rt2x00pci.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /*
  2. Copyright (C) 2004 - 2008 rt2x00 SourceForge Project
  3. <http://rt2x00.serialmonkey.com>
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the
  14. Free Software Foundation, Inc.,
  15. 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  16. */
  17. /*
  18. Module: rt2x00pci
  19. Abstract: Data structures for the rt2x00pci module.
  20. */
  21. #ifndef RT2X00PCI_H
  22. #define RT2X00PCI_H
  23. #include <linux/io.h>
  24. /*
  25. * This variable should be used with the
  26. * pci_driver structure initialization.
  27. */
  28. #define PCI_DEVICE_DATA(__ops) .driver_data = (kernel_ulong_t)(__ops)
  29. /*
  30. * Register defines.
  31. * Some registers require multiple attempts before success,
  32. * in those cases REGISTER_BUSY_COUNT attempts should be
  33. * taken with a REGISTER_BUSY_DELAY interval.
  34. */
  35. #define REGISTER_BUSY_COUNT 5
  36. #define REGISTER_BUSY_DELAY 100
  37. /*
  38. * Descriptor availability flags.
  39. * All PCI device descriptors have these 2 flags
  40. * with the exact same definition.
  41. * By storing them here we can use them inside rt2x00pci
  42. * for some simple entry availability checking.
  43. */
  44. #define TXD_ENTRY_OWNER_NIC FIELD32(0x00000001)
  45. #define TXD_ENTRY_VALID FIELD32(0x00000002)
  46. #define RXD_ENTRY_OWNER_NIC FIELD32(0x00000001)
  47. /*
  48. * Register access.
  49. */
  50. static inline void rt2x00pci_register_read(struct rt2x00_dev *rt2x00dev,
  51. const unsigned long offset,
  52. u32 *value)
  53. {
  54. *value = readl(rt2x00dev->csr_addr + offset);
  55. }
  56. static inline void
  57. rt2x00pci_register_multiread(struct rt2x00_dev *rt2x00dev,
  58. const unsigned long offset,
  59. void *value, const u16 length)
  60. {
  61. memcpy_fromio(value, rt2x00dev->csr_addr + offset, length);
  62. }
  63. static inline void rt2x00pci_register_write(struct rt2x00_dev *rt2x00dev,
  64. const unsigned long offset,
  65. u32 value)
  66. {
  67. writel(value, rt2x00dev->csr_addr + offset);
  68. }
  69. static inline void
  70. rt2x00pci_register_multiwrite(struct rt2x00_dev *rt2x00dev,
  71. const unsigned long offset,
  72. void *value, const u16 length)
  73. {
  74. memcpy_toio(rt2x00dev->csr_addr + offset, value, length);
  75. }
  76. /*
  77. * Beacon handlers.
  78. */
  79. int rt2x00pci_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb,
  80. struct ieee80211_tx_control *control);
  81. /*
  82. * TX data handlers.
  83. */
  84. int rt2x00pci_write_tx_data(struct rt2x00_dev *rt2x00dev,
  85. struct data_queue *queue, struct sk_buff *skb,
  86. struct ieee80211_tx_control *control);
  87. /**
  88. * struct queue_entry_priv_pci_rx: Per RX entry PCI specific information
  89. *
  90. * @desc: Pointer to device descriptor.
  91. * @data: Pointer to device's entry memory.
  92. * @dma: DMA pointer to &data.
  93. */
  94. struct queue_entry_priv_pci_rx {
  95. __le32 *desc;
  96. void *data;
  97. dma_addr_t dma;
  98. };
  99. /**
  100. * struct queue_entry_priv_pci_tx: Per TX entry PCI specific information
  101. *
  102. * @desc: Pointer to device descriptor
  103. * @data: Pointer to device's entry memory.
  104. * @dma: DMA pointer to &data.
  105. * @control: mac80211 control structure used to transmit data.
  106. */
  107. struct queue_entry_priv_pci_tx {
  108. __le32 *desc;
  109. void *data;
  110. dma_addr_t dma;
  111. struct ieee80211_tx_control control;
  112. };
  113. /**
  114. * rt2x00pci_rxdone - Handle RX done events
  115. * @rt2x00dev: Device pointer, see &struct rt2x00_dev.
  116. */
  117. void rt2x00pci_rxdone(struct rt2x00_dev *rt2x00dev);
  118. /**
  119. * rt2x00pci_txdone - Handle TX done events
  120. * @rt2x00dev: Device pointer, see &struct rt2x00_dev.
  121. * @entry: Entry which has completed the transmission of a frame.
  122. * @desc: TX done descriptor
  123. */
  124. void rt2x00pci_txdone(struct rt2x00_dev *rt2x00dev, struct queue_entry *entry,
  125. struct txdone_entry_desc *desc);
  126. /*
  127. * Device initialization handlers.
  128. */
  129. int rt2x00pci_initialize(struct rt2x00_dev *rt2x00dev);
  130. void rt2x00pci_uninitialize(struct rt2x00_dev *rt2x00dev);
  131. /*
  132. * PCI driver handlers.
  133. */
  134. int rt2x00pci_probe(struct pci_dev *pci_dev, const struct pci_device_id *id);
  135. void rt2x00pci_remove(struct pci_dev *pci_dev);
  136. #ifdef CONFIG_PM
  137. int rt2x00pci_suspend(struct pci_dev *pci_dev, pm_message_t state);
  138. int rt2x00pci_resume(struct pci_dev *pci_dev);
  139. #else
  140. #define rt2x00pci_suspend NULL
  141. #define rt2x00pci_resume NULL
  142. #endif /* CONFIG_PM */
  143. #endif /* RT2X00PCI_H */