1*5f819ca3Schs /* $NetBSD: autoconf.c,v 1.22 2012/10/27 17:17:24 chs Exp $ */
216b9c606Sthorpej
316b9c606Sthorpej /*-
416b9c606Sthorpej * Copyright (c) 2001 The NetBSD Foundation, Inc.
516b9c606Sthorpej * All rights reserved.
616b9c606Sthorpej *
716b9c606Sthorpej * This code is derived from software contributed to The NetBSD Foundation
816b9c606Sthorpej * by Jason R. Thorpe.
916b9c606Sthorpej *
1016b9c606Sthorpej * Redistribution and use in source and binary forms, with or without
1116b9c606Sthorpej * modification, are permitted provided that the following conditions
1216b9c606Sthorpej * are met:
1316b9c606Sthorpej * 1. Redistributions of source code must retain the above copyright
1416b9c606Sthorpej * notice, this list of conditions and the following disclaimer.
1516b9c606Sthorpej * 2. Redistributions in binary form must reproduce the above copyright
1616b9c606Sthorpej * notice, this list of conditions and the following disclaimer in the
1716b9c606Sthorpej * documentation and/or other materials provided with the distribution.
1816b9c606Sthorpej *
1916b9c606Sthorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
2016b9c606Sthorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2116b9c606Sthorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2216b9c606Sthorpej * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
2316b9c606Sthorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2416b9c606Sthorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2516b9c606Sthorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2616b9c606Sthorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2716b9c606Sthorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2816b9c606Sthorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2916b9c606Sthorpej * POSSIBILITY OF SUCH DAMAGE.
3016b9c606Sthorpej */
3116b9c606Sthorpej
326fdfc66cSlukem #include <sys/cdefs.h>
33*5f819ca3Schs __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.22 2012/10/27 17:17:24 chs Exp $");
346fdfc66cSlukem
3516b9c606Sthorpej #include "opt_algor_p4032.h"
3616b9c606Sthorpej #include "opt_algor_p5064.h"
3716b9c606Sthorpej #include "opt_algor_p6032.h"
3816b9c606Sthorpej
3916b9c606Sthorpej #include <sys/param.h>
40febf67b8Smatt #include <sys/bus.h>
4116b9c606Sthorpej #include <sys/conf.h>
4216b9c606Sthorpej #include <sys/device.h>
43febf67b8Smatt #include <sys/intr.h>
44febf67b8Smatt #include <sys/reboot.h>
45febf67b8Smatt #include <sys/systm.h>
4616b9c606Sthorpej
4708fcaa05Sthorpej #include <dev/pci/pcivar.h>
4808fcaa05Sthorpej
490ed7df81Sthorpej #include <net/if.h>
500ed7df81Sthorpej #include <net/if_ether.h>
510ed7df81Sthorpej
52febf67b8Smatt #include <algor/autoconf.h>
5316b9c606Sthorpej
54cb468f2eSthorpej #ifdef ALGOR_P4032
55cb468f2eSthorpej #include <algor/algor/algor_p4032var.h>
56cb468f2eSthorpej #endif
57cb468f2eSthorpej
5816b9c606Sthorpej void
cpu_configure(void)5916b9c606Sthorpej cpu_configure(void)
6016b9c606Sthorpej {
6116b9c606Sthorpej
62ce66bf08Sthorpej intr_init();
6316b9c606Sthorpej
6416b9c606Sthorpej (void) splhigh();
650b11d718She if (config_rootfound("mainbus", NULL) == 0)
6616b9c606Sthorpej panic("no mainbus found");
6744e83481Stsutsui
6844e83481Stsutsui /*
6944e83481Stsutsui * Hardware interrupts will be enabled in
7044e83481Stsutsui * sys/arch/mips/mips/mips3_clockintr.c:mips3_initclocks()
7144e83481Stsutsui * to avoid hardclock(9) by CPU INT5 before softclockintr is
7244e83481Stsutsui * initialized in initclocks().
7344e83481Stsutsui */
7416b9c606Sthorpej }
7516b9c606Sthorpej
7616b9c606Sthorpej void
cpu_rootconf(void)7716b9c606Sthorpej cpu_rootconf(void)
7816b9c606Sthorpej {
7916b9c606Sthorpej
8040637d6dSmlelstv rootconf();
8116b9c606Sthorpej }
8216b9c606Sthorpej
83cb468f2eSthorpej #if defined(ALGOR_P4032)
84cb468f2eSthorpej #define BUILTIN_ETHERNET_P(pa) \
85cb468f2eSthorpej ((pa)->pa_bus == 0 && (pa)->pa_device == 5 && (pa)->pa_function == 0)
86cb468f2eSthorpej #elif defined(ALGOR_P5064)
87cb468f2eSthorpej #define BUILTIN_ETHERNET_P(pa) \
88cb468f2eSthorpej ((pa)->pa_bus == 0 && (pa)->pa_device == 0 && (pa)->pa_function == 0)
89cb468f2eSthorpej #elif defined(ALGOR_P6032)
90cb468f2eSthorpej #define BUILTIN_ETHERNET_P(pa) \
91cb468f2eSthorpej ((pa)->pa_bus == 0 && (pa)->pa_device == 16 && (pa)->pa_function == 0)
92cb468f2eSthorpej #else
93cb468f2eSthorpej #define BUILTIN_ETHERNET_P(pa) 0
94cb468f2eSthorpej #endif
95cb468f2eSthorpej
9616b9c606Sthorpej void
device_register(device_t dev,void * aux)97*5f819ca3Schs device_register(device_t dev, void *aux)
9816b9c606Sthorpej {
99*5f819ca3Schs device_t pdev;
10016b9c606Sthorpej
10116b9c606Sthorpej /*
10216b9c606Sthorpej * We don't ever know the boot device. But that's because the
10316b9c606Sthorpej * firmware only loads from the network or the parallel port.
10416b9c606Sthorpej */
105cb468f2eSthorpej
106cb468f2eSthorpej /*
107cb468f2eSthorpej * Fetch the MAC address for the built-in Ethernet (we grab it
108cb468f2eSthorpej * from PMON earlier in the boot process).
109cb468f2eSthorpej */
110ef9d89adSthorpej if ((pdev = device_parent(dev)) != NULL && device_is_a(pdev, "pci")) {
111cb468f2eSthorpej struct pci_attach_args *pa = aux;
112cb468f2eSthorpej
113cb468f2eSthorpej if (BUILTIN_ETHERNET_P(pa)) {
114fb44a857Sthorpej prop_data_t pd = prop_data_create_data_nocopy(
115fb44a857Sthorpej algor_ethaddr, ETHER_ADDR_LEN);
116fb44a857Sthorpej KASSERT(pd != NULL);
117fb44a857Sthorpej if (prop_dictionary_set(device_properties(dev),
118f9e1815aSmartin "mac-address", pd) == false) {
119cb468f2eSthorpej printf("WARNING: unable to set mac-addr "
120*5f819ca3Schs "property for %s\n", device_xname(dev));
121cb468f2eSthorpej }
122fb44a857Sthorpej prop_object_release(pd);
123cb468f2eSthorpej #if defined(ALGOR_P4032)
124cb468f2eSthorpej /*
125cb468f2eSthorpej * XXX This is gross, disgusting, and otherwise vile,
126cb468f2eSthorpej * XXX but V962 rev. < B2 have broken DMA FIFOs. Give
127cb468f2eSthorpej * XXX the on-board Ethernet a different DMA window
128cb468f2eSthorpej * XXX that has pre-fetching disabled so that Ethernet
129cb468f2eSthorpej * XXX performance doesn't completely suck.
130cb468f2eSthorpej */
131cb468f2eSthorpej pa->pa_dmat = &p4032_configuration.ac_pci_pf_dmat;
132cb468f2eSthorpej pa->pa_dmat64 = NULL;
133cb468f2eSthorpej #endif /* ALGOR_P4032 */
134cb468f2eSthorpej }
135cb468f2eSthorpej }
13616b9c606Sthorpej }
137