Skip to contentSkip to conversation

iio: adc: Add support for QCOM SPMI PMIC7 ADC

PATCH Superseded Jishnu Prakash 7 participants 22 messages Mar 24, 2020 – Apr 14, 2020

Subsystems (3)

v1 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

cover iio: adc: Add support for QCOM SPMI PMIC7 ADC

The first patch converts the ADC DT bindings from .txt to .yaml format.

The second patch updates the documentation, for PMIC7 ADC. The main difference between PMIC5 and PMIC7 for ADC is that for PMIC7, SW requests to ADCs (on any PMIC) need to go through the ADC on PMK8350, which communicates with the ADCs on other PMICs through PBS. A SID register has been added for SW to specify the PMIC with which it needs to communicate.

The third patch adds driver support for PMIC7 ADC. It also adds definitions for PMIC7 ADC channels and virtual channel definitions per PMIC (made by combining ADC channel number and PMIC SID), to be used by ADC clients for PMIC7.

Jishnu Prakash (3):
iio: adc: Convert the QCOM SPMI ADC bindings to .yaml format
iio: adc: Add PMIC7 ADC bindings
iio: adc: Add support for PMIC7 ADC

 .../devicetree/bindings/iio/adc/qcom,spmi-vadc.txt | 173 --------------
 .../bindings/iio/adc/qcom,spmi-vadc.yaml           | 192 +++++++++++++++
 drivers/iio/adc/qcom-spmi-adc5.c                   | 239 ++++++++++++++++++-
 drivers/iio/adc/qcom-vadc-common.c                 | 260 +++++++++++++++++++++
 drivers/iio/adc/qcom-vadc-common.h                 |  14 ++
 include/dt-bindings/iio/qcom,spmi-adc7-pm8350.h    |  67 ++++++
 include/dt-bindings/iio/qcom,spmi-adc7-pm8350b.h   |  88 +++++++
 include/dt-bindings/iio/qcom,spmi-adc7-pmk8350.h   |  46 ++++
 include/dt-bindings/iio/qcom,spmi-adc7-pmr735a.h   |  28 +++
 include/dt-bindings/iio/qcom,spmi-adc7-pmr735b.h   |  28 +++
 include/dt-bindings/iio/qcom,spmi-vadc.h           |  78 ++++++-
 11 files changed, 1035 insertions(+), 178 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.txt
 create mode 100644 Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml
 create mode 100644 include/dt-bindings/iio/qcom,spmi-adc7-pm8350.h
 create mode 100644 include/dt-bindings/iio/qcom,spmi-adc7-pm8350b.h
 create mode 100644 include/dt-bindings/iio/qcom,spmi-adc7-pmk8350.h
 create mode 100644 include/dt-bindings/iio/qcom,spmi-adc7-pmr735a.h
 create mode 100644 include/dt-bindings/iio/qcom,spmi-adc7-pmr735b.h
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
#1 lore raw

PATCH 1/3 iio: adc: Convert the QCOM SPMI ADC bindings to .yaml format

Convert the adc bindings from .txt to .yaml format.

---
 .../devicetree/bindings/iio/adc/qcom,spmi-vadc.txt | 173 --------------------
 .../bindings/iio/adc/qcom,spmi-vadc.yaml           | 178 +++++++++++++++++++++
 2 files changed, 178 insertions(+), 173 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.txt
 create mode 100644 Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.txt deleted +0 -173
deleted file mode 100644
index c878768..0000000
@@ -1,173 +0,0 @@
-Qualcomm's SPMI PMIC ADC
-
-- SPMI PMIC voltage ADC (VADC) provides interface to clients to read
-  voltage. The VADC is a 15-bit sigma-delta ADC.
-- SPMI PMIC5 voltage ADC (ADC) provides interface to clients to read
-  voltage. The VADC is a 16-bit sigma-delta ADC.
-
-VADC node:
-
-- compatible:
-    Usage: required
-    Value type: <string>
-    Definition: Should contain "qcom,spmi-vadc".
-                Should contain "qcom,spmi-adc5" for PMIC5 ADC driver.
-                Should contain "qcom,spmi-adc-rev2" for PMIC rev2 ADC driver.
-                Should contain "qcom,pms405-adc" for PMS405 PMIC
-
-- reg:
-    Usage: required
-    Value type: <prop-encoded-array>
-    Definition: VADC base address in the SPMI PMIC register map.
-
-- #address-cells:
-    Usage: required
-    Value type: <u32>
-    Definition: Must be one. Child node 'reg' property should define ADC
-            channel number.
-
-- #size-cells:
-    Usage: required
-    Value type: <u32>
-    Definition: Must be zero.
-
-- #io-channel-cells:
-    Usage: required
-    Value type: <u32>
-    Definition: Must be one. For details about IIO bindings see:
-            Documentation/devicetree/bindings/iio/iio-bindings.txt
-
-- interrupts:
-    Usage: optional
-    Value type: <prop-encoded-array>
-    Definition: End of conversion interrupt.
-
-Channel node properties:
-
-- reg:
-    Usage: required
-    Value type: <u32>
-    Definition: ADC channel number.
-            See include/dt-bindings/iio/qcom,spmi-vadc.h
-
-- label:
-    Usage: required for "qcom,spmi-adc5" and "qcom,spmi-adc-rev2"
-    Value type: <empty>
-    Definition: ADC input of the platform as seen in the schematics.
-            For thermistor inputs connected to generic AMUX or GPIO inputs
-            these can vary across platform for the same pins. Hence select
-            the platform schematics name for this channel.
-
-- qcom,decimation:
-    Usage: optional
-    Value type: <u32>
-    Definition: This parameter is used to decrease ADC sampling rate.
-            Quicker measurements can be made by reducing decimation ratio.
-            - For compatible property "qcom,spmi-vadc", valid values are
-              512, 1024, 2048, 4096. If property is not found, default value
-              of 512 will be used.
-            - For compatible property "qcom,spmi-adc5", valid values are 250, 420
-              and 840. If property is not found, default value of 840 is used.
-            - For compatible property "qcom,spmi-adc-rev2", valid values are 256,
-              512 and 1024. If property is not present, default value is 1024.
-
-- qcom,pre-scaling:
-    Usage: optional
-    Value type: <u32 array>
-    Definition: Used for scaling the channel input signal before the signal is
-            fed to VADC. The configuration for this node is to know the
-            pre-determined ratio and use it for post scaling. Select one from
-            the following options.
-            <1 1>, <1 3>, <1 4>, <1 6>, <1 20>, <1 8>, <10 81>, <1 10>
-            If property is not found default value depending on chip will be used.
-
-- qcom,ratiometric:
-    Usage: optional
-    Value type: <empty>
-    Definition: Channel calibration type.
-            - For compatible property "qcom,spmi-vadc", if this property is
-              specified VADC will use the VDD reference (1.8V) and GND for
-              channel calibration. If property is not found, channel will be
-              calibrated with 0.625V and 1.25V reference channels, also
-              known as absolute calibration.
-            - For compatible property "qcom,spmi-adc5" and "qcom,spmi-adc-rev2",
-              if this property is specified VADC will use the VDD reference
-              (1.875V) and GND for channel calibration. If property is not found,
-              channel will be calibrated with 0V and 1.25V reference channels,
-              also known as absolute calibration.
-
-- qcom,hw-settle-time:
-    Usage: optional
-    Value type: <u32>
-    Definition: Time between AMUX getting configured and the ADC starting
-            conversion. The 'hw_settle_time' is an index used from valid values
-            and programmed in hardware to achieve the hardware settling delay.
-            - For compatible property "qcom,spmi-vadc" and "qcom,spmi-adc-rev2",
-              Delay = 100us * (hw_settle_time) for hw_settle_time < 11,
-              and 2ms * (hw_settle_time - 10) otherwise.
-              Valid values are: 0, 100, 200, 300, 400, 500, 600, 700, 800,
-              900 us and 1, 2, 4, 6, 8, 10 ms.
-              If property is not found, channel will use 0us.
-            - For compatible property "qcom,spmi-adc5", delay = 15us for
-              value 0, 100us * (value) for values < 11,
-              and 2ms * (value - 10) otherwise.
-              Valid values are: 15, 100, 200, 300, 400, 500, 600, 700, 800,
-              900 us and 1, 2, 4, 6, 8, 10 ms
-              Certain controller digital versions have valid values of
-              15, 100, 200, 300, 400, 500, 600, 700, 1, 2, 4, 8, 16, 32, 64, 128 ms
-              If property is not found, channel will use 15us.
-
-- qcom,avg-samples:
-    Usage: optional
-    Value type: <u32>
-    Definition: Number of samples to be used for measurement.
-            Averaging provides the option to obtain a single measurement
-            from the ADC that is an average of multiple samples. The value
-            selected is 2^(value).
-            - For compatible property "qcom,spmi-vadc", valid values
-              are: 1, 2, 4, 8, 16, 32, 64, 128, 256, 512
-              If property is not found, 1 sample will be used.
-            - For compatible property "qcom,spmi-adc5" and "qcom,spmi-adc-rev2",
-              valid values are: 1, 2, 4, 8, 16
-              If property is not found, 1 sample will be used.
-
-NOTE:
-
-For compatible property "qcom,spmi-vadc" following channels, also known as
-reference point channels, are used for result calibration and their channel
-configuration nodes should be defined:
-VADC_REF_625MV and/or VADC_SPARE1(based on PMIC version) VADC_REF_1250MV,
-VADC_GND_REF and VADC_VDD_VADC.
-
-Example:
-
-#include <dt-bindings/iio/qcom,spmi-vadc.h>
-#include <linux/irq.h>
-/* ... */
-
-	/* VADC node */
-	pmic_vadc: vadc@3100 {
-		compatible = "qcom,spmi-vadc";
-		reg = <0x3100>;
-		interrupts = <0x0 0x31 0x0 IRQ_TYPE_EDGE_RISING>;
-		#address-cells = <1>;
-		#size-cells = <0>;
-		#io-channel-cells = <1>;
-		io-channel-ranges;
-
-		/* Channel node */
-		adc-chan@VADC_LR_MUX10_USB_ID {
-			reg = <VADC_LR_MUX10_USB_ID>;
-			qcom,decimation = <512>;
-			qcom,ratiometric;
-			qcom,hw-settle-time = <200>;
-			qcom,avg-samples = <1>;
-			qcom,pre-scaling = <1 3>;
-		};
-	};
-
-	/* IIO client node */
-	usb {
-		io-channels = <&pmic_vadc VADC_LR_MUX10_USB_ID>;
-		io-channel-names = "vadc";
-	};
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml new file +178 -0

178 lines not on this page · raw message

Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
maintainer
#2 lore raw

Re: [PATCH 1/3] iio: adc: Convert the QCOM SPMI ADC bindings to .yaml format

Quoted 3 lines · On Tue, 24 Mar 2020 21:14:08 +0530 Jishnu Prakash <[email protected]>…

Convert the adc bindings from .txt to .yaml format.

Hi Jishnu,

Looks to me like we can tighten the checks a fair bit in here rather than just using uint32s

Now, my yaml isn't great so I won't try to say how, but there are plenty of examples in tree.

Thanks,

Jonathan

Quoted 273 lines
---
 .../devicetree/bindings/iio/adc/qcom,spmi-vadc.txt | 173 --------------------
 .../bindings/iio/adc/qcom,spmi-vadc.yaml           | 178 +++++++++++++++++++++
 2 files changed, 178 insertions(+), 173 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.txt
 create mode 100644 Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.txt deleted +0 -173
