Ilya Yanok | eb81955 | 2012-11-06 13:48:21 +0000 | [diff] [blame] | 1 | /* |
| 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 Rini | 5b8031c | 2016-01-14 22:05:13 -0500 | [diff] [blame] | 8 | * SPDX-License-Identifier: GPL-2.0 |
Ilya Yanok | eb81955 | 2012-11-06 13:48:21 +0000 | [diff] [blame] | 9 | */ |
| 10 | |
| 11 | #ifndef _MUSB_HOST_H |
| 12 | #define _MUSB_HOST_H |
| 13 | #ifdef __UBOOT__ |
| 14 | #include "usb-compat.h" |
| 15 | #endif |
| 16 | |
| 17 | static inline struct usb_hcd *musb_to_hcd(struct musb *musb) |
| 18 | { |
| 19 | return container_of((void *) musb, struct usb_hcd, hcd_priv); |
| 20 | } |
| 21 | |
| 22 | static 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 */ |
| 28 | struct 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 */ |
| 56 | static 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 | |
| 64 | extern void musb_root_disconnect(struct musb *musb); |
| 65 | |
| 66 | struct usb_hcd; |
| 67 | |
| 68 | extern int musb_hub_status_data(struct usb_hcd *hcd, char *buf); |
| 69 | extern int musb_hub_control(struct usb_hcd *hcd, |
| 70 | u16 typeReq, u16 wValue, u16 wIndex, |
| 71 | char *buf, u16 wLength); |
| 72 | |
| 73 | extern const struct hc_driver musb_hc_driver; |
| 74 | |
| 75 | static 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__ |
| 88 | int musb_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flags); |
Hans de Goede | b918a0c | 2015-01-11 20:34:52 +0100 | [diff] [blame] | 89 | int musb_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status); |
Ilya Yanok | eb81955 | 2012-11-06 13:48:21 +0000 | [diff] [blame] | 90 | #endif |
| 91 | #endif /* _MUSB_HOST_H */ |