[PATCH 0/6] mfd: Add support for the LTC4283 Hot Swap Controller

Nuno Sá via B4 Relay posted 6 patches 1 month, 3 weeks ago
.../devicetree/bindings/gpio/adi,ltc4283.yaml      |   33 +
.../devicetree/bindings/hwmon/adi,ltc4283.yaml     |  159 ++
.../devicetree/bindings/mfd/adi,ltc4283.yaml       |   85 +
Documentation/hwmon/ltc4283.rst                    |  266 ++++
MAINTAINERS                                        |   13 +
drivers/gpio/Kconfig                               |   10 +
drivers/gpio/Makefile                              |    1 +
drivers/gpio/gpio-ltc4283.c                        |  233 +++
drivers/hwmon/Kconfig                              |   10 +
drivers/hwmon/Makefile                             |    1 +
drivers/hwmon/ltc4283-hwmon.c                      | 1658 ++++++++++++++++++++
drivers/mfd/Kconfig                                |   11 +
drivers/mfd/Makefile                               |    1 +
drivers/mfd/ltc4283.c                              |  140 ++
include/linux/mfd/ltc4283.h                        |   33 +
15 files changed, 2654 insertions(+)
[PATCH 0/6] mfd: Add support for the LTC4283 Hot Swap Controller
Posted by Nuno Sá via B4 Relay 1 month, 3 weeks ago
The LTC4283 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.

It also features 8 pins that can be configured as GPIO devices. But since
the main usage for this device is monitoring, the GPIO part is optional
while the HWMON is being made as required.

Also to note that the device has some similarities with the already
supported ltc4282 hwmon driver but it is different enough to be in it's own
driver (apart from being added as MFD). The register map is also fairly
different.

Last time (for the ltc4282) I tried to add the gpio bits directly in the
hwmon driver but Guenter did not really liked it and so this time I'm doing
it as MFD.
 

---
Nuno Sá (6):
      dt-binbings: mfd: Add bindings for the LTC4283 Swap Controller
      mfd: ltc4283: Add support for the LTC4283 Swap Controller
      dt-binbings: hwmon: Add bindings for the LTC4283 Swap Controller
      hwmon: ltc4283-hwmon: Add support for the LTC4283 Swap Controller
      dt-binbings: gpio: Add bindings for the LTC4283 Swap Controller
      gpio: gpio-ltc4283: Add support for the LTC4283 Swap Controller

 .../devicetree/bindings/gpio/adi,ltc4283.yaml      |   33 +
 .../devicetree/bindings/hwmon/adi,ltc4283.yaml     |  159 ++
 .../devicetree/bindings/mfd/adi,ltc4283.yaml       |   85 +
 Documentation/hwmon/ltc4283.rst                    |  266 ++++
 MAINTAINERS                                        |   13 +
 drivers/gpio/Kconfig                               |   10 +
 drivers/gpio/Makefile                              |    1 +
 drivers/gpio/gpio-ltc4283.c                        |  233 +++
 drivers/hwmon/Kconfig                              |   10 +
 drivers/hwmon/Makefile                             |    1 +
 drivers/hwmon/ltc4283-hwmon.c                      | 1658 ++++++++++++++++++++
 drivers/mfd/Kconfig                                |   11 +
 drivers/mfd/Makefile                               |    1 +
 drivers/mfd/ltc4283.c                              |  140 ++
 include/linux/mfd/ltc4283.h                        |   33 +
 15 files changed, 2654 insertions(+)
---
base-commit: 9703c672af8dd3573c76ce509dfff26bf6c4768d
change-id: 20250812-ltc4283-support-27c8c4e69c6b
--

Thanks!
- Nuno Sá


Re: [PATCH 0/6] mfd: Add support for the LTC4283 Hot Swap Controller
Posted by Linus Walleij 1 month, 2 weeks ago
On Thu, Aug 14, 2025 at 12:52 PM Nuno Sá via B4 Relay
<devnull+nuno.sa.analog.com@kernel.org> wrote:

> The LTC4283 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.
>
> It also features 8 pins that can be configured as GPIO devices. But since
> the main usage for this device is monitoring, the GPIO part is optional
> while the HWMON is being made as required.

This main device just screams Industrial I/O, IIO.

(I think it's fine to use an MFD core and split off GPIO to a
separate driver, and I suggest maybe you merge MFD and
GPIO ahead of the main driver.)

Jonathan (Cameron) will have the last word on it but IMO this firmly
belongs below drivers/iio.

Perhaps not in one of the existing subdirs there but then it is time to
be brave and create a new one.

It will take some time and consideration, but I think it would be better
for everyone.

