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