* [PATCH 1/3] b43: N-PHY: band width setting with dumb clock control call
2010-12-22 19:11 [PATCH 0/3] b43: Is this series still valid?? John W. Linville
@ 2010-12-22 19:11 ` John W. Linville
2010-12-22 19:11 ` [PATCH 2/3] b43: N-PHY: add sub calls of band width setting John W. Linville
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: John W. Linville @ 2010-12-22 19:11 UTC (permalink / raw)
To: linux-wireless; +Cc: Rafał Miłecki, John W. Linville
From: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
---
drivers/net/wireless/b43/phy_common.c | 20 ++++++++++++++++++++
drivers/net/wireless/b43/phy_common.h | 11 +++++++++++
drivers/net/wireless/b43/phy_n.c | 2 +-
3 files changed, 32 insertions(+), 1 deletions(-)
diff --git a/drivers/net/wireless/b43/phy_common.c b/drivers/net/wireless/b43/phy_common.c
index b5c5ce9..113b9f1 100644
--- a/drivers/net/wireless/b43/phy_common.c
+++ b/drivers/net/wireless/b43/phy_common.c
@@ -482,3 +482,23 @@ struct b43_c32 b43_cordic(int theta)
return ret;
}
+
+/* http://bcm-v4.sipsolutions.net/802.11/PHY/ClkCtlClk */
+static void b43_clock_control(struct b43_wldev *dev, u32 mode)
+{
+ /* TODO */
+}
+
+/* http://bcm-v4.sipsolutions.net/802.11/PHY/BmacBwSet */
+void b43_bmac_set_b_width(struct b43_wldev *dev, u8 b_width)
+{
+ bool fast = dev->phy.forcefastclk;
+ if (!fast)
+ b43_clock_control(dev, 0);
+ dev->phy.b_width = b_width;
+ b43_read32(dev, B43_MMIO_MACCTL); /* flush writes */
+ /* TODO: Call PHY BMAC Reset */
+ dev->phy.ops->init(dev);
+ if (fast)
+ b43_clock_control(dev, 2);
+}
diff --git a/drivers/net/wireless/b43/phy_common.h b/drivers/net/wireless/b43/phy_common.h
index 2401bee..2dd04cf 100644
--- a/drivers/net/wireless/b43/phy_common.h
+++ b/drivers/net/wireless/b43/phy_common.h
@@ -222,6 +222,9 @@ struct b43_phy {
bool supports_2ghz;
bool supports_5ghz;
+ /* Band width */
+ u8 b_width;
+
/* HT info */
bool is_40mhz;
@@ -265,6 +268,9 @@ struct b43_phy {
/* PHY TX errors counter. */
atomic_t txerr_cnt;
+ /* Clock */
+ bool forcefastclk;
+
#ifdef CONFIG_B43_DEBUG
/* PHY registers locked (w.r.t. firmware) */
bool phy_locked;
@@ -440,4 +446,9 @@ bool b43_channel_type_is_40mhz(enum nl80211_channel_type channel_type);
struct b43_c32 b43_cordic(int theta);
+/**
+ * b43_bmac_set_b_width - Set band width
+ */
+void b43_bmac_set_b_width(struct b43_wldev *dev, u8 b_width);
+
#endif /* LINUX_B43_PHY_COMMON_H_ */
diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c
index a1aa570..3f2ce92 100644
--- a/drivers/net/wireless/b43/phy_n.c
+++ b/drivers/net/wireless/b43/phy_n.c
@@ -3595,7 +3595,7 @@ static int b43_nphy_set_channel(struct b43_wldev *dev,
if (b43_channel_type_is_40mhz(phy->channel_type) !=
b43_channel_type_is_40mhz(channel_type))
- ; /* TODO: BMAC BW Set (channel_type) */
+ b43_bmac_set_b_width(dev, channel_type);
if (channel_type == NL80211_CHAN_HT40PLUS)
b43_phy_set(dev, B43_NPHY_RXCTL,
--
1.7.3.3
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 2/3] b43: N-PHY: add sub calls of band width setting
2010-12-22 19:11 [PATCH 0/3] b43: Is this series still valid?? John W. Linville
2010-12-22 19:11 ` [PATCH 1/3] b43: N-PHY: band width setting with dumb clock control call John W. Linville
@ 2010-12-22 19:11 ` John W. Linville
2010-12-22 19:11 ` [PATCH 3/3] b43: N-PHY: check for clk when setting RX core state John W. Linville
2010-12-22 19:20 ` [PATCH 0/3] b43: Is this series still valid?? Rafał Miłecki
3 siblings, 0 replies; 6+ messages in thread
From: John W. Linville @ 2010-12-22 19:11 UTC (permalink / raw)
To: linux-wireless; +Cc: Rafał Miłecki, John W. Linville
From: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
---
drivers/net/wireless/b43/b43.h | 1 +
drivers/net/wireless/b43/phy_common.c | 150 ++++++++++++++++++++++++++++++++-
drivers/net/wireless/b43/phy_common.h | 7 ++
3 files changed, 157 insertions(+), 1 deletions(-)
diff --git a/drivers/net/wireless/b43/b43.h b/drivers/net/wireless/b43/b43.h
index bd4cb75..2798a9e 100644
--- a/drivers/net/wireless/b43/b43.h
+++ b/drivers/net/wireless/b43/b43.h
@@ -57,6 +57,7 @@
#define B43_MMIO_TSF_CFP_REP 0x188
#define B43_MMIO_TSF_CFP_START 0x18C
#define B43_MMIO_TSF_CFP_MAXDUR 0x190
+#define B43_MMIO_CLKCTL 0x1E0 /* clock control status */
/* 32-bit DMA */
#define B43_MMIO_DMA32_BASE0 0x200
diff --git a/drivers/net/wireless/b43/phy_common.c b/drivers/net/wireless/b43/phy_common.c
index 113b9f1..9b94cdc 100644
--- a/drivers/net/wireless/b43/phy_common.c
+++ b/drivers/net/wireless/b43/phy_common.c
@@ -483,10 +483,158 @@ struct b43_c32 b43_cordic(int theta)
return ret;
}
+/* http://bcm-v4.sipsolutions.net/802.11/NcClkCtlCc */
+static bool b43_no_check_clock_control_chip_common(struct b43_wldev *dev,
+ u32 mode)
+{
+ /* TODO: this is temporary hack */
+ return (mode == 0);
+}
+
+/* http://bcm-v4.sipsolutions.net/802.11/ClkCtlCc */
+static bool b43_clock_control_chip_common(struct b43_wldev *dev, u32 mode)
+{
+ struct ssb_bus *bus = dev->dev->bus;
+ u16 chip_id = bus->chip_id;
+ u16 chip_rev = bus->chip_rev;
+ /* TODO: specs distinguish PCI and PCIe */
+ bool pci = (bus->bustype == SSB_BUSTYPE_PCI);
+
+ if (dev->dev->id.revision < 6)
+ return false;
+ if (pci && ((chip_id == 0x4311 && chip_rev < 2) ||
+ (pci && chip_id == 0x4321) ||
+ (pci && chip_id == 0x4716)))
+ return (mode == 0);
+ return b43_no_check_clock_control_chip_common(dev, mode);
+}
+
+/* http://bcm-v4.sipsolutions.net/802.11/PHY/BmacWaitForWake */
+static void b43_phy_bmac_wait_for_wake(struct b43_wldev *dev)
+{
+ u8 core_rev = dev->dev->bus->pcicore.dev->id.revision;
+ u16 tmp, i;
+
+ if (core_rev == 4) {
+ udelay(5);
+ return;
+ }
+
+ if (dev->phy.type == B43_PHYTYPE_G && core_rev == 5)
+ udelay(2000);
+ else
+ udelay(40);
+
+ for (i = 0; i < 1500; i++) {
+ tmp = b43_shm_read16(dev, B43_SHM_SHARED,
+ B43_SHM_SH_UCODESTAT);
+ if (tmp == B43_SHM_SH_UCODESTAT_SLEEP) {
+ i = 0;
+ break;
+ }
+ udelay(10);
+ }
+ if (i)
+ b43err(dev->wl, "ucode wake up timeout\n");
+}
+
+/* http://bcm-v4.sipsolutions.net/802.11/PHY/MctrlWrite */
+static void b43_phy_mac_control_write(struct b43_wldev *dev)
+{
+ u32 tmp = dev->phy.maccontrol;
+ if (dev->phy.wake_override)
+ tmp |= B43_MACCTL_AWAKE;
+ if (dev->phy.mute_override)
+ tmp &= ~B43_MACCTL_AP;
+ tmp |= B43_MACCTL_INFRA;
+ b43_write32(dev, B43_MMIO_MACCTL, tmp);
+}
+
+/* http://bcm-v4.sipsolutions.net/802.11/PHY/UcodeWakeOverrideSet */
+static void b43_ucode_wake_override_set(struct b43_wldev *dev, u32 override)
+{
+ dev->phy.wake_override |= override;
+ if (dev->phy.wake_override || dev->phy.maccontrol & B43_MACCTL_AWAKE)
+ return;
+ b43_phy_mac_control_write(dev);
+ b43_phy_bmac_wait_for_wake(dev);
+}
+
+/* http://bcm-v4.sipsolutions.net/802.11/PHY/UcodeWakeOverrideClear */
+static void b43_ucode_wake_override_clear(struct b43_wldev *dev, u32 override)
+{
+ dev->phy.wake_override &= ~override;
+ if (dev->phy.wake_override != (dev->phy.maccontrol & B43_MACCTL_AWAKE))
+ return;
+ b43_phy_mac_control_write(dev);
+}
+
/* http://bcm-v4.sipsolutions.net/802.11/PHY/ClkCtlClk */
static void b43_clock_control(struct b43_wldev *dev, u32 mode)
{
- /* TODO */
+ struct b43_phy *phy = &dev->phy;
+ struct ssb_bus *bus = dev->dev->bus;
+ u8 core_rev = bus->pcicore.dev->id.revision;
+ u16 i;
+ u32 clkctl;
+ bool wakeup;
+
+ if (bus->chipco.capabilities & SSB_CHIPCO_CAP_PMU) { /* PMU Present */
+ B43_WARN_ON(core_rev < 20);
+ if (phy->clk) {
+ bool tmp = (bus->chipco.pmu.rev == 0 &&
+ (b43_read32(dev, B43_MMIO_CLKCTL) & 0x12));
+
+ if (mode == 0) {
+ clkctl = b43_read32(dev, B43_MMIO_CLKCTL);
+ clkctl |= 0x2;
+ b43_write32(dev, B43_MMIO_CLKCTL, clkctl);
+ udelay(33);
+ }
+
+ if (mode == 0 || tmp) {
+ for (i = 0; i < 1500; i++) {
+ clkctl = b43_read32(dev, B43_MMIO_CLKCTL);
+ if ((clkctl & 0x20000) == 0) {
+ i = 0;
+ break;
+ }
+ udelay(10);
+ }
+ if (i)
+ b43err(dev->wl, "clock timeout\n");
+ }
+
+ if (mode != 0 && tmp) {
+ clkctl = b43_read32(dev, B43_MMIO_CLKCTL);
+ clkctl &= ~0x2;
+ b43_write32(dev, B43_MMIO_CLKCTL, clkctl);
+ }
+ }
+ phy->forcefastclk = (mode == 0);
+ } else {
+ B43_WARN_ON(core_rev >= 20);
+
+ wakeup = (core_rev < 9);
+ if (phy->up && wakeup)
+ b43_ucode_wake_override_set(dev, 1);
+
+ phy->forcefastclk = b43_clock_control_chip_common(dev, mode);
+ if (core_rev < 11) {
+ if (phy->forcefastclk)
+ ; /* TODO: b43_mhf(dev, 0, 0x400, 0x400, 3); */
+ else
+ ; /* TODO: b43_mhf(dev, 0, 0x400, 0, 3); */
+ }
+
+ if (phy->forcefastclk)
+ phy->wake_override |= 0x10;
+ else
+ phy->wake_override &= ~0x10;
+
+ if (phy->up && wakeup)
+ b43_ucode_wake_override_clear(dev, 1);
+ }
}
/* http://bcm-v4.sipsolutions.net/802.11/PHY/BmacBwSet */
diff --git a/drivers/net/wireless/b43/phy_common.h b/drivers/net/wireless/b43/phy_common.h
index 2dd04cf..000c503 100644
--- a/drivers/net/wireless/b43/phy_common.h
+++ b/drivers/net/wireless/b43/phy_common.h
@@ -269,8 +269,15 @@ struct b43_phy {
atomic_t txerr_cnt;
/* Clock */
+ u32 clk;
bool forcefastclk;
+ bool up;
+ u32 maccontrol;
+
+ u32 wake_override;
+ u32 mute_override;
+
#ifdef CONFIG_B43_DEBUG
/* PHY registers locked (w.r.t. firmware) */
bool phy_locked;
--
1.7.3.3
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 3/3] b43: N-PHY: check for clk when setting RX core state
2010-12-22 19:11 [PATCH 0/3] b43: Is this series still valid?? John W. Linville
2010-12-22 19:11 ` [PATCH 1/3] b43: N-PHY: band width setting with dumb clock control call John W. Linville
2010-12-22 19:11 ` [PATCH 2/3] b43: N-PHY: add sub calls of band width setting John W. Linville
@ 2010-12-22 19:11 ` John W. Linville
2010-12-22 19:20 ` [PATCH 0/3] b43: Is this series still valid?? Rafał Miłecki
3 siblings, 0 replies; 6+ messages in thread
From: John W. Linville @ 2010-12-22 19:11 UTC (permalink / raw)
To: linux-wireless; +Cc: Rafał Miłecki, John W. Linville
From: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
---
drivers/net/wireless/b43/phy_n.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c
index 3f2ce92..d50e880 100644
--- a/drivers/net/wireless/b43/phy_n.c
+++ b/drivers/net/wireless/b43/phy_n.c
@@ -3282,7 +3282,7 @@ static void b43_nphy_set_rx_core_state(struct b43_wldev *dev, u8 mask)
nphy->phyrxchain = mask;
- if (0 /* FIXME clk */)
+ if (!phy->clk)
return;
b43_mac_suspend(dev);
--
1.7.3.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 0/3] b43: Is this series still valid??
2010-12-22 19:11 [PATCH 0/3] b43: Is this series still valid?? John W. Linville
` (2 preceding siblings ...)
2010-12-22 19:11 ` [PATCH 3/3] b43: N-PHY: check for clk when setting RX core state John W. Linville
@ 2010-12-22 19:20 ` Rafał Miłecki
2010-12-22 20:02 ` John W. Linville
3 siblings, 1 reply; 6+ messages in thread
From: Rafał Miłecki @ 2010-12-22 19:20 UTC (permalink / raw)
To: John W. Linville; +Cc: linux-wireless
2010/12/22 John W. Linville <linville@tuxdriver.com>:
> I found this old series pending in my queue from months ago. I sat on
> them because they had some discussion and never got reposted.
>
> Looking closer, the discussion never amounted to a NAK. So, I tried
> applying them, and they applied with only minor massaging.
>
> So, are these still valid?
>
> Let me know...
The way we call init in one of patches may be incorrect, I'm not sure
if we still need to keep b_width (from other patch). I think it'll be
better to ignore that patches for now.
--
Rafał
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH 0/3] b43: Is this series still valid??
2010-12-22 19:20 ` [PATCH 0/3] b43: Is this series still valid?? Rafał Miłecki
@ 2010-12-22 20:02 ` John W. Linville
0 siblings, 0 replies; 6+ messages in thread
From: John W. Linville @ 2010-12-22 20:02 UTC (permalink / raw)
To: Rafał Miłecki; +Cc: linux-wireless
On Wed, Dec 22, 2010 at 08:20:18PM +0100, Rafał Miłecki wrote:
> 2010/12/22 John W. Linville <linville@tuxdriver.com>:
> > I found this old series pending in my queue from months ago. I sat on
> > them because they had some discussion and never got reposted.
> >
> > Looking closer, the discussion never amounted to a NAK. So, I tried
> > applying them, and they applied with only minor massaging.
> >
> > So, are these still valid?
> >
> > Let me know...
>
> The way we call init in one of patches may be incorrect, I'm not sure
> if we still need to keep b_width (from other patch). I think it'll be
> better to ignore that patches for now.
OK, I'll drop them -- please repost if/when they are ready...
John
--
John W. Linville Someday the world will need a hero, and you
linville@tuxdriver.com might be all we have. Be ready.
^ permalink raw reply [flat|nested] 6+ messages in thread