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