Skip to contentSkip to conversation

backlight: Add Awinic AW99703 driver

PATCH In review Luka Panio 4 participants 11 messages Oct 16 – Oct 19

Subsystems (4)
lore
Share & tools
lore

Luka Panio

author
#0 lore raw

cover backlight: Add Awinic AW99703 driver

The Awinic AW99703 is a high-efficiency 3-channel WLED driver with an integrated boost converter and 11-bit brightness control over I2C, optionally combined with a PWM input. It is used as an LCD backlight driver in some mobile devices.

This series adds the devicetree binding and a driver for it.

Tested on the Nexphone by Nex Computers.

A board DTS using it will follow separately.

Luka Panio (2):
dt-bindings: leds: backlight: Add Awinic AW99703 backlight
backlight: Add Awinic AW99703 backlight driver

 .../leds/backlight/awinic,aw99703.yaml        | 131 ++++
 MAINTAINERS                                   |   6 +
 drivers/video/backlight/Kconfig               |  11 +
 drivers/video/backlight/Makefile              |   1 +
 drivers/video/backlight/aw99703.c             | 583 ++++++++++++++++++
 5 files changed, 732 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/backlight/awinic,aw99703.yaml
 create mode 100644 drivers/video/backlight/aw99703.c

base-commit: d419d682257d813f6cb7a28e42b35d0edf4ad038

Signature · 1 line
2.55.0
author
#1 lore raw

PATCH 1/2 dt-bindings: leds: backlight: Add Awinic AW99703 backlight

The Awinic AW99703 is a 3-string WLED driver converter with an integrated boost converter and 11-bit brightness control over I2C, optionally combined with a PWM input.

---
 .../leds/backlight/awinic,aw99703.yaml        | 131 ++++++++++++++++++
 1 file changed, 131 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/backlight/awinic,aw99703.yaml
Documentation/devicetree/bindings/leds/backlight/awinic,aw99703.yaml new file +131 -0
new file mode 100644
index 000000000000..62e8cc3118f2
@@ -0,0 +1,131 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/leds/backlight/awinic,aw99703.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Awinic AW99703 WLED Backlight Driver
+
+maintainers:
+  - Luka Panio <[email protected]>
+
+description:
+  The AW99703 is a 3-string WLED driver with an integrated boost converter
+  and 11-bit I2C (optionally PWM) brightness control.
+
+allOf:
+  - $ref: common.yaml#
+
+properties:
+  compatible:
+    const: awinic,aw99703
+
+  reg:
+    maxItems: 1
+
+  enable-gpios:
+    description: GPIO connected to the HWEN pin.
+    maxItems: 1
+
+  awinic,led-strings:
+    description: Number of enabled LED strings, starting with CH1.
+    $ref: /schemas/types.yaml#/definitions/uint32
+    minimum: 1
+    maximum: 3
+    default: 3
+
+  awinic,iled-max-microamp:
+    description:
+      Full-scale current of each LED string, reached at the maximum
+      brightness code (and 100% PWM duty cycle if PWM dimming is used).
+    minimum: 4800
+    maximum: 29600
+    multipleOf: 800
+    default: 20000
+
+  awinic,ramp-on-time-us:
+    description: Current sink ramp-up time when leaving standby.
+    enum: [512, 1000, 2000, 4000, 8000, 16000, 32000, 64000, 128000,
+           256000, 512000, 1024000, 2048000, 4096000, 8192000, 16384000]
+    default: 8000
+
+  awinic,ramp-off-time-us:
+    description: Current sink ramp-down time when entering standby.
+    enum: [512, 1000, 2000, 4000, 8000, 16000, 32000, 64000, 128000,
+           256000, 512000, 1024000, 2048000, 4096000, 8192000, 16384000]
+    default: 8000
+
+  awinic,pwm-trans-time-ms:
+    description:
+      Transition time between brightness levels set by the PWM input,
+      for a change over the full duty cycle range.
+    enum: [2, 4, 8, 16, 32, 64, 128, 256]
+    default: 2
+
+  awinic,i2c-trans-time-ms:
+    description:
+      Fixed transition time between brightness levels set over I2C,
+      independent of the size of the change. When absent the brightness
+      ramps with a fixed slope of 1 us per brightness code instead.
+    enum: [128, 192, 256, 320, 384, 448, 512, 576, 640, 768, 1024, 1280,
+           1536, 2560, 4096]
+
+  awinic,ovp-microvolt:
+    description: Boost over-voltage protection threshold.
+    enum: [17500000, 24000000, 31000000, 38000000, 41500000]
+    default: 38000000
+
+  awinic,ocp-microamp:
+    description: Boost over-current protection threshold.
+    enum: [900000, 1800000, 2700000, 3400000]
+    default: 2700000
+
+  awinic,sw-freq-hz:
+    description: Boost switching frequency.
+    enum: [500000, 1000000]
+    default: 1000000
+
+  awinic,inductor-nanohenry:
+    description: Boost inductor value.
+    $ref: /schemas/types.yaml#/definitions/uint32
+    enum: [4700, 10000]
+    default: 4700
+
+  awinic,pwm-input:
+    description: Combine the PWM input pin with the I2C brightness.
+    type: boolean
+
+  awinic,exponential-map:
+    description: Use the exponential brightness curve instead of linear.
+    type: boolean
+
+  default-brightness:
+    maximum: 2047
+
+  max-brightness:
+    maximum: 2047
+
+required:
+  - compatible
+  - reg
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        backlight@36 {
+            compatible = "awinic,aw99703";
+            reg = <0x36>;
+            enable-gpios = <&gpio 7 GPIO_ACTIVE_HIGH>;
+            awinic,led-strings = <2>;
+            awinic,iled-max-microamp = <20000>;
+            awinic,ocp-microamp = <3400000>;
+            awinic,inductor-nanohenry = <10000>;
+        };
+    };
Signature · 1 line
2.55.0
#2 lore raw

