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

📄 s3c2510pci.c

📁 VxWorks BSP for S3C2510A
💻 C
📖 第 1 页 / 共 2 页
字号:
/*************************************************************************
*                                                                       
* FILE NAME:                                                             
*     s3c2510Pci.c                                        		 
*                                                                       
* DESCRIPTION: 
* SAMSUNG S3C2510 PCI Host driver.
* The file has functions which Auto Initialize PCI devices on the system.
*                   
*                                                                       
*-----------------------------------------------------------------------
* Copyright (C) 2003 Samsung Electronics. Inc., SISO, Bangalore             
*-----------------------------------------------------------------------
*  
* History
* -------                                                                                                                                   
* NAME            DATE              Modification Note
* 
* Sachin Prasad    08 Jul  2003        Modified to make Ansi C compliant
* Woongi Kim         Jan 2003 		 Created	
*                                                                       
*************************************************************************/

#include "vxWorks.h"
#include "intLib.h"
#include "cacheLib.h"
#include "errno.h"
#include "stdio.h"
#include "logLib.h"
#include "taskLib.h"
#include "config.h"
#include "drv/multi/s3c2510.h"
#include "drv/intrCtl/s3c2510Intr.h"

/* VxWorks PCI Library Include */
#include "drv/pci/pciAutoConfigLib.h"
#include "drv/pci/pciConfigLib.h"
#include "drv/pci/pciIntLib.h"


/* S3C2510 Specific PCI Definition */
#include "s3c2510Pci_def.h"
#include "s3c2510Pci.h"


/* include PCI related VxWorks source codes */
#include "pci/pciAutoConfigLib.c"
#include "pci/pciConfigLib.c"
#include "pci/pciConfigShow.c"
#include "pci/pciIntLib.c"

/* Forward Function Declarations */

static STATUS sysPciAutoconfigInclude(PCI_SYSTEM * pSys, PCI_LOC * pLoc, UINT devVend );
static UCHAR sysPciAutoconfigIntrAssign(PCI_SYSTEM * pSys, PCI_LOC * pLoc, UCHAR pin);
static void sysPciAutoconfigPreEnumBridgeInit(PCI_SYSTEM * pSys, PCI_LOC * pLoc, UINT devVend);
static void sysPciAutoconfigPostEnumBridgeInit(PCI_SYSTEM * pSys, PCI_LOC * pLoc, UINT devVend);


