xref: /OK3568_Linux_fs/kernel/drivers/watchdog/sbsa_gwdt.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0-only
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * SBSA(Server Base System Architecture) Generic Watchdog driver
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  * Copyright (c) 2015, Linaro Ltd.
6*4882a593Smuzhiyun  * Author: Fu Wei <fu.wei@linaro.org>
7*4882a593Smuzhiyun  *         Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
8*4882a593Smuzhiyun  *         Al Stone <al.stone@linaro.org>
9*4882a593Smuzhiyun  *         Timur Tabi <timur@codeaurora.org>
10*4882a593Smuzhiyun  *
11*4882a593Smuzhiyun  * ARM SBSA Generic Watchdog has two stage timeouts:
12*4882a593Smuzhiyun  * the first signal (WS0) is for alerting the system by interrupt,
13*4882a593Smuzhiyun  * the second one (WS1) is a real hardware reset.
14*4882a593Smuzhiyun  * More details about the hardware specification of this device:
15*4882a593Smuzhiyun  * ARM DEN0029B - Server Base System Architecture (SBSA)
16*4882a593Smuzhiyun  *
17*4882a593Smuzhiyun  * This driver can operate ARM SBSA Generic Watchdog as a single stage watchdog
18*4882a593Smuzhiyun  * or a two stages watchdog, it's set up by the module parameter "action".
19*4882a593Smuzhiyun  * In the single stage mode, when the timeout is reached, your system
20*4882a593Smuzhiyun  * will be reset by WS1. The first signal (WS0) is ignored.
21*4882a593Smuzhiyun  * In the two stages mode, when the timeout is reached, the first signal (WS0)
22*4882a593Smuzhiyun  * will trigger panic. If the system is getting into trouble and cannot be reset
23*4882a593Smuzhiyun  * by panic or restart properly by the kdump kernel(if supported), then the
24*4882a593Smuzhiyun  * second stage (as long as the first stage) will be reached, system will be
25*4882a593Smuzhiyun  * reset by WS1. This function can help administrator to backup the system
26*4882a593Smuzhiyun  * context info by panic console output or kdump.
27*4882a593Smuzhiyun  *
28*4882a593Smuzhiyun  * SBSA GWDT:
29*4882a593Smuzhiyun  * if action is 1 (the two stages mode):
30*4882a593Smuzhiyun  * |--------WOR-------WS0--------WOR-------WS1
31*4882a593Smuzhiyun  * |----timeout-----(panic)----timeout-----reset
32*4882a593Smuzhiyun  *
33*4882a593Smuzhiyun  * if action is 0 (the single stage mode):
34*4882a593Smuzhiyun  * |------WOR-----WS0(ignored)-----WOR------WS1
35*4882a593Smuzhiyun  * |--------------timeout-------------------reset
36*4882a593Smuzhiyun  *
37*4882a593Smuzhiyun  * Note: Since this watchdog timer has two stages, and each stage is determined
38*4882a593Smuzhiyun  * by WOR, in the single stage mode, the timeout is (WOR * 2); in the two
39*4882a593Smuzhiyun  * stages mode, the timeout is WOR. The maximum timeout in the two stages mode
40*4882a593Smuzhiyun  * is half of that in the single stage mode.
41*4882a593Smuzhiyun  */
42*4882a593Smuzhiyun 
43*4882a593Smuzhiyun #include <linux/io.h>
44*4882a593Smuzhiyun #include <linux/io-64-nonatomic-lo-hi.h>
45*4882a593Smuzhiyun #include <linux/interrupt.h>
46*4882a593Smuzhiyun #include <linux/module.h>
47*4882a593Smuzhiyun #include <linux/moduleparam.h>
48*4882a593Smuzhiyun #include <linux/of.h>
49*4882a593Smuzhiyun #include <linux/of_device.h>
50*4882a593Smuzhiyun #include <linux/platform_device.h>
51*4882a593Smuzhiyun #include <linux/uaccess.h>
52*4882a593Smuzhiyun #include <linux/watchdog.h>
53*4882a593Smuzhiyun #include <asm/arch_timer.h>
54*4882a593Smuzhiyun 
55*4882a593Smuzhiyun #define DRV_NAME		"sbsa-gwdt"
56*4882a593Smuzhiyun #define WATCHDOG_NAME		"SBSA Generic Watchdog"
57*4882a593Smuzhiyun 
58*4882a593Smuzhiyun /* SBSA Generic Watchdog register definitions */
59*4882a593Smuzhiyun /* refresh frame */
60*4882a593Smuzhiyun #define SBSA_GWDT_WRR		0x000
61*4882a593Smuzhiyun 
62*4882a593Smuzhiyun /* control frame */
63*4882a593Smuzhiyun #define SBSA_GWDT_WCS		0x000
64*4882a593Smuzhiyun #define SBSA_GWDT_WOR		0x008
65*4882a593Smuzhiyun #define SBSA_GWDT_WCV		0x010
66*4882a593Smuzhiyun 
67*4882a593Smuzhiyun /* refresh/control frame */
68*4882a593Smuzhiyun #define SBSA_GWDT_W_IIDR	0xfcc
69*4882a593Smuzhiyun #define SBSA_GWDT_IDR		0xfd0
70*4882a593Smuzhiyun 
71*4882a593Smuzhiyun /* Watchdog Control and Status Register */
72*4882a593Smuzhiyun #define SBSA_GWDT_WCS_EN	BIT(0)
73*4882a593Smuzhiyun #define SBSA_GWDT_WCS_WS0	BIT(1)
74*4882a593Smuzhiyun #define SBSA_GWDT_WCS_WS1	BIT(2)
75*4882a593Smuzhiyun 
76*4882a593Smuzhiyun /**
77*4882a593Smuzhiyun  * struct sbsa_gwdt - Internal representation of the SBSA GWDT
78*4882a593Smuzhiyun  * @wdd:		kernel watchdog_device structure
79*4882a593Smuzhiyun  * @clk:		store the System Counter clock frequency, in Hz.
80*4882a593Smuzhiyun  * @refresh_base:	Virtual address of the watchdog refresh frame
81*4882a593Smuzhiyun  * @control_base:	Virtual address of the watchdog control frame
82*4882a593Smuzhiyun  */
83*4882a593Smuzhiyun struct sbsa_gwdt {
84*4882a593Smuzhiyun 	struct watchdog_device	wdd;
85*4882a593Smuzhiyun 	u32			clk;
86*4882a593Smuzhiyun 	void __iomem		*refresh_base;
87*4882a593Smuzhiyun 	void __iomem		*control_base;
88*4882a593Smuzhiyun };
89*4882a593Smuzhiyun 
90*4882a593Smuzhiyun #define DEFAULT_TIMEOUT		10 /* seconds */
91*4882a593Smuzhiyun 
92*4882a593Smuzhiyun static unsigned int timeout;
93*4882a593Smuzhiyun module_param(timeout, uint, 0);
94*4882a593Smuzhiyun MODULE_PARM_DESC(timeout,
95*4882a593Smuzhiyun 		 "Watchdog timeout in seconds. (>=0, default="
96*4882a593Smuzhiyun 		 __MODULE_STRING(DEFAULT_TIMEOUT) ")");
97*4882a593Smuzhiyun 
98*4882a593Smuzhiyun /*
99*4882a593Smuzhiyun  * action refers to action taken when watchdog gets WS0
100*4882a593Smuzhiyun  * 0 = skip
101*4882a593Smuzhiyun  * 1 = panic
102*4882a593Smuzhiyun  * defaults to skip (0)
103*4882a593Smuzhiyun  */
104*4882a593Smuzhiyun static int action;
105*4882a593Smuzhiyun module_param(action, int, 0);
106*4882a593Smuzhiyun MODULE_PARM_DESC(action, "after watchdog gets WS0 interrupt, do: "
107*4882a593Smuzhiyun 		 "0 = skip(*)  1 = panic");
108*4882a593Smuzhiyun 
109*4882a593Smuzhiyun static bool nowayout = WATCHDOG_NOWAYOUT;
110*4882a593Smuzhiyun module_param(nowayout, bool, S_IRUGO);
111*4882a593Smuzhiyun MODULE_PARM_DESC(nowayout,
112*4882a593Smuzhiyun 		 "Watchdog cannot be stopped once started (default="
113*4882a593Smuzhiyun 		 __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
114*4882a593Smuzhiyun 
115*4882a593Smuzhiyun /*
116*4882a593Smuzhiyun  * watchdog operation functions
117*4882a593Smuzhiyun  */
sbsa_gwdt_set_timeout(struct watchdog_device * wdd,unsigned int timeout)118*4882a593Smuzhiyun static int sbsa_gwdt_set_timeout(struct watchdog_device *wdd,
119*4882a593Smuzhiyun 				 unsigned int timeout)
120*4882a593Smuzhiyun {
121*4882a593Smuzhiyun 	struct sbsa_gwdt *gwdt = watchdog_get_drvdata(wdd);
122*4882a593Smuzhiyun 
123*4882a593Smuzhiyun 	wdd->timeout = timeout;
124*4882a593Smuzhiyun 
125*4882a593Smuzhiyun 	if (action)
126*4882a593Smuzhiyun 		writel(gwdt->clk * timeout,
127*4882a593Smuzhiyun 		       gwdt->control_base + SBSA_GWDT_WOR);
128*4882a593Smuzhiyun 	else
129*4882a593Smuzhiyun 		/*
130*4882a593Smuzhiyun 		 * In the single stage mode, The first signal (WS0) is ignored,
131*4882a593Smuzhiyun 		 * the timeout is (WOR * 2), so the WOR should be configured
132*4882a593Smuzhiyun 		 * to half value of timeout.
133*4882a593Smuzhiyun 		 */
134*4882a593Smuzhiyun 		writel(gwdt->clk / 2 * timeout,
135*4882a593Smuzhiyun 		       gwdt->control_base + SBSA_GWDT_WOR);
136*4882a593Smuzhiyun 
137*4882a593Smuzhiyun 	return 0;
138*4882a593Smuzhiyun }
139*4882a593Smuzhiyun 
sbsa_gwdt_get_timeleft(struct watchdog_device * wdd)140*4882a593Smuzhiyun static unsigned int sbsa_gwdt_get_timeleft(struct watchdog_device *wdd)
141*4882a593Smuzhiyun {
142*4882a593Smuzhiyun 	struct sbsa_gwdt *gwdt = watchdog_get_drvdata(wdd);
143*4882a593Smuzhiyun 	u64 timeleft = 0;
144*4882a593Smuzhiyun 
145*4882a593Smuzhiyun 	/*
146*4882a593Smuzhiyun 	 * In the single stage mode, if WS0 is deasserted
147*4882a593Smuzhiyun 	 * (watchdog is in the first stage),
148*4882a593Smuzhiyun 	 * timeleft = WOR + (WCV - system counter)
149*4882a593Smuzhiyun 	 */
150*4882a593Smuzhiyun 	if (!action &&
151*4882a593Smuzhiyun 	    !(readl(gwdt->control_base + SBSA_GWDT_WCS) & SBSA_GWDT_WCS_WS0))
152*4882a593Smuzhiyun 		timeleft += readl(gwdt->control_base + SBSA_GWDT_WOR);
153*4882a593Smuzhiyun 
154*4882a593Smuzhiyun 	timeleft += lo_hi_readq(gwdt->control_base + SBSA_GWDT_WCV) -
155*4882a593Smuzhiyun 		    arch_timer_read_counter();
156*4882a593Smuzhiyun 
157*4882a593Smuzhiyun 	do_div(timeleft, gwdt->clk);
158*4882a593Smuzhiyun 
159*4882a593Smuzhiyun 	return timeleft;
160*4882a593Smuzhiyun }
161*4882a593Smuzhiyun 
sbsa_gwdt_keepalive(struct watchdog_device * wdd)162*4882a593Smuzhiyun static int sbsa_gwdt_keepalive(struct watchdog_device *wdd)
163*4882a593Smuzhiyun {
164*4882a593Smuzhiyun 	struct sbsa_gwdt *gwdt = watchdog_get_drvdata(wdd);
165*4882a593Smuzhiyun 
166*4882a593Smuzhiyun 	/*
167*4882a593Smuzhiyun 	 * Writing WRR for an explicit watchdog refresh.
168*4882a593Smuzhiyun 	 * You can write anyting (like 0).
169*4882a593Smuzhiyun 	 */
170*4882a593Smuzhiyun 	writel(0, gwdt->refresh_base + SBSA_GWDT_WRR);
171*4882a593Smuzhiyun 
172*4882a593Smuzhiyun 	return 0;
173*4882a593Smuzhiyun }
174*4882a593Smuzhiyun 
sbsa_gwdt_start(struct watchdog_device * wdd)175*4882a593Smuzhiyun static int sbsa_gwdt_start(struct watchdog_device *wdd)
176*4882a593Smuzhiyun {
177*4882a593Smuzhiyun 	struct sbsa_gwdt *gwdt = watchdog_get_drvdata(wdd);
178*4882a593Smuzhiyun 
179*4882a593Smuzhiyun 	/* writing WCS will cause an explicit watchdog refresh */
180*4882a593Smuzhiyun 	writel(SBSA_GWDT_WCS_EN, gwdt->control_base + SBSA_GWDT_WCS);
181*4882a593Smuzhiyun 
182*4882a593Smuzhiyun 	return 0;
183*4882a593Smuzhiyun }
184*4882a593Smuzhiyun 
sbsa_gwdt_stop(struct watchdog_device * wdd)185*4882a593Smuzhiyun static int sbsa_gwdt_stop(struct watchdog_device *wdd)
186*4882a593Smuzhiyun {
187*4882a593Smuzhiyun 	struct sbsa_gwdt *gwdt = watchdog_get_drvdata(wdd);
188*4882a593Smuzhiyun 
189*4882a593Smuzhiyun 	/* Simply write 0 to WCS to clean WCS_EN bit */
190*4882a593Smuzhiyun 	writel(0, gwdt->control_base + SBSA_GWDT_WCS);
191*4882a593Smuzhiyun 
192*4882a593Smuzhiyun 	return 0;
193*4882a593Smuzhiyun }
194*4882a593Smuzhiyun 
sbsa_gwdt_interrupt(int irq,void * dev_id)195*4882a593Smuzhiyun static irqreturn_t sbsa_gwdt_interrupt(int irq, void *dev_id)
196*4882a593Smuzhiyun {
197*4882a593Smuzhiyun 	panic(WATCHDOG_NAME " timeout");
198*4882a593Smuzhiyun 
199*4882a593Smuzhiyun 	return IRQ_HANDLED;
200*4882a593Smuzhiyun }
201*4882a593Smuzhiyun 
202*4882a593Smuzhiyun static const struct watchdog_info sbsa_gwdt_info = {
203*4882a593Smuzhiyun 	.identity	= WATCHDOG_NAME,
204*4882a593Smuzhiyun 	.options	= WDIOF_SETTIMEOUT |
205*4882a593Smuzhiyun 			  WDIOF_KEEPALIVEPING |
206*4882a593Smuzhiyun 			  WDIOF_MAGICCLOSE |
207*4882a593Smuzhiyun 			  WDIOF_CARDRESET,
208*4882a593Smuzhiyun };
209*4882a593Smuzhiyun 
210*4882a593Smuzhiyun static const struct watchdog_ops sbsa_gwdt_ops = {
211*4882a593Smuzhiyun 	.owner		= THIS_MODULE,
212*4882a593Smuzhiyun 	.start		= sbsa_gwdt_start,
213*4882a593Smuzhiyun 	.stop		= sbsa_gwdt_stop,
214*4882a593Smuzhiyun 	.ping		= sbsa_gwdt_keepalive,
215*4882a593Smuzhiyun 	.set_timeout	= sbsa_gwdt_set_timeout,
216*4882a593Smuzhiyun 	.get_timeleft	= sbsa_gwdt_get_timeleft,
217*4882a593Smuzhiyun };
218*4882a593Smuzhiyun 
sbsa_gwdt_probe(struct platform_device * pdev)219*4882a593Smuzhiyun static int sbsa_gwdt_probe(struct platform_device *pdev)
220*4882a593Smuzhiyun {
221*4882a593Smuzhiyun 	void __iomem *rf_base, *cf_base;
222*4882a593Smuzhiyun 	struct device *dev = &pdev->dev;
223*4882a593Smuzhiyun 	struct watchdog_device *wdd;
224*4882a593Smuzhiyun 	struct sbsa_gwdt *gwdt;
225*4882a593Smuzhiyun 	int ret, irq;
226*4882a593Smuzhiyun 	u32 status;
227*4882a593Smuzhiyun 
228*4882a593Smuzhiyun 	gwdt = devm_kzalloc(dev, sizeof(*gwdt), GFP_KERNEL);
229*4882a593Smuzhiyun 	if (!gwdt)
230*4882a593Smuzhiyun 		return -ENOMEM;
231*4882a593Smuzhiyun 	platform_set_drvdata(pdev, gwdt);
232*4882a593Smuzhiyun 
233*4882a593Smuzhiyun 	cf_base = devm_platform_ioremap_resource(pdev, 0);
234*4882a593Smuzhiyun 	if (IS_ERR(cf_base))
235*4882a593Smuzhiyun 		return PTR_ERR(cf_base);
236*4882a593Smuzhiyun 
237*4882a593Smuzhiyun 	rf_base = devm_platform_ioremap_resource(pdev, 1);
238*4882a593Smuzhiyun 	if (IS_ERR(rf_base))
239*4882a593Smuzhiyun 		return PTR_ERR(rf_base);
240*4882a593Smuzhiyun 
241*4882a593Smuzhiyun 	/*
242*4882a593Smuzhiyun 	 * Get the frequency of system counter from the cp15 interface of ARM
243*4882a593Smuzhiyun 	 * Generic timer. We don't need to check it, because if it returns "0",
244*4882a593Smuzhiyun 	 * system would panic in very early stage.
245*4882a593Smuzhiyun 	 */
246*4882a593Smuzhiyun 	gwdt->clk = arch_timer_get_cntfrq();
247*4882a593Smuzhiyun 	gwdt->refresh_base = rf_base;
248*4882a593Smuzhiyun 	gwdt->control_base = cf_base;
249*4882a593Smuzhiyun 
250*4882a593Smuzhiyun 	wdd = &gwdt->wdd;
251*4882a593Smuzhiyun 	wdd->parent = dev;
252*4882a593Smuzhiyun 	wdd->info = &sbsa_gwdt_info;
253*4882a593Smuzhiyun 	wdd->ops = &sbsa_gwdt_ops;
254*4882a593Smuzhiyun 	wdd->min_timeout = 1;
255*4882a593Smuzhiyun 	wdd->max_hw_heartbeat_ms = U32_MAX / gwdt->clk * 1000;
256*4882a593Smuzhiyun 	wdd->timeout = DEFAULT_TIMEOUT;
257*4882a593Smuzhiyun 	watchdog_set_drvdata(wdd, gwdt);
258*4882a593Smuzhiyun 	watchdog_set_nowayout(wdd, nowayout);
259*4882a593Smuzhiyun 
260*4882a593Smuzhiyun 	status = readl(cf_base + SBSA_GWDT_WCS);
261*4882a593Smuzhiyun 	if (status & SBSA_GWDT_WCS_WS1) {
262*4882a593Smuzhiyun 		dev_warn(dev, "System reset by WDT.\n");
263*4882a593Smuzhiyun 		wdd->bootstatus |= WDIOF_CARDRESET;
264*4882a593Smuzhiyun 	}
265*4882a593Smuzhiyun 	if (status & SBSA_GWDT_WCS_EN)
266*4882a593Smuzhiyun 		set_bit(WDOG_HW_RUNNING, &wdd->status);
267*4882a593Smuzhiyun 
268*4882a593Smuzhiyun 	if (action) {
269*4882a593Smuzhiyun 		irq = platform_get_irq(pdev, 0);
270*4882a593Smuzhiyun 		if (irq < 0) {
271*4882a593Smuzhiyun 			action = 0;
272*4882a593Smuzhiyun 			dev_warn(dev, "unable to get ws0 interrupt.\n");
273*4882a593Smuzhiyun 		} else {
274*4882a593Smuzhiyun 			/*
275*4882a593Smuzhiyun 			 * In case there is a pending ws0 interrupt, just ping
276*4882a593Smuzhiyun 			 * the watchdog before registering the interrupt routine
277*4882a593Smuzhiyun 			 */
278*4882a593Smuzhiyun 			writel(0, rf_base + SBSA_GWDT_WRR);
279*4882a593Smuzhiyun 			if (devm_request_irq(dev, irq, sbsa_gwdt_interrupt, 0,
280*4882a593Smuzhiyun 					     pdev->name, gwdt)) {
281*4882a593Smuzhiyun 				action = 0;
282*4882a593Smuzhiyun 				dev_warn(dev, "unable to request IRQ %d.\n",
283*4882a593Smuzhiyun 					 irq);
284*4882a593Smuzhiyun 			}
285*4882a593Smuzhiyun 		}
286*4882a593Smuzhiyun 		if (!action)
287*4882a593Smuzhiyun 			dev_warn(dev, "falling back to single stage mode.\n");
288*4882a593Smuzhiyun 	}
289*4882a593Smuzhiyun 	/*
290*4882a593Smuzhiyun 	 * In the single stage mode, The first signal (WS0) is ignored,
291*4882a593Smuzhiyun 	 * the timeout is (WOR * 2), so the maximum timeout should be doubled.
292*4882a593Smuzhiyun 	 */
293*4882a593Smuzhiyun 	if (!action)
294*4882a593Smuzhiyun 		wdd->max_hw_heartbeat_ms *= 2;
295*4882a593Smuzhiyun 
296*4882a593Smuzhiyun 	watchdog_init_timeout(wdd, timeout, dev);
297*4882a593Smuzhiyun 	/*
298*4882a593Smuzhiyun 	 * Update timeout to WOR.
299*4882a593Smuzhiyun 	 * Because of the explicit watchdog refresh mechanism,
300*4882a593Smuzhiyun 	 * it's also a ping, if watchdog is enabled.
301*4882a593Smuzhiyun 	 */
302*4882a593Smuzhiyun 	sbsa_gwdt_set_timeout(wdd, wdd->timeout);
303*4882a593Smuzhiyun 
304*4882a593Smuzhiyun 	watchdog_stop_on_reboot(wdd);
305*4882a593Smuzhiyun 	ret = devm_watchdog_register_device(dev, wdd);
306*4882a593Smuzhiyun 	if (ret)
307*4882a593Smuzhiyun 		return ret;
308*4882a593Smuzhiyun 
309*4882a593Smuzhiyun 	dev_info(dev, "Initialized with %ds timeout @ %u Hz, action=%d.%s\n",
310*4882a593Smuzhiyun 		 wdd->timeout, gwdt->clk, action,
311*4882a593Smuzhiyun 		 status & SBSA_GWDT_WCS_EN ? " [enabled]" : "");
312*4882a593Smuzhiyun 
313*4882a593Smuzhiyun 	return 0;
314*4882a593Smuzhiyun }
315*4882a593Smuzhiyun 
316*4882a593Smuzhiyun /* Disable watchdog if it is active during suspend */
sbsa_gwdt_suspend(struct device * dev)317*4882a593Smuzhiyun static int __maybe_unused sbsa_gwdt_suspend(struct device *dev)
318*4882a593Smuzhiyun {
319*4882a593Smuzhiyun 	struct sbsa_gwdt *gwdt = dev_get_drvdata(dev);
320*4882a593Smuzhiyun 
321*4882a593Smuzhiyun 	if (watchdog_active(&gwdt->wdd))
322*4882a593Smuzhiyun 		sbsa_gwdt_stop(&gwdt->wdd);
323*4882a593Smuzhiyun 
324*4882a593Smuzhiyun 	return 0;
325*4882a593Smuzhiyun }
326*4882a593Smuzhiyun 
327*4882a593Smuzhiyun /* Enable watchdog if necessary */
sbsa_gwdt_resume(struct device * dev)328*4882a593Smuzhiyun static int __maybe_unused sbsa_gwdt_resume(struct device *dev)
329*4882a593Smuzhiyun {
330*4882a593Smuzhiyun 	struct sbsa_gwdt *gwdt = dev_get_drvdata(dev);
331*4882a593Smuzhiyun 
332*4882a593Smuzhiyun 	if (watchdog_active(&gwdt->wdd))
333*4882a593Smuzhiyun 		sbsa_gwdt_start(&gwdt->wdd);
334*4882a593Smuzhiyun 
335*4882a593Smuzhiyun 	return 0;
336*4882a593Smuzhiyun }
337*4882a593Smuzhiyun 
338*4882a593Smuzhiyun static const struct dev_pm_ops sbsa_gwdt_pm_ops = {
339*4882a593Smuzhiyun 	SET_SYSTEM_SLEEP_PM_OPS(sbsa_gwdt_suspend, sbsa_gwdt_resume)
340*4882a593Smuzhiyun };
341*4882a593Smuzhiyun 
342*4882a593Smuzhiyun static const struct of_device_id sbsa_gwdt_of_match[] = {
343*4882a593Smuzhiyun 	{ .compatible = "arm,sbsa-gwdt", },
344*4882a593Smuzhiyun 	{},
345*4882a593Smuzhiyun };
346*4882a593Smuzhiyun MODULE_DEVICE_TABLE(of, sbsa_gwdt_of_match);
347*4882a593Smuzhiyun 
348*4882a593Smuzhiyun static const struct platform_device_id sbsa_gwdt_pdev_match[] = {
349*4882a593Smuzhiyun 	{ .name = DRV_NAME, },
350*4882a593Smuzhiyun 	{},
351*4882a593Smuzhiyun };
352*4882a593Smuzhiyun MODULE_DEVICE_TABLE(platform, sbsa_gwdt_pdev_match);
353*4882a593Smuzhiyun 
354*4882a593Smuzhiyun static struct platform_driver sbsa_gwdt_driver = {
355*4882a593Smuzhiyun 	.driver = {
356*4882a593Smuzhiyun 		.name = DRV_NAME,
357*4882a593Smuzhiyun 		.pm = &sbsa_gwdt_pm_ops,
358*4882a593Smuzhiyun 		.of_match_table = sbsa_gwdt_of_match,
359*4882a593Smuzhiyun 	},
360*4882a593Smuzhiyun 	.probe = sbsa_gwdt_probe,
361*4882a593Smuzhiyun 	.id_table = sbsa_gwdt_pdev_match,
362*4882a593Smuzhiyun };
363*4882a593Smuzhiyun 
364*4882a593Smuzhiyun module_platform_driver(sbsa_gwdt_driver);
365*4882a593Smuzhiyun 
366*4882a593Smuzhiyun MODULE_DESCRIPTION("SBSA Generic Watchdog Driver");
367*4882a593Smuzhiyun MODULE_AUTHOR("Fu Wei <fu.wei@linaro.org>");
368*4882a593Smuzhiyun MODULE_AUTHOR("Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>");
369*4882a593Smuzhiyun MODULE_AUTHOR("Al Stone <al.stone@linaro.org>");
370*4882a593Smuzhiyun MODULE_AUTHOR("Timur Tabi <timur@codeaurora.org>");
371*4882a593Smuzhiyun MODULE_LICENSE("GPL v2");
372*4882a593Smuzhiyun MODULE_ALIAS("platform:" DRV_NAME);
373