[PATCH v3 07/10] leds: pca995x: Make output gain configurable
From: Nora Schiffer
Date: Tue Sep 22 2026 - 10:58:58 EST
The output gain linearly configures the LED current in 255 levels; the
absolute current depends on both the gain value and the R_ext resistor
connected to the LED driver. Make the gain configurable in the Device
Tree instead of hardcoding it to 128, allowing to adjust the current
for different hardware designs.
Signed-off-by: Nora Schiffer <nora.schiffer@xxxxxxxxxxxxxxx>
---
drivers/leds/leds-pca995x.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/leds/leds-pca995x.c b/drivers/leds/leds-pca995x.c
index b528b2b4990a7..13cce0c3fdc19 100644
--- a/drivers/leds/leds-pca995x.c
+++ b/drivers/leds/leds-pca995x.c
@@ -127,6 +127,7 @@ static int pca995x_probe(struct i2c_client *client)
struct pca995x_chip *chip;
struct pca995x_led *led;
int i, reg, ret;
+ u32 iref;
chipdef = device_get_match_data(&client->dev);
@@ -154,6 +155,11 @@ static int pca995x_probe(struct i2c_client *client)
i2c_set_clientdata(client, chip);
+ if (device_property_read_u32(dev, "nxp,output-gain", &iref))
+ iref = PCA995X_IREFALL_HALF_CFG;
+ else if (iref > PCA995X_IREFALL_FULL_CFG)
+ return dev_err_probe(dev, -EINVAL, "invalid nxp,output-gain\n");
+
device_for_each_child_node_scoped(dev, child) {
ret = fwnode_property_read_u32(child, "reg", ®);
if (ret)
@@ -178,7 +184,7 @@ static int pca995x_probe(struct i2c_client *client)
goto err_put_nodes;
/* IREF Output current value for all LEDn outputs */
- ret = regmap_write(chip->regmap, chipdef->irefall, PCA995X_IREFALL_HALF_CFG);
+ ret = regmap_write(chip->regmap, chipdef->irefall, iref);
if (ret)
goto err_put_nodes;
--
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
https://www.tq-group.com/