Yours,
Linus Walleij
Re: [PATCH 0/6] mfd: Add support for the LTC4283 Hot Swap Controller
Posted by Guenter Roeck 1 month, 2 weeks ago
On 8/19/25 05:36, Linus Walleij wrote:
> On Thu, Aug 14, 2025 at 12:52 PM Nuno Sá via B4 Relay
> <devnull+nuno.sa.analog.com@kernel.org> wrote:
> 
>> The LTC4283 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.
>>
>> It also features 8 pins that can be configured as GPIO devices. But since
>> the main usage for this device is monitoring, the GPIO part is optional
>> while the HWMON is being made as required.
> 
> This main device just screams Industrial I/O, IIO.
> 

Really ? I would have assumed that the sensors on a chip like this are supposed
to be used for hardware monitoring, and that IIO is supposed to be used in cases
where the data itself is the relevant information. What exactly makes a hot swap
controller screaming IIO ? Am I missing something here ?

I am not going to argue about this if IIO wants to extend into hardware monitoring,
I just wonder about the rationale behind it.

Thanks,
Guenter

> (I think it's fine to use an MFD core and split off GPIO to a
> separate driver, and I suggest maybe you merge MFD and
> GPIO ahead of the main driver.)
> 
> Jonathan (Cameron) will have the last word on it but IMO this firmly
> belongs below drivers/iio.
> 
> Perhaps not in one of the existing subdirs there but then it is time to
> be brave and create a new one.
> 
> It will take some time and consideration, but I think it would be better
> for everyone.
> 
> Yours,
> Linus Walleij
> 

Re: [PATCH 0/6] mfd: Add support for the LTC4283 Hot Swap Controller
Posted by Linus Walleij 1 month, 2 weeks ago
On Tue, Aug 19, 2025 at 6:11 PM Guenter Roeck <linux@roeck-us.net> wrote:
> On 8/19/25 05:36, Linus Walleij wrote:
> > On Thu, Aug 14, 2025 at 12:52 PM Nuno Sá via B4 Relay
> > <devnull+nuno.sa.analog.com@kernel.org> wrote:
> >
> >> The LTC4283 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.
> >>
> >> It also features 8 pins that can be configured as GPIO devices. But since
> >> the main usage for this device is monitoring, the GPIO part is optional
> >> while the HWMON is being made as required.
> >
> > This main device just screams Industrial I/O, IIO.
> >
>
> Really ? I would have assumed that the sensors on a chip like this are supposed
> to be used for hardware monitoring, and that IIO is supposed to be used in cases
> where the data itself is the relevant information. What exactly makes a hot swap
> controller screaming IIO ? Am I missing something here ?
>
> I am not going to argue about this if IIO wants to extend into hardware monitoring,
> I just wonder about the rationale behind it.

It was mainly because the text talks about regulating currents and current
rush, and an onboard ADC. There is admittedly even a bit of regulator
framework-related business going on.

On second look it's fine to keep as hwmon, discard my previous
opinion, I should have looked closer and now I changed my mind.
I'ts good with some pushback!

Yours,
Linus Walleij
Re: [PATCH 0/6] mfd: Add support for the LTC4283 Hot Swap Controller
Posted by Guenter Roeck 1 month, 3 weeks ago
On 8/14/25 03:52, Nuno Sá via B4 Relay wrote:
> The LTC4283 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.
> 
> It also features 8 pins that can be configured as GPIO devices. But since
> the main usage for this device is monitoring, the GPIO part is optional
> while the HWMON is being made as required.
> 
> Also to note that the device has some similarities with the already
> supported ltc4282 hwmon driver but it is different enough to be in it's own
> driver (apart from being added as MFD). The register map is also fairly
> different.
> 
> Last time (for the ltc4282) I tried to add the gpio bits directly in the
> hwmon driver but Guenter did not really liked it and so this time I'm doing
> it as MFD.
> 
Nowadays I suggest that people use auxiliary drivers in such situations.

Guenter

Re: [PATCH 0/6] mfd: Add support for the LTC4283 Hot Swap Controller
Posted by Nuno Sá 1 month, 3 weeks ago
On Thu, Aug 14, 2025 at 05:54:26AM -0700, Guenter Roeck wrote:
> On 8/14/25 03:52, Nuno Sá via B4 Relay wrote:
> > The LTC4283 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.
> > 
> > It also features 8 pins that can be configured as GPIO devices. But since
> > the main usage for this device is monitoring, the GPIO part is optional
> > while the HWMON is being made as required.
> > 
> > Also to note that the device has some similarities with the already
> > supported ltc4282 hwmon driver but it is different enough to be in it's own
> > driver (apart from being added as MFD). The register map is also fairly
> > different.
> > 
> > Last time (for the ltc4282) I tried to add the gpio bits directly in the
> > hwmon driver but Guenter did not really liked it and so this time I'm doing
> > it as MFD.
> > 
> Nowadays I suggest that people use auxiliary drivers in such situations.

I see. But do you have any issue with it being MFD?

I'm anyways tempted to the auxiliary device idea. The main usage for
this device is HWMON and I dunno anyone would use it only as a GPIO
controller. With the auxiliary device we would only need one bindings file
and slightly better bindings for the pins functionality.

