usrUsbHcdUhciInit.c
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:2k
源码类别:

VxWorks

开发平台:

C/C++

  1. /* usrUsbHcdUhciInit.c - Initialization of a UHCI Host Controller Driver */
  2. /* Copyright 1999-2000 Wind River Systems, Inc. */
  3. /*
  4. Modification history
  5. --------------------
  6. 01a,23aug00,wef  Created
  7. */
  8. /*
  9. DESCRIPTION
  10. This configlette initializes a USB Host Controller if present on a system.
  11. It receives a parameter which indicates whether an OHCI or a UHCI controller
  12. is to be intialized.  The initialization process includes bringing up the 
  13. chip and also "attaches" the chip to the previously initilazed USB stack. 
  14. The stack is initialized in usrUsbInit.c
  15. */
  16. /* includes */
  17. #include "usb/usbPciLib.h"
  18. #include "usb/usbdLib.h"
  19. #include "drv/usb/usbUhci.h"
  20. #include "drv/usb/usbHcdUhciLib.h"  
  21. LOCAL GENERIC_HANDLE uhciAttachToken = NULL;
  22. /* defines */
  23. /* locals */
  24. /*****************************************************************************
  25. *
  26. * usrUsbHcdUhciAttach - attaches a Host Controller to the USB Stack
  27. *
  28. * This functions searches the pci bus for either a OHCI or UHCI type
  29. * USB Host Controller.  If it finds one, it attaches it to the already
  30. * initialized USB Stack
  31. *
  32. * RETURNS: OK if sucessful or ERROR if failure
  33. */
  34. LOCAL STATUS usrUsbHcdUhciAttach ()
  35.     {
  36.     UINT16 ret;
  37.     UINT8 busNo;
  38.     UINT8 deviceNo;
  39.     UINT8 funcNo;
  40.     PCI_CFG_HEADER pciCfgHdr;
  41.     UINT8 pciClass    = UHCI_CLASS;
  42.     UINT8 pciSubclass = UHCI_SUBCLASS;
  43.     UINT8 pciPgmIf    = UHCI_PGMIF;
  44.     HCD_EXEC_FUNC execFunc = &usbHcdUhciExec; 
  45.     GENERIC_HANDLE *pToken = &uhciAttachToken;
  46.     
  47.     if (*pToken == NULL)
  48.         {
  49.         if (!usbPciClassFind (pciClass, pciSubclass, pciPgmIf, 0, 
  50.     &busNo, &deviceNo, &funcNo))
  51.             {
  52.             printf ("No UHCI host controller found.n");
  53.             return ERROR;
  54.             }
  55.         printf ("UHCI Controller found.n"); 
  56. printf ("Waiting to attach...");
  57.         usbPciConfigHeaderGet (busNo, deviceNo, funcNo, &pciCfgHdr);
  58.         /* Attach the UHCI HCD to the USBD. */
  59.         ret = usbdHcdAttach (execFunc, &pciCfgHdr, pToken);
  60.         if (ret == OK)
  61.    {
  62.            printf ("Done, AttachToken = 0x%xn", (UINT) *pToken);
  63.    }
  64.         else
  65.            {
  66.            printf ("USB HCD Attached FAILED!n");
  67.            return ERROR;
  68.            }
  69.         }
  70.     else 
  71.         {
  72.         printf("UHCI Already Attachedn");
  73.         }
  74.     return OK; 
  75.     
  76.     }