[PATCH v4 0/2] iio: adc: add Nuvoton NCT7201 ADC driver

Eason Yang posted 2 patches 9 months, 4 weeks ago
There is a newer version of this series
.../bindings/iio/adc/nuvoton,nct7201.yaml     |  57 ++
MAINTAINERS                                   |   2 +
drivers/iio/adc/Kconfig                       |  11 +
drivers/iio/adc/Makefile                      |   1 +
drivers/iio/adc/nct7201.c                     | 487 ++++++++++++++++++
5 files changed, 558 insertions(+)
create mode 100644 Documentation/devicetree/bindings/iio/adc/nuvoton,nct7201.yaml
create mode 100644 drivers/iio/adc/nct7201.c
[PATCH v4 0/2] iio: adc: add Nuvoton NCT7201 ADC driver
Posted by Eason Yang 9 months, 4 weeks ago
Change since version 4:
 - Fix comments
 - Add interrupts and reset-gpios to the DT example
 - Use the FIELD_PREP and FIELD_GET
 - Add use_single_write in regmap_config
 - Use regmap_access_table

Change since version 3:
 - Fix comments
 - Don't put nct720"x" in the name, just call it nct7201
 - Remove differential inputs until conversions are finished
 - Add NCT7201_ prefix in all macros and avoid the tables
 - Correct event threshold values in raw units
 - Add with and without interrupt callback function to have the event
   config part and one that doesn't
 - Remove print an error message if regmap_wirte failed case

Change since version 2:
 - Remvoe read-vin-data-size property, default use read word vin data
 - Use regmap instead of i2c smbus API
 - IIO should be IIO_CHAN_INFO_RAW and _SCALE not _PROCESSED
 - Use dev_xxx_probe in probe function and dev_xxx in other functions
 - Use devm_iio_device_register replace of iio_device_register
 - Use guard(mutex) replace of mutex_lock
 - Use get_unaligned_le16 conversion API

Changes since version 1:
 - Add new property in iio:adc binding document
 - Add new driver for Nuvoton NCT720x driver

Eason Yang (2):
  dt-bindings: iio: adc: add NCT7201 ADCs
  iio: adc: add support for Nuvoton NCT7201

 .../bindings/iio/adc/nuvoton,nct7201.yaml     |  57 ++
 MAINTAINERS                                   |   2 +
 drivers/iio/adc/Kconfig                       |  11 +
 drivers/iio/adc/Makefile                      |   1 +
 drivers/iio/adc/nct7201.c                     | 487 ++++++++++++++++++
 5 files changed, 558 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/adc/nuvoton,nct7201.yaml
 create mode 100644 drivers/iio/adc/nct7201.c

-- 
2.34.1
Re: [PATCH v4 0/2] iio: adc: add Nuvoton NCT7201 ADC driver
Posted by Jonathan Cameron 9 months, 3 weeks ago
On Fri, 21 Feb 2025 17:09:16 +0800
Eason Yang <j2anfernee@gmail.com> wrote:

Hi Eason,

Not sure if I asked this before, but this is a device that seems
to be typically used for hardware monitoring and there are a number
of similar sounding device in drivers/hwmon/  

That raises a couple of questions:
1) Is it compatible with any of those existing drivers?
2) Why IIO rather than HWMON?

There isn't normally a problem with having a hardware monitoring
related device supported by IIO, it is just good to know if your
usecase makes that a good idea.  We have the iio-hwmon bridge
driver to solve the problem of a device than can be used either
as a generic ADC or as a hwmon type monitoring device (which tends
to have more alarms etc)

Jonathan


