1
2
3
4
5
6
7
8
9
10#ifndef __MUSB_GADGET_H
11#define __MUSB_GADGET_H
12
13#include <linux/list.h>
14
15#if IS_ENABLED(CONFIG_USB_MUSB_GADGET) || IS_ENABLED(CONFIG_USB_MUSB_DUAL_ROLE)
16extern irqreturn_t musb_g_ep0_irq(struct musb *);
17extern void musb_g_tx(struct musb *, u8);
18extern void musb_g_rx(struct musb *, u8);
19extern void musb_g_reset(struct musb *);
20extern void musb_g_suspend(struct musb *);
21extern void musb_g_resume(struct musb *);
22extern void musb_g_wakeup(struct musb *);
23extern void musb_g_disconnect(struct musb *);
24extern void musb_gadget_cleanup(struct musb *);
25extern int musb_gadget_setup(struct musb *);
26
27#else
28static inline irqreturn_t musb_g_ep0_irq(struct musb *musb)
29{
30 return 0;
31}
32
33static inline void musb_g_tx(struct musb *musb, u8 epnum) {}
34static inline void musb_g_rx(struct musb *musb, u8 epnum) {}
35static inline void musb_g_reset(struct musb *musb) {}
36static inline void musb_g_suspend(struct musb *musb) {}
37static inline void musb_g_resume(struct musb *musb) {}
38static inline void musb_g_wakeup(struct musb *musb) {}
39static inline void musb_g_disconnect(struct musb *musb) {}
40static inline void musb_gadget_cleanup(struct musb *musb) {}
41static inline int musb_gadget_setup(struct musb *musb)
42{
43 return 0;
44}
45#endif
46
47enum buffer_map_state {
48 UN_MAPPED = 0,
49 PRE_MAPPED,
50 MUSB_MAPPED
51};
52
53struct musb_request {
54 struct usb_request request;
55 struct list_head list;
56 struct musb_ep *ep;
57 struct musb *musb;
58 u8 tx;
59 u8 epnum;
60 enum buffer_map_state map_state;
61};
62
63static inline struct musb_request *to_musb_request(struct usb_request *req)
64{
65 return req ? container_of(req, struct musb_request, request) : NULL;
66}
67
68extern struct usb_request *
69musb_alloc_request(struct usb_ep *ep, gfp_t gfp_flags);
70extern void musb_free_request(struct usb_ep *ep, struct usb_request *req);
71
72
73
74
75
76struct musb_ep {
77
78 struct usb_ep end_point;
79 char name[12];
80 struct musb_hw_ep *hw_ep;
81 struct musb *musb;
82 u8 current_epnum;
83
84
85 u8 type;
86 u8 is_in;
87 u16 packet_sz;
88 const struct usb_endpoint_descriptor *desc;
89 struct dma_channel *dma;
90
91
92 struct list_head req_list;
93
94 u8 wedged;
95
96
97 u8 busy;
98
99 u8 hb_mult;
100};
101
102static inline struct musb_ep *to_musb_ep(struct usb_ep *ep)
103{
104 return ep ? container_of(ep, struct musb_ep, end_point) : NULL;
105}
106
107static inline struct musb_request *next_request(struct musb_ep *ep)
108{
109 struct list_head *queue = &ep->req_list;
110
111 if (list_empty(queue))
112 return NULL;
113 return container_of(queue->next, struct musb_request, list);
114}
115
116extern const struct usb_ep_ops musb_g_ep0_ops;
117
118extern void musb_g_giveback(struct musb_ep *, struct usb_request *, int);
119
120extern void musb_ep_restart(struct musb *, struct musb_request *);
121
122#endif
123