[PATCH v5 07/11] leds: pca995x: Make output gain configurable

From: Nora Schiffer

Date: Mon Oct 05 2026 - 10:00:08 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 | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/leds/leds-pca995x.c b/drivers/leds/leds-pca995x.c
index b528b2b4990a7..df3f7ab2e1f87 100644
--- a/drivers/leds/leds-pca995x.c
+++ b/drivers/leds/leds-pca995x.c
@@ -122,6 +122,7 @@ static int pca995x_probe(struct i2c_client *client)
{
struct fwnode_handle *led_fwnodes[PCA995X_MAX_OUTPUTS] = { 0 };
struct device *dev = &client->dev;
+ u32 val, iref = PCA995X_IREFALL_HALF_CFG;
const struct pca995x_chipdef *chipdef;
struct gpio_desc *reset_gpio;
struct pca995x_chip *chip;
@@ -154,6 +155,13 @@ static int pca995x_probe(struct i2c_client *client)

i2c_set_clientdata(client, chip);

+ if (!device_property_read_u32(dev, "nxp,output-gain", &val)) {
+ if (val > PCA995X_IREFALL_FULL_CFG)
+ return dev_err_probe(dev, -EINVAL, "invalid nxp,output-gain\n");
+
+ iref = val;
+ }
+
device_for_each_child_node_scoped(dev, child) {
ret = fwnode_property_read_u32(child, "reg", &reg);
if (ret)
@@ -178,7 +186,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/