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