Beispiel #1
0
/*******************************************************************************
* mvCpuIfPexRemap - Set CPU remap register for address windows.
*
* DESCRIPTION:
*
* INPUT:
*       pexTarget   - Peripheral target enumerator. Must be a PEX target.
*       pAddrDecWin - CPU target window information data structure.
*                     Note that caller has to fill in the base field only. The
*                     size field is ignored.
*
* OUTPUT:
*       None.
*
* RETURN:
*       MV_ERROR if target is not a PEX one, MV_OK otherwise.
*
*******************************************************************************/
MV_U32 mvCpuIfPexRemap(MV_TARGET pexTarget, MV_ADDR_WIN *pAddrDecWin)
{
    MV_U32 winNum;

    /* Check parameters */

    if (mvCtrlPexMaxIfGet() > 1)
    {
        if ((!MV_TARGET_IS_PEX1(pexTarget))&&(!MV_TARGET_IS_PEX0(pexTarget)))
        {
            mvOsPrintf("mvCpuIfPexRemap: target %d is illegal\n",pexTarget);
            return 0xffffffff;
        }
    }
    else
    {
        if (!MV_TARGET_IS_PEX0(pexTarget))
        {
            mvOsPrintf("mvCpuIfPexRemap: target %d is illegal\n",pexTarget);
            return 0xffffffff;
        }
    }

    /* get the Window number associated with this target */
    winNum = mvAhbToMbusWinTargetGet(pexTarget);

    if (winNum >= MAX_AHB_TO_MBUS_WINS)
    {
        mvOsPrintf("mvCpuIfPexRemap: mvAhbToMbusWinTargetGet Failed\n");
        return 0xffffffff;
    }

    return mvAhbToMbusWinRemap(winNum , pAddrDecWin);
}
Beispiel #2
0
/*******************************************************************************
* mvCpuIfTargetWinGet - Get CPU-to-peripheral target address window
*
* DESCRIPTION:
*		Get the CPU peripheral target address window.
*
* INPUT:
*       target - Peripheral target enumerator
*
* OUTPUT:
*       pAddrDecWin - CPU target window information data structure.
*
* RETURN:
*       MV_OK if target exist, MV_ERROR otherwise.
*
*******************************************************************************/
MV_STATUS mvCpuIfTargetWinGet(MV_TARGET target, MV_CPU_DEC_WIN *pAddrDecWin)
{

    MV_U32 winNum=0xffffffff;
    MV_AHB_TO_MBUS_DEC_WIN decWin;
    MV_DRAM_DEC_WIN addrDecWin;

    target = MV_CHANGE_BOOT_CS(target);

    /* Check parameters */
    if (target >= MAX_TARGETS)
    {
        mvOsPrintf("mvCpuIfTargetWinGet: target %d is illegal\n", target);
        return MV_ERROR;
    }

    if (MV_TARGET_IS_DRAM(target))
    {
        if (mvDramIfWinGet(target,&addrDecWin) != MV_OK)
        {
            mvOsPrintf("mvCpuIfTargetWinGet: Failed to get window target %d\n",
                       target);
            return MV_ERROR;
        }

        /* copy relevant data to MV_CPU_DEC_WIN structure */
        pAddrDecWin->addrWin.baseLow = addrDecWin.addrWin.baseLow;
        pAddrDecWin->addrWin.baseHigh = addrDecWin.addrWin.baseHigh;
        pAddrDecWin->addrWin.size = addrDecWin.addrWin.size;
        pAddrDecWin->enable = addrDecWin.enable;
        pAddrDecWin->winNum = 0xffffffff;
    }
    else
    {
        /* get the Window number associated with this target */

        winNum = mvAhbToMbusWinTargetGet(target);
        if (winNum >= MAX_AHB_TO_MBUS_WINS)
        {
            return MV_NO_SUCH;
        }

        if (mvAhbToMbusWinGet(winNum , &decWin) != MV_OK)
        {
            mvOsPrintf("%s: mvAhbToMbusWinGet Failed at winNum = %d\n",
                       __FUNCTION__, winNum);
            return MV_ERROR;
        }

        /* copy relevant data to MV_CPU_DEC_WIN structure */
        pAddrDecWin->addrWin.baseLow = decWin.addrWin.baseLow;
        pAddrDecWin->addrWin.baseHigh = decWin.addrWin.baseHigh;
        pAddrDecWin->addrWin.size = decWin.addrWin.size;
        pAddrDecWin->enable = decWin.enable;
        pAddrDecWin->winNum = winNum;

    }

    return MV_OK;
}
Beispiel #3
0
/*******************************************************************************
* mvCpuIfTargetWinEnable - Enable/disable a CPU address decode window
*
* DESCRIPTION:
*       This function enable/disable a CPU address decode window.
*       if parameter 'enable' == MV_TRUE the routine will enable the 
*       window, thus enabling CPU accesses (before enabling the window it is 
*       tested for overlapping). Otherwise, the window will be disabled.
*
* INPUT:
*       target - Peripheral target enumerator.
*       enable - Enable/disable parameter.
*
* OUTPUT:
*       N/A
*
* RETURN:
*       MV_ERROR if protection window number was wrong, or the window 
*       overlapps other target window.
*
*******************************************************************************/
MV_STATUS mvCpuIfTargetWinEnable(MV_TARGET target,MV_BOOL enable)
{
	MV_U32 winNum, temp;
	MV_CPU_DEC_WIN addrDecWin;

	/* Check parameters */
	if (target >= MAX_TARGETS)
	{
		mvOsPrintf("mvCpuIfTargetWinEnable: target %d is Illigal\n", target);
		return MV_ERROR;
	}

	/* get the window and check if it exist */
	temp = mvCpuIfTargetWinGet(target, &addrDecWin);
	if (MV_NO_SUCH == temp)
	{
		return (enable? MV_ERROR: MV_OK);
	}
	else if( MV_OK != temp)
	{
		mvOsPrintf("%s: ERR. Getting target %d failed.\n",__FUNCTION__, target);
		return MV_ERROR;
	}

	/* check overlap */

	if (MV_TRUE == enable)
	{
		if (MV_TRUE == cpuTargetWinOverlap(target, &addrDecWin.addrWin))
		{
			DB(mvOsPrintf("%s: ERR. Target %d overlap\n",__FUNCTION__, target));
			return MV_ERROR;
		}
		
	}

	if (!MV_TARGET_IS_DRAM(target))
	{
		/* get the Window number associated with this target */

		winNum = mvAhbToMbusWinTargetGet(target);

		if (winNum >= MAX_AHB_TO_MBUS_WINS)
		{
			return (enable? MV_ERROR: MV_OK);
		}

		if (mvAhbToMbusWinEnable(winNum , enable) != MV_OK)
		{
			mvOsPrintf("mvCpuIfTargetWinGet: Failed to enable window = %d\n",
					   winNum);
			return MV_ERROR;

		}
	}

	return MV_OK;
}
/*******************************************************************************
* mvCpuIfPciRemap - Set CPU remap register for address windows.
*
* DESCRIPTION:
*
* INPUT:
*       pciTarget   - Peripheral target enumerator. Must be a PCI target.
*       pAddrDecWin - CPU target window information data structure.
*                     Note that caller has to fill in the base field only. The
*                     size field is ignored.
*
* OUTPUT:
*       None.
*
* RETURN:
*       MV_ERROR if target is not a PCI one, MV_OK otherwise.
*
*******************************************************************************/
MV_U32 mvCpuIfPciRemap(MV_TARGET pciIfTarget, MV_ADDR_WIN *pAddrDecWin)
{
	MV_U32 winNum;

	/* get the Window number associated with this target */
	winNum = mvAhbToMbusWinTargetGet(pciIfTarget);

	if (winNum >= MAX_AHB_TO_MBUS_WINS) {
		mvOsPrintf("mvCpuIfPexRemap: mvAhbToMbusWinTargetGet Failed\n");
		return 0xffffffff;
	}

	return mvAhbToMbusWinRemap(winNum, pAddrDecWin);
}
Beispiel #5
0
/*******************************************************************************
* mvCpuIfPciRemap - Set CPU remap register for address windows.
*
* DESCRIPTION:
*
* INPUT:
*       pciTarget   - Peripheral target enumerator. Must be a PCI target.
*       pAddrDecWin - CPU target window information data structure.
*                     Note that caller has to fill in the base field only. The
*                     size field is ignored.
*
* OUTPUT:
*       None.
*
* RETURN:
*       MV_ERROR if target is not a PCI one, MV_OK otherwise.
*
*******************************************************************************/
MV_U32 mvCpuIfPciRemap(MV_TARGET pciTarget, MV_ADDR_WIN *pAddrDecWin)
{
	MV_U32 winNum;

	/* Check parameters */
	if (!MV_TARGET_IS_PCI(pciTarget)) {
		mvOsPrintf("mvCpuIfPciRemap: target %d is illegal\n", pciTarget);
		return 0xffffffff;
	}

	/* get the Window number associated with this target */
	winNum = mvAhbToMbusWinTargetGet(pciTarget);

	if (winNum >= MAX_AHB_TO_MBUS_WINS) {
		mvOsPrintf("mvCpuIfPciRemap: mvAhbToMbusWinTargetGet Failed\n");
		return 0xffffffff;
	}

	return mvAhbToMbusWinRemap(winNum, pAddrDecWin);
}
Beispiel #6
0
MV_U32 mvPexHwConfigRead (MV_U32 pexIf, MV_U32 bus, MV_U32 dev, MV_U32 func,
                        MV_U32 regOff)
{
#endif
	MV_U32 pexData = 0;
	MV_U32	localDev,localBus;

	/* Parameter checking   */
	if (PEX_DEFAULT_IF != pexIf)
	{
		if (pexIf >= mvCtrlPexMaxIfGet())
		{
			mvOsPrintf("mvPexConfigRead: ERR. Invalid PEX interface %d\n",pexIf);
			return 0xFFFFFFFF;
		}
	}

	if (dev >= MAX_PEX_DEVICES)
	{
		DB(mvOsPrintf("mvPexConfigRead: ERR. device number illigal %d\n", dev));
		return 0xFFFFFFFF;
	}
	
	if (func >= MAX_PEX_FUNCS)
	{
		DB(mvOsPrintf("mvPexConfigRead: ERR. function num illigal %d\n", func));
		return 0xFFFFFFFF;
	}
	
	if (bus >= MAX_PEX_BUSSES)
	{
		DB(mvOsPrintf("mvPexConfigRead: ERR. bus number illigal %d\n", bus));
		return MV_ERROR;
	}
    	     
    DB(mvOsPrintf("mvPexConfigRead: pexIf %d, bus %d, dev %d, func %d, regOff 0x%x\n",
                   pexIf, bus, dev, func, regOff));
	
	localDev = mvPexLocalDevNumGet(pexIf);
	localBus = mvPexLocalBusNumGet(pexIf);
                                     
    /* Speed up the process. In case on no link, return MV_ERROR */
    if ((dev != localDev) || (bus != localBus))
    {
        pexData = MV_REG_READ(PEX_STATUS_REG(pexIf));

        if ((pexData & PXSR_DL_DOWN))
        {
            return MV_ERROR;
        }
    }

    /* in PCI Express we have only one device number */
	/* and this number is the first number we encounter 
	else that the localDev*/
	/* spec pex define return on config read/write on any device */
	if (bus == localBus)
	{
		if (localDev == 0)
		{
			/* if local dev is 0 then the first number we encounter 
			after 0 is 1 */
			if ((dev != 1)&&(dev != localDev))
			{
				return MV_ERROR;
			}	
		}
		else
		{
			/* if local dev is not 0 then the first number we encounter 
			is 0 */
	
			if ((dev != 0)&&(dev != localDev))
			{
				return MV_ERROR;
			}
		}
		if(func != 0 ) /* i.e bridge */
		{
			return MV_ERROR;
		}
	}
    
    
	/* Creating PEX address to be passed */
	pexData = (bus << PXCAR_BUS_NUM_OFFS);
	pexData |= (dev << PXCAR_DEVICE_NUM_OFFS);
	pexData |= (func << PXCAR_FUNC_NUM_OFFS);
	pexData |= (regOff & PXCAR_REG_NUM_MASK); /* lgacy register space */
	/* extended register space */
	pexData |=(((regOff & PXCAR_REAL_EXT_REG_NUM_MASK) >> 
				PXCAR_REAL_EXT_REG_NUM_OFFS) << PXCAR_EXT_REG_NUM_OFFS);

	pexData |= PXCAR_CONFIG_EN; 
	
	/* Write the address to the PEX configuration address register */
	MV_REG_WRITE(PEX_CFG_ADDR_REG(pexIf), pexData);

	DB(mvOsPrintf("mvPexConfigRead:address pexData=%x ",pexData));
    
	
	/* In order to let the PEX controller absorbed the address of the read 	*/
	/* transaction we perform a validity check that the address was written */
	if(pexData != MV_REG_READ(PEX_CFG_ADDR_REG(pexIf)))
	{
		return MV_ERROR;
	}

	/* cleaning Master Abort */
	MV_REG_BIT_SET(PEX_CFG_DIRECT_ACCESS(pexIf,PEX_STATUS_AND_COMMAND), 
				   PXSAC_MABORT);
#if 0
	/* Guideline (GL# PCI Express-1) Erroneous Read Data on Configuration   */
	/* This guideline is relevant for all devices except of the following devices:
	   88F5281-BO and above, 88F5181L-A0 and above, 88F1281 A0 and above
	   88F6183 A0 and above, 88F6183L  */
	if ( ( (dev != localDev) || (bus != localBus) ) && 
		(
		!(MV_5281_DEV_ID == mvCtrlModelGet())&&
		!((MV_5181_DEV_ID == mvCtrlModelGet())&& (mvCtrlRevGet() >= MV_5181L_A0_REV))&&
		!(MV_1281_DEV_ID == mvCtrlModelGet())&&
		!(MV_6183_DEV_ID == mvCtrlModelGet())&&
		!(MV_6183L_DEV_ID == mvCtrlModelGet())&&
		!(MV_6281_DEV_ID == mvCtrlModelGet())&&
		!(MV_6192_DEV_ID == mvCtrlModelGet())&&
		!(MV_6190_DEV_ID == mvCtrlModelGet())&&
        !(MV_6180_DEV_ID == mvCtrlModelGet())&& 
		!(MV_78XX0_DEV_ID == mvCtrlModelGet()) 
		))
	{

		/* PCI-Express configuration read work-around */

		/* we will use one of the Punit (AHBToMbus) windows to access the xbar 
		and read the data from there */
		/*
		Need to configure the 2 free Punit (AHB to MBus bridge) 
		address decoding windows:
		Configure the flash Window to handle Configuration space requests 
		for PEX0/1:
		1.    write 0x7931/0x7941 to the flash window and the size, 
		      79-xbar attr (pci cfg), 3/4-xbar target (pex0/1), 1-WinEn
		2.    write base to flash window 
		
		Configuration transactions from the CPU should write/read the data 
		to/from address of the form:
		addr[31:28] = 0x5 (for PEX0) or 0x6 (for PEX1)
		addr[27:24] = extended register number
		addr[23:16] = bus number
		addr[15:11] = device number
		addr[10:8]   = function number
		addr[7:0]     = register number
		*/

		#include "ctrlEnv/sys/mvAhbToMbus.h"
		{
			MV_U32 winNum;
			MV_AHB_TO_MBUS_DEC_WIN originWin;
			MV_U32 pciAddr=0;
			MV_U32 remapLow=0,remapHigh=0;

			/* 
			We will use DEV_CS2\Flash window for this workarround 
			*/
            
			winNum = mvAhbToMbusWinTargetGet(PEX_CONFIG_RW_WA_TARGET);

			/* save remap values if exist */
			if ((1 == winNum)||(0 == winNum))
			{
				remapLow = MV_REG_READ(AHB_TO_MBUS_WIN_REMAP_LOW_REG(winNum));
				remapHigh = MV_REG_READ(AHB_TO_MBUS_WIN_REMAP_HIGH_REG(winNum));

			}
			

			/* save the original window values */
			mvAhbToMbusWinGet(winNum,&originWin);

			if (PEX_CONFIG_RW_WA_USE_ORIGINAL_WIN_VALUES)
			{
				/* set the window as xbar window */
				if (pexIf)
				{
					MV_REG_WRITE(AHB_TO_MBUS_WIN_CTRL_REG(winNum), 
					(0x7931 | (((originWin.addrWin.size >> 16)-1) ) << 16));
				}
				else
				{
					MV_REG_WRITE(AHB_TO_MBUS_WIN_CTRL_REG(winNum), 
					(0x7941 | (((originWin.addrWin.size >> 16)-1) ) << 16));
				}

				MV_REG_WRITE(AHB_TO_MBUS_WIN_BASE_REG(winNum),
							 originWin.addrWin.baseLow);

				/*pciAddr = originWin.addrWin.baseLow;*/
				pciAddr = (MV_U32)CPU_MEMIO_UNCACHED_ADDR(
					(MV_U32)originWin.addrWin.baseLow);
			
			}
Beispiel #7
0
/*******************************************************************************
* mvCpuIfTargetWinSet - Set CPU-to-peripheral target address window
*
* DESCRIPTION:
*       This function sets a peripheral target (e.g. SDRAM bank0, PCI0_MEM0)
*       address window, also known as address decode window.
*       A new address decode window is set for specified target address window.
*       If address decode window parameter structure enables the window,
*       the routine will also enable the target window, allowing CPU to access
*       the target window.
*
* INPUT:
*       target      - Peripheral target enumerator.
*       pAddrDecWin - CPU target window data structure.
*
* OUTPUT:
*       N/A
*
* RETURN:
*       MV_OK if CPU target window was set correctly, MV_ERROR in case of
*       address window overlapps with other active CPU target window or
*		trying to assign 36bit base address while CPU does not support that.
*       The function returns MV_NOT_SUPPORTED, if the target is unsupported.
*
*******************************************************************************/
MV_STATUS mvCpuIfTargetWinSet(MV_TARGET target, MV_CPU_DEC_WIN *pAddrDecWin)
{
    MV_AHB_TO_MBUS_DEC_WIN decWin;
    MV_U32 existingWinNum;
    MV_DRAM_DEC_WIN addrDecWin;

    target = MV_CHANGE_BOOT_CS(target);

    /* Check parameters */
    if (target >= MAX_TARGETS)
    {
        mvOsPrintf("mvCpuIfTargetWinSet: target %d is illegal\n", target);
        return MV_ERROR;
    }

    /* 2) Check if the requested window overlaps with current windows		*/
    if (MV_TRUE == cpuTargetWinOverlap(target, &pAddrDecWin->addrWin))
    {
        mvOsPrintf("mvCpuIfTargetWinSet: ERR. Target %d overlap\n", target);
        return MV_BAD_PARAM;
    }

    if (MV_TARGET_IS_DRAM(target))
    {
        /* copy relevant data to MV_DRAM_DEC_WIN structure */
        addrDecWin.addrWin.baseHigh = pAddrDecWin->addrWin.baseHigh;
        addrDecWin.addrWin.baseLow = pAddrDecWin->addrWin.baseLow;
        addrDecWin.addrWin.size = pAddrDecWin->addrWin.size;
        addrDecWin.enable = pAddrDecWin->enable;


        if (mvDramIfWinSet(target,&addrDecWin) != MV_OK);
        {
            mvOsPrintf("mvCpuIfTargetWinSet: mvDramIfWinSet Failed\n");
            return MV_ERROR;
        }

    }
    else
    {
        /* copy relevant data to MV_AHB_TO_MBUS_DEC_WIN structure */
        decWin.addrWin.baseLow = pAddrDecWin->addrWin.baseLow;
        decWin.addrWin.baseHigh = pAddrDecWin->addrWin.baseHigh;
        decWin.addrWin.size = pAddrDecWin->addrWin.size;
        decWin.enable = pAddrDecWin->enable;
        decWin.target = target;

        existingWinNum = mvAhbToMbusWinTargetGet(target);

        /* check if there is already another Window configured
        for this target */
        if ((existingWinNum < MAX_AHB_TO_MBUS_WINS )&&
                (existingWinNum != pAddrDecWin->winNum))
        {
            /* if we want to enable the new winow number
            passed by the user , then the old one should
            be disabled */
            if (MV_TRUE == pAddrDecWin->enable)
            {
                /* be sure it is disabled */
                mvAhbToMbusWinEnable(existingWinNum , MV_FALSE);
            }
        }

        if (mvAhbToMbusWinSet(pAddrDecWin->winNum,&decWin) != MV_OK)
        {
            mvOsPrintf("mvCpuIfTargetWinSet: mvAhbToMbusWinSet Failed\n");
            return MV_ERROR;
        }

    }

    return MV_OK;
}
Beispiel #8
0
MV_STATUS mvAhbToMbusWinTargetSwap(MV_TARGET target1,MV_TARGET target2)
{
	MV_U32 winNum1,winNum2;
	MV_AHB_TO_MBUS_DEC_WIN winDec1,winDec2,winDecTemp;
	AHB_TO_MBUS_REMAP_REG_OFFS remapRegs1,remapRegs2;
	MV_U32 remapBaseLow1=0,remapBaseLow2=0;
	MV_U32 remapBaseHigh1=0,remapBaseHigh2=0;


	/* Check parameters */
	if (target1 >= MAX_TARGETS)
	{
		mvOsPrintf("mvAhbToMbusWinTargetSwap: target %d is Illigal\n", target1);
		return MV_ERROR;
	}

	if (target2 >= MAX_TARGETS)
	{
		mvOsPrintf("mvAhbToMbusWinTargetSwap: target %d is Illigal\n", target1);
		return MV_ERROR;
	}


    /* get window associated with this target */
	winNum1 = mvAhbToMbusWinTargetGet(target1);

	if (winNum1 == 0xffffffff)
	{
		mvOsPrintf("mvAhbToMbusWinTargetSwap: target %d has illigal win %d\n",
					target1,winNum1);
		return MV_ERROR;

	}

    /* get window associated with this target */
	winNum2 = mvAhbToMbusWinTargetGet(target2);

	if (winNum2 == 0xffffffff)
	{
		mvOsPrintf("mvAhbToMbusWinTargetSwap: target %d has illigal win %d\n",
					target2,winNum2);
		return MV_ERROR;

	}

	/* now Get original values of both Windows */
	if (MV_OK != mvAhbToMbusWinGet(winNum1,&winDec1))
	{
		mvOsPrintf("mvAhbToMbusWinTargetSwap: mvAhbToMbusWinGet failed win %d\n",
					winNum1);
		return MV_ERROR;

	}
	if (MV_OK != mvAhbToMbusWinGet(winNum2,&winDec2))
	{
		mvOsPrintf("mvAhbToMbusWinTargetSwap: mvAhbToMbusWinGet failed win %d\n",
					winNum2);
		return MV_ERROR;

	}


	/* disable both windows */
	if (MV_OK != mvAhbToMbusWinEnable(winNum1,MV_FALSE))
	{
		mvOsPrintf("mvAhbToMbusWinTargetSwap: failed to enable window %d\n",
					winNum1);
		return MV_ERROR;

	}
	if (MV_OK != mvAhbToMbusWinEnable(winNum2,MV_FALSE))
	{
		mvOsPrintf("mvAhbToMbusWinTargetSwap: failed to enable windo %d\n",
					winNum2);
		return MV_ERROR;

	}


	/* now swap targets */

	/* first save winDec2 values */
	winDecTemp.addrWin.baseHigh = winDec2.addrWin.baseHigh;
	winDecTemp.addrWin.baseLow = winDec2.addrWin.baseLow;
	winDecTemp.addrWin.size = winDec2.addrWin.size;
	winDecTemp.enable = winDec2.enable;
	winDecTemp.target = winDec2.target;

	/* winDec2 = winDec1 */
	winDec2.addrWin.baseHigh = winDec1.addrWin.baseHigh;
	winDec2.addrWin.baseLow = winDec1.addrWin.baseLow;
	winDec2.addrWin.size = winDec1.addrWin.size;
	winDec2.enable = winDec1.enable;
	winDec2.target = winDec1.target;


	/* winDec1 = winDecTemp */
	winDec1.addrWin.baseHigh = winDecTemp.addrWin.baseHigh;
	winDec1.addrWin.baseLow = winDecTemp.addrWin.baseLow;
	winDec1.addrWin.size = winDecTemp.addrWin.size;
	winDec1.enable = winDecTemp.enable;
	winDec1.target = winDecTemp.target;


	/* now set the new values */


    mvAhbToMbusWinSet(winNum1,&winDec1);
	mvAhbToMbusWinSet(winNum2,&winDec2);





	/* now we will treat the remap windows if exist */


	/* now check if one or both windows has a remap window
	as well after the swap ! */

	/* if a window had a remap value differnt than the base value
	before the swap , then after the swap the remap value will be
	equal to the base value unless both windows has a remap windows*/

	/* first get old values */
	if (MV_NO_SUCH != ahbToMbusRemapRegOffsGet(winNum1,&remapRegs1))
	{
		remapBaseLow1 = MV_REG_READ(remapRegs1.lowRegOffs);
	    remapBaseHigh1 = MV_REG_READ(remapRegs1.highRegOffs);

	}
	if (MV_NO_SUCH != ahbToMbusRemapRegOffsGet(winNum2,&remapRegs2))
	{
		remapBaseLow2 = MV_REG_READ(remapRegs2.lowRegOffs);
	    remapBaseHigh2 = MV_REG_READ(remapRegs2.highRegOffs);


	}

	/* now do the swap */
	if (MV_NO_SUCH != ahbToMbusRemapRegOffsGet(winNum1,&remapRegs1))
	{
		if (MV_NO_SUCH != ahbToMbusRemapRegOffsGet(winNum2,&remapRegs2))
		{
			/* Two windows has a remap !!! so swap */

			MV_REG_WRITE(remapRegs2.highRegOffs,remapBaseHigh1);
			MV_REG_WRITE(remapRegs2.lowRegOffs,remapBaseLow1);

			MV_REG_WRITE(remapRegs1.highRegOffs,remapBaseHigh2);
			MV_REG_WRITE(remapRegs1.lowRegOffs,remapBaseLow2);



		}
		else
		{
			/* remap == base */
			MV_REG_WRITE(remapRegs1.highRegOffs,winDec1.addrWin.baseHigh);
			MV_REG_WRITE(remapRegs1.lowRegOffs,winDec1.addrWin.baseLow);

		}

	}
	else if (MV_NO_SUCH != ahbToMbusRemapRegOffsGet(winNum2,&remapRegs2))
	{
		/* remap == base */
		MV_REG_WRITE(remapRegs2.highRegOffs,winDec2.addrWin.baseHigh);
		MV_REG_WRITE(remapRegs2.lowRegOffs,winDec2.addrWin.baseLow);

	}



	return MV_OK;


}
Beispiel #9
0
/*******************************************************************************
* mvCpuIfTargetWinGet - Get CPU-to-peripheral target address window
*
* DESCRIPTION:
*		Get the CPU peripheral target address window.
*
* INPUT:
*       target - Peripheral target enumerator
*
* OUTPUT:
*       pAddrDecWin - CPU target window information data structure.
*
* RETURN:
*       MV_OK if target exist, MV_ERROR otherwise.
*
*******************************************************************************/
MV_STATUS mvCpuIfTargetWinGet(MV_TARGET target, MV_CPU_DEC_WIN *pAddrDecWin)
{
	MV_U32 winNum = 0xffffffff;
	MV_AHB_TO_MBUS_DEC_WIN decWin;
	MV_DRAM_DEC_WIN addrDecWin;
	MV_U32 dramEn = 0;
	MV_TARGET i;

	target = MV_CHANGE_BOOT_CS(target);

	/* Check parameters */
	if (target >= MAX_TARGETS) {
		mvOsPrintf("mvCpuIfTargetWinGet: target %d is illegal\n", target);
		return MV_ERROR;
	}

	if (MV_TARGET_IS_DRAM(target)) {
		/* If none of the DRAM windows is enabled, then the CPU DRAM
		 ** access is going through the XBAR.
		 */
		for (i = SDRAM_CS0; i < SDRAM_CS3; i++) {
			if (mvDramIfWinGet(target, &addrDecWin) != MV_OK) {
				mvOsPrintf("mvCpuIfTargetWinGet: Failed to get window target %d\n", i);
				return MV_ERROR;
			}
			if (addrDecWin.enable == MV_TRUE)
				dramEn = 1;
		}
	}

	if ((dramEn == 1) && (MV_TARGET_IS_DRAM(target))) {
		if (mvDramIfWinGet(target, &addrDecWin) != MV_OK) {
			mvOsPrintf("mvCpuIfTargetWinGet: Failed to get window target %d\n", target);
			return MV_ERROR;
		}

		/* copy relevant data to MV_CPU_DEC_WIN structure */
		pAddrDecWin->addrWin.baseLow = addrDecWin.addrWin.baseLow;
		pAddrDecWin->addrWin.baseHigh = addrDecWin.addrWin.baseHigh;
		pAddrDecWin->addrWin.size = addrDecWin.addrWin.size;
		pAddrDecWin->enable = addrDecWin.enable;
		pAddrDecWin->winNum = 0xffffffff;
	} else {
		/* get the Window number associated with this target */
		winNum = mvAhbToMbusWinTargetGet(target);
		if (winNum >= MAX_AHB_TO_MBUS_WINS)
			return MV_NO_SUCH;

		if (mvAhbToMbusWinGet(winNum, &decWin) != MV_OK) {
			mvOsPrintf("%s: mvAhbToMbusWinGet Failed at winNum = %d\n", __func__, winNum);
			return MV_ERROR;
		}

		/* copy relevant data to MV_CPU_DEC_WIN structure */
		pAddrDecWin->addrWin.baseLow = decWin.addrWin.baseLow;
		pAddrDecWin->addrWin.baseHigh = decWin.addrWin.baseHigh;
		pAddrDecWin->addrWin.size = decWin.addrWin.size;
		pAddrDecWin->enable = decWin.enable;
		pAddrDecWin->winNum = winNum;
	}

	return MV_OK;
}