Skip to contentSkip to conversation

b43: first series for 3.18

PATCH New Rafał Miłecki 3 participants 15 messages Jul 31, 2014 – Aug 7, 2014 Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

cover b43: first series for 3.18

John, this patchset continues improvements for b43. It doesn't fix any particular bug/issue, so please queue it for 3.18. There is nothing important enough to risk breaking wireless-next for 3.17.

Rafa? Mi?ecki (7):
b43: update flushing many writes performed in a row
b43: don't duplicate common PHY read/write ops
b43: flush some writes on Broadcom MIPS SoCs
b43: N-PHY: update rev3+ gain control workarounds
b43: N-PHY: add RF power tables for radio 0x2057 revs 9 & 14
b43: implement PPR (Power Per Rate) management/API
b43: N-PHY: support setting custom TX power

 drivers/net/wireless/b43/Makefile      |   1 +
 drivers/net/wireless/b43/b43.h         |  16 +++
 drivers/net/wireless/b43/bus.h         |  14 +++
 drivers/net/wireless/b43/main.c        |  17 ++-
 drivers/net/wireless/b43/phy_a.c       |   4 +-
 drivers/net/wireless/b43/phy_common.c  |  25 ++++-
 drivers/net/wireless/b43/phy_g.c       |   8 +-
 drivers/net/wireless/b43/phy_ht.c      |  20 +---
 drivers/net/wireless/b43/phy_lcn.c     |  20 +---
 drivers/net/wireless/b43/phy_lp.c      |  20 +---
 drivers/net/wireless/b43/phy_n.c       | 128 +++++++++++++++------
 drivers/net/wireless/b43/phy_n.h       |   4 +
 drivers/net/wireless/b43/ppr.c         | 199 +++++++++++++++++++++++++++++++++
 drivers/net/wireless/b43/ppr.h         |  45 ++++++++
 drivers/net/wireless/b43/tables_nphy.c | 128 +++++++++++++++++----
 drivers/net/wireless/b43/tables_nphy.h |   2 +
 16 files changed, 523 insertions(+), 128 deletions(-)
 create mode 100644 drivers/net/wireless/b43/ppr.c
 create mode 100644 drivers/net/wireless/b43/ppr.h
Signature · 1 line
1.8.4.5
#1 lore raw

PATCH 1/7 b43: update flushing many writes performed in a row

Flush radio writes as well and add some tiny optimizations (e.g. masksetting PHY reg involves reading it, so reset the counter).

---
 drivers/net/wireless/b43/bus.h        | 14 ++++++++++++++
 drivers/net/wireless/b43/phy_common.c | 13 ++++++++++---
 drivers/net/wireless/b43/phy_n.c      |  1 +
 3 files changed, 25 insertions(+), 3 deletions(-)
drivers/net/wireless/b43/bus.h +14 -0
index f3205c6..460d9d9 100644
@@ -60,7 +60,21 @@ static inline bool b43_bus_host_is_pcmcia(struct b43_bus_dev *dev)
 #else
 	return false;
 #endif
+};
+
+static inline bool b43_bus_host_is_pci(struct b43_bus_dev *dev)
+{
+#ifdef CONFIG_B43_BCMA
+	if (dev->bus_type == B43_BUS_BCMA)
+		return (dev->bdev->bus->hosttype == BCMA_HOSTTYPE_PCI);
+#endif
+#ifdef CONFIG_B43_SSB
+	if (dev->bus_type == B43_BUS_SSB)
+		return (dev->sdev->bus->bustype == SSB_BUSTYPE_PCI);
+#endif
+	return false;
 }
+
 static inline bool b43_bus_host_is_sdio(struct b43_bus_dev *dev)
 {
 #ifdef CONFIG_B43_SSB
drivers/net/wireless/b43/phy_common.c +10 -3
index 3cbef21..c868748 100644
@@ -222,12 +222,18 @@ static inline void assert_mac_suspended(struct b43_wldev *dev)
 u16 b43_radio_read(struct b43_wldev *dev, u16 reg)
 {
 	assert_mac_suspended(dev);
+	dev->phy.writes_counter = 0;
 	return dev->phy.ops->radio_read(dev, reg);
 }
 
 void b43_radio_write(struct b43_wldev *dev, u16 reg, u16 value)
 {
 	assert_mac_suspended(dev);
+	if (b43_bus_host_is_pci(dev->dev) &&
+	    ++dev->phy.writes_counter > B43_MAX_WRITES_IN_ROW) {
+		b43_read32(dev, B43_MMIO_MACCTL);
+		dev->phy.writes_counter = 1;
+	}
 	dev->phy.ops->radio_write(dev, reg, value);
 }
 
@@ -274,11 +280,12 @@ u16 b43_phy_read(struct b43_wldev *dev, u16 reg)
 void b43_phy_write(struct b43_wldev *dev, u16 reg, u16 value)
 {
 	assert_mac_suspended(dev);
-	dev->phy.ops->phy_write(dev, reg, value);
-	if (++dev->phy.writes_counter == B43_MAX_WRITES_IN_ROW) {
+	if (b43_bus_host_is_pci(dev->dev) &&
+	    ++dev->phy.writes_counter > B43_MAX_WRITES_IN_ROW) {
 		b43_read16(dev, B43_MMIO_PHY_VER);
-		dev->phy.writes_counter = 0;
+		dev->phy.writes_counter = 1;
 	}
+	dev->phy.ops->phy_write(dev, reg, value);
 }
 
 void b43_phy_copy(struct b43_wldev *dev, u16 destreg, u16 srcreg)
drivers/net/wireless/b43/phy_n.c +1 -0
index e2a3f0d..b04aa34 100644
@@ -6517,6 +6517,7 @@ static void b43_nphy_op_maskset(struct b43_wldev *dev, u16 reg, u16 mask,
 	check_phyreg(dev, reg);
 	b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
 	b43_maskset16(dev, B43_MMIO_PHY_DATA, mask, set);
+	dev->phy.writes_counter = 1;
 }
 
 static u16 b43_nphy_op_radio_read(struct b43_wldev *dev, u16 reg)
Signature · 1 line
1.8.4.5
#2 lore raw

PATCH 2/7 b43: don't duplicate common PHY read/write ops

In reply to Rafał Miłecki

Most of the PHYs use the same way of accessing registers, so move that code to the shared place. An exception is G-PHY which sometimes access A-PHY regs and requires special handling.

---
 drivers/net/wireless/b43/phy_common.c | 14 ++++++++++++--
 drivers/net/wireless/b43/phy_ht.c     | 14 --------------
 drivers/net/wireless/b43/phy_lcn.c    | 14 --------------
 drivers/net/wireless/b43/phy_lp.c     | 14 --------------
 drivers/net/wireless/b43/phy_n.c      | 16 ----------------
 5 files changed, 12 insertions(+), 60 deletions(-)
drivers/net/wireless/b43/phy_common.c +12 -2
index c868748..08ca524 100644
@@ -274,7 +274,12 @@ u16 b43_phy_read(struct b43_wldev *dev, u16 reg)
 {
 	assert_mac_suspended(dev);
 	dev->phy.writes_counter = 0;
-	return dev->phy.ops->phy_read(dev, reg);
+
+	if (dev->phy.ops->phy_read)
+		return dev->phy.ops->phy_read(dev, reg);
+
+	b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
+	return b43_read16(dev, B43_MMIO_PHY_DATA);
 }
 
 void b43_phy_write(struct b43_wldev *dev, u16 reg, u16 value)
@@ -285,7 +290,12 @@ void b43_phy_write(struct b43_wldev *dev, u16 reg, u16 value)
 		b43_read16(dev, B43_MMIO_PHY_VER);
 		dev->phy.writes_counter = 1;
 	}
-	dev->phy.ops->phy_write(dev, reg, value);
+
+	if (dev->phy.ops->phy_write)
+		return dev->phy.ops->phy_write(dev, reg, value);
+
+	b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
+	b43_write16(dev, B43_MMIO_PHY_DATA, value);
 }
 
 void b43_phy_copy(struct b43_wldev *dev, u16 destreg, u16 srcreg)
drivers/net/wireless/b43/phy_ht.c +0 -14
index f2974c6..8b0b4b6 100644
@@ -1071,18 +1071,6 @@ static unsigned int b43_phy_ht_op_get_default_chan(struct b43_wldev *dev)
  * R/W ops.
  **************************************************/
 
