Skip to contentSkip to conversation

Add support for the GE HealthCare PMC ADC

PATCH Superseded Herve Codina 4 participants 16 messages Oct 1, 2024 – Oct 6, 2024

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Herve Codina

author maintainer
#0 lore raw

cover Add support for the GE HealthCare PMC ADC

Hi,

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

Best regards,
Herve Codina

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        |  82 ++++++
 .../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                | 233 ++++++++++++++++++
 include/dt-bindings/iio/adc/gehc,pmc-adc.h    |  10 +
 7 files changed, 346 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
Signature · 1 line
2.46.1
author maintainer
#1 lore raw

PATCH 1/4 dt-bindings: vendor-prefixes: Add an entry for GE HealthCare

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

---
 Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/vendor-prefixes.yaml +2 -0
index b320a39de7fe..15877574a417 100644
@@ -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,.*":
Signature · 1 line
2.46.1
author maintainer
#3 lore raw

PATCH 2/4 dt-bindings: iio: adc: Add the GE HealthCare PMC ADC

In reply to Herve Codina

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

---
 .../bindings/iio/adc/gehc,pmc-adc.yaml        | 82 +++++++++++++++++++
 include/dt-bindings/iio/adc/gehc,pmc-adc.h    | 10 +++
 2 files changed, 92 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
Documentation/devicetree/bindings/iio/adc/gehc,pmc-adc.yaml new file +82 -0
new file mode 100644
index 000000000000..6b2bb1309767
@@ -0,0 +1,82 @@
+# 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 <[email protected]>
+
+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
+
+  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>;
+        };
+    };
+...
include/dt-bindings/iio/adc/gehc,pmc-adc.h new file +10 -0
new file mode 100644
index 000000000000..2f291e3c76ae
@@ -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
Signature · 1 line
2.46.1
#4 lore raw

Re: [PATCH 2/4] dt-bindings: iio: adc: Add the GE HealthCare PMC ADC

Quoted 51 lines · Herve Codina

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

---
 .../bindings/iio/adc/gehc,pmc-adc.yaml        | 82 +++++++++++++++++++
 include/dt-bindings/iio/adc/gehc,pmc-adc.h    | 10 +++
 2 files changed, 92 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
Documentation/devicetree/bindings/iio/adc/gehc,pmc-adc.yaml new file +34 -0
new file mode 100644
index 000000000000..6b2bb1309767
@@ -0,0 +1,82 @@
+# 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 <[email protected]>
+
+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.
+

Documentation/devicetree/bindings/iio/adc/gehc,pmc-adc.yaml line 44

Quoted 10 lines
Documentation/devicetree/bindings/iio/adc/gehc,pmc-adc.yaml new file +10 -0
+  vref-supply:
+    description:
+      Regulator for the voltage reference power supply.
+
+  clocks:
+    maxItems: 1
+
+  clock-names:
+    items:
+      - const: osc

Since there's no datasheet for me to look up, why is the clock optional?

Quoted 57 lines
Documentation/devicetree/bindings/iio/adc/gehc,pmc-adc.yaml new file +38 -0
+
+  "#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>;
+        };
+    };
+...
include/dt-bindings/iio/adc/gehc,pmc-adc.h new file +10 -0
new file mode 100644
index 000000000000..2f291e3c76ae
@@ -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
Signature · 1 line
2.46.1
author maintainer
#5 lore raw

Re: [PATCH 2/4] dt-bindings: iio: adc: Add the GE HealthCare PMC ADC

Quoted 8 lines · On Tue, 1 Oct 2024 17:18:30 +0100 Conor Dooley <[email protected]> wrote:
Quoted 7 lines · Herve Codina

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

---
 .../bindings/iio/adc/gehc,pmc-adc.yaml        | 82 +++++++++++++++++++
 include/dt-bindings/iio/adc/gehc,pmc-adc.h    | 10 +++

...

Quoted 8 lines

Documentation/devicetree/bindings/iio/adc/gehc,pmc-adc.yaml line 44

