📄 sysmottsecend.c
字号:
/* extract the unit number */ tok = strtok_r (pParamStr, ":", &holder); if (tok == NULL) return (NULL); unit = (int) strtoul (tok, NULL, 16); if (unit > MOT_TSEC_MAX_DEVS ) return (NULL); /* enable stats and put into GMII mode */ usrFlags = MOT_TSEC_USR_STAT_ENABLE | MOT_TSEC_USR_MODE_GMII; /* get the MAC address */ if ( sysMotTsecEnetAddrGet(unit, enetAddr) == ERROR ) return (NULL); /* convert to string of chars */ /* finish off the initialization parameter string */ sprintf (paramStr, "%d:0x%x:0x%x:%02x-%02x-%02x-%02x-%02x-%02x:0x%x:0x%x:0x%x:0x%x:0x%x:0x%x:0x%x", unit, CCSBAR, sysMotTsecNumByUnit[unit], enetAddr[0], enetAddr[1], enetAddr[2], enetAddr[3], enetAddr[4], enetAddr[5], usrFlags, (UINT32)&sysMotTsecPhyParms[unit], (UINT32)&sysMotTsecFuncs, (UINT32)&sysMotTsecParms, (UINT32)NULL, (UINT32)NULL, (UINT32)&sysMotIntCtrl[unit] ); if ((pEnd = (END_OBJ *) motTsecEndLoad (paramStr)) == (END_OBJ *)NULL) logMsg ("Error: motTsecEndLoad failed to load driver\n", 0, 0, 0, 0, 0, 0);#if 0 else logMsg ("Load successful: 0x%08x\n", (int)pEnd, 0, 0, 0, 0, 0);#endif } return pEnd; }/************************************************************************* sysMiiPhyStatusGet - Return Status for all PHY attributes that are* harware 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 ) { UINT8 eAdrs[MAC_ADRS_LEN]; STATUS status; status = sysNetMacNVRamAddrGet ("mottsec", unit, eAdrs, MAC_ADRS_LEN); if (status == OK) { memcpy(pAddr,eAdrs,MAC_ADRS_LEN); } return status; }/************************************************************************* 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 ) { STATUS status; status = sysNetMacAddrSet ("mottsec", unit, pAddr, MAC_ADRS_LEN); return status; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -