pl330 dmac是基于arm amba的dma控制器,最多有8个操作通道,32个事件处理,并且有多个外设接口,有自己的命令集,详细信息看pl330 datesheet。
pl330驱动程序:
pl330驱动程序位于看kernel/driver/dma/pl330.c文件,该驱动程序由三星coder写的。
驱动的关键数据结构:
17 struct dma_pl330_platdata {
18 /*
19 * Number of valid peripherals connected to DMAC.
20 * This may be different from the value read from
21 * CR0, as the PL330 implementation might have 'holes'
22 * in the peri list or the peri could also be reached
23 * from another DMAC which the platform prefers.
24 */
25 u8 nr_valid_peri;
26 /* Array of valid peripherals */
27 u8 *peri_id;
28 /* Operational capabilities */
29 dma_cap_mask_t cap_mask;
30 /* Bytes to allocate for MC buffer */
31 unsigned mcbuf_sz; //dmac指令存储空间大小
32 };
该结构体是pl330的平台数据,用于声明具体soc上的pl330 dmac的配置,一般通过amba device的设备平台数据传入。
577 struct dma_pl330_dmac {
578 struct pl330_info pif;
579
580 /* DMA-Engine Device */
581 struct dma_device ddma;
582
583 /* Pool of descriptors available for the DMAC's channels */
584 struct list_head desc_pool;
585 /* To protect desc_pool manipulation */
586 spinlock_t pool_lock;
587
588 /* Peripheral channels connected to this DMAC */
589 struct dma_pl330_chan *peripherals; /* keep at end */
590 };
该结构体是pl330 dmac的抽象,封装了dma引擎结构体,是更高层的抽象,内部包含了 struct dma_device ddma (dma引擎对象),struct pl330_info pif(pl330的信息),struct list_head desc_pool(dmac通道的执行描述池链表)
/* Handle to the DMAC provided to the PL330 core */
308 struct pl330_info {
309 /* Owning device */
310 struct device *dev;
311 /* Size of MicroCode buffers for each channel. */
312 unsigned mcbufsz;
313 /* ioremap'ed address of PL330 registers. */
314 void __iomem *base;
315 /* Client can freely use it. */
316 void *client_data;
317 /* PL330 core data, Client must not touch it. */
318 void *pl330_data;
319 /* Populated by the PL330 core driver during pl330_add */
320 struct pl330_config pcfg;
321 /*
322 * If the DMAC has some reset mechanism, then the
323 * client may want to provide pointer to the method.
324 */
325 void (*dmac_reset)(struct pl330_info *pi);
326 };
该结构体是pl330中十分重要的数据,包含了pl330 dmac的硬件信息,包括unsigned mcbufsz(每个通道的指令集缓存大小), void __iomem *base(pl330 dmac寄存器基址),void *pl330_data(pl330 驱动使用数据),struct pl330_config pcfg(pl330 dmac配置信息,一般通过读dmac寄存器获取), void (*dmac_reset)(struct pl330_info *pi)(dmac复位操作函数,用来指定特定的复位操作)