2020-04-04 10:49:55 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2008-07-24 09:27:36 +00:00
|
|
|
/*
|
|
|
|
* MUSB OTG driver peripheral defines
|
|
|
|
*
|
|
|
|
* Copyright 2005 Mentor Graphics Corporation
|
|
|
|
* Copyright (C) 2005-2006 by Texas Instruments
|
|
|
|
* Copyright (C) 2006-2007 Nokia Corporation
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __MUSB_GADGET_H
|
|
|
|
#define __MUSB_GADGET_H
|
|
|
|
|
2011-02-16 10:40:05 +00:00
|
|
|
#include <linux/list.h>
|
|
|
|
|
2013-04-10 19:55:46 +00:00
|
|
|
#if IS_ENABLED(CONFIG_USB_MUSB_GADGET) || IS_ENABLED(CONFIG_USB_MUSB_DUAL_ROLE)
|
2013-04-10 19:55:41 +00:00
|
|
|
extern irqreturn_t musb_g_ep0_irq(struct musb *);
|
|
|
|
extern void musb_g_tx(struct musb *, u8);
|
|
|
|
extern void musb_g_rx(struct musb *, u8);
|
|
|
|
extern void musb_g_reset(struct musb *);
|
|
|
|
extern void musb_g_suspend(struct musb *);
|
|
|
|
extern void musb_g_resume(struct musb *);
|
|
|
|
extern void musb_g_wakeup(struct musb *);
|
|
|
|
extern void musb_g_disconnect(struct musb *);
|
|
|
|
extern void musb_gadget_cleanup(struct musb *);
|
|
|
|
extern int musb_gadget_setup(struct musb *);
|
|
|
|
|
2013-04-10 19:55:46 +00:00
|
|
|
#else
|
|
|
|
static inline irqreturn_t musb_g_ep0_irq(struct musb *musb)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void musb_g_tx(struct musb *musb, u8 epnum) {}
|
|
|
|
static inline void musb_g_rx(struct musb *musb, u8 epnum) {}
|
|
|
|
static inline void musb_g_reset(struct musb *musb) {}
|
|
|
|
static inline void musb_g_suspend(struct musb *musb) {}
|
|
|
|
static inline void musb_g_resume(struct musb *musb) {}
|
|
|
|
static inline void musb_g_wakeup(struct musb *musb) {}
|
|
|
|
static inline void musb_g_disconnect(struct musb *musb) {}
|
|
|
|
static inline void musb_gadget_cleanup(struct musb *musb) {}
|
|
|
|
static inline int musb_gadget_setup(struct musb *musb)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-01-04 11:47:02 +00:00
|
|
|
enum buffer_map_state {
|
|
|
|
UN_MAPPED = 0,
|
|
|
|
PRE_MAPPED,
|
|
|
|
MUSB_MAPPED
|
|
|
|
};
|
|
|
|
|
2008-07-24 09:27:36 +00:00
|
|
|
struct musb_request {
|
|
|
|
struct usb_request request;
|
2011-02-16 10:40:05 +00:00
|
|
|
struct list_head list;
|
2008-07-24 09:27:36 +00:00
|
|
|
struct musb_ep *ep;
|
|
|
|
struct musb *musb;
|
|
|
|
u8 tx; /* endpoint direction */
|
|
|
|
u8 epnum;
|
2011-01-04 11:47:02 +00:00
|
|
|
enum buffer_map_state map_state;
|
2008-07-24 09:27:36 +00:00
|
|
|
};
|
|
|
|
|
2018-05-21 13:42:21 +00:00
|
|
|
#define to_musb_request(r) container_of((r), struct musb_request, request)
|
2008-07-24 09:27:36 +00:00
|
|
|
|
|
|
|
extern struct usb_request *
|
|
|
|
musb_alloc_request(struct usb_ep *ep, gfp_t gfp_flags);
|
|
|
|
extern void musb_free_request(struct usb_ep *ep, struct usb_request *req);
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* struct musb_ep - peripheral side view of endpoint rx or tx side
|
|
|
|
*/
|
|
|
|
struct musb_ep {
|
|
|
|
/* stuff towards the head is basically write-once. */
|
|
|
|
struct usb_ep end_point;
|
|
|
|
char name[12];
|
|
|
|
struct musb_hw_ep *hw_ep;
|
|
|
|
struct musb *musb;
|
|
|
|
u8 current_epnum;
|
|
|
|
|
|
|
|
/* ... when enabled/disabled ... */
|
|
|
|
u8 type;
|
|
|
|
u8 is_in;
|
|
|
|
u16 packet_sz;
|
|
|
|
const struct usb_endpoint_descriptor *desc;
|
|
|
|
struct dma_channel *dma;
|
|
|
|
|
|
|
|
/* later things are modified based on usage */
|
|
|
|
struct list_head req_list;
|
|
|
|
|
2009-11-18 19:51:51 +00:00
|
|
|
u8 wedged;
|
|
|
|
|
2008-07-24 09:27:36 +00:00
|
|
|
/* true if lock must be dropped but req_list may not be advanced */
|
|
|
|
u8 busy;
|
2010-09-24 10:44:04 +00:00
|
|
|
|
|
|
|
u8 hb_mult;
|
2008-07-24 09:27:36 +00:00
|
|
|
};
|
|
|
|
|
2018-05-21 13:42:22 +00:00
|
|
|
#define to_musb_ep(ep) container_of((ep), struct musb_ep, end_point)
|
2008-07-24 09:27:36 +00:00
|
|
|
|
2011-02-16 10:40:05 +00:00
|
|
|
static inline struct musb_request *next_request(struct musb_ep *ep)
|
2008-07-24 09:27:36 +00:00
|
|
|
{
|
|
|
|
struct list_head *queue = &ep->req_list;
|
|
|
|
|
|
|
|
if (list_empty(queue))
|
|
|
|
return NULL;
|
2011-02-16 10:40:05 +00:00
|
|
|
return container_of(queue->next, struct musb_request, list);
|
2008-07-24 09:27:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
extern const struct usb_ep_ops musb_g_ep0_ops;
|
|
|
|
|
|
|
|
extern void musb_g_giveback(struct musb_ep *, struct usb_request *, int);
|
|
|
|
|
2010-09-11 18:23:12 +00:00
|
|
|
extern void musb_ep_restart(struct musb *, struct musb_request *);
|
|
|
|
|
2008-07-24 09:27:36 +00:00
|
|
|
#endif /* __MUSB_GADGET_H */
|