|
简介:ARM2440与FPGA通信,通过DMA方式。ARM的DMA请求信号(XnDREQ0)由FPGA提供。
问题:在驱动程序中配置好DMA控制器后,打开DMA控制器,理论上是控制器应该等待请求信号XnDREQ0有效,才
发起DMA传输。但是问题在于,当打开DMA控制器后,不管外部XnDREQ0信号如何给定(调试时用外部电平给),
DMA控制器均发起DMA传输。
驱动源代码:#include
#include
#include
#include
#include
#include //copy_to_use, copy_from_user
#include
//#include
#include //readl, readb, writel, writeb
#include
//#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define XDREQ0_MAJOR 239
#define XDREQ0_MINOR 0
#define dma_base (ioremap(0x4B000000,0x24))
#define DMA_DISRC0 (dma_base)
#define DMA_DISRCC0 (dma_base+0x4)
#define DMA_DIDST0 (dma_base+0x8)
#define DMA_DIDSTC0 (dma_base+0xC)
#define DMA_DCON0 (dma_base+0x10)
#define DMA_DSTAT0 (dma_base+0x14)
#define DMA_DCSRC0 (dma_base+0x18)
#define DMA_DCDST0 (dma_base+0x1C)
#define DMA_DMASKTRIG (dma_base+0x20)
#define mydma_channel 0
#define GPB_base (ioremap(0x56000010,0x0C))
#define GPBCON (GPB_base)
#define GPBDAT (GPB_base+0x4)
#define GPBUP (GPB_base+0x8)
MODULE_AUTHOR("hankle");
MODULE_DESCRIPTION("s3c2440 dma driver");
MODULE_LICENSE("GPL");
struct device *my_cdev;
struct class *my_class;
/*open*/
int fifo_dma_open(struct inode * inode,struct file * filp)
{
printk("dma is open\n");
//try_module_get(THIS_MODULE);
return 0;
}
int fifo_dma_release(struct inode * inode,struct file * filp)
{
printk("dma is released!\n");
//module_put(THIS_MODULE);
return 0;
}
ssize_t fifo_dma_read(struct file *filp, unsigned long *buff,size_t count,loff_t *f_ops)
{
unsigned long a,b,c,d,e;
int transfer_flag;
unsigned long srcaddr;
unsigned long dma_distaddr;
unsigned long order;
dma_addr_t *dma_buf_virt;
printk(KERN_ALERT"Kmalloc count %d",count);
order = get_order(count);
dma_buf_virt = __get_free_pages(GFP_KERNEL|GFP_DMA,order);
dma_distaddr = virt_to_phys(dma_buf_virt);
printk(KERN_ALERT"dma_buf_phy address is %lx \n",dma_distaddr);
srcaddr = 0x12000000; //GCS2 select
writel(srcaddr,DMA_DISRC0);
a= readl(DMA_DISRC0);
printk(KERN_ALERT"DMA_DISRC0 is %lx \n",a);
writel(((0 |
|