* [PATCH v2 0/6] backlight: aw99706: Add Awinic AW99703 support
@ 2026-12-05 0:51 Luka Panio
2026-12-05 0:51 ` [PATCH v2 1/6] dt-bindings: leds: backlight: aw99706: Use standard led-max-microamp Luka Panio
` (6 more replies)
0 siblings, 7 replies; 14+ messages in thread
From: Luka Panio @ 2026-12-05 0:51 UTC (permalink / raw)
To: lee, danielt, jingoohan1
Cc: pavel, robh, krzk+dt, conor+dt, deller, griffin, junjie.cao,
mitltlatltl, andreas, dri-devel, linux-leds, devicetree,
linux-fbdev, linux-kernel, Luka Panio
The Awinic AW99703 is a 3-channel WLED driver with an integrated boost
converter and 11-bit brightness control over I2C, used for the panel
backlight of the Nexphone (QCM6490).
As suggested on v1, this version adds the AW99703 to the existing aw99706
driver instead of adding a new one. The two chips share the programming
model but have different register maps, so the driver is first converted
to per-chip data. Following the binding review, the AW99703 binding uses
the standard led-sources and led-max-microamp properties, and the
AW99706 binding gains led-max-microamp as well, with the vendor
awinic,iled-max-microamp property deprecated but still read.
Patch 3 is a fix for the existing driver: the chip ID was read before
HWEN was asserted.
Andreas, your Kobo Clara 2e series [1] adds a separate aw99703 driver
and binding for the same chip. Hopefully we can settle on 1 driver,
please test this driver and let me know if it works for you, or you
have any other ideas.
[1] https://lore.kernel.org/all/20261202-bl-aw99703-upstr-v2-0-cc41570c0404@kemnade.info/
Changes in v2:
- Add AW99703 support to the aw99706 driver instead of a new driver
- Drop the ramp, transition and mapping properties; use led-sources and
led-max-microamp
- Add led-max-microamp to the AW99706 binding, deprecate
awinic,iled-max-microamp and keep reading it as a fallback
- Read the brightness properties into u32 variables
- Assert HWEN before reading the chip ID and drop it again on probe failure
- Add optional vin-supply and label
Luka Panio (6):
dt-bindings: leds: backlight: aw99706: Use standard led-max-microamp
dt-bindings: leds: backlight: Add Awinic AW99703 backlight
backlight: aw99706: Enable the chip before reading its ID
backlight: aw99706: Introduce per-chip data
backlight: aw99706: Support the led-max-microamp property
backlight: aw99706: Add AW99703 support
.../leds/backlight/awinic,aw99703.yaml | 118 +++++
.../leds/backlight/awinic,aw99706.yaml | 10 +-
MAINTAINERS | 2 +
drivers/video/backlight/Kconfig | 6 +-
drivers/video/backlight/aw99706.c | 434 ++++++++++++++----
5 files changed, 488 insertions(+), 82 deletions(-)
create mode 100644 Documentation/devicetree/bindings/leds/backlight/awinic,aw99703.yaml
base-commit: 29beb21c21ada7207692b2d69fc58dcd15dab6e9
--
2.55.0
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v2 1/6] dt-bindings: leds: backlight: aw99706: Use standard led-max-microamp
2026-12-05 0:51 [PATCH v2 0/6] backlight: aw99706: Add Awinic AW99703 support Luka Panio
@ 2026-12-05 0:51 ` Luka Panio
2026-12-05 1:01 ` sashiko-bot
2026-12-05 0:51 ` [PATCH v2 2/6] dt-bindings: leds: backlight: Add Awinic AW99703 backlight Luka Panio
` (5 subsequent siblings)
6 siblings, 1 reply; 14+ messages in thread
From: Luka Panio @ 2026-12-05 0:51 UTC (permalink / raw)
To: lee, danielt, jingoohan1
Cc: pavel, robh, krzk+dt, conor+dt, deller, griffin, junjie.cao,
mitltlatltl, andreas, dri-devel, linux-leds, devicetree,
linux-fbdev, linux-kernel, Luka Panio
Replace awinic,iled-max-microamp with generic led-max-microamp.
awinic,iled-max-microamp is kep as deprecated for existing device trees.
Signed-off-by: Luka Panio <lukapanio@gmail.com>
---
.../bindings/leds/backlight/awinic,aw99706.yaml | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/leds/backlight/awinic,aw99706.yaml b/Documentation/devicetree/bindings/leds/backlight/awinic,aw99706.yaml
index 60eae50ff742..0690e0e0de65 100644
--- a/Documentation/devicetree/bindings/leds/backlight/awinic,aw99706.yaml
+++ b/Documentation/devicetree/bindings/leds/backlight/awinic,aw99706.yaml
@@ -45,12 +45,20 @@ properties:
enum: [ 1500000, 2000000, 2500000, 3000000 ]
default: 3000000
+ led-max-microamp:
+ description: Maximum LED current setting in uA.
+ minimum: 5000
+ maximum: 50000
+ multipleOf: 500
+ default: 20000
+
awinic,iled-max-microamp:
description: Maximum LED current setting in uA.
minimum: 5000
maximum: 50000
multipleOf: 500
default: 20000
+ deprecated: true
awinic,uvlo-thres-microvolt:
description: UVLO(Under Voltage Lock Out) in uV.
@@ -93,7 +101,7 @@ examples:
awinic,sw-freq-hz = <750000>;
awinic,sw-ilmt-microamp = <3000000>;
awinic,uvlo-thres-microvolt = <2200000>;
- awinic,iled-max-microamp = <20000>;
+ led-max-microamp = <20000>;
awinic,ramp-ctl = <2>;
};
};
--
2.55.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v2 2/6] dt-bindings: leds: backlight: Add Awinic AW99703 backlight
2026-12-05 0:51 [PATCH v2 0/6] backlight: aw99706: Add Awinic AW99703 support Luka Panio
2026-12-05 0:51 ` [PATCH v2 1/6] dt-bindings: leds: backlight: aw99706: Use standard led-max-microamp Luka Panio
@ 2026-12-05 0:51 ` Luka Panio
2026-12-05 1:04 ` sashiko-bot
2026-12-05 9:55 ` Andreas Kemnade
2026-12-05 0:51 ` [PATCH v2 3/6] backlight: aw99706: Enable the chip before reading its ID Luka Panio
` (4 subsequent siblings)
6 siblings, 2 replies; 14+ messages in thread
From: Luka Panio @ 2026-12-05 0:51 UTC (permalink / raw)
To: lee, danielt, jingoohan1
Cc: pavel, robh, krzk+dt, conor+dt, deller, griffin, junjie.cao,
mitltlatltl, andreas, dri-devel, linux-leds, devicetree,
linux-fbdev, linux-kernel, Luka Panio
The Awinic AW99703 is a 3-channel WLED driver with an integrated boost
converter and 11-bit brightness control over I2C, optionally combined
with a PWM input.
Signed-off-by: Luka Panio <lukapanio@gmail.com>
---
.../leds/backlight/awinic,aw99703.yaml | 118 ++++++++++++++++++
MAINTAINERS | 2 +
2 files changed, 120 insertions(+)
create mode 100644 Documentation/devicetree/bindings/leds/backlight/awinic,aw99703.yaml
diff --git a/Documentation/devicetree/bindings/leds/backlight/awinic,aw99703.yaml b/Documentation/devicetree/bindings/leds/backlight/awinic,aw99703.yaml
new file mode 100644
index 000000000000..a08da356542c
--- /dev/null
+++ b/Documentation/devicetree/bindings/leds/backlight/awinic,aw99703.yaml
@@ -0,0 +1,118 @@
+# 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 3-channel WLED Backlight Driver
+
+maintainers:
+ - Luka Panio <lukapanio@gmail.com>
+
+description:
+ The AW99703 is a 3-channel WLED driver with an integrated boost converter
+ and 11-bit brightness control over I2C, optionally combined with a PWM
+ input.
+
+allOf:
+ - $ref: common.yaml#
+
+properties:
+ compatible:
+ const: awinic,aw99703
+
+ reg:
+ maxItems: 1
+
+ enable-gpios:
+ description: GPIO connected to the HWEN pin.
+ maxItems: 1
+
+ vin-supply:
+ description: Regulator supplying the VIN pin.
+
+ label:
+ description:
+ Name of the backlight device, e.g. to tell several AW99703 on one board
+ apart.
+
+ led-sources:
+ description: |
+ LED strings connected to the device:
+ 0 - LED1
+ 1 - LED2
+ 2 - LED3
+ minItems: 1
+ maxItems: 3
+ items:
+ maximum: 2
+ default: [0, 1, 2]
+
+ led-max-microamp:
+ description:
+ Full-scale current of each enabled LED string. All strings share the
+ same setting.
+ minimum: 4800
+ maximum: 29600
+ multipleOf: 800
+ default: 20000
+
+ 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: Value of the boost inductor fitted on the board.
+ $ref: /schemas/types.yaml#/definitions/uint32
+ enum: [4700, 10000]
+ default: 4700
+
+ awinic,pwm-input:
+ description:
+ The PWM input pin is connected and its duty cycle is combined with the
+ brightness set over I2C.
+ 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>;
+ vin-supply = <&vreg_bl>;
+ label = "lcd-backlight";
+ led-sources = <0 1>;
+ led-max-microamp = <20000>;
+ awinic,ocp-microamp = <3400000>;
+ awinic,inductor-nanohenry = <10000>;
+ };
+ };
diff --git a/MAINTAINERS b/MAINTAINERS
index bb36b126e531..e46fc60bc623 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4605,7 +4605,9 @@ F: sound/hda/codecs/side-codecs/aw88399*
AWINIC AW99706 WLED BACKLIGHT DRIVER
M: Junjie Cao <junjie.cao@linux.dev>
+R: Luka Panio <lukapanio@gmail.com>
S: Maintained
+F: Documentation/devicetree/bindings/leds/backlight/awinic,aw99703.yaml
F: Documentation/devicetree/bindings/leds/backlight/awinic,aw99706.yaml
F: drivers/video/backlight/aw99706.c
--
2.55.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v2 3/6] backlight: aw99706: Enable the chip before reading its ID
2026-12-05 0:51 [PATCH v2 0/6] backlight: aw99706: Add Awinic AW99703 support Luka Panio
2026-12-05 0:51 ` [PATCH v2 1/6] dt-bindings: leds: backlight: aw99706: Use standard led-max-microamp Luka Panio
2026-12-05 0:51 ` [PATCH v2 2/6] dt-bindings: leds: backlight: Add Awinic AW99703 backlight Luka Panio
@ 2026-12-05 0:51 ` Luka Panio
2026-12-05 1:05 ` sashiko-bot
2026-12-05 0:51 ` [PATCH v2 4/6] backlight: aw99706: Introduce per-chip data Luka Panio
` (3 subsequent siblings)
6 siblings, 1 reply; 14+ messages in thread
From: Luka Panio @ 2026-12-05 0:51 UTC (permalink / raw)
To: lee, danielt, jingoohan1
Cc: pavel, robh, krzk+dt, conor+dt, deller, griffin, junjie.cao,
mitltlatltl, andreas, dri-devel, linux-leds, devicetree,
linux-fbdev, linux-kernel, Luka Panio
The chip ID is read before the HWEN GPIO is requested, so the check only
passes if the chip was already enabled, e.g. by the bootloader. Request
and assert HWEN first, and de-assert it again if probe fails afterwards
so the chip is not left powered.
Fixes: 147b38a5ad06 ("backlight: aw99706: Add support for Awinic AW99706 backlight")
Signed-off-by: Luka Panio <lukapanio@gmail.com>
---
drivers/video/backlight/aw99706.c | 33 ++++++++++++++++++++-----------
1 file changed, 22 insertions(+), 11 deletions(-)
diff --git a/drivers/video/backlight/aw99706.c b/drivers/video/backlight/aw99706.c
index 43f82c83f91a..c6b0d0122ad6 100644
--- a/drivers/video/backlight/aw99706.c
+++ b/drivers/video/backlight/aw99706.c
@@ -389,11 +389,6 @@ static int aw99706_probe(struct i2c_client *client)
return dev_err_probe(dev, PTR_ERR(aw->regmap),
"Failed to init regmap\n");
- ret = aw99706_chip_id_read(aw);
- if (ret != AW99706_ID)
- return dev_err_probe(dev, -ENODEV,
- "Unknown chip id 0x%02x\n", ret);
-
aw99706_dt_parse(aw, &props);
aw->hwen_gpio = devm_gpiod_get(aw->dev, "enable", GPIOD_OUT_LOW);
@@ -401,23 +396,39 @@ static int aw99706_probe(struct i2c_client *client)
return dev_err_probe(dev, PTR_ERR(aw->hwen_gpio),
"Failed to get enable gpio\n");
+ gpiod_set_value_cansleep(aw->hwen_gpio, 1);
+
+ ret = aw99706_chip_id_read(aw);
+ if (ret != AW99706_ID) {
+ ret = dev_err_probe(dev, -ENODEV, "Unknown chip id 0x%02x\n",
+ ret);
+ goto err_power_off;
+ }
+
ret = aw99706_hw_init(aw);
- if (ret < 0)
- return dev_err_probe(dev, ret,
- "Failed to initialize the chip\n");
+ if (ret < 0) {
+ dev_err_probe(dev, ret, "Failed to initialize the chip\n");
+ goto err_power_off;
+ }
props.type = BACKLIGHT_RAW;
props.scale = BACKLIGHT_SCALE_LINEAR;
bl_dev = devm_backlight_device_register(dev, "aw99706-backlight", dev,
aw, &aw99706_bl_ops, &props);
- if (IS_ERR(bl_dev))
- return dev_err_probe(dev, PTR_ERR(bl_dev),
- "Failed to register backlight!\n");
+ if (IS_ERR(bl_dev)) {
+ ret = dev_err_probe(dev, PTR_ERR(bl_dev),
+ "Failed to register backlight!\n");
+ goto err_power_off;
+ }
aw->bl_dev = bl_dev;
return 0;
+
+err_power_off:
+ gpiod_set_value_cansleep(aw->hwen_gpio, 0);
+ return ret;
}
static void aw99706_remove(struct i2c_client *client)
--
2.55.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v2 4/6] backlight: aw99706: Introduce per-chip data
2026-12-05 0:51 [PATCH v2 0/6] backlight: aw99706: Add Awinic AW99703 support Luka Panio
` (2 preceding siblings ...)
2026-12-05 0:51 ` [PATCH v2 3/6] backlight: aw99706: Enable the chip before reading its ID Luka Panio
@ 2026-12-05 0:51 ` Luka Panio
2026-12-05 0:51 ` [PATCH v2 5/6] backlight: aw99706: Support the led-max-microamp property Luka Panio
` (2 subsequent siblings)
6 siblings, 0 replies; 14+ messages in thread
From: Luka Panio @ 2026-12-05 0:51 UTC (permalink / raw)
To: lee, danielt, jingoohan1
Cc: pavel, robh, krzk+dt, conor+dt, deller, griffin, junjie.cao,
mitltlatltl, andreas, dri-devel, linux-leds, devicetree,
linux-fbdev, linux-kernel, Luka Panio
Move the chip specific details (register map, DT properties, chip ID,
brightness and enable register layout, maximum brightness) into a chip
data structure selected by the match tables. This prepares the driver
to support other Awinic backlight controllers with a different register
layout.
Signed-off-by: Luka Panio <lukapanio@gmail.com>
---
drivers/video/backlight/aw99706.c | 205 ++++++++++++++++++++----------
1 file changed, 140 insertions(+), 65 deletions(-)
diff --git a/drivers/video/backlight/aw99706.c b/drivers/video/backlight/aw99706.c
index c6b0d0122ad6..db12ee1c979d 100644
--- a/drivers/video/backlight/aw99706.c
+++ b/drivers/video/backlight/aw99706.c
@@ -10,7 +10,6 @@
*/
#include <linux/backlight.h>
-#include <linux/bitfield.h>
#include <linux/delay.h>
#include <linux/gpio/consumer.h>
#include <linux/i2c.h>
@@ -36,10 +35,8 @@
#define AW99706_CFG3_REG 0x03
#define AW99706_CFG4_REG 0x04
-#define AW99706_BRT_MSB_MASK GENMASK(3, 0)
#define AW99706_CFG5_REG 0x05
-#define AW99706_BRT_LSB_MASK GENMASK(7, 0)
#define AW99706_CFG6_REG 0x06
#define AW99706_RAMP_CTL_MASK GENMASK(7, 6)
@@ -83,6 +80,9 @@ struct aw99706_dt_prop {
int (*lookup)(const struct aw99706_dt_prop *prop, u32 dt_val, u8 *val);
const u32 * const lookup_tbl;
u8 tbl_size;
+ u32 min;
+ u32 max;
+ u32 step;
u8 reg;
u8 mask;
u32 def_val;
@@ -109,56 +109,63 @@ static int aw99706_dt_property_lookup(const struct aw99706_dt_prop *prop,
return i == prop->tbl_size ? -EINVAL : 0;
}
-#define MIN_ILED_MAX 5000
-#define MAX_ILED_MAX 50000
-#define STEP_ILED_MAX 500
-
-static int
-aw99706_dt_property_iled_max_convert(const struct aw99706_dt_prop *prop,
+static int aw99706_dt_property_range(const struct aw99706_dt_prop *prop,
u32 dt_val, u8 *val)
{
- if (dt_val > MAX_ILED_MAX || dt_val < MIN_ILED_MAX)
+ if (dt_val > prop->max || dt_val < prop->min)
return -EINVAL;
- if ((dt_val - MIN_ILED_MAX) % STEP_ILED_MAX)
+ if ((dt_val - prop->min) % prop->step)
return -EINVAL;
- *val = (dt_val - MIN_ILED_MAX) / STEP_ILED_MAX;
+ *val = (dt_val - prop->min) / prop->step;
return 0;
}
static const struct aw99706_dt_prop aw99706_dt_props[] = {
{
- "awinic,dim-mode", aw99706_dt_property_lookup,
- NULL, 0,
- AW99706_CFG0_REG, AW99706_DIM_MODE_MASK, 1,
+ .name = "awinic,dim-mode",
+ .lookup = aw99706_dt_property_lookup,
+ .reg = AW99706_CFG0_REG, .mask = AW99706_DIM_MODE_MASK,
+ .def_val = 1,
},
{
- "awinic,sw-freq-hz", aw99706_dt_property_lookup,
- aw99706_sw_freq_tbl, ARRAY_SIZE(aw99706_sw_freq_tbl),
- AW99706_CFG1_REG, AW99706_SW_FREQ_MASK, 750000,
+ .name = "awinic,sw-freq-hz",
+ .lookup = aw99706_dt_property_lookup,
+ .lookup_tbl = aw99706_sw_freq_tbl,
+ .tbl_size = ARRAY_SIZE(aw99706_sw_freq_tbl),
+ .reg = AW99706_CFG1_REG, .mask = AW99706_SW_FREQ_MASK,
+ .def_val = 750000,
},
{
- "awinic,sw-ilmt-microamp", aw99706_dt_property_lookup,
- aw99706_sw_ilmt_tbl, ARRAY_SIZE(aw99706_sw_ilmt_tbl),
- AW99706_CFG1_REG, AW99706_SW_ILMT_MASK, 3000000,
+ .name = "awinic,sw-ilmt-microamp",
+ .lookup = aw99706_dt_property_lookup,
+ .lookup_tbl = aw99706_sw_ilmt_tbl,
+ .tbl_size = ARRAY_SIZE(aw99706_sw_ilmt_tbl),
+ .reg = AW99706_CFG1_REG, .mask = AW99706_SW_ILMT_MASK,
+ .def_val = 3000000,
},
{
- "awinic,iled-max-microamp", aw99706_dt_property_iled_max_convert,
- NULL, 0,
- AW99706_CFG2_REG, AW99706_ILED_MAX_MASK, 20000,
-
+ .name = "awinic,iled-max-microamp",
+ .lookup = aw99706_dt_property_range,
+ .min = 5000, .max = 50000, .step = 500,
+ .reg = AW99706_CFG2_REG, .mask = AW99706_ILED_MAX_MASK,
+ .def_val = 20000,
},
{
- "awinic,uvlo-thres-microvolt", aw99706_dt_property_lookup,
- aw99706_ulvo_thres_tbl, ARRAY_SIZE(aw99706_ulvo_thres_tbl),
- AW99706_CFG2_REG, AW99706_UVLOSEL_MASK, 2200000,
+ .name = "awinic,uvlo-thres-microvolt",
+ .lookup = aw99706_dt_property_lookup,
+ .lookup_tbl = aw99706_ulvo_thres_tbl,
+ .tbl_size = ARRAY_SIZE(aw99706_ulvo_thres_tbl),
+ .reg = AW99706_CFG2_REG, .mask = AW99706_UVLOSEL_MASK,
+ .def_val = 2200000,
},
{
- "awinic,ramp-ctl", aw99706_dt_property_lookup,
- NULL, 0,
- AW99706_CFG6_REG, AW99706_RAMP_CTL_MASK, 2,
+ .name = "awinic,ramp-ctl",
+ .lookup = aw99706_dt_property_lookup,
+ .reg = AW99706_CFG6_REG, .mask = AW99706_RAMP_CTL_MASK,
+ .def_val = 2,
}
};
@@ -168,13 +175,34 @@ struct reg_init_data {
u8 val;
};
+#define AW99706_MAX_INIT_REGS 8
+
+struct aw99706_chip_data {
+ const char *bl_name;
+ const struct regmap_config *regmap_config;
+ const struct aw99706_dt_prop *dt_props;
+ u8 num_dt_props;
+ u8 id_reg;
+ u8 id;
+ u32 max_brightness;
+ u8 brt_msb_reg;
+ u8 brt_lsb_reg;
+ u8 brt_lsb_bits;
+ bool brt_lsb_first;
+ u8 en_reg;
+ u8 en_mask;
+ u8 en_val;
+};
+
struct aw99706_device {
struct i2c_client *client;
struct device *dev;
+ const struct aw99706_chip_data *chip;
struct regmap *regmap;
struct backlight_device *bl_dev;
struct gpio_desc *hwen_gpio;
- struct reg_init_data init_tbl[ARRAY_SIZE(aw99706_dt_props)];
+ struct reg_init_data init_tbl[AW99706_MAX_INIT_REGS];
+ unsigned int num_init;
bool bl_enable;
};
@@ -239,16 +267,29 @@ static inline int aw99706_i2c_update_bits(struct aw99706_device *aw, u8 reg,
return regmap_update_bits(aw->regmap, reg, mask, val);
}
+static void aw99706_add_init(struct aw99706_device *aw, u8 reg, u8 mask,
+ u8 val)
+{
+ if (WARN_ON(aw->num_init >= ARRAY_SIZE(aw->init_tbl)))
+ return;
+
+ aw->init_tbl[aw->num_init].reg = reg;
+ aw->init_tbl[aw->num_init].mask = mask;
+ aw->init_tbl[aw->num_init].val = val;
+ aw->num_init++;
+}
+
static void aw99706_dt_parse(struct aw99706_device *aw,
struct backlight_properties *bl_props)
{
+ const struct aw99706_chip_data *chip = aw->chip;
const struct aw99706_dt_prop *prop;
- u32 dt_val;
+ u32 dt_val, max_brt, brt;
int ret, i;
u8 val;
- for (i = 0; i < ARRAY_SIZE(aw99706_dt_props); i++) {
- prop = &aw99706_dt_props[i];
+ for (i = 0; i < chip->num_dt_props; i++) {
+ prop = &chip->dt_props[i];
ret = device_property_read_u32(aw->dev, prop->name, &dt_val);
if (ret < 0)
dt_val = prop->def_val;
@@ -260,23 +301,23 @@ static void aw99706_dt_parse(struct aw99706_device *aw,
prop->lookup(prop, prop->def_val, &val);
}
- aw->init_tbl[i].reg = prop->reg;
- aw->init_tbl[i].mask = prop->mask;
- aw->init_tbl[i].val = val << __ffs(prop->mask);
+ aw99706_add_init(aw, prop->reg, prop->mask,
+ val << __ffs(prop->mask));
}
- bl_props->brightness = AW99706_MAX_BRT_LVL >> 1;
- bl_props->max_brightness = AW99706_MAX_BRT_LVL;
- device_property_read_u32(aw->dev, "default-brightness",
- &bl_props->brightness);
- device_property_read_u32(aw->dev, "max-brightness",
- &bl_props->max_brightness);
+ brt = chip->max_brightness >> 1;
+ max_brt = chip->max_brightness;
+ device_property_read_u32(aw->dev, "default-brightness", &brt);
+ device_property_read_u32(aw->dev, "max-brightness", &max_brt);
+
+ if (max_brt > chip->max_brightness)
+ max_brt = chip->max_brightness;
- if (bl_props->max_brightness > AW99706_MAX_BRT_LVL)
- bl_props->max_brightness = AW99706_MAX_BRT_LVL;
+ if (brt > max_brt)
+ brt = max_brt;
- if (bl_props->brightness > bl_props->max_brightness)
- bl_props->brightness = bl_props->max_brightness;
+ bl_props->brightness = brt;
+ bl_props->max_brightness = max_brt;
}
static int aw99706_hw_init(struct aw99706_device *aw)
@@ -285,7 +326,7 @@ static int aw99706_hw_init(struct aw99706_device *aw)
gpiod_set_value_cansleep(aw->hwen_gpio, 1);
- for (i = 0; i < ARRAY_SIZE(aw->init_tbl); i++) {
+ for (i = 0; i < aw->num_init; i++) {
ret = aw99706_i2c_update_bits(aw, aw->init_tbl[i].reg,
aw->init_tbl[i].mask,
aw->init_tbl[i].val);
@@ -300,30 +341,45 @@ static int aw99706_hw_init(struct aw99706_device *aw)
static int aw99706_bl_enable(struct aw99706_device *aw, bool en)
{
+ const struct aw99706_chip_data *chip = aw->chip;
int ret;
- u8 val;
- val = FIELD_PREP(AW99706_BACKLIGHT_EN_MASK, en);
- ret = aw99706_i2c_update_bits(aw, AW99706_CFGD_REG,
- AW99706_BACKLIGHT_EN_MASK, val);
+ ret = aw99706_i2c_update_bits(aw, chip->en_reg, chip->en_mask,
+ en ? chip->en_val : 0);
if (ret)
dev_err(aw->dev, "Failed to enable backlight!\n");
return ret;
}
-static int aw99706_update_brightness(struct aw99706_device *aw, u32 brt_lvl)
+static int aw99706_write_brightness(struct aw99706_device *aw, u32 brt_lvl)
{
- bool bl_enable_now = !!brt_lvl;
+ const struct aw99706_chip_data *chip = aw->chip;
+ u8 lsb = brt_lvl & GENMASK(chip->brt_lsb_bits - 1, 0);
+ u8 msb = brt_lvl >> chip->brt_lsb_bits;
int ret;
- ret = aw99706_i2c_write(aw, AW99706_CFG4_REG,
- (brt_lvl >> 8) & AW99706_BRT_MSB_MASK);
+ if (chip->brt_lsb_first) {
+ ret = aw99706_i2c_write(aw, chip->brt_lsb_reg, lsb);
+ if (ret < 0)
+ return ret;
+
+ return aw99706_i2c_write(aw, chip->brt_msb_reg, msb);
+ }
+
+ ret = aw99706_i2c_write(aw, chip->brt_msb_reg, msb);
if (ret < 0)
return ret;
- ret = aw99706_i2c_write(aw, AW99706_CFG5_REG,
- brt_lvl & AW99706_BRT_LSB_MASK);
+ return aw99706_i2c_write(aw, chip->brt_lsb_reg, lsb);
+}
+
+static int aw99706_update_brightness(struct aw99706_device *aw, u32 brt_lvl)
+{
+ bool bl_enable_now = !!brt_lvl;
+ int ret;
+
+ ret = aw99706_write_brightness(aw, brt_lvl);
if (ret < 0)
return ret;
@@ -361,7 +417,7 @@ static int aw99706_chip_id_read(struct aw99706_device *aw)
int ret;
unsigned int val;
- ret = aw99706_i2c_read(aw, AW99706_CHIPID_REG, &val);
+ ret = aw99706_i2c_read(aw, aw->chip->id_reg, &val);
if (ret < 0)
return ret;
@@ -382,9 +438,12 @@ static int aw99706_probe(struct i2c_client *client)
aw->client = client;
aw->dev = dev;
+ aw->chip = i2c_get_match_data(client);
+ if (!aw->chip)
+ return -ENODEV;
i2c_set_clientdata(client, aw);
- aw->regmap = devm_regmap_init_i2c(client, &aw99706_regmap_config);
+ aw->regmap = devm_regmap_init_i2c(client, aw->chip->regmap_config);
if (IS_ERR(aw->regmap))
return dev_err_probe(dev, PTR_ERR(aw->regmap),
"Failed to init regmap\n");
@@ -399,7 +458,7 @@ static int aw99706_probe(struct i2c_client *client)
gpiod_set_value_cansleep(aw->hwen_gpio, 1);
ret = aw99706_chip_id_read(aw);
- if (ret != AW99706_ID) {
+ if (ret != aw->chip->id) {
ret = dev_err_probe(dev, -ENODEV, "Unknown chip id 0x%02x\n",
ret);
goto err_power_off;
@@ -414,7 +473,7 @@ static int aw99706_probe(struct i2c_client *client)
props.type = BACKLIGHT_RAW;
props.scale = BACKLIGHT_SCALE_LINEAR;
- bl_dev = devm_backlight_device_register(dev, "aw99706-backlight", dev,
+ bl_dev = devm_backlight_device_register(dev, aw->chip->bl_name, dev,
aw, &aw99706_bl_ops, &props);
if (IS_ERR(bl_dev)) {
ret = dev_err_probe(dev, PTR_ERR(bl_dev),
@@ -458,14 +517,30 @@ static int aw99706_resume(struct device *dev)
static DEFINE_SIMPLE_DEV_PM_OPS(aw99706_pm_ops, aw99706_suspend, aw99706_resume);
+static const struct aw99706_chip_data aw99706_chip = {
+ .bl_name = "aw99706-backlight",
+ .regmap_config = &aw99706_regmap_config,
+ .dt_props = aw99706_dt_props,
+ .num_dt_props = ARRAY_SIZE(aw99706_dt_props),
+ .id_reg = AW99706_CHIPID_REG,
+ .id = AW99706_ID,
+ .max_brightness = AW99706_MAX_BRT_LVL,
+ .brt_msb_reg = AW99706_CFG4_REG,
+ .brt_lsb_reg = AW99706_CFG5_REG,
+ .brt_lsb_bits = 8,
+ .en_reg = AW99706_CFGD_REG,
+ .en_mask = AW99706_BACKLIGHT_EN_MASK,
+ .en_val = AW99706_BACKLIGHT_EN_MASK,
+};
+
static const struct i2c_device_id aw99706_ids[] = {
- { .name = "aw99706" },
+ { .name = "aw99706", .driver_data = (kernel_ulong_t)&aw99706_chip },
{ }
};
MODULE_DEVICE_TABLE(i2c, aw99706_ids);
static const struct of_device_id aw99706_match_table[] = {
- { .compatible = "awinic,aw99706", },
+ { .compatible = "awinic,aw99706", .data = &aw99706_chip },
{ }
};
MODULE_DEVICE_TABLE(of, aw99706_match_table);
--
2.55.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v2 5/6] backlight: aw99706: Support the led-max-microamp property
2026-12-05 0:51 [PATCH v2 0/6] backlight: aw99706: Add Awinic AW99703 support Luka Panio
` (3 preceding siblings ...)
2026-12-05 0:51 ` [PATCH v2 4/6] backlight: aw99706: Introduce per-chip data Luka Panio
@ 2026-12-05 0:51 ` Luka Panio
2026-12-05 0:59 ` sashiko-bot
2026-12-05 0:51 ` [PATCH v2 6/6] backlight: aw99706: Add AW99703 support Luka Panio
2026-12-05 12:16 ` [PATCH v2 0/6] backlight: aw99706: Add Awinic " Andreas Kemnade
6 siblings, 1 reply; 14+ messages in thread
From: Luka Panio @ 2026-12-05 0:51 UTC (permalink / raw)
To: lee, danielt, jingoohan1
Cc: pavel, robh, krzk+dt, conor+dt, deller, griffin, junjie.cao,
mitltlatltl, andreas, dri-devel, linux-leds, devicetree,
linux-fbdev, linux-kernel, Luka Panio
Signed-off-by: Luka Panio <lukapanio@gmail.com>
---
drivers/video/backlight/aw99706.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/video/backlight/aw99706.c b/drivers/video/backlight/aw99706.c
index db12ee1c979d..5e0f8ccd3c88 100644
--- a/drivers/video/backlight/aw99706.c
+++ b/drivers/video/backlight/aw99706.c
@@ -77,6 +77,7 @@ static const u32 aw99706_ulvo_thres_tbl[] = {
struct aw99706_dt_prop {
const char * const name;
+ const char * const legacy_name;
int (*lookup)(const struct aw99706_dt_prop *prop, u32 dt_val, u8 *val);
const u32 * const lookup_tbl;
u8 tbl_size;
@@ -147,7 +148,8 @@ static const struct aw99706_dt_prop aw99706_dt_props[] = {
.def_val = 3000000,
},
{
- .name = "awinic,iled-max-microamp",
+ .name = "led-max-microamp",
+ .legacy_name = "awinic,iled-max-microamp",
.lookup = aw99706_dt_property_range,
.min = 5000, .max = 50000, .step = 500,
.reg = AW99706_CFG2_REG, .mask = AW99706_ILED_MAX_MASK,
@@ -291,6 +293,10 @@ static void aw99706_dt_parse(struct aw99706_device *aw,
for (i = 0; i < chip->num_dt_props; i++) {
prop = &chip->dt_props[i];
ret = device_property_read_u32(aw->dev, prop->name, &dt_val);
+ if (ret < 0 && prop->legacy_name)
+ ret = device_property_read_u32(aw->dev,
+ prop->legacy_name,
+ &dt_val);
if (ret < 0)
dt_val = prop->def_val;
--
2.55.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v2 6/6] backlight: aw99706: Add AW99703 support
2026-12-05 0:51 [PATCH v2 0/6] backlight: aw99706: Add Awinic AW99703 support Luka Panio
` (4 preceding siblings ...)
2026-12-05 0:51 ` [PATCH v2 5/6] backlight: aw99706: Support the led-max-microamp property Luka Panio
@ 2026-12-05 0:51 ` Luka Panio
2026-12-05 1:11 ` sashiko-bot
2026-12-05 12:16 ` [PATCH v2 0/6] backlight: aw99706: Add Awinic " Andreas Kemnade
6 siblings, 1 reply; 14+ messages in thread
From: Luka Panio @ 2026-12-05 0:51 UTC (permalink / raw)
To: lee, danielt, jingoohan1
Cc: pavel, robh, krzk+dt, conor+dt, deller, griffin, junjie.cao,
mitltlatltl, andreas, dri-devel, linux-leds, devicetree,
linux-fbdev, linux-kernel, Luka Panio
The Awinic AW99703 is a 3-channel WLED driver with an integrated boost
converter and 11-bit brightness control over I2C. It follows the same
programming model as the AW99706 but with a different register layout,
so add it as another chip variant.
Register values follow the AW99703 datasheet (V1.6).
Signed-off-by: Luka Panio <lukapanio@gmail.com>
---
drivers/video/backlight/Kconfig | 6 +-
drivers/video/backlight/aw99706.c | 194 +++++++++++++++++++++++++++++-
2 files changed, 193 insertions(+), 7 deletions(-)
diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig
index dbf4ca23a9b6..894e593cef6c 100644
--- a/drivers/video/backlight/Kconfig
+++ b/drivers/video/backlight/Kconfig
@@ -157,12 +157,12 @@ config BACKLIGHT_ATMEL_LCDC
in unless the board's description says it's wired that way.
config BACKLIGHT_AW99706
- tristate "Backlight Driver for Awinic AW99706"
+ tristate "Backlight Driver for Awinic AW99706 and AW99703"
depends on I2C
select REGMAP_I2C
help
- If you have a LCD backlight connected to the WLED output of AW99706
- WLED output, say Y here to enable this driver.
+ If you have a LCD backlight connected to the WLED output of an
+ Awinic AW99706 or AW99703, say Y here to enable this driver.
config BACKLIGHT_EP93XX
tristate "Cirrus EP93xx Backlight Driver"
diff --git a/drivers/video/backlight/aw99706.c b/drivers/video/backlight/aw99706.c
index 5e0f8ccd3c88..f898df0d4ed1 100644
--- a/drivers/video/backlight/aw99706.c
+++ b/drivers/video/backlight/aw99706.c
@@ -1,9 +1,10 @@
// SPDX-License-Identifier: GPL-2.0
/*
- * aw99706 - Backlight driver for the AWINIC AW99706
+ * aw99706 - Backlight driver for the AWINIC AW99706 and AW99703
*
* Copyright (C) 2025 Junjie Cao <caojunjie650@gmail.com>
* Copyright (C) 2025 Pengyu Luo <mitltlatltl@gmail.com>
+ * Copyright (C) 2026 Luka Panio <lukapanio@gmail.com>
*
* Based on vendor driver:
* Copyright (c) 2023 AWINIC Technology CO., LTD
@@ -16,6 +17,7 @@
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/regmap.h>
+#include <linux/regulator/consumer.h>
#define AW99706_MAX_BRT_LVL 4095
#define AW99706_REG_MAX 0x1F
@@ -57,6 +59,33 @@
#define AW99706_MTPLDOSEL_REG 0x1E
#define AW99706_MTPRUN_REG 0x1F
+#define AW99703_MAX_BRT_LVL 2047
+#define AW99703_ID 0x03
+#define AW99703_HWEN_DELAY_US 3500
+
+#define AW99703_ID_REG 0x00
+#define AW99703_SFTRST_REG 0x01
+#define AW99703_MODE_REG 0x02
+#define AW99703_PDIS_MASK BIT(4)
+#define AW99703_MAP_LINEAR_MASK BIT(2)
+#define AW99703_WORKMODE_MASK GENMASK(1, 0)
+#define AW99703_WORKMODE_BACKLIGHT 1
+#define AW99703_LEDCUR_REG 0x03
+#define AW99703_BLFS_MASK GENMASK(7, 3)
+#define AW99703_CHANNEL_MASK GENMASK(2, 0)
+#define AW99703_BSTCTR1_REG 0x04
+#define AW99703_SW_FREQ_MASK BIT(5)
+#define AW99703_OVPSEL_MASK GENMASK(4, 2)
+#define AW99703_OCPSEL_MASK GENMASK(1, 0)
+#define AW99703_BSTCTR2_REG 0x05
+#define AW99703_IDCTSEL_MASK BIT(6)
+#define AW99703_LEDLSB_REG 0x06
+#define AW99703_LEDMSB_REG 0x07
+#define AW99703_AFLOW_REG 0x0D
+#define AW99703_FLAGS2_REG 0x0F
+#define AW99703_FLAGS3_REG 0x11
+#define AW99703_REG_MAX 0x69
+
#define RESV U32_MAX
/* Boost switching frequency table, in Hz */
@@ -75,6 +104,20 @@ static const u32 aw99706_ulvo_thres_tbl[] = {
2200000, 5000000
};
+/* AW99703 boost switching frequency table, in Hz */
+static const u32 aw99703_sw_freq_tbl[] = { 500000, 1000000 };
+
+/* AW99703 boost over-voltage protection table, in uV (1xx = 41.5 V) */
+static const u32 aw99703_ovp_tbl[] = {
+ 17500000, 24000000, 31000000, 38000000, 41500000, RESV, RESV, RESV
+};
+
+/* AW99703 boost over-current protection table, in uA */
+static const u32 aw99703_ocp_tbl[] = { 900000, 1800000, 2700000, 3400000 };
+
+/* AW99703 boost inductor table, in nH */
+static const u32 aw99703_inductor_tbl[] = { 4700, 10000 };
+
struct aw99706_dt_prop {
const char * const name;
const char * const legacy_name;
@@ -171,6 +214,48 @@ static const struct aw99706_dt_prop aw99706_dt_props[] = {
}
};
+static const struct aw99706_dt_prop aw99703_dt_props[] = {
+ {
+ .name = "awinic,sw-freq-hz",
+ .lookup = aw99706_dt_property_lookup,
+ .lookup_tbl = aw99703_sw_freq_tbl,
+ .tbl_size = ARRAY_SIZE(aw99703_sw_freq_tbl),
+ .reg = AW99703_BSTCTR1_REG, .mask = AW99703_SW_FREQ_MASK,
+ .def_val = 1000000,
+ },
+ {
+ .name = "awinic,ovp-microvolt",
+ .lookup = aw99706_dt_property_lookup,
+ .lookup_tbl = aw99703_ovp_tbl,
+ .tbl_size = ARRAY_SIZE(aw99703_ovp_tbl),
+ .reg = AW99703_BSTCTR1_REG, .mask = AW99703_OVPSEL_MASK,
+ .def_val = 38000000,
+ },
+ {
+ .name = "awinic,ocp-microamp",
+ .lookup = aw99706_dt_property_lookup,
+ .lookup_tbl = aw99703_ocp_tbl,
+ .tbl_size = ARRAY_SIZE(aw99703_ocp_tbl),
+ .reg = AW99703_BSTCTR1_REG, .mask = AW99703_OCPSEL_MASK,
+ .def_val = 2700000,
+ },
+ {
+ .name = "awinic,inductor-nanohenry",
+ .lookup = aw99706_dt_property_lookup,
+ .lookup_tbl = aw99703_inductor_tbl,
+ .tbl_size = ARRAY_SIZE(aw99703_inductor_tbl),
+ .reg = AW99703_BSTCTR2_REG, .mask = AW99703_IDCTSEL_MASK,
+ .def_val = 4700,
+ },
+ {
+ .name = "led-max-microamp",
+ .lookup = aw99706_dt_property_range,
+ .min = 4800, .max = 29600, .step = 800,
+ .reg = AW99703_LEDCUR_REG, .mask = AW99703_BLFS_MASK,
+ .def_val = 20000,
+ },
+};
+
struct reg_init_data {
u8 reg;
u8 mask;
@@ -179,14 +264,18 @@ struct reg_init_data {
#define AW99706_MAX_INIT_REGS 8
+struct aw99706_device;
+
struct aw99706_chip_data {
const char *bl_name;
+ void (*dt_parse_extra)(struct aw99706_device *aw);
const struct regmap_config *regmap_config;
const struct aw99706_dt_prop *dt_props;
u8 num_dt_props;
u8 id_reg;
u8 id;
u32 max_brightness;
+ unsigned int hwen_delay_us;
u8 brt_msb_reg;
u8 brt_lsb_reg;
u8 brt_lsb_bits;
@@ -311,6 +400,9 @@ static void aw99706_dt_parse(struct aw99706_device *aw,
val << __ffs(prop->mask));
}
+ if (chip->dt_parse_extra)
+ chip->dt_parse_extra(aw);
+
brt = chip->max_brightness >> 1;
max_brt = chip->max_brightness;
device_property_read_u32(aw->dev, "default-brightness", &brt);
@@ -326,6 +418,38 @@ static void aw99706_dt_parse(struct aw99706_device *aw,
bl_props->max_brightness = max_brt;
}
+static void aw99703_dt_parse_extra(struct aw99706_device *aw)
+{
+ u32 sources[3];
+ u8 channels = 0;
+ int count, i;
+
+ count = device_property_count_u32(aw->dev, "led-sources");
+ if (count > 0 && count <= ARRAY_SIZE(sources) &&
+ !device_property_read_u32_array(aw->dev, "led-sources", sources,
+ count)) {
+ for (i = 0; i < count; i++) {
+ if (sources[i] > 2) {
+ dev_warn(aw->dev, "invalid led-sources, enabling all strings\n");
+ channels = 0;
+ break;
+ }
+ channels |= BIT(sources[i]);
+ }
+ }
+ if (!channels)
+ channels = AW99703_CHANNEL_MASK;
+
+ aw99706_add_init(aw, AW99703_LEDCUR_REG, AW99703_CHANNEL_MASK, channels);
+
+ aw99706_add_init(aw, AW99703_MODE_REG, AW99703_PDIS_MASK,
+ device_property_read_bool(aw->dev, "awinic,pwm-input") ?
+ 0 : AW99703_PDIS_MASK);
+
+ aw99706_add_init(aw, AW99703_MODE_REG, AW99703_MAP_LINEAR_MASK,
+ AW99703_MAP_LINEAR_MASK);
+}
+
static int aw99706_hw_init(struct aw99706_device *aw)
{
int ret, i;
@@ -410,6 +534,36 @@ static const struct backlight_ops aw99706_bl_ops = {
.update_status = aw99706_bl_update_status,
};
+static bool aw99703_readable_reg(struct device *dev, unsigned int reg)
+{
+ switch (reg) {
+ case AW99703_ID_REG:
+ case AW99703_MODE_REG ... AW99703_FLAGS2_REG:
+ case AW99703_FLAGS3_REG:
+ return true;
+ default:
+ return false;
+ }
+}
+
+static bool aw99703_writeable_reg(struct device *dev, unsigned int reg)
+{
+ switch (reg) {
+ case AW99703_SFTRST_REG ... AW99703_AFLOW_REG:
+ return true;
+ default:
+ return false;
+ }
+}
+
+static const struct regmap_config aw99703_regmap_config = {
+ .reg_bits = 8,
+ .val_bits = 8,
+ .max_register = AW99703_REG_MAX,
+ .writeable_reg = aw99703_writeable_reg,
+ .readable_reg = aw99703_readable_reg,
+};
+
static const struct regmap_config aw99706_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
@@ -436,6 +590,7 @@ static int aw99706_probe(struct i2c_client *client)
struct aw99706_device *aw;
struct backlight_device *bl_dev;
struct backlight_properties props = {};
+ const char *name;
int ret = 0;
aw = devm_kzalloc_obj(dev, *aw);
@@ -456,12 +611,19 @@ static int aw99706_probe(struct i2c_client *client)
aw99706_dt_parse(aw, &props);
- aw->hwen_gpio = devm_gpiod_get(aw->dev, "enable", GPIOD_OUT_LOW);
+ ret = devm_regulator_get_enable_optional(dev, "vin");
+ if (ret < 0 && ret != -ENODEV)
+ return dev_err_probe(dev, ret, "Failed to enable vin supply\n");
+
+ aw->hwen_gpio = devm_gpiod_get_optional(aw->dev, "enable",
+ GPIOD_OUT_LOW);
if (IS_ERR(aw->hwen_gpio))
return dev_err_probe(dev, PTR_ERR(aw->hwen_gpio),
"Failed to get enable gpio\n");
gpiod_set_value_cansleep(aw->hwen_gpio, 1);
+ if (aw->hwen_gpio && aw->chip->hwen_delay_us)
+ fsleep(aw->chip->hwen_delay_us);
ret = aw99706_chip_id_read(aw);
if (ret != aw->chip->id) {
@@ -479,7 +641,10 @@ static int aw99706_probe(struct i2c_client *client)
props.type = BACKLIGHT_RAW;
props.scale = BACKLIGHT_SCALE_LINEAR;
- bl_dev = devm_backlight_device_register(dev, aw->chip->bl_name, dev,
+ if (device_property_read_string(dev, "label", &name))
+ name = aw->chip->bl_name;
+
+ bl_dev = devm_backlight_device_register(dev, name, dev,
aw, &aw99706_bl_ops, &props);
if (IS_ERR(bl_dev)) {
ret = dev_err_probe(dev, PTR_ERR(bl_dev),
@@ -539,13 +704,34 @@ static const struct aw99706_chip_data aw99706_chip = {
.en_val = AW99706_BACKLIGHT_EN_MASK,
};
+static const struct aw99706_chip_data aw99703_chip = {
+ .bl_name = "aw99703-backlight",
+ .dt_parse_extra = aw99703_dt_parse_extra,
+ .regmap_config = &aw99703_regmap_config,
+ .dt_props = aw99703_dt_props,
+ .num_dt_props = ARRAY_SIZE(aw99703_dt_props),
+ .id_reg = AW99703_ID_REG,
+ .id = AW99703_ID,
+ .max_brightness = AW99703_MAX_BRT_LVL,
+ .hwen_delay_us = AW99703_HWEN_DELAY_US,
+ .brt_msb_reg = AW99703_LEDMSB_REG,
+ .brt_lsb_reg = AW99703_LEDLSB_REG,
+ .brt_lsb_bits = 3,
+ .brt_lsb_first = true,
+ .en_reg = AW99703_MODE_REG,
+ .en_mask = AW99703_WORKMODE_MASK,
+ .en_val = AW99703_WORKMODE_BACKLIGHT,
+};
+
static const struct i2c_device_id aw99706_ids[] = {
+ { .name = "aw99703", .driver_data = (kernel_ulong_t)&aw99703_chip },
{ .name = "aw99706", .driver_data = (kernel_ulong_t)&aw99706_chip },
{ }
};
MODULE_DEVICE_TABLE(i2c, aw99706_ids);
static const struct of_device_id aw99706_match_table[] = {
+ { .compatible = "awinic,aw99703", .data = &aw99703_chip },
{ .compatible = "awinic,aw99706", .data = &aw99706_chip },
{ }
};
@@ -565,4 +751,4 @@ static struct i2c_driver aw99706_i2c_driver = {
module_i2c_driver(aw99706_i2c_driver);
MODULE_LICENSE("GPL v2");
-MODULE_DESCRIPTION("BackLight driver for aw99706");
+MODULE_DESCRIPTION("BackLight driver for aw99706 and aw99703");
--
2.55.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH v2 5/6] backlight: aw99706: Support the led-max-microamp property
2026-12-05 0:51 ` [PATCH v2 5/6] backlight: aw99706: Support the led-max-microamp property Luka Panio
@ 2026-12-05 0:59 ` sashiko-bot
0 siblings, 0 replies; 14+ messages in thread
From: sashiko-bot @ 2026-12-05 0:59 UTC (permalink / raw)
To: Luka Panio; +Cc: dri-devel, linux-leds, devicetree, robh, conor+dt, lee
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Low] backlight: aw99706: empty commit message body omits rationale
and fallback
- [Low] backlight: aw99706: aw99706_dt_parse() warns with wrong name for
legacy prop
--
commit 145a6dabcb5680c7062435715038e4c7b53fef01
Author: Luka Panio <lukapanio@gmail.com>
> backlight: aw99706: Support the led-max-microamp property
>
> Signed-off-by: Luka Panio <lukapanio@gmail.com>
[Severity: Low]
The commit message has no body explaining why the driver switches to
led-max-microamp or noting that awinic,iled-max-microamp is retained as a
fallback when led-max-microamp is absent. A short description of the
rationale and fallback precedence would help future readers of git history.
> diff --git a/drivers/video/backlight/aw99706.c b/drivers/video/backlight/aw99706.c
> index db12ee1c979da..5e0f8ccd3c88e 100644
> --- a/drivers/video/backlight/aw99706.c
> +++ b/drivers/video/backlight/aw99706.c
[ ... ]
> @@ -291,6 +293,10 @@ static void aw99706_dt_parse(struct aw99706_device *aw,
> for (i = 0; i < chip->num_dt_props; i++) {
> prop = &chip->dt_props[i];
> ret = device_property_read_u32(aw->dev, prop->name, &dt_val);
> + if (ret < 0 && prop->legacy_name)
> + ret = device_property_read_u32(aw->dev,
> + prop->legacy_name,
> + &dt_val);
> if (ret < 0)
> dt_val = prop->def_val;
[Severity: Low]
When a legacy device tree omits led-max-microamp and provides an invalid
awinic,iled-max-microamp value, does the dev_warn() right below log
prop->name (led-max-microamp) instead of the legacy property that supplied
dt_val?
Tracking the matched property name in a local variable and passing it to
dev_warn() would ensure the warning identifies the offending property.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261205005118.884885-1-lukapanio@gmail.com?part=5
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 1/6] dt-bindings: leds: backlight: aw99706: Use standard led-max-microamp
2026-12-05 0:51 ` [PATCH v2 1/6] dt-bindings: leds: backlight: aw99706: Use standard led-max-microamp Luka Panio
@ 2026-12-05 1:01 ` sashiko-bot
0 siblings, 0 replies; 14+ messages in thread
From: sashiko-bot @ 2026-12-05 1:01 UTC (permalink / raw)
To: Luka Panio; +Cc: dri-devel, linux-leds, devicetree, robh, conor+dt, lee
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] dt-bindings: aw99706: place led-max-microamp before vendor
properties
--
commit b5cccb409159501f7c23d7b085592afcea3d6e74
Author: Luka Panio <lukapanio@gmail.com>
dt-bindings: leds: backlight: aw99706: Use standard led-max-microamp
This commit adds the standard led-max-microamp property to the AW99706
backlight DT binding, marks awinic,iled-max-microamp as deprecated, and
updates the example node.
> diff --git a/Documentation/devicetree/bindings/leds/backlight/awinic,aw99706.yaml b/Documentation/devicetree/bindings/leds/backlight/awinic,aw99706.yaml
> index 60eae50ff742f..0690e0e0de659 100644
> --- a/Documentation/devicetree/bindings/leds/backlight/awinic,aw99706.yaml
> +++ b/Documentation/devicetree/bindings/leds/backlight/awinic,aw99706.yaml
> @@ -45,12 +45,20 @@ properties:
> enum: [ 1500000, 2000000, 2500000, 3000000 ]
> default: 3000000
>
> + led-max-microamp:
> + description: Maximum LED current setting in uA.
> + minimum: 5000
> + maximum: 50000
> + multipleOf: 500
> + default: 20000
> +
> awinic,iled-max-microamp:
> description: Maximum LED current setting in uA.
> minimum: 5000
> maximum: 50000
> multipleOf: 500
> default: 20000
> + deprecated: true
>
> awinic,uvlo-thres-microvolt:
> description: UVLO(Under Voltage Lock Out) in uV.
> @@ -93,7 +101,7 @@ examples:
> awinic,sw-freq-hz = <750000>;
> awinic,sw-ilmt-microamp = <3000000>;
> awinic,uvlo-thres-microvolt = <2200000>;
> - awinic,iled-max-microamp = <20000>;
> + led-max-microamp = <20000>;
> awinic,ramp-ctl = <2>;
> };
> };
[Severity: Low]
Should led-max-microamp be placed before the vendor-prefixed awinic,*
properties in both the properties block (before awinic,dim-mode) and the
examples node? Per Documentation/devicetree/bindings/dts-coding-style.rst
and writing-schema.rst, standard properties without vendor prefixes belong
before vendor-specific ones.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261205005118.884885-1-lukapanio@gmail.com?part=1
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 2/6] dt-bindings: leds: backlight: Add Awinic AW99703 backlight
2026-12-05 0:51 ` [PATCH v2 2/6] dt-bindings: leds: backlight: Add Awinic AW99703 backlight Luka Panio
@ 2026-12-05 1:04 ` sashiko-bot
2026-12-05 9:55 ` Andreas Kemnade
1 sibling, 0 replies; 14+ messages in thread
From: sashiko-bot @ 2026-12-05 1:04 UTC (permalink / raw)
To: Luka Panio; +Cc: dri-devel, linux-leds, devicetree, robh, conor+dt, lee
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] dt-bindings: leds: backlight: brightness properties after vendor
properties
--
commit e73a777362909b5241688863c1637a75fd178b6d
Author: Luka Panio <lukapanio@gmail.com>
dt-bindings: leds: backlight: Add Awinic AW99703 backlight
This commit adds the Devicetree binding schema for the Awinic AW99703
3-channel WLED backlight driver and updates MAINTAINERS.
> diff --git a/Documentation/devicetree/bindings/leds/backlight/awinic,aw99703.yaml b/Documentation/devicetree/bindings/leds/backlight/awinic,aw99703.yaml
> new file mode 100644
> index 0000000000000..a08da356542ce
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/leds/backlight/awinic,aw99703.yaml
[ ... ]
> + awinic,pwm-input:
> + description:
> + The PWM input pin is connected and its duty cycle is combined with the
> + brightness set over I2C.
> + type: boolean
> +
> + default-brightness:
> + maximum: 2047
> +
> + max-brightness:
> + maximum: 2047
[Severity: Low]
Should default-brightness and max-brightness be placed before the
awinic,* vendor-specific properties?
Documentation/devicetree/bindings/writing-schema.rst follows the property
ordering in dts-coding-style.rst, which groups standard properties before
vendor-prefixed ones. Moving these two common.yaml properties above
awinic,ovp-microvolt keeps the schema consistent with that convention.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261205005118.884885-1-lukapanio@gmail.com?part=2
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 3/6] backlight: aw99706: Enable the chip before reading its ID
2026-12-05 0:51 ` [PATCH v2 3/6] backlight: aw99706: Enable the chip before reading its ID Luka Panio
@ 2026-12-05 1:05 ` sashiko-bot
0 siblings, 0 replies; 14+ messages in thread
From: sashiko-bot @ 2026-12-05 1:05 UTC (permalink / raw)
To: Luka Panio; +Cc: dri-devel, linux-leds, devicetree, robh, conor+dt, lee
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] backlight: aw99706: GPIOD_OUT_LOW causes HWEN low glitch in
aw99706_probe()
--
commit 075b8a34b2576dc02fa570093a2f3e92820bbe54
Author: Luka Panio <lukapanio@gmail.com>
backlight: aw99706: Enable the chip before reading its ID
This commit moves the chip ID read in aw99706_probe() after requesting and
asserting the enable GPIO, and de-asserts the GPIO if subsequent probe steps
fail.
> diff --git a/drivers/video/backlight/aw99706.c b/drivers/video/backlight/aw99706.c
> index 43f82c83f91a3..c6b0d0122ad69 100644
> --- a/drivers/video/backlight/aw99706.c
> +++ b/drivers/video/backlight/aw99706.c
> @@ -389,11 +389,6 @@ static int aw99706_probe(struct i2c_client *client)
[ ... ]
> aw->hwen_gpio = devm_gpiod_get(aw->dev, "enable", GPIOD_OUT_LOW);
> @@ -401,23 +396,39 @@ static int aw99706_probe(struct i2c_client *client)
> return dev_err_probe(dev, PTR_ERR(aw->hwen_gpio),
> "Failed to get enable gpio\n");
>
> + gpiod_set_value_cansleep(aw->hwen_gpio, 1);
> +
> + ret = aw99706_chip_id_read(aw);
[Severity: Medium]
Does requesting aw->hwen_gpio with GPIOD_OUT_LOW and immediately asserting
it high glitch the enable line low before aw99706_chip_id_read()?
On boards where the bootloader already enabled the backlight, this low
pulse can reset the chip, causing display flicker or making
aw99706_chip_id_read() fail while the chip is resetting. Requesting the
GPIO with GPIOD_OUT_HIGH instead would avoid the low pulse and remove the
redundant gpiod_set_value_cansleep() call.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261205005118.884885-1-lukapanio@gmail.com?part=3
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 6/6] backlight: aw99706: Add AW99703 support
2026-12-05 0:51 ` [PATCH v2 6/6] backlight: aw99706: Add AW99703 support Luka Panio
@ 2026-12-05 1:11 ` sashiko-bot
0 siblings, 0 replies; 14+ messages in thread
From: sashiko-bot @ 2026-12-05 1:11 UTC (permalink / raw)
To: Luka Panio; +Cc: dri-devel, linux-leds, devicetree, robh, conor+dt, lee
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] backlight: aw99706: skip hwen_delay_us in aw99706_probe()
without enable-gpios
- [Medium] backlight: aw99706: missing hwen_delay_us in
aw99706_hw_init() on resume
- [Medium] backlight: aw99706: aw->bl_enable desynced when enable-gpios
is omitted
--
commit 33423fef0e8fe321782e20dbb975455055809999
Author: Luka Panio <lukapanio@gmail.com>
backlight: aw99706: Add AW99703 support
This commit adds support for the Awinic AW99703 3-channel WLED backlight
driver to the aw99706 driver, including optional vin regulator and enable
GPIO handling, a label property, and an HWEN startup delay.
> diff --git a/drivers/video/backlight/aw99706.c b/drivers/video/backlight/aw99706.c
> index 5e0f8ccd3c88e..f898df0d4ed15 100644
> --- a/drivers/video/backlight/aw99706.c
> +++ b/drivers/video/backlight/aw99706.c
[ ... ]
> @@ -456,12 +611,19 @@ static int aw99706_probe(struct i2c_client *client)
>
> aw99706_dt_parse(aw, &props);
>
> - aw->hwen_gpio = devm_gpiod_get(aw->dev, "enable", GPIOD_OUT_LOW);
> + ret = devm_regulator_get_enable_optional(dev, "vin");
> + if (ret < 0 && ret != -ENODEV)
> + return dev_err_probe(dev, ret, "Failed to enable vin supply\n");
> +
> + aw->hwen_gpio = devm_gpiod_get_optional(aw->dev, "enable",
> + GPIOD_OUT_LOW);
> if (IS_ERR(aw->hwen_gpio))
> return dev_err_probe(dev, PTR_ERR(aw->hwen_gpio),
> "Failed to get enable gpio\n");
[Severity: Medium]
Can aw->bl_enable get out of sync with the hardware when enable-gpios is
omitted?
Without an enable GPIO, probe neither resets the chip nor reads
chip->en_reg, so aw->bl_enable stays false even if the bootloader left the
backlight enabled. A later aw99706_update_brightness(aw, 0) when blanking
the backlight then skips aw99706_bl_enable(aw, false), leaving the boost
converter active. Initializing aw->bl_enable from chip->en_reg or issuing
a software reset when no enable GPIO is present would keep the cached state
aligned.
>
> gpiod_set_value_cansleep(aw->hwen_gpio, 1);
> + if (aw->hwen_gpio && aw->chip->hwen_delay_us)
> + fsleep(aw->chip->hwen_delay_us);
>
> ret = aw99706_chip_id_read(aw);
[Severity: Medium]
Should the hwen_delay_us wait also run when vin-supply powers the chip
without enable-gpios?
When HWEN is tied high to VIN and enable-gpios is omitted,
devm_regulator_get_enable_optional() enables the supply but aw->hwen_gpio
is NULL, so fsleep() is skipped. aw99706_chip_id_read() then accesses the
chip before the 3.5 ms startup window completes, which can NACK over I2C
and fail probe with -ENODEV.
[Severity: Medium]
Does aw99706_hw_init() also need to wait aw->chip->hwen_delay_us after
asserting aw->hwen_gpio?
aw99706_resume() calls aw99706_hw_init() directly, which drives
aw->hwen_gpio high and immediately issues I2C writes for aw->init_tbl[].
If HWEN dropped low during suspend or hibernation, skipping the 3.5 ms
startup delay on AW99703 can cause those transfers to fail and leave the
backlight uninitialized after resume.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261205005118.884885-1-lukapanio@gmail.com?part=6
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 2/6] dt-bindings: leds: backlight: Add Awinic AW99703 backlight
2026-12-05 0:51 ` [PATCH v2 2/6] dt-bindings: leds: backlight: Add Awinic AW99703 backlight Luka Panio
2026-12-05 1:04 ` sashiko-bot
@ 2026-12-05 9:55 ` Andreas Kemnade
1 sibling, 0 replies; 14+ messages in thread
From: Andreas Kemnade @ 2026-12-05 9:55 UTC (permalink / raw)
To: Luka Panio
Cc: lee, danielt, jingoohan1, pavel, robh, krzk+dt, conor+dt, deller,
griffin, junjie.cao, mitltlatltl, dri-devel, linux-leds,
devicetree, linux-fbdev, linux-kernel
On Sat, 5 Dec 2026 01:51:14 +0100
Luka Panio <lukapanio@gmail.com> wrote:
> The Awinic AW99703 is a 3-channel WLED driver with an integrated boost
> converter and 11-bit brightness control over I2C, optionally combined
> with a PWM input.
>
> Signed-off-by: Luka Panio <lukapanio@gmail.com>
> ---
[...]
> +
> + awinic,pwm-input:
> + description:
> + The PWM input pin is connected and its duty cycle is combined with the
> + brightness set over I2C.
> + type: boolean
> +
Hmm, shouln't this be a type object and a phandle for a pwm intput.
But no idea what is a sane way to translate brightness input into pwm
duty cycle and brightness register setting.
The driver can just ignore that for now.
Regards,
Andreas
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 0/6] backlight: aw99706: Add Awinic AW99703 support
2026-12-05 0:51 [PATCH v2 0/6] backlight: aw99706: Add Awinic AW99703 support Luka Panio
` (5 preceding siblings ...)
2026-12-05 0:51 ` [PATCH v2 6/6] backlight: aw99706: Add AW99703 support Luka Panio
@ 2026-12-05 12:16 ` Andreas Kemnade
6 siblings, 0 replies; 14+ messages in thread
From: Andreas Kemnade @ 2026-12-05 12:16 UTC (permalink / raw)
To: Luka Panio
Cc: lee, danielt, jingoohan1, pavel, robh, krzk+dt, conor+dt, deller,
griffin, junjie.cao, mitltlatltl, dri-devel, linux-leds,
devicetree, linux-fbdev, linux-kernel
On Sat, 5 Dec 2026 01:51:12 +0100
Luka Panio <lukapanio@gmail.com> wrote:
> The Awinic AW99703 is a 3-channel WLED driver with an integrated boost
> converter and 11-bit brightness control over I2C, used for the panel
> backlight of the Nexphone (QCM6490).
>
A general word to the process here:
My devicetree has something like this:
&i2c1 {
pinctrl-names = "default","sleep";
pinctrl-0 = <&pinctrl_i2c1>;
pinctrl-1 = <&pinctrl_i2c1_sleep>;
clock-frequency = <100000>;
status = "okay";
/* backlight aw99703 at 0x36 */
};
The idea is to describe the hardware as good as possible, as well as indicating
a source of possible testes and helpers. I buy the device after having the
impression that I could do what I want to do with it. Then I put together things
and am happy if they compile and basically work. Then I replace drivers with
cleaner ones.
I am wondering if the process can be more automated to that comments like that
would lead to being automatically added in driver submissions.
> As suggested on v1, this version adds the AW99703 to the existing aw99706
> driver instead of adding a new one. The two chips share the programming
> model but have different register maps, so the driver is first converted
> to per-chip data. Following the binding review, the AW99703 binding uses
> the standard led-sources and led-max-microamp properties, and the
> AW99706 binding gains led-max-microamp as well, with the vendor
> awinic,iled-max-microamp property deprecated but still read.
>
> Patch 3 is a fix for the existing driver: the chip ID was read before
> HWEN was asserted.
>
> Andreas, your Kobo Clara 2e series [1] adds a separate aw99703 driver
> and binding for the same chip. Hopefully we can settle on 1 driver,
> please test this driver and let me know if it works for you, or you
> have any other ideas.
>
I added the led-sources property and tested:
Issues found:
- After booting I found that backlight in sysfs is set to 1023, but
backlight is off. After a suspend resume
cycle, backlight is on. Test was done from a minimal initramfs system without
any userspace controlling the backlight
Expected behaviour: brightness value in sysfs matches the hardware
state and is the same before and after suspend.
- hwen/regulator stays on even when backlight is off
(can be solved after this series is in with a bit more thought)
Regards,
Andreas
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2026-12-05 12:16 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-05 0:51 [PATCH v2 0/6] backlight: aw99706: Add Awinic AW99703 support Luka Panio
2026-12-05 0:51 ` [PATCH v2 1/6] dt-bindings: leds: backlight: aw99706: Use standard led-max-microamp Luka Panio
2026-12-05 1:01 ` sashiko-bot
2026-12-05 0:51 ` [PATCH v2 2/6] dt-bindings: leds: backlight: Add Awinic AW99703 backlight Luka Panio
2026-12-05 1:04 ` sashiko-bot
2026-12-05 9:55 ` Andreas Kemnade
2026-12-05 0:51 ` [PATCH v2 3/6] backlight: aw99706: Enable the chip before reading its ID Luka Panio
2026-12-05 1:05 ` sashiko-bot
2026-12-05 0:51 ` [PATCH v2 4/6] backlight: aw99706: Introduce per-chip data Luka Panio
2026-12-05 0:51 ` [PATCH v2 5/6] backlight: aw99706: Support the led-max-microamp property Luka Panio
2026-12-05 0:59 ` sashiko-bot
2026-12-05 0:51 ` [PATCH v2 6/6] backlight: aw99706: Add AW99703 support Luka Panio
2026-12-05 1:11 ` sashiko-bot
2026-12-05 12:16 ` [PATCH v2 0/6] backlight: aw99706: Add Awinic " Andreas Kemnade
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox