usb: lowlevel interface change to support multiple controllers
Carry an index in the lowlevel usb functions to make specify the
respective usb controller.
Also pass through an controller struct from lowlevel_init to the
creation of the root usb device of this controller.
Signed-off-by: Lucas Stach <dev@lynxeye.de>
Reviewed-by: Marek Vasut <marex@denx.de>
diff --git a/common/usb.c b/common/usb.c
index 1b40228..e58b6f4 100644
--- a/common/usb.c
+++ b/common/usb.c
@@ -76,6 +76,7 @@
static int asynch_allowed;
char usb_started; /* flag for the started/stopped USB status */
+void *ctrl; /* goes away in a following commit, but don't break bisect */
/**********************************************************************
* some forward declerations...
@@ -96,7 +97,7 @@
usb_hub_reset();
/* init low_level USB */
printf("USB: ");
- result = usb_lowlevel_init();
+ result = usb_lowlevel_init(0, &ctrl);
/* if lowlevel init is OK, scan the bus for devices
* i.e. search HUBs and configure them */
if (result == 0) {
@@ -123,7 +124,7 @@
asynch_allowed = 1;
usb_started = 0;
usb_hub_reset();
- res = usb_lowlevel_stop();
+ res = usb_lowlevel_stop(0);
}
return res;
}
@@ -754,7 +755,7 @@
/* returns a pointer of a new device structure or NULL, if
* no device struct is available
*/
-struct usb_device *usb_alloc_new_device(void)
+struct usb_device *usb_alloc_new_device(void *controller)
{
int i;
USB_PRINTF("New Device %d\n", dev_index);
@@ -768,6 +769,7 @@
for (i = 0; i < USB_MAXCHILDREN; i++)
usb_dev[dev_index].children[i] = NULL;
usb_dev[dev_index].parent = NULL;
+ usb_dev[dev_index].controller = controller;
dev_index++;
return &usb_dev[dev_index - 1];
}
@@ -958,7 +960,7 @@
}
dev_index = 0;
/* device 0 is always present (root hub, so let it analyze) */
- dev = usb_alloc_new_device();
+ dev = usb_alloc_new_device(ctrl);
if (usb_new_device(dev))
printf("No USB Device found\n");
else