hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/rtc/rtc-mxc_v2.c
....@@ -10,6 +10,7 @@
1010 #include <linux/module.h>
1111 #include <linux/mod_devicetable.h>
1212 #include <linux/platform_device.h>
13
+#include <linux/pm_wakeirq.h>
1314 #include <linux/rtc.h>
1415
1516 #define SRTC_LPPDR_INIT 0x41736166 /* init for glitch detect */
....@@ -278,7 +279,6 @@
278279 static int mxc_rtc_probe(struct platform_device *pdev)
279280 {
280281 struct mxc_rtc_data *pdata;
281
- struct resource *res;
282282 void __iomem *ioaddr;
283283 int ret = 0;
284284
....@@ -286,8 +286,7 @@
286286 if (!pdata)
287287 return -ENOMEM;
288288
289
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
290
- pdata->ioaddr = devm_ioremap_resource(&pdev->dev, res);
289
+ pdata->ioaddr = devm_platform_ioremap_resource(pdev, 0);
291290 if (IS_ERR(pdata->ioaddr))
292291 return PTR_ERR(pdata->ioaddr);
293292
....@@ -305,6 +304,9 @@
305304 return pdata->irq;
306305
307306 device_init_wakeup(&pdev->dev, 1);
307
+ ret = dev_pm_set_wake_irq(&pdev->dev, pdata->irq);
308
+ if (ret)
309
+ dev_err(&pdev->dev, "failed to enable irq wake\n");
308310
309311 ret = clk_prepare_enable(pdata->clk);
310312 if (ret)
....@@ -335,8 +337,10 @@
335337 }
336338
337339 pdata->rtc = devm_rtc_allocate_device(&pdev->dev);
338
- if (IS_ERR(pdata->rtc))
340
+ if (IS_ERR(pdata->rtc)) {
341
+ clk_disable_unprepare(pdata->clk);
339342 return PTR_ERR(pdata->rtc);
343
+ }
340344
341345 pdata->rtc->ops = &mxc_rtc_ops;
342346 pdata->rtc->range_max = U32_MAX;
....@@ -367,30 +371,6 @@
367371 return 0;
368372 }
369373
370
-#ifdef CONFIG_PM_SLEEP
371
-static int mxc_rtc_suspend(struct device *dev)
372
-{
373
- struct mxc_rtc_data *pdata = dev_get_drvdata(dev);
374
-
375
- if (device_may_wakeup(dev))
376
- enable_irq_wake(pdata->irq);
377
-
378
- return 0;
379
-}
380
-
381
-static int mxc_rtc_resume(struct device *dev)
382
-{
383
- struct mxc_rtc_data *pdata = dev_get_drvdata(dev);
384
-
385
- if (device_may_wakeup(dev))
386
- disable_irq_wake(pdata->irq);
387
-
388
- return 0;
389
-}
390
-#endif
391
-
392
-static SIMPLE_DEV_PM_OPS(mxc_rtc_pm_ops, mxc_rtc_suspend, mxc_rtc_resume);
393
-
394374 static const struct of_device_id mxc_ids[] = {
395375 { .compatible = "fsl,imx53-rtc", },
396376 {}
....@@ -401,7 +381,6 @@
401381 .driver = {
402382 .name = "mxc_rtc_v2",
403383 .of_match_table = mxc_ids,
404
- .pm = &mxc_rtc_pm_ops,
405384 },
406385 .probe = mxc_rtc_probe,
407386 .remove = mxc_rtc_remove,