1 /* $NetBSD: xel.c,v 1.16 2008/12/18 05:56:42 isaki Exp $ */
4 * Copyright (c) 1998 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
33 * TSR Xellent30 driver.
34 * Detect Xellent30, and reserve its I/O area.
37 #include <sys/cdefs.h>
38 __KERNEL_RCSID(0, "$NetBSD: xel.c,v 1.16 2008/12/18 05:56:42 isaki Exp $");
40 #include <sys/param.h>
41 #include <sys/systm.h>
42 #include <sys/kernel.h>
43 #include <sys/device.h>
45 #include <machine/cpu.h>
46 #include <machine/bus.h>
48 #include <arch/x68k/dev/intiovar.h>
50 static paddr_t
xel_addr(device_t
, cfdata_t
, struct intio_attach_args
*);
51 static int xel_probe(paddr_t
);
52 static int xel_match(device_t
, cfdata_t
, void *);
53 static void xel_attach(device_t
, device_t
, void *);
56 bus_space_tag_t sc_bst
;
57 bus_space_handle_t sc_bh
;
60 CFATTACH_DECL_NEW(xel
, sizeof(struct xel_softc
),
61 xel_match
, xel_attach
, NULL
, NULL
);
63 static paddr_t xel_addrs
[] = { 0xec0000, 0xec4000, 0xec8000, 0xecc000 };
65 #define XEL_MODE_RAM_LOWER 0x00
66 #define XEL_MODE_RAM_HIGHER 0x01
67 #define XEL_MODE_UNMAP_RAM 0x00
68 #define XEL_MODE_MAP_RAM 0x02
69 #define XEL_MODE_MPU_000 0x00
70 #define XEL_MODE_MPU_030 0x04
72 #define XEL_RAM_ADDR_LOWER 0xbc0000
73 #define XEL_RAM_ADDR_HIGHER 0xfc0000
77 xel_addr(device_t parent
, cfdata_t match
, struct intio_attach_args
*ia
)
81 if (match
->cf_addr
== INTIOCF_ADDR_DEFAULT
) {
84 for (i
= 0; i
< sizeof(xel_addrs
)/sizeof(xel_addrs
[0]); i
++) {
85 if (xel_probe(xel_addrs
[i
])) {
91 if (xel_probe((paddr_t
) match
->cf_addr
))
92 addr
= (paddr_t
) match
->cf_addr
;
97 ia
->ia_addr
= (int) addr
;
99 if (intio_map_allocate_region(parent
, ia
, INTIO_MAP_TESTONLY
)
112 xel_probe(paddr_t addr
)
115 volatile u_int16_t
*start
= (volatile u_int16_t
*)IIOV(addr
);
117 volatile u_int32_t
*sram
= (volatile u_int32_t
*)IIOV(XEL_RAM_ADDR_HIGHER
);
122 nofault
= (int *) &faultbuf
;
123 if (setjmp(&faultbuf
)) {
130 /* Try to map the Xellent local memory. */
131 start
[0] = XEL_MODE_RAM_HIGHER
| XEL_MODE_MAP_RAM
| XEL_MODE_MPU_030
;
134 /* the contents should be deferent. */
135 if (b1
== sram
[0] && b2
== sram
[1]) {
140 /* Try to write to the local memory. */
141 sram
[0] = 0x55555555;
142 sram
[1] = 0xaaaaaaaa;
143 if (sram
[0] != 0x55555555 || sram
[1] != 0xaaaaaaaa) {
149 sram
[0] = 0xaaaaaaaa;
150 sram
[1] = 0x55555555;
151 if (sram
[0] != 0xaaaaaaaa || sram
[1] != 0x55555555) {
162 start
[0] = XEL_MODE_UNMAP_RAM
| XEL_MODE_MPU_030
;
169 xel_match(device_t parent
, cfdata_t match
, void *aux
)
171 struct intio_attach_args
*ia
= aux
;
173 if (strcmp(ia
->ia_name
, "xel") != 0)
176 if (xel_addr(parent
, match
, ia
)) {
178 if (cputype
!= CPU_68030
)
179 panic("Non-030 Xellent???");
187 xel_attach(device_t parent
, device_t self
, void *aux
)
189 struct xel_softc
*sc
= device_private(self
);
190 struct intio_attach_args
*ia
= aux
;
191 cfdata_t cf
= device_cfdata(self
);
195 addr
= xel_addr(parent
, cf
, aux
);
196 sc
->sc_bst
= ia
->ia_bst
;
197 ia
->ia_addr
= (int) addr
;
198 ia
->ia_size
= 0x4000;
199 r
= intio_map_allocate_region(parent
, ia
, INTIO_MAP_ALLOCATE
);
202 panic("IO map for Xellent30 corruption??");
204 aprint_normal(": Xellent30 MPU Accelerator.\n");