1 /* $NetBSD: ebus_emips.c,v 1.3 2011/06/12 04:00:33 tsutsui Exp $ */
2
3 /*-
4 * Copyright (c) 2010 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code was written by Alessandro Forin and Neil Pittman
8 * at Microsoft Research and contributed to The NetBSD Foundation
9 * by Microsoft Corporation.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
34 __KERNEL_RCSID(0, "$NetBSD: ebus_emips.c,v 1.3 2011/06/12 04:00:33 tsutsui Exp $");
35
36 #include "opt_xilinx_ml40x.h"
37 #include "opt_xs_bee3.h"
38
39 #include <sys/param.h>
40 #include <sys/systm.h>
41 #include <sys/device.h>
42
43 #include <emips/ebus/ebusvar.h>
44
45 #include <machine/autoconf.h>
46 #include <machine/sysconf.h>
47
48 #include <machine/emipsreg.h>
49 #include <emips/emips/emipstype.h>
50
51 static int ebus_emips_match(device_t, cfdata_t, void *);
52 static void ebus_emips_attach(device_t, device_t, void *);
53
54 CFATTACH_DECL_NEW(ebus_emips, 0,
55 ebus_emips_match, ebus_emips_attach, NULL, NULL);
56
57 #if defined(XILINX_ML40x) || defined(XS_BEE3)
58 struct ebus_attach_args ebus_emips_devs[] = {
59 /* NAME INTERRUPT PHYS VIRT PHYS_SIZE */
60 { "eclock", AIC_TIMER, TIMER_DEFAULT_ADDRESS, NULL, sizeof(struct _Tc) },
61 { "dz", AIC_USART, USART_DEFAULT_ADDRESS, NULL, sizeof(struct _Usart)},
62 { "ace", AIC_SYSTEM_ACE, IDE_DEFAULT_ADDRESS, NULL, sizeof(struct _Sac) },
63 { "ace", AIC_SYSTEM_ACE2, IDE_DEFAULT_ADDRESS+256, NULL, sizeof(struct _Sac) },
64 { "enic", AIC_ETHERNET, ETHERNET_DEFAULT_ADDRESS, NULL, sizeof(struct _Enic) },
65 { "icap", AIC_ICAP, ICAP_DEFAULT_ADDRESS, NULL, sizeof(struct _Icap) },
66 { "gpio", AIC_GPIO, GPIO_DEFAULT_ADDRESS, NULL, sizeof(struct _Pio) },
67 { "flash", 0, FLASH_0_DEFAULT_ADDRESS, NULL, sizeof(struct _Flash) },
68 { "lcd", 0, LCD_DEFAULT_ADDRESS, NULL, sizeof(struct _Lcd) },
69 { "evga", AIC_VGA, VGA_DEFAULT_ADDRESS, NULL, sizeof(struct _Evga) },
70 { "ps2", AIC_PS2, PS2_DEFAULT_ADDRESS, NULL, sizeof(struct _Cpbdi) },
71 { "ac97", AIC_AC97, AC97_DEFAULT_ADDRESS, NULL, sizeof(struct _Cpbdi) },
72 };
73 static const int ebus_emips_ndevs =
74 sizeof(ebus_emips_devs)/sizeof(ebus_emips_devs[0]);
75 #endif /* XILINX_ML40x */
76
77 static int ebus_attached;
78
79 static int
ebus_emips_match(device_t parent,cfdata_t cf,void * aux)80 ebus_emips_match(device_t parent, cfdata_t cf, void *aux)
81 {
82 struct mainbus_attach_args *ma = aux;
83
84 if (ebus_attached)
85 return 0;
86 if (systype != XS_ML40x && systype != XS_BE3 && systype != XS_ML50x)
87 return 0;
88 if (strcmp(ma->ma_name, "baseboard") != 0)
89 return 0;
90
91 return 1;
92 }
93
94 static void
ebus_emips_attach(device_t parent,device_t self,void * aux)95 ebus_emips_attach(device_t parent, device_t self, void *aux)
96 {
97 struct ebus_dev_attach_args ida;
98
99 ebus_attached = 1;
100
101 ida.ida_busname = "ebus";
102 switch (systype) {
103 #if defined(XILINX_ML40x) || defined(XS_BEE3)
104 case XS_ML40x:
105 case XS_ML50x:
106 case XS_BE3:
107 ida.ida_devs = ebus_emips_devs;
108 ida.ida_ndevs = ebus_emips_ndevs;
109 break;
110 #endif
111 default:
112 panic("ebus_emips_attach: no ebus configured for systype = %d",
113 systype);
114 }
115
116 ebusattach(parent, self, &ida);
117 }
118