v3 Exynos5422 odroidxu3 pwm-fan control using thermal sensors
Subsystems (3)
This work depeds upon work done by Lukasz Majewski <[email protected]> and Sjoerd Simons <[email protected]> regarding the pwm-fan.
Changes from v1
fixed the registration of thermal sensor to tmu_cpu0
Dropped patches.
0005-pwm-samsung-Fix-output-race-on-disabling.patch 0006-hwmon-pwm-fan-Update-the-duty-cycle-inorder-to-contr.patch
changes from v2
Added patch
0006-hwmon-pwm-fan-Update-the-duty-cycle-inorder-to-contr.patch
-Anand Moon
PATCH v3 1/6 ARM: dts :exynos5422-odroidxu3 Add pwm-fan node to the Odroid-XU3 board.
Add pwm-fan node to the OdroidXU3 board.
Tested on OdroidXU3 board.
Changes since v1 : None
Changes since v2 : None
--- arch/arm/boot/dts/exynos5422-odroidxu3.dts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
arch/arm/boot/dts/exynos5422-odroidxu3.dts +16 -0
@@ -278,6 +278,15 @@ rtc at 101E0000 { status = "okay"; }; + + fan0: pwm-fan { + compatible = "pwm-fan"; + pwms = <&pwm 0 20972 0>; + cooling-min-state = <0>; + cooling-max-state = <3>; + #cooling-cells = <2>; + cooling-levels = <0 130 170 230>; + }; }; &hdmi {
@@ -369,3 +378,10 @@ shunt-resistor = <10000>; }; }; + +&pwm { + pinctrl-0 = <&pwm0_out>; + pinctrl-names = "default"; + samsung,pwm-outputs = <0>; + status = "okay"; +};
Signature · 1 line
1.9.1
PATCH v3 2/6 ARM: dts: OdroidXU3: Enable TMU at Exynos5422 base.
In reply to Anand MoonThis commit enables TMU IP block on the Exynos5422 OdroidXU3 device.
Tested on OdroidXU3 board.
Changes since v1 : None
Changes since v2 : None
--- arch/arm/boot/dts/exynos5422-odroidxu3.dts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
arch/arm/boot/dts/exynos5422-odroidxu3.dts +25 -0
@@ -287,6 +287,31 @@ #cooling-cells = <2>; cooling-levels = <0 130 170 230>; }; + + tmu at 10060000 { + vtmu-supply = <&ldo10_reg>; + status = "okay"; + }; + + tmu at 10064000 { + vtmu-supply = <&ldo10_reg>; + status = "okay"; + }; + + tmu at 10068000 { + vtmu-supply = <&ldo10_reg>; + status = "okay"; + }; + + tmu at 1006c000 { + vtmu-supply = <&ldo10_reg>; + status = "okay"; + }; + + tmu at 100a0000 { + vtmu-supply = <&ldo10_reg>; + status = "okay"; + }; }; &hdmi {
Signature · 1 line
1.9.1
PATCH v3 3/6 ARM: dts: define default thermal-zones for exynos5
In reply to Anand MoonTrip points corresponding to the one defined in the exynos_tmu_data.c for Exynos5 have been included.
This thermal-zones attribute is afterwards reused for Exynos5422.
Changes since v1 : Fixed the thernal_sensor registration of the sensors tmu_cpu0 Changes since v2 : None
--- arch/arm/boot/dts/exynos5-cpu-thermal.dtsi | 59 ++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 arch/arm/boot/dts/exynos5-cpu-thermal.dtsi
arch/arm/boot/dts/exynos5-cpu-thermal.dtsi new file +59 -0
@@ -0,0 +1,59 @@ +/* + * Device tree sources for Exynos5 thermal zone + * + * Copyright (c) 2015 Lukasz Majewski <[email protected]> + * Anand Moon <[email protected]> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + */ + +#include <dt-bindings/thermal/thermal.h> + +/ { + thermal-zones { + cpu0_thermal: cpu0-thermal { + thermal-sensors = <&tmu_cpu0 0>; + polling-delay-passive = <0>; + polling-delay = <0>; + trips { + cpu_alert0: cpu-alert-0 { + temperature = <50000>; /* millicelsius */ + hysteresis = <5000>; /* millicelsius */ + type = "active"; + }; + cpu_alert1: cpu-alert-1 { + temperature = <60000>; /* millicelsius */ + hysteresis = <5000>; /* millicelsius */ + type = "active"; + }; + cpu_alert2: cpu-alert-2 { + temperature = <70000>; /* millicelsius */ + hysteresis = <5000>; /* millicelsius */ + type = "active"; + }; + cpu_crit0: cpu-crit-0 { + temperature = <100000>; /* millicelsius */ + hysteresis = <0>; /* millicelsius */ + type = "critical"; + }; + }; + cooling-maps { + map0 { + trip = <&cpu_alert0>; + cooling-device = <&fan0 0 1>; + }; + map1 { + trip = <&cpu_alert1>; + cooling-device = <&fan0 1 2>; + }; + map2 { + trip = <&cpu_alert2>; + cooling-device = <&fan0 2 3>; + }; + }; + }; + }; +};
Signature · 1 line
1.9.1
PATCH v3 4/6 ARM: dts exynos5420 update the cooling cells for core cpu0
In reply to Anand Moonupdate the cooling level for cpu0 to avoid following message.
root at odroidxu3:~# dmesg | grep ther
[ 0.241511] /thermal-zones/cpu-thermal/cooling-maps/map0:
could not get #cooling-cells for /cpus/cpu at 0Tested on OdroidXU3
Changes since v1 : None
Changes since v2 : None
--- arch/arm/boot/dts/exynos5420.dtsi | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm/boot/dts/exynos5420.dtsi +4 -0
@@ -61,6 +61,10 @@ reg = <0x0>; clock-frequency = <1800000000>; cci-control-port = <&cci_control1>; + + cooling-min-level = <10>; + cooling-max-level = <7>; + #cooling-cells = <2>; /* min followed by max */ }; cpu1: cpu at 1 {
Signature · 1 line
1.9.1
PATCH v3 5/6 ARM: dts: Enable thermal_zone for exynos5422.
In reply to Anand MoonInclude exynos5-cpu-thermal.dtsi to enable thermal_zone support.
Changes since v1 : Seperate the include previous patch. Changes since v2 : None
--- arch/arm/boot/dts/exynos5422-odroidxu3.dts | 1 + 1 file changed, 1 insertion(+)
arch/arm/boot/dts/exynos5422-odroidxu3.dts +1 -0
@@ -12,6 +12,7 @@ /dts-v1/; #include "exynos5800.dtsi" +#include "exynos5-cpu-thermal.dtsi" / { model = "Hardkernel Odroid XU3";
Signature · 1 line
1.9.1
PATCH v3 6/6 hwmon: pwm-fan: Update the duty cycle inorder to control the pwm-fan
In reply to Anand MoonIn order to disable the PWM we need to update using following sequence.
pwm_config(pwm, 0, period);
pwm_disable(pwm);
pwm_config() with a zero duty cycle to make it clear the timer and update the PWM registers. pwm_disable will clear the TCON_AUTORELOAD(tcon_chan) and update the PWM register.
Next change in state will get trigger unless a new PWM cycle happened.
pwm_config(pwm, duty, period);
pwm_enable(pwm);
Through pwm_config we update the duty cycle and period and update the PWM register. pwm_enable will update the state to TCON_MANUALUPDATE(tcon_chan)
and TCON_START(tcon_chan) | TCON_AUTORELOAD(tcon_chan) and update the PWM register.
--- drivers/hwmon/pwm-fan.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/hwmon/pwm-fan.c +4 -6
@@ -44,26 +44,24 @@ static int __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)int ret =0 ;mutex_lock (&ctx->lock); +if (ctx->pwm_value == pwm) goto exit_set_pwm_err; -if (pwm ==0 ) { -pwm_disable (ctx->pwm); - goto exit_set_pwm; - } - duty =DIV_ROUND_UP (pwm * (ctx->pwm->period -1 ),MAX_PWM ); ret =pwm_config (ctx->pwm, duty, ctx->pwm->period);if (ret) goto exit_set_pwm_err; +if (pwm ==0 ) +pwm_disable (ctx->pwm); +if (ctx->pwm_value ==0 ) { ret =pwm_enable (ctx->pwm);if (ret) goto exit_set_pwm_err; } -exit_set_pwm: ctx->pwm_value = pwm; exit_set_pwm_err:mutex_unlock (&ctx->lock);
Signature · 1 line
1.9.1
Guenter Roeck
maintainerPATCH v3 6/6 hwmon: pwm-fan: Update the duty cycle inorder to control the pwm-fan
Quoted 8 lines · Anand Moon
In order to disable the PWM we need to update using following sequence.
pwm_config(pwm, 0, period);
pwm_disable(pwm);
pwm_config()with a zero duty cycle to make it clear the timer and update the PWM registers.pwm_disablewill clear theTCON_AUTORELOAD(tcon_chan)and update the PWM register.
There is no TCON_AUTORELOAD in this driver. Future developers will have no idea what you are talking about here. Please provide a generic comment.
Quoted 2 lines
Next change in state will get trigger unless a new PWM cycle happened.
That sentence is difficult to parse. Actually, I have no idea what it is supposed to mean.
Quoted 7 lines
pwm_config(pwm, duty, period);
pwm_enable(pwm);Through
pwm_configwe update the duty cycle and period and update the PWM register.pwm_enablewill update the state toTCON_MANUALUPDATE(tcon_chan)
andTCON_START(tcon_chan)|TCON_AUTORELOAD(tcon_chan)and update the PWM register.
This sentence does not make sense in the context of the pwm-fan driver.
Quoted 14 lines
Reported-by Markus Reichl <[email protected]>Tested-by Markus Reichl <[email protected]>Reviewed-by Lukasz Majewski <[email protected]>Reviewed-by Sjoerd Simons <[email protected]>Signed-off-by Anand Moon <[email protected]>--- drivers/hwmon/pwm-fan.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)drivers/hwmon/pwm-fan.c +0
-0
drivers/hwmon/pwm-fan.c static int __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm) · line 47
Quoted 4 lines
drivers/hwmon/pwm-fan.c +1
-0@@ -44,26 +44,24 @@ static int __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)int ret =0 ;mutex_lock (&ctx->lock); +
Please refrain from making unnecessary whitespace changes.
Thanks,
Guenter
PATCH v3 6/6 hwmon: pwm-fan: Update the duty cycle inorder to control the pwm-fan
hi Guenter,
I am referring to #linux/drivers/pwm/pwm-samsung.c
Will update the comment.
-Anand Moon
Quoted 58 lines · Guenter Roeck
Quoted 11 lines · Anand Moon
In order to disable the PWM we need to update using following sequence.
pwm_config(pwm, 0, period); pwm_disable(pwm);
pwm_config()with a zero duty cycle to make it clear the timer and update the PWM registers.pwm_disablewill clear theTCON_AUTORELOAD(tcon_chan)and update the PWM register.There is no
TCON_AUTORELOADin this driver. Future developers will have no idea
what you are talking about here. Please provide a generic comment.Quoted 2 lines
Next change in state will get trigger unless a new PWM cycle happened.
That sentence is difficult to parse. Actually, I have no idea what it is supposed to mean.
Quoted 9 lines
pwm_config(pwm, duty, period); pwm_enable(pwm);Through
pwm_configwe update the duty cycle and period and update the PWM register.pwm_enablewill update the state toTCON_MANUALUPDATE(tcon_chan)andTCON_START(tcon_chan)|TCON_AUTORELOAD(tcon_chan)and update the PWM register.This sentence does not make sense in the context of the pwm-fan driver.
Quoted 14 lines
Reported-by Markus Reichl <[email protected]>Tested-by Markus Reichl <[email protected]>Reviewed-by Lukasz Majewski <[email protected]>Reviewed-by Sjoerd Simons <[email protected]>Signed-off-by Anand Moon <[email protected]>--- drivers/hwmon/pwm-fan.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)drivers/hwmon/pwm-fan.c +0
-0drivers/hwmon/pwm-fan.c static int __set_pwm(struct pwm_fan_ctx *ctx, · line 48
Quoted 5 lines
drivers/hwmon/pwm-fan.c +1
-0@@ -44,26 +44,24 @@ static int __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)int ret =0 ;mutex_lock (&ctx->lock); +Please refrain from making unnecessary whitespace changes.
Thanks,
Guenter
Guenter Roeck
maintainerPATCH v3 6/6 hwmon: pwm-fan: Update the duty cycle inorder to control the pwm-fan
Quoted 6 lines · Anand Moon
hi Guenter,
I am referring to #linux/drivers/pwm/pwm-samsung.c
Will update the comment.
Sure, but that doesn't help as patch description for the pwm-fan driver.
Guenter
Quoted 62 lines
-Anand Moon
Quoted 58 lines · Guenter Roeck
Quoted 11 lines · Anand Moon
In order to disable the PWM we need to update using following sequence.
pwm_config(pwm, 0, period); pwm_disable(pwm);
pwm_config()with a zero duty cycle to make it clear the timer and update the PWM registers.pwm_disablewill clear theTCON_AUTORELOAD(tcon_chan)and update the PWM register.There is no
TCON_AUTORELOADin this driver. Future developers will have no idea
what you are talking about here. Please provide a generic comment.Quoted 2 lines
Next change in state will get trigger unless a new PWM cycle happened.
That sentence is difficult to parse. Actually, I have no idea what it is supposed to mean.
Quoted 9 lines
pwm_config(pwm, duty, period); pwm_enable(pwm);Through
pwm_configwe update the duty cycle and period and update the PWM register.pwm_enablewill update the state toTCON_MANUALUPDATE(tcon_chan)andTCON_START(tcon_chan)|TCON_AUTORELOAD(tcon_chan)and update the PWM register.This sentence does not make sense in the context of the pwm-fan driver.
Quoted 14 lines
Reported-by Markus Reichl <[email protected]>Tested-by Markus Reichl <[email protected]>Reviewed-by Lukasz Majewski <[email protected]>Reviewed-by Sjoerd Simons <[email protected]>Signed-off-by Anand Moon <[email protected]>--- drivers/hwmon/pwm-fan.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)drivers/hwmon/pwm-fan.c +0
-0drivers/hwmon/pwm-fan.c static int __set_pwm(struct pwm_fan_ctx *ctx, · line 48
Quoted 5 lines
drivers/hwmon/pwm-fan.c +1
-0@@ -44,26 +44,24 @@ static int __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)int ret =0 ;mutex_lock (&ctx->lock); +Please refrain from making unnecessary whitespace changes.
Thanks,
Guenter