Home | History | Annotate | Line # | Download | only in xmi
xmi.c revision 1.8
      1  1.8  christos /*	$NetBSD: xmi.c,v 1.8 2007/03/04 06:02:52 christos Exp $	*/
      2  1.1     ragge 
      3  1.1     ragge /*
      4  1.1     ragge  * Copyright (c) 2000 Ludd, University of Lule}, Sweden. All rights reserved.
      5  1.1     ragge  *
      6  1.1     ragge  * Redistribution and use in source and binary forms, with or without
      7  1.1     ragge  * modification, are permitted provided that the following conditions
      8  1.1     ragge  * are met:
      9  1.1     ragge  * 1. Redistributions of source code must retain the above copyright
     10  1.1     ragge  *    notice, this list of conditions and the following disclaimer.
     11  1.1     ragge  * 2. Redistributions in binary form must reproduce the above copyright
     12  1.1     ragge  *    notice, this list of conditions and the following disclaimer in the
     13  1.1     ragge  *    documentation and/or other materials provided with the distribution.
     14  1.1     ragge  * 3. All advertising materials mentioning features or use of this software
     15  1.1     ragge  *    must display the following acknowledgement:
     16  1.1     ragge  *      This product includes software developed at Ludd, University of
     17  1.1     ragge  *      Lule}, Sweden and its contributors.
     18  1.1     ragge  * 4. The name of the author may not be used to endorse or promote products
     19  1.1     ragge  *    derived from this software without specific prior written permission
     20  1.1     ragge  *
     21  1.1     ragge  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     22  1.1     ragge  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23  1.1     ragge  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24  1.1     ragge  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     25  1.1     ragge  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     26  1.1     ragge  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27  1.1     ragge  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28  1.1     ragge  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29  1.1     ragge  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     30  1.1     ragge  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31  1.1     ragge  */
     32  1.1     ragge 
     33  1.1     ragge /*
     34  1.1     ragge  * XMI specific routines.
     35  1.1     ragge  */
     36  1.2     lukem 
     37  1.2     lukem #include <sys/cdefs.h>
     38  1.8  christos __KERNEL_RCSID(0, "$NetBSD: xmi.c,v 1.8 2007/03/04 06:02:52 christos Exp $");
     39  1.1     ragge 
     40  1.1     ragge #include <sys/param.h>
     41  1.1     ragge #include <sys/systm.h>
     42  1.1     ragge #include <sys/device.h>
     43  1.1     ragge 
     44  1.5   thorpej #include <uvm/uvm_extern.h>
     45  1.5   thorpej 
     46  1.1     ragge #include <machine/bus.h>
     47  1.1     ragge #include <machine/cpu.h>
     48  1.1     ragge 
     49  1.1     ragge #include <dev/xmi/xmireg.h>
     50  1.1     ragge #include <dev/xmi/xmivar.h>
     51  1.1     ragge 
     52  1.1     ragge static int xmi_print(void *, const char *);
     53  1.1     ragge 
     54  1.1     ragge struct xmi_list xmi_list[] = {
     55  1.1     ragge 	{XMIDT_KA62, 0, "ka6200"},
     56  1.1     ragge 	{XMIDT_KA64, 1, "ka6400"},
     57  1.1     ragge 	{XMIDT_KA65, 0, "ka6500"},
     58  1.1     ragge 	{XMIDT_KA66, 0, "ka6600"},
     59  1.1     ragge 	{XMIDT_MS62, 1, "ms62"},
     60  1.1     ragge 	{XMIDT_DWMBA, 1, "dwmba"},
     61  1.1     ragge 	{0,0,0}
     62  1.1     ragge };
     63  1.1     ragge 
     64  1.1     ragge int
     65  1.1     ragge xmi_print(void *aux, const char *name)
     66  1.1     ragge {
     67  1.1     ragge 	struct xmi_attach_args *xa = aux;
     68  1.1     ragge 	struct xmi_list *xl;
     69  1.1     ragge 
     70  1.1     ragge 	for (xl = &xmi_list[0]; xl->xl_nr; xl++)
     71  1.1     ragge 		if (xl->xl_nr == bus_space_read_2(xa->xa_iot, xa->xa_ioh, 0))
     72  1.1     ragge 			break;
     73  1.1     ragge 
     74  1.1     ragge 	if (name) {
     75  1.1     ragge 		if (xl->xl_nr == 0)
     76  1.3   thorpej 			aprint_normal("unknown device 0x%x",
     77  1.1     ragge 			    bus_space_read_2(xa->xa_iot, xa->xa_ioh, 0));
     78  1.1     ragge 		else
     79  1.4   thorpej 			aprint_normal(xl->xl_name);
     80  1.3   thorpej 		aprint_normal(" at %s", name);
     81  1.1     ragge 	}
     82  1.3   thorpej 	aprint_normal(" node %d", xa->xa_nodenr);
     83  1.1     ragge 	return xl->xl_havedriver ? UNCONF : UNSUPP;
     84  1.1     ragge }
     85  1.1     ragge 
     86  1.1     ragge static	int lastiv = 0;
     87  1.1     ragge 
     88  1.1     ragge void
     89  1.1     ragge xmi_attach(struct xmi_softc *sc)
     90  1.1     ragge {
     91  1.1     ragge 	struct xmi_attach_args xa;
     92  1.1     ragge 	int nodenr;
     93  1.1     ragge 
     94  1.1     ragge 	printf("\n");
     95  1.1     ragge 
     96  1.1     ragge 	xa.xa_iot = sc->sc_iot;
     97  1.1     ragge 	xa.xa_busnr = sc->sc_busnr;
     98  1.1     ragge 	xa.xa_dmat = sc->sc_dmat;
     99  1.1     ragge 	xa.xa_intcpu = sc->sc_intcpu;
    100  1.1     ragge 	/*
    101  1.1     ragge 	 * Interrupt numbers. All vectors from 256-512 are free, use
    102  1.1     ragge 	 * them for XMI devices and just count them up.
    103  1.1     ragge 	 * Above 512 are only interrupt vectors for unibus devices.
    104  1.1     ragge 	 *
    105  1.1     ragge 	 * The XMI nodespace is giant in size. Only map in the first
    106  1.1     ragge 	 * page here and map more (if needed) in the device itself.
    107  1.1     ragge 	 */
    108  1.1     ragge 	for (nodenr = 0; nodenr < NNODEXMI; nodenr++) {
    109  1.1     ragge 		if (bus_space_map(sc->sc_iot, sc->sc_addr + XMI_NODE(nodenr),
    110  1.5   thorpej 		    PAGE_SIZE, 0, &xa.xa_ioh)) {
    111  1.6     perry 			printf("xmi_attach: bus_space_map failed, node %d\n",
    112  1.1     ragge 			    nodenr);
    113  1.1     ragge 			return;
    114  1.1     ragge 		}
    115  1.8  christos 		if (badaddr((void *)xa.xa_ioh, 4)) {
    116  1.5   thorpej 			bus_space_unmap(sc->sc_iot, xa.xa_ioh, PAGE_SIZE);
    117  1.1     ragge 			continue;
    118  1.1     ragge 		}
    119  1.1     ragge 		xa.xa_nodenr = nodenr;
    120  1.1     ragge 		xa.xa_ivec = 256 + lastiv;
    121  1.1     ragge 		lastiv += 4;
    122  1.1     ragge 		config_found(&sc->sc_dev, &xa, xmi_print);
    123  1.1     ragge 	}
    124  1.1     ragge }
    125