Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Ilya Yanok | 06bb920 | 2012-11-06 13:48:21 +0000 | [diff] [blame] | 2 | /* |
| 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 Yanok | 06bb920 | 2012-11-06 13:48:21 +0000 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #ifndef _MUSB_HOST_H |
| 11 | #define _MUSB_HOST_H |
| 12 | #ifdef __UBOOT__ |
Rui Miguel Silva | fb0c70c | 2022-06-29 11:06:14 +0100 | [diff] [blame] | 13 | #include <linux/usb/usb_urb_compat.h> |
Ilya Yanok | 06bb920 | 2012-11-06 13:48:21 +0000 | [diff] [blame] | 14 | #endif |
| 15 | |
| 16 | static inline struct usb_hcd *musb_to_hcd(struct musb *musb) |
| 17 | { |
| 18 | return container_of((void *) musb, struct usb_hcd, hcd_priv); |
| 19 | } |
| 20 | |
| 21 | static 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 */ |
| 27 | struct 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 */ |
| 55 | static 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 | |
| 63 | extern void musb_root_disconnect(struct musb *musb); |
| 64 | |
| 65 | struct usb_hcd; |
| 66 | |
| 67 | extern int musb_hub_status_data(struct usb_hcd *hcd, char *buf); |
| 68 | extern int musb_hub_control(struct usb_hcd *hcd, |
| 69 | u16 typeReq, u16 wValue, u16 wIndex, |
| 70 | char *buf, u16 wLength); |
| 71 | |
| 72 | extern const struct hc_driver musb_hc_driver; |
| 73 | |
| 74 | static 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__ |
| 87 | int musb_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flags); |
Hans de Goede | 0e4da95 | 2015-01-11 20:34:52 +0100 | [diff] [blame] | 88 | int musb_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status); |
Ilya Yanok | 06bb920 | 2012-11-06 13:48:21 +0000 | [diff] [blame] | 89 | #endif |
| 90 | #endif /* _MUSB_HOST_H */ |