devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/4] Add support for the GE HealthCare PMC ADC
@ 2024-10-03 11:46 Herve Codina
  2024-10-03 11:46 ` [PATCH v2 1/4] dt-bindings: vendor-prefixes: Add an entry for GE HealthCare Herve Codina
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Herve Codina @ 2024-10-03 11:46 UTC (permalink / raw)
  To: Herve Codina, David Lechner, Jonathan Cameron, Lars-Peter Clausen,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley
  Cc: linux-iio, devicetree, linux-kernel, Luca Ceresoli, Ian Ray,
	Thomas Petazzoni

Hi,

The GE HealthCare PMC Analog to Digital Converter (ADC) is a 16-Channel
voltage and current, 16-Bit ADC with an I2C Interface.

Compare to the previous iteration, this v2 series mainly:
  - Add a description in the binding
  - Fixed sign_extend32() parameter
  - Use dev_err_probe()
  - Remove scale and use processed channels

Best regards,
Herve Codina

Changes v1 -> v2
  v1: https://lore.kernel.org/lkml/20241001074618.350785-1-herve.codina@bootlin.com/

  - Patch 1
    Add 'Acked-by: Conor Dooley <conor.dooley@microchip.com>'

  - Patch 2
    Add a desccription for the 'osc' clock.

  - Patch 3
    Replace sign_extend32(ret, 16) by sign_extend32(ret, 15).
    Use dev_err_probe().
    Remove scale and use processed channels as values are read in IIO
    expected unit (mV or mA).

  - Patch 4
    No changes

Herve Codina (4):
  dt-bindings: vendor-prefixes: Add an entry for GE HealthCare
  dt-bindings: iio: adc: Add the GE HealthCare PMC ADC
  iio: adc: Add support for the GE HealthCare PMC ADC
  MAINTAINERS: add the GE HealthCare PMC ADC driver entry

 .../bindings/iio/adc/gehc,pmc-adc.yaml        |  86 +++++++
 .../devicetree/bindings/vendor-prefixes.yaml  |   2 +
 MAINTAINERS                                   |   8 +
 drivers/iio/adc/Kconfig                       |  10 +
 drivers/iio/adc/Makefile                      |   1 +
 drivers/iio/adc/gehc-pmc-adc.c                | 227 ++++++++++++++++++
 include/dt-bindings/iio/adc/gehc,pmc-adc.h    |  10 +
 7 files changed, 344 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/adc/gehc,pmc-adc.yaml
 create mode 100644 drivers/iio/adc/gehc-pmc-adc.c
 create mode 100644 include/dt-bindings/iio/adc/gehc,pmc-adc.h

-- 
2.46.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v2 1/4] dt-bindings: vendor-prefixes: Add an entry for GE HealthCare
  2024-10-03 11:46 [PATCH v2 0/4] Add support for the GE HealthCare PMC ADC Herve Codina
@ 2024-10-03 11:46 ` Herve Codina
  2024-10-03 11:55   ` Ian Ray
  2024-10-03 11:46 ` [PATCH v2 2/4] dt-bindings: iio: adc: Add the GE HealthCare PMC ADC Herve Codina
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 12+ messages in thread
From: Herve Codina @ 2024-10-03 11:46 UTC (permalink / raw)
  To: Herve Codina, David Lechner, Jonathan Cameron, Lars-Peter Clausen,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley
  Cc: linux-iio, devicetree, linux-kernel, Luca Ceresoli, Ian Ray,
	Thomas Petazzoni, Conor Dooley

Add the "gehc" entry for GE HealthCare.
https://www.gehealthcare.com

Signed-off-by: Herve Codina <herve.codina@bootlin.com>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
---
 Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml b/Documentation/devicetree/bindings/vendor-prefixes.yaml
index b320a39de7fe..15877574a417 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.yaml
+++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml
@@ -561,6 +561,8 @@ patternProperties:
     description: GE Fanuc Intelligent Platforms Embedded Systems, Inc.
   "^GEFanuc,.*":
     description: GE Fanuc Intelligent Platforms Embedded Systems, Inc.
+  "^gehc,.*":
+    description: GE HealthCare
   "^gemei,.*":
     description: Gemei Digital Technology Co., Ltd.
   "^gemtek,.*":
-- 
2.46.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2 2/4] dt-bindings: iio: adc: Add the GE HealthCare PMC ADC
  2024-10-03 11:46 [PATCH v2 0/4] Add support for the GE HealthCare PMC ADC Herve Codina
  2024-10-03 11:46 ` [PATCH v2 1/4] dt-bindings: vendor-prefixes: Add an entry for GE HealthCare Herve Codina
@ 2024-10-03 11:46 ` Herve Codina
  2024-10-03 11:56   ` Ian Ray
  2024-10-03 16:16   ` Conor Dooley
  2024-10-03 11:46 ` [PATCH v2 3/4] iio: adc: Add support for " Herve Codina
  2024-10-03 11:46 ` [PATCH v2 4/4] MAINTAINERS: add the GE HealthCare PMC ADC driver entry Herve Codina
  3 siblings, 2 replies; 12+ messages in thread
From: Herve Codina @ 2024-10-03 11:46 UTC (permalink / raw)
  To: Herve Codina, David Lechner, Jonathan Cameron, Lars-Peter Clausen,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley
  Cc: linux-iio, devicetree, linux-kernel, Luca Ceresoli, Ian Ray,
	Thomas Petazzoni

The GE HealthCare PMC Analog to Digital Converter (ADC) is a 16-Channel
(voltage and current), 16-Bit ADC with an I2C Interface.

Signed-off-by: Herve Codina <herve.codina@bootlin.com>
---
 .../bindings/iio/adc/gehc,pmc-adc.yaml        | 86 +++++++++++++++++++
 include/dt-bindings/iio/adc/gehc,pmc-adc.h    | 10 +++
 2 files changed, 96 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/adc/gehc,pmc-adc.yaml
 create mode 100644 include/dt-bindings/iio/adc/gehc,pmc-adc.h

