The PowerPC processors supported by U-Boot have many different varieties of hardware reset capabilites.
Some, such as the 7xx/74xx, require a board-specific hardware-reset signal to be supplied to the CPU. Others use CPU-specific restart registers or faulting instructions. Several of the CPU-specific do_reset() functions called a custom helper function "board_reset()" to allow board-specific override. All of the do_reset() functions in arch/powerpc/ were changed to the new prototype __arch_restart() and all PowerPC board/* changed to use the function prototype __board_restart(). The "lwmon" board seems to keep its board-specific code littered in ifdef blocks in the middle of common code, and its restart function was no exception. That do_reset() function was moved to board/lwmon/lwmon.c where it belonged and changed to use the prototype __board_restart(). A few do_reset() functions in arch/powerpc/ used to be protected by ifdefs due to conflicting board-specific definitions. As they no longer conflict, the excess #ifdefs are removed. The ppmc7xx board does not appear to have any usable hardware reset functionality, so it has a no-op __arch_emergency_restart() function. If the CPU is in an invalid state then jump-to-RAM probably won't work. All of the rest of the reset code will probably work even when the CPU is in a bad state, so they should be fine with the defaults. Signed-off-by: Kyle Moffett <kyle.d.moff...@boeing.com> Cc: Wolfgang Denk <w...@denx.de> Cc: Stefan Roese <s...@denx.de> Cc: Kim Phillips <kim.phill...@freescale.com> Cc: Andy Fleming <aflem...@gmail.com> Cc: Kumar Gala <kumar.g...@freescale.com> --- arch/powerpc/cpu/74xx_7xx/cpu.c | 7 +----- arch/powerpc/cpu/mpc512x/cpu.c | 3 +- arch/powerpc/cpu/mpc5xx/cpu.c | 2 +- arch/powerpc/cpu/mpc5xxx/cpu.c | 3 +- arch/powerpc/cpu/mpc8220/cpu.c | 2 +- arch/powerpc/cpu/mpc824x/cpu.c | 2 +- arch/powerpc/cpu/mpc8260/cpu.c | 6 +---- arch/powerpc/cpu/mpc83xx/cpu.c | 5 +--- arch/powerpc/cpu/mpc85xx/cpu.c | 17 +++++++++++---- arch/powerpc/cpu/mpc86xx/cpu.c | 16 +-------------- arch/powerpc/cpu/mpc8xx/cpu.c | 30 +---------------------------- arch/powerpc/cpu/ppc4xx/cpu.c | 8 +------ board/amcc/yosemite/yosemite.c | 3 +- board/eltec/bab7xx/bab7xx.c | 4 +- board/eltec/elppc/elppc.c | 2 +- board/freescale/mpc8610hpcd/mpc8610hpcd.c | 3 +- board/freescale/mpc8641hpcn/mpc8641hpcn.c | 3 +- board/funkwerk/vovpn-gw/vovpn-gw.c | 5 +--- board/lwmon/lwmon.c | 22 +++++++++++++++++++++ board/lwmon5/lwmon5.c | 3 +- board/pcippc2/pcippc2.c | 2 +- board/ppmc7xx/ppmc7xx.c | 18 ++++++++++++---- board/sbc8641d/sbc8641d.c | 3 +- include/configs/VoVPN-GW.h | 3 -- include/configs/lwmon5.h | 1 - include/configs/yosemite.h | 1 - 26 files changed, 73 insertions(+), 101 deletions(-) diff --git a/arch/powerpc/cpu/74xx_7xx/cpu.c b/arch/powerpc/cpu/74xx_7xx/cpu.c index b6a31b4..24b531a 100644 --- a/arch/powerpc/cpu/74xx_7xx/cpu.c +++ b/arch/powerpc/cpu/74xx_7xx/cpu.c @@ -229,12 +229,8 @@ soft_restart(unsigned long addr) } -#if !defined(CONFIG_PCIPPC2) && \ - !defined(CONFIG_BAB7xx) && \ - !defined(CONFIG_ELPPC) && \ - !defined(CONFIG_PPMC7XX) /* no generic way to do board reset. simply call soft_reset. */ -int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +int __arch_restart(void) { ulong addr; /* flush and disable I/D cache */ @@ -269,7 +265,6 @@ int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return 1; } -#endif /* ------------------------------------------------------------------------- */ diff --git a/arch/powerpc/cpu/mpc512x/cpu.c b/arch/powerpc/cpu/mpc512x/cpu.c index a1a3bd4..c2dab2c 100644 --- a/arch/powerpc/cpu/mpc512x/cpu.c +++ b/arch/powerpc/cpu/mpc512x/cpu.c @@ -74,8 +74,7 @@ int checkcpu (void) } -int -do_reset (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) +int __arch_restart(void) { ulong msr; volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR; diff --git a/arch/powerpc/cpu/mpc5xx/cpu.c b/arch/powerpc/cpu/mpc5xx/cpu.c index 5aa7f84..74193dc 100644 --- a/arch/powerpc/cpu/mpc5xx/cpu.c +++ b/arch/powerpc/cpu/mpc5xx/cpu.c @@ -138,7 +138,7 @@ int dcache_status (void) /* * Reset board */ -int do_reset (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) +int __arch_restart(void) { #if defined(CONFIG_PATI) volatile ulong *addr = (ulong *) CONFIG_SYS_RESET_ADDRESS; diff --git a/arch/powerpc/cpu/mpc5xxx/cpu.c b/arch/powerpc/cpu/mpc5xxx/cpu.c index 0c1eebd..ed3b267 100644 --- a/arch/powerpc/cpu/mpc5xxx/cpu.c +++ b/arch/powerpc/cpu/mpc5xxx/cpu.c @@ -77,8 +77,7 @@ int checkcpu (void) /* ------------------------------------------------------------------------- */ -int -do_reset (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) +int __arch_restart(void) { ulong msr; /* Interrupts and MMU off */ diff --git a/arch/powerpc/cpu/mpc8220/cpu.c b/arch/powerpc/cpu/mpc8220/cpu.c index 64e0526..fa9d076 100644 --- a/arch/powerpc/cpu/mpc8220/cpu.c +++ b/arch/powerpc/cpu/mpc8220/cpu.c @@ -52,7 +52,7 @@ int checkcpu (void) /* ------------------------------------------------------------------------- */ -int do_reset (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) +int __arch_restart(void) { volatile gptmr8220_t *gptmr = (volatile gptmr8220_t *) MMAP_GPTMR; ulong msr; diff --git a/arch/powerpc/cpu/mpc824x/cpu.c b/arch/powerpc/cpu/mpc824x/cpu.c index 44f91b2..c3188c9 100644 --- a/arch/powerpc/cpu/mpc824x/cpu.c +++ b/arch/powerpc/cpu/mpc824x/cpu.c @@ -92,7 +92,7 @@ int checkdcache (void) /*------------------------------------------------------------------- */ -int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +int __arch_restart(void) { ulong msr, addr; diff --git a/arch/powerpc/cpu/mpc8260/cpu.c b/arch/powerpc/cpu/mpc8260/cpu.c index 220c1e2..2c07147 100644 --- a/arch/powerpc/cpu/mpc8260/cpu.c +++ b/arch/powerpc/cpu/mpc8260/cpu.c @@ -236,9 +236,7 @@ void upmconfig (uint upm, uint * table, uint size) /* ------------------------------------------------------------------------- */ -#if !defined(CONFIG_HAVE_OWN_RESET) -int -do_reset (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) +int __arch_restart(void) { ulong msr, addr; @@ -268,9 +266,7 @@ do_reset (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) #endif ((void (*)(void)) addr) (); return 1; - } -#endif /* CONFIG_HAVE_OWN_RESET */ /* ------------------------------------------------------------------------- */ diff --git a/arch/powerpc/cpu/mpc83xx/cpu.c b/arch/powerpc/cpu/mpc83xx/cpu.c index 6635109..03f5154 100644 --- a/arch/powerpc/cpu/mpc83xx/cpu.c +++ b/arch/powerpc/cpu/mpc83xx/cpu.c @@ -126,8 +126,7 @@ int checkcpu(void) return 0; } -int -do_reset (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) +int __arch_restart(void) { ulong msr; #ifndef MPC83xx_RESET @@ -136,8 +135,6 @@ do_reset (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR; - puts("Resetting the board.\n"); - #ifdef MPC83xx_RESET /* Interrupts and MMU off */ diff --git a/arch/powerpc/cpu/mpc85xx/cpu.c b/arch/powerpc/cpu/mpc85xx/cpu.c index 1aad2ba..c1690fa 100644 --- a/arch/powerpc/cpu/mpc85xx/cpu.c +++ b/arch/powerpc/cpu/mpc85xx/cpu.c @@ -202,11 +202,11 @@ int checkcpu (void) /* ------------------------------------------------------------------------- */ -int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) -{ -/* Everything after the first generation of PQ3 parts has RSTCR */ #if defined(CONFIG_MPC8540) || defined(CONFIG_MPC8541) || \ defined(CONFIG_MPC8555) || defined(CONFIG_MPC8560) + +int __arch_restart(void) +{ unsigned long val, msr; /* @@ -220,15 +220,22 @@ int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) val = mfspr(DBCR0); val |= 0x70000000; mtspr(DBCR0,val); + return 1; +} + #else + +/* Everything after the first generation of PQ3 parts has RSTCR */ +int __arch_restart(void) +{ volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); out_be32(&gur->rstcr, 0x2); /* HRESET_REQ */ udelay(100); -#endif - return 1; } +#endif + /* * Get timebase clock frequency diff --git a/arch/powerpc/cpu/mpc86xx/cpu.c b/arch/powerpc/cpu/mpc86xx/cpu.c index ffcc8e6..5633a3a 100644 --- a/arch/powerpc/cpu/mpc86xx/cpu.c +++ b/arch/powerpc/cpu/mpc86xx/cpu.c @@ -32,17 +32,6 @@ DECLARE_GLOBAL_DATA_PTR; -/* - * Default board reset function - */ -static void -__board_reset(void) -{ - /* Do nothing */ -} -void board_reset(void) __attribute__((weak, alias("__board_reset"))); - - int checkcpu(void) { @@ -123,14 +112,11 @@ checkcpu(void) } -int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +int __arch_restart(void) { volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR; volatile ccsr_gur_t *gur = &immap->im_gur; - /* Attempt board-specific reset */ - board_reset(); - /* Next try asserting HRESET_REQ */ out_be32(&gur->rstcr, MPC86xx_RSTCR_HRST_REQ); diff --git a/arch/powerpc/cpu/mpc8xx/cpu.c b/arch/powerpc/cpu/mpc8xx/cpu.c index 142cfa5..e73b33e 100644 --- a/arch/powerpc/cpu/mpc8xx/cpu.c +++ b/arch/powerpc/cpu/mpc8xx/cpu.c @@ -476,9 +476,7 @@ void upmconfig (uint upm, uint * table, uint size) /* ------------------------------------------------------------------------- */ -#ifndef CONFIG_LWMON - -int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +int __arch_restart(void) { ulong msr, addr; @@ -512,32 +510,6 @@ int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return 1; } -#else /* CONFIG_LWMON */ - -/* - * On the LWMON board, the MCLR reset input of the PIC's on the board - * uses a 47K/1n RC combination which has a 47us time constant. The - * low signal on the HRESET pin of the CPU is only 512 clocks = 8 us - * and thus too short to reset the external hardware. So we use the - * watchdog to reset the board. - */ -int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) -{ - /* prevent triggering the watchdog */ - disable_interrupts (); - - /* make sure the watchdog is running */ - reset_8xx_watchdog ((immap_t *) CONFIG_SYS_IMMR); - - /* wait for watchdog reset */ - while (1) {}; - - /* NOTREACHED */ - return 1; -} - -#endif /* CONFIG_LWMON */ - /* ------------------------------------------------------------------------- */ /* diff --git a/arch/powerpc/cpu/ppc4xx/cpu.c b/arch/powerpc/cpu/ppc4xx/cpu.c index 67f1fff..add4518 100644 --- a/arch/powerpc/cpu/ppc4xx/cpu.c +++ b/arch/powerpc/cpu/ppc4xx/cpu.c @@ -40,8 +40,6 @@ DECLARE_GLOBAL_DATA_PTR; -void board_reset(void); - /* * To provide an interface to detect CPU number for boards that support * more then one CPU, we implement the "weak" default functions here. @@ -699,11 +697,8 @@ int ppc440spe_revB() { /* ------------------------------------------------------------------------- */ -int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +int __arch_restart(void) { -#if defined(CONFIG_BOARD_RESET) - board_reset(); -#else #if defined(CONFIG_SYS_4xx_RESET_TYPE) mtspr(SPRN_DBCR0, CONFIG_SYS_4xx_RESET_TYPE << 28); #else @@ -712,7 +707,6 @@ int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) */ mtspr(SPRN_DBCR0, 0x30000000); #endif /* defined(CONFIG_SYS_4xx_RESET_TYPE) */ -#endif /* defined(CONFIG_BOARD_RESET) */ return 1; } diff --git a/board/amcc/yosemite/yosemite.c b/board/amcc/yosemite/yosemite.c index aaeab6f..74f675a 100644 --- a/board/amcc/yosemite/yosemite.c +++ b/board/amcc/yosemite/yosemite.c @@ -365,8 +365,9 @@ void hw_watchdog_reset(void) } #endif -void board_reset(void) +int __board_restart(void) { /* give reset to BCSR */ *(unsigned char *)(CONFIG_SYS_BCSR_BASE | 0x06) = 0x09; + return -1; } diff --git a/board/eltec/bab7xx/bab7xx.c b/board/eltec/bab7xx/bab7xx.c index ea4897b..5cd1525 100644 --- a/board/eltec/bab7xx/bab7xx.c +++ b/board/eltec/bab7xx/bab7xx.c @@ -181,10 +181,10 @@ void after_reloc (ulong dest_addr) /* ------------------------------------------------------------------------- */ /* - * do_reset is done here because in this case it is board specific, since the + * reset is done here because in this case it is board specific, since the * 7xx CPUs can only be reset by external HW (the RTC in this case). */ -int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +int __board_restart(void) { #if defined(CONFIG_RTC_MK48T59) /* trigger watchdog immediately */ diff --git a/board/eltec/elppc/elppc.c b/board/eltec/elppc/elppc.c index cb9ab86..e10a984 100644 --- a/board/eltec/elppc/elppc.c +++ b/board/eltec/elppc/elppc.c @@ -117,7 +117,7 @@ phys_size_t initdram (int board_type) * Register PI in the MPC 107 (at offset 0x41090 of the Embedded Utilities * Memory Block). */ -int do_reset (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) +int __board_restart(void) { out8 (MPC107_EUMB_PI, 1); return (0); diff --git a/board/freescale/mpc8610hpcd/mpc8610hpcd.c b/board/freescale/mpc8610hpcd/mpc8610hpcd.c index d7dd470..ee31588 100644 --- a/board/freescale/mpc8610hpcd/mpc8610hpcd.c +++ b/board/freescale/mpc8610hpcd/mpc8610hpcd.c @@ -314,7 +314,7 @@ int board_eth_init(bd_t *bis) return pci_eth_init(bis); } -void board_reset(void) +int __board_restart(void) { u8 *pixis_base = (u8 *)PIXIS_BASE; @@ -322,4 +322,5 @@ void board_reset(void) while (1) ; + return -1; } diff --git a/board/freescale/mpc8641hpcn/mpc8641hpcn.c b/board/freescale/mpc8641hpcn/mpc8641hpcn.c index 166ff0c..60b52cf 100644 --- a/board/freescale/mpc8641hpcn/mpc8641hpcn.c +++ b/board/freescale/mpc8641hpcn/mpc8641hpcn.c @@ -252,7 +252,7 @@ int board_eth_init(bd_t *bis) return pci_eth_init(bis); } -void board_reset(void) +int __board_restart(void) { u8 *pixis_base = (u8 *)PIXIS_BASE; @@ -260,6 +260,7 @@ void board_reset(void) while (1) ; + return -1; } #ifdef CONFIG_MP diff --git a/board/funkwerk/vovpn-gw/vovpn-gw.c b/board/funkwerk/vovpn-gw/vovpn-gw.c index a4bfbc9..14d495b 100644 --- a/board/funkwerk/vovpn-gw/vovpn-gw.c +++ b/board/funkwerk/vovpn-gw/vovpn-gw.c @@ -304,9 +304,7 @@ int misc_init_r (void) return 0; } -#if defined(CONFIG_HAVE_OWN_RESET) -int -do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +int __board_restart(void) { volatile ioport_t *iop; @@ -314,7 +312,6 @@ do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) iop->pdat |= 0x00002000; /* PC18 = HW_RESET */ return 1; } -#endif /* CONFIG_HAVE_OWN_RESET */ #define ns2clk(ns) (ns / (1000000000 / CONFIG_8260_CLKIN) + 1) diff --git a/board/lwmon/lwmon.c b/board/lwmon/lwmon.c index 9d6c21f..4c99b68 100644 --- a/board/lwmon/lwmon.c +++ b/board/lwmon/lwmon.c @@ -1052,6 +1052,28 @@ void board_poweroff (void) while (1); } +/* + * On the LWMON board, the MCLR reset input of the PIC's on the board + * uses a 47K/1n RC combination which has a 47us time constant. The + * low signal on the HRESET pin of the CPU is only 512 clocks = 8 us + * and thus too short to reset the external hardware. So we use the + * watchdog to reset the board. + */ +int __board_restart(void) +{ + /* prevent triggering the watchdog */ + disable_interrupts (); + + /* make sure the watchdog is running */ + reset_8xx_watchdog ((immap_t *) CONFIG_SYS_IMMR); + + /* wait for watchdog reset */ + while (1) {}; + + /* NOTREACHED */ + return 1; +} + #ifdef CONFIG_MODEM_SUPPORT static int key_pressed(void) { diff --git a/board/lwmon5/lwmon5.c b/board/lwmon5/lwmon5.c index dd275bf..f659fd6 100644 --- a/board/lwmon5/lwmon5.c +++ b/board/lwmon5/lwmon5.c @@ -490,7 +490,8 @@ void video_get_info_str(int line_number, char *info) #endif /* CONFIG_CONSOLE_EXTRA_INFO */ #endif /* CONFIG_VIDEO */ -void board_reset(void) +int __board_restart(void) { gpio_write_bit(CONFIG_SYS_GPIO_BOARD_RESET, 1); + return -1; } diff --git a/board/pcippc2/pcippc2.c b/board/pcippc2/pcippc2.c index 4a91458..568b6f1 100644 --- a/board/pcippc2/pcippc2.c +++ b/board/pcippc2/pcippc2.c @@ -69,7 +69,7 @@ phys_size_t initdram (int board_type) return cpc710_ram_init (); } -int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +int __board_restart(void) { out32 (REG (CPC0, SPOR), 0); iobarrier_rw (); diff --git a/board/ppmc7xx/ppmc7xx.c b/board/ppmc7xx/ppmc7xx.c index 432d366..709fa33 100644 --- a/board/ppmc7xx/ppmc7xx.c +++ b/board/ppmc7xx/ppmc7xx.c @@ -84,14 +84,12 @@ int misc_init_r( void ) /* - * do_reset() + * __board_restart() * - * Shell command to reset the board. + * Called when the board needs to be rebooted */ -int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +int __board_restart(void) { - printf( "Resetting...\n" ); - /* Disabe and invalidate cache */ icache_disable(); dcache_disable(); @@ -106,6 +104,16 @@ int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return 1; } +/* + * The __board_restart() just jumps back to RAM, which isn't safe to do in + * emergency conditions. Since we don't have anything better to do, just + * fall through into the default hang(). + */ +void __board_emergency_restart(void) +{ + return; +} + int board_eth_init(bd_t *bis) { return pci_eth_init(bis); diff --git a/board/sbc8641d/sbc8641d.c b/board/sbc8641d/sbc8641d.c index 5c30b26..4d8f17c 100644 --- a/board/sbc8641d/sbc8641d.c +++ b/board/sbc8641d/sbc8641d.c @@ -245,7 +245,7 @@ unsigned long get_board_sys_clk (ulong dummy) return val; } -void board_reset(void) +int __board_restart(void) { #ifdef CONFIG_SYS_RESET_ADDRESS ulong addr = CONFIG_SYS_RESET_ADDRESS; @@ -272,6 +272,7 @@ void board_reset(void) __asm__ __volatile__ ("mtspr 27, 4"); __asm__ __volatile__ ("rfi"); #endif + return -1; } #ifdef CONFIG_MP diff --git a/include/configs/VoVPN-GW.h b/include/configs/VoVPN-GW.h index c06909f..796c9a0 100644 --- a/include/configs/VoVPN-GW.h +++ b/include/configs/VoVPN-GW.h @@ -47,9 +47,6 @@ /* have reset_phy_r() function */ #define CONFIG_RESET_PHY_R 1 -/* have special reset function */ -#define CONFIG_HAVE_OWN_RESET 1 - /* allow serial and ethaddr to be overwritten */ #define CONFIG_ENV_OVERWRITE diff --git a/include/configs/lwmon5.h b/include/configs/lwmon5.h index a1ead70..a8c6348 100644 --- a/include/configs/lwmon5.h +++ b/include/configs/lwmon5.h @@ -49,7 +49,6 @@ #define CONFIG_BOARD_EARLY_INIT_R /* Call board_early_init_r */ #define CONFIG_BOARD_POSTCLK_INIT /* Call board_postclk_init */ #define CONFIG_MISC_INIT_R /* Call misc_init_r */ -#define CONFIG_BOARD_RESET /* Call board_reset */ /* * Base addresses -- Note these are effective addresses where the diff --git a/include/configs/yosemite.h b/include/configs/yosemite.h index 0cbef6f..1657d91 100644 --- a/include/configs/yosemite.h +++ b/include/configs/yosemite.h @@ -51,7 +51,6 @@ #define CONFIG_BOARD_EARLY_INIT_F 1 /* Call board_early_init_f */ #define CONFIG_MISC_INIT_R 1 /* call misc_init_r() */ -#define CONFIG_BOARD_RESET 1 /* call board_reset() */ /*----------------------------------------------------------------------- * Base addresses -- Note these are effective addresses where the -- 1.7.2.3 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot