static void usb_hub_power_on(struct usb_hub_device *hub) { int i; struct usb_device *dev; unsigned pgood_delay = hub->desc.bPwrOn2PwrGood * 2; dev = hub->pusb_dev; /* * Enable power to the ports: * Here we Power-cycle the ports: aka, * turning them off and turning on again. */ for (i = 0; i < dev->maxchild; i++) { usb_clear_port_feature(dev, i + 1, USB_PORT_FEAT_POWER); dev_dbg(&dev->dev, "port %d returns %lX\n", i + 1, dev->status); } /* Wait at least 2 * bPwrOn2PwrGood for PP to change */ mdelay(pgood_delay); /* Enable power to the ports */ dev_dbg(&dev->dev, "enabling power on all ports\n"); for (i = 0; i < dev->maxchild; i++) { usb_set_port_feature(dev, i + 1, USB_PORT_FEAT_POWER); dev_dbg(&dev->dev, "port %d returns %lX\n", i + 1, dev->status); } /* power on is encoded in 2ms increments -> times 2 for the actual delay */ mdelay(pgood_delay + 1000); }
static int usb_hub_port_reset(USB_DEV_T *hub, int port, USB_DEV_T *dev, uint32_t delay) { int i; USB_info("usb_hub_port_reset: hub:%d, port:%d dev:%x\n", hub->devnum, port + 1, (int)dev); /* Reset the port */ for(i = 0; i < HUB_RESET_TRIES; i++) /* retry loop */ { usb_set_port_feature(hub, port + 1, USB_PORT_FEAT_RESET); /* return success if the port reset OK */ if(!usb_hub_port_wait_reset(hub, port, dev, delay)) { usb_clear_port_feature(hub, port + 1, USB_PORT_FEAT_C_RESET); return 0; } USB_error("port %d of hub %d not enabled, %dth trying reset again...\n", port + 1, hub->devnum, i); delay = HUB_LONG_RESET_TIME; } USB_error("Cannot enable port %i of hub %d, disabling port.\n", port + 1, hub->devnum); USB_error("Error - Maybe the USB cable is bad?\n"); return -1; }
/* return: -1 on error, 0 on success, 1 on disconnect. */ static int usb_hub_port_reset(struct usb_device *hub, int port, struct usb_device *dev, unsigned int delay) { int i, status; usb_enable_pci_slot1_frame(__LINE__); // Ed Lai 2005/06/25 /* Reset the port */ for (i = 0; i < HUB_RESET_TRIES; i++) { usb_set_port_feature(hub, port + 1, USB_PORT_FEAT_RESET); /* return on disconnect or reset */ status = usb_hub_port_wait_reset(hub, port, dev, delay); if (status != -1) { usb_clear_port_feature(hub, port + 1, USB_PORT_FEAT_C_RESET); return status; } dbg("port %d of hub %d not enabled, trying reset again...", port + 1, hub->devnum); delay = HUB_LONG_RESET_TIME; } err("Cannot enable port %i of hub %d, disabling port.", port + 1, hub->devnum); err("Maybe the USB cable is bad?"); return -1; }
static int usb_hub_port_reset(struct usb_device *hub, int port, struct usb_device *dev, unsigned int delay) { int i; /* Reset the port */ for (i = 0; i < HUB_RESET_TRIES; i++) { usb_set_port_feature(hub, port + 1, USB_PORT_FEAT_RESET); /* return success if the port reset OK */ if (!usb_hub_port_wait_reset(hub, port, dev, delay)) { usb_clear_port_feature(hub, port + 1, USB_PORT_FEAT_C_RESET); return 0; } dbg("port %d of hub %d not enabled, trying reset again...", port + 1, hub->devnum); delay = HUB_LONG_RESET_TIME; } err("Cannot enable port %i of hub %d, disabling port.", port + 1, hub->devnum); err("Maybe the USB cable is bad?"); return -1; }
/* return: -1 on error, 0 on success, 1 on disconnect. */ static int usb_hub_port_reset(struct usb_device *hub, int port, struct usb_device *dev, unsigned int delay) { int i, status; /* Reset the port */ for (i = 0; i < HUB_RESET_TRIES; i++) { usb_set_port_feature(hub, port + 1, USB_PORT_FEAT_RESET); /* return on disconnect or reset */ status = usb_hub_port_wait_reset(hub, port, dev, delay); if (status != -1) { usb_clear_port_feature(hub, port + 1, USB_PORT_FEAT_C_RESET); return status; } dbg("port %d of hub %d not enabled, trying reset again...", port + 1, hub->devnum); delay = HUB_LONG_RESET_TIME; } //2005-01-21 by kanki for fixing usb loop issue (temporary solution from broadcom) //err("Cannot enable port %i of hub %d, disabling port.", // port + 1, hub->devnum); //err("Maybe the USB cable is bad?"); return -1; }
static void usb_hub_power_on(struct usb_hub_device *hub) { int i; struct usb_device *dev; unsigned pgood_delay = hub->desc.bPwrOn2PwrGood * 2; const char *env; dev = hub->pusb_dev; debug("enabling power on all ports\n"); for (i = 0; i < dev->maxchild; i++) { usb_set_port_feature(dev, i + 1, USB_PORT_FEAT_POWER); debug("port %d returns %lX\n", i + 1, dev->status); } /* * Wait for power to become stable, * plus spec-defined max time for device to connect * but allow this time to be increased via env variable as some * devices break the spec and require longer warm-up times */ env = getenv("usb_pgood_delay"); if (env) pgood_delay = max(pgood_delay, (unsigned)simple_strtol(env, NULL, 0)); debug("pgood_delay=%dms\n", pgood_delay); mdelay(pgood_delay + 1000); }
/* return: -1 on error, 0 on success, 1 on disconnect. */ static int usb_hub_port_reset(struct usb_device *hub, int port, struct usb_device *dev, unsigned int delay) { int i, status; /* Reset the port */ for (i = 0; i < HUB_RESET_TRIES; i++) { usb_set_port_feature(hub, port + 1, USB_PORT_FEAT_RESET); /* return on disconnect or reset */ status = usb_hub_port_wait_reset(hub, port, dev, delay); // !!TB - dd-wrt fix for USB 2.0 if (status == 0) { /* TRSTRCY = 10 ms; plus some extra */ wait_ms(10 + 40); } if (status != -1) { usb_clear_port_feature(hub, port + 1, USB_PORT_FEAT_C_RESET); return status; } dbg("port %d of hub %d not enabled, trying reset again...", port + 1, hub->devnum); delay = HUB_LONG_RESET_TIME; } err("Cannot enable port %i of hub %d, disabling port.", port + 1, hub->devnum); err("Maybe the USB cable is bad?"); return -1; }
/* return: -1 on error, 0 on success, 1 on disconnect. */ static int usb_hub_port_reset(struct usb_device *hub, int port, struct usb_device *dev, unsigned int delay) { int i, status; DBG_HOST_HUB("### >>> Enter hub.c file --> usb_hub_port_reset function \n"); /* Reset the port */ for (i = 0; i < HUB_RESET_TRIES; i++) { usb_set_port_feature(hub, port + 1, USB_PORT_FEAT_RESET); /* return on disconnect or reset */ status = usb_hub_port_wait_reset(hub, port, dev, delay); if (status != -1) { usb_clear_port_feature(hub, port + 1, USB_PORT_FEAT_C_RESET); return status; } dbg("port %d of hub %d not enabled, trying reset again...", port + 1, hub->devnum); delay = HUB_LONG_RESET_TIME; } err("Cannot enable port %i of hub %d, disabling port.", port + 1, hub->devnum); err("Maybe the USB cable is bad?"); return -1; }
static void usb_hub_power_on(struct usb_hub_device *hub) { int i; struct usb_device *dev; unsigned pgood_delay = hub->desc.bPwrOn2PwrGood * 2; ALLOC_CACHE_ALIGN_BUFFER(struct usb_port_status, portsts, 1); unsigned short portstatus; int ret; dev = hub->pusb_dev; /* * Enable power to the ports: * Here we Power-cycle the ports: aka, * turning them off and turning on again. */ debug("enabling power on all ports\n"); for (i = 0; i < dev->maxchild; i++) { usb_clear_port_feature(dev, i + 1, USB_PORT_FEAT_POWER); debug("port %d returns %lX\n", i + 1, dev->status); } /* Wait at least 2*bPwrOn2PwrGood for PP to change */ mdelay(pgood_delay); for (i = 0; i < dev->maxchild; i++) { ret = usb_get_port_status(dev, i + 1, portsts); if (ret < 0) { debug("port %d: get_port_status failed\n", i + 1); return; } /* * Check to confirm the state of Port Power: * xHCI says "After modifying PP, s/w shall read * PP and confirm that it has reached the desired state * before modifying it again, undefined behavior may occur * if this procedure is not followed". * EHCI doesn't say anything like this, but no harm in keeping * this. */ portstatus = le16_to_cpu(portsts->wPortStatus); if (portstatus & (USB_PORT_STAT_POWER << 1)) { debug("port %d: Port power change failed\n", i + 1); return; } } for (i = 0; i < dev->maxchild; i++) { usb_set_port_feature(dev, i + 1, USB_PORT_FEAT_POWER); debug("port %d returns %lX\n", i + 1, dev->status); } /* Wait for power to become stable */ mdelay(max(pgood_delay, CONFIG_USB_HUB_MIN_POWER_ON_DELAY)); }
static void usb_hub_power_on(struct usb_hub *hub) { int i; /* Enable power to the ports */ dbg("enabling power on all ports"); for (i = 0; i < hub->descriptor->bNbrPorts; i++) usb_set_port_feature(hub->dev, i + 1, USB_PORT_FEAT_POWER); /* Wait for power to be enabled */ wait_ms(hub->descriptor->bPwrOn2PwrGood * 2); }
int hub_port_reset(struct usb_device *dev, int port, unsigned short *portstat) { int tries; struct usb_port_status portsts; unsigned short portstatus, portchange; dev_dbg(&dev->dev, "hub_port_reset: resetting port %d...\n", port); for (tries = 0; tries < MAX_TRIES; tries++) { usb_set_port_feature(dev, port + 1, USB_PORT_FEAT_RESET); mdelay(200); if (usb_get_port_status(dev, port + 1, &portsts) < 0) { dev_dbg(&dev->dev, "get_port_status failed status %lX\n", dev->status); return -1; } portstatus = le16_to_cpu(portsts.wPortStatus); portchange = le16_to_cpu(portsts.wPortChange); dev_dbg(&dev->dev, "portstatus %x, change %x, %s\n", portstatus, portchange, portspeed(portstatus)); dev_dbg(&dev->dev, "STAT_C_CONNECTION = %d STAT_CONNECTION = %d" \ " USB_PORT_STAT_ENABLE %d\n", (portchange & USB_PORT_STAT_C_CONNECTION) ? 1 : 0, (portstatus & USB_PORT_STAT_CONNECTION) ? 1 : 0, (portstatus & USB_PORT_STAT_ENABLE) ? 1 : 0); if ((portchange & USB_PORT_STAT_C_CONNECTION) || !(portstatus & USB_PORT_STAT_CONNECTION)) return -1; if (portstatus & USB_PORT_STAT_ENABLE) break; mdelay(200); } if (tries == MAX_TRIES) { dev_dbg(&dev->dev, "Cannot enable port %i after %i retries, " \ "disabling port.\n", port + 1, MAX_TRIES); dev_dbg(&dev->dev, "Maybe the USB cable is bad?\n"); return -1; } usb_clear_port_feature(dev, port + 1, USB_PORT_FEAT_C_RESET); *portstat = portstatus; return 0; }
static void usb_hub_power_on(struct usb_hub *hub) { int i; unsigned pgood_delay = hub->descriptor->bPwrOn2PwrGood * 2; /* Enable power to the ports */ dbg("enabling power on all ports"); for (i = 0; i < hub->descriptor->bNbrPorts; i++) usb_set_port_feature(hub->dev, i + 1, USB_PORT_FEAT_POWER); /* Wait at least 100 msec for power to become stable */ wait_ms(max(pgood_delay, (unsigned) 100)); }
static void usb_hub_power_on(USB_HUB_T *hub) { int i; /* Enable power to the ports */ for(i = 0; i < hub->descriptor.bNbrPorts; i++) { USB_info("enable port:%d of hub:%d\n", i + 1, hub->dev->devnum); usb_set_port_feature(hub->dev, i + 1, USB_PORT_FEAT_POWER); } /* Wait for power to be enabled */ usbh_mdelay(hub->descriptor.bPwrOn2PwrGood * 2); }
static void usb_hub_power_on(struct usb_hub_device *hub) { int i; struct usb_device *dev; unsigned pgood_delay = hub->desc.bPwrOn2PwrGood * 2; dev = hub->pusb_dev; /* Enable power to the ports */ USB_HUB_PRINTF("enabling power on all ports\n"); for (i = 0; i < dev->maxchild; i++) { usb_set_port_feature(dev, i + 1, USB_PORT_FEAT_POWER); USB_HUB_PRINTF("port %d returns %lX\n", i + 1, dev->status); } /* Wait at least 100 msec for power to become stable */ mdelay(max(pgood_delay, (unsigned)100)); }
static void usb_hub_power_on(struct usb_hub_device *hub) { int i; struct usb_device *dev; unsigned pgood_delay = hub->desc.bPwrOn2PwrGood * 2; dev = hub->pusb_dev; debug("enabling power on all ports\n"); for (i = 0; i < dev->maxchild; i++) { usb_set_port_feature(dev, i + 1, USB_PORT_FEAT_POWER); debug("port %d returns %lX\n", i + 1, dev->status); } /* * Wait for power to become stable, * plus spec-defined max time for device to connect */ mdelay(pgood_delay + 1000); }
int hub_port_reset(struct usb_device *dev, int port, unsigned short *portstat) { int tries; ALLOC_CACHE_ALIGN_BUFFER(struct usb_port_status, portsts, 1); unsigned short portstatus, portchange; debug("hub_port_reset: resetting port %d...\n", port); for (tries = 0; tries < MAX_TRIES; tries++) { usb_set_port_feature(dev, port + 1, USB_PORT_FEAT_RESET); mdelay(200); if (usb_get_port_status(dev, port + 1, portsts) < 0) { debug("get_port_status failed status %lX\n", dev->status); return -1; } portstatus = le16_to_cpu(portsts->wPortStatus); portchange = le16_to_cpu(portsts->wPortChange); debug("portstatus %x, change %x, %s\n", portstatus, portchange, portspeed(portstatus)); debug("STAT_C_CONNECTION = %d STAT_CONNECTION = %d" \ " USB_PORT_STAT_ENABLE %d\n", (portchange & USB_PORT_STAT_C_CONNECTION) ? 1 : 0, (portstatus & USB_PORT_STAT_CONNECTION) ? 1 : 0, (portstatus & USB_PORT_STAT_ENABLE) ? 1 : 0); /* * Perhaps we should check for the following here: * - C_CONNECTION hasn't been set. * - CONNECTION is still set. * * Doing so would ensure that the device is still connected * to the bus, and hasn't been unplugged or replaced while the * USB bus reset was going on. * * However, if we do that, then (at least) a San Disk Ultra * USB 3.0 16GB device fails to reset on (at least) an NVIDIA * Tegra Jetson TK1 board. For some reason, the device appears * to briefly drop off the bus when this second bus reset is * executed, yet if we retry this loop, it'll eventually come * back after another reset or two. */ if (portstatus & USB_PORT_STAT_ENABLE) break; mdelay(200); } if (tries == MAX_TRIES) { debug("Cannot enable port %i after %i retries, " \ "disabling port.\n", port + 1, MAX_TRIES); debug("Maybe the USB cable is bad?\n"); return -1; } usb_clear_port_feature(dev, port + 1, USB_PORT_FEAT_C_RESET); *portstat = portstatus; return 0; }
int hub_port_reset(struct usb_device *dev, int port, unsigned short *portstat) { int tries, status; unsigned delay = HUB_SHORT_RESET_TIME; int oldspeed = dev->speed; /* root hub ports have a slightly longer reset period * (from USB 2.0 spec, section 7.1.7.5) */ if (!dev->parent) { delay = HUB_ROOT_RESET_TIME; } /* Some low speed devices have problems with the quick delay, so */ /* be a bit pessimistic with those devices. RHbug #23670 */ if (oldspeed == USB_SPEED_LOW) delay = HUB_LONG_RESET_TIME; USB_HUB_PRINTF("hub_port_reset: resetting port %d...\n", port); for (tries = 0; tries < MAX_TRIES; tries++) { status = usb_set_port_feature(dev, port + 1, USB_PORT_FEAT_RESET); if (status) USB_HUB_PRINTF("cannot reset port %d (err = %d)\n", port, status); else { status = hub_port_wait_reset(dev, port, delay, portstat); if (status && status != -ENOTCONN) USB_HUB_PRINTF("port_wait_reset: err = %d\n", status); } /* return on disconnect or reset */ switch (status) { case 0: /* TRSTRCY = 10 ms; plus some extra */ mdelay(10 + 40); /* FALL THROUGH */ case -1: case -ENOTCONN: /* we have finished trying to reset, so return */ usb_clear_port_feature(dev, port + 1, USB_PORT_FEAT_C_RESET); return 0; } USB_HUB_PRINTF ( "port %d not enabled, trying reset again...\n", port); delay = HUB_LONG_RESET_TIME; } if (tries == MAX_TRIES) { USB_HUB_PRINTF("Cannot enable port %i after %i retries, " \ "disabling port.\n", port + 1, MAX_TRIES); USB_HUB_PRINTF("Maybe the USB cable is bad?\n"); return -1; } return 0; }