summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/pld/inc/pld_common.h10
-rw-r--r--core/pld/src/pld_pcie.c52
2 files changed, 62 insertions, 0 deletions
diff --git a/core/pld/inc/pld_common.h b/core/pld/inc/pld_common.h
index 8f009c43441c..53f25b4394a1 100644
--- a/core/pld/inc/pld_common.h
+++ b/core/pld/inc/pld_common.h
@@ -268,6 +268,12 @@ struct pld_soc_info {
* is enabled
* @modem_status: optional operation, will be called when platform driver
* sending modem power status to WLAN FW
+ * @runtime_suspend: optional operation, prepare the device for a condition
+ * in which it won't be able to communicate with the CPU(s)
+ * and RAM due to power management.
+ * @runtime_resume: optional operation, put the device into the fully
+ * active state in response to a wakeup event generated by
+ * hardware or at the request of software.
*/
struct pld_driver_ops {
int (*probe)(struct device *dev,
@@ -290,6 +296,10 @@ struct pld_driver_ops {
void (*modem_status)(struct device *dev,
enum pld_bus_type bus_type,
int state);
+ int (*runtime_suspend)(struct device *dev,
+ enum pld_bus_type bus_type);
+ int (*runtime_resume)(struct device *dev,
+ enum pld_bus_type bus_type);
};
int pld_init(void);
diff --git a/core/pld/src/pld_pcie.c b/core/pld/src/pld_pcie.c
index ca7778059b55..ab3cbd1e52eb 100644
--- a/core/pld/src/pld_pcie.c
+++ b/core/pld/src/pld_pcie.c
@@ -198,6 +198,48 @@ static void pld_pcie_notify_handler(struct pci_dev *pdev, int state)
pld_context->ops->modem_status(&pdev->dev,
PLD_BUS_TYPE_PCIE, state);
}
+
+#ifdef FEATURE_RUNTIME_PM
+/**
+ * pld_pcie_runtime_suspend() - PM runtime suspend
+ * @pdev: PCIE device
+ *
+ * PM runtime suspend callback function.
+ *
+ * Return: int
+ */
+static int pld_pcie_runtime_suspend(struct pci_dev *pdev)
+{
+ struct pld_context *pld_context;
+
+ pld_context = pld_get_global_context();
+ if (pld_context->ops->runtime_suspend)
+ return pld_context->ops->runtime_suspend(&pdev->dev,
+ PLD_BUS_TYPE_PCIE);
+
+ return -ENODEV;
+}
+
+/**
+ * pld_pcie_runtime_resume() - PM runtime resume
+ * @pdev: PCIE device
+ *
+ * PM runtime resume callback function.
+ *
+ * Return: int
+ */
+static int pld_pcie_runtime_resume(struct pci_dev *pdev)
+{
+ struct pld_context *pld_context;
+
+ pld_context = pld_get_global_context();
+ if (pld_context->ops->runtime_resume)
+ return pld_context->ops->runtime_resume(&pdev->dev,
+ PLD_BUS_TYPE_PCIE);
+
+ return -ENODEV;
+}
+#endif
#endif
/**
@@ -246,6 +288,13 @@ static struct pci_device_id pld_pcie_id_table[] = {
};
#ifdef CONFIG_CNSS
+#ifdef FEATURE_RUNTIME_PM
+struct cnss_wlan_runtime_ops runtime_pm_ops = {
+ .runtime_suspend = pld_pcie_runtime_suspend,
+ .runtime_resume = pld_pcie_runtime_resume,
+};
+#endif
+
struct cnss_wlan_driver pld_pcie_ops = {
.name = "pld_pcie",
.id_table = pld_pcie_id_table,
@@ -259,6 +308,9 @@ struct cnss_wlan_driver pld_pcie_ops = {
.suspend = pld_pcie_suspend,
.resume = pld_pcie_resume,
#endif
+#ifdef FEATURE_RUNTIME_PM
+ .runtime_ops = &runtime_pm_ops,
+#endif
};
/**