1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
|
/* $NetBSD: vme_pcc.c,v 1.26 2012/10/27 17:18:04 chs Exp $ */
/*-
* Copyright (c) 1996-2000 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe and Steve C. Woodford.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* VME support specific to the Type 1 VMEchip found on the
* MVME-147.
*
* For a manual on the MVME-147, call: 408.991.8634. (Yes, this
* is the Sunnyvale sales office.)
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: vme_pcc.c,v 1.26 2012/10/27 17:18:04 chs Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <sys/malloc.h>
#include <sys/kcore.h>
#include <machine/cpu.h>
#include <machine/bus.h>
#include <dev/vme/vmereg.h>
#include <dev/vme/vmevar.h>
#include <mvme68k/dev/pccreg.h>
#include <mvme68k/dev/pccvar.h>
#include <dev/mvme/mvmebus.h>
#include <mvme68k/dev/vme_pccreg.h>
#include <mvme68k/dev/vme_pccvar.h>
int vme_pcc_match(device_t, cfdata_t, void *);
void vme_pcc_attach(device_t, device_t, void *);
CFATTACH_DECL_NEW(vmepcc, sizeof(struct vme_pcc_softc),
vme_pcc_match, vme_pcc_attach, NULL, NULL);
extern struct cfdriver vmepcc_cd;
extern phys_ram_seg_t mem_clusters[];
static int vme_pcc_attached;
void vme_pcc_intr_establish(void *, int, int, int, int,
int (*)(void *), void *, struct evcnt *);
void vme_pcc_intr_disestablish(void *, int, int, int, struct evcnt *);
static struct mvmebus_range vme_pcc_masters[] = {
{VME_AM_A24 |
MVMEBUS_AM_CAP_DATA | MVMEBUS_AM_CAP_PROG |
MVMEBUS_AM_CAP_SUPER | MVMEBUS_AM_CAP_USER,
VME_D32 | VME_D16 | VME_D8,
VME1_A24D32_LOC_START,
VME1_A24_MASK,
VME1_A24D32_START,
VME1_A24D32_END},
{VME_AM_A32 |
MVMEBUS_AM_CAP_DATA | MVMEBUS_AM_CAP_PROG |
MVMEBUS_AM_CAP_SUPER | MVMEBUS_AM_CAP_USER,
VME_D32 | VME_D16 | VME_D8,
VME1_A32D32_LOC_START,
VME1_A32_MASK,
VME1_A32D32_START,
VME1_A32D32_END},
{VME_AM_A24 |
MVMEBUS_AM_CAP_DATA | MVMEBUS_AM_CAP_PROG |
MVMEBUS_AM_CAP_SUPER | MVMEBUS_AM_CAP_USER,
VME_D16 | VME_D8,
VME1_A24D16_LOC_START,
VME1_A24_MASK,
VME1_A24D16_START,
VME1_A24D16_END},
{VME_AM_A32 |
MVMEBUS_AM_CAP_DATA | MVMEBUS_AM_CAP_PROG |
MVMEBUS_AM_CAP_SUPER | MVMEBUS_AM_CAP_USER,
VME_D16 | VME_D8,
VME1_A32D16_LOC_START,
VME1_A32_MASK,
VME1_A32D16_START,
VME1_A32D16_END},
{VME_AM_A16 |
MVMEBUS_AM_CAP_DATA |
MVMEBUS_AM_CAP_SUPER | MVMEBUS_AM_CAP_USER,
VME_D16 | VME_D8,
VME1_A16D16_LOC_START,
VME1_A16_MASK,
VME1_A16D16_START,
VME1_A16D16_END}
};
#define VME1_NMASTERS (sizeof(vme_pcc_masters)/sizeof(struct mvmebus_range))
/* ARGSUSED */
int
vme_pcc_match(device_t parent, cfdata_t cf, void *aux)
{
struct pcc_attach_args *pa;
pa = aux;
/* Only one VME chip, please. */
if (vme_pcc_attached)
return (0);
if (strcmp(pa->pa_name, vmepcc_cd.cd_name))
return (0);
return (1);
}
void
vme_pcc_attach(device_t parent, device_t self, void *aux)
{
struct pcc_attach_args *pa;
struct vme_pcc_softc *sc;
vme_am_t am;
uint8_t reg;
sc = device_private(self);
sc->sc_mvmebus.sc_dev = self;
pa = aux;
/* Map the VMEchip's registers */
bus_space_map(pa->pa_bust, pa->pa_offset, VME1REG_SIZE, 0,
&sc->sc_bush);
/* Initialise stuff used by the mvme68k common VMEbus front-end */
sc->sc_mvmebus.sc_bust = pa->pa_bust;
sc->sc_mvmebus.sc_dmat = pa->pa_dmat;
sc->sc_mvmebus.sc_chip = sc;
sc->sc_mvmebus.sc_nmasters = VME1_NMASTERS;
sc->sc_mvmebus.sc_masters = &vme_pcc_masters[0];
sc->sc_mvmebus.sc_nslaves = VME1_NSLAVES;
sc->sc_mvmebus.sc_slaves = &sc->sc_slave[0];
sc->sc_mvmebus.sc_intr_establish = vme_pcc_intr_establish;
sc->sc_mvmebus.sc_intr_disestablish = vme_pcc_intr_disestablish;
/* Initialize the chip. */
reg = vme1_reg_read(sc, VME1REG_SCON) & ~VME1_SCON_SYSFAIL;
vme1_reg_write(sc, VME1REG_SCON, reg);
printf(": Type 1 VMEchip, scon jumper %s\n",
(reg & VME1_SCON_SWITCH) ? "enabled" : "disabled");
/*
* Adjust the start address of the first range in vme_pcc_masters[]
* according to how much onboard memory exists. Disable the first
* range if onboard memory >= 16Mb, and adjust the start of the
* second range (A32D32).
*/
vme_pcc_masters[0].vr_vmestart = (vme_addr_t) mem_clusters[0].size;
if (mem_clusters[0].size >= 0x01000000) {
vme_pcc_masters[0].vr_am = MVMEBUS_AM_DISABLED;
vme_pcc_masters[1].vr_vmestart +=
(vme_addr_t) (mem_clusters[0].size - 0x01000000);
}
am = 0;
reg = vme1_reg_read(sc, VME1REG_SLADDRMOD);
if ((reg & VME1_SLMOD_DATA) != 0)
am |= MVMEBUS_AM_CAP_DATA;
if ((reg & VME1_SLMOD_PRGRM) != 0)
am |= MVMEBUS_AM_CAP_PROG;
if ((reg & VME1_SLMOD_SUPER) != 0)
am |= MVMEBUS_AM_CAP_SUPER;
if ((reg & VME1_SLMOD_USER) != 0)
am |= MVMEBUS_AM_CAP_USER;
if ((reg & VME1_SLMOD_BLOCK) != 0)
am |= MVMEBUS_AM_CAP_BLK;
#ifdef notyet
if ((reg & VME1_SLMOD_SHORT) != 0) {
sc->sc_slave[VME1_SLAVE_A16].vr_am = am | VME_AM_A16;
sc->sc_slave[VME1_SLAVE_A16].vr_mask = 0xffffu;
} else
#endif
sc->sc_slave[VME1_SLAVE_A16].vr_am = MVMEBUS_AM_DISABLED;
if (pcc_slave_base_addr < 0x01000000u && (reg & VME1_SLMOD_STND) != 0) {
sc->sc_slave[VME1_SLAVE_A24].vr_am = am | VME_AM_A24;
sc->sc_slave[VME1_SLAVE_A24].vr_datasize = VME_D32 |
VME_D16 | VME_D8;
sc->sc_slave[VME1_SLAVE_A24].vr_mask = 0xffffffu;
sc->sc_slave[VME1_SLAVE_A24].vr_locstart = 0;
sc->sc_slave[VME1_SLAVE_A24].vr_vmestart = pcc_slave_base_addr;
sc->sc_slave[VME1_SLAVE_A24].vr_vmeend = (pcc_slave_base_addr +
mem_clusters[0].size - 1) & 0x00ffffffu;
} else
sc->sc_slave[VME1_SLAVE_A24].vr_am = MVMEBUS_AM_DISABLED;
if ((reg & VME1_SLMOD_EXTED) != 0) {
sc->sc_slave[VME1_SLAVE_A32].vr_am = am | VME_AM_A32;
sc->sc_slave[VME1_SLAVE_A32].vr_datasize = VME_D32 |
VME_D16 | VME_D8;
sc->sc_slave[VME1_SLAVE_A32].vr_mask = 0xffffffffu;
sc->sc_slave[VME1_SLAVE_A32].vr_locstart = 0;
sc->sc_slave[VME1_SLAVE_A32].vr_vmestart = pcc_slave_base_addr;
sc->sc_slave[VME1_SLAVE_A32].vr_vmeend =
pcc_slave_base_addr + mem_clusters[0].size - 1;
} else
sc->sc_slave[VME1_SLAVE_A32].vr_am = MVMEBUS_AM_DISABLED;
vme_pcc_attached = 1;
mvmebus_attach(&sc->sc_mvmebus);
}
void
vme_pcc_intr_establish(void *csc, int prior, int level, int vector, int first, int (*func)(void *), void *arg, struct evcnt *evcnt)
{
struct vme_pcc_softc *sc = csc;
if (prior != level)
panic("vme_pcc_intr_establish: CPU priority != VMEbus irq level");
isrlink_vectored(func, arg, prior, vector, evcnt);
if (first) {
evcnt_attach_dynamic(evcnt, EVCNT_TYPE_INTR,
isrlink_evcnt(prior), device_xname(sc->sc_mvmebus.sc_dev),
mvmebus_irq_name[level]);
/*
* There had better not be another VMEbus master responding
* to this interrupt level...
*/
vme1_reg_write(sc, VME1REG_IRQEN,
vme1_reg_read(sc, VME1REG_IRQEN) | VME1_IRQ_VME(level));
}
}
void
vme_pcc_intr_disestablish(void *csc, int level, int vector, int last, struct evcnt *evcnt)
{
struct vme_pcc_softc *sc = csc;
isrunlink_vectored(vector);
if (last) {
vme1_reg_write(sc, VME1REG_IRQEN,
vme1_reg_read(sc, VME1REG_IRQEN) & ~VME1_IRQ_VME(level));
evcnt_detach(evcnt);
}
}
|