[PATCH v2 0/1] thermal: mt8173: minor mtk_thermal.c cleanups

2017-02-21 Thread Dawei Chien
If thermal bank with 4 sensors, thermal driver should read TEMP_MSR3.

However, currently thermal driver would not read TEMP_MSR3 since mt8173
thermal driver only use 3 sensors on each thermal bank at the same time,
so this patch would not effect temperature.
Only if mt mt8173 thermal driver use 4 sensors on any thermal bank, would
read third sensor two times, and lose fourth sensor of vale.

Change since V1:
1. Update commis message
 a. Add Reviewed-by: Matthias Brugger 
 b. Add tag Fixes: b7cf0053738c ("thermal: Add Mediatek thermal driver for 
mt2701.")



[PATCH v2 0/1] thermal: mt8173: minor mtk_thermal.c cleanups

2017-02-21 Thread Dawei Chien
If thermal bank with 4 sensors, thermal driver should read TEMP_MSR3.

However, currently thermal driver would not read TEMP_MSR3 since mt8173
thermal driver only use 3 sensors on each thermal bank at the same time,
so this patch would not effect temperature.
Only if mt mt8173 thermal driver use 4 sensors on any thermal bank, would
read third sensor two times, and lose fourth sensor of vale.

Change since V1:
1. Update commis message
 a. Add Reviewed-by: Matthias Brugger 
 b. Add tag Fixes: b7cf0053738c ("thermal: Add Mediatek thermal driver for 
mt2701.")



[PATCH v2 1/1] thermal: mt8173: minor mtk_thermal.c cleanups

2017-02-21 Thread Dawei Chien
If thermal bank with 4 sensors, thermal driver should read TEMP_MSR3.

However, currently thermal driver would not read TEMP_MSR3 since mt8173
thermal driver only use 3 sensors on each thermal bank at the same time,
so this patch would not effect temperature.
Only if mt mt8173 thermal driver use 4 sensors on any thermal bank, would
read third sensor two times, and lose fourth sensor of vale.

cc: sta...@vger.kernel.org
Fixes: b7cf0053738c ("thermal: Add Mediatek thermal driver for mt2701.")
Reviewed-by: Matthias Brugger <matthias@gmail.com>
Signed-off-by: Dawei Chien <dawei.ch...@mediatek.com>
---
 drivers/thermal/mtk_thermal.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/thermal/mtk_thermal.c b/drivers/thermal/mtk_thermal.c
index 34169c3..c124151 100644
--- a/drivers/thermal/mtk_thermal.c
+++ b/drivers/thermal/mtk_thermal.c
@@ -191,7 +191,7 @@ struct mtk_thermal {
 };
 
 const int mt8173_msr[MT8173_NUM_SENSORS_PER_ZONE] = {
-   TEMP_MSR0, TEMP_MSR1, TEMP_MSR2, TEMP_MSR2
+   TEMP_MSR0, TEMP_MSR1, TEMP_MSR2, TEMP_MSR3
 };
 
 const int mt8173_adcpnp[MT8173_NUM_SENSORS_PER_ZONE] = {
-- 
1.9.1



[PATCH v2 1/1] thermal: mt8173: minor mtk_thermal.c cleanups

2017-02-21 Thread Dawei Chien
If thermal bank with 4 sensors, thermal driver should read TEMP_MSR3.

However, currently thermal driver would not read TEMP_MSR3 since mt8173
thermal driver only use 3 sensors on each thermal bank at the same time,
so this patch would not effect temperature.
Only if mt mt8173 thermal driver use 4 sensors on any thermal bank, would
read third sensor two times, and lose fourth sensor of vale.

cc: sta...@vger.kernel.org
Fixes: b7cf0053738c ("thermal: Add Mediatek thermal driver for mt2701.")
Reviewed-by: Matthias Brugger 
Signed-off-by: Dawei Chien 
---
 drivers/thermal/mtk_thermal.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/thermal/mtk_thermal.c b/drivers/thermal/mtk_thermal.c
index 34169c3..c124151 100644
--- a/drivers/thermal/mtk_thermal.c
+++ b/drivers/thermal/mtk_thermal.c
@@ -191,7 +191,7 @@ struct mtk_thermal {
 };
 
 const int mt8173_msr[MT8173_NUM_SENSORS_PER_ZONE] = {
-   TEMP_MSR0, TEMP_MSR1, TEMP_MSR2, TEMP_MSR2
+   TEMP_MSR0, TEMP_MSR1, TEMP_MSR2, TEMP_MSR3
 };
 
 const int mt8173_adcpnp[MT8173_NUM_SENSORS_PER_ZONE] = {
-- 
1.9.1



Re: [PATCH] thermal: mt8173: minor mtk_thermal.c cleanups

2017-02-13 Thread Dawei Chien
Hi, Matthias,

On Thu, 2017-02-09 at 22:25 +0100, Matthias Brugger wrote:
> 
> On 02/08/2017 06:31 AM, Dawei Chien wrote:
> > Thermal driver should read TEMP_MSR3 if thermal bank with 4 sensors.
> > However, Currently thermal driver don't need read TEMP_MSR3 since
> > thermal controller only use 3 sensors for each thermal bank.
> >
> > Signed-off-by: Dawei Chien <dawei.ch...@mediatek.com>
> > ---
> 
> Actually the commit message should state:
> Fixes: b7cf0053738c ("thermal: Add Mediatek thermal driver for mt2701.")
> 
> ...and get backported to v4.9 and v4.10.
> 
> Reviewed-by: Matthias Brugger <matthias@gmail.com>
> 
> Regards,
> Matthias

Thank you for your review. I would add below commit message on next
version. However, currently 8173 thermal driver would not read TEMP_MSR3
since thermal driver only use 3 sensors on each bank, this patch would
not effect temperature.
Only if thermal driver use 4 sensors on any thermal bank, would read
third sensor two times, and lose fourth sensor of vale.
Fixes: b7cf0053738c ("thermal: Add Mediatek thermal driver for mt2701.")

> >  drivers/thermal/mtk_thermal.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/thermal/mtk_thermal.c b/drivers/thermal/mtk_thermal.c
> > index 34169c3..c124151 100644
> > --- a/drivers/thermal/mtk_thermal.c
> > +++ b/drivers/thermal/mtk_thermal.c
> > @@ -191,7 +191,7 @@ struct mtk_thermal {
> >  };
> >
> >  const int mt8173_msr[MT8173_NUM_SENSORS_PER_ZONE] = {
> > -   TEMP_MSR0, TEMP_MSR1, TEMP_MSR2, TEMP_MSR2
> > +   TEMP_MSR0, TEMP_MSR1, TEMP_MSR2, TEMP_MSR3
> >  };
> >
> >  const int mt8173_adcpnp[MT8173_NUM_SENSORS_PER_ZONE] = {
> >




Re: [PATCH] thermal: mt8173: minor mtk_thermal.c cleanups

2017-02-13 Thread Dawei Chien
Hi, Matthias,

On Thu, 2017-02-09 at 22:25 +0100, Matthias Brugger wrote:
> 
> On 02/08/2017 06:31 AM, Dawei Chien wrote:
> > Thermal driver should read TEMP_MSR3 if thermal bank with 4 sensors.
> > However, Currently thermal driver don't need read TEMP_MSR3 since
> > thermal controller only use 3 sensors for each thermal bank.
> >
> > Signed-off-by: Dawei Chien 
> > ---
> 
> Actually the commit message should state:
> Fixes: b7cf0053738c ("thermal: Add Mediatek thermal driver for mt2701.")
> 
> ...and get backported to v4.9 and v4.10.
> 
> Reviewed-by: Matthias Brugger 
> 
> Regards,
> Matthias

Thank you for your review. I would add below commit message on next
version. However, currently 8173 thermal driver would not read TEMP_MSR3
since thermal driver only use 3 sensors on each bank, this patch would
not effect temperature.
Only if thermal driver use 4 sensors on any thermal bank, would read
third sensor two times, and lose fourth sensor of vale.
Fixes: b7cf0053738c ("thermal: Add Mediatek thermal driver for mt2701.")

> >  drivers/thermal/mtk_thermal.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/thermal/mtk_thermal.c b/drivers/thermal/mtk_thermal.c
> > index 34169c3..c124151 100644
> > --- a/drivers/thermal/mtk_thermal.c
> > +++ b/drivers/thermal/mtk_thermal.c
> > @@ -191,7 +191,7 @@ struct mtk_thermal {
> >  };
> >
> >  const int mt8173_msr[MT8173_NUM_SENSORS_PER_ZONE] = {
> > -   TEMP_MSR0, TEMP_MSR1, TEMP_MSR2, TEMP_MSR2
> > +   TEMP_MSR0, TEMP_MSR1, TEMP_MSR2, TEMP_MSR3
> >  };
> >
> >  const int mt8173_adcpnp[MT8173_NUM_SENSORS_PER_ZONE] = {
> >




[PATCH] thermal: mt8173: minor mtk_thermal.c cleanups

2017-02-07 Thread Dawei Chien
Thermal driver should read TEMP_MSR3 if thermal bank with 4 sensors.
However, Currently thermal driver don't need read TEMP_MSR3 since
thermal controller only use 3 sensors for each thermal bank.

Signed-off-by: Dawei Chien <dawei.ch...@mediatek.com>
---
 drivers/thermal/mtk_thermal.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/thermal/mtk_thermal.c b/drivers/thermal/mtk_thermal.c
index 34169c3..c124151 100644
--- a/drivers/thermal/mtk_thermal.c
+++ b/drivers/thermal/mtk_thermal.c
@@ -191,7 +191,7 @@ struct mtk_thermal {
 };
 
 const int mt8173_msr[MT8173_NUM_SENSORS_PER_ZONE] = {
-   TEMP_MSR0, TEMP_MSR1, TEMP_MSR2, TEMP_MSR2
+   TEMP_MSR0, TEMP_MSR1, TEMP_MSR2, TEMP_MSR3
 };
 
 const int mt8173_adcpnp[MT8173_NUM_SENSORS_PER_ZONE] = {
-- 
1.9.1



[PATCH] thermal: mt8173: minor mtk_thermal.c cleanups

2017-02-07 Thread Dawei Chien
Thermal driver should read TEMP_MSR3 if thermal bank with 4 sensors.
However, Currently thermal driver don't need read TEMP_MSR3 since
thermal controller only use 3 sensors for each thermal bank.

Signed-off-by: Dawei Chien 
---
 drivers/thermal/mtk_thermal.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/thermal/mtk_thermal.c b/drivers/thermal/mtk_thermal.c
index 34169c3..c124151 100644
--- a/drivers/thermal/mtk_thermal.c
+++ b/drivers/thermal/mtk_thermal.c
@@ -191,7 +191,7 @@ struct mtk_thermal {
 };
 
 const int mt8173_msr[MT8173_NUM_SENSORS_PER_ZONE] = {
-   TEMP_MSR0, TEMP_MSR1, TEMP_MSR2, TEMP_MSR2
+   TEMP_MSR0, TEMP_MSR1, TEMP_MSR2, TEMP_MSR3
 };
 
 const int mt8173_adcpnp[MT8173_NUM_SENSORS_PER_ZONE] = {
-- 
1.9.1



Re: [PATCH v2 6/6] arm: dts: mt2701: Add thermal device node.

2017-01-15 Thread Dawei Chien
On Mon, 2017-01-16 at 11:44 +0800, Dawei Chien wrote:
> On Fri, 2017-01-13 at 16:27 +0100, Matthias Brugger wrote:
> > 
> > On 13/01/17 09:42, Erin Lo wrote:
> > > From: Dawei Chien <dawei.ch...@mediatek.com>
> > >
> > > Add thermal controller device nodes for MT2701.
> > >
> > > Signed-off-by: Dawei Chien <dawei.ch...@mediatek.com>
> > > Signed-off-by: Erin Lo <erin...@mediatek.com>
> > > ---
> > >  arch/arm/boot/dts/mt2701.dtsi | 43 
> > > +++
> > >  1 file changed, 43 insertions(+)
> > >
> > > diff --git a/arch/arm/boot/dts/mt2701.dtsi b/arch/arm/boot/dts/mt2701.dtsi
> > > index 3847f70..c43d5f8 100644
> > > --- a/arch/arm/boot/dts/mt2701.dtsi
> > > +++ b/arch/arm/boot/dts/mt2701.dtsi
> > > @@ -89,6 +89,36 @@
> > >   clock-output-names = "rtc32k";
> > >   };
> > >
> > > + thermal-zones {
> > > + cpu_thermal: cpu_thermal {
> > > + polling-delay-passive = <1000>; /* milliseconds */
> > > + polling-delay = <1000>; /* milliseconds */
> > > +
> > > + thermal-sensors = < 0>;
> > > + sustainable-power = <1000>;
> > > +
> > > + trips {
> > > + threshold: trip-point@0 {
> > > + temperature = <68000>;
> > > + hysteresis = <2000>;
> > > + type = "passive";
> > > + };
> > > +
> > > + target: trip-point@1 {
> > > + temperature = <85000>;
> > > + hysteresis = <2000>;
> > > + type = "passive";
> > > + };
> > > +
> > > + cpu_crit: cpu_crit@0 {
> > > + temperature = <115000>;
> > > + hysteresis = <2000>;
> > > + type = "critical";
> > > + };
> > > + };
> > > + };
> > > + };
> > > +
> > >   timer {
> > >   compatible = "arm,armv7-timer";
> > >   interrupt-parent = <>;
> > > @@ -270,6 +300,19 @@
> > >   status = "disabled";
> > >   };
> > >
> > > + thermal: thermal@1100b000 {
> > > + #thermal-sensor-cells = <0>;
> > > + compatible = "mediatek,mt2701-thermal";
> > > + reg = <0 0x1100b000 0 0x1000>;
> > > + interrupts = ;
> > > + clocks = < CLK_PERI_THERM>, < CLK_PERI_AUXADC>;
> > > + clock-names = "therm", "auxadc";
> > > + resets = < 0x10>;
> > 
> > should be MT2701_PERI_AUXADC_SW_RST, right?
> > 
> Thank you for your reminding, I didn't realize mt2701-resets.h upstream
> already, I would update on next version, thank you.
> 
> resets = < MT2701_PERI_AUXADC_SW_RST>;

Actually, Should be MT2701_PERI_THERM_SW_RST.

resets = < MT2701_PERI_THERM_SW_RST>;

> > > + reset-names = "therm";
> > > + mediatek,auxadc = <>;
> > > + mediatek,apmixedsys = <>;
> > > + };
> > > +
> > >   nandc: nfi@1100d000 {
> > >   compatible = "mediatek,mt2701-nfc";
> > >   reg = <0 0x1100d000 0 0x1000>;
> > >
> 




Re: [PATCH v2 6/6] arm: dts: mt2701: Add thermal device node.

2017-01-15 Thread Dawei Chien
On Mon, 2017-01-16 at 11:44 +0800, Dawei Chien wrote:
> On Fri, 2017-01-13 at 16:27 +0100, Matthias Brugger wrote:
> > 
> > On 13/01/17 09:42, Erin Lo wrote:
> > > From: Dawei Chien 
> > >
> > > Add thermal controller device nodes for MT2701.
> > >
> > > Signed-off-by: Dawei Chien 
> > > Signed-off-by: Erin Lo 
> > > ---
> > >  arch/arm/boot/dts/mt2701.dtsi | 43 
> > > +++
> > >  1 file changed, 43 insertions(+)
> > >
> > > diff --git a/arch/arm/boot/dts/mt2701.dtsi b/arch/arm/boot/dts/mt2701.dtsi
> > > index 3847f70..c43d5f8 100644
> > > --- a/arch/arm/boot/dts/mt2701.dtsi
> > > +++ b/arch/arm/boot/dts/mt2701.dtsi
> > > @@ -89,6 +89,36 @@
> > >   clock-output-names = "rtc32k";
> > >   };
> > >
> > > + thermal-zones {
> > > + cpu_thermal: cpu_thermal {
> > > + polling-delay-passive = <1000>; /* milliseconds */
> > > + polling-delay = <1000>; /* milliseconds */
> > > +
> > > + thermal-sensors = < 0>;
> > > + sustainable-power = <1000>;
> > > +
> > > + trips {
> > > + threshold: trip-point@0 {
> > > + temperature = <68000>;
> > > + hysteresis = <2000>;
> > > + type = "passive";
> > > + };
> > > +
> > > + target: trip-point@1 {
> > > + temperature = <85000>;
> > > + hysteresis = <2000>;
> > > + type = "passive";
> > > + };
> > > +
> > > + cpu_crit: cpu_crit@0 {
> > > + temperature = <115000>;
> > > + hysteresis = <2000>;
> > > + type = "critical";
> > > + };
> > > + };
> > > + };
> > > + };
> > > +
> > >   timer {
> > >   compatible = "arm,armv7-timer";
> > >   interrupt-parent = <>;
> > > @@ -270,6 +300,19 @@
> > >   status = "disabled";
> > >   };
> > >
> > > + thermal: thermal@1100b000 {
> > > + #thermal-sensor-cells = <0>;
> > > + compatible = "mediatek,mt2701-thermal";
> > > + reg = <0 0x1100b000 0 0x1000>;
> > > + interrupts = ;
> > > + clocks = < CLK_PERI_THERM>, < CLK_PERI_AUXADC>;
> > > + clock-names = "therm", "auxadc";
> > > + resets = < 0x10>;
> > 
> > should be MT2701_PERI_AUXADC_SW_RST, right?
> > 
> Thank you for your reminding, I didn't realize mt2701-resets.h upstream
> already, I would update on next version, thank you.
> 
> resets = < MT2701_PERI_AUXADC_SW_RST>;

Actually, Should be MT2701_PERI_THERM_SW_RST.

resets = < MT2701_PERI_THERM_SW_RST>;

> > > + reset-names = "therm";
> > > + mediatek,auxadc = <>;
> > > + mediatek,apmixedsys = <>;
> > > + };
> > > +
> > >   nandc: nfi@1100d000 {
> > >   compatible = "mediatek,mt2701-nfc";
> > >   reg = <0 0x1100d000 0 0x1000>;
> > >
> 




Re: [PATCH v2 6/6] arm: dts: mt2701: Add thermal device node.

2017-01-15 Thread Dawei Chien
On Fri, 2017-01-13 at 16:27 +0100, Matthias Brugger wrote:
> 
> On 13/01/17 09:42, Erin Lo wrote:
> > From: Dawei Chien <dawei.ch...@mediatek.com>
> >
> > Add thermal controller device nodes for MT2701.
> >
> > Signed-off-by: Dawei Chien <dawei.ch...@mediatek.com>
> > Signed-off-by: Erin Lo <erin...@mediatek.com>
> > ---
> >  arch/arm/boot/dts/mt2701.dtsi | 43 
> > +++
> >  1 file changed, 43 insertions(+)
> >
> > diff --git a/arch/arm/boot/dts/mt2701.dtsi b/arch/arm/boot/dts/mt2701.dtsi
> > index 3847f70..c43d5f8 100644
> > --- a/arch/arm/boot/dts/mt2701.dtsi
> > +++ b/arch/arm/boot/dts/mt2701.dtsi
> > @@ -89,6 +89,36 @@
> > clock-output-names = "rtc32k";
> > };
> >
> > +   thermal-zones {
> > +   cpu_thermal: cpu_thermal {
> > +   polling-delay-passive = <1000>; /* milliseconds */
> > +   polling-delay = <1000>; /* milliseconds */
> > +
> > +   thermal-sensors = < 0>;
> > +   sustainable-power = <1000>;
> > +
> > +   trips {
> > +   threshold: trip-point@0 {
> > +   temperature = <68000>;
> > +   hysteresis = <2000>;
> > +   type = "passive";
> > +   };
> > +
> > +   target: trip-point@1 {
> > +   temperature = <85000>;
> > +   hysteresis = <2000>;
> > +   type = "passive";
> > +   };
> > +
> > +   cpu_crit: cpu_crit@0 {
> > +   temperature = <115000>;
> > +   hysteresis = <2000>;
> > +   type = "critical";
> > +   };
> > +   };
> > +   };
> > +   };
> > +
> > timer {
> > compatible = "arm,armv7-timer";
> > interrupt-parent = <>;
> > @@ -270,6 +300,19 @@
> > status = "disabled";
> > };
> >
> > +   thermal: thermal@1100b000 {
> > +   #thermal-sensor-cells = <0>;
> > +   compatible = "mediatek,mt2701-thermal";
> > +   reg = <0 0x1100b000 0 0x1000>;
> > +   interrupts = ;
> > +   clocks = < CLK_PERI_THERM>, < CLK_PERI_AUXADC>;
> > +   clock-names = "therm", "auxadc";
> > +   resets = < 0x10>;
> 
> should be MT2701_PERI_AUXADC_SW_RST, right?
> 
Thank you for your reminding, I didn't realize mt2701-resets.h upstream
already, I would update on next version, thank you.

resets = < MT2701_PERI_AUXADC_SW_RST>;

> > +   reset-names = "therm";
> > +   mediatek,auxadc = <>;
> > +   mediatek,apmixedsys = <>;
> > +   };
> > +
> > nandc: nfi@1100d000 {
> > compatible = "mediatek,mt2701-nfc";
> > reg = <0 0x1100d000 0 0x1000>;
> >




Re: [PATCH v2 6/6] arm: dts: mt2701: Add thermal device node.

2017-01-15 Thread Dawei Chien
On Fri, 2017-01-13 at 16:27 +0100, Matthias Brugger wrote:
> 
> On 13/01/17 09:42, Erin Lo wrote:
> > From: Dawei Chien 
> >
> > Add thermal controller device nodes for MT2701.
> >
> > Signed-off-by: Dawei Chien 
> > Signed-off-by: Erin Lo 
> > ---
> >  arch/arm/boot/dts/mt2701.dtsi | 43 
> > +++
> >  1 file changed, 43 insertions(+)
> >
> > diff --git a/arch/arm/boot/dts/mt2701.dtsi b/arch/arm/boot/dts/mt2701.dtsi
> > index 3847f70..c43d5f8 100644
> > --- a/arch/arm/boot/dts/mt2701.dtsi
> > +++ b/arch/arm/boot/dts/mt2701.dtsi
> > @@ -89,6 +89,36 @@
> > clock-output-names = "rtc32k";
> > };
> >
> > +   thermal-zones {
> > +   cpu_thermal: cpu_thermal {
> > +   polling-delay-passive = <1000>; /* milliseconds */
> > +   polling-delay = <1000>; /* milliseconds */
> > +
> > +   thermal-sensors = < 0>;
> > +   sustainable-power = <1000>;
> > +
> > +   trips {
> > +   threshold: trip-point@0 {
> > +   temperature = <68000>;
> > +   hysteresis = <2000>;
> > +   type = "passive";
> > +   };
> > +
> > +   target: trip-point@1 {
> > +   temperature = <85000>;
> > +   hysteresis = <2000>;
> > +   type = "passive";
> > +   };
> > +
> > +   cpu_crit: cpu_crit@0 {
> > +   temperature = <115000>;
> > +   hysteresis = <2000>;
> > +   type = "critical";
> > +   };
> > +   };
> > +   };
> > +   };
> > +
> > timer {
> > compatible = "arm,armv7-timer";
> > interrupt-parent = <>;
> > @@ -270,6 +300,19 @@
> > status = "disabled";
> > };
> >
> > +   thermal: thermal@1100b000 {
> > +   #thermal-sensor-cells = <0>;
> > +   compatible = "mediatek,mt2701-thermal";
> > +   reg = <0 0x1100b000 0 0x1000>;
> > +   interrupts = ;
> > +   clocks = < CLK_PERI_THERM>, < CLK_PERI_AUXADC>;
> > +   clock-names = "therm", "auxadc";
> > +   resets = < 0x10>;
> 
> should be MT2701_PERI_AUXADC_SW_RST, right?
> 
Thank you for your reminding, I didn't realize mt2701-resets.h upstream
already, I would update on next version, thank you.

resets = < MT2701_PERI_AUXADC_SW_RST>;

> > +   reset-names = "therm";
> > +   mediatek,auxadc = <>;
> > +   mediatek,apmixedsys = <>;
> > +   };
> > +
> > nandc: nfi@1100d000 {
> > compatible = "mediatek,mt2701-nfc";
> > reg = <0 0x1100d000 0 0x1000>;
> >




arm64: dts: mt8173: add node for thermal calibration

2017-01-12 Thread Dawei Chien
From: "dawei.ch...@mediatek.com" <dawei.ch...@mediatek.com>

Add this for supporting thermal calibration by e-fuse data.

Signed-off-by: Dawei Chien <dawei.ch...@mediatek.com>
---
 arch/arm64/boot/dts/mediatek/mt8173.dtsi | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
index 12e7027..adfac1e 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -401,6 +401,11 @@
efuse: efuse@10206000 {
compatible = "mediatek,mt8173-efuse";
reg = <0 0x10206000 0 0x1000>;
+   #address-cells = <1>;
+   #size-cells = <1>;
+   thermal_calibration: calib@528 {
+   reg = <0x528 0xc>;
+   };
};
 
apmixedsys: clock-controller@10209000 {
@@ -574,6 +579,8 @@
resets = < MT8173_PERI_THERM_SW_RST>;
mediatek,auxadc = <>;
mediatek,apmixedsys = <>;
+   nvmem-cells = <_calibration>;
+   nvmem-cell-names = "calibration-data";
};
 
nor_flash: spi@1100d000 {
-- 
1.9.1



arm64: dts: mt8173: add node for thermal calibration

2017-01-12 Thread Dawei Chien
From: "dawei.ch...@mediatek.com" 

Add this for supporting thermal calibration by e-fuse data.

Signed-off-by: Dawei Chien 
---
 arch/arm64/boot/dts/mediatek/mt8173.dtsi | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
index 12e7027..adfac1e 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -401,6 +401,11 @@
efuse: efuse@10206000 {
compatible = "mediatek,mt8173-efuse";
reg = <0 0x10206000 0 0x1000>;
+   #address-cells = <1>;
+   #size-cells = <1>;
+   thermal_calibration: calib@528 {
+   reg = <0x528 0xc>;
+   };
};
 
apmixedsys: clock-controller@10209000 {
@@ -574,6 +579,8 @@
resets = < MT8173_PERI_THERM_SW_RST>;
mediatek,auxadc = <>;
mediatek,apmixedsys = <>;
+   nvmem-cells = <_calibration>;
+   nvmem-cell-names = "calibration-data";
};
 
nor_flash: spi@1100d000 {
-- 
1.9.1



Re: [PATCH v2 3/3] arm: dts: thermal: add thermal/auxadc node.

2016-09-07 Thread Dawei Chien
On Tue, 2016-09-06 at 11:28 +0800, Dawei Chien wrote:
> Dear Rui,
> 
> On Tue, 2016-09-06 at 08:30 +0800, Zhang Rui wrote:
> > On 二, 2016-09-06 at 08:24 +0800, Zhang Rui wrote:
> > > On 四, 2016-08-18 at 11:50 +0800, Dawei Chien wrote:
> > > > 
> > > > This adds the thermal controller and auxadc nodes
> > > > to the Mediatek MT2701 dtsi file.
> > > > 
> > > > Signed-off-by: Dawei Chien <dawei.ch...@mediatek.com>
> > > > ---
> > > > This patch depned on:
> > > > https://patchwork.kernel.org/patch/9249589/
> > > > https://patchwork.kernel.org/patch/9249589/
> > > Hmm, does this mean that I should take all these three patches and
> > > hold
> > > the patches in next merge window until the above patch has been
> > > merged?
> > > 
> Yes, this patch is base on auxadc patchset.
> 
> > Patch 3/3 can not be applied on top of upstream kernel, so I guess it
> > still has some other dependencies.
> > I think I can apply patch 1, 2 first. And patch 3/3 should be handled
> > in the dt tree.
> 
> Sorry, this patch is also need Mediatek's clock patchset what I miss to
> add in dependency list, I would resend this dt tree once clock patch
> merge, or resend this for right dependency on next version, thank you.

Actually, since patch1/patch2 would be OK so far, I would just only
resend patch3 after MTK clock pathcset ready, I prefer to merge
patch1/patch2 if possible, thank you.


> > thanks,
> > rui
> > > thanks,
> > > rui 
> > > > 
> > > > ---
> > > >  arch/arm/boot/dts/mt2701.dtsi |   44
> > > > +
> > > >  1 file changed, 44 insertions(+)
> > > > 
> > > > diff --git a/arch/arm/boot/dts/mt2701.dtsi
> > > > b/arch/arm/boot/dts/mt2701.dtsi
> > > > index e9150a4..cee4724 100644
> > > > --- a/arch/arm/boot/dts/mt2701.dtsi
> > > > +++ b/arch/arm/boot/dts/mt2701.dtsi
> > > > @@ -87,6 +87,36 @@
> > > > clock-output-names = "rtc32k";
> > > > };
> > > >  
> > > > +   thermal-zones {
> > > > +   cpu_thermal: cpu_thermal {
> > > > +   polling-delay-passive = <1000>; /*
> > > > milliseconds */
> > > > +   polling-delay = <1000>; /* milliseconds */
> > > > +
> > > > +   thermal-sensors = < 0>;
> > > > +   sustainable-power = <1000>;
> > > > +
> > > > +   trips {
> > > > +   threshold: trip-point@0 {
> > > > +   temperature = <68000>;
> > > > +   hysteresis = <2000>;
> > > > +   type = "passive";
> > > > +   };
> > > > +
> > > > +   target: trip-point@1 {
> > > > +   temperature = <85000>;
> > > > +   hysteresis = <2000>;
> > > > +   type = "passive";
> > > > +   };
> > > > +
> > > > +   cpu_crit: cpu_crit@0 {
> > > > +   temperature = <115000>;
> > > > +   hysteresis = <2000>;
> > > > +   type = "critical";
> > > > +   };
> > > > +   };
> > > > +   };
> > > > +   };
> > > > +
> > > > timer {
> > > > compatible = "arm,armv7-timer";
> > > > interrupt-parent = <>;
> > > > @@ -222,4 +252,18 @@
> > > > clock-names = "baud", "bus";
> > > > status = "disabled";
> > > > };
> > > > +
> > > > +   thermal: thermal@1100b000 {
> > > > +   #thermal-sensor-cells = <0>;
> > > > +   compatible = "mediatek,mt2701-thermal";
> > > > +   reg = <0 0x1100b000 0 0x1000>;
> > > > +   interrupts = ;
> > > > +   clocks = < CLK_PERI_THERM>, <
> > > > CLK_PERI_AUXADC>;
> > > > +   clock-names = "therm", "auxadc";
> > > > +   resets = < 0x10>;
> > > > +   reset-names = "therm";
> > > > +   mediatek,auxadc = <>;
> > > > +   mediatek,apmixedsys = <>;
> > > > +   };
> > > > +
> > > >  };
> > > --
> > > To unsubscribe from this list: send the line "unsubscribe linux-pm"
> > > in
> > > the body of a message to majord...@vger.kernel.org
> > > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 




Re: [PATCH v2 3/3] arm: dts: thermal: add thermal/auxadc node.

2016-09-07 Thread Dawei Chien
On Tue, 2016-09-06 at 11:28 +0800, Dawei Chien wrote:
> Dear Rui,
> 
> On Tue, 2016-09-06 at 08:30 +0800, Zhang Rui wrote:
> > On 二, 2016-09-06 at 08:24 +0800, Zhang Rui wrote:
> > > On 四, 2016-08-18 at 11:50 +0800, Dawei Chien wrote:
> > > > 
> > > > This adds the thermal controller and auxadc nodes
> > > > to the Mediatek MT2701 dtsi file.
> > > > 
> > > > Signed-off-by: Dawei Chien 
> > > > ---
> > > > This patch depned on:
> > > > https://patchwork.kernel.org/patch/9249589/
> > > > https://patchwork.kernel.org/patch/9249589/
> > > Hmm, does this mean that I should take all these three patches and
> > > hold
> > > the patches in next merge window until the above patch has been
> > > merged?
> > > 
> Yes, this patch is base on auxadc patchset.
> 
> > Patch 3/3 can not be applied on top of upstream kernel, so I guess it
> > still has some other dependencies.
> > I think I can apply patch 1, 2 first. And patch 3/3 should be handled
> > in the dt tree.
> 
> Sorry, this patch is also need Mediatek's clock patchset what I miss to
> add in dependency list, I would resend this dt tree once clock patch
> merge, or resend this for right dependency on next version, thank you.

Actually, since patch1/patch2 would be OK so far, I would just only
resend patch3 after MTK clock pathcset ready, I prefer to merge
patch1/patch2 if possible, thank you.


> > thanks,
> > rui
> > > thanks,
> > > rui 
> > > > 
> > > > ---
> > > >  arch/arm/boot/dts/mt2701.dtsi |   44
> > > > +
> > > >  1 file changed, 44 insertions(+)
> > > > 
> > > > diff --git a/arch/arm/boot/dts/mt2701.dtsi
> > > > b/arch/arm/boot/dts/mt2701.dtsi
> > > > index e9150a4..cee4724 100644
> > > > --- a/arch/arm/boot/dts/mt2701.dtsi
> > > > +++ b/arch/arm/boot/dts/mt2701.dtsi
> > > > @@ -87,6 +87,36 @@
> > > > clock-output-names = "rtc32k";
> > > > };
> > > >  
> > > > +   thermal-zones {
> > > > +   cpu_thermal: cpu_thermal {
> > > > +   polling-delay-passive = <1000>; /*
> > > > milliseconds */
> > > > +   polling-delay = <1000>; /* milliseconds */
> > > > +
> > > > +   thermal-sensors = < 0>;
> > > > +   sustainable-power = <1000>;
> > > > +
> > > > +   trips {
> > > > +   threshold: trip-point@0 {
> > > > +   temperature = <68000>;
> > > > +   hysteresis = <2000>;
> > > > +   type = "passive";
> > > > +   };
> > > > +
> > > > +   target: trip-point@1 {
> > > > +   temperature = <85000>;
> > > > +   hysteresis = <2000>;
> > > > +   type = "passive";
> > > > +   };
> > > > +
> > > > +   cpu_crit: cpu_crit@0 {
> > > > +   temperature = <115000>;
> > > > +   hysteresis = <2000>;
> > > > +   type = "critical";
> > > > +   };
> > > > +   };
> > > > +   };
> > > > +   };
> > > > +
> > > > timer {
> > > > compatible = "arm,armv7-timer";
> > > > interrupt-parent = <>;
> > > > @@ -222,4 +252,18 @@
> > > > clock-names = "baud", "bus";
> > > > status = "disabled";
> > > > };
> > > > +
> > > > +   thermal: thermal@1100b000 {
> > > > +   #thermal-sensor-cells = <0>;
> > > > +   compatible = "mediatek,mt2701-thermal";
> > > > +   reg = <0 0x1100b000 0 0x1000>;
> > > > +   interrupts = ;
> > > > +   clocks = < CLK_PERI_THERM>, <
> > > > CLK_PERI_AUXADC>;
> > > > +   clock-names = "therm", "auxadc";
> > > > +   resets = < 0x10>;
> > > > +   reset-names = "therm";
> > > > +   mediatek,auxadc = <>;
> > > > +   mediatek,apmixedsys = <>;
> > > > +   };
> > > > +
> > > >  };
> > > --
> > > To unsubscribe from this list: send the line "unsubscribe linux-pm"
> > > in
> > > the body of a message to majord...@vger.kernel.org
> > > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 




Re: [PATCH v2 3/3] arm: dts: thermal: add thermal/auxadc node.

2016-09-05 Thread Dawei Chien
Dear Rui,

On Tue, 2016-09-06 at 08:30 +0800, Zhang Rui wrote:
> On 二, 2016-09-06 at 08:24 +0800, Zhang Rui wrote:
> > On 四, 2016-08-18 at 11:50 +0800, Dawei Chien wrote:
> > > 
> > > This adds the thermal controller and auxadc nodes
> > > to the Mediatek MT2701 dtsi file.
> > > 
> > > Signed-off-by: Dawei Chien <dawei.ch...@mediatek.com>
> > > ---
> > > This patch depned on:
> > > https://patchwork.kernel.org/patch/9249589/
> > > https://patchwork.kernel.org/patch/9249589/
> > Hmm, does this mean that I should take all these three patches and
> > hold
> > the patches in next merge window until the above patch has been
> > merged?
> > 
Yes, this patch is base on auxadc patchset.

> Patch 3/3 can not be applied on top of upstream kernel, so I guess it
> still has some other dependencies.
> I think I can apply patch 1, 2 first. And patch 3/3 should be handled
> in the dt tree.

Sorry, this patch is also need Mediatek's clock patchset what I miss to
add in dependency list, I would resend this dt tree once clock patch
merge, or resend this for right dependency on next version, thank you.

> thanks,
> rui
> > thanks,
> > rui 
> > > 
> > > ---
> > >  arch/arm/boot/dts/mt2701.dtsi |   44
> > > +
> > >  1 file changed, 44 insertions(+)
> > > 
> > > diff --git a/arch/arm/boot/dts/mt2701.dtsi
> > > b/arch/arm/boot/dts/mt2701.dtsi
> > > index e9150a4..cee4724 100644
> > > --- a/arch/arm/boot/dts/mt2701.dtsi
> > > +++ b/arch/arm/boot/dts/mt2701.dtsi
> > > @@ -87,6 +87,36 @@
> > >   clock-output-names = "rtc32k";
> > >   };
> > >  
> > > + thermal-zones {
> > > + cpu_thermal: cpu_thermal {
> > > + polling-delay-passive = <1000>; /*
> > > milliseconds */
> > > + polling-delay = <1000>; /* milliseconds */
> > > +
> > > + thermal-sensors = < 0>;
> > > + sustainable-power = <1000>;
> > > +
> > > + trips {
> > > + threshold: trip-point@0 {
> > > + temperature = <68000>;
> > > + hysteresis = <2000>;
> > > + type = "passive";
> > > + };
> > > +
> > > + target: trip-point@1 {
> > > + temperature = <85000>;
> > > + hysteresis = <2000>;
> > > + type = "passive";
> > > + };
> > > +
> > > + cpu_crit: cpu_crit@0 {
> > > + temperature = <115000>;
> > > + hysteresis = <2000>;
> > > + type = "critical";
> > > + };
> > > + };
> > > + };
> > > + };
> > > +
> > >   timer {
> > >   compatible = "arm,armv7-timer";
> > >   interrupt-parent = <>;
> > > @@ -222,4 +252,18 @@
> > >   clock-names = "baud", "bus";
> > >   status = "disabled";
> > >   };
> > > +
> > > + thermal: thermal@1100b000 {
> > > + #thermal-sensor-cells = <0>;
> > > + compatible = "mediatek,mt2701-thermal";
> > > + reg = <0 0x1100b000 0 0x1000>;
> > > + interrupts = ;
> > > + clocks = < CLK_PERI_THERM>, <
> > > CLK_PERI_AUXADC>;
> > > + clock-names = "therm", "auxadc";
> > > + resets = < 0x10>;
> > > + reset-names = "therm";
> > > + mediatek,auxadc = <>;
> > > + mediatek,apmixedsys = <>;
> > > + };
> > > +
> > >  };
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-pm"
> > in
> > the body of a message to majord...@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html




Re: [PATCH v2 3/3] arm: dts: thermal: add thermal/auxadc node.

2016-09-05 Thread Dawei Chien
Dear Rui,

On Tue, 2016-09-06 at 08:30 +0800, Zhang Rui wrote:
> On 二, 2016-09-06 at 08:24 +0800, Zhang Rui wrote:
> > On 四, 2016-08-18 at 11:50 +0800, Dawei Chien wrote:
> > > 
> > > This adds the thermal controller and auxadc nodes
> > > to the Mediatek MT2701 dtsi file.
> > > 
> > > Signed-off-by: Dawei Chien 
> > > ---
> > > This patch depned on:
> > > https://patchwork.kernel.org/patch/9249589/
> > > https://patchwork.kernel.org/patch/9249589/
> > Hmm, does this mean that I should take all these three patches and
> > hold
> > the patches in next merge window until the above patch has been
> > merged?
> > 
Yes, this patch is base on auxadc patchset.

> Patch 3/3 can not be applied on top of upstream kernel, so I guess it
> still has some other dependencies.
> I think I can apply patch 1, 2 first. And patch 3/3 should be handled
> in the dt tree.

Sorry, this patch is also need Mediatek's clock patchset what I miss to
add in dependency list, I would resend this dt tree once clock patch
merge, or resend this for right dependency on next version, thank you.

> thanks,
> rui
> > thanks,
> > rui 
> > > 
> > > ---
> > >  arch/arm/boot/dts/mt2701.dtsi |   44
> > > +
> > >  1 file changed, 44 insertions(+)
> > > 
> > > diff --git a/arch/arm/boot/dts/mt2701.dtsi
> > > b/arch/arm/boot/dts/mt2701.dtsi
> > > index e9150a4..cee4724 100644
> > > --- a/arch/arm/boot/dts/mt2701.dtsi
> > > +++ b/arch/arm/boot/dts/mt2701.dtsi
> > > @@ -87,6 +87,36 @@
> > >   clock-output-names = "rtc32k";
> > >   };
> > >  
> > > + thermal-zones {
> > > + cpu_thermal: cpu_thermal {
> > > + polling-delay-passive = <1000>; /*
> > > milliseconds */
> > > + polling-delay = <1000>; /* milliseconds */
> > > +
> > > + thermal-sensors = < 0>;
> > > + sustainable-power = <1000>;
> > > +
> > > + trips {
> > > + threshold: trip-point@0 {
> > > + temperature = <68000>;
> > > + hysteresis = <2000>;
> > > + type = "passive";
> > > + };
> > > +
> > > + target: trip-point@1 {
> > > + temperature = <85000>;
> > > + hysteresis = <2000>;
> > > + type = "passive";
> > > + };
> > > +
> > > + cpu_crit: cpu_crit@0 {
> > > + temperature = <115000>;
> > > + hysteresis = <2000>;
> > > + type = "critical";
> > > + };
> > > + };
> > > + };
> > > + };
> > > +
> > >   timer {
> > >   compatible = "arm,armv7-timer";
> > >   interrupt-parent = <>;
> > > @@ -222,4 +252,18 @@
> > >   clock-names = "baud", "bus";
> > >   status = "disabled";
> > >   };
> > > +
> > > + thermal: thermal@1100b000 {
> > > + #thermal-sensor-cells = <0>;
> > > + compatible = "mediatek,mt2701-thermal";
> > > + reg = <0 0x1100b000 0 0x1000>;
> > > + interrupts = ;
> > > + clocks = < CLK_PERI_THERM>, <
> > > CLK_PERI_AUXADC>;
> > > + clock-names = "therm", "auxadc";
> > > + resets = < 0x10>;
> > > + reset-names = "therm";
> > > + mediatek,auxadc = <>;
> > > + mediatek,apmixedsys = <>;
> > > + };
> > > +
> > >  };
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-pm"
> > in
> > the body of a message to majord...@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html




[PATCH v2 0/3] Add Mediatek thermal driver for mt2701

2016-08-17 Thread Dawei Chien
This series support for mt2701 chip to mtk_thermal.c,
and integrate both mt8173 and mt2701 on the same driver.
MT8173 has four banks and five sensors, and MT2701 has
only one bank and three sensors.

Change since V1:
1. Restore macro name with MT8173 for nvmem calibration data
since original macro name could be used for both MT2701/MT8173.

2. Add flexible array member to instead of normal array since
thermal bank has different array size between MT2701 to MT8173.

Dawei Chien (3):
  dt-bindings: thermal: Add binding document for Mediatek thermal
controller
  thermal: Add Mediatek thermal driver for mt2701.
  arm: dts: thermal: add thermal/auxadc node.

 .../bindings/thermal/mediatek-thermal.txt  |4 +-
 arch/arm/boot/dts/mt2701.dtsi  |   44 
 drivers/thermal/mtk_thermal.c  |  215 ++--
 3 files changed, 199 insertions(+), 64 deletions(-)



[PATCH v2 1/3] dt-bindings: thermal: Add binding document for Mediatek thermal controller

2016-08-17 Thread Dawei Chien
This adds the device tree binding documentation for the mediatek thermal
controller found on Mediatek MT2701.

Signed-off-by: Dawei Chien <dawei.ch...@mediatek.com>
---
 .../bindings/thermal/mediatek-thermal.txt  |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/thermal/mediatek-thermal.txt 
b/Documentation/devicetree/bindings/thermal/mediatek-thermal.txt
index 81f9a51..e2f494d 100644
--- a/Documentation/devicetree/bindings/thermal/mediatek-thermal.txt
+++ b/Documentation/devicetree/bindings/thermal/mediatek-thermal.txt
@@ -8,7 +8,9 @@ apmixedsys register space via AHB bus accesses, so a phandle to 
the APMIXEDSYS
 is also needed.
 
 Required properties:
-- compatible: "mediatek,mt8173-thermal"
+- compatible:
+  - "mediatek,mt8173-thermal" : For MT8173 family of SoCs
+  - "mediatek,mt2701-thermal" : For MT2701 family of SoCs
 - reg: Address range of the thermal controller
 - interrupts: IRQ for the thermal controller
 - clocks, clock-names: Clocks needed for the thermal controller. required
-- 
1.7.9.5



[PATCH v2 0/3] Add Mediatek thermal driver for mt2701

2016-08-17 Thread Dawei Chien
This series support for mt2701 chip to mtk_thermal.c,
and integrate both mt8173 and mt2701 on the same driver.
MT8173 has four banks and five sensors, and MT2701 has
only one bank and three sensors.

Change since V1:
1. Restore macro name with MT8173 for nvmem calibration data
since original macro name could be used for both MT2701/MT8173.

2. Add flexible array member to instead of normal array since
thermal bank has different array size between MT2701 to MT8173.

Dawei Chien (3):
  dt-bindings: thermal: Add binding document for Mediatek thermal
controller
  thermal: Add Mediatek thermal driver for mt2701.
  arm: dts: thermal: add thermal/auxadc node.

 .../bindings/thermal/mediatek-thermal.txt  |4 +-
 arch/arm/boot/dts/mt2701.dtsi  |   44 
 drivers/thermal/mtk_thermal.c  |  215 ++--
 3 files changed, 199 insertions(+), 64 deletions(-)



[PATCH v2 1/3] dt-bindings: thermal: Add binding document for Mediatek thermal controller

2016-08-17 Thread Dawei Chien
This adds the device tree binding documentation for the mediatek thermal
controller found on Mediatek MT2701.

Signed-off-by: Dawei Chien 
---
 .../bindings/thermal/mediatek-thermal.txt  |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/thermal/mediatek-thermal.txt 
b/Documentation/devicetree/bindings/thermal/mediatek-thermal.txt
index 81f9a51..e2f494d 100644
--- a/Documentation/devicetree/bindings/thermal/mediatek-thermal.txt
+++ b/Documentation/devicetree/bindings/thermal/mediatek-thermal.txt
@@ -8,7 +8,9 @@ apmixedsys register space via AHB bus accesses, so a phandle to 
the APMIXEDSYS
 is also needed.
 
 Required properties:
-- compatible: "mediatek,mt8173-thermal"
+- compatible:
+  - "mediatek,mt8173-thermal" : For MT8173 family of SoCs
+  - "mediatek,mt2701-thermal" : For MT2701 family of SoCs
 - reg: Address range of the thermal controller
 - interrupts: IRQ for the thermal controller
 - clocks, clock-names: Clocks needed for the thermal controller. required
-- 
1.7.9.5



[PATCH v2 2/3] thermal: Add Mediatek thermal driver for mt2701.

2016-08-17 Thread Dawei Chien
This patch adds support for mt2701 chip to mtk_thermal,
and integrate both mt8173 and mt2701 on the same driver.
MT8173 has four banks and five sensors, and MT2701 has
only one bank and three sensors.

Signed-off-by: Dawei Chien <dawei.ch...@mediatek.com>
---
This patch dependents on "Add clock support for Mediatek MT2701"[1].
Please accept this patch together with [1].
[1]http://lists.infradead.org/pipermail/linux-mediatek/2016-August/006620.html
---
 drivers/thermal/mtk_thermal.c |  215 +
 1 file changed, 152 insertions(+), 63 deletions(-)

diff --git a/drivers/thermal/mtk_thermal.c b/drivers/thermal/mtk_thermal.c
index 262ab0a..7b233c7 100644
--- a/drivers/thermal/mtk_thermal.c
+++ b/drivers/thermal/mtk_thermal.c
@@ -2,6 +2,7 @@
  * Copyright (c) 2015 MediaTek Inc.
  * Author: Hanyi Wu <hanyi...@mediatek.com>
  * Sascha Hauer <s.ha...@pengutronix.de>
+ * Dawei Chien <dawei.ch...@mediatek.com>
  *
  * 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
@@ -21,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -88,6 +90,7 @@
 #define TEMP_ADCVALIDMASK_VALID_HIGH   BIT(5)
 #define TEMP_ADCVALIDMASK_VALID_POS(bit)   (bit)
 
+/* MT8173 thermal sensors */
 #define MT8173_TS1 0
 #define MT8173_TS2 1
 #define MT8173_TS3 2
@@ -106,7 +109,12 @@
 /* The number of sensing points per bank */
 #define MT8173_NUM_SENSORS_PER_ZONE4
 
-/* Layout of the fuses providing the calibration data */
+/*
+ * Layout of the fuses providing the calibration data
+ * These macros could be used for both MT8173 and MT2701.
+ * MT8173 has five sensors and need five VTS calibration data,
+ * and MT2701 has three sensors and need three VTS calibration data.
+ */
 #define MT8173_CALIB_BUF0_VALIDBIT(0)
 #define MT8173_CALIB_BUF1_ADC_GE(x)(((x) >> 22) & 0x3ff)
 #define MT8173_CALIB_BUF0_VTS_TS1(x)   (((x) >> 17) & 0x1ff)
@@ -117,24 +125,50 @@
 #define MT8173_CALIB_BUF0_DEGC_CALI(x) (((x) >> 1) & 0x3f)
 #define MT8173_CALIB_BUF0_O_SLOPE(x)   (((x) >> 26) & 0x3f)
 
+/* MT2701 thermal sensors */
+#define MT2701_TS1 0
+#define MT2701_TS2 1
+#define MT2701_TSABB   2
+
+/* AUXADC channel 11 is used for the temperature sensors */
+#define MT2701_TEMP_AUXADC_CHANNEL 11
+
+/* The total number of temperature sensors in the MT2701 */
+#define MT2701_NUM_SENSORS 3
+
 #define THERMAL_NAME"mtk-thermal"
 
+/* The number of sensing points per bank */
+#define MT2701_NUM_SENSORS_PER_ZONE3
+
 struct mtk_thermal;
 
+struct thermal_bank_cfg {
+   unsigned int num_sensors;
+   const int *sensors;
+};
+
 struct mtk_thermal_bank {
struct mtk_thermal *mt;
int id;
 };
 
+struct mtk_thermal_data {
+   s32 num_banks;
+   s32 num_sensors;
+   s32 auxadc_channel;
+   const int *sensor_mux_values;
+   const int *msr;
+   const int *adcpnp;
+   struct thermal_bank_cfg bank_data[];
+};
+
 struct mtk_thermal {
struct device *dev;
void __iomem *thermal_base;
 
struct clk *clk_peri_therm;
struct clk *clk_auxadc;
-
-   struct mtk_thermal_bank banks[MT8173_NUM_ZONES];
-
/* lock: for getting and putting banks */
struct mutex lock;
 
@@ -144,16 +178,44 @@ struct mtk_thermal {
s32 o_slope;
s32 vts[MT8173_NUM_SENSORS];
 
+   const struct mtk_thermal_data *conf;
+   struct mtk_thermal_bank banks[];
 };
 
-struct mtk_thermal_bank_cfg {
-   unsigned int num_sensors;
-   unsigned int sensors[MT8173_NUM_SENSORS_PER_ZONE];
+/* MT8173 thermal sensor data */
+const int mt8173_bank_data[MT8173_NUM_ZONES][3] = {
+   { MT8173_TS2, MT8173_TS3 },
+   { MT8173_TS2, MT8173_TS4 },
+   { MT8173_TS1, MT8173_TS2, MT8173_TSABB },
+   { MT8173_TS2 },
 };
 
-static const int sensor_mux_values[MT8173_NUM_SENSORS] = { 0, 1, 2, 3, 16 };
+const int mt8173_msr[MT8173_NUM_SENSORS_PER_ZONE] = {
+   TEMP_MSR0, TEMP_MSR1, TEMP_MSR2, TEMP_MSR2
+};
 
-/*
+const int mt8173_adcpnp[MT8173_NUM_SENSORS_PER_ZONE] = {
+   TEMP_ADCPNP0, TEMP_ADCPNP1, TEMP_ADCPNP2, TEMP_ADCPNP3
+};
+
+const int mt8173_mux_values[MT8173_NUM_SENSORS] = { 0, 1, 2, 3, 16 };
+
+/* MT2701 thermal sensor data */
+const int mt2701_bank_data[MT2701_NUM_SENSORS] = {
+   MT2701_TS1, MT2701_TS2, MT2701_TSABB
+};
+
+const int mt2701_msr[MT2701_NUM_SENSORS_PER_ZONE] = {
+   TEMP_MSR0, TEMP_MSR1, TEMP_MSR2
+};
+
+const int mt2701_adcpnp[MT2701_NUM_SENSORS_PER_ZONE] = {
+   TEMP_ADCPNP0, TEMP_ADCPNP1, TEMP_ADCPNP2
+};
+
+const int mt2701_mux_values[MT2701_NUM_SENSORS] = { 0, 1, 16 };
+
+/**
  * The MT8173 thermal controller has four banks. Each bank can read up to
  * four temperature sensors simultaneously. The MT8173 has a total of 5
  * tempe

[PATCH v2 3/3] arm: dts: thermal: add thermal/auxadc node.

2016-08-17 Thread Dawei Chien
This adds the thermal controller and auxadc nodes
to the Mediatek MT2701 dtsi file.

Signed-off-by: Dawei Chien <dawei.ch...@mediatek.com>
---
This patch depned on:
https://patchwork.kernel.org/patch/9249589/
---
 arch/arm/boot/dts/mt2701.dtsi |   44 +
 1 file changed, 44 insertions(+)

diff --git a/arch/arm/boot/dts/mt2701.dtsi b/arch/arm/boot/dts/mt2701.dtsi
index e9150a4..cee4724 100644
--- a/arch/arm/boot/dts/mt2701.dtsi
+++ b/arch/arm/boot/dts/mt2701.dtsi
@@ -87,6 +87,36 @@
clock-output-names = "rtc32k";
};
 
+   thermal-zones {
+   cpu_thermal: cpu_thermal {
+   polling-delay-passive = <1000>; /* milliseconds */
+   polling-delay = <1000>; /* milliseconds */
+
+   thermal-sensors = < 0>;
+   sustainable-power = <1000>;
+
+   trips {
+   threshold: trip-point@0 {
+   temperature = <68000>;
+   hysteresis = <2000>;
+   type = "passive";
+   };
+
+   target: trip-point@1 {
+   temperature = <85000>;
+   hysteresis = <2000>;
+   type = "passive";
+   };
+
+   cpu_crit: cpu_crit@0 {
+   temperature = <115000>;
+   hysteresis = <2000>;
+   type = "critical";
+   };
+   };
+   };
+   };
+
timer {
compatible = "arm,armv7-timer";
interrupt-parent = <>;
@@ -222,4 +252,18 @@
clock-names = "baud", "bus";
status = "disabled";
};
+
+   thermal: thermal@1100b000 {
+   #thermal-sensor-cells = <0>;
+   compatible = "mediatek,mt2701-thermal";
+   reg = <0 0x1100b000 0 0x1000>;
+   interrupts = ;
+   clocks = < CLK_PERI_THERM>, < CLK_PERI_AUXADC>;
+   clock-names = "therm", "auxadc";
+   resets = < 0x10>;
+   reset-names = "therm";
+   mediatek,auxadc = <>;
+   mediatek,apmixedsys = <>;
+   };
+
 };
-- 
1.7.9.5



[PATCH v2 3/3] arm: dts: thermal: add thermal/auxadc node.

2016-08-17 Thread Dawei Chien
This adds the thermal controller and auxadc nodes
to the Mediatek MT2701 dtsi file.

Signed-off-by: Dawei Chien 
---
This patch depned on:
https://patchwork.kernel.org/patch/9249589/
---
 arch/arm/boot/dts/mt2701.dtsi |   44 +
 1 file changed, 44 insertions(+)

diff --git a/arch/arm/boot/dts/mt2701.dtsi b/arch/arm/boot/dts/mt2701.dtsi
index e9150a4..cee4724 100644
--- a/arch/arm/boot/dts/mt2701.dtsi
+++ b/arch/arm/boot/dts/mt2701.dtsi
@@ -87,6 +87,36 @@
clock-output-names = "rtc32k";
};
 
+   thermal-zones {
+   cpu_thermal: cpu_thermal {
+   polling-delay-passive = <1000>; /* milliseconds */
+   polling-delay = <1000>; /* milliseconds */
+
+   thermal-sensors = < 0>;
+   sustainable-power = <1000>;
+
+   trips {
+   threshold: trip-point@0 {
+   temperature = <68000>;
+   hysteresis = <2000>;
+   type = "passive";
+   };
+
+   target: trip-point@1 {
+   temperature = <85000>;
+   hysteresis = <2000>;
+   type = "passive";
+   };
+
+   cpu_crit: cpu_crit@0 {
+   temperature = <115000>;
+   hysteresis = <2000>;
+   type = "critical";
+   };
+   };
+   };
+   };
+
timer {
compatible = "arm,armv7-timer";
interrupt-parent = <>;
@@ -222,4 +252,18 @@
clock-names = "baud", "bus";
status = "disabled";
};
+
+   thermal: thermal@1100b000 {
+   #thermal-sensor-cells = <0>;
+   compatible = "mediatek,mt2701-thermal";
+   reg = <0 0x1100b000 0 0x1000>;
+   interrupts = ;
+   clocks = < CLK_PERI_THERM>, < CLK_PERI_AUXADC>;
+   clock-names = "therm", "auxadc";
+   resets = < 0x10>;
+   reset-names = "therm";
+   mediatek,auxadc = <>;
+   mediatek,apmixedsys = <>;
+   };
+
 };
-- 
1.7.9.5



[PATCH v2 2/3] thermal: Add Mediatek thermal driver for mt2701.

2016-08-17 Thread Dawei Chien
This patch adds support for mt2701 chip to mtk_thermal,
and integrate both mt8173 and mt2701 on the same driver.
MT8173 has four banks and five sensors, and MT2701 has
only one bank and three sensors.

Signed-off-by: Dawei Chien 
---
This patch dependents on "Add clock support for Mediatek MT2701"[1].
Please accept this patch together with [1].
[1]http://lists.infradead.org/pipermail/linux-mediatek/2016-August/006620.html
---
 drivers/thermal/mtk_thermal.c |  215 +
 1 file changed, 152 insertions(+), 63 deletions(-)

diff --git a/drivers/thermal/mtk_thermal.c b/drivers/thermal/mtk_thermal.c
index 262ab0a..7b233c7 100644
--- a/drivers/thermal/mtk_thermal.c
+++ b/drivers/thermal/mtk_thermal.c
@@ -2,6 +2,7 @@
  * Copyright (c) 2015 MediaTek Inc.
  * Author: Hanyi Wu 
  * Sascha Hauer 
+ * Dawei Chien 
  *
  * 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
@@ -21,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -88,6 +90,7 @@
 #define TEMP_ADCVALIDMASK_VALID_HIGH   BIT(5)
 #define TEMP_ADCVALIDMASK_VALID_POS(bit)   (bit)
 
+/* MT8173 thermal sensors */
 #define MT8173_TS1 0
 #define MT8173_TS2 1
 #define MT8173_TS3 2
@@ -106,7 +109,12 @@
 /* The number of sensing points per bank */
 #define MT8173_NUM_SENSORS_PER_ZONE4
 
-/* Layout of the fuses providing the calibration data */
+/*
+ * Layout of the fuses providing the calibration data
+ * These macros could be used for both MT8173 and MT2701.
+ * MT8173 has five sensors and need five VTS calibration data,
+ * and MT2701 has three sensors and need three VTS calibration data.
+ */
 #define MT8173_CALIB_BUF0_VALIDBIT(0)
 #define MT8173_CALIB_BUF1_ADC_GE(x)(((x) >> 22) & 0x3ff)
 #define MT8173_CALIB_BUF0_VTS_TS1(x)   (((x) >> 17) & 0x1ff)
@@ -117,24 +125,50 @@
 #define MT8173_CALIB_BUF0_DEGC_CALI(x) (((x) >> 1) & 0x3f)
 #define MT8173_CALIB_BUF0_O_SLOPE(x)   (((x) >> 26) & 0x3f)
 
+/* MT2701 thermal sensors */
+#define MT2701_TS1 0
+#define MT2701_TS2 1
+#define MT2701_TSABB   2
+
+/* AUXADC channel 11 is used for the temperature sensors */
+#define MT2701_TEMP_AUXADC_CHANNEL 11
+
+/* The total number of temperature sensors in the MT2701 */
+#define MT2701_NUM_SENSORS 3
+
 #define THERMAL_NAME"mtk-thermal"
 
+/* The number of sensing points per bank */
+#define MT2701_NUM_SENSORS_PER_ZONE3
+
 struct mtk_thermal;
 
+struct thermal_bank_cfg {
+   unsigned int num_sensors;
+   const int *sensors;
+};
+
 struct mtk_thermal_bank {
struct mtk_thermal *mt;
int id;
 };
 
+struct mtk_thermal_data {
+   s32 num_banks;
+   s32 num_sensors;
+   s32 auxadc_channel;
+   const int *sensor_mux_values;
+   const int *msr;
+   const int *adcpnp;
+   struct thermal_bank_cfg bank_data[];
+};
+
 struct mtk_thermal {
struct device *dev;
void __iomem *thermal_base;
 
struct clk *clk_peri_therm;
struct clk *clk_auxadc;
-
-   struct mtk_thermal_bank banks[MT8173_NUM_ZONES];
-
/* lock: for getting and putting banks */
struct mutex lock;
 
@@ -144,16 +178,44 @@ struct mtk_thermal {
s32 o_slope;
s32 vts[MT8173_NUM_SENSORS];
 
+   const struct mtk_thermal_data *conf;
+   struct mtk_thermal_bank banks[];
 };
 
-struct mtk_thermal_bank_cfg {
-   unsigned int num_sensors;
-   unsigned int sensors[MT8173_NUM_SENSORS_PER_ZONE];
+/* MT8173 thermal sensor data */
+const int mt8173_bank_data[MT8173_NUM_ZONES][3] = {
+   { MT8173_TS2, MT8173_TS3 },
+   { MT8173_TS2, MT8173_TS4 },
+   { MT8173_TS1, MT8173_TS2, MT8173_TSABB },
+   { MT8173_TS2 },
 };
 
-static const int sensor_mux_values[MT8173_NUM_SENSORS] = { 0, 1, 2, 3, 16 };
+const int mt8173_msr[MT8173_NUM_SENSORS_PER_ZONE] = {
+   TEMP_MSR0, TEMP_MSR1, TEMP_MSR2, TEMP_MSR2
+};
 
-/*
+const int mt8173_adcpnp[MT8173_NUM_SENSORS_PER_ZONE] = {
+   TEMP_ADCPNP0, TEMP_ADCPNP1, TEMP_ADCPNP2, TEMP_ADCPNP3
+};
+
+const int mt8173_mux_values[MT8173_NUM_SENSORS] = { 0, 1, 2, 3, 16 };
+
+/* MT2701 thermal sensor data */
+const int mt2701_bank_data[MT2701_NUM_SENSORS] = {
+   MT2701_TS1, MT2701_TS2, MT2701_TSABB
+};
+
+const int mt2701_msr[MT2701_NUM_SENSORS_PER_ZONE] = {
+   TEMP_MSR0, TEMP_MSR1, TEMP_MSR2
+};
+
+const int mt2701_adcpnp[MT2701_NUM_SENSORS_PER_ZONE] = {
+   TEMP_ADCPNP0, TEMP_ADCPNP1, TEMP_ADCPNP2
+};
+
+const int mt2701_mux_values[MT2701_NUM_SENSORS] = { 0, 1, 16 };
+
+/**
  * The MT8173 thermal controller has four banks. Each bank can read up to
  * four temperature sensors simultaneously. The MT8173 has a total of 5
  * temperature sensors. We use each bank to measure a certain area of the
@@ -166,42 +228,53 @@ static const int sensor_mux_values[MT8173_N

Re: [PATCH 3/3] arm: dts: thermal: add thermal/auxadc node.

2016-08-15 Thread dawei chien
Hi Matthias,

On Thu, 2016-08-11 at 17:51 +0200, Matthias Brugger wrote:
> 
> On 07/07/16 11:06, Dawei Chien wrote:
> > This adds the thermal controller and auxadc nodes
> > to the Mediatek MT2701 dtsi file.
> >
> > Signed-off-by: Dawei Chien <dawei.ch...@mediatek.com>
> > ---
> > This patch depned on:
> > https://patchwork.kernel.org/patch/9213545/
> > ---
> >  arch/arm/boot/dts/mt2701.dtsi |   43 
> > +
> >  1 file changed, 43 insertions(+)
> >
> > diff --git a/arch/arm/boot/dts/mt2701.dtsi b/arch/arm/boot/dts/mt2701.dtsi
> > index 2ac8b50..0834a23 100644
> > --- a/arch/arm/boot/dts/mt2701.dtsi
> > +++ b/arch/arm/boot/dts/mt2701.dtsi
> > @@ -77,6 +77,36 @@
> > #clock-cells = <0>;
> > };
> >
> > +   thermal-zones {
> > +   cpu_thermal: cpu_thermal {
> > +   polling-delay-passive = <1000>; /* milliseconds */
> > +   polling-delay = <1000>; /* milliseconds */
> > +
> > +   thermal-sensors = < 0>;
> > +   sustainable-power = <1000>;
> > +
> > +   trips {
> > +   threshold: trip-point@0 {
> > +   temperature = <68000>;
> > +   hysteresis = <2000>;
> > +   type = "passive";
> > +   };
> > +
> > +   target: trip-point@1 {
> > +   temperature = <85000>;
> > +   hysteresis = <2000>;
> > +   type = "passive";
> > +   };
> > +
> > +   cpu_crit: cpu_crit@0 {
> > +   temperature = <115000>;
> > +   hysteresis = <2000>;
> > +   type = "critical";
> > +   };
> > +   };
> > +   };
> > +   };
> > +
> > timer {
> > compatible = "arm,armv7-timer";
> > interrupt-parent = <>;
> > @@ -183,4 +213,17 @@
> > clocks = <_clk>;
> > status = "disabled";
> > };
> > +
> > +   thermal: thermal@1100b000 {
> > +   #thermal-sensor-cells = <0>;
> > +   compatible = "mediatek,mt2701-thermal";
> > +   reg = <0 0x1100b000 0 0x1000>;
> > +   interrupts = ;
> > +   clocks = < CLK_PERI_THERM>, < CLK_PERI_AUXADC>;
> > +   clock-names = "therm", "auxadc";
> > +   resets = < 0x10>;
> > +   reset-names = "therm";
> > +   mediatek,auxadc = <>;
> > +   mediatek,apmixedsys = <>;
> > +   };
> >  };
> >
> 
> what about:
> status = "disabled"; ?

Since thermal driver would protect our platform by shutdown method once
SoC temperature over critical point, I prefer keep this rather than
disabling, how do you think, thank you.

BR,
Dawei



Re: [PATCH 3/3] arm: dts: thermal: add thermal/auxadc node.

2016-08-15 Thread dawei chien
Hi Matthias,

On Thu, 2016-08-11 at 17:51 +0200, Matthias Brugger wrote:
> 
> On 07/07/16 11:06, Dawei Chien wrote:
> > This adds the thermal controller and auxadc nodes
> > to the Mediatek MT2701 dtsi file.
> >
> > Signed-off-by: Dawei Chien 
> > ---
> > This patch depned on:
> > https://patchwork.kernel.org/patch/9213545/
> > ---
> >  arch/arm/boot/dts/mt2701.dtsi |   43 
> > +
> >  1 file changed, 43 insertions(+)
> >
> > diff --git a/arch/arm/boot/dts/mt2701.dtsi b/arch/arm/boot/dts/mt2701.dtsi
> > index 2ac8b50..0834a23 100644
> > --- a/arch/arm/boot/dts/mt2701.dtsi
> > +++ b/arch/arm/boot/dts/mt2701.dtsi
> > @@ -77,6 +77,36 @@
> > #clock-cells = <0>;
> > };
> >
> > +   thermal-zones {
> > +   cpu_thermal: cpu_thermal {
> > +   polling-delay-passive = <1000>; /* milliseconds */
> > +   polling-delay = <1000>; /* milliseconds */
> > +
> > +   thermal-sensors = < 0>;
> > +   sustainable-power = <1000>;
> > +
> > +   trips {
> > +   threshold: trip-point@0 {
> > +   temperature = <68000>;
> > +   hysteresis = <2000>;
> > +   type = "passive";
> > +   };
> > +
> > +   target: trip-point@1 {
> > +   temperature = <85000>;
> > +   hysteresis = <2000>;
> > +   type = "passive";
> > +   };
> > +
> > +   cpu_crit: cpu_crit@0 {
> > +   temperature = <115000>;
> > +   hysteresis = <2000>;
> > +   type = "critical";
> > +   };
> > +   };
> > +   };
> > +   };
> > +
> > timer {
> > compatible = "arm,armv7-timer";
> > interrupt-parent = <>;
> > @@ -183,4 +213,17 @@
> > clocks = <_clk>;
> > status = "disabled";
> > };
> > +
> > +   thermal: thermal@1100b000 {
> > +   #thermal-sensor-cells = <0>;
> > +   compatible = "mediatek,mt2701-thermal";
> > +   reg = <0 0x1100b000 0 0x1000>;
> > +   interrupts = ;
> > +   clocks = < CLK_PERI_THERM>, < CLK_PERI_AUXADC>;
> > +   clock-names = "therm", "auxadc";
> > +   resets = < 0x10>;
> > +   reset-names = "therm";
> > +   mediatek,auxadc = <>;
> > +   mediatek,apmixedsys = <>;
> > +   };
> >  };
> >
> 
> what about:
> status = "disabled"; ?

Since thermal driver would protect our platform by shutdown method once
SoC temperature over critical point, I prefer keep this rather than
disabling, how do you think, thank you.

BR,
Dawei



Re: [PATCH 1/3] dt-bindings: thermal: Add binding document for Mediatek thermal controller

2016-08-15 Thread dawei chien
Hi Matthias,

On Thu, 2016-08-11 at 17:48 +0200, Matthias Brugger wrote:
> 
> On 11/07/16 10:52, dawei chien wrote:
> > Dear Keerthy,
> >
> > On Thu, 2016-07-07 at 16:39 +0530, Keerthy wrote:
> >>
> >> On Thursday 07 July 2016 02:36 PM, Dawei Chien wrote:
> >>> This adds the device tree binding documentation for the mediatek thermal
> >>> controller found on Mediatek MT2701.
> >>>
> >>> Signed-off-by: Dawei Chien <dawei.ch...@mediatek.com>
> >>> ---
> >>>   .../bindings/thermal/mediatek-thermal.txt  |2 +-
> >>>   1 file changed, 1 insertion(+), 1 deletion(-)
> >>>
> >>> diff --git 
> >>> a/Documentation/devicetree/bindings/thermal/mediatek-thermal.txt 
> >>> b/Documentation/devicetree/bindings/thermal/mediatek-thermal.txt
> >>> index 81f9a51..bb55e79 100644
> >>> --- a/Documentation/devicetree/bindings/thermal/mediatek-thermal.txt
> >>> +++ b/Documentation/devicetree/bindings/thermal/mediatek-thermal.txt
> >>> @@ -8,7 +8,7 @@ apmixedsys register space via AHB bus accesses, so a 
> >>> phandle to the APMIXEDSYS
> >>>   is also needed.
> >>>
> >>>   Required properties:
> >>> -- compatible: "mediatek,mt8173-thermal"
> >>> +- compatible: "mediatek,mt8173-thermal" or "mediatek,mt2701-thermal"
> >>
> >> - compatible :
> >>   - "mediatek,mt8173-thermal" : For MT8173 family of SoCs
> >>   - "mediatek,mt2701-thermal" : For MT2701 family of SoCs
> >
> > Thank you, I will update it on next version.
> >
> 
> Do you know about the compability to older SoCs (e.g. mt6589)?
> It might make sense to add mediatek,mtk-thermal if they are compatible 
> or nearly compatible.

I agree with you that we should add mediatek,mtk-thermal for compatible
or nearly compatible SoC.
However, there is no more compatible SoC so far. Once we have such new
nearly compatible SoC, we would update it on this binding document soon,
thank you.

BR,
Dawei

> >>
> >>>   - reg: Address range of the thermal controller
> >>>   - interrupts: IRQ for the thermal controller
> >>>   - clocks, clock-names: Clocks needed for the thermal controller. 
> >>> required
> >>>
> >
> >




Re: [PATCH 1/3] dt-bindings: thermal: Add binding document for Mediatek thermal controller

2016-08-15 Thread dawei chien
Hi Matthias,

On Thu, 2016-08-11 at 17:48 +0200, Matthias Brugger wrote:
> 
> On 11/07/16 10:52, dawei chien wrote:
> > Dear Keerthy,
> >
> > On Thu, 2016-07-07 at 16:39 +0530, Keerthy wrote:
> >>
> >> On Thursday 07 July 2016 02:36 PM, Dawei Chien wrote:
> >>> This adds the device tree binding documentation for the mediatek thermal
> >>> controller found on Mediatek MT2701.
> >>>
> >>> Signed-off-by: Dawei Chien 
> >>> ---
> >>>   .../bindings/thermal/mediatek-thermal.txt  |2 +-
> >>>   1 file changed, 1 insertion(+), 1 deletion(-)
> >>>
> >>> diff --git 
> >>> a/Documentation/devicetree/bindings/thermal/mediatek-thermal.txt 
> >>> b/Documentation/devicetree/bindings/thermal/mediatek-thermal.txt
> >>> index 81f9a51..bb55e79 100644
> >>> --- a/Documentation/devicetree/bindings/thermal/mediatek-thermal.txt
> >>> +++ b/Documentation/devicetree/bindings/thermal/mediatek-thermal.txt
> >>> @@ -8,7 +8,7 @@ apmixedsys register space via AHB bus accesses, so a 
> >>> phandle to the APMIXEDSYS
> >>>   is also needed.
> >>>
> >>>   Required properties:
> >>> -- compatible: "mediatek,mt8173-thermal"
> >>> +- compatible: "mediatek,mt8173-thermal" or "mediatek,mt2701-thermal"
> >>
> >> - compatible :
> >>   - "mediatek,mt8173-thermal" : For MT8173 family of SoCs
> >>   - "mediatek,mt2701-thermal" : For MT2701 family of SoCs
> >
> > Thank you, I will update it on next version.
> >
> 
> Do you know about the compability to older SoCs (e.g. mt6589)?
> It might make sense to add mediatek,mtk-thermal if they are compatible 
> or nearly compatible.

I agree with you that we should add mediatek,mtk-thermal for compatible
or nearly compatible SoC.
However, there is no more compatible SoC so far. Once we have such new
nearly compatible SoC, we would update it on this binding document soon,
thank you.

BR,
Dawei

> >>
> >>>   - reg: Address range of the thermal controller
> >>>   - interrupts: IRQ for the thermal controller
> >>>   - clocks, clock-names: Clocks needed for the thermal controller. 
> >>> required
> >>>
> >
> >




Re: [PATCH 2/3] thermal: Add Mediatek thermal driver for mt2701.

2016-08-08 Thread dawei chien
Dear Keerthy,

On Mon, 2016-07-11 at 16:56 +0800, dawei chien wrote:
> Dear Keerthy,
> 
> On Thu, 2016-07-07 at 17:24 +0530, Keerthy wrote:
> > Hi Dawei Chien,
> > 
> > 
> > On Thursday 07 July 2016 02:36 PM, Dawei Chien wrote:
> > > This patch adds support for mt2701 chip to mtk_thermal.c,
> > > and integrate both mt8173 and mt2701 on the same driver.
> > > MT8173 has four banks and five sensors, and MT2701 has
> > > only one bank and three sensors.
> > >
> > > Signed-off-by: Dawei Chien <dawei.ch...@mediatek.com>
> > > ---
> > >   drivers/thermal/mtk_thermal.c |  258 
> > > ++---
> > >   1 file changed, 165 insertions(+), 93 deletions(-)
> > >
> > > diff --git a/drivers/thermal/mtk_thermal.c b/drivers/thermal/mtk_thermal.c
> > > index 262ab0a..860f2e2 100644
> > > --- a/drivers/thermal/mtk_thermal.c
> > > +++ b/drivers/thermal/mtk_thermal.c
> > > @@ -2,6 +2,7 @@
> > >* Copyright (c) 2015 MediaTek Inc.
> > >* Author: Hanyi Wu <hanyi...@mediatek.com>
> > >* Sascha Hauer <s.ha...@pengutronix.de>
> > > + * Dawei Chien <dawei.ch...@mediatek.com>
> > >*
> > >* 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
> > > @@ -21,6 +22,7 @@
> > >   #include 
> > >   #include 
> > >   #include 
> > > +#include 
> > >   #include 
> > >   #include 
> > >   #include 
> > > @@ -88,6 +90,7 @@
> > >   #define TEMP_ADCVALIDMASK_VALID_HIGHBIT(5)
> > >   #define TEMP_ADCVALIDMASK_VALID_POS(bit)(bit)
> > >
> > > +/* MT8173 thermal sensors */
> > >   #define MT8173_TS1  0
> > >   #define MT8173_TS2  1
> > >   #define MT8173_TS3  2
> > > @@ -97,35 +100,62 @@
> > >   /* AUXADC channel 11 is used for the temperature sensors */
> > >   #define MT8173_TEMP_AUXADC_CHANNEL  11
> > >
> > > -/* The total number of temperature sensors in the MT8173 */
> > > -#define MT8173_NUM_SENSORS   5
> > > -
> > > -/* The number of banks in the MT8173 */
> > > -#define MT8173_NUM_ZONES 4
> > > -
> > > -/* The number of sensing points per bank */
> > > -#define MT8173_NUM_SENSORS_PER_ZONE  4
> > > -
> > >   /* Layout of the fuses providing the calibration data */
> > > -#define MT8173_CALIB_BUF0_VALID  BIT(0)
> > > -#define MT8173_CALIB_BUF1_ADC_GE(x)  (((x) >> 22) & 0x3ff)
> > > -#define MT8173_CALIB_BUF0_VTS_TS1(x) (((x) >> 17) & 0x1ff)
> > > -#define MT8173_CALIB_BUF0_VTS_TS2(x) (((x) >> 8) & 0x1ff)
> > > -#define MT8173_CALIB_BUF1_VTS_TS3(x) (((x) >> 0) & 0x1ff)
> > > -#define MT8173_CALIB_BUF2_VTS_TS4(x) (((x) >> 23) & 0x1ff)
> > > -#define MT8173_CALIB_BUF2_VTS_TSABB(x)   (((x) >> 14) & 0x1ff)
> > > -#define MT8173_CALIB_BUF0_DEGC_CALI(x)   (((x) >> 1) & 0x3f)
> > > -#define MT8173_CALIB_BUF0_O_SLOPE(x) (((x) >> 26) & 0x3f)
> > > +#define CALIB_BUF0_VALID BIT(0)
> > > +#define CALIB_BUF1_ADC_GE(x) (((x) >> 22) & 0x3ff)
> > > +#define CALIB_BUF0_VTS_TS1(x)(((x) >> 17) & 0x1ff)
> > > +#define CALIB_BUF0_VTS_TS2(x)(((x) >> 8) & 0x1ff)
> > > +#define CALIB_BUF1_VTS_TS3(x)(((x) >> 0) & 0x1ff)
> > > +#define CALIB_BUF2_VTS_TS4(x)(((x) >> 23) & 0x1ff)
> > > +#define CALIB_BUF2_VTS_TS5(x)(((x) >> 14) & 0x1ff)
> > > +#define CALIB_BUF0_DEGC_CALI(x)  (((x) >> 1) & 0x3f)
> > > +#define CALIB_BUF0_O_SLOPE(x)(((x) >> 26) & 0x3f)
> > > +
> > 
> > IMHO the above changes from defining CALIB_BUF1_ADC_GE(x) to 
> > CALIB_BUF0_O_SLOPE(x) can be avoided. We are just renaming the same 
> > defines to a generic name. Instead the macro starting with MT8173 can 
> > only be used wherever needed commonly both by 8173 instance and for
> > 2701 instance.
> > 
> 
> I would have a try to keep MT8173 original one and add some comment for
> the macro starting on next version.

Just confirm again,
we don't need change common macro name, and just need to add comment for
MT8173/MT2701, right?

> > > +#define NVMEM_TS10
> > > +#define NVMEM_TS21
> 

Re: [PATCH 2/3] thermal: Add Mediatek thermal driver for mt2701.

2016-08-08 Thread dawei chien
Dear Keerthy,

On Mon, 2016-07-11 at 16:56 +0800, dawei chien wrote:
> Dear Keerthy,
> 
> On Thu, 2016-07-07 at 17:24 +0530, Keerthy wrote:
> > Hi Dawei Chien,
> > 
> > 
> > On Thursday 07 July 2016 02:36 PM, Dawei Chien wrote:
> > > This patch adds support for mt2701 chip to mtk_thermal.c,
> > > and integrate both mt8173 and mt2701 on the same driver.
> > > MT8173 has four banks and five sensors, and MT2701 has
> > > only one bank and three sensors.
> > >
> > > Signed-off-by: Dawei Chien 
> > > ---
> > >   drivers/thermal/mtk_thermal.c |  258 
> > > ++---
> > >   1 file changed, 165 insertions(+), 93 deletions(-)
> > >
> > > diff --git a/drivers/thermal/mtk_thermal.c b/drivers/thermal/mtk_thermal.c
> > > index 262ab0a..860f2e2 100644
> > > --- a/drivers/thermal/mtk_thermal.c
> > > +++ b/drivers/thermal/mtk_thermal.c
> > > @@ -2,6 +2,7 @@
> > >* Copyright (c) 2015 MediaTek Inc.
> > >* Author: Hanyi Wu 
> > >* Sascha Hauer 
> > > + * Dawei Chien 
> > >*
> > >* 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
> > > @@ -21,6 +22,7 @@
> > >   #include 
> > >   #include 
> > >   #include 
> > > +#include 
> > >   #include 
> > >   #include 
> > >   #include 
> > > @@ -88,6 +90,7 @@
> > >   #define TEMP_ADCVALIDMASK_VALID_HIGHBIT(5)
> > >   #define TEMP_ADCVALIDMASK_VALID_POS(bit)(bit)
> > >
> > > +/* MT8173 thermal sensors */
> > >   #define MT8173_TS1  0
> > >   #define MT8173_TS2  1
> > >   #define MT8173_TS3  2
> > > @@ -97,35 +100,62 @@
> > >   /* AUXADC channel 11 is used for the temperature sensors */
> > >   #define MT8173_TEMP_AUXADC_CHANNEL  11
> > >
> > > -/* The total number of temperature sensors in the MT8173 */
> > > -#define MT8173_NUM_SENSORS   5
> > > -
> > > -/* The number of banks in the MT8173 */
> > > -#define MT8173_NUM_ZONES 4
> > > -
> > > -/* The number of sensing points per bank */
> > > -#define MT8173_NUM_SENSORS_PER_ZONE  4
> > > -
> > >   /* Layout of the fuses providing the calibration data */
> > > -#define MT8173_CALIB_BUF0_VALID  BIT(0)
> > > -#define MT8173_CALIB_BUF1_ADC_GE(x)  (((x) >> 22) & 0x3ff)
> > > -#define MT8173_CALIB_BUF0_VTS_TS1(x) (((x) >> 17) & 0x1ff)
> > > -#define MT8173_CALIB_BUF0_VTS_TS2(x) (((x) >> 8) & 0x1ff)
> > > -#define MT8173_CALIB_BUF1_VTS_TS3(x) (((x) >> 0) & 0x1ff)
> > > -#define MT8173_CALIB_BUF2_VTS_TS4(x) (((x) >> 23) & 0x1ff)
> > > -#define MT8173_CALIB_BUF2_VTS_TSABB(x)   (((x) >> 14) & 0x1ff)
> > > -#define MT8173_CALIB_BUF0_DEGC_CALI(x)   (((x) >> 1) & 0x3f)
> > > -#define MT8173_CALIB_BUF0_O_SLOPE(x) (((x) >> 26) & 0x3f)
> > > +#define CALIB_BUF0_VALID BIT(0)
> > > +#define CALIB_BUF1_ADC_GE(x) (((x) >> 22) & 0x3ff)
> > > +#define CALIB_BUF0_VTS_TS1(x)(((x) >> 17) & 0x1ff)
> > > +#define CALIB_BUF0_VTS_TS2(x)(((x) >> 8) & 0x1ff)
> > > +#define CALIB_BUF1_VTS_TS3(x)(((x) >> 0) & 0x1ff)
> > > +#define CALIB_BUF2_VTS_TS4(x)(((x) >> 23) & 0x1ff)
> > > +#define CALIB_BUF2_VTS_TS5(x)(((x) >> 14) & 0x1ff)
> > > +#define CALIB_BUF0_DEGC_CALI(x)  (((x) >> 1) & 0x3f)
> > > +#define CALIB_BUF0_O_SLOPE(x)(((x) >> 26) & 0x3f)
> > > +
> > 
> > IMHO the above changes from defining CALIB_BUF1_ADC_GE(x) to 
> > CALIB_BUF0_O_SLOPE(x) can be avoided. We are just renaming the same 
> > defines to a generic name. Instead the macro starting with MT8173 can 
> > only be used wherever needed commonly both by 8173 instance and for
> > 2701 instance.
> > 
> 
> I would have a try to keep MT8173 original one and add some comment for
> the macro starting on next version.

Just confirm again,
we don't need change common macro name, and just need to add comment for
MT8173/MT2701, right?

> > > +#define NVMEM_TS10
> > > +#define NVMEM_TS21
> > > +#define NVMEM_TS32
> > > +#define NVMEM_TS43
> > > +#define NVMEM_TS54
>

Re: [PATCH 3/3] arm: dts: thermal: add thermal/auxadc node.

2016-07-11 Thread dawei chien
Dear Keerthy,

On Thu, 2016-07-07 at 17:39 +0530, Keerthy wrote:
> 
> On Thursday 07 July 2016 02:36 PM, Dawei Chien wrote:
> > This adds the thermal controller and auxadc nodes
> > to the Mediatek MT2701 dtsi file.
> >
> > Signed-off-by: Dawei Chien <dawei.ch...@mediatek.com>
> > ---
> > This patch depned on:
> > https://patchwork.kernel.org/patch/9213545/
> > ---
> >   arch/arm/boot/dts/mt2701.dtsi |   43 
> > +
> >   1 file changed, 43 insertions(+)
> >
> > diff --git a/arch/arm/boot/dts/mt2701.dtsi b/arch/arm/boot/dts/mt2701.dtsi
> > index 2ac8b50..0834a23 100644
> > --- a/arch/arm/boot/dts/mt2701.dtsi
> > +++ b/arch/arm/boot/dts/mt2701.dtsi
> > @@ -77,6 +77,36 @@
> > #clock-cells = <0>;
> > };
> >
> > +   thermal-zones {
> > +   cpu_thermal: cpu_thermal {
> > +   polling-delay-passive = <1000>; /* milliseconds */
> > +   polling-delay = <1000>; /* milliseconds */
> > +
> > +   thermal-sensors = < 0>;
> > +   sustainable-power = <1000>;
> > +
> > +   trips {
> > +   threshold: trip-point@0 {
> > +   temperature = <68000>;
> > +   hysteresis = <2000>;
> > +   type = "passive";
> > +   };
> > +
> > +   target: trip-point@1 {
> > +   temperature = <85000>;
> > +   hysteresis = <2000>;
> > +   type = "passive";
> > +   };
> > +
> > +   cpu_crit: cpu_crit@0 {
> > +   temperature = <115000>;
> > +   hysteresis = <2000>;
> > +   type = "critical";
> > +   };
> > +   };
> > +   };
> > +   };
> > +
> 
> are there any corresponding cooling-maps?

Since MT2701 does not register CPUFREQ cooling device and its' own
device node, I could not add cooling-maps so far.
Could we add cooling map after CPUFREQ ready, thank you.

> 
> > timer {
> > compatible = "arm,armv7-timer";
> > interrupt-parent = <>;
> > @@ -183,4 +213,17 @@
> > clocks = <_clk>;
> > status = "disabled";
> > };
> > +
> > +   thermal: thermal@1100b000 {
> > +   #thermal-sensor-cells = <0>;
> > +   compatible = "mediatek,mt2701-thermal";
> > +   reg = <0 0x1100b000 0 0x1000>;
> > +   interrupts = ;
> > +   clocks = < CLK_PERI_THERM>, < CLK_PERI_AUXADC>;
> > +   clock-names = "therm", "auxadc";
> > +   resets = < 0x10>;
> > +   reset-names = "therm";
> > +   mediatek,auxadc = <>;
> > +   mediatek,apmixedsys = <>;
> > +   };
> >   };
> >




Re: [PATCH 3/3] arm: dts: thermal: add thermal/auxadc node.

2016-07-11 Thread dawei chien
Dear Keerthy,

On Thu, 2016-07-07 at 17:39 +0530, Keerthy wrote:
> 
> On Thursday 07 July 2016 02:36 PM, Dawei Chien wrote:
> > This adds the thermal controller and auxadc nodes
> > to the Mediatek MT2701 dtsi file.
> >
> > Signed-off-by: Dawei Chien 
> > ---
> > This patch depned on:
> > https://patchwork.kernel.org/patch/9213545/
> > ---
> >   arch/arm/boot/dts/mt2701.dtsi |   43 
> > +
> >   1 file changed, 43 insertions(+)
> >
> > diff --git a/arch/arm/boot/dts/mt2701.dtsi b/arch/arm/boot/dts/mt2701.dtsi
> > index 2ac8b50..0834a23 100644
> > --- a/arch/arm/boot/dts/mt2701.dtsi
> > +++ b/arch/arm/boot/dts/mt2701.dtsi
> > @@ -77,6 +77,36 @@
> > #clock-cells = <0>;
> > };
> >
> > +   thermal-zones {
> > +   cpu_thermal: cpu_thermal {
> > +   polling-delay-passive = <1000>; /* milliseconds */
> > +   polling-delay = <1000>; /* milliseconds */
> > +
> > +   thermal-sensors = < 0>;
> > +   sustainable-power = <1000>;
> > +
> > +   trips {
> > +   threshold: trip-point@0 {
> > +   temperature = <68000>;
> > +   hysteresis = <2000>;
> > +   type = "passive";
> > +   };
> > +
> > +   target: trip-point@1 {
> > +   temperature = <85000>;
> > +   hysteresis = <2000>;
> > +   type = "passive";
> > +   };
> > +
> > +   cpu_crit: cpu_crit@0 {
> > +   temperature = <115000>;
> > +   hysteresis = <2000>;
> > +   type = "critical";
> > +   };
> > +   };
> > +   };
> > +   };
> > +
> 
> are there any corresponding cooling-maps?

Since MT2701 does not register CPUFREQ cooling device and its' own
device node, I could not add cooling-maps so far.
Could we add cooling map after CPUFREQ ready, thank you.

> 
> > timer {
> > compatible = "arm,armv7-timer";
> > interrupt-parent = <>;
> > @@ -183,4 +213,17 @@
> > clocks = <_clk>;
> > status = "disabled";
> > };
> > +
> > +   thermal: thermal@1100b000 {
> > +   #thermal-sensor-cells = <0>;
> > +   compatible = "mediatek,mt2701-thermal";
> > +   reg = <0 0x1100b000 0 0x1000>;
> > +   interrupts = ;
> > +   clocks = < CLK_PERI_THERM>, < CLK_PERI_AUXADC>;
> > +   clock-names = "therm", "auxadc";
> > +   resets = < 0x10>;
> > +   reset-names = "therm";
> > +   mediatek,auxadc = <>;
> > +   mediatek,apmixedsys = <>;
> > +   };
> >   };
> >




Re: [PATCH 2/3] thermal: Add Mediatek thermal driver for mt2701.

2016-07-11 Thread dawei chien
Dear Keerthy,

On Thu, 2016-07-07 at 17:24 +0530, Keerthy wrote:
> Hi Dawei Chien,
> 
> 
> On Thursday 07 July 2016 02:36 PM, Dawei Chien wrote:
> > This patch adds support for mt2701 chip to mtk_thermal.c,
> > and integrate both mt8173 and mt2701 on the same driver.
> > MT8173 has four banks and five sensors, and MT2701 has
> > only one bank and three sensors.
> >
> > Signed-off-by: Dawei Chien <dawei.ch...@mediatek.com>
> > ---
> >   drivers/thermal/mtk_thermal.c |  258 
> > ++---
> >   1 file changed, 165 insertions(+), 93 deletions(-)
> >
> > diff --git a/drivers/thermal/mtk_thermal.c b/drivers/thermal/mtk_thermal.c
> > index 262ab0a..860f2e2 100644
> > --- a/drivers/thermal/mtk_thermal.c
> > +++ b/drivers/thermal/mtk_thermal.c
> > @@ -2,6 +2,7 @@
> >* Copyright (c) 2015 MediaTek Inc.
> >    * Author: Hanyi Wu <hanyi...@mediatek.com>
> >* Sascha Hauer <s.ha...@pengutronix.de>
> > + * Dawei Chien <dawei.ch...@mediatek.com>
> >*
> >* 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
> > @@ -21,6 +22,7 @@
> >   #include 
> >   #include 
> >   #include 
> > +#include 
> >   #include 
> >   #include 
> >   #include 
> > @@ -88,6 +90,7 @@
> >   #define TEMP_ADCVALIDMASK_VALID_HIGH  BIT(5)
> >   #define TEMP_ADCVALIDMASK_VALID_POS(bit)  (bit)
> >
> > +/* MT8173 thermal sensors */
> >   #define MT8173_TS10
> >   #define MT8173_TS21
> >   #define MT8173_TS32
> > @@ -97,35 +100,62 @@
> >   /* AUXADC channel 11 is used for the temperature sensors */
> >   #define MT8173_TEMP_AUXADC_CHANNEL11
> >
> > -/* The total number of temperature sensors in the MT8173 */
> > -#define MT8173_NUM_SENSORS 5
> > -
> > -/* The number of banks in the MT8173 */
> > -#define MT8173_NUM_ZONES   4
> > -
> > -/* The number of sensing points per bank */
> > -#define MT8173_NUM_SENSORS_PER_ZONE4
> > -
> >   /* Layout of the fuses providing the calibration data */
> > -#define MT8173_CALIB_BUF0_VALIDBIT(0)
> > -#define MT8173_CALIB_BUF1_ADC_GE(x)(((x) >> 22) & 0x3ff)
> > -#define MT8173_CALIB_BUF0_VTS_TS1(x)   (((x) >> 17) & 0x1ff)
> > -#define MT8173_CALIB_BUF0_VTS_TS2(x)   (((x) >> 8) & 0x1ff)
> > -#define MT8173_CALIB_BUF1_VTS_TS3(x)   (((x) >> 0) & 0x1ff)
> > -#define MT8173_CALIB_BUF2_VTS_TS4(x)   (((x) >> 23) & 0x1ff)
> > -#define MT8173_CALIB_BUF2_VTS_TSABB(x) (((x) >> 14) & 0x1ff)
> > -#define MT8173_CALIB_BUF0_DEGC_CALI(x) (((x) >> 1) & 0x3f)
> > -#define MT8173_CALIB_BUF0_O_SLOPE(x)   (((x) >> 26) & 0x3f)
> > +#define CALIB_BUF0_VALID   BIT(0)
> > +#define CALIB_BUF1_ADC_GE(x)   (((x) >> 22) & 0x3ff)
> > +#define CALIB_BUF0_VTS_TS1(x)  (((x) >> 17) & 0x1ff)
> > +#define CALIB_BUF0_VTS_TS2(x)  (((x) >> 8) & 0x1ff)
> > +#define CALIB_BUF1_VTS_TS3(x)  (((x) >> 0) & 0x1ff)
> > +#define CALIB_BUF2_VTS_TS4(x)  (((x) >> 23) & 0x1ff)
> > +#define CALIB_BUF2_VTS_TS5(x)  (((x) >> 14) & 0x1ff)
> > +#define CALIB_BUF0_DEGC_CALI(x)(((x) >> 1) & 0x3f)
> > +#define CALIB_BUF0_O_SLOPE(x)  (((x) >> 26) & 0x3f)
> > +
> 
> IMHO the above changes from defining CALIB_BUF1_ADC_GE(x) to 
> CALIB_BUF0_O_SLOPE(x) can be avoided. We are just renaming the same 
> defines to a generic name. Instead the macro starting with MT8173 can 
> only be used wherever needed commonly both by 8173 instance and for
> 2701 instance.
> 

I would have a try to keep MT8173 original one and add some comment for
the macro starting on next version.

> > +#define NVMEM_TS1  0
> > +#define NVMEM_TS2  1
> > +#define NVMEM_TS3  2
> > +#define NVMEM_TS4  3
> > +#define NVMEM_TS5  4
> > +

Does these need to keep the old one
MT8173_TS1/MT8173_TS2/MT8173_TS3/MT8173_TS4/MT8173_TSABB


> > +/* MT2701 thermal sensors */
> > +#define MT2701_TS1 0
> > +#define MT2701_TS2 1
> > +#define MT2701_TSABB   2
> > +
> > +/* AUXADC channel 11 is used for the temperature sensors */
> > +#define MT2701_TEMP_AUXADC_CHANNEL 11
> >
> >   #define THERMAL_NAME"mtk-thermal"
> >
> > +/* Maximum support banks */
> > +#define MAX_NUM

Re: [PATCH 2/3] thermal: Add Mediatek thermal driver for mt2701.

2016-07-11 Thread dawei chien
Dear Keerthy,

On Thu, 2016-07-07 at 17:24 +0530, Keerthy wrote:
> Hi Dawei Chien,
> 
> 
> On Thursday 07 July 2016 02:36 PM, Dawei Chien wrote:
> > This patch adds support for mt2701 chip to mtk_thermal.c,
> > and integrate both mt8173 and mt2701 on the same driver.
> > MT8173 has four banks and five sensors, and MT2701 has
> > only one bank and three sensors.
> >
> > Signed-off-by: Dawei Chien 
> > ---
> >   drivers/thermal/mtk_thermal.c |  258 
> > ++---
> >   1 file changed, 165 insertions(+), 93 deletions(-)
> >
> > diff --git a/drivers/thermal/mtk_thermal.c b/drivers/thermal/mtk_thermal.c
> > index 262ab0a..860f2e2 100644
> > --- a/drivers/thermal/mtk_thermal.c
> > +++ b/drivers/thermal/mtk_thermal.c
> > @@ -2,6 +2,7 @@
> >* Copyright (c) 2015 MediaTek Inc.
> >* Author: Hanyi Wu 
> >* Sascha Hauer 
> > + * Dawei Chien 
> >*
> >* 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
> > @@ -21,6 +22,7 @@
> >   #include 
> >   #include 
> >   #include 
> > +#include 
> >   #include 
> >   #include 
> >   #include 
> > @@ -88,6 +90,7 @@
> >   #define TEMP_ADCVALIDMASK_VALID_HIGH  BIT(5)
> >   #define TEMP_ADCVALIDMASK_VALID_POS(bit)  (bit)
> >
> > +/* MT8173 thermal sensors */
> >   #define MT8173_TS10
> >   #define MT8173_TS21
> >   #define MT8173_TS32
> > @@ -97,35 +100,62 @@
> >   /* AUXADC channel 11 is used for the temperature sensors */
> >   #define MT8173_TEMP_AUXADC_CHANNEL11
> >
> > -/* The total number of temperature sensors in the MT8173 */
> > -#define MT8173_NUM_SENSORS 5
> > -
> > -/* The number of banks in the MT8173 */
> > -#define MT8173_NUM_ZONES   4
> > -
> > -/* The number of sensing points per bank */
> > -#define MT8173_NUM_SENSORS_PER_ZONE4
> > -
> >   /* Layout of the fuses providing the calibration data */
> > -#define MT8173_CALIB_BUF0_VALIDBIT(0)
> > -#define MT8173_CALIB_BUF1_ADC_GE(x)(((x) >> 22) & 0x3ff)
> > -#define MT8173_CALIB_BUF0_VTS_TS1(x)   (((x) >> 17) & 0x1ff)
> > -#define MT8173_CALIB_BUF0_VTS_TS2(x)   (((x) >> 8) & 0x1ff)
> > -#define MT8173_CALIB_BUF1_VTS_TS3(x)   (((x) >> 0) & 0x1ff)
> > -#define MT8173_CALIB_BUF2_VTS_TS4(x)   (((x) >> 23) & 0x1ff)
> > -#define MT8173_CALIB_BUF2_VTS_TSABB(x) (((x) >> 14) & 0x1ff)
> > -#define MT8173_CALIB_BUF0_DEGC_CALI(x) (((x) >> 1) & 0x3f)
> > -#define MT8173_CALIB_BUF0_O_SLOPE(x)   (((x) >> 26) & 0x3f)
> > +#define CALIB_BUF0_VALID   BIT(0)
> > +#define CALIB_BUF1_ADC_GE(x)   (((x) >> 22) & 0x3ff)
> > +#define CALIB_BUF0_VTS_TS1(x)  (((x) >> 17) & 0x1ff)
> > +#define CALIB_BUF0_VTS_TS2(x)  (((x) >> 8) & 0x1ff)
> > +#define CALIB_BUF1_VTS_TS3(x)  (((x) >> 0) & 0x1ff)
> > +#define CALIB_BUF2_VTS_TS4(x)  (((x) >> 23) & 0x1ff)
> > +#define CALIB_BUF2_VTS_TS5(x)  (((x) >> 14) & 0x1ff)
> > +#define CALIB_BUF0_DEGC_CALI(x)(((x) >> 1) & 0x3f)
> > +#define CALIB_BUF0_O_SLOPE(x)  (((x) >> 26) & 0x3f)
> > +
> 
> IMHO the above changes from defining CALIB_BUF1_ADC_GE(x) to 
> CALIB_BUF0_O_SLOPE(x) can be avoided. We are just renaming the same 
> defines to a generic name. Instead the macro starting with MT8173 can 
> only be used wherever needed commonly both by 8173 instance and for
> 2701 instance.
> 

I would have a try to keep MT8173 original one and add some comment for
the macro starting on next version.

> > +#define NVMEM_TS1  0
> > +#define NVMEM_TS2  1
> > +#define NVMEM_TS3  2
> > +#define NVMEM_TS4  3
> > +#define NVMEM_TS5  4
> > +

Does these need to keep the old one
MT8173_TS1/MT8173_TS2/MT8173_TS3/MT8173_TS4/MT8173_TSABB


> > +/* MT2701 thermal sensors */
> > +#define MT2701_TS1 0
> > +#define MT2701_TS2 1
> > +#define MT2701_TSABB   2
> > +
> > +/* AUXADC channel 11 is used for the temperature sensors */
> > +#define MT2701_TEMP_AUXADC_CHANNEL 11
> >
> >   #define THERMAL_NAME"mtk-thermal"
> >
> > +/* Maximum support banks */
> > +#define MAX_NUM_BANK   5
> 
> Why is this 5?
> Commit message states: MT8173 has four banks and five sensors, and 
&

Re: [PATCH 1/3] dt-bindings: thermal: Add binding document for Mediatek thermal controller

2016-07-11 Thread dawei chien
Dear Keerthy,

On Thu, 2016-07-07 at 16:39 +0530, Keerthy wrote:
> 
> On Thursday 07 July 2016 02:36 PM, Dawei Chien wrote:
> > This adds the device tree binding documentation for the mediatek thermal
> > controller found on Mediatek MT2701.
> >
> > Signed-off-by: Dawei Chien <dawei.ch...@mediatek.com>
> > ---
> >   .../bindings/thermal/mediatek-thermal.txt  |2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/Documentation/devicetree/bindings/thermal/mediatek-thermal.txt 
> > b/Documentation/devicetree/bindings/thermal/mediatek-thermal.txt
> > index 81f9a51..bb55e79 100644
> > --- a/Documentation/devicetree/bindings/thermal/mediatek-thermal.txt
> > +++ b/Documentation/devicetree/bindings/thermal/mediatek-thermal.txt
> > @@ -8,7 +8,7 @@ apmixedsys register space via AHB bus accesses, so a 
> > phandle to the APMIXEDSYS
> >   is also needed.
> >
> >   Required properties:
> > -- compatible: "mediatek,mt8173-thermal"
> > +- compatible: "mediatek,mt8173-thermal" or "mediatek,mt2701-thermal"
> 
> - compatible :
>   - "mediatek,mt8173-thermal" : For MT8173 family of SoCs
>   - "mediatek,mt2701-thermal" : For MT2701 family of SoCs

Thank you, I will update it on next version.

> 
> >   - reg: Address range of the thermal controller
> >   - interrupts: IRQ for the thermal controller
> >   - clocks, clock-names: Clocks needed for the thermal controller. required
> >




Re: [PATCH 1/3] dt-bindings: thermal: Add binding document for Mediatek thermal controller

2016-07-11 Thread dawei chien
Dear Keerthy,

On Thu, 2016-07-07 at 16:39 +0530, Keerthy wrote:
> 
> On Thursday 07 July 2016 02:36 PM, Dawei Chien wrote:
> > This adds the device tree binding documentation for the mediatek thermal
> > controller found on Mediatek MT2701.
> >
> > Signed-off-by: Dawei Chien 
> > ---
> >   .../bindings/thermal/mediatek-thermal.txt  |2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/Documentation/devicetree/bindings/thermal/mediatek-thermal.txt 
> > b/Documentation/devicetree/bindings/thermal/mediatek-thermal.txt
> > index 81f9a51..bb55e79 100644
> > --- a/Documentation/devicetree/bindings/thermal/mediatek-thermal.txt
> > +++ b/Documentation/devicetree/bindings/thermal/mediatek-thermal.txt
> > @@ -8,7 +8,7 @@ apmixedsys register space via AHB bus accesses, so a 
> > phandle to the APMIXEDSYS
> >   is also needed.
> >
> >   Required properties:
> > -- compatible: "mediatek,mt8173-thermal"
> > +- compatible: "mediatek,mt8173-thermal" or "mediatek,mt2701-thermal"
> 
> - compatible :
>   - "mediatek,mt8173-thermal" : For MT8173 family of SoCs
>   - "mediatek,mt2701-thermal" : For MT2701 family of SoCs

Thank you, I will update it on next version.

> 
> >   - reg: Address range of the thermal controller
> >   - interrupts: IRQ for the thermal controller
> >   - clocks, clock-names: Clocks needed for the thermal controller. required
> >




[PATCH 2/3] thermal: Add Mediatek thermal driver for mt2701.

2016-07-07 Thread Dawei Chien
This patch adds support for mt2701 chip to mtk_thermal.c,
and integrate both mt8173 and mt2701 on the same driver.
MT8173 has four banks and five sensors, and MT2701 has
only one bank and three sensors.

Signed-off-by: Dawei Chien <dawei.ch...@mediatek.com>
---
 drivers/thermal/mtk_thermal.c |  258 ++---
 1 file changed, 165 insertions(+), 93 deletions(-)

diff --git a/drivers/thermal/mtk_thermal.c b/drivers/thermal/mtk_thermal.c
index 262ab0a..860f2e2 100644
--- a/drivers/thermal/mtk_thermal.c
+++ b/drivers/thermal/mtk_thermal.c
@@ -2,6 +2,7 @@
  * Copyright (c) 2015 MediaTek Inc.
  * Author: Hanyi Wu <hanyi...@mediatek.com>
  * Sascha Hauer <s.ha...@pengutronix.de>
+ *     Dawei Chien <dawei.ch...@mediatek.com>
  *
  * 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
@@ -21,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -88,6 +90,7 @@
 #define TEMP_ADCVALIDMASK_VALID_HIGH   BIT(5)
 #define TEMP_ADCVALIDMASK_VALID_POS(bit)   (bit)
 
+/* MT8173 thermal sensors */
 #define MT8173_TS1 0
 #define MT8173_TS2 1
 #define MT8173_TS3 2
@@ -97,35 +100,62 @@
 /* AUXADC channel 11 is used for the temperature sensors */
 #define MT8173_TEMP_AUXADC_CHANNEL 11
 
-/* The total number of temperature sensors in the MT8173 */
-#define MT8173_NUM_SENSORS 5
-
-/* The number of banks in the MT8173 */
-#define MT8173_NUM_ZONES   4
-
-/* The number of sensing points per bank */
-#define MT8173_NUM_SENSORS_PER_ZONE4
-
 /* Layout of the fuses providing the calibration data */
-#define MT8173_CALIB_BUF0_VALIDBIT(0)
-#define MT8173_CALIB_BUF1_ADC_GE(x)(((x) >> 22) & 0x3ff)
-#define MT8173_CALIB_BUF0_VTS_TS1(x)   (((x) >> 17) & 0x1ff)
-#define MT8173_CALIB_BUF0_VTS_TS2(x)   (((x) >> 8) & 0x1ff)
-#define MT8173_CALIB_BUF1_VTS_TS3(x)   (((x) >> 0) & 0x1ff)
-#define MT8173_CALIB_BUF2_VTS_TS4(x)   (((x) >> 23) & 0x1ff)
-#define MT8173_CALIB_BUF2_VTS_TSABB(x) (((x) >> 14) & 0x1ff)
-#define MT8173_CALIB_BUF0_DEGC_CALI(x) (((x) >> 1) & 0x3f)
-#define MT8173_CALIB_BUF0_O_SLOPE(x)   (((x) >> 26) & 0x3f)
+#define CALIB_BUF0_VALID   BIT(0)
+#define CALIB_BUF1_ADC_GE(x)   (((x) >> 22) & 0x3ff)
+#define CALIB_BUF0_VTS_TS1(x)  (((x) >> 17) & 0x1ff)
+#define CALIB_BUF0_VTS_TS2(x)  (((x) >> 8) & 0x1ff)
+#define CALIB_BUF1_VTS_TS3(x)  (((x) >> 0) & 0x1ff)
+#define CALIB_BUF2_VTS_TS4(x)  (((x) >> 23) & 0x1ff)
+#define CALIB_BUF2_VTS_TS5(x)  (((x) >> 14) & 0x1ff)
+#define CALIB_BUF0_DEGC_CALI(x)(((x) >> 1) & 0x3f)
+#define CALIB_BUF0_O_SLOPE(x)  (((x) >> 26) & 0x3f)
+
+#define NVMEM_TS1  0
+#define NVMEM_TS2  1
+#define NVMEM_TS3  2
+#define NVMEM_TS4  3
+#define NVMEM_TS5  4
+
+/* MT2701 thermal sensors */
+#define MT2701_TS1 0
+#define MT2701_TS2 1
+#define MT2701_TSABB   2
+
+/* AUXADC channel 11 is used for the temperature sensors */
+#define MT2701_TEMP_AUXADC_CHANNEL 11
 
 #define THERMAL_NAME"mtk-thermal"
 
+/* Maximum support banks */
+#define MAX_NUM_BANK   5
+
 struct mtk_thermal;
 
+struct thermal_bank_cfg {
+   unsigned int num_sensors;
+   unsigned int sensors[MAX_NUM_BANK];
+};
+
 struct mtk_thermal_bank {
struct mtk_thermal *mt;
int id;
 };
 
