blob: 1c66c4fe3637115b1c8cae0f5c47f8277fd7bfb6 [file] [log] [blame]
Ilya Yanokeb819552012-11-06 13:48:21 +00001#ifndef __USB_COMPAT_H__
2#define __USB_COMPAT_H__
3
4#include "usb.h"
5
Simon Glass16178622020-07-19 10:15:55 -06006struct udevice;
7
Ilya Yanokeb819552012-11-06 13:48:21 +00008struct usb_hcd {
9 void *hcd_priv;
10};
11
12struct usb_host_endpoint {
13 struct usb_endpoint_descriptor desc;
14 struct list_head urb_list;
15 void *hcpriv;
16};
17
18/*
19 * urb->transfer_flags:
20 *
21 * Note: URB_DIR_IN/OUT is automatically set in usb_submit_urb().
22 */
23#define URB_SHORT_NOT_OK 0x0001 /* report short reads as errors */
24#define URB_ZERO_PACKET 0x0040 /* Finish bulk OUT with short packet */
25
26struct urb;
27
28typedef void (*usb_complete_t)(struct urb *);
29
30struct urb {
31 void *hcpriv; /* private data for host controller */
32 struct list_head urb_list; /* list head for use by the urb's
33 * current owner */
34 struct usb_device *dev; /* (in) pointer to associated device */
35 struct usb_host_endpoint *ep; /* (internal) pointer to endpoint */
36 unsigned int pipe; /* (in) pipe information */
37 int status; /* (return) non-ISO status */
38 unsigned int transfer_flags; /* (in) URB_SHORT_NOT_OK | ...*/
39 void *transfer_buffer; /* (in) associated data buffer */
40 dma_addr_t transfer_dma; /* (in) dma addr for transfer_buffer */
41 u32 transfer_buffer_length; /* (in) data buffer length */
42 u32 actual_length; /* (return) actual transfer length */
43 unsigned char *setup_packet; /* (in) setup packet (control only) */
44 int start_frame; /* (modify) start frame (ISO) */
45 usb_complete_t complete; /* (in) completion routine */
46};
47
48#define usb_hcd_link_urb_to_ep(hcd, urb) ({ \
49 int ret = 0; \
50 list_add_tail(&urb->urb_list, &urb->ep->urb_list); \
51 ret; })
52#define usb_hcd_unlink_urb_from_ep(hcd, urb) list_del_init(&urb->urb_list)
Hans de Goedeb918a0c2015-01-11 20:34:52 +010053#define usb_hcd_check_unlink_urb(hdc, urb, status) 0
Ilya Yanokeb819552012-11-06 13:48:21 +000054
55static inline void usb_hcd_giveback_urb(struct usb_hcd *hcd,
56 struct urb *urb,
57 int status)
58{
59 urb->status = status;
60 if (urb->complete)
61 urb->complete(urb);
62}
63
64static inline int usb_hcd_unmap_urb_for_dma(struct usb_hcd *hcd,
65 struct urb *urb)
66{
67 /* TODO: add cache invalidation here */
68 return 0;
69}
70
Simon Glass16178622020-07-19 10:15:55 -060071/**
72 * usb_dev_get_parent() - Get the parent of a USB device
73 *
74 * @udev: USB struct containing information about the device
75 * @return associated device for which udev == dev_get_parent_priv(dev)
76 */
77struct usb_device *usb_dev_get_parent(struct usb_device *udev);
Hans de Goedee740ca32015-06-17 21:33:55 +020078
Ilya Yanokeb819552012-11-06 13:48:21 +000079#endif /* __USB_COMPAT_H__ */