No empty .Rs/.Re
[netbsd-mini2440.git] / sys / arch / evbppc / pmppc / mainbus.c
blobe39444cee5ab413ad6d24af7e56710ac023f7322
1 /* $NetBSD: mainbus.c,v 1.2 2007/10/17 19:54:18 garbled Exp $ */
3 /*
4 * Copyright (c) 2002 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Lennart Augustsson (lennart@augustsson.net) at Sandburst Corp.
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: mainbus.c,v 1.2 2007/10/17 19:54:18 garbled Exp $");
35 #include <sys/param.h>
36 #include <sys/device.h>
37 #include <sys/systm.h>
39 #include <machine/bus.h>
40 #include <machine/pmppc.h>
41 #include <arch/evbppc/pmppc/dev/mainbus.h>
43 #include <dev/ic/cpc700reg.h>
45 #include "locators.h"
46 #include "mainbus.h"
48 #if NCPU == 0
49 #error A cpu device is now required
50 #endif
52 int mainbus_match(struct device *, struct cfdata *, void *);
53 void mainbus_attach(struct device *, struct device *, void *);
55 CFATTACH_DECL(mainbus, sizeof(struct device),
56 mainbus_match, mainbus_attach, NULL, NULL);
58 static int mainbus_print(void *, const char *);
61 * Probe for the mainbus; always succeeds.
63 int
64 mainbus_match(struct device *parent, struct cfdata *match, void *aux)
67 return 1;
70 static int
71 mainbus_submatch(struct device *parent, struct cfdata *cf,
72 const int *ldesc, void *aux)
74 struct mainbus_attach_args *maa = aux;
76 if (cf->cf_loc[MAINBUSCF_ADDR] != maa->mb_addr)
77 return (0);
79 return (config_match(parent, cf, aux));
82 static int
83 mainbus_print(void *aux, const char *pnp)
85 struct mainbus_attach_args *mba = aux;
87 if (pnp)
88 aprint_normal("%s at %s", mba->mb_name, pnp);
89 if (mba->mb_addr != MAINBUSCF_ADDR_DEFAULT)
90 aprint_normal(" addr 0x%08lx", mba->mb_addr);
91 if (mba->mb_irq != MAINBUSCF_IRQ_DEFAULT)
92 aprint_normal(" irq %d", mba->mb_irq);
93 return (UNCONF);
97 * Attach the mainbus.
99 void
100 mainbus_attach(struct device *parent, struct device *self, void *aux)
102 struct mainbus_attach_args maa;
104 printf(": Artesyn PM/PPC\n");
105 printf("%s: %sPCI bus Monarch\n", self->dv_xname,
106 a_config.a_is_monarch ? "" : "not");
107 printf("%s: boot from %s, %sECC, %s L2 cache\n",
108 self->dv_xname,
109 a_config.a_boot_device == A_BOOT_ROM ? "ROM" : "flash",
110 a_config.a_has_ecc ? "" : "no ",
111 a_config.a_l2_cache == A_CACHE_PARITY ? "parity" :
112 a_config.a_l2_cache == A_CACHE_NO_PARITY ? "no-parity" : "no");
114 maa.mb_bt = &pmppc_mem_tag;
116 maa.mb_name = "cpu";
117 maa.mb_addr = MAINBUSCF_ADDR_DEFAULT;
118 maa.mb_irq = MAINBUSCF_IRQ_DEFAULT;
119 config_found(self, &maa, mainbus_print);
121 if (a_config.a_has_rtc) {
122 maa.mb_name = "rtc";
123 maa.mb_addr = PMPPC_RTC;
124 maa.mb_irq = PMPPC_I_RTC_INT;
125 config_found_sm_loc(self, "mainbus", NULL, &maa, mainbus_print,
126 mainbus_submatch);
129 if (a_config.a_has_eth) {
130 maa.mb_name = "cs";
131 maa.mb_addr = PMPPC_CS_IO_BASE;
132 maa.mb_irq = PMPPC_I_ETH_INT;
133 config_found_sm_loc(self, "mainbus", NULL, &maa, mainbus_print,
134 mainbus_submatch);
135 maa.mb_bt = &pmppc_mem_tag;
137 if (a_config.a_flash_width != 0) {
138 maa.mb_name = "flash";
139 maa.mb_addr = PMPPC_FLASH_BASE;
140 maa.mb_irq = MAINBUSCF_IRQ_DEFAULT;
141 maa.u.mb_flash.size = a_config.a_flash_size;
142 maa.u.mb_flash.width = a_config.a_flash_width;
143 config_found_sm_loc(self, "mainbus", NULL, &maa, mainbus_print,
144 mainbus_submatch);
147 maa.mb_name = "cpc";
148 maa.mb_addr = MAINBUSCF_ADDR_DEFAULT;
149 maa.mb_irq = MAINBUSCF_IRQ_DEFAULT;
150 config_found(self, &maa, mainbus_print);
153 static int cpu_match(struct device *, struct cfdata *, void *);
154 static void cpu_attach(struct device *, struct device *, void *);
156 CFATTACH_DECL(cpu, sizeof(struct device),
157 cpu_match, cpu_attach, NULL, NULL);
159 extern struct cfdriver cpu_cd;
162 cpu_match(struct device *parent, struct cfdata *cf, void *aux)
164 struct mainbus_attach_args *maa = aux;
166 if (strcmp(maa->mb_name, cpu_cd.cd_name) != 0)
167 return 0;
169 if (cpu_info[0].ci_dev != NULL)
170 return 0;
172 return 1;
175 void
176 cpu_attach(struct device *parent, struct device *self, void *aux)
178 (void) cpu_attach_common(self, 0);