diff options
author | 2020-12-18 18:24:44 +0000 | |
---|---|---|
committer | 2020-12-18 18:24:44 +0000 | |
commit | e5b83da55683952281851d15bf0dd9d83f6fb221 (patch) | |
tree | 02be4d24bda660571d53c9f590008199a04ba940 | |
parent | Add code to initialize the USB 3 PHY on i.MX8MP. (diff) | |
download | wireguard-openbsd-e5b83da55683952281851d15bf0dd9d83f6fb221.tar.xz wireguard-openbsd-e5b83da55683952281851d15bf0dd9d83f6fb221.zip |
Add glue for the USB3 controller on the i.MX8MP SoC. NXP had this glue for
the i.MX8MQ as well, but while upstreaming they were told to shove it. Now
for the i.MX8MP this glue is making a comeback. Apparently there's some
divergence in low power handling to the regular DWC3 IP with special IRQs.
Now the question remains if this driver will be obsolete soon again, or if
this time it's here to stay. The fun part is that while this driver was
written independent from the previous version, the diff is basically zero.
ok kettenis@
-rw-r--r-- | sys/arch/arm64/conf/GENERIC | 3 | ||||
-rw-r--r-- | sys/arch/arm64/conf/RAMDISK | 3 | ||||
-rw-r--r-- | sys/dev/fdt/files.fdt | 6 | ||||
-rw-r--r-- | sys/dev/fdt/imxdwusb.c | 75 |
4 files changed, 84 insertions, 3 deletions
diff --git a/sys/arch/arm64/conf/GENERIC b/sys/arch/arm64/conf/GENERIC index 4c3339a1505..e3dd7d232d8 100644 --- a/sys/arch/arm64/conf/GENERIC +++ b/sys/arch/arm64/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.181 2020/12/06 20:39:07 kettenis Exp $ +# $OpenBSD: GENERIC,v 1.182 2020/12/18 18:24:44 patrick Exp $ # # GENERIC machine description file # @@ -131,6 +131,7 @@ imxccm* at fdt? early 1 imxiomuxc* at fdt? early 1 imxanatop* at fdt? early 1 imxsrc* at fdt? early 1 +imxdwusb* at fdt? imxehci* at fdt? usb* at imxehci? imxgpc* at fdt? diff --git a/sys/arch/arm64/conf/RAMDISK b/sys/arch/arm64/conf/RAMDISK index a9e76bb3d7b..6de65082b48 100644 --- a/sys/arch/arm64/conf/RAMDISK +++ b/sys/arch/arm64/conf/RAMDISK @@ -1,4 +1,4 @@ -# $OpenBSD: RAMDISK,v 1.136 2020/11/29 22:02:37 kettenis Exp $ +# $OpenBSD: RAMDISK,v 1.137 2020/12/18 18:24:44 patrick Exp $ # # GENERIC machine description file # @@ -115,6 +115,7 @@ imxccm* at fdt? early 1 imxiomuxc* at fdt? early 1 imxanatop* at fdt? early 1 imxsrc* at fdt? early 1 +imxdwusb* at fdt? imxehci* at fdt? usb* at imxehci? imxgpc* at fdt? diff --git a/sys/dev/fdt/files.fdt b/sys/dev/fdt/files.fdt index a6318a472b2..376aaf3b903 100644 --- a/sys/dev/fdt/files.fdt +++ b/sys/dev/fdt/files.fdt @@ -1,4 +1,4 @@ -# $OpenBSD: files.fdt,v 1.144 2020/11/29 21:09:49 kettenis Exp $ +# $OpenBSD: files.fdt,v 1.145 2020/12/18 18:24:45 patrick Exp $ # # Config file and device description for machine-independent FDT code. # Included by ports that need it. @@ -452,6 +452,10 @@ device imxccm attach imxccm at fdt file dev/fdt/imxccm.c imxccm +device imxdwusb: fdt +attach imxdwusb at fdt +file dev/fdt/imxdwusb.c imxdwusb + device imxehci: usbus attach imxehci at fdt file dev/fdt/imxehci.c imxehci diff --git a/sys/dev/fdt/imxdwusb.c b/sys/dev/fdt/imxdwusb.c new file mode 100644 index 00000000000..43f7eac904e --- /dev/null +++ b/sys/dev/fdt/imxdwusb.c @@ -0,0 +1,75 @@ +/* $OpenBSD: imxdwusb.c,v 1.3 2020/12/18 18:24:45 patrick Exp $ */ +/* + * Copyright (c) 2017, 2018 Mark Kettenis <kettenis@openbsd.org> + * Copyright (c) 2020 Patrick Wildt <patrick@blueri.se> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/device.h> + +#include <machine/bus.h> +#include <machine/fdt.h> + +#include <arm64/dev/simplebusvar.h> + +#include <dev/ofw/openfirm.h> +#include <dev/ofw/ofw_clock.h> +#include <dev/ofw/ofw_gpio.h> +#include <dev/ofw/ofw_power.h> +#include <dev/ofw/fdt.h> + +/* + * This driver is based on preliminary device tree bindings and will + * almost certainly need changes once the official bindings land in + * mainline Linux. Support for these preliminary bindings will be + * dropped as soon as official bindings are available. + */ + +struct imxdwusb_softc { + struct simplebus_softc sc_sbus; +}; + +int imxdwusb_match(struct device *, void *, void *); +void imxdwusb_attach(struct device *, struct device *, void *); + +struct cfattach imxdwusb_ca = { + sizeof(struct imxdwusb_softc), imxdwusb_match, imxdwusb_attach +}; + +struct cfdriver imxdwusb_cd = { + NULL, "imxdwusb", DV_DULL +}; + +int +imxdwusb_match(struct device *parent, void *match, void *aux) +{ + struct fdt_attach_args *faa = aux; + + return OF_is_compatible(faa->fa_node, "fsl,imx8mp-dwc3"); +} + +void +imxdwusb_attach(struct device *parent, struct device *self, void *aux) +{ + struct imxdwusb_softc *sc = (struct imxdwusb_softc *)self; + struct fdt_attach_args *faa = aux; + + power_domain_enable(faa->fa_node); + clock_enable_all(faa->fa_node); + reset_deassert_all(faa->fa_node); + + simplebus_attach(parent, &sc->sc_sbus.sc_dev, faa); +} |