📄 usbpcistub.c
字号:
/* usrUsbM834xInit.c - Initialization of a USB Host Controller Memory Mapped Interfaces *//* Copyright 1999-2005 Wind River Systems, Inc. *//*Modification history--------------------01b,16aug05,dtr Update comments.01a,11aug03,cfc Support for USB2 Host Stack*//*DESCRIPTIONThis configlette initializes a USB Host Controller Interface (EHCI)INCLUDE FILES: usb/pciConstants.h, usb/usbPciLib.h*//* includes */#include "vxWorks.h"#include "config.h"#include "drv/intrCtl/quiccIntrCtl.h"#include "usb2/usbHst.h"#include "usb2/usbEhcdDataStructures.h"/* defines */#ifdef INCLUDE_EHCI#define EHCI_CLASS 0x0c /* BASEC value for serial bus */#define EHCI_SUBCLASS 0x03 /* SCC value for USB */#define EHCI_PGMIF 0x20 /* EnhancedHCI */#define EHCI_HCCPARAMS 0x08 /* HCCPARAMS register offset */#define EHCI_HCCPARAMS_EECP_MASK 0x0000FF00 /* * extended capabilities * field position mask value */#define EHCI_HCCPARAMS_EECP_MIN 0x40 /* * extended capabilities * minimum value */#define EHCI_USBLEGSUP_OS_OFFSET 3 /* * Offset into the USBLEGSUP * register to access the OS * controllable space */UINT32 BADDR_EHCI[2];UINT32 IRQ_EHCI[2];#endif/* forward declarations */#ifdef INCLUDE_EHCIvoid sysEhciM834xInit();void usb2EhciM834xInit();#endifUINT32 usbMemToPci ( pVOID pMem /* memory address to convert */ ) ;pVOID usbPciToMem ( UINT32 pciAdrs /* 32-bit PCI address to be converted */ ) ;BOOL firstTime = TRUE;IMPORT UINT usbDataSwap(UINT);void usbEhciM834xInit(void) ;UINT16 usbPciWordIn ( UINT32 pMem /* memory address to convert */ ) { return *(UINT32*)pMem; }UINT32 usbPciDwordIn ( UINT32 pMem /* memory address to convert */ ) { return *(UINT32*)pMem; }UINT8 usbPciByteIn ( UINT32 pMem /* memory address to convert */ ) { return *(UINT32*)pMem; }void usbPciWordOut ( UINT32 pMem, /* memory address to convert */ UINT16 data ) { *(UINT32*)pMem = data; }void usbPciDwordOut ( UINT32 pMem, UINT32 data /* memory address to convert */ ) { *(UINT32*)pMem = data; }void usbPciByteOut ( UINT32 pMem, /* memory address to convert */ UINT8 data ) { *(UINT32*)pMem = data; }/***************************************************************************** usbPciWordGet - Returns a UINT16 configuration value** This function returns the UINT16 value at offset <regOffset> from* the PCI configuration space of the device identified by <busNo>,* <deviceNo>, and <funcNo>.** NOTE: This function adjusts for big vs. little endian environments.** RETURNS: UINT16 value read from device configuration space*/UINT32 usbPciWordGet ( UINT8 busNo, /* Bus number of device */ UINT8 deviceNo, /* Device number of device */ UINT8 funcNo, /* Function number of device */ UINT16 regOffset /* Offset into PCI config space */ ) { return 0; }/***************************************************************************** usbPciDwordGet - Returns a UINT32 configuration value** This function returns the UINT32 value at offset <regOffset> from* the PCI configuration space of the device identified by <busNo>,* <deviceNo>, and <funcNo>.** NOTE: This function adjusts for big vs. little endian environments.** RETURNS: UINT32 value read from device configuration space*/UINT32 usbPciDwordGet ( UINT8 busNo, /* Bus number of device */ UINT8 deviceNo, /* Device number of device */ UINT8 funcNo, /* Function number of device */ UINT16 regOffset /* Offset into PCI config space */ ) { UINT32 value; if (pciConfigInLong (busNo, deviceNo, funcNo, regOffset, &value) != OK) return 0; return value; }/***************************************************************************** usbPciConfigHeaderGet - Reads a device's PCI configuration header** This function reads the PCI configuration header for the device* identified by <busNo>, <deviceNo>, and <funcNo>. The configuration* header is stored in the <pCfgHdr> buffer provided by the caller.** This function initializes the <pCfgHdr> structure to zeros. Any* fields which cannot be read from the device's configuration header* will remain zero upon return. This function does not attempt to read* fields defined as "reserved" in the PCI configuration header.** RETURNS: N/A*/VOID usbPciConfigHeaderGet ( UINT8 busNo, /* Bus number of device */ UINT8 deviceNo, /* Device number of device */ UINT8 funcNo, /* Function number of device */ pPCI_CFG_HEADER pCfgHdr /* Buffer provided by caller */ ) { /* Do nothing if CfgHdr is NULL */ return; }/*******************************************************************************/void usbdM834xInit() {#ifdef INCLUDE_EHCI usbEhciM834xInit();#endif }/*************************************************************************//*NOTE: The EHCI controller is on the local bus of this processor and hasno PCI configuration registers. Therefore, by default, it exists andno searching for the EHCI core is required.Also, the EHCI core has no companion controllers but insteadintegrates a TT controller which allows low and full speeddevices to be hooked directly to 1 or 2 downstream ports.Low and full speed devices use the EHCI data structures.See the MPC8349E RM for more information.*/#if defined(INCLUDE_EHCI) && defined(MPC83XX)void usbEhciM834xInit(void) { BADDR_EHCI[0] = (UINT32)M83XX_CAPLENGTH(CCSBAR) ; IRQ_EHCI[0] = INUM_USB2_MPH ; }#endifUINT32 usbPciMemioOffset(){return(0);}/*************************************************************************** usbM834xIntDisable - Disables system interrupts** This routine is used to disable the interrupts for IRQ specifed in* <nIRQNumber>.** RETURNS: status of the function called to disable the interrupt** ERRNO: None*//* XXX this name needs to be changed */int usbPciIntDisable(UINT16 nIRQNumber) { int retStat = 0; retStat = (int)intDisable(nIRQNumber); return(retStat); }/*************************************************************************** usbM834xIntEnable - Enable system interrupts** This routine is used to enable the interrupts for IRQ specifed in* <nIRQNumber>.** RETURNS: status of the function called to enable the interrupt** ERRNO: none*//* XXX this name needs to be changed */int usbPciIntEnable(UINT16 nIRQNumber) { int retStat = 0; retStat = (int)intEnable(nIRQNumber); return(retStat); }/***************************************************************************** usbPciIntConnect - Connect to a interrupt vector** Connects the <func> to the interrupt number <intNo>. <param> is an* application-specific value which will be passed to <func> each time* the interrupt handler is invoked.** RETURNS: OK, or ERROR if unable to connect/enable interrupt*/STATUS usbPciIntConnect ( VOIDFUNCPTR func, /* new interrupt handler */ pVOID param, /* parameter for int handler */ UINT16 intNo /* interrupt vector number */ ) { UINT32 vec = (UINT32)intNo ; if (intConnect((VOIDFUNCPTR *)vec, func, (int)param) != OK) return ERROR; if (intEnable(vec) != OK) { return ERROR; } return OK; }/***************************************************************************** usbPciIntDisconnect - Removes an interrupt handler** Removes an interrupt handler installed by usbPciIntConnect(). <func>,* <param>, and <intNo> must match the corresponding parameters from an earlier* call to usbPciIntConnect().** RETURNS: N/A*/VOID usbPciIntRestore ( VOIDFUNCPTR func, /* int handler to be removed */ pVOID param, /* parameter for int handler */ UINT16 intNo /* interrupt vector number */ ) { UINT32 vec = (UINT32)intNo ; intDisable(vec); }/***************************************************************************** usbMemToPci - Convert a memory address to a PCI-reachable memory address** Converts <pMem> to an equivalent 32-bit memory address visible from the* PCI bus. This conversion is necessary to allow PCI bus masters to address* the same memory viewed by the processor.** RETURNS: converted memory address*/UINT32 usbMemToPci ( pVOID pMem /* memory address to convert */ ) { /* The conversion is a two-step process. First, we need to convert the * logical processor address (virtual) to a physical address. Then, we * convert the physical address to one which can be seen from the PCI * bus. */ /* 1:1 */ return (UINT32)pMem ; }/***************************************************************************** usbPciToMem - Convert a PCI-reachable address to a CPU-reachable pointer** Converts <pciAdrs> to an equivalent CPU memory address.** RETURNS: pointer to PCI memory*/pVOID usbPciToMem ( UINT32 pciAdrs /* 32-bit PCI address to be converted */ ) { /* 1:1 */ return(void *)(pciAdrs); }/* include this for onboard USB *//********************************************************************* * * usbPciClassFind - * * usbPciClassFind() * * RETURNS : NONE * */BOOL usbPciClassFind ( UINT8 pciClass, /* PCI device class */ UINT8 subClass, /* PCI device sub-class */ UINT8 pgmIf, /* Programming interface */ UINT16 index, /* Caller wants nth matching dev */ UINT8 * pBusNo, /* Bus number of matching dev */ UINT8 * pDeviceNo, /* Device number of matching dev */ UINT8 * pFuncNo /* Function number of matching dev */ ) { USB_HCD_BUS_INFO *hcdInfo; hcdInfo = (USB_HCD_BUS_INFO*)pBusNo; /* Copy all the data members */ hcdInfo->pFuncDataSwap = (FUNCPTR)usbDataSwap; hcdInfo->pFuncBufferSwap = NULL; hcdInfo->pFuncCpuToBus = (FUNCPTR)usbPciToMem; hcdInfo->pFuncBusToCpu = (FUNCPTR)usbMemToPci; hcdInfo->pFuncIntConnect = (FUNCPTR)usbPciIntConnect; hcdInfo->pFuncIntDisconnect = (FUNCPTR)usbPciIntRestore; hcdInfo->pBaseAddress = (VOID*)M83XX_CAPLENGTH(CCSBAR) ; if (firstTime==TRUE) { firstTime = FALSE; if(index==0) hcdInfo->irq = INUM_USB2_MPH; if(index == 0) return TRUE ; else { return FALSE ; } } else { return FALSE; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -