1198160Srrs/*- 2198625Srrs * Copyright (c) 2006 Raza Microelectronics 3198160Srrs * All rights reserved. 4198160Srrs * 5198160Srrs * Redistribution and use in source and binary forms, with or without 6198160Srrs * modification, are permitted provided that the following conditions 7198160Srrs * are met: 8198160Srrs * 1. Redistributions of source code must retain the above copyright 9198160Srrs * notice, this list of conditions and the following disclaimer. 10198160Srrs * 2. Redistributions in binary form must reproduce the above copyright 11198160Srrs * notice, this list of conditions and the following disclaimer in the 12198160Srrs * documentation and/or other materials provided with the distribution. 13198160Srrs * 14198160Srrs * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15198160Srrs * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16198160Srrs * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17198160Srrs * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 18198160Srrs * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19198160Srrs * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 20198160Srrs * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 21198160Srrs * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22198160Srrs * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23198160Srrs * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24198160Srrs * SUCH DAMAGE. 25198160Srrs */ 26198160Srrs 27198160Srrs#include <sys/cdefs.h> 28202173Simp__FBSDID("$FreeBSD: stable/11/sys/mips/rmi/uart_bus_xlr_iodi.c 340145 2018-11-04 23:28:56Z mmacy $"); 29198160Srrs 30198160Srrs#include <sys/param.h> 31198160Srrs#include <sys/systm.h> 32198160Srrs#include <sys/bus.h> 33198160Srrs#include <sys/kernel.h> 34198160Srrs#include <sys/module.h> 35198160Srrs#include <sys/lock.h> 36198160Srrs#include <sys/mutex.h> 37198160Srrs 38198160Srrs#include <machine/bus.h> 39198160Srrs#include <sys/rman.h> 40198160Srrs#include <machine/resource.h> 41198956Srrs#include <mips/rmi/iomap.h> 42198160Srrs#include <dev/uart/uart.h> 43198160Srrs#include <dev/uart/uart_bus.h> 44198956Srrs#include <dev/uart/uart_cpu.h> 45198160Srrs 46198160Srrsstatic int uart_iodi_probe(device_t dev); 47198160Srrs 48198160Srrsstatic device_method_t uart_iodi_methods[] = { 49198160Srrs /* Device interface */ 50198625Srrs DEVMETHOD(device_probe, uart_iodi_probe), 51198625Srrs DEVMETHOD(device_attach, uart_bus_attach), 52198625Srrs DEVMETHOD(device_detach, uart_bus_detach), 53198625Srrs {0, 0} 54198160Srrs}; 55198160Srrs 56198160Srrsstatic driver_t uart_iodi_driver = { 57198160Srrs uart_driver_name, 58198160Srrs uart_iodi_methods, 59198160Srrs sizeof(struct uart_softc), 60198160Srrs}; 61198160Srrs 62198956Srrs 63198956Srrsextern SLIST_HEAD(uart_devinfo_list, uart_devinfo) uart_sysdevs; 64198160Srrsstatic int 65198160Srrsuart_iodi_probe(device_t dev) 66198160Srrs{ 67198160Srrs struct uart_softc *sc; 68198160Srrs sc = device_get_softc(dev); 69198956Srrs sc->sc_sysdev = SLIST_FIRST(&uart_sysdevs); 70198625Srrs sc->sc_class = &uart_ns8250_class; 71198956Srrs bcopy(&sc->sc_sysdev->bas, &sc->sc_bas, sizeof(sc->sc_bas)); 72198956Srrs sc->sc_sysdev->bas.bst = rmi_bus_space; 73198956Srrs sc->sc_sysdev->bas.bsh = MIPS_PHYS_TO_KSEG1(XLR_UART0ADDR); 74198956Srrs sc->sc_bas.bst = rmi_bus_space; 75198956Srrs sc->sc_bas.bsh = MIPS_PHYS_TO_KSEG1(XLR_UART0ADDR); 76198625Srrs /* regshft = 2, rclk = 66000000, rid = 0, chan = 0 */ 77340145Smmacy return (uart_bus_probe(dev, 2, 0, 66000000, 0, 0, 0)); 78198160Srrs} 79198160Srrs 80198160SrrsDRIVER_MODULE(uart, iodi, uart_iodi_driver, uart_devclass, 0, 0); 81