Skip to contentSkip to conversation

Maxim MAX1241 driver

PATCH Superseded Alexandru Lazar 3 participants 7 messages Apr 1, 2020 – Apr 3, 2020

Subsystems (2)

v6 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v6 cover Maxim MAX1241 driver

Hi everyone,

Here's version 6 of a patch series which adds support for the Maxim MAX1241, a 12-bit, single-channel, SPI-connected ADC.

Changelog so far:

v6:

* Add separate cleanup actions for vdd and vref regulators respectively
* Change shdn pin name to shutdown. shdn is what the datasheet calls it but "shutdown" seems to be semi-standard, at least in the bindings (Rob orriginally suggested that I change the name in the docs. Figured it made zero sense to have it bear another name in the code)
* Dropped maxItems property in vref binding, made binding dual-licensed
* Changed name of spi node in binding example

v5:

* Add vdd supply binding
* Reorder include headers -- one of them had escaped the long mechanized hand of the Alphabetron
* Drop scan_index and scan_type from channel spec, as the driver doesn't support buffered modes
* Drop a useless initialization of a local variable in probe function
* Revise dt-bindings patch subject line, revise maintainer and copyright to match the Signed-off: string, drop reference to driver from bindings description
* Various readability/cosmetic fixes

v4:

* Dropped explicit documentation of SPI reg property
* Reordered patch series so that dt bindings come first

v3:

* Fixed silly copy-paste error in Kconfig description

v2:

