1 /* 2 * drivers/usb/sunxi_usb/udc/sunxi_udc_dma.h 3 * (C) Copyright 2010-2015 4 * Allwinner Technology Co., Ltd. <www.allwinnertech.com> 5 * javen, 2010-3-3, create this file 6 * 7 * udc dma ops. 8 * 9 * This program is free software; you can redistribute it and/or 10 * modify it under the terms of the GNU General Public License as 11 * published by the Free Software Foundation; either version 2 of 12 * the License, or (at your option) any later version. 13 * 14 */ 15 16 #ifndef __SUNXI_UDC_DMA_H__ 17 #define __SUNXI_UDC_DMA_H__ 18 19 #ifdef SW_UDC_DMA 20 #define is_udc_support_dma() 1 21 #else 22 #define is_udc_support_dma() 0 23 #endif 24 25 /* dma channel total */ 26 #define DMA_CHAN_TOTAL (8) 27 typedef int *dm_hdl_t; 28 29 /* define dma channel struct */ 30 typedef struct { 31 u32 used; /* 1 used, 0 unuse */ 32 u32 channel_num; 33 u32 ep_num; /* the ep's index in sunxi_udc.ep[] */ 34 void __iomem *reg_base; /* regs base addr */ 35 spinlock_t lock; /* dma channel lock */ 36 } dma_channel_t; 37 38 extern dma_channel_t dma_chnl[DMA_CHAN_TOTAL]; 39 40 /* dma config information */ 41 struct dma_config_t { 42 spinlock_t lock; /* dma channel lock */ 43 u32 dma_num; 44 u32 dma_working; 45 u32 dma_en; 46 u32 dma_bst_len; 47 u32 dma_dir; 48 u32 dma_for_ep; 49 u32 dma_sdram_str_addr; 50 u32 dma_bc; 51 u32 dma_residual_bc; 52 }; 53 54 extern int g_dma_debug; 55 56 void sunxi_udc_switch_bus_to_dma(struct sunxi_udc_ep *ep, u32 is_tx); 57 void sunxi_udc_switch_bus_to_pio(struct sunxi_udc_ep *ep, __u32 is_tx); 58 59 void sunxi_udc_enable_dma_channel_irq(struct sunxi_udc_ep *ep); 60 void sunxi_udc_disable_dma_channel_irq(struct sunxi_udc_ep *ep); 61 void sunxi_dma_set_config(dm_hdl_t dma_hdl, struct dma_config_t *pcfg); 62 dm_hdl_t sunxi_udc_dma_request(void); 63 int sunxi_udc_dma_release(dm_hdl_t dma_hdl); 64 int sunxi_udc_dma_chan_disable(dm_hdl_t dma_hdl); 65 void sunxi_udc_dma_set_config(struct sunxi_udc_ep *ep, 66 struct sunxi_udc_request *req, __u32 buff_addr, __u32 len); 67 void sunxi_udc_dma_start(struct sunxi_udc_ep *ep, 68 void __iomem *fifo, __u32 buffer, __u32 len); 69 void sunxi_udc_dma_stop(struct sunxi_udc_ep *ep); 70 __u32 sunxi_udc_dma_transmit_length(struct sunxi_udc_ep *ep); 71 __u32 sunxi_udc_dma_is_busy(struct sunxi_udc_ep *ep); 72 void sunxi_udc_dma_completion(struct sunxi_udc *dev, 73 struct sunxi_udc_ep *ep, struct sunxi_udc_request *req); 74 75 __s32 sunxi_udc_dma_probe(struct sunxi_udc *dev); 76 __s32 sunxi_udc_dma_remove(struct sunxi_udc *dev); 77 78 #endif /* __SUNXI_UDC_DMA_H__ */ 79 80