/* Debug log out definition */
#define PCI_DEBUG_LEVEL 4
#ifdef PCI_DEBUG_LEVEL
#define DEBUG(n, format, args...) 						\
	do													\
	{													\
		if(n < PCI_DEBUG_LEVEL)							\
		{												\
			char __buf[100];							\
			sprintf(__buf, format, ##args);				\
			printf("%s(): %s", __FUNCTION__, __buf);	\
		}												\
	} while(0)
#else
#define DEBUG(n, format, args...)
#endif


#undef __PCI_EXT_ARB
#undef __PCI_EXT_CLK
#undef __PCI_EXT_RST
#undef __PCI_EXT_PULLUP
#undef S3C2510PCI_DEVICESHOW
#undef S3C2510PCI_PCIHEADSHOW
#undef S3C2510PCI_INTERRUPT_LOG

/*
 * PCI_Delay
 *
 * FUNCTION:
 *  A delay loop for PCI host waiting for h/w stablization.
 * 
 * RETURNS:
 *  None.
 */

static void PCI_Delay (unsigned long x)
{
	while(--x) ;
} /*** end of PCI_Delay() ***/


/*
 * SMDK2510_PCI_Setup
 *
 * FUNCTION:
 *  S3C2510 PCI Host controller setup routine. Initialize PCI Configuration space registers.
 *  Disable PCI interrupt enable registers. 
 *  Check for External Arbitor, External clock & Externel PCI reset. Set Control registers
 *  accordingly. 
 * 
 * RETURNS:
 *  STATUS OK.
 * 
 * REFERENCE:
 *  LLD Section 8.1.2
 */

static STATUS SMDK2510_PCI_Setup (void)
{
	DEBUG(4, ">>\n");

	/* Disable PCI interrupt enable registers */
	rPCIINTEN = 0x0; 

	/* we don't use External Arbitor,External clock,Externel PCI reset */	
#ifndef __PCI_EXT_ARB
	rPCICON |= PCIARBITOR_INT;
#else
	DEBUG(4, "External Arbitor set\n");
#endif

#ifdef __PCI_EXT_CLK
	DEBUG(4, "External Clock is used !!!\n");
	rPCIDIAG0 |= PCICLK_EXT;
#else
	DEBUG(4, "Internal Clock is used.\n");
	rPCIRCC |= PCICLK_33M;
#endif

#ifdef __PCI_EXT_RST
	DEBUG(4, "External PCI Reset.\n");
	rPCIDIAG0 |= PCIRESET_EXT;
#endif

#ifdef __PCI_EXT_PULLUP
	DEBUG(4, "External PCI Pull-up\n");
	rPCIDIAG0 |= PCIPULLUP_EXT;
#endif

	rPCIRCC &= ~PCIRESETCLK_MASK;
	rPCIRCC |= PCILOG_RESET;
	rPCIRCC |= PCIBUS_RESET;

	/* waiting for the client cards to be ready */	
	PCI_Delay(13300000);
	
	/*
	 * PCIHCODE value needs to be changed, because the default value(0x0d8000) is
	 * for wireless controller. It is changed to the class code of the host bridge(0x060000).
	 */
	rPCIHCODE = 0x06000001; /* set Host bridge */

	/* Initialize PCI Configuration space registers */
	rPCIHCMD |= PCIBUSMASTER_ENABLE + PCIMWI_ENABLE + PCIPERR_RESPONSE_ENABLE 
				+ (AgentMode()? PCISERR_ENABLE:0);

	/* PCI MEM 0 Size is 0x2000000, == 32M */
	rPCIBAM0 = 0xfe000000;
	/*all enable for viewing status. */
	rPCIINTEN = 0xffffffff; 

	/* ready for using */
	rPCICON |= PCICONFIG_DONE + PCISYSTEMREAD_READY;

	/* Memory Burst Read enable(Burst Read decrease its performance).*/
	sPCICON.MMP = 1;

	rPCIHSTS |= PCISTATUS_ALL; /* rPCISCR All status clear */

	/* rPCIINTST All status clear */
	rPCIINTST = ALL_WRITE1CLR;
	sPCIBELPA.BEL = WRITE0CLR;

	return OK;

}/*** end of SMDK2510_PCI_Setup() ***/


/*PCI_SYSTEM structure defined in pciAutoConfigLib.h of VxWorks */

LOCAL PCI_SYSTEM sysParams;		/* PCI system parameters */							


/*
 * S3C2510_SysPciAutoConfig
 *
 * FUNCTION:
 *  Initializes PCI_SYSTEM structure (sysParams) with board specific parameters then 
 *  call pciAutoConfig function of pciAutoConfigLib library of VxWorks.
 * 
 * RETURNS:
 *  None.
 * 
 * REFERENCE:
 *  LLD Section 8.1.4
 */

static void S3C2510_SysPciAutoConfig (void)
{

    /* 32-bit Prefetchable Memory Space */
    sysParams.pciMem32 = PCI_MEM_ADRS;
    sysParams.pciMem32Size = PCI_MEM_SIZE;

    /* 32-bit Non-prefetchable Memory Space */
    sysParams.pciMemIo32 = PCI_MEM_ADRS;
    sysParams.pciMemIo32Size = PCI_MEM_SIZE;

    /* 16-bit ISA I/O Space */
    sysParams.pciIo16 = PCI_ISA_IO_ADRS;
    sysParams.pciIo16Size = PCI_ISA_IO_SIZE;

    /* 32-bit PCI I/O Space */
    sysParams.pciIo32 = PCI_IO_ADRS;
    sysParams.pciIo32Size = PCI_IO_SIZE;

    /* Configuration space parameters */
    sysParams.maxBus = 0;				/* No secondary bus */
    sysParams.cacheSize = ( _CACHE_ALIGN_SIZE / 4 );
    sysParams.maxLatency = PCI_LAT_TIMER;


    /*
     * Interrupt routing strategy
     * across PCI-to-PCI Bridges
     */
	/* It is fixed to PCI interrupt number(15) of S3C2510 */
	sysParams.autoIntRouting = FALSE;

    /* Device inclusion and interrupt routing routines */
    sysParams.includeRtn = sysPciAutoconfigInclude;
    sysParams.intAssignRtn = sysPciAutoconfigIntrAssign;

    /*
     * PCI-to-PCI Bridge Pre-
     * and Post-enumeration init
     * routines
     */
    sysParams.bridgePreConfigInit = sysPciAutoconfigPreEnumBridgeInit;
    sysParams.bridgePostConfigInit = sysPciAutoconfigPostEnumBridgeInit;

    /*
     * Perform any needed PCI Host Bridge
     * Initialization that needs to be done
     * before pciAutoConfig is invoked here 
     * utilizing the information in the 
     * newly-populated sysParams structure. 
     */

    pciAutoConfig (&sysParams);

    /*
     * Perform any needed post-enumeration
     * PCI Host Bridge Initialization here
     * utilizing the information in the 
     * sysParams structure that has been 
     * updated as a result of the scan 
     * and configuration passes. 
     */

}/*** end of S3C2510_SysPciAutoConfig() ***/


/*************************************************************************** 
*		Local BSP-Specific routines supplied by BSP Developer 
***************************************************************************/

/*
 * sysPciAutoconfigInclude
 *
 * FUNCTION:
 *  Makes all device auto configurable. 
 * 
 * RETURNS:
 *  STATUS OK.
 */


static STATUS sysPciAutoconfigInclude
    (
    PCI_SYSTEM * pSys,		/* PCI_SYSTEM structure pointer */
    PCI_LOC * pLoc,			/* pointer to function in question */
	UINT devVend			/* deviceID/vendorID of device */
    )
{
	return OK; /* Autoconfigure all devices */
} /*** end of sysPciAutoconfigInclude() ***/

/*
 * sysPciAutoconfigIntrAssign
 *
 * FUNCTION:
 *  Assigns the interrupt line register value for device. 
 * 
 * RETURNS:
 *  In S3C2510 its always 15.
 */

static UCHAR sysPciAutoconfigIntrAssign
    (
    PCI_SYSTEM * pSys,		/* PCI_SYSTEM structure pointer */
    PCI_LOC * pLoc,			/* pointer to function in question */
    UCHAR pin				/* contents of PCI int pin register */
    )
{
	DEBUG(4, "pin = 0x%02x.\n", pin);
    return (UCHAR)INT_IRQ_PCI_PCCARD;
} /*** end of sysPciAutoconfigIntrAssign() ***/

/*
 * sysPciAutoconfigPreEnumBridgeInit
 *
 * FUNCTION:
 *  This function takes care of any special pre initialization requirements of a 
 *  particular type of bridge at a specified geographic location.
 *  
 * NOTE:
 *  In S3C2510 it is not used.
 * 
 * RETURNS:
 *  None.
 */

static void sysPciAutoconfigPreEnumBridgeInit
    (
    PCI_SYSTEM * pSys,		/* PCI_SYSTEM structure pointer */
    PCI_LOC * pLoc,			/* pointer to function in question */
    UINT devVend			/* deviceID/vendorID of device */
    )
{
    return;
} /*** end of sysPciAutoconfigPreEnumBridgeInit() ***/

/*
 * sysPciAutoconfigPostEnumBridgeInit
 *
 * FUNCTION:
 *  This function takes care of any special post initialization requirements of a 
 *  particular type of bridge at a specified geographic location.
 *  
 * NOTE:
 *  In S3C2510 it is not used.
 * 
 * RETURNS:
 *  None.
 */

static void sysPciAutoconfigPostEnumBridgeInit
    (
    PCI_SYSTEM * pSys,		/* PCI_SYSTEM structure pointer */
    PCI_LOC * pLoc,			/* pointer to function in question */
    UINT devVend			/* deviceID/vendorID of device */
    )
{
    return;
} /*** end of sysPciAutoconfigPostEnumBridgeInit() ***/


/*
 * PCIMakeConfigAddress
 *
 * FUNCTION:
 *  Make PCI address from bus, device, function and offset number.

⌨️ 快捷键说明

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