在线时间0 小时
UID91155
注册时间2008-11-12
NXP金币0
该用户从未签到
新手上路

- 积分
- 21
- 最后登录
- 1970-1-1
|
发表于 2008-12-30 17:57:18
|
显示全部楼层
回复:mpc8313的DMA的例程
DMA mode, use the 8313E as the DMAC to read/write the PCI target card, if reading ,it's failed, if writing, it's successful! why?
the corrective code list as:
void __iomem *DMA_BASE = ioremap(get_immrbase() + DMA_OFFSET, 0x300);
void __iomem *DMA_SR = DMA_BASE + DMASR0;
void __iomem *DMA_MR = DMA_BASE + DMAMR0;
void __iomem *DMA_SAR = DMA_BASE + DMASAR0;
void __iomem *DMA_DAR = DMA_BASE + DMADAR0;
void __iomem *DMA_BCR = DMA_BASE + DMABCR0;
printk(KERN_INFO "dma prepare2!\n");
if(mypci_card->channels == 0)
{ // Source Address
out_le32(DMA_SAR, mypci_card->bs_addr[1].base);
// Destination Address
out_le32(DMA_DAR, mypci_card->dmabuf.dma_addr);
// Counter
out_le32(DMA_BCR, 0x100);
// DMA mode
reg = DMAMR_CTM | DMAMR_SEN PRC_H;//|DMAMR_IRQS|DMAMR_EOTIE; //后两项开启DMA中断
out_le32(DMA_MR, reg);
printk("Going to start transfer: 0x%08lx->0x%08lx(0x%08lx) mode=0x%08lx\n",
(long unsigned int) in_le32(DMA_SAR), (long unsigned int)in_le32(DMA_DAR),(long unsigned int) in_le32(DMA_BCR), (long unsigned int)in_le32(DMA_MR));
// Start transfer
reg |= DMAMR_CS;
msleep(1);
out_le32(DMA_MR, reg);
reg = in_le32(DMA_SR);
while (reg & DMASR_CB) { //此处请采用中断方式处理
printk("CB=1\n");
reg = in_le32(DMA_SR);
}
printk("Done! DMA Status=0x%x\n", reg);
}
else
{
printk("channel error\n");
}
iounmap(DMA_BASE); |
|