0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef _MUSB_HOST_H
0011 #define _MUSB_HOST_H
0012
0013 #include <linux/scatterlist.h>
0014
0015
0016 struct musb_qh {
0017 struct usb_host_endpoint *hep;
0018 struct usb_device *dev;
0019 struct musb_hw_ep *hw_ep;
0020
0021 struct list_head ring;
0022
0023 u8 mux;
0024
0025 unsigned offset;
0026 unsigned segsize;
0027
0028 u8 type_reg;
0029 u8 intv_reg;
0030 u8 addr_reg;
0031 u8 h_addr_reg;
0032 u8 h_port_reg;
0033
0034 u8 is_ready;
0035 u8 type;
0036 u8 epnum;
0037 u8 hb_mult;
0038 u16 maxpacket;
0039 u16 frame;
0040 unsigned iso_idx;
0041 struct sg_mapping_iter sg_miter;
0042 bool use_sg;
0043 };
0044
0045
0046 static inline struct musb_qh *first_qh(struct list_head *q)
0047 {
0048 if (list_empty(q))
0049 return NULL;
0050 return list_entry(q->next, struct musb_qh, ring);
0051 }
0052
0053
0054 #if IS_ENABLED(CONFIG_USB_MUSB_HOST) || IS_ENABLED(CONFIG_USB_MUSB_DUAL_ROLE)
0055 extern struct musb *hcd_to_musb(struct usb_hcd *);
0056 extern irqreturn_t musb_h_ep0_irq(struct musb *);
0057 extern int musb_host_alloc(struct musb *);
0058 extern int musb_host_setup(struct musb *, int);
0059 extern void musb_host_cleanup(struct musb *);
0060 extern void musb_host_tx(struct musb *, u8);
0061 extern void musb_host_rx(struct musb *, u8);
0062 extern void musb_root_disconnect(struct musb *musb);
0063 extern void musb_host_free(struct musb *);
0064 extern void musb_host_resume_root_hub(struct musb *musb);
0065 extern void musb_host_poke_root_hub(struct musb *musb);
0066 extern int musb_port_suspend(struct musb *musb, bool do_suspend);
0067 extern void musb_port_reset(struct musb *musb, bool do_reset);
0068 extern void musb_host_finish_resume(struct work_struct *work);
0069 #else
0070 static inline struct musb *hcd_to_musb(struct usb_hcd *hcd)
0071 {
0072 return NULL;
0073 }
0074
0075 static inline irqreturn_t musb_h_ep0_irq(struct musb *musb)
0076 {
0077 return 0;
0078 }
0079
0080 static inline int musb_host_alloc(struct musb *musb)
0081 {
0082 return 0;
0083 }
0084
0085 static inline int musb_host_setup(struct musb *musb, int power_budget)
0086 {
0087 return 0;
0088 }
0089
0090 static inline void musb_host_cleanup(struct musb *musb) {}
0091 static inline void musb_host_free(struct musb *musb) {}
0092 static inline void musb_host_tx(struct musb *musb, u8 epnum) {}
0093 static inline void musb_host_rx(struct musb *musb, u8 epnum) {}
0094 static inline void musb_root_disconnect(struct musb *musb) {}
0095 static inline void musb_host_resume_root_hub(struct musb *musb) {}
0096 static inline void musb_host_poke_root_hub(struct musb *musb) {}
0097 static inline int musb_port_suspend(struct musb *musb, bool do_suspend)
0098 {
0099 return 0;
0100 }
0101 static inline void musb_port_reset(struct musb *musb, bool do_reset) {}
0102 static inline void musb_host_finish_resume(struct work_struct *work) {}
0103 #endif
0104
0105 struct usb_hcd;
0106
0107 extern int musb_hub_status_data(struct usb_hcd *hcd, char *buf);
0108 extern int musb_hub_control(struct usb_hcd *hcd,
0109 u16 typeReq, u16 wValue, u16 wIndex,
0110 char *buf, u16 wLength);
0111
0112 static inline struct urb *next_urb(struct musb_qh *qh)
0113 {
0114 struct list_head *queue;
0115
0116 if (!qh)
0117 return NULL;
0118 queue = &qh->hep->urb_list;
0119 if (list_empty(queue))
0120 return NULL;
0121 return list_entry(queue->next, struct urb, urb_list);
0122 }
0123
0124 #endif