diff --git a/Documentation/devicetree/bindings/iio/adc/gehc,pmc-adc.yaml b/Documentation/devicetree/bindings/iio/adc/gehc,pmc-adc.yaml
new file mode 100644
index 000000000000..2cea7c104a26
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/adc/gehc,pmc-adc.yaml
@@ -0,0 +1,86 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/adc/gehc,pmc-adc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: GE HealthCare PMC Analog to Digital Converter (ADC)
+
+maintainers:
+  - Herve Codina <herve.codina@bootlin.com>
+
+description:
+  The GE HealthCare PMC ADC is a 16-Channel (voltage and current), 16-Bit ADC
+  with an I2C Interface.
+
+properties:
+  compatible:
+    const: gehc,pmc-adc
+
+  reg:
+    maxItems: 1
+
+  vdd-supply:
+    description:
+      Regulator for the VDD power supply.
+
+  vdda-supply:
+    description:
+      Regulator for the VDD analog (VDDA) power supply.
+
+  vddio-supply:
+    description:
+      Regulator for the VDD IO (VDDIO) power supply.
+
+  vref-supply:
+    description:
+      Regulator for the voltage reference power supply.
+
+  clocks:
+    maxItems: 1
+    description:
+      The component uses an external oscillator (osc) if an external oscillator
+      is connected to its clock pins. Otherwise, it uses an internal reference
+      clock.
+
+  clock-names:
+    items:
+      - const: osc
+
+  "#io-channel-cells":
+    const: 2
+    description: |
+      The first cell is the channel type (dt-bindings/iio/adc/gehc,pmc-adc.h
+      defines these values):
+       - 0: voltage
+       - 1: current
+      The second cell is the channel number from 0 to 15.
+
+required:
+  - compatible
+  - reg
+  - vdd-supply
+  - vdda-supply
+  - vddio-supply
+  - vref-supply
+  - '#io-channel-cells'
+
+additionalProperties: false
+
+examples:
+  - |
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        adc@14 {
+            compatible = "gehc,pmc-adc";
+            reg = <0x14>;
+            vdd-supply = <&reg_vdd>;
+            vdda-supply = <&reg_vdda>;
+            vddio-supply = <&reg_vddio>;
+            vref-supply = <&reg_vref>;
+            #io-channel-cells = <2>;
+        };
+    };
+...
diff --git a/include/dt-bindings/iio/adc/gehc,pmc-adc.h b/include/dt-bindings/iio/adc/gehc,pmc-adc.h
new file mode 100644
index 000000000000..2f291e3c76ae
--- /dev/null
+++ b/include/dt-bindings/iio/adc/gehc,pmc-adc.h
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause */
+
+#ifndef _DT_BINDINGS_IIO_ADC_GEHC_PMC_ADC_H
+#define _DT_BINDINGS_IIO_ADC_GEHC_PMC_ADC_H
+
+/* ADC channel type */
+#define GEHC_PMC_ADC_VOLTAGE	0
+#define GEHC_PMC_ADC_CURRENT	1
+
+#endif
-- 
2.46.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2 3/4] iio: adc: Add support for the GE HealthCare PMC ADC
  2024-10-03 11:46 [PATCH v2 0/4] Add support for the GE HealthCare PMC ADC Herve Codina
  2024-10-03 11:46 ` [PATCH v2 1/4] dt-bindings: vendor-prefixes: Add an entry for GE HealthCare Herve Codina
  2024-10-03 11:46 ` [PATCH v2 2/4] dt-bindings: iio: adc: Add the GE HealthCare PMC ADC Herve Codina
@ 2024-10-03 11:46 ` Herve Codina
  2024-10-03 11:56   ` Ian Ray
  2024-10-03 13:39   ` David Lechner
  2024-10-03 11:46 ` [PATCH v2 4/4] MAINTAINERS: add the GE HealthCare PMC ADC driver entry Herve Codina
  3 siblings, 2 replies; 12+ messages in thread
From: Herve Codina @ 2024-10-03 11:46 UTC (permalink / raw)
  To: Herve Codina, David Lechner, Jonathan Cameron, Lars-Peter Clausen,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley
  Cc: linux-iio, devicetree, linux-kernel, Luca Ceresoli, Ian Ray,
	Thomas Petazzoni

The GE HealthCare PMC Analog to Digital Converter (ADC) is a 16-Channel
(voltage and current), 16-Bit ADC with an I2C Interface.

Signed-off-by: Herve Codina <herve.codina@bootlin.com>
---
 drivers/iio/adc/Kconfig        |  10 ++
 drivers/iio/adc/Makefile       |   1 +
 drivers/iio/adc/gehc-pmc-adc.c | 227 +++++++++++++++++++++++++++++++++
 3 files changed, 238 insertions(+)
 create mode 100644 drivers/iio/adc/gehc-pmc-adc.c

diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
index 97ece1a4b7e3..87b20f972c25 100644
--- a/drivers/iio/adc/Kconfig
+++ b/drivers/iio/adc/Kconfig
@@ -571,6 +571,16 @@ config FSL_MX25_ADC
 	  Generic Conversion Queue driver used for general purpose ADC in the
 	  MX25. This driver supports single measurements using the MX25 ADC.
 
+config GEHC_PMC_ADC
+	tristate "GE HealthCare PMC ADC driver"
+	depends on I2C
+	help
+	  Say yes here to build support for the GE HealthCare PMC 16-bit
+	  16-Channel ADC.
+
+	  To compile this driver as a module, choose M here: the module will be
+	  called gehc-pmc-adc.
+
 config HI8435
 	tristate "Holt Integrated Circuits HI-8435 threshold detector"
 	select IIO_TRIGGERED_EVENT
diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile
index 7b91cd98c0e0..66b36dfe9a28 100644
--- a/drivers/iio/adc/Makefile
+++ b/drivers/iio/adc/Makefile
@@ -52,6 +52,7 @@ obj-$(CONFIG_ENVELOPE_DETECTOR) += envelope-detector.o
 obj-$(CONFIG_EP93XX_ADC) += ep93xx_adc.o
 obj-$(CONFIG_EXYNOS_ADC) += exynos_adc.o
 obj-$(CONFIG_FSL_MX25_ADC) += fsl-imx25-gcq.o
+obj-$(CONFIG_GEHC_PMC_ADC) += gehc-pmc-adc.o
 obj-$(CONFIG_HI8435) += hi8435.o
 obj-$(CONFIG_HX711) += hx711.o
 obj-$(CONFIG_IMX7D_ADC) += imx7d_adc.o
