|
5 | 5 | #include "../dma.h" |
6 | 6 | #include "mac.h" |
7 | 7 |
|
8 | | -int mt7915_init_tx_queues(struct mt7915_phy *phy, int idx, int n_desc) |
| 8 | +int mt7915_init_tx_queues(struct mt7915_phy *phy, int idx, int n_desc, int ring_base) |
9 | 9 | { |
10 | 10 | int i, err; |
11 | 11 |
|
12 | | - err = mt76_init_tx_queue(phy->mt76, 0, idx, n_desc, MT_TX_RING_BASE); |
| 12 | + err = mt76_init_tx_queue(phy->mt76, 0, idx, n_desc, ring_base); |
13 | 13 | if (err < 0) |
14 | 14 | return err; |
15 | 15 |
|
@@ -40,52 +40,90 @@ static int mt7915_poll_tx(struct napi_struct *napi, int budget) |
40 | 40 | return 0; |
41 | 41 | } |
42 | 42 |
|
| 43 | +static void mt7915_dma_config(struct mt7915_dev *dev) |
| 44 | +{ |
| 45 | +#define Q_CONFIG(q, wfdma, int, id) do { \ |
| 46 | + if (wfdma) \ |
| 47 | + dev->wfdma_mask |= (1 << (q)); \ |
| 48 | + dev->q_int_mask[(q)] = int; \ |
| 49 | + dev->q_id[(q)] = id; \ |
| 50 | + } while (0) |
| 51 | + |
| 52 | +#define MCUQ_CONFIG(q, wfdma, int, id) Q_CONFIG(q, (wfdma), (int), (id)) |
| 53 | +#define RXQ_CONFIG(q, wfdma, int, id) Q_CONFIG(__RXQ(q), (wfdma), (int), (id)) |
| 54 | +#define TXQ_CONFIG(q, wfdma, int, id) Q_CONFIG(__TXQ(q), (wfdma), (int), (id)) |
| 55 | + |
| 56 | + if (is_mt7915(&dev->mt76)) { |
| 57 | + RXQ_CONFIG(MT_RXQ_MAIN, WFDMA0, MT_INT_RX_DONE_BAND0, MT7915_RXQ_BAND0); |
| 58 | + RXQ_CONFIG(MT_RXQ_MCU, WFDMA1, MT_INT_RX_DONE_WM, MT7915_RXQ_MCU_WM); |
| 59 | + RXQ_CONFIG(MT_RXQ_MCU_WA, WFDMA1, MT_INT_RX_DONE_WA, MT7915_RXQ_MCU_WA); |
| 60 | + RXQ_CONFIG(MT_RXQ_EXT, WFDMA0, MT_INT_RX_DONE_BAND1, MT7915_RXQ_BAND1); |
| 61 | + RXQ_CONFIG(MT_RXQ_EXT_WA, WFDMA1, MT_INT_RX_DONE_WA_EXT, MT7915_RXQ_MCU_WA_EXT); |
| 62 | + TXQ_CONFIG(0, WFDMA1, MT_INT_TX_DONE_BAND0, MT7915_TXQ_BAND0); |
| 63 | + TXQ_CONFIG(1, WFDMA1, MT_INT_TX_DONE_BAND1, MT7915_TXQ_BAND1); |
| 64 | + MCUQ_CONFIG(MT_MCUQ_WM, WFDMA1, MT_INT_TX_DONE_MCU_WM, MT7915_TXQ_MCU_WM); |
| 65 | + MCUQ_CONFIG(MT_MCUQ_WA, WFDMA1, MT_INT_TX_DONE_MCU_WA, MT7915_TXQ_MCU_WA); |
| 66 | + MCUQ_CONFIG(MT_MCUQ_FWDL, WFDMA1, MT_INT_TX_DONE_FWDL, MT7915_TXQ_FWDL); |
| 67 | + } else { |
| 68 | + RXQ_CONFIG(MT_RXQ_MAIN, WFDMA0, MT_INT_RX_DONE_BAND0_MT7916, MT7916_RXQ_BAND0); |
| 69 | + RXQ_CONFIG(MT_RXQ_MCU, WFDMA0, MT_INT_RX_DONE_WM, MT7916_RXQ_MCU_WM); |
| 70 | + RXQ_CONFIG(MT_RXQ_MCU_WA, WFDMA0, MT_INT_RX_DONE_WA, MT7916_RXQ_MCU_WA); |
| 71 | + RXQ_CONFIG(MT_RXQ_EXT, WFDMA0, MT_INT_RX_DONE_BAND1_MT7916, MT7916_RXQ_BAND1); |
| 72 | + RXQ_CONFIG(MT_RXQ_EXT_WA, WFDMA0, MT_INT_RX_DONE_WA_EXT_MT7916, MT7916_RXQ_MCU_WA_EXT); |
| 73 | + TXQ_CONFIG(0, WFDMA0, MT_INT_TX_DONE_BAND0, MT7915_TXQ_BAND0); |
| 74 | + TXQ_CONFIG(1, WFDMA0, MT_INT_TX_DONE_BAND1, MT7915_TXQ_BAND1); |
| 75 | + MCUQ_CONFIG(MT_MCUQ_WM, WFDMA0, MT_INT_TX_DONE_MCU_WM, MT7915_TXQ_MCU_WM); |
| 76 | + MCUQ_CONFIG(MT_MCUQ_WA, WFDMA0, MT_INT_TX_DONE_MCU_WA_MT7916, MT7915_TXQ_MCU_WA); |
| 77 | + MCUQ_CONFIG(MT_MCUQ_FWDL, WFDMA0, MT_INT_TX_DONE_FWDL, MT7915_TXQ_FWDL); |
| 78 | + } |
| 79 | +} |
| 80 | + |
43 | 81 | static void __mt7915_dma_prefetch(struct mt7915_dev *dev, u32 ofs) |
44 | 82 | { |
45 | | -#define PREFETCH(base, depth) ((base) << 16 | (depth)) |
46 | | - |
47 | | - mt76_wr(dev, MT_WFDMA0_RX_RING0_EXT_CTRL + ofs, PREFETCH(0x0, 0x4)); |
48 | | - mt76_wr(dev, MT_WFDMA0_RX_RING1_EXT_CTRL + ofs, PREFETCH(0x40, 0x4)); |
49 | | - mt76_wr(dev, MT_WFDMA0_RX_RING2_EXT_CTRL + ofs, PREFETCH(0x80, 0x0)); |
50 | | - |
51 | | - mt76_wr(dev, MT_WFDMA1_TX_RING0_EXT_CTRL + ofs, PREFETCH(0x80, 0x4)); |
52 | | - mt76_wr(dev, MT_WFDMA1_TX_RING1_EXT_CTRL + ofs, PREFETCH(0xc0, 0x4)); |
53 | | - mt76_wr(dev, MT_WFDMA1_TX_RING2_EXT_CTRL + ofs, PREFETCH(0x100, 0x4)); |
54 | | - mt76_wr(dev, MT_WFDMA1_TX_RING3_EXT_CTRL + ofs, PREFETCH(0x140, 0x4)); |
55 | | - mt76_wr(dev, MT_WFDMA1_TX_RING4_EXT_CTRL + ofs, PREFETCH(0x180, 0x4)); |
56 | | - mt76_wr(dev, MT_WFDMA1_TX_RING5_EXT_CTRL + ofs, PREFETCH(0x1c0, 0x4)); |
57 | | - mt76_wr(dev, MT_WFDMA1_TX_RING6_EXT_CTRL + ofs, PREFETCH(0x200, 0x4)); |
58 | | - mt76_wr(dev, MT_WFDMA1_TX_RING7_EXT_CTRL + ofs, PREFETCH(0x240, 0x4)); |
59 | | - |
60 | | - mt76_wr(dev, MT_WFDMA1_TX_RING16_EXT_CTRL + ofs, PREFETCH(0x280, 0x4)); |
61 | | - mt76_wr(dev, MT_WFDMA1_TX_RING17_EXT_CTRL + ofs, PREFETCH(0x2c0, 0x4)); |
62 | | - mt76_wr(dev, MT_WFDMA1_TX_RING18_EXT_CTRL + ofs, PREFETCH(0x300, 0x4)); |
63 | | - mt76_wr(dev, MT_WFDMA1_TX_RING19_EXT_CTRL + ofs, PREFETCH(0x340, 0x4)); |
64 | | - mt76_wr(dev, MT_WFDMA1_TX_RING20_EXT_CTRL + ofs, PREFETCH(0x380, 0x4)); |
65 | | - mt76_wr(dev, MT_WFDMA1_TX_RING21_EXT_CTRL + ofs, PREFETCH(0x3c0, 0x0)); |
66 | | - |
67 | | - mt76_wr(dev, MT_WFDMA1_RX_RING0_EXT_CTRL + ofs, PREFETCH(0x3c0, 0x4)); |
68 | | - mt76_wr(dev, MT_WFDMA1_RX_RING1_EXT_CTRL + ofs, PREFETCH(0x400, 0x4)); |
69 | | - mt76_wr(dev, MT_WFDMA1_RX_RING2_EXT_CTRL + ofs, PREFETCH(0x440, 0x4)); |
70 | | - mt76_wr(dev, MT_WFDMA1_RX_RING3_EXT_CTRL + ofs, PREFETCH(0x480, 0x0)); |
| 83 | +#define PREFETCH(_base, _depth) ((_base) << 16 | (_depth)) |
| 84 | + |
| 85 | + /* prefetch SRAM wrapping boundary for tx/rx ring. */ |
| 86 | + mt76_wr(dev, MT_MCUQ_EXT_CTRL(MT_MCUQ_FWDL) + ofs, PREFETCH(0x0, 0x4)); |
| 87 | + mt76_wr(dev, MT_MCUQ_EXT_CTRL(MT_MCUQ_WM) + ofs, PREFETCH(0x40, 0x4)); |
| 88 | + mt76_wr(dev, MT_TXQ_EXT_CTRL(0) + ofs, PREFETCH(0x80, 0x4)); |
| 89 | + mt76_wr(dev, MT_TXQ_EXT_CTRL(1) + ofs, PREFETCH(0xc0, 0x4)); |
| 90 | + mt76_wr(dev, MT_MCUQ_EXT_CTRL(MT_MCUQ_WA) + ofs, PREFETCH(0x100, 0x4)); |
| 91 | + |
| 92 | + mt76_wr(dev, MT_RXQ_EXT_CTRL(MT_RXQ_MCU) + ofs, PREFETCH(0x140, 0x4)); |
| 93 | + mt76_wr(dev, MT_RXQ_EXT_CTRL(MT_RXQ_MCU_WA) + ofs, PREFETCH(0x180, 0x4)); |
| 94 | + mt76_wr(dev, MT_RXQ_EXT_CTRL(MT_RXQ_EXT_WA) + ofs, PREFETCH(0x1c0, 0x4)); |
| 95 | + mt76_wr(dev, MT_RXQ_EXT_CTRL(MT_RXQ_MAIN) + ofs, PREFETCH(0x200, 0x4)); |
| 96 | + mt76_wr(dev, MT_RXQ_EXT_CTRL(MT_RXQ_EXT) + ofs, PREFETCH(0x240, 0x4)); |
| 97 | + |
| 98 | + /* for mt7915, the ring which is next the last |
| 99 | + * used ring must be initialized. |
| 100 | + */ |
| 101 | + if (is_mt7915(&dev->mt76)) { |
| 102 | + ofs += 0x4; |
| 103 | + mt76_wr(dev, MT_MCUQ_EXT_CTRL(MT_MCUQ_WA) + ofs, PREFETCH(0x140, 0x0)); |
| 104 | + mt76_wr(dev, MT_RXQ_EXT_CTRL(MT_RXQ_EXT_WA) + ofs, PREFETCH(0x200, 0x0)); |
| 105 | + mt76_wr(dev, MT_RXQ_EXT_CTRL(MT_RXQ_EXT) + ofs, PREFETCH(0x280, 0x0)); |
| 106 | + } |
71 | 107 | } |
72 | 108 |
|
73 | 109 | void mt7915_dma_prefetch(struct mt7915_dev *dev) |
74 | 110 | { |
75 | 111 | __mt7915_dma_prefetch(dev, 0); |
76 | 112 | if (dev->hif2) |
77 | | - __mt7915_dma_prefetch(dev, MT_WFDMA1_PCIE1_BASE - MT_WFDMA1_BASE); |
| 113 | + __mt7915_dma_prefetch(dev, MT_WFDMA0_PCIE1(0) - MT_WFDMA0(0)); |
78 | 114 | } |
79 | 115 |
|
80 | 116 | int mt7915_dma_init(struct mt7915_dev *dev) |
81 | 117 | { |
82 | 118 | u32 hif1_ofs = 0; |
83 | 119 | int ret; |
84 | 120 |
|
| 121 | + mt7915_dma_config(dev); |
| 122 | + |
85 | 123 | mt76_dma_attach(&dev->mt76); |
86 | 124 |
|
87 | 125 | if (dev->hif2) |
88 | | - hif1_ofs = MT_WFDMA1_PCIE1_BASE - MT_WFDMA1_BASE; |
| 126 | + hif1_ofs = MT_WFDMA0_PCIE1(0) - MT_WFDMA0(0); |
89 | 127 |
|
90 | 128 | /* configure global setting */ |
91 | 129 | mt76_set(dev, MT_WFDMA1_GLO_CFG, |
@@ -116,64 +154,79 @@ int mt7915_dma_init(struct mt7915_dev *dev) |
116 | 154 | mt7915_dma_prefetch(dev); |
117 | 155 |
|
118 | 156 | /* init tx queue */ |
119 | | - ret = mt7915_init_tx_queues(&dev->phy, MT7915_TXQ_BAND0, |
120 | | - MT7915_TX_RING_SIZE); |
| 157 | + ret = mt7915_init_tx_queues(&dev->phy, |
| 158 | + MT_TXQ_ID(0), |
| 159 | + MT7915_TX_RING_SIZE, |
| 160 | + MT_TXQ_RING_BASE(0)); |
121 | 161 | if (ret) |
122 | 162 | return ret; |
123 | 163 |
|
124 | 164 | /* command to WM */ |
125 | | - ret = mt76_init_mcu_queue(&dev->mt76, MT_MCUQ_WM, MT7915_TXQ_MCU_WM, |
126 | | - MT7915_TX_MCU_RING_SIZE, MT_TX_RING_BASE); |
| 165 | + ret = mt76_init_mcu_queue(&dev->mt76, MT_MCUQ_WM, |
| 166 | + MT_MCUQ_ID(MT_MCUQ_WM), |
| 167 | + MT7915_TX_MCU_RING_SIZE, |
| 168 | + MT_MCUQ_RING_BASE(MT_MCUQ_WM)); |
127 | 169 | if (ret) |
128 | 170 | return ret; |
129 | 171 |
|
130 | 172 | /* command to WA */ |
131 | | - ret = mt76_init_mcu_queue(&dev->mt76, MT_MCUQ_WA, MT7915_TXQ_MCU_WA, |
132 | | - MT7915_TX_MCU_RING_SIZE, MT_TX_RING_BASE); |
| 173 | + ret = mt76_init_mcu_queue(&dev->mt76, MT_MCUQ_WA, |
| 174 | + MT_MCUQ_ID(MT_MCUQ_WA), |
| 175 | + MT7915_TX_MCU_RING_SIZE, |
| 176 | + MT_MCUQ_RING_BASE(MT_MCUQ_WA)); |
133 | 177 | if (ret) |
134 | 178 | return ret; |
135 | 179 |
|
136 | 180 | /* firmware download */ |
137 | | - ret = mt76_init_mcu_queue(&dev->mt76, MT_MCUQ_FWDL, MT7915_TXQ_FWDL, |
138 | | - MT7915_TX_FWDL_RING_SIZE, MT_TX_RING_BASE); |
| 181 | + ret = mt76_init_mcu_queue(&dev->mt76, MT_MCUQ_FWDL, |
| 182 | + MT_MCUQ_ID(MT_MCUQ_FWDL), |
| 183 | + MT7915_TX_FWDL_RING_SIZE, |
| 184 | + MT_MCUQ_RING_BASE(MT_MCUQ_FWDL)); |
139 | 185 | if (ret) |
140 | 186 | return ret; |
141 | 187 |
|
142 | 188 | /* event from WM */ |
143 | 189 | ret = mt76_queue_alloc(dev, &dev->mt76.q_rx[MT_RXQ_MCU], |
144 | | - MT7915_RXQ_MCU_WM, MT7915_RX_MCU_RING_SIZE, |
145 | | - MT_RX_BUF_SIZE, MT_RX_EVENT_RING_BASE); |
| 190 | + MT_RXQ_ID(MT_RXQ_MCU), |
| 191 | + MT7915_RX_MCU_RING_SIZE, |
| 192 | + MT_RX_BUF_SIZE, |
| 193 | + MT_RXQ_RING_BASE(MT_RXQ_MCU)); |
146 | 194 | if (ret) |
147 | 195 | return ret; |
148 | 196 |
|
149 | 197 | /* event from WA */ |
150 | 198 | ret = mt76_queue_alloc(dev, &dev->mt76.q_rx[MT_RXQ_MCU_WA], |
151 | | - MT7915_RXQ_MCU_WA, MT7915_RX_MCU_RING_SIZE, |
152 | | - MT_RX_BUF_SIZE, MT_RX_EVENT_RING_BASE); |
| 199 | + MT_RXQ_ID(MT_RXQ_MCU_WA), |
| 200 | + MT7915_RX_MCU_RING_SIZE, |
| 201 | + MT_RX_BUF_SIZE, |
| 202 | + MT_RXQ_RING_BASE(MT_RXQ_MCU_WA)); |
153 | 203 | if (ret) |
154 | 204 | return ret; |
155 | 205 |
|
156 | 206 | /* rx data queue */ |
157 | 207 | ret = mt76_queue_alloc(dev, &dev->mt76.q_rx[MT_RXQ_MAIN], |
158 | | - MT7915_RXQ_BAND0, MT7915_RX_RING_SIZE, |
159 | | - MT_RX_BUF_SIZE, MT_RX_DATA_RING_BASE); |
| 208 | + MT_RXQ_ID(MT_RXQ_MAIN), |
| 209 | + MT7915_RX_RING_SIZE, |
| 210 | + MT_RX_BUF_SIZE, |
| 211 | + MT_RXQ_RING_BASE(MT_RXQ_MAIN)); |
160 | 212 | if (ret) |
161 | 213 | return ret; |
162 | 214 |
|
163 | 215 | if (dev->dbdc_support) { |
164 | 216 | ret = mt76_queue_alloc(dev, &dev->mt76.q_rx[MT_RXQ_EXT], |
165 | | - MT7915_RXQ_BAND1, MT7915_RX_RING_SIZE, |
| 217 | + MT_RXQ_ID(MT_RXQ_EXT), |
| 218 | + MT7915_RX_RING_SIZE, |
166 | 219 | MT_RX_BUF_SIZE, |
167 | | - MT_RX_DATA_RING_BASE + hif1_ofs); |
| 220 | + MT_RXQ_RING_BASE(MT_RXQ_EXT) + hif1_ofs); |
168 | 221 | if (ret) |
169 | 222 | return ret; |
170 | 223 |
|
171 | 224 | /* event from WA */ |
172 | 225 | ret = mt76_queue_alloc(dev, &dev->mt76.q_rx[MT_RXQ_EXT_WA], |
173 | | - MT7915_RXQ_MCU_WA_EXT, |
| 226 | + MT_RXQ_ID(MT_RXQ_EXT_WA), |
174 | 227 | MT7915_RX_MCU_RING_SIZE, |
175 | 228 | MT_RX_BUF_SIZE, |
176 | | - MT_RX_EVENT_RING_BASE + hif1_ofs); |
| 229 | + MT_RXQ_RING_BASE(MT_RXQ_EXT_WA) + hif1_ofs); |
177 | 230 | if (ret) |
178 | 231 | return ret; |
179 | 232 | } |
|
0 commit comments