Skip to contentSkip to conversation

iio: adc: mt6360: Add ADC driver for MT6360

PATCH In review Gene Chen 3 participants 9 messages Oct 20, 2020 – Nov 8, 2020

Subsystems (3)
lore
Share & tools
lore

Gene Chen

author
#0 lore raw

v7 cover iio: adc: mt6360: Add ADC driver for MT6360

In-Reply-To:

This patch series add MT6360 ADC support contains driver, testing document and binding document

Gene Chen (2)
dt-bindings: iio: adc: add bindings doc for MT6360 ADC
Documentation: ABI: testing: mt6360: Add ADC sysfs guideline
iio: adc: mt6360: Add ADC driver for MT6360

 Documentation/ABI/testing/sysfs-bus-iio-adc-mt6360                 |   78 ++
 Documentation/devicetree/bindings/iio/adc/mediatek,mt6360-adc.yaml |   34 
 drivers/iio/adc/Kconfig                                            |   11 
 drivers/iio/adc/Makefile                                           |    1 
 drivers/iio/adc/mt6360-adc.c                                       |  372 ++++++++++
 5 files changed, 496 insertions(+)

changelogs between v1 & v2
- adc: use IIO_CHAN_INFO_PROCESSED only
- adc: use devm_iio_triggered_buffer_setup
- adc: use use s64 to record timestamp

changelogs between v2 & v3
- Rearrange include file order by alphabet
- Set line length constraint below 100
- Add Document for testing adc sysfs node guideline
- Set compiler 64 bit aligned when handle iio timestamp

changelogs between v3 & v4
- Fix sysfs guideline description
- Replace iio channel processed by raw/scale/offset
- Add comment of read adc flow for special HW design

changelogs between v4 & v5
- Rename dt-bindings aligned to file name
- Aligned sysfs node name with driver and add VBUSDIVX description
- Add ADC channel sysfs node "*_labels"

changelogs between v5 & v6
- Memset aligned adc data
- Remove strong casting void pointer

changelogs between v6 & v7
- Avoid adc polling infinite loop

author
#1 lore raw

PATCH v7 1/3 dt-bindings: iio: adc: add bindings doc for MT6360 ADC

From: Gene Chen <[email protected]>

This change adds the binding doc for the MT6360 ADC.

---
 .../bindings/iio/adc/mediatek,mt6360-adc.yaml      | 34 ++++++++++++++++++++++
 1 file changed, 34 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/adc/mediatek,mt6360-adc.yaml
Documentation/devicetree/bindings/iio/adc/mediatek,mt6360-adc.yaml new file +34 -0
new file mode 100644
index 0000000..a7350ec
@@ -0,0 +1,34 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/adc/mediatek,mt6360-adc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Mediatek MT6360 and similar ADCs
+
+maintainers:
+  - Gene Chen <[email protected]>
+
+description: |
+  Family of simple ADCs with i2c interface and internal references.
+
+properties:
+  compatible:
+    const: mediatek,mt6360-adc
+
+  "#io-channel-cells":
+    const: 1
+
+required:
+  - compatible
+  - "#io-channel-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+    adc {
+      compatible = "mediatek,mt6360-adc";
+      #io-channel-cells = <1>;
+    };
+...
Signature · 1 line
2.7.4
maintainer
#2 lore raw

Re: [PATCH v7 1/3] dt-bindings: iio: adc: add bindings doc for MT6360 ADC

Quoted 10 lines · Gene Chen

From: Gene Chen <[email protected]>

This change adds the binding doc for the MT6360 ADC.

---
 .../bindings/iio/adc/mediatek,mt6360-adc.yaml      | 34 ++++++++++++++++++++++
 1 file changed, 34 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/adc/mediatek,mt6360-adc.yaml

Please add Acked-by/Reviewed-by tags when posting new versions. However, there's no need to repost patches *only* to add the tags. The upstream maintainer will do that for acks received on the version they apply.

