Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ti-soc-thermal: implement omap3 support

This adds support for OMAP3 chips to ti-soc-thermal. As requested by
TI people, it is marked unreliable and warning is printed.

Signed-off-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>

authored by

Pavel Machek and committed by
Eduardo Valentin
9c5c87e5 3225031f

+145
+7
Documentation/devicetree/bindings/thermal/ti_soc_thermal.txt
··· 10 10 11 11 Required properties: 12 12 - compatible : Should be: 13 + - "ti,omap34xx-bandgap" : for OMAP34xx bandgap 13 14 - "ti,omap4430-bandgap" : for OMAP4430 bandgap 14 15 - "ti,omap4460-bandgap" : for OMAP4460 bandgap 15 16 - "ti,omap4470-bandgap" : for OMAP4470 bandgap ··· 26 25 soc to soc, apart of depending on available features. 27 26 28 27 Example: 28 + OMAP34xx: 29 + bandgap { 30 + reg = <0x48002524 0x4>; 31 + compatible = "ti,omap34xx-bandgap"; 32 + }; 33 + 29 34 OMAP4430: 30 35 bandgap { 31 36 reg = <0x4a002260 0x4 0x4a00232C 0x4>;
+15
drivers/thermal/ti-soc-thermal/Kconfig
··· 19 19 This includes trip points definitions, extrapolation rules and 20 20 CPU cooling device bindings. 21 21 22 + config OMAP3_THERMAL 23 + bool "Texas Instruments OMAP3 thermal support" 24 + depends on TI_SOC_THERMAL 25 + depends on ARCH_OMAP3 || COMPILE_TEST 26 + help 27 + If you say yes here you get thermal support for the Texas Instruments 28 + OMAP3 SoC family. The current chips supported are: 29 + - OMAP3430 30 + 31 + OMAP3 chips normally don't need thermal management, and sensors in 32 + this generation are not accurate, nor they are very close to 33 + the important hotspots. 34 + 35 + Say 'N' here. 36 + 22 37 config OMAP4_THERMAL 23 38 bool "Texas Instruments OMAP4 thermal support" 24 39 depends on TI_SOC_THERMAL
+1
drivers/thermal/ti-soc-thermal/Makefile
··· 2 2 ti-soc-thermal-y := ti-bandgap.o 3 3 ti-soc-thermal-$(CONFIG_TI_THERMAL) += ti-thermal-common.o 4 4 ti-soc-thermal-$(CONFIG_DRA752_THERMAL) += dra752-thermal-data.o 5 + ti-soc-thermal-$(CONFIG_OMAP3_THERMAL) += omap3-thermal-data.o 5 6 ti-soc-thermal-$(CONFIG_OMAP4_THERMAL) += omap4-thermal-data.o 6 7 ti-soc-thermal-$(CONFIG_OMAP5_THERMAL) += omap5-thermal-data.o
+103
drivers/thermal/ti-soc-thermal/omap3-thermal-data.c
··· 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 + 29 + #include "ti-thermal.h" 30 + #include "ti-bandgap.h" 31 + 32 + /* 33 + * OMAP34XX has one instance of thermal sensor for MPU 34 + * need to describe the individual bit fields 35 + */ 36 + static struct temp_sensor_registers 37 + omap34xx_mpu_temp_sensor_registers = { 38 + .temp_sensor_ctrl = 0, 39 + .bgap_soc_mask = BIT(8), 40 + .bgap_eocz_mask = BIT(7), 41 + .bgap_dtemp_mask = 0x7f, 42 + 43 + .bgap_mode_ctrl = 0, 44 + .mode_ctrl_mask = BIT(9), 45 + }; 46 + 47 + /* Thresholds and limits for OMAP34XX MPU temperature sensor */ 48 + static struct temp_sensor_data omap34xx_mpu_temp_sensor_data = { 49 + .min_freq = 32768, 50 + .max_freq = 32768, 51 + .max_temp = 125000, 52 + .min_temp = -40000, 53 + .hyst_val = 5000, 54 + }; 55 + 56 + /* 57 + * Temperature values in milli degree celsius 58 + */ 59 + static const int 60 + omap34xx_adc_to_temp[128] = { 61 + -40000, -40000, -40000, -40000, -40000, -39000, -38000, -36000, 62 + -34000, -32000, -31000, -29000, -28000, -26000, -25000, -24000, 63 + -22000, -21000, -19000, -18000, -17000, -15000, -14000, -12000, 64 + -11000, -9000, -8000, -7000, -5000, -4000, -2000, -1000, 0000, 65 + 1000, 3000, 4000, 5000, 7000, 8000, 10000, 11000, 13000, 14000, 66 + 15000, 17000, 18000, 20000, 21000, 22000, 24000, 25000, 27000, 67 + 28000, 30000, 31000, 32000, 34000, 35000, 37000, 38000, 39000, 68 + 41000, 42000, 44000, 45000, 47000, 48000, 49000, 51000, 52000, 69 + 53000, 55000, 56000, 58000, 59000, 60000, 62000, 63000, 65000, 70 + 66000, 67000, 69000, 70000, 72000, 73000, 74000, 76000, 77000, 71 + 79000, 80000, 81000, 83000, 84000, 85000, 87000, 88000, 89000, 72 + 91000, 92000, 94000, 95000, 96000, 98000, 99000, 100000, 73 + 102000, 103000, 105000, 106000, 107000, 109000, 110000, 111000, 74 + 113000, 114000, 116000, 117000, 118000, 120000, 121000, 122000, 75 + 124000, 124000, 125000, 125000, 125000, 125000, 125000 76 + }; 77 + 78 + /* OMAP34XX data */ 79 + const struct ti_bandgap_data omap34xx_data = { 80 + .features = TI_BANDGAP_FEATURE_CLK_CTRL | TI_BANDGAP_FEATURE_UNRELIABLE, 81 + .fclock_name = "ts_fck", 82 + .div_ck_name = "ts_fck", 83 + .conv_table = omap34xx_adc_to_temp, 84 + .adc_start_val = 0, 85 + .adc_end_val = 127, 86 + .expose_sensor = ti_thermal_expose_sensor, 87 + .remove_sensor = ti_thermal_remove_sensor, 88 + 89 + .sensors = { 90 + { 91 + .registers = &omap34xx_mpu_temp_sensor_registers, 92 + .ts_data = &omap34xx_mpu_temp_sensor_data, 93 + .domain = "cpu", 94 + .slope = 0, 95 + .constant = 20000, 96 + .slope_pcb = 0, 97 + .constant_pcb = 20000, 98 + .register_cooling = NULL, 99 + .unregister_cooling = NULL, 100 + }, 101 + }, 102 + .sensor_count = 1, 103 + };
+10
drivers/thermal/ti-soc-thermal/ti-bandgap.c
··· 1274 1274 } 1275 1275 bgp->dev = &pdev->dev; 1276 1276 1277 + if (TI_BANDGAP_HAS(bgp, UNRELIABLE)) 1278 + dev_warn(&pdev->dev, 1279 + "This OMAP thermal sensor is unreliable. You've been warned\n"); 1280 + 1277 1281 if (TI_BANDGAP_HAS(bgp, TSHUT)) { 1278 1282 ret = ti_bandgap_tshut_init(bgp, pdev); 1279 1283 if (ret) { ··· 1583 1579 #endif 1584 1580 1585 1581 static const struct of_device_id of_ti_bandgap_match[] = { 1582 + #ifdef CONFIG_OMAP3_THERMAL 1583 + { 1584 + .compatible = "ti,omap34xx-bandgap", 1585 + .data = (void *)&omap34xx_data, 1586 + }, 1587 + #endif 1586 1588 #ifdef CONFIG_OMAP4_THERMAL 1587 1589 { 1588 1590 .compatible = "ti,omap4430-bandgap",
+9
drivers/thermal/ti-soc-thermal/ti-bandgap.h
··· 322 322 * has Errata 814 323 323 * TI_BANDGAP_FEATURE_ERRATA_813 - used to workaorund when the bandgap device 324 324 * has Errata 813 325 + * TI_BANDGAP_FEATURE_UNRELIABLE - used when the sensor readings are too 326 + * inaccurate. 325 327 * TI_BANDGAP_HAS(b, f) - macro to check if a bandgap device is capable of a 326 328 * specific feature (above) or not. Return non-zero, if yes. 327 329 */ ··· 339 337 #define TI_BANDGAP_FEATURE_HISTORY_BUFFER BIT(9) 340 338 #define TI_BANDGAP_FEATURE_ERRATA_814 BIT(10) 341 339 #define TI_BANDGAP_FEATURE_ERRATA_813 BIT(11) 340 + #define TI_BANDGAP_FEATURE_UNRELIABLE BIT(12) 342 341 #define TI_BANDGAP_HAS(b, f) \ 343 342 ((b)->conf->features & TI_BANDGAP_FEATURE_ ## f) 344 343 ··· 392 389 int ti_bandgap_set_sensor_data(struct ti_bandgap *bgp, int id, void *data); 393 390 void *ti_bandgap_get_sensor_data(struct ti_bandgap *bgp, int id); 394 391 int ti_bandgap_get_trend(struct ti_bandgap *bgp, int id, int *trend); 392 + 393 + #ifdef CONFIG_OMAP3_THERMAL 394 + extern const struct ti_bandgap_data omap34xx_data; 395 + #else 396 + #define omap34xx_data NULL 397 + #endif 395 398 396 399 #ifdef CONFIG_OMAP4_THERMAL 397 400 extern const struct ti_bandgap_data omap4430_data;