thermal: rockchip: enhance the tsadc's bandgap feature for rk3399
Subsystems (2)
PATCH 1/2 thermal: rockchip: enhance the tsadc's bandgap feature for rk3399
From: Rocky Hao <[email protected]>
Due to the voltage ripple, the sensing data of the tsadc is not accurate. And in this patch, the bandgap feature is enhanced to remove the voltage ripple, and then the tsadc can sense the temperature more precisely.
Obsolete codes are removed as well.
---
drivers/thermal/rockchip_thermal.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/thermal/rockchip_thermal.c +6 -5
@@ -222,10 +222,10 @@ struct rockchip_thermal_data {#define GRF_TSADC_TESTBIT_L 0x0e648#define GRF_TSADC_TESTBIT_H 0x0e64c -#define GRF_TSADC_TSEN_PD_ON (0x30003 << 0) -#define GRF_TSADC_TSEN_PD_OFF (0x30000 << 0)#define GRF_SARADC_TESTBIT_ON (0x10001 << 2)#define GRF_TSADC_TESTBIT_H_ON (0x10001 << 2) +#define GRF_TSADC_VCM_EN_L (0x10001 << 7) +#define GRF_TSADC_VCM_EN_H (0x10001 << 7)/** * struct tsadc_table - code to temperature conversion table
@@ -567,9 +567,10 @@ static void rk_tsadcv3_initialize(struct regmap *grf, void __iomem *regs, regs + TSADCV2_HIGHT_TSHUT_DEBOUNCE); }else { -regmap_write (grf,GRF_TSADC_TESTBIT_L ,GRF_TSADC_TSEN_PD_ON ); -mdelay (10 ); -regmap_write (grf,GRF_TSADC_TESTBIT_L ,GRF_TSADC_TSEN_PD_OFF ); +/* Enable the voltage common mode feature */ +regmap_write (grf,GRF_TSADC_TESTBIT_L ,GRF_TSADC_VCM_EN_L ); +regmap_write (grf,GRF_TSADC_TESTBIT_H ,GRF_TSADC_VCM_EN_H ); +usleep_range (15 ,100 );/* The spec note says@least 15 us */ regmap_write (grf,GRF_SARADC_TESTBIT ,GRF_SARADC_TESTBIT_ON );regmap_write (grf,GRF_TSADC_TESTBIT_H ,GRF_TSADC_TESTBIT_H_ON );
Signature · 1 line
1.9.1
PATCH 2/2 thermal: rockchip: optimize sensor auto accessing period
From: Rocky Hao <[email protected]>
In less than 10 ms, the temperature of soc will arise 10 degree. 250 ms is too big for soc tempeture control. Setting 2.5 ms will speed up temperature accessing speed but introduce no more cpu's computing overhead. We set AUTO_PERIOD_TIME and TSADCV3_AUTO_PERIOD_HT_TIME the same value, because normal temperature update speed is also our consern in IPA.
---
drivers/thermal/rockchip_thermal.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/thermal/rockchip_thermal.c +2 -2
@@ -213,8 +213,8 @@ struct rockchip_thermal_data {#define TSADCV2_HIGHT_TSHUT_DEBOUNCE_COUNT 4#define TSADCV2_AUTO_PERIOD_TIME 250/* 250ms */ #define TSADCV2_AUTO_PERIOD_HT_TIME 50/* 50ms */ -#define TSADCV3_AUTO_PERIOD_TIME 187500/* 250ms */ -#define TSADCV3_AUTO_PERIOD_HT_TIME 37500/* 50ms */ +#define TSADCV3_AUTO_PERIOD_TIME 1875/* 2.5ms */ +#define TSADCV3_AUTO_PERIOD_HT_TIME 1875/* 2.5ms */ #define TSADCV2_USER_INTER_PD_SOC 0x340/* 13 clocks */
Signature · 1 line
1.9.1
Re: [PATCH 2/2] thermal: rockchip: optimize sensor auto accessing period
Quoted 36 lines · Caesar Wang
From: Rocky Hao <[email protected]>
In less than 10 ms, the temperature of soc will arise 10 degree. 250 ms is too big for soc tempeture control. Setting 2.5 ms will speed up temperature accessing speed but introduce no more cpu's computing overhead. We set
AUTO_PERIOD_TIMEandTSADCV3_AUTO_PERIOD_HT_TIMEthe same value, because normal temperature update speed is also our consern in IPA.Signed-off-by Rocky Hao <[email protected]>Signed-off-by Caesar Wang <[email protected]>Cc Zhang Rui <[email protected]>Cc Eduardo Valentin <[email protected]>Cc Heiko Stuebner <[email protected]>Cc linux-pm at vger.kernel.org---
drivers/thermal/rockchip_thermal.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/thermal/rockchip_thermal.c +2
-3@@ -213,8 +213,8 @@ struct rockchip_thermal_data {#define TSADCV2_HIGHT_TSHUT_DEBOUNCE_COUNT 4#define TSADCV2_AUTO_PERIOD_TIME 250/* 250ms */ #define TSADCV2_AUTO_PERIOD_HT_TIME 50/* 50ms */ -#define TSADCV3_AUTO_PERIOD_TIME 187500/* 250ms */ -#define TSADCV3_AUTO_PERIOD_HT_TIME 37500/* 50ms */ +#define TSADCV3_AUTO_PERIOD_TIME 1875/* 2.5ms */ +#define TSADCV3_AUTO_PERIOD_HT_TIME 1875/* 2.5ms */ #define TSADCV2_USER_INTER_PD_SOC 0x340/* 13 clocks */ --
Quoted 2 lines
1.9.1
Steve
Quoted 51 lines · Caesar Wang
From: Rocky Hao <[email protected]>
Due to the voltage ripple, the sensing data of the tsadc is not accurate. And in this patch, the bandgap feature is enhanced to remove the voltage ripple, and then the tsadc can sense the temperature more precisely.
Obsolete codes are removed as well.
Signed-off-by Rocky Hao <[email protected]>Signed-off-by Caesar Wang <[email protected]>Cc Eduardo Valentin <[email protected]>Cc Zhang Rui <[email protected]>Cc Heiko Stuebner <[email protected]>Cc linux-pm at vger.kernel.org---
drivers/thermal/rockchip_thermal.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)drivers/thermal/rockchip_thermal.c +6
-6@@ -222,10 +222,10 @@ struct rockchip_thermal_data {#define GRF_TSADC_TESTBIT_L 0x0e648#define GRF_TSADC_TESTBIT_H 0x0e64c -#define GRF_TSADC_TSEN_PD_ON (0x30003 << 0) -#define GRF_TSADC_TSEN_PD_OFF (0x30000 << 0)#define GRF_SARADC_TESTBIT_ON (0x10001 << 2)#define GRF_TSADC_TESTBIT_H_ON (0x10001 << 2) +#define GRF_TSADC_VCM_EN_L (0x10001 << 7) +#define GRF_TSADC_VCM_EN_H (0x10001 << 7)/** * struct tsadc_table - code to temperature conversion table @@ -567,9 +567,10 @@ static void rk_tsadcv3_initialize(struct regmap *grf, void __iomem *regs, regs + TSADCV2_HIGHT_TSHUT_DEBOUNCE); }else { -regmap_write (grf,GRF_TSADC_TESTBIT_L ,GRF_TSADC_TSEN_PD_ON ); -mdelay (10 ); -regmap_write (grf,GRF_TSADC_TESTBIT_L ,GRF_TSADC_TSEN_PD_OFF ); +/* Enable the voltage common mode feature */ +regmap_write (grf,GRF_TSADC_TESTBIT_L ,GRF_TSADC_VCM_EN_L ); +regmap_write (grf,GRF_TSADC_TESTBIT_H ,GRF_TSADC_VCM_EN_H ); +usleep_range (15 ,100 );/* The spec note says at least 15 us */ regmap_write (grf,GRF_SARADC_TESTBIT ,GRF_SARADC_TESTBIT_ON );regmap_write (grf,GRF_TSADC_TESTBIT_H ,GRF_TSADC_TESTBIT_H_ON ); --
Quoted 2 lines
1.9.1
Steve
Zhang Rui
reviewerQuoted 8 lines · Caesar Wang
From: Rocky Hao <[email protected]>
Due to the voltage ripple, the sensing data of the tsadc is not accurate.
And in this patch, the bandgap feature is enhanced to remove the voltage
ripple, and then the tsadc can sense the temperature more precisely.
Quoted 8 lines
Obsolete codes are removed as well.
Signed-off-by Rocky Hao <[email protected]>Signed-off-by Caesar Wang <[email protected]>Cc Eduardo Valentin <[email protected]>Cc Zhang Rui <[email protected]>Cc Heiko Stuebner <[email protected]>Cc linux-pm at vger.kernel.org
Both patches applied and queued for 4.9.
thanks,
rui
Quoted 45 lines
---
?drivers/thermal/rockchip_thermal.c | 11 ++++++----- ?1 file changed, 6 insertions(+), 5 deletions(-)
drivers/thermal/rockchip_thermal.c +0
-0@@ -222,10 +222,10 @@ struct rockchip_thermal_data {?#define
GRF_TSADC_TESTBIT_L0x0e648
?#defineGRF_TSADC_TESTBIT_H0x0e64c
?drivers/thermal/rockchip_thermal.c +0
-2-#define GRF_TSADC_TSEN_PD_ON (0x30003 << 0) -#define GRF_TSADC_TSEN_PD_OFF (0x30000 << 0)?#define
GRF_SARADC_TESTBIT_ON(0x10001<< 2)
?#defineGRF_TSADC_TESTBIT_H_ON(0x10001<< 2)drivers/thermal/rockchip_thermal.c +2
-0+#define GRF_TSADC_VCM_EN_L (0x10001 << 7) +#define GRF_TSADC_VCM_EN_H (0x10001 << 7)?
?/**
? * structtsadc_table- code to temperature conversion tabledrivers/thermal/rockchip_thermal.c +0
-0@@ -567,9 +567,10 @@ static void rk_tsadcv3_initialize(struct regmap *grf, void__iomem *regs, ? ???????regs + TSADCV2_HIGHT_TSHUT_DEBOUNCE);?
? } else {drivers/thermal/rockchip_thermal.c +0
-1- regmap_write(grf, GRF_TSADC_TESTBIT_L,
GRF_TSADC_TSEN_PD_ON);drivers/thermal/rockchip_thermal.c +0
-2-mdelay (10 ); - regmap_write(grf, GRF_TSADC_TESTBIT_L,
GRF_TSADC_TSEN_PD_OFF);drivers/thermal/rockchip_thermal.c +2
-0+/* Enable the voltage common mode feature */ + regmap_write(grf, GRF_TSADC_TESTBIT_L,
GRF_TSADC_VCM_EN_L);drivers/thermal/rockchip_thermal.c +1
-0+ regmap_write(grf, GRF_TSADC_TESTBIT_H,
GRF_TSADC_VCM_EN_H);
+
?usleep_range(15, 100); /* The spec note says at
least 15 us */
? regmap_write(grf,GRF_SARADC_TESTBIT,GRF_SARADC_TESTBIT_ON);
? regmap_write(grf,GRF_TSADC_TESTBIT_H,GRF_TSADC_TESTBIT_H_ON);