blob: 5a604bdb0cf202d5f6b6cb9609bf1aaa907fcd4e [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0 */
Ilya Yanokeb819552012-11-06 13:48:21 +00002/*
3 * MUSB OTG driver host defines
4 *
5 * Copyright 2005 Mentor Graphics Corporation
6 * Copyright (C) 2005-2006 by Texas Instruments
7 * Copyright (C) 2006-2007 Nokia Corporation
Ilya Yanokeb819552012-11-06 13:48:21 +00008 */
9
10#ifndef _MUSB_HOST_H
11#define _MUSB_HOST_H
12#ifdef __UBOOT__
Rui Miguel Silvab2d2b782022-06-29 11:06:14 +010013#include <linux/usb/usb_urb_compat.h>
Ilya Yanokeb819552012-11-06 13:48:21 +000014#endif
15
16static inline struct usb_hcd *musb_to_hcd(struct musb *musb)
17{
18 return container_of((void *) musb, struct usb_hcd, hcd_priv);
19}
20
21static inline struct musb *hcd_to_musb(struct usb_hcd *hcd)
22{
23 return (struct musb *) (hcd->hcd_priv);
24}
25
26/* stored in "usb_host_endpoint.hcpriv" for scheduled endpoints */
27struct musb_qh {
28 struct usb_host_endpoint *hep; /* usbcore info */
29 struct usb_device *dev;
30 struct musb_hw_ep *hw_ep; /* current binding */
31
32 struct list_head ring; /* of musb_qh */
33 /* struct musb_qh *next; */ /* for periodic tree */
34 u8 mux; /* qh multiplexed to hw_ep */
35
36 unsigned offset; /* in urb->transfer_buffer */
37 unsigned segsize; /* current xfer fragment */
38
39 u8 type_reg; /* {rx,tx} type register */
40 u8 intv_reg; /* {rx,tx} interval register */
41 u8 addr_reg; /* device address register */
42 u8 h_addr_reg; /* hub address register */
43 u8 h_port_reg; /* hub port register */
44
45 u8 is_ready; /* safe to modify hw_ep */
46 u8 type; /* XFERTYPE_* */
47 u8 epnum;
48 u8 hb_mult; /* high bandwidth pkts per uf */
49 u16 maxpacket;
50 u16 frame; /* for periodic schedule */
51 unsigned iso_idx; /* in urb->iso_frame_desc[] */
52};
53
54/* map from control or bulk queue head to the first qh on that ring */
55static inline struct musb_qh *first_qh(struct list_head *q)
56{
57 if (list_empty(q))
58 return NULL;
59 return list_entry(q->next, struct musb_qh, ring);
60}
61
62
63extern void musb_root_disconnect(struct musb *musb);
64
65struct usb_hcd;
66
67extern int musb_hub_status_data(struct usb_hcd *hcd, char *buf);
68extern int musb_hub_control(struct usb_hcd *hcd,
69 u16 typeReq, u16 wValue, u16 wIndex,
70 char *buf, u16 wLength);
71
72extern const struct hc_driver musb_hc_driver;
73
74static inline struct urb *next_urb(struct musb_qh *qh)
75{
76 struct list_head *queue;
77
78 if (!qh)
79 return NULL;
80 queue = &qh->hep->urb_list;
81 if (list_empty(queue))
82 return NULL;
83 return list_entry(queue->next, struct urb, urb_list);
84}
85
86#ifdef __UBOOT__
87int musb_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flags);
Hans de Goedeb918a0c2015-01-11 20:34:52 +010088int musb_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status);
Ilya Yanokeb819552012-11-06 13:48:21 +000089#endif
90#endif /* _MUSB_HOST_H */