diff options
author | Amit Daniel Kachhap <amit.daniel@samsung.com> | 2013-06-24 06:50:40 -0400 |
---|---|---|
committer | Eduardo Valentin <eduardo.valentin@ti.com> | 2013-08-13 09:52:02 -0400 |
commit | f4dae7532c33380aa23ddcf83d0260bfdee48549 (patch) | |
tree | de012e848e942b51edaa597190d8f76aba458177 /drivers/thermal | |
parent | cebe7373a7e659d29e939ed2ce379b478684793c (diff) |
thermal: exynos: Add TMU features to check instead of using SOC type
This patch adds several features supported by TMU as bitfields.
This features varies across different SOC type and comparing
the features present in the TMU is more logical than comparing
the soc itself.
Acked-by: Kukjin Kim <kgene.kim@samsung.com>
Acked-by: Jonghwa Lee <jonghwa3.lee@samsung.com>
Acked-by: Eduardo Valentin <eduardo.valentin@ti.com>
Signed-off-by: Amit Daniel Kachhap <amit.daniel@samsung.com>
Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
Diffstat (limited to 'drivers/thermal')
-rw-r--r-- | drivers/thermal/samsung/exynos_tmu.c | 26 | ||||
-rw-r--r-- | drivers/thermal/samsung/exynos_tmu.h | 31 | ||||
-rw-r--r-- | drivers/thermal/samsung/exynos_tmu_data.c | 6 |
3 files changed, 52 insertions, 11 deletions
diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index 7f65fe088d24..05b95c6bb95b 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c | |||
@@ -142,13 +142,15 @@ static int exynos_tmu_initialize(struct platform_device *pdev) | |||
142 | mutex_lock(&data->lock); | 142 | mutex_lock(&data->lock); |
143 | clk_enable(data->clk); | 143 | clk_enable(data->clk); |
144 | 144 | ||
145 | status = readb(data->base + reg->tmu_status); | 145 | if (TMU_SUPPORTS(pdata, READY_STATUS)) { |
146 | if (!status) { | 146 | status = readb(data->base + reg->tmu_status); |
147 | ret = -EBUSY; | 147 | if (!status) { |
148 | goto out; | 148 | ret = -EBUSY; |
149 | goto out; | ||
150 | } | ||
149 | } | 151 | } |
150 | 152 | ||
151 | if (data->soc == SOC_ARCH_EXYNOS) | 153 | if (TMU_SUPPORTS(pdata, TRIM_RELOAD)) |
152 | __raw_writel(1, data->base + reg->triminfo_ctrl); | 154 | __raw_writel(1, data->base + reg->triminfo_ctrl); |
153 | 155 | ||
154 | /* Save trimming info in order to perform calibration */ | 156 | /* Save trimming info in order to perform calibration */ |
@@ -287,7 +289,7 @@ static void exynos_tmu_control(struct platform_device *pdev, bool on) | |||
287 | pdata->trigger_enable[2] << reg->inten_rise2_shift | | 289 | pdata->trigger_enable[2] << reg->inten_rise2_shift | |
288 | pdata->trigger_enable[1] << reg->inten_rise1_shift | | 290 | pdata->trigger_enable[1] << reg->inten_rise1_shift | |
289 | pdata->trigger_enable[0] << reg->inten_rise0_shift; | 291 | pdata->trigger_enable[0] << reg->inten_rise0_shift; |
290 | if (pdata->threshold_falling) | 292 | if (TMU_SUPPORTS(pdata, FALLING_TRIP)) |
291 | interrupt_en |= | 293 | interrupt_en |= |
292 | interrupt_en << reg->inten_fall0_shift; | 294 | interrupt_en << reg->inten_fall0_shift; |
293 | } else { | 295 | } else { |
@@ -329,7 +331,7 @@ static int exynos_tmu_set_emulation(void *drv_data, unsigned long temp) | |||
329 | unsigned int val; | 331 | unsigned int val; |
330 | int ret = -EINVAL; | 332 | int ret = -EINVAL; |
331 | 333 | ||
332 | if (data->soc == SOC_ARCH_EXYNOS4210) | 334 | if (!TMU_SUPPORTS(pdata, EMULATION)) |
333 | goto out; | 335 | goto out; |
334 | 336 | ||
335 | if (temp && temp < MCELSIUS) | 337 | if (temp && temp < MCELSIUS) |
@@ -343,9 +345,13 @@ static int exynos_tmu_set_emulation(void *drv_data, unsigned long temp) | |||
343 | if (temp) { | 345 | if (temp) { |
344 | temp /= MCELSIUS; | 346 | temp /= MCELSIUS; |
345 | 347 | ||
346 | val = (EXYNOS_EMUL_TIME << reg->emul_time_shift) | | 348 | if (TMU_SUPPORTS(pdata, EMUL_TIME)) { |
347 | (temp_to_code(data, temp) | 349 | val &= ~(EXYNOS_EMUL_TIME_MASK << reg->emul_time_shift); |
348 | << reg->emul_temp_shift) | EXYNOS_EMUL_ENABLE; | 350 | val |= (EXYNOS_EMUL_TIME << reg->emul_time_shift); |
351 | } | ||
352 | val &= ~(EXYNOS_EMUL_DATA_MASK << reg->emul_temp_shift); | ||
353 | val |= (temp_to_code(data, temp) << reg->emul_temp_shift) | | ||
354 | EXYNOS_EMUL_ENABLE; | ||
349 | } else { | 355 | } else { |
350 | val &= ~EXYNOS_EMUL_ENABLE; | 356 | val &= ~EXYNOS_EMUL_ENABLE; |
351 | } | 357 | } |
diff --git a/drivers/thermal/samsung/exynos_tmu.h b/drivers/thermal/samsung/exynos_tmu.h index 53fa7024090a..ff8844f3b99b 100644 --- a/drivers/thermal/samsung/exynos_tmu.h +++ b/drivers/thermal/samsung/exynos_tmu.h | |||
@@ -43,6 +43,34 @@ enum soc_type { | |||
43 | }; | 43 | }; |
44 | 44 | ||
45 | /** | 45 | /** |
46 | * EXYNOS TMU supported features. | ||
47 | * TMU_SUPPORT_EMULATION - This features is used to set user defined | ||
48 | * temperature to the TMU controller. | ||
49 | * TMU_SUPPORT_MULTI_INST - This features denotes that the soc | ||
50 | * has many instances of TMU. | ||
51 | * TMU_SUPPORT_TRIM_RELOAD - This features shows that trimming can | ||
52 | * be reloaded. | ||
53 | * TMU_SUPPORT_FALLING_TRIP - This features shows that interrupt can | ||
54 | * be registered for falling trips also. | ||
55 | * TMU_SUPPORT_READY_STATUS - This feature tells that the TMU current | ||
56 | * state(active/idle) can be checked. | ||
57 | * TMU_SUPPORT_EMUL_TIME - This features allows to set next temp emulation | ||
58 | * sample time. | ||
59 | * TMU_SUPPORT_SHARED_MEMORY - This feature tells that the different TMU | ||
60 | * sensors shares some common registers. | ||
61 | * TMU_SUPPORT - macro to compare the above features with the supplied. | ||
62 | */ | ||
63 | #define TMU_SUPPORT_EMULATION BIT(0) | ||
64 | #define TMU_SUPPORT_MULTI_INST BIT(1) | ||
65 | #define TMU_SUPPORT_TRIM_RELOAD BIT(2) | ||
66 | #define TMU_SUPPORT_FALLING_TRIP BIT(3) | ||
67 | #define TMU_SUPPORT_READY_STATUS BIT(4) | ||
68 | #define TMU_SUPPORT_EMUL_TIME BIT(5) | ||
69 | #define TMU_SUPPORT_SHARED_MEMORY BIT(6) | ||
70 | |||
71 | #define TMU_SUPPORTS(a, b) (a->features & TMU_SUPPORT_ ## b) | ||
72 | |||
73 | /** | ||
46 | * struct exynos_tmu_register - register descriptors to access registers and | 74 | * struct exynos_tmu_register - register descriptors to access registers and |
47 | * bitfields. The register validity, offsets and bitfield values may vary | 75 | * bitfields. The register validity, offsets and bitfield values may vary |
48 | * slightly across different exynos SOC's. | 76 | * slightly across different exynos SOC's. |
@@ -222,6 +250,8 @@ struct exynos_tmu_registers { | |||
222 | * applicable to only some of the trigger levels. | 250 | * applicable to only some of the trigger levels. |
223 | * @registers: Pointer to structure containing all the TMU controller registers | 251 | * @registers: Pointer to structure containing all the TMU controller registers |
224 | * and bitfields shifts and masks. | 252 | * and bitfields shifts and masks. |
253 | * @features: a bitfield value indicating the features supported in SOC like | ||
254 | * emulation, multi instance etc | ||
225 | * | 255 | * |
226 | * This structure is required for configuration of exynos_tmu driver. | 256 | * This structure is required for configuration of exynos_tmu driver. |
227 | */ | 257 | */ |
@@ -249,6 +279,7 @@ struct exynos_tmu_platform_data { | |||
249 | struct freq_clip_table freq_tab[4]; | 279 | struct freq_clip_table freq_tab[4]; |
250 | unsigned int freq_tab_count; | 280 | unsigned int freq_tab_count; |
251 | const struct exynos_tmu_registers *registers; | 281 | const struct exynos_tmu_registers *registers; |
282 | unsigned int features; | ||
252 | }; | 283 | }; |
253 | 284 | ||
254 | /** | 285 | /** |
diff --git a/drivers/thermal/samsung/exynos_tmu_data.c b/drivers/thermal/samsung/exynos_tmu_data.c index a5c25b4bb0c0..2612b452dafd 100644 --- a/drivers/thermal/samsung/exynos_tmu_data.c +++ b/drivers/thermal/samsung/exynos_tmu_data.c | |||
@@ -83,6 +83,7 @@ struct exynos_tmu_init_data const exynos4210_default_tmu_data = { | |||
83 | .freq_tab_count = 2, | 83 | .freq_tab_count = 2, |
84 | .type = SOC_ARCH_EXYNOS4210, | 84 | .type = SOC_ARCH_EXYNOS4210, |
85 | .registers = &exynos4210_tmu_registers, | 85 | .registers = &exynos4210_tmu_registers, |
86 | .features = TMU_SUPPORT_READY_STATUS, | ||
86 | }, | 87 | }, |
87 | }, | 88 | }, |
88 | .tmu_count = 1, | 89 | .tmu_count = 1, |
@@ -162,7 +163,10 @@ static const struct exynos_tmu_registers exynos5250_tmu_registers = { | |||
162 | }, \ | 163 | }, \ |
163 | .freq_tab_count = 2, \ | 164 | .freq_tab_count = 2, \ |
164 | .type = SOC_ARCH_EXYNOS, \ | 165 | .type = SOC_ARCH_EXYNOS, \ |
165 | .registers = &exynos5250_tmu_registers, | 166 | .registers = &exynos5250_tmu_registers, \ |
167 | .features = (TMU_SUPPORT_EMULATION | TMU_SUPPORT_TRIM_RELOAD | \ | ||
168 | TMU_SUPPORT_FALLING_TRIP | TMU_SUPPORT_READY_STATUS | \ | ||
169 | TMU_SUPPORT_EMUL_TIME) | ||
166 | 170 | ||
167 | struct exynos_tmu_init_data const exynos5250_default_tmu_data = { | 171 | struct exynos_tmu_init_data const exynos5250_default_tmu_data = { |
168 | .tmu_data = { | 172 | .tmu_data = { |