deleted file mode 100644
index c878768..0000000
@@ -1,173 +0,0 @@
-Qualcomm's SPMI PMIC ADC
-
-- SPMI PMIC voltage ADC (VADC) provides interface to clients to read
-  voltage. The VADC is a 15-bit sigma-delta ADC.
-- SPMI PMIC5 voltage ADC (ADC) provides interface to clients to read
-  voltage. The VADC is a 16-bit sigma-delta ADC.
-
-VADC node:
-
-- compatible:
-    Usage: required
-    Value type: <string>
-    Definition: Should contain "qcom,spmi-vadc".
-                Should contain "qcom,spmi-adc5" for PMIC5 ADC driver.
-                Should contain "qcom,spmi-adc-rev2" for PMIC rev2 ADC driver.
-                Should contain "qcom,pms405-adc" for PMS405 PMIC
-
-- reg:
-    Usage: required
-    Value type: <prop-encoded-array>
-    Definition: VADC base address in the SPMI PMIC register map.
-
-- #address-cells:
-    Usage: required
-    Value type: <u32>
-    Definition: Must be one. Child node 'reg' property should define ADC
-            channel number.
-
-- #size-cells:
-    Usage: required
-    Value type: <u32>
-    Definition: Must be zero.
-
-- #io-channel-cells:
-    Usage: required
-    Value type: <u32>
-    Definition: Must be one. For details about IIO bindings see:
-            Documentation/devicetree/bindings/iio/iio-bindings.txt
-
-- interrupts:
-    Usage: optional
-    Value type: <prop-encoded-array>
-    Definition: End of conversion interrupt.
-
-Channel node properties:
-
-- reg:
-    Usage: required
-    Value type: <u32>
-    Definition: ADC channel number.
-            See include/dt-bindings/iio/qcom,spmi-vadc.h
-
-- label:
-    Usage: required for "qcom,spmi-adc5" and "qcom,spmi-adc-rev2"
-    Value type: <empty>
-    Definition: ADC input of the platform as seen in the schematics.
-            For thermistor inputs connected to generic AMUX or GPIO inputs
-            these can vary across platform for the same pins. Hence select
-            the platform schematics name for this channel.
-
-- qcom,decimation:
-    Usage: optional
-    Value type: <u32>
-    Definition: This parameter is used to decrease ADC sampling rate.
-            Quicker measurements can be made by reducing decimation ratio.
-            - For compatible property "qcom,spmi-vadc", valid values are
-              512, 1024, 2048, 4096. If property is not found, default value
-              of 512 will be used.
-            - For compatible property "qcom,spmi-adc5", valid values are 250, 420
-              and 840. If property is not found, default value of 840 is used.
-            - For compatible property "qcom,spmi-adc-rev2", valid values are 256,
-              512 and 1024. If property is not present, default value is 1024.
-
-- qcom,pre-scaling:
-    Usage: optional
-    Value type: <u32 array>
-    Definition: Used for scaling the channel input signal before the signal is
-            fed to VADC. The configuration for this node is to know the
-            pre-determined ratio and use it for post scaling. Select one from
-            the following options.
-            <1 1>, <1 3>, <1 4>, <1 6>, <1 20>, <1 8>, <10 81>, <1 10>
-            If property is not found default value depending on chip will be used.
-
-- qcom,ratiometric:
-    Usage: optional
-    Value type: <empty>
-    Definition: Channel calibration type.
-            - For compatible property "qcom,spmi-vadc", if this property is
-              specified VADC will use the VDD reference (1.8V) and GND for
-              channel calibration. If property is not found, channel will be
-              calibrated with 0.625V and 1.25V reference channels, also
-              known as absolute calibration.
-            - For compatible property "qcom,spmi-adc5" and "qcom,spmi-adc-rev2",
-              if this property is specified VADC will use the VDD reference
-              (1.875V) and GND for channel calibration. If property is not found,
-              channel will be calibrated with 0V and 1.25V reference channels,
-              also known as absolute calibration.
-
-- qcom,hw-settle-time:
-    Usage: optional
-    Value type: <u32>
-    Definition: Time between AMUX getting configured and the ADC starting
-            conversion. The 'hw_settle_time' is an index used from valid values
-            and programmed in hardware to achieve the hardware settling delay.
-            - For compatible property "qcom,spmi-vadc" and "qcom,spmi-adc-rev2",
-              Delay = 100us * (hw_settle_time) for hw_settle_time < 11,
-              and 2ms * (hw_settle_time - 10) otherwise.
-              Valid values are: 0, 100, 200, 300, 400, 500, 600, 700, 800,
-              900 us and 1, 2, 4, 6, 8, 10 ms.
-              If property is not found, channel will use 0us.
-            - For compatible property "qcom,spmi-adc5", delay = 15us for
-              value 0, 100us * (value) for values < 11,
-              and 2ms * (value - 10) otherwise.
-              Valid values are: 15, 100, 200, 300, 400, 500, 600, 700, 800,
-              900 us and 1, 2, 4, 6, 8, 10 ms
-              Certain controller digital versions have valid values of
-              15, 100, 200, 300, 400, 500, 600, 700, 1, 2, 4, 8, 16, 32, 64, 128 ms
-              If property is not found, channel will use 15us.
-
-- qcom,avg-samples:
-    Usage: optional
-    Value type: <u32>
-    Definition: Number of samples to be used for measurement.
-            Averaging provides the option to obtain a single measurement
-            from the ADC that is an average of multiple samples. The value
-            selected is 2^(value).
-            - For compatible property "qcom,spmi-vadc", valid values
-              are: 1, 2, 4, 8, 16, 32, 64, 128, 256, 512
-              If property is not found, 1 sample will be used.
-            - For compatible property "qcom,spmi-adc5" and "qcom,spmi-adc-rev2",
-              valid values are: 1, 2, 4, 8, 16
-              If property is not found, 1 sample will be used.
-
-NOTE:
-
-For compatible property "qcom,spmi-vadc" following channels, also known as
-reference point channels, are used for result calibration and their channel
-configuration nodes should be defined:
-VADC_REF_625MV and/or VADC_SPARE1(based on PMIC version) VADC_REF_1250MV,
-VADC_GND_REF and VADC_VDD_VADC.
-
-Example:
-
-#include <dt-bindings/iio/qcom,spmi-vadc.h>
-#include <linux/irq.h>
-/* ... */
-
-	/* VADC node */
-	pmic_vadc: vadc@3100 {
-		compatible = "qcom,spmi-vadc";
-		reg = <0x3100>;
-		interrupts = <0x0 0x31 0x0 IRQ_TYPE_EDGE_RISING>;
-		#address-cells = <1>;
-		#size-cells = <0>;
-		#io-channel-cells = <1>;
-		io-channel-ranges;
-
-		/* Channel node */
-		adc-chan@VADC_LR_MUX10_USB_ID {
-			reg = <VADC_LR_MUX10_USB_ID>;
-			qcom,decimation = <512>;
-			qcom,ratiometric;
-			qcom,hw-settle-time = <200>;
-			qcom,avg-samples = <1>;
-			qcom,pre-scaling = <1 3>;
-		};
-	};
-
-	/* IIO client node */
-	usb {
-		io-channels = <&pmic_vadc VADC_LR_MUX10_USB_ID>;
-		io-channel-names = "vadc";
-	};
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml new file +81 -0
new file mode 100644
index 0000000..72db14c
@@ -0,0 +1,178 @@
+# SPDX-License-Identifier: GPL-2.0-only
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/adc/qcom,spmi-vadc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Qualcomm's SPMI PMIC ADC
+
+maintainers:
+  - Andy Gross <[email protected]>
+  - Bjorn Andersson <[email protected]>
+
+description: |
+  SPMI PMIC voltage ADC (VADC) provides interface to clients to read
+  voltage. The VADC is a 15-bit sigma-delta ADC.
+  SPMI PMIC5 voltage ADC (ADC) provides interface to clients to read
+  voltage. The VADC is a 16-bit sigma-delta ADC.
+
+properties:
+  compatible:
+    enum:
+      - qcom,spmi-vadc
+      - qcom,spmi-adc5
+      - qcom,spmi-adc-rev2
+      - qcom,pms405-adc
+
+  reg:
+    description: VADC base address in the SPMI PMIC register map
+    maxItems: 1
+
+  '#address-cells':
+    const: 1
+
+  '#size-cells':
+    const: 0
+
+  '#io-channel-cells':
+    const: 1
+
+  interrupts:
+    maxItems: 1
+    description:
+      End of conversion interrupt.
+
+required:
+  - compatible
+  - reg
+  - '#address-cells'
+  - '#size-cells'
+  - '#io-channel-cells'
+
+patternProperties:
+  "^[a-z0-9-_@]$":
+    type: object
+    description: |
+      Represents the external channels which are connected to the ADC.
+      For compatible property "qcom,spmi-vadc" following channels, also known as
+      reference point channels, are used for result calibration and their channel
+      configuration nodes should be defined:
+      VADC_REF_625MV and/or VADC_SPARE1(based on PMIC version) VADC_REF_1250MV,
+      VADC_GND_REF and VADC_VDD_VADC.
+
+    properties:
+      reg:
+        description: |
+          ADC channel number.
+          See include/dt-bindings/iio/qcom,spmi-vadc.h
+
+      label:
+        description: |
+            ADC input of the platform as seen in the schematics.
+            For thermistor inputs connected to generic AMUX or GPIO inputs
+            these can vary across platform for the same pins. Hence select
+            the platform schematics name for this channel. It is required
+            for "qcom,spmi-adc5" and "qcom,spmi-adc-rev2".
+        allOf:
+          - $ref: /schemas/types.yaml#/definitions/string
+
+      qcom,decimation:
+        description: |
+            This parameter is used to decrease ADC sampling rate.

Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml line 91

Quoted 10 lines
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml new file +10 -0
+            Quicker measurements can be made by reducing decimation ratio.
+            - For compatible property "qcom,spmi-vadc", valid values are
+              512, 1024, 2048, 4096. If property is not found, default value
+              of 512 will be used.
+            - For compatible property "qcom,spmi-adc5", valid values are 250, 420
+              and 840. If property is not found, default value of 840 is used.
+            - For compatible property "qcom,spmi-adc-rev2", valid values are 256,
+              512 and 1024. If property is not present, default value is 1024.
+        allOf:
+          - $ref: /schemas/types.yaml#/definitions/uint32

Should ideally verify all the values against models etc rather than a uint32 binding.

Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml line 99

Quoted 8 lines
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml new file +8 -0
+
+      qcom,pre-scaling:
+        description: |
+            Used for scaling the channel input signal before the signal is
+            fed to VADC. The configuration for this node is to know the
+            pre-determined ratio and use it for post scaling. Select one from
+            the following options.
+            <1 1>, <1 3>, <1 4>, <1 6>, <1 20>, <1 8>, <10 81>, <1 10>

Can we not provide this list as something that can be verified?

Quoted 30 lines
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml new file +30 -0
+            If property is not found default value depending on chip will be used.
+        allOf:
+          - $ref: /schemas/types.yaml#/definitions/uint32
+
+      qcom,ratiometric:
+        description: |
+            Channel calibration type.
+            - For compatible property "qcom,spmi-vadc", if this property is
+              specified VADC will use the VDD reference (1.8V) and GND for
+              channel calibration. If property is not found, channel will be
+              calibrated with 0.625V and 1.25V reference channels, also
+              known as absolute calibration.
+            - For compatible property "qcom,spmi-adc5" and "qcom,spmi-adc-rev2",
+              if this property is specified VADC will use the VDD reference (1.875V)
+              and GND for channel calibration. If property is not found, channel
+              will be calibrated with 0V and 1.25V reference channels, also known
+              as absolute calibration.
+        type: boolean
+
+      qcom,hw-settle-time:
+        description: |
+            Time between AMUX getting configured and the ADC starting
+            conversion. The 'hw_settle_time' is an index used from valid values
+            and programmed in hardware to achieve the hardware settling delay.
+            - For compatible property "qcom,spmi-vadc" and "qcom,spmi-adc-rev2",
+              Delay = 100us * (hw_settle_time) for hw_settle_time < 11,
+              and 2ms * (hw_settle_time - 10) otherwise.
+              Valid values are: 0, 100, 200, 300, 400, 500, 600, 700, 800,
+              900 us and 1, 2, 4, 6, 8, 10 ms.
+              If property is not found, channel will use 0us.

Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml line 139

Quoted 10 lines
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml new file +10 -0
+            - For compatible property "qcom,spmi-adc5", delay = 15us for
+              value 0, 100us * (value) for values < 11,
+              and 2ms * (value - 10) otherwise.
+              Valid values are: 15, 100, 200, 300, 400, 500, 600, 700, 800,
+              900 us and 1, 2, 4, 6, 8, 10 ms
+              Certain controller digital versions have valid values of
+              15, 100, 200, 300, 400, 500, 600, 700, 1, 2, 4, 8, 16, 32, 64, 128 ms
+              If property is not found, channel will use 15us.
+        allOf:
+          - $ref: /schemas/types.yaml#/definitions/uint32

Can we verify those values.

Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml line 151

Quoted 12 lines
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml new file +12 -0
+
+      qcom,avg-samples:
+        description: |
+            Number of samples to be used for measurement.
+            Averaging provides the option to obtain a single measurement
+            from the ADC that is an average of multiple samples. The value
+            selected is 2^(value).
+            - For compatible property "qcom,spmi-vadc", valid values
+              are: 1, 2, 4, 8, 16, 32, 64, 128, 256, 512
+              If property is not found, 1 sample will be used.
+        allOf:
+          - $ref: /schemas/types.yaml#/definitions/uint32

Verify the values if possible.

Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml line 160

Quoted 9 lines
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml new file +9 -0
+
+    required:
+      - reg
+      - diff-channels
+
+examples:
+  - |
+      /* VADC node */
+      pmic_vadc: vadc@3100 {

Should really be using generic names, so adc@3100 preferred.

Quoted 18 lines
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml new file +18 -0
+        compatible = "qcom,spmi-vadc";
+        reg = <0x3100>;
+        interrupts = <0x0 0x31 0x0 0x1>;
+        #address-cells = <1>;
+        #size-cells = <0>;
+        #io-channel-cells = <1>;
+        io-channel-ranges;
+
+        /* Channel node */
+        adc-chan@0x39 {
+          reg = <0x39>;
+          qcom,decimation = <512>;
+          qcom,ratiometric;
+          qcom,hw-settle-time = <200>;
+          qcom,avg-samples = <1>;
+          qcom,pre-scaling = <1 3>;
+        };
+      };
#3 lore raw

Re: [PATCH 1/3] iio: adc: Convert the QCOM SPMI ADC bindings to .yaml format

Hi Jonathan,

Quoted 32 lines · Jonathan Cameron
Quoted 3 lines · On Tue, 24 Mar 2020 21:14:08 +0530 Jishnu Prakash <[email protected]>…

Convert the adc bindings from .txt to .yaml format.

Hi Jishnu,

Looks to me like we can tighten the checks a fair bit in here rather than just using uint32s

Now, my yaml isn't great so I won't try to say how, but there are plenty of examples in tree.

Thanks,

Jonathan

Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml new file +14 -0
+
+      qcom,decimation:
+        description: |
+            This parameter is used to decrease ADC sampling rate.
+            Quicker measurements can be made by reducing decimation ratio.
+            - For compatible property "qcom,spmi-vadc", valid values are
+              512, 1024, 2048, 4096. If property is not found, default value
+              of 512 will be used.
+            - For compatible property "qcom,spmi-adc5", valid values are 250, 420
+              and 840. If property is not found, default value of 840 is used.
+            - For compatible property "qcom,spmi-adc-rev2", valid values are 256,
+              512 and 1024. If property is not present, default value is 1024.
+        allOf:
+          - $ref: /schemas/types.yaml#/definitions/uint32
Quoted 1 line

Should ideally verify all the values against models etc rather than a uint32 binding.

I'll add constraints for all properties for which it's applicable in the next post.

Quoted 11 lines
Quoted 9 lines
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml new file +8 -0
+
+      qcom,pre-scaling:
+        description: |
+            Used for scaling the channel input signal before the signal is
+            fed to VADC. The configuration for this node is to know the
+            pre-determined ratio and use it for post scaling. Select one from
+            the following options.
+            <1 1>, <1 3>, <1 4>, <1 6>, <1 20>, <1 8>, <10 81>, <1 10>
Quoted 6 lines

Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml line 160

