Path: blob/master/arch/arm/mach-davinci/include/mach/edma.h
17633 views
/*1* TI DAVINCI dma definitions2*3* Copyright (C) 2006-2009 Texas Instruments.4*5* This program is free software; you can redistribute it and/or modify it6* under the terms of the GNU General Public License as published by the7* Free Software Foundation; either version 2 of the License, or (at your8* option) any later version.9*10* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED11* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF12* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN13* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,14* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT15* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF16* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON17* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT18* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF19* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.20*21* You should have received a copy of the GNU General Public License along22* with this program; if not, write to the Free Software Foundation, Inc.,23* 675 Mass Ave, Cambridge, MA 02139, USA.24*25*/2627/*28* This EDMA3 programming framework exposes two basic kinds of resource:29*30* Channel Triggers transfers, usually from a hardware event but31* also manually or by "chaining" from DMA completions.32* Each channel is coupled to a Parameter RAM (PaRAM) slot.33*34* Slot Each PaRAM slot holds a DMA transfer descriptor (PaRAM35* "set"), source and destination addresses, a link to a36* next PaRAM slot (if any), options for the transfer, and37* instructions for updating those addresses. There are38* more than twice as many slots as event channels.39*40* Each PaRAM set describes a sequence of transfers, either for one large41* buffer or for several discontiguous smaller buffers. An EDMA transfer42* is driven only from a channel, which performs the transfers specified43* in its PaRAM slot until there are no more transfers. When that last44* transfer completes, the "link" field may be used to reload the channel's45* PaRAM slot with a new transfer descriptor.46*47* The EDMA Channel Controller (CC) maps requests from channels into physical48* Transfer Controller (TC) requests when the channel triggers (by hardware49* or software events, or by chaining). The two physical DMA channels provided50* by the TCs are thus shared by many logical channels.51*52* DaVinci hardware also has a "QDMA" mechanism which is not currently53* supported through this interface. (DSP firmware uses it though.)54*/5556#ifndef EDMA_H_57#define EDMA_H_5859/* PaRAM slots are laid out like this */60struct edmacc_param {61unsigned int opt;62unsigned int src;63unsigned int a_b_cnt;64unsigned int dst;65unsigned int src_dst_bidx;66unsigned int link_bcntrld;67unsigned int src_dst_cidx;68unsigned int ccnt;69};7071#define CCINT0_INTERRUPT 1672#define CCERRINT_INTERRUPT 1773#define TCERRINT0_INTERRUPT 1874#define TCERRINT1_INTERRUPT 197576/* fields in edmacc_param.opt */77#define SAM BIT(0)78#define DAM BIT(1)79#define SYNCDIM BIT(2)80#define STATIC BIT(3)81#define EDMA_FWID (0x07 << 8)82#define TCCMODE BIT(11)83#define EDMA_TCC(t) ((t) << 12)84#define TCINTEN BIT(20)85#define ITCINTEN BIT(21)86#define TCCHEN BIT(22)87#define ITCCHEN BIT(23)8889#define TRWORD (0x7<<2)90#define PAENTRY (0x1ff<<5)9192/* Drivers should avoid using these symbolic names for dm644x93* channels, and use platform_device IORESOURCE_DMA resources94* instead. (Other DaVinci chips have different peripherals95* and thus have different DMA channel mappings.)96*/97#define DAVINCI_DMA_MCBSP_TX 298#define DAVINCI_DMA_MCBSP_RX 399#define DAVINCI_DMA_VPSS_HIST 4100#define DAVINCI_DMA_VPSS_H3A 5101#define DAVINCI_DMA_VPSS_PRVU 6102#define DAVINCI_DMA_VPSS_RSZ 7103#define DAVINCI_DMA_IMCOP_IMXINT 8104#define DAVINCI_DMA_IMCOP_VLCDINT 9105#define DAVINCI_DMA_IMCO_PASQINT 10106#define DAVINCI_DMA_IMCOP_DSQINT 11107#define DAVINCI_DMA_SPI_SPIX 16108#define DAVINCI_DMA_SPI_SPIR 17109#define DAVINCI_DMA_UART0_URXEVT0 18110#define DAVINCI_DMA_UART0_UTXEVT0 19111#define DAVINCI_DMA_UART1_URXEVT1 20112#define DAVINCI_DMA_UART1_UTXEVT1 21113#define DAVINCI_DMA_UART2_URXEVT2 22114#define DAVINCI_DMA_UART2_UTXEVT2 23115#define DAVINCI_DMA_MEMSTK_MSEVT 24116#define DAVINCI_DMA_MMCRXEVT 26117#define DAVINCI_DMA_MMCTXEVT 27118#define DAVINCI_DMA_I2C_ICREVT 28119#define DAVINCI_DMA_I2C_ICXEVT 29120#define DAVINCI_DMA_GPIO_GPINT0 32121#define DAVINCI_DMA_GPIO_GPINT1 33122#define DAVINCI_DMA_GPIO_GPINT2 34123#define DAVINCI_DMA_GPIO_GPINT3 35124#define DAVINCI_DMA_GPIO_GPINT4 36125#define DAVINCI_DMA_GPIO_GPINT5 37126#define DAVINCI_DMA_GPIO_GPINT6 38127#define DAVINCI_DMA_GPIO_GPINT7 39128#define DAVINCI_DMA_GPIO_GPBNKINT0 40129#define DAVINCI_DMA_GPIO_GPBNKINT1 41130#define DAVINCI_DMA_GPIO_GPBNKINT2 42131#define DAVINCI_DMA_GPIO_GPBNKINT3 43132#define DAVINCI_DMA_GPIO_GPBNKINT4 44133#define DAVINCI_DMA_TIMER0_TINT0 48134#define DAVINCI_DMA_TIMER1_TINT1 49135#define DAVINCI_DMA_TIMER2_TINT2 50136#define DAVINCI_DMA_TIMER3_TINT3 51137#define DAVINCI_DMA_PWM0 52138#define DAVINCI_DMA_PWM1 53139#define DAVINCI_DMA_PWM2 54140141/* DA830 specific EDMA3 information */142#define EDMA_DA830_NUM_DMACH 32143#define EDMA_DA830_NUM_TCC 32144#define EDMA_DA830_NUM_PARAMENTRY 128145#define EDMA_DA830_NUM_EVQUE 2146#define EDMA_DA830_NUM_TC 2147#define EDMA_DA830_CHMAP_EXIST 0148#define EDMA_DA830_NUM_REGIONS 4149#define DA830_DMACH2EVENT_MAP0 0x000FC03Fu150#define DA830_DMACH2EVENT_MAP1 0x00000000u151#define DA830_EDMA_ARM_OWN 0x30FFCCFFu152153/*ch_status paramater of callback function possible values*/154#define DMA_COMPLETE 1155#define DMA_CC_ERROR 2156#define DMA_TC1_ERROR 3157#define DMA_TC2_ERROR 4158159enum address_mode {160INCR = 0,161FIFO = 1162};163164enum fifo_width {165W8BIT = 0,166W16BIT = 1,167W32BIT = 2,168W64BIT = 3,169W128BIT = 4,170W256BIT = 5171};172173enum dma_event_q {174EVENTQ_0 = 0,175EVENTQ_1 = 1,176EVENTQ_2 = 2,177EVENTQ_3 = 3,178EVENTQ_DEFAULT = -1179};180181enum sync_dimension {182ASYNC = 0,183ABSYNC = 1184};185186#define EDMA_CTLR_CHAN(ctlr, chan) (((ctlr) << 16) | (chan))187#define EDMA_CTLR(i) ((i) >> 16)188#define EDMA_CHAN_SLOT(i) ((i) & 0xffff)189190#define EDMA_CHANNEL_ANY -1 /* for edma_alloc_channel() */191#define EDMA_SLOT_ANY -1 /* for edma_alloc_slot() */192#define EDMA_CONT_PARAMS_ANY 1001193#define EDMA_CONT_PARAMS_FIXED_EXACT 1002194#define EDMA_CONT_PARAMS_FIXED_NOT_EXACT 1003195196#define EDMA_MAX_CC 2197198/* alloc/free DMA channels and their dedicated parameter RAM slots */199int edma_alloc_channel(int channel,200void (*callback)(unsigned channel, u16 ch_status, void *data),201void *data, enum dma_event_q);202void edma_free_channel(unsigned channel);203204/* alloc/free parameter RAM slots */205int edma_alloc_slot(unsigned ctlr, int slot);206void edma_free_slot(unsigned slot);207208/* alloc/free a set of contiguous parameter RAM slots */209int edma_alloc_cont_slots(unsigned ctlr, unsigned int id, int slot, int count);210int edma_free_cont_slots(unsigned slot, int count);211212/* calls that operate on part of a parameter RAM slot */213void edma_set_src(unsigned slot, dma_addr_t src_port,214enum address_mode mode, enum fifo_width);215void edma_set_dest(unsigned slot, dma_addr_t dest_port,216enum address_mode mode, enum fifo_width);217void edma_get_position(unsigned slot, dma_addr_t *src, dma_addr_t *dst);218void edma_set_src_index(unsigned slot, s16 src_bidx, s16 src_cidx);219void edma_set_dest_index(unsigned slot, s16 dest_bidx, s16 dest_cidx);220void edma_set_transfer_params(unsigned slot, u16 acnt, u16 bcnt, u16 ccnt,221u16 bcnt_rld, enum sync_dimension sync_mode);222void edma_link(unsigned from, unsigned to);223void edma_unlink(unsigned from);224225/* calls that operate on an entire parameter RAM slot */226void edma_write_slot(unsigned slot, const struct edmacc_param *params);227void edma_read_slot(unsigned slot, struct edmacc_param *params);228229/* channel control operations */230int edma_start(unsigned channel);231void edma_stop(unsigned channel);232void edma_clean_channel(unsigned channel);233void edma_clear_event(unsigned channel);234void edma_pause(unsigned channel);235void edma_resume(unsigned channel);236237struct edma_rsv_info {238239const s16 (*rsv_chans)[2];240const s16 (*rsv_slots)[2];241};242243/* platform_data for EDMA driver */244struct edma_soc_info {245246/* how many dma resources of each type */247unsigned n_channel;248unsigned n_region;249unsigned n_slot;250unsigned n_tc;251unsigned n_cc;252enum dma_event_q default_queue;253254/* Resource reservation for other cores */255struct edma_rsv_info *rsv;256257const s8 (*queue_tc_mapping)[2];258const s8 (*queue_priority_mapping)[2];259};260261#endif262263264