Example #1
0
/*******************************************************************************
* mvCpuIfAddDecShow - Print the CPU address decode map.
*
* DESCRIPTION:
*		This function print the CPU address decode map.
*
* INPUT:
*       None.
*
* OUTPUT:
*       None.
*
* RETURN:
*       None.
*
*******************************************************************************/
MV_VOID mvCpuIfAddDecShow(MV_VOID)
{
    MV_CPU_DEC_WIN win;
    MV_U32 target;
    mvOsOutput( "\n" );
    mvOsOutput( "CPU Interface\n" );
    mvOsOutput( "-------------\n" );

    for( target = 0; target < MAX_TARGETS; target++ )
    {

        memset( &win, 0, sizeof(MV_CPU_DEC_WIN) );

        mvOsOutput( "%s ",mvCtrlTargetNameGet(target));
        mvOsOutput( "...." );

        if( mvCpuIfTargetWinGet( target, &win ) == MV_OK )
        {
            if( win.enable )
            {
                mvOsOutput( "base %08x, ", win.addrWin.baseLow );
                mvSizePrint( win.addrWin.size );
                mvOsOutput( "\n" );

            }
            else
                mvOsOutput( "disable\n" );
        }
        else if( mvCpuIfTargetWinGet( target, &win ) == MV_NO_SUCH )
        {
            mvOsOutput( "no such\n" );
        }
    }
}
Example #2
0
static MV_VOID mvXorAddrDecShowUnit(MV_U32 unit)
{
	MV_XOR_DEC_WIN win;
	int            i;

	mvOsOutput( "\n" );
	mvOsOutput( "XOR %d:\n", unit );
	mvOsOutput( "----\n" );

	for( i = 0; i < XOR_MAX_ADDR_DEC_WIN; i++ )
	{
		memset( &win, 0, sizeof(MV_XOR_DEC_WIN) );

		mvOsOutput( "win%d - ", i );

		if( mvXorTargetWinGet(unit, i, &win ) == MV_OK )
		{
			if( win.enable )
			{
				mvOsOutput( "%s base %x, ",
				mvCtrlTargetNameGet(win.target), win.addrWin.baseLow );

				mvSizePrint( win.addrWin.size );
				
                mvOsOutput( "\n" );
			}
			else
				mvOsOutput( "disable\n" );
		}
	}
}
Example #3
0
/*******************************************************************************
* mvAudioAddrDecShow - Print the AUDIO address decode map.
*
* DESCRIPTION:
*		This function print the AUDIO address decode map.
*
* INPUT:
*       None.
*
* OUTPUT:
*       None.
*
* RETURN:
*       None.
*
*******************************************************************************/
MV_VOID mvAudioUnitAddrDecShow(int unit)
{
	MV_AUDIO_DEC_WIN win;
	int i;

	mvOsOutput( "\n" );
	mvOsOutput( "AUDIO:\n" );
	mvOsOutput( "----\n" );

	for( i = 0; i < MV_AUDIO_MAX_ADDR_DECODE_WIN; i++ )
	{
            memset( &win, 0, sizeof(MV_AUDIO_DEC_WIN) );

	    mvOsOutput( "win%d - ", i );

	    if( mvAudioWinGet(unit, i, &win) == MV_OK )
	    {
	        if( win.enable )
	        {
                    mvOsOutput( "%s base %08x, ",
                    mvCtrlTargetNameGet(win.target), win.addrWin.baseLow );
                    mvOsOutput( "...." );

                    mvSizePrint( win.addrWin.size );
    
		    mvOsOutput( "\n" );
                }
		else
		mvOsOutput( "disable\n" );
	    }
	}
}
Example #4
0
MV_VOID mvTdmAddrDecShow(MV_VOID)
{
	MV_TDM_DEC_WIN win;
	int i;

	mvOsOutput( "\n" );
	mvOsOutput( "TDM:\n" );
	mvOsOutput( "----\n" );

	for( i = 0; i < TDM_MBUS_MAX_WIN; i++ )
	{
		memset( &win, 0, sizeof(MV_TDM_DEC_WIN) );

		mvOsOutput( "win%d - ", i );

		if (mvTdmWinGet(i, &win ) == MV_OK )
		{
			if( win.enable )
			{
                mvOsOutput( "%s base %08x, ",
                mvCtrlTargetNameGet(win.target), win.addrWin.baseLow);
                mvOsOutput( "...." );
                mvSizePrint( win.addrWin.size );
				mvOsOutput( "\n" );
			}
			else
				mvOsOutput( "disable\n" );
		}
	}
}
Example #5
0
/*******************************************************************************
* mvEthAddrDecShow - Print the Etherent address decode map.
*
* DESCRIPTION:
*       This function print the Etherent address decode map.
*
* INPUT:
*       None.
*
* OUTPUT:
*       None.
*
* RETURN:
*       None.
*
*******************************************************************************/
void    mvEthPortAddrDecShow(int port)
{
    MV_ETH_DEC_WIN  win;
    int             i;

    mvOsOutput( "\n" );
    mvOsOutput( "ETH #%d:\n", port );
    mvOsOutput( "----\n" );

    for( i = 0; i < ETH_MAX_DECODE_WIN; i++ )
    {
        memset( &win, 0, sizeof(ETH_MAX_DECODE_WIN) );

        mvOsOutput( "win%d - ", i );

        if( mvEthWinGet(port, i, &win ) == MV_OK )
        {
            if( win.enable )
            {
                mvOsOutput( "%s base %08x, ",
                mvCtrlTargetNameGet(win.target), win.addrWin.baseLow );
                mvOsOutput( "...." );
                mvSizePrint( win.addrWin.size );

                mvOsOutput( "\n" );
            }
            else
                mvOsOutput( "disable\n" );
        }
    }
    return;
}
Example #6
0
/*******************************************************************************
* mvAhbToMbusAddDecShow - Print the AHB to MBus bridge address decode map.
*
* DESCRIPTION:
*		This function print the CPU address decode map.
*
* INPUT:
*       None.
*
* OUTPUT:
*       None.
*
* RETURN:
*       None.
*
*******************************************************************************/
MV_VOID mvAhbToMbusAddDecShow(MV_VOID)
{
	MV_AHB_TO_MBUS_DEC_WIN win;
	MV_U32 winNum;
	mvOsOutput( "\n" );
	mvOsOutput( "AHB To MBUS Bridge:\n" );
	mvOsOutput( "-------------------\n" );

	for( winNum = 0; winNum < MAX_AHB_TO_MBUS_WINS; winNum++ )
	{
		memset( &win, 0, sizeof(MV_AHB_TO_MBUS_DEC_WIN) );

		mvOsOutput( "win%d - ", winNum );

		if( mvAhbToMbusWinGet( winNum, &win ) == MV_OK )
		{
			if( win.enable )
			{
				mvOsOutput( "%s base %08x, ",
				mvCtrlTargetNameGet(win.target), win.addrWin.baseLow );
                		mvOsOutput( "...." );
				mvSizePrint( win.addrWin.size );

				mvOsOutput( "\n" );

            }
			else
				mvOsOutput( "disable\n" );
		}
	}

}
Example #7
0
/*******************************************************************************
* mvAudioWinSet - Set AUDIO target address window
*
* DESCRIPTION:
*       This function sets a peripheral target (e.g. SDRAM bank0, PCI_MEM0) 
*       address window, also known as address decode window. 
*       After setting this target window, the AUDIO will be able to access the 
*       target within the address window. 
*
* INPUT:
*       winNum      - AUDIO target address decode window number.
*       pAddrDecWin - AUDIO target window data structure.
*
* OUTPUT:
*       None.
*
* RETURN:
*       MV_ERROR if address window overlapps with other address decode windows.
*       MV_BAD_PARAM if base address is invalid parameter or target is 
*       unknown.
*
*******************************************************************************/
MV_STATUS mvAudioWinSet(int unit, MV_U32 winNum, MV_AUDIO_DEC_WIN *pAddrDecWin)
{
    MV_TARGET_ATTRIB    targetAttribs;
    MV_DEC_REGS         decRegs;

    /* Parameter checking   */
    if (winNum >= MV_AUDIO_MAX_ADDR_DECODE_WIN)
    {
        mvOsPrintf("%s: ERR. Invalid win num %d\n",__FUNCTION__, winNum);
        return MV_BAD_PARAM;
    }
    
    /* check if address is aligned to the size */
    if(MV_IS_NOT_ALIGN(pAddrDecWin->addrWin.baseLow, pAddrDecWin->addrWin.size))
    {
		mvOsPrintf("mvAudioWinSet:Error setting AUDIO window %d to "\
			   "target %s.\nAddress 0x%08x is unaligned to size 0x%x.\n",
			   winNum,
			   mvCtrlTargetNameGet(pAddrDecWin->target), 
			   pAddrDecWin->addrWin.baseLow,
			   pAddrDecWin->addrWin.size);
		return MV_ERROR;
    }

    decRegs.baseReg = 0;
    decRegs.sizeReg = 0;

    if (MV_OK != mvCtrlAddrDecToReg(&(pAddrDecWin->addrWin),&decRegs))
    {
        mvOsPrintf("%s: mvCtrlAddrDecToReg Failed\n", __FUNCTION__);
        return MV_ERROR;
    }

    mvCtrlAttribGet(pAddrDecWin->target, &targetAttribs);
                                                                                                                         
    /* set attributes */
    decRegs.sizeReg &= ~MV_AUDIO_WIN_ATTR_MASK;
    decRegs.sizeReg |= (targetAttribs.attrib << MV_AUDIO_WIN_ATTR_OFFSET);

    /* set target ID */
    decRegs.sizeReg &= ~MV_AUDIO_WIN_TARGET_MASK;
    decRegs.sizeReg |= (targetAttribs.targetId << MV_AUDIO_WIN_TARGET_OFFSET);

    if (pAddrDecWin->enable == MV_TRUE)
    {
        decRegs.sizeReg |= MV_AUDIO_WIN_ENABLE_MASK;
    }
    else
    {
        decRegs.sizeReg &= ~MV_AUDIO_WIN_ENABLE_MASK;
    }

    MV_REG_WRITE( MV_AUDIO_WIN_CTRL_REG(unit, winNum), decRegs.sizeReg);
    MV_REG_WRITE( MV_AUDIO_WIN_BASE_REG(unit, winNum), decRegs.baseReg);
    
    return MV_OK;
}
Example #8
0
static MV_VOID mvXorAddrDecShowUnit(MV_U32 unit)
{
	MV_UNIT_WIN_INFO win;
	int            	 i;

	mvOsOutput( "\n" );
	mvOsOutput( "XOR %d:\n", unit );
	mvOsOutput( "----\n" );

	for( i = 0; i < XOR_MAX_ADDR_DEC_WIN; i++ )
	{
		memset( &win, 0, sizeof(MV_UNIT_WIN_INFO) );

		mvOsOutput( "win%d - ", i );

		if( mvXorTargetWinRead(unit, i, &win ) == MV_OK )
		{
			if( win.enable )
			{
				/* In MV88F6781 there is no differentiation between different DRAM Chip Selects,	*/
				/* they all use the same target ID and attributes. So in order to print correctly	*/
				/* we use i as the target. When i is 1 it is SDRAM_CS1 etc.				*/
				if (mvCtrlTargetByWinInfoGet(&win) != SDRAM_CS0) {
					mvOsOutput( "%s base %08x, ",
						mvCtrlTargetNameGet(mvCtrlTargetByWinInfoGet(&win)), win.addrWin.baseLow);
				}
				else {
		                	mvOsOutput( "%s base %08x, ",
                				mvCtrlTargetNameGet(i), win.addrWin.baseLow);
				}

				mvSizePrint( win.addrWin.size );
				mvOsOutput( "\n" );
			}
			else
				mvOsOutput( "disable\n" );
		}
	}
}
Example #9
0
/*******************************************************************************
* mvSataAddrDecShow - Print the SATA address decode map.
*
* DESCRIPTION:
*		This function print the SATA address decode map.
*
* INPUT:
*       None.
*
* OUTPUT:
*       None.
*
* RETURN:
*       None.
*
*******************************************************************************/
MV_VOID mvSataAddrDecShow(MV_VOID)
{

    MV_SATA_DEC_WIN win;
    int i,j;



    for( j = 0; j < MV_SATA_MAX_CHAN; j++ )
    {
        if (MV_FALSE == mvCtrlPwrClckGet(SATA_UNIT_ID, j))
            return;

        mvOsOutput( "\n" );
        mvOsOutput( "SATA %d:\n", j );
        mvOsOutput( "----\n" );

        for( i = 0; i < MV_SATA_MAX_ADDR_DECODE_WIN; i++ )
        {
            memset( &win, 0, sizeof(MV_SATA_DEC_WIN) );

            mvOsOutput( "win%d - ", i );

            if( mvSataWinGet(j, i, &win ) == MV_OK )
            {
                if( win.enable )
                {
                    mvOsOutput( "%s base %08x, ",
                                mvCtrlTargetNameGet(win.target), win.addrWin.baseLow );
                    mvOsOutput( "...." );

                    mvSizePrint( win.addrWin.size );

                    mvOsOutput( "\n" );
                }
                else
                    mvOsOutput( "disable\n" );
            }
        }
    }
}
Example #10
0
/*******************************************************************************
* mvAhbToMbusAddDecShow - Print the Ahb to MBus bridge address decode map.
*
* DESCRIPTION:
*		This function print the CPU address decode map.
*
* INPUT:
*       cpu      	- CPU id
*
* OUTPUT:
*       None.
*
* RETURN:
*       None.
*
*******************************************************************************/
MV_VOID mvAhbToMbusAddDecShow(MV_U32 cpu)
{
	MV_AHB_TO_MBUS_DEC_WIN win;
	MV_U32 winNum;
	/* Check parameters */
	if (cpu >= MV_MAX_CPU)
	{
		mvOsPrintf("mvAhbToMbusAddDecShow: ERR. Invalid cpu %d\n", cpu);
		return;
	}

	mvOsOutput( "\n" );
	mvOsOutput( "CPU %d, AHB To MBUS Bridge:\n", cpu);
	mvOsOutput( "-------------------\n" );

	for( winNum = 0; winNum < MAX_AHB_TO_MBUS_WINS; winNum++ ) 
	{
		memset( &win, 0, sizeof(MV_AHB_TO_MBUS_DEC_WIN) );

		mvOsOutput( "win%d - ", winNum );

		if( mvAhbToMbusWinGet(cpu, winNum, &win ) == MV_OK )
		{
			if( win.enable )
			{
				mvOsOutput( "%s base %08x, ",
				mvCtrlTargetNameGet(win.target), win.addrWin.baseLow );
                		mvOsOutput( "...." );
				mvSizePrint( win.addrWin.size );
				mvOsOutput( "\n" );
			}
			else
				mvOsOutput( "disable\n" );
		}
	}
}
Example #11
0
/*******************************************************************************
* mvTsuAddrDecShow
*
* DESCRIPTION:
*	Print the TSU address decode map.
*
* INPUT:
*       None.
*
* OUTPUT:
*       None.
*
* RETURN:
*       None.
*
*******************************************************************************/
void mvTsuAddrDecShow(void)
{
	MV_TSU_DEC_WIN  win;
	int             i;

	if (MV_FALSE == mvCtrlPwrClckGet(TS_UNIT_ID, 0))
		return;

	mvOsOutput( "\n" );
	mvOsOutput( "TSU:\n");
	mvOsOutput( "----\n" );

	for(i = 0; i < TSU_MAX_DECODE_WIN; i++)
	{
		memset(&win, 0, sizeof(TSU_MAX_DECODE_WIN));
		mvOsOutput( "win%d - ", i );

		if(mvTsuWinGet(i, &win ) == MV_OK )
		{
			if(win.enable == MV_TRUE)
			{
				mvOsOutput("%s base %08x, ",
					   mvCtrlTargetNameGet(win.target),
					   win.addrWin.baseLow);
				mvOsOutput( "...." );
				mvSizePrint(win.addrWin.size );
				mvOsOutput( "\n" );
			}
			else
			{
				mvOsOutput( "disable\n" );
			}
		}
	}
	return;
}
Example #12
0
/*******************************************************************************
* mvTsuWinSet
*
* DESCRIPTION:
*       This function sets a peripheral target (e.g. SDRAM bank0, PCI_MEM0)
*       address window, also known as address decode window.
*       After setting this target window, the TSU will be able to access the
*       target within the address window.
*
* INPUT:
*       winNum      - TSU to target address decode window number.
*       pAddrDecWin - TSU target window data structure.
*
* OUTPUT:
*       None.
*
* RETURN:
*       MV_ERROR	- if address window overlapps with other address decode
*			windows.
*       MV_BAD_PARAM	- if base address is invalid parameter or target is
*			unknown.
*
*******************************************************************************/
MV_STATUS mvTsuWinSet(MV_U32 winNum, MV_TSU_DEC_WIN *pAddrDecWin)
{
	MV_TARGET_ATTRIB    targetAttribs;
	MV_DEC_REGS         decRegs;

	/* Parameter checking   */
	if(winNum >= TSU_MAX_DECODE_WIN)
	{
		mvOsPrintf("mvTsuWinSet: ERR. Invalid win num %d\n",winNum);
		return MV_BAD_PARAM;
	}

	/* Check if the requested window overlapps with current windows     */
	if(MV_TRUE == tsuWinOverlapDetect(winNum, &pAddrDecWin->addrWin))
	{
		mvOsPrintf("mvTsuWinSet: ERR. Window %d overlap\n", winNum);
		return MV_ERROR;
	}

	/* check if address is aligned to the size */
	if(MV_IS_NOT_ALIGN(pAddrDecWin->addrWin.baseLow,pAddrDecWin->addrWin.size))
	{
		mvOsPrintf("mvTsuWinSet: Error setting TSU window %d to target "
			   "%s.\nAddress 0x%08x is unaligned to size 0x%x.\n",
			   winNum, mvCtrlTargetNameGet(pAddrDecWin->target),
			   pAddrDecWin->addrWin.baseLow,
			   pAddrDecWin->addrWin.size);
		return MV_ERROR;
	}

	decRegs.baseReg = MV_REG_READ(MV_TSU_WIN_BASE_REG(winNum));
	decRegs.sizeReg = MV_REG_READ(MV_TSU_WIN_CTRL_REG(winNum));

	if(MV_OK != mvCtrlAddrDecToReg(&(pAddrDecWin->addrWin),&decRegs))
	{
		mvOsPrintf("mvTsuWinSet: mvCtrlAddrDecToReg Failed\n");
		return MV_ERROR;
	}

	mvCtrlAttribGet(pAddrDecWin->target,&targetAttribs);

	/* set attributes */
	decRegs.sizeReg &= ~TSU_WIN_CTRL_ATTR_MASK;
	decRegs.sizeReg |= targetAttribs.attrib << TSU_WIN_CTRL_ATTR_OFFS;
	/* set target ID */
	decRegs.sizeReg &= ~TSU_WIN_CTRL_TARGET_MASK;
	decRegs.sizeReg |= targetAttribs.targetId << TSU_WIN_CTRL_TARGET_OFFS;

	/* for the safe side we disable the window before writing the new */
	/* values */
	mvTsuWinEnable(winNum, MV_FALSE);
	MV_REG_WRITE(MV_TSU_WIN_CTRL_REG(winNum),decRegs.sizeReg);

	/* Write to address decode Size Register                            */
	MV_REG_WRITE(MV_TSU_WIN_BASE_REG(winNum), decRegs.baseReg);

	/* Enable address decode target window                              */
	if(pAddrDecWin->enable == MV_TRUE)
	{
		mvTsuWinEnable(winNum,MV_TRUE);
	}

	return MV_OK;
}
Example #13
0
/*******************************************************************************
* mvAhbToMbusWinSet - Set CPU-to-peripheral winNum address window
*
* DESCRIPTION:
*       This function sets
*       address window, also known as address decode window.
*       A new address decode window is set for specified winNum address window.
*       If address decode window parameter structure enables the window,
*       the routine will also enable the winNum window, allowing CPU to access
*       the winNum window.
*
* INPUT:
*       winNum      - Windows number.
*       pAddrDecWin - CPU winNum window data structure.
*
* OUTPUT:
*       N/A
*
* RETURN:
*       MV_OK if CPU winNum window was set correctly, MV_ERROR in case of
*       address window overlapps with other active CPU winNum window or
*		trying to assign 36bit base address while CPU does not support that.
*       The function returns MV_NOT_SUPPORTED, if the winNum is unsupported.
*
*******************************************************************************/
MV_STATUS mvAhbToMbusWinSet(MV_U32 winNum, MV_AHB_TO_MBUS_DEC_WIN *pAddrDecWin)
{
	MV_TARGET_ATTRIB targetAttribs;
	MV_DEC_REGS decRegs;
	MV_U32 sizeToReg;

	/* Parameter checking   */
	if (winNum >= MAX_AHB_TO_MBUS_WINS) {
		mvOsPrintf("mvAhbToMbusWinSet: ERR. Invalid winNum %d\n", winNum);
		return MV_NOT_SUPPORTED;
	}

	/* check if address is aligned to the size */
	if (MV_IS_NOT_ALIGN(pAddrDecWin->addrWin.baseLow, pAddrDecWin->addrWin.size)) {
		mvOsPrintf("mvAhbToMbusWinSet:Error setting AHB to MBUS window %d to "
			   "target %s.\nAddress 0x%08x is unaligned to size 0x%llx.\n",
			   winNum,
			   mvCtrlTargetNameGet(pAddrDecWin->target),
			   pAddrDecWin->addrWin.baseLow, pAddrDecWin->addrWin.size);
		return MV_ERROR;
	}

	/* Size parameter validity check.                       */
	if (MV_IS_NOT_ALIGN(pAddrDecWin->addrWin.size, ATMWCR_WIN_SIZE_ALIGNMENT)) {
		mvOsPrintf("mvAhbToMbusWinSet: Failed, size not aligned to 0x%x.\n", ATMWCR_WIN_SIZE_ALIGNMENT);
		return MV_BAD_PARAM;
	}

	/* Write to address decode Base Address Register        */
	decRegs.baseReg = (pAddrDecWin->addrWin.baseLow & ATMWBR_BASE_MASK);

	/* Get size register value according to window size     */
	sizeToReg = (pAddrDecWin->addrWin.size / ATMWCR_WIN_SIZE_ALIGNMENT) - 1;

	/* set size                                             */
	decRegs.ctrlReg = (sizeToReg << ATMWCR_WIN_SIZE_OFFS);

	/* enable\Disable */
	if (MV_TRUE == pAddrDecWin->enable)
		decRegs.ctrlReg |= ATMWCR_WIN_ENABLE;
	else
		decRegs.ctrlReg &= ~ATMWCR_WIN_ENABLE;

	mvCtrlAttribGet(pAddrDecWin->target, &targetAttribs);

	/* set attributes */
	decRegs.ctrlReg &= ~ATMWCR_WIN_ATTR_MASK;
	decRegs.ctrlReg |= targetAttribs.attrib << ATMWCR_WIN_ATTR_OFFS;
	/* set target ID */
	decRegs.ctrlReg &= ~ATMWCR_WIN_TARGET_MASK;
	decRegs.ctrlReg |= targetAttribs.targetId << ATMWCR_WIN_TARGET_OFFS;

#if !defined(MV_RUN_FROM_FLASH)
	/* To be on the safe side we disable the window before writing the  */
	/* new values.                                                      */
	if (winNum != MV_AHB_TO_MBUS_INTREG_WIN)
		mvAhbToMbusWinEnable(winNum, MV_FALSE);
#endif

	/* 3) Write to address decode Base Address Register                   */
	if (winNum != MV_AHB_TO_MBUS_INTREG_WIN)
		MV_REG_WRITE(AHB_TO_MBUS_WIN_BASE_REG(winNum), decRegs.baseReg);
	else
		MV_REG_WRITE(AHB_TO_MBUS_WIN_INTEREG_REG, decRegs.baseReg);

	/* Internal register space have no size */
	/* register. Do not perform size register assigment for those targets   */
	if (winNum != MV_AHB_TO_MBUS_INTREG_WIN) {
		/* Write to address decode Size Register                                */
		MV_REG_WRITE(AHB_TO_MBUS_WIN_CTRL_REG(winNum), decRegs.ctrlReg);
	}

	return MV_OK;
}
Example #14
0
/*******************************************************************************
* mvUsbWinSet - Set USB target address window
*
* DESCRIPTION:
*       This function sets a peripheral target (e.g. SDRAM bank0, PCI_MEM0)
*       address window, also known as address decode window.
*       After setting this target window, the USB will be able to access the
*       target within the address window.
*
* INPUT:
*       winNum      - USB target address decode window number.
*       pAddrDecWin - USB target window data structure.
*
* OUTPUT:
*       None.
*
* RETURN:
*       MV_ERROR if address window overlapps with other address decode windows.
*       MV_BAD_PARAM if base address is invalid parameter or target is
*       unknown.
*
*******************************************************************************/
MV_STATUS mvUsbWinSet(int dev, MV_U32 winNum, MV_DEC_WIN *pDecWin)
{
    MV_DEC_WIN_PARAMS   winParams;
    MV_U32              sizeReg, baseReg;

    /* Parameter checking   */
    if (winNum >= MV_USB_MAX_ADDR_DECODE_WIN)
    {
        mvOsPrintf("%s: ERR. Invalid win num %d\n",__FUNCTION__, winNum);
        return MV_BAD_PARAM;
    }

    /* Check if the requested window overlapps with current windows         */
    if (MV_TRUE == usbWinOverlapDetect(dev, winNum, &pDecWin->addrWin))
    {
        mvOsPrintf("%s: ERR. Window %d overlap\n", __FUNCTION__, winNum);
        return MV_ERROR;
    }

    /* check if address is aligned to the size */
    if(MV_IS_NOT_ALIGN(pDecWin->addrWin.baseLow, pDecWin->addrWin.size))
    {
        mvOsPrintf("mvUsbWinSet:Error setting USB window %d to "\
                   "target %s.\nAddress 0x%08x is unaligned to size 0x%x.\n",
                   winNum,
                   mvCtrlTargetNameGet(pDecWin->target),
                   pDecWin->addrWin.baseLow,
                   pDecWin->addrWin.size);
        return MV_ERROR;
    }

    if(MV_OK != mvCtrlAddrDecToParams(pDecWin, &winParams))
    {
        mvOsPrintf("%s: mvCtrlAddrDecToParams Failed\n", __FUNCTION__);
        return MV_ERROR;
    }

    /* set Size, Attributes and TargetID */
    sizeReg = (((winParams.targetId << MV_USB_WIN_TARGET_OFFSET) & MV_USB_WIN_TARGET_MASK) |
               ((winParams.attrib   << MV_USB_WIN_ATTR_OFFSET)   & MV_USB_WIN_ATTR_MASK)   |
               ((winParams.size << MV_USB_WIN_SIZE_OFFSET) & MV_USB_WIN_SIZE_MASK));

#if defined(MV645xx) || defined(MV646xx)
    /* If window is DRAM with HW cache coherency, make sure bit2 is set */
    sizeReg &= ~MV_USB_WIN_BURST_WR_LIMIT_MASK;

    if((MV_TARGET_IS_DRAM(pDecWin->target)) &&
       (pDecWin->addrWinAttr.cachePolicy != NO_COHERENCY))
    {
        sizeReg |= MV_USB_WIN_BURST_WR_32BIT_LIMIT;
    }
    else
    {
        sizeReg |= MV_USB_WIN_BURST_WR_NO_LIMIT;
    }
#endif /* MV645xx || MV646xx */

    if (pDecWin->enable == MV_TRUE)
    {
        sizeReg |= MV_USB_WIN_ENABLE_MASK;
    }
    else
    {
        sizeReg &= ~MV_USB_WIN_ENABLE_MASK;
    }

    /* Update Base value  */
    baseReg = (winParams.baseAddr & MV_USB_WIN_BASE_MASK);

    MV_REG_WRITE( MV_USB_WIN_CTRL_REG(dev, winNum), sizeReg);
    MV_REG_WRITE( MV_USB_WIN_BASE_REG(dev, winNum), baseReg);

    return MV_OK;
}
Example #15
0
/*******************************************************************************
* mvUsbAddrDecShow - Print the USB address decode map.
*
* DESCRIPTION:
*       This function print the USB address decode map.
*
* INPUT:
*       None.
*
* OUTPUT:
*       None.
*
* RETURN:
*       None.
*
*******************************************************************************/
MV_VOID mvUsbAddrDecShow(MV_VOID)
{
    MV_UNIT_WIN_INFO	addrDecWin;
    int         	i, winNum;

    mvOsOutput( "\n" );
    mvOsOutput( "USB:\n" );
    mvOsOutput( "----\n" );

    for(i=0; i<mvCtrlUsbMaxGet(); i++)
    {
        mvOsOutput( "Device %d:\n", i);

        for(winNum = 0; winNum < MV_USB_MAX_ADDR_DECODE_WIN; winNum++)
        {
            memset(&addrDecWin, 0, sizeof(MV_DEC_WIN) );

            mvOsOutput( "win%d - ", winNum );

            if( mvUsbWinRead(i, winNum, &addrDecWin ) == MV_OK )
            {
                if( addrDecWin.enable )
                {
			/* In MV88F6781 there is no differentiation between different DRAM Chip Selects,	*/
			/* they all use the same target ID and attributes. So in order to print correctly	*/
			/* we use i as the target. When i is 1 it is SDRAM_CS1 etc.				*/
			if (mvCtrlTargetByWinInfoGet(&addrDecWin) != SDRAM_CS0) {
				mvOsOutput( "%s base %08x, ",
                       		mvCtrlTargetNameGet(mvCtrlTargetByWinInfoGet(&addrDecWin)), addrDecWin.addrWin.baseLow );
			}
			else {
				mvOsOutput( "%s base %08x, ",
                        		mvCtrlTargetNameGet(winNum), addrDecWin.addrWin.baseLow);
			}

                    	mvSizePrint( addrDecWin.addrWin.size );

#if defined(MV645xx) || defined(MV646xx)
                    switch( addrDecWin.addrWinAttr.swapType)
                    {
                        case MV_BYTE_SWAP:
                            mvOsOutput( "BYTE_SWAP, " );
                            break;
                        case MV_NO_SWAP:
                            mvOsOutput( "NO_SWAP  , " );
                            break;
                        case MV_BYTE_WORD_SWAP:
                            mvOsOutput( "BYTE_WORD_SWAP, " );
                            break;
                        case MV_WORD_SWAP:
                            mvOsOutput( "WORD_SWAP, " );
                            break;
                        default:
                            mvOsOutput( "SWAP N/A , " );
                    }

                    switch( addrDecWin.addrWinAttr.cachePolicy )
                    {
                        case NO_COHERENCY:
                            mvOsOutput( "NO_COHERENCY , " );
                            break;
                        case WT_COHERENCY:
                            mvOsOutput( "WT_COHERENCY , " );
                            break;
                        case WB_COHERENCY:
                            mvOsOutput( "WB_COHERENCY , " );
                            break;
                        default:
                            mvOsOutput( "COHERENCY N/A, " );
                    }

                    switch( addrDecWin.addrWinAttr.pcixNoSnoop )
                    {
                        case 0:
                            mvOsOutput( "PCI-X NS inactive, " );
                            break;
                        case 1:
                            mvOsOutput( "PCI-X NS active  , " );
                            break;
                        default:
                            mvOsOutput( "PCI-X NS N/A     , " );
                    }

                    switch( addrDecWin.addrWinAttr.p2pReq64 )
                    {
                        case 0:
                            mvOsOutput( "REQ64 force" );
                            break;
                        case 1:
                            mvOsOutput( "REQ64 detect" );
                            break;
                        default:
                            mvOsOutput( "REQ64 N/A" );
                    }
#endif /* MV645xx || MV646xx */
                    mvOsOutput( "\n" );
                }
                else
                    mvOsOutput( "disable\n" );
            }
        }
    }
}
Example #16
0
/*******************************************************************************
* mvAhbToMbusWinSet - Set CPU-to-peripheral winNum address window
*
* DESCRIPTION:
*       This function sets
*       address window, also known as address decode window.
*       A new address decode window is set for specified winNum address window.
*       If address decode window parameter structure enables the window,
*       the routine will also enable the winNum window, allowing CPU to access
*       the winNum window.
*
* INPUT:
*       winNum      - Windows number.
*       pAddrDecWin - CPU winNum window data structure.
*
* OUTPUT:
*       N/A
*
* RETURN:
*       MV_OK if CPU winNum window was set correctly, MV_ERROR in case of
*       address window overlapps with other active CPU winNum window or
*		trying to assign 36bit base address while CPU does not support that.
*       The function returns MV_NOT_SUPPORTED, if the winNum is unsupported.
*
*******************************************************************************/
MV_STATUS mvAhbToMbusWinSet(MV_U32 winNum, MV_AHB_TO_MBUS_DEC_WIN *pAddrDecWin)
{
	MV_TARGET_ATTRIB targetAttribs;
	MV_DEC_REGS decRegs;

	/* Parameter checking   */
	if (winNum >= MAX_AHB_TO_MBUS_WINS)
	{
		mvOsPrintf("mvAhbToMbusWinSet: ERR. Invalid winNum %d\n", winNum);
		return MV_NOT_SUPPORTED;
	}


	/* read base register*/
	if (winNum != MV_AHB_TO_MBUS_INTREG_WIN)
	{
		decRegs.baseReg = MV_REG_READ(AHB_TO_MBUS_WIN_BASE_REG(winNum));
	}
	else
	{
		decRegs.baseReg = MV_REG_READ(AHB_TO_MBUS_WIN_INTEREG_REG);
	}

	/* check if address is aligned to the size */
	if(MV_IS_NOT_ALIGN(pAddrDecWin->addrWin.baseLow, pAddrDecWin->addrWin.size))
	{
		mvOsPrintf("mvAhbToMbusWinSet:Error setting AHB to MBUS window %d to "\
				   "target %s.\nAddress 0x%08x is unaligned to size 0x%x.\n",
				   winNum,
				   mvCtrlTargetNameGet(pAddrDecWin->target),
				   pAddrDecWin->addrWin.baseLow,
				   pAddrDecWin->addrWin.size);
		return MV_ERROR;
	}

	/* read control register*/
	if (winNum != MV_AHB_TO_MBUS_INTREG_WIN)
	{
		decRegs.sizeReg = MV_REG_READ(AHB_TO_MBUS_WIN_CTRL_REG(winNum));
	}

	if (MV_OK != mvCtrlAddrDecToReg(&(pAddrDecWin->addrWin),&decRegs))
	{
		mvOsPrintf("mvAhbToMbusWinSet:mvCtrlAddrDecToReg Failed\n");
		return MV_ERROR;
	}

	/* enable\Disable */
	if (MV_TRUE == pAddrDecWin->enable)
	{
		decRegs.sizeReg |= ATMWCR_WIN_ENABLE;
	}
	else
	{
		decRegs.sizeReg &= ~ATMWCR_WIN_ENABLE;
	}

	mvCtrlAttribGet(pAddrDecWin->target,&targetAttribs);

	/* set attributes */
	decRegs.sizeReg &= ~ATMWCR_WIN_ATTR_MASK;
	decRegs.sizeReg |= targetAttribs.attrib << ATMWCR_WIN_ATTR_OFFS;
	/* set target ID */
	decRegs.sizeReg &= ~ATMWCR_WIN_TARGET_MASK;
	decRegs.sizeReg |= targetAttribs.targetId << ATMWCR_WIN_TARGET_OFFS;

#if !defined(MV_RUN_FROM_FLASH)
    /* To be on the safe side we disable the window before writing the  */
    /* new values.                                                      */
	if (winNum != MV_AHB_TO_MBUS_INTREG_WIN)
	{
		mvAhbToMbusWinEnable(winNum,MV_FALSE);
	}
#endif

	/* 3) Write to address decode Base Address Register                   */
	if (winNum != MV_AHB_TO_MBUS_INTREG_WIN)
	{
		MV_REG_WRITE(AHB_TO_MBUS_WIN_BASE_REG(winNum), decRegs.baseReg);
	}
	else
	{
		MV_REG_WRITE(AHB_TO_MBUS_WIN_INTEREG_REG, decRegs.baseReg);
	}


	/* Internal register space have no size	*/
	/* register. Do not perform size register assigment for those targets 	*/
	if (winNum != MV_AHB_TO_MBUS_INTREG_WIN)
	{
		/* Write to address decode Size Register                        	*/
		MV_REG_WRITE(AHB_TO_MBUS_WIN_CTRL_REG(winNum), decRegs.sizeReg);
	}

    return MV_OK;
}
Example #17
0
/*******************************************************************************
* mvDmaWinSet - Set DMA target address window
*
* DESCRIPTION:
*       This function sets a peripheral target (e.g. SDRAM bank0, PCI_MEM0) 
*       address window, also known as address decode window. 
*       After setting this target window, the DMA will be able to access the 
*       target within the address window. 
*
* INPUT:
*       winNum      - IDMA to target address decode window number.
*       pAddrDecWin - IDMA target window data structure.
*
* OUTPUT:
*       None.
*
* RETURN:
*       MV_ERROR if address window overlapps with other address decode windows.
*       MV_BAD_PARAM if base address is invalid parameter or target is 
*       unknown.
*
*******************************************************************************/
MV_STATUS mvDmaWinSet(MV_U32 winNum, MV_DMA_DEC_WIN *pAddrDecWin)
{
	MV_TARGET_ATTRIB targetAttribs;
        MV_DEC_REGS decRegs;

    /* Parameter checking   */
    if (winNum >= IDMA_MAX_ADDR_DEC_WIN)
    {
		mvOsPrintf("mvDmaWinSet: ERR. Invalid win num %d\n",winNum);
        return MV_BAD_PARAM;
    }
    
    /* Check if the requested window overlapps with current windows         */
    if (MV_TRUE == dmaWinOverlapDetect(winNum, &pAddrDecWin->addrWin))
   	{
        	mvOsPrintf("mvDmaWinSet: ERR. Window %d overlap\n", winNum);
		return MV_ERROR;
	}

	/* check if address is aligned to the size */
	if(MV_IS_NOT_ALIGN(pAddrDecWin->addrWin.baseLow, pAddrDecWin->addrWin.size))
	{
		mvOsPrintf("mvDmaWinSet: Error setting IDMA window %d to "\
				   "target %s.\nAddress 0x%08x is unaligned to size 0x%x.\n",
				   winNum,
				   mvCtrlTargetNameGet(pAddrDecWin->target), 
				   pAddrDecWin->addrWin.baseLow,
				   pAddrDecWin->addrWin.size);
		return MV_ERROR;
	}


	decRegs.baseReg = MV_REG_READ(IDMA_BASE_ADDR_REG(winNum));
	decRegs.sizeReg = MV_REG_READ(IDMA_SIZE_REG(winNum));

	if (MV_OK != mvCtrlAddrDecToReg(&(pAddrDecWin->addrWin),&decRegs))
	{
			mvOsPrintf("mvDmaWinSet: mvCtrlAddrDecToReg Failed\n");
			return MV_ERROR;
	}
	
	mvCtrlAttribGet(pAddrDecWin->target, &targetAttribs);

#if defined(MV_88F5182) || defined(MV_88F5181L)
    /* See BTS Nastore  #19.*/
    /* To access Tunit SRAM from IDMA use targetId = 0x5 */
    /* To access Tunit SRAM from the CPU use targetId = 0x9 */
    if(pAddrDecWin->target == CRYPT_ENG)
        targetAttribs.targetId = 5;
#endif /* defined(MV_88F5182) || defined(MV_88F5181L) */

	/* set attributes */
	decRegs.baseReg &= ~IDMA_WIN_ATTR_MASK;
	decRegs.baseReg |= targetAttribs.attrib << IDMA_WIN_ATTR_OFFS;
	/* set target ID */
	decRegs.baseReg &= ~IDMA_WIN_TARGET_MASK;
	decRegs.baseReg |= targetAttribs.targetId << IDMA_WIN_TARGET_OFFS;
	
	/* for the safe side we disable the window before writing the new
	values */
	mvDmaWinEnable(winNum,MV_FALSE);

	MV_REG_WRITE(IDMA_BASE_ADDR_REG(winNum), decRegs.baseReg);

	/* Write to address decode Size Register                             */
	MV_REG_WRITE(IDMA_SIZE_REG(winNum), decRegs.sizeReg);

	/* Enable address decode target window                               */
	if (pAddrDecWin->enable == MV_TRUE)
	{
    	mvDmaWinEnable(winNum, MV_TRUE);
	}
    
	return MV_OK;
}
Example #18
0
* mvTdmWinSet - Set TDM target address window
*
* DESCRIPTION:
*       This function sets a peripheral target (e.g. SDRAM bank0, PCI_MEM0)
*       address window, also known as address decode window.
*       After setting this target window, the TDM will be able to access the
*       target within the address window.
*
* INPUT:
*       winNum      - TDM to target address decode window number.
*       pAddrDecWin - TDM target window data structure.
*
* OUTPUT:
*       None.
*
* RETURN:
*       MV_ERROR if address window overlapps with other address decode windows.
*       MV_BAD_PARAM if base address is invalid parameter or target is
*       unknown.
*
*******************************************************************************/

MV_STATUS mvTdmWinSet(MV_U32 winNum, MV_TDM_DEC_WIN *pAddrDecWin)
{
	MV_TARGET_ATTRIB targetAttribs;
	MV_DEC_REGS decRegs;
	MV_U32 ctrlReg = 0;

    /* Parameter checking   */
    if (winNum >= TDM_MBUS_MAX_WIN)
    {
		mvOsPrintf("mvTdmWinSet: ERR. Invalid win num %d\n",winNum);
        return MV_BAD_PARAM;
    }
    
    /* Check if the requested window overlapps with current windows         */
    if (MV_TRUE == tdmWinOverlapDetect(winNum, &pAddrDecWin->addrWin))
   	{
       	mvOsPrintf("mvTdmWinSet: ERR. Window %d overlap\n", winNum);
		return MV_ERROR;
	}

	/* check if address is aligned to the size */
	if (MV_IS_NOT_ALIGN(pAddrDecWin->addrWin.baseLow, pAddrDecWin->addrWin.size))
	{
		mvOsPrintf("mvTdmWinSet: Error setting TDM window %d to "\
				   "target %s.\nAddress 0x%08x is unaligned to size 0x%x.\n",
				   winNum,
				   mvCtrlTargetNameGet(pAddrDecWin->target), 
				   pAddrDecWin->addrWin.baseLow,
				   pAddrDecWin->addrWin.size);
		return MV_ERROR;
	}

	decRegs.baseReg = MV_REG_READ(TDM_WIN_BASE_REG(winNum));
	decRegs.sizeReg = (MV_REG_READ(TDM_WIN_CTRL_REG(winNum)) & TDM_WIN_SIZE_MASK) >>  TDM_WIN_SIZE_OFFS;

	if (MV_OK != mvCtrlAddrDecToReg(&(pAddrDecWin->addrWin),&decRegs))
	{
			mvOsPrintf("mvTdmWinSet: mvCtrlAddrDecToReg Failed\n");
			return MV_ERROR;
	}
	
	mvCtrlAttribGet(pAddrDecWin->target, &targetAttribs);
	
	/* for the safe side we disable the window before writing the new
	values */
	mvTdmWinEnable(winNum, MV_FALSE);

	ctrlReg |= (targetAttribs.attrib << TDM_WIN_ATTRIB_OFFS);
	ctrlReg |= (targetAttribs.targetId << TDM_WIN_TARGET_OFFS);
	ctrlReg |= (decRegs.sizeReg & TDM_WIN_SIZE_MASK);

	/* Write to address base and control registers  */
	MV_REG_WRITE(TDM_WIN_BASE_REG(winNum), decRegs.baseReg);
	MV_REG_WRITE(TDM_WIN_CTRL_REG(winNum), ctrlReg);  
	/* Enable address decode target window  */
	if (pAddrDecWin->enable == MV_TRUE)
	{
		mvTdmWinEnable(winNum, MV_TRUE);
	}    
	return MV_OK;
}