diff mbox series

[v3,09/11] wifi: ath9k: implement QCN550x tx

Message ID 20230629231625.951744-10-wlooi@ucalgary.ca
State New
Headers show
Series wifi: ath9k: add support for QCN550x | expand

Commit Message

Wenli Looi June 29, 2023, 11:16 p.m. UTC
Certain fields in ar9003_txc are slightly different, but overall this
device can be treated similar to other AR9003 devices.

Signed-off-by: Wenli Looi <wlooi@ucalgary.ca>
---
 drivers/net/wireless/ath/ath9k/ar9003_mac.c | 45 +++++++++++++++------
 drivers/net/wireless/ath/ath9k/ar9003_mac.h |  4 ++
 drivers/net/wireless/ath/ath9k/mac.h        | 13 ++++++
 3 files changed, 50 insertions(+), 12 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
index 3d512916a2..be80fd9263 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
@@ -26,9 +26,9 @@  static void ar9003_hw_rx_enable(struct ath_hw *hw)
 static void
 ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
 {
+	u32 val, ctl12, ctl17, ctl18;
 	struct ar9003_txc *ads = ds;
 	int checksum = 0;
-	u32 val, ctl12, ctl17;
 	u8 desc_len;
 
 	desc_len = ((AR_SREV_9462(ah) || AR_SREV_9565(ah)) ? 0x18 : 0x17);
@@ -132,8 +132,21 @@  ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
 		break;
 	}
 
+	ctl18 = set11nRateFlags(i->rates, 0) |
+		set11nRateFlags(i->rates, 1) |
+		set11nRateFlags(i->rates, 2) |
+		set11nRateFlags(i->rates, 3) |
+		SM(i->rtscts_rate, AR_RTSCTSRate);
+
 	val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
-	ctl12 |= SM(val, AR_PAPRDChainMask);
+
+	if (!AR_SREV_5502(ah)) {
+		ctl12 |= SM(val, AR_PAPRDChainMask);
+		ctl18 |= set11nChainSel(i->rates, 0) |
+			 set11nChainSel(i->rates, 1) |
+			 set11nChainSel(i->rates, 2) |
+			 set11nChainSel(i->rates, 3);
+	}
 
 	WRITE_ONCE(ads->ctl12, ctl12);
 	WRITE_ONCE(ads->ctl17, ctl17);
@@ -144,18 +157,22 @@  ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
 	WRITE_ONCE(ads->ctl16, set11nPktDurRTSCTS(i->rates, 2)
 		| set11nPktDurRTSCTS(i->rates, 3));
 
-	WRITE_ONCE(ads->ctl18,
-		  set11nRateFlags(i->rates, 0) | set11nChainSel(i->rates, 0)
-		| set11nRateFlags(i->rates, 1) | set11nChainSel(i->rates, 1)
-		| set11nRateFlags(i->rates, 2) | set11nChainSel(i->rates, 2)
-		| set11nRateFlags(i->rates, 3) | set11nChainSel(i->rates, 3)
-		| SM(i->rtscts_rate, AR_RTSCTSRate));
+	WRITE_ONCE(ads->ctl18, ctl18);
 
 	WRITE_ONCE(ads->ctl19, AR_Not_Sounding);
 
 	WRITE_ONCE(ads->ctl20, SM(i->txpower[1], AR_XmitPower1));
 	WRITE_ONCE(ads->ctl21, SM(i->txpower[2], AR_XmitPower2));
 	WRITE_ONCE(ads->ctl22, SM(i->txpower[3], AR_XmitPower3));
+
+	if (AR_SREV_5502(ah)) {
+		WRITE_ONCE(ads->ctl23,
+			   set11nChainSelQCN5502(i->rates, 0) |
+			   set11nChainSelQCN5502(i->rates, 1) |
+			   set11nChainSelQCN5502(i->rates, 2) |
+			   set11nChainSelQCN5502(i->rates, 3) |
+			   SM(val, QCN5502_PAPRDChainMask));
+	}
 }
 
 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
@@ -355,8 +372,8 @@  static bool ar9003_hw_get_isr(struct ath_hw *ah, enum ath9k_int *masked,
 static int ar9003_hw_proc_txdesc(struct ath_hw *ah, void *ds,
 				 struct ath_tx_status *ts)
 {
+	u32 status, tx_ba_status;
 	struct ar9003_txs *ads;
-	u32 status;
 
 	ads = &ah->ts_ring[ah->ts_tail];
 
@@ -390,13 +407,17 @@  static int ar9003_hw_proc_txdesc(struct ath_hw *ah, void *ds,
 	ts->ts_rssi_ctl0 = MS(status, AR_TxRSSIAnt00);
 	ts->ts_rssi_ctl1 = MS(status, AR_TxRSSIAnt01);
 	ts->ts_rssi_ctl2 = MS(status, AR_TxRSSIAnt02);
-	if (status & AR_TxBaStatus) {
+	if (!AR_SREV_5502(ah))
+		tx_ba_status = status & AR_TxBaStatus;
+
+	status = READ_ONCE(ads->status3);
+	if (AR_SREV_5502(ah))
+		tx_ba_status = status & QCN5502_TxBaStatus;
+	if (tx_ba_status) {
 		ts->ts_flags |= ATH9K_TX_BA;
 		ts->ba_low = ads->status5;
 		ts->ba_high = ads->status6;
 	}
-
-	status = READ_ONCE(ads->status3);
 	if (status & AR_ExcessiveRetries)
 		ts->ts_status |= ATH9K_TXERR_XRETRY;
 	if (status & AR_Filtered)
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.h b/drivers/net/wireless/ath/ath9k/ar9003_mac.h
index ec8f3fac67..11a67822fa 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_mac.h
+++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.h
@@ -41,6 +41,10 @@ 
 #define AR_PAPRDChainMask	0x00000e00
 #define AR_PAPRDChainMask_S	9
 
+/* ctl 23 */
+#define QCN5502_PAPRDChainMask		0x0000f000
+#define QCN5502_PAPRDChainMask_S	16
+
 #define MAP_ISR_S2_CST          6
 #define MAP_ISR_S2_GTT          6
 #define MAP_ISR_S2_TIM          3
diff --git a/drivers/net/wireless/ath/ath9k/mac.h b/drivers/net/wireless/ath/ath9k/mac.h
index af44b33814..81e1918ad4 100644
--- a/drivers/net/wireless/ath/ath9k/mac.h
+++ b/drivers/net/wireless/ath/ath9k/mac.h
@@ -40,6 +40,9 @@ 
 #define set11nChainSel(_series, _index)					\
 	(SM((_series)[_index].ChSel, AR_ChainSel##_index))
 
+#define set11nChainSelQCN5502(_series, _index)				\
+	(SM((_series)[_index].ChSel, QCN5502_ChainSel_##_index))
+
 #define CCK_SIFS_TIME        10
 #define CCK_PREAMBLE_BITS   144
 #define CCK_PLCP_BITS        48
@@ -458,6 +461,16 @@  struct ar5416_desc {
 #define AR_TxBaStatus       0x40000000
 #define AR_TxStatusRsvd01   0x80000000
 
+#define QCN5502_ChainSel_0   0x0000000f
+#define QCN5502_ChainSel_0_S 0
+#define QCN5502_ChainSel_1   0x000000f0
+#define QCN5502_ChainSel_1_S 4
+#define QCN5502_ChainSel_2   0x00000f00
+#define QCN5502_ChainSel_2_S 8
+#define QCN5502_ChainSel_3   0x0000f000
+#define QCN5502_ChainSel_3_S 12
+#define QCN5502_TxBaStatus   0x00200000
+
 /*
  * AR_FrmXmitOK - Frame transmission success flag. If set, the frame was
  * transmitted successfully. If clear, no ACK or BA was received to indicate