-static u16 b43_phy_ht_op_read(struct b43_wldev *dev, u16 reg)
-{
-	b43_write16(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_write16(dev, B43_MMIO_PHY_DATA, value);
-}
-
 static void b43_phy_ht_op_maskset(struct b43_wldev *dev, u16 reg, u16 mask,
 				 u16 set)
 {
@@ -1126,8 +1114,6 @@ const struct b43_phy_operations b43_phyops_ht = {
 	.free			= b43_phy_ht_op_free,
 	.prepare_structs	= b43_phy_ht_op_prepare_structs,
 	.init			= b43_phy_ht_op_init,
-	.phy_read		= b43_phy_ht_op_read,
-	.phy_write		= b43_phy_ht_op_write,
 	.phy_maskset		= b43_phy_ht_op_maskset,
 	.radio_read		= b43_phy_ht_op_radio_read,
 	.radio_write		= b43_phy_ht_op_radio_write,
drivers/net/wireless/b43/phy_lcn.c +0 -14
index e76bbdf..bf29c3e 100644
@@ -810,18 +810,6 @@ static void b43_phy_lcn_op_adjust_txpower(struct b43_wldev *dev)
  * R/W ops.
  **************************************************/
 
-static u16 b43_phy_lcn_op_read(struct b43_wldev *dev, u16 reg)
-{
-	b43_write16(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_write16(dev, B43_MMIO_PHY_DATA, value);
-}
-
 static void b43_phy_lcn_op_maskset(struct b43_wldev *dev, u16 reg, u16 mask,
 				   u16 set)
 {
@@ -855,8 +843,6 @@ const struct b43_phy_operations b43_phyops_lcn = {
 	.free			= b43_phy_lcn_op_free,
 	.prepare_structs	= b43_phy_lcn_op_prepare_structs,
 	.init			= b43_phy_lcn_op_init,
-	.phy_read		= b43_phy_lcn_op_read,
-	.phy_write		= b43_phy_lcn_op_write,
 	.phy_maskset		= b43_phy_lcn_op_maskset,
 	.radio_read		= b43_phy_lcn_op_radio_read,
 	.radio_write		= b43_phy_lcn_op_radio_write,
drivers/net/wireless/b43/phy_lp.c +0 -14
index 92190da..1e9bae6 100644
@@ -1985,18 +1985,6 @@ static void lpphy_calibration(struct b43_wldev *dev)
 	b43_mac_enable(dev);
 }
 
-static u16 b43_lpphy_op_read(struct b43_wldev *dev, u16 reg)
-{
-	b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
-	return b43_read16(dev, B43_MMIO_PHY_DATA);
-}
-
-static void b43_lpphy_op_write(struct b43_wldev *dev, u16 reg, u16 value)
-{
-	b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
-	b43_write16(dev, B43_MMIO_PHY_DATA, value);
-}
-
 static void b43_lpphy_op_maskset(struct b43_wldev *dev, u16 reg, u16 mask,
 				 u16 set)
 {
@@ -2713,8 +2701,6 @@ const struct b43_phy_operations b43_phyops_lp = {
 	.free			= b43_lpphy_op_free,
 	.prepare_structs	= b43_lpphy_op_prepare_structs,
 	.init			= b43_lpphy_op_init,
-	.phy_read		= b43_lpphy_op_read,
-	.phy_write		= b43_lpphy_op_write,
 	.phy_maskset		= b43_lpphy_op_maskset,
 	.radio_read		= b43_lpphy_op_radio_read,
 	.radio_write		= b43_lpphy_op_radio_write,
drivers/net/wireless/b43/phy_n.c +0 -16
index b04aa34..5565318 100644
@@ -6497,20 +6497,6 @@ static inline void check_phyreg(struct b43_wldev *dev, u16 offset)
 #endif /* B43_DEBUG */
 }
 
-static u16 b43_nphy_op_read(struct b43_wldev *dev, u16 reg)
-{
-	check_phyreg(dev, reg);
-	b43_write16(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_write16(dev, B43_MMIO_PHY_DATA, value);
-}
-
 static void b43_nphy_op_maskset(struct b43_wldev *dev, u16 reg, u16 mask,
 				 u16 set)
 {
@@ -6653,8 +6639,6 @@ const struct b43_phy_operations b43_phyops_n = {
 	.free			= b43_nphy_op_free,
 	.prepare_structs	= b43_nphy_op_prepare_structs,
 	.init			= b43_nphy_op_init,
-	.phy_read		= b43_nphy_op_read,
-	.phy_write		= b43_nphy_op_write,
 	.phy_maskset		= b43_nphy_op_maskset,
 	.radio_read		= b43_nphy_op_radio_read,
 	.radio_write		= b43_nphy_op_radio_write,
Signature · 1 line
1.8.4.5
#3 lore raw

PATCH 3/7 b43: flush some writes on Broadcom MIPS SoCs

In reply to Rafał Miłecki

Access to PHY and radio registers is indirect on Broadcom hardware and it seems that addressing on MIPS SoCs may require flushing. Broadcom code does that unconditionally on MIPS, so let's do the same to make sure hardware won't miss anything important.

---
 drivers/net/wireless/b43/b43.h        |  8 ++++++++
 drivers/net/wireless/b43/main.c       | 17 ++++++++---------
 drivers/net/wireless/b43/phy_a.c      |  4 ++--
 drivers/net/wireless/b43/phy_common.c |  4 ++--
 drivers/net/wireless/b43/phy_g.c      |  8 ++++----
 drivers/net/wireless/b43/phy_ht.c     |  6 +++---
 drivers/net/wireless/b43/phy_lcn.c    |  6 +++---
 drivers/net/wireless/b43/phy_lp.c     |  6 +++---
 drivers/net/wireless/b43/phy_n.c      |  6 +++---
 9 files changed, 36 insertions(+), 29 deletions(-)
drivers/net/wireless/b43/b43.h +8 -0
index 4113b69..ff0c666 100644
@@ -1012,6 +1012,14 @@ static inline void b43_write16(struct b43_wldev *dev, u16 offset, u16 value)
 	dev->dev->write16(dev->dev, offset, value);
 }
 
+static inline void b43_write16f(struct b43_wldev *dev, u16 offset, u16 value)
+{
+	b43_write16(dev, offset, value);
+#if defined(CONFIG_BCM47XX) || defined(CONFIG_BCM63XX)
+	b43_read16(dev, offset);
+#endif
+}
+
 static inline void b43_maskset16(struct b43_wldev *dev, u16 offset, u16 mask,
 				 u16 set)
 {
drivers/net/wireless/b43/main.c +8 -9
index 2af1ac3..66ff718 100644
@@ -4466,10 +4466,10 @@ static int b43_phy_versioning(struct b43_wldev *dev)
 	if (core_rev == 40 || core_rev == 42) {
 		radio_manuf = 0x17F;
 
-		b43_write16(dev, B43_MMIO_RADIO24_CONTROL, 0);
+		b43_write16f(dev, B43_MMIO_RADIO24_CONTROL, 0);
 		radio_rev = b43_read16(dev, B43_MMIO_RADIO24_DATA);
 
-		b43_write16(dev, B43_MMIO_RADIO24_CONTROL, 1);
+		b43_write16f(dev, B43_MMIO_RADIO24_CONTROL, 1);
 		radio_id = b43_read16(dev, B43_MMIO_RADIO24_DATA);
 
 		radio_ver = 0; /* Is there version somewhere? */
@@ -4477,7 +4477,7 @@ static int b43_phy_versioning(struct b43_wldev *dev)
 		u16 radio24[3];
 
 		for (tmp = 0; tmp < 3; tmp++) {
-			b43_write16(dev, B43_MMIO_RADIO24_CONTROL, tmp);
+			b43_write16f(dev, B43_MMIO_RADIO24_CONTROL, tmp);
 			radio24[tmp] = b43_read16(dev, B43_MMIO_RADIO24_DATA);
 		}
 
@@ -4494,13 +4494,12 @@ static int b43_phy_versioning(struct b43_wldev *dev)
 			else
 				tmp = 0x5205017F;
 		} else {
-			b43_write16(dev, B43_MMIO_RADIO_CONTROL,
-				    B43_RADIOCTL_ID);
+			b43_write16f(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_RADIOCTL_ID);
-			tmp |= (u32)b43_read16(dev, B43_MMIO_RADIO_DATA_HIGH)
-				<< 16;
+			b43_write16f(dev, B43_MMIO_RADIO_CONTROL,
+				     B43_RADIOCTL_ID);
+			tmp |= b43_read16(dev, B43_MMIO_RADIO_DATA_HIGH) << 16;
 		}
 		radio_manuf = (tmp & 0x00000FFF);
 		radio_id = (tmp & 0x0FFFF000) >> 12;
drivers/net/wireless/b43/phy_a.c +2 -2
index 25e4043..99c036f 100644
@@ -444,14 +444,14 @@ static inline u16 adjust_phyreg(struct b43_wldev *dev, u16 offset)
 static u16 b43_aphy_op_read(struct b43_wldev *dev, u16 reg)
 {
 	reg = adjust_phyreg(dev, reg);
-	b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
+	b43_write16f(dev, B43_MMIO_PHY_CONTROL, reg);
 	return b43_read16(dev, B43_MMIO_PHY_DATA);
 }
 
 static void b43_aphy_op_write(struct b43_wldev *dev, u16 reg, u16 value)
 {
 	reg = adjust_phyreg(dev, reg);
-	b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
+	b43_write16f(dev, B43_MMIO_PHY_CONTROL, reg);
 	b43_write16(dev, B43_MMIO_PHY_DATA, value);
 }
 
drivers/net/wireless/b43/phy_common.c +2 -2
index 08ca524..1dfc682 100644
@@ -278,7 +278,7 @@ u16 b43_phy_read(struct b43_wldev *dev, u16 reg)
 	if (dev->phy.ops->phy_read)
 		return dev->phy.ops->phy_read(dev, reg);
 
-	b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
+	b43_write16f(dev, B43_MMIO_PHY_CONTROL, reg);
 	return b43_read16(dev, B43_MMIO_PHY_DATA);
 }
 
@@ -294,7 +294,7 @@ void b43_phy_write(struct b43_wldev *dev, u16 reg, u16 value)
 	if (dev->phy.ops->phy_write)
 		return dev->phy.ops->phy_write(dev, reg, value);
 
-	b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
+	b43_write16f(dev, B43_MMIO_PHY_CONTROL, reg);
 	b43_write16(dev, B43_MMIO_PHY_DATA, value);
 }
 
drivers/net/wireless/b43/phy_g.c +4 -4
index 8f5c14b..727ce6e 100644
@@ -2555,13 +2555,13 @@ static void b43_gphy_op_exit(struct b43_wldev *dev)
 
 static u16 b43_gphy_op_read(struct b43_wldev *dev, u16 reg)
 {
-	b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
+	b43_write16f(dev, B43_MMIO_PHY_CONTROL, reg);
 	return b43_read16(dev, B43_MMIO_PHY_DATA);
 }
 
 static void b43_gphy_op_write(struct b43_wldev *dev, u16 reg, u16 value)
 {
-	b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
+	b43_write16f(dev, B43_MMIO_PHY_CONTROL, reg);
 	b43_write16(dev, B43_MMIO_PHY_DATA, value);
 }
 
@@ -2572,7 +2572,7 @@ static u16 b43_gphy_op_radio_read(struct b43_wldev *dev, u16 reg)
 	/* G-PHY needs 0x80 for read access. */
 	reg |= 0x80;
 
-	b43_write16(dev, B43_MMIO_RADIO_CONTROL, reg);
+	b43_write16f(dev, B43_MMIO_RADIO_CONTROL, reg);
 	return b43_read16(dev, B43_MMIO_RADIO_DATA_LOW);
 }
 
@@ -2581,7 +2581,7 @@ static void b43_gphy_op_radio_write(struct b43_wldev *dev, u16 reg, u16 value)
 	/* Register 1 is a 32-bit register. */
 	B43_WARN_ON(reg == 1);
 
-	b43_write16(dev, B43_MMIO_RADIO_CONTROL, reg);
+	b43_write16f(dev, B43_MMIO_RADIO_CONTROL, reg);
 	b43_write16(dev, B43_MMIO_RADIO_DATA_LOW, value);
 }
 
drivers/net/wireless/b43/phy_ht.c +3 -3
index 8b0b4b6..c4dc8b0 100644
@@ -1074,7 +1074,7 @@ static unsigned int b43_phy_ht_op_get_default_chan(struct b43_wldev *dev)
 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_write16f(dev, B43_MMIO_PHY_CONTROL, reg);
 	b43_write16(dev, B43_MMIO_PHY_DATA,
 		    (b43_read16(dev, B43_MMIO_PHY_DATA) & mask) | set);
 }
@@ -1084,14 +1084,14 @@ static u16 b43_phy_ht_op_radio_read(struct b43_wldev *dev, u16 reg)
 	/* HT-PHY needs 0x200 for read access */
 	reg |= 0x200;
 
-	b43_write16(dev, B43_MMIO_RADIO24_CONTROL, reg);
+	b43_write16f(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_write16f(dev, B43_MMIO_RADIO24_CONTROL, reg);
 	b43_write16(dev, B43_MMIO_RADIO24_DATA, value);
 }
 
drivers/net/wireless/b43/phy_lcn.c +3 -3
index bf29c3e..97461cc 100644
@@ -813,7 +813,7 @@ static void b43_phy_lcn_op_adjust_txpower(struct b43_wldev *dev)
 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_write16f(dev, B43_MMIO_PHY_CONTROL, reg);
 	b43_write16(dev, B43_MMIO_PHY_DATA,
 		    (b43_read16(dev, B43_MMIO_PHY_DATA) & mask) | set);
 }
@@ -823,14 +823,14 @@ static u16 b43_phy_lcn_op_radio_read(struct b43_wldev *dev, u16 reg)
 	/* LCN-PHY needs 0x200 for read access */
 	reg |= 0x200;
 
-	b43_write16(dev, B43_MMIO_RADIO24_CONTROL, reg);
+	b43_write16f(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_write16f(dev, B43_MMIO_RADIO24_CONTROL, reg);
 	b43_write16(dev, B43_MMIO_RADIO24_DATA, value);
 }
 
drivers/net/wireless/b43/phy_lp.c +3 -3
index 1e9bae6..058a9f2 100644
@@ -1988,7 +1988,7 @@ static void lpphy_calibration(struct b43_wldev *dev)
 static void b43_lpphy_op_maskset(struct b43_wldev *dev, u16 reg, u16 mask,
 				 u16 set)
 {
-	b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
+	b43_write16f(dev, B43_MMIO_PHY_CONTROL, reg);
 	b43_write16(dev, B43_MMIO_PHY_DATA,
 		    (b43_read16(dev, B43_MMIO_PHY_DATA) & mask) | set);
 }
@@ -2004,7 +2004,7 @@ static u16 b43_lpphy_op_radio_read(struct b43_wldev *dev, u16 reg)
 	} else
 		reg |= 0x200;
 
-	b43_write16(dev, B43_MMIO_RADIO_CONTROL, reg);
+	b43_write16f(dev, B43_MMIO_RADIO_CONTROL, reg);
 	return b43_read16(dev, B43_MMIO_RADIO_DATA_LOW);
 }
 
@@ -2013,7 +2013,7 @@ static void b43_lpphy_op_radio_write(struct b43_wldev *dev, u16 reg, u16 value)
 	/* Register 1 is a 32-bit register. */
 	B43_WARN_ON(reg == 1);
 
-	b43_write16(dev, B43_MMIO_RADIO_CONTROL, reg);
+	b43_write16f(dev, B43_MMIO_RADIO_CONTROL, reg);
 	b43_write16(dev, B43_MMIO_RADIO_DATA_LOW, value);
 }
 
drivers/net/wireless/b43/phy_n.c +3 -3
index 5565318..df64032 100644
@@ -6501,7 +6501,7 @@ static void b43_nphy_op_maskset(struct b43_wldev *dev, u16 reg, u16 mask,
 				 u16 set)
 {
 	check_phyreg(dev, reg);
-	b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
+	b43_write16f(dev, B43_MMIO_PHY_CONTROL, reg);
 	b43_maskset16(dev, B43_MMIO_PHY_DATA, mask, set);
 	dev->phy.writes_counter = 1;
 }
@@ -6516,7 +6516,7 @@ static u16 b43_nphy_op_radio_read(struct b43_wldev *dev, u16 reg)
 	else
 		reg |= 0x100;
 
-	b43_write16(dev, B43_MMIO_RADIO_CONTROL, reg);
+	b43_write16f(dev, B43_MMIO_RADIO_CONTROL, reg);
 	return b43_read16(dev, B43_MMIO_RADIO_DATA_LOW);
 }
 
@@ -6525,7 +6525,7 @@ static void b43_nphy_op_radio_write(struct b43_wldev *dev, u16 reg, u16 value)
 	/* Register 1 is a 32-bit register. */
 	B43_WARN_ON(dev->phy.rev < 7 && reg == 1);
 
-	b43_write16(dev, B43_MMIO_RADIO_CONTROL, reg);
+	b43_write16f(dev, B43_MMIO_RADIO_CONTROL, reg);
 	b43_write16(dev, B43_MMIO_RADIO_DATA_LOW, value);
 }
 
Signature · 1 line
1.8.4.5
#11 lore raw

PATCH 4/7 b43: N-PHY: update rev3+ gain control workarounds

In reply to Rafał Miłecki

This fixes workarounds on rev 6+ and cleans code slightly.

---
 drivers/net/wireless/b43/tables_nphy.c | 61 +++++++++++++++++++++-------------
 1 file changed, 37 insertions(+), 24 deletions(-)
drivers/net/wireless/b43/tables_nphy.c +37 -24
index 4b58850..f449cff 100644
@@ -3197,7 +3197,7 @@ static struct nphy_gain_ctl_workaround_entry nphy_gain_ctl_workaround[2][4] = {
 			{ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
 			0x527E, /* invalid for external LNA! */
 			{ 0x513F, 0x513F, 0x513F, 0x513F }, /* invalid for external LNA! */
-			0x1076, 0x0066, 0x0000, /* low is invalid (the last one) */
+			0x007E, 0x0066, 0x0000, /* low is invalid (the last one) */
 			0x18, 0x18, 0x18,
 			0x01D0, 0x5,
 		},
@@ -3711,6 +3711,7 @@ const u32 *b43_nphy_get_tx_gain_table(struct b43_wldev *dev)
 struct nphy_gain_ctl_workaround_entry *b43_nphy_get_gain_ctl_workaround_ent(
 	struct b43_wldev *dev, bool ghz5, bool ext_lna)
 {
+	struct b43_phy *phy = &dev->phy;
 	struct nphy_gain_ctl_workaround_entry *e;
 	u8 phy_idx;
 
@@ -3729,37 +3730,49 @@ struct nphy_gain_ctl_workaround_entry *b43_nphy_get_gain_ctl_workaround_ent(
 	e = &nphy_gain_ctl_workaround[ghz5][phy_idx];
 
 	/* Some workarounds to the workarounds... */
-	if (ghz5 && dev->phy.rev >= 6) {
-		if (dev->phy.radio_rev == 11 &&
-		    !b43_is_40mhz(dev))
-			e->cliplo_gain = 0x2d;
-	} else if (!ghz5 && dev->phy.rev >= 5) {
-		static const int gain_data[] = {0x0062, 0x0064, 0x006a, 0x106a,
-						0x106c, 0x1074, 0x107c, 0x207c};
+	if (!ghz5) {
 		u8 tr_iso = dev->dev->bus_sprom->fem.ghz2.tr_iso;
 
-		if (ext_lna) {
+		if (tr_iso > 7)
+			tr_iso = 3;
+
+		if (phy->rev >= 6) {
+			static const int gain_data[] = { 0x106a, 0x106c, 0x1074,
+							 0x107c, 0x007e, 0x107e,
+							 0x207e, 0x307e, };
+
+			e->cliplo_gain = gain_data[tr_iso];
+		} else if (phy->rev == 5) {
+			static const int gain_data[] = { 0x0062, 0x0064, 0x006a,
+							 0x106a, 0x106c, 0x1074,
+							 0x107c, 0x207c, };
+
+			e->cliplo_gain = gain_data[tr_iso];
+		}
+
+		if (phy->rev >= 5 && ext_lna) {
 			e->rfseq_init[0] &= ~0x4000;
 			e->rfseq_init[1] &= ~0x4000;
 			e->rfseq_init[2] &= ~0x4000;
 			e->rfseq_init[3] &= ~0x4000;
 			e->init_gain &= ~0x4000;
 		}
-		if (tr_iso > 7)
-			tr_iso = 3;
-		e->cliplo_gain = gain_data[tr_iso];
-
-	} else if (ghz5 && dev->phy.rev == 4 && ext_lna) {
-		e->rfseq_init[0] &= ~0x4000;
-		e->rfseq_init[1] &= ~0x4000;
-		e->rfseq_init[2] &= ~0x4000;
-		e->rfseq_init[3] &= ~0x4000;
-		e->init_gain &= ~0x4000;
-		e->rfseq_init[0] |= 0x1000;
-		e->rfseq_init[1] |= 0x1000;
-		e->rfseq_init[2] |= 0x1000;
-		e->rfseq_init[3] |= 0x1000;
-		e->init_gain |= 0x1000;
+	} else {
+		if (phy->rev >= 6) {
+			if (phy->radio_rev == 11 && !b43_is_40mhz(dev))
+				e->crsminu = 0x2d;
+		} else if (phy->rev == 4 && ext_lna) {
+			e->rfseq_init[0] &= ~0x4000;
+			e->rfseq_init[1] &= ~0x4000;
+			e->rfseq_init[2] &= ~0x4000;
+			e->rfseq_init[3] &= ~0x4000;
+			e->init_gain &= ~0x4000;
+			e->rfseq_init[0] |= 0x1000;
+			e->rfseq_init[1] |= 0x1000;
+			e->rfseq_init[2] |= 0x1000;
+			e->rfseq_init[3] |= 0x1000;
+			e->init_gain |= 0x1000;
+		}
 	}
 
 	return e;
Signature · 1 line
1.8.4.5
#12 lore raw

PATCH 5/7 b43: N-PHY: add RF power tables for radio 0x2057 revs 9 & 14

In reply to Rafał Miłecki

Don't write them as we don't have gains configured correctly yet.

---
These magic tables I add here may deserve some explanation. The problem with fetching these tables was that wl.ko doesn't write them directly. Instead it uses values from another table, extracts some bits from them and then picks a proper value. This is why I couldn't get all values by simply looking at MMIO dump and I had to guess few.

First I found writes of proper tables in MMIO dump:

1) Writing "txpwr" 32b values (cut to 5 out of 128)
phy_write(0x0072) <- 0x68c0 // This is (26 << 10) | 0xC0
phy_write(0x0074) <- 0x60ff
phy_write(0x0073) <- 0x0031 // This was 0x60ff0031 value
phy_write(0x0074) <- 0x60e7
phy_write(0x0073) <- 0x002c // This was 0x60e7002c value
phy_write(0x0074) <- 0x60cf
phy_write(0x0073) <- 0x002a // This was 0x60cf002a value
phy_write(0x0074) <- 0x60c7
phy_write(0x0073) <- 0x0029 // This was 0x60c70029 value
phy_write(0x0074) <- 0x60b7
phy_write(0x0073) <- 0x0029 // This was 0x60b70029 value
(...)

2) Writing RF power offset values (cut to 5 out of 128)
phy_write(0x0072) <- 0x6a40 // This is ((26 << 10) | 0x240) + 0
phy_write(0x0074) <- 0x0000
phy_write(0x0073) <- 0x0000
phy_write(0x0072) <- 0x6a41 // This is ((26 << 10) | 0x240) + 1
phy_write(0x0074) <- 0xffff
phy_write(0x0073) <- 0xfffd
phy_write(0x0072) <- 0x6a42 // This is ((26 << 10) | 0x240) + 2
phy_write(0x0074) <- 0xffff
phy_write(0x0073) <- 0xfff9
phy_write(0x0072) <- 0x6a43 // This is ((26 << 10) | 0x240) + 3
phy_write(0x0074) <- 0xffff
phy_write(0x0073) <- 0xfff7
phy_write(0x0072) <- 0x6a44 // This is ((26 << 10) | 0x240) + 4
phy_write(0x0074) <- 0xffff
phy_write(0x0073) <- 0xfff4
(...)

Then from every "txpwr" value I extracted "pad_gain" value using:
((table[i] >> 19) & 0x1f) and put corresponding write to the second table next to it. Then I had to change hex value into signed int. It went like this:
txpwr:0x60ff0031 pad_gain:31 0x00000000 0
txpwr:0x60e7002c pad_gain:28 0xfffffffd -3
txpwr:0x60cf002a pad_gain:25 0xfffffff9 -7
txpwr:0x60c70029 pad_gain:24 0xfffffff7 -9
txpwr:0x60b70029 pad_gain:22 0xfffffff4 -12
(...)

---
 drivers/net/wireless/b43/phy_n.c       | 21 +++++++++--
 drivers/net/wireless/b43/tables_nphy.c | 67 ++++++++++++++++++++++++++++++++++
 drivers/net/wireless/b43/tables_nphy.h |  2 +
 3 files changed, 87 insertions(+), 3 deletions(-)
drivers/net/wireless/b43/phy_n.c +18 -3
index df64032..57a3ab2 100644
@@ -4235,8 +4235,9 @@ static void b43_nphy_tx_gain_table_upload(struct b43_wldev *dev)
 
 	const u32 *table = NULL;
 	u32 rfpwr_offset;
-	u8 pga_gain;
+	u8 pga_gain, pad_gain;
 	int i;
+	const s16 *uninitialized_var(rf_pwr_offset_table);
 
 	table = b43_nphy_get_tx_gain_table(dev);
 	if (!table)
@@ -4252,13 +4253,27 @@ static void b43_nphy_tx_gain_table_upload(struct b43_wldev *dev)
 	nphy->gmval = (table[0] >> 16) & 0x7000;
 #endif
 
+	if (phy->rev >= 19) {
+		return;
+	} else if (phy->rev >= 7) {
+		rf_pwr_offset_table = b43_ntab_get_rf_pwr_offset_table(dev);
+		if (!rf_pwr_offset_table)
+			return;
+		/* TODO: Enable this once we have gains configured */
+		return;
+	}
+
 	for (i = 0; i < 128; i++) {
 		if (phy->rev >= 19) {
 			/* TODO */
 			return;
 		} else if (phy->rev >= 7) {
-			/* TODO */
-			return;
+			pga_gain = (table[i] >> 24) & 0xf;
+			pad_gain = (table[i] >> 19) & 0x1f;
+			if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ)
+				rfpwr_offset = rf_pwr_offset_table[pad_gain];
+			else
+				rfpwr_offset = rf_pwr_offset_table[pga_gain];
 		} else {
 			pga_gain = (table[i] >> 24) & 0xF;
 			if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ)
drivers/net/wireless/b43/tables_nphy.c +67 -0

79 lines not on this page · raw message

drivers/net/wireless/b43/tables_nphy.h +2 -0
index 3ce2e6f..b51f386 100644
@@ -191,6 +191,8 @@ void b43_nphy_tables_init(struct b43_wldev *dev);
 
 const u32 *b43_nphy_get_tx_gain_table(struct b43_wldev *dev);
 
+const s16 *b43_ntab_get_rf_pwr_offset_table(struct b43_wldev *dev);
+
 extern const s8 b43_ntab_papd_pga_gain_delta_ipa_2g[];
 
 extern const u16 tbl_iqcal_gainparams[2][9][8];
Signature · 1 line
1.8.4.5
#13 lore raw

PATCH v2 6/7 b43: implement PPR (Power Per Rate) management/API

In reply to Rafał Miłecki

Broadcom hardware supports auto-adjustment of TX power depending on the currently used rate. So far all calculations were handled without any helpers (API) using big arrays and magic offsets.
It seems Broadcom recently decided to clean this up by developing PPR. Their wlc_ppr.h can be found in open parts of the SDK.
As we plan to implement support for rate-based TX power it makes sense to also implement our version of PPR as well.

---
Notes: I compile it unconditionally, other PHYs should use it as well. I already started working on HT-PHY.

V2: Drop unneeded __packed
Added Copyright/GPL header
Dropped some unneeded pointer (u32 replaced it) Replaced BUG_ON with WARN_ON_ONCE
Fix indexing some array (use 4 + i)

---
 drivers/net/wireless/b43/Makefile |   1 +
 drivers/net/wireless/b43/b43.h    |   7 ++
 drivers/net/wireless/b43/ppr.c    | 199 ++++++++++++++++++++++++++++++++++++++
 drivers/net/wireless/b43/ppr.h    |  45 +++++++++
 4 files changed, 252 insertions(+)
 create mode 100644 drivers/net/wireless/b43/ppr.c
 create mode 100644 drivers/net/wireless/b43/ppr.h
drivers/net/wireless/b43/Makefile +1 -0
index 6e00b88..9f7965a 100644
@@ -18,6 +18,7 @@ b43-y				+= xmit.o
 b43-y				+= dma.o
 b43-y				+= pio.o
 b43-y				+= rfkill.o
+b43-y				+= ppr.o
 b43-$(CONFIG_B43_LEDS)		+= leds.o
 b43-$(CONFIG_B43_PCMCIA)	+= pcmcia.o
 b43-$(CONFIG_B43_SDIO)		+= sdio.o
drivers/net/wireless/b43/b43.h +7 -0
index ff0c666..d55bd86 100644
@@ -791,6 +791,13 @@ struct b43_firmware {
 	bool pcm_request_failed;
 };
 
+enum b43_band {
+	B43_BAND_2G = 0,
+	B43_BAND_5G_LO = 1,
+	B43_BAND_5G_MI = 2,
+	B43_BAND_5G_HI = 3,
+};
+
 /* Device (802.11 core) initialization status. */
 enum {
 	B43_STAT_UNINIT = 0,	/* Uninitialized. */
drivers/net/wireless/b43/ppr.c new file +199 -0

199 lines not on this page · raw message

drivers/net/wireless/b43/ppr.h new file +45 -0

45 lines not on this page · raw message

Signature · 1 line
1.8.4.5
#14 lore raw

PATCH v2 7/7 b43: N-PHY: support setting custom TX power

In reply to Rafał Miłecki

---
Notes: I still need to implement helper for B43_MACCTL_PHY_LOCK, but this may require wider changes, so will be handled in another patch.

V2: Make struct b43_ppr part of struct b43_phy_n

---
 drivers/net/wireless/b43/b43.h   |  1 +
 drivers/net/wireless/b43/phy_n.c | 84 ++++++++++++++++++++++++++++++++++------
 drivers/net/wireless/b43/phy_n.h |  4 ++
 3 files changed, 77 insertions(+), 12 deletions(-)
drivers/net/wireless/b43/b43.h +1 -0
index d55bd86..c0dda0b 100644
@@ -457,6 +457,7 @@ enum {
 #define B43_MACCTL_RADIOLOCK		0x00080000	/* Radio lock */
 #define B43_MACCTL_BEACPROMISC		0x00100000	/* Beacon Promiscuous */
 #define B43_MACCTL_KEEP_BADPLCP		0x00200000	/* Keep frames with bad PLCP */
+#define B43_MACCTL_PHY_LOCK		0x00200000
 #define B43_MACCTL_KEEP_CTL		0x00400000	/* Keep control frames */
 #define B43_MACCTL_KEEP_BAD		0x00800000	/* Keep bad frames (FCS) */
 #define B43_MACCTL_PROMISC		0x01000000	/* Promiscuous mode */
drivers/net/wireless/b43/phy_n.c +72 -12

124 lines not on this page · raw message

drivers/net/wireless/b43/phy_n.h +4 -0
index 30bec81..a6da2c3 100644
@@ -2,6 +2,7 @@
 #define B43_NPHY_H_
 
 #include "phy_common.h"
+#include "ppr.h"
 
 
 /* N-PHY registers. */
@@ -967,6 +968,9 @@ struct b43_phy_n {
 	struct b43_phy_n_txpwrindex txpwrindex[2];
 	struct b43_phy_n_pwr_ctl_info pwr_ctl_info[2];
 	struct b43_chanspec txiqlocal_chanspec;
+	struct b43_ppr tx_pwr_max_ppr;
+	u16 tx_pwr_last_recalc_freq;
+	int tx_pwr_last_recalc_limit;
 
 	u8 txrx_chain;
 	u16 tx_rx_cal_phy_saveregs[11];
Signature · 1 line
1.8.4.5
#4 lore raw

PATCH 3/7 b43: flush some writes on Broadcom MIPS SoCs

In reply to Rafał Miłecki
Quoted 6 lines · Rafa? Mi?ecki

Access to PHY and radio registers is indirect on Broadcom hardware and it seems that addressing on MIPS SoCs may require flushing. Broadcom code does that unconditionally on MIPS, so let's do the same to make sure hardware won't miss anything important.

Quoted 12 lines
---
 drivers/net/wireless/b43/b43.h        |  8 ++++++++
 drivers/net/wireless/b43/main.c       | 17 ++++++++---------
 drivers/net/wireless/b43/phy_a.c      |  4 ++--
 drivers/net/wireless/b43/phy_common.c |  4 ++--
 drivers/net/wireless/b43/phy_g.c      |  8 ++++----
 drivers/net/wireless/b43/phy_ht.c     |  6 +++---
 drivers/net/wireless/b43/phy_lcn.c    |  6 +++---
 drivers/net/wireless/b43/phy_lp.c     |  6 +++---
 drivers/net/wireless/b43/phy_n.c      |  6 +++---
 9 files changed, 36 insertions(+), 29 deletions(-)

A comment in brcmsmac says this is only needed to work around a bug in the host pcie controller of 4717, 4718 and 4706. I haven't noticed this problem with BCM4706, so it could be that it is already fixed in the shipped version of bcm4706.

The comment says the following:
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 commit did the cleanup:
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=6a9a25eec0b55ea45e22710a9bcaf9690cb42fe6

Hauke

#7 lore raw

PATCH 3/7 b43: flush some writes on Broadcom MIPS SoCs

In reply to Rafał Miłecki

2014-07-31 12:59 GMT-07:00 Rafa? Mi?ecki <[email protected]>:

Quoted 23 lines

Access to PHY and radio registers is indirect on Broadcom hardware and it seems that addressing on MIPS SoCs may require flushing. Broadcom code does that unconditionally on MIPS, so let's do the same to make sure hardware won't miss anything important.

---
 drivers/net/wireless/b43/b43.h        |  8 ++++++++
 drivers/net/wireless/b43/main.c       | 17 ++++++++---------
 drivers/net/wireless/b43/phy_a.c      |  4 ++--
 drivers/net/wireless/b43/phy_common.c |  4 ++--
 drivers/net/wireless/b43/phy_g.c      |  8 ++++----
 drivers/net/wireless/b43/phy_ht.c     |  6 +++---
 drivers/net/wireless/b43/phy_lcn.c    |  6 +++---
 drivers/net/wireless/b43/phy_lp.c     |  6 +++---
 drivers/net/wireless/b43/phy_n.c      |  6 +++---
 9 files changed, 36 insertions(+), 29 deletions(-)
drivers/net/wireless/b43/b43.h +0 -0
index 4113b69..ff0c666 100644

drivers/net/wireless/b43/b43.h static inline void b43_write16(struct b43_wldev *dev, u16 offset, u16 value) · line 1021

Quoted 10 lines
drivers/net/wireless/b43/b43.h +7 -0
@@ -1012,6 +1012,14 @@ static inline void b43_write16(struct b43_wldev *dev, u16 offset, u16 value)
        dev->dev->write16(dev->dev, offset, value);
 }
 
+static inline void b43_write16f(struct b43_wldev *dev, u16 offset, u16 value)
+{
+       b43_write16(dev, offset, value);
+#if defined(CONFIG_BCM47XX) || defined(CONFIG_BCM63XX)
+       b43_read16(dev, offset);
+#endif
+}

How about you leave the calls to b43_write16() to avoid missing call sites, but you re-define it for BCM47XX and BCM63XX? Or, you could introduce a __b43_write16() that defaults to dev->dev->write16 in the normal case, and gets called by b43_write16() such that we you'd get:

static u16 void __b43_read16(struct b43_wldev *dev, u16 offset)

{
     return dev->dev->readt16(dev->dev, offset);

|

static inline void __b43_write16(struct b43_wldev *dev, u16 offset, u16 value)

{
      dev->dev->write16(dev->dev, offset, value);
#if defined(CONFIG_BCM47XX) || defined(CONFIG_BCM63XX)
      __b43_read16(dev, offset);

#endif
}

static inline void b43_write16(struct b43_wldev *dev, u16 offset, u16 value)

{
      __b43_write16(dev, offset, value);
}
Quoted 259 lines
drivers/net/wireless/b43/b43.h +1 -0
+
 static inline void b43_maskset16(struct b43_wldev *dev, u16 offset, u16 mask,
                                 u16 set)
 {
drivers/net/wireless/b43/main.c +8 -9
index 2af1ac3..66ff718 100644
@@ -4466,10 +4466,10 @@ static int b43_phy_versioning(struct b43_wldev *dev)
        if (core_rev == 40 || core_rev == 42) {
                radio_manuf = 0x17F;
 
-               b43_write16(dev, B43_MMIO_RADIO24_CONTROL, 0);
+               b43_write16f(dev, B43_MMIO_RADIO24_CONTROL, 0);
                radio_rev = b43_read16(dev, B43_MMIO_RADIO24_DATA);
 
-               b43_write16(dev, B43_MMIO_RADIO24_CONTROL, 1);
+               b43_write16f(dev, B43_MMIO_RADIO24_CONTROL, 1);
                radio_id = b43_read16(dev, B43_MMIO_RADIO24_DATA);
 
                radio_ver = 0; /* Is there version somewhere? */
@@ -4477,7 +4477,7 @@ static int b43_phy_versioning(struct b43_wldev *dev)
                u16 radio24[3];
 
                for (tmp = 0; tmp < 3; tmp++) {
-                       b43_write16(dev, B43_MMIO_RADIO24_CONTROL, tmp);
+                       b43_write16f(dev, B43_MMIO_RADIO24_CONTROL, tmp);
                        radio24[tmp] = b43_read16(dev, B43_MMIO_RADIO24_DATA);
                }
 
@@ -4494,13 +4494,12 @@ static int b43_phy_versioning(struct b43_wldev *dev)
                        else
                                tmp = 0x5205017F;
                } else {
-                       b43_write16(dev, B43_MMIO_RADIO_CONTROL,
-                                   B43_RADIOCTL_ID);
+                       b43_write16f(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_RADIOCTL_ID);
-                       tmp |= (u32)b43_read16(dev, B43_MMIO_RADIO_DATA_HIGH)
-                               << 16;
+                       b43_write16f(dev, B43_MMIO_RADIO_CONTROL,
+                                    B43_RADIOCTL_ID);
+                       tmp |= b43_read16(dev, B43_MMIO_RADIO_DATA_HIGH) << 16;
                }
                radio_manuf = (tmp & 0x00000FFF);
                radio_id = (tmp & 0x0FFFF000) >> 12;
drivers/net/wireless/b43/phy_a.c +2 -2
index 25e4043..99c036f 100644
@@ -444,14 +444,14 @@ static inline u16 adjust_phyreg(struct b43_wldev *dev, u16 offset)
 static u16 b43_aphy_op_read(struct b43_wldev *dev, u16 reg)
 {
        reg = adjust_phyreg(dev, reg);
-       b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
+       b43_write16f(dev, B43_MMIO_PHY_CONTROL, reg);
        return b43_read16(dev, B43_MMIO_PHY_DATA);
 }
 
 static void b43_aphy_op_write(struct b43_wldev *dev, u16 reg, u16 value)
 {
        reg = adjust_phyreg(dev, reg);
-       b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
+       b43_write16f(dev, B43_MMIO_PHY_CONTROL, reg);
        b43_write16(dev, B43_MMIO_PHY_DATA, value);
 }
 
drivers/net/wireless/b43/phy_common.c +2 -2
index 08ca524..1dfc682 100644
@@ -278,7 +278,7 @@ u16 b43_phy_read(struct b43_wldev *dev, u16 reg)
        if (dev->phy.ops->phy_read)
                return dev->phy.ops->phy_read(dev, reg);
 
-       b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
+       b43_write16f(dev, B43_MMIO_PHY_CONTROL, reg);
        return b43_read16(dev, B43_MMIO_PHY_DATA);
 }
 
@@ -294,7 +294,7 @@ void b43_phy_write(struct b43_wldev *dev, u16 reg, u16 value)
        if (dev->phy.ops->phy_write)
                return dev->phy.ops->phy_write(dev, reg, value);
 
-       b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
+       b43_write16f(dev, B43_MMIO_PHY_CONTROL, reg);
        b43_write16(dev, B43_MMIO_PHY_DATA, value);
 }
 
drivers/net/wireless/b43/phy_g.c +4 -4
index 8f5c14b..727ce6e 100644
@@ -2555,13 +2555,13 @@ static void b43_gphy_op_exit(struct b43_wldev *dev)
 
 static u16 b43_gphy_op_read(struct b43_wldev *dev, u16 reg)
 {
-       b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
+       b43_write16f(dev, B43_MMIO_PHY_CONTROL, reg);
        return b43_read16(dev, B43_MMIO_PHY_DATA);
 }
 
 static void b43_gphy_op_write(struct b43_wldev *dev, u16 reg, u16 value)
 {
-       b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
+       b43_write16f(dev, B43_MMIO_PHY_CONTROL, reg);
        b43_write16(dev, B43_MMIO_PHY_DATA, value);
 }
 
@@ -2572,7 +2572,7 @@ static u16 b43_gphy_op_radio_read(struct b43_wldev *dev, u16 reg)
        /* G-PHY needs 0x80 for read access. */
        reg |= 0x80;
 
-       b43_write16(dev, B43_MMIO_RADIO_CONTROL, reg);
+       b43_write16f(dev, B43_MMIO_RADIO_CONTROL, reg);
        return b43_read16(dev, B43_MMIO_RADIO_DATA_LOW);
 }
 
@@ -2581,7 +2581,7 @@ static void b43_gphy_op_radio_write(struct b43_wldev *dev, u16 reg, u16 value)
        /* Register 1 is a 32-bit register. */
        B43_WARN_ON(reg == 1);
 
-       b43_write16(dev, B43_MMIO_RADIO_CONTROL, reg);
+       b43_write16f(dev, B43_MMIO_RADIO_CONTROL, reg);
        b43_write16(dev, B43_MMIO_RADIO_DATA_LOW, value);
 }
 
drivers/net/wireless/b43/phy_ht.c +3 -3
index 8b0b4b6..c4dc8b0 100644
@@ -1074,7 +1074,7 @@ static unsigned int b43_phy_ht_op_get_default_chan(struct b43_wldev *dev)
 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_write16f(dev, B43_MMIO_PHY_CONTROL, reg);
        b43_write16(dev, B43_MMIO_PHY_DATA,
                    (b43_read16(dev, B43_MMIO_PHY_DATA) & mask) | set);
 }
@@ -1084,14 +1084,14 @@ static u16 b43_phy_ht_op_radio_read(struct b43_wldev *dev, u16 reg)
        /* HT-PHY needs 0x200 for read access */
        reg |= 0x200;
 
-       b43_write16(dev, B43_MMIO_RADIO24_CONTROL, reg);
+       b43_write16f(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_write16f(dev, B43_MMIO_RADIO24_CONTROL, reg);
        b43_write16(dev, B43_MMIO_RADIO24_DATA, value);
 }
 
drivers/net/wireless/b43/phy_lcn.c +3 -3
index bf29c3e..97461cc 100644
@@ -813,7 +813,7 @@ static void b43_phy_lcn_op_adjust_txpower(struct b43_wldev *dev)
 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_write16f(dev, B43_MMIO_PHY_CONTROL, reg);
        b43_write16(dev, B43_MMIO_PHY_DATA,
                    (b43_read16(dev, B43_MMIO_PHY_DATA) & mask) | set);
 }
@@ -823,14 +823,14 @@ static u16 b43_phy_lcn_op_radio_read(struct b43_wldev *dev, u16 reg)
        /* LCN-PHY needs 0x200 for read access */
        reg |= 0x200;
 
-       b43_write16(dev, B43_MMIO_RADIO24_CONTROL, reg);
+       b43_write16f(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_write16f(dev, B43_MMIO_RADIO24_CONTROL, reg);
        b43_write16(dev, B43_MMIO_RADIO24_DATA, value);
 }
 
drivers/net/wireless/b43/phy_lp.c +3 -3
index 1e9bae6..058a9f2 100644
@@ -1988,7 +1988,7 @@ static void lpphy_calibration(struct b43_wldev *dev)
 static void b43_lpphy_op_maskset(struct b43_wldev *dev, u16 reg, u16 mask,
                                 u16 set)
 {
-       b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
+       b43_write16f(dev, B43_MMIO_PHY_CONTROL, reg);
        b43_write16(dev, B43_MMIO_PHY_DATA,
                    (b43_read16(dev, B43_MMIO_PHY_DATA) & mask) | set);
 }
@@ -2004,7 +2004,7 @@ static u16 b43_lpphy_op_radio_read(struct b43_wldev *dev, u16 reg)
        } else
                reg |= 0x200;
 
