bi_xmi.c revision 1.7
1/*	$NetBSD: bi_xmi.c,v 1.7 2008/03/11 05:34:02 matt Exp $	*/
2
3/*
4 * Copyright (c) 2000 Ludd, University of Lule}, Sweden. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 *    notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 *    notice, this list of conditions and the following disclaimer in the
13 *    documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software
15 *    must display the following acknowledgement:
16 *      This product includes software developed at Ludd, University of
17 *      Lule}, Sweden and its contributors.
18 * 4. The name of the author may not be used to endorse or promote products
19 *    derived from this software without specific prior written permission
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33
34/*
35 * DWMBA XMI-BI adapter.
36 */
37
38#include <sys/cdefs.h>
39__KERNEL_RCSID(0, "$NetBSD: bi_xmi.c,v 1.7 2008/03/11 05:34:02 matt Exp $");
40
41#include <sys/param.h>
42#include <sys/device.h>
43
44#include <sys/bus.h>
45
46#include <dev/xmi/xmireg.h>
47#include <dev/xmi/xmivar.h>
48
49#include <dev/bi/bireg.h>
50#include <dev/bi/bivar.h>
51
52#include "locators.h"
53
54static int
55bi_xmi_match(struct device *parent, struct cfdata *cf, void *aux)
56{
57	struct xmi_attach_args *xa = aux;
58
59	if (bus_space_read_2(xa->xa_iot, xa->xa_ioh, XMI_TYPE) != XMIDT_DWMBA)
60		return 0;
61
62	if (cf->cf_loc[XMICF_NODE] != XMICF_NODE_DEFAULT &&
63	    cf->cf_loc[XMICF_NODE] != xa->xa_nodenr)
64		return 0;
65
66	return 1;
67}
68
69static void
70bi_xmi_attach(struct device *parent, struct device *self, void *aux)
71{
72	struct bi_softc *sc = device_private(self);
73	struct xmi_attach_args *xa = aux;
74
75	/*
76	 * Fill in bus specific data.
77	 */
78	sc->sc_dev = self;
79	sc->sc_addr = (bus_addr_t)BI_BASE(xa->xa_nodenr, 0);
80	sc->sc_iot = xa->xa_iot; /* No special I/O handling */
81	sc->sc_dmat = xa->xa_dmat; /* No special DMA handling either */
82	sc->sc_intcpu = xa->xa_intcpu;
83
84	bi_attach(sc);
85}
86
87CFATTACH_DECL_NEW(bi_xmi, sizeof(struct bi_softc),
88    bi_xmi_match, bi_xmi_attach, NULL, NULL);
89