Re: [PATCH 1/2] dt-bindings: leds: backlight: Add Awinic AW99703 backlight

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Medium] dt-bindings: missing 'pwms' property for PWM input - [Low] dt-bindings: missing power supply…

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] dt-bindings: missing 'pwms' property for PWM input
- [Low] dt-bindings: missing power supply property
--

commit bdcbdabe3e1453e58fc8f39fabc82b20db81480c
Author: Luka Panio <[email protected]>

dt-bindings: leds: backlight: Add Awinic AW99703 backlight

The Awinic AW99703 is a 3-string WLED driver converter with an integrated boost converter and 11-bit brightness control over I2C, optionally combined with a PWM input.

Quoted 17 lines
Documentation/devicetree/bindings/leds/backlight/awinic,aw99703.yaml new file +11 -0
new file mode 100644
index 0000000000000..62e8cc3118f2e
@@ -0,0 +1,131 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/leds/backlight/awinic,aw99703.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Awinic AW99703 WLED Backlight Driver
+
+maintainers:
+  - Luka Panio <[email protected]>
+

Documentation/devicetree/bindings/leds/backlight/awinic,aw99703.yaml line 21

Quoted 10 lines
Documentation/devicetree/bindings/leds/backlight/awinic,aw99703.yaml new file +10 -0
+description:
+  The AW99703 is a 3-string WLED driver with an integrated boost converter
+  and 11-bit I2C (optionally PWM) brightness control.
+
+allOf:
+  - $ref: common.yaml#
+
+properties:
+  compatible:
+    const: awinic,aw99703

[Severity: Low]
Is a power supply property needed for the boost converter?

The hardware has an integrated boost converter, which typically requires a supply such as 'vin-supply' or 'vcc-supply'. Because the schema enforces 'unevaluatedProperties: false', boards with a controllable regulator powering the backlight will fail schema validation if they attempt to define it.

[ ... ]

Documentation/devicetree/bindings/leds/backlight/awinic,aw99703.yaml line 96

Quoted 9 lines
Documentation/devicetree/bindings/leds/backlight/awinic,aw99703.yaml new file +9 -0
+  awinic,inductor-nanohenry:
+    description: Boost inductor value.
+    $ref: /schemas/types.yaml#/definitions/uint32
+    enum: [4700, 10000]
+    default: 4700
+
+  awinic,pwm-input:
+    description: Combine the PWM input pin with the I2C brightness.
+    type: boolean

[Severity: Medium]
Should the standard 'pwms' property be defined alongside this property?

The schema defines 'awinic,pwm-input' to indicate the hardware uses a PWM input pin, but it doesn't define the standard 'pwms' property. Since this schema uses 'unevaluatedProperties: false', board device trees attempting to properly link a PWM controller using 'pwms = <&pwm ...>;' will fail schema validation.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#3 lore raw

Re: [PATCH 1/2] dt-bindings: leds: backlight: Add Awinic AW99703 backlight

