diff options
author | Alexander Shiyan <eagle.alexander923@gmail.com> | 2022-06-09 12:19:46 +0300 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2022-06-14 10:41:50 +0200 |
commit | 5a4d742347441327951981ca8d803091d2f4643d (patch) | |
tree | 3261273441f56648c9b4f981f2331fb047496742 /arch/arm/mach-omap | |
parent | 11a1f28cbf22f662665681b389a428db1e35c719 (diff) | |
download | barebox-5a4d742347441327951981ca8d803091d2f4643d.tar.gz barebox-5a4d742347441327951981ca8d803091d2f4643d.tar.xz |
ARM: OMAP: Rework watchdog code
This patch introduces the omap_watchdog_disable() function,
since the WDT core is the same for different OMAP variants,
it can be used for all supported SOCs.
Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com>
Link: https://lore.barebox.org/20220609091946.20028-1-eagle.alexander923@gmail.com
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/mach-omap')
-rw-r--r-- | arch/arm/mach-omap/Makefile | 2 | ||||
-rw-r--r-- | arch/arm/mach-omap/include/mach/generic.h | 2 | ||||
-rw-r--r-- | arch/arm/mach-omap/include/mach/wdt.h | 43 | ||||
-rw-r--r-- | arch/arm/mach-omap/omap3_generic.c | 12 | ||||
-rw-r--r-- | arch/arm/mach-omap/omap4_generic.c | 22 | ||||
-rw-r--r-- | arch/arm/mach-omap/omap_generic.c | 18 |
6 files changed, 24 insertions, 75 deletions
diff --git a/arch/arm/mach-omap/Makefile b/arch/arm/mach-omap/Makefile index 88c6b1d594..6b42196b23 100644 --- a/arch/arm/mach-omap/Makefile +++ b/arch/arm/mach-omap/Makefile @@ -16,7 +16,7 @@ # # obj-$(CONFIG_ARCH_OMAP) += syslib.o omap_devices.o omap_generic.o -pbl-$(CONFIG_ARCH_OMAP) += syslib.o +pbl-$(CONFIG_ARCH_OMAP) += syslib.o omap_generic.o obj-$(CONFIG_ARCH_OMAP3) += omap3_generic.o auxcr.o pbl-$(CONFIG_ARCH_OMAP3) += omap3_generic.o auxcr.o obj-$(CONFIG_ARCH_OMAP4) += omap4_generic.o omap4_clock.o diff --git a/arch/arm/mach-omap/include/mach/generic.h b/arch/arm/mach-omap/include/mach/generic.h index fa391c8d48..8b2b7a4f0c 100644 --- a/arch/arm/mach-omap/include/mach/generic.h +++ b/arch/arm/mach-omap/include/mach/generic.h @@ -79,6 +79,8 @@ static inline int omap_set_mmc_dev(const char *mmcdev) void __noreturn omap_start_barebox(void *barebox); +void omap_watchdog_disable(const void __iomem *wdt); + void omap_set_bootmmc_devname(const char *devname); const char *omap_get_bootmmc_devname(void); diff --git a/arch/arm/mach-omap/include/mach/wdt.h b/arch/arm/mach-omap/include/mach/wdt.h deleted file mode 100644 index 9a5288d386..0000000000 --- a/arch/arm/mach-omap/include/mach/wdt.h +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @file - * @brief This file contains the Watchdog timer specific register definitions - * - * (C) Copyright 2008 - * Texas Instruments, <www.ti.com> - * Nishanth Menon <x0nishan@ti.com> - * - * 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 __ASM_ARCH_OMAP_WDT_H -#define __ASM_ARCH_OMAP_WDT_H - -/** Watchdog Register defines */ -#define OMAP3_WDT_REG(REGNAME) (OMAP3_MPU_WDTIMER_BASE + OMAP_WDT_##REGNAME) -#define AM33XX_WDT_REG(REGNAME) (AM33XX_WDT_BASE + OMAP_WDT_##REGNAME) - -#define OMAP_WDT_WIDR (0x000) -#define OMAP_WDT_SYSCONFIG (0x010) -#define OMAP_WDT_WD_SYSSTATUS (0x014) -#define OMAP_WDT_WISR (0x018) -#define OMAP_WDT_WIER (0x01C) -#define OMAP_WDT_WCLR (0x024) -#define OMAP_WDT_WCRR (0x028) -#define OMAP_WDT_WLDR (0x02C) -#define OMAP_WDT_WTGR (0x030) -#define OMAP_WDT_WWPS (0x034) -#define OMAP_WDT_WSPR (0x048) - -/* Unlock Code for Watchdog timer to disable the same */ -#define WDT_DISABLE_CODE1 0xAAAA -#define WDT_DISABLE_CODE2 0x5555 - -#endif /* __ASM_ARCH_OMAP_WDT_H */ diff --git a/arch/arm/mach-omap/omap3_generic.c b/arch/arm/mach-omap/omap3_generic.c index 3f6a346277..69f2d51a62 100644 --- a/arch/arm/mach-omap/omap3_generic.c +++ b/arch/arm/mach-omap/omap3_generic.c @@ -40,7 +40,6 @@ #include <mach/omap3-smx.h> #include <mach/clocks.h> #include <mach/omap3-clock.h> -#include <mach/wdt.h> #include <mach/sys_info.h> #include <mach/syslib.h> #include <mach/omap3-generic.h> @@ -379,19 +378,10 @@ static void secureworld_exit(void) */ static void watchdog_init(void) { - int pending = 1; - sr32(OMAP3_CM_REG(FCLKEN_WKUP), 5, 1, 1); sr32(OMAP3_CM_REG(ICLKEN_WKUP), 5, 1, 1); - wait_on_value((0x1 << 5), 0x20, OMAP3_CM_REG(IDLEST_WKUP), 5); - - writel(WDT_DISABLE_CODE1, OMAP3_WDT_REG(WSPR)); - - do { - pending = readl(OMAP3_WDT_REG(WWPS)); - } while (pending); - writel(WDT_DISABLE_CODE2, OMAP3_WDT_REG(WSPR)); + omap_watchdog_disable(IOMEM(OMAP3_MPU_WDTIMER_BASE)); } /** diff --git a/arch/arm/mach-omap/omap4_generic.c b/arch/arm/mach-omap/omap4_generic.c index 406b686318..6d165b7f68 100644 --- a/arch/arm/mach-omap/omap4_generic.c +++ b/arch/arm/mach-omap/omap4_generic.c @@ -65,18 +65,6 @@ void omap4_set_warmboot_order(u32 *device_list) writel(OMAP44XX_SAR_CH_START, OMAP44XX_SAR_CH_ADDRESS); } -#define WATCHDOG_WSPR 0x48 -#define WATCHDOG_WWPS 0x34 - -static void wait_for_command_complete(void) -{ - int pending = 1; - - do { - pending = readl(OMAP44XX_WDT2_BASE + WATCHDOG_WWPS); - } while (pending); -} - /* EMIF */ #define EMIF_MOD_ID_REV 0x0000 #define EMIF_STATUS 0x0004 @@ -463,14 +451,8 @@ unsigned int omap4_revision(void) */ static int watchdog_init(void) { - void __iomem *wd2_base = (void *)OMAP44XX_WDT2_BASE; - - if (!cpu_is_omap4()) - return 0; - - writel(WD_UNLOCK1, wd2_base + WATCHDOG_WSPR); - wait_for_command_complete(); - writel(WD_UNLOCK2, wd2_base + WATCHDOG_WSPR); + if (cpu_is_omap4()) + omap_watchdog_disable(IOMEM(OMAP44XX_WDT2_BASE)); return 0; } diff --git a/arch/arm/mach-omap/omap_generic.c b/arch/arm/mach-omap/omap_generic.c index a1c0aeb595..6bb26a6ef0 100644 --- a/arch/arm/mach-omap/omap_generic.c +++ b/arch/arm/mach-omap/omap_generic.c @@ -70,6 +70,24 @@ void __noreturn omap_start_barebox(void *barebox) hang(); } +#define OMAP_WDT_WWPS 0x34 +#define OMAP_WDT_WSPR 0x48 +#define WDT_DISABLE_CODE1 0xaaaa +#define WDT_DISABLE_CODE2 0x5555 + +void omap_watchdog_disable(const void __iomem *wdt) +{ + /* WDT is already running when the bootloader gets control + * Disable it to avoid "random" resets + */ + __raw_writel(WDT_DISABLE_CODE1, wdt + OMAP_WDT_WSPR); + + do { + } while (__raw_readl(wdt + OMAP_WDT_WWPS)); + + __raw_writel(WDT_DISABLE_CODE2, wdt + OMAP_WDT_WSPR); +} + #ifdef CONFIG_BOOTM static int do_bootm_omap_barebox(struct image_data *data) { |