musbfsh_host.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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. * Copyright 2015 Mediatek Inc.
  9. * Marvin Lin <marvin.lin@mediatek.com>
  10. * Arvin Wang <arvin.wang@mediatek.com>
  11. * Vincent Fan <vincent.fan@mediatek.com>
  12. * Bryant Lu <bryant.lu@mediatek.com>
  13. * Yu-Chang Wang <yu-chang.wang@mediatek.com>
  14. * Macpaul Lin <macpaul.lin@mediatek.com>
  15. *
  16. * This program is free software; you can redistribute it and/or
  17. * modify it under the terms of the GNU General Public License
  18. * version 2 as published by the Free Software Foundation.
  19. *
  20. * This program is distributed in the hope that it will be useful, but
  21. * WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  23. * General Public License for more details.
  24. *
  25. * You should have received a copy of the GNU General Public License
  26. * along with this program.
  27. *
  28. * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
  29. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  30. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
  31. * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  32. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  33. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  34. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  35. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  36. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  37. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  38. *
  39. */
  40. #ifndef _MUSBFSH_HOST_H
  41. #define _MUSBFSH_HOST_H
  42. #include <linux/scatterlist.h>
  43. static inline struct usb_hcd *musbfsh_to_hcd(struct musbfsh *musb)
  44. {
  45. return container_of((void *)musb, struct usb_hcd, hcd_priv);
  46. }
  47. static inline struct musbfsh *hcd_to_musbfsh(struct usb_hcd *hcd)
  48. {
  49. return (struct musbfsh *)(hcd->hcd_priv);
  50. }
  51. /* stored in "usb_host_endpoint.hcpriv" for scheduled endpoints */
  52. struct musbfsh_qh {
  53. struct usb_host_endpoint *hep; /* usbcore info */
  54. struct usb_device *dev;
  55. struct musbfsh_hw_ep *hw_ep; /* current binding */
  56. struct list_head ring; /* of musbfsh_qh */
  57. /* struct musbfsh_qh *next; *//* for periodic tree */
  58. u8 mux; /* qh multiplexed to hw_ep */
  59. unsigned offset; /* in urb->transfer_buffer */
  60. unsigned segsize; /* current xfer fragment */
  61. u8 type_reg; /* {rx,tx} type register */
  62. u8 intv_reg; /* {rx,tx} interval register */
  63. u8 addr_reg; /* device address register */
  64. u8 h_addr_reg; /* hub address register */
  65. u8 h_port_reg; /* hub port register */
  66. u8 is_ready; /* safe to modify hw_ep */
  67. u8 type; /* XFERTYPE_* */
  68. u8 epnum;
  69. u8 hb_mult; /* high bandwidth pkts per uf */
  70. u16 maxpacket;
  71. u16 frame; /* for periodic schedule */
  72. unsigned iso_idx; /* in urb->iso_frame_desc[] */
  73. struct sg_mapping_iter sg_miter; /* for highmem in PIO mode */
  74. };
  75. /* map from control or bulk queue head to the first qh on that ring */
  76. static inline struct musbfsh_qh *first_qh(struct list_head *q)
  77. {
  78. if (list_empty(q))
  79. return NULL;
  80. return list_entry(q->next, struct musbfsh_qh, ring);
  81. }
  82. extern void musbfsh_root_disconnect(struct musbfsh *musb);
  83. struct usb_hcd;
  84. extern int musbfsh_hub_status_data(struct usb_hcd *hcd, char *buf);
  85. extern int musbfsh_hub_control(struct usb_hcd *hcd,
  86. u16 typeReq, u16 wValue, u16 wIndex, char *buf,
  87. u16 wLength);
  88. extern struct hc_driver musbfsh_hc_driver;
  89. static inline struct urb *next_urb(struct musbfsh_qh *qh)
  90. {
  91. struct list_head *queue;
  92. if (!qh)
  93. return NULL;
  94. queue = &qh->hep->urb_list;
  95. if (list_empty(queue))
  96. return NULL;
  97. return list_entry(queue->next, struct urb, urb_list);
  98. }
  99. /* file include host.h for get icusb related struct */
  100. #ifdef CONFIG_MTK_ICUSB_SUPPORT
  101. #include "musbfsh_icusb.h"
  102. #endif
  103. #ifdef CONFIG_MTK_DT_USB_SUPPORT
  104. extern int musbfsh_connect_flag;
  105. /* This should be in platform musbfsh_mt65xx.h */
  106. #endif
  107. #ifdef MTK_USB_RUNTIME_SUPPORT
  108. #include <cust_eint.h>
  109. extern void mt_eint_unmask(unsigned int line);
  110. extern void mt_eint_mask(unsigned int line);
  111. extern void request_wakeup_md_timeout(unsigned int dev_id,
  112. unsigned int dev_sub_id);
  113. #endif
  114. #ifdef CONFIG_MTK_DT_USB_SUPPORT
  115. extern void request_wakeup_md_timeout(unsigned int dev_id,
  116. unsigned int dev_sub_id);
  117. extern int musbfsh_skip_port_suspend;
  118. extern int musbfsh_skip_port_resume;
  119. #endif
  120. #endif /* _MUSBFSH_HOST_H */