1 /* $NetBSD: autoconf.c,v 1.16 2007/02/22 04:49:02 thorpej Exp $ */
4 * Copyright (c) 2001 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
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: autoconf.c,v 1.16 2007/02/22 04:49:02 thorpej Exp $");
35 #include "opt_algor_p4032.h"
36 #include "opt_algor_p5064.h"
37 #include "opt_algor_p6032.h"
39 #include <sys/param.h>
40 #include <sys/systm.h>
42 #include <sys/reboot.h>
43 #include <sys/device.h>
45 #include <dev/pci/pcivar.h>
48 #include <net/if_ether.h>
50 #include <machine/bus.h>
51 #include <machine/autoconf.h>
52 #include <machine/intr.h>
55 #include <algor/algor/algor_p4032var.h>
65 if (config_rootfound("mainbus", NULL
) == 0)
66 panic("no mainbus found");
69 * Hardware interrupts will be enabled in
70 * sys/arch/mips/mips/mips3_clockintr.c:mips3_initclocks()
71 * to avoid hardclock(9) by CPU INT5 before softclockintr is
72 * initialized in initclocks().
80 setroot(booted_device
, booted_partition
);
83 #if defined(ALGOR_P4032)
84 #define BUILTIN_ETHERNET_P(pa) \
85 ((pa)->pa_bus == 0 && (pa)->pa_device == 5 && (pa)->pa_function == 0)
86 #elif defined(ALGOR_P5064)
87 #define BUILTIN_ETHERNET_P(pa) \
88 ((pa)->pa_bus == 0 && (pa)->pa_device == 0 && (pa)->pa_function == 0)
89 #elif defined(ALGOR_P6032)
90 #define BUILTIN_ETHERNET_P(pa) \
91 ((pa)->pa_bus == 0 && (pa)->pa_device == 16 && (pa)->pa_function == 0)
93 #define BUILTIN_ETHERNET_P(pa) 0
97 device_register(struct device
*dev
, void *aux
)
102 * We don't ever know the boot device. But that's because the
103 * firmware only loads from the network or the parallel port.
107 * Fetch the MAC address for the built-in Ethernet (we grab it
108 * from PMON earlier in the boot process).
110 if ((pdev
= device_parent(dev
)) != NULL
&& device_is_a(pdev
, "pci")) {
111 struct pci_attach_args
*pa
= aux
;
113 if (BUILTIN_ETHERNET_P(pa
)) {
114 prop_data_t pd
= prop_data_create_data_nocopy(
115 algor_ethaddr
, ETHER_ADDR_LEN
);
117 if (prop_dictionary_set(device_properties(dev
),
118 "mac-addr", pd
) == false) {
119 printf("WARNING: unable to set mac-addr "
120 "property for %s\n", dev
->dv_xname
);
122 prop_object_release(pd
);
123 #if defined(ALGOR_P4032)
125 * XXX This is gross, disgusting, and otherwise vile,
126 * XXX but V962 rev. < B2 have broken DMA FIFOs. Give
127 * XXX the on-board Ethernet a different DMA window
128 * XXX that has pre-fetching disabled so that Ethernet
129 * XXX performance doesn't completely suck.
131 pa
->pa_dmat
= &p4032_configuration
.ac_pci_pf_dmat
;
132 pa
->pa_dmat64
= NULL
;
133 #endif /* ALGOR_P4032 */