leds: flash: LM3643 dual LED flash driver
Subsystems (2)
cover leds: flash: LM3643 dual LED flash driver
This series adds a flash LED driver for the Texas Instruments LM3643. I wrote it to support the Windows Hello NIR illuminator on my ThinkPad X9-15 Gen 1, which appears to have a single LED connected to both current sources. All non-error code paths have been tested on my device.
This device is enumerated by ACPI (HID TXNW3643) as an I2C client with no _DSD. The driver, following the leds/flash convention, sees no LED child nodes and fails to probe. For testing I have been using an SSDT overlay.
On Windows, Lenovo distributes an LM3643 driver authored by Intel. Its inf file matches on the HID alone and contains a default intensity for each LED, 100% for LED1 and 60% for LED2, which suggests the driver applies a static configuration to any enumerated LM3643.
I am sending this RFC to ask how best to supply this default static configuration. The options I can see are:
1. A DMI-matched table, similar to touchscreen_dmi.c, that attaches LED child nodes on verified boards. I haven't found any existing examples of this being done for LED child nodes.
2. A generic fallback in the driver exposing both current sources as independent LEDs. However this would apply to all matches without a firmware description.
I'd appreciate any guidance on the preferred approach.
Rillian Grant (2):
dt-bindings: leds: Document TI LM3643 dual LED flash driver
leds: flash: Add support for the TI LM3643 dual LED flash driver
.../devicetree/bindings/leds/ti,lm3643.yaml | 126 +++ MAINTAINERS | 7 + drivers/leds/flash/Kconfig | 12 + drivers/leds/flash/Makefile | 1 + drivers/leds/flash/leds-lm3643.c | 775 ++++++++++++++++++ 5 files changed, 921 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/ti,lm3643.yaml create mode 100644 drivers/leds/flash/leds-lm3643.c
base-commit: a4ff2be345d0abc943da8dd8da98151843b750dc
Signature · 1 line
2.55.0
RFC PATCH 1/2 dt-bindings: leds: Document TI LM3643 dual LED flash driver
Document Texas Instruments LM3643 dual LED flash driver devicetree bindings.
--- .../devicetree/bindings/leds/ti,lm3643.yaml | 126 ++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/ti,lm3643.yaml
Documentation/devicetree/bindings/leds/ti,lm3643.yaml new file +126 -0
@@ -0,0 +1,126 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/leds/ti,lm3643.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Texas Instruments LM3643 1500mA dual LED Flash Driver + +maintainers: + - Rillian Grant <[email protected]> + +description: | + The LM3643 is a dual LED flash driver utilizing a synchronous boost converter + to provide power to two current sources. + + The dual high-side current sources can be tied together to provide flash + currents up to 1.5A through a single LED. + + Datasheet: https://www.ti.com/lit/ds/symlink/lm3643.pdf + +properties: + compatible: + enum: + - ti,lm3643 + + reg: + maxItems: 1 + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + +patternProperties: + "^led@[0-1]$": + type: object + $ref: common.yaml# + unevaluatedProperties: false + + properties: + reg: + description: Index of the LED. + minimum: 0 + maximum: 1 + + led-sources: + minItems: 1 + maxItems: 2 + items: + minimum: 0 + maximum: 1 + + flash-max-microamp: + description: | + Maximum flash current through this LED. Each high-side current source + can provide up to 1.5A. The maximum current the boost can deliver is + 1.5A across both sources. + + Valid values for an LED connected to one source: + 10900 - 1500000, step by 11725 (rounded down) + Valid values for an LED connected to both sources: + 21800 - 1500000, step by 23450 (rounded down) + + minimum: 10900 + maximum: 1500000 + + led-max-microamp: + description: | + Maximum torch current through this LED. In torch mode each high-side + current source can provide up to 179mA. + + Valid values for an LED connected to one source: + 977 - 179000, step by 1400 (rounded down) + Valid values for an LED connected to both sources: + 1954 - 358000, step by 2800 (rounded down) + + minimum: 977 + maximum: 358000 + + flash-max-timeout-us: + description: | + The chip supports timeouts from 10ms to 100ms in increments of 10ms + and from 100ms to 400ms in increments of 50ms. The provided value + will be rounded down to a supported value. + + minimum: 10000 + maximum: 400000 + + required: + - reg + - led-sources + +required: + - compatible + - reg + - "#address-cells" + - "#size-cells" + +additionalProperties: false + +examples: + - | + #include <dt-bindings/leds/common.h> + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + flash-led-controller@63 { + compatible = "ti,lm3643"; + reg = <0x63>; + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + led-sources = <0>, <1>; + function = LED_FUNCTION_FLASH; + color = <LED_COLOR_ID_IR>; + flash-max-microamp = <750000>; + led-max-microamp = <180000>; + flash-max-timeout-us = <150000>; + }; + }; + };
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [RFC PATCH 1/2] dt-bindings: leds: Document TI LM3643 dual LED flash driver
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] The schema does not enforce `flash-max-microamp`, `flash-max-timeout-us`, and `led-max-microamp`…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The schema does not enforce flash-max-microamp, flash-max-timeout-us, and led-max-microamp as required properties for the LED child node. --
--- Patch [1]: [RFC PATCH 1/2] dt-bindings: leds: Document TI LM3643 dual LED flash driver --- commit 0c56365dce9a84b7387d67d8621b8beeacea7aec
Author: Rillian Grant <[email protected]>
dt-bindings: leds: Document TI LM3643 dual LED flash driver
This commit documents the devicetree bindings for the Texas Instruments LM3643 dual LED flash driver, which uses a synchronous boost converter to power up to two current sources up to 1.5A.
Quoted 5 lines
Documentation/devicetree/bindings/leds/ti,lm3643.yaml new file +0
-0
[ ... ]
Quoted 5 lines
Documentation/devicetree/bindings/leds/ti,lm3643.yaml new file +5
-0+patternProperties: + "^led@[0-1]$": + type: object + $ref: common.yaml# + unevaluatedProperties: false
[ ... ]
Documentation/devicetree/bindings/leds/ti,lm3643.yaml line 92
Quoted 12 lines
Documentation/devicetree/bindings/leds/ti,lm3643.yaml new file +12
-0+ flash-max-timeout-us: + description: | + The chip supports timeouts from 10ms to 100ms in increments of 10ms + and from 100ms to 400ms in increments of 50ms. The provided value + will be rounded down to a supported value. + + minimum: 10000 + maximum: 400000 + + required: + - reg + - led-sources
[Severity: High]
Should flash-max-microamp, flash-max-timeout-us, and led-max-microamp be included here as required properties for the LED child node?
Without these properties enforced by the schema, a device tree could omit them and still pass validation. If omitted, will driver fallback to the controller's absolute maximums (1.5A and 400ms) risk physically damaging connected LEDs that have lower electrical limits?
Quoted 6 lines
Documentation/devicetree/bindings/leds/ti,lm3643.yaml new file +6
-0+ +required: + - compatible + - reg + - "#address-cells" + - "#size-cells"
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
RFC PATCH 2/2 leds: flash: Add support for the TI LM3643 dual LED flash driver
In reply to Rillian GrantThe LM3643 is an I2C dual LED flash driver. Its two high-side current sources share a synchronous boost converter and each supports torch and flash modes with programmable current and flash timeout alongside fault reporting.
It also supports connecting both sources together to supply one LED with current up to the boost converter's 1.5A maximum. In that case the current will be split between each source symmetrically and the sources will be enabled and disabled at the same time.
As strobing is toggled chip-wide the driver returns -EBUSY when a sibling LED is active.
Flash timeouts do not have a constant step. The driver advertises the most granular step and rounds down to the nearest supported value.
Register behavior was taken from the datasheet (SNVS967A).
--- MAINTAINERS | 7 + drivers/leds/flash/Kconfig | 12 + drivers/leds/flash/Makefile | 1 + drivers/leds/flash/leds-lm3643.c | 775 +++++++++++++++++++++++++++++++ 4 files changed, 795 insertions(+) create mode 100644 drivers/leds/flash/leds-lm3643.c
MAINTAINERS +7 -0
@@ -26791,6 +26791,13 @@ F: include/linux/dma/k3-udma-glue.h F: include/linux/dma/ti-cppi5.h X: drivers/dma/ti/cppi41.c +TEXAS INSTRUMENTS LM3643 LED FLASH DRIVER +M: Rillian Grant <[email protected]> +L: [email protected] +S: Maintained +F: Documentation/devicetree/bindings/leds/ti,lm3643.yaml +F: drivers/leds/flash/leds-lm3643.c + TEXAS INSTRUMENTS TPS25990 HARDWARE MONITOR DRIVER M: Jerome Brunet <[email protected]> L: [email protected]
drivers/leds/flash/Kconfig +12 -0
@@ -39,6 +39,18 @@ config LEDS_LM3601X This option enables support for the TI LM3601x family of flash, torch and indicator classes. +config LEDS_LM3643 + tristate "LED support for LM3643 dual LED flash driver" + depends on I2C + depends on V4L2_FLASH_LED_CLASS || !V4L2_FLASH_LED_CLASS + select REGMAP_I2C + help + This option enables support for the Texas Instruments LM3643 dual + LED flash driver. + + This driver can also be built as a module. If so, the module + will be called "leds-lm3643". + config LEDS_MAX77693 tristate "LED support for MAX77693 Flash" depends on V4L2_FLASH_LED_CLASS || !V4L2_FLASH_LED_CLASS
drivers/leds/flash/Makefile +1 -0
@@ -6,6 +6,7 @@ obj-$(CONFIG_LEDS_AAT1290) += leds-aat1290.o obj-$(CONFIG_LEDS_AS3645A) += leds-as3645a.o obj-$(CONFIG_LEDS_KTD2692) += leds-ktd2692.o obj-$(CONFIG_LEDS_LM3601X) += leds-lm3601x.o +obj-$(CONFIG_LEDS_LM3643) += leds-lm3643.o obj-$(CONFIG_LEDS_MAX77693) += leds-max77693.o obj-$(CONFIG_LEDS_QCOM_FLASH) += leds-qcom-flash.o obj-$(CONFIG_LEDS_RT4505) += leds-rt4505.o
drivers/leds/flash/leds-lm3643.c new file +775 -0
775 lines not on this page · raw message
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [RFC PATCH 2/2] leds: flash: Add support for the TI LM3643 dual LED flash driver
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] Turning off an LED fails to clear the chip mode bits, causing power drain and breaking flash…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Turning off an LED fails to clear the chip mode bits, causing power drain and breaking flash strobe teardown. --
--- Patch [2]: [RFC PATCH 2/2] leds: flash: Add support for the TI LM3643 dual LED flash driver --- commit bdf1945ab184ca005c2f401ecd5408571ece1de3
Author: Rillian Grant <[email protected]>
leds: flash: Add support for the TI LM3643 dual LED flash driver
The LM3643 is an I2C dual LED flash driver. Its two high-side current sources share a synchronous boost converter and each supports torch and flash modes with programmable current and flash timeout alongside fault reporting.
Quoted 4 lines
drivers/leds/flash/leds-lm3643.c new file +0
-0
[ ... ]
Quoted 3 lines
drivers/leds/flash/leds-lm3643.c new file +3
-0+static int lm3643_torch_set_brightness (struct led_classdev *led_cdev, +enum led_brightness brightness) +{
[ ... ]
drivers/leds/flash/leds-lm3643.c line 276
Quoted 3 lines
drivers/leds/flash/leds-lm3643.c new file +3
-0+if (brightness ==0 ) +return regmap_update_bits (led->regmap,LM3643_REG_ENABLE , + chan->enable_bit,0 );
[Severity: High]
When brightness is 0, this only clears the channel's enable bit but leaves the LM3643_MODE_MASK bits intact. If no other LEDs are active, does this leave the chip in an active power state (Torch or Flash mode) instead of transitioning to LM3643_MODE_STANDBY, potentially causing continuous battery drain?
[ ... ]
Quoted 2 lines
drivers/leds/flash/leds-lm3643.c new file +2
-0+static int lm3643_flash_strobe_set (struct led_classdev_flash *fled_cdev,bool state) +{
[ ... ]
drivers/leds/flash/leds-lm3643.c line 373
Quoted 7 lines
drivers/leds/flash/leds-lm3643.c new file +7
-0+if (!state) { +if (mode !=LM3643_MODE_FLASH || !(enable_reg & chan->enable_bit)) +return 0 ; + +return regmap_update_bits (led->regmap,LM3643_REG_ENABLE , +LM3643_MODE_MASK ,LM3643_MODE_STANDBY ); + }
[Severity: High]
If the torch brightness was set to 0 during a flash, the channel's enable bit will have been cleared. During the subsequent teardown call to lm3643_flash_strobe_set() with state = false, does this early return trigger because the enable bit is no longer set?
This would fail to restore the mode to LM3643_MODE_STANDBY, permanently stranding the driver's state machine in Flash mode.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Lee Jones
maintainerRe: [RFC PATCH 2/2] leds: flash: Add support for the TI LM3643 dual LED flash driver
Quoted 2 lines · On Fri, 21 Aug 2026, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Turning off an LED fails to clear the chip mode bits, causing power drain and breaking flash strobe teardown.
Please review, explain or fix the Sashiko review(s).
If this is a set, this request includes the other patches too.
Quoted 63 lines
--
--- Patch [2]: [RFC PATCH 2/2] leds: flash: Add support for the TI LM3643 dual LED flash driver --- commit
bdf1945ab184ca005c2f401ecd5408571ece1de3
Author: Rillian Grant <[email protected]>leds: flash: Add support for the TI LM3643 dual LED flash driver
The LM3643 is an I2C dual LED flash driver. Its two high-side current sources share a synchronous boost converter and each supports torch and flash modes with programmable current and flash timeout alongside fault reporting.
Quoted 4 lines
drivers/leds/flash/leds-lm3643.c new file +0
-0[ ... ]
Quoted 3 lines
drivers/leds/flash/leds-lm3643.c new file +3
-0+static int lm3643_torch_set_brightness (struct led_classdev *led_cdev, +enum led_brightness brightness) +{[ ... ]
drivers/leds/flash/leds-lm3643.c line 276
Quoted 3 lines
drivers/leds/flash/leds-lm3643.c new file +3
-0+if (brightness ==0 ) +return regmap_update_bits (led->regmap,LM3643_REG_ENABLE , + chan->enable_bit,0 );[Severity: High]
When brightness is 0, this only clears the channel's enable bit but leaves theLM3643_MODE_MASKbits intact. If no other LEDs are active, does this leave the chip in an active power state (Torch or Flash mode) instead of transitioning toLM3643_MODE_STANDBY, potentially causing continuous battery drain?[ ... ]
Quoted 2 lines
drivers/leds/flash/leds-lm3643.c new file +2
-0+static int lm3643_flash_strobe_set (struct led_classdev_flash *fled_cdev,bool state) +{[ ... ]
drivers/leds/flash/leds-lm3643.c line 373
Quoted 7 lines
drivers/leds/flash/leds-lm3643.c new file +7
-0+if (!state) { +if (mode !=LM3643_MODE_FLASH || !(enable_reg & chan->enable_bit)) +return 0 ; + +return regmap_update_bits (led->regmap,LM3643_REG_ENABLE , +LM3643_MODE_MASK ,LM3643_MODE_STANDBY ); + }[Severity: High]
If the torch brightness was set to 0 during a flash, the channel's enable bit will have been cleared. During the subsequent teardown call tolm3643_flash_strobe_set()with state = false, does this early return trigger because the enable bit is no longer set?This would fail to restore the mode to
LM3643_MODE_STANDBY, permanently stranding the driver's state machine in Flash mode.Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Signature · 1 line
Lee Jones
cover leds: flash: lm3643: standby fix and ACPI LED description
In reply to Rillian GrantThese apply on top of Rillian Grant's "[RFC PATCH 0/2] leds: flash:
LM3643 dual LED flash driver" and answer two things from that thread.
Patch 1 addresses the two state-machine problems flagged by the Sashiko review of the RFC, which Lee Jones asked to have addressed: switching the last active output off left the chip in torch or flash mode instead of standby.
Patch 2 addresses the question in the RFC cover letter about supplying a default configuration on ACPI machines, where the chip is enumerated as TXNW3643 without LED child nodes: it adds a DMI table describing the LED as a software node, starting with the Lenovo ThinkPad X1 Carbon Gen 14, where the LM3643 drives the Windows Hello IR flood illuminator with both current sources feeding one LED. The limits are 100 mA torch and 300 mA flash per output, well below the chip's maximums.
Tested on that laptop with Fedora 44 (kernel 7.2.5): the LED appears as ir:flash, torch mode lights the ST VD55G1 IR camera's field of view and the chip returns to standby when the torch is switched off, and face authentication with howdy works on those frames.
Rillian, if you prefer to fold these into a v2 of your series, please do; a DMI entry for the X9-15 Gen 1 only needs its product version string.
Ruslan Koreev (2):
leds: flash: lm3643: Return to standby when the last output is
switched off
leds: flash: lm3643: Describe the LED of ACPI boards without LED nodes
drivers/leds/flash/leds-lm3643.c | 115 +++++++++++++++++++++++++++++-- 1 file changed, 109 insertions(+), 6 deletions(-)
Signature · 1 line
2.55.0
PATCH 1/2 leds: flash: lm3643: Return to standby when the last output is switched off
Setting the torch brightness of an output to 0 only cleared its enable bit and left the mode bits at torch (or flash), so the chip kept its boost converter running with no output enabled. Likewise switching the strobe off returned early when the output's enable bit had already been cleared, leaving the mode bits at flash. Both were flagged by the Sashiko review of the RFC, which Lee Jones asked to have addressed.
Clear the mode bits together with the enable bit whenever the sibling output is not active, so that the chip goes back to standby when its last output is switched off.
--- drivers/leds/flash/leds-lm3643.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-)
drivers/leds/flash/leds-lm3643.c +17 -6
@@ -271,9 +271,15 @@ static int lm3643_torch_set_brightness(struct led_classdev *led_cdev, mode != LM3643_MODE_TORCH)return -EBUSY ; -if (brightness ==0 ) -return regmap_update_bits (led->regmap,LM3643_REG_ENABLE , - chan->enable_bit,0 ); +if (brightness ==0 ) { +unsigned int mask = chan->enable_bit; + +/* Last active output: leave torch mode, back to standby */ +if (!(enable & sibling_bit)) + mask |=LM3643_MODE_MASK ; + +return regmap_update_bits (led->regmap,LM3643_REG_ENABLE , mask,0 ); + } ret =regmap_update_bits (led->regmap, chan->torch_br_reg,LM3643_TORCH_BR_MASK ,LM3643_TORCH_BR_CDEV_TO_CODE (brightness));
@@ -365,11 +371,16 @@ static int lm3643_flash_strobe_set(struct led_classdev_flash *fled_cdev, bool st mode = enable_reg &LM3643_MODE_MASK ;if (!state) { -if (mode !=LM3643_MODE_FLASH || !(enable_reg & chan->enable_bit)) +unsigned int mask = chan->enable_bit; + +if (mode !=LM3643_MODE_FLASH )return 0 ; -return regmap_update_bits (led->regmap,LM3643_REG_ENABLE , -LM3643_MODE_MASK ,LM3643_MODE_STANDBY ); +/* Leave flash mode once no other output is strobing */ +if (!(enable_reg & sibling_bit)) + mask |=LM3643_MODE_MASK ; + +return regmap_update_bits (led->regmap,LM3643_REG_ENABLE , mask,0 ); }if ((enable_reg & sibling_bit) && mode !=LM3643_MODE_STANDBY )return -EBUSY ;
Signature · 1 line
2.55.0
Lee Jones
maintainerRe: [PATCH 1/2] leds: flash: lm3643: Return to standby when the last output is switched off
--- checkpatch.pl: clean (0 issues) ---
Quoted 7 lines · Ruslan Koreev
Setting the torch brightness of an output to 0 only cleared its enable bit and left the mode bits at torch (or flash), so the chip kept its boost converter running with no output enabled. Likewise switching the strobe off returned early when the output's enable bit had already been cleared, leaving the mode bits at flash. Both were flagged by the Sashiko review of the RFC, which Lee Jones asked to have addressed.
Quoted 5 lines
Clear the mode bits together with the enable bit whenever the sibling output is not active, so that the chip goes back to standby when its last output is switched off.
Signed-off-by Ruslan Koreev <[email protected]>
Given that the base series hasn't been merged yet, please coordinate with Rillian to fold these fixes directly into the next version of the original series rather than sending fix-up patches on top of an unapplied RFC.
Quoted 50 lines
--- drivers/leds/flash/leds-lm3643.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-)drivers/leds/flash/leds-lm3643.c +17
-6@@ -271,9 +271,15 @@ static int lm3643_torch_set_brightness(struct led_classdev *led_cdev, mode != LM3643_MODE_TORCH)return -EBUSY ; -if (brightness ==0 ) -return regmap_update_bits (led->regmap,LM3643_REG_ENABLE , - chan->enable_bit,0 ); +if (brightness ==0 ) { +unsigned int mask = chan->enable_bit; + +/* Last active output: leave torch mode, back to standby */ +if (!(enable & sibling_bit)) + mask |=LM3643_MODE_MASK ; + +return regmap_update_bits (led->regmap,LM3643_REG_ENABLE , mask,0 ); + } ret =regmap_update_bits (led->regmap, chan->torch_br_reg,LM3643_TORCH_BR_MASK ,LM3643_TORCH_BR_CDEV_TO_CODE (brightness));@@ -365,11 +371,16 @@ static int lm3643_flash_strobe_set(struct led_classdev_flash *fled_cdev, bool st mode = enable_reg &LM3643_MODE_MASK ;if (!state) { -if (mode !=LM3643_MODE_FLASH || !(enable_reg & chan->enable_bit)) +unsigned int mask = chan->enable_bit; + +if (mode !=LM3643_MODE_FLASH )return 0 ; -return regmap_update_bits (led->regmap,LM3643_REG_ENABLE , -LM3643_MODE_MASK ,LM3643_MODE_STANDBY ); +/* Leave flash mode once no other output is strobing */ +if (!(enable_reg & sibling_bit)) + mask |=LM3643_MODE_MASK ; + +return regmap_update_bits (led->regmap,LM3643_REG_ENABLE , mask,0 ); }if ((enable_reg & sibling_bit) && mode !=LM3643_MODE_STANDBY )return -EBUSY ;Signature · 1 line
2.55.0
Signature · 1 line
Lee Jones
Re: [PATCH 1/2] leds: flash: lm3643: Return to standby when the last output is switched off
Hi Lee,
Quoted 3 lines · Lee Jones
Given that the base series hasn't been merged yet, please coordinate with Rillian to fold these fixes directly into the next version of the original series rather than sending fix-up patches on top of an unapplied RFC.
Rillian already folded the standby fix into the driver in patch 2/4 and included the ACPI LED description as patch 3/4. Both were included in v2 and carried forward into v3, posted on October 11:
https://lore.kernel.org/linux-leds/[email protected]/
Please treat my original two-patch series as superseded.
Thanks,
Ruslan
PATCH 2/2 leds: flash: lm3643: Describe the LED of ACPI boards without LED nodes
In reply to Ruslan KoreevLenovo ThinkPads enumerate the LM3643 through ACPI (HID TXNW3643) without a _DSD, so the device has no LED child nodes and the driver refuses to probe. On these laptops the chip drives the Windows Hello IR flood illuminator, with both current sources feeding a single LED, and Lenovo's Windows driver applies a fixed configuration to any LM3643 it finds.
Add a DMI table that provides that description as a software node when the firmware offers none: one IR flash LED on both outputs, with torch and flash limits well below the chip's maximums. Start with the ThinkPad X1 Carbon Gen 14.
The description is keyed by DMI instead of being applied to every TXNW3643 because the wiring is a board property: which output feeds which LED and how much current the LED tolerates cannot be read from the chip, and a wrong guess overdrives an LED. The firmware cannot be fixed from the driver side, and a per-board table is what x86-android-tablets does for devices whose ACPI tables describe nothing either. Boards with a _DSD are not affected, the fallback only runs when the device has no child nodes. The limits are conservative because the LED part is not documented; the illuminator is bright enough for face authentication at a fraction of them.
Tested on that laptop: torch through /sys/class/leds/ir:flash lights the ST VD55G1 IR camera's field of view, and the resulting frames are good enough for face authentication.
--- drivers/leds/flash/leds-lm3643.c | 92 ++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+)
drivers/leds/flash/leds-lm3643.c +92 -0
@@ -9,6 +9,7 @@#include <linux/bitfield.h> #include <linux/bits.h> #include <linux/cleanup.h> +#include <linux/dmi.h> #include <linux/i2c.h> #include <linux/led-class-flash.h> #include <linux/leds.h>
@@ -690,6 +691,91 @@ static int lm3643_register_led(struct device *dev, struct lm3643 *chip,return lm3643_register_v4l2 (dev, led, fwnode); } +/* +* Lenovo ThinkPads enumerate the chip through ACPI (HID TXNW3643) without a +* _DSD, so the LED is not described by firmware. On the boards below it drives +* the Windows Hello IR flood illuminator, with both current sources feeding a +* single LED. Describe that with a software node, with torch and flash limits +* (100 mA and 300 mA per output) well below the chip's maximums. +*/ +static const u32 lm3643_ir_flood_sources[] = {0 ,1 }; + +static const struct property_entry lm3643_ir_flood_props[] = { +PROPERTY_ENTRY_U32_ARRAY ("led-sources" , lm3643_ir_flood_sources), +PROPERTY_ENTRY_STRING ("function" ,LED_FUNCTION_FLASH ), +PROPERTY_ENTRY_U32 ("color" ,LED_COLOR_ID_IR ), +PROPERTY_ENTRY_U32 ("led-max-microamp" ,200000 ), +PROPERTY_ENTRY_U32 ("flash-max-microamp" ,600000 ), +PROPERTY_ENTRY_U32 ("flash-max-timeout-us" ,100000 ), + { } +}; + +static const struct software_node lm3643_ir_flood_root = { + .name ="lm3643" , +}; + +static const struct software_node lm3643_ir_flood_led = { + .name ="led-0" , + .parent = &lm3643_ir_flood_root, + .properties = lm3643_ir_flood_props, +}; + +static const struct software_node *lm3643_ir_flood_nodes[] = { + &lm3643_ir_flood_root, + &lm3643_ir_flood_led, +NULL +}; + +static const struct dmi_system_id lm3643_dmi_leds[] = { + { +/* Lenovo ThinkPad X1 Carbon Gen 14 */ + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"LENOVO" ), +DMI_MATCH (DMI_PRODUCT_VERSION ,"ThinkPad X1 Carbon Gen 14" ), + }, + .driver_data = (void *)lm3643_ir_flood_nodes, + }, + { } +}; + +static void lm3643_remove_dmi_leds (void *data) +{ +struct device *dev = data; +const struct dmi_system_id *id =dmi_first_match (lm3643_dmi_leds); + +set_secondary_fwnode (dev,NULL ); +if (id) +software_node_unregister_node_group (id->driver_data); +} + +static int lm3643_add_dmi_leds (struct device *dev) +{ +const struct dmi_system_id *id; +const struct software_node **nodes; +int ret; + +if (!has_acpi_companion (dev)) +return 0 ; + + id =dmi_first_match (lm3643_dmi_leds); +if (!id) +return 0 ; + + nodes = id->driver_data; +/* The nodes are static: a second chip on the same board cannot reuse them */ +if (software_node_fwnode (nodes[0 ])) +return dev_err_probe (dev, -EBUSY ,"LED description already in use\n" ); + + ret =software_node_register_node_group (nodes); +if (ret) +return dev_err_probe (dev, ret,"failed to register the LED description\n" ); + +set_secondary_fwnode (dev,software_node_fwnode (nodes[0 ])); +dev_info (dev,"no LED nodes in firmware, using the DMI description\n" ); + +return devm_add_action_or_reset (dev, lm3643_remove_dmi_leds, dev); +} +static int lm3643_probe (struct i2c_client *client) {struct device *dev = &client->dev;
@@ -699,6 +785,12 @@ static int lm3643_probe(struct i2c_client *client)int ret; count =device_get_child_node_count (dev); +if (!count) { + ret =lm3643_add_dmi_leds (dev); +if (ret) +return ret; + count =device_get_child_node_count (dev); + }if (!count || count >LM3643_NUM_CHANNELS )return dev_err_probe (dev, -EINVAL ,"%u LED nodes found, expected 1 to %d\n" , count,LM3643_NUM_CHANNELS );
Signature · 1 line
2.55.0