blob: 3b27e20eff80ff1d295d50e879888ed938eda913 [file] [log] [blame]
Michael Buesche4d6b792007-09-18 15:39:42 -04001#ifndef B43_LO_H_
2#define B43_LO_H_
3
Michael Bueschef1a6282008-08-27 18:53:02 +02004/* G-PHY Local Oscillator */
5
6#include "phy_g.h"
Michael Buesche4d6b792007-09-18 15:39:42 -04007
8struct b43_wldev;
9
10/* Local Oscillator control value-pair. */
11struct b43_loctl {
12 /* Control values. */
13 s8 i;
14 s8 q;
Michael Buesche4d6b792007-09-18 15:39:42 -040015};
Michael Buesche4d6b792007-09-18 15:39:42 -040016/* Debugging: Poison value for i and q values. */
17#define B43_LOCTL_POISON 111
18
Michael Bueschf5eda472008-04-20 16:03:32 +020019/* This struct holds calibrated LO settings for a set of
20 * Baseband and RF attenuation settings. */
21struct b43_lo_calib {
22 /* The set of attenuation values this set of LO
23 * control values is calibrated for. */
24 struct b43_bbatt bbatt;
25 struct b43_rfatt rfatt;
26 /* The set of control values for the LO. */
27 struct b43_loctl ctl;
28 /* The time when these settings were calibrated (in jiffies) */
29 unsigned long calib_time;
30 /* List. */
31 struct list_head list;
32};
Michael Buesche4d6b792007-09-18 15:39:42 -040033
Michael Bueschf5eda472008-04-20 16:03:32 +020034/* Size of the DC Lookup Table in 16bit words. */
35#define B43_DC_LT_SIZE 32
36
37/* Local Oscillator calibration information */
Michael Buesche4d6b792007-09-18 15:39:42 -040038struct b43_txpower_lo_control {
Michael Bueschf5eda472008-04-20 16:03:32 +020039 /* Lists of RF and BB attenuation values for this device.
40 * Used for building hardware power control tables. */
Michael Buesche4d6b792007-09-18 15:39:42 -040041 struct b43_rfatt_list rfatt_list;
42 struct b43_bbatt_list bbatt_list;
43
Michael Bueschf5eda472008-04-20 16:03:32 +020044 /* The DC Lookup Table is cached in memory here.
45 * Note that this is only used for Hardware Power Control. */
46 u16 dc_lt[B43_DC_LT_SIZE];
47
48 /* List of calibrated control values (struct b43_lo_calib). */
49 struct list_head calib_list;
50 /* Last time the power vector was read (jiffies). */
51 unsigned long pwr_vec_read_time;
52 /* Last time the txctl values were measured (jiffies). */
53 unsigned long txctl_measured_time;
54
Michael Buesche4d6b792007-09-18 15:39:42 -040055 /* Current TX Bias value */
56 u8 tx_bias;
57 /* Current TX Magnification Value (if used by the device) */
58 u8 tx_magn;
59
Michael Buesche4d6b792007-09-18 15:39:42 -040060 /* Saved device PowerVector */
61 u64 power_vector;
62};
63
Michael Bueschf5eda472008-04-20 16:03:32 +020064/* Calibration expire timeouts.
65 * Timeouts must be multiple of 15 seconds. To make sure
66 * the item really expired when the 15 second timer hits, we
67 * subtract two additional seconds from the timeout. */
68#define B43_LO_CALIB_EXPIRE (HZ * (30 - 2))
69#define B43_LO_PWRVEC_EXPIRE (HZ * (30 - 2))
70#define B43_LO_TXCTL_EXPIRE (HZ * (180 - 4))
71
Michael Buesche4d6b792007-09-18 15:39:42 -040072
73/* Adjust the Local Oscillator to the saved attenuation
74 * and txctl values.
75 */
76void b43_lo_g_adjust(struct b43_wldev *dev);
77/* Adjust to specific values. */
78void b43_lo_g_adjust_to(struct b43_wldev *dev,
79 u16 rfatt, u16 bbatt, u16 tx_control);
80
Michael Bueschf5eda472008-04-20 16:03:32 +020081void b43_gphy_dc_lt_init(struct b43_wldev *dev, bool update_all);
Michael Buesche4d6b792007-09-18 15:39:42 -040082
Michael Bueschf5eda472008-04-20 16:03:32 +020083void b43_lo_g_maintanance_work(struct b43_wldev *dev);
84void b43_lo_g_cleanup(struct b43_wldev *dev);
85void b43_lo_g_init(struct b43_wldev *dev);
Michael Buesche4d6b792007-09-18 15:39:42 -040086
87#endif /* B43_LO_H_ */