exynos_tmu.h 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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 soc_type {
  34. SOC_ARCH_EXYNOS3250 = 1,
  35. SOC_ARCH_EXYNOS4210,
  36. SOC_ARCH_EXYNOS4412,
  37. SOC_ARCH_EXYNOS5250,
  38. SOC_ARCH_EXYNOS5260,
  39. SOC_ARCH_EXYNOS5420_TRIMINFO,
  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_ADDRESS_MULTIPLE - 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_ADDRESS_MULTIPLE 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_ctrl: trim info controller register.
  74. * @triminfo_ctrl_count: the number of trim info controller register.
  75. * @tmu_ctrl: TMU main controller register.
  76. * @test_mux_addr_shift: shift bits of test mux address.
  77. * @therm_trip_mode_shift: shift bits of tripping mode in tmu_ctrl register.
  78. * @therm_trip_mode_mask: mask bits of tripping mode in tmu_ctrl register.
  79. * @therm_trip_en_shift: shift bits of tripping enable in tmu_ctrl register.
  80. * @tmu_status: register drescribing the TMU status.
  81. * @tmu_cur_temp: register containing the current temperature of the TMU.
  82. * @threshold_temp: register containing the base threshold level.
  83. * @threshold_th0: Register containing first set of rising levels.
  84. * @threshold_th1: Register containing second set of rising levels.
  85. * @threshold_th2: Register containing third set of rising levels.
  86. * @threshold_th3_l0_shift: shift bits of level0 threshold temperature.
  87. * @tmu_inten: register containing the different threshold interrupt
  88. enable bits.
  89. * @inten_rise0_shift: shift bits of rising 0 interrupt bits.
  90. * @inten_rise1_shift: shift bits of rising 1 interrupt bits.
  91. * @inten_rise2_shift: shift bits of rising 2 interrupt bits.
  92. * @inten_rise3_shift: shift bits of rising 3 interrupt bits.
  93. * @inten_fall0_shift: shift bits of falling 0 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. * @tmu_irqstatus: register to find which TMU generated interrupts.
  100. * @tmu_pmin: register to get/set the Pmin value.
  101. */
  102. struct exynos_tmu_registers {
  103. u32 triminfo_data;
  104. u32 triminfo_ctrl[MAX_TRIMINFO_CTRL_REG];
  105. u32 triminfo_ctrl_count;
  106. u32 tmu_ctrl;
  107. u32 test_mux_addr_shift;
  108. u32 therm_trip_mode_shift;
  109. u32 therm_trip_mode_mask;
  110. u32 therm_trip_en_shift;
  111. u32 tmu_status;
  112. u32 tmu_cur_temp;
  113. u32 threshold_temp;
  114. u32 threshold_th0;
  115. u32 threshold_th1;
  116. u32 threshold_th2;
  117. u32 threshold_th3_l0_shift;
  118. u32 tmu_inten;
  119. u32 inten_rise0_shift;
  120. u32 inten_rise1_shift;
  121. u32 inten_rise2_shift;
  122. u32 inten_rise3_shift;
  123. u32 inten_fall0_shift;
  124. u32 tmu_intstat;
  125. u32 tmu_intclear;
  126. u32 emul_con;
  127. u32 emul_temp_shift;
  128. u32 emul_time_shift;
  129. u32 tmu_irqstatus;
  130. u32 tmu_pmin;
  131. };
  132. /**
  133. * struct exynos_tmu_platform_data
  134. * @threshold: basic temperature for generating interrupt
  135. * 25 <= threshold <= 125 [unit: degree Celsius]
  136. * @threshold_falling: differntial value for setting threshold
  137. * of temperature falling interrupt.
  138. * @trigger_levels: array for each interrupt levels
  139. * [unit: degree Celsius]
  140. * 0: temperature for trigger_level0 interrupt
  141. * condition for trigger_level0 interrupt:
  142. * current temperature > threshold + trigger_levels[0]
  143. * 1: temperature for trigger_level1 interrupt
  144. * condition for trigger_level1 interrupt:
  145. * current temperature > threshold + trigger_levels[1]
  146. * 2: temperature for trigger_level2 interrupt
  147. * condition for trigger_level2 interrupt:
  148. * current temperature > threshold + trigger_levels[2]
  149. * 3: temperature for trigger_level3 interrupt
  150. * condition for trigger_level3 interrupt:
  151. * current temperature > threshold + trigger_levels[3]
  152. * @trigger_type: defines the type of trigger. Possible values are,
  153. * THROTTLE_ACTIVE trigger type
  154. * THROTTLE_PASSIVE trigger type
  155. * SW_TRIP trigger type
  156. * HW_TRIP
  157. * @trigger_enable[]: array to denote which trigger levels are enabled.
  158. * 1 = enable trigger_level[] interrupt,
  159. * 0 = disable trigger_level[] interrupt
  160. * @max_trigger_level: max trigger level supported by the TMU
  161. * @non_hw_trigger_levels: number of defined non-hardware trigger levels
  162. * @gain: gain of amplifier in the positive-TC generator block
  163. * 0 < gain <= 15
  164. * @reference_voltage: reference voltage of amplifier
  165. * in the positive-TC generator block
  166. * 0 < reference_voltage <= 31
  167. * @noise_cancel_mode: noise cancellation mode
  168. * 000, 100, 101, 110 and 111 can be different modes
  169. * @type: determines the type of SOC
  170. * @efuse_value: platform defined fuse value
  171. * @min_efuse_value: minimum valid trimming data
  172. * @max_efuse_value: maximum valid trimming data
  173. * @first_point_trim: temp value of the first point trimming
  174. * @second_point_trim: temp value of the second point trimming
  175. * @default_temp_offset: default temperature offset in case of no trimming
  176. * @test_mux; information if SoC supports test MUX
  177. * @triminfo_reload: reload value to read TRIMINFO register
  178. * @cal_type: calibration type for temperature
  179. * @freq_clip_table: Table representing frequency reduction percentage.
  180. * @freq_tab_count: Count of the above table as frequency reduction may
  181. * applicable to only some of the trigger levels.
  182. * @registers: Pointer to structure containing all the TMU controller registers
  183. * and bitfields shifts and masks.
  184. * @features: a bitfield value indicating the features supported in SOC like
  185. * emulation, multi instance etc
  186. *
  187. * This structure is required for configuration of exynos_tmu driver.
  188. */
  189. struct exynos_tmu_platform_data {
  190. u8 threshold;
  191. u8 threshold_falling;
  192. u8 trigger_levels[MAX_TRIP_COUNT];
  193. enum trigger_type trigger_type[MAX_TRIP_COUNT];
  194. bool trigger_enable[MAX_TRIP_COUNT];
  195. u8 max_trigger_level;
  196. u8 non_hw_trigger_levels;
  197. u8 gain;
  198. u8 reference_voltage;
  199. u8 noise_cancel_mode;
  200. u32 efuse_value;
  201. u32 min_efuse_value;
  202. u32 max_efuse_value;
  203. u8 first_point_trim;
  204. u8 second_point_trim;
  205. u8 default_temp_offset;
  206. u8 test_mux;
  207. u8 triminfo_reload[MAX_TRIMINFO_CTRL_REG];
  208. enum calibration_type cal_type;
  209. enum soc_type type;
  210. struct freq_clip_table freq_tab[4];
  211. unsigned int freq_tab_count;
  212. const struct exynos_tmu_registers *registers;
  213. unsigned int features;
  214. };
  215. /**
  216. * struct exynos_tmu_init_data
  217. * @tmu_count: number of TMU instances.
  218. * @tmu_data: platform data of all TMU instances.
  219. * This structure is required to store data for multi-instance exynos tmu
  220. * driver.
  221. */
  222. struct exynos_tmu_init_data {
  223. int tmu_count;
  224. struct exynos_tmu_platform_data tmu_data[];
  225. };
  226. #endif /* _EXYNOS_TMU_H */