1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35#ifndef _MUSB_HOST_H
36#define _MUSB_HOST_H
37
38#include <linux/scatterlist.h>
39
40
41struct musb_qh {
42 struct usb_host_endpoint *hep;
43 struct usb_device *dev;
44 struct musb_hw_ep *hw_ep;
45
46 struct list_head ring;
47
48 u8 mux;
49
50 unsigned offset;
51 unsigned segsize;
52
53 u8 type_reg;
54 u8 intv_reg;
55 u8 addr_reg;
56 u8 h_addr_reg;
57 u8 h_port_reg;
58
59 u8 is_ready;
60 u8 type;
61 u8 epnum;
62 u8 hb_mult;
63 u16 maxpacket;
64 u16 frame;
65 unsigned iso_idx;
66 struct sg_mapping_iter sg_miter;
67 bool use_sg;
68};
69
70
71static inline struct musb_qh *first_qh(struct list_head *q)
72{
73 if (list_empty(q))
74 return NULL;
75 return list_entry(q->next, struct musb_qh, ring);
76}
77
78
79#if IS_ENABLED(CONFIG_USB_MUSB_HOST) || IS_ENABLED(CONFIG_USB_MUSB_DUAL_ROLE)
80extern struct musb *hcd_to_musb(struct usb_hcd *);
81extern irqreturn_t musb_h_ep0_irq(struct musb *);
82extern int musb_host_alloc(struct musb *);
83extern int musb_host_setup(struct musb *, int);
84extern void musb_host_cleanup(struct musb *);
85extern void musb_host_tx(struct musb *, u8);
86extern void musb_host_rx(struct musb *, u8);
87extern void musb_root_disconnect(struct musb *musb);
88extern void musb_host_free(struct musb *);
89extern void musb_host_cleanup(struct musb *);
90extern void musb_host_tx(struct musb *, u8);
91extern void musb_host_rx(struct musb *, u8);
92extern void musb_root_disconnect(struct musb *musb);
93extern void musb_host_resume_root_hub(struct musb *musb);
94extern void musb_host_poke_root_hub(struct musb *musb);
95extern void musb_port_suspend(struct musb *musb, bool do_suspend);
96extern void musb_port_reset(struct musb *musb, bool do_reset);
97extern void musb_host_finish_resume(struct work_struct *work);
98#else
99static inline struct musb *hcd_to_musb(struct usb_hcd *hcd)
100{
101 return NULL;
102}
103
104static inline irqreturn_t musb_h_ep0_irq(struct musb *musb)
105{
106 return 0;
107}
108
109static inline int musb_host_alloc(struct musb *musb)
110{
111 return 0;
112}
113
114static inline int musb_host_setup(struct musb *musb, int power_budget)
115{
116 return 0;
117}
118
119static inline void musb_host_cleanup(struct musb *musb) {}
120static inline void musb_host_free(struct musb *musb) {}
121static inline void musb_host_tx(struct musb *musb, u8 epnum) {}
122static inline void musb_host_rx(struct musb *musb, u8 epnum) {}
123static inline void musb_root_disconnect(struct musb *musb) {}
124static inline void musb_host_resume_root_hub(struct musb *musb) {}
125static inline void musb_host_poll_rh_status(struct musb *musb) {}
126static inline void musb_host_poke_root_hub(struct musb *musb) {}
127static inline void musb_port_suspend(struct musb *musb, bool do_suspend) {}
128static inline void musb_port_reset(struct musb *musb, bool do_reset) {}
129static inline void musb_host_finish_resume(struct work_struct *work) {}
130#endif
131
132struct usb_hcd;
133
134extern int musb_hub_status_data(struct usb_hcd *hcd, char *buf);
135extern int musb_hub_control(struct usb_hcd *hcd,
136 u16 typeReq, u16 wValue, u16 wIndex,
137 char *buf, u16 wLength);
138
139static inline struct urb *next_urb(struct musb_qh *qh)
140{
141 struct list_head *queue;
142
143 if (!qh)
144 return NULL;
145 queue = &qh->hep->urb_list;
146 if (list_empty(queue))
147 return NULL;
148 return list_entry(queue->next, struct urb, urb_list);
149}
150
151#endif
152