Lines Matching +full:wdt +full:- +full:enable +full:- +full:once

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * mpc8xxx_wdt.c - MPC8xx/MPC83xx/MPC86xx watchdog userspace interface
12 * Note: it appears that you can only actually ENABLE or DISABLE the thing
13 * once after POR. Once enabled, you cannot disable, and vice versa.
34 #define SWCRR_SWEN 0x00000004 /* Watchdog Enable bit. */
69 MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started "
74 /* Ping the WDT */ in mpc8xxx_wdt_keepalive()
75 spin_lock(&ddata->lock); in mpc8xxx_wdt_keepalive()
76 out_be16(&ddata->base->swsrr, 0x556c); in mpc8xxx_wdt_keepalive()
77 out_be16(&ddata->base->swsrr, 0xaa39); in mpc8xxx_wdt_keepalive()
78 spin_unlock(&ddata->lock); in mpc8xxx_wdt_keepalive()
85 u32 tmp = in_be32(&ddata->base->swcrr); in mpc8xxx_wdt_start()
89 tmp |= SWCRR_SWEN | SWCRR_SWPR | (ddata->swtc << 16); in mpc8xxx_wdt_start()
94 out_be32(&ddata->base->swcrr, tmp); in mpc8xxx_wdt_start()
96 tmp = in_be32(&ddata->base->swcrr); in mpc8xxx_wdt_start()
98 return -EOPNOTSUPP; in mpc8xxx_wdt_start()
100 ddata->swtc = tmp >> 16; in mpc8xxx_wdt_start()
101 set_bit(WDOG_HW_RUNNING, &ddata->wdd.status); in mpc8xxx_wdt_start()
135 struct device *dev = &ofdev->dev; in mpc8xxx_wdt_probe()
139 return -EINVAL; in mpc8xxx_wdt_probe()
141 if (!freq || freq == -1) in mpc8xxx_wdt_probe()
142 return -EINVAL; in mpc8xxx_wdt_probe()
146 return -ENOMEM; in mpc8xxx_wdt_probe()
148 ddata->base = devm_platform_ioremap_resource(ofdev, 0); in mpc8xxx_wdt_probe()
149 if (IS_ERR(ddata->base)) in mpc8xxx_wdt_probe()
150 return PTR_ERR(ddata->base); in mpc8xxx_wdt_probe()
152 enabled = in_be32(&ddata->base->swcrr) & SWCRR_SWEN; in mpc8xxx_wdt_probe()
153 if (!enabled && wdt_type->hw_enabled) { in mpc8xxx_wdt_probe()
155 return -ENODEV; in mpc8xxx_wdt_probe()
161 u32 __iomem *rsr = ioremap(res->start, resource_size(res)); in mpc8xxx_wdt_probe()
164 return -ENOMEM; in mpc8xxx_wdt_probe()
166 status = in_be32(rsr) & wdt_type->rsr_mask; in mpc8xxx_wdt_probe()
167 ddata->wdd.bootstatus = status ? WDIOF_CARDRESET : 0; in mpc8xxx_wdt_probe()
169 out_be32(rsr, wdt_type->rsr_mask); in mpc8xxx_wdt_probe()
176 spin_lock_init(&ddata->lock); in mpc8xxx_wdt_probe()
178 ddata->wdd.info = &mpc8xxx_wdt_info; in mpc8xxx_wdt_probe()
179 ddata->wdd.ops = &mpc8xxx_wdt_ops; in mpc8xxx_wdt_probe()
181 ddata->wdd.timeout = WATCHDOG_TIMEOUT; in mpc8xxx_wdt_probe()
182 watchdog_init_timeout(&ddata->wdd, timeout, dev); in mpc8xxx_wdt_probe()
184 watchdog_set_nowayout(&ddata->wdd, nowayout); in mpc8xxx_wdt_probe()
186 ddata->swtc = min(ddata->wdd.timeout * freq / wdt_type->prescaler, in mpc8xxx_wdt_probe()
191 * MPC8xxx, we should ping the wdt from the kernel until the in mpc8xxx_wdt_probe()
195 mpc8xxx_wdt_start(&ddata->wdd); in mpc8xxx_wdt_probe()
197 ddata->wdd.max_hw_heartbeat_ms = (ddata->swtc * wdt_type->prescaler) / in mpc8xxx_wdt_probe()
199 ddata->wdd.min_timeout = ddata->wdd.max_hw_heartbeat_ms / 1000; in mpc8xxx_wdt_probe()
200 if (ddata->wdd.timeout < ddata->wdd.min_timeout) in mpc8xxx_wdt_probe()
201 ddata->wdd.timeout = ddata->wdd.min_timeout; in mpc8xxx_wdt_probe()
203 ret = devm_watchdog_register_device(dev, &ddata->wdd); in mpc8xxx_wdt_probe()
208 "WDT driver for MPC8xxx initialized. mode:%s timeout=%d sec\n", in mpc8xxx_wdt_probe()
209 reset ? "reset" : "interrupt", ddata->wdd.timeout); in mpc8xxx_wdt_probe()
224 .compatible = "fsl,mpc8610-wdt",
232 .compatible = "fsl,mpc823-wdt",