SDIO驱动(16)使用DMA传输数据2

本文详细介绍了在SDIO驱动中如何利用DMA控制器进行数据传输。从s3c24xx_dma_order_set()函数开始,探讨了如何配置DMA的源/目的寄存器、设置通道属性,以及在probe函数中启动和配置DMA的过程。通过s3c2410_dma_devconfig()、s3cmci_dma_setup()和s3c2410_dma_setbuffdone_fn()等函数,确保了DMA的正确运行,并设置了完成回调函数。最后,通过s3cmci_prepare_dma()控制DMA的启停,实现高效的数据传输。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

DMA控制器驱动框架中的第二个函数:

s3c24xx_dma_order_set(&s3c2440_dma_order);
参数s3c2440_dma_order是一个全局变量,抽象的是下图物理channel和逻辑channel及其互相关系:

static struct s3c24xx_dma_order __initdata s3c2440_dma_order = {
	.channels	= {
		[DMACH_SDI]	= {
			.list	= {
				[0]	= 3 | DMA_CH_VALID,
				[1]	= 2 | DMA_CH_VALID,
				[2]	= 1 | DMA_CH_VALID,
				[3]	= 0 | DMA_CH_VALID,
			},
		},
		[DMACH_I2S_IN]	= {
			.list	= {
				[0]	= 1 | DMA_CH_VALID,
				[1]	= 2 | DMA_CH_VALID,
			},
		},
		......
	},
};
对于SDIO/MMC/SD,其DMA源有4个(上图红框),位于物理channel的0~3通道;同样,I2SSDI的DMA源有2个,位于通道0、1等等。

再来看s3c24xx_dma_order_set()函数:

int __init s3c24xx_dma_order_set(struct s3c24xx_dma_order *ord)
{
	struct s3c24xx_dma_order *nord = dma_order;

	if (nord == NULL)
		nord = kmalloc(sizeof(struct s3c24xx_dma_order), GFP_KERNEL);

	if (nord == NULL) {
		printk(KERN_ERR "no memory to store dma channel order\n");
		return -ENOMEM;
	}

	dma_order = nord;
	memcpy(nord, ord, sizeof(struct s3c24xx_dma_order));
	return 0;
}
还是很简单:为全局变量dma_order分配空间并把s3c2440_dma_order的内容copy过去,何必多此一举?

最后一个函数:

s3c24xx_dma_init_map(&s3c2440_dma_sel); 

int __init s3c24xx_dma_init_map(struct s3c24xx_dma_selection *sel)
{
	struct s3c24xx_dma_map *nmap;
	size_t map_sz = sizeof(*nmap) * sel->map_size;
	int ptr;

	nmap = kmalloc(map_sz, GFP_KERNEL);
	if (nmap == NULL)
		return -ENOMEM;

	memcpy(nmap, sel->map, map_sz);
	memcpy(&dma_sel, sel, sizeof(*sel));

	dma_sel.map = nmap;

	for (ptr = 0; ptr < sel->map_size; ptr++)
		s3c24xx_dma_check_entry(nmap+ptr, ptr);

	return 0;
}
s 3 c 2
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值