160727d8bSWarner Losh /*- 271e3c308SPedro F. Giffuni * SPDX-License-Identifier: BSD-3-Clause 371e3c308SPedro F. Giffuni * 48860e8c6SPeter Grehan * Copyright 2002 by Peter Grehan. All rights reserved. 58860e8c6SPeter Grehan * 68860e8c6SPeter Grehan * Redistribution and use in source and binary forms, with or without 78860e8c6SPeter Grehan * modification, are permitted provided that the following conditions 88860e8c6SPeter Grehan * are met: 98860e8c6SPeter Grehan * 1. Redistributions of source code must retain the above copyright 108860e8c6SPeter Grehan * notice, this list of conditions and the following disclaimer. 118860e8c6SPeter Grehan * 2. Redistributions in binary form must reproduce the above copyright 128860e8c6SPeter Grehan * notice, this list of conditions and the following disclaimer in the 138860e8c6SPeter Grehan * documentation and/or other materials provided with the distribution. 148860e8c6SPeter Grehan * 3. The name of the author may not be used to endorse or promote products 158860e8c6SPeter Grehan * derived from this software without specific prior written permission. 168860e8c6SPeter Grehan * 178860e8c6SPeter Grehan * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 188860e8c6SPeter Grehan * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 198860e8c6SPeter Grehan * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 208860e8c6SPeter Grehan * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 218860e8c6SPeter Grehan * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 228860e8c6SPeter Grehan * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 238860e8c6SPeter Grehan * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 248860e8c6SPeter Grehan * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 258860e8c6SPeter Grehan * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 268860e8c6SPeter Grehan * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 278860e8c6SPeter Grehan * SUCH DAMAGE. 288860e8c6SPeter Grehan * 298860e8c6SPeter Grehan * $FreeBSD$ 308860e8c6SPeter Grehan */ 318860e8c6SPeter Grehan 328860e8c6SPeter Grehan /* 338860e8c6SPeter Grehan * PSIM local bus 16550 348860e8c6SPeter Grehan */ 358860e8c6SPeter Grehan 368860e8c6SPeter Grehan #include <sys/param.h> 378860e8c6SPeter Grehan #include <sys/systm.h> 388860e8c6SPeter Grehan #include <sys/bus.h> 398860e8c6SPeter Grehan #include <sys/conf.h> 408860e8c6SPeter Grehan #include <sys/kernel.h> 418860e8c6SPeter Grehan #include <sys/lock.h> 428860e8c6SPeter Grehan #include <sys/malloc.h> 438860e8c6SPeter Grehan #include <sys/mutex.h> 448860e8c6SPeter Grehan #include <sys/module.h> 458860e8c6SPeter Grehan #include <sys/tty.h> 468860e8c6SPeter Grehan #include <machine/bus.h> 478860e8c6SPeter Grehan #include <sys/timepps.h> 488860e8c6SPeter Grehan 498860e8c6SPeter Grehan #include <dev/ofw/openfirm.h> 508860e8c6SPeter Grehan #include <powerpc/psim/iobusvar.h> 518860e8c6SPeter Grehan 523c1cfa96SMarcel Moolenaar #include <dev/uart/uart.h> 533c1cfa96SMarcel Moolenaar #include <dev/uart/uart_bus.h> 548860e8c6SPeter Grehan 553c1cfa96SMarcel Moolenaar static int uart_iobus_probe(device_t dev); 568860e8c6SPeter Grehan 573c1cfa96SMarcel Moolenaar static device_method_t uart_iobus_methods[] = { 588860e8c6SPeter Grehan /* Device interface */ 593c1cfa96SMarcel Moolenaar DEVMETHOD(device_probe, uart_iobus_probe), 603c1cfa96SMarcel Moolenaar DEVMETHOD(device_attach, uart_bus_attach), 613c1cfa96SMarcel Moolenaar DEVMETHOD(device_detach, uart_bus_detach), 628860e8c6SPeter Grehan 638860e8c6SPeter Grehan { 0, 0 } 648860e8c6SPeter Grehan }; 658860e8c6SPeter Grehan 663c1cfa96SMarcel Moolenaar static driver_t uart_iobus_driver = { 673c1cfa96SMarcel Moolenaar uart_driver_name, 683c1cfa96SMarcel Moolenaar uart_iobus_methods, 693c1cfa96SMarcel Moolenaar sizeof(struct uart_softc), 708860e8c6SPeter Grehan }; 718860e8c6SPeter Grehan 728860e8c6SPeter Grehan static int 733c1cfa96SMarcel Moolenaar uart_iobus_probe(device_t dev) 748860e8c6SPeter Grehan { 753c1cfa96SMarcel Moolenaar struct uart_softc *sc; 763c1cfa96SMarcel Moolenaar char *type; 778860e8c6SPeter Grehan 783c1cfa96SMarcel Moolenaar type = iobus_get_name(dev); 798860e8c6SPeter Grehan if (strncmp(type, "com", 3) != 0) 808860e8c6SPeter Grehan return (ENXIO); 818860e8c6SPeter Grehan 823c1cfa96SMarcel Moolenaar sc = device_get_softc(dev); 833c1cfa96SMarcel Moolenaar sc->sc_class = &uart_ns8250_class; 848860e8c6SPeter Grehan 858860e8c6SPeter Grehan device_set_desc(dev, "PSIM serial port"); 86*381388b9SMatt Macy return (uart_bus_probe(dev, 0, 0, 0, 0, 0, 0)); 878860e8c6SPeter Grehan } 888860e8c6SPeter Grehan 893c1cfa96SMarcel Moolenaar DRIVER_MODULE(uart, iobus, uart_iobus_driver, uart_devclass, 0, 0); 90