1220297Sadrian/*- 2220297Sadrian * Copyright (c) 2007 Bruce M. Simpson. 3220297Sadrian * All rights reserved. 4220297Sadrian * 5220297Sadrian * Redistribution and use in source and binary forms, with or without 6220297Sadrian * modification, are permitted provided that the following conditions 7220297Sadrian * are met: 8220297Sadrian * 1. Redistributions of source code must retain the above copyright 9220297Sadrian * notice, this list of conditions and the following disclaimer. 10220297Sadrian * 2. Redistributions in binary form must reproduce the above copyright 11220297Sadrian * notice, this list of conditions and the following disclaimer in the 12220297Sadrian * documentation and/or other materials provided with the distribution. 13220297Sadrian * 14220297Sadrian * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15220297Sadrian * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16220297Sadrian * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17220297Sadrian * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18220297Sadrian * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19220297Sadrian * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20220297Sadrian * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21220297Sadrian * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22220297Sadrian * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23220297Sadrian * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24220297Sadrian * $Id$ 25220297Sadrian */ 26220297Sadrian/* 27220297Sadrian * Skeleton of this file was based on respective code for ARM 28220297Sadrian * code written by Olivier Houchard. 29220297Sadrian */ 30220297Sadrian 31220297Sadrian/* 32220297Sadrian * XXXMIPS: This file is hacked from arm/... . XXXMIPS here means this file is 33220297Sadrian * experimental and was written for MIPS32 port. 34220297Sadrian */ 35220297Sadrian#include "opt_uart.h" 36220297Sadrian 37220297Sadrian#include <sys/cdefs.h> 38220297Sadrian__FBSDID("$FreeBSD: stable/11/sys/mips/rt305x/uart_bus_rt305x.c 340145 2018-11-04 23:28:56Z mmacy $"); 39220297Sadrian 40220297Sadrian#include <sys/param.h> 41220297Sadrian#include <sys/systm.h> 42220297Sadrian#include <sys/bus.h> 43220297Sadrian#include <sys/conf.h> 44220297Sadrian#include <sys/kernel.h> 45220297Sadrian#include <sys/module.h> 46220297Sadrian#include <machine/bus.h> 47220297Sadrian#include <sys/rman.h> 48220297Sadrian#include <machine/resource.h> 49220297Sadrian 50220297Sadrian#include <dev/pci/pcivar.h> 51220297Sadrian 52220297Sadrian#include <dev/uart/uart.h> 53220297Sadrian#include <dev/uart/uart_bus.h> 54220297Sadrian#include <dev/uart/uart_cpu.h> 55220297Sadrian 56220297Sadrian#include <mips/rt305x/rt305xreg.h> 57220297Sadrian 58220297Sadrian#include "uart_if.h" 59220297Sadrian 60220297Sadrianstatic int uart_rt305x_probe(device_t dev); 61220297Sadrian 62220297Sadrianextern struct uart_class uart_rt305x_uart_class; 63220297Sadrian 64220297Sadrianstatic device_method_t uart_rt305x_methods[] = { 65220297Sadrian /* Device interface */ 66220297Sadrian DEVMETHOD(device_probe, uart_rt305x_probe), 67220297Sadrian DEVMETHOD(device_attach, uart_bus_attach), 68220297Sadrian DEVMETHOD(device_detach, uart_bus_detach), 69220297Sadrian { 0, 0 } 70220297Sadrian}; 71220297Sadrian 72220297Sadrianstatic driver_t uart_rt305x_driver = { 73220297Sadrian uart_driver_name, 74220297Sadrian uart_rt305x_methods, 75220297Sadrian sizeof(struct uart_softc), 76220297Sadrian}; 77220297Sadrian 78220297Sadrianstatic int 79220297Sadrianuart_rt305x_probe(device_t dev) 80220297Sadrian{ 81220297Sadrian struct uart_softc *sc; 82220297Sadrian 83220297Sadrian sc = device_get_softc(dev); 84220297Sadrian sc->sc_class = &uart_rt305x_uart_class; 85220297Sadrian sc->sc_bas.regshft = 2; 86220297Sadrian sc->sc_bas.bst = mips_bus_space_generic; 87220297Sadrian sc->sc_bas.bsh = 88220297Sadrian MIPS_PHYS_TO_KSEG1(device_get_unit(dev)?UARTLITE_BASE:UART_BASE); 89220297Sadrian 90340145Smmacy return (uart_bus_probe(dev, 2, 0, SYSTEM_CLOCK, 0, 0, 0)); 91220297Sadrian} 92220297Sadrian 93220297SadrianDRIVER_MODULE(uart, obio, uart_rt305x_driver, uart_devclass, 0, 0); 94220297Sadrian 95