From: kettenis Date: Sun, 17 Dec 2017 13:23:03 +0000 (+0000) Subject: Add magic to make USB PYs work on Allwinner H3/H5/A64. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=bf50f09fa97f919a415a01514a6852e2d06a15f5;p=openbsd Add magic to make USB PYs work on Allwinner H3/H5/A64. --- diff --git a/sys/dev/fdt/ehci_fdt.c b/sys/dev/fdt/ehci_fdt.c index 55fe75f1a9c..75f6fba1fe4 100644 --- a/sys/dev/fdt/ehci_fdt.c +++ b/sys/dev/fdt/ehci_fdt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ehci_fdt.c,v 1.1 2017/04/29 20:49:09 kettenis Exp $ */ +/* $OpenBSD: ehci_fdt.c,v 1.2 2017/12/17 13:23:03 kettenis Exp $ */ /* * Copyright (c) 2005 David Gwynne @@ -261,15 +261,26 @@ sun4i_phy_init(struct ehci_fdt_softc *sc, uint32_t *cells) uint32_t val; int node; + node = OF_getnodebyphandle(cells[0]); + if (node == -1) + return; + val = bus_space_read_4(sc->sc.iot, sc->sc.ioh, SUNXI_HCI_ICR); val |= SUNXI_AHB_INCR8 | SUNXI_AHB_INCR4; val |= SUNXI_AHB_INCRX_ALIGN; val |= SUNXI_ULPI_BYPASS; bus_space_write_4(sc->sc.iot, sc->sc.ioh, SUNXI_HCI_ICR, val); - node = OF_getnodebyphandle(cells[0]); - if (node == -1) - return; + /* + * We need to poke an undocumented register to make the PHY + * work on Allwinner H3/H5/A64. + */ + if (OF_is_compatible(node, "allwinner,sun8i-h3-usb-phy") || + OF_is_compatible(node, "allwinner,sun50i-a64-usb-phy")) { + val = bus_space_read_4(sc->sc.iot, sc->sc.ioh, 0x810); + val &= ~(1 << 1); + bus_space_write_4(sc->sc.iot, sc->sc.ioh, 0x810, val); + } pinctrl_byname(node, "default");