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

📄 usbohci.c

📁 usb2 driver for vxwokrs
💻 C
📖 第 1 页 / 共 4 页
字号:
/* usbOhci.c - USB OHCI Driver Entry and Exit points *//* Copyright 2004-2005 Wind River Systems, Inc.    This software includes software licensed to Wind River Systems, Inc.   by Wipro, Ltd. Wind River licensees may use this software according     to the terms of their Wind River license agreement(s) applicable to    this software.*//*modification history--------------------01h,15apr05,pdg  Fix for compilation error when USB_OHCI_POLLING_MODE is                 defined01g,11apr05,ami  Changes made in Warm Reboot Function01f,06apr05,mta  Fix for warm reboot giving mempartfree error01e,28mar05,pdg  non-PCI changes01d,02mar05,ami  SPR #106373 (Max OHCI Controller Issue) & correction in usbOhciCreatePipe function call01c,25feb05,mta  SPR 10627601b,27jun03,nld Changing the code to WRS standards01a,17mar02,ssh Initial Version*//*DESCRIPTIONThis provides the entry and exit points for the USB OHCI driver.INCLUDE FILES:	usb2/usbOhci.h, usb2/usbOhciRegisterInfo.h, usb2/usbOhciTransferManagement.h, usbOhciRootHubEmulation.c, usbOhciTransferManagement.c, usbOhciIsr.crebootLib.h*//*INTERNAL ******************************************************************************* * Filename         : usbOhci.c * * Copyright        : * * THE COPYRIGHT IN THE CONTENTS OF THIS SOFTWARE VEST WITH WIPRO * LIMITED A COMPANY INCORPORATED UNDER THE LAWS OF INDIA AND HAVING * ITS REGISTERED OFFICE AT DODDAKANNELLI SARJAPUR ROAD  BANGALORE * 560 035. DISTRIBUTION OR COPYING OF THIS SOFTWARE BY * ANY INDIVIDUAL OR ENTITY OTHER THAN THE ADDRESSEE IS STRICTLY * PROHIBITED AND MAY INCUR LEGAL LIABILITY. IF YOU ARE NOT THE * ADDRESSEE PLEASE NOTIFY US IMMEDIATELY BY PHONE OR BY RETURN EMAIL. * THE ADDRESSEE IS ADVISED TO MAINTAIN THE PROPRIETARY INTERESTS OF * THIS COPYRIGHT AS PER APPLICABLE LAWS. * * Description      : This file contains entry and exit points for the *                    OHCI driver. * * ******************************************************************************//* includes */#include "usb2/usbOsal.h"#include "usb2/BusAbstractionLayer.h"#include "usb2/usbHst.h"#include "usb2/usbOhci.h"#include "usb2/usbOhciRegisterInfo.h"#include "usb2/usbOhciTransferManagement.h"#include "rebootLib.h"/* defines *//********************** MODULE SPECIFIC MACRO DEFINITION **********************//* To hold the maximum bandwidth support in USB 1.1. * * NOTE: The formula used to compute the bandwidth required by an endpoint *       (COMPUTE_BANDWIDTH_FOR_INTERRUPT_ENDPOINT and *       COMPUTE_BANDWIDTH_FOR_ISOCHRONOUS_ENDPOINT) return the value in  *       nano seconds. Hence, the following variable stores the bandwidth *       available in nano seconds. */#define USB_OHCI_MAXIMUM_USB11_BANDWIDTH                        1000000/* To hold the percentage of bandwidth reserved for periodic transfers */ #define USB_OHCI_PERCENTAGE_BANDWIDTH_FOR_PERIODIC_TRANSFERS	0.90 /* 90% */#define PUSB_OHCI_ENDPOINT_DESCRIPTOR_OFFSET  16 /* * Mask value for the interrupts to be enabled. Enable the following  * interupts: * *  - Schedule Overrun *  - Done Head Write Back *  - Start Of Frame             *  - Resume Detect *  - Unrecoverable Error *  - Frame Number Overflow *  - Root Hub Status Change *   * Finally set the Master Interrupt Enable bit. *//*  * NOTE: For debugging, only the following interrupts are enabled * *       - Schedule Overrun *       - Done Head Write Back *       - SOF *       - Root Hub Status Change */#define USB_OHCI_INTERRUPT_MASK         						0x80000042/*  * Specifies the time (in milli seconds) to wait for the host controller * reset operation to complete. */#define USB_OHCI_WAIT_FOR_HOST_CONTROLLER_RESET_COMPLETION  	1/* * On completion of the reset, the host controller is in USB_SUSPEND * state. The host controller should remain in the USB_SUSPEND state * for atleast 2ms. */#define USB_OHCI_MINIMUM_DURATION_IN_SUSPEND_STATE           	2/*  * To hold the configuration values for the default control endpoint (BEGIN) * * This endpoint will be used to configure all the newly attached devices. *//* To hold the default device address */#define USB_DEFAULT_DEVICE_ADDRESS                  0/* To hold the default device speed */#define USB_DEFAULT_DEVICE_SPEED                    USB_OHCI_DEVICE_FULL_SPEED/* To hold the default device maximum packet size */#define USB_DEFAULT_DEVICE_MAXIMUM_PACKET_SIZE      0x40/* Globals Added for Non PCI support */extern pUSB_HCD_BUS_INFO	pOhciBusInfo[];extern UINT32	maxOhciCount;/* To hold the configuration values for the default control endpoint (END) *//* typedefs *//****************** MODULE SPECIFIC DATA STRUCTURE DECLARATION ****************//******************* MODULE SPECIFIC VARIABLES DEFINITION *********************//* To hold the OHCI Controller information */LOCAL 	USB_OHCI_INFORMATION * usbOhciControllerInfo = NULL;/* Flag to indicate that the OHCI Controllers are initialized */LOCAL 	BOOLEAN bInitialized = FALSE;/*  * To hold the handle to the host controller driver. This handle will be  * returned by USBD in response to the USBHST_RegisterHCD() function call. * This handle should be used to deregister the host controller driver, i.e. * the handle will be passed as a parameter to USBHST_DeregisterHCD()  * function. */	LOCAL 	UINT32 hHostControllerDriver = 0;extern UINT32	maxOhciCount; /* maximum number of OHCI controllers *//**************************** SUB MODULE INCLUDES *****************************//*  * Root hub emulation module  * * Since the transfer management module uses the function root hub emulation * module, include the root hub emulation module before the transfer  * management module. */#include "usbOhciRootHubEmulation.c"/*  * Transfer Management module * * Since the ISR uses the functions in transfer management module, include * the transfer management module before the ISR module.  */#include "usbOhciTransferManagement.c"/* ISR module */#include "usbOhciIsr.c"#ifdef OHCI_MODULE_TESTING#include "usbOhciDebug.c"#endif/* forward declarations *//****************** MODULE SPECIFIC FUNCTIONS DECLARATION *********************//* Function to initailize the OHCI Host Controller */LOCAL   BOOLEAN		usbOhciInitializeHostController(UINT8 uHostControllerIndex);VOID usbOhciPowerOffPorts	(	UINT32   uHostControllerIndex	);LOCAL VOID usbOhciDisable    (    int    startType    );/* functions *//************************ GLOBAL FUNCTIONS DEFINITION *************************//***************************************************************************** usbOhciInit - initialise the USB OHCI Host Controller Driver.** This function initialises the OHCI Host Controller Driver. It detects the* number of USB OHCI Controllers present on the system and initializes all the* OHCI controllers.** PARAMETERS: N/A** RETURNS: TRUE if the OHCI Host Controllers are initialized, otherwise FALSE** ERRNO:*   None.*/BOOLEAN usbOhciInit (void)    {    /* To hold the status of initializing the OHCI host controller */    BOOLEAN bStatus = TRUE;    /* To hold the loop index */    UINT32  uIndex = 0;    /*     * To hold the OHCI Host Controller Driver functions to be registered     * with USBD.     */    USBHST_HC_DRIVER    hostControllerDriverEntry;    /* To hold the status of deregistering the OHCI host controller driver */    USBHST_STATUS   uUsbStatus = USBHST_SUCCESS;    /* Debug print */    OS_LOG_MESSAGE_LOW(        OHCD,        "Entering the  function: usbOhciInit().\n",         0,         0,         0,         0);    /*     * This function should be called only once. When the function is called,     * if any OHCI Host Controllers are detected, the OHCI controllers will     * be initialized and the OHCI Controller information pointer will be     * updated.     *     * Check whether the OHCI Controller information pointer is valid. If     * this pointer is valid, then the function is called for the second time.     * Hence, return without processing the request.     */    if (bInitialized)    	{		/* WindView Instrumentation */		USB_HCD_LOG_EVENT(			USB_OHCI_WV_INIT_EXIT,			"usbOhciInit() exits : Error - already called once",			USB_OHCD_WV_FILTER);        return FALSE;    	}    if (maxOhciCount == 0)        {	/* WindView Instrumentation */	USB_HCD_LOG_EVENT(			USB_OHCI_WV_INIT_EXIT,			"usbOhciInit() exits : No OHCI Controller present",			USB_OHCD_WV_FILTER);        return FALSE;        }    /* Clear the OHCI host controller driver entry functions information */    OS_MEMSET(&hostControllerDriverEntry, 0, sizeof(USBHST_HC_DRIVER));    /* Initialize the OHCI host controller driver entry points (BEGIN) */    /* Function to create the pipes for the endpoint */    hostControllerDriverEntry.createPipe = usbOhciCreatePipe;    /* Function to delete a pipe corresponding to an endpoint */    hostControllerDriverEntry.deletePipe = usbOhciDeletePipe;    /* This function is used to submit a request to the device */    hostControllerDriverEntry.submitURB = usbOhciSubmitUrb;    /* This function is used to cancel a request submitted to the device */    hostControllerDriverEntry.cancelURB = usbOhciCancelUrb;    /*      * Function to determine whether the bandwidth is available to support the      * new configuration or an alternate interface.     */    hostControllerDriverEntry.isBandwidthAvailable =         usbOhciIsBandwidthAvailable;    /*      * Function to modify the properties of the default control pipe, i.e. the      * pipe corresponding to Address 0, Endpoint 0.     */    hostControllerDriverEntry.modifyDefaultPipe = usbOhciModifyDefaultPipe;    /* Function to check whether any request is pending on a pipe */    hostControllerDriverEntry.isRequestPending = usbOhciIsRequestPending;    /* Function to obtain the current frame number */    hostControllerDriverEntry.getFrameNumber = usbOhciGetFrameNumber;    /* Function to modify the frame width */    hostControllerDriverEntry.setBitRate = usbOhciSetBitRate;    /* Initialize the OHCI host controller driver entry points (END) */    /* Register the OHCI host controller driver with USBD */    uUsbStatus = usbHstHCDRegister (&hostControllerDriverEntry,                                     &hHostControllerDriver,                                     NULL);    /*      * Check whether the OHCI host controller driver was registered      * successfully      */    if (uUsbStatus != USBHST_SUCCESS)    	{        /* Failed to register the OHCI host controller driver */        OS_LOG_MESSAGE_HIGH (			OHCD,			"Failed to register OHCI host controller driver.\n",			0,			0,			0,			0);        /*          * Call the function to clean up the resources allocated for          * the host controller.         */        usbOhciExit ();		/* WindView Instrumentation */		USB_HCD_LOG_EVENT(			USB_OHCI_WV_INIT_EXIT, 			"usbOhciInit() exits - OHCD registration failed",			USB_OHCD_WV_FILTER);        /* Return without proceeding */        return FALSE;    	}    /* Allocate the memory for  OHCI host controller */    usbOhciControllerInfo = (USB_OHCI_INFORMATION *)OS_MALLOC                            (sizeof(USB_OHCI_INFORMATION) * maxOhciCount);    if (usbOhciControllerInfo == NULL)        {        /*         * Call the function to clean up the resources allocated for         * the host controller.         */        usbOhciExit();		/* WindView Instrumentation */		USB_HCD_LOG_EVENT(			USB_OHCI_WV_INIT_EXIT, 			"usbOhciInit() exits : Error - no OHCI Controller",			USB_OHCD_WV_FILTER);        /* No OHCI Controllers were found on the system */        return FALSE;        }    /* Clear the OHCI Host Controller information */    OS_MEMSET (usbOhciControllerInfo,                0,               sizeof (USB_OHCI_INFORMATION) * maxOhciCount);     /* Hook the function that should be called on reboot */     if(ERROR == rebootHookAdd((FUNCPTR)usbOhciDisable))         {         return FALSE;         }    /*     * Initialize the OHCI Controller information corresponding to the OHCI     * Controllers found on the system. The following operations are     * performed:     *     * a) Initialize the PCI IRQ Number     * b) Initialize the Base Address of USB Registers

⌨️ 快捷键说明

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