Home | History | Annotate | Line # | Download | only in uba
      1  1.4     ragge /*	$NetBSD: uba_ubi.c,v 1.4 2017/05/22 17:15:45 ragge Exp $	   */
      2  1.1  christos /*
      3  1.1  christos  * Copyright (c) 1982, 1986 The Regents of the University of California.
      4  1.1  christos  * All rights reserved.
      5  1.1  christos  *
      6  1.1  christos  * Redistribution and use in source and binary forms, with or without
      7  1.1  christos  * modification, are permitted provided that the following conditions
      8  1.1  christos  * are met:
      9  1.1  christos  * 1. Redistributions of source code must retain the above copyright
     10  1.1  christos  *    notice, this list of conditions and the following disclaimer.
     11  1.1  christos  * 2. Redistributions in binary form must reproduce the above copyright
     12  1.1  christos  *    notice, this list of conditions and the following disclaimer in the
     13  1.1  christos  *    documentation and/or other materials provided with the distribution.
     14  1.1  christos  * 3. Neither the name of the University nor the names of its contributors
     15  1.1  christos  *    may be used to endorse or promote products derived from this software
     16  1.1  christos  *    without specific prior written permission.
     17  1.1  christos  *
     18  1.1  christos  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     19  1.1  christos  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     20  1.1  christos  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     21  1.1  christos  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     22  1.1  christos  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     23  1.1  christos  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     24  1.1  christos  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     25  1.1  christos  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     26  1.1  christos  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     27  1.1  christos  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     28  1.1  christos  * SUCH DAMAGE.
     29  1.1  christos  *
     30  1.1  christos  *	@(#)uba.c	7.10 (Berkeley) 12/16/90
     31  1.1  christos  *	@(#)autoconf.c	7.20 (Berkeley) 5/9/91
     32  1.1  christos  */
     33  1.1  christos 
     34  1.1  christos /*
     35  1.1  christos  * Copyright (c) 1996 Jonathan Stone.
     36  1.1  christos  * Copyright (c) 1994, 1996 Ludd, University of Lule}, Sweden.
     37  1.1  christos  *
     38  1.1  christos  * Redistribution and use in source and binary forms, with or without
     39  1.1  christos  * modification, are permitted provided that the following conditions
     40  1.1  christos  * are met:
     41  1.1  christos  * 1. Redistributions of source code must retain the above copyright
     42  1.1  christos  *    notice, this list of conditions and the following disclaimer.
     43  1.1  christos  * 2. Redistributions in binary form must reproduce the above copyright
     44  1.1  christos  *    notice, this list of conditions and the following disclaimer in the
     45  1.1  christos  *    documentation and/or other materials provided with the distribution.
     46  1.1  christos  *
     47  1.1  christos  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     48  1.1  christos  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     49  1.1  christos  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     50  1.1  christos  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     51  1.1  christos  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     52  1.1  christos  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     53  1.1  christos  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     54  1.1  christos  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     55  1.1  christos  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     56  1.1  christos  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     57  1.1  christos  * SUCH DAMAGE.
     58  1.1  christos  *
     59  1.1  christos  *	@(#)uba.c	7.10 (Berkeley) 12/16/90
     60  1.1  christos  *	@(#)autoconf.c	7.20 (Berkeley) 5/9/91
     61  1.1  christos  */
     62  1.1  christos 
     63  1.1  christos #include <sys/cdefs.h>
     64  1.4     ragge __KERNEL_RCSID(0, "$NetBSD: uba_ubi.c,v 1.4 2017/05/22 17:15:45 ragge Exp $");
     65  1.2      matt 
     66  1.2      matt #define _VAX_BUS_DMA_PRIVATE
     67  1.1  christos 
     68  1.1  christos #include <sys/param.h>
     69  1.2      matt #include <sys/systm.h>
     70  1.2      matt #include <sys/bus.h>
     71  1.2      matt #include <sys/cpu.h>
     72  1.1  christos #include <sys/device.h>
     73  1.1  christos 
     74  1.1  christos #include <machine/nexus.h>
     75  1.1  christos #include <machine/sgmap.h>
     76  1.1  christos 
     77  1.1  christos #include <dev/qbus/ubavar.h>
     78  1.1  christos 
     79  1.1  christos #include <vax/uba/uba_common.h>
     80  1.1  christos 
     81  1.1  christos #include "locators.h"
     82  1.1  christos 
     83  1.1  christos /* Some UBI-specific defines */
     84  1.1  christos #define	UBASIZE		((UBAPAGES + UBAIOPAGES) * VAX_NBPG)
     85  1.1  christos #define UMEM730     	(0xfc0000)
     86  1.1  christos #define	UIOPAGE		(UMEM730 + (UBAPAGES * VAX_NBPG))
     87  1.1  christos 
     88  1.1  christos /*
     89  1.1  christos  * The DW780, DW750 and DW730 are quite similar to their function from
     90  1.1  christos  * a programmers point of view. Differencies are number of BDP's
     91  1.1  christos  * and bus status/command registers, the latter are (partly) IPR's
     92  1.1  christos  * on 750.
     93  1.1  christos  */
     94  1.3      matt static	int	dw730_match(device_t, cfdata_t, void *);
     95  1.3      matt static	void	dw730_attach(device_t, device_t, void *);
     96  1.1  christos static	void	dw730_init(struct uba_softc*);
     97  1.1  christos #ifdef notyet
     98  1.1  christos static	void	dw730_purge(struct uba_softc *, int);
     99  1.1  christos #endif
    100  1.1  christos 
    101  1.1  christos CFATTACH_DECL_NEW(uba_ubi, sizeof(struct uba_vsoftc),
    102  1.1  christos     dw730_match, dw730_attach, NULL, NULL);
    103  1.1  christos 
    104  1.1  christos extern	struct vax_bus_space vax_mem_bus_space;
    105  1.1  christos 
    106  1.1  christos int
    107  1.1  christos dw730_match(device_t parent, cfdata_t cf, void *aux)
    108  1.1  christos {
    109  1.1  christos 	struct sbi_attach_args *sa = (struct sbi_attach_args *)aux;
    110  1.1  christos 
    111  1.1  christos 	if (cf->cf_loc[UBICF_TR] != sa->sa_nexnum &&
    112  1.1  christos 	    cf->cf_loc[UBICF_TR] != UBICF_TR_DEFAULT)
    113  1.1  christos 		return 0;
    114  1.1  christos 	/*
    115  1.1  christos 	 * The uba type is actually only telling where the uba
    116  1.1  christos 	 * space is in nexus space.
    117  1.1  christos 	 */
    118  1.1  christos 	if ((sa->sa_type & ~3) != NEX_UBA0)
    119  1.1  christos 		return 0;
    120  1.1  christos 
    121  1.1  christos 	return 1;
    122  1.1  christos }
    123  1.1  christos 
    124  1.1  christos void
    125  1.1  christos dw730_attach(device_t parent, device_t self, void *aux)
    126  1.1  christos {
    127  1.1  christos 	struct uba_vsoftc *sc = device_private(self);
    128  1.1  christos 	struct sbi_attach_args *sa = aux;
    129  1.1  christos 
    130  1.1  christos 	printf(": DW730\n");
    131  1.1  christos 
    132  1.1  christos 	/*
    133  1.1  christos 	 * Fill in bus specific data.
    134  1.1  christos 	 */
    135  1.1  christos 	sc->uv_sc.uh_dev = self;
    136  1.1  christos 	sc->uv_sc.uh_ubainit = dw730_init;
    137  1.1  christos #ifdef notyet
    138  1.1  christos 	sc->uv_sc.uh_ubapurge = dw730_purge;
    139  1.1  christos #endif
    140  1.1  christos 	sc->uv_sc.uh_iot = &vax_mem_bus_space;
    141  1.1  christos 	sc->uv_sc.uh_dmat = &sc->uv_dmat;
    142  1.1  christos 	sc->uv_sc.uh_type = UBA_UBA;
    143  1.1  christos 	sc->uv_sc.uh_nr = sa->sa_type == NEX_UBA1;
    144  1.1  christos 
    145  1.1  christos 	/*
    146  1.1  christos 	 * Fill in variables used by the sgmap system.
    147  1.1  christos 	 */
    148  1.1  christos 	sc->uv_size = UBAPAGES * VAX_NBPG;
    149  1.1  christos 	sc->uv_uba = (void *)sa->sa_ioh; /* Map registers is in adaptor */
    150  1.1  christos 
    151  1.1  christos 	uba_dma_init(sc);
    152  1.1  christos 	uba_attach(&sc->uv_sc, UIOPAGE);
    153  1.1  christos }
    154  1.1  christos 
    155  1.1  christos void
    156  1.1  christos dw730_init(struct uba_softc *sc)
    157  1.1  christos {
    158  1.1  christos 	mtpr(0, PR_IUR);
    159  1.1  christos 	DELAY(500000);
    160  1.1  christos }
    161  1.1  christos 
    162  1.1  christos #ifdef notyet
    163  1.1  christos void
    164  1.1  christos dw730_purge(struct uba_softc sc, int bdp)
    165  1.1  christos {
    166  1.1  christos 	sc->uh_uba->uba_dpr[bdp] |= UBADPR_PURGE | UBADPR_NXM | UBADPR_UCE;
    167  1.1  christos }
    168  1.1  christos #endif
    169