rt2x00mmio.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*
  2. Copyright (C) 2004 - 2009 Ivo van Doorn <IvDoorn@gmail.com>
  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: rt2x00mmio
  19. Abstract: Data structures for the rt2x00mmio module.
  20. */
  21. #ifndef RT2X00MMIO_H
  22. #define RT2X00MMIO_H
  23. #include <linux/io.h>
  24. /*
  25. * Register access.
  26. */
  27. static inline void rt2x00mmio_register_read(struct rt2x00_dev *rt2x00dev,
  28. const unsigned int offset,
  29. u32 *value)
  30. {
  31. *value = readl(rt2x00dev->csr.base + offset);
  32. }
  33. #define rt2x00pci_register_read rt2x00mmio_register_read
  34. static inline void rt2x00mmio_register_multiread(struct rt2x00_dev *rt2x00dev,
  35. const unsigned int offset,
  36. void *value, const u32 length)
  37. {
  38. memcpy_fromio(value, rt2x00dev->csr.base + offset, length);
  39. }
  40. #define rt2x00pci_register_multiread rt2x00mmio_register_multiread
  41. static inline void rt2x00mmio_register_write(struct rt2x00_dev *rt2x00dev,
  42. const unsigned int offset,
  43. u32 value)
  44. {
  45. writel(value, rt2x00dev->csr.base + offset);
  46. }
  47. #define rt2x00pci_register_write rt2x00mmio_register_write
  48. static inline void rt2x00mmio_register_multiwrite(struct rt2x00_dev *rt2x00dev,
  49. const unsigned int offset,
  50. const void *value,
  51. const u32 length)
  52. {
  53. __iowrite32_copy(rt2x00dev->csr.base + offset, value, length >> 2);
  54. }
  55. #define rt2x00pci_register_multiwrite rt2x00mmio_register_multiwrite
  56. /**
  57. * rt2x00mmio_regbusy_read - Read from register with busy check
  58. * @rt2x00dev: Device pointer, see &struct rt2x00_dev.
  59. * @offset: Register offset
  60. * @field: Field to check if register is busy
  61. * @reg: Pointer to where register contents should be stored
  62. *
  63. * This function will read the given register, and checks if the
  64. * register is busy. If it is, it will sleep for a couple of
  65. * microseconds before reading the register again. If the register
  66. * is not read after a certain timeout, this function will return
  67. * FALSE.
  68. */
  69. int rt2x00mmio_regbusy_read(struct rt2x00_dev *rt2x00dev,
  70. const unsigned int offset,
  71. const struct rt2x00_field32 field,
  72. u32 *reg);
  73. #define rt2x00pci_regbusy_read rt2x00mmio_regbusy_read
  74. /**
  75. * struct queue_entry_priv_mmio: Per entry PCI specific information
  76. *
  77. * @desc: Pointer to device descriptor
  78. * @desc_dma: DMA pointer to &desc.
  79. * @data: Pointer to device's entry memory.
  80. * @data_dma: DMA pointer to &data.
  81. */
  82. struct queue_entry_priv_mmio {
  83. __le32 *desc;
  84. dma_addr_t desc_dma;
  85. };
  86. #define queue_entry_priv_pci queue_entry_priv_mmio
  87. /**
  88. * rt2x00mmio_rxdone - Handle RX done events
  89. * @rt2x00dev: Device pointer, see &struct rt2x00_dev.
  90. *
  91. * Returns true if there are still rx frames pending and false if all
  92. * pending rx frames were processed.
  93. */
  94. bool rt2x00mmio_rxdone(struct rt2x00_dev *rt2x00dev);
  95. #define rt2x00pci_rxdone rt2x00mmio_rxdone
  96. /**
  97. * rt2x00mmio_flush_queue - Flush data queue
  98. * @queue: Data queue to stop
  99. * @drop: True to drop all pending frames.
  100. *
  101. * This will wait for a maximum of 100ms, waiting for the queues
  102. * to become empty.
  103. */
  104. void rt2x00mmio_flush_queue(struct data_queue *queue, bool drop);
  105. #define rt2x00pci_flush_queue rt2x00mmio_flush_queue
  106. /*
  107. * Device initialization handlers.
  108. */
  109. int rt2x00mmio_initialize(struct rt2x00_dev *rt2x00dev);
  110. #define rt2x00pci_initialize rt2x00mmio_initialize
  111. void rt2x00mmio_uninitialize(struct rt2x00_dev *rt2x00dev);
  112. #define rt2x00pci_uninitialize rt2x00mmio_uninitialize
  113. #endif /* RT2X00MMIO_H */