mbox series

[v7,0/7] add thermal sensor driver for A64, A83T, H3, H5, H6, R40

Message ID 20191218042121.1471954-1-anarsoul@gmail.com
Headers show
Series add thermal sensor driver for A64, A83T, H3, H5, H6, R40 | expand

Message

Vasily Khoruzhick Dec. 18, 2019, 4:21 a.m. UTC
This patchset adds driver for thermal sensor in A64, A83T, H3, H5,
H6 and R40 SoCs.

v7:
	- [vasily] Address Maxime's comments for dt-schema
	- [vasily] Move common part of H3 and H5 dts into sunxi-h3-h5.dtsi
	- [vasily] Add Maxime's a-b to the driver patch 

v6:
	- [ondrej, vasily] Squash all driver related changes into a
			   single patch
	- [ondrej] Rename calib -> calibration
	- [ondrej] Fix thermal zone registration check
	- [ondrej] Lower rate of sensor data interrupts to 4/sec/sensor
	- [ondrej] Rework scale/offset values, H6 calibration
	- [ondrej] Explicitly set mod clock to 24 MHz
	- [ondrej] Set undocumented bits in CTRL0 for H6
	- [ondrej] Add support for A83T
	- [ondrej] Add dts changes for A83T, H3, H5, H6
	- [vasily] Add dts changes for A64
	- [vasily] Address Maxime's comments for YAML scheme
	- [vasily] Make .calc_temp callback mandatory
	- [vasily] Set .max_register in regmap config, so regs can be
		   inspected using debugfs


Ondrej Jirman (4):
  ARM: dts: sun8i-a83t: Add thermal sensor and thermal zones
  ARM: dts: sun8i-h3: Add thermal sensor and thermal zones
  arm64: dts: allwinner: h5: Add thermal sensor and thermal zones
  arm64: dts: allwinner: h6: Add thermal sensor and thermal zones

Vasily Khoruzhick (1):
  arm64: dts: allwinner: a64: Add thermal sensors and thermal zones

Yangtao Li (2):
  thermal: sun8i: add thermal driver for H6/H5/H3/A64/A83T/R40
  dt-bindings: thermal: add YAML schema for sun8i-thermal driver
    bindings

 .../thermal/allwinner,sun8i-a83t-ths.yaml     | 146 ++++
 MAINTAINERS                                   |   7 +
 arch/arm/boot/dts/sun8i-a83t.dtsi             |  36 +
 arch/arm/boot/dts/sun8i-h3.dtsi               |  20 +
 arch/arm/boot/dts/sunxi-h3-h5.dtsi            |   6 +
 arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi |  42 ++
 arch/arm64/boot/dts/allwinner/sun50i-h5.dtsi  |  26 +
 arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi  |  33 +
 drivers/thermal/Kconfig                       |  14 +
 drivers/thermal/Makefile                      |   1 +
 drivers/thermal/sun8i_thermal.c               | 639 ++++++++++++++++++
 11 files changed, 970 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/thermal/allwinner,sun8i-a83t-ths.yaml
 create mode 100644 drivers/thermal/sun8i_thermal.c

Comments

