Commit e922602e authored by Arend van Spriel's avatar Arend van Spriel Committed by John W. Linville

brcm80211: smac: cleanup buscore handling in aiutils.c

Instead of storing the buscore information now the BCMA core device
is kept for quick reference in si_info structure.
Reviewed-by: default avatarPieter-Paul Giesberts <pieterpg@broadcom.com>
Reviewed-by: default avatarAlwin Beukers <alwin@broadcom.com>
Signed-off-by: default avatarArend van Spriel <arend@broadcom.com>
Signed-off-by: default avatarFranky Lin <frankyl@broadcom.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 99559f13
...@@ -479,10 +479,9 @@ static bool ai_buscore_prep(struct si_info *sii) ...@@ -479,10 +479,9 @@ static bool ai_buscore_prep(struct si_info *sii)
static bool static bool
ai_buscore_setup(struct si_info *sii, struct bcma_device *cc) ai_buscore_setup(struct si_info *sii, struct bcma_device *cc)
{ {
struct bcma_device *pci = NULL;
struct bcma_device *pcie = NULL;
struct bcma_device *core; struct bcma_device *core;
bool pci, pcie;
uint i;
uint pciidx, pcieidx, pcirev, pcierev;
/* no cores found, bail out */ /* no cores found, bail out */
...@@ -506,15 +505,7 @@ ai_buscore_setup(struct si_info *sii, struct bcma_device *cc) ...@@ -506,15 +505,7 @@ ai_buscore_setup(struct si_info *sii, struct bcma_device *cc)
sii->pub.pmurev = sii->pub.pmucaps & PCAP_REV_MASK; sii->pub.pmurev = sii->pub.pmucaps & PCAP_REV_MASK;
} }
/* figure out bus/orignal core idx */ /* figure out buscore */
sii->pub.buscoretype = NODEV_CORE_ID;
sii->pub.buscorerev = NOREV;
sii->buscoreidx = BADIDX;
pci = pcie = false;
pcirev = pcierev = NOREV;
pciidx = pcieidx = BADIDX;
list_for_each_entry(core, &cc->bus->cores, list) { list_for_each_entry(core, &cc->bus->cores, list) {
uint cid, crev; uint cid, crev;
...@@ -522,30 +513,22 @@ ai_buscore_setup(struct si_info *sii, struct bcma_device *cc) ...@@ -522,30 +513,22 @@ ai_buscore_setup(struct si_info *sii, struct bcma_device *cc)
crev = core->id.rev; crev = core->id.rev;
if (cid == PCI_CORE_ID) { if (cid == PCI_CORE_ID) {
pciidx = i; pci = core;
pcirev = crev;
pci = true;
} else if (cid == PCIE_CORE_ID) { } else if (cid == PCIE_CORE_ID) {
pcieidx = i; pcie = core;
pcierev = crev;
pcie = true;
} }
} }
if (pci && pcie) { if (pci && pcie) {
if (ai_ispcie(sii)) if (ai_ispcie(sii))
pci = false; pci = NULL;
else else
pcie = false; pcie = NULL;
} }
if (pci) { if (pci) {
sii->pub.buscoretype = PCI_CORE_ID; sii->buscore = pci;
sii->pub.buscorerev = pcirev;
sii->buscoreidx = pciidx;
} else if (pcie) { } else if (pcie) {
sii->pub.buscoretype = PCIE_CORE_ID; sii->buscore = pcie;
sii->pub.buscorerev = pcierev;
sii->buscoreidx = pcieidx;
} }
/* fixup necessary chip/core configurations */ /* fixup necessary chip/core configurations */
...@@ -554,10 +537,8 @@ ai_buscore_setup(struct si_info *sii, struct bcma_device *cc) ...@@ -554,10 +537,8 @@ ai_buscore_setup(struct si_info *sii, struct bcma_device *cc)
if (sii->pch == NULL) if (sii->pch == NULL)
return false; return false;
} }
if (ai_pci_fixcfg(&sii->pub)) { if (ai_pci_fixcfg(&sii->pub))
/* si_doattach: si_pci_fixcfg failed */
return false; return false;
}
return true; return true;
} }
...@@ -589,7 +570,6 @@ static struct si_info *ai_doattach(struct si_info *sii, ...@@ -589,7 +570,6 @@ static struct si_info *ai_doattach(struct si_info *sii,
savewin = 0; savewin = 0;
sii->icbus = pbus; sii->icbus = pbus;
sii->buscoreidx = BADIDX;
sii->pcibus = pbus->host_pci; sii->pcibus = pbus->host_pci;
/* switch to Chipcommon core */ /* switch to Chipcommon core */
...@@ -1248,3 +1228,15 @@ bool ai_is_otp_disabled(struct si_pub *sih) ...@@ -1248,3 +1228,15 @@ bool ai_is_otp_disabled(struct si_pub *sih)
return false; return false;
} }
} }
uint ai_get_buscoretype(struct si_pub *sih)
{
struct si_info *sii = (struct si_info *)sih;
return sii->buscore->id.id;
}
uint ai_get_buscorerev(struct si_pub *sih)
{
struct si_info *sii = (struct si_info *)sih;
return sii->buscore->id.rev;
}
...@@ -146,8 +146,6 @@ ...@@ -146,8 +146,6 @@
* public (read-only) portion of aiutils handle returned by si_attach() * public (read-only) portion of aiutils handle returned by si_attach()
*/ */
struct si_pub { struct si_pub {
uint buscoretype; /* PCI_CORE_ID, PCIE_CORE_ID, PCMCIA_CORE_ID */
uint buscorerev; /* buscore rev */
int ccrev; /* chip common core rev */ int ccrev; /* chip common core rev */
u32 cccaps; /* chip common capabilities */ u32 cccaps; /* chip common capabilities */
int pmurev; /* pmu core rev */ int pmurev; /* pmu core rev */
...@@ -175,11 +173,10 @@ struct si_info { ...@@ -175,11 +173,10 @@ struct si_info {
struct bcma_bus *icbus; /* handle to soc interconnect bus */ struct bcma_bus *icbus; /* handle to soc interconnect bus */
struct pci_dev *pcibus; /* handle to pci bus */ struct pci_dev *pcibus; /* handle to pci bus */
struct pcicore_info *pch; /* PCI/E core handle */ struct pcicore_info *pch; /* PCI/E core handle */
struct bcma_device *buscore;
struct list_head var_list; /* list of srom variables */ struct list_head var_list; /* list of srom variables */
u32 chipst; /* chip status */ u32 chipst; /* chip status */
uint buscoreidx; /* buscore index */
}; };
/* /*
...@@ -224,47 +221,49 @@ extern void ai_chipcontrl_epa4331(struct si_pub *sih, bool on); ...@@ -224,47 +221,49 @@ extern void ai_chipcontrl_epa4331(struct si_pub *sih, bool on);
/* Enable Ex-PA for 4313 */ /* Enable Ex-PA for 4313 */
extern void ai_epa_4313war(struct si_pub *sih); extern void ai_epa_4313war(struct si_pub *sih);
static inline uint ai_get_buscoretype(struct si_pub *sih) extern uint ai_get_buscoretype(struct si_pub *sih);
{ extern uint ai_get_buscorerev(struct si_pub *sih);
return sih->buscoretype;
}
static inline uint ai_get_buscorerev(struct si_pub *sih)
{
return sih->buscorerev;
}
static inline int ai_get_ccrev(struct si_pub *sih) static inline int ai_get_ccrev(struct si_pub *sih)
{ {
return sih->ccrev; return sih->ccrev;
} }
static inline u32 ai_get_cccaps(struct si_pub *sih) static inline u32 ai_get_cccaps(struct si_pub *sih)
{ {
return sih->cccaps; return sih->cccaps;
} }
static inline int ai_get_pmurev(struct si_pub *sih) static inline int ai_get_pmurev(struct si_pub *sih)
{ {
return sih->pmurev; return sih->pmurev;
} }
static inline u32 ai_get_pmucaps(struct si_pub *sih) static inline u32 ai_get_pmucaps(struct si_pub *sih)
{ {
return sih->pmucaps; return sih->pmucaps;
} }
static inline uint ai_get_boardtype(struct si_pub *sih) static inline uint ai_get_boardtype(struct si_pub *sih)
{ {
return sih->boardtype; return sih->boardtype;
} }
static inline uint ai_get_boardvendor(struct si_pub *sih) static inline uint ai_get_boardvendor(struct si_pub *sih)
{ {
return sih->boardvendor; return sih->boardvendor;
} }
static inline uint ai_get_chip_id(struct si_pub *sih) static inline uint ai_get_chip_id(struct si_pub *sih)
{ {
return sih->chip; return sih->chip;
} }
static inline uint ai_get_chiprev(struct si_pub *sih) static inline uint ai_get_chiprev(struct si_pub *sih)
{ {
return sih->chiprev; return sih->chiprev;
} }
static inline uint ai_get_chippkg(struct si_pub *sih) static inline uint ai_get_chippkg(struct si_pub *sih)
{ {
return sih->chippkg; return sih->chippkg;
......
...@@ -408,7 +408,7 @@ pcie_mdioop(struct pcicore_info *pi, uint physmedia, uint regaddr, bool write, ...@@ -408,7 +408,7 @@ pcie_mdioop(struct pcicore_info *pi, uint physmedia, uint regaddr, bool write,
bcma_write32(pi->core, PCIEREGOFFS(mdiocontrol), bcma_write32(pi->core, PCIEREGOFFS(mdiocontrol),
MDIOCTL_PREAM_EN | MDIOCTL_DIVISOR_VAL); MDIOCTL_PREAM_EN | MDIOCTL_DIVISOR_VAL);
if (pi->sih->buscorerev >= 10) { if (ai_get_buscorerev(pi->sih) >= 10) {
/* new serdes is slower in rw, /* new serdes is slower in rw,
* using two layers of reg address mapping * using two layers of reg address mapping
*/ */
...@@ -782,7 +782,6 @@ void pcicore_down(struct pcicore_info *pi, int state) ...@@ -782,7 +782,6 @@ void pcicore_down(struct pcicore_info *pi, int state)
pcie_extendL1timer(pi, false); pcie_extendL1timer(pi, false);
} }
/* precondition: current core is sii->buscoretype */
void pcicore_fixcfg(struct pcicore_info *pi) void pcicore_fixcfg(struct pcicore_info *pi)
{ {
struct bcma_device *core = pi->core; struct bcma_device *core = pi->core;
......
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