Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

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