Commit | Line | Data |
---|---|---|
5fd54ace | 1 | // SPDX-License-Identifier: GPL-2.0 |
550a7375 FB |
2 | /* |
3 | * MUSB OTG driver peripheral defines | |
4 | * | |
5 | * Copyright 2005 Mentor Graphics Corporation | |
6 | * Copyright (C) 2005-2006 by Texas Instruments | |
7 | * Copyright (C) 2006-2007 Nokia Corporation | |
550a7375 FB |
8 | */ |
9 | ||
10 | #ifndef __MUSB_GADGET_H | |
11 | #define __MUSB_GADGET_H | |
12 | ||
ad1adb89 FB |
13 | #include <linux/list.h> |
14 | ||
b7b741ea | 15 | #if IS_ENABLED(CONFIG_USB_MUSB_GADGET) || IS_ENABLED(CONFIG_USB_MUSB_DUAL_ROLE) |
c2a2759d DM |
16 | extern irqreturn_t musb_g_ep0_irq(struct musb *); |
17 | extern void musb_g_tx(struct musb *, u8); | |
18 | extern void musb_g_rx(struct musb *, u8); | |
19 | extern void musb_g_reset(struct musb *); | |
20 | extern void musb_g_suspend(struct musb *); | |
21 | extern void musb_g_resume(struct musb *); | |
22 | extern void musb_g_wakeup(struct musb *); | |
23 | extern void musb_g_disconnect(struct musb *); | |
24 | extern void musb_gadget_cleanup(struct musb *); | |
25 | extern int musb_gadget_setup(struct musb *); | |
26 | ||
b7b741ea DM |
27 | #else |
28 | static inline irqreturn_t musb_g_ep0_irq(struct musb *musb) | |
29 | { | |
30 | return 0; | |
31 | } | |
32 | ||
33 | static inline void musb_g_tx(struct musb *musb, u8 epnum) {} | |
34 | static inline void musb_g_rx(struct musb *musb, u8 epnum) {} | |
35 | static inline void musb_g_reset(struct musb *musb) {} | |
36 | static inline void musb_g_suspend(struct musb *musb) {} | |
37 | static inline void musb_g_resume(struct musb *musb) {} | |
38 | static inline void musb_g_wakeup(struct musb *musb) {} | |
39 | static inline void musb_g_disconnect(struct musb *musb) {} | |
40 | static inline void musb_gadget_cleanup(struct musb *musb) {} | |
41 | static inline int musb_gadget_setup(struct musb *musb) | |
42 | { | |
43 | return 0; | |
44 | } | |
45 | #endif | |
46 | ||
c65bfa62 MYK |
47 | enum buffer_map_state { |
48 | UN_MAPPED = 0, | |
49 | PRE_MAPPED, | |
50 | MUSB_MAPPED | |
51 | }; | |
52 | ||
550a7375 FB |
53 | struct musb_request { |
54 | struct usb_request request; | |
ad1adb89 | 55 | struct list_head list; |
550a7375 FB |
56 | struct musb_ep *ep; |
57 | struct musb *musb; | |
58 | u8 tx; /* endpoint direction */ | |
59 | u8 epnum; | |
c65bfa62 | 60 | enum buffer_map_state map_state; |
550a7375 FB |
61 | }; |
62 | ||
8dca5107 | 63 | #define to_musb_request(r) container_of((r), struct musb_request, request) |
550a7375 FB |
64 | |
65 | extern struct usb_request * | |
66 | musb_alloc_request(struct usb_ep *ep, gfp_t gfp_flags); | |
67 | extern void musb_free_request(struct usb_ep *ep, struct usb_request *req); | |
68 | ||
69 | ||
70 | /* | |
71 | * struct musb_ep - peripheral side view of endpoint rx or tx side | |
72 | */ | |
73 | struct musb_ep { | |
74 | /* stuff towards the head is basically write-once. */ | |
75 | struct usb_ep end_point; | |
76 | char name[12]; | |
77 | struct musb_hw_ep *hw_ep; | |
78 | struct musb *musb; | |
79 | u8 current_epnum; | |
80 | ||
81 | /* ... when enabled/disabled ... */ | |
82 | u8 type; | |
83 | u8 is_in; | |
84 | u16 packet_sz; | |
85 | const struct usb_endpoint_descriptor *desc; | |
86 | struct dma_channel *dma; | |
87 | ||
88 | /* later things are modified based on usage */ | |
89 | struct list_head req_list; | |
90 | ||
47e97605 SS |
91 | u8 wedged; |
92 | ||
550a7375 FB |
93 | /* true if lock must be dropped but req_list may not be advanced */ |
94 | u8 busy; | |
f11d893d ML |
95 | |
96 | u8 hb_mult; | |
550a7375 FB |
97 | }; |
98 | ||
ddf12f04 | 99 | #define to_musb_ep(ep) container_of((ep), struct musb_ep, end_point) |
550a7375 | 100 | |
ad1adb89 | 101 | static inline struct musb_request *next_request(struct musb_ep *ep) |
550a7375 FB |
102 | { |
103 | struct list_head *queue = &ep->req_list; | |
104 | ||
105 | if (list_empty(queue)) | |
106 | return NULL; | |
ad1adb89 | 107 | return container_of(queue->next, struct musb_request, list); |
550a7375 FB |
108 | } |
109 | ||
550a7375 FB |
110 | extern const struct usb_ep_ops musb_g_ep0_ops; |
111 | ||
550a7375 FB |
112 | extern void musb_g_giveback(struct musb_ep *, struct usb_request *, int); |
113 | ||
a666e3e6 SS |
114 | extern void musb_ep_restart(struct musb *, struct musb_request *); |
115 | ||
550a7375 | 116 | #endif /* __MUSB_GADGET_H */ |