Merge git://git.denx.de/u-boot
[oweals/u-boot.git] / drivers / usb / host / ehci-hcd.c
index b040f12ee9e7b1804088868029e46fe8d4a74085..c85dbcecfa739fb2b43a3e162ac5ed441c29cfca 100644 (file)
@@ -5,20 +5,7 @@
  *
  * All rights reserved.
  *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation version 2 of
- * the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
+ * SPDX-License-Identifier:    GPL-2.0
  */
 #include <common.h>
 #include <dm.h>
@@ -28,6 +15,7 @@
 #include <usb.h>
 #include <asm/io.h>
 #include <malloc.h>
+#include <memalign.h>
 #include <watchdog.h>
 #include <linux/compiler.h>
 
@@ -315,7 +303,7 @@ static void ehci_update_endpt2_dev_n_port(struct usb_device *udev,
 
        ttdev = udev;
        parent = udev->dev;
-       uparent = dev_get_parentdata(parent);
+       uparent = dev_get_parent_priv(parent);
 
        while (uparent->speed != USB_SPEED_HIGH) {
                struct udevice *dev = parent;
@@ -325,9 +313,9 @@ static void ehci_update_endpt2_dev_n_port(struct usb_device *udev,
                        return;
                }
 
-               ttdev = dev_get_parentdata(dev);
+               ttdev = dev_get_parent_priv(dev);
                parent = dev->parent;
-               uparent = dev_get_parentdata(parent);
+               uparent = dev_get_parent_priv(parent);
        }
        parent_devnum = uparent->devnum;
 #else
@@ -1658,8 +1646,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;
@@ -1679,6 +1669,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;