From 7e83101958506cfd654647fae15ab21f696dd565 Mon Sep 17 00:00:00 2001 From: patrick Date: Sun, 6 Nov 2022 12:12:45 +0000 Subject: [PATCH] Add glue for the USB3 controller on the Lenovo x13s. ok kettenis@ --- sys/arch/arm64/conf/GENERIC | 3 +- sys/arch/arm64/conf/RAMDISK | 3 +- sys/dev/fdt/files.fdt | 6 +++- sys/dev/fdt/qcdwusb.c | 67 +++++++++++++++++++++++++++++++++++++ 4 files changed, 76 insertions(+), 3 deletions(-) create mode 100644 sys/dev/fdt/qcdwusb.c 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 + * Copyright (c) 2020, 2022 Patrick Wildt + * + * 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 +#include + +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); +} -- 2.20.1