musb_host.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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_resume_root_hub(struct musb *musb);
  55. extern void musb_host_poke_root_hub(struct musb *musb);
  56. extern int musb_port_suspend(struct musb *musb, bool do_suspend);
  57. extern void musb_port_reset(struct musb *musb, bool do_reset);
  58. extern void musb_host_finish_resume(struct work_struct *work);
  59. #else
  60. static inline struct musb *hcd_to_musb(struct usb_hcd *hcd)
  61. {
  62. return NULL;
  63. }
  64. static inline irqreturn_t musb_h_ep0_irq(struct musb *musb)
  65. {
  66. return 0;
  67. }
  68. static inline int musb_host_alloc(struct musb *musb)
  69. {
  70. return 0;
  71. }
  72. static inline int musb_host_setup(struct musb *musb, int power_budget)
  73. {
  74. return 0;
  75. }
  76. static inline void musb_host_cleanup(struct musb *musb) {}
  77. static inline void musb_host_free(struct musb *musb) {}
  78. static inline void musb_host_tx(struct musb *musb, u8 epnum) {}
  79. static inline void musb_host_rx(struct musb *musb, u8 epnum) {}
  80. static inline void musb_root_disconnect(struct musb *musb) {}
  81. static inline void musb_host_resume_root_hub(struct musb *musb) {}
  82. static inline void musb_host_poke_root_hub(struct musb *musb) {}
  83. static inline int musb_port_suspend(struct musb *musb, bool do_suspend)
  84. {
  85. return 0;
  86. }
  87. static inline void musb_port_reset(struct musb *musb, bool do_reset) {}
  88. static inline void musb_host_finish_resume(struct work_struct *work) {}
  89. #endif
  90. struct usb_hcd;
  91. extern int musb_hub_status_data(struct usb_hcd *hcd, char *buf);
  92. extern int musb_hub_control(struct usb_hcd *hcd,
  93. u16 typeReq, u16 wValue, u16 wIndex,
  94. char *buf, u16 wLength);
  95. static inline struct urb *next_urb(struct musb_qh *qh)
  96. {
  97. struct list_head *queue;
  98. if (!qh)
  99. return NULL;
  100. queue = &qh->hep->urb_list;
  101. if (list_empty(queue))
  102. return NULL;
  103. return list_entry(queue->next, struct urb, urb_list);
  104. }
  105. #endif /* _MUSB_HOST_H */