diff --git a/drivers/iio/adc/gehc-pmc-adc.c b/drivers/iio/adc/gehc-pmc-adc.c
new file mode 100644
index 000000000000..c70a93f4a61b
--- /dev/null
+++ b/drivers/iio/adc/gehc-pmc-adc.c
@@ -0,0 +1,227 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * The GE HealthCare PMC ADC is a 16-Channel (Voltage and current), 16-Bit
+ * ADC with an I2C Interface.
+ *
+ * Copyright (C) 2024, GE HealthCare
+ *
+ * Authors:
+ * Herve Codina <herve.codina@bootlin.com>
+ */
+#include <dt-bindings/iio/adc/gehc,pmc-adc.h>
+#include <linux/bitops.h>
+#include <linux/clk.h>
+#include <linux/i2c.h>
+#include <linux/iio/iio.h>
+#include <linux/module.h>
+#include <linux/regulator/consumer.h>
+#include <linux/slab.h>
+
+struct pmc_adc {
+	struct i2c_client *client;
+};
+
+#define PMC_ADC_CMD_REQUEST_PROTOCOL_VERSION	0x01
+#define PMC_ADC_CMD_READ_VOLTAGE(_ch)		(0x10 | (_ch))
+#define PMC_ADC_CMD_READ_CURRENT(_ch)		(0x20 | (_ch))
+
+#define PMC_ADC_VOLTAGE_CHANNEL(_ch, _ds_name) {			\
+	.type = IIO_VOLTAGE,						\
+	.indexed = 1,							\
+	.channel = (_ch),						\
+	.address = PMC_ADC_CMD_READ_VOLTAGE(_ch),			\
+	.info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED),		\
+	.datasheet_name = (_ds_name),					\
+}
+
+#define PMC_ADC_CURRENT_CHANNEL(_ch, _ds_name) {			\
+	.type = IIO_CURRENT,						\
+	.indexed = 1,							\
+	.channel = (_ch),						\
+	.address = PMC_ADC_CMD_READ_CURRENT(_ch),			\
+	.info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED),		\
+	.datasheet_name = (_ds_name),					\
+}
+
+static const struct iio_chan_spec pmc_adc_channels[] = {
+	PMC_ADC_VOLTAGE_CHANNEL(0, "CH0_V"),
+	PMC_ADC_VOLTAGE_CHANNEL(1, "CH1_V"),
+	PMC_ADC_VOLTAGE_CHANNEL(2, "CH2_V"),
+	PMC_ADC_VOLTAGE_CHANNEL(3, "CH3_V"),
+	PMC_ADC_VOLTAGE_CHANNEL(4, "CH4_V"),
+	PMC_ADC_VOLTAGE_CHANNEL(5, "CH5_V"),
+	PMC_ADC_VOLTAGE_CHANNEL(6, "CH6_V"),
+	PMC_ADC_VOLTAGE_CHANNEL(7, "CH7_V"),
+	PMC_ADC_VOLTAGE_CHANNEL(8, "CH8_V"),
+	PMC_ADC_VOLTAGE_CHANNEL(9, "CH9_V"),
+	PMC_ADC_VOLTAGE_CHANNEL(10, "CH10_V"),
+	PMC_ADC_VOLTAGE_CHANNEL(11, "CH11_V"),
+	PMC_ADC_VOLTAGE_CHANNEL(12, "CH12_V"),
+	PMC_ADC_VOLTAGE_CHANNEL(13, "CH13_V"),
+	PMC_ADC_VOLTAGE_CHANNEL(14, "CH14_V"),
+	PMC_ADC_VOLTAGE_CHANNEL(15, "CH15_V"),
+
+	PMC_ADC_CURRENT_CHANNEL(0, "CH0_I"),
+	PMC_ADC_CURRENT_CHANNEL(1, "CH1_I"),
+	PMC_ADC_CURRENT_CHANNEL(2, "CH2_I"),
+	PMC_ADC_CURRENT_CHANNEL(3, "CH3_I"),
+	PMC_ADC_CURRENT_CHANNEL(4, "CH4_I"),
+	PMC_ADC_CURRENT_CHANNEL(5, "CH5_I"),
+	PMC_ADC_CURRENT_CHANNEL(6, "CH6_I"),
+	PMC_ADC_CURRENT_CHANNEL(7, "CH7_I"),
+	PMC_ADC_CURRENT_CHANNEL(8, "CH8_I"),
+	PMC_ADC_CURRENT_CHANNEL(9, "CH9_I"),
+	PMC_ADC_CURRENT_CHANNEL(10, "CH10_I"),
+	PMC_ADC_CURRENT_CHANNEL(11, "CH11_I"),
+	PMC_ADC_CURRENT_CHANNEL(12, "CH12_I"),
+	PMC_ADC_CURRENT_CHANNEL(13, "CH13_I"),
+	PMC_ADC_CURRENT_CHANNEL(14, "CH14_I"),
+	PMC_ADC_CURRENT_CHANNEL(15, "CH15_I"),
+};
+
+static int pmc_adc_read_raw_ch(struct pmc_adc *pmc_adc, u8 cmd, int *val)
+{
+	s32 ret;
+
+	ret = i2c_smbus_read_word_swapped(pmc_adc->client, cmd);
+	if (ret < 0) {
+		dev_err(&pmc_adc->client->dev, "i2c read word failed (%d)\n", ret);
+		return ret;
+	}
+
+	*val = sign_extend32(ret, 15);
+	return 0;
+}
+
+static int pmc_adc_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan,
+			    int *val, int *val2, long mask)
+{
+	struct pmc_adc *pmc_adc = iio_priv(indio_dev);
+	int ret;
+
+	switch (mask) {
+	case IIO_CHAN_INFO_PROCESSED:
+		/* Values are directly read in mV or mA */
+		ret = pmc_adc_read_raw_ch(pmc_adc, chan->address, val);
+		if (ret)
+			return ret;
+		return IIO_VAL_INT;
+	}
+
+	return -EINVAL;
+}
+
+static int pmc_adc_fwnode_xlate(struct iio_dev *indio_dev,
+				const struct fwnode_reference_args *iiospec)
+{
+	enum iio_chan_type expected_type;
+	unsigned int i;
+
+	/*
+	 * args[0]: Acquisition type (i.e. voltage or current)
+	 * args[1]: PMC ADC channel number
+	 */
+	if (iiospec->nargs != 2)
+		return -EINVAL;
+
+	switch (iiospec->args[0]) {
+	case GEHC_PMC_ADC_VOLTAGE:
+		expected_type = IIO_VOLTAGE;
+		break;
+	case GEHC_PMC_ADC_CURRENT:
+		expected_type = IIO_CURRENT;
+		break;
+	default:
+		dev_err(&indio_dev->dev, "Invalid channel type %llu\n",
+			iiospec->args[0]);
+		return -EINVAL;
+	}
+
+	for (i = 0; i < indio_dev->num_channels; i++)
+		if (indio_dev->channels[i].type == expected_type &&
+		    indio_dev->channels[i].channel == iiospec->args[1])
+			return i;
+
+	dev_err(&indio_dev->dev, "Invalid channel type %llu number %llu\n",
+		iiospec->args[0], iiospec->args[1]);
+	return -EINVAL;
+}
+
+static const struct iio_info pmc_adc_info = {
+	.read_raw = pmc_adc_read_raw,
+	.fwnode_xlate = pmc_adc_fwnode_xlate,
+};
+
+static const char *const pmc_adc_regulator_names[] = {
+	"vdd",
+	"vdda",
+	"vddio",
+	"vref",
+};
+
+static int pmc_adc_probe(struct i2c_client *client)
+{
+	struct iio_dev *indio_dev;
+	struct pmc_adc *pmc_adc;
+	struct clk *clk;
+	s32 val;
+	int ret;
+
+	ret = devm_regulator_bulk_get_enable(&client->dev, ARRAY_SIZE(pmc_adc_regulator_names),
+					     pmc_adc_regulator_names);
+	if (ret)
+		return dev_err_probe(&client->dev, ret, "Failed to get regulators\n");
+
+	clk = devm_clk_get_optional_enabled(&client->dev, "osc");
+	if (IS_ERR(clk))
+		return dev_err_probe(&client->dev, PTR_ERR(clk), "Failed to get osc clock\n");
+
+	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*pmc_adc));
+	if (!indio_dev)
+		return -ENOMEM;
+
+	pmc_adc = iio_priv(indio_dev);
+	pmc_adc->client = client;
+
+	val = i2c_smbus_read_byte_data(pmc_adc->client, PMC_ADC_CMD_REQUEST_PROTOCOL_VERSION);
+	if (val < 0)
+		return dev_err_probe(&client->dev, val, "Failed to get protocol version\n");
+
+	if (val != 0x01)
+		return dev_err_probe(&client->dev, -EINVAL,
+				     "Unsupported protocol version 0x%02x\n", val);
+
+	indio_dev->name = "pmc_adc";
+	indio_dev->info = &pmc_adc_info;
+	indio_dev->channels = pmc_adc_channels;
+	indio_dev->num_channels = ARRAY_SIZE(pmc_adc_channels);
+
+	return devm_iio_device_register(&client->dev, indio_dev);
+}
+
+static const struct of_device_id pmc_adc_of_match[] = {
+	{ .compatible = "gehc,pmc-adc"},
+	{ }
+};
+MODULE_DEVICE_TABLE(of, pmc_adc_of_match);
+
+static const struct i2c_device_id pmc_adc_id_table[] = {
+	{ "pmc-adc" },
+	{ }
+};
+MODULE_DEVICE_TABLE(i2c, pmc_adc_id_table);
+
+static struct i2c_driver pmc_adc_i2c_driver = {
+	.driver  = {
+		.name = "pmc-adc",
+		.of_match_table = pmc_adc_of_match,
+	},
+	.id_table = pmc_adc_id_table,
+	.probe  = pmc_adc_probe,
+};
+
+module_i2c_driver(pmc_adc_i2c_driver);
+
+MODULE_AUTHOR("Herve Codina <herve.codina@bootlin.com>");
+MODULE_DESCRIPTION("GE HealthCare PMC ADC driver");
+MODULE_LICENSE("GPL");
-- 
2.46.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2 4/4] MAINTAINERS: add the GE HealthCare PMC ADC driver entry
  2024-10-03 11:46 [PATCH v2 0/4] Add support for the GE HealthCare PMC ADC Herve Codina
                   ` (2 preceding siblings ...)
  2024-10-03 11:46 ` [PATCH v2 3/4] iio: adc: Add support for " Herve Codina
