diff options
author | Lucas Stach <l.stach@pengutronix.de> | 2018-02-06 22:11:14 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2018-02-09 09:30:22 +0100 |
commit | e7158f2befe3be75d342c0315de264f61f4c61c3 (patch) | |
tree | e3693402b8f99ada771fe0f0f8253a3b2fe763c6 /arch/arm/mach-bcm283x | |
parent | bdf5be35d7b7d4b74de0e101e9b874d41235b157 (diff) | |
download | barebox-e7158f2befe3be75d342c0315de264f61f4c61c3.tar.gz barebox-e7158f2befe3be75d342c0315de264f61f4c61c3.tar.xz |
watchdog: implement bcm2835 watchdog
Move out of architecture code and add some real watchdog functionality.
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/mach-bcm283x')
-rw-r--r-- | arch/arm/mach-bcm283x/Makefile | 2 | ||||
-rw-r--r-- | arch/arm/mach-bcm283x/include/mach/wd.h | 47 | ||||
-rw-r--r-- | arch/arm/mach-bcm283x/wd.c | 75 |
3 files changed, 1 insertions, 123 deletions
diff --git a/arch/arm/mach-bcm283x/Makefile b/arch/arm/mach-bcm283x/Makefile index 96ea69365e..940f98cbce 100644 --- a/arch/arm/mach-bcm283x/Makefile +++ b/arch/arm/mach-bcm283x/Makefile @@ -1 +1 @@ -obj-y += core.o mbox.o wd.o +obj-y += core.o mbox.o diff --git a/arch/arm/mach-bcm283x/include/mach/wd.h b/arch/arm/mach-bcm283x/include/mach/wd.h deleted file mode 100644 index cdd22d48c0..0000000000 --- a/arch/arm/mach-bcm283x/include/mach/wd.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Extract from arch/arm/mach-bcm2708/include/mach/platform.h - * - * Copyright (C) 2010 Broadcom - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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. - * - */ - -#ifndef _WD_H -#define _WD_H - -/* - * Watchdog - */ -#define PM_RSTC 0x1c -#define PM_RSTS 0x20 -#define PM_WDOG 0x24 - -#define PM_WDOG_RESET 0000000000 -#define PM_PASSWORD 0x5a000000 -#define PM_WDOG_TIME_SET 0x000fffff -#define PM_RSTC_WRCFG_CLR 0xffffffcf -#define PM_RSTC_WRCFG_SET 0x00000030 -#define PM_RSTC_WRCFG_FULL_RESET 0x00000020 -#define PM_RSTC_RESET 0x00000102 - -#define PM_RSTS_HADPOR_SET 0x00001000 -#define PM_RSTS_HADSRH_SET 0x00000400 -#define PM_RSTS_HADSRF_SET 0x00000200 -#define PM_RSTS_HADSRQ_SET 0x00000100 -#define PM_RSTS_HADWRH_SET 0x00000040 -#define PM_RSTS_HADWRF_SET 0x00000020 -#define PM_RSTS_HADWRQ_SET 0x00000010 -#define PM_RSTS_HADDRH_SET 0x00000004 -#define PM_RSTS_HADDRF_SET 0x00000002 -#define PM_RSTS_HADDRQ_SET 0x00000001 - -#endif diff --git a/arch/arm/mach-bcm283x/wd.c b/arch/arm/mach-bcm283x/wd.c deleted file mode 100644 index 5a5188fd2e..0000000000 --- a/arch/arm/mach-bcm283x/wd.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2017 Pengutronix, Lucas Stach <l.stach@pengutronix.de> - * - * Based on code from Carlo Caione <carlo@carlocaione.org> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * 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> -#include <init.h> -#include <io.h> -#include <restart.h> - -#include <mach/wd.h> - -static void __iomem *wd_base; - -#define RESET_TIMEOUT 10 - -static void __noreturn bcm2835_restart_soc(struct restart_handler *rst) -{ - uint32_t rstc; - - rstc = readl(wd_base + PM_RSTC); - rstc &= ~PM_RSTC_WRCFG_SET; - rstc |= PM_RSTC_WRCFG_FULL_RESET; - writel(PM_PASSWORD | RESET_TIMEOUT, wd_base + PM_WDOG); - writel(PM_PASSWORD | rstc, wd_base + PM_RSTC); - - hang(); -} - -static int bcm2835_wd_probe(struct device_d *dev) -{ - struct resource *iores; - - iores = dev_request_mem_resource(dev, 0); - if (IS_ERR(iores)) { - dev_err(dev, "could not get memory region\n"); - return PTR_ERR(iores); - } - wd_base = IOMEM(iores->start); - - restart_handler_register_fn(bcm2835_restart_soc); - - return 0; -} - -static __maybe_unused struct of_device_id bcm2835_wd_dt_ids[] = { - { - .compatible = "brcm,bcm2835-pm-wdt", - }, { - /* sentinel */ - }, -}; - -static struct driver_d bcm2835_wd_driver = { - .name = "bcm2835_wd", - .of_compatible = DRV_OF_COMPAT(bcm2835_wd_dt_ids), - .probe = bcm2835_wd_probe, -}; - -static int __init bcm2835_wd_init(void) -{ - return platform_driver_register(&bcm2835_wd_driver); -} -device_initcall(bcm2835_wd_init); |