Re: [PATCH 2/5] m68k: move watchdog functions in mcf_wdt driver
On 6/25/23 21:35, Angelo Dureghello wrote: Move watchdog functions inside a separate watchdog driver. Signed-off-by: Angelo Dureghello --- arch/m68k/cpu/mcf523x/cpu.c | 42 - arch/m68k/cpu/mcf52x2/cpu.c | 47 + arch/m68k/cpu/mcf532x/cpu.c | 44 -- 3 files changed, 1 insertion(+), 132 deletions(-) Now this is a nice diff-stat. Thanks for cleaning this up and moving all this stuff into the watchdog driver. And again, please double-check, if the hw_foo stuff (now in the wdt driver) can be completely removed. Reviewed-by: Stefan Roese Thanks, Stefan diff --git a/arch/m68k/cpu/mcf523x/cpu.c b/arch/m68k/cpu/mcf523x/cpu.c index ba2c228911..bef67767b4 100644 --- a/arch/m68k/cpu/mcf523x/cpu.c +++ b/arch/m68k/cpu/mcf523x/cpu.c @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -62,47 +61,6 @@ int print_cpuinfo(void) }; #endif /* CONFIG_DISPLAY_CPUINFO */ -#if defined(CONFIG_WATCHDOG) -/* Called by macro WATCHDOG_RESET */ -void watchdog_reset(void) -{ - wdog_t *wdp = (wdog_t *) (MMAP_WDOG); - - /* Count register */ - out_be16(>sr, 0x); - asm("nop"); - out_be16(>sr, 0x); -} - -int watchdog_disable(void) -{ - wdog_t *wdp = (wdog_t *) (MMAP_WDOG); - - /* UserManual, once the wdog is disabled, wdog cannot be re-enabled */ - /* halted watchdog timer */ - setbits_be16(>cr, WTM_WCR_HALTED); - - puts("WATCHDOG:disabled\n"); - return (0); -} - -int watchdog_init(void) -{ - wdog_t *wdp = (wdog_t *) (MMAP_WDOG); - u32 wdog_module = 0; - - /* set timeout and enable watchdog */ - wdog_module = ((CFG_SYS_CLK / CONFIG_SYS_HZ) * CONFIG_WATCHDOG_TIMEOUT_MSECS); - wdog_module |= (wdog_module / 8192); - out_be16(>mr, wdog_module); - - out_be16(>cr, WTM_WCR_EN); - puts("WATCHDOG:enabled\n"); - - return (0); -} -#endif /* CONFIG_WATCHDOG */ - #if defined(CONFIG_MCFFEC) /* Default initializations for MCFFEC controllers. To override, * create a board-specific function called: diff --git a/arch/m68k/cpu/mcf52x2/cpu.c b/arch/m68k/cpu/mcf52x2/cpu.c index d7cbf11e25..5042a38b3e 100644 --- a/arch/m68k/cpu/mcf52x2/cpu.c +++ b/arch/m68k/cpu/mcf52x2/cpu.c @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include @@ -53,51 +52,7 @@ int print_cpuinfo(void) return 0; }; #endif /* CONFIG_DISPLAY_CPUINFO */ - -#if defined(CONFIG_WATCHDOG) -/* Called by macro WATCHDOG_RESET */ -void watchdog_reset(void) -{ - wdog_t *wdt = (wdog_t *)(MMAP_WDOG); - - out_be16(>sr, 0x); - out_be16(>sr, 0x); -} - -int watchdog_disable(void) -{ - wdog_t *wdt = (wdog_t *)(MMAP_WDOG); - - /* reset watchdog counter */ - out_be16(>sr, 0x); - out_be16(>sr, 0x); - /* disable watchdog timer */ - out_be16(>cr, 0); - - puts("WATCHDOG:disabled\n"); - return (0); -} - -int watchdog_init(void) -{ - wdog_t *wdt = (wdog_t *)(MMAP_WDOG); - - /* disable watchdog */ - out_be16(>cr, 0); - - /* set timeout and enable watchdog */ - out_be16(>mr, - (CONFIG_WATCHDOG_TIMEOUT_MSECS * CONFIG_SYS_HZ) / (32768 * 1000) - 1); - - /* reset watchdog counter */ - out_be16(>sr, 0x); - out_be16(>sr, 0x); - - puts("WATCHDOG:enabled\n"); - return (0); -} -#endif /* #ifdef CONFIG_WATCHDOG */ -#endif /* #ifdef CONFIG_M5208 */ +#endif /* #ifdef CONFIG_M5208 */ #ifdef CONFIG_M5271 #if defined(CONFIG_DISPLAY_CPUINFO) diff --git a/arch/m68k/cpu/mcf532x/cpu.c b/arch/m68k/cpu/mcf532x/cpu.c index 548cbca36a..18d20a8926 100644 --- a/arch/m68k/cpu/mcf532x/cpu.c +++ b/arch/m68k/cpu/mcf532x/cpu.c @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -102,49 +101,6 @@ int print_cpuinfo(void) }; #endif /* CONFIG_DISPLAY_CPUINFO */ -#if defined(CONFIG_WATCHDOG) -/* Called by macro WATCHDOG_RESET */ -void watchdog_reset(void) -{ - wdog_t *wdp = (wdog_t *) (MMAP_WDOG); - - /* Count register */ - out_be16(>sr, 0x); - out_be16(>sr, 0x); -} - -int watchdog_disable(void) -{ - wdog_t *wdp = (wdog_t *) (MMAP_WDOG); - - /* UserManual, once the wdog is disabled, wdog cannot be re-enabled */ - /* halted watchdog timer */ - setbits_be16(>cr, WTM_WCR_HALTED); - - puts("WATCHDOG:disabled\n"); - return (0); -} - -int watchdog_init(void) -{ - wdog_t *wdp = (wdog_t *) (MMAP_WDOG); - u32 wdog_module = 0; - - /* set timeout and enable watchdog */ - wdog_module = ((CFG_SYS_CLK / 1000) * CONFIG_WATCHDOG_TIMEOUT_MSECS); -#ifdef CONFIG_M5329 - out_be16(>mr, wdog_module / 8192); -#else -
[PATCH 2/5] m68k: move watchdog functions in mcf_wdt driver
Move watchdog functions inside a separate watchdog driver. Signed-off-by: Angelo Dureghello --- arch/m68k/cpu/mcf523x/cpu.c | 42 - arch/m68k/cpu/mcf52x2/cpu.c | 47 + arch/m68k/cpu/mcf532x/cpu.c | 44 -- 3 files changed, 1 insertion(+), 132 deletions(-) diff --git a/arch/m68k/cpu/mcf523x/cpu.c b/arch/m68k/cpu/mcf523x/cpu.c index ba2c228911..bef67767b4 100644 --- a/arch/m68k/cpu/mcf523x/cpu.c +++ b/arch/m68k/cpu/mcf523x/cpu.c @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -62,47 +61,6 @@ int print_cpuinfo(void) }; #endif /* CONFIG_DISPLAY_CPUINFO */ -#if defined(CONFIG_WATCHDOG) -/* Called by macro WATCHDOG_RESET */ -void watchdog_reset(void) -{ - wdog_t *wdp = (wdog_t *) (MMAP_WDOG); - - /* Count register */ - out_be16(>sr, 0x); - asm("nop"); - out_be16(>sr, 0x); -} - -int watchdog_disable(void) -{ - wdog_t *wdp = (wdog_t *) (MMAP_WDOG); - - /* UserManual, once the wdog is disabled, wdog cannot be re-enabled */ - /* halted watchdog timer */ - setbits_be16(>cr, WTM_WCR_HALTED); - - puts("WATCHDOG:disabled\n"); - return (0); -} - -int watchdog_init(void) -{ - wdog_t *wdp = (wdog_t *) (MMAP_WDOG); - u32 wdog_module = 0; - - /* set timeout and enable watchdog */ - wdog_module = ((CFG_SYS_CLK / CONFIG_SYS_HZ) * CONFIG_WATCHDOG_TIMEOUT_MSECS); - wdog_module |= (wdog_module / 8192); - out_be16(>mr, wdog_module); - - out_be16(>cr, WTM_WCR_EN); - puts("WATCHDOG:enabled\n"); - - return (0); -} -#endif /* CONFIG_WATCHDOG */ - #if defined(CONFIG_MCFFEC) /* Default initializations for MCFFEC controllers. To override, * create a board-specific function called: diff --git a/arch/m68k/cpu/mcf52x2/cpu.c b/arch/m68k/cpu/mcf52x2/cpu.c index d7cbf11e25..5042a38b3e 100644 --- a/arch/m68k/cpu/mcf52x2/cpu.c +++ b/arch/m68k/cpu/mcf52x2/cpu.c @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include @@ -53,51 +52,7 @@ int print_cpuinfo(void) return 0; }; #endif /* CONFIG_DISPLAY_CPUINFO */ - -#if defined(CONFIG_WATCHDOG) -/* Called by macro WATCHDOG_RESET */ -void watchdog_reset(void) -{ - wdog_t *wdt = (wdog_t *)(MMAP_WDOG); - - out_be16(>sr, 0x); - out_be16(>sr, 0x); -} - -int watchdog_disable(void) -{ - wdog_t *wdt = (wdog_t *)(MMAP_WDOG); - - /* reset watchdog counter */ - out_be16(>sr, 0x); - out_be16(>sr, 0x); - /* disable watchdog timer */ - out_be16(>cr, 0); - - puts("WATCHDOG:disabled\n"); - return (0); -} - -int watchdog_init(void) -{ - wdog_t *wdt = (wdog_t *)(MMAP_WDOG); - - /* disable watchdog */ - out_be16(>cr, 0); - - /* set timeout and enable watchdog */ - out_be16(>mr, - (CONFIG_WATCHDOG_TIMEOUT_MSECS * CONFIG_SYS_HZ) / (32768 * 1000) - 1); - - /* reset watchdog counter */ - out_be16(>sr, 0x); - out_be16(>sr, 0x); - - puts("WATCHDOG:enabled\n"); - return (0); -} -#endif /* #ifdef CONFIG_WATCHDOG */ -#endif /* #ifdef CONFIG_M5208 */ +#endif /* #ifdef CONFIG_M5208 */ #ifdef CONFIG_M5271 #if defined(CONFIG_DISPLAY_CPUINFO) diff --git a/arch/m68k/cpu/mcf532x/cpu.c b/arch/m68k/cpu/mcf532x/cpu.c index 548cbca36a..18d20a8926 100644 --- a/arch/m68k/cpu/mcf532x/cpu.c +++ b/arch/m68k/cpu/mcf532x/cpu.c @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -102,49 +101,6 @@ int print_cpuinfo(void) }; #endif /* CONFIG_DISPLAY_CPUINFO */ -#if defined(CONFIG_WATCHDOG) -/* Called by macro WATCHDOG_RESET */ -void watchdog_reset(void) -{ - wdog_t *wdp = (wdog_t *) (MMAP_WDOG); - - /* Count register */ - out_be16(>sr, 0x); - out_be16(>sr, 0x); -} - -int watchdog_disable(void) -{ - wdog_t *wdp = (wdog_t *) (MMAP_WDOG); - - /* UserManual, once the wdog is disabled, wdog cannot be re-enabled */ - /* halted watchdog timer */ - setbits_be16(>cr, WTM_WCR_HALTED); - - puts("WATCHDOG:disabled\n"); - return (0); -} - -int watchdog_init(void) -{ - wdog_t *wdp = (wdog_t *) (MMAP_WDOG); - u32 wdog_module = 0; - - /* set timeout and enable watchdog */ - wdog_module = ((CFG_SYS_CLK / 1000) * CONFIG_WATCHDOG_TIMEOUT_MSECS); -#ifdef CONFIG_M5329 - out_be16(>mr, wdog_module / 8192); -#else - out_be16(>mr, wdog_module / 4096); -#endif - - out_be16(>cr, WTM_WCR_EN); - puts("WATCHDOG:enabled\n"); - - return (0); -} -#endif /* CONFIG_WATCHDOG */ - #if defined(CONFIG_MCFFEC) /* Default initializations for MCFFEC controllers. To override, * create a board-specific function called: --