예제 #1
0
/*******************************************************************************
* mvXorTargetWinEnable - Enable/disable a Xor address decode window
*
* DESCRIPTION:
*       This function enable/disable a XOR address decode window.
*       if parameter 'enable' == MV_TRUE the routine will enable the
*       window, thus enabling XOR accesses (before enabling the window it is
*       tested for overlapping). Otherwise, the window will be disabled.
*
* INPUT:
*       winNum - Decode window number.
*       enable - Enable/disable parameter.
*
* OUTPUT:
*       None.
*
* RETURN:
*       MV_BAD_PARAM if parameters to function invalid, MV_OK otherwise.
*
*******************************************************************************/
MV_STATUS mvXorTargetWinEnable(MV_U32 unit, MV_U32 winNum, MV_BOOL enable)
{
	MV_UNIT_WIN_INFO addrDecWin;
	MV_U32 chan;

	/* Parameter checking   */
	if (winNum >= XOR_MAX_ADDR_DEC_WIN) {
		DB(mvOsPrintf("%s: ERR. Invalid winNum%d\n",  __func__, winNum));
		return MV_ERROR;
	}

	if (enable == MV_TRUE) {
		/* Get current window */
		if (MV_OK != mvXorTargetWinRead(unit, winNum, &addrDecWin)) {
			DB(mvOsPrintf("%s: ERR. targetWinGet fail\n",  __func__));
			return MV_ERROR;
		}

		/* Check for overlapping */
		if (MV_TRUE == xorWinOverlapDetect(unit, winNum, &(addrDecWin.addrWin))) {
			/* Overlap detected */
			DB(mvOsPrintf("%s: ERR. Overlap detected\n",  __func__));
			return MV_ERROR;
		}

		/* No Overlap. Enable address decode target window */
		for (chan = 0; chan < MV_XOR_MAX_CHAN_PER_UNIT; chan++)
			MV_REG_BIT_SET(XOR_WINDOW_CTRL_REG(unit, chan), XEXWCR_WIN_EN_MASK(winNum));
	} else {
		/* Disable address decode target window */
		for (chan = 0; chan < MV_XOR_MAX_CHAN_PER_UNIT; chan++)
			MV_REG_BIT_RESET(XOR_WINDOW_CTRL_REG(unit, chan), XEXWCR_WIN_EN_MASK(winNum));
	}
	return MV_OK;
}
예제 #2
0
/*******************************************************************************
* mvXorTargetWinWrite - Set XOR target address window
*
* DESCRIPTION:
*       This function sets a peripheral target (e.g. SDRAM bank0, PCI_MEM0)
*       address window. After setting this target window, the XOR will be
*       able to access the target within the address window.
*
* INPUT:
*	    winNum - One of the possible XOR memory decode windows.
*       target - Peripheral target enumerator.
*       base   - Window base address.
*       size   - Window size.
*       enable - Window enable/disable.
*
* OUTPUT:
*       None.
*
* RETURN:
*       MV_BAD_PARAM if parameters to function invalid, MV_OK otherwise.
*
*******************************************************************************/
MV_STATUS mvXorTargetWinWrite(MV_U32 unit, MV_U32 winNum,
				MV_UNIT_WIN_INFO *pAddrDecWin)
{
	MV_U32 sizeReg, baseReg;
	MV_U32 chan;

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

	if (pAddrDecWin == NULL) {
		DB(mvOsPrintf("%s: ERR. pAddrDecWin is NULL pointer\n",  __func__));
		return MV_BAD_PTR;
	}

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

	if (!MV_IS_POWER_OF_2(pAddrDecWin->addrWin.size)) {
		mvOsPrintf("%s: ERR. Illegal window size.\n",  __func__);
		return MV_BAD_PARAM;
	}

	baseReg = MV_REG_READ(XOR_BASE_ADDR_REG(unit, winNum));
	sizeReg = MV_REG_READ(XOR_SIZE_MASK_REG(unit, winNum));

	baseReg = pAddrDecWin->addrWin.baseLow & XEBARX_BASE_MASK;
	sizeReg = (pAddrDecWin->addrWin.size / XOR_WIN_SIZE_ALIGN) - 1;
	sizeReg = (sizeReg << XESMRX_SIZE_MASK_OFFS) & XESMRX_SIZE_MASK_MASK;

	/* set attributes */
	baseReg &= ~XEBARX_ATTR_MASK;
	baseReg |= pAddrDecWin->attrib << XEBARX_ATTR_OFFS;
	/* set target ID */
	baseReg &= ~XEBARX_TARGET_MASK;
	baseReg |= pAddrDecWin->targetId << XEBARX_TARGET_OFFS;

	/* Write to address decode Base Address Register */
	MV_REG_WRITE(XOR_BASE_ADDR_REG(unit, winNum), baseReg);

	/* Write to Size Register */
	MV_REG_WRITE(XOR_SIZE_MASK_REG(unit, winNum), sizeReg);

	for (chan = 0; chan < MV_XOR_MAX_CHAN_PER_UNIT; chan++) {
		if (pAddrDecWin->enable)
			MV_REG_BIT_SET(XOR_WINDOW_CTRL_REG(unit, chan), XEXWCR_WIN_EN_MASK(winNum));
		 else
			MV_REG_BIT_RESET(XOR_WINDOW_CTRL_REG(unit, chan), XEXWCR_WIN_EN_MASK(winNum));
	}
	return MV_OK;
}
예제 #3
0
/*******************************************************************************
* mvXorTargetWinSet - Set XOR target address window
*
* DESCRIPTION:
*       This function sets a peripheral target (e.g. SDRAM bank0, PCI_MEM0) 
*       address window. After setting this target window, the XOR will be 
*       able to access the target within the address window. 
*
* INPUT:
*	    winNum - One of the possible XOR memory decode windows.
*       target - Peripheral target enumerator.
*       base   - Window base address.
*       size   - Window size.
*       enable - Window enable/disable.
*
* OUTPUT:
*       None.
*
* RETURN:
*       MV_BAD_PARAM if parameters to function invalid, MV_OK otherwise.
*
*******************************************************************************/
MV_STATUS mvXorTargetWinSet(MV_U32 unit, MV_U32 winNum, MV_XOR_DEC_WIN *pAddrDecWin)
{
    MV_DEC_REGS xorDecRegs;
	MV_TARGET_ATTRIB targetAttribs;
    MV_U32      chan;
    
    /* Parameter checking */
    if (winNum >= XOR_MAX_ADDR_DEC_WIN)
    {
		DB(mvOsPrintf("%s: ERR. Invalid win num %d\n",__FUNCTION__, winNum));
        return MV_BAD_PARAM;
    }
    if (pAddrDecWin == NULL)
    {
        DB(mvOsPrintf("%s: ERR. pAddrDecWin is NULL pointer\n", __FUNCTION__ ));
        return MV_BAD_PTR;
    }                                         
    /* Check if the requested window overlaps with current windows */
    if (MV_TRUE == xorWinOverlapDetect(unit, winNum, &pAddrDecWin->addrWin))
    {
	DB(mvOsPrintf("%s: ERR. Window %d overlap\n",__FUNCTION__,winNum));
	return MV_ERROR;
    }                              

    xorDecRegs.baseReg = MV_REG_READ(XOR_BASE_ADDR_REG(unit,winNum));
    xorDecRegs.sizeReg = MV_REG_READ(XOR_SIZE_MASK_REG(unit,winNum));

    /* Get Base Address and size registers values */
    if(MV_OK != mvCtrlAddrDecToReg(&pAddrDecWin->addrWin, &xorDecRegs))
    {
		DB(mvOsPrintf("%s: ERR. Invalid addr dec window\n",__FUNCTION__));
        return MV_BAD_PARAM;
	}
    

	mvCtrlAttribGet(pAddrDecWin->target,&targetAttribs);

	/* set attributes */
	xorDecRegs.baseReg &= ~XEBARX_ATTR_MASK;
	xorDecRegs.baseReg |= targetAttribs.attrib << XEBARX_ATTR_OFFS;
	/* set target ID */
	xorDecRegs.baseReg &= ~XEBARX_TARGET_MASK;
	xorDecRegs.baseReg |= targetAttribs.targetId << XEBARX_TARGET_OFFS;


    /* Write to address decode Base Address Register */
	MV_REG_WRITE(XOR_BASE_ADDR_REG(unit,winNum), xorDecRegs.baseReg);
    
    /* Write to Size Register */
	MV_REG_WRITE(XOR_SIZE_MASK_REG(unit,winNum), xorDecRegs.sizeReg);
    
    for (chan = 0; chan < MV_XOR_MAX_CHAN; chan++)
    {
        if (pAddrDecWin->enable)
        {
            MV_REG_BIT_SET(XOR_WINDOW_CTRL_REG(unit,chan),
                           XEXWCR_WIN_EN_MASK(winNum));
        }
        else
        {
            MV_REG_BIT_RESET(XOR_WINDOW_CTRL_REG(unit,chan),
                             XEXWCR_WIN_EN_MASK(winNum));
        }
    }
    return MV_OK;
}