exynos_tmu.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. /*
  2. * exynos_tmu.h - Samsung EXYNOS TMU (Thermal Management Unit)
  3. *
  4. * Copyright (C) 2011 Samsung Electronics
  5. * Donggeun Kim <dg77.kim@samsung.com>
  6. * Amit Daniel Kachhap <amit.daniel@samsung.com>
  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. #ifndef _EXYNOS_TMU_H
  23. #define _EXYNOS_TMU_H
  24. #include <linux/cpu_cooling.h>
  25. #include "exynos_thermal_common.h"
  26. enum calibration_type {
  27. TYPE_ONE_POINT_TRIMMING,
  28. TYPE_ONE_POINT_TRIMMING_25,
  29. TYPE_ONE_POINT_TRIMMING_85,
  30. TYPE_TWO_POINT_TRIMMING,
  31. TYPE_NONE,
  32. };
  33. enum calibration_mode {
  34. SW_MODE,
  35. HW_MODE,
  36. };
  37. enum soc_type {
  38. SOC_ARCH_EXYNOS4210 = 1,
  39. SOC_ARCH_EXYNOS4412,
  40. SOC_ARCH_EXYNOS5250,
  41. SOC_ARCH_EXYNOS5440,
  42. };
  43. /**
  44. * EXYNOS TMU supported features.
  45. * TMU_SUPPORT_EMULATION - This features is used to set user defined
  46. * temperature to the TMU controller.
  47. * TMU_SUPPORT_MULTI_INST - This features denotes that the soc
  48. * has many instances of TMU.
  49. * TMU_SUPPORT_TRIM_RELOAD - This features shows that trimming can
  50. * be reloaded.
  51. * TMU_SUPPORT_FALLING_TRIP - This features shows that interrupt can
  52. * be registered for falling trips also.
  53. * TMU_SUPPORT_READY_STATUS - This feature tells that the TMU current
  54. * state(active/idle) can be checked.
  55. * TMU_SUPPORT_EMUL_TIME - This features allows to set next temp emulation
  56. * sample time.
  57. * TMU_SUPPORT_SHARED_MEMORY - This feature tells that the different TMU
  58. * sensors shares some common registers.
  59. * TMU_SUPPORT - macro to compare the above features with the supplied.
  60. */
  61. #define TMU_SUPPORT_EMULATION BIT(0)
  62. #define TMU_SUPPORT_MULTI_INST BIT(1)
  63. #define TMU_SUPPORT_TRIM_RELOAD BIT(2)
  64. #define TMU_SUPPORT_FALLING_TRIP BIT(3)
  65. #define TMU_SUPPORT_READY_STATUS BIT(4)
  66. #define TMU_SUPPORT_EMUL_TIME BIT(5)
  67. #define TMU_SUPPORT_SHARED_MEMORY BIT(6)
  68. #define TMU_SUPPORTS(a, b) (a->features & TMU_SUPPORT_ ## b)
  69. /**
  70. * struct exynos_tmu_register - register descriptors to access registers and
  71. * bitfields. The register validity, offsets and bitfield values may vary
  72. * slightly across different exynos SOC's.
  73. * @triminfo_data: register containing 2 pont trimming data
  74. * @triminfo_25_shift: shift bit of the 25 C trim value in triminfo_data reg.
  75. * @triminfo_85_shift: shift bit of the 85 C trim value in triminfo_data reg.
  76. * @triminfo_ctrl: trim info controller register.
  77. * @triminfo_reload_shift: shift of triminfo reload enable bit in triminfo_ctrl
  78. reg.
  79. * @tmu_ctrl: TMU main controller register.
  80. * @test_mux_addr_shift: shift bits of test mux address.
  81. * @buf_vref_sel_shift: shift bits of reference voltage in tmu_ctrl register.
  82. * @buf_vref_sel_mask: mask bits of reference voltage in tmu_ctrl register.
  83. * @therm_trip_mode_shift: shift bits of tripping mode in tmu_ctrl register.
  84. * @therm_trip_mode_mask: mask bits of tripping mode in tmu_ctrl register.
  85. * @therm_trip_en_shift: shift bits of tripping enable in tmu_ctrl register.
  86. * @buf_slope_sel_shift: shift bits of amplifier gain value in tmu_ctrl
  87. register.
  88. * @buf_slope_sel_mask: mask bits of amplifier gain value in tmu_ctrl register.
  89. * @calib_mode_shift: shift bits of calibration mode value in tmu_ctrl
  90. register.
  91. * @calib_mode_mask: mask bits of calibration mode value in tmu_ctrl
  92. register.
  93. * @therm_trip_tq_en_shift: shift bits of thermal trip enable by TQ pin in
  94. tmu_ctrl register.
  95. * @core_en_shift: shift bits of TMU core enable bit in tmu_ctrl register.
  96. * @tmu_status: register drescribing the TMU status.
  97. * @tmu_cur_temp: register containing the current temperature of the TMU.
  98. * @tmu_cur_temp_shift: shift bits of current temp value in tmu_cur_temp
  99. register.
  100. * @threshold_temp: register containing the base threshold level.
  101. * @threshold_th0: Register containing first set of rising levels.
  102. * @threshold_th0_l0_shift: shift bits of level0 threshold temperature.
  103. * @threshold_th0_l1_shift: shift bits of level1 threshold temperature.
  104. * @threshold_th0_l2_shift: shift bits of level2 threshold temperature.
  105. * @threshold_th0_l3_shift: shift bits of level3 threshold temperature.
  106. * @threshold_th1: Register containing second set of rising levels.
  107. * @threshold_th1_l0_shift: shift bits of level0 threshold temperature.
  108. * @threshold_th1_l1_shift: shift bits of level1 threshold temperature.
  109. * @threshold_th1_l2_shift: shift bits of level2 threshold temperature.
  110. * @threshold_th1_l3_shift: shift bits of level3 threshold temperature.
  111. * @threshold_th2: Register containing third set of rising levels.
  112. * @threshold_th2_l0_shift: shift bits of level0 threshold temperature.
  113. * @threshold_th3: Register containing fourth set of rising levels.
  114. * @threshold_th3_l0_shift: shift bits of level0 threshold temperature.
  115. * @tmu_inten: register containing the different threshold interrupt
  116. enable bits.
  117. * @inten_rise_shift: shift bits of all rising interrupt bits.
  118. * @inten_rise_mask: mask bits of all rising interrupt bits.
  119. * @inten_fall_shift: shift bits of all rising interrupt bits.
  120. * @inten_fall_mask: mask bits of all rising interrupt bits.
  121. * @inten_rise0_shift: shift bits of rising 0 interrupt bits.
  122. * @inten_rise1_shift: shift bits of rising 1 interrupt bits.
  123. * @inten_rise2_shift: shift bits of rising 2 interrupt bits.
  124. * @inten_rise3_shift: shift bits of rising 3 interrupt bits.
  125. * @inten_fall0_shift: shift bits of falling 0 interrupt bits.
  126. * @inten_fall1_shift: shift bits of falling 1 interrupt bits.
  127. * @inten_fall2_shift: shift bits of falling 2 interrupt bits.
  128. * @inten_fall3_shift: shift bits of falling 3 interrupt bits.
  129. * @tmu_intstat: Register containing the interrupt status values.
  130. * @tmu_intclear: Register for clearing the raised interrupt status.
  131. * @emul_con: TMU emulation controller register.
  132. * @emul_temp_shift: shift bits of emulation temperature.
  133. * @emul_time_shift: shift bits of emulation time.
  134. * @emul_time_mask: mask bits of emulation time.
  135. * @tmu_irqstatus: register to find which TMU generated interrupts.
  136. * @tmu_pmin: register to get/set the Pmin value.
  137. */
  138. struct exynos_tmu_registers {
  139. u32 triminfo_data;
  140. u32 triminfo_25_shift;
  141. u32 triminfo_85_shift;
  142. u32 triminfo_ctrl;
  143. u32 triminfo_reload_shift;
  144. u32 tmu_ctrl;
  145. u32 test_mux_addr_shift;
  146. u32 buf_vref_sel_shift;
  147. u32 buf_vref_sel_mask;
  148. u32 therm_trip_mode_shift;
  149. u32 therm_trip_mode_mask;
  150. u32 therm_trip_en_shift;
  151. u32 buf_slope_sel_shift;
  152. u32 buf_slope_sel_mask;
  153. u32 calib_mode_shift;
  154. u32 calib_mode_mask;
  155. u32 therm_trip_tq_en_shift;
  156. u32 core_en_shift;
  157. u32 tmu_status;
  158. u32 tmu_cur_temp;
  159. u32 tmu_cur_temp_shift;
  160. u32 threshold_temp;
  161. u32 threshold_th0;
  162. u32 threshold_th0_l0_shift;
  163. u32 threshold_th0_l1_shift;
  164. u32 threshold_th0_l2_shift;
  165. u32 threshold_th0_l3_shift;
  166. u32 threshold_th1;
  167. u32 threshold_th1_l0_shift;
  168. u32 threshold_th1_l1_shift;
  169. u32 threshold_th1_l2_shift;
  170. u32 threshold_th1_l3_shift;
  171. u32 threshold_th2;
  172. u32 threshold_th2_l0_shift;
  173. u32 threshold_th3;
  174. u32 threshold_th3_l0_shift;
  175. u32 tmu_inten;
  176. u32 inten_rise_shift;
  177. u32 inten_rise_mask;
  178. u32 inten_fall_shift;
  179. u32 inten_fall_mask;
  180. u32 inten_rise0_shift;
  181. u32 inten_rise1_shift;
  182. u32 inten_rise2_shift;
  183. u32 inten_rise3_shift;
  184. u32 inten_fall0_shift;
  185. u32 inten_fall1_shift;
  186. u32 inten_fall2_shift;
  187. u32 inten_fall3_shift;
  188. u32 tmu_intstat;
  189. u32 tmu_intclear;
  190. u32 emul_con;
  191. u32 emul_temp_shift;
  192. u32 emul_time_shift;
  193. u32 emul_time_mask;
  194. u32 tmu_irqstatus;
  195. u32 tmu_pmin;
  196. };
  197. /**
  198. * struct exynos_tmu_platform_data
  199. * @threshold: basic temperature for generating interrupt
  200. * 25 <= threshold <= 125 [unit: degree Celsius]
  201. * @threshold_falling: differntial value for setting threshold
  202. * of temperature falling interrupt.
  203. * @trigger_levels: array for each interrupt levels
  204. * [unit: degree Celsius]
  205. * 0: temperature for trigger_level0 interrupt
  206. * condition for trigger_level0 interrupt:
  207. * current temperature > threshold + trigger_levels[0]
  208. * 1: temperature for trigger_level1 interrupt
  209. * condition for trigger_level1 interrupt:
  210. * current temperature > threshold + trigger_levels[1]
  211. * 2: temperature for trigger_level2 interrupt
  212. * condition for trigger_level2 interrupt:
  213. * current temperature > threshold + trigger_levels[2]
  214. * 3: temperature for trigger_level3 interrupt
  215. * condition for trigger_level3 interrupt:
  216. * current temperature > threshold + trigger_levels[3]
  217. * @trigger_type: defines the type of trigger. Possible values are,
  218. * THROTTLE_ACTIVE trigger type
  219. * THROTTLE_PASSIVE trigger type
  220. * SW_TRIP trigger type
  221. * HW_TRIP
  222. * @trigger_enable[]: array to denote which trigger levels are enabled.
  223. * 1 = enable trigger_level[] interrupt,
  224. * 0 = disable trigger_level[] interrupt
  225. * @max_trigger_level: max trigger level supported by the TMU
  226. * @gain: gain of amplifier in the positive-TC generator block
  227. * 0 <= gain <= 15
  228. * @reference_voltage: reference voltage of amplifier
  229. * in the positive-TC generator block
  230. * 0 <= reference_voltage <= 31
  231. * @noise_cancel_mode: noise cancellation mode
  232. * 000, 100, 101, 110 and 111 can be different modes
  233. * @type: determines the type of SOC
  234. * @efuse_value: platform defined fuse value
  235. * @min_efuse_value: minimum valid trimming data
  236. * @max_efuse_value: maximum valid trimming data
  237. * @first_point_trim: temp value of the first point trimming
  238. * @second_point_trim: temp value of the second point trimming
  239. * @default_temp_offset: default temperature offset in case of no trimming
  240. * @test_mux; information if SoC supports test MUX
  241. * @cal_type: calibration type for temperature
  242. * @cal_mode: calibration mode for temperature
  243. * @freq_clip_table: Table representing frequency reduction percentage.
  244. * @freq_tab_count: Count of the above table as frequency reduction may
  245. * applicable to only some of the trigger levels.
  246. * @registers: Pointer to structure containing all the TMU controller registers
  247. * and bitfields shifts and masks.
  248. * @features: a bitfield value indicating the features supported in SOC like
  249. * emulation, multi instance etc
  250. *
  251. * This structure is required for configuration of exynos_tmu driver.
  252. */
  253. struct exynos_tmu_platform_data {
  254. u8 threshold;
  255. u8 threshold_falling;
  256. u8 trigger_levels[MAX_TRIP_COUNT];
  257. enum trigger_type trigger_type[MAX_TRIP_COUNT];
  258. bool trigger_enable[MAX_TRIP_COUNT];
  259. u8 max_trigger_level;
  260. u8 gain;
  261. u8 reference_voltage;
  262. u8 noise_cancel_mode;
  263. u32 efuse_value;
  264. u32 min_efuse_value;
  265. u32 max_efuse_value;
  266. u8 first_point_trim;
  267. u8 second_point_trim;
  268. u8 default_temp_offset;
  269. u8 test_mux;
  270. enum calibration_type cal_type;
  271. enum calibration_mode cal_mode;
  272. enum soc_type type;
  273. struct freq_clip_table freq_tab[4];
  274. unsigned int freq_tab_count;
  275. const struct exynos_tmu_registers *registers;
  276. unsigned int features;
  277. };
  278. /**
  279. * struct exynos_tmu_init_data
  280. * @tmu_count: number of TMU instances.
  281. * @tmu_data: platform data of all TMU instances.
  282. * This structure is required to store data for multi-instance exynos tmu
  283. * driver.
  284. */
  285. struct exynos_tmu_init_data {
  286. int tmu_count;
  287. struct exynos_tmu_platform_data tmu_data[];
  288. };
  289. #endif /* _EXYNOS_TMU_H */