Commit d1591314 authored by Michael Buesch's avatar Michael Buesch Committed by David S. Miller

b43: Add NPHY channel switch code

This adds code and table data for channel switching on NPHYs.
Signed-off-by: default avatarMichael Buesch <mb@bu3sch.de>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 53a6e234
...@@ -35,12 +35,78 @@ void b43_nphy_xmitpower(struct b43_wldev *dev) ...@@ -35,12 +35,78 @@ void b43_nphy_xmitpower(struct b43_wldev *dev)
{//TODO {//TODO
} }
static void b43_chantab_radio_upload(struct b43_wldev *dev,
const struct b43_nphy_channeltab_entry *e)
{
b43_radio_write16(dev, B2055_PLL_REF, e->radio_pll_ref);
b43_radio_write16(dev, B2055_RF_PLLMOD0, e->radio_rf_pllmod0);
b43_radio_write16(dev, B2055_RF_PLLMOD1, e->radio_rf_pllmod1);
b43_radio_write16(dev, B2055_VCO_CAPTAIL, e->radio_vco_captail);
b43_radio_write16(dev, B2055_VCO_CAL1, e->radio_vco_cal1);
b43_radio_write16(dev, B2055_VCO_CAL2, e->radio_vco_cal2);
b43_radio_write16(dev, B2055_PLL_LFC1, e->radio_pll_lfc1);
b43_radio_write16(dev, B2055_PLL_LFR1, e->radio_pll_lfr1);
b43_radio_write16(dev, B2055_PLL_LFC2, e->radio_pll_lfc2);
b43_radio_write16(dev, B2055_LGBUF_CENBUF, e->radio_lgbuf_cenbuf);
b43_radio_write16(dev, B2055_LGEN_TUNE1, e->radio_lgen_tune1);
b43_radio_write16(dev, B2055_LGEN_TUNE2, e->radio_lgen_tune2);
b43_radio_write16(dev, B2055_C1_LGBUF_ATUNE, e->radio_c1_lgbuf_atune);
b43_radio_write16(dev, B2055_C1_LGBUF_GTUNE, e->radio_c1_lgbuf_gtune);
b43_radio_write16(dev, B2055_C1_RX_RFR1, e->radio_c1_rx_rfr1);
b43_radio_write16(dev, B2055_C1_TX_PGAPADTN, e->radio_c1_tx_pgapadtn);
b43_radio_write16(dev, B2055_C1_TX_MXBGTRIM, e->radio_c1_tx_mxbgtrim);
b43_radio_write16(dev, B2055_C2_LGBUF_ATUNE, e->radio_c2_lgbuf_atune);
b43_radio_write16(dev, B2055_C2_LGBUF_GTUNE, e->radio_c2_lgbuf_gtune);
b43_radio_write16(dev, B2055_C2_RX_RFR1, e->radio_c2_rx_rfr1);
b43_radio_write16(dev, B2055_C2_TX_PGAPADTN, e->radio_c2_tx_pgapadtn);
b43_radio_write16(dev, B2055_C2_TX_MXBGTRIM, e->radio_c2_tx_mxbgtrim);
}
static void b43_chantab_phy_upload(struct b43_wldev *dev,
const struct b43_nphy_channeltab_entry *e)
{
b43_phy_write(dev, B43_NPHY_BW1A, e->phy_bw1a);
b43_phy_write(dev, B43_NPHY_BW2, e->phy_bw2);
b43_phy_write(dev, B43_NPHY_BW3, e->phy_bw3);
b43_phy_write(dev, B43_NPHY_BW4, e->phy_bw4);
b43_phy_write(dev, B43_NPHY_BW5, e->phy_bw5);
b43_phy_write(dev, B43_NPHY_BW6, e->phy_bw6);
}
static void b43_nphy_tx_power_fix(struct b43_wldev *dev)
{
//TODO
}
/* Tune the hardware to a new channel. Don't call this directly. /* Tune the hardware to a new channel. Don't call this directly.
* Use b43_radio_selectchannel() */ * Use b43_radio_selectchannel() */
void b43_nphy_selectchannel(struct b43_wldev *dev, u8 channel) int b43_nphy_selectchannel(struct b43_wldev *dev, u8 channel)
{ {
const struct b43_nphy_channeltab_entry *tabent;
//TODO tabent = b43_nphy_get_chantabent(dev, channel);
if (!tabent)
return -ESRCH;
//FIXME enable/disable band select upper20 in RXCTL
if (0 /*FIXME 5Ghz*/)
b43_radio_maskset(dev, B2055_MASTER1, 0xFF8F, 0x20);
else
b43_radio_maskset(dev, B2055_MASTER1, 0xFF8F, 0x50);
b43_chantab_radio_upload(dev, tabent);
udelay(50);
b43_radio_write16(dev, B2055_VCO_CAL10, 5);
b43_radio_write16(dev, B2055_VCO_CAL10, 45);
b43_radio_write16(dev, B2055_VCO_CAL10, 65);
udelay(300);
if (0 /*FIXME 5Ghz*/)
b43_phy_set(dev, B43_NPHY_BANDCTL, B43_NPHY_BANDCTL_5GHZ);
else
b43_phy_mask(dev, B43_NPHY_BANDCTL, ~B43_NPHY_BANDCTL_5GHZ);
b43_chantab_phy_upload(dev, tabent);
b43_nphy_tx_power_fix(dev);
return 0;
} }
static void b43_radio_init2055_pre(struct b43_wldev *dev) static void b43_radio_init2055_pre(struct b43_wldev *dev)
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#define B43_NPHY_CHANNEL B43_PHY_N(0x005) /* Channel */ #define B43_NPHY_CHANNEL B43_PHY_N(0x005) /* Channel */
#define B43_NPHY_TXERR B43_PHY_N(0x007) /* TX error */ #define B43_NPHY_TXERR B43_PHY_N(0x007) /* TX error */
#define B43_NPHY_BANDCTL B43_PHY_N(0x009) /* Band control */ #define B43_NPHY_BANDCTL B43_PHY_N(0x009) /* Band control */
#define B43_NPHY_BANDCTL_5GHZ 0x0001 /* Use the 5GHz band */
#define B43_NPHY_4WI_ADDR B43_PHY_N(0x00B) /* Four-wire bus address */ #define B43_NPHY_4WI_ADDR B43_PHY_N(0x00B) /* Four-wire bus address */
#define B43_NPHY_4WI_DATAHI B43_PHY_N(0x00C) /* Four-wire bus data high */ #define B43_NPHY_4WI_DATAHI B43_PHY_N(0x00C) /* Four-wire bus data high */
#define B43_NPHY_4WI_DATALO B43_PHY_N(0x00D) /* Four-wire bus data low */ #define B43_NPHY_4WI_DATALO B43_PHY_N(0x00D) /* Four-wire bus data low */
...@@ -917,7 +918,7 @@ int b43_phy_initn(struct b43_wldev *dev); ...@@ -917,7 +918,7 @@ int b43_phy_initn(struct b43_wldev *dev);
void b43_nphy_radio_turn_on(struct b43_wldev *dev); void b43_nphy_radio_turn_on(struct b43_wldev *dev);
void b43_nphy_radio_turn_off(struct b43_wldev *dev); void b43_nphy_radio_turn_off(struct b43_wldev *dev);
void b43_nphy_selectchannel(struct b43_wldev *dev, u8 channel); int b43_nphy_selectchannel(struct b43_wldev *dev, u8 channel);
void b43_nphy_xmitpower(struct b43_wldev *dev); void b43_nphy_xmitpower(struct b43_wldev *dev);
void b43_nphy_set_rxantenna(struct b43_wldev *dev, int antenna); void b43_nphy_set_rxantenna(struct b43_wldev *dev, int antenna);
......
...@@ -3883,7 +3883,8 @@ int b43_radio_selectchannel(struct b43_wldev *dev, ...@@ -3883,7 +3883,8 @@ int b43_radio_selectchannel(struct b43_wldev *dev,
struct b43_phy *phy = &dev->phy; struct b43_phy *phy = &dev->phy;
u16 r8, tmp; u16 r8, tmp;
u16 freq; u16 freq;
u16 channelcookie; u16 channelcookie, savedcookie;
int err = 0;
if (channel == 0xFF) { if (channel == 0xFF) {
switch (phy->type) { switch (phy->type) {
...@@ -3910,12 +3911,15 @@ int b43_radio_selectchannel(struct b43_wldev *dev, ...@@ -3910,12 +3911,15 @@ int b43_radio_selectchannel(struct b43_wldev *dev,
if (0 /*FIXME on 5Ghz */) if (0 /*FIXME on 5Ghz */)
channelcookie |= 0x100; channelcookie |= 0x100;
//FIXME set 40Mhz flag if required //FIXME set 40Mhz flag if required
savedcookie = b43_shm_read16(dev, B43_SHM_SHARED, B43_SHM_SH_CHAN);
b43_shm_write16(dev, B43_SHM_SHARED, B43_SHM_SH_CHAN, channelcookie); b43_shm_write16(dev, B43_SHM_SHARED, B43_SHM_SH_CHAN, channelcookie);
switch (phy->type) { switch (phy->type) {
case B43_PHYTYPE_A: case B43_PHYTYPE_A:
if (channel > 200) if (channel > 200) {
return -EINVAL; err = -EINVAL;
goto out;
}
freq = channel2freq_a(channel); freq = channel2freq_a(channel);
r8 = b43_radio_read16(dev, 0x0008); r8 = b43_radio_read16(dev, 0x0008);
...@@ -3964,8 +3968,10 @@ int b43_radio_selectchannel(struct b43_wldev *dev, ...@@ -3964,8 +3968,10 @@ int b43_radio_selectchannel(struct b43_wldev *dev,
b43_phy_xmitpower(dev); //FIXME correct? b43_phy_xmitpower(dev); //FIXME correct?
break; break;
case B43_PHYTYPE_G: case B43_PHYTYPE_G:
if ((channel < 1) || (channel > 14)) if ((channel < 1) || (channel > 14)) {
return -EINVAL; err = -EINVAL;
goto out;
}
if (synthetic_pu_workaround) if (synthetic_pu_workaround)
b43_synth_pu_workaround(dev, channel); b43_synth_pu_workaround(dev, channel);
...@@ -3990,7 +3996,9 @@ int b43_radio_selectchannel(struct b43_wldev *dev, ...@@ -3990,7 +3996,9 @@ int b43_radio_selectchannel(struct b43_wldev *dev,
} }
break; break;
case B43_PHYTYPE_N: case B43_PHYTYPE_N:
b43_nphy_selectchannel(dev, channel); err = b43_nphy_selectchannel(dev, channel);
if (err)
goto out;
break; break;
default: default:
B43_WARN_ON(1); B43_WARN_ON(1);
...@@ -3999,8 +4007,12 @@ int b43_radio_selectchannel(struct b43_wldev *dev, ...@@ -3999,8 +4007,12 @@ int b43_radio_selectchannel(struct b43_wldev *dev,
phy->channel = channel; phy->channel = channel;
/* Wait for the radio to tune to the channel and stabilize. */ /* Wait for the radio to tune to the channel and stabilize. */
msleep(8); msleep(8);
out:
return 0; if (err) {
b43_shm_write16(dev, B43_SHM_SHARED,
B43_SHM_SH_CHAN, savedcookie);
}
return err;
} }
void b43_radio_turn_on(struct b43_wldev *dev) void b43_radio_turn_on(struct b43_wldev *dev)
......
This diff is collapsed.
...@@ -4,6 +4,46 @@ ...@@ -4,6 +4,46 @@
#include <linux/types.h> #include <linux/types.h>
struct b43_nphy_channeltab_entry {
/* The channel number */
u8 channel;
/* Radio register values on channelswitch */
u8 radio_pll_ref;
u8 radio_rf_pllmod0;
u8 radio_rf_pllmod1;
u8 radio_vco_captail;
u8 radio_vco_cal1;
u8 radio_vco_cal2;
u8 radio_pll_lfc1;
u8 radio_pll_lfr1;
u8 radio_pll_lfc2;
u8 radio_lgbuf_cenbuf;
u8 radio_lgen_tune1;
u8 radio_lgen_tune2;
u8 radio_c1_lgbuf_atune;
u8 radio_c1_lgbuf_gtune;
u8 radio_c1_rx_rfr1;
u8 radio_c1_tx_pgapadtn;
u8 radio_c1_tx_mxbgtrim;
u8 radio_c2_lgbuf_atune;
u8 radio_c2_lgbuf_gtune;
u8 radio_c2_rx_rfr1;
u8 radio_c2_tx_pgapadtn;
u8 radio_c2_tx_mxbgtrim;
/* PHY register values on channelswitch */
u16 phy_bw1a;
u16 phy_bw2;
u16 phy_bw3;
u16 phy_bw4;
u16 phy_bw5;
u16 phy_bw6;
/* The channel frequency in MHz */
u16 freq;
/* An unknown value */
u16 unk2;
};
struct b43_wldev; struct b43_wldev;
/* Upload the default register value table. /* Upload the default register value table.
...@@ -14,4 +54,10 @@ void b2055_upload_inittab(struct b43_wldev *dev, ...@@ -14,4 +54,10 @@ void b2055_upload_inittab(struct b43_wldev *dev,
bool ghz5, bool ignore_uploadflag); bool ghz5, bool ignore_uploadflag);
/* Get the NPHY Channel Switch Table entry for a channel number.
* Returns NULL on failure to find an entry. */
const struct b43_nphy_channeltab_entry *
b43_nphy_get_chantabent(struct b43_wldev *dev, u8 channel);
#endif /* B43_TABLES_NPHY_H_ */ #endif /* B43_TABLES_NPHY_H_ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment