1384740dcSRalf Baechle /* 2384740dcSRalf Baechle * 3384740dcSRalf Baechle * BRIEF MODULE DESCRIPTION 4384740dcSRalf Baechle * Include file for Alchemy Semiconductor's Au1550 Descriptor 5384740dcSRalf Baechle * Based DMA Controller. 6384740dcSRalf Baechle * 7384740dcSRalf Baechle * Copyright 2004 Embedded Edge, LLC 8384740dcSRalf Baechle * dan@embeddededge.com 9384740dcSRalf Baechle * 10384740dcSRalf Baechle * This program is free software; you can redistribute it and/or modify it 11384740dcSRalf Baechle * under the terms of the GNU General Public License as published by the 12384740dcSRalf Baechle * Free Software Foundation; either version 2 of the License, or (at your 13384740dcSRalf Baechle * option) any later version. 14384740dcSRalf Baechle * 15384740dcSRalf Baechle * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 16384740dcSRalf Baechle * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 17384740dcSRalf Baechle * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN 18384740dcSRalf Baechle * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19384740dcSRalf Baechle * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20384740dcSRalf Baechle * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 21384740dcSRalf Baechle * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 22384740dcSRalf Baechle * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23384740dcSRalf Baechle * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24384740dcSRalf Baechle * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25384740dcSRalf Baechle * 26384740dcSRalf Baechle * You should have received a copy of the GNU General Public License along 27384740dcSRalf Baechle * with this program; if not, write to the Free Software Foundation, Inc., 28384740dcSRalf Baechle * 675 Mass Ave, Cambridge, MA 02139, USA. 29384740dcSRalf Baechle */ 30384740dcSRalf Baechle 31384740dcSRalf Baechle /* 32384740dcSRalf Baechle * Specifics for the Au1xxx Descriptor-Based DMA Controller, 33384740dcSRalf Baechle * first seen in the AU1550 part. 34384740dcSRalf Baechle */ 35384740dcSRalf Baechle #ifndef _AU1000_DBDMA_H_ 36384740dcSRalf Baechle #define _AU1000_DBDMA_H_ 37384740dcSRalf Baechle 38384740dcSRalf Baechle #ifndef _LANGUAGE_ASSEMBLY 39384740dcSRalf Baechle 40384740dcSRalf Baechle /* 41384740dcSRalf Baechle * The DMA base addresses. 42384740dcSRalf Baechle * The channels are every 256 bytes (0x0100) from the channel 0 base. 43384740dcSRalf Baechle * Interrupt status/enable is bits 15:0 for channels 15 to zero. 44384740dcSRalf Baechle */ 45384740dcSRalf Baechle #define DDMA_GLOBAL_BASE 0xb4003000 46384740dcSRalf Baechle #define DDMA_CHANNEL_BASE 0xb4002000 47384740dcSRalf Baechle 48384740dcSRalf Baechle typedef volatile struct dbdma_global { 49384740dcSRalf Baechle u32 ddma_config; 50384740dcSRalf Baechle u32 ddma_intstat; 51384740dcSRalf Baechle u32 ddma_throttle; 52384740dcSRalf Baechle u32 ddma_inten; 53384740dcSRalf Baechle } dbdma_global_t; 54384740dcSRalf Baechle 55384740dcSRalf Baechle /* General Configuration. */ 56384740dcSRalf Baechle #define DDMA_CONFIG_AF (1 << 2) 57384740dcSRalf Baechle #define DDMA_CONFIG_AH (1 << 1) 58384740dcSRalf Baechle #define DDMA_CONFIG_AL (1 << 0) 59384740dcSRalf Baechle 60384740dcSRalf Baechle #define DDMA_THROTTLE_EN (1 << 31) 61384740dcSRalf Baechle 62384740dcSRalf Baechle /* The structure of a DMA Channel. */ 63384740dcSRalf Baechle typedef volatile struct au1xxx_dma_channel { 64384740dcSRalf Baechle u32 ddma_cfg; /* See below */ 65384740dcSRalf Baechle u32 ddma_desptr; /* 32-byte aligned pointer to descriptor */ 66384740dcSRalf Baechle u32 ddma_statptr; /* word aligned pointer to status word */ 67384740dcSRalf Baechle u32 ddma_dbell; /* A write activates channel operation */ 68384740dcSRalf Baechle u32 ddma_irq; /* If bit 0 set, interrupt pending */ 69384740dcSRalf Baechle u32 ddma_stat; /* See below */ 70384740dcSRalf Baechle u32 ddma_bytecnt; /* Byte count, valid only when chan idle */ 71384740dcSRalf Baechle /* Remainder, up to the 256 byte boundary, is reserved. */ 72384740dcSRalf Baechle } au1x_dma_chan_t; 73384740dcSRalf Baechle 74384740dcSRalf Baechle #define DDMA_CFG_SED (1 << 9) /* source DMA level/edge detect */ 75384740dcSRalf Baechle #define DDMA_CFG_SP (1 << 8) /* source DMA polarity */ 76384740dcSRalf Baechle #define DDMA_CFG_DED (1 << 7) /* destination DMA level/edge detect */ 77384740dcSRalf Baechle #define DDMA_CFG_DP (1 << 6) /* destination DMA polarity */ 78384740dcSRalf Baechle #define DDMA_CFG_SYNC (1 << 5) /* Sync static bus controller */ 79384740dcSRalf Baechle #define DDMA_CFG_PPR (1 << 4) /* PCI posted read/write control */ 80384740dcSRalf Baechle #define DDMA_CFG_DFN (1 << 3) /* Descriptor fetch non-coherent */ 81384740dcSRalf Baechle #define DDMA_CFG_SBE (1 << 2) /* Source big endian */ 82384740dcSRalf Baechle #define DDMA_CFG_DBE (1 << 1) /* Destination big endian */ 83384740dcSRalf Baechle #define DDMA_CFG_EN (1 << 0) /* Channel enable */ 84384740dcSRalf Baechle 85384740dcSRalf Baechle /* 86384740dcSRalf Baechle * Always set when descriptor processing done, regardless of 87384740dcSRalf Baechle * interrupt enable state. Reflected in global intstat, don't 88384740dcSRalf Baechle * clear this until global intstat is read/used. 89384740dcSRalf Baechle */ 90384740dcSRalf Baechle #define DDMA_IRQ_IN (1 << 0) 91384740dcSRalf Baechle 92384740dcSRalf Baechle #define DDMA_STAT_DB (1 << 2) /* Doorbell pushed */ 93384740dcSRalf Baechle #define DDMA_STAT_V (1 << 1) /* Descriptor valid */ 94384740dcSRalf Baechle #define DDMA_STAT_H (1 << 0) /* Channel Halted */ 95384740dcSRalf Baechle 96384740dcSRalf Baechle /* 97384740dcSRalf Baechle * "Standard" DDMA Descriptor. 98384740dcSRalf Baechle * Must be 32-byte aligned. 99384740dcSRalf Baechle */ 100384740dcSRalf Baechle typedef volatile struct au1xxx_ddma_desc { 101384740dcSRalf Baechle u32 dscr_cmd0; /* See below */ 102384740dcSRalf Baechle u32 dscr_cmd1; /* See below */ 103384740dcSRalf Baechle u32 dscr_source0; /* source phys address */ 104384740dcSRalf Baechle u32 dscr_source1; /* See below */ 105384740dcSRalf Baechle u32 dscr_dest0; /* Destination address */ 106384740dcSRalf Baechle u32 dscr_dest1; /* See below */ 107384740dcSRalf Baechle u32 dscr_stat; /* completion status */ 108384740dcSRalf Baechle u32 dscr_nxtptr; /* Next descriptor pointer (mostly) */ 109384740dcSRalf Baechle /* 110384740dcSRalf Baechle * First 32 bytes are HW specific!!! 111384740dcSRalf Baechle * Lets have some SW data following -- make sure it's 32 bytes. 112384740dcSRalf Baechle */ 113384740dcSRalf Baechle u32 sw_status; 114384740dcSRalf Baechle u32 sw_context; 115384740dcSRalf Baechle u32 sw_reserved[6]; 116384740dcSRalf Baechle } au1x_ddma_desc_t; 117384740dcSRalf Baechle 118384740dcSRalf Baechle #define DSCR_CMD0_V (1 << 31) /* Descriptor valid */ 119384740dcSRalf Baechle #define DSCR_CMD0_MEM (1 << 30) /* mem-mem transfer */ 120384740dcSRalf Baechle #define DSCR_CMD0_SID_MASK (0x1f << 25) /* Source ID */ 121384740dcSRalf Baechle #define DSCR_CMD0_DID_MASK (0x1f << 20) /* Destination ID */ 122384740dcSRalf Baechle #define DSCR_CMD0_SW_MASK (0x3 << 18) /* Source Width */ 123384740dcSRalf Baechle #define DSCR_CMD0_DW_MASK (0x3 << 16) /* Destination Width */ 124384740dcSRalf Baechle #define DSCR_CMD0_ARB (0x1 << 15) /* Set for Hi Pri */ 125384740dcSRalf Baechle #define DSCR_CMD0_DT_MASK (0x3 << 13) /* Descriptor Type */ 126384740dcSRalf Baechle #define DSCR_CMD0_SN (0x1 << 12) /* Source non-coherent */ 127384740dcSRalf Baechle #define DSCR_CMD0_DN (0x1 << 11) /* Destination non-coherent */ 128384740dcSRalf Baechle #define DSCR_CMD0_SM (0x1 << 10) /* Stride mode */ 129384740dcSRalf Baechle #define DSCR_CMD0_IE (0x1 << 8) /* Interrupt Enable */ 130384740dcSRalf Baechle #define DSCR_CMD0_SP (0x1 << 4) /* Status pointer select */ 131384740dcSRalf Baechle #define DSCR_CMD0_CV (0x1 << 2) /* Clear Valid when done */ 132384740dcSRalf Baechle #define DSCR_CMD0_ST_MASK (0x3 << 0) /* Status instruction */ 133384740dcSRalf Baechle 134384740dcSRalf Baechle #define SW_STATUS_INUSE (1 << 0) 135384740dcSRalf Baechle 136384740dcSRalf Baechle /* Command 0 device IDs. */ 137384740dcSRalf Baechle #ifdef CONFIG_SOC_AU1550 138384740dcSRalf Baechle #define DSCR_CMD0_UART0_TX 0 139384740dcSRalf Baechle #define DSCR_CMD0_UART0_RX 1 140384740dcSRalf Baechle #define DSCR_CMD0_UART3_TX 2 141384740dcSRalf Baechle #define DSCR_CMD0_UART3_RX 3 142384740dcSRalf Baechle #define DSCR_CMD0_DMA_REQ0 4 143384740dcSRalf Baechle #define DSCR_CMD0_DMA_REQ1 5 144384740dcSRalf Baechle #define DSCR_CMD0_DMA_REQ2 6 145384740dcSRalf Baechle #define DSCR_CMD0_DMA_REQ3 7 146384740dcSRalf Baechle #define DSCR_CMD0_USBDEV_RX0 8 147384740dcSRalf Baechle #define DSCR_CMD0_USBDEV_TX0 9 148384740dcSRalf Baechle #define DSCR_CMD0_USBDEV_TX1 10 149384740dcSRalf Baechle #define DSCR_CMD0_USBDEV_TX2 11 150384740dcSRalf Baechle #define DSCR_CMD0_USBDEV_RX3 12 151384740dcSRalf Baechle #define DSCR_CMD0_USBDEV_RX4 13 152384740dcSRalf Baechle #define DSCR_CMD0_PSC0_TX 14 153384740dcSRalf Baechle #define DSCR_CMD0_PSC0_RX 15 154384740dcSRalf Baechle #define DSCR_CMD0_PSC1_TX 16 155384740dcSRalf Baechle #define DSCR_CMD0_PSC1_RX 17 156384740dcSRalf Baechle #define DSCR_CMD0_PSC2_TX 18 157384740dcSRalf Baechle #define DSCR_CMD0_PSC2_RX 19 158384740dcSRalf Baechle #define DSCR_CMD0_PSC3_TX 20 159384740dcSRalf Baechle #define DSCR_CMD0_PSC3_RX 21 160384740dcSRalf Baechle #define DSCR_CMD0_PCI_WRITE 22 161384740dcSRalf Baechle #define DSCR_CMD0_NAND_FLASH 23 162384740dcSRalf Baechle #define DSCR_CMD0_MAC0_RX 24 163384740dcSRalf Baechle #define DSCR_CMD0_MAC0_TX 25 164384740dcSRalf Baechle #define DSCR_CMD0_MAC1_RX 26 165384740dcSRalf Baechle #define DSCR_CMD0_MAC1_TX 27 166384740dcSRalf Baechle #endif /* CONFIG_SOC_AU1550 */ 167384740dcSRalf Baechle 168384740dcSRalf Baechle #ifdef CONFIG_SOC_AU1200 169384740dcSRalf Baechle #define DSCR_CMD0_UART0_TX 0 170384740dcSRalf Baechle #define DSCR_CMD0_UART0_RX 1 171384740dcSRalf Baechle #define DSCR_CMD0_UART1_TX 2 172384740dcSRalf Baechle #define DSCR_CMD0_UART1_RX 3 173384740dcSRalf Baechle #define DSCR_CMD0_DMA_REQ0 4 174384740dcSRalf Baechle #define DSCR_CMD0_DMA_REQ1 5 175384740dcSRalf Baechle #define DSCR_CMD0_MAE_BE 6 176384740dcSRalf Baechle #define DSCR_CMD0_MAE_FE 7 177384740dcSRalf Baechle #define DSCR_CMD0_SDMS_TX0 8 178384740dcSRalf Baechle #define DSCR_CMD0_SDMS_RX0 9 179384740dcSRalf Baechle #define DSCR_CMD0_SDMS_TX1 10 180384740dcSRalf Baechle #define DSCR_CMD0_SDMS_RX1 11 181384740dcSRalf Baechle #define DSCR_CMD0_AES_TX 13 182384740dcSRalf Baechle #define DSCR_CMD0_AES_RX 12 183384740dcSRalf Baechle #define DSCR_CMD0_PSC0_TX 14 184384740dcSRalf Baechle #define DSCR_CMD0_PSC0_RX 15 185384740dcSRalf Baechle #define DSCR_CMD0_PSC1_TX 16 186384740dcSRalf Baechle #define DSCR_CMD0_PSC1_RX 17 187384740dcSRalf Baechle #define DSCR_CMD0_CIM_RXA 18 188384740dcSRalf Baechle #define DSCR_CMD0_CIM_RXB 19 189384740dcSRalf Baechle #define DSCR_CMD0_CIM_RXC 20 190384740dcSRalf Baechle #define DSCR_CMD0_MAE_BOTH 21 191384740dcSRalf Baechle #define DSCR_CMD0_LCD 22 192384740dcSRalf Baechle #define DSCR_CMD0_NAND_FLASH 23 193384740dcSRalf Baechle #define DSCR_CMD0_PSC0_SYNC 24 194384740dcSRalf Baechle #define DSCR_CMD0_PSC1_SYNC 25 195384740dcSRalf Baechle #define DSCR_CMD0_CIM_SYNC 26 196384740dcSRalf Baechle #endif /* CONFIG_SOC_AU1200 */ 197384740dcSRalf Baechle 198384740dcSRalf Baechle #define DSCR_CMD0_THROTTLE 30 199384740dcSRalf Baechle #define DSCR_CMD0_ALWAYS 31 200384740dcSRalf Baechle #define DSCR_NDEV_IDS 32 201384740dcSRalf Baechle /* This macro is used to find/create custom device types */ 202384740dcSRalf Baechle #define DSCR_DEV2CUSTOM_ID(x, d) (((((x) & 0xFFFF) << 8) | 0x32000000) | \ 203384740dcSRalf Baechle ((d) & 0xFF)) 204384740dcSRalf Baechle #define DSCR_CUSTOM2DEV_ID(x) ((x) & 0xFF) 205384740dcSRalf Baechle 206384740dcSRalf Baechle #define DSCR_CMD0_SID(x) (((x) & 0x1f) << 25) 207384740dcSRalf Baechle #define DSCR_CMD0_DID(x) (((x) & 0x1f) << 20) 208384740dcSRalf Baechle 209384740dcSRalf Baechle /* Source/Destination transfer width. */ 210384740dcSRalf Baechle #define DSCR_CMD0_BYTE 0 211384740dcSRalf Baechle #define DSCR_CMD0_HALFWORD 1 212384740dcSRalf Baechle #define DSCR_CMD0_WORD 2 213384740dcSRalf Baechle 214384740dcSRalf Baechle #define DSCR_CMD0_SW(x) (((x) & 0x3) << 18) 215384740dcSRalf Baechle #define DSCR_CMD0_DW(x) (((x) & 0x3) << 16) 216384740dcSRalf Baechle 217384740dcSRalf Baechle /* DDMA Descriptor Type. */ 218384740dcSRalf Baechle #define DSCR_CMD0_STANDARD 0 219384740dcSRalf Baechle #define DSCR_CMD0_LITERAL 1 220384740dcSRalf Baechle #define DSCR_CMD0_CMP_BRANCH 2 221384740dcSRalf Baechle 222384740dcSRalf Baechle #define DSCR_CMD0_DT(x) (((x) & 0x3) << 13) 223384740dcSRalf Baechle 224384740dcSRalf Baechle /* Status Instruction. */ 225384740dcSRalf Baechle #define DSCR_CMD0_ST_NOCHANGE 0 /* Don't change */ 226384740dcSRalf Baechle #define DSCR_CMD0_ST_CURRENT 1 /* Write current status */ 227384740dcSRalf Baechle #define DSCR_CMD0_ST_CMD0 2 /* Write cmd0 with V cleared */ 228384740dcSRalf Baechle #define DSCR_CMD0_ST_BYTECNT 3 /* Write remaining byte count */ 229384740dcSRalf Baechle 230384740dcSRalf Baechle #define DSCR_CMD0_ST(x) (((x) & 0x3) << 0) 231384740dcSRalf Baechle 232384740dcSRalf Baechle /* Descriptor Command 1. */ 233384740dcSRalf Baechle #define DSCR_CMD1_SUPTR_MASK (0xf << 28) /* upper 4 bits of src addr */ 234384740dcSRalf Baechle #define DSCR_CMD1_DUPTR_MASK (0xf << 24) /* upper 4 bits of dest addr */ 235384740dcSRalf Baechle #define DSCR_CMD1_FL_MASK (0x3 << 22) /* Flag bits */ 236384740dcSRalf Baechle #define DSCR_CMD1_BC_MASK (0x3fffff) /* Byte count */ 237384740dcSRalf Baechle 238384740dcSRalf Baechle /* Flag description. */ 239384740dcSRalf Baechle #define DSCR_CMD1_FL_MEM_STRIDE0 0 240384740dcSRalf Baechle #define DSCR_CMD1_FL_MEM_STRIDE1 1 241384740dcSRalf Baechle #define DSCR_CMD1_FL_MEM_STRIDE2 2 242384740dcSRalf Baechle 243384740dcSRalf Baechle #define DSCR_CMD1_FL(x) (((x) & 0x3) << 22) 244384740dcSRalf Baechle 245384740dcSRalf Baechle /* Source1, 1-dimensional stride. */ 246384740dcSRalf Baechle #define DSCR_SRC1_STS_MASK (3 << 30) /* Src xfer size */ 247384740dcSRalf Baechle #define DSCR_SRC1_SAM_MASK (3 << 28) /* Src xfer movement */ 248384740dcSRalf Baechle #define DSCR_SRC1_SB_MASK (0x3fff << 14) /* Block size */ 249384740dcSRalf Baechle #define DSCR_SRC1_SB(x) (((x) & 0x3fff) << 14) 250384740dcSRalf Baechle #define DSCR_SRC1_SS_MASK (0x3fff << 0) /* Stride */ 251384740dcSRalf Baechle #define DSCR_SRC1_SS(x) (((x) & 0x3fff) << 0) 252384740dcSRalf Baechle 253384740dcSRalf Baechle /* Dest1, 1-dimensional stride. */ 254384740dcSRalf Baechle #define DSCR_DEST1_DTS_MASK (3 << 30) /* Dest xfer size */ 255384740dcSRalf Baechle #define DSCR_DEST1_DAM_MASK (3 << 28) /* Dest xfer movement */ 256384740dcSRalf Baechle #define DSCR_DEST1_DB_MASK (0x3fff << 14) /* Block size */ 257384740dcSRalf Baechle #define DSCR_DEST1_DB(x) (((x) & 0x3fff) << 14) 258384740dcSRalf Baechle #define DSCR_DEST1_DS_MASK (0x3fff << 0) /* Stride */ 259384740dcSRalf Baechle #define DSCR_DEST1_DS(x) (((x) & 0x3fff) << 0) 260384740dcSRalf Baechle 261384740dcSRalf Baechle #define DSCR_xTS_SIZE1 0 262384740dcSRalf Baechle #define DSCR_xTS_SIZE2 1 263384740dcSRalf Baechle #define DSCR_xTS_SIZE4 2 264384740dcSRalf Baechle #define DSCR_xTS_SIZE8 3 265384740dcSRalf Baechle #define DSCR_SRC1_STS(x) (((x) & 3) << 30) 266384740dcSRalf Baechle #define DSCR_DEST1_DTS(x) (((x) & 3) << 30) 267384740dcSRalf Baechle 268384740dcSRalf Baechle #define DSCR_xAM_INCREMENT 0 269384740dcSRalf Baechle #define DSCR_xAM_DECREMENT 1 270384740dcSRalf Baechle #define DSCR_xAM_STATIC 2 271384740dcSRalf Baechle #define DSCR_xAM_BURST 3 272384740dcSRalf Baechle #define DSCR_SRC1_SAM(x) (((x) & 3) << 28) 273384740dcSRalf Baechle #define DSCR_DEST1_DAM(x) (((x) & 3) << 28) 274384740dcSRalf Baechle 275384740dcSRalf Baechle /* The next descriptor pointer. */ 276384740dcSRalf Baechle #define DSCR_NXTPTR_MASK (0x07ffffff) 277384740dcSRalf Baechle #define DSCR_NXTPTR(x) ((x) >> 5) 278384740dcSRalf Baechle #define DSCR_GET_NXTPTR(x) ((x) << 5) 279384740dcSRalf Baechle #define DSCR_NXTPTR_MS (1 << 27) 280384740dcSRalf Baechle 281384740dcSRalf Baechle /* The number of DBDMA channels. */ 282384740dcSRalf Baechle #define NUM_DBDMA_CHANS 16 283384740dcSRalf Baechle 284384740dcSRalf Baechle /* 285384740dcSRalf Baechle * DDMA API definitions 286384740dcSRalf Baechle * FIXME: may not fit to this header file 287384740dcSRalf Baechle */ 288384740dcSRalf Baechle typedef struct dbdma_device_table { 289384740dcSRalf Baechle u32 dev_id; 290384740dcSRalf Baechle u32 dev_flags; 291384740dcSRalf Baechle u32 dev_tsize; 292384740dcSRalf Baechle u32 dev_devwidth; 293384740dcSRalf Baechle u32 dev_physaddr; /* If FIFO */ 294384740dcSRalf Baechle u32 dev_intlevel; 295384740dcSRalf Baechle u32 dev_intpolarity; 296384740dcSRalf Baechle } dbdev_tab_t; 297384740dcSRalf Baechle 298384740dcSRalf Baechle 299384740dcSRalf Baechle typedef struct dbdma_chan_config { 300384740dcSRalf Baechle spinlock_t lock; 301384740dcSRalf Baechle 302384740dcSRalf Baechle u32 chan_flags; 303384740dcSRalf Baechle u32 chan_index; 304384740dcSRalf Baechle dbdev_tab_t *chan_src; 305384740dcSRalf Baechle dbdev_tab_t *chan_dest; 306384740dcSRalf Baechle au1x_dma_chan_t *chan_ptr; 307384740dcSRalf Baechle au1x_ddma_desc_t *chan_desc_base; 308384740dcSRalf Baechle au1x_ddma_desc_t *get_ptr, *put_ptr, *cur_ptr; 309384740dcSRalf Baechle void *chan_callparam; 310384740dcSRalf Baechle void (*chan_callback)(int, void *); 311384740dcSRalf Baechle } chan_tab_t; 312384740dcSRalf Baechle 313384740dcSRalf Baechle #define DEV_FLAGS_INUSE (1 << 0) 314384740dcSRalf Baechle #define DEV_FLAGS_ANYUSE (1 << 1) 315384740dcSRalf Baechle #define DEV_FLAGS_OUT (1 << 2) 316384740dcSRalf Baechle #define DEV_FLAGS_IN (1 << 3) 317384740dcSRalf Baechle #define DEV_FLAGS_BURSTABLE (1 << 4) 318384740dcSRalf Baechle #define DEV_FLAGS_SYNC (1 << 5) 319384740dcSRalf Baechle /* end DDMA API definitions */ 320384740dcSRalf Baechle 321384740dcSRalf Baechle /* 322384740dcSRalf Baechle * External functions for drivers to use. 323384740dcSRalf Baechle * Use this to allocate a DBDMA channel. The device IDs are one of 324384740dcSRalf Baechle * the DSCR_CMD0 devices IDs, which is usually redefined to a more 325384740dcSRalf Baechle * meaningful name. The 'callback' is called during DMA completion 326384740dcSRalf Baechle * interrupt. 327384740dcSRalf Baechle */ 328384740dcSRalf Baechle extern u32 au1xxx_dbdma_chan_alloc(u32 srcid, u32 destid, 329384740dcSRalf Baechle void (*callback)(int, void *), 330384740dcSRalf Baechle void *callparam); 331384740dcSRalf Baechle 332384740dcSRalf Baechle #define DBDMA_MEM_CHAN DSCR_CMD0_ALWAYS 333384740dcSRalf Baechle 334384740dcSRalf Baechle /* Set the device width of an in/out FIFO. */ 335384740dcSRalf Baechle u32 au1xxx_dbdma_set_devwidth(u32 chanid, int bits); 336384740dcSRalf Baechle 337384740dcSRalf Baechle /* Allocate a ring of descriptors for DBDMA. */ 338384740dcSRalf Baechle u32 au1xxx_dbdma_ring_alloc(u32 chanid, int entries); 339384740dcSRalf Baechle 340384740dcSRalf Baechle /* Put buffers on source/destination descriptors. */ 341384740dcSRalf Baechle u32 _au1xxx_dbdma_put_source(u32 chanid, void *buf, int nbytes, u32 flags); 342384740dcSRalf Baechle u32 _au1xxx_dbdma_put_dest(u32 chanid, void *buf, int nbytes, u32 flags); 343384740dcSRalf Baechle 344384740dcSRalf Baechle /* Get a buffer from the destination descriptor. */ 345384740dcSRalf Baechle u32 au1xxx_dbdma_get_dest(u32 chanid, void **buf, int *nbytes); 346384740dcSRalf Baechle 347384740dcSRalf Baechle void au1xxx_dbdma_stop(u32 chanid); 348384740dcSRalf Baechle void au1xxx_dbdma_start(u32 chanid); 349384740dcSRalf Baechle void au1xxx_dbdma_reset(u32 chanid); 350384740dcSRalf Baechle u32 au1xxx_get_dma_residue(u32 chanid); 351384740dcSRalf Baechle 352384740dcSRalf Baechle void au1xxx_dbdma_chan_free(u32 chanid); 353384740dcSRalf Baechle void au1xxx_dbdma_dump(u32 chanid); 354384740dcSRalf Baechle 355384740dcSRalf Baechle u32 au1xxx_dbdma_put_dscr(u32 chanid, au1x_ddma_desc_t *dscr); 356384740dcSRalf Baechle 357384740dcSRalf Baechle u32 au1xxx_ddma_add_device(dbdev_tab_t *dev); 358384740dcSRalf Baechle extern void au1xxx_ddma_del_device(u32 devid); 359384740dcSRalf Baechle void *au1xxx_ddma_get_nextptr_virt(au1x_ddma_desc_t *dp); 360*ac15dad0SManuel Lauss #ifdef CONFIG_PM 361*ac15dad0SManuel Lauss void au1xxx_dbdma_suspend(void); 362*ac15dad0SManuel Lauss void au1xxx_dbdma_resume(void); 363*ac15dad0SManuel Lauss #endif 364*ac15dad0SManuel Lauss 365384740dcSRalf Baechle 366384740dcSRalf Baechle /* 367384740dcSRalf Baechle * Some compatibilty macros -- needed to make changes to API 368384740dcSRalf Baechle * without breaking existing drivers. 369384740dcSRalf Baechle */ 370384740dcSRalf Baechle #define au1xxx_dbdma_put_source(chanid, buf, nbytes) \ 371384740dcSRalf Baechle _au1xxx_dbdma_put_source(chanid, buf, nbytes, DDMA_FLAGS_IE) 372384740dcSRalf Baechle #define au1xxx_dbdma_put_source_flags(chanid, buf, nbytes, flags) \ 373384740dcSRalf Baechle _au1xxx_dbdma_put_source(chanid, buf, nbytes, flags) 374384740dcSRalf Baechle #define put_source_flags(chanid, buf, nbytes, flags) \ 375384740dcSRalf Baechle au1xxx_dbdma_put_source_flags(chanid, buf, nbytes, flags) 376384740dcSRalf Baechle 377384740dcSRalf Baechle #define au1xxx_dbdma_put_dest(chanid, buf, nbytes) \ 378384740dcSRalf Baechle _au1xxx_dbdma_put_dest(chanid, buf, nbytes, DDMA_FLAGS_IE) 379384740dcSRalf Baechle #define au1xxx_dbdma_put_dest_flags(chanid, buf, nbytes, flags) \ 380384740dcSRalf Baechle _au1xxx_dbdma_put_dest(chanid, buf, nbytes, flags) 381384740dcSRalf Baechle #define put_dest_flags(chanid, buf, nbytes, flags) \ 382384740dcSRalf Baechle au1xxx_dbdma_put_dest_flags(chanid, buf, nbytes, flags) 383384740dcSRalf Baechle 384384740dcSRalf Baechle /* 385384740dcSRalf Baechle * Flags for the put_source/put_dest functions. 386384740dcSRalf Baechle */ 387384740dcSRalf Baechle #define DDMA_FLAGS_IE (1 << 0) 388384740dcSRalf Baechle #define DDMA_FLAGS_NOIE (1 << 1) 389384740dcSRalf Baechle 390384740dcSRalf Baechle #endif /* _LANGUAGE_ASSEMBLY */ 391384740dcSRalf Baechle #endif /* _AU1000_DBDMA_H_ */ 392