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