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