xref: /linux/drivers/thermal/ti-soc-thermal/omap3-thermal-data.c (revision 75bf465f0bc33e9b776a46d6a1b9b990f5fb7c37)
1*9c92ab61SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
29c5c87e5SPavel Machek /*
39c5c87e5SPavel Machek  * OMAP3 thermal driver.
49c5c87e5SPavel Machek  *
59c5c87e5SPavel Machek  * Copyright (C) 2011-2012 Texas Instruments Inc.
69c5c87e5SPavel Machek  * Copyright (C) 2014 Pavel Machek <pavel@ucw.cz>
79c5c87e5SPavel Machek  *
89c5c87e5SPavel Machek  * Note
99c5c87e5SPavel Machek  * http://www.ti.com/lit/er/sprz278f/sprz278f.pdf "Advisory
109c5c87e5SPavel Machek  * 3.1.1.186 MMC OCP Clock Not Gated When Thermal Sensor Is Used"
119c5c87e5SPavel Machek  *
129c5c87e5SPavel Machek  * Also TI says:
139c5c87e5SPavel Machek  * Just be careful when you try to make thermal policy like decisions
149c5c87e5SPavel Machek  * based on this sensor. Placement of the sensor w.r.t the actual logic
159c5c87e5SPavel Machek  * generating heat has to be a factor as well. If you are just looking
169c5c87e5SPavel Machek  * for an approximation temperature (thermometerish kind), you might be
179c5c87e5SPavel Machek  * ok with this. I am not sure we'd find any TI data around this.. just a
189c5c87e5SPavel Machek  * heads up.
199c5c87e5SPavel Machek  */
209c5c87e5SPavel Machek 
219c5c87e5SPavel Machek #include "ti-thermal.h"
229c5c87e5SPavel Machek #include "ti-bandgap.h"
239c5c87e5SPavel Machek 
249c5c87e5SPavel Machek /*
259c5c87e5SPavel Machek  * OMAP34XX has one instance of thermal sensor for MPU
269c5c87e5SPavel Machek  * need to describe the individual bit fields
279c5c87e5SPavel Machek  */
289c5c87e5SPavel Machek static struct temp_sensor_registers
299c5c87e5SPavel Machek omap34xx_mpu_temp_sensor_registers = {
309c5c87e5SPavel Machek 	.temp_sensor_ctrl = 0,
319c5c87e5SPavel Machek 	.bgap_soc_mask = BIT(8),
329c5c87e5SPavel Machek 	.bgap_eocz_mask = BIT(7),
339c5c87e5SPavel Machek 	.bgap_dtemp_mask = 0x7f,
349c5c87e5SPavel Machek 
359c5c87e5SPavel Machek 	.bgap_mode_ctrl = 0,
369c5c87e5SPavel Machek 	.mode_ctrl_mask = BIT(9),
379c5c87e5SPavel Machek };
389c5c87e5SPavel Machek 
399c5c87e5SPavel Machek /* Thresholds and limits for OMAP34XX MPU temperature sensor */
409c5c87e5SPavel Machek static struct temp_sensor_data omap34xx_mpu_temp_sensor_data = {
419c5c87e5SPavel Machek 	.min_freq = 32768,
429c5c87e5SPavel Machek 	.max_freq = 32768,
439c5c87e5SPavel Machek };
449c5c87e5SPavel Machek 
459c5c87e5SPavel Machek /*
469c5c87e5SPavel Machek  * Temperature values in milli degree celsius
479c5c87e5SPavel Machek  */
489c5c87e5SPavel Machek static const int
499c5c87e5SPavel Machek omap34xx_adc_to_temp[128] = {
509c5c87e5SPavel Machek 	-40000, -40000, -40000, -40000, -40000, -39000, -38000, -36000,
519c5c87e5SPavel Machek 	-34000, -32000, -31000,	-29000, -28000, -26000, -25000, -24000,
529c5c87e5SPavel Machek 	-22000, -21000, -19000, -18000, -17000, -15000,	-14000, -12000,
539c5c87e5SPavel Machek 	-11000, -9000, -8000, -7000, -5000, -4000, -2000, -1000, 0000,
549c5c87e5SPavel Machek 	1000, 3000, 4000, 5000, 7000, 8000, 10000, 11000, 13000, 14000,
559c5c87e5SPavel Machek 	15000, 17000, 18000, 20000, 21000, 22000, 24000, 25000, 27000,
569c5c87e5SPavel Machek 	28000, 30000, 31000, 32000, 34000, 35000, 37000, 38000, 39000,
579c5c87e5SPavel Machek 	41000, 42000, 44000, 45000, 47000, 48000, 49000, 51000, 52000,
589c5c87e5SPavel Machek 	53000, 55000, 56000, 58000, 59000, 60000, 62000, 63000, 65000,
599c5c87e5SPavel Machek 	66000, 67000, 69000, 70000, 72000, 73000, 74000, 76000, 77000,
609c5c87e5SPavel Machek 	79000, 80000, 81000, 83000, 84000, 85000, 87000, 88000, 89000,
619c5c87e5SPavel Machek 	91000, 92000, 94000, 95000, 96000, 98000, 99000, 100000,
629c5c87e5SPavel Machek 	102000, 103000, 105000, 106000, 107000, 109000, 110000, 111000,
639c5c87e5SPavel Machek 	113000, 114000, 116000, 117000, 118000, 120000, 121000, 122000,
649c5c87e5SPavel Machek 	124000, 124000, 125000, 125000, 125000, 125000,	125000
659c5c87e5SPavel Machek };
669c5c87e5SPavel Machek 
679c5c87e5SPavel Machek /* OMAP34XX data */
689c5c87e5SPavel Machek const struct ti_bandgap_data omap34xx_data = {
699c5c87e5SPavel Machek 	.features = TI_BANDGAP_FEATURE_CLK_CTRL | TI_BANDGAP_FEATURE_UNRELIABLE,
709c5c87e5SPavel Machek 	.fclock_name = "ts_fck",
719c5c87e5SPavel Machek 	.div_ck_name = "ts_fck",
729c5c87e5SPavel Machek 	.conv_table = omap34xx_adc_to_temp,
739c5c87e5SPavel Machek 	.adc_start_val = 0,
749c5c87e5SPavel Machek 	.adc_end_val = 127,
759c5c87e5SPavel Machek 	.expose_sensor = ti_thermal_expose_sensor,
769c5c87e5SPavel Machek 	.remove_sensor = ti_thermal_remove_sensor,
779c5c87e5SPavel Machek 
789c5c87e5SPavel Machek 	.sensors = {
799c5c87e5SPavel Machek 		{
809c5c87e5SPavel Machek 		.registers = &omap34xx_mpu_temp_sensor_registers,
819c5c87e5SPavel Machek 		.ts_data = &omap34xx_mpu_temp_sensor_data,
829c5c87e5SPavel Machek 		.domain = "cpu",
839c5c87e5SPavel Machek 		.slope_pcb = 0,
849c5c87e5SPavel Machek 		.constant_pcb = 20000,
859c5c87e5SPavel Machek 		.register_cooling = NULL,
869c5c87e5SPavel Machek 		.unregister_cooling = NULL,
879c5c87e5SPavel Machek 		},
889c5c87e5SPavel Machek 	},
899c5c87e5SPavel Machek 	.sensor_count = 1,
909c5c87e5SPavel Machek };
91b840b6e6SEduardo Valentin 
92b840b6e6SEduardo Valentin /*
93b840b6e6SEduardo Valentin  * OMAP36XX has one instance of thermal sensor for MPU
94b840b6e6SEduardo Valentin  * need to describe the individual bit fields
95b840b6e6SEduardo Valentin  */
96b840b6e6SEduardo Valentin static struct temp_sensor_registers
97b840b6e6SEduardo Valentin omap36xx_mpu_temp_sensor_registers = {
98b840b6e6SEduardo Valentin 	.temp_sensor_ctrl = 0,
99b840b6e6SEduardo Valentin 	.bgap_soc_mask = BIT(9),
100b840b6e6SEduardo Valentin 	.bgap_eocz_mask = BIT(8),
101b840b6e6SEduardo Valentin 	.bgap_dtemp_mask = 0xFF,
102b840b6e6SEduardo Valentin 
103b840b6e6SEduardo Valentin 	.bgap_mode_ctrl = 0,
104b840b6e6SEduardo Valentin 	.mode_ctrl_mask = BIT(10),
105b840b6e6SEduardo Valentin };
106b840b6e6SEduardo Valentin 
107b840b6e6SEduardo Valentin /* Thresholds and limits for OMAP36XX MPU temperature sensor */
108b840b6e6SEduardo Valentin static struct temp_sensor_data omap36xx_mpu_temp_sensor_data = {
109b840b6e6SEduardo Valentin 	.min_freq = 32768,
110b840b6e6SEduardo Valentin 	.max_freq = 32768,
111b840b6e6SEduardo Valentin };
112b840b6e6SEduardo Valentin 
113b840b6e6SEduardo Valentin /*
114b840b6e6SEduardo Valentin  * Temperature values in milli degree celsius
115b840b6e6SEduardo Valentin  */
116b840b6e6SEduardo Valentin static const int
117b840b6e6SEduardo Valentin omap36xx_adc_to_temp[128] = {
118b840b6e6SEduardo Valentin 	-40000, -40000, -40000, -40000, -40000, -40000, -40000, -40000,
119b840b6e6SEduardo Valentin 	-40000, -40000, -40000,	-40000, -40000, -38000, -35000, -34000,
120b840b6e6SEduardo Valentin 	-32000, -30000, -28000, -26000, -24000, -22000,	-20000, -18500,
121b840b6e6SEduardo Valentin 	-17000, -15000, -13500, -12000, -10000, -8000, -6500, -5000, -3500,
122b840b6e6SEduardo Valentin 	-1500, 0, 2000, 3500, 5000, 6500, 8500, 10000, 12000, 13500,
123b840b6e6SEduardo Valentin 	15000, 17000, 19000, 21000, 23000, 25000, 27000, 28500, 30000,
124b840b6e6SEduardo Valentin 	32000, 33500, 35000, 37000, 38500, 40000, 42000, 43500, 45000,
125b840b6e6SEduardo Valentin 	47000, 48500, 50000, 52000, 53500, 55000, 57000, 58500, 60000,
126b840b6e6SEduardo Valentin 	62000, 64000, 66000, 68000, 70000, 71500, 73500, 75000, 77000,
127b840b6e6SEduardo Valentin 	78500, 80000, 82000, 83500, 85000, 87000, 88500, 90000, 92000,
128b840b6e6SEduardo Valentin 	93500, 95000, 97000, 98500, 100000, 102000, 103500, 105000, 107000,
129b840b6e6SEduardo Valentin 	109000, 111000, 113000, 115000, 117000, 118500, 120000, 122000,
130b840b6e6SEduardo Valentin 	123500, 125000, 125000, 125000, 125000, 125000, 125000, 125000,
131b840b6e6SEduardo Valentin 	125000, 125000, 125000, 125000, 125000, 125000, 125000, 125000,
132b840b6e6SEduardo Valentin 	125000, 125000, 125000, 125000, 125000, 125000,	125000
133b840b6e6SEduardo Valentin };
134b840b6e6SEduardo Valentin 
135b840b6e6SEduardo Valentin /* OMAP36XX data */
136b840b6e6SEduardo Valentin const struct ti_bandgap_data omap36xx_data = {
137b840b6e6SEduardo Valentin 	.features = TI_BANDGAP_FEATURE_CLK_CTRL | TI_BANDGAP_FEATURE_UNRELIABLE,
138b840b6e6SEduardo Valentin 	.fclock_name = "ts_fck",
139b840b6e6SEduardo Valentin 	.div_ck_name = "ts_fck",
140b840b6e6SEduardo Valentin 	.conv_table = omap36xx_adc_to_temp,
141b840b6e6SEduardo Valentin 	.adc_start_val = 0,
142b840b6e6SEduardo Valentin 	.adc_end_val = 127,
143b840b6e6SEduardo Valentin 	.expose_sensor = ti_thermal_expose_sensor,
144b840b6e6SEduardo Valentin 	.remove_sensor = ti_thermal_remove_sensor,
145b840b6e6SEduardo Valentin 
146b840b6e6SEduardo Valentin 	.sensors = {
147b840b6e6SEduardo Valentin 		{
148b840b6e6SEduardo Valentin 		.registers = &omap36xx_mpu_temp_sensor_registers,
149b840b6e6SEduardo Valentin 		.ts_data = &omap36xx_mpu_temp_sensor_data,
150b840b6e6SEduardo Valentin 		.domain = "cpu",
151b840b6e6SEduardo Valentin 		.slope_pcb = 0,
152b840b6e6SEduardo Valentin 		.constant_pcb = 20000,
153b840b6e6SEduardo Valentin 		.register_cooling = NULL,
154b840b6e6SEduardo Valentin 		.unregister_cooling = NULL,
155b840b6e6SEduardo Valentin 		},
156b840b6e6SEduardo Valentin 	},
157b840b6e6SEduardo Valentin 	.sensor_count = 1,
158b840b6e6SEduardo Valentin };
159