Skip to content

Commit

Permalink
Merge tag 'leds-for-5.2-rc1' of git://git.kernel.org/pub/scm/linux/ke…
Browse files Browse the repository at this point in the history
…rnel/git/j.anaszewski/linux-leds

Pull LED updates from Jacek Anaszewski:
 "LED core fixes and improvements:

      - avoid races with workqueue
      - Kconfig: pedantic cleanup
      - small fixes for Flash class description

  leds-lt3593:

      - remove unneeded assignment in lt3593_led_probe
      - drop pdata handling code

  leds-blinkm:

      - clean up double assignment to data->i2c_addr

  leds-pca955x, leds-pca963x:

      - revert ACPI support, as it turned out that there is no evidence
          of officially registered ACPI IDs for these devices.
      - make use of device property API

  leds-as3645a:

      - switch to fwnode property API

  LED related addition to ACPI documentation:

      - document how to refer to LEDs from remote nodes

  LED related fix to ALSA line6/toneport driver:

      - avoid polluting led_* namespace

  And lm3532 driver relocation from MFD to LED subsystem, accompanied by
  various improvements and optimizations; it entails also a change in
  omap4-droid4-xt894.dts:

      - leds: lm3532: Introduce the lm3532 LED driver
      - mfd: ti-lmu: Remove LM3532 backlight driver references
      - ARM: dts: omap4-droid4: Update backlight dt properties
      - dt: lm3532: Add lm3532 dt doc and update ti_lmu doc"

* tag 'leds-for-5.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/j.anaszewski/linux-leds:
  leds: avoid races with workqueue
  ALSA: line6: Avoid polluting led_* namespace
  leds: lm3532: Introduce the lm3532 LED driver
  mfd: ti-lmu: Remove LM3532 backlight driver references
  ARM: dts: omap4-droid4: Update backlight dt properties
  dt: lm3532: Add lm3532 dt doc and update ti_lmu doc
  leds: Small fixes for Flash class description
  leds: blinkm: clean up double assignment to data->i2c_addr
  leds: pca963x: Make use of device property API
  leds: pca955x: Make use of device property API
  leds: lt3593: Remove unneeded assignment in lt3593_led_probe
  leds: lt3593: drop pdata handling code
  leds: pca955x: Revert "Add ACPI support"
  leds: pca963x: Revert "Add ACPI support"
  drivers: leds: Kconfig: pedantic cleanups
  ACPI: Document how to refer to LEDs from remote nodes
  leds: as3645a: Switch to fwnode property API
  • Loading branch information
torvalds committed May 8, 2019
2 parents f678d6d + 0db3791 commit 8b35ad6
Show file tree
Hide file tree
Showing 18 changed files with 1,023 additions and 292 deletions.
99 changes: 99 additions & 0 deletions Documentation/acpi/dsd/leds.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
Describing and referring to LEDs in ACPI

Individual LEDs are described by hierarchical data extension [6] nodes under the
device node, the LED driver chip. The "reg" property in the LED specific nodes
tells the numerical ID of each individual LED output to which the LEDs are
connected. [3] The hierarchical data nodes are named "led@X", where X is the
number of the LED output.

Referring to LEDs in Device tree is documented in [4], in "flash-leds" property
documentation. In short, LEDs are directly referred to by using phandles.

While Device tree allows referring to any node in the tree[1], in ACPI
references are limited to device nodes only [2]. For this reason using the same
mechanism on ACPI is not possible. A mechanism to refer to non-device ACPI nodes
is documented in [7].

ACPI allows (as does DT) using integer arguments after the reference. A
combination of the LED driver device reference and an integer argument,
referring to the "reg" property of the relevant LED, is used to identify
individual LEDs. The value of the "reg" property is a contract between the
firmware and software, it uniquely identifies the LED driver outputs.

Under the LED driver device, The first hierarchical data extension package list
entry shall contain the string "led@" followed by the number of the LED,
followed by the referred object name. That object shall be named "LED" followed
by the number of the LED.

An ASL example of a camera sensor device and a LED driver device for two LEDs.
Objects not relevant for LEDs or the references to them have been omitted.

