11a59d1b8SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later 259dfa54cSAmit Daniel Kachhap /* 3ca07ee4eSKrzysztof Kozlowski * exynos_tmu.c - Samsung Exynos TMU (Thermal Management Unit) 459dfa54cSAmit Daniel Kachhap * 53b6a1a80SLukasz Majewski * Copyright (C) 2014 Samsung Electronics 63b6a1a80SLukasz Majewski * Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> 73b6a1a80SLukasz Majewski * Lukasz Majewski <l.majewski@samsung.com> 83b6a1a80SLukasz Majewski * 959dfa54cSAmit Daniel Kachhap * Copyright (C) 2011 Samsung Electronics 1059dfa54cSAmit Daniel Kachhap * Donggeun Kim <dg77.kim@samsung.com> 1159dfa54cSAmit Daniel Kachhap * Amit Daniel Kachhap <amit.kachhap@linaro.org> 1259dfa54cSAmit Daniel Kachhap */ 1359dfa54cSAmit Daniel Kachhap 1459dfa54cSAmit Daniel Kachhap #include <linux/clk.h> 1559dfa54cSAmit Daniel Kachhap #include <linux/io.h> 1659dfa54cSAmit Daniel Kachhap #include <linux/interrupt.h> 1759dfa54cSAmit Daniel Kachhap #include <linux/module.h> 18f6a756e8SRob Herring #include <linux/of.h> 19cebe7373SAmit Daniel Kachhap #include <linux/of_address.h> 20cebe7373SAmit Daniel Kachhap #include <linux/of_irq.h> 2159dfa54cSAmit Daniel Kachhap #include <linux/platform_device.h> 22498d22f6SAmit Daniel Kachhap #include <linux/regulator/consumer.h> 239272d2d4SDaniel Lezcano #include <linux/thermal.h> 2459dfa54cSAmit Daniel Kachhap 257efd18a2SBartlomiej Zolnierkiewicz #include <dt-bindings/thermal/thermal_exynos.h> 267efd18a2SBartlomiej Zolnierkiewicz 272845f6ecSBartlomiej Zolnierkiewicz /* Exynos generic registers */ 282845f6ecSBartlomiej Zolnierkiewicz #define EXYNOS_TMU_REG_TRIMINFO 0x0 292845f6ecSBartlomiej Zolnierkiewicz #define EXYNOS_TMU_REG_CONTROL 0x20 302845f6ecSBartlomiej Zolnierkiewicz #define EXYNOS_TMU_REG_STATUS 0x28 312845f6ecSBartlomiej Zolnierkiewicz #define EXYNOS_TMU_REG_CURRENT_TEMP 0x40 322845f6ecSBartlomiej Zolnierkiewicz #define EXYNOS_TMU_REG_INTEN 0x70 332845f6ecSBartlomiej Zolnierkiewicz #define EXYNOS_TMU_REG_INTSTAT 0x74 342845f6ecSBartlomiej Zolnierkiewicz #define EXYNOS_TMU_REG_INTCLEAR 0x78 352845f6ecSBartlomiej Zolnierkiewicz 362845f6ecSBartlomiej Zolnierkiewicz #define EXYNOS_TMU_TEMP_MASK 0xff 372845f6ecSBartlomiej Zolnierkiewicz #define EXYNOS_TMU_REF_VOLTAGE_SHIFT 24 382845f6ecSBartlomiej Zolnierkiewicz #define EXYNOS_TMU_REF_VOLTAGE_MASK 0x1f 392845f6ecSBartlomiej Zolnierkiewicz #define EXYNOS_TMU_BUF_SLOPE_SEL_MASK 0xf 402845f6ecSBartlomiej Zolnierkiewicz #define EXYNOS_TMU_BUF_SLOPE_SEL_SHIFT 8 412845f6ecSBartlomiej Zolnierkiewicz #define EXYNOS_TMU_CORE_EN_SHIFT 0 422845f6ecSBartlomiej Zolnierkiewicz 432845f6ecSBartlomiej Zolnierkiewicz /* Exynos3250 specific registers */ 442845f6ecSBartlomiej Zolnierkiewicz #define EXYNOS_TMU_TRIMINFO_CON1 0x10 452845f6ecSBartlomiej Zolnierkiewicz 462845f6ecSBartlomiej Zolnierkiewicz /* Exynos4210 specific registers */ 472845f6ecSBartlomiej Zolnierkiewicz #define EXYNOS4210_TMU_REG_THRESHOLD_TEMP 0x44 482845f6ecSBartlomiej Zolnierkiewicz #define EXYNOS4210_TMU_REG_TRIG_LEVEL0 0x50 492845f6ecSBartlomiej Zolnierkiewicz 502845f6ecSBartlomiej Zolnierkiewicz /* Exynos5250, Exynos4412, Exynos3250 specific registers */ 512845f6ecSBartlomiej Zolnierkiewicz #define EXYNOS_TMU_TRIMINFO_CON2 0x14 522845f6ecSBartlomiej Zolnierkiewicz #define EXYNOS_THD_TEMP_RISE 0x50 532845f6ecSBartlomiej Zolnierkiewicz #define EXYNOS_THD_TEMP_FALL 0x54 542845f6ecSBartlomiej Zolnierkiewicz #define EXYNOS_EMUL_CON 0x80 552845f6ecSBartlomiej Zolnierkiewicz 562845f6ecSBartlomiej Zolnierkiewicz #define EXYNOS_TRIMINFO_RELOAD_ENABLE 1 572845f6ecSBartlomiej Zolnierkiewicz #define EXYNOS_TRIMINFO_25_SHIFT 0 582845f6ecSBartlomiej Zolnierkiewicz #define EXYNOS_TRIMINFO_85_SHIFT 8 592845f6ecSBartlomiej Zolnierkiewicz #define EXYNOS_TMU_TRIP_MODE_SHIFT 13 602845f6ecSBartlomiej Zolnierkiewicz #define EXYNOS_TMU_TRIP_MODE_MASK 0x7 612845f6ecSBartlomiej Zolnierkiewicz #define EXYNOS_TMU_THERM_TRIP_EN_SHIFT 12 622845f6ecSBartlomiej Zolnierkiewicz 632845f6ecSBartlomiej Zolnierkiewicz #define EXYNOS_TMU_INTEN_RISE0_SHIFT 0 642845f6ecSBartlomiej Zolnierkiewicz #define EXYNOS_TMU_INTEN_FALL0_SHIFT 16 652845f6ecSBartlomiej Zolnierkiewicz 662845f6ecSBartlomiej Zolnierkiewicz #define EXYNOS_EMUL_TIME 0x57F0 672845f6ecSBartlomiej Zolnierkiewicz #define EXYNOS_EMUL_TIME_MASK 0xffff 682845f6ecSBartlomiej Zolnierkiewicz #define EXYNOS_EMUL_TIME_SHIFT 16 692845f6ecSBartlomiej Zolnierkiewicz #define EXYNOS_EMUL_DATA_SHIFT 8 702845f6ecSBartlomiej Zolnierkiewicz #define EXYNOS_EMUL_DATA_MASK 0xFF 712845f6ecSBartlomiej Zolnierkiewicz #define EXYNOS_EMUL_ENABLE 0x1 722845f6ecSBartlomiej Zolnierkiewicz 732845f6ecSBartlomiej Zolnierkiewicz /* Exynos5260 specific */ 742845f6ecSBartlomiej Zolnierkiewicz #define EXYNOS5260_TMU_REG_INTEN 0xC0 752845f6ecSBartlomiej Zolnierkiewicz #define EXYNOS5260_TMU_REG_INTSTAT 0xC4 762845f6ecSBartlomiej Zolnierkiewicz #define EXYNOS5260_TMU_REG_INTCLEAR 0xC8 772845f6ecSBartlomiej Zolnierkiewicz #define EXYNOS5260_EMUL_CON 0x100 782845f6ecSBartlomiej Zolnierkiewicz 792845f6ecSBartlomiej Zolnierkiewicz /* Exynos4412 specific */ 802845f6ecSBartlomiej Zolnierkiewicz #define EXYNOS4412_MUX_ADDR_VALUE 6 812845f6ecSBartlomiej Zolnierkiewicz #define EXYNOS4412_MUX_ADDR_SHIFT 20 822845f6ecSBartlomiej Zolnierkiewicz 83488c7455SChanwoo Choi /* Exynos5433 specific registers */ 84488c7455SChanwoo Choi #define EXYNOS5433_THD_TEMP_RISE3_0 0x050 85488c7455SChanwoo Choi #define EXYNOS5433_THD_TEMP_RISE7_4 0x054 86488c7455SChanwoo Choi #define EXYNOS5433_THD_TEMP_FALL3_0 0x060 87488c7455SChanwoo Choi #define EXYNOS5433_THD_TEMP_FALL7_4 0x064 88488c7455SChanwoo Choi #define EXYNOS5433_TMU_REG_INTEN 0x0c0 89488c7455SChanwoo Choi #define EXYNOS5433_TMU_REG_INTPEND 0x0c8 90488c7455SChanwoo Choi #define EXYNOS5433_TMU_EMUL_CON 0x110 91488c7455SChanwoo Choi #define EXYNOS5433_TMU_PD_DET_EN 0x130 92488c7455SChanwoo Choi 93488c7455SChanwoo Choi #define EXYNOS5433_TRIMINFO_SENSOR_ID_SHIFT 16 94488c7455SChanwoo Choi #define EXYNOS5433_TRIMINFO_CALIB_SEL_SHIFT 23 95488c7455SChanwoo Choi #define EXYNOS5433_TRIMINFO_SENSOR_ID_MASK \ 96488c7455SChanwoo Choi (0xf << EXYNOS5433_TRIMINFO_SENSOR_ID_SHIFT) 97488c7455SChanwoo Choi #define EXYNOS5433_TRIMINFO_CALIB_SEL_MASK BIT(23) 98488c7455SChanwoo Choi 99488c7455SChanwoo Choi #define EXYNOS5433_TRIMINFO_ONE_POINT_TRIMMING 0 100488c7455SChanwoo Choi #define EXYNOS5433_TRIMINFO_TWO_POINT_TRIMMING 1 101488c7455SChanwoo Choi 102488c7455SChanwoo Choi #define EXYNOS5433_PD_DET_EN 1 103488c7455SChanwoo Choi 10461020d18SBartlomiej Zolnierkiewicz #define EXYNOS5433_G3D_BASE 0x10070000 10559dfa54cSAmit Daniel Kachhap 1066c247393SAbhilash Kesavan /* Exynos7 specific registers */ 1076c247393SAbhilash Kesavan #define EXYNOS7_THD_TEMP_RISE7_6 0x50 1086c247393SAbhilash Kesavan #define EXYNOS7_THD_TEMP_FALL7_6 0x60 1096c247393SAbhilash Kesavan #define EXYNOS7_TMU_REG_INTEN 0x110 1106c247393SAbhilash Kesavan #define EXYNOS7_TMU_REG_INTPEND 0x118 1116c247393SAbhilash Kesavan #define EXYNOS7_TMU_REG_EMUL_CON 0x160 1126c247393SAbhilash Kesavan 1136c247393SAbhilash Kesavan #define EXYNOS7_TMU_TEMP_MASK 0x1ff 1146c247393SAbhilash Kesavan #define EXYNOS7_PD_DET_EN_SHIFT 23 1156c247393SAbhilash Kesavan #define EXYNOS7_TMU_INTEN_RISE0_SHIFT 0 1166c247393SAbhilash Kesavan #define EXYNOS7_EMUL_DATA_SHIFT 7 1176c247393SAbhilash Kesavan #define EXYNOS7_EMUL_DATA_MASK 0x1ff 1186c247393SAbhilash Kesavan 119718b4ca1SBartlomiej Zolnierkiewicz #define EXYNOS_FIRST_POINT_TRIM 25 120718b4ca1SBartlomiej Zolnierkiewicz #define EXYNOS_SECOND_POINT_TRIM 85 121718b4ca1SBartlomiej Zolnierkiewicz 12209d29426SBartlomiej Zolnierkiewicz #define EXYNOS_NOISE_CANCEL_MODE 4 12309d29426SBartlomiej Zolnierkiewicz 1243b6a1a80SLukasz Majewski #define MCELSIUS 1000 1257efd18a2SBartlomiej Zolnierkiewicz 1267efd18a2SBartlomiej Zolnierkiewicz enum soc_type { 1277efd18a2SBartlomiej Zolnierkiewicz SOC_ARCH_EXYNOS3250 = 1, 1287efd18a2SBartlomiej Zolnierkiewicz SOC_ARCH_EXYNOS4210, 1297efd18a2SBartlomiej Zolnierkiewicz SOC_ARCH_EXYNOS4412, 1307efd18a2SBartlomiej Zolnierkiewicz SOC_ARCH_EXYNOS5250, 1317efd18a2SBartlomiej Zolnierkiewicz SOC_ARCH_EXYNOS5260, 1327efd18a2SBartlomiej Zolnierkiewicz SOC_ARCH_EXYNOS5420, 1337efd18a2SBartlomiej Zolnierkiewicz SOC_ARCH_EXYNOS5420_TRIMINFO, 1347efd18a2SBartlomiej Zolnierkiewicz SOC_ARCH_EXYNOS5433, 1357efd18a2SBartlomiej Zolnierkiewicz SOC_ARCH_EXYNOS7, 1367efd18a2SBartlomiej Zolnierkiewicz }; 1377efd18a2SBartlomiej Zolnierkiewicz 138cebe7373SAmit Daniel Kachhap /** 139cebe7373SAmit Daniel Kachhap * struct exynos_tmu_data : A structure to hold the private data of the TMU 1409625e9e6SAmit Kucheria * driver 141cebe7373SAmit Daniel Kachhap * @base: base address of the single instance of the TMU controller. 1429025d563SNaveen Krishna Chatradhi * @base_second: base address of the common registers of the TMU controller. 143cebe7373SAmit Daniel Kachhap * @irq: irq number of the TMU controller. 144cebe7373SAmit Daniel Kachhap * @soc: id of the SOC type. 145cebe7373SAmit Daniel Kachhap * @lock: lock to implement synchronization. 146cebe7373SAmit Daniel Kachhap * @clk: pointer to the clock structure. 14714a11dc7SNaveen Krishna Chatradhi * @clk_sec: pointer to the clock structure for accessing the base_second. 1486c247393SAbhilash Kesavan * @sclk: pointer to the clock structure for accessing the tmu special clk. 149199b3e3cSBartlomiej Zolnierkiewicz * @cal_type: calibration type for temperature 150e3ed3649SBartlomiej Zolnierkiewicz * @efuse_value: SoC defined fuse value 151e3ed3649SBartlomiej Zolnierkiewicz * @min_efuse_value: minimum valid trimming data 152e3ed3649SBartlomiej Zolnierkiewicz * @max_efuse_value: maximum valid trimming data 153cebe7373SAmit Daniel Kachhap * @temp_error1: fused value of the first point trim. 154cebe7373SAmit Daniel Kachhap * @temp_error2: fused value of the second point trim. 155fccfe099SBartlomiej Zolnierkiewicz * @gain: gain of amplifier in the positive-TC generator block 156fccfe099SBartlomiej Zolnierkiewicz * 0 < gain <= 15 15761020d18SBartlomiej Zolnierkiewicz * @reference_voltage: reference voltage of amplifier 15861020d18SBartlomiej Zolnierkiewicz * in the positive-TC generator block 15961020d18SBartlomiej Zolnierkiewicz * 0 < reference_voltage <= 31 1609625e9e6SAmit Kucheria * @tzd: pointer to thermal_zone_device structure 1613a3a5f15SKrzysztof Kozlowski * @ntrip: number of supported trip points. 16288fc6f73SMarek Szyprowski * @enabled: current status of TMU device 1639625e9e6SAmit Kucheria * @tmu_set_trip_temp: SoC specific method to set trip (rising threshold) 1649625e9e6SAmit Kucheria * @tmu_set_trip_hyst: SoC specific to set hysteresis (falling threshold) 16572d1100bSBartlomiej Zolnierkiewicz * @tmu_initialize: SoC specific TMU initialization method 16637f9034fSBartlomiej Zolnierkiewicz * @tmu_control: SoC specific TMU control method 167b79985caSBartlomiej Zolnierkiewicz * @tmu_read: SoC specific TMU temperature read method 168285d994aSBartlomiej Zolnierkiewicz * @tmu_set_emulation: SoC specific TMU emulation setting method 169a7331f72SBartlomiej Zolnierkiewicz * @tmu_clear_irqs: SoC specific TMU interrupts clearing method 170cebe7373SAmit Daniel Kachhap */ 17159dfa54cSAmit Daniel Kachhap struct exynos_tmu_data { 17259dfa54cSAmit Daniel Kachhap void __iomem *base; 1739025d563SNaveen Krishna Chatradhi void __iomem *base_second; 17459dfa54cSAmit Daniel Kachhap int irq; 17559dfa54cSAmit Daniel Kachhap enum soc_type soc; 17659dfa54cSAmit Daniel Kachhap struct mutex lock; 1776c247393SAbhilash Kesavan struct clk *clk, *clk_sec, *sclk; 178199b3e3cSBartlomiej Zolnierkiewicz u32 cal_type; 179e3ed3649SBartlomiej Zolnierkiewicz u32 efuse_value; 180e3ed3649SBartlomiej Zolnierkiewicz u32 min_efuse_value; 181e3ed3649SBartlomiej Zolnierkiewicz u32 max_efuse_value; 1826c247393SAbhilash Kesavan u16 temp_error1, temp_error2; 183fccfe099SBartlomiej Zolnierkiewicz u8 gain; 18461020d18SBartlomiej Zolnierkiewicz u8 reference_voltage; 1853b6a1a80SLukasz Majewski struct thermal_zone_device *tzd; 1863a3a5f15SKrzysztof Kozlowski unsigned int ntrip; 18788fc6f73SMarek Szyprowski bool enabled; 1883b6a1a80SLukasz Majewski 189c8f8f768SBartlomiej Zolnierkiewicz void (*tmu_set_trip_temp)(struct exynos_tmu_data *data, int trip, 190c8f8f768SBartlomiej Zolnierkiewicz u8 temp); 191c8f8f768SBartlomiej Zolnierkiewicz void (*tmu_set_trip_hyst)(struct exynos_tmu_data *data, int trip, 192c8f8f768SBartlomiej Zolnierkiewicz u8 temp, u8 hyst); 193c35268f5SBartlomiej Zolnierkiewicz void (*tmu_initialize)(struct platform_device *pdev); 19437f9034fSBartlomiej Zolnierkiewicz void (*tmu_control)(struct platform_device *pdev, bool on); 195b79985caSBartlomiej Zolnierkiewicz int (*tmu_read)(struct exynos_tmu_data *data); 19617e8351aSSascha Hauer void (*tmu_set_emulation)(struct exynos_tmu_data *data, int temp); 197a7331f72SBartlomiej Zolnierkiewicz void (*tmu_clear_irqs)(struct exynos_tmu_data *data); 19859dfa54cSAmit Daniel Kachhap }; 19959dfa54cSAmit Daniel Kachhap 20059dfa54cSAmit Daniel Kachhap /* 20159dfa54cSAmit Daniel Kachhap * TMU treats temperature as a mapped temperature code. 20259dfa54cSAmit Daniel Kachhap * The temperature is converted differently depending on the calibration type. 20359dfa54cSAmit Daniel Kachhap */ 20459dfa54cSAmit Daniel Kachhap static int temp_to_code(struct exynos_tmu_data *data, u8 temp) 20559dfa54cSAmit Daniel Kachhap { 206199b3e3cSBartlomiej Zolnierkiewicz if (data->cal_type == TYPE_ONE_POINT_TRIMMING) 207718b4ca1SBartlomiej Zolnierkiewicz return temp + data->temp_error1 - EXYNOS_FIRST_POINT_TRIM; 20859dfa54cSAmit Daniel Kachhap 209718b4ca1SBartlomiej Zolnierkiewicz return (temp - EXYNOS_FIRST_POINT_TRIM) * 21059dfa54cSAmit Daniel Kachhap (data->temp_error2 - data->temp_error1) / 211718b4ca1SBartlomiej Zolnierkiewicz (EXYNOS_SECOND_POINT_TRIM - EXYNOS_FIRST_POINT_TRIM) + 212bb34b4c8SAmit Daniel Kachhap data->temp_error1; 21359dfa54cSAmit Daniel Kachhap } 21459dfa54cSAmit Daniel Kachhap 21559dfa54cSAmit Daniel Kachhap /* 21659dfa54cSAmit Daniel Kachhap * Calculate a temperature value from a temperature code. 21759dfa54cSAmit Daniel Kachhap * The unit of the temperature is degree Celsius. 21859dfa54cSAmit Daniel Kachhap */ 2196c247393SAbhilash Kesavan static int code_to_temp(struct exynos_tmu_data *data, u16 temp_code) 22059dfa54cSAmit Daniel Kachhap { 221199b3e3cSBartlomiej Zolnierkiewicz if (data->cal_type == TYPE_ONE_POINT_TRIMMING) 222718b4ca1SBartlomiej Zolnierkiewicz return temp_code - data->temp_error1 + EXYNOS_FIRST_POINT_TRIM; 22359dfa54cSAmit Daniel Kachhap 2249c933b1bSBartlomiej Zolnierkiewicz return (temp_code - data->temp_error1) * 225718b4ca1SBartlomiej Zolnierkiewicz (EXYNOS_SECOND_POINT_TRIM - EXYNOS_FIRST_POINT_TRIM) / 226bb34b4c8SAmit Daniel Kachhap (data->temp_error2 - data->temp_error1) + 227718b4ca1SBartlomiej Zolnierkiewicz EXYNOS_FIRST_POINT_TRIM; 22859dfa54cSAmit Daniel Kachhap } 22959dfa54cSAmit Daniel Kachhap 2308328a4b1SBartlomiej Zolnierkiewicz static void sanitize_temp_error(struct exynos_tmu_data *data, u32 trim_info) 231b835ced1SBartlomiej Zolnierkiewicz { 232aef27b65SBartlomiej Zolnierkiewicz u16 tmu_temp_mask = 233aef27b65SBartlomiej Zolnierkiewicz (data->soc == SOC_ARCH_EXYNOS7) ? EXYNOS7_TMU_TEMP_MASK 234aef27b65SBartlomiej Zolnierkiewicz : EXYNOS_TMU_TEMP_MASK; 23559dfa54cSAmit Daniel Kachhap 236aef27b65SBartlomiej Zolnierkiewicz data->temp_error1 = trim_info & tmu_temp_mask; 23799d67fb9SBartlomiej Zolnierkiewicz data->temp_error2 = ((trim_info >> EXYNOS_TRIMINFO_85_SHIFT) & 238b8d582b9SAmit Daniel Kachhap EXYNOS_TMU_TEMP_MASK); 23959dfa54cSAmit Daniel Kachhap 2405000806cSAmit Daniel Kachhap if (!data->temp_error1 || 241e3ed3649SBartlomiej Zolnierkiewicz (data->min_efuse_value > data->temp_error1) || 242e3ed3649SBartlomiej Zolnierkiewicz (data->temp_error1 > data->max_efuse_value)) 243e3ed3649SBartlomiej Zolnierkiewicz data->temp_error1 = data->efuse_value & EXYNOS_TMU_TEMP_MASK; 2445000806cSAmit Daniel Kachhap 2455000806cSAmit Daniel Kachhap if (!data->temp_error2) 2465000806cSAmit Daniel Kachhap data->temp_error2 = 247e3ed3649SBartlomiej Zolnierkiewicz (data->efuse_value >> EXYNOS_TRIMINFO_85_SHIFT) & 2485000806cSAmit Daniel Kachhap EXYNOS_TMU_TEMP_MASK; 2498328a4b1SBartlomiej Zolnierkiewicz } 25059dfa54cSAmit Daniel Kachhap 25159dfa54cSAmit Daniel Kachhap static int exynos_tmu_initialize(struct platform_device *pdev) 25259dfa54cSAmit Daniel Kachhap { 25359dfa54cSAmit Daniel Kachhap struct exynos_tmu_data *data = platform_get_drvdata(pdev); 25497b3881bSBartlomiej Zolnierkiewicz unsigned int status; 255b72ba67bSMateusz Majewski int ret = 0; 2563a3a5f15SKrzysztof Kozlowski 25759dfa54cSAmit Daniel Kachhap mutex_lock(&data->lock); 25859dfa54cSAmit Daniel Kachhap clk_enable(data->clk); 25959dfa54cSAmit Daniel Kachhap if (!IS_ERR(data->clk_sec)) 26059dfa54cSAmit Daniel Kachhap clk_enable(data->clk_sec); 26197b3881bSBartlomiej Zolnierkiewicz 26297b3881bSBartlomiej Zolnierkiewicz status = readb(data->base + EXYNOS_TMU_REG_STATUS); 263fac36bacSBartlomiej Zolnierkiewicz if (!status) { 26497b3881bSBartlomiej Zolnierkiewicz ret = -EBUSY; 265fac36bacSBartlomiej Zolnierkiewicz } else { 266c35268f5SBartlomiej Zolnierkiewicz data->tmu_initialize(pdev); 267b72ba67bSMateusz Majewski data->tmu_clear_irqs(data); 268b72ba67bSMateusz Majewski } 269b72ba67bSMateusz Majewski 270b72ba67bSMateusz Majewski if (!IS_ERR(data->clk_sec)) 271b72ba67bSMateusz Majewski clk_disable(data->clk_sec); 272b72ba67bSMateusz Majewski clk_disable(data->clk); 273b72ba67bSMateusz Majewski mutex_unlock(&data->lock); 274b72ba67bSMateusz Majewski 275b72ba67bSMateusz Majewski return ret; 276b72ba67bSMateusz Majewski } 277b72ba67bSMateusz Majewski 278b72ba67bSMateusz Majewski static int exynos_thermal_zone_configure(struct platform_device *pdev) 279b72ba67bSMateusz Majewski { 280b72ba67bSMateusz Majewski struct exynos_tmu_data *data = platform_get_drvdata(pdev); 281b72ba67bSMateusz Majewski struct thermal_zone_device *tzd = data->tzd; 282b72ba67bSMateusz Majewski int i, num_trips = thermal_zone_get_num_trips(tzd); 283b72ba67bSMateusz Majewski int ret = 0, temp; 284b72ba67bSMateusz Majewski 285b72ba67bSMateusz Majewski ret = thermal_zone_get_crit_temp(tzd, &temp); 286b72ba67bSMateusz Majewski 287b72ba67bSMateusz Majewski if (ret && data->soc != SOC_ARCH_EXYNOS5433) { /* FIXME */ 288b72ba67bSMateusz Majewski dev_err(&pdev->dev, 289b72ba67bSMateusz Majewski "No CRITICAL trip point defined in device tree!\n"); 290b72ba67bSMateusz Majewski goto out; 291b72ba67bSMateusz Majewski } 292b72ba67bSMateusz Majewski 293b72ba67bSMateusz Majewski mutex_lock(&data->lock); 294b72ba67bSMateusz Majewski 295b72ba67bSMateusz Majewski if (num_trips > data->ntrip) { 296b72ba67bSMateusz Majewski dev_info(&pdev->dev, 297b72ba67bSMateusz Majewski "More trip points than supported by this TMU.\n"); 298b72ba67bSMateusz Majewski dev_info(&pdev->dev, 299b72ba67bSMateusz Majewski "%d trip points should be configured in polling mode.\n", 300b72ba67bSMateusz Majewski num_trips - data->ntrip); 301b72ba67bSMateusz Majewski } 302b72ba67bSMateusz Majewski 303b72ba67bSMateusz Majewski clk_enable(data->clk); 304b72ba67bSMateusz Majewski 305b72ba67bSMateusz Majewski num_trips = min_t(int, num_trips, data->ntrip); 306c8f8f768SBartlomiej Zolnierkiewicz 307c8f8f768SBartlomiej Zolnierkiewicz /* Write temperature code for rising and falling threshold */ 308b72ba67bSMateusz Majewski for (i = 0; i < num_trips; i++) { 309ca38255eSDaniel Lezcano struct thermal_trip trip; 310ca38255eSDaniel Lezcano 311ca38255eSDaniel Lezcano ret = thermal_zone_get_trip(tzd, i, &trip); 31289335c20SBartlomiej Zolnierkiewicz if (ret) 31389335c20SBartlomiej Zolnierkiewicz goto err; 314ca38255eSDaniel Lezcano 315ca38255eSDaniel Lezcano data->tmu_set_trip_temp(data, i, trip.temperature / MCELSIUS); 316ca38255eSDaniel Lezcano data->tmu_set_trip_hyst(data, i, trip.temperature / MCELSIUS, 317ca38255eSDaniel Lezcano trip.hysteresis / MCELSIUS); 318c8f8f768SBartlomiej Zolnierkiewicz } 319c8f8f768SBartlomiej Zolnierkiewicz 32089335c20SBartlomiej Zolnierkiewicz err: 32159dfa54cSAmit Daniel Kachhap clk_disable(data->clk); 32259dfa54cSAmit Daniel Kachhap mutex_unlock(&data->lock); 3238f1c404bSBartlomiej Zolnierkiewicz out: 32459dfa54cSAmit Daniel Kachhap return ret; 32559dfa54cSAmit Daniel Kachhap } 32659dfa54cSAmit Daniel Kachhap 327d00671c3SBartlomiej Zolnierkiewicz static u32 get_con_reg(struct exynos_tmu_data *data, u32 con) 32859dfa54cSAmit Daniel Kachhap { 3297575983cSBartlomiej Zolnierkiewicz if (data->soc == SOC_ARCH_EXYNOS4412 || 3307575983cSBartlomiej Zolnierkiewicz data->soc == SOC_ARCH_EXYNOS3250) 3317575983cSBartlomiej Zolnierkiewicz con |= (EXYNOS4412_MUX_ADDR_VALUE << EXYNOS4412_MUX_ADDR_SHIFT); 33286f5362eSLukasz Majewski 33399d67fb9SBartlomiej Zolnierkiewicz con &= ~(EXYNOS_TMU_REF_VOLTAGE_MASK << EXYNOS_TMU_REF_VOLTAGE_SHIFT); 33461020d18SBartlomiej Zolnierkiewicz con |= data->reference_voltage << EXYNOS_TMU_REF_VOLTAGE_SHIFT; 335d0a0ce3eSAmit Daniel Kachhap 33699d67fb9SBartlomiej Zolnierkiewicz con &= ~(EXYNOS_TMU_BUF_SLOPE_SEL_MASK << EXYNOS_TMU_BUF_SLOPE_SEL_SHIFT); 337fccfe099SBartlomiej Zolnierkiewicz con |= (data->gain << EXYNOS_TMU_BUF_SLOPE_SEL_SHIFT); 338d0a0ce3eSAmit Daniel Kachhap 339b9504a6aSBartlomiej Zolnierkiewicz con &= ~(EXYNOS_TMU_TRIP_MODE_MASK << EXYNOS_TMU_TRIP_MODE_SHIFT); 34009d29426SBartlomiej Zolnierkiewicz con |= (EXYNOS_NOISE_CANCEL_MODE << EXYNOS_TMU_TRIP_MODE_SHIFT); 34159dfa54cSAmit Daniel Kachhap 342d00671c3SBartlomiej Zolnierkiewicz return con; 343d00671c3SBartlomiej Zolnierkiewicz } 344d00671c3SBartlomiej Zolnierkiewicz 345d00671c3SBartlomiej Zolnierkiewicz static void exynos_tmu_control(struct platform_device *pdev, bool on) 346d00671c3SBartlomiej Zolnierkiewicz { 347d00671c3SBartlomiej Zolnierkiewicz struct exynos_tmu_data *data = platform_get_drvdata(pdev); 348d00671c3SBartlomiej Zolnierkiewicz 349d00671c3SBartlomiej Zolnierkiewicz mutex_lock(&data->lock); 350d00671c3SBartlomiej Zolnierkiewicz clk_enable(data->clk); 35137f9034fSBartlomiej Zolnierkiewicz data->tmu_control(pdev, on); 35288fc6f73SMarek Szyprowski data->enabled = on; 35359dfa54cSAmit Daniel Kachhap clk_disable(data->clk); 35459dfa54cSAmit Daniel Kachhap mutex_unlock(&data->lock); 35559dfa54cSAmit Daniel Kachhap } 35659dfa54cSAmit Daniel Kachhap 357a503a10fSBartlomiej Zolnierkiewicz static void exynos4210_tmu_set_trip_temp(struct exynos_tmu_data *data, 358ca38255eSDaniel Lezcano int trip_id, u8 temp) 35972d1100bSBartlomiej Zolnierkiewicz { 360d7a5b431SMateusz Majewski temp = temp_to_code(data, temp); 361ca38255eSDaniel Lezcano writeb(temp, data->base + EXYNOS4210_TMU_REG_TRIG_LEVEL0 + trip_id * 4); 362a503a10fSBartlomiej Zolnierkiewicz } 363a503a10fSBartlomiej Zolnierkiewicz 364c8f8f768SBartlomiej Zolnierkiewicz /* failing thresholds are not supported on Exynos4210 */ 365c8f8f768SBartlomiej Zolnierkiewicz static void exynos4210_tmu_set_trip_hyst(struct exynos_tmu_data *data, 366c8f8f768SBartlomiej Zolnierkiewicz int trip, u8 temp, u8 hyst) 367c8f8f768SBartlomiej Zolnierkiewicz { 368c8f8f768SBartlomiej Zolnierkiewicz } 369c8f8f768SBartlomiej Zolnierkiewicz 370c35268f5SBartlomiej Zolnierkiewicz static void exynos4210_tmu_initialize(struct platform_device *pdev) 37172d1100bSBartlomiej Zolnierkiewicz { 37272d1100bSBartlomiej Zolnierkiewicz struct exynos_tmu_data *data = platform_get_drvdata(pdev); 37372d1100bSBartlomiej Zolnierkiewicz 37472d1100bSBartlomiej Zolnierkiewicz sanitize_temp_error(data, readl(data->base + EXYNOS_TMU_REG_TRIMINFO)); 375d7a5b431SMateusz Majewski 376d7a5b431SMateusz Majewski writeb(0, data->base + EXYNOS4210_TMU_REG_THRESHOLD_TEMP); 37772d1100bSBartlomiej Zolnierkiewicz } 37872d1100bSBartlomiej Zolnierkiewicz 379a503a10fSBartlomiej Zolnierkiewicz static void exynos4412_tmu_set_trip_temp(struct exynos_tmu_data *data, 380a503a10fSBartlomiej Zolnierkiewicz int trip, u8 temp) 381a503a10fSBartlomiej Zolnierkiewicz { 382a503a10fSBartlomiej Zolnierkiewicz u32 th, con; 383a503a10fSBartlomiej Zolnierkiewicz 384a503a10fSBartlomiej Zolnierkiewicz th = readl(data->base + EXYNOS_THD_TEMP_RISE); 385a503a10fSBartlomiej Zolnierkiewicz th &= ~(0xff << 8 * trip); 386a503a10fSBartlomiej Zolnierkiewicz th |= temp_to_code(data, temp) << 8 * trip; 387a503a10fSBartlomiej Zolnierkiewicz writel(th, data->base + EXYNOS_THD_TEMP_RISE); 388a503a10fSBartlomiej Zolnierkiewicz 389a503a10fSBartlomiej Zolnierkiewicz if (trip == 3) { 390a503a10fSBartlomiej Zolnierkiewicz con = readl(data->base + EXYNOS_TMU_REG_CONTROL); 391*af00d488SMateusz Majewski con |= BIT(EXYNOS_TMU_THERM_TRIP_EN_SHIFT); 392a503a10fSBartlomiej Zolnierkiewicz writel(con, data->base + EXYNOS_TMU_REG_CONTROL); 393a503a10fSBartlomiej Zolnierkiewicz } 394a503a10fSBartlomiej Zolnierkiewicz } 395a503a10fSBartlomiej Zolnierkiewicz 396a503a10fSBartlomiej Zolnierkiewicz static void exynos4412_tmu_set_trip_hyst(struct exynos_tmu_data *data, 397a503a10fSBartlomiej Zolnierkiewicz int trip, u8 temp, u8 hyst) 398a503a10fSBartlomiej Zolnierkiewicz { 399a503a10fSBartlomiej Zolnierkiewicz u32 th; 400a503a10fSBartlomiej Zolnierkiewicz 401a503a10fSBartlomiej Zolnierkiewicz th = readl(data->base + EXYNOS_THD_TEMP_FALL); 402a503a10fSBartlomiej Zolnierkiewicz th &= ~(0xff << 8 * trip); 403a503a10fSBartlomiej Zolnierkiewicz if (hyst) 404a503a10fSBartlomiej Zolnierkiewicz th |= temp_to_code(data, temp - hyst) << 8 * trip; 405a503a10fSBartlomiej Zolnierkiewicz writel(th, data->base + EXYNOS_THD_TEMP_FALL); 406a503a10fSBartlomiej Zolnierkiewicz } 407a503a10fSBartlomiej Zolnierkiewicz 408c35268f5SBartlomiej Zolnierkiewicz static void exynos4412_tmu_initialize(struct platform_device *pdev) 40972d1100bSBartlomiej Zolnierkiewicz { 41072d1100bSBartlomiej Zolnierkiewicz struct exynos_tmu_data *data = platform_get_drvdata(pdev); 411a503a10fSBartlomiej Zolnierkiewicz unsigned int trim_info, ctrl; 41272d1100bSBartlomiej Zolnierkiewicz 41372d1100bSBartlomiej Zolnierkiewicz if (data->soc == SOC_ARCH_EXYNOS3250 || 41472d1100bSBartlomiej Zolnierkiewicz data->soc == SOC_ARCH_EXYNOS4412 || 41572d1100bSBartlomiej Zolnierkiewicz data->soc == SOC_ARCH_EXYNOS5250) { 41672d1100bSBartlomiej Zolnierkiewicz if (data->soc == SOC_ARCH_EXYNOS3250) { 41772d1100bSBartlomiej Zolnierkiewicz ctrl = readl(data->base + EXYNOS_TMU_TRIMINFO_CON1); 41872d1100bSBartlomiej Zolnierkiewicz ctrl |= EXYNOS_TRIMINFO_RELOAD_ENABLE; 41972d1100bSBartlomiej Zolnierkiewicz writel(ctrl, data->base + EXYNOS_TMU_TRIMINFO_CON1); 42072d1100bSBartlomiej Zolnierkiewicz } 42172d1100bSBartlomiej Zolnierkiewicz ctrl = readl(data->base + EXYNOS_TMU_TRIMINFO_CON2); 42272d1100bSBartlomiej Zolnierkiewicz ctrl |= EXYNOS_TRIMINFO_RELOAD_ENABLE; 42372d1100bSBartlomiej Zolnierkiewicz writel(ctrl, data->base + EXYNOS_TMU_TRIMINFO_CON2); 42472d1100bSBartlomiej Zolnierkiewicz } 42572d1100bSBartlomiej Zolnierkiewicz 42672d1100bSBartlomiej Zolnierkiewicz /* On exynos5420 the triminfo register is in the shared space */ 42772d1100bSBartlomiej Zolnierkiewicz if (data->soc == SOC_ARCH_EXYNOS5420_TRIMINFO) 42872d1100bSBartlomiej Zolnierkiewicz trim_info = readl(data->base_second + EXYNOS_TMU_REG_TRIMINFO); 42972d1100bSBartlomiej Zolnierkiewicz else 43072d1100bSBartlomiej Zolnierkiewicz trim_info = readl(data->base + EXYNOS_TMU_REG_TRIMINFO); 43172d1100bSBartlomiej Zolnierkiewicz 43272d1100bSBartlomiej Zolnierkiewicz sanitize_temp_error(data, trim_info); 4333b6a1a80SLukasz Majewski } 4343b6a1a80SLukasz Majewski 435a503a10fSBartlomiej Zolnierkiewicz static void exynos5433_tmu_set_trip_temp(struct exynos_tmu_data *data, 436a503a10fSBartlomiej Zolnierkiewicz int trip, u8 temp) 437a503a10fSBartlomiej Zolnierkiewicz { 438a503a10fSBartlomiej Zolnierkiewicz unsigned int reg_off, j; 439a503a10fSBartlomiej Zolnierkiewicz u32 th; 440a503a10fSBartlomiej Zolnierkiewicz 441a503a10fSBartlomiej Zolnierkiewicz if (trip > 3) { 442a503a10fSBartlomiej Zolnierkiewicz reg_off = EXYNOS5433_THD_TEMP_RISE7_4; 443a503a10fSBartlomiej Zolnierkiewicz j = trip - 4; 444a503a10fSBartlomiej Zolnierkiewicz } else { 445a503a10fSBartlomiej Zolnierkiewicz reg_off = EXYNOS5433_THD_TEMP_RISE3_0; 446a503a10fSBartlomiej Zolnierkiewicz j = trip; 4473b6a1a80SLukasz Majewski } 4483b6a1a80SLukasz Majewski 449a503a10fSBartlomiej Zolnierkiewicz th = readl(data->base + reg_off); 450a503a10fSBartlomiej Zolnierkiewicz th &= ~(0xff << j * 8); 451a503a10fSBartlomiej Zolnierkiewicz th |= (temp_to_code(data, temp) << j * 8); 452a503a10fSBartlomiej Zolnierkiewicz writel(th, data->base + reg_off); 45372d1100bSBartlomiej Zolnierkiewicz } 45472d1100bSBartlomiej Zolnierkiewicz 455a503a10fSBartlomiej Zolnierkiewicz static void exynos5433_tmu_set_trip_hyst(struct exynos_tmu_data *data, 456a503a10fSBartlomiej Zolnierkiewicz int trip, u8 temp, u8 hyst) 457a503a10fSBartlomiej Zolnierkiewicz { 458a503a10fSBartlomiej Zolnierkiewicz unsigned int reg_off, j; 459a503a10fSBartlomiej Zolnierkiewicz u32 th; 460a503a10fSBartlomiej Zolnierkiewicz 461a503a10fSBartlomiej Zolnierkiewicz if (trip > 3) { 462a503a10fSBartlomiej Zolnierkiewicz reg_off = EXYNOS5433_THD_TEMP_FALL7_4; 463a503a10fSBartlomiej Zolnierkiewicz j = trip - 4; 464a503a10fSBartlomiej Zolnierkiewicz } else { 465a503a10fSBartlomiej Zolnierkiewicz reg_off = EXYNOS5433_THD_TEMP_FALL3_0; 466a503a10fSBartlomiej Zolnierkiewicz j = trip; 467a503a10fSBartlomiej Zolnierkiewicz } 468a503a10fSBartlomiej Zolnierkiewicz 469a503a10fSBartlomiej Zolnierkiewicz th = readl(data->base + reg_off); 470a503a10fSBartlomiej Zolnierkiewicz th &= ~(0xff << j * 8); 471a503a10fSBartlomiej Zolnierkiewicz th |= (temp_to_code(data, temp - hyst) << j * 8); 472a503a10fSBartlomiej Zolnierkiewicz writel(th, data->base + reg_off); 47372d1100bSBartlomiej Zolnierkiewicz } 47472d1100bSBartlomiej Zolnierkiewicz 475c35268f5SBartlomiej Zolnierkiewicz static void exynos5433_tmu_initialize(struct platform_device *pdev) 476488c7455SChanwoo Choi { 477488c7455SChanwoo Choi struct exynos_tmu_data *data = platform_get_drvdata(pdev); 47897b3881bSBartlomiej Zolnierkiewicz unsigned int trim_info; 479c8f8f768SBartlomiej Zolnierkiewicz int sensor_id, cal_type; 480488c7455SChanwoo Choi 481488c7455SChanwoo Choi trim_info = readl(data->base + EXYNOS_TMU_REG_TRIMINFO); 482488c7455SChanwoo Choi sanitize_temp_error(data, trim_info); 483488c7455SChanwoo Choi 484488c7455SChanwoo Choi /* Read the temperature sensor id */ 485488c7455SChanwoo Choi sensor_id = (trim_info & EXYNOS5433_TRIMINFO_SENSOR_ID_MASK) 486488c7455SChanwoo Choi >> EXYNOS5433_TRIMINFO_SENSOR_ID_SHIFT; 487488c7455SChanwoo Choi dev_info(&pdev->dev, "Temperature sensor ID: 0x%x\n", sensor_id); 488488c7455SChanwoo Choi 489488c7455SChanwoo Choi /* Read the calibration mode */ 490488c7455SChanwoo Choi writel(trim_info, data->base + EXYNOS_TMU_REG_TRIMINFO); 491488c7455SChanwoo Choi cal_type = (trim_info & EXYNOS5433_TRIMINFO_CALIB_SEL_MASK) 492488c7455SChanwoo Choi >> EXYNOS5433_TRIMINFO_CALIB_SEL_SHIFT; 493488c7455SChanwoo Choi 494488c7455SChanwoo Choi switch (cal_type) { 495488c7455SChanwoo Choi case EXYNOS5433_TRIMINFO_TWO_POINT_TRIMMING: 496199b3e3cSBartlomiej Zolnierkiewicz data->cal_type = TYPE_TWO_POINT_TRIMMING; 497488c7455SChanwoo Choi break; 498199b3e3cSBartlomiej Zolnierkiewicz case EXYNOS5433_TRIMINFO_ONE_POINT_TRIMMING: 499488c7455SChanwoo Choi default: 500199b3e3cSBartlomiej Zolnierkiewicz data->cal_type = TYPE_ONE_POINT_TRIMMING; 501488c7455SChanwoo Choi break; 502baba1ebbSKrzysztof Kozlowski } 503488c7455SChanwoo Choi 504488c7455SChanwoo Choi dev_info(&pdev->dev, "Calibration type is %d-point calibration\n", 505488c7455SChanwoo Choi cal_type ? 2 : 1); 506488c7455SChanwoo Choi } 507488c7455SChanwoo Choi 508a503a10fSBartlomiej Zolnierkiewicz static void exynos7_tmu_set_trip_temp(struct exynos_tmu_data *data, 509a503a10fSBartlomiej Zolnierkiewicz int trip, u8 temp) 51072d1100bSBartlomiej Zolnierkiewicz { 5116c247393SAbhilash Kesavan unsigned int reg_off, bit_off; 512a503a10fSBartlomiej Zolnierkiewicz u32 th; 5136c247393SAbhilash Kesavan 514a503a10fSBartlomiej Zolnierkiewicz reg_off = ((7 - trip) / 2) * 4; 515a503a10fSBartlomiej Zolnierkiewicz bit_off = ((8 - trip) % 2); 516a503a10fSBartlomiej Zolnierkiewicz 517a503a10fSBartlomiej Zolnierkiewicz th = readl(data->base + EXYNOS7_THD_TEMP_RISE7_6 + reg_off); 518a503a10fSBartlomiej Zolnierkiewicz th &= ~(EXYNOS7_TMU_TEMP_MASK << (16 * bit_off)); 519a503a10fSBartlomiej Zolnierkiewicz th |= temp_to_code(data, temp) << (16 * bit_off); 520a503a10fSBartlomiej Zolnierkiewicz writel(th, data->base + EXYNOS7_THD_TEMP_RISE7_6 + reg_off); 5216c247393SAbhilash Kesavan } 5226c247393SAbhilash Kesavan 523a503a10fSBartlomiej Zolnierkiewicz static void exynos7_tmu_set_trip_hyst(struct exynos_tmu_data *data, 524a503a10fSBartlomiej Zolnierkiewicz int trip, u8 temp, u8 hyst) 525a503a10fSBartlomiej Zolnierkiewicz { 526a503a10fSBartlomiej Zolnierkiewicz unsigned int reg_off, bit_off; 527a503a10fSBartlomiej Zolnierkiewicz u32 th; 528a503a10fSBartlomiej Zolnierkiewicz 529a503a10fSBartlomiej Zolnierkiewicz reg_off = ((7 - trip) / 2) * 4; 530a503a10fSBartlomiej Zolnierkiewicz bit_off = ((8 - trip) % 2); 531a503a10fSBartlomiej Zolnierkiewicz 532a503a10fSBartlomiej Zolnierkiewicz th = readl(data->base + EXYNOS7_THD_TEMP_FALL7_6 + reg_off); 533a503a10fSBartlomiej Zolnierkiewicz th &= ~(EXYNOS7_TMU_TEMP_MASK << (16 * bit_off)); 534a503a10fSBartlomiej Zolnierkiewicz th |= temp_to_code(data, temp - hyst) << (16 * bit_off); 535a503a10fSBartlomiej Zolnierkiewicz writel(th, data->base + EXYNOS7_THD_TEMP_FALL7_6 + reg_off); 536a503a10fSBartlomiej Zolnierkiewicz } 537a503a10fSBartlomiej Zolnierkiewicz 538c35268f5SBartlomiej Zolnierkiewicz static void exynos7_tmu_initialize(struct platform_device *pdev) 5396c247393SAbhilash Kesavan { 5406c247393SAbhilash Kesavan struct exynos_tmu_data *data = platform_get_drvdata(pdev); 54197b3881bSBartlomiej Zolnierkiewicz unsigned int trim_info; 5426c247393SAbhilash Kesavan 5436c247393SAbhilash Kesavan trim_info = readl(data->base + EXYNOS_TMU_REG_TRIMINFO); 544aef27b65SBartlomiej Zolnierkiewicz sanitize_temp_error(data, trim_info); 5456c247393SAbhilash Kesavan } 5466c247393SAbhilash Kesavan 54737f9034fSBartlomiej Zolnierkiewicz static void exynos4210_tmu_control(struct platform_device *pdev, bool on) 54837f9034fSBartlomiej Zolnierkiewicz { 54937f9034fSBartlomiej Zolnierkiewicz struct exynos_tmu_data *data = platform_get_drvdata(pdev); 5503b6a1a80SLukasz Majewski struct thermal_zone_device *tz = data->tzd; 55103ef4855SDaniel Lezcano struct thermal_trip trip; 55264e94192SBartlomiej Zolnierkiewicz unsigned int con, interrupt_en = 0, i; 55337f9034fSBartlomiej Zolnierkiewicz 55437f9034fSBartlomiej Zolnierkiewicz con = get_con_reg(data, readl(data->base + EXYNOS_TMU_REG_CONTROL)); 55537f9034fSBartlomiej Zolnierkiewicz 55659dfa54cSAmit Daniel Kachhap if (on) { 55764e94192SBartlomiej Zolnierkiewicz for (i = 0; i < data->ntrip; i++) { 55803ef4855SDaniel Lezcano if (thermal_zone_get_trip(tz, i, &trip)) 55964e94192SBartlomiej Zolnierkiewicz continue; 56064e94192SBartlomiej Zolnierkiewicz 56164e94192SBartlomiej Zolnierkiewicz interrupt_en |= 562*af00d488SMateusz Majewski BIT(EXYNOS_TMU_INTEN_RISE0_SHIFT + i * 4); 56364e94192SBartlomiej Zolnierkiewicz } 5643b6a1a80SLukasz Majewski 565e0761533SBartlomiej Zolnierkiewicz if (data->soc != SOC_ARCH_EXYNOS4210) 56659dfa54cSAmit Daniel Kachhap interrupt_en |= 56737f9034fSBartlomiej Zolnierkiewicz interrupt_en << EXYNOS_TMU_INTEN_FALL0_SHIFT; 56864e94192SBartlomiej Zolnierkiewicz 569*af00d488SMateusz Majewski con |= BIT(EXYNOS_TMU_CORE_EN_SHIFT); 57059dfa54cSAmit Daniel Kachhap } else { 571*af00d488SMateusz Majewski con &= ~BIT(EXYNOS_TMU_CORE_EN_SHIFT); 57259dfa54cSAmit Daniel Kachhap } 57364e94192SBartlomiej Zolnierkiewicz 57437f9034fSBartlomiej Zolnierkiewicz writel(interrupt_en, data->base + EXYNOS_TMU_REG_INTEN); 57537f9034fSBartlomiej Zolnierkiewicz writel(con, data->base + EXYNOS_TMU_REG_CONTROL); 57637f9034fSBartlomiej Zolnierkiewicz } 57759dfa54cSAmit Daniel Kachhap 578488c7455SChanwoo Choi static void exynos5433_tmu_control(struct platform_device *pdev, bool on) 579488c7455SChanwoo Choi { 580488c7455SChanwoo Choi struct exynos_tmu_data *data = platform_get_drvdata(pdev); 581488c7455SChanwoo Choi struct thermal_zone_device *tz = data->tzd; 58203ef4855SDaniel Lezcano struct thermal_trip trip; 58364e94192SBartlomiej Zolnierkiewicz unsigned int con, interrupt_en = 0, pd_det_en, i; 584488c7455SChanwoo Choi 585488c7455SChanwoo Choi con = get_con_reg(data, readl(data->base + EXYNOS_TMU_REG_CONTROL)); 586488c7455SChanwoo Choi 587488c7455SChanwoo Choi if (on) { 58864e94192SBartlomiej Zolnierkiewicz for (i = 0; i < data->ntrip; i++) { 58903ef4855SDaniel Lezcano if (thermal_zone_get_trip(tz, i, &trip)) 59064e94192SBartlomiej Zolnierkiewicz continue; 59164e94192SBartlomiej Zolnierkiewicz 59264e94192SBartlomiej Zolnierkiewicz interrupt_en |= 593*af00d488SMateusz Majewski BIT(EXYNOS7_TMU_INTEN_RISE0_SHIFT + i); 59464e94192SBartlomiej Zolnierkiewicz } 595488c7455SChanwoo Choi 596488c7455SChanwoo Choi interrupt_en |= 597488c7455SChanwoo Choi interrupt_en << EXYNOS_TMU_INTEN_FALL0_SHIFT; 59864e94192SBartlomiej Zolnierkiewicz 599*af00d488SMateusz Majewski con |= BIT(EXYNOS_TMU_CORE_EN_SHIFT); 60064e94192SBartlomiej Zolnierkiewicz } else 601*af00d488SMateusz Majewski con &= ~BIT(EXYNOS_TMU_CORE_EN_SHIFT); 602488c7455SChanwoo Choi 603488c7455SChanwoo Choi pd_det_en = on ? EXYNOS5433_PD_DET_EN : 0; 604488c7455SChanwoo Choi 605488c7455SChanwoo Choi writel(pd_det_en, data->base + EXYNOS5433_TMU_PD_DET_EN); 606488c7455SChanwoo Choi writel(interrupt_en, data->base + EXYNOS5433_TMU_REG_INTEN); 607488c7455SChanwoo Choi writel(con, data->base + EXYNOS_TMU_REG_CONTROL); 608488c7455SChanwoo Choi } 609488c7455SChanwoo Choi 6106c247393SAbhilash Kesavan static void exynos7_tmu_control(struct platform_device *pdev, bool on) 6116c247393SAbhilash Kesavan { 6126c247393SAbhilash Kesavan struct exynos_tmu_data *data = platform_get_drvdata(pdev); 6136c247393SAbhilash Kesavan struct thermal_zone_device *tz = data->tzd; 61403ef4855SDaniel Lezcano struct thermal_trip trip; 61564e94192SBartlomiej Zolnierkiewicz unsigned int con, interrupt_en = 0, i; 6166c247393SAbhilash Kesavan 6176c247393SAbhilash Kesavan con = get_con_reg(data, readl(data->base + EXYNOS_TMU_REG_CONTROL)); 6186c247393SAbhilash Kesavan 6196c247393SAbhilash Kesavan if (on) { 62064e94192SBartlomiej Zolnierkiewicz for (i = 0; i < data->ntrip; i++) { 62103ef4855SDaniel Lezcano if (thermal_zone_get_trip(tz, i, &trip)) 62264e94192SBartlomiej Zolnierkiewicz continue; 62364e94192SBartlomiej Zolnierkiewicz 62464e94192SBartlomiej Zolnierkiewicz interrupt_en |= 625*af00d488SMateusz Majewski BIT(EXYNOS7_TMU_INTEN_RISE0_SHIFT + i); 62664e94192SBartlomiej Zolnierkiewicz } 6276c247393SAbhilash Kesavan 6286c247393SAbhilash Kesavan interrupt_en |= 6296c247393SAbhilash Kesavan interrupt_en << EXYNOS_TMU_INTEN_FALL0_SHIFT; 63064e94192SBartlomiej Zolnierkiewicz 631*af00d488SMateusz Majewski con |= BIT(EXYNOS_TMU_CORE_EN_SHIFT); 632*af00d488SMateusz Majewski con |= BIT(EXYNOS7_PD_DET_EN_SHIFT); 6336c247393SAbhilash Kesavan } else { 634*af00d488SMateusz Majewski con &= ~BIT(EXYNOS_TMU_CORE_EN_SHIFT); 635*af00d488SMateusz Majewski con &= ~BIT(EXYNOS7_PD_DET_EN_SHIFT); 6366c247393SAbhilash Kesavan } 6376c247393SAbhilash Kesavan 6386c247393SAbhilash Kesavan writel(interrupt_en, data->base + EXYNOS7_TMU_REG_INTEN); 6396c247393SAbhilash Kesavan writel(con, data->base + EXYNOS_TMU_REG_CONTROL); 6406c247393SAbhilash Kesavan } 6416c247393SAbhilash Kesavan 6427ea98f70SDaniel Lezcano static int exynos_get_temp(struct thermal_zone_device *tz, int *temp) 64359dfa54cSAmit Daniel Kachhap { 6445f68d078SDaniel Lezcano struct exynos_tmu_data *data = thermal_zone_device_priv(tz); 645c8da6cdeSMarek Szyprowski int value, ret = 0; 6463b6a1a80SLukasz Majewski 6473b5236ccSMarek Szyprowski if (!data || !data->tmu_read) 6483b6a1a80SLukasz Majewski return -EINVAL; 649ffe6e16fSKrzysztof Kozlowski else if (!data->enabled) 650ffe6e16fSKrzysztof Kozlowski /* 651ffe6e16fSKrzysztof Kozlowski * Called too early, probably 652ffe6e16fSKrzysztof Kozlowski * from thermal_zone_of_sensor_register(). 653ffe6e16fSKrzysztof Kozlowski */ 654ffe6e16fSKrzysztof Kozlowski return -EAGAIN; 65559dfa54cSAmit Daniel Kachhap 65659dfa54cSAmit Daniel Kachhap mutex_lock(&data->lock); 65759dfa54cSAmit Daniel Kachhap clk_enable(data->clk); 6583b6a1a80SLukasz Majewski 659c8da6cdeSMarek Szyprowski value = data->tmu_read(data); 660c8da6cdeSMarek Szyprowski if (value < 0) 661c8da6cdeSMarek Szyprowski ret = value; 662c8da6cdeSMarek Szyprowski else 663c8da6cdeSMarek Szyprowski *temp = code_to_temp(data, value) * MCELSIUS; 6643b6a1a80SLukasz Majewski 66559dfa54cSAmit Daniel Kachhap clk_disable(data->clk); 66659dfa54cSAmit Daniel Kachhap mutex_unlock(&data->lock); 66759dfa54cSAmit Daniel Kachhap 668c8da6cdeSMarek Szyprowski return ret; 66959dfa54cSAmit Daniel Kachhap } 67059dfa54cSAmit Daniel Kachhap 67159dfa54cSAmit Daniel Kachhap #ifdef CONFIG_THERMAL_EMULATION 672154013eaSBartlomiej Zolnierkiewicz static u32 get_emul_con_reg(struct exynos_tmu_data *data, unsigned int val, 67317e8351aSSascha Hauer int temp) 674154013eaSBartlomiej Zolnierkiewicz { 675154013eaSBartlomiej Zolnierkiewicz if (temp) { 676154013eaSBartlomiej Zolnierkiewicz temp /= MCELSIUS; 677154013eaSBartlomiej Zolnierkiewicz 678154013eaSBartlomiej Zolnierkiewicz val &= ~(EXYNOS_EMUL_TIME_MASK << EXYNOS_EMUL_TIME_SHIFT); 679154013eaSBartlomiej Zolnierkiewicz val |= (EXYNOS_EMUL_TIME << EXYNOS_EMUL_TIME_SHIFT); 6806c247393SAbhilash Kesavan if (data->soc == SOC_ARCH_EXYNOS7) { 6816c247393SAbhilash Kesavan val &= ~(EXYNOS7_EMUL_DATA_MASK << 6826c247393SAbhilash Kesavan EXYNOS7_EMUL_DATA_SHIFT); 6836c247393SAbhilash Kesavan val |= (temp_to_code(data, temp) << 6846c247393SAbhilash Kesavan EXYNOS7_EMUL_DATA_SHIFT) | 685154013eaSBartlomiej Zolnierkiewicz EXYNOS_EMUL_ENABLE; 686154013eaSBartlomiej Zolnierkiewicz } else { 6876c247393SAbhilash Kesavan val &= ~(EXYNOS_EMUL_DATA_MASK << 6886c247393SAbhilash Kesavan EXYNOS_EMUL_DATA_SHIFT); 6896c247393SAbhilash Kesavan val |= (temp_to_code(data, temp) << 6906c247393SAbhilash Kesavan EXYNOS_EMUL_DATA_SHIFT) | 6916c247393SAbhilash Kesavan EXYNOS_EMUL_ENABLE; 6926c247393SAbhilash Kesavan } 6936c247393SAbhilash Kesavan } else { 694154013eaSBartlomiej Zolnierkiewicz val &= ~EXYNOS_EMUL_ENABLE; 695154013eaSBartlomiej Zolnierkiewicz } 696154013eaSBartlomiej Zolnierkiewicz 697154013eaSBartlomiej Zolnierkiewicz return val; 698154013eaSBartlomiej Zolnierkiewicz } 699154013eaSBartlomiej Zolnierkiewicz 700285d994aSBartlomiej Zolnierkiewicz static void exynos4412_tmu_set_emulation(struct exynos_tmu_data *data, 70117e8351aSSascha Hauer int temp) 702285d994aSBartlomiej Zolnierkiewicz { 703285d994aSBartlomiej Zolnierkiewicz unsigned int val; 704285d994aSBartlomiej Zolnierkiewicz u32 emul_con; 705285d994aSBartlomiej Zolnierkiewicz 706285d994aSBartlomiej Zolnierkiewicz if (data->soc == SOC_ARCH_EXYNOS5260) 707285d994aSBartlomiej Zolnierkiewicz emul_con = EXYNOS5260_EMUL_CON; 708b28fec13SSudip Mukherjee else if (data->soc == SOC_ARCH_EXYNOS5433) 709488c7455SChanwoo Choi emul_con = EXYNOS5433_TMU_EMUL_CON; 7106c247393SAbhilash Kesavan else if (data->soc == SOC_ARCH_EXYNOS7) 7116c247393SAbhilash Kesavan emul_con = EXYNOS7_TMU_REG_EMUL_CON; 712285d994aSBartlomiej Zolnierkiewicz else 713285d994aSBartlomiej Zolnierkiewicz emul_con = EXYNOS_EMUL_CON; 714285d994aSBartlomiej Zolnierkiewicz 715285d994aSBartlomiej Zolnierkiewicz val = readl(data->base + emul_con); 716285d994aSBartlomiej Zolnierkiewicz val = get_emul_con_reg(data, val, temp); 717285d994aSBartlomiej Zolnierkiewicz writel(val, data->base + emul_con); 718285d994aSBartlomiej Zolnierkiewicz } 719285d994aSBartlomiej Zolnierkiewicz 7207ea98f70SDaniel Lezcano static int exynos_tmu_set_emulation(struct thermal_zone_device *tz, int temp) 72159dfa54cSAmit Daniel Kachhap { 7225f68d078SDaniel Lezcano struct exynos_tmu_data *data = thermal_zone_device_priv(tz); 72359dfa54cSAmit Daniel Kachhap int ret = -EINVAL; 72459dfa54cSAmit Daniel Kachhap 725ef3f80fcSBartlomiej Zolnierkiewicz if (data->soc == SOC_ARCH_EXYNOS4210) 72659dfa54cSAmit Daniel Kachhap goto out; 72759dfa54cSAmit Daniel Kachhap 72859dfa54cSAmit Daniel Kachhap if (temp && temp < MCELSIUS) 72959dfa54cSAmit Daniel Kachhap goto out; 73059dfa54cSAmit Daniel Kachhap 73159dfa54cSAmit Daniel Kachhap mutex_lock(&data->lock); 73259dfa54cSAmit Daniel Kachhap clk_enable(data->clk); 733285d994aSBartlomiej Zolnierkiewicz data->tmu_set_emulation(data, temp); 73459dfa54cSAmit Daniel Kachhap clk_disable(data->clk); 73559dfa54cSAmit Daniel Kachhap mutex_unlock(&data->lock); 73659dfa54cSAmit Daniel Kachhap return 0; 73759dfa54cSAmit Daniel Kachhap out: 73859dfa54cSAmit Daniel Kachhap return ret; 73959dfa54cSAmit Daniel Kachhap } 74059dfa54cSAmit Daniel Kachhap #else 741285d994aSBartlomiej Zolnierkiewicz #define exynos4412_tmu_set_emulation NULL 7427ea98f70SDaniel Lezcano static int exynos_tmu_set_emulation(struct thermal_zone_device *tz, int temp) 74359dfa54cSAmit Daniel Kachhap { return -EINVAL; } 74459dfa54cSAmit Daniel Kachhap #endif /* CONFIG_THERMAL_EMULATION */ 74559dfa54cSAmit Daniel Kachhap 746b79985caSBartlomiej Zolnierkiewicz static int exynos4210_tmu_read(struct exynos_tmu_data *data) 747b79985caSBartlomiej Zolnierkiewicz { 748b79985caSBartlomiej Zolnierkiewicz int ret = readb(data->base + EXYNOS_TMU_REG_CURRENT_TEMP); 749b79985caSBartlomiej Zolnierkiewicz 750b79985caSBartlomiej Zolnierkiewicz /* "temp_code" should range between 75 and 175 */ 751b79985caSBartlomiej Zolnierkiewicz return (ret < 75 || ret > 175) ? -ENODATA : ret; 752b79985caSBartlomiej Zolnierkiewicz } 753b79985caSBartlomiej Zolnierkiewicz 754b79985caSBartlomiej Zolnierkiewicz static int exynos4412_tmu_read(struct exynos_tmu_data *data) 755b79985caSBartlomiej Zolnierkiewicz { 756b79985caSBartlomiej Zolnierkiewicz return readb(data->base + EXYNOS_TMU_REG_CURRENT_TEMP); 757b79985caSBartlomiej Zolnierkiewicz } 758b79985caSBartlomiej Zolnierkiewicz 7596c247393SAbhilash Kesavan static int exynos7_tmu_read(struct exynos_tmu_data *data) 7606c247393SAbhilash Kesavan { 7616c247393SAbhilash Kesavan return readw(data->base + EXYNOS_TMU_REG_CURRENT_TEMP) & 7626c247393SAbhilash Kesavan EXYNOS7_TMU_TEMP_MASK; 7636c247393SAbhilash Kesavan } 7646c247393SAbhilash Kesavan 76520009a81SMateusz Majewski static irqreturn_t exynos_tmu_threaded_irq(int irq, void *id) 76659dfa54cSAmit Daniel Kachhap { 76720009a81SMateusz Majewski struct exynos_tmu_data *data = id; 768a0395eeeSAmit Daniel Kachhap 769b43e3cfeSBartlomiej Zolnierkiewicz thermal_zone_device_update(data->tzd, THERMAL_EVENT_UNSPECIFIED); 770b43e3cfeSBartlomiej Zolnierkiewicz 77159dfa54cSAmit Daniel Kachhap mutex_lock(&data->lock); 77259dfa54cSAmit Daniel Kachhap clk_enable(data->clk); 773b8d582b9SAmit Daniel Kachhap 774a4463c4fSAmit Daniel Kachhap /* TODO: take action based on particular interrupt */ 775a7331f72SBartlomiej Zolnierkiewicz data->tmu_clear_irqs(data); 776b8d582b9SAmit Daniel Kachhap 77759dfa54cSAmit Daniel Kachhap clk_disable(data->clk); 77859dfa54cSAmit Daniel Kachhap mutex_unlock(&data->lock); 77920009a81SMateusz Majewski 78020009a81SMateusz Majewski return IRQ_HANDLED; 78159dfa54cSAmit Daniel Kachhap } 78259dfa54cSAmit Daniel Kachhap 783a7331f72SBartlomiej Zolnierkiewicz static void exynos4210_tmu_clear_irqs(struct exynos_tmu_data *data) 784a7331f72SBartlomiej Zolnierkiewicz { 785a7331f72SBartlomiej Zolnierkiewicz unsigned int val_irq; 786a7331f72SBartlomiej Zolnierkiewicz u32 tmu_intstat, tmu_intclear; 787a7331f72SBartlomiej Zolnierkiewicz 788a7331f72SBartlomiej Zolnierkiewicz if (data->soc == SOC_ARCH_EXYNOS5260) { 789a7331f72SBartlomiej Zolnierkiewicz tmu_intstat = EXYNOS5260_TMU_REG_INTSTAT; 790a7331f72SBartlomiej Zolnierkiewicz tmu_intclear = EXYNOS5260_TMU_REG_INTCLEAR; 7916c247393SAbhilash Kesavan } else if (data->soc == SOC_ARCH_EXYNOS7) { 7926c247393SAbhilash Kesavan tmu_intstat = EXYNOS7_TMU_REG_INTPEND; 7936c247393SAbhilash Kesavan tmu_intclear = EXYNOS7_TMU_REG_INTPEND; 794488c7455SChanwoo Choi } else if (data->soc == SOC_ARCH_EXYNOS5433) { 795488c7455SChanwoo Choi tmu_intstat = EXYNOS5433_TMU_REG_INTPEND; 796488c7455SChanwoo Choi tmu_intclear = EXYNOS5433_TMU_REG_INTPEND; 797a7331f72SBartlomiej Zolnierkiewicz } else { 798a7331f72SBartlomiej Zolnierkiewicz tmu_intstat = EXYNOS_TMU_REG_INTSTAT; 799a7331f72SBartlomiej Zolnierkiewicz tmu_intclear = EXYNOS_TMU_REG_INTCLEAR; 800a7331f72SBartlomiej Zolnierkiewicz } 801a7331f72SBartlomiej Zolnierkiewicz 802a7331f72SBartlomiej Zolnierkiewicz val_irq = readl(data->base + tmu_intstat); 803a7331f72SBartlomiej Zolnierkiewicz /* 804a7331f72SBartlomiej Zolnierkiewicz * Clear the interrupts. Please note that the documentation for 805a7331f72SBartlomiej Zolnierkiewicz * Exynos3250, Exynos4412, Exynos5250 and Exynos5260 incorrectly 806a7331f72SBartlomiej Zolnierkiewicz * states that INTCLEAR register has a different placing of bits 807a7331f72SBartlomiej Zolnierkiewicz * responsible for FALL IRQs than INTSTAT register. Exynos5420 808a7331f72SBartlomiej Zolnierkiewicz * and Exynos5440 documentation is correct (Exynos4210 doesn't 809a7331f72SBartlomiej Zolnierkiewicz * support FALL IRQs at all). 810a7331f72SBartlomiej Zolnierkiewicz */ 811a7331f72SBartlomiej Zolnierkiewicz writel(val_irq, data->base + tmu_intclear); 812a7331f72SBartlomiej Zolnierkiewicz } 813a7331f72SBartlomiej Zolnierkiewicz 81459dfa54cSAmit Daniel Kachhap static const struct of_device_id exynos_tmu_match[] = { 815fee88e2bSMaciej Purski { 816fee88e2bSMaciej Purski .compatible = "samsung,exynos3250-tmu", 817fee88e2bSMaciej Purski .data = (const void *)SOC_ARCH_EXYNOS3250, 818fee88e2bSMaciej Purski }, { 819fee88e2bSMaciej Purski .compatible = "samsung,exynos4210-tmu", 820fee88e2bSMaciej Purski .data = (const void *)SOC_ARCH_EXYNOS4210, 821fee88e2bSMaciej Purski }, { 822fee88e2bSMaciej Purski .compatible = "samsung,exynos4412-tmu", 823fee88e2bSMaciej Purski .data = (const void *)SOC_ARCH_EXYNOS4412, 824fee88e2bSMaciej Purski }, { 825fee88e2bSMaciej Purski .compatible = "samsung,exynos5250-tmu", 826fee88e2bSMaciej Purski .data = (const void *)SOC_ARCH_EXYNOS5250, 827fee88e2bSMaciej Purski }, { 828fee88e2bSMaciej Purski .compatible = "samsung,exynos5260-tmu", 829fee88e2bSMaciej Purski .data = (const void *)SOC_ARCH_EXYNOS5260, 830fee88e2bSMaciej Purski }, { 831fee88e2bSMaciej Purski .compatible = "samsung,exynos5420-tmu", 832fee88e2bSMaciej Purski .data = (const void *)SOC_ARCH_EXYNOS5420, 833fee88e2bSMaciej Purski }, { 834fee88e2bSMaciej Purski .compatible = "samsung,exynos5420-tmu-ext-triminfo", 835fee88e2bSMaciej Purski .data = (const void *)SOC_ARCH_EXYNOS5420_TRIMINFO, 836fee88e2bSMaciej Purski }, { 837fee88e2bSMaciej Purski .compatible = "samsung,exynos5433-tmu", 838fee88e2bSMaciej Purski .data = (const void *)SOC_ARCH_EXYNOS5433, 839fee88e2bSMaciej Purski }, { 840fee88e2bSMaciej Purski .compatible = "samsung,exynos7-tmu", 841fee88e2bSMaciej Purski .data = (const void *)SOC_ARCH_EXYNOS7, 842fee88e2bSMaciej Purski }, 843fee88e2bSMaciej Purski { }, 84459dfa54cSAmit Daniel Kachhap }; 84559dfa54cSAmit Daniel Kachhap MODULE_DEVICE_TABLE(of, exynos_tmu_match); 84659dfa54cSAmit Daniel Kachhap 847cebe7373SAmit Daniel Kachhap static int exynos_map_dt_data(struct platform_device *pdev) 84859dfa54cSAmit Daniel Kachhap { 849cebe7373SAmit Daniel Kachhap struct exynos_tmu_data *data = platform_get_drvdata(pdev); 850cebe7373SAmit Daniel Kachhap struct resource res; 85159dfa54cSAmit Daniel Kachhap 85273b5b1d7SSachin Kamat if (!data || !pdev->dev.of_node) 853cebe7373SAmit Daniel Kachhap return -ENODEV; 85459dfa54cSAmit Daniel Kachhap 855cebe7373SAmit Daniel Kachhap data->irq = irq_of_parse_and_map(pdev->dev.of_node, 0); 856cebe7373SAmit Daniel Kachhap if (data->irq <= 0) { 857cebe7373SAmit Daniel Kachhap dev_err(&pdev->dev, "failed to get IRQ\n"); 858cebe7373SAmit Daniel Kachhap return -ENODEV; 859cebe7373SAmit Daniel Kachhap } 860cebe7373SAmit Daniel Kachhap 861cebe7373SAmit Daniel Kachhap if (of_address_to_resource(pdev->dev.of_node, 0, &res)) { 862cebe7373SAmit Daniel Kachhap dev_err(&pdev->dev, "failed to get Resource 0\n"); 863cebe7373SAmit Daniel Kachhap return -ENODEV; 864cebe7373SAmit Daniel Kachhap } 865cebe7373SAmit Daniel Kachhap 866cebe7373SAmit Daniel Kachhap data->base = devm_ioremap(&pdev->dev, res.start, resource_size(&res)); 867cebe7373SAmit Daniel Kachhap if (!data->base) { 868cebe7373SAmit Daniel Kachhap dev_err(&pdev->dev, "Failed to ioremap memory\n"); 869cebe7373SAmit Daniel Kachhap return -EADDRNOTAVAIL; 870cebe7373SAmit Daniel Kachhap } 871cebe7373SAmit Daniel Kachhap 8721892f9f0SKrzysztof Kozlowski data->soc = (uintptr_t)of_device_get_match_data(&pdev->dev); 87356adb9efSBartlomiej Zolnierkiewicz 87456adb9efSBartlomiej Zolnierkiewicz switch (data->soc) { 87556adb9efSBartlomiej Zolnierkiewicz case SOC_ARCH_EXYNOS4210: 876c8f8f768SBartlomiej Zolnierkiewicz data->tmu_set_trip_temp = exynos4210_tmu_set_trip_temp; 877c8f8f768SBartlomiej Zolnierkiewicz data->tmu_set_trip_hyst = exynos4210_tmu_set_trip_hyst; 87856adb9efSBartlomiej Zolnierkiewicz data->tmu_initialize = exynos4210_tmu_initialize; 87956adb9efSBartlomiej Zolnierkiewicz data->tmu_control = exynos4210_tmu_control; 88056adb9efSBartlomiej Zolnierkiewicz data->tmu_read = exynos4210_tmu_read; 88156adb9efSBartlomiej Zolnierkiewicz data->tmu_clear_irqs = exynos4210_tmu_clear_irqs; 8823a3a5f15SKrzysztof Kozlowski data->ntrip = 4; 883fccfe099SBartlomiej Zolnierkiewicz data->gain = 15; 88461020d18SBartlomiej Zolnierkiewicz data->reference_voltage = 7; 885e3ed3649SBartlomiej Zolnierkiewicz data->efuse_value = 55; 886e3ed3649SBartlomiej Zolnierkiewicz data->min_efuse_value = 40; 887e3ed3649SBartlomiej Zolnierkiewicz data->max_efuse_value = 100; 88856adb9efSBartlomiej Zolnierkiewicz break; 88956adb9efSBartlomiej Zolnierkiewicz case SOC_ARCH_EXYNOS3250: 89056adb9efSBartlomiej Zolnierkiewicz case SOC_ARCH_EXYNOS4412: 89156adb9efSBartlomiej Zolnierkiewicz case SOC_ARCH_EXYNOS5250: 89256adb9efSBartlomiej Zolnierkiewicz case SOC_ARCH_EXYNOS5260: 89356adb9efSBartlomiej Zolnierkiewicz case SOC_ARCH_EXYNOS5420: 89456adb9efSBartlomiej Zolnierkiewicz case SOC_ARCH_EXYNOS5420_TRIMINFO: 895c8f8f768SBartlomiej Zolnierkiewicz data->tmu_set_trip_temp = exynos4412_tmu_set_trip_temp; 896c8f8f768SBartlomiej Zolnierkiewicz data->tmu_set_trip_hyst = exynos4412_tmu_set_trip_hyst; 89756adb9efSBartlomiej Zolnierkiewicz data->tmu_initialize = exynos4412_tmu_initialize; 89856adb9efSBartlomiej Zolnierkiewicz data->tmu_control = exynos4210_tmu_control; 89956adb9efSBartlomiej Zolnierkiewicz data->tmu_read = exynos4412_tmu_read; 90056adb9efSBartlomiej Zolnierkiewicz data->tmu_set_emulation = exynos4412_tmu_set_emulation; 90156adb9efSBartlomiej Zolnierkiewicz data->tmu_clear_irqs = exynos4210_tmu_clear_irqs; 9023a3a5f15SKrzysztof Kozlowski data->ntrip = 4; 903fccfe099SBartlomiej Zolnierkiewicz data->gain = 8; 90461020d18SBartlomiej Zolnierkiewicz data->reference_voltage = 16; 905e3ed3649SBartlomiej Zolnierkiewicz data->efuse_value = 55; 906e3ed3649SBartlomiej Zolnierkiewicz if (data->soc != SOC_ARCH_EXYNOS5420 && 907e3ed3649SBartlomiej Zolnierkiewicz data->soc != SOC_ARCH_EXYNOS5420_TRIMINFO) 908e3ed3649SBartlomiej Zolnierkiewicz data->min_efuse_value = 40; 909e3ed3649SBartlomiej Zolnierkiewicz else 910e3ed3649SBartlomiej Zolnierkiewicz data->min_efuse_value = 0; 911e3ed3649SBartlomiej Zolnierkiewicz data->max_efuse_value = 100; 91256adb9efSBartlomiej Zolnierkiewicz break; 913488c7455SChanwoo Choi case SOC_ARCH_EXYNOS5433: 914c8f8f768SBartlomiej Zolnierkiewicz data->tmu_set_trip_temp = exynos5433_tmu_set_trip_temp; 915c8f8f768SBartlomiej Zolnierkiewicz data->tmu_set_trip_hyst = exynos5433_tmu_set_trip_hyst; 916488c7455SChanwoo Choi data->tmu_initialize = exynos5433_tmu_initialize; 917488c7455SChanwoo Choi data->tmu_control = exynos5433_tmu_control; 918488c7455SChanwoo Choi data->tmu_read = exynos4412_tmu_read; 919488c7455SChanwoo Choi data->tmu_set_emulation = exynos4412_tmu_set_emulation; 920488c7455SChanwoo Choi data->tmu_clear_irqs = exynos4210_tmu_clear_irqs; 9213a3a5f15SKrzysztof Kozlowski data->ntrip = 8; 922fccfe099SBartlomiej Zolnierkiewicz data->gain = 8; 92361020d18SBartlomiej Zolnierkiewicz if (res.start == EXYNOS5433_G3D_BASE) 92461020d18SBartlomiej Zolnierkiewicz data->reference_voltage = 23; 92561020d18SBartlomiej Zolnierkiewicz else 92661020d18SBartlomiej Zolnierkiewicz data->reference_voltage = 16; 927e3ed3649SBartlomiej Zolnierkiewicz data->efuse_value = 75; 928e3ed3649SBartlomiej Zolnierkiewicz data->min_efuse_value = 40; 929e3ed3649SBartlomiej Zolnierkiewicz data->max_efuse_value = 150; 93056adb9efSBartlomiej Zolnierkiewicz break; 9316c247393SAbhilash Kesavan case SOC_ARCH_EXYNOS7: 932c8f8f768SBartlomiej Zolnierkiewicz data->tmu_set_trip_temp = exynos7_tmu_set_trip_temp; 933c8f8f768SBartlomiej Zolnierkiewicz data->tmu_set_trip_hyst = exynos7_tmu_set_trip_hyst; 9346c247393SAbhilash Kesavan data->tmu_initialize = exynos7_tmu_initialize; 9356c247393SAbhilash Kesavan data->tmu_control = exynos7_tmu_control; 9366c247393SAbhilash Kesavan data->tmu_read = exynos7_tmu_read; 9376c247393SAbhilash Kesavan data->tmu_set_emulation = exynos4412_tmu_set_emulation; 9386c247393SAbhilash Kesavan data->tmu_clear_irqs = exynos4210_tmu_clear_irqs; 9393a3a5f15SKrzysztof Kozlowski data->ntrip = 8; 940fccfe099SBartlomiej Zolnierkiewicz data->gain = 9; 94161020d18SBartlomiej Zolnierkiewicz data->reference_voltage = 17; 942e3ed3649SBartlomiej Zolnierkiewicz data->efuse_value = 75; 943e3ed3649SBartlomiej Zolnierkiewicz data->min_efuse_value = 15; 944e3ed3649SBartlomiej Zolnierkiewicz data->max_efuse_value = 100; 9456c247393SAbhilash Kesavan break; 94656adb9efSBartlomiej Zolnierkiewicz default: 94756adb9efSBartlomiej Zolnierkiewicz dev_err(&pdev->dev, "Platform not supported\n"); 94856adb9efSBartlomiej Zolnierkiewicz return -EINVAL; 94956adb9efSBartlomiej Zolnierkiewicz } 95056adb9efSBartlomiej Zolnierkiewicz 951199b3e3cSBartlomiej Zolnierkiewicz data->cal_type = TYPE_ONE_POINT_TRIMMING; 952199b3e3cSBartlomiej Zolnierkiewicz 953d9b6ee14SAmit Daniel Kachhap /* 954d9b6ee14SAmit Daniel Kachhap * Check if the TMU shares some registers and then try to map the 955d9b6ee14SAmit Daniel Kachhap * memory of common registers. 956d9b6ee14SAmit Daniel Kachhap */ 9578014220dSKrzysztof Kozlowski if (data->soc != SOC_ARCH_EXYNOS5420_TRIMINFO) 958d9b6ee14SAmit Daniel Kachhap return 0; 959d9b6ee14SAmit Daniel Kachhap 960d9b6ee14SAmit Daniel Kachhap if (of_address_to_resource(pdev->dev.of_node, 1, &res)) { 961d9b6ee14SAmit Daniel Kachhap dev_err(&pdev->dev, "failed to get Resource 1\n"); 962d9b6ee14SAmit Daniel Kachhap return -ENODEV; 963d9b6ee14SAmit Daniel Kachhap } 964d9b6ee14SAmit Daniel Kachhap 9659025d563SNaveen Krishna Chatradhi data->base_second = devm_ioremap(&pdev->dev, res.start, 966d9b6ee14SAmit Daniel Kachhap resource_size(&res)); 9679025d563SNaveen Krishna Chatradhi if (!data->base_second) { 968d9b6ee14SAmit Daniel Kachhap dev_err(&pdev->dev, "Failed to ioremap memory\n"); 969d9b6ee14SAmit Daniel Kachhap return -ENOMEM; 970d9b6ee14SAmit Daniel Kachhap } 971cebe7373SAmit Daniel Kachhap 972cebe7373SAmit Daniel Kachhap return 0; 973cebe7373SAmit Daniel Kachhap } 974cebe7373SAmit Daniel Kachhap 9757ea98f70SDaniel Lezcano static const struct thermal_zone_device_ops exynos_sensor_ops = { 9763b6a1a80SLukasz Majewski .get_temp = exynos_get_temp, 9773b6a1a80SLukasz Majewski .set_emul_temp = exynos_tmu_set_emulation, 9783b6a1a80SLukasz Majewski }; 9793b6a1a80SLukasz Majewski 980cebe7373SAmit Daniel Kachhap static int exynos_tmu_probe(struct platform_device *pdev) 981cebe7373SAmit Daniel Kachhap { 9823b6a1a80SLukasz Majewski struct exynos_tmu_data *data; 9833b6a1a80SLukasz Majewski int ret; 984cebe7373SAmit Daniel Kachhap 98559dfa54cSAmit Daniel Kachhap data = devm_kzalloc(&pdev->dev, sizeof(struct exynos_tmu_data), 98659dfa54cSAmit Daniel Kachhap GFP_KERNEL); 9872a9675b3SJingoo Han if (!data) 98859dfa54cSAmit Daniel Kachhap return -ENOMEM; 98959dfa54cSAmit Daniel Kachhap 990cebe7373SAmit Daniel Kachhap platform_set_drvdata(pdev, data); 991cebe7373SAmit Daniel Kachhap mutex_init(&data->lock); 992cebe7373SAmit Daniel Kachhap 993824ead03SKrzysztof Kozlowski /* 994824ead03SKrzysztof Kozlowski * Try enabling the regulator if found 995824ead03SKrzysztof Kozlowski * TODO: Add regulator as an SOC feature, so that regulator enable 996824ead03SKrzysztof Kozlowski * is a compulsory call. 997824ead03SKrzysztof Kozlowski */ 9985d6976d0SMateusz Majewski ret = devm_regulator_get_enable_optional(&pdev->dev, "vtmu"); 99952ef6f56SMateusz Majewski switch (ret) { 10005d6976d0SMateusz Majewski case 0: 100152ef6f56SMateusz Majewski case -ENODEV: 100252ef6f56SMateusz Majewski break; 100352ef6f56SMateusz Majewski case -EPROBE_DEFER: 1004ccb361d2SJavier Martinez Canillas return -EPROBE_DEFER; 100552ef6f56SMateusz Majewski default: 10065d6976d0SMateusz Majewski dev_err(&pdev->dev, "Failed to get enabled regulator: %d\n", 100752ef6f56SMateusz Majewski ret); 100852ef6f56SMateusz Majewski return ret; 100952ef6f56SMateusz Majewski } 1010824ead03SKrzysztof Kozlowski 1011cebe7373SAmit Daniel Kachhap ret = exynos_map_dt_data(pdev); 1012cebe7373SAmit Daniel Kachhap if (ret) 10135d6976d0SMateusz Majewski return ret; 1014cebe7373SAmit Daniel Kachhap 101559dfa54cSAmit Daniel Kachhap data->clk = devm_clk_get(&pdev->dev, "tmu_apbif"); 101659dfa54cSAmit Daniel Kachhap if (IS_ERR(data->clk)) { 101759dfa54cSAmit Daniel Kachhap dev_err(&pdev->dev, "Failed to get clock\n"); 10185d6976d0SMateusz Majewski return PTR_ERR(data->clk); 101959dfa54cSAmit Daniel Kachhap } 102059dfa54cSAmit Daniel Kachhap 102114a11dc7SNaveen Krishna Chatradhi data->clk_sec = devm_clk_get(&pdev->dev, "tmu_triminfo_apbif"); 102214a11dc7SNaveen Krishna Chatradhi if (IS_ERR(data->clk_sec)) { 102314a11dc7SNaveen Krishna Chatradhi if (data->soc == SOC_ARCH_EXYNOS5420_TRIMINFO) { 102414a11dc7SNaveen Krishna Chatradhi dev_err(&pdev->dev, "Failed to get triminfo clock\n"); 10255d6976d0SMateusz Majewski return PTR_ERR(data->clk_sec); 102614a11dc7SNaveen Krishna Chatradhi } 102714a11dc7SNaveen Krishna Chatradhi } else { 102814a11dc7SNaveen Krishna Chatradhi ret = clk_prepare(data->clk_sec); 102914a11dc7SNaveen Krishna Chatradhi if (ret) { 103014a11dc7SNaveen Krishna Chatradhi dev_err(&pdev->dev, "Failed to get clock\n"); 10315d6976d0SMateusz Majewski return ret; 103214a11dc7SNaveen Krishna Chatradhi } 103314a11dc7SNaveen Krishna Chatradhi } 103414a11dc7SNaveen Krishna Chatradhi 103514a11dc7SNaveen Krishna Chatradhi ret = clk_prepare(data->clk); 103614a11dc7SNaveen Krishna Chatradhi if (ret) { 103714a11dc7SNaveen Krishna Chatradhi dev_err(&pdev->dev, "Failed to get clock\n"); 103814a11dc7SNaveen Krishna Chatradhi goto err_clk_sec; 103914a11dc7SNaveen Krishna Chatradhi } 104059dfa54cSAmit Daniel Kachhap 1041488c7455SChanwoo Choi switch (data->soc) { 1042488c7455SChanwoo Choi case SOC_ARCH_EXYNOS5433: 1043488c7455SChanwoo Choi case SOC_ARCH_EXYNOS7: 10446c247393SAbhilash Kesavan data->sclk = devm_clk_get(&pdev->dev, "tmu_sclk"); 10456c247393SAbhilash Kesavan if (IS_ERR(data->sclk)) { 10466c247393SAbhilash Kesavan dev_err(&pdev->dev, "Failed to get sclk\n"); 104702d438f6SDan Carpenter ret = PTR_ERR(data->sclk); 10486c247393SAbhilash Kesavan goto err_clk; 10496c247393SAbhilash Kesavan } else { 10506c247393SAbhilash Kesavan ret = clk_prepare_enable(data->sclk); 10516c247393SAbhilash Kesavan if (ret) { 10526c247393SAbhilash Kesavan dev_err(&pdev->dev, "Failed to enable sclk\n"); 10536c247393SAbhilash Kesavan goto err_clk; 10546c247393SAbhilash Kesavan } 10556c247393SAbhilash Kesavan } 1056488c7455SChanwoo Choi break; 1057488c7455SChanwoo Choi default: 1058488c7455SChanwoo Choi break; 1059baba1ebbSKrzysztof Kozlowski } 10606c247393SAbhilash Kesavan 1061b72ba67bSMateusz Majewski ret = exynos_tmu_initialize(pdev); 1062b72ba67bSMateusz Majewski if (ret) { 1063b72ba67bSMateusz Majewski dev_err(&pdev->dev, "Failed to initialize TMU\n"); 1064b72ba67bSMateusz Majewski goto err_sclk; 1065b72ba67bSMateusz Majewski } 1066b72ba67bSMateusz Majewski 10677ea98f70SDaniel Lezcano data->tzd = devm_thermal_of_zone_register(&pdev->dev, 0, data, 10689e4249b4SKrzysztof Kozlowski &exynos_sensor_ops); 10699e4249b4SKrzysztof Kozlowski if (IS_ERR(data->tzd)) { 10709e4249b4SKrzysztof Kozlowski ret = PTR_ERR(data->tzd); 107182bdde8eSMarek Szyprowski if (ret != -EPROBE_DEFER) 107282bdde8eSMarek Szyprowski dev_err(&pdev->dev, "Failed to register sensor: %d\n", 107382bdde8eSMarek Szyprowski ret); 10749e4249b4SKrzysztof Kozlowski goto err_sclk; 10759e4249b4SKrzysztof Kozlowski } 107659dfa54cSAmit Daniel Kachhap 1077b72ba67bSMateusz Majewski ret = exynos_thermal_zone_configure(pdev); 107859dfa54cSAmit Daniel Kachhap if (ret) { 1079b72ba67bSMateusz Majewski dev_err(&pdev->dev, "Failed to configure the thermal zone\n"); 10807ea98f70SDaniel Lezcano goto err_sclk; 108159dfa54cSAmit Daniel Kachhap } 108259dfa54cSAmit Daniel Kachhap 108320009a81SMateusz Majewski ret = devm_request_threaded_irq(&pdev->dev, data->irq, NULL, 108420009a81SMateusz Majewski exynos_tmu_threaded_irq, 108520009a81SMateusz Majewski IRQF_TRIGGER_RISING 108620009a81SMateusz Majewski | IRQF_SHARED | IRQF_ONESHOT, 108720009a81SMateusz Majewski dev_name(&pdev->dev), data); 1088cebe7373SAmit Daniel Kachhap if (ret) { 1089cebe7373SAmit Daniel Kachhap dev_err(&pdev->dev, "Failed to request irq: %d\n", data->irq); 10907ea98f70SDaniel Lezcano goto err_sclk; 1091cebe7373SAmit Daniel Kachhap } 109259dfa54cSAmit Daniel Kachhap 10933b6a1a80SLukasz Majewski exynos_tmu_control(pdev, true); 109459dfa54cSAmit Daniel Kachhap return 0; 10959e4249b4SKrzysztof Kozlowski 10966c247393SAbhilash Kesavan err_sclk: 10976c247393SAbhilash Kesavan clk_disable_unprepare(data->sclk); 109859dfa54cSAmit Daniel Kachhap err_clk: 109959dfa54cSAmit Daniel Kachhap clk_unprepare(data->clk); 110014a11dc7SNaveen Krishna Chatradhi err_clk_sec: 110114a11dc7SNaveen Krishna Chatradhi if (!IS_ERR(data->clk_sec)) 110214a11dc7SNaveen Krishna Chatradhi clk_unprepare(data->clk_sec); 110359dfa54cSAmit Daniel Kachhap return ret; 110459dfa54cSAmit Daniel Kachhap } 110559dfa54cSAmit Daniel Kachhap 11060b478d7bSUwe Kleine-König static void exynos_tmu_remove(struct platform_device *pdev) 110759dfa54cSAmit Daniel Kachhap { 110859dfa54cSAmit Daniel Kachhap struct exynos_tmu_data *data = platform_get_drvdata(pdev); 110959dfa54cSAmit Daniel Kachhap 11104215688eSBartlomiej Zolnierkiewicz exynos_tmu_control(pdev, false); 11114215688eSBartlomiej Zolnierkiewicz 11126c247393SAbhilash Kesavan clk_disable_unprepare(data->sclk); 111359dfa54cSAmit Daniel Kachhap clk_unprepare(data->clk); 111414a11dc7SNaveen Krishna Chatradhi if (!IS_ERR(data->clk_sec)) 111514a11dc7SNaveen Krishna Chatradhi clk_unprepare(data->clk_sec); 111659dfa54cSAmit Daniel Kachhap } 111759dfa54cSAmit Daniel Kachhap 111859dfa54cSAmit Daniel Kachhap #ifdef CONFIG_PM_SLEEP 111959dfa54cSAmit Daniel Kachhap static int exynos_tmu_suspend(struct device *dev) 112059dfa54cSAmit Daniel Kachhap { 112159dfa54cSAmit Daniel Kachhap exynos_tmu_control(to_platform_device(dev), false); 112259dfa54cSAmit Daniel Kachhap 112359dfa54cSAmit Daniel Kachhap return 0; 112459dfa54cSAmit Daniel Kachhap } 112559dfa54cSAmit Daniel Kachhap 112659dfa54cSAmit Daniel Kachhap static int exynos_tmu_resume(struct device *dev) 112759dfa54cSAmit Daniel Kachhap { 112859dfa54cSAmit Daniel Kachhap struct platform_device *pdev = to_platform_device(dev); 112959dfa54cSAmit Daniel Kachhap 113059dfa54cSAmit Daniel Kachhap exynos_tmu_initialize(pdev); 113159dfa54cSAmit Daniel Kachhap exynos_tmu_control(pdev, true); 113259dfa54cSAmit Daniel Kachhap 113359dfa54cSAmit Daniel Kachhap return 0; 113459dfa54cSAmit Daniel Kachhap } 113559dfa54cSAmit Daniel Kachhap 113659dfa54cSAmit Daniel Kachhap static SIMPLE_DEV_PM_OPS(exynos_tmu_pm, 113759dfa54cSAmit Daniel Kachhap exynos_tmu_suspend, exynos_tmu_resume); 113859dfa54cSAmit Daniel Kachhap #define EXYNOS_TMU_PM (&exynos_tmu_pm) 113959dfa54cSAmit Daniel Kachhap #else 114059dfa54cSAmit Daniel Kachhap #define EXYNOS_TMU_PM NULL 114159dfa54cSAmit Daniel Kachhap #endif 114259dfa54cSAmit Daniel Kachhap 114359dfa54cSAmit Daniel Kachhap static struct platform_driver exynos_tmu_driver = { 114459dfa54cSAmit Daniel Kachhap .driver = { 114559dfa54cSAmit Daniel Kachhap .name = "exynos-tmu", 114659dfa54cSAmit Daniel Kachhap .pm = EXYNOS_TMU_PM, 114773b5b1d7SSachin Kamat .of_match_table = exynos_tmu_match, 114859dfa54cSAmit Daniel Kachhap }, 114959dfa54cSAmit Daniel Kachhap .probe = exynos_tmu_probe, 11500b478d7bSUwe Kleine-König .remove_new = exynos_tmu_remove, 115159dfa54cSAmit Daniel Kachhap }; 115259dfa54cSAmit Daniel Kachhap 115359dfa54cSAmit Daniel Kachhap module_platform_driver(exynos_tmu_driver); 115459dfa54cSAmit Daniel Kachhap 1155ca07ee4eSKrzysztof Kozlowski MODULE_DESCRIPTION("Exynos TMU Driver"); 115659dfa54cSAmit Daniel Kachhap MODULE_AUTHOR("Donggeun Kim <dg77.kim@samsung.com>"); 115759dfa54cSAmit Daniel Kachhap MODULE_LICENSE("GPL"); 115859dfa54cSAmit Daniel Kachhap MODULE_ALIAS("platform:exynos-tmu"); 1159