1 #ifndef __USB_COMPAT_H__
2 #define __USB_COMPAT_H__
11 struct usb_host_endpoint {
12 struct usb_endpoint_descriptor desc;
13 struct list_head urb_list;
18 * urb->transfer_flags:
20 * Note: URB_DIR_IN/OUT is automatically set in usb_submit_urb().
22 #define URB_SHORT_NOT_OK 0x0001 /* report short reads as errors */
23 #define URB_ZERO_PACKET 0x0040 /* Finish bulk OUT with short packet */
27 typedef void (*usb_complete_t)(struct urb *);
30 void *hcpriv; /* private data for host controller */
31 struct list_head urb_list; /* list head for use by the urb's
33 struct usb_device *dev; /* (in) pointer to associated device */
34 struct usb_host_endpoint *ep; /* (internal) pointer to endpoint */
35 unsigned int pipe; /* (in) pipe information */
36 int status; /* (return) non-ISO status */
37 unsigned int transfer_flags; /* (in) URB_SHORT_NOT_OK | ...*/
38 void *transfer_buffer; /* (in) associated data buffer */
39 dma_addr_t transfer_dma; /* (in) dma addr for transfer_buffer */
40 u32 transfer_buffer_length; /* (in) data buffer length */
41 u32 actual_length; /* (return) actual transfer length */
42 unsigned char *setup_packet; /* (in) setup packet (control only) */
43 int start_frame; /* (modify) start frame (ISO) */
44 usb_complete_t complete; /* (in) completion routine */
47 #define usb_hcd_link_urb_to_ep(hcd, urb) ({ \
49 list_add_tail(&urb->urb_list, &urb->ep->urb_list); \
51 #define usb_hcd_unlink_urb_from_ep(hcd, urb) list_del_init(&urb->urb_list)
52 #define usb_hcd_check_unlink_urb(hdc, urb, status) 0
54 static inline void usb_hcd_giveback_urb(struct usb_hcd *hcd,
63 static inline int usb_hcd_unmap_urb_for_dma(struct usb_hcd *hcd,
66 /* TODO: add cache invalidation here */
70 #if CONFIG_IS_ENABLED(DM_USB)
71 static inline struct usb_device *usb_dev_get_parent(struct usb_device *udev)
73 struct udevice *parent = udev->dev->parent;
76 * When called from usb-uclass.c: usb_scan_device() udev->dev points
77 * to the parent udevice, not the actual udevice belonging to the
78 * udev as the device is not instantiated yet.
80 * If dev is an usb-bus, then we are called from usb_scan_device() for
81 * an usb-device plugged directly into the root port, return NULL.
83 if (device_get_uclass_id(udev->dev) == UCLASS_USB)
87 * If these 2 are not the same we are being called from
88 * usb_scan_device() and udev itself is the parent.
90 if (dev_get_parent_priv(udev->dev) != udev)
93 /* We are being called normally, use the parent pointer */
94 if (device_get_uclass_id(parent) == UCLASS_USB_HUB)
95 return dev_get_parent_priv(parent);
100 static inline struct usb_device *usb_dev_get_parent(struct usb_device *dev)
106 #endif /* __USB_COMPAT_H__ */