summaryrefslogtreecommitdiffstats
path: root/arch/mips
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/mips
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/mips')
-rw-r--r--arch/mips/lib/bootm.c3
-rw-r--r--arch/mips/mach-ar231x/ar231x_reset.c8
-rw-r--r--arch/mips/mach-ath79/reset.c15
-rw-r--r--arch/mips/mach-bcm47xx/reset.c16
-rw-r--r--arch/mips/mach-loongson/loongson1_reset.c15
-rw-r--r--arch/mips/mach-malta/reset.c16
6 files changed, 57 insertions, 16 deletions
diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c
index 0e03aa9bcb..84f72f5ac0 100644
--- a/arch/mips/lib/bootm.c
+++ b/arch/mips/lib/bootm.c
@@ -5,6 +5,7 @@
#include <fs.h>
#include <errno.h>
#include <binfmt.h>
+#include <restart.h>
#include <asm/byteorder.h>
@@ -20,7 +21,7 @@ static int do_bootm_barebox(struct image_data *data)
barebox();
- reset_cpu(0);
+ restart_machine();
}
static struct image_handler barebox_handler = {
diff --git a/arch/mips/mach-ar231x/ar231x_reset.c b/arch/mips/mach-ar231x/ar231x_reset.c
index 0788add164..318f772108 100644
--- a/arch/mips/mach-ar231x/ar231x_reset.c
+++ b/arch/mips/mach-ar231x/ar231x_reset.c
@@ -10,6 +10,7 @@
#include <common.h>
#include <init.h>
#include <io.h>
+#include <restart.h>
#include <linux/err.h>
#include <mach/ar2312_regs.h>
@@ -17,16 +18,16 @@
static void __iomem *reset_base;
-void __noreturn reset_cpu(ulong addr)
+static void __noreturn ar2312x_restart_soc(struct restart_handler *rst)
{
printf("reseting cpu\n");
__raw_writel(0x10000,
(char *)KSEG1ADDR(AR2312_WD_TIMER));
__raw_writel(AR2312_WD_CTRL_RESET,
(char *)KSEG1ADDR(AR2312_WD_CTRL));
- unreachable();
+
+ hang();
}
-EXPORT_SYMBOL(reset_cpu);
static u32 ar231x_reset_readl(void)
{
@@ -69,6 +70,7 @@ static struct driver_d ar231x_reset_driver = {
static int ar231x_reset_init(void)
{
+ restart_handler_register_fn(ar2312x_restart_soc);
return platform_driver_register(&ar231x_reset_driver);
}
coredevice_initcall(ar231x_reset_init);
diff --git a/arch/mips/mach-ath79/reset.c b/arch/mips/mach-ath79/reset.c
index a0e9b349ca..0665788227 100644
--- a/arch/mips/mach-ath79/reset.c
+++ b/arch/mips/mach-ath79/reset.c
@@ -16,9 +16,11 @@
*/
#include <common.h>
+#include <init.h>
+#include <restart.h>
#include <mach/ath79.h>
-void __noreturn reset_cpu(ulong addr)
+static void __noreturn ath79_restart_soc(struct restart_handler *rst)
{
ath79_reset_wr(AR933X_RESET_REG_RESET_MODULE, AR71XX_RESET_FULL_CHIP);
/*
@@ -26,7 +28,14 @@ void __noreturn reset_cpu(ulong addr)
* pulling the reset pin. The system will reboot with PLL disabled.
* Always zero when read.
*/
- unreachable();
+ hang();
/*NOTREACHED*/
}
-EXPORT_SYMBOL(reset_cpu);
+
+static int restart_register_feature(void)
+{
+ restart_handler_register_fn(ath79_restart_soc);
+
+ return 0;
+}
+coredevice_initcall(restart_register_feature);
diff --git a/arch/mips/mach-bcm47xx/reset.c b/arch/mips/mach-bcm47xx/reset.c
index 00aee190fe..6287adb374 100644
--- a/arch/mips/mach-bcm47xx/reset.c
+++ b/arch/mips/mach-bcm47xx/reset.c
@@ -17,12 +17,22 @@
#include <common.h>
#include <io.h>
+#include <init.h>
+#include <restart.h>
#include <mach/hardware.h>
-void __noreturn reset_cpu(ulong addr)
+static void __noreturn bcm47xx_restart_soc(struct restart_handler *rst)
{
__raw_writel(GORESET, (char *)SOFTRES_REG);
- while (1);
+
+ hang();
/*NOTREACHED*/
}
-EXPORT_SYMBOL(reset_cpu);
+
+static int restart_register_feature(void)
+{
+ restart_handler_register_fn(bcm47xx_restart_soc);
+
+ return 0;
+}
+coredevice_initcall(restart_register_feature);
diff --git a/arch/mips/mach-loongson/loongson1_reset.c b/arch/mips/mach-loongson/loongson1_reset.c
index 8975392ca6..7a8f1d6836 100644
--- a/arch/mips/mach-loongson/loongson1_reset.c
+++ b/arch/mips/mach-loongson/loongson1_reset.c
@@ -14,14 +14,23 @@
#include <common.h>
#include <io.h>
+#include <init.h>
+#include <restart.h>
#include <mach/loongson1.h>
-void __noreturn reset_cpu(ulong addr)
+static void __noreturn longhorn_restart_soc(struct restart_handler *rst)
{
__raw_writel(0x1, LS1X_WDT_EN);
__raw_writel(0x1, LS1X_WDT_SET);
__raw_writel(0x1, LS1X_WDT_TIMER);
- unreachable();
+ hang();
}
-EXPORT_SYMBOL(reset_cpu);
+
+static int restart_register_feature(void)
+{
+ restart_handler_register_fn(longhorn_restart_soc);
+
+ return 0;
+}
+coredevice_initcall(restart_register_feature);
diff --git a/arch/mips/mach-malta/reset.c b/arch/mips/mach-malta/reset.c
index f1dc68afb5..ff29cd5e9b 100644
--- a/arch/mips/mach-malta/reset.c
+++ b/arch/mips/mach-malta/reset.c
@@ -22,12 +22,22 @@
#include <common.h>
#include <io.h>
+#include <init.h>
+#include <restart.h>
#include <mach/hardware.h>
-void __noreturn reset_cpu(ulong addr)
+static void __noreturn malta_restart_soc(struct restart_handler *rst)
{
__raw_writel(GORESET, (char *)SOFTRES_REG);
- while (1);
+
+ hang();
/*NOTREACHED*/
}
-EXPORT_SYMBOL(reset_cpu);
+
+static int restart_register_feature(void)
+{
+ restart_handler_register_fn(malta_restart_soc);
+
+ return 0;
+}
+coredevice_initcall(restart_register_feature);