📄 dec21143.c
字号:
if (((link_code_word & CSR12_CODE_100MB_FD) == CSR12_CODE_100MB_FD) &&
((csr14_val & CSR14_100BASE_TX_FD) == CSR14_100BASE_TX_FD))
{
use_full_duplex = NU_TRUE;
use_100MB = NU_TRUE;
}
/* 100BASE-TX Half Duplex */
else if (((link_code_word & CSR12_CODE_100MB_HD) == CSR12_CODE_100MB_HD) &&
((csr14_val & CSR14_100BASE_T4) == 0x0) &&
((csr14_val & CSR14_100BASE_TX_FD) == 0x0) &&
((csr14_val & CSR14_100BASE_TX_HD) == CSR14_100BASE_TX_HD))
{
use_full_duplex = NU_FALSE;
use_100MB = NU_TRUE;
}
/* 100BASE-TX Half Duplex */
else if (((link_code_word & CSR12_CODE_100MB_HD) == CSR12_CODE_100MB_HD) &&
((csr14_val & CSR14_100BASE_TX_HD) == CSR14_100BASE_TX_HD))
{
use_full_duplex = NU_FALSE;
use_100MB = NU_TRUE;
}
/* 10BASE-T Full Duplex */
else if (((link_code_word & CSR12_CODE_10MB_FD) == CSR12_CODE_10MB_FD) &&
((csr14_val & CSR14_100BASE_T4) == 0x0) &&
((csr14_val & CSR14_100BASE_TX_FD) == 0x0) &&
((csr14_val & CSR14_100BASE_TX_HD) == 0x0) &&
((*csr6_val & CSR6_FULL_DUPLEX_MODE) == CSR6_FULL_DUPLEX_MODE))
{
use_full_duplex = NU_TRUE;
use_100MB = NU_FALSE;
}
/* 10BASE-T Full Duplex */
else if (((link_code_word >> 1) == (CSR12_CODE_10MB_FD >> 1)) &&
((*csr6_val & CSR6_FULL_DUPLEX_MODE) == CSR6_FULL_DUPLEX_MODE))
{
use_full_duplex = NU_TRUE;
use_100MB = NU_FALSE;
}
/* 10BASE-T Half Duplex */
else if (((link_code_word & CSR12_CODE_10MB_HD) == CSR12_CODE_10MB_HD) &&
((csr14_val & CSR14_100BASE_T4) == 0x0) &&
((csr14_val & CSR14_100BASE_TX_FD) == 0x0) &&
((csr14_val & CSR14_100BASE_TX_HD) == 0x0) &&
((csr14_val & CSR14_10BASET_HD_ENABLE) == CSR14_10BASET_HD_ENABLE) &&
((*csr6_val & CSR6_FULL_DUPLEX_MODE) == 0x0))
{
use_full_duplex = NU_FALSE;
use_100MB = NU_FALSE;
}
/* 10BASE-T Half Duplex */
else if ((link_code_word == CSR12_CODE_10MB_HD) &&
((csr14_val & CSR14_10BASET_HD_ENABLE) == CSR14_10BASET_HD_ENABLE))
{
use_full_duplex = NU_FALSE;
use_100MB = NU_FALSE;
}
else
/* We have nothing to go on for initializing the link.
Return with an error. */
return (-1);
/* Now that we know what the link partner can do, initialize the
chip. */
/* Do we do 100MB? */
if (use_100MB)
{
/* Reset the SIA */
OUTDW (device->dev_io_addr + CSR13, CLEAR_ALL);
OUTDW (device->dev_io_addr + CSR14, CLEAR_ALL);
/* Preserve CSR6s value and add in the functions we
need to 100MB mode. */
*csr6_val |= (CSR6_PORT_SELECT |
CSR6_PCS_FUNCTION | CSR6_SCRAMBLER_MODE |
CSR6_HEARTBEAT_DISABLE | CSR6_CAPTURE_EFFECT_ENABLE);
/* Do we need to add in full duplex. */
if (use_full_duplex)
*csr6_val |= CSR6_FULL_DUPLEX_MODE;
/* Write out CSR6. */
OUTDW (device->dev_io_addr + CSR6, *csr6_val);
/* Set the speed for this device in SNMP. */
SNMP_ifSpeed(device->dev_index, 100000000); /* 100 Mbps */
}
else
{
/* Otherwise we do 10MB */
/* Do we need full duplex? */
if (use_full_duplex)
{
*csr6_val |= CSR6_FULL_DUPLEX_MODE;
/* Write out CSR6. */
OUTDW (device->dev_io_addr + CSR6, *csr6_val);
}
/* Reset the SIA */
OUTDW (device->dev_io_addr + CSR13, CLEAR_ALL);
OUTDW (device->dev_io_addr + CSR14, 0x7f3f);
OUTDW (device->dev_io_addr + CSR15, 0x0008);
/* Set the SIA to 10BASE-T mode and wake it up. */
OUTDW (device->dev_io_addr + CSR13, CSR13_SIA_RESET);
/* Set the speed for this device in SNMP. */
SNMP_ifSpeed(device->dev_index, 10000000); /* 10 Mbps */
}
} /* end if negotiation completed with a valid link code */
else
{
/* Since negotiation timedout, we do not have a link code
word to tell us what to initialize the link as, so we will
use the link status bits in CSR12. NOTE: the logic for
these bits is reversed. If it is set then that link
is in the fail state. */
/* Check for 100Mbs link status first. */
if (!(csr12_val & CSR12_100MB_LINK_STATUS))
{
/* Since the 100MB link is in the pass state we will
initialize the chip for 100MB half duplex. */
/* Half duplex mode using the SYM port. */
/* Reset the SIA */
OUTDW (device->dev_io_addr + CSR13, CLEAR_ALL);
OUTDW (device->dev_io_addr + CSR14, CLEAR_ALL);
/* Preserve CSR6s value and add in the functions we
need to 100MB mode. */
*csr6_val |= (CSR6_PORT_SELECT |
CSR6_PCS_FUNCTION | CSR6_SCRAMBLER_MODE |
CSR6_HEARTBEAT_DISABLE | CSR6_CAPTURE_EFFECT_ENABLE);
/* Write out CSR6. */
OUTDW (device->dev_io_addr + CSR6, *csr6_val);
/* Set the speed for this device in SNMP. */
SNMP_ifSpeed(device->dev_index, 100000000); /* 100 Mbps */
}
else
if (!(csr12_val & CSR12_10MB_LINK_STATUS))
{
/* Since the 10MB link is in the pass state we will
initialize the chip for 10MB half duplex. */
/* Half duplex mode using the 10BASE-T port. */
/* Reset the SIA */
OUTDW (device->dev_io_addr + CSR13, CLEAR_ALL);
OUTDW (device->dev_io_addr + CSR14, 0x7f3f);
OUTDW (device->dev_io_addr + CSR15, 0x0008);
/* Set the SIA to 10BASE-T mode and wake it up. */
OUTDW (device->dev_io_addr + CSR13, CSR13_SIA_RESET);
/* Set the speed for this device in SNMP. */
SNMP_ifSpeed(device->dev_index, 10000000); /* 10 Mbps */
}
else
{
/* We have nothing to go on for initializing the link.
So just set it to the lowest common denominator,
ie. 10Mbps at half duplex. */
/* Half duplex mode using the 10BASE-T port. */
/* Reset the SIA */
OUTDW (device->dev_io_addr + CSR13, CLEAR_ALL);
OUTDW (device->dev_io_addr + CSR14, 0x7f3f);
OUTDW (device->dev_io_addr + CSR15, 0x0008);
/* Set the SIA to 10BASE-T mode and wake it up. */
OUTDW (device->dev_io_addr + CSR13, CSR13_SIA_RESET);
/* Set the speed for this device in SNMP. */
SNMP_ifSpeed(device->dev_index, 10000000); /* 10 Mbps */
}
} /* end if the negotiation timedout. */
return (NU_SUCCESS);
} /* end DEC21143_Init_Link */
/****************************************************************************/
/* FUNCTION */
/* */
/* DEC21143_Negotiate_Link_HISR */
/* */
/* DESCRIPTION */
/* */
/* This function simply get the device that activated the HISR and */
/* renegotiates the link. This only used when the link changes after */
/* initialization has completed. */
/* */
/* AUTHOR */
/* */
/* Uriah T. Pollock, Accelerated Technology Inc. */
/* */
/* CALLED BY */
/* */
/* Activated by DEC21143_LISR */
/* */
/* CALLS */
/* */
/* DEC21143_Negotiate_Link */
/* */
/* INPUTS */
/* */
/* NONE */
/* */
/* OUTPUTS */
/* */
/* NONE */
/* */
/* HISTORY */
/* */
/* NAME DATE REMARKS */
/* */
/* Uriah T. Pollock 01/12/99 Created initial version 1.0 */
/* */
/****************************************************************************/
VOID DEC21143_Negotiate_Link_HISR (VOID)
{
DV_DEVICE_ENTRY *device;
DEC21143_XDATA *dec_data;
/* Get a pointer to the device. */
device = DEC21143_Negotiate_Device_Buffer[DEC21143_Negotiate_Read];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -