📄 sysgei82544end.c
字号:
/* set the TX_CLK rate when operate in 1000T mode */ MII_READ (phyAddr, INTEL_82544PHY_EXT_PHY_SPEC_CTRL_REG, ®Val, retVal); regVal |= INTEL_82544PHY_EPSCR_TX_CLK_25; MII_WRITE (phyAddr, INTEL_82544PHY_EXT_PHY_SPEC_CTRL_REG, regVal, retVal); /* INTEL PHY's bug fixing ... */ MII_WRITE (phyAddr, 29, 0x5, retVal); MII_READ (phyAddr, 30, ®Val, retVal); regVal |= 0x100; MII_WRITE (phyAddr, 30, regVal, retVal); } /* other PHYS .... */ return; }/******************************************************************************* sys543IntAck - acknowledge an 82543 interrupt** This routine performs any 82543 interrupt acknowledge that may be* required. This typically involves an operation to some interrupt* control hardware.** This routine gets called from the 82543 driver's interrupt handler.** This routine assumes that the PCI configuration information has already* been setup.** ERRNO: N/A** RETURNS: OK, or ERROR*/LOCAL int sys543IntAck ( int unit /* unit number */ ) {#if 0/* On the supported boards there is nothing for us to do so simply return OK */ GEI_RESOURCE *pReso = &geiResources [unit]; switch (pReso->boardType) { case PRO1000_543_BOARD: /* handle PRO1000F LAN Adaptor */ case PRO1000_544_BOARD: /* handle PRO1000F LAN Adaptor */ case PRO1000_546_BOARD: break; default: SYS_GEI_LOG ("sys543IntAck ERROR\n",0,0,0,0,0,0); return (ERROR); }#endif /* 0 */ return (OK); }/******************************************************************************* sys543IntEnable - enable 82543 interrupts** This routine enables 82543 interrupts. This may involve operations on* interrupt control hardware.** The 82543 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 int sys543IntEnable ( int unit /* unit number */ ) { GEI_RESOURCE *pReso = &geiResources [unit]; switch (pReso->boardType) { case PRO1000_543_BOARD: /* handle PRO1000F LAN Adaptor */ case PRO1000_544_BOARD: /* handle PRO1000F LAN Adaptor */ case PRO1000_546_BOARD: intEnable (pReso->irq); break; default: SYS_GEI_LOG ("sys543IntEnable ERROR\n",0,0,0,0,0,0); return (ERROR); } return (OK); }/******************************************************************************* sys543IntDisable - disable 82543 interrupts** This routine disables 82543 interrupts. This may involve operations on* interrupt control hardware.** The 82543 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.** ERRNO: N/A** RETURNS: OK, or ERROR if interrupts could not be disabled.*/LOCAL STATUS sys543IntDisable ( int unit /* unit number */ ) { GEI_RESOURCE *pReso = &geiResources [unit]; switch (pReso->boardType) { case PRO1000_543_BOARD: /* handle PRO1000F LAN Adaptor */ case PRO1000_544_BOARD: /* handle PRO1000F LAN Adaptor */ case PRO1000_546_BOARD: intDisable (pReso->irq); break; default: SYS_GEI_LOG ("sys543IntDisable ERROR\n",0,0,0,0,0,0); return (ERROR); } return (OK); }/**************************************************************************** sys543LocalToBus - convert local address to corresponding PCI address** Converts a local bus (DRAM) address to the PCI address used by the NIC to* access the local address.** ERRNO: N/A** RETURNS: PCI bus address**/LOCAL UINT32 sys543LocalToBus ( int unit, /* unit number */ UINT32 localAddr /* RP local address to convert */ ) { UINT32 sysAddr; sysAddr = (UINT32)sysPhysToPci((void *)localAddr); return (sysAddr); }/**************************************************************************** sys543BusToLocal - convert PCI address to corresponding local address** Converts a PCI bus address to the corresponding local bus address.** ERRNO: N/A** RETURNS: local address useable by the CPU*/LOCAL UINT32 sys543BusToLocal ( int unit, /* unit number */ UINT32 sysAddr /* PCI bus address to convert */ ) { UINT32 localAddr; /* Does this need to be fast ?? */ localAddr = (UINT32)sysPciToPhys((void *)sysAddr); return (localAddr); }/***************************************************************************** sys543GeiInit - prepare LAN adaptor for 8254x initialization** This routine find out the PCI device, and map its memory and IO address.* If there is also an FEI network card on the PCI bus sys543GeiInit should* be called prior to initializing the 82557 with sys557PciInit().** ERRNO: N/A** RETURNS: void*/void sys543GeiInit (void){ GEI_RESOURCE *pReso; /* chip resources */ UINT32 memBaseLow; /* mem base low */ UINT32 memBaseHigh; /* mem base High */ UINT32 flashBaseLow; /* flash base low */ UINT32 flashBaseHigh; /* flash base high */ UINT32 ioBase; /* io base */ unsigned char irq; /* irq number */ unsigned int type; UINT i, unit, unitNum; for(i = 0; i < MAX_END_DEVS; ++i) { if(pendDevTbl[i].endLoadFunc == sysGei82543EndLoad) { pendDevTbl[i].processed = TRUE; } } /* * The following code tries to automatically detect * all instances of gei driver supported Ethernet cards. */ for (unit = 0; unit < sysGeiUnits ; unit++) { pReso = &geiResources [geiUnits]; if(sysPciFindDevices(geiDevices, geiUnits, &pReso->pciBus, &pReso->pciDevice, &pReso->pciVendID, &pReso->pciDevID) != OK) { break; /* found all instances */ } switch(pReso->pciDevID) { case PRO1000_543_PCI_DEVICE_ID_T: case PRO1000_543_PCI_DEVICE_ID_FT: pReso->boardType = PRO1000_543_BOARD; /* gei 82543's */ break; case PRO1000_544_PCI_DEVICE_ID_XT: case PRO1000_544_PCI_DEVICE_ID_XF: case PRO1000_544_PCI_DEVICE_ID_GC: pReso->boardType = PRO1000_544_BOARD; /* gei 82544's */ break; case PRO1000_540_PCI_DEVICE_ID_XT: case PRO1000_545_PCI_DEVICE_ID_XT: case PRO1000_546_PCI_DEVICE_ID_XT: case PRO1000_545_PCI_DEVICE_ID_MF: case PRO1000_546_PCI_DEVICE_ID_MF: pReso->boardType = PRO1000_546_BOARD; /* gei 82546's */ break; } pReso->pciFunc = 0; /* * * 64-bit BARs * * Memory: BAR0: [31:17]: memory base * [16:4] : read as "0" * [3] : 0 - device is not prefetchable * [2:1] : 10b - 64-bit address space * [0] : 0 - memory map decoded * * BAR1: [63:32]: memory base, high bits * * FLASH : BAR2: if BAR0[31:xx]: flash memory base * [xx:4] : read as "0" * * where 64K 31:16 15:4 * 128K 31:17 16:4 * 256K 31:18 17:4 * 512K 31:19 18:4 * * [3] : 0 - device is not prefetchable * [2:1] : 10b - 64-bit address space * [0] : 0 - memory map decoded * * BAR3: [63:32]: flash memory base, high bits * * IO : BAR4: if BAR0[31:3]: memory base * [2:1] : 00b * [0] : 1 - io map decoded * * 32-bit BARs * * Memory: BAR0: [31:17]: memory base, read/write * [16:4] : read as "0" * [3] : 0 - device is not prefetchable * [2:1] : 00b - 32-bit address space * [0] : 0 - memory map decoded * * FLASH : BAR1: if BAR0[31:xx]: flash memory base * [xx:4] : read as "0" * * where 64K 31:16 15:4 * 128K 31:17 16:4 * 256K 31:18 17:4 * 512K 31:19 18:4 * * [3] : 0 - device is not prefetchable * [2:1] : 00b - 32-bit address space * [0] : 0 - memory map decoded * * IO : BAR2: if BAR0[31:3]: memory base, read/write * [2:1] : 00b * [0] : 1 - io map decoded * */ /* read back memory base address and IO base address */ pciConfigInLong (pReso->pciBus, pReso->pciDevice, pReso->pciFunc, PCI_CFG_BASE_ADDRESS_0, &memBaseLow); type = memBaseLow & 0x6; pReso->addr64 = ((type & BAR0_64_BIT) == BAR0_64_BIT)? TRUE : FALSE; if (pReso->addr64) { pciConfigInLong (pReso->pciBus, pReso->pciDevice, pReso->pciFunc, PCI_CFG_BASE_ADDRESS_1, &memBaseHigh); pciConfigInLong (pReso->pciBus, pReso->pciDevice, pReso->pciFunc, PCI_CFG_BASE_ADDRESS_2, &flashBaseLow); pciConfigInLong (pReso->pciBus, pReso->pciDevice, pReso->pciFunc, PCI_CFG_BASE_ADDRESS_3, &flashBaseHigh); pciConfigInLong (pReso->pciBus, pReso->pciDevice, pReso->pciFunc, PCI_CFG_BASE_ADDRESS_4, &ioBase); } else { pciConfigInLong (pReso->pciBus, pReso->pciDevice, pReso->pciFunc, PCI_CFG_BASE_ADDRESS_1, &flashBaseLow); ioBase = 0x0; memBaseHigh = 0x0; flashBaseHigh = 0x0; } pciConfigInByte (pReso->pciBus, pReso->pciDevice, pReso->pciFunc, PCI_CFG_DEV_INT_LINE, &irq); pciConfigInWord (pReso->pciBus, pReso->pciDevice, pReso->pciFunc, PCI_CFG_SUB_VENDER_ID, &pReso->subSysVendID); pciConfigInWord (pReso->pciBus, pReso->pciDevice, pReso->pciFunc, PCI_CFG_SUB_SYSTEM_ID, &pReso->subSysDevID); pciConfigInByte (pReso->pciBus, pReso->pciDevice, pReso->pciFunc, PCI_CFG_CLASS, &pReso->classCode); pciConfigInByte (pReso->pciBus, pReso->pciDevice, pReso->pciFunc, PCI_CFG_SUBCLASS, &pReso->subClassCode); pciConfigInByte (pReso->pciBus, pReso->pciDevice, pReso->pciFunc, PCI_CFG_PROGRAMMING_IF, &pReso->progIF); pciConfigInByte (pReso->pciBus, pReso->pciDevice, pReso->pciFunc, PCI_CFG_REVISION, &pReso->revID); /* clear IO/Mem, mem type, prefetch bits */ memBaseLow &= ~0xf; flashBaseLow &= ~0xf; ioBase &= ~0x7; /* overwrite the resource table with read value */ pReso->memBaseLow = memBaseLow + IXP425_PCI_BASE; pReso->memBaseHigh = memBaseHigh; pReso->flashBaseLow = flashBaseLow + IXP425_PCI_BASE; pReso->flashBaseHigh = flashBaseHigh; pReso->ioBase = ioBase + IXP425_PCI_BASE; pReso->irq = irq; geiUnits++; } if(geiUnits) { /* one or more devices were found */ for(unitNum = 0, i = 0; unitNum < geiUnits && i < MAX_END_DEVS; ++i) { if(pendDevTbl[i].endLoadFunc == sysGei82543EndLoad || pendDevTbl[i].endLoadFunc == END_TBL_END) { pendDevTbl[i].unit = unitNum; pendDevTbl[i].endLoadFunc = sysGei82543EndLoad; pendDevTbl[i].endLoadString = ""; pendDevTbl[i].endLoan = TRUE /* GEI_BUFF_LOAN */ ; pendDevTbl[i].pBSP = NULL; pendDevTbl[i].processed = FALSE; ++unitNum; } } }}/******************************************************************************** sysGei82543EndLoad - load an instance of the gei82543End driver** This routine loads the gei driver with initial parameters specified by* values given in the BSP configuration files (config.h).** This routine only loads and initializes one instance of the device.* If the user wishes to use more than one 82543 devices, this routine* should be changed.** ERRNO: N/A** RETURNS: pointer to END object, (END_OBJ *) ERROR, or NULL.** SEE ALSO: gei82543EndLoad()*/END_OBJ * sysGei82543EndLoad ( char * pParamStr, /* ptr to initialization parameter string */ void * unused /* unused optional argument */ ) { /* * The gei82543End driver END_LOAD_STRING should be: * <memBase>:<memSize>:<rxDesNum>:<txDesNum>:<usrFlags>:<offset> * <offset> should be decimal, and the others hexadecimal. * Note that gei unit string is prepended by the mux, so we * don't put it here. */#define MAX_PARAM_STR 200 char * pStr = NULL; char paramStr [MAX_PARAM_STR]; END_OBJ * pEnd; UINT unit; GEI_RESOURCE *pReso; if (pParamStr == NULL) return ((END_OBJ *) ERROR); if (strlen (pParamStr) == 0) { /* * muxDevLoad() calls us twice. If the string is * zero length, then this is the first time through * this routine. */ pEnd = (END_OBJ *) gei82543EndLoad (pParamStr); } else { UINT32 memAddrAlloc, memAddr; UINT32 memSize = 0; UINT32 txDesNum; UINT32 rxDesNum; UINT32 clSize; UINT32 mtu; /* * On the second pass though here, we actually create * the initialization parameter string on the fly. * Note that we will be handed our unit number on the * second pass and we need to preserve that information. * So we use the unit number handed from the input string. */ pStr = strncpy (paramStr, pParamStr, MAX_PARAM_STR); if (pStr [MAX_PARAM_STR -1] != EOS) return NULL; if ( (unit = strtoul (paramStr, NULL, 0)) >= SYS_GEI_MAX_UNITS) { SYS_GEI_LOG ("sysGei82543EndLoad: unit number %d too large.\n", unit,0,0,0,0,0);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -