}
}
-static struct bcma_device *ai_find_bcma_core(struct si_pub *sih, uint coreidx)
-{
- struct si_info *sii = (struct si_info *)sih;
- struct bcma_device *core;
-
- list_for_each_entry(core, &sii->icbus->cores, list) {
- if (core->core_index == coreidx)
- return core;
- }
- return NULL;
-}
-/*
- * This function changes the logical "focus" to the indicated core.
- * Return the current core's virtual address. Since each core starts with the
- * same set of registers (BIST, clock control, etc), the returned address
- * contains the first register of this 'common' register block (not to be
- * confused with 'common core').
- */
-void __iomem *ai_setcoreidx(struct si_pub *sih, uint coreidx)
-{
- struct si_info *sii = (struct si_info *)sih;
- struct bcma_device *core;
-
- if (sii->curidx != coreidx) {
- core = ai_find_bcma_core(sih, coreidx);
- if (core == NULL)
- return NULL;
-
- (void)bcma_aread32(core, BCMA_IOST);
- sii->curidx = coreidx;
- }
- return sii->curmap;
-}
-
-uint ai_corerev(struct si_pub *sih)
-{
- struct si_info *sii;
- u32 cib;
-
- sii = (struct si_info *)sih;
- cib = sii->cib[sii->curidx];
- return (cib & CIB_REV_MASK) >> CIB_REV_SHIFT;
-}
-
/* return true if PCIE capability exists in the pci config space */
static bool ai_ispcie(struct si_info *sii)
{
for (i = 0; i < sii->numcores; i++) {
uint cid, crev;
- ai_setcoreidx(&sii->pub, i);
- cid = ai_coreid(&sii->pub);
- crev = ai_corerev(&sii->pub);
+ cid = sii->coreid[i];
+ crev = (sii->cib[i] & CIB_REV_MASK) >> CIB_REV_SHIFT;
if (cid == PCI_CORE_ID) {
pciidx = i;
kfree(sii);
}
-uint ai_coreid(struct si_pub *sih)
-{
- struct si_info *sii;
-
- sii = (struct si_info *)sih;
- return sii->coreid[sii->curidx];
-}
-
-uint ai_coreidx(struct si_pub *sih)
-{
- struct si_info *sii;
-
- sii = (struct si_info *)sih;
- return sii->curidx;
-}
-
/* return index of coreid or BADIDX if not found */
struct bcma_device *ai_findcore(struct si_pub *sih, u16 coreid, u16 coreunit)
{
}
/*
- * This function changes logical "focus" to the indicated core;
- * must be called with interrupts off.
- * Moreover, callers should keep interrupts off during switching
- * out of and back to d11 core.
- */
-void __iomem *ai_setcore(struct si_pub *sih, uint coreid, uint coreunit)
-{
- struct bcma_device *core;
-
- core = ai_findcore(sih, coreid, coreunit);
- if (core == NULL)
- return NULL;
-
- return ai_setcoreidx(sih, core->core_index);
-}
-
-/*
- * Switch to 'coreidx', issue a single arbitrary 32bit register mask&set
- * operation, switch back to the original core, and return the new value.
- *
- * When using the silicon backplane, no fiddling with interrupts or core
- * switches is needed.
- *
- * Also, when using pci/pcie, we can optimize away the core switching for pci
- * registers and (on newer pci cores) chipcommon registers.
+ * read/modify chipcommon core register.
*/
uint ai_cc_reg(struct si_pub *sih, uint regoff, u32 mask, u32 val)
{
struct bcma_device *cc;
- uint origidx = 0;
u32 w;
struct si_info *sii;
sii = (struct si_info *)sih;
cc = sii->icbus->drv_cc.core;
- /* save current core index */
- origidx = ai_coreidx(&sii->pub);
-
/* mask and set */
if (mask || val) {
bcma_maskset32(cc, regoff, ~mask, val);
/* readback */
w = bcma_read32(cc, regoff);
- /* restore core index */
- ai_setcoreidx(&sii->pub, origidx);
-
return w;
}
void ai_pci_setup(struct si_pub *sih, uint coremask)
{
struct si_info *sii;
- struct sbpciregs __iomem *regs = NULL;
u32 w;
- uint idx = 0;
sii = (struct si_info *)sih;
- if (PCI(sih)) {
- /* get current core index */
- idx = sii->curidx;
-
- /* switch over to pci core */
- regs = ai_setcoreidx(sih, sii->buscoreidx);
- }
-
/*
* Enable sb->pci interrupts. Assume
* PCI rev 2.3 support was added in pci core rev 6 and things changed..
if (PCI(sih)) {
pcicore_pci_setup(sii->pch);
-
- /* switch back to previous core */
- ai_setcoreidx(sih, idx);
}
}
*/
int ai_pci_fixcfg(struct si_pub *sih)
{
- uint origidx;
- void __iomem *regs = NULL;
struct si_info *sii = (struct si_info *)sih;
/* Fixup PI in SROM shadow area to enable the correct PCI core access */
- /* save the current index */
- origidx = ai_coreidx(&sii->pub);
-
/* check 'pi' is correct and fix it if not */
- regs = ai_setcore(&sii->pub, ai_get_buscoretype(sih), 0);
pcicore_fixcfg(sii->pch);
-
- /* restore the original index */
- ai_setcoreidx(&sii->pub, origidx);
-
pcicore_hwup(sii->pch);
return 0;
}
uint *msg_level; /* message level pointer */
char name[MAXNAMEL]; /* callers name for diag msgs */
- struct bcma_device *d11core;
+ struct bcma_device *core;
struct device *dmadev;
bool dma64; /* this dma engine is operating in 64-bit mode */
if (dmactrlflags & DMA_CTRL_PEN) {
u32 control;
- control = bcma_read32(di->d11core, DMA64TXREGOFFS(di, control));
- bcma_write32(di->d11core, DMA64TXREGOFFS(di, control),
+ control = bcma_read32(di->core, DMA64TXREGOFFS(di, control));
+ bcma_write32(di->core, DMA64TXREGOFFS(di, control),
control | D64_XC_PD);
- if (bcma_read32(di->d11core, DMA64TXREGOFFS(di, control)) &
+ if (bcma_read32(di->core, DMA64TXREGOFFS(di, control)) &
D64_XC_PD)
/* We *can* disable it so it is supported,
* restore control register
*/
- bcma_write32(di->d11core, DMA64TXREGOFFS(di, control),
+ bcma_write32(di->core, DMA64TXREGOFFS(di, control),
control);
else
/* Not supported, don't allow it to be enabled */
static bool _dma64_addrext(struct dma_info *di, uint ctrl_offset)
{
u32 w;
- bcma_set32(di->d11core, ctrl_offset, D64_XC_AE);
- w = bcma_read32(di->d11core, ctrl_offset);
- bcma_mask32(di->d11core, ctrl_offset, ~D64_XC_AE);
+ bcma_set32(di->core, ctrl_offset, D64_XC_AE);
+ w = bcma_read32(di->core, ctrl_offset);
+ bcma_mask32(di->core, ctrl_offset, ~D64_XC_AE);
return (w & D64_XC_AE) == D64_XC_AE;
}
/* Check to see if the descriptors need to be aligned on 4K/8K or not */
if (di->d64txregbase != 0) {
- bcma_write32(di->d11core, DMA64TXREGOFFS(di, addrlow), 0xff0);
- addrl = bcma_read32(di->d11core, DMA64TXREGOFFS(di, addrlow));
+ bcma_write32(di->core, DMA64TXREGOFFS(di, addrlow), 0xff0);
+ addrl = bcma_read32(di->core, DMA64TXREGOFFS(di, addrlow));
if (addrl != 0)
return false;
} else if (di->d64rxregbase != 0) {
- bcma_write32(di->d11core, DMA64RXREGOFFS(di, addrlow), 0xff0);
- addrl = bcma_read32(di->d11core, DMA64RXREGOFFS(di, addrlow));
+ bcma_write32(di->core, DMA64RXREGOFFS(di, addrlow), 0xff0);
+ addrl = bcma_read32(di->core, DMA64RXREGOFFS(di, addrlow));
if (addrl != 0)
return false;
}
}
struct dma_pub *dma_attach(char *name, struct si_pub *sih,
- struct bcma_device *d11core,
+ struct bcma_device *core,
uint txregbase, uint rxregbase, uint ntxd, uint nrxd,
uint rxbufsize, int rxextheadroom,
uint nrxpost, uint rxoffset, uint *msg_level)
{
struct dma_info *di;
+ u8 rev = core->id.rev;
uint size;
/* allocate private info structure */
di->dma64 =
- ((bcma_aread32(d11core, BCMA_IOST) & SISF_DMA64) == SISF_DMA64);
+ ((bcma_aread32(core, BCMA_IOST) & SISF_DMA64) == SISF_DMA64);
/* init dma reg info */
- di->d11core = d11core;
+ di->core = core;
di->d64txregbase = txregbase;
di->d64rxregbase = rxregbase;
strncpy(di->name, name, MAXNAMEL);
di->name[MAXNAMEL - 1] = '\0';
- di->dmadev = d11core->dma_dev;
+ di->dmadev = core->dma_dev;
/* save tunables */
di->ntxd = (u16) ntxd;
di->dataoffsetlow = di->ddoffsetlow;
di->dataoffsethigh = di->ddoffsethigh;
/* WAR64450 : DMACtl.Addr ext fields are not supported in SDIOD core. */
- if ((ai_coreid(sih) == SDIOD_CORE_ID)
- && ((ai_corerev(sih) > 0) && (ai_corerev(sih) <= 2)))
+ if ((core->id.id == SDIOD_CORE_ID)
+ && ((rev > 0) && (rev <= 2)))
di->addrext = 0;
- else if ((ai_coreid(sih) == I2S_CORE_ID) &&
- ((ai_corerev(sih) == 0) || (ai_corerev(sih) == 1)))
+ else if ((core->id.id == I2S_CORE_ID) &&
+ ((rev == 0) || (rev == 1)))
di->addrext = 0;
else
di->addrext = _dma_isaddrext(di);
if ((di->ddoffsetlow == 0)
|| !(pa & PCI32ADDR_HIGH)) {
if (direction == DMA_TX) {
- bcma_write32(di->d11core, DMA64TXREGOFFS(di, addrlow),
+ bcma_write32(di->core, DMA64TXREGOFFS(di, addrlow),
pa + di->ddoffsetlow);
- bcma_write32(di->d11core, DMA64TXREGOFFS(di, addrhigh),
+ bcma_write32(di->core, DMA64TXREGOFFS(di, addrhigh),
di->ddoffsethigh);
} else {
- bcma_write32(di->d11core, DMA64RXREGOFFS(di, addrlow),
+ bcma_write32(di->core, DMA64RXREGOFFS(di, addrlow),
pa + di->ddoffsetlow);
- bcma_write32(di->d11core, DMA64RXREGOFFS(di, addrhigh),
+ bcma_write32(di->core, DMA64RXREGOFFS(di, addrhigh),
di->ddoffsethigh);
}
} else {
pa &= ~PCI32ADDR_HIGH;
if (direction == DMA_TX) {
- bcma_write32(di->d11core, DMA64TXREGOFFS(di, addrlow),
+ bcma_write32(di->core, DMA64TXREGOFFS(di, addrlow),
pa + di->ddoffsetlow);
- bcma_write32(di->d11core, DMA64TXREGOFFS(di, addrhigh),
+ bcma_write32(di->core, DMA64TXREGOFFS(di, addrhigh),
di->ddoffsethigh);
- bcma_maskset32(di->d11core, DMA64TXREGOFFS(di, control),
+ bcma_maskset32(di->core, DMA64TXREGOFFS(di, control),
D64_XC_AE, (ae << D64_XC_AE_SHIFT));
} else {
- bcma_write32(di->d11core, DMA64RXREGOFFS(di, addrlow),
+ bcma_write32(di->core, DMA64RXREGOFFS(di, addrlow),
pa + di->ddoffsetlow);
- bcma_write32(di->d11core, DMA64RXREGOFFS(di, addrhigh),
+ bcma_write32(di->core, DMA64RXREGOFFS(di, addrhigh),
di->ddoffsethigh);
- bcma_maskset32(di->d11core, DMA64RXREGOFFS(di, control),
+ bcma_maskset32(di->core, DMA64RXREGOFFS(di, control),
D64_RC_AE, (ae << D64_RC_AE_SHIFT));
}
}
DMA_TRACE("%s:\n", di->name);
- control = D64_RC_RE | (bcma_read32(di->d11core,
+ control = D64_RC_RE | (bcma_read32(di->core,
DMA64RXREGOFFS(di, control)) &
D64_RC_AE);
if (dmactrlflags & DMA_CTRL_ROC)
control |= D64_RC_OC;
- bcma_write32(di->d11core, DMA64RXREGOFFS(di, control),
+ bcma_write32(di->core, DMA64RXREGOFFS(di, control),
((di->rxoffset << D64_RC_RO_SHIFT) | control));
}
return NULL;
curr =
- B2I(((bcma_read32(di->d11core,
+ B2I(((bcma_read32(di->core,
DMA64RXREGOFFS(di, status0)) & D64_RS0_CD_MASK) -
di->rcvptrbase) & D64_RS0_CD_MASK, struct dma64desc);
if (resid > 0) {
uint cur;
cur =
- B2I(((bcma_read32(di->d11core,
+ B2I(((bcma_read32(di->core,
DMA64RXREGOFFS(di, status0)) &
D64_RS0_CD_MASK) - di->rcvptrbase) &
D64_RS0_CD_MASK, struct dma64desc);
if (di->nrxd == 0)
return true;
- return ((bcma_read32(di->d11core,
+ return ((bcma_read32(di->core,
DMA64RXREGOFFS(di, status0)) & D64_RS0_CD_MASK) ==
- (bcma_read32(di->d11core, DMA64RXREGOFFS(di, ptr)) &
+ (bcma_read32(di->core, DMA64RXREGOFFS(di, ptr)) &
D64_RS0_CD_MASK));
}
di->rxout = rxout;
/* update the chip lastdscr pointer */
- bcma_write32(di->d11core, DMA64RXREGOFFS(di, ptr),
+ bcma_write32(di->core, DMA64RXREGOFFS(di, ptr),
di->rcvptrbase + I2B(rxout, struct dma64desc));
return ring_empty;
if ((di->dma.dmactrlflags & DMA_CTRL_PEN) == 0)
control |= D64_XC_PD;
- bcma_set32(di->d11core, DMA64TXREGOFFS(di, control), control);
+ bcma_set32(di->core, DMA64TXREGOFFS(di, control), control);
/* DMA engine with alignment requirement requires table to be inited
* before enabling the engine
if (di->ntxd == 0)
return;
- bcma_set32(di->d11core, DMA64TXREGOFFS(di, control), D64_XC_SE);
+ bcma_set32(di->core, DMA64TXREGOFFS(di, control), D64_XC_SE);
}
void dma_txresume(struct dma_pub *pub)
if (di->ntxd == 0)
return;
- bcma_mask32(di->d11core, DMA64TXREGOFFS(di, control), ~D64_XC_SE);
+ bcma_mask32(di->core, DMA64TXREGOFFS(di, control), ~D64_XC_SE);
}
bool dma_txsuspended(struct dma_pub *pub)
struct dma_info *di = (struct dma_info *)pub;
return (di->ntxd == 0) ||
- ((bcma_read32(di->d11core,
+ ((bcma_read32(di->core,
DMA64TXREGOFFS(di, control)) & D64_XC_SE) ==
D64_XC_SE);
}
return true;
/* suspend tx DMA first */
- bcma_write32(di->d11core, DMA64TXREGOFFS(di, control), D64_XC_SE);
+ bcma_write32(di->core, DMA64TXREGOFFS(di, control), D64_XC_SE);
SPINWAIT(((status =
- (bcma_read32(di->d11core, DMA64TXREGOFFS(di, status0)) &
+ (bcma_read32(di->core, DMA64TXREGOFFS(di, status0)) &
D64_XS0_XS_MASK)) != D64_XS0_XS_DISABLED) &&
(status != D64_XS0_XS_IDLE) && (status != D64_XS0_XS_STOPPED),
10000);
- bcma_write32(di->d11core, DMA64TXREGOFFS(di, control), 0);
+ bcma_write32(di->core, DMA64TXREGOFFS(di, control), 0);
SPINWAIT(((status =
- (bcma_read32(di->d11core, DMA64TXREGOFFS(di, status0)) &
+ (bcma_read32(di->core, DMA64TXREGOFFS(di, status0)) &
D64_XS0_XS_MASK)) != D64_XS0_XS_DISABLED), 10000);
/* wait for the last transaction to complete */
if (di->nrxd == 0)
return true;
- bcma_write32(di->d11core, DMA64RXREGOFFS(di, control), 0);
+ bcma_write32(di->core, DMA64RXREGOFFS(di, control), 0);
SPINWAIT(((status =
- (bcma_read32(di->d11core, DMA64RXREGOFFS(di, status0)) &
+ (bcma_read32(di->core, DMA64RXREGOFFS(di, status0)) &
D64_RS0_RS_MASK)) != D64_RS0_RS_DISABLED), 10000);
return status == D64_RS0_RS_DISABLED;
/* kick the chip */
if (commit)
- bcma_write32(di->d11core, DMA64TXREGOFFS(di, ptr),
+ bcma_write32(di->core, DMA64TXREGOFFS(di, ptr),
di->xmtptrbase + I2B(txout, struct dma64desc));
/* tx flow control */
if (range == DMA_RANGE_ALL)
end = di->txout;
else {
- end = (u16) (B2I(((bcma_read32(di->d11core,
+ end = (u16) (B2I(((bcma_read32(di->core,
DMA64TXREGOFFS(di, status0)) &
D64_XS0_CD_MASK) - di->xmtptrbase) &
D64_XS0_CD_MASK, struct dma64desc));
if (range == DMA_RANGE_TRANSFERED) {
active_desc =
- (u16)(bcma_read32(di->d11core,
+ (u16)(bcma_read32(di->core,
DMA64TXREGOFFS(di, status1)) &
D64_XS1_AD_MASK);
active_desc =