1/*- 2 * Copyright 2003-2011 Netlogic Microsystems (Netlogic). All rights 3 * reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: 8 * 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in 13 * the documentation and/or other materials provided with the 14 * distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY Netlogic Microsystems ``AS IS'' AND 17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NETLOGIC OR CONTRIBUTORS BE 20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 26 * THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 * NETLOGIC_BSD */ 29 30#include <sys/cdefs.h> 31__FBSDID("$FreeBSD$"); 32 33#include <sys/param.h> 34#include <sys/systm.h> 35#include <sys/bus.h> 36#include <sys/kernel.h> 37#include <sys/module.h> 38#include <sys/lock.h> 39#include <sys/mutex.h> 40#include <sys/rman.h> 41 42#include <machine/bus.h> 43#include <machine/resource.h> 44 45#include <mips/nlm/hal/haldefs.h> 46#include <mips/nlm/hal/iomap.h> 47#include <mips/nlm/hal/uart.h> 48 49#include <dev/uart/uart.h> 50#include <dev/uart/uart_bus.h> 51#include <dev/uart/uart_cpu.h> 52 53static int uart_iodi_probe(device_t dev); 54 55static device_method_t uart_iodi_methods[] = { 56 /* Device interface */ 57 DEVMETHOD(device_probe, uart_iodi_probe), 58 DEVMETHOD(device_attach, uart_bus_attach), 59 DEVMETHOD(device_detach, uart_bus_detach), 60 {0, 0} 61}; 62 63static driver_t uart_iodi_driver = { 64 uart_driver_name, 65 uart_iodi_methods, 66 sizeof(struct uart_softc), 67}; 68 69extern SLIST_HEAD(uart_devinfo_list, uart_devinfo) uart_sysdevs; 70 71static int 72uart_iodi_probe(device_t dev) 73{ 74 struct uart_softc *sc; 75 76 sc = device_get_softc(dev); 77 sc->sc_sysdev = SLIST_FIRST(&uart_sysdevs); 78 sc->sc_class = &uart_ns8250_class; 79 bcopy(&sc->sc_sysdev->bas, &sc->sc_bas, sizeof(sc->sc_bas)); 80 sc->sc_sysdev->bas.bst = rmi_bus_space; 81 sc->sc_sysdev->bas.bsh = nlm_get_uart_regbase(0, 0); 82 sc->sc_bas.bst = rmi_bus_space; 83 sc->sc_bas.bsh = nlm_get_uart_regbase(0, 0); 84 /* regshft = 2, rclk = 66000000, rid = 0, chan = 0 */ 85 return (uart_bus_probe(dev, 2, 133000000, 0, 0)); 86} 87 88DRIVER_MODULE(uart, iodi, uart_iodi_driver, uart_devclass, 0, 0); 89