All of lore.kernel.org
 help / color / mirror / Atom feed
* [ath9k-devel] [PATCH] ath10k: split ath10k_pci_target_ps_control
@ 2013-04-18 12:47 Bartosz Markowski
  2013-04-22  8:46 ` Kalle Valo
  0 siblings, 1 reply; 6+ messages in thread
From: Bartosz Markowski @ 2013-04-18 12:47 UTC (permalink / raw)
  To: ath9k-devel

Divide the target_ps_control into 2 logical pieces:
- ath10k_pci_wake
- ath10k_pci_sleep

Signed-off-by: Bartosz Markowski <bartosz.markowski@tieto.com>
---
 drivers/net/wireless/ath/ath10k/pci.c |  117 ++++++++++++++++-----------------
 drivers/net/wireless/ath/ath10k/pci.h |   18 +----
 2 files changed, 60 insertions(+), 75 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/pci.c b/drivers/net/wireless/ath/ath10k/pci.c
index e4024ef..fedf321 100644
--- a/drivers/net/wireless/ath/ath10k/pci.c
+++ b/drivers/net/wireless/ath/ath10k/pci.c
@@ -442,6 +442,63 @@ static void ath10k_pci_wait_for_target_to_awake(struct ath10k *ar)
 		ath10k_warn("Unable to wakeup target\n");
 }
 
+void ath10k_pci_wake(struct ath10k *ar)
+{
+	struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
+	void __iomem *pci_addr = ar_pci->mem;
+	static int max_delay;
+	int tot_delay = 0;
+	int curr_delay = 5;
+
+	if (!ath10k_target_ps)
+		return;
+
+	if (atomic_read(&ar_pci->keep_awake_count) == 0) {
+		/* Force AWAKE */
+		iowrite32(PCIE_SOC_WAKE_V_MASK_T(ar),
+			  pci_addr + PCIE_LOCAL_BASE_ADDRESS_T(ar) + PCIE_SOC_WAKE_ADDRESS_T(ar));
+	}
+	atomic_inc(&ar_pci->keep_awake_count);
+
+	if (ar_pci->verified_awake)
+		return;
+
+	for (;;) {
+		if (ath10k_pci_target_is_awake(ar)) {
+			ar_pci->verified_awake = true;
+			break;
+		}
+
+		if (tot_delay > PCIE_WAKE_TIMEOUT)
+			ath10k_warn("keep_awake_count %d\n", atomic_read(&ar_pci->keep_awake_count));
+
+		udelay(curr_delay);
+		tot_delay += curr_delay;
+
+		if (curr_delay < 50)
+			curr_delay += 5;
+	}
+
+	if (tot_delay > max_delay)
+		max_delay = tot_delay;
+}
+
+void ath10k_pci_sleep(struct ath10k *ar)
+{
+	struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
+	void __iomem *pci_addr = ar_pci->mem;
+
+	if (!ath10k_target_ps)
+		return;
+
+	if (atomic_dec_and_test(&ar_pci->keep_awake_count)) {
+		/* Allow sleep */
+		ar_pci->verified_awake = false;
+		iowrite32(PCIE_SOC_WAKE_RESET_T(ar),
+			  pci_addr + PCIE_LOCAL_BASE_ADDRESS_T(ar) + PCIE_SOC_WAKE_ADDRESS_T(ar));
+	}
+}
+
 /*
  * FIXME: Handle OOM properly.
  */
@@ -1631,7 +1688,7 @@ static int ath10k_pci_probe_device(struct ath10k *ar)
 	else {
 		/* Force AWAKE forever */
 		ath10k_dbg(ATH10K_DBG_PCI, "on-chip power save disabled\n");
-		ath10k_pci_target_ps_control(ar, false, true);
+		ath10k_pci_wake(ar);
 	}
 
 	ath10k_pci_ce_init(ar);
@@ -1655,64 +1712,6 @@ ce_deinit:
 	return ret;
 }
 
-void ath10k_pci_target_ps_control(struct ath10k *ar, bool sleep_ok,
-				  bool wait_for_it)
-{
-	struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
-	void __iomem *pci_addr = ar_pci->mem;
-	static int max_delay;
-
-	if (sleep_ok) {
-		if (atomic_dec_and_test(&ar_pci->keep_awake_count)) {
-			/* Allow sleep */
-			ar_pci->verified_awake = false;
-			iowrite32(PCIE_SOC_WAKE_RESET_T(ar),
-				  pci_addr + PCIE_LOCAL_BASE_ADDRESS_T(ar) +
-				  PCIE_SOC_WAKE_ADDRESS_T(ar));
-		}
-	} else {
-		if (atomic_read(&ar_pci->keep_awake_count) == 0) {
-			/* Force AWAKE */
-			iowrite32(PCIE_SOC_WAKE_V_MASK_T(ar),
-				  pci_addr + PCIE_LOCAL_BASE_ADDRESS_T(ar) +
-				  PCIE_SOC_WAKE_ADDRESS_T(ar));
-		}
-		atomic_inc(&ar_pci->keep_awake_count);
-
-		if (wait_for_it && !ar_pci->verified_awake) {
-			int tot_delay = 0;
-			int curr_delay = 5;
-
-			for (;;) {
-				if (ath10k_pci_target_is_awake(ar)) {
-					ar_pci->verified_awake = true;
-					break;
-				}
-
-				if (tot_delay > PCIE_WAKE_TIMEOUT) {
-					ath10k_warn
-					    ("keep_awake_count %d "
-					     "PCIE_SOC_WAKE_ADDRESS = %x\n",
-					     atomic_read(&ar_pci->
-							keep_awake_count),
-					     ioread32(pci_addr +
-					       PCIE_LOCAL_BASE_ADDRESS_T(ar) +
-					       PCIE_SOC_WAKE_ADDRESS_T(ar)));
-				}
-
-				udelay(curr_delay);
-				tot_delay += curr_delay;
-
-				if (curr_delay < 50)
-					curr_delay += 5;
-			}
-
-			if (tot_delay > max_delay)
-				max_delay = tot_delay;
-		}
-	}
-}
-
 static void ath10k_pci_fw_interrupt_handler(struct ath10k *ar)
 {
 	struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
diff --git a/drivers/net/wireless/ath/ath10k/pci.h b/drivers/net/wireless/ath/ath10k/pci.h
index 9b497a7..2e988a2 100644
--- a/drivers/net/wireless/ath/ath10k/pci.h
+++ b/drivers/net/wireless/ath/ath10k/pci.h
@@ -347,21 +347,7 @@ static inline void WAR_CE_SRC_RING_WRITE_IDX_SET(struct ath10k *ar,
 	}
 }
 
-void ath10k_pci_target_ps_control(struct ath10k *ar,
-				  bool sleep_ok,
-				  bool wait_for_it);
-
-static inline void ath10k_pci_wake(struct ath10k *ar)
-{
-	if (ath10k_target_ps)
-		ath10k_pci_target_ps_control(ar, false, true);
-}
-
-static inline void ath10k_pci_sleep(struct ath10k *ar)
-{
-	if (ath10k_target_ps)
-		ath10k_pci_target_ps_control(ar, true, false);
-}
-
+void ath10k_pci_wake(struct ath10k *ar);
+void ath10k_pci_sleep(struct ath10k *ar);
 
 #endif /* _PCI_H_ */
-- 
1.7.10

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-04-22  9:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-18 12:47 [ath9k-devel] [PATCH] ath10k: split ath10k_pci_target_ps_control Bartosz Markowski
2013-04-22  8:46 ` Kalle Valo
2013-04-22  8:50   ` Bartosz.Markowski at tieto.com
2013-04-22  9:28     ` Markowski Bartosz
2013-04-22  9:38       ` Kalle Valo
2013-04-22  9:44         ` Markowski Bartosz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.