mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-12-14 15:23:07 +00:00
a68256074f
Commitf3729ba6e7
("watchdog: mpc8xx_wdt: Watchdog driver and macros cleanup") switched the watchdog to CONFIG_WATCHDOG. But this is not compatible with the 8xx because it starts the watchdog HW timer at reset and must be serviced from the very beginning including while U-boot is executed in the firmware before relocation in RAM. Select CONFIG_HW_WATCHDOG and make hw_watchdog_reset() visible. Meanwhile, finalise the cleanup of arch/powerpc/cpu/mpc8xx/Kconfig by removing the lines put in comment in that commit, and also remove again the selection of CONFIG_MPC8xx_WATCHDOG which was removed by that commit and brought back by mistake by commitb3134ffbd9
("watchdog: Kconfig: Sort entry alphabetically") Note that there was an 'imply WATCHDOG' in the original commit but it disappeared in the Kconfig alphabetical sorting, so no need to remove it here. Fixes:f3729ba6e7
("watchdog: mpc8xx_wdt: Watchdog driver and macros cleanup") Fixes:b3134ffbd9
("watchdog: Kconfig: Sort entry alphabetically") Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr> Cc: Stefan Roese <sr@denx.de> Cc: Patrice Chotard <patrice.chotard@st.com> Reviewed-by: Stefan Roese <sr@denx.de>
67 lines
1.4 KiB
C
67 lines
1.4 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* Copyright 2017 CS Systemes d'Information
|
|
*/
|
|
|
|
#include <common.h>
|
|
#include <dm.h>
|
|
#include <wdt.h>
|
|
#include <mpc8xx.h>
|
|
#include <asm/cpm_8xx.h>
|
|
#include <asm/io.h>
|
|
|
|
void hw_watchdog_reset(void)
|
|
{
|
|
immap_t __iomem *immap = (immap_t __iomem *)CONFIG_SYS_IMMR;
|
|
|
|
out_be16(&immap->im_siu_conf.sc_swsr, 0x556c); /* write magic1 */
|
|
out_be16(&immap->im_siu_conf.sc_swsr, 0xaa39); /* write magic2 */
|
|
}
|
|
|
|
static int mpc8xx_wdt_start(struct udevice *dev, u64 timeout, ulong flags)
|
|
{
|
|
immap_t __iomem *immap = (immap_t __iomem *)CONFIG_SYS_IMMR;
|
|
|
|
out_be32(&immap->im_siu_conf.sc_sypcr, CONFIG_SYS_SYPCR);
|
|
|
|
if (!(in_be32(&immap->im_siu_conf.sc_sypcr) & SYPCR_SWE))
|
|
return -EBUSY;
|
|
return 0;
|
|
|
|
}
|
|
|
|
static int mpc8xx_wdt_stop(struct udevice *dev)
|
|
{
|
|
immap_t __iomem *immap = (immap_t __iomem *)CONFIG_SYS_IMMR;
|
|
|
|
out_be32(&immap->im_siu_conf.sc_sypcr, CONFIG_SYS_SYPCR & ~SYPCR_SWE);
|
|
|
|
if (in_be32(&immap->im_siu_conf.sc_sypcr) & SYPCR_SWE)
|
|
return -EBUSY;
|
|
return 0;
|
|
}
|
|
|
|
static int mpc8xx_wdt_reset(struct udevice *dev)
|
|
{
|
|
hw_watchdog_reset();
|
|
|
|
return 0;
|
|
}
|
|
|
|
static const struct wdt_ops mpc8xx_wdt_ops = {
|
|
.start = mpc8xx_wdt_start,
|
|
.reset = mpc8xx_wdt_reset,
|
|
.stop = mpc8xx_wdt_stop,
|
|
};
|
|
|
|
static const struct udevice_id mpc8xx_wdt_ids[] = {
|
|
{ .compatible = "fsl,pq1-wdt" },
|
|
{}
|
|
};
|
|
|
|
U_BOOT_DRIVER(wdt_mpc8xx) = {
|
|
.name = "wdt_mpc8xx",
|
|
.id = UCLASS_WDT,
|
|
.of_match = mpc8xx_wdt_ids,
|
|
.ops = &mpc8xx_wdt_ops,
|
|
};
|