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/arm/mach-mvebu | |
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/arm/mach-mvebu')
-rw-r--r-- | arch/arm/mach-mvebu/armada-370-xp.c | 9 | ||||
-rw-r--r-- | arch/arm/mach-mvebu/common.c | 13 | ||||
-rw-r--r-- | arch/arm/mach-mvebu/dove.c | 9 | ||||
-rw-r--r-- | arch/arm/mach-mvebu/include/mach/common.h | 1 | ||||
-rw-r--r-- | arch/arm/mach-mvebu/kirkwood.c | 9 |
5 files changed, 15 insertions, 26 deletions
diff --git a/arch/arm/mach-mvebu/armada-370-xp.c b/arch/arm/mach-mvebu/armada-370-xp.c index 2405629526..c362cfdabe 100644 --- a/arch/arm/mach-mvebu/armada-370-xp.c +++ b/arch/arm/mach-mvebu/armada-370-xp.c @@ -17,6 +17,7 @@ #include <common.h> #include <init.h> #include <io.h> +#include <restart.h> #include <of.h> #include <of_address.h> #include <asm/memory.h> @@ -104,12 +105,12 @@ static int armada_370_xp_soc_id_fixup(void) return 0; } -static void __noreturn armada_370_xp_reset_cpu(unsigned long addr) +static void __noreturn armada_370_xp_restart_soc(struct restart_handler *rst) { writel(0x1, ARMADA_370_XP_SYSCTL_BASE + 0x60); writel(0x1, ARMADA_370_XP_SYSCTL_BASE + 0x64); - while (1) - ; + + hang(); } static int armada_xp_init_soc(struct device_node *root) @@ -132,7 +133,7 @@ static int armada_370_xp_init_soc(struct device_node *root, void *context) if (!of_machine_is_compatible("marvell,armada-370-xp")) return 0; - mvebu_set_reset(armada_370_xp_reset_cpu); + restart_handler_register_fn(armada_370_xp_restart_soc); barebox_set_model("Marvell Armada 370/XP"); barebox_set_hostname("armada"); diff --git a/arch/arm/mach-mvebu/common.c b/arch/arm/mach-mvebu/common.c index 7d28d9c45a..cb40d0cb6f 100644 --- a/arch/arm/mach-mvebu/common.c +++ b/arch/arm/mach-mvebu/common.c @@ -123,16 +123,3 @@ int mvebu_set_memory(u64 phys_base, u64 phys_size) return 0; } - -static __noreturn void (*mvebu_reset_cpu)(unsigned long addr); - -void __noreturn reset_cpu(unsigned long addr) -{ - mvebu_reset_cpu(addr); -} -EXPORT_SYMBOL(reset_cpu); - -void mvebu_set_reset(void __noreturn (*reset)(unsigned long addr)) -{ - mvebu_reset_cpu = reset; -} diff --git a/arch/arm/mach-mvebu/dove.c b/arch/arm/mach-mvebu/dove.c index a7284fd33a..ba4af3aae9 100644 --- a/arch/arm/mach-mvebu/dove.c +++ b/arch/arm/mach-mvebu/dove.c @@ -17,6 +17,7 @@ #include <common.h> #include <init.h> #include <io.h> +#include <restart.h> #include <asm/memory.h> #include <linux/mbus.h> #include <mach/dove-regs.h> @@ -68,13 +69,13 @@ static inline void dove_memory_find(unsigned long *phys_base, } } -static void __noreturn dove_reset_cpu(unsigned long addr) +static void __noreturn dove_restart_soc(struct restart_handler *rst) { /* enable and assert RSTOUTn */ writel(SOFT_RESET_OUT_EN, DOVE_BRIDGE_BASE + BRIDGE_RSTOUT_MASK); writel(SOFT_RESET_EN, DOVE_BRIDGE_BASE + BRIDGE_SYS_SOFT_RESET); - while (1) - ; + + hang(); } static int dove_init_soc(struct device_node *root, void *context) @@ -84,7 +85,7 @@ static int dove_init_soc(struct device_node *root, void *context) if (!of_machine_is_compatible("marvell,dove")) return 0; - mvebu_set_reset(dove_reset_cpu); + restart_handler_register_fn(dove_restart_soc); barebox_set_model("Marvell Dove"); barebox_set_hostname("dove"); diff --git a/arch/arm/mach-mvebu/include/mach/common.h b/arch/arm/mach-mvebu/include/mach/common.h index 5ce33fd882..602af8f28f 100644 --- a/arch/arm/mach-mvebu/include/mach/common.h +++ b/arch/arm/mach-mvebu/include/mach/common.h @@ -21,6 +21,5 @@ #define MVEBU_REMAP_INT_REG_BASE 0xf1000000 int mvebu_set_memory(u64 phys_base, u64 phys_size); -void mvebu_set_reset(void __noreturn (*reset)(unsigned long addr)); #endif diff --git a/arch/arm/mach-mvebu/kirkwood.c b/arch/arm/mach-mvebu/kirkwood.c index 19c6f07303..72a6b0db3c 100644 --- a/arch/arm/mach-mvebu/kirkwood.c +++ b/arch/arm/mach-mvebu/kirkwood.c @@ -16,6 +16,7 @@ #include <common.h> #include <init.h> #include <io.h> +#include <restart.h> #include <asm/memory.h> #include <linux/mbus.h> #include <mach/kirkwood-regs.h> @@ -43,12 +44,12 @@ static inline void kirkwood_memory_find(unsigned long *phys_base, } } -static void __noreturn kirkwood_reset_cpu(unsigned long addr) +static void __noreturn kirkwood_restart_soc(struct restart_handler *rst) { writel(SOFT_RESET_OUT_EN, KIRKWOOD_BRIDGE_BASE + BRIDGE_RSTOUT_MASK); writel(SOFT_RESET_EN, KIRKWOOD_BRIDGE_BASE + BRIDGE_SYS_SOFT_RESET); - for(;;) - ; + + hang(); } static int kirkwood_init_soc(struct device_node *root, void *context) @@ -58,7 +59,7 @@ static int kirkwood_init_soc(struct device_node *root, void *context) if (!of_machine_is_compatible("marvell,kirkwood")) return 0; - mvebu_set_reset(kirkwood_reset_cpu); + restart_handler_register_fn(kirkwood_restart_soc); barebox_set_model("Marvell Kirkwood"); barebox_set_hostname("kirkwood"); |