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

📄 sysfei82557end.c

📁 WINDRIVER SBC7410 BSP
💻 C
📖 第 1 页 / 共 2 页
字号:
* This routine returns the interrupt level the <pIntLvl> parameter.** RETURNS: OK or ERROR if the adapter could not be prepared for initialization.*/STATUS sys557Init    (    int unit,                   /* unit number */    FEI_BOARD_INFO *pBoard      /* board information for the end driver */    )    {    FEI_RESOURCE *pReso;    /* resource ptr, initialized by sys557PciInit */    UINT16 sum = 0;     /* checksum of eeprom on fei board */    int ix;         /* general index */    int iy;         /* general index */    UINT16 value;       /* test return value */    if ( unit >= feiUnits )        return(ERROR);    /* figure out which fei resource we are working with */    pReso = &feiResources [unit];    /* set up the board */    if ( (pReso->boardType != TYPE_PRO100B_PCI) || (pReso->boardType != TYPE_PRO100S_PCI) )   /* only setup once */        {        /* read the configuration in EEPROM */        for ( ix = 0; ix < EE_SIZE; ix++ )            {            value = sys557eepromRead (unit, ix);            pReso->eeprom[ix] = value;            sum += value;            }        /*         * Verify checksum correct. This will fail if part is not correctly             * mapped and initialized as per sys557PciInit.             */        if ( sum != EE_CHECKSUM )            printf ("i82557(%d): Invalid EEPROM checksum %#4.4x\n", unit, sum);        /* DP83840-specific setup */        if ( ((pReso->eeprom[6]>>8) & 0x3f) == DP83840 )            {            int reg23 = sys557mdioRead (unit, pReso->eeprom[6] & 0x1f, 23);            sys557mdioWrite (unit, pReso->eeprom[6] & 0x1f, 23, reg23 | 0x0420);            }        /* perform a system self-test */        pReso->timeout = 16000;             /* Timeout for self-test */        pReso->pResults  = (volatile int *) cacheDmaMalloc(sizeof(pReso->str));        pReso->pResults[0] = 0;        pReso->pResults[1] = -1;        sysOutLong(PCI_MEMIO2LOCAL((pReso->membaseCsr + SCB_PORT)), (int)pReso->pResults | 1);        do            {            sysDelay ();        /* delay for one IO READ cycle */            }        while ( (pReso->pResults[1] == -1) && (--pReso->timeout >= 0) );        if ( pReso->pciDevice == PRO100B_PCI_DEVICE_ID )            pReso->boardType = TYPE_PRO100B_PCI;        else            pReso->boardType = TYPE_PRO100S_PCI;        }    /* complete initialization of the board information structure */    pBoard->vector   = pReso->irq;    pBoard->baseAddr = pReso->membaseCsr;    for ( ix = 0, iy = 0; ix < 3; ix++ )        {        pBoard->enetAddr[iy++] = pReso->eeprom[ix] & 0xff;        pBoard->enetAddr[iy++] = (pReso->eeprom[ix] >> 8) & 0xff;        }    pBoard->intEnable     = sys557IntEnable;    pBoard->intDisable    = sys557IntDisable;    pBoard->intAck        = sys557IntAck;    pBoard->sysLocalToBus = sys557LocalToPciBusAdrs;    pBoard->sysBusToLocal = sys557PciBusToLocalAdrs;    #ifdef FEI_10MB    pBoard->phySpeed      = NULL;    pBoard->phyDpx        = NULL;    #endif    return(OK);    }/***************************************************************************    ** sys557IntEnable - enable 82557 interrupts** This routine enables 8255x interrupts.  This may involve operations on* interrupt control hardware.** RETURNS: OK or ERROR for invalid arguments.*/LOCAL STATUS sys557IntEnable     (    int unit   /* unit number */    )    {#if defined(INCLUDE_PCI_STANDALONE)    sysGt64260MuxedIntEnable(GPP_INT_TYPE, 9); /* pin 9 */#else    sysGt64260MuxedIntEnable(GPP_INT_TYPE, 5); /* pin 5 */#endif    return OK ;    }/********************************************************************************* sys557IntDisable - disable 82557 interrupts** This routine disables 8255x interrupts.  This may involve operations on* interrupt control hardware.** RETURNS: OK or ERROR for invalid arguments.*/LOCAL STATUS sys557IntDisable     (    int unit   /* unit number */    )    {#if defined(INCLUDE_PCI_STANDALONE)    sysGt64260MuxedIntDisable(GPP_INT_TYPE, 9); /* pin 9 */#else    sysGt64260MuxedIntDisable(GPP_INT_TYPE, 5); /* pin 5 */#endif    return OK ;    }/***************************************************************************** sys557IntAck - acknowledge an 82557 interrupt** This routine performs any 82557 interrupt acknowledge that may be* required.  This typically involves an operation to some interrupt* control hardware.** This routine gets called from the 82557 driver's interrupt handler.** This routine assumes that the PCI configuration information has already* been setup.** RETURNS: OK, or ERROR if the interrupt could not be acknowledged.*/LOCAL STATUS sys557IntAck    (    int unit            /* unit number */    )    {    FEI_RESOURCE *pReso = &feiResources [unit];    switch ( pReso->boardType )        {        case TYPE_PRO100B_PCI:          /* handle PRO100B LAN Adapter */        case TYPE_PRO100S_PCI:          /* handle PRO100S LAN Adapter */            /* no addition work necessary for the PRO100B/PRO100S */            break;        default:            return(ERROR);        }    return(OK);    }/***************************************************************************** sys557eepromRead - read a word from the 82557 EEPROM** RETURNS: the EEPROM data word read in.*/LOCAL UINT16 sys557eepromRead    (    int unit,           /* unit number */    int location        /* address of word to be read */    )    {    UINT32 membase = PCI_MEMIO2LOCAL (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);        sysDelay ();    /* delay for one IO READ cycle */        sysOutWord (membase + SCB_EEPROM, EE_CS | dataval | EE_SK);        sysDelay ();    /* 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);        sysDelay ();    /* delay for one IO READ cycle */        sysOutWord (membase + SCB_EEPROM, EE_CS | dataval | EE_SK);        sysDelay ();    /* delay for one IO READ cycle */        sysOutWord (membase + SCB_EEPROM, EE_CS | dataval);        sysDelay ();    /* 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);        sysDelay ();    /* delay for one IO READ cycle */        retval = (retval << 1) |                 ((sysInWord (membase + SCB_EEPROM) & EE_DO) ? 1 : 0);        sysOutWord (membase + SCB_EEPROM, EE_CS);        sysDelay ();    /* 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 = PCI_MEMIO2LOCAL((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        {        sysDelay ();    /* 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 = PCI_MEMIO2LOCAL((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        {        sysDelay ();    /* 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);    }/***************************************************************************** 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 */    )    {    adrs = LOCAL2PCI_MEMIO (adrs);    return(adrs);    }/***************************************************************************** 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 */    )    {    adrs = PCI_MEMIO2LOCAL(adrs);    return(adrs);    }#endif /* defined (INCLUDE_FEI82557END) && defined (INCLUDE_NETWORK) */

⌨️ 快捷键说明

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