Thomas Gleixner | 2874c5f | 2019-05-27 08:55:01 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
Kumar Gala | fabbfb9 | 2006-01-14 13:20:50 -0800 | [diff] [blame] | 2 | /* |
Anton Vorontsov | 0d7b101 | 2008-07-03 23:51:36 -0700 | [diff] [blame] | 3 | * mpc8xxx_wdt.c - MPC8xx/MPC83xx/MPC86xx watchdog userspace interface |
Kumar Gala | fabbfb9 | 2006-01-14 13:20:50 -0800 | [diff] [blame] | 4 | * |
| 5 | * Authors: Dave Updegraff <dave@cray.org> |
Wim Van Sebroeck | 5f3b275 | 2011-02-23 20:04:38 +0000 | [diff] [blame] | 6 | * Kumar Gala <galak@kernel.crashing.org> |
| 7 | * Attribution: from 83xx_wst: Florian Schirmer <jolt@tuxbox.org> |
| 8 | * ..and from sc520_wdt |
Anton Vorontsov | 500c919 | 2008-07-03 23:51:34 -0700 | [diff] [blame] | 9 | * Copyright (c) 2008 MontaVista Software, Inc. |
| 10 | * Anton Vorontsov <avorontsov@ru.mvista.com> |
Kumar Gala | fabbfb9 | 2006-01-14 13:20:50 -0800 | [diff] [blame] | 11 | * |
| 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. |
Kumar Gala | fabbfb9 | 2006-01-14 13:20:50 -0800 | [diff] [blame] | 14 | */ |
| 15 | |
Kumar Gala | fabbfb9 | 2006-01-14 13:20:50 -0800 | [diff] [blame] | 16 | #include <linux/fs.h> |
| 17 | #include <linux/init.h> |
| 18 | #include <linux/kernel.h> |
Rob Herring | 5af5073 | 2013-09-17 14:28:33 -0500 | [diff] [blame] | 19 | #include <linux/of_address.h> |
Anton Vorontsov | ef8ab12 | 2008-07-03 23:51:32 -0700 | [diff] [blame] | 20 | #include <linux/of_platform.h> |
Kumar Gala | fabbfb9 | 2006-01-14 13:20:50 -0800 | [diff] [blame] | 21 | #include <linux/module.h> |
| 22 | #include <linux/watchdog.h> |
Alan Cox | f26ef3d | 2008-05-19 14:07:09 +0100 | [diff] [blame] | 23 | #include <linux/io.h> |
| 24 | #include <linux/uaccess.h> |
Anton Vorontsov | ef8ab12 | 2008-07-03 23:51:32 -0700 | [diff] [blame] | 25 | #include <sysdev/fsl_soc.h> |
Kumar Gala | fabbfb9 | 2006-01-14 13:20:50 -0800 | [diff] [blame] | 26 | |
Christophe Leroy | 19ce949 | 2017-11-08 15:39:44 +0100 | [diff] [blame] | 27 | #define WATCHDOG_TIMEOUT 10 |
| 28 | |
Anton Vorontsov | 59ca1b0 | 2008-07-03 23:51:35 -0700 | [diff] [blame] | 29 | struct mpc8xxx_wdt { |
Kumar Gala | fabbfb9 | 2006-01-14 13:20:50 -0800 | [diff] [blame] | 30 | __be32 res0; |
| 31 | __be32 swcrr; /* System watchdog control register */ |
| 32 | #define SWCRR_SWTC 0xFFFF0000 /* Software Watchdog Time Count. */ |
Christophe Leroy | 19ce949 | 2017-11-08 15:39:44 +0100 | [diff] [blame] | 33 | #define SWCRR_SWF 0x00000008 /* Software Watchdog Freeze (mpc8xx). */ |
Kumar Gala | fabbfb9 | 2006-01-14 13:20:50 -0800 | [diff] [blame] | 34 | #define SWCRR_SWEN 0x00000004 /* Watchdog Enable bit. */ |
| 35 | #define SWCRR_SWRI 0x00000002 /* Software Watchdog Reset/Interrupt Select bit.*/ |
| 36 | #define SWCRR_SWPR 0x00000001 /* Software Watchdog Counter Prescale bit. */ |
| 37 | __be32 swcnr; /* System watchdog count register */ |
| 38 | u8 res1[2]; |
| 39 | __be16 swsrr; /* System watchdog service register */ |
| 40 | u8 res2[0xF0]; |
| 41 | }; |
| 42 | |
Anton Vorontsov | 59ca1b0 | 2008-07-03 23:51:35 -0700 | [diff] [blame] | 43 | struct mpc8xxx_wdt_type { |
Anton Vorontsov | 500c919 | 2008-07-03 23:51:34 -0700 | [diff] [blame] | 44 | int prescaler; |
| 45 | bool hw_enabled; |
Christophe Leroy | 38e48b7 | 2018-09-17 06:22:50 +0000 | [diff] [blame] | 46 | u32 rsr_mask; |
Anton Vorontsov | 500c919 | 2008-07-03 23:51:34 -0700 | [diff] [blame] | 47 | }; |
| 48 | |
Uwe Kleine-König | 7997eba | 2015-08-12 10:15:56 +0200 | [diff] [blame] | 49 | struct mpc8xxx_wdt_ddata { |
| 50 | struct mpc8xxx_wdt __iomem *base; |
| 51 | struct watchdog_device wdd; |
Uwe Kleine-König | 7997eba | 2015-08-12 10:15:56 +0200 | [diff] [blame] | 52 | spinlock_t lock; |
Christophe Leroy | 19ce949 | 2017-11-08 15:39:44 +0100 | [diff] [blame] | 53 | u16 swtc; |
Uwe Kleine-König | 7997eba | 2015-08-12 10:15:56 +0200 | [diff] [blame] | 54 | }; |
Kumar Gala | fabbfb9 | 2006-01-14 13:20:50 -0800 | [diff] [blame] | 55 | |
Christophe Leroy | 19ce949 | 2017-11-08 15:39:44 +0100 | [diff] [blame] | 56 | static u16 timeout; |
Kumar Gala | fabbfb9 | 2006-01-14 13:20:50 -0800 | [diff] [blame] | 57 | module_param(timeout, ushort, 0); |
Alan Cox | f26ef3d | 2008-05-19 14:07:09 +0100 | [diff] [blame] | 58 | MODULE_PARM_DESC(timeout, |
Christophe Leroy | 19ce949 | 2017-11-08 15:39:44 +0100 | [diff] [blame] | 59 | "Watchdog timeout in seconds. (1<timeout<65535, default=" |
| 60 | __MODULE_STRING(WATCHDOG_TIMEOUT) ")"); |
Kumar Gala | fabbfb9 | 2006-01-14 13:20:50 -0800 | [diff] [blame] | 61 | |
Rusty Russell | 90ab5ee | 2012-01-13 09:32:20 +1030 | [diff] [blame] | 62 | static bool reset = 1; |
Kumar Gala | fabbfb9 | 2006-01-14 13:20:50 -0800 | [diff] [blame] | 63 | module_param(reset, bool, 0); |
Alan Cox | f26ef3d | 2008-05-19 14:07:09 +0100 | [diff] [blame] | 64 | MODULE_PARM_DESC(reset, |
| 65 | "Watchdog Interrupt/Reset Mode. 0 = interrupt, 1 = reset"); |
Kumar Gala | fabbfb9 | 2006-01-14 13:20:50 -0800 | [diff] [blame] | 66 | |
Wim Van Sebroeck | 86a1e18 | 2012-03-05 16:51:11 +0100 | [diff] [blame] | 67 | static bool nowayout = WATCHDOG_NOWAYOUT; |
| 68 | module_param(nowayout, bool, 0); |
Anton Vorontsov | 500c919 | 2008-07-03 23:51:34 -0700 | [diff] [blame] | 69 | MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started " |
| 70 | "(default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); |
| 71 | |
Uwe Kleine-König | 7997eba | 2015-08-12 10:15:56 +0200 | [diff] [blame] | 72 | static void mpc8xxx_wdt_keepalive(struct mpc8xxx_wdt_ddata *ddata) |
Kumar Gala | fabbfb9 | 2006-01-14 13:20:50 -0800 | [diff] [blame] | 73 | { |
| 74 | /* Ping the WDT */ |
Uwe Kleine-König | 7997eba | 2015-08-12 10:15:56 +0200 | [diff] [blame] | 75 | spin_lock(&ddata->lock); |
| 76 | out_be16(&ddata->base->swsrr, 0x556c); |
| 77 | out_be16(&ddata->base->swsrr, 0xaa39); |
| 78 | spin_unlock(&ddata->lock); |
Kumar Gala | fabbfb9 | 2006-01-14 13:20:50 -0800 | [diff] [blame] | 79 | } |
| 80 | |
Christophe Leroy | d5cfaf0 | 2013-12-04 07:32:14 +0100 | [diff] [blame] | 81 | static int mpc8xxx_wdt_start(struct watchdog_device *w) |
Kumar Gala | fabbfb9 | 2006-01-14 13:20:50 -0800 | [diff] [blame] | 82 | { |
Uwe Kleine-König | 7997eba | 2015-08-12 10:15:56 +0200 | [diff] [blame] | 83 | struct mpc8xxx_wdt_ddata *ddata = |
| 84 | container_of(w, struct mpc8xxx_wdt_ddata, wdd); |
Christophe Leroy | 19ce949 | 2017-11-08 15:39:44 +0100 | [diff] [blame] | 85 | u32 tmp = in_be32(&ddata->base->swcrr); |
Kumar Gala | fabbfb9 | 2006-01-14 13:20:50 -0800 | [diff] [blame] | 86 | |
| 87 | /* Good, fire up the show */ |
Christophe Leroy | 19ce949 | 2017-11-08 15:39:44 +0100 | [diff] [blame] | 88 | tmp &= ~(SWCRR_SWTC | SWCRR_SWF | SWCRR_SWEN | SWCRR_SWRI | SWCRR_SWPR); |
| 89 | tmp |= SWCRR_SWEN | SWCRR_SWPR | (ddata->swtc << 16); |
| 90 | |
Kumar Gala | fabbfb9 | 2006-01-14 13:20:50 -0800 | [diff] [blame] | 91 | if (reset) |
| 92 | tmp |= SWCRR_SWRI; |
| 93 | |
Uwe Kleine-König | 7997eba | 2015-08-12 10:15:56 +0200 | [diff] [blame] | 94 | out_be32(&ddata->base->swcrr, tmp); |
Kumar Gala | fabbfb9 | 2006-01-14 13:20:50 -0800 | [diff] [blame] | 95 | |
Christophe Leroy | 19ce949 | 2017-11-08 15:39:44 +0100 | [diff] [blame] | 96 | tmp = in_be32(&ddata->base->swcrr); |
| 97 | if (!(tmp & SWCRR_SWEN)) |
| 98 | return -EOPNOTSUPP; |
| 99 | |
| 100 | ddata->swtc = tmp >> 16; |
| 101 | set_bit(WDOG_HW_RUNNING, &ddata->wdd.status); |
Anton Vorontsov | 500c919 | 2008-07-03 23:51:34 -0700 | [diff] [blame] | 102 | |
Kumar Gala | fabbfb9 | 2006-01-14 13:20:50 -0800 | [diff] [blame] | 103 | return 0; |
| 104 | } |
| 105 | |
Christophe Leroy | d5cfaf0 | 2013-12-04 07:32:14 +0100 | [diff] [blame] | 106 | static int mpc8xxx_wdt_ping(struct watchdog_device *w) |
Kumar Gala | fabbfb9 | 2006-01-14 13:20:50 -0800 | [diff] [blame] | 107 | { |
Uwe Kleine-König | 7997eba | 2015-08-12 10:15:56 +0200 | [diff] [blame] | 108 | struct mpc8xxx_wdt_ddata *ddata = |
| 109 | container_of(w, struct mpc8xxx_wdt_ddata, wdd); |
| 110 | |
| 111 | mpc8xxx_wdt_keepalive(ddata); |
Christophe Leroy | d5cfaf0 | 2013-12-04 07:32:14 +0100 | [diff] [blame] | 112 | return 0; |
Kumar Gala | fabbfb9 | 2006-01-14 13:20:50 -0800 | [diff] [blame] | 113 | } |
| 114 | |
Christophe Leroy | d5cfaf0 | 2013-12-04 07:32:14 +0100 | [diff] [blame] | 115 | static struct watchdog_info mpc8xxx_wdt_info = { |
Christophe Leroy | 19ce949 | 2017-11-08 15:39:44 +0100 | [diff] [blame] | 116 | .options = WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE | WDIOF_SETTIMEOUT, |
Christophe Leroy | d5cfaf0 | 2013-12-04 07:32:14 +0100 | [diff] [blame] | 117 | .firmware_version = 1, |
| 118 | .identity = "MPC8xxx", |
Kumar Gala | fabbfb9 | 2006-01-14 13:20:50 -0800 | [diff] [blame] | 119 | }; |
| 120 | |
Christophe Leroy | d5cfaf0 | 2013-12-04 07:32:14 +0100 | [diff] [blame] | 121 | static struct watchdog_ops mpc8xxx_wdt_ops = { |
| 122 | .owner = THIS_MODULE, |
| 123 | .start = mpc8xxx_wdt_start, |
| 124 | .ping = mpc8xxx_wdt_ping, |
Christophe Leroy | d5cfaf0 | 2013-12-04 07:32:14 +0100 | [diff] [blame] | 125 | }; |
| 126 | |
Bill Pemberton | 2d991a1 | 2012-11-19 13:21:41 -0500 | [diff] [blame] | 127 | static int mpc8xxx_wdt_probe(struct platform_device *ofdev) |
Kumar Gala | fabbfb9 | 2006-01-14 13:20:50 -0800 | [diff] [blame] | 128 | { |
Kumar Gala | fabbfb9 | 2006-01-14 13:20:50 -0800 | [diff] [blame] | 129 | int ret; |
Uwe Kleine-König | de5f712 | 2015-08-12 10:15:55 +0200 | [diff] [blame] | 130 | struct resource *res; |
Arnd Bergmann | 639397e | 2012-05-21 21:57:39 +0200 | [diff] [blame] | 131 | const struct mpc8xxx_wdt_type *wdt_type; |
Uwe Kleine-König | 7997eba | 2015-08-12 10:15:56 +0200 | [diff] [blame] | 132 | struct mpc8xxx_wdt_ddata *ddata; |
Anton Vorontsov | ef8ab12 | 2008-07-03 23:51:32 -0700 | [diff] [blame] | 133 | u32 freq = fsl_get_sys_freq(); |
Anton Vorontsov | 500c919 | 2008-07-03 23:51:34 -0700 | [diff] [blame] | 134 | bool enabled; |
Christophe Leroy | 79b10e0 | 2018-09-17 06:22:47 +0000 | [diff] [blame] | 135 | struct device *dev = &ofdev->dev; |
Kumar Gala | fabbfb9 | 2006-01-14 13:20:50 -0800 | [diff] [blame] | 136 | |
Christophe Leroy | 79b10e0 | 2018-09-17 06:22:47 +0000 | [diff] [blame] | 137 | wdt_type = of_device_get_match_data(dev); |
Uwe Kleine-König | f0ded83 | 2015-08-12 10:15:54 +0200 | [diff] [blame] | 138 | if (!wdt_type) |
Grant Likely | 1c48a5c | 2011-02-17 02:43:24 -0700 | [diff] [blame] | 139 | return -EINVAL; |
Grant Likely | 1c48a5c | 2011-02-17 02:43:24 -0700 | [diff] [blame] | 140 | |
Anton Vorontsov | ef8ab12 | 2008-07-03 23:51:32 -0700 | [diff] [blame] | 141 | if (!freq || freq == -1) |
| 142 | return -EINVAL; |
Kumar Gala | fabbfb9 | 2006-01-14 13:20:50 -0800 | [diff] [blame] | 143 | |
Christophe Leroy | 79b10e0 | 2018-09-17 06:22:47 +0000 | [diff] [blame] | 144 | ddata = devm_kzalloc(dev, sizeof(*ddata), GFP_KERNEL); |
Uwe Kleine-König | 7997eba | 2015-08-12 10:15:56 +0200 | [diff] [blame] | 145 | if (!ddata) |
| 146 | return -ENOMEM; |
Kumar Gala | fabbfb9 | 2006-01-14 13:20:50 -0800 | [diff] [blame] | 147 | |
Guenter Roeck | 0f0a6a2 | 2019-04-02 12:01:53 -0700 | [diff] [blame] | 148 | ddata->base = devm_platform_ioremap_resource(ofdev, 0); |
Uwe Kleine-König | 7997eba | 2015-08-12 10:15:56 +0200 | [diff] [blame] | 149 | if (IS_ERR(ddata->base)) |
| 150 | return PTR_ERR(ddata->base); |
| 151 | |
| 152 | enabled = in_be32(&ddata->base->swcrr) & SWCRR_SWEN; |
Anton Vorontsov | 500c919 | 2008-07-03 23:51:34 -0700 | [diff] [blame] | 153 | if (!enabled && wdt_type->hw_enabled) { |
Christophe Leroy | 79b10e0 | 2018-09-17 06:22:47 +0000 | [diff] [blame] | 154 | dev_info(dev, "could not be enabled in software\n"); |
Uwe Kleine-König | 72cd501 | 2015-08-12 10:15:57 +0200 | [diff] [blame] | 155 | return -ENODEV; |
Anton Vorontsov | 500c919 | 2008-07-03 23:51:34 -0700 | [diff] [blame] | 156 | } |
| 157 | |
Christophe Leroy | 38e48b7 | 2018-09-17 06:22:50 +0000 | [diff] [blame] | 158 | res = platform_get_resource(ofdev, IORESOURCE_MEM, 1); |
| 159 | if (res) { |
| 160 | bool status; |
| 161 | u32 __iomem *rsr = ioremap(res->start, resource_size(res)); |
| 162 | |
| 163 | if (!rsr) |
| 164 | return -ENOMEM; |
| 165 | |
| 166 | status = in_be32(rsr) & wdt_type->rsr_mask; |
| 167 | ddata->wdd.bootstatus = status ? WDIOF_CARDRESET : 0; |
| 168 | /* clear reset status bits related to watchdog timer */ |
| 169 | out_be32(rsr, wdt_type->rsr_mask); |
| 170 | iounmap(rsr); |
| 171 | |
| 172 | dev_info(dev, "Last boot was %scaused by watchdog\n", |
| 173 | status ? "" : "not "); |
| 174 | } |
| 175 | |
Uwe Kleine-König | 7997eba | 2015-08-12 10:15:56 +0200 | [diff] [blame] | 176 | spin_lock_init(&ddata->lock); |
Uwe Kleine-König | 7997eba | 2015-08-12 10:15:56 +0200 | [diff] [blame] | 177 | |
| 178 | ddata->wdd.info = &mpc8xxx_wdt_info, |
| 179 | ddata->wdd.ops = &mpc8xxx_wdt_ops, |
| 180 | |
Christophe Leroy | 19ce949 | 2017-11-08 15:39:44 +0100 | [diff] [blame] | 181 | ddata->wdd.timeout = WATCHDOG_TIMEOUT; |
Christophe Leroy | 79b10e0 | 2018-09-17 06:22:47 +0000 | [diff] [blame] | 182 | watchdog_init_timeout(&ddata->wdd, timeout, dev); |
Uwe Kleine-König | 50ffb53 | 2015-08-12 10:15:53 +0200 | [diff] [blame] | 183 | |
Uwe Kleine-König | 7997eba | 2015-08-12 10:15:56 +0200 | [diff] [blame] | 184 | watchdog_set_nowayout(&ddata->wdd, nowayout); |
Uwe Kleine-König | 50ffb53 | 2015-08-12 10:15:53 +0200 | [diff] [blame] | 185 | |
Christophe Leroy | 19ce949 | 2017-11-08 15:39:44 +0100 | [diff] [blame] | 186 | ddata->swtc = min(ddata->wdd.timeout * freq / wdt_type->prescaler, |
| 187 | 0xffffU); |
Anton Vorontsov | 500c919 | 2008-07-03 23:51:34 -0700 | [diff] [blame] | 188 | |
| 189 | /* |
| 190 | * If the watchdog was previously enabled or we're running on |
Anton Vorontsov | 59ca1b0 | 2008-07-03 23:51:35 -0700 | [diff] [blame] | 191 | * MPC8xxx, we should ping the wdt from the kernel until the |
Anton Vorontsov | 500c919 | 2008-07-03 23:51:34 -0700 | [diff] [blame] | 192 | * userspace handles it. |
| 193 | */ |
| 194 | if (enabled) |
Christophe Leroy | 19ce949 | 2017-11-08 15:39:44 +0100 | [diff] [blame] | 195 | mpc8xxx_wdt_start(&ddata->wdd); |
| 196 | |
| 197 | ddata->wdd.max_hw_heartbeat_ms = (ddata->swtc * wdt_type->prescaler) / |
| 198 | (freq / 1000); |
| 199 | ddata->wdd.min_timeout = ddata->wdd.max_hw_heartbeat_ms / 1000; |
| 200 | if (ddata->wdd.timeout < ddata->wdd.min_timeout) |
| 201 | ddata->wdd.timeout = ddata->wdd.min_timeout; |
| 202 | |
Guenter Roeck | 81df6db | 2019-04-10 09:28:02 -0700 | [diff] [blame] | 203 | ret = devm_watchdog_register_device(dev, &ddata->wdd); |
Wolfram Sang | a239027 | 2019-05-18 23:27:40 +0200 | [diff] [blame] | 204 | if (ret) |
Christophe Leroy | 19ce949 | 2017-11-08 15:39:44 +0100 | [diff] [blame] | 205 | return ret; |
Christophe Leroy | 19ce949 | 2017-11-08 15:39:44 +0100 | [diff] [blame] | 206 | |
Christophe Leroy | 79b10e0 | 2018-09-17 06:22:47 +0000 | [diff] [blame] | 207 | dev_info(dev, |
| 208 | "WDT driver for MPC8xxx initialized. mode:%s timeout=%d sec\n", |
| 209 | reset ? "reset" : "interrupt", ddata->wdd.timeout); |
Uwe Kleine-König | 7997eba | 2015-08-12 10:15:56 +0200 | [diff] [blame] | 210 | |
| 211 | platform_set_drvdata(ofdev, ddata); |
Kumar Gala | fabbfb9 | 2006-01-14 13:20:50 -0800 | [diff] [blame] | 212 | return 0; |
Kumar Gala | fabbfb9 | 2006-01-14 13:20:50 -0800 | [diff] [blame] | 213 | } |
| 214 | |
Anton Vorontsov | 59ca1b0 | 2008-07-03 23:51:35 -0700 | [diff] [blame] | 215 | static const struct of_device_id mpc8xxx_wdt_match[] = { |
Anton Vorontsov | ef8ab12 | 2008-07-03 23:51:32 -0700 | [diff] [blame] | 216 | { |
| 217 | .compatible = "mpc83xx_wdt", |
Anton Vorontsov | 59ca1b0 | 2008-07-03 23:51:35 -0700 | [diff] [blame] | 218 | .data = &(struct mpc8xxx_wdt_type) { |
Anton Vorontsov | 500c919 | 2008-07-03 23:51:34 -0700 | [diff] [blame] | 219 | .prescaler = 0x10000, |
Christophe Leroy | 38e48b7 | 2018-09-17 06:22:50 +0000 | [diff] [blame] | 220 | .rsr_mask = BIT(3), /* RSR Bit SWRS */ |
Anton Vorontsov | 500c919 | 2008-07-03 23:51:34 -0700 | [diff] [blame] | 221 | }, |
| 222 | }, |
| 223 | { |
| 224 | .compatible = "fsl,mpc8610-wdt", |
Anton Vorontsov | 59ca1b0 | 2008-07-03 23:51:35 -0700 | [diff] [blame] | 225 | .data = &(struct mpc8xxx_wdt_type) { |
Anton Vorontsov | 500c919 | 2008-07-03 23:51:34 -0700 | [diff] [blame] | 226 | .prescaler = 0x10000, |
| 227 | .hw_enabled = true, |
Christophe Leroy | 38e48b7 | 2018-09-17 06:22:50 +0000 | [diff] [blame] | 228 | .rsr_mask = BIT(20), /* RSTRSCR Bit WDT_RR */ |
Anton Vorontsov | 500c919 | 2008-07-03 23:51:34 -0700 | [diff] [blame] | 229 | }, |
Anton Vorontsov | ef8ab12 | 2008-07-03 23:51:32 -0700 | [diff] [blame] | 230 | }, |
Anton Vorontsov | 0d7b101 | 2008-07-03 23:51:36 -0700 | [diff] [blame] | 231 | { |
| 232 | .compatible = "fsl,mpc823-wdt", |
| 233 | .data = &(struct mpc8xxx_wdt_type) { |
| 234 | .prescaler = 0x800, |
Christophe Leroy | 4af897f | 2013-11-30 16:45:40 +0100 | [diff] [blame] | 235 | .hw_enabled = true, |
Christophe Leroy | 38e48b7 | 2018-09-17 06:22:50 +0000 | [diff] [blame] | 236 | .rsr_mask = BIT(28), /* RSR Bit SWRS */ |
Anton Vorontsov | 0d7b101 | 2008-07-03 23:51:36 -0700 | [diff] [blame] | 237 | }, |
| 238 | }, |
Anton Vorontsov | ef8ab12 | 2008-07-03 23:51:32 -0700 | [diff] [blame] | 239 | {}, |
| 240 | }; |
Anton Vorontsov | 59ca1b0 | 2008-07-03 23:51:35 -0700 | [diff] [blame] | 241 | MODULE_DEVICE_TABLE(of, mpc8xxx_wdt_match); |
Anton Vorontsov | ef8ab12 | 2008-07-03 23:51:32 -0700 | [diff] [blame] | 242 | |
Grant Likely | 1c48a5c | 2011-02-17 02:43:24 -0700 | [diff] [blame] | 243 | static struct platform_driver mpc8xxx_wdt_driver = { |
Anton Vorontsov | 59ca1b0 | 2008-07-03 23:51:35 -0700 | [diff] [blame] | 244 | .probe = mpc8xxx_wdt_probe, |
Grant Likely | 4018294 | 2010-04-13 16:13:02 -0700 | [diff] [blame] | 245 | .driver = { |
| 246 | .name = "mpc8xxx_wdt", |
Grant Likely | 4018294 | 2010-04-13 16:13:02 -0700 | [diff] [blame] | 247 | .of_match_table = mpc8xxx_wdt_match, |
Kumar Gala | fabbfb9 | 2006-01-14 13:20:50 -0800 | [diff] [blame] | 248 | }, |
| 249 | }; |
| 250 | |
Anton Vorontsov | 59ca1b0 | 2008-07-03 23:51:35 -0700 | [diff] [blame] | 251 | static int __init mpc8xxx_wdt_init(void) |
Kumar Gala | fabbfb9 | 2006-01-14 13:20:50 -0800 | [diff] [blame] | 252 | { |
Grant Likely | 1c48a5c | 2011-02-17 02:43:24 -0700 | [diff] [blame] | 253 | return platform_driver_register(&mpc8xxx_wdt_driver); |
Kumar Gala | fabbfb9 | 2006-01-14 13:20:50 -0800 | [diff] [blame] | 254 | } |
Anton Vorontsov | 0d7b101 | 2008-07-03 23:51:36 -0700 | [diff] [blame] | 255 | arch_initcall(mpc8xxx_wdt_init); |
Kumar Gala | fabbfb9 | 2006-01-14 13:20:50 -0800 | [diff] [blame] | 256 | |
Anton Vorontsov | 59ca1b0 | 2008-07-03 23:51:35 -0700 | [diff] [blame] | 257 | static void __exit mpc8xxx_wdt_exit(void) |
Kumar Gala | fabbfb9 | 2006-01-14 13:20:50 -0800 | [diff] [blame] | 258 | { |
Grant Likely | 1c48a5c | 2011-02-17 02:43:24 -0700 | [diff] [blame] | 259 | platform_driver_unregister(&mpc8xxx_wdt_driver); |
Kumar Gala | fabbfb9 | 2006-01-14 13:20:50 -0800 | [diff] [blame] | 260 | } |
Anton Vorontsov | 59ca1b0 | 2008-07-03 23:51:35 -0700 | [diff] [blame] | 261 | module_exit(mpc8xxx_wdt_exit); |
Kumar Gala | fabbfb9 | 2006-01-14 13:20:50 -0800 | [diff] [blame] | 262 | |
| 263 | MODULE_AUTHOR("Dave Updegraff, Kumar Gala"); |
Anton Vorontsov | 0d7b101 | 2008-07-03 23:51:36 -0700 | [diff] [blame] | 264 | MODULE_DESCRIPTION("Driver for watchdog timer in MPC8xx/MPC83xx/MPC86xx " |
| 265 | "uProcessors"); |
Kumar Gala | fabbfb9 | 2006-01-14 13:20:50 -0800 | [diff] [blame] | 266 | MODULE_LICENSE("GPL"); |