Commit f7f601002d26cd5afc2241728a1e4d6106044184

Authored by Stefan Roese
Committed by Marek Vasut
1 parent e4fb863f6d

usb: legacy_hub_port_reset(): Speedup hub reset handling

Start with a short USB hub reset delay of 20ms. This can be enough for
some configurations.

The 2nd delay at the end of the loop is completely removed. Since the
delay hasn't been long enough, a longer delay time of 200ms is assigned
and will be used in the next loop round.

This hub reset handling is also used in the v4.4 Linux USB driver,
hub_port_reset().

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Simon Glass <sjg@chromium.org>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Tested-by: Stephen Warren <swarren@nvidia.com>
Cc: Marek Vasut <marex@denx.de>

Showing 1 changed file with 7 additions and 2 deletions Side-by-side Diff

... ... @@ -46,6 +46,9 @@
46 46  
47 47 #define USB_BUFSIZ 512
48 48  
  49 +#define HUB_SHORT_RESET_TIME 20
  50 +#define HUB_LONG_RESET_TIME 200
  51 +
49 52 /* TODO(sjg@chromium.org): Remove this when CONFIG_DM_USB is defined */
50 53 static struct usb_hub_device hub_dev[USB_MAX_HUB];
51 54 static int usb_hub_index;
... ... @@ -164,6 +167,7 @@
164 167 int err, tries;
165 168 ALLOC_CACHE_ALIGN_BUFFER(struct usb_port_status, portsts, 1);
166 169 unsigned short portstatus, portchange;
  170 + int delay = HUB_SHORT_RESET_TIME; /* start with short reset delay */
167 171  
168 172 #ifdef CONFIG_DM_USB
169 173 debug("%s: resetting '%s' port %d...\n", __func__, dev->dev->name,
... ... @@ -176,7 +180,7 @@
176 180 if (err < 0)
177 181 return err;
178 182  
179   - mdelay(200);
  183 + mdelay(delay);
180 184  
181 185 if (usb_get_port_status(dev, port + 1, portsts) < 0) {
182 186 debug("get_port_status failed status %lX\n",
... ... @@ -215,7 +219,8 @@
215 219 if (portstatus & USB_PORT_STAT_ENABLE)
216 220 break;
217 221  
218   - mdelay(200);
  222 + /* Switch to long reset delay for the next round */
  223 + delay = HUB_LONG_RESET_TIME;
219 224 }
220 225  
221 226 if (tries == MAX_TRIES) {