From: Sander Vanheule <sander@svanheule.net>
To: Edelweise Escala <edelweise.escala@analog.com>,
Lee Jones <lee@kernel.org>, Pavel Machek <pavel@kernel.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>
Cc: linux-leds@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v7 2/2] leds: ltc3220: Add Support for LTC3220 18 channel LED Driver
Date: Sun, 10 May 2026 11:07:48 +0200 [thread overview]
Message-ID: <32d4a57c074c766c8ad83e4b220e44b1df9ae485.camel@svanheule.net> (raw)
In-Reply-To: <20260508-ltc3220-driver-v7-2-0f092ba54f23@analog.com>
Hi Edelweise,
On Fri, 2026-05-08 at 12:09 +0800, Edelweise Escala wrote:
> +static const struct regmap_config ltc3220_regmap_config = {
> + .reg_bits = 8,
> + .val_bits = 8,
> + .max_register = LTC3220_GRAD_BLINK_REG,
> + .cache_type = REGCACHE_FLAT,
> + .volatile_reg = ltc3220_volatile_reg,
> +};
With this config, you are assuming that all register values will default to 0,
otherwise the cache will not work properly. While the datasheet seems to
indicate this is the case, I also suspect you are now seeing the warning
"using zero-initialized flat cache, this may cause unexpected behavior"
I would suggest to use REGCACHE_FLAT_S instead.
[...]
> +static int ltc3220_reset(struct ltc3220 *ltc3220, struct i2c_client *client)
> +{
> + struct gpio_desc *reset_gpio;
> + int ret;
> +
> + reset_gpio = devm_gpiod_get_optional(&client->dev, "reset",
> GPIOD_OUT_HIGH);
> + if (IS_ERR(reset_gpio))
> + return dev_err_probe(&client->dev, PTR_ERR(reset_gpio),
> "Failed on reset GPIO\n");
> +
> + if (reset_gpio) {
> + gpiod_set_value_cansleep(reset_gpio, 0);
> +
> + return devm_add_action_or_reset(&client->dev,
> ltc3220_reset_gpio_action,
> + reset_gpio);
> + }
> +
> + ret = regmap_write(ltc3220->regmap, LTC3220_COMMAND_REG, 0);
> + if (ret)
> + return ret;
> +
> + for (int i = 0; i < LTC3220_NUM_LEDS; i++) {
> + ret = regmap_write(ltc3220->regmap, LTC3220_ULED_REG(i), 0);
> + if (ret)
> + return ret;
> + }
> +
> + return regmap_write(ltc3220->regmap, LTC3220_GRAD_BLINK_REG, 0);
> +}
regmap_write() will always go to hardware, so this feels a bit like you're
manually forcing the hardware to match the cache state. The implied all-0 cache
could otherwise prevent later regmap_update_bits() calls from actually
performing a write.
> +static DEFINE_SIMPLE_DEV_PM_OPS(ltc3220_pm_ops, ltc3220_suspend,
> ltc3220_resume);
> +
> +static int ltc3220_probe(struct i2c_client *client)
> +{
> + struct ltc3220 *ltc3220;
> + bool aggregated_led_found = false;
> + int num_leds = 0;
> + u8 led_index = 0;
> + int ret;
> +
> + ltc3220 = devm_kzalloc(&client->dev, sizeof(*ltc3220), GFP_KERNEL);
> + if (!ltc3220)
> + return -ENOMEM;
> +
> + ltc3220->regmap = devm_regmap_init_i2c(client,
> <c3220_regmap_config);
> + if (IS_ERR(ltc3220->regmap))
> + return dev_err_probe(&client->dev, PTR_ERR(ltc3220->regmap),
> + "Failed to initialize regmap\n");
> +
> + i2c_set_clientdata(client, ltc3220);
> +
> + ret = ltc3220_reset(ltc3220, client);
> + if (ret)
> + return dev_err_probe(&client->dev, ret, "Failed to reset
> device\n");
Up to you if you want to clear the device configuration (maybe this causes LED
flickering?), but with REGCACHE_FLAT_S, you should be able to maintain the boot
state of the device.
Best,
Sander
prev parent reply other threads:[~2026-05-10 9:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-08 4:09 [PATCH v7 0/2] Add Support for LTC3220 18 Channel LED Driver Edelweise Escala
2026-05-08 4:09 ` [PATCH v7 1/2] dt-bindings: leds: Add LTC3220 18 channel " Edelweise Escala
2026-05-08 13:57 ` Rob Herring
2026-05-08 4:09 ` [PATCH v7 2/2] leds: ltc3220: Add Support for " Edelweise Escala
2026-05-10 9:07 ` Sander Vanheule [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=32d4a57c074c766c8ad83e4b220e44b1df9ae485.camel@svanheule.net \
--to=sander@svanheule.net \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=edelweise.escala@analog.com \
--cc=krzk+dt@kernel.org \
--cc=lee@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=pavel@kernel.org \
--cc=robh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox