b43: N-PHY: fixes for radio 0x2057
PATCH 1/2 b43: N-PHY: fixes for radio 0x2057
Enable initialization and update calibration code to fix:
b43-phy0 ERROR: Radio 0x2057 rcal timeout b43-phy0 debug: Radio 0x2057 rccal timeout b43-phy0 debug: Radio 0x2057 rccal timeout b43-phy0 ERROR: Radio 0x2057 rcal timeout
Signed-off-by Rafa? Mi?ecki <[email protected]>
--- drivers/net/wireless/b43/phy_n.c | 63 +++++++++++++++++++++++++++++------ drivers/net/wireless/b43/radio_2057.c | 20 +++++------ 2 files changed, 61 insertions(+), 22 deletions(-)
drivers/net/wireless/b43/phy_n.c +52 -11
@@ -590,7 +590,9 @@ static void b43_nphy_set_rf_sequence(struct b43_wldev *dev, u8 cmd,* Radio 0x2057 **************************************************/ -/* http://bcm-v4.sipsolutions.net/PHY/radio2057_rcal */ +/* Calibrate resistors in LPF of PLL? +* http://bcm-v4.sipsolutions.net/PHY/radio205x_rcal +*/ static u8 b43_radio_2057_rcal (struct b43_wldev *dev) {struct b43_phy *phy = &dev->phy;
@@ -603,15 +605,25 @@ static u8 b43_radio_2057_rcal(struct b43_wldev *dev)b43_radio_maskset (dev,0x1ca , ~0x2 ,0x1 ); } +/* Enable */ b43_radio_set (dev,R2057_RCAL_CONFIG ,0x1 );udelay (10 ); -b43_radio_set (dev,R2057_RCAL_CONFIG ,0x3 ); -if (!b43_radio_wait_value (dev,R2057_RCCAL_N1_1 ,1 ,1 ,100 ,1000000 )) { + +/* Start */ +b43_radio_set (dev,R2057_RCAL_CONFIG ,0x2 ); +usleep_range (100 ,200 ); + +/* Stop */ +b43_radio_mask (dev,R2057_RCAL_CONFIG , ~0x2 ); + +/* Wait and check for result */ +if (!b43_radio_wait_value (dev,R2057_RCAL_STATUS ,1 ,1 ,100 ,1000000 )) {b43err (dev->wl,"Radio 0x2057 rcal timeout\n" );return 0 ; } -b43_radio_mask (dev,R2057_RCAL_CONFIG , ~0x2 ); tmp =b43_radio_read (dev,R2057_RCAL_STATUS ) &0x3E ; + +/* Disable */ b43_radio_mask (dev,R2057_RCAL_CONFIG , ~0x1 );if (phy->radio_rev ==5 ) {
@@ -627,7 +639,9 @@ static u8 b43_radio_2057_rcal(struct b43_wldev *dev)return tmp &0x3e ; } -/* http://bcm-v4.sipsolutions.net/PHY/radio2057_rccal */ +/* Calibrate the internal RC oscillator? +* http://bcm-v4.sipsolutions.net/PHY/radio2057_rccal +*/ static u16 b43_radio_2057_rccal (struct b43_wldev *dev) {struct b43_phy *phy = &dev->phy;
@@ -635,49 +649,76 @@ static u16 b43_radio_2057_rccal(struct b43_wldev *dev) phy->radio_rev == 6);u16 tmp; +/* Setup cal */ if (special) {b43_radio_write (dev,R2057_RCCAL_MASTER ,0x61 );b43_radio_write (dev,R2057_RCCAL_TRC0 ,0xC0 ); }else { -b43_radio_write (dev,0x1AE ,0x61 ); +b43_radio_write (dev, R2057v7_RCCAL_MASTER,0x61 );b43_radio_write (dev,R2057_RCCAL_TRC0 ,0xE1 ); }b43_radio_write (dev,R2057_RCCAL_X1 ,0x6E ); + +/* Start, wait, stop */ b43_radio_write (dev,R2057_RCCAL_START_R1_Q1_P1 ,0x55 ); -if (!b43_radio_wait_value (dev,R2057_RCCAL_DONE_OSCCAP ,1 ,1 ,500 , +if (!b43_radio_wait_value (dev,R2057_RCCAL_DONE_OSCCAP ,2 ,2 ,500 ,5000000 ))b43dbg (dev->wl,"Radio 0x2057 rccal timeout\n" ); +usleep_range (35 ,70 );b43_radio_write (dev,R2057_RCCAL_START_R1_Q1_P1 ,0x15 ); +usleep_range (70 ,140 ); + +/* Setup cal */ if (special) {b43_radio_write (dev,R2057_RCCAL_MASTER ,0x69 );b43_radio_write (dev,R2057_RCCAL_TRC0 ,0xB0 ); }else { -b43_radio_write (dev,0x1AE ,0x69 ); +b43_radio_write (dev, R2057v7_RCCAL_MASTER,0x69 );b43_radio_write (dev,R2057_RCCAL_TRC0 ,0xD5 ); }b43_radio_write (dev,R2057_RCCAL_X1 ,0x6E ); + +/* Start, wait, stop */ +usleep_range (35 ,70 );b43_radio_write (dev,R2057_RCCAL_START_R1_Q1_P1 ,0x55 ); -if (!b43_radio_wait_value (dev,R2057_RCCAL_DONE_OSCCAP ,1 ,1 ,500 , +usleep_range (70 ,140 ); +if (!b43_radio_wait_value (dev,R2057_RCCAL_DONE_OSCCAP ,2 ,2 ,500 ,5000000 ))b43dbg (dev->wl,"Radio 0x2057 rccal timeout\n" ); +usleep_range (35 ,70 );b43_radio_write (dev,R2057_RCCAL_START_R1_Q1_P1 ,0x15 ); +usleep_range (70 ,140 ); + +/* Setup cal */ if (special) {b43_radio_write (dev,R2057_RCCAL_MASTER ,0x73 );b43_radio_write (dev,R2057_RCCAL_X1 ,0x28 );b43_radio_write (dev,R2057_RCCAL_TRC0 ,0xB0 ); }else { -b43_radio_write (dev,0x1AE ,0x73 ); +b43_radio_write (dev, R2057v7_RCCAL_MASTER,0x73 );b43_radio_write (dev,R2057_RCCAL_X1 ,0x6E );b43_radio_write (dev,R2057_RCCAL_TRC0 ,0x99 ); } + +/* Start, wait, stop */ +usleep_range (35 ,70 );b43_radio_write (dev,R2057_RCCAL_START_R1_Q1_P1 ,0x55 ); -if (!b43_radio_wait_value (dev,R2057_RCCAL_DONE_OSCCAP ,1 ,1 ,500 , +usleep_range (70 ,140 ); +if (!b43_radio_wait_value (dev,R2057_RCCAL_DONE_OSCCAP ,2 ,2 ,500 ,5000000 )) {b43err (dev->wl,"Radio 0x2057 rcal timeout\n" );return 0 ; } tmp =b43_radio_read (dev,R2057_RCCAL_DONE_OSCCAP ); +usleep_range (35 ,70 );b43_radio_write (dev,R2057_RCCAL_START_R1_Q1_P1 ,0x15 ); +usleep_range (70 ,140 ); + +if (special) +b43_radio_mask (dev,R2057_RCCAL_MASTER , ~0x1 ); +else +b43_radio_mask (dev, R2057v7_RCCAL_MASTER, ~0x1 ); +return tmp; }
drivers/net/wireless/b43/radio_2057.c +9 -11
@@ -26,7 +26,7 @@#include "radio_2057.h" #include "phy_common.h" -static u16 r2057_rev4_init[42 ][2 ] = { +static u16 r2057_rev4_init[][2 ] = { {0x0E ,0x20 }, {0x31 ,0x00 }, {0x32 ,0x00 }, {0x33 ,0x00 }, {0x35 ,0x26 }, {0x3C ,0xff }, {0x3D ,0xff }, {0x3E ,0xff }, {0x3F ,0xff }, {0x62 ,0x33 }, {0x8A ,0xf0 }, {0x8B ,0x10 },
@@ -40,7 +40,7 @@ static u16 r2057_rev4_init[42][2] = { { 0x1AB, 0x00 }, { 0x1AC, 0x00 }, }; -static u16 r2057_rev5_init[44 ][2 ] = { +static u16 r2057_rev5_init[][2 ] = { {0x00 ,0x00 }, {0x01 ,0x57 }, {0x02 ,0x20 }, {0x23 ,0x6 }, {0x31 ,0x00 }, {0x32 ,0x00 }, {0x33 ,0x00 }, {0x51 ,0x70 }, { 0x59, 0x88 }, { 0x5C, 0x20 }, { 0x62, 0x33 }, { 0x63, 0x0f },
@@ -54,7 +54,7 @@ static u16 r2057_rev5_init[44][2] = { { 0x1AC, 0x00 }, { 0x1B7, 0x0c }, { 0x1C1, 0x01 }, { 0x1C2, 0x80 }, }; -static u16 r2057_rev5a_init[45 ][2 ] = { +static u16 r2057_rev5a_init[][2 ] = { {0x00 ,0x15 }, {0x01 ,0x57 }, {0x02 ,0x20 }, {0x23 ,0x6 }, {0x31 ,0x00 }, {0x32 ,0x00 }, {0x33 ,0x00 }, {0x51 ,0x70 }, { 0x59, 0x88 }, { 0x5C, 0x20 }, { 0x62, 0x33 }, { 0x63, 0x0f },
@@ -69,7 +69,7 @@ static u16 r2057_rev5a_init[45][2] = { { 0x1C2, 0x80 }, }; -static u16 r2057_rev7_init[54 ][2 ] = { +static u16 r2057_rev7_init[][2 ] = { {0x00 ,0x00 }, {0x01 ,0x57 }, {0x02 ,0x20 }, {0x31 ,0x00 }, {0x32 ,0x00 }, {0x33 ,0x00 }, {0x51 ,0x70 }, {0x59 ,0x88 }, { 0x5C, 0x20 }, { 0x62, 0x33 }, { 0x63, 0x0f }, { 0x64, 0x13 },
@@ -86,7 +86,7 @@ static u16 r2057_rev7_init[54][2] = { { 0x1B7, 0x05 }, { 0x1C2, 0xa0 }, }; -static u16 r2057_rev8_init[54 ][2 ] = { +static u16 r2057_rev8_init[][2 ] = { {0x00 ,0x08 }, {0x01 ,0x57 }, {0x02 ,0x20 }, {0x31 ,0x00 }, {0x32 ,0x00 }, {0x33 ,0x00 }, {0x51 ,0x70 }, {0x59 ,0x88 }, { 0x5C, 0x20 }, { 0x62, 0x33 }, { 0x63, 0x0f }, { 0x64, 0x0f },
@@ -130,12 +130,10 @@ void r2057_upload_inittabs(struct b43_wldev *dev) } } +B43_WARN_ON (!table); +if (table) { -for (i =0 ; i <10 ; i++) { -pr_info ("radio_write 0x%X " , *table); - table++; -pr_info ("0x%X\n" , *table); - table++; - } +for (i =0 ; i < size; i++, table +=2 ) +b43_radio_write (dev, table[0 ], table[1 ]); } }
Signature · 1 line
1.8.4.5
PATCH 2/2 b43: N-PHY: complete generic support for 0x2057 radio
It doesn't include any device (radio revision) specific code yet, so it isn't really usable. As the commit says, it's just some generic code.
Signed-off-by Rafa? Mi?ecki <[email protected]>
--- drivers/net/wireless/b43/phy_n.c | 132 +++++++++++++++++++++++++++++++--- drivers/net/wireless/b43/radio_2057.c | 104 +++++++++++++++++++++++---- drivers/net/wireless/b43/radio_2057.h | 66 +++++++++++++++++ 3 files changed, 282 insertions(+), 20 deletions(-)
drivers/net/wireless/b43/phy_n.c +124 -8
@@ -590,6 +590,100 @@ static void b43_nphy_set_rf_sequence(struct b43_wldev *dev, u8 cmd,* Radio 0x2057 **************************************************/ +static void b43_radio_2057_chantab_upload (struct b43_wldev *dev, +const struct b43_nphy_chantabent_rev7 *e_r7, +const struct b43_nphy_chantabent_rev7_2g *e_r7_2g) +{ +if (e_r7_2g) { +b43_radio_write (dev,R2057_VCOCAL_COUNTVAL0 , e_r7_2g->radio_vcocal_countval0); +b43_radio_write (dev,R2057_VCOCAL_COUNTVAL1 , e_r7_2g->radio_vcocal_countval1); +b43_radio_write (dev,R2057_RFPLL_REFMASTER_SPAREXTALSIZE , e_r7_2g->radio_rfpll_refmaster_sparextalsize); +b43_radio_write (dev,R2057_RFPLL_LOOPFILTER_R1 , e_r7_2g->radio_rfpll_loopfilter_r1); +b43_radio_write (dev,R2057_RFPLL_LOOPFILTER_C2 , e_r7_2g->radio_rfpll_loopfilter_c2); +b43_radio_write (dev,R2057_RFPLL_LOOPFILTER_C1 , e_r7_2g->radio_rfpll_loopfilter_c1); +b43_radio_write (dev,R2057_CP_KPD_IDAC , e_r7_2g->radio_cp_kpd_idac); +b43_radio_write (dev,R2057_RFPLL_MMD0 , e_r7_2g->radio_rfpll_mmd0); +b43_radio_write (dev,R2057_RFPLL_MMD1 , e_r7_2g->radio_rfpll_mmd1); +b43_radio_write (dev,R2057_VCOBUF_TUNE , e_r7_2g->radio_vcobuf_tune); +b43_radio_write (dev,R2057_LOGEN_MX2G_TUNE , e_r7_2g->radio_logen_mx2g_tune); +b43_radio_write (dev,R2057_LOGEN_INDBUF2G_TUNE , e_r7_2g->radio_logen_indbuf2g_tune); +b43_radio_write (dev,R2057_TXMIX2G_TUNE_BOOST_PU_CORE0 , e_r7_2g->radio_txmix2g_tune_boost_pu_core0); +b43_radio_write (dev,R2057_PAD2G_TUNE_PUS_CORE0 , e_r7_2g->radio_pad2g_tune_pus_core0); +b43_radio_write (dev,R2057_LNA2G_TUNE_CORE0 , e_r7_2g->radio_lna2g_tune_core0); +b43_radio_write (dev,R2057_TXMIX2G_TUNE_BOOST_PU_CORE1 , e_r7_2g->radio_txmix2g_tune_boost_pu_core1); +b43_radio_write (dev,R2057_PAD2G_TUNE_PUS_CORE1 , e_r7_2g->radio_pad2g_tune_pus_core1); +b43_radio_write (dev,R2057_LNA2G_TUNE_CORE1 , e_r7_2g->radio_lna2g_tune_core1); + + }else { +b43_radio_write (dev,R2057_VCOCAL_COUNTVAL0 , e_r7->radio_vcocal_countval0); +b43_radio_write (dev,R2057_VCOCAL_COUNTVAL1 , e_r7->radio_vcocal_countval1); +b43_radio_write (dev,R2057_RFPLL_REFMASTER_SPAREXTALSIZE , e_r7->radio_rfpll_refmaster_sparextalsize); +b43_radio_write (dev,R2057_RFPLL_LOOPFILTER_R1 , e_r7->radio_rfpll_loopfilter_r1); +b43_radio_write (dev,R2057_RFPLL_LOOPFILTER_C2 , e_r7->radio_rfpll_loopfilter_c2); +b43_radio_write (dev,R2057_RFPLL_LOOPFILTER_C1 , e_r7->radio_rfpll_loopfilter_c1); +b43_radio_write (dev,R2057_CP_KPD_IDAC , e_r7->radio_cp_kpd_idac); +b43_radio_write (dev,R2057_RFPLL_MMD0 , e_r7->radio_rfpll_mmd0); +b43_radio_write (dev,R2057_RFPLL_MMD1 , e_r7->radio_rfpll_mmd1); +b43_radio_write (dev,R2057_VCOBUF_TUNE , e_r7->radio_vcobuf_tune); +b43_radio_write (dev,R2057_LOGEN_MX2G_TUNE , e_r7->radio_logen_mx2g_tune); +b43_radio_write (dev,R2057_LOGEN_MX5G_TUNE , e_r7->radio_logen_mx5g_tune); +b43_radio_write (dev,R2057_LOGEN_INDBUF2G_TUNE , e_r7->radio_logen_indbuf2g_tune); +b43_radio_write (dev,R2057_LOGEN_INDBUF5G_TUNE , e_r7->radio_logen_indbuf5g_tune); +b43_radio_write (dev,R2057_TXMIX2G_TUNE_BOOST_PU_CORE0 , e_r7->radio_txmix2g_tune_boost_pu_core0); +b43_radio_write (dev,R2057_PAD2G_TUNE_PUS_CORE0 , e_r7->radio_pad2g_tune_pus_core0); +b43_radio_write (dev,R2057_PGA_BOOST_TUNE_CORE0 , e_r7->radio_pga_boost_tune_core0); +b43_radio_write (dev,R2057_TXMIX5G_BOOST_TUNE_CORE0 , e_r7->radio_txmix5g_boost_tune_core0); +b43_radio_write (dev,R2057_PAD5G_TUNE_MISC_PUS_CORE0 , e_r7->radio_pad5g_tune_misc_pus_core0); +b43_radio_write (dev,R2057_LNA2G_TUNE_CORE0 , e_r7->radio_lna2g_tune_core0); +b43_radio_write (dev,R2057_LNA5G_TUNE_CORE0 , e_r7->radio_lna5g_tune_core0); +b43_radio_write (dev,R2057_TXMIX2G_TUNE_BOOST_PU_CORE1 , e_r7->radio_txmix2g_tune_boost_pu_core1); +b43_radio_write (dev,R2057_PAD2G_TUNE_PUS_CORE1 , e_r7->radio_pad2g_tune_pus_core1); +b43_radio_write (dev,R2057_PGA_BOOST_TUNE_CORE1 , e_r7->radio_pga_boost_tune_core1); +b43_radio_write (dev,R2057_TXMIX5G_BOOST_TUNE_CORE1 , e_r7->radio_txmix5g_boost_tune_core1); +b43_radio_write (dev,R2057_PAD5G_TUNE_MISC_PUS_CORE1 , e_r7->radio_pad5g_tune_misc_pus_core1); +b43_radio_write (dev,R2057_LNA2G_TUNE_CORE1 , e_r7->radio_lna2g_tune_core1); +b43_radio_write (dev,R2057_LNA5G_TUNE_CORE1 , e_r7->radio_lna5g_tune_core1); + } +} + +static void b43_radio_2057_setup (struct b43_wldev *dev, +const struct b43_nphy_chantabent_rev7 *tabent_r7, +const struct b43_nphy_chantabent_rev7_2g *tabent_r7_2g) +{ +struct b43_phy *phy = &dev->phy; + +b43_radio_2057_chantab_upload (dev, tabent_r7, tabent_r7_2g); + +switch (phy->radio_rev) { + case 0 ... 4: +case 6 : +if (b43_current_band (dev->wl) ==IEEE80211_BAND_2GHZ ) { +b43_radio_write (dev,R2057_RFPLL_LOOPFILTER_R1 ,0x3f ); +b43_radio_write (dev,R2057_CP_KPD_IDAC ,0x3f ); +b43_radio_write (dev,R2057_RFPLL_LOOPFILTER_C1 ,0x8 ); +b43_radio_write (dev,R2057_RFPLL_LOOPFILTER_C2 ,0x8 ); + }else { +b43_radio_write (dev,R2057_RFPLL_LOOPFILTER_R1 ,0x1f ); +b43_radio_write (dev,R2057_CP_KPD_IDAC ,0x3f ); +b43_radio_write (dev,R2057_RFPLL_LOOPFILTER_C1 ,0x8 ); +b43_radio_write (dev,R2057_RFPLL_LOOPFILTER_C2 ,0x8 ); + } +break ; +/* TODO */ + } + +/* TODO */ + +usleep_range (50 ,100 ); + +/* VCO calibration */ +b43_radio_mask (dev,R2057_RFPLL_MISC_EN , ~0x01 ); +b43_radio_mask (dev,R2057_RFPLL_MISC_CAL_RESETN , ~0x04 ); +b43_radio_set (dev,R2057_RFPLL_MISC_CAL_RESETN ,0x4 ); +b43_radio_set (dev,R2057_RFPLL_MISC_EN ,0x01 ); +usleep_range (300 ,600 ); +} +/* Calibrate resistors in LPF of PLL? * http://bcm-v4.sipsolutions.net/PHY/radio205x_rcal */
@@ -5535,10 +5629,17 @@ static int b43_nphy_set_channel(struct b43_wldev *dev,const struct b43_nphy_channeltab_entry_rev2 *tabent_r2 =NULL ;const struct b43_nphy_channeltab_entry_rev3 *tabent_r3 =NULL ; +const struct b43_nphy_chantabent_rev7 *tabent_r7 =NULL ; +const struct b43_nphy_chantabent_rev7_2g *tabent_r7_2g =NULL ;u8 tmp; -if (dev->phy.rev >=3 ) { +if (phy->rev >=7 ) { +r2057_get_chantabent_rev7 (dev, channel->center_freq, + &tabent_r7, &tabent_r7_2g); +if (!tabent_r7 && !tabent_r7_2g) +return -ESRCH ; + }else if (phy->rev >=3 ) { tabent_r3 =b43_nphy_get_chantabent_rev3 (dev, channel->center_freq);if (!tabent_r3)
@@ -5560,14 +5661,29 @@ static int b43_nphy_set_channel(struct b43_wldev *dev, ;/* TODO: BMAC BW Set (channel_type) */ #endif -if (channel_type ==NL80211_CHAN_HT40PLUS ) -b43_phy_set (dev,B43_NPHY_RXCTL , -B43_NPHY_RXCTL_BSELU20 ); -else if (channel_type ==NL80211_CHAN_HT40MINUS ) -b43_phy_mask (dev,B43_NPHY_RXCTL , - ~B43_NPHY_RXCTL_BSELU20 ); +if (channel_type ==NL80211_CHAN_HT40PLUS ) { +b43_phy_set (dev,B43_NPHY_RXCTL ,B43_NPHY_RXCTL_BSELU20 ); +if (phy->rev >=7 ) +b43_phy_set (dev,0x310 ,0x8000 ); + }else if (channel_type ==NL80211_CHAN_HT40MINUS ) { +b43_phy_mask (dev,B43_NPHY_RXCTL , ~B43_NPHY_RXCTL_BSELU20 ); +if (phy->rev >=7 ) +b43_phy_mask (dev,0x310 , (u16 )~0x8000 ); + } -if (dev->phy.rev >=3 ) { +if (phy->rev >=7 ) { +const struct b43_phy_n_sfo_cfg *phy_regs = tabent_r7 ? + &(tabent_r7->phy_regs) : &(tabent_r7_2g->phy_regs); + +if (phy->radio_rev <=4 || phy->radio_rev ==6 ) { + tmp = (channel->band ==IEEE80211_BAND_5GHZ ) ?2 :0 ; +b43_radio_maskset (dev,R2057_TIA_CONFIG_CORE0 , ~2 , tmp); +b43_radio_maskset (dev,R2057_TIA_CONFIG_CORE1 , ~2 , tmp); + } + +b43_radio_2057_setup (dev, tabent_r7, tabent_r7_2g); +b43_nphy_channel_setup (dev, phy_regs, channel); + }else if (phy->rev >=3 ) { tmp = (channel->band ==IEEE80211_BAND_5GHZ ) ?4 :0 ;b43_radio_maskset (dev,0x08 ,0xFFFB , tmp);b43_radio_2056_setup (dev, tabent_r3);
drivers/net/wireless/b43/radio_2057.c +92 -12
132 lines not on this page · raw message
drivers/net/wireless/b43/radio_2057.h +66 -0
72 lines not on this page · raw message
Signature · 1 line
1.8.4.5