Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/arm/fdt Add acpi @ fdt glue



details:   https://anonhg.NetBSD.org/src/rev/d041a190f67a
branches:  trunk
changeset: 433934:d041a190f67a
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Fri Oct 12 22:20:48 2018 +0000

description:
Add acpi @ fdt glue

diffstat:

 sys/arch/arm/fdt/acpi_fdt.c |  90 +++++++++++++++++++++++++++++++++++++++++++++
 sys/arch/arm/fdt/files.fdt  |   5 ++-
 2 files changed, 94 insertions(+), 1 deletions(-)

diffs (110 lines):

diff -r dc2f09b0c2e6 -r d041a190f67a sys/arch/arm/fdt/acpi_fdt.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/arm/fdt/acpi_fdt.c       Fri Oct 12 22:20:48 2018 +0000
@@ -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 <jmcneill%invisible.ca@localhost>
+ * 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);
+}
diff -r dc2f09b0c2e6 -r d041a190f67a sys/arch/arm/fdt/files.fdt
--- a/sys/arch/arm/fdt/files.fdt        Fri Oct 12 22:20:04 2018 +0000
+++ b/sys/arch/arm/fdt/files.fdt        Fri Oct 12 22:20:48 2018 +0000
@@ -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 @@
 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



Home | Main Index | Thread Index | Old Index