Skip to contentSkip to conversation

iio: imx8qxp-adc: Add driver support for NXP IMX8QXP ADC

PATCH Superseded Cai Huoqing 3 participants 6 messages Sep 21, 2021 – Sep 23, 2021

Subsystems (4)

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v5 cover iio: imx8qxp-adc: Add driver support for NXP IMX8QXP ADC

The NXP i.MX 8QuadXPlus SOC has a new ADC IP. These patches add driver support for this ADC.

dt-bindings: iio: adc:
v1->v2:
*Fix some indentation issues.
*Mark status as okay.
*Change clock2 source.
v3->v4:
*Remove 'status' from examples. *Remove unused 'state'.
*Remove interrupts-parent.
*Change num of address/size-cells from 1 to 2.
v4->v5:
*Remove unused properties

iio: imx8qxp-adc:
v1->v2:
*Squash patches 1, 2, 3, and 5 into a single patch.
*Add device specific prefix.
*Remove the brackets around individual numbers.
*Make use of FIELD_PREP() and FIELD_GET().
*Remove a lot of cache values.
*Replace mlock with adc->lock.
*Move adc->value read from isr to the completion.
*Set pm_runtime_disable/_put_noidle() before adc_disable.
*Add error handler-err_disable_reg/err_unprepare_clk.
v2->v3:
*Add "return 0" to adc_runtime_resume().
v3->v4:
*Sort header file declarations in alphabetical order.
*Remove explicitly cast from "void *".
*Make use of dev_err_probe().
*Add some blank lines to help readability.
v4->v5:
*Update commit message.
*Remove unused headers.
*Wrap imx8qxp_adc_read_raw() at a shorter line length that helps readability. *Deal with clock/regulator in probe/remove().
*Use ADC_DRIVER_NAME instead of dev_name(dev).
*Don't use dev_error_probe() without returning -PROBE_DEFER.

v1 link:
https://patchwork.kernel.org/project/linux-arm-kernel/patch/[email protected]/
v3 link:
https://patchwork.kernel.org/project/linux-arm-kernel/cover/[email protected]/
v4 link:
https://patchwork.kernel.org/project/linux-arm-kernel/cover/[email protected]/

Cai Huoqing (3):
iio: imx8qxp-adc: Add driver support for NXP IMX8QXP ADC
iio: imx8qxp-adc: dt-bindings: iio: adc: Add binding documentation for
NXP IMX8QXP ADC
MAINTAINERS: Add the driver info of the NXP IMX8QXP

 .../bindings/iio/adc/nxp,imx8qxp-adc.yaml     |  78 +++
 MAINTAINERS                                   |   7 +
 drivers/iio/adc/Kconfig                       |  10 +
 drivers/iio/adc/Makefile                      |   1 +
 drivers/iio/adc/imx8qxp-adc.c                 | 492 ++++++++++++++++++
 5 files changed, 588 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/adc/nxp,imx8qxp-adc.yaml
 create mode 100644 drivers/iio/adc/imx8qxp-adc.c
Signature · 7 lines
2.25.1


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#1 lore raw

PATCH v5 1/3 iio: imx8qxp-adc: Add driver support for NXP IMX8QXP ADC

The NXP i.MX 8QuadXPlus SOC has a new ADC IP, so add driver support for this ADC.

---
v1->v2:
*Squash patches 1, 2, 3, and 5 into a single patch.
*Add device specific prefix.
*Remove the brackets around individual numbers.
*Make use of FIELD_PREP() and FIELD_GET().
*Remove a lot of cache values.
*Replace mlock with adc->lock.
*Move adc->value read from isr to the completion.
*Set pm_runtime_disable/_put_noidle() before adc_disable.
*Add error handler-err_disable_reg/err_unprepare_clk.
v2->v3:
*Add "return 0" to adc_runtime_resume().
v3->v4:
*Sort header file declarations in alphabetical order.
*Remove explicitly cast from "void *".
*Make use of dev_err_probe().
*Add some blank lines to help readability.
v4->v5:
*Update commit message.
*Remove unused headers.
*Wrap imx8qxp_adc_read_raw() at a shorter line length that helps readability. *Deal with clock/regulator in probe/remove().
*Use ADC_DRIVER_NAME instead of dev_name(dev).
*Don't use dev_error_probe() without returning -PROBE_DEFER.