In reply to Luka Panio
Quoted 17 lines · Luka Panio
Documentation/devicetree/bindings/leds/backlight/awinic,aw99703.yaml new file +17 -0
+  awinic,iled-max-microamp:
+    description:
+      Full-scale current of each LED string, reached at the maximum
+      brightness code (and 100% PWM duty cycle if PWM dimming is used).
+    minimum: 4800
+    maximum: 29600
+    multipleOf: 800
+    default: 20000
+
+  awinic,ramp-on-time-us:
+    description: Current sink ramp-up time when leaving standby.
+    enum: [512, 1000, 2000, 4000, 8000, 16000, 32000, 64000, 128000,
+           256000, 512000, 1024000, 2048000, 4096000, 8192000, 16384000]
+    default: 8000
+
+  awinic,ramp-off-time-us:
+    description: Current sink ramp-down time when entering standby.

Documentation/devicetree/bindings/leds/backlight/awinic,aw99703.yaml line 63

Quoted 10 lines
Documentation/devicetree/bindings/leds/backlight/awinic,aw99703.yaml new file +10 -0
+    enum: [512, 1000, 2000, 4000, 8000, 16000, 32000, 64000, 128000,
+           256000, 512000, 1024000, 2048000, 4096000, 8192000, 16384000]
+    default: 8000
+
+  awinic,pwm-trans-time-ms:
+    description:
+      Transition time between brightness levels set by the PWM input,
+      for a change over the full duty cycle range.
+    enum: [2, 4, 8, 16, 32, 64, 128, 256]
+    default: 2

Feels like you are re-implementing triggers. Several properties actually feel duplicating standard LED ones.

Documentation/devicetree/bindings/leds/backlight/awinic,aw99703.yaml line 71

Quoted 8 lines
Documentation/devicetree/bindings/leds/backlight/awinic,aw99703.yaml new file +8 -0
+
+  awinic,i2c-trans-time-ms:
+    description:
+      Fixed transition time between brightness levels set over I2C,
+      independent of the size of the change. When absent the brightness
+      ramps with a fixed slope of 1 us per brightness code instead.
+    enum: [128, 192, 256, 320, 384, 448, 512, 576, 640, 768, 1024, 1280,
+           1536, 2560, 4096]

Best regards,
Krzysztof

author
#4 lore raw

Re: [PATCH 1/2] dt-bindings: leds: backlight: Add Awinic AW99703 backlight

Hi Krzysztof,

Quoted 24 lines · Krzysztof Kozlowski
Quoted 22 lines · Luka Panio
Documentation/devicetree/bindings/leds/backlight/awinic,aw99703.yaml new file +22 -0
+  awinic,iled-max-microamp:
+    description:
+      Full-scale current of each LED string, reached at the maximum
+      brightness code (and 100% PWM duty cycle if PWM dimming is used).
+    minimum: 4800
+    maximum: 29600
+    multipleOf: 800
+    default: 20000
+
+  awinic,ramp-on-time-us:
+    description: Current sink ramp-up time when leaving standby.
+    enum: [512, 1000, 2000, 4000, 8000, 16000, 32000, 64000, 128000,
+           256000, 512000, 1024000, 2048000, 4096000, 8192000, 16384000]
+    default: 8000
+
+  awinic,ramp-off-time-us:
+    description: Current sink ramp-down time when entering standby.
+    enum: [512, 1000, 2000, 4000, 8000, 16000, 32000, 64000, 128000,
+           256000, 512000, 1024000, 2048000, 4096000, 8192000, 16384000]
+    default: 8000
+
+  awinic,pwm-trans-time-ms:
Quoted 9 lines

Documentation/devicetree/bindings/leds/backlight/awinic,aw99703.yaml line 63

Quoted 5 lines
Documentation/devicetree/bindings/leds/backlight/awinic,aw99703.yaml new file +5 -0
+    description:
+      Transition time between brightness levels set by the PWM input,
+      for a change over the full duty cycle range.
+    enum: [2, 4, 8, 16, 32, 64, 128, 256]
+    default: 2

Feels like you are re-implementing triggers. Several properties actually feel duplicating standard LED ones.

Thanks for the review. Agreed, the ramp/transition timings and the mapping mode are not really hardware descriptions. In v2 I'll drop them and leave the chip defaults, and switch to the standard led-sources and led-max-microamp properties instead of awinic,led-strings and awinic,iled-max-microamp.

Quoted 9 lines

Documentation/devicetree/bindings/leds/backlight/awinic,aw99703.yaml line 71

Quoted 8 lines
Documentation/devicetree/bindings/leds/backlight/awinic,aw99703.yaml new file +8 -0
+
+  awinic,i2c-trans-time-ms:
+    description:
+      Fixed transition time between brightness levels set over I2C,
+      independent of the size of the change. When absent the brightness
+      ramps with a fixed slope of 1 us per brightness code instead.
+    enum: [128, 192, 256, 320, 384, 448, 512, 576, 640, 768, 1024, 1280,
+           1536, 2560, 4096]
Quoted 3 lines

Best regards,
Krzysztof

Thanks,
Luka

author
#5 lore raw

PATCH 2/2 backlight: Add Awinic AW99703 backlight driver

In reply to Luka Panio

Add a driver for the Awinic AW99703 3-string WLED backlight controller.

Register values follow the AW99703 datasheet (V1.6), the structure follows the aw99706 driver.

---
 MAINTAINERS                       |   6 +
 drivers/video/backlight/Kconfig   |  11 +
 drivers/video/backlight/Makefile  |   1 +
 drivers/video/backlight/aw99703.c | 583 ++++++++++++++++++++++++++++++
 4 files changed, 601 insertions(+)
 create mode 100644 drivers/video/backlight/aw99703.c
MAINTAINERS +6 -0
index 461a56850c84..e4168448e95c 100644
@@ -4525,6 +4525,12 @@ L:	[email protected]
 S:	Maintained
 F:	sound/hda/codecs/side-codecs/aw88399*
 
+AWINIC AW99703 WLED BACKLIGHT DRIVER
+M:	Luka Panio <[email protected]>
+S:	Maintained
+F:	Documentation/devicetree/bindings/leds/backlight/awinic,aw99703.yaml
+F:	drivers/video/backlight/aw99703.c
+
 AWINIC AW99706 WLED BACKLIGHT DRIVER
 M:	Junjie Cao <[email protected]>
 S:	Maintained
drivers/video/backlight/Kconfig +11 -0
index dbf4ca23a9b6..c2494f7fa5d2 100644
@@ -156,6 +156,17 @@ config BACKLIGHT_ATMEL_LCDC
 	  If in doubt, it's safe to enable this option; it doesn't kick
 	  in unless the board's description says it's wired that way.
 
+config BACKLIGHT_AW99703
+	tristate "Backlight Driver for Awinic AW99703"
+	depends on I2C
+	select REGMAP_I2C
+	help
+	  If you have a LCD backlight connected to the WLED outputs of an
+	  Awinic AW99703, say Y here to enable this driver.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called aw99703.
+
 config BACKLIGHT_AW99706
 	tristate "Backlight Driver for Awinic AW99706"
 	depends on I2C
drivers/video/backlight/Makefile +1 -0
index 34469711c6cd..09ec9bd71c92 100644
@@ -25,6 +25,7 @@ obj-$(CONFIG_BACKLIGHT_ADP8870)		+= adp8870_bl.o
 obj-$(CONFIG_BACKLIGHT_APPLE)		+= apple_bl.o
 obj-$(CONFIG_BACKLIGHT_APPLE_DWI)	+= apple_dwi_bl.o
 obj-$(CONFIG_BACKLIGHT_AS3711)		+= as3711_bl.o
+obj-$(CONFIG_BACKLIGHT_AW99703)		+= aw99703.o
 obj-$(CONFIG_BACKLIGHT_AW99706)		+= aw99706.o
 obj-$(CONFIG_BACKLIGHT_BD6107)		+= bd6107.o
 obj-$(CONFIG_BACKLIGHT_CGBC)		+= cgbc_bl.o
drivers/video/backlight/aw99703.c new file +583 -0

583 lines not on this page · raw message

Signature · 1 line
2.55.0
#6 lore raw

Re: [PATCH 2/2] backlight: Add Awinic AW99703 backlight driver

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider: - [High] build: Incompatible pointer type passed to device_property_read_u32() - [Medium] gpio: Hardware…

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] build: Incompatible pointer type passed to device_property_read_u32()
- [Medium] gpio: Hardware left powered on upon early probe failure
- [Low] backlight: TOCTOU race in aw99703_shutdown() missing update_lock
--

commit b010e2c6526192785d6b65bcadf761f3928c7acd
Author: Luka Panio <[email protected]>

backlight: Add Awinic AW99703 backlight driver

Add a driver for the Awinic AW99703 3-string WLED backlight controller.

