📄 usrusbhcdohciinit.c
字号:
/* usrUsbHcdOhciInit.c - Initialization of a OHCI Host Controller Driver */
/* Copyright 1999-2002 Wind River Systems, Inc. */
/*
Modification history
--------------------
01c,14jan01,wef fixed bug that hcd scan would quit if the host controllers
were not sequntially configured in pci memory space.
01b,16jan01,wef modified to search for multiple host controllers instead of
just one.
01a,23aug00,wef Created
*/
/*
DESCRIPTION
This configlette initializes a USB Host Controller if present on a system.
The initialization process includes bringing up the chip and also "attaches"
the chip to the previously initilazed USB stack. The stack is initialized in
usrUsbInit.c
*/
/* includes */
#include "stdio.h"
#include "string.h"
#include "ctype.h"
#include "usb/usbPlatform.h" /* Basic definitions */
#include "usb/usbPciLib.h"
#include "usb/pciConstants.h"
#include "usb/usbdLib.h"
#include "drv/usb/usbOhci.h"
#include "drv/usb/usbHcdOhciLib.h"
#include "drv/multi/s3c2510.h"
#include "drv/intrCtl/s3c2510Intr.h"
/* defines */
#define MAX_OHCI_HCDS 2
/* Extra definitions used */
#define S3C2510_USB_HOST_BASE_ADDRESS 0xF0100000
#define INVALID_PCI_DEVICE_ID 0xFFFF
#define INVALID_PCI_VENDOR_ID 0xFFFF
#define USB_HOST_DEBUG 0
/* locals */
LOCAL GENERIC_HANDLE ohciAttachToken[MAX_OHCI_HCDS] = {NULL,NULL};
/*****************************************************************************
*
* usrUsbHcdOhciAttach - attaches a Host Controller to the USB Stack
*
* This function searches the pci bus for an OHCI type
* USB Host Controller. If it finds one, it attaches it to the already
* initialized USB Stack
*
* RETURNS: OK if sucessful or ERROR if failure
*/
STATUS usrUsbHcdOhciAttach ()
{
UINT16 status;
UINT8 busNo;
UINT8 deviceNo;
UINT8 funcNo;
PCI_CFG_HEADER pciCfgHdr;
UINT8 pciClass = OHCI_CLASS;
UINT8 pciSubclass = OHCI_SUBCLASS;
UINT8 pciPgmIf = OHCI_PGMIF;
HCD_EXEC_FUNC execFunc = &usbHcdOhciExec;
UINT8 HCDCount = 0;
UINT8 i =0;
/*GENERIC_HANDLE *pToken = &ohciAttachToken;*/
int idx;
/* just to test */
/* printf ("Value of S3C2510_UPLLCON before setting %x \n", *S3C2510_UPLLCON ); */
/* printf ("Value of S3C2510_SYSCFG %x \n", *S3C2510_SYSCFG );*/
/* *S3C2510_SYSCFG = 0x00000100; */ /* as per linux*/
/* *S3C2510_HPRIR = 0x00000330; */
/* *S3C2510_SYSCFG = 0x30000102;*//* as per our BSP */
/* changing USB Clock */
/* *S3C2510_UPLLCON = 0x00010358;*/
/* test ends here */
/* Enable the peripheral clock */
*S3C2510_PCLKDIS &= ~S3C2510_PCLKDIS_USBH;
#if USB_HOST_DEBUG
printf ("Values starting at S3C2510_SYSCFG \n" );
for (i=0;i<11;i++)
{
printf ("Offset %d : %x\n",i,*REG_32(i*4));
}
#endif
/* Form the fake PCI header for S3C2510 OHCI host controller */
memset (&pciCfgHdr,0, sizeof(PCI_CFG_HEADER));
pciCfgHdr.vendorId = INVALID_PCI_VENDOR_ID;
pciCfgHdr.deviceId = INVALID_PCI_DEVICE_ID;
pciCfgHdr.baseReg [0] = S3C2510_USB_HOST_BASE_ADDRESS;/* 0xF0100000 */
pciCfgHdr.intLine = INT_LVL_USBH;/* 13 */
/* Attach the OHCI HCD to the USBD. */
status = usbdHcdAttach (execFunc, &pciCfgHdr, &ohciAttachToken[HCDCount]);
if (status == OK)
{
printf ("S3c2510 attached Done.\n");
/* Increment the attached HCD count */
HCDCount++;
}
else
{
/* S32510 HCD attach Failure */
printf("S3c2510 HCD attach failed \n");
}
/*
* Loop through the maximum number of PCI devices
* that might be connected to a system in search of
* OHCI type USB Controllers.
*
*/
for (idx = 0; idx < PCI_MAX_DEV; idx++)
{
if (!usbPciClassFind (pciClass,
pciSubclass,
pciPgmIf,
idx,
&busNo,
&deviceNo,
&funcNo))
{
continue;
}
printf ("PCI based OHCI Controller found.\n");
printf ("Waiting to attach to USBD...");
usbPciConfigHeaderGet (busNo, deviceNo, funcNo, &pciCfgHdr);
/* if attached HCDs more than MAX_OHCI_HCDS */
if (HCDCount >= MAX_OHCI_HCDS) break;
/* Attach the OHCI HCD to the USBD. */
status = usbdHcdAttach (execFunc, &pciCfgHdr, &ohciAttachToken[HCDCount]);
/*status = usbdHcdAttach (execFunc, &pciCfgHdr, pToken);*/
/* Increment the attached HCD count */
HCDCount++;
/* *pToken += sizeof (GENERIC_HANDLE);*/
if (status == OK)
{
printf ("Done.\n");
}
else
{
printf ("Error attaching host controller # %d.\n", idx);
return ERROR;
}
}
return status;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -