thermal: imx_thermal: rework driver to be reused
Subsystems (4)
PATCH 1/1 thermal: imx_thermal: rework driver to be reused
- Rework imx_thermal driver to be used across i.MX processor that support thermal sensors
- Make read_cpu_temperature SoC dependent
--- arch/arm/cpu/armv7/mx6/soc.c | 86 +++++++++++++++++++++++- arch/arm/imx-common/cpu.c | 13 ++-- arch/arm/include/asm/arch-mx6/sys_proto.h | 2 + drivers/thermal/Makefile | 2 +- drivers/thermal/imx_thermal.c | 106 ------------------------------ 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 +- include/imx_thermal.h | 26 ++++++++ 15 files changed, 130 insertions(+), 125 deletions(-)
arch/arm/cpu/armv7/mx6/soc.c +85 -1
@@ -22,6 +22,7 @@#include <asm/arch/mxc_hdmi.h> #include <asm/arch/crm_regs.h> #include <dm.h> +#include <div64.h> #include <imx_thermal.h> enum ldo_reg {
@@ -38,7 +39,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,
@@ -171,6 +172,89 @@ u32 get_cpu_temp_grade(int *minc, int *maxc)return val; } +int read_cpu_temperature (struct udevice *dev) +{ +int temperature; +unsigned int reg, n_meas; +const struct imx_thermal_plat *pdata =dev_get_platdata (dev); +struct anatop_regs *anatop = (struct anatop_regs *)pdata->regs; +struct thermal_data *priv =dev_get_priv (dev); +u32 fuse = priv->fuse; +int t1, n1; +u32 c1, c2; +u64 temp64; + +/* +* Sensor data layout: +* [31:20] - sensor value @ 25C +* We use universal formula now and only need sensor value @ 25C +* slope = 0.4297157 - (0.0015976 * 25C fuse) +*/ + n1 = fuse >>20 ; + t1 =25 ;/* t1 always 25C */ + +/* +* Derived from linear interpolation: +* slope = 0.4297157 - (0.0015976 * 25C fuse) +* slope = (FACTOR2 - FACTOR1 * n1) / FACTOR0 +* (Nmeas - n1) / (Tmeas - t1) = slope +* We want to reduce this down to the minimum computation necessary +* for each temperature read. Also, we want Tmeas in millicelsius +* and we don't want to lose precision from integer division. So... +* Tmeas = (Nmeas - n1) / slope + t1 +* milli_Tmeas = 1000 * (Nmeas - n1) / slope + 1000 * t1 +* milli_Tmeas = -1000 * (n1 - Nmeas) / slope + 1000 * t1 +* Let constant c1 = (-1000 / slope) +* milli_Tmeas = (n1 - Nmeas) * c1 + 1000 * t1 +* Let constant c2 = n1 *c1 + 1000 * t1 +* milli_Tmeas = c2 - Nmeas * c1 +*/ + temp64 =FACTOR0 ; + temp64 *=1000 ; +do_div (temp64,FACTOR1 * n1 -FACTOR2 ); + c1 = temp64; + c2 = n1 * c1 +1000 * t1; + +/* +* now we only use single measure, every time we read +* the temperature, we will power on/down anadig thermal +* module +*/ +writel (TEMPSENSE0_POWER_DOWN , &anatop->tempsense0_clr); +writel (MISC0_REFTOP_SELBIASOFF , &anatop->ana_misc0_set); + +/* setup measure freq */ + reg =readl (&anatop->tempsense1); + reg &= ~TEMPSENSE1_MEASURE_FREQ ; + reg |=MEASURE_FREQ ; +writel (reg, &anatop->tempsense1); + +/* start the measurement process */ +writel (TEMPSENSE0_MEASURE_TEMP , &anatop->tempsense0_clr); +writel (TEMPSENSE0_FINISHED , &anatop->tempsense0_clr); +writel (TEMPSENSE0_MEASURE_TEMP , &anatop->tempsense0_set); + +/* make sure that the latest temp is valid */ +while ((readl (&anatop->tempsense0) & +TEMPSENSE0_FINISHED ) ==0 ) +udelay (10000 ); + +/* read temperature count */ + reg =readl (&anatop->tempsense0); + n_meas = (reg &TEMPSENSE0_TEMP_CNT_MASK ) + >>TEMPSENSE0_TEMP_CNT_SHIFT ; +writel (TEMPSENSE0_FINISHED , &anatop->tempsense0_clr); + +/* milli_Tmeas = c2 - Nmeas * c1 */ + temperature = (long )(c2 - n_meas * c1)/1000 ; + +/* power down anatop thermal sensor */ +writel (TEMPSENSE0_POWER_DOWN , &anatop->tempsense0_set); +writel (MISC0_REFTOP_SELBIASOFF , &anatop->ana_misc0_clr); + +return temperature; +} +#ifdef CONFIG_REVISION_TAG u32 __weak get_board_rev (void ) {
arch/arm/imx-common/cpu.c +6 -7
@@ -154,14 +154,13 @@ int print_cpuinfo(void)u32 cpurev;__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 (); -#if defined(CONFIG_MX6 ) +#if defined(CONFIG_IMX_THERMAL ) +struct udevice *thermal_dev; +int cpu_tmp, ret; +int minc, maxc; + printf("CPU: Freescale i.MX%s rev%d.%d", get_imx_type((cpurev & 0xFF000) >> 12), (cpurev & 0x000F0) >> 4,
@@ -181,7 +180,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 :
arch/arm/include/asm/arch-mx6/sys_proto.h +2 -0
@@ -8,6 +8,7 @@#ifndef _SYS_PROTO_H_#define _SYS_PROTO_H_ +#include <dm.h> #include <asm/imx-common/regs-common.h> #include "../arch-imx/cpu.h"
@@ -18,6 +19,7 @@ u32 get_nr_cpus(void);u32 get_cpu_rev (void );u32 get_cpu_speed_grade_hz (void );u32 get_cpu_temp_grade (int *minc,int *maxc); +int read_cpu_temperature (struct udevice *dev);/* returns MXC_CPU_ value */ #define cpu_type (rev) (((rev) >> 12) & 0xff)
drivers/thermal/Makefile +1 -1
@@ -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
drivers/thermal/imx_thermal.c +0 -106
118 lines not on this page · raw message
include/configs/cgtqmx6eval.h +2 -2
@@ -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
include/configs/embestmx6boards.h +1 -1
@@ -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)
include/configs/gw_ventana.h +1 -1
@@ -57,7 +57,7 @@#define CONFIG_CMD_GPIO /* Thermal */ -#define CONFIG_IMX6_THERMAL +#define CONFIG_IMX_THERMAL /* Serial */ #define CONFIG_MXC_UART
include/configs/mx6cuboxi.h +1 -1
@@ -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
include/configs/mx6sabre_common.h +1 -1
@@ -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)
include/configs/mx6slevk.h +1 -1
@@ -190,6 +190,6 @@#define CONFIG_SYS_MMC_ENV_DEV 1/* SDHC2*/ #endif -#define CONFIG_IMX6_THERMAL +#define CONFIG_IMX_THERMAL #endif /* __CONFIG_H */
include/configs/mx6sxsabresd.h +1 -1
@@ -176,7 +176,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
include/configs/mx6ul_14x14_evk.h +1 -1
@@ -221,6 +221,6 @@#define CONFIG_USB_MAX_CONTROLLER_COUNT 2#endif -#define CONFIG_IMX6_THERMAL +#define CONFIG_IMX_THERMAL #endif
include/configs/tbs2910.h +1 -1
@@ -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
include/imx_thermal.h +26 -0
@@ -20,4 +20,30 @@ struct imx_thermal_plat { int fuse_word; }; +struct thermal_data { +unsigned int fuse; +int critical; +int minc; +int maxc; +}; + +/* board will busyloop until this many degrees C below CPU max temperature */ +#define TEMPERATURE_HOT_DELTA 5/* CPU maxT - 5C */ +#define FACTOR0 10000000 +#define FACTOR1 15976 +#define FACTOR2 4297157 +#define MEASURE_FREQ 327 + +#define TEMPERATURE_MIN -40 +#define TEMPERATURE_HOT 85 +#define TEMPERATURE_MAX 125 + +#define TEMPSENSE0_TEMP_CNT_SHIFT 8 +#define TEMPSENSE0_TEMP_CNT_MASK (0xfff << TEMPSENSE0_TEMP_CNT_SHIFT) +#define TEMPSENSE0_FINISHED (1 << 2) +#define TEMPSENSE0_MEASURE_TEMP (1 << 1) +#define TEMPSENSE0_POWER_DOWN (1 << 0) +#define MISC0_REFTOP_SELBIASOFF (1 << 3) +#define TEMPSENSE1_MEASURE_FREQ 0xffff +#endif /* _IMX_THERMAL_H_ */
Signature · 1 line
2.1.4
PATCH 1/1 thermal: imx_thermal: rework driver to be reused
Hi Adrian,
Quoted 2 lines · Adrian Alonso
- Rework
imx_thermaldriver to be used across i.MX processor that support thermal sensors
ok
Quoted 1 line
- Make
read_cpu_temperatureSoC dependent
Agree on that, but why moving into the soc / cpu file ?
We have a driver for a specific hardware. The driver supports more as one SOC. it is a common case. We have already such a cases, and the driver must have code for both of them.
Take as example the SPI driver (on u-boot or Linux). It supports multiple i.MXes without demanding code outside of the driver itself.
Aomething like:
read_cpu_temperature_mx6(....)
{
}
read_cpu_temperature_mx7(....)
{
}
int read_cpu_temperature(struct udevice *dev)
{
<check cpu type, call right function>
}
I think moving "read_cpu_temperature" is wrong because everybody expects that all stuff related to the thermal is in the corresponding driver, that is imx-thermal.
Quoted 464 lines
Signed-off-by Adrian Alonso <[email protected]>Signed-off-by Peng Fan <[email protected]>--- arch/arm/cpu/armv7/mx6/soc.c | 86 +++++++++++++++++++++++- arch/arm/imx-common/cpu.c | 13 ++-- arch/arm/include/asm/arch-mx6/sys_proto.h | 2 + drivers/thermal/Makefile | 2 +- drivers/thermal/imx_thermal.c | 106 ------------------------------ 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 +- include/imx_thermal.h | 26 ++++++++ 15 files changed, 130 insertions(+), 125 deletions(-)arch/arm/cpu/armv7/mx6/soc.c +85
-1@@ -22,6 +22,7 @@#include <asm/arch/mxc_hdmi.h> #include <asm/arch/crm_regs.h> #include <dm.h> +#include <div64.h> #include <imx_thermal.h> enum ldo_reg {@@ -38,7 +39,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,@@ -171,6 +172,89 @@ u32 get_cpu_temp_grade(int *minc, int *maxc)return val; } +int read_cpu_temperature (struct udevice *dev) +{ +int temperature; +unsigned int reg, n_meas; +const struct imx_thermal_plat *pdata =dev_get_platdata (dev); +struct anatop_regs *anatop = (struct anatop_regs *)pdata->regs; +struct thermal_data *priv =dev_get_priv (dev); +u32 fuse = priv->fuse; +int t1, n1; +u32 c1, c2; +u64 temp64; + +/* +* Sensor data layout: +* [31:20] - sensor value @ 25C +* We use universal formula now and only need sensor value @ 25C +* slope = 0.4297157 - (0.0015976 * 25C fuse) +*/ + n1 = fuse >>20 ; + t1 =25 ;/* t1 always 25C */ + +/* +* Derived from linear interpolation: +* slope = 0.4297157 - (0.0015976 * 25C fuse) +* slope = (FACTOR2 - FACTOR1 * n1) / FACTOR0 +* (Nmeas - n1) / (Tmeas - t1) = slope +* We want to reduce this down to the minimum computation necessary +* for each temperature read. Also, we want Tmeas in millicelsius +* and we don't want to lose precision from integer division. So... +* Tmeas = (Nmeas - n1) / slope + t1 +* milli_Tmeas = 1000 * (Nmeas - n1) / slope + 1000 * t1 +* milli_Tmeas = -1000 * (n1 - Nmeas) / slope + 1000 * t1 +* Let constant c1 = (-1000 / slope) +* milli_Tmeas = (n1 - Nmeas) * c1 + 1000 * t1 +* Let constant c2 = n1 *c1 + 1000 * t1 +* milli_Tmeas = c2 - Nmeas * c1 +*/ + temp64 =FACTOR0 ; + temp64 *=1000 ; +do_div (temp64,FACTOR1 * n1 -FACTOR2 ); + c1 = temp64; + c2 = n1 * c1 +1000 * t1; + +/* +* now we only use single measure, every time we read +* the temperature, we will power on/down anadig thermal +* module +*/ +writel (TEMPSENSE0_POWER_DOWN , &anatop->tempsense0_clr); +writel (MISC0_REFTOP_SELBIASOFF , &anatop->ana_misc0_set); + +/* setup measure freq */ + reg =readl (&anatop->tempsense1); + reg &= ~TEMPSENSE1_MEASURE_FREQ ; + reg |=MEASURE_FREQ ; +writel (reg, &anatop->tempsense1); + +/* start the measurement process */ +writel (TEMPSENSE0_MEASURE_TEMP , &anatop->tempsense0_clr); +writel (TEMPSENSE0_FINISHED , &anatop->tempsense0_clr); +writel (TEMPSENSE0_MEASURE_TEMP , &anatop->tempsense0_set); + +/* make sure that the latest temp is valid */ +while ((readl (&anatop->tempsense0) & +TEMPSENSE0_FINISHED ) ==0 ) +udelay (10000 ); + +/* read temperature count */ + reg =readl (&anatop->tempsense0); + n_meas = (reg &TEMPSENSE0_TEMP_CNT_MASK ) + >>TEMPSENSE0_TEMP_CNT_SHIFT ; +writel (TEMPSENSE0_FINISHED , &anatop->tempsense0_clr); + +/* milli_Tmeas = c2 - Nmeas * c1 */ + temperature = (long )(c2 - n_meas * c1)/1000 ; + +/* power down anatop thermal sensor */ +writel (TEMPSENSE0_POWER_DOWN , &anatop->tempsense0_set); +writel (MISC0_REFTOP_SELBIASOFF , &anatop->ana_misc0_clr); + +return temperature; +} +#ifdef CONFIG_REVISION_TAG u32 __weak get_board_rev (void ) {arch/arm/imx-common/cpu.c +6
-7@@ -154,14 +154,13 @@ int print_cpuinfo(void)u32 cpurev;__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 (); -#if defined(CONFIG_MX6 ) +#if defined(CONFIG_IMX_THERMAL ) +struct udevice *thermal_dev; +int cpu_tmp, ret; +int minc, maxc; + printf("CPU: Freescale i.MX%s rev%d.%d", get_imx_type((cpurev & 0xFF000) >> 12), (cpurev & 0x000F0) >> 4,@@ -181,7 +180,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 :arch/arm/include/asm/arch-mx6/sys_proto.h +2
-0@@ -8,6 +8,7 @@#ifndef _SYS_PROTO_H_#define _SYS_PROTO_H_ +#include <dm.h> #include <asm/imx-common/regs-common.h> #include "../arch-imx/cpu.h" @@ -18,6 +19,7 @@ u32 get_nr_cpus(void);u32 get_cpu_rev (void );u32 get_cpu_speed_grade_hz (void );u32 get_cpu_temp_grade (int *minc,int *maxc); +int read_cpu_temperature (struct udevice *dev);/* returns MXC_CPU_ value */ #define cpu_type (rev) (((rev) >> 12) & 0xff)drivers/thermal/Makefile +1
-1@@ -6,4 +6,4 @@ # obj-$(CONFIG_DM_THERMAL) += thermal-uclass.o -obj-$(CONFIG_IMX6_THERMAL) += imx_thermal.o +obj-$(CONFIG_IMX_THERMAL) += imx_thermal.odrivers/thermal/imx_thermal.c +0
-106@@ -8,7 +8,6 @@#include <config.h> #include <common.h> -#include <div64.h> #include <fuse.h> #include <asm/io.h> #include <asm/arch/clock.h> @@ -19,111 +18,6 @@#include <thermal.h> #include <imx_thermal.h> -/* board will busyloop until this many degrees C below CPU max temperature */ -#define TEMPERATURE_HOT_DELTA 5/* CPU maxT - 5C */ -#define FACTOR0 10000000 -#define FACTOR1 15976 -#define FACTOR2 4297157 -#define MEASURE_FREQ 327 - -#define TEMPSENSE0_TEMP_CNT_SHIFT 8 -#define TEMPSENSE0_TEMP_CNT_MASK (0xfff << TEMPSENSE0_TEMP_CNT_SHIFT) -#define TEMPSENSE0_FINISHED (1 << 2) -#define TEMPSENSE0_MEASURE_TEMP (1 << 1) -#define TEMPSENSE0_POWER_DOWN (1 << 0) -#define MISC0_REFTOP_SELBIASOFF (1 << 3) -#define TEMPSENSE1_MEASURE_FREQ 0xffff - -struct thermal_data { -unsigned int fuse; -int critical; -int minc; -int maxc; -}; - -static int read_cpu_temperature (struct udevice *dev) -{ -int temperature; -unsigned int reg, n_meas; -const struct imx_thermal_plat *pdata =dev_get_platdata (dev); -struct anatop_regs *anatop = (struct anatop_regs *)pdata->regs; -struct thermal_data *priv =dev_get_priv (dev); -u32 fuse = priv->fuse; -int t1, n1; -u32 c1, c2; -u64 temp64; - -/* -* Sensor data layout: -* [31:20] - sensor value @ 25C -* We use universal formula now and only need sensor value @ 25C -* slope = 0.4297157 - (0.0015976 * 25C fuse) -*/ - n1 = fuse >>20 ; - t1 =25 ;/* t1 always 25C */ - -/* -* Derived from linear interpolation: -* slope = 0.4297157 - (0.0015976 * 25C fuse) -* slope = (FACTOR2 - FACTOR1 * n1) / FACTOR0 -* (Nmeas - n1) / (Tmeas - t1) = slope -* We want to reduce this down to the minimum computation necessary -* for each temperature read. Also, we want Tmeas in millicelsius -* and we don't want to lose precision from integer division. So... -* Tmeas = (Nmeas - n1) / slope + t1 -* milli_Tmeas = 1000 * (Nmeas - n1) / slope + 1000 * t1 -* milli_Tmeas = -1000 * (n1 - Nmeas) / slope + 1000 * t1 -* Let constant c1 = (-1000 / slope) -* milli_Tmeas = (n1 - Nmeas) * c1 + 1000 * t1 -* Let constant c2 = n1 *c1 + 1000 * t1 -* milli_Tmeas = c2 - Nmeas * c1 -*/ - temp64 =FACTOR0 ; - temp64 *=1000 ; -do_div (temp64,FACTOR1 * n1 -FACTOR2 ); - c1 = temp64; - c2 = n1 * c1 +1000 * t1; - -/* -* now we only use single measure, every time we read -* the temperature, we will power on/down anadig thermal -* module -*/ -writel (TEMPSENSE0_POWER_DOWN , &anatop->tempsense0_clr); -writel (MISC0_REFTOP_SELBIASOFF , &anatop->ana_misc0_set); - -/* setup measure freq */ - reg =readl (&anatop->tempsense1); - reg &= ~TEMPSENSE1_MEASURE_FREQ ; - reg |=MEASURE_FREQ ; -writel (reg, &anatop->tempsense1); - -/* start the measurement process */ -writel (TEMPSENSE0_MEASURE_TEMP , &anatop->tempsense0_clr); -writel (TEMPSENSE0_FINISHED , &anatop->tempsense0_clr); -writel (TEMPSENSE0_MEASURE_TEMP , &anatop->tempsense0_set); - -/* make sure that the latest temp is valid */ -while ((readl (&anatop->tempsense0) & -TEMPSENSE0_FINISHED ) ==0 ) -udelay (10000 ); - -/* read temperature count */ - reg =readl (&anatop->tempsense0); - n_meas = (reg &TEMPSENSE0_TEMP_CNT_MASK ) - >>TEMPSENSE0_TEMP_CNT_SHIFT ; -writel (TEMPSENSE0_FINISHED , &anatop->tempsense0_clr); - -/* milli_Tmeas = c2 - Nmeas * c1 */ - temperature = (long )(c2 - n_meas * c1)/1000 ; - -/* power down anatop thermal sensor */ -writel (TEMPSENSE0_POWER_DOWN , &anatop->tempsense0_set); -writel (MISC0_REFTOP_SELBIASOFF , &anatop->ana_misc0_clr); - -return temperature; -} -int imx_thermal_get_temp (struct udevice *dev,int *temp) {struct thermal_data *priv =dev_get_priv (dev);include/configs/cgtqmx6eval.h +2
-2@@ -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 include/configs/embestmx6boards.h +1
-1@@ -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)include/configs/gw_ventana.h +1
-1@@ -57,7 +57,7 @@#define CONFIG_CMD_GPIO /* Thermal */ -#define CONFIG_IMX6_THERMAL +#define CONFIG_IMX_THERMAL /* Serial */ #define CONFIG_MXC_UART include/configs/mx6cuboxi.h +1
-1@@ -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 include/configs/mx6sabre_common.h +1
-1@@ -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)include/configs/mx6slevk.h +1
-1@@ -190,6 +190,6 @@#define CONFIG_SYS_MMC_ENV_DEV 1/* SDHC2*/ #endif -#define CONFIG_IMX6_THERMAL +#define CONFIG_IMX_THERMAL #endif /* __CONFIG_H */ include/configs/mx6sxsabresd.h +1
-1@@ -176,7 +176,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 include/configs/mx6ul_14x14_evk.h +1
-1@@ -221,6 +221,6 @@#define CONFIG_USB_MAX_CONTROLLER_COUNT 2#endif -#define CONFIG_IMX6_THERMAL +#define CONFIG_IMX_THERMAL #endif include/configs/tbs2910.h +1
-1@@ -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 1include/imx_thermal.h +17
-0@@ -20,4 +20,30 @@ struct imx_thermal_plat {int fuse_word; }; +struct thermal_data { +unsigned int fuse; +int critical; +int minc; +int maxc; +}; + +/* board will busyloop until this many degrees C below CPU max temperature */ +#define TEMPERATURE_HOT_DELTA 5/* CPU maxT - 5C */ +#define FACTOR0 10000000 +#define FACTOR1 15976 +#define FACTOR2 4297157 +#define MEASURE_FREQ 327 + +#define TEMPERATURE_MIN -40 +#define TEMPERATURE_HOT 85 +#define TEMPERATURE_MAX 125
include/imx_thermal.h struct imx_thermal_plat { · line 49
Quoted 10 lines
include/imx_thermal.h +9
-0+ +#define TEMPSENSE0_TEMP_CNT_SHIFT 8 +#define TEMPSENSE0_TEMP_CNT_MASK (0xfff << TEMPSENSE0_TEMP_CNT_SHIFT) +#define TEMPSENSE0_FINISHED (1 << 2) +#define TEMPSENSE0_MEASURE_TEMP (1 << 1) +#define TEMPSENSE0_POWER_DOWN (1 << 0) +#define MISC0_REFTOP_SELBIASOFF (1 << 3) +#define TEMPSENSE1_MEASURE_FREQ 0xffff +#endif /* _IMX_THERMAL_H_ */
Regards,
Stefano
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================
PATCH 1/1 thermal: imx_thermal: rework driver to be reused
Hi Stefano,
Quoted 13 lines
-----Original Message-----
From: Stefano Babic [mailto:sbabic at denx.de]
Sent: Tuesday, August 25, 2015 12:23 PM
To: Alonso Lazcano Adrian-B38018 <[email protected]>; u- boot at lists.denx.de; sbabic at denx.de
Cc: otavio at ossystems.com.br; Estevam Fabio-R49496 <[email protected]>; Li Frank-B20596 <[email protected]>; Garg Nitin-B37173 <[email protected]>
Subject: Re: [PATCH] thermal:imx_thermal: rework driver to be reusedHi Adrian,
On 25/08/2015 18:07, Adrian Alonso wrote:
Quoted 8 lines
Quoted 2 lines
- Rework
imx_thermaldriver to be used across i.MX processor that support thermal sensorsok
Quoted 1 line
- Make
read_cpu_temperatureSoC dependentAgree on that, but why moving into the soc / cpu file ?
[Adrian] Well I was following the same way as function get_cpu_temp_grade is implemented In the soc/cpu file; seem to me that read_cpu_temperature could be moved in the same way.
Quoted 8 lines
We have a driver for a specific hardware. The driver supports more as one SOC. it is a common case. We have already such a cases, and the driver must have code for both of them.
Take as example the SPI driver (on u-boot or Linux). It supports multiple i.MXes without demanding code outside of the driver itself.
[Adrian] Ok, I can re-implement as suggested either approach seem ok to me :)
Quoted 513 lines
Something like:
read_cpu_temperature_mx6(....)
{}
read_cpu_temperature_mx7(....)
{}
int
read_cpu_temperature(struct udevice *dev){
<check cpu type, call right function>}
I think moving "
read_cpu_temperature" is wrong because everybody expects that all stuff related to the thermal is in the corresponding driver, that is imx- thermal.Quoted 62 lines
Signed-off-by Adrian Alonso <[email protected]>Signed-off-by Peng Fan <[email protected]>--- arch/arm/cpu/armv7/mx6/soc.c | 86 +++++++++++++++++++++++- arch/arm/imx-common/cpu.c | 13 ++-- arch/arm/include/asm/arch-mx6/sys_proto.h | 2 + drivers/thermal/Makefile | 2 +- drivers/thermal/imx_thermal.c | 106 ------------------------------ 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 +- include/imx_thermal.h | 26 ++++++++ 15 files changed, 130 insertions(+), 125 deletions(-)(quoted diff) +0
-0
b/arch/arm/cpu/armv7/mx6/soc.cindex 8ad8da8..68f4507 100644arch/arm/cpu/armv7/mx6/soc.c +18
-1@@ -22,6 +22,7 @@#include <asm/arch/mxc_hdmi.h> #include <asm/arch/crm_regs.h> #include <dm.h> +#include <div64.h> #include <imx_thermal.h> enum ldo_reg {@@ -38,7 +39,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,@@ -171,6 +172,89 @@ u32 get_cpu_temp_grade(int *minc, int *maxc)return val; } +int read_cpu_temperature (struct udevice *dev) { +int temperature; +unsigned int reg, n_meas; +const struct imx_thermal_plat *pdata =dev_get_platdata (dev); +struct anatop_regs *anatop = (struct anatop_regs *)pdata->regs; +struct thermal_data *priv =dev_get_priv (dev); +u32 fuse = priv->fuse; +int t1, n1; +u32 c1, c2; +u64 temp64; + +/* +* Sensor data layout: +* [31:20] - sensor value @ 25C +* We use universal formula now and only need sensor value @ 25C +* slope = 0.4297157 - (0.0015976 * 25C fuse) arch/arm/cpu/armv7/mx6/soc.c u32 get_cpu_temp_grade(int *minc, int *maxc) · line 200
Quoted 10 lines
arch/arm/cpu/armv7/mx6/soc.c +10
-0+*/ + n1 = fuse >>20 ; + t1 =25 ;/* t1 always 25C */ + +/* +* Derived from linear interpolation: +* slope = 0.4297157 - (0.0015976 * 25C fuse) +* slope = (FACTOR2 - FACTOR1 * n1) / FACTOR0 +* (Nmeas - n1) / (Tmeas - t1) = slope +* We want to reduce this down to the minimum computation necessary
Quoted 134 lines
arch/arm/cpu/armv7/mx6/soc.c +56
-0+* for each temperature read. Also, we want Tmeas in millicelsius +* and we don't want to lose precision from integer division. So... +* Tmeas = (Nmeas - n1) / slope + t1 +* milli_Tmeas = 1000 * (Nmeas - n1) / slope + 1000 * t1 +* milli_Tmeas = -1000 * (n1 - Nmeas) / slope + 1000 * t1 +* Let constant c1 = (-1000 / slope) +* milli_Tmeas = (n1 - Nmeas) * c1 + 1000 * t1 +* Let constant c2 = n1 *c1 + 1000 * t1 +* milli_Tmeas = c2 - Nmeas * c1 +*/ + temp64 =FACTOR0 ; + temp64 *=1000 ; +do_div (temp64,FACTOR1 * n1 -FACTOR2 ); + c1 = temp64; + c2 = n1 * c1 +1000 * t1; + +/* +* now we only use single measure, every time we read +* the temperature, we will power on/down anadig thermal +* module +*/ +writel (TEMPSENSE0_POWER_DOWN , &anatop->tempsense0_clr); +writel (MISC0_REFTOP_SELBIASOFF , &anatop->ana_misc0_set); + +/* setup measure freq */ + reg =readl (&anatop->tempsense1); + reg &= ~TEMPSENSE1_MEASURE_FREQ ; + reg |=MEASURE_FREQ ; +writel (reg, &anatop->tempsense1); + +/* start the measurement process */ +writel (TEMPSENSE0_MEASURE_TEMP , &anatop->tempsense0_clr); +writel (TEMPSENSE0_FINISHED , &anatop->tempsense0_clr); +writel (TEMPSENSE0_MEASURE_TEMP , &anatop->tempsense0_set); + +/* make sure that the latest temp is valid */ +while ((readl (&anatop->tempsense0) & +TEMPSENSE0_FINISHED ) ==0 ) +udelay (10000 ); + +/* read temperature count */ + reg =readl (&anatop->tempsense0); + n_meas = (reg &TEMPSENSE0_TEMP_CNT_MASK ) + >>TEMPSENSE0_TEMP_CNT_SHIFT ; +writel (TEMPSENSE0_FINISHED , &anatop->tempsense0_clr); + +/* milli_Tmeas = c2 - Nmeas * c1 */ + temperature = (long )(c2 - n_meas * c1)/1000 ; + +/* power down anatop thermal sensor */ +writel (TEMPSENSE0_POWER_DOWN , &anatop->tempsense0_set); +writel (MISC0_REFTOP_SELBIASOFF , &anatop->ana_misc0_clr); + +return temperature; +} +#ifdef CONFIG_REVISION_TAG u32 __weak get_board_rev (void ) {arch/arm/imx-common/cpu.c +6
-7@@ -154,14 +154,13 @@ int print_cpuinfo(void)u32 cpurev;__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 (); -#if defined(CONFIG_MX6 ) +#if defined(CONFIG_IMX_THERMAL ) +struct udevice *thermal_dev; +int cpu_tmp, ret; +int minc, maxc; + printf("CPU: Freescale i.MX%s rev%d.%d", get_imx_type((cpurev & 0xFF000) >> 12), (cpurev & 0x000F0) >> 4,@@ -181,7 +180,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 :arch/arm/include/asm/arch-mx6/sys_proto.h +2
-0@@ -8,6 +8,7 @@#ifndef _SYS_PROTO_H_#define _SYS_PROTO_H_ +#include <dm.h> #include <asm/imx-common/regs-common.h> #include "../arch-imx/cpu.h" @@ -18,6 +19,7 @@ u32 get_nr_cpus(void);u32 get_cpu_rev (void );u32 get_cpu_speed_grade_hz (void );u32 get_cpu_temp_grade (int *minc,int *maxc); +int read_cpu_temperature (struct udevice *dev);/* returns MXC_CPU_ value */ #define cpu_type (rev) (((rev) >> 12) & 0xff) diff --gita/drivers/thermal/Makefile b/drivers/thermal/Makefile index 6d4cacd..d768f5e 100644
drivers/thermal/Makefile +1
-1@@ -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(quoted diff) +0
-0
b/drivers/thermal/imx_thermal.cindex 3c6c967..f037f81 100644drivers/thermal/imx_thermal.c +0
-1@@ -8,7 +8,6 @@#include <config.h> #include <common.h> -#include <div64.h> #include <fuse.h> #include <asm/io.h> #include <asm/arch/clock.h> drivers/thermal/imx_thermal.c line 22
Quoted 4 lines
drivers/thermal/imx_thermal.c +0
-1@@ -19,111 +18,6 @@#include <thermal.h> #include <imx_thermal.h> -/* board will busyloop until this many degrees C below CPU max temperature */
drivers/thermal/imx_thermal.c
Quoted 8 lines
drivers/thermal/imx_thermal.c +0
-8-#define TEMPERATURE_HOT_DELTA 5/* CPU maxT - 5C */ -#define FACTOR0 10000000 -#define FACTOR1 15976 -#define FACTOR2 4297157 -#define MEASURE_FREQ 327 - -#define TEMPSENSE0_TEMP_CNT_SHIFT 8 -#define TEMPSENSE0_TEMP_CNT_MASK (0xfff <<
TEMPSENSE0_TEMP_CNT_SHIFT)Quoted 29 lines
drivers/thermal/imx_thermal.c +0
-29-#define TEMPSENSE0_FINISHED (1 << 2) -#define TEMPSENSE0_MEASURE_TEMP (1 << 1) -#define TEMPSENSE0_POWER_DOWN (1 << 0) -#define MISC0_REFTOP_SELBIASOFF (1 << 3) -#define TEMPSENSE1_MEASURE_FREQ 0xffff - -struct thermal_data { -unsigned int fuse; -int critical; -int minc; -int maxc; -}; - -static int read_cpu_temperature(struct udevice *dev) -{ -int temperature; -unsigned int reg, n_meas; -const struct imx_thermal_plat *pdata =dev_get_platdata (dev); -struct anatop_regs *anatop = (struct anatop_regs *)pdata->regs; -struct thermal_data *priv =dev_get_priv (dev); -u32 fuse = priv->fuse; -int t1, n1; -u32 c1, c2; -u64 temp64; - -/* -* Sensor data layout: -* [31:20] - sensor value @ 25C -* We use universal formula now and only need sensor value @ 25C -* slope = 0.4297157 - (0.0015976 * 25C fuse) drivers/thermal/imx_thermal.c
Quoted 10 lines
drivers/thermal/imx_thermal.c +0
-10-*/ - n1 = fuse >>20 ; - t1 =25 ;/* t1 always 25C */ - -/* -* Derived from linear interpolation: -* slope = 0.4297157 - (0.0015976 * 25C fuse) -* slope = (FACTOR2 - FACTOR1 * n1) / FACTOR0 -* (Nmeas - n1) / (Tmeas - t1) = slope -* We want to reduce this down to the minimum computation necessary
Quoted 185 lines
drivers/thermal/imx_thermal.c +0
-56-* for each temperature read. Also, we want Tmeas in millicelsius -* and we don't want to lose precision from integer division. So... -* Tmeas = (Nmeas - n1) / slope + t1 -* milli_Tmeas = 1000 * (Nmeas - n1) / slope + 1000 * t1 -* milli_Tmeas = -1000 * (n1 - Nmeas) / slope + 1000 * t1 -* Let constant c1 = (-1000 / slope) -* milli_Tmeas = (n1 - Nmeas) * c1 + 1000 * t1 -* Let constant c2 = n1 *c1 + 1000 * t1 -* milli_Tmeas = c2 - Nmeas * c1 -*/ - temp64 =FACTOR0 ; - temp64 *=1000 ; -do_div (temp64,FACTOR1 * n1 -FACTOR2 ); - c1 = temp64; - c2 = n1 * c1 +1000 * t1; - -/* -* now we only use single measure, every time we read -* the temperature, we will power on/down anadig thermal -* module -*/ -writel (TEMPSENSE0_POWER_DOWN , &anatop->tempsense0_clr); -writel (MISC0_REFTOP_SELBIASOFF , &anatop->ana_misc0_set); - -/* setup measure freq */ - reg =readl (&anatop->tempsense1); - reg &= ~TEMPSENSE1_MEASURE_FREQ ; - reg |=MEASURE_FREQ ; -writel (reg, &anatop->tempsense1); - -/* start the measurement process */ -writel (TEMPSENSE0_MEASURE_TEMP , &anatop->tempsense0_clr); -writel (TEMPSENSE0_FINISHED , &anatop->tempsense0_clr); -writel (TEMPSENSE0_MEASURE_TEMP , &anatop->tempsense0_set); - -/* make sure that the latest temp is valid */ -while ((readl (&anatop->tempsense0) & -TEMPSENSE0_FINISHED ) ==0 ) -udelay (10000 ); - -/* read temperature count */ - reg =readl (&anatop->tempsense0); - n_meas = (reg &TEMPSENSE0_TEMP_CNT_MASK ) - >>TEMPSENSE0_TEMP_CNT_SHIFT ; -writel (TEMPSENSE0_FINISHED , &anatop->tempsense0_clr); - -/* milli_Tmeas = c2 - Nmeas * c1 */ - temperature = (long )(c2 - n_meas * c1)/1000 ; - -/* power down anatop thermal sensor */ -writel (TEMPSENSE0_POWER_DOWN , &anatop->tempsense0_set); -writel (MISC0_REFTOP_SELBIASOFF , &anatop->ana_misc0_clr); - -return temperature; -} -int imx_thermal_get_temp (struct udevice *dev,int *temp) { struct thermal_data *priv = dev_get_priv(dev); diff --git
a/include/configs/cgtqmx6eval.hb/include/configs/cgtqmx6eval.hindex fb5b82e..c21f178 100644include/configs/cgtqmx6eval.h +2
-2@@ -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 include/configs/embestmx6boards.h +1
-1@@ -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)(quoted diff) +0
-0
b/include/configs/gw_ventana.hindex 8b9d922..231bea7 100644include/configs/gw_ventana.h +1
-1@@ -57,7 +57,7 @@#define CONFIG_CMD_GPIO /* Thermal */ -#define CONFIG_IMX6_THERMAL +#define CONFIG_IMX_THERMAL /* Serial */ #define CONFIG_MXC_UART include/configs/mx6cuboxi.h +1
-1@@ -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 include/configs/mx6sabre_common.h +1
-1@@ -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)include/configs/mx6slevk.h +1
-1@@ -190,6 +190,6 @@#define CONFIG_SYS_MMC_ENV_DEV 1/* SDHC2*/ #endif -#define CONFIG_IMX6_THERMAL +#define CONFIG_IMX_THERMAL #endif /* __CONFIG_H */ (quoted diff) +0
-0
b/include/configs/mx6sxsabresd.hindex 848bdcd..381eaa2 100644include/configs/mx6sxsabresd.h +1
-1@@ -176,7 +176,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 include/configs/mx6ul_14x14_evk.h +1
-1@@ -221,6 +221,6 @@#define CONFIG_USB_MAX_CONTROLLER_COUNT 2 #endif -#define CONFIG_IMX6_THERMAL +#define CONFIG_IMX_THERMAL #endif include/configs/tbs2910.h +1
-1@@ -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 1include/imx_thermal.h index renamed from include/imx_thermal.h +0
-08ce333c..62fed3b 100644
include/imx_thermal.h +0
-0@@ -20,4 +20,30 @@ struct imx_thermal_plat {int fuse_word;include/imx_thermal.h struct imx_thermal_plat { · line 30
Quoted 10 lines
include/imx_thermal.h +8
-0}; +struct thermal_data { +unsigned int fuse; +int critical; +int minc; +int maxc; +}; + +/* board will busyloop until this many degrees C below CPU max temperature */
include/imx_thermal.h struct imx_thermal_plat {
Quoted 12 lines
include/imx_thermal.h +12
-0+#define TEMPERATURE_HOT_DELTA 5/* CPU maxT - 5C */ +#define FACTOR0 10000000 +#define FACTOR1 15976 +#define FACTOR2 4297157 +#define MEASURE_FREQ 327 + +#define TEMPERATURE_MIN -40 +#define TEMPERATURE_HOT 85 +#define TEMPERATURE_MAX 125 + +#define TEMPSENSE0_TEMP_CNT_SHIFT 8 +#define TEMPSENSE0_TEMP_CNT_MASK (0xfff <<
TEMPSENSE0_TEMP_CNT_SHIFT)include/imx_thermal.h struct imx_thermal_plat { · line 49
Quoted 8 lines
include/imx_thermal.h +6
-0+#define TEMPSENSE0_FINISHED (1 << 2) +#define TEMPSENSE0_MEASURE_TEMP (1 << 1) +#define TEMPSENSE0_POWER_DOWN (1 << 0) +#define MISC0_REFTOP_SELBIASOFF (1 << 3) +#define TEMPSENSE1_MEASURE_FREQ 0xffff +#endif /* _IMX_THERMAL_H_ */ Regards,
Stefano--
============================================================
=========
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
============================================================
=========