1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright 2017 CS Systemes d'Information
11 #include <asm/cpm_8xx.h>
14 void hw_watchdog_reset(void)
16 immap_t __iomem *immap = (immap_t __iomem *)CONFIG_SYS_IMMR;
18 out_be16(&immap->im_siu_conf.sc_swsr, 0x556c); /* write magic1 */
19 out_be16(&immap->im_siu_conf.sc_swsr, 0xaa39); /* write magic2 */
22 static int mpc8xx_wdt_start(struct udevice *dev, u64 timeout, ulong flags)
24 immap_t __iomem *immap = (immap_t __iomem *)CONFIG_SYS_IMMR;
25 u32 val = CONFIG_SYS_SYPCR;
26 const char *mode = env_get("watchdog_mode");
28 if (strcmp(mode, "off") == 0)
29 val = val & ~(SYPCR_SWE | SYPCR_SWRI);
30 else if (strcmp(mode, "nmi") == 0)
31 val = (val & ~SYPCR_SWRI) | SYPCR_SWE;
33 out_be32(&immap->im_siu_conf.sc_sypcr, val);
35 if (!(in_be32(&immap->im_siu_conf.sc_sypcr) & SYPCR_SWE))
41 static int mpc8xx_wdt_stop(struct udevice *dev)
43 immap_t __iomem *immap = (immap_t __iomem *)CONFIG_SYS_IMMR;
45 out_be32(&immap->im_siu_conf.sc_sypcr, CONFIG_SYS_SYPCR & ~SYPCR_SWE);
47 if (in_be32(&immap->im_siu_conf.sc_sypcr) & SYPCR_SWE)
52 static int mpc8xx_wdt_reset(struct udevice *dev)
59 static const struct wdt_ops mpc8xx_wdt_ops = {
60 .start = mpc8xx_wdt_start,
61 .reset = mpc8xx_wdt_reset,
62 .stop = mpc8xx_wdt_stop,
65 static const struct udevice_id mpc8xx_wdt_ids[] = {
66 { .compatible = "fsl,pq1-wdt" },
70 U_BOOT_DRIVER(wdt_mpc8xx) = {
73 .of_match = mpc8xx_wdt_ids,
74 .ops = &mpc8xx_wdt_ops,