b43: bus: abstract board info
authorRafał Miłecki <zajec5@gmail.com>
Wed, 18 May 2011 00:06:42 +0000 (02:06 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Wed, 1 Jun 2011 19:10:57 +0000 (15:10 -0400)
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/b43/bus.c
drivers/net/wireless/b43/bus.h
drivers/net/wireless/b43/leds.c
drivers/net/wireless/b43/phy_a.c
drivers/net/wireless/b43/phy_common.c
drivers/net/wireless/b43/phy_g.c
drivers/net/wireless/b43/phy_lp.c
drivers/net/wireless/b43/phy_n.c
drivers/net/wireless/b43/wa.c

index 8d0e7584eafd4ce7075d8a860dcf0b5dc0b8b289..f897b7054a0a02bd08fa9c1276121645c88cdfa4 100644 (file)
@@ -74,6 +74,10 @@ struct b43_bus_dev *b43_bus_dev_ssb_init(struct ssb_device *sdev)
        dev->dma_dev = sdev->dma_dev;
        dev->irq = sdev->irq;
 
+       dev->board_vendor = sdev->bus->boardinfo.vendor;
+       dev->board_type = sdev->bus->boardinfo.type;
+       dev->board_rev = sdev->bus->boardinfo.rev;
+
        dev->chip_id = sdev->bus->chip_id;
        dev->chip_rev = sdev->bus->chip_rev;
        dev->chip_pkg = sdev->bus->chip_package;
index 14942fb605d9c2464557347f2630c42f9ed57065..e88b4494beaaa169d21eabcc6b78c6a16bf5680b 100644 (file)
@@ -24,6 +24,10 @@ struct b43_bus_dev {
        struct device *dma_dev;
        unsigned int irq;
 
+       u16 board_vendor;
+       u16 board_type;
+       u16 board_rev;
+
        u16 chip_id;
        u8 chip_rev;
        u8 chip_pkg;
index 70bcf4276146482ad797dd6258e1d4929764ad96..b56ed41fc1bd31c55a7abc7b799b1d47bf97191a 100644 (file)
@@ -215,7 +215,6 @@ static void b43_led_get_sprominfo(struct b43_wldev *dev,
                                  enum b43_led_behaviour *behaviour,
                                  bool *activelow)
 {
-       struct ssb_bus *bus = dev->sdev->bus;
        u8 sprom[4];
 
        sprom[0] = dev->dev->bus_sprom->gpio0;
@@ -231,12 +230,12 @@ static void b43_led_get_sprominfo(struct b43_wldev *dev,
                case 0:
                        *behaviour = B43_LED_ACTIVITY;
                        *activelow = 1;
-                       if (bus->boardinfo.vendor == PCI_VENDOR_ID_COMPAQ)
+                       if (dev->dev->board_vendor == PCI_VENDOR_ID_COMPAQ)
                                *behaviour = B43_LED_RADIO_ALL;
                        break;
                case 1:
                        *behaviour = B43_LED_RADIO_B;
-                       if (bus->boardinfo.vendor == PCI_VENDOR_ID_ASUSTEK)
+                       if (dev->dev->board_vendor == PCI_VENDOR_ID_ASUSTEK)
                                *behaviour = B43_LED_ASSOC;
                        break;
                case 2:
index 821b516fe9e4baf909e90c5cad3ca966d740df7f..73ace5552bad42770fd8085aefaaf4601ee804a4 100644 (file)
@@ -265,7 +265,6 @@ static void hardware_pctl_init_aphy(struct b43_wldev *dev)
 
 void b43_phy_inita(struct b43_wldev *dev)
 {
-       struct ssb_bus *bus = dev->sdev->bus;
        struct b43_phy *phy = &dev->phy;
 
        /* This lowlevel A-PHY init is also called from G-PHY init.
@@ -296,9 +295,9 @@ void b43_phy_inita(struct b43_wldev *dev)
 
                b43_radio_init2060(dev);
 
-               if ((bus->boardinfo.vendor == SSB_BOARDVENDOR_BCM) &&
-                   ((bus->boardinfo.type == SSB_BOARD_BU4306) ||
-                    (bus->boardinfo.type == SSB_BOARD_BU4309))) {
+               if ((dev->dev->board_vendor == SSB_BOARDVENDOR_BCM) &&
+                   ((dev->dev->board_type == SSB_BOARD_BU4306) ||
+                    (dev->dev->board_type == SSB_BOARD_BU4309))) {
                        ; //TODO: A PHY LO
                }
 
index 3f7bdf84544658b9cc6d47cc2410b4a5ac35e149..425af28ea4e5dd445cbbcae917d1a6aab7ac814c 100644 (file)
@@ -368,8 +368,8 @@ void b43_phy_txpower_check(struct b43_wldev *dev, unsigned int flags)
        /* The next check will be needed in two seconds, or later. */
        phy->next_txpwr_check_time = round_jiffies(now + (HZ * 2));
 
-       if ((dev->sdev->bus->boardinfo.vendor == SSB_BOARDVENDOR_BCM) &&
-           (dev->sdev->bus->boardinfo.type == SSB_BOARD_BU4306))
+       if ((dev->dev->board_vendor == SSB_BOARDVENDOR_BCM) &&
+           (dev->dev->board_type == SSB_BOARD_BU4306))
                return; /* No software txpower adjustment needed */
 
        result = phy->ops->recalc_txpower(dev, !!(flags & B43_TXPWR_IGNORE_TSSI));
index 40ce9e6d104eb1c7d2306ff193831a76dc5c325b..684be1fd59ae247f882d1e8623b085c455625622 100644 (file)
@@ -1491,7 +1491,6 @@ static u16 b43_radio_init2050(struct b43_wldev *dev)
 
 static void b43_phy_initb5(struct b43_wldev *dev)
 {
-       struct ssb_bus *bus = dev->sdev->bus;
        struct b43_phy *phy = &dev->phy;
        struct b43_phy_g *gphy = phy->g;
        u16 offset, value;
@@ -1500,8 +1499,8 @@ static void b43_phy_initb5(struct b43_wldev *dev)
        if (phy->analog == 1) {
                b43_radio_set(dev, 0x007A, 0x0050);
        }
-       if ((bus->boardinfo.vendor != SSB_BOARDVENDOR_BCM) &&
-           (bus->boardinfo.type != SSB_BOARD_BU4306)) {
+       if ((dev->dev->board_vendor != SSB_BOARDVENDOR_BCM) &&
+           (dev->dev->board_type != SSB_BOARD_BU4306)) {
                value = 0x2120;
                for (offset = 0x00A8; offset < 0x00C7; offset++) {
                        b43_phy_write(dev, offset, value);
@@ -1922,7 +1921,6 @@ static void b43_hardware_pctl_init_gphy(struct b43_wldev *dev)
 /* Initialize B/G PHY power control */
 static void b43_phy_init_pctl(struct b43_wldev *dev)
 {
-       struct ssb_bus *bus = dev->sdev->bus;
        struct b43_phy *phy = &dev->phy;
        struct b43_phy_g *gphy = phy->g;
        struct b43_rfatt old_rfatt;
@@ -1931,8 +1929,8 @@ static void b43_phy_init_pctl(struct b43_wldev *dev)
 
        B43_WARN_ON(phy->type != B43_PHYTYPE_G);
 
-       if ((bus->boardinfo.vendor == SSB_BOARDVENDOR_BCM) &&
-           (bus->boardinfo.type == SSB_BOARD_BU4306))
+       if ((dev->dev->board_vendor == SSB_BOARDVENDOR_BCM) &&
+           (dev->dev->board_type == SSB_BOARD_BU4306))
                return;
 
        b43_phy_write(dev, 0x0028, 0x8018);
@@ -2136,17 +2134,17 @@ static void default_baseband_attenuation(struct b43_wldev *dev,
 static void default_radio_attenuation(struct b43_wldev *dev,
                                      struct b43_rfatt *rf)
 {
-       struct ssb_bus *bus = dev->sdev->bus;
+       struct b43_bus_dev *bdev = dev->dev;
        struct b43_phy *phy = &dev->phy;
 
        rf->with_padmix = 0;
 
-       if (bus->boardinfo.vendor == SSB_BOARDVENDOR_BCM &&
-           bus->boardinfo.type == SSB_BOARD_BCM4309G) {
-               if (bus->boardinfo.rev < 0x43) {
+       if (dev->dev->board_vendor == SSB_BOARDVENDOR_BCM &&
+           dev->dev->board_type == SSB_BOARD_BCM4309G) {
+               if (dev->dev->board_rev < 0x43) {
                        rf->att = 2;
                        return;
-               } else if (bus->boardinfo.rev < 0x51) {
+               } else if (dev->dev->board_rev < 0x51) {
                        rf->att = 3;
                        return;
                }
@@ -2172,21 +2170,21 @@ static void default_radio_attenuation(struct b43_wldev *dev,
                        return;
                case 1:
                        if (phy->type == B43_PHYTYPE_G) {
-                               if (bus->boardinfo.vendor == SSB_BOARDVENDOR_BCM
-                                   && bus->boardinfo.type == SSB_BOARD_BCM4309G
-                                   && bus->boardinfo.rev >= 30)
+                               if (bdev->board_vendor == SSB_BOARDVENDOR_BCM
+                                   && bdev->board_type == SSB_BOARD_BCM4309G
+                                   && bdev->board_rev >= 30)
                                        rf->att = 3;
-                               else if (bus->boardinfo.vendor ==
+                               else if (bdev->board_vendor ==
                                         SSB_BOARDVENDOR_BCM
-                                        && bus->boardinfo.type ==
+                                        && bdev->board_type ==
                                         SSB_BOARD_BU4306)
                                        rf->att = 3;
                                else
                                        rf->att = 1;
                        } else {
-                               if (bus->boardinfo.vendor == SSB_BOARDVENDOR_BCM
-                                   && bus->boardinfo.type == SSB_BOARD_BCM4309G
-                                   && bus->boardinfo.rev >= 30)
+                               if (bdev->board_vendor == SSB_BOARDVENDOR_BCM
+                                   && bdev->board_type == SSB_BOARD_BCM4309G
+                                   && bdev->board_rev >= 30)
                                        rf->att = 7;
                                else
                                        rf->att = 6;
@@ -2194,16 +2192,16 @@ static void default_radio_attenuation(struct b43_wldev *dev,
                        return;
                case 2:
                        if (phy->type == B43_PHYTYPE_G) {
-                               if (bus->boardinfo.vendor == SSB_BOARDVENDOR_BCM
-                                   && bus->boardinfo.type == SSB_BOARD_BCM4309G
-                                   && bus->boardinfo.rev >= 30)
+                               if (bdev->board_vendor == SSB_BOARDVENDOR_BCM
+                                   && bdev->board_type == SSB_BOARD_BCM4309G
+                                   && bdev->board_rev >= 30)
                                        rf->att = 3;
-                               else if (bus->boardinfo.vendor ==
+                               else if (bdev->board_vendor ==
                                         SSB_BOARDVENDOR_BCM
-                                        && bus->boardinfo.type ==
+                                        && bdev->board_type ==
                                         SSB_BOARD_BU4306)
                                        rf->att = 5;
-                               else if (dev->dev->chip_id == 0x4320)
+                               else if (bdev->chip_id == 0x4320)
                                        rf->att = 4;
                                else
                                        rf->att = 3;
index bb78be319bd30a2c057de7e38eb22aecd6798d0e..2606c25e574f591cccc716ea9f0a5d8959ca046b 100644 (file)
@@ -287,7 +287,7 @@ static void lpphy_baseband_rev0_1_init(struct b43_wldev *dev)
                b43_phy_maskset(dev, B43_LPPHY_TR_LOOKUP_8, 0xFFC0, 0x000A);
                b43_phy_maskset(dev, B43_LPPHY_TR_LOOKUP_8, 0xC0FF, 0x0B00);
        } else if (b43_current_band(dev->wl) == IEEE80211_BAND_5GHZ ||
-                 (bus->boardinfo.type == 0x048A) || ((dev->phy.rev == 0) &&
+                 (dev->dev->board_type == 0x048A) || ((dev->phy.rev == 0) &&
                  (sprom->boardflags_lo & B43_BFL_FEM))) {
                b43_phy_maskset(dev, B43_LPPHY_TR_LOOKUP_1, 0xFFC0, 0x0001);
                b43_phy_maskset(dev, B43_LPPHY_TR_LOOKUP_1, 0xC0FF, 0x0400);
@@ -413,7 +413,6 @@ static void lpphy_restore_dig_flt_state(struct b43_wldev *dev)
 
 static void lpphy_baseband_rev2plus_init(struct b43_wldev *dev)
 {
-       struct ssb_bus *bus = dev->sdev->bus;
        struct b43_phy_lp *lpphy = dev->phy.lp;
 
        b43_phy_write(dev, B43_LPPHY_AFE_DAC_CTL, 0x50);
@@ -433,7 +432,7 @@ static void lpphy_baseband_rev2plus_init(struct b43_wldev *dev)
        b43_phy_mask(dev, B43_LPPHY_CRSGAIN_CTL, ~0x4000);
        b43_phy_mask(dev, B43_LPPHY_CRSGAIN_CTL, ~0x2000);
        b43_phy_set(dev, B43_PHY_OFDM(0x10A), 0x1);
-       if (bus->boardinfo.rev >= 0x18) {
+       if (dev->dev->board_rev >= 0x18) {
                b43_lptab_write(dev, B43_LPTAB32(17, 65), 0xEC);
                b43_phy_maskset(dev, B43_PHY_OFDM(0x10A), 0xFF01, 0x14);
        } else {
index 46428ad5ab8428cc0fa4f857676ff505bbd1ed13..ad14f3b428c5882ad0de963396ffdcaa7d001744 100644 (file)
@@ -424,15 +424,14 @@ static void b43_radio_init2055_post(struct b43_wldev *dev)
 {
        struct b43_phy_n *nphy = dev->phy.n;
        struct ssb_sprom *sprom = dev->dev->bus_sprom;
-       struct ssb_boardinfo *binfo = &(dev->sdev->bus->boardinfo);
        int i;
        u16 val;
        bool workaround = false;
 
        if (sprom->revision < 4)
-               workaround = (binfo->vendor != PCI_VENDOR_ID_BROADCOM &&
-                               binfo->type == 0x46D &&
-                               binfo->rev >= 0x41);
+               workaround = (dev->dev->board_vendor != PCI_VENDOR_ID_BROADCOM
+                             && dev->dev->board_type == 0x46D
+                             && dev->dev->board_rev >= 0x41);
        else
                workaround =
                        !(sprom->boardflags2_lo & B43_BFL2_RXBB_INT_REG_DIS);
@@ -1373,7 +1372,6 @@ static void b43_nphy_gain_ctrl_workarounds(struct b43_wldev *dev)
 /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/Workarounds */
 static void b43_nphy_workarounds(struct b43_wldev *dev)
 {
-       struct ssb_bus *bus = dev->sdev->bus;
        struct ssb_sprom *sprom = dev->dev->bus_sprom;
        struct b43_phy *phy = &dev->phy;
        struct b43_phy_n *nphy = phy->n;
@@ -1505,7 +1503,7 @@ static void b43_nphy_workarounds(struct b43_wldev *dev)
                b43_phy_write(dev, B43_NPHY_RFCTL_LUT_TRSW_UP2, 0x301);
 
                if (sprom->boardflags2_lo & 0x100 &&
-                   bus->boardinfo.type == 0x8B) {
+                   dev->dev->board_type == 0x8B) {
                        delays1[0] = 0x1;
                        delays1[5] = 0x14;
                }
@@ -3587,7 +3585,6 @@ static void b43_nphy_set_rx_core_state(struct b43_wldev *dev, u8 mask)
  */
 int b43_phy_initn(struct b43_wldev *dev)
 {
-       struct ssb_bus *bus = dev->sdev->bus;
        struct ssb_sprom *sprom = dev->dev->bus_sprom;
        struct b43_phy *phy = &dev->phy;
        struct b43_phy_n *nphy = phy->n;
@@ -3642,8 +3639,8 @@ int b43_phy_initn(struct b43_wldev *dev)
        b43_phy_write(dev, B43_NPHY_AFESEQ_TX2RX_PUD_40M, 0x20);
 
        if (sprom->boardflags2_lo & 0x100 ||
-           (bus->boardinfo.vendor == PCI_VENDOR_ID_APPLE &&
-            bus->boardinfo.type == 0x8B))
+           (dev->dev->board_vendor == PCI_VENDOR_ID_APPLE &&
+            dev->dev->board_type == 0x8B))
                b43_phy_write(dev, B43_NPHY_TXREALFD, 0xA0);
        else
                b43_phy_write(dev, B43_NPHY_TXREALFD, 0xB8);
index 2829ee1872c9d1cbff71c8a857ded6dcd9acb401..5d00d0eaf2e7aee1d58bf83c4ad7669876e37397 100644 (file)
@@ -458,17 +458,15 @@ static void b43_wa_rssi_adc(struct b43_wldev *dev)
 
 static void b43_wa_boards_a(struct b43_wldev *dev)
 {
-       struct ssb_bus *bus = dev->sdev->bus;
-
-       if (bus->boardinfo.vendor == SSB_BOARDVENDOR_BCM &&
-           bus->boardinfo.type == SSB_BOARD_BU4306 &&
-           bus->boardinfo.rev < 0x30) {
+       if (dev->dev->board_vendor == SSB_BOARDVENDOR_BCM &&
+           dev->dev->board_type == SSB_BOARD_BU4306 &&
+           dev->dev->board_rev < 0x30) {
                b43_phy_write(dev, 0x0010, 0xE000);
                b43_phy_write(dev, 0x0013, 0x0140);
                b43_phy_write(dev, 0x0014, 0x0280);
        } else {
-               if (bus->boardinfo.type == SSB_BOARD_MP4318 &&
-                   bus->boardinfo.rev < 0x20) {
+               if (dev->dev->board_type == SSB_BOARD_MP4318 &&
+                   dev->dev->board_rev < 0x20) {
                        b43_phy_write(dev, 0x0013, 0x0210);
                        b43_phy_write(dev, 0x0014, 0x0840);
                } else {
@@ -486,13 +484,12 @@ static void b43_wa_boards_a(struct b43_wldev *dev)
 
 static void b43_wa_boards_g(struct b43_wldev *dev)
 {
-       struct ssb_bus *bus = dev->sdev->bus;
        struct ssb_sprom *sprom = dev->dev->bus_sprom;
        struct b43_phy *phy = &dev->phy;
 
-       if (bus->boardinfo.vendor != SSB_BOARDVENDOR_BCM ||
-           bus->boardinfo.type != SSB_BOARD_BU4306 ||
-           bus->boardinfo.rev != 0x17) {
+       if (dev->dev->board_vendor != SSB_BOARDVENDOR_BCM ||
+           dev->dev->board_type != SSB_BOARD_BU4306 ||
+           dev->dev->board_rev != 0x17) {
                if (phy->rev < 2) {
                        b43_ofdmtab_write16(dev, B43_OFDMTAB_GAINX_R1, 1, 0x0002);
                        b43_ofdmtab_write16(dev, B43_OFDMTAB_GAINX_R1, 2, 0x0001);