]> Git Repo - linux.git/blobdiff - drivers/pwm/pwm-stm32-lp.c
Merge branch 'for-next' into for-linus
[linux.git] / drivers / pwm / pwm-stm32-lp.c
index 0059b24cfdc3c39579b9e70b11b9f0271399db1a..2211a642066dbad0fe2288c6ebbfb56d19968c23 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/mfd/stm32-lptimer.h>
 #include <linux/module.h>
 #include <linux/of.h>
+#include <linux/pinctrl/consumer.h>
 #include <linux/platform_device.h>
 #include <linux/pwm.h>
 
@@ -223,6 +224,29 @@ static int stm32_pwm_lp_remove(struct platform_device *pdev)
        return pwmchip_remove(&priv->chip);
 }
 
+static int __maybe_unused stm32_pwm_lp_suspend(struct device *dev)
+{
+       struct stm32_pwm_lp *priv = dev_get_drvdata(dev);
+       struct pwm_state state;
+
+       pwm_get_state(&priv->chip.pwms[0], &state);
+       if (state.enabled) {
+               dev_err(dev, "The consumer didn't stop us (%s)\n",
+                       priv->chip.pwms[0].label);
+               return -EBUSY;
+       }
+
+       return pinctrl_pm_select_sleep_state(dev);
+}
+
+static int __maybe_unused stm32_pwm_lp_resume(struct device *dev)
+{
+       return pinctrl_pm_select_default_state(dev);
+}
+
+static SIMPLE_DEV_PM_OPS(stm32_pwm_lp_pm_ops, stm32_pwm_lp_suspend,
+                        stm32_pwm_lp_resume);
+
 static const struct of_device_id stm32_pwm_lp_of_match[] = {
        { .compatible = "st,stm32-pwm-lp", },
        {},
@@ -235,6 +259,7 @@ static struct platform_driver stm32_pwm_lp_driver = {
        .driver = {
                .name = "stm32-pwm-lp",
                .of_match_table = of_match_ptr(stm32_pwm_lp_of_match),
+               .pm = &stm32_pwm_lp_pm_ops,
        },
 };
 module_platform_driver(stm32_pwm_lp_driver);
This page took 0.034427 seconds and 4 git commands to generate.