* Removed useeless header includes
* Dropped needlessly verbose stuff in _read and _probe functions
* Dropped useless GPL notice
* Lowered log level of shdn pin status in probe function, now it's dev_dbg
* Added proper error checking for the GPIO shutdown pin
* remove now always returns zero (man, I've been wrong about this for *years* now...)
* Added regulator disable action, cleanup is now handled via devm
* Drop delay_usecs, use delay.value, delay.unit
* Drop config_of, of_match_ptr call
* Dropped IIO_BUFFER, IIO_TRIGGERED_BUFFER dependencies, set SPI_MASTER as dependency, fix indenting.
* DT binding: use correct id, add reg description (looks pretty standard), dropped spi-max-frequency, fixed dt_binding_check complaints (oops!)

Alexandru Lazar (2):
dt-bindings: iio: adc: Add MAX1241 bindings
iio: adc: Add MAX1241 driver

 .../bindings/iio/adc/maxim,max1241.yaml       |  64 +++++
 drivers/iio/adc/Kconfig                       |  10 +
 drivers/iio/adc/Makefile                      |   1 +
 drivers/iio/adc/max1241.c                     | 227 ++++++++++++++++++
 4 files changed, 302 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/adc/maxim,max1241.yaml
 create mode 100644 drivers/iio/adc/max1241.c
Signature · 1 line
2.20.1
#1 lore raw

PATCH v6 1/2 dt-bindings: iio: adc: Add MAX1241 bindings

Add device-tree bindings documentation for the MAX1241 device driver.

---
 .../bindings/iio/adc/maxim,max1241.yaml       | 64 +++++++++++++++++++
 1 file changed, 64 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/adc/maxim,max1241.yaml
Documentation/devicetree/bindings/iio/adc/maxim,max1241.yaml new file +64 -0
new file mode 100644
index 000000000000..7da9e4153ac1
@@ -0,0 +1,64 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+# Copyright 2020 Alexandru Lazar
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/adc/maxim,max1241.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Maxim MAX1241 12-bit, single-channel analog to digital converter
+
+maintainers:
+  - Alexandru Lazar <[email protected]>
+
+description: |
+  Bindings for the max1241 12-bit, single-channel ADC device. Datasheet
+  can be found at:
+    https://datasheets.maximintegrated.com/en/ds/MAX1240-MAX1241.pdf
+
+properties:
+  compatible:
+    enum:
+      - maxim,max1241
+
+  reg:
+    maxItems: 1
+
+  vdd-supply:
+    description:
+      Device tree identifier of the regulator that powers the ADC.
+
+  vref-supply:
+    description:
+      Device tree identifier of the regulator that provides the external
+      reference voltage.
+    maxItems: 1
+
+  shutdown-gpios:
+    description:
+      GPIO spec for the GPIO pin connected to the ADC's /SHDN pin. If
+      specified, the /SHDN pin will be asserted between conversions,
+      thus enabling power-down mode.
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - vdd-supply
+  - vref-supply
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    spi {
+      #address-cells = <1>;
+      #size-cells = <0>;
+
+        adc@0 {
+            compatible = "maxim,max1241";
+            reg = <0>;
+            vdd-supply = <&adc_vdd>;
+            vref-supply = <&adc_vref>;
+            spi-max-frequency = <1000000>;
+            shutdown-gpios = <&gpio 26 1>;
+        };
+    };
Signature · 1 line
2.20.1
#2 lore raw

PATCH v6 2/2 iio: adc: Add MAX1241 driver

In reply to Alexandru Lazar

Add driver for the Maxim MAX1241 12-bit, single-channel ADC.

---
 drivers/iio/adc/Kconfig   |  10 ++
 drivers/iio/adc/Makefile  |   1 +
 drivers/iio/adc/max1241.c | 227 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 238 insertions(+)
 create mode 100644 drivers/iio/adc/max1241.c
drivers/iio/adc/Kconfig +10 -0
index 5d8540b7b427..55f6462cd93f 100644
@@ -566,6 +566,16 @@ config MAX1118
 	  To compile this driver as a module, choose M here: the module will be
 	  called max1118.
 
+config MAX1241
+	tristate "Maxim max1241 ADC driver"
+	depends on SPI_MASTER
+	help
+	  Say yes here to build support for Maxim max1241 12-bit, single-channel
+	  ADC.
+
+	  To compile this driver as a module, choose M here: the module will be
+	  called max1241.
+
 config MAX1363
 	tristate "Maxim max1363 ADC driver"
 	depends on I2C
drivers/iio/adc/Makefile +1 -0
index a1f1fbec0f87..37d6f17559dc 100644
@@ -54,6 +54,7 @@ obj-$(CONFIG_LTC2497) += ltc2497.o
 obj-$(CONFIG_MAX1027) += max1027.o
 obj-$(CONFIG_MAX11100) += max11100.o
 obj-$(CONFIG_MAX1118) += max1118.o
+obj-$(CONFIG_MAX1241) += max1241.o
 obj-$(CONFIG_MAX1363) += max1363.o
 obj-$(CONFIG_MAX9611) += max9611.o
 obj-$(CONFIG_MCP320X) += mcp320x.o
drivers/iio/adc/max1241.c new file +227 -0

227 lines not on this page · raw message

Signature · 1 line
2.20.1
#3 lore raw

Re: [PATCH v6 2/2] iio: adc: Add MAX1241 driver

Quoted 3 lines · Alexandru Lazar

Add driver for the Maxim MAX1241 12-bit, single-channel ADC.

Perhaps put data sheet link as Datasheet: tag here?

Quoted 2 lines

...

Quoted 1 line

+ indio_dev->name = spi_get_device_id(spi)->name;

Shouldn't be rather part number?
Jonathan?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#4 lore raw

Re: [PATCH v6 2/2] iio: adc: Add MAX1241 driver

Quoted 5 lines · Andy Shevchenko
Quoted 2 lines · Alexandru Lazar

Add driver for the Maxim MAX1241 12-bit, single-channel ADC.

Perhaps put data sheet link as Datasheet: tag here?

Quoted 7 lines
Quoted 2 lines

...

Quoted 1 line

+ indio_dev->name = spi_get_device_id(spi)->name;

Shouldn't be rather part number?
Jonathan?

This is the part number as defined in the spi_device id table :)

+static const struct spi_device_id max1241_id[] = {
+ { "max1241", max1241 },
+ {}
+};

- Lars

#5 lore raw

Re: [PATCH v6 2/2] iio: adc: Add MAX1241 driver

Quoted 8 lines · Lars-Peter Clausen
Quoted 7 lines · Andy Shevchenko
Quoted 2 lines · Alexandru Lazar

Add driver for the Maxim MAX1241 12-bit, single-channel ADC.

Perhaps put data sheet link as Datasheet: tag here?

Quoted 2 lines
Quoted 7 lines
Quoted 5 lines

...

Quoted 1 line

+ indio_dev->name = spi_get_device_id(spi)->name;

Shouldn't be rather part number?
Jonathan?

This is the part number as defined in the spi_device id table :)

Okay!

Quoted 4 lines
drivers/iio/adc/max1241.c new file +4 -0
+static const struct spi_device_id max1241_id[] = {
+       { "max1241", max1241 },
+       {}
+};
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#6 lore raw

Re: [PATCH v6 2/2] iio: adc: Add MAX1241 driver

In reply to Andy Shevchenko
Quoted 6 lines · Andy Shevchenko
Quoted 3 lines · Alexandru Lazar

Add driver for the Maxim MAX1241 12-bit, single-channel ADC.

Perhaps put data sheet link as Datasheet: tag here?

Sure, makes sense. I'll send a v7 in a jiffy.