No empty .Rs/.Re
[netbsd-mini2440.git] / sys / arch / evbmips / gdium / bonito_mainbus.c
blob52e21f1d3d450867d20bbfba727d06f4392fd4e3
1 /* $NetBSD: bonito_mainbus.c,v 1.11 2008/04/28 20:23:10 martin Exp $ */
3 /*-
4 * Copyright (c) 2001 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 #include <sys/cdefs.h>
33 __KERNEL_RCSID(0, "$NetBSD: bonito_mainbus.c,v 1.11 2008/04/28 20:23:10 martin Exp $");
35 #include <sys/param.h>
36 #include <sys/systm.h>
37 #include <sys/conf.h>
38 #include <sys/reboot.h>
39 #include <sys/device.h>
41 #include <machine/bus.h>
43 #include <mips/bonito/bonitoreg.h>
45 #include <evbmips/gdium/gdiumvar.h>
47 static int bonito_mainbus_match(device_t, cfdata_t, void *);
48 static void bonito_mainbus_attach(device_t, device_t, void *);
50 CFATTACH_DECL_NEW(bonito_mainbus, 0,
51 bonito_mainbus_match, bonito_mainbus_attach, NULL, NULL);
53 extern struct cfdriver bonito_cd;
55 int
56 bonito_mainbus_match(device_t parent, cfdata_t cf, void *aux)
58 struct mainbus_attach_args * const maa = aux;
60 if (strcmp(maa->maa_name, bonito_cd.cd_name) == 0)
61 return (1);
63 return (0);
66 void
67 bonito_mainbus_attach(device_t parent, device_t self, void *aux)
69 struct pcibus_attach_args pba;
70 struct gdium_config * const gc = &gdium_configuration;
71 pcireg_t rev;
73 self->dv_private = &gc->gc_bonito;
76 * There is only one PCI controller on a Loongson chip.
79 rev = PCI_REVISION(REGVAL(BONITO_PCICLASS));
81 printf(": BONITO Memory and PCI controller, %s rev. %d.%d\n",
82 BONITO_REV_FPGA(rev) ? "FPGA" : "ASIC",
83 BONITO_REV_MAJOR(rev), BONITO_REV_MINOR(rev));
85 pba.pba_flags = PCI_FLAGS_IO_ENABLED | PCI_FLAGS_MEM_ENABLED;
86 pba.pba_bus = 0;
87 pba.pba_bridgetag = NULL;
89 pba.pba_iot = &gc->gc_iot;
90 pba.pba_memt = &gc->gc_memt;
91 pba.pba_dmat = &gc->gc_pci_dmat;
92 pba.pba_dmat64 = NULL;
93 pba.pba_pc = &gc->gc_pc;
95 (void) config_found_ia(self, "pcibus", &pba, pcibusprint);