Example #1
0
/*******************************************************************************
* mvDmaWinEnable - Enable/disable a DMA to target address window
*
* DESCRIPTION:
*       This function enable/disable a DMA to target address window.
*       According to parameter 'enable' the routine will enable the 
*       window, thus enabling DMA accesses (before enabling the window it is 
*       tested for overlapping). Otherwise, the window will be disabled.
*
* INPUT:
*       winNum - IDMA to target address decode window number.
*       enable - Enable/disable parameter.
*
* OUTPUT:
*       N/A
*
* RETURN:
*       MV_ERROR if decode window number was wrong or enabled window overlapps.
*
*******************************************************************************/
MV_STATUS mvDmaWinEnable(MV_U32 winNum,MV_BOOL enable)
{
	MV_DMA_DEC_WIN addrDecWin;
    
	/* Parameter checking   */
	if (winNum >= IDMA_MAX_ADDR_DEC_WIN)
	{
		mvOsPrintf("mvDmaWinEnable:ERR. Invalid winNum%d\n",winNum);
		return MV_ERROR;
	}

	if (enable == MV_TRUE) 
	{   /* First check for overlap with other enabled windows				*/
		/* Get current window */
		if (MV_OK != mvDmaWinGet(winNum, &addrDecWin))
		{
			mvOsPrintf("mvDmaWinEnable:ERR. targetWinGet fail\n");
			return MV_ERROR;
		}
		/* Check for overlapping */
		if (MV_FALSE == dmaWinOverlapDetect(winNum, &(addrDecWin.addrWin)))
		{
			/* No Overlap. Enable address decode target window              */
			MV_REG_BIT_RESET(IDMA_BASE_ADDR_ENABLE_REG, IBAER_ENABLE(winNum));
		}
		else
		{   /* Overlap detected	*/
			mvOsPrintf("mvDmaWinEnable:ERR. Overlap detected\n");
			return MV_ERROR;
		}
	}
	else
	{   /* Disable address decode target window                             */
		MV_REG_BIT_SET(IDMA_BASE_ADDR_ENABLE_REG, IBAER_ENABLE(winNum));
	}
	return MV_OK;
}
Example #2
0
MV_STATUS mvTdmWinEnable(int winNum, MV_BOOL enable)
{
	MV_TDM_DEC_WIN addrDecWin;

	if (MV_TRUE == enable)
	{
		if (winNum >= TDM_MBUS_MAX_WIN)
		{
			mvOsPrintf("mvTdmWinEnable:ERR. Invalid winNum%d\n",winNum);
			return MV_ERROR;
		}	
		
		/* First check for overlap with other enabled windows				*/
		/* Get current window */
		if (MV_OK != mvTdmWinGet(winNum, &addrDecWin))
		{
			mvOsPrintf("mvTdmWinEnable:ERR. targetWinGet fail\n");
			return MV_ERROR;
		}
		/* Check for overlapping */
		if (MV_FALSE == tdmWinOverlapDetect(winNum, &(addrDecWin.addrWin)))
		{
			/* No Overlap. Enable address decode target window */
			MV_REG_BIT_SET(TDM_WIN_CTRL_REG(winNum), TDM_WIN_ENABLE_MASK);
		}
		else
		{   /* Overlap detected	*/
			mvOsPrintf("mvTdmWinEnable:ERR. Overlap detected\n");
			return MV_ERROR;
		}
	}
	else
	{
		MV_REG_BIT_RESET(TDM_WIN_CTRL_REG(winNum), TDM_WIN_ENABLE_MASK);	
	}
	return MV_OK;
}
Example #3
0
/*******************************************************************************
* sdramIfWinOverlap - Check if an address window overlap an SDRAM address window
*
* DESCRIPTION:
*		This function scan each SDRAM address decode window to test if it 
*		overlapps the given address windoow 
*
* INPUT:
*       target      - SDRAM target where the function skips checking.
*       pAddrDecWin - The tested address window for overlapping with 
*					  SDRAM windows.
*
* OUTPUT:
*       None.
*
* RETURN:
*       MV_TRUE if the given address window overlaps any enabled address
*       decode map, MV_FALSE otherwise.
*
*******************************************************************************/
static MV_BOOL sdramIfWinOverlap(MV_TARGET target, MV_ADDR_WIN *pAddrWin)
{
	MV_TARGET	targetNum;
	MV_DRAM_DEC_WIN 	addrDecWin;
	
	for(targetNum = SDRAM_CS0; targetNum < SDRAM_CS3+1 ; targetNum++)
	{
		/* don't check our winNum or illegal targets */
		if (targetNum == target)
		{
			continue;
		}
		
		/* Get window parameters 	*/
		if (MV_OK != mvDramIfWinGet(targetNum, &addrDecWin))
		{
			mvOsPrintf("sdramIfWinOverlap: ERR. TargetWinGet failed\n");
			return MV_ERROR;
		}
	
		/* Do not check disabled windows	*/
		if (MV_FALSE == addrDecWin.enable)
		{
			continue;
		}
	
		if(MV_TRUE == ctrlWinOverlapTest(pAddrWin, &addrDecWin.addrWin))
		{                    
			mvOsPrintf(
			"sdramIfWinOverlap: Required target %d overlap winNum %d\n", 
			target, targetNum);
			return MV_TRUE;           
		}
	}
	
	return MV_FALSE;
}
Example #4
0
void mvEthSwitchPhyRegWrite(MV_U32 ethPortNum, MV_U16 prt,
                                 MV_U16 regOffs, MV_U16 data)
{
	MV_U16 reg;
	volatile MV_U32 timeout;

	/*Make sure SMIBusy bit cleared before another SMI operation can take place*/
	timeout = KW2_SW_PHY_TIMEOUT;
	do {
		mvEthSwitchRegRead(ethPortNum, MV_KW2_SW_GLOBAL_2_REG_DEV_ADDR,
				MV_KW2_SW_SMI_PHY_COMMAND,&reg);
		if(timeout-- == 0)
		{
			mvOsPrintf("mvEthPhyRegRead: SMI busy timeout\n");
			return;
		}
	}while (reg & KW2_SW_PHY_SMI_BUSY_MASK);

	mvEthSwitchRegWrite (ethPortNum, MV_KW2_SW_GLOBAL_2_REG_DEV_ADDR,
			MV_KW2_SW_SMI_PHY_DATA, data);

	mvEthSwitchRegWrite (ethPortNum, MV_KW2_SW_GLOBAL_2_REG_DEV_ADDR,
			MV_KW2_SW_SMI_PHY_COMMAND,(0x9400 | (prt << 5) | regOffs));

	/*Make sure SMIBusy bit cleared before another SMI operation can take place*/
	timeout = KW2_SW_PHY_TIMEOUT;
	do {
		mvEthSwitchRegRead(ethPortNum, MV_KW2_SW_GLOBAL_2_REG_DEV_ADDR,
				MV_KW2_SW_SMI_PHY_COMMAND,&reg);
		if(timeout-- == 0)
		{
			mvOsPrintf("mvEthPhyRegRead: SMI busy timeout\n");
			return;
		}
	}while (reg & KW2_SW_PHY_SMI_BUSY_MASK);

}
/*******************************************************************************
* mvXorSetProtWinSet - Configure access attributes of a XOR engine
*                               to one of the XOR memory windows.
*
* DESCRIPTION:
*       Each engine can be configured with access attributes for each of the
*       memory spaces. This function sets access attributes
*       to a given window for the given engine
*
* INPUTS:
*       chan    - One of the possible engines.
*       winNum  - One of the possible XOR memory spaces.
*       access  - Protection access rights.
*       write   - Write rights.
*
* OUTPUT:
*       None.
*
* RETURN:
*       MV_BAD_PARAM if parameters to function invalid, MV_OK otherwise.
*
*******************************************************************************/
MV_STATUS mvXorProtWinSet(MV_U32 unit, MV_U32 chan, MV_U32 winNum, MV_BOOL access, MV_BOOL write)
{
	MV_U32 temp;

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

	temp = MV_REG_READ(XOR_WINDOW_CTRL_REG(unit, chan)) & (~XEXWCR_WIN_ACC_MASK(winNum));

	/* if access is disable */
	if (!access) {
		/* disable access */
		temp |= XEXWCR_WIN_ACC_NO_ACC(winNum);
	}
	/* if access is enable */
	else {
		/* if write is enable */
		if (write) {
			/* enable write */
			temp |= XEXWCR_WIN_ACC_RW(winNum);
		}
		/* if write is disable */
		else {
			/* disable write */
			temp |= XEXWCR_WIN_ACC_RO(winNum);
		}
	}
	MV_REG_WRITE(XOR_WINDOW_CTRL_REG(unit, chan), temp);
	return MV_OK;
}
Example #6
0
/* Print a NFP Rule */
void    mvFpRulePrint(const MV_FP_RULE *rule)
{
	mvFpActionTypePrint(rule);
	mvFpRuleTypePrint(rule);
	mvOsPrintf(", SIP=");
	mvDebugPrintIpAddr(MV_32BIT_BE(rule->routingInfo.srcIp));
	mvOsPrintf(", DIP=");
	mvDebugPrintIpAddr(MV_32BIT_BE(rule->routingInfo.dstIp));
	mvOsPrintf(", GTW=");
	mvDebugPrintIpAddr(MV_32BIT_BE(rule->routingInfo.defGtwIp));
	mvOsPrintf(", DA=");
	mvDebugPrintMacAddr(rule->routingInfo.dstMac);
	mvOsPrintf(", SA=");
	mvDebugPrintMacAddr(rule->routingInfo.srcMac);
	mvOsPrintf(", inIf=%d", rule->routingInfo.inIfIndex);
	mvOsPrintf(", outIf=%d", rule->routingInfo.outIfIndex);

  	mvOsPrintf(", count=%d, aware_flags=0x%X", rule->mgmtInfo.new_count, rule->routingInfo.aware_flags);
	mvOsPrintf("\n");
}
Example #7
0
void mvCesaDebugSA(short sid, int mode)
{
	MV_CESA_OPERATION oper;
	MV_CESA_DIRECTION dir;
	MV_CESA_CRYPTO_ALG cryptoAlg;
	MV_CESA_CRYPTO_MODE cryptoMode;
	MV_CESA_MAC_MODE macMode;
	MV_CESA_SA *pSA = pCesaSAD[sid];

	if (pSA != NULL) {
		/*if(((pSA->count != 0) && (mode > 0)) || (mode >= 2))
		   { */
		mvOsPrintf("\n\nCESA SA Entry #%d (%p) - %s (count=%d)\n",
			   sid, pSA, (pSA != NULL) ? "Valid" : "Invalid", pSA->count);

		oper = (pSA->config & MV_CESA_OPERATION_MASK) >> MV_CESA_OPERATION_OFFSET;
		dir = (pSA->config & MV_CESA_DIRECTION_MASK) >> MV_CESA_DIRECTION_BIT;
		mvOsPrintf("%s - %s ", mvCesaDebugOperStr(oper), (dir == MV_CESA_DIR_ENCODE) ? "Encode" : "Decode");
		if (oper != MV_CESA_MAC_ONLY) {
			cryptoAlg = (pSA->config & MV_CESA_CRYPTO_ALG_MASK) >> MV_CESA_CRYPTO_ALG_OFFSET;
			cryptoMode = (pSA->config & MV_CESA_CRYPTO_MODE_MASK) >> MV_CESA_CRYPTO_MODE_BIT;
			mvOsPrintf("- %s - %s ", mvCesaDebugCryptoAlgStr(cryptoAlg),
				   (cryptoMode == MV_CESA_CRYPTO_ECB) ? "ECB" : "CBC");
		}
/*******************************************************************************
* mvPexLocalBusNumSet - Set PEX interface local bus number.
*
* DESCRIPTION:
*       This function sets given PEX interface its local bus number.
*       Note: In case the PEX interface is PEX-X, the information is read-only.
*
* INPUT:
*       pexIf  - PEX interface number.
*       busNum - Bus number.
*
* OUTPUT:
*       None.
*
* RETURN:
*       MV_NOT_ALLOWED in case PEX interface is PEX-X.
*		MV_BAD_PARAM on bad parameters ,
*       otherwise MV_OK
*
*******************************************************************************/
MV_STATUS mvPexLocalBusNumSet(MV_U32 pexIf, MV_U32 busNum)
{
	MV_U32 pexStatus;

	/* Parameter checking   */
	if (pexIf >= pexHalData[pexIf].maxPexIf) {
		mvOsPrintf("mvPexLocalBusNumSet: ERR. Invalid PEX interface %d\n", pexIf);
		return MV_BAD_PARAM;
	}
	if (busNum >= MAX_PEX_BUSSES) {
		mvOsPrintf("mvPexLocalBusNumSet: ERR. bus number illigal %d\n", busNum);
		return MV_ERROR;
	}

	pexStatus = MV_REG_READ(PEX_STATUS_REG(pexIf));

	pexStatus &= ~PXSR_PEX_BUS_NUM_MASK;

	pexStatus |= (busNum << PXSR_PEX_BUS_NUM_OFFS) & PXSR_PEX_BUS_NUM_MASK;

	MV_REG_WRITE(PEX_STATUS_REG(pexIf), pexStatus);

	return MV_OK;
}
Example #9
0
/*******************************************************************************
* mvCpuIfTargetWinSizeGet - Get CPU target address window size
*
* DESCRIPTION:
*		Get the size of CPU-to-peripheral target window.
*
* INPUT:
*       target - Peripheral target enumerator
*
* OUTPUT:
*       None.
*
* RETURN:
*       32bit size. Function also returns '0' if window is closed.
*		Function returns 0xFFFFFFFF in case of an error.
*
*******************************************************************************/
MV_U32 mvCpuIfTargetWinSizeGet(MV_TARGET target)
{
	MV_CPU_DEC_WIN addrDecWin;

	target = MV_CHANGE_BOOT_CS(target);

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

	/* Get the winNum window */
	if (MV_OK != mvCpuIfTargetWinGet(target, &addrDecWin)) {
		mvOsPrintf("mvCpuIfTargetWinSizeGet:ERR. Getting target %d failed.\n", target);
		return 0;
	}

	/* Check if window is enabled   */
	if (addrDecWin.enable == MV_TRUE)
		return (addrDecWin.addrWin.size);
	else
		return 0;	/* Window disabled. return 0 */
}
Example #10
0
/* Print NFP Rule Database (Routing + ARP information table) */
MV_STATUS   mvFpRuleDbPrint(void)
{
	MV_U32 count, i;
	MV_FP_RULE *currRule;

	mvOsPrintf("\nPrinting NFP Rule Database\n");
    count = 0;

	for(i=0; i<ruleDbSize; i++) 
    {
		currRule = ruleDb[i].ruleChain;

        if(currRule != NULL)
    	    mvOsPrintf("\n%03u: FP DB hash=0x%x", count, i);

		while (currRule != NULL) {
          	mvOsPrintf("\n%03u: Rule=%p: ", count, currRule);
	        mvFpRulePrint(currRule);
	        currRule = currRule->next;
            count++;
        }
	}
	return MV_OK;
}
Example #11
0
/*******************************************************************************
* mvEthProtWinSet - Set access protection of Ethernet to target window.
*
* DESCRIPTION:
*       Each Ethernet port can be configured with access attributes for each 
*       of the Ethenret to target windows (address decode windows). This
*       function sets access attributes to a given window for the given channel.
*
* INPUTS:
*       ethPort   - ETH channel number. See MV_ETH_CHANNEL enumerator.
*       winNum - IETH to target address decode window number.
*       access - IETH access rights. See MV_ACCESS_RIGHTS enumerator.
*
* OUTPUT:
*       None.
*
* RETURN:
*       MV_ERROR in case window number is invalid or access right reserved.
*
*******************************************************************************/
MV_STATUS mvEthProtWinSet(MV_U32 portNo, MV_U32 winNum, MV_ACCESS_RIGHTS access)
{    
    MV_U32 protReg;

    /* Parameter checking   */
    if(portNo >= mvCtrlEthMaxPortGet())
    {
        mvOsPrintf("mvEthProtWinSet:ERR. Invalid port number %d\n", portNo);
        return MV_ERROR;
    }
    
    if (winNum >= ETH_MAX_DECODE_WIN)
    {
            mvOsPrintf("mvEthProtWinSet:ERR. Invalid winNum%d\n",winNum);
            return MV_ERROR;
    }

    if((access == ACC_RESERVED) || (access >= MAX_ACC_RIGHTS))
    {
        mvOsPrintf("mvEthProtWinSet:ERR. Inv access param %d\n", access);
        return MV_ERROR;
    }
    /* Read current protection register */
    protReg = MV_REG_READ(ETH_ACCESS_PROTECT_REG(portNo));
                          
    /* Clear protection window field */
    protReg &= ~(ETH_PROT_WIN_MASK(winNum));

    /* Set new protection field value */
    protReg |= (access << (ETH_PROT_WIN_OFFS(winNum)));
    
    /* Write protection register back   */
    MV_REG_WRITE(ETH_ACCESS_PROTECT_REG(portNo), protReg);

    return MV_OK;
}               
Example #12
0
/*******************************************************************************
* mvCntmrLoad -
*
* DESCRIPTION:
*       Load an init Value to a given counter/timer
*
* INPUT:
*       countNum - counter number
*       value - value to be loaded
*
* OUTPUT:
*       None.
*
* RETURN:
*       MV_BAD_PARAM on bad parameters , MV_ERROR on error ,MV_OK on sucess
*******************************************************************************/
MV_STATUS mvCntmrLoad(MV_U32 countNum, MV_U32 value)
{
	if (countNum >= MV_CNTMR_MAX_COUNTER )
	{

		mvOsPrintf(("mvCntmrLoad: Err. Illigal counter number \n"));
		return MV_BAD_PARAM;;

	}

	MV_REG_WRITE(CNTMR_RELOAD_REG(countNum),value);
	MV_REG_WRITE(CNTMR_VAL_REG(countNum),value);

	return MV_OK;
}
Example #13
0
/* no need to use in tool */
void mvCesaDebugMbuf(const char *str, MV_CESA_MBUF *pMbuf, int offset, int size)
{
	int frag, len, fragOffset;

	if (str != NULL)
		mvOsPrintf("%s: pMbuf=%p, numFrags=%d, mbufSize=%d\n", str, pMbuf, pMbuf->numFrags, pMbuf->mbufSize);

	frag = mvCesaMbufOffset(pMbuf, offset, &fragOffset);
	if (frag == MV_INVALID) {
		mvOsPrintf("CESA Mbuf Error: offset (%d) out of range\n", offset);
		return;
	}

	for (; frag < pMbuf->numFrags; frag++) {
		mvOsPrintf("#%2d. bufVirt=%p, bufSize=%d\n",
			   frag, pMbuf->pFrags[frag].bufVirtPtr, pMbuf->pFrags[frag].bufSize);
		if (size > 0) {
			len = MV_MIN(pMbuf->pFrags[frag].bufSize, size);
			mvDebugMemDump(pMbuf->pFrags[frag].bufVirtPtr + fragOffset, len, 1);
			size -= len;
			fragOffset = 0;
		}
	}
}
Example #14
0
/*******************************************************************************
* ahbToMbusRemapRegOffsGet - Get CPU address remap register offsets
*
* DESCRIPTION:
* 		CPU to PCI address remap registers offsets are inconsecutive. 
*		This function returns PCI address remap registers offsets.
*
* INPUT:
*       cpu      	- CPU id
*       winNum - Address decode window number. See MV_U32 enumerator.
*
* OUTPUT:
*       None.
*
* RETURN:
*		MV_ERROR if winNum is not a PCI one.
*
*******************************************************************************/
static MV_STATUS ahbToMbusRemapRegOffsGet(MV_U32 cpu, MV_U32 winNum, 
					    AHB_TO_MBUS_REMAP_REG_OFFS *pRemapRegs)
{
	pRemapRegs->lowRegOffs  = AHB_TO_MBUS_WIN_REMAP_LOW_REG(cpu, winNum);
	pRemapRegs->highRegOffs = AHB_TO_MBUS_WIN_REMAP_HIGH_REG(cpu, winNum);

	if ((pRemapRegs->lowRegOffs == 0) || (pRemapRegs->highRegOffs == 0))
	{
			DB(mvOsPrintf("ahbToMbusRemapRegOffsGet: ERR. Invalid winNum %d\n", 
						winNum));
		   	return MV_NO_SUCH;
	}

	return MV_OK;
}
Example #15
0
/*******************************************************************************
* mvNetaPmtClear - Clear Packet Modification Table
*
* INPUT:
*       int			port - NETA port number
*
* RETURN:   MV_STATUS  
*               MV_OK - Success, Others - Failure
*******************************************************************************/
MV_STATUS   mvNetaPmtClear(int port)
{
	int         idx;
	MV_NETA_PMT entry;

    if ((port < 0) || (port >= mvNetaHalData.maxPort)) {
        mvOsPrintf("%s: port %d is out of range\n", __FUNCTION__, port);
        return MV_OUT_OF_RANGE;
    }

    MV_NETA_PMT_INVALID_SET(&entry);
    for (idx=0; idx<MV_ETH_PMT_SIZE; idx++)
		mvNetaPmtWrite(port, idx, &entry);

    return MV_OK;
}
/*******************************************************************************
* mvPp2WinEnable - Enable/disable a ETH to target address window
*
* DESCRIPTION:
*       This function enable/disable a ETH to target address window.
*       According to parameter 'enable' the routine will enable the
*       window, thus enabling ETH accesses (before enabling the window it is
*       tested for overlapping). Otherwise, the window will be disabled.
*
* INPUT:
*       winNum - ETH to target address decode window number.
*       enable - Enable/disable parameter.
*
* OUTPUT:
*       N/A
*
* RETURN:
*       MV_ERROR if decode window number was wrong or enabled window overlapps.
*
*******************************************************************************/
MV_STATUS mvPp2WinEnable(MV_U32 dummy/*backward compability*/, MV_U32 winNum, MV_BOOL enable)
{
	/* Parameter checking   */
	if (winNum >= ETH_MAX_DECODE_WIN) {
		mvOsPrintf("mvPp2TargetWinEnable:ERR. Invalid winNum%d\n", winNum);
		return MV_ERROR;
	}

	if (enable)
		MV_REG_BIT_SET(ETH_BASE_ADDR_ENABLE_REG, (1 << winNum));
	else
		/* Disable address decode target window                             */
		MV_REG_BIT_RESET(ETH_BASE_ADDR_ENABLE_REG, (1 << winNum));

	return MV_OK;
}
Example #17
0
/*******************************************************************************
* mvFlashErase - Completly Erase a flash.
*
* DESCRIPTION:
*       This function completly erase the given flash, by erasing all the
*		flash sectors one by one (Currently there is no support for HW
*		flash erase).
*
* INPUT:
*       pFlash - Flash identifier structure.
*
* OUTPUT:
*       None.
*
* RETURN:
*	MV_BAD_PARAM if pFlash is NULL,
*   MV_OK if erased completed successfully,
*	MV_FAIL otherwise.
*
*******************************************************************************/
MV_STATUS mvFlashErase(MV_FLASH_INFO *pFlash)
{
	MV_U32 i;

	if (NULL == pFlash)
		return MV_BAD_PARAM;

	DB(mvOsPrintf("Flash: mvFlashErase \n"));
	/* erase all sectors in the flash one by one */
	for (i = 0; i < mvFlashNumOfSecsGet(pFlash); i++) {
		if (MV_OK != mvFlashSecErase(pFlash, i))
			return MV_FAIL;
	}

	return MV_OK;
}
Example #18
0
MV_BOOL mvSemaLock(MV_32 num)
{
	MV_U32 tmp;
	MV_U32 cpuId;
	if (num > MV_MAX_SEMA)
	{
		mvOsPrintf("Invalid semaphore number\n");
		return MV_FALSE;
	}
	cpuId = whoAmI();
	do
	{
		tmp = MV_REG_BYTE_READ(MV_SEMA_REG_BASE+num);
	} while ((tmp & 0xFF) != cpuId);
	return MV_TRUE;
}
Example #19
0
MV_BOOL mvSemaTryLock(MV_32 num)
{
	MV_U32 tmp;
	if (num > MV_MAX_SEMA)
	{
		mvOsPrintf("Invalid semaphore number\n");
		return MV_FALSE;
	}	       
	tmp = MV_REG_BYTE_READ(MV_SEMA_REG_BASE+num);
	if ((tmp & 0xFF) != whoAmI())
	{
		return MV_FALSE;
	}
	else
		return MV_TRUE;
}
Example #20
0
/*******************************************************************************
* mvPexModeGet - Get Pex Mode
*
* DESCRIPTION:
*
* INPUT:
*       pexIf   - PEX interface number.
*
* OUTPUT:
*       pexMode - Pex mode structure
*
* RETURN:
*       MV_OK on success , MV_ERROR otherwise
*
*******************************************************************************/
MV_U32 mvPexModeGet(MV_U32 pexIf,MV_PEX_MODE *pexMode)
{
	MV_U32 pexData;

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

	pexData = MV_REG_READ(PEX_CTRL_REG(pexIf));

	switch (pexData & PXCR_DEV_TYPE_CTRL_MASK)
	{
	case PXCR_DEV_TYPE_CTRL_CMPLX:
		pexMode->pexType = MV_PEX_ROOT_COMPLEX;
		break;
	case PXCR_DEV_TYPE_CTRL_POINT:
		pexMode->pexType = MV_PEX_END_POINT;
		break;

	}

    /* Check if we have link */
    if (MV_REG_READ(PEX_STATUS_REG(pexIf)) & PXSR_DL_DOWN)
    {
        pexMode->pexLinkUp = MV_FALSE;
        
        /* If there is no link, the auto negotiation data is worthless */
        pexMode->pexWidth  = MV_PEX_WITDH_INVALID;
    }   
    else
    {
        pexMode->pexLinkUp = MV_TRUE;

        /* We have link. The link width is now valid */
        pexData = MV_REG_READ(PEX_CFG_DIRECT_ACCESS(pexIf, PEX_LINK_CTRL_STAT_REG));
        pexMode->pexWidth = ((pexData & PXLCSR_NEG_LNK_WDTH_MASK) >> 
                             PXLCSR_NEG_LNK_WDTH_OFFS);
    }

    return MV_OK;
}
Example #21
0
* mvTdmWinInit - Initialize TDM address decode windows 
*
* DESCRIPTION:
*               This function initialize TDM window decode unit. It set the 
*               default address decode
*               windows of the unit.
*
* INPUT:
*       None.
*
* OUTPUT:
*       None.
*
* RETURN:
*       MV_ERROR if setting fail.
*******************************************************************************/

MV_STATUS mvTdmWinInit(void)
{
	MV_U32 		winNum;
	MV_U32		winPrioIndex = 0;
	MV_CPU_DEC_WIN cpuAddrDecWin;
	MV_TDM_DEC_WIN tdmWin;
	MV_STATUS status;

	/*Disable all windows*/	
	for (winNum = 0; winNum < TDM_MBUS_MAX_WIN; winNum++)
	{
		mvTdmWinEnable(winNum, MV_FALSE);
	}

	for (winNum = 0; ((tdmAddrDecPrioTap[winPrioIndex] != TBL_TERM) && 
					  (winNum < TDM_MBUS_MAX_WIN)); )
	{	
		status = mvCpuIfTargetWinGet(tdmAddrDecPrioTap[winPrioIndex], 
									 &cpuAddrDecWin);
        if (MV_NO_SUCH == status)
        {
            winPrioIndex++;
            continue;
        }
		if (MV_OK != status)
		{
			mvOsPrintf("mvTdmInit: ERR. mvCpuIfTargetWinGet failed\n");
			return MV_ERROR;
		}

        if (cpuAddrDecWin.enable == MV_TRUE)
		{
			tdmWin.addrWin.baseHigh = cpuAddrDecWin.addrWin.baseHigh;
			tdmWin.addrWin.baseLow = cpuAddrDecWin.addrWin.baseLow;
			tdmWin.addrWin.size = cpuAddrDecWin.addrWin.size;
			tdmWin.enable = MV_TRUE;
		    tdmWin.target = tdmAddrDecPrioTap[winPrioIndex];
		    if (MV_OK != mvTdmWinSet(winNum, &tdmWin))
		    {
			    return MV_ERROR;
		    }
		    winNum++;
		}
		winPrioIndex++;			
    }
	return MV_OK;
}
/*******************************************************************************
* mvNflashInit - Initialize the Flash indetifier structure.
*
* DESCRIPTION:
*		This function initialize the Flash indetifier structure. 
*		Note that this function must be called only after the MV_NFLASH_HW_IF
*		field in the MV_NFLASH_INFO was initialized by the BSP. Only then 
*		access to nflash is possible.
*
* INPUT:
*		pFlash - flash information.
*
* OUTPUT:
*		Initialize MV_NFLASH_INFO Nflash identifier struct.
*		
*
* RETURN:
*		MV_ERROR if device and vendor ID can't be read.
*		MV_OK otherwise.
*
*******************************************************************************/
MV_STATUS mvNflashInit(MV_NFLASH_INFO *pFlash)
{
	MV_U16 flashId;
	int i = 0;
    
	if(NULL == pFlash)
		return 0;

	/* Initialize base address and device width from BSP */
	pFlash->baseAddr = pFlash->nflashHwIf.devBaseAddr;
	pFlash->devWidth = pFlash->nflashHwIf.devWidth;
		
    /* Initialize HW interface */
    mvNflashHwIfInit(&pFlash->nflashHwIf);

	/* Read the device and vendor ID */
	flashId = mvNflashIdGet(pFlash);

	/* check if this flash is Supported, and Init the pFlash flash feild */	
    while((supNflashAry[i].devVen != ((flashId << VENDOR_ID_OFFS) & 0xFF) && 
		  (supNflashAry[i].devId  != ((flashId << DEVICE_ID_OFFS) & 0xFF))))
	{		
		if (i++ == (sizeof(supNflashAry) / sizeof(supNflashAry[0])))
		{
			mvOsPrintf("mvNflashInit: Unsupported Flash ID 0x%x.\n", flashId);
			return MV_ERROR;
		}
	}

	pFlash->pNflashStruct = &supNflashAry[i];

	/* Init pFlash sectors */	
	/*
	if(MV_OK != flashSecsInit(pFlash))
	{
		mvOsPrintf("Flash: ERROR mvFlashInit flashSecsInit failed \n");
		return 0;
	}*/
	
    /* print all flash information */
	DB(mvNflashPrint(pFlash));

	/* reset the Flash */
	mvNflashReset(pFlash);

	return MV_OK;
	}
Example #23
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)) );    
    }
}
/* Print MIB counters of the Ethernet port */
void mvEthMibCountersShow(int port)
{
	if (MV_PON_PORT(port)) {
		mvOsPrintf("%s: not supported for PON port\n", __func__);
		return;
	}

/*TODO: check port
	if (mvNetaTxpCheck(port))
		return;
*/
	mvOsPrintf("\nMIBs: port=%d\n", port);

	mvOsPrintf("\n[Rx]\n");
	mvEthMibPrint(port, ETH_MIB_GOOD_FRAMES_RECEIVED, "GOOD_FRAMES_RECEIVED");
	mvEthMibPrint(port, ETH_MIB_BAD_FRAMES_RECEIVED, "BAD_FRAMES_RECEIVED");
	mvEthMibPrint(port, ETH_MIB_BROADCAST_FRAMES_RECEIVED, "BROADCAST_FRAMES_RECEIVED");
	mvEthMibPrint(port, ETH_MIB_MULTICAST_FRAMES_RECEIVED, "MULTICAST_FRAMES_RECEIVED");
	mvEthMibPrint(port, ETH_MIB_GOOD_OCTETS_RECEIVED_LOW, "GOOD_OCTETS_RECEIVED");
	mvOsPrintf("\n[Rx Errors]\n");
	mvEthMibPrint(port, ETH_MIB_BAD_OCTETS_RECEIVED, "BAD_OCTETS_RECEIVED");
	mvEthMibPrint(port, ETH_MIB_UNDERSIZE_RECEIVED, "UNDERSIZE_RECEIVED");
	mvEthMibPrint(port, ETH_MIB_FRAGMENTS_RECEIVED, "FRAGMENTS_RECEIVED");
	mvEthMibPrint(port, ETH_MIB_OVERSIZE_RECEIVED, "OVERSIZE_RECEIVED");
	mvEthMibPrint(port, ETH_MIB_JABBER_RECEIVED, "JABBER_RECEIVED");
	mvEthMibPrint(port, ETH_MIB_MAC_RECEIVE_ERROR, "MAC_RECEIVE_ERROR");
	mvEthMibPrint(port, ETH_MIB_BAD_CRC_EVENT, "BAD_CRC_EVENT");
	mvOsPrintf("\n[Tx]\n");
	mvEthMibPrint(port, ETH_MIB_GOOD_FRAMES_SENT, "GOOD_FRAMES_SENT");
	mvEthMibPrint(port, ETH_MIB_BROADCAST_FRAMES_SENT, "BROADCAST_FRAMES_SENT");
	mvEthMibPrint(port, ETH_MIB_MULTICAST_FRAMES_SENT, "MULTICAST_FRAMES_SENT");
	mvEthMibPrint(port, ETH_MIB_GOOD_OCTETS_SENT_LOW, "GOOD_OCTETS_SENT");
	mvOsPrintf("\n[Tx Errors]\n");
	mvEthMibPrint(port, ETH_MIB_INTERNAL_MAC_TRANSMIT_ERR, "INTERNAL_MAC_TRANSMIT_ERR");
	mvEthMibPrint(port, ETH_MIB_EXCESSIVE_COLLISION, "EXCESSIVE_COLLISION");
	mvEthMibPrint(port, ETH_MIB_COLLISION, "COLLISION");
	mvEthMibPrint(port, ETH_MIB_LATE_COLLISION, "LATE_COLLISION");
	mvOsPrintf("\n[FC control]\n");
	mvEthMibPrint(port, ETH_MIB_UNREC_MAC_CONTROL_RECEIVED, "UNREC_MAC_CONTROL_RECEIVED");
	mvEthMibPrint(port, ETH_MIB_GOOD_FC_RECEIVED, "GOOD_FC_RECEIVED");
	mvEthMibPrint(port, ETH_MIB_BAD_FC_RECEIVED, "BAD_FC_RECEIVED");
	mvEthMibPrint(port, ETH_MIB_FC_SENT, "FC_SENT");
	mvOsPrintf("\n");
}
/* Returns the head of the list if successful, NULL otherwise */
MV_LIST_ELEMENT *mvListCreate(MV_VOID)
{
	MV_LIST_ELEMENT *head = (MV_LIST_ELEMENT *)mvOsMalloc(sizeof(MV_LIST_ELEMENT));

	if (head) {
		head->prev = NULL;
		head->next = NULL;
		head->data = 0;
	}

#ifdef MV_LIST_SANITY_CHECKS
	if (!head)
		mvOsPrintf("%s ERROR: memory allocation for new list failed\n", __func__);
#endif /* MV_LIST_SANITY_CHECKS */

	return head;
}
Example #26
0
/*******************************************************************************
* mvAudioWinInit - Initialize the integrated AUDIO target address window.
*
* DESCRIPTION:
*       Initialize the AUDIO peripheral target address window.
*
* INPUT:
*
*
* OUTPUT:
*     
*
* RETURN:
*       MV_ERROR if register parameters are invalid.
*
*******************************************************************************/
MV_STATUS mvAudioWinInit(int unit)
{
    int             winNum;
    MV_AUDIO_DEC_WIN  audioWin;
    MV_CPU_DEC_WIN  cpuAddrDecWin;
    MV_U32          status;

    /* Initiate Audio address decode */

    /* First disable all address decode windows */
    for(winNum = 0; winNum < MV_AUDIO_MAX_ADDR_DECODE_WIN; winNum++)
    {
        MV_U32  regVal = MV_REG_READ(MV_AUDIO_WIN_CTRL_REG(unit, winNum));
        regVal &= ~MV_AUDIO_WIN_ENABLE_MASK;
        MV_REG_WRITE(MV_AUDIO_WIN_CTRL_REG(unit, winNum), regVal);
    }

    for(winNum = 0; winNum < MV_AUDIO_MAX_ADDR_DECODE_WIN; winNum++)
    {
	/* We will set the Window to DRAM_CS0 in default */
	/* first get attributes from CPU If */
	status = mvCpuIfTargetWinGet(SDRAM_CS0,	&cpuAddrDecWin);
	
	if (MV_OK != status)
	{
		mvOsPrintf("%s: ERR. mvCpuIfTargetWinGet failed\n", __FUNCTION__);
		return MV_ERROR;
	}
	
	if (cpuAddrDecWin.enable == MV_TRUE)
	{
		audioWin.addrWin.baseHigh = cpuAddrDecWin.addrWin.baseHigh;
		audioWin.addrWin.baseLow  = cpuAddrDecWin.addrWin.baseLow;
		audioWin.addrWin.size     = cpuAddrDecWin.addrWin.size;
		audioWin.enable           = MV_TRUE;
		audioWin.target           = SDRAM_CS0;
	
		if(MV_OK != mvAudioWinSet(unit, winNum, &audioWin))
		{
			return MV_ERROR;
		}
	}
    }

    return MV_OK;
}
Example #27
0
void mvBmPoolEnable(int pool)
{
	MV_U32 regVal;

	/* validate poolId */
	if ((pool < 0) || (pool >= MV_BM_POOLS)) {
		mvOsPrintf("bmPoolId = %d is invalid \n", pool);
		return;
	}
	regVal = MV_REG_READ(MV_BM_POOL_BASE_REG(pool));
	regVal |= MV_BM_POOL_ENABLE_MASK;
	MV_REG_WRITE(MV_BM_POOL_BASE_REG(pool), regVal);

	/* Clear BM cause register */
	MV_REG_WRITE(MV_BM_INTR_CAUSE_REG, 0);

}
Example #28
0
/*******************************************************************************
* mvWaitOnWipClear - Block waiting for the WIP (write in progress) to be cleared
*
* DESCRIPTION:
*       Block waiting for the WIP (write in progress) to be cleared
*
********************************************************************************/
static MV_STATUS mvWaitOnWipClear(MV_SFLASH_INFO * pFlinfo)
{
    MV_STATUS ret;
	MV_U32 i;
    MV_U8 stat;

	for (i=0; i<MV_SFLASH_MAX_WAIT_LOOP; i++)
	{
        if ((ret = mvStatusRegGet(pFlinfo, &stat)) != MV_OK)
            return ret;

		if ((stat & MV_SFLASH_STATUS_REG_WIP_MASK) == 0)
			return MV_OK;
	}

    DB(mvOsPrintf("%s WARNING: Write Timeout!\n", __FUNCTION__);)
	return MV_TIMEOUT;
Example #29
0
static inline int xorReady(void)
{
    int timeout = 0;

    while (!(MV_REG_READ(XOR_CAUSE_REG(1)) & XOR_CAUSE_DONE_MASK(XOR_CHAN(0)))) {
        if (timeout > 0x100000) {
            mvOsPrintf("XOR timeout\n");
            return 0;
        }
        timeout++;
    }

    /* Clear int */
    MV_REG_WRITE(XOR_CAUSE_REG(1), ~(XOR_CAUSE_DONE_MASK(XOR_CHAN(0))));

    return 1;
}
Example #30
0
static int pnc_eth_port_map(int eth_port)
{
	switch (eth_port) {
	case 0:
		return 2;

	case 1:
		return 4;

	case 2:
		return 0;

	default:
		mvOsPrintf("%s: eth_port=%d is out of range\n", __func__, eth_port);
		return -1;
	}
}