exynos_tmu.c (930aa102e2b0ba70ea420999362e2edc4fda15d3) exynos_tmu.c (8131a246600f0c34a71cbe1a2e4a19af7e9bc887)
1/*
2 * exynos_tmu.c - Samsung EXYNOS TMU (Thermal Management Unit)
3 *
4 * Copyright (C) 2011 Samsung Electronics
5 * Donggeun Kim <dg77.kim@samsung.com>
6 * Amit Daniel Kachhap <amit.kachhap@linaro.org>
7 *
8 * This program is free software; you can redistribute it and/or modify

--- 201 unchanged lines hidden (view full) ---

210 trigger_levs++;
211 }
212
213 rising_threshold = readl(data->base + reg->threshold_th0);
214
215 if (data->soc == SOC_ARCH_EXYNOS4210) {
216 /* Write temperature code for threshold */
217 threshold_code = temp_to_code(data, pdata->threshold);
1/*
2 * exynos_tmu.c - Samsung EXYNOS TMU (Thermal Management Unit)
3 *
4 * Copyright (C) 2011 Samsung Electronics
5 * Donggeun Kim <dg77.kim@samsung.com>
6 * Amit Daniel Kachhap <amit.kachhap@linaro.org>
7 *
8 * This program is free software; you can redistribute it and/or modify

--- 201 unchanged lines hidden (view full) ---

210 trigger_levs++;
211 }
212
213 rising_threshold = readl(data->base + reg->threshold_th0);
214
215 if (data->soc == SOC_ARCH_EXYNOS4210) {
216 /* Write temperature code for threshold */
217 threshold_code = temp_to_code(data, pdata->threshold);
218 if (threshold_code < 0) {
219 ret = threshold_code;
220 goto out;
221 }
222 writeb(threshold_code,
223 data->base + reg->threshold_temp);
224 for (i = 0; i < trigger_levs; i++)
225 writeb(pdata->trigger_levels[i], data->base +
226 reg->threshold_th0 + i * sizeof(reg->threshold_th0));
227
228 writel(reg->intclr_rise_mask, data->base + reg->tmu_intclear);
229 } else {
230 /* Write temperature code for rising and falling threshold */
231 for (i = 0;
232 i < trigger_levs && i < EXYNOS_MAX_TRIGGER_PER_REG; i++) {
233 threshold_code = temp_to_code(data,
234 pdata->trigger_levels[i]);
218 writeb(threshold_code,
219 data->base + reg->threshold_temp);
220 for (i = 0; i < trigger_levs; i++)
221 writeb(pdata->trigger_levels[i], data->base +
222 reg->threshold_th0 + i * sizeof(reg->threshold_th0));
223
224 writel(reg->intclr_rise_mask, data->base + reg->tmu_intclear);
225 } else {
226 /* Write temperature code for rising and falling threshold */
227 for (i = 0;
228 i < trigger_levs && i < EXYNOS_MAX_TRIGGER_PER_REG; i++) {
229 threshold_code = temp_to_code(data,
230 pdata->trigger_levels[i]);
235 if (threshold_code < 0) {
236 ret = threshold_code;
237 goto out;
238 }
239 rising_threshold &= ~(0xff << 8 * i);
240 rising_threshold |= threshold_code << 8 * i;
241 if (pdata->threshold_falling) {
242 threshold_code = temp_to_code(data,
243 pdata->trigger_levels[i] -
244 pdata->threshold_falling);
231 rising_threshold &= ~(0xff << 8 * i);
232 rising_threshold |= threshold_code << 8 * i;
233 if (pdata->threshold_falling) {
234 threshold_code = temp_to_code(data,
235 pdata->trigger_levels[i] -
236 pdata->threshold_falling);
245 if (threshold_code > 0)
246 falling_threshold |=
247 threshold_code << 8 * i;
237 falling_threshold |= threshold_code << 8 * i;
248 }
249 }
250
251 writel(rising_threshold,
252 data->base + reg->threshold_th0);
253 writel(falling_threshold,
254 data->base + reg->threshold_th1);
255
256 writel((reg->intclr_rise_mask << reg->intclr_rise_shift) |
257 (reg->intclr_fall_mask << reg->intclr_fall_shift),
258 data->base + reg->tmu_intclear);
259
260 /* if last threshold limit is also present */
261 i = pdata->max_trigger_level - 1;
262 if (pdata->trigger_levels[i] &&
263 (pdata->trigger_type[i] == HW_TRIP)) {
264 threshold_code = temp_to_code(data,
265 pdata->trigger_levels[i]);
238 }
239 }
240
241 writel(rising_threshold,
242 data->base + reg->threshold_th0);
243 writel(falling_threshold,
244 data->base + reg->threshold_th1);
245
246 writel((reg->intclr_rise_mask << reg->intclr_rise_shift) |
247 (reg->intclr_fall_mask << reg->intclr_fall_shift),
248 data->base + reg->tmu_intclear);
249
250 /* if last threshold limit is also present */
251 i = pdata->max_trigger_level - 1;
252 if (pdata->trigger_levels[i] &&
253 (pdata->trigger_type[i] == HW_TRIP)) {
254 threshold_code = temp_to_code(data,
255 pdata->trigger_levels[i]);
266 if (threshold_code < 0) {
267 ret = threshold_code;
268 goto out;
269 }
270 if (i == EXYNOS_MAX_TRIGGER_PER_REG - 1) {
271 /* 1-4 level to be assigned in th0 reg */
272 rising_threshold &= ~(0xff << 8 * i);
273 rising_threshold |= threshold_code << 8 * i;
274 writel(rising_threshold,
275 data->base + reg->threshold_th0);
276 } else if (i == EXYNOS_MAX_TRIGGER_PER_REG) {
277 /* 5th level to be assigned in th2 reg */

--- 501 unchanged lines hidden ---
256 if (i == EXYNOS_MAX_TRIGGER_PER_REG - 1) {
257 /* 1-4 level to be assigned in th0 reg */
258 rising_threshold &= ~(0xff << 8 * i);
259 rising_threshold |= threshold_code << 8 * i;
260 writel(rising_threshold,
261 data->base + reg->threshold_th0);
262 } else if (i == EXYNOS_MAX_TRIGGER_PER_REG) {
263 /* 5th level to be assigned in th2 reg */

--- 501 unchanged lines hidden ---