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

📄 usbtcdnet2280initexit.c

📁 This the compressed USB driver source code for vxworks5.6. It has device controller driver and other
💻 C
📖 第 1 页 / 共 2 页
字号:
/* usbTcdNET2280InitExit.c - initialization/uninitialization for NET2280 TCD *//* Copyright 2004 Wind River Systems, Inc. *//*Modification history--------------------01h,19oct04,ami  #if 0 removed in usbTcdNet2280FncAttach function01g,30sep04,pdg  Removed usbTcdNET2280Util.c01f,29sep04,pdg  Include filename changed01e,29sep04,ami  Changes for Mips01d,20sep04,ami  NET2280 tested in High Speed01c,17sep04,ami  After Control, Interrupt IN and Bulk OUT Testing01b,08sep04,ami  Code Review Comments Incorporated01a,04sep04,ami  First.*//*DESCRIPTIONThis file implements the initialization and uninitialization modules of TCD(Target Controller Driver) for the Netchip NET2280.This module exports a single entry point, usbTcdNET2280Exec().  This isthe USB_TCD_EXEC_FUNC for this TCD.  The caller passes requests to the TCD byconstructing TRBs, or Target Request Blocks, and passing them to this entrypoint.TCDs are initialized by invoking the TCD_FNC_ATTACH function.  In response tothis function, the TCD returns information about the target controller,including its USB speed, the number of endpoints it supports etc.INCLUDE FILES: usb/usbPlatform.h, usb/ossLib.h, usb/usbPciLib.h,               usb/target/usbHalCommon.h, usb/target/usbTcd.h               drv/usb/target/usbNET2280.h,               drv/usb/target/usbNET2280Tcd.h,               drv/usb/target/usbTcdNET2280Lib.h,               drv/usb/target/usbTcdNET2280Debug.h, rebootLib.h,               usb/target/usbPeriphInstr.h*//* includes */#include "usb/usbPlatform.h"#include "usb/ossLib.h"#include "usb/usbPciLib.h"#include "usb/target/usbHalCommon.h"#include "usb/target/usbTcd.h"#include "drv/usb/target/usbNET2280.h"#include "drv/usb/target/usbNET2280Tcd.h"#include "drv/usb/target/usbTcdNET2280Lib.h"#include "drv/usb/target/usbTcdNET2280Debug.h"#include "usb/target/usbPeriphInstr.h"#include "rebootLib.h"#include "usbTcdNET2280DeviceControl.c"#include "usbTcdNET2280Endpoint.c"#include "usbTcdNET2280Interrupt.c"/* defines */#define MAX_NET2280_CONTROLLERS 5/* globals */UINT32 usbNET2280Debug = 0;UINT32 baseNET2280Addr[MAX_NET2280_CONTROLLERS] = {0,0,0,0,0};   /******************************************************************************** usbNET2280Exit - function to be called on a reboot** This function clears the USBCTL register bit on a reboot.** RETURNS: None.** ERRNO:*   None.** \NOMANUAL*/LOCAL VOID usbNET2280Exit    (    int	startType    )    {        UINT8	i = 0;    for (i = 0; i < MAX_NET2280_CONTROLLERS; i++)        {                 /* for all NET2280 controllers, reset the USB_CTL register */         if (baseNET2280Addr [i] != 0)              *(volatile UINT32 *)(baseNET2280Addr [i] + NET2280_USBCTL_REG) = 0;         }    } /******************************************************************************** usbTcdNET2280FncAttach - function implementing function code TCD_FNC_ATTACH** The purpose of this function is to initialize the Target Controller* for USB operation.** RETURNS: OK or ERROR if failed to initialize the Target Controller.** ERRNO:* \is* \i S_usbTcdLib_BAD_PARAM* Bad parameter is passed.** \i S_usbTcdLib_OUT_OF_MEMORY* No more memory to allocate variables.** \i S_usbTcdLib_HW_NOT_READY* Hardware is not ready.** \i  S_usbTcdLib_GENERAL_FAULT* Fault occured in upper software layers.* \ie** \NOMANUAL*/LOCAL STATUS usbTcdNET2280FncAttach    (    pTRB_ATTACH		pTrb		/* TRB to be executed */    )    {    pTRB_HEADER pHeader = (pTRB_HEADER) pTrb;	/* TRB_HEADER */    pUSB_TCD_NET2280_TARGET	pTarget = NULL;	/* USB_TCD_NET2280_TARGET */    pUSB_TCD_NET2280_PARAMS	pParams = NULL;	/* USB_TCD_NET2280_PARAMS */    UINT32	data32 = 0;			/* temporary variable */    UINT8	i = 0 ;    /* WindView Instrumentation */    USB_TCD_LOG_EVENT(USB_TCD_NET2280_INIT_EXIT,    "usbTcdNET2280FncAttach entered...", USB_TCD_NET2280_WV_FILTER);    USB_NET2280_DEBUG ("usbTcdNET2280FncAttach : Entered...\n",0,0,0,0,0,0);    /* Validate Parameters */    if (pHeader == NULL || pHeader->trbLength < sizeof (TRB_HEADER))        {        /* WindView Instrumentation */        USB_TCD_LOG_EVENT (USB_TCD_NET2280_INIT_EXIT,        "usbTcdNET2280FncAttach exiting: Bad Parameter Received...",        USB_TCD_NET2280_WV_FILTER);        USB_NET2280_ERROR ("usbTcdNET2280FncAttach : Bad Parameters...\n",        0,0,0,0,0,0);        return ossStatus (S_usbTcdLib_BAD_PARAM);        }    if ( (pTrb->tcdParam == NULL ) || (pTrb->usbHalIsr == NULL ) ||         (pTrb->pHalDeviceInfo == NULL) || (pTrb->pDeviceInfo == NULL)  )        {        /* WindView Instrumentation */        USB_TCD_LOG_EVENT (USB_TCD_NET2280_INIT_EXIT,        "usbTcdNET2280FncAttach exiting: Bad Parameter Received...",        USB_TCD_NET2280_WV_FILTER);        USB_NET2280_ERROR ("usbTcdNET2280FncAttach : Bad Parameters...\n",        0,0,0,0,0,0);        return ossStatus (S_usbTcdLib_BAD_PARAM);        }    pParams = (pUSB_TCD_NET2280_PARAMS)pTrb->tcdParam;    /*     * Check if the base address[0] is valid.If not, the device is not located,     * return an error in this case     */    if (pParams->ioBase[0] == 0)        {        /* WindView Instrumentation */        USB_TCD_LOG_EVENT(USB_TCD_NET2280_INIT_EXIT,        "usbTcdNET2280FncAttach exiting: Device not located...",        USB_TCD_NET2280_WV_FILTER);                USB_NET2280_ERROR ("usbTcdNET2280FncAttach : Device not located... \n",        0,0,0,0,0,0);        return ossStatus (S_usbTcdLib_HW_NOT_READY);        }    /* Create a pUSB_TCD_NET2280_TARGET structure to manage controller. */    if ((pTarget = OSS_CALLOC (sizeof (*pTarget))) == NULL )        {        /* WindView Instrumentation */        USB_TCD_LOG_EVENT(USB_TCD_NET2280_INIT_EXIT,        "usbTcdNET2280FncAttach exiting: Memory Allocation Error...",        USB_TCD_NET2280_WV_FILTER);        USB_NET2280_ERROR ("usbTcdNET2280FncAttach : Memory Allocation Error \        ...\n",0,0,0,0,0,0);        return ossStatus (S_usbTcdLib_OUT_OF_MEMORY);        }    /* Store the user supplied parameters */    for (i = 0 ; i < NET2280_NO_OF_PCI_BADDR ; i++)        pTarget->ioBase [i] = pParams->ioBase [i];    pTarget->irq = pParams->irq;    /*      * Store the base addresses in a vacant slot in the the global variable.     * It is used to reset the USB_CTL register during warm reboot.     */    for (i = 0; i < MAX_NET2280_CONTROLLERS; i++)        {        if (baseNET2280Addr [i] == 0)                        baseNET2280Addr [i] = pTarget->ioBase [0];        }               /* Hook the function which needs to be called on a reboot */     if(ERROR == rebootHookAdd((FUNCPTR)usbNET2280Exit))	{        /* WindView Instrumentation */         USB_TCD_LOG_EVENT(USB_TCD_NET2280_INIT_EXIT,        "usbTcdNET2280FncAttach exiting: Enable to hook function for reboot...",        USB_TCD_NET2280_WV_FILTER);           USB_NET2280_ERROR ( " usbTcdNET2280FncAttach: Not able \        to hook a function on reboot ", 0,0,0,0,0,0);        OSS_FREE (pTarget);		return ERROR;        }    /* Initialize the DEVINIT regsiter. */        data32 = NET2280_DEVINIT_CLK_FREQ;    data32 |= NET2280_DEVINIT_PCIEN | NET2280_DEVINIT_8051_RESET;    NET2280_CFG_WRITE (pTarget, NET2280_DEVINIT_REG, data32);    /* Reset the FIFO */    data32 = NET2280_CFG_READ (pTarget, NET2280_DEVINIT_REG);    data32 |= NET2280_DEVINIT_FIFO_RESET | NET2280_DEVINIT_USB_RESET;       NET2280_CFG_WRITE (pTarget, NET2280_DEVINIT_REG, data32);    /* Disable auto-enumeration by setting all bits of STDRSP register to 0 */    NET2280_CFG_WRITE (pTarget, NET2280_STDRSP_REG, 0);    /* clear the interrupt status register */    NET2280_CFG_WRITE (pTarget, NET2280_IRQSTAT0_REG, NET2280_IRQENB0_SETUP);    NET2280_CFG_WRITE (pTarget, NET2280_IRQSTAT1_REG, NET2280_IRQENB1_REG_MASK);     /*     * Enable the interrupts for resume, suspend, root port reset, VBUS status     * change, power state status change, parity error interrupt & PCI     * Interrupt Enable     */    /* Suspend Interrupt needs to be handled */    data32 = NET2280_IRQENB1_RESM |              NET2280_IRQENB1_RPRESET | NET2280_IRQENB1_VBUS |             NET2280_IRQENB1_PSCINTEN | NET2280_IRQENB1_PCIPARITYERR |             NET2280_IRQENB1_INTEN;    NET2280_CFG_WRITE (pTarget, NET2280_PCIIRQENB1_REG, data32);     /*     * Set the Bit USB Root Port Wakeup Eanble of USBCTL register to enable the     * root part wake up condition to be detected      */    data32 = NET2280_USBCTL_REG_RPWE;    NET2280_CFG_WRITE (pTarget, NET2280_USBCTL_REG, data32);    /* Store HAL parameters */    pTarget->usbHalIsr = pTrb->usbHalIsr;    pTarget->usbHalIsrParam = pTrb->usbHalIsrParam;    /* Return target information to caller */    pTrb->pHalDeviceInfo->uNumberEndpoints = NET2280_NUM_ENDPOINTS;    /* supports remote wake up, test mode feature and is USB2 compliant */    pTrb->pDeviceInfo->uDeviceFeature = USB_FEATURE_DEVICE_REMOTE_WAKEUP |                                        USB_FEATURE_TEST_MODE |                                        USB_FEATURE_USB20;    /* Reset the dmaEot */    pTarget->dmaEot = 0;    /* supported endpoint bitmap */    pTrb->pDeviceInfo->uEndpointNumberBitmap = USB_NET2280_TCD_ENDPOINT_BITMAP;    /* Hook the ISR */    if (usbPciIntConnect ((INT_HANDLER_PROTOTYPE)usbTcdNET2280Isr,        (pVOID)pTarget, pTarget->irq)!= OK)        {        OSS_FREE (pTarget);        USB_NET2280_ERROR ("usbTcdNET2280FncAttach :Error Hooking the ISR...\n",        0,0,0,0,0,0);        return ERROR;        }    /* update handle */    pHeader->handle = pTarget;    USB_NET2280_DEBUG ("usbTcdNET2280FncAttach : Exiting...\n",0,0,0,0,0,0);    return OK;    }/******************************************************************************** usbTcdNET2280FncDetach - implements TCD_FNC_DETACH** The purpose of this function is to shutdown the Target Controller** RETURNS: OK or ERROR, if TCD is not able to detach.** ERRNO:* \is* \i S_usbTcdLib_BAD_PARAM* Bad parameter is passed.* \ie** \NOMANUAL*/LOCAL STATUS usbTcdNET2280FncDetach    (    pTRB_DETACH		pTrb		/* TRB to be executed */    )    {    pTRB_HEADER	pHeader = (pTRB_HEADER) pTrb;	/* TRB_HEADER */    pUSB_TCD_NET2280_TARGET	pTarget = NULL;	/* pUSB_TCD_NET2280_TARGET */    UINT32	data32 = 0;    /* WindView Instrumentation */    USB_TCD_LOG_EVENT(USB_TCD_NET2280_INIT_EXIT,   "usbTcdNET2280FncDetach entered...", USB_TCD_NET2280_WV_FILTER);    USB_NET2280_DEBUG ("usbTcdNET2280FncDetach : Entered...\n",0,0,0,0,0,0);    /* Validate parameters */    if (pHeader == NULL || pHeader->trbLength < sizeof (TRB_HEADER) ||        (pHeader->handle == NULL))        {

⌨️ 快捷键说明

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