diff options
Diffstat (limited to 'arch/arm')
39 files changed, 237 insertions, 186 deletions
diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c index 8327c3f560..7bb9b43656 100644 --- a/arch/arm/lib/bootm.c +++ b/arch/arm/lib/bootm.c @@ -16,6 +16,7 @@ #include <libbb.h> #include <magicvar.h> #include <binfmt.h> +#include <restart.h> #include <asm/byteorder.h> #include <asm/setup.h> @@ -111,7 +112,7 @@ static int __do_bootm_linux(struct image_data *data, unsigned long free_mem, int start_linux((void *)kernel, swap, initrd_start, initrd_size, data->oftree); - reset_cpu(0); + restart_machine(); return -ERESTARTSYS; } @@ -378,7 +379,7 @@ static int do_bootm_barebox(struct image_data *data) start_linux(barebox, 0, 0, 0, data->oftree); - reset_cpu(0); + restart_machine(); } static struct image_handler barebox_handler = { @@ -518,7 +519,7 @@ static int do_bootm_aimage(struct image_data *data) second(); - reset_cpu(0); + restart_machine(); } close(fd); 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); diff --git a/arch/arm/mach-bcm2835/core.c b/arch/arm/mach-bcm2835/core.c index 5d08012f8b..64f3781388 100644 --- a/arch/arm/mach-bcm2835/core.c +++ b/arch/arm/mach-bcm2835/core.c @@ -18,6 +18,7 @@ #include <common.h> #include <init.h> +#include <restart.h> #include <linux/clk.h> #include <linux/clkdev.h> @@ -51,13 +52,6 @@ static int bcm2835_clk_init(void) } postcore_initcall(bcm2835_clk_init); -static int bcm2835_dev_init(void) -{ - add_generic_device("bcm2835-gpio", 0, NULL, BCM2835_GPIO_BASE, 0xB0, IORESOURCE_MEM, NULL); - return 0; -} -coredevice_initcall(bcm2835_dev_init); - void bcm2835_register_uart(void) { amba_apb_device_add(NULL, "uart0-pl011", 0, BCM2835_UART0_BASE, 4096, NULL, 0); @@ -72,7 +66,7 @@ void bcm2835_add_device_sdram(u32 size) } #define RESET_TIMEOUT 10 -void __noreturn reset_cpu(unsigned long addr) +static void __noreturn bcm2835_restart_soc(struct restart_handler *rst) { uint32_t rstc; @@ -82,6 +76,13 @@ void __noreturn reset_cpu(unsigned long addr) writel(PM_PASSWORD | RESET_TIMEOUT, PM_WDOG); writel(PM_PASSWORD | rstc, PM_RSTC); - while (1); + hang(); } -EXPORT_SYMBOL(reset_cpu); + +static int bcm2835_dev_init(void) +{ + add_generic_device("bcm2835-gpio", 0, NULL, BCM2835_GPIO_BASE, 0xB0, IORESOURCE_MEM, NULL); + restart_handler_register_fn(bcm2835_restart_soc); + return 0; +} +coredevice_initcall(bcm2835_dev_init); diff --git a/arch/arm/mach-clps711x/reset.c b/arch/arm/mach-clps711x/reset.c index 859d8ae574..03f40b73fa 100644 --- a/arch/arm/mach-clps711x/reset.c +++ b/arch/arm/mach-clps711x/reset.c @@ -8,8 +8,10 @@ */ #include <common.h> +#include <init.h> +#include <restart.h> -void __noreturn reset_cpu(unsigned long addr) +static void __noreturn clps711x_restart_soc(struct restart_handler *rst) { shutdown_barebox(); @@ -17,3 +19,11 @@ void __noreturn reset_cpu(unsigned long addr) hang(); } + +static int restart_register_feature(void) +{ + restart_handler_register_fn(clps711x_restart_soc); + + return 0; +} +coredevice_initcall(restart_register_feature); diff --git a/arch/arm/mach-davinci/time.c b/arch/arm/mach-davinci/time.c index 60f0d192a3..4d1b570aa0 100644 --- a/arch/arm/mach-davinci/time.c +++ b/arch/arm/mach-davinci/time.c @@ -12,6 +12,7 @@ #include <common.h> #include <io.h> #include <init.h> +#include <restart.h> #include <clock.h> #include <mach/time.h> @@ -164,7 +165,7 @@ static int clocksource_init(void) core_initcall(clocksource_init); /* reset board using watchdog timer */ -void __noreturn reset_cpu(ulong addr) +static void __noreturn davinci_restart_soc(struct restart_handler *rst) { u32 tgcr, wdtcr; void __iomem *base; @@ -204,6 +205,13 @@ void __noreturn reset_cpu(ulong addr) wdtcr = 0x00004000; __raw_writel(wdtcr, base + WDTCR); - unreachable(); + hang(); } -EXPORT_SYMBOL(reset_cpu); + +static int restart_register_feature(void) +{ + restart_handler_register_fn(davinci_restart_soc); + + return 0; +} +coredevice_initcall(restart_register_feature); diff --git a/arch/arm/mach-digic/Makefile b/arch/arm/mach-digic/Makefile index 820eb10ac2..16a218658a 100644 --- a/arch/arm/mach-digic/Makefile +++ b/arch/arm/mach-digic/Makefile @@ -1 +1 @@ -obj-y += core.o +obj- := __dummy__.o diff --git a/arch/arm/mach-digic/core.c b/arch/arm/mach-digic/core.c deleted file mode 100644 index b1caec0bc8..0000000000 --- a/arch/arm/mach-digic/core.c +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) 2013 Antony Pavlov <antonynpavlov@gmail.com> - * - * This file is part of barebox. - * See file CREDITS for list of people who contributed to this project. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ - -#include <common.h> - -void __noreturn reset_cpu(unsigned long ignored) -{ - pr_err("%s: unimplemented\n", __func__); - hang(); -} -EXPORT_SYMBOL(reset_cpu); diff --git a/arch/arm/mach-ep93xx/clocksource.c b/arch/arm/mach-ep93xx/clocksource.c index f396d0a0a2..83c05cea00 100644 --- a/arch/arm/mach-ep93xx/clocksource.c +++ b/arch/arm/mach-ep93xx/clocksource.c @@ -20,6 +20,7 @@ #include <init.h> #include <clock.h> #include <io.h> +#include <restart.h> #include <mach/ep93xx-regs.h> #define TIMER_CLKSEL (1 << 3) @@ -63,10 +64,8 @@ static int clocksource_init(void) core_initcall(clocksource_init); -/* - * Reset the cpu - */ -void __noreturn reset_cpu(unsigned long addr) +/* Reset the SoC */ +static void __noreturn ep92xx_restart_soc(struct restart_handler *rst) { struct syscon_regs *syscon = (struct syscon_regs *)SYSCON_BASE; uint32_t value; @@ -84,7 +83,13 @@ void __noreturn reset_cpu(unsigned long addr) writel(value, &syscon->devicecfg); /* Dying... */ - while (1) - ; /* noop */ + hang(); +} + +static int restart_register_feature(void) +{ + restart_handler_register_fn(ep92xx_restart_soc); + + return 0; } -EXPORT_SYMBOL(reset_cpu); +coredevice_initcall(restart_register_feature); diff --git a/arch/arm/mach-highbank/reset.c b/arch/arm/mach-highbank/reset.c index b9664e41bb..929ded5951 100644 --- a/arch/arm/mach-highbank/reset.c +++ b/arch/arm/mach-highbank/reset.c @@ -6,17 +6,27 @@ #include <common.h> #include <io.h> +#include <restart.h> +#include <init.h> #include <mach/devices.h> #include <mach/sysregs.h> -void __noreturn reset_cpu(ulong addr) +static void __noreturn highbank_restart_soc(struct restart_handler *rst) { hingbank_set_pwr_hard_reset(); asm(" wfi"); - while(1); + hang(); +} + +static int restart_register_feature(void) +{ + restart_handler_register_fn(highbank_restart_soc); + + return 0; } +coredevice_initcall(restart_register_feature); void __noreturn poweroff() { 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"); diff --git a/arch/arm/mach-mxs/soc-imx23.c b/arch/arm/mach-mxs/soc-imx23.c index 339c57748f..d471c8eb5c 100644 --- a/arch/arm/mach-mxs/soc-imx23.c +++ b/arch/arm/mach-mxs/soc-imx23.c @@ -16,6 +16,7 @@ #include <common.h> #include <init.h> +#include <restart.h> #include <mach/imx23-regs.h> #include <io.h> @@ -23,18 +24,16 @@ # define HW_CLKCTRL_RESET_CHIP (1 << 1) /* Reset the full i.MX23 SoC via a chipset feature */ -void __noreturn reset_cpu(unsigned long addr) +static void __noreturn imx23_restart_soc(struct restart_handler *rst) { u32 reg; reg = readl(IMX_CCM_BASE + HW_CLKCTRL_RESET); writel(reg | HW_CLKCTRL_RESET_CHIP, IMX_CCM_BASE + HW_CLKCTRL_RESET); - while (1) - ; + hang(); /*NOTREACHED*/ } -EXPORT_SYMBOL(reset_cpu); static int imx23_devices_init(void) { @@ -46,6 +45,7 @@ static int imx23_devices_init(void) add_generic_device("imx23-gpio", 0, NULL, IMX_IOMUXC_BASE, 0x2000, IORESOURCE_MEM, NULL); add_generic_device("imx23-gpio", 1, NULL, IMX_IOMUXC_BASE, 0x2000, IORESOURCE_MEM, NULL); add_generic_device("imx23-gpio", 2, NULL, IMX_IOMUXC_BASE, 0x2000, IORESOURCE_MEM, NULL); + restart_handler_register_fn(imx23_restart_soc); return 0; } diff --git a/arch/arm/mach-mxs/soc-imx28.c b/arch/arm/mach-mxs/soc-imx28.c index b4ec38d912..dc6020aa36 100644 --- a/arch/arm/mach-mxs/soc-imx28.c +++ b/arch/arm/mach-mxs/soc-imx28.c @@ -16,6 +16,7 @@ #include <common.h> #include <init.h> +#include <restart.h> #include <mach/imx28-regs.h> #include <io.h> @@ -24,18 +25,16 @@ #define HW_CLKCTRL_WDOG_POR_DISABLE (1 << 5) /* Reset the full i.MX28 SoC via a chipset feature */ -void __noreturn reset_cpu(unsigned long addr) +static void __noreturn imx28_restart_soc(struct restart_handler *rst) { u32 reg; reg = readl(IMX_CCM_BASE + HW_CLKCTRL_RESET); writel(reg | HW_CLKCTRL_RESET_CHIP, IMX_CCM_BASE + HW_CLKCTRL_RESET); - while (1) - ; + hang(); /*NOTREACHED*/ } -EXPORT_SYMBOL(reset_cpu); static int imx28_init(void) { @@ -50,6 +49,8 @@ static int imx28_init(void) HW_CLKCTRL_WDOG_POR_DISABLE; writel(reg, IMX_CCM_BASE + HW_CLKCTRL_RESET); + restart_handler_register_fn(imx28_restart_soc); + return 0; } postcore_initcall(imx28_init); diff --git a/arch/arm/mach-netx/generic.c b/arch/arm/mach-netx/generic.c index 6127dde868..6c3b953d1f 100644 --- a/arch/arm/mach-netx/generic.c +++ b/arch/arm/mach-netx/generic.c @@ -15,8 +15,10 @@ */ #include <common.h> +#include <init.h> #include <command.h> #include <io.h> +#include <restart.h> #include <mach/netx-regs.h> #include "eth_firmware.h" @@ -134,17 +136,24 @@ failure: return COMMAND_ERROR_USAGE; } -void __noreturn reset_cpu(unsigned long addr) +BAREBOX_CMD_START(loadxc) + .cmd = do_loadxc, + BAREBOX_CMD_DESC("load XMAC/XPEC engine with ethernet firmware") + BAREBOX_CMD_GROUP(CMD_GRP_NET) +BAREBOX_CMD_END + +static void __noreturn netx_restart_soc(struct restart_handler *rst) { SYSTEM_REG(SYSTEM_RES_CR) = 0x01000008; /* Not reached */ - while (1); + hang(); } +static int restart_register_feature(void) +{ + restart_handler_register_fn(netx_restart_soc); -BAREBOX_CMD_START(loadxc) - .cmd = do_loadxc, - BAREBOX_CMD_DESC("load XMAC/XPEC engine with ethernet firmware") - BAREBOX_CMD_GROUP(CMD_GRP_NET) -BAREBOX_CMD_END + return 0; +} +coredevice_initcall(restart_register_feature); diff --git a/arch/arm/mach-nomadik/reset.c b/arch/arm/mach-nomadik/reset.c index bb5696a345..8bdaada8a1 100644 --- a/arch/arm/mach-nomadik/reset.c +++ b/arch/arm/mach-nomadik/reset.c @@ -15,10 +15,12 @@ */ #include <common.h> +#include <init.h> #include <io.h> +#include <restart.h> #include <mach/hardware.h> -void __noreturn reset_cpu(unsigned long addr) +static void __noreturn nomadik_restart_soc(struct restart_handler *rst) { void __iomem *src_rstsr = (void *)(NOMADIK_SRC_BASE + 0x18); @@ -28,6 +30,13 @@ void __noreturn reset_cpu(unsigned long addr) writel(1, src_rstsr); /* Not reached */ - while (1); + hang(); } -EXPORT_SYMBOL(reset_cpu); + +static int restart_register_feature(void) +{ + restart_handler_register_fn(nomadik_restart_soc); + + return 0; +} +coredevice_initcall(restart_register_feature); diff --git a/arch/arm/mach-omap/am33xx_generic.c b/arch/arm/mach-omap/am33xx_generic.c index 7ce32f01e1..ae0ee585a8 100644 --- a/arch/arm/mach-omap/am33xx_generic.c +++ b/arch/arm/mach-omap/am33xx_generic.c @@ -19,6 +19,7 @@ #include <init.h> #include <io.h> #include <net.h> +#include <restart.h> #include <asm/barebox-arm.h> #include <mach/am33xx-silicon.h> #include <mach/am33xx-clock.h> @@ -28,11 +29,11 @@ #include <mach/gpmc.h> #include <reset_source.h> -void __noreturn am33xx_reset_cpu(unsigned long addr) +static void __noreturn am33xx_restart_soc(struct restart_handler *rst) { writel(AM33XX_PRM_RSTCTRL_RESET, AM33XX_PRM_RSTCTRL); - while (1); + hang(); } /** @@ -243,6 +244,8 @@ int am33xx_init(void) { omap_gpmc_base = (void *)AM33XX_GPMC_BASE; + restart_handler_register_fn(am33xx_restart_soc); + am33xx_enable_per_clocks(); if (IS_ENABLED(CONFIG_RESET_SOURCE)) diff --git a/arch/arm/mach-omap/include/mach/am33xx-generic.h b/arch/arm/mach-omap/include/mach/am33xx-generic.h index 03418b053b..7e64e74d5c 100644 --- a/arch/arm/mach-omap/include/mach/am33xx-generic.h +++ b/arch/arm/mach-omap/include/mach/am33xx-generic.h @@ -28,8 +28,6 @@ u32 am33xx_running_in_flash(void); u32 am33xx_running_in_sram(void); u32 am33xx_running_in_sdram(void); -void __noreturn am33xx_reset_cpu(unsigned long addr); - void am33xx_enable_per_clocks(void); int am33xx_init(void); int am33xx_devices_init(void); diff --git a/arch/arm/mach-omap/include/mach/omap3-generic.h b/arch/arm/mach-omap/include/mach/omap3-generic.h index ab53b98971..177862e4b1 100644 --- a/arch/arm/mach-omap/include/mach/omap3-generic.h +++ b/arch/arm/mach-omap/include/mach/omap3-generic.h @@ -24,8 +24,6 @@ u32 omap3_running_in_flash(void); u32 omap3_running_in_sram(void); u32 omap3_running_in_sdram(void); -void __noreturn omap3_reset_cpu(unsigned long addr); - int omap3_init(void); int omap3_devices_init(void); diff --git a/arch/arm/mach-omap/include/mach/omap4-generic.h b/arch/arm/mach-omap/include/mach/omap4-generic.h index e246e360e5..7ec41d880b 100644 --- a/arch/arm/mach-omap/include/mach/omap4-generic.h +++ b/arch/arm/mach-omap/include/mach/omap4-generic.h @@ -18,8 +18,6 @@ static inline void omap4_save_bootinfo(uint32_t *info) memcpy((void *)OMAP44XX_SRAM_SCRATCH_SPACE, info, 3 * sizeof(uint32_t)); } -void __noreturn omap4_reset_cpu(unsigned long addr); - int omap4_init(void); int omap4_devices_init(void); diff --git a/arch/arm/mach-omap/omap3_generic.c b/arch/arm/mach-omap/omap3_generic.c index 0f2e9ce6b7..5c29feaeb4 100644 --- a/arch/arm/mach-omap/omap3_generic.c +++ b/arch/arm/mach-omap/omap3_generic.c @@ -31,6 +31,7 @@ #include <bootsource.h> #include <init.h> #include <io.h> +#include <restart.h> #include <mach/omap3-silicon.h> #include <mach/gpmc.h> #include <mach/generic.h> @@ -52,13 +53,12 @@ * * @return void */ -void __noreturn omap3_reset_cpu(unsigned long addr) +static void __noreturn omap3_restart_soc(struct restart_handler *rst) { writel(OMAP3_PRM_RSTCTRL_RESET, OMAP3_PRM_REG(RSTCTRL)); - while (1); + hang(); } -EXPORT_SYMBOL(reset_cpu); /** * @brief Low level CPU type @@ -490,6 +490,8 @@ int omap3_init(void) { omap_gpmc_base = (void *)OMAP3_GPMC_BASE; + restart_handler_register_fn(omap3_restart_soc); + return omap3_bootsource(); } diff --git a/arch/arm/mach-omap/omap4_generic.c b/arch/arm/mach-omap/omap4_generic.c index 0b683da181..a3f370df8f 100644 --- a/arch/arm/mach-omap/omap4_generic.c +++ b/arch/arm/mach-omap/omap4_generic.c @@ -1,6 +1,7 @@ #include <common.h> #include <bootsource.h> #include <init.h> +#include <restart.h> #include <io.h> #include <mach/omap4-clock.h> #include <mach/omap4-silicon.h> @@ -34,11 +35,11 @@ #define EMIF_L3_CONFIG_VAL_SYS_10_LL_0 0x0A0000FF #define EMIF_L3_CONFIG_VAL_SYS_10_MPU_3_LL_0 0x0A300000 -void __noreturn omap4_reset_cpu(unsigned long addr) +static void __noreturn omap4_restart_soc(struct restart_handler *rst) { writel(OMAP44XX_PRM_RSTCTRL_RESET, OMAP44XX_PRM_RSTCTRL); - while (1); + hang(); } void omap4_set_warmboot_order(u32 *device_list) @@ -533,6 +534,8 @@ int omap4_init(void) { omap_gpmc_base = (void *)OMAP44XX_GPMC_BASE; + restart_handler_register_fn(omap4_restart_soc); + return omap4_bootsource(); } diff --git a/arch/arm/mach-omap/omap_generic.c b/arch/arm/mach-omap/omap_generic.c index 334cf8db56..165487c645 100644 --- a/arch/arm/mach-omap/omap_generic.c +++ b/arch/arm/mach-omap/omap_generic.c @@ -150,17 +150,6 @@ static int omap_env_init(void) late_initcall(omap_env_init); #endif -void __noreturn reset_cpu(unsigned long addr) -{ - if (cpu_is_omap3()) - omap3_reset_cpu(addr); - if (cpu_is_omap4()) - omap4_reset_cpu(addr); - if (cpu_is_am33xx()) - am33xx_reset_cpu(addr); - while (1); -} - static int omap_soc_from_dt(void) { if (of_machine_is_compatible("ti,am33xx")) diff --git a/arch/arm/mach-pxa/common.c b/arch/arm/mach-pxa/common.c index 2c27d812fc..c0281d69ef 100644 --- a/arch/arm/mach-pxa/common.c +++ b/arch/arm/mach-pxa/common.c @@ -16,6 +16,8 @@ */ #include <common.h> +#include <init.h> +#include <restart.h> #include <mach/pxa-regs.h> #include <asm/io.h> @@ -29,7 +31,7 @@ extern void pxa_clear_reset_source(void); -void reset_cpu(ulong addr) +static void __noreturn pxa_restart_soc(struct restart_handler *rst) { /* Clear last reset source */ pxa_clear_reset_source(); @@ -39,5 +41,13 @@ void reset_cpu(ulong addr) writel(OSSR_M3, OSSR); writel(readl(OSCR) + 368640, OSMR3); /* ... in 100 ms */ - while (1); + hang(); } + +static int restart_register_feature(void) +{ + restart_handler_register_fn(pxa_restart_soc); + + return 0; +} +coredevice_initcall(restart_register_feature); diff --git a/arch/arm/mach-rockchip/core.c b/arch/arm/mach-rockchip/core.c index bab06df63c..2428fee349 100644 --- a/arch/arm/mach-rockchip/core.c +++ b/arch/arm/mach-rockchip/core.c @@ -13,16 +13,24 @@ #include <asm/io.h> #include <common.h> +#include <init.h> +#include <restart.h> #include <mach/rockchip-regs.h> -void __noreturn reset_cpu(unsigned long addr) +static void __noreturn rockchip_restart_soc(struct restart_handler *rst) { /* Map bootrom from address 0 */ writel(RK_SOC_CON0_REMAP << 16, RK_GRF_BASE + RK_GRF_SOC_CON0); /* Reset */ writel(0xeca8, RK_CRU_BASE + RK_CRU_GLB_SRST_SND); - while (1) - ; + hang(); } -EXPORT_SYMBOL(reset_cpu); + +static int restart_register_feature(void) +{ + restart_handler_register_fn(rockchip_restart_soc); + + return 0; +} +coredevice_initcall(restart_register_feature); diff --git a/arch/arm/mach-samsung/generic.c b/arch/arm/mach-samsung/generic.c index 75965d7826..4f13fce13b 100644 --- a/arch/arm/mach-samsung/generic.c +++ b/arch/arm/mach-samsung/generic.c @@ -21,6 +21,7 @@ #include <config.h> #include <common.h> #include <init.h> +#include <restart.h> #include <io.h> #include <mach/s3c-iomap.h> #include <mach/s3c-generic.h> @@ -29,7 +30,7 @@ #define S3C_WTDAT (S3C_WATCHDOG_BASE + 0x04) #define S3C_WTCNT (S3C_WATCHDOG_BASE + 0x08) -void __noreturn reset_cpu(unsigned long addr) +static void __noreturn samsung_restart_soc(struct restart_handler *rst) { /* Disable watchdog */ writew(0x0000, S3C_WTCON); @@ -41,7 +42,13 @@ void __noreturn reset_cpu(unsigned long addr) writew(0x0021, S3C_WTCON); /* loop forever and wait for reset to happen */ - while(1) - ; + hang(); } -EXPORT_SYMBOL(reset_cpu); + +static int restart_register_feature(void) +{ + restart_handler_register_fn(samsung_restart_soc); + + return 0; +} +coredevice_initcall(restart_register_feature); diff --git a/arch/arm/mach-socfpga/reset-manager.c b/arch/arm/mach-socfpga/reset-manager.c index a9e7e1448f..04522da4d1 100644 --- a/arch/arm/mach-socfpga/reset-manager.c +++ b/arch/arm/mach-socfpga/reset-manager.c @@ -17,6 +17,8 @@ #include <common.h> #include <io.h> +#include <init.h> +#include <restart.h> #include <mach/socfpga-regs.h> #include <mach/reset-manager.h> @@ -38,7 +40,7 @@ void watchdog_disable(void) } /* Write the reset manager register to cause reset */ -void reset_cpu(ulong addr) +static void __noreturn socfpga_restart_soc(struct restart_handler *rst) { /* request a warm reset */ writel((1 << RSTMGR_CTRL_SWWARMRSTREQ_LSB), @@ -47,5 +49,13 @@ void reset_cpu(ulong addr) * infinite loop here as watchdog will trigger and reset * the processor */ - while (1); + hang(); } + +static int restart_register_feature(void) +{ + restart_handler_register_fn(socfpga_restart_soc); + + return 0; +} +coredevice_initcall(restart_register_feature); diff --git a/arch/arm/mach-tegra/tegra20-pmc.c b/arch/arm/mach-tegra/tegra20-pmc.c index eaa5ac73ff..02f0bf7499 100644 --- a/arch/arm/mach-tegra/tegra20-pmc.c +++ b/arch/arm/mach-tegra/tegra20-pmc.c @@ -23,6 +23,7 @@ #include <common.h> #include <init.h> #include <io.h> +#include <restart.h> #include <linux/err.h> #include <linux/clk.h> #include <linux/reset.h> @@ -36,13 +37,12 @@ static void __iomem *pmc_base; static int tegra_num_powerdomains; /* main SoC reset trigger */ -void __noreturn reset_cpu(ulong addr) +static void __noreturn tegra20_restart_soc(struct restart_handler *rst) { writel(PMC_CNTRL_MAIN_RST, pmc_base + PMC_CNTRL); - unreachable(); + hang(); } -EXPORT_SYMBOL(reset_cpu); static int tegra_powergate_set(int id, bool new_state) { @@ -219,7 +219,7 @@ static int tegra20_pmc_probe(struct device_d *dev) static int do_tegrarcm(int argc, char *argv[]) { writel(2, pmc_base + PMC_SCRATCH(0)); - reset_cpu(0); + restart_machine(); return 0; } @@ -244,6 +244,7 @@ static struct driver_d tegra20_pmc_driver = { static int tegra20_pmc_init(void) { + restart_handler_register_fn(tegra20_restart_soc); return platform_driver_register(&tegra20_pmc_driver); } coredevice_initcall(tegra20_pmc_init); diff --git a/arch/arm/mach-uemd/Makefile b/arch/arm/mach-uemd/Makefile index f3cc6684b8..16a218658a 100644 --- a/arch/arm/mach-uemd/Makefile +++ b/arch/arm/mach-uemd/Makefile @@ -1 +1 @@ -obj-y += reset.o +obj- := __dummy__.o diff --git a/arch/arm/mach-uemd/reset.c b/arch/arm/mach-uemd/reset.c deleted file mode 100644 index 00ae0be0b3..0000000000 --- a/arch/arm/mach-uemd/reset.c +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (C) 2014 Antony Pavlov <antonynpavlov@gmail.com> - * - * This file is part of barebox. - * See file CREDITS for list of people who contributed to this project. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ - -#include <common.h> - -void __noreturn reset_cpu(ulong addr) -{ - hang(); -} -EXPORT_SYMBOL(reset_cpu); diff --git a/arch/arm/mach-versatile/core.c b/arch/arm/mach-versatile/core.c index c671aa6173..7c6e9523a2 100644 --- a/arch/arm/mach-versatile/core.c +++ b/arch/arm/mach-versatile/core.c @@ -26,6 +26,7 @@ #include <init.h> #include <clock.h> #include <debug_ll.h> +#include <restart.h> #include <linux/sizes.h> #include <linux/clkdev.h> @@ -184,7 +185,7 @@ void versatile_register_uart(unsigned id) amba_apb_device_add(NULL, "uart-pl011", id, start, 4096, NULL, 0); } -void __noreturn reset_cpu (unsigned long ignored) +static void versatile_reset_soc(struct restart_handler *rst) { u32 val; @@ -195,9 +196,8 @@ void __noreturn reset_cpu (unsigned long ignored) __raw_writel(val, VERSATILE_SYS_RESETCTL); __raw_writel(0, VERSATILE_SYS_LOCK); - while(1); + hang(); } -EXPORT_SYMBOL(reset_cpu); static int versatile_init(void) { @@ -205,6 +205,7 @@ static int versatile_init(void) amba_apb_device_add(NULL, "pl061_gpio", 1, 0x101e5000, 4096, NULL, 0); amba_apb_device_add(NULL, "pl061_gpio", 2, 0x101e6000, 4096, NULL, 0); amba_apb_device_add(NULL, "pl061_gpio", 3, 0x101e7000, 4096, NULL, 0); + restart_handler_register_fn(versatile_reset_soc); return 0; } coredevice_initcall(versatile_init); diff --git a/arch/arm/mach-vexpress/reset.c b/arch/arm/mach-vexpress/reset.c index ad6e06fe5f..3164ae3079 100644 --- a/arch/arm/mach-vexpress/reset.c +++ b/arch/arm/mach-vexpress/reset.c @@ -6,17 +6,26 @@ #include <common.h> #include <io.h> +#include <init.h> +#include <restart.h> #include <linux/amba/sp805.h> #include <mach/devices.h> void __iomem *v2m_wdt_base; -void reset_cpu(ulong addr) +static void vexpress_reset_soc(struct restart_handler *rst) { writel(LOAD_MIN, v2m_wdt_base + WDTLOAD); writeb(RESET_ENABLE, v2m_wdt_base + WDTCONTROL); - while (1) - ; + hang(); } + +static int restart_register_feature(void) +{ + restart_handler_register_fn(vexpress_reset_soc); + + return 0; +} +coredevice_initcall(restart_register_feature); diff --git a/arch/arm/mach-zynq/zynq.c b/arch/arm/mach-zynq/zynq.c index bd29e13377..a0a8d0d249 100644 --- a/arch/arm/mach-zynq/zynq.c +++ b/arch/arm/mach-zynq/zynq.c @@ -17,8 +17,19 @@ #include <asm-generic/io.h> #include <common.h> #include <init.h> +#include <restart.h> #include <mach/zynq7000-regs.h> +static void __noreturn zynq_restart_soc(struct restart_handler *rst) +{ + /* write unlock key to slcr */ + writel(0xDF0D, ZYNQ_SLCR_UNLOCK); + /* reset */ + writel(0x1, ZYNQ_PSS_RST_CTRL); + + hang(); +} + static int zynq_init(void) { u32 val; @@ -40,17 +51,8 @@ static int zynq_init(void) add_generic_device("zynq-clock", 0, NULL, ZYNQ_SLCR_BASE, 0x4000, IORESOURCE_MEM, NULL); add_generic_device("smp_twd", 0, NULL, CORTEXA9_SCU_TIMER_BASE_ADDR, 0x4000, IORESOURCE_MEM, NULL); + restart_handler_register_fn(zynq_restart_soc); + return 0; } postcore_initcall(zynq_init); - -void __noreturn reset_cpu(unsigned long addr) -{ - /* write unlock key to slcr */ - writel(0xDF0D, ZYNQ_SLCR_UNLOCK); - /* reset */ - writel(0x1, ZYNQ_PSS_RST_CTRL); - - while (1) - ; -} |