uart_bus_sbusart.c revision 182901
128263Spst/*- 228263Spst * Copyright (c) 2007 Bruce M. Simpson. 350472Speter * All rights reserved. 428263Spst * 561981Sbrian * Redistribution and use in source and binary forms, with or without 661981Sbrian * modification, are permitted provided that the following conditions 728263Spst * are met: 861981Sbrian * 1. Redistributions of source code must retain the above copyright 961981Sbrian * notice, this list of conditions and the following disclaimer. 1061981Sbrian * 2. Redistributions in binary form must reproduce the above copyright 1161981Sbrian * notice, this list of conditions and the following disclaimer in the 1261981Sbrian * documentation and/or other materials provided with the distribution. 1361981Sbrian * 1428263Spst * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1528263Spst * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1661981Sbrian * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1761981Sbrian * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1865843Sbrian * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1961981Sbrian * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2065843Sbrian * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2165843Sbrian * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2265843Sbrian * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2365843Sbrian * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2465843Sbrian * $Id$ 2565843Sbrian */ 2665843Sbrian/* 2765843Sbrian * Skeleton of this file was based on respective code for ARM 2865843Sbrian * code written by Olivier Houchard. 2961981Sbrian */ 3061981Sbrian 3161981Sbrian/* 3261981Sbrian * XXXMIPS: This file is hacked from arm/... . XXXMIPS here means this file is 3361981Sbrian * experimental and was written for MIPS32 port. 3461981Sbrian */ 3561981Sbrian#include "opt_uart.h" 3661981Sbrian 3761981Sbrian#include <sys/cdefs.h> 3861981Sbrian__FBSDID("$FreeBSD: head/sys/mips/sentry5/uart_bus_sbusart.c 182901 2008-09-10 03:49:08Z gonzo $"); 3965843Sbrian 4065843Sbrian#include <sys/param.h> 4165843Sbrian#include <sys/systm.h> 4265843Sbrian#include <sys/bus.h> 4365843Sbrian#include <sys/conf.h> 4465843Sbrian#include <sys/kernel.h> 4565843Sbrian#include <sys/module.h> 4665843Sbrian#include <machine/bus.h> 4765843Sbrian#include <sys/rman.h> 4861981Sbrian#include <machine/resource.h> 4965843Sbrian 5065843Sbrian#include <dev/pci/pcivar.h> 5161981Sbrian 5265843Sbrian#include <dev/uart/uart.h> 5365843Sbrian#include <dev/uart/uart_bus.h> 54#include <dev/uart/uart_cpu.h> 55 56#include <mips/sentry5/sentry5reg.h> 57 58#include "uart_if.h" 59 60static int uart_malta_probe(device_t dev); 61 62extern struct uart_class malta_uart_class; 63 64static device_method_t uart_malta_methods[] = { 65 /* Device interface */ 66 DEVMETHOD(device_probe, uart_malta_probe), 67 DEVMETHOD(device_attach, uart_bus_attach), 68 DEVMETHOD(device_detach, uart_bus_detach), 69 { 0, 0 } 70}; 71 72static driver_t uart_malta_driver = { 73 uart_driver_name, 74 uart_malta_methods, 75 sizeof(struct uart_softc), 76}; 77 78extern SLIST_HEAD(uart_devinfo_list, uart_devinfo) uart_sysdevs; 79static int 80uart_malta_probe(device_t dev) 81{ 82 struct uart_softc *sc; 83 84 sc = device_get_softc(dev); 85 sc->sc_sysdev = SLIST_FIRST(&uart_sysdevs); 86 sc->sc_class = &uart_ns8250_class; 87 bcopy(&sc->sc_sysdev->bas, &sc->sc_bas, sizeof(sc->sc_bas)); 88 sc->sc_sysdev->bas.bst = 0; 89 sc->sc_sysdev->bas.bsh = MIPS_PHYS_TO_KSEG1(SENTRY5_UART1ADR); 90 sc->sc_bas.bst = 0; 91 sc->sc_bas.bsh = MIPS_PHYS_TO_KSEG1(SENTRY5_UART1ADR); 92 return(uart_bus_probe(dev, 0, 0, 0, 0)); 93} 94 95DRIVER_MODULE(uart, obio, uart_malta_driver, uart_devclass, 0, 0); 96