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