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