v1 link:
https://patchwork.kernel.org/project/linux-arm-kernel/patch/[email protected]/
v3 link:
https://patchwork.kernel.org/project/linux-arm-kernel/patch/[email protected]/
v4 link:
https://patchwork.kernel.org/project/linux-arm-kernel/patch/[email protected]/

 drivers/iio/adc/Kconfig       |  10 +
 drivers/iio/adc/Makefile      |   1 +
 drivers/iio/adc/imx8qxp-adc.c | 494 ++++++++++++++++++++++++++++++++++
 3 files changed, 505 insertions(+)
 create mode 100644 drivers/iio/adc/imx8qxp-adc.c
drivers/iio/adc/Kconfig +10 -0
index af168e1c9fdb..fa8ad63d6ac2 100644
@@ -530,6 +530,16 @@ config IMX7D_ADC
 	  This driver can also be built as a module. If so, the module will be
 	  called imx7d_adc.
 
+config IMX8QXP_ADC
+	tristate "NXP IMX8QXP ADC driver"
+	depends on ARCH_MXC_ARM64 || COMPILE_TEST
+	depends on HAS_IOMEM
+	help
+	  Say yes here to build support for IMX8QXP ADC.
+
+	  This driver can also be built as a module. If so, the module will be
+	  called imx8qxp-adc.
+
 config LP8788_ADC
 	tristate "LP8788 ADC driver"
 	depends on MFD_LP8788
drivers/iio/adc/Makefile +1 -0
index d68550f493e3..d3f53549720c 100644
@@ -46,6 +46,7 @@ obj-$(CONFIG_FSL_MX25_ADC) += fsl-imx25-gcq.o
 obj-$(CONFIG_HI8435) += hi8435.o
 obj-$(CONFIG_HX711) += hx711.o
 obj-$(CONFIG_IMX7D_ADC) += imx7d_adc.o
+obj-$(CONFIG_IMX8QXP_ADC) += imx8qxp-adc.o
 obj-$(CONFIG_INA2XX_ADC) += ina2xx-adc.o
 obj-$(CONFIG_INGENIC_ADC) += ingenic-adc.o
 obj-$(CONFIG_INTEL_MRFLD_ADC) += intel_mrfld_adc.o
drivers/iio/adc/imx8qxp-adc.c new file +494 -0

494 lines not on this page · raw message

Signature · 1 line
2.25.1
reviewer
#2 lore raw

Hi Cai,

drivers/iio/adc/imx8qxp-adc.c line 392

Quoted 6 lines · Cai Huoqing
drivers/iio/adc/imx8qxp-adc.c new file +6 -0
+error_iio_device_register:
+       clk_disable_unprepare(adc->ipg_clk);
+error_adc_ipg_clk_enable:
+       clk_disable_unprepare(adc->clk);
+error_adc_clk_enable:
+       regulator_disable(adc->vref);

Please rename these labels to indicate the action that will be performed.

Something like this:

error_ipg_clk_disable:

       clk_disable_unprepare(adc->ipg_clk);
error_adc_clk_disable:
       clk_disable_unprepare(adc->clk);
error_regulator_disable:
       regulator_disable(adc->vref);
#3 lore raw

PATCH v5 2/3 iio: imx8qxp-adc: dt-bindings: iio: adc: Add binding documentation for NXP IMX8QXP ADC

In reply to Cai Huoqing

The NXP i.MX 8QuadXPlus SOC a new ADC IP, so add
binding documentation for NXP IMX8QXP ADC.

---
v1->v2:
*Fix some indentation issues.
*Mark status as okay.
*Change clock2 source.
v3->v4:
*Remove 'status' from examples. *Remove unused 'state'.
*Remove interrupts-parent.
*Change num of address/size-cells from 1 to 2.
v4->v5:
*Remove unused properties
v1 link:
https://patchwork.kernel.org/project/linux-arm-kernel/patch/[email protected]/
v3 link:
https://patchwork.kernel.org/project/linux-arm-kernel/patch/[email protected]/
v4 link:
https://patchwork.kernel.org/project/linux-arm-kernel/patch/[email protected]/

 .../bindings/iio/adc/nxp,imx8qxp-adc.yaml     | 78 +++++++++++++++++++
 1 file changed, 78 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/adc/nxp,imx8qxp-adc.yaml
