Index: stable/11/sys/arm/at91/uart_bus_at91usart.c =================================================================== --- stable/11/sys/arm/at91/uart_bus_at91usart.c +++ stable/11/sys/arm/at91/uart_bus_at91usart.c @@ -104,7 +104,7 @@ sc->sc_class = &at91_usart_class; if (sc->sc_class->uc_rclk == 0) sc->sc_class->uc_rclk = at91_master_clock; - return (uart_bus_probe(dev, 0, 0, 0, device_get_unit(dev))); + return (uart_bus_probe(dev, 0, 0, 0, 0, device_get_unit(dev), 0)); } Index: stable/11/sys/arm/cavium/cns11xx/uart_bus_ec.c =================================================================== --- stable/11/sys/arm/cavium/cns11xx/uart_bus_ec.c +++ stable/11/sys/arm/cavium/cns11xx/uart_bus_ec.c @@ -69,7 +69,7 @@ sc = device_get_softc(dev); sc->sc_class = &uart_ns8250_class; - status = uart_bus_probe(dev, EC_UART_REGSHIFT, EC_UART_CLOCK, 0, 0); + status = uart_bus_probe(dev, EC_UART_REGSHIFT, 0, EC_UART_CLOCK, 0, 0, 0); return (status); } Index: stable/11/sys/arm/nvidia/tegra_uart.c =================================================================== --- stable/11/sys/arm/nvidia/tegra_uart.c +++ stable/11/sys/arm/nvidia/tegra_uart.c @@ -217,7 +217,7 @@ device_printf(dev, "Cannot enable UART clock: %d\n", rv); return (ENXIO); } - return (uart_bus_probe(dev, shift, (int)freq, 0, 0)); + return (uart_bus_probe(dev, shift, 0, (int)freq, 0, 0, 0)); } static int @@ -248,4 +248,4 @@ }; DRIVER_MODULE(tegra_uart, simplebus, tegra_uart_driver, uart_devclass, - 0, 0); \ No newline at end of file + 0, 0); Index: stable/11/sys/arm/xscale/i8134x/uart_bus_i81342.c =================================================================== --- stable/11/sys/arm/xscale/i8134x/uart_bus_i81342.c +++ stable/11/sys/arm/xscale/i8134x/uart_bus_i81342.c @@ -83,7 +83,7 @@ 0x40 | 0x10); bus_release_resource(dev, sc->sc_rtype, sc->sc_rrid, sc->sc_rres); - err = uart_bus_probe(dev, 2, 33334000, 0, device_get_unit(dev)); + err = uart_bus_probe(dev, 2, 0, 33334000, 0, device_get_unit(dev), 0); sc->sc_rxfifosz = sc->sc_txfifosz = 1; return (err); } Index: stable/11/sys/arm/xscale/ixp425/uart_bus_ixp425.c =================================================================== --- stable/11/sys/arm/xscale/ixp425/uart_bus_ixp425.c +++ stable/11/sys/arm/xscale/ixp425/uart_bus_ixp425.c @@ -78,5 +78,5 @@ if (bootverbose) device_printf(dev, "rclk %u\n", rclk); - return uart_bus_probe(dev, 0, rclk, 0, 0); + return uart_bus_probe(dev, 0, 0, rclk, 0, 0, 0); } Index: stable/11/sys/arm/xscale/pxa/uart_bus_pxa.c =================================================================== --- stable/11/sys/arm/xscale/pxa/uart_bus_pxa.c +++ stable/11/sys/arm/xscale/pxa/uart_bus_pxa.c @@ -97,7 +97,7 @@ sc = device_get_softc(dev); sc->sc_class = &uart_ns8250_class; - return(uart_bus_probe(dev, 2, PXA2X0_COM_FREQ, 0, 0)); + return(uart_bus_probe(dev, 2, 0, PXA2X0_COM_FREQ, 0, 0, 0)); } DRIVER_MODULE(uart, pxa, uart_pxa_driver, uart_devclass, 0, 0); Index: stable/11/sys/dev/acpica/acpi.c =================================================================== --- stable/11/sys/dev/acpica/acpi.c +++ stable/11/sys/dev/acpica/acpi.c @@ -2169,6 +2169,14 @@ ACPI_FAILURE(AcpiGetObjectInfo(h, &devinfo))) return (FALSE); + /* Onboard serial ports on certain AMD motherboards have an invalid _STA + * method that always returns 0. Force them to always be treated as present. + * + * This may solely be a quirk of a preproduction BIOS. + */ + if (acpi_MatchHid(h, "AMDI0020") || acpi_MatchHid(h, "AMDI0010")) + return (TRUE); + /* If no _STA method, must be present */ present = (devinfo->Valid & ACPI_VALID_STA) == 0 || ACPI_DEVICE_PRESENT(devinfo->CurrentStatus) ? TRUE : FALSE; Index: stable/11/sys/dev/uart/uart.h =================================================================== --- stable/11/sys/dev/uart/uart.h +++ stable/11/sys/dev/uart/uart.h @@ -41,9 +41,12 @@ u_int chan; u_int rclk; u_int regshft; + u_int regiowidth; + u_int busy_detect; }; #define uart_regofs(bas, reg) ((reg) << (bas)->regshft) +#define uart_regiowidth(bas) ((bas)->regiowidth) #define uart_getreg(bas, reg) \ bus_space_read_1((bas)->bst, (bas)->bsh, uart_regofs(bas, reg)) Index: stable/11/sys/dev/uart/uart_bus.h =================================================================== --- stable/11/sys/dev/uart/uart_bus.h +++ stable/11/sys/dev/uart/uart_bus.h @@ -54,6 +54,9 @@ #define UART_IOCTL_OFLOW 3 #define UART_IOCTL_BAUD 4 +/* UART quirk flag */ +#define UART_F_BUSY_DETECT 0x1 + /* * UART class & instance (=softc) */ @@ -63,6 +66,7 @@ u_int uc_range; /* Bus space address range. */ u_int uc_rclk; /* Default rclk for this device. */ u_int uc_rshift; /* Default regshift for this device. */ + u_int uc_riowidth; /* Default reg io width for this device. */ }; struct uart_softc { @@ -137,7 +141,7 @@ int uart_bus_resume(device_t dev); serdev_intr_t *uart_bus_ihand(device_t dev, int ipend); int uart_bus_ipend(device_t dev); -int uart_bus_probe(device_t dev, int regshft, int rclk, int rid, int chan); +int uart_bus_probe(device_t dev, int regshft, int regiowidth, int rclk, int rid, int chan, int quirks); int uart_bus_sysdev(device_t dev); void uart_sched_softih(struct uart_softc *, uint32_t); Index: stable/11/sys/dev/uart/uart_bus_acpi.c =================================================================== --- stable/11/sys/dev/uart/uart_bus_acpi.c +++ stable/11/sys/dev/uart/uart_bus_acpi.c @@ -35,11 +35,14 @@ #include #include -#include - #include #include +#include +#include +#include +#include + static int uart_acpi_probe(device_t dev); static device_method_t uart_acpi_methods[] = { @@ -57,33 +60,40 @@ sizeof(struct uart_softc), }; -static struct isa_pnp_id acpi_ns8250_ids[] = { - {0x0005d041, "Standard PC COM port"}, /* PNP0500 */ - {0x0105d041, "16550A-compatible COM port"}, /* PNP0501 */ - {0x0205d041, "Multiport serial device (non-intelligent 16550)"}, /* PNP0502 */ - {0x1005d041, "Generic IRDA-compatible device"}, /* PNP0510 */ - {0x1105d041, "Generic IRDA-compatible device"}, /* PNP0511 */ - {0x04f0235c, "Wacom Tablet PC Screen"}, /* WACF004 */ - {0x0ef0235c, "Wacom Tablet PC Screen 00e"}, /* WACF00e */ - {0xe502aa1a, "Wacom Tablet at FuS Lifebook T"}, /* FUJ02E5 */ - {0} -}; +static struct acpi_uart_compat_data * +uart_acpi_find_device(device_t dev) +{ + struct acpi_uart_compat_data **cd, *cd_it; + ACPI_HANDLE h; + if ((h = acpi_get_handle(dev)) == NULL) + return (NULL); + + SET_FOREACH(cd, uart_acpi_class_and_device_set) { + for (cd_it = *cd; cd_it->cd_hid != NULL; cd_it++) { + if (acpi_MatchHid(h, cd_it->cd_hid)) + return (cd_it); + } + } + + return (NULL); +} + static int uart_acpi_probe(device_t dev) { struct uart_softc *sc; - device_t parent; + struct acpi_uart_compat_data *cd; - parent = device_get_parent(dev); sc = device_get_softc(dev); - if (!ISA_PNP_PROBE(parent, dev, acpi_ns8250_ids)) { - sc->sc_class = &uart_ns8250_class; - return (uart_bus_probe(dev, 0, 0, 0, 0)); + if ((cd = uart_acpi_find_device(dev)) != NULL) { + sc->sc_class = cd->cd_class; + if (cd->cd_desc != NULL) + device_set_desc(dev, cd->cd_desc); + return (uart_bus_probe(dev, cd->cd_regshft, cd->cd_regiowidth, + cd->cd_rclk, 0, 0, cd->cd_quirks)); } - - /* Add checks for non-ns8250 IDs here. */ return (ENXIO); } Index: stable/11/sys/dev/uart/uart_bus_ebus.c =================================================================== --- stable/11/sys/dev/uart/uart_bus_ebus.c +++ stable/11/sys/dev/uart/uart_bus_ebus.c @@ -97,7 +97,7 @@ return (ENXIO); } sc->sc_class = &uart_ns8250_class; - return (uart_bus_probe(dev, 0, 0, 0, 0)); + return (uart_bus_probe(dev, 0, 0, 0, 0, 0, 0)); } return (ENXIO); Index: stable/11/sys/dev/uart/uart_bus_fdt.c =================================================================== --- stable/11/sys/dev/uart/uart_bus_fdt.c +++ stable/11/sys/dev/uart/uart_bus_fdt.c @@ -90,6 +90,15 @@ return (0); } +int +uart_fdt_get_io_width(phandle_t node, pcell_t *cell) +{ + + if ((OF_getencprop(node, "reg-io-width", cell, sizeof(*cell))) <= 0) + return (-1); + return (0); +} + static uintptr_t uart_fdt_find_device(device_t dev) { @@ -161,7 +170,7 @@ const char **name; struct uart_class *class; phandle_t node, chosen; - pcell_t br, clk, shift; + pcell_t br, clk, shift, iowidth; char *cp; int err; @@ -212,6 +221,9 @@ if (uart_fdt_get_shift(node, &shift) != 0) shift = uart_getregshift(class); + if (uart_fdt_get_io_width(node, &iowidth) != 0) + iowidth = uart_getregiowidth(class); + if (OF_getencprop(node, "current-speed", &br, sizeof(br)) <= 0) br = 0; @@ -232,7 +244,7 @@ { struct uart_softc *sc; phandle_t node; - pcell_t clock, shift; + pcell_t clock, shift, iowidth; int err; sc = device_get_softc(dev); @@ -250,8 +262,10 @@ return (err); if (uart_fdt_get_shift(node, &shift) != 0) shift = uart_getregshift(sc->sc_class); + if (uart_fdt_get_io_width(node, &iowidth) != 0) + iowidth = uart_getregiowidth(sc->sc_class); - return (uart_bus_probe(dev, (int)shift, (int)clock, 0, 0)); + return (uart_bus_probe(dev, (int)shift, (int)iowidth, (int)clock, 0, 0, 0)); } DRIVER_MODULE(uart, simplebus, uart_fdt_driver, uart_devclass, 0, 0); Index: stable/11/sys/dev/uart/uart_bus_isa.c =================================================================== --- stable/11/sys/dev/uart/uart_bus_isa.c +++ stable/11/sys/dev/uart/uart_bus_isa.c @@ -185,7 +185,7 @@ #else sc->sc_class = &uart_ns8250_class; #endif - return (uart_bus_probe(dev, 0, 0, 0, 0)); + return (uart_bus_probe(dev, 0, 0, 0, 0, 0, 0)); } DRIVER_MODULE(uart, isa, uart_isa_driver, uart_devclass, 0, 0); Index: stable/11/sys/dev/uart/uart_bus_pccard.c =================================================================== --- stable/11/sys/dev/uart/uart_bus_pccard.c +++ stable/11/sys/dev/uart/uart_bus_pccard.c @@ -93,7 +93,7 @@ sc = device_get_softc(dev); sc->sc_class = &uart_ns8250_class; - error = uart_bus_probe(dev, 0, 0, 0, 0); + error = uart_bus_probe(dev, 0, 0, 0, 0, 0, 0); if (error > 0) return (error); return (uart_bus_attach(dev)); Index: stable/11/sys/dev/uart/uart_bus_pci.c =================================================================== --- stable/11/sys/dev/uart/uart_bus_pci.c +++ stable/11/sys/dev/uart/uart_bus_pci.c @@ -202,7 +202,7 @@ return (ENXIO); match: - result = uart_bus_probe(dev, id->regshft, id->rclk, id->rid, 0); + result = uart_bus_probe(dev, id->regshft, 0, id->rclk, id->rid, 0, 0); /* Bail out on error. */ if (result > 0) return (result); Index: stable/11/sys/dev/uart/uart_bus_puc.c =================================================================== --- stable/11/sys/dev/uart/uart_bus_puc.c +++ stable/11/sys/dev/uart/uart_bus_puc.c @@ -81,7 +81,7 @@ if (BUS_READ_IVAR(parent, dev, PUC_IVAR_CLOCK, &rclk)) rclk = 0; - return (uart_bus_probe(dev, 0, rclk, 0, 0)); + return (uart_bus_probe(dev, 0, 0, rclk, 0, 0, 0)); } DRIVER_MODULE(uart, puc, uart_puc_driver, uart_devclass, 0, 0); Index: stable/11/sys/dev/uart/uart_bus_scc.c =================================================================== --- stable/11/sys/dev/uart/uart_bus_scc.c +++ stable/11/sys/dev/uart/uart_bus_scc.c @@ -112,7 +112,7 @@ BUS_READ_IVAR(parent, dev, SCC_IVAR_REGSHFT, &rs)) return (ENXIO); - return (uart_bus_probe(dev, rs, cl, 0, ch)); + return (uart_bus_probe(dev, rs, 0, cl, 0, ch, 0)); } DRIVER_MODULE(uart, scc, uart_scc_driver, uart_devclass, 0, 0); Index: stable/11/sys/dev/uart/uart_core.c =================================================================== --- stable/11/sys/dev/uart/uart_core.c +++ stable/11/sys/dev/uart/uart_core.c @@ -252,6 +252,12 @@ return ((uc != NULL) ? uc->uc_rshift : 0); } +u_int +uart_getregiowidth(struct uart_class *uc) +{ + return ((uc != NULL) ? uc->uc_riowidth : 0); +} + /* * Schedule a soft interrupt. We do this on the 0 to !0 transition * of the TTY pending interrupt status. @@ -481,7 +487,7 @@ } int -uart_bus_probe(device_t dev, int regshft, int rclk, int rid, int chan) +uart_bus_probe(device_t dev, int regshft, int regiowidth, int rclk, int rid, int chan, int quirks) { struct uart_softc *sc; struct uart_devinfo *sysdev; @@ -539,7 +545,9 @@ sc->sc_bas.bst = rman_get_bustag(sc->sc_rres); sc->sc_bas.chan = chan; sc->sc_bas.regshft = regshft; + sc->sc_bas.regiowidth = regiowidth; sc->sc_bas.rclk = (rclk == 0) ? sc->sc_class->uc_rclk : rclk; + sc->sc_bas.busy_detect = !!(quirks & UART_F_BUSY_DETECT); SLIST_FOREACH(sysdev, &uart_sysdevs, next) { if (chan == sysdev->bas.chan && Index: stable/11/sys/dev/uart/uart_cpu.h =================================================================== --- stable/11/sys/dev/uart/uart_cpu.h +++ stable/11/sys/dev/uart/uart_cpu.h @@ -80,6 +80,7 @@ struct uart_ops *uart_getops(struct uart_class *); int uart_getrange(struct uart_class *); u_int uart_getregshift(struct uart_class *); +u_int uart_getregiowidth(struct uart_class *); void uart_add_sysdev(struct uart_devinfo *); Index: stable/11/sys/dev/uart/uart_cpu_acpi.h =================================================================== --- stable/11/sys/dev/uart/uart_cpu_acpi.h +++ stable/11/sys/dev/uart/uart_cpu_acpi.h @@ -0,0 +1,69 @@ +/*- + * 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 *cd_hid; + struct uart_class *cd_class; + + uint16_t cd_port_subtype; + int cd_regshft; + int cd_regiowidth; + int cd_rclk; + int cd_quirks; + const char *cd_desc; +}; + +/* + * 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: stable/11/sys/dev/uart/uart_cpu_fdt.h =================================================================== --- stable/11/sys/dev/uart/uart_cpu_fdt.h +++ stable/11/sys/dev/uart/uart_cpu_fdt.h @@ -54,5 +54,6 @@ bus_space_handle_t *, int *, u_int *, u_int *); int uart_fdt_get_clock(phandle_t node, pcell_t *cell); int uart_fdt_get_shift(phandle_t node, pcell_t *cell); +int uart_fdt_get_io_width(phandle_t node, pcell_t *cell); #endif /* _DEV_UART_CPU_FDT_H_ */ Index: stable/11/sys/dev/uart/uart_cpu_fdt.c =================================================================== --- stable/11/sys/dev/uart/uart_cpu_fdt.c +++ stable/11/sys/dev/uart/uart_cpu_fdt.c @@ -70,53 +70,6 @@ return ((pmap_kextract(b1->bsh) == pmap_kextract(b2->bsh)) ? 1 : 0); } -static int -phandle_chosen_propdev(phandle_t chosen, const char *name, phandle_t *node) -{ - char buf[64]; - - if (OF_getprop(chosen, name, buf, sizeof(buf)) <= 0) - return (ENXIO); - if ((*node = OF_finddevice(buf)) == -1) - return (ENXIO); - - return (0); -} - -static const struct ofw_compat_data * -uart_fdt_find_compatible(phandle_t node, const struct ofw_compat_data *cd) -{ - const struct ofw_compat_data *ocd; - - for (ocd = cd; ocd->ocd_str != NULL; ocd++) { - if (fdt_is_compatible(node, ocd->ocd_str)) - return (ocd); - } - return (NULL); -} - -static uintptr_t -uart_fdt_find_by_node(phandle_t node, int class_list) -{ - struct ofw_compat_data **cd; - const struct ofw_compat_data *ocd; - - if (class_list) { - SET_FOREACH(cd, uart_fdt_class_set) { - ocd = uart_fdt_find_compatible(node, *cd); - if ((ocd != NULL) && (ocd->ocd_data != 0)) - return (ocd->ocd_data); - } - } else { - SET_FOREACH(cd, uart_fdt_class_and_device_set) { - ocd = uart_fdt_find_compatible(node, *cd); - if ((ocd != NULL) && (ocd->ocd_data != 0)) - return (ocd->ocd_data); - } - } - return (0); -} - int uart_cpu_getdev(int devtype, struct uart_devinfo *di) { Index: stable/11/sys/dev/uart/uart_dev_ns8250.c =================================================================== --- stable/11/sys/dev/uart/uart_dev_ns8250.c +++ stable/11/sys/dev/uart/uart_dev_ns8250.c @@ -24,6 +24,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "opt_acpi.h" #include "opt_platform.h" #include "opt_uart.h" @@ -52,7 +53,9 @@ #include #include #include - +#ifdef DEV_ACPI +#include +#endif #include #include "uart_if.h" @@ -390,6 +393,26 @@ .uc_rclk = DEFAULT_RCLK, .uc_rshift = 0 }; + +/* + * XXX -- refactor out ACPI and FDT ifdefs + */ +#ifdef DEV_ACPI +static struct acpi_uart_compat_data acpi_compat_data[] = { + {"AMD0020", &uart_ns8250_class, 0, 2, 0, 48000000, UART_F_BUSY_DETECT, "AMD / Synopsys Designware UART"}, + {"AMDI0020", &uart_ns8250_class, 0, 2, 0, 48000000, UART_F_BUSY_DETECT, "AMD / Synopsys Designware UART"}, + {"PNP0500", &uart_ns8250_class, 0, 0, 0, 0, 0, "Standard PC COM port"}, + {"PNP0501", &uart_ns8250_class, 0, 0, 0, 0, 0, "16550A-compatible COM port"}, + {"PNP0502", &uart_ns8250_class, 0, 0, 0, 0, 0, "Multiport serial device (non-intelligent 16550)"}, + {"PNP0510", &uart_ns8250_class, 0, 0, 0, 0, 0, "Generic IRDA-compatible device"}, + {"PNP0511", &uart_ns8250_class, 0, 0, 0, 0, 0, "Generic IRDA-compatible device"}, + {"WACF004", &uart_ns8250_class, 0, 0, 0, 0, 0, "Wacom Tablet PC Screen"}, + {"WACF00E", &uart_ns8250_class, 0, 0, 0, 0, 0, "Wacom Tablet PC Screen 00e"}, + {"FUJ02E5", &uart_ns8250_class, 0, 0, 0, 0, 0, "Wacom Tablet at FuS Lifebook T"}, + {NULL, NULL, 0, 0 , 0, 0, 0, NULL}, +}; +UART_ACPI_CLASS_AND_DEVICE(acpi_compat_data); +#endif #ifdef FDT static struct ofw_compat_data compat_data[] = { Index: stable/11/sys/dev/uart/uart_dev_pl011.c =================================================================== --- stable/11/sys/dev/uart/uart_dev_pl011.c +++ stable/11/sys/dev/uart/uart_dev_pl011.c @@ -283,6 +283,15 @@ }; UART_FDT_CLASS_AND_DEVICE(compat_data); +#ifdef DEV_ACPI +static struct acpi_uart_compat_data acpi_compat_data[] = { + {"ARMH0011", &uart_pl011_class, ACPI_DBG2_ARM_PL011, 2, 0, 0, 0, "uart plo11"}, + {"ARMH0011", &uart_pl011_class, ACPI_DBG2_ARM_SBSA_GENERIC, 2, 0, 0, 0, "uart plo11"}, + {NULL, NULL, 0, 0, 0, 0, 0, NULL}, +}; +UART_ACPI_CLASS_AND_DEVICE(acpi_compat_data); +#endif + static int uart_pl011_bus_attach(struct uart_softc *sc) { Index: stable/11/sys/dev/uart/uart_dev_snps.c =================================================================== --- stable/11/sys/dev/uart/uart_dev_snps.c +++ stable/11/sys/dev/uart/uart_dev_snps.c @@ -61,22 +61,9 @@ #endif }; -static int -snps_uart_attach(struct uart_softc *uart_sc) -{ - struct snps_softc *sc; - - sc = (struct snps_softc *)uart_sc; - - /* UART requires to read USR reg when IIR_BUSY */ - sc->ns8250.busy_detect = 1; - - return (ns8250_bus_attach(uart_sc)); -} - static kobj_method_t snps_methods[] = { KOBJMETHOD(uart_probe, ns8250_bus_probe), - KOBJMETHOD(uart_attach, snps_uart_attach), + KOBJMETHOD(uart_attach, ns8250_bus_attach), KOBJMETHOD(uart_detach, ns8250_bus_detach), KOBJMETHOD(uart_flush, ns8250_bus_flush), KOBJMETHOD(uart_getsig, ns8250_bus_getsig), @@ -136,7 +123,7 @@ struct snps_softc *sc; struct uart_class *uart_class; phandle_t node; - uint32_t shift, clock; + uint32_t shift, iowidth, clock; uint64_t freq; int error; #ifdef EXT_RESOURCES @@ -159,6 +146,8 @@ node = ofw_bus_get_node(dev); if (OF_getencprop(node, "reg-shift", &shift, sizeof(shift)) <= 0) shift = 0; + if (OF_getencprop(node, "reg-io-width", &iowidth, sizeof(iowidth)) <= 0) + iowidth = 1; if (OF_getencprop(node, "clock-frequency", &clock, sizeof(clock)) <= 0) clock = 0; @@ -200,7 +189,7 @@ if (bootverbose && clock == 0) device_printf(dev, "could not determine frequency\n"); - error = uart_bus_probe(dev, (int)shift, (int)clock, 0, 0); + error = uart_bus_probe(dev, (int)shift, (int)iowidth, (int)clock, 0, 0, UART_F_BUSY_DETECT); if (error != 0) return (error); Index: stable/11/sys/mips/adm5120/uart_bus_adm5120.c =================================================================== --- stable/11/sys/mips/adm5120/uart_bus_adm5120.c +++ stable/11/sys/mips/adm5120/uart_bus_adm5120.c @@ -87,7 +87,7 @@ sc->sc_class = &uart_adm5120_uart_class; bcopy(&sc->sc_sysdev->bas, &sc->sc_bas, sizeof(sc->sc_bas)); - return (uart_bus_probe(dev, 0, 0, 0, 0)); + return (uart_bus_probe(dev, 0, 0, 0, 0, 0, 0)); } DRIVER_MODULE(uart, obio, uart_adm5120_driver, uart_devclass, 0, 0); Index: stable/11/sys/mips/alchemy/uart_bus_alchemy.c =================================================================== --- stable/11/sys/mips/alchemy/uart_bus_alchemy.c +++ stable/11/sys/mips/alchemy/uart_bus_alchemy.c @@ -81,7 +81,7 @@ sc->sc_class = &uart_ns8250_class; bcopy(&sc->sc_sysdev->bas, &sc->sc_bas, sizeof(sc->sc_bas)); - return (uart_bus_probe(dev, 0, 0, 0, 0)); + return (uart_bus_probe(dev, 0, 0, 0, 0, 0, 0)); } DRIVER_MODULE(uart, obio, uart_alchemy_driver, uart_devclass, 0, 0); Index: stable/11/sys/mips/atheros/uart_bus_ar71xx.c =================================================================== --- stable/11/sys/mips/atheros/uart_bus_ar71xx.c +++ stable/11/sys/mips/atheros/uart_bus_ar71xx.c @@ -83,7 +83,7 @@ sc->sc_bas.bst = mips_bus_space_generic; sc->sc_bas.bsh = MIPS_PHYS_TO_KSEG1(AR71XX_UART_ADDR) + 3; - return (uart_bus_probe(dev, 2, freq, 0, 0)); + return (uart_bus_probe(dev, 2, 0, freq, 0, 0, 0)); } DRIVER_MODULE(uart, apb, uart_ar71xx_driver, uart_devclass, 0, 0); Index: stable/11/sys/mips/atheros/uart_bus_ar933x.c =================================================================== --- stable/11/sys/mips/atheros/uart_bus_ar933x.c +++ stable/11/sys/mips/atheros/uart_bus_ar933x.c @@ -85,7 +85,7 @@ sc->sc_bas.bst = mips_bus_space_generic; sc->sc_bas.bsh = MIPS_PHYS_TO_KSEG1(AR71XX_UART_ADDR); - return (uart_bus_probe(dev, 2, freq, 0, 0)); + return (uart_bus_probe(dev, 2, 0, freq, 0, 0, 0)); } DRIVER_MODULE(uart, apb, uart_ar933x_driver, uart_devclass, 0, 0); Index: stable/11/sys/mips/broadcom/uart_bus_chipc.c =================================================================== --- stable/11/sys/mips/broadcom/uart_bus_chipc.c +++ stable/11/sys/mips/broadcom/uart_bus_chipc.c @@ -63,7 +63,7 @@ /* TODO: UART rate should be calculated from CPU clock speed * as fetched from bhnd bus */ socinfo = bcm_get_socinfo(); - return (uart_bus_probe(dev, 0, socinfo->uartrate, 0, 0)); + return (uart_bus_probe(dev, 0, 0, socinfo->uartrate, 0, 0, 0)); } static device_method_t uart_chipc_methods[] = { Index: stable/11/sys/mips/cavium/uart_bus_octeonusart.c =================================================================== --- stable/11/sys/mips/cavium/uart_bus_octeonusart.c +++ stable/11/sys/mips/cavium/uart_bus_octeonusart.c @@ -105,7 +105,7 @@ if (bus_space_map(sc->sc_bas.bst, CVMX_MIO_UARTX_RBR(0), uart_getrange(sc->sc_class), 0, &sc->sc_bas.bsh) != 0) return (ENXIO); - return (uart_bus_probe(dev, sc->sc_bas.regshft, 0, 0, unit)); + return (uart_bus_probe(dev, sc->sc_bas.regshft, 0, 0, 0, unit, 0)); } DRIVER_MODULE(uart, obio, uart_octeon_driver, uart_devclass, 0, 0); Index: stable/11/sys/mips/idt/uart_bus_rc32434.c =================================================================== --- stable/11/sys/mips/idt/uart_bus_rc32434.c +++ stable/11/sys/mips/idt/uart_bus_rc32434.c @@ -94,7 +94,7 @@ sc->sc_bas.bst = mips_bus_space_generic; sc->sc_bas.bsh = MIPS_PHYS_TO_KSEG1(IDT_BASE_UART0); - return (uart_bus_probe(dev, 2, 330000000UL/2, 0, 0)); + return (uart_bus_probe(dev, 2, 0, 330000000UL/2, 0, 0, 0)); } DRIVER_MODULE(uart, obio, uart_rc32434_driver, uart_devclass, 0, 0); Index: stable/11/sys/mips/malta/uart_bus_maltausart.c =================================================================== --- stable/11/sys/mips/malta/uart_bus_maltausart.c +++ stable/11/sys/mips/malta/uart_bus_maltausart.c @@ -85,7 +85,7 @@ sc->sc_sysdev->bas.bsh = MIPS_PHYS_TO_KSEG1(MALTA_UART0ADR); sc->sc_bas.bst = mips_bus_space_generic; sc->sc_bas.bsh = MIPS_PHYS_TO_KSEG1(MALTA_UART0ADR); - return(uart_bus_probe(dev, 0, 0, 0, 0)); + return(uart_bus_probe(dev, 0, 0, 0, 0, 0, 0)); } DRIVER_MODULE(uart, obio, uart_malta_driver, uart_devclass, 0, 0); Index: stable/11/sys/mips/rmi/uart_bus_xlr_iodi.c =================================================================== --- stable/11/sys/mips/rmi/uart_bus_xlr_iodi.c +++ stable/11/sys/mips/rmi/uart_bus_xlr_iodi.c @@ -74,7 +74,7 @@ sc->sc_bas.bst = rmi_bus_space; sc->sc_bas.bsh = MIPS_PHYS_TO_KSEG1(XLR_UART0ADDR); /* regshft = 2, rclk = 66000000, rid = 0, chan = 0 */ - return (uart_bus_probe(dev, 2, 66000000, 0, 0)); + return (uart_bus_probe(dev, 2, 0, 66000000, 0, 0, 0)); } DRIVER_MODULE(uart, iodi, uart_iodi_driver, uart_devclass, 0, 0); Index: stable/11/sys/mips/rt305x/uart_bus_rt305x.c =================================================================== --- stable/11/sys/mips/rt305x/uart_bus_rt305x.c +++ stable/11/sys/mips/rt305x/uart_bus_rt305x.c @@ -87,7 +87,7 @@ sc->sc_bas.bsh = MIPS_PHYS_TO_KSEG1(device_get_unit(dev)?UARTLITE_BASE:UART_BASE); - return (uart_bus_probe(dev, 2, SYSTEM_CLOCK, 0, 0)); + return (uart_bus_probe(dev, 2, 0, SYSTEM_CLOCK, 0, 0, 0)); } DRIVER_MODULE(uart, obio, uart_rt305x_driver, uart_devclass, 0, 0); Index: stable/11/sys/modules/uart/Makefile =================================================================== --- stable/11/sys/modules/uart/Makefile +++ stable/11/sys/modules/uart/Makefile @@ -2,6 +2,12 @@ .PATH: ${SRCTOP}/sys/dev/uart + +.if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "amd64" || \ + ${MACHINE_ARCH} == "i386" +uart_bus_acpi=uart_bus_acpi.c +.endif + .if ${MACHINE_CPUARCH} == "sparc64" uart_bus_ebus= uart_bus_ebus.c .endif @@ -25,15 +31,15 @@ .endif KMOD= uart -SRCS= uart_bus_acpi.c ${uart_bus_ebus} uart_bus_isa.c uart_bus_pccard.c \ +SRCS= ${uart_bus_acpi} ${uart_bus_ebus} uart_bus_isa.c uart_bus_pccard.c \ uart_bus_pci.c uart_bus_puc.c uart_bus_scc.c \ uart_core.c ${uart_cpu_machine} uart_dbg.c \ ${uart_dev_lpc} uart_dev_ns8250.c uart_dev_quicc.c uart_dev_sab82532.c \ uart_dev_z8530.c \ uart_if.c uart_if.h uart_subr.c uart_tty.c -SRCS+= bus_if.h card_if.h device_if.h isa_if.h ${ofw_bus_if} pci_if.h \ +SRCS+= acpi_if.h bus_if.h card_if.h device_if.h isa_if.h ${ofw_bus_if} pci_if.h \ power_if.h pccarddevs.h serdev_if.h -SRCS+= opt_platform.h opt_uart.h +SRCS+= opt_acpi.h opt_platform.h opt_uart.h .include Index: stable/11/sys/pc98/include/acpica_machdep.h =================================================================== --- stable/11/sys/pc98/include/acpica_machdep.h +++ stable/11/sys/pc98/include/acpica_machdep.h @@ -0,0 +1,6 @@ +/*- + * This file is in the public domain. + */ +/* $FreeBSD$ */ + +#include Index: stable/11/sys/powerpc/psim/uart_iobus.c =================================================================== --- stable/11/sys/powerpc/psim/uart_iobus.c +++ stable/11/sys/powerpc/psim/uart_iobus.c @@ -81,7 +81,7 @@ sc->sc_class = &uart_ns8250_class; device_set_desc(dev, "PSIM serial port"); - return (uart_bus_probe(dev, 0, 0, 0, 0)); + return (uart_bus_probe(dev, 0, 0, 0, 0, 0, 0)); } DRIVER_MODULE(uart, iobus, uart_iobus_driver, uart_devclass, 0, 0); Index: stable/11/sys/sparc64/pci/sbbc.c =================================================================== --- stable/11/sys/sparc64/pci/sbbc.c +++ stable/11/sys/sparc64/pci/sbbc.c @@ -618,7 +618,7 @@ sc = device_get_softc(dev); sc->sc_class = &uart_sbbc_class; device_set_desc(dev, "Serengeti console"); - return (uart_bus_probe(dev, 0, 0, SBBC_PCI_BAR, 0)); + return (uart_bus_probe(dev, 0, 0, 0, SBBC_PCI_BAR, 0, 0)); } /*