omap5-thermal-data.c 11 KB

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