Index: ofw/ofw_misc.c =================================================================== RCS file: /cvs/src/sys/dev/ofw/ofw_misc.c,v retrieving revision 1.38 diff -u -p -r1.38 ofw_misc.c --- ofw/ofw_misc.c 17 Dec 2022 11:54:32 -0000 1.38 +++ ofw/ofw_misc.c 2 Apr 2023 04:42:37 -0000 @@ -207,7 +247,7 @@ phy_next_phy(uint32_t *cells) } int -phy_enable_idx(int node, int idx) +phy_enable_prop_idx(int node, char *prop, int idx) { uint32_t *phys; uint32_t *phy; @@ -219,7 +259,7 @@ phy_enable_idx(int node, int idx) return -1; phys = malloc(len, M_TEMP, M_WAITOK); - OF_getpropintarray(node, "phys", phys, len); + OF_getpropintarray(node, prop, phys, len); phy = phys; while (phy && phy < phys + (len / sizeof(uint32_t))) { @@ -233,6 +273,12 @@ phy_enable_idx(int node, int idx) free(phys, M_TEMP, len); return rv; +} + +int +phy_enable_idx(int node, int idx) +{ + return (phy_enable_prop_idx(node, "phys", idx)); } int Index: ofw/ofw_misc.h =================================================================== RCS file: /cvs/src/sys/dev/ofw/ofw_misc.h,v retrieving revision 1.27 diff -u -p -r1.27 ofw_misc.h --- ofw/ofw_misc.h 12 Dec 2022 19:18:25 -0000 1.27 +++ ofw/ofw_misc.h 2 Apr 2023 04:42:37 -0000 @@ -51,6 +68,7 @@ struct phy_device { void phy_register(struct phy_device *); +int phy_enable_prop_idx(int, char *, int); int phy_enable_idx(int, int); int phy_enable(int, const char *); Index: fdt/ehci_fdt.c =================================================================== RCS file: /cvs/src/sys/dev/fdt/ehci_fdt.c,v retrieving revision 1.9 diff -u -p -r1.9 ehci_fdt.c --- fdt/ehci_fdt.c 23 May 2022 11:37:22 -0000 1.9 +++ fdt/ehci_fdt.c 2 Apr 2023 04:42:37 -0000 @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -252,6 +253,9 @@ ehci_init_phys(struct ehci_fdt_softc *sc uint32_t *phys; uint32_t *phy; int len; + + if (phy_enable(sc->sc_node, "usb") == 0) + return; len = OF_getproplen(sc->sc_node, "phys"); if (len <= 0) Index: fdt/xhci_fdt.c =================================================================== RCS file: /cvs/src/sys/dev/fdt/xhci_fdt.c,v retrieving revision 1.22 diff -u -p -r1.22 xhci_fdt.c --- fdt/xhci_fdt.c 10 Mar 2023 10:22:55 -0000 1.22 +++ fdt/xhci_fdt.c 2 Apr 2023 04:42:37 -0000 @@ -362,32 +362,16 @@ xhci_init_phy(struct xhci_fdt_softc *sc, } void -xhci_init_phys(struct xhci_fdt_softc *sc) +xhci_phy_enable(struct xhci_fdt_softc *sc, char *name) { uint32_t *phys; uint32_t *phy; - uint32_t usb_phy; - int len, idx; - - /* - * 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; - } + int idx, len; - /* - * Generic PHY binding; only initialize USB 3 PHY for now. - */ - idx = OF_getindex(sc->sc_node, "usb3-phy", "phy-names"); + idx = OF_getindex(sc->sc_node, name, "phy-names"); if (idx < 0) return; - if (phy_enable_idx(sc->sc_node, idx) != ENXIO) - return; - len = OF_getproplen(sc->sc_node, "phys"); if (len <= 0) return; @@ -407,6 +391,26 @@ xhci_init_phys(struct xhci_fdt_softc *sc idx--; } free(phys, M_TEMP, len); +} + +void +xhci_init_phys(struct xhci_fdt_softc *sc) +{ + int rv; + + rv = phy_enable_prop_idx(sc->sc_node, "usb-phy", 0); + if (rv != 0) { + rv = phy_enable(sc->sc_node, "usb2-phy"); + if (rv != 0) + xhci_phy_enable(sc, "usb2-phy"); + } + + rv = phy_enable_prop_idx(sc->sc_node, "usb-phy", 1); + if (rv != 0) { + rv = phy_enable(sc->sc_node, "usb3-phy"); + if (rv != 0) + xhci_phy_enable(sc, "usb3-phy"); + } } /*