Quoted 6 lines
Documentation/devicetree/bindings/iio/adc/gehc,pmc-adc.yaml new file +6 -0
+  clocks:
+    maxItems: 1
+
+  clock-names:
+    items:
+      - const: osc  

Since there's no datasheet for me to look up, why is the clock optional?

The component uses an external oscillator (osc) if an external oscillator is connected to its clock pins. Otherwise, it uses an internal reference clock.

Best regards,
Hervé

Signature · 3 lines
Hervé Codina, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#6 lore raw

Re: [PATCH 2/4] dt-bindings: iio: adc: Add the GE HealthCare PMC ADC

Quoted 19 lines · Herve Codina
Quoted 8 lines · On Tue, 1 Oct 2024 17:18:30 +0100 Conor Dooley <[email protected]> wrote:
Quoted 7 lines · Herve Codina

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

---
 .../bindings/iio/adc/gehc,pmc-adc.yaml        | 82 +++++++++++++++++++
 include/dt-bindings/iio/adc/gehc,pmc-adc.h    | 10 +++

...

Quoted 7 lines
Quoted 6 lines
Documentation/devicetree/bindings/iio/adc/gehc,pmc-adc.yaml new file +6 -0
+  clocks:
+    maxItems: 1
+
+  clock-names:
+    items:
+      - const: osc  
Quoted 4 lines
Quoted 1 line

Since there's no datasheet for me to look up, why is the clock optional?

The component uses an external oscillator (osc) if an external oscillator is connected to its clock pins. Otherwise, it uses an internal reference clock.

Could you please add a description of the clock with this statement, given there's no datasheet or w/e linked here?

author maintainer
#7 lore raw

Re: [PATCH 2/4] dt-bindings: iio: adc: Add the GE HealthCare PMC ADC

Hi Conor,

Quoted 20 lines · On Tue, 1 Oct 2024 18:03:37 +0100 Conor Dooley <[email protected]> wrote:
Quoted 19 lines · Herve Codina
Quoted 8 lines · On Tue, 1 Oct 2024 17:18:30 +0100 Conor Dooley <[email protected]> wrote:
Quoted 7 lines · Herve Codina

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

---
 .../bindings/iio/adc/gehc,pmc-adc.yaml        | 82 +++++++++++++++++++
 include/dt-bindings/iio/adc/gehc,pmc-adc.h    | 10 +++  

...

Quoted 7 lines
Quoted 6 lines
Documentation/devicetree/bindings/iio/adc/gehc,pmc-adc.yaml new file +6 -0
+  clocks:
+    maxItems: 1
+
+  clock-names:
+    items:
+      - const: osc    
Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Since there's no datasheet for me to look up, why is the clock optional?

The component uses an external oscillator (osc) if an external oscillator is connected to its clock pins. Otherwise, it uses an internal reference clock.

Could you please add a description of the clock with this statement, given there's no datasheet or w/e linked here?

Sure, I will add a description in the next iteration.

There is no datasheet or any similar document available for this component. This is reason why I cannot add a link to this kind of dos.

Best regards,
Hervé

#8 lore raw

Re: [PATCH 2/4] dt-bindings: iio: adc: Add the GE HealthCare PMC ADC

Quoted 30 lines · Herve Codina

Hi Conor,

Quoted 25 lines · On Tue, 1 Oct 2024 18:03:37 +0100 Conor Dooley <[email protected]> wrote:
Quoted 23 lines · Herve Codina
Quoted 8 lines · On Tue, 1 Oct 2024 17:18:30 +0100 Conor Dooley <[email protected]> wrote:
Quoted 7 lines · Herve Codina

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

---
 .../bindings/iio/adc/gehc,pmc-adc.yaml        | 82 +++++++++++++++++++
 include/dt-bindings/iio/adc/gehc,pmc-adc.h    | 10 +++  

...

Quoted 8 lines

Documentation/devicetree/bindings/iio/adc/gehc,pmc-adc.yaml line 44

Quoted 6 lines
Documentation/devicetree/bindings/iio/adc/gehc,pmc-adc.yaml new file +6 -0
+  clocks:
+    maxItems: 1
+
+  clock-names:
+    items:
+      - const: osc    

Since there's no datasheet for me to look up, why is the clock optional?

The component uses an external oscillator (osc) if an external oscillator is connected to its clock pins. Otherwise, it uses an internal reference clock.

Quoted 7 lines
Quoted 2 lines

Could you please add a description of the clock with this statement, given there's no datasheet or w/e linked here?

Sure, I will add a description in the next iteration.

There is no datasheet or any similar document available for this component. This is reason why I cannot add a link to this kind of dos.

Yeah, I had taken a look last night and couldn't find one, so I figured that this was the case.

author maintainer
#9 lore raw

PATCH 3/4 iio: adc: Add support for the GE HealthCare PMC ADC

In reply to Herve Codina

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

---
 drivers/iio/adc/Kconfig        |  10 ++
 drivers/iio/adc/Makefile       |   1 +
 drivers/iio/adc/gehc-pmc-adc.c | 233 +++++++++++++++++++++++++++++++++
 3 files changed, 244 insertions(+)
 create mode 100644 drivers/iio/adc/gehc-pmc-adc.c
drivers/iio/adc/Kconfig +10 -0
index 97ece1a4b7e3..87b20f972c25 100644
@@ -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
drivers/iio/adc/Makefile +1 -0
index 7b91cd98c0e0..66b36dfe9a28 100644
@@ -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
drivers/iio/adc/gehc-pmc-adc.c new file +233 -0

233 lines not on this page · raw message

Signature · 1 line
2.46.1
reviewer
#10 lore raw

Re: [PATCH 3/4] iio: adc: Add support for the GE HealthCare PMC ADC

Quoted 6 lines · Herve Codina

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

---

...

drivers/iio/adc/gehc-pmc-adc.c line 94

Quoted 11 lines
drivers/iio/adc/gehc-pmc-adc.c new file +11 -0
+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, 16);

Shouldn't this be 15, not 16?

Quoted 3 lines
drivers/iio/adc/gehc-pmc-adc.c new file +3 -0
+       return 0;
+}
+

...

Quoted 21 lines
drivers/iio/adc/gehc-pmc-adc.c new file +21 -0
+
+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;

drivers/iio/adc/gehc-pmc-adc.c line 196

Quoted 10 lines
drivers/iio/adc/gehc-pmc-adc.c new file +10 -0
+
+       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) {
+               dev_err(&client->dev, "Unsupported protocol version 0x%02x\n", val);

Use dev_err_probe?

Quoted 10 lines
drivers/iio/adc/gehc-pmc-adc.c new file +10 -0
+               return -EINVAL;
+       }
+
+       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);
+}
author maintainer
#11 lore raw

Re: [PATCH 3/4] iio: adc: Add support for the GE HealthCare PMC ADC

Hi David,

Quoted 10 lines · On Tue, 1 Oct 2024 12:19:16 -0500 David Lechner <[email protected]> wrote:
Quoted 6 lines · Herve Codina

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

---

...

Quoted 13 lines

drivers/iio/adc/gehc-pmc-adc.c line 94

Quoted 11 lines
drivers/iio/adc/gehc-pmc-adc.c new file +11 -0
+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, 16);  

Shouldn't this be 15, not 16?

Yes, indeed, I double checked on my side and it should be 15! Thanks for catching it. It will be fixed in the next iteration.

Quoted 32 lines
Quoted 4 lines
drivers/iio/adc/gehc-pmc-adc.c new file +3 -0
+       return 0;
+}
+  

...

Quoted 25 lines
drivers/iio/adc/gehc-pmc-adc.c new file +25 -0
+
+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;
+
Quoted 8 lines

drivers/iio/adc/gehc-pmc-adc.c line 196

Quoted 6 lines
drivers/iio/adc/gehc-pmc-adc.c new file +6 -0
+       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) {
+               dev_err(&client->dev, "Unsupported protocol version 0x%02x\n", val);  

Use dev_err_probe?

Yes, will be changed in the next iteration.

Quoted 4 lines

drivers/iio/adc/gehc-pmc-adc.c line 118

Quoted 4 lines
drivers/iio/adc/gehc-pmc-adc.c new file +3 -0
+               return -EINVAL;
+       }
+

Best regards,
Hervé

maintainer
#12 lore raw

Re: [PATCH 3/4] iio: adc: Add support for the GE HealthCare PMC ADC

In reply to Herve Codina
Quoted 4 lines · On Tue, 1 Oct 2024 09:46:17 +0200 Herve Codina <[email protected]>…

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

Just one thing to add to David's review.

I'm going to guess this isn't a general purpose ADC? Can you share any info on what sort of device it is used in?

No problem if not - I'm just curious as I've not seen GE HealthCare I2C parts before!

Quoted 14 lines
drivers/iio/adc/gehc-pmc-adc.c new file +6 -0
new file mode 100644
index 000000000000..c46c2fb84d35
@@ -0,0 +1,233 @@
 
 
+
+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;

drivers/iio/adc/gehc-pmc-adc.c line 112

Quoted 10 lines
drivers/iio/adc/gehc-pmc-adc.c new file +10 -0
+
+	switch (mask) {
+	case IIO_CHAN_INFO_RAW:
+		ret = pmc_adc_read_raw_ch(pmc_adc, chan->address, val);
+		if (ret)
+			return ret;
+		return IIO_VAL_INT;
+
+	case IIO_CHAN_INFO_SCALE:
+		*val = 1; /* Raw values are directly read in mV or mA */

Drop this scale and make the channels processed. That saves userspace even applying the *1 this indicates. Rare to find a device that outputs in our base units but might as well take advantage of one that does :)

Quoted 5 lines
drivers/iio/adc/gehc-pmc-adc.c new file +5 -0
+		return IIO_VAL_INT;
+	}
+
+	return -EINVAL;
+}
author maintainer
#13 lore raw

Re: [PATCH 3/4] iio: adc: Add support for the GE HealthCare PMC ADC

Hi Jonathan,

Quoted 8 lines · On Tue, 1 Oct 2024 20:24:30 +0100 Jonathan Cameron <[email protected]> wrote:
Quoted 4 lines · On Tue, 1 Oct 2024 09:46:17 +0200 Herve Codina <[email protected]>…

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

Quoted 7 lines

Just one thing to add to David's review.

I'm going to guess this isn't a general purpose ADC? Can you share any info on what sort of device it is used in?

No problem if not - I'm just curious as I've not seen GE HealthCare I2C parts before!

I cannot tell about the product it is used in :(
One sure thing I can say is that the component itself is not available off the shelf, and is fully designed to be used in a specific product.

Quoted 19 lines
Quoted 19 lines
drivers/iio/adc/gehc-pmc-adc.c new file +10 -0
new file mode 100644
index 000000000000..c46c2fb84d35
@@ -0,0 +1,233 @@  
 
 
+
+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_RAW:
+		ret = pmc_adc_read_raw_ch(pmc_adc, chan->address, val);
Quoted 8 lines

drivers/iio/adc/gehc-pmc-adc.c line 112

Quoted 6 lines
drivers/iio/adc/gehc-pmc-adc.c new file +6 -0
+		if (ret)
+			return ret;
+		return IIO_VAL_INT;
+
+	case IIO_CHAN_INFO_SCALE:
+		*val = 1; /* Raw values are directly read in mV or mA */  

Drop this scale and make the channels processed. That saves userspace even applying

I thought that scale was mandatory.

From the userspace, offset is clearly optional
https://elixir.bootlin.com/linux/v6.11/source/Documentation/ABI/testing/sysfs-bus-iio#L458
But nothing about a default value is mentioned in the scale description
https://elixir.bootlin.com/linux/v6.11/source/Documentation/ABI/testing/sysfs-bus-iio#L515

Quoted 2 lines

the *1 this indicates. Rare to find a device that outputs in our base units but might as well take advantage of one that does :)

Yes, the device is a custom designed device and it has a fully knowledge (by design) of the board it is soldered on. As I was involved in the communication protocol definition, units were chosen to fit well with IIO.

Quoted 6 lines

drivers/iio/adc/gehc-pmc-adc.c line 117

