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