/* * * cppi41_dma.h * Description: * see below * * * Copyright (C) 2008, Texas Instruments, Incorporated * * This program is free software; you can distribute it and/or modify it * under the terms of the GNU General Public License (Version 2) as * published by the Free Software Foundation. * * This program is distributed in the hope it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. * */ #ifndef _CPPI41_DMA_H_ #define _CPPI41_DMA_H_ /* configuration */ //#define USB_CPPI4_DEBUG #define USB_USE_ACC_LIST #define USB_INCLUDE_ASSERT #define USB_CPPI_TX_TASKLET_MODE #define USB_CPPI_RX_TASKLET_MODE #ifdef CONFIG_ARM_AVALANCHE_PPD #ifndef CONFIG_USB_MUSB_HDRC_HCD #define CONFIG_USB_PPD_SUPPORT #endif #define USB_PPD_INFRA_TXDMA_NUM 1 #define USB_PPD_INFRA_RXDMA_NUM 1 /* 20101221 AVM/WK: TI patch for DMA issue */ #define USB_RX_EPDMA_NUM USB_CPPI41_DMA_NUM #endif #include #include #include #include #include //#include "dma.h" //#include #include "musb_core.h" //#include //#include //#if defined(CONFIG_ARM_AVALANCHE_PPD) && defined(CONFIG_USB_PPD_SUPPORT) //#include //#endif #include #include #if defined(CONFIG_ARM_AVALANCHE_PPD) && defined(CONFIG_USB_PPD_SUPPORT) #include #endif #define PAL_CPPI4_CACHE_INVALIDATE(addr, size) dma_cache_inv ((unsigned long)(addr), (size)) #define PAL_CPPI4_CACHE_WRITEBACK(addr, size) dma_cache_wback ((unsigned long)(addr), (size)) #define PAL_CPPI4_CACHE_WRITEBACK_INVALIDATE(addr, size) dma_cache_wback_inv ((unsigned long)(addr), (size)) #ifndef PRIVATE #define PRIVATE static #endif #ifdef USB_INCLUDE_ASSERT #define assert(handle_parent, expr) \ if(!(expr)) { \ handle_parent->hDDC->ddaIf->ddaErrLog( "Assertion failed! %s,%s,%s,line=%d\n", \ #expr,__FILE__,__FUNCTION__,__LINE__); BUG (); } #else #define assert(handle_parent, expr) #endif #define USB_CPPI4_DEBUG_LEVEL 4 #define USB_HOST 0 #define USBOTG_MAX_TX_QS 1 #define MAX_USB_CPPI4_CHANNEL 4 #define USB_OTG_MAX_TX_QS 1 #define USBOTG_NUM_RXFDB_QS 1 /* TODO */ #define CPPI4_PKT_TYPE_USB 5 #define USB_RX_EMBEDDED_BD_NUM 64 #ifdef CONFIG_ARM_AVALANCHE_USB_ON_OWN_DMA_SCHEDULER /* 20101221 AVM/WK: TI patch for DMA issue */ /* DMA BLOCK number 0 is used for usb only */ #define USB_CPPI41_DMA_NUM 0 #else /* DMA number 1 is used for usb */ #define USB_CPPI41_DMA_NUM 1//1 #endif /* CPPI4.1 DMA Tx channels for ep1 to ep4*/ #define USB_CPPI41DMA_EP1_TXCH 4 #define USB_CPPI41DMA_EP2_TXCH 5 #define USB_CPPI41DMA_EP3_TXCH 6 #define USB_CPPI41DMA_EP4_TXCH 7 /* CPPI4.1 DMA Rx channels for ep1 to ep4*/ #define USB_CPPI41DMA_EP1_RXCH 4 #define USB_CPPI41DMA_EP2_RXCH 5 #define USB_CPPI41DMA_EP3_RXCH 6 #define USB_CPPI41DMA_EP4_RXCH 7 /* accumulator configuration */ #define USB_ACC_MODE_LIST_MODE 0 /* 0 => list mode */ #define USB_ACC_MODE_MONITOR_MODE 1 /* 1 => monitor mode */ /* error defintiorns */ #define USB_SUCCESS 0 #define USB_ERR_TX_OUT_OF_BD 1 #define USB_ERR_CPPI_TX_CH 2 #define USB_ERR_CPPI_DESC_REGN_FAIL 3 #define USB_ERR_TX_CH_ALREADY_CLOSED 4 #define USB_ERR_RX_CH_ALREADY_CLOSED 5 #define USB_ERR_RXCH_INVALID 6 #define USB_ERR_RX_OUT_OF_BD 7 /* CPPI tx/rx channel states */ #define USB_CPPI4_CH_INITIALIZED 1 #define USB_CPPI4_CH_OPENED 2 #define USB_CPPI4_CH_CLOSED 3 /* CPPI4 Buffer Descriptor Macros * CPPI41 related MACROS * TODO: Need to move to a better place (inside CPPI module?). */ #define CPPI4_DESC_TYPE_SHIFT_HOST 27 #define CPPI4_DESC_TYPE_HOST 16 #define CPPI4_PKT_TYPE_SHIFT 26 #define CPPI4_PKT_TYPE_ETH 7 #define CPPI4_PKT_RETPLCY_SHIFT 15 #define CPPI4_PKT_RETPLCY_FULL 0 #define CPPI4_DESC_LOC_SHIFT 14 #define CPPI4_DESC_LOC_OFFCHIP 0 #define CPPI4_PKT_RETQMGR_SHIFT 12 #define CPPI4_PKT_RETQ_SHIFT 0 #define CPPI4_DESC_TYPE_SHIFT_TD 27 #define CPPI4_DESC_TYPE_MASK_TD (0x1F << CPPI4_DESC_TYPE_SHIFT_TD) #define CPPI4_DESC_TYPE_TD 19 #define CPPI4_BD_BUF_SIZE_MASK 0xFFFF #define CPPI4_BD_PKT_LENGTH_MASK 0x3FFFFF /* Only CPPI specified bytes need to be invalidated */ #define CPPI4_BD_LENGTH_FOR_CACHE 64 /* TODO to be moved to arch/asm/mach-avalanch.. common header file */ #define USB_CPPI4_HOST_DESC_ALGN 64 #define USB_CPPI4_EPNUM_BD 64 #define USB_CPPI4_MAX_BD (CPPI41_MAX_USB_DESC) #define USB_CPPI4_QMGR_NUM 0 /* * INTD registers defintions */ #define INTCBASE 0x50000000 #define INTCACCUMMASK 0x18 #define INTDBASE (IO_ADDRESS(0x03064000)) #define INTDSTATUS (INTDBASE + 0x204) #define INTD_COUNT_REGBASE (INTDBASE + 0x300) #define INTD_EOI_REG (INTDBASE + 0x10) /* * accumulator list configuration data */ //#define USB_USE_ACCUMULATOR_LIST #define USBOTG_ACC_LIST_DIV 2 #define USB_ACC_ENTRY_SIZE_VAL CPPI41_ACC_ENTRY_D #define USB_ACC_ENTRY_SIZE 4 #define USB_ACC_LIST_MODE 0 #define USB_ACC_RX_MAXENTRIES 32//32 #define USB_ACC_TX_MAXENTRIES 32//32 #define USB_ACC_INTR_MODE 3 #define USB_ACC_INTR_DELAY 1//40 #define USB_ACC_LIST_DIV 2 #define USB_ACC_STALL_AVOID 0 #define CPPI41_ACC_ENTRY_D 0 #define CPPI41_ACC_ENTRY_CD 1 #define CPPI41_ACC_ENTRY_ABCD 2 #define USB_EP1_4TX_INTVEC (INTC_CPINTD_VEC_BASE + USB_EP_TX_ACC_VEC_NUM) #define USB_EP1_4RX_INTVEC (INTC_CPINTD_VEC_BASE + USB_EP_RX_ACC_VEC_NUM) #define USB_CPPI_TXDMA_INTR (AVALANCHE_INTD_BASE_INT + USB_ACCTX_INTD_VEC ) #define USB_CPPI_RXDMA_INTR (AVALANCHE_INTD_BASE_INT + USB_ACCRX_INTD_VEC ) #define USB_ACC_TXCH_MASK ( 1 << USB_ACC_TX_CHNUM ) #define USB_ACC_TXCH_SHIFT_CNT (USB_ACC_TX_CHNUM) #define USB_ACC_RXCH_MASK (0xF <accChNum); } static inline int disableTxIntr (usbTxCppiCh* txCppi) { return avalanche_intd_disable_interrupt (USB_HOST, txCppi->accChNum); } #endif static inline int enableTxIntr (int accChNum) { return avalanche_intd_enable_interrupt (USB_HOST, accChNum); } static inline int disableTxIntr (int accChNum) { return avalanche_intd_disable_interrupt (USB_HOST, accChNum); } static inline int enableRxIntr (usbRxCppiCh* rxCppi) { return avalanche_intd_enable_interrupt (USB_HOST, rxCppi->accChNum); } static inline int disableRxIntr (usbRxCppiCh* rxCppi) { return avalanche_intd_disable_interrupt (USB_HOST, rxCppi->accChNum); } #if 0 static inline int doTxEOI (usbTxCppiCh* txCppi) { #if defined USB_USE_ACC_LIST return avalanche_intd_write_eoi (txCppi->accVecNum); #else return 0; #endif } #endif static inline int doTxEOI (int accVecNum) { #if defined USB_USE_ACC_LIST return avalanche_intd_write_eoi (accVecNum); #else return 0; #endif } static inline int doRxEOI (usbRxCppiCh* rxCppi) { #if defined USB_USE_ACC_LIST return avalanche_intd_write_eoi (rxCppi->accVecNum); #else return 0; #endif } /************************ End - Interrupt related functions *******************/