hc
2024-05-10 37f49e37ab4cb5d0bc4c60eb5c6d4dd57db767bb
kernel/drivers/pwm/pwm-lpss-platform.c
....@@ -1,13 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Intel Low Power Subsystem PWM controller driver
34 *
45 * Copyright (C) 2014, Intel Corporation
56 *
67 * Derived from the original pwm-lpss.c
7
- *
8
- * This program is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License version 2 as
10
- * published by the Free Software Foundation.
118 */
129
1310 #include <linux/acpi.h>
....@@ -30,6 +27,7 @@
3027 .clk_rate = 19200000,
3128 .npwm = 1,
3229 .base_unit_bits = 16,
30
+ .other_devices_aml_touches_pwm_regs = true,
3331 };
3432
3533 /* Broxton */
....@@ -60,6 +58,7 @@
6058
6159 platform_set_drvdata(pdev, lpwm);
6260
61
+ dev_pm_set_driver_flags(&pdev->dev, DPM_FLAG_SMART_PREPARE);
6362 pm_runtime_set_active(&pdev->dev);
6463 pm_runtime_enable(&pdev->dev);
6564
....@@ -74,13 +73,28 @@
7473 return pwm_lpss_remove(lpwm);
7574 }
7675
77
-static SIMPLE_DEV_PM_OPS(pwm_lpss_platform_pm_ops,
78
- pwm_lpss_suspend,
79
- pwm_lpss_resume);
76
+static int pwm_lpss_prepare(struct device *dev)
77
+{
78
+ struct pwm_lpss_chip *lpwm = dev_get_drvdata(dev);
79
+
80
+ /*
81
+ * If other device's AML code touches the PWM regs on suspend/resume
82
+ * force runtime-resume the PWM controller to allow this.
83
+ */
84
+ if (lpwm->info->other_devices_aml_touches_pwm_regs)
85
+ return 0; /* Force runtime-resume */
86
+
87
+ return 1; /* If runtime-suspended leave as is */
88
+}
89
+
90
+static const struct dev_pm_ops pwm_lpss_platform_pm_ops = {
91
+ .prepare = pwm_lpss_prepare,
92
+};
8093
8194 static const struct acpi_device_id pwm_lpss_acpi_match[] = {
8295 { "80860F09", (unsigned long)&pwm_lpss_byt_info },
8396 { "80862288", (unsigned long)&pwm_lpss_bsw_info },
97
+ { "80862289", (unsigned long)&pwm_lpss_bsw_info },
8498 { "80865AC8", (unsigned long)&pwm_lpss_bxt_info },
8599 { },
86100 };