📄 sysmotfcc2end.c
字号:
return retVal; }/************************************************************************* sysMiiInt - MII interrupt service routine** This routine check if the link up or down and update a flag** RETURNS: None.*/LOCAL void sysMiiInt ( PHY_INFO * pPhyInfo ) { UINT16 miiIntStatusReg =0; volatile int tmp; /* Clear MII interrupt by reading Int status reg * Interrupt controller doesn't chain ISRs so phyAddr will be wrong * Just read both to make sure. Not time efficient but then * no performance reqd for this interrupt */ if(pPhyInfo1!=NULL) MII_READ(pPhyInfo1->phyAddr,21,&miiIntStatusReg,tmp); if(pPhyInfo2!=NULL) MII_READ(pPhyInfo2->phyAddr,21,&miiIntStatusReg,tmp); ++miiNumLinkChgInts; /* Clear pending interrupt */ *M8260_SIPNR_H(vxImmrGet())=0x400; if(fccFuncs.miiPhyInt != NULL) { if(pPhyInfo1!=NULL) fccFuncs.miiPhyInt(pPhyInfo1->pDrvCtrl); if(pPhyInfo2!=NULL) fccFuncs.miiPhyInt(pPhyInfo2->pDrvCtrl); } }/************************************************************************* 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,tmp; VUINT16 miiSpecial,miiIntEnableReg; retVal = miiPhyInit (pPhyInfo); MII_READ(pPhyInfo->phyAddr,21,&miiIntEnableReg,tmp); if (tmp == OK) { intConnect (INUM_TO_IVEC(INUM_IRQ5),sysMiiInt,(int)pPhyInfo); miiIntEnableReg = 0x0c00; /* Enable link status change */ MII_WRITE(pPhyInfo->phyAddr, 21, miiIntEnableReg, tmp); MII_READ(pPhyInfo->phyAddr,21,&miiIntEnableReg,tmp); if (tmp == OK) { intEnable (INUM_IRQ5); } } if(pPhyInfo1 == NULL) pPhyInfo1 = pPhyInfo; else pPhyInfo2 = pPhyInfo; miiSpecial = 0x0400; MII_WRITE(pPhyInfo->phyAddr,16,miiSpecial,retVal); /* * Enable 10BaseT/MII mode, instead of serial mode. * If we don't do this, 10Mbps mode won't work right. */ MII_READ(pPhyInfo->phyAddr, 18, &miiSpecial, retVal); miiSpecial &= ~0x400; MII_WRITE(pPhyInfo->phyAddr, 18, miiSpecial, retVal); return retVal; }/************************************************************************* sysFccEnetEnable - enable the MII interface to the FCC 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 FCC.** RETURNS: OK, or ERROR if the FCC controller cannot be enabled.*/STATUS sysFccEnetEnable ( UINT32 immrVal, /* base address of the on-chip RAM */ UINT8 fccNum /* FCC being used */ ) { int intLevel; intLevel = intLock (); /* assert the enable signal */ if (fccNum==2) { /* de-assert the enable signal */ *BCSR3 |= 0x10000000; /* assert the reset signal */ *BCSR3 &= ~0x08000000; sysMsDelay(1); *BCSR3 |= 0x08000000; sysMsDelay(1); *BCSR3 &= ~0x10000000; sysMsDelay(10); *M8260_IOP_PCPAR(immrVal) |= (PC17 | PC16); *M8260_IOP_PCSO(immrVal) &= ~(PC17 | PC16); *M8260_IOP_PCDIR(immrVal) &= ~(PC17 | PC16); *M8260_IOP_PBPAR(immrVal) |= (PB31 | PB30 | PB29 | PB28 | PB27 | PB26 | PB25 | PB24 | PB23 | PB22 | PB21 | PB20 | PB19 | PB18); *M8260_IOP_PBDIR(immrVal) |= (PB31 | PB29 | PB25 | PB24 | PB23 | PB22); *M8260_IOP_PBDIR(immrVal) &= ~(PB30 | PB28 | PB27 | PB26 | PB21 | PB20 | PB19 | PB18); *M8260_IOP_PBSO(immrVal) &= ~(PB31 | PB30 | PB28 | PB27 | PB26 | PB25 | PB24 | PB23 | PB22 | PB21 | PB20 | PB19 | PB18); *M8260_IOP_PBSO(immrVal) |= (PB29); /* connect FCC2 clocks */ *M8260_CMXFCR (immrVal) &= ~0xff0000; *M8260_CMXFCR (immrVal) |= (M8260_CMXFCR_R2CS_CLK15 | M8260_CMXFCR_T2CS_CLK16); *M8260_CMXFCR (immrVal) &= ~(M8260_CMXFCR_FC2_MUX); } if (fccNum==1) { /* de-assert the enable signal */ *BCSR1 |= 0x08000000; /* assert the reset signal */ *BCSR1 &= ~0x04000000; sysMsDelay(1); *BCSR1 |= 0x04000000; sysMsDelay(1); *BCSR1 &= ~0x08000000; sysMsDelay(10); *M8260_IOP_PCPAR(immrVal) |= (PC21 | PC22); *M8260_IOP_PCSO(immrVal) &= ~(PC21 | PC22); *M8260_IOP_PCDIR(immrVal) &= ~(PC21 | PC22); *M8260_IOP_PASO(immrVal) |= (PD29 | PA28 | PA27 | PA26); *M8260_IOP_PADIR(immrVal) |= (PB29 | PB28 | PB21 | PB20 | PB19 | PB18); *M8260_IOP_PCSO(immrVal) |= (PC15 | PC14 | PC13 | PC12 | PC7 | PC6); *M8260_IOP_PCDIR(immrVal) |= (PC15 | PC14 | PC13 | PC12 | PC7 | PC6); *M8260_IOP_PDSO(immrVal) |= (PD29 | PD7); *M8260_IOP_PDDIR(immrVal) |= (PD29 | PD19 | PD18 | PD7); *M8260_IOP_PAPAR(immrVal) = (PA29 | PA28 | PA27 | PA26 | PA21 | PA20 |PA19 | PA18 | PA17 | PA16 | PA15 | PA14); *M8260_IOP_PCPAR(immrVal) |= (PC15 | PC14 | PC13 | PC12 | PC7 | PC6); *M8260_IOP_PDPAR(immrVal) |= (PD29 | PD19 | PD18); /* connect FCC1 clocks */ *M8260_CMXFCR (immrVal) &= ~0xff000000; *M8260_CMXFCR (immrVal) |= (M8260_CMXFCR_R1CS_CLK11 | M8260_CMXFCR_T1CS_CLK10); /* NMSI mode */ *M8260_CMXFCR (immrVal) &= ~(M8260_CMXFCR_FC1_MUX); } intUnlock (intLevel); taskDelay (sysClkRateGet() >> 2); return(OK); }/************************************************************************* sysFccEnetDisable - disable MII interface to the FCC controller** This routine is expected to perform any target specific functions required* to disable the Ethernet device and the MII interface to the FCC* controller. This involves restoring the default values for all the Port* B and C signals.** RETURNS: OK, always.*/STATUS sysFccEnetDisable ( UINT32 immrVal, /* base address of the on-chip RAM */ UINT8 fccNum /* FCC being used */ ) { volatile UINT32 tmp; int intLevel; intLevel = intLock (); /* * configure all Port B and C pins previously used as general * purpose input pins */ *M8260_IOP_PBPAR(immrVal) &= ~(PB15 | PB14); /* clear PAR bits for xcvr RST and PWRDWN pins */ *M8260_IOP_PBDIR(immrVal) |= (PB15 | PB14); /* make them outputs */ tmp = *M8260_IOP_PBDAT(immrVal); /* get current port B data */ tmp |= (PB14); /* drive the active high PWRWN pin high */ tmp &= ~(PB15); /* drive the active low RST low too */ *M8260_IOP_PBDAT(immrVal) = tmp; if (fccNum==2) { *M8260_IOP_PCPAR(immrVal) &= ~(PC17 | PC16); *M8260_IOP_PCDIR(immrVal) &= ~(PC10); *M8260_IOP_PBPAR(immrVal) &= ~(PB31 | PB30 | PB29 | PB28 | PB27 | PB26 | PB25 | PB24 | PB23 | PB22 | PB21 | PB20 | PB19 | PB18); *M8260_IOP_PBDIR(immrVal) &= ~(PB31 | PB29 | PB25 | PB24 | PB23 | PB22); /* Disable the interrupt */ intDisable (INUM_FCC2); /* de-assert the enable signal */ *BCSR3 |= 0x10000000; /* assert the reset signal */ *BCSR3 &= ~0x08000000; taskDelay(1); *BCSR3 |= 0x08000000; *BCSR3 &= ~0x10000000; } if (fccNum==1) { *M8260_IOP_PCPAR(immrVal) &= ~(PC21 | PC20); *M8260_IOP_PASO(immrVal) &= ~(PD29 | PA28 | PA27 | PA26); *M8260_IOP_PADIR(immrVal) &= ~(PB29 | PB28 | PB21 | PB20 | PB19 | PB18); *M8260_IOP_PCSO(immrVal) &= ~(PC15 | PC14 | PC13 | PC12 | PC7 | PC6); *M8260_IOP_PCDIR(immrVal) &= ~(PC15 | PC14 | PC13 | PC12 | PC7 | PC6); *M8260_IOP_PDSO(immrVal) &= ~(PD29 | PD7); *M8260_IOP_PDDIR(immrVal) &= ~(PD29 | PD19 | PD18 | PD7); *M8260_IOP_PAPAR(immrVal) &= ~(PA29 | PA28 | PA27 | PA26 | PA21 | PA20 |PA19 | PA18 | PA17 | PA16 | PA15 | PA14); *M8260_IOP_PCPAR(immrVal) &= ~(PC15 | PC14 | PC13 | PC12 | PC7 | PC6); *M8260_IOP_PDPAR(immrVal) &= ~(PD29 | PD19 | PD18); /* Disable the interrupt */ intDisable (INUM_FCC1); /* de-assert the enable signal */ *BCSR1 |= 0x08000000; /* assert the reset signal */ *BCSR1 &= ~0x04000000; taskDelay(1); *BCSR1 |= 0x04000000; *BCSR1 &= ~0x08000000; } intUnlock (intLevel); return(OK); }/************************************************************************* sysFccEnetCommand - issue a command to the Ethernet interface controller** RETURNS: OK, or ERROR if the Ethernet controller could not be restarted.*/STATUS sysFccEnetCommand ( UINT32 immrVal, /* base address of the on-chip RAM */ UINT8 fccNum, /* FCC being used */ UINT16 command ) { return (OK); }#ifndef NSDELAY#define MOTOROLA_FCC_LOOP_NS 2#define NSDELAY(nsec) \ { \ volatile int nx = 0; \ volatile int loop = (int)(nsec*MOTOROLA_FCC_LOOP_NS); \ \ for (nx = 0; nx < loop; nx++); \ }#endif /* NSDELAY *//************************************************************************* sysFccMiiBitWr - write one bit to the MII interface** This routine writes the value in <bitVal> to the MDIO line of a MII* interface. The MDC line is asserted for a while, and then negated.* If <bitVal> is NONE, then the MDIO pin should be left in high-impedance* state.** SEE ALSO: sysFccMiiBitRd()** RETURNS: OK, or ERROR.*/STATUS sysFccMiiBitWr ( UINT32 immrVal, /* base address of the on-chip RAM */ UINT8 fccNum, /* FCC being used */ INT32 bitVal /* the bit being written */ ) { miiBitWrCount++; /* * we create the timing reference for transfer of info on the MDIO line * MDIO is mapped on PC18, MDC on PC19. We need to keep the same data * on MDIO for at least 400 nsec. */ *M8260_IOP_PCPAR(immrVal) &= ~(PC19 | PC18); *M8260_IOP_PCDIR(immrVal) |= (PC19 | PC18); *M8260_IOP_PCDAT(immrVal) |= (PC19); switch (bitVal) { case 0: *M8260_IOP_PCDAT(immrVal) &= ~(PC18); break; case 1: *M8260_IOP_PCDAT(immrVal) |= (PC18); break; case ((INT32) NONE): /* put it in high-impedance state */ *M8260_IOP_PCDIR(immrVal) &= ~(PC18); break; default: return (ERROR); } /* delay about 200 nsec. */ NSDELAY (1); /* now we toggle the clock and delay again */ *M8260_IOP_PCDAT(immrVal) &= ~(PC19); NSDELAY (1); return (OK); }/************************************************************************* sysFccMiiBitRd - read one bit from the MII interface** This routine reads one bit from the MDIO line of a MII* interface. The MDC line is asserted for a while, and then negated.** SEE ALSO: sysFccMiiBitWr()** RETURNS: OK, or ERROR.*/STATUS sysFccMiiBitRd ( UINT32 immrVal, /* base address of the on-chip RAM */ UINT8 fccNum, /* FCC being used */ INT8 * bitVal /* the bit being read */ ) { miiBitRdCount++; /* * we create the timing reference for transfer of info on the MDIO line * MDIO is mapped on PC18, MDC on PC19. We can read data on MDIO after * at least 400 nsec. */ *M8260_IOP_PCPAR(immrVal) &= ~(PC19 | PC18); *M8260_IOP_PCDIR(immrVal) &= ~(PC18); *M8260_IOP_PCDIR(immrVal) |= (PC19); *M8260_IOP_PCDAT(immrVal) |= (PC19); /* delay about 200 nsec. */ NSDELAY (1); /* now we toggle the clock and delay again */ *M8260_IOP_PCDAT(immrVal) &= ~(PC19); NSDELAY (1); /* we can now read the MDIO data on PC18 */ *bitVal = (*M8260_IOP_PCDAT(immrVal) & (PC18)) >> 13; return (OK); }#endif /* INCLUDE_MOTFCCEND */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -