Merge tag 'acpi-4.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael...
[muen/linux.git] / drivers / acpi / acpi_lpss.c
index 6633bc8e58462dc999c82af6f7b5f9b22f8c8235..7f2b02cc8ea148c6091b56006889babfeb09e309 100644 (file)
@@ -693,7 +693,7 @@ static int acpi_lpss_activate(struct device *dev)
        struct lpss_private_data *pdata = acpi_driver_data(ACPI_COMPANION(dev));
        int ret;
 
-       ret = acpi_dev_runtime_resume(dev);
+       ret = acpi_dev_resume(dev);
        if (ret)
                return ret;
 
@@ -713,43 +713,9 @@ static int acpi_lpss_activate(struct device *dev)
 
 static void acpi_lpss_dismiss(struct device *dev)
 {
-       acpi_dev_runtime_suspend(dev);
+       acpi_dev_suspend(dev, false);
 }
 
-#ifdef CONFIG_PM_SLEEP
-static int acpi_lpss_suspend_late(struct device *dev)
-{
-       struct lpss_private_data *pdata = acpi_driver_data(ACPI_COMPANION(dev));
-       int ret;
-
-       ret = pm_generic_suspend_late(dev);
-       if (ret)
-               return ret;
-
-       if (pdata->dev_desc->flags & LPSS_SAVE_CTX)
-               acpi_lpss_save_ctx(dev, pdata);
-
-       return acpi_dev_suspend_late(dev);
-}
-
-static int acpi_lpss_resume_early(struct device *dev)
-{
-       struct lpss_private_data *pdata = acpi_driver_data(ACPI_COMPANION(dev));
-       int ret;
-
-       ret = acpi_dev_resume_early(dev);
-       if (ret)
-               return ret;
-
-       acpi_lpss_d3_to_d0_delay(pdata);
-
-       if (pdata->dev_desc->flags & LPSS_SAVE_CTX)
-               acpi_lpss_restore_ctx(dev, pdata);
-
-       return pm_generic_resume_early(dev);
-}
-#endif /* CONFIG_PM_SLEEP */
-
 /* IOSF SB for LPSS island */
 #define LPSS_IOSF_UNIT_LPIOEP          0xA0
 #define LPSS_IOSF_UNIT_LPIO1           0xAB
@@ -835,19 +801,15 @@ static void lpss_iosf_exit_d3_state(void)
        mutex_unlock(&lpss_iosf_mutex);
 }
 
-static int acpi_lpss_runtime_suspend(struct device *dev)
+static int acpi_lpss_suspend(struct device *dev, bool wakeup)
 {
        struct lpss_private_data *pdata = acpi_driver_data(ACPI_COMPANION(dev));
        int ret;
 
-       ret = pm_generic_runtime_suspend(dev);
-       if (ret)
-               return ret;
-
        if (pdata->dev_desc->flags & LPSS_SAVE_CTX)
                acpi_lpss_save_ctx(dev, pdata);
 
-       ret = acpi_dev_runtime_suspend(dev);
+       ret = acpi_dev_suspend(dev, wakeup);
 
        /*
         * This call must be last in the sequence, otherwise PMC will return
@@ -860,7 +822,7 @@ static int acpi_lpss_runtime_suspend(struct device *dev)
        return ret;
 }
 
-static int acpi_lpss_runtime_resume(struct device *dev)
+static int acpi_lpss_resume(struct device *dev)
 {
        struct lpss_private_data *pdata = acpi_driver_data(ACPI_COMPANION(dev));
        int ret;
@@ -872,7 +834,7 @@ static int acpi_lpss_runtime_resume(struct device *dev)
        if (lpss_quirks & LPSS_QUIRK_ALWAYS_POWER_ON && iosf_mbi_available())
                lpss_iosf_exit_d3_state();
 
-       ret = acpi_dev_runtime_resume(dev);
+       ret = acpi_dev_resume(dev);
        if (ret)
                return ret;
 
@@ -881,7 +843,41 @@ static int acpi_lpss_runtime_resume(struct device *dev)
        if (pdata->dev_desc->flags & LPSS_SAVE_CTX)
                acpi_lpss_restore_ctx(dev, pdata);
 
-       return pm_generic_runtime_resume(dev);
+       return 0;
+}
+
+#ifdef CONFIG_PM_SLEEP
+static int acpi_lpss_suspend_late(struct device *dev)
+{
+       int ret;
+
+       if (dev_pm_smart_suspend_and_suspended(dev))
+               return 0;
+
+       ret = pm_generic_suspend_late(dev);
+       return ret ? ret : acpi_lpss_suspend(dev, device_may_wakeup(dev));
+}
+
+static int acpi_lpss_resume_early(struct device *dev)
+{
+       int ret = acpi_lpss_resume(dev);
+
+       return ret ? ret : pm_generic_resume_early(dev);
+}
+#endif /* CONFIG_PM_SLEEP */
+
+static int acpi_lpss_runtime_suspend(struct device *dev)
+{
+       int ret = pm_generic_runtime_suspend(dev);
+
+       return ret ? ret : acpi_lpss_suspend(dev, true);
+}
+
+static int acpi_lpss_runtime_resume(struct device *dev)
+{
+       int ret = acpi_lpss_resume(dev);
+
+       return ret ? ret : pm_generic_runtime_resume(dev);
 }
 #endif /* CONFIG_PM */
 
@@ -894,13 +890,20 @@ static struct dev_pm_domain acpi_lpss_pm_domain = {
 #ifdef CONFIG_PM
 #ifdef CONFIG_PM_SLEEP
                .prepare = acpi_subsys_prepare,
-               .complete = pm_complete_with_resume_check,
+               .complete = acpi_subsys_complete,
                .suspend = acpi_subsys_suspend,
                .suspend_late = acpi_lpss_suspend_late,
+               .suspend_noirq = acpi_subsys_suspend_noirq,
+               .resume_noirq = acpi_subsys_resume_noirq,
                .resume_early = acpi_lpss_resume_early,
                .freeze = acpi_subsys_freeze,
+               .freeze_late = acpi_subsys_freeze_late,
+               .freeze_noirq = acpi_subsys_freeze_noirq,
+               .thaw_noirq = acpi_subsys_thaw_noirq,
                .poweroff = acpi_subsys_suspend,
                .poweroff_late = acpi_lpss_suspend_late,
+               .poweroff_noirq = acpi_subsys_suspend_noirq,
+               .restore_noirq = acpi_subsys_resume_noirq,
                .restore_early = acpi_lpss_resume_early,
 #endif
                .runtime_suspend = acpi_lpss_runtime_suspend,