18860e8c6SPeter Grehan /* 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_pio.h> 458860e8c6SPeter Grehan #include <machine/bus.h> 468860e8c6SPeter Grehan #include <sys/timepps.h> 478860e8c6SPeter Grehan 488860e8c6SPeter Grehan #include <dev/ofw/openfirm.h> 498860e8c6SPeter Grehan #include <powerpc/psim/iobusvar.h> 508860e8c6SPeter Grehan 518860e8c6SPeter Grehan #include <dev/sio/sioreg.h> 528860e8c6SPeter Grehan #include <dev/sio/siovar.h> 538860e8c6SPeter Grehan 548860e8c6SPeter Grehan #include <isa/isavar.h> /* for isa_irq_pending() prototype */ 558860e8c6SPeter Grehan 568860e8c6SPeter Grehan static int sio_iobus_attach(device_t dev); 578860e8c6SPeter Grehan static int sio_iobus_probe(device_t dev); 588860e8c6SPeter Grehan 598860e8c6SPeter Grehan static device_method_t sio_iobus_methods[] = { 608860e8c6SPeter Grehan /* Device interface */ 618860e8c6SPeter Grehan DEVMETHOD(device_probe, sio_iobus_probe), 628860e8c6SPeter Grehan DEVMETHOD(device_attach, sio_iobus_attach), 638860e8c6SPeter Grehan 648860e8c6SPeter Grehan { 0, 0 } 658860e8c6SPeter Grehan }; 668860e8c6SPeter Grehan 678860e8c6SPeter Grehan static driver_t sio_iobus_driver = { 688860e8c6SPeter Grehan sio_driver_name, 698860e8c6SPeter Grehan sio_iobus_methods, 708860e8c6SPeter Grehan 0, 718860e8c6SPeter Grehan }; 728860e8c6SPeter Grehan 738860e8c6SPeter Grehan static int 748860e8c6SPeter Grehan sio_iobus_attach(device_t dev) 758860e8c6SPeter Grehan { 768860e8c6SPeter Grehan return (sioattach(dev, 0, DEFAULT_RCLK)); 778860e8c6SPeter Grehan } 788860e8c6SPeter Grehan 798860e8c6SPeter Grehan static int 808860e8c6SPeter Grehan sio_iobus_probe(device_t dev) 818860e8c6SPeter Grehan { 828860e8c6SPeter Grehan char *type = iobus_get_name(dev); 838860e8c6SPeter Grehan 848860e8c6SPeter Grehan if (strncmp(type, "com", 3) != 0) 858860e8c6SPeter Grehan return (ENXIO); 868860e8c6SPeter Grehan 878860e8c6SPeter Grehan 888860e8c6SPeter Grehan device_set_desc(dev, "PSIM serial port"); 898860e8c6SPeter Grehan 908860e8c6SPeter Grehan /* 918860e8c6SPeter Grehan * Call sioprobe with noprobe=1, to avoid hitting a psim bug 928860e8c6SPeter Grehan */ 938860e8c6SPeter Grehan return (sioprobe(dev, 0, 0, 1)); 948860e8c6SPeter Grehan } 958860e8c6SPeter Grehan 968860e8c6SPeter Grehan DRIVER_MODULE(sio, iobus, sio_iobus_driver, sio_devclass, 0, 0); 978860e8c6SPeter Grehan 988860e8c6SPeter Grehan /* 998860e8c6SPeter Grehan * Stub function. Perhaps a way to get this to work correctly would 1008860e8c6SPeter Grehan * be for child devices to set a field in the dev structure to 1018860e8c6SPeter Grehan * inform the parent that they are isa devices, and then use a 1028860e8c6SPeter Grehan * intr_pending() call which would propagate up to nexus to see 1038860e8c6SPeter Grehan * if the interrupt controller had any intrs in the isa group set 1048860e8c6SPeter Grehan */ 1058860e8c6SPeter Grehan intrmask_t 1068860e8c6SPeter Grehan isa_irq_pending(void) 1078860e8c6SPeter Grehan { 1088860e8c6SPeter Grehan return (0); 1098860e8c6SPeter Grehan } 110