Skip to content

Commit 1f21de5

Browse files
rmileckilinvjw
authored andcommitted
b43: HT-PHY: Implement band switching
It works pretty much the same way as in N-PHY. Signed-off-by: Rafał Miłecki <zajec5@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
1 parent 48bf43f commit 1f21de5

3 files changed

Lines changed: 40 additions & 6 deletions

File tree

‎drivers/net/wireless/b43/b43.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,11 @@ enum {
476476
#define B43_MACCMD_CCA 0x00000008 /* Clear channel assessment */
477477
#define B43_MACCMD_BGNOISE 0x00000010 /* Background noise */
478478

479+
/* B43_MMIO_PSM_PHY_HDR bits */
480+
#define B43_PSM_HDR_MAC_PHY_RESET 0x00000001
481+
#define B43_PSM_HDR_MAC_PHY_CLOCK_EN 0x00000002
482+
#define B43_PSM_HDR_MAC_PHY_FORCE_CLK 0x00000004
483+
479484
/* See BCMA_CLKCTLST_EXTRESREQ and BCMA_CLKCTLST_EXTRESST */
480485
#define B43_BCMA_CLKCTLST_80211_PLL_REQ 0x00000100
481486
#define B43_BCMA_CLKCTLST_PHY_PLL_REQ 0x00000200

‎drivers/net/wireless/b43/phy_ht.c‎

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,26 @@ static void b43_phy_ht_bphy_init(struct b43_wldev *dev)
321321
b43_phy_write(dev, B43_PHY_N_BMODE(0x38), 0x668);
322322
}
323323

324+
static void b43_phy_ht_bphy_reset(struct b43_wldev *dev, bool reset)
325+
{
326+
u16 tmp;
327+
328+
tmp = b43_read16(dev, B43_MMIO_PSM_PHY_HDR);
329+
b43_write16(dev, B43_MMIO_PSM_PHY_HDR,
330+
tmp | B43_PSM_HDR_MAC_PHY_FORCE_CLK);
331+
332+
/* Put BPHY in or take it out of the reset */
333+
if (reset)
334+
b43_phy_set(dev, B43_PHY_B_BBCFG,
335+
B43_PHY_B_BBCFG_RSTCCA | B43_PHY_B_BBCFG_RSTRX);
336+
else
337+
b43_phy_mask(dev, B43_PHY_B_BBCFG,
338+
(u16)~(B43_PHY_B_BBCFG_RSTCCA |
339+
B43_PHY_B_BBCFG_RSTRX));
340+
341+
b43_write16(dev, B43_MMIO_PSM_PHY_HDR, tmp);
342+
}
343+
324344
/**************************************************
325345
* Samples
326346
**************************************************/
@@ -757,13 +777,19 @@ static void b43_phy_ht_channel_setup(struct b43_wldev *dev,
757777
const struct b43_phy_ht_channeltab_e_phy *e,
758778
struct ieee80211_channel *new_channel)
759779
{
760-
bool old_band_5ghz;
780+
if (new_channel->band == IEEE80211_BAND_5GHZ) {
781+
/* Switch to 2 GHz for a moment to access B-PHY regs */
782+
b43_phy_mask(dev, B43_PHY_HT_BANDCTL, ~B43_PHY_HT_BANDCTL_5GHZ);
783+
784+
b43_phy_ht_bphy_reset(dev, true);
785+
786+
/* Switch to 5 GHz */
787+
b43_phy_set(dev, B43_PHY_HT_BANDCTL, B43_PHY_HT_BANDCTL_5GHZ);
788+
} else {
789+
/* Switch to 2 GHz */
790+
b43_phy_mask(dev, B43_PHY_HT_BANDCTL, ~B43_PHY_HT_BANDCTL_5GHZ);
761791

762-
old_band_5ghz = b43_phy_read(dev, B43_PHY_HT_BANDCTL) & 0; /* FIXME */
763-
if (new_channel->band == IEEE80211_BAND_5GHZ && !old_band_5ghz) {
764-
/* TODO */
765-
} else if (new_channel->band == IEEE80211_BAND_2GHZ && old_band_5ghz) {
766-
/* TODO */
792+
b43_phy_ht_bphy_reset(dev, false);
767793
}
768794

769795
b43_phy_write(dev, B43_PHY_HT_BW1, e->bw1);

‎drivers/net/wireless/b43/phy_ht.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@
106106
#define B43_PHY_HT_TXPCTL_TARG_PWR2_C3_SHIFT 0
107107
#define B43_PHY_HT_TX_PCTL_STATUS_C3 B43_PHY_EXTG(0x169)
108108

109+
#define B43_PHY_B_BBCFG B43_PHY_N_BMODE(0x001)
110+
#define B43_PHY_B_BBCFG_RSTCCA 0x4000 /* Reset CCA */
111+
#define B43_PHY_B_BBCFG_RSTRX 0x8000 /* Reset RX */
109112
#define B43_PHY_HT_TEST B43_PHY_N_BMODE(0x00A)
110113

111114

0 commit comments

Comments
 (0)