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