xref: /freebsd/share/man/man4/gpioled.4 (revision 0b3105a37d7adcadcb720112fed4dc4e8040be99)
1.\" Copyright (c) 2013, Luiz Otavio O Souza <loos@FreeBSD.org>
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\"
13.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23.\" SUCH DAMAGE.
24.\"
25.\" $FreeBSD$
26.\"
27.Dd May 14, 2014
28.Dt GPIOLED 4
29.Os
30.Sh NAME
31.Nm gpioled
32.Nd GPIO LED generic device driver
33.Sh SYNOPSIS
34To compile this driver into the kernel,
35place the following lines in your
36kernel configuration file:
37.Bd -ragged -offset indent
38.Cd "device gpio"
39.Cd "device gpioled"
40.Ed
41.Sh DESCRIPTION
42The
43.Nm
44driver provides glue to attach a
45.Xr led 4
46compatible device to a GPIO pin.
47Each LED in the system has a
48.Pa name
49which is used to export a device as
50.Pa /dev/led/<name> .
51The GPIO pin can then be controlled by writing to this device as described
52in
53.Xr led 4 .
54.Pp
55On a
56.Xr device.hints 5
57based system, like
58.Li MIPS ,
59these values are configurable for
60.Nm :
61.Bl -tag -width ".Va hint.gpioiic.%d.atXXX"
62.It Va hint.gpioled.%d.at
63The gpiobus you are attaching to.
64Normally assigned to gpiobus0.
65.It Va hint.gpioled.%d.name
66Arbitrary name of device in
67.Pa /dev/led/
68to create for
69.Xr led 4 .
70.It Va hint.gpioled.%d.pins
71Which pin on the GPIO interface to map to this instance.
72Please note that this mask should only ever have one bit set
73(any other bits - i.e., pins - will be ignored).
74.El
75.Pp
76On a
77.Xr FDT 4
78based system, like
79.Li ARM ,
80the DTS part for a
81.Nm gpioled
82device usually looks like:
83.Bd -literal
84gpio: gpio {
85
86	gpio-controller;
87	...
88
89	led0 {
90		compatible = "gpioled";
91		gpios = <&gpio 16 2 0>;		/* GPIO pin 16. */
92		name = "ok";
93	};
94
95	led1 {
96		compatible = "gpioled";
97		gpios = <&gpio 17 2 0>;		/* GPIO pin 17. */
98		name = "user-led1";
99	};
100};
101.Ed
102.Pp
103Optionally, you can choose to combine all the LEDs under a single
104.Dq gpio-leds
105compatible node:
106.Bd -literal
107simplebus0 {
108
109	...
110
111	leds {
112		compatible = "gpio-leds";
113
114		led0 {
115			gpios = <&gpio 16 2 0>;
116			name = "ok"
117		};
118
119		led1 {
120			gpios = <&gpio 17 2 0>;
121			name = "user-led1"
122		};
123	};
124};
125.Ed
126.Pp
127Both methods are equally supported and it is possible to have the LEDs
128defined with any sort of mix between the methods.
129The only restriction is that a GPIO pin cannot be mapped by two different
130(gpio)leds.
131.Pp
132For more details about the
133.Va gpios
134property, please consult
135.Pa /usr/src/sys/boot/fdt/dts/bindings-gpio.txt .
136.Pp
137The property
138.Va name
139is the arbitrary name of the device in
140.Pa /dev/led/
141to create for
142.Xr led 4 .
143.Sh SEE ALSO
144.Xr fdt 4 ,
145.Xr gpio 4 ,
146.Xr gpioiic 4 ,
147.Xr led 4
148.Sh HISTORY
149The
150.Nm
151manual page first appeared in
152.Fx 10.1 .
153.Sh AUTHORS
154This
155manual page was written by
156.An Luiz Otavio O Souza .
157