exynos_tmu.h 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  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_TWO_POINT_TRIMMING,
  29. TYPE_NONE,
  30. };
  31. enum calibration_mode {
  32. SW_MODE,
  33. HW_MODE,
  34. };
  35. enum soc_type {
  36. SOC_ARCH_EXYNOS4210 = 1,
  37. SOC_ARCH_EXYNOS,
  38. };
  39. /**
  40. * struct exynos_tmu_register - register descriptors to access registers and
  41. * bitfields. The register validity, offsets and bitfield values may vary
  42. * slightly across different exynos SOC's.
  43. * @triminfo_data: register containing 2 pont trimming data
  44. * @triminfo_25_shift: shift bit of the 25 C trim value in triminfo_data reg.
  45. * @triminfo_85_shift: shift bit of the 85 C trim value in triminfo_data reg.
  46. * @triminfo_ctrl: trim info controller register.
  47. * @triminfo_reload_shift: shift of triminfo reload enable bit in triminfo_ctrl
  48. reg.
  49. * @tmu_ctrl: TMU main controller register.
  50. * @buf_vref_sel_shift: shift bits of reference voltage in tmu_ctrl register.
  51. * @buf_vref_sel_mask: mask bits of reference voltage in tmu_ctrl register.
  52. * @therm_trip_mode_shift: shift bits of tripping mode in tmu_ctrl register.
  53. * @therm_trip_mode_mask: mask bits of tripping mode in tmu_ctrl register.
  54. * @therm_trip_en_shift: shift bits of tripping enable in tmu_ctrl register.
  55. * @buf_slope_sel_shift: shift bits of amplifier gain value in tmu_ctrl
  56. register.
  57. * @buf_slope_sel_mask: mask bits of amplifier gain value in tmu_ctrl register.
  58. * @therm_trip_tq_en_shift: shift bits of thermal trip enable by TQ pin in
  59. tmu_ctrl register.
  60. * @core_en_shift: shift bits of TMU core enable bit in tmu_ctrl register.
  61. * @tmu_status: register drescribing the TMU status.
  62. * @tmu_cur_temp: register containing the current temperature of the TMU.
  63. * @tmu_cur_temp_shift: shift bits of current temp value in tmu_cur_temp
  64. register.
  65. * @threshold_temp: register containing the base threshold level.
  66. * @threshold_th0: Register containing first set of rising levels.
  67. * @threshold_th0_l0_shift: shift bits of level0 threshold temperature.
  68. * @threshold_th0_l1_shift: shift bits of level1 threshold temperature.
  69. * @threshold_th0_l2_shift: shift bits of level2 threshold temperature.
  70. * @threshold_th0_l3_shift: shift bits of level3 threshold temperature.
  71. * @threshold_th1: Register containing second set of rising levels.
  72. * @threshold_th1_l0_shift: shift bits of level0 threshold temperature.
  73. * @threshold_th1_l1_shift: shift bits of level1 threshold temperature.
  74. * @threshold_th1_l2_shift: shift bits of level2 threshold temperature.
  75. * @threshold_th1_l3_shift: shift bits of level3 threshold temperature.
  76. * @threshold_th2: Register containing third set of rising levels.
  77. * @threshold_th2_l0_shift: shift bits of level0 threshold temperature.
  78. * @threshold_th3: Register containing fourth set of rising levels.
  79. * @threshold_th3_l0_shift: shift bits of level0 threshold temperature.
  80. * @tmu_inten: register containing the different threshold interrupt
  81. enable bits.
  82. * @inten_rise_shift: shift bits of all rising interrupt bits.
  83. * @inten_rise_mask: mask bits of all rising interrupt bits.
  84. * @inten_fall_shift: shift bits of all rising interrupt bits.
  85. * @inten_fall_mask: mask bits of all rising interrupt bits.
  86. * @inten_rise0_shift: shift bits of rising 0 interrupt bits.
  87. * @inten_rise1_shift: shift bits of rising 1 interrupt bits.
  88. * @inten_rise2_shift: shift bits of rising 2 interrupt bits.
  89. * @inten_rise3_shift: shift bits of rising 3 interrupt bits.
  90. * @inten_fall0_shift: shift bits of falling 0 interrupt bits.
  91. * @inten_fall1_shift: shift bits of falling 1 interrupt bits.
  92. * @inten_fall2_shift: shift bits of falling 2 interrupt bits.
  93. * @inten_fall3_shift: shift bits of falling 3 interrupt bits.
  94. * @tmu_intstat: Register containing the interrupt status values.
  95. * @tmu_intclear: Register for clearing the raised interrupt status.
  96. * @emul_con: TMU emulation controller register.
  97. * @emul_temp_shift: shift bits of emulation temperature.
  98. * @emul_time_shift: shift bits of emulation time.
  99. * @emul_time_mask: mask bits of emulation time.
  100. */
  101. struct exynos_tmu_registers {
  102. u32 triminfo_data;
  103. u32 triminfo_25_shift;
  104. u32 triminfo_85_shift;
  105. u32 triminfo_ctrl;
  106. u32 triminfo_reload_shift;
  107. u32 tmu_ctrl;
  108. u32 buf_vref_sel_shift;
  109. u32 buf_vref_sel_mask;
  110. u32 therm_trip_mode_shift;
  111. u32 therm_trip_mode_mask;
  112. u32 therm_trip_en_shift;
  113. u32 buf_slope_sel_shift;
  114. u32 buf_slope_sel_mask;
  115. u32 therm_trip_tq_en_shift;
  116. u32 core_en_shift;
  117. u32 tmu_status;
  118. u32 tmu_cur_temp;
  119. u32 tmu_cur_temp_shift;
  120. u32 threshold_temp;
  121. u32 threshold_th0;
  122. u32 threshold_th0_l0_shift;
  123. u32 threshold_th0_l1_shift;
  124. u32 threshold_th0_l2_shift;
  125. u32 threshold_th0_l3_shift;
  126. u32 threshold_th1;
  127. u32 threshold_th1_l0_shift;
  128. u32 threshold_th1_l1_shift;
  129. u32 threshold_th1_l2_shift;
  130. u32 threshold_th1_l3_shift;
  131. u32 threshold_th2;
  132. u32 threshold_th2_l0_shift;
  133. u32 threshold_th3;
  134. u32 threshold_th3_l0_shift;
  135. u32 tmu_inten;
  136. u32 inten_rise_shift;
  137. u32 inten_rise_mask;
  138. u32 inten_fall_shift;
  139. u32 inten_fall_mask;
  140. u32 inten_rise0_shift;
  141. u32 inten_rise1_shift;
  142. u32 inten_rise2_shift;
  143. u32 inten_rise3_shift;
  144. u32 inten_fall0_shift;
  145. u32 inten_fall1_shift;
  146. u32 inten_fall2_shift;
  147. u32 inten_fall3_shift;
  148. u32 tmu_intstat;
  149. u32 tmu_intclear;
  150. u32 emul_con;
  151. u32 emul_temp_shift;
  152. u32 emul_time_shift;
  153. u32 emul_time_mask;
  154. };
  155. /**
  156. * struct exynos_tmu_platform_data
  157. * @threshold: basic temperature for generating interrupt
  158. * 25 <= threshold <= 125 [unit: degree Celsius]
  159. * @threshold_falling: differntial value for setting threshold
  160. * of temperature falling interrupt.
  161. * @trigger_levels: array for each interrupt levels
  162. * [unit: degree Celsius]
  163. * 0: temperature for trigger_level0 interrupt
  164. * condition for trigger_level0 interrupt:
  165. * current temperature > threshold + trigger_levels[0]
  166. * 1: temperature for trigger_level1 interrupt
  167. * condition for trigger_level1 interrupt:
  168. * current temperature > threshold + trigger_levels[1]
  169. * 2: temperature for trigger_level2 interrupt
  170. * condition for trigger_level2 interrupt:
  171. * current temperature > threshold + trigger_levels[2]
  172. * 3: temperature for trigger_level3 interrupt
  173. * condition for trigger_level3 interrupt:
  174. * current temperature > threshold + trigger_levels[3]
  175. * @trigger_type: defines the type of trigger. Possible values are,
  176. * THROTTLE_ACTIVE trigger type
  177. * THROTTLE_PASSIVE trigger type
  178. * SW_TRIP trigger type
  179. * HW_TRIP
  180. * @trigger_enable[]: array to denote which trigger levels are enabled.
  181. * 1 = enable trigger_level[] interrupt,
  182. * 0 = disable trigger_level[] interrupt
  183. * @max_trigger_level: max trigger level supported by the TMU
  184. * @gain: gain of amplifier in the positive-TC generator block
  185. * 0 <= gain <= 15
  186. * @reference_voltage: reference voltage of amplifier
  187. * in the positive-TC generator block
  188. * 0 <= reference_voltage <= 31
  189. * @noise_cancel_mode: noise cancellation mode
  190. * 000, 100, 101, 110 and 111 can be different modes
  191. * @type: determines the type of SOC
  192. * @efuse_value: platform defined fuse value
  193. * @min_efuse_value: minimum valid trimming data
  194. * @max_efuse_value: maximum valid trimming data
  195. * @first_point_trim: temp value of the first point trimming
  196. * @second_point_trim: temp value of the second point trimming
  197. * @default_temp_offset: default temperature offset in case of no trimming
  198. * @cal_type: calibration type for temperature
  199. * @cal_mode: calibration mode for temperature
  200. * @freq_clip_table: Table representing frequency reduction percentage.
  201. * @freq_tab_count: Count of the above table as frequency reduction may
  202. * applicable to only some of the trigger levels.
  203. * @registers: Pointer to structure containing all the TMU controller registers
  204. * and bitfields shifts and masks.
  205. *
  206. * This structure is required for configuration of exynos_tmu driver.
  207. */
  208. struct exynos_tmu_platform_data {
  209. u8 threshold;
  210. u8 threshold_falling;
  211. u8 trigger_levels[MAX_TRIP_COUNT];
  212. enum trigger_type trigger_type[MAX_TRIP_COUNT];
  213. bool trigger_enable[MAX_TRIP_COUNT];
  214. u8 max_trigger_level;
  215. u8 gain;
  216. u8 reference_voltage;
  217. u8 noise_cancel_mode;
  218. u32 efuse_value;
  219. u32 min_efuse_value;
  220. u32 max_efuse_value;
  221. u8 first_point_trim;
  222. u8 second_point_trim;
  223. u8 default_temp_offset;
  224. enum calibration_type cal_type;
  225. enum calibration_mode cal_mode;
  226. enum soc_type type;
  227. struct freq_clip_table freq_tab[4];
  228. unsigned int freq_tab_count;
  229. const struct exynos_tmu_registers *registers;
  230. };
  231. #endif /* _EXYNOS_TMU_H */