From: Patrice Chotard <patrice.chot...@st.com>

Extend ehci-generic driver with generic PHY framework

Signed-off-by: Patrice Chotard <patrice.chot...@st.com>
Reviewed-by: Simon Glass <s...@chromium.org>
---

v7:     _ none

v6:     _ none

v5:     _ none

v4:     _ update the memory allocation for deasserted resets and enabled
          clocks reference list. Replace lists by arrays.
        _ usage of new RESET and CLOCK methods clk_count(), reset_count(),
          reset_assert_all() and clk_disable_all().

v3:     _ keep enabled clocks and deasserted resets reference in list in order 
to
          disable clock or assert resets in error path or in .remove callback
        _ use struct generic_ehci * instead of struct udevice * as parameter for
          ehci_release_resets() and ehci_release_clocks()

 drivers/usb/host/ehci-generic.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/drivers/usb/host/ehci-generic.c b/drivers/usb/host/ehci-generic.c
index 388b242..00a7772 100644
--- a/drivers/usb/host/ehci-generic.c
+++ b/drivers/usb/host/ehci-generic.c
@@ -6,6 +6,7 @@
 
 #include <common.h>
 #include <clk.h>
+#include <generic-phy.h>
 #include <reset.h>
 #include <asm/io.h>
 #include <dm.h>
@@ -22,6 +23,7 @@ struct generic_ehci {
        struct ehci_ctrl ctrl;
        struct clk *clocks;
        struct reset_ctl *resets;
+       struct phy phy;
        int clock_count;
        int reset_count;
 };
@@ -99,6 +101,21 @@ static int ehci_usb_probe(struct udevice *dev)
                        goto clk_err;
                }
        }
+
+       err = generic_phy_get_by_index(dev, 0, &priv->phy);
+       if (err) {
+               if (err != -ENOENT) {
+                       error("failed to get usb phy\n");
+                       goto reset_err;
+               }
+       } else {
+               err = generic_phy_init(&priv->phy);
+               if (err) {
+                       error("failed to init usb phy\n");
+                       goto reset_err;
+               }
+       }
+
        hccr = map_physmem(devfdt_get_addr(dev), 0x100, MAP_NOCACHE);
        hcor = (struct ehci_hcor *)((uintptr_t)hccr +
                                    HC_LENGTH(ehci_readl(&hccr->cr_capbase)));
@@ -107,6 +124,12 @@ static int ehci_usb_probe(struct udevice *dev)
        if (!err)
                return err;
 
+       if (generic_phy_valid(&priv->phy)) {
+               ret = generic_phy_exit(&priv->phy);
+               if (ret)
+                       return ret;
+       }
+
 reset_err:
        ret = reset_assert_all(priv->resets, priv->reset_count);
        if (ret)
@@ -128,6 +151,12 @@ static int ehci_usb_remove(struct udevice *dev)
        if (ret)
                return ret;
 
+       if (generic_phy_valid(&priv->phy)) {
+               ret = generic_phy_exit(&priv->phy);
+               if (ret)
+                       return ret;
+       }
+
        ret =  reset_assert_all(priv->resets, priv->reset_count);
        if (ret)
                return ret;
-- 
1.9.1

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot

Reply via email to