Chen-Yu Tsai Dec. 18, 2019, 4:32 a.m. UTC | #1
On Wed, Dec 18, 2019 at 12:22 PM Vasily Khoruzhick <anarsoul@gmail.com> wrote:
>
> From: Ondrej Jirman <megous@megous.com>
>
> There are two sensors, one for CPU, one for GPU.
>
> Signed-off-by: Ondrej Jirman <megous@megous.com>
> Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
> ---
>  arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi | 33 ++++++++++++++++++++
>  1 file changed, 33 insertions(+)
>
> diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
> index 29824081b43b..cdcb1a36301a 100644
> --- a/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
> +++ b/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
> @@ -11,6 +11,7 @@
>  #include <dt-bindings/reset/sun50i-h6-ccu.h>
>  #include <dt-bindings/reset/sun50i-h6-r-ccu.h>
>  #include <dt-bindings/reset/sun8i-de2.h>
> +#include <dt-bindings/thermal/thermal.h>
>
>  / {
>         interrupt-parent = <&gic>;
> @@ -233,6 +234,12 @@ dma: dma-controller@3002000 {
>                 sid: efuse@3006000 {
>                         compatible = "allwinner,sun50i-h6-sid";
>                         reg = <0x03006000 0x400>;
> +                       #address-cells = <1>;
> +                       #size-cells = <1>;
> +
> +                       ths_calibration: thermal-sensor-calibration@14 {
> +                               reg = <0x14 0x6>;

Nit: my preference is to use words as the smallest increment, so this
would have a size of 8 instead of 6. Same goes for the A64 dts.

AFAICT this doesn't impact the driver in any way.

ChenYu


> +                       };
>                 };
>
>                 watchdog: watchdog@30090a0 {
> @@ -856,5 +863,31 @@ r_i2c: i2c@7081400 {
>                         #address-cells = <1>;
>                         #size-cells = <0>;
>                 };
> +
> +               ths: thermal-sensor@5070400 {
> +                       compatible = "allwinner,sun50i-h6-ths";
> +                       reg = <0x05070400 0x100>;
> +                       interrupts = <GIC_SPI 15 IRQ_TYPE_LEVEL_HIGH>;
> +                       clocks = <&ccu CLK_BUS_THS>;
> +                       clock-names = "bus";
> +                       resets = <&ccu RST_BUS_THS>;
> +                       nvmem-cells = <&ths_calibration>;
> +                       nvmem-cell-names = "calibration";
> +                       #thermal-sensor-cells = <1>;
> +               };
> +       };
> +
> +       thermal-zones {
> +               cpu-thermal {
> +                       polling-delay-passive = <0>;
> +                       polling-delay = <0>;
> +                       thermal-sensors = <&ths 0>;
> +               };
> +
> +               gpu-thermal {
> +                       polling-delay-passive = <0>;
> +                       polling-delay = <0>;
> +                       thermal-sensors = <&ths 1>;
> +               };
>         };
>  };
> --
> 2.24.1
>
Vasily Khoruzhick Dec. 18, 2019, 11:18 p.m. UTC | #2
On Tue, Dec 17, 2019 at 8:32 PM Chen-Yu Tsai <wens@csie.org> wrote:
>
> On Wed, Dec 18, 2019 at 12:22 PM Vasily Khoruzhick <anarsoul@gmail.com> wrote:
> >
> > From: Ondrej Jirman <megous@megous.com>
> >
> > There are two sensors, one for CPU, one for GPU.
> >
> > Signed-off-by: Ondrej Jirman <megous@megous.com>
> > Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
> > ---
> >  arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi | 33 ++++++++++++++++++++
> >  1 file changed, 33 insertions(+)
> >
> > diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
> > index 29824081b43b..cdcb1a36301a 100644
> > --- a/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
> > +++ b/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
> > @@ -11,6 +11,7 @@
> >  #include <dt-bindings/reset/sun50i-h6-ccu.h>
> >  #include <dt-bindings/reset/sun50i-h6-r-ccu.h>
> >  #include <dt-bindings/reset/sun8i-de2.h>
> > +#include <dt-bindings/thermal/thermal.h>
> >
> >  / {
> >         interrupt-parent = <&gic>;
> > @@ -233,6 +234,12 @@ dma: dma-controller@3002000 {
> >                 sid: efuse@3006000 {
> >                         compatible = "allwinner,sun50i-h6-sid";
> >                         reg = <0x03006000 0x400>;
> > +                       #address-cells = <1>;
> > +                       #size-cells = <1>;
> > +
> > +                       ths_calibration: thermal-sensor-calibration@14 {
> > +                               reg = <0x14 0x6>;
>
> Nit: my preference is to use words as the smallest increment, so this
> would have a size of 8 instead of 6. Same goes for the A64 dts.
>
> AFAICT this doesn't impact the driver in any way.

H6 has only 2 sensors, so it should be 4. That's my overlook, I'll
change it to 4 for H6 and to 8 for A64.

>
> ChenYu
>
>
> > +                       };
> >                 };
> >
> >                 watchdog: watchdog@30090a0 {
> > @@ -856,5 +863,31 @@ r_i2c: i2c@7081400 {
> >                         #address-cells = <1>;
> >                         #size-cells = <0>;
> >                 };
> > +
> > +               ths: thermal-sensor@5070400 {
> > +                       compatible = "allwinner,sun50i-h6-ths";
> > +                       reg = <0x05070400 0x100>;
> > +                       interrupts = <GIC_SPI 15 IRQ_TYPE_LEVEL_HIGH>;
> > +                       clocks = <&ccu CLK_BUS_THS>;
> > +                       clock-names = "bus";
> > +                       resets = <&ccu RST_BUS_THS>;
> > +                       nvmem-cells = <&ths_calibration>;
> > +                       nvmem-cell-names = "calibration";
> > +                       #thermal-sensor-cells = <1>;
> > +               };
> > +       };
> > +
> > +       thermal-zones {
> > +               cpu-thermal {
> > +                       polling-delay-passive = <0>;
> > +                       polling-delay = <0>;
> > +                       thermal-sensors = <&ths 0>;
> > +               };
> > +
> > +               gpu-thermal {
> > +                       polling-delay-passive = <0>;
> > +                       polling-delay = <0>;
> > +                       thermal-sensors = <&ths 1>;
> > +               };
> >         };
> >  };
> > --
> > 2.24.1
> >
Ondřej Jirman Dec. 19, 2019, 1:03 a.m. UTC | #3
On Wed, Dec 18, 2019 at 03:18:51PM -0800, Vasily Khoruzhick wrote:
> On Tue, Dec 17, 2019 at 8:32 PM Chen-Yu Tsai <wens@csie.org> wrote:
> >
> > On Wed, Dec 18, 2019 at 12:22 PM Vasily Khoruzhick <anarsoul@gmail.com> wrote:
> > >
> > > From: Ondrej Jirman <megous@megous.com>
> > >
> > > There are two sensors, one for CPU, one for GPU.
> > >
> > > Signed-off-by: Ondrej Jirman <megous@megous.com>
> > > Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
> > > ---
> > >  arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi | 33 ++++++++++++++++++++
> > >  1 file changed, 33 insertions(+)
> > >
> > > diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
> > > index 29824081b43b..cdcb1a36301a 100644
> > > --- a/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
> > > +++ b/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
> > > @@ -11,6 +11,7 @@
> > >  #include <dt-bindings/reset/sun50i-h6-ccu.h>
> > >  #include <dt-bindings/reset/sun50i-h6-r-ccu.h>
> > >  #include <dt-bindings/reset/sun8i-de2.h>
> > > +#include <dt-bindings/thermal/thermal.h>
> > >
> > >  / {
> > >         interrupt-parent = <&gic>;
> > > @@ -233,6 +234,12 @@ dma: dma-controller@3002000 {
> > >                 sid: efuse@3006000 {
> > >                         compatible = "allwinner,sun50i-h6-sid";
> > >                         reg = <0x03006000 0x400>;
> > > +                       #address-cells = <1>;
> > > +                       #size-cells = <1>;
> > > +
> > > +                       ths_calibration: thermal-sensor-calibration@14 {
> > > +                               reg = <0x14 0x6>;
> >
> > Nit: my preference is to use words as the smallest increment, so this
> > would have a size of 8 instead of 6. Same goes for the A64 dts.
> >
> > AFAICT this doesn't impact the driver in any way.
> 
> H6 has only 2 sensors, so it should be 4. That's my overlook, I'll
> change it to 4 for H6 and to 8 for A64.

No it's correct. There's 2 bytes reference temperature and 2x 2 byte
values for individual sensor calibration constants.

regards,
	o.

> >
> > ChenYu
> >
> >
> > > +                       };
> > >                 };
> > >
> > >                 watchdog: watchdog@30090a0 {
> > > @@ -856,5 +863,31 @@ r_i2c: i2c@7081400 {
> > >                         #address-cells = <1>;
> > >                         #size-cells = <0>;
> > >                 };
> > > +
> > > +               ths: thermal-sensor@5070400 {
> > > +                       compatible = "allwinner,sun50i-h6-ths";
> > > +                       reg = <0x05070400 0x100>;
> > > +                       interrupts = <GIC_SPI 15 IRQ_TYPE_LEVEL_HIGH>;
> > > +                       clocks = <&ccu CLK_BUS_THS>;
> > > +                       clock-names = "bus";
> > > +                       resets = <&ccu RST_BUS_THS>;
> > > +                       nvmem-cells = <&ths_calibration>;
> > > +                       nvmem-cell-names = "calibration";
> > > +                       #thermal-sensor-cells = <1>;
> > > +               };
> > > +       };
> > > +
> > > +       thermal-zones {
> > > +               cpu-thermal {
> > > +                       polling-delay-passive = <0>;
> > > +                       polling-delay = <0>;
> > > +                       thermal-sensors = <&ths 0>;
> > > +               };
> > > +
> > > +               gpu-thermal {
> > > +                       polling-delay-passive = <0>;
> > > +                       polling-delay = <0>;
> > > +                       thermal-sensors = <&ths 1>;
> > > +               };
> > >         };
> > >  };
> > > --
> > > 2.24.1
> > >
Vasily Khoruzhick Dec. 19, 2019, 1:42 a.m. UTC | #4
On Wed, Dec 18, 2019 at 5:03 PM Ondřej Jirman <megous@megous.com> wrote:
>
> On Wed, Dec 18, 2019 at 03:18:51PM -0800, Vasily Khoruzhick wrote:
> > On Tue, Dec 17, 2019 at 8:32 PM Chen-Yu Tsai <wens@csie.org> wrote:
> > >
> > > On Wed, Dec 18, 2019 at 12:22 PM Vasily Khoruzhick <anarsoul@gmail.com> wrote:
> > > >
> > > > From: Ondrej Jirman <megous@megous.com>
> > > >
> > > > There are two sensors, one for CPU, one for GPU.
> > > >
> > > > Signed-off-by: Ondrej Jirman <megous@megous.com>
> > > > Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
> > > > ---
> > > >  arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi | 33 ++++++++++++++++++++
> > > >  1 file changed, 33 insertions(+)
> > > >
> > > > diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
> > > > index 29824081b43b..cdcb1a36301a 100644
> > > > --- a/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
> > > > +++ b/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
> > > > @@ -11,6 +11,7 @@
> > > >  #include <dt-bindings/reset/sun50i-h6-ccu.h>
> > > >  #include <dt-bindings/reset/sun50i-h6-r-ccu.h>
> > > >  #include <dt-bindings/reset/sun8i-de2.h>
> > > > +#include <dt-bindings/thermal/thermal.h>
> > > >
> > > >  / {
> > > >         interrupt-parent = <&gic>;
> > > > @@ -233,6 +234,12 @@ dma: dma-controller@3002000 {
> > > >                 sid: efuse@3006000 {
> > > >                         compatible = "allwinner,sun50i-h6-sid";
> > > >                         reg = <0x03006000 0x400>;
> > > > +                       #address-cells = <1>;
> > > > +                       #size-cells = <1>;
> > > > +
> > > > +                       ths_calibration: thermal-sensor-calibration@14 {
> > > > +                               reg = <0x14 0x6>;
> > >
> > > Nit: my preference is to use words as the smallest increment, so this
> > > would have a size of 8 instead of 6. Same goes for the A64 dts.
> > >
> > > AFAICT this doesn't impact the driver in any way.
> >
> > H6 has only 2 sensors, so it should be 4. That's my overlook, I'll
> > change it to 4 for H6 and to 8 for A64.
>
> No it's correct. There's 2 bytes reference temperature and 2x 2 byte
> values for individual sensor calibration constants.

So it should be 8 if we round it up to word boundary?

> regards,
>         o.
>
> > >
> > > ChenYu
> > >
> > >
> > > > +                       };
> > > >                 };
> > > >
> > > >                 watchdog: watchdog@30090a0 {
> > > > @@ -856,5 +863,31 @@ r_i2c: i2c@7081400 {
> > > >                         #address-cells = <1>;
> > > >                         #size-cells = <0>;
> > > >                 };
> > > > +
> > > > +               ths: thermal-sensor@5070400 {
> > > > +                       compatible = "allwinner,sun50i-h6-ths";
> > > > +                       reg = <0x05070400 0x100>;
> > > > +                       interrupts = <GIC_SPI 15 IRQ_TYPE_LEVEL_HIGH>;
> > > > +                       clocks = <&ccu CLK_BUS_THS>;
> > > > +                       clock-names = "bus";
> > > > +                       resets = <&ccu RST_BUS_THS>;
> > > > +                       nvmem-cells = <&ths_calibration>;
> > > > +                       nvmem-cell-names = "calibration";
> > > > +                       #thermal-sensor-cells = <1>;
> > > > +               };
> > > > +       };
> > > > +
> > > > +       thermal-zones {
> > > > +               cpu-thermal {
> > > > +                       polling-delay-passive = <0>;
> > > > +                       polling-delay = <0>;
> > > > +                       thermal-sensors = <&ths 0>;
> > > > +               };
> > > > +
> > > > +               gpu-thermal {
> > > > +                       polling-delay-passive = <0>;
> > > > +                       polling-delay = <0>;
> > > > +                       thermal-sensors = <&ths 1>;
> > > > +               };
> > > >         };
> > > >  };
> > > > --
> > > > 2.24.1
> > > >
Chen-Yu Tsai Dec. 19, 2019, 2:59 a.m. UTC | #5
On Thu, Dec 19, 2019 at 9:42 AM Vasily Khoruzhick <anarsoul@gmail.com> wrote:
>
> On Wed, Dec 18, 2019 at 5:03 PM Ondřej Jirman <megous@megous.com> wrote:
> >
> > On Wed, Dec 18, 2019 at 03:18:51PM -0800, Vasily Khoruzhick wrote:
> > > On Tue, Dec 17, 2019 at 8:32 PM Chen-Yu Tsai <wens@csie.org> wrote:
> > > >
> > > > On Wed, Dec 18, 2019 at 12:22 PM Vasily Khoruzhick <anarsoul@gmail.com> wrote:
> > > > >
> > > > > From: Ondrej Jirman <megous@megous.com>
> > > > >
> > > > > There are two sensors, one for CPU, one for GPU.
> > > > >
> > > > > Signed-off-by: Ondrej Jirman <megous@megous.com>
> > > > > Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
> > > > > ---
> > > > >  arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi | 33 ++++++++++++++++++++
> > > > >  1 file changed, 33 insertions(+)
> > > > >
> > > > > diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
> > > > > index 29824081b43b..cdcb1a36301a 100644
> > > > > --- a/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
> > > > > +++ b/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
> > > > > @@ -11,6 +11,7 @@
> > > > >  #include <dt-bindings/reset/sun50i-h6-ccu.h>
> > > > >  #include <dt-bindings/reset/sun50i-h6-r-ccu.h>
> > > > >  #include <dt-bindings/reset/sun8i-de2.h>
> > > > > +#include <dt-bindings/thermal/thermal.h>
> > > > >
> > > > >  / {
> > > > >         interrupt-parent = <&gic>;
> > > > > @@ -233,6 +234,12 @@ dma: dma-controller@3002000 {
> > > > >                 sid: efuse@3006000 {
> > > > >                         compatible = "allwinner,sun50i-h6-sid";
> > > > >                         reg = <0x03006000 0x400>;
> > > > > +                       #address-cells = <1>;
> > > > > +                       #size-cells = <1>;
> > > > > +
> > > > > +                       ths_calibration: thermal-sensor-calibration@14 {
> > > > > +                               reg = <0x14 0x6>;
> > > >
> > > > Nit: my preference is to use words as the smallest increment, so this
> > > > would have a size of 8 instead of 6. Same goes for the A64 dts.
> > > >
> > > > AFAICT this doesn't impact the driver in any way.
> > >
> > > H6 has only 2 sensors, so it should be 4. That's my overlook, I'll
> > > change it to 4 for H6 and to 8 for A64.
> >
> > No it's correct. There's 2 bytes reference temperature and 2x 2 byte
> > values for individual sensor calibration constants.
>
> So it should be 8 if we round it up to word boundary?

That is correct.

> > regards,
> >         o.
> >
> > > >
> > > > ChenYu
> > > >
> > > >
> > > > > +                       };
> > > > >                 };
> > > > >
> > > > >                 watchdog: watchdog@30090a0 {
> > > > > @@ -856,5 +863,31 @@ r_i2c: i2c@7081400 {
> > > > >                         #address-cells = <1>;
> > > > >                         #size-cells = <0>;
> > > > >                 };
> > > > > +
> > > > > +               ths: thermal-sensor@5070400 {
> > > > > +                       compatible = "allwinner,sun50i-h6-ths";
> > > > > +                       reg = <0x05070400 0x100>;
> > > > > +                       interrupts = <GIC_SPI 15 IRQ_TYPE_LEVEL_HIGH>;
> > > > > +                       clocks = <&ccu CLK_BUS_THS>;
> > > > > +                       clock-names = "bus";
> > > > > +                       resets = <&ccu RST_BUS_THS>;
> > > > > +                       nvmem-cells = <&ths_calibration>;
> > > > > +                       nvmem-cell-names = "calibration";
> > > > > +                       #thermal-sensor-cells = <1>;
> > > > > +               };
> > > > > +       };
> > > > > +
> > > > > +       thermal-zones {
> > > > > +               cpu-thermal {
> > > > > +                       polling-delay-passive = <0>;
> > > > > +                       polling-delay = <0>;
> > > > > +                       thermal-sensors = <&ths 0>;
> > > > > +               };
> > > > > +
> > > > > +               gpu-thermal {
> > > > > +                       polling-delay-passive = <0>;
> > > > > +                       polling-delay = <0>;
> > > > > +                       thermal-sensors = <&ths 1>;
> > > > > +               };
> > > > >         };
> > > > >  };
> > > > > --
> > > > > 2.24.1
> > > > >
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel