devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
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>
Subject: Re: [PATCH v4 2/3] hwmon: ltc4283: Add support for the LTC4283 Swap Controller
Date: Tue, 16 Dec 2025 13:17:17 +0000	[thread overview]
Message-ID: <50bea4bef338490cae92f61a8cc9a555db4529c2.camel@gmail.com> (raw)
In-Reply-To: <ca659699-e5f8-436f-bfdb-d0d250d34fca@roeck-us.net>

On Fri, 2025-12-12 at 09:07 -0800, Guenter Roeck wrote:
> On 12/12/25 08:50, Nuno Sá wrote:
> > On Thu, 2025-12-11 at 09:56 -0800, Guenter Roeck wrote:
> > > On 12/4/25 08:15, Nuno Sá via B4 Relay wrote:
> > > > From: Nuno Sá <nuno.sa@analog.com>
> > > > 
> > > > Support the LTC4283 How Swap Controller. The device features programmable
> > > > current limit with foldback and independently adjustable inrush current to
> > > > optimize the MOSFET safe operating area (SOA). The SOA timer limits MOSFET
> > > > temperature rise for reliable protection against overstresses.
> > > > 
> > > > An I2C interface and onboard ADC allow monitoring of board current,
> > > > voltage, power, energy, and fault status.
> > > > 
> > > > Signed-off-by: Nuno Sá <nuno.sa@analog.com>
> > > > ---
> > > ...
> > > > diff --git a/drivers/hwmon/ltc4283.c b/drivers/hwmon/ltc4283.c
> > > > new file mode 100644
> > > > index 000000000000..d79432678b84
> > > > --- /dev/null
> > > > +++ b/drivers/hwmon/ltc4283.c
> > > ...
> > > > +
> > > > +static int ltc4283_read_voltage_word(const struct ltc4283_hwmon *st,
> > > > +				     u32 reg, u32 fs, long *val)
> > > > +{
> > > > +	__be16 in;
> > > > +	int ret;
> > > > +
> > > > +	ret = regmap_bulk_read(st->map, reg, &in, sizeof(in));
> > > 
> > > I had a look into the regmap code. In its current implementation,
> > > that will work as long as
> > > 1) regmap is configured to not cache anything
> > > 2) the I2C controller supports I2C_FUNC_SMBUS_I2C_BLOCK
> > > 
> > 
> > Possibly dumb question... what would be the issue about doing multiple
> > regmap reads if we can't do the bulk? That would be my naive approach in
> > the driver if I'm not going to use the bulk API.
> > 
> 
> You mean on the same address ? I don't have the chip to check, but I am quite
> sure that it would return the 1st byte again.
> 
> FWIW, in the lm92 driver I used a regmap_bus to solve pretty much the same
> problem.
> 
> 

Ok, I know understand the issue. We do have real word registers (though the energy
spans 6 registers IIRC) in which case the regmap bulk fallback would fail. So I do
agree with you that relying on regmap implementation details is questionable so
I'll add my own bus.

But the above made me start thinking about how we should handle
i2c_check_functionality()? For this device, I2C_FUNC_SMBUS_WORD_DATA and
I2C_FUNC_SMBUS_BYTE_DATA (can we have word without byte??) are the minimum the
controller needs to support. So I could add the below:

if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA
				    | I2C_FUNC_SMBUS_WORD_DATA))
		return -ENODEV;

But can't we have I2C_FUNC_I2C (or even I2C_FUNC_SMBUS_I2C_BLOCK) without
supporting SMBUS?

I mean, I can so something similar to what's being done in regmap-i2c but maybe
that's too much? I'm leaning in that direction though...


This made me wonder, again, about ltc4282 but in there word registers are in
fact reg and reg + 1.

- Nuno Sá

  reply	other threads:[~2025-12-16 13:16 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-04 16:15 [PATCH v4 0/3] hwmon: Add support for the LTC4283 Hot Swap Controller Nuno Sá via B4 Relay
2025-12-04 16:15 ` [PATCH v4 1/3] dt-bindings: hwmon: Document the LTC4283 " Nuno Sá via B4 Relay
2025-12-04 16:15 ` [PATCH v4 2/3] hwmon: ltc4283: Add support for " Nuno Sá via B4 Relay
2025-12-06 18:40   ` Guenter Roeck
2025-12-12 16:34     ` Nuno Sá
2025-12-12 16:46       ` Guenter Roeck
2025-12-12 16:55         ` Nuno Sá
2025-12-12 17:21           ` Guenter Roeck
2025-12-12 17:31           ` Guenter Roeck
2025-12-11 17:56   ` Guenter Roeck
2025-12-12 16:50     ` Nuno Sá
2025-12-12 17:07       ` Guenter Roeck
2025-12-16 13:17         ` Nuno Sá [this message]
2025-12-15  8:20   ` Tomas Melin
2025-12-15 14:04     ` Guenter Roeck
2025-12-04 16:15 ` [PATCH v4 3/3] gpio: gpio-ltc4283: " Nuno Sá via B4 Relay
2025-12-10 23:46   ` Linus Walleij

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=50bea4bef338490cae92f61a8cc9a555db4529c2.camel@gmail.com \
    --to=noname.nuno@gmail.com \
    --cc=brgl@bgdev.pl \
    --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=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 \
    /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;
as well as URLs for NNTP newsgroup(s).