Device (LED)
{
Name (_DSD, Package () {
ToUUID("dbb8e3e6-5886-4ba6-8795-1319f52a966b"),
Package () {
Package () { "led@0", LED0 },
Package () { "led@1", LED1 },
}
})
Name (LED0, Package () {
ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
Package () {
Package () { "reg", 0 },
Package () { "flash-max-microamp", 1000000 },
Package () { "flash-timeout-us", 200000 },
Package () { "led-max-microamp", 100000 },
Package () { "label", "white:flash" },
}
})
Name (LED1, Package () {
ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
Package () {
Package () { "reg", 1 },
Package () { "led-max-microamp", 10000 },
Package () { "label", "red:indicator" },
}
})
}

Device (SEN)
{
Name (_DSD, Package () {
ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
Package () {
Package () {
"flash-leds",
Package () { ^LED, "led@0", ^LED, "led@1" },
}
}
})
}

where

LED LED driver device
LED0 First LED
LED1 Second LED
SEN Camera sensor device (or another device the LED is
related to)

[1] Device tree. <URL:http://www.devicetree.org>, referenced 2019-02-21.

[2] Advanced Configuration and Power Interface Specification.
<URL:https://uefi.org/sites/default/files/resources/ACPI_6_3_final_Jan30.pdf>,
referenced 2019-02-21.

[3] Documentation/devicetree/bindings/leds/common.txt

[4] Documentation/devicetree/bindings/media/video-interfaces.txt

[5] Device Properties UUID For _DSD.
<URL:http://www.uefi.org/sites/default/files/resources/_DSD-device-properties-UUID.pdf>,
referenced 2019-02-21.

[6] Hierarchical Data Extension UUID For _DSD.
<URL:http://www.uefi.org/sites/default/files/resources/_DSD-hierarchical-data-extension-UUID-v1.1.pdf>,
referenced 2019-02-21.

[7] Documentation/acpi/dsd/data-node-reference.txt
101 changes: 101 additions & 0 deletions Documentation/devicetree/bindings/leds/leds-lm3532.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
* Texas Instruments - lm3532 White LED driver with ambient light sensing
capability.

The LM3532 provides the 3 high-voltage, low-side current sinks. The device is
programmable over an I2C-compatible interface and has independent
current control for all three channels. The adaptive current regulation
method allows for different LED currents in each current sink thus allowing
for a wide variety of backlight and keypad applications.

The main features of the LM3532 include dual ambient light sensor inputs
each with 32 internal voltage setting resistors, 8-bit logarithmic and linear
brightness control, dual external PWM brightness control inputs, and up to
1000:1 dimming ratio with programmable fade in and fade out settings.

Required properties:
- compatible : "ti,lm3532"
- reg : I2C slave address
- #address-cells : 1
- #size-cells : 0

Optional properties:
- enable-gpios : gpio pin to enable (active high)/disable the device.
- ramp-up-us - The Run time ramp rates/step are from one current
set-point to another after the device has reached its
initial target set point from turn-on
- ramp-down-us - The Run time ramp rates/step are from one current
set-point to another after the device has reached its
initial target set point from turn-on
Range for ramp settings: 8us - 65536us

Optional properties if ALS mode is used:
- ti,als-vmin - Minimum ALS voltage defined in Volts
- ti,als-vmax - Maximum ALS voltage defined in Volts
Per the data sheet the max ALS voltage is 2V and the min is 0V

- ti,als1-imp-sel - ALS1 impedance resistor selection in Ohms
- ti,als2-imp-sel - ALS2 impedance resistor selection in Ohms
Range for impedance select: 37000 Ohms - 1190 Ohms
Values above 37kohms will be set to the "High Impedance" setting

- ti,als-avrg-time-us - Determines the length of time the device needs to
average the two ALS inputs. This is only used if
the input mode is LM3532_ALS_INPUT_AVRG.
Range: 17920us - 2293760us
- ti,als-input-mode - Determines how the device uses the attached ALS
devices.
0x00 - ALS1 and ALS2 input average
0x01 - ALS1 Input
0x02 - ALS2 Input
0x03 - Max of ALS1 and ALS2

Required child properties:
- reg : Indicates control bank the LED string is controlled by
- led-sources : see Documentation/devicetree/bindings/leds/common.txt
- ti,led-mode : Defines if the LED strings are manually controlled or
if the LED strings are controlled by the ALS.
0x00 - LED strings are I2C controlled via full scale
brightness control register
0x01 - LED strings are ALS controlled

