/*******************************************************************************
* mvPp2WinRead
*
* DESCRIPTION:
*       Read Ethernet peripheral target address window.
*
* INPUT:
*       winNum - ETH to target address decode window number.
*
* OUTPUT:
*       pAddrDecWin - ETH target window data structure.
*
* RETURN:
*	MV_BAD_PARAM if winNum is invalid.
*	MV_ERROR otherwise.
*
*******************************************************************************/
MV_STATUS mvPp2WinRead(MV_U32 dummy/*backward compability*/, MV_U32 winNum, MV_UNIT_WIN_INFO *pAddrDecWin)
{
	MV_U32 baseReg, sizeReg;
	MV_U32 alignment, size;

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

	baseReg = MV_REG_READ(ETH_WIN_BASE_REG(winNum));
	sizeReg = MV_REG_READ(ETH_WIN_SIZE_REG(winNum));

	alignment = 1 << ETH_WIN_SIZE_OFFS;
	size = (sizeReg & ETH_WIN_SIZE_MASK) >> ETH_WIN_SIZE_OFFS;
	pAddrDecWin->addrWin.size = (size + 1) * alignment;

	/* Extract base address                                     */
	pAddrDecWin->addrWin.baseLow = baseReg & ETH_WIN_BASE_MASK;
	pAddrDecWin->addrWin.baseHigh = 0;

	/* attrib and targetId */
	pAddrDecWin->attrib = (baseReg & ETH_WIN_ATTR_MASK) >> ETH_WIN_ATTR_OFFS;
	pAddrDecWin->targetId = (baseReg & ETH_WIN_TARGET_MASK) >> ETH_WIN_TARGET_OFFS;

	/* Check if window is enabled   */
	if (~(MV_REG_READ(ETH_BASE_ADDR_ENABLE_REG)) & (1 << winNum))
		pAddrDecWin->enable = MV_TRUE;
	else
		pAddrDecWin->enable = MV_FALSE;
	return MV_OK;
}
Example #2
0
/* Print Giga Ethernet UNIT registers */
void    ethRegs(void)
{
    int win;

    mvOsPrintf("ETH_PHY_ADDR_REG                    : 0x%X = 0x%08x\n", 
                ETH_PHY_ADDR_REG, 
                MV_REG_READ(ETH_PHY_ADDR_REG) );    

    mvOsPrintf("ETH_BASE_ADDR_ENABLE_REG            : 0x%X = 0x%08x\n", 
                ETH_BASE_ADDR_ENABLE_REG, 
                MV_REG_READ( ETH_BASE_ADDR_ENABLE_REG) );    
    
    mvOsPrintf("ETH_UNIT_INTERRUPT_CAUSE_REG        : 0x%X = 0x%08x\n", 
                ETH_UNIT_INTERRUPT_CAUSE_REG, 
                MV_REG_READ( ETH_UNIT_INTERRUPT_CAUSE_REG) );    

    mvOsPrintf("ETH_UNIT_INTERRUPT_MASK_REG         : 0x%X = 0x%08x\n", 
                ETH_UNIT_INTERRUPT_MASK_REG, 
                MV_REG_READ( ETH_UNIT_INTERRUPT_MASK_REG) );    

    mvOsPrintf("ETH_UNIT_ERROR_ADDR_REG             : 0x%X = 0x%08x\n", 
                ETH_UNIT_ERROR_ADDR_REG, 
                MV_REG_READ(ETH_UNIT_ERROR_ADDR_REG) );    

    mvOsPrintf("ETH_UNIT_INTERNAL_ADDR_ERROR_REG    : 0x%X = 0x%08x\n", 
                ETH_UNIT_INTERNAL_ADDR_ERROR_REG, 
                MV_REG_READ(ETH_UNIT_INTERNAL_ADDR_ERROR_REG) );    
    
    for(win=0; win<ETH_MAX_DECODE_WIN; win++)
    {
        mvOsPrintf("\nAddrDecWin #%d\n", win);
        mvOsPrintf("\tETH_WIN_BASE_REG(win)       : 0x%X = 0x%08x\n", 
                ETH_WIN_BASE_REG(win), 
                MV_REG_READ( ETH_WIN_BASE_REG(win)) );    
        mvOsPrintf("\tETH_WIN_SIZE_REG(win)       : 0x%X = 0x%08x\n", 
                ETH_WIN_SIZE_REG(win), 
                MV_REG_READ( ETH_WIN_SIZE_REG(win)) );    
    }
}
Example #3
0
/*******************************************************************************
* mvETHWinGet - Get dma peripheral target address window.
*
* DESCRIPTION:
*               Get ETH peripheral target address window.
*
* INPUT:
*       winNum - ETH to target address decode window number.
*
* OUTPUT:
*       pAddrDecWin - ETH target window data structure.
*
* RETURN:
*       MV_ERROR if register parameters are invalid.
*
*******************************************************************************/
MV_STATUS mvEthWinGet(int port, MV_U32 winNum, MV_ETH_DEC_WIN *pAddrDecWin)
{
    MV_DEC_REGS decRegs;
    MV_TARGET_ATTRIB targetAttrib;
    
    /* Parameter checking   */
    if (winNum >= ETH_MAX_DECODE_WIN)
    {
        mvOsPrintf("mvEthWinGet: ERR. Invalid winNum %d\n", winNum);
        return MV_NOT_SUPPORTED;
    }
    
    decRegs.baseReg =  MV_REG_READ(ETH_WIN_BASE_REG(port, winNum));
    decRegs.sizeReg = MV_REG_READ(ETH_WIN_SIZE_REG(port, winNum));
    
    if (MV_OK != mvCtrlRegToAddrDec(&decRegs,&(pAddrDecWin->addrWin)))
    {
        mvOsPrintf("mvAhbToMbusWinGet: mvCtrlRegToAddrDec Failed \n");
        return MV_ERROR;
    }
    
    /* attrib and targetId */
    targetAttrib.attrib = 
     (decRegs.baseReg & ETH_WIN_ATTR_MASK) >> ETH_WIN_ATTR_OFFS;
    targetAttrib.targetId = 
     (decRegs.baseReg & ETH_WIN_TARGET_MASK) >> ETH_WIN_TARGET_OFFS;
    
    pAddrDecWin->target = mvCtrlTargetGet(&targetAttrib);
    
    /* Check if window is enabled   */
    if (~(MV_REG_READ(ETH_BASE_ADDR_ENABLE_REG(port))) & (1 << winNum) )
    {
        pAddrDecWin->enable = MV_TRUE;
    }
    else
    {
        pAddrDecWin->enable = MV_FALSE;
    }
    
        return MV_OK;
}
/*******************************************************************************
* mvPp2WinWrite
*
* DESCRIPTION:
*	This function writes the address decoding registers according to the
*	given window configuration.
*
* INPUT:
*	unit	    - The Ethernet unit number to configure.
*       winNum	    - ETH target address decode window number.
*       pAddrDecWin - ETH target window data structure.
*
* OUTPUT:
*       None.
*
* RETURN:
*       MV_OK on success,
*	MV_BAD_PARAM if winNum is invalid.
*	MV_ERROR otherwise.
*
*******************************************************************************/
MV_STATUS mvPp2WinWrite(MV_U32 dummy/*backward compability*/, MV_U32 winNum, MV_UNIT_WIN_INFO *pAddrDecWin)
{
	MV_U32 size, alignment;
	MV_U32 baseReg, sizeReg;

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

	/* Check if the requested window overlapps with current windows     */
	if (MV_TRUE == ethWinOverlapDetect(winNum, &pAddrDecWin->addrWin)) {
		mvOsPrintf("mvPp2WinWrite: 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("mvPp2WinSet: Error setting Ethernet window %d.\n"
			   "Address 0x%08x is unaligned to size 0x%x.\n",
			   winNum, pAddrDecWin->addrWin.baseLow, (MV_U32)pAddrDecWin->addrWin.size);
		return MV_ERROR;
	}

	size = pAddrDecWin->addrWin.size;
	if (!MV_IS_POWER_OF_2(size)) {
		mvOsPrintf("mvPp2WinWrite: Error setting AUDIO window %d. "
			   "Window size is not a power to 2.", winNum);
		return MV_BAD_PARAM;
	}

	baseReg = (pAddrDecWin->addrWin.baseLow & ETH_WIN_BASE_MASK);
	sizeReg = MV_REG_READ(ETH_WIN_SIZE_REG(winNum));

	/* set size */
	alignment = 1 << ETH_WIN_SIZE_OFFS;
	sizeReg &= ~ETH_WIN_SIZE_MASK;
	sizeReg |= (((size / alignment) - 1) << ETH_WIN_SIZE_OFFS);

	/* set attributes */
	baseReg &= ~ETH_WIN_ATTR_MASK;
	baseReg |= pAddrDecWin->attrib << ETH_WIN_ATTR_OFFS;

	/* set target ID */
	baseReg &= ~ETH_WIN_TARGET_MASK;
	baseReg |= pAddrDecWin->targetId << ETH_WIN_TARGET_OFFS;

	/* for the safe side we disable the window before writing the new
	   values */
	mvPp2WinEnable(0, winNum, MV_FALSE);
	mvPp2WrReg(ETH_WIN_BASE_REG(winNum), baseReg);

	/* Write to address decode Size Register                            */
	mvPp2WrReg(ETH_WIN_SIZE_REG(winNum), sizeReg);

	/* Enable address decode target window                              */
	if (pAddrDecWin->enable == MV_TRUE)
		mvPp2WinEnable(0, winNum, MV_TRUE);

	return MV_OK;
}
Example #5
0
/*******************************************************************************
* mvEthWinSet - Set ETH 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 ETH will be able to access the
*       target within the address window.
*
* INPUT:
*       winNum      - ETH to target address decode window number.
*       pAddrDecWin - ETH 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 mvEthWinSet(int port, MV_U32 winNum, MV_ETH_DEC_WIN *pAddrDecWin)
{
    MV_TARGET_ATTRIB    targetAttribs;
    MV_DEC_REGS         decRegs;
    
    /* Parameter checking   */
    if (winNum >= ETH_MAX_DECODE_WIN)
    {
        mvOsPrintf("mvEthWinSet: ERR. Invalid win num %d\n",winNum);
        return MV_BAD_PARAM;
    }    
    
    /* Check if the requested window overlapps with current windows     */
    if (MV_TRUE == ethWinOverlapDetect(port, winNum, &pAddrDecWin->addrWin))
    {
        mvOsPrintf("mvEthWinSet: 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("mvEthWinSet: Error setting Ethernet 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(ETH_WIN_BASE_REG(port, winNum));
    decRegs.sizeReg = MV_REG_READ(ETH_WIN_SIZE_REG(port, winNum));
    
    if (MV_OK != mvCtrlAddrDecToReg(&(pAddrDecWin->addrWin),&decRegs))
    {
        mvOsPrintf("mvEthWinSet:mvCtrlAddrDecToReg Failed\n");
        return MV_ERROR;
    }
    
    mvCtrlAttribGet(pAddrDecWin->target,&targetAttribs);
    
    /* set attributes */
    decRegs.baseReg &= ~ETH_WIN_ATTR_MASK;
    decRegs.baseReg |= targetAttribs.attrib << ETH_WIN_ATTR_OFFS;
    /* set target ID */
    decRegs.baseReg &= ~ETH_WIN_TARGET_MASK;
    decRegs.baseReg |= targetAttribs.targetId << ETH_WIN_TARGET_OFFS;
    
    /* for the safe side we disable the window before writing the new
    values */
    mvEthWinEnable(port, winNum, MV_FALSE);
    MV_REG_WRITE(ETH_WIN_BASE_REG(port, winNum), decRegs.baseReg);
    
    /* Write to address decode Size Register                            */
    MV_REG_WRITE(ETH_WIN_SIZE_REG(port, winNum), decRegs.sizeReg);
    
    /* Enable address decode target window                              */
    if (pAddrDecWin->enable == MV_TRUE)
    {
            mvEthWinEnable(port, winNum, MV_TRUE);
    }
    
    return MV_OK;
}