All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/11] add thermal throttling to Allwinner A33 SoC
@ 2017-03-10 10:39 ` Quentin Schulz
  0 siblings, 0 replies; 85+ messages in thread
From: Quentin Schulz @ 2017-03-10 10:39 UTC (permalink / raw)
  To: dmitry.torokhov, robh+dt, mark.rutland, maxime.ripard, wens,
	lee.jones, linux, jic23, knaack.h, lars, pmeerw,
	stefan.mavrodiev
  Cc: Quentin Schulz, devicetree, linux-arm-kernel, linux-kernel,
	linux-iio, linux-sunxi, thomas.petazzoni

The Allwinner SoCs all have an ADC that can also act as a touchscreen
controller and a thermal sensor. The first four channels can be used
either for the ADC or the touchscreen and the fifth channel is used for
the thermal sensor. We currently have a driver for the two latter
functions in drivers/input/touchscreen/sun4i-ts.c but we don't have
access to the ADC feature at all. It is meant to replace the current
driver by using MFD and subdrivers for existing bindings.

The Allwinner A33 only has a thermal sensor present in the GPADC. In
addition, there is not an existing DT binding for the GPADC. Thus, we do
not need the sun4i-gpadc MFD driver which was made to keep DT compatibility
and probe subdrivers without the need to add DT subnodes.

This series of patch adds the thermal sensor for the A33 and GPU/CPU
thermal throttling. It also adds the cpu-supply property to the CPU node
needed by the Sinlinx SinA33 and Olinuxino A33 to adapt their CPU regulator
voltage depending on the currently used OPP. The other A33 boards all have
their cpu-supply property set.

This series also fixes the missing operating-points-v2 property in cpu DT
nodes. Finally, it also adds all remaining OPPs which can be found in
Allwinner 3.4 linux and fex files of all A33 boards.

This patch *HAS NOT* been tested on the Olinuxino A33.
 @Stefan (or anyone owning an Olinuxino A33), could you test this patch
 series on your board, test CPUfreq and tell us if it works in a stable
 manner? Thanks!

This series of patch is based on this[1] series of patch.

[1] https://lkml.org/lkml/2016/12/13/298 : "[PATCH v9] add support for Allwinner
SoCs ADC"

Thanks,
Quentin

Maxime Ripard (1):
  ARM: sun8i: a33: Add devfreq-based GPU cooling

Quentin Schulz (10):
  ARM: sun8i: a33: add operating-points-v2 property to all nodes
  ARM: sun8i: a33: add all operating points
  ARM: dts: sun8i: sina33: add cpu-supply
  ARM: dts: sun8i: olinuxino: add cpu-supply
  Documentation: DT: bindings: mfd: add A33 GPADC binding
  Documentation: DT: bindings: input: touschcreen: remove sun4i
    documentation
  iio: adc: sun4i-gpadc-iio: move code used in MFD probing to new
    function
  iio: adc: sun4i-gpadc-iio: add support for A33 thermal sensor
  ARM: dtsi: sun8i: a33: add thermal sensor
  ARM: dtsi: sun8i: a33: add CPU thermal throttling

 .../touchscreen/sun4i.txt => mfd/sun4i-gpadc.txt}  |  21 +++
 arch/arm/boot/dts/sun8i-a23-a33.dtsi               |   3 +
 arch/arm/boot/dts/sun8i-a33-olinuxino.dts          |   4 +
 arch/arm/boot/dts/sun8i-a33-sinlinx-sina33.dts     |   4 +
 arch/arm/boot/dts/sun8i-a33.dtsi                   | 149 ++++++++++++++++++
 drivers/iio/adc/Kconfig                            |   2 +-
 drivers/iio/adc/sun4i-gpadc-iio.c                  | 170 +++++++++++++++++----
 include/linux/mfd/sun4i-gpadc.h                    |   4 +
 8 files changed, 324 insertions(+), 33 deletions(-)
 rename Documentation/devicetree/bindings/{input/touchscreen/sun4i.txt => mfd/sun4i-gpadc.txt} (64%)

-- 
2.9.3

^ permalink raw reply	[flat|nested] 85+ messages in thread

* [PATCH v2 00/11] add thermal throttling to Allwinner A33 SoC
@ 2017-03-10 10:39 ` Quentin Schulz
  0 siblings, 0 replies; 85+ messages in thread
From: Quentin Schulz @ 2017-03-10 10:39 UTC (permalink / raw)
  To: dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8, wens-jdAy2FN1RRM,
	lee.jones-QSEj5FYQhm4dnm+yROfE0A, linux-I+IVW8TIWO2tmTQ+vhA3Yw,
	jic23-DgEjT+Ai2ygdnm+yROfE0A, knaack.h-Mmb7MZpHnFY,
	lars-Qo5EllUWu/uELgA04lAiVw, pmeerw-jW+XmwGofnusTnJN9+BGXg,
	stefan.mavrodiev-Re5JQEeQqe8AvxtiuMwx3w
  Cc: Quentin Schulz, devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-iio-u79uwXL29TY76Z2rM5mHXA,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
	thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8

The Allwinner SoCs all have an ADC that can also act as a touchscreen
controller and a thermal sensor. The first four channels can be used
either for the ADC or the touchscreen and the fifth channel is used for
the thermal sensor. We currently have a driver for the two latter
functions in drivers/input/touchscreen/sun4i-ts.c but we don't have
access to the ADC feature at all. It is meant to replace the current
driver by using MFD and subdrivers for existing bindings.

The Allwinner A33 only has a thermal sensor present in the GPADC. In
addition, there is not an existing DT binding for the GPADC. Thus, we do
not need the sun4i-gpadc MFD driver which was made to keep DT compatibility
and probe subdrivers without the need to add DT subnodes.

This series of patch adds the thermal sensor for the A33 and GPU/CPU
thermal throttling. It also adds the cpu-supply property to the CPU node
needed by the Sinlinx SinA33 and Olinuxino A33 to adapt their CPU regulator
voltage depending on the currently used OPP. The other A33 boards all have
their cpu-supply property set.

This series also fixes the missing operating-points-v2 property in cpu DT
nodes. Finally, it also adds all remaining OPPs which can be found in
Allwinner 3.4 linux and fex files of all A33 boards.

This patch *HAS NOT* been tested on the Olinuxino A33.
 @Stefan (or anyone owning an Olinuxino A33), could you test this patch
 series on your board, test CPUfreq and tell us if it works in a stable
 manner? Thanks!

This series of patch is based on this[1] series of patch.

[1] https://lkml.org/lkml/2016/12/13/298 : "[PATCH v9] add support for Allwinner
SoCs ADC"

Thanks,
Quentin

Maxime Ripard (1):
  ARM: sun8i: a33: Add devfreq-based GPU cooling

Quentin Schulz (10):
  ARM: sun8i: a33: add operating-points-v2 property to all nodes
  ARM: sun8i: a33: add all operating points
  ARM: dts: sun8i: sina33: add cpu-supply
  ARM: dts: sun8i: olinuxino: add cpu-supply
  Documentation: DT: bindings: mfd: add A33 GPADC binding
  Documentation: DT: bindings: input: touschcreen: remove sun4i
    documentation
  iio: adc: sun4i-gpadc-iio: move code used in MFD probing to new
    function
  iio: adc: sun4i-gpadc-iio: add support for A33 thermal sensor
  ARM: dtsi: sun8i: a33: add thermal sensor
  ARM: dtsi: sun8i: a33: add CPU thermal throttling

 .../touchscreen/sun4i.txt => mfd/sun4i-gpadc.txt}  |  21 +++
 arch/arm/boot/dts/sun8i-a23-a33.dtsi               |   3 +
 arch/arm/boot/dts/sun8i-a33-olinuxino.dts          |   4 +
 arch/arm/boot/dts/sun8i-a33-sinlinx-sina33.dts     |   4 +
 arch/arm/boot/dts/sun8i-a33.dtsi                   | 149 ++++++++++++++++++
 drivers/iio/adc/Kconfig                            |   2 +-
 drivers/iio/adc/sun4i-gpadc-iio.c                  | 170 +++++++++++++++++----
 include/linux/mfd/sun4i-gpadc.h                    |   4 +
 8 files changed, 324 insertions(+), 33 deletions(-)
 rename Documentation/devicetree/bindings/{input/touchscreen/sun4i.txt => mfd/sun4i-gpadc.txt} (64%)

-- 
2.9.3

^ permalink raw reply	[flat|nested] 85+ messages in thread

* [PATCH v2 00/11] add thermal throttling to Allwinner A33 SoC
@ 2017-03-10 10:39 ` Quentin Schulz
  0 siblings, 0 replies; 85+ messages in thread
From: Quentin Schulz @ 2017-03-10 10:39 UTC (permalink / raw)
  To: linux-arm-kernel

The Allwinner SoCs all have an ADC that can also act as a touchscreen
controller and a thermal sensor. The first four channels can be used
either for the ADC or the touchscreen and the fifth channel is used for
the thermal sensor. We currently have a driver for the two latter
functions in drivers/input/touchscreen/sun4i-ts.c but we don't have
access to the ADC feature at all. It is meant to replace the current
driver by using MFD and subdrivers for existing bindings.

The Allwinner A33 only has a thermal sensor present in the GPADC. In
addition, there is not an existing DT binding for the GPADC. Thus, we do
not need the sun4i-gpadc MFD driver which was made to keep DT compatibility
and probe subdrivers without the need to add DT subnodes.

This series of patch adds the thermal sensor for the A33 and GPU/CPU
thermal throttling. It also adds the cpu-supply property to the CPU node
needed by the Sinlinx SinA33 and Olinuxino A33 to adapt their CPU regulator
voltage depending on the currently used OPP. The other A33 boards all have
their cpu-supply property set.

This series also fixes the missing operating-points-v2 property in cpu DT
nodes. Finally, it also adds all remaining OPPs which can be found in
Allwinner 3.4 linux and fex files of all A33 boards.

This patch *HAS NOT* been tested on the Olinuxino A33.
 @Stefan (or anyone owning an Olinuxino A33), could you test this patch
 series on your board, test CPUfreq and tell us if it works in a stable
 manner? Thanks!

This series of patch is based on this[1] series of patch.

[1] https://lkml.org/lkml/2016/12/13/298 : "[PATCH v9] add support for Allwinner
SoCs ADC"

Thanks,
Quentin

Maxime Ripard (1):
  ARM: sun8i: a33: Add devfreq-based GPU cooling

Quentin Schulz (10):
  ARM: sun8i: a33: add operating-points-v2 property to all nodes
  ARM: sun8i: a33: add all operating points
  ARM: dts: sun8i: sina33: add cpu-supply
  ARM: dts: sun8i: olinuxino: add cpu-supply
  Documentation: DT: bindings: mfd: add A33 GPADC binding
  Documentation: DT: bindings: input: touschcreen: remove sun4i
    documentation
  iio: adc: sun4i-gpadc-iio: move code used in MFD probing to new
    function
  iio: adc: sun4i-gpadc-iio: add support for A33 thermal sensor
  ARM: dtsi: sun8i: a33: add thermal sensor
  ARM: dtsi: sun8i: a33: add CPU thermal throttling

 .../touchscreen/sun4i.txt => mfd/sun4i-gpadc.txt}  |  21 +++
 arch/arm/boot/dts/sun8i-a23-a33.dtsi               |   3 +
 arch/arm/boot/dts/sun8i-a33-olinuxino.dts          |   4 +
 arch/arm/boot/dts/sun8i-a33-sinlinx-sina33.dts     |   4 +
 arch/arm/boot/dts/sun8i-a33.dtsi                   | 149 ++++++++++++++++++
 drivers/iio/adc/Kconfig                            |   2 +-
 drivers/iio/adc/sun4i-gpadc-iio.c                  | 170 +++++++++++++++++----
 include/linux/mfd/sun4i-gpadc.h                    |   4 +
 8 files changed, 324 insertions(+), 33 deletions(-)
 rename Documentation/devicetree/bindings/{input/touchscreen/sun4i.txt => mfd/sun4i-gpadc.txt} (64%)

-- 
2.9.3

^ permalink raw reply	[flat|nested] 85+ messages in thread

* [PATCH v2 01/11] ARM: sun8i: a33: add operating-points-v2 property to all nodes
@ 2017-03-10 10:39   ` Quentin Schulz
  0 siblings, 0 replies; 85+ messages in thread
From: Quentin Schulz @ 2017-03-10 10:39 UTC (permalink / raw)
  To: dmitry.torokhov, robh+dt, mark.rutland, maxime.ripard, wens,
	lee.jones, linux, jic23, knaack.h, lars, pmeerw,
	stefan.mavrodiev
  Cc: Quentin Schulz, devicetree, linux-arm-kernel, linux-kernel,
	linux-iio, linux-sunxi, thomas.petazzoni

The OPP are declared as shared but no operating points are declared for
cpu1, 2 and 3. Thus, the following error happens during the boot:

cpu cpu1: dev_pm_opp_of_get_sharing_cpus: Couldn't find tcpu_dev node.

This patch applies the operating points to each cpu of the A33.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
---

added in v2

 arch/arm/boot/dts/sun8i-a33.dtsi | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/arch/arm/boot/dts/sun8i-a33.dtsi b/arch/arm/boot/dts/sun8i-a33.dtsi
index fb105a1..b86f0e7 100644
--- a/arch/arm/boot/dts/sun8i-a33.dtsi
+++ b/arch/arm/boot/dts/sun8i-a33.dtsi
@@ -81,16 +81,22 @@
 			operating-points-v2 = <&cpu0_opp_table>;
 		};
 
+		cpu@1 {
+			operating-points-v2 = <&cpu0_opp_table>;
+		};
+
 		cpu@2 {
 			compatible = "arm,cortex-a7";
 			device_type = "cpu";
 			reg = <2>;
+			operating-points-v2 = <&cpu0_opp_table>;
 		};
 
 		cpu@3 {
 			compatible = "arm,cortex-a7";
 			device_type = "cpu";
 			reg = <3>;
+			operating-points-v2 = <&cpu0_opp_table>;
 		};
 	};
 
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH v2 01/11] ARM: sun8i: a33: add operating-points-v2 property to all nodes
@ 2017-03-10 10:39   ` Quentin Schulz
  0 siblings, 0 replies; 85+ messages in thread
From: Quentin Schulz @ 2017-03-10 10:39 UTC (permalink / raw)
  To: dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8, wens-jdAy2FN1RRM,
	lee.jones-QSEj5FYQhm4dnm+yROfE0A, linux-I+IVW8TIWO2tmTQ+vhA3Yw,
	jic23-DgEjT+Ai2ygdnm+yROfE0A, knaack.h-Mmb7MZpHnFY,
	lars-Qo5EllUWu/uELgA04lAiVw, pmeerw-jW+XmwGofnusTnJN9+BGXg,
	stefan.mavrodiev-Re5JQEeQqe8AvxtiuMwx3w
  Cc: Quentin Schulz, devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-iio-u79uwXL29TY76Z2rM5mHXA,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
	thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8

The OPP are declared as shared but no operating points are declared for
cpu1, 2 and 3. Thus, the following error happens during the boot:

cpu cpu1: dev_pm_opp_of_get_sharing_cpus: Couldn't find tcpu_dev node.

This patch applies the operating points to each cpu of the A33.

Signed-off-by: Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
---

added in v2

 arch/arm/boot/dts/sun8i-a33.dtsi | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/arch/arm/boot/dts/sun8i-a33.dtsi b/arch/arm/boot/dts/sun8i-a33.dtsi
index fb105a1..b86f0e7 100644
--- a/arch/arm/boot/dts/sun8i-a33.dtsi
+++ b/arch/arm/boot/dts/sun8i-a33.dtsi
@@ -81,16 +81,22 @@
 			operating-points-v2 = <&cpu0_opp_table>;
 		};
 
+		cpu@1 {
+			operating-points-v2 = <&cpu0_opp_table>;
+		};
+
 		cpu@2 {
 			compatible = "arm,cortex-a7";
 			device_type = "cpu";
 			reg = <2>;
+			operating-points-v2 = <&cpu0_opp_table>;
 		};
 
 		cpu@3 {
 			compatible = "arm,cortex-a7";
 			device_type = "cpu";
 			reg = <3>;
+			operating-points-v2 = <&cpu0_opp_table>;
 		};
 	};
 
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH v2 01/11] ARM: sun8i: a33: add operating-points-v2 property to all nodes
@ 2017-03-10 10:39   ` Quentin Schulz
  0 siblings, 0 replies; 85+ messages in thread
From: Quentin Schulz @ 2017-03-10 10:39 UTC (permalink / raw)
  To: linux-arm-kernel

The OPP are declared as shared but no operating points are declared for
cpu1, 2 and 3. Thus, the following error happens during the boot:

cpu cpu1: dev_pm_opp_of_get_sharing_cpus: Couldn't find tcpu_dev node.

This patch applies the operating points to each cpu of the A33.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
---

added in v2

 arch/arm/boot/dts/sun8i-a33.dtsi | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/arch/arm/boot/dts/sun8i-a33.dtsi b/arch/arm/boot/dts/sun8i-a33.dtsi
index fb105a1..b86f0e7 100644
--- a/arch/arm/boot/dts/sun8i-a33.dtsi
+++ b/arch/arm/boot/dts/sun8i-a33.dtsi
@@ -81,16 +81,22 @@
 			operating-points-v2 = <&cpu0_opp_table>;
 		};
 
+		cpu at 1 {
+			operating-points-v2 = <&cpu0_opp_table>;
+		};
+
 		cpu at 2 {
 			compatible = "arm,cortex-a7";
 			device_type = "cpu";
 			reg = <2>;
+			operating-points-v2 = <&cpu0_opp_table>;
 		};
 
 		cpu at 3 {
 			compatible = "arm,cortex-a7";
 			device_type = "cpu";
 			reg = <3>;
+			operating-points-v2 = <&cpu0_opp_table>;
 		};
 	};
 
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH v2 02/11] ARM: sun8i: a33: add all operating points
@ 2017-03-10 10:39   ` Quentin Schulz
  0 siblings, 0 replies; 85+ messages in thread
From: Quentin Schulz @ 2017-03-10 10:39 UTC (permalink / raw)
  To: dmitry.torokhov, robh+dt, mark.rutland, maxime.ripard, wens,
	lee.jones, linux, jic23, knaack.h, lars, pmeerw,
	stefan.mavrodiev
  Cc: Quentin Schulz, devicetree, linux-arm-kernel, linux-kernel,
	linux-iio, linux-sunxi, thomas.petazzoni

This adds all operating points allowed for the A33 as defined by fex
files available at:
https://github.com/linux-sunxi/sunxi-boards/tree/master/sys_config/a33

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
---

added in v2

 arch/arm/boot/dts/sun8i-a33.dtsi | 60 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)

diff --git a/arch/arm/boot/dts/sun8i-a33.dtsi b/arch/arm/boot/dts/sun8i-a33.dtsi
index b86f0e7..ba87a9e 100644
--- a/arch/arm/boot/dts/sun8i-a33.dtsi
+++ b/arch/arm/boot/dts/sun8i-a33.dtsi
@@ -49,24 +49,84 @@
 		compatible = "operating-points-v2";
 		opp-shared;
 
+		opp@120000000 {
+			opp-hz = /bits/ 64 <120000000>;
+			opp-microvolt = <1040000>;
+			clock-latency-ns = <244144>; /* 8 32k periods */
+		};
+
+		opp@240000000 {
+			opp-hz = /bits/ 64 <240000000>;
+			opp-microvolt = <1040000>;
+			clock-latency-ns = <244144>; /* 8 32k periods */
+		};
+
+		opp@312000000 {
+			opp-hz = /bits/ 64 <312000000>;
+			opp-microvolt = <1040000>;
+			clock-latency-ns = <244144>; /* 8 32k periods */
+		};
+
+		opp@408000000 {
+			opp-hz = /bits/ 64 <408000000>;
+			opp-microvolt = <1040000>;
+			clock-latency-ns = <244144>; /* 8 32k periods */
+		};
+
+		opp@480000000 {
+			opp-hz = /bits/ 64 <480000000>;
+			opp-microvolt = <1040000>;
+			clock-latency-ns = <244144>; /* 8 32k periods */
+		};
+
+		opp@504000000 {
+			opp-hz = /bits/ 64 <504000000>;
+			opp-microvolt = <1040000>;
+			clock-latency-ns = <244144>; /* 8 32k periods */
+		};
+
+		opp@600000000 {
+			opp-hz = /bits/ 64 <600000000>;
+			opp-microvolt = <1040000>;
+			clock-latency-ns = <244144>; /* 8 32k periods */
+		};
+
 		opp@648000000 {
 			opp-hz = /bits/ 64 <648000000>;
 			opp-microvolt = <1040000>;
 			clock-latency-ns = <244144>; /* 8 32k periods */
 		};
 
+		opp@720000000 {
+			opp-hz = /bits/ 64 <720000000>;
+			opp-microvolt = <1100000>;
+			clock-latency-ns = <244144>; /* 8 32k periods */
+		};
+
 		opp@816000000 {
 			opp-hz = /bits/ 64 <816000000>;
 			opp-microvolt = <1100000>;
 			clock-latency-ns = <244144>; /* 8 32k periods */
 		};
 
+		opp@912000000 {
+			opp-hz = /bits/ 64 <912000000>;
+			opp-microvolt = <1200000>;
+			clock-latency-ns = <244144>; /* 8 32k periods */
+		};
+
 		opp@1008000000 {
 			opp-hz = /bits/ 64 <1008000000>;
 			opp-microvolt = <1200000>;
 			clock-latency-ns = <244144>; /* 8 32k periods */
 		};
 
+		opp@1104000000 {
+			opp-hz = /bits/ 64 <1104000000>;
+			opp-microvolt = <1320000>;
+			clock-latency-ns = <244144>; /* 8 32k periods */
+		};
+
 		opp@1200000000 {
 			opp-hz = /bits/ 64 <1200000000>;
 			opp-microvolt = <1320000>;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH v2 02/11] ARM: sun8i: a33: add all operating points
@ 2017-03-10 10:39   ` Quentin Schulz
  0 siblings, 0 replies; 85+ messages in thread
From: Quentin Schulz @ 2017-03-10 10:39 UTC (permalink / raw)
  To: dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8, wens-jdAy2FN1RRM,
	lee.jones-QSEj5FYQhm4dnm+yROfE0A, linux-I+IVW8TIWO2tmTQ+vhA3Yw,
	jic23-DgEjT+Ai2ygdnm+yROfE0A, knaack.h-Mmb7MZpHnFY,
	lars-Qo5EllUWu/uELgA04lAiVw, pmeerw-jW+XmwGofnusTnJN9+BGXg,
	stefan.mavrodiev-Re5JQEeQqe8AvxtiuMwx3w
  Cc: Quentin Schulz, devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-iio-u79uwXL29TY76Z2rM5mHXA,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
	thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8

This adds all operating points allowed for the A33 as defined by fex
files available at:
https://github.com/linux-sunxi/sunxi-boards/tree/master/sys_config/a33

Signed-off-by: Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
---

added in v2

 arch/arm/boot/dts/sun8i-a33.dtsi | 60 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)

diff --git a/arch/arm/boot/dts/sun8i-a33.dtsi b/arch/arm/boot/dts/sun8i-a33.dtsi
index b86f0e7..ba87a9e 100644
--- a/arch/arm/boot/dts/sun8i-a33.dtsi
+++ b/arch/arm/boot/dts/sun8i-a33.dtsi
@@ -49,24 +49,84 @@
 		compatible = "operating-points-v2";
 		opp-shared;
 
+		opp@120000000 {
+			opp-hz = /bits/ 64 <120000000>;
+			opp-microvolt = <1040000>;
+			clock-latency-ns = <244144>; /* 8 32k periods */
+		};
+
+		opp@240000000 {
+			opp-hz = /bits/ 64 <240000000>;
+			opp-microvolt = <1040000>;
+			clock-latency-ns = <244144>; /* 8 32k periods */
+		};
+
+		opp@312000000 {
+			opp-hz = /bits/ 64 <312000000>;
+			opp-microvolt = <1040000>;
+			clock-latency-ns = <244144>; /* 8 32k periods */
+		};
+
+		opp@408000000 {
+			opp-hz = /bits/ 64 <408000000>;
+			opp-microvolt = <1040000>;
+			clock-latency-ns = <244144>; /* 8 32k periods */
+		};
+
+		opp@480000000 {
+			opp-hz = /bits/ 64 <480000000>;
+			opp-microvolt = <1040000>;
+			clock-latency-ns = <244144>; /* 8 32k periods */
+		};
+
+		opp@504000000 {
+			opp-hz = /bits/ 64 <504000000>;
+			opp-microvolt = <1040000>;
+			clock-latency-ns = <244144>; /* 8 32k periods */
+		};
+
+		opp@600000000 {
+			opp-hz = /bits/ 64 <600000000>;
+			opp-microvolt = <1040000>;
+			clock-latency-ns = <244144>; /* 8 32k periods */
+		};
+
 		opp@648000000 {
 			opp-hz = /bits/ 64 <648000000>;
 			opp-microvolt = <1040000>;
 			clock-latency-ns = <244144>; /* 8 32k periods */
 		};
 
+		opp@720000000 {
+			opp-hz = /bits/ 64 <720000000>;
+			opp-microvolt = <1100000>;
+			clock-latency-ns = <244144>; /* 8 32k periods */
+		};
+
 		opp@816000000 {
 			opp-hz = /bits/ 64 <816000000>;
 			opp-microvolt = <1100000>;
 			clock-latency-ns = <244144>; /* 8 32k periods */
 		};
 
+		opp@912000000 {
+			opp-hz = /bits/ 64 <912000000>;
+			opp-microvolt = <1200000>;
+			clock-latency-ns = <244144>; /* 8 32k periods */
+		};
+
 		opp@1008000000 {
 			opp-hz = /bits/ 64 <1008000000>;
 			opp-microvolt = <1200000>;
 			clock-latency-ns = <244144>; /* 8 32k periods */
 		};
 
+		opp@1104000000 {
+			opp-hz = /bits/ 64 <1104000000>;
+			opp-microvolt = <1320000>;
+			clock-latency-ns = <244144>; /* 8 32k periods */
+		};
+
 		opp@1200000000 {
 			opp-hz = /bits/ 64 <1200000000>;
 			opp-microvolt = <1320000>;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH v2 02/11] ARM: sun8i: a33: add all operating points
@ 2017-03-10 10:39   ` Quentin Schulz
  0 siblings, 0 replies; 85+ messages in thread
From: Quentin Schulz @ 2017-03-10 10:39 UTC (permalink / raw)
  To: linux-arm-kernel

This adds all operating points allowed for the A33 as defined by fex
files available at:
https://github.com/linux-sunxi/sunxi-boards/tree/master/sys_config/a33

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
---

added in v2

 arch/arm/boot/dts/sun8i-a33.dtsi | 60 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)

diff --git a/arch/arm/boot/dts/sun8i-a33.dtsi b/arch/arm/boot/dts/sun8i-a33.dtsi
index b86f0e7..ba87a9e 100644
--- a/arch/arm/boot/dts/sun8i-a33.dtsi
+++ b/arch/arm/boot/dts/sun8i-a33.dtsi
@@ -49,24 +49,84 @@
 		compatible = "operating-points-v2";
 		opp-shared;
 
+		opp at 120000000 {
+			opp-hz = /bits/ 64 <120000000>;
+			opp-microvolt = <1040000>;
+			clock-latency-ns = <244144>; /* 8 32k periods */
+		};
+
+		opp at 240000000 {
+			opp-hz = /bits/ 64 <240000000>;
+			opp-microvolt = <1040000>;
+			clock-latency-ns = <244144>; /* 8 32k periods */
+		};
+
+		opp at 312000000 {
+			opp-hz = /bits/ 64 <312000000>;
+			opp-microvolt = <1040000>;
+			clock-latency-ns = <244144>; /* 8 32k periods */
+		};
+
+		opp at 408000000 {
+			opp-hz = /bits/ 64 <408000000>;
+			opp-microvolt = <1040000>;
+			clock-latency-ns = <244144>; /* 8 32k periods */
+		};
+
+		opp at 480000000 {
+			opp-hz = /bits/ 64 <480000000>;
+			opp-microvolt = <1040000>;
+			clock-latency-ns = <244144>; /* 8 32k periods */
+		};
+
+		opp at 504000000 {
+			opp-hz = /bits/ 64 <504000000>;
+			opp-microvolt = <1040000>;
+			clock-latency-ns = <244144>; /* 8 32k periods */
+		};
+
+		opp at 600000000 {
+			opp-hz = /bits/ 64 <600000000>;
+			opp-microvolt = <1040000>;
+			clock-latency-ns = <244144>; /* 8 32k periods */
+		};
+
 		opp at 648000000 {
 			opp-hz = /bits/ 64 <648000000>;
 			opp-microvolt = <1040000>;
 			clock-latency-ns = <244144>; /* 8 32k periods */
 		};
 
+		opp at 720000000 {
+			opp-hz = /bits/ 64 <720000000>;
+			opp-microvolt = <1100000>;
+			clock-latency-ns = <244144>; /* 8 32k periods */
+		};
+
 		opp at 816000000 {
 			opp-hz = /bits/ 64 <816000000>;
 			opp-microvolt = <1100000>;
 			clock-latency-ns = <244144>; /* 8 32k periods */
 		};
 
+		opp at 912000000 {
+			opp-hz = /bits/ 64 <912000000>;
+			opp-microvolt = <1200000>;
+			clock-latency-ns = <244144>; /* 8 32k periods */
+		};
+
 		opp at 1008000000 {
 			opp-hz = /bits/ 64 <1008000000>;
 			opp-microvolt = <1200000>;
 			clock-latency-ns = <244144>; /* 8 32k periods */
 		};
 
+		opp at 1104000000 {
+			opp-hz = /bits/ 64 <1104000000>;
+			opp-microvolt = <1320000>;
+			clock-latency-ns = <244144>; /* 8 32k periods */
+		};
+
 		opp at 1200000000 {
 			opp-hz = /bits/ 64 <1200000000>;
 			opp-microvolt = <1320000>;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH v2 03/11] ARM: dts: sun8i: sina33: add cpu-supply
@ 2017-03-10 10:39   ` Quentin Schulz
  0 siblings, 0 replies; 85+ messages in thread
From: Quentin Schulz @ 2017-03-10 10:39 UTC (permalink / raw)
  To: dmitry.torokhov, robh+dt, mark.rutland, maxime.ripard, wens,
	lee.jones, linux, jic23, knaack.h, lars, pmeerw,
	stefan.mavrodiev
  Cc: Quentin Schulz, devicetree, linux-arm-kernel, linux-kernel,
	linux-iio, linux-sunxi, thomas.petazzoni

This adds the cpu-supply DT property to the cpu0 DT node needed by
the board to adapt the regulator voltage depending on the currently used
OPP.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
---
 arch/arm/boot/dts/sun8i-a33-sinlinx-sina33.dts | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/boot/dts/sun8i-a33-sinlinx-sina33.dts b/arch/arm/boot/dts/sun8i-a33-sinlinx-sina33.dts
index cde14b3..0c76aea 100644
--- a/arch/arm/boot/dts/sun8i-a33-sinlinx-sina33.dts
+++ b/arch/arm/boot/dts/sun8i-a33-sinlinx-sina33.dts
@@ -91,6 +91,10 @@
 	status = "okay";
 };
 
+&cpu0 {
+	cpu-supply = <&reg_dcdc3>;
+};
+
 &ehci0 {
 	status = "okay";
 };
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH v2 03/11] ARM: dts: sun8i: sina33: add cpu-supply
@ 2017-03-10 10:39   ` Quentin Schulz
  0 siblings, 0 replies; 85+ messages in thread
From: Quentin Schulz @ 2017-03-10 10:39 UTC (permalink / raw)
  To: dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8, wens-jdAy2FN1RRM,
	lee.jones-QSEj5FYQhm4dnm+yROfE0A, linux-I+IVW8TIWO2tmTQ+vhA3Yw,
	jic23-DgEjT+Ai2ygdnm+yROfE0A, knaack.h-Mmb7MZpHnFY,
	lars-Qo5EllUWu/uELgA04lAiVw, pmeerw-jW+XmwGofnusTnJN9+BGXg,
	stefan.mavrodiev-Re5JQEeQqe8AvxtiuMwx3w
  Cc: Quentin Schulz, devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-iio-u79uwXL29TY76Z2rM5mHXA,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
	thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8

This adds the cpu-supply DT property to the cpu0 DT node needed by
the board to adapt the regulator voltage depending on the currently used
OPP.

Signed-off-by: Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
---
 arch/arm/boot/dts/sun8i-a33-sinlinx-sina33.dts | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/boot/dts/sun8i-a33-sinlinx-sina33.dts b/arch/arm/boot/dts/sun8i-a33-sinlinx-sina33.dts
index cde14b3..0c76aea 100644
--- a/arch/arm/boot/dts/sun8i-a33-sinlinx-sina33.dts
+++ b/arch/arm/boot/dts/sun8i-a33-sinlinx-sina33.dts
@@ -91,6 +91,10 @@
 	status = "okay";
 };
 
+&cpu0 {
+	cpu-supply = <&reg_dcdc3>;
+};
+
 &ehci0 {
 	status = "okay";
 };
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH v2 03/11] ARM: dts: sun8i: sina33: add cpu-supply
@ 2017-03-10 10:39   ` Quentin Schulz
  0 siblings, 0 replies; 85+ messages in thread
From: Quentin Schulz @ 2017-03-10 10:39 UTC (permalink / raw)
  To: linux-arm-kernel

This adds the cpu-supply DT property to the cpu0 DT node needed by
the board to adapt the regulator voltage depending on the currently used
OPP.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
---
 arch/arm/boot/dts/sun8i-a33-sinlinx-sina33.dts | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/boot/dts/sun8i-a33-sinlinx-sina33.dts b/arch/arm/boot/dts/sun8i-a33-sinlinx-sina33.dts
index cde14b3..0c76aea 100644
--- a/arch/arm/boot/dts/sun8i-a33-sinlinx-sina33.dts
+++ b/arch/arm/boot/dts/sun8i-a33-sinlinx-sina33.dts
@@ -91,6 +91,10 @@
 	status = "okay";
 };
 
+&cpu0 {
+	cpu-supply = <&reg_dcdc3>;
+};
+
 &ehci0 {
 	status = "okay";
 };
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH v2 04/11] ARM: dts: sun8i: olinuxino: add cpu-supply
@ 2017-03-10 10:39   ` Quentin Schulz
  0 siblings, 0 replies; 85+ messages in thread
From: Quentin Schulz @ 2017-03-10 10:39 UTC (permalink / raw)
  To: dmitry.torokhov, robh+dt, mark.rutland, maxime.ripard, wens,
	lee.jones, linux, jic23, knaack.h, lars, pmeerw,
	stefan.mavrodiev
  Cc: Quentin Schulz, devicetree, linux-arm-kernel, linux-kernel,
	linux-iio, linux-sunxi, thomas.petazzoni

This adds the cpu-supply DT property to the cpu0 DT node needed by
the board to adapt the regulator voltage depending on the currently use
OPP.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
---
 arch/arm/boot/dts/sun8i-a33-olinuxino.dts | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/boot/dts/sun8i-a33-olinuxino.dts b/arch/arm/boot/dts/sun8i-a33-olinuxino.dts
index be9a6b8..9d25e90 100644
--- a/arch/arm/boot/dts/sun8i-a33-olinuxino.dts
+++ b/arch/arm/boot/dts/sun8i-a33-olinuxino.dts
@@ -72,6 +72,10 @@
 	};
 };
 
+&cpu0 {
+	cpu-supply = <&reg_dcdc3>;
+};
+
 &ehci0 {
 	status = "okay";
 };
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH v2 04/11] ARM: dts: sun8i: olinuxino: add cpu-supply
@ 2017-03-10 10:39   ` Quentin Schulz
  0 siblings, 0 replies; 85+ messages in thread
From: Quentin Schulz @ 2017-03-10 10:39 UTC (permalink / raw)
  To: dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8, wens-jdAy2FN1RRM,
	lee.jones-QSEj5FYQhm4dnm+yROfE0A, linux-I+IVW8TIWO2tmTQ+vhA3Yw,
	jic23-DgEjT+Ai2ygdnm+yROfE0A, knaack.h-Mmb7MZpHnFY,
	lars-Qo5EllUWu/uELgA04lAiVw, pmeerw-jW+XmwGofnusTnJN9+BGXg,
	stefan.mavrodiev-Re5JQEeQqe8AvxtiuMwx3w
  Cc: Quentin Schulz, devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-iio-u79uwXL29TY76Z2rM5mHXA,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
	thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8

This adds the cpu-supply DT property to the cpu0 DT node needed by
the board to adapt the regulator voltage depending on the currently use
OPP.

Signed-off-by: Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
---
 arch/arm/boot/dts/sun8i-a33-olinuxino.dts | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/boot/dts/sun8i-a33-olinuxino.dts b/arch/arm/boot/dts/sun8i-a33-olinuxino.dts
index be9a6b8..9d25e90 100644
--- a/arch/arm/boot/dts/sun8i-a33-olinuxino.dts
+++ b/arch/arm/boot/dts/sun8i-a33-olinuxino.dts
@@ -72,6 +72,10 @@
 	};
 };
 
+&cpu0 {
+	cpu-supply = <&reg_dcdc3>;
+};
+
 &ehci0 {
 	status = "okay";
 };
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH v2 04/11] ARM: dts: sun8i: olinuxino: add cpu-supply
@ 2017-03-10 10:39   ` Quentin Schulz
  0 siblings, 0 replies; 85+ messages in thread
From: Quentin Schulz @ 2017-03-10 10:39 UTC (permalink / raw)
  To: linux-arm-kernel

This adds the cpu-supply DT property to the cpu0 DT node needed by
the board to adapt the regulator voltage depending on the currently use
OPP.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
---
 arch/arm/boot/dts/sun8i-a33-olinuxino.dts | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/boot/dts/sun8i-a33-olinuxino.dts b/arch/arm/boot/dts/sun8i-a33-olinuxino.dts
index be9a6b8..9d25e90 100644
--- a/arch/arm/boot/dts/sun8i-a33-olinuxino.dts
+++ b/arch/arm/boot/dts/sun8i-a33-olinuxino.dts
@@ -72,6 +72,10 @@
 	};
 };
 
+&cpu0 {
+	cpu-supply = <&reg_dcdc3>;
+};
+
 &ehci0 {
 	status = "okay";
 };
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH v2 05/11] Documentation: DT: bindings: mfd: add A33 GPADC binding
@ 2017-03-10 10:39   ` Quentin Schulz
  0 siblings, 0 replies; 85+ messages in thread
From: Quentin Schulz @ 2017-03-10 10:39 UTC (permalink / raw)
  To: dmitry.torokhov, robh+dt, mark.rutland, maxime.ripard, wens,
	lee.jones, linux, jic23, knaack.h, lars, pmeerw,
	stefan.mavrodiev
  Cc: Quentin Schulz, devicetree, linux-arm-kernel, linux-kernel,
	linux-iio, linux-sunxi, thomas.petazzoni

This patch adds documentation for the A33 GPADC binding.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
---

added in v2

 .../devicetree/bindings/mfd/sun4i-gpadc.txt        | 59 ++++++++++++++++++++++
 1 file changed, 59 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt

diff --git a/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt b/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
new file mode 100644
index 0000000..17242c8
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
@@ -0,0 +1,59 @@
+Allwinner SoCs' GPADC Device Tree bindings
+------------------------------------------
+The Allwinner SoCs all have an ADC that can also act as a thermal sensor
+and sometimes as a touchscreen controller.
+
+Required properties:
+  - compatible: "sun8i-a33-gpadc-iio",
+  - reg: mmio address range of the chip,
+  - #thermal-sensor-cells: shall be 0,
+  - #io-channel-cells: shall be 0,
+
+Example:
+	rtp: rtp@01c25000 {
+		compatible = "allwinner,sun8i-a33-gpadc-iio";
+		reg = <0x01c25000 0x100>;
+		#thermal-sensor-cells = <0>;
+		#io-channel-cells = <0>;
+	};
+
+sun4i, sun5i and sun6i SoCs are also supported via the older binding:
+
+sun4i resistive touchscreen controller
+--------------------------------------
+
+Required properties:
+ - compatible: "allwinner,sun4i-a10-ts", "allwinner,sun5i-a13-ts" or
+   "allwinner,sun6i-a31-ts"
+ - reg: mmio address range of the chip
+ - interrupts: interrupt to which the chip is connected
+ - #thermal-sensor-cells: shall be 0
+
+Optional properties:
+ - allwinner,ts-attached	 : boolean indicating that an actual touchscreen
+				   is attached to the controller
+ - allwinner,tp-sensitive-adjust : integer (4 bits)
+				   adjust sensitivity of pen down detection
+				   between 0 (least sensitive) and 15
+				   (defaults to 15)
+ - allwinner,filter-type	 : integer (2 bits)
+				   select median and averaging filter
+				   samples used for median / averaging filter
+				   0: 4/2
+				   1: 5/3
+				   2: 8/4
+				   3: 16/8
+				   (defaults to 1)
+
+Example:
+
+	rtp: rtp@01c25000 {
+		compatible = "allwinner,sun4i-a10-ts";
+		reg = <0x01c25000 0x100>;
+		interrupts = <29>;
+		allwinner,ts-attached;
+		#thermal-sensor-cells = <0>;
+		/* sensitive/noisy touch panel */
+		allwinner,tp-sensitive-adjust = <0>;
+		allwinner,filter-type = <3>;
+	};
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH v2 05/11] Documentation: DT: bindings: mfd: add A33 GPADC binding
@ 2017-03-10 10:39   ` Quentin Schulz
  0 siblings, 0 replies; 85+ messages in thread
From: Quentin Schulz @ 2017-03-10 10:39 UTC (permalink / raw)
  To: dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8, wens-jdAy2FN1RRM,
	lee.jones-QSEj5FYQhm4dnm+yROfE0A, linux-I+IVW8TIWO2tmTQ+vhA3Yw,
	jic23-DgEjT+Ai2ygdnm+yROfE0A, knaack.h-Mmb7MZpHnFY,
	lars-Qo5EllUWu/uELgA04lAiVw, pmeerw-jW+XmwGofnusTnJN9+BGXg,
	stefan.mavrodiev-Re5JQEeQqe8AvxtiuMwx3w
  Cc: Quentin Schulz, devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-iio-u79uwXL29TY76Z2rM5mHXA,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
	thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8

This patch adds documentation for the A33 GPADC binding.

Signed-off-by: Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
---

added in v2

 .../devicetree/bindings/mfd/sun4i-gpadc.txt        | 59 ++++++++++++++++++++++
 1 file changed, 59 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt

diff --git a/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt b/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
new file mode 100644
index 0000000..17242c8
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
@@ -0,0 +1,59 @@
+Allwinner SoCs' GPADC Device Tree bindings
+------------------------------------------
+The Allwinner SoCs all have an ADC that can also act as a thermal sensor
+and sometimes as a touchscreen controller.
+
+Required properties:
+  - compatible: "sun8i-a33-gpadc-iio",
+  - reg: mmio address range of the chip,
+  - #thermal-sensor-cells: shall be 0,
+  - #io-channel-cells: shall be 0,
+
+Example:
+	rtp: rtp@01c25000 {
+		compatible = "allwinner,sun8i-a33-gpadc-iio";
+		reg = <0x01c25000 0x100>;
+		#thermal-sensor-cells = <0>;
+		#io-channel-cells = <0>;
+	};
+
+sun4i, sun5i and sun6i SoCs are also supported via the older binding:
+
+sun4i resistive touchscreen controller
+--------------------------------------
+
+Required properties:
+ - compatible: "allwinner,sun4i-a10-ts", "allwinner,sun5i-a13-ts" or
+   "allwinner,sun6i-a31-ts"
+ - reg: mmio address range of the chip
+ - interrupts: interrupt to which the chip is connected
+ - #thermal-sensor-cells: shall be 0
+
+Optional properties:
+ - allwinner,ts-attached	 : boolean indicating that an actual touchscreen
+				   is attached to the controller
+ - allwinner,tp-sensitive-adjust : integer (4 bits)
+				   adjust sensitivity of pen down detection
+				   between 0 (least sensitive) and 15
+				   (defaults to 15)
+ - allwinner,filter-type	 : integer (2 bits)
+				   select median and averaging filter
+				   samples used for median / averaging filter
+				   0: 4/2
+				   1: 5/3
+				   2: 8/4
+				   3: 16/8
+				   (defaults to 1)
+
+Example:
+
+	rtp: rtp@01c25000 {
+		compatible = "allwinner,sun4i-a10-ts";
+		reg = <0x01c25000 0x100>;
+		interrupts = <29>;
+		allwinner,ts-attached;
+		#thermal-sensor-cells = <0>;
+		/* sensitive/noisy touch panel */
+		allwinner,tp-sensitive-adjust = <0>;
+		allwinner,filter-type = <3>;
+	};
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH v2 05/11] Documentation: DT: bindings: mfd: add A33 GPADC binding
@ 2017-03-10 10:39   ` Quentin Schulz
  0 siblings, 0 replies; 85+ messages in thread
From: Quentin Schulz @ 2017-03-10 10:39 UTC (permalink / raw)
  To: linux-arm-kernel

This patch adds documentation for the A33 GPADC binding.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
---

added in v2

 .../devicetree/bindings/mfd/sun4i-gpadc.txt        | 59 ++++++++++++++++++++++
 1 file changed, 59 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt

diff --git a/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt b/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
new file mode 100644
index 0000000..17242c8
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
@@ -0,0 +1,59 @@
+Allwinner SoCs' GPADC Device Tree bindings
+------------------------------------------
+The Allwinner SoCs all have an ADC that can also act as a thermal sensor
+and sometimes as a touchscreen controller.
+
+Required properties:
+  - compatible: "sun8i-a33-gpadc-iio",
+  - reg: mmio address range of the chip,
+  - #thermal-sensor-cells: shall be 0,
+  - #io-channel-cells: shall be 0,
+
+Example:
+	rtp: rtp at 01c25000 {
+		compatible = "allwinner,sun8i-a33-gpadc-iio";
+		reg = <0x01c25000 0x100>;
+		#thermal-sensor-cells = <0>;
+		#io-channel-cells = <0>;
+	};
+
+sun4i, sun5i and sun6i SoCs are also supported via the older binding:
+
+sun4i resistive touchscreen controller
+--------------------------------------
+
+Required properties:
+ - compatible: "allwinner,sun4i-a10-ts", "allwinner,sun5i-a13-ts" or
+   "allwinner,sun6i-a31-ts"
+ - reg: mmio address range of the chip
+ - interrupts: interrupt to which the chip is connected
+ - #thermal-sensor-cells: shall be 0
+
+Optional properties:
+ - allwinner,ts-attached	 : boolean indicating that an actual touchscreen
+				   is attached to the controller
+ - allwinner,tp-sensitive-adjust : integer (4 bits)
+				   adjust sensitivity of pen down detection
+				   between 0 (least sensitive) and 15
+				   (defaults to 15)
+ - allwinner,filter-type	 : integer (2 bits)
+				   select median and averaging filter
+				   samples used for median / averaging filter
+				   0: 4/2
+				   1: 5/3
+				   2: 8/4
+				   3: 16/8
+				   (defaults to 1)
+
+Example:
+
+	rtp: rtp at 01c25000 {
+		compatible = "allwinner,sun4i-a10-ts";
+		reg = <0x01c25000 0x100>;
+		interrupts = <29>;
+		allwinner,ts-attached;
+		#thermal-sensor-cells = <0>;
+		/* sensitive/noisy touch panel */
+		allwinner,tp-sensitive-adjust = <0>;
+		allwinner,filter-type = <3>;
+	};
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH v2 06/11] Documentation: DT: bindings: input: touschcreen: remove sun4i documentation
@ 2017-03-10 10:39   ` Quentin Schulz
  0 siblings, 0 replies; 85+ messages in thread
From: Quentin Schulz @ 2017-03-10 10:39 UTC (permalink / raw)
  To: dmitry.torokhov, robh+dt, mark.rutland, maxime.ripard, wens,
	lee.jones, linux, jic23, knaack.h, lars, pmeerw,
	stefan.mavrodiev
  Cc: Quentin Schulz, devicetree, linux-arm-kernel, linux-kernel,
	linux-iio, linux-sunxi, thomas.petazzoni

This patch removes the sun4i touchscreen controller binding
documentation since it has been merged with the sun4i GPADC binding
documentation.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
---

added in v2

 .../bindings/input/touchscreen/sun4i.txt           | 38 ----------------------
 1 file changed, 38 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/input/touchscreen/sun4i.txt

diff --git a/Documentation/devicetree/bindings/input/touchscreen/sun4i.txt b/Documentation/devicetree/bindings/input/touchscreen/sun4i.txt
deleted file mode 100644
index 89abecd..0000000
--- a/Documentation/devicetree/bindings/input/touchscreen/sun4i.txt
+++ /dev/null
@@ -1,38 +0,0 @@
-sun4i resistive touchscreen controller
---------------------------------------
-
-Required properties:
- - compatible: "allwinner,sun4i-a10-ts", "allwinner,sun5i-a13-ts" or
-   "allwinner,sun6i-a31-ts"
- - reg: mmio address range of the chip
- - interrupts: interrupt to which the chip is connected
- - #thermal-sensor-cells: shall be 0
-
-Optional properties:
- - allwinner,ts-attached	 : boolean indicating that an actual touchscreen
-				   is attached to the controller
- - allwinner,tp-sensitive-adjust : integer (4 bits)
-				   adjust sensitivity of pen down detection
-				   between 0 (least sensitive) and 15
-				   (defaults to 15)
- - allwinner,filter-type	 : integer (2 bits)
-				   select median and averaging filter
-				   samples used for median / averaging filter
-				   0: 4/2
-				   1: 5/3
-				   2: 8/4
-				   3: 16/8
-				   (defaults to 1)
-
-Example:
-
-	rtp: rtp@01c25000 {
-		compatible = "allwinner,sun4i-a10-ts";
-		reg = <0x01c25000 0x100>;
-		interrupts = <29>;
-		allwinner,ts-attached;
-		#thermal-sensor-cells = <0>;
-		/* sensitive/noisy touch panel */
-		allwinner,tp-sensitive-adjust = <0>;
-		allwinner,filter-type = <3>;
-	};
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH v2 06/11] Documentation: DT: bindings: input: touschcreen: remove sun4i documentation
@ 2017-03-10 10:39   ` Quentin Schulz
  0 siblings, 0 replies; 85+ messages in thread
From: Quentin Schulz @ 2017-03-10 10:39 UTC (permalink / raw)
  To: dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8, wens-jdAy2FN1RRM,
	lee.jones-QSEj5FYQhm4dnm+yROfE0A, linux-I+IVW8TIWO2tmTQ+vhA3Yw,
	jic23-DgEjT+Ai2ygdnm+yROfE0A, knaack.h-Mmb7MZpHnFY,
	lars-Qo5EllUWu/uELgA04lAiVw, pmeerw-jW+XmwGofnusTnJN9+BGXg,
	stefan.mavrodiev-Re5JQEeQqe8AvxtiuMwx3w
  Cc: Quentin Schulz, devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-iio-u79uwXL29TY76Z2rM5mHXA,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
	thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8

This patch removes the sun4i touchscreen controller binding
documentation since it has been merged with the sun4i GPADC binding
documentation.

Signed-off-by: Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
---

added in v2

 .../bindings/input/touchscreen/sun4i.txt           | 38 ----------------------
 1 file changed, 38 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/input/touchscreen/sun4i.txt

diff --git a/Documentation/devicetree/bindings/input/touchscreen/sun4i.txt b/Documentation/devicetree/bindings/input/touchscreen/sun4i.txt
deleted file mode 100644
index 89abecd..0000000
--- a/Documentation/devicetree/bindings/input/touchscreen/sun4i.txt
+++ /dev/null
@@ -1,38 +0,0 @@
-sun4i resistive touchscreen controller
---------------------------------------
-
-Required properties:
- - compatible: "allwinner,sun4i-a10-ts", "allwinner,sun5i-a13-ts" or
-   "allwinner,sun6i-a31-ts"
- - reg: mmio address range of the chip
- - interrupts: interrupt to which the chip is connected
- - #thermal-sensor-cells: shall be 0
-
-Optional properties:
- - allwinner,ts-attached	 : boolean indicating that an actual touchscreen
-				   is attached to the controller
- - allwinner,tp-sensitive-adjust : integer (4 bits)
-				   adjust sensitivity of pen down detection
-				   between 0 (least sensitive) and 15
-				   (defaults to 15)
- - allwinner,filter-type	 : integer (2 bits)
-				   select median and averaging filter
-				   samples used for median / averaging filter
-				   0: 4/2
-				   1: 5/3
-				   2: 8/4
-				   3: 16/8
-				   (defaults to 1)
-
-Example:
-
-	rtp: rtp@01c25000 {
-		compatible = "allwinner,sun4i-a10-ts";
-		reg = <0x01c25000 0x100>;
-		interrupts = <29>;
-		allwinner,ts-attached;
-		#thermal-sensor-cells = <0>;
-		/* sensitive/noisy touch panel */
-		allwinner,tp-sensitive-adjust = <0>;
-		allwinner,filter-type = <3>;
-	};
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH v2 06/11] Documentation: DT: bindings: input: touschcreen: remove sun4i documentation
@ 2017-03-10 10:39   ` Quentin Schulz
  0 siblings, 0 replies; 85+ messages in thread
From: Quentin Schulz @ 2017-03-10 10:39 UTC (permalink / raw)
  To: linux-arm-kernel

This patch removes the sun4i touchscreen controller binding
documentation since it has been merged with the sun4i GPADC binding
documentation.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
---

added in v2

 .../bindings/input/touchscreen/sun4i.txt           | 38 ----------------------
 1 file changed, 38 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/input/touchscreen/sun4i.txt

diff --git a/Documentation/devicetree/bindings/input/touchscreen/sun4i.txt b/Documentation/devicetree/bindings/input/touchscreen/sun4i.txt
deleted file mode 100644
index 89abecd..0000000
--- a/Documentation/devicetree/bindings/input/touchscreen/sun4i.txt
+++ /dev/null
@@ -1,38 +0,0 @@
-sun4i resistive touchscreen controller
---------------------------------------
-
-Required properties:
- - compatible: "allwinner,sun4i-a10-ts", "allwinner,sun5i-a13-ts" or
-   "allwinner,sun6i-a31-ts"
- - reg: mmio address range of the chip
- - interrupts: interrupt to which the chip is connected
- - #thermal-sensor-cells: shall be 0
-
-Optional properties:
- - allwinner,ts-attached	 : boolean indicating that an actual touchscreen
-				   is attached to the controller
- - allwinner,tp-sensitive-adjust : integer (4 bits)
-				   adjust sensitivity of pen down detection
-				   between 0 (least sensitive) and 15
-				   (defaults to 15)
- - allwinner,filter-type	 : integer (2 bits)
-				   select median and averaging filter
-				   samples used for median / averaging filter
-				   0: 4/2
-				   1: 5/3
-				   2: 8/4
-				   3: 16/8
-				   (defaults to 1)
-
-Example:
-
-	rtp: rtp at 01c25000 {
-		compatible = "allwinner,sun4i-a10-ts";
-		reg = <0x01c25000 0x100>;
-		interrupts = <29>;
-		allwinner,ts-attached;
-		#thermal-sensor-cells = <0>;
-		/* sensitive/noisy touch panel */
-		allwinner,tp-sensitive-adjust = <0>;
-		allwinner,filter-type = <3>;
-	};
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH v2 07/11] iio: adc: sun4i-gpadc-iio: move code used in MFD probing to new function
@ 2017-03-10 10:39   ` Quentin Schulz
  0 siblings, 0 replies; 85+ messages in thread
From: Quentin Schulz @ 2017-03-10 10:39 UTC (permalink / raw)
  To: dmitry.torokhov, robh+dt, mark.rutland, maxime.ripard, wens,
	lee.jones, linux, jic23, knaack.h, lars, pmeerw,
	stefan.mavrodiev
  Cc: Quentin Schulz, devicetree, linux-arm-kernel, linux-kernel,
	linux-iio, linux-sunxi, thomas.petazzoni

This moves code used in MFD probing to a new sun4i_gpadc_probe_mfd
function.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
---

added in v2

 drivers/iio/adc/sun4i-gpadc-iio.c | 78 ++++++++++++++++++++++-----------------
 1 file changed, 45 insertions(+), 33 deletions(-)

diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c
index a8e134f..7cb997a 100644
--- a/drivers/iio/adc/sun4i-gpadc-iio.c
+++ b/drivers/iio/adc/sun4i-gpadc-iio.c
@@ -454,31 +454,16 @@ static int sun4i_irq_init(struct platform_device *pdev, const char *name,
 	return 0;
 }
 
-static int sun4i_gpadc_probe(struct platform_device *pdev)
+static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
+				 struct iio_dev *indio_dev)
 {
-	struct sun4i_gpadc_iio *info;
-	struct iio_dev *indio_dev;
+	struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
+	struct sun4i_gpadc_dev *sun4i_gpadc_dev =
+		dev_get_drvdata(pdev->dev.parent);
 	int ret;
-	struct sun4i_gpadc_dev *sun4i_gpadc_dev;
-
-	sun4i_gpadc_dev = dev_get_drvdata(pdev->dev.parent);
-
-	indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*info));
-	if (!indio_dev)
-		return -ENOMEM;
 
-	info = iio_priv(indio_dev);
-	platform_set_drvdata(pdev, indio_dev);
-
-	mutex_init(&info->mutex);
 	info->regmap = sun4i_gpadc_dev->regmap;
-	info->indio_dev = indio_dev;
-	init_completion(&info->completion);
-	indio_dev->name = dev_name(&pdev->dev);
-	indio_dev->dev.parent = &pdev->dev;
-	indio_dev->dev.of_node = pdev->dev.of_node;
-	indio_dev->info = &sun4i_gpadc_iio_info;
-	indio_dev->modes = INDIO_DIRECT_MODE;
+
 	indio_dev->num_channels = ARRAY_SIZE(sun4i_gpadc_channels);
 	indio_dev->channels = sun4i_gpadc_channels;
 
@@ -519,8 +504,7 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
 			dev_err(&pdev->dev,
 				"could not register thermal sensor: %ld\n",
 				PTR_ERR(tzd));
-			ret = PTR_ERR(tzd);
-			goto err;
+			return PTR_ERR(tzd);
 		}
 	} else {
 		indio_dev->num_channels =
@@ -528,36 +512,65 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
 		indio_dev->channels = sun4i_gpadc_channels_no_temp;
 	}
 
-	pm_runtime_set_autosuspend_delay(&pdev->dev,
-					 SUN4I_GPADC_AUTOSUSPEND_DELAY);
-	pm_runtime_use_autosuspend(&pdev->dev);
-	pm_runtime_set_suspended(&pdev->dev);
-	pm_runtime_enable(&pdev->dev);
-
 	if (IS_ENABLED(CONFIG_THERMAL_OF)) {
 		ret = sun4i_irq_init(pdev, "TEMP_DATA_PENDING",
 				     sun4i_gpadc_temp_data_irq_handler,
 				     "temp_data", &info->temp_data_irq,
 				     &info->ignore_temp_data_irq);
 		if (ret < 0)
-			goto err;
+			return ret;
 	}
 
 	ret = sun4i_irq_init(pdev, "FIFO_DATA_PENDING",
 			     sun4i_gpadc_fifo_data_irq_handler, "fifo_data",
 			     &info->fifo_data_irq, &info->ignore_fifo_data_irq);
 	if (ret < 0)
-		goto err;
+		return ret;
 
 	if (IS_ENABLED(CONFIG_THERMAL_OF)) {
 		ret = iio_map_array_register(indio_dev, sun4i_gpadc_hwmon_maps);
 		if (ret < 0) {
 			dev_err(&pdev->dev,
 				"failed to register iio map array\n");
-			goto err;
+			return ret;
 		}
 	}
 
+	return 0;
+}
+
+static int sun4i_gpadc_probe(struct platform_device *pdev)
+{
+	struct sun4i_gpadc_iio *info;
+	struct iio_dev *indio_dev;
+	int ret;
+
+	indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*info));
+	if (!indio_dev)
+		return -ENOMEM;
+
+	info = iio_priv(indio_dev);
+	platform_set_drvdata(pdev, indio_dev);
+
+	mutex_init(&info->mutex);
+	info->indio_dev = indio_dev;
+	init_completion(&info->completion);
+	indio_dev->name = dev_name(&pdev->dev);
+	indio_dev->dev.parent = &pdev->dev;
+	indio_dev->dev.of_node = pdev->dev.of_node;
+	indio_dev->info = &sun4i_gpadc_iio_info;
+	indio_dev->modes = INDIO_DIRECT_MODE;
+
+	ret = sun4i_gpadc_probe_mfd(pdev, indio_dev);
+	if (ret)
+		return ret;
+
+	pm_runtime_set_autosuspend_delay(&pdev->dev,
+					 SUN4I_GPADC_AUTOSUSPEND_DELAY);
+	pm_runtime_use_autosuspend(&pdev->dev);
+	pm_runtime_set_suspended(&pdev->dev);
+	pm_runtime_enable(&pdev->dev);
+
 	ret = devm_iio_device_register(&pdev->dev, indio_dev);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "could not register the device\n");
@@ -570,7 +583,6 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
 	if (IS_ENABLED(CONFIG_THERMAL_OF))
 		iio_map_array_unregister(indio_dev);
 
-err:
 	pm_runtime_put(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
 
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH v2 07/11] iio: adc: sun4i-gpadc-iio: move code used in MFD probing to new function
@ 2017-03-10 10:39   ` Quentin Schulz
  0 siblings, 0 replies; 85+ messages in thread
From: Quentin Schulz @ 2017-03-10 10:39 UTC (permalink / raw)
  To: dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8, wens-jdAy2FN1RRM,
	lee.jones-QSEj5FYQhm4dnm+yROfE0A, linux-I+IVW8TIWO2tmTQ+vhA3Yw,
	jic23-DgEjT+Ai2ygdnm+yROfE0A, knaack.h-Mmb7MZpHnFY,
	lars-Qo5EllUWu/uELgA04lAiVw, pmeerw-jW+XmwGofnusTnJN9+BGXg,
	stefan.mavrodiev-Re5JQEeQqe8AvxtiuMwx3w
  Cc: Quentin Schulz, devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-iio-u79uwXL29TY76Z2rM5mHXA,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
	thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8

This moves code used in MFD probing to a new sun4i_gpadc_probe_mfd
function.

Signed-off-by: Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
---

added in v2

 drivers/iio/adc/sun4i-gpadc-iio.c | 78 ++++++++++++++++++++++-----------------
 1 file changed, 45 insertions(+), 33 deletions(-)

diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c
index a8e134f..7cb997a 100644
--- a/drivers/iio/adc/sun4i-gpadc-iio.c
+++ b/drivers/iio/adc/sun4i-gpadc-iio.c
@@ -454,31 +454,16 @@ static int sun4i_irq_init(struct platform_device *pdev, const char *name,
 	return 0;
 }
 
-static int sun4i_gpadc_probe(struct platform_device *pdev)
+static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
+				 struct iio_dev *indio_dev)
 {
-	struct sun4i_gpadc_iio *info;
-	struct iio_dev *indio_dev;
+	struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
+	struct sun4i_gpadc_dev *sun4i_gpadc_dev =
+		dev_get_drvdata(pdev->dev.parent);
 	int ret;
-	struct sun4i_gpadc_dev *sun4i_gpadc_dev;
-
-	sun4i_gpadc_dev = dev_get_drvdata(pdev->dev.parent);
-
-	indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*info));
-	if (!indio_dev)
-		return -ENOMEM;
 
-	info = iio_priv(indio_dev);
-	platform_set_drvdata(pdev, indio_dev);
-
-	mutex_init(&info->mutex);
 	info->regmap = sun4i_gpadc_dev->regmap;
-	info->indio_dev = indio_dev;
-	init_completion(&info->completion);
-	indio_dev->name = dev_name(&pdev->dev);
-	indio_dev->dev.parent = &pdev->dev;
-	indio_dev->dev.of_node = pdev->dev.of_node;
-	indio_dev->info = &sun4i_gpadc_iio_info;
-	indio_dev->modes = INDIO_DIRECT_MODE;
+
 	indio_dev->num_channels = ARRAY_SIZE(sun4i_gpadc_channels);
 	indio_dev->channels = sun4i_gpadc_channels;
 
@@ -519,8 +504,7 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
 			dev_err(&pdev->dev,
 				"could not register thermal sensor: %ld\n",
 				PTR_ERR(tzd));
-			ret = PTR_ERR(tzd);
-			goto err;
+			return PTR_ERR(tzd);
 		}
 	} else {
 		indio_dev->num_channels =
@@ -528,36 +512,65 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
 		indio_dev->channels = sun4i_gpadc_channels_no_temp;
 	}
 
-	pm_runtime_set_autosuspend_delay(&pdev->dev,
-					 SUN4I_GPADC_AUTOSUSPEND_DELAY);
-	pm_runtime_use_autosuspend(&pdev->dev);
-	pm_runtime_set_suspended(&pdev->dev);
-	pm_runtime_enable(&pdev->dev);
-
 	if (IS_ENABLED(CONFIG_THERMAL_OF)) {
 		ret = sun4i_irq_init(pdev, "TEMP_DATA_PENDING",
 				     sun4i_gpadc_temp_data_irq_handler,
 				     "temp_data", &info->temp_data_irq,
 				     &info->ignore_temp_data_irq);
 		if (ret < 0)
-			goto err;
+			return ret;
 	}
 
 	ret = sun4i_irq_init(pdev, "FIFO_DATA_PENDING",
 			     sun4i_gpadc_fifo_data_irq_handler, "fifo_data",
 			     &info->fifo_data_irq, &info->ignore_fifo_data_irq);
 	if (ret < 0)
-		goto err;
+		return ret;
 
 	if (IS_ENABLED(CONFIG_THERMAL_OF)) {
 		ret = iio_map_array_register(indio_dev, sun4i_gpadc_hwmon_maps);
 		if (ret < 0) {
 			dev_err(&pdev->dev,
 				"failed to register iio map array\n");
-			goto err;
+			return ret;
 		}
 	}
 
+	return 0;
+}
+
+static int sun4i_gpadc_probe(struct platform_device *pdev)
+{
+	struct sun4i_gpadc_iio *info;
+	struct iio_dev *indio_dev;
+	int ret;
+
+	indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*info));
+	if (!indio_dev)
+		return -ENOMEM;
+
+	info = iio_priv(indio_dev);
+	platform_set_drvdata(pdev, indio_dev);
+
+	mutex_init(&info->mutex);
+	info->indio_dev = indio_dev;
+	init_completion(&info->completion);
+	indio_dev->name = dev_name(&pdev->dev);
+	indio_dev->dev.parent = &pdev->dev;
+	indio_dev->dev.of_node = pdev->dev.of_node;
+	indio_dev->info = &sun4i_gpadc_iio_info;
+	indio_dev->modes = INDIO_DIRECT_MODE;
+
+	ret = sun4i_gpadc_probe_mfd(pdev, indio_dev);
+	if (ret)
+		return ret;
+
+	pm_runtime_set_autosuspend_delay(&pdev->dev,
+					 SUN4I_GPADC_AUTOSUSPEND_DELAY);
+	pm_runtime_use_autosuspend(&pdev->dev);
+	pm_runtime_set_suspended(&pdev->dev);
+	pm_runtime_enable(&pdev->dev);
+
 	ret = devm_iio_device_register(&pdev->dev, indio_dev);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "could not register the device\n");
@@ -570,7 +583,6 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
 	if (IS_ENABLED(CONFIG_THERMAL_OF))
 		iio_map_array_unregister(indio_dev);
 
-err:
 	pm_runtime_put(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
 
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH v2 07/11] iio: adc: sun4i-gpadc-iio: move code used in MFD probing to new function
@ 2017-03-10 10:39   ` Quentin Schulz
  0 siblings, 0 replies; 85+ messages in thread
From: Quentin Schulz @ 2017-03-10 10:39 UTC (permalink / raw)
  To: linux-arm-kernel

This moves code used in MFD probing to a new sun4i_gpadc_probe_mfd
function.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
---

added in v2

 drivers/iio/adc/sun4i-gpadc-iio.c | 78 ++++++++++++++++++++++-----------------
 1 file changed, 45 insertions(+), 33 deletions(-)

diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c
index a8e134f..7cb997a 100644
--- a/drivers/iio/adc/sun4i-gpadc-iio.c
+++ b/drivers/iio/adc/sun4i-gpadc-iio.c
@@ -454,31 +454,16 @@ static int sun4i_irq_init(struct platform_device *pdev, const char *name,
 	return 0;
 }
 
-static int sun4i_gpadc_probe(struct platform_device *pdev)
+static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
+				 struct iio_dev *indio_dev)
 {
-	struct sun4i_gpadc_iio *info;
-	struct iio_dev *indio_dev;
+	struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
+	struct sun4i_gpadc_dev *sun4i_gpadc_dev =
+		dev_get_drvdata(pdev->dev.parent);
 	int ret;
-	struct sun4i_gpadc_dev *sun4i_gpadc_dev;
-
-	sun4i_gpadc_dev = dev_get_drvdata(pdev->dev.parent);
-
-	indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*info));
-	if (!indio_dev)
-		return -ENOMEM;
 
-	info = iio_priv(indio_dev);
-	platform_set_drvdata(pdev, indio_dev);
-
-	mutex_init(&info->mutex);
 	info->regmap = sun4i_gpadc_dev->regmap;
-	info->indio_dev = indio_dev;
-	init_completion(&info->completion);
-	indio_dev->name = dev_name(&pdev->dev);
-	indio_dev->dev.parent = &pdev->dev;
-	indio_dev->dev.of_node = pdev->dev.of_node;
-	indio_dev->info = &sun4i_gpadc_iio_info;
-	indio_dev->modes = INDIO_DIRECT_MODE;
+
 	indio_dev->num_channels = ARRAY_SIZE(sun4i_gpadc_channels);
 	indio_dev->channels = sun4i_gpadc_channels;
 
@@ -519,8 +504,7 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
 			dev_err(&pdev->dev,
 				"could not register thermal sensor: %ld\n",
 				PTR_ERR(tzd));
-			ret = PTR_ERR(tzd);
-			goto err;
+			return PTR_ERR(tzd);
 		}
 	} else {
 		indio_dev->num_channels =
@@ -528,36 +512,65 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
 		indio_dev->channels = sun4i_gpadc_channels_no_temp;
 	}
 
-	pm_runtime_set_autosuspend_delay(&pdev->dev,
-					 SUN4I_GPADC_AUTOSUSPEND_DELAY);
-	pm_runtime_use_autosuspend(&pdev->dev);
-	pm_runtime_set_suspended(&pdev->dev);
-	pm_runtime_enable(&pdev->dev);
-
 	if (IS_ENABLED(CONFIG_THERMAL_OF)) {
 		ret = sun4i_irq_init(pdev, "TEMP_DATA_PENDING",
 				     sun4i_gpadc_temp_data_irq_handler,
 				     "temp_data", &info->temp_data_irq,
 				     &info->ignore_temp_data_irq);
 		if (ret < 0)
-			goto err;
+			return ret;
 	}
 
 	ret = sun4i_irq_init(pdev, "FIFO_DATA_PENDING",
 			     sun4i_gpadc_fifo_data_irq_handler, "fifo_data",
 			     &info->fifo_data_irq, &info->ignore_fifo_data_irq);
 	if (ret < 0)
-		goto err;
+		return ret;
 
 	if (IS_ENABLED(CONFIG_THERMAL_OF)) {
 		ret = iio_map_array_register(indio_dev, sun4i_gpadc_hwmon_maps);
 		if (ret < 0) {
 			dev_err(&pdev->dev,
 				"failed to register iio map array\n");
-			goto err;
+			return ret;
 		}
 	}
 
+	return 0;
+}
+
+static int sun4i_gpadc_probe(struct platform_device *pdev)
+{
+	struct sun4i_gpadc_iio *info;
+	struct iio_dev *indio_dev;
+	int ret;
+
+	indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*info));
+	if (!indio_dev)
+		return -ENOMEM;
+
+	info = iio_priv(indio_dev);
+	platform_set_drvdata(pdev, indio_dev);
+
+	mutex_init(&info->mutex);
+	info->indio_dev = indio_dev;
+	init_completion(&info->completion);
+	indio_dev->name = dev_name(&pdev->dev);
+	indio_dev->dev.parent = &pdev->dev;
+	indio_dev->dev.of_node = pdev->dev.of_node;
+	indio_dev->info = &sun4i_gpadc_iio_info;
+	indio_dev->modes = INDIO_DIRECT_MODE;
+
+	ret = sun4i_gpadc_probe_mfd(pdev, indio_dev);
+	if (ret)
+		return ret;
+
+	pm_runtime_set_autosuspend_delay(&pdev->dev,
+					 SUN4I_GPADC_AUTOSUSPEND_DELAY);
+	pm_runtime_use_autosuspend(&pdev->dev);
+	pm_runtime_set_suspended(&pdev->dev);
+	pm_runtime_enable(&pdev->dev);
+
 	ret = devm_iio_device_register(&pdev->dev, indio_dev);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "could not register the device\n");
@@ -570,7 +583,6 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
 	if (IS_ENABLED(CONFIG_THERMAL_OF))
 		iio_map_array_unregister(indio_dev);
 
-err:
 	pm_runtime_put(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
 
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH v2 08/11] iio: adc: sun4i-gpadc-iio: add support for A33 thermal sensor
@ 2017-03-10 10:39   ` Quentin Schulz
  0 siblings, 0 replies; 85+ messages in thread
From: Quentin Schulz @ 2017-03-10 10:39 UTC (permalink / raw)
  To: dmitry.torokhov, robh+dt, mark.rutland, maxime.ripard, wens,
	lee.jones, linux, jic23, knaack.h, lars, pmeerw,
	stefan.mavrodiev
  Cc: Quentin Schulz, devicetree, linux-arm-kernel, linux-kernel,
	linux-iio, linux-sunxi, thomas.petazzoni

This adds support for the Allwinner A33 thermal sensor.

Unlike the A10, A13 and A31, the Allwinner A33 only has one channel
which is dedicated to the thermal sensor. Moreover, its thermal sensor
does not generate interruptions, thus we only need to directly read the
register storing the temperature value.

The MFD used by the A10, A13 and A31, was created to avoid breaking the
DT binding, but since the nodes for the ADC weren't there for the A33,
it is not needed.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
---

v2:
  - removed added comments in Kconfig,
  - simplified Kconfig depends on condition,
  - removed THERMAL_OF requirement for sun8i,
  - renamed sun8i_gpadc_channels to sun8i_a33_gpadc_channels,
  - renamed use_dt boolean in no_irq as it reflects better why we need it,
  - removed spurious/unneeded modifications done in v1,

 drivers/iio/adc/Kconfig           |   2 +-
 drivers/iio/adc/sun4i-gpadc-iio.c | 100 ++++++++++++++++++++++++++++++++++++--
 include/linux/mfd/sun4i-gpadc.h   |   4 ++
 3 files changed, 102 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
index 9f8b4b1..8c8ead6 100644
--- a/drivers/iio/adc/Kconfig
+++ b/drivers/iio/adc/Kconfig
@@ -562,7 +562,7 @@ config STX104
 config SUN4I_GPADC
 	tristate "Support for the Allwinner SoCs GPADC"
 	depends on IIO
-	depends on MFD_SUN4I_GPADC
+	depends on MFD_SUN4I_GPADC || MACH_SUN8I
 	help
 	  Say yes here to build support for Allwinner (A10, A13 and A31) SoCs
 	  GPADC. This ADC provides 4 channels which can be used as an ADC or as
diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c
index 7cb997a..70684cd 100644
--- a/drivers/iio/adc/sun4i-gpadc-iio.c
+++ b/drivers/iio/adc/sun4i-gpadc-iio.c
@@ -85,6 +85,12 @@ static const struct gpadc_data sun6i_gpadc_data = {
 	.adc_chan_mask = SUN6I_GPADC_CTRL1_ADC_CHAN_MASK,
 };
 
+static const struct gpadc_data sun8i_a33_gpadc_data = {
+	.temp_offset = -1662,
+	.temp_scale = 162,
+	.tp_mode_en = SUN8I_GPADC_CTRL1_CHOP_TEMP_EN,
+};
+
 struct sun4i_gpadc_iio {
 	struct iio_dev			*indio_dev;
 	struct completion		completion;
@@ -96,6 +102,7 @@ struct sun4i_gpadc_iio {
 	unsigned int			temp_data_irq;
 	atomic_t			ignore_temp_data_irq;
 	const struct gpadc_data		*data;
+	bool				no_irq;
 	/* prevents concurrent reads of temperature and ADC */
 	struct mutex			mutex;
 };
@@ -138,6 +145,23 @@ static const struct iio_chan_spec sun4i_gpadc_channels_no_temp[] = {
 	SUN4I_GPADC_ADC_CHANNEL(3, "adc_chan3"),
 };
 
+static const struct iio_chan_spec sun8i_a33_gpadc_channels[] = {
+	{
+		.type = IIO_TEMP,
+		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
+				      BIT(IIO_CHAN_INFO_SCALE) |
+				      BIT(IIO_CHAN_INFO_OFFSET),
+		.datasheet_name = "temp_adc",
+	},
+};
+
+static const struct regmap_config sun4i_gpadc_regmap_config = {
+	.reg_bits = 32,
+	.val_bits = 32,
+	.reg_stride = 4,
+	.fast_io = true,
+};
+
 static int sun4i_prepare_for_irq(struct iio_dev *indio_dev, int channel,
 				 unsigned int irq)
 {
@@ -247,6 +271,17 @@ static int sun4i_gpadc_temp_read(struct iio_dev *indio_dev, int *val)
 {
 	struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
 
+	if (info->no_irq) {
+		pm_runtime_get_sync(indio_dev->dev.parent);
+
+		regmap_read(info->regmap, SUN4I_GPADC_TEMP_DATA, val);
+
+		pm_runtime_mark_last_busy(indio_dev->dev.parent);
+		pm_runtime_put_autosuspend(indio_dev->dev.parent);
+
+		return 0;
+	}
+
 	return sun4i_gpadc_read(indio_dev, 0, val, info->temp_data_irq);
 }
 
@@ -454,6 +489,58 @@ static int sun4i_irq_init(struct platform_device *pdev, const char *name,
 	return 0;
 }
 
+static const struct of_device_id sun4i_gpadc_of_id[] = {
+	{
+		.compatible = "allwinner,sun8i-a33-gpadc-iio",
+		.data = &sun8i_a33_gpadc_data,
+	},
+	{ /* sentinel */ }
+};
+
+static int sun4i_gpadc_probe_dt(struct platform_device *pdev,
+				struct iio_dev *indio_dev)
+{
+	struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
+	const struct of_device_id *of_dev;
+	struct thermal_zone_device *tzd;
+	struct resource *mem;
+	void __iomem *base;
+	int ret;
+
+	of_dev = of_match_device(sun4i_gpadc_of_id, &pdev->dev);
+	if (!of_dev)
+		return -ENODEV;
+
+	info->no_irq = true;
+	info->data = (struct gpadc_data *)of_dev->data;
+	indio_dev->num_channels = ARRAY_SIZE(sun8i_a33_gpadc_channels);
+	indio_dev->channels = sun8i_a33_gpadc_channels;
+
+	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	base = devm_ioremap_resource(&pdev->dev, mem);
+	if (IS_ERR(base))
+		return PTR_ERR(base);
+
+	info->regmap = devm_regmap_init_mmio(&pdev->dev, base,
+					     &sun4i_gpadc_regmap_config);
+	if (IS_ERR(info->regmap)) {
+		ret = PTR_ERR(info->regmap);
+		dev_err(&pdev->dev, "failed to init regmap: %d\n", ret);
+		return ret;
+	}
+
+	if (!IS_ENABLED(THERMAL_OF))
+		return 0;
+
+	tzd = devm_thermal_zone_of_sensor_register(&pdev->dev, 0, info,
+						   &sun4i_ts_tz_ops);
+	if (IS_ERR(tzd))
+		dev_err(&pdev->dev, "could not register thermal sensor: %ld\n",
+			PTR_ERR(tzd));
+
+	return PTR_ERR_OR_ZERO(tzd);
+}
+
 static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
 				 struct iio_dev *indio_dev)
 {
@@ -462,6 +549,7 @@ static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
 		dev_get_drvdata(pdev->dev.parent);
 	int ret;
 
+	info->no_irq = false;
 	info->regmap = sun4i_gpadc_dev->regmap;
 
 	indio_dev->num_channels = ARRAY_SIZE(sun4i_gpadc_channels);
@@ -561,7 +649,11 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
 	indio_dev->info = &sun4i_gpadc_iio_info;
 	indio_dev->modes = INDIO_DIRECT_MODE;
 
-	ret = sun4i_gpadc_probe_mfd(pdev, indio_dev);
+	if (pdev->dev.of_node)
+		ret = sun4i_gpadc_probe_dt(pdev, indio_dev);
+	else
+		ret = sun4i_gpadc_probe_mfd(pdev, indio_dev);
+
 	if (ret)
 		return ret;
 
@@ -580,7 +672,7 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
 	return 0;
 
 err_map:
-	if (IS_ENABLED(CONFIG_THERMAL_OF))
+	if (!info->no_irq && IS_ENABLED(CONFIG_THERMAL_OF))
 		iio_map_array_unregister(indio_dev);
 
 	pm_runtime_put(&pdev->dev);
@@ -592,10 +684,11 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
 static int sun4i_gpadc_remove(struct platform_device *pdev)
 {
 	struct iio_dev *indio_dev = platform_get_drvdata(pdev);
+	struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
 
 	pm_runtime_put(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
-	if (IS_ENABLED(CONFIG_THERMAL_OF))
+	if (!info->no_irq && IS_ENABLED(CONFIG_THERMAL_OF))
 		iio_map_array_unregister(indio_dev);
 
 	return 0;
@@ -611,6 +704,7 @@ static const struct platform_device_id sun4i_gpadc_id[] = {
 static struct platform_driver sun4i_gpadc_driver = {
 	.driver = {
 		.name = "sun4i-gpadc-iio",
+		.of_match_table = sun4i_gpadc_of_id,
 		.pm = &sun4i_gpadc_pm_ops,
 	},
 	.id_table = sun4i_gpadc_id,
diff --git a/include/linux/mfd/sun4i-gpadc.h b/include/linux/mfd/sun4i-gpadc.h
index 509e736..139872c 100644
--- a/include/linux/mfd/sun4i-gpadc.h
+++ b/include/linux/mfd/sun4i-gpadc.h
@@ -38,6 +38,10 @@
 #define SUN6I_GPADC_CTRL1_ADC_CHAN_SELECT(x)		(GENMASK(3, 0) & BIT(x))
 #define SUN6I_GPADC_CTRL1_ADC_CHAN_MASK			GENMASK(3, 0)
 
+/* TP_CTRL1 bits for sun8i SoCs */
+#define SUN8I_GPADC_CTRL1_CHOP_TEMP_EN			BIT(8)
+#define SUN8I_GPADC_CTRL1_GPADC_CALI_EN			BIT(7)
+
 #define SUN4I_GPADC_CTRL2				0x08
 
 #define SUN4I_GPADC_CTRL2_TP_SENSITIVE_ADJUST(x)	((GENMASK(3, 0) & (x)) << 28)
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH v2 08/11] iio: adc: sun4i-gpadc-iio: add support for A33 thermal sensor
@ 2017-03-10 10:39   ` Quentin Schulz
  0 siblings, 0 replies; 85+ messages in thread
From: Quentin Schulz @ 2017-03-10 10:39 UTC (permalink / raw)
  To: dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8, wens-jdAy2FN1RRM,
	lee.jones-QSEj5FYQhm4dnm+yROfE0A, linux-I+IVW8TIWO2tmTQ+vhA3Yw,
	jic23-DgEjT+Ai2ygdnm+yROfE0A, knaack.h-Mmb7MZpHnFY,
	lars-Qo5EllUWu/uELgA04lAiVw, pmeerw-jW+XmwGofnusTnJN9+BGXg,
	stefan.mavrodiev-Re5JQEeQqe8AvxtiuMwx3w
  Cc: Quentin Schulz, devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-iio-u79uwXL29TY76Z2rM5mHXA,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
	thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8

This adds support for the Allwinner A33 thermal sensor.

Unlike the A10, A13 and A31, the Allwinner A33 only has one channel
which is dedicated to the thermal sensor. Moreover, its thermal sensor
does not generate interruptions, thus we only need to directly read the
register storing the temperature value.

The MFD used by the A10, A13 and A31, was created to avoid breaking the
DT binding, but since the nodes for the ADC weren't there for the A33,
it is not needed.

Signed-off-by: Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
---

v2:
  - removed added comments in Kconfig,
  - simplified Kconfig depends on condition,
  - removed THERMAL_OF requirement for sun8i,
  - renamed sun8i_gpadc_channels to sun8i_a33_gpadc_channels,
  - renamed use_dt boolean in no_irq as it reflects better why we need it,
  - removed spurious/unneeded modifications done in v1,

 drivers/iio/adc/Kconfig           |   2 +-
 drivers/iio/adc/sun4i-gpadc-iio.c | 100 ++++++++++++++++++++++++++++++++++++--
 include/linux/mfd/sun4i-gpadc.h   |   4 ++
 3 files changed, 102 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
index 9f8b4b1..8c8ead6 100644
--- a/drivers/iio/adc/Kconfig
+++ b/drivers/iio/adc/Kconfig
@@ -562,7 +562,7 @@ config STX104
 config SUN4I_GPADC
 	tristate "Support for the Allwinner SoCs GPADC"
 	depends on IIO
-	depends on MFD_SUN4I_GPADC
+	depends on MFD_SUN4I_GPADC || MACH_SUN8I
 	help
 	  Say yes here to build support for Allwinner (A10, A13 and A31) SoCs
 	  GPADC. This ADC provides 4 channels which can be used as an ADC or as
diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c
index 7cb997a..70684cd 100644
--- a/drivers/iio/adc/sun4i-gpadc-iio.c
+++ b/drivers/iio/adc/sun4i-gpadc-iio.c
@@ -85,6 +85,12 @@ static const struct gpadc_data sun6i_gpadc_data = {
 	.adc_chan_mask = SUN6I_GPADC_CTRL1_ADC_CHAN_MASK,
 };
 
+static const struct gpadc_data sun8i_a33_gpadc_data = {
+	.temp_offset = -1662,
+	.temp_scale = 162,
+	.tp_mode_en = SUN8I_GPADC_CTRL1_CHOP_TEMP_EN,
+};
+
 struct sun4i_gpadc_iio {
 	struct iio_dev			*indio_dev;
 	struct completion		completion;
@@ -96,6 +102,7 @@ struct sun4i_gpadc_iio {
 	unsigned int			temp_data_irq;
 	atomic_t			ignore_temp_data_irq;
 	const struct gpadc_data		*data;
+	bool				no_irq;
 	/* prevents concurrent reads of temperature and ADC */
 	struct mutex			mutex;
 };
@@ -138,6 +145,23 @@ static const struct iio_chan_spec sun4i_gpadc_channels_no_temp[] = {
 	SUN4I_GPADC_ADC_CHANNEL(3, "adc_chan3"),
 };
 
+static const struct iio_chan_spec sun8i_a33_gpadc_channels[] = {
+	{
+		.type = IIO_TEMP,
+		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
+				      BIT(IIO_CHAN_INFO_SCALE) |
+				      BIT(IIO_CHAN_INFO_OFFSET),
+		.datasheet_name = "temp_adc",
+	},
+};
+
+static const struct regmap_config sun4i_gpadc_regmap_config = {
+	.reg_bits = 32,
+	.val_bits = 32,
+	.reg_stride = 4,
+	.fast_io = true,
+};
+
 static int sun4i_prepare_for_irq(struct iio_dev *indio_dev, int channel,
 				 unsigned int irq)
 {
@@ -247,6 +271,17 @@ static int sun4i_gpadc_temp_read(struct iio_dev *indio_dev, int *val)
 {
 	struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
 
+	if (info->no_irq) {
+		pm_runtime_get_sync(indio_dev->dev.parent);
+
+		regmap_read(info->regmap, SUN4I_GPADC_TEMP_DATA, val);
+
+		pm_runtime_mark_last_busy(indio_dev->dev.parent);
+		pm_runtime_put_autosuspend(indio_dev->dev.parent);
+
+		return 0;
+	}
+
 	return sun4i_gpadc_read(indio_dev, 0, val, info->temp_data_irq);
 }
 
@@ -454,6 +489,58 @@ static int sun4i_irq_init(struct platform_device *pdev, const char *name,
 	return 0;
 }
 
+static const struct of_device_id sun4i_gpadc_of_id[] = {
+	{
+		.compatible = "allwinner,sun8i-a33-gpadc-iio",
+		.data = &sun8i_a33_gpadc_data,
+	},
+	{ /* sentinel */ }
+};
+
+static int sun4i_gpadc_probe_dt(struct platform_device *pdev,
+				struct iio_dev *indio_dev)
+{
+	struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
+	const struct of_device_id *of_dev;
+	struct thermal_zone_device *tzd;
+	struct resource *mem;
+	void __iomem *base;
+	int ret;
+
+	of_dev = of_match_device(sun4i_gpadc_of_id, &pdev->dev);
+	if (!of_dev)
+		return -ENODEV;
+
+	info->no_irq = true;
+	info->data = (struct gpadc_data *)of_dev->data;
+	indio_dev->num_channels = ARRAY_SIZE(sun8i_a33_gpadc_channels);
+	indio_dev->channels = sun8i_a33_gpadc_channels;
+
+	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	base = devm_ioremap_resource(&pdev->dev, mem);
+	if (IS_ERR(base))
+		return PTR_ERR(base);
+
+	info->regmap = devm_regmap_init_mmio(&pdev->dev, base,
+					     &sun4i_gpadc_regmap_config);
+	if (IS_ERR(info->regmap)) {
+		ret = PTR_ERR(info->regmap);
+		dev_err(&pdev->dev, "failed to init regmap: %d\n", ret);
+		return ret;
+	}
+
+	if (!IS_ENABLED(THERMAL_OF))
+		return 0;
+
+	tzd = devm_thermal_zone_of_sensor_register(&pdev->dev, 0, info,
+						   &sun4i_ts_tz_ops);
+	if (IS_ERR(tzd))
+		dev_err(&pdev->dev, "could not register thermal sensor: %ld\n",
+			PTR_ERR(tzd));
+
+	return PTR_ERR_OR_ZERO(tzd);
+}
+
 static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
 				 struct iio_dev *indio_dev)
 {
@@ -462,6 +549,7 @@ static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
 		dev_get_drvdata(pdev->dev.parent);
 	int ret;
 
+	info->no_irq = false;
 	info->regmap = sun4i_gpadc_dev->regmap;
 
 	indio_dev->num_channels = ARRAY_SIZE(sun4i_gpadc_channels);
@@ -561,7 +649,11 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
 	indio_dev->info = &sun4i_gpadc_iio_info;
 	indio_dev->modes = INDIO_DIRECT_MODE;
 
-	ret = sun4i_gpadc_probe_mfd(pdev, indio_dev);
+	if (pdev->dev.of_node)
+		ret = sun4i_gpadc_probe_dt(pdev, indio_dev);
+	else
+		ret = sun4i_gpadc_probe_mfd(pdev, indio_dev);
+
 	if (ret)
 		return ret;
 
@@ -580,7 +672,7 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
 	return 0;
 
 err_map:
-	if (IS_ENABLED(CONFIG_THERMAL_OF))
+	if (!info->no_irq && IS_ENABLED(CONFIG_THERMAL_OF))
 		iio_map_array_unregister(indio_dev);
 
 	pm_runtime_put(&pdev->dev);
@@ -592,10 +684,11 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
 static int sun4i_gpadc_remove(struct platform_device *pdev)
 {
 	struct iio_dev *indio_dev = platform_get_drvdata(pdev);
+	struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
 
 	pm_runtime_put(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
-	if (IS_ENABLED(CONFIG_THERMAL_OF))
+	if (!info->no_irq && IS_ENABLED(CONFIG_THERMAL_OF))
 		iio_map_array_unregister(indio_dev);
 
 	return 0;
@@ -611,6 +704,7 @@ static const struct platform_device_id sun4i_gpadc_id[] = {
 static struct platform_driver sun4i_gpadc_driver = {
 	.driver = {
 		.name = "sun4i-gpadc-iio",
+		.of_match_table = sun4i_gpadc_of_id,
 		.pm = &sun4i_gpadc_pm_ops,
 	},
 	.id_table = sun4i_gpadc_id,
diff --git a/include/linux/mfd/sun4i-gpadc.h b/include/linux/mfd/sun4i-gpadc.h
index 509e736..139872c 100644
--- a/include/linux/mfd/sun4i-gpadc.h
+++ b/include/linux/mfd/sun4i-gpadc.h
@@ -38,6 +38,10 @@
 #define SUN6I_GPADC_CTRL1_ADC_CHAN_SELECT(x)		(GENMASK(3, 0) & BIT(x))
 #define SUN6I_GPADC_CTRL1_ADC_CHAN_MASK			GENMASK(3, 0)
 
+/* TP_CTRL1 bits for sun8i SoCs */
+#define SUN8I_GPADC_CTRL1_CHOP_TEMP_EN			BIT(8)
+#define SUN8I_GPADC_CTRL1_GPADC_CALI_EN			BIT(7)
+
 #define SUN4I_GPADC_CTRL2				0x08
 
 #define SUN4I_GPADC_CTRL2_TP_SENSITIVE_ADJUST(x)	((GENMASK(3, 0) & (x)) << 28)
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH v2 08/11] iio: adc: sun4i-gpadc-iio: add support for A33 thermal sensor
@ 2017-03-10 10:39   ` Quentin Schulz
  0 siblings, 0 replies; 85+ messages in thread
From: Quentin Schulz @ 2017-03-10 10:39 UTC (permalink / raw)
  To: linux-arm-kernel

This adds support for the Allwinner A33 thermal sensor.

Unlike the A10, A13 and A31, the Allwinner A33 only has one channel
which is dedicated to the thermal sensor. Moreover, its thermal sensor
does not generate interruptions, thus we only need to directly read the
register storing the temperature value.

The MFD used by the A10, A13 and A31, was created to avoid breaking the
DT binding, but since the nodes for the ADC weren't there for the A33,
it is not needed.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
---

v2:
  - removed added comments in Kconfig,
  - simplified Kconfig depends on condition,
  - removed THERMAL_OF requirement for sun8i,
  - renamed sun8i_gpadc_channels to sun8i_a33_gpadc_channels,
  - renamed use_dt boolean in no_irq as it reflects better why we need it,
  - removed spurious/unneeded modifications done in v1,

 drivers/iio/adc/Kconfig           |   2 +-
 drivers/iio/adc/sun4i-gpadc-iio.c | 100 ++++++++++++++++++++++++++++++++++++--
 include/linux/mfd/sun4i-gpadc.h   |   4 ++
 3 files changed, 102 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
index 9f8b4b1..8c8ead6 100644
--- a/drivers/iio/adc/Kconfig
+++ b/drivers/iio/adc/Kconfig
@@ -562,7 +562,7 @@ config STX104
 config SUN4I_GPADC
 	tristate "Support for the Allwinner SoCs GPADC"
 	depends on IIO
-	depends on MFD_SUN4I_GPADC
+	depends on MFD_SUN4I_GPADC || MACH_SUN8I
 	help
 	  Say yes here to build support for Allwinner (A10, A13 and A31) SoCs
 	  GPADC. This ADC provides 4 channels which can be used as an ADC or as
diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c
index 7cb997a..70684cd 100644
--- a/drivers/iio/adc/sun4i-gpadc-iio.c
+++ b/drivers/iio/adc/sun4i-gpadc-iio.c
@@ -85,6 +85,12 @@ static const struct gpadc_data sun6i_gpadc_data = {
 	.adc_chan_mask = SUN6I_GPADC_CTRL1_ADC_CHAN_MASK,
 };
 
+static const struct gpadc_data sun8i_a33_gpadc_data = {
+	.temp_offset = -1662,
+	.temp_scale = 162,
+	.tp_mode_en = SUN8I_GPADC_CTRL1_CHOP_TEMP_EN,
+};
+
 struct sun4i_gpadc_iio {
 	struct iio_dev			*indio_dev;
 	struct completion		completion;
@@ -96,6 +102,7 @@ struct sun4i_gpadc_iio {
 	unsigned int			temp_data_irq;
 	atomic_t			ignore_temp_data_irq;
 	const struct gpadc_data		*data;
+	bool				no_irq;
 	/* prevents concurrent reads of temperature and ADC */
 	struct mutex			mutex;
 };
@@ -138,6 +145,23 @@ static const struct iio_chan_spec sun4i_gpadc_channels_no_temp[] = {
 	SUN4I_GPADC_ADC_CHANNEL(3, "adc_chan3"),
 };
 
+static const struct iio_chan_spec sun8i_a33_gpadc_channels[] = {
+	{
+		.type = IIO_TEMP,
+		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
+				      BIT(IIO_CHAN_INFO_SCALE) |
+				      BIT(IIO_CHAN_INFO_OFFSET),
+		.datasheet_name = "temp_adc",
+	},
+};
+
+static const struct regmap_config sun4i_gpadc_regmap_config = {
+	.reg_bits = 32,
+	.val_bits = 32,
+	.reg_stride = 4,
+	.fast_io = true,
+};
+
 static int sun4i_prepare_for_irq(struct iio_dev *indio_dev, int channel,
 				 unsigned int irq)
 {
@@ -247,6 +271,17 @@ static int sun4i_gpadc_temp_read(struct iio_dev *indio_dev, int *val)
 {
 	struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
 
+	if (info->no_irq) {
+		pm_runtime_get_sync(indio_dev->dev.parent);
+
+		regmap_read(info->regmap, SUN4I_GPADC_TEMP_DATA, val);
+
+		pm_runtime_mark_last_busy(indio_dev->dev.parent);
+		pm_runtime_put_autosuspend(indio_dev->dev.parent);
+
+		return 0;
+	}
+
 	return sun4i_gpadc_read(indio_dev, 0, val, info->temp_data_irq);
 }
 
@@ -454,6 +489,58 @@ static int sun4i_irq_init(struct platform_device *pdev, const char *name,
 	return 0;
 }
 
+static const struct of_device_id sun4i_gpadc_of_id[] = {
+	{
+		.compatible = "allwinner,sun8i-a33-gpadc-iio",
+		.data = &sun8i_a33_gpadc_data,
+	},
+	{ /* sentinel */ }
+};
+
+static int sun4i_gpadc_probe_dt(struct platform_device *pdev,
+				struct iio_dev *indio_dev)
+{
+	struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
+	const struct of_device_id *of_dev;
+	struct thermal_zone_device *tzd;
+	struct resource *mem;
+	void __iomem *base;
+	int ret;
+
+	of_dev = of_match_device(sun4i_gpadc_of_id, &pdev->dev);
+	if (!of_dev)
+		return -ENODEV;
+
+	info->no_irq = true;
+	info->data = (struct gpadc_data *)of_dev->data;
+	indio_dev->num_channels = ARRAY_SIZE(sun8i_a33_gpadc_channels);
+	indio_dev->channels = sun8i_a33_gpadc_channels;
+
+	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	base = devm_ioremap_resource(&pdev->dev, mem);
+	if (IS_ERR(base))
+		return PTR_ERR(base);
+
+	info->regmap = devm_regmap_init_mmio(&pdev->dev, base,
+					     &sun4i_gpadc_regmap_config);
+	if (IS_ERR(info->regmap)) {
+		ret = PTR_ERR(info->regmap);
+		dev_err(&pdev->dev, "failed to init regmap: %d\n", ret);
+		return ret;
+	}
+
+	if (!IS_ENABLED(THERMAL_OF))
+		return 0;
+
+	tzd = devm_thermal_zone_of_sensor_register(&pdev->dev, 0, info,
+						   &sun4i_ts_tz_ops);
+	if (IS_ERR(tzd))
+		dev_err(&pdev->dev, "could not register thermal sensor: %ld\n",
+			PTR_ERR(tzd));
+
+	return PTR_ERR_OR_ZERO(tzd);
+}
+
 static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
 				 struct iio_dev *indio_dev)
 {
@@ -462,6 +549,7 @@ static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
 		dev_get_drvdata(pdev->dev.parent);
 	int ret;
 
+	info->no_irq = false;
 	info->regmap = sun4i_gpadc_dev->regmap;
 
 	indio_dev->num_channels = ARRAY_SIZE(sun4i_gpadc_channels);
@@ -561,7 +649,11 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
 	indio_dev->info = &sun4i_gpadc_iio_info;
 	indio_dev->modes = INDIO_DIRECT_MODE;
 
-	ret = sun4i_gpadc_probe_mfd(pdev, indio_dev);
+	if (pdev->dev.of_node)
+		ret = sun4i_gpadc_probe_dt(pdev, indio_dev);
+	else
+		ret = sun4i_gpadc_probe_mfd(pdev, indio_dev);
+
 	if (ret)
 		return ret;
 
@@ -580,7 +672,7 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
 	return 0;
 
 err_map:
-	if (IS_ENABLED(CONFIG_THERMAL_OF))
+	if (!info->no_irq && IS_ENABLED(CONFIG_THERMAL_OF))
 		iio_map_array_unregister(indio_dev);
 
 	pm_runtime_put(&pdev->dev);
@@ -592,10 +684,11 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
 static int sun4i_gpadc_remove(struct platform_device *pdev)
 {
 	struct iio_dev *indio_dev = platform_get_drvdata(pdev);
+	struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
 
 	pm_runtime_put(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
-	if (IS_ENABLED(CONFIG_THERMAL_OF))
+	if (!info->no_irq && IS_ENABLED(CONFIG_THERMAL_OF))
 		iio_map_array_unregister(indio_dev);
 
 	return 0;
@@ -611,6 +704,7 @@ static const struct platform_device_id sun4i_gpadc_id[] = {
 static struct platform_driver sun4i_gpadc_driver = {
 	.driver = {
 		.name = "sun4i-gpadc-iio",
+		.of_match_table = sun4i_gpadc_of_id,
 		.pm = &sun4i_gpadc_pm_ops,
 	},
 	.id_table = sun4i_gpadc_id,
diff --git a/include/linux/mfd/sun4i-gpadc.h b/include/linux/mfd/sun4i-gpadc.h
index 509e736..139872c 100644
--- a/include/linux/mfd/sun4i-gpadc.h
+++ b/include/linux/mfd/sun4i-gpadc.h
@@ -38,6 +38,10 @@
 #define SUN6I_GPADC_CTRL1_ADC_CHAN_SELECT(x)		(GENMASK(3, 0) & BIT(x))
 #define SUN6I_GPADC_CTRL1_ADC_CHAN_MASK			GENMASK(3, 0)
 
+/* TP_CTRL1 bits for sun8i SoCs */
+#define SUN8I_GPADC_CTRL1_CHOP_TEMP_EN			BIT(8)
+#define SUN8I_GPADC_CTRL1_GPADC_CALI_EN			BIT(7)
+
 #define SUN4I_GPADC_CTRL2				0x08
 
 #define SUN4I_GPADC_CTRL2_TP_SENSITIVE_ADJUST(x)	((GENMASK(3, 0) & (x)) << 28)
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH v2 09/11] ARM: dtsi: sun8i: a33: add thermal sensor
@ 2017-03-10 10:39   ` Quentin Schulz
  0 siblings, 0 replies; 85+ messages in thread
From: Quentin Schulz @ 2017-03-10 10:39 UTC (permalink / raw)
  To: dmitry.torokhov, robh+dt, mark.rutland, maxime.ripard, wens,
	lee.jones, linux, jic23, knaack.h, lars, pmeerw,
	stefan.mavrodiev
  Cc: Quentin Schulz, devicetree, linux-arm-kernel, linux-kernel,
	linux-iio, linux-sunxi, thomas.petazzoni

This adds the DT node for the thermal sensor present in the Allwinner
A33 GPADC.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
---
 arch/arm/boot/dts/sun8i-a33.dtsi | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/sun8i-a33.dtsi b/arch/arm/boot/dts/sun8i-a33.dtsi
index ba87a9e..704f2b0 100644
--- a/arch/arm/boot/dts/sun8i-a33.dtsi
+++ b/arch/arm/boot/dts/sun8i-a33.dtsi
@@ -278,6 +278,13 @@
 			status = "disabled";
 		};
 
+		rtp: rtp@01c25000 {
+			compatible = "allwinner,sun8i-a33-gpadc-iio";
+			reg = <0x01c25000 0x100>;
+			#thermal-sensor-cells = <0>;
+			#io-channel-cells = <0>;
+		};
+
 		fe0: display-frontend@01e00000 {
 			compatible = "allwinner,sun8i-a33-display-frontend";
 			reg = <0x01e00000 0x20000>;
@@ -388,6 +395,11 @@
 			};
 		};
 	};
+
+	iio-hwmon {
+		compatible = "iio-hwmon";
+		io-channels = <&rtp>;
+	};
 };
 
 &ccu {
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH v2 09/11] ARM: dtsi: sun8i: a33: add thermal sensor
@ 2017-03-10 10:39   ` Quentin Schulz
  0 siblings, 0 replies; 85+ messages in thread
From: Quentin Schulz @ 2017-03-10 10:39 UTC (permalink / raw)
  To: dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8, wens-jdAy2FN1RRM,
	lee.jones-QSEj5FYQhm4dnm+yROfE0A, linux-I+IVW8TIWO2tmTQ+vhA3Yw,
	jic23-DgEjT+Ai2ygdnm+yROfE0A, knaack.h-Mmb7MZpHnFY,
	lars-Qo5EllUWu/uELgA04lAiVw, pmeerw-jW+XmwGofnusTnJN9+BGXg,
	stefan.mavrodiev-Re5JQEeQqe8AvxtiuMwx3w
  Cc: Quentin Schulz, devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-iio-u79uwXL29TY76Z2rM5mHXA,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
	thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8

This adds the DT node for the thermal sensor present in the Allwinner
A33 GPADC.

Signed-off-by: Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
---
 arch/arm/boot/dts/sun8i-a33.dtsi | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/sun8i-a33.dtsi b/arch/arm/boot/dts/sun8i-a33.dtsi
index ba87a9e..704f2b0 100644
--- a/arch/arm/boot/dts/sun8i-a33.dtsi
+++ b/arch/arm/boot/dts/sun8i-a33.dtsi
@@ -278,6 +278,13 @@
 			status = "disabled";
 		};
 
+		rtp: rtp@01c25000 {
+			compatible = "allwinner,sun8i-a33-gpadc-iio";
+			reg = <0x01c25000 0x100>;
+			#thermal-sensor-cells = <0>;
+			#io-channel-cells = <0>;
+		};
+
 		fe0: display-frontend@01e00000 {
 			compatible = "allwinner,sun8i-a33-display-frontend";
 			reg = <0x01e00000 0x20000>;
@@ -388,6 +395,11 @@
 			};
 		};
 	};
+
+	iio-hwmon {
+		compatible = "iio-hwmon";
+		io-channels = <&rtp>;
+	};
 };
 
 &ccu {
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH v2 09/11] ARM: dtsi: sun8i: a33: add thermal sensor
@ 2017-03-10 10:39   ` Quentin Schulz
  0 siblings, 0 replies; 85+ messages in thread
From: Quentin Schulz @ 2017-03-10 10:39 UTC (permalink / raw)
  To: linux-arm-kernel

This adds the DT node for the thermal sensor present in the Allwinner
A33 GPADC.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
---
 arch/arm/boot/dts/sun8i-a33.dtsi | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/sun8i-a33.dtsi b/arch/arm/boot/dts/sun8i-a33.dtsi
index ba87a9e..704f2b0 100644
--- a/arch/arm/boot/dts/sun8i-a33.dtsi
+++ b/arch/arm/boot/dts/sun8i-a33.dtsi
@@ -278,6 +278,13 @@
 			status = "disabled";
 		};
 
+		rtp: rtp at 01c25000 {
+			compatible = "allwinner,sun8i-a33-gpadc-iio";
+			reg = <0x01c25000 0x100>;
+			#thermal-sensor-cells = <0>;
+			#io-channel-cells = <0>;
+		};
+
 		fe0: display-frontend at 01e00000 {
 			compatible = "allwinner,sun8i-a33-display-frontend";
 			reg = <0x01e00000 0x20000>;
@@ -388,6 +395,11 @@
 			};
 		};
 	};
+
+	iio-hwmon {
+		compatible = "iio-hwmon";
+		io-channels = <&rtp>;
+	};
 };
 
 &ccu {
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH v2 10/11] ARM: dtsi: sun8i: a33: add CPU thermal throttling
@ 2017-03-10 10:39   ` Quentin Schulz
  0 siblings, 0 replies; 85+ messages in thread
From: Quentin Schulz @ 2017-03-10 10:39 UTC (permalink / raw)
  To: dmitry.torokhov, robh+dt, mark.rutland, maxime.ripard, wens,
	lee.jones, linux, jic23, knaack.h, lars, pmeerw,
	stefan.mavrodiev
  Cc: Quentin Schulz, devicetree, linux-arm-kernel, linux-kernel,
	linux-iio, linux-sunxi, thomas.petazzoni

This adds CPU thermal throttling for the Allwinner A33. It uses the
thermal sensor present in the SoC's GPADC.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
---

v2:
  - updated cooling-max-level to reflect newly added OPPs,

 arch/arm/boot/dts/sun8i-a33.dtsi | 47 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/arch/arm/boot/dts/sun8i-a33.dtsi b/arch/arm/boot/dts/sun8i-a33.dtsi
index 704f2b0..df6e77f 100644
--- a/arch/arm/boot/dts/sun8i-a33.dtsi
+++ b/arch/arm/boot/dts/sun8i-a33.dtsi
@@ -43,6 +43,7 @@
  */
 
 #include "sun8i-a23-a33.dtsi"
+#include <dt-bindings/thermal/thermal.h>
 
 / {
 	cpu0_opp_table: opp_table0 {
@@ -139,6 +140,9 @@
 			clocks = <&ccu CLK_CPUX>;
 			clock-names = "cpu";
 			operating-points-v2 = <&cpu0_opp_table>;
+			cooling-min-level = <0>;
+			cooling-max-level = <13>;
+			#cooling-cells = <2>;
 		};
 
 		cpu@1 {
@@ -182,6 +186,49 @@
 		};
 	};
 
+	thermal-zones {
+		cpu_thermal {
+			/* milliseconds */
+			polling-delay-passive = <250>;
+			polling-delay = <1000>;
+			thermal-sensors = <&rtp>;
+
+			cooling-maps {
+				map0 {
+					trip = <&cpu_alert0>;
+					cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
+				};
+				map1 {
+					trip = <&cpu_alert1>;
+					cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
+				};
+			};
+
+			trips {
+				cpu_alert0: cpu_alert0 {
+					/* milliCelsius */
+					temperature = <75000>;
+					hysteresis = <2000>;
+					type = "passive";
+				};
+
+				cpu_alert1: cpu_alert1 {
+					/* milliCelsius */
+					temperature = <90000>;
+					hysteresis = <2000>;
+					type = "hot";
+				};
+
+				cpu_crit: cpu_crit {
+					/* milliCelsius */
+					temperature = <110000>;
+					hysteresis = <2000>;
+					type = "critical";
+				};
+			};
+		};
+	};
+
 	memory {
 		reg = <0x40000000 0x80000000>;
 	};
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH v2 10/11] ARM: dtsi: sun8i: a33: add CPU thermal throttling
@ 2017-03-10 10:39   ` Quentin Schulz
  0 siblings, 0 replies; 85+ messages in thread
From: Quentin Schulz @ 2017-03-10 10:39 UTC (permalink / raw)
  To: dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8, wens-jdAy2FN1RRM,
	lee.jones-QSEj5FYQhm4dnm+yROfE0A, linux-I+IVW8TIWO2tmTQ+vhA3Yw,
	jic23-DgEjT+Ai2ygdnm+yROfE0A, knaack.h-Mmb7MZpHnFY,
	lars-Qo5EllUWu/uELgA04lAiVw, pmeerw-jW+XmwGofnusTnJN9+BGXg,
	stefan.mavrodiev-Re5JQEeQqe8AvxtiuMwx3w
  Cc: Quentin Schulz, devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-iio-u79uwXL29TY76Z2rM5mHXA,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
	thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8

This adds CPU thermal throttling for the Allwinner A33. It uses the
thermal sensor present in the SoC's GPADC.

Signed-off-by: Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
---

v2:
  - updated cooling-max-level to reflect newly added OPPs,

 arch/arm/boot/dts/sun8i-a33.dtsi | 47 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/arch/arm/boot/dts/sun8i-a33.dtsi b/arch/arm/boot/dts/sun8i-a33.dtsi
index 704f2b0..df6e77f 100644
--- a/arch/arm/boot/dts/sun8i-a33.dtsi
+++ b/arch/arm/boot/dts/sun8i-a33.dtsi
@@ -43,6 +43,7 @@
  */
 
 #include "sun8i-a23-a33.dtsi"
+#include <dt-bindings/thermal/thermal.h>
 
 / {
 	cpu0_opp_table: opp_table0 {
@@ -139,6 +140,9 @@
 			clocks = <&ccu CLK_CPUX>;
 			clock-names = "cpu";
 			operating-points-v2 = <&cpu0_opp_table>;
+			cooling-min-level = <0>;
+			cooling-max-level = <13>;
+			#cooling-cells = <2>;
 		};
 
 		cpu@1 {
@@ -182,6 +186,49 @@
 		};
 	};
 
+	thermal-zones {
+		cpu_thermal {
+			/* milliseconds */
+			polling-delay-passive = <250>;
+			polling-delay = <1000>;
+			thermal-sensors = <&rtp>;
+
+			cooling-maps {
+				map0 {
+					trip = <&cpu_alert0>;
+					cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
+				};
+				map1 {
+					trip = <&cpu_alert1>;
+					cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
+				};
+			};
+
+			trips {
+				cpu_alert0: cpu_alert0 {
+					/* milliCelsius */
+					temperature = <75000>;
+					hysteresis = <2000>;
+					type = "passive";
+				};
+
+				cpu_alert1: cpu_alert1 {
+					/* milliCelsius */
+					temperature = <90000>;
+					hysteresis = <2000>;
+					type = "hot";
+				};
+
+				cpu_crit: cpu_crit {
+					/* milliCelsius */
+					temperature = <110000>;
+					hysteresis = <2000>;
+					type = "critical";
+				};
+			};
+		};
+	};
+
 	memory {
 		reg = <0x40000000 0x80000000>;
 	};
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH v2 10/11] ARM: dtsi: sun8i: a33: add CPU thermal throttling
@ 2017-03-10 10:39   ` Quentin Schulz
  0 siblings, 0 replies; 85+ messages in thread
From: Quentin Schulz @ 2017-03-10 10:39 UTC (permalink / raw)
  To: linux-arm-kernel

This adds CPU thermal throttling for the Allwinner A33. It uses the
thermal sensor present in the SoC's GPADC.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
---

v2:
  - updated cooling-max-level to reflect newly added OPPs,

 arch/arm/boot/dts/sun8i-a33.dtsi | 47 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/arch/arm/boot/dts/sun8i-a33.dtsi b/arch/arm/boot/dts/sun8i-a33.dtsi
index 704f2b0..df6e77f 100644
--- a/arch/arm/boot/dts/sun8i-a33.dtsi
+++ b/arch/arm/boot/dts/sun8i-a33.dtsi
@@ -43,6 +43,7 @@
  */
 
 #include "sun8i-a23-a33.dtsi"
+#include <dt-bindings/thermal/thermal.h>
 
 / {
 	cpu0_opp_table: opp_table0 {
@@ -139,6 +140,9 @@
 			clocks = <&ccu CLK_CPUX>;
 			clock-names = "cpu";
 			operating-points-v2 = <&cpu0_opp_table>;
+			cooling-min-level = <0>;
+			cooling-max-level = <13>;
+			#cooling-cells = <2>;
 		};
 
 		cpu at 1 {
@@ -182,6 +186,49 @@
 		};
 	};
 
+	thermal-zones {
+		cpu_thermal {
+			/* milliseconds */
+			polling-delay-passive = <250>;
+			polling-delay = <1000>;
+			thermal-sensors = <&rtp>;
+
+			cooling-maps {
+				map0 {
+					trip = <&cpu_alert0>;
+					cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
+				};
+				map1 {
+					trip = <&cpu_alert1>;
+					cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
+				};
+			};
+
+			trips {
+				cpu_alert0: cpu_alert0 {
+					/* milliCelsius */
+					temperature = <75000>;
+					hysteresis = <2000>;
+					type = "passive";
+				};
+
+				cpu_alert1: cpu_alert1 {
+					/* milliCelsius */
+					temperature = <90000>;
+					hysteresis = <2000>;
+					type = "hot";
+				};
+
+				cpu_crit: cpu_crit {
+					/* milliCelsius */
+					temperature = <110000>;
+					hysteresis = <2000>;
+					type = "critical";
+				};
+			};
+		};
+	};
+
 	memory {
 		reg = <0x40000000 0x80000000>;
 	};
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH v2 11/11] ARM: sun8i: a33: Add devfreq-based GPU cooling
@ 2017-03-10 10:39   ` Quentin Schulz
  0 siblings, 0 replies; 85+ messages in thread
From: Quentin Schulz @ 2017-03-10 10:39 UTC (permalink / raw)
  To: dmitry.torokhov, robh+dt, mark.rutland, maxime.ripard, wens,
	lee.jones, linux, jic23, knaack.h, lars, pmeerw,
	stefan.mavrodiev
  Cc: devicetree, linux-arm-kernel, linux-kernel, linux-iio,
	linux-sunxi, thomas.petazzoni, Quentin Schulz

From: Maxime Ripard <maxime.ripard@free-electrons.com>

This adds GPU thermal throttling for the Allwinner A33.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
---

added in v2

 arch/arm/boot/dts/sun8i-a23-a33.dtsi |  3 +++
 arch/arm/boot/dts/sun8i-a33.dtsi     | 24 ++++++++++++++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/arch/arm/boot/dts/sun8i-a23-a33.dtsi b/arch/arm/boot/dts/sun8i-a23-a33.dtsi
index 5e8725d..dc4e942 100644
--- a/arch/arm/boot/dts/sun8i-a23-a33.dtsi
+++ b/arch/arm/boot/dts/sun8i-a23-a33.dtsi
@@ -495,6 +495,9 @@
 
 			assigned-clocks = <&ccu CLK_GPU>;
 			assigned-clock-rates = <384000000>;
+			cooling-min-level = <0>;
+			cooling-max-level = <2>;
+			#cooling-cells = <2>;
 		};
 
 		gic: interrupt-controller@01c81000 {
diff --git a/arch/arm/boot/dts/sun8i-a33.dtsi b/arch/arm/boot/dts/sun8i-a33.dtsi
index df6e77f..6552762 100644
--- a/arch/arm/boot/dts/sun8i-a33.dtsi
+++ b/arch/arm/boot/dts/sun8i-a33.dtsi
@@ -202,6 +202,16 @@
 					trip = <&cpu_alert1>;
 					cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
 				};
+
+				map2 {
+					trip = <&gpu_alert0>;
+					cooling-device = <&mali 1 THERMAL_NO_LIMIT>;
+				};
+
+				map3 {
+					trip = <&gpu_alert1>;
+					cooling-device = <&mali 2 THERMAL_NO_LIMIT>;
+				};
 			};
 
 			trips {
@@ -212,6 +222,13 @@
 					type = "passive";
 				};
 
+				gpu_alert0: gpu_alert0 {
+					/* milliCelsius */
+					temperature = <85000>;
+					hysteresis = <2000>;
+					type = "passive";
+				};
+
 				cpu_alert1: cpu_alert1 {
 					/* milliCelsius */
 					temperature = <90000>;
@@ -219,6 +236,13 @@
 					type = "hot";
 				};
 
+				gpu_alert1: gpu_alert1 {
+					/* milliCelsius */
+					temperature = <95000>;
+					hysteresis = <2000>;
+					type = "hot";
+				};
+
 				cpu_crit: cpu_crit {
 					/* milliCelsius */
 					temperature = <110000>;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH v2 11/11] ARM: sun8i: a33: Add devfreq-based GPU cooling
@ 2017-03-10 10:39   ` Quentin Schulz
  0 siblings, 0 replies; 85+ messages in thread
From: Quentin Schulz @ 2017-03-10 10:39 UTC (permalink / raw)
  To: dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8, wens-jdAy2FN1RRM,
	lee.jones-QSEj5FYQhm4dnm+yROfE0A, linux-I+IVW8TIWO2tmTQ+vhA3Yw,
	jic23-DgEjT+Ai2ygdnm+yROfE0A, knaack.h-Mmb7MZpHnFY,
	lars-Qo5EllUWu/uELgA04lAiVw, pmeerw-jW+XmwGofnusTnJN9+BGXg,
	stefan.mavrodiev-Re5JQEeQqe8AvxtiuMwx3w
  Cc: devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-iio-u79uwXL29TY76Z2rM5mHXA,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
	thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
	Quentin Schulz

From: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>

This adds GPU thermal throttling for the Allwinner A33.

Signed-off-by: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
Signed-off-by: Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
---

added in v2

 arch/arm/boot/dts/sun8i-a23-a33.dtsi |  3 +++
 arch/arm/boot/dts/sun8i-a33.dtsi     | 24 ++++++++++++++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/arch/arm/boot/dts/sun8i-a23-a33.dtsi b/arch/arm/boot/dts/sun8i-a23-a33.dtsi
index 5e8725d..dc4e942 100644
--- a/arch/arm/boot/dts/sun8i-a23-a33.dtsi
+++ b/arch/arm/boot/dts/sun8i-a23-a33.dtsi
@@ -495,6 +495,9 @@
 
 			assigned-clocks = <&ccu CLK_GPU>;
 			assigned-clock-rates = <384000000>;
+			cooling-min-level = <0>;
+			cooling-max-level = <2>;
+			#cooling-cells = <2>;
 		};
 
 		gic: interrupt-controller@01c81000 {
diff --git a/arch/arm/boot/dts/sun8i-a33.dtsi b/arch/arm/boot/dts/sun8i-a33.dtsi
index df6e77f..6552762 100644
--- a/arch/arm/boot/dts/sun8i-a33.dtsi
+++ b/arch/arm/boot/dts/sun8i-a33.dtsi
@@ -202,6 +202,16 @@
 					trip = <&cpu_alert1>;
 					cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
 				};
+
+				map2 {
+					trip = <&gpu_alert0>;
+					cooling-device = <&mali 1 THERMAL_NO_LIMIT>;
+				};
+
+				map3 {
+					trip = <&gpu_alert1>;
+					cooling-device = <&mali 2 THERMAL_NO_LIMIT>;
+				};
 			};
 
 			trips {
@@ -212,6 +222,13 @@
 					type = "passive";
 				};
 
+				gpu_alert0: gpu_alert0 {
+					/* milliCelsius */
+					temperature = <85000>;
+					hysteresis = <2000>;
+					type = "passive";
+				};
+
 				cpu_alert1: cpu_alert1 {
 					/* milliCelsius */
 					temperature = <90000>;
@@ -219,6 +236,13 @@
 					type = "hot";
 				};
 
+				gpu_alert1: gpu_alert1 {
+					/* milliCelsius */
+					temperature = <95000>;
+					hysteresis = <2000>;
+					type = "hot";
+				};
+
 				cpu_crit: cpu_crit {
 					/* milliCelsius */
 					temperature = <110000>;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 85+ messages in thread

* [PATCH v2 11/11] ARM: sun8i: a33: Add devfreq-based GPU cooling
@ 2017-03-10 10:39   ` Quentin Schulz
  0 siblings, 0 replies; 85+ messages in thread
From: Quentin Schulz @ 2017-03-10 10:39 UTC (permalink / raw)
  To: linux-arm-kernel

From: Maxime Ripard <maxime.ripard@free-electrons.com>

This adds GPU thermal throttling for the Allwinner A33.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
---

added in v2

 arch/arm/boot/dts/sun8i-a23-a33.dtsi |  3 +++
 arch/arm/boot/dts/sun8i-a33.dtsi     | 24 ++++++++++++++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/arch/arm/boot/dts/sun8i-a23-a33.dtsi b/arch/arm/boot/dts/sun8i-a23-a33.dtsi
index 5e8725d..dc4e942 100644
--- a/arch/arm/boot/dts/sun8i-a23-a33.dtsi
+++ b/arch/arm/boot/dts/sun8i-a23-a33.dtsi
@@ -495,6 +495,9 @@
 
 			assigned-clocks = <&ccu CLK_GPU>;
 			assigned-clock-rates = <384000000>;
+			cooling-min-level = <0>;
+			cooling-max-level = <2>;
+			#cooling-cells = <2>;
 		};
 
 		gic: interrupt-controller at 01c81000 {
diff --git a/arch/arm/boot/dts/sun8i-a33.dtsi b/arch/arm/boot/dts/sun8i-a33.dtsi
index df6e77f..6552762 100644
--- a/arch/arm/boot/dts/sun8i-a33.dtsi
+++ b/arch/arm/boot/dts/sun8i-a33.dtsi
@@ -202,6 +202,16 @@
 					trip = <&cpu_alert1>;
 					cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
 				};
+
+				map2 {
+					trip = <&gpu_alert0>;
+					cooling-device = <&mali 1 THERMAL_NO_LIMIT>;
+				};
+
+				map3 {
+					trip = <&gpu_alert1>;
+					cooling-device = <&mali 2 THERMAL_NO_LIMIT>;
+				};
 			};
 
 			trips {
@@ -212,6 +222,13 @@
 					type = "passive";
 				};
 
+				gpu_alert0: gpu_alert0 {
+					/* milliCelsius */
+					temperature = <85000>;
+					hysteresis = <2000>;
+					type = "passive";
+				};
+
 				cpu_alert1: cpu_alert1 {
 					/* milliCelsius */
 					temperature = <90000>;
@@ -219,6 +236,13 @@
 					type = "hot";
 				};
 
+				gpu_alert1: gpu_alert1 {
+					/* milliCelsius */
+					temperature = <95000>;
+					hysteresis = <2000>;
+					type = "hot";
+				};
+
 				cpu_crit: cpu_crit {
 					/* milliCelsius */
 					temperature = <110000>;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 85+ messages in thread

* Re: [PATCH v2 05/11] Documentation: DT: bindings: mfd: add A33 GPADC binding
       [not found]   ` <20170310103921.19469-6-quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
  2017-03-10 19:25       ` Icenowy Zheng
@ 2017-03-10 12:25     ` Maxime Ripard
  0 siblings, 0 replies; 85+ messages in thread
From: Maxime Ripard @ 2017-03-10 12:25 UTC (permalink / raw)
  To: Quentin Schulz
  Cc: dmitry.torokhov, robh+dt, mark.rutland, wens, lee.jones, linux,
	jic23, knaack.h, lars, pmeerw, stefan.mavrodiev, devicetree,
	linux-arm-kernel, linux-kernel, linux-iio, linux-sunxi,
	thomas.petazzoni

[-- Attachment #1: Type: text/plain, Size: 1305 bytes --]

On Fri, Mar 10, 2017 at 11:39:15AM +0100, Quentin Schulz wrote:
> This patch adds documentation for the A33 GPADC binding.
> 
> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
> ---
> 
> added in v2
> 
>  .../devicetree/bindings/mfd/sun4i-gpadc.txt        | 59 ++++++++++++++++++++++
>  1 file changed, 59 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
> 
> diff --git a/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt b/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
> new file mode 100644
> index 0000000..17242c8
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
> @@ -0,0 +1,59 @@
> +Allwinner SoCs' GPADC Device Tree bindings
> +------------------------------------------
> +The Allwinner SoCs all have an ADC that can also act as a thermal sensor
> +and sometimes as a touchscreen controller.
> +
> +Required properties:
> +  - compatible: "sun8i-a33-gpadc-iio",

This doesn't match your example, and you shouldn't have IIO in
there. Compatibles shouldn't be tied to a given framework, since that
is Linux specific (and might even change in the future).

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH v2 05/11] Documentation: DT: bindings: mfd: add A33 GPADC binding
@ 2017-03-10 12:25     ` Maxime Ripard
  0 siblings, 0 replies; 85+ messages in thread
From: Maxime Ripard @ 2017-03-10 12:25 UTC (permalink / raw)
  To: Quentin Schulz
  Cc: dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	wens-jdAy2FN1RRM, lee.jones-QSEj5FYQhm4dnm+yROfE0A,
	linux-I+IVW8TIWO2tmTQ+vhA3Yw, jic23-DgEjT+Ai2ygdnm+yROfE0A,
	knaack.h-Mmb7MZpHnFY, lars-Qo5EllUWu/uELgA04lAiVw,
	pmeerw-jW+XmwGofnusTnJN9+BGXg,
	stefan.mavrodiev-Re5JQEeQqe8AvxtiuMwx3w,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-iio-u79uwXL29TY76Z2rM5mHXA,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
	thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8

[-- Attachment #1: Type: text/plain, Size: 1299 bytes --]

On Fri, Mar 10, 2017 at 11:39:15AM +0100, Quentin Schulz wrote:
> This patch adds documentation for the A33 GPADC binding.
> 
> Signed-off-by: Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> ---
> 
> added in v2
> 
>  .../devicetree/bindings/mfd/sun4i-gpadc.txt        | 59 ++++++++++++++++++++++
>  1 file changed, 59 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
> 
> diff --git a/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt b/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
> new file mode 100644
> index 0000000..17242c8
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
> @@ -0,0 +1,59 @@
> +Allwinner SoCs' GPADC Device Tree bindings
> +------------------------------------------
> +The Allwinner SoCs all have an ADC that can also act as a thermal sensor
> +and sometimes as a touchscreen controller.
> +
> +Required properties:
> +  - compatible: "sun8i-a33-gpadc-iio",

This doesn't match your example, and you shouldn't have IIO in
there. Compatibles shouldn't be tied to a given framework, since that
is Linux specific (and might even change in the future).

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 85+ messages in thread

* [PATCH v2 05/11] Documentation: DT: bindings: mfd: add A33 GPADC binding
@ 2017-03-10 12:25     ` Maxime Ripard
  0 siblings, 0 replies; 85+ messages in thread
From: Maxime Ripard @ 2017-03-10 12:25 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Mar 10, 2017 at 11:39:15AM +0100, Quentin Schulz wrote:
> This patch adds documentation for the A33 GPADC binding.
> 
> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
> ---
> 
> added in v2
> 
>  .../devicetree/bindings/mfd/sun4i-gpadc.txt        | 59 ++++++++++++++++++++++
>  1 file changed, 59 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
> 
> diff --git a/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt b/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
> new file mode 100644
> index 0000000..17242c8
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
> @@ -0,0 +1,59 @@
> +Allwinner SoCs' GPADC Device Tree bindings
> +------------------------------------------
> +The Allwinner SoCs all have an ADC that can also act as a thermal sensor
> +and sometimes as a touchscreen controller.
> +
> +Required properties:
> +  - compatible: "sun8i-a33-gpadc-iio",

This doesn't match your example, and you shouldn't have IIO in
there. Compatibles shouldn't be tied to a given framework, since that
is Linux specific (and might even change in the future).

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170310/dcdb3187/attachment.sig>

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH v2 05/11] Documentation: DT: bindings: mfd: add A33 GPADC binding
  2017-03-10 10:39   ` Quentin Schulz
  (?)
@ 2017-03-10 19:25       ` Icenowy Zheng
  -1 siblings, 0 replies; 85+ messages in thread
From: Icenowy Zheng @ 2017-03-10 19:25 UTC (permalink / raw)
  To: Quentin Schulz, dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8, wens-jdAy2FN1RRM,
	lee.jones-QSEj5FYQhm4dnm+yROfE0A, linux-I+IVW8TIWO2tmTQ+vhA3Yw,
	jic23-DgEjT+Ai2ygdnm+yROfE0A, knaack.h-Mmb7MZpHnFY,
	lars-Qo5EllUWu/uELgA04lAiVw, pmeerw-jW+XmwGofnusTnJN9+BGXg,
	stefan.mavrodiev-Re5JQEeQqe8AvxtiuMwx3w
  Cc: thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-iio-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r



10.03.2017, 18:56, "Quentin Schulz" <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>:
> This patch adds documentation for the A33 GPADC binding.
>
> Signed-off-by: Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> ---
>
> added in v2
>
>  .../devicetree/bindings/mfd/sun4i-gpadc.txt | 59 ++++++++++++++++++++++
>  1 file changed, 59 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
>
> diff --git a/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt b/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
> new file mode 100644
> index 0000000..17242c8
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
> @@ -0,0 +1,59 @@
> +Allwinner SoCs' GPADC Device Tree bindings
> +------------------------------------------
> +The Allwinner SoCs all have an ADC that can also act as a thermal sensor
> +and sometimes as a touchscreen controller.
> +
> +Required properties:
> + - compatible: "sun8i-a33-gpadc-iio",
> + - reg: mmio address range of the chip,
> + - #thermal-sensor-cells: shall be 0,
> + - #io-channel-cells: shall be 0,
> +
> +Example:
> + rtp: rtp@01c25000 {

I think we'd better call it ths.

And can you make thermal-sensor-cells become 1?

Maxime Ripard wants to base H3/H5/A64 thermal driver on this patchset, and
for H5/A64 there's 2/3 thermal sensors.

Thus for A33/H3 we will have thermal-sensor-cells to 1, but only have
<&ths 0>.

> + compatible = "allwinner,sun8i-a33-gpadc-iio";
> + reg = <0x01c25000 0x100>;
> + #thermal-sensor-cells = <0>;
> + #io-channel-cells = <0>;
> + };
> +
> +sun4i, sun5i and sun6i SoCs are also supported via the older binding:
> +
> +sun4i resistive touchscreen controller
> +--------------------------------------
> +
> +Required properties:
> + - compatible: "allwinner,sun4i-a10-ts", "allwinner,sun5i-a13-ts" or
> + "allwinner,sun6i-a31-ts"
> + - reg: mmio address range of the chip
> + - interrupts: interrupt to which the chip is connected
> + - #thermal-sensor-cells: shall be 0
> +
> +Optional properties:
> + - allwinner,ts-attached : boolean indicating that an actual touchscreen
> + is attached to the controller
> + - allwinner,tp-sensitive-adjust : integer (4 bits)
> + adjust sensitivity of pen down detection
> + between 0 (least sensitive) and 15
> + (defaults to 15)
> + - allwinner,filter-type : integer (2 bits)
> + select median and averaging filter
> + samples used for median / averaging filter
> + 0: 4/2
> + 1: 5/3
> + 2: 8/4
> + 3: 16/8
> + (defaults to 1)
> +
> +Example:
> +
> + rtp: rtp@01c25000 {
> + compatible = "allwinner,sun4i-a10-ts";
> + reg = <0x01c25000 0x100>;
> + interrupts = <29>;
> + allwinner,ts-attached;
> + #thermal-sensor-cells = <0>;
> + /* sensitive/noisy touch panel */
> + allwinner,tp-sensitive-adjust = <0>;
> + allwinner,filter-type = <3>;
> + };
> --
> 2.9.3
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

-- 
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/d/optout.

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH v2 05/11] Documentation: DT: bindings: mfd: add A33 GPADC binding
@ 2017-03-10 19:25       ` Icenowy Zheng
  0 siblings, 0 replies; 85+ messages in thread
From: Icenowy Zheng @ 2017-03-10 19:25 UTC (permalink / raw)
  To: Quentin Schulz, dmitry.torokhov, robh+dt, mark.rutland,
	maxime.ripard, wens, lee.jones, linux, jic23, knaack.h, lars,
	pmeerw, stefan.mavrodiev
  Cc: thomas.petazzoni, devicetree, linux-iio, linux-kernel,
	linux-sunxi, linux-arm-kernel



10.03.2017, 18:56, "Quentin Schulz" <quentin.schulz@free-electrons.com>:
> This patch adds documentation for the A33 GPADC binding.
>
> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
> ---
>
> added in v2
>
>  .../devicetree/bindings/mfd/sun4i-gpadc.txt | 59 ++++++++++++++++++++++
>  1 file changed, 59 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
>
> diff --git a/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt b/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
> new file mode 100644
> index 0000000..17242c8
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
> @@ -0,0 +1,59 @@
> +Allwinner SoCs' GPADC Device Tree bindings
> +------------------------------------------
> +The Allwinner SoCs all have an ADC that can also act as a thermal sensor
> +and sometimes as a touchscreen controller.
> +
> +Required properties:
> + - compatible: "sun8i-a33-gpadc-iio",
> + - reg: mmio address range of the chip,
> + - #thermal-sensor-cells: shall be 0,
> + - #io-channel-cells: shall be 0,
> +
> +Example:
> + rtp: rtp@01c25000 {

I think we'd better call it ths.

And can you make thermal-sensor-cells become 1?

Maxime Ripard wants to base H3/H5/A64 thermal driver on this patchset, and
for H5/A64 there's 2/3 thermal sensors.

Thus for A33/H3 we will have thermal-sensor-cells to 1, but only have
<&ths 0>.

> + compatible = "allwinner,sun8i-a33-gpadc-iio";
> + reg = <0x01c25000 0x100>;
> + #thermal-sensor-cells = <0>;
> + #io-channel-cells = <0>;
> + };
> +
> +sun4i, sun5i and sun6i SoCs are also supported via the older binding:
> +
> +sun4i resistive touchscreen controller
> +--------------------------------------
> +
> +Required properties:
> + - compatible: "allwinner,sun4i-a10-ts", "allwinner,sun5i-a13-ts" or
> + "allwinner,sun6i-a31-ts"
> + - reg: mmio address range of the chip
> + - interrupts: interrupt to which the chip is connected
> + - #thermal-sensor-cells: shall be 0
> +
> +Optional properties:
> + - allwinner,ts-attached : boolean indicating that an actual touchscreen
> + is attached to the controller
> + - allwinner,tp-sensitive-adjust : integer (4 bits)
> + adjust sensitivity of pen down detection
> + between 0 (least sensitive) and 15
> + (defaults to 15)
> + - allwinner,filter-type : integer (2 bits)
> + select median and averaging filter
> + samples used for median / averaging filter
> + 0: 4/2
> + 1: 5/3
> + 2: 8/4
> + 3: 16/8
> + (defaults to 1)
> +
> +Example:
> +
> + rtp: rtp@01c25000 {
> + compatible = "allwinner,sun4i-a10-ts";
> + reg = <0x01c25000 0x100>;
> + interrupts = <29>;
> + allwinner,ts-attached;
> + #thermal-sensor-cells = <0>;
> + /* sensitive/noisy touch panel */
> + allwinner,tp-sensitive-adjust = <0>;
> + allwinner,filter-type = <3>;
> + };
> --
> 2.9.3
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 85+ messages in thread

* [PATCH v2 05/11] Documentation: DT: bindings: mfd: add A33 GPADC binding
@ 2017-03-10 19:25       ` Icenowy Zheng
  0 siblings, 0 replies; 85+ messages in thread
From: Icenowy Zheng @ 2017-03-10 19:25 UTC (permalink / raw)
  To: linux-arm-kernel



10.03.2017, 18:56, "Quentin Schulz" <quentin.schulz@free-electrons.com>:
> This patch adds documentation for the A33 GPADC binding.
>
> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
> ---
>
> added in v2
>
> ?.../devicetree/bindings/mfd/sun4i-gpadc.txt | 59 ++++++++++++++++++++++
> ?1 file changed, 59 insertions(+)
> ?create mode 100644 Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
>
> diff --git a/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt b/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
> new file mode 100644
> index 0000000..17242c8
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
> @@ -0,0 +1,59 @@
> +Allwinner SoCs' GPADC Device Tree bindings
> +------------------------------------------
> +The Allwinner SoCs all have an ADC that can also act as a thermal sensor
> +and sometimes as a touchscreen controller.
> +
> +Required properties:
> + - compatible: "sun8i-a33-gpadc-iio",
> + - reg: mmio address range of the chip,
> + - #thermal-sensor-cells: shall be 0,
> + - #io-channel-cells: shall be 0,
> +
> +Example:
> + rtp: rtp at 01c25000 {

I think we'd better call it ths.

And can you make thermal-sensor-cells become 1?

Maxime Ripard wants to base H3/H5/A64 thermal driver on this patchset, and
for H5/A64 there's 2/3 thermal sensors.

Thus for A33/H3 we will have thermal-sensor-cells to 1, but only have
<&ths 0>.

> + compatible = "allwinner,sun8i-a33-gpadc-iio";
> + reg = <0x01c25000 0x100>;
> + #thermal-sensor-cells = <0>;
> + #io-channel-cells = <0>;
> + };
> +
> +sun4i, sun5i and sun6i SoCs are also supported via the older binding:
> +
> +sun4i resistive touchscreen controller
> +--------------------------------------
> +
> +Required properties:
> + - compatible: "allwinner,sun4i-a10-ts", "allwinner,sun5i-a13-ts" or
> + "allwinner,sun6i-a31-ts"
> + - reg: mmio address range of the chip
> + - interrupts: interrupt to which the chip is connected
> + - #thermal-sensor-cells: shall be 0
> +
> +Optional properties:
> + - allwinner,ts-attached : boolean indicating that an actual touchscreen
> + is attached to the controller
> + - allwinner,tp-sensitive-adjust : integer (4 bits)
> + adjust sensitivity of pen down detection
> + between 0 (least sensitive) and 15
> + (defaults to 15)
> + - allwinner,filter-type : integer (2 bits)
> + select median and averaging filter
> + samples used for median / averaging filter
> + 0: 4/2
> + 1: 5/3
> + 2: 8/4
> + 3: 16/8
> + (defaults to 1)
> +
> +Example:
> +
> + rtp: rtp at 01c25000 {
> + compatible = "allwinner,sun4i-a10-ts";
> + reg = <0x01c25000 0x100>;
> + interrupts = <29>;
> + allwinner,ts-attached;
> + #thermal-sensor-cells = <0>;
> + /* sensitive/noisy touch panel */
> + allwinner,tp-sensitive-adjust = <0>;
> + allwinner,filter-type = <3>;
> + };
> --
> 2.9.3
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH v2 09/11] ARM: dtsi: sun8i: a33: add thermal sensor
  2017-03-10 10:39   ` Quentin Schulz
  (?)
@ 2017-03-10 19:28       ` Icenowy Zheng
  -1 siblings, 0 replies; 85+ messages in thread
From: Icenowy Zheng @ 2017-03-10 19:28 UTC (permalink / raw)
  To: Quentin Schulz, dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8, wens-jdAy2FN1RRM,
	lee.jones-QSEj5FYQhm4dnm+yROfE0A, linux-I+IVW8TIWO2tmTQ+vhA3Yw,
	jic23-DgEjT+Ai2ygdnm+yROfE0A, knaack.h-Mmb7MZpHnFY,
	lars-Qo5EllUWu/uELgA04lAiVw, pmeerw-jW+XmwGofnusTnJN9+BGXg,
	stefan.mavrodiev-Re5JQEeQqe8AvxtiuMwx3w
  Cc: thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-iio-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r



10.03.2017, 18:42, "Quentin Schulz" <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>:
> This adds the DT node for the thermal sensor present in the Allwinner
> A33 GPADC.
>
> Signed-off-by: Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> ---
>  arch/arm/boot/dts/sun8i-a33.dtsi | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
>
> diff --git a/arch/arm/boot/dts/sun8i-a33.dtsi b/arch/arm/boot/dts/sun8i-a33.dtsi
> index ba87a9e..704f2b0 100644
> --- a/arch/arm/boot/dts/sun8i-a33.dtsi
> +++ b/arch/arm/boot/dts/sun8i-a33.dtsi
> @@ -278,6 +278,13 @@
>                          status = "disabled";
>                  };
>
> + rtp: rtp@01c25000 {
> + compatible = "allwinner,sun8i-a33-gpadc-iio";
> + reg = <0x01c25000 0x100>;
> + #thermal-sensor-cells = <0>;
> + #io-channel-cells = <0>;
> + };

As I said, it's not a "rtp" (Resistive touch panel).

> +
>                  fe0: display-frontend@01e00000 {
>                          compatible = "allwinner,sun8i-a33-display-frontend";
>                          reg = <0x01e00000 0x20000>;
> @@ -388,6 +395,11 @@
>                          };
>                  };
>          };
> +
> + iio-hwmon {
> + compatible = "iio-hwmon";
> + io-channels = <&rtp>;
> + };
>  };
>
>  &ccu {
> --
> 2.9.3
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

-- 
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/d/optout.

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH v2 09/11] ARM: dtsi: sun8i: a33: add thermal sensor
@ 2017-03-10 19:28       ` Icenowy Zheng
  0 siblings, 0 replies; 85+ messages in thread
From: Icenowy Zheng @ 2017-03-10 19:28 UTC (permalink / raw)
  To: Quentin Schulz, dmitry.torokhov, robh+dt, mark.rutland,
	maxime.ripard, wens, lee.jones, linux, jic23, knaack.h, lars,
	pmeerw, stefan.mavrodiev
  Cc: thomas.petazzoni, devicetree, linux-iio, linux-kernel,
	linux-sunxi, linux-arm-kernel



10.03.2017, 18:42, "Quentin Schulz" <quentin.schulz@free-electrons.com>:
> This adds the DT node for the thermal sensor present in the Allwinner
> A33 GPADC.
>
> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
> ---
>  arch/arm/boot/dts/sun8i-a33.dtsi | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
>
> diff --git a/arch/arm/boot/dts/sun8i-a33.dtsi b/arch/arm/boot/dts/sun8i-a33.dtsi
> index ba87a9e..704f2b0 100644
> --- a/arch/arm/boot/dts/sun8i-a33.dtsi
> +++ b/arch/arm/boot/dts/sun8i-a33.dtsi
> @@ -278,6 +278,13 @@
>                          status = "disabled";
>                  };
>
> + rtp: rtp@01c25000 {
> + compatible = "allwinner,sun8i-a33-gpadc-iio";
> + reg = <0x01c25000 0x100>;
> + #thermal-sensor-cells = <0>;
> + #io-channel-cells = <0>;
> + };

As I said, it's not a "rtp" (Resistive touch panel).

> +
>                  fe0: display-frontend@01e00000 {
>                          compatible = "allwinner,sun8i-a33-display-frontend";
>                          reg = <0x01e00000 0x20000>;
> @@ -388,6 +395,11 @@
>                          };
>                  };
>          };
> +
> + iio-hwmon {
> + compatible = "iio-hwmon";
> + io-channels = <&rtp>;
> + };
>  };
>
>  &ccu {
> --
> 2.9.3
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 85+ messages in thread

* [PATCH v2 09/11] ARM: dtsi: sun8i: a33: add thermal sensor
@ 2017-03-10 19:28       ` Icenowy Zheng
  0 siblings, 0 replies; 85+ messages in thread
From: Icenowy Zheng @ 2017-03-10 19:28 UTC (permalink / raw)
  To: linux-arm-kernel



10.03.2017, 18:42, "Quentin Schulz" <quentin.schulz@free-electrons.com>:
> This adds the DT node for the thermal sensor present in the Allwinner
> A33 GPADC.
>
> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
> ---
> ?arch/arm/boot/dts/sun8i-a33.dtsi | 12 ++++++++++++
> ?1 file changed, 12 insertions(+)
>
> diff --git a/arch/arm/boot/dts/sun8i-a33.dtsi b/arch/arm/boot/dts/sun8i-a33.dtsi
> index ba87a9e..704f2b0 100644
> --- a/arch/arm/boot/dts/sun8i-a33.dtsi
> +++ b/arch/arm/boot/dts/sun8i-a33.dtsi
> @@ -278,6 +278,13 @@
> ?????????????????????????status = "disabled";
> ?????????????????};
>
> + rtp: rtp at 01c25000 {
> + compatible = "allwinner,sun8i-a33-gpadc-iio";
> + reg = <0x01c25000 0x100>;
> + #thermal-sensor-cells = <0>;
> + #io-channel-cells = <0>;
> + };

As I said, it's not a "rtp" (Resistive touch panel).

> +
> ?????????????????fe0: display-frontend at 01e00000 {
> ?????????????????????????compatible = "allwinner,sun8i-a33-display-frontend";
> ?????????????????????????reg = <0x01e00000 0x20000>;
> @@ -388,6 +395,11 @@
> ?????????????????????????};
> ?????????????????};
> ?????????};
> +
> + iio-hwmon {
> + compatible = "iio-hwmon";
> + io-channels = <&rtp>;
> + };
> ?};
>
> ?&ccu {
> --
> 2.9.3
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH v2 05/11] Documentation: DT: bindings: mfd: add A33 GPADC binding
  2017-03-10 12:25     ` Maxime Ripard
  (?)
@ 2017-03-10 19:33       ` Icenowy Zheng
  -1 siblings, 0 replies; 85+ messages in thread
From: Icenowy Zheng @ 2017-03-10 19:33 UTC (permalink / raw)
  To: Maxime Ripard, Quentin Schulz
  Cc: mark.rutland-5wv7dgnIgG8, devicetree-u79uwXL29TY76Z2rM5mHXA,
	lars-Qo5EllUWu/uELgA04lAiVw, linux-iio-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
	dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w,
	linux-I+IVW8TIWO2tmTQ+vhA3Yw,
	stefan.mavrodiev-Re5JQEeQqe8AvxtiuMwx3w, wens-jdAy2FN1RRM,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	pmeerw-jW+XmwGofnusTnJN9+BGXg, knaack.h-Mmb7MZpHnFY,
	lee.jones-QSEj5FYQhm4dnm+yROfE0A,
	thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
	jic23-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org



10.03.2017, 20:26, "Maxime Ripard" <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>:
> On Fri, Mar 10, 2017 at 11:39:15AM +0100, Quentin Schulz wrote:
>>  This patch adds documentation for the A33 GPADC binding.
>>
>>  Signed-off-by: Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
>>  ---
>>
>>  added in v2
>>
>>   .../devicetree/bindings/mfd/sun4i-gpadc.txt | 59 ++++++++++++++++++++++
>>   1 file changed, 59 insertions(+)
>>   create mode 100644 Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
>>
>>  diff --git a/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt b/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
>>  new file mode 100644
>>  index 0000000..17242c8
>>  --- /dev/null
>>  +++ b/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
>>  @@ -0,0 +1,59 @@
>>  +Allwinner SoCs' GPADC Device Tree bindings
>>  +------------------------------------------
>>  +The Allwinner SoCs all have an ADC that can also act as a thermal sensor
>>  +and sometimes as a touchscreen controller.
>>  +
>>  +Required properties:
>>  + - compatible: "sun8i-a33-gpadc-iio",
>
> This doesn't match your example, and you shouldn't have IIO in
> there. Compatibles shouldn't be tied to a given framework, since that
> is Linux specific (and might even change in the future).

>From this aspect, I think we shouldn't even call it gpadc in compatible --
as it's not GP at all on A33.

>
> Maxime
>
> --
> Maxime Ripard, Free Electrons
> Embedded Linux and Kernel engineering
> http://free-electrons.com
> ,
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

-- 
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/d/optout.

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH v2 05/11] Documentation: DT: bindings: mfd: add A33 GPADC binding
@ 2017-03-10 19:33       ` Icenowy Zheng
  0 siblings, 0 replies; 85+ messages in thread
From: Icenowy Zheng @ 2017-03-10 19:33 UTC (permalink / raw)
  To: Maxime Ripard, Quentin Schulz
  Cc: mark.rutland, devicetree, lars, linux-iio, linux-kernel,
	linux-sunxi, dmitry.torokhov, linux, stefan.mavrodiev, wens,
	robh+dt, linux-arm-kernel, pmeerw, knaack.h, lee.jones,
	thomas.petazzoni, jic23



10.03.2017, 20:26, "Maxime Ripard" <maxime.ripard@free-electrons.com>:
> On Fri, Mar 10, 2017 at 11:39:15AM +0100, Quentin Schulz wrote:
>>  This patch adds documentation for the A33 GPADC binding.
>>
>>  Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
>>  ---
>>
>>  added in v2
>>
>>   .../devicetree/bindings/mfd/sun4i-gpadc.txt | 59 ++++++++++++++++++++++
>>   1 file changed, 59 insertions(+)
>>   create mode 100644 Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
>>
>>  diff --git a/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt b/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
>>  new file mode 100644
>>  index 0000000..17242c8
>>  --- /dev/null
>>  +++ b/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
>>  @@ -0,0 +1,59 @@
>>  +Allwinner SoCs' GPADC Device Tree bindings
>>  +------------------------------------------
>>  +The Allwinner SoCs all have an ADC that can also act as a thermal sensor
>>  +and sometimes as a touchscreen controller.
>>  +
>>  +Required properties:
>>  + - compatible: "sun8i-a33-gpadc-iio",
>
> This doesn't match your example, and you shouldn't have IIO in
> there. Compatibles shouldn't be tied to a given framework, since that
> is Linux specific (and might even change in the future).

>From this aspect, I think we shouldn't even call it gpadc in compatible --
as it's not GP at all on A33.

>
> Maxime
>
> --
> Maxime Ripard, Free Electrons
> Embedded Linux and Kernel engineering
> http://free-electrons.com
> ,
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 85+ messages in thread

* [PATCH v2 05/11] Documentation: DT: bindings: mfd: add A33 GPADC binding
@ 2017-03-10 19:33       ` Icenowy Zheng
  0 siblings, 0 replies; 85+ messages in thread
From: Icenowy Zheng @ 2017-03-10 19:33 UTC (permalink / raw)
  To: linux-arm-kernel



10.03.2017, 20:26, "Maxime Ripard" <maxime.ripard@free-electrons.com>:
> On Fri, Mar 10, 2017 at 11:39:15AM +0100, Quentin Schulz wrote:
>> ?This patch adds documentation for the A33 GPADC binding.
>>
>> ?Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
>> ?---
>>
>> ?added in v2
>>
>> ??.../devicetree/bindings/mfd/sun4i-gpadc.txt | 59 ++++++++++++++++++++++
>> ??1 file changed, 59 insertions(+)
>> ??create mode 100644 Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
>>
>> ?diff --git a/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt b/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
>> ?new file mode 100644
>> ?index 0000000..17242c8
>> ?--- /dev/null
>> ?+++ b/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
>> ?@@ -0,0 +1,59 @@
>> ?+Allwinner SoCs' GPADC Device Tree bindings
>> ?+------------------------------------------
>> ?+The Allwinner SoCs all have an ADC that can also act as a thermal sensor
>> ?+and sometimes as a touchscreen controller.
>> ?+
>> ?+Required properties:
>> ?+ - compatible: "sun8i-a33-gpadc-iio",
>
> This doesn't match your example, and you shouldn't have IIO in
> there. Compatibles shouldn't be tied to a given framework, since that
> is Linux specific (and might even change in the future).

>From this aspect, I think we shouldn't even call it gpadc in compatible --
as it's not GP at all on A33.

>
> Maxime
>
> --
> Maxime Ripard, Free Electrons
> Embedded Linux and Kernel engineering
> http://free-electrons.com
> ,
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH v2 07/11] iio: adc: sun4i-gpadc-iio: move code used in MFD probing to new function
  2017-03-10 10:39   ` Quentin Schulz
  (?)
@ 2017-03-10 19:36       ` Icenowy Zheng
  -1 siblings, 0 replies; 85+ messages in thread
From: Icenowy Zheng @ 2017-03-10 19:36 UTC (permalink / raw)
  To: Quentin Schulz, dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8, wens-jdAy2FN1RRM,
	lee.jones-QSEj5FYQhm4dnm+yROfE0A, linux-I+IVW8TIWO2tmTQ+vhA3Yw,
	jic23-DgEjT+Ai2ygdnm+yROfE0A, knaack.h-Mmb7MZpHnFY,
	lars-Qo5EllUWu/uELgA04lAiVw, pmeerw-jW+XmwGofnusTnJN9+BGXg,
	stefan.mavrodiev-Re5JQEeQqe8AvxtiuMwx3w
  Cc: thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-iio-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r



10.03.2017, 18:56, "Quentin Schulz" <quentin.schulz@free-electrons.com>:
> This moves code used in MFD probing to a new sun4i_gpadc_probe_mfd
> function.
>
> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
> ---
>
> added in v2
>
>  drivers/iio/adc/sun4i-gpadc-iio.c | 78 ++++++++++++++++++++++-----------------

I cannot find this source file even in linux-next.

>  1 file changed, 45 insertions(+), 33 deletions(-)
>
> diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c
> index a8e134f..7cb997a 100644
> --- a/drivers/iio/adc/sun4i-gpadc-iio.c
> +++ b/drivers/iio/adc/sun4i-gpadc-iio.c
> @@ -454,31 +454,16 @@ static int sun4i_irq_init(struct platform_device *pdev, const char *name,
>          return 0;
>  }
>
> -static int sun4i_gpadc_probe(struct platform_device *pdev)
> +static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
> + struct iio_dev *indio_dev)
>  {
> - struct sun4i_gpadc_iio *info;
> - struct iio_dev *indio_dev;
> + struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
> + struct sun4i_gpadc_dev *sun4i_gpadc_dev =
> + dev_get_drvdata(pdev->dev.parent);
>          int ret;
> - struct sun4i_gpadc_dev *sun4i_gpadc_dev;
> -
> - sun4i_gpadc_dev = dev_get_drvdata(pdev->dev.parent);
> -
> - indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*info));
> - if (!indio_dev)
> - return -ENOMEM;
>
> - info = iio_priv(indio_dev);
> - platform_set_drvdata(pdev, indio_dev);
> -
> - mutex_init(&info->mutex);
>          info->regmap = sun4i_gpadc_dev->regmap;
> - info->indio_dev = indio_dev;
> - init_completion(&info->completion);
> - indio_dev->name = dev_name(&pdev->dev);
> - indio_dev->dev.parent = &pdev->dev;
> - indio_dev->dev.of_node = pdev->dev.of_node;
> - indio_dev->info = &sun4i_gpadc_iio_info;
> - indio_dev->modes = INDIO_DIRECT_MODE;
> +
>          indio_dev->num_channels = ARRAY_SIZE(sun4i_gpadc_channels);
>          indio_dev->channels = sun4i_gpadc_channels;
>
> @@ -519,8 +504,7 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>                          dev_err(&pdev->dev,
>                                  "could not register thermal sensor: %ld\n",
>                                  PTR_ERR(tzd));
> - ret = PTR_ERR(tzd);
> - goto err;
> + return PTR_ERR(tzd);
>                  }
>          } else {
>                  indio_dev->num_channels =
> @@ -528,36 +512,65 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>                  indio_dev->channels = sun4i_gpadc_channels_no_temp;
>          }
>
> - pm_runtime_set_autosuspend_delay(&pdev->dev,
> - SUN4I_GPADC_AUTOSUSPEND_DELAY);
> - pm_runtime_use_autosuspend(&pdev->dev);
> - pm_runtime_set_suspended(&pdev->dev);
> - pm_runtime_enable(&pdev->dev);
> -
>          if (IS_ENABLED(CONFIG_THERMAL_OF)) {
>                  ret = sun4i_irq_init(pdev, "TEMP_DATA_PENDING",
>                                       sun4i_gpadc_temp_data_irq_handler,
>                                       "temp_data", &info->temp_data_irq,
>                                       &info->ignore_temp_data_irq);
>                  if (ret < 0)
> - goto err;
> + return ret;
>          }
>
>          ret = sun4i_irq_init(pdev, "FIFO_DATA_PENDING",
>                               sun4i_gpadc_fifo_data_irq_handler, "fifo_data",
>                               &info->fifo_data_irq, &info->ignore_fifo_data_irq);
>          if (ret < 0)
> - goto err;
> + return ret;
>
>          if (IS_ENABLED(CONFIG_THERMAL_OF)) {
>                  ret = iio_map_array_register(indio_dev, sun4i_gpadc_hwmon_maps);
>                  if (ret < 0) {
>                          dev_err(&pdev->dev,
>                                  "failed to register iio map array\n");
> - goto err;
> + return ret;
>                  }
>          }
>
> + return 0;
> +}
> +
> +static int sun4i_gpadc_probe(struct platform_device *pdev)
> +{
> + struct sun4i_gpadc_iio *info;
> + struct iio_dev *indio_dev;
> + int ret;
> +
> + indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*info));
> + if (!indio_dev)
> + return -ENOMEM;
> +
> + info = iio_priv(indio_dev);
> + platform_set_drvdata(pdev, indio_dev);
> +
> + mutex_init(&info->mutex);
> + info->indio_dev = indio_dev;
> + init_completion(&info->completion);
> + indio_dev->name = dev_name(&pdev->dev);
> + indio_dev->dev.parent = &pdev->dev;
> + indio_dev->dev.of_node = pdev->dev.of_node;
> + indio_dev->info = &sun4i_gpadc_iio_info;
> + indio_dev->modes = INDIO_DIRECT_MODE;
> +
> + ret = sun4i_gpadc_probe_mfd(pdev, indio_dev);
> + if (ret)
> + return ret;
> +
> + pm_runtime_set_autosuspend_delay(&pdev->dev,
> + SUN4I_GPADC_AUTOSUSPEND_DELAY);
> + pm_runtime_use_autosuspend(&pdev->dev);
> + pm_runtime_set_suspended(&pdev->dev);
> + pm_runtime_enable(&pdev->dev);
> +
>          ret = devm_iio_device_register(&pdev->dev, indio_dev);
>          if (ret < 0) {
>                  dev_err(&pdev->dev, "could not register the device\n");
> @@ -570,7 +583,6 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>          if (IS_ENABLED(CONFIG_THERMAL_OF))
>                  iio_map_array_unregister(indio_dev);
>
> -err:
>          pm_runtime_put(&pdev->dev);
>          pm_runtime_disable(&pdev->dev);
>
> --
> 2.9.3
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

-- 
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH v2 07/11] iio: adc: sun4i-gpadc-iio: move code used in MFD probing to new function
@ 2017-03-10 19:36       ` Icenowy Zheng
  0 siblings, 0 replies; 85+ messages in thread
From: Icenowy Zheng @ 2017-03-10 19:36 UTC (permalink / raw)
  To: Quentin Schulz, dmitry.torokhov, robh+dt, mark.rutland,
	maxime.ripard, wens, lee.jones, linux, jic23, knaack.h, lars,
	pmeerw, stefan.mavrodiev
  Cc: thomas.petazzoni, devicetree, linux-iio, linux-kernel,
	linux-sunxi, linux-arm-kernel



10.03.2017, 18:56, "Quentin Schulz" <quentin.schulz@free-electrons.com>:
> This moves code used in MFD probing to a new sun4i_gpadc_probe_mfd
> function.
>
> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
> ---
>
> added in v2
>
>  drivers/iio/adc/sun4i-gpadc-iio.c | 78 ++++++++++++++++++++++-----------------

I cannot find this source file even in linux-next.

>  1 file changed, 45 insertions(+), 33 deletions(-)
>
> diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c
> index a8e134f..7cb997a 100644
> --- a/drivers/iio/adc/sun4i-gpadc-iio.c
> +++ b/drivers/iio/adc/sun4i-gpadc-iio.c
> @@ -454,31 +454,16 @@ static int sun4i_irq_init(struct platform_device *pdev, const char *name,
>          return 0;
>  }
>
> -static int sun4i_gpadc_probe(struct platform_device *pdev)
> +static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
> + struct iio_dev *indio_dev)
>  {
> - struct sun4i_gpadc_iio *info;
> - struct iio_dev *indio_dev;
> + struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
> + struct sun4i_gpadc_dev *sun4i_gpadc_dev =
> + dev_get_drvdata(pdev->dev.parent);
>          int ret;
> - struct sun4i_gpadc_dev *sun4i_gpadc_dev;
> -
> - sun4i_gpadc_dev = dev_get_drvdata(pdev->dev.parent);
> -
> - indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*info));
> - if (!indio_dev)
> - return -ENOMEM;
>
> - info = iio_priv(indio_dev);
> - platform_set_drvdata(pdev, indio_dev);
> -
> - mutex_init(&info->mutex);
>          info->regmap = sun4i_gpadc_dev->regmap;
> - info->indio_dev = indio_dev;
> - init_completion(&info->completion);
> - indio_dev->name = dev_name(&pdev->dev);
> - indio_dev->dev.parent = &pdev->dev;
> - indio_dev->dev.of_node = pdev->dev.of_node;
> - indio_dev->info = &sun4i_gpadc_iio_info;
> - indio_dev->modes = INDIO_DIRECT_MODE;
> +
>          indio_dev->num_channels = ARRAY_SIZE(sun4i_gpadc_channels);
>          indio_dev->channels = sun4i_gpadc_channels;
>
> @@ -519,8 +504,7 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>                          dev_err(&pdev->dev,
>                                  "could not register thermal sensor: %ld\n",
>                                  PTR_ERR(tzd));
> - ret = PTR_ERR(tzd);
> - goto err;
> + return PTR_ERR(tzd);
>                  }
>          } else {
>                  indio_dev->num_channels =
> @@ -528,36 +512,65 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>                  indio_dev->channels = sun4i_gpadc_channels_no_temp;
>          }
>
> - pm_runtime_set_autosuspend_delay(&pdev->dev,
> - SUN4I_GPADC_AUTOSUSPEND_DELAY);
> - pm_runtime_use_autosuspend(&pdev->dev);
> - pm_runtime_set_suspended(&pdev->dev);
> - pm_runtime_enable(&pdev->dev);
> -
>          if (IS_ENABLED(CONFIG_THERMAL_OF)) {
>                  ret = sun4i_irq_init(pdev, "TEMP_DATA_PENDING",
>                                       sun4i_gpadc_temp_data_irq_handler,
>                                       "temp_data", &info->temp_data_irq,
>                                       &info->ignore_temp_data_irq);
>                  if (ret < 0)
> - goto err;
> + return ret;
>          }
>
>          ret = sun4i_irq_init(pdev, "FIFO_DATA_PENDING",
>                               sun4i_gpadc_fifo_data_irq_handler, "fifo_data",
>                               &info->fifo_data_irq, &info->ignore_fifo_data_irq);
>          if (ret < 0)
> - goto err;
> + return ret;
>
>          if (IS_ENABLED(CONFIG_THERMAL_OF)) {
>                  ret = iio_map_array_register(indio_dev, sun4i_gpadc_hwmon_maps);
>                  if (ret < 0) {
>                          dev_err(&pdev->dev,
>                                  "failed to register iio map array\n");
> - goto err;
> + return ret;
>                  }
>          }
>
> + return 0;
> +}
> +
> +static int sun4i_gpadc_probe(struct platform_device *pdev)
> +{
> + struct sun4i_gpadc_iio *info;
> + struct iio_dev *indio_dev;
> + int ret;
> +
> + indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*info));
> + if (!indio_dev)
> + return -ENOMEM;
> +
> + info = iio_priv(indio_dev);
> + platform_set_drvdata(pdev, indio_dev);
> +
> + mutex_init(&info->mutex);
> + info->indio_dev = indio_dev;
> + init_completion(&info->completion);
> + indio_dev->name = dev_name(&pdev->dev);
> + indio_dev->dev.parent = &pdev->dev;
> + indio_dev->dev.of_node = pdev->dev.of_node;
> + indio_dev->info = &sun4i_gpadc_iio_info;
> + indio_dev->modes = INDIO_DIRECT_MODE;
> +
> + ret = sun4i_gpadc_probe_mfd(pdev, indio_dev);
> + if (ret)
> + return ret;
> +
> + pm_runtime_set_autosuspend_delay(&pdev->dev,
> + SUN4I_GPADC_AUTOSUSPEND_DELAY);
> + pm_runtime_use_autosuspend(&pdev->dev);
> + pm_runtime_set_suspended(&pdev->dev);
> + pm_runtime_enable(&pdev->dev);
> +
>          ret = devm_iio_device_register(&pdev->dev, indio_dev);
>          if (ret < 0) {
>                  dev_err(&pdev->dev, "could not register the device\n");
> @@ -570,7 +583,6 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>          if (IS_ENABLED(CONFIG_THERMAL_OF))
>                  iio_map_array_unregister(indio_dev);
>
> -err:
>          pm_runtime_put(&pdev->dev);
>          pm_runtime_disable(&pdev->dev);
>
> --
> 2.9.3
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 85+ messages in thread

* [PATCH v2 07/11] iio: adc: sun4i-gpadc-iio: move code used in MFD probing to new function
@ 2017-03-10 19:36       ` Icenowy Zheng
  0 siblings, 0 replies; 85+ messages in thread
From: Icenowy Zheng @ 2017-03-10 19:36 UTC (permalink / raw)
  To: linux-arm-kernel



10.03.2017, 18:56, "Quentin Schulz" <quentin.schulz@free-electrons.com>:
> This moves code used in MFD probing to a new sun4i_gpadc_probe_mfd
> function.
>
> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
> ---
>
> added in v2
>
> ?drivers/iio/adc/sun4i-gpadc-iio.c | 78 ++++++++++++++++++++++-----------------

I cannot find this source file even in linux-next.

> ?1 file changed, 45 insertions(+), 33 deletions(-)
>
> diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c
> index a8e134f..7cb997a 100644
> --- a/drivers/iio/adc/sun4i-gpadc-iio.c
> +++ b/drivers/iio/adc/sun4i-gpadc-iio.c
> @@ -454,31 +454,16 @@ static int sun4i_irq_init(struct platform_device *pdev, const char *name,
> ?????????return 0;
> ?}
>
> -static int sun4i_gpadc_probe(struct platform_device *pdev)
> +static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
> + struct iio_dev *indio_dev)
> ?{
> - struct sun4i_gpadc_iio *info;
> - struct iio_dev *indio_dev;
> + struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
> + struct sun4i_gpadc_dev *sun4i_gpadc_dev =
> + dev_get_drvdata(pdev->dev.parent);
> ?????????int ret;
> - struct sun4i_gpadc_dev *sun4i_gpadc_dev;
> -
> - sun4i_gpadc_dev = dev_get_drvdata(pdev->dev.parent);
> -
> - indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*info));
> - if (!indio_dev)
> - return -ENOMEM;
>
> - info = iio_priv(indio_dev);
> - platform_set_drvdata(pdev, indio_dev);
> -
> - mutex_init(&info->mutex);
> ?????????info->regmap = sun4i_gpadc_dev->regmap;
> - info->indio_dev = indio_dev;
> - init_completion(&info->completion);
> - indio_dev->name = dev_name(&pdev->dev);
> - indio_dev->dev.parent = &pdev->dev;
> - indio_dev->dev.of_node = pdev->dev.of_node;
> - indio_dev->info = &sun4i_gpadc_iio_info;
> - indio_dev->modes = INDIO_DIRECT_MODE;
> +
> ?????????indio_dev->num_channels = ARRAY_SIZE(sun4i_gpadc_channels);
> ?????????indio_dev->channels = sun4i_gpadc_channels;
>
> @@ -519,8 +504,7 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
> ?????????????????????????dev_err(&pdev->dev,
> ?????????????????????????????????"could not register thermal sensor: %ld\n",
> ?????????????????????????????????PTR_ERR(tzd));
> - ret = PTR_ERR(tzd);
> - goto err;
> + return PTR_ERR(tzd);
> ?????????????????}
> ?????????} else {
> ?????????????????indio_dev->num_channels =
> @@ -528,36 +512,65 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
> ?????????????????indio_dev->channels = sun4i_gpadc_channels_no_temp;
> ?????????}
>
> - pm_runtime_set_autosuspend_delay(&pdev->dev,
> - SUN4I_GPADC_AUTOSUSPEND_DELAY);
> - pm_runtime_use_autosuspend(&pdev->dev);
> - pm_runtime_set_suspended(&pdev->dev);
> - pm_runtime_enable(&pdev->dev);
> -
> ?????????if (IS_ENABLED(CONFIG_THERMAL_OF)) {
> ?????????????????ret = sun4i_irq_init(pdev, "TEMP_DATA_PENDING",
> ??????????????????????????????????????sun4i_gpadc_temp_data_irq_handler,
> ??????????????????????????????????????"temp_data", &info->temp_data_irq,
> ??????????????????????????????????????&info->ignore_temp_data_irq);
> ?????????????????if (ret < 0)
> - goto err;
> + return ret;
> ?????????}
>
> ?????????ret = sun4i_irq_init(pdev, "FIFO_DATA_PENDING",
> ??????????????????????????????sun4i_gpadc_fifo_data_irq_handler, "fifo_data",
> ??????????????????????????????&info->fifo_data_irq, &info->ignore_fifo_data_irq);
> ?????????if (ret < 0)
> - goto err;
> + return ret;
>
> ?????????if (IS_ENABLED(CONFIG_THERMAL_OF)) {
> ?????????????????ret = iio_map_array_register(indio_dev, sun4i_gpadc_hwmon_maps);
> ?????????????????if (ret < 0) {
> ?????????????????????????dev_err(&pdev->dev,
> ?????????????????????????????????"failed to register iio map array\n");
> - goto err;
> + return ret;
> ?????????????????}
> ?????????}
>
> + return 0;
> +}
> +
> +static int sun4i_gpadc_probe(struct platform_device *pdev)
> +{
> + struct sun4i_gpadc_iio *info;
> + struct iio_dev *indio_dev;
> + int ret;
> +
> + indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*info));
> + if (!indio_dev)
> + return -ENOMEM;
> +
> + info = iio_priv(indio_dev);
> + platform_set_drvdata(pdev, indio_dev);
> +
> + mutex_init(&info->mutex);
> + info->indio_dev = indio_dev;
> + init_completion(&info->completion);
> + indio_dev->name = dev_name(&pdev->dev);
> + indio_dev->dev.parent = &pdev->dev;
> + indio_dev->dev.of_node = pdev->dev.of_node;
> + indio_dev->info = &sun4i_gpadc_iio_info;
> + indio_dev->modes = INDIO_DIRECT_MODE;
> +
> + ret = sun4i_gpadc_probe_mfd(pdev, indio_dev);
> + if (ret)
> + return ret;
> +
> + pm_runtime_set_autosuspend_delay(&pdev->dev,
> + SUN4I_GPADC_AUTOSUSPEND_DELAY);
> + pm_runtime_use_autosuspend(&pdev->dev);
> + pm_runtime_set_suspended(&pdev->dev);
> + pm_runtime_enable(&pdev->dev);
> +
> ?????????ret = devm_iio_device_register(&pdev->dev, indio_dev);
> ?????????if (ret < 0) {
> ?????????????????dev_err(&pdev->dev, "could not register the device\n");
> @@ -570,7 +583,6 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
> ?????????if (IS_ENABLED(CONFIG_THERMAL_OF))
> ?????????????????iio_map_array_unregister(indio_dev);
>
> -err:
> ?????????pm_runtime_put(&pdev->dev);
> ?????????pm_runtime_disable(&pdev->dev);
>
> --
> 2.9.3
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH v2 05/11] Documentation: DT: bindings: mfd: add A33 GPADC binding
@ 2017-03-11 14:07         ` Quentin Schulz
  0 siblings, 0 replies; 85+ messages in thread
From: Quentin Schulz @ 2017-03-11 14:07 UTC (permalink / raw)
  To: Icenowy Zheng, dmitry.torokhov, robh+dt, mark.rutland,
	maxime.ripard, wens, lee.jones, linux, jic23, knaack.h, lars,
	pmeerw, stefan.mavrodiev
  Cc: thomas.petazzoni, devicetree, linux-iio, linux-kernel,
	linux-sunxi, linux-arm-kernel

Hi Icenowy,

On 10/03/2017 20:25, Icenowy Zheng wrote:
> 
> 
> 10.03.2017, 18:56, "Quentin Schulz" <quentin.schulz@free-electrons.com>:
>> This patch adds documentation for the A33 GPADC binding.
>>
>> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
>> ---
>>
>> added in v2
>>
>>  .../devicetree/bindings/mfd/sun4i-gpadc.txt | 59 ++++++++++++++++++++++
>>  1 file changed, 59 insertions(+)
>>  create mode 100644 Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
>>
>> diff --git a/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt b/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
>> new file mode 100644
>> index 0000000..17242c8
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
>> @@ -0,0 +1,59 @@
>> +Allwinner SoCs' GPADC Device Tree bindings
>> +------------------------------------------
>> +The Allwinner SoCs all have an ADC that can also act as a thermal sensor
>> +and sometimes as a touchscreen controller.
>> +
>> +Required properties:
>> + - compatible: "sun8i-a33-gpadc-iio",
>> + - reg: mmio address range of the chip,
>> + - #thermal-sensor-cells: shall be 0,
>> + - #io-channel-cells: shall be 0,
>> +
>> +Example:
>> + rtp: rtp@01c25000 {
> 
> I think we'd better call it ths.
> 

To match the datasheet, I agree.

> And can you make thermal-sensor-cells become 1?
> 
> Maxime Ripard wants to base H3/H5/A64 thermal driver on this patchset, and
> for H5/A64 there's 2/3 thermal sensors.
> 

Yes, that'll require a specific DT node for those thermal sensors. Then
since we would update the possible compatibles in the documentation
anyway, that would be a good idea to update to say that
thermal-sensor-cells could be different from 0 too.

That was my mindset to set thermal-sensor-cells to 0, since we only
support SoC which has only one thermal sensor at the moment.

> Thus for A33/H3 we will have thermal-sensor-cells to 1, but only have
> <&ths 0>.
> 

That's non-sense. There is one thermal sensor for the A33,
thermal-sensor-cells has to be 0.

I don't mind to remove the requirement for thermal-sensor-cells to be 0
but I won't put a requirement for it to be 1 as it isn't true.

Thanks,
Quentin
>> + compatible = "allwinner,sun8i-a33-gpadc-iio";
>> + reg = <0x01c25000 0x100>;
>> + #thermal-sensor-cells = <0>;
>> + #io-channel-cells = <0>;
>> + };
>> +
>> +sun4i, sun5i and sun6i SoCs are also supported via the older binding:
>> +
>> +sun4i resistive touchscreen controller
>> +--------------------------------------
>> +
>> +Required properties:
>> + - compatible: "allwinner,sun4i-a10-ts", "allwinner,sun5i-a13-ts" or
>> + "allwinner,sun6i-a31-ts"
>> + - reg: mmio address range of the chip
>> + - interrupts: interrupt to which the chip is connected
>> + - #thermal-sensor-cells: shall be 0
>> +
>> +Optional properties:
>> + - allwinner,ts-attached : boolean indicating that an actual touchscreen
>> + is attached to the controller
>> + - allwinner,tp-sensitive-adjust : integer (4 bits)
>> + adjust sensitivity of pen down detection
>> + between 0 (least sensitive) and 15
>> + (defaults to 15)
>> + - allwinner,filter-type : integer (2 bits)
>> + select median and averaging filter
>> + samples used for median / averaging filter
>> + 0: 4/2
>> + 1: 5/3
>> + 2: 8/4
>> + 3: 16/8
>> + (defaults to 1)
>> +
>> +Example:
>> +
>> + rtp: rtp@01c25000 {
>> + compatible = "allwinner,sun4i-a10-ts";
>> + reg = <0x01c25000 0x100>;
>> + interrupts = <29>;
>> + allwinner,ts-attached;
>> + #thermal-sensor-cells = <0>;
>> + /* sensitive/noisy touch panel */
>> + allwinner,tp-sensitive-adjust = <0>;
>> + allwinner,filter-type = <3>;
>> + };
>> --
>> 2.9.3
>>
>> _______________________________________________
>> linux-arm-kernel mailing list
>> linux-arm-kernel@lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> 

-- 
Quentin Schulz, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH v2 05/11] Documentation: DT: bindings: mfd: add A33 GPADC binding
@ 2017-03-11 14:07         ` Quentin Schulz
  0 siblings, 0 replies; 85+ messages in thread
From: Quentin Schulz @ 2017-03-11 14:07 UTC (permalink / raw)
  To: Icenowy Zheng, dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8, wens-jdAy2FN1RRM,
	lee.jones-QSEj5FYQhm4dnm+yROfE0A, linux-I+IVW8TIWO2tmTQ+vhA3Yw,
	jic23-DgEjT+Ai2ygdnm+yROfE0A, knaack.h-Mmb7MZpHnFY,
	lars-Qo5EllUWu/uELgA04lAiVw, pmeerw-jW+XmwGofnusTnJN9+BGXg,
	stefan.mavrodiev-Re5JQEeQqe8AvxtiuMwx3w
  Cc: thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-iio-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

Hi Icenowy,

On 10/03/2017 20:25, Icenowy Zheng wrote:
> 
> 
> 10.03.2017, 18:56, "Quentin Schulz" <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>:
>> This patch adds documentation for the A33 GPADC binding.
>>
>> Signed-off-by: Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
>> ---
>>
>> added in v2
>>
>>  .../devicetree/bindings/mfd/sun4i-gpadc.txt | 59 ++++++++++++++++++++++
>>  1 file changed, 59 insertions(+)
>>  create mode 100644 Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
>>
>> diff --git a/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt b/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
>> new file mode 100644
>> index 0000000..17242c8
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
>> @@ -0,0 +1,59 @@
>> +Allwinner SoCs' GPADC Device Tree bindings
>> +------------------------------------------
>> +The Allwinner SoCs all have an ADC that can also act as a thermal sensor
>> +and sometimes as a touchscreen controller.
>> +
>> +Required properties:
>> + - compatible: "sun8i-a33-gpadc-iio",
>> + - reg: mmio address range of the chip,
>> + - #thermal-sensor-cells: shall be 0,
>> + - #io-channel-cells: shall be 0,
>> +
>> +Example:
>> + rtp: rtp@01c25000 {
> 
> I think we'd better call it ths.
> 

To match the datasheet, I agree.

> And can you make thermal-sensor-cells become 1?
> 
> Maxime Ripard wants to base H3/H5/A64 thermal driver on this patchset, and
> for H5/A64 there's 2/3 thermal sensors.
> 

Yes, that'll require a specific DT node for those thermal sensors. Then
since we would update the possible compatibles in the documentation
anyway, that would be a good idea to update to say that
thermal-sensor-cells could be different from 0 too.

That was my mindset to set thermal-sensor-cells to 0, since we only
support SoC which has only one thermal sensor at the moment.

> Thus for A33/H3 we will have thermal-sensor-cells to 1, but only have
> <&ths 0>.
> 

That's non-sense. There is one thermal sensor for the A33,
thermal-sensor-cells has to be 0.

I don't mind to remove the requirement for thermal-sensor-cells to be 0
but I won't put a requirement for it to be 1 as it isn't true.

Thanks,
Quentin
>> + compatible = "allwinner,sun8i-a33-gpadc-iio";
>> + reg = <0x01c25000 0x100>;
>> + #thermal-sensor-cells = <0>;
>> + #io-channel-cells = <0>;
>> + };
>> +
>> +sun4i, sun5i and sun6i SoCs are also supported via the older binding:
>> +
>> +sun4i resistive touchscreen controller
>> +--------------------------------------
>> +
>> +Required properties:
>> + - compatible: "allwinner,sun4i-a10-ts", "allwinner,sun5i-a13-ts" or
>> + "allwinner,sun6i-a31-ts"
>> + - reg: mmio address range of the chip
>> + - interrupts: interrupt to which the chip is connected
>> + - #thermal-sensor-cells: shall be 0
>> +
>> +Optional properties:
>> + - allwinner,ts-attached : boolean indicating that an actual touchscreen
>> + is attached to the controller
>> + - allwinner,tp-sensitive-adjust : integer (4 bits)
>> + adjust sensitivity of pen down detection
>> + between 0 (least sensitive) and 15
>> + (defaults to 15)
>> + - allwinner,filter-type : integer (2 bits)
>> + select median and averaging filter
>> + samples used for median / averaging filter
>> + 0: 4/2
>> + 1: 5/3
>> + 2: 8/4
>> + 3: 16/8
>> + (defaults to 1)
>> +
>> +Example:
>> +
>> + rtp: rtp@01c25000 {
>> + compatible = "allwinner,sun4i-a10-ts";
>> + reg = <0x01c25000 0x100>;
>> + interrupts = <29>;
>> + allwinner,ts-attached;
>> + #thermal-sensor-cells = <0>;
>> + /* sensitive/noisy touch panel */
>> + allwinner,tp-sensitive-adjust = <0>;
>> + allwinner,filter-type = <3>;
>> + };
>> --
>> 2.9.3
>>
>> _______________________________________________
>> linux-arm-kernel mailing list
>> linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> 

-- 
Quentin Schulz, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH v2 05/11] Documentation: DT: bindings: mfd: add A33 GPADC binding
@ 2017-03-11 14:07         ` Quentin Schulz
  0 siblings, 0 replies; 85+ messages in thread
From: Quentin Schulz @ 2017-03-11 14:07 UTC (permalink / raw)
  To: Icenowy Zheng, dmitry.torokhov, robh+dt, mark.rutland,
	maxime.ripard, wens, lee.jones, linux, jic23, knaack.h, lars,
	pmeerw, stefan.mavrodiev
  Cc: thomas.petazzoni, devicetree, linux-iio, linux-kernel,
	linux-sunxi, linux-arm-kernel

Hi Icenowy,

On 10/03/2017 20:25, Icenowy Zheng wrote:
> 
> 
> 10.03.2017, 18:56, "Quentin Schulz" <quentin.schulz@free-electrons.com>:
>> This patch adds documentation for the A33 GPADC binding.
>>
>> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
>> ---
>>
>> added in v2
>>
>>  .../devicetree/bindings/mfd/sun4i-gpadc.txt | 59 ++++++++++++++++++++++
>>  1 file changed, 59 insertions(+)
>>  create mode 100644 Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
>>
>> diff --git a/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt b/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
>> new file mode 100644
>> index 0000000..17242c8
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
>> @@ -0,0 +1,59 @@
>> +Allwinner SoCs' GPADC Device Tree bindings
>> +------------------------------------------
>> +The Allwinner SoCs all have an ADC that can also act as a thermal sensor
>> +and sometimes as a touchscreen controller.
>> +
>> +Required properties:
>> + - compatible: "sun8i-a33-gpadc-iio",
>> + - reg: mmio address range of the chip,
>> + - #thermal-sensor-cells: shall be 0,
>> + - #io-channel-cells: shall be 0,
>> +
>> +Example:
>> + rtp: rtp@01c25000 {
> 
> I think we'd better call it ths.
> 

To match the datasheet, I agree.

> And can you make thermal-sensor-cells become 1?
> 
> Maxime Ripard wants to base H3/H5/A64 thermal driver on this patchset, and
> for H5/A64 there's 2/3 thermal sensors.
> 

Yes, that'll require a specific DT node for those thermal sensors. Then
since we would update the possible compatibles in the documentation
anyway, that would be a good idea to update to say that
thermal-sensor-cells could be different from 0 too.

That was my mindset to set thermal-sensor-cells to 0, since we only
support SoC which has only one thermal sensor at the moment.

> Thus for A33/H3 we will have thermal-sensor-cells to 1, but only have
> <&ths 0>.
> 

That's non-sense. There is one thermal sensor for the A33,
thermal-sensor-cells has to be 0.

I don't mind to remove the requirement for thermal-sensor-cells to be 0
but I won't put a requirement for it to be 1 as it isn't true.

Thanks,
Quentin
>> + compatible = "allwinner,sun8i-a33-gpadc-iio";
>> + reg = <0x01c25000 0x100>;
>> + #thermal-sensor-cells = <0>;
>> + #io-channel-cells = <0>;
>> + };
>> +
>> +sun4i, sun5i and sun6i SoCs are also supported via the older binding:
>> +
>> +sun4i resistive touchscreen controller
>> +--------------------------------------
>> +
>> +Required properties:
>> + - compatible: "allwinner,sun4i-a10-ts", "allwinner,sun5i-a13-ts" or
>> + "allwinner,sun6i-a31-ts"
>> + - reg: mmio address range of the chip
>> + - interrupts: interrupt to which the chip is connected
>> + - #thermal-sensor-cells: shall be 0
>> +
>> +Optional properties:
>> + - allwinner,ts-attached : boolean indicating that an actual touchscreen
>> + is attached to the controller
>> + - allwinner,tp-sensitive-adjust : integer (4 bits)
>> + adjust sensitivity of pen down detection
>> + between 0 (least sensitive) and 15
>> + (defaults to 15)
>> + - allwinner,filter-type : integer (2 bits)
>> + select median and averaging filter
>> + samples used for median / averaging filter
>> + 0: 4/2
>> + 1: 5/3
>> + 2: 8/4
>> + 3: 16/8
>> + (defaults to 1)
>> +
>> +Example:
>> +
>> + rtp: rtp@01c25000 {
>> + compatible = "allwinner,sun4i-a10-ts";
>> + reg = <0x01c25000 0x100>;
>> + interrupts = <29>;
>> + allwinner,ts-attached;
>> + #thermal-sensor-cells = <0>;
>> + /* sensitive/noisy touch panel */
>> + allwinner,tp-sensitive-adjust = <0>;
>> + allwinner,filter-type = <3>;
>> + };
>> --
>> 2.9.3
>>
>> _______________________________________________
>> linux-arm-kernel mailing list
>> linux-arm-kernel@lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> 

-- 
Quentin Schulz, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 85+ messages in thread

* [PATCH v2 05/11] Documentation: DT: bindings: mfd: add A33 GPADC binding
@ 2017-03-11 14:07         ` Quentin Schulz
  0 siblings, 0 replies; 85+ messages in thread
From: Quentin Schulz @ 2017-03-11 14:07 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Icenowy,

On 10/03/2017 20:25, Icenowy Zheng wrote:
> 
> 
> 10.03.2017, 18:56, "Quentin Schulz" <quentin.schulz@free-electrons.com>:
>> This patch adds documentation for the A33 GPADC binding.
>>
>> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
>> ---
>>
>> added in v2
>>
>>  .../devicetree/bindings/mfd/sun4i-gpadc.txt | 59 ++++++++++++++++++++++
>>  1 file changed, 59 insertions(+)
>>  create mode 100644 Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
>>
>> diff --git a/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt b/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
>> new file mode 100644
>> index 0000000..17242c8
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
>> @@ -0,0 +1,59 @@
>> +Allwinner SoCs' GPADC Device Tree bindings
>> +------------------------------------------
>> +The Allwinner SoCs all have an ADC that can also act as a thermal sensor
>> +and sometimes as a touchscreen controller.
>> +
>> +Required properties:
>> + - compatible: "sun8i-a33-gpadc-iio",
>> + - reg: mmio address range of the chip,
>> + - #thermal-sensor-cells: shall be 0,
>> + - #io-channel-cells: shall be 0,
>> +
>> +Example:
>> + rtp: rtp at 01c25000 {
> 
> I think we'd better call it ths.
> 

To match the datasheet, I agree.

> And can you make thermal-sensor-cells become 1?
> 
> Maxime Ripard wants to base H3/H5/A64 thermal driver on this patchset, and
> for H5/A64 there's 2/3 thermal sensors.
> 

Yes, that'll require a specific DT node for those thermal sensors. Then
since we would update the possible compatibles in the documentation
anyway, that would be a good idea to update to say that
thermal-sensor-cells could be different from 0 too.

That was my mindset to set thermal-sensor-cells to 0, since we only
support SoC which has only one thermal sensor at the moment.

> Thus for A33/H3 we will have thermal-sensor-cells to 1, but only have
> <&ths 0>.
> 

That's non-sense. There is one thermal sensor for the A33,
thermal-sensor-cells has to be 0.

I don't mind to remove the requirement for thermal-sensor-cells to be 0
but I won't put a requirement for it to be 1 as it isn't true.

Thanks,
Quentin
>> + compatible = "allwinner,sun8i-a33-gpadc-iio";
>> + reg = <0x01c25000 0x100>;
>> + #thermal-sensor-cells = <0>;
>> + #io-channel-cells = <0>;
>> + };
>> +
>> +sun4i, sun5i and sun6i SoCs are also supported via the older binding:
>> +
>> +sun4i resistive touchscreen controller
>> +--------------------------------------
>> +
>> +Required properties:
>> + - compatible: "allwinner,sun4i-a10-ts", "allwinner,sun5i-a13-ts" or
>> + "allwinner,sun6i-a31-ts"
>> + - reg: mmio address range of the chip
>> + - interrupts: interrupt to which the chip is connected
>> + - #thermal-sensor-cells: shall be 0
>> +
>> +Optional properties:
>> + - allwinner,ts-attached : boolean indicating that an actual touchscreen
>> + is attached to the controller
>> + - allwinner,tp-sensitive-adjust : integer (4 bits)
>> + adjust sensitivity of pen down detection
>> + between 0 (least sensitive) and 15
>> + (defaults to 15)
>> + - allwinner,filter-type : integer (2 bits)
>> + select median and averaging filter
>> + samples used for median / averaging filter
>> + 0: 4/2
>> + 1: 5/3
>> + 2: 8/4
>> + 3: 16/8
>> + (defaults to 1)
>> +
>> +Example:
>> +
>> + rtp: rtp at 01c25000 {
>> + compatible = "allwinner,sun4i-a10-ts";
>> + reg = <0x01c25000 0x100>;
>> + interrupts = <29>;
>> + allwinner,ts-attached;
>> + #thermal-sensor-cells = <0>;
>> + /* sensitive/noisy touch panel */
>> + allwinner,tp-sensitive-adjust = <0>;
>> + allwinner,filter-type = <3>;
>> + };
>> --
>> 2.9.3
>>
>> _______________________________________________
>> linux-arm-kernel mailing list
>> linux-arm-kernel at lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> 

-- 
Quentin Schulz, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH v2 07/11] iio: adc: sun4i-gpadc-iio: move code used in MFD probing to new function
@ 2017-03-11 14:09         ` Quentin Schulz
  0 siblings, 0 replies; 85+ messages in thread
From: Quentin Schulz @ 2017-03-11 14:09 UTC (permalink / raw)
  To: icenowy, dmitry.torokhov, robh+dt, mark.rutland, maxime.ripard,
	wens, lee.jones, linux, jic23, knaack.h, lars, pmeerw,
	stefan.mavrodiev
  Cc: thomas.petazzoni, devicetree, linux-iio, linux-kernel,
	linux-sunxi, linux-arm-kernel

Hi Icenowy,

On 10/03/2017 20:36, Icenowy Zheng wrote:
> 
> 
> 10.03.2017, 18:56, "Quentin Schulz" <quentin.schulz@free-electrons.com>:
>> This moves code used in MFD probing to a new sun4i_gpadc_probe_mfd
>> function.
>>
>> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
>> ---
>>
>> added in v2
>>
>>  drivers/iio/adc/sun4i-gpadc-iio.c | 78 ++++++++++++++++++++++-----------------
> 
> I cannot find this source file even in linux-next.
> 

>From the cover letter:

This series of patch is based on this[1] series of patch.

[1] https://lkml.org/lkml/2016/12/13/298 : "[PATCH v9] add support for
Allwinner SoCs ADC"

Quentin
>>  1 file changed, 45 insertions(+), 33 deletions(-)
>>
>> diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c
>> index a8e134f..7cb997a 100644
>> --- a/drivers/iio/adc/sun4i-gpadc-iio.c
>> +++ b/drivers/iio/adc/sun4i-gpadc-iio.c
>> @@ -454,31 +454,16 @@ static int sun4i_irq_init(struct platform_device *pdev, const char *name,
>>          return 0;
>>  }
>>
>> -static int sun4i_gpadc_probe(struct platform_device *pdev)
>> +static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
>> + struct iio_dev *indio_dev)
>>  {
>> - struct sun4i_gpadc_iio *info;
>> - struct iio_dev *indio_dev;
>> + struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
>> + struct sun4i_gpadc_dev *sun4i_gpadc_dev =
>> + dev_get_drvdata(pdev->dev.parent);
>>          int ret;
>> - struct sun4i_gpadc_dev *sun4i_gpadc_dev;
>> -
>> - sun4i_gpadc_dev = dev_get_drvdata(pdev->dev.parent);
>> -
>> - indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*info));
>> - if (!indio_dev)
>> - return -ENOMEM;
>>
>> - info = iio_priv(indio_dev);
>> - platform_set_drvdata(pdev, indio_dev);
>> -
>> - mutex_init(&info->mutex);
>>          info->regmap = sun4i_gpadc_dev->regmap;
>> - info->indio_dev = indio_dev;
>> - init_completion(&info->completion);
>> - indio_dev->name = dev_name(&pdev->dev);
>> - indio_dev->dev.parent = &pdev->dev;
>> - indio_dev->dev.of_node = pdev->dev.of_node;
>> - indio_dev->info = &sun4i_gpadc_iio_info;
>> - indio_dev->modes = INDIO_DIRECT_MODE;
>> +
>>          indio_dev->num_channels = ARRAY_SIZE(sun4i_gpadc_channels);
>>          indio_dev->channels = sun4i_gpadc_channels;
>>
>> @@ -519,8 +504,7 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>>                          dev_err(&pdev->dev,
>>                                  "could not register thermal sensor: %ld\n",
>>                                  PTR_ERR(tzd));
>> - ret = PTR_ERR(tzd);
>> - goto err;
>> + return PTR_ERR(tzd);
>>                  }
>>          } else {
>>                  indio_dev->num_channels =
>> @@ -528,36 +512,65 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>>                  indio_dev->channels = sun4i_gpadc_channels_no_temp;
>>          }
>>
>> - pm_runtime_set_autosuspend_delay(&pdev->dev,
>> - SUN4I_GPADC_AUTOSUSPEND_DELAY);
>> - pm_runtime_use_autosuspend(&pdev->dev);
>> - pm_runtime_set_suspended(&pdev->dev);
>> - pm_runtime_enable(&pdev->dev);
>> -
>>          if (IS_ENABLED(CONFIG_THERMAL_OF)) {
>>                  ret = sun4i_irq_init(pdev, "TEMP_DATA_PENDING",
>>                                       sun4i_gpadc_temp_data_irq_handler,
>>                                       "temp_data", &info->temp_data_irq,
>>                                       &info->ignore_temp_data_irq);
>>                  if (ret < 0)
>> - goto err;
>> + return ret;
>>          }
>>
>>          ret = sun4i_irq_init(pdev, "FIFO_DATA_PENDING",
>>                               sun4i_gpadc_fifo_data_irq_handler, "fifo_data",
>>                               &info->fifo_data_irq, &info->ignore_fifo_data_irq);
>>          if (ret < 0)
>> - goto err;
>> + return ret;
>>
>>          if (IS_ENABLED(CONFIG_THERMAL_OF)) {
>>                  ret = iio_map_array_register(indio_dev, sun4i_gpadc_hwmon_maps);
>>                  if (ret < 0) {
>>                          dev_err(&pdev->dev,
>>                                  "failed to register iio map array\n");
>> - goto err;
>> + return ret;
>>                  }
>>          }
>>
>> + return 0;
>> +}
>> +
>> +static int sun4i_gpadc_probe(struct platform_device *pdev)
>> +{
>> + struct sun4i_gpadc_iio *info;
>> + struct iio_dev *indio_dev;
>> + int ret;
>> +
>> + indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*info));
>> + if (!indio_dev)
>> + return -ENOMEM;
>> +
>> + info = iio_priv(indio_dev);
>> + platform_set_drvdata(pdev, indio_dev);
>> +
>> + mutex_init(&info->mutex);
>> + info->indio_dev = indio_dev;
>> + init_completion(&info->completion);
>> + indio_dev->name = dev_name(&pdev->dev);
>> + indio_dev->dev.parent = &pdev->dev;
>> + indio_dev->dev.of_node = pdev->dev.of_node;
>> + indio_dev->info = &sun4i_gpadc_iio_info;
>> + indio_dev->modes = INDIO_DIRECT_MODE;
>> +
>> + ret = sun4i_gpadc_probe_mfd(pdev, indio_dev);
>> + if (ret)
>> + return ret;
>> +
>> + pm_runtime_set_autosuspend_delay(&pdev->dev,
>> + SUN4I_GPADC_AUTOSUSPEND_DELAY);
>> + pm_runtime_use_autosuspend(&pdev->dev);
>> + pm_runtime_set_suspended(&pdev->dev);
>> + pm_runtime_enable(&pdev->dev);
>> +
>>          ret = devm_iio_device_register(&pdev->dev, indio_dev);
>>          if (ret < 0) {
>>                  dev_err(&pdev->dev, "could not register the device\n");
>> @@ -570,7 +583,6 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>>          if (IS_ENABLED(CONFIG_THERMAL_OF))
>>                  iio_map_array_unregister(indio_dev);
>>
>> -err:
>>          pm_runtime_put(&pdev->dev);
>>          pm_runtime_disable(&pdev->dev);
>>
>> --
>> 2.9.3
>>
>> _______________________________________________
>> linux-arm-kernel mailing list
>> linux-arm-kernel@lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> 

-- 
Quentin Schulz, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH v2 07/11] iio: adc: sun4i-gpadc-iio: move code used in MFD probing to new function
@ 2017-03-11 14:09         ` Quentin Schulz
  0 siblings, 0 replies; 85+ messages in thread
From: Quentin Schulz @ 2017-03-11 14:09 UTC (permalink / raw)
  To: icenowy-ymACFijhrKM, dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8, wens-jdAy2FN1RRM,
	lee.jones-QSEj5FYQhm4dnm+yROfE0A, linux-I+IVW8TIWO2tmTQ+vhA3Yw,
	jic23-DgEjT+Ai2ygdnm+yROfE0A, knaack.h-Mmb7MZpHnFY,
	lars-Qo5EllUWu/uELgA04lAiVw, pmeerw-jW+XmwGofnusTnJN9+BGXg,
	stefan.mavrodiev-Re5JQEeQqe8AvxtiuMwx3w
  Cc: thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-iio-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

Hi Icenowy,

On 10/03/2017 20:36, Icenowy Zheng wrote:
> 
> 
> 10.03.2017, 18:56, "Quentin Schulz" <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>:
>> This moves code used in MFD probing to a new sun4i_gpadc_probe_mfd
>> function.
>>
>> Signed-off-by: Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
>> ---
>>
>> added in v2
>>
>>  drivers/iio/adc/sun4i-gpadc-iio.c | 78 ++++++++++++++++++++++-----------------
> 
> I cannot find this source file even in linux-next.
> 

>From the cover letter:

This series of patch is based on this[1] series of patch.

[1] https://lkml.org/lkml/2016/12/13/298 : "[PATCH v9] add support for
Allwinner SoCs ADC"

Quentin
>>  1 file changed, 45 insertions(+), 33 deletions(-)
>>
>> diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c
>> index a8e134f..7cb997a 100644
>> --- a/drivers/iio/adc/sun4i-gpadc-iio.c
>> +++ b/drivers/iio/adc/sun4i-gpadc-iio.c
>> @@ -454,31 +454,16 @@ static int sun4i_irq_init(struct platform_device *pdev, const char *name,
>>          return 0;
>>  }
>>
>> -static int sun4i_gpadc_probe(struct platform_device *pdev)
>> +static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
>> + struct iio_dev *indio_dev)
>>  {
>> - struct sun4i_gpadc_iio *info;
>> - struct iio_dev *indio_dev;
>> + struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
>> + struct sun4i_gpadc_dev *sun4i_gpadc_dev =
>> + dev_get_drvdata(pdev->dev.parent);
>>          int ret;
>> - struct sun4i_gpadc_dev *sun4i_gpadc_dev;
>> -
>> - sun4i_gpadc_dev = dev_get_drvdata(pdev->dev.parent);
>> -
>> - indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*info));
>> - if (!indio_dev)
>> - return -ENOMEM;
>>
>> - info = iio_priv(indio_dev);
>> - platform_set_drvdata(pdev, indio_dev);
>> -
>> - mutex_init(&info->mutex);
>>          info->regmap = sun4i_gpadc_dev->regmap;
>> - info->indio_dev = indio_dev;
>> - init_completion(&info->completion);
>> - indio_dev->name = dev_name(&pdev->dev);
>> - indio_dev->dev.parent = &pdev->dev;
>> - indio_dev->dev.of_node = pdev->dev.of_node;
>> - indio_dev->info = &sun4i_gpadc_iio_info;
>> - indio_dev->modes = INDIO_DIRECT_MODE;
>> +
>>          indio_dev->num_channels = ARRAY_SIZE(sun4i_gpadc_channels);
>>          indio_dev->channels = sun4i_gpadc_channels;
>>
>> @@ -519,8 +504,7 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>>                          dev_err(&pdev->dev,
>>                                  "could not register thermal sensor: %ld\n",
>>                                  PTR_ERR(tzd));
>> - ret = PTR_ERR(tzd);
>> - goto err;
>> + return PTR_ERR(tzd);
>>                  }
>>          } else {
>>                  indio_dev->num_channels =
>> @@ -528,36 +512,65 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>>                  indio_dev->channels = sun4i_gpadc_channels_no_temp;
>>          }
>>
>> - pm_runtime_set_autosuspend_delay(&pdev->dev,
>> - SUN4I_GPADC_AUTOSUSPEND_DELAY);
>> - pm_runtime_use_autosuspend(&pdev->dev);
>> - pm_runtime_set_suspended(&pdev->dev);
>> - pm_runtime_enable(&pdev->dev);
>> -
>>          if (IS_ENABLED(CONFIG_THERMAL_OF)) {
>>                  ret = sun4i_irq_init(pdev, "TEMP_DATA_PENDING",
>>                                       sun4i_gpadc_temp_data_irq_handler,
>>                                       "temp_data", &info->temp_data_irq,
>>                                       &info->ignore_temp_data_irq);
>>                  if (ret < 0)
>> - goto err;
>> + return ret;
>>          }
>>
>>          ret = sun4i_irq_init(pdev, "FIFO_DATA_PENDING",
>>                               sun4i_gpadc_fifo_data_irq_handler, "fifo_data",
>>                               &info->fifo_data_irq, &info->ignore_fifo_data_irq);
>>          if (ret < 0)
>> - goto err;
>> + return ret;
>>
>>          if (IS_ENABLED(CONFIG_THERMAL_OF)) {
>>                  ret = iio_map_array_register(indio_dev, sun4i_gpadc_hwmon_maps);
>>                  if (ret < 0) {
>>                          dev_err(&pdev->dev,
>>                                  "failed to register iio map array\n");
>> - goto err;
>> + return ret;
>>                  }
>>          }
>>
>> + return 0;
>> +}
>> +
>> +static int sun4i_gpadc_probe(struct platform_device *pdev)
>> +{
>> + struct sun4i_gpadc_iio *info;
>> + struct iio_dev *indio_dev;
>> + int ret;
>> +
>> + indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*info));
>> + if (!indio_dev)
>> + return -ENOMEM;
>> +
>> + info = iio_priv(indio_dev);
>> + platform_set_drvdata(pdev, indio_dev);
>> +
>> + mutex_init(&info->mutex);
>> + info->indio_dev = indio_dev;
>> + init_completion(&info->completion);
>> + indio_dev->name = dev_name(&pdev->dev);
>> + indio_dev->dev.parent = &pdev->dev;
>> + indio_dev->dev.of_node = pdev->dev.of_node;
>> + indio_dev->info = &sun4i_gpadc_iio_info;
>> + indio_dev->modes = INDIO_DIRECT_MODE;
>> +
>> + ret = sun4i_gpadc_probe_mfd(pdev, indio_dev);
>> + if (ret)
>> + return ret;
>> +
>> + pm_runtime_set_autosuspend_delay(&pdev->dev,
>> + SUN4I_GPADC_AUTOSUSPEND_DELAY);
>> + pm_runtime_use_autosuspend(&pdev->dev);
>> + pm_runtime_set_suspended(&pdev->dev);
>> + pm_runtime_enable(&pdev->dev);
>> +
>>          ret = devm_iio_device_register(&pdev->dev, indio_dev);
>>          if (ret < 0) {
>>                  dev_err(&pdev->dev, "could not register the device\n");
>> @@ -570,7 +583,6 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>>          if (IS_ENABLED(CONFIG_THERMAL_OF))
>>                  iio_map_array_unregister(indio_dev);
>>
>> -err:
>>          pm_runtime_put(&pdev->dev);
>>          pm_runtime_disable(&pdev->dev);
>>
>> --
>> 2.9.3
>>
>> _______________________________________________
>> linux-arm-kernel mailing list
>> linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> 

-- 
Quentin Schulz, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH v2 07/11] iio: adc: sun4i-gpadc-iio: move code used in MFD probing to new function
@ 2017-03-11 14:09         ` Quentin Schulz
  0 siblings, 0 replies; 85+ messages in thread
From: Quentin Schulz @ 2017-03-11 14:09 UTC (permalink / raw)
  To: icenowy, dmitry.torokhov, robh+dt, mark.rutland, maxime.ripard,
	wens, lee.jones, linux, jic23, knaack.h, lars, pmeerw,
	stefan.mavrodiev
  Cc: thomas.petazzoni, devicetree, linux-iio, linux-kernel,
	linux-sunxi, linux-arm-kernel

Hi Icenowy,

On 10/03/2017 20:36, Icenowy Zheng wrote:
> 
> 
> 10.03.2017, 18:56, "Quentin Schulz" <quentin.schulz@free-electrons.com>:
>> This moves code used in MFD probing to a new sun4i_gpadc_probe_mfd
>> function.
>>
>> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
>> ---
>>
>> added in v2
>>
>>  drivers/iio/adc/sun4i-gpadc-iio.c | 78 ++++++++++++++++++++++-----------------
> 
> I cannot find this source file even in linux-next.
> 

>From the cover letter:

This series of patch is based on this[1] series of patch.

[1] https://lkml.org/lkml/2016/12/13/298 : "[PATCH v9] add support for
Allwinner SoCs ADC"

Quentin
>>  1 file changed, 45 insertions(+), 33 deletions(-)
>>
>> diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c
>> index a8e134f..7cb997a 100644
>> --- a/drivers/iio/adc/sun4i-gpadc-iio.c
>> +++ b/drivers/iio/adc/sun4i-gpadc-iio.c
>> @@ -454,31 +454,16 @@ static int sun4i_irq_init(struct platform_device *pdev, const char *name,
>>          return 0;
>>  }
>>
>> -static int sun4i_gpadc_probe(struct platform_device *pdev)
>> +static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
>> + struct iio_dev *indio_dev)
>>  {
>> - struct sun4i_gpadc_iio *info;
>> - struct iio_dev *indio_dev;
>> + struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
>> + struct sun4i_gpadc_dev *sun4i_gpadc_dev =
>> + dev_get_drvdata(pdev->dev.parent);
>>          int ret;
>> - struct sun4i_gpadc_dev *sun4i_gpadc_dev;
>> -
>> - sun4i_gpadc_dev = dev_get_drvdata(pdev->dev.parent);
>> -
>> - indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*info));
>> - if (!indio_dev)
>> - return -ENOMEM;
>>
>> - info = iio_priv(indio_dev);
>> - platform_set_drvdata(pdev, indio_dev);
>> -
>> - mutex_init(&info->mutex);
>>          info->regmap = sun4i_gpadc_dev->regmap;
>> - info->indio_dev = indio_dev;
>> - init_completion(&info->completion);
>> - indio_dev->name = dev_name(&pdev->dev);
>> - indio_dev->dev.parent = &pdev->dev;
>> - indio_dev->dev.of_node = pdev->dev.of_node;
>> - indio_dev->info = &sun4i_gpadc_iio_info;
>> - indio_dev->modes = INDIO_DIRECT_MODE;
>> +
>>          indio_dev->num_channels = ARRAY_SIZE(sun4i_gpadc_channels);
>>          indio_dev->channels = sun4i_gpadc_channels;
>>
>> @@ -519,8 +504,7 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>>                          dev_err(&pdev->dev,
>>                                  "could not register thermal sensor: %ld\n",
>>                                  PTR_ERR(tzd));
>> - ret = PTR_ERR(tzd);
>> - goto err;
>> + return PTR_ERR(tzd);
>>                  }
>>          } else {
>>                  indio_dev->num_channels =
>> @@ -528,36 +512,65 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>>                  indio_dev->channels = sun4i_gpadc_channels_no_temp;
>>          }
>>
>> - pm_runtime_set_autosuspend_delay(&pdev->dev,
>> - SUN4I_GPADC_AUTOSUSPEND_DELAY);
>> - pm_runtime_use_autosuspend(&pdev->dev);
>> - pm_runtime_set_suspended(&pdev->dev);
>> - pm_runtime_enable(&pdev->dev);
>> -
>>          if (IS_ENABLED(CONFIG_THERMAL_OF)) {
>>                  ret = sun4i_irq_init(pdev, "TEMP_DATA_PENDING",
>>                                       sun4i_gpadc_temp_data_irq_handler,
>>                                       "temp_data", &info->temp_data_irq,
>>                                       &info->ignore_temp_data_irq);
>>                  if (ret < 0)
>> - goto err;
>> + return ret;
>>          }
>>
>>          ret = sun4i_irq_init(pdev, "FIFO_DATA_PENDING",
>>                               sun4i_gpadc_fifo_data_irq_handler, "fifo_data",
>>                               &info->fifo_data_irq, &info->ignore_fifo_data_irq);
>>          if (ret < 0)
>> - goto err;
>> + return ret;
>>
>>          if (IS_ENABLED(CONFIG_THERMAL_OF)) {
>>                  ret = iio_map_array_register(indio_dev, sun4i_gpadc_hwmon_maps);
>>                  if (ret < 0) {
>>                          dev_err(&pdev->dev,
>>                                  "failed to register iio map array\n");
>> - goto err;
>> + return ret;
>>                  }
>>          }
>>
>> + return 0;
>> +}
>> +
>> +static int sun4i_gpadc_probe(struct platform_device *pdev)
>> +{
>> + struct sun4i_gpadc_iio *info;
>> + struct iio_dev *indio_dev;
>> + int ret;
>> +
>> + indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*info));
>> + if (!indio_dev)
>> + return -ENOMEM;
>> +
>> + info = iio_priv(indio_dev);
>> + platform_set_drvdata(pdev, indio_dev);
>> +
>> + mutex_init(&info->mutex);
>> + info->indio_dev = indio_dev;
>> + init_completion(&info->completion);
>> + indio_dev->name = dev_name(&pdev->dev);
>> + indio_dev->dev.parent = &pdev->dev;
>> + indio_dev->dev.of_node = pdev->dev.of_node;
>> + indio_dev->info = &sun4i_gpadc_iio_info;
>> + indio_dev->modes = INDIO_DIRECT_MODE;
>> +
>> + ret = sun4i_gpadc_probe_mfd(pdev, indio_dev);
>> + if (ret)
>> + return ret;
>> +
>> + pm_runtime_set_autosuspend_delay(&pdev->dev,
>> + SUN4I_GPADC_AUTOSUSPEND_DELAY);
>> + pm_runtime_use_autosuspend(&pdev->dev);
>> + pm_runtime_set_suspended(&pdev->dev);
>> + pm_runtime_enable(&pdev->dev);
>> +
>>          ret = devm_iio_device_register(&pdev->dev, indio_dev);
>>          if (ret < 0) {
>>                  dev_err(&pdev->dev, "could not register the device\n");
>> @@ -570,7 +583,6 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>>          if (IS_ENABLED(CONFIG_THERMAL_OF))
>>                  iio_map_array_unregister(indio_dev);
>>
>> -err:
>>          pm_runtime_put(&pdev->dev);
>>          pm_runtime_disable(&pdev->dev);
>>
>> --
>> 2.9.3
>>
>> _______________________________________________
>> linux-arm-kernel mailing list
>> linux-arm-kernel@lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> 

-- 
Quentin Schulz, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 85+ messages in thread

* [PATCH v2 07/11] iio: adc: sun4i-gpadc-iio: move code used in MFD probing to new function
@ 2017-03-11 14:09         ` Quentin Schulz
  0 siblings, 0 replies; 85+ messages in thread
From: Quentin Schulz @ 2017-03-11 14:09 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Icenowy,

On 10/03/2017 20:36, Icenowy Zheng wrote:
> 
> 
> 10.03.2017, 18:56, "Quentin Schulz" <quentin.schulz@free-electrons.com>:
>> This moves code used in MFD probing to a new sun4i_gpadc_probe_mfd
>> function.
>>
>> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
>> ---
>>
>> added in v2
>>
>>  drivers/iio/adc/sun4i-gpadc-iio.c | 78 ++++++++++++++++++++++-----------------
> 
> I cannot find this source file even in linux-next.
> 

>From the cover letter:

This series of patch is based on this[1] series of patch.

[1] https://lkml.org/lkml/2016/12/13/298 : "[PATCH v9] add support for
Allwinner SoCs ADC"

Quentin
>>  1 file changed, 45 insertions(+), 33 deletions(-)
>>
>> diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c
>> index a8e134f..7cb997a 100644
>> --- a/drivers/iio/adc/sun4i-gpadc-iio.c
>> +++ b/drivers/iio/adc/sun4i-gpadc-iio.c
>> @@ -454,31 +454,16 @@ static int sun4i_irq_init(struct platform_device *pdev, const char *name,
>>          return 0;
>>  }
>>
>> -static int sun4i_gpadc_probe(struct platform_device *pdev)
>> +static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
>> + struct iio_dev *indio_dev)
>>  {
>> - struct sun4i_gpadc_iio *info;
>> - struct iio_dev *indio_dev;
>> + struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
>> + struct sun4i_gpadc_dev *sun4i_gpadc_dev =
>> + dev_get_drvdata(pdev->dev.parent);
>>          int ret;
>> - struct sun4i_gpadc_dev *sun4i_gpadc_dev;
>> -
>> - sun4i_gpadc_dev = dev_get_drvdata(pdev->dev.parent);
>> -
>> - indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*info));
>> - if (!indio_dev)
>> - return -ENOMEM;
>>
>> - info = iio_priv(indio_dev);
>> - platform_set_drvdata(pdev, indio_dev);
>> -
>> - mutex_init(&info->mutex);
>>          info->regmap = sun4i_gpadc_dev->regmap;
>> - info->indio_dev = indio_dev;
>> - init_completion(&info->completion);
>> - indio_dev->name = dev_name(&pdev->dev);
>> - indio_dev->dev.parent = &pdev->dev;
>> - indio_dev->dev.of_node = pdev->dev.of_node;
>> - indio_dev->info = &sun4i_gpadc_iio_info;
>> - indio_dev->modes = INDIO_DIRECT_MODE;
>> +
>>          indio_dev->num_channels = ARRAY_SIZE(sun4i_gpadc_channels);
>>          indio_dev->channels = sun4i_gpadc_channels;
>>
>> @@ -519,8 +504,7 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>>                          dev_err(&pdev->dev,
>>                                  "could not register thermal sensor: %ld\n",
>>                                  PTR_ERR(tzd));
>> - ret = PTR_ERR(tzd);
>> - goto err;
>> + return PTR_ERR(tzd);
>>                  }
>>          } else {
>>                  indio_dev->num_channels =
>> @@ -528,36 +512,65 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>>                  indio_dev->channels = sun4i_gpadc_channels_no_temp;
>>          }
>>
>> - pm_runtime_set_autosuspend_delay(&pdev->dev,
>> - SUN4I_GPADC_AUTOSUSPEND_DELAY);
>> - pm_runtime_use_autosuspend(&pdev->dev);
>> - pm_runtime_set_suspended(&pdev->dev);
>> - pm_runtime_enable(&pdev->dev);
>> -
>>          if (IS_ENABLED(CONFIG_THERMAL_OF)) {
>>                  ret = sun4i_irq_init(pdev, "TEMP_DATA_PENDING",
>>                                       sun4i_gpadc_temp_data_irq_handler,
>>                                       "temp_data", &info->temp_data_irq,
>>                                       &info->ignore_temp_data_irq);
>>                  if (ret < 0)
>> - goto err;
>> + return ret;
>>          }
>>
>>          ret = sun4i_irq_init(pdev, "FIFO_DATA_PENDING",
>>                               sun4i_gpadc_fifo_data_irq_handler, "fifo_data",
>>                               &info->fifo_data_irq, &info->ignore_fifo_data_irq);
>>          if (ret < 0)
>> - goto err;
>> + return ret;
>>
>>          if (IS_ENABLED(CONFIG_THERMAL_OF)) {
>>                  ret = iio_map_array_register(indio_dev, sun4i_gpadc_hwmon_maps);
>>                  if (ret < 0) {
>>                          dev_err(&pdev->dev,
>>                                  "failed to register iio map array\n");
>> - goto err;
>> + return ret;
>>                  }
>>          }
>>
>> + return 0;
>> +}
>> +
>> +static int sun4i_gpadc_probe(struct platform_device *pdev)
>> +{
>> + struct sun4i_gpadc_iio *info;
>> + struct iio_dev *indio_dev;
>> + int ret;
>> +
>> + indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*info));
>> + if (!indio_dev)
>> + return -ENOMEM;
>> +
>> + info = iio_priv(indio_dev);
>> + platform_set_drvdata(pdev, indio_dev);
>> +
>> + mutex_init(&info->mutex);
>> + info->indio_dev = indio_dev;
>> + init_completion(&info->completion);
>> + indio_dev->name = dev_name(&pdev->dev);
>> + indio_dev->dev.parent = &pdev->dev;
>> + indio_dev->dev.of_node = pdev->dev.of_node;
>> + indio_dev->info = &sun4i_gpadc_iio_info;
>> + indio_dev->modes = INDIO_DIRECT_MODE;
>> +
>> + ret = sun4i_gpadc_probe_mfd(pdev, indio_dev);
>> + if (ret)
>> + return ret;
>> +
>> + pm_runtime_set_autosuspend_delay(&pdev->dev,
>> + SUN4I_GPADC_AUTOSUSPEND_DELAY);
>> + pm_runtime_use_autosuspend(&pdev->dev);
>> + pm_runtime_set_suspended(&pdev->dev);
>> + pm_runtime_enable(&pdev->dev);
>> +
>>          ret = devm_iio_device_register(&pdev->dev, indio_dev);
>>          if (ret < 0) {
>>                  dev_err(&pdev->dev, "could not register the device\n");
>> @@ -570,7 +583,6 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>>          if (IS_ENABLED(CONFIG_THERMAL_OF))
>>                  iio_map_array_unregister(indio_dev);
>>
>> -err:
>>          pm_runtime_put(&pdev->dev);
>>          pm_runtime_disable(&pdev->dev);
>>
>> --
>> 2.9.3
>>
>> _______________________________________________
>> linux-arm-kernel mailing list
>> linux-arm-kernel at lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> 

-- 
Quentin Schulz, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH v2 07/11] iio: adc: sun4i-gpadc-iio: move code used in MFD probing to new function
       [not found]   ` <20170310103921.19469-8-quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
  2017-03-10 19:36       ` Icenowy Zheng
@ 2017-03-13 20:58     ` Jonathan Cameron
  0 siblings, 0 replies; 85+ messages in thread
From: Jonathan Cameron @ 2017-03-13 20:58 UTC (permalink / raw)
  To: Quentin Schulz, dmitry.torokhov, robh+dt, mark.rutland,
	maxime.ripard, wens, lee.jones, linux, knaack.h, lars, pmeerw,
	stefan.mavrodiev
  Cc: devicetree, linux-arm-kernel, linux-kernel, linux-iio,
	linux-sunxi, thomas.petazzoni

On 10/03/17 10:39, Quentin Schulz wrote:
> This moves code used in MFD probing to a new sun4i_gpadc_probe_mfd
> function.
> 
> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
Looks sane to me - though a hint on why in the explanation wouldn't go
amiss!

We'll have to figure out the path for this series at somepoint.
In meantime

Acked-by: Jonathan Cameron <jic23@kernel.org>
> ---
> 
> added in v2
> 
>  drivers/iio/adc/sun4i-gpadc-iio.c | 78 ++++++++++++++++++++++-----------------
>  1 file changed, 45 insertions(+), 33 deletions(-)
> 
> diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c
> index a8e134f..7cb997a 100644
> --- a/drivers/iio/adc/sun4i-gpadc-iio.c
> +++ b/drivers/iio/adc/sun4i-gpadc-iio.c
> @@ -454,31 +454,16 @@ static int sun4i_irq_init(struct platform_device *pdev, const char *name,
>  	return 0;
>  }
>  
> -static int sun4i_gpadc_probe(struct platform_device *pdev)
> +static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
> +				 struct iio_dev *indio_dev)
>  {
> -	struct sun4i_gpadc_iio *info;
> -	struct iio_dev *indio_dev;
> +	struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
> +	struct sun4i_gpadc_dev *sun4i_gpadc_dev =
> +		dev_get_drvdata(pdev->dev.parent);
>  	int ret;
> -	struct sun4i_gpadc_dev *sun4i_gpadc_dev;
> -
> -	sun4i_gpadc_dev = dev_get_drvdata(pdev->dev.parent);
> -
> -	indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*info));
> -	if (!indio_dev)
> -		return -ENOMEM;
>  
> -	info = iio_priv(indio_dev);
> -	platform_set_drvdata(pdev, indio_dev);
> -
> -	mutex_init(&info->mutex);
>  	info->regmap = sun4i_gpadc_dev->regmap;
> -	info->indio_dev = indio_dev;
> -	init_completion(&info->completion);
> -	indio_dev->name = dev_name(&pdev->dev);
> -	indio_dev->dev.parent = &pdev->dev;
> -	indio_dev->dev.of_node = pdev->dev.of_node;
> -	indio_dev->info = &sun4i_gpadc_iio_info;
> -	indio_dev->modes = INDIO_DIRECT_MODE;
> +
>  	indio_dev->num_channels = ARRAY_SIZE(sun4i_gpadc_channels);
>  	indio_dev->channels = sun4i_gpadc_channels;
>  
> @@ -519,8 +504,7 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>  			dev_err(&pdev->dev,
>  				"could not register thermal sensor: %ld\n",
>  				PTR_ERR(tzd));
> -			ret = PTR_ERR(tzd);
> -			goto err;
> +			return PTR_ERR(tzd);
>  		}
>  	} else {
>  		indio_dev->num_channels =
> @@ -528,36 +512,65 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>  		indio_dev->channels = sun4i_gpadc_channels_no_temp;
>  	}
>  
> -	pm_runtime_set_autosuspend_delay(&pdev->dev,
> -					 SUN4I_GPADC_AUTOSUSPEND_DELAY);
> -	pm_runtime_use_autosuspend(&pdev->dev);
> -	pm_runtime_set_suspended(&pdev->dev);
> -	pm_runtime_enable(&pdev->dev);
> -
>  	if (IS_ENABLED(CONFIG_THERMAL_OF)) {
>  		ret = sun4i_irq_init(pdev, "TEMP_DATA_PENDING",
>  				     sun4i_gpadc_temp_data_irq_handler,
>  				     "temp_data", &info->temp_data_irq,
>  				     &info->ignore_temp_data_irq);
>  		if (ret < 0)
> -			goto err;
> +			return ret;
>  	}
>  
>  	ret = sun4i_irq_init(pdev, "FIFO_DATA_PENDING",
>  			     sun4i_gpadc_fifo_data_irq_handler, "fifo_data",
>  			     &info->fifo_data_irq, &info->ignore_fifo_data_irq);
>  	if (ret < 0)
> -		goto err;
> +		return ret;
>  
>  	if (IS_ENABLED(CONFIG_THERMAL_OF)) {
>  		ret = iio_map_array_register(indio_dev, sun4i_gpadc_hwmon_maps);
>  		if (ret < 0) {
>  			dev_err(&pdev->dev,
>  				"failed to register iio map array\n");
> -			goto err;
> +			return ret;
>  		}
>  	}
>  
> +	return 0;
> +}
> +
> +static int sun4i_gpadc_probe(struct platform_device *pdev)
> +{
> +	struct sun4i_gpadc_iio *info;
> +	struct iio_dev *indio_dev;
> +	int ret;
> +
> +	indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*info));
> +	if (!indio_dev)
> +		return -ENOMEM;
> +
> +	info = iio_priv(indio_dev);
> +	platform_set_drvdata(pdev, indio_dev);
> +
> +	mutex_init(&info->mutex);
> +	info->indio_dev = indio_dev;
> +	init_completion(&info->completion);
> +	indio_dev->name = dev_name(&pdev->dev);
> +	indio_dev->dev.parent = &pdev->dev;
> +	indio_dev->dev.of_node = pdev->dev.of_node;
> +	indio_dev->info = &sun4i_gpadc_iio_info;
> +	indio_dev->modes = INDIO_DIRECT_MODE;
> +
> +	ret = sun4i_gpadc_probe_mfd(pdev, indio_dev);
> +	if (ret)
> +		return ret;
> +
> +	pm_runtime_set_autosuspend_delay(&pdev->dev,
> +					 SUN4I_GPADC_AUTOSUSPEND_DELAY);
> +	pm_runtime_use_autosuspend(&pdev->dev);
> +	pm_runtime_set_suspended(&pdev->dev);
> +	pm_runtime_enable(&pdev->dev);
> +
>  	ret = devm_iio_device_register(&pdev->dev, indio_dev);
>  	if (ret < 0) {
>  		dev_err(&pdev->dev, "could not register the device\n");
> @@ -570,7 +583,6 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>  	if (IS_ENABLED(CONFIG_THERMAL_OF))
>  		iio_map_array_unregister(indio_dev);
>  
> -err:
>  	pm_runtime_put(&pdev->dev);
>  	pm_runtime_disable(&pdev->dev);
>  
> 

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH v2 07/11] iio: adc: sun4i-gpadc-iio: move code used in MFD probing to new function
@ 2017-03-13 20:58     ` Jonathan Cameron
  0 siblings, 0 replies; 85+ messages in thread
From: Jonathan Cameron @ 2017-03-13 20:58 UTC (permalink / raw)
  To: Quentin Schulz, dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8, wens-jdAy2FN1RRM,
	lee.jones-QSEj5FYQhm4dnm+yROfE0A, linux-I+IVW8TIWO2tmTQ+vhA3Yw,
	knaack.h-Mmb7MZpHnFY, lars-Qo5EllUWu/uELgA04lAiVw,
	pmeerw-jW+XmwGofnusTnJN9+BGXg,
	stefan.mavrodiev-Re5JQEeQqe8AvxtiuMwx3w
  Cc: devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-iio-u79uwXL29TY76Z2rM5mHXA,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
	thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8

On 10/03/17 10:39, Quentin Schulz wrote:
> This moves code used in MFD probing to a new sun4i_gpadc_probe_mfd
> function.
> 
> Signed-off-by: Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
Looks sane to me - though a hint on why in the explanation wouldn't go
amiss!

We'll have to figure out the path for this series at somepoint.
In meantime

Acked-by: Jonathan Cameron <jic23-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
> ---
> 
> added in v2
> 
>  drivers/iio/adc/sun4i-gpadc-iio.c | 78 ++++++++++++++++++++++-----------------
>  1 file changed, 45 insertions(+), 33 deletions(-)
> 
> diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c
> index a8e134f..7cb997a 100644
> --- a/drivers/iio/adc/sun4i-gpadc-iio.c
> +++ b/drivers/iio/adc/sun4i-gpadc-iio.c
> @@ -454,31 +454,16 @@ static int sun4i_irq_init(struct platform_device *pdev, const char *name,
>  	return 0;
>  }
>  
> -static int sun4i_gpadc_probe(struct platform_device *pdev)
> +static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
> +				 struct iio_dev *indio_dev)
>  {
> -	struct sun4i_gpadc_iio *info;
> -	struct iio_dev *indio_dev;
> +	struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
> +	struct sun4i_gpadc_dev *sun4i_gpadc_dev =
> +		dev_get_drvdata(pdev->dev.parent);
>  	int ret;
> -	struct sun4i_gpadc_dev *sun4i_gpadc_dev;
> -
> -	sun4i_gpadc_dev = dev_get_drvdata(pdev->dev.parent);
> -
> -	indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*info));
> -	if (!indio_dev)
> -		return -ENOMEM;
>  
> -	info = iio_priv(indio_dev);
> -	platform_set_drvdata(pdev, indio_dev);
> -
> -	mutex_init(&info->mutex);
>  	info->regmap = sun4i_gpadc_dev->regmap;
> -	info->indio_dev = indio_dev;
> -	init_completion(&info->completion);
> -	indio_dev->name = dev_name(&pdev->dev);
> -	indio_dev->dev.parent = &pdev->dev;
> -	indio_dev->dev.of_node = pdev->dev.of_node;
> -	indio_dev->info = &sun4i_gpadc_iio_info;
> -	indio_dev->modes = INDIO_DIRECT_MODE;
> +
>  	indio_dev->num_channels = ARRAY_SIZE(sun4i_gpadc_channels);
>  	indio_dev->channels = sun4i_gpadc_channels;
>  
> @@ -519,8 +504,7 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>  			dev_err(&pdev->dev,
>  				"could not register thermal sensor: %ld\n",
>  				PTR_ERR(tzd));
> -			ret = PTR_ERR(tzd);
> -			goto err;
> +			return PTR_ERR(tzd);
>  		}
>  	} else {
>  		indio_dev->num_channels =
> @@ -528,36 +512,65 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>  		indio_dev->channels = sun4i_gpadc_channels_no_temp;
>  	}
>  
> -	pm_runtime_set_autosuspend_delay(&pdev->dev,
> -					 SUN4I_GPADC_AUTOSUSPEND_DELAY);
> -	pm_runtime_use_autosuspend(&pdev->dev);
> -	pm_runtime_set_suspended(&pdev->dev);
> -	pm_runtime_enable(&pdev->dev);
> -
>  	if (IS_ENABLED(CONFIG_THERMAL_OF)) {
>  		ret = sun4i_irq_init(pdev, "TEMP_DATA_PENDING",
>  				     sun4i_gpadc_temp_data_irq_handler,
>  				     "temp_data", &info->temp_data_irq,
>  				     &info->ignore_temp_data_irq);
>  		if (ret < 0)
> -			goto err;
> +			return ret;
>  	}
>  
>  	ret = sun4i_irq_init(pdev, "FIFO_DATA_PENDING",
>  			     sun4i_gpadc_fifo_data_irq_handler, "fifo_data",
>  			     &info->fifo_data_irq, &info->ignore_fifo_data_irq);
>  	if (ret < 0)
> -		goto err;
> +		return ret;
>  
>  	if (IS_ENABLED(CONFIG_THERMAL_OF)) {
>  		ret = iio_map_array_register(indio_dev, sun4i_gpadc_hwmon_maps);
>  		if (ret < 0) {
>  			dev_err(&pdev->dev,
>  				"failed to register iio map array\n");
> -			goto err;
> +			return ret;
>  		}
>  	}
>  
> +	return 0;
> +}
> +
> +static int sun4i_gpadc_probe(struct platform_device *pdev)
> +{
> +	struct sun4i_gpadc_iio *info;
> +	struct iio_dev *indio_dev;
> +	int ret;
> +
> +	indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*info));
> +	if (!indio_dev)
> +		return -ENOMEM;
> +
> +	info = iio_priv(indio_dev);
> +	platform_set_drvdata(pdev, indio_dev);
> +
> +	mutex_init(&info->mutex);
> +	info->indio_dev = indio_dev;
> +	init_completion(&info->completion);
> +	indio_dev->name = dev_name(&pdev->dev);
> +	indio_dev->dev.parent = &pdev->dev;
> +	indio_dev->dev.of_node = pdev->dev.of_node;
> +	indio_dev->info = &sun4i_gpadc_iio_info;
> +	indio_dev->modes = INDIO_DIRECT_MODE;
> +
> +	ret = sun4i_gpadc_probe_mfd(pdev, indio_dev);
> +	if (ret)
> +		return ret;
> +
> +	pm_runtime_set_autosuspend_delay(&pdev->dev,
> +					 SUN4I_GPADC_AUTOSUSPEND_DELAY);
> +	pm_runtime_use_autosuspend(&pdev->dev);
> +	pm_runtime_set_suspended(&pdev->dev);
> +	pm_runtime_enable(&pdev->dev);
> +
>  	ret = devm_iio_device_register(&pdev->dev, indio_dev);
>  	if (ret < 0) {
>  		dev_err(&pdev->dev, "could not register the device\n");
> @@ -570,7 +583,6 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>  	if (IS_ENABLED(CONFIG_THERMAL_OF))
>  		iio_map_array_unregister(indio_dev);
>  
> -err:
>  	pm_runtime_put(&pdev->dev);
>  	pm_runtime_disable(&pdev->dev);
>  
> 

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 85+ messages in thread

* [PATCH v2 07/11] iio: adc: sun4i-gpadc-iio: move code used in MFD probing to new function
@ 2017-03-13 20:58     ` Jonathan Cameron
  0 siblings, 0 replies; 85+ messages in thread
From: Jonathan Cameron @ 2017-03-13 20:58 UTC (permalink / raw)
  To: linux-arm-kernel

On 10/03/17 10:39, Quentin Schulz wrote:
> This moves code used in MFD probing to a new sun4i_gpadc_probe_mfd
> function.
> 
> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
Looks sane to me - though a hint on why in the explanation wouldn't go
amiss!

We'll have to figure out the path for this series at somepoint.
In meantime

Acked-by: Jonathan Cameron <jic23@kernel.org>
> ---
> 
> added in v2
> 
>  drivers/iio/adc/sun4i-gpadc-iio.c | 78 ++++++++++++++++++++++-----------------
>  1 file changed, 45 insertions(+), 33 deletions(-)
> 
> diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c
> index a8e134f..7cb997a 100644
> --- a/drivers/iio/adc/sun4i-gpadc-iio.c
> +++ b/drivers/iio/adc/sun4i-gpadc-iio.c
> @@ -454,31 +454,16 @@ static int sun4i_irq_init(struct platform_device *pdev, const char *name,
>  	return 0;
>  }
>  
> -static int sun4i_gpadc_probe(struct platform_device *pdev)
> +static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
> +				 struct iio_dev *indio_dev)
>  {
> -	struct sun4i_gpadc_iio *info;
> -	struct iio_dev *indio_dev;
> +	struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
> +	struct sun4i_gpadc_dev *sun4i_gpadc_dev =
> +		dev_get_drvdata(pdev->dev.parent);
>  	int ret;
> -	struct sun4i_gpadc_dev *sun4i_gpadc_dev;
> -
> -	sun4i_gpadc_dev = dev_get_drvdata(pdev->dev.parent);
> -
> -	indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*info));
> -	if (!indio_dev)
> -		return -ENOMEM;
>  
> -	info = iio_priv(indio_dev);
> -	platform_set_drvdata(pdev, indio_dev);
> -
> -	mutex_init(&info->mutex);
>  	info->regmap = sun4i_gpadc_dev->regmap;
> -	info->indio_dev = indio_dev;
> -	init_completion(&info->completion);
> -	indio_dev->name = dev_name(&pdev->dev);
> -	indio_dev->dev.parent = &pdev->dev;
> -	indio_dev->dev.of_node = pdev->dev.of_node;
> -	indio_dev->info = &sun4i_gpadc_iio_info;
> -	indio_dev->modes = INDIO_DIRECT_MODE;
> +
>  	indio_dev->num_channels = ARRAY_SIZE(sun4i_gpadc_channels);
>  	indio_dev->channels = sun4i_gpadc_channels;
>  
> @@ -519,8 +504,7 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>  			dev_err(&pdev->dev,
>  				"could not register thermal sensor: %ld\n",
>  				PTR_ERR(tzd));
> -			ret = PTR_ERR(tzd);
> -			goto err;
> +			return PTR_ERR(tzd);
>  		}
>  	} else {
>  		indio_dev->num_channels =
> @@ -528,36 +512,65 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>  		indio_dev->channels = sun4i_gpadc_channels_no_temp;
>  	}
>  
> -	pm_runtime_set_autosuspend_delay(&pdev->dev,
> -					 SUN4I_GPADC_AUTOSUSPEND_DELAY);
> -	pm_runtime_use_autosuspend(&pdev->dev);
> -	pm_runtime_set_suspended(&pdev->dev);
> -	pm_runtime_enable(&pdev->dev);
> -
>  	if (IS_ENABLED(CONFIG_THERMAL_OF)) {
>  		ret = sun4i_irq_init(pdev, "TEMP_DATA_PENDING",
>  				     sun4i_gpadc_temp_data_irq_handler,
>  				     "temp_data", &info->temp_data_irq,
>  				     &info->ignore_temp_data_irq);
>  		if (ret < 0)
> -			goto err;
> +			return ret;
>  	}
>  
>  	ret = sun4i_irq_init(pdev, "FIFO_DATA_PENDING",
>  			     sun4i_gpadc_fifo_data_irq_handler, "fifo_data",
>  			     &info->fifo_data_irq, &info->ignore_fifo_data_irq);
>  	if (ret < 0)
> -		goto err;
> +		return ret;
>  
>  	if (IS_ENABLED(CONFIG_THERMAL_OF)) {
>  		ret = iio_map_array_register(indio_dev, sun4i_gpadc_hwmon_maps);
>  		if (ret < 0) {
>  			dev_err(&pdev->dev,
>  				"failed to register iio map array\n");
> -			goto err;
> +			return ret;
>  		}
>  	}
>  
> +	return 0;
> +}
> +
> +static int sun4i_gpadc_probe(struct platform_device *pdev)
> +{
> +	struct sun4i_gpadc_iio *info;
> +	struct iio_dev *indio_dev;
> +	int ret;
> +
> +	indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*info));
> +	if (!indio_dev)
> +		return -ENOMEM;
> +
> +	info = iio_priv(indio_dev);
> +	platform_set_drvdata(pdev, indio_dev);
> +
> +	mutex_init(&info->mutex);
> +	info->indio_dev = indio_dev;
> +	init_completion(&info->completion);
> +	indio_dev->name = dev_name(&pdev->dev);
> +	indio_dev->dev.parent = &pdev->dev;
> +	indio_dev->dev.of_node = pdev->dev.of_node;
> +	indio_dev->info = &sun4i_gpadc_iio_info;
> +	indio_dev->modes = INDIO_DIRECT_MODE;
> +
> +	ret = sun4i_gpadc_probe_mfd(pdev, indio_dev);
> +	if (ret)
> +		return ret;
> +
> +	pm_runtime_set_autosuspend_delay(&pdev->dev,
> +					 SUN4I_GPADC_AUTOSUSPEND_DELAY);
> +	pm_runtime_use_autosuspend(&pdev->dev);
> +	pm_runtime_set_suspended(&pdev->dev);
> +	pm_runtime_enable(&pdev->dev);
> +
>  	ret = devm_iio_device_register(&pdev->dev, indio_dev);
>  	if (ret < 0) {
>  		dev_err(&pdev->dev, "could not register the device\n");
> @@ -570,7 +583,6 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>  	if (IS_ENABLED(CONFIG_THERMAL_OF))
>  		iio_map_array_unregister(indio_dev);
>  
> -err:
>  	pm_runtime_put(&pdev->dev);
>  	pm_runtime_disable(&pdev->dev);
>  
> 

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH v2 08/11] iio: adc: sun4i-gpadc-iio: add support for A33 thermal sensor
@ 2017-03-13 21:06     ` Jonathan Cameron
  0 siblings, 0 replies; 85+ messages in thread
From: Jonathan Cameron @ 2017-03-13 21:06 UTC (permalink / raw)
  To: Quentin Schulz, dmitry.torokhov, robh+dt, mark.rutland,
	maxime.ripard, wens, lee.jones, linux, knaack.h, lars, pmeerw,
	stefan.mavrodiev
  Cc: devicetree, linux-arm-kernel, linux-kernel, linux-iio,
	linux-sunxi, thomas.petazzoni

On 10/03/17 10:39, Quentin Schulz wrote:
> This adds support for the Allwinner A33 thermal sensor.
> 
> Unlike the A10, A13 and A31, the Allwinner A33 only has one channel
> which is dedicated to the thermal sensor. Moreover, its thermal sensor
> does not generate interruptions, thus we only need to directly read the
> register storing the temperature value.
> 
> The MFD used by the A10, A13 and A31, was created to avoid breaking the
> DT binding, but since the nodes for the ADC weren't there for the A33,
> it is not needed.
> 
> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>

Talk me through why it makes sense to do this rather than simply spin out
a really simple thermal driver for the A33?

I'm not against what you have here, but don't feel it has been fully argued.

Jonathan
> ---
> 
> v2:
>   - removed added comments in Kconfig,
>   - simplified Kconfig depends on condition,
>   - removed THERMAL_OF requirement for sun8i,
>   - renamed sun8i_gpadc_channels to sun8i_a33_gpadc_channels,
>   - renamed use_dt boolean in no_irq as it reflects better why we need it,
>   - removed spurious/unneeded modifications done in v1,
> 
>  drivers/iio/adc/Kconfig           |   2 +-
>  drivers/iio/adc/sun4i-gpadc-iio.c | 100 ++++++++++++++++++++++++++++++++++++--
>  include/linux/mfd/sun4i-gpadc.h   |   4 ++
>  3 files changed, 102 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
> index 9f8b4b1..8c8ead6 100644
> --- a/drivers/iio/adc/Kconfig
> +++ b/drivers/iio/adc/Kconfig
> @@ -562,7 +562,7 @@ config STX104
>  config SUN4I_GPADC
>  	tristate "Support for the Allwinner SoCs GPADC"
>  	depends on IIO
> -	depends on MFD_SUN4I_GPADC
> +	depends on MFD_SUN4I_GPADC || MACH_SUN8I
>  	help
>  	  Say yes here to build support for Allwinner (A10, A13 and A31) SoCs
>  	  GPADC. This ADC provides 4 channels which can be used as an ADC or as
> diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c
> index 7cb997a..70684cd 100644
> --- a/drivers/iio/adc/sun4i-gpadc-iio.c
> +++ b/drivers/iio/adc/sun4i-gpadc-iio.c
> @@ -85,6 +85,12 @@ static const struct gpadc_data sun6i_gpadc_data = {
>  	.adc_chan_mask = SUN6I_GPADC_CTRL1_ADC_CHAN_MASK,
>  };
>  
> +static const struct gpadc_data sun8i_a33_gpadc_data = {
> +	.temp_offset = -1662,
> +	.temp_scale = 162,
> +	.tp_mode_en = SUN8I_GPADC_CTRL1_CHOP_TEMP_EN,
> +};
> +
>  struct sun4i_gpadc_iio {
>  	struct iio_dev			*indio_dev;
>  	struct completion		completion;
> @@ -96,6 +102,7 @@ struct sun4i_gpadc_iio {
>  	unsigned int			temp_data_irq;
>  	atomic_t			ignore_temp_data_irq;
>  	const struct gpadc_data		*data;
> +	bool				no_irq;
>  	/* prevents concurrent reads of temperature and ADC */
>  	struct mutex			mutex;
>  };
> @@ -138,6 +145,23 @@ static const struct iio_chan_spec sun4i_gpadc_channels_no_temp[] = {
>  	SUN4I_GPADC_ADC_CHANNEL(3, "adc_chan3"),
>  };
>  
> +static const struct iio_chan_spec sun8i_a33_gpadc_channels[] = {
> +	{
> +		.type = IIO_TEMP,
> +		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
> +				      BIT(IIO_CHAN_INFO_SCALE) |
> +				      BIT(IIO_CHAN_INFO_OFFSET),
> +		.datasheet_name = "temp_adc",
> +	},
> +};
> +
> +static const struct regmap_config sun4i_gpadc_regmap_config = {
> +	.reg_bits = 32,
> +	.val_bits = 32,
> +	.reg_stride = 4,
> +	.fast_io = true,
> +};
> +
>  static int sun4i_prepare_for_irq(struct iio_dev *indio_dev, int channel,
>  				 unsigned int irq)
>  {
> @@ -247,6 +271,17 @@ static int sun4i_gpadc_temp_read(struct iio_dev *indio_dev, int *val)
>  {
>  	struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
>  
> +	if (info->no_irq) {
> +		pm_runtime_get_sync(indio_dev->dev.parent);
> +
> +		regmap_read(info->regmap, SUN4I_GPADC_TEMP_DATA, val);
> +
> +		pm_runtime_mark_last_busy(indio_dev->dev.parent);
> +		pm_runtime_put_autosuspend(indio_dev->dev.parent);
> +
> +		return 0;
> +	}
> +
>  	return sun4i_gpadc_read(indio_dev, 0, val, info->temp_data_irq);
>  }
>  
> @@ -454,6 +489,58 @@ static int sun4i_irq_init(struct platform_device *pdev, const char *name,
>  	return 0;
>  }
>  
> +static const struct of_device_id sun4i_gpadc_of_id[] = {
> +	{
> +		.compatible = "allwinner,sun8i-a33-gpadc-iio",
> +		.data = &sun8i_a33_gpadc_data,
> +	},
> +	{ /* sentinel */ }
> +};
> +
> +static int sun4i_gpadc_probe_dt(struct platform_device *pdev,
> +				struct iio_dev *indio_dev)
> +{
> +	struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
> +	const struct of_device_id *of_dev;
> +	struct thermal_zone_device *tzd;
> +	struct resource *mem;
> +	void __iomem *base;
> +	int ret;
> +
> +	of_dev = of_match_device(sun4i_gpadc_of_id, &pdev->dev);
> +	if (!of_dev)
> +		return -ENODEV;
> +
> +	info->no_irq = true;
> +	info->data = (struct gpadc_data *)of_dev->data;
> +	indio_dev->num_channels = ARRAY_SIZE(sun8i_a33_gpadc_channels);
> +	indio_dev->channels = sun8i_a33_gpadc_channels;
> +
> +	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	base = devm_ioremap_resource(&pdev->dev, mem);
> +	if (IS_ERR(base))
> +		return PTR_ERR(base);
> +
> +	info->regmap = devm_regmap_init_mmio(&pdev->dev, base,
> +					     &sun4i_gpadc_regmap_config);
> +	if (IS_ERR(info->regmap)) {
> +		ret = PTR_ERR(info->regmap);
> +		dev_err(&pdev->dev, "failed to init regmap: %d\n", ret);
> +		return ret;
> +	}
> +
> +	if (!IS_ENABLED(THERMAL_OF))
> +		return 0;
> +
> +	tzd = devm_thermal_zone_of_sensor_register(&pdev->dev, 0, info,
> +						   &sun4i_ts_tz_ops);
> +	if (IS_ERR(tzd))
> +		dev_err(&pdev->dev, "could not register thermal sensor: %ld\n",
> +			PTR_ERR(tzd));
> +
> +	return PTR_ERR_OR_ZERO(tzd);
> +}
> +
>  static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
>  				 struct iio_dev *indio_dev)
>  {
> @@ -462,6 +549,7 @@ static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
>  		dev_get_drvdata(pdev->dev.parent);
>  	int ret;
>  
> +	info->no_irq = false;
>  	info->regmap = sun4i_gpadc_dev->regmap;
>  
>  	indio_dev->num_channels = ARRAY_SIZE(sun4i_gpadc_channels);
> @@ -561,7 +649,11 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>  	indio_dev->info = &sun4i_gpadc_iio_info;
>  	indio_dev->modes = INDIO_DIRECT_MODE;
>  
> -	ret = sun4i_gpadc_probe_mfd(pdev, indio_dev);
> +	if (pdev->dev.of_node)
> +		ret = sun4i_gpadc_probe_dt(pdev, indio_dev);
> +	else
> +		ret = sun4i_gpadc_probe_mfd(pdev, indio_dev);
> +
>  	if (ret)
>  		return ret;
>  
> @@ -580,7 +672,7 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>  	return 0;
>  
>  err_map:
> -	if (IS_ENABLED(CONFIG_THERMAL_OF))
> +	if (!info->no_irq && IS_ENABLED(CONFIG_THERMAL_OF))
>  		iio_map_array_unregister(indio_dev);
>  
>  	pm_runtime_put(&pdev->dev);
> @@ -592,10 +684,11 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>  static int sun4i_gpadc_remove(struct platform_device *pdev)
>  {
>  	struct iio_dev *indio_dev = platform_get_drvdata(pdev);
> +	struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
>  
>  	pm_runtime_put(&pdev->dev);
>  	pm_runtime_disable(&pdev->dev);
> -	if (IS_ENABLED(CONFIG_THERMAL_OF))
> +	if (!info->no_irq && IS_ENABLED(CONFIG_THERMAL_OF))
>  		iio_map_array_unregister(indio_dev);
>  
>  	return 0;
> @@ -611,6 +704,7 @@ static const struct platform_device_id sun4i_gpadc_id[] = {
>  static struct platform_driver sun4i_gpadc_driver = {
>  	.driver = {
>  		.name = "sun4i-gpadc-iio",
> +		.of_match_table = sun4i_gpadc_of_id,
>  		.pm = &sun4i_gpadc_pm_ops,
>  	},
>  	.id_table = sun4i_gpadc_id,
> diff --git a/include/linux/mfd/sun4i-gpadc.h b/include/linux/mfd/sun4i-gpadc.h
> index 509e736..139872c 100644
> --- a/include/linux/mfd/sun4i-gpadc.h
> +++ b/include/linux/mfd/sun4i-gpadc.h
> @@ -38,6 +38,10 @@
>  #define SUN6I_GPADC_CTRL1_ADC_CHAN_SELECT(x)		(GENMASK(3, 0) & BIT(x))
>  #define SUN6I_GPADC_CTRL1_ADC_CHAN_MASK			GENMASK(3, 0)
>  
> +/* TP_CTRL1 bits for sun8i SoCs */
> +#define SUN8I_GPADC_CTRL1_CHOP_TEMP_EN			BIT(8)
> +#define SUN8I_GPADC_CTRL1_GPADC_CALI_EN			BIT(7)
> +
>  #define SUN4I_GPADC_CTRL2				0x08
>  
>  #define SUN4I_GPADC_CTRL2_TP_SENSITIVE_ADJUST(x)	((GENMASK(3, 0) & (x)) << 28)
> 

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH v2 08/11] iio: adc: sun4i-gpadc-iio: add support for A33 thermal sensor
@ 2017-03-13 21:06     ` Jonathan Cameron
  0 siblings, 0 replies; 85+ messages in thread
From: Jonathan Cameron @ 2017-03-13 21:06 UTC (permalink / raw)
  To: Quentin Schulz, dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8, wens-jdAy2FN1RRM,
	lee.jones-QSEj5FYQhm4dnm+yROfE0A, linux-I+IVW8TIWO2tmTQ+vhA3Yw,
	knaack.h-Mmb7MZpHnFY, lars-Qo5EllUWu/uELgA04lAiVw,
	pmeerw-jW+XmwGofnusTnJN9+BGXg,
	stefan.mavrodiev-Re5JQEeQqe8AvxtiuMwx3w
  Cc: devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-iio-u79uwXL29TY76Z2rM5mHXA,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
	thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8

On 10/03/17 10:39, Quentin Schulz wrote:
> This adds support for the Allwinner A33 thermal sensor.
> 
> Unlike the A10, A13 and A31, the Allwinner A33 only has one channel
> which is dedicated to the thermal sensor. Moreover, its thermal sensor
> does not generate interruptions, thus we only need to directly read the
> register storing the temperature value.
> 
> The MFD used by the A10, A13 and A31, was created to avoid breaking the
> DT binding, but since the nodes for the ADC weren't there for the A33,
> it is not needed.
> 
> Signed-off-by: Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>

Talk me through why it makes sense to do this rather than simply spin out
a really simple thermal driver for the A33?

I'm not against what you have here, but don't feel it has been fully argued.

Jonathan
> ---
> 
> v2:
>   - removed added comments in Kconfig,
>   - simplified Kconfig depends on condition,
>   - removed THERMAL_OF requirement for sun8i,
>   - renamed sun8i_gpadc_channels to sun8i_a33_gpadc_channels,
>   - renamed use_dt boolean in no_irq as it reflects better why we need it,
>   - removed spurious/unneeded modifications done in v1,
> 
>  drivers/iio/adc/Kconfig           |   2 +-
>  drivers/iio/adc/sun4i-gpadc-iio.c | 100 ++++++++++++++++++++++++++++++++++++--
>  include/linux/mfd/sun4i-gpadc.h   |   4 ++
>  3 files changed, 102 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
> index 9f8b4b1..8c8ead6 100644
> --- a/drivers/iio/adc/Kconfig
> +++ b/drivers/iio/adc/Kconfig
> @@ -562,7 +562,7 @@ config STX104
>  config SUN4I_GPADC
>  	tristate "Support for the Allwinner SoCs GPADC"
>  	depends on IIO
> -	depends on MFD_SUN4I_GPADC
> +	depends on MFD_SUN4I_GPADC || MACH_SUN8I
>  	help
>  	  Say yes here to build support for Allwinner (A10, A13 and A31) SoCs
>  	  GPADC. This ADC provides 4 channels which can be used as an ADC or as
> diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c
> index 7cb997a..70684cd 100644
> --- a/drivers/iio/adc/sun4i-gpadc-iio.c
> +++ b/drivers/iio/adc/sun4i-gpadc-iio.c
> @@ -85,6 +85,12 @@ static const struct gpadc_data sun6i_gpadc_data = {
>  	.adc_chan_mask = SUN6I_GPADC_CTRL1_ADC_CHAN_MASK,
>  };
>  
> +static const struct gpadc_data sun8i_a33_gpadc_data = {
> +	.temp_offset = -1662,
> +	.temp_scale = 162,
> +	.tp_mode_en = SUN8I_GPADC_CTRL1_CHOP_TEMP_EN,
> +};
> +
>  struct sun4i_gpadc_iio {
>  	struct iio_dev			*indio_dev;
>  	struct completion		completion;
> @@ -96,6 +102,7 @@ struct sun4i_gpadc_iio {
>  	unsigned int			temp_data_irq;
>  	atomic_t			ignore_temp_data_irq;
>  	const struct gpadc_data		*data;
> +	bool				no_irq;
>  	/* prevents concurrent reads of temperature and ADC */
>  	struct mutex			mutex;
>  };
> @@ -138,6 +145,23 @@ static const struct iio_chan_spec sun4i_gpadc_channels_no_temp[] = {
>  	SUN4I_GPADC_ADC_CHANNEL(3, "adc_chan3"),
>  };
>  
> +static const struct iio_chan_spec sun8i_a33_gpadc_channels[] = {
> +	{
> +		.type = IIO_TEMP,
> +		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
> +				      BIT(IIO_CHAN_INFO_SCALE) |
> +				      BIT(IIO_CHAN_INFO_OFFSET),
> +		.datasheet_name = "temp_adc",
> +	},
> +};
> +
> +static const struct regmap_config sun4i_gpadc_regmap_config = {
> +	.reg_bits = 32,
> +	.val_bits = 32,
> +	.reg_stride = 4,
> +	.fast_io = true,
> +};
> +
>  static int sun4i_prepare_for_irq(struct iio_dev *indio_dev, int channel,
>  				 unsigned int irq)
>  {
> @@ -247,6 +271,17 @@ static int sun4i_gpadc_temp_read(struct iio_dev *indio_dev, int *val)
>  {
>  	struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
>  
> +	if (info->no_irq) {
> +		pm_runtime_get_sync(indio_dev->dev.parent);
> +
> +		regmap_read(info->regmap, SUN4I_GPADC_TEMP_DATA, val);
> +
> +		pm_runtime_mark_last_busy(indio_dev->dev.parent);
> +		pm_runtime_put_autosuspend(indio_dev->dev.parent);
> +
> +		return 0;
> +	}
> +
>  	return sun4i_gpadc_read(indio_dev, 0, val, info->temp_data_irq);
>  }
>  
> @@ -454,6 +489,58 @@ static int sun4i_irq_init(struct platform_device *pdev, const char *name,
>  	return 0;
>  }
>  
> +static const struct of_device_id sun4i_gpadc_of_id[] = {
> +	{
> +		.compatible = "allwinner,sun8i-a33-gpadc-iio",
> +		.data = &sun8i_a33_gpadc_data,
> +	},
> +	{ /* sentinel */ }
> +};
> +
> +static int sun4i_gpadc_probe_dt(struct platform_device *pdev,
> +				struct iio_dev *indio_dev)
> +{
> +	struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
> +	const struct of_device_id *of_dev;
> +	struct thermal_zone_device *tzd;
> +	struct resource *mem;
> +	void __iomem *base;
> +	int ret;
> +
> +	of_dev = of_match_device(sun4i_gpadc_of_id, &pdev->dev);
> +	if (!of_dev)
> +		return -ENODEV;
> +
> +	info->no_irq = true;
> +	info->data = (struct gpadc_data *)of_dev->data;
> +	indio_dev->num_channels = ARRAY_SIZE(sun8i_a33_gpadc_channels);
> +	indio_dev->channels = sun8i_a33_gpadc_channels;
> +
> +	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	base = devm_ioremap_resource(&pdev->dev, mem);
> +	if (IS_ERR(base))
> +		return PTR_ERR(base);
> +
> +	info->regmap = devm_regmap_init_mmio(&pdev->dev, base,
> +					     &sun4i_gpadc_regmap_config);
> +	if (IS_ERR(info->regmap)) {
> +		ret = PTR_ERR(info->regmap);
> +		dev_err(&pdev->dev, "failed to init regmap: %d\n", ret);
> +		return ret;
> +	}
> +
> +	if (!IS_ENABLED(THERMAL_OF))
> +		return 0;
> +
> +	tzd = devm_thermal_zone_of_sensor_register(&pdev->dev, 0, info,
> +						   &sun4i_ts_tz_ops);
> +	if (IS_ERR(tzd))
> +		dev_err(&pdev->dev, "could not register thermal sensor: %ld\n",
> +			PTR_ERR(tzd));
> +
> +	return PTR_ERR_OR_ZERO(tzd);
> +}
> +
>  static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
>  				 struct iio_dev *indio_dev)
>  {
> @@ -462,6 +549,7 @@ static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
>  		dev_get_drvdata(pdev->dev.parent);
>  	int ret;
>  
> +	info->no_irq = false;
>  	info->regmap = sun4i_gpadc_dev->regmap;
>  
>  	indio_dev->num_channels = ARRAY_SIZE(sun4i_gpadc_channels);
> @@ -561,7 +649,11 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>  	indio_dev->info = &sun4i_gpadc_iio_info;
>  	indio_dev->modes = INDIO_DIRECT_MODE;
>  
> -	ret = sun4i_gpadc_probe_mfd(pdev, indio_dev);
> +	if (pdev->dev.of_node)
> +		ret = sun4i_gpadc_probe_dt(pdev, indio_dev);
> +	else
> +		ret = sun4i_gpadc_probe_mfd(pdev, indio_dev);
> +
>  	if (ret)
>  		return ret;
>  
> @@ -580,7 +672,7 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>  	return 0;
>  
>  err_map:
> -	if (IS_ENABLED(CONFIG_THERMAL_OF))
> +	if (!info->no_irq && IS_ENABLED(CONFIG_THERMAL_OF))
>  		iio_map_array_unregister(indio_dev);
>  
>  	pm_runtime_put(&pdev->dev);
> @@ -592,10 +684,11 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>  static int sun4i_gpadc_remove(struct platform_device *pdev)
>  {
>  	struct iio_dev *indio_dev = platform_get_drvdata(pdev);
> +	struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
>  
>  	pm_runtime_put(&pdev->dev);
>  	pm_runtime_disable(&pdev->dev);
> -	if (IS_ENABLED(CONFIG_THERMAL_OF))
> +	if (!info->no_irq && IS_ENABLED(CONFIG_THERMAL_OF))
>  		iio_map_array_unregister(indio_dev);
>  
>  	return 0;
> @@ -611,6 +704,7 @@ static const struct platform_device_id sun4i_gpadc_id[] = {
>  static struct platform_driver sun4i_gpadc_driver = {
>  	.driver = {
>  		.name = "sun4i-gpadc-iio",
> +		.of_match_table = sun4i_gpadc_of_id,
>  		.pm = &sun4i_gpadc_pm_ops,
>  	},
>  	.id_table = sun4i_gpadc_id,
> diff --git a/include/linux/mfd/sun4i-gpadc.h b/include/linux/mfd/sun4i-gpadc.h
> index 509e736..139872c 100644
> --- a/include/linux/mfd/sun4i-gpadc.h
> +++ b/include/linux/mfd/sun4i-gpadc.h
> @@ -38,6 +38,10 @@
>  #define SUN6I_GPADC_CTRL1_ADC_CHAN_SELECT(x)		(GENMASK(3, 0) & BIT(x))
>  #define SUN6I_GPADC_CTRL1_ADC_CHAN_MASK			GENMASK(3, 0)
>  
> +/* TP_CTRL1 bits for sun8i SoCs */
> +#define SUN8I_GPADC_CTRL1_CHOP_TEMP_EN			BIT(8)
> +#define SUN8I_GPADC_CTRL1_GPADC_CALI_EN			BIT(7)
> +
>  #define SUN4I_GPADC_CTRL2				0x08
>  
>  #define SUN4I_GPADC_CTRL2_TP_SENSITIVE_ADJUST(x)	((GENMASK(3, 0) & (x)) << 28)
> 

^ permalink raw reply	[flat|nested] 85+ messages in thread

* [PATCH v2 08/11] iio: adc: sun4i-gpadc-iio: add support for A33 thermal sensor
@ 2017-03-13 21:06     ` Jonathan Cameron
  0 siblings, 0 replies; 85+ messages in thread
From: Jonathan Cameron @ 2017-03-13 21:06 UTC (permalink / raw)
  To: linux-arm-kernel

On 10/03/17 10:39, Quentin Schulz wrote:
> This adds support for the Allwinner A33 thermal sensor.
> 
> Unlike the A10, A13 and A31, the Allwinner A33 only has one channel
> which is dedicated to the thermal sensor. Moreover, its thermal sensor
> does not generate interruptions, thus we only need to directly read the
> register storing the temperature value.
> 
> The MFD used by the A10, A13 and A31, was created to avoid breaking the
> DT binding, but since the nodes for the ADC weren't there for the A33,
> it is not needed.
> 
> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>

Talk me through why it makes sense to do this rather than simply spin out
a really simple thermal driver for the A33?

I'm not against what you have here, but don't feel it has been fully argued.

Jonathan
> ---
> 
> v2:
>   - removed added comments in Kconfig,
>   - simplified Kconfig depends on condition,
>   - removed THERMAL_OF requirement for sun8i,
>   - renamed sun8i_gpadc_channels to sun8i_a33_gpadc_channels,
>   - renamed use_dt boolean in no_irq as it reflects better why we need it,
>   - removed spurious/unneeded modifications done in v1,
> 
>  drivers/iio/adc/Kconfig           |   2 +-
>  drivers/iio/adc/sun4i-gpadc-iio.c | 100 ++++++++++++++++++++++++++++++++++++--
>  include/linux/mfd/sun4i-gpadc.h   |   4 ++
>  3 files changed, 102 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
> index 9f8b4b1..8c8ead6 100644
> --- a/drivers/iio/adc/Kconfig
> +++ b/drivers/iio/adc/Kconfig
> @@ -562,7 +562,7 @@ config STX104
>  config SUN4I_GPADC
>  	tristate "Support for the Allwinner SoCs GPADC"
>  	depends on IIO
> -	depends on MFD_SUN4I_GPADC
> +	depends on MFD_SUN4I_GPADC || MACH_SUN8I
>  	help
>  	  Say yes here to build support for Allwinner (A10, A13 and A31) SoCs
>  	  GPADC. This ADC provides 4 channels which can be used as an ADC or as
> diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c
> index 7cb997a..70684cd 100644
> --- a/drivers/iio/adc/sun4i-gpadc-iio.c
> +++ b/drivers/iio/adc/sun4i-gpadc-iio.c
> @@ -85,6 +85,12 @@ static const struct gpadc_data sun6i_gpadc_data = {
>  	.adc_chan_mask = SUN6I_GPADC_CTRL1_ADC_CHAN_MASK,
>  };
>  
> +static const struct gpadc_data sun8i_a33_gpadc_data = {
> +	.temp_offset = -1662,
> +	.temp_scale = 162,
> +	.tp_mode_en = SUN8I_GPADC_CTRL1_CHOP_TEMP_EN,
> +};
> +
>  struct sun4i_gpadc_iio {
>  	struct iio_dev			*indio_dev;
>  	struct completion		completion;
> @@ -96,6 +102,7 @@ struct sun4i_gpadc_iio {
>  	unsigned int			temp_data_irq;
>  	atomic_t			ignore_temp_data_irq;
>  	const struct gpadc_data		*data;
> +	bool				no_irq;
>  	/* prevents concurrent reads of temperature and ADC */
>  	struct mutex			mutex;
>  };
> @@ -138,6 +145,23 @@ static const struct iio_chan_spec sun4i_gpadc_channels_no_temp[] = {
>  	SUN4I_GPADC_ADC_CHANNEL(3, "adc_chan3"),
>  };
>  
> +static const struct iio_chan_spec sun8i_a33_gpadc_channels[] = {
> +	{
> +		.type = IIO_TEMP,
> +		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
> +				      BIT(IIO_CHAN_INFO_SCALE) |
> +				      BIT(IIO_CHAN_INFO_OFFSET),
> +		.datasheet_name = "temp_adc",
> +	},
> +};
> +
> +static const struct regmap_config sun4i_gpadc_regmap_config = {
> +	.reg_bits = 32,
> +	.val_bits = 32,
> +	.reg_stride = 4,
> +	.fast_io = true,
> +};
> +
>  static int sun4i_prepare_for_irq(struct iio_dev *indio_dev, int channel,
>  				 unsigned int irq)
>  {
> @@ -247,6 +271,17 @@ static int sun4i_gpadc_temp_read(struct iio_dev *indio_dev, int *val)
>  {
>  	struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
>  
> +	if (info->no_irq) {
> +		pm_runtime_get_sync(indio_dev->dev.parent);
> +
> +		regmap_read(info->regmap, SUN4I_GPADC_TEMP_DATA, val);
> +
> +		pm_runtime_mark_last_busy(indio_dev->dev.parent);
> +		pm_runtime_put_autosuspend(indio_dev->dev.parent);
> +
> +		return 0;
> +	}
> +
>  	return sun4i_gpadc_read(indio_dev, 0, val, info->temp_data_irq);
>  }
>  
> @@ -454,6 +489,58 @@ static int sun4i_irq_init(struct platform_device *pdev, const char *name,
>  	return 0;
>  }
>  
> +static const struct of_device_id sun4i_gpadc_of_id[] = {
> +	{
> +		.compatible = "allwinner,sun8i-a33-gpadc-iio",
> +		.data = &sun8i_a33_gpadc_data,
> +	},
> +	{ /* sentinel */ }
> +};
> +
> +static int sun4i_gpadc_probe_dt(struct platform_device *pdev,
> +				struct iio_dev *indio_dev)
> +{
> +	struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
> +	const struct of_device_id *of_dev;
> +	struct thermal_zone_device *tzd;
> +	struct resource *mem;
> +	void __iomem *base;
> +	int ret;
> +
> +	of_dev = of_match_device(sun4i_gpadc_of_id, &pdev->dev);
> +	if (!of_dev)
> +		return -ENODEV;
> +
> +	info->no_irq = true;
> +	info->data = (struct gpadc_data *)of_dev->data;
> +	indio_dev->num_channels = ARRAY_SIZE(sun8i_a33_gpadc_channels);
> +	indio_dev->channels = sun8i_a33_gpadc_channels;
> +
> +	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	base = devm_ioremap_resource(&pdev->dev, mem);
> +	if (IS_ERR(base))
> +		return PTR_ERR(base);
> +
> +	info->regmap = devm_regmap_init_mmio(&pdev->dev, base,
> +					     &sun4i_gpadc_regmap_config);
> +	if (IS_ERR(info->regmap)) {
> +		ret = PTR_ERR(info->regmap);
> +		dev_err(&pdev->dev, "failed to init regmap: %d\n", ret);
> +		return ret;
> +	}
> +
> +	if (!IS_ENABLED(THERMAL_OF))
> +		return 0;
> +
> +	tzd = devm_thermal_zone_of_sensor_register(&pdev->dev, 0, info,
> +						   &sun4i_ts_tz_ops);
> +	if (IS_ERR(tzd))
> +		dev_err(&pdev->dev, "could not register thermal sensor: %ld\n",
> +			PTR_ERR(tzd));
> +
> +	return PTR_ERR_OR_ZERO(tzd);
> +}
> +
>  static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
>  				 struct iio_dev *indio_dev)
>  {
> @@ -462,6 +549,7 @@ static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
>  		dev_get_drvdata(pdev->dev.parent);
>  	int ret;
>  
> +	info->no_irq = false;
>  	info->regmap = sun4i_gpadc_dev->regmap;
>  
>  	indio_dev->num_channels = ARRAY_SIZE(sun4i_gpadc_channels);
> @@ -561,7 +649,11 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>  	indio_dev->info = &sun4i_gpadc_iio_info;
>  	indio_dev->modes = INDIO_DIRECT_MODE;
>  
> -	ret = sun4i_gpadc_probe_mfd(pdev, indio_dev);
> +	if (pdev->dev.of_node)
> +		ret = sun4i_gpadc_probe_dt(pdev, indio_dev);
> +	else
> +		ret = sun4i_gpadc_probe_mfd(pdev, indio_dev);
> +
>  	if (ret)
>  		return ret;
>  
> @@ -580,7 +672,7 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>  	return 0;
>  
>  err_map:
> -	if (IS_ENABLED(CONFIG_THERMAL_OF))
> +	if (!info->no_irq && IS_ENABLED(CONFIG_THERMAL_OF))
>  		iio_map_array_unregister(indio_dev);
>  
>  	pm_runtime_put(&pdev->dev);
> @@ -592,10 +684,11 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>  static int sun4i_gpadc_remove(struct platform_device *pdev)
>  {
>  	struct iio_dev *indio_dev = platform_get_drvdata(pdev);
> +	struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
>  
>  	pm_runtime_put(&pdev->dev);
>  	pm_runtime_disable(&pdev->dev);
> -	if (IS_ENABLED(CONFIG_THERMAL_OF))
> +	if (!info->no_irq && IS_ENABLED(CONFIG_THERMAL_OF))
>  		iio_map_array_unregister(indio_dev);
>  
>  	return 0;
> @@ -611,6 +704,7 @@ static const struct platform_device_id sun4i_gpadc_id[] = {
>  static struct platform_driver sun4i_gpadc_driver = {
>  	.driver = {
>  		.name = "sun4i-gpadc-iio",
> +		.of_match_table = sun4i_gpadc_of_id,
>  		.pm = &sun4i_gpadc_pm_ops,
>  	},
>  	.id_table = sun4i_gpadc_id,
> diff --git a/include/linux/mfd/sun4i-gpadc.h b/include/linux/mfd/sun4i-gpadc.h
> index 509e736..139872c 100644
> --- a/include/linux/mfd/sun4i-gpadc.h
> +++ b/include/linux/mfd/sun4i-gpadc.h
> @@ -38,6 +38,10 @@
>  #define SUN6I_GPADC_CTRL1_ADC_CHAN_SELECT(x)		(GENMASK(3, 0) & BIT(x))
>  #define SUN6I_GPADC_CTRL1_ADC_CHAN_MASK			GENMASK(3, 0)
>  
> +/* TP_CTRL1 bits for sun8i SoCs */
> +#define SUN8I_GPADC_CTRL1_CHOP_TEMP_EN			BIT(8)
> +#define SUN8I_GPADC_CTRL1_GPADC_CALI_EN			BIT(7)
> +
>  #define SUN4I_GPADC_CTRL2				0x08
>  
>  #define SUN4I_GPADC_CTRL2_TP_SENSITIVE_ADJUST(x)	((GENMASK(3, 0) & (x)) << 28)
> 

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH v2 08/11] iio: adc: sun4i-gpadc-iio: add support for A33 thermal sensor
  2017-03-13 21:06     ` Jonathan Cameron
  (?)
@ 2017-03-14  5:18         ` Icenowy Zheng
  -1 siblings, 0 replies; 85+ messages in thread
From: Icenowy Zheng @ 2017-03-14  5:18 UTC (permalink / raw)
  To: Jonathan Cameron, Quentin Schulz,
	dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8, wens-jdAy2FN1RRM,
	lee.jones-QSEj5FYQhm4dnm+yROfE0A, linux-I+IVW8TIWO2tmTQ+vhA3Yw,
	knaack.h-Mmb7MZpHnFY, lars-Qo5EllUWu/uELgA04lAiVw,
	pmeerw-jW+XmwGofnusTnJN9+BGXg,
	stefan.mavrodiev-Re5JQEeQqe8AvxtiuMwx3w
  Cc: thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-iio-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r



14.03.2017, 05:08, "Jonathan Cameron" <jic23-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>:
> On 10/03/17 10:39, Quentin Schulz wrote:
>>  This adds support for the Allwinner A33 thermal sensor.
>>
>>  Unlike the A10, A13 and A31, the Allwinner A33 only has one channel
>>  which is dedicated to the thermal sensor. Moreover, its thermal sensor
>>  does not generate interruptions, thus we only need to directly read the
>>  register storing the temperature value.
>>
>>  The MFD used by the A10, A13 and A31, was created to avoid breaking the
>>  DT binding, but since the nodes for the ADC weren't there for the A33,
>>  it is not needed.
>>
>>  Signed-off-by: Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
>
> Talk me through why it makes sense to do this rather than simply spin out
> a really simple thermal driver for the A33?

According to him the A33 thermal sensor is a simplified version of the GPADC.

I have already did a simple thermal driver ~8 months ago, but is rejected for
this reason.

>
> I'm not against what you have here, but don't feel it has been fully argued.
>
> Jonathan
>>  ---
>>
>>  v2:
>>    - removed added comments in Kconfig,
>>    - simplified Kconfig depends on condition,
>>    - removed THERMAL_OF requirement for sun8i,
>>    - renamed sun8i_gpadc_channels to sun8i_a33_gpadc_channels,
>>    - renamed use_dt boolean in no_irq as it reflects better why we need it,
>>    - removed spurious/unneeded modifications done in v1,
>>
>>   drivers/iio/adc/Kconfig | 2 +-
>>   drivers/iio/adc/sun4i-gpadc-iio.c | 100 ++++++++++++++++++++++++++++++++++++--
>>   include/linux/mfd/sun4i-gpadc.h | 4 ++
>>   3 files changed, 102 insertions(+), 4 deletions(-)
>>
>>  diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
>>  index 9f8b4b1..8c8ead6 100644
>>  --- a/drivers/iio/adc/Kconfig
>>  +++ b/drivers/iio/adc/Kconfig
>>  @@ -562,7 +562,7 @@ config STX104
>>   config SUN4I_GPADC
>>           tristate "Support for the Allwinner SoCs GPADC"
>>           depends on IIO
>>  - depends on MFD_SUN4I_GPADC
>>  + depends on MFD_SUN4I_GPADC || MACH_SUN8I
>>           help
>>             Say yes here to build support for Allwinner (A10, A13 and A31) SoCs
>>             GPADC. This ADC provides 4 channels which can be used as an ADC or as
>>  diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c
>>  index 7cb997a..70684cd 100644
>>  --- a/drivers/iio/adc/sun4i-gpadc-iio.c
>>  +++ b/drivers/iio/adc/sun4i-gpadc-iio.c
>>  @@ -85,6 +85,12 @@ static const struct gpadc_data sun6i_gpadc_data = {
>>           .adc_chan_mask = SUN6I_GPADC_CTRL1_ADC_CHAN_MASK,
>>   };
>>
>>  +static const struct gpadc_data sun8i_a33_gpadc_data = {
>>  + .temp_offset = -1662,
>>  + .temp_scale = 162,
>>  + .tp_mode_en = SUN8I_GPADC_CTRL1_CHOP_TEMP_EN,
>>  +};
>>  +
>>   struct sun4i_gpadc_iio {
>>           struct iio_dev *indio_dev;
>>           struct completion completion;
>>  @@ -96,6 +102,7 @@ struct sun4i_gpadc_iio {
>>           unsigned int temp_data_irq;
>>           atomic_t ignore_temp_data_irq;
>>           const struct gpadc_data *data;
>>  + bool no_irq;
>>           /* prevents concurrent reads of temperature and ADC */
>>           struct mutex mutex;
>>   };
>>  @@ -138,6 +145,23 @@ static const struct iio_chan_spec sun4i_gpadc_channels_no_temp[] = {
>>           SUN4I_GPADC_ADC_CHANNEL(3, "adc_chan3"),
>>   };
>>
>>  +static const struct iio_chan_spec sun8i_a33_gpadc_channels[] = {
>>  + {
>>  + .type = IIO_TEMP,
>>  + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
>>  + BIT(IIO_CHAN_INFO_SCALE) |
>>  + BIT(IIO_CHAN_INFO_OFFSET),
>>  + .datasheet_name = "temp_adc",
>>  + },
>>  +};
>>  +
>>  +static const struct regmap_config sun4i_gpadc_regmap_config = {
>>  + .reg_bits = 32,
>>  + .val_bits = 32,
>>  + .reg_stride = 4,
>>  + .fast_io = true,
>>  +};
>>  +
>>   static int sun4i_prepare_for_irq(struct iio_dev *indio_dev, int channel,
>>                                    unsigned int irq)
>>   {
>>  @@ -247,6 +271,17 @@ static int sun4i_gpadc_temp_read(struct iio_dev *indio_dev, int *val)
>>   {
>>           struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
>>
>>  + if (info->no_irq) {
>>  + pm_runtime_get_sync(indio_dev->dev.parent);
>>  +
>>  + regmap_read(info->regmap, SUN4I_GPADC_TEMP_DATA, val);
>>  +
>>  + pm_runtime_mark_last_busy(indio_dev->dev.parent);
>>  + pm_runtime_put_autosuspend(indio_dev->dev.parent);
>>  +
>>  + return 0;
>>  + }
>>  +
>>           return sun4i_gpadc_read(indio_dev, 0, val, info->temp_data_irq);
>>   }
>>
>>  @@ -454,6 +489,58 @@ static int sun4i_irq_init(struct platform_device *pdev, const char *name,
>>           return 0;
>>   }
>>
>>  +static const struct of_device_id sun4i_gpadc_of_id[] = {
>>  + {
>>  + .compatible = "allwinner,sun8i-a33-gpadc-iio",
>>  + .data = &sun8i_a33_gpadc_data,
>>  + },
>>  + { /* sentinel */ }
>>  +};
>>  +
>>  +static int sun4i_gpadc_probe_dt(struct platform_device *pdev,
>>  + struct iio_dev *indio_dev)
>>  +{
>>  + struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
>>  + const struct of_device_id *of_dev;
>>  + struct thermal_zone_device *tzd;
>>  + struct resource *mem;
>>  + void __iomem *base;
>>  + int ret;
>>  +
>>  + of_dev = of_match_device(sun4i_gpadc_of_id, &pdev->dev);
>>  + if (!of_dev)
>>  + return -ENODEV;
>>  +
>>  + info->no_irq = true;
>>  + info->data = (struct gpadc_data *)of_dev->data;
>>  + indio_dev->num_channels = ARRAY_SIZE(sun8i_a33_gpadc_channels);
>>  + indio_dev->channels = sun8i_a33_gpadc_channels;
>>  +
>>  + mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>>  + base = devm_ioremap_resource(&pdev->dev, mem);
>>  + if (IS_ERR(base))
>>  + return PTR_ERR(base);
>>  +
>>  + info->regmap = devm_regmap_init_mmio(&pdev->dev, base,
>>  + &sun4i_gpadc_regmap_config);
>>  + if (IS_ERR(info->regmap)) {
>>  + ret = PTR_ERR(info->regmap);
>>  + dev_err(&pdev->dev, "failed to init regmap: %d\n", ret);
>>  + return ret;
>>  + }
>>  +
>>  + if (!IS_ENABLED(THERMAL_OF))
>>  + return 0;
>>  +
>>  + tzd = devm_thermal_zone_of_sensor_register(&pdev->dev, 0, info,
>>  + &sun4i_ts_tz_ops);
>>  + if (IS_ERR(tzd))
>>  + dev_err(&pdev->dev, "could not register thermal sensor: %ld\n",
>>  + PTR_ERR(tzd));
>>  +
>>  + return PTR_ERR_OR_ZERO(tzd);
>>  +}
>>  +
>>   static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
>>                                    struct iio_dev *indio_dev)
>>   {
>>  @@ -462,6 +549,7 @@ static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
>>                   dev_get_drvdata(pdev->dev.parent);
>>           int ret;
>>
>>  + info->no_irq = false;
>>           info->regmap = sun4i_gpadc_dev->regmap;
>>
>>           indio_dev->num_channels = ARRAY_SIZE(sun4i_gpadc_channels);
>>  @@ -561,7 +649,11 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>>           indio_dev->info = &sun4i_gpadc_iio_info;
>>           indio_dev->modes = INDIO_DIRECT_MODE;
>>
>>  - ret = sun4i_gpadc_probe_mfd(pdev, indio_dev);
>>  + if (pdev->dev.of_node)
>>  + ret = sun4i_gpadc_probe_dt(pdev, indio_dev);
>>  + else
>>  + ret = sun4i_gpadc_probe_mfd(pdev, indio_dev);
>>  +
>>           if (ret)
>>                   return ret;
>>
>>  @@ -580,7 +672,7 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>>           return 0;
>>
>>   err_map:
>>  - if (IS_ENABLED(CONFIG_THERMAL_OF))
>>  + if (!info->no_irq && IS_ENABLED(CONFIG_THERMAL_OF))
>>                   iio_map_array_unregister(indio_dev);
>>
>>           pm_runtime_put(&pdev->dev);
>>  @@ -592,10 +684,11 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>>   static int sun4i_gpadc_remove(struct platform_device *pdev)
>>   {
>>           struct iio_dev *indio_dev = platform_get_drvdata(pdev);
>>  + struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
>>
>>           pm_runtime_put(&pdev->dev);
>>           pm_runtime_disable(&pdev->dev);
>>  - if (IS_ENABLED(CONFIG_THERMAL_OF))
>>  + if (!info->no_irq && IS_ENABLED(CONFIG_THERMAL_OF))
>>                   iio_map_array_unregister(indio_dev);
>>
>>           return 0;
>>  @@ -611,6 +704,7 @@ static const struct platform_device_id sun4i_gpadc_id[] = {
>>   static struct platform_driver sun4i_gpadc_driver = {
>>           .driver = {
>>                   .name = "sun4i-gpadc-iio",
>>  + .of_match_table = sun4i_gpadc_of_id,
>>                   .pm = &sun4i_gpadc_pm_ops,
>>           },
>>           .id_table = sun4i_gpadc_id,
>>  diff --git a/include/linux/mfd/sun4i-gpadc.h b/include/linux/mfd/sun4i-gpadc.h
>>  index 509e736..139872c 100644
>>  --- a/include/linux/mfd/sun4i-gpadc.h
>>  +++ b/include/linux/mfd/sun4i-gpadc.h
>>  @@ -38,6 +38,10 @@
>>   #define SUN6I_GPADC_CTRL1_ADC_CHAN_SELECT(x) (GENMASK(3, 0) & BIT(x))
>>   #define SUN6I_GPADC_CTRL1_ADC_CHAN_MASK GENMASK(3, 0)
>>
>>  +/* TP_CTRL1 bits for sun8i SoCs */
>>  +#define SUN8I_GPADC_CTRL1_CHOP_TEMP_EN BIT(8)
>>  +#define SUN8I_GPADC_CTRL1_GPADC_CALI_EN BIT(7)
>>  +
>>   #define SUN4I_GPADC_CTRL2 0x08
>>
>>   #define SUN4I_GPADC_CTRL2_TP_SENSITIVE_ADJUST(x) ((GENMASK(3, 0) & (x)) << 28)
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

-- 
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/d/optout.

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH v2 08/11] iio: adc: sun4i-gpadc-iio: add support for A33 thermal sensor
@ 2017-03-14  5:18         ` Icenowy Zheng
  0 siblings, 0 replies; 85+ messages in thread
From: Icenowy Zheng @ 2017-03-14  5:18 UTC (permalink / raw)
  To: Jonathan Cameron, Quentin Schulz, dmitry.torokhov, robh+dt,
	mark.rutland, maxime.ripard, wens, lee.jones, linux, knaack.h,
	lars, pmeerw, stefan.mavrodiev
  Cc: thomas.petazzoni, devicetree, linux-iio, linux-kernel,
	linux-sunxi, linux-arm-kernel



14.03.2017, 05:08, "Jonathan Cameron" <jic23@kernel.org>:
> On 10/03/17 10:39, Quentin Schulz wrote:
>>  This adds support for the Allwinner A33 thermal sensor.
>>
>>  Unlike the A10, A13 and A31, the Allwinner A33 only has one channel
>>  which is dedicated to the thermal sensor. Moreover, its thermal sensor
>>  does not generate interruptions, thus we only need to directly read the
>>  register storing the temperature value.
>>
>>  The MFD used by the A10, A13 and A31, was created to avoid breaking the
>>  DT binding, but since the nodes for the ADC weren't there for the A33,
>>  it is not needed.
>>
>>  Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
>
> Talk me through why it makes sense to do this rather than simply spin out
> a really simple thermal driver for the A33?

According to him the A33 thermal sensor is a simplified version of the GPADC.

I have already did a simple thermal driver ~8 months ago, but is rejected for
this reason.

>
> I'm not against what you have here, but don't feel it has been fully argued.
>
> Jonathan
>>  ---
>>
>>  v2:
>>    - removed added comments in Kconfig,
>>    - simplified Kconfig depends on condition,
>>    - removed THERMAL_OF requirement for sun8i,
>>    - renamed sun8i_gpadc_channels to sun8i_a33_gpadc_channels,
>>    - renamed use_dt boolean in no_irq as it reflects better why we need it,
>>    - removed spurious/unneeded modifications done in v1,
>>
>>   drivers/iio/adc/Kconfig | 2 +-
>>   drivers/iio/adc/sun4i-gpadc-iio.c | 100 ++++++++++++++++++++++++++++++++++++--
>>   include/linux/mfd/sun4i-gpadc.h | 4 ++
>>   3 files changed, 102 insertions(+), 4 deletions(-)
>>
>>  diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
>>  index 9f8b4b1..8c8ead6 100644
>>  --- a/drivers/iio/adc/Kconfig
>>  +++ b/drivers/iio/adc/Kconfig
>>  @@ -562,7 +562,7 @@ config STX104
>>   config SUN4I_GPADC
>>           tristate "Support for the Allwinner SoCs GPADC"
>>           depends on IIO
>>  - depends on MFD_SUN4I_GPADC
>>  + depends on MFD_SUN4I_GPADC || MACH_SUN8I
>>           help
>>             Say yes here to build support for Allwinner (A10, A13 and A31) SoCs
>>             GPADC. This ADC provides 4 channels which can be used as an ADC or as
>>  diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c
>>  index 7cb997a..70684cd 100644
>>  --- a/drivers/iio/adc/sun4i-gpadc-iio.c
>>  +++ b/drivers/iio/adc/sun4i-gpadc-iio.c
>>  @@ -85,6 +85,12 @@ static const struct gpadc_data sun6i_gpadc_data = {
>>           .adc_chan_mask = SUN6I_GPADC_CTRL1_ADC_CHAN_MASK,
>>   };
>>
>>  +static const struct gpadc_data sun8i_a33_gpadc_data = {
>>  + .temp_offset = -1662,
>>  + .temp_scale = 162,
>>  + .tp_mode_en = SUN8I_GPADC_CTRL1_CHOP_TEMP_EN,
>>  +};
>>  +
>>   struct sun4i_gpadc_iio {
>>           struct iio_dev *indio_dev;
>>           struct completion completion;
>>  @@ -96,6 +102,7 @@ struct sun4i_gpadc_iio {
>>           unsigned int temp_data_irq;
>>           atomic_t ignore_temp_data_irq;
>>           const struct gpadc_data *data;
>>  + bool no_irq;
>>           /* prevents concurrent reads of temperature and ADC */
>>           struct mutex mutex;
>>   };
>>  @@ -138,6 +145,23 @@ static const struct iio_chan_spec sun4i_gpadc_channels_no_temp[] = {
>>           SUN4I_GPADC_ADC_CHANNEL(3, "adc_chan3"),
>>   };
>>
>>  +static const struct iio_chan_spec sun8i_a33_gpadc_channels[] = {
>>  + {
>>  + .type = IIO_TEMP,
>>  + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
>>  + BIT(IIO_CHAN_INFO_SCALE) |
>>  + BIT(IIO_CHAN_INFO_OFFSET),
>>  + .datasheet_name = "temp_adc",
>>  + },
>>  +};
>>  +
>>  +static const struct regmap_config sun4i_gpadc_regmap_config = {
>>  + .reg_bits = 32,
>>  + .val_bits = 32,
>>  + .reg_stride = 4,
>>  + .fast_io = true,
>>  +};
>>  +
>>   static int sun4i_prepare_for_irq(struct iio_dev *indio_dev, int channel,
>>                                    unsigned int irq)
>>   {
>>  @@ -247,6 +271,17 @@ static int sun4i_gpadc_temp_read(struct iio_dev *indio_dev, int *val)
>>   {
>>           struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
>>
>>  + if (info->no_irq) {
>>  + pm_runtime_get_sync(indio_dev->dev.parent);
>>  +
>>  + regmap_read(info->regmap, SUN4I_GPADC_TEMP_DATA, val);
>>  +
>>  + pm_runtime_mark_last_busy(indio_dev->dev.parent);
>>  + pm_runtime_put_autosuspend(indio_dev->dev.parent);
>>  +
>>  + return 0;
>>  + }
>>  +
>>           return sun4i_gpadc_read(indio_dev, 0, val, info->temp_data_irq);
>>   }
>>
>>  @@ -454,6 +489,58 @@ static int sun4i_irq_init(struct platform_device *pdev, const char *name,
>>           return 0;
>>   }
>>
>>  +static const struct of_device_id sun4i_gpadc_of_id[] = {
>>  + {
>>  + .compatible = "allwinner,sun8i-a33-gpadc-iio",
>>  + .data = &sun8i_a33_gpadc_data,
>>  + },
>>  + { /* sentinel */ }
>>  +};
>>  +
>>  +static int sun4i_gpadc_probe_dt(struct platform_device *pdev,
>>  + struct iio_dev *indio_dev)
>>  +{
>>  + struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
>>  + const struct of_device_id *of_dev;
>>  + struct thermal_zone_device *tzd;
>>  + struct resource *mem;
>>  + void __iomem *base;
>>  + int ret;
>>  +
>>  + of_dev = of_match_device(sun4i_gpadc_of_id, &pdev->dev);
>>  + if (!of_dev)
>>  + return -ENODEV;
>>  +
>>  + info->no_irq = true;
>>  + info->data = (struct gpadc_data *)of_dev->data;
>>  + indio_dev->num_channels = ARRAY_SIZE(sun8i_a33_gpadc_channels);
>>  + indio_dev->channels = sun8i_a33_gpadc_channels;
>>  +
>>  + mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>>  + base = devm_ioremap_resource(&pdev->dev, mem);
>>  + if (IS_ERR(base))
>>  + return PTR_ERR(base);
>>  +
>>  + info->regmap = devm_regmap_init_mmio(&pdev->dev, base,
>>  + &sun4i_gpadc_regmap_config);
>>  + if (IS_ERR(info->regmap)) {
>>  + ret = PTR_ERR(info->regmap);
>>  + dev_err(&pdev->dev, "failed to init regmap: %d\n", ret);
>>  + return ret;
>>  + }
>>  +
>>  + if (!IS_ENABLED(THERMAL_OF))
>>  + return 0;
>>  +
>>  + tzd = devm_thermal_zone_of_sensor_register(&pdev->dev, 0, info,
>>  + &sun4i_ts_tz_ops);
>>  + if (IS_ERR(tzd))
>>  + dev_err(&pdev->dev, "could not register thermal sensor: %ld\n",
>>  + PTR_ERR(tzd));
>>  +
>>  + return PTR_ERR_OR_ZERO(tzd);
>>  +}
>>  +
>>   static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
>>                                    struct iio_dev *indio_dev)
>>   {
>>  @@ -462,6 +549,7 @@ static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
>>                   dev_get_drvdata(pdev->dev.parent);
>>           int ret;
>>
>>  + info->no_irq = false;
>>           info->regmap = sun4i_gpadc_dev->regmap;
>>
>>           indio_dev->num_channels = ARRAY_SIZE(sun4i_gpadc_channels);
>>  @@ -561,7 +649,11 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>>           indio_dev->info = &sun4i_gpadc_iio_info;
>>           indio_dev->modes = INDIO_DIRECT_MODE;
>>
>>  - ret = sun4i_gpadc_probe_mfd(pdev, indio_dev);
>>  + if (pdev->dev.of_node)
>>  + ret = sun4i_gpadc_probe_dt(pdev, indio_dev);
>>  + else
>>  + ret = sun4i_gpadc_probe_mfd(pdev, indio_dev);
>>  +
>>           if (ret)
>>                   return ret;
>>
>>  @@ -580,7 +672,7 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>>           return 0;
>>
>>   err_map:
>>  - if (IS_ENABLED(CONFIG_THERMAL_OF))
>>  + if (!info->no_irq && IS_ENABLED(CONFIG_THERMAL_OF))
>>                   iio_map_array_unregister(indio_dev);
>>
>>           pm_runtime_put(&pdev->dev);
>>  @@ -592,10 +684,11 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>>   static int sun4i_gpadc_remove(struct platform_device *pdev)
>>   {
>>           struct iio_dev *indio_dev = platform_get_drvdata(pdev);
>>  + struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
>>
>>           pm_runtime_put(&pdev->dev);
>>           pm_runtime_disable(&pdev->dev);
>>  - if (IS_ENABLED(CONFIG_THERMAL_OF))
>>  + if (!info->no_irq && IS_ENABLED(CONFIG_THERMAL_OF))
>>                   iio_map_array_unregister(indio_dev);
>>
>>           return 0;
>>  @@ -611,6 +704,7 @@ static const struct platform_device_id sun4i_gpadc_id[] = {
>>   static struct platform_driver sun4i_gpadc_driver = {
>>           .driver = {
>>                   .name = "sun4i-gpadc-iio",
>>  + .of_match_table = sun4i_gpadc_of_id,
>>                   .pm = &sun4i_gpadc_pm_ops,
>>           },
>>           .id_table = sun4i_gpadc_id,
>>  diff --git a/include/linux/mfd/sun4i-gpadc.h b/include/linux/mfd/sun4i-gpadc.h
>>  index 509e736..139872c 100644
>>  --- a/include/linux/mfd/sun4i-gpadc.h
>>  +++ b/include/linux/mfd/sun4i-gpadc.h
>>  @@ -38,6 +38,10 @@
>>   #define SUN6I_GPADC_CTRL1_ADC_CHAN_SELECT(x) (GENMASK(3, 0) & BIT(x))
>>   #define SUN6I_GPADC_CTRL1_ADC_CHAN_MASK GENMASK(3, 0)
>>
>>  +/* TP_CTRL1 bits for sun8i SoCs */
>>  +#define SUN8I_GPADC_CTRL1_CHOP_TEMP_EN BIT(8)
>>  +#define SUN8I_GPADC_CTRL1_GPADC_CALI_EN BIT(7)
>>  +
>>   #define SUN4I_GPADC_CTRL2 0x08
>>
>>   #define SUN4I_GPADC_CTRL2_TP_SENSITIVE_ADJUST(x) ((GENMASK(3, 0) & (x)) << 28)
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 85+ messages in thread

* [PATCH v2 08/11] iio: adc: sun4i-gpadc-iio: add support for A33 thermal sensor
@ 2017-03-14  5:18         ` Icenowy Zheng
  0 siblings, 0 replies; 85+ messages in thread
From: Icenowy Zheng @ 2017-03-14  5:18 UTC (permalink / raw)
  To: linux-arm-kernel



14.03.2017, 05:08, "Jonathan Cameron" <jic23@kernel.org>:
> On 10/03/17 10:39, Quentin Schulz wrote:
>> ?This adds support for the Allwinner A33 thermal sensor.
>>
>> ?Unlike the A10, A13 and A31, the Allwinner A33 only has one channel
>> ?which is dedicated to the thermal sensor. Moreover, its thermal sensor
>> ?does not generate interruptions, thus we only need to directly read the
>> ?register storing the temperature value.
>>
>> ?The MFD used by the A10, A13 and A31, was created to avoid breaking the
>> ?DT binding, but since the nodes for the ADC weren't there for the A33,
>> ?it is not needed.
>>
>> ?Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
>
> Talk me through why it makes sense to do this rather than simply spin out
> a really simple thermal driver for the A33?

According to him the A33 thermal sensor is a simplified version of the GPADC.

I have already did a simple thermal driver ~8 months ago, but is rejected for
this reason.

>
> I'm not against what you have here, but don't feel it has been fully argued.
>
> Jonathan
>> ?---
>>
>> ?v2:
>> ???- removed added comments in Kconfig,
>> ???- simplified Kconfig depends on condition,
>> ???- removed THERMAL_OF requirement for sun8i,
>> ???- renamed sun8i_gpadc_channels to sun8i_a33_gpadc_channels,
>> ???- renamed use_dt boolean in no_irq as it reflects better why we need it,
>> ???- removed spurious/unneeded modifications done in v1,
>>
>> ??drivers/iio/adc/Kconfig | 2 +-
>> ??drivers/iio/adc/sun4i-gpadc-iio.c | 100 ++++++++++++++++++++++++++++++++++++--
>> ??include/linux/mfd/sun4i-gpadc.h | 4 ++
>> ??3 files changed, 102 insertions(+), 4 deletions(-)
>>
>> ?diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
>> ?index 9f8b4b1..8c8ead6 100644
>> ?--- a/drivers/iio/adc/Kconfig
>> ?+++ b/drivers/iio/adc/Kconfig
>> ?@@ -562,7 +562,7 @@ config STX104
>> ??config SUN4I_GPADC
>> ??????????tristate "Support for the Allwinner SoCs GPADC"
>> ??????????depends on IIO
>> ?- depends on MFD_SUN4I_GPADC
>> ?+ depends on MFD_SUN4I_GPADC || MACH_SUN8I
>> ??????????help
>> ????????????Say yes here to build support for Allwinner (A10, A13 and A31) SoCs
>> ????????????GPADC. This ADC provides 4 channels which can be used as an ADC or as
>> ?diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c
>> ?index 7cb997a..70684cd 100644
>> ?--- a/drivers/iio/adc/sun4i-gpadc-iio.c
>> ?+++ b/drivers/iio/adc/sun4i-gpadc-iio.c
>> ?@@ -85,6 +85,12 @@ static const struct gpadc_data sun6i_gpadc_data = {
>> ??????????.adc_chan_mask = SUN6I_GPADC_CTRL1_ADC_CHAN_MASK,
>> ??};
>>
>> ?+static const struct gpadc_data sun8i_a33_gpadc_data = {
>> ?+ .temp_offset = -1662,
>> ?+ .temp_scale = 162,
>> ?+ .tp_mode_en = SUN8I_GPADC_CTRL1_CHOP_TEMP_EN,
>> ?+};
>> ?+
>> ??struct sun4i_gpadc_iio {
>> ??????????struct iio_dev *indio_dev;
>> ??????????struct completion completion;
>> ?@@ -96,6 +102,7 @@ struct sun4i_gpadc_iio {
>> ??????????unsigned int temp_data_irq;
>> ??????????atomic_t ignore_temp_data_irq;
>> ??????????const struct gpadc_data *data;
>> ?+ bool no_irq;
>> ??????????/* prevents concurrent reads of temperature and ADC */
>> ??????????struct mutex mutex;
>> ??};
>> ?@@ -138,6 +145,23 @@ static const struct iio_chan_spec sun4i_gpadc_channels_no_temp[] = {
>> ??????????SUN4I_GPADC_ADC_CHANNEL(3, "adc_chan3"),
>> ??};
>>
>> ?+static const struct iio_chan_spec sun8i_a33_gpadc_channels[] = {
>> ?+ {
>> ?+ .type = IIO_TEMP,
>> ?+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
>> ?+ BIT(IIO_CHAN_INFO_SCALE) |
>> ?+ BIT(IIO_CHAN_INFO_OFFSET),
>> ?+ .datasheet_name = "temp_adc",
>> ?+ },
>> ?+};
>> ?+
>> ?+static const struct regmap_config sun4i_gpadc_regmap_config = {
>> ?+ .reg_bits = 32,
>> ?+ .val_bits = 32,
>> ?+ .reg_stride = 4,
>> ?+ .fast_io = true,
>> ?+};
>> ?+
>> ??static int sun4i_prepare_for_irq(struct iio_dev *indio_dev, int channel,
>> ???????????????????????????????????unsigned int irq)
>> ??{
>> ?@@ -247,6 +271,17 @@ static int sun4i_gpadc_temp_read(struct iio_dev *indio_dev, int *val)
>> ??{
>> ??????????struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
>>
>> ?+ if (info->no_irq) {
>> ?+ pm_runtime_get_sync(indio_dev->dev.parent);
>> ?+
>> ?+ regmap_read(info->regmap, SUN4I_GPADC_TEMP_DATA, val);
>> ?+
>> ?+ pm_runtime_mark_last_busy(indio_dev->dev.parent);
>> ?+ pm_runtime_put_autosuspend(indio_dev->dev.parent);
>> ?+
>> ?+ return 0;
>> ?+ }
>> ?+
>> ??????????return sun4i_gpadc_read(indio_dev, 0, val, info->temp_data_irq);
>> ??}
>>
>> ?@@ -454,6 +489,58 @@ static int sun4i_irq_init(struct platform_device *pdev, const char *name,
>> ??????????return 0;
>> ??}
>>
>> ?+static const struct of_device_id sun4i_gpadc_of_id[] = {
>> ?+ {
>> ?+ .compatible = "allwinner,sun8i-a33-gpadc-iio",
>> ?+ .data = &sun8i_a33_gpadc_data,
>> ?+ },
>> ?+ { /* sentinel */ }
>> ?+};
>> ?+
>> ?+static int sun4i_gpadc_probe_dt(struct platform_device *pdev,
>> ?+ struct iio_dev *indio_dev)
>> ?+{
>> ?+ struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
>> ?+ const struct of_device_id *of_dev;
>> ?+ struct thermal_zone_device *tzd;
>> ?+ struct resource *mem;
>> ?+ void __iomem *base;
>> ?+ int ret;
>> ?+
>> ?+ of_dev = of_match_device(sun4i_gpadc_of_id, &pdev->dev);
>> ?+ if (!of_dev)
>> ?+ return -ENODEV;
>> ?+
>> ?+ info->no_irq = true;
>> ?+ info->data = (struct gpadc_data *)of_dev->data;
>> ?+ indio_dev->num_channels = ARRAY_SIZE(sun8i_a33_gpadc_channels);
>> ?+ indio_dev->channels = sun8i_a33_gpadc_channels;
>> ?+
>> ?+ mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>> ?+ base = devm_ioremap_resource(&pdev->dev, mem);
>> ?+ if (IS_ERR(base))
>> ?+ return PTR_ERR(base);
>> ?+
>> ?+ info->regmap = devm_regmap_init_mmio(&pdev->dev, base,
>> ?+ &sun4i_gpadc_regmap_config);
>> ?+ if (IS_ERR(info->regmap)) {
>> ?+ ret = PTR_ERR(info->regmap);
>> ?+ dev_err(&pdev->dev, "failed to init regmap: %d\n", ret);
>> ?+ return ret;
>> ?+ }
>> ?+
>> ?+ if (!IS_ENABLED(THERMAL_OF))
>> ?+ return 0;
>> ?+
>> ?+ tzd = devm_thermal_zone_of_sensor_register(&pdev->dev, 0, info,
>> ?+ &sun4i_ts_tz_ops);
>> ?+ if (IS_ERR(tzd))
>> ?+ dev_err(&pdev->dev, "could not register thermal sensor: %ld\n",
>> ?+ PTR_ERR(tzd));
>> ?+
>> ?+ return PTR_ERR_OR_ZERO(tzd);
>> ?+}
>> ?+
>> ??static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
>> ???????????????????????????????????struct iio_dev *indio_dev)
>> ??{
>> ?@@ -462,6 +549,7 @@ static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
>> ??????????????????dev_get_drvdata(pdev->dev.parent);
>> ??????????int ret;
>>
>> ?+ info->no_irq = false;
>> ??????????info->regmap = sun4i_gpadc_dev->regmap;
>>
>> ??????????indio_dev->num_channels = ARRAY_SIZE(sun4i_gpadc_channels);
>> ?@@ -561,7 +649,11 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>> ??????????indio_dev->info = &sun4i_gpadc_iio_info;
>> ??????????indio_dev->modes = INDIO_DIRECT_MODE;
>>
>> ?- ret = sun4i_gpadc_probe_mfd(pdev, indio_dev);
>> ?+ if (pdev->dev.of_node)
>> ?+ ret = sun4i_gpadc_probe_dt(pdev, indio_dev);
>> ?+ else
>> ?+ ret = sun4i_gpadc_probe_mfd(pdev, indio_dev);
>> ?+
>> ??????????if (ret)
>> ??????????????????return ret;
>>
>> ?@@ -580,7 +672,7 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>> ??????????return 0;
>>
>> ??err_map:
>> ?- if (IS_ENABLED(CONFIG_THERMAL_OF))
>> ?+ if (!info->no_irq && IS_ENABLED(CONFIG_THERMAL_OF))
>> ??????????????????iio_map_array_unregister(indio_dev);
>>
>> ??????????pm_runtime_put(&pdev->dev);
>> ?@@ -592,10 +684,11 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>> ??static int sun4i_gpadc_remove(struct platform_device *pdev)
>> ??{
>> ??????????struct iio_dev *indio_dev = platform_get_drvdata(pdev);
>> ?+ struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
>>
>> ??????????pm_runtime_put(&pdev->dev);
>> ??????????pm_runtime_disable(&pdev->dev);
>> ?- if (IS_ENABLED(CONFIG_THERMAL_OF))
>> ?+ if (!info->no_irq && IS_ENABLED(CONFIG_THERMAL_OF))
>> ??????????????????iio_map_array_unregister(indio_dev);
>>
>> ??????????return 0;
>> ?@@ -611,6 +704,7 @@ static const struct platform_device_id sun4i_gpadc_id[] = {
>> ??static struct platform_driver sun4i_gpadc_driver = {
>> ??????????.driver = {
>> ??????????????????.name = "sun4i-gpadc-iio",
>> ?+ .of_match_table = sun4i_gpadc_of_id,
>> ??????????????????.pm = &sun4i_gpadc_pm_ops,
>> ??????????},
>> ??????????.id_table = sun4i_gpadc_id,
>> ?diff --git a/include/linux/mfd/sun4i-gpadc.h b/include/linux/mfd/sun4i-gpadc.h
>> ?index 509e736..139872c 100644
>> ?--- a/include/linux/mfd/sun4i-gpadc.h
>> ?+++ b/include/linux/mfd/sun4i-gpadc.h
>> ?@@ -38,6 +38,10 @@
>> ??#define SUN6I_GPADC_CTRL1_ADC_CHAN_SELECT(x) (GENMASK(3, 0) & BIT(x))
>> ??#define SUN6I_GPADC_CTRL1_ADC_CHAN_MASK GENMASK(3, 0)
>>
>> ?+/* TP_CTRL1 bits for sun8i SoCs */
>> ?+#define SUN8I_GPADC_CTRL1_CHOP_TEMP_EN BIT(8)
>> ?+#define SUN8I_GPADC_CTRL1_GPADC_CALI_EN BIT(7)
>> ?+
>> ??#define SUN4I_GPADC_CTRL2 0x08
>>
>> ??#define SUN4I_GPADC_CTRL2_TP_SENSITIVE_ADJUST(x) ((GENMASK(3, 0) & (x)) << 28)
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH v2 08/11] iio: adc: sun4i-gpadc-iio: add support for A33 thermal sensor
@ 2017-03-14  7:15           ` Quentin Schulz
  0 siblings, 0 replies; 85+ messages in thread
From: Quentin Schulz @ 2017-03-14  7:15 UTC (permalink / raw)
  To: Icenowy Zheng, Jonathan Cameron, dmitry.torokhov, robh+dt,
	mark.rutland, maxime.ripard, wens, lee.jones, linux, knaack.h,
	lars, pmeerw, stefan.mavrodiev
  Cc: thomas.petazzoni, devicetree, linux-iio, linux-kernel,
	linux-sunxi, linux-arm-kernel

Hi Jonathan,

On 14/03/2017 06:18, Icenowy Zheng wrote:
> 
> 
> 14.03.2017, 05:08, "Jonathan Cameron" <jic23@kernel.org>:
>> On 10/03/17 10:39, Quentin Schulz wrote:
>>>  This adds support for the Allwinner A33 thermal sensor.
>>>
>>>  Unlike the A10, A13 and A31, the Allwinner A33 only has one channel
>>>  which is dedicated to the thermal sensor. Moreover, its thermal sensor
>>>  does not generate interruptions, thus we only need to directly read the
>>>  register storing the temperature value.
>>>
>>>  The MFD used by the A10, A13 and A31, was created to avoid breaking the
>>>  DT binding, but since the nodes for the ADC weren't there for the A33,
>>>  it is not needed.
>>>
>>>  Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
>>
>> Talk me through why it makes sense to do this rather than simply spin out
>> a really simple thermal driver for the A33?
> 
> According to him the A33 thermal sensor is a simplified version of the GPADC.
> 

Same registers with almost same bits for the same purpose (temperature).
Some SoCs have an ADC and one or more thermal sensors (A10, A13, A31,
H3) while others have only one thermal sensor (A23, A33). Same IP with
or without ADC/Touchscreen so same driver, that was my mindset.

The thermal part behaves the same except for the presence of interrupts
or not. (A33 has bits for interrupts in the datasheet but that just does
not work).

Thanks,
Quentin

> I have already did a simple thermal driver ~8 months ago, but is rejected for
> this reason.
> 
>>
>> I'm not against what you have here, but don't feel it has been fully argued.
>>
>> Jonathan
>>>  ---
>>>
>>>  v2:
>>>    - removed added comments in Kconfig,
>>>    - simplified Kconfig depends on condition,
>>>    - removed THERMAL_OF requirement for sun8i,
>>>    - renamed sun8i_gpadc_channels to sun8i_a33_gpadc_channels,
>>>    - renamed use_dt boolean in no_irq as it reflects better why we need it,
>>>    - removed spurious/unneeded modifications done in v1,
>>>
>>>   drivers/iio/adc/Kconfig | 2 +-
>>>   drivers/iio/adc/sun4i-gpadc-iio.c | 100 ++++++++++++++++++++++++++++++++++++--
>>>   include/linux/mfd/sun4i-gpadc.h | 4 ++
>>>   3 files changed, 102 insertions(+), 4 deletions(-)
>>>
>>>  diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
>>>  index 9f8b4b1..8c8ead6 100644
>>>  --- a/drivers/iio/adc/Kconfig
>>>  +++ b/drivers/iio/adc/Kconfig
>>>  @@ -562,7 +562,7 @@ config STX104
>>>   config SUN4I_GPADC
>>>           tristate "Support for the Allwinner SoCs GPADC"
>>>           depends on IIO
>>>  - depends on MFD_SUN4I_GPADC
>>>  + depends on MFD_SUN4I_GPADC || MACH_SUN8I
>>>           help
>>>             Say yes here to build support for Allwinner (A10, A13 and A31) SoCs
>>>             GPADC. This ADC provides 4 channels which can be used as an ADC or as
>>>  diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c
>>>  index 7cb997a..70684cd 100644
>>>  --- a/drivers/iio/adc/sun4i-gpadc-iio.c
>>>  +++ b/drivers/iio/adc/sun4i-gpadc-iio.c
>>>  @@ -85,6 +85,12 @@ static const struct gpadc_data sun6i_gpadc_data = {
>>>           .adc_chan_mask = SUN6I_GPADC_CTRL1_ADC_CHAN_MASK,
>>>   };
>>>
>>>  +static const struct gpadc_data sun8i_a33_gpadc_data = {
>>>  + .temp_offset = -1662,
>>>  + .temp_scale = 162,
>>>  + .tp_mode_en = SUN8I_GPADC_CTRL1_CHOP_TEMP_EN,
>>>  +};
>>>  +
>>>   struct sun4i_gpadc_iio {
>>>           struct iio_dev *indio_dev;
>>>           struct completion completion;
>>>  @@ -96,6 +102,7 @@ struct sun4i_gpadc_iio {
>>>           unsigned int temp_data_irq;
>>>           atomic_t ignore_temp_data_irq;
>>>           const struct gpadc_data *data;
>>>  + bool no_irq;
>>>           /* prevents concurrent reads of temperature and ADC */
>>>           struct mutex mutex;
>>>   };
>>>  @@ -138,6 +145,23 @@ static const struct iio_chan_spec sun4i_gpadc_channels_no_temp[] = {
>>>           SUN4I_GPADC_ADC_CHANNEL(3, "adc_chan3"),
>>>   };
>>>
>>>  +static const struct iio_chan_spec sun8i_a33_gpadc_channels[] = {
>>>  + {
>>>  + .type = IIO_TEMP,
>>>  + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
>>>  + BIT(IIO_CHAN_INFO_SCALE) |
>>>  + BIT(IIO_CHAN_INFO_OFFSET),
>>>  + .datasheet_name = "temp_adc",
>>>  + },
>>>  +};
>>>  +
>>>  +static const struct regmap_config sun4i_gpadc_regmap_config = {
>>>  + .reg_bits = 32,
>>>  + .val_bits = 32,
>>>  + .reg_stride = 4,
>>>  + .fast_io = true,
>>>  +};
>>>  +
>>>   static int sun4i_prepare_for_irq(struct iio_dev *indio_dev, int channel,
>>>                                    unsigned int irq)
>>>   {
>>>  @@ -247,6 +271,17 @@ static int sun4i_gpadc_temp_read(struct iio_dev *indio_dev, int *val)
>>>   {
>>>           struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
>>>
>>>  + if (info->no_irq) {
>>>  + pm_runtime_get_sync(indio_dev->dev.parent);
>>>  +
>>>  + regmap_read(info->regmap, SUN4I_GPADC_TEMP_DATA, val);
>>>  +
>>>  + pm_runtime_mark_last_busy(indio_dev->dev.parent);
>>>  + pm_runtime_put_autosuspend(indio_dev->dev.parent);
>>>  +
>>>  + return 0;
>>>  + }
>>>  +
>>>           return sun4i_gpadc_read(indio_dev, 0, val, info->temp_data_irq);
>>>   }
>>>
>>>  @@ -454,6 +489,58 @@ static int sun4i_irq_init(struct platform_device *pdev, const char *name,
>>>           return 0;
>>>   }
>>>
>>>  +static const struct of_device_id sun4i_gpadc_of_id[] = {
>>>  + {
>>>  + .compatible = "allwinner,sun8i-a33-gpadc-iio",
>>>  + .data = &sun8i_a33_gpadc_data,
>>>  + },
>>>  + { /* sentinel */ }
>>>  +};
>>>  +
>>>  +static int sun4i_gpadc_probe_dt(struct platform_device *pdev,
>>>  + struct iio_dev *indio_dev)
>>>  +{
>>>  + struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
>>>  + const struct of_device_id *of_dev;
>>>  + struct thermal_zone_device *tzd;
>>>  + struct resource *mem;
>>>  + void __iomem *base;
>>>  + int ret;
>>>  +
>>>  + of_dev = of_match_device(sun4i_gpadc_of_id, &pdev->dev);
>>>  + if (!of_dev)
>>>  + return -ENODEV;
>>>  +
>>>  + info->no_irq = true;
>>>  + info->data = (struct gpadc_data *)of_dev->data;
>>>  + indio_dev->num_channels = ARRAY_SIZE(sun8i_a33_gpadc_channels);
>>>  + indio_dev->channels = sun8i_a33_gpadc_channels;
>>>  +
>>>  + mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>>>  + base = devm_ioremap_resource(&pdev->dev, mem);
>>>  + if (IS_ERR(base))
>>>  + return PTR_ERR(base);
>>>  +
>>>  + info->regmap = devm_regmap_init_mmio(&pdev->dev, base,
>>>  + &sun4i_gpadc_regmap_config);
>>>  + if (IS_ERR(info->regmap)) {
>>>  + ret = PTR_ERR(info->regmap);
>>>  + dev_err(&pdev->dev, "failed to init regmap: %d\n", ret);
>>>  + return ret;
>>>  + }
>>>  +
>>>  + if (!IS_ENABLED(THERMAL_OF))
>>>  + return 0;
>>>  +
>>>  + tzd = devm_thermal_zone_of_sensor_register(&pdev->dev, 0, info,
>>>  + &sun4i_ts_tz_ops);
>>>  + if (IS_ERR(tzd))
>>>  + dev_err(&pdev->dev, "could not register thermal sensor: %ld\n",
>>>  + PTR_ERR(tzd));
>>>  +
>>>  + return PTR_ERR_OR_ZERO(tzd);
>>>  +}
>>>  +
>>>   static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
>>>                                    struct iio_dev *indio_dev)
>>>   {
>>>  @@ -462,6 +549,7 @@ static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
>>>                   dev_get_drvdata(pdev->dev.parent);
>>>           int ret;
>>>
>>>  + info->no_irq = false;
>>>           info->regmap = sun4i_gpadc_dev->regmap;
>>>
>>>           indio_dev->num_channels = ARRAY_SIZE(sun4i_gpadc_channels);
>>>  @@ -561,7 +649,11 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>>>           indio_dev->info = &sun4i_gpadc_iio_info;
>>>           indio_dev->modes = INDIO_DIRECT_MODE;
>>>
>>>  - ret = sun4i_gpadc_probe_mfd(pdev, indio_dev);
>>>  + if (pdev->dev.of_node)
>>>  + ret = sun4i_gpadc_probe_dt(pdev, indio_dev);
>>>  + else
>>>  + ret = sun4i_gpadc_probe_mfd(pdev, indio_dev);
>>>  +
>>>           if (ret)
>>>                   return ret;
>>>
>>>  @@ -580,7 +672,7 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>>>           return 0;
>>>
>>>   err_map:
>>>  - if (IS_ENABLED(CONFIG_THERMAL_OF))
>>>  + if (!info->no_irq && IS_ENABLED(CONFIG_THERMAL_OF))
>>>                   iio_map_array_unregister(indio_dev);
>>>
>>>           pm_runtime_put(&pdev->dev);
>>>  @@ -592,10 +684,11 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>>>   static int sun4i_gpadc_remove(struct platform_device *pdev)
>>>   {
>>>           struct iio_dev *indio_dev = platform_get_drvdata(pdev);
>>>  + struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
>>>
>>>           pm_runtime_put(&pdev->dev);
>>>           pm_runtime_disable(&pdev->dev);
>>>  - if (IS_ENABLED(CONFIG_THERMAL_OF))
>>>  + if (!info->no_irq && IS_ENABLED(CONFIG_THERMAL_OF))
>>>                   iio_map_array_unregister(indio_dev);
>>>
>>>           return 0;
>>>  @@ -611,6 +704,7 @@ static const struct platform_device_id sun4i_gpadc_id[] = {
>>>   static struct platform_driver sun4i_gpadc_driver = {
>>>           .driver = {
>>>                   .name = "sun4i-gpadc-iio",
>>>  + .of_match_table = sun4i_gpadc_of_id,
>>>                   .pm = &sun4i_gpadc_pm_ops,
>>>           },
>>>           .id_table = sun4i_gpadc_id,
>>>  diff --git a/include/linux/mfd/sun4i-gpadc.h b/include/linux/mfd/sun4i-gpadc.h
>>>  index 509e736..139872c 100644
>>>  --- a/include/linux/mfd/sun4i-gpadc.h
>>>  +++ b/include/linux/mfd/sun4i-gpadc.h
>>>  @@ -38,6 +38,10 @@
>>>   #define SUN6I_GPADC_CTRL1_ADC_CHAN_SELECT(x) (GENMASK(3, 0) & BIT(x))
>>>   #define SUN6I_GPADC_CTRL1_ADC_CHAN_MASK GENMASK(3, 0)
>>>
>>>  +/* TP_CTRL1 bits for sun8i SoCs */
>>>  +#define SUN8I_GPADC_CTRL1_CHOP_TEMP_EN BIT(8)
>>>  +#define SUN8I_GPADC_CTRL1_GPADC_CALI_EN BIT(7)
>>>  +
>>>   #define SUN4I_GPADC_CTRL2 0x08
>>>
>>>   #define SUN4I_GPADC_CTRL2_TP_SENSITIVE_ADJUST(x) ((GENMASK(3, 0) & (x)) << 28)
>>
>> _______________________________________________
>> linux-arm-kernel mailing list
>> linux-arm-kernel@lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

-- 
Quentin Schulz, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH v2 08/11] iio: adc: sun4i-gpadc-iio: add support for A33 thermal sensor
@ 2017-03-14  7:15           ` Quentin Schulz
  0 siblings, 0 replies; 85+ messages in thread
From: Quentin Schulz @ 2017-03-14  7:15 UTC (permalink / raw)
  To: Icenowy Zheng, Jonathan Cameron,
	dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8, wens-jdAy2FN1RRM,
	lee.jones-QSEj5FYQhm4dnm+yROfE0A, linux-I+IVW8TIWO2tmTQ+vhA3Yw,
	knaack.h-Mmb7MZpHnFY, lars-Qo5EllUWu/uELgA04lAiVw,
	pmeerw-jW+XmwGofnusTnJN9+BGXg,
	stefan.mavrodiev-Re5JQEeQqe8AvxtiuMwx3w
  Cc: thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-iio-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

Hi Jonathan,

On 14/03/2017 06:18, Icenowy Zheng wrote:
> 
> 
> 14.03.2017, 05:08, "Jonathan Cameron" <jic23-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>:
>> On 10/03/17 10:39, Quentin Schulz wrote:
>>>  This adds support for the Allwinner A33 thermal sensor.
>>>
>>>  Unlike the A10, A13 and A31, the Allwinner A33 only has one channel
>>>  which is dedicated to the thermal sensor. Moreover, its thermal sensor
>>>  does not generate interruptions, thus we only need to directly read the
>>>  register storing the temperature value.
>>>
>>>  The MFD used by the A10, A13 and A31, was created to avoid breaking the
>>>  DT binding, but since the nodes for the ADC weren't there for the A33,
>>>  it is not needed.
>>>
>>>  Signed-off-by: Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
>>
>> Talk me through why it makes sense to do this rather than simply spin out
>> a really simple thermal driver for the A33?
> 
> According to him the A33 thermal sensor is a simplified version of the GPADC.
> 

Same registers with almost same bits for the same purpose (temperature).
Some SoCs have an ADC and one or more thermal sensors (A10, A13, A31,
H3) while others have only one thermal sensor (A23, A33). Same IP with
or without ADC/Touchscreen so same driver, that was my mindset.

The thermal part behaves the same except for the presence of interrupts
or not. (A33 has bits for interrupts in the datasheet but that just does
not work).

Thanks,
Quentin

> I have already did a simple thermal driver ~8 months ago, but is rejected for
> this reason.
> 
>>
>> I'm not against what you have here, but don't feel it has been fully argued.
>>
>> Jonathan
>>>  ---
>>>
>>>  v2:
>>>    - removed added comments in Kconfig,
>>>    - simplified Kconfig depends on condition,
>>>    - removed THERMAL_OF requirement for sun8i,
>>>    - renamed sun8i_gpadc_channels to sun8i_a33_gpadc_channels,
>>>    - renamed use_dt boolean in no_irq as it reflects better why we need it,
>>>    - removed spurious/unneeded modifications done in v1,
>>>
>>>   drivers/iio/adc/Kconfig | 2 +-
>>>   drivers/iio/adc/sun4i-gpadc-iio.c | 100 ++++++++++++++++++++++++++++++++++++--
>>>   include/linux/mfd/sun4i-gpadc.h | 4 ++
>>>   3 files changed, 102 insertions(+), 4 deletions(-)
>>>
>>>  diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
>>>  index 9f8b4b1..8c8ead6 100644
>>>  --- a/drivers/iio/adc/Kconfig
>>>  +++ b/drivers/iio/adc/Kconfig
>>>  @@ -562,7 +562,7 @@ config STX104
>>>   config SUN4I_GPADC
>>>           tristate "Support for the Allwinner SoCs GPADC"
>>>           depends on IIO
>>>  - depends on MFD_SUN4I_GPADC
>>>  + depends on MFD_SUN4I_GPADC || MACH_SUN8I
>>>           help
>>>             Say yes here to build support for Allwinner (A10, A13 and A31) SoCs
>>>             GPADC. This ADC provides 4 channels which can be used as an ADC or as
>>>  diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c
>>>  index 7cb997a..70684cd 100644
>>>  --- a/drivers/iio/adc/sun4i-gpadc-iio.c
>>>  +++ b/drivers/iio/adc/sun4i-gpadc-iio.c
>>>  @@ -85,6 +85,12 @@ static const struct gpadc_data sun6i_gpadc_data = {
>>>           .adc_chan_mask = SUN6I_GPADC_CTRL1_ADC_CHAN_MASK,
>>>   };
>>>
>>>  +static const struct gpadc_data sun8i_a33_gpadc_data = {
>>>  + .temp_offset = -1662,
>>>  + .temp_scale = 162,
>>>  + .tp_mode_en = SUN8I_GPADC_CTRL1_CHOP_TEMP_EN,
>>>  +};
>>>  +
>>>   struct sun4i_gpadc_iio {
>>>           struct iio_dev *indio_dev;
>>>           struct completion completion;
>>>  @@ -96,6 +102,7 @@ struct sun4i_gpadc_iio {
>>>           unsigned int temp_data_irq;
>>>           atomic_t ignore_temp_data_irq;
>>>           const struct gpadc_data *data;
>>>  + bool no_irq;
>>>           /* prevents concurrent reads of temperature and ADC */
>>>           struct mutex mutex;
>>>   };
>>>  @@ -138,6 +145,23 @@ static const struct iio_chan_spec sun4i_gpadc_channels_no_temp[] = {
>>>           SUN4I_GPADC_ADC_CHANNEL(3, "adc_chan3"),
>>>   };
>>>
>>>  +static const struct iio_chan_spec sun8i_a33_gpadc_channels[] = {
>>>  + {
>>>  + .type = IIO_TEMP,
>>>  + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
>>>  + BIT(IIO_CHAN_INFO_SCALE) |
>>>  + BIT(IIO_CHAN_INFO_OFFSET),
>>>  + .datasheet_name = "temp_adc",
>>>  + },
>>>  +};
>>>  +
>>>  +static const struct regmap_config sun4i_gpadc_regmap_config = {
>>>  + .reg_bits = 32,
>>>  + .val_bits = 32,
>>>  + .reg_stride = 4,
>>>  + .fast_io = true,
>>>  +};
>>>  +
>>>   static int sun4i_prepare_for_irq(struct iio_dev *indio_dev, int channel,
>>>                                    unsigned int irq)
>>>   {
>>>  @@ -247,6 +271,17 @@ static int sun4i_gpadc_temp_read(struct iio_dev *indio_dev, int *val)
>>>   {
>>>           struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
>>>
>>>  + if (info->no_irq) {
>>>  + pm_runtime_get_sync(indio_dev->dev.parent);
>>>  +
>>>  + regmap_read(info->regmap, SUN4I_GPADC_TEMP_DATA, val);
>>>  +
>>>  + pm_runtime_mark_last_busy(indio_dev->dev.parent);
>>>  + pm_runtime_put_autosuspend(indio_dev->dev.parent);
>>>  +
>>>  + return 0;
>>>  + }
>>>  +
>>>           return sun4i_gpadc_read(indio_dev, 0, val, info->temp_data_irq);
>>>   }
>>>
>>>  @@ -454,6 +489,58 @@ static int sun4i_irq_init(struct platform_device *pdev, const char *name,
>>>           return 0;
>>>   }
>>>
>>>  +static const struct of_device_id sun4i_gpadc_of_id[] = {
>>>  + {
>>>  + .compatible = "allwinner,sun8i-a33-gpadc-iio",
>>>  + .data = &sun8i_a33_gpadc_data,
>>>  + },
>>>  + { /* sentinel */ }
>>>  +};
>>>  +
>>>  +static int sun4i_gpadc_probe_dt(struct platform_device *pdev,
>>>  + struct iio_dev *indio_dev)
>>>  +{
>>>  + struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
>>>  + const struct of_device_id *of_dev;
>>>  + struct thermal_zone_device *tzd;
>>>  + struct resource *mem;
>>>  + void __iomem *base;
>>>  + int ret;
>>>  +
>>>  + of_dev = of_match_device(sun4i_gpadc_of_id, &pdev->dev);
>>>  + if (!of_dev)
>>>  + return -ENODEV;
>>>  +
>>>  + info->no_irq = true;
>>>  + info->data = (struct gpadc_data *)of_dev->data;
>>>  + indio_dev->num_channels = ARRAY_SIZE(sun8i_a33_gpadc_channels);
>>>  + indio_dev->channels = sun8i_a33_gpadc_channels;
>>>  +
>>>  + mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>>>  + base = devm_ioremap_resource(&pdev->dev, mem);
>>>  + if (IS_ERR(base))
>>>  + return PTR_ERR(base);
>>>  +
>>>  + info->regmap = devm_regmap_init_mmio(&pdev->dev, base,
>>>  + &sun4i_gpadc_regmap_config);
>>>  + if (IS_ERR(info->regmap)) {
>>>  + ret = PTR_ERR(info->regmap);
>>>  + dev_err(&pdev->dev, "failed to init regmap: %d\n", ret);
>>>  + return ret;
>>>  + }
>>>  +
>>>  + if (!IS_ENABLED(THERMAL_OF))
>>>  + return 0;
>>>  +
>>>  + tzd = devm_thermal_zone_of_sensor_register(&pdev->dev, 0, info,
>>>  + &sun4i_ts_tz_ops);
>>>  + if (IS_ERR(tzd))
>>>  + dev_err(&pdev->dev, "could not register thermal sensor: %ld\n",
>>>  + PTR_ERR(tzd));
>>>  +
>>>  + return PTR_ERR_OR_ZERO(tzd);
>>>  +}
>>>  +
>>>   static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
>>>                                    struct iio_dev *indio_dev)
>>>   {
>>>  @@ -462,6 +549,7 @@ static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
>>>                   dev_get_drvdata(pdev->dev.parent);
>>>           int ret;
>>>
>>>  + info->no_irq = false;
>>>           info->regmap = sun4i_gpadc_dev->regmap;
>>>
>>>           indio_dev->num_channels = ARRAY_SIZE(sun4i_gpadc_channels);
>>>  @@ -561,7 +649,11 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>>>           indio_dev->info = &sun4i_gpadc_iio_info;
>>>           indio_dev->modes = INDIO_DIRECT_MODE;
>>>
>>>  - ret = sun4i_gpadc_probe_mfd(pdev, indio_dev);
>>>  + if (pdev->dev.of_node)
>>>  + ret = sun4i_gpadc_probe_dt(pdev, indio_dev);
>>>  + else
>>>  + ret = sun4i_gpadc_probe_mfd(pdev, indio_dev);
>>>  +
>>>           if (ret)
>>>                   return ret;
>>>
>>>  @@ -580,7 +672,7 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>>>           return 0;
>>>
>>>   err_map:
>>>  - if (IS_ENABLED(CONFIG_THERMAL_OF))
>>>  + if (!info->no_irq && IS_ENABLED(CONFIG_THERMAL_OF))
>>>                   iio_map_array_unregister(indio_dev);
>>>
>>>           pm_runtime_put(&pdev->dev);
>>>  @@ -592,10 +684,11 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>>>   static int sun4i_gpadc_remove(struct platform_device *pdev)
>>>   {
>>>           struct iio_dev *indio_dev = platform_get_drvdata(pdev);
>>>  + struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
>>>
>>>           pm_runtime_put(&pdev->dev);
>>>           pm_runtime_disable(&pdev->dev);
>>>  - if (IS_ENABLED(CONFIG_THERMAL_OF))
>>>  + if (!info->no_irq && IS_ENABLED(CONFIG_THERMAL_OF))
>>>                   iio_map_array_unregister(indio_dev);
>>>
>>>           return 0;
>>>  @@ -611,6 +704,7 @@ static const struct platform_device_id sun4i_gpadc_id[] = {
>>>   static struct platform_driver sun4i_gpadc_driver = {
>>>           .driver = {
>>>                   .name = "sun4i-gpadc-iio",
>>>  + .of_match_table = sun4i_gpadc_of_id,
>>>                   .pm = &sun4i_gpadc_pm_ops,
>>>           },
>>>           .id_table = sun4i_gpadc_id,
>>>  diff --git a/include/linux/mfd/sun4i-gpadc.h b/include/linux/mfd/sun4i-gpadc.h
>>>  index 509e736..139872c 100644
>>>  --- a/include/linux/mfd/sun4i-gpadc.h
>>>  +++ b/include/linux/mfd/sun4i-gpadc.h
>>>  @@ -38,6 +38,10 @@
>>>   #define SUN6I_GPADC_CTRL1_ADC_CHAN_SELECT(x) (GENMASK(3, 0) & BIT(x))
>>>   #define SUN6I_GPADC_CTRL1_ADC_CHAN_MASK GENMASK(3, 0)
>>>
>>>  +/* TP_CTRL1 bits for sun8i SoCs */
>>>  +#define SUN8I_GPADC_CTRL1_CHOP_TEMP_EN BIT(8)
>>>  +#define SUN8I_GPADC_CTRL1_GPADC_CALI_EN BIT(7)
>>>  +
>>>   #define SUN4I_GPADC_CTRL2 0x08
>>>
>>>   #define SUN4I_GPADC_CTRL2_TP_SENSITIVE_ADJUST(x) ((GENMASK(3, 0) & (x)) << 28)
>>
>> _______________________________________________
>> linux-arm-kernel mailing list
>> linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

-- 
Quentin Schulz, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH v2 08/11] iio: adc: sun4i-gpadc-iio: add support for A33 thermal sensor
@ 2017-03-14  7:15           ` Quentin Schulz
  0 siblings, 0 replies; 85+ messages in thread
From: Quentin Schulz @ 2017-03-14  7:15 UTC (permalink / raw)
  To: Icenowy Zheng, Jonathan Cameron, dmitry.torokhov, robh+dt,
	mark.rutland, maxime.ripard, wens, lee.jones, linux, knaack.h,
	lars, pmeerw, stefan.mavrodiev
  Cc: thomas.petazzoni, devicetree, linux-iio, linux-kernel,
	linux-sunxi, linux-arm-kernel

Hi Jonathan,

On 14/03/2017 06:18, Icenowy Zheng wrote:
> 
> 
> 14.03.2017, 05:08, "Jonathan Cameron" <jic23@kernel.org>:
>> On 10/03/17 10:39, Quentin Schulz wrote:
>>>  This adds support for the Allwinner A33 thermal sensor.
>>>
>>>  Unlike the A10, A13 and A31, the Allwinner A33 only has one channel
>>>  which is dedicated to the thermal sensor. Moreover, its thermal sensor
>>>  does not generate interruptions, thus we only need to directly read the
>>>  register storing the temperature value.
>>>
>>>  The MFD used by the A10, A13 and A31, was created to avoid breaking the
>>>  DT binding, but since the nodes for the ADC weren't there for the A33,
>>>  it is not needed.
>>>
>>>  Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
>>
>> Talk me through why it makes sense to do this rather than simply spin out
>> a really simple thermal driver for the A33?
> 
> According to him the A33 thermal sensor is a simplified version of the GPADC.
> 

Same registers with almost same bits for the same purpose (temperature).
Some SoCs have an ADC and one or more thermal sensors (A10, A13, A31,
H3) while others have only one thermal sensor (A23, A33). Same IP with
or without ADC/Touchscreen so same driver, that was my mindset.

The thermal part behaves the same except for the presence of interrupts
or not. (A33 has bits for interrupts in the datasheet but that just does
not work).

Thanks,
Quentin

> I have already did a simple thermal driver ~8 months ago, but is rejected for
> this reason.
> 
>>
>> I'm not against what you have here, but don't feel it has been fully argued.
>>
>> Jonathan
>>>  ---
>>>
>>>  v2:
>>>    - removed added comments in Kconfig,
>>>    - simplified Kconfig depends on condition,
>>>    - removed THERMAL_OF requirement for sun8i,
>>>    - renamed sun8i_gpadc_channels to sun8i_a33_gpadc_channels,
>>>    - renamed use_dt boolean in no_irq as it reflects better why we need it,
>>>    - removed spurious/unneeded modifications done in v1,
>>>
>>>   drivers/iio/adc/Kconfig | 2 +-
>>>   drivers/iio/adc/sun4i-gpadc-iio.c | 100 ++++++++++++++++++++++++++++++++++++--
>>>   include/linux/mfd/sun4i-gpadc.h | 4 ++
>>>   3 files changed, 102 insertions(+), 4 deletions(-)
>>>
>>>  diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
>>>  index 9f8b4b1..8c8ead6 100644
>>>  --- a/drivers/iio/adc/Kconfig
>>>  +++ b/drivers/iio/adc/Kconfig
>>>  @@ -562,7 +562,7 @@ config STX104
>>>   config SUN4I_GPADC
>>>           tristate "Support for the Allwinner SoCs GPADC"
>>>           depends on IIO
>>>  - depends on MFD_SUN4I_GPADC
>>>  + depends on MFD_SUN4I_GPADC || MACH_SUN8I
>>>           help
>>>             Say yes here to build support for Allwinner (A10, A13 and A31) SoCs
>>>             GPADC. This ADC provides 4 channels which can be used as an ADC or as
>>>  diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c
>>>  index 7cb997a..70684cd 100644
>>>  --- a/drivers/iio/adc/sun4i-gpadc-iio.c
>>>  +++ b/drivers/iio/adc/sun4i-gpadc-iio.c
>>>  @@ -85,6 +85,12 @@ static const struct gpadc_data sun6i_gpadc_data = {
>>>           .adc_chan_mask = SUN6I_GPADC_CTRL1_ADC_CHAN_MASK,
>>>   };
>>>
>>>  +static const struct gpadc_data sun8i_a33_gpadc_data = {
>>>  + .temp_offset = -1662,
>>>  + .temp_scale = 162,
>>>  + .tp_mode_en = SUN8I_GPADC_CTRL1_CHOP_TEMP_EN,
>>>  +};
>>>  +
>>>   struct sun4i_gpadc_iio {
>>>           struct iio_dev *indio_dev;
>>>           struct completion completion;
>>>  @@ -96,6 +102,7 @@ struct sun4i_gpadc_iio {
>>>           unsigned int temp_data_irq;
>>>           atomic_t ignore_temp_data_irq;
>>>           const struct gpadc_data *data;
>>>  + bool no_irq;
>>>           /* prevents concurrent reads of temperature and ADC */
>>>           struct mutex mutex;
>>>   };
>>>  @@ -138,6 +145,23 @@ static const struct iio_chan_spec sun4i_gpadc_channels_no_temp[] = {
>>>           SUN4I_GPADC_ADC_CHANNEL(3, "adc_chan3"),
>>>   };
>>>
>>>  +static const struct iio_chan_spec sun8i_a33_gpadc_channels[] = {
>>>  + {
>>>  + .type = IIO_TEMP,
>>>  + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
>>>  + BIT(IIO_CHAN_INFO_SCALE) |
>>>  + BIT(IIO_CHAN_INFO_OFFSET),
>>>  + .datasheet_name = "temp_adc",
>>>  + },
>>>  +};
>>>  +
>>>  +static const struct regmap_config sun4i_gpadc_regmap_config = {
>>>  + .reg_bits = 32,
>>>  + .val_bits = 32,
>>>  + .reg_stride = 4,
>>>  + .fast_io = true,
>>>  +};
>>>  +
>>>   static int sun4i_prepare_for_irq(struct iio_dev *indio_dev, int channel,
>>>                                    unsigned int irq)
>>>   {
>>>  @@ -247,6 +271,17 @@ static int sun4i_gpadc_temp_read(struct iio_dev *indio_dev, int *val)
>>>   {
>>>           struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
>>>
>>>  + if (info->no_irq) {
>>>  + pm_runtime_get_sync(indio_dev->dev.parent);
>>>  +
>>>  + regmap_read(info->regmap, SUN4I_GPADC_TEMP_DATA, val);
>>>  +
>>>  + pm_runtime_mark_last_busy(indio_dev->dev.parent);
>>>  + pm_runtime_put_autosuspend(indio_dev->dev.parent);
>>>  +
>>>  + return 0;
>>>  + }
>>>  +
>>>           return sun4i_gpadc_read(indio_dev, 0, val, info->temp_data_irq);
>>>   }
>>>
>>>  @@ -454,6 +489,58 @@ static int sun4i_irq_init(struct platform_device *pdev, const char *name,
>>>           return 0;
>>>   }
>>>
>>>  +static const struct of_device_id sun4i_gpadc_of_id[] = {
>>>  + {
>>>  + .compatible = "allwinner,sun8i-a33-gpadc-iio",
>>>  + .data = &sun8i_a33_gpadc_data,
>>>  + },
>>>  + { /* sentinel */ }
>>>  +};
>>>  +
>>>  +static int sun4i_gpadc_probe_dt(struct platform_device *pdev,
>>>  + struct iio_dev *indio_dev)
>>>  +{
>>>  + struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
>>>  + const struct of_device_id *of_dev;
>>>  + struct thermal_zone_device *tzd;
>>>  + struct resource *mem;
>>>  + void __iomem *base;
>>>  + int ret;
>>>  +
>>>  + of_dev = of_match_device(sun4i_gpadc_of_id, &pdev->dev);
>>>  + if (!of_dev)
>>>  + return -ENODEV;
>>>  +
>>>  + info->no_irq = true;
>>>  + info->data = (struct gpadc_data *)of_dev->data;
>>>  + indio_dev->num_channels = ARRAY_SIZE(sun8i_a33_gpadc_channels);
>>>  + indio_dev->channels = sun8i_a33_gpadc_channels;
>>>  +
>>>  + mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>>>  + base = devm_ioremap_resource(&pdev->dev, mem);
>>>  + if (IS_ERR(base))
>>>  + return PTR_ERR(base);
>>>  +
>>>  + info->regmap = devm_regmap_init_mmio(&pdev->dev, base,
>>>  + &sun4i_gpadc_regmap_config);
>>>  + if (IS_ERR(info->regmap)) {
>>>  + ret = PTR_ERR(info->regmap);
>>>  + dev_err(&pdev->dev, "failed to init regmap: %d\n", ret);
>>>  + return ret;
>>>  + }
>>>  +
>>>  + if (!IS_ENABLED(THERMAL_OF))
>>>  + return 0;
>>>  +
>>>  + tzd = devm_thermal_zone_of_sensor_register(&pdev->dev, 0, info,
>>>  + &sun4i_ts_tz_ops);
>>>  + if (IS_ERR(tzd))
>>>  + dev_err(&pdev->dev, "could not register thermal sensor: %ld\n",
>>>  + PTR_ERR(tzd));
>>>  +
>>>  + return PTR_ERR_OR_ZERO(tzd);
>>>  +}
>>>  +
>>>   static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
>>>                                    struct iio_dev *indio_dev)
>>>   {
>>>  @@ -462,6 +549,7 @@ static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
>>>                   dev_get_drvdata(pdev->dev.parent);
>>>           int ret;
>>>
>>>  + info->no_irq = false;
>>>           info->regmap = sun4i_gpadc_dev->regmap;
>>>
>>>           indio_dev->num_channels = ARRAY_SIZE(sun4i_gpadc_channels);
>>>  @@ -561,7 +649,11 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>>>           indio_dev->info = &sun4i_gpadc_iio_info;
>>>           indio_dev->modes = INDIO_DIRECT_MODE;
>>>
>>>  - ret = sun4i_gpadc_probe_mfd(pdev, indio_dev);
>>>  + if (pdev->dev.of_node)
>>>  + ret = sun4i_gpadc_probe_dt(pdev, indio_dev);
>>>  + else
>>>  + ret = sun4i_gpadc_probe_mfd(pdev, indio_dev);
>>>  +
>>>           if (ret)
>>>                   return ret;
>>>
>>>  @@ -580,7 +672,7 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>>>           return 0;
>>>
>>>   err_map:
>>>  - if (IS_ENABLED(CONFIG_THERMAL_OF))
>>>  + if (!info->no_irq && IS_ENABLED(CONFIG_THERMAL_OF))
>>>                   iio_map_array_unregister(indio_dev);
>>>
>>>           pm_runtime_put(&pdev->dev);
>>>  @@ -592,10 +684,11 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>>>   static int sun4i_gpadc_remove(struct platform_device *pdev)
>>>   {
>>>           struct iio_dev *indio_dev = platform_get_drvdata(pdev);
>>>  + struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
>>>
>>>           pm_runtime_put(&pdev->dev);
>>>           pm_runtime_disable(&pdev->dev);
>>>  - if (IS_ENABLED(CONFIG_THERMAL_OF))
>>>  + if (!info->no_irq && IS_ENABLED(CONFIG_THERMAL_OF))
>>>                   iio_map_array_unregister(indio_dev);
>>>
>>>           return 0;
>>>  @@ -611,6 +704,7 @@ static const struct platform_device_id sun4i_gpadc_id[] = {
>>>   static struct platform_driver sun4i_gpadc_driver = {
>>>           .driver = {
>>>                   .name = "sun4i-gpadc-iio",
>>>  + .of_match_table = sun4i_gpadc_of_id,
>>>                   .pm = &sun4i_gpadc_pm_ops,
>>>           },
>>>           .id_table = sun4i_gpadc_id,
>>>  diff --git a/include/linux/mfd/sun4i-gpadc.h b/include/linux/mfd/sun4i-gpadc.h
>>>  index 509e736..139872c 100644
>>>  --- a/include/linux/mfd/sun4i-gpadc.h
>>>  +++ b/include/linux/mfd/sun4i-gpadc.h
>>>  @@ -38,6 +38,10 @@
>>>   #define SUN6I_GPADC_CTRL1_ADC_CHAN_SELECT(x) (GENMASK(3, 0) & BIT(x))
>>>   #define SUN6I_GPADC_CTRL1_ADC_CHAN_MASK GENMASK(3, 0)
>>>
>>>  +/* TP_CTRL1 bits for sun8i SoCs */
>>>  +#define SUN8I_GPADC_CTRL1_CHOP_TEMP_EN BIT(8)
>>>  +#define SUN8I_GPADC_CTRL1_GPADC_CALI_EN BIT(7)
>>>  +
>>>   #define SUN4I_GPADC_CTRL2 0x08
>>>
>>>   #define SUN4I_GPADC_CTRL2_TP_SENSITIVE_ADJUST(x) ((GENMASK(3, 0) & (x)) << 28)
>>
>> _______________________________________________
>> linux-arm-kernel mailing list
>> linux-arm-kernel@lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

-- 
Quentin Schulz, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 85+ messages in thread

* [PATCH v2 08/11] iio: adc: sun4i-gpadc-iio: add support for A33 thermal sensor
@ 2017-03-14  7:15           ` Quentin Schulz
  0 siblings, 0 replies; 85+ messages in thread
From: Quentin Schulz @ 2017-03-14  7:15 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Jonathan,

On 14/03/2017 06:18, Icenowy Zheng wrote:
> 
> 
> 14.03.2017, 05:08, "Jonathan Cameron" <jic23@kernel.org>:
>> On 10/03/17 10:39, Quentin Schulz wrote:
>>>  This adds support for the Allwinner A33 thermal sensor.
>>>
>>>  Unlike the A10, A13 and A31, the Allwinner A33 only has one channel
>>>  which is dedicated to the thermal sensor. Moreover, its thermal sensor
>>>  does not generate interruptions, thus we only need to directly read the
>>>  register storing the temperature value.
>>>
>>>  The MFD used by the A10, A13 and A31, was created to avoid breaking the
>>>  DT binding, but since the nodes for the ADC weren't there for the A33,
>>>  it is not needed.
>>>
>>>  Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
>>
>> Talk me through why it makes sense to do this rather than simply spin out
>> a really simple thermal driver for the A33?
> 
> According to him the A33 thermal sensor is a simplified version of the GPADC.
> 

Same registers with almost same bits for the same purpose (temperature).
Some SoCs have an ADC and one or more thermal sensors (A10, A13, A31,
H3) while others have only one thermal sensor (A23, A33). Same IP with
or without ADC/Touchscreen so same driver, that was my mindset.

The thermal part behaves the same except for the presence of interrupts
or not. (A33 has bits for interrupts in the datasheet but that just does
not work).

Thanks,
Quentin

> I have already did a simple thermal driver ~8 months ago, but is rejected for
> this reason.
> 
>>
>> I'm not against what you have here, but don't feel it has been fully argued.
>>
>> Jonathan
>>>  ---
>>>
>>>  v2:
>>>    - removed added comments in Kconfig,
>>>    - simplified Kconfig depends on condition,
>>>    - removed THERMAL_OF requirement for sun8i,
>>>    - renamed sun8i_gpadc_channels to sun8i_a33_gpadc_channels,
>>>    - renamed use_dt boolean in no_irq as it reflects better why we need it,
>>>    - removed spurious/unneeded modifications done in v1,
>>>
>>>   drivers/iio/adc/Kconfig | 2 +-
>>>   drivers/iio/adc/sun4i-gpadc-iio.c | 100 ++++++++++++++++++++++++++++++++++++--
>>>   include/linux/mfd/sun4i-gpadc.h | 4 ++
>>>   3 files changed, 102 insertions(+), 4 deletions(-)
>>>
>>>  diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
>>>  index 9f8b4b1..8c8ead6 100644
>>>  --- a/drivers/iio/adc/Kconfig
>>>  +++ b/drivers/iio/adc/Kconfig
>>>  @@ -562,7 +562,7 @@ config STX104
>>>   config SUN4I_GPADC
>>>           tristate "Support for the Allwinner SoCs GPADC"
>>>           depends on IIO
>>>  - depends on MFD_SUN4I_GPADC
>>>  + depends on MFD_SUN4I_GPADC || MACH_SUN8I
>>>           help
>>>             Say yes here to build support for Allwinner (A10, A13 and A31) SoCs
>>>             GPADC. This ADC provides 4 channels which can be used as an ADC or as
>>>  diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c
>>>  index 7cb997a..70684cd 100644
>>>  --- a/drivers/iio/adc/sun4i-gpadc-iio.c
>>>  +++ b/drivers/iio/adc/sun4i-gpadc-iio.c
>>>  @@ -85,6 +85,12 @@ static const struct gpadc_data sun6i_gpadc_data = {
>>>           .adc_chan_mask = SUN6I_GPADC_CTRL1_ADC_CHAN_MASK,
>>>   };
>>>
>>>  +static const struct gpadc_data sun8i_a33_gpadc_data = {
>>>  + .temp_offset = -1662,
>>>  + .temp_scale = 162,
>>>  + .tp_mode_en = SUN8I_GPADC_CTRL1_CHOP_TEMP_EN,
>>>  +};
>>>  +
>>>   struct sun4i_gpadc_iio {
>>>           struct iio_dev *indio_dev;
>>>           struct completion completion;
>>>  @@ -96,6 +102,7 @@ struct sun4i_gpadc_iio {
>>>           unsigned int temp_data_irq;
>>>           atomic_t ignore_temp_data_irq;
>>>           const struct gpadc_data *data;
>>>  + bool no_irq;
>>>           /* prevents concurrent reads of temperature and ADC */
>>>           struct mutex mutex;
>>>   };
>>>  @@ -138,6 +145,23 @@ static const struct iio_chan_spec sun4i_gpadc_channels_no_temp[] = {
>>>           SUN4I_GPADC_ADC_CHANNEL(3, "adc_chan3"),
>>>   };
>>>
>>>  +static const struct iio_chan_spec sun8i_a33_gpadc_channels[] = {
>>>  + {
>>>  + .type = IIO_TEMP,
>>>  + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
>>>  + BIT(IIO_CHAN_INFO_SCALE) |
>>>  + BIT(IIO_CHAN_INFO_OFFSET),
>>>  + .datasheet_name = "temp_adc",
>>>  + },
>>>  +};
>>>  +
>>>  +static const struct regmap_config sun4i_gpadc_regmap_config = {
>>>  + .reg_bits = 32,
>>>  + .val_bits = 32,
>>>  + .reg_stride = 4,
>>>  + .fast_io = true,
>>>  +};
>>>  +
>>>   static int sun4i_prepare_for_irq(struct iio_dev *indio_dev, int channel,
>>>                                    unsigned int irq)
>>>   {
>>>  @@ -247,6 +271,17 @@ static int sun4i_gpadc_temp_read(struct iio_dev *indio_dev, int *val)
>>>   {
>>>           struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
>>>
>>>  + if (info->no_irq) {
>>>  + pm_runtime_get_sync(indio_dev->dev.parent);
>>>  +
>>>  + regmap_read(info->regmap, SUN4I_GPADC_TEMP_DATA, val);
>>>  +
>>>  + pm_runtime_mark_last_busy(indio_dev->dev.parent);
>>>  + pm_runtime_put_autosuspend(indio_dev->dev.parent);
>>>  +
>>>  + return 0;
>>>  + }
>>>  +
>>>           return sun4i_gpadc_read(indio_dev, 0, val, info->temp_data_irq);
>>>   }
>>>
>>>  @@ -454,6 +489,58 @@ static int sun4i_irq_init(struct platform_device *pdev, const char *name,
>>>           return 0;
>>>   }
>>>
>>>  +static const struct of_device_id sun4i_gpadc_of_id[] = {
>>>  + {
>>>  + .compatible = "allwinner,sun8i-a33-gpadc-iio",
>>>  + .data = &sun8i_a33_gpadc_data,
>>>  + },
>>>  + { /* sentinel */ }
>>>  +};
>>>  +
>>>  +static int sun4i_gpadc_probe_dt(struct platform_device *pdev,
>>>  + struct iio_dev *indio_dev)
>>>  +{
>>>  + struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
>>>  + const struct of_device_id *of_dev;
>>>  + struct thermal_zone_device *tzd;
>>>  + struct resource *mem;
>>>  + void __iomem *base;
>>>  + int ret;
>>>  +
>>>  + of_dev = of_match_device(sun4i_gpadc_of_id, &pdev->dev);
>>>  + if (!of_dev)
>>>  + return -ENODEV;
>>>  +
>>>  + info->no_irq = true;
>>>  + info->data = (struct gpadc_data *)of_dev->data;
>>>  + indio_dev->num_channels = ARRAY_SIZE(sun8i_a33_gpadc_channels);
>>>  + indio_dev->channels = sun8i_a33_gpadc_channels;
>>>  +
>>>  + mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>>>  + base = devm_ioremap_resource(&pdev->dev, mem);
>>>  + if (IS_ERR(base))
>>>  + return PTR_ERR(base);
>>>  +
>>>  + info->regmap = devm_regmap_init_mmio(&pdev->dev, base,
>>>  + &sun4i_gpadc_regmap_config);
>>>  + if (IS_ERR(info->regmap)) {
>>>  + ret = PTR_ERR(info->regmap);
>>>  + dev_err(&pdev->dev, "failed to init regmap: %d\n", ret);
>>>  + return ret;
>>>  + }
>>>  +
>>>  + if (!IS_ENABLED(THERMAL_OF))
>>>  + return 0;
>>>  +
>>>  + tzd = devm_thermal_zone_of_sensor_register(&pdev->dev, 0, info,
>>>  + &sun4i_ts_tz_ops);
>>>  + if (IS_ERR(tzd))
>>>  + dev_err(&pdev->dev, "could not register thermal sensor: %ld\n",
>>>  + PTR_ERR(tzd));
>>>  +
>>>  + return PTR_ERR_OR_ZERO(tzd);
>>>  +}
>>>  +
>>>   static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
>>>                                    struct iio_dev *indio_dev)
>>>   {
>>>  @@ -462,6 +549,7 @@ static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
>>>                   dev_get_drvdata(pdev->dev.parent);
>>>           int ret;
>>>
>>>  + info->no_irq = false;
>>>           info->regmap = sun4i_gpadc_dev->regmap;
>>>
>>>           indio_dev->num_channels = ARRAY_SIZE(sun4i_gpadc_channels);
>>>  @@ -561,7 +649,11 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>>>           indio_dev->info = &sun4i_gpadc_iio_info;
>>>           indio_dev->modes = INDIO_DIRECT_MODE;
>>>
>>>  - ret = sun4i_gpadc_probe_mfd(pdev, indio_dev);
>>>  + if (pdev->dev.of_node)
>>>  + ret = sun4i_gpadc_probe_dt(pdev, indio_dev);
>>>  + else
>>>  + ret = sun4i_gpadc_probe_mfd(pdev, indio_dev);
>>>  +
>>>           if (ret)
>>>                   return ret;
>>>
>>>  @@ -580,7 +672,7 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>>>           return 0;
>>>
>>>   err_map:
>>>  - if (IS_ENABLED(CONFIG_THERMAL_OF))
>>>  + if (!info->no_irq && IS_ENABLED(CONFIG_THERMAL_OF))
>>>                   iio_map_array_unregister(indio_dev);
>>>
>>>           pm_runtime_put(&pdev->dev);
>>>  @@ -592,10 +684,11 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>>>   static int sun4i_gpadc_remove(struct platform_device *pdev)
>>>   {
>>>           struct iio_dev *indio_dev = platform_get_drvdata(pdev);
>>>  + struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
>>>
>>>           pm_runtime_put(&pdev->dev);
>>>           pm_runtime_disable(&pdev->dev);
>>>  - if (IS_ENABLED(CONFIG_THERMAL_OF))
>>>  + if (!info->no_irq && IS_ENABLED(CONFIG_THERMAL_OF))
>>>                   iio_map_array_unregister(indio_dev);
>>>
>>>           return 0;
>>>  @@ -611,6 +704,7 @@ static const struct platform_device_id sun4i_gpadc_id[] = {
>>>   static struct platform_driver sun4i_gpadc_driver = {
>>>           .driver = {
>>>                   .name = "sun4i-gpadc-iio",
>>>  + .of_match_table = sun4i_gpadc_of_id,
>>>                   .pm = &sun4i_gpadc_pm_ops,
>>>           },
>>>           .id_table = sun4i_gpadc_id,
>>>  diff --git a/include/linux/mfd/sun4i-gpadc.h b/include/linux/mfd/sun4i-gpadc.h
>>>  index 509e736..139872c 100644
>>>  --- a/include/linux/mfd/sun4i-gpadc.h
>>>  +++ b/include/linux/mfd/sun4i-gpadc.h
>>>  @@ -38,6 +38,10 @@
>>>   #define SUN6I_GPADC_CTRL1_ADC_CHAN_SELECT(x) (GENMASK(3, 0) & BIT(x))
>>>   #define SUN6I_GPADC_CTRL1_ADC_CHAN_MASK GENMASK(3, 0)
>>>
>>>  +/* TP_CTRL1 bits for sun8i SoCs */
>>>  +#define SUN8I_GPADC_CTRL1_CHOP_TEMP_EN BIT(8)
>>>  +#define SUN8I_GPADC_CTRL1_GPADC_CALI_EN BIT(7)
>>>  +
>>>   #define SUN4I_GPADC_CTRL2 0x08
>>>
>>>   #define SUN4I_GPADC_CTRL2_TP_SENSITIVE_ADJUST(x) ((GENMASK(3, 0) & (x)) << 28)
>>
>> _______________________________________________
>> linux-arm-kernel mailing list
>> linux-arm-kernel at lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

-- 
Quentin Schulz, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH v2 08/11] iio: adc: sun4i-gpadc-iio: add support for A33 thermal sensor
@ 2017-03-15 10:38     ` Lee Jones
  0 siblings, 0 replies; 85+ messages in thread
From: Lee Jones @ 2017-03-15 10:38 UTC (permalink / raw)
  To: Quentin Schulz
  Cc: dmitry.torokhov, robh+dt, mark.rutland, maxime.ripard, wens,
	linux, jic23, knaack.h, lars, pmeerw, stefan.mavrodiev,
	devicetree, linux-arm-kernel, linux-kernel, linux-iio,
	linux-sunxi, thomas.petazzoni

On Fri, 10 Mar 2017, Quentin Schulz wrote:

> This adds support for the Allwinner A33 thermal sensor.
> 
> Unlike the A10, A13 and A31, the Allwinner A33 only has one channel
> which is dedicated to the thermal sensor. Moreover, its thermal sensor
> does not generate interruptions, thus we only need to directly read the
> register storing the temperature value.
> 
> The MFD used by the A10, A13 and A31, was created to avoid breaking the
> DT binding, but since the nodes for the ADC weren't there for the A33,
> it is not needed.
> 
> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
> ---
> 
> v2:
>   - removed added comments in Kconfig,
>   - simplified Kconfig depends on condition,
>   - removed THERMAL_OF requirement for sun8i,
>   - renamed sun8i_gpadc_channels to sun8i_a33_gpadc_channels,
>   - renamed use_dt boolean in no_irq as it reflects better why we need it,
>   - removed spurious/unneeded modifications done in v1,
> 
>  drivers/iio/adc/Kconfig           |   2 +-
>  drivers/iio/adc/sun4i-gpadc-iio.c | 100 ++++++++++++++++++++++++++++++++++++--

>  include/linux/mfd/sun4i-gpadc.h   |   4 ++

For the MFD parts only:
  Acked-by: Lee Jones <lee.jones@linaro.org>

>  3 files changed, 102 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
> index 9f8b4b1..8c8ead6 100644
> --- a/drivers/iio/adc/Kconfig
> +++ b/drivers/iio/adc/Kconfig
> @@ -562,7 +562,7 @@ config STX104
>  config SUN4I_GPADC
>  	tristate "Support for the Allwinner SoCs GPADC"
>  	depends on IIO
> -	depends on MFD_SUN4I_GPADC
> +	depends on MFD_SUN4I_GPADC || MACH_SUN8I
>  	help
>  	  Say yes here to build support for Allwinner (A10, A13 and A31) SoCs
>  	  GPADC. This ADC provides 4 channels which can be used as an ADC or as
> diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c
> index 7cb997a..70684cd 100644
> --- a/drivers/iio/adc/sun4i-gpadc-iio.c
> +++ b/drivers/iio/adc/sun4i-gpadc-iio.c
> @@ -85,6 +85,12 @@ static const struct gpadc_data sun6i_gpadc_data = {
>  	.adc_chan_mask = SUN6I_GPADC_CTRL1_ADC_CHAN_MASK,
>  };
>  
> +static const struct gpadc_data sun8i_a33_gpadc_data = {
> +	.temp_offset = -1662,
> +	.temp_scale = 162,
> +	.tp_mode_en = SUN8I_GPADC_CTRL1_CHOP_TEMP_EN,
> +};
> +
>  struct sun4i_gpadc_iio {
>  	struct iio_dev			*indio_dev;
>  	struct completion		completion;
> @@ -96,6 +102,7 @@ struct sun4i_gpadc_iio {
>  	unsigned int			temp_data_irq;
>  	atomic_t			ignore_temp_data_irq;
>  	const struct gpadc_data		*data;
> +	bool				no_irq;
>  	/* prevents concurrent reads of temperature and ADC */
>  	struct mutex			mutex;
>  };
> @@ -138,6 +145,23 @@ static const struct iio_chan_spec sun4i_gpadc_channels_no_temp[] = {
>  	SUN4I_GPADC_ADC_CHANNEL(3, "adc_chan3"),
>  };
>  
> +static const struct iio_chan_spec sun8i_a33_gpadc_channels[] = {
> +	{
> +		.type = IIO_TEMP,
> +		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
> +				      BIT(IIO_CHAN_INFO_SCALE) |
> +				      BIT(IIO_CHAN_INFO_OFFSET),
> +		.datasheet_name = "temp_adc",
> +	},
> +};
> +
> +static const struct regmap_config sun4i_gpadc_regmap_config = {
> +	.reg_bits = 32,
> +	.val_bits = 32,
> +	.reg_stride = 4,
> +	.fast_io = true,
> +};
> +
>  static int sun4i_prepare_for_irq(struct iio_dev *indio_dev, int channel,
>  				 unsigned int irq)
>  {
> @@ -247,6 +271,17 @@ static int sun4i_gpadc_temp_read(struct iio_dev *indio_dev, int *val)
>  {
>  	struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
>  
> +	if (info->no_irq) {
> +		pm_runtime_get_sync(indio_dev->dev.parent);
> +
> +		regmap_read(info->regmap, SUN4I_GPADC_TEMP_DATA, val);
> +
> +		pm_runtime_mark_last_busy(indio_dev->dev.parent);
> +		pm_runtime_put_autosuspend(indio_dev->dev.parent);
> +
> +		return 0;
> +	}
> +
>  	return sun4i_gpadc_read(indio_dev, 0, val, info->temp_data_irq);
>  }
>  
> @@ -454,6 +489,58 @@ static int sun4i_irq_init(struct platform_device *pdev, const char *name,
>  	return 0;
>  }
>  
> +static const struct of_device_id sun4i_gpadc_of_id[] = {
> +	{
> +		.compatible = "allwinner,sun8i-a33-gpadc-iio",
> +		.data = &sun8i_a33_gpadc_data,
> +	},
> +	{ /* sentinel */ }
> +};
> +
> +static int sun4i_gpadc_probe_dt(struct platform_device *pdev,
> +				struct iio_dev *indio_dev)
> +{
> +	struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
> +	const struct of_device_id *of_dev;
> +	struct thermal_zone_device *tzd;
> +	struct resource *mem;
> +	void __iomem *base;
> +	int ret;
> +
> +	of_dev = of_match_device(sun4i_gpadc_of_id, &pdev->dev);
> +	if (!of_dev)
> +		return -ENODEV;
> +
> +	info->no_irq = true;
> +	info->data = (struct gpadc_data *)of_dev->data;
> +	indio_dev->num_channels = ARRAY_SIZE(sun8i_a33_gpadc_channels);
> +	indio_dev->channels = sun8i_a33_gpadc_channels;
> +
> +	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	base = devm_ioremap_resource(&pdev->dev, mem);
> +	if (IS_ERR(base))
> +		return PTR_ERR(base);
> +
> +	info->regmap = devm_regmap_init_mmio(&pdev->dev, base,
> +					     &sun4i_gpadc_regmap_config);
> +	if (IS_ERR(info->regmap)) {
> +		ret = PTR_ERR(info->regmap);
> +		dev_err(&pdev->dev, "failed to init regmap: %d\n", ret);
> +		return ret;
> +	}
> +
> +	if (!IS_ENABLED(THERMAL_OF))
> +		return 0;
> +
> +	tzd = devm_thermal_zone_of_sensor_register(&pdev->dev, 0, info,
> +						   &sun4i_ts_tz_ops);
> +	if (IS_ERR(tzd))
> +		dev_err(&pdev->dev, "could not register thermal sensor: %ld\n",
> +			PTR_ERR(tzd));
> +
> +	return PTR_ERR_OR_ZERO(tzd);
> +}
> +
>  static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
>  				 struct iio_dev *indio_dev)
>  {
> @@ -462,6 +549,7 @@ static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
>  		dev_get_drvdata(pdev->dev.parent);
>  	int ret;
>  
> +	info->no_irq = false;
>  	info->regmap = sun4i_gpadc_dev->regmap;
>  
>  	indio_dev->num_channels = ARRAY_SIZE(sun4i_gpadc_channels);
> @@ -561,7 +649,11 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>  	indio_dev->info = &sun4i_gpadc_iio_info;
>  	indio_dev->modes = INDIO_DIRECT_MODE;
>  
> -	ret = sun4i_gpadc_probe_mfd(pdev, indio_dev);
> +	if (pdev->dev.of_node)
> +		ret = sun4i_gpadc_probe_dt(pdev, indio_dev);
> +	else
> +		ret = sun4i_gpadc_probe_mfd(pdev, indio_dev);
> +
>  	if (ret)
>  		return ret;
>  
> @@ -580,7 +672,7 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>  	return 0;
>  
>  err_map:
> -	if (IS_ENABLED(CONFIG_THERMAL_OF))
> +	if (!info->no_irq && IS_ENABLED(CONFIG_THERMAL_OF))
>  		iio_map_array_unregister(indio_dev);
>  
>  	pm_runtime_put(&pdev->dev);
> @@ -592,10 +684,11 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>  static int sun4i_gpadc_remove(struct platform_device *pdev)
>  {
>  	struct iio_dev *indio_dev = platform_get_drvdata(pdev);
> +	struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
>  
>  	pm_runtime_put(&pdev->dev);
>  	pm_runtime_disable(&pdev->dev);
> -	if (IS_ENABLED(CONFIG_THERMAL_OF))
> +	if (!info->no_irq && IS_ENABLED(CONFIG_THERMAL_OF))
>  		iio_map_array_unregister(indio_dev);
>  
>  	return 0;
> @@ -611,6 +704,7 @@ static const struct platform_device_id sun4i_gpadc_id[] = {
>  static struct platform_driver sun4i_gpadc_driver = {
>  	.driver = {
>  		.name = "sun4i-gpadc-iio",
> +		.of_match_table = sun4i_gpadc_of_id,
>  		.pm = &sun4i_gpadc_pm_ops,
>  	},
>  	.id_table = sun4i_gpadc_id,
> diff --git a/include/linux/mfd/sun4i-gpadc.h b/include/linux/mfd/sun4i-gpadc.h
> index 509e736..139872c 100644
> --- a/include/linux/mfd/sun4i-gpadc.h
> +++ b/include/linux/mfd/sun4i-gpadc.h
> @@ -38,6 +38,10 @@
>  #define SUN6I_GPADC_CTRL1_ADC_CHAN_SELECT(x)		(GENMASK(3, 0) & BIT(x))
>  #define SUN6I_GPADC_CTRL1_ADC_CHAN_MASK			GENMASK(3, 0)
>  
> +/* TP_CTRL1 bits for sun8i SoCs */
> +#define SUN8I_GPADC_CTRL1_CHOP_TEMP_EN			BIT(8)
> +#define SUN8I_GPADC_CTRL1_GPADC_CALI_EN			BIT(7)
> +
>  #define SUN4I_GPADC_CTRL2				0x08
>  
>  #define SUN4I_GPADC_CTRL2_TP_SENSITIVE_ADJUST(x)	((GENMASK(3, 0) & (x)) << 28)

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH v2 08/11] iio: adc: sun4i-gpadc-iio: add support for A33 thermal sensor
@ 2017-03-15 10:38     ` Lee Jones
  0 siblings, 0 replies; 85+ messages in thread
From: Lee Jones @ 2017-03-15 10:38 UTC (permalink / raw)
  To: Quentin Schulz
  Cc: dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8, wens-jdAy2FN1RRM,
	linux-I+IVW8TIWO2tmTQ+vhA3Yw, jic23-DgEjT+Ai2ygdnm+yROfE0A,
	knaack.h-Mmb7MZpHnFY, lars-Qo5EllUWu/uELgA04lAiVw,
	pmeerw-jW+XmwGofnusTnJN9+BGXg,
	stefan.mavrodiev-Re5JQEeQqe8AvxtiuMwx3w,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-iio-u79uwXL29TY76Z2rM5mHXA,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
	thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8

On Fri, 10 Mar 2017, Quentin Schulz wrote:

> This adds support for the Allwinner A33 thermal sensor.
> 
> Unlike the A10, A13 and A31, the Allwinner A33 only has one channel
> which is dedicated to the thermal sensor. Moreover, its thermal sensor
> does not generate interruptions, thus we only need to directly read the
> register storing the temperature value.
> 
> The MFD used by the A10, A13 and A31, was created to avoid breaking the
> DT binding, but since the nodes for the ADC weren't there for the A33,
> it is not needed.
> 
> Signed-off-by: Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> ---
> 
> v2:
>   - removed added comments in Kconfig,
>   - simplified Kconfig depends on condition,
>   - removed THERMAL_OF requirement for sun8i,
>   - renamed sun8i_gpadc_channels to sun8i_a33_gpadc_channels,
>   - renamed use_dt boolean in no_irq as it reflects better why we need it,
>   - removed spurious/unneeded modifications done in v1,
> 
>  drivers/iio/adc/Kconfig           |   2 +-
>  drivers/iio/adc/sun4i-gpadc-iio.c | 100 ++++++++++++++++++++++++++++++++++++--

>  include/linux/mfd/sun4i-gpadc.h   |   4 ++

For the MFD parts only:
  Acked-by: Lee Jones <lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>

>  3 files changed, 102 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
> index 9f8b4b1..8c8ead6 100644
> --- a/drivers/iio/adc/Kconfig
> +++ b/drivers/iio/adc/Kconfig
> @@ -562,7 +562,7 @@ config STX104
>  config SUN4I_GPADC
>  	tristate "Support for the Allwinner SoCs GPADC"
>  	depends on IIO
> -	depends on MFD_SUN4I_GPADC
> +	depends on MFD_SUN4I_GPADC || MACH_SUN8I
>  	help
>  	  Say yes here to build support for Allwinner (A10, A13 and A31) SoCs
>  	  GPADC. This ADC provides 4 channels which can be used as an ADC or as
> diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c
> index 7cb997a..70684cd 100644
> --- a/drivers/iio/adc/sun4i-gpadc-iio.c
> +++ b/drivers/iio/adc/sun4i-gpadc-iio.c
> @@ -85,6 +85,12 @@ static const struct gpadc_data sun6i_gpadc_data = {
>  	.adc_chan_mask = SUN6I_GPADC_CTRL1_ADC_CHAN_MASK,
>  };
>  
> +static const struct gpadc_data sun8i_a33_gpadc_data = {
> +	.temp_offset = -1662,
> +	.temp_scale = 162,
> +	.tp_mode_en = SUN8I_GPADC_CTRL1_CHOP_TEMP_EN,
> +};
> +
>  struct sun4i_gpadc_iio {
>  	struct iio_dev			*indio_dev;
>  	struct completion		completion;
> @@ -96,6 +102,7 @@ struct sun4i_gpadc_iio {
>  	unsigned int			temp_data_irq;
>  	atomic_t			ignore_temp_data_irq;
>  	const struct gpadc_data		*data;
> +	bool				no_irq;
>  	/* prevents concurrent reads of temperature and ADC */
>  	struct mutex			mutex;
>  };
> @@ -138,6 +145,23 @@ static const struct iio_chan_spec sun4i_gpadc_channels_no_temp[] = {
>  	SUN4I_GPADC_ADC_CHANNEL(3, "adc_chan3"),
>  };
>  
> +static const struct iio_chan_spec sun8i_a33_gpadc_channels[] = {
> +	{
> +		.type = IIO_TEMP,
> +		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
> +				      BIT(IIO_CHAN_INFO_SCALE) |
> +				      BIT(IIO_CHAN_INFO_OFFSET),
> +		.datasheet_name = "temp_adc",
> +	},
> +};
> +
> +static const struct regmap_config sun4i_gpadc_regmap_config = {
> +	.reg_bits = 32,
> +	.val_bits = 32,
> +	.reg_stride = 4,
> +	.fast_io = true,
> +};
> +
>  static int sun4i_prepare_for_irq(struct iio_dev *indio_dev, int channel,
>  				 unsigned int irq)
>  {
> @@ -247,6 +271,17 @@ static int sun4i_gpadc_temp_read(struct iio_dev *indio_dev, int *val)
>  {
>  	struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
>  
> +	if (info->no_irq) {
> +		pm_runtime_get_sync(indio_dev->dev.parent);
> +
> +		regmap_read(info->regmap, SUN4I_GPADC_TEMP_DATA, val);
> +
> +		pm_runtime_mark_last_busy(indio_dev->dev.parent);
> +		pm_runtime_put_autosuspend(indio_dev->dev.parent);
> +
> +		return 0;
> +	}
> +
>  	return sun4i_gpadc_read(indio_dev, 0, val, info->temp_data_irq);
>  }
>  
> @@ -454,6 +489,58 @@ static int sun4i_irq_init(struct platform_device *pdev, const char *name,
>  	return 0;
>  }
>  
> +static const struct of_device_id sun4i_gpadc_of_id[] = {
> +	{
> +		.compatible = "allwinner,sun8i-a33-gpadc-iio",
> +		.data = &sun8i_a33_gpadc_data,
> +	},
> +	{ /* sentinel */ }
> +};
> +
> +static int sun4i_gpadc_probe_dt(struct platform_device *pdev,
> +				struct iio_dev *indio_dev)
> +{
> +	struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
> +	const struct of_device_id *of_dev;
> +	struct thermal_zone_device *tzd;
> +	struct resource *mem;
> +	void __iomem *base;
> +	int ret;
> +
> +	of_dev = of_match_device(sun4i_gpadc_of_id, &pdev->dev);
> +	if (!of_dev)
> +		return -ENODEV;
> +
> +	info->no_irq = true;
> +	info->data = (struct gpadc_data *)of_dev->data;
> +	indio_dev->num_channels = ARRAY_SIZE(sun8i_a33_gpadc_channels);
> +	indio_dev->channels = sun8i_a33_gpadc_channels;
> +
> +	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	base = devm_ioremap_resource(&pdev->dev, mem);
> +	if (IS_ERR(base))
> +		return PTR_ERR(base);
> +
> +	info->regmap = devm_regmap_init_mmio(&pdev->dev, base,
> +					     &sun4i_gpadc_regmap_config);
> +	if (IS_ERR(info->regmap)) {
> +		ret = PTR_ERR(info->regmap);
> +		dev_err(&pdev->dev, "failed to init regmap: %d\n", ret);
> +		return ret;
> +	}
> +
> +	if (!IS_ENABLED(THERMAL_OF))
> +		return 0;
> +
> +	tzd = devm_thermal_zone_of_sensor_register(&pdev->dev, 0, info,
> +						   &sun4i_ts_tz_ops);
> +	if (IS_ERR(tzd))
> +		dev_err(&pdev->dev, "could not register thermal sensor: %ld\n",
> +			PTR_ERR(tzd));
> +
> +	return PTR_ERR_OR_ZERO(tzd);
> +}
> +
>  static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
>  				 struct iio_dev *indio_dev)
>  {
> @@ -462,6 +549,7 @@ static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
>  		dev_get_drvdata(pdev->dev.parent);
>  	int ret;
>  
> +	info->no_irq = false;
>  	info->regmap = sun4i_gpadc_dev->regmap;
>  
>  	indio_dev->num_channels = ARRAY_SIZE(sun4i_gpadc_channels);
> @@ -561,7 +649,11 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>  	indio_dev->info = &sun4i_gpadc_iio_info;
>  	indio_dev->modes = INDIO_DIRECT_MODE;
>  
> -	ret = sun4i_gpadc_probe_mfd(pdev, indio_dev);
> +	if (pdev->dev.of_node)
> +		ret = sun4i_gpadc_probe_dt(pdev, indio_dev);
> +	else
> +		ret = sun4i_gpadc_probe_mfd(pdev, indio_dev);
> +
>  	if (ret)
>  		return ret;
>  
> @@ -580,7 +672,7 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>  	return 0;
>  
>  err_map:
> -	if (IS_ENABLED(CONFIG_THERMAL_OF))
> +	if (!info->no_irq && IS_ENABLED(CONFIG_THERMAL_OF))
>  		iio_map_array_unregister(indio_dev);
>  
>  	pm_runtime_put(&pdev->dev);
> @@ -592,10 +684,11 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>  static int sun4i_gpadc_remove(struct platform_device *pdev)
>  {
>  	struct iio_dev *indio_dev = platform_get_drvdata(pdev);
> +	struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
>  
>  	pm_runtime_put(&pdev->dev);
>  	pm_runtime_disable(&pdev->dev);
> -	if (IS_ENABLED(CONFIG_THERMAL_OF))
> +	if (!info->no_irq && IS_ENABLED(CONFIG_THERMAL_OF))
>  		iio_map_array_unregister(indio_dev);
>  
>  	return 0;
> @@ -611,6 +704,7 @@ static const struct platform_device_id sun4i_gpadc_id[] = {
>  static struct platform_driver sun4i_gpadc_driver = {
>  	.driver = {
>  		.name = "sun4i-gpadc-iio",
> +		.of_match_table = sun4i_gpadc_of_id,
>  		.pm = &sun4i_gpadc_pm_ops,
>  	},
>  	.id_table = sun4i_gpadc_id,
> diff --git a/include/linux/mfd/sun4i-gpadc.h b/include/linux/mfd/sun4i-gpadc.h
> index 509e736..139872c 100644
> --- a/include/linux/mfd/sun4i-gpadc.h
> +++ b/include/linux/mfd/sun4i-gpadc.h
> @@ -38,6 +38,10 @@
>  #define SUN6I_GPADC_CTRL1_ADC_CHAN_SELECT(x)		(GENMASK(3, 0) & BIT(x))
>  #define SUN6I_GPADC_CTRL1_ADC_CHAN_MASK			GENMASK(3, 0)
>  
> +/* TP_CTRL1 bits for sun8i SoCs */
> +#define SUN8I_GPADC_CTRL1_CHOP_TEMP_EN			BIT(8)
> +#define SUN8I_GPADC_CTRL1_GPADC_CALI_EN			BIT(7)
> +
>  #define SUN4I_GPADC_CTRL2				0x08
>  
>  #define SUN4I_GPADC_CTRL2_TP_SENSITIVE_ADJUST(x)	((GENMASK(3, 0) & (x)) << 28)

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

-- 
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/d/optout.

^ permalink raw reply	[flat|nested] 85+ messages in thread

* [PATCH v2 08/11] iio: adc: sun4i-gpadc-iio: add support for A33 thermal sensor
@ 2017-03-15 10:38     ` Lee Jones
  0 siblings, 0 replies; 85+ messages in thread
From: Lee Jones @ 2017-03-15 10:38 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, 10 Mar 2017, Quentin Schulz wrote:

> This adds support for the Allwinner A33 thermal sensor.
> 
> Unlike the A10, A13 and A31, the Allwinner A33 only has one channel
> which is dedicated to the thermal sensor. Moreover, its thermal sensor
> does not generate interruptions, thus we only need to directly read the
> register storing the temperature value.
> 
> The MFD used by the A10, A13 and A31, was created to avoid breaking the
> DT binding, but since the nodes for the ADC weren't there for the A33,
> it is not needed.
> 
> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
> ---
> 
> v2:
>   - removed added comments in Kconfig,
>   - simplified Kconfig depends on condition,
>   - removed THERMAL_OF requirement for sun8i,
>   - renamed sun8i_gpadc_channels to sun8i_a33_gpadc_channels,
>   - renamed use_dt boolean in no_irq as it reflects better why we need it,
>   - removed spurious/unneeded modifications done in v1,
> 
>  drivers/iio/adc/Kconfig           |   2 +-
>  drivers/iio/adc/sun4i-gpadc-iio.c | 100 ++++++++++++++++++++++++++++++++++++--

>  include/linux/mfd/sun4i-gpadc.h   |   4 ++

For the MFD parts only:
  Acked-by: Lee Jones <lee.jones@linaro.org>

>  3 files changed, 102 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
> index 9f8b4b1..8c8ead6 100644
> --- a/drivers/iio/adc/Kconfig
> +++ b/drivers/iio/adc/Kconfig
> @@ -562,7 +562,7 @@ config STX104
>  config SUN4I_GPADC
>  	tristate "Support for the Allwinner SoCs GPADC"
>  	depends on IIO
> -	depends on MFD_SUN4I_GPADC
> +	depends on MFD_SUN4I_GPADC || MACH_SUN8I
>  	help
>  	  Say yes here to build support for Allwinner (A10, A13 and A31) SoCs
>  	  GPADC. This ADC provides 4 channels which can be used as an ADC or as
> diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c
> index 7cb997a..70684cd 100644
> --- a/drivers/iio/adc/sun4i-gpadc-iio.c
> +++ b/drivers/iio/adc/sun4i-gpadc-iio.c
> @@ -85,6 +85,12 @@ static const struct gpadc_data sun6i_gpadc_data = {
>  	.adc_chan_mask = SUN6I_GPADC_CTRL1_ADC_CHAN_MASK,
>  };
>  
> +static const struct gpadc_data sun8i_a33_gpadc_data = {
> +	.temp_offset = -1662,
> +	.temp_scale = 162,
> +	.tp_mode_en = SUN8I_GPADC_CTRL1_CHOP_TEMP_EN,
> +};
> +
>  struct sun4i_gpadc_iio {
>  	struct iio_dev			*indio_dev;
>  	struct completion		completion;
> @@ -96,6 +102,7 @@ struct sun4i_gpadc_iio {
>  	unsigned int			temp_data_irq;
>  	atomic_t			ignore_temp_data_irq;
>  	const struct gpadc_data		*data;
> +	bool				no_irq;
>  	/* prevents concurrent reads of temperature and ADC */
>  	struct mutex			mutex;
>  };
> @@ -138,6 +145,23 @@ static const struct iio_chan_spec sun4i_gpadc_channels_no_temp[] = {
>  	SUN4I_GPADC_ADC_CHANNEL(3, "adc_chan3"),
>  };
>  
> +static const struct iio_chan_spec sun8i_a33_gpadc_channels[] = {
> +	{
> +		.type = IIO_TEMP,
> +		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
> +				      BIT(IIO_CHAN_INFO_SCALE) |
> +				      BIT(IIO_CHAN_INFO_OFFSET),
> +		.datasheet_name = "temp_adc",
> +	},
> +};
> +
> +static const struct regmap_config sun4i_gpadc_regmap_config = {
> +	.reg_bits = 32,
> +	.val_bits = 32,
> +	.reg_stride = 4,
> +	.fast_io = true,
> +};
> +
>  static int sun4i_prepare_for_irq(struct iio_dev *indio_dev, int channel,
>  				 unsigned int irq)
>  {
> @@ -247,6 +271,17 @@ static int sun4i_gpadc_temp_read(struct iio_dev *indio_dev, int *val)
>  {
>  	struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
>  
> +	if (info->no_irq) {
> +		pm_runtime_get_sync(indio_dev->dev.parent);
> +
> +		regmap_read(info->regmap, SUN4I_GPADC_TEMP_DATA, val);
> +
> +		pm_runtime_mark_last_busy(indio_dev->dev.parent);
> +		pm_runtime_put_autosuspend(indio_dev->dev.parent);
> +
> +		return 0;
> +	}
> +
>  	return sun4i_gpadc_read(indio_dev, 0, val, info->temp_data_irq);
>  }
>  
> @@ -454,6 +489,58 @@ static int sun4i_irq_init(struct platform_device *pdev, const char *name,
>  	return 0;
>  }
>  
> +static const struct of_device_id sun4i_gpadc_of_id[] = {
> +	{
> +		.compatible = "allwinner,sun8i-a33-gpadc-iio",
> +		.data = &sun8i_a33_gpadc_data,
> +	},
> +	{ /* sentinel */ }
> +};
> +
> +static int sun4i_gpadc_probe_dt(struct platform_device *pdev,
> +				struct iio_dev *indio_dev)
> +{
> +	struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
> +	const struct of_device_id *of_dev;
> +	struct thermal_zone_device *tzd;
> +	struct resource *mem;
> +	void __iomem *base;
> +	int ret;
> +
> +	of_dev = of_match_device(sun4i_gpadc_of_id, &pdev->dev);
> +	if (!of_dev)
> +		return -ENODEV;
> +
> +	info->no_irq = true;
> +	info->data = (struct gpadc_data *)of_dev->data;
> +	indio_dev->num_channels = ARRAY_SIZE(sun8i_a33_gpadc_channels);
> +	indio_dev->channels = sun8i_a33_gpadc_channels;
> +
> +	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	base = devm_ioremap_resource(&pdev->dev, mem);
> +	if (IS_ERR(base))
> +		return PTR_ERR(base);
> +
> +	info->regmap = devm_regmap_init_mmio(&pdev->dev, base,
> +					     &sun4i_gpadc_regmap_config);
> +	if (IS_ERR(info->regmap)) {
> +		ret = PTR_ERR(info->regmap);
> +		dev_err(&pdev->dev, "failed to init regmap: %d\n", ret);
> +		return ret;
> +	}
> +
> +	if (!IS_ENABLED(THERMAL_OF))
> +		return 0;
> +
> +	tzd = devm_thermal_zone_of_sensor_register(&pdev->dev, 0, info,
> +						   &sun4i_ts_tz_ops);
> +	if (IS_ERR(tzd))
> +		dev_err(&pdev->dev, "could not register thermal sensor: %ld\n",
> +			PTR_ERR(tzd));
> +
> +	return PTR_ERR_OR_ZERO(tzd);
> +}
> +
>  static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
>  				 struct iio_dev *indio_dev)
>  {
> @@ -462,6 +549,7 @@ static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
>  		dev_get_drvdata(pdev->dev.parent);
>  	int ret;
>  
> +	info->no_irq = false;
>  	info->regmap = sun4i_gpadc_dev->regmap;
>  
>  	indio_dev->num_channels = ARRAY_SIZE(sun4i_gpadc_channels);
> @@ -561,7 +649,11 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>  	indio_dev->info = &sun4i_gpadc_iio_info;
>  	indio_dev->modes = INDIO_DIRECT_MODE;
>  
> -	ret = sun4i_gpadc_probe_mfd(pdev, indio_dev);
> +	if (pdev->dev.of_node)
> +		ret = sun4i_gpadc_probe_dt(pdev, indio_dev);
> +	else
> +		ret = sun4i_gpadc_probe_mfd(pdev, indio_dev);
> +
>  	if (ret)
>  		return ret;
>  
> @@ -580,7 +672,7 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>  	return 0;
>  
>  err_map:
> -	if (IS_ENABLED(CONFIG_THERMAL_OF))
> +	if (!info->no_irq && IS_ENABLED(CONFIG_THERMAL_OF))
>  		iio_map_array_unregister(indio_dev);
>  
>  	pm_runtime_put(&pdev->dev);
> @@ -592,10 +684,11 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>  static int sun4i_gpadc_remove(struct platform_device *pdev)
>  {
>  	struct iio_dev *indio_dev = platform_get_drvdata(pdev);
> +	struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
>  
>  	pm_runtime_put(&pdev->dev);
>  	pm_runtime_disable(&pdev->dev);
> -	if (IS_ENABLED(CONFIG_THERMAL_OF))
> +	if (!info->no_irq && IS_ENABLED(CONFIG_THERMAL_OF))
>  		iio_map_array_unregister(indio_dev);
>  
>  	return 0;
> @@ -611,6 +704,7 @@ static const struct platform_device_id sun4i_gpadc_id[] = {
>  static struct platform_driver sun4i_gpadc_driver = {
>  	.driver = {
>  		.name = "sun4i-gpadc-iio",
> +		.of_match_table = sun4i_gpadc_of_id,
>  		.pm = &sun4i_gpadc_pm_ops,
>  	},
>  	.id_table = sun4i_gpadc_id,
> diff --git a/include/linux/mfd/sun4i-gpadc.h b/include/linux/mfd/sun4i-gpadc.h
> index 509e736..139872c 100644
> --- a/include/linux/mfd/sun4i-gpadc.h
> +++ b/include/linux/mfd/sun4i-gpadc.h
> @@ -38,6 +38,10 @@
>  #define SUN6I_GPADC_CTRL1_ADC_CHAN_SELECT(x)		(GENMASK(3, 0) & BIT(x))
>  #define SUN6I_GPADC_CTRL1_ADC_CHAN_MASK			GENMASK(3, 0)
>  
> +/* TP_CTRL1 bits for sun8i SoCs */
> +#define SUN8I_GPADC_CTRL1_CHOP_TEMP_EN			BIT(8)
> +#define SUN8I_GPADC_CTRL1_GPADC_CALI_EN			BIT(7)
> +
>  #define SUN4I_GPADC_CTRL2				0x08
>  
>  #define SUN4I_GPADC_CTRL2_TP_SENSITIVE_ADJUST(x)	((GENMASK(3, 0) & (x)) << 28)

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org ? Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH v2 08/11] iio: adc: sun4i-gpadc-iio: add support for A33 thermal sensor
  2017-03-14  7:15           ` Quentin Schulz
  (?)
@ 2017-03-18 14:18             ` Jonathan Cameron
  -1 siblings, 0 replies; 85+ messages in thread
From: Jonathan Cameron @ 2017-03-18 14:18 UTC (permalink / raw)
  To: Quentin Schulz, Icenowy Zheng, dmitry.torokhov, robh+dt,
	mark.rutland, maxime.ripard, wens, lee.jones, linux, knaack.h,
	lars, pmeerw, stefan.mavrodiev
  Cc: thomas.petazzoni, devicetree, linux-iio, linux-kernel,
	linux-sunxi, linux-arm-kernel

On 14/03/17 07:15, Quentin Schulz wrote:
> Hi Jonathan,
> 
> On 14/03/2017 06:18, Icenowy Zheng wrote:
>>
>>
>> 14.03.2017, 05:08, "Jonathan Cameron" <jic23@kernel.org>:
>>> On 10/03/17 10:39, Quentin Schulz wrote:
>>>>  This adds support for the Allwinner A33 thermal sensor.
>>>>
>>>>  Unlike the A10, A13 and A31, the Allwinner A33 only has one channel
>>>>  which is dedicated to the thermal sensor. Moreover, its thermal sensor
>>>>  does not generate interruptions, thus we only need to directly read the
>>>>  register storing the temperature value.
>>>>
>>>>  The MFD used by the A10, A13 and A31, was created to avoid breaking the
>>>>  DT binding, but since the nodes for the ADC weren't there for the A33,
>>>>  it is not needed.
>>>>
>>>>  Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
>>>
>>> Talk me through why it makes sense to do this rather than simply spin out
>>> a really simple thermal driver for the A33?
>>
>> According to him the A33 thermal sensor is a simplified version of the GPADC.
>>
> 
> Same registers with almost same bits for the same purpose (temperature).
> Some SoCs have an ADC and one or more thermal sensors (A10, A13, A31,
> H3) while others have only one thermal sensor (A23, A33). Same IP with
> or without ADC/Touchscreen so same driver, that was my mindset.
> 
> The thermal part behaves the same except for the presence of interrupts
> or not. (A33 has bits for interrupts in the datasheet but that just does
> not work).
Hmm. I'm just about convinced by this argument, please make it in the patch
description going forward.

Jonathan
> 
> Thanks,
> Quentin
> 
>> I have already did a simple thermal driver ~8 months ago, but is rejected for
>> this reason.
>>
>>>
>>> I'm not against what you have here, but don't feel it has been fully argued.
>>>
>>> Jonathan
>>>>  ---
>>>>
>>>>  v2:
>>>>    - removed added comments in Kconfig,
>>>>    - simplified Kconfig depends on condition,
>>>>    - removed THERMAL_OF requirement for sun8i,
>>>>    - renamed sun8i_gpadc_channels to sun8i_a33_gpadc_channels,
>>>>    - renamed use_dt boolean in no_irq as it reflects better why we need it,
>>>>    - removed spurious/unneeded modifications done in v1,
>>>>
>>>>   drivers/iio/adc/Kconfig | 2 +-
>>>>   drivers/iio/adc/sun4i-gpadc-iio.c | 100 ++++++++++++++++++++++++++++++++++++--
>>>>   include/linux/mfd/sun4i-gpadc.h | 4 ++
>>>>   3 files changed, 102 insertions(+), 4 deletions(-)
>>>>
>>>>  diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
>>>>  index 9f8b4b1..8c8ead6 100644
>>>>  --- a/drivers/iio/adc/Kconfig
>>>>  +++ b/drivers/iio/adc/Kconfig
>>>>  @@ -562,7 +562,7 @@ config STX104
>>>>   config SUN4I_GPADC
>>>>           tristate "Support for the Allwinner SoCs GPADC"
>>>>           depends on IIO
>>>>  - depends on MFD_SUN4I_GPADC
>>>>  + depends on MFD_SUN4I_GPADC || MACH_SUN8I
>>>>           help
>>>>             Say yes here to build support for Allwinner (A10, A13 and A31) SoCs
>>>>             GPADC. This ADC provides 4 channels which can be used as an ADC or as
>>>>  diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c
>>>>  index 7cb997a..70684cd 100644
>>>>  --- a/drivers/iio/adc/sun4i-gpadc-iio.c
>>>>  +++ b/drivers/iio/adc/sun4i-gpadc-iio.c
>>>>  @@ -85,6 +85,12 @@ static const struct gpadc_data sun6i_gpadc_data = {
>>>>           .adc_chan_mask = SUN6I_GPADC_CTRL1_ADC_CHAN_MASK,
>>>>   };
>>>>
>>>>  +static const struct gpadc_data sun8i_a33_gpadc_data = {
>>>>  + .temp_offset = -1662,
>>>>  + .temp_scale = 162,
>>>>  + .tp_mode_en = SUN8I_GPADC_CTRL1_CHOP_TEMP_EN,
>>>>  +};
>>>>  +
>>>>   struct sun4i_gpadc_iio {
>>>>           struct iio_dev *indio_dev;
>>>>           struct completion completion;
>>>>  @@ -96,6 +102,7 @@ struct sun4i_gpadc_iio {
>>>>           unsigned int temp_data_irq;
>>>>           atomic_t ignore_temp_data_irq;
>>>>           const struct gpadc_data *data;
>>>>  + bool no_irq;
>>>>           /* prevents concurrent reads of temperature and ADC */
>>>>           struct mutex mutex;
>>>>   };
>>>>  @@ -138,6 +145,23 @@ static const struct iio_chan_spec sun4i_gpadc_channels_no_temp[] = {
>>>>           SUN4I_GPADC_ADC_CHANNEL(3, "adc_chan3"),
>>>>   };
>>>>
>>>>  +static const struct iio_chan_spec sun8i_a33_gpadc_channels[] = {
>>>>  + {
>>>>  + .type = IIO_TEMP,
>>>>  + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
>>>>  + BIT(IIO_CHAN_INFO_SCALE) |
>>>>  + BIT(IIO_CHAN_INFO_OFFSET),
>>>>  + .datasheet_name = "temp_adc",
>>>>  + },
>>>>  +};
>>>>  +
>>>>  +static const struct regmap_config sun4i_gpadc_regmap_config = {
>>>>  + .reg_bits = 32,
>>>>  + .val_bits = 32,
>>>>  + .reg_stride = 4,
>>>>  + .fast_io = true,
>>>>  +};
>>>>  +
>>>>   static int sun4i_prepare_for_irq(struct iio_dev *indio_dev, int channel,
>>>>                                    unsigned int irq)
>>>>   {
>>>>  @@ -247,6 +271,17 @@ static int sun4i_gpadc_temp_read(struct iio_dev *indio_dev, int *val)
>>>>   {
>>>>           struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
>>>>
>>>>  + if (info->no_irq) {
>>>>  + pm_runtime_get_sync(indio_dev->dev.parent);
>>>>  +
>>>>  + regmap_read(info->regmap, SUN4I_GPADC_TEMP_DATA, val);
>>>>  +
>>>>  + pm_runtime_mark_last_busy(indio_dev->dev.parent);
>>>>  + pm_runtime_put_autosuspend(indio_dev->dev.parent);
>>>>  +
>>>>  + return 0;
>>>>  + }
>>>>  +
>>>>           return sun4i_gpadc_read(indio_dev, 0, val, info->temp_data_irq);
>>>>   }
>>>>
>>>>  @@ -454,6 +489,58 @@ static int sun4i_irq_init(struct platform_device *pdev, const char *name,
>>>>           return 0;
>>>>   }
>>>>
>>>>  +static const struct of_device_id sun4i_gpadc_of_id[] = {
>>>>  + {
>>>>  + .compatible = "allwinner,sun8i-a33-gpadc-iio",
>>>>  + .data = &sun8i_a33_gpadc_data,
>>>>  + },
>>>>  + { /* sentinel */ }
>>>>  +};
>>>>  +
>>>>  +static int sun4i_gpadc_probe_dt(struct platform_device *pdev,
>>>>  + struct iio_dev *indio_dev)
>>>>  +{
>>>>  + struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
>>>>  + const struct of_device_id *of_dev;
>>>>  + struct thermal_zone_device *tzd;
>>>>  + struct resource *mem;
>>>>  + void __iomem *base;
>>>>  + int ret;
>>>>  +
>>>>  + of_dev = of_match_device(sun4i_gpadc_of_id, &pdev->dev);
>>>>  + if (!of_dev)
>>>>  + return -ENODEV;
>>>>  +
>>>>  + info->no_irq = true;
>>>>  + info->data = (struct gpadc_data *)of_dev->data;
>>>>  + indio_dev->num_channels = ARRAY_SIZE(sun8i_a33_gpadc_channels);
>>>>  + indio_dev->channels = sun8i_a33_gpadc_channels;
>>>>  +
>>>>  + mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>>>>  + base = devm_ioremap_resource(&pdev->dev, mem);
>>>>  + if (IS_ERR(base))
>>>>  + return PTR_ERR(base);
>>>>  +
>>>>  + info->regmap = devm_regmap_init_mmio(&pdev->dev, base,
>>>>  + &sun4i_gpadc_regmap_config);
>>>>  + if (IS_ERR(info->regmap)) {
>>>>  + ret = PTR_ERR(info->regmap);
>>>>  + dev_err(&pdev->dev, "failed to init regmap: %d\n", ret);
>>>>  + return ret;
>>>>  + }
>>>>  +
>>>>  + if (!IS_ENABLED(THERMAL_OF))
>>>>  + return 0;
>>>>  +
>>>>  + tzd = devm_thermal_zone_of_sensor_register(&pdev->dev, 0, info,
>>>>  + &sun4i_ts_tz_ops);
>>>>  + if (IS_ERR(tzd))
>>>>  + dev_err(&pdev->dev, "could not register thermal sensor: %ld\n",
>>>>  + PTR_ERR(tzd));
>>>>  +
>>>>  + return PTR_ERR_OR_ZERO(tzd);
>>>>  +}
>>>>  +
>>>>   static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
>>>>                                    struct iio_dev *indio_dev)
>>>>   {
>>>>  @@ -462,6 +549,7 @@ static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
>>>>                   dev_get_drvdata(pdev->dev.parent);
>>>>           int ret;
>>>>
>>>>  + info->no_irq = false;
>>>>           info->regmap = sun4i_gpadc_dev->regmap;
>>>>
>>>>           indio_dev->num_channels = ARRAY_SIZE(sun4i_gpadc_channels);
>>>>  @@ -561,7 +649,11 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>>>>           indio_dev->info = &sun4i_gpadc_iio_info;
>>>>           indio_dev->modes = INDIO_DIRECT_MODE;
>>>>
>>>>  - ret = sun4i_gpadc_probe_mfd(pdev, indio_dev);
>>>>  + if (pdev->dev.of_node)
>>>>  + ret = sun4i_gpadc_probe_dt(pdev, indio_dev);
>>>>  + else
>>>>  + ret = sun4i_gpadc_probe_mfd(pdev, indio_dev);
>>>>  +
>>>>           if (ret)
>>>>                   return ret;
>>>>
>>>>  @@ -580,7 +672,7 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>>>>           return 0;
>>>>
>>>>   err_map:
>>>>  - if (IS_ENABLED(CONFIG_THERMAL_OF))
>>>>  + if (!info->no_irq && IS_ENABLED(CONFIG_THERMAL_OF))
>>>>                   iio_map_array_unregister(indio_dev);
>>>>
>>>>           pm_runtime_put(&pdev->dev);
>>>>  @@ -592,10 +684,11 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>>>>   static int sun4i_gpadc_remove(struct platform_device *pdev)
>>>>   {
>>>>           struct iio_dev *indio_dev = platform_get_drvdata(pdev);
>>>>  + struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
>>>>
>>>>           pm_runtime_put(&pdev->dev);
>>>>           pm_runtime_disable(&pdev->dev);
>>>>  - if (IS_ENABLED(CONFIG_THERMAL_OF))
>>>>  + if (!info->no_irq && IS_ENABLED(CONFIG_THERMAL_OF))
>>>>                   iio_map_array_unregister(indio_dev);
>>>>
>>>>           return 0;
>>>>  @@ -611,6 +704,7 @@ static const struct platform_device_id sun4i_gpadc_id[] = {
>>>>   static struct platform_driver sun4i_gpadc_driver = {
>>>>           .driver = {
>>>>                   .name = "sun4i-gpadc-iio",
>>>>  + .of_match_table = sun4i_gpadc_of_id,
>>>>                   .pm = &sun4i_gpadc_pm_ops,
>>>>           },
>>>>           .id_table = sun4i_gpadc_id,
>>>>  diff --git a/include/linux/mfd/sun4i-gpadc.h b/include/linux/mfd/sun4i-gpadc.h
>>>>  index 509e736..139872c 100644
>>>>  --- a/include/linux/mfd/sun4i-gpadc.h
>>>>  +++ b/include/linux/mfd/sun4i-gpadc.h
>>>>  @@ -38,6 +38,10 @@
>>>>   #define SUN6I_GPADC_CTRL1_ADC_CHAN_SELECT(x) (GENMASK(3, 0) & BIT(x))
>>>>   #define SUN6I_GPADC_CTRL1_ADC_CHAN_MASK GENMASK(3, 0)
>>>>
>>>>  +/* TP_CTRL1 bits for sun8i SoCs */
>>>>  +#define SUN8I_GPADC_CTRL1_CHOP_TEMP_EN BIT(8)
>>>>  +#define SUN8I_GPADC_CTRL1_GPADC_CALI_EN BIT(7)
>>>>  +
>>>>   #define SUN4I_GPADC_CTRL2 0x08
>>>>
>>>>   #define SUN4I_GPADC_CTRL2_TP_SENSITIVE_ADJUST(x) ((GENMASK(3, 0) & (x)) << 28)
>>>
>>> _______________________________________________
>>> linux-arm-kernel mailing list
>>> linux-arm-kernel@lists.infradead.org
>>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> 

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH v2 08/11] iio: adc: sun4i-gpadc-iio: add support for A33 thermal sensor
@ 2017-03-18 14:18             ` Jonathan Cameron
  0 siblings, 0 replies; 85+ messages in thread
From: Jonathan Cameron @ 2017-03-18 14:18 UTC (permalink / raw)
  To: Quentin Schulz, Icenowy Zheng, dmitry.torokhov, robh+dt,
	mark.rutland, maxime.ripard, wens, lee.jones, linux, knaack.h,
	lars, pmeerw, stefan.mavrodiev
  Cc: thomas.petazzoni, devicetree, linux-iio, linux-kernel,
	linux-sunxi, linux-arm-kernel

On 14/03/17 07:15, Quentin Schulz wrote:
> Hi Jonathan,
> 
> On 14/03/2017 06:18, Icenowy Zheng wrote:
>>
>>
>> 14.03.2017, 05:08, "Jonathan Cameron" <jic23@kernel.org>:
>>> On 10/03/17 10:39, Quentin Schulz wrote:
>>>>  This adds support for the Allwinner A33 thermal sensor.
>>>>
>>>>  Unlike the A10, A13 and A31, the Allwinner A33 only has one channel
>>>>  which is dedicated to the thermal sensor. Moreover, its thermal sensor
>>>>  does not generate interruptions, thus we only need to directly read the
>>>>  register storing the temperature value.
>>>>
>>>>  The MFD used by the A10, A13 and A31, was created to avoid breaking the
>>>>  DT binding, but since the nodes for the ADC weren't there for the A33,
>>>>  it is not needed.
>>>>
>>>>  Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
>>>
>>> Talk me through why it makes sense to do this rather than simply spin out
>>> a really simple thermal driver for the A33?
>>
>> According to him the A33 thermal sensor is a simplified version of the GPADC.
>>
> 
> Same registers with almost same bits for the same purpose (temperature).
> Some SoCs have an ADC and one or more thermal sensors (A10, A13, A31,
> H3) while others have only one thermal sensor (A23, A33). Same IP with
> or without ADC/Touchscreen so same driver, that was my mindset.
> 
> The thermal part behaves the same except for the presence of interrupts
> or not. (A33 has bits for interrupts in the datasheet but that just does
> not work).
Hmm. I'm just about convinced by this argument, please make it in the patch
description going forward.

Jonathan
> 
> Thanks,
> Quentin
> 
>> I have already did a simple thermal driver ~8 months ago, but is rejected for
>> this reason.
>>
>>>
>>> I'm not against what you have here, but don't feel it has been fully argued.
>>>
>>> Jonathan
>>>>  ---
>>>>
>>>>  v2:
>>>>    - removed added comments in Kconfig,
>>>>    - simplified Kconfig depends on condition,
>>>>    - removed THERMAL_OF requirement for sun8i,
>>>>    - renamed sun8i_gpadc_channels to sun8i_a33_gpadc_channels,
>>>>    - renamed use_dt boolean in no_irq as it reflects better why we need it,
>>>>    - removed spurious/unneeded modifications done in v1,
>>>>
>>>>   drivers/iio/adc/Kconfig | 2 +-
>>>>   drivers/iio/adc/sun4i-gpadc-iio.c | 100 ++++++++++++++++++++++++++++++++++++--
>>>>   include/linux/mfd/sun4i-gpadc.h | 4 ++
>>>>   3 files changed, 102 insertions(+), 4 deletions(-)
>>>>
>>>>  diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
>>>>  index 9f8b4b1..8c8ead6 100644
>>>>  --- a/drivers/iio/adc/Kconfig
>>>>  +++ b/drivers/iio/adc/Kconfig
>>>>  @@ -562,7 +562,7 @@ config STX104
>>>>   config SUN4I_GPADC
>>>>           tristate "Support for the Allwinner SoCs GPADC"
>>>>           depends on IIO
>>>>  - depends on MFD_SUN4I_GPADC
>>>>  + depends on MFD_SUN4I_GPADC || MACH_SUN8I
>>>>           help
>>>>             Say yes here to build support for Allwinner (A10, A13 and A31) SoCs
>>>>             GPADC. This ADC provides 4 channels which can be used as an ADC or as
>>>>  diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c
>>>>  index 7cb997a..70684cd 100644
>>>>  --- a/drivers/iio/adc/sun4i-gpadc-iio.c
>>>>  +++ b/drivers/iio/adc/sun4i-gpadc-iio.c
>>>>  @@ -85,6 +85,12 @@ static const struct gpadc_data sun6i_gpadc_data = {
>>>>           .adc_chan_mask = SUN6I_GPADC_CTRL1_ADC_CHAN_MASK,
>>>>   };
>>>>
>>>>  +static const struct gpadc_data sun8i_a33_gpadc_data = {
>>>>  + .temp_offset = -1662,
>>>>  + .temp_scale = 162,
>>>>  + .tp_mode_en = SUN8I_GPADC_CTRL1_CHOP_TEMP_EN,
>>>>  +};
>>>>  +
>>>>   struct sun4i_gpadc_iio {
>>>>           struct iio_dev *indio_dev;
>>>>           struct completion completion;
>>>>  @@ -96,6 +102,7 @@ struct sun4i_gpadc_iio {
>>>>           unsigned int temp_data_irq;
>>>>           atomic_t ignore_temp_data_irq;
>>>>           const struct gpadc_data *data;
>>>>  + bool no_irq;
>>>>           /* prevents concurrent reads of temperature and ADC */
>>>>           struct mutex mutex;
>>>>   };
>>>>  @@ -138,6 +145,23 @@ static const struct iio_chan_spec sun4i_gpadc_channels_no_temp[] = {
>>>>           SUN4I_GPADC_ADC_CHANNEL(3, "adc_chan3"),
>>>>   };
>>>>
>>>>  +static const struct iio_chan_spec sun8i_a33_gpadc_channels[] = {
>>>>  + {
>>>>  + .type = IIO_TEMP,
>>>>  + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
>>>>  + BIT(IIO_CHAN_INFO_SCALE) |
>>>>  + BIT(IIO_CHAN_INFO_OFFSET),
>>>>  + .datasheet_name = "temp_adc",
>>>>  + },
>>>>  +};
>>>>  +
>>>>  +static const struct regmap_config sun4i_gpadc_regmap_config = {
>>>>  + .reg_bits = 32,
>>>>  + .val_bits = 32,
>>>>  + .reg_stride = 4,
>>>>  + .fast_io = true,
>>>>  +};
>>>>  +
>>>>   static int sun4i_prepare_for_irq(struct iio_dev *indio_dev, int channel,
>>>>                                    unsigned int irq)
>>>>   {
>>>>  @@ -247,6 +271,17 @@ static int sun4i_gpadc_temp_read(struct iio_dev *indio_dev, int *val)
>>>>   {
>>>>           struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
>>>>
>>>>  + if (info->no_irq) {
>>>>  + pm_runtime_get_sync(indio_dev->dev.parent);
>>>>  +
>>>>  + regmap_read(info->regmap, SUN4I_GPADC_TEMP_DATA, val);
>>>>  +
>>>>  + pm_runtime_mark_last_busy(indio_dev->dev.parent);
>>>>  + pm_runtime_put_autosuspend(indio_dev->dev.parent);
>>>>  +
>>>>  + return 0;
>>>>  + }
>>>>  +
>>>>           return sun4i_gpadc_read(indio_dev, 0, val, info->temp_data_irq);
>>>>   }
>>>>
>>>>  @@ -454,6 +489,58 @@ static int sun4i_irq_init(struct platform_device *pdev, const char *name,
>>>>           return 0;
>>>>   }
>>>>
>>>>  +static const struct of_device_id sun4i_gpadc_of_id[] = {
>>>>  + {
>>>>  + .compatible = "allwinner,sun8i-a33-gpadc-iio",
>>>>  + .data = &sun8i_a33_gpadc_data,
>>>>  + },
>>>>  + { /* sentinel */ }
>>>>  +};
>>>>  +
>>>>  +static int sun4i_gpadc_probe_dt(struct platform_device *pdev,
>>>>  + struct iio_dev *indio_dev)
>>>>  +{
>>>>  + struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
>>>>  + const struct of_device_id *of_dev;
>>>>  + struct thermal_zone_device *tzd;
>>>>  + struct resource *mem;
>>>>  + void __iomem *base;
>>>>  + int ret;
>>>>  +
>>>>  + of_dev = of_match_device(sun4i_gpadc_of_id, &pdev->dev);
>>>>  + if (!of_dev)
>>>>  + return -ENODEV;
>>>>  +
>>>>  + info->no_irq = true;
>>>>  + info->data = (struct gpadc_data *)of_dev->data;
>>>>  + indio_dev->num_channels = ARRAY_SIZE(sun8i_a33_gpadc_channels);
>>>>  + indio_dev->channels = sun8i_a33_gpadc_channels;
>>>>  +
>>>>  + mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>>>>  + base = devm_ioremap_resource(&pdev->dev, mem);
>>>>  + if (IS_ERR(base))
>>>>  + return PTR_ERR(base);
>>>>  +
>>>>  + info->regmap = devm_regmap_init_mmio(&pdev->dev, base,
>>>>  + &sun4i_gpadc_regmap_config);
>>>>  + if (IS_ERR(info->regmap)) {
>>>>  + ret = PTR_ERR(info->regmap);
>>>>  + dev_err(&pdev->dev, "failed to init regmap: %d\n", ret);
>>>>  + return ret;
>>>>  + }
>>>>  +
>>>>  + if (!IS_ENABLED(THERMAL_OF))
>>>>  + return 0;
>>>>  +
>>>>  + tzd = devm_thermal_zone_of_sensor_register(&pdev->dev, 0, info,
>>>>  + &sun4i_ts_tz_ops);
>>>>  + if (IS_ERR(tzd))
>>>>  + dev_err(&pdev->dev, "could not register thermal sensor: %ld\n",
>>>>  + PTR_ERR(tzd));
>>>>  +
>>>>  + return PTR_ERR_OR_ZERO(tzd);
>>>>  +}
>>>>  +
>>>>   static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
>>>>                                    struct iio_dev *indio_dev)
>>>>   {
>>>>  @@ -462,6 +549,7 @@ static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
>>>>                   dev_get_drvdata(pdev->dev.parent);
>>>>           int ret;
>>>>
>>>>  + info->no_irq = false;
>>>>           info->regmap = sun4i_gpadc_dev->regmap;
>>>>
>>>>           indio_dev->num_channels = ARRAY_SIZE(sun4i_gpadc_channels);
>>>>  @@ -561,7 +649,11 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>>>>           indio_dev->info = &sun4i_gpadc_iio_info;
>>>>           indio_dev->modes = INDIO_DIRECT_MODE;
>>>>
>>>>  - ret = sun4i_gpadc_probe_mfd(pdev, indio_dev);
>>>>  + if (pdev->dev.of_node)
>>>>  + ret = sun4i_gpadc_probe_dt(pdev, indio_dev);
>>>>  + else
>>>>  + ret = sun4i_gpadc_probe_mfd(pdev, indio_dev);
>>>>  +
>>>>           if (ret)
>>>>                   return ret;
>>>>
>>>>  @@ -580,7 +672,7 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>>>>           return 0;
>>>>
>>>>   err_map:
>>>>  - if (IS_ENABLED(CONFIG_THERMAL_OF))
>>>>  + if (!info->no_irq && IS_ENABLED(CONFIG_THERMAL_OF))
>>>>                   iio_map_array_unregister(indio_dev);
>>>>
>>>>           pm_runtime_put(&pdev->dev);
>>>>  @@ -592,10 +684,11 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>>>>   static int sun4i_gpadc_remove(struct platform_device *pdev)
>>>>   {
>>>>           struct iio_dev *indio_dev = platform_get_drvdata(pdev);
>>>>  + struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
>>>>
>>>>           pm_runtime_put(&pdev->dev);
>>>>           pm_runtime_disable(&pdev->dev);
>>>>  - if (IS_ENABLED(CONFIG_THERMAL_OF))
>>>>  + if (!info->no_irq && IS_ENABLED(CONFIG_THERMAL_OF))
>>>>                   iio_map_array_unregister(indio_dev);
>>>>
>>>>           return 0;
>>>>  @@ -611,6 +704,7 @@ static const struct platform_device_id sun4i_gpadc_id[] = {
>>>>   static struct platform_driver sun4i_gpadc_driver = {
>>>>           .driver = {
>>>>                   .name = "sun4i-gpadc-iio",
>>>>  + .of_match_table = sun4i_gpadc_of_id,
>>>>                   .pm = &sun4i_gpadc_pm_ops,
>>>>           },
>>>>           .id_table = sun4i_gpadc_id,
>>>>  diff --git a/include/linux/mfd/sun4i-gpadc.h b/include/linux/mfd/sun4i-gpadc.h
>>>>  index 509e736..139872c 100644
>>>>  --- a/include/linux/mfd/sun4i-gpadc.h
>>>>  +++ b/include/linux/mfd/sun4i-gpadc.h
>>>>  @@ -38,6 +38,10 @@
>>>>   #define SUN6I_GPADC_CTRL1_ADC_CHAN_SELECT(x) (GENMASK(3, 0) & BIT(x))
>>>>   #define SUN6I_GPADC_CTRL1_ADC_CHAN_MASK GENMASK(3, 0)
>>>>
>>>>  +/* TP_CTRL1 bits for sun8i SoCs */
>>>>  +#define SUN8I_GPADC_CTRL1_CHOP_TEMP_EN BIT(8)
>>>>  +#define SUN8I_GPADC_CTRL1_GPADC_CALI_EN BIT(7)
>>>>  +
>>>>   #define SUN4I_GPADC_CTRL2 0x08
>>>>
>>>>   #define SUN4I_GPADC_CTRL2_TP_SENSITIVE_ADJUST(x) ((GENMASK(3, 0) & (x)) << 28)
>>>
>>> _______________________________________________
>>> linux-arm-kernel mailing list
>>> linux-arm-kernel@lists.infradead.org
>>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> 

^ permalink raw reply	[flat|nested] 85+ messages in thread

* [PATCH v2 08/11] iio: adc: sun4i-gpadc-iio: add support for A33 thermal sensor
@ 2017-03-18 14:18             ` Jonathan Cameron
  0 siblings, 0 replies; 85+ messages in thread
From: Jonathan Cameron @ 2017-03-18 14:18 UTC (permalink / raw)
  To: linux-arm-kernel

On 14/03/17 07:15, Quentin Schulz wrote:
> Hi Jonathan,
> 
> On 14/03/2017 06:18, Icenowy Zheng wrote:
>>
>>
>> 14.03.2017, 05:08, "Jonathan Cameron" <jic23@kernel.org>:
>>> On 10/03/17 10:39, Quentin Schulz wrote:
>>>>  This adds support for the Allwinner A33 thermal sensor.
>>>>
>>>>  Unlike the A10, A13 and A31, the Allwinner A33 only has one channel
>>>>  which is dedicated to the thermal sensor. Moreover, its thermal sensor
>>>>  does not generate interruptions, thus we only need to directly read the
>>>>  register storing the temperature value.
>>>>
>>>>  The MFD used by the A10, A13 and A31, was created to avoid breaking the
>>>>  DT binding, but since the nodes for the ADC weren't there for the A33,
>>>>  it is not needed.
>>>>
>>>>  Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
>>>
>>> Talk me through why it makes sense to do this rather than simply spin out
>>> a really simple thermal driver for the A33?
>>
>> According to him the A33 thermal sensor is a simplified version of the GPADC.
>>
> 
> Same registers with almost same bits for the same purpose (temperature).
> Some SoCs have an ADC and one or more thermal sensors (A10, A13, A31,
> H3) while others have only one thermal sensor (A23, A33). Same IP with
> or without ADC/Touchscreen so same driver, that was my mindset.
> 
> The thermal part behaves the same except for the presence of interrupts
> or not. (A33 has bits for interrupts in the datasheet but that just does
> not work).
Hmm. I'm just about convinced by this argument, please make it in the patch
description going forward.

Jonathan
> 
> Thanks,
> Quentin
> 
>> I have already did a simple thermal driver ~8 months ago, but is rejected for
>> this reason.
>>
>>>
>>> I'm not against what you have here, but don't feel it has been fully argued.
>>>
>>> Jonathan
>>>>  ---
>>>>
>>>>  v2:
>>>>    - removed added comments in Kconfig,
>>>>    - simplified Kconfig depends on condition,
>>>>    - removed THERMAL_OF requirement for sun8i,
>>>>    - renamed sun8i_gpadc_channels to sun8i_a33_gpadc_channels,
>>>>    - renamed use_dt boolean in no_irq as it reflects better why we need it,
>>>>    - removed spurious/unneeded modifications done in v1,
>>>>
>>>>   drivers/iio/adc/Kconfig | 2 +-
>>>>   drivers/iio/adc/sun4i-gpadc-iio.c | 100 ++++++++++++++++++++++++++++++++++++--
>>>>   include/linux/mfd/sun4i-gpadc.h | 4 ++
>>>>   3 files changed, 102 insertions(+), 4 deletions(-)
>>>>
>>>>  diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
>>>>  index 9f8b4b1..8c8ead6 100644
>>>>  --- a/drivers/iio/adc/Kconfig
>>>>  +++ b/drivers/iio/adc/Kconfig
>>>>  @@ -562,7 +562,7 @@ config STX104
>>>>   config SUN4I_GPADC
>>>>           tristate "Support for the Allwinner SoCs GPADC"
>>>>           depends on IIO
>>>>  - depends on MFD_SUN4I_GPADC
>>>>  + depends on MFD_SUN4I_GPADC || MACH_SUN8I
>>>>           help
>>>>             Say yes here to build support for Allwinner (A10, A13 and A31) SoCs
>>>>             GPADC. This ADC provides 4 channels which can be used as an ADC or as
>>>>  diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c
>>>>  index 7cb997a..70684cd 100644
>>>>  --- a/drivers/iio/adc/sun4i-gpadc-iio.c
>>>>  +++ b/drivers/iio/adc/sun4i-gpadc-iio.c
>>>>  @@ -85,6 +85,12 @@ static const struct gpadc_data sun6i_gpadc_data = {
>>>>           .adc_chan_mask = SUN6I_GPADC_CTRL1_ADC_CHAN_MASK,
>>>>   };
>>>>
>>>>  +static const struct gpadc_data sun8i_a33_gpadc_data = {
>>>>  + .temp_offset = -1662,
>>>>  + .temp_scale = 162,
>>>>  + .tp_mode_en = SUN8I_GPADC_CTRL1_CHOP_TEMP_EN,
>>>>  +};
>>>>  +
>>>>   struct sun4i_gpadc_iio {
>>>>           struct iio_dev *indio_dev;
>>>>           struct completion completion;
>>>>  @@ -96,6 +102,7 @@ struct sun4i_gpadc_iio {
>>>>           unsigned int temp_data_irq;
>>>>           atomic_t ignore_temp_data_irq;
>>>>           const struct gpadc_data *data;
>>>>  + bool no_irq;
>>>>           /* prevents concurrent reads of temperature and ADC */
>>>>           struct mutex mutex;
>>>>   };
>>>>  @@ -138,6 +145,23 @@ static const struct iio_chan_spec sun4i_gpadc_channels_no_temp[] = {
>>>>           SUN4I_GPADC_ADC_CHANNEL(3, "adc_chan3"),
>>>>   };
>>>>
>>>>  +static const struct iio_chan_spec sun8i_a33_gpadc_channels[] = {
>>>>  + {
>>>>  + .type = IIO_TEMP,
>>>>  + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
>>>>  + BIT(IIO_CHAN_INFO_SCALE) |
>>>>  + BIT(IIO_CHAN_INFO_OFFSET),
>>>>  + .datasheet_name = "temp_adc",
>>>>  + },
>>>>  +};
>>>>  +
>>>>  +static const struct regmap_config sun4i_gpadc_regmap_config = {
>>>>  + .reg_bits = 32,
>>>>  + .val_bits = 32,
>>>>  + .reg_stride = 4,
>>>>  + .fast_io = true,
>>>>  +};
>>>>  +
>>>>   static int sun4i_prepare_for_irq(struct iio_dev *indio_dev, int channel,
>>>>                                    unsigned int irq)
>>>>   {
>>>>  @@ -247,6 +271,17 @@ static int sun4i_gpadc_temp_read(struct iio_dev *indio_dev, int *val)
>>>>   {
>>>>           struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
>>>>
>>>>  + if (info->no_irq) {
>>>>  + pm_runtime_get_sync(indio_dev->dev.parent);
>>>>  +
>>>>  + regmap_read(info->regmap, SUN4I_GPADC_TEMP_DATA, val);
>>>>  +
>>>>  + pm_runtime_mark_last_busy(indio_dev->dev.parent);
>>>>  + pm_runtime_put_autosuspend(indio_dev->dev.parent);
>>>>  +
>>>>  + return 0;
>>>>  + }
>>>>  +
>>>>           return sun4i_gpadc_read(indio_dev, 0, val, info->temp_data_irq);
>>>>   }
>>>>
>>>>  @@ -454,6 +489,58 @@ static int sun4i_irq_init(struct platform_device *pdev, const char *name,
>>>>           return 0;
>>>>   }
>>>>
>>>>  +static const struct of_device_id sun4i_gpadc_of_id[] = {
>>>>  + {
>>>>  + .compatible = "allwinner,sun8i-a33-gpadc-iio",
>>>>  + .data = &sun8i_a33_gpadc_data,
>>>>  + },
>>>>  + { /* sentinel */ }
>>>>  +};
>>>>  +
>>>>  +static int sun4i_gpadc_probe_dt(struct platform_device *pdev,
>>>>  + struct iio_dev *indio_dev)
>>>>  +{
>>>>  + struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
>>>>  + const struct of_device_id *of_dev;
>>>>  + struct thermal_zone_device *tzd;
>>>>  + struct resource *mem;
>>>>  + void __iomem *base;
>>>>  + int ret;
>>>>  +
>>>>  + of_dev = of_match_device(sun4i_gpadc_of_id, &pdev->dev);
>>>>  + if (!of_dev)
>>>>  + return -ENODEV;
>>>>  +
>>>>  + info->no_irq = true;
>>>>  + info->data = (struct gpadc_data *)of_dev->data;
>>>>  + indio_dev->num_channels = ARRAY_SIZE(sun8i_a33_gpadc_channels);
>>>>  + indio_dev->channels = sun8i_a33_gpadc_channels;
>>>>  +
>>>>  + mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>>>>  + base = devm_ioremap_resource(&pdev->dev, mem);
>>>>  + if (IS_ERR(base))
>>>>  + return PTR_ERR(base);
>>>>  +
>>>>  + info->regmap = devm_regmap_init_mmio(&pdev->dev, base,
>>>>  + &sun4i_gpadc_regmap_config);
>>>>  + if (IS_ERR(info->regmap)) {
>>>>  + ret = PTR_ERR(info->regmap);
>>>>  + dev_err(&pdev->dev, "failed to init regmap: %d\n", ret);
>>>>  + return ret;
>>>>  + }
>>>>  +
>>>>  + if (!IS_ENABLED(THERMAL_OF))
>>>>  + return 0;
>>>>  +
>>>>  + tzd = devm_thermal_zone_of_sensor_register(&pdev->dev, 0, info,
>>>>  + &sun4i_ts_tz_ops);
>>>>  + if (IS_ERR(tzd))
>>>>  + dev_err(&pdev->dev, "could not register thermal sensor: %ld\n",
>>>>  + PTR_ERR(tzd));
>>>>  +
>>>>  + return PTR_ERR_OR_ZERO(tzd);
>>>>  +}
>>>>  +
>>>>   static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
>>>>                                    struct iio_dev *indio_dev)
>>>>   {
>>>>  @@ -462,6 +549,7 @@ static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
>>>>                   dev_get_drvdata(pdev->dev.parent);
>>>>           int ret;
>>>>
>>>>  + info->no_irq = false;
>>>>           info->regmap = sun4i_gpadc_dev->regmap;
>>>>
>>>>           indio_dev->num_channels = ARRAY_SIZE(sun4i_gpadc_channels);
>>>>  @@ -561,7 +649,11 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>>>>           indio_dev->info = &sun4i_gpadc_iio_info;
>>>>           indio_dev->modes = INDIO_DIRECT_MODE;
>>>>
>>>>  - ret = sun4i_gpadc_probe_mfd(pdev, indio_dev);
>>>>  + if (pdev->dev.of_node)
>>>>  + ret = sun4i_gpadc_probe_dt(pdev, indio_dev);
>>>>  + else
>>>>  + ret = sun4i_gpadc_probe_mfd(pdev, indio_dev);
>>>>  +
>>>>           if (ret)
>>>>                   return ret;
>>>>
>>>>  @@ -580,7 +672,7 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>>>>           return 0;
>>>>
>>>>   err_map:
>>>>  - if (IS_ENABLED(CONFIG_THERMAL_OF))
>>>>  + if (!info->no_irq && IS_ENABLED(CONFIG_THERMAL_OF))
>>>>                   iio_map_array_unregister(indio_dev);
>>>>
>>>>           pm_runtime_put(&pdev->dev);
>>>>  @@ -592,10 +684,11 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>>>>   static int sun4i_gpadc_remove(struct platform_device *pdev)
>>>>   {
>>>>           struct iio_dev *indio_dev = platform_get_drvdata(pdev);
>>>>  + struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
>>>>
>>>>           pm_runtime_put(&pdev->dev);
>>>>           pm_runtime_disable(&pdev->dev);
>>>>  - if (IS_ENABLED(CONFIG_THERMAL_OF))
>>>>  + if (!info->no_irq && IS_ENABLED(CONFIG_THERMAL_OF))
>>>>                   iio_map_array_unregister(indio_dev);
>>>>
>>>>           return 0;
>>>>  @@ -611,6 +704,7 @@ static const struct platform_device_id sun4i_gpadc_id[] = {
>>>>   static struct platform_driver sun4i_gpadc_driver = {
>>>>           .driver = {
>>>>                   .name = "sun4i-gpadc-iio",
>>>>  + .of_match_table = sun4i_gpadc_of_id,
>>>>                   .pm = &sun4i_gpadc_pm_ops,
>>>>           },
>>>>           .id_table = sun4i_gpadc_id,
>>>>  diff --git a/include/linux/mfd/sun4i-gpadc.h b/include/linux/mfd/sun4i-gpadc.h
>>>>  index 509e736..139872c 100644
>>>>  --- a/include/linux/mfd/sun4i-gpadc.h
>>>>  +++ b/include/linux/mfd/sun4i-gpadc.h
>>>>  @@ -38,6 +38,10 @@
>>>>   #define SUN6I_GPADC_CTRL1_ADC_CHAN_SELECT(x) (GENMASK(3, 0) & BIT(x))
>>>>   #define SUN6I_GPADC_CTRL1_ADC_CHAN_MASK GENMASK(3, 0)
>>>>
>>>>  +/* TP_CTRL1 bits for sun8i SoCs */
>>>>  +#define SUN8I_GPADC_CTRL1_CHOP_TEMP_EN BIT(8)
>>>>  +#define SUN8I_GPADC_CTRL1_GPADC_CALI_EN BIT(7)
>>>>  +
>>>>   #define SUN4I_GPADC_CTRL2 0x08
>>>>
>>>>   #define SUN4I_GPADC_CTRL2_TP_SENSITIVE_ADJUST(x) ((GENMASK(3, 0) & (x)) << 28)
>>>
>>> _______________________________________________
>>> linux-arm-kernel mailing list
>>> linux-arm-kernel at lists.infradead.org
>>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> 

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH v2 05/11] Documentation: DT: bindings: mfd: add A33 GPADC binding
@ 2017-03-20  8:45           ` maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8
  0 siblings, 0 replies; 85+ messages in thread
From: maxime.ripard @ 2017-03-20  8:45 UTC (permalink / raw)
  To: Quentin Schulz
  Cc: Icenowy Zheng, dmitry.torokhov, robh+dt, mark.rutland, wens,
	lee.jones, linux, jic23, knaack.h, lars, pmeerw,
	stefan.mavrodiev, thomas.petazzoni, devicetree, linux-iio,
	linux-kernel, linux-sunxi, linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 2234 bytes --]

Hi,

On Sat, Mar 11, 2017 at 03:07:55PM +0100, Quentin Schulz wrote:
> Hi Icenowy,
> 
> On 10/03/2017 20:25, Icenowy Zheng wrote:
> > 
> > 
> > 10.03.2017, 18:56, "Quentin Schulz" <quentin.schulz@free-electrons.com>:
> >> This patch adds documentation for the A33 GPADC binding.
> >>
> >> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
> >> ---
> >>
> >> added in v2
> >>
> >>  .../devicetree/bindings/mfd/sun4i-gpadc.txt | 59 ++++++++++++++++++++++
> >>  1 file changed, 59 insertions(+)
> >>  create mode 100644 Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
> >>
> >> diff --git a/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt b/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
> >> new file mode 100644
> >> index 0000000..17242c8
> >> --- /dev/null
> >> +++ b/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
> >> @@ -0,0 +1,59 @@
> >> +Allwinner SoCs' GPADC Device Tree bindings
> >> +------------------------------------------
> >> +The Allwinner SoCs all have an ADC that can also act as a thermal sensor
> >> +and sometimes as a touchscreen controller.
> >> +
> >> +Required properties:
> >> + - compatible: "sun8i-a33-gpadc-iio",
> >> + - reg: mmio address range of the chip,
> >> + - #thermal-sensor-cells: shall be 0,
> >> + - #io-channel-cells: shall be 0,
> >> +
> >> +Example:
> >> + rtp: rtp@01c25000 {
> > 
> > I think we'd better call it ths.
> 
> To match the datasheet, I agree.

I agree too.

> > And can you make thermal-sensor-cells become 1?
> > 
> > Maxime Ripard wants to base H3/H5/A64 thermal driver on this patchset, and
> > for H5/A64 there's 2/3 thermal sensors.
> 
> Yes, that'll require a specific DT node for those thermal sensors. Then
> since we would update the possible compatibles in the documentation
> anyway, that would be a good idea to update to say that
> thermal-sensor-cells could be different from 0 too.
> 
> That was my mindset to set thermal-sensor-cells to 0, since we only
> support SoC which has only one thermal sensor at the moment.

And I agree here as well.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH v2 05/11] Documentation: DT: bindings: mfd: add A33 GPADC binding
@ 2017-03-20  8:45           ` maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8
  0 siblings, 0 replies; 85+ messages in thread
From: maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8 @ 2017-03-20  8:45 UTC (permalink / raw)
  To: Quentin Schulz
  Cc: Icenowy Zheng, dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	wens-jdAy2FN1RRM, lee.jones-QSEj5FYQhm4dnm+yROfE0A,
	linux-I+IVW8TIWO2tmTQ+vhA3Yw, jic23-DgEjT+Ai2ygdnm+yROfE0A,
	knaack.h-Mmb7MZpHnFY, lars-Qo5EllUWu/uELgA04lAiVw,
	pmeerw-jW+XmwGofnusTnJN9+BGXg,
	stefan.mavrodiev-Re5JQEeQqe8AvxtiuMwx3w,
	thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-iio-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

[-- Attachment #1: Type: text/plain, Size: 2228 bytes --]

Hi,

On Sat, Mar 11, 2017 at 03:07:55PM +0100, Quentin Schulz wrote:
> Hi Icenowy,
> 
> On 10/03/2017 20:25, Icenowy Zheng wrote:
> > 
> > 
> > 10.03.2017, 18:56, "Quentin Schulz" <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>:
> >> This patch adds documentation for the A33 GPADC binding.
> >>
> >> Signed-off-by: Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> >> ---
> >>
> >> added in v2
> >>
> >>  .../devicetree/bindings/mfd/sun4i-gpadc.txt | 59 ++++++++++++++++++++++
> >>  1 file changed, 59 insertions(+)
> >>  create mode 100644 Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
> >>
> >> diff --git a/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt b/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
> >> new file mode 100644
> >> index 0000000..17242c8
> >> --- /dev/null
> >> +++ b/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
> >> @@ -0,0 +1,59 @@
> >> +Allwinner SoCs' GPADC Device Tree bindings
> >> +------------------------------------------
> >> +The Allwinner SoCs all have an ADC that can also act as a thermal sensor
> >> +and sometimes as a touchscreen controller.
> >> +
> >> +Required properties:
> >> + - compatible: "sun8i-a33-gpadc-iio",
> >> + - reg: mmio address range of the chip,
> >> + - #thermal-sensor-cells: shall be 0,
> >> + - #io-channel-cells: shall be 0,
> >> +
> >> +Example:
> >> + rtp: rtp@01c25000 {
> > 
> > I think we'd better call it ths.
> 
> To match the datasheet, I agree.

I agree too.

> > And can you make thermal-sensor-cells become 1?
> > 
> > Maxime Ripard wants to base H3/H5/A64 thermal driver on this patchset, and
> > for H5/A64 there's 2/3 thermal sensors.
> 
> Yes, that'll require a specific DT node for those thermal sensors. Then
> since we would update the possible compatibles in the documentation
> anyway, that would be a good idea to update to say that
> thermal-sensor-cells could be different from 0 too.
> 
> That was my mindset to set thermal-sensor-cells to 0, since we only
> support SoC which has only one thermal sensor at the moment.

And I agree here as well.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH v2 05/11] Documentation: DT: bindings: mfd: add A33 GPADC binding
@ 2017-03-20  8:45           ` maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8
  0 siblings, 0 replies; 85+ messages in thread
From: maxime.ripard @ 2017-03-20  8:45 UTC (permalink / raw)
  To: Quentin Schulz
  Cc: Icenowy Zheng, dmitry.torokhov, robh+dt, mark.rutland, wens,
	lee.jones, linux, jic23, knaack.h, lars, pmeerw,
	stefan.mavrodiev, thomas.petazzoni, devicetree, linux-iio,
	linux-kernel, linux-sunxi, linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 2234 bytes --]

Hi,

On Sat, Mar 11, 2017 at 03:07:55PM +0100, Quentin Schulz wrote:
> Hi Icenowy,
> 
> On 10/03/2017 20:25, Icenowy Zheng wrote:
> > 
> > 
> > 10.03.2017, 18:56, "Quentin Schulz" <quentin.schulz@free-electrons.com>:
> >> This patch adds documentation for the A33 GPADC binding.
> >>
> >> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
> >> ---
> >>
> >> added in v2
> >>
> >>  .../devicetree/bindings/mfd/sun4i-gpadc.txt | 59 ++++++++++++++++++++++
> >>  1 file changed, 59 insertions(+)
> >>  create mode 100644 Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
> >>
> >> diff --git a/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt b/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
> >> new file mode 100644
> >> index 0000000..17242c8
> >> --- /dev/null
> >> +++ b/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
> >> @@ -0,0 +1,59 @@
> >> +Allwinner SoCs' GPADC Device Tree bindings
> >> +------------------------------------------
> >> +The Allwinner SoCs all have an ADC that can also act as a thermal sensor
> >> +and sometimes as a touchscreen controller.
> >> +
> >> +Required properties:
> >> + - compatible: "sun8i-a33-gpadc-iio",
> >> + - reg: mmio address range of the chip,
> >> + - #thermal-sensor-cells: shall be 0,
> >> + - #io-channel-cells: shall be 0,
> >> +
> >> +Example:
> >> + rtp: rtp@01c25000 {
> > 
> > I think we'd better call it ths.
> 
> To match the datasheet, I agree.

I agree too.

> > And can you make thermal-sensor-cells become 1?
> > 
> > Maxime Ripard wants to base H3/H5/A64 thermal driver on this patchset, and
> > for H5/A64 there's 2/3 thermal sensors.
> 
> Yes, that'll require a specific DT node for those thermal sensors. Then
> since we would update the possible compatibles in the documentation
> anyway, that would be a good idea to update to say that
> thermal-sensor-cells could be different from 0 too.
> 
> That was my mindset to set thermal-sensor-cells to 0, since we only
> support SoC which has only one thermal sensor at the moment.

And I agree here as well.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

^ permalink raw reply	[flat|nested] 85+ messages in thread

* [PATCH v2 05/11] Documentation: DT: bindings: mfd: add A33 GPADC binding
@ 2017-03-20  8:45           ` maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8
  0 siblings, 0 replies; 85+ messages in thread
From: maxime.ripard at free-electrons.com @ 2017-03-20  8:45 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

On Sat, Mar 11, 2017 at 03:07:55PM +0100, Quentin Schulz wrote:
> Hi Icenowy,
> 
> On 10/03/2017 20:25, Icenowy Zheng wrote:
> > 
> > 
> > 10.03.2017, 18:56, "Quentin Schulz" <quentin.schulz@free-electrons.com>:
> >> This patch adds documentation for the A33 GPADC binding.
> >>
> >> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
> >> ---
> >>
> >> added in v2
> >>
> >>  .../devicetree/bindings/mfd/sun4i-gpadc.txt | 59 ++++++++++++++++++++++
> >>  1 file changed, 59 insertions(+)
> >>  create mode 100644 Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
> >>
> >> diff --git a/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt b/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
> >> new file mode 100644
> >> index 0000000..17242c8
> >> --- /dev/null
> >> +++ b/Documentation/devicetree/bindings/mfd/sun4i-gpadc.txt
> >> @@ -0,0 +1,59 @@
> >> +Allwinner SoCs' GPADC Device Tree bindings
> >> +------------------------------------------
> >> +The Allwinner SoCs all have an ADC that can also act as a thermal sensor
> >> +and sometimes as a touchscreen controller.
> >> +
> >> +Required properties:
> >> + - compatible: "sun8i-a33-gpadc-iio",
> >> + - reg: mmio address range of the chip,
> >> + - #thermal-sensor-cells: shall be 0,
> >> + - #io-channel-cells: shall be 0,
> >> +
> >> +Example:
> >> + rtp: rtp at 01c25000 {
> > 
> > I think we'd better call it ths.
> 
> To match the datasheet, I agree.

I agree too.

> > And can you make thermal-sensor-cells become 1?
> > 
> > Maxime Ripard wants to base H3/H5/A64 thermal driver on this patchset, and
> > for H5/A64 there's 2/3 thermal sensors.
> 
> Yes, that'll require a specific DT node for those thermal sensors. Then
> since we would update the possible compatibles in the documentation
> anyway, that would be a good idea to update to say that
> thermal-sensor-cells could be different from 0 too.
> 
> That was my mindset to set thermal-sensor-cells to 0, since we only
> support SoC which has only one thermal sensor at the moment.

And I agree here as well.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170320/e15c6e41/attachment.sig>

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH v2 06/11] Documentation: DT: bindings: input: touschcreen: remove sun4i documentation
@ 2017-03-20 15:09     ` Rob Herring
  0 siblings, 0 replies; 85+ messages in thread
From: Rob Herring @ 2017-03-20 15:09 UTC (permalink / raw)
  To: Quentin Schulz
  Cc: dmitry.torokhov, mark.rutland, maxime.ripard, wens, lee.jones,
	linux, jic23, knaack.h, lars, pmeerw, stefan.mavrodiev,
	devicetree, linux-arm-kernel, linux-kernel, linux-iio,
	linux-sunxi, thomas.petazzoni

On Fri, Mar 10, 2017 at 11:39:16AM +0100, Quentin Schulz wrote:
> This patch removes the sun4i touchscreen controller binding
> documentation since it has been merged with the sun4i GPADC binding
> documentation.
> 
> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
> ---
> 
> added in v2
> 
>  .../bindings/input/touchscreen/sun4i.txt           | 38 ----------------------
>  1 file changed, 38 deletions(-)
>  delete mode 100644 Documentation/devicetree/bindings/input/touchscreen/sun4i.txt

Acked-by: Rob Herring <robh@kernel.org>

^ permalink raw reply	[flat|nested] 85+ messages in thread

* Re: [PATCH v2 06/11] Documentation: DT: bindings: input: touschcreen: remove sun4i documentation
@ 2017-03-20 15:09     ` Rob Herring
  0 siblings, 0 replies; 85+ messages in thread
From: Rob Herring @ 2017-03-20 15:09 UTC (permalink / raw)
  To: Quentin Schulz
  Cc: dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w, mark.rutland-5wv7dgnIgG8,
	maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8, wens-jdAy2FN1RRM,
	lee.jones-QSEj5FYQhm4dnm+yROfE0A, linux-I+IVW8TIWO2tmTQ+vhA3Yw,
	jic23-DgEjT+Ai2ygdnm+yROfE0A, knaack.h-Mmb7MZpHnFY,
	lars-Qo5EllUWu/uELgA04lAiVw, pmeerw-jW+XmwGofnusTnJN9+BGXg,
	stefan.mavrodiev-Re5JQEeQqe8AvxtiuMwx3w,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-iio-u79uwXL29TY76Z2rM5mHXA,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
	thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8

On Fri, Mar 10, 2017 at 11:39:16AM +0100, Quentin Schulz wrote:
> This patch removes the sun4i touchscreen controller binding
> documentation since it has been merged with the sun4i GPADC binding
> documentation.
> 
> Signed-off-by: Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> ---
> 
> added in v2
> 
>  .../bindings/input/touchscreen/sun4i.txt           | 38 ----------------------
>  1 file changed, 38 deletions(-)
>  delete mode 100644 Documentation/devicetree/bindings/input/touchscreen/sun4i.txt

Acked-by: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>

^ permalink raw reply	[flat|nested] 85+ messages in thread

* [PATCH v2 06/11] Documentation: DT: bindings: input: touschcreen: remove sun4i documentation
@ 2017-03-20 15:09     ` Rob Herring
  0 siblings, 0 replies; 85+ messages in thread
From: Rob Herring @ 2017-03-20 15:09 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Mar 10, 2017 at 11:39:16AM +0100, Quentin Schulz wrote:
> This patch removes the sun4i touchscreen controller binding
> documentation since it has been merged with the sun4i GPADC binding
> documentation.
> 
> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
> ---
> 
> added in v2
> 
>  .../bindings/input/touchscreen/sun4i.txt           | 38 ----------------------
>  1 file changed, 38 deletions(-)
>  delete mode 100644 Documentation/devicetree/bindings/input/touchscreen/sun4i.txt

Acked-by: Rob Herring <robh@kernel.org>

^ permalink raw reply	[flat|nested] 85+ messages in thread

end of thread, other threads:[~2017-03-20 15:10 UTC | newest]

Thread overview: 85+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-10 10:39 [PATCH v2 00/11] add thermal throttling to Allwinner A33 SoC Quentin Schulz
2017-03-10 10:39 ` Quentin Schulz
2017-03-10 10:39 ` Quentin Schulz
2017-03-10 10:39 ` [PATCH v2 01/11] ARM: sun8i: a33: add operating-points-v2 property to all nodes Quentin Schulz
2017-03-10 10:39   ` Quentin Schulz
2017-03-10 10:39   ` Quentin Schulz
2017-03-10 10:39 ` [PATCH v2 02/11] ARM: sun8i: a33: add all operating points Quentin Schulz
2017-03-10 10:39   ` Quentin Schulz
2017-03-10 10:39   ` Quentin Schulz
2017-03-10 10:39 ` [PATCH v2 03/11] ARM: dts: sun8i: sina33: add cpu-supply Quentin Schulz
2017-03-10 10:39   ` Quentin Schulz
2017-03-10 10:39   ` Quentin Schulz
2017-03-10 10:39 ` [PATCH v2 04/11] ARM: dts: sun8i: olinuxino: " Quentin Schulz
2017-03-10 10:39   ` Quentin Schulz
2017-03-10 10:39   ` Quentin Schulz
2017-03-10 10:39 ` [PATCH v2 05/11] Documentation: DT: bindings: mfd: add A33 GPADC binding Quentin Schulz
2017-03-10 10:39   ` Quentin Schulz
2017-03-10 10:39   ` Quentin Schulz
2017-03-10 12:25   ` Maxime Ripard
2017-03-10 12:25     ` Maxime Ripard
2017-03-10 12:25     ` Maxime Ripard
2017-03-10 19:33     ` Icenowy Zheng
2017-03-10 19:33       ` Icenowy Zheng
2017-03-10 19:33       ` Icenowy Zheng
     [not found]   ` <20170310103921.19469-6-quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2017-03-10 19:25     ` Icenowy Zheng
2017-03-10 19:25       ` Icenowy Zheng
2017-03-10 19:25       ` Icenowy Zheng
2017-03-11 14:07       ` Quentin Schulz
2017-03-11 14:07         ` Quentin Schulz
2017-03-11 14:07         ` Quentin Schulz
2017-03-11 14:07         ` Quentin Schulz
2017-03-20  8:45         ` maxime.ripard
2017-03-20  8:45           ` maxime.ripard at free-electrons.com
2017-03-20  8:45           ` maxime.ripard
2017-03-20  8:45           ` maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8
2017-03-10 10:39 ` [PATCH v2 06/11] Documentation: DT: bindings: input: touschcreen: remove sun4i documentation Quentin Schulz
2017-03-10 10:39   ` Quentin Schulz
2017-03-10 10:39   ` Quentin Schulz
2017-03-20 15:09   ` Rob Herring
2017-03-20 15:09     ` Rob Herring
2017-03-20 15:09     ` Rob Herring
2017-03-10 10:39 ` [PATCH v2 07/11] iio: adc: sun4i-gpadc-iio: move code used in MFD probing to new function Quentin Schulz
2017-03-10 10:39   ` Quentin Schulz
2017-03-10 10:39   ` Quentin Schulz
     [not found]   ` <20170310103921.19469-8-quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2017-03-10 19:36     ` Icenowy Zheng
2017-03-10 19:36       ` Icenowy Zheng
2017-03-10 19:36       ` Icenowy Zheng
2017-03-11 14:09       ` Quentin Schulz
2017-03-11 14:09         ` Quentin Schulz
2017-03-11 14:09         ` Quentin Schulz
2017-03-11 14:09         ` Quentin Schulz
2017-03-13 20:58   ` Jonathan Cameron
2017-03-13 20:58     ` Jonathan Cameron
2017-03-13 20:58     ` Jonathan Cameron
2017-03-10 10:39 ` [PATCH v2 08/11] iio: adc: sun4i-gpadc-iio: add support for A33 thermal sensor Quentin Schulz
2017-03-10 10:39   ` Quentin Schulz
2017-03-10 10:39   ` Quentin Schulz
2017-03-13 21:06   ` Jonathan Cameron
2017-03-13 21:06     ` Jonathan Cameron
2017-03-13 21:06     ` Jonathan Cameron
     [not found]     ` <c70640c7-7dd9-dc7c-b751-430b2ad59245-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2017-03-14  5:18       ` Icenowy Zheng
2017-03-14  5:18         ` Icenowy Zheng
2017-03-14  5:18         ` Icenowy Zheng
2017-03-14  7:15         ` Quentin Schulz
2017-03-14  7:15           ` Quentin Schulz
2017-03-14  7:15           ` Quentin Schulz
2017-03-14  7:15           ` Quentin Schulz
2017-03-18 14:18           ` Jonathan Cameron
2017-03-18 14:18             ` Jonathan Cameron
2017-03-18 14:18             ` Jonathan Cameron
2017-03-15 10:38   ` Lee Jones
2017-03-15 10:38     ` Lee Jones
2017-03-15 10:38     ` Lee Jones
2017-03-10 10:39 ` [PATCH v2 09/11] ARM: dtsi: sun8i: a33: add " Quentin Schulz
2017-03-10 10:39   ` Quentin Schulz
2017-03-10 10:39   ` Quentin Schulz
     [not found]   ` <20170310103921.19469-10-quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2017-03-10 19:28     ` Icenowy Zheng
2017-03-10 19:28       ` Icenowy Zheng
2017-03-10 19:28       ` Icenowy Zheng
2017-03-10 10:39 ` [PATCH v2 10/11] ARM: dtsi: sun8i: a33: add CPU thermal throttling Quentin Schulz
2017-03-10 10:39   ` Quentin Schulz
2017-03-10 10:39   ` Quentin Schulz
2017-03-10 10:39 ` [PATCH v2 11/11] ARM: sun8i: a33: Add devfreq-based GPU cooling Quentin Schulz
2017-03-10 10:39   ` Quentin Schulz
2017-03-10 10:39   ` Quentin Schulz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.