No empty .Rs/.Re
[netbsd-mini2440.git] / sys / arch / arm / xscale / becc_space.c
blob41cfa03dd1e06af5c61adeca242d86c26c287e6b
1 /* $NetBSD: becc_space.c,v 1.2.2.3 2004/09/21 13:13:42 skrll Exp $ */
3 /*
4 * Copyright (c) 2001, 2002 Wasabi Systems, Inc.
5 * All rights reserved.
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
11 * are met:
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
23 * written permission.
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 */
56 bs_protos(becc);
57 bs_protos(becc_io);
58 bs_protos(becc_mem);
59 bs_protos(becc_pci);
60 bs_protos(bs_notimpl);
63 * Template bus_space -- copied, and the bits that are NULL are
64 * filled in.
66 const struct bus_space becc_bs_tag_template = {
67 /* cookie */
68 (void *) 0,
70 /* mapping/unmapping */
71 NULL,
72 NULL,
73 becc_bs_subregion,
75 /* allocation/deallocation */
76 NULL,
77 NULL,
79 /* get kernel virtual address */
80 becc_bs_vaddr,
82 /* mmap */
83 becc_bs_mmap,
85 /* barrier */
86 becc_bs_barrier,
88 /* read (single) */
89 becc_pci_bs_r_1,
90 becc_pci_bs_r_2,
91 becc_pci_bs_r_4,
92 bs_notimpl_bs_r_8,
94 /* read multiple */
95 bs_notimpl_bs_rm_1,
96 bs_notimpl_bs_rm_2,
97 bs_notimpl_bs_rm_4,
98 bs_notimpl_bs_rm_8,
100 /* read region */
101 bs_notimpl_bs_rr_1,
102 bs_notimpl_bs_rr_2,
103 bs_notimpl_bs_rr_4,
104 bs_notimpl_bs_rr_8,
106 /* write (single) */
107 becc_pci_bs_w_1,
108 becc_pci_bs_w_2,
109 becc_pci_bs_w_4,
110 bs_notimpl_bs_w_8,
112 /* write multiple */
113 bs_notimpl_bs_wm_1,
114 bs_notimpl_bs_wm_2,
115 bs_notimpl_bs_wm_4,
116 bs_notimpl_bs_wm_8,
118 /* write region */
119 bs_notimpl_bs_wr_1,
120 bs_notimpl_bs_wr_2,
121 bs_notimpl_bs_wr_4,
122 bs_notimpl_bs_wr_8,
124 /* set multiple */
125 bs_notimpl_bs_sm_1,
126 bs_notimpl_bs_sm_2,
127 bs_notimpl_bs_sm_4,
128 bs_notimpl_bs_sm_8,
130 /* set region */
131 bs_notimpl_bs_sr_1,
132 bs_notimpl_bs_sr_2,
133 bs_notimpl_bs_sr_4,
134 bs_notimpl_bs_sr_8,
136 /* copy */
137 bs_notimpl_bs_c_1,
138 bs_notimpl_bs_c_2,
139 bs_notimpl_bs_c_4,
140 bs_notimpl_bs_c_8,
143 void
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;
158 void
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;
181 return (0);
184 void
185 becc_bs_barrier(void *t, bus_space_handle_t bsh, bus_size_t offset,
186 bus_size_t len, int flags)
189 /* Nothing to do. */
192 void *
193 becc_bs_vaddr(void *t, bus_space_handle_t bsh)
196 return ((void *)bsh);
199 paddr_t
200 becc_bs_mmap(void *t, bus_addr_t addr, off_t off, int prot, int flags)
203 /* Not supported. */
204 return (-1);
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;
214 vaddr_t winvaddr;
215 uint32_t busbase;
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;
221 } else
222 return (EINVAL);
224 if ((bpa + size) >= (busbase + (64 * 1024)))
225 return (EINVAL);
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);
234 return (0);
237 void
238 becc_io_bs_unmap(void *t, bus_space_handle_t bsh, bus_size_t size)
241 /* Nothing to do. */
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");
253 void
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");
260 void *
261 becc_io_bs_vaddr(void *t, bus_space_handle_t bsh)
264 /* Not supported. */
265 return (NULL);
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;
276 vaddr_t winvaddr;
277 uint32_t busbase;
280 * The two memory windows have been configured to the same
281 * PCI base by board-specific code, so we only need to look
282 * at the first one.
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];
289 } else
290 return (EINVAL);
292 if ((bpa + size) >= (busbase + BECC_PCI_MEM1_SIZE))
293 return (EINVAL);
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);
302 return (0);
305 void
306 becc_mem_bs_unmap(void *t, bus_space_handle_t bsh, bus_size_t size)
309 /* Nothing to do. */
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");
321 void
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");
328 paddr_t
329 becc_mem_bs_mmap(void *t, bus_addr_t addr, off_t off, int prot, int flags)
332 /* XXX */
333 return (-1);