@ 2024-10-03 11:46 ` Herve Codina
  2024-10-03 11:56   ` Ian Ray
  3 siblings, 1 reply; 12+ messages in thread
From: Herve Codina @ 2024-10-03 11:46 UTC (permalink / raw)
  To: Herve Codina, David Lechner, Jonathan Cameron, Lars-Peter Clausen,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley
  Cc: linux-iio, devicetree, linux-kernel, Luca Ceresoli, Ian Ray,
	Thomas Petazzoni

After contributing the driver, add myself as the maintainer for the
GE HealthCare PCM ADC IIO driver.

Signed-off-by: Herve Codina <herve.codina@bootlin.com>
---
 MAINTAINERS | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index bd288a97c770..6cccbe4e3d72 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -9459,6 +9459,14 @@ M:	Kieran Bingham <kbingham@kernel.org>
 S:	Supported
 F:	scripts/gdb/
 
+GE HEALTHCARE PMC ADC DRIVER
+M:	Herve Codina <herve.codina@bootlin.com>
+L:	linux-iio@vger.kernel.org
+S:	Maintained
+F:	Documentation/devicetree/bindings/iio/adc/gehc,pmc-adc.yaml
+F:	drivers/iio/adc/gehc-pmc-adc.c
+F:	include/dt-bindings/iio/adc/gehc,pmc-adc.h
+
 GEMINI CRYPTO DRIVER
 M:	Corentin Labbe <clabbe@baylibre.com>
 L:	linux-crypto@vger.kernel.org
-- 
2.46.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 1/4] dt-bindings: vendor-prefixes: Add an entry for GE HealthCare
  2024-10-03 11:46 ` [PATCH v2 1/4] dt-bindings: vendor-prefixes: Add an entry for GE HealthCare Herve Codina
@ 2024-10-03 11:55   ` Ian Ray
  0 siblings, 0 replies; 12+ messages in thread
From: Ian Ray @ 2024-10-03 11:55 UTC (permalink / raw)
  To: Herve Codina
  Cc: David Lechner, Jonathan Cameron, Lars-Peter Clausen, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, linux-iio, devicetree,
	linux-kernel, Luca Ceresoli, Thomas Petazzoni, Conor Dooley

On Thu, Oct 03, 2024 at 01:46:38PM +0200, Herve Codina wrote:
> 
> WARNING: This email originated from outside of GE HealthCare. Please validate the sender's email address before clicking on links or attachments as they may not be safe.
> 
> Add the "gehc" entry for GE HealthCare.
> https://www.gehealthcare.com
> 
> Signed-off-by: Herve Codina <herve.codina@bootlin.com>
> Acked-by: Conor Dooley <conor.dooley@microchip.com>

Tested-by: Ian Ray <ian.ray@gehealthcare.com>