Documentation/devicetree/bindings/iio/adc/nxp,imx8qxp-adc.yaml new file +78 -0
new file mode 100644
index 000000000000..9c59a20a6032
@@ -0,0 +1,78 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/adc/nxp,imx8qxp-adc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: NXP IMX8QXP ADC bindings
+
+maintainers:
+  - Cai Huoqing <[email protected]>
+
+description:
+  Supports the ADC found on the IMX8QXP SoC.
+
+properties:
+  compatible:
+    const: nxp,imx8qxp-adc
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    maxItems: 2
+
+  clock-names:
+    items:
+      - const: per
+      - const: ipg
+
+  assigned-clocks:
+    maxItems: 1
+
+  assigned-clock-rates:
+    maxItems: 1
+
+  power-domains:
+    maxItems: 1
+
+  "#io-channel-cells":
+    const: 1
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - clock-names
+  - assigned-clocks
+  - assigned-clock-rates
+  - power-domains
+  - "#io-channel-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/firmware/imx/rsrc.h>
+    soc {
+        #address-cells = <2>;
+        #size-cells = <2>;
+        adc@5a880000 {
+            compatible = "nxp,imx8qxp-adc";
+            reg = <0x0 0x5a880000 0x0 0x10000>;
+            interrupts = <GIC_SPI 240 IRQ_TYPE_LEVEL_HIGH>;
+            clocks = <&clk IMX_SC_R_ADC_0>,
+                     <&clk IMX_SC_R_ADC_0>;
+            clock-names = "per", "ipg";
+            assigned-clocks = <&clk IMX_SC_R_ADC_0>;
+            assigned-clock-rates = <24000000>;
+            power-domains = <&pd IMX_SC_R_ADC_0>;
+            #io-channel-cells = <1>;
+        };
+    };
+...
Signature · 1 line
2.25.1
maintainer Reviewed-by on v5 2/3
#4 lore raw

Re: [PATCH v5 2/3] iio: imx8qxp-adc: dt-bindings: iio: adc: Add binding documentation for NXP IMX8QXP ADC

Quoted 23 lines · Cai Huoqing

The NXP i.MX 8QuadXPlus SOC a new ADC IP, so add
binding documentation for NXP IMX8QXP ADC.

---
v1->v2:
*Fix some indentation issues.
*Mark status as okay.
*Change clock2 source.
v3->v4:
*Remove 'status' from examples. *Remove unused 'state'.
*Remove interrupts-parent.
*Change num of address/size-cells from 1 to 2.
v4->v5:
*Remove unused properties
v1 link:
https://patchwork.kernel.org/project/linux-arm-kernel/patch/[email protected]/
v3 link:
https://patchwork.kernel.org/project/linux-arm-kernel/patch/[email protected]/
v4 link:
https://patchwork.kernel.org/project/linux-arm-kernel/patch/[email protected]/

Quoted 4 lines
 .../bindings/iio/adc/nxp,imx8qxp-adc.yaml     | 78 +++++++++++++++++++
 1 file changed, 78 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/adc/nxp,imx8qxp-adc.yaml
#5 lore raw

PATCH v5 3/3 MAINTAINERS: Add the driver info of the NXP IMX8QXP

In reply to Cai Huoqing

The NXP i.MX 8QuadXPlus SOC has a new ADC IP. After adding the driver support for it, I add the driver info of the NXP IMX8QXP ADC to MAINTAINERS file.

---
 MAINTAINERS | 7 +++++++
 1 file changed, 7 insertions(+)
MAINTAINERS +7 -0
index 15a5fd8323f7..271fe42a1211 100644
@@ -13489,6 +13489,13 @@ S:	Maintained
 F:	Documentation/devicetree/bindings/display/imx/nxp,imx8mq-dcss.yaml
 F:	drivers/gpu/drm/imx/dcss/
 
+NXP i.MX 8QXP ADC DRIVER
+M:	Cai Huoqing <[email protected]>
+L:	[email protected]
+S:	Supported
+F:	Documentation/devicetree/bindings/iio/adc/nxp,imx8qxp-adc.yaml
+F:	drivers/iio/adc/imx8qxp-adc.c
+
 NXP PF8100/PF8121A/PF8200 PMIC REGULATOR DEVICE DRIVER
 M:	Jagan Teki <[email protected]>
 S:	Maintained
Signature · 1 line
2.25.1