Merge branch 'for-next/usb'
This commit is contained in:
commit
12657cb99e
|
@ -22,24 +22,20 @@
|
|||
#include <usb/usb.h>
|
||||
#include <getopt.h>
|
||||
|
||||
static int scanned;
|
||||
|
||||
static int do_usb(int argc, char *argv[])
|
||||
{
|
||||
int opt;
|
||||
int force = 0;
|
||||
|
||||
while ((opt = getopt(argc, argv, "f")) > 0) {
|
||||
switch (opt) {
|
||||
case 'f':
|
||||
scanned = 0;
|
||||
force = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!scanned) {
|
||||
usb_rescan();
|
||||
scanned = 1;
|
||||
}
|
||||
usb_rescan(force);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -431,14 +431,22 @@ static int usb_new_device(struct usb_device *dev)
|
|||
if (dev->descriptor->iSerialNumber)
|
||||
usb_string(dev, dev->descriptor->iSerialNumber,
|
||||
dev->serial, sizeof(dev->serial));
|
||||
|
||||
if (parent) {
|
||||
sprintf(dev->dev.name, "%s-%d", parent->dev.name, port);
|
||||
} else {
|
||||
sprintf(dev->dev.name, "usb%d", dev->host->busnum);
|
||||
}
|
||||
|
||||
dev->dev.id = DEVICE_ID_SINGLE;
|
||||
|
||||
register_device(&dev->dev);
|
||||
|
||||
/* now prode if the device is a hub */
|
||||
usb_hub_probe(dev, 0);
|
||||
|
||||
sprintf(dev->dev.name, "usb%d-%d", dev->host->busnum, dev->devnum);
|
||||
|
||||
print_usb_device(dev);
|
||||
|
||||
register_device(&dev->dev);
|
||||
dev_add_param_int_ro(&dev->dev, "iManufacturer",
|
||||
dev->descriptor->iManufacturer, "%d");
|
||||
dev_add_param_int_ro(&dev->dev, "iProduct",
|
||||
|
@ -480,13 +488,18 @@ static struct usb_device *usb_alloc_new_device(void)
|
|||
return usbdev;
|
||||
}
|
||||
|
||||
void usb_rescan(void)
|
||||
int usb_host_detect(struct usb_host *host, int force)
|
||||
{
|
||||
struct usb_device *dev, *tmp;
|
||||
struct usb_host *host;
|
||||
int ret;
|
||||
|
||||
if (host->scanned && !force)
|
||||
return -EBUSY;
|
||||
|
||||
list_for_each_entry_safe(dev, tmp, &usb_device_list, list) {
|
||||
if (dev->host != host)
|
||||
continue;
|
||||
|
||||
list_del(&dev->list);
|
||||
unregister_device(&dev->dev);
|
||||
if (dev->hub)
|
||||
|
@ -496,17 +509,31 @@ void usb_rescan(void)
|
|||
free(dev);
|
||||
}
|
||||
|
||||
ret = host->init(host);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
dev = usb_alloc_new_device();
|
||||
dev->host = host;
|
||||
usb_new_device(dev);
|
||||
|
||||
host->scanned = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void usb_rescan(int force)
|
||||
{
|
||||
struct usb_host *host;
|
||||
int ret;
|
||||
|
||||
printf("USB: scanning bus for devices...\n");
|
||||
dev_index = 0;
|
||||
|
||||
list_for_each_entry(host, &host_list, list) {
|
||||
ret = host->init(host);
|
||||
ret = usb_host_detect(host, force);
|
||||
if (ret)
|
||||
continue;
|
||||
|
||||
dev = usb_alloc_new_device();
|
||||
dev->host = host;
|
||||
usb_new_device(dev);
|
||||
}
|
||||
|
||||
printf("%d USB Device(s) found\n", dev_index);
|
||||
|
|
|
@ -850,6 +850,13 @@ submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
|
|||
return -1;
|
||||
}
|
||||
|
||||
static int ehci_detect(struct device_d *dev)
|
||||
{
|
||||
struct ehci_priv *ehci = dev->priv;
|
||||
|
||||
return usb_host_detect(&ehci->host, 0);
|
||||
}
|
||||
|
||||
int ehci_register(struct device_d *dev, struct ehci_data *data)
|
||||
{
|
||||
struct usb_host *host;
|
||||
|
@ -885,6 +892,8 @@ int ehci_register(struct device_d *dev, struct ehci_data *data)
|
|||
ehci_reset(ehci);
|
||||
}
|
||||
|
||||
dev->detect = ehci_detect;
|
||||
|
||||
usb_register_host(host);
|
||||
|
||||
reg = HC_VERSION(ehci_readl(&ehci->hccr->cr_capbase));
|
||||
|
|
|
@ -211,10 +211,13 @@ struct usb_host {
|
|||
struct list_head list;
|
||||
|
||||
int busnum;
|
||||
int scanned;
|
||||
};
|
||||
|
||||
int usb_register_host(struct usb_host *);
|
||||
|
||||
int usb_host_detect(struct usb_host *host, int force);
|
||||
|
||||
/* Defines */
|
||||
#define USB_UHCI_VEND_ID 0x8086
|
||||
#define USB_UHCI_DEV_ID 0x7112
|
||||
|
@ -248,7 +251,7 @@ int usb_clear_halt(struct usb_device *dev, int pipe);
|
|||
int usb_string(struct usb_device *dev, int index, char *buf, size_t size);
|
||||
int usb_set_interface(struct usb_device *dev, int interface, int alternate);
|
||||
|
||||
void usb_rescan(void);
|
||||
void usb_rescan(int force);
|
||||
|
||||
/* big endian -> little endian conversion */
|
||||
/* some CPUs are already little endian e.g. the ARM920T */
|
||||
|
|
Loading…
Reference in New Issue