rt2800mmio.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /* Copyright (C) 2009 - 2010 Ivo van Doorn <IvDoorn@gmail.com>
  2. * Copyright (C) 2009 Alban Browaeys <prahal@yahoo.com>
  3. * Copyright (C) 2009 Felix Fietkau <nbd@openwrt.org>
  4. * Copyright (C) 2009 Luis Correia <luis.f.correia@gmail.com>
  5. * Copyright (C) 2009 Mattias Nissler <mattias.nissler@gmx.de>
  6. * Copyright (C) 2009 Mark Asselstine <asselsm@gmail.com>
  7. * Copyright (C) 2009 Xose Vazquez Perez <xose.vazquez@gmail.com>
  8. * Copyright (C) 2009 Bart Zolnierkiewicz <bzolnier@gmail.com>
  9. * <http://rt2x00.serialmonkey.com>
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, see <http://www.gnu.org/licenses/>.
  23. */
  24. /* Module: rt2800mmio
  25. * Abstract: forward declarations for the rt2800mmio module.
  26. */
  27. #ifndef RT2800MMIO_H
  28. #define RT2800MMIO_H
  29. /*
  30. * Queue register offset macros
  31. */
  32. #define TX_QUEUE_REG_OFFSET 0x10
  33. #define TX_BASE_PTR(__x) (TX_BASE_PTR0 + ((__x) * TX_QUEUE_REG_OFFSET))
  34. #define TX_MAX_CNT(__x) (TX_MAX_CNT0 + ((__x) * TX_QUEUE_REG_OFFSET))
  35. #define TX_CTX_IDX(__x) (TX_CTX_IDX0 + ((__x) * TX_QUEUE_REG_OFFSET))
  36. #define TX_DTX_IDX(__x) (TX_DTX_IDX0 + ((__x) * TX_QUEUE_REG_OFFSET))
  37. /*
  38. * DMA descriptor defines.
  39. */
  40. #define TXD_DESC_SIZE (4 * sizeof(__le32))
  41. #define RXD_DESC_SIZE (4 * sizeof(__le32))
  42. /*
  43. * TX descriptor format for TX, PRIO and Beacon Ring.
  44. */
  45. /*
  46. * Word0
  47. */
  48. #define TXD_W0_SD_PTR0 FIELD32(0xffffffff)
  49. /*
  50. * Word1
  51. */
  52. #define TXD_W1_SD_LEN1 FIELD32(0x00003fff)
  53. #define TXD_W1_LAST_SEC1 FIELD32(0x00004000)
  54. #define TXD_W1_BURST FIELD32(0x00008000)
  55. #define TXD_W1_SD_LEN0 FIELD32(0x3fff0000)
  56. #define TXD_W1_LAST_SEC0 FIELD32(0x40000000)
  57. #define TXD_W1_DMA_DONE FIELD32(0x80000000)
  58. /*
  59. * Word2
  60. */
  61. #define TXD_W2_SD_PTR1 FIELD32(0xffffffff)
  62. /*
  63. * Word3
  64. * WIV: Wireless Info Valid. 1: Driver filled WI, 0: DMA needs to copy WI
  65. * QSEL: Select on-chip FIFO ID for 2nd-stage output scheduler.
  66. * 0:MGMT, 1:HCCA 2:EDCA
  67. */
  68. #define TXD_W3_WIV FIELD32(0x01000000)
  69. #define TXD_W3_QSEL FIELD32(0x06000000)
  70. #define TXD_W3_TCO FIELD32(0x20000000)
  71. #define TXD_W3_UCO FIELD32(0x40000000)
  72. #define TXD_W3_ICO FIELD32(0x80000000)
  73. /*
  74. * RX descriptor format for RX Ring.
  75. */
  76. /*
  77. * Word0
  78. */
  79. #define RXD_W0_SDP0 FIELD32(0xffffffff)
  80. /*
  81. * Word1
  82. */
  83. #define RXD_W1_SDL1 FIELD32(0x00003fff)
  84. #define RXD_W1_SDL0 FIELD32(0x3fff0000)
  85. #define RXD_W1_LS0 FIELD32(0x40000000)
  86. #define RXD_W1_DMA_DONE FIELD32(0x80000000)
  87. /*
  88. * Word2
  89. */
  90. #define RXD_W2_SDP1 FIELD32(0xffffffff)
  91. /*
  92. * Word3
  93. * AMSDU: RX with 802.3 header, not 802.11 header.
  94. * DECRYPTED: This frame is being decrypted.
  95. */
  96. #define RXD_W3_BA FIELD32(0x00000001)
  97. #define RXD_W3_DATA FIELD32(0x00000002)
  98. #define RXD_W3_NULLDATA FIELD32(0x00000004)
  99. #define RXD_W3_FRAG FIELD32(0x00000008)
  100. #define RXD_W3_UNICAST_TO_ME FIELD32(0x00000010)
  101. #define RXD_W3_MULTICAST FIELD32(0x00000020)
  102. #define RXD_W3_BROADCAST FIELD32(0x00000040)
  103. #define RXD_W3_MY_BSS FIELD32(0x00000080)
  104. #define RXD_W3_CRC_ERROR FIELD32(0x00000100)
  105. #define RXD_W3_CIPHER_ERROR FIELD32(0x00000600)
  106. #define RXD_W3_AMSDU FIELD32(0x00000800)
  107. #define RXD_W3_HTC FIELD32(0x00001000)
  108. #define RXD_W3_RSSI FIELD32(0x00002000)
  109. #define RXD_W3_L2PAD FIELD32(0x00004000)
  110. #define RXD_W3_AMPDU FIELD32(0x00008000)
  111. #define RXD_W3_DECRYPTED FIELD32(0x00010000)
  112. #define RXD_W3_PLCP_SIGNAL FIELD32(0x00020000)
  113. #define RXD_W3_PLCP_RSSI FIELD32(0x00040000)
  114. /* TX descriptor initialization */
  115. __le32 *rt2800mmio_get_txwi(struct queue_entry *entry);
  116. void rt2800mmio_write_tx_desc(struct queue_entry *entry,
  117. struct txentry_desc *txdesc);
  118. /* RX control handlers */
  119. void rt2800mmio_fill_rxdone(struct queue_entry *entry,
  120. struct rxdone_entry_desc *rxdesc);
  121. /* Interrupt functions */
  122. void rt2800mmio_txstatus_tasklet(unsigned long data);
  123. void rt2800mmio_pretbtt_tasklet(unsigned long data);
  124. void rt2800mmio_tbtt_tasklet(unsigned long data);
  125. void rt2800mmio_rxdone_tasklet(unsigned long data);
  126. void rt2800mmio_autowake_tasklet(unsigned long data);
  127. irqreturn_t rt2800mmio_interrupt(int irq, void *dev_instance);
  128. void rt2800mmio_toggle_irq(struct rt2x00_dev *rt2x00dev,
  129. enum dev_state state);
  130. /* Queue handlers */
  131. void rt2800mmio_start_queue(struct data_queue *queue);
  132. void rt2800mmio_kick_queue(struct data_queue *queue);
  133. void rt2800mmio_stop_queue(struct data_queue *queue);
  134. void rt2800mmio_queue_init(struct data_queue *queue);
  135. /* Initialization functions */
  136. bool rt2800mmio_get_entry_state(struct queue_entry *entry);
  137. void rt2800mmio_clear_entry(struct queue_entry *entry);
  138. int rt2800mmio_init_queues(struct rt2x00_dev *rt2x00dev);
  139. int rt2800mmio_init_registers(struct rt2x00_dev *rt2x00dev);
  140. /* Device state switch handlers. */
  141. int rt2800mmio_enable_radio(struct rt2x00_dev *rt2x00dev);
  142. #endif /* RT2800MMIO_H */