hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/soc/ti/pm33xx.c
....@@ -19,6 +19,7 @@
1919 #include <linux/of_address.h>
2020 #include <linux/platform_data/pm33xx.h>
2121 #include <linux/platform_device.h>
22
+#include <linux/pm_runtime.h>
2223 #include <linux/rtc.h>
2324 #include <linux/rtc/rtc-omap.h>
2425 #include <linux/sizes.h>
....@@ -528,7 +529,7 @@
528529
529530 ret = am33xx_pm_alloc_sram();
530531 if (ret)
531
- return ret;
532
+ goto err_wkup_m3_ipc_put;
532533
533534 ret = am33xx_pm_rtc_setup();
534535 if (ret)
....@@ -555,28 +556,41 @@
555556 suspend_wfi_flags |= WFI_FLAG_WAKE_M3;
556557 #endif /* CONFIG_SUSPEND */
557558
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
+
558566 ret = pm_ops->init(am33xx_do_sram_idle);
559567 if (ret) {
560568 dev_err(dev, "Unable to call core pm init!\n");
561569 ret = -ENODEV;
562
- goto err_put_wkup_m3_ipc;
570
+ goto err_pm_runtime_put;
563571 }
564572
565573 return 0;
566574
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);
569579 err_unsetup_rtc:
570580 iounmap(rtc_base_virt);
571581 clk_put(rtc_fck);
572582 err_free_sram:
573583 am33xx_pm_free_sram();
574584 pm33xx_dev = NULL;
585
+err_wkup_m3_ipc_put:
586
+ wkup_m3_ipc_put(m3_ipc);
575587 return ret;
576588 }
577589
578590 static int am33xx_pm_remove(struct platform_device *pdev)
579591 {
592
+ pm_runtime_put_sync(&pdev->dev);
593
+ pm_runtime_disable(&pdev->dev);
580594 if (pm_ops->deinit)
581595 pm_ops->deinit();
582596 suspend_set_ops(NULL);