Annotation of sys/arch/arm/xscale/pxa2x0_space.c, Revision 1.1.1.1
1.1 nbrk 1: /* $OpenBSD: pxa2x0_space.c,v 1.3 2005/07/18 02:43:24 fgsch Exp $ */
2: /* $NetBSD: pxa2x0_space.c,v 1.5 2004/06/07 19:45:22 nathanw Exp $ */
3:
4: /*
5: * Copyright (c) 2001, 2002 Wasabi Systems, Inc.
6: * All rights reserved.
7: *
8: * Written by Jason R. Thorpe for Wasabi Systems, Inc.
9: *
10: * Redistribution and use in source and binary forms, with or without
11: * modification, are permitted provided that the following conditions
12: * are met:
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.
18: * 3. All advertising materials mentioning features or use of this software
19: * must display the following acknowledgement:
20: * This product includes software developed for the NetBSD Project by
21: * Wasabi Systems, Inc.
22: * 4. The name of Wasabi Systems, Inc. may not be used to endorse
23: * or promote products derived from this software without specific prior
24: * written permission.
25: *
26: * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
27: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28: * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
30: * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36: * POSSIBILITY OF SUCH DAMAGE.
37: */
38: /*
39: * Copyright (c) 1997 Mark Brinicombe.
40: * Copyright (c) 1997 Causality Limited.
41: * All rights reserved.
42: *
43: * This code is derived from software contributed to The NetBSD Foundation
44: * by Ichiro FUKUHARA.
45: *
46: * Redistribution and use in source and binary forms, with or without
47: * modification, are permitted provided that the following conditions
48: * are met:
49: * 1. Redistributions of source code must retain the above copyright
50: * notice, this list of conditions and the following disclaimer.
51: * 2. Redistributions in binary form must reproduce the above copyright
52: * notice, this list of conditions and the following disclaimer in the
53: * documentation and/or other materials provided with the distribution.
54: * 3. All advertising materials mentioning features or use of this software
55: * must display the following acknowledgement:
56: * This product includes software developed by Mark Brinicombe.
57: * 4. The name of the company nor the name of the author may be used to
58: * endorse or promote products derived from this software without specific
59: * prior written permission.
60: *
61: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
62: * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
63: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
64: * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
65: * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
66: * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
67: * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
68: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
69: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
70: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
71: * SUCH DAMAGE.
72: */
73:
74: /*
75: * bus_space functions for Intel PXA2[51]0 application processor.
76: * Derived from i80321_space.c.
77: */
78:
79: #include <sys/cdefs.h>
80: /*
81: __KERNEL_RCSID(0, "$NetBSD: pxa2x0_space.c,v 1.5 2004/06/07 19:45:22 nathanw Exp $");
82: */
83:
84: #include <sys/param.h>
85: #include <sys/systm.h>
86:
87: #include <uvm/uvm_extern.h>
88:
89: #include <machine/bus.h>
90:
91: /* Prototypes for all the bus_space structure functions */
92: bs_protos(pxa2x0);
93: bs_protos(generic);
94: bs_protos(generic_armv4);
95: bs_protos(bs_notimpl);
96:
97: struct bus_space pxa2x0_bs_tag = {
98: /* cookie */
99: (void *) 0,
100:
101: /* mapping/unmapping */
102: pxa2x0_bs_map,
103: pxa2x0_bs_unmap,
104: pxa2x0_bs_subregion,
105:
106: /* allocation/deallocation */
107: pxa2x0_bs_alloc, /* not implemented */
108: pxa2x0_bs_free, /* not implemented */
109:
110: /* get kernel virtual address */
111: pxa2x0_bs_vaddr,
112:
113: /* mmap */
114: bs_notimpl_bs_mmap,
115:
116: /* barrier */
117: pxa2x0_bs_barrier,
118:
119: /* read (single) */
120: generic_bs_r_1,
121: generic_armv4_bs_r_2,
122: generic_bs_r_4,
123: bs_notimpl_bs_r_8,
124:
125: /* read multiple */
126: generic_bs_rm_1,
127: generic_armv4_bs_rm_2,
128: generic_bs_rm_4,
129: bs_notimpl_bs_rm_8,
130:
131: /* read region */
132: generic_bs_rr_1,
133: generic_armv4_bs_rr_2,
134: generic_bs_rr_4,
135: bs_notimpl_bs_rr_8,
136:
137: /* write (single) */
138: generic_bs_w_1,
139: generic_armv4_bs_w_2,
140: generic_bs_w_4,
141: bs_notimpl_bs_w_8,
142:
143: /* write multiple */
144: generic_bs_wm_1,
145: generic_armv4_bs_wm_2,
146: generic_bs_wm_4,
147: bs_notimpl_bs_wm_8,
148:
149: /* write region */
150: generic_bs_wr_1,
151: generic_armv4_bs_wr_2,
152: generic_bs_wr_4,
153: bs_notimpl_bs_wr_8,
154:
155: /* set multiple */
156: bs_notimpl_bs_sm_1,
157: bs_notimpl_bs_sm_2,
158: bs_notimpl_bs_sm_4,
159: bs_notimpl_bs_sm_8,
160:
161: /* set region */
162: generic_bs_sr_1,
163: generic_armv4_bs_sr_2,
164: bs_notimpl_bs_sr_4,
165: bs_notimpl_bs_sr_8,
166:
167: /* copy */
168: bs_notimpl_bs_c_1,
169: generic_armv4_bs_c_2,
170: bs_notimpl_bs_c_4,
171: bs_notimpl_bs_c_8,
172: };
173:
174: int
175: pxa2x0_bs_map(void *t, bus_addr_t bpa, bus_size_t size,
176: int flag, bus_space_handle_t *bshp)
177: {
178: u_long startpa, endpa, pa;
179: vaddr_t va;
180: pt_entry_t *pte;
181:
182: if ((u_long)bpa > (u_long)KERNEL_BASE) {
183: /* Some IO registers (ex. UART ports for console)
184: are mapped to fixed address by board specific
185: routine. */
186: *bshp = bpa;
187: return(0);
188: }
189:
190: startpa = trunc_page(bpa);
191: endpa = round_page(bpa + size);
192:
193: /* XXX use extent manager to check duplicate mapping */
194:
195: va = uvm_km_valloc(kernel_map, endpa - startpa);
196: if (! va)
197: return(ENOMEM);
198:
199: *bshp = (bus_space_handle_t)(va + (bpa - startpa));
200:
201: for (pa = startpa; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) {
202: pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE);
203: if ((flag & BUS_SPACE_MAP_CACHEABLE) == 0) {
204: pte = vtopte(va);
205: *pte &= ~L2_S_CACHE_MASK;
206: PTE_SYNC(pte);
207: /* XXX: pmap_kenter_pa() also does PTE_SYNC(). a bit of
208: * waste.
209: */
210: }
211: }
212: pmap_update(pmap_kernel());
213:
214: return(0);
215: }
216:
217: void
218: pxa2x0_bs_unmap(void *t, bus_space_handle_t bsh, bus_size_t size)
219: {
220:
221: if (bsh > (u_long)KERNEL_BASE)
222: return;
223:
224: uvm_km_free(kernel_map, bsh, size);
225: }
226:
227:
228: int
229: pxa2x0_bs_subregion(void *t, bus_space_handle_t bsh, bus_size_t offset,
230: bus_size_t size, bus_space_handle_t *nbshp)
231: {
232:
233: *nbshp = bsh + offset;
234: return (0);
235: }
236:
237: void
238: pxa2x0_bs_barrier(void *t, bus_space_handle_t bsh, bus_size_t offset,
239: bus_size_t len, int flags)
240: {
241:
242: /* Nothing to do. */
243: }
244:
245: void *
246: pxa2x0_bs_vaddr(void *t, bus_space_handle_t bsh)
247: {
248:
249: return ((void *)bsh);
250: }
251:
252:
253: int
254: pxa2x0_bs_alloc(void *t, bus_addr_t rstart, bus_addr_t rend,
255: bus_size_t size, bus_size_t alignment, bus_size_t boundary, int flags,
256: bus_addr_t *bpap, bus_space_handle_t *bshp)
257: {
258:
259: panic("pxa2x0_io_bs_alloc(): not implemented");
260: }
261:
262: void
263: pxa2x0_bs_free(void *t, bus_space_handle_t bsh, bus_size_t size)
264: {
265:
266: panic("pxa2x0_io_bs_free(): not implemented");
267: }
268:
CVSweb