Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/bwi/bwirf.c
Show First 20 Lines • Show All 1,254 Lines • ▼ Show 20 Lines | DPRINTF(sc, BWI_DBG_RF | BWI_DBG_TXPOWER | BWI_DBG_ATTACH, | ||||
"idle tssi0: %d\n", rf->rf_idle_tssi0); | "idle tssi0: %d\n", rf->rf_idle_tssi0); | ||||
return error; | return error; | ||||
} | } | ||||
static void | static void | ||||
bwi_rf_lo_update_11g(struct bwi_mac *mac) | bwi_rf_lo_update_11g(struct bwi_mac *mac) | ||||
{ | { | ||||
struct bwi_softc *sc = mac->mac_sc; | struct bwi_softc *sc = mac->mac_sc; | ||||
struct ifnet *ifp = sc->sc_ifp; | |||||
struct bwi_rf *rf = &mac->mac_rf; | struct bwi_rf *rf = &mac->mac_rf; | ||||
struct bwi_phy *phy = &mac->mac_phy; | struct bwi_phy *phy = &mac->mac_phy; | ||||
struct bwi_tpctl *tpctl = &mac->mac_tpctl; | struct bwi_tpctl *tpctl = &mac->mac_tpctl; | ||||
struct rf_saveregs regs; | struct rf_saveregs regs; | ||||
uint16_t ant_div, chan_ex; | uint16_t ant_div, chan_ex; | ||||
uint8_t devi_ctrl; | uint8_t devi_ctrl; | ||||
u_int orig_chan; | u_int orig_chan; | ||||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | bwi_rf_lo_update_11g(struct bwi_mac *mac) | ||||
if (phy->phy_flags & BWI_PHY_F_LINKED) { | if (phy->phy_flags & BWI_PHY_F_LINKED) { | ||||
PHY_WRITE(mac, 0x814, regs.phy_814 | 0x3); | PHY_WRITE(mac, 0x814, regs.phy_814 | 0x3); | ||||
PHY_WRITE(mac, 0x815, regs.phy_815 & 0xfffc); | PHY_WRITE(mac, 0x815, regs.phy_815 & 0xfffc); | ||||
PHY_WRITE(mac, 0x811, 0x1b3); | PHY_WRITE(mac, 0x811, 0x1b3); | ||||
PHY_WRITE(mac, 0x812, 0xb2); | PHY_WRITE(mac, 0x812, 0xb2); | ||||
} | } | ||||
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) | if ((sc->sc_flags & BWI_F_RUNNING) == 0) | ||||
tpctl->tp_ctrl2 = bwi_rf_get_tp_ctrl2(mac); | tpctl->tp_ctrl2 = bwi_rf_get_tp_ctrl2(mac); | ||||
PHY_WRITE(mac, 0x80f, 0x8078); | PHY_WRITE(mac, 0x80f, 0x8078); | ||||
/* | /* | ||||
* Measure all RF LO | * Measure all RF LO | ||||
*/ | */ | ||||
devi_ctrl = _bwi_rf_lo_update_11g(mac, regs.rf_7a); | devi_ctrl = _bwi_rf_lo_update_11g(mac, regs.rf_7a); | ||||
/* | /* | ||||
* Restore saved RF/PHY registers | * Restore saved RF/PHY registers | ||||
*/ | */ | ||||
if (phy->phy_flags & BWI_PHY_F_LINKED) { | if (phy->phy_flags & BWI_PHY_F_LINKED) { | ||||
PHY_WRITE(mac, 0x15, 0xe300); | PHY_WRITE(mac, 0x15, 0xe300); | ||||
PHY_WRITE(mac, 0x812, (devi_ctrl << 8) | 0xa0); | PHY_WRITE(mac, 0x812, (devi_ctrl << 8) | 0xa0); | ||||
DELAY(5); | DELAY(5); | ||||
PHY_WRITE(mac, 0x812, (devi_ctrl << 8) | 0xa2); | PHY_WRITE(mac, 0x812, (devi_ctrl << 8) | 0xa2); | ||||
DELAY(2); | DELAY(2); | ||||
PHY_WRITE(mac, 0x812, (devi_ctrl << 8) | 0xa3); | PHY_WRITE(mac, 0x812, (devi_ctrl << 8) | 0xa3); | ||||
} else { | } else { | ||||
PHY_WRITE(mac, 0x15, devi_ctrl | 0xefa0); | PHY_WRITE(mac, 0x15, devi_ctrl | 0xefa0); | ||||
} | } | ||||
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) | if ((sc->sc_flags & BWI_F_RUNNING) == 0) | ||||
tpctl = NULL; | tpctl = NULL; | ||||
bwi_rf_lo_adjust(mac, tpctl); | bwi_rf_lo_adjust(mac, tpctl); | ||||
PHY_WRITE(mac, 0x2e, 0x807f); | PHY_WRITE(mac, 0x2e, 0x807f); | ||||
if (phy->phy_flags & BWI_PHY_F_LINKED) | if (phy->phy_flags & BWI_PHY_F_LINKED) | ||||
PHY_WRITE(mac, 0x2f, 0x202); | PHY_WRITE(mac, 0x2f, 0x202); | ||||
else | else | ||||
PHY_WRITE(mac, 0x2f, 0x101); | PHY_WRITE(mac, 0x2f, 0x101); | ||||
▲ Show 20 Lines • Show All 93 Lines • ▼ Show 20 Lines | #define BBP_ATTEN_MAX 4 /* half */ | ||||
static const int rf_atten_list[RF_ATTEN_LISTSZ] = | static const int rf_atten_list[RF_ATTEN_LISTSZ] = | ||||
{ 3, 1, 5, 7, 9, 2, 0, 4, 6, 8, 1, 2, 3, 4 }; | { 3, 1, 5, 7, 9, 2, 0, 4, 6, 8, 1, 2, 3, 4 }; | ||||
static const int rf_atten_init_list[RF_ATTEN_LISTSZ] = | static const int rf_atten_init_list[RF_ATTEN_LISTSZ] = | ||||
{ 0, 3, 1, 5, 7, 3, 2, 0, 4, 6, -1, -1, -1, -1 }; | { 0, 3, 1, 5, 7, 3, 2, 0, 4, 6, -1, -1, -1, -1 }; | ||||
static const int rf_lo_measure_order[RF_ATTEN_LISTSZ] = | static const int rf_lo_measure_order[RF_ATTEN_LISTSZ] = | ||||
{ 3, 1, 5, 7, 9, 2, 0, 4, 6, 8, 10, 11, 12, 13 }; | { 3, 1, 5, 7, 9, 2, 0, 4, 6, 8, 10, 11, 12, 13 }; | ||||
struct ifnet *ifp = mac->mac_sc->sc_ifp; | struct bwi_softc *sc = mac->mac_sc; | ||||
struct bwi_rf_lo lo_save, *lo; | struct bwi_rf_lo lo_save, *lo; | ||||
uint8_t devi_ctrl = 0; | uint8_t devi_ctrl = 0; | ||||
int idx, adj_rf7a = 0; | int idx, adj_rf7a = 0; | ||||
bzero(&lo_save, sizeof(lo_save)); | bzero(&lo_save, sizeof(lo_save)); | ||||
for (idx = 0; idx < RF_ATTEN_LISTSZ; ++idx) { | for (idx = 0; idx < RF_ATTEN_LISTSZ; ++idx) { | ||||
int init_rf_atten = rf_atten_init_list[idx]; | int init_rf_atten = rf_atten_init_list[idx]; | ||||
int rf_atten = rf_atten_list[idx]; | int rf_atten = rf_atten_list[idx]; | ||||
int bbp_atten; | int bbp_atten; | ||||
for (bbp_atten = 0; bbp_atten < BBP_ATTEN_MAX; ++bbp_atten) { | for (bbp_atten = 0; bbp_atten < BBP_ATTEN_MAX; ++bbp_atten) { | ||||
uint16_t tp_ctrl2, rf7a; | uint16_t tp_ctrl2, rf7a; | ||||
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) { | if ((sc->sc_flags & BWI_F_RUNNING) == 0) { | ||||
if (idx == 0) { | if (idx == 0) { | ||||
bzero(&lo_save, sizeof(lo_save)); | bzero(&lo_save, sizeof(lo_save)); | ||||
} else if (init_rf_atten < 0) { | } else if (init_rf_atten < 0) { | ||||
lo = bwi_get_rf_lo(mac, | lo = bwi_get_rf_lo(mac, | ||||
rf_atten, 2 * bbp_atten); | rf_atten, 2 * bbp_atten); | ||||
bcopy(lo, &lo_save, sizeof(lo_save)); | bcopy(lo, &lo_save, sizeof(lo_save)); | ||||
} else { | } else { | ||||
lo = bwi_get_rf_lo(mac, | lo = bwi_get_rf_lo(mac, | ||||
▲ Show 20 Lines • Show All 1,205 Lines • Show Last 20 Lines |