예제 #1
0
ret_t rtl8370_getAsicRegBit(uint32 reg, uint32 bit, uint32 *value)
{
    
#if defined(RTK_X86_ASICDRV)/*RTK-CNSD2-NickWu-20061222: for x86 compile*/

    uint32 regData;
    ret_t retVal;

    if(bit>=RTL8370_REGBITLENGTH)
        return RT_ERR_INPUT;    
    
    retVal = Access_Read(reg, 2, &regData);    
    if (retVal != TRUE) 
		return RT_ERR_SMI;    
    
    *value = (regData & (0x1 << bit)) >> bit;    

    if(0x8370 == cleDebuggingDisplay)
        PRINT("R[0x%4.4x]=0x%4.4x\n",reg,regData);

#elif defined(CONFIG_RTL8370_ASICDRV_TEST)

    if(bit>=RTL8370_REGBITLENGTH)
        return RT_ERR_INPUT;    

    if(reg >= RTL8370_VIRTUAL_REG_SIZE)
        return RT_ERR_OUT_OF_RANGE;

    *value = (Rtl8370sVirtualReg[reg] & (0x1 << bit)) >> bit;    

    if(0x8370 == cleDebuggingDisplay)
        PRINT("R[0x%4.4x]=0x%4.4x\n",reg,Rtl8370sVirtualReg[reg]);
    
#else
    uint32 regData;
    ret_t retVal;

    retVal = smi_read(reg, &regData);
    if (retVal != RT_ERR_OK) 
		return RT_ERR_SMI;
  #ifdef CONFIG_RTL865X_CLE
    if(0x8370 == cleDebuggingDisplay)
        PRINT("R[0x%4.4x]=0x%4.4x\n",reg,regData);
  #endif
    
    *value = (regData & (0x1 << bit)) >> bit;    

#endif
    return RT_ERR_OK;
}
예제 #2
0
/* Function Name:
 *      rtl8367b_getAsicReg
 * Description:
 *      Get content of asic register
 * Input:
 *      reg 	- register's address
 *      value 	- Value setting to register
 * Output:
 *      None
 * Return:
 *      RT_ERR_OK 		- Success
 *      RT_ERR_SMI  	- SMI access error
 * Note:
 *      Value 0x0000 will be returned for ASIC un-mapping address
 */
ret_t rtl8367b_getAsicReg(rtk_uint32 reg, rtk_uint32 *pValue)
{

#if defined(RTK_X86_ASICDRV)

	rtk_uint32 regData;
	ret_t retVal;

	retVal = Access_Read(reg, 2, &regData);
	if(TRUE != retVal)
		return RT_ERR_SMI;

	*pValue = regData;

	if(0x8367B == cleDebuggingDisplay)
		PRINT("R[0x%4.4x]=0x%4.4x\n", reg, regData);

#elif defined(CONFIG_RTL8367B_ASICDRV_TEST)
	if(reg >= CLE_VIRTUAL_REG_SIZE)
		return RT_ERR_OUT_OF_RANGE;

	*pValue = CleVirtualReg[reg];

	if(0x8367B == cleDebuggingDisplay)
		PRINT("R[0x%4.4x]=0x%4.4x\n", reg, CleVirtualReg[reg]);

#elif defined(EMBEDDED_SUPPORT)
    if(reg > RTL8367B_REGDATAMAX  )
	    return RT_ERR_INPUT;

	*value = getReg(reg);

#else
	rtk_uint32 regData;
	ret_t retVal;

	retVal = smi_read(reg, &regData);
	if(retVal != RT_ERR_OK)
		return RT_ERR_SMI;

	*pValue = regData;
  #ifdef CONFIG_RTL865X_CLE
	if(0x8367B == cleDebuggingDisplay)
		PRINT("R[0x%4.4x]=0x%4.4x\n", reg, regData);
  #endif

#endif
	return RT_ERR_OK;
}
예제 #3
0
/* Function Name:
 *      rtl8367b_setAsicRegBit
 * Description:
 *      Set a bit value of a specified register
 * Input:
 *      reg 	- register's address
 *      bit 	- bit location
 *      value 	- value to set. It can be value 0 or 1.
 * Output:
 *      None
 * Return:
 *      RT_ERR_OK 		- Success
 *      RT_ERR_SMI  	- SMI access error
 *      RT_ERR_INPUT  	- Invalid input parameter
 * Note:
 *      Set a bit of a specified register to 1 or 0.
 */
