Exemplo n.º 1
0
/*******************************************************************************
* mvTsuWinRead
*
* DESCRIPTION:
*	Get TSU peripheral target address window.
*
* INPUT:
*	unit   - The Unit ID.
*	winNum - TSU to target address decode window number.
*
* OUTPUT:
*       pAddrDecWin - TSU target window data structure.
*
* RETURN:
*       MV_ERROR if register parameters are invalid.
*
*******************************************************************************/
MV_STATUS mvTsuWinRead(MV_U32 unit, MV_U32 winNum, MV_UNIT_WIN_INFO *pAddrDecWin)
{
	MV_U32 baseReg, sizeReg;

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

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

	pAddrDecWin->addrWin.size = (sizeReg & TSU_WIN_CTRL_SIZE_MASK) >> TSU_WIN_CTRL_SIZE_OFFS;
	pAddrDecWin->addrWin.size = (pAddrDecWin->addrWin.size + 1) * TSU_WIN_SIZE_ALIGN;

	pAddrDecWin->addrWin.baseLow = baseReg & TSU_WIN_BASE_MASK;
	pAddrDecWin->addrWin.baseHigh =  0;

	/* attrib and targetId */
	pAddrDecWin->attrib = 
		(sizeReg & TSU_WIN_CTRL_ATTR_MASK) >> TSU_WIN_CTRL_ATTR_OFFS;
	pAddrDecWin->targetId = 
		(sizeReg & TSU_WIN_CTRL_TARGET_MASK) >> TSU_WIN_CTRL_TARGET_OFFS;

	/* Check if window is enabled   */
	if((MV_REG_READ(MV_TSU_WIN_CTRL_REG(winNum)) & TSU_WIN_CTRL_EN_MASK))
		pAddrDecWin->enable = MV_TRUE;
	else
		pAddrDecWin->enable = MV_FALSE;

	return MV_OK;
}
Exemplo n.º 2
0
/*******************************************************************************
* mvTsuWinWrite
*
* 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:
*	unit	    - The Unit ID.
*       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 mvTsuWinWrite(MV_U32 unit, MV_U32 winNum, MV_UNIT_WIN_INFO *pAddrDecWin)
{
	MV_U32  sizeReg, baseReg;

	/* 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.\n"
			   "Address 0x%08x is unaligned to size 0x%x.\n",
			   winNum,
			   pAddrDecWin->addrWin.baseLow,
			   pAddrDecWin->addrWin.size);
		return MV_ERROR;
	}

	baseReg = pAddrDecWin->addrWin.baseLow & TSU_WIN_BASE_MASK;
	sizeReg = (pAddrDecWin->addrWin.size / TSU_WIN_SIZE_ALIGN) - 1;
	sizeReg = (sizeReg << TSU_WIN_CTRL_SIZE_OFFS) & TSU_WIN_CTRL_SIZE_MASK;

	/* set attributes */
	baseReg &= ~TSU_WIN_CTRL_ATTR_MASK;
	baseReg |= pAddrDecWin->attrib << TSU_WIN_CTRL_ATTR_OFFS;
	/* set target ID */
	baseReg &= ~TSU_WIN_CTRL_TARGET_MASK;
	baseReg |= pAddrDecWin->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), sizeReg);

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

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

	return MV_OK;
}
Exemplo n.º 3
0
/*******************************************************************************
* mvTsuWinGet
*
* DESCRIPTION:
*	Get TSU peripheral target address window.
*
* INPUT:
*	winNum - TSU to target address decode window number.
*
* OUTPUT:
*       pAddrDecWin - TSU target window data structure.
*
* RETURN:
*       MV_ERROR if register parameters are invalid.
*
*******************************************************************************/
MV_STATUS mvTsuWinGet(MV_U32 winNum, MV_TSU_DEC_WIN *pAddrDecWin)
{
	MV_DEC_REGS decRegs;
	MV_TARGET_ATTRIB targetAttrib;

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

	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 != mvCtrlRegToAddrDec(&decRegs,&(pAddrDecWin->addrWin)))
	{
		mvOsPrintf("mvTsuWinGet: mvCtrlRegToAddrDec Failed \n");
		return MV_ERROR;
	}

	/* attrib and targetId */
	targetAttrib.attrib =
		(decRegs.sizeReg & TSU_WIN_CTRL_ATTR_MASK) >> TSU_WIN_CTRL_ATTR_OFFS;
	targetAttrib.targetId =
		(decRegs.sizeReg & TSU_WIN_CTRL_TARGET_MASK) >> TSU_WIN_CTRL_TARGET_OFFS;

	pAddrDecWin->target = mvCtrlTargetGet(&targetAttrib);

	/* Check if window is enabled   */
	if((MV_REG_READ(MV_TSU_WIN_CTRL_REG(winNum)) & TSU_WIN_CTRL_EN_MASK))
	{
		pAddrDecWin->enable = MV_TRUE;
	}
	else
	{
		pAddrDecWin->enable = MV_FALSE;
	}

	return MV_OK;
}
Exemplo n.º 4
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;
}