aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2013-10-17 03:42:23 -0400
committerJohn W. Linville <linville@tuxdriver.com>2013-10-18 14:06:59 -0400
commitd5580ade2fec2a0d50ceee7a9ce44a35a4de133b (patch)
tree9b4e3ef9ad7ceac901174c27deb0b359b13d6238 /drivers/net/wireless/rt2x00
parent51e62469eac296d39d57fb75f182e4ef8066f82f (diff)
rt2x00: rt2800pci: move queue functions to the rt2800mmio module
Move the functions into a separate module, in order to make those usable from other modules. Also move the queue register offset macros from rt2800pci.h into rt2800mmio.h. Signed-off-by: Gabor Juhos <juhosg@openwrt.org> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/rt2x00')
-rw-r--r--drivers/net/wireless/rt2x00/rt2800mmio.c137
-rw-r--r--drivers/net/wireless/rt2x00/rt2800mmio.h15
-rw-r--r--drivers/net/wireless/rt2x00/rt2800pci.c133
-rw-r--r--drivers/net/wireless/rt2x00/rt2800pci.h9
4 files changed, 152 insertions, 142 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2800mmio.c b/drivers/net/wireless/rt2x00/rt2800mmio.c
index bfae4f03a522..c42bea56ec15 100644
--- a/drivers/net/wireless/rt2x00/rt2800mmio.c
+++ b/drivers/net/wireless/rt2x00/rt2800mmio.c
@@ -552,6 +552,143 @@ void rt2800mmio_toggle_irq(struct rt2x00_dev *rt2x00dev,
552} 552}
553EXPORT_SYMBOL_GPL(rt2800mmio_toggle_irq); 553EXPORT_SYMBOL_GPL(rt2800mmio_toggle_irq);
554 554
555/*
556 * Queue handlers.
557 */
558void rt2800mmio_start_queue(struct data_queue *queue)
559{
560 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
561 u32 reg;
562
563 switch (queue->qid) {
564 case QID_RX:
565 rt2x00mmio_register_read(rt2x00dev, MAC_SYS_CTRL, &reg);
566 rt2x00_set_field32(&reg, MAC_SYS_CTRL_ENABLE_RX, 1);
567 rt2x00mmio_register_write(rt2x00dev, MAC_SYS_CTRL, reg);
568 break;
569 case QID_BEACON:
570 rt2x00mmio_register_read(rt2x00dev, BCN_TIME_CFG, &reg);
571 rt2x00_set_field32(&reg, BCN_TIME_CFG_TSF_TICKING, 1);
572 rt2x00_set_field32(&reg, BCN_TIME_CFG_TBTT_ENABLE, 1);
573 rt2x00_set_field32(&reg, BCN_TIME_CFG_BEACON_GEN, 1);
574 rt2x00mmio_register_write(rt2x00dev, BCN_TIME_CFG, reg);
575
576 rt2x00mmio_register_read(rt2x00dev, INT_TIMER_EN, &reg);
577 rt2x00_set_field32(&reg, INT_TIMER_EN_PRE_TBTT_TIMER, 1);
578 rt2x00mmio_register_write(rt2x00dev, INT_TIMER_EN, reg);
579 break;
580 default:
581 break;
582 }
583}
584EXPORT_SYMBOL_GPL(rt2800mmio_start_queue);
585
586void rt2800mmio_kick_queue(struct data_queue *queue)
587{
588 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
589 struct queue_entry *entry;
590
591 switch (queue->qid) {
592 case QID_AC_VO:
593 case QID_AC_VI:
594 case QID_AC_BE:
595 case QID_AC_BK:
596 entry = rt2x00queue_get_entry(queue, Q_INDEX);
597 rt2x00mmio_register_write(rt2x00dev, TX_CTX_IDX(queue->qid),
598 entry->entry_idx);
599 break;
600 case QID_MGMT:
601 entry = rt2x00queue_get_entry(queue, Q_INDEX);
602 rt2x00mmio_register_write(rt2x00dev, TX_CTX_IDX(5),
603 entry->entry_idx);
604 break;
605 default:
606 break;
607 }
608}
609EXPORT_SYMBOL_GPL(rt2800mmio_kick_queue);
610
611void rt2800mmio_stop_queue(struct data_queue *queue)
612{
613 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
614 u32 reg;
615
616 switch (queue->qid) {
617 case QID_RX:
618 rt2x00mmio_register_read(rt2x00dev, MAC_SYS_CTRL, &reg);
619 rt2x00_set_field32(&reg, MAC_SYS_CTRL_ENABLE_RX, 0);
620 rt2x00mmio_register_write(rt2x00dev, MAC_SYS_CTRL, reg);
621 break;
622 case QID_BEACON:
623 rt2x00mmio_register_read(rt2x00dev, BCN_TIME_CFG, &reg);
624 rt2x00_set_field32(&reg, BCN_TIME_CFG_TSF_TICKING, 0);
625 rt2x00_set_field32(&reg, BCN_TIME_CFG_TBTT_ENABLE, 0);
626 rt2x00_set_field32(&reg, BCN_TIME_CFG_BEACON_GEN, 0);
627 rt2x00mmio_register_write(rt2x00dev, BCN_TIME_CFG, reg);
628
629 rt2x00mmio_register_read(rt2x00dev, INT_TIMER_EN, &reg);
630 rt2x00_set_field32(&reg, INT_TIMER_EN_PRE_TBTT_TIMER, 0);
631 rt2x00mmio_register_write(rt2x00dev, INT_TIMER_EN, reg);
632
633 /*
634 * Wait for current invocation to finish. The tasklet
635 * won't be scheduled anymore afterwards since we disabled
636 * the TBTT and PRE TBTT timer.
637 */
638 tasklet_kill(&rt2x00dev->tbtt_tasklet);
639 tasklet_kill(&rt2x00dev->pretbtt_tasklet);
640
641 break;
642 default:
643 break;
644 }
645}
646EXPORT_SYMBOL_GPL(rt2800mmio_stop_queue);
647
648void rt2800mmio_queue_init(struct data_queue *queue)
649{
650 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
651 unsigned short txwi_size, rxwi_size;
652
653 rt2800_get_txwi_rxwi_size(rt2x00dev, &txwi_size, &rxwi_size);
654
655 switch (queue->qid) {
656 case QID_RX:
657 queue->limit = 128;
658 queue->data_size = AGGREGATION_SIZE;
659 queue->desc_size = RXD_DESC_SIZE;
660 queue->winfo_size = rxwi_size;
661 queue->priv_size = sizeof(struct queue_entry_priv_mmio);
662 break;
663
664 case QID_AC_VO:
665 case QID_AC_VI:
666 case QID_AC_BE:
667 case QID_AC_BK:
668 queue->limit = 64;
669 queue->data_size = AGGREGATION_SIZE;
670 queue->desc_size = TXD_DESC_SIZE;
671 queue->winfo_size = txwi_size;
672 queue->priv_size = sizeof(struct queue_entry_priv_mmio);
673 break;
674
675 case QID_BEACON:
676 queue->limit = 8;
677 queue->data_size = 0; /* No DMA required for beacons */
678 queue->desc_size = TXD_DESC_SIZE;
679 queue->winfo_size = txwi_size;
680 queue->priv_size = sizeof(struct queue_entry_priv_mmio);
681 break;
682
683 case QID_ATIM:
684 /* fallthrough */
685 default:
686 BUG();
687 break;
688 }
689}
690EXPORT_SYMBOL_GPL(rt2800mmio_queue_init);
691
555MODULE_AUTHOR(DRV_PROJECT); 692MODULE_AUTHOR(DRV_PROJECT);
556MODULE_VERSION(DRV_VERSION); 693MODULE_VERSION(DRV_VERSION);
557MODULE_DESCRIPTION("rt2800 MMIO library"); 694MODULE_DESCRIPTION("rt2800 MMIO library");
diff --git a/drivers/net/wireless/rt2x00/rt2800mmio.h b/drivers/net/wireless/rt2x00/rt2800mmio.h
index 30e66ab9af37..676df2e62d45 100644
--- a/drivers/net/wireless/rt2x00/rt2800mmio.h
+++ b/drivers/net/wireless/rt2x00/rt2800mmio.h
@@ -32,6 +32,15 @@
32#define RT2800MMIO_H 32#define RT2800MMIO_H
33 33
34/* 34/*
35 * Queue register offset macros
36 */
37#define TX_QUEUE_REG_OFFSET 0x10
38#define TX_BASE_PTR(__x) (TX_BASE_PTR0 + ((__x) * TX_QUEUE_REG_OFFSET))
39#define TX_MAX_CNT(__x) (TX_MAX_CNT0 + ((__x) * TX_QUEUE_REG_OFFSET))
40#define TX_CTX_IDX(__x) (TX_CTX_IDX0 + ((__x) * TX_QUEUE_REG_OFFSET))
41#define TX_DTX_IDX(__x) (TX_DTX_IDX0 + ((__x) * TX_QUEUE_REG_OFFSET))
42
43/*
35 * DMA descriptor defines. 44 * DMA descriptor defines.
36 */ 45 */
37#define TXD_DESC_SIZE (4 * sizeof(__le32)) 46#define TXD_DESC_SIZE (4 * sizeof(__le32))
@@ -138,4 +147,10 @@ irqreturn_t rt2800mmio_interrupt(int irq, void *dev_instance);
138void rt2800mmio_toggle_irq(struct rt2x00_dev *rt2x00dev, 147void rt2800mmio_toggle_irq(struct rt2x00_dev *rt2x00dev,
139 enum dev_state state); 148 enum dev_state state);
140 149
150/* Queue handlers */
151void rt2800mmio_start_queue(struct data_queue *queue);
152void rt2800mmio_kick_queue(struct data_queue *queue);
153void rt2800mmio_stop_queue(struct data_queue *queue);
154void rt2800mmio_queue_init(struct data_queue *queue);
155
141#endif /* RT2800MMIO_H */ 156#endif /* RT2800MMIO_H */
diff --git a/drivers/net/wireless/rt2x00/rt2800pci.c b/drivers/net/wireless/rt2x00/rt2800pci.c
index 118f2d592a93..d0e4ec50caec 100644
--- a/drivers/net/wireless/rt2x00/rt2800pci.c
+++ b/drivers/net/wireless/rt2x00/rt2800pci.c
@@ -202,96 +202,6 @@ static inline int rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev)
202#endif /* CONFIG_PCI */ 202#endif /* CONFIG_PCI */
203 203
204/* 204/*
205 * Queue handlers.
206 */
207static void rt2800mmio_start_queue(struct data_queue *queue)
208{
209 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
210 u32 reg;
211
212 switch (queue->qid) {
213 case QID_RX:
214 rt2x00mmio_register_read(rt2x00dev, MAC_SYS_CTRL, &reg);
215 rt2x00_set_field32(&reg, MAC_SYS_CTRL_ENABLE_RX, 1);
216 rt2x00mmio_register_write(rt2x00dev, MAC_SYS_CTRL, reg);
217 break;
218 case QID_BEACON:
219 rt2x00mmio_register_read(rt2x00dev, BCN_TIME_CFG, &reg);
220 rt2x00_set_field32(&reg, BCN_TIME_CFG_TSF_TICKING, 1);
221 rt2x00_set_field32(&reg, BCN_TIME_CFG_TBTT_ENABLE, 1);
222 rt2x00_set_field32(&reg, BCN_TIME_CFG_BEACON_GEN, 1);
223 rt2x00mmio_register_write(rt2x00dev, BCN_TIME_CFG, reg);
224
225 rt2x00mmio_register_read(rt2x00dev, INT_TIMER_EN, &reg);
226 rt2x00_set_field32(&reg, INT_TIMER_EN_PRE_TBTT_TIMER, 1);
227 rt2x00mmio_register_write(rt2x00dev, INT_TIMER_EN, reg);
228 break;
229 default:
230 break;
231 }
232}
233
234static void rt2800mmio_kick_queue(struct data_queue *queue)
235{
236 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
237 struct queue_entry *entry;
238
239 switch (queue->qid) {
240 case QID_AC_VO:
241 case QID_AC_VI:
242 case QID_AC_BE:
243 case QID_AC_BK:
244 entry = rt2x00queue_get_entry(queue, Q_INDEX);
245 rt2x00mmio_register_write(rt2x00dev, TX_CTX_IDX(queue->qid),
246 entry->entry_idx);
247 break;
248 case QID_MGMT:
249 entry = rt2x00queue_get_entry(queue, Q_INDEX);
250 rt2x00mmio_register_write(rt2x00dev, TX_CTX_IDX(5),
251 entry->entry_idx);
252 break;
253 default:
254 break;
255 }
256}
257
258static void rt2800mmio_stop_queue(struct data_queue *queue)
259{
260 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
261 u32 reg;
262
263 switch (queue->qid) {
264 case QID_RX:
265 rt2x00mmio_register_read(rt2x00dev, MAC_SYS_CTRL, &reg);
266 rt2x00_set_field32(&reg, MAC_SYS_CTRL_ENABLE_RX, 0);
267 rt2x00mmio_register_write(rt2x00dev, MAC_SYS_CTRL, reg);
268 break;
269 case QID_BEACON:
270 rt2x00mmio_register_read(rt2x00dev, BCN_TIME_CFG, &reg);
271 rt2x00_set_field32(&reg, BCN_TIME_CFG_TSF_TICKING, 0);
272 rt2x00_set_field32(&reg, BCN_TIME_CFG_TBTT_ENABLE, 0);
273 rt2x00_set_field32(&reg, BCN_TIME_CFG_BEACON_GEN, 0);
274 rt2x00mmio_register_write(rt2x00dev, BCN_TIME_CFG, reg);
275
276 rt2x00mmio_register_read(rt2x00dev, INT_TIMER_EN, &reg);
277 rt2x00_set_field32(&reg, INT_TIMER_EN_PRE_TBTT_TIMER, 0);
278 rt2x00mmio_register_write(rt2x00dev, INT_TIMER_EN, reg);
279
280 /*
281 * Wait for current invocation to finish. The tasklet
282 * won't be scheduled anymore afterwards since we disabled
283 * the TBTT and PRE TBTT timer.
284 */
285 tasklet_kill(&rt2x00dev->tbtt_tasklet);
286 tasklet_kill(&rt2x00dev->pretbtt_tasklet);
287
288 break;
289 default:
290 break;
291 }
292}
293
294/*
295 * Firmware functions 205 * Firmware functions
296 */ 206 */
297static char *rt2800pci_get_firmware_name(struct rt2x00_dev *rt2x00dev) 207static char *rt2800pci_get_firmware_name(struct rt2x00_dev *rt2x00dev)
@@ -689,49 +599,6 @@ static const struct rt2x00lib_ops rt2800pci_rt2x00_ops = {
689 .sta_remove = rt2800_sta_remove, 599 .sta_remove = rt2800_sta_remove,
690}; 600};
691 601
692static void rt2800mmio_queue_init(struct data_queue *queue)
693{
694 struct rt2x00_dev *rt2x00dev = queue->rt2x00dev;
695 unsigned short txwi_size, rxwi_size;
696
697 rt2800_get_txwi_rxwi_size(rt2x00dev, &txwi_size, &rxwi_size);
698
699 switch (queue->qid) {
700 case QID_RX:
701 queue->limit = 128;
702 queue->data_size = AGGREGATION_SIZE;
703 queue->desc_size = RXD_DESC_SIZE;
704 queue->winfo_size = rxwi_size;
705 queue->priv_size = sizeof(struct queue_entry_priv_mmio);
706 break;
707
708 case QID_AC_VO:
709 case QID_AC_VI:
710 case QID_AC_BE:
711 case QID_AC_BK:
712 queue->limit = 64;
713 queue->data_size = AGGREGATION_SIZE;
714 queue->desc_size = TXD_DESC_SIZE;
715 queue->winfo_size = txwi_size;
716 queue->priv_size = sizeof(struct queue_entry_priv_mmio);
717 break;
718
719 case QID_BEACON:
720 queue->limit = 8;
721 queue->data_size = 0; /* No DMA required for beacons */
722 queue->desc_size = TXD_DESC_SIZE;
723 queue->winfo_size = txwi_size;
724 queue->priv_size = sizeof(struct queue_entry_priv_mmio);
725 break;
726
727 case QID_ATIM:
728 /* fallthrough */
729 default:
730 BUG();
731 break;
732 }
733}
734
735static const struct rt2x00_ops rt2800pci_ops = { 602static const struct rt2x00_ops rt2800pci_ops = {
736 .name = KBUILD_MODNAME, 603 .name = KBUILD_MODNAME,
737 .drv_data_size = sizeof(struct rt2800_drv_data), 604 .drv_data_size = sizeof(struct rt2800_drv_data),
diff --git a/drivers/net/wireless/rt2x00/rt2800pci.h b/drivers/net/wireless/rt2x00/rt2800pci.h
index 0e551593bf16..a81c9ee281c0 100644
--- a/drivers/net/wireless/rt2x00/rt2800pci.h
+++ b/drivers/net/wireless/rt2x00/rt2800pci.h
@@ -35,15 +35,6 @@
35#define RT2800PCI_H 35#define RT2800PCI_H
36 36
37/* 37/*
38 * Queue register offset macros
39 */
40#define TX_QUEUE_REG_OFFSET 0x10
41#define TX_BASE_PTR(__x) (TX_BASE_PTR0 + ((__x) * TX_QUEUE_REG_OFFSET))
42#define TX_MAX_CNT(__x) (TX_MAX_CNT0 + ((__x) * TX_QUEUE_REG_OFFSET))
43#define TX_CTX_IDX(__x) (TX_CTX_IDX0 + ((__x) * TX_QUEUE_REG_OFFSET))
44#define TX_DTX_IDX(__x) (TX_DTX_IDX0 + ((__x) * TX_QUEUE_REG_OFFSET))
45
46/*
47 * 8051 firmware image. 38 * 8051 firmware image.
48 */ 39 */
49#define FIRMWARE_RT2860 "rt2860.bin" 40#define FIRMWARE_RT2860 "rt2860.bin"