-       b43_write16(dev, B43_MMIO_RADIO_CONTROL, reg);
+       b43_write16f(dev, B43_MMIO_RADIO_CONTROL, reg);
        return b43_read16(dev, B43_MMIO_RADIO_DATA_LOW);
 }
 
@@ -2013,7 +2013,7 @@ static void b43_lpphy_op_radio_write(struct b43_wldev *dev, u16 reg, u16 value)
        /* Register 1 is a 32-bit register. */
        B43_WARN_ON(reg == 1);
 
-       b43_write16(dev, B43_MMIO_RADIO_CONTROL, reg);
+       b43_write16f(dev, B43_MMIO_RADIO_CONTROL, reg);
        b43_write16(dev, B43_MMIO_RADIO_DATA_LOW, value);
 }
 
drivers/net/wireless/b43/phy_n.c +3 -4
index 5565318..df64032 100644
@@ -6501,7 +6501,7 @@ static void b43_nphy_op_maskset(struct b43_wldev *dev, u16 reg, u16 mask,
                                 u16 set)
 {
        check_phyreg(dev, reg);
-       b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
+       b43_write16f(dev, B43_MMIO_PHY_CONTROL, reg);
        b43_maskset16(dev, B43_MMIO_PHY_DATA, mask, set);
        dev->phy.writes_counter = 1;
 }