If a tag was not added on purpose, please state why and what changed.

maintainer
#3 lore raw

Re: [PATCH v7 1/3] dt-bindings: iio: adc: add bindings doc for MT6360 ADC

In reply to Gene Chen
Quoted 3 lines · On Tue, 20 Oct 2020 16:07:45 +0800 Gene Chen <[email protected]>…

From: Gene Chen <[email protected]>

This change adds the binding doc for the MT6360 ADC.

One thing I'd previously missed below.

Jonathan

Quoted 16 lines
---
 .../bindings/iio/adc/mediatek,mt6360-adc.yaml      | 34 ++++++++++++++++++++++
 1 file changed, 34 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/adc/mediatek,mt6360-adc.yaml
Documentation/devicetree/bindings/iio/adc/mediatek,mt6360-adc.yaml new file +3 -0
new file mode 100644
index 0000000..a7350ec
@@ -0,0 +1,34 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---

Documentation/devicetree/bindings/iio/adc/mediatek,mt6360-adc.yaml line 13

Quoted 10 lines
Documentation/devicetree/bindings/iio/adc/mediatek,mt6360-adc.yaml new file +10 -0
+$id: http://devicetree.org/schemas/iio/adc/mediatek,mt6360-adc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Mediatek MT6360 and similar ADCs
+
+maintainers:
+  - Gene Chen <[email protected]>
+
+description: |
+  Family of simple ADCs with i2c interface and internal references.

That seems unlikely...

Quoted 21 lines
Documentation/devicetree/bindings/iio/adc/mediatek,mt6360-adc.yaml new file +21 -0
+
+properties:
+  compatible:
+    const: mediatek,mt6360-adc
+
+  "#io-channel-cells":
+    const: 1
+
+required:
+  - compatible
+  - "#io-channel-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+    adc {
+      compatible = "mediatek,mt6360-adc";
+      #io-channel-cells = <1>;
+    };
+...
author
#4 lore raw

PATCH v7 2/3 Documentation: ABI: testing: mt6360: Add ADC sysfs guideline

In reply to Gene Chen

From: Gene Chen <[email protected]>

Add ABI documentation for mt6360 ADC sysfs interfaces.

---
 Documentation/ABI/testing/sysfs-bus-iio-adc-mt6360 | 78 ++++++++++++++++++++++
 1 file changed, 78 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-bus-iio-adc-mt6360
Documentation/ABI/testing/sysfs-bus-iio-adc-mt6360 new file +78 -0
new file mode 100644
index 0000000..e5a7b1c
@@ -0,0 +1,78 @@
+What:		/sys/bus/iio/devices/iio:deviceX/in_voltage0_raw
+KernelVersion:	5.8.0
+Contact:	[email protected]
+Description:
+		Indicated MT6360 USBID ADC which connected to connector ID pin.
+		Calculating with scale and offset returns voltage in uV
+
+What:		/sys/bus/iio/devices/iio:deviceX/in_voltage1_raw
+KernelVersion:	5.8.0
+Contact:	[email protected]
+Description:
+		Indicated MT6360 VBUS ADC with lower accuracy(+-75mA)
+		higher measure range(1~22mV)
+		Calculating with scale and offset returns voltage in uV
+
+What:		/sys/bus/iio/devices/iio:deviceX/in_voltage2_raw
+KernelVersion:	5.8.0
+Contact:	[email protected]
+Description:
+		Indicated MT6360 VBUS ADC with higher accuracy(+-30mA)
+		lower measure range(1~9.76V)
+		Calculating with scale and offset returns voltage in uV
+
+What:		/sys/bus/iio/devices/iio:deviceX/in_voltage3_raw
+KernelVersion:	5.8.0
+Contact:	[email protected]
+Description:
+		Indicated MT6360 VSYS ADC
+		Calculating with scale and offset returns voltage in uV
+
+What:		/sys/bus/iio/devices/iio:deviceX/in_voltage4_raw
+KernelVersion:	5.8.0
+Contact:	[email protected]
+Description:
+		Indicated MT6360 VBAT ADC
+		Calculating with scale and offset returns voltage in uV
+
+What:		/sys/bus/iio/devices/iio:deviceX/in_current5_raw
+KernelVersion:	5.8.0
+Contact:	[email protected]
+Description:
+		Indicated MT6360 IBUS ADC
+		Calculating with scale and offset returns voltage in uA
+
+What:		/sys/bus/iio/devices/iio:deviceX/in_current6_raw
+KernelVersion:	5.8.0
+Contact:	[email protected]
+Description:
+		Indicated MT6360 IBAT ADC
+		Calculating with scale and offset returns voltage in uA
+
+What:		/sys/bus/iio/devices/iio:deviceX/in_current7_raw
+KernelVersion:	5.8.0
+Contact:	[email protected]
+Description:
+		Indicated MT6360 CHG_VDDP ADC
+		Calculating with scale and offset returns voltage in uV
+
+What:		/sys/bus/iio/devices/iio:deviceX/in_temp8_raw
+KernelVersion:	5.8.0
+Contact:	[email protected]
+Description:
+		Indicated MT6360 IC junction temperature
+		Calculating with scale and offset returns temperature in degree
+
+What:		/sys/bus/iio/devices/iio:deviceX/in_voltage9_raw
+KernelVersion:	5.8.0
+Contact:	[email protected]
+Description:
+		Indicated MT6360 VREF_TS ADC
+		Calculating with scale and offset returns voltage in uV
+
+What:		/sys/bus/iio/devices/iio:deviceX/in_voltage10_raw
+KernelVersion:	5.8.0
+Contact:	[email protected]
+Description:
+		Indicated MT6360 TS ADC
+		Calculating with scale and offset returns voltage in uV
Signature · 1 line
2.7.4
author
#5 lore raw

PATCH v7 3/3 iio: adc: mt6360: Add ADC driver for MT6360

In reply to Gene Chen

From: Gene Chen <[email protected]>

Add MT6360 ADC driver including Charger Current, Voltage, and Temperature.

---
 drivers/iio/adc/Kconfig      |  11 ++
 drivers/iio/adc/Makefile     |   1 +
 drivers/iio/adc/mt6360-adc.c | 372 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 384 insertions(+)
 create mode 100644 drivers/iio/adc/mt6360-adc.c
drivers/iio/adc/Kconfig +11 -0
index d94dc80..a135ada 100644
@@ -703,6 +703,17 @@ config MCP3911
 	  This driver can also be built as a module. If so, the module will be
 	  called mcp3911.
 
+config MEDIATEK_MT6360_ADC
+	tristate "Mediatek MT6360 ADC driver"
+	depends on MFD_MT6360
+	select IIO_BUFFER
+	select IIO_TRIGGERED_BUFFER
+	help
+	  Say Y here to enable MT6360 ADC support.
+	  Integrated for System Monitoring includes
+	  is used in smartphones and tablets and supports a 11 channel
+	  general purpose ADC.
+
 config MEDIATEK_MT6577_AUXADC
 	tristate "MediaTek AUXADC driver"
 	depends on ARCH_MEDIATEK || COMPILE_TEST
drivers/iio/adc/Makefile +1 -0
index 90f94ad..5fca90a 100644
@@ -65,6 +65,7 @@ obj-$(CONFIG_MAX9611) += max9611.o
 obj-$(CONFIG_MCP320X) += mcp320x.o
 obj-$(CONFIG_MCP3422) += mcp3422.o
 obj-$(CONFIG_MCP3911) += mcp3911.o
+obj-$(CONFIG_MEDIATEK_MT6360_ADC) += mt6360-adc.o
 obj-$(CONFIG_MEDIATEK_MT6577_AUXADC) += mt6577_auxadc.o
 obj-$(CONFIG_MEN_Z188_ADC) += men_z188_adc.o
 obj-$(CONFIG_MESON_SARADC) += meson_saradc.o
