rtl8180.h 3.9 KB

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