Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 1 | /* |
Amit Daniel Kachhap | c48cbba | 2012-08-16 17:11:41 +0530 | [diff] [blame] | 2 | * exynos_thermal.c - Samsung EXYNOS TMU (Thermal Management Unit) |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 2011 Samsung Electronics |
| 5 | * Donggeun Kim <dg77.kim@samsung.com> |
Amit Daniel Kachhap | c48cbba | 2012-08-16 17:11:41 +0530 | [diff] [blame] | 6 | * Amit Daniel Kachhap <amit.kachhap@linaro.org> |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 21 | * |
| 22 | */ |
| 23 | |
| 24 | #include <linux/module.h> |
| 25 | #include <linux/err.h> |
| 26 | #include <linux/kernel.h> |
| 27 | #include <linux/slab.h> |
| 28 | #include <linux/platform_device.h> |
| 29 | #include <linux/interrupt.h> |
| 30 | #include <linux/clk.h> |
| 31 | #include <linux/workqueue.h> |
| 32 | #include <linux/sysfs.h> |
| 33 | #include <linux/kobject.h> |
| 34 | #include <linux/io.h> |
| 35 | #include <linux/mutex.h> |
Amit Daniel Kachhap | c48cbba | 2012-08-16 17:11:41 +0530 | [diff] [blame] | 36 | #include <linux/platform_data/exynos_thermal.h> |
Amit Daniel Kachhap | 7e0b55e | 2012-08-16 17:11:43 +0530 | [diff] [blame] | 37 | #include <linux/thermal.h> |
| 38 | #include <linux/cpufreq.h> |
| 39 | #include <linux/cpu_cooling.h> |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 40 | #include <linux/of.h> |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 41 | |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 42 | #include <plat/cpu.h> |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 43 | |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 44 | /* Exynos generic registers */ |
| 45 | #define EXYNOS_TMU_REG_TRIMINFO 0x0 |
| 46 | #define EXYNOS_TMU_REG_CONTROL 0x20 |
| 47 | #define EXYNOS_TMU_REG_STATUS 0x28 |
| 48 | #define EXYNOS_TMU_REG_CURRENT_TEMP 0x40 |
| 49 | #define EXYNOS_TMU_REG_INTEN 0x70 |
| 50 | #define EXYNOS_TMU_REG_INTSTAT 0x74 |
| 51 | #define EXYNOS_TMU_REG_INTCLEAR 0x78 |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 52 | |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 53 | #define EXYNOS_TMU_TRIM_TEMP_MASK 0xff |
| 54 | #define EXYNOS_TMU_GAIN_SHIFT 8 |
| 55 | #define EXYNOS_TMU_REF_VOLTAGE_SHIFT 24 |
| 56 | #define EXYNOS_TMU_CORE_ON 3 |
| 57 | #define EXYNOS_TMU_CORE_OFF 2 |
| 58 | #define EXYNOS_TMU_DEF_CODE_TO_TEMP_OFFSET 50 |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 59 | |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 60 | /* Exynos4210 specific registers */ |
| 61 | #define EXYNOS4210_TMU_REG_THRESHOLD_TEMP 0x44 |
| 62 | #define EXYNOS4210_TMU_REG_TRIG_LEVEL0 0x50 |
| 63 | #define EXYNOS4210_TMU_REG_TRIG_LEVEL1 0x54 |
| 64 | #define EXYNOS4210_TMU_REG_TRIG_LEVEL2 0x58 |
| 65 | #define EXYNOS4210_TMU_REG_TRIG_LEVEL3 0x5C |
| 66 | #define EXYNOS4210_TMU_REG_PAST_TEMP0 0x60 |
| 67 | #define EXYNOS4210_TMU_REG_PAST_TEMP1 0x64 |
| 68 | #define EXYNOS4210_TMU_REG_PAST_TEMP2 0x68 |
| 69 | #define EXYNOS4210_TMU_REG_PAST_TEMP3 0x6C |
| 70 | |
| 71 | #define EXYNOS4210_TMU_TRIG_LEVEL0_MASK 0x1 |
| 72 | #define EXYNOS4210_TMU_TRIG_LEVEL1_MASK 0x10 |
| 73 | #define EXYNOS4210_TMU_TRIG_LEVEL2_MASK 0x100 |
| 74 | #define EXYNOS4210_TMU_TRIG_LEVEL3_MASK 0x1000 |
| 75 | #define EXYNOS4210_TMU_INTCLEAR_VAL 0x1111 |
| 76 | |
| 77 | /* Exynos5250 and Exynos4412 specific registers */ |
| 78 | #define EXYNOS_TMU_TRIMINFO_CON 0x14 |
| 79 | #define EXYNOS_THD_TEMP_RISE 0x50 |
| 80 | #define EXYNOS_THD_TEMP_FALL 0x54 |
| 81 | #define EXYNOS_EMUL_CON 0x80 |
| 82 | |
| 83 | #define EXYNOS_TRIMINFO_RELOAD 0x1 |
| 84 | #define EXYNOS_TMU_CLEAR_RISE_INT 0x111 |
Amit Daniel Kachhap | 3ad9524 | 2013-01-17 01:42:18 +0000 | [diff] [blame] | 85 | #define EXYNOS_TMU_CLEAR_FALL_INT (0x111 << 12) |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 86 | #define EXYNOS_MUX_ADDR_VALUE 6 |
| 87 | #define EXYNOS_MUX_ADDR_SHIFT 20 |
| 88 | #define EXYNOS_TMU_TRIP_MODE_SHIFT 13 |
| 89 | |
| 90 | #define EFUSE_MIN_VALUE 40 |
| 91 | #define EFUSE_MAX_VALUE 100 |
| 92 | |
| 93 | /* In-kernel thermal framework related macros & definations */ |
| 94 | #define SENSOR_NAME_LEN 16 |
| 95 | #define MAX_TRIP_COUNT 8 |
| 96 | #define MAX_COOLING_DEVICE 4 |
Jonghwa Lee | 4f0a684 | 2013-02-08 01:13:06 +0000 | [diff] [blame] | 97 | #define MAX_THRESHOLD_LEVS 4 |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 98 | |
| 99 | #define ACTIVE_INTERVAL 500 |
| 100 | #define IDLE_INTERVAL 10000 |
Amit Daniel Kachhap | 7e0b55e | 2012-08-16 17:11:43 +0530 | [diff] [blame] | 101 | #define MCELSIUS 1000 |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 102 | |
Jonghwa Lee | bbf63be | 2012-11-21 13:31:01 +0900 | [diff] [blame] | 103 | #ifdef CONFIG_EXYNOS_THERMAL_EMUL |
| 104 | #define EXYNOS_EMUL_TIME 0x57F0 |
| 105 | #define EXYNOS_EMUL_TIME_SHIFT 16 |
| 106 | #define EXYNOS_EMUL_DATA_SHIFT 8 |
| 107 | #define EXYNOS_EMUL_DATA_MASK 0xFF |
| 108 | #define EXYNOS_EMUL_ENABLE 0x1 |
| 109 | #endif /* CONFIG_EXYNOS_THERMAL_EMUL */ |
| 110 | |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 111 | /* CPU Zone information */ |
| 112 | #define PANIC_ZONE 4 |
| 113 | #define WARN_ZONE 3 |
| 114 | #define MONITOR_ZONE 2 |
| 115 | #define SAFE_ZONE 1 |
| 116 | |
| 117 | #define GET_ZONE(trip) (trip + 2) |
| 118 | #define GET_TRIP(zone) (zone - 2) |
| 119 | |
Amit Daniel Kachhap | 7e0b55e | 2012-08-16 17:11:43 +0530 | [diff] [blame] | 120 | #define EXYNOS_ZONE_COUNT 3 |
| 121 | |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 122 | struct exynos_tmu_data { |
| 123 | struct exynos_tmu_platform_data *pdata; |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 124 | struct resource *mem; |
| 125 | void __iomem *base; |
| 126 | int irq; |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 127 | enum soc_type soc; |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 128 | struct work_struct irq_work; |
| 129 | struct mutex lock; |
| 130 | struct clk *clk; |
| 131 | u8 temp_error1, temp_error2; |
| 132 | }; |
| 133 | |
Amit Daniel Kachhap | 7e0b55e | 2012-08-16 17:11:43 +0530 | [diff] [blame] | 134 | struct thermal_trip_point_conf { |
| 135 | int trip_val[MAX_TRIP_COUNT]; |
| 136 | int trip_count; |
Jonghwa Lee | 4f0a684 | 2013-02-08 01:13:06 +0000 | [diff] [blame] | 137 | u8 trigger_falling; |
Amit Daniel Kachhap | 7e0b55e | 2012-08-16 17:11:43 +0530 | [diff] [blame] | 138 | }; |
| 139 | |
| 140 | struct thermal_cooling_conf { |
| 141 | struct freq_clip_table freq_data[MAX_TRIP_COUNT]; |
| 142 | int freq_clip_count; |
| 143 | }; |
| 144 | |
| 145 | struct thermal_sensor_conf { |
| 146 | char name[SENSOR_NAME_LEN]; |
| 147 | int (*read_temperature)(void *data); |
| 148 | struct thermal_trip_point_conf trip_data; |
| 149 | struct thermal_cooling_conf cooling_data; |
| 150 | void *private_data; |
| 151 | }; |
| 152 | |
| 153 | struct exynos_thermal_zone { |
| 154 | enum thermal_device_mode mode; |
| 155 | struct thermal_zone_device *therm_dev; |
| 156 | struct thermal_cooling_device *cool_dev[MAX_COOLING_DEVICE]; |
| 157 | unsigned int cool_dev_size; |
| 158 | struct platform_device *exynos4_dev; |
| 159 | struct thermal_sensor_conf *sensor_conf; |
| 160 | bool bind; |
| 161 | }; |
| 162 | |
| 163 | static struct exynos_thermal_zone *th_zone; |
| 164 | static void exynos_unregister_thermal(void); |
| 165 | static int exynos_register_thermal(struct thermal_sensor_conf *sensor_conf); |
| 166 | |
| 167 | /* Get mode callback functions for thermal zone */ |
| 168 | static int exynos_get_mode(struct thermal_zone_device *thermal, |
| 169 | enum thermal_device_mode *mode) |
| 170 | { |
| 171 | if (th_zone) |
| 172 | *mode = th_zone->mode; |
| 173 | return 0; |
| 174 | } |
| 175 | |
| 176 | /* Set mode callback functions for thermal zone */ |
| 177 | static int exynos_set_mode(struct thermal_zone_device *thermal, |
| 178 | enum thermal_device_mode mode) |
| 179 | { |
| 180 | if (!th_zone->therm_dev) { |
| 181 | pr_notice("thermal zone not registered\n"); |
| 182 | return 0; |
| 183 | } |
| 184 | |
| 185 | mutex_lock(&th_zone->therm_dev->lock); |
| 186 | |
Jonghwa Lee | 4f0a684 | 2013-02-08 01:13:06 +0000 | [diff] [blame] | 187 | if (mode == THERMAL_DEVICE_ENABLED && |
| 188 | !th_zone->sensor_conf->trip_data.trigger_falling) |
Amit Daniel Kachhap | 7e0b55e | 2012-08-16 17:11:43 +0530 | [diff] [blame] | 189 | th_zone->therm_dev->polling_delay = IDLE_INTERVAL; |
| 190 | else |
| 191 | th_zone->therm_dev->polling_delay = 0; |
| 192 | |
| 193 | mutex_unlock(&th_zone->therm_dev->lock); |
| 194 | |
| 195 | th_zone->mode = mode; |
| 196 | thermal_zone_device_update(th_zone->therm_dev); |
| 197 | pr_info("thermal polling set for duration=%d msec\n", |
| 198 | th_zone->therm_dev->polling_delay); |
| 199 | return 0; |
| 200 | } |
| 201 | |
| 202 | |
| 203 | /* Get trip type callback functions for thermal zone */ |
| 204 | static int exynos_get_trip_type(struct thermal_zone_device *thermal, int trip, |
| 205 | enum thermal_trip_type *type) |
| 206 | { |
| 207 | switch (GET_ZONE(trip)) { |
| 208 | case MONITOR_ZONE: |
| 209 | case WARN_ZONE: |
| 210 | *type = THERMAL_TRIP_ACTIVE; |
| 211 | break; |
| 212 | case PANIC_ZONE: |
| 213 | *type = THERMAL_TRIP_CRITICAL; |
| 214 | break; |
| 215 | default: |
| 216 | return -EINVAL; |
| 217 | } |
| 218 | return 0; |
| 219 | } |
| 220 | |
| 221 | /* Get trip temperature callback functions for thermal zone */ |
| 222 | static int exynos_get_trip_temp(struct thermal_zone_device *thermal, int trip, |
| 223 | unsigned long *temp) |
| 224 | { |
| 225 | if (trip < GET_TRIP(MONITOR_ZONE) || trip > GET_TRIP(PANIC_ZONE)) |
| 226 | return -EINVAL; |
| 227 | |
| 228 | *temp = th_zone->sensor_conf->trip_data.trip_val[trip]; |
| 229 | /* convert the temperature into millicelsius */ |
| 230 | *temp = *temp * MCELSIUS; |
| 231 | |
| 232 | return 0; |
| 233 | } |
| 234 | |
| 235 | /* Get critical temperature callback functions for thermal zone */ |
| 236 | static int exynos_get_crit_temp(struct thermal_zone_device *thermal, |
| 237 | unsigned long *temp) |
| 238 | { |
| 239 | int ret; |
| 240 | /* Panic zone */ |
| 241 | ret = exynos_get_trip_temp(thermal, GET_TRIP(PANIC_ZONE), temp); |
| 242 | return ret; |
| 243 | } |
| 244 | |
Amit Daniel Kachhap | 7e0b55e | 2012-08-16 17:11:43 +0530 | [diff] [blame] | 245 | /* Bind callback functions for thermal zone */ |
| 246 | static int exynos_bind(struct thermal_zone_device *thermal, |
| 247 | struct thermal_cooling_device *cdev) |
| 248 | { |
| 249 | int ret = 0, i, tab_size, level; |
| 250 | struct freq_clip_table *tab_ptr, *clip_data; |
| 251 | struct thermal_sensor_conf *data = th_zone->sensor_conf; |
| 252 | |
| 253 | tab_ptr = (struct freq_clip_table *)data->cooling_data.freq_data; |
| 254 | tab_size = data->cooling_data.freq_clip_count; |
| 255 | |
| 256 | if (tab_ptr == NULL || tab_size == 0) |
| 257 | return -EINVAL; |
| 258 | |
| 259 | /* find the cooling device registered*/ |
| 260 | for (i = 0; i < th_zone->cool_dev_size; i++) |
| 261 | if (cdev == th_zone->cool_dev[i]) |
| 262 | break; |
| 263 | |
| 264 | /* No matching cooling device */ |
| 265 | if (i == th_zone->cool_dev_size) |
| 266 | return 0; |
| 267 | |
| 268 | /* Bind the thermal zone to the cpufreq cooling device */ |
| 269 | for (i = 0; i < tab_size; i++) { |
| 270 | clip_data = (struct freq_clip_table *)&(tab_ptr[i]); |
Zhang Rui | 57df810 | 2013-02-08 14:52:06 +0800 | [diff] [blame^] | 271 | level = cpufreq_cooling_get_level(0, clip_data->freq_clip_max); |
| 272 | if (level == THERMAL_CSTATE_INVALID) |
Amit Daniel Kachhap | 7e0b55e | 2012-08-16 17:11:43 +0530 | [diff] [blame] | 273 | return 0; |
| 274 | switch (GET_ZONE(i)) { |
| 275 | case MONITOR_ZONE: |
| 276 | case WARN_ZONE: |
| 277 | if (thermal_zone_bind_cooling_device(thermal, i, cdev, |
Amit Daniel Kachhap | ce760ed | 2013-02-08 01:13:07 +0000 | [diff] [blame] | 278 | level, 0)) { |
Amit Daniel Kachhap | 7e0b55e | 2012-08-16 17:11:43 +0530 | [diff] [blame] | 279 | pr_err("error binding cdev inst %d\n", i); |
| 280 | ret = -EINVAL; |
| 281 | } |
| 282 | th_zone->bind = true; |
| 283 | break; |
| 284 | default: |
| 285 | ret = -EINVAL; |
| 286 | } |
| 287 | } |
| 288 | |
| 289 | return ret; |
| 290 | } |
| 291 | |
| 292 | /* Unbind callback functions for thermal zone */ |
| 293 | static int exynos_unbind(struct thermal_zone_device *thermal, |
| 294 | struct thermal_cooling_device *cdev) |
| 295 | { |
| 296 | int ret = 0, i, tab_size; |
| 297 | struct thermal_sensor_conf *data = th_zone->sensor_conf; |
| 298 | |
| 299 | if (th_zone->bind == false) |
| 300 | return 0; |
| 301 | |
| 302 | tab_size = data->cooling_data.freq_clip_count; |
| 303 | |
| 304 | if (tab_size == 0) |
| 305 | return -EINVAL; |
| 306 | |
| 307 | /* find the cooling device registered*/ |
| 308 | for (i = 0; i < th_zone->cool_dev_size; i++) |
| 309 | if (cdev == th_zone->cool_dev[i]) |
| 310 | break; |
| 311 | |
| 312 | /* No matching cooling device */ |
| 313 | if (i == th_zone->cool_dev_size) |
| 314 | return 0; |
| 315 | |
| 316 | /* Bind the thermal zone to the cpufreq cooling device */ |
| 317 | for (i = 0; i < tab_size; i++) { |
| 318 | switch (GET_ZONE(i)) { |
| 319 | case MONITOR_ZONE: |
| 320 | case WARN_ZONE: |
| 321 | if (thermal_zone_unbind_cooling_device(thermal, i, |
| 322 | cdev)) { |
| 323 | pr_err("error unbinding cdev inst=%d\n", i); |
| 324 | ret = -EINVAL; |
| 325 | } |
| 326 | th_zone->bind = false; |
| 327 | break; |
| 328 | default: |
| 329 | ret = -EINVAL; |
| 330 | } |
| 331 | } |
| 332 | return ret; |
| 333 | } |
| 334 | |
| 335 | /* Get temperature callback functions for thermal zone */ |
| 336 | static int exynos_get_temp(struct thermal_zone_device *thermal, |
| 337 | unsigned long *temp) |
| 338 | { |
| 339 | void *data; |
| 340 | |
| 341 | if (!th_zone->sensor_conf) { |
| 342 | pr_info("Temperature sensor not initialised\n"); |
| 343 | return -EINVAL; |
| 344 | } |
| 345 | data = th_zone->sensor_conf->private_data; |
| 346 | *temp = th_zone->sensor_conf->read_temperature(data); |
| 347 | /* convert the temperature into millicelsius */ |
| 348 | *temp = *temp * MCELSIUS; |
| 349 | return 0; |
| 350 | } |
| 351 | |
| 352 | /* Get the temperature trend */ |
| 353 | static int exynos_get_trend(struct thermal_zone_device *thermal, |
| 354 | int trip, enum thermal_trend *trend) |
| 355 | { |
Amit Daniel Kachhap | 3ad9524 | 2013-01-17 01:42:18 +0000 | [diff] [blame] | 356 | int ret; |
| 357 | unsigned long trip_temp; |
| 358 | |
| 359 | ret = exynos_get_trip_temp(thermal, trip, &trip_temp); |
| 360 | if (ret < 0) |
| 361 | return ret; |
| 362 | |
| 363 | if (thermal->temperature >= trip_temp) |
Amit Daniel Kachhap | ce760ed | 2013-02-08 01:13:07 +0000 | [diff] [blame] | 364 | *trend = THERMAL_TREND_RAISE_FULL; |
Amit Daniel Kachhap | 7e0b55e | 2012-08-16 17:11:43 +0530 | [diff] [blame] | 365 | else |
Amit Daniel Kachhap | ce760ed | 2013-02-08 01:13:07 +0000 | [diff] [blame] | 366 | *trend = THERMAL_TREND_DROP_FULL; |
Amit Daniel Kachhap | 7e0b55e | 2012-08-16 17:11:43 +0530 | [diff] [blame] | 367 | |
| 368 | return 0; |
| 369 | } |
| 370 | /* Operation callback functions for thermal zone */ |
| 371 | static struct thermal_zone_device_ops const exynos_dev_ops = { |
| 372 | .bind = exynos_bind, |
| 373 | .unbind = exynos_unbind, |
| 374 | .get_temp = exynos_get_temp, |
| 375 | .get_trend = exynos_get_trend, |
| 376 | .get_mode = exynos_get_mode, |
| 377 | .set_mode = exynos_set_mode, |
| 378 | .get_trip_type = exynos_get_trip_type, |
| 379 | .get_trip_temp = exynos_get_trip_temp, |
| 380 | .get_crit_temp = exynos_get_crit_temp, |
| 381 | }; |
| 382 | |
| 383 | /* |
| 384 | * This function may be called from interrupt based temperature sensor |
| 385 | * when threshold is changed. |
| 386 | */ |
| 387 | static void exynos_report_trigger(void) |
| 388 | { |
| 389 | unsigned int i; |
| 390 | char data[10]; |
| 391 | char *envp[] = { data, NULL }; |
| 392 | |
| 393 | if (!th_zone || !th_zone->therm_dev) |
| 394 | return; |
| 395 | if (th_zone->bind == false) { |
| 396 | for (i = 0; i < th_zone->cool_dev_size; i++) { |
| 397 | if (!th_zone->cool_dev[i]) |
| 398 | continue; |
| 399 | exynos_bind(th_zone->therm_dev, |
| 400 | th_zone->cool_dev[i]); |
| 401 | } |
| 402 | } |
| 403 | |
| 404 | thermal_zone_device_update(th_zone->therm_dev); |
| 405 | |
| 406 | mutex_lock(&th_zone->therm_dev->lock); |
| 407 | /* Find the level for which trip happened */ |
| 408 | for (i = 0; i < th_zone->sensor_conf->trip_data.trip_count; i++) { |
| 409 | if (th_zone->therm_dev->last_temperature < |
| 410 | th_zone->sensor_conf->trip_data.trip_val[i] * MCELSIUS) |
| 411 | break; |
| 412 | } |
| 413 | |
Jonghwa Lee | 4f0a684 | 2013-02-08 01:13:06 +0000 | [diff] [blame] | 414 | if (th_zone->mode == THERMAL_DEVICE_ENABLED && |
| 415 | !th_zone->sensor_conf->trip_data.trigger_falling) { |
Amit Daniel Kachhap | 7e0b55e | 2012-08-16 17:11:43 +0530 | [diff] [blame] | 416 | if (i > 0) |
| 417 | th_zone->therm_dev->polling_delay = ACTIVE_INTERVAL; |
| 418 | else |
| 419 | th_zone->therm_dev->polling_delay = IDLE_INTERVAL; |
| 420 | } |
| 421 | |
| 422 | snprintf(data, sizeof(data), "%u", i); |
| 423 | kobject_uevent_env(&th_zone->therm_dev->device.kobj, KOBJ_CHANGE, envp); |
| 424 | mutex_unlock(&th_zone->therm_dev->lock); |
| 425 | } |
| 426 | |
| 427 | /* Register with the in-kernel thermal management */ |
| 428 | static int exynos_register_thermal(struct thermal_sensor_conf *sensor_conf) |
| 429 | { |
| 430 | int ret; |
| 431 | struct cpumask mask_val; |
| 432 | |
| 433 | if (!sensor_conf || !sensor_conf->read_temperature) { |
| 434 | pr_err("Temperature sensor not initialised\n"); |
| 435 | return -EINVAL; |
| 436 | } |
| 437 | |
| 438 | th_zone = kzalloc(sizeof(struct exynos_thermal_zone), GFP_KERNEL); |
| 439 | if (!th_zone) |
| 440 | return -ENOMEM; |
| 441 | |
| 442 | th_zone->sensor_conf = sensor_conf; |
| 443 | cpumask_set_cpu(0, &mask_val); |
| 444 | th_zone->cool_dev[0] = cpufreq_cooling_register(&mask_val); |
| 445 | if (IS_ERR(th_zone->cool_dev[0])) { |
| 446 | pr_err("Failed to register cpufreq cooling device\n"); |
| 447 | ret = -EINVAL; |
| 448 | goto err_unregister; |
| 449 | } |
| 450 | th_zone->cool_dev_size++; |
| 451 | |
| 452 | th_zone->therm_dev = thermal_zone_device_register(sensor_conf->name, |
Durgadoss R | 50125a9 | 2012-09-18 11:04:56 +0530 | [diff] [blame] | 453 | EXYNOS_ZONE_COUNT, 0, NULL, &exynos_dev_ops, NULL, 0, |
Jonghwa Lee | 4f0a684 | 2013-02-08 01:13:06 +0000 | [diff] [blame] | 454 | sensor_conf->trip_data.trigger_falling ? |
| 455 | 0 : IDLE_INTERVAL); |
Amit Daniel Kachhap | 7e0b55e | 2012-08-16 17:11:43 +0530 | [diff] [blame] | 456 | |
| 457 | if (IS_ERR(th_zone->therm_dev)) { |
| 458 | pr_err("Failed to register thermal zone device\n"); |
Devendra Naga | 043e465 | 2013-03-04 16:52:48 +0000 | [diff] [blame] | 459 | ret = PTR_ERR(th_zone->therm_dev); |
Amit Daniel Kachhap | 7e0b55e | 2012-08-16 17:11:43 +0530 | [diff] [blame] | 460 | goto err_unregister; |
| 461 | } |
| 462 | th_zone->mode = THERMAL_DEVICE_ENABLED; |
| 463 | |
| 464 | pr_info("Exynos: Kernel Thermal management registered\n"); |
| 465 | |
| 466 | return 0; |
| 467 | |
| 468 | err_unregister: |
| 469 | exynos_unregister_thermal(); |
| 470 | return ret; |
| 471 | } |
| 472 | |
| 473 | /* Un-Register with the in-kernel thermal management */ |
| 474 | static void exynos_unregister_thermal(void) |
| 475 | { |
| 476 | int i; |
| 477 | |
Sachin Kamat | c072fed | 2012-09-27 16:20:38 +0530 | [diff] [blame] | 478 | if (!th_zone) |
| 479 | return; |
| 480 | |
| 481 | if (th_zone->therm_dev) |
Amit Daniel Kachhap | 7e0b55e | 2012-08-16 17:11:43 +0530 | [diff] [blame] | 482 | thermal_zone_device_unregister(th_zone->therm_dev); |
| 483 | |
| 484 | for (i = 0; i < th_zone->cool_dev_size; i++) { |
Sachin Kamat | c072fed | 2012-09-27 16:20:38 +0530 | [diff] [blame] | 485 | if (th_zone->cool_dev[i]) |
Amit Daniel Kachhap | 7e0b55e | 2012-08-16 17:11:43 +0530 | [diff] [blame] | 486 | cpufreq_cooling_unregister(th_zone->cool_dev[i]); |
| 487 | } |
| 488 | |
| 489 | kfree(th_zone); |
| 490 | pr_info("Exynos: Kernel Thermal management unregistered\n"); |
| 491 | } |
| 492 | |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 493 | /* |
| 494 | * TMU treats temperature as a mapped temperature code. |
| 495 | * The temperature is converted differently depending on the calibration type. |
| 496 | */ |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 497 | static int temp_to_code(struct exynos_tmu_data *data, u8 temp) |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 498 | { |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 499 | struct exynos_tmu_platform_data *pdata = data->pdata; |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 500 | int temp_code; |
| 501 | |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 502 | if (data->soc == SOC_ARCH_EXYNOS4210) |
| 503 | /* temp should range between 25 and 125 */ |
| 504 | if (temp < 25 || temp > 125) { |
| 505 | temp_code = -EINVAL; |
| 506 | goto out; |
| 507 | } |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 508 | |
| 509 | switch (pdata->cal_type) { |
| 510 | case TYPE_TWO_POINT_TRIMMING: |
| 511 | temp_code = (temp - 25) * |
| 512 | (data->temp_error2 - data->temp_error1) / |
| 513 | (85 - 25) + data->temp_error1; |
| 514 | break; |
| 515 | case TYPE_ONE_POINT_TRIMMING: |
| 516 | temp_code = temp + data->temp_error1 - 25; |
| 517 | break; |
| 518 | default: |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 519 | temp_code = temp + EXYNOS_TMU_DEF_CODE_TO_TEMP_OFFSET; |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 520 | break; |
| 521 | } |
| 522 | out: |
| 523 | return temp_code; |
| 524 | } |
| 525 | |
| 526 | /* |
| 527 | * Calculate a temperature value from a temperature code. |
| 528 | * The unit of the temperature is degree Celsius. |
| 529 | */ |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 530 | static int code_to_temp(struct exynos_tmu_data *data, u8 temp_code) |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 531 | { |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 532 | struct exynos_tmu_platform_data *pdata = data->pdata; |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 533 | int temp; |
| 534 | |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 535 | if (data->soc == SOC_ARCH_EXYNOS4210) |
| 536 | /* temp_code should range between 75 and 175 */ |
| 537 | if (temp_code < 75 || temp_code > 175) { |
| 538 | temp = -ENODATA; |
| 539 | goto out; |
| 540 | } |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 541 | |
| 542 | switch (pdata->cal_type) { |
| 543 | case TYPE_TWO_POINT_TRIMMING: |
| 544 | temp = (temp_code - data->temp_error1) * (85 - 25) / |
| 545 | (data->temp_error2 - data->temp_error1) + 25; |
| 546 | break; |
| 547 | case TYPE_ONE_POINT_TRIMMING: |
| 548 | temp = temp_code - data->temp_error1 + 25; |
| 549 | break; |
| 550 | default: |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 551 | temp = temp_code - EXYNOS_TMU_DEF_CODE_TO_TEMP_OFFSET; |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 552 | break; |
| 553 | } |
| 554 | out: |
| 555 | return temp; |
| 556 | } |
| 557 | |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 558 | static int exynos_tmu_initialize(struct platform_device *pdev) |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 559 | { |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 560 | struct exynos_tmu_data *data = platform_get_drvdata(pdev); |
| 561 | struct exynos_tmu_platform_data *pdata = data->pdata; |
Jonghwa Lee | 4f0a684 | 2013-02-08 01:13:06 +0000 | [diff] [blame] | 562 | unsigned int status, trim_info; |
| 563 | unsigned int rising_threshold = 0, falling_threshold = 0; |
| 564 | int ret = 0, threshold_code, i, trigger_levs = 0; |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 565 | |
| 566 | mutex_lock(&data->lock); |
| 567 | clk_enable(data->clk); |
| 568 | |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 569 | status = readb(data->base + EXYNOS_TMU_REG_STATUS); |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 570 | if (!status) { |
| 571 | ret = -EBUSY; |
| 572 | goto out; |
| 573 | } |
| 574 | |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 575 | if (data->soc == SOC_ARCH_EXYNOS) { |
| 576 | __raw_writel(EXYNOS_TRIMINFO_RELOAD, |
| 577 | data->base + EXYNOS_TMU_TRIMINFO_CON); |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 578 | } |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 579 | /* Save trimming info in order to perform calibration */ |
| 580 | trim_info = readl(data->base + EXYNOS_TMU_REG_TRIMINFO); |
| 581 | data->temp_error1 = trim_info & EXYNOS_TMU_TRIM_TEMP_MASK; |
| 582 | data->temp_error2 = ((trim_info >> 8) & EXYNOS_TMU_TRIM_TEMP_MASK); |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 583 | |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 584 | if ((EFUSE_MIN_VALUE > data->temp_error1) || |
| 585 | (data->temp_error1 > EFUSE_MAX_VALUE) || |
| 586 | (data->temp_error2 != 0)) |
| 587 | data->temp_error1 = pdata->efuse_value; |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 588 | |
Jonghwa Lee | 4f0a684 | 2013-02-08 01:13:06 +0000 | [diff] [blame] | 589 | /* Count trigger levels to be enabled */ |
| 590 | for (i = 0; i < MAX_THRESHOLD_LEVS; i++) |
| 591 | if (pdata->trigger_levels[i]) |
| 592 | trigger_levs++; |
| 593 | |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 594 | if (data->soc == SOC_ARCH_EXYNOS4210) { |
| 595 | /* Write temperature code for threshold */ |
| 596 | threshold_code = temp_to_code(data, pdata->threshold); |
| 597 | if (threshold_code < 0) { |
| 598 | ret = threshold_code; |
| 599 | goto out; |
| 600 | } |
| 601 | writeb(threshold_code, |
| 602 | data->base + EXYNOS4210_TMU_REG_THRESHOLD_TEMP); |
Jonghwa Lee | 4f0a684 | 2013-02-08 01:13:06 +0000 | [diff] [blame] | 603 | for (i = 0; i < trigger_levs; i++) |
| 604 | writeb(pdata->trigger_levels[i], |
| 605 | data->base + EXYNOS4210_TMU_REG_TRIG_LEVEL0 + i * 4); |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 606 | |
| 607 | writel(EXYNOS4210_TMU_INTCLEAR_VAL, |
| 608 | data->base + EXYNOS_TMU_REG_INTCLEAR); |
| 609 | } else if (data->soc == SOC_ARCH_EXYNOS) { |
Jonghwa Lee | 4f0a684 | 2013-02-08 01:13:06 +0000 | [diff] [blame] | 610 | /* Write temperature code for rising and falling threshold */ |
| 611 | for (i = 0; i < trigger_levs; i++) { |
| 612 | threshold_code = temp_to_code(data, |
| 613 | pdata->trigger_levels[i]); |
| 614 | if (threshold_code < 0) { |
| 615 | ret = threshold_code; |
| 616 | goto out; |
| 617 | } |
| 618 | rising_threshold |= threshold_code << 8 * i; |
| 619 | if (pdata->threshold_falling) { |
| 620 | threshold_code = temp_to_code(data, |
| 621 | pdata->trigger_levels[i] - |
| 622 | pdata->threshold_falling); |
| 623 | if (threshold_code > 0) |
| 624 | falling_threshold |= |
| 625 | threshold_code << 8 * i; |
| 626 | } |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 627 | } |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 628 | |
| 629 | writel(rising_threshold, |
| 630 | data->base + EXYNOS_THD_TEMP_RISE); |
Jonghwa Lee | 4f0a684 | 2013-02-08 01:13:06 +0000 | [diff] [blame] | 631 | writel(falling_threshold, |
| 632 | data->base + EXYNOS_THD_TEMP_FALL); |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 633 | |
Jonghwa Lee | 4f0a684 | 2013-02-08 01:13:06 +0000 | [diff] [blame] | 634 | writel(EXYNOS_TMU_CLEAR_RISE_INT | EXYNOS_TMU_CLEAR_FALL_INT, |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 635 | data->base + EXYNOS_TMU_REG_INTCLEAR); |
| 636 | } |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 637 | out: |
| 638 | clk_disable(data->clk); |
| 639 | mutex_unlock(&data->lock); |
| 640 | |
| 641 | return ret; |
| 642 | } |
| 643 | |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 644 | static void exynos_tmu_control(struct platform_device *pdev, bool on) |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 645 | { |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 646 | struct exynos_tmu_data *data = platform_get_drvdata(pdev); |
| 647 | struct exynos_tmu_platform_data *pdata = data->pdata; |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 648 | unsigned int con, interrupt_en; |
| 649 | |
| 650 | mutex_lock(&data->lock); |
| 651 | clk_enable(data->clk); |
| 652 | |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 653 | con = pdata->reference_voltage << EXYNOS_TMU_REF_VOLTAGE_SHIFT | |
| 654 | pdata->gain << EXYNOS_TMU_GAIN_SHIFT; |
| 655 | |
| 656 | if (data->soc == SOC_ARCH_EXYNOS) { |
| 657 | con |= pdata->noise_cancel_mode << EXYNOS_TMU_TRIP_MODE_SHIFT; |
| 658 | con |= (EXYNOS_MUX_ADDR_VALUE << EXYNOS_MUX_ADDR_SHIFT); |
| 659 | } |
| 660 | |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 661 | if (on) { |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 662 | con |= EXYNOS_TMU_CORE_ON; |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 663 | interrupt_en = pdata->trigger_level3_en << 12 | |
| 664 | pdata->trigger_level2_en << 8 | |
| 665 | pdata->trigger_level1_en << 4 | |
| 666 | pdata->trigger_level0_en; |
Jonghwa Lee | 4f0a684 | 2013-02-08 01:13:06 +0000 | [diff] [blame] | 667 | if (pdata->threshold_falling) |
| 668 | interrupt_en |= interrupt_en << 16; |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 669 | } else { |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 670 | con |= EXYNOS_TMU_CORE_OFF; |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 671 | interrupt_en = 0; /* Disable all interrupts */ |
| 672 | } |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 673 | writel(interrupt_en, data->base + EXYNOS_TMU_REG_INTEN); |
| 674 | writel(con, data->base + EXYNOS_TMU_REG_CONTROL); |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 675 | |
| 676 | clk_disable(data->clk); |
| 677 | mutex_unlock(&data->lock); |
| 678 | } |
| 679 | |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 680 | static int exynos_tmu_read(struct exynos_tmu_data *data) |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 681 | { |
| 682 | u8 temp_code; |
| 683 | int temp; |
| 684 | |
| 685 | mutex_lock(&data->lock); |
| 686 | clk_enable(data->clk); |
| 687 | |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 688 | temp_code = readb(data->base + EXYNOS_TMU_REG_CURRENT_TEMP); |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 689 | temp = code_to_temp(data, temp_code); |
| 690 | |
| 691 | clk_disable(data->clk); |
| 692 | mutex_unlock(&data->lock); |
| 693 | |
| 694 | return temp; |
| 695 | } |
| 696 | |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 697 | static void exynos_tmu_work(struct work_struct *work) |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 698 | { |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 699 | struct exynos_tmu_data *data = container_of(work, |
| 700 | struct exynos_tmu_data, irq_work); |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 701 | |
Amit Daniel Kachhap | 3ad9524 | 2013-01-17 01:42:18 +0000 | [diff] [blame] | 702 | exynos_report_trigger(); |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 703 | mutex_lock(&data->lock); |
| 704 | clk_enable(data->clk); |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 705 | if (data->soc == SOC_ARCH_EXYNOS) |
Jonghwa Lee | 4f0a684 | 2013-02-08 01:13:06 +0000 | [diff] [blame] | 706 | writel(EXYNOS_TMU_CLEAR_RISE_INT | |
| 707 | EXYNOS_TMU_CLEAR_FALL_INT, |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 708 | data->base + EXYNOS_TMU_REG_INTCLEAR); |
| 709 | else |
| 710 | writel(EXYNOS4210_TMU_INTCLEAR_VAL, |
| 711 | data->base + EXYNOS_TMU_REG_INTCLEAR); |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 712 | clk_disable(data->clk); |
| 713 | mutex_unlock(&data->lock); |
Amit Daniel Kachhap | 3ad9524 | 2013-01-17 01:42:18 +0000 | [diff] [blame] | 714 | |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 715 | enable_irq(data->irq); |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 716 | } |
| 717 | |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 718 | static irqreturn_t exynos_tmu_irq(int irq, void *id) |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 719 | { |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 720 | struct exynos_tmu_data *data = id; |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 721 | |
| 722 | disable_irq_nosync(irq); |
| 723 | schedule_work(&data->irq_work); |
| 724 | |
| 725 | return IRQ_HANDLED; |
| 726 | } |
Amit Daniel Kachhap | 7e0b55e | 2012-08-16 17:11:43 +0530 | [diff] [blame] | 727 | static struct thermal_sensor_conf exynos_sensor_conf = { |
| 728 | .name = "exynos-therm", |
| 729 | .read_temperature = (int (*)(void *))exynos_tmu_read, |
Amit Daniel Kachhap | 17be868 | 2012-08-16 17:11:44 +0530 | [diff] [blame] | 730 | }; |
| 731 | |
| 732 | #if defined(CONFIG_CPU_EXYNOS4210) |
| 733 | static struct exynos_tmu_platform_data const exynos4210_default_tmu_data = { |
| 734 | .threshold = 80, |
| 735 | .trigger_levels[0] = 5, |
| 736 | .trigger_levels[1] = 20, |
| 737 | .trigger_levels[2] = 30, |
| 738 | .trigger_level0_en = 1, |
| 739 | .trigger_level1_en = 1, |
| 740 | .trigger_level2_en = 1, |
| 741 | .trigger_level3_en = 0, |
| 742 | .gain = 15, |
| 743 | .reference_voltage = 7, |
| 744 | .cal_type = TYPE_ONE_POINT_TRIMMING, |
| 745 | .freq_tab[0] = { |
| 746 | .freq_clip_max = 800 * 1000, |
| 747 | .temp_level = 85, |
| 748 | }, |
| 749 | .freq_tab[1] = { |
| 750 | .freq_clip_max = 200 * 1000, |
| 751 | .temp_level = 100, |
| 752 | }, |
| 753 | .freq_tab_count = 2, |
| 754 | .type = SOC_ARCH_EXYNOS4210, |
| 755 | }; |
| 756 | #define EXYNOS4210_TMU_DRV_DATA (&exynos4210_default_tmu_data) |
| 757 | #else |
| 758 | #define EXYNOS4210_TMU_DRV_DATA (NULL) |
| 759 | #endif |
| 760 | |
| 761 | #if defined(CONFIG_SOC_EXYNOS5250) || defined(CONFIG_SOC_EXYNOS4412) |
| 762 | static struct exynos_tmu_platform_data const exynos_default_tmu_data = { |
Jonghwa Lee | 4f0a684 | 2013-02-08 01:13:06 +0000 | [diff] [blame] | 763 | .threshold_falling = 10, |
Amit Daniel Kachhap | 17be868 | 2012-08-16 17:11:44 +0530 | [diff] [blame] | 764 | .trigger_levels[0] = 85, |
| 765 | .trigger_levels[1] = 103, |
| 766 | .trigger_levels[2] = 110, |
| 767 | .trigger_level0_en = 1, |
| 768 | .trigger_level1_en = 1, |
| 769 | .trigger_level2_en = 1, |
| 770 | .trigger_level3_en = 0, |
| 771 | .gain = 8, |
| 772 | .reference_voltage = 16, |
| 773 | .noise_cancel_mode = 4, |
| 774 | .cal_type = TYPE_ONE_POINT_TRIMMING, |
| 775 | .efuse_value = 55, |
| 776 | .freq_tab[0] = { |
| 777 | .freq_clip_max = 800 * 1000, |
| 778 | .temp_level = 85, |
| 779 | }, |
| 780 | .freq_tab[1] = { |
| 781 | .freq_clip_max = 200 * 1000, |
| 782 | .temp_level = 103, |
| 783 | }, |
| 784 | .freq_tab_count = 2, |
| 785 | .type = SOC_ARCH_EXYNOS, |
| 786 | }; |
| 787 | #define EXYNOS_TMU_DRV_DATA (&exynos_default_tmu_data) |
| 788 | #else |
| 789 | #define EXYNOS_TMU_DRV_DATA (NULL) |
| 790 | #endif |
| 791 | |
| 792 | #ifdef CONFIG_OF |
| 793 | static const struct of_device_id exynos_tmu_match[] = { |
| 794 | { |
| 795 | .compatible = "samsung,exynos4210-tmu", |
| 796 | .data = (void *)EXYNOS4210_TMU_DRV_DATA, |
| 797 | }, |
| 798 | { |
| 799 | .compatible = "samsung,exynos5250-tmu", |
| 800 | .data = (void *)EXYNOS_TMU_DRV_DATA, |
| 801 | }, |
| 802 | {}, |
| 803 | }; |
| 804 | MODULE_DEVICE_TABLE(of, exynos_tmu_match); |
Amit Daniel Kachhap | 17be868 | 2012-08-16 17:11:44 +0530 | [diff] [blame] | 805 | #endif |
| 806 | |
| 807 | static struct platform_device_id exynos_tmu_driver_ids[] = { |
| 808 | { |
| 809 | .name = "exynos4210-tmu", |
| 810 | .driver_data = (kernel_ulong_t)EXYNOS4210_TMU_DRV_DATA, |
| 811 | }, |
| 812 | { |
| 813 | .name = "exynos5250-tmu", |
| 814 | .driver_data = (kernel_ulong_t)EXYNOS_TMU_DRV_DATA, |
| 815 | }, |
| 816 | { }, |
| 817 | }; |
Jonghwan Choi | 3ae53b1 | 2012-10-23 14:54:42 +0800 | [diff] [blame] | 818 | MODULE_DEVICE_TABLE(platform, exynos_tmu_driver_ids); |
Amit Daniel Kachhap | 17be868 | 2012-08-16 17:11:44 +0530 | [diff] [blame] | 819 | |
| 820 | static inline struct exynos_tmu_platform_data *exynos_get_driver_data( |
| 821 | struct platform_device *pdev) |
| 822 | { |
| 823 | #ifdef CONFIG_OF |
| 824 | if (pdev->dev.of_node) { |
| 825 | const struct of_device_id *match; |
| 826 | match = of_match_node(exynos_tmu_match, pdev->dev.of_node); |
| 827 | if (!match) |
| 828 | return NULL; |
| 829 | return (struct exynos_tmu_platform_data *) match->data; |
| 830 | } |
| 831 | #endif |
| 832 | return (struct exynos_tmu_platform_data *) |
| 833 | platform_get_device_id(pdev)->driver_data; |
Amit Daniel Kachhap | 7e0b55e | 2012-08-16 17:11:43 +0530 | [diff] [blame] | 834 | } |
Jonghwa Lee | bbf63be | 2012-11-21 13:31:01 +0900 | [diff] [blame] | 835 | |
| 836 | #ifdef CONFIG_EXYNOS_THERMAL_EMUL |
| 837 | static ssize_t exynos_tmu_emulation_show(struct device *dev, |
| 838 | struct device_attribute *attr, |
| 839 | char *buf) |
| 840 | { |
| 841 | struct platform_device *pdev = container_of(dev, |
| 842 | struct platform_device, dev); |
| 843 | struct exynos_tmu_data *data = platform_get_drvdata(pdev); |
| 844 | unsigned int reg; |
| 845 | u8 temp_code; |
| 846 | int temp = 0; |
| 847 | |
| 848 | if (data->soc == SOC_ARCH_EXYNOS4210) |
| 849 | goto out; |
| 850 | |
| 851 | mutex_lock(&data->lock); |
| 852 | clk_enable(data->clk); |
| 853 | reg = readl(data->base + EXYNOS_EMUL_CON); |
| 854 | clk_disable(data->clk); |
| 855 | mutex_unlock(&data->lock); |
| 856 | |
| 857 | if (reg & EXYNOS_EMUL_ENABLE) { |
| 858 | reg >>= EXYNOS_EMUL_DATA_SHIFT; |
| 859 | temp_code = reg & EXYNOS_EMUL_DATA_MASK; |
| 860 | temp = code_to_temp(data, temp_code); |
| 861 | } |
| 862 | out: |
| 863 | return sprintf(buf, "%d\n", temp * MCELSIUS); |
| 864 | } |
| 865 | |
| 866 | static ssize_t exynos_tmu_emulation_store(struct device *dev, |
| 867 | struct device_attribute *attr, |
| 868 | const char *buf, size_t count) |
| 869 | { |
| 870 | struct platform_device *pdev = container_of(dev, |
| 871 | struct platform_device, dev); |
| 872 | struct exynos_tmu_data *data = platform_get_drvdata(pdev); |
| 873 | unsigned int reg; |
| 874 | int temp; |
| 875 | |
| 876 | if (data->soc == SOC_ARCH_EXYNOS4210) |
| 877 | goto out; |
| 878 | |
| 879 | if (!sscanf(buf, "%d\n", &temp) || temp < 0) |
| 880 | return -EINVAL; |
| 881 | |
| 882 | mutex_lock(&data->lock); |
| 883 | clk_enable(data->clk); |
| 884 | |
| 885 | reg = readl(data->base + EXYNOS_EMUL_CON); |
| 886 | |
| 887 | if (temp) { |
| 888 | /* Both CELSIUS and MCELSIUS type are available for input */ |
| 889 | if (temp > MCELSIUS) |
| 890 | temp /= MCELSIUS; |
| 891 | |
| 892 | reg = (EXYNOS_EMUL_TIME << EXYNOS_EMUL_TIME_SHIFT) | |
| 893 | (temp_to_code(data, (temp / MCELSIUS)) |
| 894 | << EXYNOS_EMUL_DATA_SHIFT) | EXYNOS_EMUL_ENABLE; |
| 895 | } else { |
| 896 | reg &= ~EXYNOS_EMUL_ENABLE; |
| 897 | } |
| 898 | |
| 899 | writel(reg, data->base + EXYNOS_EMUL_CON); |
| 900 | |
| 901 | clk_disable(data->clk); |
| 902 | mutex_unlock(&data->lock); |
| 903 | |
| 904 | out: |
| 905 | return count; |
| 906 | } |
| 907 | |
| 908 | static DEVICE_ATTR(emulation, 0644, exynos_tmu_emulation_show, |
| 909 | exynos_tmu_emulation_store); |
| 910 | static int create_emulation_sysfs(struct device *dev) |
| 911 | { |
| 912 | return device_create_file(dev, &dev_attr_emulation); |
| 913 | } |
| 914 | static void remove_emulation_sysfs(struct device *dev) |
| 915 | { |
| 916 | device_remove_file(dev, &dev_attr_emulation); |
| 917 | } |
| 918 | #else |
| 919 | static inline int create_emulation_sysfs(struct device *dev) { return 0; } |
| 920 | static inline void remove_emulation_sysfs(struct device *dev) {} |
| 921 | #endif |
| 922 | |
Greg Kroah-Hartman | 4eab7a9e | 2012-12-21 13:15:52 -0800 | [diff] [blame] | 923 | static int exynos_tmu_probe(struct platform_device *pdev) |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 924 | { |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 925 | struct exynos_tmu_data *data; |
| 926 | struct exynos_tmu_platform_data *pdata = pdev->dev.platform_data; |
Amit Daniel Kachhap | 7e0b55e | 2012-08-16 17:11:43 +0530 | [diff] [blame] | 927 | int ret, i; |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 928 | |
Amit Daniel Kachhap | 17be868 | 2012-08-16 17:11:44 +0530 | [diff] [blame] | 929 | if (!pdata) |
| 930 | pdata = exynos_get_driver_data(pdev); |
| 931 | |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 932 | if (!pdata) { |
| 933 | dev_err(&pdev->dev, "No platform init data supplied.\n"); |
| 934 | return -ENODEV; |
| 935 | } |
Amit Daniel Kachhap | 79e093c | 2012-08-16 05:41:45 -0600 | [diff] [blame] | 936 | data = devm_kzalloc(&pdev->dev, sizeof(struct exynos_tmu_data), |
| 937 | GFP_KERNEL); |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 938 | if (!data) { |
| 939 | dev_err(&pdev->dev, "Failed to allocate driver structure\n"); |
| 940 | return -ENOMEM; |
| 941 | } |
| 942 | |
| 943 | data->irq = platform_get_irq(pdev, 0); |
| 944 | if (data->irq < 0) { |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 945 | dev_err(&pdev->dev, "Failed to get platform irq\n"); |
Amit Daniel Kachhap | 79e093c | 2012-08-16 05:41:45 -0600 | [diff] [blame] | 946 | return data->irq; |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 947 | } |
| 948 | |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 949 | INIT_WORK(&data->irq_work, exynos_tmu_work); |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 950 | |
| 951 | data->mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 952 | if (!data->mem) { |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 953 | dev_err(&pdev->dev, "Failed to get platform resource\n"); |
Amit Daniel Kachhap | 79e093c | 2012-08-16 05:41:45 -0600 | [diff] [blame] | 954 | return -ENOENT; |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 955 | } |
| 956 | |
Thierry Reding | ca36b1b | 2013-01-21 11:09:20 +0100 | [diff] [blame] | 957 | data->base = devm_ioremap_resource(&pdev->dev, data->mem); |
| 958 | if (IS_ERR(data->base)) |
| 959 | return PTR_ERR(data->base); |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 960 | |
Amit Daniel Kachhap | 79e093c | 2012-08-16 05:41:45 -0600 | [diff] [blame] | 961 | ret = devm_request_irq(&pdev->dev, data->irq, exynos_tmu_irq, |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 962 | IRQF_TRIGGER_RISING, "exynos-tmu", data); |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 963 | if (ret) { |
| 964 | dev_err(&pdev->dev, "Failed to request irq: %d\n", data->irq); |
Amit Daniel Kachhap | 79e093c | 2012-08-16 05:41:45 -0600 | [diff] [blame] | 965 | return ret; |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 966 | } |
| 967 | |
| 968 | data->clk = clk_get(NULL, "tmu_apbif"); |
| 969 | if (IS_ERR(data->clk)) { |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 970 | dev_err(&pdev->dev, "Failed to get clock\n"); |
Amit Daniel Kachhap | 79e093c | 2012-08-16 05:41:45 -0600 | [diff] [blame] | 971 | return PTR_ERR(data->clk); |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 972 | } |
| 973 | |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 974 | if (pdata->type == SOC_ARCH_EXYNOS || |
| 975 | pdata->type == SOC_ARCH_EXYNOS4210) |
| 976 | data->soc = pdata->type; |
| 977 | else { |
| 978 | ret = -EINVAL; |
| 979 | dev_err(&pdev->dev, "Platform not supported\n"); |
| 980 | goto err_clk; |
| 981 | } |
| 982 | |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 983 | data->pdata = pdata; |
| 984 | platform_set_drvdata(pdev, data); |
| 985 | mutex_init(&data->lock); |
| 986 | |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 987 | ret = exynos_tmu_initialize(pdev); |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 988 | if (ret) { |
| 989 | dev_err(&pdev->dev, "Failed to initialize TMU\n"); |
| 990 | goto err_clk; |
| 991 | } |
| 992 | |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 993 | exynos_tmu_control(pdev, true); |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 994 | |
Amit Daniel Kachhap | 7e0b55e | 2012-08-16 17:11:43 +0530 | [diff] [blame] | 995 | /* Register the sensor with thermal management interface */ |
| 996 | (&exynos_sensor_conf)->private_data = data; |
| 997 | exynos_sensor_conf.trip_data.trip_count = pdata->trigger_level0_en + |
| 998 | pdata->trigger_level1_en + pdata->trigger_level2_en + |
| 999 | pdata->trigger_level3_en; |
| 1000 | |
| 1001 | for (i = 0; i < exynos_sensor_conf.trip_data.trip_count; i++) |
| 1002 | exynos_sensor_conf.trip_data.trip_val[i] = |
| 1003 | pdata->threshold + pdata->trigger_levels[i]; |
| 1004 | |
Jonghwa Lee | 4f0a684 | 2013-02-08 01:13:06 +0000 | [diff] [blame] | 1005 | exynos_sensor_conf.trip_data.trigger_falling = pdata->threshold_falling; |
| 1006 | |
Amit Daniel Kachhap | 7e0b55e | 2012-08-16 17:11:43 +0530 | [diff] [blame] | 1007 | exynos_sensor_conf.cooling_data.freq_clip_count = |
| 1008 | pdata->freq_tab_count; |
| 1009 | for (i = 0; i < pdata->freq_tab_count; i++) { |
| 1010 | exynos_sensor_conf.cooling_data.freq_data[i].freq_clip_max = |
| 1011 | pdata->freq_tab[i].freq_clip_max; |
| 1012 | exynos_sensor_conf.cooling_data.freq_data[i].temp_level = |
| 1013 | pdata->freq_tab[i].temp_level; |
| 1014 | } |
| 1015 | |
| 1016 | ret = exynos_register_thermal(&exynos_sensor_conf); |
| 1017 | if (ret) { |
| 1018 | dev_err(&pdev->dev, "Failed to register thermal interface\n"); |
| 1019 | goto err_clk; |
| 1020 | } |
Jonghwa Lee | bbf63be | 2012-11-21 13:31:01 +0900 | [diff] [blame] | 1021 | |
| 1022 | ret = create_emulation_sysfs(&pdev->dev); |
| 1023 | if (ret) |
| 1024 | dev_err(&pdev->dev, "Failed to create emulation mode sysfs node\n"); |
| 1025 | |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 1026 | return 0; |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 1027 | err_clk: |
| 1028 | platform_set_drvdata(pdev, NULL); |
| 1029 | clk_put(data->clk); |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 1030 | return ret; |
| 1031 | } |
| 1032 | |
Greg Kroah-Hartman | 4eab7a9e | 2012-12-21 13:15:52 -0800 | [diff] [blame] | 1033 | static int exynos_tmu_remove(struct platform_device *pdev) |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 1034 | { |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 1035 | struct exynos_tmu_data *data = platform_get_drvdata(pdev); |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 1036 | |
Jonghwa Lee | bbf63be | 2012-11-21 13:31:01 +0900 | [diff] [blame] | 1037 | remove_emulation_sysfs(&pdev->dev); |
| 1038 | |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 1039 | exynos_tmu_control(pdev, false); |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 1040 | |
Amit Daniel Kachhap | 7e0b55e | 2012-08-16 17:11:43 +0530 | [diff] [blame] | 1041 | exynos_unregister_thermal(); |
| 1042 | |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 1043 | clk_put(data->clk); |
| 1044 | |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 1045 | platform_set_drvdata(pdev, NULL); |
| 1046 | |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 1047 | return 0; |
| 1048 | } |
| 1049 | |
Rafael J. Wysocki | 08cd675 | 2012-07-08 21:48:15 +0200 | [diff] [blame] | 1050 | #ifdef CONFIG_PM_SLEEP |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 1051 | static int exynos_tmu_suspend(struct device *dev) |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 1052 | { |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 1053 | exynos_tmu_control(to_platform_device(dev), false); |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 1054 | |
| 1055 | return 0; |
| 1056 | } |
| 1057 | |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 1058 | static int exynos_tmu_resume(struct device *dev) |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 1059 | { |
Rafael J. Wysocki | 08cd675 | 2012-07-08 21:48:15 +0200 | [diff] [blame] | 1060 | struct platform_device *pdev = to_platform_device(dev); |
| 1061 | |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 1062 | exynos_tmu_initialize(pdev); |
| 1063 | exynos_tmu_control(pdev, true); |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 1064 | |
| 1065 | return 0; |
| 1066 | } |
Rafael J. Wysocki | 08cd675 | 2012-07-08 21:48:15 +0200 | [diff] [blame] | 1067 | |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 1068 | static SIMPLE_DEV_PM_OPS(exynos_tmu_pm, |
| 1069 | exynos_tmu_suspend, exynos_tmu_resume); |
| 1070 | #define EXYNOS_TMU_PM (&exynos_tmu_pm) |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 1071 | #else |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 1072 | #define EXYNOS_TMU_PM NULL |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 1073 | #endif |
| 1074 | |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 1075 | static struct platform_driver exynos_tmu_driver = { |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 1076 | .driver = { |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 1077 | .name = "exynos-tmu", |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 1078 | .owner = THIS_MODULE, |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 1079 | .pm = EXYNOS_TMU_PM, |
Sachin Kamat | caa5cbd | 2012-12-12 15:54:24 +0530 | [diff] [blame] | 1080 | .of_match_table = of_match_ptr(exynos_tmu_match), |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 1081 | }, |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 1082 | .probe = exynos_tmu_probe, |
Greg Kroah-Hartman | 4eab7a9e | 2012-12-21 13:15:52 -0800 | [diff] [blame] | 1083 | .remove = exynos_tmu_remove, |
Amit Daniel Kachhap | 17be868 | 2012-08-16 17:11:44 +0530 | [diff] [blame] | 1084 | .id_table = exynos_tmu_driver_ids, |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 1085 | }; |
| 1086 | |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 1087 | module_platform_driver(exynos_tmu_driver); |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 1088 | |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 1089 | MODULE_DESCRIPTION("EXYNOS TMU Driver"); |
Donggeun Kim | 9d97e5c | 2011-09-07 18:49:08 +0900 | [diff] [blame] | 1090 | MODULE_AUTHOR("Donggeun Kim <dg77.kim@samsung.com>"); |
| 1091 | MODULE_LICENSE("GPL"); |
Amit Daniel Kachhap | f22d9c0 | 2012-08-16 17:11:42 +0530 | [diff] [blame] | 1092 | MODULE_ALIAS("platform:exynos-tmu"); |