drivers/iio/adc/mt6360-adc.c new file +372 -0

372 lines not on this page · raw message

Signature · 1 line
2.7.4
maintainer
#6 lore raw
In reply to Gene Chen
Quoted 5 lines · On Tue, 20 Oct 2020 16:07:44 +0800 Gene Chen <[email protected]>…

In-Reply-To:

This patch series add MT6360 ADC support contains driver, testing document and binding document

Hi Gene,

Other than that small edit needed in the dt binding this is stalled on the label code getting upstreamed into the core.

I've asked Cristian to repost that so hopefully we can resolve that dependency and get this merged fairly soon.

For the dt thing I can just drop the description entirely, but would prefer if you sent a v8 fixing the tags issue Rob pointed out and also fixing that description.

Thanks,

Jonathan

Quoted 40 lines

Gene Chen (2)
dt-bindings: iio: adc: add bindings doc for MT6360 ADC
Documentation: ABI: testing: mt6360: Add ADC sysfs guideline
iio: adc: mt6360: Add ADC driver for MT6360

 Documentation/ABI/testing/sysfs-bus-iio-adc-mt6360                 |   78 ++
 Documentation/devicetree/bindings/iio/adc/mediatek,mt6360-adc.yaml |   34 
 drivers/iio/adc/Kconfig                                            |   11 
 drivers/iio/adc/Makefile                                           |    1 
 drivers/iio/adc/mt6360-adc.c                                       |  372 ++++++++++
 5 files changed, 496 insertions(+)

changelogs between v1 & v2
- adc: use IIO_CHAN_INFO_PROCESSED only
- adc: use devm_iio_triggered_buffer_setup
- adc: use use s64 to record timestamp

changelogs between v2 & v3
- Rearrange include file order by alphabet
- Set line length constraint below 100
- Add Document for testing adc sysfs node guideline
- Set compiler 64 bit aligned when handle iio timestamp

changelogs between v3 & v4
- Fix sysfs guideline description
- Replace iio channel processed by raw/scale/offset
- Add comment of read adc flow for special HW design

changelogs between v4 & v5
- Rename dt-bindings aligned to file name
- Aligned sysfs node name with driver and add VBUSDIVX description
- Add ADC channel sysfs node "*_labels"

changelogs between v5 & v6
- Memset aligned adc data
- Remove strong casting void pointer

changelogs between v6 & v7
- Avoid adc polling infinite loop

author
#7 lore raw

Jonathan Cameron <[email protected]> 於 2020年11月1日 週日 下午11:40寫道:

Quoted 17 lines
Quoted 5 lines · On Tue, 20 Oct 2020 16:07:44 +0800 Gene Chen <[email protected]>…

In-Reply-To:

This patch series add MT6360 ADC support contains driver, testing document and binding document

Hi Gene,

Other than that small edit needed in the dt binding this is stalled on the label code getting upstreamed into the core.

I've asked Cristian to repost that so hopefully we can resolve that dependency and get this merged fairly soon.

Quoted 8 lines

For the dt thing I can just drop the description entirely, but would prefer if you sent a v8 fixing the tags issue Rob pointed out and also fixing that description.

Thanks,

Jonathan

=============

Review

Quoted 2 lines
(quoted diff) +2 -0
+description: |
+  Family of simple ADCs with i2c interface and internal references.

That seems unlikely...
=============

Do you means I should remove this description?
If yes, I will also update PATCH v8 for add tags and fix dt-bindings.

Quoted 41 lines
Quoted 40 lines

