DECLARE_GLOBAL_DATA_PTR;
-#define TEMPERATURE_MIN -40
+#ifdef CONFIG_MX6_TEMPERATURE_MIN
+#define TEMPERATURE_MIN CONFIG_MX6_TEMPERATURE_MIN
+#else
+#define TEMPERATURE_MIN (-40)
+#endif
+#ifdef CONFIG_MX6_TEMPERATURE_HOT
+#define TEMPERATURE_HOT CONFIG_MX6_TEMPERATURE_HOT
+#else
#define TEMPERATURE_HOT 80
+#endif
+#ifdef CONFIG_MX6_TEMPERATURE_MAX
+#define TEMPERATURE_MAX CONFIG_MX6_TEMPERATURE_MAX
+#else
#define TEMPERATURE_MAX 125
+#endif
+#define TEMP_AVG_COUNT 5
+#define TEMP_WARN_THRESHOLD 5
#define REG_VALUE_TO_CEL(ratio, raw) ((raw_n40c - raw) * 100 / ratio - 40)
#define __data __attribute__((section(".data")))
raw_n40c = raw_25c + (13 * ratio) / 20;
/* now we only using single measure, every time we measure
- the temperature, we will power on/down the anadig module*/
+ * the temperature, we will power on/off the anadig module
+ */
writel(BM_ANADIG_TEMPSENSE0_POWER_DOWN, &anatop->tempsense0_clr);
writel(BM_ANADIG_ANA_MISC0_REFTOP_SELBIASOFF, &anatop->ana_misc0_set);
int check_cpu_temperature(int boot)
{
static int __data max_temp;
- int boot_limit = TEMPERATURE_HOT;
+ int boot_limit = getenv_ulong("max_boot_temp", 10, TEMPERATURE_HOT);
int tmp = read_cpu_temperature();
+ bool first = true;
if (tmp < TEMPERATURE_MIN || tmp > TEMPERATURE_MAX) {
printf("Temperature: can't get valid data!\n");
return tmp;
}
- while (tmp >= boot_limit) {
- if (boot) {
- printf("CPU is %d C, too hot to boot, waiting...\n",
- tmp);
- udelay(5000000);
- tmp = read_cpu_temperature();
- boot_limit = TEMPERATURE_HOT - 1;
- } else {
- printf("CPU is %d C, too hot, resetting...\n",
- tmp);
- udelay(1000000);
+ if (!boot) {
+ if (tmp > boot_limit) {
+ printf("CPU is %d C, too hot, resetting...\n", tmp);
+ udelay(100000);
reset_cpu(0);
}
- }
-
- if (boot) {
+ if (tmp > max_temp) {
+ if (tmp > boot_limit - TEMP_WARN_THRESHOLD)
+ printf("WARNING: CPU temperature %d C\n", tmp);
+ max_temp = tmp;
+ }
+ } else {
printf("Temperature: %d C, calibration data 0x%x\n",
tmp, thermal_calib);
- } else if (tmp > max_temp) {
- if (tmp > TEMPERATURE_HOT - 5)
- printf("WARNING: CPU temperature %d C\n", tmp);
- max_temp = tmp;
+ while (tmp >= boot_limit) {
+ if (first) {
+ printf("CPU is %d C, too hot to boot, waiting...\n",
+ tmp);
+ first = false;
+ }
+ if (ctrlc())
+ break;
+ udelay(50000);
+ tmp = read_cpu_temperature();
+ if (tmp > boot_limit - TEMP_WARN_THRESHOLD && tmp != max_temp)
+ printf("WARNING: CPU temperature %d C\n", tmp);
+ max_temp = tmp;
+ }
}
return tmp;
}
#define TX6_RESET_OUT_GPIO IMX_GPIO_NR(7, 12)
-#define TEMPERATURE_MIN -40
+#ifdef CONFIG_MX6_TEMPERATURE_MIN
+#define TEMPERATURE_MIN CONFIG_MX6_TEMPERATURE_MIN
+#else
+#define TEMPERATURE_MIN (-40)
+#endif
+#ifdef CONFIG_MX6_TEMPERATURE_HOT
+#define TEMPERATURE_HOT CONFIG_MX6_TEMPERATURE_HOT
+#else
#define TEMPERATURE_HOT 80
-#define TEMPERATURE_MAX 125
+#endif
DECLARE_GLOBAL_DATA_PTR;
printf("\n");
}
-int read_cpu_temperature(void);
-int check_cpu_temperature(int boot);
-
static const char *tx6_mod_suffix;
static void tx6qdl_print_cpuinfo(void)
mxc_get_clock(MXC_ARM_CLK) / 1000000);
print_reset_cause();
+#ifdef CONFIG_MX6_TEMPERATURE_HOT
check_cpu_temperature(1);
+#endif
}
int board_early_init_f(void)
return 0;
}
+#ifndef CONFIG_MX6_TEMPERATURE_HOT
+static bool tx6_temp_check_enabled = true;
+#else
+#define tx6_temp_check_enabled 0
+#endif
+
int board_init(void)
{
int ret;
gd->bd->bi_arch_number = -1;
if (ctrlc()) {
+#ifndef CONFIG_MX6_TEMPERATURE_HOT
+ tx6_temp_check_enabled = false;
+#endif
printf("CTRL-C detected; Skipping PMIC setup\n");
return 1;
}
LED_STATE_ON,
};
-static inline int calc_blink_rate(int tmp)
+static inline int calc_blink_rate(void)
{
+ if (!tx6_temp_check_enabled)
+ return CONFIG_SYS_HZ;
+
return CONFIG_SYS_HZ + CONFIG_SYS_HZ / 10 -
- (tmp - TEMPERATURE_MIN) * CONFIG_SYS_HZ /
+ (check_cpu_temperature(0) - TEMPERATURE_MIN) * CONFIG_SYS_HZ /
(TEMPERATURE_HOT - TEMPERATURE_MIN);
}
last = get_timer(0);
gpio_set_value(TX6_LED_GPIO, 1);
led_state = LED_STATE_ON;
- blink_rate = calc_blink_rate(check_cpu_temperature(0));
+ blink_rate = calc_blink_rate();
} else {
if (get_timer(last) > blink_rate) {
- blink_rate = calc_blink_rate(check_cpu_temperature(0));
+ blink_rate = calc_blink_rate();
last = get_timer_masked();
if (led_state == LED_STATE_ON) {
gpio_set_value(TX6_LED_GPIO, 0);
int ret = 0;
const char *baseboard;
+ if (tx6_temp_check_enabled)
+ check_cpu_temperature(1);
+
tx6qdl_set_cpu_clock();
- karo_fdt_move_fdt();
+ if (!had_ctrlc())
+ karo_fdt_move_fdt();
baseboard = getenv("baseboard");
if (!baseboard)