⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sysfei82557end.c

📁 该源码为mpc8248处理器的BSP
💻 C
📖 第 1 页 / 共 2 页
字号:
LOCAL STATUS sys557IntAck    (    int unit            /* unit number */    )    {    FEI_RESOURCE *pReso = &feiResources [unit];     switch (pReso->boardType)        {        case TYPE_PRO100B_PCI:          /* handle PRO100B LAN Adapter */           /* no addition work necessary for the PRO100B */            break;         default:            return (ERROR);        }     return (OK);    }  /********************************************************************************* sys557eepromRead - read a word from the 82557 EEPROM** RETURNS: the EEPROM data word read in.*/ UINT16 sys557eepromRead    (    int unit,           /* unit number */    int location        /* address of word to be read */    )    {    UINT32 membase =  (feiResources[unit].membaseCsr);    UINT32 retval = 0;    UINT32 dataval;    volatile UINT32 dummy;    int ix;     sysOutWord (membase + SCB_EEPROM, EE_CS);    /* enable EEPROM */     /* write the READ opcode */     for (ix = EE_CMD_BITS - 1; ix >= 0; ix--)        {        dataval = (EE_CMD_READ & (1 << ix)) ? EE_DI : 0;         sysOutWord (membase + SCB_EEPROM, EE_CS | dataval);         sysUsDelay (1000);    /* delay for one IO READ cycle */         sysOutWord (membase + SCB_EEPROM, EE_CS | dataval | EE_SK);         sysUsDelay (1000);    /* delay for one IO READ cycle */        }     /* write the location */     for (ix = EE_ADDR_BITS - 1; ix >= 0; ix--)        {        dataval = (location & (1 << ix)) ? EE_DI : 0;        sysOutWord (membase + SCB_EEPROM, EE_CS | dataval);        sysUsDelay (1000);    /* delay for one IO READ cycle */        sysOutWord (membase + SCB_EEPROM, EE_CS | dataval | EE_SK);        sysUsDelay (1000);    /* delay for one IO READ cycle */        sysOutWord (membase + SCB_EEPROM, EE_CS | dataval);        sysUsDelay (1000);    /* delay for one IO READ cycle */        dummy = sysInWord (membase + SCB_EEPROM);        }     if ((dummy & EE_DO) == 0)           /* dummy read */        ;     /* read the data */     for (ix = EE_DATA_BITS - 1; ix >= 0; ix--)        {        sysOutWord (membase + SCB_EEPROM, EE_CS | EE_SK);         sysUsDelay (1000);    /* delay for one IO READ cycle */         retval = (retval << 1) |                 ((sysInWord (membase + SCB_EEPROM) & EE_DO) ? 1 : 0);         sysOutWord (membase + SCB_EEPROM, EE_CS);         sysUsDelay (1000);    /* delay for one IO READ cycle */        }     sysOutWord (membase + SCB_EEPROM, 0x00);     /* disable EEPROM */     return (retval);    } /********************************************************************************* sys557mdioRead - read MDIO** RETURNS: read value*/ LOCAL UINT16 sys557mdioRead    (    int unit,           /* unit number */    int phyId,          /* PHY ID */    int location        /* location to read */    )    {    UINT32 membase = ((feiResources[unit].membaseCsr));    int timeout   = 64*4;       /* <64 usec. to complete, typ 27 ticks */    int val;     sysOutLong (membase + SCB_MDI, 0x08000000 | (location<<16) | (phyId<<21));     do {        sysUsDelay (1000);    /* delay for one IO READ cycle */        val = sysInLong (membase + SCB_MDI);        if (--timeout < 0)            printf ("sys557mdioRead() timed out with val = %8.8x.\n", val);        } while (! (val & 0x10000000));     return (val & 0xffff);    } /********************************************************************************* sys557mdioWrite - write MDIO** RETURNS: write value*/ LOCAL UINT16 sys557mdioWrite    (    int unit,           /* unit number */    int phyId,          /* PHY ID */    int location,       /* location to write */    int value           /* value to write */    )    {    UINT32 membase = ((feiResources[unit].membaseCsr));    int timeout   = 64*4;       /* <64 usec. to complete, typ 27 ticks */    int val;     sysOutLong (membase + SCB_MDI,                0x04000000 | (location<<16) | (phyId<<21) | value);    do {        sysUsDelay (1000);    /* delay for one IO READ cycle */        val = sysInLong (membase + SCB_MDI);        if (--timeout < 0)            printf ("sys557mdioWrite() timed out with val = %8.8x.\n", val);        } while (! (val & 0x10000000));     return (val & 0xffff);    } /********************************************************************************* sys557Show - shows 82557 configuration** this routine shows (Intel Pro Express 100) configuration** RETURNS: N/A*/ void sys557Show    (    int unit            /* unit number */    )    {    FEI_RESOURCE *pReso = &feiResources [unit];    UINT32 membase       =  (pReso->membaseCsr);    UCHAR etheraddr[6];    int ix;    int iy;     if (unit >= feiUnits)        {        printf ("none\n");        return;        }     for (ix = 0, iy = 0; ix < 3; ix++)        {        etheraddr[iy++] = pReso->eeprom[ix];        etheraddr[iy++] = pReso->eeprom[ix] >> 8;        }     printf ("82557(%d): Intel EtherExpress Pro 10/100 at %#3x ", unit, membase);     for (ix = 0; ix < 5; ix++)        printf ("%2.2X:", etheraddr[ix]);     printf ("%2.2X\n", etheraddr[ix]);     printf ("CSR mem base address = 0x%x, Flash mem base address = 0x%x\n",            pReso->membaseCsr, pReso->membaseFlash);    printf ("PCI bus no. = 0x%x, device no. = 0x%x"            ", function no. = 0x%x, IRQ = %d\n",            pReso->pciBus, pReso->pciDevice, pReso->pciFunc, pReso->irq);     if (pReso->eeprom[3] & 0x03)        printf ("Receiver lock-up bug exists -- enabling work-around.\n");     printf ("Board assembly %4.4x%2.2x-%3.3d, Physical connectors present:",        pReso->eeprom[8], pReso->eeprom[9]>>8, pReso->eeprom[9] & 0xff);    for (ix = 0; ix < 4; ix++)        if (pReso->eeprom[5] & (1 << ix))            printf (connectors [ix]);     printf ("\nPrimary interface chip %s PHY #%d.\n",        phys[(pReso->eeprom[6]>>8)&7], pReso->eeprom[6] & 0x1f);    if (pReso->eeprom[7] & 0x0700)        printf ("Secondary interface chip %s.\n",                phys[(pReso->eeprom[7]>>8)&7]);      if (pReso->timeout < 0)        {               /* Test optimized out. */        printf ("Self test failed, status %8.8x:\n"                " Failure to initialize the 82557.\n"                " Verify that the card is a bus-master capable slot.\n",               pReso->pResults[1]);        }    else        {        printf ("General self-test: %s.\n"                " Serial sub-system self-test: %s.\n"                " Internal registers self-test: %s.\n"                " ROM checksum self-test: %s (%#8.8x).\n",                pReso->pResults[1] & 0x1000 ? "failed" : "passed",                pReso->pResults[1] & 0x0020 ? "failed" : "passed",                pReso->pResults[1] & 0x0008 ? "failed" : "passed",                pReso->pResults[1] & 0x0004 ? "failed" : "passed",                pReso->pResults[0]);        }    } /******************************************************************************** sys557LocalToPciBusAdrs - convert a local address to a bus address** This routine returns a PCIbus address for the LOCAL bus address.**/ LOCAL UINT32 sys557LocalToPciBusAdrs    (    int unit,    UINT32      adrs    /* Local Address */    )    {    return (LOCAL2PCI_MEMIO (adrs)); /* yk.h */    }  /******************************************************************************** sys557PciBusToLocalAdrs - convert a bus address to a local address** This routine returns a local address that is used to access the PCIbus.* The bus address that is passed into this routine is the PCIbus address* as it would be seen on the local bus.**/ LOCAL UINT32 sys557PciBusToLocalAdrs    (    int unit,    UINT32      adrs    /* PCI Address */    )    {    return (adrs); /* yk.h */    }/********************************************************************************* sys557IntEnable - enable 82557 interrupts** This routine enables 82557 interrupts.  This may involve operations on* interrupt control hardware.** The 82557 driver calls this routine throughout normal operation to terminate* critical sections of code.** This routine assumes that the PCI configuration information has already* been setup.** RETURNS: OK, or ERROR if interrupts could not be enabled.*/LOCAL STATUS sys557IntEnable    (    int unit            /* unit number */    )    {    FEI_RESOURCE *pReso = &feiResources [unit];    return (pciDeviceIntEnable ((int)pReso->irq));    }/********************************************************************************* sys557IntDisable - disable 82557 interrupts** This routine disables 82557 interrupts.  This may involve operations on* interrupt control hardware.** The 82557 driver calls this routine throughout normal operation to enter* critical sections of code.** This routine assumes that the PCI configuration information has already* been setup.** RETURNS: OK, or ERROR if interrupts could not be disabled.*/LOCAL STATUS sys557IntDisable    (    int unit            /* unit number */    )    {    FEI_RESOURCE *pReso = &feiResources [unit];        return (pciDeviceIntDisable ((int)pReso->irq));    }LOCAL STATUS sys557IntConnect     (     void *vector,     VOIDFUNCPTR *intHandler,     int drvCtrl,     STATUS *retval    ){*retval = pciDeviceIntConnect ((int)vector,intHandler,drvCtrl);return OK;}LOCAL STATUS sys557IntDisconnect     (     void *vector,     VOIDFUNCPTR *intHandler    ){int retVal;retVal = pciDeviceIntDisconnect((int)vector, intHandler);return OK;}#endif /* defined (INCLUDE_FEI_END) && defined (INCLUDE_NETWORK) */#ifdef CTDB_MPC8280#define MAV 0x569514e4void CheckPciMain (void){    FEI_RESOURCE *pReso;    int pciBus;    int pciDevice;    int pciFunc;    int unit;    BOOL duplicate;    UINT32 membaseCsr;    UINT32 membaseFlash;    char irq;    int ix;     for (unit = 0; unit < 1; unit++)        {        if (pciFindDevice ((MAV & 0xffff), (MAV >> 16),                           unit, &pciBus, &pciDevice, &pciFunc) != OK)           {           continue;	   }        printf("find \n");                /* check the duplicate */         pReso     = &feiResources [0];        duplicate = FALSE;         for (ix = 0; ix < 32; ix++, pReso++)            {            if ((ix != unit) && (pReso->pciBus == pciBus) &&                (pReso->pciDevice == pciDevice) && (pReso->pciFunc == pciFunc))                duplicate = TRUE;            }         if (duplicate)            continue;         /* we found the right one */         pReso = &feiResources [unit];        pReso->pciBus    = pciBus;        pReso->pciDevice = pciDevice;        pReso->pciFunc   = pciFunc;        /* get memory base address and IO base address */         pciConfigInLong (pReso->pciBus, pReso->pciDevice, pReso->pciFunc,                         PCI_CFG_BASE_ADDRESS_0, &membaseCsr);        pciConfigInLong (pReso->pciBus, pReso->pciDevice, pReso->pciFunc,                         PCI_CFG_BASE_ADDRESS_2, &membaseFlash);        pciConfigInByte (pReso->pciBus, pReso->pciDevice, pReso->pciFunc,                         PCI_CFG_DEV_INT_LINE, &irq);         membaseCsr   &= PCI_MEMBASE_MASK;        membaseFlash &= PCI_MEMBASE_MASK;         /* over write the resource table with read value */         pReso->membaseCsr   = PCI_MEMIO2LOCAL(membaseCsr);        pReso->iobaseCsr    = 0;         pReso->membaseFlash = PCI_MEMIO2LOCAL(membaseFlash);        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);        feiUnits++;     printf ("CSR mem base address = 0x%x, Flash mem base address = 0x%x\n",            pReso->membaseCsr, pReso->membaseFlash);    printf ("PCI bus no. = 0x%x, device no. = 0x%x"            ", function no. = 0x%x, IRQ = %d\n",            pReso->pciBus, pReso->pciDevice, pReso->pciFunc, pReso->irq);         }}#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -