usb: ehci: remember init mode
authorStephen Warren <swarren@nvidia.com>
Thu, 20 Aug 2015 23:38:05 +0000 (17:38 -0600)
committerMarek Vasut <marex@denx.de>
Mon, 7 Sep 2015 11:41:05 +0000 (13:41 +0200)
When an EHCI device is registered in device mode, the HW isn't actually
initialized at all, and hence isn't left in a running state. Consequently,
when the device is deregistered, ehci_shutdown() will fail, since the HW
bits it expects to see set in response to its shutdown requests will not
be sent, and the message "EHCI failed to shut down host controller." will
be printed.

Fix ehci-hcd.c to remember whether the device was registered in host or
device mode, and only call ehci_shutdown() for host mode registrations.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
drivers/usb/host/ehci-hcd.c
drivers/usb/host/ehci.h

index 3a0d32e..88b670b 100644 (file)
@@ -1645,8 +1645,10 @@ int ehci_register(struct udevice *dev, struct ehci_hccr *hccr,
        ctrl->hcor = hcor;
        ctrl->priv = ctrl;
 
-       if (init == USB_INIT_DEVICE)
+       ctrl->init = init;
+       if (ctrl->init == USB_INIT_DEVICE)
                goto done;
+
        ret = ehci_reset(ctrl);
        if (ret)
                goto err;
@@ -1666,6 +1668,9 @@ int ehci_deregister(struct udevice *dev)
 {
        struct ehci_ctrl *ctrl = dev_get_priv(dev);
 
+       if (ctrl->init == USB_INIT_DEVICE)
+               return 0;
+
        ehci_shutdown(ctrl);
 
        return 0;
index 3379c29..b41c04a 100644 (file)
@@ -242,6 +242,7 @@ struct ehci_ops {
 };
 
 struct ehci_ctrl {
+       enum usb_init_type init;
        struct ehci_hccr *hccr; /* R/O registers, not need for volatile */
        struct ehci_hcor *hcor;
        int rootdev;