/******************************************************************************
**
**
** COPYRIGHT (C) 2000, 2001 Intel Corporation.
**
** This software as well as the software described in it is furnished under
** license and may only be used or copied in accordance with the terms of the
** license. The information in this file is furnished for informational use
** only, is subject to change without notice, and should not be construed as
** a commitment by Intel Corporation. Intel Corporation assumes no
** responsibility or liability for any errors or inaccuracies that may appear
** in this document or any software that may be provided in association with
** this document.
** Except as permitted by such license, no part of this document may be
** reproduced, stored in a retrieval system, or transmitted in any form or by
** any means without the express written consent of Intel Corporation.
**
** FILENAME: xsdma.c
**
** PURPOSE: Contains the API implementation for the DMA controller
** driver.
**
** Valid for : Cotulla processor
**
** EAS VERSION :
**
** LAST MODIFIED: $Modtime: 7/17/03 1:01p $
******************************************************************************/
/*******************************************************************************
* HEADER FILES
*******************************************************************************/
#include <string.h>
#include <stdio.h>
#include "systypes.h"
#include "XsIntCtrlApi.h"
#include "XsDmaApi.h"
#include "xsdma.h"
#include "dm_errors.h"
#include "mallocx.h"
#include "cotulla.h"
#include "DM_Debug.h"
//#include "serialCommon.h"
#include "timedelays.h"
/*******************************************************************************
* MACRO DEFINITIONS
*******************************************************************************/
#define DM_ReturnMem(virtualAddr) free(virtualAddr)
/*******************************************************************************
* GLOBAL DEFINITIONS
*******************************************************************************/
volatile XsDmaCtrlT *XsDmaControlRegsP = (XsDmaCtrlT *)DMA_REGISTER_BASE;
static UINT XsDmaChannelsUsedWord = 0;
/*******************************************************************************
This table contains the DMA specific data for the peripheral devices.
Refer to table 6-4 in the Cotulla EAS August, 2000.
*******************************************************************************/
XsDmaToDeviceT DmaDeviceTable[] = {
/* Name receive transmit width burst */
{XSDMA_DN_MEMORY, 0, 0, DCMD_WIDTH_4, 0},
{XSDMA_DN_I2S, 0x40400080, 0x40400080, DCMD_WIDTH_4, DCMD_SIZE_32},
{XSDMA_DN_BTUART, 0x40200000, 0x40200000, DCMD_WIDTH_1, DCMD_SIZE_32},
{XSDMA_DN_FFUART, 0x40100000, 0x40100000, DCMD_WIDTH_1, DCMD_SIZE_32},
{XSDMA_DN_AC97_MIC, 0x40500060, 0, DCMD_WIDTH_4, DCMD_SIZE_32},
{XSDMA_DN_AC97_MODEM, 0x40500140, 0x40500140, DCMD_WIDTH_4, DCMD_SIZE_32},
{XSDMA_DN_AC97_AUDIO, 0x40500040, 0x40500040, DCMD_WIDTH_4, DCMD_SIZE_32},
{XSDMA_DN_SSP1, 0x41000010, 0x41000010, DCMD_WIDTH_2, DCMD_SIZE_16},
{XSDMA_DN_ICP, 0x4080000C, 0x4080000C, DCMD_WIDTH_1, DCMD_SIZE_8},
{XSDMA_DN_STUART, 0x40700000, 0x40700000, DCMD_WIDTH_1, DCMD_SIZE_32},
{XSDMA_DN_MMC, 0x41100040, 0x41100044, DCMD_WIDTH_1, DCMD_SIZE_32},
{XSDMA_DN_USB_EP_0, 0x40600300, 0x40600300, DCMD_WIDTH_4, DCMD_SIZE_32},
{XSDMA_DN_USB_EP_A, 0x40600304, 0x40600304, DCMD_WIDTH_4, DCMD_SIZE_32},
{XSDMA_DN_USB_EP_B, 0x40600308, 0x40600308, DCMD_WIDTH_4, DCMD_SIZE_32},
{XSDMA_DN_USB_EP_C, 0x4060030C, 0x4060030C, DCMD_WIDTH_4, DCMD_SIZE_32},
{XSDMA_DN_USB_EP_D, 0x40600310, 0x40600310, DCMD_WIDTH_4, DCMD_SIZE_32},
{XSDMA_DN_USB_EP_E, 0x40600314, 0x40600314, DCMD_WIDTH_4, DCMD_SIZE_32},
{XSDMA_DN_USB_EP_F, 0x40600318, 0x40600318, DCMD_WIDTH_4, DCMD_SIZE_32},
{XSDMA_DN_USB_EP_G, 0x4060031C, 0x4060031C, DCMD_WIDTH_4, DCMD_SIZE_32},
{XSDMA_DN_USB_EP_H, 0x40600320, 0x40600320, DCMD_WIDTH_4, DCMD_SIZE_32},
{XSDMA_DN_USB_EP_I, 0x40600324, 0x40600324, DCMD_WIDTH_4, DCMD_SIZE_32},
{XSDMA_DN_USB_EP_J, 0x40600328, 0x40600328, DCMD_WIDTH_4, DCMD_SIZE_32},
{XSDMA_DN_USB_EP_K, 0x4060032C, 0x4060032C, DCMD_WIDTH_4, DCMD_SIZE_32},
{XSDMA_DN_USB_EP_L, 0x40600330, 0x40600330, DCMD_WIDTH_4, DCMD_SIZE_32},
{XSDMA_DN_USB_EP_M, 0x40600334, 0x40600334, DCMD_WIDTH_4, DCMD_SIZE_32},
{XSDMA_DN_USB_EP_N, 0x40600338, 0x40600338, DCMD_WIDTH_4, DCMD_SIZE_32},
{XSDMA_DN_USB_EP_P, 0x4060033C, 0x4060033C, DCMD_WIDTH_4, DCMD_SIZE_32},
{XSDMA_DN_USB_EP_Q, 0x40600340, 0x40600340, DCMD_WIDTH_4, DCMD_SIZE_32},
{XSDMA_DN_USB_EP_R, 0x40600344, 0x40600344, DCMD_WIDTH_4, DCMD_SIZE_32},
{XSDMA_DN_USB_EP_S, 0x40600348, 0x40600348, DCMD_WIDTH_4, DCMD_SIZE_32},
{XSDMA_DN_USB_EP_T, 0x4060034C, 0x4060034C, DCMD_WIDTH_4, DCMD_SIZE_32},
{XSDMA_DN_USB_EP_U, 0x40600350, 0x40600350, DCMD_WIDTH_4, DCMD_SIZE_32},
{XSDMA_DN_USB_EP_V, 0x40600354, 0x40600354, DCMD_WIDTH_4, DCMD_SIZE_32},
{XSDMA_DN_USB_EP_W, 0x40600358, 0x40600358, DCMD_WIDTH_4, DCMD_SIZE_32},
{XSDMA_DN_USB_EP_X, 0x4060035C, 0x4060035C, DCMD_WIDTH_4, DCMD_SIZE_32},
//SHAWN- DCMD_WIDTH from 1 to 4 now.. any issues?
{XSDMA_DN_BASEBAND_1, 0x41400004, 0x41400004, DCMD_WIDTH_4, DCMD_SIZE_32},
{XSDMA_DN_BASEBAND_2, 0x41400008, 0x41400008, DCMD_WIDTH_4, DCMD_SIZE_32},
{XSDMA_DN_BASEBAND_3, 0x4140000C, 0x4140000C, DCMD_WIDTH_4, DCMD_SIZE_32},
{XSDMA_DN_BASEBAND_4, 0x41400010, 0x41400010, DCMD_WIDTH_4, DCMD_SIZE_32},
{XSDMA_DN_BASEBAND_5, 0x41400014, 0x41400014, DCMD_WIDTH_4, DCMD_SIZE_32},
{XSDMA_DN_BASEBAND_6, 0x41400018, 0x41400018, DCMD_WIDTH_4, DCMD_SIZE_32},
{XSDMA_DN_BASEBAND_7, 0x4140001C, 0x4140001C, DCMD_WIDTH_4, DCMD_SIZE_32},
{XSDMA_DN_USIM, 0x41600000, 0x41600004, DCMD_WIDTH_1, DCMD_SIZE_32},
{XSDMA_DN_SSP2, 0x41700010, 0x41700010, DCMD_WIDTH_2, DCMD_SIZE_16},
{XSDMA_DN_MEM_STICK, 0x41800018, 0x4180001C, DCMD_WIDTH_1, DCMD_SIZE_8},
{XSDMA_DN_SSP3, 0x41900010, 0x41900010, DCMD_WIDTH_2, DCMD_SIZE_16}
};
/*******************************************************************************
* FUNCTION DEFINITIONS
*******************************************************************************/
/*
*******************************************************************************
*
* FUNCTION: DM_GetDmaDescriptorAlignedBlock
*
* DESCRIPTION: Get a single block of memory that is the size of a DMA
* descriptor structure, with the appropriate alignment.
*
* INPUT PARAMETERS:
* XsDmaDescriptorElementsTPT* virtualPP:
* Address of a pointer to the new descriptor block.
* PUINT32 physicalAddrP:
* Address of a variable to hold the new descriptor block's
* physical address.
*
* RETURNS: UINT32
* Success: ERR_NONE (0)
* Failure: Anything other than ERR_NONE. Memory not allocated.
*
*
* GLOBAL EFFECTS: None
*
* ASSUMPTIONS: malloc() provides allocates memory units that are
* DMA descriptor-aligned.
*
* CALLS: malloc
*
* CALLED BY: Anyone
*
* PROTOTYPE: UINT32 DM_GetDmaDescriptorAlignedBlock
* (XsDmaDescriptorElementsTPT*,
*
评论0