musb_host.h 2.4 KB

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