> Change since version 4:
>  - Fix comments
>  - Add interrupts and reset-gpios to the DT example
>  - Use the FIELD_PREP and FIELD_GET
>  - Add use_single_write in regmap_config
>  - Use regmap_access_table
> 
> Change since version 3:
>  - Fix comments
>  - Don't put nct720"x" in the name, just call it nct7201
>  - Remove differential inputs until conversions are finished
>  - Add NCT7201_ prefix in all macros and avoid the tables
>  - Correct event threshold values in raw units
>  - Add with and without interrupt callback function to have the event
>    config part and one that doesn't
>  - Remove print an error message if regmap_wirte failed case
> 
> Change since version 2:
>  - Remvoe read-vin-data-size property, default use read word vin data
>  - Use regmap instead of i2c smbus API
>  - IIO should be IIO_CHAN_INFO_RAW and _SCALE not _PROCESSED
>  - Use dev_xxx_probe in probe function and dev_xxx in other functions
>  - Use devm_iio_device_register replace of iio_device_register
>  - Use guard(mutex) replace of mutex_lock
>  - Use get_unaligned_le16 conversion API
> 
> Changes since version 1:
>  - Add new property in iio:adc binding document
>  - Add new driver for Nuvoton NCT720x driver
> 
> Eason Yang (2):
>   dt-bindings: iio: adc: add NCT7201 ADCs
>   iio: adc: add support for Nuvoton NCT7201
> 
>  .../bindings/iio/adc/nuvoton,nct7201.yaml     |  57 ++
>  MAINTAINERS                                   |   2 +
>  drivers/iio/adc/Kconfig                       |  11 +
>  drivers/iio/adc/Makefile                      |   1 +
>  drivers/iio/adc/nct7201.c                     | 487 ++++++++++++++++++
>  5 files changed, 558 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/iio/adc/nuvoton,nct7201.yaml
>  create mode 100644 drivers/iio/adc/nct7201.c
>
Re: [PATCH v4 0/2] iio: adc: add Nuvoton NCT7201 ADC driver
Posted by Yu-Hsian Yang 8 months, 1 week ago
Dear Jonathan,

Thanks again for the review

Jonathan Cameron <jic23@kernel.org> 於 2025年2月22日 週六 下午11:25寫道:
>
> On Fri, 21 Feb 2025 17:09:16 +0800
> Eason Yang <j2anfernee@gmail.com> wrote:
>
> Hi Eason,
>
> Not sure if I asked this before, but this is a device that seems
> to be typically used for hardware monitoring and there are a number
> of similar sounding device in drivers/hwmon/
>
> That raises a couple of questions:
> 1) Is it compatible with any of those existing drivers?

No, we need a new driver to do the ADC conversion for NCT7201/NCT7202.

> 2) Why IIO rather than HWMON?

A driver for NCT7201 with more functionality is available in the iio
adc subsystem.
If the chip is used for hardware monitoring, the iio->hwmon bridge
should be used.
>
> There isn't normally a problem with having a hardware monitoring
> related device supported by IIO, it is just good to know if your
> usecase makes that a good idea.  We have the iio-hwmon bridge
> driver to solve the problem of a device than can be used either
> as a generic ADC or as a hwmon type monitoring device (which tends
> to have more alarms etc)

Yes, we also verify the iio-hwmon bridge.

>
> Jonathan
>
>
> > Change since version 4:
> >  - Fix comments
> >  - Add interrupts and reset-gpios to the DT example
> >  - Use the FIELD_PREP and FIELD_GET
> >  - Add use_single_write in regmap_config
> >  - Use regmap_access_table
> >
> > Change since version 3:
> >  - Fix comments
> >  - Don't put nct720"x" in the name, just call it nct7201
> >  - Remove differential inputs until conversions are finished
> >  - Add NCT7201_ prefix in all macros and avoid the tables
> >  - Correct event threshold values in raw units
> >  - Add with and without interrupt callback function to have the event
> >    config part and one that doesn't
> >  - Remove print an error message if regmap_wirte failed case
> >
> > Change since version 2:
> >  - Remvoe read-vin-data-size property, default use read word vin data
> >  - Use regmap instead of i2c smbus API
> >  - IIO should be IIO_CHAN_INFO_RAW and _SCALE not _PROCESSED
> >  - Use dev_xxx_probe in probe function and dev_xxx in other functions
> >  - Use devm_iio_device_register replace of iio_device_register
> >  - Use guard(mutex) replace of mutex_lock
> >  - Use get_unaligned_le16 conversion API
> >
> > Changes since version 1:
> >  - Add new property in iio:adc binding document
> >  - Add new driver for Nuvoton NCT720x driver
> >
> > Eason Yang (2):
> >   dt-bindings: iio: adc: add NCT7201 ADCs
> >   iio: adc: add support for Nuvoton NCT7201
> >
> >  .../bindings/iio/adc/nuvoton,nct7201.yaml     |  57 ++
> >  MAINTAINERS                                   |   2 +
> >  drivers/iio/adc/Kconfig                       |  11 +
> >  drivers/iio/adc/Makefile                      |   1 +
> >  drivers/iio/adc/nct7201.c                     | 487 ++++++++++++++++++
> >  5 files changed, 558 insertions(+)
> >  create mode 100644 Documentation/devicetree/bindings/iio/adc/nuvoton,nct7201.yaml
> >  create mode 100644 drivers/iio/adc/nct7201.c
> >
>