Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[PATCH 0/5] thermal: rockchip: add tsadc support in thermal driver and IPA thermal control for rk3328 in dts

67 views
Skip to first unread message

Rocky Hao

unread,
Jul 25, 2017, 5:10:08 AM7/25/17
to
This series patches add the tsadc support in thermal driver and in devicetree for rk3328.
Also add thermal control with Intelligent Power Allocation (IPA) policy by default. Please
refer to https://developer.arm.com/open-source/intelligent-power-allocation for more information
about IPA.


Rocky Hao (5):
dt-bindings: rockchip-thermal: Support the RK3328 SoC compatible
thermal: rockchip: Support the RK3328 SOC in thermal driver
arm64: dts: rockchip: add tsadc node for rk3328 SoC
arm64: dts: rockchip: add thermal nodes for rk3328 SoC
arm64: dts: rockchip: Enable tsadc module on RK3328 eavluation board

.../bindings/thermal/rockchip-thermal.txt | 1 +
arch/arm64/boot/dts/rockchip/rk3328-evb.dts | 4 ++
arch/arm64/boot/dts/rockchip/rk3328.dtsi | 63 +++++++++++++++++++++
drivers/thermal/rockchip_thermal.c | 65 ++++++++++++++++++++++
4 files changed, 133 insertions(+)

--
1.9.1

Rocky Hao

unread,
Jul 25, 2017, 5:10:08 AM7/25/17
to
RK3328 SOC has one Temperature Sensor for CPU.

Change-Id: I176c76bae1801d815a513986cfefcb55272c69a8
Signed-off-by: Rocky Hao <rock...@rock-chips.com>
---
drivers/thermal/rockchip_thermal.c | 65 ++++++++++++++++++++++++++++++++++++++
1 file changed, 65 insertions(+)

diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_thermal.c
index 4c7796512453..206035139110 100644
--- a/drivers/thermal/rockchip_thermal.c
+++ b/drivers/thermal/rockchip_thermal.c
@@ -320,6 +320,44 @@ struct tsadc_table {
{0, 125000},
};

+static const struct tsadc_table rk3328_code_table[] = {
+ {0, -40000},
+ {296, -40000},
+ {304, -35000},
+ {313, -30000},
+ {331, -20000},
+ {340, -15000},
+ {349, -10000},
+ {359, -5000},
+ {368, 0},
+ {378, 5000},
+ {388, 10000},
+ {398, 15000},
+ {408, 20000},
+ {418, 25000},
+ {429, 30000},
+ {440, 35000},
+ {451, 40000},
+ {462, 45000},
+ {473, 50000},
+ {485, 55000},
+ {496, 60000},
+ {508, 65000},
+ {521, 70000},
+ {533, 75000},
+ {546, 80000},
+ {559, 85000},
+ {572, 90000},
+ {586, 95000},
+ {600, 100000},
+ {614, 105000},
+ {629, 110000},
+ {644, 115000},
+ {659, 120000},
+ {675, 125000},
+ {TSADCV2_DATA_MASK, 125000},
+};
+
static const struct tsadc_table rk3368_code_table[] = {
{0, -40000},
{106, -40000},
@@ -790,6 +828,29 @@ static void rk_tsadcv2_tshut_mode(int chn, void __iomem *regs,
},
};

+static const struct rockchip_tsadc_chip rk3328_tsadc_data = {
+ .chn_id[SENSOR_CPU] = 0, /* cpu sensor is channel 0 */
+ .chn_num = 1, /* one channels for tsadc */
+
+ .tshut_mode = TSHUT_MODE_CRU, /* default TSHUT via CRU */
+ .tshut_temp = 95000,
+
+ .initialize = rk_tsadcv2_initialize,
+ .irq_ack = rk_tsadcv3_irq_ack,
+ .control = rk_tsadcv3_control,
+ .get_temp = rk_tsadcv2_get_temp,
+ .set_alarm_temp = rk_tsadcv2_alarm_temp,
+ .set_tshut_temp = rk_tsadcv2_tshut_temp,
+ .set_tshut_mode = rk_tsadcv2_tshut_mode,
+
+ .table = {
+ .id = rk3328_code_table,
+ .length = ARRAY_SIZE(rk3328_code_table),
+ .data_mask = TSADCV2_DATA_MASK,
+ .mode = ADC_INCREMENT,
+ },
+};
+
static const struct rockchip_tsadc_chip rk3366_tsadc_data = {
.chn_id[SENSOR_CPU] = 0, /* cpu sensor is channel 0 */
.chn_id[SENSOR_GPU] = 1, /* gpu sensor is channel 1 */
@@ -875,6 +936,10 @@ static void rk_tsadcv2_tshut_mode(int chn, void __iomem *regs,
.data = (void *)&rk3288_tsadc_data,
},
{
+ .compatible = "rockchip,rk3328-tsadc",
+ .data = (void *)&rk3328_tsadc_data,
+ },
+ {
.compatible = "rockchip,rk3366-tsadc",
.data = (void *)&rk3366_tsadc_data,
},
--
1.9.1

Rocky Hao

unread,
Jul 25, 2017, 5:10:10 AM7/25/17
to
add thermal zone and dynamic CPU power coefficients for rk3328

Change-Id: I227468506c0b978a0fd4dd9596631e026743910e
Signed-off-by: Rocky Hao <rock...@rock-chips.com>
---
arch/arm64/boot/dts/rockchip/rk3328.dtsi | 43 ++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)

diff --git a/arch/arm64/boot/dts/rockchip/rk3328.dtsi b/arch/arm64/boot/dts/rockchip/rk3328.dtsi
index 186fb93fdffd..68829f808320 100644
--- a/arch/arm64/boot/dts/rockchip/rk3328.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3328.dtsi
@@ -47,6 +47,7 @@
#include <dt-bindings/pinctrl/rockchip.h>
#include <dt-bindings/power/rk3328-power.h>
#include <dt-bindings/soc/rockchip,boot-mode.h>
+#include <dt-bindings/thermal/thermal.h>

/ {
compatible = "rockchip,rk3328";
@@ -74,6 +75,8 @@
compatible = "arm,cortex-a53", "arm,armv8";
reg = <0x0 0x0>;
clocks = <&cru ARMCLK>;
+ #cooling-cells = <2>; /* min followed by max */
+ dynamic-power-coefficient = <120>;
enable-method = "psci";
next-level-cache = <&l2>;
};
@@ -83,6 +86,7 @@
compatible = "arm,cortex-a53", "arm,armv8";
reg = <0x0 0x1>;
clocks = <&cru ARMCLK>;
+ dynamic-power-coefficient = <120>;
enable-method = "psci";
next-level-cache = <&l2>;
};
@@ -92,6 +96,7 @@
compatible = "arm,cortex-a53", "arm,armv8";
reg = <0x0 0x2>;
clocks = <&cru ARMCLK>;
+ dynamic-power-coefficient = <120>;
enable-method = "psci";
next-level-cache = <&l2>;
};
@@ -101,6 +106,7 @@
compatible = "arm,cortex-a53", "arm,armv8";
reg = <0x0 0x3>;
clocks = <&cru ARMCLK>;
+ dynamic-power-coefficient = <120>;
enable-method = "psci";
next-level-cache = <&l2>;
};
@@ -308,6 +314,43 @@
interrupts = <GIC_SPI 40 IRQ_TYPE_LEVEL_HIGH>;
};

+ thermal-zones {
+ soc_thermal: soc-thermal {
+ polling-delay-passive = <20>; /* milliseconds */
+ polling-delay = <1000>; /* milliseconds */
+ sustainable-power = <1000>; /* milliwatts */
+
+ thermal-sensors = <&tsadc 0>;
+
+ trips {
+ threshold: trip-point0 {
+ temperature = <70000>; /* millicelsius */
+ hysteresis = <2000>; /* millicelsius */
+ type = "passive";
+ };
+ target: trip-point1 {
+ temperature = <85000>; /* millicelsius */
+ hysteresis = <2000>; /* millicelsius */
+ type = "passive";
+ };
+ soc_crit: soc-crit {
+ temperature = <95000>; /* millicelsius */
+ hysteresis = <2000>; /* millicelsius */
+ type = "critical";
+ };
+ };
+
+ cooling-maps {
+ map0 {
+ trip = <&target>;
+ cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
+ contribution = <4096>;
+ };
+ };
+ };
+
+ };
+
tsadc: tsadc@ff250000 {
compatible = "rockchip,rk3328-tsadc";
reg = <0x0 0xff250000 0x0 0x100>;
--
1.9.1

Rocky Hao

unread,
Jul 25, 2017, 5:20:16 AM7/25/17
to
enable tsadc module on RK3328 eavluation board

Change-Id: Ieb45a02b90dae3fbefe7d2b571b3961412d866ad
Signed-off-by: Rocky Hao <rock...@rock-chips.com>
---
arch/arm64/boot/dts/rockchip/rk3328-evb.dts | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/arch/arm64/boot/dts/rockchip/rk3328-evb.dts b/arch/arm64/boot/dts/rockchip/rk3328-evb.dts
index 8c61d91bf89b..e7db0dc97ce0 100644
--- a/arch/arm64/boot/dts/rockchip/rk3328-evb.dts
+++ b/arch/arm64/boot/dts/rockchip/rk3328-evb.dts
@@ -52,6 +52,10 @@
};
};

