mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-12-02 01:19:49 +00:00
musb: Update usb-compat to work with struct usb_device without a parent ptr
When building with CONFIG_DM_USB=y struct usb_device does not have a parent pointer. This commit adds support to the musb code to deal with this. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Acked-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
1583723638
commit
e740ca3cab
3 changed files with 75 additions and 1 deletions
|
@ -2067,7 +2067,11 @@ int musb_urb_enqueue(
|
||||||
|
|
||||||
/* precompute addressing for external hub/tt ports */
|
/* precompute addressing for external hub/tt ports */
|
||||||
if (musb->is_multipoint) {
|
if (musb->is_multipoint) {
|
||||||
|
#ifndef __UBOOT__
|
||||||
struct usb_device *parent = urb->dev->parent;
|
struct usb_device *parent = urb->dev->parent;
|
||||||
|
#else
|
||||||
|
struct usb_device *parent = usb_dev_get_parent(urb->dev);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef __UBOOT__
|
#ifndef __UBOOT__
|
||||||
if (parent != hcd->self.root_hub) {
|
if (parent != hcd->self.root_hub) {
|
||||||
|
|
|
@ -97,7 +97,7 @@ int submit_control_msg(struct usb_device *dev, unsigned long pipe,
|
||||||
buffer, len, setup, 0);
|
buffer, len, setup, 0);
|
||||||
|
|
||||||
/* Fix speed for non hub-attached devices */
|
/* Fix speed for non hub-attached devices */
|
||||||
if (!dev->parent)
|
if (!usb_dev_get_parent(dev))
|
||||||
dev->speed = host_speed;
|
dev->speed = host_speed;
|
||||||
|
|
||||||
return submit_urb(&hcd, &urb);
|
return submit_urb(&hcd, &urb);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#ifndef __USB_COMPAT_H__
|
#ifndef __USB_COMPAT_H__
|
||||||
#define __USB_COMPAT_H__
|
#define __USB_COMPAT_H__
|
||||||
|
|
||||||
|
#include <dm.h>
|
||||||
#include "usb.h"
|
#include "usb.h"
|
||||||
|
|
||||||
struct usb_hcd {
|
struct usb_hcd {
|
||||||
|
@ -66,6 +67,68 @@ static inline int usb_hcd_unmap_urb_for_dma(struct usb_hcd *hcd,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_DM_USB
|
||||||
|
static inline u16 find_tt(struct usb_device *udev)
|
||||||
|
{
|
||||||
|
struct udevice *parent;
|
||||||
|
struct usb_device *uparent, *ttdev;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When called from usb-uclass.c: usb_scan_device() udev->dev points
|
||||||
|
* to the parent udevice, not the actual udevice belonging to the
|
||||||
|
* udev as the device is not instantiated yet. So when searching
|
||||||
|
* for the first usb-2 parent start with udev->dev not
|
||||||
|
* udev->dev->parent .
|
||||||
|
*/
|
||||||
|
ttdev = udev;
|
||||||
|
parent = udev->dev;
|
||||||
|
uparent = dev_get_parentdata(parent);
|
||||||
|
|
||||||
|
while (uparent->speed != USB_SPEED_HIGH) {
|
||||||
|
struct udevice *dev = parent;
|
||||||
|
|
||||||
|
if (device_get_uclass_id(dev->parent) != UCLASS_USB_HUB) {
|
||||||
|
printf("musb: Error cannot find high speed parent of usb-1 device\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ttdev = dev_get_parentdata(dev);
|
||||||
|
parent = dev->parent;
|
||||||
|
uparent = dev_get_parentdata(parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (uparent->devnum << 8) | (ttdev->portnr - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline struct usb_device *usb_dev_get_parent(struct usb_device *udev)
|
||||||
|
{
|
||||||
|
struct udevice *parent = udev->dev->parent;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When called from usb-uclass.c: usb_scan_device() udev->dev points
|
||||||
|
* to the parent udevice, not the actual udevice belonging to the
|
||||||
|
* udev as the device is not instantiated yet.
|
||||||
|
*
|
||||||
|
* If dev is an usb-bus, then we are called from usb_scan_device() for
|
||||||
|
* an usb-device plugged directly into the root port, return NULL.
|
||||||
|
*/
|
||||||
|
if (device_get_uclass_id(udev->dev) == UCLASS_USB)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If these 2 are not the same we are being called from
|
||||||
|
* usb_scan_device() and udev itself is the parent.
|
||||||
|
*/
|
||||||
|
if (dev_get_parentdata(udev->dev) != udev)
|
||||||
|
return udev;
|
||||||
|
|
||||||
|
/* We are being called normally, use the parent pointer */
|
||||||
|
if (device_get_uclass_id(parent) == UCLASS_USB_HUB)
|
||||||
|
return dev_get_parentdata(parent);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
#else
|
||||||
static inline u16 find_tt(struct usb_device *dev)
|
static inline u16 find_tt(struct usb_device *dev)
|
||||||
{
|
{
|
||||||
u8 chid;
|
u8 chid;
|
||||||
|
@ -86,4 +149,11 @@ static inline u16 find_tt(struct usb_device *dev)
|
||||||
|
|
||||||
return (hub << 8) | chid;
|
return (hub << 8) | chid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline struct usb_device *usb_dev_get_parent(struct usb_device *dev)
|
||||||
|
{
|
||||||
|
return dev->parent;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* __USB_COMPAT_H__ */
|
#endif /* __USB_COMPAT_H__ */
|
||||||
|
|
Loading…
Reference in a new issue