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>
This commit is contained in:
parent
15c52b3ddd
commit
1368f99346
|
@ -38,7 +38,7 @@ struct scu_regs {
|
||||||
u32 fpga_rev;
|
u32 fpga_rev;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if defined(CONFIG_IMX6_THERMAL)
|
#if defined(CONFIG_IMX_THERMAL)
|
||||||
static const struct imx_thermal_plat imx6_thermal_plat = {
|
static const struct imx_thermal_plat imx6_thermal_plat = {
|
||||||
.regs = (void *)ANATOP_BASE_ADDR,
|
.regs = (void *)ANATOP_BASE_ADDR,
|
||||||
.fuse_bank = 1,
|
.fuse_bank = 1,
|
||||||
|
|
|
@ -154,14 +154,12 @@ int print_cpuinfo(void)
|
||||||
u32 cpurev;
|
u32 cpurev;
|
||||||
__maybe_unused u32 max_freq;
|
__maybe_unused u32 max_freq;
|
||||||
|
|
||||||
#if defined(CONFIG_MX6) && defined(CONFIG_IMX6_THERMAL)
|
|
||||||
struct udevice *thermal_dev;
|
|
||||||
int cpu_tmp, minc, maxc, ret;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
cpurev = get_cpu_rev();
|
cpurev = get_cpu_rev();
|
||||||
|
|
||||||
#if defined(CONFIG_MX6)
|
#if defined(CONFIG_IMX_THERMAL)
|
||||||
|
struct udevice *thermal_dev;
|
||||||
|
int cpu_tmp, minc, maxc, ret;
|
||||||
|
|
||||||
printf("CPU: Freescale i.MX%s rev%d.%d",
|
printf("CPU: Freescale i.MX%s rev%d.%d",
|
||||||
get_imx_type((cpurev & 0xFF000) >> 12),
|
get_imx_type((cpurev & 0xFF000) >> 12),
|
||||||
(cpurev & 0x000F0) >> 4,
|
(cpurev & 0x000F0) >> 4,
|
||||||
|
@ -181,7 +179,7 @@ int print_cpuinfo(void)
|
||||||
mxc_get_clock(MXC_ARM_CLK) / 1000000);
|
mxc_get_clock(MXC_ARM_CLK) / 1000000);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_MX6) && defined(CONFIG_IMX6_THERMAL)
|
#if defined(CONFIG_IMX_THERMAL)
|
||||||
puts("CPU: ");
|
puts("CPU: ");
|
||||||
switch (get_cpu_temp_grade(&minc, &maxc)) {
|
switch (get_cpu_temp_grade(&minc, &maxc)) {
|
||||||
case TEMP_AUTOMOTIVE:
|
case TEMP_AUTOMOTIVE:
|
||||||
|
|
|
@ -6,4 +6,4 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
obj-$(CONFIG_DM_THERMAL) += thermal-uclass.o
|
obj-$(CONFIG_DM_THERMAL) += thermal-uclass.o
|
||||||
obj-$(CONFIG_IMX6_THERMAL) += imx_thermal.o
|
obj-$(CONFIG_IMX_THERMAL) += imx_thermal.o
|
||||||
|
|
|
@ -41,7 +41,7 @@ struct thermal_data {
|
||||||
int maxc;
|
int maxc;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int read_cpu_temperature(struct udevice *dev)
|
static int read_cpu_temperature_mx6(struct udevice *dev)
|
||||||
{
|
{
|
||||||
int temperature;
|
int temperature;
|
||||||
unsigned int reg, n_meas;
|
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);
|
struct thermal_data *priv = dev_get_priv(dev);
|
||||||
int cpu_tmp = 0;
|
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) {
|
while (cpu_tmp >= priv->critical) {
|
||||||
printf("CPU Temperature (%dC) too close to max (%dC)",
|
printf("CPU Temperature (%dC) too close to max (%dC)",
|
||||||
cpu_tmp, priv->maxc);
|
cpu_tmp, priv->maxc);
|
||||||
puts(" waiting...\n");
|
puts(" waiting...\n");
|
||||||
udelay(5000000);
|
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;
|
*temp = cpu_tmp;
|
||||||
|
@ -157,11 +159,13 @@ static int imx_thermal_probe(struct udevice *dev)
|
||||||
/* Read Temperature calibration data fuse */
|
/* Read Temperature calibration data fuse */
|
||||||
fuse_read(pdata->fuse_bank, pdata->fuse_word, &fuse);
|
fuse_read(pdata->fuse_bank, pdata->fuse_word, &fuse);
|
||||||
|
|
||||||
|
if (is_soc_type(MXC_SOC_MX6)) {
|
||||||
/* Check for valid fuse */
|
/* Check for valid fuse */
|
||||||
if (fuse == 0 || fuse == ~0) {
|
if (fuse == 0 || fuse == ~0) {
|
||||||
printf("CPU: Thermal invalid data, fuse: 0x%x\n", fuse);
|
printf("CPU: Thermal invalid data, fuse: 0x%x\n", fuse);
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* set critical cooling temp */
|
/* set critical cooling temp */
|
||||||
get_cpu_temp_grade(&priv->minc, &priv->maxc);
|
get_cpu_temp_grade(&priv->minc, &priv->maxc);
|
||||||
|
|
|
@ -33,10 +33,10 @@
|
||||||
#define CONFIG_CMD_BMODE
|
#define CONFIG_CMD_BMODE
|
||||||
|
|
||||||
/* Thermal support */
|
/* Thermal support */
|
||||||
#define CONFIG_IMX6_THERMAL
|
#define CONFIG_IMX_THERMAL
|
||||||
|
|
||||||
#define CONFIG_CMD_FUSE
|
#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
|
#define CONFIG_MXC_OCOTP
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
#define PHYS_SDRAM_SIZE (1u * 1024 * 1024 * 1024)
|
#define PHYS_SDRAM_SIZE (1u * 1024 * 1024 * 1024)
|
||||||
|
|
||||||
#define CONFIG_IMX6_THERMAL
|
#define CONFIG_IMX_THERMAL
|
||||||
|
|
||||||
/* Size of malloc() pool */
|
/* Size of malloc() pool */
|
||||||
#define CONFIG_SYS_MALLOC_LEN (10 * SZ_1M)
|
#define CONFIG_SYS_MALLOC_LEN (10 * SZ_1M)
|
||||||
|
|
|
@ -57,7 +57,7 @@
|
||||||
#define CONFIG_CMD_GPIO
|
#define CONFIG_CMD_GPIO
|
||||||
|
|
||||||
/* Thermal */
|
/* Thermal */
|
||||||
#define CONFIG_IMX6_THERMAL
|
#define CONFIG_IMX_THERMAL
|
||||||
|
|
||||||
/* Serial */
|
/* Serial */
|
||||||
#define CONFIG_MXC_UART
|
#define CONFIG_MXC_UART
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
#define CONFIG_SPL_MMC_SUPPORT
|
#define CONFIG_SPL_MMC_SUPPORT
|
||||||
#include "imx6_spl.h"
|
#include "imx6_spl.h"
|
||||||
|
|
||||||
#define CONFIG_IMX6_THERMAL
|
#define CONFIG_IMX_THERMAL
|
||||||
|
|
||||||
#define CONFIG_SYS_MALLOC_LEN (10 * SZ_1M)
|
#define CONFIG_SYS_MALLOC_LEN (10 * SZ_1M)
|
||||||
#define CONFIG_BOARD_EARLY_INIT_F
|
#define CONFIG_BOARD_EARLY_INIT_F
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
#include "mx6_common.h"
|
#include "mx6_common.h"
|
||||||
|
|
||||||
#define CONFIG_IMX6_THERMAL
|
#define CONFIG_IMX_THERMAL
|
||||||
|
|
||||||
/* Size of malloc() pool */
|
/* Size of malloc() pool */
|
||||||
#define CONFIG_SYS_MALLOC_LEN (10 * SZ_1M)
|
#define CONFIG_SYS_MALLOC_LEN (10 * SZ_1M)
|
||||||
|
|
|
@ -197,6 +197,6 @@
|
||||||
#define CONFIG_SYS_MMC_ENV_DEV 1 /* SDHC2*/
|
#define CONFIG_SYS_MMC_ENV_DEV 1 /* SDHC2*/
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define CONFIG_IMX6_THERMAL
|
#define CONFIG_IMX_THERMAL
|
||||||
|
|
||||||
#endif /* __CONFIG_H */
|
#endif /* __CONFIG_H */
|
||||||
|
|
|
@ -177,7 +177,7 @@
|
||||||
#define CONFIG_PCIE_IMX_POWER_GPIO IMX_GPIO_NR(2, 1)
|
#define CONFIG_PCIE_IMX_POWER_GPIO IMX_GPIO_NR(2, 1)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define CONFIG_IMX6_THERMAL
|
#define CONFIG_IMX_THERMAL
|
||||||
|
|
||||||
#define CONFIG_CMD_TIME
|
#define CONFIG_CMD_TIME
|
||||||
|
|
||||||
|
|
|
@ -241,6 +241,6 @@
|
||||||
#define CONFIG_FEC_DMA_MINALIGN 64
|
#define CONFIG_FEC_DMA_MINALIGN 64
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define CONFIG_IMX6_THERMAL
|
#define CONFIG_IMX_THERMAL
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
#define CONFIG_SYS_HZ 1000
|
#define CONFIG_SYS_HZ 1000
|
||||||
|
|
||||||
#define CONFIG_IMX6_THERMAL
|
#define CONFIG_IMX_THERMAL
|
||||||
|
|
||||||
/* Physical Memory Map */
|
/* Physical Memory Map */
|
||||||
#define CONFIG_NR_DRAM_BANKS 1
|
#define CONFIG_NR_DRAM_BANKS 1
|
||||||
|
|
Loading…
Reference in New Issue