1 /* $NetBSD: becc_space.c,v 1.2.2.3 2004/09/21 13:13:42 skrll Exp $ */
4 * Copyright (c) 2001, 2002 Wasabi Systems, Inc.
7 * Written by Jason R. Thorpe for Wasabi Systems, Inc.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed for the NetBSD Project by
20 * Wasabi Systems, Inc.
21 * 4. The name of Wasabi Systems, Inc. may not be used to endorse
22 * or promote products derived from this software without specific prior
25 * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
29 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
39 * bus_space functions for the ADI Engineering Big Endian Companion Chip.
42 #include <sys/cdefs.h>
43 __KERNEL_RCSID(0, "$NetBSD: becc_space.c,v 1.2.2.3 2004/09/21 13:13:42 skrll Exp $");
45 #include <sys/param.h>
46 #include <sys/systm.h>
48 #include <uvm/uvm_extern.h>
50 #include <machine/bus.h>
52 #include <arm/xscale/beccreg.h>
53 #include <arm/xscale/beccvar.h>
55 /* Prototypes for all the bus_space structure functions */
60 bs_protos(bs_notimpl
);
63 * Template bus_space -- copied, and the bits that are NULL are
66 const struct bus_space becc_bs_tag_template
= {
70 /* mapping/unmapping */
75 /* allocation/deallocation */
79 /* get kernel virtual address */
144 becc_io_bs_init(bus_space_tag_t bs
, void *cookie
)
147 *bs
= becc_bs_tag_template
;
148 bs
->bs_cookie
= cookie
;
150 bs
->bs_map
= becc_io_bs_map
;
151 bs
->bs_unmap
= becc_io_bs_unmap
;
152 bs
->bs_alloc
= becc_io_bs_alloc
;
153 bs
->bs_free
= becc_io_bs_free
;
155 bs
->bs_vaddr
= becc_io_bs_vaddr
;
159 becc_mem_bs_init(bus_space_tag_t bs
, void *cookie
)
162 *bs
= becc_bs_tag_template
;
163 bs
->bs_cookie
= cookie
;
165 bs
->bs_map
= becc_mem_bs_map
;
166 bs
->bs_unmap
= becc_mem_bs_unmap
;
167 bs
->bs_alloc
= becc_mem_bs_alloc
;
168 bs
->bs_free
= becc_mem_bs_free
;
170 bs
->bs_mmap
= becc_mem_bs_mmap
;
173 /* *** Routines shared by becc, PCI IO, and PCI MEM. *** */
176 becc_bs_subregion(void *t
, bus_space_handle_t bsh
, bus_size_t offset
,
177 bus_size_t size
, bus_space_handle_t
*nbshp
)
180 *nbshp
= bsh
+ offset
;
185 becc_bs_barrier(void *t
, bus_space_handle_t bsh
, bus_size_t offset
,
186 bus_size_t len
, int flags
)
193 becc_bs_vaddr(void *t
, bus_space_handle_t bsh
)
196 return ((void *)bsh
);
200 becc_bs_mmap(void *t
, bus_addr_t addr
, off_t off
, int prot
, int flags
)
207 /* *** Routines for PCI IO. *** */
210 becc_io_bs_map(void *t
, bus_addr_t bpa
, bus_size_t size
, int flags
,
211 bus_space_handle_t
*bshp
)
213 struct becc_softc
*sc
= t
;
217 if (bpa
>= sc
->sc_ioout_xlate
&&
218 bpa
< (sc
->sc_ioout_xlate
+ (64 * 1024))) {
219 busbase
= sc
->sc_ioout_xlate
;
220 winvaddr
= sc
->sc_pci_io_base
;
224 if ((bpa
+ size
) >= (busbase
+ (64 * 1024)))
228 * Found the window -- PCI I/O space is mapped at a fixed
229 * virtual address by board-specific code. Translate the
230 * bus address to the virtual address.
232 *bshp
= winvaddr
+ (bpa
- busbase
);
238 becc_io_bs_unmap(void *t
, bus_space_handle_t bsh
, bus_size_t size
)
245 becc_io_bs_alloc(void *t
, bus_addr_t rstart
, bus_addr_t rend
,
246 bus_size_t size
, bus_size_t alignment
, bus_size_t boundary
, int flags
,
247 bus_addr_t
*bpap
, bus_space_handle_t
*bshp
)
250 panic("becc_io_bs_alloc(): not implemented\n");
254 becc_io_bs_free(void *t
, bus_space_handle_t bsh
, bus_size_t size
)
257 panic("becc_io_bs_free(): not implemented\n");
261 becc_io_bs_vaddr(void *t
, bus_space_handle_t bsh
)
268 /* *** Routines for PCI MEM. *** */
271 becc_mem_bs_map(void *t
, bus_addr_t bpa
, bus_size_t size
, int flags
,
272 bus_space_handle_t
*bshp
)
275 struct becc_softc
*sc
= t
;
280 * The two memory windows have been configured to the same
281 * PCI base by board-specific code, so we only need to look
285 if (bpa
>= sc
->sc_owin_xlate
[0] &&
286 bpa
< (sc
->sc_owin_xlate
[0] + BECC_PCI_MEM1_SIZE
)) {
287 busbase
= sc
->sc_owin_xlate
[0];
288 winvaddr
= sc
->sc_pci_mem_base
[0];
292 if ((bpa
+ size
) >= (busbase
+ BECC_PCI_MEM1_SIZE
))
296 * Found the window -- PCI MEM space is mapped at a fixed
297 * virtual address by board-specific code. Translate the
298 * bus address to the virtual address.
300 *bshp
= winvaddr
+ (bpa
- busbase
);
306 becc_mem_bs_unmap(void *t
, bus_space_handle_t bsh
, bus_size_t size
)
313 becc_mem_bs_alloc(void *t
, bus_addr_t rstart
, bus_addr_t rend
,
314 bus_size_t size
, bus_size_t alignment
, bus_size_t boundary
, int flags
,
315 bus_addr_t
*bpap
, bus_space_handle_t
*bshp
)
318 panic("becc_mem_bs_alloc(): not implemented\n");
322 becc_mem_bs_free(void *t
, bus_space_handle_t bsh
, bus_size_t size
)
325 panic("becc_mem_bs_free(): not implemented\n");
329 becc_mem_bs_mmap(void *t
, bus_addr_t addr
, off_t off
, int prot
, int flags
)