> ---
>  Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml b/Documentation/devicetree/bindings/vendor-prefixes.yaml
> index b320a39de7fe..15877574a417 100644
> --- a/Documentation/devicetree/bindings/vendor-prefixes.yaml
> +++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml
> @@ -561,6 +561,8 @@ patternProperties:
>      description: GE Fanuc Intelligent Platforms Embedded Systems, Inc.
>    "^GEFanuc,.*":
>      description: GE Fanuc Intelligent Platforms Embedded Systems, Inc.
> +  "^gehc,.*":
> +    description: GE HealthCare
>    "^gemei,.*":
>      description: Gemei Digital Technology Co., Ltd.
>    "^gemtek,.*":
> --
> 2.46.1
> 
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 2/4] dt-bindings: iio: adc: Add the GE HealthCare PMC ADC
  2024-10-03 11:46 ` [PATCH v2 2/4] dt-bindings: iio: adc: Add the GE HealthCare PMC ADC Herve Codina
@ 2024-10-03 11:56   ` Ian Ray
  2024-10-03 16:16   ` Conor Dooley
  1 sibling, 0 replies; 12+ messages in thread
From: Ian Ray @ 2024-10-03 11:56 UTC (permalink / raw)
  To: Herve Codina
  Cc: David Lechner, Jonathan Cameron, Lars-Peter Clausen, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, linux-iio, devicetree,
	linux-kernel, Luca Ceresoli, Thomas Petazzoni

On Thu, Oct 03, 2024 at 01:46:39PM +0200, Herve Codina wrote:
> 
> WARNING: This email originated from outside of GE HealthCare. Please validate the sender's email address before clicking on links or attachments as they may not be safe.
> 
> The GE HealthCare PMC Analog to Digital Converter (ADC) is a 16-Channel
> (voltage and current), 16-Bit ADC with an I2C Interface.
> 
> Signed-off-by: Herve Codina <herve.codina@bootlin.com>

Tested-by: Ian Ray <ian.ray@gehealthcare.com>

> ---
>  .../bindings/iio/adc/gehc,pmc-adc.yaml        | 86 +++++++++++++++++++
>  include/dt-bindings/iio/adc/gehc,pmc-adc.h    | 10 +++
>  2 files changed, 96 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/iio/adc/gehc,pmc-adc.yaml
>  create mode 100644 include/dt-bindings/iio/adc/gehc,pmc-adc.h
> 
> diff --git a/Documentation/devicetree/bindings/iio/adc/gehc,pmc-adc.yaml b/Documentation/devicetree/bindings/iio/adc/gehc,pmc-adc.yaml
> new file mode 100644
> index 000000000000..2cea7c104a26
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/iio/adc/gehc,pmc-adc.yaml
> @@ -0,0 +1,86 @@
> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fdevicetree.org%2Fschemas%2Fiio%2Fadc%2Fgehc%2Cpmc-adc.yaml%23&data=05%7C02%7Cian.ray%40gehealthcare.com%7C29c6b87aecab477476ef08dce3a11117%7C9a309606d6ec4188a28a298812b4bbbf%7C0%7C0%7C638635528128598570%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=SDlnZF05zDF5iYE2X%2BsDV9BKN73B2rc5cAaPOJVY%2BrA%3D&reserved=0
> +$schema: https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fdevicetree.org%2Fmeta-schemas%2Fcore.yaml%23&data=05%7C02%7Cian.ray%40gehealthcare.com%7C29c6b87aecab477476ef08dce3a11117%7C9a309606d6ec4188a28a298812b4bbbf%7C0%7C0%7C638635528128610679%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=FbLudkkL4uUu2oTjkGLe7SFCI%2B5kXRCNhBPRcess0hc%3D&reserved=0
> +
> +title: GE HealthCare PMC Analog to Digital Converter (ADC)
> +
> +maintainers:
> +  - Herve Codina <herve.codina@bootlin.com>
> +
> +description:
> +  The GE HealthCare PMC ADC is a 16-Channel (voltage and current), 16-Bit ADC
> +  with an I2C Interface.
> +
> +properties:
> +  compatible:
> +    const: gehc,pmc-adc
> +
> +  reg:
> +    maxItems: 1
> +
> +  vdd-supply:
> +    description:
> +      Regulator for the VDD power supply.
> +
> +  vdda-supply:
> +    description:
> +      Regulator for the VDD analog (VDDA) power supply.
> +
> +  vddio-supply:
> +    description:
> +      Regulator for the VDD IO (VDDIO) power supply.
> +
> +  vref-supply:
> +    description:
> +      Regulator for the voltage reference power supply.
> +
> +  clocks:
> +    maxItems: 1
> +    description:
> +      The component uses an external oscillator (osc) if an external oscillator
> +      is connected to its clock pins. Otherwise, it uses an internal reference
> +      clock.
> +
> +  clock-names:
> +    items:
> +      - const: osc
> +
> +  "#io-channel-cells":
> +    const: 2
> +    description: |
> +      The first cell is the channel type (dt-bindings/iio/adc/gehc,pmc-adc.h
> +      defines these values):
> +       - 0: voltage
> +       - 1: current
> +      The second cell is the channel number from 0 to 15.
> +
> +required:
> +  - compatible
> +  - reg
> +  - vdd-supply
> +  - vdda-supply
> +  - vddio-supply
> +  - vref-supply
> +  - '#io-channel-cells'
> +
> +additionalProperties: false
> +
> +examples:
> +  - |
> +    i2c {
> +        #address-cells = <1>;
> +        #size-cells = <0>;
> +
> +        adc@14 {
> +            compatible = "gehc,pmc-adc";
> +            reg = <0x14>;
> +            vdd-supply = <&reg_vdd>;
> +            vdda-supply = <&reg_vdda>;
> +            vddio-supply = <&reg_vddio>;
> +            vref-supply = <&reg_vref>;
> +            #io-channel-cells = <2>;
> +        };
> +    };
> +...
> diff --git a/include/dt-bindings/iio/adc/gehc,pmc-adc.h b/include/dt-bindings/iio/adc/gehc,pmc-adc.h
> new file mode 100644
> index 000000000000..2f291e3c76ae
> --- /dev/null
> +++ b/include/dt-bindings/iio/adc/gehc,pmc-adc.h
> @@ -0,0 +1,10 @@
> +/* SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause */
> +
> +#ifndef _DT_BINDINGS_IIO_ADC_GEHC_PMC_ADC_H
> +#define _DT_BINDINGS_IIO_ADC_GEHC_PMC_ADC_H
> +
> +/* ADC channel type */
> +#define GEHC_PMC_ADC_VOLTAGE   0
> +#define GEHC_PMC_ADC_CURRENT   1
> +
> +#endif
> --
> 2.46.1
> 
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 3/4] iio: adc: Add support for the GE HealthCare PMC ADC
  2024-10-03 11:46 ` [PATCH v2 3/4] iio: adc: Add support for " Herve Codina
@ 2024-10-03 11:56   ` Ian Ray
  2024-10-03 13:39   ` David Lechner
  1 sibling, 0 replies; 12+ messages in thread
From: Ian Ray @ 2024-10-03 11:56 UTC (permalink / raw)
  To: Herve Codina
  Cc: David Lechner, Jonathan Cameron, Lars-Peter Clausen, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, linux-iio, devicetree,
	linux-kernel, Luca Ceresoli, Thomas Petazzoni

On Thu, Oct 03, 2024 at 01:46:40PM +0200, Herve Codina wrote:
> 
> The GE HealthCare PMC Analog to Digital Converter (ADC) is a 16-Channel
> (voltage and current), 16-Bit ADC with an I2C Interface.
> 
> Signed-off-by: Herve Codina <herve.codina@bootlin.com>

Tested-by: Ian Ray <ian.ray@gehealthcare.com>

