From 0ff022dc3b2674f575bcf30a2a988002845eb698 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ond=C5=99ej=20Jirman?= <megi@xff.cz>
Date: Mon, 7 Oct 2019 02:12:34 +0200
Subject: iio: adc: sun4i-gpadc-iio: Allow to use sun5i-a13-gpadc-iio from DT

We can now use allwinner,sun5i-a13-gpadc-iio to create a sub-node of
allwinner,sun5i-a13-ts, that can be referenced by other drivers
via IIO framework.

Signed-off-by: Ondrej Jirman <megi@xff.cz>
---
 arch/arm/boot/dts/allwinner/sun5i.dtsi | 5 +++++
 drivers/iio/adc/sun4i-gpadc-iio.c      | 3 ++-
 drivers/mfd/sun4i-gpadc.c              | 1 +
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/allwinner/sun5i.dtsi b/arch/arm/boot/dts/allwinner/sun5i.dtsi
index d7c7b454a11a..e6836fd4b8dc 100644
--- a/arch/arm/boot/dts/allwinner/sun5i.dtsi
+++ b/arch/arm/boot/dts/allwinner/sun5i.dtsi
@@ -657,6 +657,11 @@ rtp: rtp@1c25000 {
 			reg = <0x01c25000 0x100>;
 			interrupts = <29>;
 			#thermal-sensor-cells = <0>;
+
+			rtp_adc: adc {
+				compatible = "allwinner,sun5i-a13-gpadc-iio";
+				#io-channel-cells = <1>;
+			};
 		};
 
 		uart0: serial@1c28000 {
diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c
index 8b27458dcd66..3c673c35629f 100644
--- a/drivers/iio/adc/sun4i-gpadc-iio.c
+++ b/drivers/iio/adc/sun4i-gpadc-iio.c
@@ -618,7 +618,8 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
 	indio_dev->info = &sun4i_gpadc_iio_info;
 	indio_dev->modes = INDIO_DIRECT_MODE;
 
-	if (pdev->dev.of_node)
+	if (pdev->dev.of_node && of_match_node(sun4i_gpadc_of_id,
+					       pdev->dev.of_node))
 		ret = sun4i_gpadc_probe_dt(pdev, indio_dev);
 	else
 		ret = sun4i_gpadc_probe_mfd(pdev, indio_dev);
diff --git a/drivers/mfd/sun4i-gpadc.c b/drivers/mfd/sun4i-gpadc.c
index 3029d48e982c..51da961cffd5 100644
--- a/drivers/mfd/sun4i-gpadc.c
+++ b/drivers/mfd/sun4i-gpadc.c
@@ -53,6 +53,7 @@ static struct mfd_cell sun4i_gpadc_cells[] = {
 static struct mfd_cell sun5i_gpadc_cells[] = {
 	{
 		.name	= "sun5i-a13-gpadc-iio",
+		.of_compatible	= "allwinner,sun5i-a13-gpadc-iio",
 		.resources = adc_resources,
 		.num_resources = ARRAY_SIZE(adc_resources),
 	},
-- 
2.35.3

