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