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