From 73f10ef56673c96a4aba17712a6d6c4c4aa76e04 Mon Sep 17 00:00:00 2001
From: Yuanyuan Liu <yuanliu@codeaurora.org>
Date: Tue, 24 Jun 2014 14:48:44 -0700
Subject: [PATCH] cnss: Add PCIe power control support

Export a PCIe power control API to WLAN host driver who will decide
which suspend mode (D3 or D0 mode) it will enter based on the number
of connected clients and then call this API to vote PCIe link down/up
accordingly.

CRs-Fixed: 685771
Change-Id: Ib44938b94ba07a1b220615e9f1febcafca8f4277
Signed-off-by: Yuanyuan Liu <yuanliu@codeaurora.org>
Signed-off-by: Yue Ma <yuem@codeaurora.org>
---
 drivers/net/wireless/cnss/cnss.c | 14 ++++++++++++++
 include/net/cnss.h               |  3 +++
 2 files changed, 17 insertions(+)

diff --git a/drivers/net/wireless/cnss/cnss.c b/drivers/net/wireless/cnss/cnss.c
index dad93253cf1a..6be665ec8819 100644
--- a/drivers/net/wireless/cnss/cnss.c
+++ b/drivers/net/wireless/cnss/cnss.c
@@ -1057,6 +1057,20 @@ void cnss_pm_wake_lock_destroy(struct wakeup_source *ws)
 }
 EXPORT_SYMBOL(cnss_pm_wake_lock_destroy);
 
+#ifdef CONFIG_PCI_MSM
+int cnss_wlan_pm_control(bool vote)
+{
+	if (!penv || !penv->pdev)
+		return -ENODEV;
+
+	return msm_pcie_pm_control(
+		vote ? MSM_PCIE_DISABLE_PC : MSM_PCIE_ENABLE_PC,
+		cnss_get_pci_dev_bus_number(penv->pdev),
+		penv->pdev, NULL, PM_OPTIONS);
+}
+EXPORT_SYMBOL(cnss_wlan_pm_control);
+#endif
+
 void cnss_flush_work(void *work)
 {
 	struct work_struct *cnss_work = work;
diff --git a/include/net/cnss.h b/include/net/cnss.h
index 00e4c22a754f..2ffe6d9dca3f 100644
--- a/include/net/cnss.h
+++ b/include/net/cnss.h
@@ -93,6 +93,9 @@ extern void cnss_pm_wake_lock(struct wakeup_source *ws);
 extern void cnss_pm_wake_lock_timeout(struct wakeup_source *ws, ulong msec);
 extern void cnss_pm_wake_lock_release(struct wakeup_source *ws);
 extern void cnss_pm_wake_lock_destroy(struct wakeup_source *ws);
+#ifdef CONFIG_PCI_MSM
+extern int cnss_wlan_pm_control(bool vote);
+#endif
 
 extern int cnss_set_cpus_allowed_ptr(struct task_struct *task, ulong cpu);
 extern void cnss_request_pm_qos(u32 qos_val);
-- 
GitLab