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_GADGET_H
36#define __MUSB_GADGET_H
37
38#include <linux/list.h>
39
40#if IS_ENABLED(CONFIG_USB_MUSB_GADGET) || IS_ENABLED(CONFIG_USB_MUSB_DUAL_ROLE)
41extern irqreturn_t musb_g_ep0_irq(struct musb *);
42extern void musb_g_tx(struct musb *, u8);
43extern void musb_g_rx(struct musb *, u8);
44extern void musb_g_reset(struct musb *);
45extern void musb_g_suspend(struct musb *);
46extern void musb_g_resume(struct musb *);
47extern void musb_g_wakeup(struct musb *);
48extern void musb_g_disconnect(struct musb *);
49extern void musb_gadget_cleanup(struct musb *);
50extern int musb_gadget_setup(struct musb *);
51
52#else
53static inline irqreturn_t musb_g_ep0_irq(struct musb *musb)
54{
55 return 0;
56}
57
58static inline void musb_g_tx(struct musb *musb, u8 epnum) {}
59static inline void musb_g_rx(struct musb *musb, u8 epnum) {}
60static inline void musb_g_reset(struct musb *musb) {}
61static inline void musb_g_suspend(struct musb *musb) {}
62static inline void musb_g_resume(struct musb *musb) {}
63static inline void musb_g_wakeup(struct musb *musb) {}
64static inline void musb_g_disconnect(struct musb *musb) {}
65static inline void musb_gadget_cleanup(struct musb *musb) {}
66static inline int musb_gadget_setup(struct musb *musb)
67{
68 return 0;
69}
70#endif
71
72enum buffer_map_state {
73 UN_MAPPED = 0,
74 PRE_MAPPED,
75 MUSB_MAPPED
76};
77
78struct musb_request {
79 struct usb_request request;
80 struct list_head list;
81 struct musb_ep *ep;
82 struct musb *musb;
83 u8 tx;
84 u8 epnum;
85 enum buffer_map_state map_state;
86};
87
88static inline struct musb_request *to_musb_request(struct usb_request *req)
89{
90 return req ? container_of(req, struct musb_request, request) : NULL;
91}
92
93extern struct usb_request *
94musb_alloc_request(struct usb_ep *ep, gfp_t gfp_flags);
95extern void musb_free_request(struct usb_ep *ep, struct usb_request *req);
96
97
98
99
100
101struct musb_ep {
102
103 struct usb_ep end_point;
104 char name[12];
105 struct musb_hw_ep *hw_ep;
106 struct musb *musb;
107 u8 current_epnum;
108
109
110 u8 type;
111 u8 is_in;
112 u16 packet_sz;
113 const struct usb_endpoint_descriptor *desc;
114 struct dma_channel *dma;
115
116
117 struct list_head req_list;
118
119 u8 wedged;
120
121
122 u8 busy;
123
124 u8 hb_mult;
125};
126
127static inline struct musb_ep *to_musb_ep(struct usb_ep *ep)
128{
129 return ep ? container_of(ep, struct musb_ep, end_point) : NULL;
130}
131
132static inline struct musb_request *next_request(struct musb_ep *ep)
133{
134 struct list_head *queue = &ep->req_list;
135
136 if (list_empty(queue))
137 return NULL;
138 return container_of(queue->next, struct musb_request, list);
139}
140
141extern const struct usb_ep_ops musb_g_ep0_ops;
142
143extern void musb_g_giveback(struct musb_ep *, struct usb_request *, int);
144
145extern void musb_ep_restart(struct musb *, struct musb_request *);
146
147#endif
148