📄 sysfei82557end.c
字号:
sysDelay (); /* delay for one IO READ cycle */
} while ((pReso->pResults[1] == -1) && (--pReso->timeout >= 0));
pReso->boardType = TYPE_PRO100B_PCI;
}
/* initializes the board information structure */
pBoard->vector = pReso->irq/*IVEC_TO_INUM(pReso->irq)*/;
pBoard->baseAddr = pReso->membaseCsr;
/*
for (ix = 0, iy = 0; ix < 3; ix++)
{
pBoard->enetAddr[iy++] = pReso->eeprom[ix] & 0xff;
pBoard->enetAddr[iy++] = (pReso->eeprom[ix] >> 8) & 0xff;
}
*/
if(unit == 0)
{
pReso->eeprom[0] = 0x0400;
pReso->eeprom[1] = 0x3658;
pReso->eeprom[2] = 0x4612;
pBoard->enetAddr[0] = 00;
pBoard->enetAddr[1] = 04;
pBoard->enetAddr[2] = 58;
pBoard->enetAddr[3] = 36;
pBoard->enetAddr[4] = 12;
pBoard->enetAddr[5] = 46;
}
else
{
pReso->eeprom[0] = 0x0400;
pReso->eeprom[1] = 0x3658;
pReso->eeprom[2] = 0x4712;
pBoard->enetAddr[0] = 00;
pBoard->enetAddr[1] = 04;
pBoard->enetAddr[2] = 58;
pBoard->enetAddr[3] = 36;
pBoard->enetAddr[4] = 12;
pBoard->enetAddr[5] = 47;
}
pBoard->intEnable = sys557IntEnable;
pBoard->intDisable = sys557IntDisable;
pBoard->intAck = sys557IntAck;
pBoard->sysLocalToBus = sys557LocalToPciBusAdrs;
pBoard->sysBusToLocal = sys557PciBusToLocalAdrs;
#ifdef FEI_10MB
pBoard->phySpeed = NULL;
pBoard->phyDpx = NULL;
#endif
intEnable (pReso->irq);
return (OK);
}
/*******************************************************************************
*
* sys557IntEnable - enable 82557 PCI ethernet device interrupts
*
* This routine enables 82557 interrupts. This may involve operations on
* interrupt control hardware.
*
* The 82557 driver calls this routine throughout normal operation to terminate
* critical sections of code.
*
* This routine assumes that the PCI configuration information has already
* been setup.
*
* RETURNS: OK, or ERROR if interrupts could not be enabled.
*/
LOCAL STATUS sys557IntEnable
(
int unit /* END driver unit number */
)
{
return ((unit >= feiUnits) ? ERROR :
(sysIntEnablePIC (feiResources[unit].irq)));
}
/*******************************************************************************
*
* sys557IntDisable - disable 82557 PCI ethernet device interrupts
*
* This routine disables 82557 interrupts. This may involve operations on
* interrupt control hardware.
*
* The 82557 driver calls this routine throughout normal operation to enter
* critical sections of code.
*
* This routine assumes that the PCI configuration information has already
* been setup.
*
* RETURNS: OK, or ERROR if interrupts could not be disabled.
*/
LOCAL STATUS sys557IntDisable
(
int unit /* END driver unit number */
)
{
return ((unit >= feiUnits) ? ERROR :
(sysIntDisable (feiResources[unit].irq)));
}
/*******************************************************************************
*
* sys557IntAck - acknowledge an 82557 interrupt
*
* This routine performs any 82557 interrupt acknowledge that may be
* required. This typically involves an operation to some interrupt
* control hardware.
*
* This routine gets called from the 82557 driver's interrupt handler.
*
* This routine assumes that the PCI configuration information has already
* been setup.
*
* RETURNS: OK, or ERROR if the interrupt could not be acknowledged.
*/
LOCAL STATUS sys557IntAck
(
int unit /* unit number */
)
{
FEI_RESOURCE *pReso = &feiResources [unit];
switch (pReso->boardType)
{
case TYPE_PRO100B_PCI: /* handle PRO100B LAN Adapter */
/* no addition work necessary for the PRO100B */
break;
default:
return (ERROR);
}
return (OK);
}
/*******************************************************************************
*
* sys557eepromRead - read a word from the 82557 EEPROM
*
* RETURNS: the EEPROM data word read in.
*/
LOCAL UINT16 sys557eepromRead
(
int unit, /* unit number */
int location /* address of word to be read */
)
{
UINT32 membase = PCI_MEMIO2LOCAL (feiResources[unit].membaseCsr);
UINT32 retval = 0;
UINT32 dataval;
volatile UINT32 dummy;
int ix;
sysOutWord (membase + SCB_EEPROM, EE_CS); /* enable EEPROM */
/* write the READ opcode */
for (ix = EE_CMD_BITS - 1; ix >= 0; ix--)
{
dataval = (EE_CMD_READ & (1 << ix)) ? EE_DI : 0;
sysOutWord (membase + SCB_EEPROM, EE_CS | dataval);
sysDelay (); /* delay for one IO READ cycle */
sysOutWord (membase + SCB_EEPROM, EE_CS | dataval | EE_SK);
sysDelay (); /* delay for one IO READ cycle */
}
/* write the location */
for (ix = EE_ADDR_BITS - 1; ix >= 0; ix--)
{
dataval = (location & (1 << ix)) ? EE_DI : 0;
sysOutWord (membase + SCB_EEPROM, EE_CS | dataval);
sysDelay (); /* delay for one IO READ cycle */
sysOutWord (membase + SCB_EEPROM, EE_CS | dataval | EE_SK);
sysDelay (); /* delay for one IO READ cycle */
sysOutWord (membase + SCB_EEPROM, EE_CS | dataval);
sysDelay (); /* delay for one IO READ cycle */
dummy = sysInWord (membase + SCB_EEPROM);
}
if ((dummy & EE_DO) == 0) /* dummy read */
;
/* read the data */
for (ix = EE_DATA_BITS - 1; ix >= 0; ix--)
{
sysOutWord (membase + SCB_EEPROM, EE_CS | EE_SK);
sysDelay (); /* delay for one IO READ cycle */
retval = (retval << 1) |
((sysInWord (membase + SCB_EEPROM) & EE_DO) ? 1 : 0);
sysOutWord (membase + SCB_EEPROM, EE_CS);
sysDelay (); /* delay for one IO READ cycle */
}
sysOutWord (membase + SCB_EEPROM, 0x00); /* disable EEPROM */
return (retval);
}
/*******************************************************************************
*
* sys557mdioRead - read MDIO
*
* RETURNS: read value
*/
LOCAL UINT16 sys557mdioRead
(
int unit, /* unit number */
int phyId, /* PHY ID */
int location /* location to read */
)
{
UINT32 membase = PCI_MEMIO2LOCAL((feiResources[unit].membaseCsr));
int timeout = 64*4; /* <64 usec. to complete, typ 27 ticks */
int val;
sysOutLong (membase + SCB_MDI, 0x08000000 | (location<<16) | (phyId<<21));
do {
sysDelay (); /* delay for one IO READ cycle */
val = sysInLong (membase + SCB_MDI);
if (--timeout < 0)
printf ("sys557mdioRead() timed out with val = %8.8x.\n", val);
} while (! (val & 0x10000000));
return (val & 0xffff);
}
/*******************************************************************************
*
* sys557mdioWrite - write MDIO
*
* RETURNS: write value
*/
LOCAL UINT16 sys557mdioWrite
(
int unit, /* unit number */
int phyId, /* PHY ID */
int location, /* location to write */
int value /* value to write */
)
{
UINT32 membase = PCI_MEMIO2LOCAL((feiResources[unit].membaseCsr));
int timeout = 64*4; /* <64 usec. to complete, typ 27 ticks */
int val;
sysOutLong (membase + SCB_MDI,
0x04000000 | (location<<16) | (phyId<<21) | value);
do {
sysDelay (); /* delay for one IO READ cycle */
val = sysInLong (membase + SCB_MDI);
if (--timeout < 0)
printf ("sys557mdioWrite() timed out with val = %8.8x.\n", val);
} while (! (val & 0x10000000));
return (val & 0xffff);
}
/*******************************************************************************
*
* sys557Show - shows 82557 configuration
*
* this routine shows (Intel Pro Express 100) configuration
*
* RETURNS: N/A
*/
void sys557Show
(
int unit /* unit number */
)
{
FEI_RESOURCE *pReso = &feiResources [unit];
UINT32 membase = PCI_MEMIO2LOCAL (pReso->membaseCsr);
UCHAR etheraddr[6];
int ix;
int iy;
if (unit >= feiUnits)
{
printf ("none\n");
return;
}
for (ix = 0, iy = 0; ix < 3; ix++)
{
etheraddr[iy++] = pReso->eeprom[ix];
etheraddr[iy++] = pReso->eeprom[ix] >> 8;
}
printf ("82557(%d): Intel EtherExpress Pro 10/100 at %#3x ", unit, membase);
for (ix = 0; ix < 5; ix++)
printf ("%2.2X:", etheraddr[ix]);
printf ("%2.2X\n", etheraddr[ix]);
printf ("CSR mem base address = 0x%x, Flash mem base address = 0x%x\n",
pReso->membaseCsr, pReso->membaseFlash);
printf ("PCI bus no. = 0x%x, device no. = 0x%x"
", function no. = 0x%x, IRQ = %d\n",
pReso->pciBus, pReso->pciDevice, pReso->pciFunc, pReso->irq);
if (pReso->eeprom[3] & 0x03)
printf ("Receiver lock-up bug exists -- enabling work-around.\n");
printf ("Board assembly %4.4x%2.2x-%3.3d, Physical connectors present:",
pReso->eeprom[8], pReso->eeprom[9]>>8, pReso->eeprom[9] & 0xff);
for (ix = 0; ix < 4; ix++)
if (pReso->eeprom[5] & (1 << ix))
printf (connectors [ix]);
printf ("\nPrimary interface chip %s PHY #%d.\n",
phys[(pReso->eeprom[6]>>8)&7], pReso->eeprom[6] & 0x1f);
if (pReso->eeprom[7] & 0x0700)
printf ("Secondary interface chip %s.\n",
phys[(pReso->eeprom[7]>>8)&7]);
#if FALSE /* we don't show PHY specific info at this time */
/* ToDo: Read and set PHY registers through MDIO port. */
for (ix = 0; ix < 2; ix++)
printf ("MDIO register %d is %4.4x.\n",
ix, sys557mdioRead (unit, pReso->eeprom[6] & 0x1f, ix));
for (ix = 5; ix < 7; ix++)
printf ("MDIO register %d is %4.4x.\n",
ix, sys557mdioRead (unit, pReso->eeprom[6] & 0x1f, ix));
printf ("MDIO register %d is %4.4x.\n",
25, sys557mdioRead (unit, pReso->eeprom[6] & 0x1f, 25));
#endif /* FALSE */
if (pReso->timeout < 0)
{ /* Test optimized out. */
printf ("Self test failed, status %8.8x:\n"
" Failure to initialize the 82557.\n"
" Verify that the card is a bus-master capable slot.\n",
pReso->pResults[1]);
}
else
{
printf ("General self-test: %s.\n"
" Serial sub-system self-test: %s.\n"
" Internal registers self-test: %s.\n"
" ROM checksum self-test: %s (%#8.8x).\n",
pReso->pResults[1] & 0x1000 ? "failed" : "passed",
pReso->pResults[1] & 0x0020 ? "failed" : "passed",
pReso->pResults[1] & 0x0008 ? "failed" : "passed",
pReso->pResults[1] & 0x0004 ? "failed" : "passed",
pReso->pResults[0]);
}
}
/******************************************************************************
*
* sys557LocalToPciBusAdrs - convert a local address to a bus address
*
* This routine returns a PCIbus address for the LOCAL bus address.
*
*/
LOCAL UINT32 sys557LocalToPciBusAdrs
(
int unit,
UINT32 adrs /* Local Address */
)
{
return (LOCAL2PCI_MEMIO (adrs)); /* yk.h */
}
/******************************************************************************
*
* sys557PciBusToLocalAdrs - convert a bus address to a local address
*
* This routine returns a local address that is used to access the PCIbus.
* The bus address that is passed into this routine is the PCIbus address
* as it would be seen on the local bus.
*
*/
LOCAL UINT32 sys557PciBusToLocalAdrs
(
int unit,
UINT32 adrs /* PCI Address */
)
{
return (PCI_MEMIO2LOCAL(adrs)); /* yk.h */
}
#endif /* defined (INCLUDE_FEI_END) && defined (INCLUDE_NETWORK) */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -