1139825Simp/*- 2103620Sgrehan * Copyright 2002 by Peter Grehan. All rights reserved. 3103620Sgrehan * 4103620Sgrehan * Redistribution and use in source and binary forms, with or without 5103620Sgrehan * modification, are permitted provided that the following conditions 6103620Sgrehan * are met: 7103620Sgrehan * 1. Redistributions of source code must retain the above copyright 8103620Sgrehan * notice, this list of conditions and the following disclaimer. 9103620Sgrehan * 2. Redistributions in binary form must reproduce the above copyright 10103620Sgrehan * notice, this list of conditions and the following disclaimer in the 11103620Sgrehan * documentation and/or other materials provided with the distribution. 12103620Sgrehan * 3. The name of the author may not be used to endorse or promote products 13103620Sgrehan * derived from this software without specific prior written permission. 14103620Sgrehan * 15103620Sgrehan * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16103620Sgrehan * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17103620Sgrehan * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18103620Sgrehan * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19103620Sgrehan * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 20103620Sgrehan * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21103620Sgrehan * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 22103620Sgrehan * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 23103620Sgrehan * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24103620Sgrehan * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25103620Sgrehan * SUCH DAMAGE. 26103620Sgrehan * 27103620Sgrehan * $FreeBSD: releng/10.2/sys/powerpc/psim/uart_iobus.c 160722 2006-07-26 19:39:55Z marcel $ 28103620Sgrehan */ 29103620Sgrehan 30103620Sgrehan/* 31103620Sgrehan * PSIM local bus 16550 32103620Sgrehan */ 33103620Sgrehan 34103620Sgrehan#include <sys/param.h> 35103620Sgrehan#include <sys/systm.h> 36103620Sgrehan#include <sys/bus.h> 37103620Sgrehan#include <sys/conf.h> 38103620Sgrehan#include <sys/kernel.h> 39103620Sgrehan#include <sys/lock.h> 40103620Sgrehan#include <sys/malloc.h> 41103620Sgrehan#include <sys/mutex.h> 42103620Sgrehan#include <sys/module.h> 43103620Sgrehan#include <sys/tty.h> 44103620Sgrehan#include <machine/bus.h> 45103620Sgrehan#include <sys/timepps.h> 46103620Sgrehan 47103620Sgrehan#include <dev/ofw/openfirm.h> 48103620Sgrehan#include <powerpc/psim/iobusvar.h> 49103620Sgrehan 50160722Smarcel#include <dev/uart/uart.h> 51160722Smarcel#include <dev/uart/uart_bus.h> 52103620Sgrehan 53160722Smarcelstatic int uart_iobus_probe(device_t dev); 54103620Sgrehan 55160722Smarcelstatic device_method_t uart_iobus_methods[] = { 56103620Sgrehan /* Device interface */ 57160722Smarcel DEVMETHOD(device_probe, uart_iobus_probe), 58160722Smarcel DEVMETHOD(device_attach, uart_bus_attach), 59160722Smarcel DEVMETHOD(device_detach, uart_bus_detach), 60103620Sgrehan 61103620Sgrehan { 0, 0 } 62103620Sgrehan}; 63103620Sgrehan 64160722Smarcelstatic driver_t uart_iobus_driver = { 65160722Smarcel uart_driver_name, 66160722Smarcel uart_iobus_methods, 67160722Smarcel sizeof(struct uart_softc), 68103620Sgrehan}; 69103620Sgrehan 70103620Sgrehanstatic int 71160722Smarceluart_iobus_probe(device_t dev) 72103620Sgrehan{ 73160722Smarcel struct uart_softc *sc; 74160722Smarcel char *type; 75103620Sgrehan 76160722Smarcel type = iobus_get_name(dev); 77103620Sgrehan if (strncmp(type, "com", 3) != 0) 78103620Sgrehan return (ENXIO); 79103620Sgrehan 80160722Smarcel sc = device_get_softc(dev); 81160722Smarcel sc->sc_class = &uart_ns8250_class; 82103620Sgrehan 83103620Sgrehan device_set_desc(dev, "PSIM serial port"); 84160722Smarcel return (uart_bus_probe(dev, 0, 0, 0, 0)); 85103620Sgrehan} 86103620Sgrehan 87160722SmarcelDRIVER_MODULE(uart, iobus, uart_iobus_driver, uart_devclass, 0, 0); 88