diff options
Diffstat (limited to 'drivers/staging/brcm80211/util')
-rw-r--r-- | drivers/staging/brcm80211/util/aiutils.c | 25 | ||||
-rw-r--r-- | drivers/staging/brcm80211/util/bcmotp.c | 22 | ||||
-rw-r--r-- | drivers/staging/brcm80211/util/bcmsrom.c | 95 | ||||
-rw-r--r-- | drivers/staging/brcm80211/util/bcmutils.c | 112 | ||||
-rw-r--r-- | drivers/staging/brcm80211/util/bcmwifi.c | 4 | ||||
-rw-r--r-- | drivers/staging/brcm80211/util/hnddma.c | 136 | ||||
-rw-r--r-- | drivers/staging/brcm80211/util/hndpmu.c | 174 | ||||
-rw-r--r-- | drivers/staging/brcm80211/util/linux_osl.c | 247 | ||||
-rw-r--r-- | drivers/staging/brcm80211/util/nicpci.c | 125 | ||||
-rw-r--r-- | drivers/staging/brcm80211/util/nvram/nvram_ro.c | 4 | ||||
-rw-r--r-- | drivers/staging/brcm80211/util/sbutils.c | 13 | ||||
-rw-r--r-- | drivers/staging/brcm80211/util/siutils.c | 206 |
12 files changed, 489 insertions, 674 deletions
diff --git a/drivers/staging/brcm80211/util/aiutils.c b/drivers/staging/brcm80211/util/aiutils.c index 75a7e3a5c009..ddd2f9d64c20 100644 --- a/drivers/staging/brcm80211/util/aiutils.c +++ b/drivers/staging/brcm80211/util/aiutils.c @@ -14,11 +14,16 @@ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include <linux/delay.h> #include <linux/kernel.h> #include <linux/string.h> #include <bcmdefs.h> +#ifdef BRCM_FULLMAC +#include <linux/netdevice.h> +#endif #include <osl.h> -#include <linuxver.h> +#include <linux/module.h> +#include <linux/pci.h> #include <bcmutils.h> #include <siutils.h> #include <hndsoc.h> @@ -26,8 +31,8 @@ #include <pcicfg.h> #include <bcmdevs.h> -#define BCM47162_DMP() ((CHIPID(sih->chip) == BCM47162_CHIP_ID) && \ - (CHIPREV(sih->chiprev) == 0) && \ +#define BCM47162_DMP() ((sih->chip == BCM47162_CHIP_ID) && \ + (sih->chiprev == 0) && \ (sii->coreid[sii->curidx] == MIPS74K_CORE_ID)) /* EROM parsing */ @@ -115,7 +120,7 @@ void ai_scan(si_t *sih, void *regs, uint devid) erombase = R_REG(sii->osh, &cc->eromptr); - switch (BUSTYPE(sih->bustype)) { + switch (sih->bustype) { case SI_BUS: eromptr = (u32 *) REG_MAP(erombase, SI_CORE_SIZE); break; @@ -125,7 +130,7 @@ void ai_scan(si_t *sih, void *regs, uint devid) sii->curwrap = (void *)((unsigned long)regs + SI_CORE_SIZE); /* Now point the window at the erom */ - OSL_PCI_WRITE_CONFIG(sii->osh, PCI_BAR0_WIN, 4, erombase); + pci_write_config_dword(sii->osh->pdev, PCI_BAR0_WIN, erombase); eromptr = regs; break; @@ -330,7 +335,7 @@ void *ai_setcoreidx(si_t *sih, uint coreidx) ASSERT((sii->intrsenabled_fn == NULL) || !(*(sii)->intrsenabled_fn) ((sii)->intr_arg)); - switch (BUSTYPE(sih->bustype)) { + switch (sih->bustype) { case SI_BUS: /* map new one */ if (!sii->regs[coreidx]) { @@ -347,10 +352,10 @@ void *ai_setcoreidx(si_t *sih, uint coreidx) case PCI_BUS: /* point bar0 window */ - OSL_PCI_WRITE_CONFIG(sii->osh, PCI_BAR0_WIN, 4, addr); + pci_write_config_dword(sii->osh->pdev, PCI_BAR0_WIN, addr); regs = sii->curmap; /* point bar0 2nd 4KB window */ - OSL_PCI_WRITE_CONFIG(sii->osh, PCI_BAR0_WIN2, 4, wrap); + pci_write_config_dword(sii->osh->pdev, PCI_BAR0_WIN2, wrap); break; #ifdef BCMSDIO @@ -504,7 +509,7 @@ uint ai_corereg(si_t *sih, uint coreidx, uint regoff, uint mask, uint val) if (coreidx >= SI_MAXCORES) return 0; - if (BUSTYPE(sih->bustype) == SI_BUS) { + if (sih->bustype == SI_BUS) { /* If internal bus, we can always get at everything */ fast = true; /* map if does not exist */ @@ -514,7 +519,7 @@ uint ai_corereg(si_t *sih, uint coreidx, uint regoff, uint mask, uint val) ASSERT(GOODREGS(sii->regs[coreidx])); } r = (u32 *) ((unsigned char *) sii->regs[coreidx] + regoff); - } else if (BUSTYPE(sih->bustype) == PCI_BUS) { + } else if (sih->bustype == PCI_BUS) { /* If pci/pcie, we can get at pci/pcie regs and on newer cores to chipc */ if ((sii->coreid[coreidx] == CC_CORE_ID) && SI_FAST(sii)) { diff --git a/drivers/staging/brcm80211/util/bcmotp.c b/drivers/staging/brcm80211/util/bcmotp.c index c909832c7ee1..d820e7b9e970 100644 --- a/drivers/staging/brcm80211/util/bcmotp.c +++ b/drivers/staging/brcm80211/util/bcmotp.c @@ -14,11 +14,13 @@ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include <linux/delay.h> #include <linux/kernel.h> #include <linux/string.h> #include <bcmdefs.h> #include <osl.h> -#include <linuxver.h> +#include <linux/module.h> +#include <linux/pci.h> #include <bcmdevs.h> #include <bcmutils.h> #include <siutils.h> @@ -77,7 +79,7 @@ typedef struct { uint ccrev; /* chipc revision */ otp_fn_t *fn; /* OTP functions */ si_t *sih; /* Saved sb handle */ - osl_t *osh; + struct osl_info *osh; #ifdef BCMIPXOTP /* IPX OTP section */ @@ -221,7 +223,7 @@ static int ipxotp_max_rgnsz(si_t *sih, int osizew) { int ret = 0; - switch (CHIPID(sih->chip)) { + switch (sih->chip) { case BCM43224_CHIP_ID: case BCM43225_CHIP_ID: ret = osizew * 2 - OTP_SZ_FU_72 - OTP_SZ_CHECKSUM; @@ -271,8 +273,8 @@ static void _ipxotp_init(otpinfo_t *oi, chipcregs_t *cc) /* Read OTP lock bits and subregion programmed indication bits */ oi->status = R_REG(oi->osh, &cc->otpstatus); - if ((CHIPID(oi->sih->chip) == BCM43224_CHIP_ID) - || (CHIPID(oi->sih->chip) == BCM43225_CHIP_ID)) { + if ((oi->sih->chip == BCM43224_CHIP_ID) + || (oi->sih->chip == BCM43225_CHIP_ID)) { u32 p_bits; p_bits = (ipxotp_otpr(oi, cc, oi->otpgu_base + OTPGU_P_OFF) & @@ -569,7 +571,7 @@ static int hndotp_size(void *oh) static u16 hndotp_otpr(void *oh, chipcregs_t *cc, uint wn) { otpinfo_t *oi = (otpinfo_t *) oh; - osl_t *osh; + struct osl_info *osh; volatile u16 *ptr; ASSERT(wn < ((oi->size / 2) + OTP_RC_LIM_OFF)); @@ -584,7 +586,7 @@ static u16 hndotp_otpr(void *oh, chipcregs_t *cc, uint wn) static u16 hndotp_otproff(void *oh, chipcregs_t *cc, int woff) { otpinfo_t *oi = (otpinfo_t *) oh; - osl_t *osh; + struct osl_info *osh; volatile u16 *ptr; ASSERT(woff >= (-((int)oi->size / 2))); @@ -603,7 +605,7 @@ static u16 hndotp_read_bit(void *oh, chipcregs_t *cc, uint idx) otpinfo_t *oi = (otpinfo_t *) oh; uint k, row, col; u32 otpp, st; - osl_t *osh; + struct osl_info *osh; osh = si_osh(oi->sih); row = idx / 65; @@ -636,7 +638,7 @@ static void *hndotp_init(si_t *sih) otpinfo_t *oi; u32 cap = 0, clkdiv, otpdiv = 0; void *ret = NULL; - osl_t *osh; + struct osl_info *osh; oi = &otpinfo; @@ -900,7 +902,7 @@ void *otp_init(si_t *sih) void *ret = NULL; oi = &otpinfo; - bzero(oi, sizeof(otpinfo_t)); + memset(oi, 0, sizeof(otpinfo_t)); oi->ccrev = sih->ccrev; diff --git a/drivers/staging/brcm80211/util/bcmsrom.c b/drivers/staging/brcm80211/util/bcmsrom.c index 1282ef7eb922..19d45026a5ee 100644 --- a/drivers/staging/brcm80211/util/bcmsrom.c +++ b/drivers/staging/brcm80211/util/bcmsrom.c @@ -15,9 +15,11 @@ */ #include <linux/kernel.h> #include <linux/string.h> +#include <linux/etherdevice.h> #include <bcmdefs.h> #include <osl.h> -#include <linuxver.h> +#include <linux/module.h> +#include <linux/pci.h> #include <stdarg.h> #include <bcmutils.h> #include <hndsoc.h> @@ -66,29 +68,30 @@ extern uint _varsz; #define SROM_CIS_SINGLE 1 -static int initvars_srom_si(si_t *sih, osl_t *osh, void *curmap, char **vars, - uint *count); +static int initvars_srom_si(si_t *sih, struct osl_info *osh, void *curmap, + char **vars, uint *count); static void _initvars_srom_pci(u8 sromrev, u16 *srom, uint off, varbuf_t *b); static int initvars_srom_pci(si_t *sih, void *curmap, char **vars, uint *count); static int initvars_flash_si(si_t *sih, char **vars, uint *count); #ifdef BCMSDIO -static int initvars_cis_sdio(osl_t *osh, char **vars, uint *count); -static int sprom_cmd_sdio(osl_t *osh, u8 cmd); -static int sprom_read_sdio(osl_t *osh, u16 addr, u16 *data); +static int initvars_cis_sdio(struct osl_info *osh, char **vars, uint *count); +static int sprom_cmd_sdio(struct osl_info *osh, u8 cmd); +static int sprom_read_sdio(struct osl_info *osh, u16 addr, u16 *data); #endif /* BCMSDIO */ -static int sprom_read_pci(osl_t *osh, si_t *sih, u16 *sprom, uint wordoff, - u16 *buf, uint nwords, bool check_crc); +static int sprom_read_pci(struct osl_info *osh, si_t *sih, u16 *sprom, + uint wordoff, u16 *buf, uint nwords, bool check_crc); #if defined(BCMNVRAMR) -static int otp_read_pci(osl_t *osh, si_t *sih, u16 *buf, uint bufsz); +static int otp_read_pci(struct osl_info *osh, si_t *sih, u16 *buf, uint bufsz); #endif -static u16 srom_cc_cmd(si_t *sih, osl_t *osh, void *ccregs, u32 cmd, +static u16 srom_cc_cmd(si_t *sih, struct osl_info *osh, void *ccregs, u32 cmd, uint wordoff, u16 data); -static int initvars_table(osl_t *osh, char *start, char *end, char **vars, - uint *count); -static int initvars_flash(si_t *sih, osl_t *osh, char **vp, uint len); +static int initvars_table(struct osl_info *osh, char *start, char *end, + char **vars, uint *count); +static int initvars_flash(si_t *sih, struct osl_info *osh, char **vp, + uint len); /* Initialization of varbuf structure */ static void varbuf_init(varbuf_t *b, char *buf, uint size) @@ -129,7 +132,7 @@ static int varbuf_append(varbuf_t *b, const char *fmt, ...) if (s != NULL) { len = (size_t) (s - b->buf); for (s = b->base; s < b->buf;) { - if ((bcmp(s, b->buf, len) == 0) && s[len] == '=') { + if ((memcmp(s, b->buf, len) == 0) && s[len] == '=') { len = strlen(s) + 1; memmove(s, (s + len), ((b->buf + r + 1) - (s + len))); @@ -155,21 +158,21 @@ static int varbuf_append(varbuf_t *b, const char *fmt, ...) * Initialize local vars from the right source for this platform. * Return 0 on success, nonzero on error. */ -int srom_var_init(si_t *sih, uint bustype, void *curmap, osl_t *osh, +int srom_var_init(si_t *sih, uint bustype, void *curmap, struct osl_info *osh, char **vars, uint *count) { uint len; len = 0; - ASSERT(bustype == BUSTYPE(bustype)); + ASSERT(bustype == bustype); if (vars == NULL || count == NULL) return 0; *vars = NULL; *count = 0; - switch (BUSTYPE(bustype)) { + switch (bustype) { case SI_BUS: case JTAG_BUS: return initvars_srom_si(sih, osh, curmap, vars, count); @@ -194,7 +197,7 @@ int srom_var_init(si_t *sih, uint bustype, void *curmap, osl_t *osh, /* support only 16-bit word read from srom */ int -srom_read(si_t *sih, uint bustype, void *curmap, osl_t *osh, +srom_read(si_t *sih, uint bustype, void *curmap, struct osl_info *osh, uint byteoff, uint nbytes, u16 *buf, bool check_crc) { uint off, nw; @@ -202,7 +205,7 @@ srom_read(si_t *sih, uint bustype, void *curmap, osl_t *osh, uint i; #endif /* BCMSDIO */ - ASSERT(bustype == BUSTYPE(bustype)); + ASSERT(bustype == bustype); /* check input - 16-bit access only */ if (byteoff & 1 || nbytes & 1 || (byteoff + nbytes) > SROM_MAX) @@ -211,7 +214,7 @@ srom_read(si_t *sih, uint bustype, void *curmap, osl_t *osh, off = byteoff / 2; nw = nbytes / 2; - if (BUSTYPE(bustype) == PCI_BUS) { + if (bustype == PCI_BUS) { if (!curmap) return 1; @@ -233,7 +236,7 @@ srom_read(si_t *sih, uint bustype, void *curmap, osl_t *osh, } #endif #ifdef BCMSDIO - } else if (BUSTYPE(bustype) == SDIO_BUS) { + } else if (bustype == SDIO_BUS) { off = byteoff / 2; nw = nbytes / 2; for (i = 0; i < nw; i++) { @@ -242,7 +245,7 @@ srom_read(si_t *sih, uint bustype, void *curmap, osl_t *osh, return 1; } #endif /* BCMSDIO */ - } else if (BUSTYPE(bustype) == SI_BUS) { + } else if (bustype == SI_BUS) { return 1; } else { return 1; @@ -376,7 +379,8 @@ u8 patch_pair; /* For dongle HW, accept partial calibration parameters */ #define BCMDONGLECASE(n) -int srom_parsecis(osl_t *osh, u8 *pcis[], uint ciscnt, char **vars, uint *count) +int srom_parsecis(struct osl_info *osh, u8 *pcis[], uint ciscnt, char **vars, + uint *count) { char eabuf[32]; char *base; @@ -402,7 +406,7 @@ int srom_parsecis(osl_t *osh, u8 *pcis[], uint ciscnt, char **vars, uint *count) return -2; varbuf_init(&b, base, MAXSZ_NVRAM_VARS); - bzero(base, MAXSZ_NVRAM_VARS); + memset(base, 0, MAXSZ_NVRAM_VARS); eabuf[0] = '\0'; for (cisnum = 0; cisnum < ciscnt; cisnum++) { cis = *pcis++; @@ -496,12 +500,12 @@ int srom_parsecis(osl_t *osh, u8 *pcis[], uint ciscnt, char **vars, uint *count) break; default: /* set macaddr if HNBU_MACADDR not seen yet */ - if (eabuf[0] == '\0' - && cis[i] == LAN_NID - && !(ETHER_ISNULLADDR(&cis[i + 2])) - && !(ETHER_ISMULTI(&cis[i + 2]))) { + if (eabuf[0] == '\0' && + cis[i] == LAN_NID && + !is_zero_ether_addr(&cis[i + 2]) && + !is_multicast_ether_addr(&cis[i + 2])) { ASSERT(cis[i + 1] == - ETHER_ADDR_LEN); + ETH_ALEN); snprintf(eabuf, sizeof(eabuf), "%pM", &cis[i + 2]); @@ -970,8 +974,8 @@ int srom_parsecis(osl_t *osh, u8 *pcis[], uint ciscnt, char **vars, uint *count) break; case HNBU_MACADDR: - if (!(ETHER_ISNULLADDR(&cis[i + 1])) && - !(ETHER_ISMULTI(&cis[i + 1]))) { + if (!is_zero_ether_addr(&cis[i + 1]) && + !is_multicast_ether_addr(&cis[i + 1])) { snprintf(eabuf, sizeof(eabuf), "%pM", &cis[i + 1]); @@ -1405,8 +1409,8 @@ int srom_parsecis(osl_t *osh, u8 *pcis[], uint ciscnt, char **vars, uint *count) * not in the bus cores. */ static u16 -srom_cc_cmd(si_t *sih, osl_t *osh, void *ccregs, u32 cmd, uint wordoff, - u16 data) +srom_cc_cmd(si_t *sih, struct osl_info *osh, void *ccregs, u32 cmd, + uint wordoff, u16 data) { chipcregs_t *cc = (chipcregs_t *) ccregs; uint wait_cnt = 1000; @@ -1439,7 +1443,7 @@ srom_cc_cmd(si_t *sih, osl_t *osh, void *ccregs, u32 cmd, uint wordoff, * Return 0 on success, nonzero on error. */ static int -sprom_read_pci(osl_t *osh, si_t *sih, u16 *sprom, uint wordoff, +sprom_read_pci(struct osl_info *osh, si_t *sih, u16 *sprom, uint wordoff, u16 *buf, uint nwords, bool check_crc) { int err = 0; @@ -1499,7 +1503,7 @@ sprom_read_pci(osl_t *osh, si_t *sih, u16 *sprom, uint wordoff, } #if defined(BCMNVRAMR) -static int otp_read_pci(osl_t *osh, si_t *sih, u16 *buf, uint bufsz) +static int otp_read_pci(struct osl_info *osh, si_t *sih, u16 *buf, uint bufsz) { u8 *otp; uint sz = OTP_SZ_MAX / 2; /* size in words */ @@ -1547,8 +1551,8 @@ static int otp_read_pci(osl_t *osh, si_t *sih, u16 *buf, uint bufsz) * Create variable table from memory. * Return 0 on success, nonzero on error. */ -static int initvars_table(osl_t *osh, char *start, char *end, char **vars, - uint *count) +static int initvars_table(struct osl_info *osh, char *start, char *end, + char **vars, uint *count) { int c = (int)(end - start); @@ -1574,7 +1578,8 @@ static int initvars_table(osl_t *osh, char *start, char *end, char **vars, * of the table upon enter and to the end of the table upon exit when success. * Return 0 on success, nonzero on error. */ -static int initvars_flash(si_t *sih, osl_t *osh, char **base, uint len) +static int initvars_flash(si_t *sih, struct osl_info *osh, char **base, + uint len) { char *vp = *base; char *flash; @@ -1634,7 +1639,7 @@ static int initvars_flash(si_t *sih, osl_t *osh, char **base, uint len) */ static int initvars_flash_si(si_t *sih, char **vars, uint *count) { - osl_t *osh = si_osh(sih); + struct osl_info *osh = si_osh(sih); char *vp, *base; int err; @@ -1845,7 +1850,7 @@ static int initvars_srom_pci(si_t *sih, void *curmap, char **vars, uint *count) u32 sr; varbuf_t b; char *vp, *base = NULL; - osl_t *osh = si_osh(sih); + struct osl_info *osh = si_osh(sih); bool flash = false; int err = 0; @@ -1986,7 +1991,7 @@ static int initvars_srom_pci(si_t *sih, void *curmap, char **vars, uint *count) * Read the SDIO cis and call parsecis to initialize the vars. * Return 0 on success, nonzero on error. */ -static int initvars_cis_sdio(osl_t *osh, char **vars, uint *count) +static int initvars_cis_sdio(struct osl_info *osh, char **vars, uint *count) { u8 *cis[SBSDIO_NUM_FUNCTION + 1]; uint fn, numfn; @@ -2020,7 +2025,7 @@ static int initvars_cis_sdio(osl_t *osh, char **vars, uint *count) } /* set SDIO sprom command register */ -static int sprom_cmd_sdio(osl_t *osh, u8 cmd) +static int sprom_cmd_sdio(struct osl_info *osh, u8 cmd) { u8 status = 0; uint wait_cnt = 1000; @@ -2040,7 +2045,7 @@ static int sprom_cmd_sdio(osl_t *osh, u8 cmd) } /* read a word from the SDIO srom */ -static int sprom_read_sdio(osl_t *osh, u16 addr, u16 *data) +static int sprom_read_sdio(struct osl_info *osh, u16 addr, u16 *data) { u8 addr_l, addr_h, data_l, data_h; @@ -2068,8 +2073,8 @@ static int sprom_read_sdio(osl_t *osh, u16 addr, u16 *data) } #endif /* BCMSDIO */ -static int initvars_srom_si(si_t *sih, osl_t *osh, void *curmap, char **vars, - uint *varsz) +static int initvars_srom_si(si_t *sih, struct osl_info *osh, void *curmap, + char **vars, uint *varsz) { /* Search flash nvram section for srom variables */ return initvars_flash_si(sih, vars, varsz); diff --git a/drivers/staging/brcm80211/util/bcmutils.c b/drivers/staging/brcm80211/util/bcmutils.c index 9789ea45ecd6..fd30cc6fb7f8 100644 --- a/drivers/staging/brcm80211/util/bcmutils.c +++ b/drivers/staging/brcm80211/util/bcmutils.c @@ -19,8 +19,10 @@ #include <linux/string.h> #include <bcmdefs.h> #include <stdarg.h> +#include <linux/module.h> +#include <linux/pci.h> +#include <linux/netdevice.h> #include <osl.h> -#include <linuxver.h> #include <bcmutils.h> #include <siutils.h> #include <bcmnvram.h> @@ -30,26 +32,26 @@ #include <proto/802.1d.h> #include <proto/802.11.h> - /* copy a buffer into a pkt buffer chain */ -uint pktfrombuf(osl_t *osh, void *p, uint offset, int len, unsigned char *buf) +uint pktfrombuf(struct osl_info *osh, struct sk_buff *p, uint offset, int len, + unsigned char *buf) { uint n, ret = 0; /* skip 'offset' bytes */ - for (; p && offset; p = PKTNEXT(p)) { - if (offset < (uint) PKTLEN(p)) + for (; p && offset; p = p->next) { + if (offset < (uint) (p->len)) break; - offset -= PKTLEN(p); + offset -= p->len; } if (!p) return 0; /* copy the data */ - for (; p && len; p = PKTNEXT(p)) { - n = min((uint) PKTLEN(p) - offset, (uint) len); - bcopy(buf, PKTDATA(p) + offset, n); + for (; p && len; p = p->next) { + n = min((uint) (p->len) - offset, (uint) len); + bcopy(buf, p->data + offset, n); buf += n; len -= n; ret += n; @@ -59,13 +61,13 @@ uint pktfrombuf(osl_t *osh, void *p, uint offset, int len, unsigned char *buf) return ret; } /* return total length of buffer chain */ -uint BCMFASTPATH pkttotlen(osl_t *osh, void *p) +uint BCMFASTPATH pkttotlen(struct osl_info *osh, struct sk_buff *p) { uint total; total = 0; - for (; p; p = PKTNEXT(p)) - total += PKTLEN(p); + for (; p; p = p->next) + total += p->len; return total; } @@ -73,12 +75,13 @@ uint BCMFASTPATH pkttotlen(osl_t *osh, void *p) * osl multiple-precedence packet queue * hi_prec is always >= the number of the highest non-empty precedence */ -void *BCMFASTPATH pktq_penq(struct pktq *pq, int prec, void *p) +struct sk_buff *BCMFASTPATH pktq_penq(struct pktq *pq, int prec, + struct sk_buff *p) { struct pktq_prec *q; ASSERT(prec >= 0 && prec < pq->num_prec); - ASSERT(PKTLINK(p) == NULL); /* queueing chains not allowed */ + ASSERT(p->prev == NULL); /* queueing chains not allowed */ ASSERT(!pktq_full(pq)); ASSERT(!pktq_pfull(pq, prec)); @@ -86,7 +89,7 @@ void *BCMFASTPATH pktq_penq(struct pktq *pq, int prec, void *p) q = &pq->q[prec]; if (q->head) - PKTSETLINK(q->tail, p); + q->tail->prev = p; else q->head = p; @@ -101,12 +104,13 @@ void *BCMFASTPATH pktq_penq(struct pktq *pq, int prec, void *p) return p; } -void *BCMFASTPATH pktq_penq_head(struct pktq *pq, int prec, void *p) +struct sk_buff *BCMFASTPATH pktq_penq_head(struct pktq *pq, int prec, + struct sk_buff *p) { struct pktq_prec *q; ASSERT(prec >= 0 && prec < pq->num_prec); - ASSERT(PKTLINK(p) == NULL); /* queueing chains not allowed */ + ASSERT(p->prev == NULL); /* queueing chains not allowed */ ASSERT(!pktq_full(pq)); ASSERT(!pktq_pfull(pq, prec)); @@ -116,7 +120,7 @@ void *BCMFASTPATH pktq_penq_head(struct pktq *pq, int prec, void *p) if (q->head == NULL) q->tail = p; - PKTSETLINK(p, q->head); + p->prev = q->head; q->head = p; q->len++; @@ -128,10 +132,10 @@ void *BCMFASTPATH pktq_penq_head(struct pktq *pq, int prec, void *p) return p; } -void *BCMFASTPATH pktq_pdeq(struct pktq *pq, int prec) +struct sk_buff *BCMFASTPATH pktq_pdeq(struct pktq *pq, int prec) { struct pktq_prec *q; - void *p; + struct sk_buff *p; ASSERT(prec >= 0 && prec < pq->num_prec); @@ -141,7 +145,7 @@ void *BCMFASTPATH pktq_pdeq(struct pktq *pq, int prec) if (p == NULL) return NULL; - q->head = PKTLINK(p); + q->head = p->prev; if (q->head == NULL) q->tail = NULL; @@ -149,15 +153,15 @@ void *BCMFASTPATH pktq_pdeq(struct pktq *pq, int prec) pq->len--; - PKTSETLINK(p, NULL); + p->prev = NULL; return p; } -void *BCMFASTPATH pktq_pdeq_tail(struct pktq *pq, int prec) +struct sk_buff *BCMFASTPATH pktq_pdeq_tail(struct pktq *pq, int prec) { struct pktq_prec *q; - void *p, *prev; + struct sk_buff *p, *prev; ASSERT(prec >= 0 && prec < pq->num_prec); @@ -167,11 +171,11 @@ void *BCMFASTPATH pktq_pdeq_tail(struct pktq *pq, int prec) if (p == NULL) return NULL; - for (prev = NULL; p != q->tail; p = PKTLINK(p)) + for (prev = NULL; p != q->tail; p = p->prev) prev = p; if (prev) - PKTSETLINK(prev, NULL); + prev->prev = NULL; else q->head = NULL; @@ -184,17 +188,17 @@ void *BCMFASTPATH pktq_pdeq_tail(struct pktq *pq, int prec) } #ifdef BRCM_FULLMAC -void pktq_pflush(osl_t *osh, struct pktq *pq, int prec, bool dir) +void pktq_pflush(struct osl_info *osh, struct pktq *pq, int prec, bool dir) { struct pktq_prec *q; - void *p; + struct sk_buff *p; q = &pq->q[prec]; p = q->head; while (p) { - q->head = PKTLINK(p); - PKTSETLINK(p, NULL); - PKTFREE(osh, p, dir); + q->head = p->prev; + p->prev = NULL; + pkt_buf_free_skb(osh, p, dir); q->len--; pq->len--; p = q->head; @@ -203,7 +207,7 @@ void pktq_pflush(osl_t *osh, struct pktq *pq, int prec, bool dir) q->tail = NULL; } -void pktq_flush(osl_t *osh, struct pktq *pq, bool dir) +void pktq_flush(struct osl_info *osh, struct pktq *pq, bool dir) { int prec; for (prec = 0; prec < pq->num_prec; prec++) @@ -212,11 +216,11 @@ void pktq_flush(osl_t *osh, struct pktq *pq, bool dir) } #else /* !BRCM_FULLMAC */ void -pktq_pflush(osl_t *osh, struct pktq *pq, int prec, bool dir, ifpkt_cb_t fn, - int arg) +pktq_pflush(struct osl_info *osh, struct pktq *pq, int prec, bool dir, + ifpkt_cb_t fn, int arg) { struct pktq_prec *q; - void *p, *prev = NULL; + struct sk_buff *p, *prev = NULL; q = &pq->q[prec]; p = q->head; @@ -224,17 +228,17 @@ pktq_pflush(osl_t *osh, struct pktq *pq, int prec, bool dir, ifpkt_cb_t fn, if (fn == NULL || (*fn) (p, arg)) { bool head = (p == q->head); if (head) - q->head = PKTLINK(p); + q->head = p->prev; else - PKTSETLINK(prev, PKTLINK(p)); - PKTSETLINK(p, NULL); - PKTFREE(osh, p, dir); + prev->prev = p->prev; + p->prev = NULL; + pkt_buf_free_skb(osh, p, dir); q->len--; pq->len--; - p = (head ? q->head : PKTLINK(prev)); + p = (head ? q->head : prev->prev); } else { prev = p; - p = PKTLINK(p); + p = p->prev; } } @@ -244,7 +248,8 @@ pktq_pflush(osl_t *osh, struct pktq *pq, int prec, bool dir, ifpkt_cb_t fn, } } -void pktq_flush(osl_t *osh, struct pktq *pq, bool dir, ifpkt_cb_t fn, int arg) +void pktq_flush(struct osl_info *osh, struct pktq *pq, bool dir, + ifpkt_cb_t fn, int arg) { int prec; for (prec = 0; prec < pq->num_prec; prec++) @@ -261,7 +266,7 @@ void pktq_init(struct pktq *pq, int num_prec, int max_len) ASSERT(num_prec > 0 && num_prec <= PKTQ_MAX_PREC); /* pq is variable size; only zero out what's requested */ - bzero(pq, + memset(pq, 0, offsetof(struct pktq, q) + (sizeof(struct pktq_prec) * num_prec)); pq->num_prec = (u16) num_prec; @@ -272,7 +277,7 @@ void pktq_init(struct pktq *pq, int num_prec, int max_len) pq->q[prec].max = pq->max; } -void *pktq_peek_tail(struct pktq *pq, int *prec_out) +struct sk_buff *pktq_peek_tail(struct pktq *pq, int *prec_out) { int prec; @@ -303,10 +308,11 @@ int pktq_mlen(struct pktq *pq, uint prec_bmp) return len; } /* Priority dequeue from a specific set of precedences */ -void *BCMFASTPATH pktq_mdeq(struct pktq *pq, uint prec_bmp, int *prec_out) +struct sk_buff *BCMFASTPATH pktq_mdeq(struct pktq *pq, uint prec_bmp, + int *prec_out) { struct pktq_prec *q; - void *p; + struct sk_buff *p; int prec; if (pq->len == 0) @@ -325,7 +331,7 @@ void *BCMFASTPATH pktq_mdeq(struct pktq *pq, uint prec_bmp, int *prec_out) if (p == NULL) return NULL; - q->head = PKTLINK(p); + q->head = p->prev; if (q->head == NULL) q->tail = NULL; @@ -336,7 +342,7 @@ void *BCMFASTPATH pktq_mdeq(struct pktq *pq, uint prec_bmp, int *prec_out) pq->len--; - PKTSETLINK(p, NULL); + p->prev = NULL; return p; } @@ -373,7 +379,7 @@ char *getvar(char *vars, const char *name) /* first look in vars[] */ for (s = vars; s && *s;) { - if ((bcmp(s, name, len) == 0) && (s[len] == '=')) + if ((memcmp(s, name, len) == 0) && (s[len] == '=')) return &s[len + 1]; while (*s++) @@ -404,15 +410,15 @@ int getintvar(char *vars, const char *name) #if defined(BCMDBG) /* pretty hex print a pkt buffer chain */ -void prpkt(const char *msg, osl_t *osh, void *p0) +void prpkt(const char *msg, struct osl_info *osh, struct sk_buff *p0) { - void *p; + struct sk_buff *p; if (msg && (msg[0] != '\0')) printf("%s:\n", msg); - for (p = p0; p; p = PKTNEXT(p)) - prhex(NULL, PKTDATA(p), PKTLEN(p)); + for (p = p0; p; p = p->next) + prhex(NULL, p->data, p->len); } #endif /* defined(BCMDBG) */ diff --git a/drivers/staging/brcm80211/util/bcmwifi.c b/drivers/staging/brcm80211/util/bcmwifi.c index 1bb6c78eece7..81e54bd7a554 100644 --- a/drivers/staging/brcm80211/util/bcmwifi.c +++ b/drivers/staging/brcm80211/util/bcmwifi.c @@ -15,6 +15,10 @@ */ #include <linux/ctype.h> #include <linux/kernel.h> +#ifdef BRCM_FULLMAC +#include <linux/netdevice.h> +#endif +#include <osl.h> #include <bcmdefs.h> #include <bcmutils.h> #include <bcmwifi.h> diff --git a/drivers/staging/brcm80211/util/hnddma.c b/drivers/staging/brcm80211/util/hnddma.c index fe503e7de563..d08869239d5b 100644 --- a/drivers/staging/brcm80211/util/hnddma.c +++ b/drivers/staging/brcm80211/util/hnddma.c @@ -16,7 +16,8 @@ #include <linux/kernel.h> #include <linux/string.h> -#include <linuxver.h> +#include <linux/netdevice.h> +#include <linux/pci.h> #include <bcmdefs.h> #include <bcmdevs.h> #include <osl.h> @@ -28,6 +29,10 @@ #include <sbhnddma.h> #include <hnddma.h> +#if defined(__mips__) +#include <asm/addrspace.h> +#endif + /* debug/trace */ #ifdef BCMDBG #define DMA_ERROR(args) \ @@ -68,11 +73,12 @@ static uint dma_msg_level; #define DI_INFO(dmah) ((dma_info_t *)dmah) +#define R_SM(r) (*(r)) +#define W_SM(r, v) (*(r) = (v)) + /* dma engine software state */ typedef struct dma_info { - struct hnddma_pub hnddma; /* exported structure, don't use hnddma_t, - * which could be const - */ + struct hnddma_pub hnddma; /* exported structure */ uint *msg_level; /* message level pointer */ char name[MAXNAMEL]; /* callers name for diag msgs */ @@ -222,7 +228,7 @@ static void _dma_counterreset(dma_info_t *di); static void _dma_fifoloopbackenable(dma_info_t *di); static uint _dma_ctrlflags(dma_info_t *di, uint mask, uint flags); static u8 dma_align_sizetobits(uint size); -static void *dma_ringalloc(osl_t *osh, u32 boundary, uint size, +static void *dma_ringalloc(struct osl_info *osh, u32 boundary, uint size, u16 *alignbits, uint *alloced, dmaaddr_t *descpa, osldma_t **dmah); @@ -231,7 +237,7 @@ static bool dma32_alloc(dma_info_t *di, uint direction); static bool dma32_txreset(dma_info_t *di); static bool dma32_rxreset(dma_info_t *di); static bool dma32_txsuspendedidle(dma_info_t *di); -static int dma32_txfast(dma_info_t *di, void *p0, bool commit); +static int dma32_txfast(dma_info_t *di, struct sk_buff *p0, bool commit); static void *dma32_getnexttxp(dma_info_t *di, txd_range_t range); static void *dma32_getnextrxp(dma_info_t *di, bool forceall); static void dma32_txrotate(dma_info_t *di); @@ -246,14 +252,14 @@ static bool dma32_txstopped(dma_info_t *di); static bool dma32_rxstopped(dma_info_t *di); static bool dma32_rxenabled(dma_info_t *di); -static bool _dma32_addrext(osl_t *osh, dma32regs_t *dma32regs); +static bool _dma32_addrext(struct osl_info *osh, dma32regs_t *dma32regs); /* Prototypes for 64-bit routines */ static bool dma64_alloc(dma_info_t *di, uint direction); static bool dma64_txreset(dma_info_t *di); static bool dma64_rxreset(dma_info_t *di); static bool dma64_txsuspendedidle(dma_info_t *di); -static int dma64_txfast(dma_info_t *di, void *p0, bool commit); +static int dma64_txfast(dma_info_t *di, struct sk_buff *p0, bool commit); static int dma64_txunframed(dma_info_t *di, void *p0, uint len, bool commit); static void *dma64_getpos(dma_info_t *di, bool direction); static void *dma64_getnexttxp(dma_info_t *di, txd_range_t range); @@ -270,7 +276,7 @@ static void dma64_txreclaim(dma_info_t *di, txd_range_t range); static bool dma64_txstopped(dma_info_t *di); static bool dma64_rxstopped(dma_info_t *di); static bool dma64_rxenabled(dma_info_t *di); -static bool _dma64_addrext(osl_t *osh, dma64regs_t *dma64regs); +static bool _dma64_addrext(struct osl_info *osh, dma64regs_t *dma64regs); static inline u32 parity32(u32 data); @@ -368,10 +374,10 @@ static const di_fcn_t dma32proc = { 39 }; -hnddma_t *dma_attach(osl_t *osh, char *name, si_t *sih, void *dmaregstx, - void *dmaregsrx, uint ntxd, uint nrxd, uint rxbufsize, - int rxextheadroom, uint nrxpost, uint rxoffset, - uint *msg_level) +struct hnddma_pub *dma_attach(struct osl_info *osh, char *name, si_t *sih, + void *dmaregstx, void *dmaregsrx, uint ntxd, + uint nrxd, uint rxbufsize, int rxextheadroom, + uint nrxpost, uint rxoffset, uint *msg_level) { dma_info_t *di; uint size; @@ -570,7 +576,7 @@ hnddma_t *dma_attach(osl_t *osh, char *name, si_t *sih, void *dmaregstx, } } - return (hnddma_t *) di; + return (struct hnddma_pub *) di; fail: _dma_detach(di); @@ -663,7 +669,7 @@ dma64_dd_upd(dma_info_t *di, dma64dd_t *ddring, dmaaddr_t pa, uint outidx, } } -static bool _dma32_addrext(osl_t *osh, dma32regs_t *dma32regs) +static bool _dma32_addrext(struct osl_info *osh, dma32regs_t *dma32regs) { u32 w; @@ -902,7 +908,7 @@ static void _dma_rxinit(dma_info_t *di) /* clear rx descriptor ring */ if (DMA64_ENAB(di) && DMA64_MODE(di)) { - BZERO_SM((void *)di->rxd64, + memset((void *)di->rxd64, '\0', (di->nrxd * sizeof(dma64dd_t))); /* DMA engine with out alignment requirement requires table to be inited @@ -916,7 +922,7 @@ static void _dma_rxinit(dma_info_t *di) if (di->aligndesc_4k) _dma_ddtable_init(di, DMA_RX, di->rxdpa); } else if (DMA32_ENAB(di)) { - BZERO_SM((void *)di->rxd32, + memset((void *)di->rxd32, '\0', (di->nrxd * sizeof(dma32dd_t))); _dma_rxenable(di); _dma_ddtable_init(di, DMA_RX, di->rxdpa); @@ -978,7 +984,7 @@ _dma_rx_param_get(dma_info_t *di, u16 *rxoffset, u16 *rxbufsize) */ static void *BCMFASTPATH _dma_rx(dma_info_t *di) { - void *p, *head, *tail; + struct sk_buff *p, *head, *tail; uint len; uint pkt_len; int resid = 0; @@ -988,30 +994,31 @@ static void *BCMFASTPATH _dma_rx(dma_info_t *di) if (head == NULL) return NULL; - len = ltoh16(*(u16 *) (PKTDATA(head))); + len = ltoh16(*(u16 *) (head->data)); DMA_TRACE(("%s: dma_rx len %d\n", di->name, len)); #if defined(__mips__) +#define OSL_UNCACHED(va) ((void *)KSEG1ADDR((va))) if (!len) { - while (!(len = *(u16 *) OSL_UNCACHED(PKTDATA(head)))) + while (!(len = *(u16 *) OSL_UNCACHED(head->data))) udelay(1); - *(u16 *) PKTDATA(head) = htol16((u16) len); + *(u16 *) (head->data) = htol16((u16) len); } #endif /* defined(__mips__) */ /* set actual length */ pkt_len = min((di->rxoffset + len), di->rxbufsize); - PKTSETLEN(head, pkt_len); + __skb_trim(head, pkt_len); resid = len - (di->rxbufsize - di->rxoffset); /* check for single or multi-buffer rx */ if (resid > 0) { tail = head; while ((resid > 0) && (p = _dma_getnextrxp(di, false))) { - PKTSETNEXT(tail, p); + tail->next = p; pkt_len = min(resid, (int)di->rxbufsize); - PKTSETLEN(p, pkt_len); + __skb_trim(p, pkt_len); tail = p; resid -= di->rxbufsize; @@ -1037,7 +1044,7 @@ static void *BCMFASTPATH _dma_rx(dma_info_t *di) if ((di->hnddma.dmactrlflags & DMA_CTRL_RXMULTI) == 0) { DMA_ERROR(("%s: dma_rx: bad frame length (%d)\n", di->name, len)); - PKTFREE(di->osh, head, false); + pkt_buf_free_skb(di->osh, head, false); di->hnddma.rxgiants++; goto next_frame; } @@ -1053,7 +1060,7 @@ static void *BCMFASTPATH _dma_rx(dma_info_t *di) */ static bool BCMFASTPATH _dma_rxfill(dma_info_t *di) { - void *p; + struct sk_buff *p; u16 rxin, rxout; u32 flags = 0; uint n; @@ -1085,7 +1092,7 @@ static bool BCMFASTPATH _dma_rxfill(dma_info_t *di) size to be allocated */ - p = osl_pktget(di->osh, di->rxbufsize + extra_offset); + p = pkt_buf_get_skb(di->osh, di->rxbufsize + extra_offset); if (p == NULL) { DMA_ERROR(("%s: dma_rxfill: out of rxbufs\n", @@ -1109,17 +1116,18 @@ static bool BCMFASTPATH _dma_rxfill(dma_info_t *di) } /* reserve an extra headroom, if applicable */ if (extra_offset) - PKTPULL(p, extra_offset); + skb_pull(p, extra_offset); /* Do a cached write instead of uncached write since DMA_MAP * will flush the cache. */ - *(u32 *) (PKTDATA(p)) = 0; + *(u32 *) (p->data) = 0; if (DMASGLIST_ENAB) - bzero(&di->rxp_dmah[rxout], sizeof(hnddma_seg_map_t)); + memset(&di->rxp_dmah[rxout], 0, + sizeof(hnddma_seg_map_t)); - pa = DMA_MAP(di->osh, PKTDATA(p), + pa = DMA_MAP(di->osh, p->data, di->rxbufsize, DMA_RX, p, &di->rxp_dmah[rxout]); ASSERT(IS_ALIGNED(PHYSADDRLO(pa), 4)); @@ -1220,15 +1228,10 @@ static void _dma_rxreclaim(dma_info_t *di) { void *p; - /* "unused local" warning suppression for OSLs that - * define PKTFREE() without using the di->osh arg - */ - di = di; - DMA_TRACE(("%s: dma_rxreclaim\n", di->name)); while ((p = _dma_getnextrxp(di, true))) - PKTFREE(di->osh, p, false); + pkt_buf_free_skb(di->osh, p, false); } static void *BCMFASTPATH _dma_getnextrxp(dma_info_t *di, bool forceall) @@ -1372,7 +1375,7 @@ static unsigned long _dma_getvar(dma_info_t *di, const char *name) return 0; } -void dma_txpioloopback(osl_t *osh, dma32regs_t *regs) +void dma_txpioloopback(struct osl_info *osh, dma32regs_t *regs) { OR_REG(osh, ®s->control, XC_LE); } @@ -1395,7 +1398,7 @@ u8 dma_align_sizetobits(uint size) * descriptor ring size aligned location. This will ensure that the ring will * not cross page boundary */ -static void *dma_ringalloc(osl_t *osh, u32 boundary, uint size, +static void *dma_ringalloc(struct osl_info *osh, u32 boundary, uint size, u16 *alignbits, uint *alloced, dmaaddr_t *descpa, osldma_t **dmah) { @@ -1434,7 +1437,7 @@ static void dma32_txinit(dma_info_t *di) di->hnddma.txavail = di->ntxd - 1; /* clear tx descriptor ring */ - BZERO_SM((void *)di->txd32, (di->ntxd * sizeof(dma32dd_t))); + memset((void *)di->txd32, '\0', (di->ntxd * sizeof(dma32dd_t))); if ((di->hnddma.dmactrlflags & DMA_CTRL_PEN) == 0) control |= XC_PD; @@ -1491,7 +1494,7 @@ static void dma32_txreclaim(dma_info_t *di, txd_range_t range) return; while ((p = dma32_getnexttxp(di, range))) - PKTFREE(di->osh, p, true); + pkt_buf_free_skb(di->osh, p, true); } static bool dma32_txstopped(dma_info_t *di) @@ -1651,9 +1654,9 @@ static bool dma32_txsuspendedidle(dma_info_t *di) * WARNING: call must check the return value for error. * the error(toss frames) could be fatal and cause many subsequent hard to debug problems */ -static int dma32_txfast(dma_info_t *di, void *p0, bool commit) +static int dma32_txfast(dma_info_t *di, struct sk_buff *p0, bool commit) { - void *p, *next; + struct sk_buff *p, *next; unsigned char *data; uint len; u16 txout; @@ -1672,12 +1675,12 @@ static int dma32_txfast(dma_info_t *di, void *p0, bool commit) uint nsegs, j; hnddma_seg_map_t *map; - data = PKTDATA(p); - len = PKTLEN(p); + data = p->data; + len = p->len; #ifdef BCM_DMAPAD len += PKTDMAPAD(di->osh, p); #endif - next = PKTNEXT(p); + next = p->next; /* return nonzero if out of tx descriptors */ if (NEXTTXD(txout) == di->txin) @@ -1687,7 +1690,8 @@ static int dma32_txfast(dma_info_t *di, void *p0, bool commit) continue; if (DMASGLIST_ENAB) - bzero(&di->txp_dmah[txout], sizeof(hnddma_seg_map_t)); + memset(&di->txp_dmah[txout], 0, + sizeof(hnddma_seg_map_t)); /* get physical address of buffer start */ pa = DMA_MAP(di->osh, data, len, DMA_TX, p, @@ -1761,7 +1765,7 @@ static int dma32_txfast(dma_info_t *di, void *p0, bool commit) outoftxd: DMA_ERROR(("%s: dma_txfast: out of txds\n", di->name)); - PKTFREE(di->osh, p0, true); + pkt_buf_free_skb(di->osh, p0, true); di->hnddma.txavail = 0; di->hnddma.txnobuf++; return -1; @@ -1959,7 +1963,7 @@ static void dma32_txrotate(dma_info_t *di) if (DMASGLIST_ENAB) { bcopy(&di->txp_dmah[old], &di->txp_dmah[new], sizeof(hnddma_seg_map_t)); - bzero(&di->txp_dmah[old], sizeof(hnddma_seg_map_t)); + memset(&di->txp_dmah[old], 0, sizeof(hnddma_seg_map_t)); } di->txp[old] = NULL; @@ -1989,7 +1993,7 @@ static void dma64_txinit(dma_info_t *di) di->hnddma.txavail = di->ntxd - 1; /* clear tx descriptor ring */ - BZERO_SM((void *)di->txd64, (di->ntxd * sizeof(dma64dd_t))); + memset((void *)di->txd64, '\0', (di->ntxd * sizeof(dma64dd_t))); /* DMA engine with out alignment requirement requires table to be inited * before enabling the engine @@ -2060,7 +2064,7 @@ static void BCMFASTPATH dma64_txreclaim(dma_info_t *di, txd_range_t range) while ((p = dma64_getnexttxp(di, range))) { /* For unframed data, we don't have any packets to free */ if (!(di->hnddma.dmactrlflags & DMA_CTRL_UNFRAMED)) - PKTFREE(di->osh, p, true); + pkt_buf_free_skb(di->osh, p, true); } } @@ -2300,9 +2304,10 @@ static int dma64_txunframed(dma_info_t *di, void *buf, uint len, bool commit) * WARNING: call must check the return value for error. * the error(toss frames) could be fatal and cause many subsequent hard to debug problems */ -static int BCMFASTPATH dma64_txfast(dma_info_t *di, void *p0, bool commit) +static int BCMFASTPATH dma64_txfast(dma_info_t *di, struct sk_buff *p0, + bool commit) { - void *p, *next; + struct sk_buff *p, *next; unsigned char *data; uint len; u16 txout; @@ -2321,12 +2326,12 @@ static int BCMFASTPATH dma64_txfast(dma_info_t *di, void *p0, bool commit) uint nsegs, j; hnddma_seg_map_t *map; - data = PKTDATA(p); - len = PKTLEN(p); + data = p->data; + len = p->len; #ifdef BCM_DMAPAD len += PKTDMAPAD(di->osh, p); #endif /* BCM_DMAPAD */ - next = PKTNEXT(p); + next = p->next; /* return nonzero if out of tx descriptors */ if (NEXTTXD(txout) == di->txin) @@ -2337,7 +2342,8 @@ static int BCMFASTPATH dma64_txfast(dma_info_t *di, void *p0, bool commit) /* get physical address of buffer start */ if (DMASGLIST_ENAB) - bzero(&di->txp_dmah[txout], sizeof(hnddma_seg_map_t)); + memset(&di->txp_dmah[txout], 0, + sizeof(hnddma_seg_map_t)); pa = DMA_MAP(di->osh, data, len, DMA_TX, p, &di->txp_dmah[txout]); @@ -2409,7 +2415,7 @@ static int BCMFASTPATH dma64_txfast(dma_info_t *di, void *p0, bool commit) outoftxd: DMA_ERROR(("%s: dma_txfast: out of txds !!!\n", di->name)); - PKTFREE(di->osh, p0, true); + pkt_buf_free_skb(di->osh, p0, true); di->hnddma.txavail = 0; di->hnddma.txnobuf++; return -1; @@ -2563,7 +2569,7 @@ static void *BCMFASTPATH dma64_getnextrxp(dma_info_t *di, bool forceall) return rxp; } -static bool _dma64_addrext(osl_t *osh, dma64regs_t * dma64regs) +static bool _dma64_addrext(struct osl_info *osh, dma64regs_t * dma64regs) { u32 w; OR_REG(osh, &dma64regs->control, D64_XC_AE); @@ -2635,7 +2641,7 @@ static void dma64_txrotate(dma_info_t *di) if (DMASGLIST_ENAB) { bcopy(&di->txp_dmah[old], &di->txp_dmah[new], sizeof(hnddma_seg_map_t)); - bzero(&di->txp_dmah[old], sizeof(hnddma_seg_map_t)); + memset(&di->txp_dmah[old], 0, sizeof(hnddma_seg_map_t)); } di->txp[old] = NULL; @@ -2654,7 +2660,7 @@ static void dma64_txrotate(dma_info_t *di) uint dma_addrwidth(si_t *sih, void *dmaregs) { dma32regs_t *dma32regs; - osl_t *osh; + struct osl_info *osh; osh = si_osh(sih); @@ -2664,8 +2670,8 @@ uint dma_addrwidth(si_t *sih, void *dmaregs) /* backplane are 64-bit capable */ if (si_backplane64(sih)) /* If bus is System Backplane or PCIE then we can access 64-bits */ - if ((BUSTYPE(sih->bustype) == SI_BUS) || - ((BUSTYPE(sih->bustype) == PCI_BUS) && + if ((sih->bustype == SI_BUS) || + ((sih->bustype == PCI_BUS) && (sih->buscoretype == PCIE_CORE_ID))) return DMADDRWIDTH_64; @@ -2679,8 +2685,8 @@ uint dma_addrwidth(si_t *sih, void *dmaregs) dma32regs = (dma32regs_t *) dmaregs; /* For System Backplane, PCIE bus or addrext feature, 32-bits ok */ - if ((BUSTYPE(sih->bustype) == SI_BUS) || - ((BUSTYPE(sih->bustype) == PCI_BUS) + if ((sih->bustype == SI_BUS) || + ((sih->bustype == PCI_BUS) && sih->buscoretype == PCIE_CORE_ID) || (_dma32_addrext(osh, dma32regs))) return DMADDRWIDTH_32; diff --git a/drivers/staging/brcm80211/util/hndpmu.c b/drivers/staging/brcm80211/util/hndpmu.c index a8f3306c1d2b..6cc59a895868 100644 --- a/drivers/staging/brcm80211/util/hndpmu.c +++ b/drivers/staging/brcm80211/util/hndpmu.c @@ -13,9 +13,14 @@ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include <linux/delay.h> #include <linux/kernel.h> #include <linux/string.h> -#include <linuxver.h> +#include <linux/module.h> +#include <linux/pci.h> +#ifdef BRCM_FULLMAC +#include <linux/netdevice.h> +#endif #include <bcmdefs.h> #include <osl.h> #include <bcmutils.h> @@ -40,23 +45,23 @@ #define PMU_NONE(args) /* PLL controls/clocks */ -static void si_pmu1_pllinit0(si_t *sih, osl_t *osh, chipcregs_t *cc, +static void si_pmu1_pllinit0(si_t *sih, struct osl_info *osh, chipcregs_t *cc, u32 xtal); -static u32 si_pmu1_cpuclk0(si_t *sih, osl_t *osh, chipcregs_t *cc); -static u32 si_pmu1_alpclk0(si_t *sih, osl_t *osh, chipcregs_t *cc); +static u32 si_pmu1_cpuclk0(si_t *sih, struct osl_info *osh, chipcregs_t *cc); +static u32 si_pmu1_alpclk0(si_t *sih, struct osl_info *osh, chipcregs_t *cc); /* PMU resources */ static bool si_pmu_res_depfltr_bb(si_t *sih); static bool si_pmu_res_depfltr_ncb(si_t *sih); static bool si_pmu_res_depfltr_paldo(si_t *sih); static bool si_pmu_res_depfltr_npaldo(si_t *sih); -static u32 si_pmu_res_deps(si_t *sih, osl_t *osh, chipcregs_t *cc, +static u32 si_pmu_res_deps(si_t *sih, struct osl_info *osh, chipcregs_t *cc, u32 rsrcs, bool all); -static uint si_pmu_res_uptime(si_t *sih, osl_t *osh, chipcregs_t *cc, +static uint si_pmu_res_uptime(si_t *sih, struct osl_info *osh, chipcregs_t *cc, u8 rsrc); static void si_pmu_res_masks(si_t *sih, u32 * pmin, u32 * pmax); static void si_pmu_spuravoid_pllupdate(si_t *sih, chipcregs_t *cc, - osl_t *osh, u8 spuravoid); + struct osl_info *osh, u8 spuravoid); static void si_pmu_set_4330_plldivs(si_t *sih); @@ -101,7 +106,7 @@ void si_pmu_pllupd(si_t *sih) } /* Setup switcher voltage */ -void si_pmu_set_switcher_voltage(si_t *sih, osl_t *osh, u8 bb_voltage, +void si_pmu_set_switcher_voltage(si_t *sih, struct osl_info *osh, u8 bb_voltage, u8 rf_voltage) { chipcregs_t *cc; @@ -124,14 +129,14 @@ void si_pmu_set_switcher_voltage(si_t *sih, osl_t *osh, u8 bb_voltage, si_setcoreidx(sih, origidx); } -void si_pmu_set_ldo_voltage(si_t *sih, osl_t *osh, u8 ldo, u8 voltage) +void si_pmu_set_ldo_voltage(si_t *sih, struct osl_info *osh, u8 ldo, u8 voltage) { u8 sr_cntl_shift = 0, rc_shift = 0, shift = 0, mask = 0; u8 addr = 0; ASSERT(sih->cccaps & CC_CAP_PMU); - switch (CHIPID(sih->chip)) { + switch (sih->chip) { case BCM4336_CHIP_ID: switch (ldo) { case SET_LDO_VOLTAGE_CLDO_PWM: @@ -182,7 +187,7 @@ void si_pmu_set_ldo_voltage(si_t *sih, osl_t *osh, u8 ldo, u8 voltage) /* d11 slow to fast clock transition time in slow clock cycles */ #define D11SCC_SLOW2FAST_TRANSITION 2 -u16 si_pmu_fast_pwrup_delay(si_t *sih, osl_t *osh) +u16 si_pmu_fast_pwrup_delay(si_t *sih, struct osl_info *osh) { uint delay = PMU_MAX_TRANSITION_DLY; chipcregs_t *cc; @@ -199,7 +204,7 @@ u16 si_pmu_fast_pwrup_delay(si_t *sih, osl_t *osh) cc = si_setcoreidx(sih, SI_CC_IDX); ASSERT(cc != NULL); - switch (CHIPID(sih->chip)) { + switch (sih->chip) { case BCM43224_CHIP_ID: case BCM43225_CHIP_ID: case BCM43421_CHIP_ID: @@ -259,7 +264,7 @@ u16 si_pmu_fast_pwrup_delay(si_t *sih, osl_t *osh) return (u16) delay; } -u32 si_pmu_force_ilp(si_t *sih, osl_t *osh, bool force) +u32 si_pmu_force_ilp(si_t *sih, struct osl_info *osh, bool force) { chipcregs_t *cc; uint origidx; @@ -599,7 +604,7 @@ static void si_pmu_res_masks(si_t *sih, u32 * pmin, u32 * pmax) rsrcs = (sih->pmucaps & PCAP_RC_MASK) >> PCAP_RC_SHIFT; /* determine min/max rsrc masks */ - switch (CHIPID(sih->chip)) { + switch (sih->chip) { case BCM43224_CHIP_ID: case BCM43225_CHIP_ID: case BCM43421_CHIP_ID: @@ -677,7 +682,7 @@ static void si_pmu_res_masks(si_t *sih, u32 * pmin, u32 * pmax) } /* initialize PMU resources */ -void si_pmu_res_init(si_t *sih, osl_t *osh) +void si_pmu_res_init(si_t *sih, struct osl_info *osh) { chipcregs_t *cc; uint origidx; @@ -696,7 +701,7 @@ void si_pmu_res_init(si_t *sih, osl_t *osh) cc = si_setcoreidx(sih, SI_CC_IDX); ASSERT(cc != NULL); - switch (CHIPID(sih->chip)) { + switch (sih->chip) { case BCM4329_CHIP_ID: /* Optimize resources up/down timers */ if (ISSIM_ENAB(sih)) { @@ -1095,7 +1100,7 @@ static const pmu1_xtaltab0_t *si_pmu1_xtaltab0(si_t *sih) #ifdef BCMDBG char chn[8]; #endif - switch (CHIPID(sih->chip)) { + switch (sih->chip) { case BCM4329_CHIP_ID: return pmu1_xtaltab0_880_4329; case BCM4319_CHIP_ID: @@ -1123,7 +1128,7 @@ static const pmu1_xtaltab0_t *si_pmu1_xtaldef0(si_t *sih) char chn[8]; #endif - switch (CHIPID(sih->chip)) { + switch (sih->chip) { case BCM4329_CHIP_ID: /* Default to 38400Khz */ return &pmu1_xtaltab0_880_4329[PMU1_XTALTAB0_880_38400K]; @@ -1155,7 +1160,7 @@ static u32 si_pmu1_pllfvco0(si_t *sih) char chn[8]; #endif - switch (CHIPID(sih->chip)) { + switch (sih->chip) { case BCM4329_CHIP_ID: return FVCO_880; case BCM4319_CHIP_ID: @@ -1178,7 +1183,7 @@ static u32 si_pmu1_pllfvco0(si_t *sih) /* query alp/xtal clock frequency */ static u32 -si_pmu1_alpclk0(si_t *sih, osl_t *osh, chipcregs_t *cc) +si_pmu1_alpclk0(si_t *sih, struct osl_info *osh, chipcregs_t *cc) { const pmu1_xtaltab0_t *xt; u32 xf; @@ -1203,7 +1208,8 @@ si_pmu1_alpclk0(si_t *sih, osl_t *osh, chipcregs_t *cc) * case the xtal frequency is unknown to the s/w so we need to call * si_pmu1_xtaldef0() wherever it is needed to return a default value. */ -static void si_pmu1_pllinit0(si_t *sih, osl_t *osh, chipcregs_t *cc, u32 xtal) +static void si_pmu1_pllinit0(si_t *sih, struct osl_info *osh, chipcregs_t *cc, + u32 xtal) { const pmu1_xtaltab0_t *xt; u32 tmp; @@ -1233,8 +1239,8 @@ static void si_pmu1_pllinit0(si_t *sih, osl_t *osh, chipcregs_t *cc, u32 xtal) */ if ((((R_REG(osh, &cc->pmucontrol) & PCTL_XTALFREQ_MASK) >> PCTL_XTALFREQ_SHIFT) == xt->xf) && - !((CHIPID(sih->chip) == BCM4319_CHIP_ID) - || (CHIPID(sih->chip) == BCM4330_CHIP_ID))) { + !((sih->chip == BCM4319_CHIP_ID) + || (sih->chip == BCM4330_CHIP_ID))) { PMU_MSG(("PLL already programmed for %d.%d MHz\n", xt->fref / 1000, xt->fref % 1000)); return; @@ -1244,7 +1250,7 @@ static void si_pmu1_pllinit0(si_t *sih, osl_t *osh, chipcregs_t *cc, u32 xtal) PMU_MSG(("Programming PLL for %d.%d MHz\n", xt->fref / 1000, xt->fref % 1000)); - switch (CHIPID(sih->chip)) { + switch (sih->chip) { case BCM4329_CHIP_ID: /* Change the BBPLL drive strength to 8 for all channels */ buf_strength = 0x888888; @@ -1351,11 +1357,11 @@ static void si_pmu1_pllinit0(si_t *sih, osl_t *osh, chipcregs_t *cc, u32 xtal) p2div << PMU1_PLL0_PC0_P2DIV_SHIFT) & PMU1_PLL0_PC0_P2DIV_MASK); W_REG(osh, &cc->pllcontrol_data, tmp); - if ((CHIPID(sih->chip) == BCM4330_CHIP_ID)) + if ((sih->chip == BCM4330_CHIP_ID)) si_pmu_set_4330_plldivs(sih); - if ((CHIPID(sih->chip) == BCM4329_CHIP_ID) - && (CHIPREV(sih->chiprev) == 0)) { + if ((sih->chip == BCM4329_CHIP_ID) + && (sih->chiprev == 0)) { W_REG(osh, &cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1); tmp = R_REG(osh, &cc->pllcontrol_data); @@ -1363,9 +1369,9 @@ static void si_pmu1_pllinit0(si_t *sih, osl_t *osh, chipcregs_t *cc, u32 xtal) tmp = tmp | DOT11MAC_880MHZ_CLK_DIVISOR_VAL; W_REG(osh, &cc->pllcontrol_data, tmp); } - if ((CHIPID(sih->chip) == BCM4319_CHIP_ID) || - (CHIPID(sih->chip) == BCM4336_CHIP_ID) || - (CHIPID(sih->chip) == BCM4330_CHIP_ID)) + if ((sih->chip == BCM4319_CHIP_ID) || + (sih->chip == BCM4336_CHIP_ID) || + (sih->chip == BCM4330_CHIP_ID)) ndiv_mode = PMU1_PLL0_PC2_NDIV_MODE_MFB; else ndiv_mode = PMU1_PLL0_PC2_NDIV_MODE_MASH; @@ -1407,7 +1413,7 @@ static void si_pmu1_pllinit0(si_t *sih, osl_t *osh, chipcregs_t *cc, u32 xtal) /* to operate the 4319 usb in 24MHz/48MHz; chipcontrol[2][84:83] needs * to be updated. */ - if ((CHIPID(sih->chip) == BCM4319_CHIP_ID) + if ((sih->chip == BCM4319_CHIP_ID) && (xt->fref != XTAL_FREQ_30000MHZ)) { W_REG(osh, &cc->chipcontrol_addr, PMU1_PLL0_CHIPCTL2); tmp = @@ -1436,8 +1442,8 @@ static void si_pmu1_pllinit0(si_t *sih, osl_t *osh, chipcregs_t *cc, u32 xtal) PCTL_ILP_DIV_MASK) | ((xt->xf << PCTL_XTALFREQ_SHIFT) & PCTL_XTALFREQ_MASK); - if ((CHIPID(sih->chip) == BCM4329_CHIP_ID) - && CHIPREV(sih->chiprev) == 0) { + if ((sih->chip == BCM4329_CHIP_ID) + && sih->chiprev == 0) { /* clear the htstretch before clearing HTReqEn */ AND_REG(osh, &cc->clkstretch, ~CSTRETCH_HT); tmp &= ~PCTL_HT_REQ_EN; @@ -1448,7 +1454,7 @@ static void si_pmu1_pllinit0(si_t *sih, osl_t *osh, chipcregs_t *cc, u32 xtal) /* query the CPU clock frequency */ static u32 -si_pmu1_cpuclk0(si_t *sih, osl_t *osh, chipcregs_t *cc) +si_pmu1_cpuclk0(si_t *sih, struct osl_info *osh, chipcregs_t *cc) { u32 tmp, m1div; #ifdef BCMDBG @@ -1502,7 +1508,7 @@ si_pmu1_cpuclk0(si_t *sih, osl_t *osh, chipcregs_t *cc) } /* initialize PLL */ -void si_pmu_pll_init(si_t *sih, osl_t *osh, uint xtalfreq) +void si_pmu_pll_init(si_t *sih, struct osl_info *osh, uint xtalfreq) { chipcregs_t *cc; uint origidx; @@ -1517,7 +1523,7 @@ void si_pmu_pll_init(si_t *sih, osl_t *osh, uint xtalfreq) cc = si_setcoreidx(sih, SI_CC_IDX); ASSERT(cc != NULL); - switch (CHIPID(sih->chip)) { + switch (sih->chip) { case BCM4329_CHIP_ID: if (xtalfreq == 0) xtalfreq = 38400; @@ -1555,7 +1561,7 @@ void si_pmu_pll_init(si_t *sih, osl_t *osh, uint xtalfreq) } /* query alp/xtal clock frequency */ -u32 si_pmu_alp_clock(si_t *sih, osl_t *osh) +u32 si_pmu_alp_clock(si_t *sih, struct osl_info *osh) { chipcregs_t *cc; uint origidx; @@ -1571,7 +1577,7 @@ u32 si_pmu_alp_clock(si_t *sih, osl_t *osh) cc = si_setcoreidx(sih, SI_CC_IDX); ASSERT(cc != NULL); - switch (CHIPID(sih->chip)) { + switch (sih->chip) { case BCM43224_CHIP_ID: case BCM43225_CHIP_ID: case BCM43421_CHIP_ID: @@ -1616,7 +1622,7 @@ u32 si_pmu_alp_clock(si_t *sih, osl_t *osh) * pllreg "pll0" i.e. 12 for main 6 for phy, 0 for misc. */ static u32 -si_pmu5_clock(si_t *sih, osl_t *osh, chipcregs_t *cc, uint pll0, +si_pmu5_clock(si_t *sih, struct osl_info *osh, chipcregs_t *cc, uint pll0, uint m) { u32 tmp, div, ndiv, p1, p2, fc; @@ -1631,7 +1637,7 @@ si_pmu5_clock(si_t *sih, osl_t *osh, chipcregs_t *cc, uint pll0, return 0; } - if (CHIPID(sih->chip) == BCM5357_CHIP_ID) { + if (sih->chip == BCM5357_CHIP_ID) { /* Detect failure in clock setting */ if ((R_REG(osh, &cc->chipstatus) & 0x40000) != 0) { return 133 * 1000000; @@ -1669,7 +1675,7 @@ si_pmu5_clock(si_t *sih, osl_t *osh, chipcregs_t *cc, uint pll0, /* For designs that feed the same clock to both backplane * and CPU just return the CPU clock speed. */ -u32 si_pmu_si_clock(si_t *sih, osl_t *osh) +u32 si_pmu_si_clock(si_t *sih, struct osl_info *osh) { chipcregs_t *cc; uint origidx; @@ -1685,7 +1691,7 @@ u32 si_pmu_si_clock(si_t *sih, osl_t *osh) cc = si_setcoreidx(sih, SI_CC_IDX); ASSERT(cc != NULL); - switch (CHIPID(sih->chip)) { + switch (sih->chip) { case BCM43224_CHIP_ID: case BCM43225_CHIP_ID: case BCM43421_CHIP_ID: @@ -1702,7 +1708,7 @@ u32 si_pmu_si_clock(si_t *sih, osl_t *osh) PMU5_MAINPLL_SI); break; case BCM4329_CHIP_ID: - if (CHIPREV(sih->chiprev) == 0) + if (sih->chiprev == 0) clock = 38400 * 1000; else clock = si_pmu1_cpuclk0(sih, osh, cc); @@ -1748,7 +1754,7 @@ u32 si_pmu_si_clock(si_t *sih, osl_t *osh) } /* query CPU clock frequency */ -u32 si_pmu_cpu_clock(si_t *sih, osl_t *osh) +u32 si_pmu_cpu_clock(si_t *sih, struct osl_info *osh) { chipcregs_t *cc; uint origidx; @@ -1757,14 +1763,14 @@ u32 si_pmu_cpu_clock(si_t *sih, osl_t *osh) ASSERT(sih->cccaps & CC_CAP_PMU); if ((sih->pmurev >= 5) && - !((CHIPID(sih->chip) == BCM4329_CHIP_ID) || - (CHIPID(sih->chip) == BCM4319_CHIP_ID) || - (CHIPID(sih->chip) == BCM43236_CHIP_ID) || - (CHIPID(sih->chip) == BCM4336_CHIP_ID) || - (CHIPID(sih->chip) == BCM4330_CHIP_ID))) { + !((sih->chip == BCM4329_CHIP_ID) || + (sih->chip == BCM4319_CHIP_ID) || + (sih->chip == BCM43236_CHIP_ID) || + (sih->chip == BCM4336_CHIP_ID) || + (sih->chip == BCM4330_CHIP_ID))) { uint pll; - switch (CHIPID(sih->chip)) { + switch (sih->chip) { case BCM5356_CHIP_ID: pll = PMU5356_MAINPLL_PLL0; break; @@ -1792,7 +1798,7 @@ u32 si_pmu_cpu_clock(si_t *sih, osl_t *osh) } /* query memory clock frequency */ -u32 si_pmu_mem_clock(si_t *sih, osl_t *osh) +u32 si_pmu_mem_clock(si_t *sih, struct osl_info *osh) { chipcregs_t *cc; uint origidx; @@ -1801,14 +1807,14 @@ u32 si_pmu_mem_clock(si_t *sih, osl_t *osh) ASSERT(sih->cccaps & CC_CAP_PMU); if ((sih->pmurev >= 5) && - !((CHIPID(sih->chip) == BCM4329_CHIP_ID) || - (CHIPID(sih->chip) == BCM4319_CHIP_ID) || - (CHIPID(sih->chip) == BCM4330_CHIP_ID) || - (CHIPID(sih->chip) == BCM4336_CHIP_ID) || - (CHIPID(sih->chip) == BCM43236_CHIP_ID))) { + !((sih->chip == BCM4329_CHIP_ID) || + (sih->chip == BCM4319_CHIP_ID) || + (sih->chip == BCM4330_CHIP_ID) || + (sih->chip == BCM4336_CHIP_ID) || + (sih->chip == BCM43236_CHIP_ID))) { uint pll; - switch (CHIPID(sih->chip)) { + switch (sih->chip) { case BCM5356_CHIP_ID: pll = PMU5356_MAINPLL_PLL0; break; @@ -1841,7 +1847,7 @@ u32 si_pmu_mem_clock(si_t *sih, osl_t *osh) static u32 ilpcycles_per_sec; -u32 si_pmu_ilp_clock(si_t *sih, osl_t *osh) +u32 si_pmu_ilp_clock(si_t *sih, struct osl_info *osh) { if (ISSIM_ENAB(sih)) return ILP_CLOCK; @@ -1905,7 +1911,7 @@ static const sdiod_drive_str_t sdiod_drive_strength_tab3[] = { #define SDIOD_DRVSTR_KEY(chip, pmu) (((chip) << 16) | (pmu)) void -si_sdiod_drive_strength_init(si_t *sih, osl_t *osh, +si_sdiod_drive_strength_init(si_t *sih, struct osl_info *osh, u32 drivestrength) { chipcregs_t *cc; uint origidx, intr_val = 0; @@ -1976,7 +1982,7 @@ si_sdiod_drive_strength_init(si_t *sih, osl_t *osh, } /* initialize PMU */ -void si_pmu_init(si_t *sih, osl_t *osh) +void si_pmu_init(si_t *sih, struct osl_info *osh) { chipcregs_t *cc; uint origidx; @@ -1993,7 +1999,7 @@ void si_pmu_init(si_t *sih, osl_t *osh) else if (sih->pmurev >= 2) OR_REG(osh, &cc->pmucontrol, PCTL_NOILP_ON_WAIT); - if ((CHIPID(sih->chip) == BCM4329_CHIP_ID) && (sih->chiprev == 2)) { + if ((sih->chip == BCM4329_CHIP_ID) && (sih->chiprev == 2)) { /* Fix for 4329b0 bad LPOM state. */ W_REG(osh, &cc->regcontrol_addr, 2); OR_REG(osh, &cc->regcontrol_data, 0x100); @@ -2008,7 +2014,7 @@ void si_pmu_init(si_t *sih, osl_t *osh) /* Return up time in ILP cycles for the given resource. */ static uint -si_pmu_res_uptime(si_t *sih, osl_t *osh, chipcregs_t *cc, +si_pmu_res_uptime(si_t *sih, struct osl_info *osh, chipcregs_t *cc, u8 rsrc) { u32 deps; uint up, i, dup, dmax; @@ -2045,7 +2051,7 @@ si_pmu_res_uptime(si_t *sih, osl_t *osh, chipcregs_t *cc, /* Return dependancies (direct or all/indirect) for the given resources */ static u32 -si_pmu_res_deps(si_t *sih, osl_t *osh, chipcregs_t *cc, u32 rsrcs, +si_pmu_res_deps(si_t *sih, struct osl_info *osh, chipcregs_t *cc, u32 rsrcs, bool all) { u32 deps = 0; @@ -2065,7 +2071,7 @@ si_pmu_res_deps(si_t *sih, osl_t *osh, chipcregs_t *cc, u32 rsrcs, } /* power up/down OTP through PMU resources */ -void si_pmu_otp_power(si_t *sih, osl_t *osh, bool on) +void si_pmu_otp_power(si_t *sih, struct osl_info *osh, bool on) { chipcregs_t *cc; uint origidx; @@ -2084,7 +2090,7 @@ void si_pmu_otp_power(si_t *sih, osl_t *osh, bool on) cc = si_setcoreidx(sih, SI_CC_IDX); ASSERT(cc != NULL); - switch (CHIPID(sih->chip)) { + switch (sih->chip) { case BCM4329_CHIP_ID: rsrcs = PMURES_BIT(RES4329_OTP_PU); break; @@ -2135,7 +2141,7 @@ void si_pmu_otp_power(si_t *sih, osl_t *osh, bool on) si_setcoreidx(sih, origidx); } -void si_pmu_rcal(si_t *sih, osl_t *osh) +void si_pmu_rcal(si_t *sih, struct osl_info *osh) { chipcregs_t *cc; uint origidx; @@ -2147,7 +2153,7 @@ void si_pmu_rcal(si_t *sih, osl_t *osh) cc = si_setcoreidx(sih, SI_CC_IDX); ASSERT(cc != NULL); - switch (CHIPID(sih->chip)) { + switch (sih->chip) { case BCM4329_CHIP_ID:{ u8 rcal_code; u32 val; @@ -2218,7 +2224,7 @@ void si_pmu_rcal(si_t *sih, osl_t *osh) si_setcoreidx(sih, origidx); } -void si_pmu_spuravoid(si_t *sih, osl_t *osh, u8 spuravoid) +void si_pmu_spuravoid(si_t *sih, struct osl_info *osh, u8 spuravoid) { chipcregs_t *cc; uint origidx, intr_val; @@ -2230,7 +2236,7 @@ void si_pmu_spuravoid(si_t *sih, osl_t *osh, u8 spuravoid) ASSERT(cc != NULL); /* force the HT off */ - if (CHIPID(sih->chip) == BCM4336_CHIP_ID) { + if (sih->chip == BCM4336_CHIP_ID) { tmp = R_REG(osh, &cc->max_res_mask); tmp &= ~RES4336_HT_AVAIL; W_REG(osh, &cc->max_res_mask, tmp); @@ -2244,7 +2250,7 @@ void si_pmu_spuravoid(si_t *sih, osl_t *osh, u8 spuravoid) si_pmu_spuravoid_pllupdate(sih, cc, osh, spuravoid); /* enable HT back on */ - if (CHIPID(sih->chip) == BCM4336_CHIP_ID) { + if (sih->chip == BCM4336_CHIP_ID) { tmp = R_REG(osh, &cc->max_res_mask); tmp |= RES4336_HT_AVAIL; W_REG(osh, &cc->max_res_mask, tmp); @@ -2255,7 +2261,7 @@ void si_pmu_spuravoid(si_t *sih, osl_t *osh, u8 spuravoid) } static void -si_pmu_spuravoid_pllupdate(si_t *sih, chipcregs_t *cc, osl_t *osh, +si_pmu_spuravoid_pllupdate(si_t *sih, chipcregs_t *cc, struct osl_info *osh, u8 spuravoid) { u32 tmp = 0; @@ -2263,14 +2269,14 @@ si_pmu_spuravoid_pllupdate(si_t *sih, chipcregs_t *cc, osl_t *osh, u8 bcm5357_bcm43236_p1div[] = { 0x1, 0x5, 0x5 }; u8 bcm5357_bcm43236_ndiv[] = { 0x30, 0xf6, 0xfc }; - switch (CHIPID(sih->chip)) { + switch (sih->chip) { case BCM5357_CHIP_ID: case BCM43235_CHIP_ID: case BCM43236_CHIP_ID: case BCM43238_CHIP_ID: /* BCM5357 needs to touch PLL1_PLLCTL[02], so offset PLL0_PLLCTL[02] by 6 */ - phypll_offset = (CHIPID(sih->chip) == BCM5357_CHIP_ID) ? 6 : 0; + phypll_offset = (sih->chip == BCM5357_CHIP_ID) ? 6 : 0; /* RMW only the P1 divider */ W_REG(osh, &cc->pllcontrol_addr, @@ -2451,7 +2457,7 @@ si_pmu_spuravoid_pllupdate(si_t *sih, chipcregs_t *cc, osl_t *osh, W_REG(osh, &cc->pmucontrol, tmp); } -bool si_pmu_is_otp_powered(si_t *sih, osl_t *osh) +bool si_pmu_is_otp_powered(si_t *sih, struct osl_info *osh) { uint idx; chipcregs_t *cc; @@ -2462,7 +2468,7 @@ bool si_pmu_is_otp_powered(si_t *sih, osl_t *osh) cc = si_setcoreidx(sih, SI_CC_IDX); ASSERT(cc != NULL); - switch (CHIPID(sih->chip)) { + switch (sih->chip) { case BCM4329_CHIP_ID: st = (R_REG(osh, &cc->res_state) & PMURES_BIT(RES4329_OTP_PU)) != 0; @@ -2503,9 +2509,9 @@ bool si_pmu_is_otp_powered(si_t *sih, osl_t *osh) void #if defined(BCMDBG) -si_pmu_sprom_enable(si_t *sih, osl_t *osh, bool enable) +si_pmu_sprom_enable(si_t *sih, struct osl_info *osh, bool enable) #else -si_pmu_sprom_enable(si_t *sih, osl_t *osh, bool enable) +si_pmu_sprom_enable(si_t *sih, struct osl_info *osh, bool enable) #endif { chipcregs_t *cc; @@ -2521,7 +2527,7 @@ si_pmu_sprom_enable(si_t *sih, osl_t *osh, bool enable) } /* initialize PMU chip controls and other chip level stuff */ -void si_pmu_chip_init(si_t *sih, osl_t *osh) +void si_pmu_chip_init(si_t *sih, struct osl_info *osh) { uint origidx; @@ -2543,11 +2549,11 @@ void si_pmu_chip_init(si_t *sih, osl_t *osh) } /* initialize PMU switch/regulators */ -void si_pmu_swreg_init(si_t *sih, osl_t *osh) +void si_pmu_swreg_init(si_t *sih, struct osl_info *osh) { ASSERT(sih->cccaps & CC_CAP_PMU); - switch (CHIPID(sih->chip)) { + switch (sih->chip) { case BCM4336_CHIP_ID: /* Reduce CLDO PWM output voltage to 1.2V */ si_pmu_set_ldo_voltage(sih, osh, SET_LDO_VOLTAGE_CLDO_PWM, 0xe); @@ -2556,7 +2562,7 @@ void si_pmu_swreg_init(si_t *sih, osl_t *osh) 0xe); /* Reduce LNLDO1 output voltage to 1.2V */ si_pmu_set_ldo_voltage(sih, osh, SET_LDO_VOLTAGE_LNLDO1, 0xe); - if (CHIPREV(sih->chiprev) == 0) + if (sih->chiprev == 0) si_pmu_regcontrol(sih, 2, 0x400000, 0x400000); break; @@ -2573,7 +2579,7 @@ void si_pmu_radio_enable(si_t *sih, bool enable) { ASSERT(sih->cccaps & CC_CAP_PMU); - switch (CHIPID(sih->chip)) { + switch (sih->chip) { case BCM4319_CHIP_ID: if (enable) si_write_wrapperreg(sih, AI_OOBSELOUTB74, @@ -2587,7 +2593,7 @@ void si_pmu_radio_enable(si_t *sih, bool enable) /* Wait for a particular clock level to be on the backplane */ u32 -si_pmu_waitforclk_on_backplane(si_t *sih, osl_t *osh, u32 clk, +si_pmu_waitforclk_on_backplane(si_t *sih, struct osl_info *osh, u32 clk, u32 delay) { chipcregs_t *cc; @@ -2616,7 +2622,7 @@ si_pmu_waitforclk_on_backplane(si_t *sih, osl_t *osh, u32 clk, #define EXT_ILP_HZ 32768 -u32 si_pmu_measure_alpclk(si_t *sih, osl_t *osh) +u32 si_pmu_measure_alpclk(si_t *sih, struct osl_info *osh) { chipcregs_t *cc; uint origidx; diff --git a/drivers/staging/brcm80211/util/linux_osl.c b/drivers/staging/brcm80211/util/linux_osl.c index 2bb5b8722df6..e6716e823baa 100644 --- a/drivers/staging/brcm80211/util/linux_osl.c +++ b/drivers/staging/brcm80211/util/linux_osl.c @@ -20,145 +20,57 @@ #include <asm/paccess.h> #endif /* mips */ #include <bcmendian.h> -#include <linuxver.h> +#include <linux/module.h> +#include <linux/pci.h> +#include <linux/netdevice.h> +#include <linux/sched.h> #include <bcmdefs.h> #include <osl.h> #include <bcmutils.h> #include <pcicfg.h> -#define PCI_CFG_RETRY 10 - #define OS_HANDLE_MAGIC 0x1234abcd /* Magic # to recognise osh */ #define BCM_MEM_FILENAME_LEN 24 /* Mem. filename length */ -struct osl_info { - osl_pubinfo_t pub; - uint magic; - void *pdev; - uint failed; - uint bustype; -}; - /* Global ASSERT type flag */ u32 g_assert_type; -#ifdef BRCM_FULLMAC -static s16 linuxbcmerrormap[] = { 0, /* 0 */ - -EINVAL, /* BCME_ERROR */ - -EINVAL, /* BCME_BADARG */ - -EINVAL, /* BCME_BADOPTION */ - -EINVAL, /* BCME_NOTUP */ - -EINVAL, /* BCME_NOTDOWN */ - -EINVAL, /* BCME_NOTAP */ - -EINVAL, /* BCME_NOTSTA */ - -EINVAL, /* BCME_BADKEYIDX */ - -EINVAL, /* BCME_RADIOOFF */ - -EINVAL, /* BCME_NOTBANDLOCKED */ - -EINVAL, /* BCME_NOCLK */ - -EINVAL, /* BCME_BADRATESET */ - -EINVAL, /* BCME_BADBAND */ - -E2BIG, /* BCME_BUFTOOSHORT */ - -E2BIG, /* BCME_BUFTOOLONG */ - -EBUSY, /* BCME_BUSY */ - -EINVAL, /* BCME_NOTASSOCIATED */ - -EINVAL, /* BCME_BADSSIDLEN */ - -EINVAL, /* BCME_OUTOFRANGECHAN */ - -EINVAL, /* BCME_BADCHAN */ - -EFAULT, /* BCME_BADADDR */ - -ENOMEM, /* BCME_NORESOURCE */ - -EOPNOTSUPP, /* BCME_UNSUPPORTED */ - -EMSGSIZE, /* BCME_BADLENGTH */ - -EINVAL, /* BCME_NOTREADY */ - -EPERM, /* BCME_NOTPERMITTED */ - -ENOMEM, /* BCME_NOMEM */ - -EINVAL, /* BCME_ASSOCIATED */ - -ERANGE, /* BCME_RANGE */ - -EINVAL, /* BCME_NOTFOUND */ - -EINVAL, /* BCME_WME_NOT_ENABLED */ - -EINVAL, /* BCME_TSPEC_NOTFOUND */ - -EINVAL, /* BCME_ACM_NOTSUPPORTED */ - -EINVAL, /* BCME_NOT_WME_ASSOCIATION */ - -EIO, /* BCME_SDIO_ERROR */ - -ENODEV, /* BCME_DONGLE_DOWN */ - -EINVAL, /* BCME_VERSION */ - -EIO, /* BCME_TXFAIL */ - -EIO, /* BCME_RXFAIL */ - -EINVAL, /* BCME_NODEVICE */ - -EINVAL, /* BCME_NMODE_DISABLED */ - -ENODATA, /* BCME_NONRESIDENT */ - -/* When an new error code is added to bcmutils.h, add os - * spcecific error translation here as well - */ -/* check if BCME_LAST changed since the last time this function was updated */ -#if BCME_LAST != -42 -#error "You need to add a OS error translation in the linuxbcmerrormap \ - for new error code defined in bcmutils.h" -#endif -}; - -/* translate bcmerrors into linux errors */ -int osl_error(int bcmerror) -{ - if (bcmerror > 0) - bcmerror = 0; - else if (bcmerror < BCME_LAST) - bcmerror = BCME_ERROR; - - /* Array bounds covered by ASSERT in osl_attach */ - return linuxbcmerrormap[-bcmerror]; -} -#endif /* BRCM_FULLMAC */ - -osl_t *osl_attach(void *pdev, uint bustype, bool pkttag) +struct osl_info *osl_attach(void *pdev, uint bustype) { - osl_t *osh; + struct osl_info *osh; - osh = kmalloc(sizeof(osl_t), GFP_ATOMIC); + osh = kmalloc(sizeof(struct osl_info), GFP_ATOMIC); ASSERT(osh); - bzero(osh, sizeof(osl_t)); - -#ifdef BRCM_FULLMAC - /* Check that error map has the right number of entries in it */ - ASSERT(ABS(BCME_LAST) == (ARRAY_SIZE(linuxbcmerrormap) - 1)); -#endif /* BRCM_FULLMAC */ + memset(osh, 0, sizeof(struct osl_info)); osh->magic = OS_HANDLE_MAGIC; - osh->failed = 0; osh->pdev = pdev; - osh->pub.pkttag = pkttag; osh->bustype = bustype; switch (bustype) { case PCI_BUS: case SI_BUS: case PCMCIA_BUS: - osh->pub.mmbus = true; + osh->mmbus = true; break; case JTAG_BUS: case SDIO_BUS: case USB_BUS: case SPI_BUS: case RPC_BUS: - osh->pub.mmbus = false; + osh->mmbus = false; break; default: ASSERT(false); break; } -#if defined(BCMDBG) && !defined(BRCM_FULLMAC) - if (pkttag) { - struct sk_buff *skb; - ASSERT(OSL_PKTTAG_SZ <= sizeof(skb->cb)); - } -#endif return osh; } -void osl_detach(osl_t *osh) +void osl_detach(struct osl_info *osh) { if (osh == NULL) return; @@ -167,8 +79,7 @@ void osl_detach(osl_t *osh) kfree(osh); } -/* Return a new packet. zero out pkttag */ -void *BCMFASTPATH osl_pktget(osl_t *osh, uint len) +struct sk_buff *BCMFASTPATH pkt_buf_get_skb(struct osl_info *osh, uint len) { struct sk_buff *skb; @@ -177,24 +88,20 @@ void *BCMFASTPATH osl_pktget(osl_t *osh, uint len) skb_put(skb, len); skb->priority = 0; - osh->pub.pktalloced++; + osh->pktalloced++; } - return (void *)skb; + return skb; } /* Free the driver packet. Free the tag if present */ -void BCMFASTPATH osl_pktfree(osl_t *osh, void *p, bool send) +void BCMFASTPATH pkt_buf_free_skb(struct osl_info *osh, struct sk_buff *skb, bool send) { - struct sk_buff *skb, *nskb; + struct sk_buff *nskb; int nest = 0; - skb = (struct sk_buff *)p; ASSERT(skb); - if (send && osh->pub.tx_fn) - osh->pub.tx_fn(osh->pub.tx_ctx, p, 0); - /* perversion: we use skb->next to chain multi-skb packets */ while (skb) { nskb = skb->next; @@ -211,63 +118,14 @@ void BCMFASTPATH osl_pktfree(osl_t *osh, void *p, bool send) */ dev_kfree_skb(skb); - osh->pub.pktalloced--; + osh->pktalloced--; nest++; skb = nskb; } } -u32 osl_pci_read_config(osl_t *osh, uint offset, uint size) -{ - uint val = 0; - uint retry = PCI_CFG_RETRY; - - ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC))); - - /* only 4byte access supported */ - ASSERT(size == 4); - - do { - pci_read_config_dword(osh->pdev, offset, &val); - if (val != 0xffffffff) - break; - } while (retry--); - -#ifdef BCMDBG - if (retry < PCI_CFG_RETRY) - printk("PCI CONFIG READ access to %d required %d retries\n", - offset, (PCI_CFG_RETRY - retry)); -#endif /* BCMDBG */ - - return val; -} - -void osl_pci_write_config(osl_t *osh, uint offset, uint size, uint val) -{ - uint retry = PCI_CFG_RETRY; - - ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC))); - - /* only 4byte access supported */ - ASSERT(size == 4); - - do { - pci_write_config_dword(osh->pdev, offset, val); - if (offset != PCI_BAR0_WIN) - break; - if (osl_pci_read_config(osh, offset, size) == val) - break; - } while (retry--); - -#if defined(BCMDBG) && !defined(BRCM_FULLMAC) - if (retry < PCI_CFG_RETRY) - printk("PCI CONFIG WRITE access to %d required %d retries\n", - offset, (PCI_CFG_RETRY - retry)); -#endif /* BCMDBG */ -} - /* return bus # for the pci device pointed by osh->pdev */ -uint osl_pci_bus(osl_t *osh) +uint osl_pci_bus(struct osl_info *osh) { ASSERT(osh && (osh->magic == OS_HANDLE_MAGIC) && osh->pdev); @@ -275,40 +133,37 @@ uint osl_pci_bus(osl_t *osh) } /* return slot # for the pci device pointed by osh->pdev */ -uint osl_pci_slot(osl_t *osh) +uint osl_pci_slot(struct osl_info *osh) { ASSERT(osh && (osh->magic == OS_HANDLE_MAGIC) && osh->pdev); return PCI_SLOT(((struct pci_dev *)osh->pdev)->devfn); } -uint osl_dma_consistent_align(void) -{ - return PAGE_SIZE; -} - -void *osl_dma_alloc_consistent(osl_t *osh, uint size, u16 align_bits, +void *osl_dma_alloc_consistent(struct osl_info *osh, uint size, u16 align_bits, uint *alloced, unsigned long *pap) { ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC))); if (align_bits) { u16 align = (1 << align_bits); - if (!IS_ALIGNED(DMA_CONSISTENT_ALIGN, align)) + if (!IS_ALIGNED(PAGE_SIZE, align)) size += align; *alloced = size; } return pci_alloc_consistent(osh->pdev, size, (dma_addr_t *) pap); } -void osl_dma_free_consistent(osl_t *osh, void *va, uint size, unsigned long pa) +void osl_dma_free_consistent(struct osl_info *osh, void *va, uint size, + unsigned long pa) { ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC))); pci_free_consistent(osh->pdev, size, va, (dma_addr_t) pa); } -uint BCMFASTPATH osl_dma_map(osl_t *osh, void *va, uint size, int direction) +uint BCMFASTPATH osl_dma_map(struct osl_info *osh, void *va, uint size, + int direction) { int dir; @@ -317,7 +172,8 @@ uint BCMFASTPATH osl_dma_map(osl_t *osh, void *va, uint size, int direction) return pci_map_single(osh->pdev, va, size, dir); } -void BCMFASTPATH osl_dma_unmap(osl_t *osh, uint pa, uint size, int direction) +void BCMFASTPATH osl_dma_unmap(struct osl_info *osh, uint pa, uint size, + int direction) { int dir; @@ -373,52 +229,3 @@ void osl_assert(char *exp, char *file, int line) } #endif /* defined(BCMDBG_ASSERT) */ -#if defined(BCMSDIO) && !defined(BRCM_FULLMAC) -u8 osl_readb(osl_t *osh, volatile u8 *r) -{ - osl_rreg_fn_t rreg = ((osl_pubinfo_t *) osh)->rreg_fn; - void *ctx = ((osl_pubinfo_t *) osh)->reg_ctx; - - return (u8) ((rreg) (ctx, (void *)r, sizeof(u8))); -} - -u16 osl_readw(osl_t *osh, volatile u16 *r) -{ - osl_rreg_fn_t rreg = ((osl_pubinfo_t *) osh)->rreg_fn; - void *ctx = ((osl_pubinfo_t *) osh)->reg_ctx; - - return (u16) ((rreg) (ctx, (void *)r, sizeof(u16))); -} - -u32 osl_readl(osl_t *osh, volatile u32 *r) -{ - osl_rreg_fn_t rreg = ((osl_pubinfo_t *) osh)->rreg_fn; - void *ctx = ((osl_pubinfo_t *) osh)->reg_ctx; - - return (u32) ((rreg) (ctx, (void *)r, sizeof(u32))); -} - -void osl_writeb(osl_t *osh, volatile u8 *r, u8 v) -{ - osl_wreg_fn_t wreg = ((osl_pubinfo_t *) osh)->wreg_fn; - void *ctx = ((osl_pubinfo_t *) osh)->reg_ctx; - - ((wreg) (ctx, (void *)r, v, sizeof(u8))); -} - -void osl_writew(osl_t *osh, volatile u16 *r, u16 v) -{ - osl_wreg_fn_t wreg = ((osl_pubinfo_t *) osh)->wreg_fn; - void *ctx = ((osl_pubinfo_t *) osh)->reg_ctx; - - ((wreg) (ctx, (void *)r, v, sizeof(u16))); -} - -void osl_writel(osl_t *osh, volatile u32 *r, u32 v) -{ - osl_wreg_fn_t wreg = ((osl_pubinfo_t *) osh)->wreg_fn; - void *ctx = ((osl_pubinfo_t *) osh)->reg_ctx; - - ((wreg) (ctx, (void *)r, v, sizeof(u32))); -} -#endif /* BCMSDIO */ diff --git a/drivers/staging/brcm80211/util/nicpci.c b/drivers/staging/brcm80211/util/nicpci.c index 23f86dd7b159..56e658c429a8 100644 --- a/drivers/staging/brcm80211/util/nicpci.c +++ b/drivers/staging/brcm80211/util/nicpci.c @@ -14,8 +14,9 @@ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include <linux/delay.h> #include <linux/string.h> -#include <linuxver.h> +#include <linux/pci.h> #include <bcmdefs.h> #include <osl.h> #include <bcmutils.h> @@ -35,7 +36,7 @@ typedef struct { } regs; /* Memory mapped register to the core */ si_t *sih; /* System interconnect handle */ - osl_t *osh; /* OSL handle */ + struct osl_info *osh; /* OSL handle */ u8 pciecap_lcreg_offset; /* PCIE capability LCreg offset in the config space */ bool pcie_pr42767; u8 pcie_polarity; @@ -47,7 +48,8 @@ typedef struct { /* debug/trace */ #define PCI_ERROR(args) -#define PCIE_PUB(sih) ((BUSTYPE((sih)->bustype) == PCI_BUS) && ((sih)->buscoretype == PCIE_CORE_ID)) +#define PCIE_PUB(sih) \ + (((sih)->bustype == PCI_BUS) && ((sih)->buscoretype == PCIE_CORE_ID)) /* routines to access mdio slave device registers */ static bool pcie_mdiosetblock(pcicore_info_t *pi, uint blk); @@ -71,35 +73,6 @@ static bool pcicore_pmecap(pcicore_info_t *pi); #define PCIE_ASPM(sih) ((PCIE_PUB(sih)) && (((sih)->buscorerev >= 3) && ((sih)->buscorerev <= 5))) -#define DWORD_ALIGN(x) (x & ~(0x03)) -#define BYTE_POS(x) (x & 0x3) -#define WORD_POS(x) (x & 0x1) - -#define BYTE_SHIFT(x) (8 * BYTE_POS(x)) -#define WORD_SHIFT(x) (16 * WORD_POS(x)) - -#define BYTE_VAL(a, x) ((a >> BYTE_SHIFT(x)) & 0xFF) -#define WORD_VAL(a, x) ((a >> WORD_SHIFT(x)) & 0xFFFF) - -#define read_pci_cfg_byte(a) \ - (BYTE_VAL(OSL_PCI_READ_CONFIG(osh, DWORD_ALIGN(a), 4), a) & 0xff) - -#define read_pci_cfg_word(a) \ - (WORD_VAL(OSL_PCI_READ_CONFIG(osh, DWORD_ALIGN(a), 4), a) & 0xffff) - -#define write_pci_cfg_byte(a, val) do { \ - u32 tmpval; \ - tmpval = (OSL_PCI_READ_CONFIG(osh, DWORD_ALIGN(a), 4) & ~0xFF << BYTE_POS(a)) | \ - val << BYTE_POS(a); \ - OSL_PCI_WRITE_CONFIG(osh, DWORD_ALIGN(a), 4, tmpval); \ - } while (0) - -#define write_pci_cfg_word(a, val) do { \ - u32 tmpval; \ - tmpval = (OSL_PCI_READ_CONFIG(osh, DWORD_ALIGN(a), 4) & ~0xFFFF << WORD_POS(a)) | \ - val << WORD_POS(a); \ - OSL_PCI_WRITE_CONFIG(osh, DWORD_ALIGN(a), 4, tmpval); \ - } while (0) /* delay needed between the mdio control/ mdiodata register data access */ #define PR28829_DELAY() udelay(10) @@ -107,7 +80,7 @@ static bool pcicore_pmecap(pcicore_info_t *pi); /* Initialize the PCI core. It's caller's responsibility to make sure that this is done * only once */ -void *pcicore_init(si_t *sih, osl_t *osh, void *regs) +void *pcicore_init(si_t *sih, struct osl_info *osh, void *regs) { pcicore_info_t *pi; @@ -149,8 +122,8 @@ 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(osl_t *osh, u8 req_cap_id, unsigned char *buf, - u32 *buflen) +pcicore_find_pci_capability(struct osl_info *osh, u8 req_cap_id, + unsigned char *buf, u32 *buflen) { u8 cap_id; u8 cap_ptr = 0; @@ -158,29 +131,29 @@ pcicore_find_pci_capability(osl_t *osh, u8 req_cap_id, unsigned char *buf, u8 byte_val; /* check for Header type 0 */ - byte_val = read_pci_cfg_byte(PCI_CFG_HDR); + pci_read_config_byte(osh->pdev, PCI_CFG_HDR, &byte_val); if ((byte_val & 0x7f) != PCI_HEADER_NORMAL) goto end; /* check if the capability pointer field exists */ - byte_val = read_pci_cfg_byte(PCI_CFG_STAT); + pci_read_config_byte(osh->pdev, PCI_CFG_STAT, &byte_val); if (!(byte_val & PCI_CAPPTR_PRESENT)) goto end; - cap_ptr = read_pci_cfg_byte(PCI_CFG_CAPPTR); + pci_read_config_byte(osh->pdev, PCI_CFG_CAPPTR, &cap_ptr); /* check if the capability pointer is 0x00 */ if (cap_ptr == 0x00) goto end; /* loop thr'u the capability list and see if the pcie capabilty exists */ - cap_id = read_pci_cfg_byte(cap_ptr); + pci_read_config_byte(osh->pdev, cap_ptr, &cap_id); while (cap_id != req_cap_id) { - cap_ptr = read_pci_cfg_byte((cap_ptr + 1)); + pci_read_config_byte(osh->pdev, cap_ptr + 1, &cap_ptr); if (cap_ptr == 0x00) break; - cap_id = read_pci_cfg_byte(cap_ptr); + pci_read_config_byte(osh->pdev, cap_ptr, &cap_id); } if (cap_id != req_cap_id) { goto end; @@ -199,7 +172,7 @@ pcicore_find_pci_capability(osl_t *osh, u8 req_cap_id, unsigned char *buf, bufsize = SZPCR - cap_data; *buflen = bufsize; while (bufsize--) { - *buf = read_pci_cfg_byte(cap_data); + pci_read_config_byte(osh->pdev, cap_data, buf); cap_data++; buf++; } @@ -210,7 +183,8 @@ pcicore_find_pci_capability(osl_t *osh, u8 req_cap_id, unsigned char *buf, /* ***** Register Access API */ uint -pcie_readreg(osl_t *osh, sbpcieregs_t *pcieregs, uint addrtype, uint offset) +pcie_readreg(struct osl_info *osh, sbpcieregs_t *pcieregs, uint addrtype, + uint offset) { uint retval = 0xFFFFFFFF; @@ -236,8 +210,8 @@ pcie_readreg(osl_t *osh, sbpcieregs_t *pcieregs, uint addrtype, uint offset) } uint -pcie_writereg(osl_t *osh, sbpcieregs_t *pcieregs, uint addrtype, uint offset, - uint val) +pcie_writereg(struct osl_info *osh, sbpcieregs_t *pcieregs, uint addrtype, + uint offset, uint val) { ASSERT(pcieregs != NULL); @@ -373,15 +347,15 @@ u8 pcie_clkreq(void *pch, u32 mask, u32 val) if (!offset) return 0; - reg_val = OSL_PCI_READ_CONFIG(pi->osh, offset, sizeof(u32)); + pci_read_config_dword(pi->osh->pdev, offset, ®_val); /* set operation */ if (mask) { if (val) reg_val |= PCIE_CLKREQ_ENAB; else reg_val &= ~PCIE_CLKREQ_ENAB; - OSL_PCI_WRITE_CONFIG(pi->osh, offset, sizeof(u32), reg_val); - reg_val = OSL_PCI_READ_CONFIG(pi->osh, offset, sizeof(u32)); + pci_write_config_dword(pi->osh->pdev, offset, reg_val); + pci_read_config_dword(pi->osh->pdev, offset, ®_val); } if (reg_val & PCIE_CLKREQ_ENAB) return 1; @@ -393,7 +367,7 @@ static void pcie_extendL1timer(pcicore_info_t *pi, bool extend) { u32 w; si_t *sih = pi->sih; - osl_t *osh = pi->osh; + struct osl_info *osh = pi->osh; sbpcieregs_t *pcieregs = pi->regs.pcieregs; if (!PCIE_PUB(sih) || sih->buscorerev < 7) @@ -502,12 +476,12 @@ static void pcie_war_aspm_clkreq(pcicore_info_t *pi) W_REG(pi->osh, reg16, val16); - w = OSL_PCI_READ_CONFIG(pi->osh, pi->pciecap_lcreg_offset, - sizeof(u32)); + pci_read_config_dword(pi->osh->pdev, pi->pciecap_lcreg_offset, + &w); w &= ~PCIE_ASPM_ENAB; w |= pi->pcie_war_aspm_ovr; - OSL_PCI_WRITE_CONFIG(pi->osh, pi->pciecap_lcreg_offset, - sizeof(u32), w); + pci_write_config_dword(pi->osh->pdev, + pi->pciecap_lcreg_offset, w); } reg16 = &pcieregs->sprom[SRSH_CLKREQ_OFFSET_REV5]; @@ -577,7 +551,7 @@ static void pcie_war_noplldown(pcicore_info_t *pi) static void pcie_war_pci_setup(pcicore_info_t *pi) { si_t *sih = pi->sih; - osl_t *osh = pi->osh; + struct osl_info *osh = pi->osh; sbpcieregs_t *pcieregs = pi->regs.pcieregs; u32 w; @@ -694,11 +668,9 @@ void pcicore_sleep(void *pch) if (!pi || !PCIE_ASPM(pi->sih)) return; - w = OSL_PCI_READ_CONFIG(pi->osh, pi->pciecap_lcreg_offset, - sizeof(u32)); + pci_read_config_dword(pi->osh->pdev, pi->pciecap_lcreg_offset, &w); w &= ~PCIE_CAP_LCREG_ASPML1; - OSL_PCI_WRITE_CONFIG(pi->osh, pi->pciecap_lcreg_offset, sizeof(u32), - w); + pci_write_config_dword(pi->osh->pdev, pi->pciecap_lcreg_offset, w); pi->pcie_pr42767 = false; } @@ -718,7 +690,7 @@ void pcicore_down(void *pch, int state) /* ***** Wake-on-wireless-LAN (WOWL) support functions ***** */ /* Just uses PCI config accesses to find out, when needed before sb_attach is done */ -bool pcicore_pmecap_fast(osl_t *osh) +bool pcicore_pmecap_fast(struct osl_info *osh) { u8 cap_ptr; u32 pmecap; @@ -730,7 +702,7 @@ bool pcicore_pmecap_fast(osl_t *osh) if (!cap_ptr) return false; - pmecap = OSL_PCI_READ_CONFIG(osh, cap_ptr, sizeof(u32)); + pci_read_config_dword(osh->pdev, cap_ptr, &pmecap); return (pmecap & PME_CAP_PM_STATES) != 0; } @@ -753,9 +725,8 @@ static bool pcicore_pmecap(pcicore_info_t *pi) pi->pmecap_offset = cap_ptr; - pmecap = - OSL_PCI_READ_CONFIG(pi->osh, pi->pmecap_offset, - sizeof(u32)); + pci_read_config_dword(pi->osh->pdev, pi->pmecap_offset, + &pmecap); /* At least one state can generate PME */ pi->pmecap = (pmecap & PME_CAP_PM_STATES) != 0; @@ -774,11 +745,11 @@ void pcicore_pmeen(void *pch) if (!pcicore_pmecap(pi)) return; - w = OSL_PCI_READ_CONFIG(pi->osh, pi->pmecap_offset + PME_CSR_OFFSET, - sizeof(u32)); + pci_read_config_dword(pi->osh->pdev, pi->pmecap_offset + PME_CSR_OFFSET, + &w); w |= (PME_CSR_PME_EN); - OSL_PCI_WRITE_CONFIG(pi->osh, pi->pmecap_offset + PME_CSR_OFFSET, - sizeof(u32), w); + pci_write_config_dword(pi->osh->pdev, + pi->pmecap_offset + PME_CSR_OFFSET, w); } /* @@ -792,8 +763,8 @@ bool pcicore_pmestat(void *pch) if (!pcicore_pmecap(pi)) return false; - w = OSL_PCI_READ_CONFIG(pi->osh, pi->pmecap_offset + PME_CSR_OFFSET, - sizeof(u32)); + pci_read_config_dword(pi->osh->pdev, pi->pmecap_offset + PME_CSR_OFFSET, + &w); return (w & PME_CSR_PME_STAT) == PME_CSR_PME_STAT; } @@ -808,22 +779,23 @@ void pcicore_pmeclr(void *pch) if (!pcicore_pmecap(pi)) return; - w = OSL_PCI_READ_CONFIG(pi->osh, pi->pmecap_offset + PME_CSR_OFFSET, - sizeof(u32)); + pci_read_config_dword(pi->osh->pdev, pi->pmecap_offset + PME_CSR_OFFSET, + &w); PCI_ERROR(("pcicore_pci_pmeclr PMECSR : 0x%x\n", w)); /* PMESTAT is cleared by writing 1 to it */ w &= ~(PME_CSR_PME_EN); - OSL_PCI_WRITE_CONFIG(pi->osh, pi->pmecap_offset + PME_CSR_OFFSET, - sizeof(u32), w); + pci_write_config_dword(pi->osh->pdev, + pi->pmecap_offset + PME_CSR_OFFSET, w); } u32 pcie_lcreg(void *pch, u32 mask, u32 val) { pcicore_info_t *pi = (pcicore_info_t *) pch; u8 offset; + u32 tmpval; offset = pi->pciecap_lcreg_offset; if (!offset) @@ -831,9 +803,10 @@ u32 pcie_lcreg(void *pch, u32 mask, u32 val) /* set operation */ if (mask) - OSL_PCI_WRITE_CONFIG(pi->osh, offset, sizeof(u32), val); + pci_write_config_dword(pi->osh->pdev, offset, val); - return OSL_PCI_READ_CONFIG(pi->osh, offset, sizeof(u32)); + pci_read_config_dword(pi->osh->pdev, offset, &tmpval); + return tmpval; } u32 @@ -842,7 +815,7 @@ pcicore_pciereg(void *pch, u32 offset, u32 mask, u32 val, uint type) u32 reg_val = 0; pcicore_info_t *pi = (pcicore_info_t *) pch; sbpcieregs_t *pcieregs = pi->regs.pcieregs; - osl_t *osh = pi->osh; + struct osl_info *osh = pi->osh; if (mask) { PCI_ERROR(("PCIEREG: 0x%x writeval 0x%x\n", offset, val)); diff --git a/drivers/staging/brcm80211/util/nvram/nvram_ro.c b/drivers/staging/brcm80211/util/nvram/nvram_ro.c index f80375cd6801..e4d41ee78e2a 100644 --- a/drivers/staging/brcm80211/util/nvram/nvram_ro.c +++ b/drivers/staging/brcm80211/util/nvram/nvram_ro.c @@ -49,7 +49,7 @@ static char *findvar(char *vars, char *lim, const char *name); /* copy flash to ram */ static void get_flash_nvram(si_t *sih, struct nvram_header *nvh) { - osl_t *osh; + struct osl_info *osh; uint nvs, bufsz; vars_t *new; @@ -133,7 +133,7 @@ static char *findvar(char *vars, char *lim, const char *name) len = strlen(name); for (s = vars; (s < lim) && *s;) { - if ((bcmp(s, name, len) == 0) && (s[len] == '=')) + if ((memcmp(s, name, len) == 0) && (s[len] == '=')) return &s[len + 1]; while (*s++) diff --git a/drivers/staging/brcm80211/util/sbutils.c b/drivers/staging/brcm80211/util/sbutils.c index e4c0baba553d..63c3ab1866a4 100644 --- a/drivers/staging/brcm80211/util/sbutils.c +++ b/drivers/staging/brcm80211/util/sbutils.c @@ -16,6 +16,9 @@ #include <linux/types.h> #include <bcmdefs.h> +#ifdef BRCM_FULLMAC +#include <linux/netdevice.h> +#endif #include <osl.h> #include <bcmutils.h> #include <siutils.h> @@ -87,7 +90,7 @@ static u32 _sb_coresba(si_info_t *sii) { u32 sbaddr = 0; - switch (BUSTYPE(sii->pub.bustype)) { + switch (sii->pub.bustype) { case SPI_BUS: case SDIO_BUS: sbaddr = (u32)(unsigned long)sii->curmap; @@ -248,7 +251,7 @@ static uint _sb_scan(si_info_t *sii, u32 sba, void *regs, uint bus, u32 sbba, else { /* Older chips */ SI_ERROR(("sb_chip2numcores: unsupported chip " - "0x%x\n", CHIPID(sii->pub.chip))); + "0x%x\n", sii->pub.chip)); ASSERT(0); numcores = 1; } @@ -344,7 +347,7 @@ static void *_sb_setcoreidx(si_info_t *sii, uint coreidx) u32 sbaddr = sii->coresba[coreidx]; void *regs; - switch (BUSTYPE(sii->pub.bustype)) { + switch (sii->pub.bustype) { #ifdef BCMSDIO case SPI_BUS: case SDIO_BUS: @@ -409,8 +412,8 @@ bool sb_taclear(si_t *sih, bool details) sii = SI_INFO(sih); - if ((BUSTYPE(sii->pub.bustype) == SDIO_BUS) || - (BUSTYPE(sii->pub.bustype) == SPI_BUS)) { + if ((sii->pub.bustype == SDIO_BUS) || + (sii->pub.bustype == SPI_BUS)) { INTR_OFF(sii, intr_val); origidx = si_coreidx(sih); diff --git a/drivers/staging/brcm80211/util/siutils.c b/drivers/staging/brcm80211/util/siutils.c index f3ea7e1a7aef..b66de9b35a5a 100644 --- a/drivers/staging/brcm80211/util/siutils.c +++ b/drivers/staging/brcm80211/util/siutils.c @@ -14,11 +14,16 @@ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include <linux/delay.h> #include <linux/kernel.h> #include <linux/string.h> #include <bcmdefs.h> +#ifdef BRCM_FULLMAC +#include <linux/netdevice.h> +#endif #include <osl.h> -#include <linuxver.h> +#include <linux/module.h> +#include <linux/pci.h> #include <bcmutils.h> #include <siutils.h> #include <bcmdevs.h> @@ -53,7 +58,7 @@ #endif /* local prototypes */ -static si_info_t *si_doattach(si_info_t *sii, uint devid, osl_t *osh, +static si_info_t *si_doattach(si_info_t *sii, uint devid, struct osl_info *osh, void *regs, uint bustype, void *sdh, char **vars, uint *varsz); static bool si_buscore_prep(si_info_t *sii, uint bustype, uint devid, @@ -81,8 +86,8 @@ static u32 si_gpioreservation; * vars - pointer to a pointer area for "environment" variables * varsz - pointer to int to return the size of the vars */ -si_t *si_attach(uint devid, osl_t *osh, void *regs, uint bustype, void *sdh, - char **vars, uint *varsz) +si_t *si_attach(uint devid, struct osl_info *osh, void *regs, uint bustype, + void *sdh, char **vars, uint *varsz) { si_info_t *sii; @@ -113,12 +118,12 @@ static bool si_buscore_prep(si_info_t *sii, uint bustype, uint devid, #ifndef BRCM_FULLMAC /* kludge to enable the clock on the 4306 which lacks a slowclock */ - if (BUSTYPE(bustype) == PCI_BUS && !si_ispcie(sii)) + if (bustype == PCI_BUS && !si_ispcie(sii)) si_clkctl_xtal(&sii->pub, XTAL | PLL, ON); #endif #if defined(BCMSDIO) - if (BUSTYPE(bustype) == SDIO_BUS) { + if (bustype == SDIO_BUS) { int err; u8 clkset; @@ -220,7 +225,7 @@ static bool si_buscore_setup(si_info_t *sii, chipcregs_t *cc, uint bustype, SI_VMSG(("CORE[%d]: id 0x%x rev %d base 0x%x regs 0x%p\n", i, cid, crev, sii->coresba[i], sii->regs[i])); - if (BUSTYPE(bustype) == PCI_BUS) { + if (bustype == PCI_BUS) { if (cid == PCI_CORE_ID) { pciidx = i; pcirev = crev; @@ -232,8 +237,8 @@ static bool si_buscore_setup(si_info_t *sii, chipcregs_t *cc, uint bustype, } } #ifdef BCMSDIO - else if (((BUSTYPE(bustype) == SDIO_BUS) || - (BUSTYPE(bustype) == SPI_BUS)) && + else if (((bustype == SDIO_BUS) || + (bustype == SPI_BUS)) && ((cid == PCMCIA_CORE_ID) || (cid == SDIOD_CORE_ID))) { sii->pub.buscorerev = crev; sii->pub.buscoretype = cid; @@ -255,7 +260,7 @@ static bool si_buscore_setup(si_info_t *sii, chipcregs_t *cc, uint bustype, * or downloaded code was * already running. */ - if ((BUSTYPE(bustype) == SDIO_BUS) || (BUSTYPE(bustype) == SPI_BUS)) { + if ((bustype == SDIO_BUS) || (bustype == SPI_BUS)) { if (si_setcore(&sii->pub, ARM7S_CORE_ID, 0) || si_setcore(&sii->pub, ARMCM3_CORE_ID, 0)) si_core_disable(&sii->pub, 0); @@ -281,7 +286,7 @@ static bool si_buscore_setup(si_info_t *sii, chipcregs_t *cc, uint bustype, sii->pub.buscoretype, sii->pub.buscorerev)); /* fixup necessary chip/core configurations */ - if (BUSTYPE(sii->pub.bustype) == PCI_BUS) { + if (sii->pub.bustype == PCI_BUS) { if (SI_FAST(sii)) { if (!sii->pch) { sii->pch = (void *)pcicore_init( @@ -308,10 +313,10 @@ static __used void si_nvram_process(si_info_t *sii, char *pvars) uint w = 0; /* get boardtype and boardrev */ - switch (BUSTYPE(sii->pub.bustype)) { + switch (sii->pub.bustype) { case PCI_BUS: /* do a pci config read to get subsystem id and subvendor id */ - w = OSL_PCI_READ_CONFIG(sii->osh, PCI_CFG_SVID, sizeof(u32)); + pci_read_config_dword(sii->osh->pdev, PCI_CFG_SVID, &w); /* Let nvram variables override subsystem Vend/ID */ sii->pub.boardvendor = (u16)si_getdevpathintvar(&sii->pub, "boardvendor"); @@ -364,7 +369,7 @@ static __used void si_nvram_process(si_info_t *sii, char *pvars) /* this is will make Sonics calls directly, since Sonics is no longer supported in the Si abstraction */ /* this has been customized for the bcm 4329 ONLY */ #ifdef BCMSDIO -static si_info_t *si_doattach(si_info_t *sii, uint devid, osl_t *osh, +static si_info_t *si_doattach(si_info_t *sii, uint devid, struct osl_info *osh, void *regs, uint bustype, void *sdh, char **vars, uint *varsz) { @@ -376,7 +381,7 @@ static si_info_t *si_doattach(si_info_t *sii, uint devid, osl_t *osh, ASSERT(GOODREGS(regs)); - bzero((unsigned char *) sii, sizeof(si_info_t)); + memset((unsigned char *) sii, 0, sizeof(si_info_t)); savewin = 0; @@ -390,11 +395,6 @@ static si_info_t *si_doattach(si_info_t *sii, uint devid, osl_t *osh, cc = (chipcregs_t *) sii->curmap; sih->bustype = bustype; - if (bustype != BUSTYPE(bustype)) { - SI_ERROR(("si_doattach: bus type %d does not match configured bus type %d\n", bustype, BUSTYPE(bustype))); - return NULL; - } - /* bus/core/clk setup for register access */ if (!si_buscore_prep(sii, bustype, devid, sdh)) { SI_ERROR(("si_doattach: si_core_clk_prep failed %d\n", @@ -414,7 +414,7 @@ static si_info_t *si_doattach(si_info_t *sii, uint devid, osl_t *osh, sih->chiprev = (w & CID_REV_MASK) >> CID_REV_SHIFT; sih->chippkg = (w & CID_PKG_MASK) >> CID_PKG_SHIFT; - if ((CHIPID(sih->chip) == BCM4329_CHIP_ID) && + if ((sih->chip == BCM4329_CHIP_ID) && (sih->chippkg != BCM4329_289PIN_PKG_ID)) sih->chippkg = BCM4329_182PIN_PKG_ID; @@ -444,7 +444,7 @@ static si_info_t *si_doattach(si_info_t *sii, uint devid, osl_t *osh, /* Init nvram from sprom/otp if they exist */ if (srom_var_init - (&sii->pub, BUSTYPE(bustype), regs, sii->osh, vars, varsz)) { + (&sii->pub, bustype, regs, sii->osh, vars, varsz)) { SI_ERROR(("si_doattach: srom_var_init failed: bad srom\n")); goto exit; } @@ -499,7 +499,7 @@ static si_info_t *si_doattach(si_info_t *sii, uint devid, osl_t *osh, } #else /* BCMSDIO */ -static si_info_t *si_doattach(si_info_t *sii, uint devid, osl_t *osh, +static si_info_t *si_doattach(si_info_t *sii, uint devid, struct osl_info *osh, void *regs, uint bustype, void *sdh, char **vars, uint *varsz) { @@ -511,7 +511,7 @@ static si_info_t *si_doattach(si_info_t *sii, uint devid, osl_t *osh, ASSERT(GOODREGS(regs)); - bzero((unsigned char *) sii, sizeof(si_info_t)); + memset((unsigned char *) sii, 0, sizeof(si_info_t)); savewin = 0; @@ -522,30 +522,29 @@ static si_info_t *si_doattach(si_info_t *sii, uint devid, osl_t *osh, sii->osh = osh; /* check to see if we are a si core mimic'ing a pci core */ - if ((bustype == PCI_BUS) && - (OSL_PCI_READ_CONFIG(sii->osh, PCI_SPROM_CONTROL, sizeof(u32)) == - 0xffffffff)) { - SI_ERROR(("%s: incoming bus is PCI but it's a lie, switching to SI " "devid:0x%x\n", __func__, devid)); - bustype = SI_BUS; + if (bustype == PCI_BUS) { + pci_read_config_dword(sii->osh->pdev, PCI_SPROM_CONTROL, &w); + if (w == 0xffffffff) { + SI_ERROR(("%s: incoming bus is PCI but it's a lie, " + " switching to SI devid:0x%x\n", + __func__, devid)); + bustype = SI_BUS; + } } /* find Chipcommon address */ if (bustype == PCI_BUS) { - savewin = - OSL_PCI_READ_CONFIG(sii->osh, PCI_BAR0_WIN, sizeof(u32)); + pci_read_config_dword(sii->osh->pdev, PCI_BAR0_WIN, &savewin); if (!GOODCOREADDR(savewin, SI_ENUM_BASE)) savewin = SI_ENUM_BASE; - OSL_PCI_WRITE_CONFIG(sii->osh, PCI_BAR0_WIN, 4, SI_ENUM_BASE); + pci_write_config_dword(sii->osh->pdev, PCI_BAR0_WIN, + SI_ENUM_BASE); cc = (chipcregs_t *) regs; } else { cc = (chipcregs_t *) REG_MAP(SI_ENUM_BASE, SI_CORE_SIZE); } sih->bustype = bustype; - if (bustype != BUSTYPE(bustype)) { - SI_ERROR(("si_doattach: bus type %d does not match configured bus type %d\n", bustype, BUSTYPE(bustype))); - return NULL; - } /* bus/core/clk setup for register access */ if (!si_buscore_prep(sii, bustype, devid, sdh)) { @@ -569,7 +568,7 @@ static si_info_t *si_doattach(si_info_t *sii, uint devid, osl_t *osh, sih->issim = IS_SIM(sih->chippkg); /* scan for cores */ - if (CHIPTYPE(sii->pub.socitype) == SOCI_AI) { + if (sii->pub.socitype == SOCI_AI) { SI_MSG(("Found chip type AI (0x%08x)\n", w)); /* pass chipc address instead of original core base */ ai_scan(&sii->pub, (void *)cc, devid); @@ -592,10 +591,10 @@ static si_info_t *si_doattach(si_info_t *sii, uint devid, osl_t *osh, /* assume current core is CC */ if ((sii->pub.ccrev == 0x25) && - ((CHIPID(sih->chip) == BCM43236_CHIP_ID - || CHIPID(sih->chip) == BCM43235_CHIP_ID - || CHIPID(sih->chip) == BCM43238_CHIP_ID) - && (CHIPREV(sii->pub.chiprev) <= 2))) { + ((sih->chip == BCM43236_CHIP_ID + || sih->chip == BCM43235_CHIP_ID + || sih->chip == BCM43238_CHIP_ID) + && (sii->pub.chiprev <= 2))) { if ((cc->chipstatus & CST43236_BP_CLK) != 0) { uint clkdiv; @@ -613,7 +612,7 @@ static si_info_t *si_doattach(si_info_t *sii, uint devid, osl_t *osh, /* Init nvram from sprom/otp if they exist */ if (srom_var_init - (&sii->pub, BUSTYPE(bustype), regs, sii->osh, vars, varsz)) { + (&sii->pub, bustype, regs, sii->osh, vars, varsz)) { SI_ERROR(("si_doattach: srom_var_init failed: bad srom\n")); goto exit; } @@ -651,10 +650,10 @@ static si_info_t *si_doattach(si_info_t *sii, uint devid, osl_t *osh, pcicore_attach(sii->pch, pvars, SI_DOATTACH); } - if ((CHIPID(sih->chip) == BCM43224_CHIP_ID) || - (CHIPID(sih->chip) == BCM43421_CHIP_ID)) { + if ((sih->chip == BCM43224_CHIP_ID) || + (sih->chip == BCM43421_CHIP_ID)) { /* enable 12 mA drive strenth for 43224 and set chipControl register bit 15 */ - if (CHIPREV(sih->chiprev) == 0) { + if (sih->chiprev == 0) { SI_MSG(("Applying 43224A0 WARs\n")); si_corereg(sih, SI_CC_IDX, offsetof(chipcregs_t, chipcontrol), @@ -663,28 +662,28 @@ static si_info_t *si_doattach(si_info_t *sii, uint devid, osl_t *osh, si_pmu_chipcontrol(sih, 0, CCTRL_43224A0_12MA_LED_DRIVE, CCTRL_43224A0_12MA_LED_DRIVE); } - if (CHIPREV(sih->chiprev) >= 1) { + if (sih->chiprev >= 1) { SI_MSG(("Applying 43224B0+ WARs\n")); si_pmu_chipcontrol(sih, 0, CCTRL_43224B0_12MA_LED_DRIVE, CCTRL_43224B0_12MA_LED_DRIVE); } } - if (CHIPID(sih->chip) == BCM4313_CHIP_ID) { + if (sih->chip == BCM4313_CHIP_ID) { /* enable 12 mA drive strenth for 4313 and set chipControl register bit 1 */ SI_MSG(("Applying 4313 WARs\n")); si_pmu_chipcontrol(sih, 0, CCTRL_4313_12MA_LED_DRIVE, CCTRL_4313_12MA_LED_DRIVE); } - if (CHIPID(sih->chip) == BCM4331_CHIP_ID) { + if (sih->chip == BCM4331_CHIP_ID) { /* Enable Ext PA lines depending on chip package option */ si_chipcontrl_epa4331(sih, true); } return sii; exit: - if (BUSTYPE(sih->bustype) == PCI_BUS) { + if (sih->bustype == PCI_BUS) { if (sii->pch) pcicore_deinit(sii->pch); sii->pch = NULL; @@ -708,17 +707,17 @@ void si_detach(si_t *sih) if (sii == NULL) return; - if (BUSTYPE(sih->bustype) == SI_BUS) + if (sih->bustype == SI_BUS) for (idx = 0; idx < SI_MAXCORES; idx++) if (sii->regs[idx]) { - REG_UNMAP(sii->regs[idx]); + iounmap(sii->regs[idx]); sii->regs[idx] = NULL; } #ifndef BRCM_FULLMAC nvram_exit((void *)si_local); /* free up nvram buffers */ - if (BUSTYPE(sih->bustype) == PCI_BUS) { + if (sih->bustype == PCI_BUS) { if (sii->pch) pcicore_deinit(sii->pch); sii->pch = NULL; @@ -730,7 +729,7 @@ void si_detach(si_t *sih) kfree(sii); } -void *si_osh(si_t *sih) +struct osl_info *si_osh(si_t *sih) { si_info_t *sii; @@ -766,7 +765,7 @@ void si_deregister_intr_callback(si_t *sih) uint si_flag(si_t *sih) { - if (CHIPTYPE(sih->socitype) == SOCI_AI) + if (sih->socitype == SOCI_AI) return ai_flag(sih); else { ASSERT(0); @@ -776,7 +775,7 @@ uint si_flag(si_t *sih) void si_setint(si_t *sih, int siflag) { - if (CHIPTYPE(sih->socitype) == SOCI_AI) + if (sih->socitype == SOCI_AI) ai_setint(sih, siflag); else ASSERT(0); @@ -808,7 +807,7 @@ bool si_backplane64(si_t *sih) #ifndef BCMSDIO uint si_corerev(si_t *sih) { - if (CHIPTYPE(sih->socitype) == SOCI_AI) + if (sih->socitype == SOCI_AI) return ai_corerev(sih); else { ASSERT(0); @@ -851,7 +850,7 @@ void *si_setcore(si_t *sih, uint coreid, uint coreunit) if (!GOODIDX(idx)) return NULL; - if (CHIPTYPE(sih->socitype) == SOCI_AI) + if (sih->socitype == SOCI_AI) return ai_setcoreidx(sih, idx); else { #ifdef BCMSDIO @@ -866,7 +865,7 @@ void *si_setcore(si_t *sih, uint coreid, uint coreunit) #ifndef BCMSDIO void *si_setcoreidx(si_t *sih, uint coreidx) { - if (CHIPTYPE(sih->socitype) == SOCI_AI) + if (sih->socitype == SOCI_AI) return ai_setcoreidx(sih, coreidx); else { ASSERT(0); @@ -918,7 +917,7 @@ void si_restore_core(si_t *sih, uint coreid, uint intr_val) u32 si_core_cflags(si_t *sih, u32 mask, u32 val) { - if (CHIPTYPE(sih->socitype) == SOCI_AI) + if (sih->socitype == SOCI_AI) return ai_core_cflags(sih, mask, val); else { ASSERT(0); @@ -928,7 +927,7 @@ u32 si_core_cflags(si_t *sih, u32 mask, u32 val) u32 si_core_sflags(si_t *sih, u32 mask, u32 val) { - if (CHIPTYPE(sih->socitype) == SOCI_AI) + if (sih->socitype == SOCI_AI) return ai_core_sflags(sih, mask, val); else { ASSERT(0); @@ -938,7 +937,7 @@ u32 si_core_sflags(si_t *sih, u32 mask, u32 val) bool si_iscoreup(si_t *sih) { - if (CHIPTYPE(sih->socitype) == SOCI_AI) + if (sih->socitype == SOCI_AI) return ai_iscoreup(sih); else { #ifdef BCMSDIO @@ -953,7 +952,7 @@ bool si_iscoreup(si_t *sih) void si_write_wrapperreg(si_t *sih, u32 offset, u32 val) { /* only for 4319, no requirement for SOCI_SB */ - if (CHIPTYPE(sih->socitype) == SOCI_AI) { + if (sih->socitype == SOCI_AI) { ai_write_wrap_reg(sih, offset, val); } } @@ -961,7 +960,7 @@ void si_write_wrapperreg(si_t *sih, u32 offset, u32 val) uint si_corereg(si_t *sih, uint coreidx, uint regoff, uint mask, uint val) { - if (CHIPTYPE(sih->socitype) == SOCI_AI) + if (sih->socitype == SOCI_AI) return ai_corereg(sih, coreidx, regoff, mask, val); else { #ifdef BCMSDIO @@ -976,7 +975,7 @@ uint si_corereg(si_t *sih, uint coreidx, uint regoff, uint mask, uint val) void si_core_disable(si_t *sih, u32 bits) { - if (CHIPTYPE(sih->socitype) == SOCI_AI) + if (sih->socitype == SOCI_AI) ai_core_disable(sih, bits); #ifdef BCMSDIO else @@ -986,7 +985,7 @@ void si_core_disable(si_t *sih, u32 bits) void si_core_reset(si_t *sih, u32 bits, u32 resetbits) { - if (CHIPTYPE(sih->socitype) == SOCI_AI) + if (sih->socitype == SOCI_AI) ai_core_reset(sih, bits, resetbits); #ifdef BCMSDIO else @@ -1043,8 +1042,8 @@ void si_watchdog(si_t *sih, uint ticks) if (PMUCTL_ENAB(sih)) { - if ((CHIPID(sih->chip) == BCM4319_CHIP_ID) && - (CHIPREV(sih->chiprev) == 0) && (ticks != 0)) { + if ((sih->chip == BCM4319_CHIP_ID) && + (sih->chiprev == 0) && (ticks != 0)) { si_corereg(sih, SI_CC_IDX, offsetof(chipcregs_t, clk_ctl_st), ~0, 0x2); si_setcore(sih, USB20D_CORE_ID, 0); @@ -1085,16 +1084,18 @@ void si_watchdog(si_t *sih, uint ticks) static uint si_slowclk_src(si_info_t *sii) { chipcregs_t *cc; + u32 val; ASSERT(SI_FAST(sii) || si_coreid(&sii->pub) == CC_CORE_ID); if (sii->pub.ccrev < 6) { - if ((BUSTYPE(sii->pub.bustype) == PCI_BUS) && - (OSL_PCI_READ_CONFIG(sii->osh, PCI_GPIO_OUT, sizeof(u32)) - & PCI_CFG_GPIO_SCS)) - return SCC_SS_PCI; - else - return SCC_SS_XTAL; + if (sii->pub.bustype == PCI_BUS) { + pci_read_config_dword(sii->osh->pdev, PCI_GPIO_OUT, + &val); + if (val & PCI_CFG_GPIO_SCS) + return SCC_SS_PCI; + } + return SCC_SS_XTAL; } else if (sii->pub.ccrev < 10) { cc = (chipcregs_t *) si_setcoreidx(&sii->pub, sii->curidx); return R_REG(sii->osh, &cc->slow_clk_ctl) & SCC_SS_MASK; @@ -1264,7 +1265,7 @@ int si_clkctl_xtal(si_t *sih, uint what, bool on) sii = SI_INFO(sih); - switch (BUSTYPE(sih->bustype)) { + switch (sih->bustype) { #ifdef BCMSDIO case SDIO_BUS: @@ -1276,12 +1277,9 @@ int si_clkctl_xtal(si_t *sih, uint what, bool on) if (PCIE(sii)) return -1; - in = OSL_PCI_READ_CONFIG(sii->osh, PCI_GPIO_IN, sizeof(u32)); - out = - OSL_PCI_READ_CONFIG(sii->osh, PCI_GPIO_OUT, sizeof(u32)); - outen = - OSL_PCI_READ_CONFIG(sii->osh, PCI_GPIO_OUTEN, - sizeof(u32)); + pci_read_config_dword(sii->osh->pdev, PCI_GPIO_IN, &in); + pci_read_config_dword(sii->osh->pdev, PCI_GPIO_OUT, &out); + pci_read_config_dword(sii->osh->pdev, PCI_GPIO_OUTEN, &outen); /* * Avoid glitching the clock if GPRS is already using it. @@ -1302,18 +1300,18 @@ int si_clkctl_xtal(si_t *sih, uint what, bool on) out |= PCI_CFG_GPIO_XTAL; if (what & PLL) out |= PCI_CFG_GPIO_PLL; - OSL_PCI_WRITE_CONFIG(sii->osh, PCI_GPIO_OUT, - sizeof(u32), out); - OSL_PCI_WRITE_CONFIG(sii->osh, PCI_GPIO_OUTEN, - sizeof(u32), outen); + pci_write_config_dword(sii->osh->pdev, + PCI_GPIO_OUT, out); + pci_write_config_dword(sii->osh->pdev, + PCI_GPIO_OUTEN, outen); udelay(XTAL_ON_DELAY); } /* turn pll on */ if (what & PLL) { out &= ~PCI_CFG_GPIO_PLL; - OSL_PCI_WRITE_CONFIG(sii->osh, PCI_GPIO_OUT, - sizeof(u32), out); + pci_write_config_dword(sii->osh->pdev, + PCI_GPIO_OUT, out); mdelay(2); } } else { @@ -1321,10 +1319,10 @@ int si_clkctl_xtal(si_t *sih, uint what, bool on) out &= ~PCI_CFG_GPIO_XTAL; if (what & PLL) out |= PCI_CFG_GPIO_PLL; - OSL_PCI_WRITE_CONFIG(sii->osh, PCI_GPIO_OUT, - sizeof(u32), out); - OSL_PCI_WRITE_CONFIG(sii->osh, PCI_GPIO_OUTEN, - sizeof(u32), outen); + pci_write_config_dword(sii->osh->pdev, + PCI_GPIO_OUT, out); + pci_write_config_dword(sii->osh->pdev, + PCI_GPIO_OUTEN, outen); } default: @@ -1378,7 +1376,7 @@ static bool _si_clkctl_cc(si_info_t *sii, uint mode) INTR_OFF(sii, intr_val); origidx = sii->curidx; - if ((BUSTYPE(sii->pub.bustype) == SI_BUS) && + if ((sii->pub.bustype == SI_BUS) && si_setcore(&sii->pub, MIPS33_CORE_ID, 0) && (si_corerev(&sii->pub) <= 7) && (sii->pub.ccrev >= 10)) goto done; @@ -1460,7 +1458,7 @@ int si_devpath(si_t *sih, char *path, int size) if (!path || size <= 0) return -1; - switch (BUSTYPE(sih->bustype)) { + switch (sih->bustype) { case SI_BUS: case JTAG_BUS: slen = snprintf(path, (size_t) size, "sb/%u/", si_coreidx(sih)); @@ -1550,7 +1548,7 @@ static __used bool si_ispcie(si_info_t *sii) { u8 cap_ptr; - if (BUSTYPE(sii->pub.bustype) != PCI_BUS) + if (sii->pub.bustype != PCI_BUS) return false; cap_ptr = @@ -1617,7 +1615,7 @@ void si_pci_up(si_t *sih) sii = SI_INFO(sih); /* if not pci bus, we're done */ - if (BUSTYPE(sih->bustype) != PCI_BUS) + if (sih->bustype != PCI_BUS) return; if (PCI_FORCEHT(sii)) @@ -1646,7 +1644,7 @@ void si_pci_down(si_t *sih) sii = SI_INFO(sih); /* if not pci bus, we're done */ - if (BUSTYPE(sih->bustype) != PCI_BUS) + if (sih->bustype != PCI_BUS) return; /* release FORCEHT since chip is going to "down" state */ @@ -1669,7 +1667,7 @@ void si_pci_setup(si_t *sih, uint coremask) sii = SI_INFO(sih); - if (BUSTYPE(sii->pub.bustype) != PCI_BUS) + if (sii->pub.bustype != PCI_BUS) return; ASSERT(PCI(sii) || PCIE(sii)); @@ -1692,9 +1690,9 @@ void si_pci_setup(si_t *sih, uint coremask) */ if (PCIE(sii) || (PCI(sii) && ((sii->pub.buscorerev) >= 6))) { /* pci config write to set this core bit in PCIIntMask */ - w = OSL_PCI_READ_CONFIG(sii->osh, PCI_INT_MASK, sizeof(u32)); + pci_read_config_dword(sii->osh->pdev, PCI_INT_MASK, &w); w |= (coremask << PCI_SBIM_SHIFT); - OSL_PCI_WRITE_CONFIG(sii->osh, PCI_INT_MASK, sizeof(u32), w); + pci_write_config_dword(sii->osh->pdev, PCI_INT_MASK, w); } else { /* set sbintvec bit for our flag number */ si_setint(sih, siflag); @@ -1731,7 +1729,7 @@ int si_pci_fixcfg(si_t *sih) si_info_t *sii = SI_INFO(sih); - ASSERT(BUSTYPE(sii->pub.bustype) == PCI_BUS); + ASSERT(sii->pub.bustype == PCI_BUS); /* Fixup PI in SROM shadow area to enable the correct PCI core access */ /* save the current index */ @@ -1777,7 +1775,7 @@ u32 si_gpiocontrol(si_t *sih, u32 mask, u32 val, u8 priority) * ignore reservation if it's high priority (e.g., test apps) */ if ((priority != GPIO_HI_PRIORITY) && - (BUSTYPE(sih->bustype) == SI_BUS) && (val || mask)) { + (sih->bustype == SI_BUS) && (val || mask)) { mask = priority ? (si_gpioreservation & mask) : ((si_gpioreservation | mask) & ~(si_gpioreservation)); val &= mask; @@ -1929,10 +1927,10 @@ bool si_deviceremoved(si_t *sih) sii = SI_INFO(sih); - switch (BUSTYPE(sih->bustype)) { + switch (sih->bustype) { case PCI_BUS: ASSERT(sii->osh != NULL); - w = OSL_PCI_READ_CONFIG(sii->osh, PCI_CFG_VID, sizeof(u32)); + pci_read_config_dword(sii->osh->pdev, PCI_CFG_VID, &w); if ((w & 0xFFFF) != VENDOR_BROADCOM) return true; break; @@ -1959,7 +1957,7 @@ bool si_is_sprom_available(si_t *sih) return sromctrl & SRC_PRESENT; } - switch (CHIPID(sih->chip)) { + switch (sih->chip) { case BCM4329_CHIP_ID: return (sih->chipst & CST4329_SPROM_SEL) != 0; case BCM4319_CHIP_ID: @@ -1979,7 +1977,7 @@ bool si_is_sprom_available(si_t *sih) bool si_is_otp_disabled(si_t *sih) { - switch (CHIPID(sih->chip)) { + switch (sih->chip) { case BCM4329_CHIP_ID: return (sih->chipst & CST4329_SPROM_OTP_SEL_MASK) == CST4329_OTP_PWRDN; |