Merge git://git.denx.de/u-boot-usb
[platform/kernel/u-boot.git] / drivers / usb / dwc3 / dwc3-generic.c
index 023e953..eabd53a 100644 (file)
@@ -8,6 +8,7 @@
  */
 
 #include <common.h>
+#include <cpu_func.h>
 #include <asm-generic/io.h>
 #include <dm.h>
 #include <dm/device-internal.h>
@@ -32,8 +33,7 @@ struct dwc3_generic_plat {
 struct dwc3_generic_priv {
        void *base;
        struct dwc3 dwc3;
-       struct phy *phys;
-       int num_phys;
+       struct phy_bulk phys;
 };
 
 struct dwc3_generic_host_priv {
@@ -55,7 +55,7 @@ static int dwc3_generic_probe(struct udevice *dev,
        dwc3_of_parse(dwc3);
 #endif
 
-       rc = dwc3_setup_phy(dev, &priv->phys, &priv->num_phys);
+       rc = dwc3_setup_phy(dev, &priv->phys);
        if (rc)
                return rc;
 
@@ -78,7 +78,7 @@ static int dwc3_generic_remove(struct udevice *dev,
        struct dwc3 *dwc3 = &priv->dwc3;
 
        dwc3_remove(dwc3);
-       dwc3_shutdown_phy(dev, priv->phys, priv->num_phys);
+       dwc3_shutdown_phy(dev, &priv->phys);
        unmap_physmem(dwc3->regs, MAP_NOCACHE);
 
        return 0;
@@ -87,9 +87,9 @@ static int dwc3_generic_remove(struct udevice *dev,
 static int dwc3_generic_ofdata_to_platdata(struct udevice *dev)
 {
        struct dwc3_generic_plat *plat = dev_get_platdata(dev);
-       int node = dev_of_offset(dev);
+       ofnode node = dev->node;
 
-       plat->base = devfdt_get_addr(dev);
+       plat->base = dev_read_addr(dev);
 
        plat->maximum_speed = usb_get_maximum_speed(node);
        if (plat->maximum_speed == USB_SPEED_UNKNOWN) {
@@ -283,13 +283,11 @@ struct dwc3_glue_ops ti_ops = {
 
 static int dwc3_glue_bind(struct udevice *parent)
 {
-       const void *fdt = gd->fdt_blob;
-       int node;
+       ofnode node;
        int ret;
 
-       for (node = fdt_first_subnode(fdt, dev_of_offset(parent)); node > 0;
-            node = fdt_next_subnode(fdt, node)) {
-               const char *name = fdt_get_name(fdt, node, NULL);
+       ofnode_for_each_subnode(node, parent->node) {
+               const char *name = ofnode_get_name(node);
                enum usb_dr_mode dr_mode;
                struct udevice *dev;
                const char *driver = NULL;
@@ -321,7 +319,7 @@ static int dwc3_glue_bind(struct udevice *parent)
                        continue;
 
                ret = device_bind_driver_to_node(parent, driver, name,
-                                                offset_to_ofnode(node), &dev);
+                                                node, &dev);
                if (ret) {
                        debug("%s: not able to bind usb device mode\n",
                              __func__);
@@ -338,7 +336,7 @@ static int dwc3_glue_reset_init(struct udevice *dev,
        int ret;
 
        ret = reset_get_bulk(dev, &glue->resets);
-       if (ret == -ENOTSUPP)
+       if (ret == -ENOTSUPP || ret == -ENOENT)
                return 0;
        else if (ret)
                return ret;
@@ -358,7 +356,7 @@ static int dwc3_glue_clk_init(struct udevice *dev,
        int ret;
 
        ret = clk_get_bulk(dev, &glue->clks);
-       if (ret == -ENOSYS)
+       if (ret == -ENOSYS || ret == -ENOENT)
                return 0;
        if (ret)
                return ret;
@@ -399,7 +397,7 @@ static int dwc3_glue_probe(struct udevice *dev)
        while (child) {
                enum usb_dr_mode dr_mode;
 
-               dr_mode = usb_get_dr_mode(dev_of_offset(child));
+               dr_mode = usb_get_dr_mode(child->node);
                device_find_next_child(&child);
                if (ops && ops->select_dr_mode)
                        ops->select_dr_mode(dev, index, dr_mode);
@@ -425,6 +423,7 @@ static const struct udevice_id dwc3_glue_ids[] = {
        { .compatible = "ti,keystone-dwc3"},
        { .compatible = "ti,dwc3", .data = (ulong)&ti_ops },
        { .compatible = "ti,am437x-dwc3", .data = (ulong)&ti_ops },
+       { .compatible = "ti,am654-dwc3" },
        { }
 };