1*eb982001SEduardo Valentin /* 2*eb982001SEduardo Valentin * OMAP4 thermal driver. 3*eb982001SEduardo Valentin * 4*eb982001SEduardo Valentin * Copyright (C) 2011-2012 Texas Instruments Inc. 5*eb982001SEduardo Valentin * Contact: 6*eb982001SEduardo Valentin * Eduardo Valentin <eduardo.valentin@ti.com> 7*eb982001SEduardo Valentin * 8*eb982001SEduardo Valentin * This software is licensed under the terms of the GNU General Public 9*eb982001SEduardo Valentin * License version 2, as published by the Free Software Foundation, and 10*eb982001SEduardo Valentin * may be copied, distributed, and modified under those terms. 11*eb982001SEduardo Valentin * 12*eb982001SEduardo Valentin * This program is distributed in the hope that it will be useful, 13*eb982001SEduardo Valentin * but WITHOUT ANY WARRANTY; without even the implied warranty of 14*eb982001SEduardo Valentin * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15*eb982001SEduardo Valentin * GNU General Public License for more details. 16*eb982001SEduardo Valentin * 17*eb982001SEduardo Valentin */ 18*eb982001SEduardo Valentin 19*eb982001SEduardo Valentin #include "ti-thermal.h" 20*eb982001SEduardo Valentin #include "ti-bandgap.h" 21*eb982001SEduardo Valentin #include "omap4xxx-bandgap.h" 22*eb982001SEduardo Valentin 23*eb982001SEduardo Valentin /* 24*eb982001SEduardo Valentin * OMAP4430 has one instance of thermal sensor for MPU 25*eb982001SEduardo Valentin * need to describe the individual bit fields 26*eb982001SEduardo Valentin */ 27*eb982001SEduardo Valentin static struct temp_sensor_registers 28*eb982001SEduardo Valentin omap4430_mpu_temp_sensor_registers = { 29*eb982001SEduardo Valentin .temp_sensor_ctrl = OMAP4430_TEMP_SENSOR_CTRL_OFFSET, 30*eb982001SEduardo Valentin .bgap_tempsoff_mask = OMAP4430_BGAP_TEMPSOFF_MASK, 31*eb982001SEduardo Valentin .bgap_soc_mask = OMAP4430_BGAP_TEMP_SENSOR_SOC_MASK, 32*eb982001SEduardo Valentin .bgap_eocz_mask = OMAP4430_BGAP_TEMP_SENSOR_EOCZ_MASK, 33*eb982001SEduardo Valentin .bgap_dtemp_mask = OMAP4430_BGAP_TEMP_SENSOR_DTEMP_MASK, 34*eb982001SEduardo Valentin 35*eb982001SEduardo Valentin .bgap_mode_ctrl = OMAP4430_TEMP_SENSOR_CTRL_OFFSET, 36*eb982001SEduardo Valentin .mode_ctrl_mask = OMAP4430_SINGLE_MODE_MASK, 37*eb982001SEduardo Valentin 38*eb982001SEduardo Valentin .bgap_efuse = OMAP4430_FUSE_OPP_BGAP, 39*eb982001SEduardo Valentin }; 40*eb982001SEduardo Valentin 41*eb982001SEduardo Valentin /* Thresholds and limits for OMAP4430 MPU temperature sensor */ 42*eb982001SEduardo Valentin static struct temp_sensor_data omap4430_mpu_temp_sensor_data = { 43*eb982001SEduardo Valentin .min_freq = OMAP4430_MIN_FREQ, 44*eb982001SEduardo Valentin .max_freq = OMAP4430_MAX_FREQ, 45*eb982001SEduardo Valentin .max_temp = OMAP4430_MAX_TEMP, 46*eb982001SEduardo Valentin .min_temp = OMAP4430_MIN_TEMP, 47*eb982001SEduardo Valentin .hyst_val = OMAP4430_HYST_VAL, 48*eb982001SEduardo Valentin }; 49*eb982001SEduardo Valentin 50*eb982001SEduardo Valentin /* 51*eb982001SEduardo Valentin * Temperature values in milli degree celsius 52*eb982001SEduardo Valentin * ADC code values from 530 to 923 53*eb982001SEduardo Valentin */ 54*eb982001SEduardo Valentin static const int 55*eb982001SEduardo Valentin omap4430_adc_to_temp[OMAP4430_ADC_END_VALUE - OMAP4430_ADC_START_VALUE + 1] = { 56*eb982001SEduardo Valentin -38000, -35000, -34000, -32000, -30000, -28000, -26000, -24000, -22000, 57*eb982001SEduardo Valentin -20000, -18000, -17000, -15000, -13000, -12000, -10000, -8000, -6000, 58*eb982001SEduardo Valentin -5000, -3000, -1000, 0, 2000, 3000, 5000, 6000, 8000, 10000, 12000, 59*eb982001SEduardo Valentin 13000, 15000, 17000, 19000, 21000, 23000, 25000, 27000, 28000, 30000, 60*eb982001SEduardo Valentin 32000, 33000, 35000, 37000, 38000, 40000, 42000, 43000, 45000, 47000, 61*eb982001SEduardo Valentin 48000, 50000, 52000, 53000, 55000, 57000, 58000, 60000, 62000, 64000, 62*eb982001SEduardo Valentin 66000, 68000, 70000, 71000, 73000, 75000, 77000, 78000, 80000, 82000, 63*eb982001SEduardo Valentin 83000, 85000, 87000, 88000, 90000, 92000, 93000, 95000, 97000, 98000, 64*eb982001SEduardo Valentin 100000, 102000, 103000, 105000, 107000, 109000, 111000, 113000, 115000, 65*eb982001SEduardo Valentin 117000, 118000, 120000, 122000, 123000, 66*eb982001SEduardo Valentin }; 67*eb982001SEduardo Valentin 68*eb982001SEduardo Valentin /* OMAP4430 data */ 69*eb982001SEduardo Valentin const struct ti_bandgap_data omap4430_data = { 70*eb982001SEduardo Valentin .features = TI_BANDGAP_FEATURE_MODE_CONFIG | 71*eb982001SEduardo Valentin TI_BANDGAP_FEATURE_CLK_CTRL | 72*eb982001SEduardo Valentin TI_BANDGAP_FEATURE_POWER_SWITCH, 73*eb982001SEduardo Valentin .fclock_name = "bandgap_fclk", 74*eb982001SEduardo Valentin .div_ck_name = "bandgap_fclk", 75*eb982001SEduardo Valentin .conv_table = omap4430_adc_to_temp, 76*eb982001SEduardo Valentin .adc_start_val = OMAP4430_ADC_START_VALUE, 77*eb982001SEduardo Valentin .adc_end_val = OMAP4430_ADC_END_VALUE, 78*eb982001SEduardo Valentin .expose_sensor = ti_thermal_expose_sensor, 79*eb982001SEduardo Valentin .remove_sensor = ti_thermal_remove_sensor, 80*eb982001SEduardo Valentin .sensors = { 81*eb982001SEduardo Valentin { 82*eb982001SEduardo Valentin .registers = &omap4430_mpu_temp_sensor_registers, 83*eb982001SEduardo Valentin .ts_data = &omap4430_mpu_temp_sensor_data, 84*eb982001SEduardo Valentin .domain = "cpu", 85*eb982001SEduardo Valentin .slope = OMAP_GRADIENT_SLOPE_4430, 86*eb982001SEduardo Valentin .constant = OMAP_GRADIENT_CONST_4430, 87*eb982001SEduardo Valentin .slope_pcb = OMAP_GRADIENT_SLOPE_W_PCB_4430, 88*eb982001SEduardo Valentin .constant_pcb = OMAP_GRADIENT_CONST_W_PCB_4430, 89*eb982001SEduardo Valentin .register_cooling = ti_thermal_register_cpu_cooling, 90*eb982001SEduardo Valentin .unregister_cooling = ti_thermal_unregister_cpu_cooling, 91*eb982001SEduardo Valentin }, 92*eb982001SEduardo Valentin }, 93*eb982001SEduardo Valentin .sensor_count = 1, 94*eb982001SEduardo Valentin }; 95*eb982001SEduardo Valentin /* 96*eb982001SEduardo Valentin * OMAP4460 has one instance of thermal sensor for MPU 97*eb982001SEduardo Valentin * need to describe the individual bit fields 98*eb982001SEduardo Valentin */ 99*eb982001SEduardo Valentin static struct temp_sensor_registers 100*eb982001SEduardo Valentin omap4460_mpu_temp_sensor_registers = { 101*eb982001SEduardo Valentin .temp_sensor_ctrl = OMAP4460_TEMP_SENSOR_CTRL_OFFSET, 102*eb982001SEduardo Valentin .bgap_tempsoff_mask = OMAP4460_BGAP_TEMPSOFF_MASK, 103*eb982001SEduardo Valentin .bgap_soc_mask = OMAP4460_BGAP_TEMP_SENSOR_SOC_MASK, 104*eb982001SEduardo Valentin .bgap_eocz_mask = OMAP4460_BGAP_TEMP_SENSOR_EOCZ_MASK, 105*eb982001SEduardo Valentin .bgap_dtemp_mask = OMAP4460_BGAP_TEMP_SENSOR_DTEMP_MASK, 106*eb982001SEduardo Valentin 107*eb982001SEduardo Valentin .bgap_mask_ctrl = OMAP4460_BGAP_CTRL_OFFSET, 108*eb982001SEduardo Valentin .mask_hot_mask = OMAP4460_MASK_HOT_MASK, 109*eb982001SEduardo Valentin .mask_cold_mask = OMAP4460_MASK_COLD_MASK, 110*eb982001SEduardo Valentin 111*eb982001SEduardo Valentin .bgap_mode_ctrl = OMAP4460_BGAP_CTRL_OFFSET, 112*eb982001SEduardo Valentin .mode_ctrl_mask = OMAP4460_SINGLE_MODE_MASK, 113*eb982001SEduardo Valentin 114*eb982001SEduardo Valentin .bgap_counter = OMAP4460_BGAP_COUNTER_OFFSET, 115*eb982001SEduardo Valentin .counter_mask = OMAP4460_COUNTER_MASK, 116*eb982001SEduardo Valentin 117*eb982001SEduardo Valentin .bgap_threshold = OMAP4460_BGAP_THRESHOLD_OFFSET, 118*eb982001SEduardo Valentin .threshold_thot_mask = OMAP4460_T_HOT_MASK, 119*eb982001SEduardo Valentin .threshold_tcold_mask = OMAP4460_T_COLD_MASK, 120*eb982001SEduardo Valentin 121*eb982001SEduardo Valentin .tshut_threshold = OMAP4460_BGAP_TSHUT_OFFSET, 122*eb982001SEduardo Valentin .tshut_hot_mask = OMAP4460_TSHUT_HOT_MASK, 123*eb982001SEduardo Valentin .tshut_cold_mask = OMAP4460_TSHUT_COLD_MASK, 124*eb982001SEduardo Valentin 125*eb982001SEduardo Valentin .bgap_status = OMAP4460_BGAP_STATUS_OFFSET, 126*eb982001SEduardo Valentin .status_clean_stop_mask = OMAP4460_CLEAN_STOP_MASK, 127*eb982001SEduardo Valentin .status_bgap_alert_mask = OMAP4460_BGAP_ALERT_MASK, 128*eb982001SEduardo Valentin .status_hot_mask = OMAP4460_HOT_FLAG_MASK, 129*eb982001SEduardo Valentin .status_cold_mask = OMAP4460_COLD_FLAG_MASK, 130*eb982001SEduardo Valentin 131*eb982001SEduardo Valentin .bgap_efuse = OMAP4460_FUSE_OPP_BGAP, 132*eb982001SEduardo Valentin }; 133*eb982001SEduardo Valentin 134*eb982001SEduardo Valentin /* Thresholds and limits for OMAP4460 MPU temperature sensor */ 135*eb982001SEduardo Valentin static struct temp_sensor_data omap4460_mpu_temp_sensor_data = { 136*eb982001SEduardo Valentin .tshut_hot = OMAP4460_TSHUT_HOT, 137*eb982001SEduardo Valentin .tshut_cold = OMAP4460_TSHUT_COLD, 138*eb982001SEduardo Valentin .t_hot = OMAP4460_T_HOT, 139*eb982001SEduardo Valentin .t_cold = OMAP4460_T_COLD, 140*eb982001SEduardo Valentin .min_freq = OMAP4460_MIN_FREQ, 141*eb982001SEduardo Valentin .max_freq = OMAP4460_MAX_FREQ, 142*eb982001SEduardo Valentin .max_temp = OMAP4460_MAX_TEMP, 143*eb982001SEduardo Valentin .min_temp = OMAP4460_MIN_TEMP, 144*eb982001SEduardo Valentin .hyst_val = OMAP4460_HYST_VAL, 145*eb982001SEduardo Valentin .update_int1 = 1000, 146*eb982001SEduardo Valentin .update_int2 = 2000, 147*eb982001SEduardo Valentin }; 148*eb982001SEduardo Valentin 149*eb982001SEduardo Valentin /* 150*eb982001SEduardo Valentin * Temperature values in milli degree celsius 151*eb982001SEduardo Valentin * ADC code values from 530 to 923 152*eb982001SEduardo Valentin */ 153*eb982001SEduardo Valentin static const int 154*eb982001SEduardo Valentin omap4460_adc_to_temp[OMAP4460_ADC_END_VALUE - OMAP4460_ADC_START_VALUE + 1] = { 155*eb982001SEduardo Valentin -40000, -40000, -40000, -40000, -39800, -39400, -39000, -38600, -38200, 156*eb982001SEduardo Valentin -37800, -37300, -36800, -36400, -36000, -35600, -35200, -34800, 157*eb982001SEduardo Valentin -34300, -33800, -33400, -33000, -32600, -32200, -31800, -31300, 158*eb982001SEduardo Valentin -30800, -30400, -30000, -29600, -29200, -28700, -28200, -27800, 159*eb982001SEduardo Valentin -27400, -27000, -26600, -26200, -25700, -25200, -24800, -24400, 160*eb982001SEduardo Valentin -24000, -23600, -23200, -22700, -22200, -21800, -21400, -21000, 161*eb982001SEduardo Valentin -20600, -20200, -19700, -19200, -18800, -18400, -18000, -17600, 162*eb982001SEduardo Valentin -17200, -16700, -16200, -15800, -15400, -15000, -14600, -14200, 163*eb982001SEduardo Valentin -13700, -13200, -12800, -12400, -12000, -11600, -11200, -10700, 164*eb982001SEduardo Valentin -10200, -9800, -9400, -9000, -8600, -8200, -7700, -7200, -6800, 165*eb982001SEduardo Valentin -6400, -6000, -5600, -5200, -4800, -4300, -3800, -3400, -3000, 166*eb982001SEduardo Valentin -2600, -2200, -1800, -1300, -800, -400, 0, 400, 800, 1200, 1600, 167*eb982001SEduardo Valentin 2100, 2600, 3000, 3400, 3800, 4200, 4600, 5100, 5600, 6000, 6400, 168*eb982001SEduardo Valentin 6800, 7200, 7600, 8000, 8500, 9000, 9400, 9800, 10200, 10600, 11000, 169*eb982001SEduardo Valentin 11400, 11900, 12400, 12800, 13200, 13600, 14000, 14400, 14800, 170*eb982001SEduardo Valentin 15300, 15800, 16200, 16600, 17000, 17400, 17800, 18200, 18700, 171*eb982001SEduardo Valentin 19200, 19600, 20000, 20400, 20800, 21200, 21600, 22100, 22600, 172*eb982001SEduardo Valentin 23000, 23400, 23800, 24200, 24600, 25000, 25400, 25900, 26400, 173*eb982001SEduardo Valentin 26800, 27200, 27600, 28000, 28400, 28800, 29300, 29800, 30200, 174*eb982001SEduardo Valentin 30600, 31000, 31400, 31800, 32200, 32600, 33100, 33600, 34000, 175*eb982001SEduardo Valentin 34400, 34800, 35200, 35600, 36000, 36400, 36800, 37300, 37800, 176*eb982001SEduardo Valentin 38200, 38600, 39000, 39400, 39800, 40200, 40600, 41100, 41600, 177*eb982001SEduardo Valentin 42000, 42400, 42800, 43200, 43600, 44000, 44400, 44800, 45300, 178*eb982001SEduardo Valentin 45800, 46200, 46600, 47000, 47400, 47800, 48200, 48600, 49000, 179*eb982001SEduardo Valentin 49500, 50000, 50400, 50800, 51200, 51600, 52000, 52400, 52800, 180*eb982001SEduardo Valentin 53200, 53700, 54200, 54600, 55000, 55400, 55800, 56200, 56600, 181*eb982001SEduardo Valentin 57000, 57400, 57800, 58200, 58700, 59200, 59600, 60000, 60400, 182*eb982001SEduardo Valentin 60800, 61200, 61600, 62000, 62400, 62800, 63300, 63800, 64200, 183*eb982001SEduardo Valentin 64600, 65000, 65400, 65800, 66200, 66600, 67000, 67400, 67800, 184*eb982001SEduardo Valentin 68200, 68700, 69200, 69600, 70000, 70400, 70800, 71200, 71600, 185*eb982001SEduardo Valentin 72000, 72400, 72800, 73200, 73600, 74100, 74600, 75000, 75400, 186*eb982001SEduardo Valentin 75800, 76200, 76600, 77000, 77400, 77800, 78200, 78600, 79000, 187*eb982001SEduardo Valentin 79400, 79800, 80300, 80800, 81200, 81600, 82000, 82400, 82800, 188*eb982001SEduardo Valentin 83200, 83600, 84000, 84400, 84800, 85200, 85600, 86000, 86400, 189*eb982001SEduardo Valentin 86800, 87300, 87800, 88200, 88600, 89000, 89400, 89800, 90200, 190*eb982001SEduardo Valentin 90600, 91000, 91400, 91800, 92200, 92600, 93000, 93400, 93800, 191*eb982001SEduardo Valentin 94200, 94600, 95000, 95500, 96000, 96400, 96800, 97200, 97600, 192*eb982001SEduardo Valentin 98000, 98400, 98800, 99200, 99600, 100000, 100400, 100800, 101200, 193*eb982001SEduardo Valentin 101600, 102000, 102400, 102800, 103200, 103600, 104000, 104400, 194*eb982001SEduardo Valentin 104800, 105200, 105600, 106100, 106600, 107000, 107400, 107800, 195*eb982001SEduardo Valentin 108200, 108600, 109000, 109400, 109800, 110200, 110600, 111000, 196*eb982001SEduardo Valentin 111400, 111800, 112200, 112600, 113000, 113400, 113800, 114200, 197*eb982001SEduardo Valentin 114600, 115000, 115400, 115800, 116200, 116600, 117000, 117400, 198*eb982001SEduardo Valentin 117800, 118200, 118600, 119000, 119400, 119800, 120200, 120600, 199*eb982001SEduardo Valentin 121000, 121400, 121800, 122200, 122600, 123000, 123400, 123800, 124200, 200*eb982001SEduardo Valentin 124600, 124900, 125000, 125000, 125000, 125000 201*eb982001SEduardo Valentin }; 202*eb982001SEduardo Valentin 203*eb982001SEduardo Valentin /* OMAP4460 data */ 204*eb982001SEduardo Valentin const struct ti_bandgap_data omap4460_data = { 205*eb982001SEduardo Valentin .features = TI_BANDGAP_FEATURE_TSHUT | 206*eb982001SEduardo Valentin TI_BANDGAP_FEATURE_TSHUT_CONFIG | 207*eb982001SEduardo Valentin TI_BANDGAP_FEATURE_TALERT | 208*eb982001SEduardo Valentin TI_BANDGAP_FEATURE_MODE_CONFIG | 209*eb982001SEduardo Valentin TI_BANDGAP_FEATURE_POWER_SWITCH | 210*eb982001SEduardo Valentin TI_BANDGAP_FEATURE_CLK_CTRL | 211*eb982001SEduardo Valentin TI_BANDGAP_FEATURE_COUNTER, 212*eb982001SEduardo Valentin .fclock_name = "bandgap_ts_fclk", 213*eb982001SEduardo Valentin .div_ck_name = "div_ts_ck", 214*eb982001SEduardo Valentin .conv_table = omap4460_adc_to_temp, 215*eb982001SEduardo Valentin .adc_start_val = OMAP4460_ADC_START_VALUE, 216*eb982001SEduardo Valentin .adc_end_val = OMAP4460_ADC_END_VALUE, 217*eb982001SEduardo Valentin .expose_sensor = ti_thermal_expose_sensor, 218*eb982001SEduardo Valentin .remove_sensor = ti_thermal_remove_sensor, 219*eb982001SEduardo Valentin .report_temperature = ti_thermal_report_sensor_temperature, 220*eb982001SEduardo Valentin .sensors = { 221*eb982001SEduardo Valentin { 222*eb982001SEduardo Valentin .registers = &omap4460_mpu_temp_sensor_registers, 223*eb982001SEduardo Valentin .ts_data = &omap4460_mpu_temp_sensor_data, 224*eb982001SEduardo Valentin .domain = "cpu", 225*eb982001SEduardo Valentin .slope = OMAP_GRADIENT_SLOPE_4460, 226*eb982001SEduardo Valentin .constant = OMAP_GRADIENT_CONST_4460, 227*eb982001SEduardo Valentin .slope_pcb = OMAP_GRADIENT_SLOPE_W_PCB_4460, 228*eb982001SEduardo Valentin .constant_pcb = OMAP_GRADIENT_CONST_W_PCB_4460, 229*eb982001SEduardo Valentin .register_cooling = ti_thermal_register_cpu_cooling, 230*eb982001SEduardo Valentin .unregister_cooling = ti_thermal_unregister_cpu_cooling, 231*eb982001SEduardo Valentin }, 232*eb982001SEduardo Valentin }, 233*eb982001SEduardo Valentin .sensor_count = 1, 234*eb982001SEduardo Valentin }; 235*eb982001SEduardo Valentin 236*eb982001SEduardo Valentin /* OMAP4470 data */ 237*eb982001SEduardo Valentin const struct ti_bandgap_data omap4470_data = { 238*eb982001SEduardo Valentin .features = TI_BANDGAP_FEATURE_TSHUT | 239*eb982001SEduardo Valentin TI_BANDGAP_FEATURE_TSHUT_CONFIG | 240*eb982001SEduardo Valentin TI_BANDGAP_FEATURE_TALERT | 241*eb982001SEduardo Valentin TI_BANDGAP_FEATURE_MODE_CONFIG | 242*eb982001SEduardo Valentin TI_BANDGAP_FEATURE_POWER_SWITCH | 243*eb982001SEduardo Valentin TI_BANDGAP_FEATURE_CLK_CTRL | 244*eb982001SEduardo Valentin TI_BANDGAP_FEATURE_COUNTER, 245*eb982001SEduardo Valentin .fclock_name = "bandgap_ts_fclk", 246*eb982001SEduardo Valentin .div_ck_name = "div_ts_ck", 247*eb982001SEduardo Valentin .conv_table = omap4460_adc_to_temp, 248*eb982001SEduardo Valentin .adc_start_val = OMAP4460_ADC_START_VALUE, 249*eb982001SEduardo Valentin .adc_end_val = OMAP4460_ADC_END_VALUE, 250*eb982001SEduardo Valentin .expose_sensor = ti_thermal_expose_sensor, 251*eb982001SEduardo Valentin .remove_sensor = ti_thermal_remove_sensor, 252*eb982001SEduardo Valentin .report_temperature = ti_thermal_report_sensor_temperature, 253*eb982001SEduardo Valentin .sensors = { 254*eb982001SEduardo Valentin { 255*eb982001SEduardo Valentin .registers = &omap4460_mpu_temp_sensor_registers, 256*eb982001SEduardo Valentin .ts_data = &omap4460_mpu_temp_sensor_data, 257*eb982001SEduardo Valentin .domain = "cpu", 258*eb982001SEduardo Valentin .slope = OMAP_GRADIENT_SLOPE_4470, 259*eb982001SEduardo Valentin .constant = OMAP_GRADIENT_CONST_4470, 260*eb982001SEduardo Valentin .slope_pcb = OMAP_GRADIENT_SLOPE_W_PCB_4470, 261*eb982001SEduardo Valentin .constant_pcb = OMAP_GRADIENT_CONST_W_PCB_4470, 262*eb982001SEduardo Valentin .register_cooling = ti_thermal_register_cpu_cooling, 263*eb982001SEduardo Valentin .unregister_cooling = ti_thermal_unregister_cpu_cooling, 264*eb982001SEduardo Valentin }, 265*eb982001SEduardo Valentin }, 266*eb982001SEduardo Valentin .sensor_count = 1, 267*eb982001SEduardo Valentin }; 268