musb_host.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * MUSB OTG driver host defines
  3. *
  4. * Copyright 2005 Mentor Graphics Corporation
  5. * Copyright (C) 2005-2006 by Texas Instruments
  6. * Copyright (C) 2006-2007 Nokia Corporation
  7. *
  8. * SPDX-License-Identifier: GPL-2.0
  9. */
  10. #ifndef _MUSB_HOST_H
  11. #define _MUSB_HOST_H
  12. #ifdef __UBOOT__
  13. #include "usb-compat.h"
  14. #endif
  15. static inline struct usb_hcd *musb_to_hcd(struct musb *musb)
  16. {
  17. return container_of((void *) musb, struct usb_hcd, hcd_priv);
  18. }
  19. static inline struct musb *hcd_to_musb(struct usb_hcd *hcd)
  20. {
  21. return (struct musb *) (hcd->hcd_priv);
  22. }
  23. /* stored in "usb_host_endpoint.hcpriv" for scheduled endpoints */
  24. struct musb_qh {
  25. struct usb_host_endpoint *hep; /* usbcore info */
  26. struct usb_device *dev;
  27. struct musb_hw_ep *hw_ep; /* current binding */
  28. struct list_head ring; /* of musb_qh */
  29. /* struct musb_qh *next; */ /* for periodic tree */
  30. u8 mux; /* qh multiplexed to hw_ep */
  31. unsigned offset; /* in urb->transfer_buffer */
  32. unsigned segsize; /* current xfer fragment */
  33. u8 type_reg; /* {rx,tx} type register */
  34. u8 intv_reg; /* {rx,tx} interval register */
  35. u8 addr_reg; /* device address register */
  36. u8 h_addr_reg; /* hub address register */
  37. u8 h_port_reg; /* hub port register */
  38. u8 is_ready; /* safe to modify hw_ep */
  39. u8 type; /* XFERTYPE_* */
  40. u8 epnum;
  41. u8 hb_mult; /* high bandwidth pkts per uf */
  42. u16 maxpacket;
  43. u16 frame; /* for periodic schedule */
  44. unsigned iso_idx; /* in urb->iso_frame_desc[] */
  45. };
  46. /* map from control or bulk queue head to the first qh on that ring */
  47. static inline struct musb_qh *first_qh(struct list_head *q)
  48. {
  49. if (list_empty(q))
  50. return NULL;
  51. return list_entry(q->next, struct musb_qh, ring);
  52. }
  53. extern void musb_root_disconnect(struct musb *musb);
  54. struct usb_hcd;
  55. extern int musb_hub_status_data(struct usb_hcd *hcd, char *buf);
  56. extern int musb_hub_control(struct usb_hcd *hcd,
  57. u16 typeReq, u16 wValue, u16 wIndex,
  58. char *buf, u16 wLength);
  59. extern const struct hc_driver musb_hc_driver;
  60. static inline struct urb *next_urb(struct musb_qh *qh)
  61. {
  62. struct list_head *queue;
  63. if (!qh)
  64. return NULL;
  65. queue = &qh->hep->urb_list;
  66. if (list_empty(queue))
  67. return NULL;
  68. return list_entry(queue->next, struct urb, urb_list);
  69. }
  70. #ifdef __UBOOT__
  71. int musb_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flags);
  72. int musb_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status);
  73. #endif
  74. #endif /* _MUSB_HOST_H */