Linux Audio

Check our new training course

Loading...
v6.2
  1/* SPDX-License-Identifier: GPL-2.0 */
  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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  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;			/* endpoint direction */
 59	u8 epnum;
 60	enum buffer_map_state map_state;
 61};
 62
 63#define to_musb_request(r)	container_of((r), struct musb_request, request)
 
 
 
 64
 65extern struct usb_request *
 66musb_alloc_request(struct usb_ep *ep, gfp_t gfp_flags);
 67extern 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 */
 73struct 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
 91	u8				wedged;
 92
 93	/* true if lock must be dropped but req_list may not be advanced */
 94	u8				busy;
 95
 96	u8				hb_mult;
 97};
 98
 99#define to_musb_ep(ep)	container_of((ep), struct musb_ep, end_point)
 
 
 
100
101static inline struct musb_request *next_request(struct musb_ep *ep)
102{
103	struct list_head	*queue = &ep->req_list;
104
105	if (list_empty(queue))
106		return NULL;
107	return container_of(queue->next, struct musb_request, list);
108}
109
 
 
 
110extern const struct usb_ep_ops musb_g_ep0_ops;
 
 
 
111
112extern void musb_g_giveback(struct musb_ep *, struct usb_request *, int);
113
114extern void musb_ep_restart(struct musb *, struct musb_request *);
115
116#endif		/* __MUSB_GADGET_H */
v3.5.6
 
  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 * This program is free software; you can redistribute it and/or
  9 * modify it under the terms of the GNU General Public License
 10 * version 2 as published by the Free Software Foundation.
 11 *
 12 * This program is distributed in the hope that it will be useful, but
 13 * WITHOUT ANY WARRANTY; without even the implied warranty of
 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 15 * General Public License for more details.
 16 *
 17 * You should have received a copy of the GNU General Public License
 18 * along with this program; if not, write to the Free Software
 19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 20 * 02110-1301 USA
 21 *
 22 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
 23 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 24 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
 25 * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 28 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 29 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 32 *
 33 */
 34
 35#ifndef __MUSB_GADGET_H
 36#define __MUSB_GADGET_H
 37
 38#include <linux/list.h>
 39
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 40enum buffer_map_state {
 41	UN_MAPPED = 0,
 42	PRE_MAPPED,
 43	MUSB_MAPPED
 44};
 45
 46struct musb_request {
 47	struct usb_request	request;
 48	struct list_head	list;
 49	struct musb_ep		*ep;
 50	struct musb		*musb;
 51	u8 tx;			/* endpoint direction */
 52	u8 epnum;
 53	enum buffer_map_state map_state;
 54};
 55
 56static inline struct musb_request *to_musb_request(struct usb_request *req)
 57{
 58	return req ? container_of(req, struct musb_request, request) : NULL;
 59}
 60
 61extern struct usb_request *
 62musb_alloc_request(struct usb_ep *ep, gfp_t gfp_flags);
 63extern void musb_free_request(struct usb_ep *ep, struct usb_request *req);
 64
 65
 66/*
 67 * struct musb_ep - peripheral side view of endpoint rx or tx side
 68 */
 69struct musb_ep {
 70	/* stuff towards the head is basically write-once. */
 71	struct usb_ep			end_point;
 72	char				name[12];
 73	struct musb_hw_ep		*hw_ep;
 74	struct musb			*musb;
 75	u8				current_epnum;
 76
 77	/* ... when enabled/disabled ... */
 78	u8				type;
 79	u8				is_in;
 80	u16				packet_sz;
 81	const struct usb_endpoint_descriptor	*desc;
 82	struct dma_channel		*dma;
 83
 84	/* later things are modified based on usage */
 85	struct list_head		req_list;
 86
 87	u8				wedged;
 88
 89	/* true if lock must be dropped but req_list may not be advanced */
 90	u8				busy;
 91
 92	u8				hb_mult;
 93};
 94
 95static inline struct musb_ep *to_musb_ep(struct usb_ep *ep)
 96{
 97	return ep ? container_of(ep, struct musb_ep, end_point) : NULL;
 98}
 99
100static inline struct musb_request *next_request(struct musb_ep *ep)
101{
102	struct list_head	*queue = &ep->req_list;
103
104	if (list_empty(queue))
105		return NULL;
106	return container_of(queue->next, struct musb_request, list);
107}
108
109extern void musb_g_tx(struct musb *musb, u8 epnum);
110extern void musb_g_rx(struct musb *musb, u8 epnum);
111
112extern const struct usb_ep_ops musb_g_ep0_ops;
113
114extern int musb_gadget_setup(struct musb *);
115extern void musb_gadget_cleanup(struct musb *);
116
117extern void musb_g_giveback(struct musb_ep *, struct usb_request *, int);
118
119extern void musb_ep_restart(struct musb *, struct musb_request *);
120
121#endif		/* __MUSB_GADGET_H */