Home | History | Annotate | Line # | Download | only in bi
      1  1.27   thorpej /*	$NetBSD: bi.c,v 1.27 2021/08/07 16:19:09 thorpej Exp $ */
      2   1.1     ragge /*
      3   1.1     ragge  * Copyright (c) 1996 Ludd, University of Lule}, Sweden.
      4   1.1     ragge  * 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.20     perry  *      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 
     35   1.1     ragge /*
     36   1.1     ragge  * VAXBI specific routines.
     37   1.1     ragge  */
     38   1.1     ragge /*
     39   1.1     ragge  * TODO
     40   1.1     ragge  *   handle BIbus errors more gracefully.
     41   1.1     ragge  */
     42  1.17     lukem 
     43  1.17     lukem #include <sys/cdefs.h>
     44  1.27   thorpej __KERNEL_RCSID(0, "$NetBSD: bi.c,v 1.27 2021/08/07 16:19:09 thorpej Exp $");
     45   1.1     ragge 
     46   1.1     ragge #include <sys/param.h>
     47   1.7     ragge #include <sys/systm.h>
     48   1.1     ragge 
     49  1.23        ad #include <sys/bus.h>
     50  1.23        ad #include <sys/cpu.h>
     51  1.25      matt #include <sys/device.h>
     52   1.1     ragge 
     53  1.13     ragge #include <dev/bi/bireg.h>
     54  1.13     ragge #include <dev/bi/bivar.h>
     55   1.1     ragge 
     56  1.19     perry static int bi_print(void *, const char *);
     57   1.1     ragge 
     58  1.24      matt static const struct bi_list bi_list[] = {
     59  1.16     ragge 	{BIDT_MS820, DT_HAVDRV, "ms820"},
     60  1.16     ragge 	{BIDT_DRB32, DT_UNSUPP, "drb32"},
     61  1.16     ragge 	{BIDT_DWBUA, DT_HAVDRV|DT_ADAPT, "dwbua"},
     62  1.16     ragge 	{BIDT_KLESI, DT_HAVDRV|DT_ADAPT, "klesi"},
     63  1.16     ragge 	{BIDT_KA820, DT_HAVDRV, "ka820"},
     64  1.16     ragge 	{BIDT_DB88,  DT_HAVDRV|DT_QUIET, "db88"},
     65  1.16     ragge 	{BIDT_CIBCA, DT_UNSUPP, "cibca"},
     66  1.16     ragge 	{BIDT_DMB32, DT_UNSUPP, "dmb32"},
     67  1.16     ragge 	{BIDT_CIBCI, DT_UNSUPP, "cibci"},
     68  1.16     ragge 	{BIDT_KA800, DT_UNSUPP, "ka800"},
     69  1.16     ragge 	{BIDT_KDB50, DT_HAVDRV|DT_VEC, "kdb50"},
     70  1.16     ragge 	{BIDT_DWMBA, DT_HAVDRV|DT_QUIET, "dwmba"},
     71  1.16     ragge 	{BIDT_KFBTA, DT_UNSUPP, "kfbta"},
     72  1.16     ragge 	{BIDT_DEBNK, DT_HAVDRV|DT_VEC, "debnk"},
     73  1.16     ragge 	{BIDT_DEBNA, DT_HAVDRV|DT_VEC, "debna"},
     74   1.1     ragge 	{0,0,0}
     75   1.1     ragge };
     76   1.1     ragge 
     77   1.1     ragge int
     78  1.24      matt bi_print(void *aux, const char *name)
     79   1.1     ragge {
     80   1.1     ragge 	struct bi_attach_args *ba = aux;
     81  1.24      matt 	const struct bi_list *bl;
     82  1.15     ragge 	u_int16_t nr;
     83   1.1     ragge 
     84  1.15     ragge 	nr = bus_space_read_2(ba->ba_iot, ba->ba_ioh, 0);
     85   1.7     ragge 	for (bl = &bi_list[0]; bl->bl_nr; bl++)
     86  1.15     ragge 		if (bl->bl_nr == nr)
     87   1.7     ragge 			break;
     88   1.7     ragge 
     89   1.1     ragge 	if (name) {
     90   1.1     ragge 		if (bl->bl_nr == 0)
     91  1.18   thorpej 			aprint_normal("unknown device 0x%x", nr);
     92   1.7     ragge 		else
     93  1.18   thorpej 			aprint_normal(bl->bl_name);
     94  1.18   thorpej 		aprint_normal(" at %s", name);
     95   1.1     ragge 	}
     96  1.18   thorpej 	aprint_normal(" node %d", ba->ba_nodenr);
     97  1.16     ragge 	if (bl->bl_havedriver & DT_VEC)
     98  1.18   thorpej 		aprint_normal(" vec %o", ba->ba_ivec & 511);
     99   1.8     ragge #ifdef DEBUG
    100  1.13     ragge 	if (bus_space_read_4(ba->ba_iot, ba->ba_ioh, BIREG_SADR) &&
    101  1.13     ragge 	    bus_space_read_4(ba->ba_iot, ba->ba_ioh, BIREG_EADR))
    102  1.18   thorpej 		aprint_debug(" [sadr %x eadr %x]",
    103  1.13     ragge 		    bus_space_read_4(ba->ba_iot, ba->ba_ioh, BIREG_SADR),
    104  1.13     ragge 		    bus_space_read_4(ba->ba_iot, ba->ba_ioh, BIREG_EADR));
    105   1.8     ragge #endif
    106  1.16     ragge 	if (bl->bl_havedriver & DT_QUIET)
    107  1.18   thorpej 		aprint_normal("\n");
    108  1.16     ragge 	return bl->bl_havedriver & DT_QUIET ? QUIET :
    109  1.16     ragge 	    bl->bl_havedriver & DT_HAVDRV ? UNCONF : UNSUPP;
    110   1.1     ragge }
    111   1.1     ragge 
    112   1.1     ragge void
    113  1.24      matt bi_attach(struct bi_softc *sc)
    114   1.1     ragge {
    115   1.1     ragge 	struct bi_attach_args ba;
    116   1.1     ragge 	int nodenr;
    117   1.1     ragge 
    118  1.24      matt 	aprint_normal("\n");
    119   1.1     ragge 
    120  1.13     ragge 	ba.ba_iot = sc->sc_iot;
    121  1.13     ragge 	ba.ba_busnr = sc->sc_busnr;
    122  1.14     ragge 	ba.ba_dmat = sc->sc_dmat;
    123  1.14     ragge 	ba.ba_intcpu = sc->sc_intcpu;
    124  1.16     ragge 	ba.ba_icookie = sc;
    125  1.13     ragge 	/*
    126  1.20     perry 	 * Interrupt numbers. Assign them as described in
    127  1.16     ragge 	 * VAX 8800 system maintenance manual; this means like nexus
    128  1.16     ragge 	 * adapters have them assigned.
    129  1.16     ragge 	 * XXX - must address Unibus adapters.
    130  1.13     ragge 	 */
    131   1.1     ragge 	for (nodenr = 0; nodenr < NNODEBI; nodenr++) {
    132  1.13     ragge 		if (bus_space_map(sc->sc_iot, sc->sc_addr + BI_NODE(nodenr),
    133  1.15     ragge 		    BI_NODESIZE, 0, &ba.ba_ioh)) {
    134  1.24      matt 			aprint_error_dev(sc->sc_dev,
    135  1.24      matt 			    "bus_space_map failed, node %d\n", nodenr);
    136  1.13     ragge 			return;
    137  1.13     ragge 		}
    138  1.22  christos 		if (badaddr((void *)ba.ba_ioh, 4) ||
    139  1.16     ragge 		    (bus_space_read_2(ba.ba_iot, ba.ba_ioh, 0) == 0)) {
    140  1.16     ragge 			bus_space_unmap(ba.ba_iot, ba.ba_ioh, BI_NODESIZE);
    141  1.14     ragge 			continue;
    142  1.11     ragge 		}
    143  1.14     ragge 		ba.ba_nodenr = nodenr;
    144  1.16     ragge 		ba.ba_ivec = sc->sc_lastiv + 64 + 4 * nodenr; /* all on spl5 */
    145  1.27   thorpej 		config_found(sc->sc_dev, &ba, bi_print, CFARGS_NONE);
    146   1.1     ragge 	}
    147   1.1     ragge }
    148