> ---
>  drivers/iio/adc/Kconfig        |  10 ++
>  drivers/iio/adc/Makefile       |   1 +
>  drivers/iio/adc/gehc-pmc-adc.c | 227 +++++++++++++++++++++++++++++++++
>  3 files changed, 238 insertions(+)
>  create mode 100644 drivers/iio/adc/gehc-pmc-adc.c
> 
> diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
> index 97ece1a4b7e3..87b20f972c25 100644
> --- a/drivers/iio/adc/Kconfig
> +++ b/drivers/iio/adc/Kconfig
> @@ -571,6 +571,16 @@ config FSL_MX25_ADC
>           Generic Conversion Queue driver used for general purpose ADC in the
>           MX25. This driver supports single measurements using the MX25 ADC.
> 
> +config GEHC_PMC_ADC
> +       tristate "GE HealthCare PMC ADC driver"
> +       depends on I2C
> +       help
> +         Say yes here to build support for the GE HealthCare PMC 16-bit
> +         16-Channel ADC.
> +
> +         To compile this driver as a module, choose M here: the module will be
> +         called gehc-pmc-adc.
> +
>  config HI8435
>         tristate "Holt Integrated Circuits HI-8435 threshold detector"
>         select IIO_TRIGGERED_EVENT
> diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile
> index 7b91cd98c0e0..66b36dfe9a28 100644
> --- a/drivers/iio/adc/Makefile
> +++ b/drivers/iio/adc/Makefile
> @@ -52,6 +52,7 @@ obj-$(CONFIG_ENVELOPE_DETECTOR) += envelope-detector.o
>  obj-$(CONFIG_EP93XX_ADC) += ep93xx_adc.o
>  obj-$(CONFIG_EXYNOS_ADC) += exynos_adc.o
>  obj-$(CONFIG_FSL_MX25_ADC) += fsl-imx25-gcq.o
> +obj-$(CONFIG_GEHC_PMC_ADC) += gehc-pmc-adc.o
>  obj-$(CONFIG_HI8435) += hi8435.o
>  obj-$(CONFIG_HX711) += hx711.o
>  obj-$(CONFIG_IMX7D_ADC) += imx7d_adc.o
> diff --git a/drivers/iio/adc/gehc-pmc-adc.c b/drivers/iio/adc/gehc-pmc-adc.c
> new file mode 100644
> index 000000000000..c70a93f4a61b
> --- /dev/null
> +++ b/drivers/iio/adc/gehc-pmc-adc.c
> @@ -0,0 +1,227 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * The GE HealthCare PMC ADC is a 16-Channel (Voltage and current), 16-Bit
> + * ADC with an I2C Interface.
> + *
> + * Copyright (C) 2024, GE HealthCare
> + *
> + * Authors:
> + * Herve Codina <herve.codina@bootlin.com>
> + */
> +#include <dt-bindings/iio/adc/gehc,pmc-adc.h>
> +#include <linux/bitops.h>
> +#include <linux/clk.h>
> +#include <linux/i2c.h>
> +#include <linux/iio/iio.h>
> +#include <linux/module.h>
> +#include <linux/regulator/consumer.h>
> +#include <linux/slab.h>
> +
> +struct pmc_adc {
> +       struct i2c_client *client;
> +};
> +
> +#define PMC_ADC_CMD_REQUEST_PROTOCOL_VERSION   0x01
> +#define PMC_ADC_CMD_READ_VOLTAGE(_ch)          (0x10 | (_ch))
> +#define PMC_ADC_CMD_READ_CURRENT(_ch)          (0x20 | (_ch))
> +
> +#define PMC_ADC_VOLTAGE_CHANNEL(_ch, _ds_name) {                       \
> +       .type = IIO_VOLTAGE,                                            \
> +       .indexed = 1,                                                   \
> +       .channel = (_ch),                                               \
> +       .address = PMC_ADC_CMD_READ_VOLTAGE(_ch),                       \
> +       .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED),             \
> +       .datasheet_name = (_ds_name),                                   \
> +}
> +
> +#define PMC_ADC_CURRENT_CHANNEL(_ch, _ds_name) {                       \
> +       .type = IIO_CURRENT,                                            \
> +       .indexed = 1,                                                   \
> +       .channel = (_ch),                                               \
> +       .address = PMC_ADC_CMD_READ_CURRENT(_ch),                       \
> +       .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED),             \
> +       .datasheet_name = (_ds_name),                                   \
> +}
> +
> +static const struct iio_chan_spec pmc_adc_channels[] = {
> +       PMC_ADC_VOLTAGE_CHANNEL(0, "CH0_V"),
> +       PMC_ADC_VOLTAGE_CHANNEL(1, "CH1_V"),
> +       PMC_ADC_VOLTAGE_CHANNEL(2, "CH2_V"),
> +       PMC_ADC_VOLTAGE_CHANNEL(3, "CH3_V"),
> +       PMC_ADC_VOLTAGE_CHANNEL(4, "CH4_V"),
> +       PMC_ADC_VOLTAGE_CHANNEL(5, "CH5_V"),
> +       PMC_ADC_VOLTAGE_CHANNEL(6, "CH6_V"),
> +       PMC_ADC_VOLTAGE_CHANNEL(7, "CH7_V"),
> +       PMC_ADC_VOLTAGE_CHANNEL(8, "CH8_V"),
> +       PMC_ADC_VOLTAGE_CHANNEL(9, "CH9_V"),
> +       PMC_ADC_VOLTAGE_CHANNEL(10, "CH10_V"),
> +       PMC_ADC_VOLTAGE_CHANNEL(11, "CH11_V"),
> +       PMC_ADC_VOLTAGE_CHANNEL(12, "CH12_V"),
> +       PMC_ADC_VOLTAGE_CHANNEL(13, "CH13_V"),
> +       PMC_ADC_VOLTAGE_CHANNEL(14, "CH14_V"),
> +       PMC_ADC_VOLTAGE_CHANNEL(15, "CH15_V"),
> +
> +       PMC_ADC_CURRENT_CHANNEL(0, "CH0_I"),
> +       PMC_ADC_CURRENT_CHANNEL(1, "CH1_I"),
> +       PMC_ADC_CURRENT_CHANNEL(2, "CH2_I"),
> +       PMC_ADC_CURRENT_CHANNEL(3, "CH3_I"),
> +       PMC_ADC_CURRENT_CHANNEL(4, "CH4_I"),
> +       PMC_ADC_CURRENT_CHANNEL(5, "CH5_I"),
> +       PMC_ADC_CURRENT_CHANNEL(6, "CH6_I"),
> +       PMC_ADC_CURRENT_CHANNEL(7, "CH7_I"),
> +       PMC_ADC_CURRENT_CHANNEL(8, "CH8_I"),
> +       PMC_ADC_CURRENT_CHANNEL(9, "CH9_I"),
> +       PMC_ADC_CURRENT_CHANNEL(10, "CH10_I"),
> +       PMC_ADC_CURRENT_CHANNEL(11, "CH11_I"),
> +       PMC_ADC_CURRENT_CHANNEL(12, "CH12_I"),
> +       PMC_ADC_CURRENT_CHANNEL(13, "CH13_I"),
> +       PMC_ADC_CURRENT_CHANNEL(14, "CH14_I"),
> +       PMC_ADC_CURRENT_CHANNEL(15, "CH15_I"),
> +};
> +
> +static int pmc_adc_read_raw_ch(struct pmc_adc *pmc_adc, u8 cmd, int *val)
> +{
> +       s32 ret;
> +
> +       ret = i2c_smbus_read_word_swapped(pmc_adc->client, cmd);
> +       if (ret < 0) {
> +               dev_err(&pmc_adc->client->dev, "i2c read word failed (%d)\n", ret);
> +               return ret;
> +       }
> +
> +       *val = sign_extend32(ret, 15);
> +       return 0;
> +}
> +
> +static int pmc_adc_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan,
> +                           int *val, int *val2, long mask)
> +{
> +       struct pmc_adc *pmc_adc = iio_priv(indio_dev);
> +       int ret;
> +
> +       switch (mask) {
> +       case IIO_CHAN_INFO_PROCESSED:
> +               /* Values are directly read in mV or mA */
> +               ret = pmc_adc_read_raw_ch(pmc_adc, chan->address, val);
> +               if (ret)
> +                       return ret;
> +               return IIO_VAL_INT;
> +       }
> +
> +       return -EINVAL;
> +}
> +
> +static int pmc_adc_fwnode_xlate(struct iio_dev *indio_dev,
> +                               const struct fwnode_reference_args *iiospec)
> +{
> +       enum iio_chan_type expected_type;
> +       unsigned int i;
> +
> +       /*
> +        * args[0]: Acquisition type (i.e. voltage or current)
> +        * args[1]: PMC ADC channel number
> +        */
> +       if (iiospec->nargs != 2)
> +               return -EINVAL;
> +
> +       switch (iiospec->args[0]) {
> +       case GEHC_PMC_ADC_VOLTAGE:
> +               expected_type = IIO_VOLTAGE;
> +               break;
> +       case GEHC_PMC_ADC_CURRENT:
> +               expected_type = IIO_CURRENT;
> +               break;
> +       default:
> +               dev_err(&indio_dev->dev, "Invalid channel type %llu\n",
> +                       iiospec->args[0]);
> +               return -EINVAL;
> +       }
> +
> +       for (i = 0; i < indio_dev->num_channels; i++)
> +               if (indio_dev->channels[i].type == expected_type &&
> +                   indio_dev->channels[i].channel == iiospec->args[1])
> +                       return i;
> +
> +       dev_err(&indio_dev->dev, "Invalid channel type %llu number %llu\n",
> +               iiospec->args[0], iiospec->args[1]);
> +       return -EINVAL;
> +}
> +
> +static const struct iio_info pmc_adc_info = {
> +       .read_raw = pmc_adc_read_raw,
> +       .fwnode_xlate = pmc_adc_fwnode_xlate,
> +};
> +
> +static const char *const pmc_adc_regulator_names[] = {
> +       "vdd",
> +       "vdda",
> +       "vddio",
> +       "vref",
> +};
> +
> +static int pmc_adc_probe(struct i2c_client *client)
> +{
> +       struct iio_dev *indio_dev;
> +       struct pmc_adc *pmc_adc;
> +       struct clk *clk;
> +       s32 val;
> +       int ret;
> +
> +       ret = devm_regulator_bulk_get_enable(&client->dev, ARRAY_SIZE(pmc_adc_regulator_names),
> +                                            pmc_adc_regulator_names);
> +       if (ret)
> +               return dev_err_probe(&client->dev, ret, "Failed to get regulators\n");
> +
> +       clk = devm_clk_get_optional_enabled(&client->dev, "osc");
> +       if (IS_ERR(clk))
> +               return dev_err_probe(&client->dev, PTR_ERR(clk), "Failed to get osc clock\n");
> +
> +       indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*pmc_adc));
> +       if (!indio_dev)
> +               return -ENOMEM;
> +
> +       pmc_adc = iio_priv(indio_dev);
> +       pmc_adc->client = client;
> +
> +       val = i2c_smbus_read_byte_data(pmc_adc->client, PMC_ADC_CMD_REQUEST_PROTOCOL_VERSION);
> +       if (val < 0)
> +               return dev_err_probe(&client->dev, val, "Failed to get protocol version\n");
> +
> +       if (val != 0x01)
> +               return dev_err_probe(&client->dev, -EINVAL,
> +                                    "Unsupported protocol version 0x%02x\n", val);
> +
> +       indio_dev->name = "pmc_adc";
> +       indio_dev->info = &pmc_adc_info;
> +       indio_dev->channels = pmc_adc_channels;
> +       indio_dev->num_channels = ARRAY_SIZE(pmc_adc_channels);
> +
> +       return devm_iio_device_register(&client->dev, indio_dev);
> +}
> +
> +static const struct of_device_id pmc_adc_of_match[] = {
> +       { .compatible = "gehc,pmc-adc"},
> +       { }
> +};
> +MODULE_DEVICE_TABLE(of, pmc_adc_of_match);
> +
> +static const struct i2c_device_id pmc_adc_id_table[] = {
> +       { "pmc-adc" },
> +       { }
> +};
> +MODULE_DEVICE_TABLE(i2c, pmc_adc_id_table);
> +
> +static struct i2c_driver pmc_adc_i2c_driver = {
> +       .driver  = {
> +               .name = "pmc-adc",
> +               .of_match_table = pmc_adc_of_match,
> +       },
> +       .id_table = pmc_adc_id_table,
> +       .probe  = pmc_adc_probe,
> +};
> +
> +module_i2c_driver(pmc_adc_i2c_driver);
> +
> +MODULE_AUTHOR("Herve Codina <herve.codina@bootlin.com>");
> +MODULE_DESCRIPTION("GE HealthCare PMC ADC driver");
> +MODULE_LICENSE("GPL");
> --
> 2.46.1
> 
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 4/4] MAINTAINERS: add the GE HealthCare PMC ADC driver entry
  2024-10-03 11:46 ` [PATCH v2 4/4] MAINTAINERS: add the GE HealthCare PMC ADC driver entry Herve Codina
@ 2024-10-03 11:56   ` Ian Ray
  0 siblings, 0 replies; 12+ messages in thread
