summaryrefslogtreecommitdiff
path: root/drivers/staging/brcm80211/brcmsmac/phy
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/staging/brcm80211/brcmsmac/phy')
-rw-r--r--drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_cmn.c182
-rw-r--r--drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_hal.h5
-rw-r--r--drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_int.h4
-rw-r--r--drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_lcn.c51
-rw-r--r--drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_n.c173
-rw-r--r--drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_qmath.c296
-rw-r--r--drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_qmath.h40
7 files changed, 437 insertions, 314 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(&regs->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(&regs->phyregdata);
}
@@ -455,10 +441,6 @@ void and_phy_reg(phy_info_t *pi, u16 addr, u16 val)
(void)R_REG(&regs->phyregaddr);
#endif
- ASSERT(!
- (D11REV_IS(pi->sh->corerev, 11)
- || D11REV_IS(pi->sh->corerev, 12)) || wlc_phy_war41476(pi));
-
W_REG(&regs->phyregdata, (R_REG(&regs->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(&regs->phyregaddr);
#endif
- ASSERT(!
- (D11REV_IS(pi->sh->corerev, 11)
- || D11REV_IS(pi->sh->corerev, 12)) || wlc_phy_war41476(pi));
-
W_REG(&regs->phyregdata, (R_REG(&regs->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(&regs->phyregaddr);
#endif
- ASSERT(!
- (D11REV_IS(pi->sh->corerev, 11)
- || D11REV_IS(pi->sh->corerev, 12)) || wlc_phy_war41476(pi));
-
W_REG(&regs->phyregdata,
((R_REG(&regs->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(&regs->txe_phyctl, (ofdm ? 1 : 0) | PHY_TXC_ANT_0);
if (ISNPHY(pi) || ISLCNPHY(pi)) {
- ASSERT(ofdm);
W_REG(&regs->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)
{
diff --git a/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_hal.h b/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_hal.h
index bf962d5b339a..8939153efa56 100644
--- a/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_hal.h
+++ b/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_hal.h
@@ -18,9 +18,10 @@
#define _wlc_phy_h_
#include <wlioctl.h>
-#include <siutils.h>
+#include <aiutils.h>
#include <d11.h>
#include <wlc_phy_shim.h>
+#include <net/mac80211.h> /* struct wiphy */
#define IDCODE_VER_MASK 0x0000000f
#define IDCODE_VER_SHIFT 0
@@ -149,7 +150,7 @@ typedef struct shared_phy_params {
extern shared_phy_t *wlc_phy_shared_attach(shared_phy_params_t *shp);
extern void wlc_phy_shared_detach(shared_phy_t *phy_sh);
extern wlc_phy_t *wlc_phy_attach(shared_phy_t *sh, void *regs, int bandtype,
- char *vars);
+ char *vars, struct wiphy *wiphy);
extern void wlc_phy_detach(wlc_phy_t *ppi);
extern bool wlc_phy_get_phyversion(wlc_phy_t *pih, u16 *phytype,
diff --git a/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_int.h b/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_int.h
index 6e12a95c7360..10cbf520474f 100644
--- a/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_int.h
+++ b/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_int.h
@@ -936,6 +936,7 @@ struct phy_info {
u8 phycal_tempdelta;
u32 mcs20_po;
u32 mcs40_po;
+ struct wiphy *wiphy;
};
typedef s32 fixed;
@@ -1024,7 +1025,6 @@ extern void wlc_phy_txpower_update_shm(phy_info_t *pi);
extern void wlc_phy_cordic(fixed theta, cs32 *val);
extern u8 wlc_phy_nbits(s32 value);
-extern u32 wlc_phy_sqrt_int(u32 value);
extern void wlc_phy_compute_dB(u32 *cmplx_pwr, s8 *p_dB, u8 core);
extern uint wlc_phy_init_radio_regs_allbands(phy_info_t *pi,
@@ -1093,8 +1093,6 @@ extern void wlc_lcnphy_epa_switch(phy_info_t *pi, bool mode);
extern void wlc_2064_vco_cal(phy_info_t *pi);
extern void wlc_phy_txpower_recalc_target(phy_info_t *pi);
-extern u32 wlc_phy_qdiv_roundup(u32 dividend, u32 divisor,
- u8 precision);
#define LCNPHY_TBL_ID_PAPDCOMPDELTATBL 0x18
#define LCNPHY_TX_POWER_TABLE_SIZE 128
diff --git a/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_lcn.c b/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_lcn.c
index a5a7bb82ab42..b8864c5b7a19 100644
--- a/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_lcn.c
+++ b/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_lcn.c
@@ -19,18 +19,19 @@
#include <linux/bitops.h>
#include <linux/delay.h>
#include <wlc_cfg.h>
-#include <qmath.h>
#include <linux/pci.h>
-#include <siutils.h>
-#include <hndpmu.h>
+#include <aiutils.h>
+#include <wlc_pmu.h>
+#include <bcmnvram.h>
#include <bcmdevs.h>
#include <sbhnddma.h>
-#include <wlc_phy_radio.h>
-#include <wlc_phy_int.h>
-#include <wlc_phy_lcn.h>
-#include <wlc_phytbl_lcn.h>
+#include "wlc_phy_radio.h"
+#include "wlc_phy_int.h"
+#include "wlc_phy_qmath.h"
+#include "wlc_phy_lcn.h"
+#include "wlc_phytbl_lcn.h"
#define PLL_2064_NDIV 90
#define PLL_2064_LOW_END_VCO 3000
@@ -1081,8 +1082,6 @@ wlc_lcnphy_qdiv_roundup(u32 dividend, u32 divisor, u8 precision)
{
u32 quotient, remainder, roundup, rbit;
- ASSERT(divisor);
-
quotient = dividend / divisor;
remainder = dividend % divisor;
rbit = divisor & 1;
@@ -1780,11 +1779,6 @@ void wlc_lcnphy_set_tx_pwr_ctrl(phy_info_t *pi, u16 mode)
s8 index;
phy_info_lcnphy_t *pi_lcn = pi->u.pi_lcnphy;
- ASSERT((LCNPHY_TX_PWR_CTRL_OFF == mode) ||
- (LCNPHY_TX_PWR_CTRL_SW == mode) ||
- (LCNPHY_TX_PWR_CTRL_HW == mode) ||
- (LCNPHY_TX_PWR_CTRL_TEMPBASED == mode));
-
mode = wlc_lcnphy_set_tx_pwr_ctrl_mode(pi, mode);
old_mode = wlc_lcnphy_set_tx_pwr_ctrl_mode(pi, old_mode);
@@ -1904,16 +1898,14 @@ wlc_lcnphy_tx_iqlo_cal(phy_info_t *pi,
break;
case LCNPHY_CAL_RECAL:
- ASSERT(pi_lcn->lcnphy_cal_results.txiqlocal_bestcoeffs_valid);
-
start_coeffs = syst_coeffs;
-
cal_cmds = commands_recal;
n_cal_cmds = ARRAY_SIZE(commands_recal);
command_nums = command_nums_recal;
break;
+
default:
- ASSERT(false);
+ break;
}
wlc_lcnphy_common_write_table(pi, LCNPHY_TBL_ID_IQLOCAL,
@@ -2460,8 +2452,6 @@ void wlc_lcnphy_set_tx_pwr_by_index(phy_info_t *pi, int index)
lcnphy_txgains_t gains;
phy_info_lcnphy_t *pi_lcn = pi->u.pi_lcnphy;
- ASSERT(index <= LCNPHY_MAX_TX_POWER_INDEX);
-
pi_lcn->lcnphy_tx_power_idx_override = (s8) index;
pi_lcn->lcnphy_current_index = (u8) index;
@@ -2760,7 +2750,6 @@ wlc_lcnphy_start_tx_tone(phy_info_t *pi, s32 f_kHz, u16 max_val,
do {
bw = phy_bw * 1000 * k;
num_samps = bw / ABS(f_kHz);
- ASSERT(num_samps <= ARRAY_SIZE(data_buf));
k++;
} while ((num_samps * (u32) (ABS(f_kHz))) != bw);
} else
@@ -3255,7 +3244,7 @@ static bool wlc_lcnphy_calc_rx_iq_comp(phy_info_t *pi, u16 num_samps)
}
b /= temp;
b -= a * a;
- b = (s32) wlc_phy_sqrt_int((u32) b);
+ b = (s32) int_sqrt((unsigned long) b);
b -= (1 << 10);
a0_new = (u16) (a & 0x3ff);
b0_new = (u16) (b & 0x3ff);
@@ -3298,8 +3287,6 @@ wlc_lcnphy_rx_iq_cal(phy_info_t *pi, const lcnphy_rx_iqcomp_t *iqcomp,
return false;
}
if (module == 2) {
- ASSERT(iqcomp_sz);
-
while (iqcomp_sz--) {
if (iqcomp[iqcomp_sz].chan ==
CHSPEC_CHANNEL(pi->radio_chanspec)) {
@@ -3313,7 +3300,6 @@ wlc_lcnphy_rx_iq_cal(phy_info_t *pi, const lcnphy_rx_iqcomp_t *iqcomp,
break;
}
}
- ASSERT(result);
goto cal_done;
}
@@ -3584,9 +3570,6 @@ void wlc_lcnphy_calib_modes(phy_info_t *pi, uint mode)
if (wlc_lcnphy_tempsense_based_pwr_ctrl_enabled(pi))
wlc_lcnphy_tx_power_adjustment((wlc_phy_t *) pi);
break;
- default:
- ASSERT(0);
- break;
}
}
@@ -5071,9 +5054,7 @@ bool wlc_phy_attach_lcnphy(phy_info_t *pi)
pi->hwpwrctrl_capable = true;
}
- pi->xtalfreq = si_alp_clock(pi->sh->sih);
- ASSERT(0 == (pi->xtalfreq % 1000));
-
+ pi->xtalfreq = si_pmu_alp_clock(pi->sh->sih);
pi_lcn->lcnphy_papd_rxGnCtrl_init = 0;
pi->pi_fptr.init = wlc_phy_init_lcnphy;
@@ -5293,9 +5274,7 @@ wlc_lcnphy_load_tx_iir_filter(phy_info_t *pi, bool is_ofdm, s16 filt_type)
}
}
- if (filt_index == -1) {
- ASSERT(false);
- } else {
+ if (filt_index != -1) {
for (j = 0; j < LCNPHY_NUM_DIG_FILT_COEFFS; j++) {
write_phy_reg(pi, addr[j],
LCNPHY_txdigfiltcoeffs_cck
@@ -5310,9 +5289,7 @@ wlc_lcnphy_load_tx_iir_filter(phy_info_t *pi, bool is_ofdm, s16 filt_type)
}
}
- if (filt_index == -1) {
- ASSERT(false);
- } else {
+ if (filt_index != -1) {
for (j = 0; j < LCNPHY_NUM_DIG_FILT_COEFFS; j++) {
write_phy_reg(pi, addr_ofdm[j],
LCNPHY_txdigfiltcoeffs_ofdm
diff --git a/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_n.c b/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_n.c
index 7947c6028b6e..71275094e810 100644
--- a/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_n.c
+++ b/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_n.c
@@ -20,9 +20,9 @@
#include <wlc_cfg.h>
#include <linux/delay.h>
#include <linux/pci.h>
-#include <siutils.h>
+#include <aiutils.h>
#include <sbchipc.h>
-#include <hndpmu.h>
+#include <wlc_pmu.h>
#include <bcmdevs.h>
#include <sbhnddma.h>
@@ -14218,8 +14218,6 @@ static void WLBANDINITFN(wlc_phy_bphy_init_nphy) (phy_info_t *pi)
{
u16 addr, val;
- ASSERT(ISNPHY(pi));
-
val = 0x1e1f;
for (addr = (NPHY_TO_BPHY_OFF + BPHY_RSSI_LUT);
addr <= (NPHY_TO_BPHY_OFF + BPHY_RSSI_LUT_END); addr++) {
@@ -14367,8 +14365,6 @@ static void WLBANDINITFN(wlc_phy_tbl_init_nphy) (phy_info_t *pi)
break;
default:
-
- ASSERT(0);
break;
}
@@ -14401,8 +14397,6 @@ static void WLBANDINITFN(wlc_phy_tbl_init_nphy) (phy_info_t *pi)
[idx]);
break;
default:
-
- ASSERT(0);
break;
}
} else {
@@ -14550,7 +14544,7 @@ void WLBANDINITFN(wlc_phy_init_nphy) (phy_info_t *pi)
(pi->sh->chippkg == BCM4718_PKG_ID))) {
if ((pi->sh->boardflags & BFL_EXTLNA) &&
(CHSPEC_IS2G(pi->radio_chanspec))) {
- si_corereg(pi->sh->sih, SI_CC_IDX,
+ ai_corereg(pi->sh->sih, SI_CC_IDX,
offsetof(chipcregs_t, chipcontrol), 0x40,
0x40);
}
@@ -14564,17 +14558,15 @@ void WLBANDINITFN(wlc_phy_init_nphy) (phy_info_t *pi)
if ((pi->nphy_gband_spurwar2_en) && CHSPEC_IS2G(pi->radio_chanspec) &&
CHSPEC_IS40(pi->radio_chanspec)) {
- regs = (d11regs_t *) si_switch_core(pi->sh->sih, D11_CORE_ID,
+ regs = (d11regs_t *) ai_switch_core(pi->sh->sih, D11_CORE_ID,
&origidx, &intr_val);
- ASSERT(regs != NULL);
-
d11_clk_ctl_st = R_REG(&regs->clk_ctl_st);
AND_REG(&regs->clk_ctl_st,
~(CCS_FORCEHT | CCS_HTAREQ));
W_REG(&regs->clk_ctl_st, d11_clk_ctl_st);
- si_restore_core(pi->sh->sih, origidx, intr_val);
+ ai_restore_core(pi->sh->sih, origidx, intr_val);
}
pi->use_int_tx_iqlo_cal_nphy =
@@ -14783,10 +14775,7 @@ void WLBANDINITFN(wlc_phy_init_nphy) (phy_info_t *pi)
rfpwr_offset = (s16)
nphy_papd_padgain_dlt_2g_2057rev7
[pad_gn];
- } else {
- ASSERT(0);
}
-
} else {
if ((pi->pubpi.radiorev == 3) ||
(pi->pubpi.radiorev == 4) ||
@@ -14800,8 +14789,6 @@ void WLBANDINITFN(wlc_phy_init_nphy) (phy_info_t *pi)
rfpwr_offset = (s16)
nphy_papd_pgagain_dlt_5g_2057rev7
[pga_gn];
- } else {
- ASSERT(0);
}
}
wlc_phy_table_write_nphy(pi,
@@ -14905,10 +14892,10 @@ void WLBANDINITFN(wlc_phy_init_nphy) (phy_info_t *pi)
}
if (wlc_phy_cal_txiqlo_nphy
- (pi, target_gain, true, false) == BCME_OK) {
+ (pi, target_gain, true, false) == 0) {
if (wlc_phy_cal_rxiq_nphy
(pi, target_gain, 2,
- false) == BCME_OK) {
+ false) == 0) {
wlc_phy_savecal_nphy(pi);
}
@@ -14963,8 +14950,6 @@ static void wlc_phy_resetcca_nphy(phy_info_t *pi)
{
u16 val;
- ASSERT(0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC));
-
wlapi_bmac_phyclk_fgc(pi->sh->physhim, ON);
val = read_phy_reg(pi, 0x01);
@@ -16130,8 +16115,6 @@ static void wlc_phy_workarounds_nphy(phy_info_t *pi)
0x18, 16, bcm_adc_vmid);
wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_AFECTRL, 4,
0x1c, 16, bcm_adc_gain);
- } else {
- ASSERT(0);
}
write_radio_reg(pi,
@@ -17418,8 +17401,10 @@ static void wlc_phy_radio_postinit_2055(phy_info_t *pi)
SPINWAIT(((read_radio_reg(pi, RADIO_2055_CAL_COUNTER_OUT2) &
RADIO_2055_RCAL_DONE) != RADIO_2055_RCAL_DONE), 2000);
- ASSERT((read_radio_reg(pi, RADIO_2055_CAL_COUNTER_OUT2) &
- RADIO_2055_RCAL_DONE) == RADIO_2055_RCAL_DONE);
+ if (WARN((read_radio_reg(pi, RADIO_2055_CAL_COUNTER_OUT2) &
+ RADIO_2055_RCAL_DONE) != RADIO_2055_RCAL_DONE,
+ "HW error: radio calibration1\n"))
+ return;
and_radio_reg(pi, RADIO_2055_CAL_LPO_CNTRL,
~(RADIO_2055_CAL_LPO_ENABLE));
@@ -17510,7 +17495,6 @@ static void wlc_phy_radio_init_2056(phy_info_t *pi)
break;
default:
- ASSERT(0);
break;
}
}
@@ -17571,7 +17555,6 @@ static void wlc_phy_radio_init_2057(phy_info_t *pi)
regs_2057_ptr = regs_2057_rev5v1;
} else {
- ASSERT(0);
break;
}
@@ -17586,11 +17569,8 @@ static void wlc_phy_radio_init_2057(phy_info_t *pi)
break;
default:
- ASSERT(0);
break;
}
- } else {
- ASSERT(0);
}
wlc_phy_init_radio_regs_allbands(pi, regs_2057_ptr);
@@ -17708,7 +17688,6 @@ wlc_phy_chan2freq_nphy(phy_info_t *pi, uint channel, int *f,
}
if (i >= tbl_len) {
- ASSERT(i < tbl_len);
goto fail;
}
if (pi->pubpi.radiorev == 5) {
@@ -17765,7 +17744,6 @@ wlc_phy_chan2freq_nphy(phy_info_t *pi, uint channel, int *f,
}
if (i >= tbl_len) {
- ASSERT(i < tbl_len);
goto fail;
}
*t1 = &chan_info_tbl_p_1[i];
@@ -17777,7 +17755,6 @@ wlc_phy_chan2freq_nphy(phy_info_t *pi, uint channel, int *f,
break;
if (i >= ARRAY_SIZE(chan_info_nphy_2055)) {
- ASSERT(i < ARRAY_SIZE(chan_info_nphy_2055));
goto fail;
}
*t3 = &chan_info_nphy_2055[i];
@@ -18276,7 +18253,9 @@ static u16 wlc_phy_radio205x_rcal(phy_info_t *pi)
udelay(100);
}
- ASSERT(i < MAX_205x_RCAL_WAITLOOPS);
+ if (WARN(i == MAX_205x_RCAL_WAITLOOPS,
+ "HW error: radio calib2"))
+ return 0;
mod_radio_reg(pi, RADIO_2057_RCAL_CONFIG, 0x2, 0x0);
@@ -18325,7 +18304,9 @@ static u16 wlc_phy_radio205x_rcal(phy_info_t *pi)
udelay(100);
}
- ASSERT(i < MAX_205x_RCAL_WAITLOOPS);
+ if (WARN(i == MAX_205x_RCAL_WAITLOOPS,
+ "HW error: radio calib3"))
+ return 0;
write_radio_reg(pi, RADIO_2056_SYN_RCAL_MASTER | RADIO_2056_SYN,
0x1);
@@ -18572,8 +18553,6 @@ static u16 wlc_phy_radio2057_rccal(phy_info_t *pi)
udelay(500);
}
- ASSERT(rccal_valid & 0x2);
-
write_radio_reg(pi, RADIO_2057_RCCAL_START_R1_Q1_P1, 0x15);
rccal_valid = 0;
@@ -18596,8 +18575,6 @@ static u16 wlc_phy_radio2057_rccal(phy_info_t *pi)
udelay(500);
}
- ASSERT(rccal_valid & 0x2);
-
write_radio_reg(pi, RADIO_2057_RCCAL_START_R1_Q1_P1, 0x15);
rccal_valid = 0;
@@ -18621,7 +18598,8 @@ static u16 wlc_phy_radio2057_rccal(phy_info_t *pi)
udelay(500);
}
- ASSERT(rccal_valid & 0x2);
+ if (WARN(!(rccal_valid & 0x2), "HW error: radio calib4"))
+ return 0;
write_radio_reg(pi, RADIO_2057_RCCAL_START_R1_Q1_P1, 0x15);
@@ -19585,8 +19563,6 @@ void wlc_phy_antsel_init(wlc_phy_t *ppi, bool lut_init)
1, 0x08, 16, &v2);
wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_ANTSWCTRLLUT,
1, 0x0C, 16, &v3);
- } else {
- ASSERT(0);
}
if (pi->srom_fem5g.antswctrllut == 0) {
@@ -19598,15 +19574,13 @@ void wlc_phy_antsel_init(wlc_phy_t *ppi, bool lut_init)
1, 0x18, 16, &v2);
wlc_phy_table_write_nphy(pi, NPHY_TBL_ID_ANTSWCTRLLUT,
1, 0x1C, 16, &v3);
- } else {
- ASSERT(0);
}
} else {
write_phy_reg(pi, 0xc8, 0x0);
write_phy_reg(pi, 0xc9, 0x0);
- si_gpiocontrol(pi->sh->sih, mask, mask, GPIO_DRV_PRIORITY);
+ ai_gpiocontrol(pi->sh->sih, mask, mask, GPIO_DRV_PRIORITY);
mc = R_REG(&pi->regs->maccontrol);
mc &= ~MCTL_GPOUT_SEL_MASK;
@@ -19703,8 +19677,7 @@ void wlc_phy_force_rfseq_nphy(phy_info_t *pi, u8 cmd)
or_phy_reg(pi, 0xa3, trigger_mask);
SPINWAIT((read_phy_reg(pi, 0xa4) & status_mask), 200000);
write_phy_reg(pi, 0xa1, orig_RfseqCoreActv);
-
- ASSERT((read_phy_reg(pi, 0xa4) & status_mask) == 0);
+ WARN(read_phy_reg(pi, 0xa4) & status_mask, "HW error in rf");
}
static void
@@ -19718,8 +19691,6 @@ wlc_phy_set_rfseq_nphy(phy_info_t *pi, u8 cmd, u8 *events, u8 *dlys,
3) ? NPHY_REV3_RFSEQ_CMD_END : NPHY_RFSEQ_CMD_END;
u8 end_dly = 1;
- ASSERT(len <= 16);
-
if (pi->phyhang_avoid)
wlc_phy_stay_in_carriersearch_nphy(pi, true);
@@ -21467,7 +21438,7 @@ static void wlc_phy_rssi_cal_nphy_rev2(phy_info_t *pi, u8 rssi_type)
wlc_phy_resetcca_nphy(pi);
}
-int BCMFASTPATH
+int
wlc_phy_rssi_compute_nphy(phy_info_t *pi, wlc_d11rxhdr_t *wlc_rxh)
{
d11rxhdr_t *rxh = &wlc_rxh->rxhdr;
@@ -21503,8 +21474,6 @@ wlc_phy_rssi_compute_nphy(phy_info_t *pi, wlc_d11rxhdr_t *wlc_rxh)
rxpwr = (rxpwr0 < rxpwr1) ? rxpwr0 : rxpwr1;
else if (pi->sh->rssi_mode == RSSI_ANT_MERGE_AVG)
rxpwr = (rxpwr0 + rxpwr1) >> 1;
- else
- ASSERT(0);
return rxpwr;
}
@@ -21588,8 +21557,9 @@ wlc_phy_rfctrlintc_override_nphy(phy_info_t *pi, u8 field, u16 value,
SPINWAIT(((read_phy_reg(pi, 0x78) & val)
!= 0), 10000);
- ASSERT((read_phy_reg(pi, 0x78) & val) ==
- 0);
+ if (WARN(read_phy_reg(pi, 0x78) & val,
+ "HW error: override failed"))
+ return;
mask = (0x1 << 0);
val = 0 << 0;
@@ -22233,8 +22203,6 @@ static void wlc_phy_rssi_cal_nphy_rev3(phy_info_t *pi)
static void wlc_phy_restore_rssical_nphy(phy_info_t *pi)
{
- ASSERT(NREV_GE(pi->pubpi.phy_rev, 3));
-
if (CHSPEC_IS2G(pi->radio_chanspec)) {
if (pi->nphy_rssical_chanspec_2G == 0)
return;
@@ -22399,13 +22367,13 @@ wlc_phy_tx_tone_nphy(phy_info_t *pi, u32 f_kHz, u16 max_val,
num_samps =
wlc_phy_gen_load_samples_nphy(pi, f_kHz, max_val, dac_test_mode);
if (num_samps == 0) {
- return BCME_ERROR;
+ return -EBADE;
}
wlc_phy_runsamples_nphy(pi, num_samps, loops, wait, iqmode,
dac_test_mode, modify_bbmult);
- return BCME_OK;
+ return 0;
}
static void
@@ -22775,8 +22743,6 @@ wlc_phy_iqcal_gainparams_nphy(phy_info_t *pi, u16 core_no,
}
}
- ASSERT(idx != -1);
-
params->txgm = tbl_iqcal_gainparams_nphy[band_idx][k][1];
params->pga = tbl_iqcal_gainparams_nphy[band_idx][k][2];
params->pad = tbl_iqcal_gainparams_nphy[band_idx][k][3];
@@ -23855,8 +23821,6 @@ void wlc_phy_cal_perical_nphy_run(phy_info_t *pi, u8 caltype)
if (PHY_MUTED(pi))
return;
- ASSERT(pi->nphy_perical != PHY_PERICAL_DISABLE);
-
if (caltype == PHY_PERICAL_AUTO)
fullcal = (pi->radio_chanspec != pi->nphy_txiqlocal_chanspec);
else if (caltype == PHY_PERICAL_PARTIAL)
@@ -23913,7 +23877,7 @@ void wlc_phy_cal_perical_nphy_run(phy_info_t *pi, u8 caltype)
target_gain = pi->nphy_cal_target_gain;
}
- if (BCME_OK ==
+ if (0 ==
wlc_phy_cal_txiqlo_nphy(pi, target_gain, fullcal, mphase)) {
if (PHY_IPA(pi))
wlc_phy_a4(pi, true);
@@ -23925,7 +23889,7 @@ void wlc_phy_cal_perical_nphy_run(phy_info_t *pi, u8 caltype)
wlapi_suspend_mac_and_wait(pi->sh->physhim);
wlc_phyreg_enter((wlc_phy_t *) pi);
- if (BCME_OK == wlc_phy_cal_rxiq_nphy(pi, target_gain,
+ if (0 == wlc_phy_cal_rxiq_nphy(pi, target_gain,
(pi->
first_cal_after_assoc
|| (pi->
@@ -23955,8 +23919,6 @@ void wlc_phy_cal_perical_nphy_run(phy_info_t *pi, u8 caltype)
wlc_phy_radio205x_vcocal_nphy(pi);
}
} else {
- ASSERT(pi->nphy_perical >= PHY_PERICAL_MPHASE);
-
switch (pi->mphase_cal_phase_id) {
case MPHASE_CAL_STATE_INIT:
pi->nphy_perical_last = pi->sh->now;
@@ -23980,7 +23942,7 @@ void wlc_phy_cal_perical_nphy_run(phy_info_t *pi, u8 caltype)
if (wlc_phy_cal_txiqlo_nphy
(pi, pi->nphy_cal_target_gain, fullcal,
- true) != BCME_OK) {
+ true) != 0) {
wlc_phy_cal_perical_mphase_reset(pi);
break;
@@ -24012,7 +23974,7 @@ void wlc_phy_cal_perical_nphy_run(phy_info_t *pi, u8 caltype)
(pi->first_cal_after_assoc ||
(pi->cal_type_override ==
PHY_PERICAL_FULL)) ? 2 : 0,
- false) == BCME_OK) {
+ false) == 0) {
wlc_phy_savecal_nphy(pi);
}
@@ -24052,7 +24014,6 @@ void wlc_phy_cal_perical_nphy_run(phy_info_t *pi, u8 caltype)
break;
default:
- ASSERT(0);
wlc_phy_cal_perical_mphase_reset(pi);
break;
}
@@ -24116,7 +24077,7 @@ wlc_phy_cal_txiqlo_nphy(phy_info_t *pi, nphy_txgains_t target_gain,
void *tbl_ptr;
bool ladder_updated[2];
u8 mphase_cal_lastphase = 0;
- int bcmerror = BCME_OK;
+ int bcmerror = 0;
bool phyhang_avoid_state = false;
u16 tbl_tx_iqlo_cal_loft_ladder_20[] = {
@@ -24242,13 +24203,13 @@ wlc_phy_cal_txiqlo_nphy(phy_info_t *pi, nphy_txgains_t target_gain,
if (pi->mphase_cal_phase_id > MPHASE_CAL_STATE_TXPHASE0) {
wlc_phy_runsamples_nphy(pi, phy_bw * 8, 0xffff, 0, 1, 0, false);
- bcmerror = BCME_OK;
+ bcmerror = 0;
} else {
bcmerror =
wlc_phy_tx_tone_nphy(pi, tone_freq, max_val, 1, 0, false);
}
- if (bcmerror == BCME_OK) {
+ if (bcmerror == 0) {
if (pi->mphase_cal_phase_id > MPHASE_CAL_STATE_TXPHASE0) {
tbl_ptr = pi->mphase_txcal_bestcoeffs;
@@ -24361,7 +24322,9 @@ wlc_phy_cal_txiqlo_nphy(phy_info_t *pi, nphy_txgains_t target_gain,
SPINWAIT(((read_phy_reg(pi, 0xc0) & 0xc000) != 0),
20000);
- ASSERT((read_phy_reg(pi, 0xc0) & 0xc000) == 0);
+ if (WARN(read_phy_reg(pi, 0xc0) & 0xc000,
+ "HW error: txiq calib"))
+ return -EIO;
wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_IQLOCAL,
tbl_len, 96, 16, tbl_buf);
@@ -24468,8 +24431,6 @@ static void wlc_phy_reapply_txcal_coeffs_nphy(phy_info_t *pi)
{
u16 tbl_buf[7];
- ASSERT(NREV_LT(pi->pubpi.phy_rev, 2));
-
if ((pi->nphy_txiqlocal_chanspec == pi->radio_chanspec) &&
(pi->nphy_txiqlocal_coeffsvalid)) {
wlc_phy_table_read_nphy(pi, NPHY_TBL_ID_IQLOCAL,
@@ -24544,10 +24505,11 @@ wlc_phy_rx_iq_est_nphy(phy_info_t *pi, phy_iq_est_t *est, u16 num_samps,
SPINWAIT(((read_phy_reg(pi, 0x129) & NPHY_IqestCmd_iqstart) != 0),
10000);
- ASSERT((read_phy_reg(pi, 0x129) & NPHY_IqestCmd_iqstart) == 0);
+ if (WARN(read_phy_reg(pi, 0x129) & NPHY_IqestCmd_iqstart,
+ "HW error: rxiq est"))
+ return;
if ((read_phy_reg(pi, 0x129) & NPHY_IqestCmd_iqstart) == 0) {
- ASSERT(pi->pubpi.phy_corenum <= PHY_CORE_MAX);
for (core = 0; core < pi->pubpi.phy_corenum; core++) {
est[core].i_pwr =
(read_phy_reg(pi, NPHY_IqestipwrAccHi(core)) << 16)
@@ -24572,7 +24534,7 @@ static void wlc_phy_calc_rx_iq_comp_nphy(phy_info_t *pi, u8 core_mask)
u32 ii = 0, qq = 0;
s16 iq_nbits, qq_nbits, brsh, arsh;
s32 a, b, temp;
- int bcmerror = BCME_OK;
+ int bcmerror = 0;
uint cal_retry = 0;
if (core_mask == 0x0)
@@ -24602,7 +24564,7 @@ static void wlc_phy_calc_rx_iq_comp_nphy(phy_info_t *pi, u8 core_mask)
}
if ((ii + qq) < NPHY_MIN_RXIQ_PWR) {
- bcmerror = BCME_ERROR;
+ bcmerror = -EBADE;
break;
}
@@ -24614,14 +24576,14 @@ static void wlc_phy_calc_rx_iq_comp_nphy(phy_info_t *pi, u8 core_mask)
a = (-(iq << (30 - iq_nbits)) + (ii >> (1 + arsh)));
temp = (s32) (ii >> arsh);
if (temp == 0) {
- bcmerror = BCME_ERROR;
+ bcmerror = -EBADE;
break;
}
} else {
a = (-(iq << (30 - iq_nbits)) + (ii << (-1 - arsh)));
temp = (s32) (ii << -arsh);
if (temp == 0) {
- bcmerror = BCME_ERROR;
+ bcmerror = -EBADE;
break;
}
}
@@ -24633,20 +24595,20 @@ static void wlc_phy_calc_rx_iq_comp_nphy(phy_info_t *pi, u8 core_mask)
b = (qq << (31 - qq_nbits));
temp = (s32) (ii >> brsh);
if (temp == 0) {
- bcmerror = BCME_ERROR;
+ bcmerror = -EBADE;
break;
}
} else {
b = (qq << (31 - qq_nbits));
temp = (s32) (ii << -brsh);
if (temp == 0) {
- bcmerror = BCME_ERROR;
+ bcmerror = -EBADE;
break;
}
}
b /= temp;
b -= a * a;
- b = (s32) wlc_phy_sqrt_int((u32) b);
+ b = (s32) int_sqrt((unsigned long) b);
b -= (1 << 10);
if ((curr_core == PHY_CORE_0) && (core_mask & 0x1)) {
@@ -24671,7 +24633,7 @@ static void wlc_phy_calc_rx_iq_comp_nphy(phy_info_t *pi, u8 core_mask)
}
}
- if (bcmerror != BCME_OK) {
+ if (bcmerror != 0) {
printk("%s: Failed, cnt = %d\n", __func__, cal_retry);
if (cal_retry < CAL_RETRY_CNT) {
@@ -25451,7 +25413,7 @@ wlc_phy_rxcal_gainctrl_nphy_rev5(phy_info_t *pi, u8 rx_core,
break;
default:
- ASSERT(0);
+ break;
}
if ((curr_gaintbl_index < 0) ||
@@ -25916,7 +25878,7 @@ wlc_phy_cal_rxiq_nphy_rev3(phy_info_t *pi, nphy_txgains_t target_gain,
wlc_phy_stay_in_carriersearch_nphy(pi, false);
- return BCME_OK;
+ return 0;
}
static int
@@ -25941,7 +25903,7 @@ wlc_phy_cal_rxiq_nphy_rev2(phy_info_t *pi, nphy_txgains_t target_gain,
u16 cal_gain[2];
nphy_iqcal_params_t cal_params[2];
u8 phy_bw;
- int bcmerror = BCME_OK;
+ int bcmerror = 0;
bool first_playtone = true;
wlc_phy_stay_in_carriersearch_nphy(pi, true);
@@ -26091,7 +26053,7 @@ wlc_phy_cal_rxiq_nphy_rev2(phy_info_t *pi, nphy_txgains_t target_gain,
0, 0, 0, true);
}
- if (bcmerror == BCME_OK) {
+ if (bcmerror == 0) {
if (gain_pass < 3) {
wlc_phy_rx_iq_est_nphy(pi, est,
@@ -26114,7 +26076,7 @@ wlc_phy_cal_rxiq_nphy_rev2(phy_info_t *pi, nphy_txgains_t target_gain,
wlc_phy_stopplayback_nphy(pi);
}
- if (bcmerror != BCME_OK)
+ if (bcmerror != 0)
break;
}
@@ -26130,7 +26092,7 @@ wlc_phy_cal_rxiq_nphy_rev2(phy_info_t *pi, nphy_txgains_t target_gain,
0xa7, orig_AfectrlCore);
write_phy_reg(pi, 0xa2, orig_RfseqCoreActv);
- if (bcmerror != BCME_OK)
+ if (bcmerror != 0)
break;
}
@@ -26270,8 +26232,6 @@ static u32 *wlc_phy_get_ipa_gaintbl_nphy(phy_info_t *pi)
tx_pwrctrl_tbl =
nphy_tpc_txgain_ipa_2g_2057rev7;
- } else {
- ASSERT(0);
}
} else if (NREV_IS(pi->pubpi.phy_rev, 6)) {
@@ -26303,8 +26263,6 @@ static u32 *wlc_phy_get_ipa_gaintbl_nphy(phy_info_t *pi)
tx_pwrctrl_tbl =
nphy_tpc_txgain_ipa_5g_2057rev7;
- } else {
- ASSERT(0);
}
} else {
@@ -26347,8 +26305,6 @@ wlc_phy_papd_cal_setup_nphy(phy_info_t *pi, nphy_papd_restore_state *state,
|| (pi->pubpi.radiorev == 6)) {
mixgain = 0x00;
- } else {
- ASSERT(0);
}
} else {
@@ -26361,8 +26317,6 @@ wlc_phy_papd_cal_setup_nphy(phy_info_t *pi, nphy_papd_restore_state *state,
|| (pi->pubpi.radiorev == 8)) {
mixgain = 0x0;
- } else {
- ASSERT(0);
}
}
@@ -26464,8 +26418,6 @@ wlc_phy_papd_cal_setup_nphy(phy_info_t *pi, nphy_papd_restore_state *state,
WRITE_RADIO_REG3(pi, RADIO_2057, TX, core,
TXRXCOUPLE_2G_ATTEN, 0xf0);
- } else {
- ASSERT(0);
}
WRITE_RADIO_REG3(pi, RADIO_2057, TX, off_core,
@@ -26724,8 +26676,6 @@ wlc_phy_a1_nphy(phy_info_t *pi, u8 core, u32 winsz, u32 start,
u32 *buf, *src, *dst, sz;
sz = end - start + 1;
- ASSERT(end > start);
- ASSERT(end < NPHY_PAPD_EPS_TBL_SIZE);
buf = kmalloc(2 * sizeof(u32) * NPHY_PAPD_EPS_TBL_SIZE, GFP_ATOMIC);
if (NULL == buf) {
@@ -26787,8 +26737,6 @@ wlc_phy_a2_nphy(phy_info_t *pi, nphy_ipa_txcalgains_t *txgains,
phy_a7 = (core == PHY_CORE_0) ? 1 : 0;
- ASSERT((cal_mode == CAL_FULL) || (cal_mode == CAL_GCTRL)
- || (cal_mode == CAL_SOFT));
phy_a6 = ((cal_mode == CAL_GCTRL)
|| (cal_mode == CAL_SOFT)) ? true : false;
@@ -27333,8 +27281,6 @@ static void wlc_phy_a4(phy_info_t *pi, bool full_cal)
nphy_papd_cal_gain_index
[phy_b5], phy_b5);
- } else {
- ASSERT(0);
}
phy_b1[phy_b5].gains.pad[phy_b5] =
@@ -27417,8 +27363,6 @@ static void wlc_phy_a4(phy_info_t *pi, bool full_cal)
-(nphy_papd_padgain_dlt_2g_2057rev7
[phy_b8]
+ 1) / 2;
- } else {
- ASSERT(0);
}
} else {
phy_b7 = phy_b1[phy_b5].gains.pga[phy_b5];
@@ -27435,8 +27379,6 @@ static void wlc_phy_a4(phy_info_t *pi, bool full_cal)
-(nphy_papd_pgagain_dlt_5g_2057rev7
[phy_b7]
+ 1) / 2;
- } else {
- ASSERT(0);
}
phy_b10 = -9;
@@ -27536,8 +27478,6 @@ void wlc_phy_txpwr_fixpower_nphy(phy_info_t *pi)
u8 txpi[2], chan_freq_range;
s32 rfpwr_offset;
- ASSERT(pi->nphy_txpwrctrl == PHY_TPC_HW_OFF);
-
if (pi->phyhang_avoid)
wlc_phy_stay_in_carriersearch_nphy(pi, true);
@@ -29179,7 +29119,6 @@ wlc_phy_txpower_sromlimit_get_nphy(phy_info_t *pi, uint chan, u8 *max_pwr,
*max_pwr = pi->tx_srom_max_rate_5g_hi[txp_rate_idx];
break;
default:
- ASSERT(0);
*max_pwr = pi->tx_srom_max_rate_2g[txp_rate_idx];
break;
}
@@ -29191,8 +29130,6 @@ void wlc_phy_stay_in_carriersearch_nphy(phy_info_t *pi, bool enable)
{
u16 clip_off[] = { 0xffff, 0xffff };
- ASSERT(0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC));
-
if (enable) {
if (pi->nphy_deaf_count == 0) {
pi->classifier_state =
@@ -29207,8 +29144,6 @@ void wlc_phy_stay_in_carriersearch_nphy(phy_info_t *pi, bool enable)
wlc_phy_resetcca_nphy(pi);
} else {
- ASSERT(pi->nphy_deaf_count > 0);
-
pi->nphy_deaf_count--;
if (pi->nphy_deaf_count == 0) {
diff --git a/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_qmath.c b/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_qmath.c
new file mode 100644
index 000000000000..c98176fd0aae
--- /dev/null
+++ b/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_qmath.c
@@ -0,0 +1,296 @@
+/*
+ * Copyright (c) 2010 Broadcom Corporation
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <linux/types.h>
+
+#include "wlc_phy_qmath.h"
+
+/*
+Description: This function make 16 bit unsigned multiplication. To fit the output into
+16 bits the 32 bit multiplication result is right shifted by 16 bits.
+*/
+u16 qm_mulu16(u16 op1, u16 op2)
+{
+ return (u16) (((u32) op1 * (u32) op2) >> 16);
+}
+
+/*
+Description: This function make 16 bit multiplication and return the result in 16 bits.
+To fit the multiplication result into 16 bits the multiplication result is right shifted by
+15 bits. Right shifting 15 bits instead of 16 bits is done to remove the extra sign bit formed
+due to the multiplication.
+When both the 16bit inputs are 0x8000 then the output is saturated to 0x7fffffff.
+*/
+s16 qm_muls16(s16 op1, s16 op2)
+{
+ s32 result;
+ if (op1 == (s16) 0x8000 && op2 == (s16) 0x8000) {
+ result = 0x7fffffff;
+ } else {
+ result = ((s32) (op1) * (s32) (op2));
+ }
+ return (s16) (result >> 15);
+}
+
+/*
+Description: This function add two 32 bit numbers and return the 32bit result.
+If the result overflow 32 bits, the output will be saturated to 32bits.
+*/
+s32 qm_add32(s32 op1, s32 op2)
+{
+ s32 result;
+ result = op1 + op2;
+ if (op1 < 0 && op2 < 0 && result > 0) {
+ result = 0x80000000;
+ } else if (op1 > 0 && op2 > 0 && result < 0) {
+ result = 0x7fffffff;
+ }
+ return result;
+}
+
+/*
+Description: This function add two 16 bit numbers and return the 16bit result.
+If the result overflow 16 bits, the output will be saturated to 16bits.
+*/
+s16 qm_add16(s16 op1, s16 op2)
+{
+ s16 result;
+ s32 temp = (s32) op1 + (s32) op2;
+ if (temp > (s32) 0x7fff) {
+ result = (s16) 0x7fff;
+ } else if (temp < (s32) 0xffff8000) {
+ result = (s16) 0xffff8000;
+ } else {
+ result = (s16) temp;
+ }
+ return result;
+}
+
+/*
+Description: This function make 16 bit subtraction and return the 16bit result.
+If the result overflow 16 bits, the output will be saturated to 16bits.
+*/
+s16 qm_sub16(s16 op1, s16 op2)
+{
+ s16 result;
+ s32 temp = (s32) op1 - (s32) op2;
+ if (temp > (s32) 0x7fff) {
+ result = (s16) 0x7fff;
+ } else if (temp < (s32) 0xffff8000) {
+ result = (s16) 0xffff8000;
+ } else {
+ result = (s16) temp;
+ }
+ return result;
+}
+
+/*
+Description: This function make a 32 bit saturated left shift when the specified shift
+is +ve. This function will make a 32 bit right shift when the specified shift is -ve.
+This function return the result after shifting operation.
+*/
+s32 qm_shl32(s32 op, int shift)
+{
+ int i;
+ s32 result;
+ result = op;
+ if (shift > 31)
+ shift = 31;
+ else if (shift < -31)
+ shift = -31;
+ if (shift >= 0) {
+ for (i = 0; i < shift; i++) {
+ result = qm_add32(result, result);
+ }
+ } else {
+ result = result >> (-shift);
+ }
+ return result;
+}
+
+/*
+Description: This function make a 16 bit saturated left shift when the specified shift
+is +ve. This function will make a 16 bit right shift when the specified shift is -ve.
+This function return the result after shifting operation.
+*/
+s16 qm_shl16(s16 op, int shift)
+{
+ int i;
+ s16 result;
+ result = op;
+ if (shift > 15)
+ shift = 15;
+ else if (shift < -15)
+ shift = -15;
+ if (shift > 0) {
+ for (i = 0; i < shift; i++) {
+ result = qm_add16(result, result);
+ }
+ } else {
+ result = result >> (-shift);
+ }
+ return result;
+}
+
+/*
+Description: This function make a 16 bit right shift when shift is +ve.
+This function make a 16 bit saturated left shift when shift is -ve. This function
+return the result of the shift operation.
+*/
+s16 qm_shr16(s16 op, int shift)
+{
+ return qm_shl16(op, -shift);
+}
+
+/*
+Description: This function return the number of redundant sign bits in a 32 bit number.
+Example: qm_norm32(0x00000080) = 23
+*/
+s16 qm_norm32(s32 op)
+{
+ u16 u16extraSignBits;
+ if (op == 0) {
+ return 31;
+ } else {
+ u16extraSignBits = 0;
+ while ((op >> 31) == (op >> 30)) {
+ u16extraSignBits++;
+ op = op << 1;
+ }
+ }
+ return u16extraSignBits;
+}
+
+/* This table is log2(1+(i/32)) where i=[0:1:31], in q.15 format */
+static const s16 log_table[] = {
+ 0,
+ 1455,
+ 2866,
+ 4236,
+ 5568,
+ 6863,
+ 8124,
+ 9352,
+ 10549,
+ 11716,
+ 12855,
+ 13968,
+ 15055,
+ 16117,
+ 17156,
+ 18173,
+ 19168,
+ 20143,
+ 21098,
+ 22034,
+ 22952,
+ 23852,
+ 24736,
+ 25604,
+ 26455,
+ 27292,
+ 28114,
+ 28922,
+ 29717,
+ 30498,
+ 31267,
+ 32024
+};
+
+#define LOG_TABLE_SIZE 32 /* log_table size */
+#define LOG2_LOG_TABLE_SIZE 5 /* log2(log_table size) */
+#define Q_LOG_TABLE 15 /* qformat of log_table */
+#define LOG10_2 19728 /* log10(2) in q.16 */
+
+/*
+Description:
+This routine takes the input number N and its q format qN and compute
+the log10(N). This routine first normalizes the input no N. Then N is in mag*(2^x) format.
+mag is any number in the range 2^30-(2^31 - 1). Then log2(mag * 2^x) = log2(mag) + x is computed.
+From that log10(mag * 2^x) = log2(mag * 2^x) * log10(2) is computed.
+This routine looks the log2 value in the table considering LOG2_LOG_TABLE_SIZE+1 MSBs.
+As the MSB is always 1, only next LOG2_OF_LOG_TABLE_SIZE MSBs are used for table lookup.
+Next 16 MSBs are used for interpolation.
+Inputs:
+N - number to which log10 has to be found.
+qN - q format of N
+log10N - address where log10(N) will be written.
+qLog10N - address where log10N qformat will be written.
+Note/Problem:
+For accurate results input should be in normalized or near normalized form.
+*/
+void qm_log10(s32 N, s16 qN, s16 *log10N, s16 *qLog10N)
+{
+ s16 s16norm, s16tableIndex, s16errorApproximation;
+ u16 u16offset;
+ s32 s32log;
+
+ /* normalize the N. */
+ s16norm = qm_norm32(N);
+ N = N << s16norm;
+
+ /* The qformat of N after normalization.
+ * -30 is added to treat the no as between 1.0 to 2.0
+ * i.e. after adding the -30 to the qformat the decimal point will be
+ * just rigtht of the MSB. (i.e. after sign bit and 1st MSB). i.e.
+ * at the right side of 30th bit.
+ */
+ qN = qN + s16norm - 30;
+
+ /* take the table index as the LOG2_OF_LOG_TABLE_SIZE bits right of the MSB */
+ s16tableIndex = (s16) (N >> (32 - (2 + LOG2_LOG_TABLE_SIZE)));
+
+ /* remove the MSB. the MSB is always 1 after normalization. */
+ s16tableIndex =
+ s16tableIndex & (s16) ((1 << LOG2_LOG_TABLE_SIZE) - 1);
+
+ /* remove the (1+LOG2_OF_LOG_TABLE_SIZE) MSBs in the N. */
+ N = N & ((1 << (32 - (2 + LOG2_LOG_TABLE_SIZE))) - 1);
+
+ /* take the offset as the 16 MSBS after table index.
+ */
+ u16offset = (u16) (N >> (32 - (2 + LOG2_LOG_TABLE_SIZE + 16)));
+
+ /* look the log value in the table. */
+ s32log = log_table[s16tableIndex]; /* q.15 format */
+
+ /* interpolate using the offset. */
+ s16errorApproximation = (s16) qm_mulu16(u16offset, (u16) (log_table[s16tableIndex + 1] - log_table[s16tableIndex])); /* q.15 */
+
+ s32log = qm_add16((s16) s32log, s16errorApproximation); /* q.15 format */
+
+ /* adjust for the qformat of the N as
+ * log2(mag * 2^x) = log2(mag) + x
+ */
+ s32log = qm_add32(s32log, ((s32) -qN) << 15); /* q.15 format */
+
+ /* normalize the result. */
+ s16norm = qm_norm32(s32log);
+
+ /* bring all the important bits into lower 16 bits */
+ s32log = qm_shl32(s32log, s16norm - 16); /* q.15+s16norm-16 format */
+
+ /* compute the log10(N) by multiplying log2(N) with log10(2).
+ * as log10(mag * 2^x) = log2(mag * 2^x) * log10(2)
+ * log10N in q.15+s16norm-16+1 (LOG10_2 is in q.16)
+ */
+ *log10N = qm_muls16((s16) s32log, (s16) LOG10_2);
+
+ /* write the q format of the result. */
+ *qLog10N = 15 + s16norm - 16 + 1;
+
+ return;
+}
diff --git a/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_qmath.h b/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_qmath.h
new file mode 100644
index 000000000000..3dcee1c4aa65
--- /dev/null
+++ b/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_qmath.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2010 Broadcom Corporation
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef __QMATH_H__
+#define __QMATH_H__
+
+u16 qm_mulu16(u16 op1, u16 op2);
+
+s16 qm_muls16(s16 op1, s16 op2);
+
+s32 qm_add32(s32 op1, s32 op2);
+
+s16 qm_add16(s16 op1, s16 op2);
+
+s16 qm_sub16(s16 op1, s16 op2);
+
+s32 qm_shl32(s32 op, int shift);
+
+s16 qm_shl16(s16 op, int shift);
+
+s16 qm_shr16(s16 op, int shift);
+
+s16 qm_norm32(s32 op);
+
+void qm_log10(s32 N, s16 qN, s16 *log10N, s16 *qLog10N);
+
+#endif /* #ifndef __QMATH_H__ */