diff options
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt2800usb.c')
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2800usb.c | 105 |
1 files changed, 19 insertions, 86 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c index 9ad28be294eb..3dff56ec195a 100644 --- a/drivers/net/wireless/rt2x00/rt2800usb.c +++ b/drivers/net/wireless/rt2x00/rt2800usb.c | |||
@@ -101,19 +101,6 @@ static int rt2800usb_write_firmware(struct rt2x00_dev *rt2x00dev, | |||
101 | msleep(10); | 101 | msleep(10); |
102 | rt2800_register_write(rt2x00dev, H2M_MAILBOX_CSR, 0); | 102 | rt2800_register_write(rt2x00dev, H2M_MAILBOX_CSR, 0); |
103 | 103 | ||
104 | /* | ||
105 | * Send signal to firmware during boot time. | ||
106 | */ | ||
107 | rt2800_mcu_request(rt2x00dev, MCU_BOOT_SIGNAL, 0, 0, 0); | ||
108 | |||
109 | if (rt2x00_rt(rt2x00dev, RT3070) || | ||
110 | rt2x00_rt(rt2x00dev, RT3071) || | ||
111 | rt2x00_rt(rt2x00dev, RT3572)) { | ||
112 | udelay(200); | ||
113 | rt2800_mcu_request(rt2x00dev, MCU_CURRENT, 0, 0, 0); | ||
114 | udelay(10); | ||
115 | } | ||
116 | |||
117 | return 0; | 104 | return 0; |
118 | } | 105 | } |
119 | 106 | ||
@@ -135,26 +122,18 @@ static void rt2800usb_toggle_rx(struct rt2x00_dev *rt2x00dev, | |||
135 | static int rt2800usb_init_registers(struct rt2x00_dev *rt2x00dev) | 122 | static int rt2800usb_init_registers(struct rt2x00_dev *rt2x00dev) |
136 | { | 123 | { |
137 | u32 reg; | 124 | u32 reg; |
138 | int i; | ||
139 | 125 | ||
140 | /* | 126 | /* |
141 | * Wait until BBP and RF are ready. | 127 | * Wait until BBP and RF are ready. |
142 | */ | 128 | */ |
143 | for (i = 0; i < REGISTER_BUSY_COUNT; i++) { | 129 | if (rt2800_wait_csr_ready(rt2x00dev)) |
144 | rt2800_register_read(rt2x00dev, MAC_CSR0, ®); | ||
145 | if (reg && reg != ~0) | ||
146 | break; | ||
147 | msleep(1); | ||
148 | } | ||
149 | |||
150 | if (i == REGISTER_BUSY_COUNT) { | ||
151 | ERROR(rt2x00dev, "Unstable hardware.\n"); | ||
152 | return -EBUSY; | 130 | return -EBUSY; |
153 | } | ||
154 | 131 | ||
155 | rt2800_register_read(rt2x00dev, PBF_SYS_CTRL, ®); | 132 | rt2800_register_read(rt2x00dev, PBF_SYS_CTRL, ®); |
156 | rt2800_register_write(rt2x00dev, PBF_SYS_CTRL, reg & ~0x00002000); | 133 | rt2800_register_write(rt2x00dev, PBF_SYS_CTRL, reg & ~0x00002000); |
157 | 134 | ||
135 | rt2800_register_write(rt2x00dev, PWR_PIN_CFG, 0x00000003); | ||
136 | |||
158 | rt2800_register_read(rt2x00dev, MAC_SYS_CTRL, ®); | 137 | rt2800_register_read(rt2x00dev, MAC_SYS_CTRL, ®); |
159 | rt2x00_set_field32(®, MAC_SYS_CTRL_RESET_CSR, 1); | 138 | rt2x00_set_field32(®, MAC_SYS_CTRL_RESET_CSR, 1); |
160 | rt2x00_set_field32(®, MAC_SYS_CTRL_RESET_BBP, 1); | 139 | rt2x00_set_field32(®, MAC_SYS_CTRL_RESET_BBP, 1); |
@@ -173,30 +152,10 @@ static int rt2800usb_init_registers(struct rt2x00_dev *rt2x00dev) | |||
173 | static int rt2800usb_enable_radio(struct rt2x00_dev *rt2x00dev) | 152 | static int rt2800usb_enable_radio(struct rt2x00_dev *rt2x00dev) |
174 | { | 153 | { |
175 | u32 reg; | 154 | u32 reg; |
176 | u16 word; | ||
177 | 155 | ||
178 | /* | 156 | if (unlikely(rt2800_wait_wpdma_ready(rt2x00dev))) |
179 | * Initialize all registers. | ||
180 | */ | ||
181 | if (unlikely(rt2800_wait_wpdma_ready(rt2x00dev) || | ||
182 | rt2800_init_registers(rt2x00dev) || | ||
183 | rt2800_init_bbp(rt2x00dev) || | ||
184 | rt2800_init_rfcsr(rt2x00dev))) | ||
185 | return -EIO; | 157 | return -EIO; |
186 | 158 | ||
187 | rt2800_register_read(rt2x00dev, MAC_SYS_CTRL, ®); | ||
188 | rt2x00_set_field32(®, MAC_SYS_CTRL_ENABLE_TX, 1); | ||
189 | rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, reg); | ||
190 | |||
191 | udelay(50); | ||
192 | |||
193 | rt2800_register_read(rt2x00dev, WPDMA_GLO_CFG, ®); | ||
194 | rt2x00_set_field32(®, WPDMA_GLO_CFG_TX_WRITEBACK_DONE, 1); | ||
195 | rt2x00_set_field32(®, WPDMA_GLO_CFG_ENABLE_RX_DMA, 1); | ||
196 | rt2x00_set_field32(®, WPDMA_GLO_CFG_ENABLE_TX_DMA, 1); | ||
197 | rt2800_register_write(rt2x00dev, WPDMA_GLO_CFG, reg); | ||
198 | |||
199 | |||
200 | rt2800_register_read(rt2x00dev, USB_DMA_CFG, ®); | 159 | rt2800_register_read(rt2x00dev, USB_DMA_CFG, ®); |
201 | rt2x00_set_field32(®, USB_DMA_CFG_PHY_CLEAR, 0); | 160 | rt2x00_set_field32(®, USB_DMA_CFG_PHY_CLEAR, 0); |
202 | rt2x00_set_field32(®, USB_DMA_CFG_RX_BULK_AGG_EN, 0); | 161 | rt2x00_set_field32(®, USB_DMA_CFG_RX_BULK_AGG_EN, 0); |
@@ -211,45 +170,12 @@ static int rt2800usb_enable_radio(struct rt2x00_dev *rt2x00dev) | |||
211 | rt2x00_set_field32(®, USB_DMA_CFG_TX_BULK_EN, 1); | 170 | rt2x00_set_field32(®, USB_DMA_CFG_TX_BULK_EN, 1); |
212 | rt2800_register_write(rt2x00dev, USB_DMA_CFG, reg); | 171 | rt2800_register_write(rt2x00dev, USB_DMA_CFG, reg); |
213 | 172 | ||
214 | rt2800_register_read(rt2x00dev, MAC_SYS_CTRL, ®); | 173 | return rt2800_enable_radio(rt2x00dev); |
215 | rt2x00_set_field32(®, MAC_SYS_CTRL_ENABLE_TX, 1); | ||
216 | rt2x00_set_field32(®, MAC_SYS_CTRL_ENABLE_RX, 1); | ||
217 | rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, reg); | ||
218 | |||
219 | /* | ||
220 | * Initialize LED control | ||
221 | */ | ||
222 | rt2x00_eeprom_read(rt2x00dev, EEPROM_LED1, &word); | ||
223 | rt2800_mcu_request(rt2x00dev, MCU_LED_1, 0xff, | ||
224 | word & 0xff, (word >> 8) & 0xff); | ||
225 | |||
226 | rt2x00_eeprom_read(rt2x00dev, EEPROM_LED2, &word); | ||
227 | rt2800_mcu_request(rt2x00dev, MCU_LED_2, 0xff, | ||
228 | word & 0xff, (word >> 8) & 0xff); | ||
229 | |||
230 | rt2x00_eeprom_read(rt2x00dev, EEPROM_LED3, &word); | ||
231 | rt2800_mcu_request(rt2x00dev, MCU_LED_3, 0xff, | ||
232 | word & 0xff, (word >> 8) & 0xff); | ||
233 | |||
234 | return 0; | ||
235 | } | 174 | } |
236 | 175 | ||
237 | static void rt2800usb_disable_radio(struct rt2x00_dev *rt2x00dev) | 176 | static void rt2800usb_disable_radio(struct rt2x00_dev *rt2x00dev) |
238 | { | 177 | { |
239 | u32 reg; | 178 | rt2800_disable_radio(rt2x00dev); |
240 | |||
241 | rt2800_register_read(rt2x00dev, WPDMA_GLO_CFG, ®); | ||
242 | rt2x00_set_field32(®, WPDMA_GLO_CFG_ENABLE_TX_DMA, 0); | ||
243 | rt2x00_set_field32(®, WPDMA_GLO_CFG_ENABLE_RX_DMA, 0); | ||
244 | rt2800_register_write(rt2x00dev, WPDMA_GLO_CFG, reg); | ||
245 | |||
246 | rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, 0); | ||
247 | rt2800_register_write(rt2x00dev, PWR_PIN_CFG, 0); | ||
248 | rt2800_register_write(rt2x00dev, TX_PIN_CFG, 0); | ||
249 | |||
250 | /* Wait for DMA, ignore error */ | ||
251 | rt2800_wait_wpdma_ready(rt2x00dev); | ||
252 | |||
253 | rt2x00usb_disable_radio(rt2x00dev); | 179 | rt2x00usb_disable_radio(rt2x00dev); |
254 | } | 180 | } |
255 | 181 | ||
@@ -329,12 +255,11 @@ static __le32 *rt2800usb_get_txwi(struct queue_entry *entry) | |||
329 | return (__le32 *) (entry->skb->data + TXINFO_DESC_SIZE); | 255 | return (__le32 *) (entry->skb->data + TXINFO_DESC_SIZE); |
330 | } | 256 | } |
331 | 257 | ||
332 | static void rt2800usb_write_tx_desc(struct rt2x00_dev *rt2x00dev, | 258 | static void rt2800usb_write_tx_desc(struct queue_entry *entry, |
333 | struct sk_buff *skb, | ||
334 | struct txentry_desc *txdesc) | 259 | struct txentry_desc *txdesc) |
335 | { | 260 | { |
336 | struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb); | 261 | struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb); |
337 | __le32 *txi = (__le32 *) skb->data; | 262 | __le32 *txi = (__le32 *) entry->skb->data; |
338 | u32 word; | 263 | u32 word; |
339 | 264 | ||
340 | /* | 265 | /* |
@@ -342,7 +267,7 @@ static void rt2800usb_write_tx_desc(struct rt2x00_dev *rt2x00dev, | |||
342 | */ | 267 | */ |
343 | rt2x00_desc_read(txi, 0, &word); | 268 | rt2x00_desc_read(txi, 0, &word); |
344 | rt2x00_set_field32(&word, TXINFO_W0_USB_DMA_TX_PKT_LEN, | 269 | rt2x00_set_field32(&word, TXINFO_W0_USB_DMA_TX_PKT_LEN, |
345 | skb->len - TXINFO_DESC_SIZE); | 270 | entry->skb->len - TXINFO_DESC_SIZE); |
346 | rt2x00_set_field32(&word, TXINFO_W0_WIV, | 271 | rt2x00_set_field32(&word, TXINFO_W0_WIV, |
347 | !test_bit(ENTRY_TXD_ENCRYPT_IV, &txdesc->flags)); | 272 | !test_bit(ENTRY_TXD_ENCRYPT_IV, &txdesc->flags)); |
348 | rt2x00_set_field32(&word, TXINFO_W0_QSEL, 2); | 273 | rt2x00_set_field32(&word, TXINFO_W0_QSEL, 2); |
@@ -410,6 +335,14 @@ static void rt2800usb_work_txdone(struct work_struct *work) | |||
410 | } | 335 | } |
411 | } | 336 | } |
412 | 337 | ||
338 | static void rt2800usb_kill_tx_queue(struct data_queue *queue) | ||
339 | { | ||
340 | if (queue->qid == QID_BEACON) | ||
341 | rt2x00usb_register_write(queue->rt2x00dev, BCN_TIME_CFG, 0); | ||
342 | |||
343 | rt2x00usb_kill_tx_queue(queue); | ||
344 | } | ||
345 | |||
413 | /* | 346 | /* |
414 | * RX control handlers | 347 | * RX control handlers |
415 | */ | 348 | */ |
@@ -608,7 +541,7 @@ static const struct rt2x00lib_ops rt2800usb_rt2x00_ops = { | |||
608 | .write_beacon = rt2800_write_beacon, | 541 | .write_beacon = rt2800_write_beacon, |
609 | .get_tx_data_len = rt2800usb_get_tx_data_len, | 542 | .get_tx_data_len = rt2800usb_get_tx_data_len, |
610 | .kick_tx_queue = rt2x00usb_kick_tx_queue, | 543 | .kick_tx_queue = rt2x00usb_kick_tx_queue, |
611 | .kill_tx_queue = rt2x00usb_kill_tx_queue, | 544 | .kill_tx_queue = rt2800usb_kill_tx_queue, |
612 | .fill_rxdone = rt2800usb_fill_rxdone, | 545 | .fill_rxdone = rt2800usb_fill_rxdone, |
613 | .config_shared_key = rt2800_config_shared_key, | 546 | .config_shared_key = rt2800_config_shared_key, |
614 | .config_pairwise_key = rt2800_config_pairwise_key, | 547 | .config_pairwise_key = rt2800_config_pairwise_key, |