Quoted 6 lines
drivers/iio/adc/gehc-pmc-adc.c new file +5 -0
+		return IIO_VAL_INT;
+	}
+
+	return -EINVAL;
+}  

Best regards,
Hervé

maintainer
#14 lore raw

Re: [PATCH 3/4] iio: adc: Add support for the GE HealthCare PMC ADC

Quoted 53 lines · On Wed, 2 Oct 2024 10:23:24 +0200 Herve Codina <[email protected]> wrote:

Hi Jonathan,

Quoted 8 lines · On Tue, 1 Oct 2024 20:24:30 +0100 Jonathan Cameron <[email protected]> wrote:
Quoted 4 lines · On Tue, 1 Oct 2024 09:46:17 +0200 Herve Codina <[email protected]>…

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

Quoted 7 lines

Just one thing to add to David's review.

I'm going to guess this isn't a general purpose ADC? Can you share any info on what sort of device it is used in?

No problem if not - I'm just curious as I've not seen GE HealthCare I2C parts before!

I cannot tell about the product it is used in :(
One sure thing I can say is that the component itself is not available off the shelf, and is fully designed to be used in a specific product.

Quoted 19 lines
Quoted 19 lines
drivers/iio/adc/gehc-pmc-adc.c new file +10 -0
new file mode 100644
index 000000000000..c46c2fb84d35
@@ -0,0 +1,233 @@    
 
 
+
+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_RAW:
+		ret = pmc_adc_read_raw_ch(pmc_adc, chan->address, val);
Quoted 8 lines

drivers/iio/adc/gehc-pmc-adc.c line 112

Quoted 6 lines
drivers/iio/adc/gehc-pmc-adc.c new file +6 -0
+		if (ret)
+			return ret;
+		return IIO_VAL_INT;
+
+	case IIO_CHAN_INFO_SCALE:
+		*val = 1; /* Raw values are directly read in mV or mA */    

Drop this scale and make the channels processed. That saves userspace even applying

Quoted 6 lines

I thought that scale was mandatory.

From the userspace, offset is clearly optional
https://elixir.bootlin.com/linux/v6.11/source/Documentation/ABI/testing/sysfs-bus-iio#L458
But nothing about a default value is mentioned in the scale description
https://elixir.bootlin.com/linux/v6.11/source/Documentation/ABI/testing/sysfs-bus-iio#L515

It doesn't get applied to _PROCESSED attributes (see ABI for _input attributes which simply doesn't say to apply anything.

There is a corner case where _OFFSET is provided but not _SCALE and hence the channel is _RAW. In that case I'd say _SCALE is optional, but I'm not sure we've ever seen it in reality! The more common case (though still rare) is like this one where the reading is in the base units of the ABI so _input is the away to go. This is fairly ancient ABI lifted from hwmon.

Quoted 7 lines
Quoted 3 lines

the *1 this indicates. Rare to find a device that outputs in our base units but might as well take advantage of one that does :)

Yes, the device is a custom designed device and it has a fully knowledge (by design) of the board it is soldered on. As I was involved in the communication protocol definition, units were chosen to fit well with IIO.

Nice :)

Quoted 10 lines
Quoted 7 lines

drivers/iio/adc/gehc-pmc-adc.c line 117

Quoted 7 lines
drivers/iio/adc/gehc-pmc-adc.c new file +5 -0
+		return IIO_VAL_INT;
+	}
+
+	return -EINVAL;
+}    

Best regards,
Hervé

author maintainer
#15 lore raw

PATCH 4/4 MAINTAINERS: add the GE HealthCare PMC ADC driver entry

In reply to Herve Codina

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

---
 MAINTAINERS | 8 ++++++++
 1 file changed, 8 insertions(+)
MAINTAINERS +8 -0
index bd288a97c770..6cccbe4e3d72 100644
@@ -9459,6 +9459,14 @@ M:	Kieran Bingham <[email protected]>
 S:	Supported
 F:	scripts/gdb/
 
+GE HEALTHCARE PMC ADC DRIVER
+M:	Herve Codina <[email protected]>
+L:	[email protected]
+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 <[email protected]>
 L:	[email protected]
Signature · 1 line
2.46.1