+struct mtk_thermal_sense_point {
+   int msr;
+   int adcpnp;
+};
+
+struct mtk_thermal_data {
+   struct thermal_bank_cfg bank_data[MAX_NUM_BANK];
+   struct mtk_thermal_sense_point sensing_points[MAX_NUM_BANK];
+   int sensor_mux_values[MAX_NUM_BANK];
+   s32 num_banks;
+   s32 num_sensors;
+   s32 auxadc_channel;
+};
+
 struct mtk_thermal {
struct device *dev;
void __iomem *thermal_base;
@@ -133,27 +163,20 @@ struct mtk_thermal {
struct clk *clk_peri_therm;
struct clk *clk_auxadc;
 
-   struct mtk_thermal_bank banks[MT8173_NUM_ZONES];
-
+   struct mtk_thermal_bank banks[MAX_NUM_BANK];
+   const struct mtk_thermal_data *conf;
/* lock: for getting and putting banks */
struct mutex lock;
+   struct thermal_zone_device *tzd;
 
/* Calibration values */
s32 adc_ge;
s32 degc_cali;
s32 o_slope;
-   s32 vts[MT8173_NUM_SENSORS];
-
-};
-
-struct mtk_thermal_bank_cfg {
-   unsigned int num_sensors;
-   unsigned int sensors[MT8173_NUM_SENSORS_PER_ZONE];
+   s32 vts[MAX_NUM_BANK];
 };
 
-static const int sensor_mux_values[MT8173_NUM_SENSORS] = { 0, 1, 2, 3, 16 };
-
-/*
+/**
  * The MT8173 thermal controller has four banks. Each bank can read up to
  * four temperature sensors simultaneously. The MT8173 has a total of 5
  * temperat

[PATCH 1/3] dt-bindings: thermal: Add binding document for Mediatek thermal controller

2016-07-07 Thread Dawei Chien
This adds the device tree binding documentation for the mediatek thermal
controller found on Mediatek MT2701.

Signed-off-by: Dawei Chien <dawei.ch...@mediatek.com>
---
 .../bindings/thermal/mediatek-thermal.txt  |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/thermal/mediatek-thermal.txt 
b/Documentation/devicetree/bindings/thermal/mediatek-thermal.txt
index 81f9a51..bb55e79 100644
--- a/Documentation/devicetree/bindings/thermal/mediatek-thermal.txt
+++ b/Documentation/devicetree/bindings/thermal/mediatek-thermal.txt
@@ -8,7 +8,7 @@ apmixedsys register space via AHB bus accesses, so a phandle to 
the APMIXEDSYS
 is also needed.
 
 Required properties:
-- compatible: "mediatek,mt8173-thermal"
+- compatible: "mediatek,mt8173-thermal" or "mediatek,mt2701-thermal"
 - reg: Address range of the thermal controller
 - interrupts: IRQ for the thermal controller
 - clocks, clock-names: Clocks needed for the thermal controller. required
-- 
1.7.9.5



[PATCH 2/3] thermal: Add Mediatek thermal driver for mt2701.

2016-07-07 Thread Dawei Chien
This patch adds support for mt2701 chip to mtk_thermal.c,
and integrate both mt8173 and mt2701 on the same driver.
MT8173 has four banks and five sensors, and MT2701 has
only one bank and three sensors.

Signed-off-by: Dawei Chien 
---
 drivers/thermal/mtk_thermal.c |  258 ++---
 1 file changed, 165 insertions(+), 93 deletions(-)

diff --git a/drivers/thermal/mtk_thermal.c b/drivers/thermal/mtk_thermal.c
index 262ab0a..860f2e2 100644
--- a/drivers/thermal/mtk_thermal.c
+++ b/drivers/thermal/mtk_thermal.c
@@ -2,6 +2,7 @@
  * Copyright (c) 2015 MediaTek Inc.
  * Author: Hanyi Wu 
  * Sascha Hauer 
+ * Dawei Chien 
  *
  * 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
@@ -21,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -88,6 +90,7 @@
 #define TEMP_ADCVALIDMASK_VALID_HIGH   BIT(5)
 #define TEMP_ADCVALIDMASK_VALID_POS(bit)   (bit)
 
+/* MT8173 thermal sensors */
 #define MT8173_TS1 0
 #define MT8173_TS2 1
 #define MT8173_TS3 2
@@ -97,35 +100,62 @@
 /* AUXADC channel 11 is used for the temperature sensors */
 #define MT8173_TEMP_AUXADC_CHANNEL 11
 
-/* The total number of temperature sensors in the MT8173 */
-#define MT8173_NUM_SENSORS 5
-
-/* The number of banks in the MT8173 */
-#define MT8173_NUM_ZONES   4
-
-/* The number of sensing points per bank */
-#define MT8173_NUM_SENSORS_PER_ZONE4
-
 /* Layout of the fuses providing the calibration data */
-#define MT8173_CALIB_BUF0_VALIDBIT(0)
-#define MT8173_CALIB_BUF1_ADC_GE(x)(((x) >> 22) & 0x3ff)
-#define MT8173_CALIB_BUF0_VTS_TS1(x)   (((x) >> 17) & 0x1ff)
-#define MT8173_CALIB_BUF0_VTS_TS2(x)   (((x) >> 8) & 0x1ff)
-#define MT8173_CALIB_BUF1_VTS_TS3(x)   (((x) >> 0) & 0x1ff)
-#define MT8173_CALIB_BUF2_VTS_TS4(x)   (((x) >> 23) & 0x1ff)
-#define MT8173_CALIB_BUF2_VTS_TSABB(x) (((x) >> 14) & 0x1ff)
-#define MT8173_CALIB_BUF0_DEGC_CALI(x) (((x) >> 1) & 0x3f)
-#define MT8173_CALIB_BUF0_O_SLOPE(x)   (((x) >> 26) & 0x3f)
+#define CALIB_BUF0_VALID   BIT(0)
+#define CALIB_BUF1_ADC_GE(x)   (((x) >> 22) & 0x3ff)
+#define CALIB_BUF0_VTS_TS1(x)  (((x) >> 17) & 0x1ff)
+#define CALIB_BUF0_VTS_TS2(x)  (((x) >> 8) & 0x1ff)
+#define CALIB_BUF1_VTS_TS3(x)  (((x) >> 0) & 0x1ff)
+#define CALIB_BUF2_VTS_TS4(x)  (((x) >> 23) & 0x1ff)
+#define CALIB_BUF2_VTS_TS5(x)  (((x) >> 14) & 0x1ff)
+#define CALIB_BUF0_DEGC_CALI(x)(((x) >> 1) & 0x3f)
+#define CALIB_BUF0_O_SLOPE(x)  (((x) >> 26) & 0x3f)
+
+#define NVMEM_TS1  0
+#define NVMEM_TS2  1
+#define NVMEM_TS3  2
+#define NVMEM_TS4  3
+#define NVMEM_TS5  4
+
+/* MT2701 thermal sensors */
+#define MT2701_TS1 0
+#define MT2701_TS2 1
+#define MT2701_TSABB   2
+
+/* AUXADC channel 11 is used for the temperature sensors */
+#define MT2701_TEMP_AUXADC_CHANNEL 11
 
 #define THERMAL_NAME"mtk-thermal"
 
+/* Maximum support banks */
+#define MAX_NUM_BANK   5
+
 struct mtk_thermal;
 
+struct thermal_bank_cfg {
+   unsigned int num_sensors;
+   unsigned int sensors[MAX_NUM_BANK];
+};
+
 struct mtk_thermal_bank {
struct mtk_thermal *mt;
int id;
 };
 
+struct mtk_thermal_sense_point {
+   int msr;
+   int adcpnp;
+};
+
+struct mtk_thermal_data {
+   struct thermal_bank_cfg bank_data[MAX_NUM_BANK];
+   struct mtk_thermal_sense_point sensing_points[MAX_NUM_BANK];
+   int sensor_mux_values[MAX_NUM_BANK];
+   s32 num_banks;
+   s32 num_sensors;
+   s32 auxadc_channel;
+};
+
 struct mtk_thermal {
struct device *dev;
void __iomem *thermal_base;
@@ -133,27 +163,20 @@ struct mtk_thermal {
struct clk *clk_peri_therm;
struct clk *clk_auxadc;
 
-   struct mtk_thermal_bank banks[MT8173_NUM_ZONES];
-
+   struct mtk_thermal_bank banks[MAX_NUM_BANK];
+   const struct mtk_thermal_data *conf;
/* lock: for getting and putting banks */
struct mutex lock;
+   struct thermal_zone_device *tzd;
 
/* Calibration values */
s32 adc_ge;
s32 degc_cali;
s32 o_slope;
-   s32 vts[MT8173_NUM_SENSORS];
-
-};
-
-struct mtk_thermal_bank_cfg {
-   unsigned int num_sensors;
-   unsigned int sensors[MT8173_NUM_SENSORS_PER_ZONE];
+   s32 vts[MAX_NUM_BANK];
 };
 
-static const int sensor_mux_values[MT8173_NUM_SENSORS] = { 0, 1, 2, 3, 16 };
-
-/*
+/**
  * The MT8173 thermal controller has four banks. Each bank can read up to
  * four temperature sensors simultaneously. The MT8173 has a total of 5
  * temperature sensors. We use each bank to measure a certain area of the
@@ -166,42 +189,76 @@ static const int sensor_mux_values[MT81

[PATCH 1/3] dt-bindings: thermal: Add binding document for Mediatek thermal controller

2016-07-07 Thread Dawei Chien
This adds the device tree binding documentation for the mediatek thermal
controller found on Mediatek MT2701.

Signed-off-by: Dawei Chien 
---
 .../bindings/thermal/mediatek-thermal.txt  |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/thermal/mediatek-thermal.txt 
b/Documentation/devicetree/bindings/thermal/mediatek-thermal.txt
index 81f9a51..bb55e79 100644
--- a/Documentation/devicetree/bindings/thermal/mediatek-thermal.txt
+++ b/Documentation/devicetree/bindings/thermal/mediatek-thermal.txt
@@ -8,7 +8,7 @@ apmixedsys register space via AHB bus accesses, so a phandle to 
the APMIXEDSYS
 is also needed.
 
 Required properties:
-- compatible: "mediatek,mt8173-thermal"
+- compatible: "mediatek,mt8173-thermal" or "mediatek,mt2701-thermal"
 - reg: Address range of the thermal controller
 - interrupts: IRQ for the thermal controller
 - clocks, clock-names: Clocks needed for the thermal controller. required
-- 
1.7.9.5



[PATCH 0/3] thermal: Add Mediatek thermal driver for mt2701

2016-07-07 Thread Dawei Chien
This series support for mt2701 chip to mtk_thermal.c,
and integrate both mt8173 and mt2701 on the same driver.
MT8173 has four banks and five sensors, and MT2701 has
only one bank and three sensors.



[PATCH 0/3] thermal: Add Mediatek thermal driver for mt2701

2016-07-07 Thread Dawei Chien
This series support for mt2701 chip to mtk_thermal.c,
and integrate both mt8173 and mt2701 on the same driver.
MT8173 has four banks and five sensors, and MT2701 has
only one bank and three sensors.



[PATCH 3/3] arm: dts: thermal: add thermal/auxadc node.

2016-07-07 Thread Dawei Chien
This adds the thermal controller and auxadc nodes
to the Mediatek MT2701 dtsi file.

Signed-off-by: Dawei Chien <dawei.ch...@mediatek.com>
---
This patch depned on:
https://patchwork.kernel.org/patch/9213545/
---
 arch/arm/boot/dts/mt2701.dtsi |   43 +
 1 file changed, 43 insertions(+)

diff --git a/arch/arm/boot/dts/mt2701.dtsi b/arch/arm/boot/dts/mt2701.dtsi
index 2ac8b50..0834a23 100644
--- a/arch/arm/boot/dts/mt2701.dtsi
+++ b/arch/arm/boot/dts/mt2701.dtsi
@@ -77,6 +77,36 @@
#clock-cells = <0>;
};
 
+   thermal-zones {
+   cpu_thermal: cpu_thermal {
+   polling-delay-passive = <1000>; /* milliseconds */
+   polling-delay = <1000>; /* milliseconds */
+
+   thermal-sensors = < 0>;
+   sustainable-power = <1000>;
+
+   trips {
+   threshold: trip-point@0 {
+   temperature = <68000>;
+   hysteresis = <2000>;
+   type = "passive";
+   };
+
+   target: trip-point@1 {
+   temperature = <85000>;
+   hysteresis = <2000>;
+   type = "passive";
+   };
+
+   cpu_crit: cpu_crit@0 {
+   temperature = <115000>;
+   hysteresis = <2000>;
+   type = "critical";
+   };
+   };
+   };
+   };
+
timer {
compatible = "arm,armv7-timer";
interrupt-parent = <>;
@@ -183,4 +213,17 @@
clocks = <_clk>;
status = "disabled";
};
+
+   thermal: thermal@1100b000 {
+   #thermal-sensor-cells = <0>;
+   compatible = "mediatek,mt2701-thermal";
+   reg = <0 0x1100b000 0 0x1000>;
+   interrupts = ;
+   clocks = < CLK_PERI_THERM>, < CLK_PERI_AUXADC>;
+   clock-names = "therm", "auxadc";
+   resets = < 0x10>;
+   reset-names = "therm";
+   mediatek,auxadc = <>;
+   mediatek,apmixedsys = <>;
+   };
 };
-- 
1.7.9.5



[PATCH 3/3] arm: dts: thermal: add thermal/auxadc node.

2016-07-07 Thread Dawei Chien
This adds the thermal controller and auxadc nodes
to the Mediatek MT2701 dtsi file.

Signed-off-by: Dawei Chien 
---
This patch depned on:
https://patchwork.kernel.org/patch/9213545/
---
 arch/arm/boot/dts/mt2701.dtsi |   43 +
 1 file changed, 43 insertions(+)

diff --git a/arch/arm/boot/dts/mt2701.dtsi b/arch/arm/boot/dts/mt2701.dtsi
index 2ac8b50..0834a23 100644
--- a/arch/arm/boot/dts/mt2701.dtsi
+++ b/arch/arm/boot/dts/mt2701.dtsi
@@ -77,6 +77,36 @@
#clock-cells = <0>;
};
 
+   thermal-zones {
+   cpu_thermal: cpu_thermal {
+   polling-delay-passive = <1000>; /* milliseconds */
+   polling-delay = <1000>; /* milliseconds */
+
+   thermal-sensors = < 0>;
+   sustainable-power = <1000>;
+
+   trips {
+   threshold: trip-point@0 {
+   temperature = <68000>;
+   hysteresis = <2000>;
+   type = "passive";
+   };
+
+   target: trip-point@1 {
+   temperature = <85000>;
+   hysteresis = <2000>;
+   type = "passive";
+   };
+
+   cpu_crit: cpu_crit@0 {
+   temperature = <115000>;
+   hysteresis = <2000>;
+   type = "critical";
+   };
+   };
+   };
+   };
+
timer {
compatible = "arm,armv7-timer";
interrupt-parent = <>;
@@ -183,4 +213,17 @@
clocks = <_clk>;
status = "disabled";
};
+
+   thermal: thermal@1100b000 {
+   #thermal-sensor-cells = <0>;
+   compatible = "mediatek,mt2701-thermal";
+   reg = <0 0x1100b000 0 0x1000>;
+   interrupts = ;
+   clocks = < CLK_PERI_THERM>, < CLK_PERI_AUXADC>;
+   clock-names = "therm", "auxadc";
+   resets = < 0x10>;
+   reset-names = "therm";
+   mediatek,auxadc = <>;
+   mediatek,apmixedsys = <>;
+   };
 };
-- 
1.7.9.5



Re: [RESEND][PATCH 3/3] arm64: dts: mt8173: Add dynamic power node.

2016-04-20 Thread dawei chien
On Tue, 2016-03-15 at 16:10 +0800, Dawei Chien (錢大衛) wrote:
> This device node is for calculating dynamic power in mW.
> Since mt8173 has two clusters, there are two dynamic power
> coefficient as well.
> 
> Signed-off-by: Dawei Chien <dawei.ch...@mediatek.com>
> ---
> This patch is base on patchset:
> https://lkml.org/lkml/2015/11/17/251

Sorry for miss one dependence for this device node.
https://lkml.org/lkml/2015/7/9/206

> ---
>  arch/arm64/boot/dts/mediatek/mt8173.dtsi |4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
> b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
> index f9c44cc..5cb6b4e 100644
> --- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
> +++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
> @@ -71,6 +71,7 @@
> #cooling-cells = <2>;
> #cooling-min-level = <0>;
> #cooling-max-level = <7>;
> +   dynamic-power-coefficient = <263>;
> };
> 
> cpu1: cpu@1 {
> @@ -95,6 +96,7 @@
> #cooling-cells = <2>;
> #cooling-min-level = <0>;
> #cooling-max-level = <7>;
> +   dynamic-power-coefficient = <263>;
> };
> 
> cpu2: cpu@100 {
> @@ -119,6 +121,7 @@
> #cooling-cells = <2>;
> #cooling-min-level = <0>;
> #cooling-max-level = <7>;
> +   dynamic-power-coefficient = <530>;
> };
> 
> cpu3: cpu@101 {
> @@ -143,6 +146,7 @@
> #cooling-cells = <2>;
> #cooling-min-level = <0>;
> #cooling-max-level = <7>;
> +   dynamic-power-coefficient = <530>;
> };
> 
> idle-states {
> --
> 1.7.9.5
> 




Re: [RESEND][PATCH 3/3] arm64: dts: mt8173: Add dynamic power node.

2016-04-20 Thread dawei chien
On Tue, 2016-03-15 at 16:10 +0800, Dawei Chien (錢大衛) wrote:
> This device node is for calculating dynamic power in mW.
> Since mt8173 has two clusters, there are two dynamic power
> coefficient as well.
> 
> Signed-off-by: Dawei Chien 
> ---
> This patch is base on patchset:
> https://lkml.org/lkml/2015/11/17/251

Sorry for miss one dependence for this device node.
https://lkml.org/lkml/2015/7/9/206

> ---
>  arch/arm64/boot/dts/mediatek/mt8173.dtsi |4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
> b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
> index f9c44cc..5cb6b4e 100644
> --- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
> +++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
> @@ -71,6 +71,7 @@
> #cooling-cells = <2>;
> #cooling-min-level = <0>;
> #cooling-max-level = <7>;
> +   dynamic-power-coefficient = <263>;
> };
> 
> cpu1: cpu@1 {
> @@ -95,6 +96,7 @@
> #cooling-cells = <2>;
> #cooling-min-level = <0>;
> #cooling-max-level = <7>;
> +   dynamic-power-coefficient = <263>;
> };
> 
> cpu2: cpu@100 {
> @@ -119,6 +121,7 @@
> #cooling-cells = <2>;
> #cooling-min-level = <0>;
> #cooling-max-level = <7>;
> +   dynamic-power-coefficient = <530>;
> };
> 
> cpu3: cpu@101 {
> @@ -143,6 +146,7 @@
> #cooling-cells = <2>;
> #cooling-min-level = <0>;
> #cooling-max-level = <7>;
> +   dynamic-power-coefficient = <530>;
> };
> 
> idle-states {
> --
> 1.7.9.5
> 




Re: [PATCH v6 0/3] thermal: mediatek: Add cpu dynamic power cooling model.

2016-04-11 Thread dawei chien
On Tue, 2016-04-12 at 10:41 +0530, Viresh Kumar wrote:
> On 12-04-16, 10:32, dawei chien wrote:
> > On Tue, 2016-03-22 at 13:13 +0800, dawei chien wrote:
> > > On Tue, 2016-03-15 at 13:17 +0700, Viresh Kumar wrote:
> > > > Its Rafael, who is going to apply this one.
> > > > 
> > > > Can you please resend it as he may not have it in patchworks?
> > > > 
> > > 
> > > Hi Rafael,
> > > Would you merge this patch to your tree, thank you.
> > > 
> > > BR,
> > > Dawei
> > 
> > Hi Rafael,
> > Would you please merge this patch, or please kindly let me know for any
> > problem, thank you.
> 
> Didn't I ask you earlier to resend this patch as Rafael wouldn't have
> it in his queue now ?
> 
> Please resend it and that will make it earlier for Rafael to get it
> applied.
> 
Hi Viresh,
Please refer to following for my resending, thank you.

https://lkml.org/lkml/2016/3/15/101
https://patchwork.kernel.org/patch/8586131/
https://patchwork.kernel.org/patch/8586111/
https://patchwork.kernel.org/patch/8586081/

BR,
Dawei



Re: [PATCH v6 0/3] thermal: mediatek: Add cpu dynamic power cooling model.

2016-04-11 Thread dawei chien
On Tue, 2016-04-12 at 10:41 +0530, Viresh Kumar wrote:
> On 12-04-16, 10:32, dawei chien wrote:
> > On Tue, 2016-03-22 at 13:13 +0800, dawei chien wrote:
> > > On Tue, 2016-03-15 at 13:17 +0700, Viresh Kumar wrote:
> > > > Its Rafael, who is going to apply this one.
> > > > 
> > > > Can you please resend it as he may not have it in patchworks?
> > > > 
> > > 
> > > Hi Rafael,
> > > Would you merge this patch to your tree, thank you.
> > > 
> > > BR,
> > > Dawei
> > 
> > Hi Rafael,
> > Would you please merge this patch, or please kindly let me know for any
> > problem, thank you.
> 
> Didn't I ask you earlier to resend this patch as Rafael wouldn't have
> it in his queue now ?
> 
> Please resend it and that will make it earlier for Rafael to get it
> applied.
> 
Hi Viresh,
Please refer to following for my resending, thank you.

https://lkml.org/lkml/2016/3/15/101
https://patchwork.kernel.org/patch/8586131/
https://patchwork.kernel.org/patch/8586111/
https://patchwork.kernel.org/patch/8586081/

BR,
Dawei



Re: [PATCH v6 0/3] thermal: mediatek: Add cpu dynamic power cooling model.

2016-04-11 Thread dawei chien
On Tue, 2016-03-22 at 13:13 +0800, dawei chien wrote:
> On Tue, 2016-03-15 at 13:17 +0700, Viresh Kumar wrote:
> > On 15-03-16, 12:53, dawei chien wrote:
> > > On Thu, 2015-12-17 at 09:52 +0800, Viresh Kumar wrote:
> > > > On 16-12-15, 21:29, Dawei Chien wrote:
> > > > > Use Intelligent Power Allocation (IPA) technical to add dynamic power 
> > > > > model
> > > > > for binding CPU thermal zone. The power allocator governor allocates 
> > > > > power
> > > > > budget to control CPU temperature.
> > > > >
> > > > > Power Allocator governor is able to keep SOC temperature within a 
> > > > > defined
> > > > > temperature range to avoid SOC overheat and keep it's performance.
> > > > > mt8173-cpufreq.c need to register its' own power model with power 
> > > > > allocator
> > > > > thermal governor, so that power allocator governor can allocates 
> > > > > suitable
> > > > > power budget to control CPU temperature.
> > > > >
> > > > > Binding document is refer to this patchset
> > > > > https://lkml.org/lkml/2015/11/30/239
> > > > >
> > > > > Change since V5:
> > > > > 1. Remove thermal sensor ID from phandles
> > > > 
> > > > Though you should have included this in the new version, but still
> > > > 
> > > > Acked-by: Viresh Kumar <viresh.ku...@linaro.org>
> > > > 
> > > > --
> > > > viresh
> > > 
> > > Hi Viresh,
> > > Would you please pull this patch to your tree since following patch
> > > already pulled in, thank you.
> > > 
> > > https://lkml.org/lkml/2015/11/30/239
> > 
> > Its Rafael, who is going to apply this one.
> > 
> > Can you please resend it as he may not have it in patchworks?
> > 
> 
> Hi Rafael,
> Would you merge this patch to your tree, thank you.
> 
> BR,
> Dawei

Hi Rafael,
Would you please merge this patch, or please kindly let me know for any
problem, thank you.
 
BR,
Dawei



Re: [PATCH v6 0/3] thermal: mediatek: Add cpu dynamic power cooling model.

2016-04-11 Thread dawei chien
On Tue, 2016-03-22 at 13:13 +0800, dawei chien wrote:
> On Tue, 2016-03-15 at 13:17 +0700, Viresh Kumar wrote:
> > On 15-03-16, 12:53, dawei chien wrote:
> > > On Thu, 2015-12-17 at 09:52 +0800, Viresh Kumar wrote:
> > > > On 16-12-15, 21:29, Dawei Chien wrote:
> > > > > Use Intelligent Power Allocation (IPA) technical to add dynamic power 
> > > > > model
> > > > > for binding CPU thermal zone. The power allocator governor allocates 
> > > > > power
> > > > > budget to control CPU temperature.
> > > > >
> > > > > Power Allocator governor is able to keep SOC temperature within a 
> > > > > defined
> > > > > temperature range to avoid SOC overheat and keep it's performance.
> > > > > mt8173-cpufreq.c need to register its' own power model with power 
> > > > > allocator
> > > > > thermal governor, so that power allocator governor can allocates 
> > > > > suitable
> > > > > power budget to control CPU temperature.
> > > > >
> > > > > Binding document is refer to this patchset
> > > > > https://lkml.org/lkml/2015/11/30/239
> > > > >
> > > > > Change since V5:
> > > > > 1. Remove thermal sensor ID from phandles
> > > > 
> > > > Though you should have included this in the new version, but still
> > > > 
> > > > Acked-by: Viresh Kumar 
> > > > 
> > > > --
> > > > viresh
> > > 
> > > Hi Viresh,
> > > Would you please pull this patch to your tree since following patch
> > > already pulled in, thank you.
> > > 
> > > https://lkml.org/lkml/2015/11/30/239
> > 
> > Its Rafael, who is going to apply this one.
> > 
> > Can you please resend it as he may not have it in patchworks?
> > 
> 
> Hi Rafael,
> Would you merge this patch to your tree, thank you.
> 
> BR,
> Dawei

Hi Rafael,
Would you please merge this patch, or please kindly let me know for any
problem, thank you.
 
BR,
Dawei



Re: [PATCH v6 0/3] thermal: mediatek: Add cpu dynamic power cooling model.

2016-03-21 Thread dawei chien
On Tue, 2016-03-15 at 13:17 +0700, Viresh Kumar wrote:
> On 15-03-16, 12:53, dawei chien wrote:
> > On Thu, 2015-12-17 at 09:52 +0800, Viresh Kumar wrote:
> > > On 16-12-15, 21:29, Dawei Chien wrote:
> > > > Use Intelligent Power Allocation (IPA) technical to add dynamic power 
> > > > model
> > > > for binding CPU thermal zone. The power allocator governor allocates 
> > > > power
> > > > budget to control CPU temperature.
> > > >
> > > > Power Allocator governor is able to keep SOC temperature within a 
> > > > defined
> > > > temperature range to avoid SOC overheat and keep it's performance.
> > > > mt8173-cpufreq.c need to register its' own power model with power 
> > > > allocator
> > > > thermal governor, so that power allocator governor can allocates 
> > > > suitable
> > > > power budget to control CPU temperature.
> > > >
> > > > Binding document is refer to this patchset
> > > > https://lkml.org/lkml/2015/11/30/239
> > > >
> > > > Change since V5:
> > > > 1. Remove thermal sensor ID from phandles
> > > 
> > > Though you should have included this in the new version, but still
> > > 
> > > Acked-by: Viresh Kumar <viresh.ku...@linaro.org>
> > > 
> > > --
> > > viresh
> > 
> > Hi Viresh,
> > Would you please pull this patch to your tree since following patch
> > already pulled in, thank you.
> > 
> > https://lkml.org/lkml/2015/11/30/239
> 
> Its Rafael, who is going to apply this one.
> 
> Can you please resend it as he may not have it in patchworks?
> 

Hi Rafael,
Would you merge this patch to your tee, thank you.

BR,
Dawei



Re: [PATCH v6 0/3] thermal: mediatek: Add cpu dynamic power cooling model.

2016-03-21 Thread dawei chien
On Tue, 2016-03-15 at 13:17 +0700, Viresh Kumar wrote:
> On 15-03-16, 12:53, dawei chien wrote:
> > On Thu, 2015-12-17 at 09:52 +0800, Viresh Kumar wrote:
> > > On 16-12-15, 21:29, Dawei Chien wrote:
> > > > Use Intelligent Power Allocation (IPA) technical to add dynamic power 
> > > > model
> > > > for binding CPU thermal zone. The power allocator governor allocates 
> > > > power
> > > > budget to control CPU temperature.
> > > >
> > > > Power Allocator governor is able to keep SOC temperature within a 
> > > > defined
> > > > temperature range to avoid SOC overheat and keep it's performance.
> > > > mt8173-cpufreq.c need to register its' own power model with power 
> > > > allocator
> > > > thermal governor, so that power allocator governor can allocates 
> > > > suitable
> > > > power budget to control CPU temperature.
> > > >
> > > > Binding document is refer to this patchset
> > > > https://lkml.org/lkml/2015/11/30/239
> > > >
> > > > Change since V5:
> > > > 1. Remove thermal sensor ID from phandles
> > > 
> > > Though you should have included this in the new version, but still
> > > 
> > > Acked-by: Viresh Kumar 
> > > 
> > > --
> > > viresh
> > 
> > Hi Viresh,
> > Would you please pull this patch to your tree since following patch
> > already pulled in, thank you.
> > 
> > https://lkml.org/lkml/2015/11/30/239
> 
> Its Rafael, who is going to apply this one.
> 
> Can you please resend it as he may not have it in patchworks?
> 

Hi Rafael,
Would you merge this patch to your tee, thank you.

BR,
Dawei



[RESEND][PATCH v6 0/3] thermal: mediatek: Add cpu dynamic power cooling model.

2016-03-15 Thread Dawei Chien
Use Intelligent Power Allocation (IPA) technical to add dynamic power model for 
binding CPU thermal zone. The power allocator governor allocates power budget 
to control CPU temperature.

Power Allocator governor is able to keep SOC temperature within a defined 
temperature range to avoid SOC overheat and keep it's performance.
mt8173-cpufreq.c need to register its' own power model with power allocator 
thermal governor, so that power allocator governor can allocates suitable power 
budget to control CPU temperature.

Binding document is refer to this patchset
https://lkml.org/lkml/2015/11/30/239

Change since V5:
1. Remove thermal sensor ID from phandles

Change since V4:
1. Remove unnecessary error-checking for mt8173-cpufreq.c 2. Initializing 
variable capacitance with 0

Change since V3:
1. Remove static power model
2. Split V3's device tree in two for thermal zones and dynamic power models 
respectively

Change since V2:
1. Move dynamic/static power model in device tree

Change since V1:
1. Include mt8171.h and sort header file for mt8173.dtsi

Dawei Chien (3):
  thermal: mediatek: Add cpu dynamic power cooling model.
  arm64: dts: mt8173: Add thermal zone node.
  arm64: dts: mt8173: Add dynamic power node.

 arch/arm64/boot/dts/mediatek/mt8173.dtsi |   47 ++
 drivers/cpufreq/mt8173-cpufreq.c |   12 ++--
 2 files changed, 57 insertions(+), 2 deletions(-)


[RESEND][PATCH 3/3] arm64: dts: mt8173: Add dynamic power node.

2016-03-15 Thread Dawei Chien
This device node is for calculating dynamic power in mW.
Since mt8173 has two clusters, there are two dynamic power
coefficient as well.

Signed-off-by: Dawei Chien <dawei.ch...@mediatek.com>
---
This patch is base on patchset:
https://lkml.org/lkml/2015/11/17/251
---
 arch/arm64/boot/dts/mediatek/mt8173.dtsi |4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
index f9c44cc..5cb6b4e 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -71,6 +71,7 @@
#cooling-cells = <2>;
#cooling-min-level = <0>;
#cooling-max-level = <7>;
+   dynamic-power-coefficient = <263>;
};
 
cpu1: cpu@1 {
@@ -95,6 +96,7 @@
#cooling-cells = <2>;
#cooling-min-level = <0>;
#cooling-max-level = <7>;
+   dynamic-power-coefficient = <263>;
};
 
cpu2: cpu@100 {
@@ -119,6 +121,7 @@
#cooling-cells = <2>;
#cooling-min-level = <0>;
#cooling-max-level = <7>;
+   dynamic-power-coefficient = <530>;
};
 
cpu3: cpu@101 {
@@ -143,6 +146,7 @@
#cooling-cells = <2>;
#cooling-min-level = <0>;
#cooling-max-level = <7>;
+   dynamic-power-coefficient = <530>;
};
 
idle-states {
-- 
1.7.9.5



[RESEND][PATCH 1/3] thermal: mediatek: Add cpu dynamic power cooling model.

2016-03-15 Thread Dawei Chien
MT8173 cpufreq driver select of_cpufreq_power_cooling_register registering
cooling devices with dynamic power coefficient.

Signed-off-by: Dawei Chien <dawei.ch...@mediatek.com>
Acked-by: Viresh Kumar <viresh.ku...@linaro.org>
---
This patch is base on patchset:
https://lkml.org/lkml/2015/11/17/251
---
 drivers/cpufreq/mt8173-cpufreq.c |   11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/cpufreq/mt8173-cpufreq.c b/drivers/cpufreq/mt8173-cpufreq.c
index 1efba34..d8ad406 100644
--- a/drivers/cpufreq/mt8173-cpufreq.c
+++ b/drivers/cpufreq/mt8173-cpufreq.c
@@ -309,17 +309,24 @@ static int mtk_cpufreq_set_target(struct cpufreq_policy 
*policy,
return 0;
 }
 
+#define DYNAMIC_POWER "dynamic-power-coefficient"
+
 static void mtk_cpufreq_ready(struct cpufreq_policy *policy)
 {
struct mtk_cpu_dvfs_info *info = policy->driver_data;
struct device_node *np = of_node_get(info->cpu_dev->of_node);
+   u32 capacitance = 0;
 
if (WARN_ON(!np))
return;
 
if (of_find_property(np, "#cooling-cells", NULL)) {
-   info->cdev = of_cpufreq_cooling_register(np,
-policy->related_cpus);
+   of_property_read_u32(np, DYNAMIC_POWER, );
+
+   info->cdev = of_cpufreq_power_cooling_register(np,
+   policy->related_cpus,
+   capacitance,
+   NULL);
 
if (IS_ERR(info->cdev)) {
dev_err(info->cpu_dev,
-- 
1.7.9.5



[RESEND][PATCH 3/3] arm64: dts: mt8173: Add dynamic power node.

2016-03-15 Thread Dawei Chien
This device node is for calculating dynamic power in mW.
Since mt8173 has two clusters, there are two dynamic power
coefficient as well.

Signed-off-by: Dawei Chien 
---
This patch is base on patchset:
https://lkml.org/lkml/2015/11/17/251
---
 arch/arm64/boot/dts/mediatek/mt8173.dtsi |4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
index f9c44cc..5cb6b4e 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -71,6 +71,7 @@
#cooling-cells = <2>;
#cooling-min-level = <0>;
#cooling-max-level = <7>;
+   dynamic-power-coefficient = <263>;
};
 
cpu1: cpu@1 {
@@ -95,6 +96,7 @@
#cooling-cells = <2>;
#cooling-min-level = <0>;
#cooling-max-level = <7>;
+   dynamic-power-coefficient = <263>;
};
 
cpu2: cpu@100 {
@@ -119,6 +121,7 @@
#cooling-cells = <2>;
#cooling-min-level = <0>;
#cooling-max-level = <7>;
+   dynamic-power-coefficient = <530>;
};
 
cpu3: cpu@101 {
@@ -143,6 +146,7 @@
#cooling-cells = <2>;
#cooling-min-level = <0>;
#cooling-max-level = <7>;
+   dynamic-power-coefficient = <530>;
};
 
idle-states {
-- 
1.7.9.5



[RESEND][PATCH 1/3] thermal: mediatek: Add cpu dynamic power cooling model.

2016-03-15 Thread Dawei Chien
MT8173 cpufreq driver select of_cpufreq_power_cooling_register registering
cooling devices with dynamic power coefficient.

Signed-off-by: Dawei Chien 
Acked-by: Viresh Kumar 
---
This patch is base on patchset:
https://lkml.org/lkml/2015/11/17/251
---
 drivers/cpufreq/mt8173-cpufreq.c |   11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/cpufreq/mt8173-cpufreq.c b/drivers/cpufreq/mt8173-cpufreq.c
index 1efba34..d8ad406 100644
--- a/drivers/cpufreq/mt8173-cpufreq.c
+++ b/drivers/cpufreq/mt8173-cpufreq.c
@@ -309,17 +309,24 @@ static int mtk_cpufreq_set_target(struct cpufreq_policy 
*policy,
return 0;
 }
 
+#define DYNAMIC_POWER "dynamic-power-coefficient"
+
 static void mtk_cpufreq_ready(struct cpufreq_policy *policy)
 {
struct mtk_cpu_dvfs_info *info = policy->driver_data;
struct device_node *np = of_node_get(info->cpu_dev->of_node);
+   u32 capacitance = 0;
 
if (WARN_ON(!np))
return;
 
if (of_find_property(np, "#cooling-cells", NULL)) {
-   info->cdev = of_cpufreq_cooling_register(np,
-policy->related_cpus);
+   of_property_read_u32(np, DYNAMIC_POWER, );
+
+   info->cdev = of_cpufreq_power_cooling_register(np,
+   policy->related_cpus,
+   capacitance,
+   NULL);
 
if (IS_ERR(info->cdev)) {
dev_err(info->cpu_dev,
-- 
1.7.9.5



[RESEND][PATCH v6 0/3] thermal: mediatek: Add cpu dynamic power cooling model.

2016-03-15 Thread Dawei Chien
Use Intelligent Power Allocation (IPA) technical to add dynamic power model for 
binding CPU thermal zone. The power allocator governor allocates power budget 
to control CPU temperature.

Power Allocator governor is able to keep SOC temperature within a defined 
temperature range to avoid SOC overheat and keep it's performance.
mt8173-cpufreq.c need to register its' own power model with power allocator 
thermal governor, so that power allocator governor can allocates suitable power 
budget to control CPU temperature.

Binding document is refer to this patchset
https://lkml.org/lkml/2015/11/30/239

Change since V5:
1. Remove thermal sensor ID from phandles

Change since V4:
1. Remove unnecessary error-checking for mt8173-cpufreq.c 2. Initializing 
variable capacitance with 0

Change since V3:
1. Remove static power model
2. Split V3's device tree in two for thermal zones and dynamic power models 
respectively

Change since V2:
1. Move dynamic/static power model in device tree

Change since V1:
1. Include mt8171.h and sort header file for mt8173.dtsi

Dawei Chien (3):
  thermal: mediatek: Add cpu dynamic power cooling model.
  arm64: dts: mt8173: Add thermal zone node.
  arm64: dts: mt8173: Add dynamic power node.

 arch/arm64/boot/dts/mediatek/mt8173.dtsi |   47 ++
 drivers/cpufreq/mt8173-cpufreq.c |   12 ++--
 2 files changed, 57 insertions(+), 2 deletions(-)


[RESEND][PATCH 2/3] arm64: dts: mt8173: Add thermal zone node.

2016-03-15 Thread Dawei Chien
This adds thermal zone node to Mediatek MT8173 dtsi file.

Signed-off-by: Dawei Chien <dawei.ch...@mediatek.com>
---
This patch is base on patchset:
https://lkml.org/lkml/2015/11/30/239
---
 arch/arm64/boot/dts/mediatek/mt8173.dtsi |   43 ++
 1 file changed, 43 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
index 47151e8..f9c44cc 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -188,6 +188,49 @@
clock-output-names = "cpum_ck";
};
 
+   thermal-zones {
+   cpu_thermal: cpu_thermal {
+   polling-delay-passive = <1000>; /* milliseconds */
+   polling-delay = <1000>; /* milliseconds */
+
+   thermal-sensors = <>;
+   sustainable-power = <1500>; /* milliwatts */
+
+   trips {
+   threshold: trip-point@0 {
+   temperature = <68000>;
+   hysteresis = <2000>;
+   type = "passive";
+   };
+
+   target: trip-point@1 {
+   temperature = <85000>;
+   hysteresis = <2000>;
+   type = "passive";
+   };
+
+   cpu_crit: cpu_crit@0 {
+   temperature = <115000>;
+   hysteresis = <2000>;
+   type = "critical";
+   };
+   };
+
+   cooling-maps {
+   map@0 {
+   trip = <>;
+   cooling-device = < 0 0>;
+   contribution = <1024>;
+   };
+   map@1 {
+   trip = <>;
+   cooling-device = < 0 0>;
+   contribution = <2048>;
+   };
+   };
+   };
+   };
+
timer {
compatible = "arm,armv8-timer";
interrupt-parent = <>;
-- 
1.7.9.5



[RESEND][PATCH 2/3] arm64: dts: mt8173: Add thermal zone node.

2016-03-15 Thread Dawei Chien
This adds thermal zone node to Mediatek MT8173 dtsi file.

Signed-off-by: Dawei Chien 
---
This patch is base on patchset:
https://lkml.org/lkml/2015/11/30/239
---
 arch/arm64/boot/dts/mediatek/mt8173.dtsi |   43 ++
 1 file changed, 43 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
index 47151e8..f9c44cc 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -188,6 +188,49 @@
clock-output-names = "cpum_ck";
};
 
+   thermal-zones {
+   cpu_thermal: cpu_thermal {
+   polling-delay-passive = <1000>; /* milliseconds */
+   polling-delay = <1000>; /* milliseconds */
+
+   thermal-sensors = <>;
+   sustainable-power = <1500>; /* milliwatts */
+
+   trips {
+   threshold: trip-point@0 {
+   temperature = <68000>;
+   hysteresis = <2000>;
+   type = "passive";
+   };
+
+   target: trip-point@1 {
+   temperature = <85000>;
+   hysteresis = <2000>;
+   type = "passive";
+   };
+
+   cpu_crit: cpu_crit@0 {
+   temperature = <115000>;
+   hysteresis = <2000>;
+   type = "critical";
+   };
+   };
+
+   cooling-maps {
+   map@0 {
+   trip = <>;
+   cooling-device = < 0 0>;
+   contribution = <1024>;
+   };
+   map@1 {
+   trip = <>;
+   cooling-device = < 0 0>;
+   contribution = <2048>;
+   };
+   };
+   };
+   };
+
timer {
compatible = "arm,armv8-timer";
interrupt-parent = <>;
-- 
1.7.9.5



Re: [PATCH v6 0/3] thermal: mediatek: Add cpu dynamic power cooling model.

2016-03-14 Thread dawei chien
On Thu, 2015-12-17 at 09:52 +0800, Viresh Kumar wrote:
> On 16-12-15, 21:29, Dawei Chien wrote:
> > Use Intelligent Power Allocation (IPA) technical to add dynamic power model
> > for binding CPU thermal zone. The power allocator governor allocates power
> > budget to control CPU temperature.
> >
> > Power Allocator governor is able to keep SOC temperature within a defined
> > temperature range to avoid SOC overheat and keep it's performance.
> > mt8173-cpufreq.c need to register its' own power model with power allocator
> > thermal governor, so that power allocator governor can allocates suitable
> > power budget to control CPU temperature.
> >
> > Binding document is refer to this patchset
> > https://lkml.org/lkml/2015/11/30/239
> >
> > Change since V5:
> > 1. Remove thermal sensor ID from phandles
> 
> Though you should have included this in the new version, but still
> 
> Acked-by: Viresh Kumar <viresh.ku...@linaro.org>
> 
> --
> viresh

Hi Viresh,
Would you please pull this patch to your tree since following patch
already pulled in, thank you.

https://lkml.org/lkml/2015/11/30/239

BR,
Dawei



Re: [PATCH v6 0/3] thermal: mediatek: Add cpu dynamic power cooling model.

2016-03-14 Thread dawei chien
On Thu, 2015-12-17 at 09:52 +0800, Viresh Kumar wrote:
> On 16-12-15, 21:29, Dawei Chien wrote:
> > Use Intelligent Power Allocation (IPA) technical to add dynamic power model
> > for binding CPU thermal zone. The power allocator governor allocates power
> > budget to control CPU temperature.
> >
> > Power Allocator governor is able to keep SOC temperature within a defined
> > temperature range to avoid SOC overheat and keep it's performance.
> > mt8173-cpufreq.c need to register its' own power model with power allocator
> > thermal governor, so that power allocator governor can allocates suitable
> > power budget to control CPU temperature.
> >
> > Binding document is refer to this patchset
> > https://lkml.org/lkml/2015/11/30/239
> >
> > Change since V5:
> > 1. Remove thermal sensor ID from phandles
> 
> Though you should have included this in the new version, but still
> 
> Acked-by: Viresh Kumar 
> 
> --
> viresh

Hi Viresh,
Would you please pull this patch to your tree since following patch
already pulled in, thank you.

https://lkml.org/lkml/2015/11/30/239

BR,
Dawei



[PATCH] arm64: dts: mt8173: add node for thermal calibration

2016-02-04 Thread Dawei Chien
Add this for supporting thermal calibration by e-fuse data.

Signed-off-by: Dawei Chien 
---
Because MTK thermal/efuse patches hadn't landed on mainline, this patch
must base on following patchset:
https://lkml.org/lkml/2015/11/17/251
https://lkml.org/lkml/2015/11/19/169
https://lkml.org/lkml/2015/11/30/239
https://lkml.org/lkml/2015/12/16/195
---
 arch/arm64/boot/dts/mediatek/mt8173.dtsi |7 +++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
index ffcca66..0c9d17e 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -391,6 +391,11 @@
efuse: efuse@10206000 {
compatible = "mediatek,mt8173-efuse";
reg = <0 0x10206000 0 0x1000>;
+   #address-cells = <1>;
+   #size-cells = <1>;
+   thermal_calibration: calib@528 {
+   reg = <0x528 0xc>;
+   };
};
 
apmixedsys: clock-controller@10209000 {
@@ -744,6 +749,8 @@
resets = < MT8173_PERI_THERM_SW_RST>;
mediatek,auxadc = <>;
mediatek,apmixedsys = <>;
+   nvmem-cells = <_calibration>;
+   nvmem-cell-names = "calibration-data";
};
};
 };
-- 
1.7.9.5



[PATCH] arm64: dts: mt8173: add node for thermal calibration

2016-02-04 Thread Dawei Chien
Add this for supporting thermal calibration by e-fuse data.

Signed-off-by: Dawei Chien <dawei.ch...@mediatek.com>
---
Because MTK thermal/efuse patches hadn't landed on mainline, this patch
must base on following patchset:
https://lkml.org/lkml/2015/11/17/251
https://lkml.org/lkml/2015/11/19/169
https://lkml.org/lkml/2015/11/30/239
https://lkml.org/lkml/2015/12/16/195
---
 arch/arm64/boot/dts/mediatek/mt8173.dtsi |7 +++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
index ffcca66..0c9d17e 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -391,6 +391,11 @@
efuse: efuse@10206000 {
compatible = "mediatek,mt8173-efuse";
reg = <0 0x10206000 0 0x1000>;
+   #address-cells = <1>;
+   #size-cells = <1>;
+   thermal_calibration: calib@528 {
+   reg = <0x528 0xc>;
+   };
};
 
apmixedsys: clock-controller@10209000 {
@@ -744,6 +749,8 @@
resets = < MT8173_PERI_THERM_SW_RST>;
mediatek,auxadc = <>;
mediatek,apmixedsys = <>;
+   nvmem-cells = <_calibration>;
+   nvmem-cell-names = "calibration-data";
};
};
 };
-- 
1.7.9.5



[PATCH v6 1/3] thermal: mediatek: Add cpu dynamic power cooling model.

2015-12-16 Thread Dawei Chien
MT8173 cpufreq driver select of_cpufreq_power_cooling_register registering
cooling devices with dynamic power coefficient.

Signed-off-by: Dawei Chien 
---
This patch is base on patchset:
https://lkml.org/lkml/2015/11/17/251
---
 drivers/cpufreq/mt8173-cpufreq.c |   11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/cpufreq/mt8173-cpufreq.c b/drivers/cpufreq/mt8173-cpufreq.c
index 83001dc..d00bab5 100644
--- a/drivers/cpufreq/mt8173-cpufreq.c
+++ b/drivers/cpufreq/mt8173-cpufreq.c
@@ -263,17 +263,24 @@ static int mtk_cpufreq_set_target(struct cpufreq_policy 
*policy,
return 0;
 }
 
+#define DYNAMIC_POWER "dynamic-power-coefficient"
+
 static void mtk_cpufreq_ready(struct cpufreq_policy *policy)
 {
struct mtk_cpu_dvfs_info *info = policy->driver_data;
struct device_node *np = of_node_get(info->cpu_dev->of_node);
+   u32 capacitance = 0;
 
if (WARN_ON(!np))
return;
 
if (of_find_property(np, "#cooling-cells", NULL)) {
-   info->cdev = of_cpufreq_cooling_register(np,
-policy->related_cpus);
+   of_property_read_u32(np, DYNAMIC_POWER, );
+
+   info->cdev = of_cpufreq_power_cooling_register(np,
+   policy->related_cpus,
+   capacitance,
+   NULL);
 
if (IS_ERR(info->cdev)) {
dev_err(info->cpu_dev,
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v6 3/3] arm64: dts: mt8173: Add dynamic power node.

2015-12-16 Thread Dawei Chien
This device node is for calculating dynamic power in mW.
Since mt8173 has two clusters, there are two dynamic power
coefficient as well.

Signed-off-by: Dawei Chien 
---
This patch is base on patchset:
https://lkml.org/lkml/2015/11/17/251
---
 arch/arm64/boot/dts/mediatek/mt8173.dtsi |4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
index c962d94..b6f4ea5 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -71,6 +71,7 @@
#cooling-cells = <2>;
#cooling-min-level = <0>;
#cooling-max-level = <7>;
+   dynamic-power-coefficient = <263>;
};
 
cpu1: cpu@1 {
@@ -95,6 +96,7 @@
#cooling-cells = <2>;
#cooling-min-level = <0>;
#cooling-max-level = <7>;
+   dynamic-power-coefficient = <263>;
};
 
cpu2: cpu@100 {
@@ -119,6 +121,7 @@
#cooling-cells = <2>;
#cooling-min-level = <0>;
#cooling-max-level = <7>;
+   dynamic-power-coefficient = <530>;
};
 
cpu3: cpu@101 {
@@ -143,6 +146,7 @@
#cooling-cells = <2>;
#cooling-min-level = <0>;
#cooling-max-level = <7>;
+   dynamic-power-coefficient = <530>;
};
 
idle-states {
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v6 0/3] thermal: mediatek: Add cpu dynamic power cooling model.

2015-12-16 Thread Dawei Chien
Use Intelligent Power Allocation (IPA) technical to add dynamic power model
for binding CPU thermal zone. The power allocator governor allocates power
budget to control CPU temperature.

Power Allocator governor is able to keep SOC temperature within a defined
temperature range to avoid SOC overheat and keep it's performance.
mt8173-cpufreq.c need to register its' own power model with power allocator
thermal governor, so that power allocator governor can allocates suitable
power budget to control CPU temperature.

Binding document is refer to this patchset
https://lkml.org/lkml/2015/11/30/239

Change since V5:
1. Remove thermal sensor ID from phandles

Change since V4:
1. Remove unnecessary error-checking for mt8173-cpufreq.c
2. Initializing variable capacitance with 0

Change since V3:
1. Remove static power model
2. Split V3's device tree in two for thermal zones and dynamic power models 
respectively

Change since V2:
1. Move dynamic/static power model in device tree

Change since V1:
1. Include mt8171.h and sort header file for mt8173.dtsi

Dawei Chien (3):
  thermal: mediatek: Add cpu dynamic power cooling model.
  arm64: dts: mt8173: Add thermal zone node.
  arm64: dts: mt8173: Add dynamic power node.

 arch/arm64/boot/dts/mediatek/mt8173.dtsi |   47 ++
 drivers/cpufreq/mt8173-cpufreq.c |   12 ++--
 2 files changed, 57 insertions(+), 2 deletions(-)

--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v6 2/3] arm64: dts: mt8173: Add thermal zone node.

2015-12-16 Thread Dawei Chien
This adds thermal zone node to Mediatek MT8173 dtsi file.

Signed-off-by: Dawei Chien 
---
This patch is base on patchset:
https://lkml.org/lkml/2015/11/30/239
---
 arch/arm64/boot/dts/mediatek/mt8173.dtsi |   43 ++
 1 file changed, 43 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
index fda805d..c962d94 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -188,6 +188,49 @@
clock-output-names = "cpum_ck";
};
 
+   thermal-zones {
+   cpu_thermal: cpu_thermal {
+   polling-delay-passive = <1000>; /* milliseconds */
+   polling-delay = <1000>; /* milliseconds */
+
+   thermal-sensors = <>;
+   sustainable-power = <1500>; /* milliwatts */
+
+   trips {
+   threshold: trip-point@0 {
+   temperature = <68000>;
+   hysteresis = <2000>;
+   type = "passive";
+   };
+
+   target: trip-point@1 {
+   temperature = <85000>;
+   hysteresis = <2000>;
+   type = "passive";
+   };
+
+   cpu_crit: cpu_crit@0 {
+   temperature = <115000>;
+   hysteresis = <2000>;
+   type = "critical";
+   };
+   };
+
+   cooling-maps {
+   map@0 {
+   trip = <>;
+   cooling-device = < 0 0>;
+   contribution = <1024>;
+   };
+   map@1 {
+   trip = <>;
+   cooling-device = < 0 0>;
+   contribution = <2048>;
+   };
+   };
+   };
+   };
+
timer {
compatible = "arm,armv8-timer";
interrupt-parent = <>;
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v5 2/3] arm64: dts: mt8173: Add thermal zone node.

2015-12-16 Thread dawei chien
On Wed, 2015-12-16 at 19:22 +0800, Daniel Kurtz wrote:
> On Wed, Dec 16, 2015 at 6:09 PM, dawei chien  wrote:
> > On Wed, 2015-12-16 at 16:34 +0800, Daniel Kurtz wrote:
> >> On Wed, Dec 16, 2015 at 11:59 AM, Dawei Chien  
> >> wrote:
> >> >
> >> > This adds thermal zone node to Mediatek MT8173 dtsi file.
> >> >
> >> > Signed-off-by: Dawei Chien 
> >> > ---
> >> > This patch is base on patchset:
> >> > https://lkml.org/lkml/2015/11/30/239
> >> > ---
> >> >  arch/arm64/boot/dts/mediatek/mt8173.dtsi |   43 
> >> > ++
> >> >  1 file changed, 43 insertions(+)
> >> >
> >> > diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
> >> > b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
> >> > index fda805d..4114cee 100644
> >> > --- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
> >> > +++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
> >> > @@ -188,6 +188,49 @@
> >> > clock-output-names = "cpum_ck";
> >> > };
> >> >
> >> > +   thermal-zones {
> >> > +   cpu_thermal: cpu_thermal {
> >> > +   polling-delay-passive = <1000>; /* milliseconds 
> >> > */
> >> > +   polling-delay = <1000>; /* milliseconds */
> >> > +
> >> > +   thermal-sensors = < 0>;
> >>
> >> This should be <> with the MTK temp sensor node in
> >> https://lkml.org/lkml/2015/11/30/239 patch series.
> >>
> >> -Dan
> >
> > Hi Dan,
> > Sascha's thermal driver V12 only register sensor id as 0, so we need to
> > register sensor id as 0 to device tree as well.
> >
> > Either < 0> or <>, sensor id should be 0 for two cases.
> > I try this two case, function all work fine for two cases. May I have
> > any misunderstand? Please kindly give your comment.
> > I will re-send this patch again once you tell me the reason, thank you.
> 
> In the new patchset, Sascha changed it to:
> #thermal-sensor-cells = <0>;
> 
> Which means the <> phandle no longer has any arguments.
> 
> Thanks!
> -Dan
Hi Dan,
Thank you for your comment. Yes, I don't need to add sensor id since new
driver add thermal-sensor-cell as 0.
(Even I checked function OK to this patch with new patchset)

I will re-send this patch soon, thank you.

BR,
Dawei

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v5 2/3] arm64: dts: mt8173: Add thermal zone node.

2015-12-16 Thread dawei chien
On Wed, 2015-12-16 at 16:34 +0800, Daniel Kurtz wrote:
> On Wed, Dec 16, 2015 at 11:59 AM, Dawei Chien  
> wrote:
> >
> > This adds thermal zone node to Mediatek MT8173 dtsi file.
> >
> > Signed-off-by: Dawei Chien 
> > ---
> > This patch is base on patchset:
> > https://lkml.org/lkml/2015/11/30/239
> > ---
> >  arch/arm64/boot/dts/mediatek/mt8173.dtsi |   43 
> > ++
> >  1 file changed, 43 insertions(+)
> >
> > diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
> > b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
> > index fda805d..4114cee 100644
> > --- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
> > +++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
> > @@ -188,6 +188,49 @@
> > clock-output-names = "cpum_ck";
> > };
> >
> > +   thermal-zones {
> > +   cpu_thermal: cpu_thermal {
> > +   polling-delay-passive = <1000>; /* milliseconds */
> > +   polling-delay = <1000>; /* milliseconds */
> > +
> > +   thermal-sensors = < 0>;
> 
> This should be <> with the MTK temp sensor node in
> https://lkml.org/lkml/2015/11/30/239 patch series.
> 
> -Dan

Hi Dan,
Sascha's thermal driver V12 only register sensor id as 0, so we need to
register sensor id as 0 to device tree as well.

Either < 0> or <>, sensor id should be 0 for two cases.
I try this two case, function all work fine for two cases. May I have
any misunderstand? Please kindly give your comment.
I will re-send this patch again once you tell me the reason, thank you.

BR,
Dawei

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v6 3/3] arm64: dts: mt8173: Add dynamic power node.

2015-12-16 Thread Dawei Chien
This device node is for calculating dynamic power in mW.
Since mt8173 has two clusters, there are two dynamic power
coefficient as well.

Signed-off-by: Dawei Chien <dawei.ch...@mediatek.com>
---
This patch is base on patchset:
https://lkml.org/lkml/2015/11/17/251
---
 arch/arm64/boot/dts/mediatek/mt8173.dtsi |4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
index c962d94..b6f4ea5 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -71,6 +71,7 @@
#cooling-cells = <2>;
#cooling-min-level = <0>;
#cooling-max-level = <7>;
+   dynamic-power-coefficient = <263>;
};
 
cpu1: cpu@1 {
@@ -95,6 +96,7 @@
#cooling-cells = <2>;
#cooling-min-level = <0>;
#cooling-max-level = <7>;
+   dynamic-power-coefficient = <263>;
};
 
cpu2: cpu@100 {
@@ -119,6 +121,7 @@
#cooling-cells = <2>;
#cooling-min-level = <0>;
#cooling-max-level = <7>;
+   dynamic-power-coefficient = <530>;
};
 
cpu3: cpu@101 {
@@ -143,6 +146,7 @@
#cooling-cells = <2>;
#cooling-min-level = <0>;
#cooling-max-level = <7>;
+   dynamic-power-coefficient = <530>;
};
 
idle-states {
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v6 0/3] thermal: mediatek: Add cpu dynamic power cooling model.

2015-12-16 Thread Dawei Chien
Use Intelligent Power Allocation (IPA) technical to add dynamic power model
for binding CPU thermal zone. The power allocator governor allocates power
budget to control CPU temperature.

Power Allocator governor is able to keep SOC temperature within a defined
temperature range to avoid SOC overheat and keep it's performance.
mt8173-cpufreq.c need to register its' own power model with power allocator
thermal governor, so that power allocator governor can allocates suitable
power budget to control CPU temperature.

Binding document is refer to this patchset
https://lkml.org/lkml/2015/11/30/239

Change since V5:
1. Remove thermal sensor ID from phandles

Change since V4:
1. Remove unnecessary error-checking for mt8173-cpufreq.c
2. Initializing variable capacitance with 0

Change since V3:
1. Remove static power model
2. Split V3's device tree in two for thermal zones and dynamic power models 
respectively

Change since V2:
1. Move dynamic/static power model in device tree

Change since V1:
1. Include mt8171.h and sort header file for mt8173.dtsi

Dawei Chien (3):
  thermal: mediatek: Add cpu dynamic power cooling model.
  arm64: dts: mt8173: Add thermal zone node.
  arm64: dts: mt8173: Add dynamic power node.

 arch/arm64/boot/dts/mediatek/mt8173.dtsi |   47 ++
 drivers/cpufreq/mt8173-cpufreq.c |   12 ++--
 2 files changed, 57 insertions(+), 2 deletions(-)

--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v6 2/3] arm64: dts: mt8173: Add thermal zone node.

2015-12-16 Thread Dawei Chien
This adds thermal zone node to Mediatek MT8173 dtsi file.

Signed-off-by: Dawei Chien <dawei.ch...@mediatek.com>
---
This patch is base on patchset:
https://lkml.org/lkml/2015/11/30/239
---
 arch/arm64/boot/dts/mediatek/mt8173.dtsi |   43 ++
 1 file changed, 43 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
index fda805d..c962d94 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -188,6 +188,49 @@
clock-output-names = "cpum_ck";
};
 
+   thermal-zones {
+   cpu_thermal: cpu_thermal {
+   polling-delay-passive = <1000>; /* milliseconds */
+   polling-delay = <1000>; /* milliseconds */
+
+   thermal-sensors = <>;
+   sustainable-power = <1500>; /* milliwatts */
+
+   trips {
+   threshold: trip-point@0 {
+   temperature = <68000>;
+   hysteresis = <2000>;
+   type = "passive";
+   };
+
+   target: trip-point@1 {
+   temperature = <85000>;
+   hysteresis = <2000>;
+   type = "passive";
+   };
+
+   cpu_crit: cpu_crit@0 {
+   temperature = <115000>;
+   hysteresis = <2000>;
+   type = "critical";
+   };
+   };
+
+   cooling-maps {
+   map@0 {
+   trip = <>;
+   cooling-device = < 0 0>;
+   contribution = <1024>;
+   };
+   map@1 {
+   trip = <>;
+   cooling-device = < 0 0>;
+   contribution = <2048>;
+   };
+   };
+   };
+   };
+
timer {
compatible = "arm,armv8-timer";
interrupt-parent = <>;
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v6 1/3] thermal: mediatek: Add cpu dynamic power cooling model.

2015-12-16 Thread Dawei Chien
MT8173 cpufreq driver select of_cpufreq_power_cooling_register registering
cooling devices with dynamic power coefficient.

Signed-off-by: Dawei Chien <dawei.ch...@mediatek.com>
---
This patch is base on patchset:
https://lkml.org/lkml/2015/11/17/251
---
 drivers/cpufreq/mt8173-cpufreq.c |   11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/cpufreq/mt8173-cpufreq.c b/drivers/cpufreq/mt8173-cpufreq.c
index 83001dc..d00bab5 100644
--- a/drivers/cpufreq/mt8173-cpufreq.c
+++ b/drivers/cpufreq/mt8173-cpufreq.c
@@ -263,17 +263,24 @@ static int mtk_cpufreq_set_target(struct cpufreq_policy 
*policy,
return 0;
 }
 
+#define DYNAMIC_POWER "dynamic-power-coefficient"
+
 static void mtk_cpufreq_ready(struct cpufreq_policy *policy)
 {
struct mtk_cpu_dvfs_info *info = policy->driver_data;
struct device_node *np = of_node_get(info->cpu_dev->of_node);
+   u32 capacitance = 0;
 
if (WARN_ON(!np))
return;
 
if (of_find_property(np, "#cooling-cells", NULL)) {
-   info->cdev = of_cpufreq_cooling_register(np,
-policy->related_cpus);
+   of_property_read_u32(np, DYNAMIC_POWER, );
+
+   info->cdev = of_cpufreq_power_cooling_register(np,
+   policy->related_cpus,
+   capacitance,
+   NULL);
 
if (IS_ERR(info->cdev)) {
dev_err(info->cpu_dev,
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v5 2/3] arm64: dts: mt8173: Add thermal zone node.

2015-12-16 Thread dawei chien
On Wed, 2015-12-16 at 19:22 +0800, Daniel Kurtz wrote:
> On Wed, Dec 16, 2015 at 6:09 PM, dawei chien <dawei.ch...@mediatek.com> wrote:
> > On Wed, 2015-12-16 at 16:34 +0800, Daniel Kurtz wrote:
> >> On Wed, Dec 16, 2015 at 11:59 AM, Dawei Chien <dawei.ch...@mediatek.com> 
> >> wrote:
> >> >
> >> > This adds thermal zone node to Mediatek MT8173 dtsi file.
> >> >
> >> > Signed-off-by: Dawei Chien <dawei.ch...@mediatek.com>
> >> > ---
> >> > This patch is base on patchset:
> >> > https://lkml.org/lkml/2015/11/30/239
> >> > ---
> >> >  arch/arm64/boot/dts/mediatek/mt8173.dtsi |   43 
> >> > ++
> >> >  1 file changed, 43 insertions(+)
> >> >
> >> > diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
> >> > b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
> >> > index fda805d..4114cee 100644
> >> > --- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
> >> > +++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
> >> > @@ -188,6 +188,49 @@
> >> > clock-output-names = "cpum_ck";
> >> > };
> >> >
> >> > +   thermal-zones {
> >> > +   cpu_thermal: cpu_thermal {
> >> > +   polling-delay-passive = <1000>; /* milliseconds 
> >> > */
> >> > +   polling-delay = <1000>; /* milliseconds */
> >> > +
> >> > +   thermal-sensors = < 0>;
> >>
> >> This should be <> with the MTK temp sensor node in
> >> https://lkml.org/lkml/2015/11/30/239 patch series.
> >>
> >> -Dan
> >
> > Hi Dan,
> > Sascha's thermal driver V12 only register sensor id as 0, so we need to
> > register sensor id as 0 to device tree as well.
> >
> > Either < 0> or <>, sensor id should be 0 for two cases.
> > I try this two case, function all work fine for two cases. May I have
> > any misunderstand? Please kindly give your comment.
> > I will re-send this patch again once you tell me the reason, thank you.
> 
> In the new patchset, Sascha changed it to:
> #thermal-sensor-cells = <0>;
> 
> Which means the <> phandle no longer has any arguments.
> 
> Thanks!
> -Dan
Hi Dan,
Thank you for your comment. Yes, I don't need to add sensor id since new
driver add thermal-sensor-cell as 0.
(Even I checked function OK to this patch with new patchset)

I will re-send this patch soon, thank you.

BR,
Dawei

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v5 2/3] arm64: dts: mt8173: Add thermal zone node.

2015-12-16 Thread dawei chien
On Wed, 2015-12-16 at 16:34 +0800, Daniel Kurtz wrote:
> On Wed, Dec 16, 2015 at 11:59 AM, Dawei Chien <dawei.ch...@mediatek.com> 
> wrote:
> >
> > This adds thermal zone node to Mediatek MT8173 dtsi file.
> >
> > Signed-off-by: Dawei Chien <dawei.ch...@mediatek.com>
> > ---
> > This patch is base on patchset:
> > https://lkml.org/lkml/2015/11/30/239
> > ---
> >  arch/arm64/boot/dts/mediatek/mt8173.dtsi |   43 
> > ++
> >  1 file changed, 43 insertions(+)
> >
> > diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
> > b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
> > index fda805d..4114cee 100644
> > --- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
> > +++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
> > @@ -188,6 +188,49 @@
> > clock-output-names = "cpum_ck";
> > };
> >
> > +   thermal-zones {
> > +   cpu_thermal: cpu_thermal {
> > +   polling-delay-passive = <1000>; /* milliseconds */
> > +   polling-delay = <1000>; /* milliseconds */
> > +
> > +   thermal-sensors = < 0>;
> 
> This should be <> with the MTK temp sensor node in
> https://lkml.org/lkml/2015/11/30/239 patch series.
> 
> -Dan

Hi Dan,
Sascha's thermal driver V12 only register sensor id as 0, so we need to
register sensor id as 0 to device tree as well.

Either < 0> or <>, sensor id should be 0 for two cases.
I try this two case, function all work fine for two cases. May I have
any misunderstand? Please kindly give your comment.
I will re-send this patch again once you tell me the reason, thank you.

BR,
Dawei

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v5 1/3] thermal: mediatek: Add cpu dynamic power cooling model.

2015-12-15 Thread Dawei Chien
MT8173 cpufreq driver select of_cpufreq_power_cooling_register registering
cooling devices with dynamic power coefficient.

Signed-off-by: Dawei Chien 
---
This patch is base on patchset:
https://lkml.org/lkml/2015/11/17/251
---
 drivers/cpufreq/mt8173-cpufreq.c |   11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/cpufreq/mt8173-cpufreq.c b/drivers/cpufreq/mt8173-cpufreq.c
index 83001dc..d00bab5 100644
--- a/drivers/cpufreq/mt8173-cpufreq.c
+++ b/drivers/cpufreq/mt8173-cpufreq.c
@@ -263,17 +263,24 @@ static int mtk_cpufreq_set_target(struct cpufreq_policy 
*policy,
return 0;
 }
 
+#define DYNAMIC_POWER "dynamic-power-coefficient"
+
 static void mtk_cpufreq_ready(struct cpufreq_policy *policy)
 {
struct mtk_cpu_dvfs_info *info = policy->driver_data;
struct device_node *np = of_node_get(info->cpu_dev->of_node);
+   u32 capacitance = 0;
 
if (WARN_ON(!np))
return;
 
if (of_find_property(np, "#cooling-cells", NULL)) {
-   info->cdev = of_cpufreq_cooling_register(np,
-policy->related_cpus);
+   of_property_read_u32(np, DYNAMIC_POWER, );
+
+   info->cdev = of_cpufreq_power_cooling_register(np,
+   policy->related_cpus,
+   capacitance,
+   NULL);
 
if (IS_ERR(info->cdev)) {
dev_err(info->cpu_dev,
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v5 0/3] thermal: mediatek: Add cpu dynamic power cooling model.

2015-12-15 Thread Dawei Chien
Use Intelligent Power Allocation (IPA) technical to add dynamic power model
for binding CPU thermal zone. The power allocator governor allocates power
budget to control CPU temperature.

Power Allocator governor is able to keep SOC temperature within a defined
temperature range to avoid SOC overheat and keep it's performance.
mt8173-cpufreq.c need to register its' own power model with power allocator
thermal governor, so that power allocator governor can allocates suitable
power budget to control CPU temperature.

Binding document is refer to this patchset
https://lkml.org/lkml/2015/11/30/239

Change since V4:
1. Remove unnecessary error-checking for mt8173-cpufreq.c
2. Initializing variable capacitance with 0

Change since V3:
1. Remove static power model
2. Split V3's device tree in two for thermal zones and dynamic power models 
respectively

Change since V2:
1. Move dynamic/static power model in device tree

Change since V1:
1. Include mt8171.h and sort header file for mt8173.dtsi

Dawei Chien (3):
  thermal: mediatek: Add cpu dynamic power cooling model.
  arm64: dts: mt8173: Add thermal zone node.
  arm64: dts: mt8173: Add dynamic power node.

 arch/arm64/boot/dts/mediatek/mt8173.dtsi |   47 ++
 drivers/cpufreq/mt8173-cpufreq.c |   12 ++--
 2 files changed, 57 insertions(+), 2 deletions(-)

--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v5 3/3] arm64: dts: mt8173: Add dynamic power node.

2015-12-15 Thread Dawei Chien
This device node is for calculating dynamic power in mW.
Since mt8173 has two clusters, there are two dynamic power
coefficient as well.

Signed-off-by: Dawei Chien 
---
This patch is base on patchset:
https://lkml.org/lkml/2015/11/17/251
---
 arch/arm64/boot/dts/mediatek/mt8173.dtsi |4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
index 4114cee..33fabe4 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -71,6 +71,7 @@
#cooling-cells = <2>;
#cooling-min-level = <0>;
#cooling-max-level = <7>;
+   dynamic-power-coefficient = <263>;
};
 
cpu1: cpu@1 {
@@ -95,6 +96,7 @@
#cooling-cells = <2>;
#cooling-min-level = <0>;
#cooling-max-level = <7>;
+   dynamic-power-coefficient = <263>;
};
 
cpu2: cpu@100 {
@@ -119,6 +121,7 @@
#cooling-cells = <2>;
#cooling-min-level = <0>;
#cooling-max-level = <7>;
+   dynamic-power-coefficient = <530>;
};
 
cpu3: cpu@101 {
@@ -143,6 +146,7 @@
#cooling-cells = <2>;
#cooling-min-level = <0>;
#cooling-max-level = <7>;
+   dynamic-power-coefficient = <530>;
};
 
idle-states {
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v5 2/3] arm64: dts: mt8173: Add thermal zone node.

2015-12-15 Thread Dawei Chien
This adds thermal zone node to Mediatek MT8173 dtsi file.

Signed-off-by: Dawei Chien 
---
This patch is base on patchset:
https://lkml.org/lkml/2015/11/30/239
---
 arch/arm64/boot/dts/mediatek/mt8173.dtsi |   43 ++
 1 file changed, 43 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
index fda805d..4114cee 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -188,6 +188,49 @@
clock-output-names = "cpum_ck";
};
 
+   thermal-zones {
+   cpu_thermal: cpu_thermal {
+   polling-delay-passive = <1000>; /* milliseconds */
+   polling-delay = <1000>; /* milliseconds */
+
+   thermal-sensors = < 0>;
+   sustainable-power = <1500>; /* milliwatts */
+
+   trips {
+   threshold: trip-point@0 {
+   temperature = <68000>;
+   hysteresis = <2000>;
+   type = "passive";
+   };
+
+   target: trip-point@1 {
+   temperature = <85000>;
+   hysteresis = <2000>;
+   type = "passive";
+   };
+
+   cpu_crit: cpu_crit@0 {
+   temperature = <115000>;
+   hysteresis = <2000>;
+   type = "critical";
+   };
+   };
+
+   cooling-maps {
+   map@0 {
+   trip = <>;
+   cooling-device = < 0 0>;
+   contribution = <1024>;
+   };
+   map@1 {
+   trip = <>;
+   cooling-device = < 0 0>;
+   contribution = <2048>;
+   };
+   };
+   };
+   };
+
timer {
compatible = "arm,armv8-timer";
interrupt-parent = <>;
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v5 1/3] thermal: mediatek: Add cpu dynamic power cooling model.

2015-12-15 Thread Dawei Chien
MT8173 cpufreq driver select of_cpufreq_power_cooling_register registering
cooling devices with dynamic power coefficient.

Signed-off-by: Dawei Chien <dawei.ch...@mediatek.com>
---
This patch is base on patchset:
https://lkml.org/lkml/2015/11/17/251
---
 drivers/cpufreq/mt8173-cpufreq.c |   11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/cpufreq/mt8173-cpufreq.c b/drivers/cpufreq/mt8173-cpufreq.c
index 83001dc..d00bab5 100644
--- a/drivers/cpufreq/mt8173-cpufreq.c
+++ b/drivers/cpufreq/mt8173-cpufreq.c
@@ -263,17 +263,24 @@ static int mtk_cpufreq_set_target(struct cpufreq_policy 
*policy,
return 0;
 }
 
+#define DYNAMIC_POWER "dynamic-power-coefficient"
+
 static void mtk_cpufreq_ready(struct cpufreq_policy *policy)
 {
struct mtk_cpu_dvfs_info *info = policy->driver_data;
struct device_node *np = of_node_get(info->cpu_dev->of_node);
+   u32 capacitance = 0;
 
if (WARN_ON(!np))
return;
 
if (of_find_property(np, "#cooling-cells", NULL)) {
-   info->cdev = of_cpufreq_cooling_register(np,
-policy->related_cpus);
+   of_property_read_u32(np, DYNAMIC_POWER, );
+
+   info->cdev = of_cpufreq_power_cooling_register(np,
+   policy->related_cpus,
+   capacitance,
+   NULL);
 
if (IS_ERR(info->cdev)) {
dev_err(info->cpu_dev,
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v5 0/3] thermal: mediatek: Add cpu dynamic power cooling model.

2015-12-15 Thread Dawei Chien
Use Intelligent Power Allocation (IPA) technical to add dynamic power model
for binding CPU thermal zone. The power allocator governor allocates power
budget to control CPU temperature.

Power Allocator governor is able to keep SOC temperature within a defined
temperature range to avoid SOC overheat and keep it's performance.
mt8173-cpufreq.c need to register its' own power model with power allocator
thermal governor, so that power allocator governor can allocates suitable
power budget to control CPU temperature.

Binding document is refer to this patchset
https://lkml.org/lkml/2015/11/30/239

Change since V4:
1. Remove unnecessary error-checking for mt8173-cpufreq.c
2. Initializing variable capacitance with 0

Change since V3:
1. Remove static power model
2. Split V3's device tree in two for thermal zones and dynamic power models 
respectively

Change since V2:
1. Move dynamic/static power model in device tree

Change since V1:
1. Include mt8171.h and sort header file for mt8173.dtsi

Dawei Chien (3):
  thermal: mediatek: Add cpu dynamic power cooling model.
  arm64: dts: mt8173: Add thermal zone node.
  arm64: dts: mt8173: Add dynamic power node.

 arch/arm64/boot/dts/mediatek/mt8173.dtsi |   47 ++
 drivers/cpufreq/mt8173-cpufreq.c |   12 ++--
 2 files changed, 57 insertions(+), 2 deletions(-)

--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v5 3/3] arm64: dts: mt8173: Add dynamic power node.

2015-12-15 Thread Dawei Chien
This device node is for calculating dynamic power in mW.
Since mt8173 has two clusters, there are two dynamic power
coefficient as well.

Signed-off-by: Dawei Chien <dawei.ch...@mediatek.com>
---
This patch is base on patchset:
https://lkml.org/lkml/2015/11/17/251
---
 arch/arm64/boot/dts/mediatek/mt8173.dtsi |4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
index 4114cee..33fabe4 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -71,6 +71,7 @@
#cooling-cells = <2>;
#cooling-min-level = <0>;
#cooling-max-level = <7>;
+   dynamic-power-coefficient = <263>;
};
 
cpu1: cpu@1 {
@@ -95,6 +96,7 @@
#cooling-cells = <2>;
#cooling-min-level = <0>;
#cooling-max-level = <7>;
+   dynamic-power-coefficient = <263>;
};
 
cpu2: cpu@100 {
@@ -119,6 +121,7 @@
#cooling-cells = <2>;
#cooling-min-level = <0>;
#cooling-max-level = <7>;
+   dynamic-power-coefficient = <530>;
};
 
cpu3: cpu@101 {
@@ -143,6 +146,7 @@
#cooling-cells = <2>;
#cooling-min-level = <0>;
#cooling-max-level = <7>;
+   dynamic-power-coefficient = <530>;
};
 
idle-states {
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v5 2/3] arm64: dts: mt8173: Add thermal zone node.

2015-12-15 Thread Dawei Chien
This adds thermal zone node to Mediatek MT8173 dtsi file.

Signed-off-by: Dawei Chien <dawei.ch...@mediatek.com>
---
This patch is base on patchset:
https://lkml.org/lkml/2015/11/30/239
---
 arch/arm64/boot/dts/mediatek/mt8173.dtsi |   43 ++
 1 file changed, 43 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
index fda805d..4114cee 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -188,6 +188,49 @@
clock-output-names = "cpum_ck";
};
 
+   thermal-zones {
+   cpu_thermal: cpu_thermal {
+   polling-delay-passive = <1000>; /* milliseconds */
+   polling-delay = <1000>; /* milliseconds */
+
+   thermal-sensors = < 0>;
+   sustainable-power = <1500>; /* milliwatts */
+
+   trips {
+   threshold: trip-point@0 {
+   temperature = <68000>;
+   hysteresis = <2000>;
+   type = "passive";
+   };
+
+   target: trip-point@1 {
+   temperature = <85000>;
+   hysteresis = <2000>;
+   type = "passive";
+   };
+
+   cpu_crit: cpu_crit@0 {
+   temperature = <115000>;
+   hysteresis = <2000>;
+   type = "critical";
+   };
+   };
+
+   cooling-maps {
+   map@0 {
+   trip = <>;
+   cooling-device = < 0 0>;
+   contribution = <1024>;
+   };
+   map@1 {
+   trip = <>;
+   cooling-device = < 0 0>;
+   contribution = <2048>;
+   };
+   };
+   };
+   };
+
timer {
compatible = "arm,armv8-timer";
interrupt-parent = <>;
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v4 3/3] thermal: mediatek: Add cpu dynamic power cooling model.

2015-11-30 Thread dawei chien
On Mon, 2015-11-30 at 16:04 +0530, Viresh Kumar wrote:
> On 30-11-15, 18:21, dawei chien wrote:
> > As far as I know, user or shell script has the right for using command 
> > online/offline cpu.
> 
> Right.
> 
> > Either user by console or shell script could make cpu2 online even cpu2 
> > already onlined.
> 
> Hey, no. You can't online that is already online. You can write '1' to
> the file /sys/devices/system/cpu/cpuX/online, but it wouldn't have any
> affect.
> 
> > That could cause of_cpufreq_cooling_register execute many times for the
> > same cooling device.
> 
> No.
You are right. certainly no, it's my misunderstand.

> > "echo 1 > /sys/devices/system/cpu/cpu2/online"
> > 
> > With above hotplug command, mtk_cpufreq_ready will register cooling
> > device again as well, but fail since the cooling device already created,
> > so we might need not register cooling device again on this case.
> 
> Have you tested this yourself ?

Truly sorry for misunderstanding, so we don't need to add error checking
code there.

(It seems whole of cluster offline, the cooling device unregister as
well. If just one cpu online, cooling device register as well)

Three months ago, Once I used following command, cooling device can't
create any more. err message will show once I echo online command.
However, this bug already fixed in mainline by you. 

echo 0 > /sys/devices/system/cpu/cpu2/online
echo 0 > /sys/devices/system/cpu/cpu3/online
echo 1 > /sys/devices/system/cpu/cpu2/online

commit 528464eaa46ae1bd319882e4dd3495802e55b8c4
Author: Viresh Kumar 
Date:   Thu Jul 23 14:32:32 2015 +0530

thermal: remove dangling 'weight_attr' device file

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v4 3/3] thermal: mediatek: Add cpu dynamic power cooling model.

2015-11-30 Thread dawei chien
On Mon, 2015-11-30 at 15:00 +0530, Viresh Kumar wrote:
> On 30-11-15, 17:26, dawei chien wrote:
> > On Mon, 2015-11-30 at 11:08 +0530, Viresh Kumar wrote:
> > > On 27-11-15, 17:32, Dawei Chien wrote:
> > > > MT8173 cpufreq driver use of_cpufreq_power_cooling_register registering
> > > > cooling devices with dynamic power coefficient.
> > > > 
> > > > Signed-off-by: Dawei Chien 
> > > > ---
> > > > This patch is base on patchset:
> > > > https://lkml.org/lkml/2015/11/17/251
> > > > ---
> > > >  drivers/cpufreq/mt8173-cpufreq.c |   28 
> > > >  1 file changed, 20 insertions(+), 8 deletions(-)
> > > > 
> > > > diff --git a/drivers/cpufreq/mt8173-cpufreq.c 
> > > > b/drivers/cpufreq/mt8173-cpufreq.c
> > > > index 83001dc..4d39468 100644
> > > > --- a/drivers/cpufreq/mt8173-cpufreq.c
> > > > +++ b/drivers/cpufreq/mt8173-cpufreq.c
> > > > @@ -263,24 +263,34 @@ static int mtk_cpufreq_set_target(struct 
> > > > cpufreq_policy *policy,
> > > > return 0;
> > > >  }
> > > >  
> > > > +#define DYNAMIC_POWER "dynamic-power-coefficient"
> > > > +
> > > >  static void mtk_cpufreq_ready(struct cpufreq_policy *policy)
> > > >  {
> > > > struct mtk_cpu_dvfs_info *info = policy->driver_data;
> > > > struct device_node *np = of_node_get(info->cpu_dev->of_node);
> > > > +   u32 capacitance;
> > > >  
> > > > if (WARN_ON(!np))
> > > > return;
> > > >  
> > > > if (of_find_property(np, "#cooling-cells", NULL)) {
> > > > -   info->cdev = of_cpufreq_cooling_register(np,
> > > > -
> > > > policy->related_cpus);
> > > > +   if (!info->cdev) {
> > > 
> > > Why will info->cdev be non-NULL here ?
> > 
> > This is a error-checking to avoid user or any script by command line 
> > hotplug CPU
> > more than two times, we don't need to register cooling device on this case.
> 
> Why?
As far as I know, user or shell script has the right for using command 
online/offline cpu.
Either user by console or shell script could make cpu2 online even cpu2 already 
onlined.
That could cause of_cpufreq_cooling_register execute many times for the
same cooling device.

"echo 1 > /sys/devices/system/cpu/cpu2/online"

With above hotplug command, mtk_cpufreq_ready will register cooling
device again as well, but fail since the cooling device already created,
so we might need not register cooling device again on this case.

> > I will remove it if you don't agree it.
> 
> No, my agreeing or not doesn't matter. If what you are doing is useful
> (and I am not able to understand it), then you should make me
> understand that and don't change your code.
> 
> But, I really do not get the reasoning behind the logic. Please
> elaborate that step by step.

Please refer to above explaining, thank you.

> > > > @@ -460,7 +470,9 @@ static int mtk_cpufreq_exit(struct cpufreq_policy 
> > > > *policy)
> > > >  {
> > > > struct mtk_cpu_dvfs_info *info = policy->driver_data;
> > > >  
> > > > -   cpufreq_cooling_unregister(info->cdev);
> > > > +   if (info->cdev)
> > > > +   cpufreq_cooling_unregister(info->cdev);
> > > > +
> > > 
> > > Why do you need to update this?
> > 
> > This is a error-checking to avoid user or any script by command line
> > unplug CPU more than two times, we don't need to unregister cooling
> > device on this case.
> > 
> > I will remove it if you don't agree it.
> 
> Same here.
Please refer to the same reason as above. thank you.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v4 3/3] thermal: mediatek: Add cpu dynamic power cooling model.

2015-11-30 Thread dawei chien
On Mon, 2015-11-30 at 11:08 +0530, Viresh Kumar wrote:
> On 27-11-15, 17:32, Dawei Chien wrote:
> > MT8173 cpufreq driver use of_cpufreq_power_cooling_register registering
> > cooling devices with dynamic power coefficient.
> > 
> > Signed-off-by: Dawei Chien 
> > ---
> > This patch is base on patchset:
> > https://lkml.org/lkml/2015/11/17/251
> > ---
> >  drivers/cpufreq/mt8173-cpufreq.c |   28 
> >  1 file changed, 20 insertions(+), 8 deletions(-)
> > 
> > diff --git a/drivers/cpufreq/mt8173-cpufreq.c 
> > b/drivers/cpufreq/mt8173-cpufreq.c
> > index 83001dc..4d39468 100644
> > --- a/drivers/cpufreq/mt8173-cpufreq.c
> > +++ b/drivers/cpufreq/mt8173-cpufreq.c
> > @@ -263,24 +263,34 @@ static int mtk_cpufreq_set_target(struct 
> > cpufreq_policy *policy,
> > return 0;
> >  }
> >  
> > +#define DYNAMIC_POWER "dynamic-power-coefficient"
> > +
> >  static void mtk_cpufreq_ready(struct cpufreq_policy *policy)
> >  {
> > struct mtk_cpu_dvfs_info *info = policy->driver_data;
> > struct device_node *np = of_node_get(info->cpu_dev->of_node);
> > +   u32 capacitance;
> >  
> > if (WARN_ON(!np))
> > return;
> >  
> > if (of_find_property(np, "#cooling-cells", NULL)) {
> > -   info->cdev = of_cpufreq_cooling_register(np,
> > -policy->related_cpus);
> > +   if (!info->cdev) {
> 
> Why will info->cdev be non-NULL here ?

This is a error-checking to avoid user or any script by command line hotplug CPU
more than two times, we don't need to register cooling device on this case.

I will remove it if you don't agree it.

> > +   of_property_read_u32(np, DYNAMIC_POWER, );
> 
> This can fail, in which case capacitance will be used uninitialized.
> Fix that by initializing it with 0 at the beginning of this routine.

Thank you, I will follow your comment to fix it on next version.

> > +   info->cdev = of_cpufreq_power_cooling_register(np,
> > +   policy->related_cpus,
> > +   capacitance,
> > +   NULL);
> >  
> > -   if (IS_ERR(info->cdev)) {
> > -   dev_err(info->cpu_dev,
> > -   "running cpufreq without cooling device: %ld\n",
> > -   PTR_ERR(info->cdev));
> > +   if (IS_ERR(info->cdev)) {
> > +   dev_err(info->cpu_dev,
> > +   "running cpufreq without cooling 
> > device: %ld\n",
> > +   PTR_ERR(info->cdev));
> >  
> > -   info->cdev = NULL;
> > +   info->cdev = NULL;
> > +   }
> > }
> > }
> >  
> > @@ -460,7 +470,9 @@ static int mtk_cpufreq_exit(struct cpufreq_policy 
> > *policy)
> >  {
> > struct mtk_cpu_dvfs_info *info = policy->driver_data;
> >  
> > -   cpufreq_cooling_unregister(info->cdev);
> > +   if (info->cdev)
> > +   cpufreq_cooling_unregister(info->cdev);
> > +
> 
> Why do you need to update this?

This is a error-checking to avoid user or any script by command line
unplug CPU more than two times, we don't need to unregister cooling
device on this case.

I will remove it if you don't agree it.

> > dev_pm_opp_free_cpufreq_table(info->cpu_dev, >freq_table);
> > mtk_cpu_dvfs_info_release(info);
> > kfree(info);
> > -- 
> > 1.7.9.5
> 


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v4 3/3] thermal: mediatek: Add cpu dynamic power cooling model.

2015-11-30 Thread dawei chien
On Mon, 2015-11-30 at 11:08 +0530, Viresh Kumar wrote:
> On 27-11-15, 17:32, Dawei Chien wrote:
> > MT8173 cpufreq driver use of_cpufreq_power_cooling_register registering
> > cooling devices with dynamic power coefficient.
> > 
> > Signed-off-by: Dawei Chien <dawei.ch...@mediatek.com>
> > ---
> > This patch is base on patchset:
> > https://lkml.org/lkml/2015/11/17/251
> > ---
> >  drivers/cpufreq/mt8173-cpufreq.c |   28 
> >  1 file changed, 20 insertions(+), 8 deletions(-)
> > 
> > diff --git a/drivers/cpufreq/mt8173-cpufreq.c 
> > b/drivers/cpufreq/mt8173-cpufreq.c
> > index 83001dc..4d39468 100644
> > --- a/drivers/cpufreq/mt8173-cpufreq.c
> > +++ b/drivers/cpufreq/mt8173-cpufreq.c
> > @@ -263,24 +263,34 @@ static int mtk_cpufreq_set_target(struct 
> > cpufreq_policy *policy,
> > return 0;
> >  }
> >  
> > +#define DYNAMIC_POWER "dynamic-power-coefficient"
> > +
> >  static void mtk_cpufreq_ready(struct cpufreq_policy *policy)
> >  {
> > struct mtk_cpu_dvfs_info *info = policy->driver_data;
> > struct device_node *np = of_node_get(info->cpu_dev->of_node);
> > +   u32 capacitance;
> >  
> > if (WARN_ON(!np))
> > return;
> >  
> > if (of_find_property(np, "#cooling-cells", NULL)) {
> > -   info->cdev = of_cpufreq_cooling_register(np,
> > -policy->related_cpus);
> > +   if (!info->cdev) {
> 
> Why will info->cdev be non-NULL here ?

This is a error-checking to avoid user or any script by command line hotplug CPU
more than two times, we don't need to register cooling device on this case.

I will remove it if you don't agree it.

> > +   of_property_read_u32(np, DYNAMIC_POWER, );
> 
> This can fail, in which case capacitance will be used uninitialized.
> Fix that by initializing it with 0 at the beginning of this routine.

Thank you, I will follow your comment to fix it on next version.

> > +   info->cdev = of_cpufreq_power_cooling_register(np,
> > +   policy->related_cpus,
> > +   capacitance,
> > +   NULL);
> >  
> > -   if (IS_ERR(info->cdev)) {
> > -   dev_err(info->cpu_dev,
> > -   "running cpufreq without cooling device: %ld\n",
> > -   PTR_ERR(info->cdev));
> > +   if (IS_ERR(info->cdev)) {
> > +   dev_err(info->cpu_dev,
> > +   "running cpufreq without cooling 
> > device: %ld\n",
> > +   PTR_ERR(info->cdev));
> >  
> > -   info->cdev = NULL;
> > +   info->cdev = NULL;
> > +   }
> > }
> > }
> >  
> > @@ -460,7 +470,9 @@ static int mtk_cpufreq_exit(struct cpufreq_policy 
> > *policy)
> >  {
> > struct mtk_cpu_dvfs_info *info = policy->driver_data;
> >  
> > -   cpufreq_cooling_unregister(info->cdev);
> > +   if (info->cdev)
> > +   cpufreq_cooling_unregister(info->cdev);
> > +
> 
> Why do you need to update this?

This is a error-checking to avoid user or any script by command line
unplug CPU more than two times, we don't need to unregister cooling
device on this case.

I will remove it if you don't agree it.

> > dev_pm_opp_free_cpufreq_table(info->cpu_dev, >freq_table);
> > mtk_cpu_dvfs_info_release(info);
> > kfree(info);
> > -- 
> > 1.7.9.5
> 


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v4 3/3] thermal: mediatek: Add cpu dynamic power cooling model.

2015-11-30 Thread dawei chien
On Mon, 2015-11-30 at 15:00 +0530, Viresh Kumar wrote:
> On 30-11-15, 17:26, dawei chien wrote:
> > On Mon, 2015-11-30 at 11:08 +0530, Viresh Kumar wrote:
> > > On 27-11-15, 17:32, Dawei Chien wrote:
> > > > MT8173 cpufreq driver use of_cpufreq_power_cooling_register registering
> > > > cooling devices with dynamic power coefficient.
> > > > 
> > > > Signed-off-by: Dawei Chien <dawei.ch...@mediatek.com>
> > > > ---
> > > > This patch is base on patchset:
> > > > https://lkml.org/lkml/2015/11/17/251
> > > > ---
> > > >  drivers/cpufreq/mt8173-cpufreq.c |   28 
> > > >  1 file changed, 20 insertions(+), 8 deletions(-)
> > > > 
> > > > diff --git a/drivers/cpufreq/mt8173-cpufreq.c 
> > > > b/drivers/cpufreq/mt8173-cpufreq.c
> > > > index 83001dc..4d39468 100644
> > > > --- a/drivers/cpufreq/mt8173-cpufreq.c
> > > > +++ b/drivers/cpufreq/mt8173-cpufreq.c
> > > > @@ -263,24 +263,34 @@ static int mtk_cpufreq_set_target(struct 
> > > > cpufreq_policy *policy,
> > > > return 0;
> > > >  }
> > > >  
> > > > +#define DYNAMIC_POWER "dynamic-power-coefficient"
> > > > +
> > > >  static void mtk_cpufreq_ready(struct cpufreq_policy *policy)
> > > >  {
> > > > struct mtk_cpu_dvfs_info *info = policy->driver_data;
> > > > struct device_node *np = of_node_get(info->cpu_dev->of_node);
> > > > +   u32 capacitance;
> > > >  
> > > > if (WARN_ON(!np))
> > > > return;
> > > >  
> > > > if (of_find_property(np, "#cooling-cells", NULL)) {
> > > > -   info->cdev = of_cpufreq_cooling_register(np,
> > > > -
> > > > policy->related_cpus);
> > > > +   if (!info->cdev) {
> > > 
> > > Why will info->cdev be non-NULL here ?
> > 
> > This is a error-checking to avoid user or any script by command line 
> > hotplug CPU
> > more than two times, we don't need to register cooling device on this case.
> 
> Why?
As far as I know, user or shell script has the right for using command 
online/offline cpu.
Either user by console or shell script could make cpu2 online even cpu2 already 
onlined.
That could cause of_cpufreq_cooling_register execute many times for the
same cooling device.

"echo 1 > /sys/devices/system/cpu/cpu2/online"

With above hotplug command, mtk_cpufreq_ready will register cooling
device again as well, but fail since the cooling device already created,
so we might need not register cooling device again on this case.

> > I will remove it if you don't agree it.
> 
> No, my agreeing or not doesn't matter. If what you are doing is useful
> (and I am not able to understand it), then you should make me
> understand that and don't change your code.
> 
> But, I really do not get the reasoning behind the logic. Please
> elaborate that step by step.

Please refer to above explaining, thank you.

> > > > @@ -460,7 +470,9 @@ static int mtk_cpufreq_exit(struct cpufreq_policy 
> > > > *policy)
> > > >  {
> > > > struct mtk_cpu_dvfs_info *info = policy->driver_data;
> > > >  
> > > > -   cpufreq_cooling_unregister(info->cdev);
> > > > +   if (info->cdev)
> > > > +   cpufreq_cooling_unregister(info->cdev);
> > > > +
> > > 
> > > Why do you need to update this?
> > 
> > This is a error-checking to avoid user or any script by command line
> > unplug CPU more than two times, we don't need to unregister cooling
> > device on this case.
> > 
> > I will remove it if you don't agree it.
> 
> Same here.
Please refer to the same reason as above. thank you.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v4 3/3] thermal: mediatek: Add cpu dynamic power cooling model.

2015-11-30 Thread dawei chien
On Mon, 2015-11-30 at 16:04 +0530, Viresh Kumar wrote:
> On 30-11-15, 18:21, dawei chien wrote:
> > As far as I know, user or shell script has the right for using command 
> > online/offline cpu.
> 
> Right.
> 
> > Either user by console or shell script could make cpu2 online even cpu2 
> > already onlined.
> 
> Hey, no. You can't online that is already online. You can write '1' to
> the file /sys/devices/system/cpu/cpuX/online, but it wouldn't have any
> affect.
> 
> > That could cause of_cpufreq_cooling_register execute many times for the
> > same cooling device.
> 
> No.
You are right. certainly no, it's my misunderstand.

> > "echo 1 > /sys/devices/system/cpu/cpu2/online"
> > 
> > With above hotplug command, mtk_cpufreq_ready will register cooling
> > device again as well, but fail since the cooling device already created,
> > so we might need not register cooling device again on this case.
> 
> Have you tested this yourself ?

Truly sorry for misunderstanding, so we don't need to add error checking
code there.

(It seems whole of cluster offline, the cooling device unregister as
well. If just one cpu online, cooling device register as well)

Three months ago, Once I used following command, cooling device can't
create any more. err message will show once I echo online command.
However, this bug already fixed in mainline by you. 

echo 0 > /sys/devices/system/cpu/cpu2/online
echo 0 > /sys/devices/system/cpu/cpu3/online
echo 1 > /sys/devices/system/cpu/cpu2/online

commit 528464eaa46ae1bd319882e4dd3495802e55b8c4
Author: Viresh Kumar <viresh.ku...@linaro.org>
Date:   Thu Jul 23 14:32:32 2015 +0530

thermal: remove dangling 'weight_attr' device file

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 1/3] arm64: dts: mt8173: Add thermal zone node.

2015-11-27 Thread Dawei Chien
This adds thermal zone node to Mediatek MT8173 dtsi file.

Signed-off-by: Dawei Chien 
---
This patch is based on patchset:
https://lkml.org/lkml/2015/11/18/84
---
 arch/arm64/boot/dts/mediatek/mt8173.dtsi |   43 ++
 1 file changed, 43 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
index fda805d..4114cee 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -188,6 +188,49 @@
clock-output-names = "cpum_ck";
};
 
+   thermal-zones {
+   cpu_thermal: cpu_thermal {
+   polling-delay-passive = <1000>; /* milliseconds */
+   polling-delay = <1000>; /* milliseconds */
+
+   thermal-sensors = < 0>;
+   sustainable-power = <1500>; /* milliwatts */
+
+   trips {
+   threshold: trip-point@0 {
+   temperature = <68000>;
+   hysteresis = <2000>;
+   type = "passive";
+   };
+
+   target: trip-point@1 {
+   temperature = <85000>;
+   hysteresis = <2000>;
+   type = "passive";
+   };
+
+   cpu_crit: cpu_crit@0 {
+   temperature = <115000>;
+   hysteresis = <2000>;
+   type = "critical";
+   };
+   };
+
+   cooling-maps {
+   map@0 {
+   trip = <>;
+   cooling-device = < 0 0>;
+   contribution = <1024>;
+   };
+   map@1 {
+   trip = <>;
+   cooling-device = < 0 0>;
+   contribution = <2048>;
+   };
+   };
+   };
+   };
+
timer {
compatible = "arm,armv8-timer";
interrupt-parent = <>;
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 3/3] thermal: mediatek: Add cpu dynamic power cooling model.

2015-11-27 Thread Dawei Chien
MT8173 cpufreq driver use of_cpufreq_power_cooling_register registering
cooling devices with dynamic power coefficient.

Signed-off-by: Dawei Chien 
---
This patch is base on patchset:
https://lkml.org/lkml/2015/11/17/251
---
 drivers/cpufreq/mt8173-cpufreq.c |   28 
 1 file changed, 20 insertions(+), 8 deletions(-)

diff --git a/drivers/cpufreq/mt8173-cpufreq.c b/drivers/cpufreq/mt8173-cpufreq.c
index 83001dc..4d39468 100644
--- a/drivers/cpufreq/mt8173-cpufreq.c
+++ b/drivers/cpufreq/mt8173-cpufreq.c
@@ -263,24 +263,34 @@ static int mtk_cpufreq_set_target(struct cpufreq_policy 
*policy,
return 0;
 }
 
+#define DYNAMIC_POWER "dynamic-power-coefficient"
+
 static void mtk_cpufreq_ready(struct cpufreq_policy *policy)
 {
struct mtk_cpu_dvfs_info *info = policy->driver_data;
struct device_node *np = of_node_get(info->cpu_dev->of_node);
+   u32 capacitance;
 
if (WARN_ON(!np))
return;
 
if (of_find_property(np, "#cooling-cells", NULL)) {
-   info->cdev = of_cpufreq_cooling_register(np,
-policy->related_cpus);
+   if (!info->cdev) {
+   of_property_read_u32(np, DYNAMIC_POWER, );
+
+   info->cdev = of_cpufreq_power_cooling_register(np,
+   policy->related_cpus,
+   capacitance,
+   NULL);
 
-   if (IS_ERR(info->cdev)) {
-   dev_err(info->cpu_dev,
-   "running cpufreq without cooling device: %ld\n",
-   PTR_ERR(info->cdev));
+   if (IS_ERR(info->cdev)) {
+   dev_err(info->cpu_dev,
+   "running cpufreq without cooling 
device: %ld\n",
+   PTR_ERR(info->cdev));
 
-   info->cdev = NULL;
+   info->cdev = NULL;
+   }
}
}
 
@@ -460,7 +470,9 @@ static int mtk_cpufreq_exit(struct cpufreq_policy *policy)
 {
struct mtk_cpu_dvfs_info *info = policy->driver_data;
 
-   cpufreq_cooling_unregister(info->cdev);
+   if (info->cdev)
+   cpufreq_cooling_unregister(info->cdev);
+
dev_pm_opp_free_cpufreq_table(info->cpu_dev, >freq_table);
mtk_cpu_dvfs_info_release(info);
kfree(info);
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 0/3] thermal: mediatek: Add cpu power cooling model

2015-11-27 Thread Dawei Chien
Use Intelligent Power Allocation (IPA) technical to add dynamic power model
for binding CPU thermal zone. The power allocator governor allocates power
budget to control CPU temperature.

Power Allocator governor is able to keep SOC temperature within a defined
temperature range to avoid SOC overheat and keep it's performance.
mt8173-cpufreq.c need to register its' own power model with power allocator
thermal governor, so that power allocator governor can allocates suitable
power budget to control CPU temperature.

Binging document is refer to this patchset
https://lkml.org/lkml/2015/11/17/251

Change since V1:
1. Include mt8171.h and sort header file for mt8173.dtsi

Change since V2:
1. Move dynamic/static power model in device tree

Change since V3:
1. Remove static power model.
2. Split V3's device tree in two for thermal zones and dynamic power models 
respectively.

Dawei Chien (3):
  arm64: dts: mt8173: Add thermal zone node for mt8173 platform.
  arm64: dts: mt8173: Add dynamic power node for mt8173 platform.
  thermal: mediatek: Add cpu dynamic power cooling model.

 arch/arm64/boot/dts/mediatek/mt8173.dtsi |   47 ++
 drivers/cpufreq/mt8173-cpufreq.c |   28 +-
 2 files changed, 67 insertions(+), 8 deletions(-)

--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 2/3] arm64: dts: mt8173: Add dynamic power node.

2015-11-27 Thread Dawei Chien
This device node is for calculating dynamic power in mW.
Since mt8173 has two clusters, there are two dynamic power
coefficient as well.

Signed-off-by: Dawei Chien 
---
This patch is base on patchset:
https://lkml.org/lkml/2015/11/17/251
---
 arch/arm64/boot/dts/mediatek/mt8173.dtsi |4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
index 4114cee..33fabe4 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -71,6 +71,7 @@
#cooling-cells = <2>;
#cooling-min-level = <0>;
#cooling-max-level = <7>;
+   dynamic-power-coefficient = <263>;
};
 
cpu1: cpu@1 {
@@ -95,6 +96,7 @@
#cooling-cells = <2>;
#cooling-min-level = <0>;
#cooling-max-level = <7>;
+   dynamic-power-coefficient = <263>;
};
 
cpu2: cpu@100 {
@@ -119,6 +121,7 @@
#cooling-cells = <2>;
#cooling-min-level = <0>;
#cooling-max-level = <7>;
+   dynamic-power-coefficient = <530>;
};
 
cpu3: cpu@101 {
@@ -143,6 +146,7 @@
#cooling-cells = <2>;
#cooling-min-level = <0>;
#cooling-max-level = <7>;
+   dynamic-power-coefficient = <530>;
};
 
idle-states {
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 1/3] arm64: dts: mt8173: Add thermal zone node.

2015-11-27 Thread Dawei Chien
This adds thermal zone node to Mediatek MT8173 dtsi file.

Signed-off-by: Dawei Chien <dawei.ch...@mediatek.com>
---
This patch is based on patchset:
https://lkml.org/lkml/2015/11/18/84
---
 arch/arm64/boot/dts/mediatek/mt8173.dtsi |   43 ++
 1 file changed, 43 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
index fda805d..4114cee 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -188,6 +188,49 @@
clock-output-names = "cpum_ck";
};
 
+   thermal-zones {
+   cpu_thermal: cpu_thermal {
+   polling-delay-passive = <1000>; /* milliseconds */
+   polling-delay = <1000>; /* milliseconds */
+
+   thermal-sensors = < 0>;
+   sustainable-power = <1500>; /* milliwatts */
+
+   trips {
+   threshold: trip-point@0 {
+   temperature = <68000>;
+   hysteresis = <2000>;
+   type = "passive";
+   };
+
+   target: trip-point@1 {
+   temperature = <85000>;
+   hysteresis = <2000>;
+   type = "passive";
+   };
+
+   cpu_crit: cpu_crit@0 {
+   temperature = <115000>;
+   hysteresis = <2000>;
+   type = "critical";
+   };
+   };
+
+   cooling-maps {
+   map@0 {
+   trip = <>;
+   cooling-device = < 0 0>;
+   contribution = <1024>;
+   };
+   map@1 {
+   trip = <>;
+   cooling-device = < 0 0>;
+   contribution = <2048>;
+   };
+   };
+   };
+   };
+
timer {
compatible = "arm,armv8-timer";
interrupt-parent = <>;
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 2/3] arm64: dts: mt8173: Add dynamic power node.

2015-11-27 Thread Dawei Chien
This device node is for calculating dynamic power in mW.
Since mt8173 has two clusters, there are two dynamic power
coefficient as well.

Signed-off-by: Dawei Chien <dawei.ch...@mediatek.com>
---
This patch is base on patchset:
https://lkml.org/lkml/2015/11/17/251
---
 arch/arm64/boot/dts/mediatek/mt8173.dtsi |4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi 
b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
index 4114cee..33fabe4 100644
--- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
@@ -71,6 +71,7 @@
#cooling-cells = <2>;
#cooling-min-level = <0>;
#cooling-max-level = <7>;
+   dynamic-power-coefficient = <263>;
};
 
cpu1: cpu@1 {
@@ -95,6 +96,7 @@
#cooling-cells = <2>;
#cooling-min-level = <0>;
#cooling-max-level = <7>;
+   dynamic-power-coefficient = <263>;
};
 
cpu2: cpu@100 {
@@ -119,6 +121,7 @@
#cooling-cells = <2>;
#cooling-min-level = <0>;
#cooling-max-level = <7>;
+   dynamic-power-coefficient = <530>;
};
 
cpu3: cpu@101 {
@@ -143,6 +146,7 @@
#cooling-cells = <2>;
#cooling-min-level = <0>;
#cooling-max-level = <7>;
+   dynamic-power-coefficient = <530>;
};
 
idle-states {
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 0/3] thermal: mediatek: Add cpu power cooling model

2015-11-27 Thread Dawei Chien
Use Intelligent Power Allocation (IPA) technical to add dynamic power model
for binding CPU thermal zone. The power allocator governor allocates power
budget to control CPU temperature.

Power Allocator governor is able to keep SOC temperature within a defined
temperature range to avoid SOC overheat and keep it's performance.
mt8173-cpufreq.c need to register its' own power model with power allocator
thermal governor, so that power allocator governor can allocates suitable
power budget to control CPU temperature.

Binging document is refer to this patchset
https://lkml.org/lkml/2015/11/17/251

Change since V1:
1. Include mt8171.h and sort header file for mt8173.dtsi

Change since V2:
1. Move dynamic/static power model in device tree

Change since V3:
1. Remove static power model.
2. Split V3's device tree in two for thermal zones and dynamic power models 
respectively.

Dawei Chien (3):
  arm64: dts: mt8173: Add thermal zone node for mt8173 platform.
  arm64: dts: mt8173: Add dynamic power node for mt8173 platform.
  thermal: mediatek: Add cpu dynamic power cooling model.

 arch/arm64/boot/dts/mediatek/mt8173.dtsi |   47 ++
 drivers/cpufreq/mt8173-cpufreq.c |   28 +-
 2 files changed, 67 insertions(+), 8 deletions(-)

--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 3/3] thermal: mediatek: Add cpu dynamic power cooling model.

2015-11-27 Thread Dawei Chien
MT8173 cpufreq driver use of_cpufreq_power_cooling_register registering
cooling devices with dynamic power coefficient.

Signed-off-by: Dawei Chien <dawei.ch...@mediatek.com>
---
This patch is base on patchset:
https://lkml.org/lkml/2015/11/17/251
---
 drivers/cpufreq/mt8173-cpufreq.c |   28 
 1 file changed, 20 insertions(+), 8 deletions(-)

diff --git a/drivers/cpufreq/mt8173-cpufreq.c b/drivers/cpufreq/mt8173-cpufreq.c
index 83001dc..4d39468 100644
--- a/drivers/cpufreq/mt8173-cpufreq.c
+++ b/drivers/cpufreq/mt8173-cpufreq.c
@@ -263,24 +263,34 @@ static int mtk_cpufreq_set_target(struct cpufreq_policy 
*policy,
return 0;
 }
 
+#define DYNAMIC_POWER "dynamic-power-coefficient"
+
 static void mtk_cpufreq_ready(struct cpufreq_policy *policy)
 {
struct mtk_cpu_dvfs_info *info = policy->driver_data;
struct device_node *np = of_node_get(info->cpu_dev->of_node);
+   u32 capacitance;
 
if (WARN_ON(!np))
return;
 
if (of_find_property(np, "#cooling-cells", NULL)) {
-   info->cdev = of_cpufreq_cooling_register(np,
-policy->related_cpus);
+   if (!info->cdev) {
+   of_property_read_u32(np, DYNAMIC_POWER, );
+
+   info->cdev = of_cpufreq_power_cooling_register(np,
+   policy->related_cpus,
+   capacitance,
+   NULL);
 
-   if (IS_ERR(info->cdev)) {
-   dev_err(info->cpu_dev,
-   "running cpufreq without cooling device: %ld\n",
-   PTR_ERR(info->cdev));
+   if (IS_ERR(info->cdev)) {
+   dev_err(info->cpu_dev,
+   "running cpufreq without cooling 
device: %ld\n",
+   PTR_ERR(info->cdev));
 
-   info->cdev = NULL;
+   info->cdev = NULL;
+   }
}
}
 
@@ -460,7 +470,9 @@ static int mtk_cpufreq_exit(struct cpufreq_policy *policy)
 {
struct mtk_cpu_dvfs_info *info = policy->driver_data;
 
-   cpufreq_cooling_unregister(info->cdev);
+   if (info->cdev)
+   cpufreq_cooling_unregister(info->cdev);
+
dev_pm_opp_free_cpufreq_table(info->cpu_dev, >freq_table);
mtk_cpu_dvfs_info_release(info);
kfree(info);
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


  1   2   >