2 * Copyright (C) 2007-2013 ST-Ericsson
3 * License terms: GNU General Public License (GPL) version 2
4 * DMA driver for COH 901 318
5 * Author: Per Friden <per.friden@stericsson.com>
11 #define MAX_DMA_PACKET_SIZE_SHIFT 11
12 #define MAX_DMA_PACKET_SIZE (1 << MAX_DMA_PACKET_SIZE_SHIFT)
16 struct coh901318_pool {
18 struct dma_pool *dmapool;
21 #ifdef CONFIG_DEBUG_FS
22 int debugfs_pool_counter;
27 * struct coh901318_lli - linked list item for DMAC
28 * @control: control settings for DMAC
29 * @src_addr: transfer source address
30 * @dst_addr: transfer destination address
31 * @link_addr: physical address to next lli
32 * @virt_link_addr: virtual address of next lli (only used by pool_free)
33 * @phy_this: physical address of current lli (only used by pool_free)
35 struct coh901318_lli {
46 * coh901318_pool_create() - Creates an dma pool for lli:s
49 * @lli_nbr: number of lli:s in the pool
50 * @algin: address alignemtn of lli:s
51 * returns 0 on success otherwise none zero
53 int coh901318_pool_create(struct coh901318_pool *pool,
55 size_t lli_nbr, size_t align);
58 * coh901318_pool_destroy() - Destroys the dma pool
60 * returns 0 on success otherwise none zero
62 int coh901318_pool_destroy(struct coh901318_pool *pool);
65 * coh901318_lli_alloc() - Allocates a linked list
68 * @len: length to list
69 * return: none NULL if success otherwise NULL
71 struct coh901318_lli *
72 coh901318_lli_alloc(struct coh901318_pool *pool,
76 * coh901318_lli_free() - Returns the linked list items to the pool
78 * @lli: reference to lli pointer to be freed
80 void coh901318_lli_free(struct coh901318_pool *pool,
81 struct coh901318_lli **lli);
84 * coh901318_lli_fill_memcpy() - Prepares the lli:s for dma memcpy
88 * @size: transfer size
89 * @dst: destination address
90 * @ctrl_chained: ctrl for chained lli
91 * @ctrl_last: ctrl for the last lli
92 * returns number of CPU interrupts for the lli, negative on error.
95 coh901318_lli_fill_memcpy(struct coh901318_pool *pool,
96 struct coh901318_lli *lli,
97 dma_addr_t src, unsigned int size,
98 dma_addr_t dst, u32 ctrl_chained, u32 ctrl_last);
101 * coh901318_lli_fill_single() - Prepares the lli:s for dma single transfer
103 * @lli: allocated lli
104 * @buf: transfer buffer
105 * @size: transfer size
106 * @dev_addr: address of periphal
107 * @ctrl_chained: ctrl for chained lli
108 * @ctrl_last: ctrl for the last lli
109 * @dir: direction of transfer (to or from device)
110 * returns number of CPU interrupts for the lli, negative on error.
113 coh901318_lli_fill_single(struct coh901318_pool *pool,
114 struct coh901318_lli *lli,
115 dma_addr_t buf, unsigned int size,
116 dma_addr_t dev_addr, u32 ctrl_chained, u32 ctrl_last,
117 enum dma_transfer_direction dir);
120 * coh901318_lli_fill_single() - Prepares the lli:s for dma scatter list transfer
122 * @lli: allocated lli
123 * @sg: scatter gather list
124 * @nents: number of entries in sg
125 * @dev_addr: address of periphal
126 * @ctrl_chained: ctrl for chained lli
127 * @ctrl: ctrl of middle lli
128 * @ctrl_last: ctrl for the last lli
129 * @dir: direction of transfer (to or from device)
130 * @ctrl_irq_mask: ctrl mask for CPU interrupt
131 * returns number of CPU interrupts for the lli, negative on error.
134 coh901318_lli_fill_sg(struct coh901318_pool *pool,
135 struct coh901318_lli *lli,
136 struct scatterlist *sg, unsigned int nents,
137 dma_addr_t dev_addr, u32 ctrl_chained,
138 u32 ctrl, u32 ctrl_last,
139 enum dma_transfer_direction dir, u32 ctrl_irq_mask);
141 #endif /* COH901318_H */