1#ifndef LINUX_B43_PHY_G_H_
2#define LINUX_B43_PHY_G_H_
3
4
5#include "phy_a.h"
6
7
8#define B43_PHY_VERSION_CCK B43_PHY_CCK(0x00)
9#define B43_PHY_CCKBBANDCFG B43_PHY_CCK(0x01)
10#define B43_PHY_PGACTL B43_PHY_CCK(0x15)
11#define B43_PHY_PGACTL_LPF 0x1000
12#define B43_PHY_PGACTL_LOWBANDW 0x0040
13#define B43_PHY_PGACTL_UNKNOWN 0xEFA0
14#define B43_PHY_FBCTL1 B43_PHY_CCK(0x18)
15#define B43_PHY_ITSSI B43_PHY_CCK(0x29)
16#define B43_PHY_LO_LEAKAGE B43_PHY_CCK(0x2D)
17#define B43_PHY_ENERGY B43_PHY_CCK(0x33)
18#define B43_PHY_SYNCCTL B43_PHY_CCK(0x35)
19#define B43_PHY_FBCTL2 B43_PHY_CCK(0x38)
20#define B43_PHY_DACCTL B43_PHY_CCK(0x60)
21#define B43_PHY_RCCALOVER B43_PHY_CCK(0x78)
22
23
24#define B43_PHY_CLASSCTL B43_PHY_EXTG(0x02)
25#define B43_PHY_GTABCTL B43_PHY_EXTG(0x03)
26#define B43_PHY_GTABOFF 0x03FF
27#define B43_PHY_GTABNR 0xFC00
28#define B43_PHY_GTABNR_SHIFT 10
29#define B43_PHY_GTABDATA B43_PHY_EXTG(0x04)
30#define B43_PHY_LO_MASK B43_PHY_EXTG(0x0F)
31#define B43_PHY_LO_CTL B43_PHY_EXTG(0x10)
32#define B43_PHY_RFOVER B43_PHY_EXTG(0x11)
33#define B43_PHY_RFOVERVAL B43_PHY_EXTG(0x12)
34#define B43_PHY_RFOVERVAL_EXTLNA 0x8000
35#define B43_PHY_RFOVERVAL_LNA 0x7000
36#define B43_PHY_RFOVERVAL_LNA_SHIFT 12
37#define B43_PHY_RFOVERVAL_PGA 0x0F00
38#define B43_PHY_RFOVERVAL_PGA_SHIFT 8
39#define B43_PHY_RFOVERVAL_UNK 0x0010
40#define B43_PHY_RFOVERVAL_TRSWRX 0x00E0
41#define B43_PHY_RFOVERVAL_BW 0x0003
42#define B43_PHY_RFOVERVAL_BW_LPF 0x0001
43#define B43_PHY_RFOVERVAL_BW_LBW 0x0002
44#define B43_PHY_ANALOGOVER B43_PHY_EXTG(0x14)
45#define B43_PHY_ANALOGOVERVAL B43_PHY_EXTG(0x15)
46
47
48
49#define B43_GTAB(number, offset) (((number) << B43_PHY_GTABNR_SHIFT) | (offset))
50#define B43_GTAB_NRSSI B43_GTAB(0x00, 0)
51#define B43_GTAB_TRFEMW B43_GTAB(0x0C, 0x120)
52#define B43_GTAB_ORIGTR B43_GTAB(0x2E, 0x298)
53
54u16 b43_gtab_read(struct b43_wldev *dev, u16 table, u16 offset);
55void b43_gtab_write(struct b43_wldev *dev, u16 table, u16 offset, u16 value);
56
57
58
59#define has_tx_magnification(phy) \
60 (((phy)->rev >= 2) && \
61 ((phy)->radio_ver == 0x2050) && \
62 ((phy)->radio_rev == 8))
63
64#define has_loopback_gain(phy) \
65 (((phy)->rev > 1) || ((phy)->gmode))
66
67
68struct b43_rfatt {
69 u8 att;
70 bool with_padmix;
71};
72struct b43_rfatt_list {
73
74 const struct b43_rfatt *list;
75 u8 len;
76
77 u8 min_val;
78 u8 max_val;
79};
80
81
82static inline bool b43_compare_rfatt(const struct b43_rfatt *a,
83 const struct b43_rfatt *b)
84{
85 return ((a->att == b->att) &&
86 (a->with_padmix == b->with_padmix));
87}
88
89
90struct b43_bbatt {
91 u8 att;
92};
93struct b43_bbatt_list {
94
95 const struct b43_bbatt *list;
96 u8 len;
97
98 u8 min_val;
99 u8 max_val;
100};
101
102
103static inline bool b43_compare_bbatt(const struct b43_bbatt *a,
104 const struct b43_bbatt *b)
105{
106 return (a->att == b->att);
107}
108
109
110#define B43_TXCTL_PA3DB 0x40
111#define B43_TXCTL_PA2DB 0x20
112#define B43_TXCTL_TXMIX 0x10
113
114struct b43_txpower_lo_control;
115
116struct b43_phy_g {
117
118 bool aci_enable;
119 bool aci_wlan_automatic;
120 bool aci_hw_rssi;
121
122
123 bool radio_on;
124 struct {
125
126
127 bool valid;
128 u16 rfover;
129 u16 rfoverval;
130 } radio_off_context;
131
132 u16 minlowsig[2];
133 u16 minlowsigpos[2];
134
135
136
137 const s8 *tssi2dbm;
138
139 bool dyn_tssi_tbl;
140
141 int tgt_idle_tssi;
142
143 int cur_idle_tssi;
144
145 u8 average_tssi;
146
147 struct b43_bbatt bbatt;
148 struct b43_rfatt rfatt;
149 u8 tx_control;
150
151
152 int bbatt_delta;
153 int rfatt_delta;
154
155
156 struct b43_txpower_lo_control *lo_control;
157
158 s16 max_lb_gain;
159 s16 trsw_rx_gain;
160 s16 lna_lod_gain;
161 s16 lna_gain;
162 s16 pga_gain;
163
164
165 int interfmode;
166
167
168
169
170
171
172
173#define B43_INTERFSTACK_SIZE 26
174 u32 interfstack[B43_INTERFSTACK_SIZE];
175
176
177 s16 nrssi[2];
178 s32 nrssislope;
179
180 s8 nrssi_lt[64];
181
182 u16 lofcal;
183
184 u16 initval;
185
186
187
188
189 u16 ofdmtab_addr;
190 enum {
191 B43_OFDMTAB_DIRECTION_UNKNOWN = 0,
192 B43_OFDMTAB_DIRECTION_READ,
193 B43_OFDMTAB_DIRECTION_WRITE,
194 } ofdmtab_addr_direction;
195};
196
197void b43_gphy_set_baseband_attenuation(struct b43_wldev *dev,
198 u16 baseband_attenuation);
199void b43_gphy_channel_switch(struct b43_wldev *dev,
200 unsigned int channel,
201 bool synthetic_pu_workaround);
202u8 * b43_generate_dyn_tssi2dbm_tab(struct b43_wldev *dev,
203 s16 pab0, s16 pab1, s16 pab2);
204
205struct b43_phy_operations;
206extern const struct b43_phy_operations b43_phyops_g;
207
208#endif
209