[U-Boot] [PATCH v2 02/13] thermal: imx_thermal: rework driver to be reused
Adrian Alonso
aalonso at freescale.com
Wed Sep 2 20:54:13 CEST 2015
Rework imx_thermal driver to be used across i.MX
processor that support thermal sensor
Signed-off-by: Adrian Alonso <aalonso at freescale.com>
Signed-off-by: Peng Fan <Peng.Fan at freescale.com>
---
Changes for V2:
Rename read_cpu_temperature to read_cpu_temperature_mx6 use is_soc_type macro
to identify iMX SoC family to call the correspondind read_cpu_temperature
function per iMX SoC family.
Changes for V3:
Rework path for git://git.denx.de/u-boot-imx.git (master)
Changes for V4: Rework for thermal support for TBS2910 MatrixARM board
arch/arm/cpu/armv7/mx6/soc.c | 2 +-
arch/arm/imx-common/cpu.c | 10 ++++------
drivers/thermal/Makefile | 2 +-
drivers/thermal/imx_thermal.c | 18 +++++++++++-------
include/configs/cgtqmx6eval.h | 4 ++--
include/configs/embestmx6boards.h | 2 +-
include/configs/gw_ventana.h | 2 +-
include/configs/mx6cuboxi.h | 2 +-
include/configs/mx6sabre_common.h | 2 +-
include/configs/mx6slevk.h | 2 +-
include/configs/mx6sxsabresd.h | 2 +-
include/configs/mx6ul_14x14_evk.h | 2 +-
include/configs/tbs2910.h | 2 +-
13 files changed, 27 insertions(+), 25 deletions(-)
diff --git a/arch/arm/cpu/armv7/mx6/soc.c b/arch/arm/cpu/armv7/mx6/soc.c
index 8ad8da8..5110112 100644
--- a/arch/arm/cpu/armv7/mx6/soc.c
+++ b/arch/arm/cpu/armv7/mx6/soc.c
@@ -38,7 +38,7 @@ struct scu_regs {
u32 fpga_rev;
};
-#if defined(CONFIG_IMX6_THERMAL)
+#if defined(CONFIG_IMX_THERMAL)
static const struct imx_thermal_plat imx6_thermal_plat = {
.regs = (void *)ANATOP_BASE_ADDR,
.fuse_bank = 1,
diff --git a/arch/arm/imx-common/cpu.c b/arch/arm/imx-common/cpu.c
index e27546c..38cd0c8 100644
--- a/arch/arm/imx-common/cpu.c
+++ b/arch/arm/imx-common/cpu.c
@@ -154,14 +154,12 @@ int print_cpuinfo(void)
u32 cpurev;
__maybe_unused u32 max_freq;
-#if defined(CONFIG_MX6) && defined(CONFIG_IMX6_THERMAL)
+ cpurev = get_cpu_rev();
+
+#if defined(CONFIG_IMX_THERMAL)
struct udevice *thermal_dev;
int cpu_tmp, minc, maxc, ret;
-#endif
- cpurev = get_cpu_rev();
-
-#if defined(CONFIG_MX6)
printf("CPU: Freescale i.MX%s rev%d.%d",
get_imx_type((cpurev & 0xFF000) >> 12),
(cpurev & 0x000F0) >> 4,
@@ -181,7 +179,7 @@ int print_cpuinfo(void)
mxc_get_clock(MXC_ARM_CLK) / 1000000);
#endif
-#if defined(CONFIG_MX6) && defined(CONFIG_IMX6_THERMAL)
+#if defined(CONFIG_IMX_THERMAL)
puts("CPU: ");
switch (get_cpu_temp_grade(&minc, &maxc)) {
case TEMP_AUTOMOTIVE:
diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile
index 6d4cacd..d768f5e 100644
--- a/drivers/thermal/Makefile
+++ b/drivers/thermal/Makefile
@@ -6,4 +6,4 @@
#
obj-$(CONFIG_DM_THERMAL) += thermal-uclass.o
-obj-$(CONFIG_IMX6_THERMAL) += imx_thermal.o
+obj-$(CONFIG_IMX_THERMAL) += imx_thermal.o
diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
index 3c6c967..d90874e 100644
--- a/drivers/thermal/imx_thermal.c
+++ b/drivers/thermal/imx_thermal.c
@@ -41,7 +41,7 @@ struct thermal_data {
int maxc;
};
-static int read_cpu_temperature(struct udevice *dev)
+static int read_cpu_temperature_mx6(struct udevice *dev)
{
int temperature;
unsigned int reg, n_meas;
@@ -129,13 +129,15 @@ int imx_thermal_get_temp(struct udevice *dev, int *temp)
struct thermal_data *priv = dev_get_priv(dev);
int cpu_tmp = 0;
- cpu_tmp = read_cpu_temperature(dev);
+ if (is_soc_type(MXC_SOC_MX6))
+ cpu_tmp = read_cpu_temperature_mx6(dev);
while (cpu_tmp >= priv->critical) {
printf("CPU Temperature (%dC) too close to max (%dC)",
cpu_tmp, priv->maxc);
puts(" waiting...\n");
udelay(5000000);
- cpu_tmp = read_cpu_temperature(dev);
+ if (is_soc_type(MXC_SOC_MX6))
+ cpu_tmp = read_cpu_temperature_mx6(dev);
}
*temp = cpu_tmp;
@@ -157,10 +159,12 @@ static int imx_thermal_probe(struct udevice *dev)
/* Read Temperature calibration data fuse */
fuse_read(pdata->fuse_bank, pdata->fuse_word, &fuse);
- /* Check for valid fuse */
- if (fuse == 0 || fuse == ~0) {
- printf("CPU: Thermal invalid data, fuse: 0x%x\n", fuse);
- return -EPERM;
+ if (is_soc_type(MXC_SOC_MX6)) {
+ /* Check for valid fuse */
+ if (fuse == 0 || fuse == ~0) {
+ printf("CPU: Thermal invalid data, fuse: 0x%x\n", fuse);
+ return -EPERM;
+ }
}
/* set critical cooling temp */
diff --git a/include/configs/cgtqmx6eval.h b/include/configs/cgtqmx6eval.h
index 92930c8..55a0664 100644
--- a/include/configs/cgtqmx6eval.h
+++ b/include/configs/cgtqmx6eval.h
@@ -33,10 +33,10 @@
#define CONFIG_CMD_BMODE
/* Thermal support */
-#define CONFIG_IMX6_THERMAL
+#define CONFIG_IMX_THERMAL
#define CONFIG_CMD_FUSE
-#if defined(CONFIG_CMD_FUSE) || defined(CONFIG_IMX6_THERMAL)
+#if defined(CONFIG_CMD_FUSE) || defined(CONFIG_IMX_THERMAL)
#define CONFIG_MXC_OCOTP
#endif
diff --git a/include/configs/embestmx6boards.h b/include/configs/embestmx6boards.h
index 12744a6..58cee96 100644
--- a/include/configs/embestmx6boards.h
+++ b/include/configs/embestmx6boards.h
@@ -19,7 +19,7 @@
#define PHYS_SDRAM_SIZE (1u * 1024 * 1024 * 1024)
-#define CONFIG_IMX6_THERMAL
+#define CONFIG_IMX_THERMAL
/* Size of malloc() pool */
#define CONFIG_SYS_MALLOC_LEN (10 * SZ_1M)
diff --git a/include/configs/gw_ventana.h b/include/configs/gw_ventana.h
index 8b9d922..231bea7 100644
--- a/include/configs/gw_ventana.h
+++ b/include/configs/gw_ventana.h
@@ -57,7 +57,7 @@
#define CONFIG_CMD_GPIO
/* Thermal */
-#define CONFIG_IMX6_THERMAL
+#define CONFIG_IMX_THERMAL
/* Serial */
#define CONFIG_MXC_UART
diff --git a/include/configs/mx6cuboxi.h b/include/configs/mx6cuboxi.h
index 634a09f..6e89dd1 100644
--- a/include/configs/mx6cuboxi.h
+++ b/include/configs/mx6cuboxi.h
@@ -14,7 +14,7 @@
#define CONFIG_SPL_MMC_SUPPORT
#include "imx6_spl.h"
-#define CONFIG_IMX6_THERMAL
+#define CONFIG_IMX_THERMAL
#define CONFIG_SYS_MALLOC_LEN (10 * SZ_1M)
#define CONFIG_BOARD_EARLY_INIT_F
diff --git a/include/configs/mx6sabre_common.h b/include/configs/mx6sabre_common.h
index 6a57841..98eb042 100644
--- a/include/configs/mx6sabre_common.h
+++ b/include/configs/mx6sabre_common.h
@@ -11,7 +11,7 @@
#include "mx6_common.h"
-#define CONFIG_IMX6_THERMAL
+#define CONFIG_IMX_THERMAL
/* Size of malloc() pool */
#define CONFIG_SYS_MALLOC_LEN (10 * SZ_1M)
diff --git a/include/configs/mx6slevk.h b/include/configs/mx6slevk.h
index 04d53a7..0a641c2 100644
--- a/include/configs/mx6slevk.h
+++ b/include/configs/mx6slevk.h
@@ -197,6 +197,6 @@
#define CONFIG_SYS_MMC_ENV_DEV 1 /* SDHC2*/
#endif
-#define CONFIG_IMX6_THERMAL
+#define CONFIG_IMX_THERMAL
#endif /* __CONFIG_H */
diff --git a/include/configs/mx6sxsabresd.h b/include/configs/mx6sxsabresd.h
index 74d04a0..f30c148 100644
--- a/include/configs/mx6sxsabresd.h
+++ b/include/configs/mx6sxsabresd.h
@@ -177,7 +177,7 @@
#define CONFIG_PCIE_IMX_POWER_GPIO IMX_GPIO_NR(2, 1)
#endif
-#define CONFIG_IMX6_THERMAL
+#define CONFIG_IMX_THERMAL
#define CONFIG_CMD_TIME
diff --git a/include/configs/mx6ul_14x14_evk.h b/include/configs/mx6ul_14x14_evk.h
index 4a2280b..d8a4f16 100644
--- a/include/configs/mx6ul_14x14_evk.h
+++ b/include/configs/mx6ul_14x14_evk.h
@@ -241,6 +241,6 @@
#define CONFIG_FEC_DMA_MINALIGN 64
#endif
-#define CONFIG_IMX6_THERMAL
+#define CONFIG_IMX_THERMAL
#endif
diff --git a/include/configs/tbs2910.h b/include/configs/tbs2910.h
index 66cb274..70b4403 100644
--- a/include/configs/tbs2910.h
+++ b/include/configs/tbs2910.h
@@ -20,7 +20,7 @@
#define CONFIG_SYS_HZ 1000
-#define CONFIG_IMX6_THERMAL
+#define CONFIG_IMX_THERMAL
/* Physical Memory Map */
#define CONFIG_NR_DRAM_BANKS 1
--
2.1.4
More information about the U-Boot
mailing list