From 87b9bea20e922a46f661d69f7b5ae900159914f1 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Thu, 10 Jul 2014 15:04:35 +0200 Subject: USB: host: hub: Use usb_hub_power_on from U-Boot U-Boots power good delay function is more conservative than ours. Use it to be on the safe side. The U-Boot guys have discussed a lot about it, let's hope they got it right. Signed-off-by: Sascha Hauer --- drivers/usb/core/hub.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 6d5e3b97f8..9c87037888 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -70,16 +70,33 @@ 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(hub->desc.bPwrOn2PwrGood*2); + mdelay(pgood_delay + 1000); } #define MAX_TRIES 5 -- cgit v1.2.3