Module Name: src
Committed By: jmcneill
Date: Tue Dec 31 01:00:23 UTC 2019
Modified Files:
src/sys/external/bsd/vchiq/conf: files.vchiq
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm:
vchiq_kmod_netbsd.c vchiq_netbsd.h
Added Files:
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm:
vchiq_netbsd_acpi.c vchiq_netbsd_fdt.c
Log Message:
Split vchiq into separate fdt and acpi attachments.
To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/external/bsd/vchiq/conf/files.vchiq
cvs rdiff -u -r1.10 -r1.11 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c
cvs rdiff -u -r1.2 -r1.3 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_netbsd.h
cvs rdiff -u -r0 -r1.1 \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_netbsd_acpi.c \
src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_netbsd_fdt.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/external/bsd/vchiq/conf/files.vchiq
diff -u src/sys/external/bsd/vchiq/conf/files.vchiq:1.3 src/sys/external/bsd/vchiq/conf/files.vchiq:1.4
--- src/sys/external/bsd/vchiq/conf/files.vchiq:1.3 Sun Dec 10 21:38:27 2017
+++ src/sys/external/bsd/vchiq/conf/files.vchiq Tue Dec 31 01:00:22 2019
@@ -1,4 +1,4 @@
-# $NetBSD: files.vchiq,v 1.3 2017/12/10 21:38:27 skrll Exp $
+# $NetBSD: files.vchiq,v 1.4 2019/12/31 01:00:22 jmcneill Exp $
#
# Broadcom VideoCore IV
#
@@ -6,7 +6,6 @@
define vchiqbus { }
device vchiq: vchiqbus
-attach vchiq at fdt
file external/bsd/vchiq/dist/interface/compat/vchi_bsd.c vchiq
file external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_2835_arm.c vchiq
file external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_arm.c vchiq
@@ -17,4 +16,12 @@ file external/bsd/vchiq/dist/interface/v
file external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kern_lib.c vchiq
file external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c vchiq
+attach vchiq at fdt with vchiq_fdt
+file external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_netbsd_fdt.c vchiq_fdt
+
+ifdef acpinodebus
+attach vchiq at acpinodebus with vchiq_acpi
+file external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_netbsd_acpi.c vchiq_acpi
+endif
+
makeoptions vchiq CPPFLAGS+="-I$S/external/bsd/vchiq/dist -I$S/external/bsd/common/include -DVCOS_VERIFY_BKPTS=1 -DUSE_VCHIQ_ARM -D__VCCOREVER__=0x04000000 -DVCHIQ_ENABLE_DEBUG=1 -DVCHIQ_LOG_DEFAULT=5"
Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c:1.10 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c:1.11
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c:1.10 Sun Dec 10 21:38:27 2017
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_kmod_netbsd.c Tue Dec 31 01:00:23 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: vchiq_kmod_netbsd.c,v 1.10 2017/12/10 21:38:27 skrll Exp $ */
+/* $NetBSD: vchiq_kmod_netbsd.c,v 1.11 2019/12/31 01:00:23 jmcneill Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vchiq_kmod_netbsd.c,v 1.10 2017/12/10 21:38:27 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vchiq_kmod_netbsd.c,v 1.11 2019/12/31 01:00:23 jmcneill Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -42,122 +42,26 @@ __KERNEL_RCSID(0, "$NetBSD: vchiq_kmod_n
#include <arm/broadcom/bcm2835reg.h>
#include <arm/broadcom/bcm2835_intr.h>
-#include <dev/fdt/fdtvar.h>
-
#include "vchiq_arm.h"
#include "vchiq_2835.h"
#include "vchiq_netbsd.h"
extern VCHIQ_STATE_T g_state;
-struct vchiq_softc {
- device_t sc_dev;
- device_t sc_audiodev;
-
- bus_space_tag_t sc_iot;
- bus_space_handle_t sc_ioh;
- void *sc_ih;
-
- int sc_intr;
- int sc_phandle;
-};
-
static struct vchiq_softc *vchiq_softc = NULL;
-static int vchiq_match(device_t, cfdata_t, void *);
-static void vchiq_attach(device_t, device_t, void *);
-
-static int vchiq_intr(void *);
-static int vchiq_print(void *, const char *);
-static void vchiq_defer(device_t);
-
-/* External functions */
-int vchiq_init(void);
-
-
#define VCHIQ_DOORBELL0 0x0
#define VCHIQ_DOORBELL1 0x4
#define VCHIQ_DOORBELL2 0x8
#define VCHIQ_DOORBELL3 0xC
-
-CFATTACH_DECL_NEW(vchiq, sizeof(struct vchiq_softc),
- vchiq_match, vchiq_attach, NULL, NULL);
-
-static int
-vchiq_match(device_t parent, cfdata_t match, void *aux)
-{
- const char * const compatible[] = { "brcm,bcm2835-vchiq", NULL };
- struct fdt_attach_args * const faa = aux;
-
- return of_match_compatible(faa->faa_phandle, compatible);
-}
-
-static void
-vchiq_attach(device_t parent, device_t self, void *aux)
+void
+vchiq_set_softc(struct vchiq_softc *sc)
{
- struct vchiq_softc *sc = device_private(self);
- struct fdt_attach_args * const faa = aux;
- const int phandle = faa->faa_phandle;
-
- aprint_naive("\n");
- aprint_normal(": BCM2835 VCHIQ\n");
-
- sc->sc_dev = self;
- sc->sc_iot = faa->faa_bst;
- sc->sc_phandle = phandle;
-
- bus_addr_t addr;
- bus_size_t size;
-
- if (fdtbus_get_reg(phandle, 0, &addr, &size) != 0) {
- aprint_error(": couldn't get register address\n");
- return;
- }
-
- if (bus_space_map(faa->faa_bst, addr, size, 0, &sc->sc_ioh) != 0) {
- aprint_error_dev(sc->sc_dev, "unable to map device\n");
- return;
- }
-
- vchiq_platform_attach(faa->faa_dmat);
-
vchiq_softc = sc;
-
- config_mountroot(self, vchiq_defer);
-}
-
-static void
-vchiq_defer(device_t self)
-{
- struct vchiq_attach_args vaa;
- struct vchiq_softc *sc = device_private(self);
- const int phandle = sc->sc_phandle;
-
- vchiq_core_initialize();
-
- char intrstr[128];
- if (!fdtbus_intr_str(phandle, 0, intrstr, sizeof(intrstr))) {
- aprint_error(": failed to decode interrupt\n");
- return;
- }
-
- sc->sc_ih = fdtbus_intr_establish(phandle, 0, IPL_VM, FDT_INTR_MPSAFE,
- vchiq_intr, sc);
- if (sc->sc_ih == NULL) {
- aprint_error_dev(self, "failed to establish interrupt %s\n",
- intrstr);
- return;
- }
- aprint_normal_dev(self, "interrupting on %s\n", intrstr);
-
- vchiq_init();
-
- vaa.vaa_name = "AUDS";
- config_found_ia(self, "vchiqbus", &vaa, vchiq_print);
}
-static int
+int
vchiq_intr(void *priv)
{
struct vchiq_softc *sc = priv;
@@ -176,7 +80,7 @@ vchiq_intr(void *priv)
return 0;
}
-static int
+int
vchiq_print(void *aux, const char *pnp)
{
struct vchiq_attach_args *vaa = aux;
Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_netbsd.h
diff -u src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_netbsd.h:1.2 src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_netbsd.h:1.3
--- src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_netbsd.h:1.2 Sun Dec 10 21:38:27 2017
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_netbsd.h Tue Dec 31 01:00:23 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: vchiq_netbsd.h,v 1.2 2017/12/10 21:38:27 skrll Exp $ */
+/* $NetBSD: vchiq_netbsd.h,v 1.3 2019/12/31 01:00:23 jmcneill Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -32,10 +32,22 @@
#ifndef _VCHIQ_NETBSD_H
#define _VCHIQ_NETBSD_H
+struct vchiq_softc {
+ device_t sc_dev;
+ device_t sc_audiodev;
+
+ bus_space_tag_t sc_iot;
+ bus_space_handle_t sc_ioh;
+ void *sc_ih;
+};
+
struct vchiq_attach_args {
const char *vaa_name;
};
+int vchiq_intr(void *);
+int vchiq_print(void *, const char *);
+void vchiq_set_softc(struct vchiq_softc *);
void vchiq_platform_attach(bus_dma_tag_t tag);
#endif /* !_VCHIQ_NETBSD_H */
Added files:
Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_netbsd_acpi.c
diff -u /dev/null src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_netbsd_acpi.c:1.1
--- /dev/null Tue Dec 31 01:00:23 2019
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_netbsd_acpi.c Tue Dec 31 01:00:23 2019
@@ -0,0 +1,142 @@
+/* $NetBSD: vchiq_netbsd_acpi.c,v 1.1 2019/12/31 01:00:23 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2013 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jared D. McNeill
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: vchiq_netbsd_acpi.c,v 1.1 2019/12/31 01:00:23 jmcneill Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/sysctl.h>
+
+#include <arm/broadcom/bcm2835reg.h>
+#include <arm/broadcom/bcm2835_intr.h>
+
+#include <dev/acpi/acpivar.h>
+#include <dev/acpi/acpi_intr.h>
+
+#include "vchiq_arm.h"
+#include "vchiq_2835.h"
+#include "vchiq_netbsd.h"
+
+struct vchiq_acpi_softc {
+ struct vchiq_softc sc_vchiq;
+ ACPI_HANDLE sc_handle;
+};
+
+static int vchiq_acpi_match(device_t, cfdata_t, void *);
+static void vchiq_acpi_attach(device_t, device_t, void *);
+
+static void vchiq_acpi_defer(device_t);
+
+/* External functions */
+int vchiq_init(void);
+
+
+CFATTACH_DECL_NEW(vchiq_acpi, sizeof(struct vchiq_acpi_softc),
+ vchiq_acpi_match, vchiq_acpi_attach, NULL, NULL);
+
+static int
+vchiq_acpi_match(device_t parent, cfdata_t match, void *aux)
+{
+ const char * const compatible[] = { "BCM2835", NULL };
+ struct acpi_attach_args * const aa = aux;
+
+ if (aa->aa_node->ad_type != ACPI_TYPE_DEVICE)
+ return 0;
+
+ return acpi_match_hid(aa->aa_node->ad_devinfo, compatible);
+}
+
+static void
+vchiq_acpi_attach(device_t parent, device_t self, void *aux)
+{
+ struct vchiq_acpi_softc *asc = device_private(self);
+ struct vchiq_softc *sc = &asc->sc_vchiq;
+ struct acpi_attach_args * const aa = aux;
+ struct acpi_resources res;
+ struct acpi_mem *mem;
+ struct acpi_irq *irq;
+ ACPI_STATUS rv;
+
+ sc->sc_dev = self;
+ sc->sc_iot = aa->aa_memt;
+ asc->sc_handle = aa->aa_node->ad_handle;
+
+ rv = acpi_resource_parse(self, aa->aa_node->ad_handle, "_CRS",
+ &res, &acpi_resource_parse_ops_default);
+ if (ACPI_FAILURE(rv))
+ return;
+
+ mem = acpi_res_mem(&res, 0);
+ irq = acpi_res_irq(&res, 0);
+ if (mem == NULL || irq == NULL) {
+ aprint_error_dev(self, "couldn't find resources\n");
+ return;
+ }
+
+ if (bus_space_map(sc->sc_iot, mem->ar_base, mem->ar_size, 0,
+ &sc->sc_ioh) != 0) {
+ aprint_error_dev(sc->sc_dev, "unable to map device\n");
+ return;
+ }
+
+ vchiq_platform_attach(aa->aa_dmat);
+
+ vchiq_set_softc(sc);
+
+ config_mountroot(self, vchiq_acpi_defer);
+}
+
+static void
+vchiq_acpi_defer(device_t self)
+{
+ struct vchiq_attach_args vaa;
+ struct vchiq_acpi_softc *asc = device_private(self);
+ struct vchiq_softc *sc = &asc->sc_vchiq;
+ ACPI_HANDLE handle = asc->sc_handle;
+
+ vchiq_core_initialize();
+
+ sc->sc_ih = acpi_intr_establish(sc->sc_dev, (uint64_t)handle,
+ IPL_VM, true, vchiq_intr, sc, device_xname(self));
+ if (sc->sc_ih == NULL) {
+ aprint_error_dev(sc->sc_dev, "failed to establish interrupt\n");
+ return;
+ }
+
+ vchiq_init();
+
+ vaa.vaa_name = "AUDS";
+ config_found_ia(self, "vchiqbus", &vaa, vchiq_print);
+}
Index: src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_netbsd_fdt.c
diff -u /dev/null src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_netbsd_fdt.c:1.1
--- /dev/null Tue Dec 31 01:00:23 2019
+++ src/sys/external/bsd/vchiq/dist/interface/vchiq_arm/vchiq_netbsd_fdt.c Tue Dec 31 01:00:23 2019
@@ -0,0 +1,141 @@
+/* $NetBSD: vchiq_netbsd_fdt.c,v 1.1 2019/12/31 01:00:23 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2013 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jared D. McNeill
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: vchiq_netbsd_fdt.c,v 1.1 2019/12/31 01:00:23 jmcneill Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/sysctl.h>
+
+#include <arm/broadcom/bcm2835reg.h>
+#include <arm/broadcom/bcm2835_intr.h>
+
+#include <dev/fdt/fdtvar.h>
+
+#include "vchiq_arm.h"
+#include "vchiq_2835.h"
+#include "vchiq_netbsd.h"
+
+struct vchiq_fdt_softc {
+ struct vchiq_softc sc_vchiq;
+ int sc_phandle;
+};
+
+static int vchiq_fdt_match(device_t, cfdata_t, void *);
+static void vchiq_fdt_attach(device_t, device_t, void *);
+
+static void vchiq_fdt_defer(device_t);
+
+/* External functions */
+int vchiq_init(void);
+
+
+CFATTACH_DECL_NEW(vchiq_fdt, sizeof(struct vchiq_fdt_softc),
+ vchiq_fdt_match, vchiq_fdt_attach, NULL, NULL);
+
+static int
+vchiq_fdt_match(device_t parent, cfdata_t match, void *aux)
+{
+ const char * const compatible[] = { "brcm,bcm2835-vchiq", NULL };
+ struct fdt_attach_args * const faa = aux;
+
+ return of_match_compatible(faa->faa_phandle, compatible);
+}
+
+static void
+vchiq_fdt_attach(device_t parent, device_t self, void *aux)
+{
+ struct vchiq_fdt_softc *fsc = device_private(self);
+ struct vchiq_softc *sc = &fsc->sc_vchiq;
+ struct fdt_attach_args * const faa = aux;
+ const int phandle = faa->faa_phandle;
+
+ aprint_naive("\n");
+ aprint_normal(": BCM2835 VCHIQ\n");
+
+ sc->sc_dev = self;
+ sc->sc_iot = faa->faa_bst;
+ fsc->sc_phandle = phandle;
+
+ bus_addr_t addr;
+ bus_size_t size;
+
+ if (fdtbus_get_reg(phandle, 0, &addr, &size) != 0) {
+ aprint_error(": couldn't get register address\n");
+ return;
+ }
+
+ if (bus_space_map(faa->faa_bst, addr, size, 0, &sc->sc_ioh) != 0) {
+ aprint_error_dev(sc->sc_dev, "unable to map device\n");
+ return;
+ }
+
+ vchiq_platform_attach(faa->faa_dmat);
+
+ vchiq_set_softc(sc);
+
+ config_mountroot(self, vchiq_fdt_defer);
+}
+
+static void
+vchiq_fdt_defer(device_t self)
+{
+ struct vchiq_attach_args vaa;
+ struct vchiq_fdt_softc *fsc = device_private(self);
+ struct vchiq_softc *sc = &fsc->sc_vchiq;
+ const int phandle = fsc->sc_phandle;
+
+ vchiq_core_initialize();
+
+ char intrstr[128];
+ if (!fdtbus_intr_str(phandle, 0, intrstr, sizeof(intrstr))) {
+ aprint_error(": failed to decode interrupt\n");
+ return;
+ }
+
+ sc->sc_ih = fdtbus_intr_establish(phandle, 0, IPL_VM, FDT_INTR_MPSAFE,
+ vchiq_intr, sc);
+ if (sc->sc_ih == NULL) {
+ aprint_error_dev(self, "failed to establish interrupt %s\n",
+ intrstr);
+ return;
+ }
+ aprint_normal_dev(self, "interrupting on %s\n", intrstr);
+
+ vchiq_init();
+
+ vaa.vaa_name = "AUDS";
+ config_found_ia(self, "vchiqbus", &vaa, vchiq_print);
+}