omap3-thermal-data.c 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /*
  2. * OMAP3 thermal driver.
  3. *
  4. * Copyright (C) 2011-2012 Texas Instruments Inc.
  5. * Copyright (C) 2014 Pavel Machek <pavel@ucw.cz>
  6. *
  7. * This software is licensed under the terms of the GNU General Public
  8. * License version 2, as published by the Free Software Foundation, and
  9. * may be copied, distributed, and modified under those terms.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * Note
  17. * http://www.ti.com/lit/er/sprz278f/sprz278f.pdf "Advisory
  18. * 3.1.1.186 MMC OCP Clock Not Gated When Thermal Sensor Is Used"
  19. *
  20. * Also TI says:
  21. * Just be careful when you try to make thermal policy like decisions
  22. * based on this sensor. Placement of the sensor w.r.t the actual logic
  23. * generating heat has to be a factor as well. If you are just looking
  24. * for an approximation temperature (thermometerish kind), you might be
  25. * ok with this. I am not sure we'd find any TI data around this.. just a
  26. * heads up.
  27. */
  28. #include "ti-thermal.h"
  29. #include "ti-bandgap.h"
  30. /*
  31. * OMAP34XX has one instance of thermal sensor for MPU
  32. * need to describe the individual bit fields
  33. */
  34. static struct temp_sensor_registers
  35. omap34xx_mpu_temp_sensor_registers = {
  36. .temp_sensor_ctrl = 0,
  37. .bgap_soc_mask = BIT(8),
  38. .bgap_eocz_mask = BIT(7),
  39. .bgap_dtemp_mask = 0x7f,
  40. .bgap_mode_ctrl = 0,
  41. .mode_ctrl_mask = BIT(9),
  42. };
  43. /* Thresholds and limits for OMAP34XX MPU temperature sensor */
  44. static struct temp_sensor_data omap34xx_mpu_temp_sensor_data = {
  45. .min_freq = 32768,
  46. .max_freq = 32768,
  47. .max_temp = 125000,
  48. .min_temp = -40000,
  49. .hyst_val = 5000,
  50. };
  51. /*
  52. * Temperature values in milli degree celsius
  53. */
  54. static const int
  55. omap34xx_adc_to_temp[128] = {
  56. -40000, -40000, -40000, -40000, -40000, -39000, -38000, -36000,
  57. -34000, -32000, -31000, -29000, -28000, -26000, -25000, -24000,
  58. -22000, -21000, -19000, -18000, -17000, -15000, -14000, -12000,
  59. -11000, -9000, -8000, -7000, -5000, -4000, -2000, -1000, 0000,
  60. 1000, 3000, 4000, 5000, 7000, 8000, 10000, 11000, 13000, 14000,
  61. 15000, 17000, 18000, 20000, 21000, 22000, 24000, 25000, 27000,
  62. 28000, 30000, 31000, 32000, 34000, 35000, 37000, 38000, 39000,
  63. 41000, 42000, 44000, 45000, 47000, 48000, 49000, 51000, 52000,
  64. 53000, 55000, 56000, 58000, 59000, 60000, 62000, 63000, 65000,
  65. 66000, 67000, 69000, 70000, 72000, 73000, 74000, 76000, 77000,
  66. 79000, 80000, 81000, 83000, 84000, 85000, 87000, 88000, 89000,
  67. 91000, 92000, 94000, 95000, 96000, 98000, 99000, 100000,
  68. 102000, 103000, 105000, 106000, 107000, 109000, 110000, 111000,
  69. 113000, 114000, 116000, 117000, 118000, 120000, 121000, 122000,
  70. 124000, 124000, 125000, 125000, 125000, 125000, 125000
  71. };
  72. /* OMAP34XX data */
  73. const struct ti_bandgap_data omap34xx_data = {
  74. .features = TI_BANDGAP_FEATURE_CLK_CTRL | TI_BANDGAP_FEATURE_UNRELIABLE,
  75. .fclock_name = "ts_fck",
  76. .div_ck_name = "ts_fck",
  77. .conv_table = omap34xx_adc_to_temp,
  78. .adc_start_val = 0,
  79. .adc_end_val = 127,
  80. .expose_sensor = ti_thermal_expose_sensor,
  81. .remove_sensor = ti_thermal_remove_sensor,
  82. .sensors = {
  83. {
  84. .registers = &omap34xx_mpu_temp_sensor_registers,
  85. .ts_data = &omap34xx_mpu_temp_sensor_data,
  86. .domain = "cpu",
  87. .slope = 0,
  88. .constant = 20000,
  89. .slope_pcb = 0,
  90. .constant_pcb = 20000,
  91. .register_cooling = NULL,
  92. .unregister_cooling = NULL,
  93. },
  94. },
  95. .sensor_count = 1,
  96. };
  97. /*
  98. * OMAP36XX has one instance of thermal sensor for MPU
  99. * need to describe the individual bit fields
  100. */
  101. static struct temp_sensor_registers
  102. omap36xx_mpu_temp_sensor_registers = {
  103. .temp_sensor_ctrl = 0,
  104. .bgap_soc_mask = BIT(9),
  105. .bgap_eocz_mask = BIT(8),
  106. .bgap_dtemp_mask = 0xFF,
  107. .bgap_mode_ctrl = 0,
  108. .mode_ctrl_mask = BIT(10),
  109. };
  110. /* Thresholds and limits for OMAP36XX MPU temperature sensor */
  111. static struct temp_sensor_data omap36xx_mpu_temp_sensor_data = {
  112. .min_freq = 32768,
  113. .max_freq = 32768,
  114. .max_temp = 125000,
  115. .min_temp = -40000,
  116. .hyst_val = 5000,
  117. };
  118. /*
  119. * Temperature values in milli degree celsius
  120. */
  121. static const int
  122. omap36xx_adc_to_temp[128] = {
  123. -40000, -40000, -40000, -40000, -40000, -40000, -40000, -40000,
  124. -40000, -40000, -40000, -40000, -40000, -38000, -35000, -34000,
  125. -32000, -30000, -28000, -26000, -24000, -22000, -20000, -18500,
  126. -17000, -15000, -13500, -12000, -10000, -8000, -6500, -5000, -3500,
  127. -1500, 0, 2000, 3500, 5000, 6500, 8500, 10000, 12000, 13500,
  128. 15000, 17000, 19000, 21000, 23000, 25000, 27000, 28500, 30000,
  129. 32000, 33500, 35000, 37000, 38500, 40000, 42000, 43500, 45000,
  130. 47000, 48500, 50000, 52000, 53500, 55000, 57000, 58500, 60000,
  131. 62000, 64000, 66000, 68000, 70000, 71500, 73500, 75000, 77000,
  132. 78500, 80000, 82000, 83500, 85000, 87000, 88500, 90000, 92000,
  133. 93500, 95000, 97000, 98500, 100000, 102000, 103500, 105000, 107000,
  134. 109000, 111000, 113000, 115000, 117000, 118500, 120000, 122000,
  135. 123500, 125000, 125000, 125000, 125000, 125000, 125000, 125000,
  136. 125000, 125000, 125000, 125000, 125000, 125000, 125000, 125000,
  137. 125000, 125000, 125000, 125000, 125000, 125000, 125000
  138. };
  139. /* OMAP36XX data */
  140. const struct ti_bandgap_data omap36xx_data = {
  141. .features = TI_BANDGAP_FEATURE_CLK_CTRL | TI_BANDGAP_FEATURE_UNRELIABLE,
  142. .fclock_name = "ts_fck",
  143. .div_ck_name = "ts_fck",
  144. .conv_table = omap36xx_adc_to_temp,
  145. .adc_start_val = 0,
  146. .adc_end_val = 127,
  147. .expose_sensor = ti_thermal_expose_sensor,
  148. .remove_sensor = ti_thermal_remove_sensor,
  149. .sensors = {
  150. {
  151. .registers = &omap36xx_mpu_temp_sensor_registers,
  152. .ts_data = &omap36xx_mpu_temp_sensor_data,
  153. .domain = "cpu",
  154. .slope = 0,
  155. .constant = 20000,
  156. .slope_pcb = 0,
  157. .constant_pcb = 20000,
  158. .register_cooling = NULL,
  159. .unregister_cooling = NULL,
  160. },
  161. },
  162. .sensor_count = 1,
  163. };