musb_host.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * version 2 as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  20. * 02110-1301 USA
  21. *
  22. * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
  23. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  24. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
  25. * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  26. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  27. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  28. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  29. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  31. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. *
  33. */
  34. #ifndef _MUSB_HOST_H
  35. #define _MUSB_HOST_H
  36. #include <linux/scatterlist.h>
  37. #define musb_to_hcd(MUSB) ((MUSB)->hcd)
  38. extern struct musb *hcd_to_musb(struct usb_hcd *);
  39. /* stored in "usb_host_endpoint.hcpriv" for scheduled endpoints */
  40. struct musb_qh {
  41. struct usb_host_endpoint *hep; /* usbcore info */
  42. struct usb_device *dev;
  43. struct musb_hw_ep *hw_ep; /* current binding */
  44. struct list_head ring; /* of musb_qh */
  45. /* struct musb_qh *next; */ /* for periodic tree */
  46. u8 mux; /* qh multiplexed to hw_ep */
  47. unsigned offset; /* in urb->transfer_buffer */
  48. unsigned segsize; /* current xfer fragment */
  49. u8 type_reg; /* {rx,tx} type register */
  50. u8 intv_reg; /* {rx,tx} interval register */
  51. u8 addr_reg; /* device address register */
  52. u8 h_addr_reg; /* hub address register */
  53. u8 h_port_reg; /* hub port register */
  54. u8 is_ready; /* safe to modify hw_ep */
  55. u8 type; /* XFERTYPE_* */
  56. u8 epnum;
  57. u8 hb_mult; /* high bandwidth pkts per uf */
  58. u16 maxpacket;
  59. u16 frame; /* for periodic schedule */
  60. unsigned iso_idx; /* in urb->iso_frame_desc[] */
  61. struct sg_mapping_iter sg_miter; /* for highmem in PIO mode */
  62. };
  63. /* map from control or bulk queue head to the first qh on that ring */
  64. static inline struct musb_qh *first_qh(struct list_head *q)
  65. {
  66. if (list_empty(q))
  67. return NULL;
  68. return list_entry(q->next, struct musb_qh, ring);
  69. }
  70. extern irqreturn_t musb_h_ep0_irq(struct musb *);
  71. extern int musb_host_alloc(struct musb *);
  72. extern void musb_host_tx(struct musb *, u8);
  73. extern void musb_host_rx(struct musb *, u8);
  74. extern void musb_root_disconnect(struct musb *musb);
  75. extern void musb_host_free(struct musb *);
  76. extern void musb_host_cleanup(struct musb *);
  77. extern void musb_host_tx(struct musb *, u8);
  78. extern void musb_host_rx(struct musb *, u8);
  79. extern void musb_root_disconnect(struct musb *musb);
  80. extern void musb_host_resume_root_hub(struct musb *musb);
  81. extern void musb_host_poke_root_hub(struct musb *musb);
  82. struct usb_hcd;
  83. extern int musb_hub_status_data(struct usb_hcd *hcd, char *buf);
  84. extern int musb_hub_control(struct usb_hcd *hcd,
  85. u16 typeReq, u16 wValue, u16 wIndex,
  86. char *buf, u16 wLength);
  87. static inline struct urb *next_urb(struct musb_qh *qh)
  88. {
  89. struct list_head *queue;
  90. if (!qh)
  91. return NULL;
  92. queue = &qh->hep->urb_list;
  93. if (list_empty(queue))
  94. return NULL;
  95. return list_entry(queue->next, struct urb, urb_list);
  96. }
  97. #endif /* _MUSB_HOST_H */