@@ -6516,7 +6516,7 @@ static u16 b43_nphy_op_radio_read(struct b43_wldev *dev, u16 reg)
        else
                reg |= 0x100;
 
-       b43_write16(dev, B43_MMIO_RADIO_CONTROL, reg);
+       b43_write16f(dev, B43_MMIO_RADIO_CONTROL, reg);
        return b43_read16(dev, B43_MMIO_RADIO_DATA_LOW);
 }
 
@@ -6525,7 +6525,7 @@ static void b43_nphy_op_radio_write(struct b43_wldev *dev, u16 reg, u16 value)
        /* Register 1 is a 32-bit register. */
        B43_WARN_ON(dev->phy.rev < 7 && reg == 1);
 
-       b43_write16(dev, B43_MMIO_RADIO_CONTROL, reg);
+       b43_write16f(dev, B43_MMIO_RADIO_CONTROL, reg);
        b43_write16(dev, B43_MMIO_RADIO_DATA_LOW, value);
 }
 
--

1.8.4.5

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 1 line
Florian
#5 lore raw

PATCH 3/7 b43: flush some writes on Broadcom MIPS SoCs

In reply to Hauke Mehrtens
Quoted 5 lines · Hauke Mehrtens

A comment in brcmsmac says this is only needed to work around a bug in the host pcie controller of 4717, 4718 and 4706. I haven't noticed this problem with BCM4706, so it could be that it is already fixed in the shipped version of bcm4706.

Quoted 8 lines

The comment says the following:
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 commit did the cleanup:
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=6a9a25eec0b55ea45e22710a9bcaf9690cb42fe6

Any idea why Broadcom didn't own comments and didn't enable it for bcm4716 and bcm4706 only?

Signature · 1 line
Rafa?
#6 lore raw

PATCH 3/7 b43: flush some writes on Broadcom MIPS SoCs

In reply to Hauke Mehrtens

2014-07-31 13:23 GMT-07:00 Hauke Mehrtens <[email protected]>:

Quoted 20 lines · Rafa? Mi?ecki
Quoted 6 lines

Access to PHY and radio registers is indirect on Broadcom hardware and it seems that addressing on MIPS SoCs may require flushing. Broadcom code does that unconditionally on MIPS, so let's do the same to make sure hardware won't miss anything important.

Quoted 12 lines
---
 drivers/net/wireless/b43/b43.h        |  8 ++++++++
 drivers/net/wireless/b43/main.c       | 17 ++++++++---------
 drivers/net/wireless/b43/phy_a.c      |  4 ++--
 drivers/net/wireless/b43/phy_common.c |  4 ++--
 drivers/net/wireless/b43/phy_g.c      |  8 ++++----
 drivers/net/wireless/b43/phy_ht.c     |  6 +++---
 drivers/net/wireless/b43/phy_lcn.c    |  6 +++---
 drivers/net/wireless/b43/phy_lp.c     |  6 +++---
 drivers/net/wireless/b43/phy_n.c      |  6 +++---
 9 files changed, 36 insertions(+), 29 deletions(-)
Quoted 4 lines

A comment in brcmsmac says this is only needed to work around a bug in the host pcie controller of 4717, 4718 and 4706. I haven't noticed this problem with BCM4706, so it could be that it is already fixed in the shipped version of bcm4706.

I don't think we have ever needed it on BCM63xx as well.

Quoted 6 lines

The comment says the following:
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.

The fix in brcmsmac is covering a lot more chips with a __mips__ that it needs to. Maybe we should have a helper function that returns the SoC ID so we can selectively apply this write then read flush workaround?

Quoted 4 lines

This commit did the cleanup:
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=6a9a25eec0b55ea45e22710a9bcaf9690cb42fe6

Signature · 1 line
Florian
#8 lore raw

PATCH 3/7 b43: flush some writes on Broadcom MIPS SoCs

In reply to Florian Fainelli
Quoted 4 lines · Florian Fainelli
Quoted 4 lines
drivers/net/wireless/b43/b43.h +4 -0
+static inline void b43_write16f(struct b43_wldev *dev, u16 offset, u16 value)
+{
+       b43_write16(dev, offset, value);
+#if defined(CONFIG_BCM47XX) || defined(CONFIG_BCM63XX)
Quoted 8 lines

drivers/net/wireless/b43/b43.h static inline void b43_write16(struct b43_wldev *dev, u16 offset, u16 value) · line 1021

Quoted 3 lines
drivers/net/wireless/b43/b43.h +3 -0
+       b43_read16(dev, offset);
+#endif
+}

How about you leave the calls to b43_write16() to avoid missing call sites, but you re-define it for BCM47XX and BCM63XX? Or, you could introduce a __b43_write16() that defaults to dev->dev->write16 in the normal case, and gets called by b43_write16() such that we you'd get:

I didn't mean (and I didn't) enable flushing for all writes. Only these touching specific registers. I don't think we need to flush every single write.

#9 lore raw

PATCH 3/7 b43: flush some writes on Broadcom MIPS SoCs

2014-07-31 13:34 GMT-07:00 Rafa? Mi?ecki <[email protected]>:

Quoted 14 lines · Florian Fainelli
Quoted 4 lines
Quoted 4 lines
drivers/net/wireless/b43/b43.h +4 -0
+static inline void b43_write16f(struct b43_wldev *dev, u16 offset, u16 value)
+{
+       b43_write16(dev, offset, value);
+#if defined(CONFIG_BCM47XX) || defined(CONFIG_BCM63XX)
Quoted 8 lines

drivers/net/wireless/b43/b43.h static inline void b43_write16(struct b43_wldev *dev, u16 offset, u16 value) · line 1021

Quoted 3 lines
drivers/net/wireless/b43/b43.h +3 -0
+       b43_read16(dev, offset);
+#endif
+}

How about you leave the calls to b43_write16() to avoid missing call sites, but you re-define it for BCM47XX and BCM63XX? Or, you could introduce a __b43_write16() that defaults to dev->dev->write16 in the normal case, and gets called by b43_write16() such that we you'd get:

Quoted 3 lines

I didn't mean (and I didn't) enable flushing for all writes. Only these touching specific registers. I don't think we need to flush every single write.

Ok, then the current approach looks good to me, thanks!

Signature · 1 line
Florian
#10 lore raw

PATCH v2 3/7 b43: flush some writes on Broadcom MIPS SoCs

In reply to Rafał Miłecki

Access to PHY and radio registers is indirect on Broadcom hardware and it seems that addressing on some MIPS SoCs may require flushing. So far this problem was noticed on 0x4716 SoC only (marketing names: BCM4717, BCM4718).

---
V2: As Hauke noticed, Broadcom comment says this is needed for 0x4716
and 0x4706 only. Their code does this globally on the whole MIPS arch, but it doesn't seem to be needed. Also BCM4706 doesn't seem to require this.
So let's enable this for BCMA_CHIP_ID_BCM4716 SoC only. Florian has also confirmed he never needed this on BCM63XX.

---
 drivers/net/wireless/b43/b43.h        | 10 ++++++++++
 drivers/net/wireless/b43/bus.c        | 10 ++++++++++
 drivers/net/wireless/b43/bus.h        |  1 +
 drivers/net/wireless/b43/main.c       | 17 ++++++++---------
 drivers/net/wireless/b43/phy_a.c      |  4 ++--
 drivers/net/wireless/b43/phy_common.c |  4 ++--
 drivers/net/wireless/b43/phy_g.c      |  8 ++++----
 drivers/net/wireless/b43/phy_ht.c     |  6 +++---
 drivers/net/wireless/b43/phy_lcn.c    |  6 +++---
 drivers/net/wireless/b43/phy_lp.c     |  6 +++---
 drivers/net/wireless/b43/phy_n.c      |  6 +++---
 11 files changed, 49 insertions(+), 29 deletions(-)
drivers/net/wireless/b43/b43.h +10 -0
index 4113b69..9b2d0c9 100644
@@ -1012,6 +1012,16 @@ static inline void b43_write16(struct b43_wldev *dev, u16 offset, u16 value)
 	dev->dev->write16(dev->dev, offset, value);
 }
 
+/* To optimize this check for flush_writes on BCM47XX_BCMA only. */
+static inline void b43_write16f(struct b43_wldev *dev, u16 offset, u16 value)
+{
+	b43_write16(dev, offset, value);
+#if defined(CONFIG_BCM47XX_BCMA)
+	if (dev->dev->flush_writes)
+		b43_read16(dev, offset);
+#endif
+}
+
 static inline void b43_maskset16(struct b43_wldev *dev, u16 offset, u16 mask,
 				 u16 set)
 {
drivers/net/wireless/b43/bus.c +10 -0
index 565fdbd..17d16a3 100644
@@ -22,6 +22,10 @@
 
 */
 
+#ifdef CONFIG_BCM47XX_BCMA
+#include <asm/mach-bcm47xx/bcm47xx.h>
+#endif
+
 #include "b43.h"
 #include "bus.h"
 
@@ -102,6 +106,12 @@ struct b43_bus_dev *b43_bus_dev_bcma_init(struct bcma_device *core)
 	dev->write32 = b43_bus_bcma_write32;
 	dev->block_read = b43_bus_bcma_block_read;
 	dev->block_write = b43_bus_bcma_block_write;
+#ifdef CONFIG_BCM47XX_BCMA
+	if (b43_bus_host_is_pci(dev) &&
+	    bcm47xx_bus_type == BCM47XX_BUS_TYPE_BCMA &&
+	    bcm47xx_bus.bcma.bus.chipinfo.id == BCMA_CHIP_ID_BCM4716)
+		dev->flush_writes = true;
+#endif
 
 	dev->dev = &core->dev;
 	dev->dma_dev = core->dma_dev;
drivers/net/wireless/b43/bus.h +1 -0
index 460d9d9..256c2c1 100644
@@ -33,6 +33,7 @@ struct b43_bus_dev {
 			   size_t count, u16 offset, u8 reg_width);
 	void (*block_write)(struct b43_bus_dev *dev, const void *buffer,
 			    size_t count, u16 offset, u8 reg_width);
+	bool flush_writes;
 
 	struct device *dev;
 	struct device *dma_dev;
drivers/net/wireless/b43/main.c +8 -9
index 2af1ac3..66ff718 100644
@@ -4466,10 +4466,10 @@ static int b43_phy_versioning(struct b43_wldev *dev)
 	if (core_rev == 40 || core_rev == 42) {
 		radio_manuf = 0x17F;
 
-		b43_write16(dev, B43_MMIO_RADIO24_CONTROL, 0);
+		b43_write16f(dev, B43_MMIO_RADIO24_CONTROL, 0);
 		radio_rev = b43_read16(dev, B43_MMIO_RADIO24_DATA);
 
-		b43_write16(dev, B43_MMIO_RADIO24_CONTROL, 1);
+		b43_write16f(dev, B43_MMIO_RADIO24_CONTROL, 1);
 		radio_id = b43_read16(dev, B43_MMIO_RADIO24_DATA);
 
 		radio_ver = 0; /* Is there version somewhere? */
@@ -4477,7 +4477,7 @@ static int b43_phy_versioning(struct b43_wldev *dev)
 		u16 radio24[3];
 
 		for (tmp = 0; tmp < 3; tmp++) {
-			b43_write16(dev, B43_MMIO_RADIO24_CONTROL, tmp);
+			b43_write16f(dev, B43_MMIO_RADIO24_CONTROL, tmp);
 			radio24[tmp] = b43_read16(dev, B43_MMIO_RADIO24_DATA);
 		}
 
@@ -4494,13 +4494,12 @@ static int b43_phy_versioning(struct b43_wldev *dev)
 			else
 				tmp = 0x5205017F;
 		} else {
-			b43_write16(dev, B43_MMIO_RADIO_CONTROL,
-				    B43_RADIOCTL_ID);
+			b43_write16f(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_RADIOCTL_ID);
-			tmp |= (u32)b43_read16(dev, B43_MMIO_RADIO_DATA_HIGH)
-				<< 16;
+			b43_write16f(dev, B43_MMIO_RADIO_CONTROL,
+				     B43_RADIOCTL_ID);
+			tmp |= b43_read16(dev, B43_MMIO_RADIO_DATA_HIGH) << 16;
 		}
 		radio_manuf = (tmp & 0x00000FFF);
 		radio_id = (tmp & 0x0FFFF000) >> 12;
drivers/net/wireless/b43/phy_a.c +2 -2
index 25e4043..99c036f 100644
@@ -444,14 +444,14 @@ static inline u16 adjust_phyreg(struct b43_wldev *dev, u16 offset)
 static u16 b43_aphy_op_read(struct b43_wldev *dev, u16 reg)
 {
 	reg = adjust_phyreg(dev, reg);
-	b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
+	b43_write16f(dev, B43_MMIO_PHY_CONTROL, reg);
 	return b43_read16(dev, B43_MMIO_PHY_DATA);
 }
 
 static void b43_aphy_op_write(struct b43_wldev *dev, u16 reg, u16 value)
 {
 	reg = adjust_phyreg(dev, reg);
-	b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
+	b43_write16f(dev, B43_MMIO_PHY_CONTROL, reg);
 	b43_write16(dev, B43_MMIO_PHY_DATA, value);
 }
 
drivers/net/wireless/b43/phy_common.c +2 -2
index 08ca524..1dfc682 100644
@@ -278,7 +278,7 @@ u16 b43_phy_read(struct b43_wldev *dev, u16 reg)
 	if (dev->phy.ops->phy_read)
 		return dev->phy.ops->phy_read(dev, reg);
 
-	b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
+	b43_write16f(dev, B43_MMIO_PHY_CONTROL, reg);
 	return b43_read16(dev, B43_MMIO_PHY_DATA);
 }
 