From: Ian Ray @ 2024-10-03 11:56 UTC (permalink / raw)
  To: Herve Codina
  Cc: David Lechner, Jonathan Cameron, Lars-Peter Clausen, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, linux-iio, devicetree,
	linux-kernel, Luca Ceresoli, Thomas Petazzoni

On Thu, Oct 03, 2024 at 01:46:41PM +0200, Herve Codina wrote:
> 
> After contributing the driver, add myself as the maintainer for the
> GE HealthCare PCM ADC IIO driver.
> 
> Signed-off-by: Herve Codina <herve.codina@bootlin.com>

Tested-by: Ian Ray <ian.ray@gehealthcare.com>

> ---
>  MAINTAINERS | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index bd288a97c770..6cccbe4e3d72 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -9459,6 +9459,14 @@ M:       Kieran Bingham <kbingham@kernel.org>
>  S:     Supported
>  F:     scripts/gdb/
> 
> +GE HEALTHCARE PMC ADC DRIVER
> +M:     Herve Codina <herve.codina@bootlin.com>
> +L:     linux-iio@vger.kernel.org
> +S:     Maintained
> +F:     Documentation/devicetree/bindings/iio/adc/gehc,pmc-adc.yaml
> +F:     drivers/iio/adc/gehc-pmc-adc.c
> +F:     include/dt-bindings/iio/adc/gehc,pmc-adc.h
> +
>  GEMINI CRYPTO DRIVER
>  M:     Corentin Labbe <clabbe@baylibre.com>
>  L:     linux-crypto@vger.kernel.org
> --
> 2.46.1
> 
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 3/4] iio: adc: Add support for the GE HealthCare PMC ADC
  2024-10-03 11:46 ` [PATCH v2 3/4] iio: adc: Add support for " Herve Codina
  2024-10-03 11:56   ` Ian Ray
@ 2024-10-03 13:39   ` David Lechner
  2024-10-06 13:05     ` Jonathan Cameron
  1 sibling, 1 reply; 12+ messages in thread
From: David Lechner @ 2024-10-03 13:39 UTC (permalink / raw)
  To: Herve Codina, Jonathan Cameron, Lars-Peter Clausen, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley
  Cc: linux-iio, devicetree, linux-kernel, Luca Ceresoli, Ian Ray,
	Thomas Petazzoni

On 10/3/24 6:46 AM, Herve Codina wrote:
> The GE HealthCare PMC Analog to Digital Converter (ADC) is a 16-Channel
> (voltage and current), 16-Bit ADC with an I2C Interface.
> 
> Signed-off-by: Herve Codina <herve.codina@bootlin.com>
> ---

...


> +
> +static int pmc_adc_probe(struct i2c_client *client)
> +{
> +	struct iio_dev *indio_dev;
> +	struct pmc_adc *pmc_adc;
> +	struct clk *clk;
> +	s32 val;
> +	int ret;
> +
> +	ret = devm_regulator_bulk_get_enable(&client->dev, ARRAY_SIZE(pmc_adc_regulator_names),
> +					     pmc_adc_regulator_names);
> +	if (ret)
> +		return dev_err_probe(&client->dev, ret, "Failed to get regulators\n");
> +
> +	clk = devm_clk_get_optional_enabled(&client->dev, "osc");
> +	if (IS_ERR(clk))
> +		return dev_err_probe(&client->dev, PTR_ERR(clk), "Failed to get osc clock\n");
> +
> +	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*pmc_adc));
> +	if (!indio_dev)
> +		return -ENOMEM;
> +
> +	pmc_adc = iio_priv(indio_dev);
> +	pmc_adc->client = client;
> +
> +	val = i2c_smbus_read_byte_data(pmc_adc->client, PMC_ADC_CMD_REQUEST_PROTOCOL_VERSION);
> +	if (val < 0)
> +		return dev_err_probe(&client->dev, val, "Failed to get protocol version\n");
> +
> +	if (val != 0x01)
> +		return dev_err_probe(&client->dev, -EINVAL,
> +				     "Unsupported protocol version 0x%02x\n", val);
> +
> +	indio_dev->name = "pmc_adc";
> +	indio_dev->info = &pmc_adc_info;
> +	indio_dev->channels = pmc_adc_channels;
> +	indio_dev->num_channels = ARRAY_SIZE(pmc_adc_channels);

I don't think the core code actually checks this, but for
correctness we should add:

	indio_dev->modes = INDIO_DIRECT_MODE;

> +
> +	return devm_iio_device_register(&client->dev, indio_dev);
> +}
> +

With that...

Reviewed-by: David Lechner <dlechner@baylibre.com>


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 2/4] dt-bindings: iio: adc: Add the GE HealthCare PMC ADC
  2024-10-03 11:46 ` [PATCH v2 2/4] dt-bindings: iio: adc: Add the GE HealthCare PMC ADC Herve Codina
  2024-10-03 11:56   ` Ian Ray
@ 2024-10-03 16:16   ` Conor Dooley
  1 sibling, 0 replies; 12+ messages in thread
From: Conor Dooley @ 2024-10-03 16:16 UTC (permalink / raw)
  To: Herve Codina
  Cc: David Lechner, Jonathan Cameron, Lars-Peter Clausen, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, linux-iio, devicetree,
	linux-kernel, Luca Ceresoli, Ian Ray, Thomas Petazzoni

[-- Attachment #1: Type: text/plain, Size: 318 bytes --]

On Thu, Oct 03, 2024 at 01:46:39PM +0200, Herve Codina wrote:
> The GE HealthCare PMC Analog to Digital Converter (ADC) is a 16-Channel
> (voltage and current), 16-Bit ADC with an I2C Interface.
> 
> Signed-off-by: Herve Codina <herve.codina@bootlin.com>

Reviewed-by: Conor Dooley <conor.dooley@microchip.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 3/4] iio: adc: Add support for the GE HealthCare PMC ADC
  2024-10-03 13:39   ` David Lechner
@ 2024-10-06 13:05     ` Jonathan Cameron
  0 siblings, 0 replies; 12+ messages in thread
From: Jonathan Cameron @ 2024-10-06 13:05 UTC (permalink / raw)
  To: David Lechner
  Cc: Herve Codina, Lars-Peter Clausen, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, linux-iio, devicetree,
	linux-kernel, Luca Ceresoli, Ian Ray, Thomas Petazzoni

On Thu, 3 Oct 2024 08:39:54 -0500
David Lechner <dlechner@baylibre.com> wrote:

> On 10/3/24 6:46 AM, Herve Codina wrote:
> > The GE HealthCare PMC Analog to Digital Converter (ADC) is a 16-Channel
> > (voltage and current), 16-Bit ADC with an I2C Interface.
> > 
> > Signed-off-by: Herve Codina <herve.codina@bootlin.com>
> > ---  
> 
> ...
> 
> 
> > +
> > +static int pmc_adc_probe(struct i2c_client *client)
> > +{
> > +	struct iio_dev *indio_dev;
> > +	struct pmc_adc *pmc_adc;
> > +	struct clk *clk;
> > +	s32 val;
> > +	int ret;
> > +
> > +	ret = devm_regulator_bulk_get_enable(&client->dev, ARRAY_SIZE(pmc_adc_regulator_names),
> > +					     pmc_adc_regulator_names);
> > +	if (ret)
> > +		return dev_err_probe(&client->dev, ret, "Failed to get regulators\n");
> > +
> > +	clk = devm_clk_get_optional_enabled(&client->dev, "osc");
> > +	if (IS_ERR(clk))
> > +		return dev_err_probe(&client->dev, PTR_ERR(clk), "Failed to get osc clock\n");
> > +
> > +	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*pmc_adc));
> > +	if (!indio_dev)
> > +		return -ENOMEM;
> > +
> > +	pmc_adc = iio_priv(indio_dev);
> > +	pmc_adc->client = client;
> > +
> > +	val = i2c_smbus_read_byte_data(pmc_adc->client, PMC_ADC_CMD_REQUEST_PROTOCOL_VERSION);
> > +	if (val < 0)
> > +		return dev_err_probe(&client->dev, val, "Failed to get protocol version\n");
> > +
> > +	if (val != 0x01)
> > +		return dev_err_probe(&client->dev, -EINVAL,
> > +				     "Unsupported protocol version 0x%02x\n", val);
> > +
> > +	indio_dev->name = "pmc_adc";
> > +	indio_dev->info = &pmc_adc_info;
> > +	indio_dev->channels = pmc_adc_channels;
> > +	indio_dev->num_channels = ARRAY_SIZE(pmc_adc_channels);  
> 
> I don't think the core code actually checks this, but for
> correctness we should add:
> 
> 	indio_dev->modes = INDIO_DIRECT_MODE;
True.  This is a bit of an oddity of history :(
Maybe at somepoint we'll just drop this but for now it should be there.

Given everything else looks good I've added that whilst
applying the series.  Applied to the togreg branch of iio.git and
pushed out as testing for 0-day to poke at it.

Thanks,

Jonathan


> 
> > +
> > +	return devm_iio_device_register(&client->dev, indio_dev);
> > +}
> > +  
> 
> With that...
> 
> Reviewed-by: David Lechner <dlechner@baylibre.com>
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2024-10-06 13:05 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-03 11:46 [PATCH v2 0/4] Add support for the GE HealthCare PMC ADC Herve Codina
2024-10-03 11:46 ` [PATCH v2 1/4] dt-bindings: vendor-prefixes: Add an entry for GE HealthCare Herve Codina
2024-10-03 11:55   ` Ian Ray
2024-10-03 11:46 ` [PATCH v2 2/4] dt-bindings: iio: adc: Add the GE HealthCare PMC ADC Herve Codina
2024-10-03 11:56   ` Ian Ray
2024-10-03 16:16   ` Conor Dooley
2024-10-03 11:46 ` [PATCH v2 3/4] iio: adc: Add support for " Herve Codina
2024-10-03 11:56   ` Ian Ray
2024-10-03 13:39   ` David Lechner
2024-10-06 13:05     ` Jonathan Cameron
2024-10-03 11:46 ` [PATCH v2 4/4] MAINTAINERS: add the GE HealthCare PMC ADC driver entry Herve Codina
2024-10-03 11:56   ` Ian Ray

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).