summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Wildt <patrick@cvs.openbsd.org>2022-11-06 12:12:46 +0000
committerPatrick Wildt <patrick@cvs.openbsd.org>2022-11-06 12:12:46 +0000
commit7749abd9212b613dec35866f10063e5c0151c43a (patch)
treec0ea28e5d03d33e2c13e1cdb05e4885499d18bb1
parentffe25ab5c9dc7e694f75f59b2edefbbc503c011d (diff)
Add glue for the USB3 controller on the Lenovo x13s.
ok kettenis@
-rw-r--r--sys/arch/arm64/conf/GENERIC3
-rw-r--r--sys/arch/arm64/conf/RAMDISK3
-rw-r--r--sys/dev/fdt/files.fdt6
-rw-r--r--sys/dev/fdt/qcdwusb.c67
4 files changed, 76 insertions, 3 deletions
diff --git a/sys/arch/arm64/conf/GENERIC b/sys/arch/arm64/conf/GENERIC
index c1f21df1a0e..3ce6e7795b1 100644
--- a/sys/arch/arm64/conf/GENERIC
+++ b/sys/arch/arm64/conf/GENERIC
@@ -1,4 +1,4 @@
-# $OpenBSD: GENERIC,v 1.240 2022/10/23 18:43:00 mglocker Exp $
+# $OpenBSD: GENERIC,v 1.241 2022/11/06 12:12:45 patrick Exp $
#
# GENERIC machine description file
#
@@ -305,6 +305,7 @@ dwmmc* at fdt?
sdmmc* at dwmmc?
# Qualcomm SoCs
+qcdwusb* at fdt?
qcgpio* at acpi?
qciic* at acpi?
iic* at qciic?
diff --git a/sys/arch/arm64/conf/RAMDISK b/sys/arch/arm64/conf/RAMDISK
index 455858e554f..e96bbb0bf99 100644
--- a/sys/arch/arm64/conf/RAMDISK
+++ b/sys/arch/arm64/conf/RAMDISK
@@ -1,4 +1,4 @@
-# $OpenBSD: RAMDISK,v 1.178 2022/11/03 17:41:22 patrick Exp $
+# $OpenBSD: RAMDISK,v 1.179 2022/11/06 12:12:45 patrick Exp $
machine arm64
maxusers 4
@@ -233,6 +233,7 @@ dwmmc* at fdt?
sdmmc* at dwmmc?
# Qualcomm SoCs
+qcdwusb* at fdt?
qcgpio* at acpi?
qciic* at acpi?
iic* at qciic?
diff --git a/sys/dev/fdt/files.fdt b/sys/dev/fdt/files.fdt
index 6a721edfa3e..fb573122036 100644
--- a/sys/dev/fdt/files.fdt
+++ b/sys/dev/fdt/files.fdt
@@ -1,4 +1,4 @@
-# $OpenBSD: files.fdt,v 1.164 2022/07/14 19:06:29 kettenis Exp $
+# $OpenBSD: files.fdt,v 1.165 2022/11/06 12:12:45 patrick Exp $
#
# Config file and device description for machine-independent FDT code.
# Included by ports that need it.
@@ -620,3 +620,7 @@ file dev/fdt/gpiorestart.c gpiorestart
device tascodec
attach tascodec at i2c
file dev/fdt/tascodec.c tascodec
+
+device qcdwusb: fdt
+attach qcdwusb at fdt
+file dev/fdt/qcdwusb.c qcdwusb
diff --git a/sys/dev/fdt/qcdwusb.c b/sys/dev/fdt/qcdwusb.c
new file mode 100644
index 00000000000..4a36dc32762
--- /dev/null
+++ b/sys/dev/fdt/qcdwusb.c
@@ -0,0 +1,67 @@
+/* $OpenBSD: qcdwusb.c,v 1.1 2022/11/06 12:12:45 patrick Exp $ */
+/*
+ * Copyright (c) 2017, 2018 Mark Kettenis <kettenis@openbsd.org>
+ * Copyright (c) 2020, 2022 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_power.h>
+#include <dev/ofw/fdt.h>
+
+struct qcdwusb_softc {
+ struct simplebus_softc sc_sbus;
+};
+
+int qcdwusb_match(struct device *, void *, void *);
+void qcdwusb_attach(struct device *, struct device *, void *);
+
+const struct cfattach qcdwusb_ca = {
+ sizeof(struct qcdwusb_softc), qcdwusb_match, qcdwusb_attach
+};
+
+struct cfdriver qcdwusb_cd = {
+ NULL, "qcdwusb", DV_DULL
+};
+
+int
+qcdwusb_match(struct device *parent, void *match, void *aux)
+{
+ struct fdt_attach_args *faa = aux;
+
+ return OF_is_compatible(faa->fa_node, "qcom,dwc3");
+}
+
+void
+qcdwusb_attach(struct device *parent, struct device *self, void *aux)
+{
+ struct qcdwusb_softc *sc = (struct qcdwusb_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);
+}