1225394Sjchandra/*- 2233549Sjchandra * Copyright (c) 2003-2012 Broadcom Corporation 3233549Sjchandra * All Rights Reserved 4225394Sjchandra * 5225394Sjchandra * Redistribution and use in source and binary forms, with or without 6225394Sjchandra * modification, are permitted provided that the following conditions 7225394Sjchandra * are met: 8233549Sjchandra * 9225394Sjchandra * 1. Redistributions of source code must retain the above copyright 10225394Sjchandra * notice, this list of conditions and the following disclaimer. 11225394Sjchandra * 2. Redistributions in binary form must reproduce the above copyright 12233549Sjchandra * notice, this list of conditions and the following disclaimer in 13233549Sjchandra * the documentation and/or other materials provided with the 14233549Sjchandra * distribution. 15233549Sjchandra * 16233549Sjchandra * THIS SOFTWARE IS PROVIDED BY BROADCOM ``AS IS'' AND ANY EXPRESS OR 17233549Sjchandra * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18233549Sjchandra * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19233549Sjchandra * ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM OR CONTRIBUTORS BE LIABLE 20233549Sjchandra * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21233549Sjchandra * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22233549Sjchandra * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23233549Sjchandra * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24233549Sjchandra * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25233549Sjchandra * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26233549Sjchandra * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27225394Sjchandra */ 28225394Sjchandra 29225394Sjchandra#include <sys/cdefs.h> 30225394Sjchandra__FBSDID("$FreeBSD: releng/10.2/sys/mips/nlm/dev/uart_pci_xlp.c 233549 2012-03-27 14:48:40Z jchandra $"); 31225394Sjchandra 32225394Sjchandra#include <sys/param.h> 33225394Sjchandra#include <sys/systm.h> 34225394Sjchandra#include <sys/bus.h> 35225394Sjchandra#include <sys/conf.h> 36225394Sjchandra#include <sys/kernel.h> 37225394Sjchandra#include <sys/module.h> 38225394Sjchandra#include <machine/bus.h> 39225394Sjchandra#include <sys/rman.h> 40225394Sjchandra#include <machine/resource.h> 41225394Sjchandra 42225394Sjchandra#include <dev/pci/pcivar.h> 43225394Sjchandra 44225394Sjchandra#include <mips/nlm/hal/haldefs.h> 45225394Sjchandra#include <mips/nlm/hal/iomap.h> 46225394Sjchandra#include <mips/nlm/hal/uart.h> 47225394Sjchandra 48225394Sjchandra#include <dev/uart/uart.h> 49225394Sjchandra#include <dev/uart/uart_bus.h> 50225394Sjchandra 51225394Sjchandrastatic int uart_soc_probe(device_t dev); 52225394Sjchandra 53225394Sjchandrastatic device_method_t uart_soc_methods[] = { 54225394Sjchandra /* Device interface */ 55225394Sjchandra DEVMETHOD(device_probe, uart_soc_probe), 56225394Sjchandra DEVMETHOD(device_attach, uart_bus_attach), 57225394Sjchandra DEVMETHOD(device_detach, uart_bus_detach), 58233549Sjchandra 59233549Sjchandra DEVMETHOD_END 60225394Sjchandra}; 61225394Sjchandra 62225394Sjchandrastatic driver_t uart_soc_driver = { 63225394Sjchandra uart_driver_name, 64225394Sjchandra uart_soc_methods, 65225394Sjchandra sizeof(struct uart_softc), 66225394Sjchandra}; 67225394Sjchandra 68225394Sjchandrastatic int 69225394Sjchandrauart_soc_probe(device_t dev) 70225394Sjchandra{ 71225394Sjchandra struct uart_softc *sc; 72225394Sjchandra 73225394Sjchandra if (pci_get_vendor(dev) != PCI_VENDOR_NETLOGIC || 74225394Sjchandra pci_get_device(dev) != PCI_DEVICE_ID_NLM_UART) 75225394Sjchandra return (ENXIO); 76225394Sjchandra 77225394Sjchandra sc = device_get_softc(dev); 78225394Sjchandra sc->sc_class = &uart_ns8250_class; 79225394Sjchandra device_set_desc(dev, "Netlogic SoC UART"); 80233549Sjchandra return (uart_bus_probe(dev, 2, XLP_IO_CLK, 0, 0)); 81225394Sjchandra} 82225394Sjchandra 83225394SjchandraDRIVER_MODULE(uart_soc, pci, uart_soc_driver, uart_devclass, 0, 0); 84