Gene Chen (2)
dt-bindings: iio: adc: add bindings doc for MT6360 ADC
Documentation: ABI: testing: mt6360: Add ADC sysfs guideline
iio: adc: mt6360: Add ADC driver for MT6360

 Documentation/ABI/testing/sysfs-bus-iio-adc-mt6360                 |   78 ++
 Documentation/devicetree/bindings/iio/adc/mediatek,mt6360-adc.yaml |   34
 drivers/iio/adc/Kconfig                                            |   11
 drivers/iio/adc/Makefile                                           |    1
 drivers/iio/adc/mt6360-adc.c                                       |  372 ++++++++++
 5 files changed, 496 insertions(+)

changelogs between v1 & v2
- adc: use IIO_CHAN_INFO_PROCESSED only
- adc: use devm_iio_triggered_buffer_setup
- adc: use use s64 to record timestamp

changelogs between v2 & v3
- Rearrange include file order by alphabet
- Set line length constraint below 100
- Add Document for testing adc sysfs node guideline
- Set compiler 64 bit aligned when handle iio timestamp

changelogs between v3 & v4
- Fix sysfs guideline description
- Replace iio channel processed by raw/scale/offset
- Add comment of read adc flow for special HW design

changelogs between v4 & v5
- Rename dt-bindings aligned to file name
- Aligned sysfs node name with driver and add VBUSDIVX description
- Add ADC channel sysfs node "*_labels"

changelogs between v5 & v6
- Memset aligned adc data
- Remove strong casting void pointer

changelogs between v6 & v7
- Avoid adc polling infinite loop

maintainer
#8 lore raw
In reply to Jonathan Cameron
Quoted 13 lines · On Sun, 1 Nov 2020 15:40:19 +0000 Jonathan Cameron <[email protected]> wrote:
Quoted 5 lines · On Tue, 20 Oct 2020 16:07:44 +0800 Gene Chen <[email protected]>…

In-Reply-To:

This patch series add MT6360 ADC support contains driver, testing document and binding document

Hi Gene,

Other than that small edit needed in the dt binding this is stalled on the label code getting upstreamed into the core.

Quoted 6 lines

I've asked Cristian to repost that so hopefully we can resolve that dependency and get this merged fairly soon.

For the dt thing I can just drop the description entirely, but would prefer if you sent a v8 fixing the tags issue Rob pointed out and also fixing that description.

I've tweaked as described and applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to poke at it more than I do.

Thanks,

Jonathan

Quoted 46 lines

Thanks,

Jonathan

Quoted 40 lines

Gene Chen (2)
dt-bindings: iio: adc: add bindings doc for MT6360 ADC
Documentation: ABI: testing: mt6360: Add ADC sysfs guideline
iio: adc: mt6360: Add ADC driver for MT6360

 Documentation/ABI/testing/sysfs-bus-iio-adc-mt6360                 |   78 ++
 Documentation/devicetree/bindings/iio/adc/mediatek,mt6360-adc.yaml |   34 
 drivers/iio/adc/Kconfig                                            |   11 
 drivers/iio/adc/Makefile                                           |    1 
 drivers/iio/adc/mt6360-adc.c                                       |  372 ++++++++++
 5 files changed, 496 insertions(+)

changelogs between v1 & v2
- adc: use IIO_CHAN_INFO_PROCESSED only
- adc: use devm_iio_triggered_buffer_setup
- adc: use use s64 to record timestamp

changelogs between v2 & v3
- Rearrange include file order by alphabet
- Set line length constraint below 100
- Add Document for testing adc sysfs node guideline
- Set compiler 64 bit aligned when handle iio timestamp

changelogs between v3 & v4
- Fix sysfs guideline description
- Replace iio channel processed by raw/scale/offset
- Add comment of read adc flow for special HW design

changelogs between v4 & v5
- Rename dt-bindings aligned to file name
- Aligned sysfs node name with driver and add VBUSDIVX description
- Add ADC channel sysfs node "*_labels"

changelogs between v5 & v6
- Memset aligned adc data
- Remove strong casting void pointer

changelogs between v6 & v7
- Avoid adc polling infinite loop