* [PATCH v3 0/2] hwmon: Add device tree support for adcxx @ 2018-11-15 13:50 Florian Eckert 2018-11-15 13:50 ` [PATCH v3 1/2] hwmon: (adcxx) add devictree bindings documentation Florian Eckert 2018-11-15 13:50 ` [PATCH v3 2/2] hwmon: (adcxx) Add device tree support Florian Eckert 0 siblings, 2 replies; 6+ messages in thread From: Florian Eckert @ 2018-11-15 13:50 UTC (permalink / raw) To: jdelvare, linux, robh+dt, mark.rutland Cc: linux-hwmon, linux-kernel, devicetree, Florian Eckert Changes v2: - Use regular voltag binding Changes v3: --nothing-- No progress or feed back so try to get this upstream again. Florian Eckert (2): hwmon: (adcxx) add devictree bindings documentation hwmon: (adcxx) Add device tree support Documentation/devicetree/bindings/hwmon/adcxx.txt | 24 +++++++++ drivers/hwmon/adcxx.c | 62 ++++++++++++++++++++--- 2 files changed, 79 insertions(+), 7 deletions(-) create mode 100644 Documentation/devicetree/bindings/hwmon/adcxx.txt -- 2.11.0 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v3 1/2] hwmon: (adcxx) add devictree bindings documentation 2018-11-15 13:50 [PATCH v3 0/2] hwmon: Add device tree support for adcxx Florian Eckert @ 2018-11-15 13:50 ` Florian Eckert 2018-11-17 14:40 ` Rob Herring 2018-11-15 13:50 ` [PATCH v3 2/2] hwmon: (adcxx) Add device tree support Florian Eckert 1 sibling, 1 reply; 6+ messages in thread From: Florian Eckert @ 2018-11-15 13:50 UTC (permalink / raw) To: jdelvare, linux, robh+dt, mark.rutland Cc: linux-hwmon, linux-kernel, devicetree, Florian Eckert Document the devicetree bindings for the adcxx. Signed-off-by: Florian Eckert <fe@dev.tdt.de> --- Documentation/devicetree/bindings/hwmon/adcxx.txt | 24 +++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/adcxx.txt diff --git a/Documentation/devicetree/bindings/hwmon/adcxx.txt b/Documentation/devicetree/bindings/hwmon/adcxx.txt new file mode 100644 index 000000000000..a94a5fe21b6d --- /dev/null +++ b/Documentation/devicetree/bindings/hwmon/adcxx.txt @@ -0,0 +1,24 @@ +adcxx properties + +Required properties: +- compatible: Must be one of the following: + - "national,adcxx1s" for adcxx1s + - "national,adcxx2s" for adcxx2s + - "national,adcxx4s" for adcxx4s + - "national,adcxx8s" for adcxx8s +- reg: SPI address for chip + +Optional properties: + +- vref-supply + The external reference in microvolt for this device is set to this value. + If it does not exists the reference will be set to 3300000uV (3.3V). + +Example: + +adc@6 { + compatible = "national,adcxx2s"; + reg = <6 0>; + spi-max-frequency = <1000000>; + vref-supply = <&vref>; +}; -- 2.11.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v3 1/2] hwmon: (adcxx) add devictree bindings documentation 2018-11-15 13:50 ` [PATCH v3 1/2] hwmon: (adcxx) add devictree bindings documentation Florian Eckert @ 2018-11-17 14:40 ` Rob Herring 2018-11-19 1:25 ` Guenter Roeck 0 siblings, 1 reply; 6+ messages in thread From: Rob Herring @ 2018-11-17 14:40 UTC (permalink / raw) To: Florian Eckert Cc: jdelvare, linux, mark.rutland, linux-hwmon, linux-kernel, devicetree On Thu, Nov 15, 2018 at 02:50:12PM +0100, Florian Eckert wrote: > Document the devicetree bindings for the adcxx. > > Signed-off-by: Florian Eckert <fe@dev.tdt.de> > --- > Documentation/devicetree/bindings/hwmon/adcxx.txt | 24 +++++++++++++++++++++++ > 1 file changed, 24 insertions(+) > create mode 100644 Documentation/devicetree/bindings/hwmon/adcxx.txt > > diff --git a/Documentation/devicetree/bindings/hwmon/adcxx.txt b/Documentation/devicetree/bindings/hwmon/adcxx.txt > new file mode 100644 > index 000000000000..a94a5fe21b6d > --- /dev/null > +++ b/Documentation/devicetree/bindings/hwmon/adcxx.txt > @@ -0,0 +1,24 @@ > +adcxx properties Needs a better description of what this h/w is. ADCs go in iio/adc/ > + > +Required properties: > +- compatible: Must be one of the following: > + - "national,adcxx1s" for adcxx1s > + - "national,adcxx2s" for adcxx2s > + - "national,adcxx4s" for adcxx4s > + - "national,adcxx8s" for adcxx8s Don't use wildcards in compatible strings. > +- reg: SPI address for chip > + > +Optional properties: > + > +- vref-supply > + The external reference in microvolt for this device is set to this value. > + If it does not exists the reference will be set to 3300000uV (3.3V). > + > +Example: > + > +adc@6 { > + compatible = "national,adcxx2s"; > + reg = <6 0>; ? SPI addresses are a single cell. > + spi-max-frequency = <1000000>; > + vref-supply = <&vref>; > +}; > -- > 2.11.0 > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3 1/2] hwmon: (adcxx) add devictree bindings documentation 2018-11-17 14:40 ` Rob Herring @ 2018-11-19 1:25 ` Guenter Roeck 2018-11-20 7:16 ` Florian Eckert 0 siblings, 1 reply; 6+ messages in thread From: Guenter Roeck @ 2018-11-19 1:25 UTC (permalink / raw) To: Rob Herring Cc: Florian Eckert, jdelvare, mark.rutland, linux-hwmon, linux-kernel, devicetree On Sat, Nov 17, 2018 at 08:40:41AM -0600, Rob Herring wrote: > On Thu, Nov 15, 2018 at 02:50:12PM +0100, Florian Eckert wrote: > > Document the devicetree bindings for the adcxx. > > > > Signed-off-by: Florian Eckert <fe@dev.tdt.de> > > --- > > Documentation/devicetree/bindings/hwmon/adcxx.txt | 24 +++++++++++++++++++++++ > > 1 file changed, 24 insertions(+) > > create mode 100644 Documentation/devicetree/bindings/hwmon/adcxx.txt > > > > diff --git a/Documentation/devicetree/bindings/hwmon/adcxx.txt b/Documentation/devicetree/bindings/hwmon/adcxx.txt > > new file mode 100644 > > index 000000000000..a94a5fe21b6d > > --- /dev/null > > +++ b/Documentation/devicetree/bindings/hwmon/adcxx.txt > > @@ -0,0 +1,24 @@ > > +adcxx properties > > Needs a better description of what this h/w is. > > ADCs go in iio/adc/ > FWIW, the hwmon driver for this chip series would be a perfect candidate for a conversion to an iio driver. The driver predates the existence of iio. Florian, any interest doing that ? It is quite likely that the chip isn't used for hardware monitoring. > > + > > +Required properties: > > +- compatible: Must be one of the following: > > + - "national,adcxx1s" for adcxx1s > > + - "national,adcxx2s" for adcxx2s > > + - "national,adcxx4s" for adcxx4s > > + - "national,adcxx8s" for adcxx8s > > Don't use wildcards in compatible strings. > Should we list all of them ? ADC121S021 ADC121S051 ADC121S101 ADC101S021 ADC101S051 ADC101S101 ADC081S021 ADC081S051 ADC081S101 ADC121S625 ADC121S655 ADC121S705 ADC122S021 ADC122S051 ADC122S101 ADC102S021 ADC102S051 ADC102S101 ADC082S021 ADC082S051 ADC082S101 ADC122S625 ADC122S655 ADC122S706 ADC124S021 ADC124S051 ADC124S101 ADC104S021 ADC104S051 ADC104S101 ADC084S021 ADC084S051 ADC084S101 ADC128S022 ADC128S052 ADC128S102 I hope I didn't miss any. Guenter > > +- reg: SPI address for chip > > + > > +Optional properties: > > + > > +- vref-supply > > + The external reference in microvolt for this device is set to this value. > > + If it does not exists the reference will be set to 3300000uV (3.3V). > > + > > +Example: > > + > > +adc@6 { > > + compatible = "national,adcxx2s"; > > + reg = <6 0>; > > ? SPI addresses are a single cell. > > > + spi-max-frequency = <1000000>; > > + vref-supply = <&vref>; > > +}; > > -- > > 2.11.0 > > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3 1/2] hwmon: (adcxx) add devictree bindings documentation 2018-11-19 1:25 ` Guenter Roeck @ 2018-11-20 7:16 ` Florian Eckert 0 siblings, 0 replies; 6+ messages in thread From: Florian Eckert @ 2018-11-20 7:16 UTC (permalink / raw) To: Guenter Roeck Cc: Rob Herring, jdelvare, mark.rutland, linux-hwmon, linux-kernel, devicetree, Guenter Roeck Hello Guenter, >> >> Needs a better description of what this h/w is. >> >> ADCs go in iio/adc/ >> > FWIW, the hwmon driver for this chip series would be a perfect > candidate > for a conversion to an iio driver. The driver predates the existence of > iio. > > Florian, any interest doing that ? It is quite likely that the chip > isn't > used for hardware monitoring. I will have a look on the next week about your suggestion to port this device to iio/adc. - Florian ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v3 2/2] hwmon: (adcxx) Add device tree support 2018-11-15 13:50 [PATCH v3 0/2] hwmon: Add device tree support for adcxx Florian Eckert 2018-11-15 13:50 ` [PATCH v3 1/2] hwmon: (adcxx) add devictree bindings documentation Florian Eckert @ 2018-11-15 13:50 ` Florian Eckert 1 sibling, 0 replies; 6+ messages in thread From: Florian Eckert @ 2018-11-15 13:50 UTC (permalink / raw) To: jdelvare, linux, robh+dt, mark.rutland Cc: linux-hwmon, linux-kernel, devicetree, Florian Eckert Add device tree supoort for this driver. Set reference voltage of ADC with the regulator device tree property. If not set use default 3300000uV (3.3V). - vref-supply Signed-off-by: Florian Eckert <fe@dev.tdt.de> --- drivers/hwmon/adcxx.c | 62 +++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 55 insertions(+), 7 deletions(-) diff --git a/drivers/hwmon/adcxx.c b/drivers/hwmon/adcxx.c index 69e0bb97e597..6f3e7d65b5b8 100644 --- a/drivers/hwmon/adcxx.c +++ b/drivers/hwmon/adcxx.c @@ -4,6 +4,7 @@ * The adcxx4s is an AD converter family from National Semiconductor (NS). * * Copyright (c) 2008 Marc Pignat <marc.pignat@hevs.ch> + * Copyright (c) 2017 Florian Eckert <fe@dev.tdt.de> * * The adcxx4s communicates with a host processor via an SPI/Microwire Bus * interface. This driver supports the whole family of devices with name @@ -46,9 +47,16 @@ #include <linux/mutex.h> #include <linux/mod_devicetable.h> #include <linux/spi/spi.h> +#include <linux/of_device.h> +#include <linux/regulator/consumer.h> #define DRVNAME "adcxx" +#define ADCXX1S 1 +#define ADCXX2S 2 +#define ADCXX4S 4 +#define ADCXX8S 8 + struct adcxx { struct device *hwmon_dev; struct mutex lock; @@ -159,21 +167,60 @@ static struct sensor_device_attribute ad_input[] = { SENSOR_ATTR(in7_input, S_IRUGO, adcxx_read, NULL, 7), }; +#ifdef CONFIG_OF +static const struct of_device_id adcxx_of_ids[] = { + { + .compatible = "national,adcxx1s", + .data = (void *) ADCXX1S, + }, + { + .compatible = "national,adcxx2s", + .data = (void *) ADCXX2S, + }, + { + .compatible = "national,adcxx4s", + .data = (void *) ADCXX4S, + }, + { + .compatible = "national,adcxx8s", + . data = (void *) ADCXX8S, + }, + {}, +}; +MODULE_DEVICE_TABLE(of, adcxx_of_ids); +#endif + /*----------------------------------------------------------------------*/ static int adcxx_probe(struct spi_device *spi) { - int channels = spi_get_device_id(spi)->driver_data; + const struct of_device_id *match; + struct regulator *vref; + int vref_uv; + int channels; struct adcxx *adc; int status; int i; + match = of_match_device(adcxx_of_ids, &spi->dev); + if (match) + channels = (int)(uintptr_t)match->data; + else + channels = spi_get_device_id(spi)->driver_data; + adc = devm_kzalloc(&spi->dev, sizeof(*adc), GFP_KERNEL); if (!adc) return -ENOMEM; - /* set a default value for the reference */ - adc->reference = 3300; + vref = devm_regulator_get_optional(&spi->dev, "vref"); + if (!IS_ERR(vref)) { + vref_uv = regulator_get_voltage(vref); + adc->reference = DIV_ROUND_CLOSEST(vref_uv, 1000); + } + if (!adc->reference) + adc->reference = 3300; + dev_dbg(&spi->dev, "Reference voltage set to %dmV\n", adc->reference); + adc->channels = channels; mutex_init(&adc->lock); @@ -223,10 +270,10 @@ static int adcxx_remove(struct spi_device *spi) } static const struct spi_device_id adcxx_ids[] = { - { "adcxx1s", 1 }, - { "adcxx2s", 2 }, - { "adcxx4s", 4 }, - { "adcxx8s", 8 }, + { "adcxx1s", ADCXX1S }, + { "adcxx2s", ADCXX2S }, + { "adcxx4s", ADCXX4S }, + { "adcxx8s", ADCXX8S }, { }, }; MODULE_DEVICE_TABLE(spi, adcxx_ids); @@ -234,6 +281,7 @@ MODULE_DEVICE_TABLE(spi, adcxx_ids); static struct spi_driver adcxx_driver = { .driver = { .name = "adcxx", + .of_match_table = of_match_ptr(adcxx_of_ids), }, .id_table = adcxx_ids, .probe = adcxx_probe, -- 2.11.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-11-20 7:17 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2018-11-15 13:50 [PATCH v3 0/2] hwmon: Add device tree support for adcxx Florian Eckert 2018-11-15 13:50 ` [PATCH v3 1/2] hwmon: (adcxx) add devictree bindings documentation Florian Eckert 2018-11-17 14:40 ` Rob Herring 2018-11-19 1:25 ` Guenter Roeck 2018-11-20 7:16 ` Florian Eckert 2018-11-15 13:50 ` [PATCH v3 2/2] hwmon: (adcxx) Add device tree support Florian Eckert
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).