ret_t rtl8367b_setAsicRegBit(rtk_uint32 reg, rtk_uint32 bit, rtk_uint32 value)
{

#if defined(RTK_X86_ASICDRV)
	rtk_uint32 regData;
	ret_t retVal;

	if(bit >= RTL8367B_REGBITLENGTH)
		return RT_ERR_INPUT;

	retVal = Access_Read(reg, 2, &regData);
	if(TRUE != retVal)
		return RT_ERR_SMI;

	if(0x8367B == cleDebuggingDisplay)
		PRINT("R[0x%4.4x]=0x%4.4x\n", reg, regData);

	if(value)
		regData = regData | (1 << bit);
	else
		regData = regData & (~(1 << bit));

	retVal = Access_Write(reg,2, regData);
	if(TRUE != retVal)
		return RT_ERR_SMI;

	if(0x8367B == cleDebuggingDisplay)
		PRINT("W[0x%4.4x]=0x%4.4x\n", reg, regData);


#elif defined(CONFIG_RTL8367B_ASICDRV_TEST)

	if(bit >= RTL8367B_REGBITLENGTH)
		return RT_ERR_INPUT;

	else if(reg >= CLE_VIRTUAL_REG_SIZE)
		return RT_ERR_OUT_OF_RANGE;

	if(value)
	{
		CleVirtualReg[reg] =  CleVirtualReg[reg] | (1 << bit);
	}
	else
	{
		CleVirtualReg[reg] =  CleVirtualReg[reg] & (~(1 << bit));
	}

	if(0x8367B == cleDebuggingDisplay)
		PRINT("W[0x%4.4x]=0x%4.4x\n", reg, CleVirtualReg[reg]);

#elif defined(EMBEDDED_SUPPORT)
    rtk_uint16 tmp;

    if(reg > RTL8367B_REGDATAMAX || value > 1)
	    return RT_ERR_INPUT;

	tmp = getReg(reg);
	tmp &= (1 << bitIdx);
	tmp |= (value << bitIdx);
	setReg(reg, tmp);

#else
	rtk_uint32 regData;
	ret_t retVal;

	if(bit >= RTL8367B_REGBITLENGTH)
		return RT_ERR_INPUT;

	retVal = smi_read(reg, &regData);
	if(retVal != RT_ERR_OK)
		return RT_ERR_SMI;

  #ifdef CONFIG_RTL865X_CLE
	if(0x8367B == cleDebuggingDisplay)
		PRINT("R[0x%4.4x]=0x%4.4x\n", reg, regData);
  #endif
	if(value)
		regData = regData | (1 << bit);
	else
		regData = regData & (~(1 << bit));

	retVal = smi_write(reg, regData);
	if(retVal != RT_ERR_OK)
		return RT_ERR_SMI;

  #ifdef CONFIG_RTL865X_CLE
	if(0x8367B == cleDebuggingDisplay)
		PRINT("W[0x%4.4x]=0x%4.4x\n", reg, regData);
  #endif

#endif
	return RT_ERR_OK;
}
예제 #4
0
/* Function Name:
 *      rtl8367b_getAsicRegBits
 * Description:
 *      Get bits value of a specified register
 * Input:
 *      reg 	- register's address
 *      bits 	- bits mask for setting
 *      value 	- bits value for setting
 * Output:
 *      None
 * Return:
 *      RT_ERR_OK 		- Success
 *      RT_ERR_SMI  	- SMI access error
 *      RT_ERR_INPUT  	- Invalid input parameter
 * Note:
 *      None
 */
ret_t rtl8367b_getAsicRegBits(rtk_uint32 reg, rtk_uint32 bits, rtk_uint32 *pValue)
{

#if defined(RTK_X86_ASICDRV)

	rtk_uint32 regData;
	ret_t retVal;
	rtk_uint32 bitsShift;

	if(bits >= (1 << RTL8367B_REGBITLENGTH) )
		return RT_ERR_INPUT;

	bitsShift = 0;
	while(!(bits & (1 << bitsShift)))
	{
		bitsShift++;
		if(bitsShift >= RTL8367B_REGBITLENGTH)
			return RT_ERR_INPUT;
	}

	retVal = Access_Read(reg, 2, &regData);
	if(TRUE != retVal)
		return RT_ERR_SMI;

	*pValue = (regData & bits) >> bitsShift;

	if(0x8367B == cleDebuggingDisplay)
		PRINT("R[0x%4.4x]=0x%4.4x\n", reg, regData);

#elif defined(CONFIG_RTL8367B_ASICDRV_TEST)
	rtk_uint32 bitsShift;

	if(bits >= (1 << RTL8367B_REGBITLENGTH) )
		return RT_ERR_INPUT;

	bitsShift = 0;
	while(!(bits & (1 << bitsShift)))
	{
		bitsShift++;
		if(bitsShift >= RTL8367B_REGBITLENGTH)
			return RT_ERR_INPUT;
	}

	if(reg >= CLE_VIRTUAL_REG_SIZE)
		return RT_ERR_OUT_OF_RANGE;

	 *pValue = (CleVirtualReg[reg] & bits) >> bitsShift;

	if(0x8367B == cleDebuggingDisplay)
		PRINT("R[0x%4.4x]=0x%4.4x\n", reg, CleVirtualReg[reg]);

#elif defined(EMBEDDED_SUPPORT)
    rtk_uint32 regData;
    rtk_uint32 bitsShift;

    if(reg > RTL8367B_REGDATAMAX )
	    return RT_ERR_INPUT;

    if(bits >= (1UL << RTL8367B_REGBITLENGTH) )
        return RT_ERR_INPUT;

    bitsShift = 0;
    while(!(bits & (1UL << bitsShift)))
    {
        bitsShift++;
        if(bitsShift >= RTL8367B_REGBITLENGTH)
            return RT_ERR_INPUT;
    }

    regData = getReg(reg);
    *value = (regData & bits) >> bitsShift;

#else
	rtk_uint32 regData;
	ret_t retVal;
	rtk_uint32 bitsShift;

	if(bits>= (1<<RTL8367B_REGBITLENGTH) )
		return RT_ERR_INPUT;

	bitsShift = 0;
	while(!(bits & (1 << bitsShift)))
	{
		bitsShift++;
		if(bitsShift >= RTL8367B_REGBITLENGTH)
			return RT_ERR_INPUT;
	}

	retVal = smi_read(reg, &regData);
	if(retVal != RT_ERR_OK) return RT_ERR_SMI;

	*pValue = (regData & bits) >> bitsShift;
  #ifdef CONFIG_RTL865X_CLE
	if(0x8367B == cleDebuggingDisplay)
		PRINT("R[0x%4.4x]=0x%4.4x\n",reg, regData);
  #endif

#endif
	return RT_ERR_OK;
}
예제 #5
0
/* Function Name:
 *      rtl8367b_getAsicRegBit
 * Description:
 *      Get a bit value of a specified register
 * Input:
 *      reg 	- register's address
 *      bit 	- bit location
 *      value 	- value to get.
 * Output:
 *      None
 * Return:
 *      RT_ERR_OK 		- Success
 *      RT_ERR_SMI  	- SMI access error
 *      RT_ERR_INPUT  	- Invalid input parameter
 * Note:
 *      None
 */
ret_t rtl8367b_getAsicRegBit(rtk_uint32 reg, rtk_uint32 bit, rtk_uint32 *pValue)
{

#if defined(RTK_X86_ASICDRV)

	rtk_uint32 regData;
	ret_t retVal;

	if(bit >= RTL8367B_REGBITLENGTH)
		return RT_ERR_INPUT;

	retVal = Access_Read(reg, 2, &regData);
	if(TRUE != retVal)
		return RT_ERR_SMI;

	*pValue = (regData & (0x1 << bit)) >> bit;

	if(0x8367B == cleDebuggingDisplay)
		PRINT("R[0x%4.4x]=0x%4.4x\n", reg, regData);

#elif defined(CONFIG_RTL8367B_ASICDRV_TEST)

	if(bit >= RTL8367B_REGBITLENGTH)
		return RT_ERR_INPUT;

	if(reg >= CLE_VIRTUAL_REG_SIZE)
		return RT_ERR_OUT_OF_RANGE;

	*pValue = (CleVirtualReg[reg] & (0x1 << bit)) >> bit;

	if(0x8367B == cleDebuggingDisplay)
		PRINT("R[0x%4.4x]=0x%4.4x\n", reg, CleVirtualReg[reg]);

#elif defined(EMBEDDED_SUPPORT)
    rtk_uint16 tmp;

    if(reg > RTL8367B_REGDATAMAX )
	    return RT_ERR_INPUT;

	tmp = getReg(reg);
	tmp = tmp >> bitIdx;
	tmp &= 1;
	*value = tmp;
#else
	rtk_uint32 regData;
	ret_t retVal;

	retVal = smi_read(reg, &regData);
	if(retVal != RT_ERR_OK)
		return RT_ERR_SMI;

  #ifdef CONFIG_RTL865X_CLE
	if(0x8367B == cleDebuggingDisplay)
		PRINT("R[0x%4.4x]=0x%4.4x\n", reg, regData);
  #endif

	*pValue = (regData & (0x1 << bit)) >> bit;

#endif
	return RT_ERR_OK;
}
예제 #6
0
/*
@func ret_t | rtl8370_setAsicRegBits | Set bits value of a specified register.
@parm uint32 | reg | Register's address.
@parm uint32 | bits | Bits mask for setting. 
@parm uint32 | value | Bits value for setting. Value of bits will be set with mapping mask bit is 1.   
@rvalue RT_ERR_OK | Success.
@rvalue RT_ERR_SMI | SMI access error.
@rvalue RT_ERR_INPUT | Invalid input parameter. 
@comm
    Set bits of a specified register to value. Both bits and value are be treated as bit-mask.
    
*/
ret_t rtl8370_setAsicRegBits(uint32 reg, uint32 bits, uint32 value)
{
    
#if defined(RTK_X86_ASICDRV)/*RTK-CNSD2-NickWu-20061222: for x86 compile*/

    uint32 regData;    
    ret_t retVal;    
    uint32 bitsShift;    
    uint32 valueShifted;        

    if(bits >= (1<<RTL8370_REGBITLENGTH) )
        return RT_ERR_INPUT;    

    bitsShift = 0;
    while(!(bits & (1 << bitsShift)))
    {
        bitsShift++;
        if(bitsShift >= RTL8370_REGBITLENGTH)
            return RT_ERR_INPUT;
    }

    valueShifted = value << bitsShift;
    if(valueShifted > RTL8370_REGDATAMAX)
        return RT_ERR_INPUT;

    retVal = Access_Read(reg, 2, &regData);
    if (retVal != TRUE) 
		return RT_ERR_SMI;

    if(0x8370 == cleDebuggingDisplay)
        PRINT("R[0x%4.4x]=0x%4.4x\n",reg,regData);

    regData = regData & (~bits);
    regData = regData | (valueShifted & bits);

    retVal = Access_Write(reg, 2, regData);
    if (retVal != TRUE) 
		return RT_ERR_SMI;

    if(0x8370 == cleDebuggingDisplay)
        PRINT("W[0x%4.4x]=0x%4.4x\n",reg,regData);
    
#elif defined(CONFIG_RTL8370_ASICDRV_TEST)
    uint32 regData;    
    uint32 bitsShift;    
    uint32 valueShifted;        

    if(bits>= (1<<RTL8370_REGBITLENGTH) )
        return RT_ERR_INPUT;    

    bitsShift = 0;
    while(!(bits & (1 << bitsShift)))
    {
        bitsShift++;
        if(bitsShift >= RTL8370_REGBITLENGTH)
            return RT_ERR_INPUT;
    }
    valueShifted = value << bitsShift;

    if(valueShifted > RTL8370_REGDATAMAX)
        return RT_ERR_INPUT;

    if(reg >= RTL8370_VIRTUAL_REG_SIZE)
        return RT_ERR_OUT_OF_RANGE;

    regData = Rtl8370sVirtualReg[reg] & (~bits);
    regData = regData | (valueShifted & bits);
    
    Rtl8370sVirtualReg[reg] = regData;

    if(0x8370 == cleDebuggingDisplay)
        PRINT("W[0x%4.4x]=0x%4.4x\n",reg,regData);
    
#else
    uint32 regData;    
    ret_t retVal;    
    uint32 bitsShift;    
    uint32 valueShifted;        

    if(bits>= (1<<RTL8370_REGBITLENGTH) )
        return RT_ERR_INPUT;

    bitsShift = 0;
    while(!(bits & (1 << bitsShift)))
    {
        bitsShift++;
        if(bitsShift >= RTL8370_REGBITLENGTH)
            return RT_ERR_INPUT;
    }
    valueShifted = value << bitsShift;

    if(valueShifted > RTL8370_REGDATAMAX)
        return RT_ERR_INPUT;

    retVal = smi_read(reg, &regData);
    if (retVal != RT_ERR_OK) 
		return RT_ERR_SMI;
  #ifdef CONFIG_RTL865X_CLE
    if(0x8370 == cleDebuggingDisplay)
        PRINT("R[0x%4.4x]=0x%4.4x\n",reg,regData);
  #endif

    regData = regData & (~bits);
    regData = regData | (valueShifted & bits);

    retVal = smi_write(reg, regData);
    if (retVal != RT_ERR_OK) 
		return RT_ERR_SMI;
  #ifdef CONFIG_RTL865X_CLE
    if(0x8370 == cleDebuggingDisplay)
        PRINT("W[0x%4.4x]=0x%4.4x\n",reg,regData);
  #endif
#endif
    return RT_ERR_OK;
}
예제 #7
0
/*
@func ret_t | rtl8370_setAsicRegBit | Set a bit value of a specified register.
@parm uint32 | reg | Register's address.
@parm uint32 | bit | Bit location. For 16-bits register only. Maximun value is 15 for MSB location.
@parm uint32 | value | Value to set. It can be value 0 or 1.
@rvalue RT_ERR_OK | Success.
@rvalue RT_ERR_SMI | SMI access error.
@rvalue RT_ERR_INPUT | Invalid input parameter. 
@comm
    Set a bit of a specified register to 1 or 0. It is 16-bits system of RTL8366s chip.
    
*/
ret_t rtl8370_setAsicRegBit(uint32 reg, uint32 bit, uint32 value)
{

#if defined(RTK_X86_ASICDRV)
    uint32 regData;
    ret_t retVal;
    
    if(bit >= RTL8370_REGBITLENGTH)
        return RT_ERR_INPUT;

    retVal = Access_Read(reg, 2, &regData);
    if (retVal != TRUE) 
		return RT_ERR_SMI;

    if(0x8370 == cleDebuggingDisplay)
        PRINT("R[0x%4.4x]=0x%4.4x\n",reg,regData);

    if (value) 
        regData = regData | (1<<bit);
    else
        regData = regData & ~(1<<bit);

    retVal = Access_Write(reg, 2, regData);
    if (retVal != TRUE) 
		return RT_ERR_SMI;

    if(0x8370 == cleDebuggingDisplay)
        PRINT("W[0x%4.4x]=0x%4.4x\n",reg,regData);

    
#elif defined(CONFIG_RTL8370_ASICDRV_TEST)

    if(bit>=RTL8370_REGBITLENGTH)
        return RT_ERR_INPUT;
    else if(reg >= RTL8370_VIRTUAL_REG_SIZE)
        return RT_ERR_OUT_OF_RANGE;

    if (value) 
    {
        Rtl8370sVirtualReg[reg] =  Rtl8370sVirtualReg[reg] | (1<<bit);

    }
    else
    {
        Rtl8370sVirtualReg[reg] =  Rtl8370sVirtualReg[reg] & (~(1<<bit));
    }
    
    if(0x8370 == cleDebuggingDisplay)
        PRINT("W[0x%4.4x]=0x%4.4x\n",reg,Rtl8370sVirtualReg[reg]);

    
#else
    uint32 regData;
    ret_t retVal;
    
    if(bit>=RTL8370_REGBITLENGTH)
        return RT_ERR_INPUT;

    retVal = smi_read(reg, &regData);
    if(retVal != RT_ERR_OK) 
		return RT_ERR_SMI;
  #ifdef CONFIG_RTL865X_CLE
    if(0x8370 == cleDebuggingDisplay)
        PRINT("R[0x%4.4x]=0x%4.4x\n",reg,regData);
  #endif
    if (value) 
        regData = regData | (1<<bit);
    else
        regData = regData & (~(1<<bit));
    
    retVal = smi_write(reg, regData);
    if (retVal != RT_ERR_OK) 
		return RT_ERR_SMI;
  
  #ifdef CONFIG_RTL865X_CLE
    if(0x8370 == cleDebuggingDisplay)
        PRINT("W[0x%4.4x]=0x%4.4x\n",reg,regData);
  #endif

#endif
    return RT_ERR_OK;
}