Quoted 5 lines
drivers/video/backlight/aw99703.c new file +0 -0
new file mode 100644
index 0000000000000..b0a46753d1765

[ ... ]

Quoted 3 lines
drivers/video/backlight/aw99703.c new file +3 -0
+static void aw99703_dt_parse(struct aw99703_device *aw,
+			     struct backlight_properties *props)
+{

[ ... ]

drivers/video/backlight/aw99703.c line 314

Quoted 3 lines
drivers/video/backlight/aw99703.c new file +3 -0
+	props->max_brightness = AW99703_MAX_BRT_LVL;
+	device_property_read_u32(aw->dev, "max-brightness",
+				 &props->max_brightness);

[Severity: High]
Does this code trigger a -Wincompatible-pointer-types build failure?

device_property_read_u32() expects a u32 * as its third argument, but &props->max_brightness is a pointer to int. In recent kernel builds, this warning is promoted to a fatal error.

drivers/video/backlight/aw99703.c line 320

Quoted 6 lines
drivers/video/backlight/aw99703.c new file +6 -0
+	if (props->max_brightness > AW99703_MAX_BRT_LVL)
+		props->max_brightness = AW99703_MAX_BRT_LVL;
+
+	props->brightness = props->max_brightness >> 1;
+	device_property_read_u32(aw->dev, "default-brightness",
+				 &props->brightness);

[Severity: High]
Similarly, &props->brightness is also a pointer to int.

[ ... ]

Quoted 10 lines
drivers/video/backlight/aw99703.c new file +10 -0
+static void aw99703_power_off(void *data)
+{
+	struct aw99703_device *aw = data;
+
+	aw99703_update_brightness(aw, 0);
+	gpiod_set_value_cansleep(aw->hwen_gpio, 0);
+}
+
+static int aw99703_probe(struct i2c_client *client)
+{

[ ... ]

drivers/video/backlight/aw99703.c line 506

Quoted 11 lines
drivers/video/backlight/aw99703.c new file +11 -0
+	if (aw->hwen_gpio) {
+		ret = gpiod_direction_output(aw->hwen_gpio, 1);
+		if (ret)
+			return dev_err_probe(dev, ret,
+					     "failed to drive enable gpio\n");
+		fsleep(AW99703_HWEN_ON_DELAY_US);
+	}
+
+	ret = aw99703_chip_id_read(aw);
+	if (ret)
+		return dev_err_probe(dev, ret, "chip id check failed\n");

[Severity: Medium]
If the chip ID read fails, does this return without de-asserting the GPIO?

The probe function sets the hwen_gpio output to 1 to power on the chip, but if aw99703_chip_id_read() or aw99703_hw_init() fail, it returns an error code immediately. Since the devm_add_action_or_reset() for aw99703_power_off is registered later in the function, the cleanup action won't execute on early probe failure, leaving the hardware permanently enabled.

Quoted 10 lines
drivers/video/backlight/aw99703.c new file +10 -0
+
+	props.type = BACKLIGHT_RAW;
+	aw99703_dt_parse(aw, &props);
+	aw99703_read_boot_brightness(aw, &props);
+
+	ret = aw99703_hw_init(aw);
+	if (ret)
+		return dev_err_probe(dev, ret, "failed to initialize chip\n");
+
+	ret = devm_add_action_or_reset(dev, aw99703_power_off, aw);

[ ... ]

drivers/video/backlight/aw99703.c line 533

Quoted 4 lines
drivers/video/backlight/aw99703.c new file +4 -0
+static void aw99703_shutdown(struct i2c_client *client)
+{
+	aw99703_power_off(i2c_get_clientdata(client));
+}

[Severity: Low]
Is there a data race between this shutdown callback and concurrent sysfs writes to the brightness attribute?

aw99703_shutdown() invokes aw99703_power_off(), which modifies the aw->bl_enable flag and writes to I2C registers via aw99703_update_brightness() without acquiring the backlight bd->update_lock mutex. Since userspace tasks are not frozen during system shutdown, a concurrent sysfs operation could attempt to communicate with the chip while its registers are being written or after the power pin is de-asserted.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
#7 lore raw

Re: [PATCH 2/2] backlight: Add Awinic AW99703 backlight driver

In reply to Luka Panio
Quoted 4 lines · Luka Panio

Add a driver for the Awinic AW99703 3-string WLED backlight controller.

Register values follow the AW99703 datasheet (V1.6), the structure follows the aw99706 driver.

Given how much the structure follows the aw99706 driver I'd expect there to be more code sharing between the drivers.

Cold AW99703 support be implemented by extending the existing aw99706 driver?

Daniel.

author
#8 lore raw

Re: [PATCH 2/2] backlight: Add Awinic AW99703 backlight driver

Hi Daniel,

Quoted 4 lines · Daniel Thompson
Quoted 2 lines · Luka Panio

Add a driver for the Awinic AW99703 3-string WLED backlight controller.

Quoted 8 lines
Quoted 2 lines

Register values follow the AW99703 datasheet (V1.6), the structure follows the aw99706 driver.

Given how much the structure follows the aw99706 driver I'd expect there to be more code sharing between the drivers.

Cold AW99703 support be implemented by extending the existing aw99706 driver?

Thanks for the review. The register maps differ completely (chip ID, brightness split, enable bit, current range, boost options), but the driver flow is the same, so I'll turn aw99706 into a per-chip-data driver and add AW99703 support to it in v2.

Quoted 3 lines

Daniel.

Thanks,
Luka

author
#9 lore raw
In reply to Luka Panio

Hi Daniel, Krzysztof,

Thanks for the reviews. Before reworking this for v2 I'd like to agree on the approach.

Following Daniel's suggestion I'll add AW99703 support to the aw99706 driver using per-chip data instead of adding a new driver. The register maps differ almost entirely, so most of the DT properties stay per-chip (dim-mode/UVLO/ramp-ctl on AW99706, OVP/OCP/inductor on AW99703).

Following Krzysztof's review, the AW99703 binding will drop the ramp/transition timing and mapping properties and use the standard led-sources and led-max-microamp properties.

That leaves the one common property, the maximum LED current, spelled differently in a single driver: awinic,iled-max-microamp for AW99706 and led-max-microamp for AW99703. To avoid that I'd like to:

- add led-max-microamp to awinic,aw99706.yaml and mark awinic,iled-max-microamp as deprecated
- have the driver read led-max-microamp for both chips, falling back to awinic,iled-max-microamp on AW99706 so existing DTs keep working

Does that sound acceptable?

Thanks,
Luka

Quoted 30 lines · Luka Panio

The Awinic AW99703 is a high-efficiency 3-channel WLED driver with an integrated boost converter and 11-bit brightness control over I2C, optionally combined with a PWM input. It is used as an LCD backlight driver in some mobile devices.

This series adds the devicetree binding and a driver for it.

Tested on the Nexphone by Nex Computers.

A board DTS using it will follow separately.

Luka Panio (2):
dt-bindings: leds: backlight: Add Awinic AW99703 backlight
backlight: Add Awinic AW99703 backlight driver

 .../leds/backlight/awinic,aw99703.yaml        | 131 ++++
 MAINTAINERS                                   |   6 +
 drivers/video/backlight/Kconfig               |  11 +
 drivers/video/backlight/Makefile              |   1 +
 drivers/video/backlight/aw99703.c             | 583 ++++++++++++++++++
 5 files changed, 732 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/backlight/awinic,aw99703.yaml
 create mode 100644 drivers/video/backlight/aw99703.c

base-commit: d419d682257d813f6cb7a28e42b35d0edf4ad038 --
2.55.0

#10 lore raw
Quoted 19 lines · Luka Panio

Hi Daniel, Krzysztof,

Thanks for the reviews. Before reworking this for v2 I'd like to agree on the approach.

Following Daniel's suggestion I'll add AW99703 support to the aw99706 driver using per-chip data instead of adding a new driver. The register maps differ almost entirely, so most of the DT properties stay per-chip (dim-mode/UVLO/ramp-ctl on AW99706, OVP/OCP/inductor on AW99703).

Following Krzysztof's review, the AW99703 binding will drop the ramp/transition timing and mapping properties and use the standard led-sources and led-max-microamp properties.

That leaves the one common property, the maximum LED current, spelled differently in a single driver: awinic,iled-max-microamp for AW99706 and led-max-microamp for AW99703. To avoid that I'd like to:

Quoted 6 lines

- add led-max-microamp to awinic,aw99706.yaml and mark awinic,iled-max-microamp as deprecated
- have the driver read led-max-microamp for both chips, falling back to awinic,iled-max-microamp on AW99706 so existing DTs keep working

Does that sound acceptable?

IIUC you plan to improve the binding for AW99706 before adding AW99703 support, and you will keep the old DT property working to that existing DTBs continue to work?

Both sound good to me.

Daniel.