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