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