xref: /freebsd/share/man/man4/gpioled.4 (revision fa9896e082a1046ff4fbc75fcba4d18d1f2efc19)
18ce07fe7SLuiz Otavio O Souza.\" Copyright (c) 2013, Luiz Otavio O Souza <loos@FreeBSD.org>
28ce07fe7SLuiz Otavio O Souza.\" All rights reserved.
38ce07fe7SLuiz Otavio O Souza.\"
48ce07fe7SLuiz Otavio O Souza.\" Redistribution and use in source and binary forms, with or without
58ce07fe7SLuiz Otavio O Souza.\" modification, are permitted provided that the following conditions
68ce07fe7SLuiz Otavio O Souza.\" are met:
78ce07fe7SLuiz Otavio O Souza.\" 1. Redistributions of source code must retain the above copyright
88ce07fe7SLuiz Otavio O Souza.\"    notice, this list of conditions and the following disclaimer.
98ce07fe7SLuiz Otavio O Souza.\" 2. Redistributions in binary form must reproduce the above copyright
108ce07fe7SLuiz Otavio O Souza.\"    notice, this list of conditions and the following disclaimer in the
118ce07fe7SLuiz Otavio O Souza.\"    documentation and/or other materials provided with the distribution.
128ce07fe7SLuiz Otavio O Souza.\"
138ce07fe7SLuiz Otavio O Souza.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
148ce07fe7SLuiz Otavio O Souza.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
158ce07fe7SLuiz Otavio O Souza.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
168ce07fe7SLuiz Otavio O Souza.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
178ce07fe7SLuiz Otavio O Souza.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
188ce07fe7SLuiz Otavio O Souza.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
198ce07fe7SLuiz Otavio O Souza.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
208ce07fe7SLuiz Otavio O Souza.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
218ce07fe7SLuiz Otavio O Souza.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
228ce07fe7SLuiz Otavio O Souza.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
238ce07fe7SLuiz Otavio O Souza.\" SUCH DAMAGE.
248ce07fe7SLuiz Otavio O Souza.\"
25694d3640SAndriy Gapon.Dd May 23, 2019
268ce07fe7SLuiz Otavio O Souza.Dt GPIOLED 4
278ce07fe7SLuiz Otavio O Souza.Os
288ce07fe7SLuiz Otavio O Souza.Sh NAME
298ce07fe7SLuiz Otavio O Souza.Nm gpioled
306a6ce390SChristian Brueffer.Nd GPIO LED generic device driver
318ce07fe7SLuiz Otavio O Souza.Sh SYNOPSIS
326a6ce390SChristian BruefferTo compile this driver into the kernel,
336a6ce390SChristian Bruefferplace the following lines in your
346a6ce390SChristian Bruefferkernel configuration file:
356a6ce390SChristian Brueffer.Bd -ragged -offset indent
368ce07fe7SLuiz Otavio O Souza.Cd "device gpio"
378ce07fe7SLuiz Otavio O Souza.Cd "device gpioled"
386a6ce390SChristian Brueffer.Ed
398ce07fe7SLuiz Otavio O Souza.Sh DESCRIPTION
408ce07fe7SLuiz Otavio O SouzaThe
416a6ce390SChristian Brueffer.Nm
426a6ce390SChristian Bruefferdriver provides glue to attach a
438ce07fe7SLuiz Otavio O Souza.Xr led 4
448ce07fe7SLuiz Otavio O Souzacompatible device to a GPIO pin.
456a6ce390SChristian BruefferEach LED in the system has a
468ce07fe7SLuiz Otavio O Souza.Pa name
476a6ce390SChristian Bruefferwhich is used to export a device as
488ce07fe7SLuiz Otavio O Souza.Pa /dev/led/<name> .
498ce07fe7SLuiz Otavio O SouzaThe GPIO pin can then be controlled by writing to this device as described
506a6ce390SChristian Bruefferin
518ce07fe7SLuiz Otavio O Souza.Xr led 4 .
528ce07fe7SLuiz Otavio O Souza.Pp
536a6ce390SChristian BruefferOn a
546a6ce390SChristian Brueffer.Xr device.hints 5
556a6ce390SChristian Bruefferbased system, like
566a6ce390SChristian Brueffer.Li MIPS ,
576a6ce390SChristian Bruefferthese values are configurable for
588ce07fe7SLuiz Otavio O Souza.Nm :
598ce07fe7SLuiz Otavio O Souza.Bl -tag -width ".Va hint.gpioiic.%d.atXXX"
608ce07fe7SLuiz Otavio O Souza.It Va hint.gpioled.%d.at
618ce07fe7SLuiz Otavio O SouzaThe gpiobus you are attaching to.
628ce07fe7SLuiz Otavio O SouzaNormally assigned to gpiobus0.
638ce07fe7SLuiz Otavio O Souza.It Va hint.gpioled.%d.name
648ce07fe7SLuiz Otavio O SouzaArbitrary name of device in
658ce07fe7SLuiz Otavio O Souza.Pa /dev/led/
668ce07fe7SLuiz Otavio O Souzato create for
678ce07fe7SLuiz Otavio O Souza.Xr led 4 .
688ce07fe7SLuiz Otavio O Souza.It Va hint.gpioled.%d.pins
698ce07fe7SLuiz Otavio O SouzaWhich pin on the GPIO interface to map to this instance.
708ce07fe7SLuiz Otavio O SouzaPlease note that this mask should only ever have one bit set
716a6ce390SChristian Brueffer(any other bits - i.e., pins - will be ignored).
72452ccc02SAdrian Chadd.It Va hint.gpioled.%d.invert
73452ccc02SAdrian ChaddIf set to 1, the pin will be set to 0 to light the LED, and 1 to clear it.
74694d3640SAndriy Gapon.It Va hint.gpioled.%d.state
75*999d5a34SAndriy GaponThe initial state of the LED when the driver takes control over it.
76694d3640SAndriy GaponIf set to 1 or 0, the LED will be on or off correspondingly.
77*999d5a34SAndriy GaponIf set to -1, the LED will be kept in its original state.
788ce07fe7SLuiz Otavio O Souza.El
799a2a079aSLuiz Otavio O Souza.Pp
809a2a079aSLuiz Otavio O SouzaOn a
819a2a079aSLuiz Otavio O Souza.Xr FDT 4
829a2a079aSLuiz Otavio O Souzabased system, like
836a6ce390SChristian Brueffer.Li ARM ,
846a6ce390SChristian Bruefferthe DTS part for a
859a2a079aSLuiz Otavio O Souza.Nm gpioled
869a2a079aSLuiz Otavio O Souzadevice usually looks like:
879a2a079aSLuiz Otavio O Souza.Bd -literal
889a2a079aSLuiz Otavio O Souzagpio: gpio {
899a2a079aSLuiz Otavio O Souza
909a2a079aSLuiz Otavio O Souza	gpio-controller;
919a2a079aSLuiz Otavio O Souza	...
929a2a079aSLuiz Otavio O Souza
939a2a079aSLuiz Otavio O Souza	led0 {
949a2a079aSLuiz Otavio O Souza		compatible = "gpioled";
959a2a079aSLuiz Otavio O Souza		gpios = <&gpio 16 2 0>;		/* GPIO pin 16. */
969a2a079aSLuiz Otavio O Souza		name = "ok";
979a2a079aSLuiz Otavio O Souza	};
989a2a079aSLuiz Otavio O Souza
999a2a079aSLuiz Otavio O Souza	led1 {
1009a2a079aSLuiz Otavio O Souza		compatible = "gpioled";
1019a2a079aSLuiz Otavio O Souza		gpios = <&gpio 17 2 0>;		/* GPIO pin 17. */
1029a2a079aSLuiz Otavio O Souza		name = "user-led1";
1039a2a079aSLuiz Otavio O Souza	};
1049a2a079aSLuiz Otavio O Souza};
1059a2a079aSLuiz Otavio O Souza.Ed
1069a2a079aSLuiz Otavio O Souza.Pp
1076a6ce390SChristian BruefferOptionally, you can choose to combine all the LEDs under a single
1089a2a079aSLuiz Otavio O Souza.Dq gpio-leds
1099a2a079aSLuiz Otavio O Souzacompatible node:
1109a2a079aSLuiz Otavio O Souza.Bd -literal
1119a2a079aSLuiz Otavio O Souzasimplebus0 {
1129a2a079aSLuiz Otavio O Souza
1139a2a079aSLuiz Otavio O Souza	...
1149a2a079aSLuiz Otavio O Souza
1159a2a079aSLuiz Otavio O Souza	leds {
1169a2a079aSLuiz Otavio O Souza		compatible = "gpio-leds";
1179a2a079aSLuiz Otavio O Souza
1189a2a079aSLuiz Otavio O Souza		led0 {
1199a2a079aSLuiz Otavio O Souza			gpios = <&gpio 16 2 0>;
1209a2a079aSLuiz Otavio O Souza			name = "ok"
1219a2a079aSLuiz Otavio O Souza		};
1229a2a079aSLuiz Otavio O Souza
1239a2a079aSLuiz Otavio O Souza		led1 {
1249a2a079aSLuiz Otavio O Souza			gpios = <&gpio 17 2 0>;
1259a2a079aSLuiz Otavio O Souza			name = "user-led1"
1269a2a079aSLuiz Otavio O Souza		};
1279a2a079aSLuiz Otavio O Souza	};
1289a2a079aSLuiz Otavio O Souza};
1299a2a079aSLuiz Otavio O Souza.Ed
1309a2a079aSLuiz Otavio O Souza.Pp
1316a6ce390SChristian BruefferBoth methods are equally supported and it is possible to have the LEDs
1329a2a079aSLuiz Otavio O Souzadefined with any sort of mix between the methods.
1339a2a079aSLuiz Otavio O SouzaThe only restriction is that a GPIO pin cannot be mapped by two different
1349a2a079aSLuiz Otavio O Souza(gpio)leds.
1359a2a079aSLuiz Otavio O Souza.Pp
1369a2a079aSLuiz Otavio O SouzaFor more details about the
1379a2a079aSLuiz Otavio O Souza.Va gpios
1389a2a079aSLuiz Otavio O Souzaproperty, please consult
1392e36db14SWarner Losh.Pa /usr/src/sys/dts/bindings-gpio.txt .
1409a2a079aSLuiz Otavio O Souza.Pp
1419a2a079aSLuiz Otavio O SouzaThe property
1429a2a079aSLuiz Otavio O Souza.Va name
1436a6ce390SChristian Bruefferis the arbitrary name of the device in
1449a2a079aSLuiz Otavio O Souza.Pa /dev/led/
1459a2a079aSLuiz Otavio O Souzato create for
1469a2a079aSLuiz Otavio O Souza.Xr led 4 .
1478ce07fe7SLuiz Otavio O Souza.Sh SEE ALSO
1489a2a079aSLuiz Otavio O Souza.Xr fdt 4 ,
1498ce07fe7SLuiz Otavio O Souza.Xr gpio 4 ,
1506a6ce390SChristian Brueffer.Xr gpioiic 4 ,
1516a6ce390SChristian Brueffer.Xr led 4
1528ce07fe7SLuiz Otavio O Souza.Sh HISTORY
1538ce07fe7SLuiz Otavio O SouzaThe
1548ce07fe7SLuiz Otavio O Souza.Nm
1558ce07fe7SLuiz Otavio O Souzamanual page first appeared in
156b6d2fa3eSLuiz Otavio O Souza.Fx 10.1 .
1578ce07fe7SLuiz Otavio O Souza.Sh AUTHORS
1588ce07fe7SLuiz Otavio O SouzaThis
1598ce07fe7SLuiz Otavio O Souzamanual page was written by
1608ce07fe7SLuiz Otavio O Souza.An Luiz Otavio O Souza .
161