Quoted 5 lines
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml new file +5 -0
+
+examples:
+  - |
+      /* VADC node */
+      pmic_vadc: vadc@3100 {

Should really be using generic names, so adc@3100 preferred.

I'll change it in the next post.

maintainer
#4 lore raw

Re: [PATCH 1/3] iio: adc: Convert the QCOM SPMI ADC bindings to .yaml format

In reply to Jishnu Prakash
Quoted 10 lines · Jishnu Prakash

Convert the adc bindings from .txt to .yaml format.

---
 .../devicetree/bindings/iio/adc/qcom,spmi-vadc.txt | 173 --------------------
 .../bindings/iio/adc/qcom,spmi-vadc.yaml           | 178 +++++++++++++++++++++
 2 files changed, 178 insertions(+), 173 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.txt
 create mode 100644 Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml

My bot found errors running 'make dt_binding_check' on your patch:

Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.example.dts:20.11-26: Warning (reg_format): /example-0/vadc@3100:reg: property has invalid length (4 bytes) (#address-cells == 1, #size-cells == 1)
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.example.dt.yaml: Warning (pci_device_bus_num): Failed prerequisite 'reg_format'
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.example.dt.yaml: Warning (i2c_bus_reg): Failed prerequisite 'reg_format'
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.example.dt.yaml: Warning (spi_bus_reg): Failed prerequisite 'reg_format'
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.example.dt.yaml: vadc@3100: 'adc-chan@0x39' does not match any of the regexes: '.*-names$', '.*-supply$', '^#.*-cells$', '^#[a-zA-Z0-9,+\\-._]{0,63}$', '^[a-zA-Z][a-zA-Z0-9,+\\-._]{0,63}$', '^[a-zA-Z][a-zA-Z0-9,+\\-._]{0,63}@[0-9a-fA-F]+(,[0-9a-fA-F]+)*$', '^__.*__$', 'pinctrl-[0-9]+'

See https://patchwork.ozlabs.org/patch/1260800

If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure dt-schema is up to date:

pip3 install git+https://github.com/devicetree-org/dt-schema.git@master --upgrade

Please check and re-submit.

#5 lore raw

Re: [PATCH 1/3] iio: adc: Convert the QCOM SPMI ADC bindings to .yaml format

Hi Rob,

Quoted 19 lines · Rob Herring
Quoted 10 lines · Jishnu Prakash

Convert the adc bindings from .txt to .yaml format.

---
  .../devicetree/bindings/iio/adc/qcom,spmi-vadc.txt | 173 --------------------
  .../bindings/iio/adc/qcom,spmi-vadc.yaml           | 178 +++++++++++++++++++++
  2 files changed, 178 insertions(+), 173 deletions(-)

delete mode 100644 Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.txt create mode 100644 Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml

My bot found errors running 'make dt_binding_check' on your patch:

Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.example.dts:20.11-26: Warning (reg_format): /example-0/vadc@3100:reg: property has invalid length (4 bytes) (#address-cells == 1, #size-cells == 1)
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.example.dt.yaml: Warning (pci_device_bus_num): Failed prerequisite 'reg_format'
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.example.dt.yaml: Warning (i2c_bus_reg): Failed prerequisite 'reg_format'
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.example.dt.yaml: Warning (spi_bus_reg): Failed prerequisite 'reg_format'
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.example.dt.yaml: vadc@3100: 'adc-chan@0x39' does not match any of the regexes: '.*-names$', '.*-supply$', '^#.*-cells$', '^#[a-zA-Z0-9,+\\-._]{0,63}$', '^[a-zA-Z][a-zA-Z0-9,+\\-._]{0,63}$', '^[a-zA-Z][a-zA-Z0-9,+\\-._]{0,63}@[0-9a-fA-F]+(,[0-9a-fA-F]+)*$', '^__.*__$', 'pinctrl-[0-9]+'

Quoted 8 lines

See https://patchwork.ozlabs.org/patch/1260800

If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure dt-schema is up to date:

pip3 install git+https://github.com/devicetree-org/dt-schema.git@master --upgrade

Please check and re-submit.

I have checked it, I'll be fixing this in the next post.

#6 lore raw

Re: [PATCH 1/3] iio: adc: Convert the QCOM SPMI ADC bindings to .yaml format

In reply to Jishnu Prakash
Quoted 247 lines · Jishnu Prakash

Convert the adc bindings from .txt to .yaml format.

---
 .../devicetree/bindings/iio/adc/qcom,spmi-vadc.txt | 173 --------------------
 .../bindings/iio/adc/qcom,spmi-vadc.yaml           | 178 +++++++++++++++++++++
 2 files changed, 178 insertions(+), 173 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.txt
 create mode 100644 Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.txt deleted +0 -173
deleted file mode 100644
index c878768..0000000
@@ -1,173 +0,0 @@
-Qualcomm's SPMI PMIC ADC
-
-- SPMI PMIC voltage ADC (VADC) provides interface to clients to read
-  voltage. The VADC is a 15-bit sigma-delta ADC.
-- SPMI PMIC5 voltage ADC (ADC) provides interface to clients to read
-  voltage. The VADC is a 16-bit sigma-delta ADC.
-
-VADC node:
-
-- compatible:
-    Usage: required
-    Value type: <string>
-    Definition: Should contain "qcom,spmi-vadc".
-                Should contain "qcom,spmi-adc5" for PMIC5 ADC driver.
-                Should contain "qcom,spmi-adc-rev2" for PMIC rev2 ADC driver.
-                Should contain "qcom,pms405-adc" for PMS405 PMIC
-
-- reg:
-    Usage: required
-    Value type: <prop-encoded-array>
-    Definition: VADC base address in the SPMI PMIC register map.
-
-- #address-cells:
-    Usage: required
-    Value type: <u32>
-    Definition: Must be one. Child node 'reg' property should define ADC
-            channel number.
-
-- #size-cells:
-    Usage: required
-    Value type: <u32>
-    Definition: Must be zero.
-
-- #io-channel-cells:
-    Usage: required
-    Value type: <u32>
-    Definition: Must be one. For details about IIO bindings see:
-            Documentation/devicetree/bindings/iio/iio-bindings.txt
-
-- interrupts:
-    Usage: optional
-    Value type: <prop-encoded-array>
-    Definition: End of conversion interrupt.
-
-Channel node properties:
-
-- reg:
-    Usage: required
-    Value type: <u32>
-    Definition: ADC channel number.
-            See include/dt-bindings/iio/qcom,spmi-vadc.h
-
-- label:
-    Usage: required for "qcom,spmi-adc5" and "qcom,spmi-adc-rev2"
-    Value type: <empty>
-    Definition: ADC input of the platform as seen in the schematics.
-            For thermistor inputs connected to generic AMUX or GPIO inputs
-            these can vary across platform for the same pins. Hence select
-            the platform schematics name for this channel.
-
-- qcom,decimation:
-    Usage: optional
-    Value type: <u32>
-    Definition: This parameter is used to decrease ADC sampling rate.
-            Quicker measurements can be made by reducing decimation ratio.
-            - For compatible property "qcom,spmi-vadc", valid values are
-              512, 1024, 2048, 4096. If property is not found, default value
-              of 512 will be used.
-            - For compatible property "qcom,spmi-adc5", valid values are 250, 420
-              and 840. If property is not found, default value of 840 is used.
-            - For compatible property "qcom,spmi-adc-rev2", valid values are 256,
-              512 and 1024. If property is not present, default value is 1024.
-
-- qcom,pre-scaling:
-    Usage: optional
-    Value type: <u32 array>
-    Definition: Used for scaling the channel input signal before the signal is
-            fed to VADC. The configuration for this node is to know the
-            pre-determined ratio and use it for post scaling. Select one from
-            the following options.
-            <1 1>, <1 3>, <1 4>, <1 6>, <1 20>, <1 8>, <10 81>, <1 10>
-            If property is not found default value depending on chip will be used.
-
-- qcom,ratiometric:
-    Usage: optional
-    Value type: <empty>
-    Definition: Channel calibration type.
-            - For compatible property "qcom,spmi-vadc", if this property is
-              specified VADC will use the VDD reference (1.8V) and GND for
-              channel calibration. If property is not found, channel will be
-              calibrated with 0.625V and 1.25V reference channels, also
-              known as absolute calibration.
-            - For compatible property "qcom,spmi-adc5" and "qcom,spmi-adc-rev2",
-              if this property is specified VADC will use the VDD reference
-              (1.875V) and GND for channel calibration. If property is not found,
-              channel will be calibrated with 0V and 1.25V reference channels,
-              also known as absolute calibration.
-
-- qcom,hw-settle-time:
-    Usage: optional
-    Value type: <u32>
-    Definition: Time between AMUX getting configured and the ADC starting
-            conversion. The 'hw_settle_time' is an index used from valid values
-            and programmed in hardware to achieve the hardware settling delay.
-            - For compatible property "qcom,spmi-vadc" and "qcom,spmi-adc-rev2",
-              Delay = 100us * (hw_settle_time) for hw_settle_time < 11,
-              and 2ms * (hw_settle_time - 10) otherwise.
-              Valid values are: 0, 100, 200, 300, 400, 500, 600, 700, 800,
-              900 us and 1, 2, 4, 6, 8, 10 ms.
-              If property is not found, channel will use 0us.
-            - For compatible property "qcom,spmi-adc5", delay = 15us for
-              value 0, 100us * (value) for values < 11,
-              and 2ms * (value - 10) otherwise.
-              Valid values are: 15, 100, 200, 300, 400, 500, 600, 700, 800,
-              900 us and 1, 2, 4, 6, 8, 10 ms
-              Certain controller digital versions have valid values of
-              15, 100, 200, 300, 400, 500, 600, 700, 1, 2, 4, 8, 16, 32, 64, 128 ms
-              If property is not found, channel will use 15us.
-
-- qcom,avg-samples:
-    Usage: optional
-    Value type: <u32>
-    Definition: Number of samples to be used for measurement.
-            Averaging provides the option to obtain a single measurement
-            from the ADC that is an average of multiple samples. The value
-            selected is 2^(value).
-            - For compatible property "qcom,spmi-vadc", valid values
-              are: 1, 2, 4, 8, 16, 32, 64, 128, 256, 512
-              If property is not found, 1 sample will be used.
-            - For compatible property "qcom,spmi-adc5" and "qcom,spmi-adc-rev2",
-              valid values are: 1, 2, 4, 8, 16
-              If property is not found, 1 sample will be used.
-
-NOTE:
-
-For compatible property "qcom,spmi-vadc" following channels, also known as
-reference point channels, are used for result calibration and their channel
-configuration nodes should be defined:
-VADC_REF_625MV and/or VADC_SPARE1(based on PMIC version) VADC_REF_1250MV,
-VADC_GND_REF and VADC_VDD_VADC.
-
-Example:
-
-#include <dt-bindings/iio/qcom,spmi-vadc.h>
-#include <linux/irq.h>
-/* ... */
-
-       /* VADC node */
-       pmic_vadc: vadc@3100 {
-               compatible = "qcom,spmi-vadc";
-               reg = <0x3100>;
-               interrupts = <0x0 0x31 0x0 IRQ_TYPE_EDGE_RISING>;
-               #address-cells = <1>;
-               #size-cells = <0>;
-               #io-channel-cells = <1>;
-               io-channel-ranges;
-
-               /* Channel node */
-               adc-chan@VADC_LR_MUX10_USB_ID {
-                       reg = <VADC_LR_MUX10_USB_ID>;
-                       qcom,decimation = <512>;
-                       qcom,ratiometric;
-                       qcom,hw-settle-time = <200>;
-                       qcom,avg-samples = <1>;
-                       qcom,pre-scaling = <1 3>;
-               };
-       };
-
-       /* IIO client node */
-       usb {
-               io-channels = <&pmic_vadc VADC_LR_MUX10_USB_ID>;
-               io-channel-names = "vadc";
-       };
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml new file +51 -0
new file mode 100644
index 0000000..72db14c
@@ -0,0 +1,178 @@
+# SPDX-License-Identifier: GPL-2.0-only
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/adc/qcom,spmi-vadc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Qualcomm's SPMI PMIC ADC
+
+maintainers:
+  - Andy Gross <[email protected]>
+  - Bjorn Andersson <[email protected]>
+
+description: |
+  SPMI PMIC voltage ADC (VADC) provides interface to clients to read
+  voltage. The VADC is a 15-bit sigma-delta ADC.
+  SPMI PMIC5 voltage ADC (ADC) provides interface to clients to read
+  voltage. The VADC is a 16-bit sigma-delta ADC.
+
+properties:
+  compatible:
+    enum:
+      - qcom,spmi-vadc
+      - qcom,spmi-adc5
+      - qcom,spmi-adc-rev2
+      - qcom,pms405-adc
+
+  reg:
+    description: VADC base address in the SPMI PMIC register map
+    maxItems: 1
+
+  '#address-cells':
+    const: 1
+
+  '#size-cells':
+    const: 0
+
+  '#io-channel-cells':
+    const: 1
+
+  interrupts:
+    maxItems: 1
+    description:
+      End of conversion interrupt.
+
+required:
+  - compatible
+  - reg
+  - '#address-cells'
+  - '#size-cells'
+  - '#io-channel-cells'
+

Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml line 61

Quoted 10 lines
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml new file +10 -0
+patternProperties:
+  "^[a-z0-9-_@]$":
+    type: object
+    description: |
+      Represents the external channels which are connected to the ADC.
+      For compatible property "qcom,spmi-vadc" following channels, also known as
+      reference point channels, are used for result calibration and their channel
+      configuration nodes should be defined:
+      VADC_REF_625MV and/or VADC_SPARE1(based on PMIC version) VADC_REF_1250MV,
+      VADC_GND_REF and VADC_VDD_VADC.

Instead of this note for "qcom,spmi-vadc", you can enforce this through checks in YAML grammar.

A simple example can be found in Documentation/devicetree/bindings/thermal/qcom-tsens.yaml. Look for the if, then, else clause which determines how many interrupts need to be defined.

Quoted 6 lines
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml new file +6 -0
+
+    properties:
+      reg:
+        description: |
+          ADC channel number.
+          See include/dt-bindings/iio/qcom,spmi-vadc.h

Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml line 77

Quoted 10 lines
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml new file +10 -0
+
+      label:
+        description: |
+            ADC input of the platform as seen in the schematics.
+            For thermistor inputs connected to generic AMUX or GPIO inputs
+            these can vary across platform for the same pins. Hence select
+            the platform schematics name for this channel. It is required
+            for "qcom,spmi-adc5" and "qcom,spmi-adc-rev2".
+        allOf:
+          - $ref: /schemas/types.yaml#/definitions/string

You shouldn't need allOf here.

Just a "$ref: /schemas/types.yaml#/definitions/string" should be fine. And move it above the description.

Same for all the uses of allOf below.

Quoted 4 lines
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml new file +4 -0
+      qcom,decimation:
+        description: |
+            This parameter is used to decrease ADC sampling rate.
+            Quicker measurements can be made by reducing decimation ratio.

Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml line 92

Quoted 10 lines
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml new file +10 -0
+            - For compatible property "qcom,spmi-vadc", valid values are
+              512, 1024, 2048, 4096. If property is not found, default value
+              of 512 will be used.
+            - For compatible property "qcom,spmi-adc5", valid values are 250, 420
+              and 840. If property is not found, default value of 840 is used.
+            - For compatible property "qcom,spmi-adc-rev2", valid values are 256,
+              512 and 1024. If property is not present, default value is 1024.
+        allOf:
+          - $ref: /schemas/types.yaml#/definitions/uint32
+

As pointed out by Jonathon, please enforce these by keying off the compatible property.

Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml line 98

Quoted 6 lines
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml new file +6 -0
+      qcom,pre-scaling:
+        description: |
+            Used for scaling the channel input signal before the signal is
+            fed to VADC. The configuration for this node is to know the
+            pre-determined ratio and use it for post scaling. Select one from
+            the following options.

Please improve this description from the old binding. Does <1 3> mean the signal is scaled 3x or 1/3x?

Quoted 10 lines
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml new file +10 -0
+            <1 1>, <1 3>, <1 4>, <1 6>, <1 20>, <1 8>, <10 81>, <1 10>
+            If property is not found default value depending on chip will be used.
+        allOf:
+          - $ref: /schemas/types.yaml#/definitions/uint32
+
+      qcom,ratiometric:
+        description: |
+            Channel calibration type.
+            - For compatible property "qcom,spmi-vadc", if this property is
+              specified VADC will use the VDD reference (1.8V) and GND for

Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml line 118

Quoted 10 lines
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml new file +10 -0
+              channel calibration. If property is not found, channel will be
+              calibrated with 0.625V and 1.25V reference channels, also
+              known as absolute calibration.
+            - For compatible property "qcom,spmi-adc5" and "qcom,spmi-adc-rev2",
+              if this property is specified VADC will use the VDD reference (1.875V)
+              and GND for channel calibration. If property is not found, channel
+              will be calibrated with 0V and 1.25V reference channels, also known
+              as absolute calibration.
+        type: boolean
+

please enforce these by keying off the compatible property.

Quoted 12 lines
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml new file +12 -0
+      qcom,hw-settle-time:
+        description: |
+            Time between AMUX getting configured and the ADC starting
+            conversion. The 'hw_settle_time' is an index used from valid values
+            and programmed in hardware to achieve the hardware settling delay.
+            - For compatible property "qcom,spmi-vadc" and "qcom,spmi-adc-rev2",
+              Delay = 100us * (hw_settle_time) for hw_settle_time < 11,
+              and 2ms * (hw_settle_time - 10) otherwise.
+              Valid values are: 0, 100, 200, 300, 400, 500, 600, 700, 800,
+              900 us and 1, 2, 4, 6, 8, 10 ms.
+              If property is not found, channel will use 0us.
+            - For compatible property "qcom,spmi-adc5", delay = 15us for

Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml line 140

Quoted 10 lines
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml new file +10 -0
+              value 0, 100us * (value) for values < 11,
+              and 2ms * (value - 10) otherwise.
+              Valid values are: 15, 100, 200, 300, 400, 500, 600, 700, 800,
+              900 us and 1, 2, 4, 6, 8, 10 ms
+              Certain controller digital versions have valid values of
+              15, 100, 200, 300, 400, 500, 600, 700, 1, 2, 4, 8, 16, 32, 64, 128 ms
+              If property is not found, channel will use 15us.
+        allOf:
+          - $ref: /schemas/types.yaml#/definitions/uint32
+

please enforce these by keying off the compatible property.

Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml line 152

Quoted 12 lines
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml new file +12 -0
+      qcom,avg-samples:
+        description: |
+            Number of samples to be used for measurement.
+            Averaging provides the option to obtain a single measurement
+            from the ADC that is an average of multiple samples. The value
+            selected is 2^(value).
+            - For compatible property "qcom,spmi-vadc", valid values
+              are: 1, 2, 4, 8, 16, 32, 64, 128, 256, 512
+              If property is not found, 1 sample will be used.
+        allOf:
+          - $ref: /schemas/types.yaml#/definitions/uint32
+

please enforce these by keying off the compatible property.

Quoted 29 lines
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml new file +26 -1
+    required:
+      - reg
+      - diff-channels
+
+examples:
+  - |
+      /* VADC node */
+      pmic_vadc: vadc@3100 {
+        compatible = "qcom,spmi-vadc";
+        reg = <0x3100>;
+        interrupts = <0x0 0x31 0x0 0x1>;
+        #address-cells = <1>;
+        #size-cells = <0>;
+        #io-channel-cells = <1>;
+        io-channel-ranges;
+
+        /* Channel node */
+        adc-chan@0x39 {
+          reg = <0x39>;
+          qcom,decimation = <512>;
+          qcom,ratiometric;
+          qcom,hw-settle-time = <200>;
+          qcom,avg-samples = <1>;
+          qcom,pre-scaling = <1 3>;
+        };
+      };
--

The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project

#7 lore raw

Re: [PATCH 1/3] iio: adc: Convert the QCOM SPMI ADC bindings to .yaml format

Hi Amit,

Quoted 21 lines · Amit Kucheria
Quoted 8 lines
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml new file +7 -0
+required:
+  - compatible
+  - reg
+  - '#address-cells'
+  - '#size-cells'
+  - '#io-channel-cells'
+

Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml line 61

Quoted 10 lines
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml new file +10 -0
+patternProperties:
+  "^[a-z0-9-_@]$":
+    type: object
+    description: |
+      Represents the external channels which are connected to the ADC.
+      For compatible property "qcom,spmi-vadc" following channels, also known as
+      reference point channels, are used for result calibration and their channel
+      configuration nodes should be defined:
+      VADC_REF_625MV and/or VADC_SPARE1(based on PMIC version) VADC_REF_1250MV,
+      VADC_GND_REF and VADC_VDD_VADC.

Instead of this note for "qcom,spmi-vadc", you can enforce this through checks in YAML grammar.

Quoted 4 lines

A simple example can be found in Documentation/devicetree/bindings/thermal/qcom-tsens.yaml. Look for the if, then, else clause which determines how many interrupts need to be defined.

I have gone through tsens and other examples, but I'm not able to get a way to apply this kind of constraint, on what child nodes should be present.

In this case, the constraint would have to be that for compatible property "qcom,spmi-vadc", there should be at least four child nodes and those four should have their "reg" property fixed to the channel values mentioned above. I can see how to apply constraints on a single property like interrupts in tsens, but I'm not sure if there is a way to specify a lower limit to the number of child nodes or something like "there should be at least one child node with value 0x9 for its "reg" property". I could not find any examples with constraints placed on  number of occurrences of a child node.

Can you please share an example of such a constraint if you are aware of any or suggest some way by which this kind of constraint can be specified?

Quoted 19 lines
Quoted 7 lines
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml new file +6 -0
+
+    properties:
+      reg:
+        description: |
+          ADC channel number.
+          See include/dt-bindings/iio/qcom,spmi-vadc.h

Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml line 77

Quoted 10 lines
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml new file +10 -0
+
+      label:
+        description: |
+            ADC input of the platform as seen in the schematics.
+            For thermistor inputs connected to generic AMUX or GPIO inputs
+            these can vary across platform for the same pins. Hence select
+            the platform schematics name for this channel. It is required
+            for "qcom,spmi-adc5" and "qcom,spmi-adc-rev2".
+        allOf:
+          - $ref: /schemas/types.yaml#/definitions/string

You shouldn't need allOf here.

Quoted 4 lines

Just a "$ref: /schemas/types.yaml#/definitions/string" should be fine. And move it above the description.

Same for all the uses of allOf below.

I'll make the change in the next post.

Quoted 16 lines
Quoted 6 lines
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml new file +4 -0
+      qcom,decimation:
+        description: |
+            This parameter is used to decrease ADC sampling rate.
+            Quicker measurements can be made by reducing decimation ratio.

Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml line 92

Quoted 10 lines
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml new file +10 -0
+            - For compatible property "qcom,spmi-vadc", valid values are
+              512, 1024, 2048, 4096. If property is not found, default value
+              of 512 will be used.
+            - For compatible property "qcom,spmi-adc5", valid values are 250, 420
+              and 840. If property is not found, default value of 840 is used.
+            - For compatible property "qcom,spmi-adc-rev2", valid values are 256,
+              512 and 1024. If property is not present, default value is 1024.
+        allOf:
+          - $ref: /schemas/types.yaml#/definitions/uint32
+
Quoted 2 lines

As pointed out by Jonathon, please enforce these by keying off the compatible property.

I'll do this for all properties for which it's applicable in the next post.

Quoted 9 lines

Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml line 98

Quoted 7 lines
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml new file +6 -0
+      qcom,pre-scaling:
+        description: |
+            Used for scaling the channel input signal before the signal is
+            fed to VADC. The configuration for this node is to know the
+            pre-determined ratio and use it for post scaling. Select one from
+            the following options.

Please improve this description from the old binding. Does <1 3> mean the signal is scaled 3x or 1/3x?

<1 3> means it is scaled down to 1/3rd of actual value. I'll add to the description in the next post.

Quoted 6 lines
Quoted 6 lines
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml new file +5 -0
+            <1 1>, <1 3>, <1 4>, <1 6>, <1 20>, <1 8>, <10 81>, <1 10>
+            If property is not found default value depending on chip will be used.
+        allOf:
+          - $ref: /schemas/types.yaml#/definitions/uint32
+
#8 lore raw

Re: [PATCH 1/3] iio: adc: Convert the QCOM SPMI ADC bindings to .yaml format

Quoted 43 lines · Jishnu Prakash

Hi Amit,

Quoted 21 lines · Amit Kucheria
Quoted 8 lines
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml new file +7 -0
+required:
+  - compatible
+  - reg
+  - '#address-cells'
+  - '#size-cells'
+  - '#io-channel-cells'
+

Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml line 61

Quoted 10 lines
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml new file +10 -0
+patternProperties:
+  "^[a-z0-9-_@]$":
+    type: object
+    description: |
+      Represents the external channels which are connected to the ADC.
+      For compatible property "qcom,spmi-vadc" following channels, also known as
+      reference point channels, are used for result calibration and their channel
+      configuration nodes should be defined:
+      VADC_REF_625MV and/or VADC_SPARE1(based on PMIC version) VADC_REF_1250MV,
+      VADC_GND_REF and VADC_VDD_VADC.

Instead of this note for "qcom,spmi-vadc", you can enforce this through checks in YAML grammar.

Quoted 4 lines

A simple example can be found in Documentation/devicetree/bindings/thermal/qcom-tsens.yaml. Look for the if, then, else clause which determines how many interrupts need to be defined.

I have gone through tsens and other examples, but I'm not able to get a way to apply this kind of constraint, on what child nodes should be present.

In this case, the constraint would have to be that for compatible property "qcom,spmi-vadc", there should be at least four child nodes and those four should have their "reg" property fixed to the channel values mentioned above. I can see how to apply constraints on a single property like interrupts in tsens, but I'm not sure if there is a way to specify a lower limit to the number of child nodes or something like "there should be at least one child node with value 0x9 for its "reg" property". I could not find any examples with constraints placed on number of occurrences of a child node.

Quoted 2 lines

Can you please share an example of such a constraint if you are aware of any or suggest some way by which this kind of constraint can be specified?

Hi Jishnu,

I misread that particular property. I don't think it is possible to specify child nodes w/o splitting this binding into two, I think. Please go ahead with the rest of changes. I'll keep digging to see if this is possible.

Regards,
Amit

#9 lore raw

PATCH 2/3 iio: adc: Add PMIC7 ADC bindings

In reply to Jishnu Prakash

Add documentation for PMIC7 ADC peripheral. For PMIC7 ADC, all SW communication to ADC goes through PMK8350, which communicates with other PMICs through PBS.

---
 .../bindings/iio/adc/qcom,spmi-vadc.yaml           | 28 ++++++++++++++++------
 1 file changed, 21 insertions(+), 7 deletions(-)
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml +21 -7
index 72db14c..20f010c 100644
@@ -13,7 +13,7 @@ maintainers:
 description: |
   SPMI PMIC voltage ADC (VADC) provides interface to clients to read
   voltage. The VADC is a 15-bit sigma-delta ADC.
-  SPMI PMIC5 voltage ADC (ADC) provides interface to clients to read
+  SPMI PMIC5/PMIC7 voltage ADC (ADC) provides interface to clients to read
   voltage. The VADC is a 16-bit sigma-delta ADC.
 
 properties:
@@ -23,6 +23,7 @@ properties:
       - qcom,spmi-adc5
       - qcom,spmi-adc-rev2
       - qcom,pms405-adc
+      - qcom,spmi-adc7
 
   reg:
     description: VADC base address in the SPMI PMIC register map
@@ -65,6 +66,8 @@ patternProperties:
         description: |
           ADC channel number.
           See include/dt-bindings/iio/qcom,spmi-vadc.h
+          For PMIC7 ADC, the channel numbers are specified separately per PMIC
+          in the PMIC-specific files in include/dt-bindings/iio/.
 
       label:
         description: |
@@ -72,7 +75,7 @@ patternProperties:
             For thermistor inputs connected to generic AMUX or GPIO inputs
             these can vary across platform for the same pins. Hence select
             the platform schematics name for this channel. It is required
-            for "qcom,spmi-adc5" and "qcom,spmi-adc-rev2".
+            for "qcom,spmi-adc5", "qcom,spmi-adc7" and "qcom,spmi-adc-rev2".
         allOf:
           - $ref: /schemas/types.yaml#/definitions/string
 
@@ -85,6 +88,8 @@ patternProperties:
               of 512 will be used.
             - For compatible property "qcom,spmi-adc5", valid values are 250, 420
               and 840. If property is not found, default value of 840 is used.
+            - For compatible property "qcom,spmi-adc7", valid values are 85, 340
+              and 1360. If property is not found, default value of 1360 is used.
             - For compatible property "qcom,spmi-adc-rev2", valid values are 256,
               512 and 1024. If property is not present, default value is 1024.
         allOf:
@@ -109,11 +114,11 @@ patternProperties:
               channel calibration. If property is not found, channel will be
               calibrated with 0.625V and 1.25V reference channels, also
               known as absolute calibration.
-            - For compatible property "qcom,spmi-adc5" and "qcom,spmi-adc-rev2",
-              if this property is specified VADC will use the VDD reference (1.875V)
-              and GND for channel calibration. If property is not found, channel
-              will be calibrated with 0V and 1.25V reference channels, also known
-              as absolute calibration.
+            - For compatible property "qcom,spmi-adc5", "qcom,spmi-adc7" and
+              "qcom,spmi-adc-rev2", if this property is specified VADC will use
+              the VDD reference (1.875V) and GND for channel calibration. If
+              property is not found, channel will be calibrated with 0V and 1.25V
+              reference channels, also known as absolute calibration.
         type: boolean
 
       qcom,hw-settle-time:
@@ -135,6 +140,12 @@ patternProperties:
               Certain controller digital versions have valid values of
               15, 100, 200, 300, 400, 500, 600, 700, 1, 2, 4, 8, 16, 32, 64, 128 ms
               If property is not found, channel will use 15us.
+            - For compatible property "qcom,spmi-adc7", delay = 15us for
+              value 0, 100us * (value) for values < 8, 1ms for value 8
+              and 2ms * (value - 8) otherwise.
+              Valid values are: 15, 100, 200, 300, 400, 500, 600, 700, 1000, 2000,
+              4000, 8000, 16000, 32000, 64000, 128000 us.
+              If property is not found, channel will use 15us.
         allOf:
           - $ref: /schemas/types.yaml#/definitions/uint32
 
@@ -147,6 +158,9 @@ patternProperties:
             - For compatible property "qcom,spmi-vadc", valid values
               are: 1, 2, 4, 8, 16, 32, 64, 128, 256, 512
               If property is not found, 1 sample will be used.
+            - For compatible property "qcom,spmi-adc5", "qcom,spmi-adc7"
+              and "qcom,spmi-adc-rev2", valid values are: 1, 2, 4, 8, 16.
+              If property is not found, 1 sample will be used.
         allOf:
           - $ref: /schemas/types.yaml#/definitions/uint32
 
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
maintainer
#10 lore raw

Re: [PATCH 2/3] iio: adc: Add PMIC7 ADC bindings

Quoted 31 lines · On Tue, 24 Mar 2020 21:14:09 +0530 Jishnu Prakash <[email protected]>…

Add documentation for PMIC7 ADC peripheral. For PMIC7 ADC, all SW communication to ADC goes through PMK8350, which communicates with other PMICs through PBS.

---
 .../bindings/iio/adc/qcom,spmi-vadc.yaml           | 28 ++++++++++++++++------
 1 file changed, 21 insertions(+), 7 deletions(-)
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml +2 -1
index 72db14c..20f010c 100644
@@ -13,7 +13,7 @@ maintainers:
 description: |
   SPMI PMIC voltage ADC (VADC) provides interface to clients to read
   voltage. The VADC is a 15-bit sigma-delta ADC.
-  SPMI PMIC5 voltage ADC (ADC) provides interface to clients to read
+  SPMI PMIC5/PMIC7 voltage ADC (ADC) provides interface to clients to read
   voltage. The VADC is a 16-bit sigma-delta ADC.
 
 properties:
@@ -23,6 +23,7 @@ properties:
       - qcom,spmi-adc5
       - qcom,spmi-adc-rev2
       - qcom,pms405-adc
+      - qcom,spmi-adc7
 
   reg:
     description: VADC base address in the SPMI PMIC register map

Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml patternProperties: · line 70

Quoted 5 lines
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml +2 -0
@@ -65,6 +66,8 @@ patternProperties:
         description: |
           ADC channel number.
           See include/dt-bindings/iio/qcom,spmi-vadc.h
+          For PMIC7 ADC, the channel numbers are specified separately per PMIC
+          in the PMIC-specific files in include/dt-bindings/iio/.

That makes me thing we really should have separate compatibles. The parts clearly have differences, even if we haven't needed to use them explicitly as yet.

Quoted 61 lines
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml +17 -6
       label:
         description: |
@@ -72,7 +75,7 @@ patternProperties:
             For thermistor inputs connected to generic AMUX or GPIO inputs
             these can vary across platform for the same pins. Hence select
             the platform schematics name for this channel. It is required
-            for "qcom,spmi-adc5" and "qcom,spmi-adc-rev2".
+            for "qcom,spmi-adc5", "qcom,spmi-adc7" and "qcom,spmi-adc-rev2".
         allOf:
           - $ref: /schemas/types.yaml#/definitions/string
 
@@ -85,6 +88,8 @@ patternProperties:
               of 512 will be used.
             - For compatible property "qcom,spmi-adc5", valid values are 250, 420
               and 840. If property is not found, default value of 840 is used.
+            - For compatible property "qcom,spmi-adc7", valid values are 85, 340
+              and 1360. If property is not found, default value of 1360 is used.
             - For compatible property "qcom,spmi-adc-rev2", valid values are 256,
               512 and 1024. If property is not present, default value is 1024.
         allOf:
@@ -109,11 +114,11 @@ patternProperties:
               channel calibration. If property is not found, channel will be
               calibrated with 0.625V and 1.25V reference channels, also
               known as absolute calibration.
-            - For compatible property "qcom,spmi-adc5" and "qcom,spmi-adc-rev2",
-              if this property is specified VADC will use the VDD reference (1.875V)
-              and GND for channel calibration. If property is not found, channel
-              will be calibrated with 0V and 1.25V reference channels, also known
-              as absolute calibration.
+            - For compatible property "qcom,spmi-adc5", "qcom,spmi-adc7" and
+              "qcom,spmi-adc-rev2", if this property is specified VADC will use
+              the VDD reference (1.875V) and GND for channel calibration. If
+              property is not found, channel will be calibrated with 0V and 1.25V
+              reference channels, also known as absolute calibration.
         type: boolean
 
       qcom,hw-settle-time:
@@ -135,6 +140,12 @@ patternProperties:
               Certain controller digital versions have valid values of
               15, 100, 200, 300, 400, 500, 600, 700, 1, 2, 4, 8, 16, 32, 64, 128 ms
               If property is not found, channel will use 15us.
+            - For compatible property "qcom,spmi-adc7", delay = 15us for
+              value 0, 100us * (value) for values < 8, 1ms for value 8
+              and 2ms * (value - 8) otherwise.
+              Valid values are: 15, 100, 200, 300, 400, 500, 600, 700, 1000, 2000,
+              4000, 8000, 16000, 32000, 64000, 128000 us.
+              If property is not found, channel will use 15us.
         allOf:
           - $ref: /schemas/types.yaml#/definitions/uint32
 
@@ -147,6 +158,9 @@ patternProperties:
             - For compatible property "qcom,spmi-vadc", valid values
               are: 1, 2, 4, 8, 16, 32, 64, 128, 256, 512
               If property is not found, 1 sample will be used.
+            - For compatible property "qcom,spmi-adc5", "qcom,spmi-adc7"
+              and "qcom,spmi-adc-rev2", valid values are: 1, 2, 4, 8, 16.
+              If property is not found, 1 sample will be used.
         allOf:
           - $ref: /schemas/types.yaml#/definitions/uint32
 
#11 lore raw

Re: [PATCH 2/3] iio: adc: Add PMIC7 ADC bindings

Hi Jonathan,

Quoted 31 lines · Jonathan Cameron
Quoted 28 lines · On Tue, 24 Mar 2020 21:14:09 +0530 Jishnu Prakash <[email protected]>…

Add documentation for PMIC7 ADC peripheral. For PMIC7 ADC, all SW communication to ADC goes through PMK8350, which communicates with other PMICs through PBS.

---
  .../bindings/iio/adc/qcom,spmi-vadc.yaml           | 28 ++++++++++++++++------
  1 file changed, 21 insertions(+), 7 deletions(-)
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml +2 -1
index 72db14c..20f010c 100644
@@ -13,7 +13,7 @@ maintainers:
  description: |
    SPMI PMIC voltage ADC (VADC) provides interface to clients to read
    voltage. The VADC is a 15-bit sigma-delta ADC.
-  SPMI PMIC5 voltage ADC (ADC) provides interface to clients to read
+  SPMI PMIC5/PMIC7 voltage ADC (ADC) provides interface to clients to read
    voltage. The VADC is a 16-bit sigma-delta ADC.
 
  properties:
@@ -23,6 +23,7 @@ properties:
        - qcom,spmi-adc5
        - qcom,spmi-adc-rev2
        - qcom,pms405-adc
+      - qcom,spmi-adc7
 
Quoted 11 lines

Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml patternProperties: · line 70

Quoted 8 lines
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml +2 -0
    reg:
      description: VADC base address in the SPMI PMIC register map
@@ -65,6 +66,8 @@ patternProperties:
          description: |
            ADC channel number.
            See include/dt-bindings/iio/qcom,spmi-vadc.h
+          For PMIC7 ADC, the channel numbers are specified separately per PMIC
+          in the PMIC-specific files in include/dt-bindings/iio/.

That makes me thing we really should have separate compatibles. The parts clearly have differences, even if we haven't needed to use them explicitly as yet.

I'm not sure what you mean by this. We have added a new compatible property "qcom,spmi-adc7" for PMIC7 ADC.

Quoted 14 lines
Quoted 14 lines
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml +1 -1
        label:
          description: |
@@ -72,7 +75,7 @@ patternProperties:
              For thermistor inputs connected to generic AMUX or GPIO inputs
              these can vary across platform for the same pins. Hence select
              the platform schematics name for this channel. It is required
-            for "qcom,spmi-adc5" and "qcom,spmi-adc-rev2".
+            for "qcom,spmi-adc5", "qcom,spmi-adc7" and "qcom,spmi-adc-rev2".
          allOf:
            - $ref: /schemas/types.yaml#/definitions/string
 
#12 lore raw

Re: [PATCH 2/3] iio: adc: Add PMIC7 ADC bindings

Quoted 45 lines · On Mon, 6 Apr 2020 17:15:21 +0530 Jishnu Prakash <[email protected]>…

Hi Jonathan,

Quoted 31 lines · Jonathan Cameron
Quoted 28 lines · On Tue, 24 Mar 2020 21:14:09 +0530 Jishnu Prakash <[email protected]>…

Add documentation for PMIC7 ADC peripheral. For PMIC7 ADC, all SW communication to ADC goes through PMK8350, which communicates with other PMICs through PBS.

---
  .../bindings/iio/adc/qcom,spmi-vadc.yaml           | 28 ++++++++++++++++------
  1 file changed, 21 insertions(+), 7 deletions(-)
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml +2 -1
index 72db14c..20f010c 100644
@@ -13,7 +13,7 @@ maintainers:
  description: |
    SPMI PMIC voltage ADC (VADC) provides interface to clients to read
    voltage. The VADC is a 15-bit sigma-delta ADC.
-  SPMI PMIC5 voltage ADC (ADC) provides interface to clients to read
+  SPMI PMIC5/PMIC7 voltage ADC (ADC) provides interface to clients to read
    voltage. The VADC is a 16-bit sigma-delta ADC.
 
  properties:
@@ -23,6 +23,7 @@ properties:
        - qcom,spmi-adc5
        - qcom,spmi-adc-rev2
        - qcom,pms405-adc
+      - qcom,spmi-adc7
 
Quoted 11 lines

Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml patternProperties: · line 70

Quoted 8 lines
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml +2 -0
    reg:
      description: VADC base address in the SPMI PMIC register map
@@ -65,6 +66,8 @@ patternProperties:
          description: |
            ADC channel number.
            See include/dt-bindings/iio/qcom,spmi-vadc.h
+          For PMIC7 ADC, the channel numbers are specified separately per PMIC
+          in the PMIC-specific files in include/dt-bindings/iio/.  

That makes me thing we really should have separate compatibles. The parts clearly have differences, even if we haven't needed to use them explicitly as yet.

Quoted 2 lines

I'm not sure what you mean by this. We have added a new compatible property "qcom,spmi-adc7" for PMIC7 ADC.

I've no idea what I meant either :)

Jonathan

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml +1 -1
        label:
          description: |
@@ -72,7 +75,7 @@ patternProperties:
              For thermistor inputs connected to generic AMUX or GPIO inputs
              these can vary across platform for the same pins. Hence select
              the platform schematics name for this channel. It is required
-            for "qcom,spmi-adc5" and "qcom,spmi-adc-rev2".
+            for "qcom,spmi-adc5", "qcom,spmi-adc7" and "qcom,spmi-adc-rev2".
          allOf:
            - $ref: /schemas/types.yaml#/definitions/string
 
#13 lore raw

Re: [PATCH 2/3] iio: adc: Add PMIC7 ADC bindings

In reply to Jishnu Prakash

Hi Jishnu,

Quoted 4 lines · Jishnu Prakash

Add documentation for PMIC7 ADC peripheral. For PMIC7 ADC, all SW communication to ADC goes through PMK8350, which communicates with other PMICs through PBS.

What is PMK8350? What is PBS? Please expand the acronyms and describe more verbosely.

Quoted 97 lines
---
 .../bindings/iio/adc/qcom,spmi-vadc.yaml           | 28 ++++++++++++++++------
 1 file changed, 21 insertions(+), 7 deletions(-)
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml +21 -8
index 72db14c..20f010c 100644
@@ -13,7 +13,7 @@ maintainers:
 description: |
   SPMI PMIC voltage ADC (VADC) provides interface to clients to read
   voltage. The VADC is a 15-bit sigma-delta ADC.
-  SPMI PMIC5 voltage ADC (ADC) provides interface to clients to read
+  SPMI PMIC5/PMIC7 voltage ADC (ADC) provides interface to clients to read
   voltage. The VADC is a 16-bit sigma-delta ADC.
 
 properties:
@@ -23,6 +23,7 @@ properties:
       - qcom,spmi-adc5
       - qcom,spmi-adc-rev2
       - qcom,pms405-adc
+      - qcom,spmi-adc7
 
   reg:
     description: VADC base address in the SPMI PMIC register map
@@ -65,6 +66,8 @@ patternProperties:
         description: |
           ADC channel number.
           See include/dt-bindings/iio/qcom,spmi-vadc.h
+          For PMIC7 ADC, the channel numbers are specified separately per PMIC
+          in the PMIC-specific files in include/dt-bindings/iio/.
 
       label:
         description: |
@@ -72,7 +75,7 @@ patternProperties:
             For thermistor inputs connected to generic AMUX or GPIO inputs
             these can vary across platform for the same pins. Hence select
             the platform schematics name for this channel. It is required
-            for "qcom,spmi-adc5" and "qcom,spmi-adc-rev2".
+            for "qcom,spmi-adc5", "qcom,spmi-adc7" and "qcom,spmi-adc-rev2".
         allOf:
           - $ref: /schemas/types.yaml#/definitions/string
 
@@ -85,6 +88,8 @@ patternProperties:
               of 512 will be used.
             - For compatible property "qcom,spmi-adc5", valid values are 250, 420
               and 840. If property is not found, default value of 840 is used.
+            - For compatible property "qcom,spmi-adc7", valid values are 85, 340
+              and 1360. If property is not found, default value of 1360 is used.
             - For compatible property "qcom,spmi-adc-rev2", valid values are 256,
               512 and 1024. If property is not present, default value is 1024.
         allOf:
@@ -109,11 +114,11 @@ patternProperties:
               channel calibration. If property is not found, channel will be
               calibrated with 0.625V and 1.25V reference channels, also
               known as absolute calibration.
-            - For compatible property "qcom,spmi-adc5" and "qcom,spmi-adc-rev2",
-              if this property is specified VADC will use the VDD reference (1.875V)
-              and GND for channel calibration. If property is not found, channel
-              will be calibrated with 0V and 1.25V reference channels, also known
-              as absolute calibration.
+            - For compatible property "qcom,spmi-adc5", "qcom,spmi-adc7" and
+              "qcom,spmi-adc-rev2", if this property is specified VADC will use
+              the VDD reference (1.875V) and GND for channel calibration. If
+              property is not found, channel will be calibrated with 0V and 1.25V
+              reference channels, also known as absolute calibration.
         type: boolean
 
       qcom,hw-settle-time:
@@ -135,6 +140,12 @@ patternProperties:
               Certain controller digital versions have valid values of
               15, 100, 200, 300, 400, 500, 600, 700, 1, 2, 4, 8, 16, 32, 64, 128 ms
               If property is not found, channel will use 15us.
+            - For compatible property "qcom,spmi-adc7", delay = 15us for
+              value 0, 100us * (value) for values < 8, 1ms for value 8
+              and 2ms * (value - 8) otherwise.
+              Valid values are: 15, 100, 200, 300, 400, 500, 600, 700, 1000, 2000,
+              4000, 8000, 16000, 32000, 64000, 128000 us.
+              If property is not found, channel will use 15us.
         allOf:
           - $ref: /schemas/types.yaml#/definitions/uint32
 
@@ -147,6 +158,9 @@ patternProperties:
             - For compatible property "qcom,spmi-vadc", valid values
               are: 1, 2, 4, 8, 16, 32, 64, 128, 256, 512
               If property is not found, 1 sample will be used.
+            - For compatible property "qcom,spmi-adc5", "qcom,spmi-adc7"
+              and "qcom,spmi-adc-rev2", valid values are: 1, 2, 4, 8, 16.
+              If property is not found, 1 sample will be used.
         allOf:
           - $ref: /schemas/types.yaml#/definitions/uint32
 
--

The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project

#14 lore raw

Re: [PATCH 2/3] iio: adc: Add PMIC7 ADC bindings

Hi Amit,

Quoted 8 lines · Amit Kucheria

Hi Jishnu,

Quoted 3 lines · Jishnu Prakash

Add documentation for PMIC7 ADC peripheral. For PMIC7 ADC, all SW communication to ADC goes through PMK8350, which communicates with other PMICs through PBS.

What is PMK8350? What is PBS? Please expand the acronyms and describe more verbosely.

PMK8350 is just the name of one of the PMIC7 family of PMICs. I'll expand the description in the next post.

Quoted 19 lines
Quoted 19 lines
---
  .../bindings/iio/adc/qcom,spmi-vadc.yaml           | 28 ++++++++++++++++------
  1 file changed, 21 insertions(+), 7 deletions(-)
Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml +1 -1
index 72db14c..20f010c 100644
@@ -13,7 +13,7 @@ maintainers:
  description: |
    SPMI PMIC voltage ADC (VADC) provides interface to clients to read
    voltage. The VADC is a 15-bit sigma-delta ADC.
-  SPMI PMIC5 voltage ADC (ADC) provides interface to clients to read
+  SPMI PMIC5/PMIC7 voltage ADC (ADC) provides interface to clients to read
    voltage. The VADC is a 16-bit sigma-delta ADC.
 
 
#15 lore raw

PATCH 3/3 iio: adc: Add support for PMIC7 ADC

In reply to Jishnu Prakash

The ADC architecture on PMIC7 is changed as compared to PMIC5. The major change from PMIC5 is that all SW communication to ADC goes through PMK8350, which communicates with other PMICs through PBS when the ADC on PMK8350 works in master mode. The SID register is used to identify the PMICs with which the PBS needs to communicate. Add support for the same.

In addition, add definitions for ADC channels and virtual channel definitions per PMIC, to be used by ADC clients for PMIC7.

---
 drivers/iio/adc/qcom-spmi-adc5.c                 | 239 ++++++++++++++++++++-
 drivers/iio/adc/qcom-vadc-common.c               | 260 +++++++++++++++++++++++
 drivers/iio/adc/qcom-vadc-common.h               |  14 ++
 include/dt-bindings/iio/qcom,spmi-adc7-pm8350.h  |  67 ++++++
 include/dt-bindings/iio/qcom,spmi-adc7-pm8350b.h |  88 ++++++++
 include/dt-bindings/iio/qcom,spmi-adc7-pmk8350.h |  46 ++++
 include/dt-bindings/iio/qcom,spmi-adc7-pmr735a.h |  28 +++
 include/dt-bindings/iio/qcom,spmi-adc7-pmr735b.h |  28 +++
 include/dt-bindings/iio/qcom,spmi-vadc.h         |  78 ++++++-
 9 files changed, 843 insertions(+), 5 deletions(-)
 create mode 100644 include/dt-bindings/iio/qcom,spmi-adc7-pm8350.h
 create mode 100644 include/dt-bindings/iio/qcom,spmi-adc7-pm8350b.h
 create mode 100644 include/dt-bindings/iio/qcom,spmi-adc7-pmk8350.h
 create mode 100644 include/dt-bindings/iio/qcom,spmi-adc7-pmr735a.h
 create mode 100644 include/dt-bindings/iio/qcom,spmi-adc7-pmr735b.h
drivers/iio/adc/qcom-spmi-adc5.c +235 -4
index 21fdcde..bcfb749 100644
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 /*
- * Copyright (c) 2018, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2018, 2020, The Linux Foundation. All rights reserved.
  */
 
 #include <linux/bitops.h>
@@ -23,6 +23,7 @@
 
 #define ADC5_USR_REVISION1			0x0
 #define ADC5_USR_STATUS1			0x8
+#define ADC5_USR_STATUS1_CONV_FAULT		BIT(7)
 #define ADC5_USR_STATUS1_REQ_STS		BIT(1)
 #define ADC5_USR_STATUS1_EOC			BIT(0)
 #define ADC5_USR_STATUS1_REQ_STS_EOC_MASK	0x3
@@ -65,6 +66,9 @@
 
 #define ADC5_USR_IBAT_DATA1			0x53
 
+#define ADC_CHANNEL_OFFSET			0x8
+#define ADC_CHANNEL_MASK			0xff
+
 /*
  * Conversion time varies based on the decimation, clock rate, fast average
  * samples and measurements queued across different VADC peripherals.
@@ -79,6 +83,11 @@
 #define ADC5_HW_SETTLE_DIFF_MINOR		3
 #define ADC5_HW_SETTLE_DIFF_MAJOR		5
 
+/* For PMIC7 */
+#define ADC_APP_SID				0x40
+#define ADC_APP_SID_MASK			0xf
+#define ADC7_CONV_TIMEOUT			msecs_to_jiffies(10)
+
 enum adc5_cal_method {
 	ADC5_NO_CAL = 0,
 	ADC5_RATIOMETRIC_CAL,
@@ -96,6 +105,7 @@ enum adc5_cal_val {
  * @cal_method: calibration method.
  * @cal_val: calibration value
  * @decimation: sampling rate supported for the channel.
+ * @sid: slave id of PMIC owning the channel, for PMIC7.
  * @prescale: channel scaling performed on the input signal.
  * @hw_settle_time: the time between AMUX being configured and the
  *	start of conversion.
@@ -110,6 +120,7 @@ struct adc5_channel_prop {
 	enum adc5_cal_method	cal_method;
 	enum adc5_cal_val	cal_val;
 	unsigned int		decimation;
+	unsigned int		sid;
 	unsigned int		prescale;
 	unsigned int		hw_settle_time;
 	unsigned int		avg_samples;
@@ -140,6 +151,7 @@ struct adc5_chip {
 	bool			poll_eoc;
 	struct completion	complete;
 	struct mutex		lock;
+	bool			is_pmic7;
 	const struct adc5_data	*data;
 };
 
@@ -165,6 +177,11 @@ static int adc5_write(struct adc5_chip *adc, u16 offset, u8 *data, int len)
 	return regmap_bulk_write(adc->regmap, adc->base + offset, data, len);
 }
 
+static int adc5_masked_write(struct adc5_chip *adc, u16 offset, u8 mask, u8 val)
+{
+	return regmap_update_bits(adc->regmap, adc->base + offset, mask, val);
+}
+
 static int adc5_prescaling_from_dt(u32 num, u32 den)
 {
 	unsigned int pre;
@@ -314,6 +331,49 @@ static int adc5_configure(struct adc5_chip *adc,
 	return adc5_write(adc, ADC5_USR_DIG_PARAM, buf, sizeof(buf));
 }
 
+static int adc7_configure(struct adc5_chip *adc,
+			struct adc5_channel_prop *prop)
+{
+	int ret;
+	u8 conv_req = 0, buf[4];
+
+	ret = adc5_masked_write(adc, ADC_APP_SID, ADC_APP_SID_MASK, prop->sid);
+	if (ret)
+		return ret;
+
+	ret = adc5_read(adc, ADC5_USR_DIG_PARAM, buf, sizeof(buf));
+	if (ret < 0)
+		return ret;
+
+	/* Digital param selection */
+	adc5_update_dig_param(adc, prop, &buf[0]);
+
+	/* Update fast average sample value */
+	buf[1] &= (u8) ~ADC5_USR_FAST_AVG_CTL_SAMPLES_MASK;
+	buf[1] |= prop->avg_samples;
+
+	/* Select ADC channel */
+	buf[2] = prop->channel;
+
+	/* Select HW settle delay for channel */
+	buf[3] &= (u8) ~ADC5_USR_HW_SETTLE_DELAY_MASK;
+	buf[3] |= prop->hw_settle_time;
+
+	/* Select CONV request */
+	conv_req = ADC5_USR_CONV_REQ_REQ;
+
+	if (!adc->poll_eoc)
+		reinit_completion(&adc->complete);
+
+	ret = adc5_write(adc, ADC5_USR_DIG_PARAM, buf, sizeof(buf));
+	if (ret)
+		return ret;
+
+	ret = adc5_write(adc, ADC5_USR_CONV_REQ, &conv_req, 1);
+
+	return ret;
+}
+
 static int adc5_do_conversion(struct adc5_chip *adc,
 			struct adc5_channel_prop *prop,
 			struct iio_chan_spec const *chan,
@@ -355,6 +415,44 @@ static int adc5_do_conversion(struct adc5_chip *adc,
 	return ret;
 }
 
+static int adc7_do_conversion(struct adc5_chip *adc,
+			struct adc5_channel_prop *prop,
+			struct iio_chan_spec const *chan,
+			u16 *data_volt, u16 *data_cur)
+{
+	int ret;
+	u8 status = 0;
+
+	mutex_lock(&adc->lock);
+
+	ret = adc7_configure(adc, prop);
+	if (ret) {
+		pr_err("ADC configure failed with %d\n", ret);
+		goto unlock;
+	}
+
+	/* No support for polling mode at present*/
+	wait_for_completion_timeout(&adc->complete,
+					ADC7_CONV_TIMEOUT);
+
+	ret = adc5_read(adc, ADC5_USR_STATUS1, &status, 1);
+	if (ret < 0)
+		goto unlock;
+
+	if (status & ADC5_USR_STATUS1_CONV_FAULT) {
+		pr_err("Unexpected conversion fault\n");
+		ret = -EIO;
+		goto unlock;
+	}
+
+	ret = adc5_read_voltage_data(adc, data_volt);
+
+unlock:
+	mutex_unlock(&adc->lock);
+
+	return ret;
+}
+
 static irqreturn_t adc5_isr(int irq, void *dev_id)
 {
 	struct adc5_chip *adc = dev_id;
@@ -377,6 +475,56 @@ static int adc5_of_xlate(struct iio_dev *indio_dev,
 	return -EINVAL;
 }
 
+static int adc7_of_xlate(struct iio_dev *indio_dev,
+				const struct of_phandle_args *iiospec)
+{
+	struct adc5_chip *adc = iio_priv(indio_dev);
+	int i, v_channel;
+
+	for (i = 0; i < adc->nchannels; i++) {
+		v_channel = ((adc->chan_props[i].sid << ADC_CHANNEL_OFFSET) |
+			adc->chan_props[i].channel);
+		if (v_channel == iiospec->args[0])
+			return i;
+	}
+
+	return -EINVAL;
+}
+
+static int adc7_read_raw(struct iio_dev *indio_dev,
+			 struct iio_chan_spec const *chan, int *val, int *val2,
+			 long mask)
+{
+	struct adc5_chip *adc = iio_priv(indio_dev);
+	struct adc5_channel_prop *prop;
+	u16 adc_code_volt, adc_code_cur;
+	int ret;
+
+	prop = &adc->chan_props[chan->address];
+
+	switch (mask) {
+	case IIO_CHAN_INFO_PROCESSED:
+		ret = adc7_do_conversion(adc, prop, chan,
+					&adc_code_volt, &adc_code_cur);
+		if (ret)
+			return ret;
+
+		ret = qcom_adc5_hw_scale(prop->scale_fn_type,
+			&adc5_prescale_ratios[prop->prescale],
+			adc->data,
+			adc_code_volt, val);
+
+		if (ret)
+			return ret;
+
+		return IIO_VAL_INT;
+	default:
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
 static int adc5_read_raw(struct iio_dev *indio_dev,
 			 struct iio_chan_spec const *chan, int *val, int *val2,
 			 long mask)
@@ -415,6 +563,11 @@ static const struct iio_info adc5_info = {
 	.of_xlate = adc5_of_xlate,
 };
 
+static const struct iio_info adc7_info = {
+	.read_raw = adc7_read_raw,
+	.of_xlate = adc7_of_xlate,
+};
+
 struct adc5_channels {
 	const char *datasheet_name;
 	unsigned int prescale_index;
@@ -477,6 +630,39 @@ static const struct adc5_channels adc5_chans_pmic[ADC5_MAX_CHANNEL] = {
 					SCALE_HW_CALIB_PM5_SMB_TEMP)
 };
 
+static const struct adc5_channels adc7_chans_pmic[ADC5_MAX_CHANNEL] = {
+	[ADC7_REF_GND]		= ADC5_CHAN_VOLT("ref_gnd", 0,
+					SCALE_HW_CALIB_DEFAULT)
+	[ADC7_1P25VREF]		= ADC5_CHAN_VOLT("vref_1p25", 0,
+					SCALE_HW_CALIB_DEFAULT)
+	[ADC7_VPH_PWR]		= ADC5_CHAN_VOLT("vph_pwr", 1,
+					SCALE_HW_CALIB_DEFAULT)
+	[ADC7_VBAT_SNS]		= ADC5_CHAN_VOLT("vbat_sns", 3,
+					SCALE_HW_CALIB_DEFAULT)
+	[ADC7_DIE_TEMP]		= ADC5_CHAN_TEMP("die_temp", 0,
+					SCALE_HW_CALIB_PMIC_THERM_PM7)
+	[ADC7_AMUX_THM1_100K_PU]	= ADC5_CHAN_TEMP("amux_thm1_pu2", 0,
+					SCALE_HW_CALIB_THERM_100K_PU_PM7)
+	[ADC7_AMUX_THM2_100K_PU]	= ADC5_CHAN_TEMP("amux_thm2_pu2", 0,
+					SCALE_HW_CALIB_THERM_100K_PU_PM7)
+	[ADC7_AMUX_THM3_100K_PU]	= ADC5_CHAN_TEMP("amux_thm3_pu2", 0,
+					SCALE_HW_CALIB_THERM_100K_PU_PM7)
+	[ADC7_AMUX_THM4_100K_PU]	= ADC5_CHAN_TEMP("amux_thm4_pu2", 0,
+					SCALE_HW_CALIB_THERM_100K_PU_PM7)
+	[ADC7_AMUX_THM5_100K_PU]	= ADC5_CHAN_TEMP("amux_thm5_pu2", 0,
+					SCALE_HW_CALIB_THERM_100K_PU_PM7)
+	[ADC7_AMUX_THM6_100K_PU]	= ADC5_CHAN_TEMP("amux_thm6_pu2", 0,
+					SCALE_HW_CALIB_THERM_100K_PU_PM7)
+	[ADC7_GPIO1_100K_PU]	= ADC5_CHAN_TEMP("gpio1_pu2", 0,
+					SCALE_HW_CALIB_THERM_100K_PU_PM7)
+	[ADC7_GPIO2_100K_PU]	= ADC5_CHAN_TEMP("gpio2_pu2", 0,
+					SCALE_HW_CALIB_THERM_100K_PU_PM7)
+	[ADC7_GPIO3_100K_PU]	= ADC5_CHAN_TEMP("gpio3_pu2", 0,
+					SCALE_HW_CALIB_THERM_100K_PU_PM7)
+	[ADC7_GPIO4_100K_PU]	= ADC5_CHAN_TEMP("gpio4_pu2", 0,
+					SCALE_HW_CALIB_THERM_100K_PU_PM7)
+};
+
 static const struct adc5_channels adc5_chans_rev2[ADC5_MAX_CHANNEL] = {
 	[ADC5_REF_GND]		= ADC5_CHAN_VOLT("ref_gnd", 0,
 					SCALE_HW_CALIB_DEFAULT)
@@ -511,6 +697,7 @@ static int adc5_get_dt_channel_data(struct adc5_chip *adc,
 {
 	const char *name = node->name, *channel_name;
 	u32 chan, value, varr[2];
+	u32 sid = 0;
 	int ret;
 	struct device *dev = adc->dev;
 
@@ -520,6 +707,15 @@ static int adc5_get_dt_channel_data(struct adc5_chip *adc,
 		return ret;
 	}
 
+	/*
+	 * Value read from "reg" is virtual channel number
+	 * virtual channel number = (sid << 8 | channel number).
+	 */
+	if (adc->is_pmic7) {
+		sid = (chan >> ADC_CHANNEL_OFFSET);
+		chan = (chan & ADC_CHANNEL_MASK);
+	}
+
 	if (chan > ADC5_PARALLEL_ISENSE_VBAT_IDATA ||
 	    !data->adc_chans[chan].datasheet_name) {
 		dev_err(dev, "%s invalid channel number %d\n", name, chan);
@@ -528,6 +724,7 @@ static int adc5_get_dt_channel_data(struct adc5_chip *adc,
 
 	/* the channel has DT description */
 	prop->channel = chan;
+	prop->sid = sid;
 
 	channel_name = of_get_property(node,
 				"label", NULL) ? : node->name;
@@ -578,8 +775,9 @@ static int adc5_get_dt_channel_data(struct adc5_chip *adc,
 		pr_debug("dig_ver:minor:%d, major:%d\n", dig_version[0],
 						dig_version[1]);
 		/* Digital controller >= 5.3 have hw_settle_2 option */
-		if (dig_version[0] >= ADC5_HW_SETTLE_DIFF_MINOR &&
-			dig_version[1] >= ADC5_HW_SETTLE_DIFF_MAJOR)
+		if ((dig_version[0] >= ADC5_HW_SETTLE_DIFF_MINOR &&
+			dig_version[1] >= ADC5_HW_SETTLE_DIFF_MAJOR) ||
+			(adc->is_pmic7))
 			ret = adc5_hw_settle_time_from_dt(value,
 							data->hw_settle_2);
 		else
@@ -639,6 +837,17 @@ static const struct adc5_data adc5_data_pmic = {
 				1, 2, 4, 8, 16, 32, 64, 128},
 };
 
+static const struct adc5_data adc7_data_pmic = {
+	.full_scale_code_volt = 0x70e4,
+	.adc_chans = adc7_chans_pmic,
+	.decimation = (unsigned int [ADC5_DECIMATION_SAMPLES_MAX])
+				{85, 340, 1360},
+	.hw_settle_2 = (unsigned int [VADC_HW_SETTLE_SAMPLES_MAX])
+				{15, 100, 200, 300, 400, 500, 600, 700,
+				1000, 2000, 4000, 8000, 16000, 32000,
+				64000, 128000},
+};
+
 static const struct adc5_data adc5_data_pmic_rev2 = {
 	.full_scale_code_volt = 0x4000,
 	.full_scale_code_cur = 0x1800,
@@ -659,6 +868,10 @@ static const struct of_device_id adc5_match_table[] = {
 		.data = &adc5_data_pmic,
 	},
 	{
+		.compatible = "qcom,spmi-adc7",
+		.data = &adc7_data_pmic,
+	},
+	{
 		.compatible = "qcom,spmi-adc-rev2",
 		.data = &adc5_data_pmic_rev2,
 	},
@@ -752,6 +965,16 @@ static int adc5_probe(struct platform_device *pdev)
 	adc->regmap = regmap;
 	adc->dev = dev;
 	adc->base = reg;
+
+	platform_set_drvdata(pdev, adc);
+
+	if (of_device_is_compatible(node, "qcom,spmi-adc7")) {
+		indio_dev->info = &adc7_info;
+		adc->is_pmic7 = true;
+	} else {
+		indio_dev->info = &adc5_info;
+	}
+
 	init_completion(&adc->complete);
 	mutex_init(&adc->lock);
 
@@ -777,19 +1000,27 @@ static int adc5_probe(struct platform_device *pdev)
 	indio_dev->dev.of_node = node;
 	indio_dev->name = pdev->name;
 	indio_dev->modes = INDIO_DIRECT_MODE;
-	indio_dev->info = &adc5_info;
 	indio_dev->channels = adc->iio_chans;
 	indio_dev->num_channels = adc->nchannels;
 
 	return devm_iio_device_register(dev, indio_dev);
 }
 
+static int adc5_exit(struct platform_device *pdev)
+{
+	struct adc5_chip *adc = platform_get_drvdata(pdev);
+
+	mutex_destroy(&adc->lock);
+	return 0;
+}
+
 static struct platform_driver adc5_driver = {
 	.driver = {
 		.name = "qcom-spmi-adc5.c",
 		.of_match_table = adc5_match_table,
 	},
 	.probe = adc5_probe,
+	.remove = adc5_exit,
 };
 module_platform_driver(adc5_driver);
 
drivers/iio/adc/qcom-vadc-common.c +260 -0

296 lines not on this page · raw message

drivers/iio/adc/qcom-vadc-common.h +14 -0
index e074902a..5f9e680 100644
@@ -49,6 +49,14 @@
 #define ADC5_FULL_SCALE_CODE			0x70e4
 #define ADC5_USR_DATA_CHECK			0x8000
 
+#define R_PU_100K			100000
+#define RATIO_MAX_ADC7		0x4000
+
+#define DIE_TEMP_ADC7_SCALE_1				-60000
+#define DIE_TEMP_ADC7_SCALE_2				20000
+#define DIE_TEMP_ADC7_SCALE_FACTOR			1000
+#define DIE_TEMP_ADC7_MAX				160000
+
 /**
  * struct vadc_map_pt - Map the graph representation for ADC channel
  * @x: Represent the ADC digitized code.
@@ -110,8 +118,12 @@ struct vadc_prescale_ratio {
  *	lookup table. The hardware applies offset/slope to adc code.
  * SCALE_HW_CALIB_XOTHERM: Returns XO thermistor voltage in millidegC using
  *	100k pullup. The hardware applies offset/slope to adc code.
+ * SCALE_HW_CALIB_THERM_100K_PU_PM7: Returns temperature in millidegC using
+ *	lookup table for PMIC7. The hardware applies offset/slope to adc code.
  * SCALE_HW_CALIB_PMIC_THERM: Returns result in milli degree's Centigrade.
  *	The hardware applies offset/slope to adc code.
+ * SCALE_HW_CALIB_PMIC_THERM: Returns result in milli degree's Centigrade.
+ *	The hardware applies offset/slope to adc code. This is for PMIC7.
  * SCALE_HW_CALIB_PM5_CHG_TEMP: Returns result in millidegrees for PMIC5
  *	charger temperature.
  * SCALE_HW_CALIB_PM5_SMB_TEMP: Returns result in millidegrees for PMIC5
@@ -126,7 +138,9 @@ enum vadc_scale_fn_type {
 	SCALE_HW_CALIB_DEFAULT,
 	SCALE_HW_CALIB_THERM_100K_PULLUP,
 	SCALE_HW_CALIB_XOTHERM,
+	SCALE_HW_CALIB_THERM_100K_PU_PM7,
 	SCALE_HW_CALIB_PMIC_THERM,
+	SCALE_HW_CALIB_PMIC_THERM_PM7,
 	SCALE_HW_CALIB_PM5_CHG_TEMP,
 	SCALE_HW_CALIB_PM5_SMB_TEMP,
 	SCALE_HW_CALIB_INVALID,
include/dt-bindings/iio/qcom,spmi-adc7-pm8350.h new file +67 -0

67 lines not on this page · raw message

include/dt-bindings/iio/qcom,spmi-adc7-pm8350b.h new file +88 -0

88 lines not on this page · raw message

include/dt-bindings/iio/qcom,spmi-adc7-pmk8350.h new file +46 -0

46 lines not on this page · raw message

include/dt-bindings/iio/qcom,spmi-adc7-pmr735a.h new file +28 -0
new file mode 100644
index 0000000..d6df1b1
@@ -0,0 +1,28 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (c) 2020 The Linux Foundation. All rights reserved.
+ */
+
+#ifndef _DT_BINDINGS_QCOM_SPMI_VADC_PMR735A_H
+#define _DT_BINDINGS_QCOM_SPMI_VADC_PMR735A_H
+
+#ifndef PMR735A_SID
+#define PMR735A_SID					4
+#endif
+
+/* ADC channels for PMR735A_ADC for PMIC7 */
+#define PMR735A_ADC7_REF_GND			(PMR735A_SID << 8 | 0x0)
+#define PMR735A_ADC7_1P25VREF			(PMR735A_SID << 8 | 0x01)
+#define PMR735A_ADC7_VREF_VADC			(PMR735A_SID << 8 | 0x02)
+#define PMR735A_ADC7_DIE_TEMP			(PMR735A_SID << 8 | 0x03)
+
+#define PMR735A_ADC7_GPIO1			(PMR735A_SID << 8 | 0x0a)
+#define PMR735A_ADC7_GPIO2			(PMR735A_SID << 8 | 0x0b)
+#define PMR735A_ADC7_GPIO3			(PMR735A_SID << 8 | 0x0c)
+
+/* 100k pull-up2 */
+#define PMR735A_ADC7_GPIO1_100K_PU		(PMR735A_SID << 8 | 0x4a)
+#define PMR735A_ADC7_GPIO2_100K_PU		(PMR735A_SID << 8 | 0x4b)
+#define PMR735A_ADC7_GPIO3_100K_PU		(PMR735A_SID << 8 | 0x4c)
+
+#endif /* _DT_BINDINGS_QCOM_SPMI_VADC_PMR735A_H */
include/dt-bindings/iio/qcom,spmi-adc7-pmr735b.h new file +28 -0
new file mode 100644
index 0000000..8da0e7d
@@ -0,0 +1,28 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (c) 2020 The Linux Foundation. All rights reserved.
+ */
+
+#ifndef _DT_BINDINGS_QCOM_SPMI_VADC_PMR735B_H
+#define _DT_BINDINGS_QCOM_SPMI_VADC_PMR735B_H
+
+#ifndef PMR735B_SID
+#define PMR735B_SID					5
+#endif
+
+/* ADC channels for PMR735B_ADC for PMIC7 */
+#define PMR735B_ADC7_REF_GND			(PMR735B_SID << 8 | 0x0)
+#define PMR735B_ADC7_1P25VREF			(PMR735B_SID << 8 | 0x01)
+#define PMR735B_ADC7_VREF_VADC			(PMR735B_SID << 8 | 0x02)
+#define PMR735B_ADC7_DIE_TEMP			(PMR735B_SID << 8 | 0x03)
+
+#define PMR735B_ADC7_GPIO1			(PMR735B_SID << 8 | 0x0a)
+#define PMR735B_ADC7_GPIO2			(PMR735B_SID << 8 | 0x0b)
+#define PMR735B_ADC7_GPIO3			(PMR735B_SID << 8 | 0x0c)
+
+/* 100k pull-up2 */
+#define PMR735B_ADC7_GPIO1_100K_PU		(PMR735B_SID << 8 | 0x4a)
+#define PMR735B_ADC7_GPIO2_100K_PU		(PMR735B_SID << 8 | 0x4b)
+#define PMR735B_ADC7_GPIO3_100K_PU		(PMR735B_SID << 8 | 0x4c)
+
+#endif /* _DT_BINDINGS_QCOM_SPMI_VADC_PMR735B_H */
include/dt-bindings/iio/qcom,spmi-vadc.h +77 -1

87 lines not on this page · raw message

Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
#16 lore raw

Re: [PATCH 3/3] iio: adc: Add support for PMIC7 ADC

Quoted 9 lines · Jishnu Prakash

The ADC architecture on PMIC7 is changed as compared to PMIC5. The major change from PMIC5 is that all SW communication to ADC goes through PMK8350, which communicates with other PMICs through PBS when the ADC on PMK8350 works in master mode. The SID register is used to identify the PMICs with which the PBS needs to communicate. Add support for the same.

In addition, add definitions for ADC channels and virtual channel definitions per PMIC, to be used by ADC clients for PMIC7.

...

drivers/iio/adc/qcom-spmi-adc5.c line 70

Quoted 2 lines
drivers/iio/adc/qcom-spmi-adc5.c +2 -0
+#define ADC_CHANNEL_OFFSET                     0x8
+#define ADC_CHANNEL_MASK                       0xff

GENMASK()

...

drivers/iio/adc/qcom-spmi-adc5.c line 88

Quoted 2 lines
drivers/iio/adc/qcom-spmi-adc5.c +2 -0
+#define ADC_APP_SID                            0x40
+#define ADC_APP_SID_MASK                       0xf

GENMASK()

Quoted 1 line

+#define ADC7_CONV_TIMEOUT msecs_to_jiffies(10)

Useless.

...

Quoted 1 line

+ buf[1] &= (u8) ~ADC5_USR_FAST_AVG_CTL_SAMPLES_MASK;

Use '0xFF ^ _MASK' instead of casting.

...

Quoted 1 line

+ buf[3] &= (u8) ~ADC5_USR_HW_SETTLE_DELAY_MASK;

Ditto.

...

drivers/iio/adc/qcom-spmi-adc5.c static int adc5_configure(struct adc5_chip *adc, · line 374

Quoted 3 lines
drivers/iio/adc/qcom-spmi-adc5.c +3 -0
+       ret = adc5_write(adc, ADC5_USR_CONV_REQ, &conv_req, 1);
+
+       return ret;

return adc5_write(...);

...

Quoted 1 line

+ pr_err("ADC configure failed with %d\n", ret);

Use dev_*() instead everywhere.

...

drivers/iio/adc/qcom-spmi-adc5.c static int adc5_do_conversion(struct adc5_chip *adc, · line 436

Quoted 3 lines
drivers/iio/adc/qcom-spmi-adc5.c +3 -0
+       /* No support for polling mode at present*/
+       wait_for_completion_timeout(&adc->complete,
+                                       ADC7_CONV_TIMEOUT);

One line. The limit is 80 and it can be bend in some cases a little bit.

...

drivers/iio/adc/qcom-spmi-adc5.c static int adc5_of_xlate(struct iio_dev *indio_dev, · line 486

Quoted 2 lines
drivers/iio/adc/qcom-spmi-adc5.c +2 -0
+               v_channel = ((adc->chan_props[i].sid << ADC_CHANNEL_OFFSET) |
+                       adc->chan_props[i].channel);

Too many parentheses.

...

drivers/iio/adc/qcom-spmi-adc5.c static int adc5_get_dt_channel_data(struct adc5_chip *adc, · line 716

Quoted 2 lines
drivers/iio/adc/qcom-spmi-adc5.c +2 -0
+               sid = (chan >> ADC_CHANNEL_OFFSET);
+               chan = (chan & ADC_CHANNEL_MASK);

Ditto.

...

Quoted 1 line

+ (adc->is_pmic7))

Ditto.

...

drivers/iio/adc/qcom-spmi-adc5.c static int adc5_probe(struct platform_device *pdev) · line 976

Quoted 6 lines
drivers/iio/adc/qcom-spmi-adc5.c +6 -0
+       if (of_device_is_compatible(node, "qcom,spmi-adc7")) {
+               indio_dev->info = &adc7_info;
+               adc->is_pmic7 = true;
+       } else {
+               indio_dev->info = &adc5_info;
+       }

Hmm... I would rather put this as driver_data in ID structure(s).

...

drivers/iio/adc/qcom-spmi-adc5.c static int adc5_probe(struct platform_device *pdev)

Quoted 6 lines
drivers/iio/adc/qcom-spmi-adc5.c +5 -0
+static int adc5_exit(struct platform_device *pdev)
+{
+       struct adc5_chip *adc = platform_get_drvdata(pdev);
+
 
+       mutex_destroy(&adc->lock);

Are you sure you will have no race conditions? Does this driver use IRQs?

Quoted 2 lines
(quoted diff) +2 -0
+       return 0;
+}

...

Quoted 1 line

+ s64 resistance = 0;

= adc_code // or sign extended variant if needed.

drivers/iio/adc/qcom-vadc-common.c static int qcom_vadc_scale_code_voltage_factor(u16 adc_code, · line 508

Quoted 4 lines
drivers/iio/adc/qcom-vadc-common.c +3 -0
+       /* (ADC code * R_PULLUP (100Kohm)) / (full_scale_code - ADC code)*/
 
+       resistance = (s64) adc_code * R_PU_100K;
+       resistance = div64_s64(resistance, (RATIO_MAX_ADC7 - adc_code));

resistance *= R_PU_100K;
resistance = div64_s64(resistance, RATIO_MAX_ADC7 - adc_code);

...

drivers/iio/adc/qcom-vadc-common.c static int qcom_vadc_scale_hw_calib_die_temp( · line 575

Quoted 7 lines
drivers/iio/adc/qcom-vadc-common.c +6 -0
+       int voltage, vtemp0, temp, i = 0;
 
+       while (i < ARRAY_SIZE(adcmap7_die_temp)) {
+               if (adcmap7_die_temp[i].x > voltage)
+                       break;
+               i++;
+       }

for loop (one line less, more explicit initial value assignment)?

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

Re: [PATCH 3/3] iio: adc: Add support for PMIC7 ADC

Hi Andy,

Quoted 7 lines · Andy Shevchenko
Quoted 6 lines · Jishnu Prakash

The ADC architecture on PMIC7 is changed as compared to PMIC5. The major change from PMIC5 is that all SW communication to ADC goes through PMK8350, which communicates with other PMICs through PBS when the ADC on PMK8350 works in master mode. The SID register is used to identify the PMICs with which the PBS needs to communicate. Add support for the same.

Quoted 7 lines
Quoted 2 lines

In addition, add definitions for ADC channels and virtual channel definitions per PMIC, to be used by ADC clients for PMIC7.

...

drivers/iio/adc/qcom-spmi-adc5.c line 70

Quoted 2 lines
drivers/iio/adc/qcom-spmi-adc5.c +2 -0
+#define ADC_CHANNEL_OFFSET                     0x8
+#define ADC_CHANNEL_MASK                       0xff

GENMASK()

I'll fix this and the other simple changes in the next post.

Quoted 9 lines

...

drivers/iio/adc/qcom-spmi-adc5.c line 88

Quoted 2 lines
drivers/iio/adc/qcom-spmi-adc5.c +2 -0
+#define ADC_APP_SID                            0x40
+#define ADC_APP_SID_MASK                       0xf

GENMASK()

Quoted 1 line

+#define ADC7_CONV_TIMEOUT msecs_to_jiffies(10)

Useless.

I'm not sure what you mean by this. It is used in the API adc7_do_conversion.

Quoted 9 lines

...

+ if (of_device_is_compatible(node, "qcom,spmi-adc7")) {

drivers/iio/adc/qcom-spmi-adc5.c static int adc5_probe(struct platform_device *pdev) · line 976

Quoted 5 lines
drivers/iio/adc/qcom-spmi-adc5.c +5 -0
+               indio_dev->info = &adc7_info;
+               adc->is_pmic7 = true;
+       } else {
+               indio_dev->info = &adc5_info;
+       }

Hmm... I would rather put this as driver_data in ID structure(s).

I'll remove the check for the compatible string, using driver data, in the next post.

Quoted 9 lines

...

drivers/iio/adc/qcom-spmi-adc5.c static int adc5_probe(struct platform_device *pdev) · line 1013

Quoted 5 lines
drivers/iio/adc/qcom-spmi-adc5.c +5 -0
+static int adc5_exit(struct platform_device *pdev)
+{
+       struct adc5_chip *adc = platform_get_drvdata(pdev);
+
+       mutex_destroy(&adc->lock);

Are you sure you will have no race conditions? Does this driver use IRQs?

The driver does use an IRQ. Will fix this in the next post.

Quoted 2 lines
maintainer
#18 lore raw

Re: [PATCH 3/3] iio: adc: Add support for PMIC7 ADC

In reply to Jishnu Prakash
Quoted 10 lines · On Tue, 24 Mar 2020 21:14:10 +0530 Jishnu Prakash <[email protected]>…

The ADC architecture on PMIC7 is changed as compared to PMIC5. The major change from PMIC5 is that all SW communication to ADC goes through PMK8350, which communicates with other PMICs through PBS when the ADC on PMK8350 works in master mode. The SID register is used to identify the PMICs with which the PBS needs to communicate. Add support for the same.

In addition, add definitions for ADC channels and virtual channel definitions per PMIC, to be used by ADC clients for PMIC7.

A few additions from me.

Quoted 1 line

---

...

drivers/iio/adc/qcom-spmi-adc5.c static int adc5_probe(struct platform_device *pdev) · line 1013

Quoted 6 lines
drivers/iio/adc/qcom-spmi-adc5.c +5 -0
+static int adc5_exit(struct platform_device *pdev)
+{
+	struct adc5_chip *adc = platform_get_drvdata(pdev);
+
+	mutex_destroy(&adc->lock);

Andy raised potential races. You definitely have some as this will destroy the mutex before you've removed the userspace interfaces.

Quoted 13 lines
drivers/iio/adc/qcom-spmi-adc5.c +4 -0
+	return 0;
+}
+
 static struct platform_driver adc5_driver = {
 	.driver = {
 		.name = "qcom-spmi-adc5.c",
 		.of_match_table = adc5_match_table,
 	},
 	.probe = adc5_probe,
+	.remove = adc5_exit,
 };
 module_platform_driver(adc5_driver);

...

Quoted 7 lines
drivers/iio/adc/qcom-vadc-common.c +6 -0
+static int qcom_vadc7_scale_hw_calib_die_temp(
+				const struct vadc_prescale_ratio *prescale,
+				const struct adc5_data *data,
+				u16 adc_code, int *result_mdec)
+{
+

drivers/iio/adc/qcom-vadc-common.c static int qcom_vadc_scale_hw_calib_die_temp( · line 575

Quoted 10 lines
drivers/iio/adc/qcom-vadc-common.c +10 -0
+	int voltage, vtemp0, temp, i = 0;
+
+	voltage = qcom_vadc_scale_code_voltage_factor(adc_code,
+				prescale, data, 1);
+
+	while (i < ARRAY_SIZE(adcmap7_die_temp)) {
+		if (adcmap7_die_temp[i].x > voltage)
+			break;
+		i++;
+	}

For loop (I think Andy also raised this one).

drivers/iio/adc/qcom-vadc-common.c static int qcom_vadc_scale_hw_calib_die_temp( · line 582

Quoted 7 lines
drivers/iio/adc/qcom-vadc-common.c +7 -0
+
+	if (i == 0) {
+		*result_mdec = DIE_TEMP_ADC7_SCALE_1;
+	} else if (i == ARRAY_SIZE(adcmap7_die_temp)) {
+		*result_mdec = DIE_TEMP_ADC7_MAX;
+	} else {
+		vtemp0 = adcmap7_die_temp[i-1].x;

Spaces around the -
Same elsewhere.

Quoted 13 lines
drivers/iio/adc/qcom-vadc-common.c +10 -0
+		voltage = voltage - vtemp0;
+		temp = div64_s64(voltage * DIE_TEMP_ADC7_SCALE_FACTOR,
+			adcmap7_die_temp[i-1].y);
+		temp += DIE_TEMP_ADC7_SCALE_1 + (DIE_TEMP_ADC7_SCALE_2 * (i-1));
+		*result_mdec = temp;
+	}
+
+	return 0;
+}
+
 static int qcom_vadc_scale_hw_smb_temp(
 				const struct vadc_prescale_ratio *prescale,
 				const struct adc5_data *data,

...

#19 lore raw

Re: [PATCH 3/3] iio: adc: Add support for PMIC7 ADC

Hi Jonathan,

Quoted 19 lines · Jonathan Cameron
Quoted 10 lines · On Tue, 24 Mar 2020 21:14:10 +0530 Jishnu Prakash <[email protected]>…

The ADC architecture on PMIC7 is changed as compared to PMIC5. The major change from PMIC5 is that all SW communication to ADC goes through PMK8350, which communicates with other PMICs through PBS when the ADC on PMK8350 works in master mode. The SID register is used to identify the PMICs with which the PBS needs to communicate. Add support for the same.

In addition, add definitions for ADC channels and virtual channel definitions per PMIC, to be used by ADC clients for PMIC7.

A few additions from me.

Quoted 1 line

---

...

I'll address your comments in the next post.

maintainer
#20 lore raw

Re: [PATCH 3/3] iio: adc: Add support for PMIC7 ADC

In reply to Jishnu Prakash
Quoted 10 lines · Jishnu Prakash

The ADC architecture on PMIC7 is changed as compared to PMIC5. The major change from PMIC5 is that all SW communication to ADC goes through PMK8350, which communicates with other PMICs through PBS when the ADC on PMK8350 works in master mode. The SID register is used to identify the PMICs with which the PBS needs to communicate. Add support for the same.

In addition, add definitions for ADC channels and virtual channel definitions per PMIC, to be used by ADC clients for PMIC7.

Quoted 10 lines
---
 drivers/iio/adc/qcom-spmi-adc5.c                 | 239 ++++++++++++++++++++-
 drivers/iio/adc/qcom-vadc-common.c               | 260 +++++++++++++++++++++++
 drivers/iio/adc/qcom-vadc-common.h               |  14 ++
 include/dt-bindings/iio/qcom,spmi-adc7-pm8350.h  |  67 ++++++
 include/dt-bindings/iio/qcom,spmi-adc7-pm8350b.h |  88 ++++++++
 include/dt-bindings/iio/qcom,spmi-adc7-pmk8350.h |  46 ++++
 include/dt-bindings/iio/qcom,spmi-adc7-pmr735a.h |  28 +++
 include/dt-bindings/iio/qcom,spmi-adc7-pmr735b.h |  28 +++
 include/dt-bindings/iio/qcom,spmi-vadc.h         |  78 ++++++-

DT headers go in the binding patch(es).

Quoted 6 lines
 9 files changed, 843 insertions(+), 5 deletions(-)
 create mode 100644 include/dt-bindings/iio/qcom,spmi-adc7-pm8350.h
 create mode 100644 include/dt-bindings/iio/qcom,spmi-adc7-pm8350b.h
 create mode 100644 include/dt-bindings/iio/qcom,spmi-adc7-pmk8350.h
 create mode 100644 include/dt-bindings/iio/qcom,spmi-adc7-pmr735a.h
 create mode 100644 include/dt-bindings/iio/qcom,spmi-adc7-pmr735b.h
#21 lore raw

Re: [PATCH 3/3] iio: adc: Add support for PMIC7 ADC

Hi Rob

Quoted 21 lines · Rob Herring
Quoted 10 lines · Jishnu Prakash

The ADC architecture on PMIC7 is changed as compared to PMIC5. The major change from PMIC5 is that all SW communication to ADC goes through PMK8350, which communicates with other PMICs through PBS when the ADC on PMK8350 works in master mode. The SID register is used to identify the PMICs with which the PBS needs to communicate. Add support for the same.

In addition, add definitions for ADC channels and virtual channel definitions per PMIC, to be used by ADC clients for PMIC7.

Quoted 10 lines
---
  drivers/iio/adc/qcom-spmi-adc5.c                 | 239 ++++++++++++++++++++-
  drivers/iio/adc/qcom-vadc-common.c               | 260 +++++++++++++++++++++++
  drivers/iio/adc/qcom-vadc-common.h               |  14 ++
  include/dt-bindings/iio/qcom,spmi-adc7-pm8350.h  |  67 ++++++
  include/dt-bindings/iio/qcom,spmi-adc7-pm8350b.h |  88 ++++++++
  include/dt-bindings/iio/qcom,spmi-adc7-pmk8350.h |  46 ++++
  include/dt-bindings/iio/qcom,spmi-adc7-pmr735a.h |  28 +++
  include/dt-bindings/iio/qcom,spmi-adc7-pmr735b.h |  28 +++
  include/dt-bindings/iio/qcom,spmi-vadc.h         |  78 ++++++-
Quoted 1 line

DT headers go in the binding patch(es).

I'll move these to the bindings patch in the next post.

Quoted 7 lines
Quoted 7 lines
  9 files changed, 843 insertions(+), 5 deletions(-)

create mode 100644 include/dt-bindings/iio/qcom,spmi-adc7-pm8350.h create mode 100644 include/dt-bindings/iio/qcom,spmi-adc7-pm8350b.h create mode 100644 include/dt-bindings/iio/qcom,spmi-adc7-pmk8350.h create mode 100644 include/dt-bindings/iio/qcom,spmi-adc7-pmr735a.h create mode 100644 include/dt-bindings/iio/qcom,spmi-adc7-pmr735b.h