.. | .. |
---|
10 | 10 | #include <linux/module.h> |
---|
11 | 11 | #include <linux/mod_devicetable.h> |
---|
12 | 12 | #include <linux/platform_device.h> |
---|
| 13 | +#include <linux/pm_wakeirq.h> |
---|
13 | 14 | #include <linux/rtc.h> |
---|
14 | 15 | |
---|
15 | 16 | #define SRTC_LPPDR_INIT 0x41736166 /* init for glitch detect */ |
---|
.. | .. |
---|
278 | 279 | static int mxc_rtc_probe(struct platform_device *pdev) |
---|
279 | 280 | { |
---|
280 | 281 | struct mxc_rtc_data *pdata; |
---|
281 | | - struct resource *res; |
---|
282 | 282 | void __iomem *ioaddr; |
---|
283 | 283 | int ret = 0; |
---|
284 | 284 | |
---|
.. | .. |
---|
286 | 286 | if (!pdata) |
---|
287 | 287 | return -ENOMEM; |
---|
288 | 288 | |
---|
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); |
---|
291 | 290 | if (IS_ERR(pdata->ioaddr)) |
---|
292 | 291 | return PTR_ERR(pdata->ioaddr); |
---|
293 | 292 | |
---|
.. | .. |
---|
305 | 304 | return pdata->irq; |
---|
306 | 305 | |
---|
307 | 306 | 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"); |
---|
308 | 310 | |
---|
309 | 311 | ret = clk_prepare_enable(pdata->clk); |
---|
310 | 312 | if (ret) |
---|
.. | .. |
---|
335 | 337 | } |
---|
336 | 338 | |
---|
337 | 339 | 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); |
---|
339 | 342 | return PTR_ERR(pdata->rtc); |
---|
| 343 | + } |
---|
340 | 344 | |
---|
341 | 345 | pdata->rtc->ops = &mxc_rtc_ops; |
---|
342 | 346 | pdata->rtc->range_max = U32_MAX; |
---|
.. | .. |
---|
367 | 371 | return 0; |
---|
368 | 372 | } |
---|
369 | 373 | |
---|
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 | | - |
---|
394 | 374 | static const struct of_device_id mxc_ids[] = { |
---|
395 | 375 | { .compatible = "fsl,imx53-rtc", }, |
---|
396 | 376 | {} |
---|
.. | .. |
---|
401 | 381 | .driver = { |
---|
402 | 382 | .name = "mxc_rtc_v2", |
---|
403 | 383 | .of_match_table = mxc_ids, |
---|
404 | | - .pm = &mxc_rtc_pm_ops, |
---|
405 | 384 | }, |
---|
406 | 385 | .probe = mxc_rtc_probe, |
---|
407 | 386 | .remove = mxc_rtc_remove, |
---|