Index: sys/dev/uart/uart_bus_acpi.c =================================================================== --- sys/dev/uart/uart_bus_acpi.c +++ sys/dev/uart/uart_bus_acpi.c @@ -39,6 +39,11 @@ #include #include +#include + +#include +#include +#include static int uart_acpi_probe(device_t dev); @@ -57,6 +62,7 @@ sizeof(struct uart_softc), }; +#if defined(__i386__) || defined(__amd64__) static struct isa_pnp_id acpi_ns8250_ids[] = { {0x0005d041, "Standard PC COM port"}, /* PNP0500 */ {0x0105d041, "16550A-compatible COM port"}, /* PNP0501 */ @@ -67,6 +73,27 @@ {0xe502aa1a, "Wacom Tablet at FuS Lifebook T"}, /* FUJ02E5 */ {0} }; +#endif + +#ifdef __aarch64__ +static struct uart_class * +uart_acpi_find_device(device_t dev) +{ + struct acpi_uart_compat_data **cd; + ACPI_HANDLE h; + + if ((h = acpi_get_handle(dev)) == NULL) + return (NULL); + + SET_FOREACH(cd, uart_acpi_class_and_device_set) { + if (acpi_MatchHid(h, (*cd)->hid)) { + return ((*cd)->clas); + } + } + + return (NULL); +} +#endif static int uart_acpi_probe(device_t dev) @@ -77,12 +104,17 @@ parent = device_get_parent(dev); sc = device_get_softc(dev); +#if defined(__i386__) || defined(__amd64__) if (!ISA_PNP_PROBE(parent, dev, acpi_ns8250_ids)) { sc->sc_class = &uart_ns8250_class; return (uart_bus_probe(dev, 0, 0, 0, 0)); } - /* Add checks for non-ns8250 IDs here. */ +#elif defined(__aarch64__) + if ((sc->sc_class = uart_acpi_find_device(dev)) != NULL) + return (uart_bus_probe(dev, 2, 0, 0, 0)); +#endif + return (ENXIO); } Index: sys/dev/uart/uart_cpu_acpi.h =================================================================== --- /dev/null +++ sys/dev/uart/uart_cpu_acpi.h @@ -0,0 +1,62 @@ +/*- + * Copyright (c) 2015 Michal Meloun + * Copyright (c) 2016 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed by Andrew Turner under + * sponsorship from the FreeBSD Foundation. + * + * 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 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 AUTHOR 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. + * + * $FreeBSD$ + */ + +#ifndef _DEV_UART_CPU_ACPI_H_ +#define _DEV_UART_CPU_ACPI_H_ + +#include + +struct uart_class; + +struct acpi_uart_compat_data { + const char *hid; + struct uart_class *clas; +}; + +/* + * If your UART driver implements only uart_class and uses uart_cpu_acpi.c + * for device instantiation, then use UART_ACPI_CLASS_AND_DEVICE for its + * declaration + */ +SET_DECLARE(uart_acpi_class_and_device_set, struct acpi_uart_compat_data); +#define UART_ACPI_CLASS_AND_DEVICE(data) \ + DATA_SET(uart_acpi_class_and_device_set, data) + +/* + * If your UART driver implements uart_class and custom device layer, + * then use UART_ACPI_CLASS for its declaration + */ +SET_DECLARE(uart_acpi_class_set, struct acpi_uart_compat_data); +#define UART_ACPI_CLASS(data) \ + DATA_SET(uart_acpi_class_set, data) + +#endif /* _DEV_UART_CPU_ACPI_H_ */ Index: sys/dev/uart/uart_dev_pl011.c =================================================================== --- sys/dev/uart/uart_dev_pl011.c +++ sys/dev/uart/uart_dev_pl011.c @@ -24,6 +24,9 @@ * SUCH DAMAGE. */ +#include "opt_acpi.h" +#include "opt_platform.h" + #include __FBSDID("$FreeBSD$"); @@ -35,7 +38,12 @@ #include #include +#ifdef DEV_ACPI +#include +#endif +#ifdef FDT #include +#endif #include #include "uart_if.h" @@ -277,11 +285,22 @@ .uc_rshift = 2 }; + +#ifdef FDT static struct ofw_compat_data compat_data[] = { {"arm,pl011", (uintptr_t)&uart_pl011_class}, {NULL, (uintptr_t)NULL}, }; UART_FDT_CLASS_AND_DEVICE(compat_data); +#endif + +#ifdef DEV_ACPI +static struct acpi_uart_compat_data acpi_compat_data[] = { + {"ARMH0011", &uart_pl011_class}, + {NULL, NULL}, +}; +UART_ACPI_CLASS_AND_DEVICE(acpi_compat_data); +#endif static int uart_pl011_bus_attach(struct uart_softc *sc)