rt2x00mmio.h 2.7 KB

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