2012-01-28 04:08:49 +08:00
|
|
|
From 4f214b1ead0af7439921637645cb63f378516175 Mon Sep 17 00:00:00 2001
|
2012-01-22 06:39:20 +08:00
|
|
|
From: Hauke Mehrtens <hauke@hauke-m.de>
|
|
|
|
Date: Sat, 21 Jan 2012 18:48:38 +0100
|
|
|
|
Subject: [PATCH 33/34] b43: add workaround for b43 on pcie bus of bcm4716.
|
|
|
|
|
|
|
|
bcm4716 (which includes 4717 & 4718), plus 4706 on PCIe can reorder
|
|
|
|
transactions. As a fix, a read after write is performed on certain
|
|
|
|
places in the code. Older chips and the newer 5357 family don't require
|
|
|
|
this fix.
|
|
|
|
This code is based on the brcmsmac driver.
|
|
|
|
|
|
|
|
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
|
|
|
|
---
|
2012-01-28 04:08:49 +08:00
|
|
|
drivers/net/wireless/b43/b43.h | 26 ++++++++++++++++++++++++++
|
2012-01-22 06:39:20 +08:00
|
|
|
drivers/net/wireless/b43/bus.h | 10 ++++++++++
|
|
|
|
drivers/net/wireless/b43/phy_common.c | 6 ++++++
|
|
|
|
drivers/net/wireless/b43/phy_n.c | 10 +++++-----
|
2012-01-28 04:08:49 +08:00
|
|
|
4 files changed, 47 insertions(+), 5 deletions(-)
|
2012-01-22 06:39:20 +08:00
|
|
|
|
|
|
|
--- a/drivers/net/wireless/b43/b43.h
|
|
|
|
+++ b/drivers/net/wireless/b43/b43.h
|
2014-05-20 17:35:17 +08:00
|
|
|
@@ -1054,6 +1054,31 @@ static inline bool b43_using_pio_transfe
|
2012-01-22 06:39:20 +08:00
|
|
|
return dev->__using_pio_transfers;
|
|
|
|
}
|
|
|
|
|
|
|
|
+/*
|
|
|
|
+ * bcm4716 (which includes 4717 & 4718), plus 4706 on PCIe can reorder
|
|
|
|
+ * transactions. As a fix, a read after write is performed on certain places
|
|
|
|
+ * in the code. Older chips and the newer 5357 family don't require this fix.
|
|
|
|
+ */
|
2012-01-28 04:08:49 +08:00
|
|
|
+#ifdef CONFIG_BCM47XX_BCMA
|
2012-01-22 06:39:20 +08:00
|
|
|
+#include <asm/mach-bcm47xx/bcm47xx.h>
|
|
|
|
+static inline void b43_wflush16(struct b43_wldev *dev, u16 offset, u16 value)
|
|
|
|
+{
|
|
|
|
+ if (b43_bus_host_is_pci(dev->dev) &&
|
2012-01-28 04:08:49 +08:00
|
|
|
+ bcm47xx_bus_type == BCM47XX_BUS_TYPE_BCMA &&
|
2013-12-02 01:23:19 +08:00
|
|
|
+ bcm47xx_bus.bcma.bus.chipinfo.id == BCMA_CHIP_ID_BCM4716) {
|
2012-01-22 06:39:20 +08:00
|
|
|
+ b43_write16(dev, offset, value);
|
|
|
|
+ b43_read16(dev, offset);
|
|
|
|
+ } else {
|
|
|
|
+ b43_write16(dev, offset, value);
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+#else
|
|
|
|
+static inline void b43_wflush16(struct b43_wldev *dev, u16 offset, u16 value)
|
|
|
|
+{
|
|
|
|
+ b43_write16(dev, offset, value);
|
|
|
|
+}
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
/* Message printing */
|
|
|
|
__printf(2, 3) void b43info(struct b43_wl *wl, const char *fmt, ...);
|
|
|
|
__printf(2, 3) void b43err(struct b43_wl *wl, const char *fmt, ...);
|
|
|
|
--- a/drivers/net/wireless/b43/bus.h
|
|
|
|
+++ b/drivers/net/wireless/b43/bus.h
|
2014-05-20 17:35:17 +08:00
|
|
|
@@ -70,6 +70,16 @@ static inline bool b43_bus_host_is_sdio(
|
|
|
|
return false;
|
|
|
|
#endif
|
2012-01-22 06:39:20 +08:00
|
|
|
}
|
|
|
|
+static inline bool b43_bus_host_is_pci(struct b43_bus_dev *dev)
|
|
|
|
+{
|
|
|
|
+ if (dev->bus_type == B43_BUS_SSB)
|
|
|
|
+ return (dev->sdev->bus->bustype == SSB_BUSTYPE_PCI);
|
2013-10-14 04:25:12 +08:00
|
|
|
+#ifdef CPTCFG_B43_BCMA
|
2012-01-22 06:39:20 +08:00
|
|
|
+ if (dev->bus_type == B43_BUS_BCMA)
|
|
|
|
+ return (dev->bdev->bus->hosttype == BCMA_HOSTTYPE_PCI);
|
|
|
|
+#endif
|
|
|
|
+ return false;
|
|
|
|
+}
|
|
|
|
|
|
|
|
struct b43_bus_dev *b43_bus_dev_bcma_init(struct bcma_device *core);
|
|
|
|
struct b43_bus_dev *b43_bus_dev_ssb_init(struct ssb_device *sdev);
|
2013-12-02 01:23:19 +08:00
|
|
|
--- a/drivers/net/wireless/b43/main.c
|
|
|
|
+++ b/drivers/net/wireless/b43/main.c
|
2014-05-20 17:35:17 +08:00
|
|
|
@@ -4370,7 +4370,7 @@ static int b43_phy_versioning(struct b43
|
2013-12-02 01:23:19 +08:00
|
|
|
u16 radio24[3];
|
|
|
|
|
|
|
|
for (tmp = 0; tmp < 3; tmp++) {
|
|
|
|
- b43_write16(dev, B43_MMIO_RADIO24_CONTROL, tmp);
|
|
|
|
+ b43_wflush16(dev, B43_MMIO_RADIO24_CONTROL, tmp);
|
|
|
|
radio24[tmp] = b43_read16(dev, B43_MMIO_RADIO24_DATA);
|
|
|
|
}
|
|
|
|
|
2014-05-20 17:35:17 +08:00
|
|
|
@@ -4389,10 +4389,10 @@ static int b43_phy_versioning(struct b43
|
2013-12-02 01:23:19 +08:00
|
|
|
else
|
|
|
|
tmp = 0x5205017F;
|
|
|
|
} else {
|
|
|
|
- b43_write16(dev, B43_MMIO_RADIO_CONTROL,
|
|
|
|
+ b43_wflush16(dev, B43_MMIO_RADIO_CONTROL,
|
|
|
|
B43_RADIOCTL_ID);
|
|
|
|
tmp = b43_read16(dev, B43_MMIO_RADIO_DATA_LOW);
|
|
|
|
- b43_write16(dev, B43_MMIO_RADIO_CONTROL,
|
|
|
|
+ b43_wflush16(dev, B43_MMIO_RADIO_CONTROL,
|
|
|
|
B43_RADIOCTL_ID);
|
|
|
|
tmp |= (u32)b43_read16(dev, B43_MMIO_RADIO_DATA_HIGH)
|
|
|
|
<< 16;
|
2012-01-22 06:39:20 +08:00
|
|
|
--- a/drivers/net/wireless/b43/phy_common.c
|
|
|
|
+++ b/drivers/net/wireless/b43/phy_common.c
|
2014-05-20 17:35:17 +08:00
|
|
|
@@ -267,6 +267,12 @@ void b43_phy_write(struct b43_wldev *dev
|
2012-01-22 06:39:20 +08:00
|
|
|
{
|
|
|
|
assert_mac_suspended(dev);
|
|
|
|
dev->phy.ops->phy_write(dev, reg, value);
|
|
|
|
+#ifdef CONFIG_BCM47XX
|
|
|
|
+ if (b43_bus_host_is_pci(dev->dev) && reg == 0x72) {
|
|
|
|
+ b43_read16(dev, B43_MMIO_PHY_VER);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+#endif
|
|
|
|
if (++dev->phy.writes_counter == B43_MAX_WRITES_IN_ROW) {
|
|
|
|
b43_read16(dev, B43_MMIO_PHY_VER);
|
|
|
|
dev->phy.writes_counter = 0;
|
2013-12-02 01:23:19 +08:00
|
|
|
--- a/drivers/net/wireless/b43/phy_ht.c
|
|
|
|
+++ b/drivers/net/wireless/b43/phy_ht.c
|
|
|
|
@@ -1073,20 +1073,20 @@ static unsigned int b43_phy_ht_op_get_de
|
|
|
|
|
|
|
|
static u16 b43_phy_ht_op_read(struct b43_wldev *dev, u16 reg)
|
|
|
|
{
|
|
|
|
- b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
|
|
|
|
+ b43_wflush16(dev, B43_MMIO_PHY_CONTROL, reg);
|
|
|
|
return b43_read16(dev, B43_MMIO_PHY_DATA);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void b43_phy_ht_op_write(struct b43_wldev *dev, u16 reg, u16 value)
|
|
|
|
{
|
|
|
|
- b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
|
|
|
|
+ b43_wflush16(dev, B43_MMIO_PHY_CONTROL, reg);
|
|
|
|
b43_write16(dev, B43_MMIO_PHY_DATA, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void b43_phy_ht_op_maskset(struct b43_wldev *dev, u16 reg, u16 mask,
|
|
|
|
u16 set)
|
|
|
|
{
|
|
|
|
- b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
|
|
|
|
+ b43_wflush16(dev, B43_MMIO_PHY_CONTROL, reg);
|
|
|
|
b43_write16(dev, B43_MMIO_PHY_DATA,
|
|
|
|
(b43_read16(dev, B43_MMIO_PHY_DATA) & mask) | set);
|
|
|
|
}
|
|
|
|
@@ -1096,14 +1096,14 @@ static u16 b43_phy_ht_op_radio_read(stru
|
|
|
|
/* HT-PHY needs 0x200 for read access */
|
|
|
|
reg |= 0x200;
|
|
|
|
|
|
|
|
- b43_write16(dev, B43_MMIO_RADIO24_CONTROL, reg);
|
|
|
|
+ b43_wflush16(dev, B43_MMIO_RADIO24_CONTROL, reg);
|
|
|
|
return b43_read16(dev, B43_MMIO_RADIO24_DATA);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void b43_phy_ht_op_radio_write(struct b43_wldev *dev, u16 reg,
|
|
|
|
u16 value)
|
|
|
|
{
|
|
|
|
- b43_write16(dev, B43_MMIO_RADIO24_CONTROL, reg);
|
|
|
|
+ b43_wflush16(dev, B43_MMIO_RADIO24_CONTROL, reg);
|
|
|
|
b43_write16(dev, B43_MMIO_RADIO24_DATA, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
--- a/drivers/net/wireless/b43/phy_lcn.c
|
|
|
|
+++ b/drivers/net/wireless/b43/phy_lcn.c
|
|
|
|
@@ -845,20 +845,20 @@ static void b43_phy_lcn_op_adjust_txpowe
|
|
|
|
|
|
|
|
static u16 b43_phy_lcn_op_read(struct b43_wldev *dev, u16 reg)
|
|
|
|
{
|
|
|
|
- b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
|
|
|
|
+ b43_wflush16(dev, B43_MMIO_PHY_CONTROL, reg);
|
|
|
|
return b43_read16(dev, B43_MMIO_PHY_DATA);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void b43_phy_lcn_op_write(struct b43_wldev *dev, u16 reg, u16 value)
|
|
|
|
{
|
|
|
|
- b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
|
|
|
|
+ b43_wflush16(dev, B43_MMIO_PHY_CONTROL, reg);
|
|
|
|
b43_write16(dev, B43_MMIO_PHY_DATA, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void b43_phy_lcn_op_maskset(struct b43_wldev *dev, u16 reg, u16 mask,
|
|
|
|
u16 set)
|
|
|
|
{
|
|
|
|
- b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
|
|
|
|
+ b43_wflush16(dev, B43_MMIO_PHY_CONTROL, reg);
|
|
|
|
b43_write16(dev, B43_MMIO_PHY_DATA,
|
|
|
|
(b43_read16(dev, B43_MMIO_PHY_DATA) & mask) | set);
|
|
|
|
}
|
|
|
|
@@ -868,14 +868,14 @@ static u16 b43_phy_lcn_op_radio_read(str
|
|
|
|
/* LCN-PHY needs 0x200 for read access */
|
|
|
|
reg |= 0x200;
|
|
|
|
|
|
|
|
- b43_write16(dev, B43_MMIO_RADIO24_CONTROL, reg);
|
|
|
|
+ b43_wflush16(dev, B43_MMIO_RADIO24_CONTROL, reg);
|
|
|
|
return b43_read16(dev, B43_MMIO_RADIO24_DATA);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void b43_phy_lcn_op_radio_write(struct b43_wldev *dev, u16 reg,
|
|
|
|
u16 value)
|
|
|
|
{
|
|
|
|
- b43_write16(dev, B43_MMIO_RADIO24_CONTROL, reg);
|
|
|
|
+ b43_wflush16(dev, B43_MMIO_RADIO24_CONTROL, reg);
|
|
|
|
b43_write16(dev, B43_MMIO_RADIO24_DATA, value);
|
|
|
|
}
|
|
|
|
|
2012-01-22 06:39:20 +08:00
|
|
|
--- a/drivers/net/wireless/b43/phy_n.c
|
|
|
|
+++ b/drivers/net/wireless/b43/phy_n.c
|
2014-05-20 17:35:17 +08:00
|
|
|
@@ -5641,14 +5641,14 @@ static inline void check_phyreg(struct b
|
2012-01-22 06:39:20 +08:00
|
|
|
static u16 b43_nphy_op_read(struct b43_wldev *dev, u16 reg)
|
|
|
|
{
|
|
|
|
check_phyreg(dev, reg);
|
|
|
|
- b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
|
|
|
|
+ b43_wflush16(dev, B43_MMIO_PHY_CONTROL, reg);
|
|
|
|
return b43_read16(dev, B43_MMIO_PHY_DATA);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void b43_nphy_op_write(struct b43_wldev *dev, u16 reg, u16 value)
|
|
|
|
{
|
|
|
|
check_phyreg(dev, reg);
|
|
|
|
- b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
|
|
|
|
+ b43_wflush16(dev, B43_MMIO_PHY_CONTROL, reg);
|
|
|
|
b43_write16(dev, B43_MMIO_PHY_DATA, value);
|
|
|
|
}
|
|
|
|
|
2014-05-20 17:35:17 +08:00
|
|
|
@@ -5656,7 +5656,7 @@ static void b43_nphy_op_maskset(struct b
|
2012-01-22 06:39:20 +08:00
|
|
|
u16 set)
|
|
|
|
{
|
|
|
|
check_phyreg(dev, reg);
|
|
|
|
- b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
|
|
|
|
+ b43_wflush16(dev, B43_MMIO_PHY_CONTROL, reg);
|
2012-02-07 19:28:11 +08:00
|
|
|
b43_maskset16(dev, B43_MMIO_PHY_DATA, mask, set);
|
2012-01-22 06:39:20 +08:00
|
|
|
}
|
2012-02-07 19:28:11 +08:00
|
|
|
|
2014-05-20 17:35:17 +08:00
|
|
|
@@ -5670,7 +5670,7 @@ static u16 b43_nphy_op_radio_read(struct
|
|
|
|
else
|
|
|
|
reg |= 0x100;
|
2012-01-22 06:39:20 +08:00
|
|
|
|
|
|
|
- b43_write16(dev, B43_MMIO_RADIO_CONTROL, reg);
|
|
|
|
+ b43_wflush16(dev, B43_MMIO_RADIO_CONTROL, reg);
|
|
|
|
return b43_read16(dev, B43_MMIO_RADIO_DATA_LOW);
|
|
|
|
}
|
|
|
|
|
2014-05-20 17:35:17 +08:00
|
|
|
@@ -5679,7 +5679,7 @@ static void b43_nphy_op_radio_write(stru
|
2012-01-22 06:39:20 +08:00
|
|
|
/* Register 1 is a 32-bit register. */
|
|
|
|
B43_WARN_ON(reg == 1);
|
|
|
|
|
|
|
|
- b43_write16(dev, B43_MMIO_RADIO_CONTROL, reg);
|
|
|
|
+ b43_wflush16(dev, B43_MMIO_RADIO_CONTROL, reg);
|
|
|
|
b43_write16(dev, B43_MMIO_RADIO_DATA_LOW, value);
|
|
|
|
}
|
|
|
|
|