musb_host.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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. #include <linux/scatterlist.h>
  12. /* stored in "usb_host_endpoint.hcpriv" for scheduled endpoints */
  13. struct musb_qh {
  14. struct usb_host_endpoint *hep; /* usbcore info */
  15. struct usb_device *dev;
  16. struct musb_hw_ep *hw_ep; /* current binding */
  17. struct list_head ring; /* of musb_qh */
  18. /* struct musb_qh *next; */ /* for periodic tree */
  19. u8 mux; /* qh multiplexed to hw_ep */
  20. unsigned offset; /* in urb->transfer_buffer */
  21. unsigned segsize; /* current xfer fragment */
  22. u8 type_reg; /* {rx,tx} type register */
  23. u8 intv_reg; /* {rx,tx} interval register */
  24. u8 addr_reg; /* device address register */
  25. u8 h_addr_reg; /* hub address register */
  26. u8 h_port_reg; /* hub port register */
  27. u8 is_ready; /* safe to modify hw_ep */
  28. u8 type; /* XFERTYPE_* */
  29. u8 epnum;
  30. u8 hb_mult; /* high bandwidth pkts per uf */
  31. u16 maxpacket;
  32. u16 frame; /* for periodic schedule */
  33. unsigned iso_idx; /* in urb->iso_frame_desc[] */
  34. struct sg_mapping_iter sg_miter; /* for highmem in PIO mode */
  35. bool use_sg; /* to track urb using sglist */
  36. };
  37. /* map from control or bulk queue head to the first qh on that ring */
  38. static inline struct musb_qh *first_qh(struct list_head *q)
  39. {
  40. if (list_empty(q))
  41. return NULL;
  42. return list_entry(q->next, struct musb_qh, ring);
  43. }
  44. #if IS_ENABLED(CONFIG_USB_MUSB_HOST) || IS_ENABLED(CONFIG_USB_MUSB_DUAL_ROLE)
  45. extern struct musb *hcd_to_musb(struct usb_hcd *);
  46. extern irqreturn_t musb_h_ep0_irq(struct musb *);
  47. extern int musb_host_alloc(struct musb *);
  48. extern int musb_host_setup(struct musb *, int);
  49. extern void musb_host_cleanup(struct musb *);
  50. extern void musb_host_tx(struct musb *, u8);
  51. extern void musb_host_rx(struct musb *, u8);
  52. extern void musb_root_disconnect(struct musb *musb);
  53. extern void musb_host_free(struct musb *);
  54. extern void musb_host_cleanup(struct musb *);
  55. extern void musb_host_tx(struct musb *, u8);
  56. extern void musb_host_rx(struct musb *, u8);
  57. extern void musb_root_disconnect(struct musb *musb);
  58. extern void musb_host_resume_root_hub(struct musb *musb);
  59. extern void musb_host_poke_root_hub(struct musb *musb);
  60. extern int musb_port_suspend(struct musb *musb, bool do_suspend);
  61. extern void musb_port_reset(struct musb *musb, bool do_reset);
  62. extern void musb_host_finish_resume(struct work_struct *work);
  63. #else
  64. static inline struct musb *hcd_to_musb(struct usb_hcd *hcd)
  65. {
  66. return NULL;
  67. }
  68. static inline irqreturn_t musb_h_ep0_irq(struct musb *musb)
  69. {
  70. return 0;
  71. }
  72. static inline int musb_host_alloc(struct musb *musb)
  73. {
  74. return 0;
  75. }
  76. static inline int musb_host_setup(struct musb *musb, int power_budget)
  77. {
  78. return 0;
  79. }
  80. static inline void musb_host_cleanup(struct musb *musb) {}
  81. static inline void musb_host_free(struct musb *musb) {}
  82. static inline void musb_host_tx(struct musb *musb, u8 epnum) {}
  83. static inline void musb_host_rx(struct musb *musb, u8 epnum) {}
  84. static inline void musb_root_disconnect(struct musb *musb) {}
  85. static inline void musb_host_resume_root_hub(struct musb *musb) {}
  86. static inline void musb_host_poll_rh_status(struct musb *musb) {}
  87. static inline void musb_host_poke_root_hub(struct musb *musb) {}
  88. static inline int musb_port_suspend(struct musb *musb, bool do_suspend)
  89. {
  90. return 0;
  91. }
  92. static inline void musb_port_reset(struct musb *musb, bool do_reset) {}
  93. static inline void musb_host_finish_resume(struct work_struct *work) {}
  94. #endif
  95. struct usb_hcd;
  96. extern int musb_hub_status_data(struct usb_hcd *hcd, char *buf);
  97. extern int musb_hub_control(struct usb_hcd *hcd,
  98. u16 typeReq, u16 wValue, u16 wIndex,
  99. char *buf, u16 wLength);
  100. static inline struct urb *next_urb(struct musb_qh *qh)
  101. {
  102. struct list_head *queue;
  103. if (!qh)
  104. return NULL;
  105. queue = &qh->hep->urb_list;
  106. if (list_empty(queue))
  107. return NULL;
  108. return list_entry(queue->next, struct urb, urb_list);
  109. }
  110. #endif /* _MUSB_HOST_H */