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