| .. | .. |
|---|
| 19 | 19 | #include <linux/of_address.h> |
|---|
| 20 | 20 | #include <linux/platform_data/pm33xx.h> |
|---|
| 21 | 21 | #include <linux/platform_device.h> |
|---|
| 22 | +#include <linux/pm_runtime.h> |
|---|
| 22 | 23 | #include <linux/rtc.h> |
|---|
| 23 | 24 | #include <linux/rtc/rtc-omap.h> |
|---|
| 24 | 25 | #include <linux/sizes.h> |
|---|
| .. | .. |
|---|
| 528 | 529 | |
|---|
| 529 | 530 | ret = am33xx_pm_alloc_sram(); |
|---|
| 530 | 531 | if (ret) |
|---|
| 531 | | - return ret; |
|---|
| 532 | + goto err_wkup_m3_ipc_put; |
|---|
| 532 | 533 | |
|---|
| 533 | 534 | ret = am33xx_pm_rtc_setup(); |
|---|
| 534 | 535 | if (ret) |
|---|
| .. | .. |
|---|
| 555 | 556 | suspend_wfi_flags |= WFI_FLAG_WAKE_M3; |
|---|
| 556 | 557 | #endif /* CONFIG_SUSPEND */ |
|---|
| 557 | 558 | |
|---|
| 559 | + pm_runtime_enable(dev); |
|---|
| 560 | + ret = pm_runtime_get_sync(dev); |
|---|
| 561 | + if (ret < 0) { |
|---|
| 562 | + pm_runtime_put_noidle(dev); |
|---|
| 563 | + goto err_pm_runtime_disable; |
|---|
| 564 | + } |
|---|
| 565 | + |
|---|
| 558 | 566 | ret = pm_ops->init(am33xx_do_sram_idle); |
|---|
| 559 | 567 | if (ret) { |
|---|
| 560 | 568 | dev_err(dev, "Unable to call core pm init!\n"); |
|---|
| 561 | 569 | ret = -ENODEV; |
|---|
| 562 | | - goto err_put_wkup_m3_ipc; |
|---|
| 570 | + goto err_pm_runtime_put; |
|---|
| 563 | 571 | } |
|---|
| 564 | 572 | |
|---|
| 565 | 573 | return 0; |
|---|
| 566 | 574 | |
|---|
| 567 | | -err_put_wkup_m3_ipc: |
|---|
| 568 | | - wkup_m3_ipc_put(m3_ipc); |
|---|
| 575 | +err_pm_runtime_put: |
|---|
| 576 | + pm_runtime_put_sync(dev); |
|---|
| 577 | +err_pm_runtime_disable: |
|---|
| 578 | + pm_runtime_disable(dev); |
|---|
| 569 | 579 | err_unsetup_rtc: |
|---|
| 570 | 580 | iounmap(rtc_base_virt); |
|---|
| 571 | 581 | clk_put(rtc_fck); |
|---|
| 572 | 582 | err_free_sram: |
|---|
| 573 | 583 | am33xx_pm_free_sram(); |
|---|
| 574 | 584 | pm33xx_dev = NULL; |
|---|
| 585 | +err_wkup_m3_ipc_put: |
|---|
| 586 | + wkup_m3_ipc_put(m3_ipc); |
|---|
| 575 | 587 | return ret; |
|---|
| 576 | 588 | } |
|---|
| 577 | 589 | |
|---|
| 578 | 590 | static int am33xx_pm_remove(struct platform_device *pdev) |
|---|
| 579 | 591 | { |
|---|
| 592 | + pm_runtime_put_sync(&pdev->dev); |
|---|
| 593 | + pm_runtime_disable(&pdev->dev); |
|---|
| 580 | 594 | if (pm_ops->deinit) |
|---|
| 581 | 595 | pm_ops->deinit(); |
|---|
| 582 | 596 | suspend_set_ops(NULL); |
|---|