rt2x00mmio.h 3.4 KB

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