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