rtl8180.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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. /* rtl8180/rtl8185 have 3 queue + beacon queue.
  21. * mac80211 can use just one, + beacon = 2 tot.
  22. */
  23. #define RTL8180_NR_TX_QUEUES 2
  24. /* rtl8187SE have 6 queues + beacon queues
  25. * mac80211 can use 4 QoS data queue, + beacon = 5 tot
  26. */
  27. #define RTL8187SE_NR_TX_QUEUES 5
  28. /* for array static allocation, it is the max of above */
  29. #define RTL818X_NR_TX_QUEUES 5
  30. struct rtl8180_tx_desc {
  31. __le32 flags;
  32. __le16 rts_duration;
  33. __le16 plcp_len;
  34. __le32 tx_buf;
  35. union{
  36. __le32 frame_len;
  37. struct {
  38. __le16 frame_len_se;
  39. __le16 frame_duration;
  40. } __packed;
  41. } __packed;
  42. __le32 next_tx_desc;
  43. u8 cw;
  44. u8 retry_limit;
  45. u8 agc;
  46. u8 flags2;
  47. /* rsvd for 8180/8185.
  48. * valid for 8187se but we dont use it
  49. */
  50. u32 reserved;
  51. /* all rsvd for 8180/8185 */
  52. __le16 flags3;
  53. __le16 frag_qsize;
  54. } __packed;
  55. struct rtl818x_rx_cmd_desc {
  56. __le32 flags;
  57. u32 reserved;
  58. __le32 rx_buf;
  59. } __packed;
  60. struct rtl8180_rx_desc {
  61. __le32 flags;
  62. __le32 flags2;
  63. __le64 tsft;
  64. } __packed;
  65. struct rtl8187se_rx_desc {
  66. __le32 flags;
  67. __le64 tsft;
  68. __le32 flags2;
  69. __le32 flags3;
  70. u32 reserved[3];
  71. } __packed;
  72. struct rtl8180_tx_ring {
  73. struct rtl8180_tx_desc *desc;
  74. dma_addr_t dma;
  75. unsigned int idx;
  76. unsigned int entries;
  77. struct sk_buff_head queue;
  78. };
  79. struct rtl8180_vif {
  80. struct ieee80211_hw *dev;
  81. /* beaconing */
  82. struct delayed_work beacon_work;
  83. bool enable_beacon;
  84. };
  85. struct rtl8180_priv {
  86. /* common between rtl818x drivers */
  87. struct rtl818x_csr __iomem *map;
  88. const struct rtl818x_rf_ops *rf;
  89. struct ieee80211_vif *vif;
  90. /* rtl8180 driver specific */
  91. bool map_pio;
  92. spinlock_t lock;
  93. void *rx_ring;
  94. u8 rx_ring_sz;
  95. dma_addr_t rx_ring_dma;
  96. unsigned int rx_idx;
  97. struct sk_buff *rx_buf[32];
  98. struct rtl8180_tx_ring tx_ring[RTL818X_NR_TX_QUEUES];
  99. struct ieee80211_channel channels[14];
  100. struct ieee80211_rate rates[12];
  101. struct ieee80211_supported_band band;
  102. struct ieee80211_tx_queue_params queue_param[4];
  103. struct pci_dev *pdev;
  104. u32 rx_conf;
  105. u8 slot_time;
  106. u16 ack_time;
  107. enum {
  108. RTL818X_CHIP_FAMILY_RTL8180,
  109. RTL818X_CHIP_FAMILY_RTL8185,
  110. RTL818X_CHIP_FAMILY_RTL8187SE,
  111. } chip_family;
  112. u32 anaparam;
  113. u16 rfparam;
  114. u8 csthreshold;
  115. u8 mac_addr[ETH_ALEN];
  116. u8 rf_type;
  117. u8 xtal_out;
  118. u8 xtal_in;
  119. u8 xtal_cal;
  120. u8 thermal_meter_val;
  121. u8 thermal_meter_en;
  122. u8 antenna_diversity_en;
  123. u8 antenna_diversity_default;
  124. /* sequence # */
  125. u16 seqno;
  126. };
  127. void rtl8180_write_phy(struct ieee80211_hw *dev, u8 addr, u32 data);
  128. void rtl8180_set_anaparam(struct rtl8180_priv *priv, u32 anaparam);
  129. void rtl8180_set_anaparam2(struct rtl8180_priv *priv, u32 anaparam2);
  130. static inline u8 rtl818x_ioread8(struct rtl8180_priv *priv, u8 __iomem *addr)
  131. {
  132. return ioread8(addr);
  133. }
  134. static inline u16 rtl818x_ioread16(struct rtl8180_priv *priv, __le16 __iomem *addr)
  135. {
  136. return ioread16(addr);
  137. }
  138. static inline u32 rtl818x_ioread32(struct rtl8180_priv *priv, __le32 __iomem *addr)
  139. {
  140. return ioread32(addr);
  141. }
  142. static inline void rtl818x_iowrite8(struct rtl8180_priv *priv,
  143. u8 __iomem *addr, u8 val)
  144. {
  145. iowrite8(val, addr);
  146. }
  147. static inline void rtl818x_iowrite16(struct rtl8180_priv *priv,
  148. __le16 __iomem *addr, u16 val)
  149. {
  150. iowrite16(val, addr);
  151. }
  152. static inline void rtl818x_iowrite32(struct rtl8180_priv *priv,
  153. __le32 __iomem *addr, u32 val)
  154. {
  155. iowrite32(val, addr);
  156. }
  157. #endif /* RTL8180_H */