usb-compat.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #ifndef __USB_COMPAT_H__
  2. #define __USB_COMPAT_H__
  3. #include "usb.h"
  4. struct udevice;
  5. struct usb_hcd {
  6. void *hcd_priv;
  7. };
  8. struct usb_host_endpoint {
  9. struct usb_endpoint_descriptor desc;
  10. struct list_head urb_list;
  11. void *hcpriv;
  12. };
  13. /*
  14. * urb->transfer_flags:
  15. *
  16. * Note: URB_DIR_IN/OUT is automatically set in usb_submit_urb().
  17. */
  18. #define URB_SHORT_NOT_OK 0x0001 /* report short reads as errors */
  19. #define URB_ZERO_PACKET 0x0040 /* Finish bulk OUT with short packet */
  20. struct urb;
  21. typedef void (*usb_complete_t)(struct urb *);
  22. struct urb {
  23. void *hcpriv; /* private data for host controller */
  24. struct list_head urb_list; /* list head for use by the urb's
  25. * current owner */
  26. struct usb_device *dev; /* (in) pointer to associated device */
  27. struct usb_host_endpoint *ep; /* (internal) pointer to endpoint */
  28. unsigned int pipe; /* (in) pipe information */
  29. int status; /* (return) non-ISO status */
  30. unsigned int transfer_flags; /* (in) URB_SHORT_NOT_OK | ...*/
  31. void *transfer_buffer; /* (in) associated data buffer */
  32. dma_addr_t transfer_dma; /* (in) dma addr for transfer_buffer */
  33. u32 transfer_buffer_length; /* (in) data buffer length */
  34. u32 actual_length; /* (return) actual transfer length */
  35. unsigned char *setup_packet; /* (in) setup packet (control only) */
  36. int start_frame; /* (modify) start frame (ISO) */
  37. usb_complete_t complete; /* (in) completion routine */
  38. };
  39. #define usb_hcd_link_urb_to_ep(hcd, urb) ({ \
  40. int ret = 0; \
  41. list_add_tail(&urb->urb_list, &urb->ep->urb_list); \
  42. ret; })
  43. #define usb_hcd_unlink_urb_from_ep(hcd, urb) list_del_init(&urb->urb_list)
  44. #define usb_hcd_check_unlink_urb(hdc, urb, status) 0
  45. static inline void usb_hcd_giveback_urb(struct usb_hcd *hcd,
  46. struct urb *urb,
  47. int status)
  48. {
  49. urb->status = status;
  50. if (urb->complete)
  51. urb->complete(urb);
  52. }
  53. static inline int usb_hcd_unmap_urb_for_dma(struct usb_hcd *hcd,
  54. struct urb *urb)
  55. {
  56. /* TODO: add cache invalidation here */
  57. return 0;
  58. }
  59. /**
  60. * usb_dev_get_parent() - Get the parent of a USB device
  61. *
  62. * @udev: USB struct containing information about the device
  63. * @return associated device for which udev == dev_get_parent_priv(dev)
  64. */
  65. struct usb_device *usb_dev_get_parent(struct usb_device *udev);
  66. #endif /* __USB_COMPAT_H__ */