]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/mips/broadcom/siba_nexus.c
Fix misleading log messages upon successful sshd login.
[FreeBSD/FreeBSD.git] / sys / mips / broadcom / siba_nexus.c
1 /*-
2  * Copyright (c) 2015-2016 Landon Fuller <landon@freebsd.org>
3  * Copyright (c) 2007 Bruce M. Simpson.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
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 the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25  * SUCH DAMAGE.
26  */
27
28 #include <sys/cdefs.h>
29 __FBSDID("$FreeBSD$");
30
31 #include <sys/param.h>
32 #include <sys/kernel.h>
33 #include <sys/bus.h>
34 #include <sys/module.h>
35
36 #include <machine/bus.h>
37 #include <sys/rman.h>
38 #include <machine/resource.h>
39
40 #include <dev/bhnd/bhnd_ids.h>
41
42 #include <dev/bhnd/siba/sibareg.h>
43 #include <dev/bhnd/siba/sibavar.h>
44
45 #include "bcm_machdep.h"
46 #include "bcm_mipsvar.h"
47
48 #include "bhnd_nexusvar.h"
49
50 /*
51  * Supports siba(4) attachment to a MIPS nexus bus.
52  * 
53  * Derived from Bruce M. Simpson' original siba(4) driver.
54  */
55
56 _Static_assert(SIBA_MAX_INTR == BCM_MIPS_NINTR, "SIBA incompatible with "
57     "generic NINTR");
58
59 static int
60 siba_nexus_probe(device_t dev)
61 {
62         int error;
63
64         if (bcm_get_platform()->cid.chip_type != BHND_CHIPTYPE_SIBA)
65                 return (ENXIO);
66
67         if ((error = siba_probe(dev)) > 0)
68                 return (error);
69
70         /* Set device description */
71         bhnd_set_default_bus_desc(dev, &bcm_get_platform()->cid);
72
73         return (BUS_PROBE_SPECIFIC);
74 }
75
76 static int
77 siba_nexus_attach(device_t dev)
78 {
79         int error;
80
81         /* Perform initial attach and enumerate our children. */
82         if ((error = siba_attach(dev)))
83                 return (error);
84
85         /* Delegate remainder to standard bhnd method implementation */
86         if ((error = bhnd_generic_attach(dev)))
87                 goto failed;
88
89         return (0);
90
91 failed:
92         siba_detach(dev);
93         return (error);
94 }
95
96 static device_method_t siba_nexus_methods[] = {
97         /* Device interface */
98         DEVMETHOD(device_probe,                 siba_nexus_probe),
99         DEVMETHOD(device_attach,                siba_nexus_attach),
100
101         DEVMETHOD_END
102 };
103
104 DEFINE_CLASS_2(bhnd, siba_nexus_driver, siba_nexus_methods,
105     sizeof(struct siba_softc), bhnd_nexus_driver, siba_driver);
106
107 EARLY_DRIVER_MODULE(siba_nexus, nexus, siba_nexus_driver, bhnd_devclass, 0, 0,
108     BUS_PASS_BUS + BUS_PASS_ORDER_MIDDLE);