- Nuno Sá

> 
> Guenter
> 
Re: [PATCH 0/6] mfd: Add support for the LTC4283 Hot Swap Controller
Posted by Rob Herring 1 month, 2 weeks ago
On Thu, Aug 14, 2025 at 03:15:29PM +0100, Nuno Sá wrote:
> On Thu, Aug 14, 2025 at 05:54:26AM -0700, Guenter Roeck wrote:
> > On 8/14/25 03:52, Nuno Sá via B4 Relay wrote:
> > > The LTC4283 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.
> > > 
> > > It also features 8 pins that can be configured as GPIO devices. But since
> > > the main usage for this device is monitoring, the GPIO part is optional
> > > while the HWMON is being made as required.
> > > 
> > > Also to note that the device has some similarities with the already
> > > supported ltc4282 hwmon driver but it is different enough to be in it's own
> > > driver (apart from being added as MFD). The register map is also fairly
> > > different.
> > > 
> > > Last time (for the ltc4282) I tried to add the gpio bits directly in the
> > > hwmon driver but Guenter did not really liked it and so this time I'm doing
> > > it as MFD.
> > > 
> > Nowadays I suggest that people use auxiliary drivers in such situations.
> 
> I see. But do you have any issue with it being MFD?

I do...

> I'm anyways tempted to the auxiliary device idea. The main usage for
> this device is HWMON and I dunno anyone would use it only as a GPIO
> controller. With the auxiliary device we would only need one bindings file
> and slightly better bindings for the pins functionality.

For this reason. The driver structure influencing the binding design is 
a problem, but I think MFD is more to blame on that.

Rob
Re: [PATCH 0/6] mfd: Add support for the LTC4283 Hot Swap Controller
Posted by Nuno Sá 1 month, 1 week ago
On Wed, Aug 20, 2025 at 03:03:54PM -0500, Rob Herring wrote:
> On Thu, Aug 14, 2025 at 03:15:29PM +0100, Nuno Sá wrote:
> > On Thu, Aug 14, 2025 at 05:54:26AM -0700, Guenter Roeck wrote:
> > > On 8/14/25 03:52, Nuno Sá via B4 Relay wrote:
> > > > The LTC4283 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.
> > > > 
> > > > It also features 8 pins that can be configured as GPIO devices. But since
> > > > the main usage for this device is monitoring, the GPIO part is optional
> > > > while the HWMON is being made as required.
> > > > 
> > > > Also to note that the device has some similarities with the already
> > > > supported ltc4282 hwmon driver but it is different enough to be in it's own
> > > > driver (apart from being added as MFD). The register map is also fairly
> > > > different.
> > > > 
> > > > Last time (for the ltc4282) I tried to add the gpio bits directly in the
> > > > hwmon driver but Guenter did not really liked it and so this time I'm doing
> > > > it as MFD.
> > > > 
> > > Nowadays I suggest that people use auxiliary drivers in such situations.
> > 
> > I see. But do you have any issue with it being MFD?
> 
> I do...
> 
> > I'm anyways tempted to the auxiliary device idea. The main usage for
> > this device is HWMON and I dunno anyone would use it only as a GPIO
> > controller. With the auxiliary device we would only need one bindings file
> > and slightly better bindings for the pins functionality.
> 
> For this reason. The driver structure influencing the binding design is 
> a problem, but I think MFD is more to blame on that.
> 

Alright, it seems we're aligning for auxiliary device on v2.

- Nuno Sá
> Rob
Re: [PATCH 0/6] mfd: Add support for the LTC4283 Hot Swap Controller
Posted by Guenter Roeck 1 month, 2 weeks ago
On 8/14/25 07:15, Nuno Sá wrote:
> On Thu, Aug 14, 2025 at 05:54:26AM -0700, Guenter Roeck wrote:
>> On 8/14/25 03:52, Nuno Sá via B4 Relay wrote:
>>> The LTC4283 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.
>>>
>>> It also features 8 pins that can be configured as GPIO devices. But since
>>> the main usage for this device is monitoring, the GPIO part is optional
>>> while the HWMON is being made as required.
>>>
>>> Also to note that the device has some similarities with the already
>>> supported ltc4282 hwmon driver but it is different enough to be in it's own
>>> driver (apart from being added as MFD). The register map is also fairly
>>> different.
>>>
>>> Last time (for the ltc4282) I tried to add the gpio bits directly in the
>>> hwmon driver but Guenter did not really liked it and so this time I'm doing
>>> it as MFD.
>>>
>> Nowadays I suggest that people use auxiliary drivers in such situations.
> 
> I see. But do you have any issue with it being MFD?
> 

I only object to squeezing non-hwmon code into hwmon drivers, especially since
a relatively low-overhead alternative is now available. I would not want to
implement a driver such as this one as set of mfd drivers myself, but I won't
object to it either.

Guenter