Path: blob/master/arch/arm/mach-bcmring/include/mach/csp/dmacHw_priv.h
10821 views
/*****************************************************************************1* Copyright 2004 - 2008 Broadcom Corporation. All rights reserved.2*3* Unless you and Broadcom execute a separate written software license4* agreement governing use of this software, this software is licensed to you5* under the terms of the GNU General Public License version 2, available at6* http://www.broadcom.com/licenses/GPLv2.php (the "GPL").7*8* Notwithstanding the above, under no circumstances may you combine this9* software in any way with any other Broadcom software provided under a10* license other than the GPL, without Broadcom's express prior written11* consent.12*****************************************************************************/1314/****************************************************************************/15/**16* @file dmacHw_priv.h17*18* @brief Private Definitions for low level DMA driver19*20*/21/****************************************************************************/2223#ifndef _DMACHW_PRIV_H24#define _DMACHW_PRIV_H2526#include <csp/stdint.h>2728/* Data type for DMA Link List Item */29typedef struct {30uint32_t sar; /* Source Address Register.31Address must be aligned to CTLx.SRC_TR_WIDTH. */32uint32_t dar; /* Destination Address Register.33Address must be aligned to CTLx.DST_TR_WIDTH. */34uint32_t llpPhy; /* LLP contains the physical address of the next descriptor for block chaining using linked lists.35Address MUST be aligned to a 32-bit boundary. */36dmacHw_REG64_t ctl; /* Control Register. 64 bits */37uint32_t sstat; /* Source Status Register */38uint32_t dstat; /* Destination Status Register */39uint32_t devCtl; /* Device specific control information */40uint32_t llp; /* LLP contains the virtual address of the next descriptor for block chaining using linked lists. */41} dmacHw_DESC_t;4243/*44* Descriptor ring pointers45*/46typedef struct {47int num; /* Number of link items */48dmacHw_DESC_t *pHead; /* Head of descriptor ring (for writing) */49dmacHw_DESC_t *pTail; /* Tail of descriptor ring (for reading) */50dmacHw_DESC_t *pProg; /* Descriptor to program the channel (for programming the channel register) */51dmacHw_DESC_t *pEnd; /* End of current descriptor chain */52dmacHw_DESC_t *pFree; /* Descriptor to free memory (freeing dynamic memory) */53uint32_t virt2PhyOffset; /* Virtual to physical address offset for the descriptor ring */54} dmacHw_DESC_RING_t;5556/*57* DMA channel control block58*/59typedef struct {60uint32_t module; /* DMA controller module (0-1) */61uint32_t channel; /* DMA channel (0-7) */62volatile uint32_t varDataStarted; /* Flag indicating variable data channel is enabled */63volatile uint32_t descUpdated; /* Flag to indicate descriptor update is complete */64void *userData; /* Channel specifc user data */65} dmacHw_CBLK_t;6667#define dmacHw_ASSERT(a) if (!(a)) while (1)68#define dmacHw_MAX_CHANNEL_COUNT 1669#define dmacHw_FREE_USER_MEMORY 0xFFFFFFFF70#define dmacHw_DESC_FREE dmacHw_REG_CTL_DONE71#define dmacHw_DESC_INIT ((dmacHw_DESC_t *) 0xFFFFFFFF)72#define dmacHw_MAX_BLOCKSIZE 406473#define dmacHw_GET_DESC_RING(addr) (dmacHw_DESC_RING_t *)(addr)74#define dmacHw_ADDRESS_MASK(byte) ((byte) - 1)75#define dmacHw_NEXT_DESC(rp, dp) ((rp)->dp = (dmacHw_DESC_t *)(rp)->dp->llp)76#define dmacHw_HANDLE_TO_CBLK(handle) ((dmacHw_CBLK_t *) (handle))77#define dmacHw_CBLK_TO_HANDLE(cblkp) ((dmacHw_HANDLE_t) (cblkp))78#define dmacHw_DST_IS_MEMORY(tt) (((tt) == dmacHw_TRANSFER_TYPE_PERIPHERAL_TO_MEM) || ((tt) == dmacHw_TRANSFER_TYPE_MEM_TO_MEM)) ? 1 : 07980/****************************************************************************/81/**82* @brief Get next available transaction width83*84*85* @return On success : Next available transaction width86* On failure : dmacHw_TRANSACTION_WIDTH_887*88* @note89* None90*/91/****************************************************************************/92static inline dmacHw_TRANSACTION_WIDTH_e dmacHw_GetNextTrWidth(dmacHw_TRANSACTION_WIDTH_e tw /* [ IN ] Current transaction width */93) {94if (tw & dmacHw_REG_CTL_SRC_TR_WIDTH_MASK) {95return ((tw >> dmacHw_REG_CTL_SRC_TR_WIDTH_SHIFT) -961) << dmacHw_REG_CTL_SRC_TR_WIDTH_SHIFT;97} else if (tw & dmacHw_REG_CTL_DST_TR_WIDTH_MASK) {98return ((tw >> dmacHw_REG_CTL_DST_TR_WIDTH_SHIFT) -991) << dmacHw_REG_CTL_DST_TR_WIDTH_SHIFT;100}101102/* Default return */103return dmacHw_SRC_TRANSACTION_WIDTH_8;104}105106/****************************************************************************/107/**108* @brief Get number of bytes per transaction109*110* @return Number of bytes per transaction111*112*113* @note114* None115*/116/****************************************************************************/117static inline int dmacHw_GetTrWidthInBytes(dmacHw_TRANSACTION_WIDTH_e tw /* [ IN ] Transaction width */118) {119int width = 1;120switch (tw) {121case dmacHw_SRC_TRANSACTION_WIDTH_8:122width = 1;123break;124case dmacHw_SRC_TRANSACTION_WIDTH_16:125case dmacHw_DST_TRANSACTION_WIDTH_16:126width = 2;127break;128case dmacHw_SRC_TRANSACTION_WIDTH_32:129case dmacHw_DST_TRANSACTION_WIDTH_32:130width = 4;131break;132case dmacHw_SRC_TRANSACTION_WIDTH_64:133case dmacHw_DST_TRANSACTION_WIDTH_64:134width = 8;135break;136default:137dmacHw_ASSERT(0);138}139140/* Default transaction width */141return width;142}143144#endif /* _DMACHW_PRIV_H */145146147