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