Merge bcm43xx-mac80211 driver from tree at bu3sch.de, pulled 24/6
[openwrt/svn-archive/archive.git] / package / bcm43xx-mac80211 / src / bcm43xx / bcm43xx_lo.h
1 #ifndef BCM43xx_LO_H_
2 #define BCM43xx_LO_H_
3
4 #include "bcm43xx_phy.h"
5
6 struct bcm43xx_wldev;
7
8 /* Local Oscillator control value-pair. */
9 struct bcm43xx_loctl {
10 /* Control values. */
11 s8 i;
12 s8 q;
13 /* "Used by hardware" flag. */
14 u8 used;
15 };
16
17 /* TX Power LO Control Array.
18 * Value-pairs to adjust the LocalOscillator are stored
19 * in this structure.
20 * There are two different set of values. One for "Flag is Set"
21 * and one for "Flag is Unset".
22 * By "Flag" the flag in struct bcm43xx_rfatt is meant.
23 * The Value arrays are two-dimensional. The first index
24 * is the baseband attenuation and the second index
25 * is the radio attenuation.
26 * Use bcm43xx_get_lo_g_ctl() to retrieve a value from the lists.
27 */
28 struct bcm43xx_txpower_lo_control {
29 #define BCM43xx_NR_BB 9
30 #define BCM43xx_NR_RF 16
31 /* LO Control values, with PAD Mixer */
32 struct bcm43xx_loctl with_padmix[ BCM43xx_NR_BB ][ BCM43xx_NR_RF ];
33 /* LO Control values, without PAD Mixer */
34 struct bcm43xx_loctl no_padmix[ BCM43xx_NR_BB ][ BCM43xx_NR_RF ];
35
36 /* Flag to indicate a complete rebuild of the two tables above
37 * to the LO measuring code. */
38 u8 rebuild;
39
40 /* Lists of valid RF and BB attenuation values for this device. */
41 struct bcm43xx_rfatt_list rfatt_list;
42 struct bcm43xx_bbatt_list bbatt_list;
43
44 /* Current TX Bias value */
45 u8 tx_bias;
46 /* Current TX Magnification Value (if used by the device) */
47 u8 tx_magn;
48
49 /* GPHY LO is measured. */
50 u8 lo_measured;
51
52 /* Saved device PowerVector */
53 u64 power_vector;
54 };
55
56
57 /* Measure the BPHY Local Oscillator. */
58 void bcm43xx_lo_b_measure(struct bcm43xx_wldev *dev);
59 /* Measure the BPHY/GPHY Local Oscillator. */
60 void bcm43xx_lo_g_measure(struct bcm43xx_wldev *dev);
61
62 /* Adjust the Local Oscillator to the saved attenuation
63 * and txctl values.
64 */
65 void bcm43xx_lo_g_adjust(struct bcm43xx_wldev *dev);
66 /* Adjust to specific values. */
67 void bcm43xx_lo_g_adjust_to(struct bcm43xx_wldev *dev,
68 u16 rfatt, u16 bbatt, u16 tx_control);
69
70 /* Returns the bcm43xx_lo_g_ctl corresponding to the current
71 * attenuation values.
72 */
73 struct bcm43xx_loctl * bcm43xx_lo_g_ctl_current(struct bcm43xx_wldev *dev);
74 /* Mark all possible bcm43xx_lo_g_ctl as "unused" */
75 void bcm43xx_lo_g_ctl_mark_all_unused(struct bcm43xx_wldev *dev);
76 /* Mark the bcm43xx_lo_g_ctl corresponding to the current
77 * attenuation values as used.
78 */
79 void bcm43xx_lo_g_ctl_mark_cur_used(struct bcm43xx_wldev *dev);
80
81 /* Get a reference to a LO Control value pair in the
82 * TX Power LO Control Array.
83 */
84 struct bcm43xx_loctl * bcm43xx_get_lo_g_ctl(struct bcm43xx_wldev *dev,
85 const struct bcm43xx_rfatt *rfatt,
86 const struct bcm43xx_bbatt *bbatt);
87
88 #endif /* BCM43xx_LO_H_ */