aboutsummaryrefslogtreecommitdiffstats
path: root/board/freescale/p1_p2_rdb_pc
diff options
context:
space:
mode:
Diffstat (limited to 'board/freescale/p1_p2_rdb_pc')
-rw-r--r--board/freescale/p1_p2_rdb_pc/README2
-rw-r--r--board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c76
-rw-r--r--board/freescale/p1_p2_rdb_pc/spl.c6
-rw-r--r--board/freescale/p1_p2_rdb_pc/tlb.c2
4 files changed, 83 insertions, 3 deletions
diff --git a/board/freescale/p1_p2_rdb_pc/README b/board/freescale/p1_p2_rdb_pc/README
index 86ff04e69d9..f542decec79 100644
--- a/board/freescale/p1_p2_rdb_pc/README
+++ b/board/freescale/p1_p2_rdb_pc/README
@@ -60,5 +60,5 @@ enabled in relative defconfig file,
CONFIG_RESET_VECTOR_ADDRESS - 0xffc
If device tree support is enabled in defconfig,
-1. use 'u-boot-with-dtb.bin' for NOR boot.
+1. use 'u-boot.bin' for NOR boot.
2. use 'u-boot-with-spl.bin' for other boot.
diff --git a/board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c b/board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c
index a71952dcf39..b301491ef81 100644
--- a/board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c
+++ b/board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c
@@ -83,7 +83,19 @@ struct cpld_data {
#define CPLD_FXS_LED 0x0F
#define CPLD_SYS_RST 0x00
-void board_reset(void)
+void board_reset_prepare(void)
+{
+ /*
+ * During reset preparation, turn off external watchdog.
+ * This ensures that external watchdog does not trigger
+ * another reset or possible infinite reset loop.
+ */
+ struct cpld_data *cpld_data = (void *)(CONFIG_SYS_CPLD_BASE);
+ out_8(&cpld_data->wd_cfg, CPLD_WD_CFG);
+ in_8(&cpld_data->wd_cfg); /* Read back to sync write */
+}
+
+void board_reset_last(void)
{
struct cpld_data *cpld_data = (void *)(CONFIG_SYS_CPLD_BASE);
out_8(&cpld_data->system_rst, 1);
@@ -92,12 +104,46 @@ void board_reset(void)
void board_cpld_init(void)
{
struct cpld_data *cpld_data = (void *)(CONFIG_SYS_CPLD_BASE);
+ u8 prev_wd_cfg = in_8(&cpld_data->wd_cfg);
out_8(&cpld_data->wd_cfg, CPLD_WD_CFG);
out_8(&cpld_data->status_led, CPLD_STATUS_LED);
out_8(&cpld_data->fxo_led, CPLD_FXO_LED);
out_8(&cpld_data->fxs_led, CPLD_FXS_LED);
+
+ /*
+ * CPLD's system reset register on P1/P2 RDB boards is not autocleared
+ * after flipping it. If this register is set to one then CPLD triggers
+ * reset of CPU in few ms.
+ *
+ * CPLD does not trigger reset of CPU for 100ms after the last reset.
+ *
+ * This means that trying to reset board via CPLD system reset register
+ * cause reboot loop. To prevent this reboot loop, the only workaround
+ * is to try to clear CPLD's system reset register as early as possible
+ * and it has to be done in 100ms since the last start of reset.
+ */
out_8(&cpld_data->system_rst, CPLD_SYS_RST);
+
+ /*
+ * If watchdog timer was already set to non-disabled value then it means
+ * that watchdog timer was already activated, has already expired and
+ * caused CPU reset. If this happened then due to CPLD firmware bug,
+ * writing to wd_cfg register has no effect and therefore it is not
+ * possible to reactivate watchdog timer again. Also if CPU was reset
+ * via watchdog then some peripherals like i2c do not work. Watchdog and
+ * i2c start working again after CPU reset via non-watchdog method.
+ *
+ * So in case watchdog timer register in CPLD was already enabled then
+ * disable it in CPLD and reset CPU which cause new boot. Watchdog timer
+ * is disabled few lines above, after reading CPLD previous value.
+ * This logic (disabling timer before reset) prevents reboot loop.
+ */
+ if (prev_wd_cfg != CPLD_WD_CFG) {
+ eieio();
+ do_reset(NULL, 0, 0, NULL);
+ while (1); /* do_reset() does not occur immediately */
+ }
}
void board_gpio_init(void)
@@ -368,6 +414,24 @@ int board_eth_init(struct bd_info *bis)
}
#endif
+#if defined(CONFIG_OF_BOARD_SETUP) || defined(CONFIG_OF_BOARD_FIXUP)
+static void fix_max6370_watchdog(void *blob)
+{
+ int off = fdt_node_offset_by_compatible(blob, -1, "maxim,max6370");
+ ccsr_gpio_t *pgpio = (void *)(CONFIG_SYS_MPC85xx_GPIO_ADDR);
+ u32 gpioval = in_be32(&pgpio->gpdat);
+
+ /*
+ * Delete watchdog max6370 node in load_default mode (detected by
+ * GPIO7 - LOAD_DEFAULT_N) because CPLD in load_default mode ignores
+ * watchdog reset signal. CPLD in load_default mode does not reset
+ * board when watchdog triggers reset signal.
+ */
+ if (!(gpioval & BIT(31-7)) && off >= 0)
+ fdt_del_node(blob, off);
+}
+#endif
+
#ifdef CONFIG_OF_BOARD_SETUP
int ft_board_setup(void *blob, struct bd_info *bd)
{
@@ -393,6 +457,8 @@ int ft_board_setup(void *blob, struct bd_info *bd)
sizeof("okay"), 0);
#endif
+ fix_max6370_watchdog(blob);
+
#if defined(CONFIG_HAS_FSL_DR_USB)
fsl_fdt_fixup_dr_usb(blob, bd);
#endif
@@ -444,3 +510,11 @@ int ft_board_setup(void *blob, struct bd_info *bd)
return 0;
}
#endif
+
+#ifdef CONFIG_OF_BOARD_FIXUP
+int board_fix_fdt(void *blob)
+{
+ fix_max6370_watchdog(blob);
+ return 0;
+}
+#endif
diff --git a/board/freescale/p1_p2_rdb_pc/spl.c b/board/freescale/p1_p2_rdb_pc/spl.c
index b60027ebd9a..eda84bf2b1f 100644
--- a/board/freescale/p1_p2_rdb_pc/spl.c
+++ b/board/freescale/p1_p2_rdb_pc/spl.c
@@ -31,6 +31,12 @@ void board_init_f(ulong bootflag)
u32 plat_ratio, bus_clk;
ccsr_gur_t *gur = (void *)CONFIG_SYS_MPC85xx_GUTS_ADDR;
+ /*
+ * Call board_early_init_f() as early as possible as it workarounds
+ * reboot loop due to broken CPLD state machine for reset line.
+ */
+ board_early_init_f();
+
console_init_f();
/* Set pmuxcr to allow both i2c1 and i2c2 */
diff --git a/board/freescale/p1_p2_rdb_pc/tlb.c b/board/freescale/p1_p2_rdb_pc/tlb.c
index 105d9e38aac..65cedd42a0d 100644
--- a/board/freescale/p1_p2_rdb_pc/tlb.c
+++ b/board/freescale/p1_p2_rdb_pc/tlb.c
@@ -61,11 +61,11 @@ struct fsl_e_tlb_entry tlb_table[] = {
MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
0, 5, BOOKE_PAGESZ_1M, 1),
#endif
+#endif /* not SPL */
SET_TLB_ENTRY(1, CONFIG_SYS_CPLD_BASE, CONFIG_SYS_CPLD_BASE_PHYS,
MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
0, 6, BOOKE_PAGESZ_1M, 1),
-#endif /* not SPL */
#ifdef CONFIG_SYS_NAND_BASE
/* *I*G - NAND */