📄 gfd_dmac.c
字号:
/**************************************************************************************
*
* (c) 2004 ASIC,all rights reserved
*
*
* This source code and any compilation or derivative thereof
*is proprietary information and is confidential in nature.
* Under no circumstance is this software to be exposed or placed
*under an open source License of any type without expressed
*written permission of ASIC.
*
*filename: HA_Dmac.c
*history:
*
* Version Date Author Comment
*------------------------------------------------------------------------------------
* 1.0 2004.9.24 lmq Initial Creation
*
**************************************************************************************/
#include "HA_TypeDef.h"
#include "gfd_dmac.h"
//#include "HA_EMI.h"
#include "gfd_usb_irq.h"
#include "hardware_reg.h"
extern U32 longpk;
extern U32 blkstate;
extern U32 epstate;
ER HA_InitDMAC(void)
{
/////////////////////////////////////////////intial the register DMACIntErrClr DMACIntTCClear
*(RP) DMACIntErrClr =0xFFFFFFFF;
//#ifndef RELEASE_CODE
//temp = *(RP) DMACIntErrClr;
//if(temp != 0xFFFFFFFF)
//{
// HA_PRINT((HA_ERRORBASE_DMAC+0x0), HA_EOR_1);
//}
//#endif
*(RP)DMACIntTCClear =0xFFFFFFFF;
//#ifndef RELEASE_CODE
//temp = *(RP)DMACIntTCClear;
//if(temp != 0xFFFFFFFF)
//{
// HA_PRINT((HA_ERRORBASE_DMAC+0x4), HA_EOR_1);
//}
//#endif
*(RP)DMACIntErrClr =0x00000000;
//#ifndef RELEASE_CODE
//temp = *(RP)DMACIntErrClr;
//if(temp != 0x00000000)
//{
// HA_PRINT((HA_ERRORBASE_DMAC+0x8), HA_EOR_1);
//}
//#endif
*(RP)DMACIntTCClear =0x00000000;
//#ifndef RELEASE_CODE
//temp = *(RP)DMACIntTCClear;
//if(temp != 0x00000000)
//{
// HA_PRINT((HA_ERRORBASE_DMAC+0xc), HA_EOR_1);
//}
//#endif
return 0;
}
ER HA_DMA_TRANS_test(U32 souadress, U32 destadress, U32 datawidth, U32 datalength, U32 tansnum)
{
U32 temp,temp1,temp2,temp3,i;
*(RP)DMACSouAdd_test = souadress;
*(RP)DMACdesAdd_test = destadress;
temp1 = 0xb0000000;
if (datawidth == 0x8) temp2 = 0x0;
else if (datawidth == 0x16) temp2 = 0x1;
else if (datawidth == 0x32) temp2 = 0x2;
if (datalength == 0x16) temp3 = 0x10;
else if (datalength == 0x8) temp3 = 0x8;
else if (datalength == 0x4) temp3 = 0x4;
else if (datalength == 0x1) temp3 = 0x1;
temp = (tansnum & 0xfff) + temp1 + (temp2 << 24) + (temp3 << 16);
*(RP)DMACContr_test = temp;
*(RP)DMACEnbldChns_test = 0x000001;
i = *(RP)DMACComplish_test;
while((i&0x1) != 0x1)
{ i = *(RP)DMACComplish_test; };
return 1;
}
ER USB_DMA_TRANS_RX(U32 srcadd, U32 destadd, U32 srcwidth, U32 destwidth, U32 srcsize, U32 channelnum, U32 transnum)
{
//Parameters Notes:
//sourcewidth: byte/halfword/word
//destwidth: byte/halfword/word
//sourcesize: 1,4,8,16
//channelnum: 0-5 general channel
//transnum: number of to be transed data,by source data width
//
//note: destsize is omitted,because sourcewidth*sourcesize
// must=destwidth*destsize
U32 temp;
U32 tempdata,temp1,temp2,temp3;
U32 tempsrc,tempdest,tempcontrol,tempconfig; //These 4 temp regiser address rariable are used to replase registers
// of registers of channel which is used now
temp = channelnum;
tempsrc = DMACbase + 0x1000 + temp*0x100; //replase registers of channel to be used;
tempdest = DMACbase + 0x1004 + temp*0x100;
*(RP)tempsrc = srcadd;
*(RP)tempdest = destadd;
tempcontrol = DMACbase + 0x100c + temp*0x100;
tempconfig = DMACbase + 0x1010 + temp*0x100;
temp1 = (transnum << 2) + 0x2; //8th and 9th bit set to 1:srcadd and destadd are increasing during transaction;
temp2 = temp1 << 12; //set trans number,10th--21bit,(<4k)
//21th--10th bits determine total transcation data size;
if ((srcwidth == 0x32)&&(destwidth == 0x32)&&(srcsize == 0x4))
temp3 = 0x49b;
else if ((srcwidth == 0x32)&&(destwidth == 0x32)&&(srcsize == 0x8))
temp3 = 0x4ad;
else if ((srcwidth == 0x32)&&(destwidth == 0x32)&&(srcsize == 0x16))
temp3 = 0x4bf;
else if ((srcwidth == 0x32)&&(destwidth == 0x16)&&(srcsize == 0x8))
temp3 = 0x2bd;
else if ((srcwidth == 0x32)&&(destwidth == 0x16)&&(srcsize == 0x4))
temp3 = 0x2ab;
else if ((srcwidth == 0x32)&&(destwidth == 0x8)&&(srcsize == 0x4))
temp3 = 0x0bb;
else if ((srcwidth == 0x16)&&(destwidth == 0x32)&&(srcsize == 0x16))
temp3 = 0x46f;
else if ((srcwidth == 0x16)&&(destwidth == 0x32)&&(srcsize == 0x8))
temp3 = 0x45d;
else if ((srcwidth == 0x16)&&(destwidth == 0x16)&&(srcsize == 0x4))
temp3 = 0x25b;
else if ((srcwidth == 0x16)&&(destwidth == 0x16)&&(srcsize == 0x8))
temp3 = 0x26d;
else if ((srcwidth == 0x16)&&(destwidth == 0x16)&&(srcsize == 0x16))
temp3 = 0x27f;
else if ((srcwidth == 0x16)&&(destwidth == 0x8)&&(srcsize == 0x4))
temp3 = 0x06b;
else if ((srcwidth == 0x16)&&(destwidth == 0x8)&&(srcsize == 0x8))
temp3 = 0x07d;
else if ((srcwidth == 0x8)&&(destwidth == 0x32)&&(srcsize == 0x16))
temp3 = 0x41f;
else if ((srcwidth == 0x8)&&(destwidth == 0x16)&&(srcsize == 0x16))
temp3 = 0x22f;
else if ((srcwidth == 0x8)&&(destwidth == 0x16)&&(srcsize == 0x8))
temp3 = 0x21d;
else if ((srcwidth == 0x8)&&(destwidth == 0x8)&&(srcsize == 0x4))
temp3 = 0x01b;
else if ((srcwidth == 0x8)&&(destwidth == 0x8)&&(srcsize == 0x8))
temp3 = 0x02d;
else if ((srcwidth == 0x8)&&(destwidth == 0x8)&&(srcsize == 0x16))
temp3 = 0x03f;
//19 transcation patterns altogether,change with sourcewith,destwith,
// sourcesize and destsize.
//0th --7th bits determine which pattern is to be used;
tempdata = temp2 + temp3; //Set the control register;
*(RP)tempcontrol = tempdata;
if((longpk == LONGPKSTATE) || (((blkstate == BLKCMD) || (blkstate == BLKPRO)) && (epstate == EPBULK))){
*(RP)tempconfig =0X08d;
}else{
*(RP)tempconfig =0X09d;
}
/*
temp = *(RP)tempconfig; //judge the last trans edned or not?
while( (temp & 0x1) != 0x0)
{
temp = *(RP)tempconfig;
}
*/
return 0;
}
ER USB_DMA_TRANS_TX(U32 srcadd, U32 destadd, U32 srcwidth, U32 destwidth, U32 srcsize, U32 channelnum, U32 transnum)
{
//Parameters Notes:
//sourcewidth: byte/halfword/word
//destwidth: byte/halfword/word
//sourcesize: 1,4,8,16
//channelnum: 0-5 general channel
//transnum: number of to be transed data,by source data width
//
//note: destsize is omitted,because sourcewidth*sourcesize
// must=destwidth*destsize
U32 temp;
U32 tempdata,temp1,temp2,temp3;
U32 tempsrc,tempdest,tempcontrol,tempconfig; //These 4 temp regiser address rariable are used to replase registers
// of registers of channel which is used now
temp = channelnum;
tempsrc = DMACbase + 0x1000 + temp*0x100; //replase registers of channel to be used;
tempdest = DMACbase + 0x1004 + temp*0x100;
*(RP)tempsrc = srcadd;
*(RP)tempdest = destadd;
tempcontrol = DMACbase + 0x100c + temp*0x100;
tempconfig = DMACbase + 0x1010 + temp*0x100;
temp1 = (transnum << 2) + 0x1; //8th and 9th bit set to 1:srcadd and destadd are increasing during transaction;
temp2 = temp1 << 12; //set trans number,10th--21bit,(<4k)
//21th--10th bits determine total transcation data size;
if ((srcwidth == 0x32)&&(destwidth == 0x32)&&(srcsize == 0x4))
temp3 = 0x49b;
else if ((srcwidth == 0x32)&&(destwidth == 0x32)&&(srcsize == 0x8))
temp3 = 0x4ad;
else if ((srcwidth == 0x32)&&(destwidth == 0x32)&&(srcsize == 0x16))
temp3 = 0x4bf;
else if ((srcwidth == 0x32)&&(destwidth == 0x16)&&(srcsize == 0x8))
temp3 = 0x2bd;
else if ((srcwidth == 0x32)&&(destwidth == 0x16)&&(srcsize == 0x4))
temp3 = 0x2ab;
else if ((srcwidth == 0x32)&&(destwidth == 0x8)&&(srcsize == 0x4))
temp3 = 0x0bb;
else if ((srcwidth == 0x16)&&(destwidth == 0x32)&&(srcsize == 0x16))
temp3 = 0x46f;
else if ((srcwidth == 0x16)&&(destwidth == 0x32)&&(srcsize == 0x8))
temp3 = 0x45d;
else if ((srcwidth == 0x16)&&(destwidth == 0x16)&&(srcsize == 0x4))
temp3 = 0x25b;
else if ((srcwidth == 0x16)&&(destwidth == 0x16)&&(srcsize == 0x8))
temp3 = 0x26d;
else if ((srcwidth == 0x16)&&(destwidth == 0x16)&&(srcsize == 0x16))
temp3 = 0x27f;
else if ((srcwidth == 0x16)&&(destwidth == 0x8)&&(srcsize == 0x4))
temp3 = 0x06b;
else if ((srcwidth == 0x16)&&(destwidth == 0x8)&&(srcsize == 0x8))
temp3 = 0x07d;
else if ((srcwidth == 0x8)&&(destwidth == 0x32)&&(srcsize == 0x16))
temp3 = 0x41f;
else if ((srcwidth == 0x8)&&(destwidth == 0x16)&&(srcsize == 0x16))
temp3 = 0x22f;
else if ((srcwidth == 0x8)&&(destwidth == 0x16)&&(srcsize == 0x8))
temp3 = 0x21d;
else if ((srcwidth == 0x8)&&(destwidth == 0x8)&&(srcsize == 0x4))
temp3 = 0x01b;
else if ((srcwidth == 0x8)&&(destwidth == 0x8)&&(srcsize == 0x8))
temp3 = 0x02d;
else if ((srcwidth == 0x8)&&(destwidth == 0x8)&&(srcsize == 0x16))
temp3 = 0x03f;
//19 transcation patterns altogether,change with sourcewith,destwith,
// sourcesize and destsize.
//0th --7th bits determine which pattern is to be used;
tempdata = temp2 + temp3; //Set the control register;
*(RP)tempcontrol = tempdata;
if((longpk == LONGPKSTATE) ||( (((blkstate == BLKCMD) || (blkstate == BLKPRO)) && (epstate == EPBULK)))){
*(RP)tempconfig =0X80b;
}else{
*(RP)tempconfig =0X81b;
}
/*
temp = *(RP)tempconfig; //judge the last trans edned or not?
while( (temp & 0x1) != 0x0)
{
temp = *(RP)tempconfig;
}
*/
return 0;
}
ER HA_DMA_TRANS_TX1(U32 srcadd, U32 destadd, U32 srcwidth, U32 destwidth, U32 srcsize, U32 channelnum, U32 transnum)
{
//Parameters Notes:
//sourcewidth: byte/halfword/word
//destwidth: byte/halfword/word
//sourcesize: 1,4,8,16
//channelnum: 0-5 general channel
//transnum: number of to be transed data,by source data width
//
//note: destsize is omitted,because sourcewidth*sourcesize
// must=destwidth*destsize
U32 temp;
U32 tempdata,temp1,temp2,temp3;
U32 tempsrc,tempdest,tempcontrol,tempconfig; //These 4 temp regiser address rariable are used to replase registers
// of registers of channel which is used now
temp = channelnum;
tempsrc = DMACbase + 0x1000 + temp*0x100; //replase registers of channel to be used;
tempdest = DMACbase + 0x1004 + temp*0x100;
*(RP)tempsrc = srcadd;
*(RP)tempdest = destadd;
tempcontrol = DMACbase + 0x100c + temp*0x100;
tempconfig = DMACbase + 0x1010 + temp*0x100;
temp1 = (transnum << 2) + 0x1; //8th and 9th bit set to 1:srcadd and destadd are increasing during transaction;
temp2 = temp1 << 12; //set trans number,10th--21bit,(<4k)
//21th--10th bits determine total transcation data size;
if ((srcwidth == 0x32)&&(destwidth == 0x32)&&(srcsize == 0x4))
temp3 = 0x49b;
else if ((srcwidth == 0x32)&&(destwidth == 0x32)&&(srcsize == 0x8))
temp3 = 0x4ad;
else if ((srcwidth == 0x32)&&(destwidth == 0x32)&&(srcsize == 0x16))
temp3 = 0x4bf;
else if ((srcwidth == 0x32)&&(destwidth == 0x16)&&(srcsize == 0x8))
temp3 = 0x2bd;
else if ((srcwidth == 0x32)&&(destwidth == 0x16)&&(srcsize == 0x4))
temp3 = 0x2ab;
else if ((srcwidth == 0x32)&&(destwidth == 0x8)&&(srcsize == 0x4))
temp3 = 0x0bb;
else if ((srcwidth == 0x16)&&(destwidth == 0x32)&&(srcsize == 0x16))
temp3 = 0x46f;
else if ((srcwidth == 0x16)&&(destwidth == 0x32)&&(srcsize == 0x8))
temp3 = 0x45d;
else if ((srcwidth == 0x16)&&(destwidth == 0x16)&&(srcsize == 0x4))
temp3 = 0x25b;
else if ((srcwidth == 0x16)&&(destwidth == 0x16)&&(srcsize == 0x8))
temp3 = 0x26d;
else if ((srcwidth == 0x16)&&(destwidth == 0x16)&&(srcsize == 0x16))
temp3 = 0x27f;
else if ((srcwidth == 0x16)&&(destwidth == 0x8)&&(srcsize == 0x4))
temp3 = 0x06b;
else if ((srcwidth == 0x16)&&(destwidth == 0x8)&&(srcsize == 0x8))
temp3 = 0x07d;
else if ((srcwidth == 0x8)&&(destwidth == 0x32)&&(srcsize == 0x16))
temp3 = 0x41f;
else if ((srcwidth == 0x8)&&(destwidth == 0x16)&&(srcsize == 0x16))
temp3 = 0x22f;
else if ((srcwidth == 0x8)&&(destwidth == 0x16)&&(srcsize == 0x8))
temp3 = 0x21d;
else if ((srcwidth == 0x8)&&(destwidth == 0x8)&&(srcsize == 0x4))
temp3 = 0x01b;
else if ((srcwidth == 0x8)&&(destwidth == 0x8)&&(srcsize == 0x8))
temp3 = 0x02d;
else if ((srcwidth == 0x8)&&(destwidth == 0x8)&&(srcsize == 0x16))
temp3 = 0x03f;
//19 transcation patterns altogether,change with sourcewith,destwith,
// sourcesize and destsize.
//0th --7th bits determine which pattern is to be used;
tempdata = temp2 + temp3; //Set the control register;
*(RP)tempcontrol = tempdata;
*(RP)tempconfig =0X81b;
/*
temp = *(RP)tempconfig; //judge the last trans edned or not?
while( (temp & 0x1) != 0x0)
{
temp = *(RP)tempconfig;
}
*/
return 0;
}
ER HA_DMA_INITIAL_ONECHANNEL(U32 channelnum) //Initialze just 1 channel,clear error interuppt and
{ // accomplishment interrupt.
U32 temp = 0x1;
U32 num;
num = channelnum;
while(num != 0)
{
temp = temp*2;
num = num - 1;
}
*(RP)DMACIntErrClr = (U32)temp; //clear action;
*(RP)DMACIntTCClear =(U32)temp;
*(RP)DMACIntErrClr =0x00000000;
*(RP)DMACIntTCClear =0x00000000;
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -