diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2015-08-26 09:04:45 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2015-08-27 21:37:03 +0200 |
commit | 83b0a5ae055bc084938dac96b3ea1c796d99d86c (patch) | |
tree | ba69e2015cbfeb1626f7ea3f6bf850556541095a /arch/ppc | |
parent | 167e93947e9b755b54900ae9870dbcc089f8d6c9 (diff) | |
download | barebox-83b0a5ae055bc084938dac96b3ea1c796d99d86c.tar.gz barebox-83b0a5ae055bc084938dac96b3ea1c796d99d86c.tar.xz |
restart: replace reset_cpu with registered restart handlers
This replaces the reset_cpu() function which every SoC or board must
provide with registered handlers. This makes it possible to have multiple
reset functions for boards which have multiple ways to reset the machine.
Also boards which have no way at all to reset the machine no longer
have to provide a dummy reset_cpu() function.
The problem this solves is that some machines have external PMICs or
similar to reset the system which have to be preferred over the
internal SoC reset, because the PMIC can reset not only the SoC but also
the external devices.
To pick the right way to reset a machine each handler has a priority. The
default priority is 100 and all currently existing restart handlers are
registered with this priority. of_get_restart_priority() allows to retrieve
the priority from the device tree which makes it possible for boards to
give certain restart handlers a higher priority in order to use this one
instead of the default one.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/ppc')
-rw-r--r-- | arch/ppc/lib/ppclinux.c | 3 | ||||
-rw-r--r-- | arch/ppc/mach-mpc5xxx/cpu.c | 11 | ||||
-rw-r--r-- | arch/ppc/mach-mpc85xx/cpu.c | 14 |
3 files changed, 22 insertions, 6 deletions
diff --git a/arch/ppc/lib/ppclinux.c b/arch/ppc/lib/ppclinux.c index e25efecd43..409c0cf261 100644 --- a/arch/ppc/lib/ppclinux.c +++ b/arch/ppc/lib/ppclinux.c @@ -10,6 +10,7 @@ #include <asm/processor.h> #include <boot.h> #include <errno.h> +#include <restart.h> #include <fs.h> static int bootm_relocate_fdt(void *addr, struct image_data *data) @@ -87,7 +88,7 @@ static int do_bootm_linux(struct image_data *data) */ kernel(data->oftree, kernel, 0, 0, 0); - reset_cpu(0); + restart_machine(); error: return -1; diff --git a/arch/ppc/mach-mpc5xxx/cpu.c b/arch/ppc/mach-mpc5xxx/cpu.c index 3f826e4994..33835e7060 100644 --- a/arch/ppc/mach-mpc5xxx/cpu.c +++ b/arch/ppc/mach-mpc5xxx/cpu.c @@ -31,6 +31,7 @@ #include <types.h> #include <errno.h> #include <of.h> +#include <restart.h> #include <mach/clock.h> int checkcpu (void) @@ -59,7 +60,7 @@ int checkcpu (void) /* ------------------------------------------------------------------------- */ -void __noreturn reset_cpu (unsigned long addr) +static void __noreturn mpc5xxx_restart_soc(struct restart_handler *rst) { ulong msr; /* Interrupts and MMU off */ @@ -71,9 +72,15 @@ void __noreturn reset_cpu (unsigned long addr) /* Charge the watchdog timer */ *(vu_long *)(MPC5XXX_GPT0_COUNTER) = 0x0001000f; *(vu_long *)(MPC5XXX_GPT0_ENABLE) = 0x9004; /* wden|ce|timer_ms */ - while(1); + hang(); } +static int restart_register_feature(void) +{ + restart_handler_register_fn(mpc5xxx_restart_soc); +} +coredevice_initcall(restart_register_feature); + /* ------------------------------------------------------------------------- */ #ifdef CONFIG_OFTREE diff --git a/arch/ppc/mach-mpc85xx/cpu.c b/arch/ppc/mach-mpc85xx/cpu.c index 7c183c1b5e..42464e810c 100644 --- a/arch/ppc/mach-mpc85xx/cpu.c +++ b/arch/ppc/mach-mpc85xx/cpu.c @@ -26,12 +26,13 @@ #include <common.h> #include <memory.h> #include <init.h> +#include <restart.h> #include <asm/fsl_ddr_sdram.h> #include <asm-generic/memory_layout.h> #include <mach/mmu.h> #include <mach/immap_85xx.h> -void __noreturn reset_cpu(unsigned long addr) +static void __noreturn mpc85xx_restart_soc(struct restart_handler *rst) { void __iomem *regs = (void __iomem *)MPC85xx_GUTS_ADDR; @@ -39,10 +40,17 @@ void __noreturn reset_cpu(unsigned long addr) out_be32(regs + MPC85xx_GUTS_RSTCR_OFFSET, 0x2); /* HRESET_REQ */ udelay(100); - while (1) - ; + hang(); } +static int restart_register_feature(void) +{ + restart_handler_register_fn(mpc85xx_restart_soc); + + return 0; +} +coredevice_initcall(restart_register_feature); + long int initdram(int board_type) { phys_size_t dram_size = 0; |