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