aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZhang Rui <rui.zhang@intel.com>2015-05-18 20:12:27 -0400
committerZhang Rui <rui.zhang@intel.com>2015-05-18 20:12:27 -0400
commite93cd95029c3b8aa628f0204e80e66fc61b57f12 (patch)
treef1e8c9c9a35c0af1a566e2e673c31abc04b1a35e
parente26081808edadfd257c6c9d81014e3b25e9a6118 (diff)
parentefa86858e1d8970411a140fa1e0c4dd18a8f2a89 (diff)
Merge branch 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux-soc-thermal into for-rc
-rw-r--r--drivers/thermal/armada_thermal.c6
-rw-r--r--drivers/thermal/ti-soc-thermal/dra752-thermal-data.c3
-rw-r--r--drivers/thermal/ti-soc-thermal/omap5-thermal-data.c3
-rw-r--r--drivers/thermal/ti-soc-thermal/ti-bandgap.c78
-rw-r--r--drivers/thermal/ti-soc-thermal/ti-bandgap.h6
5 files changed, 89 insertions, 7 deletions
diff --git a/drivers/thermal/armada_thermal.c b/drivers/thermal/armada_thermal.c
index c2556cf5186b..01255fd65135 100644
--- a/drivers/thermal/armada_thermal.c
+++ b/drivers/thermal/armada_thermal.c
@@ -224,9 +224,9 @@ static const struct armada_thermal_data armada380_data = {
224 .is_valid_shift = 10, 224 .is_valid_shift = 10,
225 .temp_shift = 0, 225 .temp_shift = 0,
226 .temp_mask = 0x3ff, 226 .temp_mask = 0x3ff,
227 .coef_b = 1169498786UL, 227 .coef_b = 2931108200UL,
228 .coef_m = 2000000UL, 228 .coef_m = 5000000UL,
229 .coef_div = 4289, 229 .coef_div = 10502,
230 .inverted = true, 230 .inverted = true,
231}; 231};
232 232
diff --git a/drivers/thermal/ti-soc-thermal/dra752-thermal-data.c b/drivers/thermal/ti-soc-thermal/dra752-thermal-data.c
index a4929272074f..58b5c6694cd4 100644
--- a/drivers/thermal/ti-soc-thermal/dra752-thermal-data.c
+++ b/drivers/thermal/ti-soc-thermal/dra752-thermal-data.c
@@ -420,7 +420,8 @@ const struct ti_bandgap_data dra752_data = {
420 TI_BANDGAP_FEATURE_FREEZE_BIT | 420 TI_BANDGAP_FEATURE_FREEZE_BIT |
421 TI_BANDGAP_FEATURE_TALERT | 421 TI_BANDGAP_FEATURE_TALERT |
422 TI_BANDGAP_FEATURE_COUNTER_DELAY | 422 TI_BANDGAP_FEATURE_COUNTER_DELAY |
423 TI_BANDGAP_FEATURE_HISTORY_BUFFER, 423 TI_BANDGAP_FEATURE_HISTORY_BUFFER |
424 TI_BANDGAP_FEATURE_ERRATA_814,
424 .fclock_name = "l3instr_ts_gclk_div", 425 .fclock_name = "l3instr_ts_gclk_div",
425 .div_ck_name = "l3instr_ts_gclk_div", 426 .div_ck_name = "l3instr_ts_gclk_div",
426 .conv_table = dra752_adc_to_temp, 427 .conv_table = dra752_adc_to_temp,
diff --git a/drivers/thermal/ti-soc-thermal/omap5-thermal-data.c b/drivers/thermal/ti-soc-thermal/omap5-thermal-data.c
index eff0c80fd4af..79ff70c446ba 100644
--- a/drivers/thermal/ti-soc-thermal/omap5-thermal-data.c
+++ b/drivers/thermal/ti-soc-thermal/omap5-thermal-data.c
@@ -319,7 +319,8 @@ const struct ti_bandgap_data omap5430_data = {
319 TI_BANDGAP_FEATURE_FREEZE_BIT | 319 TI_BANDGAP_FEATURE_FREEZE_BIT |
320 TI_BANDGAP_FEATURE_TALERT | 320 TI_BANDGAP_FEATURE_TALERT |
321 TI_BANDGAP_FEATURE_COUNTER_DELAY | 321 TI_BANDGAP_FEATURE_COUNTER_DELAY |
322 TI_BANDGAP_FEATURE_HISTORY_BUFFER, 322 TI_BANDGAP_FEATURE_HISTORY_BUFFER |
323 TI_BANDGAP_FEATURE_ERRATA_813,
323 .fclock_name = "l3instr_ts_gclk_div", 324 .fclock_name = "l3instr_ts_gclk_div",
324 .div_ck_name = "l3instr_ts_gclk_div", 325 .div_ck_name = "l3instr_ts_gclk_div",
325 .conv_table = omap5430_adc_to_temp, 326 .conv_table = omap5430_adc_to_temp,
diff --git a/drivers/thermal/ti-soc-thermal/ti-bandgap.c b/drivers/thermal/ti-soc-thermal/ti-bandgap.c
index 62a5d449c388..bc14dc874594 100644
--- a/drivers/thermal/ti-soc-thermal/ti-bandgap.c
+++ b/drivers/thermal/ti-soc-thermal/ti-bandgap.c
@@ -119,6 +119,37 @@ exit:
119} 119}
120 120
121/** 121/**
122 * ti_errata814_bandgap_read_temp() - helper function to read dra7 sensor temperature
123 * @bgp: pointer to ti_bandgap structure
124 * @reg: desired register (offset) to be read
125 *
126 * Function to read dra7 bandgap sensor temperature. This is done separately
127 * so as to workaround the errata "Bandgap Temperature read Dtemp can be
128 * corrupted" - Errata ID: i814".
129 * Read accesses to registers listed below can be corrupted due to incorrect
130 * resynchronization between clock domains.
131 * Read access to registers below can be corrupted :
132 * CTRL_CORE_DTEMP_MPU/GPU/CORE/DSPEVE/IVA_n (n = 0 to 4)
133 * CTRL_CORE_TEMP_SENSOR_MPU/GPU/CORE/DSPEVE/IVA_n
134 *
135 * Return: the register value.
136 */
137static u32 ti_errata814_bandgap_read_temp(struct ti_bandgap *bgp, u32 reg)
138{
139 u32 val1, val2;
140
141 val1 = ti_bandgap_readl(bgp, reg);
142 val2 = ti_bandgap_readl(bgp, reg);
143
144 /* If both times we read the same value then that is right */
145 if (val1 == val2)
146 return val1;
147
148 /* if val1 and val2 are different read it third time */
149 return ti_bandgap_readl(bgp, reg);
150}
151
152/**
122 * ti_bandgap_read_temp() - helper function to read sensor temperature 153 * ti_bandgap_read_temp() - helper function to read sensor temperature
123 * @bgp: pointer to ti_bandgap structure 154 * @bgp: pointer to ti_bandgap structure
124 * @id: bandgap sensor id 155 * @id: bandgap sensor id
@@ -148,7 +179,11 @@ static u32 ti_bandgap_read_temp(struct ti_bandgap *bgp, int id)
148 } 179 }
149 180
150 /* read temperature */ 181 /* read temperature */
151 temp = ti_bandgap_readl(bgp, reg); 182 if (TI_BANDGAP_HAS(bgp, ERRATA_814))
183 temp = ti_errata814_bandgap_read_temp(bgp, reg);
184 else
185 temp = ti_bandgap_readl(bgp, reg);
186
152 temp &= tsr->bgap_dtemp_mask; 187 temp &= tsr->bgap_dtemp_mask;
153 188
154 if (TI_BANDGAP_HAS(bgp, FREEZE_BIT)) 189 if (TI_BANDGAP_HAS(bgp, FREEZE_BIT))
@@ -410,7 +445,7 @@ static int ti_bandgap_update_alert_threshold(struct ti_bandgap *bgp, int id,
410{ 445{
411 struct temp_sensor_data *ts_data = bgp->conf->sensors[id].ts_data; 446 struct temp_sensor_data *ts_data = bgp->conf->sensors[id].ts_data;
412 struct temp_sensor_registers *tsr; 447 struct temp_sensor_registers *tsr;
413 u32 thresh_val, reg_val, t_hot, t_cold; 448 u32 thresh_val, reg_val, t_hot, t_cold, ctrl;
414 int err = 0; 449 int err = 0;
415 450
416 tsr = bgp->conf->sensors[id].registers; 451 tsr = bgp->conf->sensors[id].registers;
@@ -442,8 +477,47 @@ static int ti_bandgap_update_alert_threshold(struct ti_bandgap *bgp, int id,
442 ~(tsr->threshold_thot_mask | tsr->threshold_tcold_mask); 477 ~(tsr->threshold_thot_mask | tsr->threshold_tcold_mask);
443 reg_val |= (t_hot << __ffs(tsr->threshold_thot_mask)) | 478 reg_val |= (t_hot << __ffs(tsr->threshold_thot_mask)) |
444 (t_cold << __ffs(tsr->threshold_tcold_mask)); 479 (t_cold << __ffs(tsr->threshold_tcold_mask));
480
481 /**
482 * Errata i813:
483 * Spurious Thermal Alert: Talert can happen randomly while the device
484 * remains under the temperature limit defined for this event to trig.
485 * This spurious event is caused by a incorrect re-synchronization
486 * between clock domains. The comparison between configured threshold
487 * and current temperature value can happen while the value is
488 * transitioning (metastable), thus causing inappropriate event
489 * generation. No spurious event occurs as long as the threshold value
490 * stays unchanged. Spurious event can be generated while a thermal
491 * alert threshold is modified in
492 * CONTROL_BANDGAP_THRESHOLD_MPU/GPU/CORE/DSPEVE/IVA_n.
493 */
494
495 if (TI_BANDGAP_HAS(bgp, ERRATA_813)) {
496 /* Mask t_hot and t_cold events at the IP Level */
497 ctrl = ti_bandgap_readl(bgp, tsr->bgap_mask_ctrl);
498
499 if (hot)
500 ctrl &= ~tsr->mask_hot_mask;
501 else
502 ctrl &= ~tsr->mask_cold_mask;
503
504 ti_bandgap_writel(bgp, ctrl, tsr->bgap_mask_ctrl);
505 }
506
507 /* Write the threshold value */
445 ti_bandgap_writel(bgp, reg_val, tsr->bgap_threshold); 508 ti_bandgap_writel(bgp, reg_val, tsr->bgap_threshold);
446 509
510 if (TI_BANDGAP_HAS(bgp, ERRATA_813)) {
511 /* Unmask t_hot and t_cold events at the IP Level */
512 ctrl = ti_bandgap_readl(bgp, tsr->bgap_mask_ctrl);
513 if (hot)
514 ctrl |= tsr->mask_hot_mask;
515 else
516 ctrl |= tsr->mask_cold_mask;
517
518 ti_bandgap_writel(bgp, ctrl, tsr->bgap_mask_ctrl);
519 }
520
447 if (err) { 521 if (err) {
448 dev_err(bgp->dev, "failed to reprogram thot threshold\n"); 522 dev_err(bgp->dev, "failed to reprogram thot threshold\n");
449 err = -EIO; 523 err = -EIO;
diff --git a/drivers/thermal/ti-soc-thermal/ti-bandgap.h b/drivers/thermal/ti-soc-thermal/ti-bandgap.h
index b3adf72f252d..0c52f7afba00 100644
--- a/drivers/thermal/ti-soc-thermal/ti-bandgap.h
+++ b/drivers/thermal/ti-soc-thermal/ti-bandgap.h
@@ -318,6 +318,10 @@ struct ti_temp_sensor {
318 * TI_BANDGAP_FEATURE_HISTORY_BUFFER - used when the bandgap device features 318 * TI_BANDGAP_FEATURE_HISTORY_BUFFER - used when the bandgap device features
319 * a history buffer of temperatures. 319 * a history buffer of temperatures.
320 * 320 *
321 * TI_BANDGAP_FEATURE_ERRATA_814 - used to workaorund when the bandgap device
322 * has Errata 814
323 * TI_BANDGAP_FEATURE_ERRATA_813 - used to workaorund when the bandgap device
324 * has Errata 813
321 * TI_BANDGAP_HAS(b, f) - macro to check if a bandgap device is capable of a 325 * TI_BANDGAP_HAS(b, f) - macro to check if a bandgap device is capable of a
322 * specific feature (above) or not. Return non-zero, if yes. 326 * specific feature (above) or not. Return non-zero, if yes.
323 */ 327 */
@@ -331,6 +335,8 @@ struct ti_temp_sensor {
331#define TI_BANDGAP_FEATURE_FREEZE_BIT BIT(7) 335#define TI_BANDGAP_FEATURE_FREEZE_BIT BIT(7)
332#define TI_BANDGAP_FEATURE_COUNTER_DELAY BIT(8) 336#define TI_BANDGAP_FEATURE_COUNTER_DELAY BIT(8)
333#define TI_BANDGAP_FEATURE_HISTORY_BUFFER BIT(9) 337#define TI_BANDGAP_FEATURE_HISTORY_BUFFER BIT(9)
338#define TI_BANDGAP_FEATURE_ERRATA_814 BIT(10)
339#define TI_BANDGAP_FEATURE_ERRATA_813 BIT(11)
334#define TI_BANDGAP_HAS(b, f) \ 340#define TI_BANDGAP_HAS(b, f) \
335 ((b)->conf->features & TI_BANDGAP_FEATURE_ ## f) 341 ((b)->conf->features & TI_BANDGAP_FEATURE_ ## f)
336 342