leds: aat1290: Add support for AAT1270
Subsystems (2)
cover leds: aat1290: Add support for AAT1270
Document AAT1270 and FLINH pin, adjust driver to suport AAT1270.
Svyatoslav Ryhel (3):
dt-bindings: leds: skyworks,aat1290: Document AAT1270 Current
Regulator for Flash LEDs
dt-bindings: leds: skyworks,aat1290: Document FLINH pin
leds: aat1290: Add support for AAT1270 Current Regulator for Flash
LEDs
.../bindings/leds/skyworks,aat1290.yaml | 8 ++- drivers/leds/flash/leds-aat1290.c | 66 +++++++++++++------ 2 files changed, 54 insertions(+), 20 deletions(-)
Signature · 1 line
2.53.0
PATCH 1/3 dt-bindings: leds: skyworks,aat1290: Document AAT1270 Current Regulator for Flash LEDs
The AAT1270 Current Regulator for Flash LEDs has a similar configuration to the AAT1290, but it uses a different programming model and requires a separate compatible.
--- Documentation/devicetree/bindings/leds/skyworks,aat1290.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/leds/skyworks,aat1290.yaml +3 -1
@@ -19,7 +19,9 @@ description: | properties: compatible: - const: skyworks,aat1290 + enum: + - skyworks,aat1290 + - skyworks,aat1270 enset-gpios: maxItems: 1
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH v1 1/3] dt-bindings: leds: skyworks,aat1290: Document AAT1270 Current Regulator for Flash LEDs
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 5 lines
The AAT1270 Current Regulator for Flash LEDs has a similar configuration to the AAT1290, but it uses a different programming model and requires a separate compatible.
Signed-off-by Svyatoslav Ryhel <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
PATCH 2/3 dt-bindings: leds: skyworks,aat1290: Document FLINH pin
In reply to Svyatoslav RyhelBoth the AAT1270 and AAT1290 feature a FLINH pin used for mandatory Flash inhibition.
--- Documentation/devicetree/bindings/leds/skyworks,aat1290.yaml | 4 ++++ 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/leds/skyworks,aat1290.yaml +4 -0
@@ -31,6 +31,10 @@ properties: maxItems: 1 description: FL_EN pin + flinh-gpios: + maxItems: 1 + description: FLINH pin + led: $ref: common.yaml# unevaluatedProperties: false
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH v1 2/3] dt-bindings: leds: skyworks,aat1290: Document FLINH pin
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 4 lines
Both the AAT1270 and AAT1290 feature a FLINH pin used for mandatory Flash inhibition.
Signed-off-by Svyatoslav Ryhel <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Re: [PATCH v1 2/3] dt-bindings: leds: skyworks,aat1290: Document FLINH pin
In reply to Svyatoslav RyhelHi Svyatoslav,
Quoted 13 lines · Svyatoslav Ryhel
Both the AAT1270 and AAT1290 feature a FLINH pin used for mandatory Flash inhibition.
Signed-off-by Svyatoslav Ryhel <[email protected]>--- Documentation/devicetree/bindings/leds/skyworks,aat1290.yaml | 4 ++++ 1 file changed, 4 insertions(+)Documentation/devicetree/bindings/leds/skyworks,aat1290.yaml +0
-0
Documentation/devicetree/bindings/leds/skyworks,aat1290.yaml properties: · line 37
Quoted 7 lines
Documentation/devicetree/bindings/leds/skyworks,aat1290.yaml +4
-0@@ -31,6 +31,10 @@ properties: maxItems: 1 description: FL_EN pin + flinh-gpios: + maxItems: 1 + description: FLINH pin +
You don't seem to make use of it in your patch.
Signature · 2 lines
Best regards, Jacek Anaszewski
Re: [PATCH v1 2/3] dt-bindings: leds: skyworks,aat1290: Document FLINH pin
нд, 11 жовт. 2026 р. о 16:28 Jacek Anaszewski <[email protected]> пише:
Quoted 20 lines
Hi Svyatoslav,
Quoted 16 lines · Svyatoslav Ryhel
Both the AAT1270 and AAT1290 feature a FLINH pin used for mandatory Flash inhibition.
Signed-off-by Svyatoslav Ryhel <[email protected]>--- Documentation/devicetree/bindings/leds/skyworks,aat1290.yaml | 4 ++++ 1 file changed, 4 insertions(+)Documentation/devicetree/bindings/leds/skyworks,aat1290.yaml +0
-0@@ -31,6 +31,10 @@ properties: maxItems: 1 description: FL_EN pin
Quoted 7 lines
Documentation/devicetree/bindings/leds/skyworks,aat1290.yaml properties: · line 37
Quoted 4 lines
Documentation/devicetree/bindings/leds/skyworks,aat1290.yaml +4
-0+ flinh-gpios: + maxItems: 1 + description: FLINH pin +You don't seem to make use of it in your patch.
I don't have to use it in my patch. This change completes and improves hardware description of the AAT1290/1270.
Quoted 4 lines
--
Best regards,
Jacek Anaszewski
Re: [PATCH v1 2/3] dt-bindings: leds: skyworks,aat1290: Document FLINH pin
Quoted 29 lines · Svyatoslav Ryhel
нд, 11 жовт. 2026 р. о 16:28 Jacek Anaszewski <[email protected]> пише:
Quoted 20 lines
Hi Svyatoslav,
Quoted 16 lines · Svyatoslav Ryhel
Both the AAT1270 and AAT1290 feature a FLINH pin used for mandatory Flash inhibition.
Signed-off-by Svyatoslav Ryhel <[email protected]>--- Documentation/devicetree/bindings/leds/skyworks,aat1290.yaml | 4 ++++ 1 file changed, 4 insertions(+)Documentation/devicetree/bindings/leds/skyworks,aat1290.yaml +0
-0@@ -31,6 +31,10 @@ properties: maxItems: 1 description: FL_EN pinQuoted 7 lines
Documentation/devicetree/bindings/leds/skyworks,aat1290.yaml properties: · line 37
Quoted 4 lines
Documentation/devicetree/bindings/leds/skyworks,aat1290.yaml +4
-0+ flinh-gpios: + maxItems: 1 + description: FLINH pin +You don't seem to make use of it in your patch.
Quoted 2 lines
I don't have to use it in my patch. This change completes and improves hardware description of the AAT1290/1270.
Still, If we don't have the use case I'd avoid adding it to not confuse people looking for its use in the driver.
Signature · 2 lines
Best regards, Jacek Anaszewski
Re: [PATCH v1 2/3] dt-bindings: leds: skyworks,aat1290: Document FLINH pin
нд, 11 жовт. 2026 р. о 20:35 Jacek Anaszewski <[email protected]> пише:
Quoted 31 lines · Svyatoslav Ryhel
Quoted 29 lines
нд, 11 жовт. 2026 р. о 16:28 Jacek Anaszewski <[email protected]> пише:
Quoted 27 lines
Hi Svyatoslav,
Quoted 13 lines · Svyatoslav Ryhel
Both the AAT1270 and AAT1290 feature a FLINH pin used for mandatory Flash inhibition.
Signed-off-by Svyatoslav Ryhel <[email protected]>--- Documentation/devicetree/bindings/leds/skyworks,aat1290.yaml | 4 ++++ 1 file changed, 4 insertions(+)Documentation/devicetree/bindings/leds/skyworks,aat1290.yaml +0
-0Documentation/devicetree/bindings/leds/skyworks,aat1290.yaml properties: · line 37
Quoted 7 lines
Documentation/devicetree/bindings/leds/skyworks,aat1290.yaml +4
-0@@ -31,6 +31,10 @@ properties: maxItems: 1 description: FL_EN pin + flinh-gpios: + maxItems: 1 + description: FLINH pin +You don't seem to make use of it in your patch.
Quoted 6 lines
Quoted 2 lines
I don't have to use it in my patch. This change completes and improves hardware description of the AAT1290/1270.
Still, If we don't have the use case I'd avoid adding it to not confuse people looking for its use in the driver.
- DO attempt to make bindings complete even if a driver doesn't support some features. For example, if a device has an interrupt, then include the 'interrupts' property even if the driver is only polled mode.
- DON'T refer to Linux or "device driver" in bindings. Bindings should be based on what the hardware has, not what an OS and driver currently support.
Quoted 3 lines
--
Best regards,
Jacek Anaszewski
Re: [PATCH v1 2/3] dt-bindings: leds: skyworks,aat1290: Document FLINH pin
Quoted 41 lines · Svyatoslav Ryhel
нд, 11 жовт. 2026 р. о 20:35 Jacek Anaszewski <[email protected]> пише:
Quoted 31 lines · Svyatoslav Ryhel
Quoted 29 lines
нд, 11 жовт. 2026 р. о 16:28 Jacek Anaszewski <[email protected]> пише:
Quoted 27 lines
Hi Svyatoslav,
Quoted 13 lines · Svyatoslav Ryhel
Both the AAT1270 and AAT1290 feature a FLINH pin used for mandatory Flash inhibition.
Signed-off-by Svyatoslav Ryhel <[email protected]>--- Documentation/devicetree/bindings/leds/skyworks,aat1290.yaml | 4 ++++ 1 file changed, 4 insertions(+)Documentation/devicetree/bindings/leds/skyworks,aat1290.yaml +0
-0Documentation/devicetree/bindings/leds/skyworks,aat1290.yaml properties: · line 37
Quoted 7 lines
Documentation/devicetree/bindings/leds/skyworks,aat1290.yaml +4
-0@@ -31,6 +31,10 @@ properties: maxItems: 1 description: FL_EN pin + flinh-gpios: + maxItems: 1 + description: FLINH pin +You don't seem to make use of it in your patch.
Quoted 6 lines
Quoted 2 lines
I don't have to use it in my patch. This change completes and improves hardware description of the AAT1290/1270.
Still, If we don't have the use case I'd avoid adding it to not confuse people looking for its use in the driver.
Quoted 8 lines
- DO attempt to make bindings complete even if a driver doesn't support some features. For example, if a device has an interrupt, then include the 'interrupts' property even if the driver is only polled mode.
- DON'T refer to Linux or "device driver" in bindings. Bindings should be based on what the hardware has, not what an OS and driver currently support.
I'll leave it to the maintainer.
Signature · 2 lines
Best regards, Jacek Anaszewski
Lee Jones
maintainerRe: [PATCH v1 2/3] dt-bindings: leds: skyworks,aat1290: Document FLINH pin
Quoted 47 lines · Jacek Anaszewski
Quoted 46 lines · Svyatoslav Ryhel
нд, 11 жовт. 2026 р. о 20:35 Jacek Anaszewski <[email protected]> пише:
Quoted 31 lines · Svyatoslav Ryhel
Quoted 29 lines
нд, 11 жовт. 2026 р. о 16:28 Jacek Anaszewski <[email protected]> пише:
Quoted 27 lines
Hi Svyatoslav,
Quoted 13 lines · Svyatoslav Ryhel
Both the AAT1270 and AAT1290 feature a FLINH pin used for mandatory Flash inhibition.
Signed-off-by Svyatoslav Ryhel <[email protected]>--- Documentation/devicetree/bindings/leds/skyworks,aat1290.yaml | 4 ++++ 1 file changed, 4 insertions(+)Documentation/devicetree/bindings/leds/skyworks,aat1290.yaml +0
-0Documentation/devicetree/bindings/leds/skyworks,aat1290.yaml properties: · line 37
Quoted 7 lines
Documentation/devicetree/bindings/leds/skyworks,aat1290.yaml +4
-0@@ -31,6 +31,10 @@ properties: maxItems: 1 description: FL_EN pin + flinh-gpios: + maxItems: 1 + description: FLINH pin +You don't seem to make use of it in your patch.
Quoted 6 lines
Quoted 2 lines
I don't have to use it in my patch. This change completes and improves hardware description of the AAT1290/1270.
Still, If we don't have the use case I'd avoid adding it to not confuse people looking for its use in the driver.
- DO attempt to make bindings complete even if a driver doesn't support some features. For example, if a device has an interrupt, then include the 'interrupts' property even if the driver is only polled mode.
Quoted 5 lines
Quoted 3 lines
- DON'T refer to Linux or "device driver" in bindings. Bindings should be based on what the hardware has, not what an OS and driver currently support.
I'll leave it to the maintainer.
DT should be OS agnostic and driver orthogonal. So long as it accurately and indisputably describes the H/W, then I think it's fair game.
Is flinh a datasheet term or did we make this up?
Signature · 1 line
Lee Jones
Re: [PATCH v1 2/3] dt-bindings: leds: skyworks,aat1290: Document FLINH pin
ср, 14 жовт. 2026 р. о 12:17 Lee Jones <[email protected]> пише:
Quoted 54 lines · Jacek Anaszewski
Quoted 52 lines · Svyatoslav Ryhel
Quoted 49 lines
нд, 11 жовт. 2026 р. о 20:35 Jacek Anaszewski <[email protected]> пише:
Quoted 31 lines · Svyatoslav Ryhel
Quoted 29 lines
нд, 11 жовт. 2026 р. о 16:28 Jacek Anaszewski <[email protected]> пише:
Quoted 27 lines
Hi Svyatoslav,
Quoted 13 lines · Svyatoslav Ryhel
Both the AAT1270 and AAT1290 feature a FLINH pin used for mandatory Flash inhibition.
Signed-off-by Svyatoslav Ryhel <[email protected]>--- Documentation/devicetree/bindings/leds/skyworks,aat1290.yaml | 4 ++++ 1 file changed, 4 insertions(+)Documentation/devicetree/bindings/leds/skyworks,aat1290.yaml +0
-0Documentation/devicetree/bindings/leds/skyworks,aat1290.yaml properties: · line 37
Quoted 7 lines
Documentation/devicetree/bindings/leds/skyworks,aat1290.yaml +4
-0@@ -31,6 +31,10 @@ properties: maxItems: 1 description: FL_EN pin + flinh-gpios: + maxItems: 1 + description: FLINH pin +You don't seem to make use of it in your patch.
Quoted 6 lines
Quoted 2 lines
I don't have to use it in my patch. This change completes and improves hardware description of the AAT1290/1270.
Still, If we don't have the use case I'd avoid adding it to not confuse people looking for its use in the driver.
- DO attempt to make bindings complete even if a driver doesn't support some features. For example, if a device has an interrupt, then include the 'interrupts' property even if the driver is only polled mode.
- DON'T refer to Linux or "device driver" in bindings. Bindings should be based on what the hardware has, not what an OS and driver currently support.
Quoted 8 lines
Quoted 1 line
I'll leave it to the maintainer.
DT should be OS agnostic and driver orthogonal. So long as it accurately and indisputably describes the H/W, then I think it's fair game.
Is
flinha datasheet term or did we make this up?
You can check yourself if you don't believe me. Both AAT1270 and AAT1290 can be found freely.
FLINH pin #10
Flash inhibit pin. FLINH is an active HIGH control input with an internal 200kΩ resistor to AGND. A low-to-high transition on the FLINH pin reduces FL sink current to the maximum (default) movie-mode current level for the duration of FLINH. Strobing the FLINH pin low to high does not reset the flash timer.
Quoted 2 lines
--
Lee Jones
Lee Jones
maintainerRe: [PATCH v1 2/3] dt-bindings: leds: skyworks,aat1290: Document FLINH pin
Quoted 61 lines · Svyatoslav Ryhel
ср, 14 жовт. 2026 р. о 12:17 Lee Jones <[email protected]> пише:
Quoted 60 lines · Jacek Anaszewski
Quoted 48 lines · Svyatoslav Ryhel
Quoted 46 lines
нд, 11 жовт. 2026 р. о 20:35 Jacek Anaszewski <[email protected]> пише:
Quoted 31 lines · Svyatoslav Ryhel
Quoted 29 lines
нд, 11 жовт. 2026 р. о 16:28 Jacek Anaszewski <[email protected]> пише:
Quoted 27 lines
Hi Svyatoslav,
Quoted 13 lines · Svyatoslav Ryhel
Both the AAT1270 and AAT1290 feature a FLINH pin used for mandatory Flash inhibition.
Signed-off-by Svyatoslav Ryhel <[email protected]>--- Documentation/devicetree/bindings/leds/skyworks,aat1290.yaml | 4 ++++ 1 file changed, 4 insertions(+)Documentation/devicetree/bindings/leds/skyworks,aat1290.yaml +0
-0Documentation/devicetree/bindings/leds/skyworks,aat1290.yaml properties: · line 37
Quoted 7 lines
Documentation/devicetree/bindings/leds/skyworks,aat1290.yaml +4
-0@@ -31,6 +31,10 @@ properties: maxItems: 1 description: FL_EN pin + flinh-gpios: + maxItems: 1 + description: FLINH pin +You don't seem to make use of it in your patch.
Quoted 6 lines
Quoted 2 lines
I don't have to use it in my patch. This change completes and improves hardware description of the AAT1290/1270.
Still, If we don't have the use case I'd avoid adding it to not confuse people looking for its use in the driver.
- DO attempt to make bindings complete even if a driver doesn't support some features. For example, if a device has an interrupt, then include the 'interrupts' property even if the driver is only polled mode.
Quoted 5 lines
Quoted 3 lines
- DON'T refer to Linux or "device driver" in bindings. Bindings should be based on what the hardware has, not what an OS and driver currently support.
I'll leave it to the maintainer.
DT should be OS agnostic and driver orthogonal. So long as it accurately and indisputably describes the H/W, then I think it's fair game.
Quoted 5 lines
Quoted 2 lines
Is
flinha datasheet term or did we make this up?You can check yourself if you don't believe me. Both AAT1270 and AAT1290 can be found freely.
I'd rather just ask you and trust the answer.
Quoted 7 lines
FLINH pin #10
Flash inhibit pin. FLINH is an active HIGH control input with an internal 200kΩ resistor to AGND. A low-to-high transition on the FLINH pin reduces FL sink current to the maximum (default) movie-mode current level for the duration of FLINH. Strobing the FLINH pin low to high does not reset the flash timer.
Okay, thanks.
Signature · 1 line
Lee Jones
PATCH 3/3 leds: aat1290: Add support for AAT1270 Current Regulator for Flash LEDs
In reply to Svyatoslav RyhelThe AAT1270 is quite similar to the AAT1290, but it does not support the Advanced Simple Serial Control (AS2C) used in the AAT1290. The AAT1270 uses an earlier version of AS2C, namely Simple Serial Control, which lacks address-sending capabilities.
Differentiate the chips by using a description structure with a flag to indicate if AS2C is supported, placing all AS2C-only features under a conditional check.
--- drivers/leds/flash/leds-aat1290.c | 66 ++++++++++++++++++++++--------- 1 file changed, 47 insertions(+), 19 deletions(-)
drivers/leds/flash/leds-aat1290.c +47 -19
@@ -43,9 +43,6 @@#define AAT1290_FLASH_TM_NUM_LEVELS 16#define AAT1290_MM_CURRENT_SCALE_SIZE 15 -#define AAT1290_NAME "aat1290" - -struct aat1290_led_config_data {/* maximum LED current in movie mode */ u32 max_mm_current;
@@ -59,6 +56,13 @@ struct aat1290_led_config_data {enum led_brightness max_brightness; }; +struct aat1290_led_chip_info { +/* led controller name */ +const char *name; +/* Advanced Simple Serial Control support */ +bool as2c; +}; +struct aat1290_led {/* platform device data */ struct platform_device *pdev;
@@ -74,6 +78,10 @@ struct aat1290_led {struct gpio_desc *gpio_fl_en;/* EN|SET pin */ struct gpio_desc *gpio_en_set; + +/* led controller description */ +const struct aat1290_led_chip_info *info; +/* movie mode current scale */ int *mm_current_scale;/* device mode */
@@ -101,15 +109,17 @@ static void aat1290_as2cwire_write(struct aat1290_led *led, int addr, int value)udelay (AAT1290_FLEN_OFF_DELAY_TIME_US ); -/* write address */ -for (i =0 ; i < addr; ++i) { -udelay (AAT1290_EN_SET_TICK_TIME_US ); -gpiod_direction_output (led->gpio_en_set,0 ); -udelay (AAT1290_EN_SET_TICK_TIME_US ); -gpiod_direction_output (led->gpio_en_set,1 ); - } +if (led->info->as2c) { +/* write address */ +for (i =0 ; i < addr; ++i) { +udelay (AAT1290_EN_SET_TICK_TIME_US ); +gpiod_direction_output (led->gpio_en_set,0 ); +udelay (AAT1290_EN_SET_TICK_TIME_US ); +gpiod_direction_output (led->gpio_en_set,1 ); + } -usleep_range (AAT1290_LATCH_TIME_MIN_US ,AAT1290_LATCH_TIME_MAX_US ); +usleep_range (AAT1290_LATCH_TIME_MIN_US ,AAT1290_LATCH_TIME_MAX_US ); + }/* write data */ for (i =0 ; i < value; ++i) {
@@ -150,16 +160,18 @@ static int aat1290_led_brightness_set(struct led_classdev *led_cdev, led->movie_mode = false; }else {if (!led->movie_mode) { -aat1290_as2cwire_write (led, -AAT1290_MM_CURRENT_RATIO_ADDR , -AAT1290_MM_TO_FL_1_92 ); +if (led->info->as2c) +aat1290_as2cwire_write (led, +AAT1290_MM_CURRENT_RATIO_ADDR , +AAT1290_MM_TO_FL_1_92 ); led->movie_mode = true; }aat1290_as2cwire_write (led,AAT1290_MOVIE_MODE_CURRENT_ADDR ,AAT1290_MAX_MM_CURR_PERCENT_0 - brightness); -aat1290_as2cwire_write (led,AAT1290_MOVIE_MODE_CONFIG_ADDR , -AAT1290_MOVIE_MODE_ON ); +if (led->info->as2c) +aat1290_as2cwire_write (led,AAT1290_MOVIE_MODE_CONFIG_ADDR , +AAT1290_MOVIE_MODE_ON ); }mutex_unlock (&led->lock);
@@ -178,7 +190,8 @@ static int aat1290_led_flash_strobe_set(struct led_classdev_flash *fled_cdev,mutex_lock (&led->lock);if (state) { -aat1290_set_flash_safety_timer (led, timeout->val); +if (led->info->as2c) +aat1290_set_flash_safety_timer (led, timeout->val);gpiod_direction_output (led->gpio_fl_en,1 ); }else {gpiod_direction_output (led->gpio_fl_en,0 );
@@ -475,6 +488,10 @@ static int aat1290_led_probe(struct platform_device *pdev) fled_cdev->ops = &flash_ops; led_cdev = &fled_cdev->led_cdev; + led->info =device_get_match_data (dev); +if (!led->info) +return -ENODEV ; + ret =aat1290_led_get_configuration (led, &led_cfg, &sub_node);if (ret <0 )return ret;
@@ -489,7 +506,7 @@ static int aat1290_led_probe(struct platform_device *pdev)aat1290_init_flash_timeout (led, &led_cfg); init_data.fwnode =of_fwnode_handle (sub_node); - init_data.devicename =AAT1290_NAME ; + init_data.devicename = led->info->name;/* Register LED Flash class device */ ret = led_classdev_flash_register_ext(&pdev->dev, fled_cdev,
@@ -528,8 +545,19 @@ static void aat1290_led_remove(struct platform_device *pdev)mutex_destroy (&led->lock); } +static const struct aat1290_led_chip_info aat1290_info = { + .name ="aat1290" , + .as2c = true, +}; + +static const struct aat1290_led_chip_info aat1270_info = { + .name ="aat1270" , + .as2c = false, +}; +static const struct of_device_id aat1290_led_dt_match[] = { - { .compatible ="skyworks,aat1290" }, + { .compatible ="skyworks,aat1290" , .data = &aat1290_info }, + { .compatible ="skyworks,aat1270" , .data = &aat1270_info }, {}, };MODULE_DEVICE_TABLE (of, aat1290_led_dt_match);
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH v1 3/3] leds: aat1290: Add support for AAT1270 Current Regulator for Flash LEDs
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] leds: aat1270: silently ignores flash timeout while exposing sysfs attribute --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] leds: aat1270: silently ignores flash timeout while exposing sysfs attribute --
commit 74189882b25371dce0e983ebf15bb883544c3cfd
Author: Svyatoslav Ryhel <[email protected]>
leds: aat1290: Add support for AAT1270 Current Regulator for Flash LEDs
This commit adds support for the AAT1270 flash LED controller. It differentiates it from the AAT1290 by introducing a chip description structure that flags whether the Advanced Simple Serial Control (AS2C) interface is supported, and gates AS2C-specific features accordingly.
Quoted 4 lines
drivers/leds/flash/leds-aat1290.c +0
-0
[ ... ]
drivers/leds/flash/leds-aat1290.c static int aat1290_led_flash_strobe_set(struct led_classdev_flash *fled_cdev, · line 194
Quoted 7 lines
drivers/leds/flash/leds-aat1290.c +2
-1@@ -178,7 +190,8 @@ static int aat1290_led_flash_strobe_set(struct led_classdev_flash *fled_cdev,mutex_lock (&led->lock);if (state) { -aat1290_set_flash_safety_timer (led, timeout->val); +if (led->info->as2c) +aat1290_set_flash_safety_timer (led, timeout->val);
[Severity: Medium]
Can this regression silently ignore the flash timeout for the AAT1270 chip while still exposing the sysfs attribute?
The patch bypasses programming the hardware flash safety timer here for chips without AS2C support (like the AAT1270). However, the driver unconditionally populates the fled_cdev->timeout bounds for all chips in aat1290_init_flash_timeout():
drivers/leds/flash/leds-aat1290.c:aat1290_init_flash_timeout() {
...
/* Init flash timeout setting */
setting = &fled_cdev->timeout;
setting->min = cfg->max_flash_tm / AAT1290_FLASH_TM_NUM_LEVELS;
setting->max = cfg->max_flash_tm;
setting->step = setting->min;
setting->val = setting->max;
}As a result, the LED subsystem will expose a writable flash_timeout sysfs attribute to userspace. Userspace can configure a timeout value, believing it provides safety bounds, but the driver will silently discard it during the actual flash strobe for the AAT1270.
Could this violate the API contract and mislead userspace into overestimating thermal safety margins?
Quoted 3 lines
drivers/leds/flash/leds-aat1290.c +0
-0gpiod_direction_output (led->gpio_fl_en,1 ); }else {gpiod_direction_output (led->gpio_fl_en,0 );
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
Re: [PATCH v1 3/3] leds: aat1290: Add support for AAT1270 Current Regulator for Flash LEDs
In reply to Svyatoslav RyhelHi Svyatoslav,
Quoted 4 lines · Svyatoslav Ryhel
The AAT1270 is quite similar to the AAT1290, but it does not support the Advanced Simple Serial Control (AS2C) used in the AAT1290. The AAT1270 uses an earlier version of AS2C, namely Simple Serial Control, which lacks address-sending capabilities.
It seems that it is not possible to set brightness level and flash timeout. Those values are controlled by the values of RSET and CT elements attached to the controller. Those values should be conveyed via Device Tree, and the LED device API should reflect that accordingly.
The question is whether it is worth a hassle to add support for this older chipset version. Could you let as know on which device it is present.
Quoted 149 lines
Differentiate the chips by using a description structure with a flag to indicate if AS2C is supported, placing all AS2C-only features under a conditional check.
Signed-off-by Svyatoslav Ryhel <[email protected]>--- drivers/leds/flash/leds-aat1290.c | 66 ++++++++++++++++++++++--------- 1 file changed, 47 insertions(+), 19 deletions(-)drivers/leds/flash/leds-aat1290.c +47
-19@@ -43,9 +43,6 @@#define AAT1290_FLASH_TM_NUM_LEVELS 16#define AAT1290_MM_CURRENT_SCALE_SIZE 15 -#define AAT1290_NAME "aat1290" - -struct aat1290_led_config_data {/* maximum LED current in movie mode */ u32 max_mm_current;@@ -59,6 +56,13 @@ struct aat1290_led_config_data {enum led_brightness max_brightness; }; +struct aat1290_led_chip_info { +/* led controller name */ +const char *name; +/* Advanced Simple Serial Control support */ +bool as2c; +}; +struct aat1290_led {/* platform device data */ struct platform_device *pdev;@@ -74,6 +78,10 @@ struct aat1290_led {struct gpio_desc *gpio_fl_en;/* EN|SET pin */ struct gpio_desc *gpio_en_set; + +/* led controller description */ +const struct aat1290_led_chip_info *info; +/* movie mode current scale */ int *mm_current_scale;/* device mode */ @@ -101,15 +109,17 @@ static void aat1290_as2cwire_write(struct aat1290_led *led, int addr, int value)udelay (AAT1290_FLEN_OFF_DELAY_TIME_US ); -/* write address */ -for (i =0 ; i < addr; ++i) { -udelay (AAT1290_EN_SET_TICK_TIME_US ); -gpiod_direction_output (led->gpio_en_set,0 ); -udelay (AAT1290_EN_SET_TICK_TIME_US ); -gpiod_direction_output (led->gpio_en_set,1 ); - } +if (led->info->as2c) { +/* write address */ +for (i =0 ; i < addr; ++i) { +udelay (AAT1290_EN_SET_TICK_TIME_US ); +gpiod_direction_output (led->gpio_en_set,0 ); +udelay (AAT1290_EN_SET_TICK_TIME_US ); +gpiod_direction_output (led->gpio_en_set,1 ); + } -usleep_range (AAT1290_LATCH_TIME_MIN_US ,AAT1290_LATCH_TIME_MAX_US ); +usleep_range (AAT1290_LATCH_TIME_MIN_US ,AAT1290_LATCH_TIME_MAX_US ); + }/* write data */ for (i =0 ; i < value; ++i) {@@ -150,16 +160,18 @@ static int aat1290_led_brightness_set(struct led_classdev *led_cdev, led->movie_mode = false; }else {if (!led->movie_mode) { -aat1290_as2cwire_write (led, -AAT1290_MM_CURRENT_RATIO_ADDR , -AAT1290_MM_TO_FL_1_92 ); +if (led->info->as2c) +aat1290_as2cwire_write (led, +AAT1290_MM_CURRENT_RATIO_ADDR , +AAT1290_MM_TO_FL_1_92 ); led->movie_mode = true; }aat1290_as2cwire_write (led,AAT1290_MOVIE_MODE_CURRENT_ADDR ,AAT1290_MAX_MM_CURR_PERCENT_0 - brightness); -aat1290_as2cwire_write (led,AAT1290_MOVIE_MODE_CONFIG_ADDR , -AAT1290_MOVIE_MODE_ON ); +if (led->info->as2c) +aat1290_as2cwire_write (led,AAT1290_MOVIE_MODE_CONFIG_ADDR , +AAT1290_MOVIE_MODE_ON ); }mutex_unlock (&led->lock);@@ -178,7 +190,8 @@ static int aat1290_led_flash_strobe_set(struct led_classdev_flash *fled_cdev,mutex_lock (&led->lock);if (state) { -aat1290_set_flash_safety_timer (led, timeout->val); +if (led->info->as2c) +aat1290_set_flash_safety_timer (led, timeout->val);gpiod_direction_output (led->gpio_fl_en,1 ); }else {gpiod_direction_output (led->gpio_fl_en,0 );@@ -475,6 +488,10 @@ static int aat1290_led_probe(struct platform_device *pdev) fled_cdev->ops = &flash_ops; led_cdev = &fled_cdev->led_cdev; + led->info =device_get_match_data (dev); +if (!led->info) +return -ENODEV ; + ret =aat1290_led_get_configuration (led, &led_cfg, &sub_node);if (ret <0 )return ret;@@ -489,7 +506,7 @@ static int aat1290_led_probe(struct platform_device *pdev)aat1290_init_flash_timeout (led, &led_cfg); init_data.fwnode =of_fwnode_handle (sub_node); - init_data.devicename =AAT1290_NAME ; + init_data.devicename = led->info->name;/* Register LED Flash class device */ ret = led_classdev_flash_register_ext(&pdev->dev, fled_cdev,@@ -528,8 +545,19 @@ static void aat1290_led_remove(struct platform_device *pdev)mutex_destroy (&led->lock); } +static const struct aat1290_led_chip_info aat1290_info = { + .name ="aat1290" , + .as2c = true, +}; + +static const struct aat1290_led_chip_info aat1270_info = { + .name ="aat1270" , + .as2c = false, +}; +static const struct of_device_id aat1290_led_dt_match[] = { - { .compatible ="skyworks,aat1290" }, + { .compatible ="skyworks,aat1290" , .data = &aat1290_info }, + { .compatible ="skyworks,aat1270" , .data = &aat1270_info }, {}, };MODULE_DEVICE_TABLE (of, aat1290_led_dt_match);
Signature · 2 lines
Best regards, Jacek Anaszewski
Re: [PATCH v1 3/3] leds: aat1290: Add support for AAT1270 Current Regulator for Flash LEDs
ср, 7 жовт. 2026 р. о 22:04 Jacek Anaszewski <[email protected]> пише:
Quoted 4 lines
Hi Svyatoslav,
On 10/7/26 10:54 AM, Svyatoslav Ryhel wrote:
Quoted 8 lines
Quoted 4 lines
The AAT1270 is quite similar to the AAT1290, but it does not support the Advanced Simple Serial Control (AS2C) used in the AAT1290. The AAT1270 uses an earlier version of AS2C, namely Simple Serial Control, which lacks address-sending capabilities.
It seems that it is not possible to set brightness level and flash timeout. Those values are controlled by the values of RSET and CT elements attached to the controller.
This is not entirely true. S2C allows setting brightness level perfectly fine, I have tested it on my LG Optimus 2X P990 (star) that has this LED flash driver. Flash timeout is fixed, that is true, but both AAT1270 and AAT1290 feature mandatory flash inhibit logic which is not implemented by this driver and can be used to set emergency flash disable.
Quoted 3 lines
Those values should be conveyed
via Device Tree, and the LED device API should reflect that accordingly.
They are calculated same way as AAT1290 does and set in the device tree. Being fixed does not mean they should be removed. Device tree describes hardware and those values are part of hw description.
Quoted 4 lines
The question is whether it is worth a hassle to add support for this older chipset version. Could you let as know on which device it is present.
LG Optimus 2X P990 (star). It is a Tegra smartphone, it is not yet supported by mainline Linux kernel, but it will be in near future. I am currently upstreaming missing parts for better support.
Quoted 155 lines
Quoted 140 lines
Differentiate the chips by using a description structure with a flag to indicate if AS2C is supported, placing all AS2C-only features under a conditional check.
Signed-off-by Svyatoslav Ryhel <[email protected]>--- drivers/leds/flash/leds-aat1290.c | 66 ++++++++++++++++++++++--------- 1 file changed, 47 insertions(+), 19 deletions(-)drivers/leds/flash/leds-aat1290.c +42
-18@@ -43,9 +43,6 @@#define AAT1290_FLASH_TM_NUM_LEVELS 16#define AAT1290_MM_CURRENT_SCALE_SIZE 15 -#define AAT1290_NAME "aat1290" - -struct aat1290_led_config_data {/* maximum LED current in movie mode */ u32 max_mm_current;@@ -59,6 +56,13 @@ struct aat1290_led_config_data {enum led_brightness max_brightness; }; +struct aat1290_led_chip_info { +/* led controller name */ +const char *name; +/* Advanced Simple Serial Control support */ +bool as2c; +}; +struct aat1290_led {/* platform device data */ struct platform_device *pdev;@@ -74,6 +78,10 @@ struct aat1290_led {struct gpio_desc *gpio_fl_en;/* EN|SET pin */ struct gpio_desc *gpio_en_set; + +/* led controller description */ +const struct aat1290_led_chip_info *info; +/* movie mode current scale */ int *mm_current_scale;/* device mode */ @@ -101,15 +109,17 @@ static void aat1290_as2cwire_write(struct aat1290_led *led, int addr, int value)udelay (AAT1290_FLEN_OFF_DELAY_TIME_US ); -/* write address */ -for (i =0 ; i < addr; ++i) { -udelay (AAT1290_EN_SET_TICK_TIME_US ); -gpiod_direction_output (led->gpio_en_set,0 ); -udelay (AAT1290_EN_SET_TICK_TIME_US ); -gpiod_direction_output (led->gpio_en_set,1 ); - } +if (led->info->as2c) { +/* write address */ +for (i =0 ; i < addr; ++i) { +udelay (AAT1290_EN_SET_TICK_TIME_US ); +gpiod_direction_output (led->gpio_en_set,0 ); +udelay (AAT1290_EN_SET_TICK_TIME_US ); +gpiod_direction_output (led->gpio_en_set,1 ); + } -usleep_range (AAT1290_LATCH_TIME_MIN_US ,AAT1290_LATCH_TIME_MAX_US ); +usleep_range (AAT1290_LATCH_TIME_MIN_US ,AAT1290_LATCH_TIME_MAX_US ); + }/* write data */ for (i =0 ; i < value; ++i) {@@ -150,16 +160,18 @@ static int aat1290_led_brightness_set(struct led_classdev *led_cdev, led->movie_mode = false; }else {if (!led->movie_mode) { -aat1290_as2cwire_write (led, -AAT1290_MM_CURRENT_RATIO_ADDR , -AAT1290_MM_TO_FL_1_92 ); +if (led->info->as2c) +aat1290_as2cwire_write (led, +AAT1290_MM_CURRENT_RATIO_ADDR , +AAT1290_MM_TO_FL_1_92 ); led->movie_mode = true; }aat1290_as2cwire_write (led,AAT1290_MOVIE_MODE_CURRENT_ADDR ,AAT1290_MAX_MM_CURR_PERCENT_0 - brightness); -aat1290_as2cwire_write (led,AAT1290_MOVIE_MODE_CONFIG_ADDR , -AAT1290_MOVIE_MODE_ON ); +if (led->info->as2c) +aat1290_as2cwire_write (led,AAT1290_MOVIE_MODE_CONFIG_ADDR , +AAT1290_MOVIE_MODE_ON ); }mutex_unlock (&led->lock);@@ -178,7 +190,8 @@ static int aat1290_led_flash_strobe_set(struct led_classdev_flash *fled_cdev,mutex_lock (&led->lock);if (state) { -aat1290_set_flash_safety_timer (led, timeout->val); +if (led->info->as2c) +aat1290_set_flash_safety_timer (led, timeout->val);gpiod_direction_output (led->gpio_fl_en,1 ); }else {gpiod_direction_output (led->gpio_fl_en,0 );@@ -475,6 +488,10 @@ static int aat1290_led_probe(struct platform_device *pdev) fled_cdev->ops = &flash_ops; led_cdev = &fled_cdev->led_cdev; + led->info =device_get_match_data (dev); +if (!led->info) +return -ENODEV ; + ret =aat1290_led_get_configuration (led, &led_cfg, &sub_node);if (ret <0 )return ret;@@ -489,7 +506,7 @@ static int aat1290_led_probe(struct platform_device *pdev)aat1290_init_flash_timeout (led, &led_cfg); init_data.fwnode =of_fwnode_handle (sub_node); - init_data.devicename =AAT1290_NAME ; + init_data.devicename = led->info->name;/* Register LED Flash class device */ ret = led_classdev_flash_register_ext(&pdev->dev, fled_cdev,@@ -528,8 +545,19 @@ static void aat1290_led_remove(struct platform_device *pdev)mutex_destroy (&led->lock); } +static const struct aat1290_led_chip_info aat1290_info = { + .name ="aat1290" , + .as2c = true, +}; + +static const struct aat1290_led_chip_info aat1270_info = { + .name ="aat1270" ,drivers/leds/flash/leds-aat1290.c static void aat1290_led_remove(struct platform_device *pdev) · line 563
Quoted 10 lines
drivers/leds/flash/leds-aat1290.c +5
-1+ .as2c = false, +}; +static const struct of_device_id aat1290_led_dt_match[] = { - { .compatible ="skyworks,aat1290" }, + { .compatible ="skyworks,aat1290" , .data = &aat1290_info }, + { .compatible ="skyworks,aat1270" , .data = &aat1270_info }, {}, };MODULE_DEVICE_TABLE (of, aat1290_led_dt_match);--
Best regards,
Jacek Anaszewski
Re: [PATCH v1 3/3] leds: aat1290: Add support for AAT1270 Current Regulator for Flash LEDs
Quoted 14 lines · Svyatoslav Ryhel
ср, 7 жовт. 2026 р. о 22:04 Jacek Anaszewski <[email protected]> пише:
Quoted 4 lines
Hi Svyatoslav,
On 10/7/26 10:54 AM, Svyatoslav Ryhel wrote:
Quoted 8 lines
Quoted 4 lines
The AAT1270 is quite similar to the AAT1290, but it does not support the Advanced Simple Serial Control (AS2C) used in the AAT1290. The AAT1270 uses an earlier version of AS2C, namely Simple Serial Control, which lacks address-sending capabilities.
It seems that it is not possible to set brightness level and flash timeout. Those values are controlled by the values of RSET and CT elements attached to the controller.
Quoted 6 lines
This is not entirely true. S2C allows setting brightness level perfectly fine, I have tested it on my LG Optimus 2X P990 (star) that has this LED flash driver. Flash timeout is fixed, that is true, but both AAT1270 and AAT1290 feature mandatory flash inhibit logic which is not implemented by this driver and can be used to set emergency flash disable.
OK, let me try to perform more thorough review, after consulting data sheet, in the coming days.
Quoted 8 lines
Quoted 3 lines
Those values should be conveyed
via Device Tree, and the LED device API should reflect that accordingly.They are calculated same way as AAT1290 does and set in the device tree. Being fixed does not mean they should be removed. Device tree describes hardware and those values are part of hw description.
Quoted 8 lines
Quoted 4 lines
The question is whether it is worth a hassle to add support for this older chipset version. Could you let as know on which device it is present.
LG Optimus 2X P990 (star). It is a Tegra smartphone, it is not yet supported by mainline Linux kernel, but it will be in near future. I am currently upstreaming missing parts for better support.
Ack.
Signature · 2 lines
Best regards, Jacek Anaszewski
Re: [PATCH v1 3/3] leds: aat1290: Add support for AAT1270 Current Regulator for Flash LEDs
In reply to Svyatoslav RyhelHi Svyatoslav,
Quoted 80 lines · Svyatoslav Ryhel
The AAT1270 is quite similar to the AAT1290, but it does not support the Advanced Simple Serial Control (AS2C) used in the AAT1290. The AAT1270 uses an earlier version of AS2C, namely Simple Serial Control, which lacks address-sending capabilities.
Differentiate the chips by using a description structure with a flag to indicate if AS2C is supported, placing all AS2C-only features under a conditional check.
Signed-off-by Svyatoslav Ryhel <[email protected]>--- drivers/leds/flash/leds-aat1290.c | 66 ++++++++++++++++++++++--------- 1 file changed, 47 insertions(+), 19 deletions(-)drivers/leds/flash/leds-aat1290.c +21
-11@@ -43,9 +43,6 @@#define AAT1290_FLASH_TM_NUM_LEVELS 16#define AAT1290_MM_CURRENT_SCALE_SIZE 15 -#define AAT1290_NAME "aat1290" - -struct aat1290_led_config_data {/* maximum LED current in movie mode */ u32 max_mm_current;@@ -59,6 +56,13 @@ struct aat1290_led_config_data {enum led_brightness max_brightness; }; +struct aat1290_led_chip_info { +/* led controller name */ +const char *name; +/* Advanced Simple Serial Control support */ +bool as2c; +}; +struct aat1290_led {/* platform device data */ struct platform_device *pdev;@@ -74,6 +78,10 @@ struct aat1290_led {struct gpio_desc *gpio_fl_en;/* EN|SET pin */ struct gpio_desc *gpio_en_set; + +/* led controller description */ +const struct aat1290_led_chip_info *info; +/* movie mode current scale */ int *mm_current_scale;/* device mode */ @@ -101,15 +109,17 @@ static void aat1290_as2cwire_write(struct aat1290_led *led, int addr, int value)udelay (AAT1290_FLEN_OFF_DELAY_TIME_US ); -/* write address */ -for (i =0 ; i < addr; ++i) { -udelay (AAT1290_EN_SET_TICK_TIME_US ); -gpiod_direction_output (led->gpio_en_set,0 ); -udelay (AAT1290_EN_SET_TICK_TIME_US ); -gpiod_direction_output (led->gpio_en_set,1 ); - } +if (led->info->as2c) { +/* write address */ +for (i =0 ; i < addr; ++i) { +udelay (AAT1290_EN_SET_TICK_TIME_US ); +gpiod_direction_output (led->gpio_en_set,0 ); +udelay (AAT1290_EN_SET_TICK_TIME_US ); +gpiod_direction_output (led->gpio_en_set,1 ); + } -usleep_range (AAT1290_LATCH_TIME_MIN_US ,AAT1290_LATCH_TIME_MAX_US ); +usleep_range (AAT1290_LATCH_TIME_MIN_US ,AAT1290_LATCH_TIME_MAX_US ); + }/* write data */ for (i =0 ; i < value; ++i) {
drivers/leds/flash/leds-aat1290.c static int aat1290_led_brightness_set(struct led_classdev *led_cdev, · line 166
Quoted 10 lines
drivers/leds/flash/leds-aat1290.c +4
-3@@ -150,16 +160,18 @@ static int aat1290_led_brightness_set(struct led_classdev *led_cdev, led->movie_mode = false; }else {if (!led->movie_mode) { -aat1290_as2cwire_write (led, -AAT1290_MM_CURRENT_RATIO_ADDR , -AAT1290_MM_TO_FL_1_92 ); +if (led->info->as2c) +aat1290_as2cwire_write (led, +AAT1290_MM_CURRENT_RATIO_ADDR , +AAT1290_MM_TO_FL_1_92 );
In AAT1270 the Maximum Movie to Flash Mode Current Ratio is constant and set to 1/7.3, whereas for AAT1290 we alter it to 1/1.92 here.
This is taken into account while calculating max_mm_current in init_mm_current_scale(), where AAT1290_MAX_MM_CURRENT definition is used, which is based on AAT1290_MM_TO_FL_RATIO (1000 / 1920).
Obviously it would have to be changed to 1000 / 7300 for AAT1270, for the calculations between brightness levels and microamperes for V4L2 Flash interface to work properly for this controller.
Quoted 14 lines
drivers/leds/flash/leds-aat1290.c +3
-2led->movie_mode = true; }aat1290_as2cwire_write (led,AAT1290_MOVIE_MODE_CURRENT_ADDR ,AAT1290_MAX_MM_CURR_PERCENT_0 - brightness); -aat1290_as2cwire_write (led,AAT1290_MOVIE_MODE_CONFIG_ADDR , -AAT1290_MOVIE_MODE_ON ); +if (led->info->as2c) +aat1290_as2cwire_write (led,AAT1290_MOVIE_MODE_CONFIG_ADDR , +AAT1290_MOVIE_MODE_ON ); }mutex_unlock (&led->lock);
drivers/leds/flash/leds-aat1290.c static int aat1290_led_flash_strobe_set(struct led_classdev_flash *fled_cdev, · line 194
Quoted 6 lines
drivers/leds/flash/leds-aat1290.c +2
-1@@ -178,7 +190,8 @@ static int aat1290_led_flash_strobe_set(struct led_classdev_flash *fled_cdev,mutex_lock (&led->lock);if (state) { -aat1290_set_flash_safety_timer (led, timeout->val); +if (led->info->as2c) +aat1290_set_flash_safety_timer (led, timeout->val);
AAT1290 has the capability of setting flash safety timer timeout, not like AAT1270, for which this is controlled solely by the discrete elements, basing on the formula T = 21.5s/µF · CT. This needs to be reflected both in the DT bindings and in the aat1290_init_flash_timeout(), where the minimum value should be also fixed for AAT1270.
Quoted 44 lines
drivers/leds/flash/leds-aat1290.c +17
-2gpiod_direction_output (led->gpio_fl_en,1 ); }else {gpiod_direction_output (led->gpio_fl_en,0 );@@ -475,6 +488,10 @@ static int aat1290_led_probe(struct platform_device *pdev) fled_cdev->ops = &flash_ops; led_cdev = &fled_cdev->led_cdev; + led->info =device_get_match_data (dev); +if (!led->info) +return -ENODEV ; + ret =aat1290_led_get_configuration (led, &led_cfg, &sub_node);if (ret <0 )return ret;@@ -489,7 +506,7 @@ static int aat1290_led_probe(struct platform_device *pdev)aat1290_init_flash_timeout (led, &led_cfg); init_data.fwnode =of_fwnode_handle (sub_node); - init_data.devicename =AAT1290_NAME ; + init_data.devicename = led->info->name;/* Register LED Flash class device */ ret = led_classdev_flash_register_ext(&pdev->dev, fled_cdev,@@ -528,8 +545,19 @@ static void aat1290_led_remove(struct platform_device *pdev)mutex_destroy (&led->lock); } +static const struct aat1290_led_chip_info aat1290_info = { + .name ="aat1290" , + .as2c = true, +}; + +static const struct aat1290_led_chip_info aat1270_info = { + .name ="aat1270" , + .as2c = false, +}; +static const struct of_device_id aat1290_led_dt_match[] = { - { .compatible ="skyworks,aat1290" }, + { .compatible ="skyworks,aat1290" , .data = &aat1290_info }, + { .compatible ="skyworks,aat1270" , .data = &aat1270_info }, {}, };MODULE_DEVICE_TABLE (of, aat1290_led_dt_match);
Signature · 2 lines
Best regards, Jacek Anaszewski
Re: [PATCH v1 3/3] leds: aat1290: Add support for AAT1270 Current Regulator for Flash LEDs
нд, 11 жовт. 2026 р. о 16:26 Jacek Anaszewski <[email protected]> пише:
Quoted 122 lines
Hi Svyatoslav,
Quoted 80 lines · Svyatoslav Ryhel
The AAT1270 is quite similar to the AAT1290, but it does not support the Advanced Simple Serial Control (AS2C) used in the AAT1290. The AAT1270 uses an earlier version of AS2C, namely Simple Serial Control, which lacks address-sending capabilities.
Differentiate the chips by using a description structure with a flag to indicate if AS2C is supported, placing all AS2C-only features under a conditional check.
Signed-off-by Svyatoslav Ryhel <[email protected]>--- drivers/leds/flash/leds-aat1290.c | 66 ++++++++++++++++++++++--------- 1 file changed, 47 insertions(+), 19 deletions(-)drivers/leds/flash/leds-aat1290.c +21
-11@@ -43,9 +43,6 @@#define AAT1290_FLASH_TM_NUM_LEVELS 16#define AAT1290_MM_CURRENT_SCALE_SIZE 15 -#define AAT1290_NAME "aat1290" - -struct aat1290_led_config_data {/* maximum LED current in movie mode */ u32 max_mm_current;@@ -59,6 +56,13 @@ struct aat1290_led_config_data {enum led_brightness max_brightness; }; +struct aat1290_led_chip_info { +/* led controller name */ +const char *name; +/* Advanced Simple Serial Control support */ +bool as2c; +}; +struct aat1290_led {/* platform device data */ struct platform_device *pdev;@@ -74,6 +78,10 @@ struct aat1290_led {struct gpio_desc *gpio_fl_en;/* EN|SET pin */ struct gpio_desc *gpio_en_set; + +/* led controller description */ +const struct aat1290_led_chip_info *info; +/* movie mode current scale */ int *mm_current_scale;/* device mode */ @@ -101,15 +109,17 @@ static void aat1290_as2cwire_write(struct aat1290_led *led, int addr, int value)udelay (AAT1290_FLEN_OFF_DELAY_TIME_US ); -/* write address */ -for (i =0 ; i < addr; ++i) { -udelay (AAT1290_EN_SET_TICK_TIME_US ); -gpiod_direction_output (led->gpio_en_set,0 ); -udelay (AAT1290_EN_SET_TICK_TIME_US ); -gpiod_direction_output (led->gpio_en_set,1 ); - } +if (led->info->as2c) { +/* write address */ +for (i =0 ; i < addr; ++i) { +udelay (AAT1290_EN_SET_TICK_TIME_US ); +gpiod_direction_output (led->gpio_en_set,0 ); +udelay (AAT1290_EN_SET_TICK_TIME_US ); +gpiod_direction_output (led->gpio_en_set,1 ); + } -usleep_range (AAT1290_LATCH_TIME_MIN_US ,AAT1290_LATCH_TIME_MAX_US ); +usleep_range (AAT1290_LATCH_TIME_MIN_US ,AAT1290_LATCH_TIME_MAX_US ); + }/* write data */ for (i =0 ; i < value; ++i) {drivers/leds/flash/leds-aat1290.c static int aat1290_led_brightness_set(struct led_classdev *led_cdev, · line 166
Quoted 10 lines
drivers/leds/flash/leds-aat1290.c +4
-3@@ -150,16 +160,18 @@ static int aat1290_led_brightness_set(struct led_classdev *led_cdev, led->movie_mode = false; }else {if (!led->movie_mode) { -aat1290_as2cwire_write (led, -AAT1290_MM_CURRENT_RATIO_ADDR , -AAT1290_MM_TO_FL_1_92 ); +if (led->info->as2c) +aat1290_as2cwire_write (led, +AAT1290_MM_CURRENT_RATIO_ADDR , +AAT1290_MM_TO_FL_1_92 );In AAT1270 the Maximum Movie to Flash Mode Current Ratio is constant and set to 1/7.3, whereas for AAT1290 we alter it to 1/1.92 here.
This is taken into account while calculating
max_mm_currentininit_mm_current_scale(), whereAAT1290_MAX_MM_CURRENTdefinition is used, which is based onAAT1290_MM_TO_FL_RATIO(1000 / 1920).Obviously it would have to be changed to 1000 / 7300 for AAT1270, for the calculations between brightness levels and microamperes for V4L2 Flash interface to work properly for this controller.
Quoted 16 lines
drivers/leds/flash/leds-aat1290.c +3
-2led->movie_mode = true; }aat1290_as2cwire_write (led,AAT1290_MOVIE_MODE_CURRENT_ADDR ,AAT1290_MAX_MM_CURR_PERCENT_0 - brightness); -aat1290_as2cwire_write (led,AAT1290_MOVIE_MODE_CONFIG_ADDR , -AAT1290_MOVIE_MODE_ON ); +if (led->info->as2c) +aat1290_as2cwire_write (led,AAT1290_MOVIE_MODE_CONFIG_ADDR , +AAT1290_MOVIE_MODE_ON ); }mutex_unlock (&led->lock);@@ -178,7 +190,8 @@ static int aat1290_led_flash_strobe_set(struct led_classdev_flash *fled_cdev,mutex_lock (&led->lock);
Quoted 12 lines
drivers/leds/flash/leds-aat1290.c static int aat1290_led_flash_strobe_set(struct led_classdev_flash *fled_cdev, · line 194
Quoted 4 lines
drivers/leds/flash/leds-aat1290.c +2
-1if (state) { -aat1290_set_flash_safety_timer (led, timeout->val); +if (led->info->as2c) +aat1290_set_flash_safety_timer (led, timeout->val);AAT1290 has the capability of setting flash safety timer timeout, not like AAT1270, for which this is controlled solely by the discrete elements, basing on the formula T = 21.5s/µF · CT. This needs to be reflected both in the DT bindings and in the
aat1290_init_flash_timeout(), where the minimum value should be also fixed for AAT1270.
Thank you for both explanations. I will take then into account while submitting v2.
Quoted 50 lines
Quoted 35 lines
drivers/leds/flash/leds-aat1290.c +12
-1gpiod_direction_output (led->gpio_fl_en,1 ); }else {gpiod_direction_output (led->gpio_fl_en,0 );@@ -475,6 +488,10 @@ static int aat1290_led_probe(struct platform_device *pdev) fled_cdev->ops = &flash_ops; led_cdev = &fled_cdev->led_cdev; + led->info =device_get_match_data (dev); +if (!led->info) +return -ENODEV ; + ret =aat1290_led_get_configuration (led, &led_cfg, &sub_node);if (ret <0 )return ret;@@ -489,7 +506,7 @@ static int aat1290_led_probe(struct platform_device *pdev)aat1290_init_flash_timeout (led, &led_cfg); init_data.fwnode =of_fwnode_handle (sub_node); - init_data.devicename =AAT1290_NAME ; + init_data.devicename = led->info->name;/* Register LED Flash class device */ ret = led_classdev_flash_register_ext(&pdev->dev, fled_cdev,@@ -528,8 +545,19 @@ static void aat1290_led_remove(struct platform_device *pdev)mutex_destroy (&led->lock); } +static const struct aat1290_led_chip_info aat1290_info = { + .name ="aat1290" , + .as2c = true, +}; + +static const struct aat1290_led_chip_info aat1270_info = { + .name ="aat1270" ,drivers/leds/flash/leds-aat1290.c static void aat1290_led_remove(struct platform_device *pdev) · line 563
Quoted 10 lines
drivers/leds/flash/leds-aat1290.c +5
-1+ .as2c = false, +}; +static const struct of_device_id aat1290_led_dt_match[] = { - { .compatible ="skyworks,aat1290" }, + { .compatible ="skyworks,aat1290" , .data = &aat1290_info }, + { .compatible ="skyworks,aat1270" , .data = &aat1270_info }, {}, };MODULE_DEVICE_TABLE (of, aat1290_led_dt_match);--
Best regards,
Jacek Anaszewski