On Fri, Oct 09, 2015 at 05:02:53PM +0800, Qipeng Zha wrote:
> Add runtime PM and use autosuspend feature with
> default timeout of 5ms.
> PWM support D3 and DevIdle/D0i3 on Broxton,
> if PWM is in D0, then SOC will not enter S0ix.
>
> Signed-off-by: Huiquan Zhong <[email protected]>
> Signed-off-by: Qipeng Zha <[email protected]>
>
> ---
> change in v2
> Change runtime get/put flow for pwm, get in enable and put in disable;
> For platform device driver, call runtime_pm_enable when init;
> Remove _resume stub function.
> ---
> drivers/pwm/pwm-lpss-pci.c | 11 +++++++++++
> drivers/pwm/pwm-lpss-platform.c | 11 +++++++++++
> drivers/pwm/pwm-lpss.c | 24 ++++++++++++++++++++++++
> drivers/pwm/pwm-lpss.h | 1 +
> 4 files changed, 47 insertions(+)
>
> diff --git a/drivers/pwm/pwm-lpss-pci.c b/drivers/pwm/pwm-lpss-pci.c
> index 45042c1..e8c31d6 100644
> --- a/drivers/pwm/pwm-lpss-pci.c
> +++ b/drivers/pwm/pwm-lpss-pci.c
> @@ -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);
Why autosuspend?
> + 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);
>
> diff --git a/drivers/pwm/pwm-lpss-platform.c b/drivers/pwm/pwm-lpss-platform.c
> index 18a9c88..829e222 100644
> --- a/drivers/pwm/pwm-lpss-platform.c
> +++ b/drivers/pwm/pwm-lpss-platform.c
> @@ -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_enable(&pdev->dev);
So you enable runtime PM here...
> +
> 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);
...but forbid it here (note it is different from _disable()).
How well have you tested this patch? Does PM still work if you
load/unload the module few times?
> return pwm_lpss_remove(lpwm);
> }
--
To unsubscribe from this list: send the line "unsubscribe linux-pwm" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html