@@ -173,6 +173,8 @@ static int apple_wdt_probe(struct platform_device *pdev)
173
173
if (!wdt -> clk_rate )
174
174
return - EINVAL ;
175
175
176
+ platform_set_drvdata (pdev , wdt );
177
+
176
178
wdt -> wdd .ops = & apple_wdt_ops ;
177
179
wdt -> wdd .info = & apple_wdt_info ;
178
180
wdt -> wdd .max_timeout = U32_MAX / wdt -> clk_rate ;
@@ -190,6 +192,28 @@ static int apple_wdt_probe(struct platform_device *pdev)
190
192
return devm_watchdog_register_device (dev , & wdt -> wdd );
191
193
}
192
194
195
+ static int apple_wdt_resume (struct device * dev )
196
+ {
197
+ struct apple_wdt * wdt = dev_get_drvdata (dev );
198
+
199
+ if (watchdog_active (& wdt -> wdd ) || watchdog_hw_running (& wdt -> wdd ))
200
+ apple_wdt_start (& wdt -> wdd );
201
+
202
+ return 0 ;
203
+ }
204
+
205
+ static int apple_wdt_suspend (struct device * dev )
206
+ {
207
+ struct apple_wdt * wdt = dev_get_drvdata (dev );
208
+
209
+ if (watchdog_active (& wdt -> wdd ) || watchdog_hw_running (& wdt -> wdd ))
210
+ apple_wdt_stop (& wdt -> wdd );
211
+
212
+ return 0 ;
213
+ }
214
+
215
+ static DEFINE_SIMPLE_DEV_PM_OPS (apple_wdt_pm_ops , apple_wdt_suspend , apple_wdt_resume ) ;
216
+
193
217
static const struct of_device_id apple_wdt_of_match [] = {
194
218
{ .compatible = "apple,wdt" },
195
219
{},
@@ -200,6 +224,7 @@ static struct platform_driver apple_wdt_driver = {
200
224
.driver = {
201
225
.name = "apple-watchdog" ,
202
226
.of_match_table = apple_wdt_of_match ,
227
+ .pm = pm_sleep_ptr (& apple_wdt_pm_ops ),
203
228
},
204
229
.probe = apple_wdt_probe ,
205
230
};
0 commit comments