Commit 1368f99346b1a6c566095bcb1df662cdbdb129b3

Authored by Adrian Alonso
Committed by Stefano Babic
1 parent 15c52b3ddd

thermal: imx_thermal: rework driver to be reused

Rework imx_thermal driver to be used across i.MX
processor that support thermal sensor

Signed-off-by: Adrian Alonso <aalonso@freescale.com>
Signed-off-by: Peng Fan <Peng.Fan@freescale.com>

Showing 13 changed files with 27 additions and 25 deletions Side-by-side Diff

arch/arm/cpu/armv7/mx6/soc.c
... ... @@ -38,7 +38,7 @@
38 38 u32 fpga_rev;
39 39 };
40 40  
41   -#if defined(CONFIG_IMX6_THERMAL)
  41 +#if defined(CONFIG_IMX_THERMAL)
42 42 static const struct imx_thermal_plat imx6_thermal_plat = {
43 43 .regs = (void *)ANATOP_BASE_ADDR,
44 44 .fuse_bank = 1,
arch/arm/imx-common/cpu.c
... ... @@ -154,14 +154,12 @@
154 154 u32 cpurev;
155 155 __maybe_unused u32 max_freq;
156 156  
157   -#if defined(CONFIG_MX6) && defined(CONFIG_IMX6_THERMAL)
  157 + cpurev = get_cpu_rev();
  158 +
  159 +#if defined(CONFIG_IMX_THERMAL)
158 160 struct udevice *thermal_dev;
159 161 int cpu_tmp, minc, maxc, ret;
160   -#endif
161 162  
162   - cpurev = get_cpu_rev();
163   -
164   -#if defined(CONFIG_MX6)
165 163 printf("CPU: Freescale i.MX%s rev%d.%d",
166 164 get_imx_type((cpurev & 0xFF000) >> 12),
167 165 (cpurev & 0x000F0) >> 4,
... ... @@ -181,7 +179,7 @@
181 179 mxc_get_clock(MXC_ARM_CLK) / 1000000);
182 180 #endif
183 181  
184   -#if defined(CONFIG_MX6) && defined(CONFIG_IMX6_THERMAL)
  182 +#if defined(CONFIG_IMX_THERMAL)
185 183 puts("CPU: ");
186 184 switch (get_cpu_temp_grade(&minc, &maxc)) {
187 185 case TEMP_AUTOMOTIVE:
drivers/thermal/Makefile
... ... @@ -6,5 +6,5 @@
6 6 #
7 7  
8 8 obj-$(CONFIG_DM_THERMAL) += thermal-uclass.o
9   -obj-$(CONFIG_IMX6_THERMAL) += imx_thermal.o
  9 +obj-$(CONFIG_IMX_THERMAL) += imx_thermal.o
drivers/thermal/imx_thermal.c
... ... @@ -41,7 +41,7 @@
41 41 int maxc;
42 42 };
43 43  
44   -static int read_cpu_temperature(struct udevice *dev)
  44 +static int read_cpu_temperature_mx6(struct udevice *dev)
45 45 {
46 46 int temperature;
47 47 unsigned int reg, n_meas;
48 48  
... ... @@ -129,13 +129,15 @@
129 129 struct thermal_data *priv = dev_get_priv(dev);
130 130 int cpu_tmp = 0;
131 131  
132   - cpu_tmp = read_cpu_temperature(dev);
  132 + if (is_soc_type(MXC_SOC_MX6))
  133 + cpu_tmp = read_cpu_temperature_mx6(dev);
133 134 while (cpu_tmp >= priv->critical) {
134 135 printf("CPU Temperature (%dC) too close to max (%dC)",
135 136 cpu_tmp, priv->maxc);
136 137 puts(" waiting...\n");
137 138 udelay(5000000);
138   - cpu_tmp = read_cpu_temperature(dev);
  139 + if (is_soc_type(MXC_SOC_MX6))
  140 + cpu_tmp = read_cpu_temperature_mx6(dev);
139 141 }
140 142  
141 143 *temp = cpu_tmp;
... ... @@ -157,10 +159,12 @@
157 159 /* Read Temperature calibration data fuse */
158 160 fuse_read(pdata->fuse_bank, pdata->fuse_word, &fuse);
159 161  
160   - /* Check for valid fuse */
161   - if (fuse == 0 || fuse == ~0) {
162   - printf("CPU: Thermal invalid data, fuse: 0x%x\n", fuse);
163   - return -EPERM;
  162 + if (is_soc_type(MXC_SOC_MX6)) {
  163 + /* Check for valid fuse */
  164 + if (fuse == 0 || fuse == ~0) {
  165 + printf("CPU: Thermal invalid data, fuse: 0x%x\n", fuse);
  166 + return -EPERM;
  167 + }
164 168 }
165 169  
166 170 /* set critical cooling temp */
include/configs/cgtqmx6eval.h
... ... @@ -33,10 +33,10 @@
33 33 #define CONFIG_CMD_BMODE
34 34  
35 35 /* Thermal support */
36   -#define CONFIG_IMX6_THERMAL
  36 +#define CONFIG_IMX_THERMAL
37 37  
38 38 #define CONFIG_CMD_FUSE
39   -#if defined(CONFIG_CMD_FUSE) || defined(CONFIG_IMX6_THERMAL)
  39 +#if defined(CONFIG_CMD_FUSE) || defined(CONFIG_IMX_THERMAL)
40 40 #define CONFIG_MXC_OCOTP
41 41 #endif
42 42  
include/configs/embestmx6boards.h
... ... @@ -19,7 +19,7 @@
19 19  
20 20 #define PHYS_SDRAM_SIZE (1u * 1024 * 1024 * 1024)
21 21  
22   -#define CONFIG_IMX6_THERMAL
  22 +#define CONFIG_IMX_THERMAL
23 23  
24 24 /* Size of malloc() pool */
25 25 #define CONFIG_SYS_MALLOC_LEN (10 * SZ_1M)
include/configs/gw_ventana.h
... ... @@ -57,7 +57,7 @@
57 57 #define CONFIG_CMD_GPIO
58 58  
59 59 /* Thermal */
60   -#define CONFIG_IMX6_THERMAL
  60 +#define CONFIG_IMX_THERMAL
61 61  
62 62 /* Serial */
63 63 #define CONFIG_MXC_UART
include/configs/mx6cuboxi.h
... ... @@ -14,7 +14,7 @@
14 14 #define CONFIG_SPL_MMC_SUPPORT
15 15 #include "imx6_spl.h"
16 16  
17   -#define CONFIG_IMX6_THERMAL
  17 +#define CONFIG_IMX_THERMAL
18 18  
19 19 #define CONFIG_SYS_MALLOC_LEN (10 * SZ_1M)
20 20 #define CONFIG_BOARD_EARLY_INIT_F
include/configs/mx6sabre_common.h
... ... @@ -11,7 +11,7 @@
11 11  
12 12 #include "mx6_common.h"
13 13  
14   -#define CONFIG_IMX6_THERMAL
  14 +#define CONFIG_IMX_THERMAL
15 15  
16 16 /* Size of malloc() pool */
17 17 #define CONFIG_SYS_MALLOC_LEN (10 * SZ_1M)
include/configs/mx6slevk.h
... ... @@ -197,7 +197,7 @@
197 197 #define CONFIG_SYS_MMC_ENV_DEV 1 /* SDHC2*/
198 198 #endif
199 199  
200   -#define CONFIG_IMX6_THERMAL
  200 +#define CONFIG_IMX_THERMAL
201 201  
202 202 #endif /* __CONFIG_H */
include/configs/mx6sxsabresd.h
... ... @@ -177,7 +177,7 @@
177 177 #define CONFIG_PCIE_IMX_POWER_GPIO IMX_GPIO_NR(2, 1)
178 178 #endif
179 179  
180   -#define CONFIG_IMX6_THERMAL
  180 +#define CONFIG_IMX_THERMAL
181 181  
182 182 #define CONFIG_CMD_TIME
183 183  
include/configs/mx6ul_14x14_evk.h
... ... @@ -241,7 +241,7 @@
241 241 #define CONFIG_FEC_DMA_MINALIGN 64
242 242 #endif
243 243  
244   -#define CONFIG_IMX6_THERMAL
  244 +#define CONFIG_IMX_THERMAL
245 245  
246 246 #endif
include/configs/tbs2910.h
... ... @@ -20,7 +20,7 @@
20 20  
21 21 #define CONFIG_SYS_HZ 1000
22 22  
23   -#define CONFIG_IMX6_THERMAL
  23 +#define CONFIG_IMX_THERMAL
24 24  
25 25 /* Physical Memory Map */
26 26 #define CONFIG_NR_DRAM_BANKS 1