Commit f4e5c544 authored by Arend van Spriel's avatar Arend van Spriel Committed by Greg Kroah-Hartman

staging: brcm80211: remove code duplication for driver variable lookup

The phy code used its own driver variable lookup functions which were
duplicates of those in the brcmsmac driver (in srom.c). The phy code
now uses the functions in srom.c through the phy_shim interface.
Reviewed-by: default avatarPieter-Paul Giesberts <pieterpg@broadcom.com>
Reviewed-by: default avatarAlwin Beukers <alwin@broadcom.com>
Reviewed-by: default avatarRoland Vossen <rvossen@broadcom.com>
Signed-off-by: default avatarArend van Spriel <arend@broadcom.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 43e45c3e
......@@ -126,42 +126,6 @@ const u8 ofdm_rate_lookup[] = {
#define PHY_WREG_LIMIT 24
char *phy_getvar(struct brcms_phy *pi, const char *name)
{
char *vars = pi->vars;
char *s;
int len;
if (!name)
return NULL;
len = strlen(name);
if (len == 0)
return NULL;
for (s = vars; s && *s;) {
if ((memcmp(s, name, len) == 0) && (s[len] == '='))
return &s[len + 1];
while (*s++)
;
}
return NULL;
}
int phy_getintvar(struct brcms_phy *pi, const char *name)
{
char *val;
unsigned long res;
val = PHY_GETVAR(pi, name);
if (val && !kstrtoul(val, 0, &res))
return res;
return 0;
}
void wlc_phyreg_enter(struct brcms_phy_pub *pih)
{
struct brcms_phy *pi = (struct brcms_phy *) pih;
......
......@@ -919,12 +919,6 @@ struct lcnphy_radio_regs {
u8 do_init_g;
};
extern char *phy_getvar(struct brcms_phy *pi, const char *name);
extern int phy_getintvar(struct brcms_phy *pi, const char *name);
#define PHY_GETVAR(pi, name) phy_getvar(pi, name)
#define PHY_GETINTVAR(pi, name) phy_getintvar(pi, name)
extern u16 read_phy_reg(struct brcms_phy *pi, u16 addr);
extern void write_phy_reg(struct brcms_phy *pi, u16 addr, u16 val);
extern void and_phy_reg(struct brcms_phy *pi, u16 addr, u16 val);
......
......@@ -4823,18 +4823,21 @@ static bool wlc_phy_txpwr_srom_read_lcnphy(struct brcms_phy *pi)
u32 offset_ofdm, offset_mcs;
pi_lcn->lcnphy_tr_isolation_mid =
(u8) PHY_GETINTVAR(pi, "triso2g");
(u8) wlapi_getintvar(pi->vars, "triso2g");
pi_lcn->lcnphy_rx_power_offset =
(u8) PHY_GETINTVAR(pi, "rxpo2g");
(u8) wlapi_getintvar(pi->vars, "rxpo2g");
pi->txpa_2g[0] = (s16) PHY_GETINTVAR(pi, "pa0b0");
pi->txpa_2g[1] = (s16) PHY_GETINTVAR(pi, "pa0b1");
pi->txpa_2g[2] = (s16) PHY_GETINTVAR(pi, "pa0b2");
pi->txpa_2g[0] = (s16) wlapi_getintvar(pi->vars, "pa0b0");
pi->txpa_2g[1] = (s16) wlapi_getintvar(pi->vars, "pa0b1");
pi->txpa_2g[2] = (s16) wlapi_getintvar(pi->vars, "pa0b2");
pi_lcn->lcnphy_rssi_vf = (u8) PHY_GETINTVAR(pi, "rssismf2g");
pi_lcn->lcnphy_rssi_vc = (u8) PHY_GETINTVAR(pi, "rssismc2g");
pi_lcn->lcnphy_rssi_gs = (u8) PHY_GETINTVAR(pi, "rssisav2g");
pi_lcn->lcnphy_rssi_vf =
(u8) wlapi_getintvar(pi->vars, "rssismf2g");
pi_lcn->lcnphy_rssi_vc =
(u8) wlapi_getintvar(pi->vars, "rssismc2g");
pi_lcn->lcnphy_rssi_gs =
(u8) wlapi_getintvar(pi->vars, "rssisav2g");
pi_lcn->lcnphy_rssi_vf_lowtemp = pi_lcn->lcnphy_rssi_vf;
pi_lcn->lcnphy_rssi_vc_lowtemp = pi_lcn->lcnphy_rssi_vc;
......@@ -4844,7 +4847,7 @@ static bool wlc_phy_txpwr_srom_read_lcnphy(struct brcms_phy *pi)
pi_lcn->lcnphy_rssi_vc_hightemp = pi_lcn->lcnphy_rssi_vc;
pi_lcn->lcnphy_rssi_gs_hightemp = pi_lcn->lcnphy_rssi_gs;
txpwr = (s8) PHY_GETINTVAR(pi, "maxp2ga0");
txpwr = (s8) wlapi_getintvar(pi->vars, "maxp2ga0");
pi->tx_srom_max_2g = txpwr;
for (i = 0; i < PWRTBL_NUM_COEFF; i++) {
......@@ -4852,7 +4855,7 @@ static bool wlc_phy_txpwr_srom_read_lcnphy(struct brcms_phy *pi)
pi->txpa_2g_high_temp[i] = pi->txpa_2g[i];
}
cckpo = (u16) PHY_GETINTVAR(pi, "cck2gpo");
cckpo = (u16) wlapi_getintvar(pi->vars, "cck2gpo");
if (cckpo) {
uint max_pwr_chan = txpwr;
......@@ -4862,7 +4865,8 @@ static bool wlc_phy_txpwr_srom_read_lcnphy(struct brcms_phy *pi)
cckpo >>= 4;
}
offset_ofdm = (u32) PHY_GETINTVAR(pi, "ofdm2gpo");
offset_ofdm =
(u32) wlapi_getintvar(pi->vars, "ofdm2gpo");
for (i = TXP_FIRST_OFDM; i <= TXP_LAST_OFDM; i++) {
pi->tx_srom_max_rate_2g[i] =
max_pwr_chan -
......@@ -4872,12 +4876,13 @@ static bool wlc_phy_txpwr_srom_read_lcnphy(struct brcms_phy *pi)
} else {
u8 opo = 0;
opo = (u8) PHY_GETINTVAR(pi, "opo");
opo = (u8) wlapi_getintvar(pi->vars, "opo");
for (i = TXP_FIRST_CCK; i <= TXP_LAST_CCK; i++)
pi->tx_srom_max_rate_2g[i] = txpwr;
offset_ofdm = (u32) PHY_GETINTVAR(pi, "ofdm2gpo");
offset_ofdm =
(u32) wlapi_getintvar(pi->vars, "ofdm2gpo");
for (i = TXP_FIRST_OFDM; i <= TXP_LAST_OFDM; i++) {
pi->tx_srom_max_rate_2g[i] = txpwr -
......@@ -4885,8 +4890,9 @@ static bool wlc_phy_txpwr_srom_read_lcnphy(struct brcms_phy *pi)
offset_ofdm >>= 4;
}
offset_mcs =
((u16) PHY_GETINTVAR(pi, "mcs2gpo1") << 16) |
(u16) PHY_GETINTVAR(pi, "mcs2gpo0");
wlapi_getintvar(pi->vars, "mcs2gpo1") << 16;
offset_mcs |=
(u16) wlapi_getintvar(pi->vars, "mcs2gpo0");
pi_lcn->lcnphy_mcs20_po = offset_mcs;
for (i = TXP_FIRST_SISO_MCS_20;
i <= TXP_LAST_SISO_MCS_20; i++) {
......@@ -4897,30 +4903,30 @@ static bool wlc_phy_txpwr_srom_read_lcnphy(struct brcms_phy *pi)
}
pi_lcn->lcnphy_rawtempsense =
(u16) PHY_GETINTVAR(pi, "rawtempsense");
(u16) wlapi_getintvar(pi->vars, "rawtempsense");
pi_lcn->lcnphy_measPower =
(u8) PHY_GETINTVAR(pi, "measpower");
(u8) wlapi_getintvar(pi->vars, "measpower");
pi_lcn->lcnphy_tempsense_slope =
(u8) PHY_GETINTVAR(pi, "tempsense_slope");
(u8) wlapi_getintvar(pi->vars, "tempsense_slope");
pi_lcn->lcnphy_hw_iqcal_en =
(bool) PHY_GETINTVAR(pi, "hw_iqcal_en");
(bool) wlapi_getintvar(pi->vars, "hw_iqcal_en");
pi_lcn->lcnphy_iqcal_swp_dis =
(bool) PHY_GETINTVAR(pi, "iqcal_swp_dis");
(bool) wlapi_getintvar(pi->vars, "iqcal_swp_dis");
pi_lcn->lcnphy_tempcorrx =
(u8) PHY_GETINTVAR(pi, "tempcorrx");
(u8) wlapi_getintvar(pi->vars, "tempcorrx");
pi_lcn->lcnphy_tempsense_option =
(u8) PHY_GETINTVAR(pi, "tempsense_option");
(u8) wlapi_getintvar(pi->vars, "tempsense_option");
pi_lcn->lcnphy_freqoffset_corr =
(u8) PHY_GETINTVAR(pi, "freqoffset_corr");
(u8) wlapi_getintvar(pi->vars, "freqoffset_corr");
if ((u8) getintvar(pi->vars, "aa2g") > 1)
wlc_phy_ant_rxdiv_set((struct brcms_phy_pub *) pi,
(u8) getintvar(pi->vars,
"aa2g"));
}
pi_lcn->lcnphy_cck_dig_filt_type = -1;
if (PHY_GETVAR(pi, "cckdigfilttype")) {
if (wlapi_getvar(pi->vars, "cckdigfilttype")) {
s16 temp;
temp = (s16) PHY_GETINTVAR(pi, "cckdigfilttype");
temp = (s16) wlapi_getintvar(pi->vars, "cckdigfilttype");
if (temp >= 0)
pi_lcn->lcnphy_cck_dig_filt_type = temp;
}
......
......@@ -215,3 +215,12 @@ wlapi_copyto_objmem(struct phy_shim_info *physhim, uint offset, const void *buf,
{
brcms_b_copyto_objmem(physhim->wlc_hw, offset, buf, l, sel);
}
char *wlapi_getvar(char *vars, const char *name)
{
return getvar(vars, name);
}
int wlapi_getintvar(char *vars, const char *name)
{
return getintvar(vars, name);
}
......@@ -178,4 +178,7 @@ extern void wlapi_copyto_objmem(struct phy_shim_info *physhim, uint,
extern void wlapi_high_update_phy_mode(struct phy_shim_info *physhim,
u32 phy_mode);
extern u16 wlapi_bmac_get_txant(struct phy_shim_info *physhim);
extern char *wlapi_getvar(char *vars, const char *name);
extern int wlapi_getintvar(char *vars, const char *name);
#endif /* _BRCM_PHY_SHIM_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