xref: /freebsd/share/man/man4/gpioled.4 (revision 9a2a079a5182c4bcdd547839ff652fb4384b9a80)
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 February 13, 2014
28.Dt GPIOLED 4
29.Os
30.Sh NAME
31.Nm gpioled
32.Nd GPIO led generic device driver
33.Sh SYNOPSIS
34.Cd "device gpio"
35.Cd "device gpioled"
36.Pp
37This driver attaches a
38.Xr led 4
39device to a GPIO pin.
40.Sh DESCRIPTION
41The
42.Em gpioled
43driver provides a glue to attach a
44.Xr led 4
45compatible device to a GPIO pin.
46Each led on the system has a
47.Pa name
48which is used to export a device in
49.Pa /dev/led/<name> .
50The GPIO pin can then be controlled by writing to this device as described
51on
52.Xr led 4 .
53.Pp
54On a hint based system, like
55.Li MIPS , these values are configureable for
56.Nm :
57.Bl -tag -width ".Va hint.gpioiic.%d.atXXX"
58.It Va hint.gpioled.%d.at
59The gpiobus you are attaching to.
60Normally assigned to gpiobus0.
61.It Va hint.gpioled.%d.name
62Arbitrary name of device in
63.Pa /dev/led/
64to create for
65.Xr led 4 .
66.It Va hint.gpioled.%d.pins
67Which pin on the GPIO interface to map to this instance.
68Please note that this mask should only ever have one bit set
69(any others bits - i.e., pins - will be ignored).
70.El
71.Pp
72On a
73.Xr FDT 4
74based system, like
75.Li ARM , the dts part for a
76.Nm gpioled
77device usually looks like:
78.Bd -literal
79gpio: gpio {
80
81	gpio-controller;
82	...
83
84	led0 {
85		compatible = "gpioled";
86		gpios = <&gpio 16 2 0>;		/* GPIO pin 16. */
87		name = "ok";
88	};
89
90	led1 {
91		compatible = "gpioled";
92		gpios = <&gpio 17 2 0>;		/* GPIO pin 17. */
93		name = "user-led1";
94	};
95};
96.Ed
97.Pp
98And optionally, you can choose combine all the leds under a single
99.Dq gpio-leds
100compatible node:
101.Bd -literal
102simplebus0 {
103
104	...
105
106	leds {
107		compatible = "gpio-leds";
108
109		led0 {
110			gpios = <&gpio 16 2 0>;
111			name = "ok"
112		};
113
114		led1 {
115			gpios = <&gpio 17 2 0>;
116			name = "user-led1"
117		};
118	};
119};
120.Ed
121.Pp
122Both methods are equally supported and it is possible to have the leds
123defined with any sort of mix between the methods.
124The only restriction is that a GPIO pin cannot be mapped by two different
125(gpio)leds.
126.Pp
127For more details about the
128.Va gpios
129property, please consult
130.Pa /usr/src/sys/boot/fdt/dts/bindings-gpio.txt .
131.Pp
132The property
133.Va name
134is the arbitrary name of device in
135.Pa /dev/led/
136to create for
137.Xr led 4 .
138.Sh SEE ALSO
139.Xr fdt 4 ,
140.Xr gpio 4 ,
141.Xr led 4 ,
142.Xr gpioiic 4
143.Sh HISTORY
144The
145.Nm
146manual page first appeared in
147.Fx 11.0 .
148.Sh AUTHORS
149This
150manual page was written by
151.An Luiz Otavio O Souza .
152