diff options
-rw-r--r-- | drivers/thermal/samsung/exynos_tmu.c | 45 | ||||
-rw-r--r-- | drivers/thermal/samsung/exynos_tmu.h | 2 | ||||
-rw-r--r-- | drivers/thermal/samsung/exynos_tmu_data.c | 6 |
3 files changed, 28 insertions, 25 deletions
diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index 938e8e63cff9..b209593d78dc 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c | |||
@@ -54,6 +54,7 @@ | |||
54 | * @reg_conf: pointer to structure to register with core thermal. | 54 | * @reg_conf: pointer to structure to register with core thermal. |
55 | * @tmu_initialize: SoC specific TMU initialization method | 55 | * @tmu_initialize: SoC specific TMU initialization method |
56 | * @tmu_control: SoC specific TMU control method | 56 | * @tmu_control: SoC specific TMU control method |
57 | * @tmu_read: SoC specific TMU temperature read method | ||
57 | */ | 58 | */ |
58 | struct exynos_tmu_data { | 59 | struct exynos_tmu_data { |
59 | int id; | 60 | int id; |
@@ -70,6 +71,7 @@ struct exynos_tmu_data { | |||
70 | struct thermal_sensor_conf *reg_conf; | 71 | struct thermal_sensor_conf *reg_conf; |
71 | int (*tmu_initialize)(struct platform_device *pdev); | 72 | int (*tmu_initialize)(struct platform_device *pdev); |
72 | void (*tmu_control)(struct platform_device *pdev, bool on); | 73 | void (*tmu_control)(struct platform_device *pdev, bool on); |
74 | int (*tmu_read)(struct exynos_tmu_data *data); | ||
73 | }; | 75 | }; |
74 | 76 | ||
75 | /* | 77 | /* |
@@ -422,29 +424,17 @@ static void exynos5440_tmu_control(struct platform_device *pdev, bool on) | |||
422 | 424 | ||
423 | static int exynos_tmu_read(struct exynos_tmu_data *data) | 425 | static int exynos_tmu_read(struct exynos_tmu_data *data) |
424 | { | 426 | { |
425 | struct exynos_tmu_platform_data *pdata = data->pdata; | 427 | int ret; |
426 | const struct exynos_tmu_registers *reg = pdata->registers; | ||
427 | u8 temp_code; | ||
428 | int temp; | ||
429 | 428 | ||
430 | mutex_lock(&data->lock); | 429 | mutex_lock(&data->lock); |
431 | clk_enable(data->clk); | 430 | clk_enable(data->clk); |
432 | 431 | ret = data->tmu_read(data); | |
433 | temp_code = readb(data->base + reg->tmu_cur_temp); | 432 | if (ret >= 0) |
434 | 433 | ret = code_to_temp(data, ret); | |
435 | if (data->soc == SOC_ARCH_EXYNOS4210) | ||
436 | /* temp_code should range between 75 and 175 */ | ||
437 | if (temp_code < 75 || temp_code > 175) { | ||
438 | temp = -ENODATA; | ||
439 | goto out; | ||
440 | } | ||
441 | |||
442 | temp = code_to_temp(data, temp_code); | ||
443 | out: | ||
444 | clk_disable(data->clk); | 434 | clk_disable(data->clk); |
445 | mutex_unlock(&data->lock); | 435 | mutex_unlock(&data->lock); |
446 | 436 | ||
447 | return temp; | 437 | return ret; |
448 | } | 438 | } |
449 | 439 | ||
450 | #ifdef CONFIG_THERMAL_EMULATION | 440 | #ifdef CONFIG_THERMAL_EMULATION |
@@ -494,6 +484,24 @@ static int exynos_tmu_set_emulation(void *drv_data, unsigned long temp) | |||
494 | { return -EINVAL; } | 484 | { return -EINVAL; } |
495 | #endif/*CONFIG_THERMAL_EMULATION*/ | 485 | #endif/*CONFIG_THERMAL_EMULATION*/ |
496 | 486 | ||
487 | static int exynos4210_tmu_read(struct exynos_tmu_data *data) | ||
488 | { | ||
489 | int ret = readb(data->base + EXYNOS_TMU_REG_CURRENT_TEMP); | ||
490 | |||
491 | /* "temp_code" should range between 75 and 175 */ | ||
492 | return (ret < 75 || ret > 175) ? -ENODATA : ret; | ||
493 | } | ||
494 | |||
495 | static int exynos4412_tmu_read(struct exynos_tmu_data *data) | ||
496 | { | ||
497 | return readb(data->base + EXYNOS_TMU_REG_CURRENT_TEMP); | ||
498 | } | ||
499 | |||
500 | static int exynos5440_tmu_read(struct exynos_tmu_data *data) | ||
501 | { | ||
502 | return readb(data->base + EXYNOS5440_TMU_S0_7_TEMP); | ||
503 | } | ||
504 | |||
497 | static void exynos_tmu_work(struct work_struct *work) | 505 | static void exynos_tmu_work(struct work_struct *work) |
498 | { | 506 | { |
499 | struct exynos_tmu_data *data = container_of(work, | 507 | struct exynos_tmu_data *data = container_of(work, |
@@ -718,6 +726,7 @@ static int exynos_tmu_probe(struct platform_device *pdev) | |||
718 | case SOC_ARCH_EXYNOS4210: | 726 | case SOC_ARCH_EXYNOS4210: |
719 | data->tmu_initialize = exynos4210_tmu_initialize; | 727 | data->tmu_initialize = exynos4210_tmu_initialize; |
720 | data->tmu_control = exynos4210_tmu_control; | 728 | data->tmu_control = exynos4210_tmu_control; |
729 | data->tmu_read = exynos4210_tmu_read; | ||
721 | break; | 730 | break; |
722 | case SOC_ARCH_EXYNOS3250: | 731 | case SOC_ARCH_EXYNOS3250: |
723 | case SOC_ARCH_EXYNOS4412: | 732 | case SOC_ARCH_EXYNOS4412: |
@@ -727,10 +736,12 @@ static int exynos_tmu_probe(struct platform_device *pdev) | |||
727 | case SOC_ARCH_EXYNOS5420_TRIMINFO: | 736 | case SOC_ARCH_EXYNOS5420_TRIMINFO: |
728 | data->tmu_initialize = exynos4412_tmu_initialize; | 737 | data->tmu_initialize = exynos4412_tmu_initialize; |
729 | data->tmu_control = exynos4210_tmu_control; | 738 | data->tmu_control = exynos4210_tmu_control; |
739 | data->tmu_read = exynos4412_tmu_read; | ||
730 | break; | 740 | break; |
731 | case SOC_ARCH_EXYNOS5440: | 741 | case SOC_ARCH_EXYNOS5440: |
732 | data->tmu_initialize = exynos5440_tmu_initialize; | 742 | data->tmu_initialize = exynos5440_tmu_initialize; |
733 | data->tmu_control = exynos5440_tmu_control; | 743 | data->tmu_control = exynos5440_tmu_control; |
744 | data->tmu_read = exynos5440_tmu_read; | ||
734 | break; | 745 | break; |
735 | default: | 746 | default: |
736 | ret = -EINVAL; | 747 | ret = -EINVAL; |
diff --git a/drivers/thermal/samsung/exynos_tmu.h b/drivers/thermal/samsung/exynos_tmu.h index 7496b54f2a86..9460e6e55fe8 100644 --- a/drivers/thermal/samsung/exynos_tmu.h +++ b/drivers/thermal/samsung/exynos_tmu.h | |||
@@ -70,13 +70,11 @@ enum soc_type { | |||
70 | /** | 70 | /** |
71 | * struct exynos_tmu_register - register descriptors to access registers. | 71 | * struct exynos_tmu_register - register descriptors to access registers. |
72 | * The register validity may vary slightly across different exynos SOC's. | 72 | * The register validity may vary slightly across different exynos SOC's. |
73 | * @tmu_cur_temp: register containing the current temperature of the TMU. | ||
74 | * @tmu_intstat: Register containing the interrupt status values. | 73 | * @tmu_intstat: Register containing the interrupt status values. |
75 | * @tmu_intclear: Register for clearing the raised interrupt status. | 74 | * @tmu_intclear: Register for clearing the raised interrupt status. |
76 | * @emul_con: TMU emulation controller register. | 75 | * @emul_con: TMU emulation controller register. |
77 | */ | 76 | */ |
78 | struct exynos_tmu_registers { | 77 | struct exynos_tmu_registers { |
79 | u32 tmu_cur_temp; | ||
80 | u32 tmu_intstat; | 78 | u32 tmu_intstat; |
81 | u32 tmu_intclear; | 79 | u32 tmu_intclear; |
82 | u32 emul_con; | 80 | u32 emul_con; |
diff --git a/drivers/thermal/samsung/exynos_tmu_data.c b/drivers/thermal/samsung/exynos_tmu_data.c index 2bfd4690e0d7..769b89d7d641 100644 --- a/drivers/thermal/samsung/exynos_tmu_data.c +++ b/drivers/thermal/samsung/exynos_tmu_data.c | |||
@@ -26,7 +26,6 @@ | |||
26 | 26 | ||
27 | #if defined(CONFIG_CPU_EXYNOS4210) | 27 | #if defined(CONFIG_CPU_EXYNOS4210) |
28 | static const struct exynos_tmu_registers exynos4210_tmu_registers = { | 28 | static const struct exynos_tmu_registers exynos4210_tmu_registers = { |
29 | .tmu_cur_temp = EXYNOS_TMU_REG_CURRENT_TEMP, | ||
30 | .tmu_intstat = EXYNOS_TMU_REG_INTSTAT, | 29 | .tmu_intstat = EXYNOS_TMU_REG_INTSTAT, |
31 | .tmu_intclear = EXYNOS_TMU_REG_INTCLEAR, | 30 | .tmu_intclear = EXYNOS_TMU_REG_INTCLEAR, |
32 | }; | 31 | }; |
@@ -74,7 +73,6 @@ struct exynos_tmu_init_data const exynos4210_default_tmu_data = { | |||
74 | 73 | ||
75 | #if defined(CONFIG_SOC_EXYNOS3250) | 74 | #if defined(CONFIG_SOC_EXYNOS3250) |
76 | static const struct exynos_tmu_registers exynos3250_tmu_registers = { | 75 | static const struct exynos_tmu_registers exynos3250_tmu_registers = { |
77 | .tmu_cur_temp = EXYNOS_TMU_REG_CURRENT_TEMP, | ||
78 | .tmu_intstat = EXYNOS_TMU_REG_INTSTAT, | 76 | .tmu_intstat = EXYNOS_TMU_REG_INTSTAT, |
79 | .tmu_intclear = EXYNOS_TMU_REG_INTCLEAR, | 77 | .tmu_intclear = EXYNOS_TMU_REG_INTCLEAR, |
80 | .emul_con = EXYNOS_EMUL_CON, | 78 | .emul_con = EXYNOS_EMUL_CON, |
@@ -135,7 +133,6 @@ struct exynos_tmu_init_data const exynos3250_default_tmu_data = { | |||
135 | 133 | ||
136 | #if defined(CONFIG_SOC_EXYNOS4412) || defined(CONFIG_SOC_EXYNOS5250) | 134 | #if defined(CONFIG_SOC_EXYNOS4412) || defined(CONFIG_SOC_EXYNOS5250) |
137 | static const struct exynos_tmu_registers exynos4412_tmu_registers = { | 135 | static const struct exynos_tmu_registers exynos4412_tmu_registers = { |
138 | .tmu_cur_temp = EXYNOS_TMU_REG_CURRENT_TEMP, | ||
139 | .tmu_intstat = EXYNOS_TMU_REG_INTSTAT, | 136 | .tmu_intstat = EXYNOS_TMU_REG_INTSTAT, |
140 | .tmu_intclear = EXYNOS_TMU_REG_INTCLEAR, | 137 | .tmu_intclear = EXYNOS_TMU_REG_INTCLEAR, |
141 | .emul_con = EXYNOS_EMUL_CON, | 138 | .emul_con = EXYNOS_EMUL_CON, |
@@ -208,7 +205,6 @@ struct exynos_tmu_init_data const exynos5250_default_tmu_data = { | |||
208 | 205 | ||
209 | #if defined(CONFIG_SOC_EXYNOS5260) | 206 | #if defined(CONFIG_SOC_EXYNOS5260) |
210 | static const struct exynos_tmu_registers exynos5260_tmu_registers = { | 207 | static const struct exynos_tmu_registers exynos5260_tmu_registers = { |
211 | .tmu_cur_temp = EXYNOS_TMU_REG_CURRENT_TEMP, | ||
212 | .tmu_intstat = EXYNOS5260_TMU_REG_INTSTAT, | 208 | .tmu_intstat = EXYNOS5260_TMU_REG_INTSTAT, |
213 | .tmu_intclear = EXYNOS5260_TMU_REG_INTCLEAR, | 209 | .tmu_intclear = EXYNOS5260_TMU_REG_INTCLEAR, |
214 | .emul_con = EXYNOS5260_EMUL_CON, | 210 | .emul_con = EXYNOS5260_EMUL_CON, |
@@ -271,7 +267,6 @@ struct exynos_tmu_init_data const exynos5260_default_tmu_data = { | |||
271 | 267 | ||
272 | #if defined(CONFIG_SOC_EXYNOS5420) | 268 | #if defined(CONFIG_SOC_EXYNOS5420) |
273 | static const struct exynos_tmu_registers exynos5420_tmu_registers = { | 269 | static const struct exynos_tmu_registers exynos5420_tmu_registers = { |
274 | .tmu_cur_temp = EXYNOS_TMU_REG_CURRENT_TEMP, | ||
275 | .tmu_intstat = EXYNOS_TMU_REG_INTSTAT, | 270 | .tmu_intstat = EXYNOS_TMU_REG_INTSTAT, |
276 | .tmu_intclear = EXYNOS_TMU_REG_INTCLEAR, | 271 | .tmu_intclear = EXYNOS_TMU_REG_INTCLEAR, |
277 | .emul_con = EXYNOS_EMUL_CON, | 272 | .emul_con = EXYNOS_EMUL_CON, |
@@ -340,7 +335,6 @@ struct exynos_tmu_init_data const exynos5420_default_tmu_data = { | |||
340 | 335 | ||
341 | #if defined(CONFIG_SOC_EXYNOS5440) | 336 | #if defined(CONFIG_SOC_EXYNOS5440) |
342 | static const struct exynos_tmu_registers exynos5440_tmu_registers = { | 337 | static const struct exynos_tmu_registers exynos5440_tmu_registers = { |
343 | .tmu_cur_temp = EXYNOS5440_TMU_S0_7_TEMP, | ||
344 | .tmu_intstat = EXYNOS5440_TMU_S0_7_IRQ, | 338 | .tmu_intstat = EXYNOS5440_TMU_S0_7_IRQ, |
345 | .tmu_intclear = EXYNOS5440_TMU_S0_7_IRQ, | 339 | .tmu_intclear = EXYNOS5440_TMU_S0_7_IRQ, |
346 | .emul_con = EXYNOS5440_TMU_S0_7_DEBUG, | 340 | .emul_con = EXYNOS5440_TMU_S0_7_DEBUG, |