📄 sysgei82544end.c
字号:
/* sysGei82544End.c - system configuration module for gei82543End *//* Copyright 2005 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------01c,09feb05,m_h gei configuration01b,18jan05,m_h GEI END driver BSP functions01a,01jan05,m_h written.*//*DESCRIPTIONThis module is the WRS-supplied configuration module for Intel PRO1000F/T/XF/XT adaptors. It has routines for initializing device resourcesand provides BSP-specific gei82543End (gei) END driver routines forIntel 82543 and 82544 Ethernet PCI bus controllers.The number of supported devices that can be configured for a particularsystem is finite and is specified by the GEI_MAX_DEV configurationconstant. This value, and the internal data structures using it, can bemodified in this file for specific implementations.INCLUDE FILES: drv/pci/pciConfigLib.h, drv/end/gei82543End.h.I "RS82543GC GIGABIT ETHERNET CONTROLLER NETWORKING SILICON DEVELOPER'S MANUAL"*/#ifdef INCLUDE_GEI_END#include "vxWorks.h"#include "config.h"#include "stdio.h"#include "sysLib.h"#include "logLib.h"#include "intLib.h"#include "taskLib.h"#include "end.h"#include "drv/pci/pciConfigLib.h"#include "drv/end/gei82543End.h"#undef SYS_GEI_DEBUG#undef SYS_543_EEPROM_UTILS#define PRO1000_543_PCI_DEVICE_ID_T (0x1001) /* Copper */#define PRO1000_543_PCI_DEVICE_ID_FT (0x1004) /* Fiber / Copper */#define PRO1000_544_PCI_DEVICE_ID_XT (0x1008) /* Copper */#define PRO1000_544_PCI_DEVICE_ID_XF (0x1009) /* Fiber */#define PRO1000_544_PCI_DEVICE_ID_GC (0x100c) /* Copper */#define PRO1000_540_PCI_DEVICE_ID_XT (0x100e) /* Copper only */#define PRO1000_545_PCI_DEVICE_ID_XT (0x100f) /* Copper */#define PRO1000_546_PCI_DEVICE_ID_XT (0x1010) /* Copper */#define PRO1000_545_PCI_DEVICE_ID_MF (0x1011) /* Fiber */#define PRO1000_546_PCI_DEVICE_ID_MF (0x1012) /* Fiber */#define PRO1000_541_PCI_DEVICE_ID_XT (0x1076) /* Copper only */#define EEPROM_EWEN_OPCODE 0x0130 /* Erase-write enable */#define EEPROM_EWDS_OPCODE 0x0100 /* Erase-write disable */#define EEPROM_ERAL_OPCODE 0x0120 /* Erase all */#ifdef SYS_GEI_DEBUG#undef LOCAL#define LOCAL#define SYS_GEI_LOG(format, arg1, arg2, arg3, arg4, arg5, arg6) \ do { \ if (_func_logMsg != NULL) \ _func_logMsg ((format), (arg1), (arg2), (arg3), \ (arg4), (arg5), (arg6)); \ } while (FALSE);#else#define SYS_GEI_LOG(format, arg1, arg2, arg3, arg4, arg5, arg6)#endif /* SYS_GEI_DEBUG */IMPORT void sysMicroDelay (int microseconds);#define SYS_DELAY(delay) sysMicroDelay(delay)#ifndef SYS_GEI_MAX_UNITS#define SYS_GEI_MAX_UNITS SYS_GEI_UNITS#endif/* Default RX descriptor */#ifndef GEI_RXDES_NUM#define GEI_RXDES_NUM GEI_DEFAULT_RXDES_NUM#endif/* Default TX descriptor */#ifndef GEI_TXDES_NUM#define GEI_TXDES_NUM GEI_DEFAULT_TXDES_NUM#endif/* Default User's flags */#ifndef GEI_USR_FLAG#define GEI_USR_FLAG GEI_DEFAULT_USR_FLAG#endif/* PCI configuration type */#ifndef PCI_CFG_TYPE#define PCI_CFG_TYPE PCI_CFG_NONE#endif/* INTEL 82544 INTERNAL PHY */#define INTEL_82544PHY_OUI_ID (0x5043)#define INTEL_82544PHY_MODEL (0x3)#define INTEL_82544PHY_PHY_SPEC_CTRL_REG (0x10)#define INTEL_82544PHY_PHY_SPEC_STAT_REG (0x11)#define INTEL_82544PHY_INT_ENABLE_REG (0x12)#define INTEL_82544PHY_INT_STATUS_REG (0x13)#define INTEL_82544PHY_EXT_PHY_SPEC_CTRL_REG (0x14)#define INTEL_82544PHY_RX_ERROR_COUNTER (0x15)#define INTEL_82544PHY_PHY_GLOBAL_STAT (0x17)#define INTEL_82544PHY_LED_CTRL_REG (0x18)#define INTEL_82544PHY_PSCR_ASSERT_CRS_ON_TX (0x0800)#define INTEL_82544PHY_EPSCR_TX_CLK_25 (0x0070)/* Alaska PHY's information */#define MARVELL_OUI_ID 0x5043#define MARVELL_ALASKA_88E1000 0x5#define MARVELL_ALASKA_88E1000S 0x4#define ALASKA_PHY_SPEC_CTRL_REG 0x10#define ALASKA_PHY_SPEC_STAT_REG 0x11#define ALASKA_INT_ENABLE_REG 0x12#define ALASKA_INT_STATUS_REG 0x13#define ALASKA_EXT_PHY_SPEC_CTRL_REG 0x14#define ALASKA_RX_ERROR_COUNTER 0x15#define ALASKA_LED_CTRL_REG 0x18#define ALASKA_PSCR_ASSERT_CRS_ON_TX 0x0800#define ALASKA_EPSCR_TX_CLK_25 0x0070#define ALASKA_PSCR_AUTO_X_1000T 0x0040#define ALASKA_PSCR_AUTO_X_MODE 0x0060#define ALASKA_PSSR_DPLX 0x2000#define ALASKA_PSSR_SPEED 0xC000#define ALASKA_PSSR_10MBS 0x0000#define ALASKA_PSSR_100MBS 0x4000#define ALASKA_PSSR_1000MBS 0x8000#define SYS_GEI_SWAP16(x) ((((x) << 8) | ((x) >> 8)) & 0xFFFF)#define SYS_GEI_SWAP32(x) \ (((x) << 24) | \ (((x) & 0x0000FF00) << 8) | \ (((x) & 0x00FF0000) >> 8) | \ (((unsigned int)(x)) >> 24))#if (defined(IXP425_PCI_ENABLE_BYTE_ROUTING) && !defined(VXWORKS_DATA_COHERENT))#define GEI_SYS_WRITE_REG(unit, reg, value) \ ((*(volatile UINT32 *)(geiResources[(unit)].memBaseLow + reg)) = \ SYS_GEI_SWAP32((UINT32)(value)))#else /* IXP425_PCI_ENABLE_BYTE_ROUTING */#define GEI_SYS_WRITE_REG(unit, reg, value) \ ((*(volatile UINT32 *)(geiResources[(unit)].memBaseLow + reg)) = \ (UINT32)(value))#endif /* IXP425_PCI_ENABLE_BYTE_ROUTING */#define GEI_SYS_READ_REG(unit, reg) \ (sysInLong(geiResources[(unit)].memBaseLow + reg))/* typedefs */typedef struct geiResource /* GEI_RESOURCE */ { UINT32 memBaseLow; /* Base Address MEM LOW (PCI address) */ UINT32 memBaseHigh; /* Base Address MEM HIGH (PCI address) */ UINT32 flashBaseLow; /* Base Address FLASH LOW (PCI address) */ UINT32 flashBaseHigh; /* Base Address FLASH HIGH (PCI address) */ UINT32 ioBase; /* Base Address IO (PCI address) */ BOOL addr64; /* flag to key 64bit addressing */ UINT16 pciVendID; /* Vendor ID */ UINT16 pciDevID; /* Device ID */ UINT16 subSysVendID; /* Subsystem Vendor ID */ UINT16 subSysDevID; /* Subsystem Device ID */ int boardType; /* type of LAN board this unit is */ int pciBus; /* PCI Bus number */ int pciDevice; /* PCI Device number */ int pciFunc; /* PCI Function number */ UINT8 pciIntPin; /* which PCI INT pin this unit use */ UINT8 irq; /* Interrupt Request Level */ UINT8 revID; /* Revision ID */ UINT8 classCode; /* Class Code */ UINT8 subClassCode; /* Sub-Class Code */ UINT8 progIF; /* Programming Interface */ UINT16 eepromSize; /* size in unit of word (16 bit) - 64/256 */ UINT16 eeprom_icw1; /* EEPROM initialization control word 1 */ UINT16 eeprom_icw2; /* EEPROM initialization control word 2 */ UCHAR enetAddr[6]; /* MAC address for this adaptor */ STATUS iniStatus; /* initialization perform status */ UINT32 localToSysOffset; /* low part sysAddr - localAddr */ BOOL useShortCable; /* TRUE if short cable used for 82544 */ /* by default is FALSE */ } GEI_RESOURCE;typedef struct _if_params { UINT32 rxDesNum; /* number of RX descriptors for this unit */ UINT32 txDesNum; /* number of TX descriptors for this unit */ UINT32 usrFlags; /* user flags for this unit */ UINT32 clSize; /* cluster size */ UINT32 mtu; /* mtu */ char * ipAddr; /* IP address string (dot notation) */ char * hostName; /* host name corresponding to IP address */ u_int subnetMask; /* subnet mask; host native byte order */ } IF_PARAMS;/* locals */LOCAL UINT32 geiUnits = 0 ; /* number of GEIs found so far */UINT32 sysGeiUnits = SYS_GEI_UNITS;LOCAL IF_PARAMS geiConfig [SYS_GEI_MAX_UNITS] = { { GEI_RXDES_NUM, GEI_TXDES_NUM, GEI_USR_FLAG, 0, /* use default cluster size */ 0, /* use default mtu */ GEI_IP_ADDR, GEI_HOST_NAME, GEI_SUBNET_MASK }, { GEI_RXDES_NUM, GEI_TXDES_NUM, GEI_USR_FLAG, 0, /* use default cluster size */ 0, /* use default mtu */ GEI_IP_ADDR, GEI_HOST_NAME, GEI_SUBNET_MASK }, { GEI_RXDES_NUM, GEI_TXDES_NUM, GEI_USR_FLAG, 0, /* use default cluster size */ 0, /* use default mtu */ GEI_IP_ADDR, GEI_HOST_NAME, GEI_SUBNET_MASK }, { GEI_RXDES_NUM, GEI_TXDES_NUM, GEI_USR_FLAG, 0, /* use default cluster size */ 0, /* use default mtu */ GEI_IP_ADDR, GEI_HOST_NAME, GEI_SUBNET_MASK }, /* Add subsequent units here */ };END_OBJ * sysGei82543EndLoad (char * pParamStr, void * unused);LOCAL GEI_RESOURCE geiResources [SYS_GEI_MAX_UNITS] = { {UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, 64, 0, 0, {UNKNOWN}, ERROR, 0}, {UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, 64, 0, 0, {UNKNOWN}, ERROR, 0}, {UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, 64, 0, 0, {UNKNOWN}, ERROR, 0}, {UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, 64, 0, 0, {UNKNOWN}, ERROR, 0}, };LOCAL SYS_PCI_IDENT geiDevices [] ={ {INTEL_PCI_VENDOR_ID, PRO1000_543_PCI_DEVICE_ID_T}, {INTEL_PCI_VENDOR_ID, PRO1000_543_PCI_DEVICE_ID_FT}, {INTEL_PCI_VENDOR_ID, PRO1000_544_PCI_DEVICE_ID_XT}, {INTEL_PCI_VENDOR_ID, PRO1000_544_PCI_DEVICE_ID_XF}, {INTEL_PCI_VENDOR_ID, PRO1000_544_PCI_DEVICE_ID_GC}, {INTEL_PCI_VENDOR_ID, PRO1000_540_PCI_DEVICE_ID_XT}, {INTEL_PCI_VENDOR_ID, PRO1000_545_PCI_DEVICE_ID_XT}, {INTEL_PCI_VENDOR_ID, PRO1000_546_PCI_DEVICE_ID_XT}, {INTEL_PCI_VENDOR_ID, PRO1000_545_PCI_DEVICE_ID_MF}, {INTEL_PCI_VENDOR_ID, PRO1000_546_PCI_DEVICE_ID_MF}, {0, 0},};END_OBJ * sysGei82543EndLoad (char * pParamStr, void * unused);LOCAL int sys543IntEnable (int unit);LOCAL int sys543IntDisable (int unit);LOCAL int sys543IntAck (int unit);LOCAL void sys544PhyPreInit (PHY_INFO *);LOCAL STATUS sys543eepromCheckSum (int unit);LOCAL UINT16 sys543eepromReadWord (int unit,UINT32);LOCAL STATUS sys543EtherAddrGet (int unit);LOCAL void sys543PhySpecRegsInit(PHY_INFO *, UINT8);LOCAL BOOL sysGei82546InitTimerSetup (ADAPTOR_INFO * );LOCAL BOOL sysGei82546DynaTimerSetup (ADAPTOR_INFO * );LOCAL void sys543Delay (void);LOCAL UINT32 sys543BusToLocal (int unit, UINT32 sysAddr);LOCAL UINT32 sys543LocalToBus (int unit, UINT32 localAddr);void sys543Show(int unit);void sys543GeiInit (void);STATUS sys543MacAddrStringConvert (UINT8 mac [], char * macAddrString);LOCAL STATUS sys543IntConnect (void *vector, VOIDFUNCPTR *intHandler, int drvCtrl);#ifdef SYS_543_EEPROM_UTILSSTATUS sys543eepromProgram (int unit, UINT16 * pContents, BOOL checksumFix);STATUS sys543eepromEraseWriteAllow (int unit, BOOL enable);STATUS sys543eepromEraseAll (int unit);STATUS sys543eepromWriteWord (int unit, UINT32 index, UINT16 word);STATUS sys543eepromCopy (int unit, UINT16 * pWords);void sys543eepromDump (int unit);STATUS sys543eepromMacAddrSet (int unit, char * macAddrString);#endif /* SYS_543_EEPROM_UTILS *//*************************************************************************** sys543Delay - delay a while.** This routine delays a bit over a microsecond.** ERRNO: N/A** RETURNS: N/A*/void sys543Delay (void) { SYS_DELAY (1); }/******************************************************************************* sys82543BoardInit - prepare LAN adaptor for 82543 initialization** This routine is expected to perform any adaptor-specific or target-specific* initialization that must be done prior to initializing the 82543.** The 82543 driver calls this routine from the driver attach routine before* any other routines in this library.** ERRNO: N/A** RETURNS: OK or ERROR if the adaptor could not be prepared for initialization.*/STATUS sys82543BoardInit ( int unit, /* unit number */ ADAPTOR_INFO *pBoard /* board information for the GEI driver */ ) { GEI_RESOURCE *pReso = &geiResources [unit]; if (unit >= geiUnits) return (ERROR); if (pReso->boardType != PRO1000_543_BOARD && pReso->boardType != PRO1000_544_BOARD && pReso->boardType != PRO1000_546_BOARD) return ERROR; if (pReso->boardType == PRO1000_546_BOARD) { UINT32 eecd; if (((eecd = GEI_SYS_READ_REG(unit, INTEL_82543GC_EECD)) & EECD_PRES_BIT) == 0x0) { printf ("ERROR: gei unit %d eeprom not present\n", unit); return ERROR; } if ((eecd & EECD_SIZE_BIT) != 0) pReso->eepromSize = 256; /* bits per word */ else pReso->eepromSize = 64; } /* perform EEPROM checksum */ if (sys543eepromCheckSum (unit) != OK) { printf ("GEI82543:unit=%d, EEPROM checksum Error!\n", unit); } sys543EtherAddrGet (unit); /* Get ethernet address */ bcopy (pReso->enetAddr, pBoard->enetAddr, ETHER_ADDRESS_SIZE); /* initializes the board information structure */ pBoard->vector = (UINT32) pReso->irq; /* get the initialization control word 1 (ICW1) in EEPROM */ pReso->eeprom_icw1 = sys543eepromReadWord (unit, EEPROM_ICW1); /* get the initialization control word 2 (ICW2) in EEPROM */ pReso->eeprom_icw2 = sys543eepromReadWord (unit, EEPROM_ICW2); /* initializes the board information structure */ pBoard->boardType = pReso->boardType; pBoard->regBaseLow = pReso->memBaseLow; pBoard->regBaseHigh = pReso->memBaseHigh; pBoard->flashBase = pReso->flashBaseLow; pBoard->adr64 = pReso->addr64; pBoard->intEnable = sys543IntEnable; pBoard->intDisable = sys543IntDisable; pBoard->intAck = sys543IntAck; /* Intel copper-based adaptor is based on GMII interface */ pBoard->phyType = GEI_PHY_GMII_TYPE;#ifdef SYS_GEI544_USE_SHORT_CABLE pReso->useShortCable = TRUE;#endif if (pBoard->boardType == PRO1000_544_BOARD && pReso->useShortCable) { miiPhyOptFuncSet ((FUNCPTR)sys544PhyPreInit); } pBoard->phySpecInit = sys543PhySpecRegsInit; pBoard->delayFunc = (FUNCPTR) sys543Delay; pBoard->delayUnit = 1000; /* 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; } /* BSP/adaptor specific (for 82540/82545/82546 only) * allow users set up the device's internal timer based on their * application. sysGeiInitTimerSet() is called when the device * starts; sysGeiDynaTimerSet() is called every 2s in tNetTask if * GEI_END_SET_TIMER is set. */ if (pReso->boardType == PRO1000_546_BOARD) { pBoard->sysGeiDynaTimerSetup = sysGei82546DynaTimerSetup; pBoard->sysGeiInitTimerSetup = sysGei82546InitTimerSetup; } else { pBoard->sysGeiDynaTimerSetup = NULL; /* default */ pBoard->sysGeiInitTimerSetup = NULL; /* default */ } /* BSP specific * callback functions perform system physical memory mapping in the PCI * address space. sysLocalToBus converts a system physical memory address * into the pci address space. sysBusToLocal converts a pci address which * actually reflects a system physical memory back to the system memory * address. The sysBusToLocal here in this driver is NOT used for mapping * PCI device's memory (e.g. PCI device's control/status registers) * to the host address space. */ pBoard->sysLocalToBus = sys543LocalToBus; pBoard->sysBusToLocal = sys543BusToLocal; /* specify the interrupt connect/disconnect routines to be used */ pBoard->intConnect = (FUNCPTR) sys543IntConnect; pBoard->intDisConnect = (FUNCPTR) sysIntDisable; /* get the ICW1 and ICW2 */ pBoard->eeprom_icw1 = pReso->eeprom_icw1; pBoard->eeprom_icw2 = pReso->eeprom_icw2; /* copy Ether address */ memcpy (&pBoard->enetAddr[0], &pReso->enetAddr[0], ETHER_ADDRESS_SIZE); /* Adaptor initialization complete */ pReso->iniStatus = OK; return (OK); }/*************************************************************************
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -