1 /* $NetBSD: mca.c,v 1.29 2009/05/12 13:15:24 cegger Exp $ */
4 * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
5 * Copyright (c) 1996-1999 Scott D. Telford.
8 * This code is derived from software contributed to The NetBSD Foundation
9 * by Scott Telford <s.telford@ed.ac.uk>.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
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.
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.
37 #include <sys/cdefs.h>
38 __KERNEL_RCSID(0, "$NetBSD: mca.c,v 1.29 2009/05/12 13:15:24 cegger Exp $");
40 #include <sys/param.h>
41 #include <sys/systm.h>
42 #include <sys/device.h>
45 #include <machine/mca_machdep.h>
47 #include <dev/mca/mcareg.h>
48 #include <dev/mca/mcavar.h>
49 #include <dev/mca/mcadevs.h>
53 int mca_match(device_t
, cfdata_t
, void *);
54 void mca_attach(device_t
, device_t
, void *);
56 CFATTACH_DECL(mca
, sizeof(struct device
),
57 mca_match
, mca_attach
, NULL
, NULL
);
59 int mca_print(void *, const char *);
62 mca_match(device_t parent
, cfdata_t cf
, void *aux
)
64 struct mcabus_attach_args
*mba
= aux
;
66 /* sanity (only mca0 supported currently) */
67 if (mba
->mba_bus
< 0 || mba
->mba_bus
> 0)
70 /* XXX check other indicators? */
76 mca_print(void *aux
, const char *pnp
)
78 register struct mca_attach_args
*ma
= aux
;
82 mca_devinfo(ma
->ma_id
, devinfo
, sizeof(devinfo
));
83 aprint_normal("%s slot %d: %s", pnp
, ma
->ma_slot
+ 1, devinfo
);
87 * Print "configured" for Memory Extension boards - there is no
88 * meaningfull driver for them, they "just work".
91 case MCA_PRODUCT_HRAM
: case MCA_PRODUCT_IQRAM
: case MCA_PRODUCT_MICRAM
:
92 case MCA_PRODUCT_ASTRAM
: case MCA_PRODUCT_KINGRAM
:
93 case MCA_PRODUCT_KINGRAM8
: case MCA_PRODUCT_KINGRAM16
:
94 case MCA_PRODUCT_KINGRAM609
: case MCA_PRODUCT_HYPRAM
:
95 case MCA_PRODUCT_QRAM1
: case MCA_PRODUCT_QRAM2
: case MCA_PRODUCT_EVERAM
:
96 case MCA_PRODUCT_BOCARAM
: case MCA_PRODUCT_IBMRAM1
:
97 case MCA_PRODUCT_IBMRAM2
: case MCA_PRODUCT_IBMRAM3
:
98 case MCA_PRODUCT_IBMRAM4
: case MCA_PRODUCT_IBMRAM5
:
99 case MCA_PRODUCT_IBMRAM6
: case MCA_PRODUCT_IBMRAM7
:
100 aprint_normal(": memory configured\n");
108 mca_attach(device_t parent
, device_t self
, void *aux
)
110 struct mcabus_attach_args
*mba
= aux
;
111 bus_space_tag_t iot
, memt
;
113 mca_chipset_tag_t mc
;
116 mca_attach_hook(parent
, self
, mba
);
120 memt
= mba
->mba_memt
;
122 dmat
= mba
->mba_dmat
;
125 * Search for and attach subdevices.
127 * NB: In the adapter setup register, slots are numbered from 0,
128 * but officially they are numbered from 1.
129 * We use the former convention internally and the latter for text
130 * messages and in config files.
133 for (slot
= 0; slot
< MCA_MAX_SLOTS
; slot
++) {
134 struct mca_attach_args ma
;
136 int locs
[MCACF_NLOCS
];
144 for(reg
= 0; reg
< 8; reg
++)
145 ma
.ma_pos
[reg
]=mca_conf_read(mc
, slot
, reg
);
147 ma
.ma_id
= ma
.ma_pos
[0] + (ma
.ma_pos
[1] << 8);
148 if (ma
.ma_id
== 0xffff) /* no adapter here */
151 locs
[MCACF_SLOT
] = slot
;
153 if (ma
.ma_pos
[2] & MCA_POS2_ENABLE
154 || mca_match_disabled(ma
.ma_id
))
155 config_found_sm_loc(self
, "mca", locs
, &ma
,
156 mca_print
, config_stdsubmatch
);
158 mca_print(&ma
, device_xname(self
));
159 printf(" disabled\n");