diff options
-rw-r--r-- | arch/arm/cpu/armv7/mx6/soc.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/arch/arm/cpu/armv7/mx6/soc.c b/arch/arm/cpu/armv7/mx6/soc.c index 3c3d2fd..207b92b 100644 --- a/arch/arm/cpu/armv7/mx6/soc.c +++ b/arch/arm/cpu/armv7/mx6/soc.c @@ -2,7 +2,7 @@ * (C) Copyright 2007 * Sascha Hauer, Pengutronix * - * (C) Copyright 2009-2014 Freescale Semiconductor, Inc. + * (C) Copyright 2009-2015 Freescale Semiconductor, Inc. * * SPDX-License-Identifier: GPL-2.0+ */ @@ -238,9 +238,8 @@ static void imx_set_wdog_powerdown(bool enable) writew(enable, &wdog2->wmcr); } -static int read_cpu_temperature(void) +static int read_cpu_temperature(int *temperature) { - int temperature; unsigned int ccm_ccgr2; unsigned int reg, tmp; unsigned int raw_25c, raw_n40c, ratio; @@ -278,7 +277,7 @@ static int read_cpu_temperature(void) writel(ccm_ccgr2, &mxc_ccm->CCGR2); if (fuse == 0 || fuse == 0xffffffff || (fuse & 0xfff00000) == 0) - return TEMPERATURE_MIN; + return -EINVAL; /* * fuse data layout: @@ -329,35 +328,38 @@ static int read_cpu_temperature(void) writel(BM_ANADIG_TEMPSENSE0_FINISHED, &mxc_ccm->tempsense0_clr); if (tmp <= raw_n40c) - temperature = REG_VALUE_TO_CEL(ratio, tmp); + *temperature = REG_VALUE_TO_CEL(ratio, tmp); else - temperature = TEMPERATURE_MIN; + *temperature = TEMPERATURE_MIN; /* power down anatop thermal sensor */ writel(BM_ANADIG_TEMPSENSE0_POWER_DOWN, &mxc_ccm->tempsense0_set); writel(BM_ANADIG_ANA_MISC0_REFTOP_SELBIASOFF, &mxc_ccm->ana_misc0_clr); - return temperature; + return 0; } void check_cpu_temperature(void) { int cpu_tmp = 0; + int ret; - cpu_tmp = read_cpu_temperature(); - while (cpu_tmp > TEMPERATURE_MIN && cpu_tmp < TEMPERATURE_MAX) { + ret = read_cpu_temperature(&cpu_tmp); + while (!ret) { if (cpu_tmp >= TEMPERATURE_HOT) { printf("CPU is %d C, too hot to boot, waiting...\n", cpu_tmp); udelay(5000000); - cpu_tmp = read_cpu_temperature(); - } else + ret = read_cpu_temperature(&cpu_tmp); + } else { + printf("CPU: Temperature %d C, calibration data: 0x%x\n", + cpu_tmp, fuse); break; + } } - if (cpu_tmp > TEMPERATURE_MIN && cpu_tmp < TEMPERATURE_MAX) - printf("CPU: Temperature %d C, calibration data: 0x%x\n", - cpu_tmp, fuse); - else + + if (ret) { printf("CPU: Temperature: can't get valid data!\n"); + } } static void set_ahb_rate(u32 val) |