exynos_tmu.h 11 KB

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