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

📄 sysbuspci.c

📁 WINDRIVER MCP750 BSP
💻 C
字号:
/* sysBusPci.c - Motorola MCPX750 PCI "board" special configuration code *//* Copyright 1997,1998,1999 Motorola, Inc. All Rights Reserved *//* Copyright 1997-1999 Wind River Systems, Inc. All Rights Reserved *//*modification history--------------------01h,01nov01,mil  Assigned USB interrupt and cleaned up compiler warnings.01g,10may99,srr  Merge in WRS pciAutoConfig support.01f,20apr99,srr  Remove non-standard CompactPCI interrupt support.01e,30sep98,scb  Make pciConfigInWord() calls with proper offset allignment.01d,29jul98,scb  Name change from "mv2600.h" to "mcpx750.h"01c,02jun98,mas  renamed module sysBusPci.c from pciNonGeneric.c.01b,24apr98,scb  mods to work with "generic" libraries.01a,05Jan98,scb  written based on Motorola bug code*//*DESCRIPTIONThis module contains the "non-generic" or "board specific" PCI-PCIbridge initialization code.  The module contains code to:  1.  Determine if a particular function is to be excluded from the	  automatic configuration process.  2.  Program the "interrupt line" field of the PCI configuration header.*//* includes */#include "mcpx750.h"#include "drv/pci/pciAutoConfigLib.h"#include "drv/pci/pciConfigLib.h"/* defines */#define INTA2INTD		4#define CPCI_LOGIGAL_SLOTS	8#define PCI_INTA		0#define PCI_INTB		1#define PCI_INTC		2#define PCI_INTD		3#define DEV_ON_ADDIN_BUS	1/* typedefs *//* globals *//* locals *//* * Table for converting (device number, interrupt pin) to interrupt * line value for programming the PCI configuration header.  This * table only applies to PCI devices which reside on bus 0 (Case 1 * as explained in sysPciAutoConfigIntAsgn()). */static UCHAR intLine [][4] =    {	{ 0xff, 0xff, 0xff, 0xff },  /* dev #0, PCI bridge */	{ 0xff, 0xff, 0xff, 0xff },  /* dev #1 */	{ 0xff, 0xff, 0xff, 0xff },  /* dev #2 */	{ 0xff, 0xff, 0xff, 0xff },  /* dev #3 */	{ 0xff, 0xff, 0xff, 0xff },  /* dev #4 */	{ 0xff, 0xff, 0xff, 0xff },  /* dev #5 */	{ 0xff, 0xff, 0xff, 0xff },  /* dev #6 */	{ 0xff, 0xff, 0xff, 0xff },  /* dev #7 */	{ 0xff, 0xff, 0xff, 0xff },  /* dev #8 */	{ 0xff, 0xff, 0xff, 0xff },  /* dev #9 */	{ 0xff, 0xff, 0xff, 0xff },  /* dev #10 */	{ 0xff, 0xff, 0xff, 0x0b },  /* dev #11, PCI-ISA/IDE/USB brg */	{ 0xff, 0xff, 0xff, 0xff },  /* dev #12, Not used */	{ 0xff, 0xff, 0xff, 0xff },  /* dev #13, Not used */	{ 0x02, 0xff, 0xff, 0xff },  /* dev #14, ethernet */	{ 0xff, 0xff, 0xff, 0xff },  /* dev #15, Not used */#ifdef CONFIG1_PLANAR_PCI /* e.g. MCP750 */	{ 0x03, 0x03, 0x03, 0x03 },  /* dev #16, PMC slot */	{ 0xff, 0xff, 0xff, 0xff },  /* dev #17, Not used */	{ 0xff, 0xff, 0xff, 0xff },  /* dev #18, Not used */	{ 0xff, 0xff, 0xff, 0xff },  /* dev #19, Not used */	{ 0x08, 0x09, 0x0a, 0x0b }   /* dev #20, PCI-PCI bridge */#endif /* CONFIG1_PLANAR_PCI */#ifdef CONFIG2_PLANAR_PCI /* e.g. MCPN750 */	{ 0x09, 0x0a, 0x0b, 0x0c },  /* dev #16, PMC slot */	{ 0x0c, 0x09, 0x0a, 0x0b },  /* dev #17, Not used */	{ 0xff, 0xff, 0xff, 0xff },  /* dev #18, Not used */	{ 0xff, 0xff, 0xff, 0xff },  /* dev #19, Not used */	{ 0x04, 0xff, 0xff, 0xff }   /* dev #20, nontransparent bridge */#endif /* CONFIG2_PLANAR_PCI */    };LOCAL    PCI_SYSTEM    sysParams;#ifdef PCI_ROLL_CALL_LIST_ENTRIES/* PCI autoconfig roll call support *//* Roll call list entry structure, list elements specified in "config.h" */typedef struct _PCI_ROLL_CALL_LIST    {    UINT count;    UINT Dev;    UINT Vend;    } PCI_ROLL_CALL_LIST;LOCAL PCI_ROLL_CALL_LIST rollCall[] =    {    PCI_ROLL_CALL_LIST_ENTRIES    { 0xffff, 0xffff, 0xffff }  /* Required entry: marks end of list */    };#endif/* forward declarations */LOCAL UCHAR sysPciAutoConfigIntAsgn ( PCI_SYSTEM * pSys, PCI_LOC * pFunc,    			UCHAR intPin );LOCAL STATUS sysPciAutoConfigInclude ( PCI_SYSTEM *pSys, PCI_LOC *pciLoc,			UINT devVend );#ifdef PCI_ROLL_CALL_LIST_ENTRIESLOCAL STATUS sysPciRollcallRtn ( );#endif/* subroutines *//******************************************************************************** sysPciAutoConfigInclude - Determine if function is to be autoConfigured** This function is called with PCI bus, device, function, and vendor * information.  It returns an indication of whether or not the particular* function should be included in the automatic configuration process.* This capability is useful if it is desired that a particular function* NOT be automatically configured.  Of course, if the device is not* included in automatic configuration, it will be unusable unless the* user's code made provisions to configure the function outside of the* the automatic process.** RETURNS: OK if function is to be included in automatic configuration,*          ERROR otherwise.*/ LOCAL STATUS sysPciAutoConfigInclude    (    PCI_SYSTEM *pSys,       /* input: AutoConfig system information */    PCI_LOC *pciLoc,        /* input: PCI address of this function */    UINT     devVend        /* input: Device/vendor ID number      */    )    {    BOOL retVal = OK;        /* If it's the host bridge then exclude it */    if ((pciLoc->bus == 0) && (pciLoc->device == 0) && (pciLoc->function == 0))        return ERROR;    switch(devVend)	{	/* EXCLUDED Devices */	case PCI_ID_IBC:		retVal = ERROR;		PCI_AUTO_DEBUG_MSG("sysPciAutoconfigInclude: Excluding IBC\n",			0, 0, 0, 0, 0, 0);		break;	 case PCI_ID_IDE:		retVal = ERROR;		PCI_AUTO_DEBUG_MSG("sysPciAutoconfigInclude: Excluding IDE\n",			0, 0, 0, 0, 0, 0);		break;	case PCI_ID_USB:		retVal = ERROR;		PCI_AUTO_DEBUG_MSG("sysPciAutoconfigInclude: Excluding USB\n",			0, 0, 0, 0, 0, 0);		break;	 case PCI_ID_PM:		retVal = ERROR;		PCI_AUTO_DEBUG_MSG("sysPciAutoconfigInclude: Excluding Power Mgmt\n",			0, 0, 0, 0, 0, 0);		break;	/* INCLUDED Devices */	case PCI_ID_PRI_LAN:		retVal = OK;		PCI_AUTO_DEBUG_MSG("sysPciAutoconfigInclude: Including Ethernet\n",			0, 0, 0, 0, 0, 0);		break;	case PCI_ID_BR_DEC21554:		retVal = OK;		PCI_AUTO_DEBUG_MSG("sysPciAutoconfigInclude: Including DEC 21554 bridge\n",			0, 0, 0, 0, 0, 0);		break;	case PCI_ID_BR_DEC21150:		retVal = OK;		PCI_AUTO_DEBUG_MSG("sysPciAutoconfigInclude: Including DEC 21150 bridge\n",			0, 0, 0, 0, 0, 0);		break;    	default:    		retVal = OK;		PCI_AUTO_DEBUG_MSG("sysPciAutoconfigInclude: Including unknown device\n",			0, 0, 0, 0, 0, 0);		break;	}    return retVal;    }/******************************************************************************** sysPciAutoConfigIntAssign - Assign the "interrupt line" value** RETURNS: "interrupt line" value.**/LOCAL UCHAR sysPciAutoConfigIntAsgn    (     PCI_SYSTEM * pSys,	/* input: AutoConfig system information */    PCI_LOC * pFunc,    UCHAR intPin	/* input: interrupt pin number */    )    {    UCHAR irqValue = 0xff;    /* Calculated value                */    if (intPin == 0)        return irqValue;    irqValue = intLine [(pFunc->device)][(intPin - 1)];    PCI_AUTO_DEBUG_MSG("intAssign called for device [%d %d %d] IRQ: %d\n",                pFunc->bus, pFunc->device, pFunc->function,                irqValue, 0, 0 );    return (irqValue);    }#ifdef PCI_ROLL_CALL_LIST_ENTRIES/******************************************************************************* sysPciRollCallRtn - Check "roll call" list against list of PCI devices found** This function checks if the number of devices actually found during* the 1st pass of PCI autoconfiguration (bus enumeration process)* passes the "roll call" test.  That is, for each entry in the roll call* list (consisting of a count and device/vendor ID), a check is made to* insure that at least the specified minimum number of devices has* actually been discovered.  If the roll call passes, the function returns* TRUE.  If the roll call fails and the time duration in seconds represented* by ROLL_CALL_MAX_DURATION has not elapsed, the function will wait 1* second and return FALSE.  If the roll call fails and the time duration in* seconds represented by ROLL_CALL_MAX_DURATION has elapsed, the function* will return TRUE.** RETURNS: TRUE if roll call test passes or timeout, FALSE otherwise.*/LOCAL STATUS sysPciRollcallRtn    (    )    {    STATUS  rollCallPass;       /* Flag indicating pass or fail */    int     rollIndex;    int    bus;    int    dev;    int    func;    int     count;    static  int secDelay = -1;    if (secDelay == -1)	secDelay = ROLL_CALL_MAX_DURATION;    rollCallPass = TRUE;        /* Default = "passed" */    rollIndex = 0;    while (secDelay >= 0)         {        if (rollCall[rollIndex].Vend == 0xffff)            break;              /* End of roll call list, we're done */        count = 0;        while (pciFindDevice(rollCall[rollIndex].Vend, rollCall[rollIndex].Dev,			    count, &bus, &dev, &func) == OK)	    count++;        if (count < rollCall[rollIndex].count)            {	    secDelay--;	    if (secDelay < 0)		{		rollCallPass = TRUE;	    /* Timeout, say we passed */		break;		}	    else		{                rollCallPass = FALSE;       /* Roll call - someone is missing */	        sysMsDelay(1000);           /* Delay a second */	        break;		}            }	rollIndex++;        }    if (rollCallPass == TRUE)	secDelay = -1;    return (rollCallPass);    }#endif/********************************************************************************* sysPciAutoConfig - PCI autoConfig support routine** This routine instantiates the PCI_SYSTEM structure needed to configure* the system. This consists of assigning address ranges to each category* of PCI system resource: Prefetchable and Non-Prefetchable 32-bit Memory, and* 16- and 32-bit I/O. Global values for the Cache Line Size and Maximum* Latency are also specified. Finally, the four supplemental routines for * device inclusion/exclusion, interrupt assignment, and pre- and* post-enumeration bridge initialization are specified. ** RETURNS: N/A*/void sysPciAutoConfig(void)    {    /*     * 32-bit Non-prefetchable Memory Space     * offset by 0x10 so that it doesn't start at PCI address 0x0     */    sysParams.pciMemIo32 = (PCI_MSTR_MEMIO_BUS + 0x10);    sysParams.pciMemIo32Size = PCI_MSTR_MEMIO_SIZE;    /* 32-bit Prefetchable Memory Space */    sysParams.pciMem32 = PCI_MSTR_MEM_BUS;    sysParams.pciMem32Size = PCI_MSTR_MEM_SIZE;    /* 16-bit ISA I/O Space - start after legacy devices. */    sysParams.pciIo16 = ISA_MSTR_IO_BUS + ISA_LEGACY_SIZE;    sysParams.pciIo16Size = ISA_MSTR_IO_SIZE - ISA_LEGACY_SIZE;    /* 32-bit PCI I/O Space */    sysParams.pciIo32 = PCI_MSTR_IO_BUS;    sysParams.pciIo32Size = PCI_MSTR_IO_SIZE;    /* Configuration space parameters */    sysParams.maxBus = 0;    sysParams.cacheSize = ( _CACHE_ALIGN_SIZE / sizeof(UINT32) );    sysParams.maxLatency = PCI_LAT_TIMER;    sysParams.autoIntRouting = TRUE;    /* Device inclusion and interrupt routing routines */    sysParams.includeRtn = sysPciAutoConfigInclude;    sysParams.intAssignRtn = sysPciAutoConfigIntAsgn;#ifdef PCI_ROLL_CALL_LIST_ENTRIES    /* "Roll call" routine */    sysParams.pciRollcallRtn = sysPciRollcallRtn;#endif    /*     * PCI-to-PCI Bridge Pre-     * and Post-enumeration init     * routines     */    sysParams.bridgePreConfigInit = NULL;    sysParams.bridgePostConfigInit = NULL;    /* Perform AutoConfig */    pciAutoConfig(&sysParams);    }

⌨️ 快捷键说明

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