aboutsummaryrefslogtreecommitdiffstats
path: root/package/bcm43xx-mac80211/src/bcm43xx/bcm43xx_lo.h
blob: e9d4d59c29b84f8158860325d72c9837b66dd53f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#ifndef BCM43xx_LO_H_
#define BCM43xx_LO_H_

#include "bcm43xx_phy.h"

struct bcm43xx_wldev;

/* Local Oscillator control value-pair. */
struct bcm43xx_loctl {
	/* Control values. */
	s8 i;
	s8 q;
	/* "Used by hardware" flag. */
	u8 used;
};

/* TX Power LO Control Array.
 * Value-pairs to adjust the LocalOscillator are stored
 * in this structure.
 * There are two different set of values. One for "Flag is Set"
 * and one for "Flag is Unset".
 * By "Flag" the flag in struct bcm43xx_rfatt is meant.
 * The Value arrays are two-dimensional. The first index
 * is the baseband attenuation and the second index
 * is the radio attenuation.
 * Use bcm43xx_get_lo_g_ctl() to retrieve a value from the lists.
 */
struct bcm43xx_txpower_lo_control {
#define BCM43xx_NR_BB	9
#define BCM43xx_NR_RF	16
	/* LO Control values, with PAD Mixer */
	struct bcm43xx_loctl with_padmix[ BCM43xx_NR_BB ][ BCM43xx_NR_RF ];
	/* LO Control values, without PAD Mixer */
	struct bcm43xx_loctl no_padmix[ BCM43xx_NR_BB ][ BCM43xx_NR_RF ];

	/* Flag to indicate a complete rebuild of the two tables above
	 * to the LO measuring code. */
	u8 rebuild;

	/* Lists of valid RF and BB attenuation values for this device. */
	struct bcm43xx_rfatt_list rfatt_list;
	struct bcm43xx_bbatt_list bbatt_list;

	/* Current RF and BB attenuation and LO control values. */
	struct bcm43xx_rfatt rfatt;
	struct bcm43xx_bbatt bbatt;

	/* Current TX Bias value */
	u8 tx_bias;
	/* Current TX Magnification Value (if used by the device) */
	u8 tx_magn;

	/* GPHY LO is measured. */
	u8 lo_measured;

	/* Saved device PowerVector */
	u64 power_vector;
};


/* Measure the BPHY Local Oscillator. */
void bcm43xx_lo_b_measure(struct bcm43xx_wldev *dev);
/* Measure the BPHY/GPHY Local Oscillator. */
void bcm43xx_lo_g_measure(struct bcm43xx_wldev *dev);

/* Adjust the Local Oscillator to the saved attenuation
 * and txctl values.
 */
void bcm43xx_lo_g_adjust(struct bcm43xx_wldev *dev);
/* Adjust to specific values. */
void bcm43xx_lo_g_adjust_to(struct bcm43xx_wldev *dev,
			  u16 rfatt, u16 bbatt, u16 txctl1);

/* Returns the bcm43xx_lo_g_ctl corresponding to the current
 * attenuation values.
 */
struct bcm43xx_loctl * bcm43xx_lo_g_ctl_current(struct bcm43xx_wldev *dev);
/* Mark all possible bcm43xx_lo_g_ctl as "unused" */
void bcm43xx_lo_g_ctl_mark_all_unused(struct bcm43xx_wldev *dev);
/* Mark the bcm43xx_lo_g_ctl corresponding to the current
 * attenuation values as used.
 */
void bcm43xx_lo_g_ctl_mark_cur_used(struct bcm43xx_wldev *dev);

/* Get a reference to a LO Control value pair in the
 * TX Power LO Control Array.
 */
struct bcm43xx_loctl * bcm43xx_get_lo_g_ctl(struct bcm43xx_wldev *dev,
					 const struct bcm43xx_rfatt *rfatt,
					 const struct bcm43xx_bbatt *bbatt);

#endif /* BCM43xx_LO_H_ */