diff options
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r-- | drivers/net/wireless/rtl8187.h | 113 |
1 files changed, 97 insertions, 16 deletions
diff --git a/drivers/net/wireless/rtl8187.h b/drivers/net/wireless/rtl8187.h index a0cfb666de0e..3afb49f8866a 100644 --- a/drivers/net/wireless/rtl8187.h +++ b/drivers/net/wireless/rtl8187.h | |||
@@ -44,17 +44,48 @@ struct rtl8187_rx_hdr { | |||
44 | __le64 mac_time; | 44 | __le64 mac_time; |
45 | } __attribute__((packed)); | 45 | } __attribute__((packed)); |
46 | 46 | ||
47 | struct rtl8187_tx_hdr { | 47 | struct rtl8187b_rx_hdr { |
48 | __le32 flags; | 48 | __le32 flags; |
49 | __le64 mac_time; | ||
50 | u8 noise; | ||
51 | u8 signal; | ||
52 | u8 agc; | ||
53 | u8 reserved; | ||
54 | __le32 unused; | ||
55 | } __attribute__((packed)); | ||
56 | |||
57 | /* {rtl8187,rtl8187b}_tx_info is in skb */ | ||
58 | |||
59 | /* Tx flags are common between rtl8187 and rtl8187b */ | ||
49 | #define RTL8187_TX_FLAG_NO_ENCRYPT (1 << 15) | 60 | #define RTL8187_TX_FLAG_NO_ENCRYPT (1 << 15) |
50 | #define RTL8187_TX_FLAG_MORE_FRAG (1 << 17) | 61 | #define RTL8187_TX_FLAG_MORE_FRAG (1 << 17) |
51 | #define RTL8187_TX_FLAG_CTS (1 << 18) | 62 | #define RTL8187_TX_FLAG_CTS (1 << 18) |
52 | #define RTL8187_TX_FLAG_RTS (1 << 23) | 63 | #define RTL8187_TX_FLAG_RTS (1 << 23) |
64 | |||
65 | struct rtl8187_tx_hdr { | ||
66 | __le32 flags; | ||
53 | __le16 rts_duration; | 67 | __le16 rts_duration; |
54 | __le16 len; | 68 | __le16 len; |
55 | __le32 retry; | 69 | __le32 retry; |
56 | } __attribute__((packed)); | 70 | } __attribute__((packed)); |
57 | 71 | ||
72 | struct rtl8187b_tx_hdr { | ||
73 | __le32 flags; | ||
74 | __le16 rts_duration; | ||
75 | __le16 len; | ||
76 | __le32 unused_1; | ||
77 | __le16 unused_2; | ||
78 | __le16 tx_duration; | ||
79 | __le32 unused_3; | ||
80 | __le32 retry; | ||
81 | __le32 unused_4[2]; | ||
82 | } __attribute__((packed)); | ||
83 | |||
84 | enum { | ||
85 | DEVICE_RTL8187, | ||
86 | DEVICE_RTL8187B | ||
87 | }; | ||
88 | |||
58 | struct rtl8187_priv { | 89 | struct rtl8187_priv { |
59 | /* common between rtl818x drivers */ | 90 | /* common between rtl818x drivers */ |
60 | struct rtl818x_csr *map; | 91 | struct rtl818x_csr *map; |
@@ -70,70 +101,120 @@ struct rtl8187_priv { | |||
70 | u32 rx_conf; | 101 | u32 rx_conf; |
71 | u16 txpwr_base; | 102 | u16 txpwr_base; |
72 | u8 asic_rev; | 103 | u8 asic_rev; |
104 | u8 is_rtl8187b; | ||
105 | enum { | ||
106 | RTL8187BvB, | ||
107 | RTL8187BvD, | ||
108 | RTL8187BvE | ||
109 | } hw_rev; | ||
73 | struct sk_buff_head rx_queue; | 110 | struct sk_buff_head rx_queue; |
111 | u8 signal; | ||
112 | u8 quality; | ||
113 | u8 noise; | ||
74 | }; | 114 | }; |
75 | 115 | ||
76 | void rtl8187_write_phy(struct ieee80211_hw *dev, u8 addr, u32 data); | 116 | void rtl8187_write_phy(struct ieee80211_hw *dev, u8 addr, u32 data); |
77 | 117 | ||
78 | static inline u8 rtl818x_ioread8(struct rtl8187_priv *priv, u8 *addr) | 118 | static inline u8 rtl818x_ioread8_idx(struct rtl8187_priv *priv, |
119 | u8 *addr, u8 idx) | ||
79 | { | 120 | { |
80 | u8 val; | 121 | u8 val; |
81 | 122 | ||
82 | usb_control_msg(priv->udev, usb_rcvctrlpipe(priv->udev, 0), | 123 | usb_control_msg(priv->udev, usb_rcvctrlpipe(priv->udev, 0), |
83 | RTL8187_REQ_GET_REG, RTL8187_REQT_READ, | 124 | RTL8187_REQ_GET_REG, RTL8187_REQT_READ, |
84 | (unsigned long)addr, 0, &val, sizeof(val), HZ / 2); | 125 | (unsigned long)addr, idx & 0x03, &val, |
126 | sizeof(val), HZ / 2); | ||
85 | 127 | ||
86 | return val; | 128 | return val; |
87 | } | 129 | } |
88 | 130 | ||
89 | static inline u16 rtl818x_ioread16(struct rtl8187_priv *priv, __le16 *addr) | 131 | static inline u8 rtl818x_ioread8(struct rtl8187_priv *priv, u8 *addr) |
132 | { | ||
133 | return rtl818x_ioread8_idx(priv, addr, 0); | ||
134 | } | ||
135 | |||
136 | static inline u16 rtl818x_ioread16_idx(struct rtl8187_priv *priv, | ||
137 | __le16 *addr, u8 idx) | ||
90 | { | 138 | { |
91 | __le16 val; | 139 | __le16 val; |
92 | 140 | ||
93 | usb_control_msg(priv->udev, usb_rcvctrlpipe(priv->udev, 0), | 141 | usb_control_msg(priv->udev, usb_rcvctrlpipe(priv->udev, 0), |
94 | RTL8187_REQ_GET_REG, RTL8187_REQT_READ, | 142 | RTL8187_REQ_GET_REG, RTL8187_REQT_READ, |
95 | (unsigned long)addr, 0, &val, sizeof(val), HZ / 2); | 143 | (unsigned long)addr, idx & 0x03, &val, |
144 | sizeof(val), HZ / 2); | ||
96 | 145 | ||
97 | return le16_to_cpu(val); | 146 | return le16_to_cpu(val); |
98 | } | 147 | } |
99 | 148 | ||
100 | static inline u32 rtl818x_ioread32(struct rtl8187_priv *priv, __le32 *addr) | 149 | static inline u16 rtl818x_ioread16(struct rtl8187_priv *priv, __le16 *addr) |
150 | { | ||
151 | return rtl818x_ioread16_idx(priv, addr, 0); | ||
152 | } | ||
153 | |||
154 | static inline u32 rtl818x_ioread32_idx(struct rtl8187_priv *priv, | ||
155 | __le32 *addr, u8 idx) | ||
101 | { | 156 | { |
102 | __le32 val; | 157 | __le32 val; |
103 | 158 | ||
104 | usb_control_msg(priv->udev, usb_rcvctrlpipe(priv->udev, 0), | 159 | usb_control_msg(priv->udev, usb_rcvctrlpipe(priv->udev, 0), |
105 | RTL8187_REQ_GET_REG, RTL8187_REQT_READ, | 160 | RTL8187_REQ_GET_REG, RTL8187_REQT_READ, |
106 | (unsigned long)addr, 0, &val, sizeof(val), HZ / 2); | 161 | (unsigned long)addr, idx & 0x03, &val, |
162 | sizeof(val), HZ / 2); | ||
107 | 163 | ||
108 | return le32_to_cpu(val); | 164 | return le32_to_cpu(val); |
109 | } | 165 | } |
110 | 166 | ||
111 | static inline void rtl818x_iowrite8(struct rtl8187_priv *priv, | 167 | static inline u32 rtl818x_ioread32(struct rtl8187_priv *priv, __le32 *addr) |
112 | u8 *addr, u8 val) | 168 | { |
169 | return rtl818x_ioread32_idx(priv, addr, 0); | ||
170 | } | ||
171 | |||
172 | static inline void rtl818x_iowrite8_idx(struct rtl8187_priv *priv, | ||
173 | u8 *addr, u8 val, u8 idx) | ||
113 | { | 174 | { |
114 | usb_control_msg(priv->udev, usb_sndctrlpipe(priv->udev, 0), | 175 | usb_control_msg(priv->udev, usb_sndctrlpipe(priv->udev, 0), |
115 | RTL8187_REQ_SET_REG, RTL8187_REQT_WRITE, | 176 | RTL8187_REQ_SET_REG, RTL8187_REQT_WRITE, |
116 | (unsigned long)addr, 0, &val, sizeof(val), HZ / 2); | 177 | (unsigned long)addr, idx & 0x03, &val, |
178 | sizeof(val), HZ / 2); | ||
179 | } | ||
180 | |||
181 | static inline void rtl818x_iowrite8(struct rtl8187_priv *priv, u8 *addr, u8 val) | ||
182 | { | ||
183 | rtl818x_iowrite8_idx(priv, addr, val, 0); | ||
117 | } | 184 | } |
118 | 185 | ||
119 | static inline void rtl818x_iowrite16(struct rtl8187_priv *priv, | 186 | static inline void rtl818x_iowrite16_idx(struct rtl8187_priv *priv, |
120 | __le16 *addr, u16 val) | 187 | __le16 *addr, u16 val, u8 idx) |
121 | { | 188 | { |
122 | __le16 buf = cpu_to_le16(val); | 189 | __le16 buf = cpu_to_le16(val); |
123 | 190 | ||
124 | usb_control_msg(priv->udev, usb_sndctrlpipe(priv->udev, 0), | 191 | usb_control_msg(priv->udev, usb_sndctrlpipe(priv->udev, 0), |
125 | RTL8187_REQ_SET_REG, RTL8187_REQT_WRITE, | 192 | RTL8187_REQ_SET_REG, RTL8187_REQT_WRITE, |
126 | (unsigned long)addr, 0, &buf, sizeof(buf), HZ / 2); | 193 | (unsigned long)addr, idx & 0x03, &buf, sizeof(buf), |
194 | HZ / 2); | ||
127 | } | 195 | } |
128 | 196 | ||
129 | static inline void rtl818x_iowrite32(struct rtl8187_priv *priv, | 197 | static inline void rtl818x_iowrite16(struct rtl8187_priv *priv, __le16 *addr, |
130 | __le32 *addr, u32 val) | 198 | u16 val) |
199 | { | ||
200 | rtl818x_iowrite16_idx(priv, addr, val, 0); | ||
201 | } | ||
202 | |||
203 | static inline void rtl818x_iowrite32_idx(struct rtl8187_priv *priv, | ||
204 | __le32 *addr, u32 val, u8 idx) | ||
131 | { | 205 | { |
132 | __le32 buf = cpu_to_le32(val); | 206 | __le32 buf = cpu_to_le32(val); |
133 | 207 | ||
134 | usb_control_msg(priv->udev, usb_sndctrlpipe(priv->udev, 0), | 208 | usb_control_msg(priv->udev, usb_sndctrlpipe(priv->udev, 0), |
135 | RTL8187_REQ_SET_REG, RTL8187_REQT_WRITE, | 209 | RTL8187_REQ_SET_REG, RTL8187_REQT_WRITE, |
136 | (unsigned long)addr, 0, &buf, sizeof(buf), HZ / 2); | 210 | (unsigned long)addr, idx & 0x03, &buf, sizeof(buf), |
211 | HZ / 2); | ||
212 | } | ||
213 | |||
214 | static inline void rtl818x_iowrite32(struct rtl8187_priv *priv, __le32 *addr, | ||
215 | u32 val) | ||
216 | { | ||
217 | rtl818x_iowrite32_idx(priv, addr, val, 0); | ||
137 | } | 218 | } |
138 | 219 | ||
139 | #endif /* RTL8187_H */ | 220 | #endif /* RTL8187_H */ |