usb_host.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * Copyright 2012 Tilera Corporation. All Rights Reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation, version 2.
  7. *
  8. * This program is distributed in the hope that it will be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  11. * NON INFRINGEMENT. See the GNU General Public License for
  12. * more details.
  13. */
  14. #ifndef _GXIO_USB_H_
  15. #define _GXIO_USB_H_
  16. #include <gxio/common.h>
  17. #include <hv/drv_usb_host_intf.h>
  18. #include <hv/iorpc.h>
  19. /*
  20. *
  21. * An API for manipulating general-purpose I/O pins.
  22. */
  23. /*
  24. *
  25. * The USB shim allows access to the processor's Universal Serial Bus
  26. * connections.
  27. */
  28. /* A context object used to manage USB hardware resources. */
  29. typedef struct {
  30. /* File descriptor for calling up to the hypervisor. */
  31. int fd;
  32. /* The VA at which our MMIO registers are mapped. */
  33. char *mmio_base;
  34. } gxio_usb_host_context_t;
  35. /* Initialize a USB context.
  36. *
  37. * A properly initialized context must be obtained before any of the other
  38. * gxio_usb_host routines may be used.
  39. *
  40. * @param context Pointer to a gxio_usb_host_context_t, which will be
  41. * initialized by this routine, if it succeeds.
  42. * @param usb_index Index of the USB shim to use.
  43. * @param is_ehci Nonzero to use the EHCI interface; zero to use the OHCI
  44. * intereface.
  45. * @return Zero if the context was successfully initialized, else a
  46. * GXIO_ERR_xxx error code.
  47. */
  48. extern int gxio_usb_host_init(gxio_usb_host_context_t *context, int usb_index,
  49. int is_ehci);
  50. /* Destroy a USB context.
  51. *
  52. * Once destroyed, a context may not be used with any gxio_usb_host routines
  53. * other than gxio_usb_host_init(). After this routine returns, no further
  54. * interrupts or signals requested on this context will be delivered. The
  55. * state and configuration of the pins which had been attached to this
  56. * context are unchanged by this operation.
  57. *
  58. * @param context Pointer to a gxio_usb_host_context_t.
  59. * @return Zero if the context was successfully destroyed, else a
  60. * GXIO_ERR_xxx error code.
  61. */
  62. extern int gxio_usb_host_destroy(gxio_usb_host_context_t *context);
  63. /* Retrieve the address of the shim's MMIO registers.
  64. *
  65. * @param context Pointer to a properly initialized gxio_usb_host_context_t.
  66. * @return The address of the shim's MMIO registers.
  67. */
  68. extern void *gxio_usb_host_get_reg_start(gxio_usb_host_context_t *context);
  69. /* Retrieve the length of the shim's MMIO registers.
  70. *
  71. * @param context Pointer to a properly initialized gxio_usb_host_context_t.
  72. * @return The length of the shim's MMIO registers.
  73. */
  74. extern size_t gxio_usb_host_get_reg_len(gxio_usb_host_context_t *context);
  75. #endif /* _GXIO_USB_H_ */