Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
phy_common.h
Go to the documentation of this file.
1 #ifndef LINUX_B43_PHY_COMMON_H_
2 #define LINUX_B43_PHY_COMMON_H_
3 
4 #include <linux/types.h>
5 #include <linux/nl80211.h>
6 
7 struct b43_wldev;
8 
9 /* Complex number using 2 32-bit signed integers */
10 struct b43_c32 { s32 i, q; };
11 
12 #define CORDIC_CONVERT(value) (((value) >= 0) ? \
13  ((((value) >> 15) + 1) >> 1) : \
14  -((((-(value)) >> 15) + 1) >> 1))
15 
16 /* PHY register routing bits */
17 #define B43_PHYROUTE 0x0C00 /* PHY register routing bits mask */
18 #define B43_PHYROUTE_BASE 0x0000 /* Base registers */
19 #define B43_PHYROUTE_OFDM_GPHY 0x0400 /* OFDM register routing for G-PHYs */
20 #define B43_PHYROUTE_EXT_GPHY 0x0800 /* Extended G-PHY registers */
21 #define B43_PHYROUTE_N_BMODE 0x0C00 /* N-PHY BMODE registers */
22 
23 /* CCK (B-PHY) registers. */
24 #define B43_PHY_CCK(reg) ((reg) | B43_PHYROUTE_BASE)
25 /* N-PHY registers. */
26 #define B43_PHY_N(reg) ((reg) | B43_PHYROUTE_BASE)
27 /* N-PHY BMODE registers. */
28 #define B43_PHY_N_BMODE(reg) ((reg) | B43_PHYROUTE_N_BMODE)
29 /* OFDM (A-PHY) registers. */
30 #define B43_PHY_OFDM(reg) ((reg) | B43_PHYROUTE_OFDM_GPHY)
31 /* Extended G-PHY registers. */
32 #define B43_PHY_EXTG(reg) ((reg) | B43_PHYROUTE_EXT_GPHY)
33 
34 
35 /* Masks for the PHY versioning registers. */
36 #define B43_PHYVER_ANALOG 0xF000
37 #define B43_PHYVER_ANALOG_SHIFT 12
38 #define B43_PHYVER_TYPE 0x0F00
39 #define B43_PHYVER_TYPE_SHIFT 8
40 #define B43_PHYVER_VERSION 0x00FF
41 
42 /* PHY writes need to be flushed if we reach limit */
43 #define B43_MAX_WRITES_IN_ROW 24
44 
58 };
59 
60 /* Antenna identifiers */
61 enum {
62  B43_ANTENNA0 = 0, /* Antenna 0 */
63  B43_ANTENNA1 = 1, /* Antenna 1 */
64  B43_ANTENNA_AUTO0 = 2, /* Automatic, starting with antenna 0 */
65  B43_ANTENNA_AUTO1 = 3, /* Automatic, starting with antenna 1 */
68 
71 };
72 
82 };
83 
158  /* Initialisation */
159  int (*allocate)(struct b43_wldev *dev);
160  void (*free)(struct b43_wldev *dev);
163  int (*init)(struct b43_wldev *dev);
164  void (*exit)(struct b43_wldev *dev);
165 
166  /* Register access */
167  u16 (*phy_read)(struct b43_wldev *dev, u16 reg);
172 
173  /* Radio */
175  void (*software_rfkill)(struct b43_wldev *dev, bool blocked);
176  void (*switch_analog)(struct b43_wldev *dev, bool on);
177  int (*switch_channel)(struct b43_wldev *dev, unsigned int new_channel);
178  unsigned int (*get_default_chan)(struct b43_wldev *dev);
181  enum b43_interference_mitigation new_mode);
182 
183  /* Transmission power adjustment */
185  bool ignore_tssi);
187 
188  /* Misc */
191 };
192 
193 struct b43_phy_a;
194 struct b43_phy_g;
195 struct b43_phy_n;
196 struct b43_phy_lp;
197 struct b43_phy_ht;
198 struct b43_phy_lcn;
199 
200 struct b43_phy {
201  /* Hardware operation callbacks. */
202  const struct b43_phy_operations *ops;
203 
204  /* Most hardware context information is stored in the standard-
205  * specific data structures pointed to by the pointers below.
206  * Only one of them is valid (the currently enabled PHY). */
207 #ifdef CONFIG_B43_DEBUG
208  /* No union for debug build to force NULL derefs in buggy code. */
209  struct {
210 #else
211  union {
212 #endif
213  /* A-PHY specific information */
214  struct b43_phy_a *a;
215  /* G-PHY specific information */
216  struct b43_phy_g *g;
217  /* N-PHY specific information */
218  struct b43_phy_n *n;
219  /* LP-PHY specific information */
220  struct b43_phy_lp *lp;
221  /* HT-PHY specific information */
222  struct b43_phy_ht *ht;
223  /* LCN-PHY specific information */
224  struct b43_phy_lcn *lcn;
225  };
226 
227  /* Band support flags. */
230 
231  /* HT info */
232  bool is_40mhz;
233 
234  /* GMODE bit enabled? */
235  bool gmode;
236 
237  /* Analog Type */
239  /* B43_PHYTYPE_ */
241  /* PHY revision number. */
243 
244  /* Count writes since last read */
246 
247  /* Radio versioning */
248  u16 radio_manuf; /* Radio manufacturer */
249  u16 radio_ver; /* Radio version */
250  u8 radio_rev; /* Radio revision */
251 
252  /* Software state of the radio */
253  bool radio_on;
254 
255  /* Desired TX power level (in dBm).
256  * This is set by the user and adjusted in b43_phy_xmitpower(). */
258 
259  /* Hardware Power Control enabled? */
261 
262  /* The time (in absolute jiffies) when the next TX power output
263  * check is needed. */
264  unsigned long next_txpwr_check_time;
265 
266  /* Current channel */
267  unsigned int channel;
270 
271  /* PHY TX errors counter. */
273 
274 #ifdef CONFIG_B43_DEBUG
275  /* PHY registers locked (w.r.t. firmware) */
276  bool phy_locked;
277  /* Radio registers locked (w.r.t. firmware) */
278  bool radio_locked;
279 #endif /* B43_DEBUG */
280 };
281 
282 
287 int b43_phy_allocate(struct b43_wldev *dev);
288 
292 void b43_phy_free(struct b43_wldev *dev);
293 
297 int b43_phy_init(struct b43_wldev *dev);
298 
302 void b43_phy_exit(struct b43_wldev *dev);
303 
308 bool b43_has_hardware_pctl(struct b43_wldev *dev);
309 
313 u16 b43_phy_read(struct b43_wldev *dev, u16 reg);
314 
318 void b43_phy_write(struct b43_wldev *dev, u16 reg, u16 value);
319 
323 void b43_phy_copy(struct b43_wldev *dev, u16 destreg, u16 srcreg);
324 
328 void b43_phy_mask(struct b43_wldev *dev, u16 offset, u16 mask);
329 
333 void b43_phy_set(struct b43_wldev *dev, u16 offset, u16 set);
334 
338 void b43_phy_maskset(struct b43_wldev *dev, u16 offset, u16 mask, u16 set);
339 
344 #define b43_radio_read16 b43_radio_read /* DEPRECATED */
345 
349 void b43_radio_write(struct b43_wldev *dev, u16 reg, u16 value);
350 #define b43_radio_write16 b43_radio_write /* DEPRECATED */
351 
355 void b43_radio_mask(struct b43_wldev *dev, u16 offset, u16 mask);
356 
360 void b43_radio_set(struct b43_wldev *dev, u16 offset, u16 set);
361 
365 void b43_radio_maskset(struct b43_wldev *dev, u16 offset, u16 mask, u16 set);
366 
371  u16 value, int delay, int timeout);
372 
376 void b43_radio_lock(struct b43_wldev *dev);
377 
381 void b43_radio_unlock(struct b43_wldev *dev);
382 
386 void b43_phy_lock(struct b43_wldev *dev);
387 
391 void b43_phy_unlock(struct b43_wldev *dev);
392 
396 int b43_switch_channel(struct b43_wldev *dev, unsigned int new_channel);
400 #define B43_DEFAULT_CHANNEL UINT_MAX
401 
405 void b43_software_rfkill(struct b43_wldev *dev, bool blocked);
406 
416 void b43_phy_txpower_check(struct b43_wldev *dev, unsigned int flags);
428 };
429 
430 struct work_struct;
432 
440 int b43_phy_shm_tssi_read(struct b43_wldev *dev, u16 shm_offset);
441 
449 void b43_phyop_switch_analog_generic(struct b43_wldev *dev, bool on);
450 
452 
453 void b43_phy_force_clock(struct b43_wldev *dev, bool force);
454 
455 struct b43_c32 b43_cordic(int theta);
456 
457 #endif /* LINUX_B43_PHY_COMMON_H_ */