rtl8180: introduce functions for setting ANAPARAM 2 and 3 params
[deliverable/linux.git] / drivers / net / wireless / 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 spinlock_t lock;
111 void *rx_ring;
112 u8 rx_ring_sz;
113 dma_addr_t rx_ring_dma;
114 unsigned int rx_idx;
115 struct sk_buff *rx_buf[32];
116 struct rtl8180_tx_ring tx_ring[RTL818X_NR_TX_QUEUES];
117 struct ieee80211_channel channels[14];
118 struct ieee80211_rate rates[12];
119 struct ieee80211_supported_band band;
120 struct pci_dev *pdev;
121 u32 rx_conf;
122 u8 slot_time;
123 u16 ack_time;
124
125 enum {
126 RTL818X_CHIP_FAMILY_RTL8180,
127 RTL818X_CHIP_FAMILY_RTL8185,
128 RTL818X_CHIP_FAMILY_RTL8187SE,
129 } chip_family;
130 u32 anaparam;
131 u16 rfparam;
132 u8 csthreshold;
133 u8 mac_addr[ETH_ALEN];
134 u8 rf_type;
135 u8 xtal_out;
136 u8 xtal_in;
137 u8 xtal_cal;
138 u8 thermal_meter_val;
139 u8 thermal_meter_en;
140 u8 antenna_diversity_en;
141 u8 antenna_diversity_default;
142 /* sequence # */
143 u16 seqno;
144 };
145
146 void rtl8180_write_phy(struct ieee80211_hw *dev, u8 addr, u32 data);
147 void rtl8180_set_anaparam(struct rtl8180_priv *priv, u32 anaparam);
148 void rtl8180_set_anaparam2(struct rtl8180_priv *priv, u32 anaparam2);
149
150 static inline u8 rtl818x_ioread8(struct rtl8180_priv *priv, u8 __iomem *addr)
151 {
152 return ioread8(addr);
153 }
154
155 static inline u16 rtl818x_ioread16(struct rtl8180_priv *priv, __le16 __iomem *addr)
156 {
157 return ioread16(addr);
158 }
159
160 static inline u32 rtl818x_ioread32(struct rtl8180_priv *priv, __le32 __iomem *addr)
161 {
162 return ioread32(addr);
163 }
164
165 static inline void rtl818x_iowrite8(struct rtl8180_priv *priv,
166 u8 __iomem *addr, u8 val)
167 {
168 iowrite8(val, addr);
169 }
170
171 static inline void rtl818x_iowrite16(struct rtl8180_priv *priv,
172 __le16 __iomem *addr, u16 val)
173 {
174 iowrite16(val, addr);
175 }
176
177 static inline void rtl818x_iowrite32(struct rtl8180_priv *priv,
178 __le32 __iomem *addr, u32 val)
179 {
180 iowrite32(val, addr);
181 }
182
183 #endif /* RTL8180_H */
This page took 0.034014 seconds and 5 git commands to generate.