diff options
-rw-r--r-- | drivers/thermal/samsung/exynos_tmu.c | 41 | ||||
-rw-r--r-- | drivers/thermal/samsung/exynos_tmu.h | 2 | ||||
-rw-r--r-- | drivers/thermal/samsung/exynos_tmu_data.c | 5 |
3 files changed, 34 insertions, 14 deletions
diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index 1b622ce0ee79..01aa5481c13e 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c | |||
@@ -55,6 +55,7 @@ | |||
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 | * @tmu_read: SoC specific TMU temperature read method |
58 | * @tmu_set_emulation: SoC specific TMU emulation setting method | ||
58 | */ | 59 | */ |
59 | struct exynos_tmu_data { | 60 | struct exynos_tmu_data { |
60 | int id; | 61 | int id; |
@@ -72,6 +73,8 @@ struct exynos_tmu_data { | |||
72 | int (*tmu_initialize)(struct platform_device *pdev); | 73 | int (*tmu_initialize)(struct platform_device *pdev); |
73 | void (*tmu_control)(struct platform_device *pdev, bool on); | 74 | void (*tmu_control)(struct platform_device *pdev, bool on); |
74 | int (*tmu_read)(struct exynos_tmu_data *data); | 75 | int (*tmu_read)(struct exynos_tmu_data *data); |
76 | void (*tmu_set_emulation)(struct exynos_tmu_data *data, | ||
77 | unsigned long temp); | ||
75 | }; | 78 | }; |
76 | 79 | ||
77 | /* | 80 | /* |
@@ -460,12 +463,36 @@ static u32 get_emul_con_reg(struct exynos_tmu_data *data, unsigned int val, | |||
460 | return val; | 463 | return val; |
461 | } | 464 | } |
462 | 465 | ||
466 | static void exynos4412_tmu_set_emulation(struct exynos_tmu_data *data, | ||
467 | unsigned long temp) | ||
468 | { | ||
469 | unsigned int val; | ||
470 | u32 emul_con; | ||
471 | |||
472 | if (data->soc == SOC_ARCH_EXYNOS5260) | ||
473 | emul_con = EXYNOS5260_EMUL_CON; | ||
474 | else | ||
475 | emul_con = EXYNOS_EMUL_CON; | ||
476 | |||
477 | val = readl(data->base + emul_con); | ||
478 | val = get_emul_con_reg(data, val, temp); | ||
479 | writel(val, data->base + emul_con); | ||
480 | } | ||
481 | |||
482 | static void exynos5440_tmu_set_emulation(struct exynos_tmu_data *data, | ||
483 | unsigned long temp) | ||
484 | { | ||
485 | unsigned int val; | ||
486 | |||
487 | val = readl(data->base + EXYNOS5440_TMU_S0_7_DEBUG); | ||
488 | val = get_emul_con_reg(data, val, temp); | ||
489 | writel(val, data->base + EXYNOS5440_TMU_S0_7_DEBUG); | ||
490 | } | ||
491 | |||
463 | static int exynos_tmu_set_emulation(void *drv_data, unsigned long temp) | 492 | static int exynos_tmu_set_emulation(void *drv_data, unsigned long temp) |
464 | { | 493 | { |
465 | struct exynos_tmu_data *data = drv_data; | 494 | struct exynos_tmu_data *data = drv_data; |
466 | struct exynos_tmu_platform_data *pdata = data->pdata; | 495 | struct exynos_tmu_platform_data *pdata = data->pdata; |
467 | const struct exynos_tmu_registers *reg = pdata->registers; | ||
468 | unsigned int val; | ||
469 | int ret = -EINVAL; | 496 | int ret = -EINVAL; |
470 | 497 | ||
471 | if (!TMU_SUPPORTS(pdata, EMULATION)) | 498 | if (!TMU_SUPPORTS(pdata, EMULATION)) |
@@ -476,11 +503,7 @@ static int exynos_tmu_set_emulation(void *drv_data, unsigned long temp) | |||
476 | 503 | ||
477 | mutex_lock(&data->lock); | 504 | mutex_lock(&data->lock); |
478 | clk_enable(data->clk); | 505 | clk_enable(data->clk); |
479 | 506 | data->tmu_set_emulation(data, temp); | |
480 | val = readl(data->base + reg->emul_con); | ||
481 | val = get_emul_con_reg(data, val, temp); | ||
482 | writel(val, data->base + reg->emul_con); | ||
483 | |||
484 | clk_disable(data->clk); | 507 | clk_disable(data->clk); |
485 | mutex_unlock(&data->lock); | 508 | mutex_unlock(&data->lock); |
486 | return 0; | 509 | return 0; |
@@ -488,6 +511,8 @@ out: | |||
488 | return ret; | 511 | return ret; |
489 | } | 512 | } |
490 | #else | 513 | #else |
514 | #define exynos4412_tmu_set_emulation NULL | ||
515 | #define exynos5440_tmu_set_emulation NULL | ||
491 | static int exynos_tmu_set_emulation(void *drv_data, unsigned long temp) | 516 | static int exynos_tmu_set_emulation(void *drv_data, unsigned long temp) |
492 | { return -EINVAL; } | 517 | { return -EINVAL; } |
493 | #endif/*CONFIG_THERMAL_EMULATION*/ | 518 | #endif/*CONFIG_THERMAL_EMULATION*/ |
@@ -745,11 +770,13 @@ static int exynos_tmu_probe(struct platform_device *pdev) | |||
745 | data->tmu_initialize = exynos4412_tmu_initialize; | 770 | data->tmu_initialize = exynos4412_tmu_initialize; |
746 | data->tmu_control = exynos4210_tmu_control; | 771 | data->tmu_control = exynos4210_tmu_control; |
747 | data->tmu_read = exynos4412_tmu_read; | 772 | data->tmu_read = exynos4412_tmu_read; |
773 | data->tmu_set_emulation = exynos4412_tmu_set_emulation; | ||
748 | break; | 774 | break; |
749 | case SOC_ARCH_EXYNOS5440: | 775 | case SOC_ARCH_EXYNOS5440: |
750 | data->tmu_initialize = exynos5440_tmu_initialize; | 776 | data->tmu_initialize = exynos5440_tmu_initialize; |
751 | data->tmu_control = exynos5440_tmu_control; | 777 | data->tmu_control = exynos5440_tmu_control; |
752 | data->tmu_read = exynos5440_tmu_read; | 778 | data->tmu_read = exynos5440_tmu_read; |
779 | data->tmu_set_emulation = exynos5440_tmu_set_emulation; | ||
753 | break; | 780 | break; |
754 | default: | 781 | default: |
755 | ret = -EINVAL; | 782 | ret = -EINVAL; |
diff --git a/drivers/thermal/samsung/exynos_tmu.h b/drivers/thermal/samsung/exynos_tmu.h index 9460e6e55fe8..785eccf22c19 100644 --- a/drivers/thermal/samsung/exynos_tmu.h +++ b/drivers/thermal/samsung/exynos_tmu.h | |||
@@ -72,12 +72,10 @@ enum soc_type { | |||
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_intstat: Register containing the interrupt status values. | 73 | * @tmu_intstat: Register containing the interrupt status values. |
74 | * @tmu_intclear: Register for clearing the raised interrupt status. | 74 | * @tmu_intclear: Register for clearing the raised interrupt status. |
75 | * @emul_con: TMU emulation controller register. | ||
76 | */ | 75 | */ |
77 | struct exynos_tmu_registers { | 76 | struct exynos_tmu_registers { |
78 | u32 tmu_intstat; | 77 | u32 tmu_intstat; |
79 | u32 tmu_intclear; | 78 | u32 tmu_intclear; |
80 | u32 emul_con; | ||
81 | }; | 79 | }; |
82 | 80 | ||
83 | /** | 81 | /** |
diff --git a/drivers/thermal/samsung/exynos_tmu_data.c b/drivers/thermal/samsung/exynos_tmu_data.c index 769b89d7d641..d0bb4b35d0b9 100644 --- a/drivers/thermal/samsung/exynos_tmu_data.c +++ b/drivers/thermal/samsung/exynos_tmu_data.c | |||
@@ -75,7 +75,6 @@ struct exynos_tmu_init_data const exynos4210_default_tmu_data = { | |||
75 | static const struct exynos_tmu_registers exynos3250_tmu_registers = { | 75 | static const struct exynos_tmu_registers exynos3250_tmu_registers = { |
76 | .tmu_intstat = EXYNOS_TMU_REG_INTSTAT, | 76 | .tmu_intstat = EXYNOS_TMU_REG_INTSTAT, |
77 | .tmu_intclear = EXYNOS_TMU_REG_INTCLEAR, | 77 | .tmu_intclear = EXYNOS_TMU_REG_INTCLEAR, |
78 | .emul_con = EXYNOS_EMUL_CON, | ||
79 | }; | 78 | }; |
80 | 79 | ||
81 | #define EXYNOS3250_TMU_DATA \ | 80 | #define EXYNOS3250_TMU_DATA \ |
@@ -135,7 +134,6 @@ struct exynos_tmu_init_data const exynos3250_default_tmu_data = { | |||
135 | static const struct exynos_tmu_registers exynos4412_tmu_registers = { | 134 | static const struct exynos_tmu_registers exynos4412_tmu_registers = { |
136 | .tmu_intstat = EXYNOS_TMU_REG_INTSTAT, | 135 | .tmu_intstat = EXYNOS_TMU_REG_INTSTAT, |
137 | .tmu_intclear = EXYNOS_TMU_REG_INTCLEAR, | 136 | .tmu_intclear = EXYNOS_TMU_REG_INTCLEAR, |
138 | .emul_con = EXYNOS_EMUL_CON, | ||
139 | }; | 137 | }; |
140 | 138 | ||
141 | #define EXYNOS4412_TMU_DATA \ | 139 | #define EXYNOS4412_TMU_DATA \ |
@@ -207,7 +205,6 @@ struct exynos_tmu_init_data const exynos5250_default_tmu_data = { | |||
207 | static const struct exynos_tmu_registers exynos5260_tmu_registers = { | 205 | static const struct exynos_tmu_registers exynos5260_tmu_registers = { |
208 | .tmu_intstat = EXYNOS5260_TMU_REG_INTSTAT, | 206 | .tmu_intstat = EXYNOS5260_TMU_REG_INTSTAT, |
209 | .tmu_intclear = EXYNOS5260_TMU_REG_INTCLEAR, | 207 | .tmu_intclear = EXYNOS5260_TMU_REG_INTCLEAR, |
210 | .emul_con = EXYNOS5260_EMUL_CON, | ||
211 | }; | 208 | }; |
212 | 209 | ||
213 | #define __EXYNOS5260_TMU_DATA \ | 210 | #define __EXYNOS5260_TMU_DATA \ |
@@ -269,7 +266,6 @@ struct exynos_tmu_init_data const exynos5260_default_tmu_data = { | |||
269 | static const struct exynos_tmu_registers exynos5420_tmu_registers = { | 266 | static const struct exynos_tmu_registers exynos5420_tmu_registers = { |
270 | .tmu_intstat = EXYNOS_TMU_REG_INTSTAT, | 267 | .tmu_intstat = EXYNOS_TMU_REG_INTSTAT, |
271 | .tmu_intclear = EXYNOS_TMU_REG_INTCLEAR, | 268 | .tmu_intclear = EXYNOS_TMU_REG_INTCLEAR, |
272 | .emul_con = EXYNOS_EMUL_CON, | ||
273 | }; | 269 | }; |
274 | 270 | ||
275 | #define __EXYNOS5420_TMU_DATA \ | 271 | #define __EXYNOS5420_TMU_DATA \ |
@@ -337,7 +333,6 @@ struct exynos_tmu_init_data const exynos5420_default_tmu_data = { | |||
337 | static const struct exynos_tmu_registers exynos5440_tmu_registers = { | 333 | static const struct exynos_tmu_registers exynos5440_tmu_registers = { |
338 | .tmu_intstat = EXYNOS5440_TMU_S0_7_IRQ, | 334 | .tmu_intstat = EXYNOS5440_TMU_S0_7_IRQ, |
339 | .tmu_intclear = EXYNOS5440_TMU_S0_7_IRQ, | 335 | .tmu_intclear = EXYNOS5440_TMU_S0_7_IRQ, |
340 | .emul_con = EXYNOS5440_TMU_S0_7_DEBUG, | ||
341 | }; | 336 | }; |
342 | 337 | ||
343 | #define EXYNOS5440_TMU_DATA \ | 338 | #define EXYNOS5440_TMU_DATA \ |