Module Name:    src
Committed By:   jmcneill
Date:           Fri Oct 12 22:20:48 UTC 2018

Modified Files:
        src/sys/arch/arm/fdt: files.fdt
Added Files:
        src/sys/arch/arm/fdt: acpi_fdt.c

Log Message:
Add acpi @ fdt glue


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/fdt/acpi_fdt.c
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/arm/fdt/files.fdt

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/fdt/files.fdt
diff -u src/sys/arch/arm/fdt/files.fdt:1.26 src/sys/arch/arm/fdt/files.fdt:1.27
--- src/sys/arch/arm/fdt/files.fdt:1.26	Fri Sep 21 12:04:06 2018
+++ src/sys/arch/arm/fdt/files.fdt	Fri Oct 12 22:20:48 2018
@@ -1,4 +1,4 @@
-# $NetBSD: files.fdt,v 1.26 2018/09/21 12:04:06 skrll Exp $
+# $NetBSD: files.fdt,v 1.27 2018/10/12 22:20:48 jmcneill Exp $
 
 include	"dev/pckbport/files.pckbport"
 
@@ -67,3 +67,6 @@ file	dev/tprof/tprof_armv8.c			pmu_fdt &
 attach	genfb at fdt with plfb_fdt: fdt_display_timing
 file	arch/arm/fdt/plfb_fdt.c			plfb_fdt
 
+device	acpifdt: acpibus
+attach	acpifdt at fdt with acpi_fdt
+file	arch/arm/fdt/acpi_fdt.c			acpi_fdt

Added files:

Index: src/sys/arch/arm/fdt/acpi_fdt.c
diff -u /dev/null src/sys/arch/arm/fdt/acpi_fdt.c:1.1
--- /dev/null	Fri Oct 12 22:20:48 2018
+++ src/sys/arch/arm/fdt/acpi_fdt.c	Fri Oct 12 22:20:48 2018
@@ -0,0 +1,90 @@
+/* $NetBSD: acpi_fdt.c,v 1.1 2018/10/12 22:20:48 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2015-2017 Jared McNeill <jmcne...@invisible.ca>
+ * All rights reserved.
+ *
+ * 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 AUTHOR ``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 AUTHOR 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: acpi_fdt.c,v 1.1 2018/10/12 22:20:48 jmcneill Exp $");
+
+#include <sys/param.h>
+#include <sys/bus.h>
+#include <sys/device.h>
+#include <sys/intr.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/lwp.h>
+#include <sys/kmem.h>
+#include <sys/queue.h>
+
+#include <dev/fdt/fdtvar.h>
+
+#include <dev/acpi/acpivar.h>
+#include <dev/pci/pcivar.h>
+
+static int	acpi_fdt_match(device_t, cfdata_t, void *);
+static void	acpi_fdt_attach(device_t, device_t, void *);
+
+static const char * const compatible[] = {
+	"netbsd,acpi",
+	NULL
+};
+
+CFATTACH_DECL_NEW(acpi_fdt, 0, acpi_fdt_match, acpi_fdt_attach, NULL, NULL);
+
+static int
+acpi_fdt_match(device_t parent, cfdata_t cf, void *aux)
+{
+	struct fdt_attach_args * const faa = aux;
+
+	return of_compatible(faa->faa_phandle, compatible) >= 0;
+}
+
+static void
+acpi_fdt_attach(device_t parent, device_t self, void *aux)
+{
+	struct fdt_attach_args * const faa = aux;
+	struct acpibus_attach_args aa;
+
+	aprint_naive("\n");
+	aprint_normal(": ACPI Platform support\n");
+
+	if (!acpi_probe())
+		aprint_error_dev(self, "failed to probe ACPI\n");
+
+	aa.aa_iot = 0;
+	aa.aa_memt = faa->faa_bst;
+	aa.aa_pc = NULL;
+	aa.aa_pciflags =
+	    PCI_FLAGS_IO_OKAY | PCI_FLAGS_MEM_OKAY |
+	    PCI_FLAGS_MRL_OKAY | PCI_FLAGS_MRM_OKAY | 
+	    PCI_FLAGS_MWI_OKAY;
+	aa.aa_ic = 0;
+	aa.aa_dmat = faa->faa_dmat;
+#ifdef _PCI_HAVE_DMA64
+	aa.aa_dmat64 = faa->faa_dmat;
+#endif
+	config_found_ia(self, "acpibus", &aa, 0);
+}

Reply via email to