Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+2346 -864
+85
Documentation/devicetree/bindings/leds/leds-lm36274.txt
··· 1 + * Texas Instruments LM36274 4-Channel LCD Backlight Driver w/Integrated Bias 2 + 3 + The LM36274 is an integrated four-channel WLED driver and LCD bias supply. 4 + The backlight boost provides the power to bias four parallel LED strings with 5 + up to 29V total output voltage. The 11-bit LED current is programmable via 6 + the I2C bus and/or controlled via a logic level PWM input from 60 uA to 30 mA. 7 + 8 + Parent device properties are documented in 9 + Documentation/devicetree/bindings/mfd/ti-lmu.txt 10 + 11 + Regulator properties are documented in 12 + Documentation/devicetree/bindings/regulator/lm363x-regulator.txt 13 + 14 + Required 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 + 24 + Optional backlight properties: 25 + - label : see Documentation/devicetree/bindings/leds/common.txt 26 + - linux,default-trigger : 27 + see Documentation/devicetree/bindings/leds/common.txt 28 + 29 + Example: 30 + 31 + HVLED string 1 and 3 are controlled by control bank A and HVLED 2 string is 32 + controlled by control bank B. 33 + 34 + lm36274@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 + 84 + For more product information please see the link below: 85 + http://www.ti.com/lit/ds/symlink/lm36274.pdf
+73
Documentation/devicetree/bindings/leds/leds-lm3697.txt
··· 1 + * Texas Instruments - LM3697 Highly Efficient White LED Driver 2 + 3 + The LM3697 11-bit LED driver provides high- 4 + performance backlight dimming for 1, 2, or 3 series 5 + LED strings while delivering up to 90% efficiency. 6 + 7 + This device is suitable for display and keypad lighting 8 + 9 + Required properties: 10 + - compatible: 11 + "ti,lm3697" 12 + - reg : I2C slave address 13 + - #address-cells : 1 14 + - #size-cells : 0 15 + 16 + Optional properties: 17 + - enable-gpios : GPIO pin to enable/disable the device 18 + - vled-supply : LED supply 19 + 20 + Required 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 + 29 + Optional 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 + 37 + Example: 38 + 39 + HVLED string 1 and 3 are controlled by control bank A and HVLED 2 string is 40 + controlled by control bank B. 41 + 42 + led-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 + 72 + For more product information please see the link below: 73 + http://www.ti.com/lit/ds/symlink/lm3697.pdf
+44
Documentation/devicetree/bindings/leds/leds-spi-byte.txt
··· 1 + * Single Byte SPI LED Device Driver. 2 + 3 + The 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 + 9 + The value for lowest and highest brightness is dependent on the device and 10 + therefore on the compatible string. 11 + 12 + Depending on the compatible string some special functions (like hardware 13 + accelerated blinking) might can be supported too. 14 + 15 + The driver currently only supports one LED. The properties of the LED are 16 + configured in a sub-node in the device node. 17 + 18 + Required 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 + 23 + Property rules described in Documentation/devicetree/bindings/spi/spi-bus.txt 24 + apply. 25 + 26 + LED 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 + 33 + Example: 34 + 35 + led-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 + };
+67 -21
Documentation/devicetree/bindings/mfd/ti-lmu.txt
··· 8 8 LM3632 Backlight and regulator 9 9 LM3633 Backlight, LED and fault monitor 10 10 LM3695 Backlight 11 - LM3697 Backlight and fault monitor 11 + LM36274 Backlight and regulator 12 12 13 13 Required properties: 14 14 - compatible: Should be one of: ··· 16 16 "ti,lm3632" 17 17 "ti,lm3633" 18 18 "ti,lm3695" 19 - "ti,lm3697" 19 + "ti,lm36274" 20 20 - reg: I2C slave address. 21 21 0x11 for LM3632 22 22 0x29 for LM3631 23 - 0x36 for LM3633, LM3697 23 + 0x36 for LM3633 24 24 0x63 for LM3695 25 + 0x11 for LM36274 25 26 26 - Optional property: 27 + Optional properties: 27 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 29 46 Required node: 30 47 - backlight: All LMU devices have backlight child nodes. ··· 52 35 Required properties: 53 36 - compatible: Should be one of: 54 37 "ti,lm3633-fault-monitor" 55 - "ti,lm3697-fault-monitor" 56 38 - leds: LED properties for LM3633. Please refer to [2]. 39 + LED properties for LM36274. Please refer to [4]. 57 40 - regulators: Regulator properties for LM3631 and LM3632. 58 41 Please refer to [3]. 59 42 60 43 [1] ../leds/backlight/ti-lmu-backlight.txt 61 44 [2] ../leds/leds-lm3633.txt 62 45 [3] ../regulator/lm363x-regulator.txt 46 + [4] ../leds/leds-lm36274.txt 63 47 64 48 lm3631@29 { 65 49 compatible = "ti,lm3631"; ··· 108 90 109 91 lcd_bl { 110 92 led-sources = <0 1>; 111 - ramp-up-msec = <300>; 93 + ramp-up-us = <300000>; 112 94 }; 113 95 }; 114 96 }; ··· 170 152 main { 171 153 label = "main_lcd"; 172 154 led-sources = <1 2>; 173 - ramp-up-msec = <500>; 174 - ramp-down-msec = <500>; 155 + ramp-up-us = <500000>; 156 + ramp-down-us = <500000>; 175 157 }; 176 158 177 159 front { 178 160 label = "front_lcd"; 179 161 led-sources = <0>; 180 - ramp-up-msec = <1000>; 181 - ramp-down-msec = <0>; 162 + ramp-up-us = <1000000>; 163 + ramp-down-us = <0>; 182 164 }; 183 165 }; 184 166 ··· 219 201 }; 220 202 }; 221 203 222 - lm3697@36 { 223 - compatible = "ti,lm3697"; 224 - reg = <0x36>; 204 + lm36274@11 { 205 + compatible = "ti,lm36274"; 206 + #address-cells = <1>; 207 + #size-cells = <0>; 208 + reg = <0x11>; 225 209 226 210 enable-gpios = <&pioC 2 GPIO_ACTIVE_HIGH>; 211 + regulators { 212 + #address-cells = <1>; 213 + #size-cells = <0>; 214 + compatible = "ti,lm363x-regulator"; 227 215 228 - backlight { 229 - compatible = "ti,lm3697-backlight"; 216 + enable-gpios = <&pioC 0 GPIO_ACTIVE_HIGH>, 217 + <&pioC 1 GPIO_ACTIVE_HIGH>; 230 218 231 - lcd { 232 - led-sources = <0 1 2>; 233 - ramp-up-msec = <200>; 234 - ramp-down-msec = <200>; 219 + vboost { 220 + regulator-name = "lcd_boost"; 221 + regulator-min-microvolt = <4000000>; 222 + regulator-max-microvolt = <7150000>; 223 + regulator-always-on; 224 + }; 225 + 226 + vpos { 227 + regulator-name = "lcd_vpos"; 228 + regulator-min-microvolt = <4000000>; 229 + regulator-max-microvolt = <6500000>; 230 + }; 231 + 232 + vneg { 233 + regulator-name = "lcd_vneg"; 234 + regulator-min-microvolt = <4000000>; 235 + regulator-max-microvolt = <6500000>; 235 236 }; 236 237 }; 237 238 238 - fault-monitor { 239 - compatible = "ti,lm3697-fault-monitor"; 239 + backlight { 240 + #address-cells = <1>; 241 + #size-cells = <0>; 242 + compatible = "ti,lm36274-backlight"; 243 + 244 + led@0 { 245 + reg = <0>; 246 + led-sources = <0 2>; 247 + label = "white:backlight_cluster"; 248 + linux,default-trigger = "backlight"; 249 + }; 240 250 }; 241 251 };
+2 -2
Documentation/laptops/thinkpad-acpi.txt
··· 679 679 sysfs notes: 680 680 681 681 The ThinkLight sysfs interface is documented by the LED class 682 - documentation, in Documentation/leds/leds-class.txt. The ThinkLight LED name 682 + documentation, in Documentation/leds/leds-class.rst. The ThinkLight LED name 683 683 is "tpacpi::thinklight". 684 684 685 685 Due to limitations in the sysfs LED class, if the status of the ThinkLight ··· 779 779 sysfs notes: 780 780 781 781 The ThinkPad LED sysfs interface is described in detail by the LED class 782 - documentation, in Documentation/leds/leds-class.txt. 782 + documentation, in Documentation/leds/leds-class.rst. 783 783 784 784 The LEDs are named (in LED ID order, from 0 to 12): 785 785 "tpacpi::power", "tpacpi:orange:batt", "tpacpi:green:batt",
+25
Documentation/leds/index.rst
··· 1 + :orphan: 2 + 3 + ==== 4 + LEDs 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
+34 -30
Documentation/leds/leds-blinkm.txt Documentation/leds/leds-blinkm.rst
··· 1 + ================== 2 + Leds BlinkM driver 3 + ================== 4 + 1 5 The leds-blinkm driver supports the devices of the BlinkM family. 2 6 3 7 They are RGB-LED modules driven by a (AT)tiny microcontroller and ··· 18 14 a) LED class interface for use with triggers 19 15 ############################################ 20 16 21 - The registration follows the scheme: 22 - blinkm-<i2c-bus-nr>-<i2c-device-nr>-<color> 17 + The registration follows the scheme:: 23 18 24 - $ ls -h /sys/class/leds/blinkm-6-* 25 - /sys/class/leds/blinkm-6-9-blue: 26 - brightness device max_brightness power subsystem trigger uevent 19 + blinkm-<i2c-bus-nr>-<i2c-device-nr>-<color> 27 20 28 - /sys/class/leds/blinkm-6-9-green: 29 - brightness device max_brightness power subsystem trigger uevent 21 + $ ls -h /sys/class/leds/blinkm-6-* 22 + /sys/class/leds/blinkm-6-9-blue: 23 + brightness device max_brightness power subsystem trigger uevent 30 24 31 - /sys/class/leds/blinkm-6-9-red: 32 - brightness device max_brightness power subsystem trigger uevent 25 + /sys/class/leds/blinkm-6-9-green: 26 + brightness device max_brightness power subsystem trigger uevent 27 + 28 + /sys/class/leds/blinkm-6-9-red: 29 + brightness device max_brightness power subsystem trigger uevent 33 30 34 31 (same is /sys/bus/i2c/devices/6-0009/leds) 35 32 36 33 We can control the colors separated into red, green and blue and 37 34 assign triggers on each color. 38 35 39 - E.g.: 36 + E.g.:: 40 37 41 - $ cat blinkm-6-9-blue/brightness 42 - 05 38 + $ cat blinkm-6-9-blue/brightness 39 + 05 43 40 44 - $ echo 200 > blinkm-6-9-blue/brightness 45 - $ 41 + $ echo 200 > blinkm-6-9-blue/brightness 42 + $ 46 43 47 - $ modprobe ledtrig-heartbeat 48 - $ echo heartbeat > blinkm-6-9-green/trigger 49 - $ 44 + $ modprobe ledtrig-heartbeat 45 + $ echo heartbeat > blinkm-6-9-green/trigger 46 + $ 50 47 51 48 52 49 b) Sysfs group to control rgb, fade, hsb, scripts ... ··· 57 52 in the sysfs folder of the I2C device. 58 53 E.g. below /sys/bus/i2c/devices/6-0009/blinkm 59 54 60 - $ ls -h /sys/bus/i2c/devices/6-0009/blinkm/ 61 - blue green red test 55 + $ ls -h /sys/bus/i2c/devices/6-0009/blinkm/ 56 + blue green red test 62 57 63 58 Currently supported is just setting red, green, blue 64 59 and a test sequence. 65 60 66 - E.g.: 61 + E.g.:: 67 62 68 - $ cat * 69 - 00 70 - 00 71 - 00 72 - #Write into test to start test sequence!# 63 + $ cat * 64 + 00 65 + 00 66 + 00 67 + #Write into test to start test sequence!# 73 68 74 - $ echo 1 > test 75 - $ 69 + $ echo 1 > test 70 + $ 76 71 77 - $ echo 255 > red 78 - $ 72 + $ echo 255 > red 73 + $ 79 74 80 75 81 76 82 77 as of 6/2012 83 78 84 79 dl9pf <at> gmx <dot> de 85 -
+33 -16
Documentation/leds/leds-class-flash.txt Documentation/leds/leds-class-flash.rst
··· 1 - 1 + ============================== 2 2 Flash LED handling under Linux 3 3 ============================== 4 4 5 5 Some LED devices provide two modes - torch and flash. In the LED subsystem 6 - those modes are supported by LED class (see Documentation/leds/leds-class.txt) 6 + those modes are supported by LED class (see Documentation/leds/leds-class.rst) 7 7 and LED Flash class respectively. The torch mode related features are enabled 8 8 by default and the flash ones only if a driver declares it by setting 9 9 LED_DEV_CAP_FLASH flag. ··· 14 14 15 15 Following sysfs attributes are exposed for controlling flash LED devices: 16 16 (see Documentation/ABI/testing/sysfs-class-led-flash) 17 + 17 18 - flash_brightness 18 19 - max_flash_brightness 19 20 - flash_timeout ··· 32 31 33 32 The driver must call the v4l2_flash_init function to get registered in the 34 33 V4L2 subsystem. The function takes six arguments: 35 - - dev : flash device, e.g. an I2C device 36 - - of_node : of_node of the LED, may be NULL if the same as device's 37 - - fled_cdev : LED flash class device to wrap 38 - - iled_cdev : LED flash class device representing indicator LED associated with 39 - fled_cdev, may be NULL 40 - - ops : V4L2 specific ops 41 - * external_strobe_set - defines the source of the flash LED strobe - 34 + 35 + - dev: 36 + flash device, e.g. an I2C device 37 + - of_node: 38 + of_node of the LED, may be NULL if the same as device's 39 + - fled_cdev: 40 + LED flash class device to wrap 41 + - iled_cdev: 42 + LED flash class device representing indicator LED associated with 43 + fled_cdev, may be NULL 44 + - ops: 45 + V4L2 specific ops 46 + 47 + * external_strobe_set 48 + defines the source of the flash LED strobe - 42 49 V4L2_CID_FLASH_STROBE control or external source, typically 43 50 a sensor, which makes it possible to synchronise the flash 44 51 strobe start with exposure start, 45 - * intensity_to_led_brightness and led_brightness_to_intensity - perform 52 + * intensity_to_led_brightness and led_brightness_to_intensity 53 + perform 46 54 enum led_brightness <-> V4L2 intensity conversion in a device 47 55 specific manner - they can be used for devices with non-linear 48 56 LED current scale. 49 - - config : configuration for V4L2 Flash sub-device 50 - * dev_name - the name of the media entity, unique in the system, 51 - * flash_faults - bitmask of flash faults that the LED flash class 57 + - config: 58 + configuration for V4L2 Flash sub-device 59 + 60 + * dev_name 61 + the name of the media entity, unique in the system, 62 + * flash_faults 63 + bitmask of flash faults that the LED flash class 52 64 device can report; corresponding LED_FAULT* bit definitions are 53 65 available in <linux/led-class-flash.h>, 54 - * torch_intensity - constraints for the LED in TORCH mode 66 + * torch_intensity 67 + constraints for the LED in TORCH mode 55 68 in microamperes, 56 - * indicator_intensity - constraints for the indicator LED 69 + * indicator_intensity 70 + constraints for the indicator LED 57 71 in microamperes, 58 - * has_external_strobe - determines whether the flash strobe source 72 + * has_external_strobe 73 + determines whether the flash strobe source 59 74 can be switched to external, 60 75 61 76 On remove the v4l2_flash_release function has to be called, which takes one
+9 -6
Documentation/leds/leds-class.txt Documentation/leds/leds-class.rst
··· 1 - 1 + ======================== 2 2 LED handling under Linux 3 3 ======================== 4 4 ··· 43 43 44 44 Is currently of the form: 45 45 46 - "devicename:colour:function" 46 + "devicename:colour:function" 47 47 48 48 There have been calls for LED properties such as colour to be exported as 49 49 individual led class attributes. As a solution which doesn't incur as much ··· 57 57 58 58 LED 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 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 66 it can block the caller for the time required for accessing 64 67 device registers and can sleep, passing LED_OFF stops hardware 65 68 blinking, returns -EBUSY if software blink fallback is enabled. ··· 73 70 74 71 A driver wanting to register a LED classdev for use by other drivers / 75 72 userspace needs to allocate and fill a led_classdev struct and then call 76 - [devm_]led_classdev_register. If the non devm version is used the driver 73 + `[devm_]led_classdev_register`. If the non devm version is used the driver 77 74 must call led_classdev_unregister from its remove function before 78 75 free-ing the led_classdev struct. 79 76 ··· 97 94 timers that may have been required for blinking. 98 95 99 96 The blink_set() function should choose a user friendly blinking value 100 - if it is called with *delay_on==0 && *delay_off==0 parameters. In this 97 + if it is called with `*delay_on==0` && `*delay_off==0` parameters. In this 101 98 case the driver should give back the chosen value through delay_on and 102 99 delay_off parameters to the leds subsystem. 103 100
+76 -24
Documentation/leds/leds-lm3556.txt Documentation/leds/leds-lm3556.rst
··· 1 + ======================== 1 2 Kernel driver for lm3556 2 3 ======================== 3 4 4 - *Texas Instrument: 5 - 1.5 A Synchronous Boost LED Flash Driver w/ High-Side Current Source 5 + * Texas Instrument: 6 + 1.5 A Synchronous Boost LED Flash Driver w/ High-Side Current Source 6 7 * Datasheet: http://www.national.com/ds/LM/LM3556.pdf 7 8 8 9 Authors: 9 - Daniel Jeong 10 + - Daniel Jeong 11 + 10 12 Contact:Daniel Jeong(daniel.jeong-at-ti.com, gshark.jeong-at-gmail.com) 11 13 12 14 Description 13 15 ----------- 14 16 There are 3 functions in LM3556, Flash, Torch and Indicator. 15 17 16 - FLASH MODE 18 + Flash Mode 19 + ^^^^^^^^^^ 20 + 17 21 In Flash Mode, the LED current source(LED) provides 16 target current levels 18 22 from 93.75 mA to 1500 mA.The Flash currents are adjusted via the CURRENT 19 23 CONTROL REGISTER(0x09).Flash mode is activated by the ENABLE REGISTER(0x0A), 20 24 or by pulling the STROBE pin HIGH. 25 + 21 26 LM3556 Flash can be controlled through sys/class/leds/flash/brightness file 27 + 22 28 * if STROBE pin is enabled, below example control brightness only, and 23 - ON / OFF will be controlled by STROBE pin. 29 + ON / OFF will be controlled by STROBE pin. 24 30 25 31 Flash Example: 26 - OFF : #echo 0 > sys/class/leds/flash/brightness 27 - 93.75 mA: #echo 1 > sys/class/leds/flash/brightness 28 - ... ..... 29 - 1500 mA: #echo 16 > sys/class/leds/flash/brightness 30 32 31 - TORCH MODE 33 + OFF:: 34 + 35 + #echo 0 > sys/class/leds/flash/brightness 36 + 37 + 93.75 mA:: 38 + 39 + #echo 1 > sys/class/leds/flash/brightness 40 + 41 + ... 42 + 43 + 1500 mA:: 44 + 45 + #echo 16 > sys/class/leds/flash/brightness 46 + 47 + Torch Mode 48 + ^^^^^^^^^^ 49 + 32 50 In Torch Mode, the current source(LED) is programmed via the CURRENT CONTROL 33 51 REGISTER(0x09).Torch Mode is activated by the ENABLE REGISTER(0x0A) or by the 34 52 hardware TORCH input. 53 + 35 54 LM3556 torch can be controlled through sys/class/leds/torch/brightness file. 36 55 * if TORCH pin is enabled, below example control brightness only, 37 56 and ON / OFF will be controlled by TORCH pin. 38 57 39 58 Torch Example: 40 - OFF : #echo 0 > sys/class/leds/torch/brightness 41 - 46.88 mA: #echo 1 > sys/class/leds/torch/brightness 42 - ... ..... 43 - 375 mA : #echo 8 > sys/class/leds/torch/brightness 44 59 45 - INDICATOR MODE 60 + OFF:: 61 + 62 + #echo 0 > sys/class/leds/torch/brightness 63 + 64 + 46.88 mA:: 65 + 66 + #echo 1 > sys/class/leds/torch/brightness 67 + 68 + ... 69 + 70 + 375 mA:: 71 + 72 + #echo 8 > sys/class/leds/torch/brightness 73 + 74 + Indicator Mode 75 + ^^^^^^^^^^^^^^ 76 + 46 77 Indicator pattern can be set through sys/class/leds/indicator/pattern file, 47 78 and 4 patterns are pre-defined in indicator_pattern array. 79 + 48 80 According to N-lank, Pulse time and N Period values, different pattern wiill 49 81 be generated.If you want new patterns for your own device, change 50 82 indicator_pattern array with your own values and INDIC_PATTERN_SIZE. 83 + 51 84 Please refer datasheet for more detail about N-Blank, Pulse time and N Period. 52 85 53 86 Indicator pattern example: 54 - pattern 0: #echo 0 > sys/class/leds/indicator/pattern 55 - .... 56 - pattern 3: #echo 3 > sys/class/leds/indicator/pattern 87 + 88 + pattern 0:: 89 + 90 + #echo 0 > sys/class/leds/indicator/pattern 91 + 92 + ... 93 + 94 + pattern 3:: 95 + 96 + #echo 3 > sys/class/leds/indicator/pattern 57 97 58 98 Indicator brightness can be controlled through 59 99 sys/class/leds/indicator/brightness file. 60 100 61 101 Example: 62 - OFF : #echo 0 > sys/class/leds/indicator/brightness 63 - 5.86 mA : #echo 1 > sys/class/leds/indicator/brightness 64 - ........ 65 - 46.875mA : #echo 8 > sys/class/leds/indicator/brightness 102 + 103 + OFF:: 104 + 105 + #echo 0 > sys/class/leds/indicator/brightness 106 + 107 + 5.86 mA:: 108 + 109 + #echo 1 > sys/class/leds/indicator/brightness 110 + 111 + ... 112 + 113 + 46.875mA:: 114 + 115 + #echo 8 > sys/class/leds/indicator/brightness 66 116 67 117 Notes 68 118 ----- ··· 120 70 To register the chip at address 0x63 on specific adapter, set the platform data 121 71 according to include/linux/platform_data/leds-lm3556.h, set the i2c board info 122 72 123 - Example: 73 + Example:: 74 + 124 75 static struct i2c_board_info board_i2c_ch4[] __initdata = { 125 76 { 126 77 I2C_BOARD_INFO(LM3556_NAME, 0x63), ··· 131 80 132 81 and register it in the platform init function 133 82 134 - Example: 83 + Example:: 84 + 135 85 board_register_i2c_bus(4, 400, 136 86 board_i2c_ch4, ARRAY_SIZE(board_i2c_ch4));
+16 -7
Documentation/leds/leds-lp3944.txt Documentation/leds/leds-lp3944.rst
··· 1 + ==================== 1 2 Kernel driver lp3944 2 3 ==================== 3 4 4 5 * National Semiconductor LP3944 Fun-light Chip 6 + 5 7 Prefix: 'lp3944' 8 + 6 9 Addresses scanned: None (see the Notes section below) 7 - Datasheet: Publicly available at the National Semiconductor website 8 - http://www.national.com/pf/LP/LP3944.html 10 + 11 + Datasheet: 12 + 13 + Publicly available at the National Semiconductor website 14 + http://www.national.com/pf/LP/LP3944.html 9 15 10 16 Authors: 11 - Antonio Ospite <ospite@studenti.unina.it> 17 + Antonio Ospite <ospite@studenti.unina.it> 12 18 13 19 14 20 Description ··· 25 19 26 20 The DIM modes are used to set _blink_ patterns for leds, the pattern is 27 21 specified supplying two parameters: 28 - - period: from 0s to 1.6s 29 - - duty cycle: percentage of the period the led is on, from 0 to 100 22 + 23 + - period: 24 + from 0s to 1.6s 25 + - duty cycle: 26 + percentage of the period the led is on, from 0 to 100 30 27 31 28 Setting a led in DIM0 or DIM1 mode makes it blink according to the pattern. 32 29 See the datasheet for details. ··· 44 35 registered using the i2c_board_info mechanism. 45 36 46 37 To register the chip at address 0x60 on adapter 0, set the platform data 47 - according to include/linux/leds-lp3944.h, set the i2c board info: 38 + according to include/linux/leds-lp3944.h, set the i2c board info:: 48 39 49 40 static struct i2c_board_info a910_i2c_board_info[] __initdata = { 50 41 { ··· 53 44 }, 54 45 }; 55 46 56 - and register it in the platform init function 47 + and register it in the platform init function:: 57 48 58 49 i2c_register_board_info(0, a910_i2c_board_info, 59 50 ARRAY_SIZE(a910_i2c_board_info));
+115
Documentation/leds/leds-lp5521.rst
··· 1 + ======================== 2 + Kernel driver for lp5521 3 + ======================== 4 + 5 + * National Semiconductor LP5521 led driver chip 6 + * Datasheet: http://www.national.com/pf/LP/LP5521.html 7 + 8 + Authors: Mathias Nyman, Yuri Zaporozhets, Samu Onkalo 9 + 10 + Contact: Samu Onkalo (samu.p.onkalo-at-nokia.com) 11 + 12 + Description 13 + ----------- 14 + 15 + LP5521 can drive up to 3 channels. Leds can be controlled directly via 16 + the led class control interface. Channels have generic names: 17 + lp5521:channelx, where x is 0 .. 2 18 + 19 + All three channels can be also controlled using the engine micro programs. 20 + More details of the instructions can be found from the public data sheet. 21 + 22 + LP5521 has the internal program memory for running various LED patterns. 23 + There are two ways to run LED patterns. 24 + 25 + 1) 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 + 46 + 2) Firmware interface - LP55xx common interface 47 + 48 + For the details, please refer to 'firmware' section in leds-lp55xx.txt 49 + 50 + sysfs contains a selftest entry. 51 + 52 + The test communicates with the chip and checks that 53 + the clock mode is automatically set to the requested one. 54 + 55 + Each 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 + 60 + Format: 10x mA i.e 10 means 1.0 mA 61 + 62 + example 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 + 107 + Note: 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 + 114 + If the current is set to 0 in the platform data, that channel is 115 + disabled and it is not visible in the sysfs.
-101
Documentation/leds/leds-lp5521.txt
··· 1 - Kernel driver for lp5521 2 - ======================== 3 - 4 - * National Semiconductor LP5521 led driver chip 5 - * Datasheet: http://www.national.com/pf/LP/LP5521.html 6 - 7 - Authors: Mathias Nyman, Yuri Zaporozhets, Samu Onkalo 8 - Contact: Samu Onkalo (samu.p.onkalo-at-nokia.com) 9 - 10 - Description 11 - ----------- 12 - 13 - LP5521 can drive up to 3 channels. Leds can be controlled directly via 14 - the led class control interface. Channels have generic names: 15 - lp5521:channelx, where x is 0 .. 2 16 - 17 - All three channels can be also controlled using the engine micro programs. 18 - More details of the instructions can be found from the public data sheet. 19 - 20 - LP5521 has the internal program memory for running various LED patterns. 21 - There are two ways to run LED patterns. 22 - 23 - 1) 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 - 38 - 2) Firmware interface - LP55xx common interface 39 - For the details, please refer to 'firmware' section in leds-lp55xx.txt 40 - 41 - sysfs contains a selftest entry. 42 - The test communicates with the chip and checks that 43 - the clock mode is automatically set to the requested one. 44 - 45 - Each 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 48 - Format: 10x mA i.e 10 means 1.0 mA 49 - 50 - example platform data: 51 - 52 - Note: chan_nr can have values between 0 and 2. 53 - The name of each channel can be configurable. 54 - If 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 - 57 - static 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 - 76 - static int lp5521_setup(void) 77 - { 78 - /* setup HW resources */ 79 - } 80 - 81 - static void lp5521_release(void) 82 - { 83 - /* Release HW resources */ 84 - } 85 - 86 - static void lp5521_enable(bool state) 87 - { 88 - /* Control of chip enable signal */ 89 - } 90 - 91 - static 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 - 100 - If the current is set to 0 in the platform data, that channel is 101 - disabled and it is not visible in the sysfs.
+147
Documentation/leds/leds-lp5523.rst
··· 1 + ======================== 2 + Kernel driver for lp5523 3 + ======================== 4 + 5 + * National Semiconductor LP5523 led driver chip 6 + * Datasheet: http://www.national.com/pf/LP/LP5523.html 7 + 8 + Authors: Mathias Nyman, Yuri Zaporozhets, Samu Onkalo 9 + Contact: Samu Onkalo (samu.p.onkalo-at-nokia.com) 10 + 11 + Description 12 + ----------- 13 + LP5523 can drive up to 9 channels. Leds can be controlled directly via 14 + the led class control interface. 15 + The name of each channel is configurable in the platform data - name and label. 16 + There are three options to make the channel name. 17 + 18 + a) Define the 'name' in the platform data 19 + 20 + To 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 + 25 + b) Use the 'label' with no 'name' field 26 + 27 + For one device name with channel number, then use 'label'. 28 + - /sys/class/leds/RGB:channelN (label: 'RGB', N: 0 ~ 8) 29 + 30 + c) Default 31 + 32 + If both fields are NULL, 'lp5523' is used by default. 33 + - /sys/class/leds/lp5523:channelN (N: 0 ~ 8) 34 + 35 + LP5523 has the internal program memory for running various LED patterns. 36 + There are two ways to run LED patterns. 37 + 38 + 1) 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 + 63 + 2) Firmware interface - LP55xx common interface 64 + 65 + For the details, please refer to 'firmware' section in leds-lp55xx.txt 66 + 67 + LP5523 has three master faders. If a channel is mapped to one of 68 + the master faders, its output is dimmed based on the value of the master 69 + fader. 70 + 71 + For example:: 72 + 73 + echo "123000123" > master_fader_leds 74 + 75 + creates 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 + 81 + Then, to have 25% of the original output on channel 0,6:: 82 + 83 + echo 64 > master_fader1 84 + 85 + To have 0% of the original output (i.e. no output) channel 1,7:: 86 + 87 + echo 0 > master_fader2 88 + 89 + To have 100% of the original output (i.e. no dimming) on channel 2,8:: 90 + 91 + echo 255 > master_fader3 92 + 93 + To clear all master fader controls:: 94 + 95 + echo "000000000" > master_fader_leds 96 + 97 + Selftest uses always the current from the platform data. 98 + 99 + Each channel contains led current settings. 100 + - /sys/class/leds/lp5523:channel2/led_current - RW 101 + - /sys/class/leds/lp5523:channel2/max_current - RO 102 + 103 + Format: 10x mA i.e 10 means 1.0 mA 104 + 105 + Example 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 + 146 + Note 147 + chan_nr can have values between 0 and 8.
-130
Documentation/leds/leds-lp5523.txt
··· 1 - Kernel driver for lp5523 2 - ======================== 3 - 4 - * National Semiconductor LP5523 led driver chip 5 - * Datasheet: http://www.national.com/pf/LP/LP5523.html 6 - 7 - Authors: Mathias Nyman, Yuri Zaporozhets, Samu Onkalo 8 - Contact: Samu Onkalo (samu.p.onkalo-at-nokia.com) 9 - 10 - Description 11 - ----------- 12 - LP5523 can drive up to 9 channels. Leds can be controlled directly via 13 - the led class control interface. 14 - The name of each channel is configurable in the platform data - name and label. 15 - There are three options to make the channel name. 16 - 17 - a) Define the 'name' in the platform data 18 - To make specific channel name, then use 'name' platform data. 19 - /sys/class/leds/R1 (name: 'R1') 20 - /sys/class/leds/B1 (name: 'B1') 21 - 22 - b) Use the 'label' with no 'name' field 23 - For one device name with channel number, then use 'label'. 24 - /sys/class/leds/RGB:channelN (label: 'RGB', N: 0 ~ 8) 25 - 26 - c) Default 27 - If both fields are NULL, 'lp5523' is used by default. 28 - /sys/class/leds/lp5523:channelN (N: 0 ~ 8) 29 - 30 - LP5523 has the internal program memory for running various LED patterns. 31 - There are two ways to run LED patterns. 32 - 33 - 1) 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 - 49 - 2) Firmware interface - LP55xx common interface 50 - For the details, please refer to 'firmware' section in leds-lp55xx.txt 51 - 52 - LP5523 has three master faders. If a channel is mapped to one of 53 - the master faders, its output is dimmed based on the value of the master 54 - fader. 55 - 56 - For example, 57 - 58 - echo "123000123" > master_fader_leds 59 - 60 - creates 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 - 66 - Then, to have 25% of the original output on channel 0,6: 67 - 68 - echo 64 > master_fader1 69 - 70 - To have 0% of the original output (i.e. no output) channel 1,7: 71 - 72 - echo 0 > master_fader2 73 - 74 - To have 100% of the original output (i.e. no dimming) on channel 2,8: 75 - 76 - echo 255 > master_fader3 77 - 78 - To clear all master fader controls: 79 - 80 - echo "000000000" > master_fader_leds 81 - 82 - Selftest uses always the current from the platform data. 83 - 84 - Each channel contains led current settings. 85 - /sys/class/leds/lp5523:channel2/led_current - RW 86 - /sys/class/leds/lp5523:channel2/max_current - RO 87 - Format: 10x mA i.e 10 means 1.0 mA 88 - 89 - Example platform data: 90 - 91 - Note - chan_nr can have values between 0 and 8. 92 - 93 - static 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 - 108 - static int lp5523_setup(void) 109 - { 110 - /* Setup HW resources */ 111 - } 112 - 113 - static void lp5523_release(void) 114 - { 115 - /* Release HW resources */ 116 - } 117 - 118 - static void lp5523_enable(bool state) 119 - { 120 - /* Control chip enable signal */ 121 - } 122 - 123 - static 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 - };
+137
Documentation/leds/leds-lp5562.rst
··· 1 + ======================== 2 + Kernel driver for lp5562 3 + ======================== 4 + 5 + * TI LP5562 LED Driver 6 + 7 + Author: Milo(Woogyom) Kim <milo.kim@ti.com> 8 + 9 + Description 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 + 19 + Device attribute 20 + ================ 21 + 22 + engine_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 + 41 + How 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 + 67 + How to load the predefined patterns 68 + =================================== 69 + 70 + Please refer to 'leds-lp55xx.txt" 71 + 72 + Setting 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 + 78 + Example 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 + 133 + To configure the platform specific data, lp55xx_platform_data structure is used 134 + 135 + 136 + If the current is set to 0 in the platform data, that channel is 137 + disabled and it is not visible in the sysfs.
-120
Documentation/leds/leds-lp5562.txt
··· 1 - Kernel driver for LP5562 2 - ======================== 3 - 4 - * TI LP5562 LED Driver 5 - 6 - Author: Milo(Woogyom) Kim <milo.kim@ti.com> 7 - 8 - Description 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 - 17 - Device 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 - 33 - How 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 - 56 - How to load the predefined patterns 57 - 58 - Please refer to 'leds-lp55xx.txt" 59 - 60 - Setting 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 - 67 - To configure the platform specific data, lp55xx_platform_data structure is used. 68 - 69 - static 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 - 96 - static int lp5562_setup(void) 97 - { 98 - /* setup HW resources */ 99 - } 100 - 101 - static void lp5562_release(void) 102 - { 103 - /* Release HW resources */ 104 - } 105 - 106 - static void lp5562_enable(bool state) 107 - { 108 - /* Control of chip enable signal */ 109 - } 110 - 111 - static 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 - 119 - If the current is set to 0 in the platform data, that channel is 120 - disabled and it is not visible in the sysfs.
+224
Documentation/leds/leds-lp55xx.rst
··· 1 + ================================================= 2 + LP5521/LP5523/LP55231/LP5562/LP8501 Common Driver 3 + ================================================= 4 + 5 + Authors: Milo(Woogyom) Kim <milo.kim@ti.com> 6 + 7 + Description 8 + ----------- 9 + LP5521, 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 + 17 + The 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 + 25 + In 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 + 32 + For example, LP5521 has maximum 3 LED channels. 33 + LP5523/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 + 47 + To 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 + 60 + LP55xx family devices have the internal program memory for running 61 + various LED patterns. 62 + 63 + This pattern data is saved as a file in the user-land or 64 + hex byte string is written into the memory through the I2C. 65 + 66 + LP55xx common driver supports the firmware interface. 67 + 68 + LP55xx chips have three program engines. 69 + 70 + To 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 + 77 + The LP55xx common driver provides simple interfaces as below. 78 + 79 + select_engine: 80 + Select which engine is used for running program 81 + run_engine: 82 + Start program which is loaded via the firmware interface 83 + firmware: 84 + Load program data 85 + 86 + In case of LP5523, one more command is required, 'enginex_leds'. 87 + It is used for selecting LED output(s) at each engine number. 88 + In more details, please refer to 'leds-lp5523.txt'. 89 + 90 + For 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 + 98 + For example, run blinking pattern in engine #3 of LP55231 99 + 100 + Two 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 + 109 + To 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 + 121 + Here is another example for LP5523. 122 + 123 + Full 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 + 132 + As soon as 'loading' is set to 0, registered callback is called. 133 + Inside the callback, the selected engine is loaded and memory is updated. 134 + To run programmed pattern, 'run_engine' attribute should be enabled. 135 + 136 + The pattern sequence of LP8501 is similar to LP5523. 137 + 138 + However pattern data is specific. 139 + 140 + Ex 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 + 148 + Ex 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 + 166 + The sequence of running the program data is common. 167 + 168 + But each device has own specific register addresses for commands. 169 + 170 + To support this, 'run_engine' and 'firmware_cb' are configurable in each driver. 171 + 172 + run_engine: 173 + Control the selected engine 174 + firmware_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 + 181 + Without the firmware interface, LP55xx driver provides another method for 182 + loading a LED pattern. That is 'predefined' pattern. 183 + 184 + A predefined pattern is defined in the platform data and load it(or them) 185 + via the sysfs if needed. 186 + 187 + To use the predefined pattern concept, 'patterns' and 'num_patterns' should be 188 + configured. 189 + 190 + Example 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 + 217 + Then, 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 + 222 + To stop running pattern:: 223 + 224 + echo 0 > /sys/bus/i2c/devices/xxxx/led_pattern
-194
Documentation/leds/leds-lp55xx.txt
··· 1 - LP5521/LP5523/LP55231/LP5562/LP8501 Common Driver 2 - ================================================= 3 - 4 - Authors: Milo(Woogyom) Kim <milo.kim@ti.com> 5 - 6 - Description 7 - ----------- 8 - LP5521, 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 - 16 - The 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 - 23 - In lp55xx common driver, two different data structure is used. 24 - 25 - o lp55xx_led 26 - control multi output LED channels such as led current, channel index. 27 - o lp55xx_chip 28 - general chip control such like the I2C and platform data. 29 - 30 - For example, LP5521 has maximum 3 LED channels. 31 - LP5523/55231 has 9 output channels. 32 - 33 - lp55xx_chip for LP5521 ... lp55xx_led #1 34 - lp55xx_led #2 35 - lp55xx_led #3 36 - 37 - lp55xx_chip for LP5523 ... lp55xx_led #1 38 - lp55xx_led #2 39 - . 40 - . 41 - lp55xx_led #9 42 - 43 - ( Chip Dependent Code ) 44 - 45 - To 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 - 58 - LP55xx family devices have the internal program memory for running 59 - various LED patterns. 60 - This pattern data is saved as a file in the user-land or 61 - hex byte string is written into the memory through the I2C. 62 - LP55xx common driver supports the firmware interface. 63 - 64 - LP55xx chips have three program engines. 65 - To 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 - 71 - The LP55xx common driver provides simple interfaces as below. 72 - select_engine : Select which engine is used for running program 73 - run_engine : Start program which is loaded via the firmware interface 74 - firmware : Load program data 75 - 76 - In case of LP5523, one more command is required, 'enginex_leds'. 77 - It is used for selecting LED output(s) at each engine number. 78 - In more details, please refer to 'leds-lp5523.txt'. 79 - 80 - For example, run blinking pattern in engine #1 of LP5521 81 - echo 1 > /sys/bus/i2c/devices/xxxx/select_engine 82 - echo 1 > /sys/class/firmware/lp5521/loading 83 - echo "4000600040FF6000" > /sys/class/firmware/lp5521/data 84 - echo 0 > /sys/class/firmware/lp5521/loading 85 - echo 1 > /sys/bus/i2c/devices/xxxx/run_engine 86 - 87 - For example, run blinking pattern in engine #3 of LP55231 88 - Two LEDs are configured as pattern output channels. 89 - echo 3 > /sys/bus/i2c/devices/xxxx/select_engine 90 - echo 1 > /sys/class/firmware/lp55231/loading 91 - echo "9d0740ff7e0040007e00a0010000" > /sys/class/firmware/lp55231/data 92 - echo 0 > /sys/class/firmware/lp55231/loading 93 - echo "000001100" > /sys/bus/i2c/devices/xxxx/engine3_leds 94 - echo 1 > /sys/bus/i2c/devices/xxxx/run_engine 95 - 96 - To start blinking patterns in engine #2 and #3 simultaneously, 97 - for idx in 2 3 98 - do 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 104 - done 105 - echo 1 > /sys/class/leds/red/device/run_engine 106 - 107 - Here is another example for LP5523. 108 - Full LED strings are selected by 'engine2_leds'. 109 - echo 2 > /sys/bus/i2c/devices/xxxx/select_engine 110 - echo 1 > /sys/class/firmware/lp5523/loading 111 - echo "9d80400004ff05ff437f0000" > /sys/class/firmware/lp5523/data 112 - echo 0 > /sys/class/firmware/lp5523/loading 113 - echo "111111111" > /sys/bus/i2c/devices/xxxx/engine2_leds 114 - echo 1 > /sys/bus/i2c/devices/xxxx/run_engine 115 - 116 - As soon as 'loading' is set to 0, registered callback is called. 117 - Inside the callback, the selected engine is loaded and memory is updated. 118 - To run programmed pattern, 'run_engine' attribute should be enabled. 119 - 120 - The pattern sequence of LP8501 is similar to LP5523. 121 - However pattern data is specific. 122 - Ex 1) Engine 1 is used 123 - echo 1 > /sys/bus/i2c/devices/xxxx/select_engine 124 - echo 1 > /sys/class/firmware/lp8501/loading 125 - echo "9d0140ff7e0040007e00a001c000" > /sys/class/firmware/lp8501/data 126 - echo 0 > /sys/class/firmware/lp8501/loading 127 - echo 1 > /sys/bus/i2c/devices/xxxx/run_engine 128 - 129 - Ex 2) Engine 2 and 3 are used at the same time 130 - echo 2 > /sys/bus/i2c/devices/xxxx/select_engine 131 - sleep 1 132 - echo 1 > /sys/class/firmware/lp8501/loading 133 - echo "9d0140ff7e0040007e00a001c000" > /sys/class/firmware/lp8501/data 134 - echo 0 > /sys/class/firmware/lp8501/loading 135 - sleep 1 136 - echo 3 > /sys/bus/i2c/devices/xxxx/select_engine 137 - sleep 1 138 - echo 1 > /sys/class/firmware/lp8501/loading 139 - echo "9d0340ff7e0040007e00a001c000" > /sys/class/firmware/lp8501/data 140 - echo 0 > /sys/class/firmware/lp8501/loading 141 - sleep 1 142 - echo 1 > /sys/class/leds/d1/device/run_engine 143 - 144 - ( 'run_engine' and 'firmware_cb' ) 145 - The sequence of running the program data is common. 146 - But each device has own specific register addresses for commands. 147 - To support this, 'run_engine' and 'firmware_cb' are configurable in each driver. 148 - run_engine : Control the selected engine 149 - firmware_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 - 154 - Without the firmware interface, LP55xx driver provides another method for 155 - loading a LED pattern. That is 'predefined' pattern. 156 - A predefined pattern is defined in the platform data and load it(or them) 157 - via the sysfs if needed. 158 - To use the predefined pattern concept, 'patterns' and 'num_patterns' should be 159 - configured. 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 - 188 - Then, 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 - 193 - To stop running pattern, 194 - echo 0 > /sys/bus/i2c/devices/xxxx/led_pattern
+118
Documentation/leds/leds-mlxcpld.rst
··· 1 + ======================================= 2 + Kernel driver for Mellanox systems LEDs 3 + ======================================= 4 + 5 + Provide system LED support for the nex Mellanox systems: 6 + "msx6710", "msx6720", "msb7700", "msn2700", "msx1410", 7 + "msn2410", "msb7800", "msn2740", "msn2100". 8 + 9 + Description 10 + ----------- 11 + Driver 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 + 64 + Driver 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 + 117 + Driver supports HW blinking at 3Hz and 6Hz frequency (50% duty cycle). 118 + For 3Hz duty cylce is about 167 msec, for 6Hz is about 83 msec.
-110
Documentation/leds/leds-mlxcpld.txt
··· 1 - Kernel driver for Mellanox systems LEDs 2 - ======================================= 3 - 4 - Provide system LED support for the nex Mellanox systems: 5 - "msx6710", "msx6720", "msb7700", "msn2700", "msx1410", 6 - "msn2410", "msb7800", "msn2740", "msn2100". 7 - 8 - Description 9 - ----------- 10 - Driver 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 - 60 - Driver 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 - 109 - Driver supports HW blinking at 3Hz and 6Hz frequency (50% duty cycle). 110 - For 3Hz duty cylce is about 167 msec, for 6Hz is about 83 msec.
+6 -5
Documentation/leds/ledtrig-oneshot.txt Documentation/leds/ledtrig-oneshot.rst
··· 1 + ==================== 1 2 One-shot LED Trigger 2 3 ==================== 3 4 ··· 18 17 on (inverted) when not rearmed. 19 18 20 19 The trigger can be activated from user space on led class devices as shown 21 - below: 20 + below:: 22 21 23 22 echo oneshot > trigger 24 23 25 24 This adds sysfs attributes to the LED that are documented in: 26 25 Documentation/ABI/testing/sysfs-class-led-trigger-oneshot 27 26 28 - Example use-case: network devices, initialization: 27 + Example use-case: network devices, initialization:: 29 28 30 29 echo oneshot > trigger # set trigger for this led 31 30 echo 33 > delay_on # blink at 1 / (33 + 33) Hz on continuous traffic 32 31 echo 33 > delay_off 33 32 34 - interface goes up: 33 + interface goes up:: 35 34 36 35 echo 1 > invert # set led as normally-on, turn the led on 37 36 38 - packet received/transmitted: 37 + packet received/transmitted:: 39 38 40 39 echo 1 > shot # led starts blinking, ignored if already blinking 41 40 42 - interface goes down 41 + interface goes down:: 43 42 44 43 echo 0 > invert # set led as normally-off, turn the led off
+39 -24
Documentation/leds/ledtrig-transient.txt Documentation/leds/ledtrig-transient.rst
··· 1 + ===================== 1 2 LED Transient Trigger 2 3 ===================== 3 4 ··· 63 62 state, the LED state changes to LED_OFF. 64 63 65 64 Transient trigger can be enabled and disabled from user space on led class 66 - devices, that support this trigger as shown below: 65 + devices, that support this trigger as shown below:: 67 66 68 - echo transient > trigger 69 - echo none > trigger 67 + echo transient > trigger 68 + echo none > trigger 70 69 71 - NOTE: Add a new property trigger state to control the state. 70 + NOTE: 71 + Add a new property trigger state to control the state. 72 72 73 73 This trigger exports three properties, activate, state, and duration. When 74 74 transient trigger is activated these properties are set to default values. ··· 81 79 - state allows user to specify a transient state to be held for the specified 82 80 duration. 83 81 84 - activate - one shot timer activate mechanism. 82 + activate 83 + - one shot timer activate mechanism. 85 84 1 when activated, 0 when deactivated. 86 85 default value is zero when transient trigger is enabled, 87 86 to allow duration to be set. ··· 92 89 deactivated state indicates that there is no active timer 93 90 running. 94 91 95 - duration - one shot timer value. When activate is set, duration value 92 + duration 93 + - one shot timer value. When activate is set, duration value 96 94 is used to start a timer that runs once. This value doesn't 97 95 get changed by the trigger unless user does a set via 98 96 echo new_value > duration 99 97 100 - state - transient state to be held. It has two values 0 or 1. 0 maps 98 + state 99 + - transient state to be held. It has two values 0 or 1. 0 maps 101 100 to LED_OFF and 1 maps to LED_FULL. The specified state is 102 101 held for the duration of the one shot timer and then the 103 102 state gets changed to the non-transient state which is the ··· 119 114 at the set value to be used when activate is set at a future time. This will 120 115 allow user app to set the time once and activate it to run it once for the 121 116 specified value as needed. When timer expires, state is restored to the 122 - non-transient state which is the inverse of the transient state. 117 + non-transient state which is the inverse of the transient state: 123 118 124 - echo 1 > activate - starts timer = duration when duration is not 0. 125 - echo 0 > activate - cancels currently running timer. 126 - echo n > duration - stores timer value to be used upon next 127 - activate. Currently active timer if 128 - any, continues to run for the specified time. 129 - echo 0 > duration - stores timer value to be used upon next 130 - activate. Currently active timer if any, 131 - continues to run for the specified time. 132 - echo 1 > state - stores desired transient state LED_FULL to be 119 + ================= =============================================== 120 + echo 1 > activate starts timer = duration when duration is not 0. 121 + echo 0 > activate cancels currently running timer. 122 + echo n > duration stores timer value to be used upon next 123 + activate. Currently active timer if 124 + any, continues to run for the specified time. 125 + echo 0 > duration stores timer value to be used upon next 126 + activate. Currently active timer if any, 127 + continues to run for the specified time. 128 + echo 1 > state stores desired transient state LED_FULL to be 133 129 held for the specified duration. 134 - echo 0 > state - stores desired transient state LED_OFF to be 130 + echo 0 > state stores desired transient state LED_OFF to be 135 131 held for the specified duration. 132 + ================= =============================================== 136 133 137 - What is not supported: 138 - ====================== 134 + What is not supported 135 + ===================== 136 + 139 137 - Timer activation is one shot and extending and/or shortening the timer 140 138 is not supported. 141 139 142 - Example use-case 1: 140 + Examples 141 + ======== 142 + 143 + use-case 1:: 144 + 143 145 echo transient > trigger 144 146 echo n > duration 145 147 echo 1 > state 146 - repeat the following step as needed: 148 + 149 + repeat the following step as needed:: 150 + 147 151 echo 1 > activate - start timer = duration to run once 148 152 echo 1 > activate - start timer = duration to run once 149 153 echo none > trigger 150 154 151 155 This trigger is intended to be used for for the following example use cases: 156 + 152 157 - Control of vibrate (phones, tablets etc.) hardware by user space app. 153 158 - Use of LED by user space app as activity indicator. 154 159 - Use of LED by user space app as a kind of watchdog indicator -- as 155 - long as the app is alive, it can keep the LED illuminated, if it dies 156 - the LED will be extinguished automatically. 160 + long as the app is alive, it can keep the LED illuminated, if it dies 161 + the LED will be extinguished automatically. 157 162 - Use by any user space app that needs a transient GPIO output.
+8 -3
Documentation/leds/ledtrig-usbport.txt Documentation/leds/ledtrig-usbport.rst
··· 1 + ==================== 1 2 USB port LED trigger 2 3 ==================== 3 4 ··· 11 10 echoing "1" to a chosen port. 12 11 13 12 Please note that this trigger allows selecting multiple USB ports for a single 14 - LED. This can be useful in two cases: 13 + LED. 14 + 15 + This can be useful in two cases: 15 16 16 17 1) Device with single USB LED and few physical ports 18 + ==================================================== 17 19 18 20 In such a case LED will be turned on as long as there is at least one connected 19 21 USB device. 20 22 21 23 2) Device with a physical port handled by few controllers 24 + ========================================================= 22 25 23 26 Some devices may have one controller per PHY standard. E.g. USB 3.0 physical 24 27 port may be handled by ohci-platform, ehci-platform and xhci-hcd. If there is ··· 30 25 31 26 32 27 This trigger can be activated from user space on led class devices as shown 33 - below: 28 + below:: 34 29 35 30 echo usbport > trigger 36 31 37 32 This adds sysfs attributes to the LED that are documented in: 38 33 Documentation/ABI/testing/sysfs-class-led-trigger-usbport 39 34 40 - Example use-case: 35 + Example use-case:: 41 36 42 37 echo usbport > trigger 43 38 echo 1 > ports/usb1-port1
+3 -2
Documentation/leds/uleds.txt Documentation/leds/uleds.rst
··· 1 + ============== 1 2 Userspace LEDs 2 3 ============== 3 4 ··· 11 10 12 11 When the driver is loaded, a character device is created at /dev/uleds. To 13 12 create a new LED class device, open /dev/uleds and write a uleds_user_dev 14 - structure to it (found in kernel public header file linux/uleds.h). 13 + structure to it (found in kernel public header file linux/uleds.h):: 15 14 16 15 #define LED_MAX_NAME_SIZE 64 17 16 18 17 struct uleds_user_dev { 19 - char name[LED_MAX_NAME_SIZE]; 18 + char name[LED_MAX_NAME_SIZE]; 20 19 }; 21 20 22 21 A new LED class device will be created with the name given. The name can be
+1 -1
MAINTAINERS
··· 10165 10165 S: Supported 10166 10166 F: drivers/leds/leds-mlxcpld.c 10167 10167 F: drivers/leds/leds-mlxreg.c 10168 - F: Documentation/leds/leds-mlxcpld.txt 10168 + F: Documentation/leds/leds-mlxcpld.rst 10169 10169 10170 10170 MELLANOX PLATFORM DRIVER 10171 10171 M: Vadim Pasternak <vadimp@mellanox.com>
+35
drivers/leds/Kconfig
··· 784 784 To compile this driver as a module, choose M here: the module 785 785 will be called leds-nic78bx. 786 786 787 + config 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 + 797 + config 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 + 806 + config 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 + 814 + config 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 + 787 822 comment "LED Triggers" 788 823 source "drivers/leds/trigger/Kconfig" 789 824
+4
drivers/leds/Makefile
··· 77 77 obj-$(CONFIG_LEDS_MLXCPLD) += leds-mlxcpld.o 78 78 obj-$(CONFIG_LEDS_MLXREG) += leds-mlxreg.o 79 79 obj-$(CONFIG_LEDS_NIC78BX) += leds-nic78bx.o 80 + obj-$(CONFIG_LEDS_SPI_BYTE) += leds-spi-byte.o 80 81 obj-$(CONFIG_LEDS_MT6323) += leds-mt6323.o 81 82 obj-$(CONFIG_LEDS_LM3692X) += leds-lm3692x.o 82 83 obj-$(CONFIG_LEDS_SC27XX_BLTC) += leds-sc27xx-bltc.o 83 84 obj-$(CONFIG_LEDS_LM3601X) += leds-lm3601x.o 85 + obj-$(CONFIG_LEDS_TI_LMU_COMMON) += leds-ti-lmu-common.o 86 + obj-$(CONFIG_LEDS_LM3697) += leds-lm3697.o 87 + obj-$(CONFIG_LEDS_LM36274) += leds-lm36274.o 84 88 85 89 # LED SPI Drivers 86 90 obj-$(CONFIG_LEDS_CR0014114) += leds-cr0014114.o
+172
drivers/leds/leds-lm36274.c
··· 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 + */ 32 + struct 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 + 43 + static 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 + 51 + static 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 + 70 + static 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 + 124 + static 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 + 156 + static const struct of_device_id of_lm36274_leds_match[] = { 157 + { .compatible = "ti,lm36274-backlight", }, 158 + {}, 159 + }; 160 + MODULE_DEVICE_TABLE(of, of_lm36274_leds_match); 161 + 162 + static struct platform_driver lm36274_driver = { 163 + .probe = lm36274_probe, 164 + .driver = { 165 + .name = "lm36274-leds", 166 + }, 167 + }; 168 + module_platform_driver(lm36274_driver) 169 + 170 + MODULE_DESCRIPTION("Texas Instruments LM36274 LED driver"); 171 + MODULE_AUTHOR("Dan Murphy <dmurphy@ti.com>"); 172 + MODULE_LICENSE("GPL v2");
+395
drivers/leds/leds-lm3697.c
··· 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 + */ 51 + struct 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 + */ 72 + struct 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 + 85 + static 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 + 102 + static 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 + 112 + static 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 + 153 + brightness_out: 154 + mutex_unlock(&led->priv->lock); 155 + return ret; 156 + } 157 + 158 + static 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 + } 189 + out: 190 + return ret; 191 + } 192 + 193 + static 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 + 301 + child_out: 302 + return ret; 303 + } 304 + 305 + static 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 + 343 + static 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 + 370 + static const struct i2c_device_id lm3697_id[] = { 371 + { "lm3697", 0 }, 372 + { } 373 + }; 374 + MODULE_DEVICE_TABLE(i2c, lm3697_id); 375 + 376 + static const struct of_device_id of_lm3697_leds_match[] = { 377 + { .compatible = "ti,lm3697", }, 378 + {}, 379 + }; 380 + MODULE_DEVICE_TABLE(of, of_lm3697_leds_match); 381 + 382 + static 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 + }; 391 + module_i2c_driver(lm3697_driver); 392 + 393 + MODULE_DESCRIPTION("Texas Instruments LM3697 LED driver"); 394 + MODULE_AUTHOR("Dan Murphy <dmurphy@ti.com>"); 395 + MODULE_LICENSE("GPL v2");
-2
drivers/leds/leds-max77650.c
··· 64 64 { 65 65 struct device_node *of_node, *child; 66 66 struct max77650_led *leds, *led; 67 - struct device *parent; 68 67 struct device *dev; 69 68 struct regmap *map; 70 69 const char *label; ··· 71 72 u32 reg; 72 73 73 74 dev = &pdev->dev; 74 - parent = dev->parent; 75 75 of_node = dev->of_node; 76 76 77 77 if (!of_node)
+1 -1
drivers/leds/leds-pca955x.c
··· 429 429 int ngpios = 0; 430 430 431 431 chip = &pca955x_chipdefs[id->driver_data]; 432 - adapter = to_i2c_adapter(client->dev.parent); 432 + adapter = client->adapter; 433 433 pdata = dev_get_platdata(&client->dev); 434 434 if (!pdata) { 435 435 pdata = pca955x_get_pdata(client, chip);
+161
drivers/leds/leds-spi-byte.c
··· 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 + 38 + struct 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 + 45 + struct 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 + 53 + static const struct spi_byte_chipdef ubnt_acb_spi_led_cdef = { 54 + .off_value = 0x0, 55 + .max_value = 0x3F, 56 + }; 57 + 58 + static const struct of_device_id spi_byte_dt_ids[] = { 59 + { .compatible = "ubnt,acb-spi-led", .data = &ubnt_acb_spi_led_cdef }, 60 + {}, 61 + }; 62 + 63 + MODULE_DEVICE_TABLE(of, spi_byte_dt_ids); 64 + 65 + static 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 + 81 + static 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 + 138 + static 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 + 147 + static 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 + 156 + module_spi_driver(spi_byte_driver); 157 + 158 + MODULE_AUTHOR("Christian Mauderer <oss@c-mauderer.de>"); 159 + MODULE_DESCRIPTION("single byte SPI LED driver"); 160 + MODULE_LICENSE("GPL v2"); 161 + MODULE_ALIAS("spi:leds-spi-byte");
+1 -1
drivers/leds/leds-tca6507.c
··· 758 758 int err; 759 759 int i = 0; 760 760 761 - adapter = to_i2c_adapter(client->dev.parent); 761 + adapter = client->adapter; 762 762 pdata = dev_get_platdata(&client->dev); 763 763 764 764 if (!i2c_check_functionality(adapter, I2C_FUNC_I2C))
+156
drivers/leds/leds-ti-lmu-common.c
··· 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 + 14 + const 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 + 19 + static 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 + 51 + int 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 + } 55 + EXPORT_SYMBOL(ti_lmu_common_set_brightness); 56 + 57 + static 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 + 84 + int 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 + } 105 + EXPORT_SYMBOL(ti_lmu_common_set_ramp); 106 + 107 + int 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 + } 126 + EXPORT_SYMBOL(ti_lmu_common_get_ramp_params); 127 + 128 + int 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 + } 150 + EXPORT_SYMBOL(ti_lmu_common_get_brt_res); 151 + 152 + MODULE_DESCRIPTION("TI LMU common LED framework"); 153 + MODULE_AUTHOR("Sebastian Reichel"); 154 + MODULE_AUTHOR("Dan Murphy <dmurphy@ti.com>"); 155 + MODULE_LICENSE("GPL v2"); 156 + MODULE_ALIAS("ti-lmu-led-common");
+1 -1
drivers/leds/trigger/Kconfig
··· 15 15 This allows LEDs to be controlled by a programmable timer 16 16 via sysfs. Some LED hardware can be programmed to start 17 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 20 If unsure, say Y. 21 21
+1 -1
drivers/leds/trigger/ledtrig-transient.c
··· 3 3 // LED Kernel Transient Trigger 4 4 // 5 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 7 // Copyright (C) 2012 Shuah Khan <shuahkhan@gmail.com> 8 8 // 9 9 // Based on Richard Purdie's ledtrig-timer.c and Atsushi Nemoto's
+2 -3
drivers/mfd/Kconfig
··· 1336 1336 select REGMAP_I2C 1337 1337 help 1338 1338 Say yes here to enable support for TI LMU chips. 1339 - 1340 - TI LMU MFD supports LM3532, LM3631, LM3632, LM3633, LM3695 and LM3697. 1341 - It consists of backlight, LED and regulator driver. 1339 + TI LMU MFD supports LM3532, LM3631, LM3632, LM3633, LM3695 and 1340 + LM36274. It consists of backlight, LED and regulator driver. 1342 1341 It provides consistent device controls for lighting functions. 1343 1342 1344 1343 config MFD_OMAP_USB_HOST
+10 -13
drivers/mfd/ti-lmu.c
··· 108 108 }, 109 109 }; 110 110 111 - static const struct mfd_cell lm3697_devices[] = { 111 + static 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", 114 - .id = LM3697, 115 - .of_compatible = "ti,lm3697-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", 116 + .name = "lm36274-leds", 117 + .id = LM36274, 118 + .of_compatible = "ti,lm36274-backlight", 122 119 }, 123 120 }; 124 121 ··· 131 134 TI_LMU_DATA(lm3632, LM3632_MAX_REG); 132 135 TI_LMU_DATA(lm3633, LM3633_MAX_REG); 133 136 TI_LMU_DATA(lm3695, LM3695_MAX_REG); 134 - TI_LMU_DATA(lm3697, LM3697_MAX_REG); 137 + TI_LMU_DATA(lm36274, LM36274_MAX_REG); 135 138 136 139 static int ti_lmu_probe(struct i2c_client *cl, const struct i2c_device_id *id) 137 140 { ··· 200 203 { .compatible = "ti,lm3632", .data = &lm3632_data }, 201 204 { .compatible = "ti,lm3633", .data = &lm3633_data }, 202 205 { .compatible = "ti,lm3695", .data = &lm3695_data }, 203 - { .compatible = "ti,lm3697", .data = &lm3697_data }, 206 + { .compatible = "ti,lm36274", .data = &lm36274_data }, 204 207 { } 205 208 }; 206 209 MODULE_DEVICE_TABLE(of, ti_lmu_of_match); ··· 210 213 { "lm3632", LM3632 }, 211 214 { "lm3633", LM3633 }, 212 215 { "lm3695", LM3695 }, 213 - { "lm3697", LM3697 }, 216 + { "lm36274", LM36274 }, 214 217 { } 215 218 }; 216 219 MODULE_DEVICE_TABLE(i2c, ti_lmu_ids);
+1 -1
drivers/regulator/Kconfig
··· 364 364 tristate "TI LM363X voltage regulators" 365 365 depends on MFD_TI_LMU 366 366 help 367 - This driver supports LM3631 and LM3632 voltage regulators for 367 + This driver supports LM3631, LM3632 and LM36274 voltage regulators for 368 368 the LCD bias. 369 369 One boost output voltage is configurable and always on. 370 370 Other LDOs are used for the display module.
+74 -4
drivers/regulator/lm363x-regulator.c
··· 34 34 #define LM3632_VBOOST_MIN 4500000 35 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 42 /* Common */ 38 43 #define LM363X_STEP_50mV 50000 39 44 #define LM363X_STEP_500mV 500000 ··· 219 214 .enable_reg = LM3632_REG_BIAS_CONFIG, 220 215 .enable_mask = LM3632_EN_VNEG_MASK, 221 216 }, 217 + 218 + /* LM36274 */ 219 + { 220 + .name = "vboost", 221 + .of_match = "vboost", 222 + .id = LM36274_BOOST, 223 + .ops = &lm363x_boost_voltage_table_ops, 224 + .n_voltages = LM36274_BOOST_VSEL_MAX, 225 + .min_uV = LM36274_VOLTAGE_MIN, 226 + .uV_step = LM363X_STEP_50mV, 227 + .type = REGULATOR_VOLTAGE, 228 + .owner = THIS_MODULE, 229 + .vsel_reg = LM36274_REG_VOUT_BOOST, 230 + .vsel_mask = LM36274_VOUT_MASK, 231 + }, 232 + { 233 + .name = "ldo_vpos", 234 + .of_match = "vpos", 235 + .id = LM36274_LDO_POS, 236 + .ops = &lm363x_regulator_voltage_table_ops, 237 + .n_voltages = LM36274_LDO_VSEL_MAX, 238 + .min_uV = LM36274_VOLTAGE_MIN, 239 + .uV_step = LM363X_STEP_50mV, 240 + .type = REGULATOR_VOLTAGE, 241 + .owner = THIS_MODULE, 242 + .vsel_reg = LM36274_REG_VOUT_POS, 243 + .vsel_mask = LM36274_VOUT_MASK, 244 + .enable_reg = LM36274_REG_BIAS_CONFIG_1, 245 + .enable_mask = LM36274_EN_VPOS_MASK, 246 + }, 247 + { 248 + .name = "ldo_vneg", 249 + .of_match = "vneg", 250 + .id = LM36274_LDO_NEG, 251 + .ops = &lm363x_regulator_voltage_table_ops, 252 + .n_voltages = LM36274_LDO_VSEL_MAX, 253 + .min_uV = LM36274_VOLTAGE_MIN, 254 + .uV_step = LM363X_STEP_50mV, 255 + .type = REGULATOR_VOLTAGE, 256 + .owner = THIS_MODULE, 257 + .vsel_reg = LM36274_REG_VOUT_NEG, 258 + .vsel_mask = LM36274_VOUT_MASK, 259 + .enable_reg = LM36274_REG_BIAS_CONFIG_1, 260 + .enable_mask = LM36274_EN_VNEG_MASK, 261 + }, 222 262 }; 223 263 224 264 static struct gpio_desc *lm363x_regulator_of_get_enable_gpio(struct device *dev, int id) ··· 276 226 */ 277 227 switch (id) { 278 228 case LM3632_LDO_POS: 229 + case LM36274_LDO_POS: 279 230 return gpiod_get_index_optional(dev, "enable", 0, 280 231 GPIOD_OUT_LOW | GPIOD_FLAGS_BIT_NONEXCLUSIVE); 281 232 case LM3632_LDO_NEG: 233 + case LM36274_LDO_NEG: 282 234 return gpiod_get_index_optional(dev, "enable", 1, 283 235 GPIOD_OUT_LOW | GPIOD_FLAGS_BIT_NONEXCLUSIVE); 284 236 default: 285 237 return NULL; 286 238 } 239 + } 240 + 241 + static int lm363x_regulator_set_ext_en(struct regmap *regmap, int id) 242 + { 243 + int ext_en_mask = 0; 244 + 245 + switch (id) { 246 + case LM3632_LDO_POS: 247 + case LM3632_LDO_NEG: 248 + ext_en_mask = LM3632_EXT_EN_MASK; 249 + break; 250 + case LM36274_LDO_POS: 251 + case LM36274_LDO_NEG: 252 + ext_en_mask = LM36274_EXT_EN_MASK; 253 + break; 254 + default: 255 + return -ENODEV; 256 + } 257 + 258 + return regmap_update_bits(regmap, lm363x_regulator_desc[id].enable_reg, 259 + ext_en_mask, ext_en_mask); 287 260 } 288 261 289 262 static int lm363x_regulator_probe(struct platform_device *pdev) ··· 333 260 334 261 if (gpiod) { 335 262 cfg.ena_gpiod = gpiod; 336 - 337 - ret = regmap_update_bits(regmap, LM3632_REG_BIAS_CONFIG, 338 - LM3632_EXT_EN_MASK, 339 - LM3632_EXT_EN_MASK); 263 + ret = lm363x_regulator_set_ext_en(regmap, id); 340 264 if (ret) { 341 265 gpiod_put(gpiod); 342 266 dev_err(dev, "External pin err: %d\n", ret);
+47
include/linux/leds-ti-lmu-common.h
··· 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 + 23 + struct 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 + 36 + int ti_lmu_common_set_brightness(struct ti_lmu_bank *lmu_bank, int brightness); 37 + 38 + int ti_lmu_common_set_ramp(struct ti_lmu_bank *lmu_bank); 39 + 40 + int ti_lmu_common_get_ramp_params(struct device *dev, 41 + struct fwnode_handle *child, 42 + struct ti_lmu_bank *lmu_data); 43 + 44 + int 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_ */
+18 -39
include/linux/mfd/ti-lmu-register.h
··· 187 187 188 188 #define LM3695_MAX_REG 0x14 189 189 190 - /* LM3697 */ 191 - #define LM3697_REG_HVLED_OUTPUT_CFG 0x10 192 - #define LM3697_HVLED1_CFG_MASK BIT(0) 193 - #define LM3697_HVLED2_CFG_MASK BIT(1) 194 - #define LM3697_HVLED3_CFG_MASK BIT(2) 195 - #define LM3697_HVLED1_CFG_SHIFT 0 196 - #define LM3697_HVLED2_CFG_SHIFT 1 197 - #define LM3697_HVLED3_CFG_SHIFT 2 190 + /* LM36274 */ 191 + #define LM36274_REG_REV 0x01 192 + #define LM36274_REG_BL_CFG_1 0x02 193 + #define LM36274_REG_BL_CFG_2 0x03 194 + #define LM36274_REG_BRT_LSB 0x04 195 + #define LM36274_REG_BRT_MSB 0x05 196 + #define LM36274_REG_BL_EN 0x08 198 197 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 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) 205 202 206 - #define LM3697_REG_RAMP_CONF 0x14 207 - #define LM3697_RAMP_MASK 0x0F 208 - #define LM3697_RAMP_EACH 0x05 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 209 210 - #define LM3697_REG_PWM_CFG 0x1C 211 - #define LM3697_PWM_A_MASK BIT(0) 212 - #define LM3697_PWM_B_MASK BIT(1) 210 + #define LM36274_MAX_REG 0x13 213 211 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 212 #endif
+4 -1
include/linux/mfd/ti-lmu.h
··· 23 23 LM3632, 24 24 LM3633, 25 25 LM3695, 26 - LM3697, 26 + LM36274, 27 27 LMU_MAX_ID, 28 28 }; 29 29 ··· 65 65 LM3632_BOOST, /* Boost output */ 66 66 LM3632_LDO_POS, /* Positive display bias output */ 67 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 /**
+1 -1
net/netfilter/Kconfig
··· 906 906 echo netfilter-ssh > /sys/class/leds/<ledname>/trigger 907 907 908 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 911 911 config NETFILTER_XT_TARGET_LOG 912 912 tristate "LOG target support"