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
40enum buffer_map_state {
41 UN_MAPPED = 0,
42 PRE_MAPPED,
43 MUSB_MAPPED
44};
45
46struct musb_request {
47 struct usb_request request;
48 struct list_head list;
49 struct musb_ep *ep;
50 struct musb *musb;
51 u8 tx;
52 u8 epnum;
53 enum buffer_map_state map_state;
54};
55
56static inline struct musb_request *to_musb_request(struct usb_request *req)
57{
58 return req ? container_of(req, struct musb_request, request) : NULL;
59}
60
61extern struct usb_request *
62musb_alloc_request(struct usb_ep *ep, gfp_t gfp_flags);
63extern void musb_free_request(struct usb_ep *ep, struct usb_request *req);
64
65
66
67
68
69struct musb_ep {
70
71 struct usb_ep end_point;
72 char name[12];
73 struct musb_hw_ep *hw_ep;
74 struct musb *musb;
75 u8 current_epnum;
76
77
78 u8 type;
79 u8 is_in;
80 u16 packet_sz;
81 const struct usb_endpoint_descriptor *desc;
82 struct dma_channel *dma;
83
84
85 struct list_head req_list;
86
87 u8 wedged;
88
89
90 u8 busy;
91
92 u8 hb_mult;
93};
94
95static inline struct musb_ep *to_musb_ep(struct usb_ep *ep)
96{
97 return ep ? container_of(ep, struct musb_ep, end_point) : NULL;
98}
99
100static inline struct musb_request *next_request(struct musb_ep *ep)
101{
102 struct list_head *queue = &ep->req_list;
103
104 if (list_empty(queue))
105 return NULL;
106 return container_of(queue->next, struct musb_request, list);
107}
108
109extern void musb_g_tx(struct musb *musb, u8 epnum);
110extern void musb_g_rx(struct musb *musb, u8 epnum);
111
112extern const struct usb_ep_ops musb_g_ep0_ops;
113
114extern int musb_gadget_setup(struct musb *);
115extern void musb_gadget_cleanup(struct musb *);
116
117extern void musb_g_giveback(struct musb_ep *, struct usb_request *, int);
118
119extern void musb_ep_restart(struct musb *, struct musb_request *);
120
121#endif
122