From: kettenis Date: Mon, 24 May 2021 18:40:19 +0000 (+0000) Subject: Add apldwusb(4), a glue driver for the Synpsys DesignWare USB 3 controllers X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=52c516329cd1f45baeb25016c442d7b20314f8cc;p=openbsd Add apldwusb(4), a glue driver for the Synpsys DesignWare USB 3 controllers found on the Apple M1 SoC. --- diff --git a/sys/arch/arm64/conf/GENERIC b/sys/arch/arm64/conf/GENERIC index 411c922ae02..d40e65471d9 100644 --- a/sys/arch/arm64/conf/GENERIC +++ b/sys/arch/arm64/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.197 2021/05/18 14:25:59 kevlo Exp $ +# $OpenBSD: GENERIC,v 1.198 2021/05/24 18:40:19 kettenis Exp $ # # GENERIC machine description file # @@ -134,6 +134,7 @@ wsdisplay* at amdgpu? # Apple apldart* at fdt? apldog* at fdt? early 1 +apldwusb* at fdt? aplintc* at fdt? early 1 aplpcie* at fdt? pci* at aplpcie? diff --git a/sys/arch/arm64/conf/RAMDISK b/sys/arch/arm64/conf/RAMDISK index d9d80a0c7f9..e68e04b570a 100644 --- a/sys/arch/arm64/conf/RAMDISK +++ b/sys/arch/arm64/conf/RAMDISK @@ -1,4 +1,4 @@ -# $OpenBSD: RAMDISK,v 1.149 2021/05/14 08:10:39 jsg Exp $ +# $OpenBSD: RAMDISK,v 1.150 2021/05/24 18:40:19 kettenis Exp $ machine arm64 maxusers 4 @@ -98,6 +98,7 @@ wsdisplay* at simplefb? # Apple apldart* at fdt? apldog* at fdt? early 1 +apldwusb* at fdt? aplintc* at fdt? early 1 aplpcie* at fdt? pci* at aplpcie? diff --git a/sys/arch/arm64/conf/files.arm64 b/sys/arch/arm64/conf/files.arm64 index 6b4517f72b9..77fa39b9b9a 100644 --- a/sys/arch/arm64/conf/files.arm64 +++ b/sys/arch/arm64/conf/files.arm64 @@ -1,4 +1,4 @@ -# $OpenBSD: files.arm64,v 1.40 2021/05/18 11:39:37 kettenis Exp $ +# $OpenBSD: files.arm64,v 1.41 2021/05/24 18:40:19 kettenis Exp $ maxpartitions 16 maxusers 2 8 128 @@ -144,6 +144,10 @@ device apldog attach apldog at fdt file arch/arm64/dev/apldog.c apldog +device apldwusb: fdt +attach apldwusb at fdt +file arch/arm64/dev/apldwusb.c apldwusb + device aplintc attach aplintc at fdt file arch/arm64/dev/aplintc.c aplintc diff --git a/sys/arch/arm64/dev/apldwusb.c b/sys/arch/arm64/dev/apldwusb.c new file mode 100644 index 00000000000..0507498c37e --- /dev/null +++ b/sys/arch/arm64/dev/apldwusb.c @@ -0,0 +1,64 @@ +/* $OpenBSD: apldwusb.c,v 1.1 2021/05/24 18:40:19 kettenis Exp $ */ +/* + * Copyright (c) 2017 Mark Kettenis + * + * 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 +#include +#include + +#include +#include + +#include + +#include +#include +#include + +struct apldwusb_softc { + struct simplebus_softc sc_sbus; +}; + +int apldwusb_match(struct device *, void *, void *); +void apldwusb_attach(struct device *, struct device *, void *); + +struct cfattach apldwusb_ca = { + sizeof(struct apldwusb_softc), apldwusb_match, apldwusb_attach +}; + +struct cfdriver apldwusb_cd = { + NULL, "apldwusb", DV_DULL +}; + +int +apldwusb_match(struct device *parent, void *match, void *aux) +{ + struct fdt_attach_args *faa = aux; + + return OF_is_compatible(faa->fa_node, "apple,dwc3-m1"); +} + +void +apldwusb_attach(struct device *parent, struct device *self, void *aux) +{ + struct apldwusb_softc *sc = (struct apldwusb_softc *)self; + struct fdt_attach_args *faa = aux; + + clock_enable_all(faa->fa_node); + reset_deassert_all(faa->fa_node); + + simplebus_attach(parent, &sc->sc_sbus.sc_dev, faa); +}