📄 sysfei82557end.c
字号:
* This routine prints out the EEPROM contents for the specified unit** ERRNO: N/A** RETURNS: void* */void sys557eepromDump ( int unit ) { int ix; UINT16 word; for(ix=0; ix<EEPROM_WORD_SIZE; ix++) { if((ix&7) == 0) printf("\n0x%02x: ", ix); word = sys557eepromRead (unit, ix); printf(" %04x", word); } printf("\n"); }/********************************************************************************* sys557mdioRead - read MDIO** This routine reads values from the PHY through the Management Data Interface** ERRNO: N/A** RETURNS: read value*/LOCAL UINT16 sys557mdioRead ( int unit, /* unit number */ int phyId, /* PHY ID */ int location /* location to read */ ) { UINT32 membase = feiResources[unit].membaseCsr; int timeout = 64*4; /* <64 usec. to complete, typ 27 ticks */ int val; sysPciOutLong (membase + SCB_MDI, 0x08000000 | (location<<16) | (phyId<<21)); do { /* poll until completion */ sysMicroDelay (1000); /* delay for one IO READ cycle */ val = sysInLong (membase + SCB_MDI); if (--timeout < 0) { printf ("sys557mdioRead() timed out with val = %8.8x.\n", val); break; } } while (! (val & 0x10000000)); return (val & 0xffff); }/********************************************************************************* sys557mdioWrite - write MDIO** This routine writes values to the PHY through the Management Data Interface** ERRNO: N/A** 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 = feiResources[unit].membaseCsr; int timeout = 64*4; /* <64 usec. to complete, typ 27 ticks */ int val; sysPciOutLong (membase + SCB_MDI, 0x04000000 | (location<<16) | (phyId<<21) | value); do { /* poll until completion */ sysMicroDelay (1000); /* delay for one IO READ cycle */ val = sysInLong (membase + SCB_MDI); if (--timeout < 0) { printf ("sys557mdioWrite() timed out with val = %8.8x.\n", val); break; } } while (! (val & 0x10000000)); return (val & 0xffff); }/********************************************************************************* sys557Show - shows 82557 configuration** This routine shows (Intel Pro Express 100) configuration** ERRNO: N/A** RETURNS: N/A*/void sys557Show ( int unit /* unit number */ ) { FEI_RESOURCE *pReso = &feiResources [unit]; UINT32 membase = 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 ("%s", 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 (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]); } }/********************************************************************************* sys557IntEnable - enable 82557 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.** ERRNO: N/A** RETURNS: OK, or ERROR if interrupts could not be enabled.*/LOCAL STATUS sys557IntEnable ( int unit /* unit number */ ) { FEI_RESOURCE *pReso = &feiResources [unit]; switch (pReso->boardType) { case TYPE_PRO100B_PCI: /* handle PRO100B LAN Adapter */ case TYPE_INBUSINESS_PCI: case TYPE_XX82559ER_PCI: intEnable (pReso->irq); break; default: return (ERROR); } return (OK); }/******************************************************************************** sys557IntDisable - disable 82557 interrupts** This routine disables 82557 interrupts. This may involve operations on* interrupt control hardware.** The 82557 driver calls this routine before critical sections of code.** This routine assumes that the PCI configuration information has already* been setup.** ERRNO: N/A** RETURNS: OK, or ERROR if unsupported board*/LOCAL STATUS sys557IntDisable ( int unit /* unit number */ ) { FEI_RESOURCE *pReso = &feiResources [unit]; switch (pReso->boardType) { case TYPE_PRO100B_PCI: /* handle PRO100B LAN Adapter */ case TYPE_INBUSINESS_PCI: case TYPE_XX82559ER_PCI: intDisable (pReso->irq); break; default: return (ERROR); } return (OK); }/******************************************************************************** sys557IntConnect - connect 82557 interrupts** This routine connects an interrupt handler to the specified vector** ERRNO: N/A** RETURNS: OK, or ERROR if unsupported board*/LOCAL STATUS sys557IntConnect ( void *vector, VOIDFUNCPTR *intHandler, int drvCtrl ) { int irq; int pin = 0; STATUS retval; retval = pciIntConnect ((VOIDFUNCPTR *)vector, (VOIDFUNCPTR)intHandler, drvCtrl); irq = sysPciIntVectorToIrq(vector); switch (irq) { case IXP425_PCI_INTA_INDEX: pin = IXP425_PCI_INTA_PIN; break; case IXP425_PCI_INTB_INDEX: pin = IXP425_PCI_INTB_PIN; break; case IXP425_PCI_INTC_INDEX: pin = IXP425_PCI_INTC_PIN; break; case IXP425_PCI_INTD_INDEX: pin = IXP425_PCI_INTD_PIN; break; } /* We need to clear the GPIO status after every interrupt. * ixp425PciInt() does this "post-processing" *//*Note: This is slightly slower than combining the two routines into one */ if (retval != ERROR) retval = pciIntConnect ((VOIDFUNCPTR *)vector, (VOIDFUNCPTR)ixp425PciInt, pin); return retval; }LOCAL STATUS sys557IntDisconnect ( void *vector, VOIDFUNCPTR *intHandler ) { STATUS retVal; retVal = pciIntDisconnect((VOIDFUNCPTR *)vector, (VOIDFUNCPTR)intHandler); return retVal; }/******************************************************************************** sys557EndPciToPhys - translate a Pci address to a physical address** This function converts a Pci memory address to a physical address.** ERRNO: N/A** RETURNS: the physical address*/UINT32 sys557EndPciToPhys ( int unit, UINT32 PciAddr /* PCI address */ ) { return((UINT32)sysPciToPhys((void *)PciAddr)); }/******************************************************************************** sys557EndPhysToPci - translate a physical address to a Pci address** This function converts a physical address to a Pci memory space address.** ERRNO: N/A** RETURNS: the Pci address*/UINT32 sys557EndPhysToPci ( int unit, UINT32 PhysAddr /* Physical address */ ) { return ((UINT32)sysPhysToPci((void *)PhysAddr)); }#endif /* defined (INCLUDE_END) && defined (INCLUDE_FEI_END) */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -