int usb_init(void) { int result; running = 0; dev_index = 0; asynch_allowed = 1; usb_hub_reset(); /* init low_level USB */ result = usb_lowlevel_init(); /* if lowlevel init is OK, scan the bus for devices i.e. search HUBs and configure them */ if(result == 0) { printf("scanning bus for devices...\n "); running = 1; /*empty port not scan*/ /*printf("port_connect_status:%x,usb_sel:%x\n",port_connect_status,usb_sel);*/ if (port_connect_status != usb_sel) { printf("Error, couldn't init Lowlevel part\n"); return -1; } result = usb_scan_devices(); if (result < 0 ) return -1; else return 0; } else { printf("Error, couldn't init Lowlevel part\n"); return -1; } }
int usb_init(void) { int result; running = 0; dev_index = 0; asynch_allowed = 1; usb_hub_reset(); /* init low_level USB */ printf("USB: "); result = usb_lowlevel_init(); /* if lowlevel init is OK, scan the bus for devices * i.e. search HUBs and configure them */ if (result == 0) { printf("scanning bus for devices... "); running = 1; usb_scan_devices(); usb_started = 1; return 0; } else { printf("Error, couldn't init Lowlevel part\n"); usb_started = 0; return -1; } }
/****************************************************************************** * Stop USB this stops the LowLevel Part and deregisters USB devices. */ int usb_stop(void) { asynch_allowed=1; usb_started = 0; usb_hub_reset(); return usb_lowlevel_stop(); }
int usb_init(void) { int result; void *ctrl; int i, start_index = 0; struct usb_device *dev; gpio_init_usb(1); running=0; dev_index=0; asynch_allowed=1; usb_hub_reset(); /* first make all devices unknown */ for (i = 0; i < USB_MAX_DEVICE; i++) { memset(&usb_dev[i], 0, sizeof(struct usb_device)); usb_dev[i].devnum = -1; } /* init low_level USB */ #define CONFIG_USB_MAX_CONTROLLER_COUNT 1 for (i = 0; i < CONFIG_USB_MAX_CONTROLLER_COUNT; i++) { /* init low_level USB */ printf("USB%d: ", i); if (usb_lowlevel_init(i, USB_INIT_HOST, &ctrl)) { puts("lowlevel init failed\n"); continue; } /* * lowlevel init is OK, now scan the bus for devices * i.e. search HUBs and configure them */ start_index = dev_index; printf("scanning bus %d for devices... ", i); dev = usb_alloc_new_device(ctrl); /* * device 0 is always present * (root hub, so let it analyze) */ if (dev) usb_new_device(dev); if (start_index == dev_index) puts("No USB Device found\n"); else printf("%d USB Device(s) found\n", dev_index - start_index); running = 1; } USB_PRINTF("scan end\n"); if (!running) { puts("USB error: all controllers failed lowlevel init\n"); return -1; } return 0; }
/*************************************************************************** * Init USB Device */ int usb_init(void) { void *ctrl; struct usb_device *dev; int i, start_index = 0; dev_index = 0; asynch_allowed = 1; usb_hub_reset(); /* first make all devices unknown */ for (i = 0; i < USB_MAX_DEVICE; i++) { memset(&usb_dev[i], 0, sizeof(struct usb_device)); usb_dev[i].devnum = -1; } /* init low_level USB */ for (i = 0; i < CONFIG_USB_MAX_CONTROLLER_COUNT; i++) { /* init low_level USB */ printf("USB%d: ", i); if (usb_lowlevel_init(i, USB_INIT_HOST, &ctrl)) { #if defined(CONFIG_OCTEON) && defined(CONFIG_OCTEON_OCX) if (i == 0) #endif puts("lowlevel init failed\n"); continue; } usb_controller_initialized[i] = true; /* * lowlevel init is OK, now scan the bus for devices * i.e. search HUBs and configure them */ start_index = dev_index; printf("scanning bus %d for devices... ", i); dev = usb_alloc_new_device(ctrl); /* * device 0 is always present * (root hub, so let it analyze) */ if (dev) usb_new_device(dev); if (start_index == dev_index) puts("No USB Device found\n"); else printf("%d USB Device(s) found\n", dev_index - start_index); usb_started = 1; } debug("scan end\n"); /* if we were not able to find at least one working bus, bail out */ if (!usb_started) { puts("USB error: all controllers failed lowlevel init\n"); return -1; } return 0; }
/****************************************************************************** * Stop USB this stops the LowLevel Part and deregisters USB devices. */ int usb_stop(int p) { int res = 0; asynch_allowed = 1; usb_started = 0; usb_hub_reset(); res = usb_lowlevel_stop(p); return res; }
int _usb_init(int port) { int result=0; #if 0 //#if defined (CONFIG_TITANIA8) || defined(CONFIG_JANUS2) // Force USB to use MIU0. *((unsigned char volatile *)(0xBF200000+0x600*2+0xF0*2+1)) = (*((unsigned char volatile *)(0xBF200000+0x600*2+0xF0*2+1)) & 0xF1) ; *((unsigned char volatile *)(0xBF200000+0x1200*2+0xF0*2+1)) = (*((unsigned char volatile *)(0xBF200000+0x1200*2+0xF0*2+1)) & 0xF1) ; #endif if ((port==0)||(port==1)||(port==2)) UsbPortSelect=port; else UsbPortSelect=0; //running=0; dev_index=0; asynch_allowed=1; printf("Check USB port[%d]:\n", port); usb_hub_reset(); /* init low_level USB */ //retry: result = usb_lowlevel_init(); /* if lowlevel init is OK, scan the bus for devices i.e. search HUBs and configure them */ if(result==0) { printf("scanning bus for devices... "); //running=1; result=usb_scan_devices(); if(result) { printf("Error, bad or unsupported device...\n"); usb_started = 0; return -1; } usb_started = 1; #if (CONFIG_COMMANDS & CFG_CMD_FAT) { char cmd_buf[32]; extern int snprintf(char *str, size_t size, const char *fmt, ...); memset(cmd_buf, 0 , sizeof(cmd_buf)); snprintf(cmd_buf, sizeof(cmd_buf), "setenv %s", ENV_PARTNO); run_command(cmd_buf, 0); } #endif return 0; } else { printf("Error, couldn't init Lowlevel part\n"); usb_started = 0; return -1; } }
/****************************************************************************** * Stop USB this stops the LowLevel Part and deregisters USB devices. */ int usb_stop(void) { int res = 0; if (usb_started) { asynch_allowed = 1; usb_started = 0; usb_hub_reset(); res = usb_lowlevel_stop(); } return res; }
/****************************************************************************** * Stop USB this stops the LowLevel Part and deregisters USB devices. */ int usb_stop(void) { int i; if (usb_started) { asynch_allowed = 1; usb_started = 0; usb_hub_reset(); for (i = 0; i < CONFIG_USB_MAX_CONTROLLER_COUNT; i++) { if (usb_lowlevel_stop(i)) printf("failed to stop USB controller %d\n", i); } } return 0; }
int usb_preinit(int port) { int result=0; #if 0 //#if defined (CONFIG_TITANIA8) || defined(CONFIG_JANUS2) // Force USB to use MIU0. *((unsigned char volatile *)(0xBF200000+0x600*2+0xF0*2+1)) = (*((unsigned char volatile *)(0xBF200000+0x600*2+0xF0*2+1)) & 0xF1) ; *((unsigned char volatile *)(0xBF200000+0x1200*2+0xF0*2+1)) = (*((unsigned char volatile *)(0xBF200000+0x1200*2+0xF0*2+1)) & 0xF1) ; #endif if ((port==0)||(port==1)||(port==2)) UsbPortSelect=port; else UsbPortSelect=0; //running=0; dev_index=0; asynch_allowed=1; printf("Preinit USB port[%d]:\n", port); usb_hub_reset(); /* init low_level USB */ //retry: result = usb_lowlevel_preinit(); /* if lowlevel init is OK, scan the bus for devices i.e. search HUBs and configure them */ if(result==0) { printf("scanning bus for devices... "); //running=1; result=usb_scan_devices(); if(result) { printf("Error, bad or unsupported device...\n"); usb_started = 0; return -1; } usb_started = 1; return 0; } else { //printf("Error, couldn't init Lowlevel part\n"); usb_started = 0; return -1; } }
/****************************************************************************** * Stop USB this stops the LowLevel Part and deregisters USB devices. */ int usb_stop(void) { int i, index = 0; if (usb_started) { asynch_allowed = 1; usb_started = 0; usb_hub_reset(); while (UsbDriverEntry[index].usb_lowlevel_stop) { for (i = 0; i < CONFIG_USB_MAX_CONTROLLER_COUNT; i++) { if (UsbDriverEntry[index].usb_lowlevel_stop(i)) printf("Failed to stop USB controller %d\r\n", i); } index++; } } return 0; }
static void usb_hub_events(void) { unsigned long flags; struct list_head *tmp; struct usb_device *dev; struct usb_hub *hub; struct usb_hub_status hubsts; u16 hubstatus; u16 hubchange; u16 portstatus; u16 portchange; int i, ret; /* * We restart the list everytime to avoid a deadlock with * deleting hubs downstream from this one. This should be * safe since we delete the hub from the event list. * Not the most efficient, but avoids deadlocks. */ DBG_HOST_HUB("### >>> Enter hub.c file --> usb_hub_events function \n"); while (1) { spin_lock_irqsave(&hub_event_lock, flags); if (list_empty(&hub_event_list)) break; /* Grab the next entry from the beginning of the list */ tmp = hub_event_list.next; hub = list_entry(tmp, struct usb_hub, event_list); dev = hub->dev; list_del(tmp); INIT_LIST_HEAD(tmp); down(&hub->khubd_sem); /* never blocks, we were on list */ spin_unlock_irqrestore(&hub_event_lock, flags); if (hub->error) { dbg("resetting hub %d for error %d", dev->devnum, hub->error); if (usb_hub_reset(hub)) { err("error resetting hub %d - disconnecting", dev->devnum); up(&hub->khubd_sem); usb_hub_disconnect(dev); continue; } hub->nerrors = 0; hub->error = 0; } for (i = 0; i < hub->descriptor->bNbrPorts; i++) { ret = usb_hub_port_status(dev, i, &portstatus, &portchange); if (ret < 0) { continue; } if (portchange & USB_PORT_STAT_C_CONNECTION) { dbg("port %d connection change", i + 1); usb_hub_port_connect_change(hub, i, portstatus, portchange); } else if (portchange & USB_PORT_STAT_C_ENABLE) { dbg("port %d enable change, status %x", i + 1, portstatus); usb_clear_port_feature(dev, i + 1, USB_PORT_FEAT_C_ENABLE); /* * EM interference sometimes causes bad shielded USB devices to * be shutdown by the hub, this hack enables them again. * Works at least with mouse driver. */ if (!(portstatus & USB_PORT_STAT_ENABLE) && (portstatus & USB_PORT_STAT_CONNECTION) && (dev->children[i])) { err("already running port %i disabled by hub (EMI?), re-enabling...", i + 1); usb_hub_port_connect_change(hub, i, portstatus, portchange); } } if (portchange & USB_PORT_STAT_C_SUSPEND) { dbg("port %d suspend change", i + 1); usb_clear_port_feature(dev, i + 1, USB_PORT_FEAT_C_SUSPEND); } if (portchange & USB_PORT_STAT_C_OVERCURRENT) { err("port %d over-current change", i + 1); usb_clear_port_feature(dev, i + 1, USB_PORT_FEAT_C_OVER_CURRENT); usb_hub_power_on(hub); } if (portchange & USB_PORT_STAT_C_RESET) { dbg("port %d reset change", i + 1); usb_clear_port_feature(dev, i + 1, USB_PORT_FEAT_C_RESET); } } /* end for i */ /* deal with hub status changes */ if (usb_get_hub_status(dev, &hubsts) < 0) err("get_hub_status failed"); else { hubstatus = le16_to_cpup(&hubsts.wHubStatus); hubchange = le16_to_cpup(&hubsts.wHubChange); if (hubchange & HUB_CHANGE_LOCAL_POWER) { dbg("hub power change"); usb_clear_hub_feature(dev, C_HUB_LOCAL_POWER); } if (hubchange & HUB_CHANGE_OVERCURRENT) { dbg("hub overcurrent change"); wait_ms(500); /* Cool down */ usb_clear_hub_feature(dev, C_HUB_OVER_CURRENT); usb_hub_power_on(hub); } } up(&hub->khubd_sem); } /* end while (1) */ spin_unlock_irqrestore(&hub_event_lock, flags); }
/*************************************************************************** * Init USB Device */ int usb_init(void) { void *ctrl; struct usb_device *dev; int i, start_index = 0; int controllers_initialized = 0; int ret; dev_index = 0; asynch_allowed = 1; usb_hub_reset(); /* first make all devices unknown */ for (i = 0; i < USB_MAX_DEVICE; i++) { memset(&usb_dev[i], 0, sizeof(struct usb_device)); usb_dev[i].devnum = -1; } /* init low_level USB */ for (i = 0; i < CONFIG_USB_MAX_CONTROLLER_COUNT; i++) { /* init low_level USB */ printf("USB%d: ", i); ret = usb_lowlevel_init(i, USB_INIT_HOST, &ctrl); if (ret == -ENODEV) { /* No such device. */ puts("Port not available.\n"); controllers_initialized++; continue; } if (ret) { /* Other error. */ puts("lowlevel init failed\n"); continue; } /* * lowlevel init is OK, now scan the bus for devices * i.e. search HUBs and configure them */ controllers_initialized++; start_index = dev_index; printf("scanning bus %d for devices... ", i); ret = usb_alloc_new_device(ctrl, &dev); if (ret) break; /* * device 0 is always present * (root hub, so let it analyze) */ ret = usb_new_device(dev); if (ret) usb_free_device(dev->controller); if (start_index == dev_index) { puts("No USB Device found\n"); continue; } else { printf("%d USB Device(s) found\n", dev_index - start_index); } usb_started = 1; } debug("scan end\n"); /* if we were not able to find at least one working bus, bail out */ if (controllers_initialized == 0) puts("USB error: all controllers failed lowlevel init\n"); return usb_started ? 0 : -ENODEV; }