/*
*********************************************************************************************************
* uC/TCP-IP
* The Embedded TCP/IP Suite
*
* (c) Copyright 2003-2006; Micrium, Inc.; Weston, FL
*
* All rights reserved. Protected by international copyright laws.
*
* uC/TCP-IP is provided in source form for FREE evaluation, for educational
* use or peaceful research. If you plan on using uC/TCP-IP in a commercial
* product you need to contact Micrium to properly license its use in your
* product. We provide ALL the source code for your convenience and to help
* you experience uC/TCP-IP. The fact that the source code is provided does
* NOT mean that you can use it without paying a licensing fee.
*
* Network Interface Card (NIC) port files provided, as is, for FREE and do
* NOT require any additional licensing or licensing fee.
*
* Knowledge of the source code may NOT be used to develop a similar product.
*
* Please help us continue to provide the Embedded community with the finest
* software available. Your honesty is greatly appreciated.
*********************************************************************************************************
*/
/*
*********************************************************************************************************
*
* NETWORK PHYSICAL LAYER
*
* BCM5221
*
* Filename : net_phy.c
* Version : V1.87
* Programmer(s) : CL
*********************************************************************************************************
* Note(s) : (1) Supports Broadcom BCM5221 Fast Ethernet Transceiver' as described in
*
* Broadcom Corporation (Broadcom; http://www.broadcom.com)
* (a) BCM5221 (10/100BASE-TX Single-Channel Signi-PHY� Transceiver
* 5221-DS08-R 02-17-2005;
* http://www.broadcom.com/products/Enterprise-Small-Office/
* Fast-Ethernet-Transceivers/BCM5221)
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* INCLUDE FILES
*********************************************************************************************************
*/
#include <net.h>
#include <net_nic.h>
#include <net_phy.h>
/*
*********************************************************************************************************
* NetNIC_PhyInit()
*
* Description : Initialize phyter (ethernet link controller)
* This instance configure the Broadcom 5221 10/100BASE-TX Single-Channel Signi-PHY� Transceiver
*
* Argument(s) : none.
*
* Return(s) : none.
*
* Caller(s) : ???_Init.
*
* Note(s) : none.
*********************************************************************************************************
*/
void NetNIC_PhyInit (void)
{
/* BCM5221 register 0x00: Control Register */
/* BIT 15: Reset */
/* BIT 09: Restart Auto-negotiation */
NetNIC_PhyRegWr(0, 0x00, DEF_BIT_15 | DEF_BIT_09);
BCM5221_DlyReset();
/* BCM5221 register 0x1A: Interrupt Register */
/* Clear pending interrupts */
NetNIC_PhyRegRd(0, 0x1A);
/* BCM5221 register 0x1A: Interrupt Register */
/* BIT 11: Mask Duxplex change interrupt */
/* BIT 10: MASK Speed change interrupt */
/* BIT 9 : Not defined. Generate Link change interrupt */
/* BIT 14: Enable Interrupts */
NetNIC_PhyRegWr(0, 0x1A, DEF_BIT_01 | DEF_BIT_10 | DEF_BIT_11);
/* BCM5221 register 0x1B: Auxilary Mode 2 Register */
/* BIT 6 : Traffic Meter Mode for ACTLED */
NetNIC_PhyRegWr(0, 0x1B, DEF_BIT_06);
NetNIC_PhyIntInit(); /* Initialize external interrupt controller */
NetNIC_PhyAutoNeg(); /* Do link auto-negotiation */
NetNIC_ConnStatus = NetNIC_PhyLinkState(); /* Set NetNIC_ConnStatus according to link state */
if (NetNIC_ConnStatus == DEF_ON) {
NetNIC_LinkUp();
} else {
NetNIC_LinkDown();
}
}
/*
*********************************************************************************************************
* NetNIC_PhyAutoNeg()
*
* Description : Do link auto-negotiation
*
* Argument(s) : none.
*
* Return(s) : none.
*
* Caller(s) : NetNIC_PhyInit.
*
* Note(s) : none.
*********************************************************************************************************
*/
void NetNIC_PhyAutoNeg (void)
{
CPU_INT16U i;
CPU_BOOLEAN link;
i = BCM5221_INIT_AUTO_NEG_RETRIES;
link = NetNIC_PhyAutoNegState();
while ((link != DEF_ON) && (i > 0)) {
BCM5221_DlyAutoNegAck();
link = NetNIC_PhyAutoNegState();
i--;
}
}
/*
*********************************************************************************************************
* NetNIC_PhyAutoNegState()
*
* Description : Returns state of auto-negotiation
* This instance probe the Intel BCM5221 '3.3V Dual-Speed Fast Ethernet Transceiver'
*
* Argument(s) : none.
*
* Return(s) : State of auto-negociation (DEF_OFF = not completed, DEF_ON = completed).
*
* Caller(s) : NetNIC_PhyInit.
*
* Note(s) : none.
*********************************************************************************************************
*/
CPU_BOOLEAN NetNIC_PhyAutoNegState (void)
{
CPU_INT32U reg_val;
/* BCM5221 register 0x01: Status Register */
/* BIT 05: Auto-negotiation complete */
reg_val = NetNIC_PhyRegRd(0, 0x01);
if ((reg_val & DEF_BIT_05) == DEF_BIT_05) {
return (DEF_ON);
} else {
return (DEF_OFF);
}
}
/*
*********************************************************************************************************
* NetNIC_PhyLinkState()
*
* Description : Returns state of ethernet link
* This instance probe the Intel BCM5221 '3.3V Dual-Speed Fast Ethernet Transceiver'
*
* Argument(s) : none.
*
* Return(s) : State of ether