Skip to contentSkip to conversation

pwm: lpss: add PM support for LPSS PWM

PATCH In review Qipeng Zha 2 participants 2 messages Sep 15, 2015

Subsystems (2)
lore
Share & tools
lore

Qipeng Zha

author
#0 lore raw

PATCH 1/1 pwm: lpss: add PM support for LPSS PWM

---
 drivers/pwm/pwm-lpss-pci.c      | 11 +++++++++++
 drivers/pwm/pwm-lpss-platform.c | 11 +++++++++++
 drivers/pwm/pwm-lpss.c          | 41 +++++++++++++++++++++++++++++++++++++++++
 drivers/pwm/pwm-lpss.h          |  1 +
 4 files changed, 64 insertions(+)
drivers/pwm/pwm-lpss-pci.c +11 -0
index 45042c1..e8c31d6 100644
@@ -13,6 +13,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/pci.h>
+#include <linux/pm_runtime.h>
 
 #include "pwm-lpss.h"
 
@@ -33,6 +34,12 @@ static int pwm_lpss_probe_pci(struct pci_dev *pdev,
 		return PTR_ERR(lpwm);
 
 	pci_set_drvdata(pdev, lpwm);
+
+	pm_runtime_set_autosuspend_delay(&pdev->dev, 5);
+	pm_runtime_use_autosuspend(&pdev->dev);
+	pm_runtime_put_noidle(&pdev->dev);
+	pm_runtime_allow(&pdev->dev);
+
 	return 0;
 }
 
@@ -40,6 +47,7 @@ static void pwm_lpss_remove_pci(struct pci_dev *pdev)
 {
 	struct pwm_lpss_chip *lpwm = pci_get_drvdata(pdev);
 
+	pm_runtime_forbid(&pdev->dev);
 	pwm_lpss_remove(lpwm);
 }
 
@@ -59,6 +67,9 @@ static struct pci_driver pwm_lpss_driver_pci = {
 	.id_table = pwm_lpss_pci_ids,
 	.probe = pwm_lpss_probe_pci,
 	.remove = pwm_lpss_remove_pci,
+	.driver = {
+		.pm = &pwm_lpss_pm,
+	},
 };
 module_pci_driver(pwm_lpss_driver_pci);
 
drivers/pwm/pwm-lpss-platform.c +11 -0
index 18a9c88..09a7d99 100644
@@ -14,6 +14,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
 
 #include "pwm-lpss.h"
 
@@ -36,6 +37,12 @@ static int pwm_lpss_probe_platform(struct platform_device *pdev)
 		return PTR_ERR(lpwm);
 
 	platform_set_drvdata(pdev, lpwm);
+
+	pm_runtime_set_autosuspend_delay(&pdev->dev, 5);
+	pm_runtime_use_autosuspend(&pdev->dev);
+	pm_runtime_put_noidle(&pdev->dev);
+	pm_runtime_allow(&pdev->dev);
+
 	return 0;
 }
 
@@ -43,6 +50,7 @@ static int pwm_lpss_remove_platform(struct platform_device *pdev)
 {
 	struct pwm_lpss_chip *lpwm = platform_get_drvdata(pdev);
 
+	pm_runtime_forbid(&pdev->dev);
 	return pwm_lpss_remove(lpwm);
 }
 
@@ -60,6 +68,9 @@ static struct platform_driver pwm_lpss_driver_platform = {
 	},
 	.probe = pwm_lpss_probe_platform,
 	.remove = pwm_lpss_remove_platform,
+	.driver = {
+		.pm = &pwm_lpss_pm,
+	},
 };
 module_platform_driver(pwm_lpss_driver_platform);
 
drivers/pwm/pwm-lpss.c +41 -0

82 lines not on this page · raw message

drivers/pwm/pwm-lpss.h +1 -0
index aa041bb..0b42983 100644
@@ -28,5 +28,6 @@ extern const struct pwm_lpss_boardinfo pwm_lpss_bsw_info;
 struct pwm_lpss_chip *pwm_lpss_probe(struct device *dev, struct resource *r,
 				     const struct pwm_lpss_boardinfo *info);
 int pwm_lpss_remove(struct pwm_lpss_chip *lpwm);
+extern const struct dev_pm_ops pwm_lpss_pm;
 
 #endif	/* __PWM_LPSS_H */
Signature · 1 line
1.8.3.2