提交 7797aa38 编写于 作者: L Larry Finger 提交者: David S. Miller

b43legacy: Convert to use of the new SPROM structure

The b43legacy driver is modified to use the new SPROM structure.
Signed-off-by: NLarry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: NJohn W. Linville <linville@tuxdriver.com>
上级 95de2841
...@@ -189,10 +189,10 @@ void b43legacy_leds_init(struct b43legacy_wldev *dev) ...@@ -189,10 +189,10 @@ void b43legacy_leds_init(struct b43legacy_wldev *dev)
enum b43legacy_led_behaviour behaviour; enum b43legacy_led_behaviour behaviour;
bool activelow; bool activelow;
sprom[0] = bus->sprom.r1.gpio0; sprom[0] = bus->sprom.gpio0;
sprom[1] = bus->sprom.r1.gpio1; sprom[1] = bus->sprom.gpio1;
sprom[2] = bus->sprom.r1.gpio2; sprom[2] = bus->sprom.gpio2;
sprom[3] = bus->sprom.r1.gpio3; sprom[3] = bus->sprom.gpio3;
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
if (sprom[i] == 0xFF) { if (sprom[i] == 0xFF) {
......
...@@ -1745,7 +1745,7 @@ static int b43legacy_gpio_init(struct b43legacy_wldev *dev) ...@@ -1745,7 +1745,7 @@ static int b43legacy_gpio_init(struct b43legacy_wldev *dev)
mask |= 0x0060; mask |= 0x0060;
set |= 0x0060; set |= 0x0060;
} }
if (dev->dev->bus->sprom.r1.boardflags_lo & B43legacy_BFL_PACTRL) { if (dev->dev->bus->sprom.boardflags_lo & B43legacy_BFL_PACTRL) {
b43legacy_write16(dev, B43legacy_MMIO_GPIO_MASK, b43legacy_write16(dev, B43legacy_MMIO_GPIO_MASK,
b43legacy_read16(dev, b43legacy_read16(dev,
B43legacy_MMIO_GPIO_MASK) B43legacy_MMIO_GPIO_MASK)
...@@ -2122,7 +2122,7 @@ static void b43legacy_periodic_every120sec(struct b43legacy_wldev *dev) ...@@ -2122,7 +2122,7 @@ static void b43legacy_periodic_every120sec(struct b43legacy_wldev *dev)
static void b43legacy_periodic_every60sec(struct b43legacy_wldev *dev) static void b43legacy_periodic_every60sec(struct b43legacy_wldev *dev)
{ {
b43legacy_phy_lo_mark_all_unused(dev); b43legacy_phy_lo_mark_all_unused(dev);
if (dev->dev->bus->sprom.r1.boardflags_lo & B43legacy_BFL_RSSI) { if (dev->dev->bus->sprom.boardflags_lo & B43legacy_BFL_RSSI) {
b43legacy_mac_suspend(dev); b43legacy_mac_suspend(dev);
b43legacy_calc_nrssi_slope(dev); b43legacy_calc_nrssi_slope(dev);
b43legacy_mac_enable(dev); b43legacy_mac_enable(dev);
...@@ -3064,7 +3064,7 @@ static int b43legacy_wireless_core_init(struct b43legacy_wldev *dev) ...@@ -3064,7 +3064,7 @@ static int b43legacy_wireless_core_init(struct b43legacy_wldev *dev)
hf |= B43legacy_HF_SYMW; hf |= B43legacy_HF_SYMW;
if (phy->rev == 1) if (phy->rev == 1)
hf |= B43legacy_HF_GDCW; hf |= B43legacy_HF_GDCW;
if (sprom->r1.boardflags_lo & B43legacy_BFL_PACTRL) if (sprom->boardflags_lo & B43legacy_BFL_PACTRL)
hf |= B43legacy_HF_OFDMPABOOST; hf |= B43legacy_HF_OFDMPABOOST;
} else if (phy->type == B43legacy_PHYTYPE_B) { } else if (phy->type == B43legacy_PHYTYPE_B) {
hf |= B43legacy_HF_SYMW; hf |= B43legacy_HF_SYMW;
...@@ -3556,12 +3556,12 @@ static void b43legacy_sprom_fixup(struct ssb_bus *bus) ...@@ -3556,12 +3556,12 @@ static void b43legacy_sprom_fixup(struct ssb_bus *bus)
if (bus->boardinfo.vendor == PCI_VENDOR_ID_APPLE && if (bus->boardinfo.vendor == PCI_VENDOR_ID_APPLE &&
bus->boardinfo.type == 0x4E && bus->boardinfo.type == 0x4E &&
bus->boardinfo.rev > 0x40) bus->boardinfo.rev > 0x40)
bus->sprom.r1.boardflags_lo |= B43legacy_BFL_PACTRL; bus->sprom.boardflags_lo |= B43legacy_BFL_PACTRL;
/* Convert Antennagain values to Q5.2 */ /* Convert Antennagain values to Q5.2 */
if (bus->sprom.r1.antenna_gain_bg == 0xFF) if (bus->sprom.antenna_gain_bg == 0xFF)
bus->sprom.r1.antenna_gain_bg = 2; /* if unset, use 2 dBm */ bus->sprom.antenna_gain_bg = 2; /* if unset, use 2 dBm */
bus->sprom.r1.antenna_gain_bg <<= 2; bus->sprom.antenna_gain_bg <<= 2;
} }
static void b43legacy_wireless_exit(struct ssb_device *dev, static void b43legacy_wireless_exit(struct ssb_device *dev,
...@@ -3596,10 +3596,10 @@ static int b43legacy_wireless_init(struct ssb_device *dev) ...@@ -3596,10 +3596,10 @@ static int b43legacy_wireless_init(struct ssb_device *dev)
hw->max_noise = -110; hw->max_noise = -110;
hw->queues = 1; /* FIXME: hardware has more queues */ hw->queues = 1; /* FIXME: hardware has more queues */
SET_IEEE80211_DEV(hw, dev->dev); SET_IEEE80211_DEV(hw, dev->dev);
if (is_valid_ether_addr(sprom->r1.et1mac)) if (is_valid_ether_addr(sprom->et1mac))
SET_IEEE80211_PERM_ADDR(hw, sprom->r1.et1mac); SET_IEEE80211_PERM_ADDR(hw, sprom->et1mac);
else else
SET_IEEE80211_PERM_ADDR(hw, sprom->r1.il0mac); SET_IEEE80211_PERM_ADDR(hw, sprom->il0mac);
/* Get and initialize struct b43legacy_wl */ /* Get and initialize struct b43legacy_wl */
wl = hw_to_b43legacy_wl(hw); wl = hw_to_b43legacy_wl(hw);
......
...@@ -441,7 +441,7 @@ static void b43legacy_phy_inita(struct b43legacy_wldev *dev) ...@@ -441,7 +441,7 @@ static void b43legacy_phy_inita(struct b43legacy_wldev *dev)
might_sleep(); might_sleep();
b43legacy_phy_setupg(dev); b43legacy_phy_setupg(dev);
if (dev->dev->bus->sprom.r1.boardflags_lo & B43legacy_BFL_PACTRL) if (dev->dev->bus->sprom.boardflags_lo & B43legacy_BFL_PACTRL)
b43legacy_phy_write(dev, 0x046E, 0x03CF); b43legacy_phy_write(dev, 0x046E, 0x03CF);
} }
...@@ -543,7 +543,7 @@ static void b43legacy_phy_initb4(struct b43legacy_wldev *dev) ...@@ -543,7 +543,7 @@ static void b43legacy_phy_initb4(struct b43legacy_wldev *dev)
if (phy->radio_ver == 0x2050) if (phy->radio_ver == 0x2050)
b43legacy_phy_write(dev, 0x002A, 0x88C2); b43legacy_phy_write(dev, 0x002A, 0x88C2);
b43legacy_radio_set_txpower_bg(dev, 0xFFFF, 0xFFFF, 0xFFFF); b43legacy_radio_set_txpower_bg(dev, 0xFFFF, 0xFFFF, 0xFFFF);
if (dev->dev->bus->sprom.r1.boardflags_lo & B43legacy_BFL_RSSI) { if (dev->dev->bus->sprom.boardflags_lo & B43legacy_BFL_RSSI) {
b43legacy_calc_nrssi_slope(dev); b43legacy_calc_nrssi_slope(dev);
b43legacy_calc_nrssi_threshold(dev); b43legacy_calc_nrssi_threshold(dev);
} }
...@@ -699,7 +699,7 @@ static void b43legacy_phy_initb6(struct b43legacy_wldev *dev) ...@@ -699,7 +699,7 @@ static void b43legacy_phy_initb6(struct b43legacy_wldev *dev)
b43legacy_radio_write16(dev, 0x005A, 0x0088); b43legacy_radio_write16(dev, 0x005A, 0x0088);
b43legacy_radio_write16(dev, 0x005B, 0x006B); b43legacy_radio_write16(dev, 0x005B, 0x006B);
b43legacy_radio_write16(dev, 0x005C, 0x000F); b43legacy_radio_write16(dev, 0x005C, 0x000F);
if (dev->dev->bus->sprom.r1.boardflags_lo & 0x8000) { if (dev->dev->bus->sprom.boardflags_lo & 0x8000) {
b43legacy_radio_write16(dev, 0x005D, 0x00FA); b43legacy_radio_write16(dev, 0x005D, 0x00FA);
b43legacy_radio_write16(dev, 0x005E, 0x00D8); b43legacy_radio_write16(dev, 0x005E, 0x00D8);
} else { } else {
...@@ -797,7 +797,7 @@ static void b43legacy_phy_initb6(struct b43legacy_wldev *dev) ...@@ -797,7 +797,7 @@ static void b43legacy_phy_initb6(struct b43legacy_wldev *dev)
b43legacy_phy_write(dev, 0x0062, 0x0007); b43legacy_phy_write(dev, 0x0062, 0x0007);
b43legacy_radio_init2050(dev); b43legacy_radio_init2050(dev);
b43legacy_phy_lo_g_measure(dev); b43legacy_phy_lo_g_measure(dev);
if (dev->dev->bus->sprom.r1.boardflags_lo & if (dev->dev->bus->sprom.boardflags_lo &
B43legacy_BFL_RSSI) { B43legacy_BFL_RSSI) {
b43legacy_calc_nrssi_slope(dev); b43legacy_calc_nrssi_slope(dev);
b43legacy_calc_nrssi_threshold(dev); b43legacy_calc_nrssi_threshold(dev);
...@@ -921,7 +921,7 @@ static void b43legacy_calc_loopback_gain(struct b43legacy_wldev *dev) ...@@ -921,7 +921,7 @@ static void b43legacy_calc_loopback_gain(struct b43legacy_wldev *dev)
b43legacy_phy_read(dev, 0x0811) | 0x0100); b43legacy_phy_read(dev, 0x0811) | 0x0100);
b43legacy_phy_write(dev, 0x0812, b43legacy_phy_write(dev, 0x0812,
b43legacy_phy_read(dev, 0x0812) & 0xCFFF); b43legacy_phy_read(dev, 0x0812) & 0xCFFF);
if (dev->dev->bus->sprom.r1.boardflags_lo & B43legacy_BFL_EXTLNA) { if (dev->dev->bus->sprom.boardflags_lo & B43legacy_BFL_EXTLNA) {
if (phy->rev >= 7) { if (phy->rev >= 7) {
b43legacy_phy_write(dev, 0x0811, b43legacy_phy_write(dev, 0x0811,
b43legacy_phy_read(dev, 0x0811) b43legacy_phy_read(dev, 0x0811)
...@@ -1072,7 +1072,7 @@ static void b43legacy_phy_initg(struct b43legacy_wldev *dev) ...@@ -1072,7 +1072,7 @@ static void b43legacy_phy_initg(struct b43legacy_wldev *dev)
b43legacy_phy_write(dev, 0x0036, b43legacy_phy_write(dev, 0x0036,
(b43legacy_phy_read(dev, 0x0036) (b43legacy_phy_read(dev, 0x0036)
& 0x0FFF) | (phy->txctl2 << 12)); & 0x0FFF) | (phy->txctl2 << 12));
if (dev->dev->bus->sprom.r1.boardflags_lo & if (dev->dev->bus->sprom.boardflags_lo &
B43legacy_BFL_PACTRL) B43legacy_BFL_PACTRL)
b43legacy_phy_write(dev, 0x002E, 0x8075); b43legacy_phy_write(dev, 0x002E, 0x8075);
else else
...@@ -1087,7 +1087,7 @@ static void b43legacy_phy_initg(struct b43legacy_wldev *dev) ...@@ -1087,7 +1087,7 @@ static void b43legacy_phy_initg(struct b43legacy_wldev *dev)
b43legacy_phy_write(dev, 0x080F, 0x8078); b43legacy_phy_write(dev, 0x080F, 0x8078);
} }
if (!(dev->dev->bus->sprom.r1.boardflags_lo & B43legacy_BFL_RSSI)) { if (!(dev->dev->bus->sprom.boardflags_lo & B43legacy_BFL_RSSI)) {
/* The specs state to update the NRSSI LT with /* The specs state to update the NRSSI LT with
* the value 0x7FFFFFFF here. I think that is some weird * the value 0x7FFFFFFF here. I think that is some weird
* compiler optimization in the original driver. * compiler optimization in the original driver.
...@@ -1838,9 +1838,9 @@ void b43legacy_phy_xmitpower(struct b43legacy_wldev *dev) ...@@ -1838,9 +1838,9 @@ void b43legacy_phy_xmitpower(struct b43legacy_wldev *dev)
estimated_pwr = b43legacy_phy_estimate_power_out(dev, average); estimated_pwr = b43legacy_phy_estimate_power_out(dev, average);
max_pwr = dev->dev->bus->sprom.r1.maxpwr_bg; max_pwr = dev->dev->bus->sprom.maxpwr_bg;
if ((dev->dev->bus->sprom.r1.boardflags_lo if ((dev->dev->bus->sprom.boardflags_lo
& B43legacy_BFL_PACTRL) && & B43legacy_BFL_PACTRL) &&
(phy->type == B43legacy_PHYTYPE_G)) (phy->type == B43legacy_PHYTYPE_G))
max_pwr -= 0x3; max_pwr -= 0x3;
...@@ -1848,7 +1848,7 @@ void b43legacy_phy_xmitpower(struct b43legacy_wldev *dev) ...@@ -1848,7 +1848,7 @@ void b43legacy_phy_xmitpower(struct b43legacy_wldev *dev)
b43legacywarn(dev->wl, "Invalid max-TX-power value in SPROM." b43legacywarn(dev->wl, "Invalid max-TX-power value in SPROM."
"\n"); "\n");
max_pwr = 74; /* fake it */ max_pwr = 74; /* fake it */
dev->dev->bus->sprom.r1.maxpwr_bg = max_pwr; dev->dev->bus->sprom.maxpwr_bg = max_pwr;
} }
/* Use regulatory information to get the maximum power. /* Use regulatory information to get the maximum power.
...@@ -1858,7 +1858,8 @@ void b43legacy_phy_xmitpower(struct b43legacy_wldev *dev) ...@@ -1858,7 +1858,8 @@ void b43legacy_phy_xmitpower(struct b43legacy_wldev *dev)
* and 1.5 dBm (a safety factor??). The result is in Q5.2 format * and 1.5 dBm (a safety factor??). The result is in Q5.2 format
* which accounts for the factor of 4 */ * which accounts for the factor of 4 */
#define REG_MAX_PWR 20 #define REG_MAX_PWR 20
max_pwr = min(REG_MAX_PWR * 4 - dev->dev->bus->sprom.r1.antenna_gain_bg max_pwr = min(REG_MAX_PWR * 4
- dev->dev->bus->sprom.antenna_gain_bg
- 0x6, max_pwr); - 0x6, max_pwr);
/* find the desired power in Q5.2 - power_level is in dBm /* find the desired power in Q5.2 - power_level is in dBm
...@@ -1918,7 +1919,7 @@ void b43legacy_phy_xmitpower(struct b43legacy_wldev *dev) ...@@ -1918,7 +1919,7 @@ void b43legacy_phy_xmitpower(struct b43legacy_wldev *dev)
txpower = 3; txpower = 3;
radio_attenuation += 2; radio_attenuation += 2;
baseband_attenuation += 2; baseband_attenuation += 2;
} else if (dev->dev->bus->sprom.r1.boardflags_lo } else if (dev->dev->bus->sprom.boardflags_lo
& B43legacy_BFL_PACTRL) { & B43legacy_BFL_PACTRL) {
baseband_attenuation += 4 * baseband_attenuation += 4 *
(radio_attenuation - 2); (radio_attenuation - 2);
...@@ -2000,9 +2001,9 @@ int b43legacy_phy_init_tssi2dbm_table(struct b43legacy_wldev *dev) ...@@ -2000,9 +2001,9 @@ int b43legacy_phy_init_tssi2dbm_table(struct b43legacy_wldev *dev)
B43legacy_WARN_ON(!(phy->type == B43legacy_PHYTYPE_B || B43legacy_WARN_ON(!(phy->type == B43legacy_PHYTYPE_B ||
phy->type == B43legacy_PHYTYPE_G)); phy->type == B43legacy_PHYTYPE_G));
pab0 = (s16)(dev->dev->bus->sprom.r1.pa0b0); pab0 = (s16)(dev->dev->bus->sprom.pa0b0);
pab1 = (s16)(dev->dev->bus->sprom.r1.pa0b1); pab1 = (s16)(dev->dev->bus->sprom.pa0b1);
pab2 = (s16)(dev->dev->bus->sprom.r1.pa0b2); pab2 = (s16)(dev->dev->bus->sprom.pa0b2);
if ((dev->dev->bus->chip_id == 0x4301) && (phy->radio_ver != 0x2050)) { if ((dev->dev->bus->chip_id == 0x4301) && (phy->radio_ver != 0x2050)) {
phy->idle_tssi = 0x34; phy->idle_tssi = 0x34;
...@@ -2013,9 +2014,10 @@ int b43legacy_phy_init_tssi2dbm_table(struct b43legacy_wldev *dev) ...@@ -2013,9 +2014,10 @@ int b43legacy_phy_init_tssi2dbm_table(struct b43legacy_wldev *dev)
if (pab0 != 0 && pab1 != 0 && pab2 != 0 && if (pab0 != 0 && pab1 != 0 && pab2 != 0 &&
pab0 != -1 && pab1 != -1 && pab2 != -1) { pab0 != -1 && pab1 != -1 && pab2 != -1) {
/* The pabX values are set in SPROM. Use them. */ /* The pabX values are set in SPROM. Use them. */
if ((s8)dev->dev->bus->sprom.r1.itssi_bg != 0 && if ((s8)dev->dev->bus->sprom.itssi_bg != 0 &&
(s8)dev->dev->bus->sprom.r1.itssi_bg != -1) (s8)dev->dev->bus->sprom.itssi_bg != -1)
phy->idle_tssi = (s8)(dev->dev->bus->sprom.r1.itssi_bg); phy->idle_tssi = (s8)(dev->dev->bus->sprom.
itssi_bg);
else else
phy->idle_tssi = 62; phy->idle_tssi = 62;
dyn_tssi2dbm = kmalloc(64, GFP_KERNEL); dyn_tssi2dbm = kmalloc(64, GFP_KERNEL);
......
...@@ -827,7 +827,7 @@ void b43legacy_calc_nrssi_threshold(struct b43legacy_wldev *dev) ...@@ -827,7 +827,7 @@ void b43legacy_calc_nrssi_threshold(struct b43legacy_wldev *dev)
case B43legacy_PHYTYPE_B: { case B43legacy_PHYTYPE_B: {
if (phy->radio_ver != 0x2050) if (phy->radio_ver != 0x2050)
return; return;
if (!(dev->dev->bus->sprom.r1.boardflags_lo & if (!(dev->dev->bus->sprom.boardflags_lo &
B43legacy_BFL_RSSI)) B43legacy_BFL_RSSI))
return; return;
...@@ -857,7 +857,7 @@ void b43legacy_calc_nrssi_threshold(struct b43legacy_wldev *dev) ...@@ -857,7 +857,7 @@ void b43legacy_calc_nrssi_threshold(struct b43legacy_wldev *dev)
} }
case B43legacy_PHYTYPE_G: case B43legacy_PHYTYPE_G:
if (!phy->gmode || if (!phy->gmode ||
!(dev->dev->bus->sprom.r1.boardflags_lo & !(dev->dev->bus->sprom.boardflags_lo &
B43legacy_BFL_RSSI)) { B43legacy_BFL_RSSI)) {
tmp16 = b43legacy_nrssi_hw_read(dev, 0x20); tmp16 = b43legacy_nrssi_hw_read(dev, 0x20);
if (tmp16 >= 0x20) if (tmp16 >= 0x20)
...@@ -1406,7 +1406,7 @@ static u16 b43legacy_get_812_value(struct b43legacy_wldev *dev, u8 lpd) ...@@ -1406,7 +1406,7 @@ static u16 b43legacy_get_812_value(struct b43legacy_wldev *dev, u8 lpd)
if (!phy->gmode) if (!phy->gmode)
return 0; return 0;
if (!has_loopback_gain(phy)) { if (!has_loopback_gain(phy)) {
if (phy->rev < 7 || !(dev->dev->bus->sprom.r1.boardflags_lo if (phy->rev < 7 || !(dev->dev->bus->sprom.boardflags_lo
& B43legacy_BFL_EXTLNA)) { & B43legacy_BFL_EXTLNA)) {
switch (lpd) { switch (lpd) {
case LPD(0, 1, 1): case LPD(0, 1, 1):
...@@ -1459,7 +1459,7 @@ static u16 b43legacy_get_812_value(struct b43legacy_wldev *dev, u8 lpd) ...@@ -1459,7 +1459,7 @@ static u16 b43legacy_get_812_value(struct b43legacy_wldev *dev, u8 lpd)
} }
loop_or = (loop << 8) | extern_lna_control; loop_or = (loop << 8) | extern_lna_control;
if (phy->rev >= 7 && dev->dev->bus->sprom.r1.boardflags_lo if (phy->rev >= 7 && dev->dev->bus->sprom.boardflags_lo
& B43legacy_BFL_EXTLNA) { & B43legacy_BFL_EXTLNA) {
if (extern_lna_control) if (extern_lna_control)
loop_or |= 0x8000; loop_or |= 0x8000;
...@@ -1550,7 +1550,7 @@ u16 b43legacy_radio_init2050(struct b43legacy_wldev *dev) ...@@ -1550,7 +1550,7 @@ u16 b43legacy_radio_init2050(struct b43legacy_wldev *dev)
b43legacy_get_812_value(dev, b43legacy_get_812_value(dev,
LPD(0, 1, 1))); LPD(0, 1, 1)));
if (phy->rev < 7 || if (phy->rev < 7 ||
!(dev->dev->bus->sprom.r1.boardflags_lo !(dev->dev->bus->sprom.boardflags_lo
& B43legacy_BFL_EXTLNA)) & B43legacy_BFL_EXTLNA))
b43legacy_phy_write(dev, 0x0811, 0x01B3); b43legacy_phy_write(dev, 0x0811, 0x01B3);
else else
...@@ -1786,7 +1786,7 @@ int b43legacy_radio_selectchannel(struct b43legacy_wldev *dev, ...@@ -1786,7 +1786,7 @@ int b43legacy_radio_selectchannel(struct b43legacy_wldev *dev,
channel2freq_bg(channel)); channel2freq_bg(channel));
if (channel == 14) { if (channel == 14) {
if (dev->dev->bus->sprom.r1.country_code == 5) /* JAPAN) */ if (dev->dev->bus->sprom.country_code == 5) /* JAPAN) */
b43legacy_shm_write32(dev, B43legacy_SHM_SHARED, b43legacy_shm_write32(dev, B43legacy_SHM_SHARED,
B43legacy_UCODEFLAGS_OFFSET, B43legacy_UCODEFLAGS_OFFSET,
b43legacy_shm_read32(dev, b43legacy_shm_read32(dev,
......
...@@ -379,7 +379,7 @@ static s8 b43legacy_rssi_postprocess(struct b43legacy_wldev *dev, ...@@ -379,7 +379,7 @@ static s8 b43legacy_rssi_postprocess(struct b43legacy_wldev *dev,
else else
tmp -= 3; tmp -= 3;
} else { } else {
if (dev->dev->bus->sprom.r1.boardflags_lo if (dev->dev->bus->sprom.boardflags_lo
& B43legacy_BFL_RSSI) { & B43legacy_BFL_RSSI) {
if (in_rssi > 63) if (in_rssi > 63)
in_rssi = 63; in_rssi = 63;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册