11.9Scegger/*	$NetBSD: bi_xmi.c,v 1.9 2009/05/12 14:48:08 cegger Exp $	*/
21.1Sragge
31.1Sragge/*
41.1Sragge * Copyright (c) 2000 Ludd, University of Lule}, Sweden. All rights reserved.
51.1Sragge *
61.1Sragge * Redistribution and use in source and binary forms, with or without
71.1Sragge * modification, are permitted provided that the following conditions
81.1Sragge * are met:
91.1Sragge * 1. Redistributions of source code must retain the above copyright
101.1Sragge *    notice, this list of conditions and the following disclaimer.
111.1Sragge * 2. Redistributions in binary form must reproduce the above copyright
121.1Sragge *    notice, this list of conditions and the following disclaimer in the
131.1Sragge *    documentation and/or other materials provided with the distribution.
141.1Sragge * 3. All advertising materials mentioning features or use of this software
151.1Sragge *    must display the following acknowledgement:
161.1Sragge *      This product includes software developed at Ludd, University of
171.1Sragge *      Lule}, Sweden and its contributors.
181.1Sragge * 4. The name of the author may not be used to endorse or promote products
191.1Sragge *    derived from this software without specific prior written permission
201.1Sragge *
211.1Sragge * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
221.1Sragge * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
231.1Sragge * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
241.1Sragge * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
251.1Sragge * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
261.1Sragge * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
271.1Sragge * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
281.1Sragge * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
291.1Sragge * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
301.1Sragge * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
311.1Sragge */
321.1Sragge
331.1Sragge
341.1Sragge/*
351.1Sragge * DWMBA XMI-BI adapter.
361.1Sragge */
371.2Slukem
381.2Slukem#include <sys/cdefs.h>
391.9Scegger__KERNEL_RCSID(0, "$NetBSD: bi_xmi.c,v 1.9 2009/05/12 14:48:08 cegger Exp $");
401.1Sragge
411.1Sragge#include <sys/param.h>
421.1Sragge#include <sys/device.h>
431.1Sragge
441.6Sad#include <sys/bus.h>
451.1Sragge
461.1Sragge#include <dev/xmi/xmireg.h>
471.1Sragge#include <dev/xmi/xmivar.h>
481.1Sragge
491.1Sragge#include <dev/bi/bireg.h>
501.1Sragge#include <dev/bi/bivar.h>
511.1Sragge
521.1Sragge#include "locators.h"
531.1Sragge
541.1Sraggestatic int
551.9Sceggerbi_xmi_match(device_t parent, cfdata_t cf, void *aux)
561.1Sragge{
571.1Sragge	struct xmi_attach_args *xa = aux;
581.1Sragge
591.1Sragge	if (bus_space_read_2(xa->xa_iot, xa->xa_ioh, XMI_TYPE) != XMIDT_DWMBA)
601.1Sragge		return 0;
611.1Sragge
621.1Sragge	if (cf->cf_loc[XMICF_NODE] != XMICF_NODE_DEFAULT &&
631.1Sragge	    cf->cf_loc[XMICF_NODE] != xa->xa_nodenr)
641.1Sragge		return 0;
651.1Sragge
661.1Sragge	return 1;
671.1Sragge}
681.1Sragge
691.1Sraggestatic void
701.9Sceggerbi_xmi_attach(device_t parent, device_t self, void *aux)
711.1Sragge{
721.7Smatt	struct bi_softc *sc = device_private(self);
731.1Sragge	struct xmi_attach_args *xa = aux;
741.1Sragge
751.1Sragge	/*
761.1Sragge	 * Fill in bus specific data.
771.1Sragge	 */
781.7Smatt	sc->sc_dev = self;
791.1Sragge	sc->sc_addr = (bus_addr_t)BI_BASE(xa->xa_nodenr, 0);
801.1Sragge	sc->sc_iot = xa->xa_iot; /* No special I/O handling */
811.1Sragge	sc->sc_dmat = xa->xa_dmat; /* No special DMA handling either */
821.1Sragge	sc->sc_intcpu = xa->xa_intcpu;
831.1Sragge
841.1Sragge	bi_attach(sc);
851.1Sragge}
861.1Sragge
871.7SmattCFATTACH_DECL_NEW(bi_xmi, sizeof(struct bi_softc),
881.5Sthorpej    bi_xmi_match, bi_xmi_attach, NULL, NULL);
89