[PATCH v4 0/2] add support for Microchip PAC194X Power Monitor

marius.cristea@microchip.com posted 2 patches 4 weeks ago
.../bindings/iio/adc/microchip,pac1944.yaml   |  315 +++
MAINTAINERS                                   |    7 +
drivers/iio/adc/Kconfig                       |   12 +
drivers/iio/adc/Makefile                      |    1 +
drivers/iio/adc/pac1944.c                     | 2172 +++++++++++++++++
5 files changed, 2507 insertions(+)
create mode 100644 Documentation/devicetree/bindings/iio/adc/microchip,pac1944.yaml
create mode 100644 drivers/iio/adc/pac1944.c
[PATCH v4 0/2] add support for Microchip PAC194X Power Monitor
Posted by marius.cristea@microchip.com 4 weeks ago
From: Marius Cristea <marius.cristea@microchip.com>

Add support for Microchip PAC194X and PAC195X series of Power Monitor
with Accumulator chip family. This driver covers the following part
numbers:
 - PAC1941, PAC1941-2, PAC1942, PAC1942-2, PAC1943, PAC1944
 - PAC1951, PAC1951-2, PAC1952, PAC1952-2, PAC1953, PAC1954

The PAC194X family supports 9V Full-Scale Range and the PAC195X supports
32V Full-Scale Range.

There are two versions of the PAC194X/5X: the PAC194X-1/5X-1 devices are
for high-side current sensing and the PAC194X/5X-2 devices are for low-side
current sensing or floating VBUS applications. The PAC194X/5X-1 is named
shortly PAC194X/5X.

Differences related to previous patch:
v4:
  rewrite the driver to keep just basic functionality
- fix review comments for device tree binding:
  change compatible from "microchip,pac194(1/2)2" to "microchip,pac194(1/2)-2"
  rewrite the interrupts and interrupt-names
  add gpio-controller
  add range for input voltage and current sense voltage
  remove the long average mode from hardware accumulator
- fix review comments for the driver:
  remove custom attributes
  fix include files
  remove "non standard" frequency
  add range parsing from the device tree for Vbus and Vsense
  free acpi allocated buffers in case of early exit

v3:
- fix review comments device tree binding:
  rewrite commit message
  change the way full scale for voltage and current is set. Add a
    properties to describe if the input is bipolar or not.
  fix the "dtschema/dtc warnings/errors"
- fix review comments driver:
  simplify the driver to include just the basic functionality. More
    features will be added later.
  fix coding style issues
  change to lower case the "to_pac1944_chip_info()" to be more like
    other container_of
  remove the PAC1944_DEV_ATTR() macro
  drop the __func__ bit from error messages
  remove unneeded casts
  change the logic to reset the accumulator when is enabled
  change from {} to { }
  remove unreachable() from the code
  rewrite the code to keep the error paths out of line
  replace scoped_guard() with guard(), where was possible
  use to_delayed_work() to get from work to delayed work
  remove active_channels[] array
  print info message in case FW disagrees with what is found on the bus

v2:
- fix review comments device tree binding:
    remove underscore from names
    add names to the interrupts and list them
    add a better description for new properties
- fix review comments driver:
    fix coding style issues
    use bitmap for checking the active channels
    keep the "pac1944_get_unaligned_be56" here because the change wasn't acceted
      into the asm-generic.
    document new added attributes
    remove the "scan" part till we support buffered capture
    remove "unlikely" marking
    add masks up in some array of const structures to avoid some case statements
    remove pac1944_mutex_destroy function
    replace some functions with a macro (just for testing)
    replace dev_err with dev_err_probe in functions used in pac1944_probe

v1:
- first version committed to review

Marius Cristea (2):
  dt-bindings: iio: adc: add support for PAC1944
  iio: adc: add support for PAC194X

 .../bindings/iio/adc/microchip,pac1944.yaml   |  315 +++
 MAINTAINERS                                   |    7 +
 drivers/iio/adc/Kconfig                       |   12 +
 drivers/iio/adc/Makefile                      |    1 +
 drivers/iio/adc/pac1944.c                     | 2172 +++++++++++++++++
 5 files changed, 2507 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/adc/microchip,pac1944.yaml
 create mode 100644 drivers/iio/adc/pac1944.c


base-commit: d2a4ec19d2a2e54c23b5180e939994d3da4a6b91
-- 
2.51.0
Re: [PATCH v4 0/2] add support for Microchip PAC194X Power Monitor
Posted by Andy Shevchenko 3 weeks, 5 days ago
On Fri, May 15, 2026 at 12:29:44PM +0300, marius.cristea@microchip.com wrote:

> Add support for Microchip PAC194X and PAC195X series of Power Monitor
> with Accumulator chip family. This driver covers the following part
> numbers:
>  - PAC1941, PAC1941-2, PAC1942, PAC1942-2, PAC1943, PAC1944
>  - PAC1951, PAC1951-2, PAC1952, PAC1952-2, PAC1953, PAC1954
> 
> The PAC194X family supports 9V Full-Scale Range and the PAC195X supports
> 32V Full-Scale Range.
> 
> There are two versions of the PAC194X/5X: the PAC194X-1/5X-1 devices are
> for high-side current sensing and the PAC194X/5X-2 devices are for low-side
> current sensing or floating VBUS applications. The PAC194X/5X-1 is named
> shortly PAC194X/5X.

It still has many subtle issues...

I am not able to review in a couple of weeks, so I recommend to read mailing lists
for the previous reviews against other big driver submissions and improve yours
accordingly.

So far, on a very fast glance I have noticed:
- the IWYU principle is not being followed
- the Kconfig help text can be improved to list part numbers for better
  maintainability

-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH v4 0/2] add support for Microchip PAC194X Power Monitor
Posted by David Lechner 3 weeks, 5 days ago
On 5/15/26 4:29 AM, marius.cristea@microchip.com wrote:
> From: Marius Cristea <marius.cristea@microchip.com>
> 
> Add support for Microchip PAC194X and PAC195X series of Power Monitor
> with Accumulator chip family. This driver covers the following part
> numbers:
>  - PAC1941, PAC1941-2, PAC1942, PAC1942-2, PAC1943, PAC1944
>  - PAC1951, PAC1951-2, PAC1952, PAC1952-2, PAC1953, PAC1954
> 
> The PAC194X family supports 9V Full-Scale Range and the PAC195X supports
> 32V Full-Scale Range.
> 
> There are two versions of the PAC194X/5X: the PAC194X-1/5X-1 devices are
> for high-side current sensing and the PAC194X/5X-2 devices are for low-side
> current sensing or floating VBUS applications. The PAC194X/5X-1 is named
> shortly PAC194X/5X.
> 
I assume we already had the hwmon vs. iio conversation? I would expect
something in the cover letter justifying why this should be an iio device
rather than hwmon since it looks like it was designed for monitoring
e.g. CPU voltage.