Optional LED child properties:
- label : see Documentation/devicetree/bindings/leds/common.txt
- linux,default-trigger :
see Documentation/devicetree/bindings/leds/common.txt

Example:
led-controller@38 {
compatible = "ti,lm3532";
#address-cells = <1>;
#size-cells = <0>;
reg = <0x38>;

enable-gpios = <&gpio6 12 GPIO_ACTIVE_HIGH>;
ramp-up-us = <1024>;
ramp-down-us = <65536>;

ti,als-vmin = <0>;
ti,als-vmax = <2000>;
ti,als1-imp-sel = <4110>;
ti,als2-imp-sel = <2180>;
ti,als-avrg-time-us = <17920>;
ti,als-input-mode = <0x00>;

led@0 {
reg = <0>;
led-sources = <2>;
ti,led-mode = <1>;
label = ":backlight";
linux,default-trigger = "backlight";
};

led@1 {
reg = <1>;
led-sources = <1>;
ti,led-mode = <0>;
label = ":kbd_backlight";
};
};

For more product information please see the links below:
http://www.ti.com/product/LM3532
20 changes: 0 additions & 20 deletions Documentation/devicetree/bindings/mfd/ti-lmu.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ TI LMU driver supports lighting devices below.

Name Child nodes
------ ---------------------------------
LM3532 Backlight
LM3631 Backlight and regulator
LM3632 Backlight and regulator
LM3633 Backlight, LED and fault monitor
Expand All @@ -13,7 +12,6 @@ TI LMU driver supports lighting devices below.

Required properties:
- compatible: Should be one of:
"ti,lm3532"
"ti,lm3631"
"ti,lm3632"
"ti,lm3633"
Expand All @@ -23,7 +21,6 @@ Required properties:
0x11 for LM3632
0x29 for LM3631
0x36 for LM3633, LM3697
0x38 for LM3532
0x63 for LM3695

Optional property:
Expand All @@ -47,23 +44,6 @@ Optional nodes:
[2] ../leds/leds-lm3633.txt
[3] ../regulator/lm363x-regulator.txt

lm3532@38 {
compatible = "ti,lm3532";
reg = <0x38>;

enable-gpios = <&pioC 2 GPIO_ACTIVE_HIGH>;

backlight {
compatible = "ti,lm3532-backlight";

lcd {
led-sources = <0 1 2>;
ramp-up-msec = <30>;
ramp-down-msec = <0>;
};
};
};

