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