rt2x00pci.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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: 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 access.
  31. */
  32. static inline void rt2x00pci_register_read(struct rt2x00_dev *rt2x00dev,
  33. const unsigned int offset,
  34. u32 *value)
  35. {
  36. *value = readl(rt2x00dev->csr.base + offset);
  37. }
  38. static inline void rt2x00pci_register_multiread(struct rt2x00_dev *rt2x00dev,
  39. const unsigned int offset,
  40. void *value, const u32 length)
  41. {
  42. memcpy_fromio(value, rt2x00dev->csr.base + offset, length);
  43. }
  44. static inline void rt2x00pci_register_write(struct rt2x00_dev *rt2x00dev,
  45. const unsigned int offset,
  46. u32 value)
  47. {
  48. writel(value, rt2x00dev->csr.base + offset);
  49. }
  50. static inline void rt2x00pci_register_multiwrite(struct rt2x00_dev *rt2x00dev,
  51. const unsigned int offset,
  52. const void *value,
  53. const u32 length)
  54. {
  55. memcpy_toio(rt2x00dev->csr.base + offset, value, length);
  56. }
  57. /**
  58. * rt2x00pci_regbusy_read - Read from register with busy check
  59. * @rt2x00dev: Device pointer, see &struct rt2x00_dev.
  60. * @offset: Register offset
  61. * @field: Field to check if register is busy
  62. * @reg: Pointer to where register contents should be stored
  63. *
  64. * This function will read the given register, and checks if the
  65. * register is busy. If it is, it will sleep for a couple of
  66. * microseconds before reading the register again. If the register
  67. * is not read after a certain timeout, this function will return
  68. * FALSE.
  69. */
  70. int rt2x00pci_regbusy_read(struct rt2x00_dev *rt2x00dev,
  71. const unsigned int offset,
  72. const struct rt2x00_field32 field,
  73. u32 *reg);
  74. /**
  75. * rt2x00pci_write_tx_data - Initialize data for TX operation
  76. * @entry: The entry where the frame is located
  77. *
  78. * This function will initialize the DMA and skb descriptor
  79. * to prepare the entry for the actual TX operation.
  80. */
  81. int rt2x00pci_write_tx_data(struct queue_entry *entry);
  82. /**
  83. * struct queue_entry_priv_pci: Per entry PCI specific information
  84. *
  85. * @desc: Pointer to device descriptor
  86. * @desc_dma: DMA pointer to &desc.
  87. * @data: Pointer to device's entry memory.
  88. * @data_dma: DMA pointer to &data.
  89. */
  90. struct queue_entry_priv_pci {
  91. __le32 *desc;
  92. dma_addr_t desc_dma;
  93. };
  94. /**
  95. * rt2x00pci_rxdone - Handle RX done events
  96. * @rt2x00dev: Device pointer, see &struct rt2x00_dev.
  97. */
  98. void rt2x00pci_rxdone(struct rt2x00_dev *rt2x00dev);
  99. /*
  100. * Device initialization handlers.
  101. */
  102. int rt2x00pci_initialize(struct rt2x00_dev *rt2x00dev);
  103. void rt2x00pci_uninitialize(struct rt2x00_dev *rt2x00dev);
  104. /*
  105. * PCI driver handlers.
  106. */
  107. int rt2x00pci_probe(struct pci_dev *pci_dev, const struct pci_device_id *id);
  108. void rt2x00pci_remove(struct pci_dev *pci_dev);
  109. #ifdef CONFIG_PM
  110. int rt2x00pci_suspend(struct pci_dev *pci_dev, pm_message_t state);
  111. int rt2x00pci_resume(struct pci_dev *pci_dev);
  112. #else
  113. #define rt2x00pci_suspend NULL
  114. #define rt2x00pci_resume NULL
  115. #endif /* CONFIG_PM */
  116. #endif /* RT2X00PCI_H */