]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - sys/arm/xscale/i80321/i80321_space.c
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / sys / arm / xscale / i80321 / i80321_space.c
1 /*      $NetBSD: i80321_space.c,v 1.6 2003/10/06 15:43:35 thorpej Exp $ */
2
3 /*-
4  * Copyright (c) 2001, 2002 Wasabi Systems, Inc.
5  * All rights reserved.
6  *
7  * Written by Jason R. Thorpe for Wasabi Systems, Inc.
8  *
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.
24  *
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.
36  */
37
38 /*
39  * bus_space functions for i80321 I/O Processor.
40  */
41
42 #include <sys/cdefs.h>
43 __FBSDID("$FreeBSD$");
44
45 #include <sys/param.h>
46 #include <sys/systm.h>
47 #include <sys/bus.h>
48
49 #include <machine/pcb.h>
50
51 #include <vm/vm.h>
52 #include <vm/vm_kern.h>
53 #include <vm/pmap.h>
54 #include <vm/vm_page.h>
55 #include <vm/vm_extern.h>
56
57 #include <machine/bus.h>
58
59 #include <arm/xscale/i80321/i80321reg.h>
60 #include <arm/xscale/i80321/i80321var.h>
61
62 /* Prototypes for all the bus_space structure functions */
63 bs_protos(i80321);
64 bs_protos(i80321_io);
65 bs_protos(i80321_mem);
66
67 void
68 i80321_bs_init(bus_space_tag_t bs, void *cookie)
69 {
70
71         *bs = *arm_base_bs_tag;
72         bs->bs_privdata = cookie;
73 }
74
75 void
76 i80321_io_bs_init(bus_space_tag_t bs, void *cookie)
77 {
78
79         *bs = *arm_base_bs_tag;
80         bs->bs_privdata = cookie;
81
82         bs->bs_map = i80321_io_bs_map;
83         bs->bs_unmap = i80321_io_bs_unmap;
84         bs->bs_alloc = i80321_io_bs_alloc;
85         bs->bs_free = i80321_io_bs_free;
86
87 }
88
89 void
90 i80321_mem_bs_init(bus_space_tag_t bs, void *cookie)
91 {
92
93         *bs = *arm_base_bs_tag;
94         bs->bs_privdata = cookie;
95
96         bs->bs_map = i80321_mem_bs_map;
97         bs->bs_unmap = i80321_mem_bs_unmap;
98         bs->bs_alloc = i80321_mem_bs_alloc;
99         bs->bs_free = i80321_mem_bs_free;
100
101 }
102
103 /* *** Routines shared by i80321, PCI IO, and PCI MEM. *** */
104
105 int
106 i80321_bs_subregion(bus_space_tag_t tag, bus_space_handle_t bsh, bus_size_t offset,
107     bus_size_t size, bus_space_handle_t *nbshp)
108 {
109
110         *nbshp = bsh + offset;
111         return (0);
112 }
113
114 void
115 i80321_bs_barrier(bus_space_tag_t tag, bus_space_handle_t bsh, bus_size_t offset,
116     bus_size_t len, int flags)
117 {
118
119         /* Nothing to do. */
120 }
121
122 /* *** Routines for PCI IO. *** */
123
124 extern struct i80321_softc *i80321_softc;
125 int
126 i80321_io_bs_map(bus_space_tag_t tag, bus_addr_t bpa, bus_size_t size, int flags,
127     bus_space_handle_t *bshp)
128 {
129         struct i80321_softc *sc = i80321_softc;
130         vm_offset_t winvaddr;
131         uint32_t busbase;
132
133         if (bpa >= sc->sc_ioout_xlate &&
134             bpa < (sc->sc_ioout_xlate + VERDE_OUT_XLATE_IO_WIN_SIZE)) {
135                 busbase = sc->sc_ioout_xlate;
136                 winvaddr = sc->sc_iow_vaddr;
137         } else
138                 return (EINVAL);
139
140         if ((bpa + size) >= (busbase + VERDE_OUT_XLATE_IO_WIN_SIZE))
141                 return (EINVAL);
142
143         /*
144          * Found the window -- PCI I/O space is mapped at a fixed
145          * virtual address by board-specific code.  Translate the
146          * bus address to the virtual address.
147          */
148         *bshp = winvaddr + (bpa - busbase);
149
150         return (0);
151 }
152
153 void
154 i80321_io_bs_unmap(bus_space_tag_t tag, bus_space_handle_t h, bus_size_t size)
155 {
156
157         /* Nothing to do. */
158 }
159
160 int
161 i80321_io_bs_alloc(bus_space_tag_t tag, bus_addr_t rstart, bus_addr_t rend,
162     bus_size_t size, bus_size_t alignment, bus_size_t boundary, int flags,
163     bus_addr_t *bpap, bus_space_handle_t *bshp)
164 {
165
166         panic("i80321_io_bs_alloc(): not implemented");
167 }
168
169 void
170 i80321_io_bs_free(bus_space_tag_t tag, bus_space_handle_t bsh, bus_size_t size)
171 {
172
173         panic("i80321_io_bs_free(): not implemented");
174 }
175
176
177 /* *** Routines for PCI MEM. *** */
178 extern int badaddr_read(void *, int, void *);
179 int
180 i80321_mem_bs_map(bus_space_tag_t tag, bus_addr_t bpa, bus_size_t size, int flags,
181     bus_space_handle_t *bshp)
182 {
183
184         *bshp = (vm_offset_t)pmap_mapdev(bpa, size);
185         return (0);
186 }
187
188 void
189 i80321_mem_bs_unmap(bus_space_tag_t tag, bus_space_handle_t h, bus_size_t size)
190 {
191
192         pmap_unmapdev((vm_offset_t)h, size);
193 }
194
195 int
196 i80321_mem_bs_alloc(bus_space_tag_t tag, bus_addr_t rstart, bus_addr_t rend,
197     bus_size_t size, bus_size_t alignment, bus_size_t boundary, int flags,
198     bus_addr_t *bpap, bus_space_handle_t *bshp)
199 {
200
201         panic("i80321_mem_bs_alloc(): not implemented");
202 }
203
204 void
205 i80321_mem_bs_free(bus_space_tag_t tag, bus_space_handle_t bsh, bus_size_t size)
206 {
207
208         panic("i80321_mem_bs_free(): not implemented");
209 }