@@ -294,7 +294,7 @@ void b43_phy_write(struct b43_wldev *dev, u16 reg, u16 value)
 	if (dev->phy.ops->phy_write)
 		return dev->phy.ops->phy_write(dev, reg, value);
 
-	b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
+	b43_write16f(dev, B43_MMIO_PHY_CONTROL, reg);
 	b43_write16(dev, B43_MMIO_PHY_DATA, value);
 }
 
drivers/net/wireless/b43/phy_g.c +4 -4
index 8f5c14b..727ce6e 100644
@@ -2555,13 +2555,13 @@ static void b43_gphy_op_exit(struct b43_wldev *dev)
 
 static u16 b43_gphy_op_read(struct b43_wldev *dev, u16 reg)
 {
-	b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
+	b43_write16f(dev, B43_MMIO_PHY_CONTROL, reg);
 	return b43_read16(dev, B43_MMIO_PHY_DATA);
 }
 
 static void b43_gphy_op_write(struct b43_wldev *dev, u16 reg, u16 value)
 {
-	b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
+	b43_write16f(dev, B43_MMIO_PHY_CONTROL, reg);
 	b43_write16(dev, B43_MMIO_PHY_DATA, value);
 }
 
@@ -2572,7 +2572,7 @@ static u16 b43_gphy_op_radio_read(struct b43_wldev *dev, u16 reg)
 	/* G-PHY needs 0x80 for read access. */
 	reg |= 0x80;
 
-	b43_write16(dev, B43_MMIO_RADIO_CONTROL, reg);
+	b43_write16f(dev, B43_MMIO_RADIO_CONTROL, reg);
 	return b43_read16(dev, B43_MMIO_RADIO_DATA_LOW);
 }
 
@@ -2581,7 +2581,7 @@ static void b43_gphy_op_radio_write(struct b43_wldev *dev, u16 reg, u16 value)
 	/* Register 1 is a 32-bit register. */
 	B43_WARN_ON(reg == 1);
 
-	b43_write16(dev, B43_MMIO_RADIO_CONTROL, reg);
+	b43_write16f(dev, B43_MMIO_RADIO_CONTROL, reg);
 	b43_write16(dev, B43_MMIO_RADIO_DATA_LOW, value);
 }
 
drivers/net/wireless/b43/phy_ht.c +3 -3
index 8b0b4b6..c4dc8b0 100644
@@ -1074,7 +1074,7 @@ static unsigned int b43_phy_ht_op_get_default_chan(struct b43_wldev *dev)
 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_write16f(dev, B43_MMIO_PHY_CONTROL, reg);
 	b43_write16(dev, B43_MMIO_PHY_DATA,
 		    (b43_read16(dev, B43_MMIO_PHY_DATA) & mask) | set);
 }
@@ -1084,14 +1084,14 @@ static u16 b43_phy_ht_op_radio_read(struct b43_wldev *dev, u16 reg)
 	/* HT-PHY needs 0x200 for read access */
 	reg |= 0x200;
 
-	b43_write16(dev, B43_MMIO_RADIO24_CONTROL, reg);
+	b43_write16f(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_write16f(dev, B43_MMIO_RADIO24_CONTROL, reg);
 	b43_write16(dev, B43_MMIO_RADIO24_DATA, value);
 }
 
drivers/net/wireless/b43/phy_lcn.c +3 -3
index bf29c3e..97461cc 100644
@@ -813,7 +813,7 @@ static void b43_phy_lcn_op_adjust_txpower(struct b43_wldev *dev)
 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_write16f(dev, B43_MMIO_PHY_CONTROL, reg);
 	b43_write16(dev, B43_MMIO_PHY_DATA,
 		    (b43_read16(dev, B43_MMIO_PHY_DATA) & mask) | set);
 }
@@ -823,14 +823,14 @@ static u16 b43_phy_lcn_op_radio_read(struct b43_wldev *dev, u16 reg)
 	/* LCN-PHY needs 0x200 for read access */
 	reg |= 0x200;
 
-	b43_write16(dev, B43_MMIO_RADIO24_CONTROL, reg);
+	b43_write16f(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_write16f(dev, B43_MMIO_RADIO24_CONTROL, reg);
 	b43_write16(dev, B43_MMIO_RADIO24_DATA, value);
 }
 
drivers/net/wireless/b43/phy_lp.c +3 -3
index 1e9bae6..058a9f2 100644
@@ -1988,7 +1988,7 @@ static void lpphy_calibration(struct b43_wldev *dev)
 static void b43_lpphy_op_maskset(struct b43_wldev *dev, u16 reg, u16 mask,
 				 u16 set)
 {
-	b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
+	b43_write16f(dev, B43_MMIO_PHY_CONTROL, reg);
 	b43_write16(dev, B43_MMIO_PHY_DATA,
 		    (b43_read16(dev, B43_MMIO_PHY_DATA) & mask) | set);
 }
@@ -2004,7 +2004,7 @@ static u16 b43_lpphy_op_radio_read(struct b43_wldev *dev, u16 reg)
 	} else
 		reg |= 0x200;
 
-	b43_write16(dev, B43_MMIO_RADIO_CONTROL, reg);
+	b43_write16f(dev, B43_MMIO_RADIO_CONTROL, reg);
 	return b43_read16(dev, B43_MMIO_RADIO_DATA_LOW);
 }
 
@@ -2013,7 +2013,7 @@ static void b43_lpphy_op_radio_write(struct b43_wldev *dev, u16 reg, u16 value)
 	/* Register 1 is a 32-bit register. */
 	B43_WARN_ON(reg == 1);
 
-	b43_write16(dev, B43_MMIO_RADIO_CONTROL, reg);
+	b43_write16f(dev, B43_MMIO_RADIO_CONTROL, reg);
 	b43_write16(dev, B43_MMIO_RADIO_DATA_LOW, value);
 }
 
drivers/net/wireless/b43/phy_n.c +3 -3
index 5565318..df64032 100644
@@ -6501,7 +6501,7 @@ static void b43_nphy_op_maskset(struct b43_wldev *dev, u16 reg, u16 mask,
 				 u16 set)
 {
 	check_phyreg(dev, reg);
-	b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
+	b43_write16f(dev, B43_MMIO_PHY_CONTROL, reg);
 	b43_maskset16(dev, B43_MMIO_PHY_DATA, mask, set);
 	dev->phy.writes_counter = 1;
 }
@@ -6516,7 +6516,7 @@ static u16 b43_nphy_op_radio_read(struct b43_wldev *dev, u16 reg)
 	else
 		reg |= 0x100;
 
-	b43_write16(dev, B43_MMIO_RADIO_CONTROL, reg);
+	b43_write16f(dev, B43_MMIO_RADIO_CONTROL, reg);
 	return b43_read16(dev, B43_MMIO_RADIO_DATA_LOW);
 }
 
@@ -6525,7 +6525,7 @@ static void b43_nphy_op_radio_write(struct b43_wldev *dev, u16 reg, u16 value)
 	/* Register 1 is a 32-bit register. */
 	B43_WARN_ON(dev->phy.rev < 7 && reg == 1);
 
-	b43_write16(dev, B43_MMIO_RADIO_CONTROL, reg);
+	b43_write16f(dev, B43_MMIO_RADIO_CONTROL, reg);
 	b43_write16(dev, B43_MMIO_RADIO_DATA_LOW, value);
 }
 
Signature · 1 line
1.8.4.5