rtl8180.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. #ifndef RTL8180_H
  2. #define RTL8180_H
  3. #include "rtl818x.h"
  4. #define MAX_RX_SIZE IEEE80211_MAX_RTS_THRESHOLD
  5. #define RF_PARAM_ANALOGPHY (1 << 0)
  6. #define RF_PARAM_ANTBDEFAULT (1 << 1)
  7. #define RF_PARAM_CARRIERSENSE1 (1 << 2)
  8. #define RF_PARAM_CARRIERSENSE2 (1 << 3)
  9. #define BB_ANTATTEN_CHAN14 0x0C
  10. #define BB_ANTENNA_B 0x40
  11. #define BB_HOST_BANG (1 << 30)
  12. #define BB_HOST_BANG_EN (1 << 2)
  13. #define BB_HOST_BANG_CLK (1 << 1)
  14. #define BB_HOST_BANG_DATA 1
  15. #define ANAPARAM_TXDACOFF_SHIFT 27
  16. #define ANAPARAM_PWR0_SHIFT 28
  17. #define ANAPARAM_PWR0_MASK (0x07 << ANAPARAM_PWR0_SHIFT)
  18. #define ANAPARAM_PWR1_SHIFT 20
  19. #define ANAPARAM_PWR1_MASK (0x7F << ANAPARAM_PWR1_SHIFT)
  20. enum rtl8180_tx_desc_flags {
  21. RTL8180_TX_DESC_FLAG_NO_ENC = (1 << 15),
  22. RTL8180_TX_DESC_FLAG_TX_OK = (1 << 15),
  23. RTL8180_TX_DESC_FLAG_SPLCP = (1 << 16),
  24. RTL8180_TX_DESC_FLAG_RX_UNDER = (1 << 16),
  25. RTL8180_TX_DESC_FLAG_MOREFRAG = (1 << 17),
  26. RTL8180_TX_DESC_FLAG_CTS = (1 << 18),
  27. RTL8180_TX_DESC_FLAG_RTS = (1 << 23),
  28. RTL8180_TX_DESC_FLAG_LS = (1 << 28),
  29. RTL8180_TX_DESC_FLAG_FS = (1 << 29),
  30. RTL8180_TX_DESC_FLAG_DMA = (1 << 30),
  31. RTL8180_TX_DESC_FLAG_OWN = (1 << 31)
  32. };
  33. struct rtl8180_tx_desc {
  34. __le32 flags;
  35. __le16 rts_duration;
  36. __le16 plcp_len;
  37. __le32 tx_buf;
  38. __le32 frame_len;
  39. __le32 next_tx_desc;
  40. u8 cw;
  41. u8 retry_limit;
  42. u8 agc;
  43. u8 flags2;
  44. u32 reserved[2];
  45. } __attribute__ ((packed));
  46. enum rtl8180_rx_desc_flags {
  47. RTL8180_RX_DESC_FLAG_ICV_ERR = (1 << 12),
  48. RTL8180_RX_DESC_FLAG_CRC32_ERR = (1 << 13),
  49. RTL8180_RX_DESC_FLAG_PM = (1 << 14),
  50. RTL8180_RX_DESC_FLAG_RX_ERR = (1 << 15),
  51. RTL8180_RX_DESC_FLAG_BCAST = (1 << 16),
  52. RTL8180_RX_DESC_FLAG_PAM = (1 << 17),
  53. RTL8180_RX_DESC_FLAG_MCAST = (1 << 18),
  54. RTL8180_RX_DESC_FLAG_SPLCP = (1 << 25),
  55. RTL8180_RX_DESC_FLAG_FOF = (1 << 26),
  56. RTL8180_RX_DESC_FLAG_DMA_FAIL = (1 << 27),
  57. RTL8180_RX_DESC_FLAG_LS = (1 << 28),
  58. RTL8180_RX_DESC_FLAG_FS = (1 << 29),
  59. RTL8180_RX_DESC_FLAG_EOR = (1 << 30),
  60. RTL8180_RX_DESC_FLAG_OWN = (1 << 31)
  61. };
  62. struct rtl8180_rx_desc {
  63. __le32 flags;
  64. __le32 flags2;
  65. union {
  66. __le32 rx_buf;
  67. __le64 tsft;
  68. };
  69. } __attribute__ ((packed));
  70. struct rtl8180_tx_ring {
  71. struct rtl8180_tx_desc *desc;
  72. dma_addr_t dma;
  73. unsigned int idx;
  74. unsigned int entries;
  75. struct sk_buff_head queue;
  76. };
  77. struct rtl8180_priv {
  78. /* common between rtl818x drivers */
  79. struct rtl818x_csr __iomem *map;
  80. const struct rtl818x_rf_ops *rf;
  81. struct ieee80211_vif *vif;
  82. int mode;
  83. /* rtl8180 driver specific */
  84. spinlock_t lock;
  85. struct rtl8180_rx_desc *rx_ring;
  86. dma_addr_t rx_ring_dma;
  87. unsigned int rx_idx;
  88. struct sk_buff *rx_buf[32];
  89. struct rtl8180_tx_ring tx_ring[4];
  90. struct ieee80211_channel channels[14];
  91. struct ieee80211_rate rates[12];
  92. struct ieee80211_supported_band band;
  93. struct pci_dev *pdev;
  94. u32 rx_conf;
  95. int r8185;
  96. u32 anaparam;
  97. u16 rfparam;
  98. u8 csthreshold;
  99. };
  100. void rtl8180_write_phy(struct ieee80211_hw *dev, u8 addr, u32 data);
  101. void rtl8180_set_anaparam(struct rtl8180_priv *priv, u32 anaparam);
  102. static inline u8 rtl818x_ioread8(struct rtl8180_priv *priv, u8 __iomem *addr)
  103. {
  104. return ioread8(addr);
  105. }
  106. static inline u16 rtl818x_ioread16(struct rtl8180_priv *priv, __le16 __iomem *addr)
  107. {
  108. return ioread16(addr);
  109. }
  110. static inline u32 rtl818x_ioread32(struct rtl8180_priv *priv, __le32 __iomem *addr)
  111. {
  112. return ioread32(addr);
  113. }
  114. static inline void rtl818x_iowrite8(struct rtl8180_priv *priv,
  115. u8 __iomem *addr, u8 val)
  116. {
  117. iowrite8(val, addr);
  118. }
  119. static inline void rtl818x_iowrite16(struct rtl8180_priv *priv,
  120. __le16 __iomem *addr, u16 val)
  121. {
  122. iowrite16(val, addr);
  123. }
  124. static inline void rtl818x_iowrite32(struct rtl8180_priv *priv,
  125. __le32 __iomem *addr, u32 val)
  126. {
  127. iowrite32(val, addr);
  128. }
  129. #endif /* RTL8180_H */