[PATCH 4/7] leds: pca995x: make output gain configurable

From: Nora Schiffer

Date: Wed Sep 02 2026 - 08:34:06 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 8eb9847b9709f..b069b93d39a54 100644
--- a/drivers/leds/leds-pca995x.c
+++ b/drivers/leds/leds-pca995x.c
@@ -126,6 +126,7 @@ static int pca995x_probe(struct i2c_client *client)
struct pca995x_chip *chip;
struct pca995x_led *led;
int i, j, reg, ret;
+ u32 iref;

chipdef = device_get_match_data(&client->dev);

@@ -153,6 +154,11 @@ static int pca995x_probe(struct i2c_client *client)

i2c_set_clientdata(client, chip);

+ if (device_property_read_u32(dev, "output-gain", &iref))
+ iref = PCA995X_IREFALL_HALF_CFG;
+ else if (iref > PCA995X_IREFALL_FULL_CFG)
+ return dev_err_probe(dev, -EINVAL, "invalid output-gain\n");
+
device_for_each_child_node_scoped(dev, child) {
ret = fwnode_property_read_u32(child, "reg", &reg);
if (ret)
@@ -195,7 +201,7 @@ static int pca995x_probe(struct i2c_client *client)
return ret;

/* IREF Output current value for all LEDn outputs */
- return regmap_write(chip->regmap, chipdef->irefall, PCA995X_IREFALL_HALF_CFG);
+ return regmap_write(chip->regmap, chipdef->irefall, iref);
}

static const struct i2c_device_id pca995x_id[] = {
--
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/