The Marvell Aramada device trees use a legacy binding for the XHCI USB
PHY.  This diff adds support for this misfeature as fixing the device
trees may take a while.  It also adds support for the "usb-nop-xceiv"
PHY type, which contains the reference to the regulator that supplies
power to the USB bus.

ok?

Index: dev/fdt/xhci_fdt.c
===================================================================
RCS file: /cvs/src/sys/dev/fdt/xhci_fdt.c,v
retrieving revision 1.6
diff -u -p -r1.6 xhci_fdt.c
--- dev/fdt/xhci_fdt.c  12 Aug 2017 16:57:07 -0000      1.6
+++ dev/fdt/xhci_fdt.c  28 Mar 2018 10:00:08 -0000
@@ -25,6 +25,7 @@
 
 #include <dev/ofw/openfirm.h>
 #include <dev/ofw/ofw_misc.h>
+#include <dev/ofw/ofw_regulator.h>
 #include <dev/ofw/fdt.h>
 
 #include <dev/usb/usb.h>
@@ -180,10 +181,13 @@ struct xhci_phy {
 };
 
 void exynos5_usbdrd_init(struct xhci_fdt_softc *, uint32_t *);
+void nop_xceiv_init(struct xhci_fdt_softc *, uint32_t *);
 
 struct xhci_phy xhci_phys[] = {
        { "samsung,exynos5250-usbdrd-phy", exynos5_usbdrd_init },
-       { "samsung,exynos5420-usbdrd-phy", exynos5_usbdrd_init }
+       { "samsung,exynos5420-usbdrd-phy", exynos5_usbdrd_init },
+       { "usb-nop-xceiv", nop_xceiv_init },
+       
 };
 
 uint32_t *
@@ -223,9 +227,21 @@ xhci_init_phys(struct xhci_fdt_softc *sc
 {
        uint32_t *phys;
        uint32_t *phy;
+       uint32_t usb_phy;
        int len, idx;
 
-       /* XXX Only initialize the USB 3 PHY for now. */
+       /*
+        * Legacy binding; assume there only is a single USB PHY.
+        */
+       usb_phy = OF_getpropint(sc->sc_node, "usb-phy", 0);
+       if (usb_phy) {
+               xhci_init_phy(sc, &usb_phy);
+               return;
+       }
+
+       /*
+        * Generic PHY binding; only initialize USB 3 PHY for now.
+        */
        idx = OF_getindex(sc->sc_node, "usb3-phy", "phy-names");
        if (idx < 0)
                return;
@@ -329,4 +345,18 @@ exynos5_usbdrd_init(struct xhci_fdt_soft
        delay(10);
        CLR(val, EXYNOS5_PHYCLKRST_PORTRESET);
        bus_space_write_4(sc->sc.iot, sc->ph_ioh, EXYNOS5_PHYCLKRST, val);
+}
+
+void
+nop_xceiv_init(struct xhci_fdt_softc *sc, uint32_t *cells)
+{
+       uint32_t vcc_supply;
+       int node;
+
+       node = OF_getnodebyphandle(cells[0]);
+       KASSERT(node != 0);
+
+       vcc_supply = OF_getpropint(node, "vcc-supply", 0);
+       if (vcc_supply)
+               regulator_enable(vcc_supply);
 }

Reply via email to