18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * OMAP3 thermal driver. 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2011-2012 Texas Instruments Inc. 68c2ecf20Sopenharmony_ci * Copyright (C) 2014 Pavel Machek <pavel@ucw.cz> 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci * Note 98c2ecf20Sopenharmony_ci * http://www.ti.com/lit/er/sprz278f/sprz278f.pdf "Advisory 108c2ecf20Sopenharmony_ci * 3.1.1.186 MMC OCP Clock Not Gated When Thermal Sensor Is Used" 118c2ecf20Sopenharmony_ci * 128c2ecf20Sopenharmony_ci * Also TI says: 138c2ecf20Sopenharmony_ci * Just be careful when you try to make thermal policy like decisions 148c2ecf20Sopenharmony_ci * based on this sensor. Placement of the sensor w.r.t the actual logic 158c2ecf20Sopenharmony_ci * generating heat has to be a factor as well. If you are just looking 168c2ecf20Sopenharmony_ci * for an approximation temperature (thermometerish kind), you might be 178c2ecf20Sopenharmony_ci * ok with this. I am not sure we'd find any TI data around this.. just a 188c2ecf20Sopenharmony_ci * heads up. 198c2ecf20Sopenharmony_ci */ 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci#include "ti-thermal.h" 228c2ecf20Sopenharmony_ci#include "ti-bandgap.h" 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci/* 258c2ecf20Sopenharmony_ci * OMAP34XX has one instance of thermal sensor for MPU 268c2ecf20Sopenharmony_ci * need to describe the individual bit fields 278c2ecf20Sopenharmony_ci */ 288c2ecf20Sopenharmony_cistatic struct temp_sensor_registers 298c2ecf20Sopenharmony_ciomap34xx_mpu_temp_sensor_registers = { 308c2ecf20Sopenharmony_ci .temp_sensor_ctrl = 0, 318c2ecf20Sopenharmony_ci .bgap_soc_mask = BIT(8), 328c2ecf20Sopenharmony_ci .bgap_eocz_mask = BIT(7), 338c2ecf20Sopenharmony_ci .bgap_dtemp_mask = 0x7f, 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci .bgap_mode_ctrl = 0, 368c2ecf20Sopenharmony_ci .mode_ctrl_mask = BIT(9), 378c2ecf20Sopenharmony_ci}; 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci/* Thresholds and limits for OMAP34XX MPU temperature sensor */ 408c2ecf20Sopenharmony_cistatic struct temp_sensor_data omap34xx_mpu_temp_sensor_data = { 418c2ecf20Sopenharmony_ci .min_freq = 32768, 428c2ecf20Sopenharmony_ci .max_freq = 32768, 438c2ecf20Sopenharmony_ci}; 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci/* 468c2ecf20Sopenharmony_ci * Temperature values in milli degree celsius 478c2ecf20Sopenharmony_ci */ 488c2ecf20Sopenharmony_cistatic const int 498c2ecf20Sopenharmony_ciomap34xx_adc_to_temp[128] = { 508c2ecf20Sopenharmony_ci -40000, -40000, -40000, -40000, -40000, -39000, -38000, -36000, 518c2ecf20Sopenharmony_ci -34000, -32000, -31000, -29000, -28000, -26000, -25000, -24000, 528c2ecf20Sopenharmony_ci -22000, -21000, -19000, -18000, -17000, -15000, -14000, -12000, 538c2ecf20Sopenharmony_ci -11000, -9000, -8000, -7000, -5000, -4000, -2000, -1000, 0000, 548c2ecf20Sopenharmony_ci 1000, 3000, 4000, 5000, 7000, 8000, 10000, 11000, 13000, 14000, 558c2ecf20Sopenharmony_ci 15000, 17000, 18000, 20000, 21000, 22000, 24000, 25000, 27000, 568c2ecf20Sopenharmony_ci 28000, 30000, 31000, 32000, 34000, 35000, 37000, 38000, 39000, 578c2ecf20Sopenharmony_ci 41000, 42000, 44000, 45000, 47000, 48000, 49000, 51000, 52000, 588c2ecf20Sopenharmony_ci 53000, 55000, 56000, 58000, 59000, 60000, 62000, 63000, 65000, 598c2ecf20Sopenharmony_ci 66000, 67000, 69000, 70000, 72000, 73000, 74000, 76000, 77000, 608c2ecf20Sopenharmony_ci 79000, 80000, 81000, 83000, 84000, 85000, 87000, 88000, 89000, 618c2ecf20Sopenharmony_ci 91000, 92000, 94000, 95000, 96000, 98000, 99000, 100000, 628c2ecf20Sopenharmony_ci 102000, 103000, 105000, 106000, 107000, 109000, 110000, 111000, 638c2ecf20Sopenharmony_ci 113000, 114000, 116000, 117000, 118000, 120000, 121000, 122000, 648c2ecf20Sopenharmony_ci 124000, 124000, 125000, 125000, 125000, 125000, 125000 658c2ecf20Sopenharmony_ci}; 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ci/* OMAP34XX data */ 688c2ecf20Sopenharmony_ciconst struct ti_bandgap_data omap34xx_data = { 698c2ecf20Sopenharmony_ci .features = TI_BANDGAP_FEATURE_CLK_CTRL | TI_BANDGAP_FEATURE_UNRELIABLE, 708c2ecf20Sopenharmony_ci .fclock_name = "ts_fck", 718c2ecf20Sopenharmony_ci .div_ck_name = "ts_fck", 728c2ecf20Sopenharmony_ci .conv_table = omap34xx_adc_to_temp, 738c2ecf20Sopenharmony_ci .adc_start_val = 0, 748c2ecf20Sopenharmony_ci .adc_end_val = 127, 758c2ecf20Sopenharmony_ci .expose_sensor = ti_thermal_expose_sensor, 768c2ecf20Sopenharmony_ci .remove_sensor = ti_thermal_remove_sensor, 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ci .sensors = { 798c2ecf20Sopenharmony_ci { 808c2ecf20Sopenharmony_ci .registers = &omap34xx_mpu_temp_sensor_registers, 818c2ecf20Sopenharmony_ci .ts_data = &omap34xx_mpu_temp_sensor_data, 828c2ecf20Sopenharmony_ci .domain = "cpu", 838c2ecf20Sopenharmony_ci .slope_pcb = 0, 848c2ecf20Sopenharmony_ci .constant_pcb = 20000, 858c2ecf20Sopenharmony_ci .register_cooling = NULL, 868c2ecf20Sopenharmony_ci .unregister_cooling = NULL, 878c2ecf20Sopenharmony_ci }, 888c2ecf20Sopenharmony_ci }, 898c2ecf20Sopenharmony_ci .sensor_count = 1, 908c2ecf20Sopenharmony_ci}; 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci/* 938c2ecf20Sopenharmony_ci * OMAP36XX has one instance of thermal sensor for MPU 948c2ecf20Sopenharmony_ci * need to describe the individual bit fields 958c2ecf20Sopenharmony_ci */ 968c2ecf20Sopenharmony_cistatic struct temp_sensor_registers 978c2ecf20Sopenharmony_ciomap36xx_mpu_temp_sensor_registers = { 988c2ecf20Sopenharmony_ci .temp_sensor_ctrl = 0, 998c2ecf20Sopenharmony_ci .bgap_soc_mask = BIT(9), 1008c2ecf20Sopenharmony_ci .bgap_eocz_mask = BIT(8), 1018c2ecf20Sopenharmony_ci .bgap_dtemp_mask = 0xFF, 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ci .bgap_mode_ctrl = 0, 1048c2ecf20Sopenharmony_ci .mode_ctrl_mask = BIT(10), 1058c2ecf20Sopenharmony_ci}; 1068c2ecf20Sopenharmony_ci 1078c2ecf20Sopenharmony_ci/* Thresholds and limits for OMAP36XX MPU temperature sensor */ 1088c2ecf20Sopenharmony_cistatic struct temp_sensor_data omap36xx_mpu_temp_sensor_data = { 1098c2ecf20Sopenharmony_ci .min_freq = 32768, 1108c2ecf20Sopenharmony_ci .max_freq = 32768, 1118c2ecf20Sopenharmony_ci}; 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_ci/* 1148c2ecf20Sopenharmony_ci * Temperature values in milli degree celsius 1158c2ecf20Sopenharmony_ci */ 1168c2ecf20Sopenharmony_cistatic const int 1178c2ecf20Sopenharmony_ciomap36xx_adc_to_temp[128] = { 1188c2ecf20Sopenharmony_ci -40000, -40000, -40000, -40000, -40000, -40000, -40000, -40000, 1198c2ecf20Sopenharmony_ci -40000, -40000, -40000, -40000, -40000, -38000, -35000, -34000, 1208c2ecf20Sopenharmony_ci -32000, -30000, -28000, -26000, -24000, -22000, -20000, -18500, 1218c2ecf20Sopenharmony_ci -17000, -15000, -13500, -12000, -10000, -8000, -6500, -5000, -3500, 1228c2ecf20Sopenharmony_ci -1500, 0, 2000, 3500, 5000, 6500, 8500, 10000, 12000, 13500, 1238c2ecf20Sopenharmony_ci 15000, 17000, 19000, 21000, 23000, 25000, 27000, 28500, 30000, 1248c2ecf20Sopenharmony_ci 32000, 33500, 35000, 37000, 38500, 40000, 42000, 43500, 45000, 1258c2ecf20Sopenharmony_ci 47000, 48500, 50000, 52000, 53500, 55000, 57000, 58500, 60000, 1268c2ecf20Sopenharmony_ci 62000, 64000, 66000, 68000, 70000, 71500, 73500, 75000, 77000, 1278c2ecf20Sopenharmony_ci 78500, 80000, 82000, 83500, 85000, 87000, 88500, 90000, 92000, 1288c2ecf20Sopenharmony_ci 93500, 95000, 97000, 98500, 100000, 102000, 103500, 105000, 107000, 1298c2ecf20Sopenharmony_ci 109000, 111000, 113000, 115000, 117000, 118500, 120000, 122000, 1308c2ecf20Sopenharmony_ci 123500, 125000, 125000, 125000, 125000, 125000, 125000, 125000, 1318c2ecf20Sopenharmony_ci 125000, 125000, 125000, 125000, 125000, 125000, 125000, 125000, 1328c2ecf20Sopenharmony_ci 125000, 125000, 125000, 125000, 125000, 125000, 125000 1338c2ecf20Sopenharmony_ci}; 1348c2ecf20Sopenharmony_ci 1358c2ecf20Sopenharmony_ci/* OMAP36XX data */ 1368c2ecf20Sopenharmony_ciconst struct ti_bandgap_data omap36xx_data = { 1378c2ecf20Sopenharmony_ci .features = TI_BANDGAP_FEATURE_CLK_CTRL | TI_BANDGAP_FEATURE_UNRELIABLE, 1388c2ecf20Sopenharmony_ci .fclock_name = "ts_fck", 1398c2ecf20Sopenharmony_ci .div_ck_name = "ts_fck", 1408c2ecf20Sopenharmony_ci .conv_table = omap36xx_adc_to_temp, 1418c2ecf20Sopenharmony_ci .adc_start_val = 0, 1428c2ecf20Sopenharmony_ci .adc_end_val = 127, 1438c2ecf20Sopenharmony_ci .expose_sensor = ti_thermal_expose_sensor, 1448c2ecf20Sopenharmony_ci .remove_sensor = ti_thermal_remove_sensor, 1458c2ecf20Sopenharmony_ci 1468c2ecf20Sopenharmony_ci .sensors = { 1478c2ecf20Sopenharmony_ci { 1488c2ecf20Sopenharmony_ci .registers = &omap36xx_mpu_temp_sensor_registers, 1498c2ecf20Sopenharmony_ci .ts_data = &omap36xx_mpu_temp_sensor_data, 1508c2ecf20Sopenharmony_ci .domain = "cpu", 1518c2ecf20Sopenharmony_ci .slope_pcb = 0, 1528c2ecf20Sopenharmony_ci .constant_pcb = 20000, 1538c2ecf20Sopenharmony_ci .register_cooling = NULL, 1548c2ecf20Sopenharmony_ci .unregister_cooling = NULL, 1558c2ecf20Sopenharmony_ci }, 1568c2ecf20Sopenharmony_ci }, 1578c2ecf20Sopenharmony_ci .sensor_count = 1, 1588c2ecf20Sopenharmony_ci}; 159