summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-07-09 11:59:39 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2019-07-09 11:59:39 -0400
commit8a3367cc8005842efcefc0cb5c29780370818572 (patch)
tree1e672969fab002a1b5594d696b3bc23ca31a0986
parent6e2bbb688aa6d05073dd1dd0b836d9becec195c1 (diff)
parent2605085fba22792f3d4a6b856c7c5a05492d1fde (diff)
Merge tag 'leds-for-5.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/j.anaszewski/linux-leds
Pull LED updates from Jacek Anaszewski: - Add a new LED common module for ti-lmu driver family - Modify MFD ti-lmu bindings - add ti,brightness-resolution - add the ramp up/down property - Add regulator support for LM36274 driver to lm363x-regulator.c - New LED class drivers with DT bindings: - leds-spi-byte - leds-lm36274 - leds-lm3697 (move the support from MFD to LED subsystem) - Simplify getting the I2C adapter of a client: - leds-tca6507 - leds-pca955x - Convert LED documentation to ReST * tag 'leds-for-5.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/j.anaszewski/linux-leds: dt: leds-lm36274.txt: fix a broken reference to ti-lmu.txt docs: leds: convert to ReST leds: leds-tca6507: simplify getting the adapter of a client leds: leds-pca955x: simplify getting the adapter of a client leds: lm36274: Introduce the TI LM36274 LED driver dt-bindings: leds: Add LED bindings for the LM36274 regulator: lm363x: Add support for LM36274 mfd: ti-lmu: Add LM36274 support to the ti-lmu dt-bindings: mfd: Add lm36274 bindings to ti-lmu leds: max77650: Remove set but not used variable 'parent' leds: avoid flush_work in atomic context leds: lm3697: Introduce the lm3697 driver mfd: ti-lmu: Remove support for LM3697 dt-bindings: ti-lmu: Modify dt bindings for the LM3697 leds: TI LMU: Add common code for TI LMU devices leds: spi-byte: add single byte SPI LED driver dt-bindings: leds: Add binding for spi-byte LED. dt-bindings: mfd: LMU: Add ti,brightness-resolution dt-bindings: mfd: LMU: Add the ramp up/down property
-rw-r--r--Documentation/devicetree/bindings/leds/leds-lm36274.txt85
-rw-r--r--Documentation/devicetree/bindings/leds/leds-lm3697.txt73
-rw-r--r--Documentation/devicetree/bindings/leds/leds-spi-byte.txt44
-rw-r--r--Documentation/devicetree/bindings/mfd/ti-lmu.txt88
-rw-r--r--Documentation/laptops/thinkpad-acpi.txt4
-rw-r--r--Documentation/leds/index.rst25
-rw-r--r--Documentation/leds/leds-blinkm.rst (renamed from Documentation/leds/leds-blinkm.txt)64
-rw-r--r--Documentation/leds/leds-class-flash.rst (renamed from Documentation/leds/leds-class-flash.txt)49
-rw-r--r--Documentation/leds/leds-class.rst (renamed from Documentation/leds/leds-class.txt)15
-rw-r--r--Documentation/leds/leds-lm3556.rst (renamed from Documentation/leds/leds-lm3556.txt)100
-rw-r--r--Documentation/leds/leds-lp3944.rst (renamed from Documentation/leds/leds-lp3944.txt)23
-rw-r--r--Documentation/leds/leds-lp5521.rst115
-rw-r--r--Documentation/leds/leds-lp5521.txt101
-rw-r--r--Documentation/leds/leds-lp5523.rst147
-rw-r--r--Documentation/leds/leds-lp5523.txt130
-rw-r--r--Documentation/leds/leds-lp5562.rst137
-rw-r--r--Documentation/leds/leds-lp5562.txt120
-rw-r--r--Documentation/leds/leds-lp55xx.rst224
-rw-r--r--Documentation/leds/leds-lp55xx.txt194
-rw-r--r--Documentation/leds/leds-mlxcpld.rst118
-rw-r--r--Documentation/leds/leds-mlxcpld.txt110
-rw-r--r--Documentation/leds/ledtrig-oneshot.rst (renamed from Documentation/leds/ledtrig-oneshot.txt)11
-rw-r--r--Documentation/leds/ledtrig-transient.rst (renamed from Documentation/leds/ledtrig-transient.txt)65
-rw-r--r--Documentation/leds/ledtrig-usbport.rst (renamed from Documentation/leds/ledtrig-usbport.txt)11
-rw-r--r--Documentation/leds/uleds.rst (renamed from Documentation/leds/uleds.txt)5
-rw-r--r--MAINTAINERS2
-rw-r--r--drivers/leds/Kconfig35
-rw-r--r--drivers/leds/Makefile4
-rw-r--r--drivers/leds/leds-lm36274.c172
-rw-r--r--drivers/leds/leds-lm3697.c395
-rw-r--r--drivers/leds/leds-max77650.c2
-rw-r--r--drivers/leds/leds-pca955x.c2
-rw-r--r--drivers/leds/leds-spi-byte.c161
-rw-r--r--drivers/leds/leds-tca6507.c2
-rw-r--r--drivers/leds/leds-ti-lmu-common.c156
-rw-r--r--drivers/leds/trigger/Kconfig2
-rw-r--r--drivers/leds/trigger/ledtrig-transient.c2
-rw-r--r--drivers/mfd/Kconfig5
-rw-r--r--drivers/mfd/ti-lmu.c23
-rw-r--r--drivers/regulator/Kconfig2
-rw-r--r--drivers/regulator/lm363x-regulator.c78
-rw-r--r--include/linux/leds-ti-lmu-common.h47
-rw-r--r--include/linux/mfd/ti-lmu-register.h63
-rw-r--r--include/linux/mfd/ti-lmu.h5
-rw-r--r--net/netfilter/Kconfig2
45 files changed, 2350 insertions, 868 deletions
diff --git a/Documentation/devicetree/bindings/leds/leds-lm36274.txt b/Documentation/devicetree/bindings/leds/leds-lm36274.txt
new file mode 100644
index 000000000000..39c230d59a4d
--- /dev/null
+++ b/Documentation/devicetree/bindings/leds/leds-lm36274.txt
@@ -0,0 +1,85 @@
1* Texas Instruments LM36274 4-Channel LCD Backlight Driver w/Integrated Bias
2
3The LM36274 is an integrated four-channel WLED driver and LCD bias supply.
4The backlight boost provides the power to bias four parallel LED strings with
5up to 29V total output voltage. The 11-bit LED current is programmable via
6the I2C bus and/or controlled via a logic level PWM input from 60 uA to 30 mA.
7
8Parent device properties are documented in
9Documentation/devicetree/bindings/mfd/ti-lmu.txt
10
11Regulator properties are documented in
12Documentation/devicetree/bindings/regulator/lm363x-regulator.txt
13
14Required backlight properties:
15 - compatible:
16 "ti,lm36274-backlight"
17 - reg : 0
18 - #address-cells : 1
19 - #size-cells : 0
20 - led-sources : Indicates which LED strings will be enabled.
21 Values from 0-3, sources is 0 based so strings will be
22 source value + 1.
23
24Optional backlight properties:
25 - label : see Documentation/devicetree/bindings/leds/common.txt
26 - linux,default-trigger :
27 see Documentation/devicetree/bindings/leds/common.txt
28
29Example:
30
31HVLED string 1 and 3 are controlled by control bank A and HVLED 2 string is
32controlled by control bank B.
33
34lm36274@11 {
35 compatible = "ti,lm36274";
36 #address-cells = <1>;
37 #size-cells = <0>;
38 reg = <0x11>;
39
40 enable-gpios = <&gpio1 28 GPIO_ACTIVE_HIGH>;
41
42 regulators {
43 #address-cells = <1>;
44 #size-cells = <0>;
45 compatible = "ti,lm363x-regulator";
46
47 enable-gpios = <&pioC 0 GPIO_ACTIVE_HIGH>,
48 <&pioC 1 GPIO_ACTIVE_HIGH>;
49
50 vboost {
51 regulator-name = "lcd_boost";
52 regulator-min-microvolt = <4000000>;
53 regulator-max-microvolt = <7150000>;
54 regulator-always-on;
55 };
56
57 vpos {
58 regulator-name = "lcd_vpos";
59 regulator-min-microvolt = <4000000>;
60 regulator-max-microvolt = <6500000>;
61 };
62
63 vneg {
64 regulator-name = "lcd_vneg";
65 regulator-min-microvolt = <4000000>;
66 regulator-max-microvolt = <6500000>;
67 };
68 };
69
70 backlight {
71 #address-cells = <1>;
72 #size-cells = <0>;
73 compatible = "ti,lm36274-backlight";
74
75 led@0 {
76 reg = <0>;
77 led-sources = <0 2>;
78 label = "white:backlight_cluster";
79 linux,default-trigger = "backlight";
80 };
81 };
82};
83
84For more product information please see the link below:
85http://www.ti.com/lit/ds/symlink/lm36274.pdf
diff --git a/Documentation/devicetree/bindings/leds/leds-lm3697.txt b/Documentation/devicetree/bindings/leds/leds-lm3697.txt
new file mode 100644
index 000000000000..63992d732959
--- /dev/null
+++ b/Documentation/devicetree/bindings/leds/leds-lm3697.txt
@@ -0,0 +1,73 @@
1* Texas Instruments - LM3697 Highly Efficient White LED Driver
2
3The LM3697 11-bit LED driver provides high-
4performance backlight dimming for 1, 2, or 3 series
5LED strings while delivering up to 90% efficiency.
6
7This device is suitable for display and keypad lighting
8
9Required properties:
10 - compatible:
11 "ti,lm3697"
12 - reg : I2C slave address
13 - #address-cells : 1
14 - #size-cells : 0
15
16Optional properties:
17 - enable-gpios : GPIO pin to enable/disable the device
18 - vled-supply : LED supply
19
20Required child properties:
21 - reg : 0 - LED is Controlled by bank A
22 1 - LED is Controlled by bank B
23 - led-sources : Indicates which HVLED string is associated to which
24 control bank. This is a zero based property so
25 HVLED1 = 0, HVLED2 = 1, HVLED3 = 2.
26 Additional information is contained
27 in Documentation/devicetree/bindings/leds/common.txt
28
29Optional child properties:
30 - ti,brightness-resolution - see Documentation/devicetree/bindings/mfd/ti-lmu.txt
31 - ramp-up-us: see Documentation/devicetree/bindings/mfd/ti-lmu.txt
32 - ramp-down-us: see Documentation/devicetree/bindings/mfd/ti-lmu.txt
33 - label : see Documentation/devicetree/bindings/leds/common.txt
34 - linux,default-trigger :
35 see Documentation/devicetree/bindings/leds/common.txt
36
37Example:
38
39HVLED string 1 and 3 are controlled by control bank A and HVLED 2 string is
40controlled by control bank B.
41
42led-controller@36 {
43 compatible = "ti,lm3697";
44 #address-cells = <1>;
45 #size-cells = <0>;
46 reg = <0x36>;
47
48 enable-gpios = <&gpio1 28 GPIO_ACTIVE_HIGH>;
49 vled-supply = <&vbatt>;
50
51 led@0 {
52 reg = <0>;
53 led-sources = <0 2>;
54 ti,brightness-resolution = <2047>;
55 ramp-up-us = <5000>;
56 ramp-down-us = <1000>;
57 label = "white:first_backlight_cluster";
58 linux,default-trigger = "backlight";
59 };
60
61 led@1 {
62 reg = <1>;
63 led-sources = <1>;
64 ti,brightness-resolution = <255>;
65 ramp-up-us = <500>;
66 ramp-down-us = <1000>;
67 label = "white:second_backlight_cluster";
68 linux,default-trigger = "backlight";
69 };
70}
71
72For more product information please see the link below:
73http://www.ti.com/lit/ds/symlink/lm3697.pdf
diff --git a/Documentation/devicetree/bindings/leds/leds-spi-byte.txt b/Documentation/devicetree/bindings/leds/leds-spi-byte.txt
new file mode 100644
index 000000000000..28b6b2d9091e
--- /dev/null
+++ b/Documentation/devicetree/bindings/leds/leds-spi-byte.txt
@@ -0,0 +1,44 @@
1* Single Byte SPI LED Device Driver.
2
3The driver can be used for controllers with a very simple SPI protocol:
4- one LED is controlled by a single byte on MOSI
5- the value of the byte gives the brightness between two values (lowest to
6 highest)
7- no return value is necessary (no MISO signal)
8
9The value for lowest and highest brightness is dependent on the device and
10therefore on the compatible string.
11
12Depending on the compatible string some special functions (like hardware
13accelerated blinking) might can be supported too.
14
15The driver currently only supports one LED. The properties of the LED are
16configured in a sub-node in the device node.
17
18Required properties:
19- compatible: should be one of
20 * "ubnt,acb-spi-led" microcontroller (SONiX 8F26E611LA) based device
21 used for example in Ubiquiti airCube ISP
22
23Property rules described in Documentation/devicetree/bindings/spi/spi-bus.txt
24apply.
25
26LED sub-node properties:
27- label:
28 see Documentation/devicetree/bindings/leds/common.txt
29- default-state:
30 see Documentation/devicetree/bindings/leds/common.txt
31 Only "on" and "off" are supported.
32
33Example:
34
35led-controller@0 {
36 compatible = "ubnt,acb-spi-led";
37 reg = <0>;
38 spi-max-frequency = <100000>;
39
40 led {
41 label = "white:status";
42 default-state = "on";
43 };
44};
diff --git a/Documentation/devicetree/bindings/mfd/ti-lmu.txt b/Documentation/devicetree/bindings/mfd/ti-lmu.txt
index 86ca786d54fc..2296b8f24de4 100644
--- a/Documentation/devicetree/bindings/mfd/ti-lmu.txt
+++ b/Documentation/devicetree/bindings/mfd/ti-lmu.txt
@@ -8,7 +8,7 @@ TI LMU driver supports lighting devices below.
8 LM3632 Backlight and regulator 8 LM3632 Backlight and regulator
9 LM3633 Backlight, LED and fault monitor 9 LM3633 Backlight, LED and fault monitor
10 LM3695 Backlight 10 LM3695 Backlight
11 LM3697 Backlight and fault monitor 11 LM36274 Backlight and regulator
12 12
13Required properties: 13Required properties:
14 - compatible: Should be one of: 14 - compatible: Should be one of:
@@ -16,15 +16,32 @@ Required properties:
16 "ti,lm3632" 16 "ti,lm3632"
17 "ti,lm3633" 17 "ti,lm3633"
18 "ti,lm3695" 18 "ti,lm3695"
19 "ti,lm3697" 19 "ti,lm36274"
20 - reg: I2C slave address. 20 - reg: I2C slave address.
21 0x11 for LM3632 21 0x11 for LM3632
22 0x29 for LM3631 22 0x29 for LM3631
23 0x36 for LM3633, LM3697 23 0x36 for LM3633
24 0x63 for LM3695 24 0x63 for LM3695
25 0x11 for LM36274
25 26
26Optional property: 27Optional properties:
27 - enable-gpios: A GPIO specifier for hardware enable pin. 28 - enable-gpios: A GPIO specifier for hardware enable pin.
29 - ramp-up-us: Current ramping from one brightness level to
30 the a higher brightness level.
31 Range from 2048 us - 117.44 s
32 - ramp-down-us: Current ramping from one brightness level to
33 the a lower brightness level.
34 Range from 2048 us - 117.44 s
35 - ti,brightness-resolution - This determines whether to use 8 bit brightness
36 mode or 11 bit brightness mode. If this value is
37 not set the device is defaulted to the preferred
38 8bit brightness mode per 7.3.4.1 of the data
39 sheet. This setting can either be in the parent
40 node or as part of the LED child nodes. This
41 is determined by the part itself if the strings
42 have a common brightness register or individual
43 brightness registers.
44 The values are 255 (8bit) or 2047 (11bit).
28 45
29Required node: 46Required node:
30 - backlight: All LMU devices have backlight child nodes. 47 - backlight: All LMU devices have backlight child nodes.
@@ -35,14 +52,15 @@ Optional nodes:
35 Required properties: 52 Required properties:
36 - compatible: Should be one of: 53 - compatible: Should be one of:
37 "ti,lm3633-fault-monitor" 54 "ti,lm3633-fault-monitor"
38 "ti,lm3697-fault-monitor"
39 - leds: LED properties for LM3633. Please refer to [2]. 55 - leds: LED properties for LM3633. Please refer to [2].
56 LED properties for LM36274. Please refer to [4].
40 - regulators: Regulator properties for LM3631 and LM3632. 57 - regulators: Regulator properties for LM3631 and LM3632.
41 Please refer to [3]. 58 Please refer to [3].
42 59
43[1] ../leds/backlight/ti-lmu-backlight.txt 60[1] ../leds/backlight/ti-lmu-backlight.txt
44[2] ../leds/leds-lm3633.txt 61[2] ../leds/leds-lm3633.txt
45[3] ../regulator/lm363x-regulator.txt 62[3] ../regulator/lm363x-regulator.txt
63[4] ../leds/leds-lm36274.txt
46 64
47lm3631@29 { 65lm3631@29 {
48 compatible = "ti,lm3631"; 66 compatible = "ti,lm3631";
@@ -90,7 +108,7 @@ lm3631@29 {
90 108
91 lcd_bl { 109 lcd_bl {
92 led-sources = <0 1>; 110 led-sources = <0 1>;
93 ramp-up-msec = <300>; 111 ramp-up-us = <300000>;
94 }; 112 };
95 }; 113 };
96}; 114};
@@ -152,15 +170,15 @@ lm3633@36 {
152 main { 170 main {
153 label = "main_lcd"; 171 label = "main_lcd";
154 led-sources = <1 2>; 172 led-sources = <1 2>;
155 ramp-up-msec = <500>; 173 ramp-up-us = <500000>;
156 ramp-down-msec = <500>; 174 ramp-down-us = <500000>;
157 }; 175 };
158 176
159 front { 177 front {
160 label = "front_lcd"; 178 label = "front_lcd";
161 led-sources = <0>; 179 led-sources = <0>;
162 ramp-up-msec = <1000>; 180 ramp-up-us = <1000000>;
163 ramp-down-msec = <0>; 181 ramp-down-us = <0>;
164 }; 182 };
165 }; 183 };
166 184
@@ -201,23 +219,51 @@ lm3695@63 {
201 }; 219 };
202}; 220};
203 221
204lm3697@36 { 222lm36274@11 {
205 compatible = "ti,lm3697"; 223 compatible = "ti,lm36274";
206 reg = <0x36>; 224 #address-cells = <1>;
225 #size-cells = <0>;
226 reg = <0x11>;
207 227
208 enable-gpios = <&pioC 2 GPIO_ACTIVE_HIGH>; 228 enable-gpios = <&pioC 2 GPIO_ACTIVE_HIGH>;
229 regulators {
230 #address-cells = <1>;
231 #size-cells = <0>;
232 compatible = "ti,lm363x-regulator";
209 233
210 backlight { 234 enable-gpios = <&pioC 0 GPIO_ACTIVE_HIGH>,
211 compatible = "ti,lm3697-backlight"; 235 <&pioC 1 GPIO_ACTIVE_HIGH>;
212 236
213 lcd { 237 vboost {
214 led-sources = <0 1 2>; 238 regulator-name = "lcd_boost";
215 ramp-up-msec = <200>; 239 regulator-min-microvolt = <4000000>;
216 ramp-down-msec = <200>; 240 regulator-max-microvolt = <7150000>;
241 regulator-always-on;
242 };
243
244 vpos {
245 regulator-name = "lcd_vpos";
246 regulator-min-microvolt = <4000000>;
247 regulator-max-microvolt = <6500000>;
248 };
249
250 vneg {
251 regulator-name = "lcd_vneg";
252 regulator-min-microvolt = <4000000>;
253 regulator-max-microvolt = <6500000>;
217 }; 254 };
218 }; 255 };
219 256
220 fault-monitor { 257 backlight {
221 compatible = "ti,lm3697-fault-monitor"; 258 #address-cells = <1>;
259 #size-cells = <0>;
260 compatible = "ti,lm36274-backlight";
261
262 led@0 {
263 reg = <0>;
264 led-sources = <0 2>;
265 label = "white:backlight_cluster";
266 linux,default-trigger = "backlight";
267 };
222 }; 268 };
223}; 269};
diff --git a/Documentation/laptops/thinkpad-acpi.txt b/Documentation/laptops/thinkpad-acpi.txt
index 6cced88de6da..75ef063622d2 100644
--- a/Documentation/laptops/thinkpad-acpi.txt
+++ b/Documentation/laptops/thinkpad-acpi.txt
@@ -679,7 +679,7 @@ status as "unknown". The available commands are:
679sysfs notes: 679sysfs notes:
680 680
681The ThinkLight sysfs interface is documented by the LED class 681The ThinkLight sysfs interface is documented by the LED class
682documentation, in Documentation/leds/leds-class.txt. The ThinkLight LED name 682documentation, in Documentation/leds/leds-class.rst. The ThinkLight LED name
683is "tpacpi::thinklight". 683is "tpacpi::thinklight".
684 684
685Due to limitations in the sysfs LED class, if the status of the ThinkLight 685Due to limitations in the sysfs LED class, if the status of the ThinkLight
@@ -779,7 +779,7 @@ All of the above can be turned on and off and can be made to blink.
779sysfs notes: 779sysfs notes:
780 780
781The ThinkPad LED sysfs interface is described in detail by the LED class 781The ThinkPad LED sysfs interface is described in detail by the LED class
782documentation, in Documentation/leds/leds-class.txt. 782documentation, in Documentation/leds/leds-class.rst.
783 783
784The LEDs are named (in LED ID order, from 0 to 12): 784The LEDs are named (in LED ID order, from 0 to 12):
785"tpacpi::power", "tpacpi:orange:batt", "tpacpi:green:batt", 785"tpacpi::power", "tpacpi:orange:batt", "tpacpi:green:batt",
diff --git a/Documentation/leds/index.rst b/Documentation/leds/index.rst
new file mode 100644
index 000000000000..9885f7c1b75d
--- /dev/null
+++ b/Documentation/leds/index.rst
@@ -0,0 +1,25 @@
1:orphan:
2
3====
4LEDs
5====
6
7.. toctree::
8 :maxdepth: 1
9
10 leds-class
11 leds-class-flash
12 ledtrig-oneshot
13 ledtrig-transient
14 ledtrig-usbport
15
16 uleds
17
18 leds-blinkm
19 leds-lm3556
20 leds-lp3944
21 leds-lp5521
22 leds-lp5523
23 leds-lp5562
24 leds-lp55xx
25 leds-mlxcpld
diff --git a/Documentation/leds/leds-blinkm.txt b/Documentation/leds/leds-blinkm.rst
index 9dd92f4cf4e1..c74b5bc877b1 100644
--- a/Documentation/leds/leds-blinkm.txt
+++ b/Documentation/leds/leds-blinkm.rst
@@ -1,3 +1,7 @@
1==================
2Leds BlinkM driver
3==================
4
1The leds-blinkm driver supports the devices of the BlinkM family. 5The leds-blinkm driver supports the devices of the BlinkM family.
2 6
3They are RGB-LED modules driven by a (AT)tiny microcontroller and 7They are RGB-LED modules driven by a (AT)tiny microcontroller and
@@ -14,35 +18,36 @@ The interface this driver provides is 2-fold:
14a) LED class interface for use with triggers 18a) LED class interface for use with triggers
15############################################ 19############################################
16 20
17The registration follows the scheme: 21The registration follows the scheme::
18blinkm-<i2c-bus-nr>-<i2c-device-nr>-<color> 22
23 blinkm-<i2c-bus-nr>-<i2c-device-nr>-<color>
19 24
20$ ls -h /sys/class/leds/blinkm-6-* 25 $ ls -h /sys/class/leds/blinkm-6-*
21/sys/class/leds/blinkm-6-9-blue: 26 /sys/class/leds/blinkm-6-9-blue:
22brightness device max_brightness power subsystem trigger uevent 27 brightness device max_brightness power subsystem trigger uevent
23 28
24/sys/class/leds/blinkm-6-9-green: 29 /sys/class/leds/blinkm-6-9-green:
25brightness device max_brightness power subsystem trigger uevent 30 brightness device max_brightness power subsystem trigger uevent
26 31
27/sys/class/leds/blinkm-6-9-red: 32 /sys/class/leds/blinkm-6-9-red:
28brightness device max_brightness power subsystem trigger uevent 33 brightness device max_brightness power subsystem trigger uevent
29 34
30(same is /sys/bus/i2c/devices/6-0009/leds) 35(same is /sys/bus/i2c/devices/6-0009/leds)
31 36
32We can control the colors separated into red, green and blue and 37We can control the colors separated into red, green and blue and
33assign triggers on each color. 38assign triggers on each color.
34 39
35E.g.: 40E.g.::
36 41
37$ cat blinkm-6-9-blue/brightness 42 $ cat blinkm-6-9-blue/brightness
3805 43 05
39 44
40$ echo 200 > blinkm-6-9-blue/brightness 45 $ echo 200 > blinkm-6-9-blue/brightness
41$ 46 $
42 47
43$ modprobe ledtrig-heartbeat 48 $ modprobe ledtrig-heartbeat
44$ echo heartbeat > blinkm-6-9-green/trigger 49 $ echo heartbeat > blinkm-6-9-green/trigger
45$ 50 $
46 51
47 52
48b) Sysfs group to control rgb, fade, hsb, scripts ... 53b) Sysfs group to control rgb, fade, hsb, scripts ...
@@ -52,29 +57,28 @@ This extended interface is available as folder blinkm
52in the sysfs folder of the I2C device. 57in the sysfs folder of the I2C device.
53E.g. below /sys/bus/i2c/devices/6-0009/blinkm 58E.g. below /sys/bus/i2c/devices/6-0009/blinkm
54 59
55$ ls -h /sys/bus/i2c/devices/6-0009/blinkm/ 60 $ ls -h /sys/bus/i2c/devices/6-0009/blinkm/
56blue green red test 61 blue green red test
57 62
58Currently supported is just setting red, green, blue 63Currently supported is just setting red, green, blue
59and a test sequence. 64and a test sequence.
60 65
61E.g.: 66E.g.::
62 67
63$ cat * 68 $ cat *
6400 69 00
6500 70 00
6600 71 00
67#Write into test to start test sequence!# 72 #Write into test to start test sequence!#
68 73
69$ echo 1 > test 74 $ echo 1 > test
70$ 75 $
71 76
72$ echo 255 > red 77 $ echo 255 > red
73$ 78 $
74 79
75 80
76 81
77as of 6/2012 82as of 6/2012
78 83
79dl9pf <at> gmx <dot> de 84dl9pf <at> gmx <dot> de
80
diff --git a/Documentation/leds/leds-class-flash.txt b/Documentation/leds/leds-class-flash.rst
index 8da3c6f4b60b..6ec12c5a1a0e 100644
--- a/Documentation/leds/leds-class-flash.txt
+++ b/Documentation/leds/leds-class-flash.rst
@@ -1,9 +1,9 @@
1 1==============================
2Flash LED handling under Linux 2Flash LED handling under Linux
3============================== 3==============================
4 4
5Some LED devices provide two modes - torch and flash. In the LED subsystem 5Some LED devices provide two modes - torch and flash. In the LED subsystem
6those modes are supported by LED class (see Documentation/leds/leds-class.txt) 6those modes are supported by LED class (see Documentation/leds/leds-class.rst)
7and LED Flash class respectively. The torch mode related features are enabled 7and LED Flash class respectively. The torch mode related features are enabled
8by default and the flash ones only if a driver declares it by setting 8by default and the flash ones only if a driver declares it by setting
9LED_DEV_CAP_FLASH flag. 9LED_DEV_CAP_FLASH flag.
@@ -14,6 +14,7 @@ registered in the LED subsystem with led_classdev_flash_register function.
14 14
15Following sysfs attributes are exposed for controlling flash LED devices: 15Following sysfs attributes are exposed for controlling flash LED devices:
16(see Documentation/ABI/testing/sysfs-class-led-flash) 16(see Documentation/ABI/testing/sysfs-class-led-flash)
17
17 - flash_brightness 18 - flash_brightness
18 - max_flash_brightness 19 - max_flash_brightness
19 - flash_timeout 20 - flash_timeout
@@ -31,30 +32,46 @@ be defined in the kernel config.
31 32
32The driver must call the v4l2_flash_init function to get registered in the 33The driver must call the v4l2_flash_init function to get registered in the
33V4L2 subsystem. The function takes six arguments: 34V4L2 subsystem. The function takes six arguments:
34- dev : flash device, e.g. an I2C device 35
35- of_node : of_node of the LED, may be NULL if the same as device's 36- dev:
36- fled_cdev : LED flash class device to wrap 37 flash device, e.g. an I2C device
37- iled_cdev : LED flash class device representing indicator LED associated with 38- of_node:
38 fled_cdev, may be NULL 39 of_node of the LED, may be NULL if the same as device's
39- ops : V4L2 specific ops 40- fled_cdev:
40 * external_strobe_set - defines the source of the flash LED strobe - 41 LED flash class device to wrap
42- iled_cdev:
43 LED flash class device representing indicator LED associated with
44 fled_cdev, may be NULL
45- ops:
46 V4L2 specific ops
47
48 * external_strobe_set
49 defines the source of the flash LED strobe -
41 V4L2_CID_FLASH_STROBE control or external source, typically 50 V4L2_CID_FLASH_STROBE control or external source, typically
42 a sensor, which makes it possible to synchronise the flash 51 a sensor, which makes it possible to synchronise the flash
43 strobe start with exposure start, 52 strobe start with exposure start,
44 * intensity_to_led_brightness and led_brightness_to_intensity - perform 53 * intensity_to_led_brightness and led_brightness_to_intensity
54 perform
45 enum led_brightness <-> V4L2 intensity conversion in a device 55 enum led_brightness <-> V4L2 intensity conversion in a device
46 specific manner - they can be used for devices with non-linear 56 specific manner - they can be used for devices with non-linear
47 LED current scale. 57 LED current scale.
48- config : configuration for V4L2 Flash sub-device 58- config:
49 * dev_name - the name of the media entity, unique in the system, 59 configuration for V4L2 Flash sub-device
50 * flash_faults - bitmask of flash faults that the LED flash class 60
61 * dev_name
62 the name of the media entity, unique in the system,
63 * flash_faults
64 bitmask of flash faults that the LED flash class
51 device can report; corresponding LED_FAULT* bit definitions are 65 device can report; corresponding LED_FAULT* bit definitions are
52 available in <linux/led-class-flash.h>, 66 available in <linux/led-class-flash.h>,
53 * torch_intensity - constraints for the LED in TORCH mode 67 * torch_intensity
68 constraints for the LED in TORCH mode
54 in microamperes, 69 in microamperes,
55 * indicator_intensity - constraints for the indicator LED 70 * indicator_intensity
71 constraints for the indicator LED
56 in microamperes, 72 in microamperes,
57 * has_external_strobe - determines whether the flash strobe source 73 * has_external_strobe
74 determines whether the flash strobe source
58 can be switched to external, 75 can be switched to external,
59 76
60On remove the v4l2_flash_release function has to be called, which takes one 77On remove the v4l2_flash_release function has to be called, which takes one
diff --git a/Documentation/leds/leds-class.txt b/Documentation/leds/leds-class.rst
index 8b39cc6b03ee..df0120a1ee3c 100644
--- a/Documentation/leds/leds-class.txt
+++ b/Documentation/leds/leds-class.rst
@@ -1,4 +1,4 @@
1 1========================
2LED handling under Linux 2LED handling under Linux
3======================== 3========================
4 4
@@ -43,7 +43,7 @@ LED Device Naming
43 43
44Is currently of the form: 44Is currently of the form:
45 45
46"devicename:colour:function" 46 "devicename:colour:function"
47 47
48There have been calls for LED properties such as colour to be exported as 48There have been calls for LED properties such as colour to be exported as
49individual led class attributes. As a solution which doesn't incur as much 49individual led class attributes. As a solution which doesn't incur as much
@@ -57,9 +57,12 @@ Brightness setting API
57 57
58LED subsystem core exposes following API for setting brightness: 58LED subsystem core exposes following API for setting brightness:
59 59
60 - led_set_brightness : it is guaranteed not to sleep, passing LED_OFF stops 60 - led_set_brightness:
61 it is guaranteed not to sleep, passing LED_OFF stops
61 blinking, 62 blinking,
62 - led_set_brightness_sync : for use cases when immediate effect is desired - 63
64 - led_set_brightness_sync:
65 for use cases when immediate effect is desired -
63 it can block the caller for the time required for accessing 66 it can block the caller for the time required for accessing
64 device registers and can sleep, passing LED_OFF stops hardware 67 device registers and can sleep, passing LED_OFF stops hardware
65 blinking, returns -EBUSY if software blink fallback is enabled. 68 blinking, returns -EBUSY if software blink fallback is enabled.
@@ -70,7 +73,7 @@ LED registration API
70 73
71A driver wanting to register a LED classdev for use by other drivers / 74A driver wanting to register a LED classdev for use by other drivers /
72userspace needs to allocate and fill a led_classdev struct and then call 75userspace needs to allocate and fill a led_classdev struct and then call
73[devm_]led_classdev_register. If the non devm version is used the driver 76`[devm_]led_classdev_register`. If the non devm version is used the driver
74must call led_classdev_unregister from its remove function before 77must call led_classdev_unregister from its remove function before
75free-ing the led_classdev struct. 78free-ing the led_classdev struct.
76 79
@@ -94,7 +97,7 @@ with brightness value LED_OFF, which should stop any software
94timers that may have been required for blinking. 97timers that may have been required for blinking.
95 98
96The blink_set() function should choose a user friendly blinking value 99The blink_set() function should choose a user friendly blinking value
97if it is called with *delay_on==0 && *delay_off==0 parameters. In this 100if it is called with `*delay_on==0` && `*delay_off==0` parameters. In this
98case the driver should give back the chosen value through delay_on and 101case the driver should give back the chosen value through delay_on and
99delay_off parameters to the leds subsystem. 102delay_off parameters to the leds subsystem.
100 103
diff --git a/Documentation/leds/leds-lm3556.txt b/Documentation/leds/leds-lm3556.rst
index 62278e871b50..1ef17d7d800e 100644
--- a/Documentation/leds/leds-lm3556.txt
+++ b/Documentation/leds/leds-lm3556.rst
@@ -1,68 +1,118 @@
1========================
1Kernel driver for lm3556 2Kernel driver for lm3556
2======================== 3========================
3 4
4*Texas Instrument: 5* Texas Instrument:
5 1.5 A Synchronous Boost LED Flash Driver w/ High-Side Current Source 6 1.5 A Synchronous Boost LED Flash Driver w/ High-Side Current Source
6* Datasheet: http://www.national.com/ds/LM/LM3556.pdf 7* Datasheet: http://www.national.com/ds/LM/LM3556.pdf
7 8
8Authors: 9Authors:
9 Daniel Jeong 10 - Daniel Jeong
11
10 Contact:Daniel Jeong(daniel.jeong-at-ti.com, gshark.jeong-at-gmail.com) 12 Contact:Daniel Jeong(daniel.jeong-at-ti.com, gshark.jeong-at-gmail.com)
11 13
12Description 14Description
13----------- 15-----------
14There are 3 functions in LM3556, Flash, Torch and Indicator. 16There are 3 functions in LM3556, Flash, Torch and Indicator.
15 17
16FLASH MODE 18Flash Mode
19^^^^^^^^^^
20
17In Flash Mode, the LED current source(LED) provides 16 target current levels 21In Flash Mode, the LED current source(LED) provides 16 target current levels
18from 93.75 mA to 1500 mA.The Flash currents are adjusted via the CURRENT 22from 93.75 mA to 1500 mA.The Flash currents are adjusted via the CURRENT
19CONTROL REGISTER(0x09).Flash mode is activated by the ENABLE REGISTER(0x0A), 23CONTROL REGISTER(0x09).Flash mode is activated by the ENABLE REGISTER(0x0A),
20or by pulling the STROBE pin HIGH. 24or by pulling the STROBE pin HIGH.
25
21LM3556 Flash can be controlled through sys/class/leds/flash/brightness file 26LM3556 Flash can be controlled through sys/class/leds/flash/brightness file
27
22* if STROBE pin is enabled, below example control brightness only, and 28* if STROBE pin is enabled, below example control brightness only, and
23ON / OFF will be controlled by STROBE pin. 29 ON / OFF will be controlled by STROBE pin.
24 30
25Flash Example: 31Flash Example:
26OFF : #echo 0 > sys/class/leds/flash/brightness
2793.75 mA: #echo 1 > sys/class/leds/flash/brightness
28... .....
291500 mA: #echo 16 > sys/class/leds/flash/brightness
30 32
31TORCH MODE 33OFF::
34
35 #echo 0 > sys/class/leds/flash/brightness
36
3793.75 mA::
38
39 #echo 1 > sys/class/leds/flash/brightness
40
41...
42
431500 mA::
44
45 #echo 16 > sys/class/leds/flash/brightness
46
47Torch Mode
48^^^^^^^^^^
49
32In Torch Mode, the current source(LED) is programmed via the CURRENT CONTROL 50In Torch Mode, the current source(LED) is programmed via the CURRENT CONTROL
33REGISTER(0x09).Torch Mode is activated by the ENABLE REGISTER(0x0A) or by the 51REGISTER(0x09).Torch Mode is activated by the ENABLE REGISTER(0x0A) or by the
34hardware TORCH input. 52hardware TORCH input.
53
35LM3556 torch can be controlled through sys/class/leds/torch/brightness file. 54LM3556 torch can be controlled through sys/class/leds/torch/brightness file.
36* if TORCH pin is enabled, below example control brightness only, 55* if TORCH pin is enabled, below example control brightness only,
37and ON / OFF will be controlled by TORCH pin. 56and ON / OFF will be controlled by TORCH pin.
38 57
39Torch Example: 58Torch Example:
40OFF : #echo 0 > sys/class/leds/torch/brightness
4146.88 mA: #echo 1 > sys/class/leds/torch/brightness
42... .....
43375 mA : #echo 8 > sys/class/leds/torch/brightness
44 59
45INDICATOR MODE 60OFF::
61
62 #echo 0 > sys/class/leds/torch/brightness
63
6446.88 mA::
65
66 #echo 1 > sys/class/leds/torch/brightness
67
68...
69
70375 mA::
71
72 #echo 8 > sys/class/leds/torch/brightness
73
74Indicator Mode
75^^^^^^^^^^^^^^
76
46Indicator pattern can be set through sys/class/leds/indicator/pattern file, 77Indicator pattern can be set through sys/class/leds/indicator/pattern file,
47and 4 patterns are pre-defined in indicator_pattern array. 78and 4 patterns are pre-defined in indicator_pattern array.
79
48According to N-lank, Pulse time and N Period values, different pattern wiill 80According to N-lank, Pulse time and N Period values, different pattern wiill
49be generated.If you want new patterns for your own device, change 81be generated.If you want new patterns for your own device, change
50indicator_pattern array with your own values and INDIC_PATTERN_SIZE. 82indicator_pattern array with your own values and INDIC_PATTERN_SIZE.
83
51Please refer datasheet for more detail about N-Blank, Pulse time and N Period. 84Please refer datasheet for more detail about N-Blank, Pulse time and N Period.
52 85
53Indicator pattern example: 86Indicator pattern example:
54pattern 0: #echo 0 > sys/class/leds/indicator/pattern 87
55.... 88pattern 0::
56pattern 3: #echo 3 > sys/class/leds/indicator/pattern 89
90 #echo 0 > sys/class/leds/indicator/pattern
91
92...
93
94pattern 3::
95
96 #echo 3 > sys/class/leds/indicator/pattern
57 97
58Indicator brightness can be controlled through 98Indicator brightness can be controlled through
59sys/class/leds/indicator/brightness file. 99sys/class/leds/indicator/brightness file.
60 100
61Example: 101Example:
62OFF : #echo 0 > sys/class/leds/indicator/brightness 102
635.86 mA : #echo 1 > sys/class/leds/indicator/brightness 103OFF::
64........ 104
6546.875mA : #echo 8 > sys/class/leds/indicator/brightness 105 #echo 0 > sys/class/leds/indicator/brightness
106
1075.86 mA::
108
109 #echo 1 > sys/class/leds/indicator/brightness
110
111...
112
11346.875mA::
114
115 #echo 8 > sys/class/leds/indicator/brightness
66 116
67Notes 117Notes
68----- 118-----
@@ -70,7 +120,8 @@ Driver expects it is registered using the i2c_board_info mechanism.
70To register the chip at address 0x63 on specific adapter, set the platform data 120To register the chip at address 0x63 on specific adapter, set the platform data
71according to include/linux/platform_data/leds-lm3556.h, set the i2c board info 121according to include/linux/platform_data/leds-lm3556.h, set the i2c board info
72 122
73Example: 123Example::
124
74 static struct i2c_board_info board_i2c_ch4[] __initdata = { 125 static struct i2c_board_info board_i2c_ch4[] __initdata = {
75 { 126 {
76 I2C_BOARD_INFO(LM3556_NAME, 0x63), 127 I2C_BOARD_INFO(LM3556_NAME, 0x63),
@@ -80,6 +131,7 @@ Example:
80 131
81and register it in the platform init function 132and register it in the platform init function
82 133
83Example: 134Example::
135
84 board_register_i2c_bus(4, 400, 136 board_register_i2c_bus(4, 400,
85 board_i2c_ch4, ARRAY_SIZE(board_i2c_ch4)); 137 board_i2c_ch4, ARRAY_SIZE(board_i2c_ch4));
diff --git a/Documentation/leds/leds-lp3944.txt b/Documentation/leds/leds-lp3944.rst
index e88ac3b60c08..c2f87dc1a3a9 100644
--- a/Documentation/leds/leds-lp3944.txt
+++ b/Documentation/leds/leds-lp3944.rst
@@ -1,14 +1,20 @@
1====================
1Kernel driver lp3944 2Kernel driver lp3944
2==================== 3====================
3 4
4 * National Semiconductor LP3944 Fun-light Chip 5 * National Semiconductor LP3944 Fun-light Chip
6
5 Prefix: 'lp3944' 7 Prefix: 'lp3944'
8
6 Addresses scanned: None (see the Notes section below) 9 Addresses scanned: None (see the Notes section below)
7 Datasheet: Publicly available at the National Semiconductor website 10
8 http://www.national.com/pf/LP/LP3944.html 11 Datasheet:
12
13 Publicly available at the National Semiconductor website
14 http://www.national.com/pf/LP/LP3944.html
9 15
10Authors: 16Authors:
11 Antonio Ospite <ospite@studenti.unina.it> 17 Antonio Ospite <ospite@studenti.unina.it>
12 18
13 19
14Description 20Description
@@ -19,8 +25,11 @@ is used as a led controller.
19 25
20The DIM modes are used to set _blink_ patterns for leds, the pattern is 26The DIM modes are used to set _blink_ patterns for leds, the pattern is
21specified supplying two parameters: 27specified supplying two parameters:
22 - period: from 0s to 1.6s 28
23 - duty cycle: percentage of the period the led is on, from 0 to 100 29 - period:
30 from 0s to 1.6s
31 - duty cycle:
32 percentage of the period the led is on, from 0 to 100
24 33
25Setting a led in DIM0 or DIM1 mode makes it blink according to the pattern. 34Setting a led in DIM0 or DIM1 mode makes it blink according to the pattern.
26See the datasheet for details. 35See the datasheet for details.
@@ -35,7 +44,7 @@ The chip is used mainly in embedded contexts, so this driver expects it is
35registered using the i2c_board_info mechanism. 44registered using the i2c_board_info mechanism.
36 45
37To register the chip at address 0x60 on adapter 0, set the platform data 46To register the chip at address 0x60 on adapter 0, set the platform data
38according to include/linux/leds-lp3944.h, set the i2c board info: 47according to include/linux/leds-lp3944.h, set the i2c board info::
39 48
40 static struct i2c_board_info a910_i2c_board_info[] __initdata = { 49 static struct i2c_board_info a910_i2c_board_info[] __initdata = {
41 { 50 {
@@ -44,7 +53,7 @@ according to include/linux/leds-lp3944.h, set the i2c board info:
44 }, 53 },
45 }; 54 };
46 55
47and register it in the platform init function 56and register it in the platform init function::
48 57
49 i2c_register_board_info(0, a910_i2c_board_info, 58 i2c_register_board_info(0, a910_i2c_board_info,
50 ARRAY_SIZE(a910_i2c_board_info)); 59 ARRAY_SIZE(a910_i2c_board_info));
diff --git a/Documentation/leds/leds-lp5521.rst b/Documentation/leds/leds-lp5521.rst
new file mode 100644
index 000000000000..0432615b083d
--- /dev/null
+++ b/Documentation/leds/leds-lp5521.rst
@@ -0,0 +1,115 @@
1========================
2Kernel driver for lp5521
3========================
4
5* National Semiconductor LP5521 led driver chip
6* Datasheet: http://www.national.com/pf/LP/LP5521.html
7
8Authors: Mathias Nyman, Yuri Zaporozhets, Samu Onkalo
9
10Contact: Samu Onkalo (samu.p.onkalo-at-nokia.com)
11
12Description
13-----------
14
15LP5521 can drive up to 3 channels. Leds can be controlled directly via
16the led class control interface. Channels have generic names:
17lp5521:channelx, where x is 0 .. 2
18
19All three channels can be also controlled using the engine micro programs.
20More details of the instructions can be found from the public data sheet.
21
22LP5521 has the internal program memory for running various LED patterns.
23There are two ways to run LED patterns.
24
251) Legacy interface - enginex_mode and enginex_load
26 Control interface for the engines:
27
28 x is 1 .. 3
29
30 enginex_mode:
31 disabled, load, run
32 enginex_load:
33 store program (visible only in engine load mode)
34
35 Example (start to blink the channel 2 led)::
36
37 cd /sys/class/leds/lp5521:channel2/device
38 echo "load" > engine3_mode
39 echo "037f4d0003ff6000" > engine3_load
40 echo "run" > engine3_mode
41
42 To stop the engine::
43
44 echo "disabled" > engine3_mode
45
462) Firmware interface - LP55xx common interface
47
48For the details, please refer to 'firmware' section in leds-lp55xx.txt
49
50sysfs contains a selftest entry.
51
52The test communicates with the chip and checks that
53the clock mode is automatically set to the requested one.
54
55Each channel has its own led current settings.
56
57- /sys/class/leds/lp5521:channel0/led_current - RW
58- /sys/class/leds/lp5521:channel0/max_current - RO
59
60Format: 10x mA i.e 10 means 1.0 mA
61
62example platform data::
63
64 static struct lp55xx_led_config lp5521_led_config[] = {
65 {
66 .name = "red",
67 .chan_nr = 0,
68 .led_current = 50,
69 .max_current = 130,
70 }, {
71 .name = "green",
72 .chan_nr = 1,
73 .led_current = 0,
74 .max_current = 130,
75 }, {
76 .name = "blue",
77 .chan_nr = 2,
78 .led_current = 0,
79 .max_current = 130,
80 }
81 };
82
83 static int lp5521_setup(void)
84 {
85 /* setup HW resources */
86 }
87
88 static void lp5521_release(void)
89 {
90 /* Release HW resources */
91 }
92
93 static void lp5521_enable(bool state)
94 {
95 /* Control of chip enable signal */
96 }
97
98 static struct lp55xx_platform_data lp5521_platform_data = {
99 .led_config = lp5521_led_config,
100 .num_channels = ARRAY_SIZE(lp5521_led_config),
101 .clock_mode = LP55XX_CLOCK_EXT,
102 .setup_resources = lp5521_setup,
103 .release_resources = lp5521_release,
104 .enable = lp5521_enable,
105 };
106
107Note:
108 chan_nr can have values between 0 and 2.
109 The name of each channel can be configurable.
110 If the name field is not defined, the default name will be set to 'xxxx:channelN'
111 (XXXX : pdata->label or i2c client name, N : channel number)
112
113
114If the current is set to 0 in the platform data, that channel is
115disabled and it is not visible in the sysfs.
diff --git a/Documentation/leds/leds-lp5521.txt b/Documentation/leds/leds-lp5521.txt
deleted file mode 100644
index d08d8c179f85..000000000000
--- a/Documentation/leds/leds-lp5521.txt
+++ /dev/null
@@ -1,101 +0,0 @@
1Kernel driver for lp5521
2========================
3
4* National Semiconductor LP5521 led driver chip
5* Datasheet: http://www.national.com/pf/LP/LP5521.html
6
7Authors: Mathias Nyman, Yuri Zaporozhets, Samu Onkalo
8Contact: Samu Onkalo (samu.p.onkalo-at-nokia.com)
9
10Description
11-----------
12
13LP5521 can drive up to 3 channels. Leds can be controlled directly via
14the led class control interface. Channels have generic names:
15lp5521:channelx, where x is 0 .. 2
16
17All three channels can be also controlled using the engine micro programs.
18More details of the instructions can be found from the public data sheet.
19
20LP5521 has the internal program memory for running various LED patterns.
21There are two ways to run LED patterns.
22
231) Legacy interface - enginex_mode and enginex_load
24 Control interface for the engines:
25 x is 1 .. 3
26 enginex_mode : disabled, load, run
27 enginex_load : store program (visible only in engine load mode)
28
29 Example (start to blink the channel 2 led):
30 cd /sys/class/leds/lp5521:channel2/device
31 echo "load" > engine3_mode
32 echo "037f4d0003ff6000" > engine3_load
33 echo "run" > engine3_mode
34
35 To stop the engine:
36 echo "disabled" > engine3_mode
37
382) Firmware interface - LP55xx common interface
39 For the details, please refer to 'firmware' section in leds-lp55xx.txt
40
41sysfs contains a selftest entry.
42The test communicates with the chip and checks that
43the clock mode is automatically set to the requested one.
44
45Each channel has its own led current settings.
46/sys/class/leds/lp5521:channel0/led_current - RW
47/sys/class/leds/lp5521:channel0/max_current - RO
48Format: 10x mA i.e 10 means 1.0 mA
49
50example platform data:
51
52Note: chan_nr can have values between 0 and 2.
53The name of each channel can be configurable.
54If the name field is not defined, the default name will be set to 'xxxx:channelN'
55(XXXX : pdata->label or i2c client name, N : channel number)
56
57static struct lp55xx_led_config lp5521_led_config[] = {
58 {
59 .name = "red",
60 .chan_nr = 0,
61 .led_current = 50,
62 .max_current = 130,
63 }, {
64 .name = "green",
65 .chan_nr = 1,
66 .led_current = 0,
67 .max_current = 130,
68 }, {
69 .name = "blue",
70 .chan_nr = 2,
71 .led_current = 0,
72 .max_current = 130,
73 }
74};
75
76static int lp5521_setup(void)
77{
78 /* setup HW resources */
79}
80
81static void lp5521_release(void)
82{
83 /* Release HW resources */
84}
85
86static void lp5521_enable(bool state)
87{
88 /* Control of chip enable signal */
89}
90
91static struct lp55xx_platform_data lp5521_platform_data = {
92 .led_config = lp5521_led_config,
93 .num_channels = ARRAY_SIZE(lp5521_led_config),
94 .clock_mode = LP55XX_CLOCK_EXT,
95 .setup_resources = lp5521_setup,
96 .release_resources = lp5521_release,
97 .enable = lp5521_enable,
98};
99
100If the current is set to 0 in the platform data, that channel is
101disabled and it is not visible in the sysfs.
diff --git a/Documentation/leds/leds-lp5523.rst b/Documentation/leds/leds-lp5523.rst
new file mode 100644
index 000000000000..7d7362a1dd57
--- /dev/null
+++ b/Documentation/leds/leds-lp5523.rst
@@ -0,0 +1,147 @@
1========================
2Kernel driver for lp5523
3========================
4
5* National Semiconductor LP5523 led driver chip
6* Datasheet: http://www.national.com/pf/LP/LP5523.html
7
8Authors: Mathias Nyman, Yuri Zaporozhets, Samu Onkalo
9Contact: Samu Onkalo (samu.p.onkalo-at-nokia.com)
10
11Description
12-----------
13LP5523 can drive up to 9 channels. Leds can be controlled directly via
14the led class control interface.
15The name of each channel is configurable in the platform data - name and label.
16There are three options to make the channel name.
17
18a) Define the 'name' in the platform data
19
20To make specific channel name, then use 'name' platform data.
21
22- /sys/class/leds/R1 (name: 'R1')
23- /sys/class/leds/B1 (name: 'B1')
24
25b) Use the 'label' with no 'name' field
26
27For one device name with channel number, then use 'label'.
28- /sys/class/leds/RGB:channelN (label: 'RGB', N: 0 ~ 8)
29
30c) Default
31
32If both fields are NULL, 'lp5523' is used by default.
33- /sys/class/leds/lp5523:channelN (N: 0 ~ 8)
34
35LP5523 has the internal program memory for running various LED patterns.
36There are two ways to run LED patterns.
37
381) Legacy interface - enginex_mode, enginex_load and enginex_leds
39
40 Control interface for the engines:
41
42 x is 1 .. 3
43
44 enginex_mode:
45 disabled, load, run
46 enginex_load:
47 microcode load
48 enginex_leds:
49 led mux control
50
51 ::
52
53 cd /sys/class/leds/lp5523:channel2/device
54 echo "load" > engine3_mode
55 echo "9d80400004ff05ff437f0000" > engine3_load
56 echo "111111111" > engine3_leds
57 echo "run" > engine3_mode
58
59 To stop the engine::
60
61 echo "disabled" > engine3_mode
62
632) Firmware interface - LP55xx common interface
64
65For the details, please refer to 'firmware' section in leds-lp55xx.txt
66
67LP5523 has three master faders. If a channel is mapped to one of
68the master faders, its output is dimmed based on the value of the master
69fader.
70
71For example::
72
73 echo "123000123" > master_fader_leds
74
75creates the following channel-fader mappings::
76
77 channel 0,6 to master_fader1
78 channel 1,7 to master_fader2
79 channel 2,8 to master_fader3
80
81Then, to have 25% of the original output on channel 0,6::
82
83 echo 64 > master_fader1
84
85To have 0% of the original output (i.e. no output) channel 1,7::
86
87 echo 0 > master_fader2
88
89To have 100% of the original output (i.e. no dimming) on channel 2,8::
90
91 echo 255 > master_fader3
92
93To clear all master fader controls::
94
95 echo "000000000" > master_fader_leds
96
97Selftest uses always the current from the platform data.
98
99Each channel contains led current settings.
100- /sys/class/leds/lp5523:channel2/led_current - RW
101- /sys/class/leds/lp5523:channel2/max_current - RO
102
103Format: 10x mA i.e 10 means 1.0 mA
104
105Example platform data::
106
107 static struct lp55xx_led_config lp5523_led_config[] = {
108 {
109 .name = "D1",
110 .chan_nr = 0,
111 .led_current = 50,
112 .max_current = 130,
113 },
114 ...
115 {
116 .chan_nr = 8,
117 .led_current = 50,
118 .max_current = 130,
119 }
120 };
121
122 static int lp5523_setup(void)
123 {
124 /* Setup HW resources */
125 }
126
127 static void lp5523_release(void)
128 {
129 /* Release HW resources */
130 }
131
132 static void lp5523_enable(bool state)
133 {
134 /* Control chip enable signal */
135 }
136
137 static struct lp55xx_platform_data lp5523_platform_data = {
138 .led_config = lp5523_led_config,
139 .num_channels = ARRAY_SIZE(lp5523_led_config),
140 .clock_mode = LP55XX_CLOCK_EXT,
141 .setup_resources = lp5523_setup,
142 .release_resources = lp5523_release,
143 .enable = lp5523_enable,
144 };
145
146Note
147 chan_nr can have values between 0 and 8.
diff --git a/Documentation/leds/leds-lp5523.txt b/Documentation/leds/leds-lp5523.txt
deleted file mode 100644
index 0961a060fc4d..000000000000
--- a/Documentation/leds/leds-lp5523.txt
+++ /dev/null
@@ -1,130 +0,0 @@
1Kernel driver for lp5523
2========================
3
4* National Semiconductor LP5523 led driver chip
5* Datasheet: http://www.national.com/pf/LP/LP5523.html
6
7Authors: Mathias Nyman, Yuri Zaporozhets, Samu Onkalo
8Contact: Samu Onkalo (samu.p.onkalo-at-nokia.com)
9
10Description
11-----------
12LP5523 can drive up to 9 channels. Leds can be controlled directly via
13the led class control interface.
14The name of each channel is configurable in the platform data - name and label.
15There are three options to make the channel name.
16
17a) Define the 'name' in the platform data
18To make specific channel name, then use 'name' platform data.
19/sys/class/leds/R1 (name: 'R1')
20/sys/class/leds/B1 (name: 'B1')
21
22b) Use the 'label' with no 'name' field
23For one device name with channel number, then use 'label'.
24/sys/class/leds/RGB:channelN (label: 'RGB', N: 0 ~ 8)
25
26c) Default
27If both fields are NULL, 'lp5523' is used by default.
28/sys/class/leds/lp5523:channelN (N: 0 ~ 8)
29
30LP5523 has the internal program memory for running various LED patterns.
31There are two ways to run LED patterns.
32
331) Legacy interface - enginex_mode, enginex_load and enginex_leds
34 Control interface for the engines:
35 x is 1 .. 3
36 enginex_mode : disabled, load, run
37 enginex_load : microcode load
38 enginex_leds : led mux control
39
40 cd /sys/class/leds/lp5523:channel2/device
41 echo "load" > engine3_mode
42 echo "9d80400004ff05ff437f0000" > engine3_load
43 echo "111111111" > engine3_leds
44 echo "run" > engine3_mode
45
46 To stop the engine:
47 echo "disabled" > engine3_mode
48
492) Firmware interface - LP55xx common interface
50 For the details, please refer to 'firmware' section in leds-lp55xx.txt
51
52LP5523 has three master faders. If a channel is mapped to one of
53the master faders, its output is dimmed based on the value of the master
54fader.
55
56For example,
57
58 echo "123000123" > master_fader_leds
59
60creates the following channel-fader mappings:
61
62 channel 0,6 to master_fader1
63 channel 1,7 to master_fader2
64 channel 2,8 to master_fader3
65
66Then, to have 25% of the original output on channel 0,6:
67
68 echo 64 > master_fader1
69
70To have 0% of the original output (i.e. no output) channel 1,7:
71
72 echo 0 > master_fader2
73
74To have 100% of the original output (i.e. no dimming) on channel 2,8:
75
76 echo 255 > master_fader3
77
78To clear all master fader controls:
79
80 echo "000000000" > master_fader_leds
81
82Selftest uses always the current from the platform data.
83
84Each channel contains led current settings.
85/sys/class/leds/lp5523:channel2/led_current - RW
86/sys/class/leds/lp5523:channel2/max_current - RO
87Format: 10x mA i.e 10 means 1.0 mA
88
89Example platform data:
90
91Note - chan_nr can have values between 0 and 8.
92
93static struct lp55xx_led_config lp5523_led_config[] = {
94 {
95 .name = "D1",
96 .chan_nr = 0,
97 .led_current = 50,
98 .max_current = 130,
99 },
100...
101 {
102 .chan_nr = 8,
103 .led_current = 50,
104 .max_current = 130,
105 }
106};
107
108static int lp5523_setup(void)
109{
110 /* Setup HW resources */
111}
112
113static void lp5523_release(void)
114{
115 /* Release HW resources */
116}
117
118static void lp5523_enable(bool state)
119{
120 /* Control chip enable signal */
121}
122
123static struct lp55xx_platform_data lp5523_platform_data = {
124 .led_config = lp5523_led_config,
125 .num_channels = ARRAY_SIZE(lp5523_led_config),
126 .clock_mode = LP55XX_CLOCK_EXT,
127 .setup_resources = lp5523_setup,
128 .release_resources = lp5523_release,
129 .enable = lp5523_enable,
130};
diff --git a/Documentation/leds/leds-lp5562.rst b/Documentation/leds/leds-lp5562.rst
new file mode 100644
index 000000000000..79bbb2487ff6
--- /dev/null
+++ b/Documentation/leds/leds-lp5562.rst
@@ -0,0 +1,137 @@
1========================
2Kernel driver for lp5562
3========================
4
5* TI LP5562 LED Driver
6
7Author: Milo(Woogyom) Kim <milo.kim@ti.com>
8
9Description
10===========
11
12 LP5562 can drive up to 4 channels. R/G/B and White.
13 LEDs can be controlled directly via the led class control interface.
14
15 All four channels can be also controlled using the engine micro programs.
16 LP5562 has the internal program memory for running various LED patterns.
17 For the details, please refer to 'firmware' section in leds-lp55xx.txt
18
19Device attribute
20================
21
22engine_mux
23 3 Engines are allocated in LP5562, but the number of channel is 4.
24 Therefore each channel should be mapped to the engine number.
25
26 Value: RGB or W
27
28 This attribute is used for programming LED data with the firmware interface.
29 Unlike the LP5521/LP5523/55231, LP5562 has unique feature for the engine mux,
30 so additional sysfs is required
31
32 LED Map
33
34 ===== === ===============================
35 Red ... Engine 1 (fixed)
36 Green ... Engine 2 (fixed)
37 Blue ... Engine 3 (fixed)
38 White ... Engine 1 or 2 or 3 (selective)
39 ===== === ===============================
40
41How to load the program data using engine_mux
42=============================================
43
44 Before loading the LP5562 program data, engine_mux should be written between
45 the engine selection and loading the firmware.
46 Engine mux has two different mode, RGB and W.
47 RGB is used for loading RGB program data, W is used for W program data.
48
49 For example, run blinking green channel pattern::
50
51 echo 2 > /sys/bus/i2c/devices/xxxx/select_engine # 2 is for green channel
52 echo "RGB" > /sys/bus/i2c/devices/xxxx/engine_mux # engine mux for RGB
53 echo 1 > /sys/class/firmware/lp5562/loading
54 echo "4000600040FF6000" > /sys/class/firmware/lp5562/data
55 echo 0 > /sys/class/firmware/lp5562/loading
56 echo 1 > /sys/bus/i2c/devices/xxxx/run_engine
57
58 To run a blinking white pattern::
59
60 echo 1 or 2 or 3 > /sys/bus/i2c/devices/xxxx/select_engine
61 echo "W" > /sys/bus/i2c/devices/xxxx/engine_mux
62 echo 1 > /sys/class/firmware/lp5562/loading
63 echo "4000600040FF6000" > /sys/class/firmware/lp5562/data
64 echo 0 > /sys/class/firmware/lp5562/loading
65 echo 1 > /sys/bus/i2c/devices/xxxx/run_engine
66
67How to load the predefined patterns
68===================================
69
70 Please refer to 'leds-lp55xx.txt"
71
72Setting Current of Each Channel
73===============================
74
75 Like LP5521 and LP5523/55231, LP5562 provides LED current settings.
76 The 'led_current' and 'max_current' are used.
77
78Example of Platform data
79========================
80
81::
82
83 static struct lp55xx_led_config lp5562_led_config[] = {
84 {
85 .name = "R",
86 .chan_nr = 0,
87 .led_current = 20,
88 .max_current = 40,
89 },
90 {
91 .name = "G",
92 .chan_nr = 1,
93 .led_current = 20,
94 .max_current = 40,
95 },
96 {
97 .name = "B",
98 .chan_nr = 2,
99 .led_current = 20,
100 .max_current = 40,
101 },
102 {
103 .name = "W",
104 .chan_nr = 3,
105 .led_current = 20,
106 .max_current = 40,
107 },
108 };
109
110 static int lp5562_setup(void)
111 {
112 /* setup HW resources */
113 }
114
115 static void lp5562_release(void)
116 {
117 /* Release HW resources */
118 }
119
120 static void lp5562_enable(bool state)
121 {
122 /* Control of chip enable signal */
123 }
124
125 static struct lp55xx_platform_data lp5562_platform_data = {
126 .led_config = lp5562_led_config,
127 .num_channels = ARRAY_SIZE(lp5562_led_config),
128 .setup_resources = lp5562_setup,
129 .release_resources = lp5562_release,
130 .enable = lp5562_enable,
131 };
132
133To configure the platform specific data, lp55xx_platform_data structure is used
134
135
136If the current is set to 0 in the platform data, that channel is
137disabled and it is not visible in the sysfs.
diff --git a/Documentation/leds/leds-lp5562.txt b/Documentation/leds/leds-lp5562.txt
deleted file mode 100644
index 5a823ff6b393..000000000000
--- a/Documentation/leds/leds-lp5562.txt
+++ /dev/null
@@ -1,120 +0,0 @@
1Kernel driver for LP5562
2========================
3
4* TI LP5562 LED Driver
5
6Author: Milo(Woogyom) Kim <milo.kim@ti.com>
7
8Description
9
10 LP5562 can drive up to 4 channels. R/G/B and White.
11 LEDs can be controlled directly via the led class control interface.
12
13 All four channels can be also controlled using the engine micro programs.
14 LP5562 has the internal program memory for running various LED patterns.
15 For the details, please refer to 'firmware' section in leds-lp55xx.txt
16
17Device attribute: engine_mux
18
19 3 Engines are allocated in LP5562, but the number of channel is 4.
20 Therefore each channel should be mapped to the engine number.
21 Value : RGB or W
22
23 This attribute is used for programming LED data with the firmware interface.
24 Unlike the LP5521/LP5523/55231, LP5562 has unique feature for the engine mux,
25 so additional sysfs is required.
26
27 LED Map
28 Red ... Engine 1 (fixed)
29 Green ... Engine 2 (fixed)
30 Blue ... Engine 3 (fixed)
31 White ... Engine 1 or 2 or 3 (selective)
32
33How to load the program data using engine_mux
34
35 Before loading the LP5562 program data, engine_mux should be written between
36 the engine selection and loading the firmware.
37 Engine mux has two different mode, RGB and W.
38 RGB is used for loading RGB program data, W is used for W program data.
39
40 For example, run blinking green channel pattern,
41 echo 2 > /sys/bus/i2c/devices/xxxx/select_engine # 2 is for green channel
42 echo "RGB" > /sys/bus/i2c/devices/xxxx/engine_mux # engine mux for RGB
43 echo 1 > /sys/class/firmware/lp5562/loading
44 echo "4000600040FF6000" > /sys/class/firmware/lp5562/data
45 echo 0 > /sys/class/firmware/lp5562/loading
46 echo 1 > /sys/bus/i2c/devices/xxxx/run_engine
47
48 To run a blinking white pattern,
49 echo 1 or 2 or 3 > /sys/bus/i2c/devices/xxxx/select_engine
50 echo "W" > /sys/bus/i2c/devices/xxxx/engine_mux
51 echo 1 > /sys/class/firmware/lp5562/loading
52 echo "4000600040FF6000" > /sys/class/firmware/lp5562/data
53 echo 0 > /sys/class/firmware/lp5562/loading
54 echo 1 > /sys/bus/i2c/devices/xxxx/run_engine
55
56How to load the predefined patterns
57
58 Please refer to 'leds-lp55xx.txt"
59
60Setting Current of Each Channel
61
62 Like LP5521 and LP5523/55231, LP5562 provides LED current settings.
63 The 'led_current' and 'max_current' are used.
64
65(Example of Platform data)
66
67To configure the platform specific data, lp55xx_platform_data structure is used.
68
69static struct lp55xx_led_config lp5562_led_config[] = {
70 {
71 .name = "R",
72 .chan_nr = 0,
73 .led_current = 20,
74 .max_current = 40,
75 },
76 {
77 .name = "G",
78 .chan_nr = 1,
79 .led_current = 20,
80 .max_current = 40,
81 },
82 {
83 .name = "B",
84 .chan_nr = 2,
85 .led_current = 20,
86 .max_current = 40,
87 },
88 {
89 .name = "W",
90 .chan_nr = 3,
91 .led_current = 20,
92 .max_current = 40,
93 },
94};
95
96static int lp5562_setup(void)
97{
98 /* setup HW resources */
99}
100
101static void lp5562_release(void)
102{
103 /* Release HW resources */
104}
105
106static void lp5562_enable(bool state)
107{
108 /* Control of chip enable signal */
109}
110
111static struct lp55xx_platform_data lp5562_platform_data = {
112 .led_config = lp5562_led_config,
113 .num_channels = ARRAY_SIZE(lp5562_led_config),
114 .setup_resources = lp5562_setup,
115 .release_resources = lp5562_release,
116 .enable = lp5562_enable,
117};
118
119If the current is set to 0 in the platform data, that channel is
120disabled and it is not visible in the sysfs.
diff --git a/Documentation/leds/leds-lp55xx.rst b/Documentation/leds/leds-lp55xx.rst
new file mode 100644
index 000000000000..632e41cec0b5
--- /dev/null
+++ b/Documentation/leds/leds-lp55xx.rst
@@ -0,0 +1,224 @@
1=================================================
2LP5521/LP5523/LP55231/LP5562/LP8501 Common Driver
3=================================================
4
5Authors: Milo(Woogyom) Kim <milo.kim@ti.com>
6
7Description
8-----------
9LP5521, LP5523/55231, LP5562 and LP8501 have common features as below.
10
11 Register access via the I2C
12 Device initialization/deinitialization
13 Create LED class devices for multiple output channels
14 Device attributes for user-space interface
15 Program memory for running LED patterns
16
17The LP55xx common driver provides these features using exported functions.
18
19 lp55xx_init_device() / lp55xx_deinit_device()
20 lp55xx_register_leds() / lp55xx_unregister_leds()
21 lp55xx_regsister_sysfs() / lp55xx_unregister_sysfs()
22
23( Driver Structure Data )
24
25In lp55xx common driver, two different data structure is used.
26
27* lp55xx_led
28 control multi output LED channels such as led current, channel index.
29* lp55xx_chip
30 general chip control such like the I2C and platform data.
31
32For example, LP5521 has maximum 3 LED channels.
33LP5523/55231 has 9 output channels::
34
35 lp55xx_chip for LP5521 ... lp55xx_led #1
36 lp55xx_led #2
37 lp55xx_led #3
38
39 lp55xx_chip for LP5523 ... lp55xx_led #1
40 lp55xx_led #2
41 .
42 .
43 lp55xx_led #9
44
45( Chip Dependent Code )
46
47To support device specific configurations, special structure
48'lpxx_device_config' is used.
49
50 - Maximum number of channels
51 - Reset command, chip enable command
52 - Chip specific initialization
53 - Brightness control register access
54 - Setting LED output current
55 - Program memory address access for running patterns
56 - Additional device specific attributes
57
58( Firmware Interface )
59
60LP55xx family devices have the internal program memory for running
61various LED patterns.
62
63This pattern data is saved as a file in the user-land or
64hex byte string is written into the memory through the I2C.
65
66LP55xx common driver supports the firmware interface.
67
68LP55xx chips have three program engines.
69
70To load and run the pattern, the programming sequence is following.
71
72 (1) Select an engine number (1/2/3)
73 (2) Mode change to load
74 (3) Write pattern data into selected area
75 (4) Mode change to run
76
77The LP55xx common driver provides simple interfaces as below.
78
79select_engine:
80 Select which engine is used for running program
81run_engine:
82 Start program which is loaded via the firmware interface
83firmware:
84 Load program data
85
86In case of LP5523, one more command is required, 'enginex_leds'.
87It is used for selecting LED output(s) at each engine number.
88In more details, please refer to 'leds-lp5523.txt'.
89
90For example, run blinking pattern in engine #1 of LP5521::
91
92 echo 1 > /sys/bus/i2c/devices/xxxx/select_engine
93 echo 1 > /sys/class/firmware/lp5521/loading
94 echo "4000600040FF6000" > /sys/class/firmware/lp5521/data
95 echo 0 > /sys/class/firmware/lp5521/loading
96 echo 1 > /sys/bus/i2c/devices/xxxx/run_engine
97
98For example, run blinking pattern in engine #3 of LP55231
99
100Two LEDs are configured as pattern output channels::
101
102 echo 3 > /sys/bus/i2c/devices/xxxx/select_engine
103 echo 1 > /sys/class/firmware/lp55231/loading
104 echo "9d0740ff7e0040007e00a0010000" > /sys/class/firmware/lp55231/data
105 echo 0 > /sys/class/firmware/lp55231/loading
106 echo "000001100" > /sys/bus/i2c/devices/xxxx/engine3_leds
107 echo 1 > /sys/bus/i2c/devices/xxxx/run_engine
108
109To start blinking patterns in engine #2 and #3 simultaneously::
110
111 for idx in 2 3
112 do
113 echo $idx > /sys/class/leds/red/device/select_engine
114 sleep 0.1
115 echo 1 > /sys/class/firmware/lp5521/loading
116 echo "4000600040FF6000" > /sys/class/firmware/lp5521/data
117 echo 0 > /sys/class/firmware/lp5521/loading
118 done
119 echo 1 > /sys/class/leds/red/device/run_engine
120
121Here is another example for LP5523.
122
123Full LED strings are selected by 'engine2_leds'::
124
125 echo 2 > /sys/bus/i2c/devices/xxxx/select_engine
126 echo 1 > /sys/class/firmware/lp5523/loading
127 echo "9d80400004ff05ff437f0000" > /sys/class/firmware/lp5523/data
128 echo 0 > /sys/class/firmware/lp5523/loading
129 echo "111111111" > /sys/bus/i2c/devices/xxxx/engine2_leds
130 echo 1 > /sys/bus/i2c/devices/xxxx/run_engine
131
132As soon as 'loading' is set to 0, registered callback is called.
133Inside the callback, the selected engine is loaded and memory is updated.
134To run programmed pattern, 'run_engine' attribute should be enabled.
135
136The pattern sequence of LP8501 is similar to LP5523.
137
138However pattern data is specific.
139
140Ex 1) Engine 1 is used::
141
142 echo 1 > /sys/bus/i2c/devices/xxxx/select_engine
143 echo 1 > /sys/class/firmware/lp8501/loading
144 echo "9d0140ff7e0040007e00a001c000" > /sys/class/firmware/lp8501/data
145 echo 0 > /sys/class/firmware/lp8501/loading
146 echo 1 > /sys/bus/i2c/devices/xxxx/run_engine
147
148Ex 2) Engine 2 and 3 are used at the same time::
149
150 echo 2 > /sys/bus/i2c/devices/xxxx/select_engine
151 sleep 1
152 echo 1 > /sys/class/firmware/lp8501/loading
153 echo "9d0140ff7e0040007e00a001c000" > /sys/class/firmware/lp8501/data
154 echo 0 > /sys/class/firmware/lp8501/loading
155 sleep 1
156 echo 3 > /sys/bus/i2c/devices/xxxx/select_engine
157 sleep 1
158 echo 1 > /sys/class/firmware/lp8501/loading
159 echo "9d0340ff7e0040007e00a001c000" > /sys/class/firmware/lp8501/data
160 echo 0 > /sys/class/firmware/lp8501/loading
161 sleep 1
162 echo 1 > /sys/class/leds/d1/device/run_engine
163
164( 'run_engine' and 'firmware_cb' )
165
166The sequence of running the program data is common.
167
168But each device has own specific register addresses for commands.
169
170To support this, 'run_engine' and 'firmware_cb' are configurable in each driver.
171
172run_engine:
173 Control the selected engine
174firmware_cb:
175 The callback function after loading the firmware is done.
176
177 Chip specific commands for loading and updating program memory.
178
179( Predefined pattern data )
180
181Without the firmware interface, LP55xx driver provides another method for
182loading a LED pattern. That is 'predefined' pattern.
183
184A predefined pattern is defined in the platform data and load it(or them)
185via the sysfs if needed.
186
187To use the predefined pattern concept, 'patterns' and 'num_patterns' should be
188configured.
189
190Example of predefined pattern data::
191
192 /* mode_1: blinking data */
193 static const u8 mode_1[] = {
194 0x40, 0x00, 0x60, 0x00, 0x40, 0xFF, 0x60, 0x00,
195 };
196
197 /* mode_2: always on */
198 static const u8 mode_2[] = { 0x40, 0xFF, };
199
200 struct lp55xx_predef_pattern board_led_patterns[] = {
201 {
202 .r = mode_1,
203 .size_r = ARRAY_SIZE(mode_1),
204 },
205 {
206 .b = mode_2,
207 .size_b = ARRAY_SIZE(mode_2),
208 },
209 }
210
211 struct lp55xx_platform_data lp5562_pdata = {
212 ...
213 .patterns = board_led_patterns,
214 .num_patterns = ARRAY_SIZE(board_led_patterns),
215 };
216
217Then, mode_1 and mode_2 can be run via through the sysfs::
218
219 echo 1 > /sys/bus/i2c/devices/xxxx/led_pattern # red blinking LED pattern
220 echo 2 > /sys/bus/i2c/devices/xxxx/led_pattern # blue LED always on
221
222To stop running pattern::
223
224 echo 0 > /sys/bus/i2c/devices/xxxx/led_pattern
diff --git a/Documentation/leds/leds-lp55xx.txt b/Documentation/leds/leds-lp55xx.txt
deleted file mode 100644
index e23fa91ea722..000000000000
--- a/Documentation/leds/leds-lp55xx.txt
+++ /dev/null
@@ -1,194 +0,0 @@
1LP5521/LP5523/LP55231/LP5562/LP8501 Common Driver
2=================================================
3
4Authors: Milo(Woogyom) Kim <milo.kim@ti.com>
5
6Description
7-----------
8LP5521, LP5523/55231, LP5562 and LP8501 have common features as below.
9
10 Register access via the I2C
11 Device initialization/deinitialization
12 Create LED class devices for multiple output channels
13 Device attributes for user-space interface
14 Program memory for running LED patterns
15
16The LP55xx common driver provides these features using exported functions.
17 lp55xx_init_device() / lp55xx_deinit_device()
18 lp55xx_register_leds() / lp55xx_unregister_leds()
19 lp55xx_regsister_sysfs() / lp55xx_unregister_sysfs()
20
21( Driver Structure Data )
22
23In lp55xx common driver, two different data structure is used.
24
25o lp55xx_led
26 control multi output LED channels such as led current, channel index.
27o lp55xx_chip
28 general chip control such like the I2C and platform data.
29
30For example, LP5521 has maximum 3 LED channels.
31LP5523/55231 has 9 output channels.
32
33lp55xx_chip for LP5521 ... lp55xx_led #1
34 lp55xx_led #2
35 lp55xx_led #3
36
37lp55xx_chip for LP5523 ... lp55xx_led #1
38 lp55xx_led #2
39 .
40 .
41 lp55xx_led #9
42
43( Chip Dependent Code )
44
45To support device specific configurations, special structure
46'lpxx_device_config' is used.
47
48 Maximum number of channels
49 Reset command, chip enable command
50 Chip specific initialization
51 Brightness control register access
52 Setting LED output current
53 Program memory address access for running patterns
54 Additional device specific attributes
55
56( Firmware Interface )
57
58LP55xx family devices have the internal program memory for running
59various LED patterns.
60This pattern data is saved as a file in the user-land or
61hex byte string is written into the memory through the I2C.
62LP55xx common driver supports the firmware interface.
63
64LP55xx chips have three program engines.
65To load and run the pattern, the programming sequence is following.
66 (1) Select an engine number (1/2/3)
67 (2) Mode change to load
68 (3) Write pattern data into selected area
69 (4) Mode change to run
70
71The LP55xx common driver provides simple interfaces as below.
72select_engine : Select which engine is used for running program
73run_engine : Start program which is loaded via the firmware interface
74firmware : Load program data
75
76In case of LP5523, one more command is required, 'enginex_leds'.
77It is used for selecting LED output(s) at each engine number.
78In more details, please refer to 'leds-lp5523.txt'.
79
80For example, run blinking pattern in engine #1 of LP5521
81echo 1 > /sys/bus/i2c/devices/xxxx/select_engine
82echo 1 > /sys/class/firmware/lp5521/loading
83echo "4000600040FF6000" > /sys/class/firmware/lp5521/data
84echo 0 > /sys/class/firmware/lp5521/loading
85echo 1 > /sys/bus/i2c/devices/xxxx/run_engine
86
87For example, run blinking pattern in engine #3 of LP55231
88Two LEDs are configured as pattern output channels.
89echo 3 > /sys/bus/i2c/devices/xxxx/select_engine
90echo 1 > /sys/class/firmware/lp55231/loading
91echo "9d0740ff7e0040007e00a0010000" > /sys/class/firmware/lp55231/data
92echo 0 > /sys/class/firmware/lp55231/loading
93echo "000001100" > /sys/bus/i2c/devices/xxxx/engine3_leds
94echo 1 > /sys/bus/i2c/devices/xxxx/run_engine
95
96To start blinking patterns in engine #2 and #3 simultaneously,
97for idx in 2 3
98do
99 echo $idx > /sys/class/leds/red/device/select_engine
100 sleep 0.1
101 echo 1 > /sys/class/firmware/lp5521/loading
102 echo "4000600040FF6000" > /sys/class/firmware/lp5521/data
103 echo 0 > /sys/class/firmware/lp5521/loading
104done
105echo 1 > /sys/class/leds/red/device/run_engine
106
107Here is another example for LP5523.
108Full LED strings are selected by 'engine2_leds'.
109echo 2 > /sys/bus/i2c/devices/xxxx/select_engine
110echo 1 > /sys/class/firmware/lp5523/loading
111echo "9d80400004ff05ff437f0000" > /sys/class/firmware/lp5523/data
112echo 0 > /sys/class/firmware/lp5523/loading
113echo "111111111" > /sys/bus/i2c/devices/xxxx/engine2_leds
114echo 1 > /sys/bus/i2c/devices/xxxx/run_engine
115
116As soon as 'loading' is set to 0, registered callback is called.
117Inside the callback, the selected engine is loaded and memory is updated.
118To run programmed pattern, 'run_engine' attribute should be enabled.
119
120The pattern sequence of LP8501 is similar to LP5523.
121However pattern data is specific.
122Ex 1) Engine 1 is used
123echo 1 > /sys/bus/i2c/devices/xxxx/select_engine
124echo 1 > /sys/class/firmware/lp8501/loading
125echo "9d0140ff7e0040007e00a001c000" > /sys/class/firmware/lp8501/data
126echo 0 > /sys/class/firmware/lp8501/loading
127echo 1 > /sys/bus/i2c/devices/xxxx/run_engine
128
129Ex 2) Engine 2 and 3 are used at the same time
130echo 2 > /sys/bus/i2c/devices/xxxx/select_engine
131sleep 1
132echo 1 > /sys/class/firmware/lp8501/loading
133echo "9d0140ff7e0040007e00a001c000" > /sys/class/firmware/lp8501/data
134echo 0 > /sys/class/firmware/lp8501/loading
135sleep 1
136echo 3 > /sys/bus/i2c/devices/xxxx/select_engine
137sleep 1
138echo 1 > /sys/class/firmware/lp8501/loading
139echo "9d0340ff7e0040007e00a001c000" > /sys/class/firmware/lp8501/data
140echo 0 > /sys/class/firmware/lp8501/loading
141sleep 1
142echo 1 > /sys/class/leds/d1/device/run_engine
143
144( 'run_engine' and 'firmware_cb' )
145The sequence of running the program data is common.
146But each device has own specific register addresses for commands.
147To support this, 'run_engine' and 'firmware_cb' are configurable in each driver.
148run_engine : Control the selected engine
149firmware_cb : The callback function after loading the firmware is done.
150 Chip specific commands for loading and updating program memory.
151
152( Predefined pattern data )
153
154Without the firmware interface, LP55xx driver provides another method for
155loading a LED pattern. That is 'predefined' pattern.
156A predefined pattern is defined in the platform data and load it(or them)
157via the sysfs if needed.
158To use the predefined pattern concept, 'patterns' and 'num_patterns' should be
159configured.
160
161 Example of predefined pattern data:
162
163 /* mode_1: blinking data */
164 static const u8 mode_1[] = {
165 0x40, 0x00, 0x60, 0x00, 0x40, 0xFF, 0x60, 0x00,
166 };
167
168 /* mode_2: always on */
169 static const u8 mode_2[] = { 0x40, 0xFF, };
170
171 struct lp55xx_predef_pattern board_led_patterns[] = {
172 {
173 .r = mode_1,
174 .size_r = ARRAY_SIZE(mode_1),
175 },
176 {
177 .b = mode_2,
178 .size_b = ARRAY_SIZE(mode_2),
179 },
180 }
181
182 struct lp55xx_platform_data lp5562_pdata = {
183 ...
184 .patterns = board_led_patterns,
185 .num_patterns = ARRAY_SIZE(board_led_patterns),
186 };
187
188Then, mode_1 and mode_2 can be run via through the sysfs.
189
190 echo 1 > /sys/bus/i2c/devices/xxxx/led_pattern # red blinking LED pattern
191 echo 2 > /sys/bus/i2c/devices/xxxx/led_pattern # blue LED always on
192
193To stop running pattern,
194 echo 0 > /sys/bus/i2c/devices/xxxx/led_pattern
diff --git a/Documentation/leds/leds-mlxcpld.rst b/Documentation/leds/leds-mlxcpld.rst
new file mode 100644
index 000000000000..528582429e0b
--- /dev/null
+++ b/Documentation/leds/leds-mlxcpld.rst
@@ -0,0 +1,118 @@
1=======================================
2Kernel driver for Mellanox systems LEDs
3=======================================
4
5Provide system LED support for the nex Mellanox systems:
6"msx6710", "msx6720", "msb7700", "msn2700", "msx1410",
7"msn2410", "msb7800", "msn2740", "msn2100".
8
9Description
10-----------
11Driver provides the following LEDs for the systems "msx6710", "msx6720",
12"msb7700", "msn2700", "msx1410", "msn2410", "msb7800", "msn2740":
13
14 - mlxcpld:fan1:green
15 - mlxcpld:fan1:red
16 - mlxcpld:fan2:green
17 - mlxcpld:fan2:red
18 - mlxcpld:fan3:green
19 - mlxcpld:fan3:red
20 - mlxcpld:fan4:green
21 - mlxcpld:fan4:red
22 - mlxcpld:psu:green
23 - mlxcpld:psu:red
24 - mlxcpld:status:green
25 - mlxcpld:status:red
26
27 "status"
28 - CPLD reg offset: 0x20
29 - Bits [3:0]
30
31 "psu"
32 - CPLD reg offset: 0x20
33 - Bits [7:4]
34
35 "fan1"
36 - CPLD reg offset: 0x21
37 - Bits [3:0]
38
39 "fan2"
40 - CPLD reg offset: 0x21
41 - Bits [7:4]
42
43 "fan3"
44 - CPLD reg offset: 0x22
45 - Bits [3:0]
46
47 "fan4"
48 - CPLD reg offset: 0x22
49 - Bits [7:4]
50
51 Color mask for all the above LEDs:
52
53 [bit3,bit2,bit1,bit0] or
54 [bit7,bit6,bit5,bit4]:
55
56 - [0,0,0,0] = LED OFF
57 - [0,1,0,1] = Red static ON
58 - [1,1,0,1] = Green static ON
59 - [0,1,1,0] = Red blink 3Hz
60 - [1,1,1,0] = Green blink 3Hz
61 - [0,1,1,1] = Red blink 6Hz
62 - [1,1,1,1] = Green blink 6Hz
63
64Driver provides the following LEDs for the system "msn2100":
65
66 - mlxcpld:fan:green
67 - mlxcpld:fan:red
68 - mlxcpld:psu1:green
69 - mlxcpld:psu1:red
70 - mlxcpld:psu2:green
71 - mlxcpld:psu2:red
72 - mlxcpld:status:green
73 - mlxcpld:status:red
74 - mlxcpld:uid:blue
75
76 "status"
77 - CPLD reg offset: 0x20
78 - Bits [3:0]
79
80 "fan"
81 - CPLD reg offset: 0x21
82 - Bits [3:0]
83
84 "psu1"
85 - CPLD reg offset: 0x23
86 - Bits [3:0]
87
88 "psu2"
89 - CPLD reg offset: 0x23
90 - Bits [7:4]
91
92 "uid"
93 - CPLD reg offset: 0x24
94 - Bits [3:0]
95
96 Color mask for all the above LEDs, excepted uid:
97
98 [bit3,bit2,bit1,bit0] or
99 [bit7,bit6,bit5,bit4]:
100
101 - [0,0,0,0] = LED OFF
102 - [0,1,0,1] = Red static ON
103 - [1,1,0,1] = Green static ON
104 - [0,1,1,0] = Red blink 3Hz
105 - [1,1,1,0] = Green blink 3Hz
106 - [0,1,1,1] = Red blink 6Hz
107 - [1,1,1,1] = Green blink 6Hz
108
109 Color mask for uid LED:
110 [bit3,bit2,bit1,bit0]:
111
112 - [0,0,0,0] = LED OFF
113 - [1,1,0,1] = Blue static ON
114 - [1,1,1,0] = Blue blink 3Hz
115 - [1,1,1,1] = Blue blink 6Hz
116
117Driver supports HW blinking at 3Hz and 6Hz frequency (50% duty cycle).
118For 3Hz duty cylce is about 167 msec, for 6Hz is about 83 msec.
diff --git a/Documentation/leds/leds-mlxcpld.txt b/Documentation/leds/leds-mlxcpld.txt
deleted file mode 100644
index a0e8fd457117..000000000000
--- a/Documentation/leds/leds-mlxcpld.txt
+++ /dev/null
@@ -1,110 +0,0 @@
1Kernel driver for Mellanox systems LEDs
2=======================================
3
4Provide system LED support for the nex Mellanox systems:
5"msx6710", "msx6720", "msb7700", "msn2700", "msx1410",
6"msn2410", "msb7800", "msn2740", "msn2100".
7
8Description
9-----------
10Driver provides the following LEDs for the systems "msx6710", "msx6720",
11"msb7700", "msn2700", "msx1410", "msn2410", "msb7800", "msn2740":
12 mlxcpld:fan1:green
13 mlxcpld:fan1:red
14 mlxcpld:fan2:green
15 mlxcpld:fan2:red
16 mlxcpld:fan3:green
17 mlxcpld:fan3:red
18 mlxcpld:fan4:green
19 mlxcpld:fan4:red
20 mlxcpld:psu:green
21 mlxcpld:psu:red
22 mlxcpld:status:green
23 mlxcpld:status:red
24
25 "status"
26 CPLD reg offset: 0x20
27 Bits [3:0]
28
29 "psu"
30 CPLD reg offset: 0x20
31 Bits [7:4]
32
33 "fan1"
34 CPLD reg offset: 0x21
35 Bits [3:0]
36
37 "fan2"
38 CPLD reg offset: 0x21
39 Bits [7:4]
40
41 "fan3"
42 CPLD reg offset: 0x22
43 Bits [3:0]
44
45 "fan4"
46 CPLD reg offset: 0x22
47 Bits [7:4]
48
49 Color mask for all the above LEDs:
50 [bit3,bit2,bit1,bit0] or
51 [bit7,bit6,bit5,bit4]:
52 [0,0,0,0] = LED OFF
53 [0,1,0,1] = Red static ON
54 [1,1,0,1] = Green static ON
55 [0,1,1,0] = Red blink 3Hz
56 [1,1,1,0] = Green blink 3Hz
57 [0,1,1,1] = Red blink 6Hz
58 [1,1,1,1] = Green blink 6Hz
59
60Driver provides the following LEDs for the system "msn2100":
61 mlxcpld:fan:green
62 mlxcpld:fan:red
63 mlxcpld:psu1:green
64 mlxcpld:psu1:red
65 mlxcpld:psu2:green
66 mlxcpld:psu2:red
67 mlxcpld:status:green
68 mlxcpld:status:red
69 mlxcpld:uid:blue
70
71 "status"
72 CPLD reg offset: 0x20
73 Bits [3:0]
74
75 "fan"
76 CPLD reg offset: 0x21
77 Bits [3:0]
78
79 "psu1"
80 CPLD reg offset: 0x23
81 Bits [3:0]
82
83 "psu2"
84 CPLD reg offset: 0x23
85 Bits [7:4]
86
87 "uid"
88 CPLD reg offset: 0x24
89 Bits [3:0]
90
91 Color mask for all the above LEDs, excepted uid:
92 [bit3,bit2,bit1,bit0] or
93 [bit7,bit6,bit5,bit4]:
94 [0,0,0,0] = LED OFF
95 [0,1,0,1] = Red static ON
96 [1,1,0,1] = Green static ON
97 [0,1,1,0] = Red blink 3Hz
98 [1,1,1,0] = Green blink 3Hz
99 [0,1,1,1] = Red blink 6Hz
100 [1,1,1,1] = Green blink 6Hz
101
102 Color mask for uid LED:
103 [bit3,bit2,bit1,bit0]:
104 [0,0,0,0] = LED OFF
105 [1,1,0,1] = Blue static ON
106 [1,1,1,0] = Blue blink 3Hz
107 [1,1,1,1] = Blue blink 6Hz
108
109Driver supports HW blinking at 3Hz and 6Hz frequency (50% duty cycle).
110For 3Hz duty cylce is about 167 msec, for 6Hz is about 83 msec.
diff --git a/Documentation/leds/ledtrig-oneshot.txt b/Documentation/leds/ledtrig-oneshot.rst
index fe57474a12e2..69fa3ea1d554 100644
--- a/Documentation/leds/ledtrig-oneshot.txt
+++ b/Documentation/leds/ledtrig-oneshot.rst
@@ -1,3 +1,4 @@
1====================
1One-shot LED Trigger 2One-shot LED Trigger
2==================== 3====================
3 4
@@ -17,27 +18,27 @@ additional "invert" property specifies if the LED has to stay off (normal) or
17on (inverted) when not rearmed. 18on (inverted) when not rearmed.
18 19
19The trigger can be activated from user space on led class devices as shown 20The trigger can be activated from user space on led class devices as shown
20below: 21below::
21 22
22 echo oneshot > trigger 23 echo oneshot > trigger
23 24
24This adds sysfs attributes to the LED that are documented in: 25This adds sysfs attributes to the LED that are documented in:
25Documentation/ABI/testing/sysfs-class-led-trigger-oneshot 26Documentation/ABI/testing/sysfs-class-led-trigger-oneshot
26 27
27Example use-case: network devices, initialization: 28Example use-case: network devices, initialization::
28 29
29 echo oneshot > trigger # set trigger for this led 30 echo oneshot > trigger # set trigger for this led
30 echo 33 > delay_on # blink at 1 / (33 + 33) Hz on continuous traffic 31 echo 33 > delay_on # blink at 1 / (33 + 33) Hz on continuous traffic
31 echo 33 > delay_off 32 echo 33 > delay_off
32 33
33interface goes up: 34interface goes up::
34 35
35 echo 1 > invert # set led as normally-on, turn the led on 36 echo 1 > invert # set led as normally-on, turn the led on
36 37
37packet received/transmitted: 38packet received/transmitted::
38 39
39 echo 1 > shot # led starts blinking, ignored if already blinking 40 echo 1 > shot # led starts blinking, ignored if already blinking
40 41
41interface goes down 42interface goes down::
42 43
43 echo 0 > invert # set led as normally-off, turn the led off 44 echo 0 > invert # set led as normally-off, turn the led off
diff --git a/Documentation/leds/ledtrig-transient.txt b/Documentation/leds/ledtrig-transient.rst
index 3bd38b487df1..d921dc830cd0 100644
--- a/Documentation/leds/ledtrig-transient.txt
+++ b/Documentation/leds/ledtrig-transient.rst
@@ -1,3 +1,4 @@
1=====================
1LED Transient Trigger 2LED Transient Trigger
2===================== 3=====================
3 4
@@ -62,12 +63,13 @@ non-transient state. When driver gets suspended, irrespective of the transient
62state, the LED state changes to LED_OFF. 63state, the LED state changes to LED_OFF.
63 64
64Transient trigger can be enabled and disabled from user space on led class 65Transient trigger can be enabled and disabled from user space on led class
65devices, that support this trigger as shown below: 66devices, that support this trigger as shown below::
66 67
67echo transient > trigger 68 echo transient > trigger
68echo none > trigger 69 echo none > trigger
69 70
70NOTE: Add a new property trigger state to control the state. 71NOTE:
72 Add a new property trigger state to control the state.
71 73
72This trigger exports three properties, activate, state, and duration. When 74This trigger exports three properties, activate, state, and duration. When
73transient trigger is activated these properties are set to default values. 75transient trigger is activated these properties are set to default values.
@@ -79,7 +81,8 @@ transient trigger is activated these properties are set to default values.
79- state allows user to specify a transient state to be held for the specified 81- state allows user to specify a transient state to be held for the specified
80 duration. 82 duration.
81 83
82 activate - one shot timer activate mechanism. 84 activate
85 - one shot timer activate mechanism.
83 1 when activated, 0 when deactivated. 86 1 when activated, 0 when deactivated.
84 default value is zero when transient trigger is enabled, 87 default value is zero when transient trigger is enabled,
85 to allow duration to be set. 88 to allow duration to be set.
@@ -89,12 +92,14 @@ transient trigger is activated these properties are set to default values.
89 deactivated state indicates that there is no active timer 92 deactivated state indicates that there is no active timer
90 running. 93 running.
91 94
92 duration - one shot timer value. When activate is set, duration value 95 duration
96 - one shot timer value. When activate is set, duration value
93 is used to start a timer that runs once. This value doesn't 97 is used to start a timer that runs once. This value doesn't
94 get changed by the trigger unless user does a set via 98 get changed by the trigger unless user does a set via
95 echo new_value > duration 99 echo new_value > duration
96 100
97 state - transient state to be held. It has two values 0 or 1. 0 maps 101 state
102 - transient state to be held. It has two values 0 or 1. 0 maps
98 to LED_OFF and 1 maps to LED_FULL. The specified state is 103 to LED_OFF and 1 maps to LED_FULL. The specified state is
99 held for the duration of the one shot timer and then the 104 held for the duration of the one shot timer and then the
100 state gets changed to the non-transient state which is the 105 state gets changed to the non-transient state which is the
@@ -114,39 +119,49 @@ When timer expires activate goes back to deactivated state, duration is left
114at the set value to be used when activate is set at a future time. This will 119at the set value to be used when activate is set at a future time. This will
115allow user app to set the time once and activate it to run it once for the 120allow user app to set the time once and activate it to run it once for the
116specified value as needed. When timer expires, state is restored to the 121specified value as needed. When timer expires, state is restored to the
117non-transient state which is the inverse of the transient state. 122non-transient state which is the inverse of the transient state:
118 123
119 echo 1 > activate - starts timer = duration when duration is not 0. 124 ================= ===============================================
120 echo 0 > activate - cancels currently running timer. 125 echo 1 > activate starts timer = duration when duration is not 0.
121 echo n > duration - stores timer value to be used upon next 126 echo 0 > activate cancels currently running timer.
122 activate. Currently active timer if 127 echo n > duration stores timer value to be used upon next
123 any, continues to run for the specified time. 128 activate. Currently active timer if
124 echo 0 > duration - stores timer value to be used upon next 129 any, continues to run for the specified time.
125 activate. Currently active timer if any, 130 echo 0 > duration stores timer value to be used upon next
126 continues to run for the specified time. 131 activate. Currently active timer if any,
127 echo 1 > state - stores desired transient state LED_FULL to be 132 continues to run for the specified time.
133 echo 1 > state stores desired transient state LED_FULL to be
128 held for the specified duration. 134 held for the specified duration.
129 echo 0 > state - stores desired transient state LED_OFF to be 135 echo 0 > state stores desired transient state LED_OFF to be
130 held for the specified duration. 136 held for the specified duration.
137 ================= ===============================================
138
139What is not supported
140=====================
131 141
132What is not supported:
133======================
134- Timer activation is one shot and extending and/or shortening the timer 142- Timer activation is one shot and extending and/or shortening the timer
135 is not supported. 143 is not supported.
136 144
137Example use-case 1: 145Examples
146========
147
148use-case 1::
149
138 echo transient > trigger 150 echo transient > trigger
139 echo n > duration 151 echo n > duration
140 echo 1 > state 152 echo 1 > state
141repeat the following step as needed: 153
154repeat the following step as needed::
155
142 echo 1 > activate - start timer = duration to run once 156 echo 1 > activate - start timer = duration to run once
143 echo 1 > activate - start timer = duration to run once 157 echo 1 > activate - start timer = duration to run once
144 echo none > trigger 158 echo none > trigger
145 159
146This trigger is intended to be used for for the following example use cases: 160This trigger is intended to be used for for the following example use cases:
161
147 - Control of vibrate (phones, tablets etc.) hardware by user space app. 162 - Control of vibrate (phones, tablets etc.) hardware by user space app.
148 - Use of LED by user space app as activity indicator. 163 - Use of LED by user space app as activity indicator.
149 - Use of LED by user space app as a kind of watchdog indicator -- as 164 - Use of LED by user space app as a kind of watchdog indicator -- as
150 long as the app is alive, it can keep the LED illuminated, if it dies 165 long as the app is alive, it can keep the LED illuminated, if it dies
151 the LED will be extinguished automatically. 166 the LED will be extinguished automatically.
152 - Use by any user space app that needs a transient GPIO output. 167 - Use by any user space app that needs a transient GPIO output.
diff --git a/Documentation/leds/ledtrig-usbport.txt b/Documentation/leds/ledtrig-usbport.rst
index 69f54bfb4789..37c2505bfd57 100644
--- a/Documentation/leds/ledtrig-usbport.txt
+++ b/Documentation/leds/ledtrig-usbport.rst
@@ -1,3 +1,4 @@
1====================
1USB port LED trigger 2USB port LED trigger
2==================== 3====================
3 4
@@ -10,14 +11,18 @@ listed as separated entries in a "ports" subdirectory. Selecting is handled by
10echoing "1" to a chosen port. 11echoing "1" to a chosen port.
11 12
12Please note that this trigger allows selecting multiple USB ports for a single 13Please note that this trigger allows selecting multiple USB ports for a single
13LED. This can be useful in two cases: 14LED.
15
16This can be useful in two cases:
14 17
151) Device with single USB LED and few physical ports 181) Device with single USB LED and few physical ports
19====================================================
16 20
17In such a case LED will be turned on as long as there is at least one connected 21In such a case LED will be turned on as long as there is at least one connected
18USB device. 22USB device.
19 23
202) Device with a physical port handled by few controllers 242) Device with a physical port handled by few controllers
25=========================================================
21 26
22Some devices may have one controller per PHY standard. E.g. USB 3.0 physical 27Some devices may have one controller per PHY standard. E.g. USB 3.0 physical
23port may be handled by ohci-platform, ehci-platform and xhci-hcd. If there is 28port may be handled by ohci-platform, ehci-platform and xhci-hcd. If there is
@@ -25,14 +30,14 @@ only one LED user will most likely want to assign ports from all 3 hubs.
25 30
26 31
27This trigger can be activated from user space on led class devices as shown 32This trigger can be activated from user space on led class devices as shown
28below: 33below::
29 34
30 echo usbport > trigger 35 echo usbport > trigger
31 36
32This adds sysfs attributes to the LED that are documented in: 37This adds sysfs attributes to the LED that are documented in:
33Documentation/ABI/testing/sysfs-class-led-trigger-usbport 38Documentation/ABI/testing/sysfs-class-led-trigger-usbport
34 39
35Example use-case: 40Example use-case::
36 41
37 echo usbport > trigger 42 echo usbport > trigger
38 echo 1 > ports/usb1-port1 43 echo 1 > ports/usb1-port1
diff --git a/Documentation/leds/uleds.txt b/Documentation/leds/uleds.rst
index 13e375a580f9..83221098009c 100644
--- a/Documentation/leds/uleds.txt
+++ b/Documentation/leds/uleds.rst
@@ -1,3 +1,4 @@
1==============
1Userspace LEDs 2Userspace LEDs
2============== 3==============
3 4
@@ -10,12 +11,12 @@ Usage
10 11
11When the driver is loaded, a character device is created at /dev/uleds. To 12When the driver is loaded, a character device is created at /dev/uleds. To
12create a new LED class device, open /dev/uleds and write a uleds_user_dev 13create a new LED class device, open /dev/uleds and write a uleds_user_dev
13structure to it (found in kernel public header file linux/uleds.h). 14structure to it (found in kernel public header file linux/uleds.h)::
14 15
15 #define LED_MAX_NAME_SIZE 64 16 #define LED_MAX_NAME_SIZE 64
16 17
17 struct uleds_user_dev { 18 struct uleds_user_dev {
18 char name[LED_MAX_NAME_SIZE]; 19 char name[LED_MAX_NAME_SIZE];
19 }; 20 };
20 21
21A new LED class device will be created with the name given. The name can be 22A new LED class device will be created with the name given. The name can be
diff --git a/MAINTAINERS b/MAINTAINERS
index 558acf24ea1e..e61476a388b1 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -10165,7 +10165,7 @@ L: linux-leds@vger.kernel.org
10165S: Supported 10165S: Supported
10166F: drivers/leds/leds-mlxcpld.c 10166F: drivers/leds/leds-mlxcpld.c
10167F: drivers/leds/leds-mlxreg.c 10167F: drivers/leds/leds-mlxreg.c
10168F: Documentation/leds/leds-mlxcpld.txt 10168F: Documentation/leds/leds-mlxcpld.rst
10169 10169
10170MELLANOX PLATFORM DRIVER 10170MELLANOX PLATFORM DRIVER
10171M: Vadim Pasternak <vadimp@mellanox.com> 10171M: Vadim Pasternak <vadimp@mellanox.com>
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index 760f73a49c9f..b0fdeef10bd9 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -784,6 +784,41 @@ config LEDS_NIC78BX
784 To compile this driver as a module, choose M here: the module 784 To compile this driver as a module, choose M here: the module
785 will be called leds-nic78bx. 785 will be called leds-nic78bx.
786 786
787config LEDS_SPI_BYTE
788 tristate "LED support for SPI LED controller with a single byte"
789 depends on LEDS_CLASS
790 depends on SPI
791 depends on OF
792 help
793 This option enables support for LED controller which use a single byte
794 for controlling the brightness. Currently the following controller is
795 supported: Ubiquiti airCube ISP microcontroller based LED controller.
796
797config LEDS_TI_LMU_COMMON
798 tristate "LED driver for TI LMU"
799 depends on LEDS_CLASS
800 depends on REGMAP
801 help
802 Say Y to enable the LED driver for TI LMU devices.
803 This supports common features between the TI LM3532, LM3631, LM3632,
804 LM3633, LM3695 and LM3697.
805
806config LEDS_LM3697
807 tristate "LED driver for LM3697"
808 depends on LEDS_TI_LMU_COMMON
809 depends on I2C && OF
810 help
811 Say Y to enable the LM3697 LED driver for TI LMU devices.
812 This supports the LED device LM3697.
813
814config LEDS_LM36274
815 tristate "LED driver for LM36274"
816 depends on LEDS_TI_LMU_COMMON
817 depends on MFD_TI_LMU
818 help
819 Say Y to enable the LM36274 LED driver for TI LMU devices.
820 This supports the LED device LM36274.
821
787comment "LED Triggers" 822comment "LED Triggers"
788source "drivers/leds/trigger/Kconfig" 823source "drivers/leds/trigger/Kconfig"
789 824
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
index 1e9702ebffee..41fb073a39c1 100644
--- a/drivers/leds/Makefile
+++ b/drivers/leds/Makefile
@@ -77,10 +77,14 @@ obj-$(CONFIG_LEDS_PM8058) += leds-pm8058.o
77obj-$(CONFIG_LEDS_MLXCPLD) += leds-mlxcpld.o 77obj-$(CONFIG_LEDS_MLXCPLD) += leds-mlxcpld.o
78obj-$(CONFIG_LEDS_MLXREG) += leds-mlxreg.o 78obj-$(CONFIG_LEDS_MLXREG) += leds-mlxreg.o
79obj-$(CONFIG_LEDS_NIC78BX) += leds-nic78bx.o 79obj-$(CONFIG_LEDS_NIC78BX) += leds-nic78bx.o
80obj-$(CONFIG_LEDS_SPI_BYTE) += leds-spi-byte.o
80obj-$(CONFIG_LEDS_MT6323) += leds-mt6323.o 81obj-$(CONFIG_LEDS_MT6323) += leds-mt6323.o
81obj-$(CONFIG_LEDS_LM3692X) += leds-lm3692x.o 82obj-$(CONFIG_LEDS_LM3692X) += leds-lm3692x.o
82obj-$(CONFIG_LEDS_SC27XX_BLTC) += leds-sc27xx-bltc.o 83obj-$(CONFIG_LEDS_SC27XX_BLTC) += leds-sc27xx-bltc.o
83obj-$(CONFIG_LEDS_LM3601X) += leds-lm3601x.o 84obj-$(CONFIG_LEDS_LM3601X) += leds-lm3601x.o
85obj-$(CONFIG_LEDS_TI_LMU_COMMON) += leds-ti-lmu-common.o
86obj-$(CONFIG_LEDS_LM3697) += leds-lm3697.o
87obj-$(CONFIG_LEDS_LM36274) += leds-lm36274.o
84 88
85# LED SPI Drivers 89# LED SPI Drivers
86obj-$(CONFIG_LEDS_CR0014114) += leds-cr0014114.o 90obj-$(CONFIG_LEDS_CR0014114) += leds-cr0014114.o
diff --git a/drivers/leds/leds-lm36274.c b/drivers/leds/leds-lm36274.c
new file mode 100644
index 000000000000..ed9dc857ec8f
--- /dev/null
+++ b/drivers/leds/leds-lm36274.c
@@ -0,0 +1,172 @@
1// SPDX-License-Identifier: GPL-2.0
2// TI LM36274 LED chip family driver
3// Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
4
5#include <linux/bitops.h>
6#include <linux/device.h>
7#include <linux/err.h>
8#include <linux/leds.h>
9#include <linux/leds-ti-lmu-common.h>
10#include <linux/module.h>
11#include <linux/of_device.h>
12#include <linux/platform_device.h>
13
14#include <linux/mfd/ti-lmu.h>
15#include <linux/mfd/ti-lmu-register.h>
16
17#include <uapi/linux/uleds.h>
18
19#define LM36274_MAX_STRINGS 4
20#define LM36274_BL_EN BIT(4)
21
22/**
23 * struct lm36274
24 * @pdev: platform device
25 * @led_dev: led class device
26 * @lmu_data: Register and setting values for common code
27 * @regmap: Devices register map
28 * @dev: Pointer to the devices device struct
29 * @led_sources - The LED strings supported in this array
30 * @num_leds - Number of LED strings are supported in this array
31 */
32struct lm36274 {
33 struct platform_device *pdev;
34 struct led_classdev led_dev;
35 struct ti_lmu_bank lmu_data;
36 struct regmap *regmap;
37 struct device *dev;
38
39 u32 led_sources[LM36274_MAX_STRINGS];
40 int num_leds;
41};
42
43static int lm36274_brightness_set(struct led_classdev *led_cdev,
44 enum led_brightness brt_val)
45{
46 struct lm36274 *led = container_of(led_cdev, struct lm36274, led_dev);
47
48 return ti_lmu_common_set_brightness(&led->lmu_data, brt_val);
49}
50
51static int lm36274_init(struct lm36274 *lm36274_data)
52{
53 int enable_val = 0;
54 int i;
55
56 for (i = 0; i < lm36274_data->num_leds; i++)
57 enable_val |= (1 << lm36274_data->led_sources[i]);
58
59 if (!enable_val) {
60 dev_err(lm36274_data->dev, "No LEDs were enabled\n");
61 return -EINVAL;
62 }
63
64 enable_val |= LM36274_BL_EN;
65
66 return regmap_write(lm36274_data->regmap, LM36274_REG_BL_EN,
67 enable_val);
68}
69
70static int lm36274_parse_dt(struct lm36274 *lm36274_data)
71{
72 struct fwnode_handle *child = NULL;
73 char label[LED_MAX_NAME_SIZE];
74 struct device *dev = &lm36274_data->pdev->dev;
75 const char *name;
76 int child_cnt;
77 int ret = -EINVAL;
78
79 /* There should only be 1 node */
80 child_cnt = device_get_child_node_count(dev);
81 if (child_cnt != 1)
82 return -EINVAL;
83
84 device_for_each_child_node(dev, child) {
85 ret = fwnode_property_read_string(child, "label", &name);
86 if (ret)
87 snprintf(label, sizeof(label),
88 "%s::", lm36274_data->pdev->name);
89 else
90 snprintf(label, sizeof(label),
91 "%s:%s", lm36274_data->pdev->name, name);
92
93 lm36274_data->num_leds = fwnode_property_read_u32_array(child,
94 "led-sources",
95 NULL, 0);
96 if (lm36274_data->num_leds <= 0)
97 return -ENODEV;
98
99 ret = fwnode_property_read_u32_array(child, "led-sources",
100 lm36274_data->led_sources,
101 lm36274_data->num_leds);
102 if (ret) {
103 dev_err(dev, "led-sources property missing\n");
104 return ret;
105 }
106
107 fwnode_property_read_string(child, "linux,default-trigger",
108 &lm36274_data->led_dev.default_trigger);
109
110 }
111
112 lm36274_data->lmu_data.regmap = lm36274_data->regmap;
113 lm36274_data->lmu_data.max_brightness = MAX_BRIGHTNESS_11BIT;
114 lm36274_data->lmu_data.msb_brightness_reg = LM36274_REG_BRT_MSB;
115 lm36274_data->lmu_data.lsb_brightness_reg = LM36274_REG_BRT_LSB;
116
117 lm36274_data->led_dev.name = label;
118 lm36274_data->led_dev.max_brightness = MAX_BRIGHTNESS_11BIT;
119 lm36274_data->led_dev.brightness_set_blocking = lm36274_brightness_set;
120
121 return 0;
122}
123
124static int lm36274_probe(struct platform_device *pdev)
125{
126 struct ti_lmu *lmu = dev_get_drvdata(pdev->dev.parent);
127 struct lm36274 *lm36274_data;
128 int ret;
129
130 lm36274_data = devm_kzalloc(&pdev->dev, sizeof(*lm36274_data),
131 GFP_KERNEL);
132 if (!lm36274_data)
133 return -ENOMEM;
134
135 lm36274_data->pdev = pdev;
136 lm36274_data->dev = lmu->dev;
137 lm36274_data->regmap = lmu->regmap;
138 dev_set_drvdata(&pdev->dev, lm36274_data);
139
140 ret = lm36274_parse_dt(lm36274_data);
141 if (ret) {
142 dev_err(lm36274_data->dev, "Failed to parse DT node\n");
143 return ret;
144 }
145
146 ret = lm36274_init(lm36274_data);
147 if (ret) {
148 dev_err(lm36274_data->dev, "Failed to init the device\n");
149 return ret;
150 }
151
152 return devm_led_classdev_register(lm36274_data->dev,
153 &lm36274_data->led_dev);
154}
155
156static const struct of_device_id of_lm36274_leds_match[] = {
157 { .compatible = "ti,lm36274-backlight", },
158 {},
159};
160MODULE_DEVICE_TABLE(of, of_lm36274_leds_match);
161
162static struct platform_driver lm36274_driver = {
163 .probe = lm36274_probe,
164 .driver = {
165 .name = "lm36274-leds",
166 },
167};
168module_platform_driver(lm36274_driver)
169
170MODULE_DESCRIPTION("Texas Instruments LM36274 LED driver");
171MODULE_AUTHOR("Dan Murphy <dmurphy@ti.com>");
172MODULE_LICENSE("GPL v2");
diff --git a/drivers/leds/leds-lm3697.c b/drivers/leds/leds-lm3697.c
new file mode 100644
index 000000000000..54e0e35df824
--- /dev/null
+++ b/drivers/leds/leds-lm3697.c
@@ -0,0 +1,395 @@
1// SPDX-License-Identifier: GPL-2.0
2// TI LM3697 LED chip family driver
3// Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/
4
5#include <linux/gpio/consumer.h>
6#include <linux/i2c.h>
7#include <linux/of.h>
8#include <linux/of_gpio.h>
9#include <linux/regulator/consumer.h>
10#include <linux/leds-ti-lmu-common.h>
11
12#define LM3697_REV 0x0
13#define LM3697_RESET 0x1
14#define LM3697_OUTPUT_CONFIG 0x10
15#define LM3697_CTRL_A_RAMP 0x11
16#define LM3697_CTRL_B_RAMP 0x12
17#define LM3697_CTRL_A_B_RT_RAMP 0x13
18#define LM3697_CTRL_A_B_RAMP_CFG 0x14
19#define LM3697_CTRL_A_B_BRT_CFG 0x16
20#define LM3697_CTRL_A_FS_CURR_CFG 0x17
21#define LM3697_CTRL_B_FS_CURR_CFG 0x18
22#define LM3697_PWM_CFG 0x1c
23#define LM3697_CTRL_A_BRT_LSB 0x20
24#define LM3697_CTRL_A_BRT_MSB 0x21
25#define LM3697_CTRL_B_BRT_LSB 0x22
26#define LM3697_CTRL_B_BRT_MSB 0x23
27#define LM3697_CTRL_ENABLE 0x24
28
29#define LM3697_SW_RESET BIT(0)
30
31#define LM3697_CTRL_A_EN BIT(0)
32#define LM3697_CTRL_B_EN BIT(1)
33#define LM3697_CTRL_A_B_EN (LM3697_CTRL_A_EN | LM3697_CTRL_B_EN)
34
35#define LM3697_MAX_LED_STRINGS 3
36
37#define LM3697_CONTROL_A 0
38#define LM3697_CONTROL_B 1
39#define LM3697_MAX_CONTROL_BANKS 2
40
41/**
42 * struct lm3697_led -
43 * @hvled_strings: Array of LED strings associated with a control bank
44 * @label: LED label
45 * @led_dev: LED class device
46 * @priv: Pointer to the device struct
47 * @lmu_data: Register and setting values for common code
48 * @control_bank: Control bank the LED is associated to. 0 is control bank A
49 * 1 is control bank B
50 */
51struct lm3697_led {
52 u32 hvled_strings[LM3697_MAX_LED_STRINGS];
53 char label[LED_MAX_NAME_SIZE];
54 struct led_classdev led_dev;
55 struct lm3697 *priv;
56 struct ti_lmu_bank lmu_data;
57 int control_bank;
58 int enabled;
59 int num_leds;
60};
61
62/**
63 * struct lm3697 -
64 * @enable_gpio: Hardware enable gpio
65 * @regulator: LED supply regulator pointer
66 * @client: Pointer to the I2C client
67 * @regmap: Devices register map
68 * @dev: Pointer to the devices device struct
69 * @lock: Lock for reading/writing the device
70 * @leds: Array of LED strings
71 */
72struct lm3697 {
73 struct gpio_desc *enable_gpio;
74 struct regulator *regulator;
75 struct i2c_client *client;
76 struct regmap *regmap;
77 struct device *dev;
78 struct mutex lock;
79
80 int bank_cfg;
81
82 struct lm3697_led leds[];
83};
84
85static const struct reg_default lm3697_reg_defs[] = {
86 {LM3697_OUTPUT_CONFIG, 0x6},
87 {LM3697_CTRL_A_RAMP, 0x0},
88 {LM3697_CTRL_B_RAMP, 0x0},
89 {LM3697_CTRL_A_B_RT_RAMP, 0x0},
90 {LM3697_CTRL_A_B_RAMP_CFG, 0x0},
91 {LM3697_CTRL_A_B_BRT_CFG, 0x0},
92 {LM3697_CTRL_A_FS_CURR_CFG, 0x13},
93 {LM3697_CTRL_B_FS_CURR_CFG, 0x13},
94 {LM3697_PWM_CFG, 0xc},
95 {LM3697_CTRL_A_BRT_LSB, 0x0},
96 {LM3697_CTRL_A_BRT_MSB, 0x0},
97 {LM3697_CTRL_B_BRT_LSB, 0x0},
98 {LM3697_CTRL_B_BRT_MSB, 0x0},
99 {LM3697_CTRL_ENABLE, 0x0},
100};
101
102static const struct regmap_config lm3697_regmap_config = {
103 .reg_bits = 8,
104 .val_bits = 8,
105
106 .max_register = LM3697_CTRL_ENABLE,
107 .reg_defaults = lm3697_reg_defs,
108 .num_reg_defaults = ARRAY_SIZE(lm3697_reg_defs),
109 .cache_type = REGCACHE_FLAT,
110};
111
112static int lm3697_brightness_set(struct led_classdev *led_cdev,
113 enum led_brightness brt_val)
114{
115 struct lm3697_led *led = container_of(led_cdev, struct lm3697_led,
116 led_dev);
117 int ctrl_en_val = (1 << led->control_bank);
118 int ret;
119
120 mutex_lock(&led->priv->lock);
121
122 if (brt_val == LED_OFF) {
123 ret = regmap_update_bits(led->priv->regmap, LM3697_CTRL_ENABLE,
124 ctrl_en_val, ~ctrl_en_val);
125 if (ret) {
126 dev_err(&led->priv->client->dev, "Cannot write ctrl register\n");
127 goto brightness_out;
128 }
129
130 led->enabled = LED_OFF;
131 } else {
132 ret = ti_lmu_common_set_brightness(&led->lmu_data, brt_val);
133 if (ret) {
134 dev_err(&led->priv->client->dev,
135 "Cannot write brightness\n");
136 goto brightness_out;
137 }
138
139 if (!led->enabled) {
140 ret = regmap_update_bits(led->priv->regmap,
141 LM3697_CTRL_ENABLE,
142 ctrl_en_val, ctrl_en_val);
143 if (ret) {
144 dev_err(&led->priv->client->dev,
145 "Cannot enable the device\n");
146 goto brightness_out;
147 }
148
149 led->enabled = brt_val;
150 }
151 }
152
153brightness_out:
154 mutex_unlock(&led->priv->lock);
155 return ret;
156}
157
158static int lm3697_init(struct lm3697 *priv)
159{
160 struct lm3697_led *led;
161 int i, ret;
162
163 if (priv->enable_gpio) {
164 gpiod_direction_output(priv->enable_gpio, 1);
165 } else {
166 ret = regmap_write(priv->regmap, LM3697_RESET, LM3697_SW_RESET);
167 if (ret) {
168 dev_err(&priv->client->dev, "Cannot reset the device\n");
169 goto out;
170 }
171 }
172
173 ret = regmap_write(priv->regmap, LM3697_CTRL_ENABLE, 0x0);
174 if (ret) {
175 dev_err(&priv->client->dev, "Cannot write ctrl enable\n");
176 goto out;
177 }
178
179 ret = regmap_write(priv->regmap, LM3697_OUTPUT_CONFIG, priv->bank_cfg);
180 if (ret)
181 dev_err(&priv->client->dev, "Cannot write OUTPUT config\n");
182
183 for (i = 0; i < LM3697_MAX_CONTROL_BANKS; i++) {
184 led = &priv->leds[i];
185 ret = ti_lmu_common_set_ramp(&led->lmu_data);
186 if (ret)
187 dev_err(&priv->client->dev, "Setting the ramp rate failed\n");
188 }
189out:
190 return ret;
191}
192
193static int lm3697_probe_dt(struct lm3697 *priv)
194{
195 struct fwnode_handle *child = NULL;
196 struct lm3697_led *led;
197 const char *name;
198 int control_bank;
199 size_t i = 0;
200 int ret = -EINVAL;
201 int j;
202
203 priv->enable_gpio = devm_gpiod_get_optional(&priv->client->dev,
204 "enable", GPIOD_OUT_LOW);
205 if (IS_ERR(priv->enable_gpio)) {
206 ret = PTR_ERR(priv->enable_gpio);
207 dev_err(&priv->client->dev, "Failed to get enable gpio: %d\n",
208 ret);
209 return ret;
210 }
211
212 priv->regulator = devm_regulator_get(&priv->client->dev, "vled");
213 if (IS_ERR(priv->regulator))
214 priv->regulator = NULL;
215
216 device_for_each_child_node(priv->dev, child) {
217 ret = fwnode_property_read_u32(child, "reg", &control_bank);
218 if (ret) {
219 dev_err(&priv->client->dev, "reg property missing\n");
220 fwnode_handle_put(child);
221 goto child_out;
222 }
223
224 if (control_bank > LM3697_CONTROL_B) {
225 dev_err(&priv->client->dev, "reg property is invalid\n");
226 ret = -EINVAL;
227 fwnode_handle_put(child);
228 goto child_out;
229 }
230
231 led = &priv->leds[i];
232
233 ret = ti_lmu_common_get_brt_res(&priv->client->dev,
234 child, &led->lmu_data);
235 if (ret)
236 dev_warn(&priv->client->dev, "brightness resolution property missing\n");
237
238 led->control_bank = control_bank;
239 led->lmu_data.regmap = priv->regmap;
240 led->lmu_data.runtime_ramp_reg = LM3697_CTRL_A_RAMP +
241 control_bank;
242 led->lmu_data.msb_brightness_reg = LM3697_CTRL_A_BRT_MSB +
243 led->control_bank * 2;
244 led->lmu_data.lsb_brightness_reg = LM3697_CTRL_A_BRT_LSB +
245 led->control_bank * 2;
246
247 led->num_leds = fwnode_property_read_u32_array(child,
248 "led-sources",
249 NULL, 0);
250
251 if (led->num_leds > LM3697_MAX_LED_STRINGS) {
252 dev_err(&priv->client->dev, "To many LED strings defined\n");
253 continue;
254 }
255
256 ret = fwnode_property_read_u32_array(child, "led-sources",
257 led->hvled_strings,
258 led->num_leds);
259 if (ret) {
260 dev_err(&priv->client->dev, "led-sources property missing\n");
261 fwnode_handle_put(child);
262 goto child_out;
263 }
264
265 for (j = 0; j < led->num_leds; j++)
266 priv->bank_cfg |=
267 (led->control_bank << led->hvled_strings[j]);
268
269 ret = ti_lmu_common_get_ramp_params(&priv->client->dev,
270 child, &led->lmu_data);
271 if (ret)
272 dev_warn(&priv->client->dev, "runtime-ramp properties missing\n");
273
274 fwnode_property_read_string(child, "linux,default-trigger",
275 &led->led_dev.default_trigger);
276
277 ret = fwnode_property_read_string(child, "label", &name);
278 if (ret)
279 snprintf(led->label, sizeof(led->label),
280 "%s::", priv->client->name);
281 else
282 snprintf(led->label, sizeof(led->label),
283 "%s:%s", priv->client->name, name);
284
285 led->priv = priv;
286 led->led_dev.name = led->label;
287 led->led_dev.max_brightness = led->lmu_data.max_brightness;
288 led->led_dev.brightness_set_blocking = lm3697_brightness_set;
289
290 ret = devm_led_classdev_register(priv->dev, &led->led_dev);
291 if (ret) {
292 dev_err(&priv->client->dev, "led register err: %d\n",
293 ret);
294 fwnode_handle_put(child);
295 goto child_out;
296 }
297
298 i++;
299 }
300
301child_out:
302 return ret;
303}
304
305static int lm3697_probe(struct i2c_client *client,
306 const struct i2c_device_id *id)
307{
308 struct lm3697 *led;
309 int count;
310 int ret;
311
312 count = device_get_child_node_count(&client->dev);
313 if (!count) {
314 dev_err(&client->dev, "LEDs are not defined in device tree!");
315 return -ENODEV;
316 }
317
318 led = devm_kzalloc(&client->dev, struct_size(led, leds, count),
319 GFP_KERNEL);
320 if (!led)
321 return -ENOMEM;
322
323 mutex_init(&led->lock);
324 i2c_set_clientdata(client, led);
325
326 led->client = client;
327 led->dev = &client->dev;
328 led->regmap = devm_regmap_init_i2c(client, &lm3697_regmap_config);
329 if (IS_ERR(led->regmap)) {
330 ret = PTR_ERR(led->regmap);
331 dev_err(&client->dev, "Failed to allocate register map: %d\n",
332 ret);
333 return ret;
334 }
335
336 ret = lm3697_probe_dt(led);
337 if (ret)
338 return ret;
339
340 return lm3697_init(led);
341}
342
343static int lm3697_remove(struct i2c_client *client)
344{
345 struct lm3697 *led = i2c_get_clientdata(client);
346 int ret;
347
348 ret = regmap_update_bits(led->regmap, LM3697_CTRL_ENABLE,
349 LM3697_CTRL_A_B_EN, 0);
350 if (ret) {
351 dev_err(&led->client->dev, "Failed to disable the device\n");
352 return ret;
353 }
354
355 if (led->enable_gpio)
356 gpiod_direction_output(led->enable_gpio, 0);
357
358 if (led->regulator) {
359 ret = regulator_disable(led->regulator);
360 if (ret)
361 dev_err(&led->client->dev,
362 "Failed to disable regulator\n");
363 }
364
365 mutex_destroy(&led->lock);
366
367 return 0;
368}
369
370static const struct i2c_device_id lm3697_id[] = {
371 { "lm3697", 0 },
372 { }
373};
374MODULE_DEVICE_TABLE(i2c, lm3697_id);
375
376static const struct of_device_id of_lm3697_leds_match[] = {
377 { .compatible = "ti,lm3697", },
378 {},
379};
380MODULE_DEVICE_TABLE(of, of_lm3697_leds_match);
381
382static struct i2c_driver lm3697_driver = {
383 .driver = {
384 .name = "lm3697",
385 .of_match_table = of_lm3697_leds_match,
386 },
387 .probe = lm3697_probe,
388 .remove = lm3697_remove,
389 .id_table = lm3697_id,
390};
391module_i2c_driver(lm3697_driver);
392
393MODULE_DESCRIPTION("Texas Instruments LM3697 LED driver");
394MODULE_AUTHOR("Dan Murphy <dmurphy@ti.com>");
395MODULE_LICENSE("GPL v2");
diff --git a/drivers/leds/leds-max77650.c b/drivers/leds/leds-max77650.c
index 6b74ce9cac12..8a8e5c65b157 100644
--- a/drivers/leds/leds-max77650.c
+++ b/drivers/leds/leds-max77650.c
@@ -64,7 +64,6 @@ static int max77650_led_probe(struct platform_device *pdev)
64{ 64{
65 struct device_node *of_node, *child; 65 struct device_node *of_node, *child;
66 struct max77650_led *leds, *led; 66 struct max77650_led *leds, *led;
67 struct device *parent;
68 struct device *dev; 67 struct device *dev;
69 struct regmap *map; 68 struct regmap *map;
70 const char *label; 69 const char *label;
@@ -72,7 +71,6 @@ static int max77650_led_probe(struct platform_device *pdev)
72 u32 reg; 71 u32 reg;
73 72
74 dev = &pdev->dev; 73 dev = &pdev->dev;
75 parent = dev->parent;
76 of_node = dev->of_node; 74 of_node = dev->of_node;
77 75
78 if (!of_node) 76 if (!of_node)
diff --git a/drivers/leds/leds-pca955x.c b/drivers/leds/leds-pca955x.c
index c2bc8f569760..4037c504589c 100644
--- a/drivers/leds/leds-pca955x.c
+++ b/drivers/leds/leds-pca955x.c
@@ -429,7 +429,7 @@ static int pca955x_probe(struct i2c_client *client,
429 int ngpios = 0; 429 int ngpios = 0;
430 430
431 chip = &pca955x_chipdefs[id->driver_data]; 431 chip = &pca955x_chipdefs[id->driver_data];
432 adapter = to_i2c_adapter(client->dev.parent); 432 adapter = client->adapter;
433 pdata = dev_get_platdata(&client->dev); 433 pdata = dev_get_platdata(&client->dev);
434 if (!pdata) { 434 if (!pdata) {
435 pdata = pca955x_get_pdata(client, chip); 435 pdata = pca955x_get_pdata(client, chip);
diff --git a/drivers/leds/leds-spi-byte.c b/drivers/leds/leds-spi-byte.c
new file mode 100644
index 000000000000..b231b563b7bb
--- /dev/null
+++ b/drivers/leds/leds-spi-byte.c
@@ -0,0 +1,161 @@
1// SPDX-License-Identifier: GPL-2.0
2// Copyright (c) 2019 Christian Mauderer <oss@c-mauderer.de>
3
4/*
5 * The driver supports controllers with a very simple SPI protocol:
6 * - one LED is controlled by a single byte on MOSI
7 * - the value of the byte gives the brightness between two values (lowest to
8 * highest)
9 * - no return value is necessary (no MISO signal)
10 *
11 * The value for minimum and maximum brightness depends on the device
12 * (compatible string).
13 *
14 * Supported devices:
15 * - "ubnt,acb-spi-led": Microcontroller (SONiX 8F26E611LA) based device used
16 * for example in Ubiquiti airCube ISP. Reverse engineered protocol for this
17 * controller:
18 * * Higher two bits set a mode. Lower six bits are a parameter.
19 * * Mode: 00 -> set brightness between 0x00 (min) and 0x3F (max)
20 * * Mode: 01 -> pulsing pattern (min -> max -> min) with an interval. From
21 * some tests, the period is about (50ms + 102ms * parameter). There is a
22 * slightly different pattern starting from 0x10 (longer gap between the
23 * pulses) but the time still follows that calculation.
24 * * Mode: 10 -> same as 01 but with only a ramp from min to max. Again a
25 * slight jump in the pattern at 0x10.
26 * * Mode: 11 -> blinking (off -> 25% -> off -> 25% -> ...) with a period of
27 * (105ms * parameter)
28 * NOTE: This driver currently only supports mode 00.
29 */
30
31#include <linux/leds.h>
32#include <linux/module.h>
33#include <linux/of_device.h>
34#include <linux/spi/spi.h>
35#include <linux/mutex.h>
36#include <uapi/linux/uleds.h>
37
38struct spi_byte_chipdef {
39 /* SPI byte that will be send to switch the LED off */
40 u8 off_value;
41 /* SPI byte that will be send to switch the LED to maximum brightness */
42 u8 max_value;
43};
44
45struct spi_byte_led {
46 struct led_classdev ldev;
47 struct spi_device *spi;
48 char name[LED_MAX_NAME_SIZE];
49 struct mutex mutex;
50 const struct spi_byte_chipdef *cdef;
51};
52
53static const struct spi_byte_chipdef ubnt_acb_spi_led_cdef = {
54 .off_value = 0x0,
55 .max_value = 0x3F,
56};
57
58static const struct of_device_id spi_byte_dt_ids[] = {
59 { .compatible = "ubnt,acb-spi-led", .data = &ubnt_acb_spi_led_cdef },
60 {},
61};
62
63MODULE_DEVICE_TABLE(of, spi_byte_dt_ids);
64
65static int spi_byte_brightness_set_blocking(struct led_classdev *dev,
66 enum led_brightness brightness)
67{
68 struct spi_byte_led *led = container_of(dev, struct spi_byte_led, ldev);
69 u8 value;
70 int ret;
71
72 value = (u8) brightness + led->cdef->off_value;
73
74 mutex_lock(&led->mutex);
75 ret = spi_write(led->spi, &value, sizeof(value));
76 mutex_unlock(&led->mutex);
77
78 return ret;
79}
80
81static int spi_byte_probe(struct spi_device *spi)
82{
83 const struct of_device_id *of_dev_id;
84 struct device_node *child;
85 struct device *dev = &spi->dev;
86 struct spi_byte_led *led;
87 const char *name = "leds-spi-byte::";
88 const char *state;
89 int ret;
90
91 of_dev_id = of_match_device(spi_byte_dt_ids, dev);
92 if (!of_dev_id)
93 return -EINVAL;
94
95 if (of_get_child_count(dev->of_node) != 1) {
96 dev_err(dev, "Device must have exactly one LED sub-node.");
97 return -EINVAL;
98 }
99 child = of_get_next_child(dev->of_node, NULL);
100
101 led = devm_kzalloc(dev, sizeof(*led), GFP_KERNEL);
102 if (!led)
103 return -ENOMEM;
104
105 of_property_read_string(child, "label", &name);
106 strlcpy(led->name, name, sizeof(led->name));
107 led->spi = spi;
108 mutex_init(&led->mutex);
109 led->cdef = of_dev_id->data;
110 led->ldev.name = led->name;
111 led->ldev.brightness = LED_OFF;
112 led->ldev.max_brightness = led->cdef->max_value - led->cdef->off_value;
113 led->ldev.brightness_set_blocking = spi_byte_brightness_set_blocking;
114
115 state = of_get_property(child, "default-state", NULL);
116 if (state) {
117 if (!strcmp(state, "on")) {
118 led->ldev.brightness = led->ldev.max_brightness;
119 } else if (strcmp(state, "off")) {
120 /* all other cases except "off" */
121 dev_err(dev, "default-state can only be 'on' or 'off'");
122 return -EINVAL;
123 }
124 }
125 spi_byte_brightness_set_blocking(&led->ldev,
126 led->ldev.brightness);
127
128 ret = devm_led_classdev_register(&spi->dev, &led->ldev);
129 if (ret) {
130 mutex_destroy(&led->mutex);
131 return ret;
132 }
133 spi_set_drvdata(spi, led);
134
135 return 0;
136}
137
138static int spi_byte_remove(struct spi_device *spi)
139{
140 struct spi_byte_led *led = spi_get_drvdata(spi);
141
142 mutex_destroy(&led->mutex);
143
144 return 0;
145}
146
147static struct spi_driver spi_byte_driver = {
148 .probe = spi_byte_probe,
149 .remove = spi_byte_remove,
150 .driver = {
151 .name = KBUILD_MODNAME,
152 .of_match_table = spi_byte_dt_ids,
153 },
154};
155
156module_spi_driver(spi_byte_driver);
157
158MODULE_AUTHOR("Christian Mauderer <oss@c-mauderer.de>");
159MODULE_DESCRIPTION("single byte SPI LED driver");
160MODULE_LICENSE("GPL v2");
161MODULE_ALIAS("spi:leds-spi-byte");
diff --git a/drivers/leds/leds-tca6507.c b/drivers/leds/leds-tca6507.c
index c59035e157d1..58be20cae183 100644
--- a/drivers/leds/leds-tca6507.c
+++ b/drivers/leds/leds-tca6507.c
@@ -758,7 +758,7 @@ static int tca6507_probe(struct i2c_client *client,
758 int err; 758 int err;
759 int i = 0; 759 int i = 0;
760 760
761 adapter = to_i2c_adapter(client->dev.parent); 761 adapter = client->adapter;
762 pdata = dev_get_platdata(&client->dev); 762 pdata = dev_get_platdata(&client->dev);
763 763
764 if (!i2c_check_functionality(adapter, I2C_FUNC_I2C)) 764 if (!i2c_check_functionality(adapter, I2C_FUNC_I2C))
diff --git a/drivers/leds/leds-ti-lmu-common.c b/drivers/leds/leds-ti-lmu-common.c
new file mode 100644
index 000000000000..adc7293004f1
--- /dev/null
+++ b/drivers/leds/leds-ti-lmu-common.c
@@ -0,0 +1,156 @@
1// SPDX-License-Identifier: GPL-2.0
2// Copyright 2015 Texas Instruments
3// Copyright 2018 Sebastian Reichel
4// Copyright 2018 Pavel Machek <pavel@ucw.cz>
5// TI LMU LED common framework, based on previous work from
6// Milo Kim <milo.kim@ti.com>
7
8#include <linux/bitops.h>
9#include <linux/err.h>
10#include <linux/of_device.h>
11
12#include <linux/leds-ti-lmu-common.h>
13
14const static int ramp_table[16] = {2048, 262000, 524000, 1049000, 2090000,
15 4194000, 8389000, 16780000, 33550000, 41940000,
16 50330000, 58720000, 67110000, 83880000,
17 100660000, 117440000};
18
19static int ti_lmu_common_update_brightness(struct ti_lmu_bank *lmu_bank,
20 int brightness)
21{
22 struct regmap *regmap = lmu_bank->regmap;
23 u8 reg, val;
24 int ret;
25
26 /*
27 * Brightness register update
28 *
29 * 11 bit dimming: update LSB bits and write MSB byte.
30 * MSB brightness should be shifted.
31 * 8 bit dimming: write MSB byte.
32 */
33 if (lmu_bank->max_brightness == MAX_BRIGHTNESS_11BIT) {
34 reg = lmu_bank->lsb_brightness_reg;
35 ret = regmap_update_bits(regmap, reg,
36 LMU_11BIT_LSB_MASK,
37 brightness);
38 if (ret)
39 return ret;
40
41 val = brightness >> LMU_11BIT_MSB_SHIFT;
42 } else {
43 val = brightness;
44 }
45
46 reg = lmu_bank->msb_brightness_reg;
47
48 return regmap_write(regmap, reg, val);
49}
50
51int ti_lmu_common_set_brightness(struct ti_lmu_bank *lmu_bank, int brightness)
52{
53 return ti_lmu_common_update_brightness(lmu_bank, brightness);
54}
55EXPORT_SYMBOL(ti_lmu_common_set_brightness);
56
57static int ti_lmu_common_convert_ramp_to_index(unsigned int usec)
58{
59 int size = ARRAY_SIZE(ramp_table);
60 int i;
61
62 if (usec <= ramp_table[0])
63 return 0;
64
65 if (usec > ramp_table[size - 1])
66 return size - 1;
67
68 for (i = 1; i < size; i++) {
69 if (usec == ramp_table[i])
70 return i;
71
72 /* Find an approximate index by looking up the table */
73 if (usec > ramp_table[i - 1] && usec < ramp_table[i]) {
74 if (usec - ramp_table[i - 1] < ramp_table[i] - usec)
75 return i - 1;
76 else
77 return i;
78 }
79 }
80
81 return -EINVAL;
82}
83
84int ti_lmu_common_set_ramp(struct ti_lmu_bank *lmu_bank)
85{
86 struct regmap *regmap = lmu_bank->regmap;
87 u8 ramp, ramp_up, ramp_down;
88
89 if (lmu_bank->ramp_up_usec == 0 && lmu_bank->ramp_down_usec == 0) {
90 ramp_up = 0;
91 ramp_down = 0;
92 } else {
93 ramp_up = ti_lmu_common_convert_ramp_to_index(lmu_bank->ramp_up_usec);
94 ramp_down = ti_lmu_common_convert_ramp_to_index(lmu_bank->ramp_down_usec);
95 }
96
97 if (ramp_up < 0 || ramp_down < 0)
98 return -EINVAL;
99
100 ramp = (ramp_up << 4) | ramp_down;
101
102 return regmap_write(regmap, lmu_bank->runtime_ramp_reg, ramp);
103
104}
105EXPORT_SYMBOL(ti_lmu_common_set_ramp);
106
107int ti_lmu_common_get_ramp_params(struct device *dev,
108 struct fwnode_handle *child,
109 struct ti_lmu_bank *lmu_data)
110{
111 int ret;
112
113 ret = fwnode_property_read_u32(child, "ramp-up-us",
114 &lmu_data->ramp_up_usec);
115 if (ret)
116 dev_warn(dev, "ramp-up-us property missing\n");
117
118
119 ret = fwnode_property_read_u32(child, "ramp-down-us",
120 &lmu_data->ramp_down_usec);
121 if (ret)
122 dev_warn(dev, "ramp-down-us property missing\n");
123
124 return 0;
125}
126EXPORT_SYMBOL(ti_lmu_common_get_ramp_params);
127
128int ti_lmu_common_get_brt_res(struct device *dev, struct fwnode_handle *child,
129 struct ti_lmu_bank *lmu_data)
130{
131 int ret;
132
133 ret = device_property_read_u32(dev, "ti,brightness-resolution",
134 &lmu_data->max_brightness);
135 if (ret)
136 ret = fwnode_property_read_u32(child,
137 "ti,brightness-resolution",
138 &lmu_data->max_brightness);
139 if (lmu_data->max_brightness <= 0) {
140 lmu_data->max_brightness = MAX_BRIGHTNESS_8BIT;
141 return ret;
142 }
143
144 if (lmu_data->max_brightness > MAX_BRIGHTNESS_11BIT)
145 lmu_data->max_brightness = MAX_BRIGHTNESS_11BIT;
146
147
148 return 0;
149}
150EXPORT_SYMBOL(ti_lmu_common_get_brt_res);
151
152MODULE_DESCRIPTION("TI LMU common LED framework");
153MODULE_AUTHOR("Sebastian Reichel");
154MODULE_AUTHOR("Dan Murphy <dmurphy@ti.com>");
155MODULE_LICENSE("GPL v2");
156MODULE_ALIAS("ti-lmu-led-common");
diff --git a/drivers/leds/trigger/Kconfig b/drivers/leds/trigger/Kconfig
index 7fa9d174a40c..ce9429ca6dde 100644
--- a/drivers/leds/trigger/Kconfig
+++ b/drivers/leds/trigger/Kconfig
@@ -15,7 +15,7 @@ config LEDS_TRIGGER_TIMER
15 This allows LEDs to be controlled by a programmable timer 15 This allows LEDs to be controlled by a programmable timer
16 via sysfs. Some LED hardware can be programmed to start 16 via sysfs. Some LED hardware can be programmed to start
17 blinking the LED without any further software interaction. 17 blinking the LED without any further software interaction.
18 For more details read Documentation/leds/leds-class.txt. 18 For more details read Documentation/leds/leds-class.rst.
19 19
20 If unsure, say Y. 20 If unsure, say Y.
21 21
diff --git a/drivers/leds/trigger/ledtrig-transient.c b/drivers/leds/trigger/ledtrig-transient.c
index a80bb82aacc2..80635183fac8 100644
--- a/drivers/leds/trigger/ledtrig-transient.c
+++ b/drivers/leds/trigger/ledtrig-transient.c
@@ -3,7 +3,7 @@
3// LED Kernel Transient Trigger 3// LED Kernel Transient Trigger
4// 4//
5// Transient trigger allows one shot timer activation. Please refer to 5// Transient trigger allows one shot timer activation. Please refer to
6// Documentation/leds/ledtrig-transient.txt for details 6// Documentation/leds/ledtrig-transient.rst for details
7// Copyright (C) 2012 Shuah Khan <shuahkhan@gmail.com> 7// Copyright (C) 2012 Shuah Khan <shuahkhan@gmail.com>
8// 8//
9// Based on Richard Purdie's ledtrig-timer.c and Atsushi Nemoto's 9// Based on Richard Purdie's ledtrig-timer.c and Atsushi Nemoto's
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index a17d275bf1d4..6855ff443e04 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -1336,9 +1336,8 @@ config MFD_TI_LMU
1336 select REGMAP_I2C 1336 select REGMAP_I2C
1337 help 1337 help
1338 Say yes here to enable support for TI LMU chips. 1338 Say yes here to enable support for TI LMU chips.
1339 1339 TI LMU MFD supports LM3532, LM3631, LM3632, LM3633, LM3695 and
1340 TI LMU MFD supports LM3532, LM3631, LM3632, LM3633, LM3695 and LM3697. 1340 LM36274. It consists of backlight, LED and regulator driver.
1341 It consists of backlight, LED and regulator driver.
1342 It provides consistent device controls for lighting functions. 1341 It provides consistent device controls for lighting functions.
1343 1342
1344config MFD_OMAP_USB_HOST 1343config MFD_OMAP_USB_HOST
diff --git a/drivers/mfd/ti-lmu.c b/drivers/mfd/ti-lmu.c
index 96b21b5af570..fd6e8c417baa 100644
--- a/drivers/mfd/ti-lmu.c
+++ b/drivers/mfd/ti-lmu.c
@@ -108,17 +108,14 @@ static const struct mfd_cell lm3695_devices[] = {
108 }, 108 },
109}; 109};
110 110
111static const struct mfd_cell lm3697_devices[] = { 111static const struct mfd_cell lm36274_devices[] = {
112 LM363X_REGULATOR(LM36274_BOOST),
113 LM363X_REGULATOR(LM36274_LDO_POS),
114 LM363X_REGULATOR(LM36274_LDO_NEG),
112 { 115 {
113 .name = "ti-lmu-backlight", 116 .name = "lm36274-leds",
114 .id = LM3697, 117 .id = LM36274,
115 .of_compatible = "ti,lm3697-backlight", 118 .of_compatible = "ti,lm36274-backlight",
116 },
117 /* Monitoring driver for open/short circuit detection */
118 {
119 .name = "ti-lmu-fault-monitor",
120 .id = LM3697,
121 .of_compatible = "ti,lm3697-fault-monitor",
122 }, 119 },
123}; 120};
124 121
@@ -134,7 +131,7 @@ TI_LMU_DATA(lm3631, LM3631_MAX_REG);
134TI_LMU_DATA(lm3632, LM3632_MAX_REG); 131TI_LMU_DATA(lm3632, LM3632_MAX_REG);
135TI_LMU_DATA(lm3633, LM3633_MAX_REG); 132TI_LMU_DATA(lm3633, LM3633_MAX_REG);
136TI_LMU_DATA(lm3695, LM3695_MAX_REG); 133TI_LMU_DATA(lm3695, LM3695_MAX_REG);
137TI_LMU_DATA(lm3697, LM3697_MAX_REG); 134TI_LMU_DATA(lm36274, LM36274_MAX_REG);
138 135
139static int ti_lmu_probe(struct i2c_client *cl, const struct i2c_device_id *id) 136static int ti_lmu_probe(struct i2c_client *cl, const struct i2c_device_id *id)
140{ 137{
@@ -203,7 +200,7 @@ static const struct of_device_id ti_lmu_of_match[] = {
203 { .compatible = "ti,lm3632", .data = &lm3632_data }, 200 { .compatible = "ti,lm3632", .data = &lm3632_data },
204 { .compatible = "ti,lm3633", .data = &lm3633_data }, 201 { .compatible = "ti,lm3633", .data = &lm3633_data },
205 { .compatible = "ti,lm3695", .data = &lm3695_data }, 202 { .compatible = "ti,lm3695", .data = &lm3695_data },
206 { .compatible = "ti,lm3697", .data = &lm3697_data }, 203 { .compatible = "ti,lm36274", .data = &lm36274_data },
207 { } 204 { }
208}; 205};
209MODULE_DEVICE_TABLE(of, ti_lmu_of_match); 206MODULE_DEVICE_TABLE(of, ti_lmu_of_match);
@@ -213,7 +210,7 @@ static const struct i2c_device_id ti_lmu_ids[] = {
213 { "lm3632", LM3632 }, 210 { "lm3632", LM3632 },
214 { "lm3633", LM3633 }, 211 { "lm3633", LM3633 },
215 { "lm3695", LM3695 }, 212 { "lm3695", LM3695 },
216 { "lm3697", LM3697 }, 213 { "lm36274", LM36274 },
217 { } 214 { }
218}; 215};
219MODULE_DEVICE_TABLE(i2c, ti_lmu_ids); 216MODULE_DEVICE_TABLE(i2c, ti_lmu_ids);
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 8553bdf87c1d..b5d0e07a62d7 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -364,7 +364,7 @@ config REGULATOR_LM363X
364 tristate "TI LM363X voltage regulators" 364 tristate "TI LM363X voltage regulators"
365 depends on MFD_TI_LMU 365 depends on MFD_TI_LMU
366 help 366 help
367 This driver supports LM3631 and LM3632 voltage regulators for 367 This driver supports LM3631, LM3632 and LM36274 voltage regulators for
368 the LCD bias. 368 the LCD bias.
369 One boost output voltage is configurable and always on. 369 One boost output voltage is configurable and always on.
370 Other LDOs are used for the display module. 370 Other LDOs are used for the display module.
diff --git a/drivers/regulator/lm363x-regulator.c b/drivers/regulator/lm363x-regulator.c
index 60f15a722760..5647e2f97ff8 100644
--- a/drivers/regulator/lm363x-regulator.c
+++ b/drivers/regulator/lm363x-regulator.c
@@ -34,6 +34,11 @@
34#define LM3632_VBOOST_MIN 4500000 34#define LM3632_VBOOST_MIN 4500000
35#define LM3632_VLDO_MIN 4000000 35#define LM3632_VLDO_MIN 4000000
36 36
37/* LM36274 */
38#define LM36274_BOOST_VSEL_MAX 0x3f
39#define LM36274_LDO_VSEL_MAX 0x34
40#define LM36274_VOLTAGE_MIN 4000000
41
37/* Common */ 42/* Common */
38#define LM363X_STEP_50mV 50000 43#define LM363X_STEP_50mV 50000
39#define LM363X_STEP_500mV 500000 44#define LM363X_STEP_500mV 500000
@@ -214,6 +219,51 @@ static const struct regulator_desc lm363x_regulator_desc[] = {
214 .enable_reg = LM3632_REG_BIAS_CONFIG, 219 .enable_reg = LM3632_REG_BIAS_CONFIG,
215 .enable_mask = LM3632_EN_VNEG_MASK, 220 .enable_mask = LM3632_EN_VNEG_MASK,
216 }, 221 },
222
223 /* LM36274 */
224 {
225 .name = "vboost",
226 .of_match = "vboost",
227 .id = LM36274_BOOST,
228 .ops = &lm363x_boost_voltage_table_ops,
229 .n_voltages = LM36274_BOOST_VSEL_MAX,
230 .min_uV = LM36274_VOLTAGE_MIN,
231 .uV_step = LM363X_STEP_50mV,
232 .type = REGULATOR_VOLTAGE,
233 .owner = THIS_MODULE,
234 .vsel_reg = LM36274_REG_VOUT_BOOST,
235 .vsel_mask = LM36274_VOUT_MASK,
236 },
237 {
238 .name = "ldo_vpos",
239 .of_match = "vpos",
240 .id = LM36274_LDO_POS,
241 .ops = &lm363x_regulator_voltage_table_ops,
242 .n_voltages = LM36274_LDO_VSEL_MAX,
243 .min_uV = LM36274_VOLTAGE_MIN,
244 .uV_step = LM363X_STEP_50mV,
245 .type = REGULATOR_VOLTAGE,
246 .owner = THIS_MODULE,
247 .vsel_reg = LM36274_REG_VOUT_POS,
248 .vsel_mask = LM36274_VOUT_MASK,
249 .enable_reg = LM36274_REG_BIAS_CONFIG_1,
250 .enable_mask = LM36274_EN_VPOS_MASK,
251 },
252 {
253 .name = "ldo_vneg",
254 .of_match = "vneg",
255 .id = LM36274_LDO_NEG,
256 .ops = &lm363x_regulator_voltage_table_ops,
257 .n_voltages = LM36274_LDO_VSEL_MAX,
258 .min_uV = LM36274_VOLTAGE_MIN,
259 .uV_step = LM363X_STEP_50mV,
260 .type = REGULATOR_VOLTAGE,
261 .owner = THIS_MODULE,
262 .vsel_reg = LM36274_REG_VOUT_NEG,
263 .vsel_mask = LM36274_VOUT_MASK,
264 .enable_reg = LM36274_REG_BIAS_CONFIG_1,
265 .enable_mask = LM36274_EN_VNEG_MASK,
266 },
217}; 267};
218 268
219static struct gpio_desc *lm363x_regulator_of_get_enable_gpio(struct device *dev, int id) 269static struct gpio_desc *lm363x_regulator_of_get_enable_gpio(struct device *dev, int id)
@@ -226,9 +276,11 @@ static struct gpio_desc *lm363x_regulator_of_get_enable_gpio(struct device *dev,
226 */ 276 */
227 switch (id) { 277 switch (id) {
228 case LM3632_LDO_POS: 278 case LM3632_LDO_POS:
279 case LM36274_LDO_POS:
229 return gpiod_get_index_optional(dev, "enable", 0, 280 return gpiod_get_index_optional(dev, "enable", 0,
230 GPIOD_OUT_LOW | GPIOD_FLAGS_BIT_NONEXCLUSIVE); 281 GPIOD_OUT_LOW | GPIOD_FLAGS_BIT_NONEXCLUSIVE);
231 case LM3632_LDO_NEG: 282 case LM3632_LDO_NEG:
283 case LM36274_LDO_NEG:
232 return gpiod_get_index_optional(dev, "enable", 1, 284 return gpiod_get_index_optional(dev, "enable", 1,
233 GPIOD_OUT_LOW | GPIOD_FLAGS_BIT_NONEXCLUSIVE); 285 GPIOD_OUT_LOW | GPIOD_FLAGS_BIT_NONEXCLUSIVE);
234 default: 286 default:
@@ -236,6 +288,27 @@ static struct gpio_desc *lm363x_regulator_of_get_enable_gpio(struct device *dev,
236 } 288 }
237} 289}
238 290
291static int lm363x_regulator_set_ext_en(struct regmap *regmap, int id)
292{
293 int ext_en_mask = 0;
294
295 switch (id) {
296 case LM3632_LDO_POS:
297 case LM3632_LDO_NEG:
298 ext_en_mask = LM3632_EXT_EN_MASK;
299 break;
300 case LM36274_LDO_POS:
301 case LM36274_LDO_NEG:
302 ext_en_mask = LM36274_EXT_EN_MASK;
303 break;
304 default:
305 return -ENODEV;
306 }
307
308 return regmap_update_bits(regmap, lm363x_regulator_desc[id].enable_reg,
309 ext_en_mask, ext_en_mask);
310}
311
239static int lm363x_regulator_probe(struct platform_device *pdev) 312static int lm363x_regulator_probe(struct platform_device *pdev)
240{ 313{
241 struct ti_lmu *lmu = dev_get_drvdata(pdev->dev.parent); 314 struct ti_lmu *lmu = dev_get_drvdata(pdev->dev.parent);
@@ -260,10 +333,7 @@ static int lm363x_regulator_probe(struct platform_device *pdev)
260 333
261 if (gpiod) { 334 if (gpiod) {
262 cfg.ena_gpiod = gpiod; 335 cfg.ena_gpiod = gpiod;
263 336 ret = lm363x_regulator_set_ext_en(regmap, id);
264 ret = regmap_update_bits(regmap, LM3632_REG_BIAS_CONFIG,
265 LM3632_EXT_EN_MASK,
266 LM3632_EXT_EN_MASK);
267 if (ret) { 337 if (ret) {
268 gpiod_put(gpiod); 338 gpiod_put(gpiod);
269 dev_err(dev, "External pin err: %d\n", ret); 339 dev_err(dev, "External pin err: %d\n", ret);
diff --git a/include/linux/leds-ti-lmu-common.h b/include/linux/leds-ti-lmu-common.h
new file mode 100644
index 000000000000..5eb111f38803
--- /dev/null
+++ b/include/linux/leds-ti-lmu-common.h
@@ -0,0 +1,47 @@
1/* SPDX-License-Identifier: GPL-2.0 */
2// TI LMU Common Core
3// Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/
4
5#ifndef _TI_LMU_COMMON_H_
6#define _TI_LMU_COMMON_H_
7
8#include <linux/delay.h>
9#include <linux/device.h>
10#include <linux/init.h>
11#include <linux/leds.h>
12#include <linux/module.h>
13#include <linux/regmap.h>
14#include <linux/slab.h>
15#include <uapi/linux/uleds.h>
16
17#define LMU_11BIT_LSB_MASK (BIT(0) | BIT(1) | BIT(2))
18#define LMU_11BIT_MSB_SHIFT 3
19
20#define MAX_BRIGHTNESS_8BIT 255
21#define MAX_BRIGHTNESS_11BIT 2047
22
23struct ti_lmu_bank {
24 struct regmap *regmap;
25
26 int max_brightness;
27
28 u8 lsb_brightness_reg;
29 u8 msb_brightness_reg;
30
31 u8 runtime_ramp_reg;
32 u32 ramp_up_usec;
33 u32 ramp_down_usec;
34};
35
36int ti_lmu_common_set_brightness(struct ti_lmu_bank *lmu_bank, int brightness);
37
38int ti_lmu_common_set_ramp(struct ti_lmu_bank *lmu_bank);
39
40int ti_lmu_common_get_ramp_params(struct device *dev,
41 struct fwnode_handle *child,
42 struct ti_lmu_bank *lmu_data);
43
44int ti_lmu_common_get_brt_res(struct device *dev, struct fwnode_handle *child,
45 struct ti_lmu_bank *lmu_data);
46
47#endif /* _TI_LMU_COMMON_H_ */
diff --git a/include/linux/mfd/ti-lmu-register.h b/include/linux/mfd/ti-lmu-register.h
index 222cb14c5b0f..116a749e0302 100644
--- a/include/linux/mfd/ti-lmu-register.h
+++ b/include/linux/mfd/ti-lmu-register.h
@@ -187,47 +187,26 @@
187 187
188#define LM3695_MAX_REG 0x14 188#define LM3695_MAX_REG 0x14
189 189
190/* LM3697 */ 190/* LM36274 */
191#define LM3697_REG_HVLED_OUTPUT_CFG 0x10 191#define LM36274_REG_REV 0x01
192#define LM3697_HVLED1_CFG_MASK BIT(0) 192#define LM36274_REG_BL_CFG_1 0x02
193#define LM3697_HVLED2_CFG_MASK BIT(1) 193#define LM36274_REG_BL_CFG_2 0x03
194#define LM3697_HVLED3_CFG_MASK BIT(2) 194#define LM36274_REG_BRT_LSB 0x04
195#define LM3697_HVLED1_CFG_SHIFT 0 195#define LM36274_REG_BRT_MSB 0x05
196#define LM3697_HVLED2_CFG_SHIFT 1 196#define LM36274_REG_BL_EN 0x08
197#define LM3697_HVLED3_CFG_SHIFT 2 197
198#define LM36274_REG_BIAS_CONFIG_1 0x09
199#define LM36274_EXT_EN_MASK BIT(0)
200#define LM36274_EN_VNEG_MASK BIT(1)
201#define LM36274_EN_VPOS_MASK BIT(2)
202
203#define LM36274_REG_BIAS_CONFIG_2 0x0a
204#define LM36274_REG_BIAS_CONFIG_3 0x0b
205#define LM36274_REG_VOUT_BOOST 0x0c
206#define LM36274_REG_VOUT_POS 0x0d
207#define LM36274_REG_VOUT_NEG 0x0e
208#define LM36274_VOUT_MASK 0x3F
209
210#define LM36274_MAX_REG 0x13
198 211
199#define LM3697_REG_BL0_RAMP 0x11
200#define LM3697_REG_BL1_RAMP 0x12
201#define LM3697_RAMPUP_MASK 0xF0
202#define LM3697_RAMPUP_SHIFT 4
203#define LM3697_RAMPDN_MASK 0x0F
204#define LM3697_RAMPDN_SHIFT 0
205
206#define LM3697_REG_RAMP_CONF 0x14
207#define LM3697_RAMP_MASK 0x0F
208#define LM3697_RAMP_EACH 0x05
209
210#define LM3697_REG_PWM_CFG 0x1C
211#define LM3697_PWM_A_MASK BIT(0)
212#define LM3697_PWM_B_MASK BIT(1)
213
214#define LM3697_REG_IMAX_A 0x17
215#define LM3697_REG_IMAX_B 0x18
216
217#define LM3697_REG_FEEDBACK_ENABLE 0x19
218
219#define LM3697_REG_BRT_A_LSB 0x20
220#define LM3697_REG_BRT_A_MSB 0x21
221#define LM3697_REG_BRT_B_LSB 0x22
222#define LM3697_REG_BRT_B_MSB 0x23
223
224#define LM3697_REG_ENABLE 0x24
225
226#define LM3697_REG_OPEN_FAULT_STATUS 0xB0
227
228#define LM3697_REG_SHORT_FAULT_STATUS 0xB2
229
230#define LM3697_REG_MONITOR_ENABLE 0xB4
231
232#define LM3697_MAX_REG 0xB4
233#endif 212#endif
diff --git a/include/linux/mfd/ti-lmu.h b/include/linux/mfd/ti-lmu.h
index 7d1e9c24f818..0bc0e8199798 100644
--- a/include/linux/mfd/ti-lmu.h
+++ b/include/linux/mfd/ti-lmu.h
@@ -23,7 +23,7 @@ enum ti_lmu_id {
23 LM3632, 23 LM3632,
24 LM3633, 24 LM3633,
25 LM3695, 25 LM3695,
26 LM3697, 26 LM36274,
27 LMU_MAX_ID, 27 LMU_MAX_ID,
28}; 28};
29 29
@@ -65,6 +65,9 @@ enum lm363x_regulator_id {
65 LM3632_BOOST, /* Boost output */ 65 LM3632_BOOST, /* Boost output */
66 LM3632_LDO_POS, /* Positive display bias output */ 66 LM3632_LDO_POS, /* Positive display bias output */
67 LM3632_LDO_NEG, /* Negative display bias output */ 67 LM3632_LDO_NEG, /* Negative display bias output */
68 LM36274_BOOST, /* Boost output */
69 LM36274_LDO_POS, /* Positive display bias output */
70 LM36274_LDO_NEG, /* Negative display bias output */
68}; 71};
69 72
70/** 73/**
diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
index 21025c2c605b..66cc11742355 100644
--- a/net/netfilter/Kconfig
+++ b/net/netfilter/Kconfig
@@ -906,7 +906,7 @@ config NETFILTER_XT_TARGET_LED
906 echo netfilter-ssh > /sys/class/leds/<ledname>/trigger 906 echo netfilter-ssh > /sys/class/leds/<ledname>/trigger
907 907
908 For more information on the LEDs available on your system, see 908 For more information on the LEDs available on your system, see
909 Documentation/leds/leds-class.txt 909 Documentation/leds/leds-class.rst
910 910
911config NETFILTER_XT_TARGET_LOG 911config NETFILTER_XT_TARGET_LOG
912 tristate "LOG target support" 912 tristate "LOG target support"