aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00/rt2800usb.c
diff options
context:
space:
mode:
authorIvo van Doorn <ivdoorn@gmail.com>2010-08-23 13:55:22 -0400
committerJohn W. Linville <linville@tuxdriver.com>2010-08-25 14:34:55 -0400
commitb9a07ae9d9e09662013992088fd58ffbcb2f9a30 (patch)
tree4c406516c317e42539830d3ed71aad98d074aa17 /drivers/net/wireless/rt2x00/rt2800usb.c
parent21595bd50dd1ef16cf0dce33835caaf5ab458d4c (diff)
rt2x00: Merge rt2800{pci/usb} radio enabling/disabling code to rt2800lib
The functions rt2800pci_enable_radio and rt2800usb_disable_radio are almost equal and can be merged into rt2800lib. This reduces the number of functions which must be exported from rt2800lib to the drivers at the same time. Also rt2800pci_disable_radio and rt2800usb_disable_radio are almost equal and can be merged into rt2800lib in a similar fashion. Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Acked-by: Helmut Schaa <helmut.schaa@googlemail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt2800usb.c')
-rw-r--r--drivers/net/wireless/rt2x00/rt2800usb.c72
1 files changed, 3 insertions, 69 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c
index 02f95892aa07..82ae58e0c5d7 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
@@ -173,30 +160,10 @@ static int rt2800usb_init_registers(struct rt2x00_dev *rt2x00dev)
173static int rt2800usb_enable_radio(struct rt2x00_dev *rt2x00dev) 160static int rt2800usb_enable_radio(struct rt2x00_dev *rt2x00dev)
174{ 161{
175 u32 reg; 162 u32 reg;
176 u16 word;
177 163
178 /* 164 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; 165 return -EIO;
186 166
187 rt2800_register_read(rt2x00dev, MAC_SYS_CTRL, &reg);
188 rt2x00_set_field32(&reg, 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, &reg);
194 rt2x00_set_field32(&reg, WPDMA_GLO_CFG_TX_WRITEBACK_DONE, 1);
195 rt2x00_set_field32(&reg, WPDMA_GLO_CFG_ENABLE_RX_DMA, 1);
196 rt2x00_set_field32(&reg, 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, &reg); 167 rt2800_register_read(rt2x00dev, USB_DMA_CFG, &reg);
201 rt2x00_set_field32(&reg, USB_DMA_CFG_PHY_CLEAR, 0); 168 rt2x00_set_field32(&reg, USB_DMA_CFG_PHY_CLEAR, 0);
202 rt2x00_set_field32(&reg, USB_DMA_CFG_RX_BULK_AGG_EN, 0); 169 rt2x00_set_field32(&reg, USB_DMA_CFG_RX_BULK_AGG_EN, 0);
@@ -211,45 +178,12 @@ static int rt2800usb_enable_radio(struct rt2x00_dev *rt2x00dev)
211 rt2x00_set_field32(&reg, USB_DMA_CFG_TX_BULK_EN, 1); 178 rt2x00_set_field32(&reg, USB_DMA_CFG_TX_BULK_EN, 1);
212 rt2800_register_write(rt2x00dev, USB_DMA_CFG, reg); 179 rt2800_register_write(rt2x00dev, USB_DMA_CFG, reg);
213 180
214 rt2800_register_read(rt2x00dev, MAC_SYS_CTRL, &reg); 181 return rt2800_enable_radio(rt2x00dev);
215 rt2x00_set_field32(&reg, MAC_SYS_CTRL_ENABLE_TX, 1);
216 rt2x00_set_field32(&reg, 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} 182}
236 183
237static void rt2800usb_disable_radio(struct rt2x00_dev *rt2x00dev) 184static void rt2800usb_disable_radio(struct rt2x00_dev *rt2x00dev)
238{ 185{
239 u32 reg; 186 rt2800_disable_radio(rt2x00dev);
240
241 rt2800_register_read(rt2x00dev, WPDMA_GLO_CFG, &reg);
242 rt2x00_set_field32(&reg, WPDMA_GLO_CFG_ENABLE_TX_DMA, 0);
243 rt2x00_set_field32(&reg, 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); 187 rt2x00usb_disable_radio(rt2x00dev);
254} 188}
255 189