summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2023-04-03 01:55:01 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2023-04-03 01:55:01 +0000
commit0a3e40ea6cda30db72eb2f74b83d1680eb4bc007 (patch)
treeec10bb27ec266fc9bcae6094874ad771017ea2a5 /sys
parent0f8bcfe532904987d20440dd9edf22d088e0fda7 (diff)
add support for enabling both the usb2 and usb3 phys.
the code tried enabling the 0th phy in the usb-phy proplist, which is the usb2 phy, and if that didn't exist it would try usb3-phy in the standard phys/phy-names properties. it now tries to enable the usb2 and usb3 phys independently. further, support using standard phy drivers registered with the ofw/fdt code, not just the ones handled inside the xhci driver. ok kettenis@
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/fdt/xhci_fdt.c44
1 files changed, 24 insertions, 20 deletions
diff --git a/sys/dev/fdt/xhci_fdt.c b/sys/dev/fdt/xhci_fdt.c
index 28381d4b737..3c172bcfaf1 100644
--- a/sys/dev/fdt/xhci_fdt.c
+++ b/sys/dev/fdt/xhci_fdt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: xhci_fdt.c,v 1.22 2023/03/10 10:22:55 kettenis Exp $ */
+/* $OpenBSD: xhci_fdt.c,v 1.23 2023/04/03 01:55:00 dlg Exp $ */
/*
* Copyright (c) 2017 Mark Kettenis <kettenis@openbsd.org>
*
@@ -362,32 +362,16 @@ xhci_init_phy(struct xhci_fdt_softc *sc, uint32_t *cells)
}
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;
@@ -409,6 +393,26 @@ xhci_init_phys(struct xhci_fdt_softc *sc)
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");
+ }
+}
+
/*
* Samsung Exynos 5 PHYs.
*/