+&tsadc {
+ status = "okay";
+};
+
&uart2 {
status = "okay";
};
--
1.9.1

Rocky Hao

unread,
Aug 4, 2017, 4:10:09 AM8/4/17
to
attempt to new compatible for thermal founding on RK3328 SoC.

Signed-off-by: Rocky Hao <rock...@rock-chips.com>
---
Change in v2:
- remove gerrit Change-Id

Documentation/devicetree/bindings/thermal/rockchip-thermal.txt | 1 +
1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/thermal/rockchip-thermal.txt b/Documentation/devicetree/bindings/thermal/rockchip-thermal.txt
index 43003aec94bd..e3a6234fb1ac 100644
--- a/Documentation/devicetree/bindings/thermal/rockchip-thermal.txt
+++ b/Documentation/devicetree/bindings/thermal/rockchip-thermal.txt
@@ -4,6 +4,7 @@ Required properties:
- compatible : should be "rockchip,<name>-tsadc"
"rockchip,rk3228-tsadc": found on RK3228 SoCs
"rockchip,rk3288-tsadc": found on RK3288 SoCs
+ "rockchip,rk3328-tsadc": found on RK3328 SoCs
"rockchip,rk3368-tsadc": found on RK3368 SoCs
"rockchip,rk3399-tsadc": found on RK3399 SoCs
- reg : physical base address of the controller and length of memory mapped
--
1.9.1

Rocky Hao

unread,
Aug 4, 2017, 4:10:09 AM8/4/17
to
add thermal zone and dynamic CPU power coefficients for rk3328

Signed-off-by: Rocky Hao <rock...@rock-chips.com>
---
Change in v2:
- remove gerrit Change-Id

Rocky Hao

unread,
Aug 4, 2017, 4:10:09 AM8/4/17
to

Rocky Hao

unread,
Aug 4, 2017, 4:10:09 AM8/4/17
to
RK3328 SOC has one Temperature Sensor for CPU.

Signed-off-by: Rocky Hao <rock...@rock-chips.com>
---
Change in v2:
- remove gerrit Change-Id

Rocky Hao

unread,
Aug 4, 2017, 4:10:09 AM8/4/17
to
enable tsadc module on RK3328 eavluation board

Signed-off-by: Rocky Hao <rock...@rock-chips.com>
---
Change in v2:
- remove gerrit Change-Id

Rob Herring

unread,
Aug 10, 2017, 1:50:09 PM8/10/17
to
On Fri, Aug 04, 2017 at 04:06:12PM +0800, Rocky Hao wrote:
> attempt to new compatible for thermal founding on RK3328 SoC.

? "Add a new compatible..."

>
> Signed-off-by: Rocky Hao <rock...@rock-chips.com>
> ---
> Change in v2:
> - remove gerrit Change-Id
>
> Documentation/devicetree/bindings/thermal/rockchip-thermal.txt | 1 +
> 1 file changed, 1 insertion(+)

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

rocky.hao

unread,
Aug 10, 2017, 9:10:04 PM8/10/17
to
Hi Rob,

Thank you very much for your reply, and your ack of course.

Best Regards,
Rocky

Zhang Rui

unread,
Aug 10, 2017, 11:10:04 PM8/10/17
to
On Tue, 2017-07-25 at 17:09 +0800, Rocky Hao wrote:
> RK3328 SOC has one Temperature Sensor for CPU.
>
> Change-Id: I176c76bae1801d815a513986cfefcb55272c69a8
> Signed-off-by: Rocky Hao <rock...@rock-chips.com>

Caesar,

what do you think of this patch?

thanks,
rui

Caesar Wang

unread,
Aug 11, 2017, 12:10:05 AM8/11/17
to
在 2017年08月11日 11:02, Zhang Rui 写道:
> On Tue, 2017-07-25 at 17:09 +0800, Rocky Hao wrote:
>> RK3328 SOC has one Temperature Sensor for CPU.
>>
>> Change-Id: I176c76bae1801d815a513986cfefcb55272c69a8
>> Signed-off-by: Rocky Hao <rock...@rock-chips.com>
Reviewed-by: Caesar Wang <w...@rock-chips.com>

> Caesar,
>
> what do you think of this patch?

