Skip to contentSkip to conversation

thermal: rockchip: enhance the tsadc's bandgap feature for rk3399

PATCH In review Caesar Wang 3 participants 5 messages Jul 27, 2016 – Aug 19, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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.

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 -5
index db5ecc5..a90423d 100644
@@ -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
#1 lore raw

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.

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 -2
index a90423d..1f165c9 100644
@@ -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
Tested-by on v1 2/2
#2 lore raw

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_TIME and TSADCV3_AUTO_PERIOD_HT_TIME the same value, because normal temperature update speed is also our consern in IPA.

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
index a90423d..1f165c9 100644
@@ -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

Tested-by on v1 1/2
#3 lore raw
In reply to Caesar Wang
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.

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
index db5ecc5..a90423d 100644
@@ -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

reviewer
#4 lore raw
In reply to Caesar Wang
Quoted 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.

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
index db5ecc5..a90423d 100644
@@ -222,10 +222,10 @@ struct rockchip_thermal_data {

?#define GRF_TSADC_TESTBIT_L 0x0e648
?#define GRF_TSADC_TESTBIT_H 0x0e64c
?

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)
?#define GRF_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)

?
?/**
? * struct tsadc_table - code to temperature conversion table

drivers/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);