uart_pci_xlp.c revision 225394
1/*-
2 * Copyright (c) 2011 Netlogic Microsystems Inc.
3 *
4 * (based on dev/uart/uart_bus_pci.c)
5 * Copyright (c) 2006 Marcel Moolenaar
6 * Copyright (c) 2001 M. Warner Losh
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 *    notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 *    notice, this list of conditions and the following disclaimer in the
16 *    documentation and/or other materials provided with the distribution.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30#include <sys/cdefs.h>
31__FBSDID("$FreeBSD: head/sys/mips/nlm/uart_pci_xlp.c 225394 2011-09-05 10:45:29Z jchandra $");
32
33#include <sys/param.h>
34#include <sys/systm.h>
35#include <sys/bus.h>
36#include <sys/conf.h>
37#include <sys/kernel.h>
38#include <sys/module.h>
39#include <machine/bus.h>
40#include <sys/rman.h>
41#include <machine/resource.h>
42
43#include <dev/pci/pcivar.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
52static int uart_soc_probe(device_t dev);
53
54static device_method_t uart_soc_methods[] = {
55	/* Device interface */
56	DEVMETHOD(device_probe,		uart_soc_probe),
57	DEVMETHOD(device_attach,	uart_bus_attach),
58	DEVMETHOD(device_detach,	uart_bus_detach),
59	{ 0, 0 }
60};
61
62static driver_t uart_soc_driver = {
63	uart_driver_name,
64	uart_soc_methods,
65	sizeof(struct uart_softc),
66};
67
68static int
69uart_soc_probe(device_t dev)
70{
71	struct uart_softc *sc;
72	uint64_t ubase;
73
74	if (pci_get_vendor(dev) != PCI_VENDOR_NETLOGIC ||
75	    pci_get_device(dev) != PCI_DEVICE_ID_NLM_UART)
76		return (ENXIO);
77
78	ubase = nlm_get_uart_regbase(0, 0);
79	sc = device_get_softc(dev);
80	sc->sc_class = &uart_ns8250_class;
81	device_set_desc(dev, "Netlogic SoC UART");
82	return (uart_bus_probe(dev, 2, 133000000, 0, 0));
83}
84
85DRIVER_MODULE(uart_soc, pci, uart_soc_driver, uart_devclass, 0, 0);
86