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 host 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_HOST_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #define _MUSB_HOST_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/scatterlist.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) /* stored in "usb_host_endpoint.hcpriv" for scheduled endpoints */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) struct musb_qh {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 	struct usb_host_endpoint *hep;		/* usbcore info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 	struct usb_device	*dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 	struct musb_hw_ep	*hw_ep;		/* current binding */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 	struct list_head	ring;		/* of musb_qh */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 	/* struct musb_qh		*next; */	/* for periodic tree */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	u8			mux;		/* qh multiplexed to hw_ep */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	unsigned		offset;		/* in urb->transfer_buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	unsigned		segsize;	/* current xfer fragment */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	u8			type_reg;	/* {rx,tx} type register */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	u8			intv_reg;	/* {rx,tx} interval register */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	u8			addr_reg;	/* device address register */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	u8			h_addr_reg;	/* hub address register */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	u8			h_port_reg;	/* hub port register */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	u8			is_ready;	/* safe to modify hw_ep */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	u8			type;		/* XFERTYPE_* */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	u8			epnum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	u8			hb_mult;	/* high bandwidth pkts per uf */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	u16			maxpacket;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	u16			frame;		/* for periodic schedule */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	unsigned		iso_idx;	/* in urb->iso_frame_desc[] */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	struct sg_mapping_iter sg_miter;	/* for highmem in PIO mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	bool			use_sg;		/* to track urb using sglist */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) /* map from control or bulk queue head to the first qh on that ring */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) static inline struct musb_qh *first_qh(struct list_head *q)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	if (list_empty(q))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 		return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	return list_entry(q->next, struct musb_qh, ring);
^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) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) #if IS_ENABLED(CONFIG_USB_MUSB_HOST) || IS_ENABLED(CONFIG_USB_MUSB_DUAL_ROLE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) extern struct musb *hcd_to_musb(struct usb_hcd *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) extern irqreturn_t musb_h_ep0_irq(struct musb *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) extern int musb_host_alloc(struct musb *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) extern int musb_host_setup(struct musb *, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) extern void musb_host_cleanup(struct musb *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) extern void musb_host_tx(struct musb *, u8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) extern void musb_host_rx(struct musb *, u8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) extern void musb_root_disconnect(struct musb *musb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) extern void musb_host_free(struct musb *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) extern void musb_host_cleanup(struct musb *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) extern void musb_host_tx(struct musb *, u8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) extern void musb_host_rx(struct musb *, u8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) extern void musb_root_disconnect(struct musb *musb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) extern void musb_host_resume_root_hub(struct musb *musb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) extern void musb_host_poke_root_hub(struct musb *musb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) extern int musb_port_suspend(struct musb *musb, bool do_suspend);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) extern void musb_port_reset(struct musb *musb, bool do_reset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) extern void musb_host_finish_resume(struct work_struct *work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) static inline struct musb *hcd_to_musb(struct usb_hcd *hcd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) static inline irqreturn_t musb_h_ep0_irq(struct musb *musb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) static inline int musb_host_alloc(struct musb *musb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) static inline int musb_host_setup(struct musb *musb, int power_budget)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) static inline void musb_host_cleanup(struct musb *musb)		{}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) static inline void musb_host_free(struct musb *musb)		{}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) static inline void musb_host_tx(struct musb *musb, u8 epnum)	{}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) static inline void musb_host_rx(struct musb *musb, u8 epnum)	{}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) static inline void musb_root_disconnect(struct musb *musb)	{}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) static inline void musb_host_resume_root_hub(struct musb *musb)	{}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) static inline void musb_host_poke_root_hub(struct musb *musb)	{}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) static inline int musb_port_suspend(struct musb *musb, bool do_suspend)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) static inline void musb_port_reset(struct musb *musb, bool do_reset) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) static inline void musb_host_finish_resume(struct work_struct *work) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) struct usb_hcd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) extern int musb_hub_status_data(struct usb_hcd *hcd, char *buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) extern int musb_hub_control(struct usb_hcd *hcd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 			u16 typeReq, u16 wValue, u16 wIndex,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 			char *buf, u16 wLength);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) static inline struct urb *next_urb(struct musb_qh *qh)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	struct list_head	*queue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	if (!qh)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 		return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	queue = &qh->hep->urb_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	if (list_empty(queue))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 		return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	return list_entry(queue->next, struct urb, urb_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) #endif				/* _MUSB_HOST_H */