omap5-thermal-data.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. /*
  2. * OMAP5 thermal driver.
  3. *
  4. * Copyright (C) 2011-2012 Texas Instruments Inc.
  5. * Contact:
  6. * Eduardo Valentin <eduardo.valentin@ti.com>
  7. *
  8. * This software is licensed under the terms of the GNU General Public
  9. * License version 2, as published by the Free Software Foundation, and
  10. * may be copied, distributed, and modified under those terms.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. */
  18. #include "ti-thermal.h"
  19. #include "ti-bandgap.h"
  20. #include "omap5xxx-bandgap.h"
  21. /*
  22. * OMAP5430 has three instances of thermal sensor for MPU, GPU & CORE,
  23. * need to describe the individual registers and bit fields.
  24. */
  25. /*
  26. * OMAP5430 MPU thermal sensor register offset and bit-fields
  27. */
  28. static struct temp_sensor_registers
  29. omap5430_mpu_temp_sensor_registers = {
  30. .temp_sensor_ctrl = OMAP5430_TEMP_SENSOR_MPU_OFFSET,
  31. .bgap_tempsoff_mask = OMAP5430_BGAP_TEMPSOFF_MASK,
  32. .bgap_eocz_mask = OMAP5430_BGAP_TEMP_SENSOR_EOCZ_MASK,
  33. .bgap_dtemp_mask = OMAP5430_BGAP_TEMP_SENSOR_DTEMP_MASK,
  34. .bgap_mask_ctrl = OMAP5430_BGAP_CTRL_OFFSET,
  35. .mask_hot_mask = OMAP5430_MASK_HOT_MPU_MASK,
  36. .mask_cold_mask = OMAP5430_MASK_COLD_MPU_MASK,
  37. .mask_counter_delay_mask = OMAP5430_MASK_COUNTER_DELAY_MASK,
  38. .mask_freeze_mask = OMAP5430_MASK_FREEZE_MPU_MASK,
  39. .bgap_counter = OMAP5430_BGAP_CTRL_OFFSET,
  40. .counter_mask = OMAP5430_COUNTER_MASK,
  41. .bgap_threshold = OMAP5430_BGAP_THRESHOLD_MPU_OFFSET,
  42. .threshold_thot_mask = OMAP5430_T_HOT_MASK,
  43. .threshold_tcold_mask = OMAP5430_T_COLD_MASK,
  44. .tshut_threshold = OMAP5430_BGAP_TSHUT_MPU_OFFSET,
  45. .tshut_hot_mask = OMAP5430_TSHUT_HOT_MASK,
  46. .tshut_cold_mask = OMAP5430_TSHUT_COLD_MASK,
  47. .bgap_status = OMAP5430_BGAP_STATUS_OFFSET,
  48. .status_hot_mask = OMAP5430_HOT_MPU_FLAG_MASK,
  49. .status_cold_mask = OMAP5430_COLD_MPU_FLAG_MASK,
  50. .ctrl_dtemp_1 = OMAP5430_BGAP_DTEMP_MPU_1_OFFSET,
  51. .ctrl_dtemp_2 = OMAP5430_BGAP_DTEMP_MPU_2_OFFSET,
  52. .bgap_efuse = OMAP5430_FUSE_OPP_BGAP_MPU,
  53. };
  54. /*
  55. * OMAP5430 GPU thermal sensor register offset and bit-fields
  56. */
  57. static struct temp_sensor_registers
  58. omap5430_gpu_temp_sensor_registers = {
  59. .temp_sensor_ctrl = OMAP5430_TEMP_SENSOR_GPU_OFFSET,
  60. .bgap_tempsoff_mask = OMAP5430_BGAP_TEMPSOFF_MASK,
  61. .bgap_eocz_mask = OMAP5430_BGAP_TEMP_SENSOR_EOCZ_MASK,
  62. .bgap_dtemp_mask = OMAP5430_BGAP_TEMP_SENSOR_DTEMP_MASK,
  63. .bgap_mask_ctrl = OMAP5430_BGAP_CTRL_OFFSET,
  64. .mask_hot_mask = OMAP5430_MASK_HOT_GPU_MASK,
  65. .mask_cold_mask = OMAP5430_MASK_COLD_GPU_MASK,
  66. .mask_counter_delay_mask = OMAP5430_MASK_COUNTER_DELAY_MASK,
  67. .mask_freeze_mask = OMAP5430_MASK_FREEZE_GPU_MASK,
  68. .bgap_counter = OMAP5430_BGAP_CTRL_OFFSET,
  69. .counter_mask = OMAP5430_COUNTER_MASK,
  70. .bgap_threshold = OMAP5430_BGAP_THRESHOLD_GPU_OFFSET,
  71. .threshold_thot_mask = OMAP5430_T_HOT_MASK,
  72. .threshold_tcold_mask = OMAP5430_T_COLD_MASK,
  73. .tshut_threshold = OMAP5430_BGAP_TSHUT_GPU_OFFSET,
  74. .tshut_hot_mask = OMAP5430_TSHUT_HOT_MASK,
  75. .tshut_cold_mask = OMAP5430_TSHUT_COLD_MASK,
  76. .bgap_status = OMAP5430_BGAP_STATUS_OFFSET,
  77. .status_hot_mask = OMAP5430_HOT_GPU_FLAG_MASK,
  78. .status_cold_mask = OMAP5430_COLD_GPU_FLAG_MASK,
  79. .ctrl_dtemp_1 = OMAP5430_BGAP_DTEMP_GPU_1_OFFSET,
  80. .ctrl_dtemp_2 = OMAP5430_BGAP_DTEMP_GPU_2_OFFSET,
  81. .bgap_efuse = OMAP5430_FUSE_OPP_BGAP_GPU,
  82. };
  83. /*
  84. * OMAP5430 CORE thermal sensor register offset and bit-fields
  85. */
  86. static struct temp_sensor_registers
  87. omap5430_core_temp_sensor_registers = {
  88. .temp_sensor_ctrl = OMAP5430_TEMP_SENSOR_CORE_OFFSET,
  89. .bgap_tempsoff_mask = OMAP5430_BGAP_TEMPSOFF_MASK,
  90. .bgap_eocz_mask = OMAP5430_BGAP_TEMP_SENSOR_EOCZ_MASK,
  91. .bgap_dtemp_mask = OMAP5430_BGAP_TEMP_SENSOR_DTEMP_MASK,
  92. .bgap_mask_ctrl = OMAP5430_BGAP_CTRL_OFFSET,
  93. .mask_hot_mask = OMAP5430_MASK_HOT_CORE_MASK,
  94. .mask_cold_mask = OMAP5430_MASK_COLD_CORE_MASK,
  95. .mask_counter_delay_mask = OMAP5430_MASK_COUNTER_DELAY_MASK,
  96. .mask_freeze_mask = OMAP5430_MASK_FREEZE_CORE_MASK,
  97. .bgap_counter = OMAP5430_BGAP_CTRL_OFFSET,
  98. .counter_mask = OMAP5430_COUNTER_MASK,
  99. .bgap_threshold = OMAP5430_BGAP_THRESHOLD_CORE_OFFSET,
  100. .threshold_thot_mask = OMAP5430_T_HOT_MASK,
  101. .threshold_tcold_mask = OMAP5430_T_COLD_MASK,
  102. .tshut_threshold = OMAP5430_BGAP_TSHUT_CORE_OFFSET,
  103. .tshut_hot_mask = OMAP5430_TSHUT_HOT_MASK,
  104. .tshut_cold_mask = OMAP5430_TSHUT_COLD_MASK,
  105. .bgap_status = OMAP5430_BGAP_STATUS_OFFSET,
  106. .status_hot_mask = OMAP5430_HOT_CORE_FLAG_MASK,
  107. .status_cold_mask = OMAP5430_COLD_CORE_FLAG_MASK,
  108. .ctrl_dtemp_1 = OMAP5430_BGAP_DTEMP_CORE_1_OFFSET,
  109. .ctrl_dtemp_2 = OMAP5430_BGAP_DTEMP_CORE_2_OFFSET,
  110. .bgap_efuse = OMAP5430_FUSE_OPP_BGAP_CORE,
  111. };
  112. /* Thresholds and limits for OMAP5430 MPU temperature sensor */
  113. static struct temp_sensor_data omap5430_mpu_temp_sensor_data = {
  114. .tshut_hot = OMAP5430_MPU_TSHUT_HOT,
  115. .tshut_cold = OMAP5430_MPU_TSHUT_COLD,
  116. .t_hot = OMAP5430_MPU_T_HOT,
  117. .t_cold = OMAP5430_MPU_T_COLD,
  118. .min_freq = OMAP5430_MPU_MIN_FREQ,
  119. .max_freq = OMAP5430_MPU_MAX_FREQ,
  120. };
  121. /* Thresholds and limits for OMAP5430 GPU temperature sensor */
  122. static struct temp_sensor_data omap5430_gpu_temp_sensor_data = {
  123. .tshut_hot = OMAP5430_GPU_TSHUT_HOT,
  124. .tshut_cold = OMAP5430_GPU_TSHUT_COLD,
  125. .t_hot = OMAP5430_GPU_T_HOT,
  126. .t_cold = OMAP5430_GPU_T_COLD,
  127. .min_freq = OMAP5430_GPU_MIN_FREQ,
  128. .max_freq = OMAP5430_GPU_MAX_FREQ,
  129. };
  130. /* Thresholds and limits for OMAP5430 CORE temperature sensor */
  131. static struct temp_sensor_data omap5430_core_temp_sensor_data = {
  132. .tshut_hot = OMAP5430_CORE_TSHUT_HOT,
  133. .tshut_cold = OMAP5430_CORE_TSHUT_COLD,
  134. .t_hot = OMAP5430_CORE_T_HOT,
  135. .t_cold = OMAP5430_CORE_T_COLD,
  136. .min_freq = OMAP5430_CORE_MIN_FREQ,
  137. .max_freq = OMAP5430_CORE_MAX_FREQ,
  138. };
  139. /*
  140. * OMAP54xx ES2.0 : Temperature values in milli degree celsius
  141. * ADC code values from 540 to 945
  142. */
  143. static int
  144. omap5430_adc_to_temp[
  145. OMAP5430_ADC_END_VALUE - OMAP5430_ADC_START_VALUE + 1] = {
  146. /* Index 540 - 549 */
  147. -40000, -40000, -40000, -40000, -39800, -39400, -39000, -38600, -38200,
  148. -37800,
  149. /* Index 550 - 559 */
  150. -37400, -37000, -36600, -36200, -35800, -35300, -34700, -34200, -33800,
  151. -33400,
  152. /* Index 560 - 569 */
  153. -33000, -32600, -32200, -31800, -31400, -31000, -30600, -30200, -29800,
  154. -29400,
  155. /* Index 570 - 579 */
  156. -29000, -28600, -28200, -27700, -27100, -26600, -26200, -25800, -25400,
  157. -25000,
  158. /* Index 580 - 589 */
  159. -24600, -24200, -23800, -23400, -23000, -22600, -22200, -21600, -21400,
  160. -21000,
  161. /* Index 590 - 599 */
  162. -20500, -19900, -19400, -19000, -18600, -18200, -17800, -17400, -17000,
  163. -16600,
  164. /* Index 600 - 609 */
  165. -16200, -15800, -15400, -15000, -14600, -14200, -13800, -13400, -13000,
  166. -12500,
  167. /* Index 610 - 619 */
  168. -11900, -11400, -11000, -10600, -10200, -9800, -9400, -9000, -8600,
  169. -8200,
  170. /* Index 620 - 629 */
  171. -7800, -7400, -7000, -6600, -6200, -5800, -5400, -5000, -4500, -3900,
  172. /* Index 630 - 639 */
  173. -3400, -3000, -2600, -2200, -1800, -1400, -1000, -600, -200, 200,
  174. /* Index 640 - 649 */
  175. 600, 1000, 1400, 1800, 2200, 2600, 3000, 3400, 3900, 4500,
  176. /* Index 650 - 659 */
  177. 5000, 5400, 5800, 6200, 6600, 7000, 7400, 7800, 8200, 8600,
  178. /* Index 660 - 669 */
  179. 9000, 9400, 9800, 10200, 10600, 11000, 11400, 11800, 12200, 12700,
  180. /* Index 670 - 679 */
  181. 13300, 13800, 14200, 14600, 15000, 15400, 15800, 16200, 16600, 17000,
  182. /* Index 680 - 689 */
  183. 17400, 17800, 18200, 18600, 19000, 19400, 19800, 20200, 20600, 21100,
  184. /* Index 690 - 699 */
  185. 21400, 21900, 22500, 23000, 23400, 23800, 24200, 24600, 25000, 25400,
  186. /* Index 700 - 709 */
  187. 25800, 26200, 26600, 27000, 27400, 27800, 28200, 28600, 29000, 29400,
  188. /* Index 710 - 719 */
  189. 29800, 30200, 30600, 31000, 31400, 31900, 32500, 33000, 33400, 33800,
  190. /* Index 720 - 729 */
  191. 34200, 34600, 35000, 35400, 35800, 36200, 36600, 37000, 37400, 37800,
  192. /* Index 730 - 739 */
  193. 38200, 38600, 39000, 39400, 39800, 40200, 40600, 41000, 41400, 41800,
  194. /* Index 740 - 749 */
  195. 42200, 42600, 43100, 43700, 44200, 44600, 45000, 45400, 45800, 46200,
  196. /* Index 750 - 759 */
  197. 46600, 47000, 47400, 47800, 48200, 48600, 49000, 49400, 49800, 50200,
  198. /* Index 760 - 769 */
  199. 50600, 51000, 51400, 51800, 52200, 52600, 53000, 53400, 53800, 54200,
  200. /* Index 770 - 779 */
  201. 54600, 55000, 55400, 55900, 56500, 57000, 57400, 57800, 58200, 58600,
  202. /* Index 780 - 789 */
  203. 59000, 59400, 59800, 60200, 60600, 61000, 61400, 61800, 62200, 62600,
  204. /* Index 790 - 799 */
  205. 63000, 63400, 63800, 64200, 64600, 65000, 65400, 65800, 66200, 66600,
  206. /* Index 800 - 809 */
  207. 67000, 67400, 67800, 68200, 68600, 69000, 69400, 69800, 70200, 70600,
  208. /* Index 810 - 819 */
  209. 71000, 71500, 72100, 72600, 73000, 73400, 73800, 74200, 74600, 75000,
  210. /* Index 820 - 829 */
  211. 75400, 75800, 76200, 76600, 77000, 77400, 77800, 78200, 78600, 79000,
  212. /* Index 830 - 839 */
  213. 79400, 79800, 80200, 80600, 81000, 81400, 81800, 82200, 82600, 83000,
  214. /* Index 840 - 849 */
  215. 83400, 83800, 84200, 84600, 85000, 85400, 85800, 86200, 86600, 87000,
  216. /* Index 850 - 859 */
  217. 87400, 87800, 88200, 88600, 89000, 89400, 89800, 90200, 90600, 91000,
  218. /* Index 860 - 869 */
  219. 91400, 91800, 92200, 92600, 93000, 93400, 93800, 94200, 94600, 95000,
  220. /* Index 870 - 879 */
  221. 95400, 95800, 96200, 96600, 97000, 97500, 98100, 98600, 99000, 99400,
  222. /* Index 880 - 889 */
  223. 99800, 100200, 100600, 101000, 101400, 101800, 102200, 102600, 103000,
  224. 103400,
  225. /* Index 890 - 899 */
  226. 103800, 104200, 104600, 105000, 105400, 105800, 106200, 106600, 107000,
  227. 107400,
  228. /* Index 900 - 909 */
  229. 107800, 108200, 108600, 109000, 109400, 109800, 110200, 110600, 111000,
  230. 111400,
  231. /* Index 910 - 919 */
  232. 111800, 112200, 112600, 113000, 113400, 113800, 114200, 114600, 115000,
  233. 115400,
  234. /* Index 920 - 929 */
  235. 115800, 116200, 116600, 117000, 117400, 117800, 118200, 118600, 119000,
  236. 119400,
  237. /* Index 930 - 939 */
  238. 119800, 120200, 120600, 121000, 121400, 121800, 122400, 122600, 123000,
  239. 123400,
  240. /* Index 940 - 945 */
  241. 123800, 124200, 124600, 124900, 125000, 125000,
  242. };
  243. /* OMAP54xx ES2.0 data */
  244. const struct ti_bandgap_data omap5430_data = {
  245. .features = TI_BANDGAP_FEATURE_TSHUT_CONFIG |
  246. TI_BANDGAP_FEATURE_FREEZE_BIT |
  247. TI_BANDGAP_FEATURE_TALERT |
  248. TI_BANDGAP_FEATURE_COUNTER_DELAY |
  249. TI_BANDGAP_FEATURE_HISTORY_BUFFER,
  250. .fclock_name = "l3instr_ts_gclk_div",
  251. .div_ck_name = "l3instr_ts_gclk_div",
  252. .conv_table = omap5430_adc_to_temp,
  253. .adc_start_val = OMAP5430_ADC_START_VALUE,
  254. .adc_end_val = OMAP5430_ADC_END_VALUE,
  255. .expose_sensor = ti_thermal_expose_sensor,
  256. .remove_sensor = ti_thermal_remove_sensor,
  257. .report_temperature = ti_thermal_report_sensor_temperature,
  258. .sensors = {
  259. {
  260. .registers = &omap5430_mpu_temp_sensor_registers,
  261. .ts_data = &omap5430_mpu_temp_sensor_data,
  262. .domain = "cpu",
  263. .register_cooling = ti_thermal_register_cpu_cooling,
  264. .unregister_cooling = ti_thermal_unregister_cpu_cooling,
  265. .slope_pcb = OMAP_GRADIENT_SLOPE_W_PCB_5430_CPU,
  266. .constant_pcb = OMAP_GRADIENT_CONST_W_PCB_5430_CPU,
  267. },
  268. {
  269. .registers = &omap5430_gpu_temp_sensor_registers,
  270. .ts_data = &omap5430_gpu_temp_sensor_data,
  271. .domain = "gpu",
  272. .slope_pcb = OMAP_GRADIENT_SLOPE_W_PCB_5430_GPU,
  273. .constant_pcb = OMAP_GRADIENT_CONST_W_PCB_5430_GPU,
  274. },
  275. {
  276. .registers = &omap5430_core_temp_sensor_registers,
  277. .ts_data = &omap5430_core_temp_sensor_data,
  278. .domain = "core",
  279. },
  280. },
  281. .sensor_count = 3,
  282. };