rtl8180.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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. struct rtl8180_tx_desc {
  21. __le32 flags;
  22. __le16 rts_duration;
  23. __le16 plcp_len;
  24. __le32 tx_buf;
  25. __le32 frame_len;
  26. __le32 next_tx_desc;
  27. u8 cw;
  28. u8 retry_limit;
  29. u8 agc;
  30. u8 flags2;
  31. u32 reserved[2];
  32. } __packed;
  33. struct rtl8180_rx_desc {
  34. __le32 flags;
  35. __le32 flags2;
  36. union {
  37. __le32 rx_buf;
  38. __le64 tsft;
  39. };
  40. } __packed;
  41. struct rtl8180_tx_ring {
  42. struct rtl8180_tx_desc *desc;
  43. dma_addr_t dma;
  44. unsigned int idx;
  45. unsigned int entries;
  46. struct sk_buff_head queue;
  47. };
  48. struct rtl8180_vif {
  49. struct ieee80211_hw *dev;
  50. /* beaconing */
  51. struct delayed_work beacon_work;
  52. bool enable_beacon;
  53. };
  54. struct rtl8180_priv {
  55. /* common between rtl818x drivers */
  56. struct rtl818x_csr __iomem *map;
  57. const struct rtl818x_rf_ops *rf;
  58. struct ieee80211_vif *vif;
  59. /* rtl8180 driver specific */
  60. spinlock_t lock;
  61. struct rtl8180_rx_desc *rx_ring;
  62. dma_addr_t rx_ring_dma;
  63. unsigned int rx_idx;
  64. struct sk_buff *rx_buf[32];
  65. struct rtl8180_tx_ring tx_ring[4];
  66. struct ieee80211_channel channels[14];
  67. struct ieee80211_rate rates[12];
  68. struct ieee80211_supported_band band;
  69. struct pci_dev *pdev;
  70. u32 rx_conf;
  71. int r8185;
  72. u32 anaparam;
  73. u16 rfparam;
  74. u8 csthreshold;
  75. /* sequence # */
  76. u16 seqno;
  77. };
  78. void rtl8180_write_phy(struct ieee80211_hw *dev, u8 addr, u32 data);
  79. void rtl8180_set_anaparam(struct rtl8180_priv *priv, u32 anaparam);
  80. static inline u8 rtl818x_ioread8(struct rtl8180_priv *priv, u8 __iomem *addr)
  81. {
  82. return ioread8(addr);
  83. }
  84. static inline u16 rtl818x_ioread16(struct rtl8180_priv *priv, __le16 __iomem *addr)
  85. {
  86. return ioread16(addr);
  87. }
  88. static inline u32 rtl818x_ioread32(struct rtl8180_priv *priv, __le32 __iomem *addr)
  89. {
  90. return ioread32(addr);
  91. }
  92. static inline void rtl818x_iowrite8(struct rtl8180_priv *priv,
  93. u8 __iomem *addr, u8 val)
  94. {
  95. iowrite8(val, addr);
  96. }
  97. static inline void rtl818x_iowrite16(struct rtl8180_priv *priv,
  98. __le16 __iomem *addr, u16 val)
  99. {
  100. iowrite16(val, addr);
  101. }
  102. static inline void rtl818x_iowrite32(struct rtl8180_priv *priv,
  103. __le32 __iomem *addr, u32 val)
  104. {
  105. iowrite32(val, addr);
  106. }
  107. #endif /* RTL8180_H */