aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorRafał Miłecki <zajec5@gmail.com>2012-01-03 16:49:17 -0500
committerJohn W. Linville <linville@tuxdriver.com>2012-01-24 14:06:05 -0500
commitaeab57517cb7995626a60e8d1817fe95e5c07f42 (patch)
tree24b62fe209b840617834c78e0e8eca047a37dd51 /drivers/net
parentd3fd8bf77affcbf80bb8297d177e17ad0b61abc8 (diff)
b43: N-PHY: add helper for getting gain table
Also move the code to tables file. Signed-off-by: Rafał Miłecki <zajec5@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/wireless/b43/phy_n.c81
-rw-r--r--drivers/net/wireless/b43/tables_nphy.c65
-rw-r--r--drivers/net/wireless/b43/tables_nphy.h12
3 files changed, 64 insertions, 94 deletions
diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c
index fbbdbdad1019..d5d02aed9dba 100644
--- a/drivers/net/wireless/b43/phy_n.c
+++ b/drivers/net/wireless/b43/phy_n.c
@@ -85,24 +85,6 @@ static inline bool b43_nphy_ipa(struct b43_wldev *dev)
85 (dev->phy.n->ipa5g_on && band == IEEE80211_BAND_5GHZ)); 85 (dev->phy.n->ipa5g_on && band == IEEE80211_BAND_5GHZ));
86} 86}
87 87
88/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/GetIpaGainTbl */
89static const u32 *b43_nphy_get_ipa_gain_table(struct b43_wldev *dev)
90{
91 if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) {
92 if (dev->phy.rev >= 6) {
93 if (dev->dev->chip_id == 47162)
94 return txpwrctrl_tx_gain_ipa_rev5;
95 return txpwrctrl_tx_gain_ipa_rev6;
96 } else if (dev->phy.rev >= 5) {
97 return txpwrctrl_tx_gain_ipa_rev5;
98 } else {
99 return txpwrctrl_tx_gain_ipa;
100 }
101 } else {
102 return txpwrctrl_tx_gain_ipa_5g;
103 }
104}
105
106/************************************************** 88/**************************************************
107 * RF (just without b43_nphy_rf_control_intc_override) 89 * RF (just without b43_nphy_rf_control_intc_override)
108 **************************************************/ 90 **************************************************/
@@ -2229,27 +2211,12 @@ static void b43_nphy_tx_power_fix(struct b43_wldev *dev)
2229 */ 2211 */
2230 2212
2231 for (i = 0; i < 2; i++) { 2213 for (i = 0; i < 2; i++) {
2232 if (dev->phy.rev >= 3) { 2214 txgain = *(b43_nphy_get_tx_gain_table(dev) + txpi[i]);
2233 if (b43_nphy_ipa(dev)) { 2215
2234 txgain = *(b43_nphy_get_ipa_gain_table(dev) + 2216 if (dev->phy.rev >= 3)
2235 txpi[i]);
2236 } else if (b43_current_band(dev->wl) ==
2237 IEEE80211_BAND_5GHZ) {
2238 /* FIXME: use 5GHz tables */
2239 txgain =
2240 b43_ntab_tx_gain_rev3plus_2ghz[txpi[i]];
2241 } else {
2242 if (dev->phy.rev >= 5 &&
2243 sprom->fem.ghz5.extpa_gain == 3)
2244 ; /* FIXME: 5GHz_txgain_HiPwrEPA */
2245 txgain =
2246 b43_ntab_tx_gain_rev3plus_2ghz[txpi[i]];
2247 }
2248 radio_gain = (txgain >> 16) & 0x1FFFF; 2217 radio_gain = (txgain >> 16) & 0x1FFFF;
2249 } else { 2218 else
2250 txgain = b43_ntab_tx_gain_rev0_1_2[txpi[i]];
2251 radio_gain = (txgain >> 16) & 0x1FFF; 2219 radio_gain = (txgain >> 16) & 0x1FFF;
2252 }
2253 2220
2254 if (dev->phy.rev >= 7) 2221 if (dev->phy.rev >= 7)
2255 dac_gain = (txgain >> 8) & 0x7; 2222 dac_gain = (txgain >> 8) & 0x7;
@@ -2647,24 +2614,7 @@ static void b43_nphy_tx_gain_table_upload(struct b43_wldev *dev)
2647 int i; 2614 int i;
2648#endif 2615#endif
2649 2616
2650 if (phy->rev >= 3) { 2617 table = b43_nphy_get_tx_gain_table(dev);
2651 if (b43_nphy_ipa(dev)) {
2652 table = b43_nphy_get_ipa_gain_table(dev);
2653 } else {
2654 if (b43_current_band(dev->wl) == IEEE80211_BAND_5GHZ) {
2655 if (phy->rev == 3)
2656 table = b43_ntab_tx_gain_rev3_5ghz;
2657 if (phy->rev == 4)
2658 table = b43_ntab_tx_gain_rev4_5ghz;
2659 else
2660 table = b43_ntab_tx_gain_rev5plus_5ghz;
2661 } else {
2662 table = b43_ntab_tx_gain_rev3plus_2ghz;
2663 }
2664 }
2665 } else {
2666 table = b43_ntab_tx_gain_rev0_1_2;
2667 }
2668 b43_ntab_write_bulk(dev, B43_NTAB32(26, 192), 128, table); 2618 b43_ntab_write_bulk(dev, B43_NTAB32(26, 192), 128, table);
2669 b43_ntab_write_bulk(dev, B43_NTAB32(27, 192), 128, table); 2619 b43_ntab_write_bulk(dev, B43_NTAB32(27, 192), 128, table);
2670 2620
@@ -3354,32 +3304,13 @@ static struct nphy_txgains b43_nphy_get_tx_gains(struct b43_wldev *dev)
3354 B43_NPHY_TXPCTL_STAT_BIDX_SHIFT; 3304 B43_NPHY_TXPCTL_STAT_BIDX_SHIFT;
3355 3305
3356 for (i = 0; i < 2; ++i) { 3306 for (i = 0; i < 2; ++i) {
3307 table = b43_nphy_get_tx_gain_table(dev);
3357 if (dev->phy.rev >= 3) { 3308 if (dev->phy.rev >= 3) {
3358 enum ieee80211_band band =
3359 b43_current_band(dev->wl);
3360
3361 if (b43_nphy_ipa(dev)) {
3362 table = b43_nphy_get_ipa_gain_table(dev);
3363 } else {
3364 if (band == IEEE80211_BAND_5GHZ) {
3365 if (dev->phy.rev == 3)
3366 table = b43_ntab_tx_gain_rev3_5ghz;
3367 else if (dev->phy.rev == 4)
3368 table = b43_ntab_tx_gain_rev4_5ghz;
3369 else
3370 table = b43_ntab_tx_gain_rev5plus_5ghz;
3371 } else {
3372 table = b43_ntab_tx_gain_rev3plus_2ghz;
3373 }
3374 }
3375
3376 target.ipa[i] = (table[index[i]] >> 16) & 0xF; 3309 target.ipa[i] = (table[index[i]] >> 16) & 0xF;
3377 target.pad[i] = (table[index[i]] >> 20) & 0xF; 3310 target.pad[i] = (table[index[i]] >> 20) & 0xF;
3378 target.pga[i] = (table[index[i]] >> 24) & 0xF; 3311 target.pga[i] = (table[index[i]] >> 24) & 0xF;
3379 target.txgm[i] = (table[index[i]] >> 28) & 0xF; 3312 target.txgm[i] = (table[index[i]] >> 28) & 0xF;
3380 } else { 3313 } else {
3381 table = b43_ntab_tx_gain_rev0_1_2;
3382
3383 target.ipa[i] = (table[index[i]] >> 16) & 0x3; 3314 target.ipa[i] = (table[index[i]] >> 16) & 0x3;
3384 target.pad[i] = (table[index[i]] >> 18) & 0x3; 3315 target.pad[i] = (table[index[i]] >> 18) & 0x3;
3385 target.pga[i] = (table[index[i]] >> 20) & 0x7; 3316 target.pga[i] = (table[index[i]] >> 20) & 0x7;
diff --git a/drivers/net/wireless/b43/tables_nphy.c b/drivers/net/wireless/b43/tables_nphy.c
index f7def13524dd..afcdca638ccf 100644
--- a/drivers/net/wireless/b43/tables_nphy.c
+++ b/drivers/net/wireless/b43/tables_nphy.c
@@ -2214,7 +2214,7 @@ static const u16 b43_ntab_antswctl2g_r3[4][32] = {
2214}; 2214};
2215 2215
2216/* TX gain tables */ 2216/* TX gain tables */
2217const u32 b43_ntab_tx_gain_rev0_1_2[] = { 2217static const u32 b43_ntab_tx_gain_rev0_1_2[] = {
2218 0x03cc2b44, 0x03cc2b42, 0x03cc2a44, 0x03cc2a42, 2218 0x03cc2b44, 0x03cc2b42, 0x03cc2a44, 0x03cc2a42,
2219 0x03cc2944, 0x03c82b44, 0x03c82b42, 0x03c82a44, 2219 0x03cc2944, 0x03c82b44, 0x03c82b42, 0x03c82a44,
2220 0x03c82a42, 0x03c82944, 0x03c82942, 0x03c82844, 2220 0x03c82a42, 0x03c82944, 0x03c82942, 0x03c82844,
@@ -2249,7 +2249,7 @@ const u32 b43_ntab_tx_gain_rev0_1_2[] = {
2249 0x03801442, 0x03801344, 0x03801342, 0x00002b00, 2249 0x03801442, 0x03801344, 0x03801342, 0x00002b00,
2250}; 2250};
2251 2251
2252const u32 b43_ntab_tx_gain_rev3plus_2ghz[] = { 2252static const u32 b43_ntab_tx_gain_rev3plus_2ghz[] = {
2253 0x1f410044, 0x1f410042, 0x1f410040, 0x1f41003e, 2253 0x1f410044, 0x1f410042, 0x1f410040, 0x1f41003e,
2254 0x1f41003c, 0x1f41003b, 0x1f410039, 0x1f410037, 2254 0x1f41003c, 0x1f41003b, 0x1f410039, 0x1f410037,
2255 0x1e410044, 0x1e410042, 0x1e410040, 0x1e41003e, 2255 0x1e410044, 0x1e410042, 0x1e410040, 0x1e41003e,
@@ -2284,7 +2284,7 @@ const u32 b43_ntab_tx_gain_rev3plus_2ghz[] = {
2284 0x1041003c, 0x1041003b, 0x10410039, 0x10410037, 2284 0x1041003c, 0x1041003b, 0x10410039, 0x10410037,
2285}; 2285};
2286 2286
2287const u32 b43_ntab_tx_gain_rev3_5ghz[] = { 2287static const u32 b43_ntab_tx_gain_rev3_5ghz[] = {
2288 0xcff70044, 0xcff70042, 0xcff70040, 0xcff7003e, 2288 0xcff70044, 0xcff70042, 0xcff70040, 0xcff7003e,
2289 0xcff7003c, 0xcff7003b, 0xcff70039, 0xcff70037, 2289 0xcff7003c, 0xcff7003b, 0xcff70039, 0xcff70037,
2290 0xcef70044, 0xcef70042, 0xcef70040, 0xcef7003e, 2290 0xcef70044, 0xcef70042, 0xcef70040, 0xcef7003e,
@@ -2319,7 +2319,7 @@ const u32 b43_ntab_tx_gain_rev3_5ghz[] = {
2319 0xc0f7003c, 0xc0f7003b, 0xc0f70039, 0xc0f70037, 2319 0xc0f7003c, 0xc0f7003b, 0xc0f70039, 0xc0f70037,
2320}; 2320};
2321 2321
2322const u32 b43_ntab_tx_gain_rev4_5ghz[] = { 2322static const u32 b43_ntab_tx_gain_rev4_5ghz[] = {
2323 0x2ff20044, 0x2ff20042, 0x2ff20040, 0x2ff2003e, 2323 0x2ff20044, 0x2ff20042, 0x2ff20040, 0x2ff2003e,
2324 0x2ff2003c, 0x2ff2003b, 0x2ff20039, 0x2ff20037, 2324 0x2ff2003c, 0x2ff2003b, 0x2ff20039, 0x2ff20037,
2325 0x2ef20044, 0x2ef20042, 0x2ef20040, 0x2ef2003e, 2325 0x2ef20044, 0x2ef20042, 0x2ef20040, 0x2ef2003e,
@@ -2354,7 +2354,7 @@ const u32 b43_ntab_tx_gain_rev4_5ghz[] = {
2354 0x20d2003a, 0x20d20038, 0x20d20036, 0x20d20034, 2354 0x20d2003a, 0x20d20038, 0x20d20036, 0x20d20034,
2355}; 2355};
2356 2356
2357const u32 b43_ntab_tx_gain_rev5plus_5ghz[] = { 2357static const u32 b43_ntab_tx_gain_rev5plus_5ghz[] = {
2358 0x0f62004a, 0x0f620048, 0x0f620046, 0x0f620044, 2358 0x0f62004a, 0x0f620048, 0x0f620046, 0x0f620044,
2359 0x0f620042, 0x0f620040, 0x0f62003e, 0x0f62003c, 2359 0x0f620042, 0x0f620040, 0x0f62003e, 0x0f62003c,
2360 0x0e620044, 0x0e620042, 0x0e620040, 0x0e62003e, 2360 0x0e620044, 0x0e620042, 0x0e620040, 0x0e62003e,
@@ -2389,7 +2389,7 @@ const u32 b43_ntab_tx_gain_rev5plus_5ghz[] = {
2389 0x0062003b, 0x00620039, 0x00620037, 0x00620035, 2389 0x0062003b, 0x00620039, 0x00620037, 0x00620035,
2390}; 2390};
2391 2391
2392const u32 txpwrctrl_tx_gain_ipa[] = { 2392static const u32 txpwrctrl_tx_gain_ipa[] = {
2393 0x5ff7002d, 0x5ff7002b, 0x5ff7002a, 0x5ff70029, 2393 0x5ff7002d, 0x5ff7002b, 0x5ff7002a, 0x5ff70029,
2394 0x5ff70028, 0x5ff70027, 0x5ff70026, 0x5ff70025, 2394 0x5ff70028, 0x5ff70027, 0x5ff70026, 0x5ff70025,
2395 0x5ef7002d, 0x5ef7002b, 0x5ef7002a, 0x5ef70029, 2395 0x5ef7002d, 0x5ef7002b, 0x5ef7002a, 0x5ef70029,
@@ -2424,7 +2424,7 @@ const u32 txpwrctrl_tx_gain_ipa[] = {
2424 0x50f70028, 0x50f70027, 0x50f70026, 0x50f70025, 2424 0x50f70028, 0x50f70027, 0x50f70026, 0x50f70025,
2425}; 2425};
2426 2426
2427const u32 txpwrctrl_tx_gain_ipa_rev5[] = { 2427static const u32 txpwrctrl_tx_gain_ipa_rev5[] = {
2428 0x1ff7002d, 0x1ff7002b, 0x1ff7002a, 0x1ff70029, 2428 0x1ff7002d, 0x1ff7002b, 0x1ff7002a, 0x1ff70029,
2429 0x1ff70028, 0x1ff70027, 0x1ff70026, 0x1ff70025, 2429 0x1ff70028, 0x1ff70027, 0x1ff70026, 0x1ff70025,
2430 0x1ef7002d, 0x1ef7002b, 0x1ef7002a, 0x1ef70029, 2430 0x1ef7002d, 0x1ef7002b, 0x1ef7002a, 0x1ef70029,
@@ -2459,7 +2459,7 @@ const u32 txpwrctrl_tx_gain_ipa_rev5[] = {
2459 0x10f70028, 0x10f70027, 0x10f70026, 0x10f70025, 2459 0x10f70028, 0x10f70027, 0x10f70026, 0x10f70025,
2460}; 2460};
2461 2461
2462const u32 txpwrctrl_tx_gain_ipa_rev6[] = { 2462static const u32 txpwrctrl_tx_gain_ipa_rev6[] = {
2463 0x0ff7002d, 0x0ff7002b, 0x0ff7002a, 0x0ff70029, 2463 0x0ff7002d, 0x0ff7002b, 0x0ff7002a, 0x0ff70029,
2464 0x0ff70028, 0x0ff70027, 0x0ff70026, 0x0ff70025, 2464 0x0ff70028, 0x0ff70027, 0x0ff70026, 0x0ff70025,
2465 0x0ef7002d, 0x0ef7002b, 0x0ef7002a, 0x0ef70029, 2465 0x0ef7002d, 0x0ef7002b, 0x0ef7002a, 0x0ef70029,
@@ -2494,7 +2494,7 @@ const u32 txpwrctrl_tx_gain_ipa_rev6[] = {
2494 0x00f70028, 0x00f70027, 0x00f70026, 0x00f70025, 2494 0x00f70028, 0x00f70027, 0x00f70026, 0x00f70025,
2495}; 2495};
2496 2496
2497const u32 txpwrctrl_tx_gain_ipa_5g[] = { 2497static const u32 txpwrctrl_tx_gain_ipa_5g[] = {
2498 0x7ff70035, 0x7ff70033, 0x7ff70032, 0x7ff70031, 2498 0x7ff70035, 0x7ff70033, 0x7ff70032, 0x7ff70031,
2499 0x7ff7002f, 0x7ff7002e, 0x7ff7002d, 0x7ff7002b, 2499 0x7ff7002f, 0x7ff7002e, 0x7ff7002d, 0x7ff7002b,
2500 0x7ff7002a, 0x7ff70029, 0x7ff70028, 0x7ff70027, 2500 0x7ff7002a, 0x7ff70029, 0x7ff70028, 0x7ff70027,
@@ -3126,6 +3126,53 @@ void b43_nphy_rev3plus_tables_init(struct b43_wldev *dev)
3126 B43_WARN_ON(1); 3126 B43_WARN_ON(1);
3127} 3127}
3128 3128
3129/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/GetIpaGainTbl */
3130static const u32 *b43_nphy_get_ipa_gain_table(struct b43_wldev *dev)
3131{
3132 if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) {
3133 if (dev->phy.rev >= 6) {
3134 if (dev->dev->chip_id == 47162)
3135 return txpwrctrl_tx_gain_ipa_rev5;
3136 return txpwrctrl_tx_gain_ipa_rev6;
3137 } else if (dev->phy.rev >= 5) {
3138 return txpwrctrl_tx_gain_ipa_rev5;
3139 } else {
3140 return txpwrctrl_tx_gain_ipa;
3141 }
3142 } else {
3143 return txpwrctrl_tx_gain_ipa_5g;
3144 }
3145}
3146
3147const u32 *b43_nphy_get_tx_gain_table(struct b43_wldev *dev)
3148{
3149 enum ieee80211_band band = b43_current_band(dev->wl);
3150 struct ssb_sprom *sprom = dev->dev->bus_sprom;
3151
3152 if (dev->phy.rev < 3)
3153 return b43_ntab_tx_gain_rev0_1_2;
3154
3155 /* rev 3+ */
3156 if ((dev->phy.n->ipa2g_on && band == IEEE80211_BAND_2GHZ) ||
3157 (dev->phy.n->ipa5g_on && band == IEEE80211_BAND_5GHZ)) {
3158 return b43_nphy_get_ipa_gain_table(dev);
3159 } else if (b43_current_band(dev->wl) == IEEE80211_BAND_5GHZ) {
3160 if (dev->phy.rev == 3)
3161 return b43_ntab_tx_gain_rev3_5ghz;
3162 if (dev->phy.rev == 4)
3163 return sprom->fem.ghz5.extpa_gain == 3 ?
3164 b43_ntab_tx_gain_rev4_5ghz :
3165 b43_ntab_tx_gain_rev4_5ghz; /* FIXME */
3166 else
3167 return b43_ntab_tx_gain_rev5plus_5ghz;
3168 } else {
3169 if (dev->phy.rev >= 5 && sprom->fem.ghz5.extpa_gain == 3)
3170 return b43_ntab_tx_gain_rev3plus_2ghz; /* FIXME */
3171 else
3172 return b43_ntab_tx_gain_rev3plus_2ghz;
3173 }
3174}
3175
3129struct nphy_gain_ctl_workaround_entry *b43_nphy_get_gain_ctl_workaround_ent( 3176struct nphy_gain_ctl_workaround_entry *b43_nphy_get_gain_ctl_workaround_ent(
3130 struct b43_wldev *dev, bool ghz5, bool ext_lna) 3177 struct b43_wldev *dev, bool ghz5, bool ext_lna)
3131{ 3178{
diff --git a/drivers/net/wireless/b43/tables_nphy.h b/drivers/net/wireless/b43/tables_nphy.h
index 97038c481930..2a9d5f14af9c 100644
--- a/drivers/net/wireless/b43/tables_nphy.h
+++ b/drivers/net/wireless/b43/tables_nphy.h
@@ -177,16 +177,8 @@ void b43_ntab_write_bulk(struct b43_wldev *dev, u32 offset,
177void b43_nphy_rev0_1_2_tables_init(struct b43_wldev *dev); 177void b43_nphy_rev0_1_2_tables_init(struct b43_wldev *dev);
178void b43_nphy_rev3plus_tables_init(struct b43_wldev *dev); 178void b43_nphy_rev3plus_tables_init(struct b43_wldev *dev);
179 179
180extern const u32 b43_ntab_tx_gain_rev0_1_2[]; 180const u32 *b43_nphy_get_tx_gain_table(struct b43_wldev *dev);
181extern const u32 b43_ntab_tx_gain_rev3plus_2ghz[]; 181
182extern const u32 b43_ntab_tx_gain_rev3_5ghz[];
183extern const u32 b43_ntab_tx_gain_rev4_5ghz[];
184extern const u32 b43_ntab_tx_gain_rev5plus_5ghz[];
185
186extern const u32 txpwrctrl_tx_gain_ipa[];
187extern const u32 txpwrctrl_tx_gain_ipa_rev5[];
188extern const u32 txpwrctrl_tx_gain_ipa_rev6[];
189extern const u32 txpwrctrl_tx_gain_ipa_5g[];
190extern const u16 tbl_iqcal_gainparams[2][9][8]; 182extern const u16 tbl_iqcal_gainparams[2][9][8];
191extern const struct nphy_txiqcal_ladder ladder_lo[]; 183extern const struct nphy_txiqcal_ladder ladder_lo[];
192extern const struct nphy_txiqcal_ladder ladder_iq[]; 184extern const struct nphy_txiqcal_ladder ladder_iq[];