Have a look at the rk3328's TRM, looks good to me.


-Caesar
> _______________________________________________
> Linux-rockchip mailing list
> Linux-r...@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-rockchip

Zhang Rui

unread,
Aug 11, 2017, 1:00:05 AM8/11/17
to
On Fri, 2017-08-04 at 16:06 +0800, Rocky Hao wrote:
> This series patches add the tsadc support in thermal driver and in
> devicetree for rk3328.
> Also add thermal control with Intelligent Power Allocation (IPA)
> policy by default.  Please
> refer to https://developer.arm.com/open-source/intelligent-power-allo
> cation for more information
> about IPA.
>
> Rocky Hao (5):
>   dt-bindings: rockchip-thermal: Support the RK3328 SoC compatible
>   thermal: rockchip: Support the RK3328 SOC in thermal driver
>   arm64: dts: rockchip: add tsadc node for rk3328 SoC
>   arm64: dts: rockchip: add thermal nodes for rk3328 SoC
>   arm64: dts: rockchip: Enable tsadc module on RK3328 eavluation
> board
>
I can take this patch set if we have ACK for patch 3, 4 and 5.

thanks,
rui

rocky.hao

unread,
Aug 11, 2017, 2:30:09 AM8/11/17
to
Hi Rui,

Thank you for the patch set acception.

Thanks again,
Rocky

Heiko Stuebner

unread,
Aug 11, 2017, 2:30:16 AM8/11/17
to
Hi,

Am Freitag, 11. August 2017, 12:51:35 CEST schrieb Zhang Rui:
> On Fri, 2017-08-04 at 16:06 +0800, Rocky Hao wrote:
> > This series patches add the tsadc support in thermal driver and in
> > devicetree for rk3328.
> > Also add thermal control with Intelligent Power Allocation (IPA)
> > policy by default. Please
> > refer to https://developer.arm.com/open-source/intelligent-power-allo
> > cation for more information
> > about IPA.
> >
> > Rocky Hao (5):
> > dt-bindings: rockchip-thermal: Support the RK3328 SoC compatible
> > thermal: rockchip: Support the RK3328 SOC in thermal driver
> > arm64: dts: rockchip: add tsadc node for rk3328 SoC
> > arm64: dts: rockchip: add thermal nodes for rk3328 SoC
> > arm64: dts: rockchip: Enable tsadc module on RK3328 eavluation
> > board
> >
> I can take this patch set if we have ACK for patch 3, 4 and 5.

I would prefer if you would just apply patches 1+2 alone and I'd take
the devicetree patches through my tree.

Having devicetree stuff mingle in a lot of trees produces unnecessary
conflicts, so the general best practice is having code + binding.txt
going through the driver tree and devicetree stuff through the platform
tree.


Thanks
Heiko

Caesar Wang

unread,
Aug 11, 2017, 2:50:06 AM8/11/17
to
The document had already described, maybe we should remove the
millicelsius/milliseconds/milliwatts here.

Zhang Rui

unread,
Aug 11, 2017, 4:10:08 AM8/11/17
to
OKay, I will take patch 1 and 2 and queue them for next merge window.

thanks,
rui
>
> Thanks
> Heiko
>

rocky.hao

unread,
Aug 11, 2017, 5:50:07 AM8/11/17
to
Hi Caesar,
Thanks for your comments.

Best Regards,
Rocky
It is ok for me.

Heiko Stuebner

unread,
Aug 11, 2017, 5:50:07 AM8/11/17
to
Hi Rocky,

Am Freitag, 11. August 2017, 17:46:55 CEST schrieb rocky.hao:
> Hi Caesar,
> Thanks for your comments.

just to add, there is no need to resend, I can drop the comments
here myself when applying :-)


Heiko

Heiko Stuebner

unread,
Aug 11, 2017, 11:20:07 AM8/11/17
to
Am Freitag, 4. August 2017, 16:09:40 CEST schrieb Rocky Hao:
> enable tsadc module on RK3328 eavluation board
>
> Signed-off-by: Rocky Hao <rock...@rock-chips.com>

applied for 4.14


Thanks
Heiko

Heiko Stuebner

unread,
Aug 11, 2017, 11:20:08 AM8/11/17
to
Am Freitag, 4. August 2017, 16:06:15 CEST schrieb Rocky Hao:
> add thermal zone and dynamic CPU power coefficients for rk3328
>
> Signed-off-by: Rocky Hao <rock...@rock-chips.com>

applied for 4.14 after dropping the unnecessary property-comments.


Thanks
Heiko
0 new messages