📄 sysmottsecend.c
字号:
/************************************************************************* sysMiiPhyStatusGet - Return Status for all PHY attributes that are* hardware dependent.*** RETURNS: ERROR or OK.*/LOCAL STATUS sysMiiPhyStatusGet ( PHY_INFO * pPhyInfo, MOT_TSEC_PHY_STATUS * pStatus ) { UINT16 miiStat; int retVal = 0; if (sysMotTsecFuncs.miiPhyRead != NULL) { retVal = sysMotTsecFuncs.miiPhyRead(pPhyInfo->phyAddr,17,&miiStat); if (retVal != OK) return ERROR; pStatus->duplex = (miiStat&0x2000)?0:1; pStatus->speed = (miiStat&0xc000)>>13; } return retVal; }#if 0/************************************************************************* sysMiiInt - MII interrupt service routine** This routine checks if the link up or down and update a flag** RETURNS: None.*/LOCAL void sysMiiInt ( PHY_INFO * pPhyInfo ) { UINT16 miiIntStatusReg; UINT32 event; /* Clear MII interrupt by reading Int status reg */ if (sysMotTsecFuncs.miiPhyRead != NULL) { sysMotTsecFuncs.miiPhyRead (pPhyInfo->phyAddr,20,&miiIntStatusReg); event = miiIntStatusReg; if (sysMotTsecFuncs.miiPhyInt != NULL) { sysMotTsecFuncs.miiPhyInt (pPhyInfo->pDrvCtrl, event); } } return; }#endif/************************************************************************* sysMiiPhyInit - initialize and configure the PHY devices** This routine scans, initializes and configures the PHY device.** RETURNS: OK, or ERROR.*/LOCAL STATUS sysMiiPhyInit ( PHY_INFO * pPhyInfo ) { int retVal=OK; /* Initialisation of Phy performed in driver */ return (retVal);#if 0 if (retVal == OK) { if (sysMotTsecFuncs.miiPhyRead != NULL) { tmp = sysMotTsecFuncs.miiPhyRead(pPhyInfo->pDrvCtrl, pPhyInfo->phyAddr,18, &miiIntEnableReg); if (tmp == OK) { /* intConnect (INUM_TO_IVEC(INUM_IRQ6),sysMiiInt,(int)pPhyInfo); */ miiIntEnableReg = 0x12; if (sysMotTsecFuncs.miiPhyWrite != NULL) { tmp = sysMotTsecFuncs.miiPhyWrite(pPhyInfo->pDrvCtrl, pPhyInfo->phyAddr, 18, miiIntEnableReg); if (tmp == OK) { /* intEnable (INUM_IRQ6); */ } retry = 4; while (retry--) { tmp = sysMotTsecFuncs.miiPhyRead(pPhyInfo->pDrvCtrl, pPhyInfo->phyAddr, 18, &value); if (value == miiIntEnableReg) break; } } } } } return OK;#endif }/************************************************************************* sysMotTsecEnetEnable - enable the MII interface to the TSEC controller** This routine is expected to perform any target specific functions required* to enable the Ethernet device and to connect the MII interface to the TSEC.** RETURNS: OK, or ERROR if the TSEC controller cannot be enabled.*/LOCAL STATUS sysMotTsecEnetEnable ( UINT32 immrVal, /* base address of the on-chip RAM */ UINT32 tsecNum /* TSEC being used */ ) { int intLevel; intLevel = intLock (); intUnlock (intLevel); return(OK); }/************************************************************************* sysMotTsecEnetDisable - disable MII interface to the TSEC controller** This routine is expected to perform any target specific functions required* to disable the Ethernet device and the MII interface to the TSEC* controller. This involves restoring the default values for all the Port* B and C signals.** RETURNS: OK, always.*/LOCAL STATUS sysMotTsecEnetDisable ( UINT32 immrVal, /* base address of the on-chip RAM */ UINT32 tsecNum /* TSEC being used */ ) { int intLevel; intLevel = intLock (); /* Disable the interrupt */ intUnlock (intLevel); return(OK); }/************************************************************************* sysMotTsecEnetAddrGet - get the hardware Ethernet address** This routine provides the six byte Ethernet hardware address that will be* used by each individual TSEC device unit. This routine must copy* the six byte address to the space provided by <addr>.** RETURNS: OK, or ERROR if the Ethernet address cannot be returned.*/LOCAL STATUS sysMotTsecEnetAddrGet ( int unit, UCHAR * pAddr ) { /* need extra room for a 'EOS' -- driver may not provide it */ UINT8 eAdrs[8]; /* STATUS status; */ int index; index = sysEnetGetMacIndex (MOT_TSEC_DEV_NAME,unit);#if 0/* status = sysEnetAddrGet (unit,eAdrs); */ if (status == OK) { memcpy(pAddr,eAdrs,6); } return status;#else memcpy(pAddr,eAdrs,6); return OK;#endif /* 0 */ }/************************************************************************* sysMotTsecEnetAddrSet - Set the hardware Ethernet address** This routine provides the six byte Ethernet hardware address that will be* used by each individual TSEC device unit. This routine must copy* the six byte address to the space provided by <addr>.** RETURNS: OK, or ERROR if the Ethernet address cannot be returned.*/LOCAL STATUS sysMotTsecEnetAddrSet ( int unit, UCHAR * pAddr ) { /* need extra room for a 'EOS' -- driver may not provide it */ /* UINT8 eAdrs[8]; */ /* STATUS status; */ int index; index = sysEnetGetMacIndex (MOT_TSEC_DEV_NAME,unit);/* status = sysEnetAddrSet (index,eAdrs); */ return OK; }#define SYS_ENET_MAX_MACS 2typedef struct { char *devName; int macUnit; } SYS_ENET_MAC_TABLE;SYS_ENET_MAC_TABLE sysEnetMac[SYS_ENET_MAX_MACS] = { {MOT_TSEC_DEV_NAME,0}, {MOT_TSEC_DEV_NAME,1} };LOCAL int sysEnetGetMacIndex ( char *devName, int unit ) { int i; for (i = 0; i < SYS_ENET_MAX_MACS; i++) { if ( strcmp(devName, sysEnetMac[i].devName) == 0 ) { if (sysEnetMac[i].macUnit == unit) return (i); } } return (-1); }#if 0STATUS sysEnetAddrGet ( int macIndex, char *eAddrs ) { if (macIndex < SYS_ENET_MAX_MACS) { } else return ERROR; }STATUS sysEnetAddrSet ( int macIndex, char *eAddrs ) { if (macIndex < SYS_ENET_MAX_MACS) { } else return ERROR; }#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -