aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmit Daniel Kachhap <amit.daniel@samsung.com>2013-06-24 06:50:32 -0400
committerEduardo Valentin <eduardo.valentin@ti.com>2013-08-13 09:52:01 -0400
commit7ca04e587ee5d391fecd477f9a3dd725c3e21f23 (patch)
tree739059dc7730144ffbf2b998ddeab65fc7f33532
parentb8d582b9405c75506f4adff9abd4afbe7b698b61 (diff)
thermal: exynos: Support thermal tripping
TMU urgently sends active-high signal (thermal trip) to PMU, and thermal tripping by hardware logic. Thermal tripping means that PMU cuts off the whole power of SoC by controlling external voltage regulator. 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: Jonghwan Choi <jhbird.choi@samsung.com> Signed-off-by: Amit Daniel Kachhap <amit.daniel@samsung.com> Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
-rw-r--r--drivers/thermal/samsung/exynos_tmu.c45
-rw-r--r--drivers/thermal/samsung/exynos_tmu_data.c2
-rw-r--r--drivers/thermal/samsung/exynos_tmu_data.h2
3 files changed, 44 insertions, 5 deletions
diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index 6fd776f41ebc..33f494ea1ed1 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -117,7 +117,7 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
117 struct exynos_tmu_data *data = platform_get_drvdata(pdev); 117 struct exynos_tmu_data *data = platform_get_drvdata(pdev);
118 struct exynos_tmu_platform_data *pdata = data->pdata; 118 struct exynos_tmu_platform_data *pdata = data->pdata;
119 const struct exynos_tmu_registers *reg = pdata->registers; 119 const struct exynos_tmu_registers *reg = pdata->registers;
120 unsigned int status, trim_info; 120 unsigned int status, trim_info = 0, con;
121 unsigned int rising_threshold = 0, falling_threshold = 0; 121 unsigned int rising_threshold = 0, falling_threshold = 0;
122 int ret = 0, threshold_code, i, trigger_levs = 0; 122 int ret = 0, threshold_code, i, trigger_levs = 0;
123 123
@@ -144,10 +144,26 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
144 (data->temp_error2 != 0)) 144 (data->temp_error2 != 0))
145 data->temp_error1 = pdata->efuse_value; 145 data->temp_error1 = pdata->efuse_value;
146 146
147 /* Count trigger levels to be enabled */ 147 if (pdata->max_trigger_level > MAX_THRESHOLD_LEVS) {
148 for (i = 0; i < MAX_THRESHOLD_LEVS; i++) 148 dev_err(&pdev->dev, "Invalid max trigger level\n");
149 if (pdata->trigger_levels[i]) 149 goto out;
150 }
151
152 for (i = 0; i < pdata->max_trigger_level; i++) {
153 if (!pdata->trigger_levels[i])
154 continue;
155
156 if ((pdata->trigger_type[i] == HW_TRIP) &&
157 (!pdata->trigger_levels[pdata->max_trigger_level - 1])) {
158 dev_err(&pdev->dev, "Invalid hw trigger level\n");
159 ret = -EINVAL;
160 goto out;
161 }
162
163 /* Count trigger levels except the HW trip*/
164 if (!(pdata->trigger_type[i] == HW_TRIP))
150 trigger_levs++; 165 trigger_levs++;
166 }
151 167
152 if (data->soc == SOC_ARCH_EXYNOS4210) { 168 if (data->soc == SOC_ARCH_EXYNOS4210) {
153 /* Write temperature code for threshold */ 169 /* Write temperature code for threshold */
@@ -165,7 +181,8 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
165 writel(reg->inten_rise_mask, data->base + reg->tmu_intclear); 181 writel(reg->inten_rise_mask, data->base + reg->tmu_intclear);
166 } else if (data->soc == SOC_ARCH_EXYNOS) { 182 } else if (data->soc == SOC_ARCH_EXYNOS) {
167 /* Write temperature code for rising and falling threshold */ 183 /* Write temperature code for rising and falling threshold */
168 for (i = 0; i < trigger_levs; i++) { 184 for (i = 0;
185 i < trigger_levs && i < EXYNOS_MAX_TRIGGER_PER_REG; i++) {
169 threshold_code = temp_to_code(data, 186 threshold_code = temp_to_code(data,
170 pdata->trigger_levels[i]); 187 pdata->trigger_levels[i]);
171 if (threshold_code < 0) { 188 if (threshold_code < 0) {
@@ -191,6 +208,24 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
191 writel((reg->inten_rise_mask << reg->inten_rise_shift) | 208 writel((reg->inten_rise_mask << reg->inten_rise_shift) |
192 (reg->inten_fall_mask << reg->inten_fall_shift), 209 (reg->inten_fall_mask << reg->inten_fall_shift),
193 data->base + reg->tmu_intclear); 210 data->base + reg->tmu_intclear);
211
212 /* if last threshold limit is also present */
213 i = pdata->max_trigger_level - 1;
214 if (pdata->trigger_levels[i] &&
215 (pdata->trigger_type[i] == HW_TRIP)) {
216 threshold_code = temp_to_code(data,
217 pdata->trigger_levels[i]);
218 if (threshold_code < 0) {
219 ret = threshold_code;
220 goto out;
221 }
222 rising_threshold |= threshold_code << 8 * i;
223 writel(rising_threshold,
224 data->base + reg->threshold_th0);
225 con = readl(data->base + reg->tmu_ctrl);
226 con |= (1 << reg->therm_trip_en_shift);
227 writel(con, data->base + reg->tmu_ctrl);
228 }
194 } 229 }
195out: 230out:
196 clk_disable(data->clk); 231 clk_disable(data->clk);
diff --git a/drivers/thermal/samsung/exynos_tmu_data.c b/drivers/thermal/samsung/exynos_tmu_data.c
index 896aa2ac0bb4..6cac39310881 100644
--- a/drivers/thermal/samsung/exynos_tmu_data.c
+++ b/drivers/thermal/samsung/exynos_tmu_data.c
@@ -123,6 +123,7 @@ struct exynos_tmu_platform_data const exynos5250_default_tmu_data = {
123 .trigger_levels[0] = 85, 123 .trigger_levels[0] = 85,
124 .trigger_levels[1] = 103, 124 .trigger_levels[1] = 103,
125 .trigger_levels[2] = 110, 125 .trigger_levels[2] = 110,
126 .trigger_levels[3] = 120,
126 .trigger_enable[0] = true, 127 .trigger_enable[0] = true,
127 .trigger_enable[1] = true, 128 .trigger_enable[1] = true,
128 .trigger_enable[2] = true, 129 .trigger_enable[2] = true,
@@ -130,6 +131,7 @@ struct exynos_tmu_platform_data const exynos5250_default_tmu_data = {
130 .trigger_type[0] = THROTTLE_ACTIVE, 131 .trigger_type[0] = THROTTLE_ACTIVE,
131 .trigger_type[1] = THROTTLE_ACTIVE, 132 .trigger_type[1] = THROTTLE_ACTIVE,
132 .trigger_type[2] = SW_TRIP, 133 .trigger_type[2] = SW_TRIP,
134 .trigger_type[3] = HW_TRIP,
133 .max_trigger_level = 4, 135 .max_trigger_level = 4,
134 .gain = 8, 136 .gain = 8,
135 .reference_voltage = 16, 137 .reference_voltage = 16,
diff --git a/drivers/thermal/samsung/exynos_tmu_data.h b/drivers/thermal/samsung/exynos_tmu_data.h
index 0e2244fb8bd1..4acf070c4817 100644
--- a/drivers/thermal/samsung/exynos_tmu_data.h
+++ b/drivers/thermal/samsung/exynos_tmu_data.h
@@ -91,6 +91,8 @@
91#define EXYNOS_EMUL_DATA_MASK 0xFF 91#define EXYNOS_EMUL_DATA_MASK 0xFF
92#define EXYNOS_EMUL_ENABLE 0x1 92#define EXYNOS_EMUL_ENABLE 0x1
93 93
94#define EXYNOS_MAX_TRIGGER_PER_REG 4
95
94#if defined(CONFIG_CPU_EXYNOS4210) 96#if defined(CONFIG_CPU_EXYNOS4210)
95extern struct exynos_tmu_platform_data const exynos4210_default_tmu_data; 97extern struct exynos_tmu_platform_data const exynos4210_default_tmu_data;
96#define EXYNOS4210_TMU_DRV_DATA (&exynos4210_default_tmu_data) 98#define EXYNOS4210_TMU_DRV_DATA (&exynos4210_default_tmu_data)