diff options
Diffstat (limited to 'drivers/staging/brcm80211/brcmsmac/nicpci.c')
-rw-r--r-- | drivers/staging/brcm80211/brcmsmac/nicpci.c | 75 |
1 files changed, 33 insertions, 42 deletions
diff --git a/drivers/staging/brcm80211/brcmsmac/nicpci.c b/drivers/staging/brcm80211/brcmsmac/nicpci.c index 3d71c590fcef..2d46e701dd25 100644 --- a/drivers/staging/brcm80211/brcmsmac/nicpci.c +++ b/drivers/staging/brcm80211/brcmsmac/nicpci.c @@ -213,9 +213,7 @@ struct pcicore_info { /* debug/trace */ #define PCI_ERROR(args) -#define PCIE_PUB(sih) \ - (((sih)->bustype == PCI_BUS) && \ - ((sih)->buscoretype == PCIE_CORE_ID)) +#define PCIE_PUB(sih) ((sih)->buscoretype == PCIE_CORE_ID) /* routines to access mdio slave device registers */ static bool pcie_mdiosetblock(struct pcicore_info *pi, uint blk); @@ -247,7 +245,8 @@ static void pcie_war_pci_setup(struct pcicore_info *pi); /* Initialize the PCI core. * It's caller's responsibility to make sure that this is done only once */ -void *pcicore_init(struct si_pub *sih, void *pdev, void *regs) +struct pcicore_info *pcicore_init(struct si_pub *sih, struct pci_dev *pdev, + void *regs) { struct pcicore_info *pi; @@ -273,7 +272,7 @@ void *pcicore_init(struct si_pub *sih, void *pdev, void *regs) return pi; } -void pcicore_deinit(void *pch) +void pcicore_deinit(struct pcicore_info *pch) { kfree(pch); } @@ -281,7 +280,7 @@ void pcicore_deinit(void *pch) /* return cap_offset if requested capability exists in the PCI config space */ /* Note that it's caller's responsibility to make sure it's a pci bus */ u8 -pcicore_find_pci_capability(void *dev, u8 req_cap_id, +pcicore_find_pci_capability(struct pci_dev *dev, u8 req_cap_id, unsigned char *buf, u32 *buflen) { u8 cap_id; @@ -399,6 +398,7 @@ static bool pcie_mdiosetblock(struct pcicore_info *pi, uint blk) while (i < pcie_serdes_spinwait) { if (R_REG(&pcieregs->mdiocontrol) & MDIOCTL_ACCESS_DONE) break; + udelay(1000); i++; } @@ -485,9 +485,8 @@ pcie_mdiowrite(struct pcicore_info *pi, uint physmedia, uint regaddr, uint val) } /* ***** Support functions ***** */ -static u8 pcie_clkreq(void *pch, u32 mask, u32 val) +static u8 pcie_clkreq(struct pcicore_info *pi, u32 mask, u32 val) { - struct pcicore_info *pi = pch; u32 reg_val; u8 offset; @@ -537,30 +536,30 @@ static void pcie_clkreq_upd(struct pcicore_info *pi, uint state) switch (state) { case SI_DOATTACH: if (PCIE_ASPM(sih)) - pcie_clkreq((void *)pi, 1, 0); + pcie_clkreq(pi, 1, 0); break; case SI_PCIDOWN: if (sih->buscorerev == 6) { /* turn on serdes PLL down */ ai_corereg(sih, SI_CC_IDX, - offsetof(chipcregs_t, chipcontrol_addr), + offsetof(struct chipcregs, chipcontrol_addr), ~0, 0); ai_corereg(sih, SI_CC_IDX, - offsetof(chipcregs_t, chipcontrol_data), + offsetof(struct chipcregs, chipcontrol_data), ~0x40, 0); } else if (pi->pcie_pr42767) { - pcie_clkreq((void *)pi, 1, 1); + pcie_clkreq(pi, 1, 1); } break; case SI_PCIUP: if (sih->buscorerev == 6) { /* turn off serdes PLL down */ ai_corereg(sih, SI_CC_IDX, - offsetof(chipcregs_t, chipcontrol_addr), + offsetof(struct chipcregs, chipcontrol_addr), ~0, 0); ai_corereg(sih, SI_CC_IDX, - offsetof(chipcregs_t, chipcontrol_data), + offsetof(struct chipcregs, chipcontrol_data), ~0x40, 0x40); } else if (PCIE_ASPM(sih)) { /* disable clkreq */ - pcie_clkreq((void *)pi, 1, 0); + pcie_clkreq(pi, 1, 0); } break; } @@ -674,7 +673,7 @@ static void pcie_war_noplldown(struct pcicore_info *pi) u16 *reg16; /* turn off serdes PLL down */ - ai_corereg(pi->sih, SI_CC_IDX, offsetof(chipcregs_t, chipcontrol), + ai_corereg(pi->sih, SI_CC_IDX, offsetof(struct chipcregs, chipcontrol), CHIPCTRL_4321_PLL_DOWN, CHIPCTRL_4321_PLL_DOWN); /* clear srom shadow backdoor */ @@ -730,9 +729,8 @@ static void pcie_war_pci_setup(struct pcicore_info *pi) } /* ***** Functions called during driver state changes ***** */ -void pcicore_attach(void *pch, char *pvars, int state) +void pcicore_attach(struct pcicore_info *pi, char *pvars, int state) { - struct pcicore_info *pi = pch; struct si_pub *sih = pi->sih; /* Determine if this board needs override */ @@ -754,20 +752,16 @@ void pcicore_attach(void *pch, char *pvars, int state) } -void pcicore_hwup(void *pch) +void pcicore_hwup(struct pcicore_info *pi) { - struct pcicore_info *pi = pch; - if (!pi || !PCIE_PUB(pi->sih)) return; pcie_war_pci_setup(pi); } -void pcicore_up(void *pch, int state) +void pcicore_up(struct pcicore_info *pi, int state) { - struct pcicore_info *pi = pch; - if (!pi || !PCIE_PUB(pi->sih)) return; @@ -780,9 +774,8 @@ void pcicore_up(void *pch, int state) /* When the device is going to enter D3 state * (or the system is going to enter S3/S4 states) */ -void pcicore_sleep(void *pch) +void pcicore_sleep(struct pcicore_info *pi) { - struct pcicore_info *pi = pch; u32 w; if (!pi || !PCIE_ASPM(pi->sih)) @@ -795,10 +788,8 @@ void pcicore_sleep(void *pch) pi->pcie_pr42767 = false; } -void pcicore_down(void *pch, int state) +void pcicore_down(struct pcicore_info *pi, int state) { - struct pcicore_info *pi = pch; - if (!pi || !PCIE_PUB(pi->sih)) return; @@ -809,20 +800,12 @@ void pcicore_down(void *pch, int state) } /* precondition: current core is sii->buscoretype */ -void pcicore_fixcfg(void *pch, void *regs) +static void pcicore_fixcfg(struct pcicore_info *pi, u16 *reg16) { - struct pcicore_info *pi = pch; struct si_info *sii = SI_INFO(pi->sih); - struct sbpciregs *pciregs = regs; - struct sbpcieregs *pcieregs = regs; - u16 val16, *reg16 = NULL; + u16 val16; uint pciidx; - /* check 'pi' is correct and fix it if not */ - if (sii->pub.buscoretype == PCIE_CORE_ID) - reg16 = &pcieregs->sprom[SRSH_PI_OFFSET]; - else if (sii->pub.buscoretype == PCI_CORE_ID) - reg16 = &pciregs->sprom[SRSH_PI_OFFSET]; pciidx = ai_coreidx(&sii->pub); val16 = R_REG(reg16); if (((val16 & SRSH_PI_MASK) >> SRSH_PI_SHIFT) != (u16)pciidx) { @@ -832,11 +815,19 @@ void pcicore_fixcfg(void *pch, void *regs) } } +void pcicore_fixcfg_pci(struct pcicore_info *pi, struct sbpciregs *pciregs) +{ + pcicore_fixcfg(pi, &pciregs->sprom[SRSH_PI_OFFSET]); +} + +void pcicore_fixcfg_pcie(struct pcicore_info *pi, struct sbpcieregs *pcieregs) +{ + pcicore_fixcfg(pi, &pcieregs->sprom[SRSH_PI_OFFSET]); +} + /* precondition: current core is pci core */ -void pcicore_pci_setup(void *pch, void *regs) +void pcicore_pci_setup(struct pcicore_info *pi, struct sbpciregs *pciregs) { - struct pcicore_info *pi = pch; - struct sbpciregs *pciregs = regs; u32 w; OR_REG(&pciregs->sbtopci2, SBTOPCI_PREF | SBTOPCI_BURST); |