From: "Nuno Sá" <noname.nuno@gmail.com>
To: Guenter Roeck <linux@roeck-us.net>,
nuno.sa@analog.com, linux-hwmon@vger.kernel.org,
linux-gpio@vger.kernel.org, devicetree@vger.kernel.org,
linux-doc@vger.kernel.org
Cc: Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Jean Delvare <jdelvare@suse.com>,
Jonathan Corbet <corbet@lwn.net>,
Linus Walleij <linus.walleij@linaro.org>,
Bartosz Golaszewski <brgl@bgdev.pl>,
"Rob Herring (Arm)" <robh@kernel.org>,
Linus Walleij <linusw@kernel.org>,
Bartosz Golaszewski <brgl@kernel.org>
Subject: Re: [PATCH v5 0/3] hwmon: Add support for the LTC4283 Hot Swap Controller
Date: Wed, 28 Jan 2026 18:07:24 +0000 [thread overview]
Message-ID: <e5b775065b92cada730f42a3d60546700ec46db9.camel@gmail.com> (raw)
In-Reply-To: <02b7cf63-4f87-4cdd-8d9e-53a7d0e808a6@roeck-us.net>
On Wed, 2026-01-28 at 08:55 -0800, Guenter Roeck wrote:
> On Wed, Jan 28, 2026 at 02:04:35AM -0800, Guenter Roeck wrote:
> > On 1/28/26 01:44, Nuno Sá wrote:
> > > Hi Guenter,
> > >
> > > On Tue, 2026-01-27 at 09:39 -0800, Guenter Roeck wrote:
> > > > Hi Nuno,
> > > >
> > > > On 12/23/25 04:21, Nuno Sá via B4 Relay wrote:
> > > > > This is v3 for the LTC4283 how swap controller. Main change is that I'm
> > > > > now using the auxiliary bus for adding the GPIO device (done depending
> > > > > on FW properties).
> > > > >
> > > > > Similar to the LTC4282 device, we're clearing some fault logs in the
> > > > > reset_history attributes.
> > > > >
> > > >
> > > > I ran the patch series through an AI review. Results are below.
> > > > Please take a look.
> > > >
>
> Another run through AI below. Please let me know if there are further inaccuracies.
>
> Thanks,
> Guenter
>
> ---
> commit 82433332ce165903d56fae327ced975aeef30475
> Author: Nuno Sá <nuno.sa@analog.com>
>
> hwmon: ltc4283: Add support for the LTC4283 Swap Controller
>
> Adds support for the LTC4283 Hot Swap Controller I2C interface.
>
> > diff --git a/drivers/hwmon/ltc4283.c b/drivers/hwmon/ltc4283.c
> > new file mode 100644
> > index 000000000000..402b53f81548
> > --- /dev/null
> > +++ b/drivers/hwmon/ltc4283.c
>
> [ ... ]
>
> > +static int ltc4283_read_power_word(const struct ltc4283_hwmon *st,
> > + u32 reg, long *val)
> > +{
> > + u64 temp = (u64)LTC4283_ADC1_FS_uV * LTC4283_ADC2_FS_mV * DECA * MILLI;
> > + unsigned int __raw;
> > + int ret;
> > +
> > + ret = regmap_read(st->map_word, reg, &__raw);
> > + if (ret)
> > + return ret;
> > +
> > + /*
> > + * Power is given by:
> > + * P = CODE(16b) * 32.768mV * 2.048V / (2^16 * Rsense)
> > + */
> > + *val = DIV64_U64_ROUND_CLOSEST(temp * __raw, BIT_ULL(16) * st->rsense);
>
> Does this overflow *val on 32-bit systems if the calculated power exceeds
> 2000 Watts (approx 2^31 microWatts)? The intermediate calculation is
> u64, but the result is assigned to a signed long.
>
I'll have to double check this one but IIRC 2000W is not a realistic value for
these applications. One thing that could overflow is power_max given that the default
register value is 0xff but we do write the proper max value depending on
rsense (I actually need to check how will this behave in case we use a default
rsense value - ie with no DT property).
> [ ... ]
>
> > +static bool ltc4283_word_reg(struct device *dev, unsigned int reg)
> > +{
> > + switch (reg) {
> > + case LTC4283_SENSE ... LTC4283_ADIO34_MAX:
> > + return true;
> > + default:
> > + return false;
> > + }
> > +}
>
> LTC4283_SENSE is 0x41 and LTC4283_ADIO34_MAX is 0x40. Does this invalid
> range (start > end) effectively disable access to the word registers
> via st->map_word?
The above is odd ad I'm pretty sure I ran sensors on this but could be some late edit
mistake. Anyways irrelevant for the next version as you prefer the custom bus regmap
approach.
>
> > +static const struct regmap_config ltc4283_word_regmap_config = {
> > + .name = "ltc4283-16",
> > + .reg_bits = 8,
> > + .val_bits = 16,
> > + .max_register = LTC4283_ADIO34_MAX,
> > + .val_format_endian = REGMAP_ENDIAN_BIG,
> > + .writeable_reg = ltc4283_word_reg,
> > + .readable_reg = ltc4283_word_reg,
> > +};
>
> Does max_register = 0x40 prevent access to the sensor value registers
> (LTC4283_SENSE at 0x41 and above) which are intended to be read as
> words?
ditto
>
> commit 5998c620fbd8915340a4b92635c9489a91fae567
> Author: Nuno Sá <nuno.sa@analog.com>
>
> gpio: gpio-ltc4283: Add support for the LTC4283 Swap Controller
>
> Adds GPIO support for the LTC4283.
>
> > diff --git a/drivers/gpio/gpio-ltc4283.c b/drivers/gpio/gpio-ltc4283.c
> > new file mode 100644
> > index 000000000000..fa0c106d4fac
> > --- /dev/null
> > +++ b/drivers/gpio/gpio-ltc4283.c
>
> [ ... ]
>
> > +#define LTC4283_PINS_MAX 8
> > +#define LTC4283_PGIOX_START_NR 4
> > +#define LTC4283_INPUT_STATUS 0x02
> > +#define LTC4283_PGIO_CONFIG 0x10
> > +#define LTC4283_PGIO_CFG_MASK(pin)
> > + GENMASK(((pin) - LTC4283_PGIOX_START_NR) * 2 + 1, (((pin) - LTC4283_PGIOX_START_NR) *
> > 2))
> > +#define LTC4283_PGIO_CONFIG_2 0x11
> > +
> > +#define LTC42823_ADIO_CONFIG 0x12
>
> This isn't a bug, but should this be LTC4283_ADIO_CONFIG instead of
> LTC42823?
Indeed!
- Nuno Sá
2
next prev parent reply other threads:[~2026-01-28 18:06 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-23 12:21 [PATCH v5 0/3] hwmon: Add support for the LTC4283 Hot Swap Controller Nuno Sá via B4 Relay
2025-12-23 12:21 ` [PATCH v5 1/3] dt-bindings: hwmon: Document the LTC4283 " Nuno Sá via B4 Relay
2025-12-23 12:21 ` [PATCH v5 2/3] hwmon: ltc4283: Add support for " Nuno Sá via B4 Relay
2025-12-23 12:21 ` [PATCH v5 3/3] gpio: gpio-ltc4283: " Nuno Sá via B4 Relay
2026-01-18 0:27 ` [PATCH v5 0/3] hwmon: Add support for the LTC4283 Hot " Guenter Roeck
2026-01-18 10:12 ` Nuno Sá
2026-01-18 15:39 ` Guenter Roeck
2026-02-17 13:39 ` Nuno Sá
2026-02-21 1:17 ` Guenter Roeck
2026-01-27 17:39 ` Guenter Roeck
2026-01-28 9:44 ` Nuno Sá
2026-01-28 10:04 ` Guenter Roeck
2026-01-28 16:55 ` Guenter Roeck
2026-01-28 18:07 ` Nuno Sá [this message]
2026-01-28 18:22 ` Guenter Roeck
2026-02-02 9:40 ` Nuno Sá
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=e5b775065b92cada730f42a3d60546700ec46db9.camel@gmail.com \
--to=noname.nuno@gmail.com \
--cc=brgl@bgdev.pl \
--cc=brgl@kernel.org \
--cc=conor+dt@kernel.org \
--cc=corbet@lwn.net \
--cc=devicetree@vger.kernel.org \
--cc=jdelvare@suse.com \
--cc=krzk+dt@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linusw@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=nuno.sa@analog.com \
--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