1 /* 2 * Copyright (C) 2010, Lars-Peter Clausen <lars@metafoo.de> 3 * JZ7420/JZ4740 DMA definitions 4 * 5 * This program is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License as published by the 7 * Free Software Foundation; either version 2 of the License, or (at your 8 * option) any later version. 9 * 10 * You should have received a copy of the GNU General Public License along 11 * with this program; if not, write to the Free Software Foundation, Inc., 12 * 675 Mass Ave, Cambridge, MA 02139, USA. 13 * 14 */ 15 16 #ifndef __ASM_MACH_JZ4740_DMA_H__ 17 #define __ASM_MACH_JZ4740_DMA_H__ 18 19 struct jz4740_dma_chan; 20 21 enum jz4740_dma_request_type { 22 JZ4740_DMA_TYPE_AUTO_REQUEST = 8, 23 JZ4740_DMA_TYPE_UART_TRANSMIT = 20, 24 JZ4740_DMA_TYPE_UART_RECEIVE = 21, 25 JZ4740_DMA_TYPE_SPI_TRANSMIT = 22, 26 JZ4740_DMA_TYPE_SPI_RECEIVE = 23, 27 JZ4740_DMA_TYPE_AIC_TRANSMIT = 24, 28 JZ4740_DMA_TYPE_AIC_RECEIVE = 25, 29 JZ4740_DMA_TYPE_MMC_TRANSMIT = 26, 30 JZ4740_DMA_TYPE_MMC_RECEIVE = 27, 31 JZ4740_DMA_TYPE_TCU = 28, 32 JZ4740_DMA_TYPE_SADC = 29, 33 JZ4740_DMA_TYPE_SLCD = 30, 34 }; 35 36 enum jz4740_dma_width { 37 JZ4740_DMA_WIDTH_32BIT = 0, 38 JZ4740_DMA_WIDTH_8BIT = 1, 39 JZ4740_DMA_WIDTH_16BIT = 2, 40 }; 41 42 enum jz4740_dma_transfer_size { 43 JZ4740_DMA_TRANSFER_SIZE_4BYTE = 0, 44 JZ4740_DMA_TRANSFER_SIZE_1BYTE = 1, 45 JZ4740_DMA_TRANSFER_SIZE_2BYTE = 2, 46 JZ4740_DMA_TRANSFER_SIZE_16BYTE = 3, 47 JZ4740_DMA_TRANSFER_SIZE_32BYTE = 4, 48 }; 49 50 enum jz4740_dma_flags { 51 JZ4740_DMA_SRC_AUTOINC = 0x2, 52 JZ4740_DMA_DST_AUTOINC = 0x1, 53 }; 54 55 enum jz4740_dma_mode { 56 JZ4740_DMA_MODE_SINGLE = 0, 57 JZ4740_DMA_MODE_BLOCK = 1, 58 }; 59 60 struct jz4740_dma_config { 61 enum jz4740_dma_width src_width; 62 enum jz4740_dma_width dst_width; 63 enum jz4740_dma_transfer_size transfer_size; 64 enum jz4740_dma_request_type request_type; 65 enum jz4740_dma_flags flags; 66 enum jz4740_dma_mode mode; 67 }; 68 69 typedef void (*jz4740_dma_complete_callback_t)(struct jz4740_dma_chan *, int, void *); 70 71 struct jz4740_dma_chan *jz4740_dma_request(void *dev, const char *name); 72 void jz4740_dma_free(struct jz4740_dma_chan *dma); 73 74 void jz4740_dma_configure(struct jz4740_dma_chan *dma, 75 const struct jz4740_dma_config *config); 76 77 78 void jz4740_dma_enable(struct jz4740_dma_chan *dma); 79 void jz4740_dma_disable(struct jz4740_dma_chan *dma); 80 81 void jz4740_dma_set_src_addr(struct jz4740_dma_chan *dma, dma_addr_t src); 82 void jz4740_dma_set_dst_addr(struct jz4740_dma_chan *dma, dma_addr_t dst); 83 void jz4740_dma_set_transfer_count(struct jz4740_dma_chan *dma, uint32_t count); 84 85 uint32_t jz4740_dma_get_residue(const struct jz4740_dma_chan *dma); 86 87 void jz4740_dma_set_complete_cb(struct jz4740_dma_chan *dma, 88 jz4740_dma_complete_callback_t cb); 89 90 #endif /* __ASM_JZ4740_DMA_H__ */ 91