📄 sysgei82543end.c
字号:
pciConfigInLong (pReso->pciBus, pReso->pciDevice, pReso->pciFunc, PCI_CFG_BASE_ADDRESS_1, &flashBase); memBaseHigh = 0x0; } pciConfigInByte (pReso->pciBus, pReso->pciDevice, pReso->pciFunc, PCI_CFG_DEV_INT_LINE, &irq); memBaseLow &= PCI_MEMBASE_MASK; flashBase &= PCI_MEMBASE_MASK; /* over write the resource table with read value */ pReso->memBaseLow = memBaseLow; pReso->memBaseHigh = memBaseHigh; pReso->flashBase = flashBase; pReso->irq = irq; /* enable mapped memory and IO addresses */ pciConfigOutWord (pReso->pciBus, pReso->pciDevice, pReso->pciFunc, PCI_CFG_COMMAND, PCI_CMD_IO_ENABLE | PCI_CMD_MEM_ENABLE | PCI_CMD_MASTER_ENABLE); /* compose loadString in endDevTbl for this unit */ sys543LoadStrCompose (unit); geiUnits++; } return OK; }/****************************************************************************** sys543LoadStrCompose - Compose the END load string for the device** The END device load string formed by this routine is in the following* following format.* <shMemBase>:<shMemSize>:<rxDesNum>:<txDesNum>:<usrFlags>:<offset>** RETURN: N/A*/LOCAL void sys543LoadStrCompose ( int unit ) { END_TBL_ENTRY * pDevTbl; for (pDevTbl = endDevTbl; pDevTbl->endLoadFunc != END_TBL_END; pDevTbl++) { if (((UINT32)pDevTbl->endLoadFunc == (UINT32)GEI82543_LOAD_FUNC) && (pDevTbl->unit == unit)) { sprintf (pDevTbl->endLoadString, "0x%x:0x%x:0x%x:0x%x:0x%x:%d",/* This will need to be setup in the original geiResources table. */ geiResources [unit].shMemBase, geiResources [unit].shMemSize, geiResources [unit].rxDesNum, /* RX Descriptor Number*/ geiResources [unit].txDesNum, /* TX Descriptor Number*/ geiResources [unit].usrFlags, /* user's flags */ GEI_X86_OFFSET_VALUE /* offset value */ ); return; } } return; }/******************************************************************************* sys82543BoardInit - Adaptor initialization for 82543 chip** This routine is expected to perform any adapter-specific or target-specific* initialization that must be done prior to initializing the 82543 chip.** The 82543 driver calls this routine from the driver load routine before* any other routines.** RETURNS: OK or ERROR*/STATUS sys82543BoardInit ( int unit, /* unit number */ ADAPTOR_INFO *pBoard /* board information for the GEI driver */ ) { GEI_RESOURCE *pReso = &geiResources [unit]; /* sanity check */ if (unit >= geiUnits) return (ERROR); /* perform EEPROM checksum */ if (sys543eepromCheckSum (unit) != OK) { printf ("GEI82543:unit=%d, EEPROM checksum Error!\n", unit); } /* get the Ethernet Address from eeprom */ if (sys543EtherAdrGet (unit) != OK) { printf ("GEI82543:unit=%d, Invalid Ethernet Address!\n", unit); } /* get the initialization control word 1 (ICW1) in EEPROM */ geiResources[unit].eeprom_icw1 = sys543eepromReadWord (unit, EEPROM_ICW1); /* get the initialization control word 2 (ICW2) in EEPROM */ geiResources[unit].eeprom_icw2 = sys543eepromReadWord (unit, EEPROM_ICW2); /* initializes the board information structure */ pBoard->boardType = pReso->boardType; pBoard->vector = pReso->irq ; pBoard->regBaseLow = pReso->memBaseLow; pBoard->regBaseHigh = pReso->memBaseHigh; pBoard->flashBase = pReso->flashBase; pBoard->adr64 = pReso->adr64; pBoard->intEnable = sys543IntEnable; pBoard->intDisable = sys543IntDisable; pBoard->intAck = sys543IntAck; pBoard->phyType = GEI_PHY_GMII_TYPE; pBoard->phySpecInit = sys543PhySpecRegsInit; pBoard->delayFunc = (FUNCPTR) sys1000NsDelay; pBoard->delayUnit = 100; pBoard->sysLocalToBus = sys543LocalToPciBusAdrs; pBoard->sysBusToLocal = sys543PciBusToLocalAdrs; /* BSP/adaptor specific * set the PHY address if you know it, otherwise set to zero. * INTEL 82540/4/5/6-based adaptors have a built-in phy with Addr of 1 */ if (pReso->boardType == PRO1000_544_BOARD || pReso->boardType == PRO1000_546_BOARD) { pBoard->phyAddr = 1; } else { pBoard->phyAddr = 0; } /* specify the interrupt connect/disconnect routines to be used */ pBoard->intConnect = (FUNCPTR) intConnect; pBoard->intDisConnect = (FUNCPTR) intDisable; /* get the ICW1 and ICW2 */ pBoard->eeprom_icw1 = geiResources[unit].eeprom_icw1; pBoard->eeprom_icw2 = geiResources[unit].eeprom_icw2; /* copy Ether address */ memcpy (&pBoard->enetAddr[0], &geiResources[unit].enetAddr[0], ETHER_ADDRESS_SIZE); /* we finished adaptor initialization */ pReso->iniStatus = OK; return (OK); }/*************************************************************************** sys543eepromReadBits - read bits from EEPROM** This routine reads bit data from EEPROM** RETURNS: value in WORD size*/LOCAL UINT16 sys543eepromReadBits ( int unit, int bitsNum ) { UINT32 ix; UINT16 val = 0; for (ix = 0; ix < bitsNum; ix++) { /* raise the clk */ GEI_SYS_WRITE_REG(unit, INTEL_82543GC_EECD, (EECD_CS_BIT | EECD_SK_BIT)); /* wait 2000ns */ sysUsDelay(2); val = ( val << 1) | ((GEI_SYS_READ_REG(unit, INTEL_82543GC_EECD) & EECD_DO_BIT)? 1 : 0); /* lower the clk */ GEI_SYS_WRITE_REG(unit, INTEL_82543GC_EECD, EECD_CS_BIT); /* wait 2000 ns */ sysUsDelay(2); } return (val); }/*************************************************************************** sys543eepromWriteBits - write bits out to EEPROM** This routine writes bits out to EEPROM** RETURNS: N/A*/LOCAL void sys543eepromWriteBits ( int unit, UINT16 value, UINT16 bitNum ) { volatile UINT16 data; if (bitNum == 0) return; while (bitNum--) { data = (value & (0x1 << bitNum )) ? EECD_DI_BIT : 0; data |= EECD_CS_BIT; /* write the data */ GEI_SYS_WRITE_REG(unit, INTEL_82543GC_EECD, data); /* wait 1000ns */ sysUsDelay(1); /* raise the clk */ GEI_SYS_WRITE_REG(unit, INTEL_82543GC_EECD, (data | EECD_SK_BIT)); /* wait 1000ns */ sysUsDelay(1); /* lower the clk */ GEI_SYS_WRITE_REG(unit, INTEL_82543GC_EECD, data); /* wait 1000ns */ sysUsDelay(1); } return; }/*************************************************************************** sys543eepromReadWord - Read a word from EEPROM** RETURNS: value in WORD size*/LOCAL UINT16 sys543eepromReadWord ( int unit, UINT32 index ) { UINT16 val; UINT32 tmp; if (index >= EEPROM_WORD_SIZE) { printf ("Invalid index:%d to EEPROM\n", index); return 0; } tmp = GEI_SYS_READ_REG(unit, INTEL_82543GC_EECD); GEI_SYS_WRITE_REG(unit, INTEL_82543GC_EECD, EECD_CS_BIT); /* wait 1000ns */ sysUsDelay(2); /* write the opcode out */ sys543eepromWriteBits (unit, EEPROM_READ_OPCODE, EEPROM_CMD_BITS); /* write the index out */ sys543eepromWriteBits (unit, index, EEPROM_INDEX_BITS); tmp = GEI_SYS_READ_REG(unit, INTEL_82543GC_EECD); /* read the data */ val = sys543eepromReadBits (unit, EEPROM_DATA_BITS); /* clean up access to EEPROM */ tmp &= ~(EECD_DI_BIT | EECD_DO_BIT | EECD_CS_BIT); GEI_SYS_WRITE_REG(unit, INTEL_82543GC_EECD, tmp); return val; }/*************************************************************************** sys543EtherAdrGet - Get Ethernet address from EEPROM** This routine get an Ethernet address from EEPROM** RETURNS: OK or ERROR*/LOCAL STATUS sys543EtherAdrGet ( int unit ) { UINT32 ix, count = 0 ; UINT16 val; UCHAR adr [ETHER_ADDRESS_SIZE]; for (ix = 0; ix < ETHER_ADDRESS_SIZE / sizeof(UINT16); ix++) { /* get word i from EEPROM */ val = sys543eepromReadWord (unit, (UINT16)(EEPROM_IA_ADDRESS + ix)); adr [count++] = (UCHAR)val; adr [count++] = (UCHAR) (val >> 8); } /* check IA is UCAST */ if (adr[0] & 0x1) return (ERROR); memcpy (&geiResources[unit].enetAddr[0], adr, ETHER_ADDRESS_SIZE); return (OK); }/**************************************************************************** sys543eepromCheckSum - calculate checksum** This routine perform EEPROM checksum** RETURNS: N/A*/LOCAL STATUS sys543eepromCheckSum ( int unit ) { UINT16 checkSum = 0 ; UINT32 ix; for (ix = 0; ix < EEPROM_WORD_SIZE; ix++) checkSum += sys543eepromReadWord (unit, ix); if (checkSum == (UINT16)EEPROM_SUM) return OK; return ERROR; }/**************************************************************************** sys543PhySpecRegsInit - Initialize PHY specific registers** This routine initialize PHY specific registers** RETURN: N/A*/LOCAL void sys543PhySpecRegsInit ( PHY_INFO * pPhyInfo, /* PHY's info structure pointer */ UINT8 phyAddr /* PHY's bus number */ ) { UINT16 regVal; /* register value */ UINT16 phyId1; /* phy Id 1 */ UINT16 phyId2; /* phy ID 2 */ UINT32 retVal; /* return value */ UINT32 phyOui = 0; /* PHY's manufacture ID */ UINT32 phyMode; /* PHY mode number */ /* Intel Pro1000T adaptor uses Alaska transceiver */ /* read device ID to check Alaska chip available */ MII_READ (phyAddr, MII_PHY_ID1_REG, &phyId1, retVal); MII_READ (phyAddr, MII_PHY_ID2_REG, &phyId2, retVal); phyOui = phyId1 << 6 | phyId2 >> 10; phyMode = (phyId2 & MII_ID2_MODE_MASK) >> 4; if (phyOui == MARVELL_OUI_ID && (phyMode == MARVELL_ALASKA_88E1000 || phyMode == MARVELL_ALASKA_88E1000S))
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -