summaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-at91
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2015-08-26 09:04:45 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2015-08-27 21:37:03 +0200
commit83b0a5ae055bc084938dac96b3ea1c796d99d86c (patch)
treeba69e2015cbfeb1626f7ea3f6bf850556541095a /arch/arm/mach-at91
parent167e93947e9b755b54900ae9870dbcc089f8d6c9 (diff)
downloadbarebox-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-at91')
-rw-r--r--arch/arm/mach-at91/at91rm9200_time.c14
-rw-r--r--arch/arm/mach-at91/at91sam9_reset.S4
-rw-r--r--arch/arm/mach-at91/at91sam9g45_reset.S4
-rw-r--r--arch/arm/mach-at91/bootstrap.c3
-rw-r--r--arch/arm/mach-at91/setup.c9
5 files changed, 26 insertions, 8 deletions
diff --git a/arch/arm/mach-at91/at91rm9200_time.c b/arch/arm/mach-at91/at91rm9200_time.c
index ae0172b4f4..fd11223b6f 100644
--- a/arch/arm/mach-at91/at91rm9200_time.c
+++ b/arch/arm/mach-at91/at91rm9200_time.c
@@ -28,6 +28,7 @@
#include <common.h>
#include <init.h>
#include <clock.h>
+#include <restart.h>
#include <mach/hardware.h>
#include <mach/at91_tc.h>
#include <mach/at91_st.h>
@@ -77,7 +78,7 @@ core_initcall(clocksource_init);
/*
* Reset the cpu through the reset controller
*/
-void __noreturn reset_cpu (unsigned long ignored)
+static void __noreturn at91rm9200_restart_soc(struct restart_handler *rst)
{
/*
* Perform a hardware reset with the use of the Watchdog timer.
@@ -86,6 +87,13 @@ void __noreturn reset_cpu (unsigned long ignored)
at91_sys_write(AT91_ST_CR, AT91_ST_WDRST);
/* Not reached */
- while (1);
+ hang();
}
-EXPORT_SYMBOL(reset_cpu);
+
+static int restart_register_feature(void)
+{
+ restart_handler_register_fn(at91rm9200_restart_soc);
+
+ return 0;
+}
+coredevice_initcall(restart_register_feature);
diff --git a/arch/arm/mach-at91/at91sam9_reset.S b/arch/arm/mach-at91/at91sam9_reset.S
index 3a3e77aaa5..890545edbf 100644
--- a/arch/arm/mach-at91/at91sam9_reset.S
+++ b/arch/arm/mach-at91/at91sam9_reset.S
@@ -20,9 +20,9 @@
.arm
- .globl reset_cpu
+ .globl restart_sam9
-reset_cpu: ldr r0, .at91_va_base_sdramc @ preload constants
+restart_sam9: ldr r0, .at91_va_base_sdramc @ preload constants
ldr r1, .at91_va_base_rstc_cr
mov r2, #1
diff --git a/arch/arm/mach-at91/at91sam9g45_reset.S b/arch/arm/mach-at91/at91sam9g45_reset.S
index e70d733ac8..2cb113cdb4 100644
--- a/arch/arm/mach-at91/at91sam9g45_reset.S
+++ b/arch/arm/mach-at91/at91sam9g45_reset.S
@@ -17,9 +17,9 @@
.arm
- .globl reset_cpu
+ .globl restart_sam9g45
-reset_cpu: ldr r0, .at91_va_base_sdramc @ preload constants
+restart_sam9g45: ldr r0, .at91_va_base_sdramc @ preload constants
ldr r1, .at91_va_base_rstc_cr
mov r2, #1
diff --git a/arch/arm/mach-at91/bootstrap.c b/arch/arm/mach-at91/bootstrap.c
index 2d18dd6b32..1baf7323fe 100644
--- a/arch/arm/mach-at91/bootstrap.c
+++ b/arch/arm/mach-at91/bootstrap.c
@@ -9,6 +9,7 @@
#include <mach/bootstrap.h>
#include <linux/sizes.h>
#include <malloc.h>
+#include <restart.h>
#include <init.h>
#include <menu.h>
@@ -145,7 +146,7 @@ static void boot_mmc_disk_action(struct menu *m, struct menu_entry *me)
static void boot_reset_action(struct menu *m, struct menu_entry *me)
{
- reset_cpu(0);
+ restart_machine();
}
void at91_bootstrap_menu(void)
diff --git a/arch/arm/mach-at91/setup.c b/arch/arm/mach-at91/setup.c
index 341979ae89..1fa50ac054 100644
--- a/arch/arm/mach-at91/setup.c
+++ b/arch/arm/mach-at91/setup.c
@@ -8,6 +8,7 @@
#include <common.h>
#include <io.h>
#include <init.h>
+#include <restart.h>
#include <mach/hardware.h>
#include <mach/cpu.h>
@@ -296,6 +297,9 @@ static int at91_detect(void)
}
postcore_initcall(at91_detect);
+void restart_sam9(struct restart_handler *rst);
+void restart_sam9g45(struct restart_handler *rst);
+
static int at91_soc_device(void)
{
struct device_d *dev;
@@ -304,6 +308,11 @@ static int at91_soc_device(void)
dev_add_param_fixed(dev, "name", (char*)at91_get_soc_type(&at91_soc_initdata));
dev_add_param_fixed(dev, "subname", (char*)at91_get_soc_subtype(&at91_soc_initdata));
+ if (IS_ENABLED(CONFIG_AT91SAM9_RESET))
+ restart_handler_register_fn(restart_sam9);
+ if (IS_ENABLED(CONFIG_AT91SAM9G45_RESET))
+ restart_handler_register_fn(restart_sam9g45);
+
return 0;
}
coredevice_initcall(at91_soc_device);