]> git.sur5r.net Git - u-boot/blobdiff - common/usb.c
VIDEO: davinci: add framebuffer to da8xx
[u-boot] / common / usb.c
index 4f7c520b344d7676d20a604be5c63d96b672efac..bed51165053ad0e2cbf90639b551ed33c6be60ed 100644 (file)
 #endif
 
 #ifdef DEBUG
-#define USB_DEBUG
-#define USB_HUB_DEBUG
-#endif
-
-#ifdef USB_DEBUG
-#define        USB_PRINTF(fmt, args...)        printf(fmt , ##args)
+#define USB_DEBUG      1
+#define USB_HUB_DEBUG  1
 #else
-#define USB_PRINTF(fmt, args...)
+#define USB_DEBUG      0
+#define USB_HUB_DEBUG  0
 #endif
 
+#define USB_PRINTF(fmt, args...)       debug_cond(USB_DEBUG, fmt, ##args)
+#define USB_HUB_PRINTF(fmt, args...)   debug_cond(USB_HUB_DEBUG, fmt, ##args)
+
 #define USB_BUFSIZ     512
 
 static struct usb_device usb_dev[USB_MAX_DEVICE];
@@ -328,7 +328,6 @@ int usb_parse_config(struct usb_device *dev, unsigned char *buffer, int cfgno)
        struct usb_descriptor_header *head;
        int index, ifno, epno, curr_if_num;
        int i;
-       unsigned char *ch;
 
        ifno = -1;
        epno = -1;
@@ -386,7 +385,9 @@ int usb_parse_config(struct usb_device *dev, unsigned char *buffer, int cfgno)
                                   head->bDescriptorType);
 
                        {
-                               ch = (unsigned char *)head;
+#ifdef USB_DEBUG
+                               unsigned char *ch = (unsigned char *)head;
+#endif
                                for (i = 0; i < head->bLength; i++)
                                        USB_PRINTF("%02X ", *ch++);
                                USB_PRINTF("\n\n\n");
@@ -957,8 +958,8 @@ void usb_scan_devices(void)
        /* insert "driver" if possible */
 #ifdef CONFIG_USB_KEYBOARD
        drv_usb_kbd_init();
-       USB_PRINTF("scan end\n");
 #endif
+       USB_PRINTF("scan end\n");
 }
 
 
@@ -967,13 +968,6 @@ void usb_scan_devices(void)
  * Probes device for being a hub and configurate it
  */
 
-#ifdef USB_HUB_DEBUG
-#define        USB_HUB_PRINTF(fmt, args...)    printf(fmt , ##args)
-#else
-#define USB_HUB_PRINTF(fmt, args...)
-#endif
-
-
 static struct usb_hub_device hub_dev[USB_MAX_HUB];
 static int usb_hub_index;
 
@@ -1120,7 +1114,7 @@ void usb_hub_port_connect_change(struct usb_device *dev, int port)
 {
        struct usb_device *usb;
        struct usb_port_status portsts;
-       unsigned short portstatus, portchange;
+       unsigned short portstatus;
 
        /* Check status */
        if (usb_get_port_status(dev, port + 1, &portsts) < 0) {
@@ -1129,9 +1123,10 @@ void usb_hub_port_connect_change(struct usb_device *dev, int port)
        }
 
        portstatus = le16_to_cpu(portsts.wPortStatus);
-       portchange = le16_to_cpu(portsts.wPortChange);
        USB_HUB_PRINTF("portstatus %x, change %x, %s\n",
-                       portstatus, portchange, portspeed(portstatus));
+                       portstatus,
+                       le16_to_cpu(portsts.wPortChange),
+                       portspeed(portstatus));
 
        /* Clear the connection change status */
        usb_clear_port_feature(dev, port + 1, USB_PORT_FEAT_C_CONNECTION);
@@ -1166,6 +1161,7 @@ void usb_hub_port_connect_change(struct usb_device *dev, int port)
 
        dev->children[port] = usb;
        usb->parent = dev;
+       usb->portnr = port + 1;
        /* Run it through the hoops (find a driver, etc) */
        if (usb_new_device(usb)) {
                /* Woops, disable the port */
@@ -1177,11 +1173,13 @@ void usb_hub_port_connect_change(struct usb_device *dev, int port)
 
 int usb_hub_configure(struct usb_device *dev)
 {
+       int i;
        unsigned char buffer[USB_BUFSIZ], *bitmap;
        struct usb_hub_descriptor *descriptor;
-       struct usb_hub_status *hubsts;
-       int i;
        struct usb_hub_device *hub;
+#ifdef USB_HUB_DEBUG
+       struct usb_hub_status *hubsts;
+#endif
 
        /* "allocate" Hub device */
        hub = usb_hub_allocate();
@@ -1283,7 +1281,9 @@ int usb_hub_configure(struct usb_device *dev)
                return -1;
        }
 
+#ifdef USB_HUB_DEBUG
        hubsts = (struct usb_hub_status *)buffer;
+#endif
        USB_HUB_PRINTF("get_hub_status returned status %X, change %X\n",
                        le16_to_cpu(hubsts->wHubStatus),
                        le16_to_cpu(hubsts->wHubChange));