1 // SPDX-License-Identifier: GPL-2.0
3 * MUSB OTG driver peripheral defines
5 * Copyright 2005 Mentor Graphics Corporation
6 * Copyright (C) 2005-2006 by Texas Instruments
7 * Copyright (C) 2006-2007 Nokia Corporation
10 #ifndef __MUSB_GADGET_H
11 #define __MUSB_GADGET_H
13 #include <linux/list.h>
15 #if IS_ENABLED(CONFIG_USB_MUSB_GADGET) || IS_ENABLED(CONFIG_USB_MUSB_DUAL_ROLE)
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
*);
28 static inline irqreturn_t
musb_g_ep0_irq(struct musb
*musb
)
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
)
47 enum buffer_map_state
{
54 struct usb_request request
;
55 struct list_head list
;
58 u8 tx
; /* endpoint direction */
60 enum buffer_map_state map_state
;
63 static inline struct musb_request
*to_musb_request(struct usb_request
*req
)
65 return req
? container_of(req
, struct musb_request
, request
) : NULL
;
68 extern struct usb_request
*
69 musb_alloc_request(struct usb_ep
*ep
, gfp_t gfp_flags
);
70 extern void musb_free_request(struct usb_ep
*ep
, struct usb_request
*req
);
74 * struct musb_ep - peripheral side view of endpoint rx or tx side
77 /* stuff towards the head is basically write-once. */
78 struct usb_ep end_point
;
80 struct musb_hw_ep
*hw_ep
;
84 /* ... when enabled/disabled ... */
88 const struct usb_endpoint_descriptor
*desc
;
89 struct dma_channel
*dma
;
91 /* later things are modified based on usage */
92 struct list_head req_list
;
96 /* true if lock must be dropped but req_list may not be advanced */
102 static inline struct musb_ep
*to_musb_ep(struct usb_ep
*ep
)
104 return ep
? container_of(ep
, struct musb_ep
, end_point
) : NULL
;
107 static inline struct musb_request
*next_request(struct musb_ep
*ep
)
109 struct list_head
*queue
= &ep
->req_list
;
111 if (list_empty(queue
))
113 return container_of(queue
->next
, struct musb_request
, list
);
116 extern const struct usb_ep_ops musb_g_ep0_ops
;
118 extern void musb_g_giveback(struct musb_ep
*, struct usb_request
*, int);
120 extern void musb_ep_restart(struct musb
*, struct musb_request
*);
122 #endif /* __MUSB_GADGET_H */