]> git.ipfire.org Git - people/ms/u-boot.git/blob - drivers/usb/musb-new/musb_gadget.h
Merge branch 'master' of git://www.denx.de/git/u-boot-microblaze
[people/ms/u-boot.git] / drivers / usb / musb-new / musb_gadget.h
1 /*
2 * MUSB OTG driver peripheral defines
3 *
4 * Copyright 2005 Mentor Graphics Corporation
5 * Copyright (C) 2005-2006 by Texas Instruments
6 * Copyright (C) 2006-2007 Nokia Corporation
7 *
8 * SPDX-License-Identifier: GPL-2.0
9 */
10
11 #ifndef __MUSB_GADGET_H
12 #define __MUSB_GADGET_H
13
14 #include <linux/list.h>
15 #ifdef __UBOOT__
16 #include <asm/byteorder.h>
17 #include <asm/errno.h>
18 #include <linux/usb/ch9.h>
19 #include <linux/usb/gadget.h>
20 #endif
21
22 enum buffer_map_state {
23 UN_MAPPED = 0,
24 PRE_MAPPED,
25 MUSB_MAPPED
26 };
27
28 struct musb_request {
29 struct usb_request request;
30 struct list_head list;
31 struct musb_ep *ep;
32 struct musb *musb;
33 u8 tx; /* endpoint direction */
34 u8 epnum;
35 enum buffer_map_state map_state;
36 };
37
38 static inline struct musb_request *to_musb_request(struct usb_request *req)
39 {
40 return req ? container_of(req, struct musb_request, request) : NULL;
41 }
42
43 extern struct usb_request *
44 musb_alloc_request(struct usb_ep *ep, gfp_t gfp_flags);
45 extern void musb_free_request(struct usb_ep *ep, struct usb_request *req);
46
47
48 /*
49 * struct musb_ep - peripheral side view of endpoint rx or tx side
50 */
51 struct musb_ep {
52 /* stuff towards the head is basically write-once. */
53 struct usb_ep end_point;
54 char name[12];
55 struct musb_hw_ep *hw_ep;
56 struct musb *musb;
57 u8 current_epnum;
58
59 /* ... when enabled/disabled ... */
60 u8 type;
61 u8 is_in;
62 u16 packet_sz;
63 const struct usb_endpoint_descriptor *desc;
64 struct dma_channel *dma;
65
66 /* later things are modified based on usage */
67 struct list_head req_list;
68
69 u8 wedged;
70
71 /* true if lock must be dropped but req_list may not be advanced */
72 u8 busy;
73
74 u8 hb_mult;
75 };
76
77 static inline struct musb_ep *to_musb_ep(struct usb_ep *ep)
78 {
79 return ep ? container_of(ep, struct musb_ep, end_point) : NULL;
80 }
81
82 static inline struct musb_request *next_request(struct musb_ep *ep)
83 {
84 struct list_head *queue = &ep->req_list;
85
86 if (list_empty(queue))
87 return NULL;
88 return container_of(queue->next, struct musb_request, list);
89 }
90
91 extern void musb_g_tx(struct musb *musb, u8 epnum);
92 extern void musb_g_rx(struct musb *musb, u8 epnum);
93
94 extern const struct usb_ep_ops musb_g_ep0_ops;
95
96 extern int musb_gadget_setup(struct musb *);
97 extern void musb_gadget_cleanup(struct musb *);
98
99 extern void musb_g_giveback(struct musb_ep *, struct usb_request *, int);
100
101 extern void musb_ep_restart(struct musb *, struct musb_request *);
102
103 #ifdef __UBOOT__
104 int musb_gadget_start(struct usb_gadget *g, struct usb_gadget_driver *driver);
105 #endif
106 #endif /* __MUSB_GADGET_H */