lm3631@29 {
compatible = "ti,lm3631";
reg = <0x29>;
Expand Down
27 changes: 18 additions & 9 deletions arch/arm/boot/dts/omap4-droid4-xt894.dts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@

width-mm = <50>;
height-mm = <89>;
backlight = <&lcd_backlight>;

panel-timing {
clock-frequency = <0>; /* Calculated by dsi */
Expand Down Expand Up @@ -383,20 +382,30 @@
};

&i2c1 {
lm3532@38 {
led-controller@38 {
compatible = "ti,lm3532";
#address-cells = <1>;
#size-cells = <0>;
reg = <0x38>;

enable-gpios = <&gpio6 12 GPIO_ACTIVE_HIGH>;

lcd_backlight: backlight {
compatible = "ti,lm3532-backlight";
ramp-up-us = <1024>;
ramp-down-us = <8193>;

lcd {
led-sources = <0 1 2>;
ramp-up-msec = <1>;
ramp-down-msec = <0>;
};
led@0 {
reg = <0>;
led-sources = <2>;
ti,led-mode = <0>;
label = ":backlight";
linux,default-trigger = "backlight";
};

led@1 {
reg = <1>;
led-sources = <1>;
ti,led-mode = <0>;
label = ":kbd_backlight";
};
};
};
Expand Down
33 changes: 22 additions & 11 deletions drivers/leds/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ config LEDS_CLASS_FLASH
tristate "LED Flash Class Support"
depends on LEDS_CLASS
help
This option enables the flash led sysfs class in /sys/class/leds.
It wrapps LED Class and adds flash LEDs specific sysfs attributes
This option enables the flash LED sysfs class in /sys/class/leds.
It wraps LED Class and adds flash LEDs specific sysfs attributes
and kernel internal API to it. You'll need this to provide support
for the flash related features of a LED device. It can be built
as a module.
Expand Down Expand Up @@ -56,7 +56,7 @@ config LEDS_AAT1290
depends on OF
depends on PINCTRL
help
This option enables support for the LEDs on the AAT1290.
This option enables support for the LEDs on the AAT1290.

config LEDS_AN30259A
tristate "LED support for Panasonic AN30259A"
Expand Down Expand Up @@ -138,6 +138,16 @@ config LEDS_LM3530
controlled manually or using PWM input or using ambient
light automatically.

config LEDS_LM3532
tristate "LCD Backlight driver for LM3532"
depends on LEDS_CLASS
depends on I2C
help
This option enables support for the LCD backlight using
LM3532 ambient light sensor chip. This ALS chip can be
controlled manually or using PWM input or using ambient
light automatically.

config LEDS_LM3533
tristate "LED support for LM3533"
depends on LEDS_CLASS
Expand Down Expand Up @@ -413,13 +423,13 @@ config LEDS_CLEVO_MAIL

This module can drive the mail LED for the following notebooks:

Clevo D400P
Clevo D410J
Clevo D410V
Clevo D400V/D470V (not tested, but might work)
Clevo M540N
Clevo M5x0N (not tested, but might work)
Positivo Mobile (Clevo M5x0V)
Clevo D400P
Clevo D410J
Clevo D410V
Clevo D400V/D470V (not tested, but might work)
Clevo M540N
Clevo M5x0N (not tested, but might work)
Positivo Mobile (Clevo M5x0V)

If your model is not listed here you can try the "nodetect"
module parameter.
Expand Down Expand Up @@ -462,7 +472,7 @@ config LEDS_WM831X_STATUS
depends on MFD_WM831X
help
This option enables support for the status LEDs of the WM831x
series of PMICs.
series of PMICs.

config LEDS_WM8350
tristate "LED Support for WM8350 AudioPlus PMIC"
Expand Down Expand Up @@ -533,6 +543,7 @@ config LEDS_LT3593
tristate "LED driver for LT3593 controllers"
depends on LEDS_CLASS
depends on GPIOLIB || COMPILE_TEST
depends on OF
help
This option enables support for LEDs driven by a Linear Technology
LT3593 controller. This controller uses a special one-wire pulse
Expand Down
1 change: 1 addition & 0 deletions drivers/leds/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ obj-$(CONFIG_LEDS_BD2802) += leds-bd2802.o
obj-$(CONFIG_LEDS_CPCAP) += leds-cpcap.o
obj-$(CONFIG_LEDS_LOCOMO) += leds-locomo.o
obj-$(CONFIG_LEDS_LM3530) += leds-lm3530.o
obj-$(CONFIG_LEDS_LM3532) += leds-lm3532.o
obj-$(CONFIG_LEDS_LM3533) += leds-lm3533.o
obj-$(CONFIG_LEDS_LM3642) += leds-lm3642.o
obj-$(CONFIG_LEDS_MIKROTIK_RB532) += leds-rb532.o
Expand Down
1 change: 1 addition & 0 deletions drivers/leds/led-class.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ static ssize_t brightness_store(struct device *dev,
if (state == LED_OFF)
led_trigger_remove(led_cdev);
led_set_brightness(led_cdev, state);
flush_work(&led_cdev->set_brightness_work);

ret = size;
unlock:
Expand Down
5 changes: 5 additions & 0 deletions drivers/leds/led-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ static void led_blink_setup(struct led_classdev *led_cdev,
unsigned long *delay_on,
unsigned long *delay_off)
{
/*
* If "set brightness to 0" is pending in workqueue, we don't
* want that to be reordered after blink_set()
*/
flush_work(&led_cdev->set_brightness_work);
if (!test_bit(LED_BLINK_ONESHOT, &led_cdev->work_flags) &&
led_cdev->blink_set &&
!led_cdev->blink_set(led_cdev, delay_on, delay_off))
Expand Down
Loading

0 comments on commit 8b35ad6

Please sign in to comment.