diff options
Diffstat (limited to 'drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_cmn.c')
-rw-r--r-- | drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_cmn.c | 182 |
1 files changed, 29 insertions, 153 deletions
diff --git a/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_cmn.c b/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_cmn.c index 8f75af2ffc58..6cba4dfbc3dd 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_cmn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_cmn.c @@ -18,10 +18,12 @@ #include <linux/kernel.h> #include <linux/string.h> -#include <bcmdefs.h> +#include <linux/bitops.h> #include <linux/delay.h> #include <linux/module.h> #include <linux/pci.h> + +#include <bcmdefs.h> #include <bcmnvram.h> #include <sbchipc.h> #include <bcmdevs.h> @@ -155,8 +157,6 @@ char *phy_getvar(phy_info_t *pi, const char *name) char *s; int len; - ASSERT(pi->vars != (char *)&pi->vars); - if (!name) return NULL; @@ -241,7 +241,7 @@ u16 read_radio_reg(phy_info_t *pi, u16 addr) break; default: - ASSERT(VALID_PHYTYPE(pi->pubpi.phy_type)); + break; } if ((D11REV_GE(pi->sh->corerev, 24)) || @@ -391,16 +391,6 @@ void write_phy_channel_reg(phy_info_t *pi, uint val) W_REG(&pi->regs->phychannel, val); } -#if defined(BCMDBG) -static bool wlc_phy_war41476(phy_info_t *pi) -{ - u32 mc = R_REG(&pi->regs->maccontrol); - - return ((mc & MCTL_EN_MAC) == 0) - || ((mc & MCTL_PHYLOCK) == MCTL_PHYLOCK); -} -#endif - u16 read_phy_reg(phy_info_t *pi, u16 addr) { d11regs_t *regs; @@ -412,10 +402,6 @@ u16 read_phy_reg(phy_info_t *pi, u16 addr) (void)R_REG(®s->phyregaddr); #endif - ASSERT(! - (D11REV_IS(pi->sh->corerev, 11) - || D11REV_IS(pi->sh->corerev, 12)) || wlc_phy_war41476(pi)); - pi->phy_wreg = 0; return R_REG(®s->phyregdata); } @@ -455,10 +441,6 @@ void and_phy_reg(phy_info_t *pi, u16 addr, u16 val) (void)R_REG(®s->phyregaddr); #endif - ASSERT(! - (D11REV_IS(pi->sh->corerev, 11) - || D11REV_IS(pi->sh->corerev, 12)) || wlc_phy_war41476(pi)); - W_REG(®s->phyregdata, (R_REG(®s->phyregdata) & val)); pi->phy_wreg = 0; } @@ -474,10 +456,6 @@ void or_phy_reg(phy_info_t *pi, u16 addr, u16 val) (void)R_REG(®s->phyregaddr); #endif - ASSERT(! - (D11REV_IS(pi->sh->corerev, 11) - || D11REV_IS(pi->sh->corerev, 12)) || wlc_phy_war41476(pi)); - W_REG(®s->phyregdata, (R_REG(®s->phyregdata) | val)); pi->phy_wreg = 0; } @@ -493,10 +471,6 @@ void mod_phy_reg(phy_info_t *pi, u16 addr, u16 mask, u16 val) (void)R_REG(®s->phyregaddr); #endif - ASSERT(! - (D11REV_IS(pi->sh->corerev, 11) - || D11REV_IS(pi->sh->corerev, 12)) || wlc_phy_war41476(pi)); - W_REG(®s->phyregdata, ((R_REG(®s->phyregdata) & ~mask) | (val & mask))); pi->phy_wreg = 0; @@ -579,14 +553,12 @@ shared_phy_t *wlc_phy_shared_attach(shared_phy_params_t *shp) void wlc_phy_shared_detach(shared_phy_t *phy_sh) { if (phy_sh) { - if (phy_sh->phy_head) { - ASSERT(!phy_sh->phy_head); - } kfree(phy_sh); } } -wlc_phy_t *wlc_phy_attach(shared_phy_t *sh, void *regs, int bandtype, char *vars) +wlc_phy_t *wlc_phy_attach(shared_phy_t *sh, void *regs, int bandtype, + char *vars, struct wiphy *wiphy) { phy_info_t *pi; u32 sflags = 0; @@ -596,7 +568,7 @@ wlc_phy_t *wlc_phy_attach(shared_phy_t *sh, void *regs, int bandtype, char *vars if (D11REV_IS(sh->corerev, 4)) sflags = SISF_2G_PHY | SISF_5G_PHY; else - sflags = si_core_sflags(sh->sih, 0, 0); + sflags = ai_core_sflags(sh->sih, 0, 0); if (BAND_5G(bandtype)) { if ((sflags & (SISF_5G_PHY | SISF_DB_PHY)) == 0) { @@ -616,6 +588,7 @@ wlc_phy_t *wlc_phy_attach(shared_phy_t *sh, void *regs, int bandtype, char *vars if (pi == NULL) { return NULL; } + pi->wiphy = wiphy; pi->regs = (d11regs_t *) regs; pi->sh = sh; pi->phy_init_por = true; @@ -781,8 +754,6 @@ void wlc_phy_detach(wlc_phy_t *pih) pi->sh->phy_head = pi->next; else if (pi->sh->phy_head->next == pi) pi->sh->phy_head->next = NULL; - else - ASSERT(0); if (pi->pi_fptr.detach) (pi->pi_fptr.detach) (pi); @@ -894,7 +865,6 @@ u32 wlc_phy_clk_bwbits(wlc_phy_t *pih) phy_bw_clkbits = SICF_BW40; break; default: - ASSERT(0); break; } } @@ -962,24 +932,20 @@ void WLBANDINITFN(wlc_phy_init) (wlc_phy_t *pih, chanspec_t chanspec) pi->radio_chanspec = chanspec; mc = R_REG(&pi->regs->maccontrol); - if ((mc & MCTL_EN_MAC) != 0) { - ASSERT((const char *) - "wlc_phy_init: Called with the MAC running!" == NULL); - } - - ASSERT(pi != NULL); + if (WARN(mc & MCTL_EN_MAC, "HW error MAC running on init")) + return; if (!(pi->measure_hold & PHY_HOLD_FOR_SCAN)) { pi->measure_hold |= PHY_HOLD_FOR_NOT_ASSOC; } - if (D11REV_GE(pi->sh->corerev, 5)) - ASSERT(si_core_sflags(pi->sh->sih, 0, 0) & SISF_FCLKA); + if (WARN(!(ai_core_sflags(pi->sh->sih, 0, 0) & SISF_FCLKA), + "HW error SISF_FCLKA\n")) + return; phy_init = pi->pi_fptr.init; if (phy_init == NULL) { - ASSERT(phy_init != NULL); return; } @@ -1013,7 +979,9 @@ void wlc_phy_cal_init(wlc_phy_t *pih) phy_info_t *pi = (phy_info_t *) pih; initfn_t cal_init = NULL; - ASSERT((R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC) == 0); + if (WARN((R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC) != 0, + "HW error: MAC enabled during phy cal\n")) + return; if (!pi->initialized) { cal_init = pi->pi_fptr.calinit; @@ -1029,8 +997,6 @@ int wlc_phy_down(wlc_phy_t *pih) phy_info_t *pi = (phy_info_t *) pih; int callbacks = 0; - ASSERT(pi->phytest_on == false); - if (pi->phycal_timer && !wlapi_del_timer(pi->sh->physhim, pi->phycal_timer)) callbacks++; @@ -1070,8 +1036,6 @@ wlc_phy_table_addr(phy_info_t *pi, uint tbl_id, uint tbl_offset, void wlc_phy_table_data_write(phy_info_t *pi, uint width, u32 val) { - ASSERT((width == 8) || (width == 16) || (width == 32)); - if ((pi->sh->chip == BCM43224_CHIP_ID || pi->sh->chip == BCM43421_CHIP_ID) && (pi->sh->chiprev == 1) && @@ -1105,8 +1069,6 @@ wlc_phy_write_table(phy_info_t *pi, const phytbl_info_t *ptbl_info, const u16 *ptbl_16b = (const u16 *)ptbl_info->tbl_ptr; const u32 *ptbl_32b = (const u32 *)ptbl_info->tbl_ptr; - ASSERT((tbl_width == 8) || (tbl_width == 16) || (tbl_width == 32)); - write_phy_reg(pi, tblAddr, (tbl_id << 10) | tbl_offset); for (idx = 0; idx < ptbl_info->tbl_len; idx++) { @@ -1148,8 +1110,6 @@ wlc_phy_read_table(phy_info_t *pi, const phytbl_info_t *ptbl_info, u16 *ptbl_16b = (u16 *)ptbl_info->tbl_ptr; u32 *ptbl_32b = (u32 *)ptbl_info->tbl_ptr; - ASSERT((tbl_width == 8) || (tbl_width == 16) || (tbl_width == 32)); - write_phy_reg(pi, tblAddr, (tbl_id << 10) | tbl_offset); for (idx = 0; idx < ptbl_info->tbl_len; idx++) { @@ -1243,8 +1203,6 @@ void wlc_phy_do_dummy_tx(phy_info_t *pi, bool ofdm, bool pa_on) }; u32 *dummypkt; - ASSERT((R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC) == 0); - dummypkt = (u32 *) (ofdm ? ofdmpkt : cckpkt); wlapi_bmac_write_template_ram(pi->sh->physhim, 0, DUMMY_PKT_LEN, dummypkt); @@ -1258,7 +1216,6 @@ void wlc_phy_do_dummy_tx(phy_info_t *pi, bool ofdm, bool pa_on) W_REG(®s->txe_phyctl, (ofdm ? 1 : 0) | PHY_TXC_ANT_0); if (ISNPHY(pi) || ISLCNPHY(pi)) { - ASSERT(ofdm); W_REG(®s->txe_phyctl1, 0x1A02); } @@ -1317,7 +1274,6 @@ void wlc_phy_do_dummy_tx(phy_info_t *pi, bool ofdm, bool pa_on) void wlc_phy_hold_upd(wlc_phy_t *pih, mbool id, bool set) { phy_info_t *pi = (phy_info_t *) pih; - ASSERT(id); if (set) { mboolset(pi->measure_hold, id); @@ -1439,8 +1395,6 @@ void wlc_phy_chanspec_set(wlc_phy_t *ppi, chanspec_t chanspec) u16 m_cur_channel; chansetfn_t chanspec_set = NULL; - ASSERT(!wf_chspec_malformed(chanspec)); - m_cur_channel = CHSPEC_CHANNEL(chanspec); if (CHSPEC_IS5G(chanspec)) m_cur_channel |= D11_CURCHANNEL_5G; @@ -1480,8 +1434,7 @@ int wlc_phy_chanspec_bandrange_get(phy_info_t *pi, chanspec_t chanspec) range = wlc_phy_get_chan_freq_range_nphy(pi, channel); } else if (ISLCNPHY(pi)) { range = wlc_phy_chanspec_freq2bandrange_lpssn(freq); - } else - ASSERT(0); + } return range; } @@ -1511,8 +1464,6 @@ wlc_phy_chanspec_band_validch(wlc_phy_t *ppi, uint band, chanvec_t *channels) uint i; uint channel; - ASSERT((band == WLC_BAND_2G) || (band == WLC_BAND_5G)); - memset(channels, 0, sizeof(chanvec_t)); for (i = 0; i < ARRAY_SIZE(chan_info_all); i++) { @@ -1535,8 +1486,6 @@ chanspec_t wlc_phy_chanspec_band_firstch(wlc_phy_t *ppi, uint band) uint channel; chanspec_t chspec; - ASSERT((band == WLC_BAND_2G) || (band == WLC_BAND_5G)); - for (i = 0; i < ARRAY_SIZE(chan_info_all); i++) { channel = chan_info_all[i].chan; @@ -1572,8 +1521,6 @@ chanspec_t wlc_phy_chanspec_band_firstch(wlc_phy_t *ppi, uint band) return chspec; } - ASSERT(0); - return (chanspec_t) INVCHANSPEC; } @@ -1581,7 +1528,6 @@ int wlc_phy_txpower_get(wlc_phy_t *ppi, uint *qdbm, bool *override) { phy_info_t *pi = (phy_info_t *) ppi; - ASSERT(qdbm != NULL); *qdbm = pi->tx_user_target[0]; if (override != NULL) *override = pi->txpwroverride; @@ -1703,7 +1649,6 @@ wlc_phy_txpower_sromlimit(wlc_phy_t *ppi, uint channel, u8 *min_pwr, break; } } - ASSERT(i < ARRAY_SIZE(chan_info_all)); if (pi->hwtxpwr) { *max_pwr = pi->hwtxpwr[i]; @@ -2134,7 +2079,6 @@ void wlc_phy_txpower_update_shm(phy_info_t *pi) { int j; if (ISNPHY(pi)) { - ASSERT(0); return; } @@ -2466,8 +2410,6 @@ void wlc_phy_ant_rxdiv_set(wlc_phy_t *ppi, u8 val) mod_phy_reg(pi, 0x410, (0x1 << 1), 0x00 << 1); mod_phy_reg(pi, 0x410, (0x1 << 0), (u16) val << 0); } - } else { - ASSERT(0); } if (!suspend) @@ -2483,7 +2425,6 @@ wlc_phy_noise_calc_phy(phy_info_t *pi, u32 *cmplx_pwr, s8 *pwr_ant) u8 i; memset((u8 *) cmplx_pwr_dbm, 0, sizeof(cmplx_pwr_dbm)); - ASSERT(pi->pubpi.phy_corenum <= PHY_CORE_MAX); wlc_phy_compute_dB(cmplx_pwr, cmplx_pwr_dbm, pi->pubpi.phy_corenum); for (i = 0; i < pi->pubpi.phy_corenum; i++) { @@ -2529,7 +2470,6 @@ wlc_phy_noise_sample_request(wlc_phy_t *pih, u8 reason, u8 ch) break; default: - ASSERT(0); break; } @@ -2678,7 +2618,6 @@ static s8 wlc_phy_noise_read_shmem(phy_info_t *pi) s8 noise_dbm = PHY_NOISE_FIXED_VAL_NPHY; u8 idx, core; - ASSERT(pi->pubpi.phy_corenum <= PHY_CORE_MAX); memset((u8 *) cmplx_pwr, 0, sizeof(cmplx_pwr)); memset((u8 *) noise_dbm_ant, 0, sizeof(noise_dbm_ant)); @@ -2760,8 +2699,6 @@ void wlc_phy_noise_sample_intr(wlc_phy_t *pih) channel = jssi_aux & D11_CURCHANNEL_MAX; noise_dbm = wlc_phy_noise_read_shmem(pi); - } else { - ASSERT(0); } wlc_phy_noise_cb(pi, channel, noise_dbm); @@ -2811,25 +2748,20 @@ s8 lcnphy_gain_index_offset_for_pkt_rssi[] = { void wlc_phy_compute_dB(u32 *cmplx_pwr, s8 *p_cmplx_pwr_dB, u8 core) { - u8 shift_ct, lsb, msb, secondmsb, i; + u8 msb, secondmsb, i; u32 tmp; for (i = 0; i < core; i++) { + secondmsb = 0; tmp = cmplx_pwr[i]; - shift_ct = msb = secondmsb = 0; - while (tmp != 0) { - tmp = tmp >> 1; - shift_ct++; - lsb = (u8) (tmp & 1); - if (lsb == 1) - msb = shift_ct; - } - secondmsb = (u8) ((cmplx_pwr[i] >> (msb - 1)) & 1); + msb = fls(tmp); + if (msb) + secondmsb = (u8) ((tmp >> (--msb - 1)) & 1); p_cmplx_pwr_dB[i] = (s8) (3 * msb + 2 * secondmsb); } } -void BCMFASTPATH wlc_phy_rssi_compute(wlc_phy_t *pih, void *ctx) +void wlc_phy_rssi_compute(wlc_phy_t *pih, void *ctx) { wlc_d11rxhdr_t *wlc_rxhdr = (wlc_d11rxhdr_t *) ctx; d11rxhdr_t *rxh = &wlc_rxhdr->rxhdr; @@ -2871,10 +2803,7 @@ void BCMFASTPATH wlc_phy_rssi_compute(wlc_phy_t *pih, void *ctx) rssi -= 256; } else if (radioid == BCM2055_ID || radioid == BCM2056_ID || radioid == BCM2057_ID) { - ASSERT(ISNPHY(pi)); rssi = wlc_phy_rssi_compute_nphy(pi, wlc_rxhdr); - } else { - ASSERT((const char *)"Unknown radio" == NULL); } end: @@ -2900,9 +2829,6 @@ void wlc_phy_set_deaf(wlc_phy_t *ppi, bool user_flag) wlc_lcnphy_deaf_mode(pi, true); else if (ISNPHY(pi)) wlc_nphy_deaf_mode(pi, true); - else { - ASSERT(0); - } } void wlc_phy_watchdog(wlc_phy_t *pih) @@ -3163,13 +3089,9 @@ void wlc_phy_cal_perical(wlc_phy_t *pih, u8 reason) } else if (pi->nphy_perical == PHY_PERICAL_SPHASE) wlc_phy_cal_perical_nphy_run(pi, PHY_PERICAL_AUTO); - else { - ASSERT(0); - } } break; default: - ASSERT(0); break; } } @@ -3192,25 +3114,6 @@ u8 wlc_phy_nbits(s32 value) return nbits; } -u32 wlc_phy_sqrt_int(u32 value) -{ - u32 root = 0, shift = 0; - - for (shift = 0; shift < 32; shift += 2) { - if (((0x40000000 >> shift) + root) <= value) { - value -= ((0x40000000 >> shift) + root); - root = (root >> 1) | (0x40000000 >> shift); - } else { - root = root >> 1; - } - } - - if (root < value) - ++root; - - return root; -} - void wlc_phy_stf_chain_init(wlc_phy_t *pih, u8 txchain, u8 rxchain) { phy_info_t *pi = (phy_info_t *) pih; @@ -3311,12 +3214,12 @@ void wlc_lcnphy_epa_switch(phy_info_t *pi, bool mode) mod_phy_reg(pi, 0x44c, (0x1 << 2), (1) << 2); } - si_corereg(pi->sh->sih, SI_CC_IDX, + ai_corereg(pi->sh->sih, SI_CC_IDX, offsetof(chipcregs_t, gpiocontrol), ~0x0, 0x0); - si_corereg(pi->sh->sih, SI_CC_IDX, + ai_corereg(pi->sh->sih, SI_CC_IDX, offsetof(chipcregs_t, gpioout), 0x40, 0x40); - si_corereg(pi->sh->sih, SI_CC_IDX, + ai_corereg(pi->sh->sih, SI_CC_IDX, offsetof(chipcregs_t, gpioouten), 0x40, 0x40); } else { @@ -3324,11 +3227,11 @@ void wlc_lcnphy_epa_switch(phy_info_t *pi, bool mode) mod_phy_reg(pi, 0x44d, (0x1 << 2), (0) << 2); - si_corereg(pi->sh->sih, SI_CC_IDX, + ai_corereg(pi->sh->sih, SI_CC_IDX, offsetof(chipcregs_t, gpioout), 0x40, 0x00); - si_corereg(pi->sh->sih, SI_CC_IDX, + ai_corereg(pi->sh->sih, SI_CC_IDX, offsetof(chipcregs_t, gpioouten), 0x40, 0x0); - si_corereg(pi->sh->sih, SI_CC_IDX, + ai_corereg(pi->sh->sih, SI_CC_IDX, offsetof(chipcregs_t, gpiocontrol), ~0x0, 0x40); } @@ -3387,33 +3290,6 @@ wlc_phy_get_pwrdet_offsets(phy_info_t *pi, s8 *cckoffset, s8 *ofdmoffset) *ofdmoffset = 0; } -u32 wlc_phy_qdiv_roundup(u32 dividend, u32 divisor, u8 precision) -{ - u32 quotient, remainder, roundup, rbit; - - ASSERT(divisor); - - quotient = dividend / divisor; - remainder = dividend % divisor; - rbit = divisor & 1; - roundup = (divisor >> 1) + rbit; - - while (precision--) { - quotient <<= 1; - if (remainder >= roundup) { - quotient++; - remainder = ((remainder - roundup) << 1) + rbit; - } else { - remainder <<= 1; - } - } - - if (remainder >= roundup) - quotient++; - - return quotient; -} - s8 wlc_phy_upd_rssi_offset(phy_info_t *pi, s8 rssi, chanspec_t chanspec) { |