New: mac80211-based bcm43xx driver from the wireless-dev tree
[openwrt.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 RF and BB attenuation and LO control values. */
45         struct bcm43xx_rfatt rfatt;
46         struct bcm43xx_bbatt bbatt;
47
48         /* Current TX Bias value */
49         u8 tx_bias;
50         /* Current TX Magnification Value (if used by the device) */
51         u8 tx_magn;
52
53         /* GPHY LO is measured. */
54         u8 lo_measured;
55
56         /* Saved device PowerVector */
57         u64 power_vector;
58 };
59
60
61 /* Measure the BPHY Local Oscillator. */
62 void bcm43xx_lo_b_measure(struct bcm43xx_wldev *dev);
63 /* Measure the BPHY/GPHY Local Oscillator. */
64 void bcm43xx_lo_g_measure(struct bcm43xx_wldev *dev);
65
66 /* Adjust the Local Oscillator to the saved attenuation
67  * and txctl values.
68  */
69 void bcm43xx_lo_g_adjust(struct bcm43xx_wldev *dev);
70 /* Adjust to specific values. */
71 void bcm43xx_lo_g_adjust_to(struct bcm43xx_wldev *dev,
72                           u16 rfatt, u16 bbatt, u16 txctl1);
73
74 /* Returns the bcm43xx_lo_g_ctl corresponding to the current
75  * attenuation values.
76  */
77 struct bcm43xx_loctl * bcm43xx_lo_g_ctl_current(struct bcm43xx_wldev *dev);
78 /* Mark all possible bcm43xx_lo_g_ctl as "unused" */
79 void bcm43xx_lo_g_ctl_mark_all_unused(struct bcm43xx_wldev *dev);
80 /* Mark the bcm43xx_lo_g_ctl corresponding to the current
81  * attenuation values as used.
82  */
83 void bcm43xx_lo_g_ctl_mark_cur_used(struct bcm43xx_wldev *dev);
84
85 /* Get a reference to a LO Control value pair in the
86  * TX Power LO Control Array.
87  */
88 struct bcm43xx_loctl * bcm43xx_get_lo_g_ctl(struct bcm43xx_wldev *dev,
89                                          const struct bcm43xx_rfatt *rfatt,
90                                          const struct bcm43xx_bbatt *bbatt);
91
92 #endif /* BCM43xx_LO_H_ */