iomd_io.c revision 1.7 1 1.7 ryo /* $NetBSD: iomd_io.c,v 1.7 2018/03/16 17:56:31 ryo Exp $ */
2 1.1 reinoud
3 1.1 reinoud /*
4 1.1 reinoud * Copyright (c) 1997 Mark Brinicombe.
5 1.1 reinoud * Copyright (c) 1997 Causality Limited.
6 1.1 reinoud * All rights reserved.
7 1.1 reinoud *
8 1.1 reinoud * Redistribution and use in source and binary forms, with or without
9 1.1 reinoud * modification, are permitted provided that the following conditions
10 1.1 reinoud * are met:
11 1.1 reinoud * 1. Redistributions of source code must retain the above copyright
12 1.1 reinoud * notice, this list of conditions and the following disclaimer.
13 1.1 reinoud * 2. Redistributions in binary form must reproduce the above copyright
14 1.1 reinoud * notice, this list of conditions and the following disclaimer in the
15 1.1 reinoud * documentation and/or other materials provided with the distribution.
16 1.1 reinoud * 3. All advertising materials mentioning features or use of this software
17 1.1 reinoud * must display the following acknowledgement:
18 1.1 reinoud * This product includes software developed by Mark Brinicombe.
19 1.1 reinoud * 4. The name of the company nor the name of the author may be used to
20 1.1 reinoud * endorse or promote products derived from this software without specific
21 1.1 reinoud * prior written permission.
22 1.1 reinoud *
23 1.1 reinoud * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
24 1.1 reinoud * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25 1.1 reinoud * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 1.1 reinoud * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
27 1.1 reinoud * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 1.1 reinoud * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29 1.1 reinoud * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 1.1 reinoud * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 1.1 reinoud * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 1.1 reinoud * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 1.1 reinoud * SUCH DAMAGE.
34 1.1 reinoud */
35 1.1 reinoud
36 1.1 reinoud /*
37 1.1 reinoud * bus_space I/O functions for iomd
38 1.1 reinoud */
39 1.3 lukem
40 1.3 lukem #include <sys/cdefs.h>
41 1.7 ryo __KERNEL_RCSID(0, "$NetBSD: iomd_io.c,v 1.7 2018/03/16 17:56:31 ryo Exp $");
42 1.1 reinoud
43 1.1 reinoud #include <sys/param.h>
44 1.1 reinoud #include <sys/systm.h>
45 1.6 dyoung #include <sys/bus.h>
46 1.1 reinoud
47 1.1 reinoud /* Proto types for all the bus_space structure functions */
48 1.1 reinoud
49 1.1 reinoud bs_protos(iomd);
50 1.1 reinoud bs_protos(bs_notimpl);
51 1.1 reinoud
52 1.1 reinoud /* Declare the iomd bus space tag */
53 1.1 reinoud
54 1.1 reinoud struct bus_space iomd_bs_tag = {
55 1.1 reinoud /* cookie */
56 1.7 ryo .bs_cookie = NULL,
57 1.1 reinoud
58 1.1 reinoud /* mapping/unmapping */
59 1.7 ryo .bs_map = iomd_bs_map,
60 1.7 ryo .bs_unmap = iomd_bs_unmap,
61 1.7 ryo .bs_subregion = iomd_bs_subregion,
62 1.1 reinoud
63 1.1 reinoud /* allocation/deallocation */
64 1.7 ryo .bs_alloc = iomd_bs_alloc,
65 1.7 ryo .bs_free = iomd_bs_free,
66 1.1 reinoud
67 1.1 reinoud /* get kernel virtual address */
68 1.7 ryo .bs_vaddr = 0, /* there is no linear mapping */
69 1.1 reinoud
70 1.1 reinoud /* mmap bus space for userland */
71 1.7 ryo .bs_mmap = bs_notimpl_bs_mmap, /* XXX correct? XXX */
72 1.1 reinoud
73 1.1 reinoud /* barrier */
74 1.7 ryo .bs_barrier = iomd_bs_barrier,
75 1.1 reinoud
76 1.1 reinoud /* read (single) */
77 1.7 ryo .bs_r_1 = iomd_bs_r_1,
78 1.7 ryo .bs_r_2 = iomd_bs_r_2,
79 1.7 ryo .bs_r_4 = iomd_bs_r_4,
80 1.7 ryo .bs_r_8 = bs_notimpl_bs_r_8,
81 1.1 reinoud
82 1.1 reinoud /* read multiple */
83 1.7 ryo .bs_rm_1 = bs_notimpl_bs_rm_1,
84 1.7 ryo .bs_rm_2 = iomd_bs_rm_2,
85 1.7 ryo .bs_rm_4 = bs_notimpl_bs_rm_4,
86 1.7 ryo .bs_rm_8 = bs_notimpl_bs_rm_8,
87 1.1 reinoud
88 1.1 reinoud /* read region */
89 1.7 ryo .bs_rr_1 = bs_notimpl_bs_rr_1,
90 1.7 ryo .bs_rr_2 = bs_notimpl_bs_rr_2,
91 1.7 ryo .bs_rr_4 = bs_notimpl_bs_rr_4,
92 1.7 ryo .bs_rr_8 = bs_notimpl_bs_rr_8,
93 1.1 reinoud
94 1.1 reinoud /* write (single) */
95 1.7 ryo .bs_w_1 = iomd_bs_w_1,
96 1.7 ryo .bs_w_2 = iomd_bs_w_2,
97 1.7 ryo .bs_w_4 = iomd_bs_w_4,
98 1.7 ryo .bs_w_8 = bs_notimpl_bs_w_8,
99 1.1 reinoud
100 1.1 reinoud /* write multiple */
101 1.7 ryo .bs_wm_1 = bs_notimpl_bs_wm_1,
102 1.7 ryo .bs_wm_2 = iomd_bs_wm_2,
103 1.7 ryo .bs_wm_4 = bs_notimpl_bs_wm_4,
104 1.7 ryo .bs_wm_8 = bs_notimpl_bs_wm_8,
105 1.1 reinoud
106 1.1 reinoud /* write region */
107 1.7 ryo .bs_wr_1 = bs_notimpl_bs_wr_1,
108 1.7 ryo .bs_wr_2 = bs_notimpl_bs_wr_2,
109 1.7 ryo .bs_wr_4 = bs_notimpl_bs_wr_4,
110 1.7 ryo .bs_wr_8 = bs_notimpl_bs_wr_8,
111 1.1 reinoud
112 1.1 reinoud /* set multiple */
113 1.7 ryo .bs_sm_1 = bs_notimpl_bs_sm_1,
114 1.7 ryo .bs_sm_2 = bs_notimpl_bs_sm_2,
115 1.7 ryo .bs_sm_4 = bs_notimpl_bs_sm_4,
116 1.7 ryo .bs_sm_8 = bs_notimpl_bs_sm_8,
117 1.1 reinoud
118 1.1 reinoud /* set region */
119 1.7 ryo .bs_sr_1 = bs_notimpl_bs_sr_1,
120 1.7 ryo .bs_sr_2 = bs_notimpl_bs_sr_2,
121 1.7 ryo .bs_sr_4 = bs_notimpl_bs_sr_4,
122 1.7 ryo .bs_sr_8 = bs_notimpl_bs_sr_8,
123 1.1 reinoud
124 1.1 reinoud /* copy */
125 1.7 ryo .bs_c_1 = bs_notimpl_bs_c_1,
126 1.7 ryo .bs_c_2 = bs_notimpl_bs_c_2,
127 1.7 ryo .bs_c_4 = bs_notimpl_bs_c_4,
128 1.7 ryo .bs_c_8 = bs_notimpl_bs_c_8,
129 1.1 reinoud };
130 1.1 reinoud
131 1.1 reinoud /* bus space functions */
132 1.1 reinoud
133 1.1 reinoud int
134 1.5 bjh21 iomd_bs_map(void *t, bus_addr_t bpa, bus_size_t size, int cacheable,
135 1.5 bjh21 bus_space_handle_t *bshp)
136 1.1 reinoud {
137 1.5 bjh21
138 1.1 reinoud /*
139 1.1 reinoud * Temporary implementation as all I/O is already mapped etc.
140 1.1 reinoud *
141 1.1 reinoud * Eventually this function will do the mapping check for multiple maps
142 1.1 reinoud */
143 1.1 reinoud *bshp = bpa;
144 1.5 bjh21 return 0;
145 1.5 bjh21 }
146 1.1 reinoud
147 1.1 reinoud int
148 1.5 bjh21 iomd_bs_alloc(void *t, bus_addr_t rstart, bus_addr_t rend, bus_size_t size,
149 1.5 bjh21 bus_size_t alignment, bus_size_t boundary, int cacheable, bus_addr_t *bpap,
150 1.5 bjh21 bus_space_handle_t *bshp)
151 1.1 reinoud {
152 1.5 bjh21
153 1.2 provos panic("iomd_alloc(): Help!");
154 1.1 reinoud }
155 1.1 reinoud
156 1.1 reinoud
157 1.1 reinoud void
158 1.5 bjh21 iomd_bs_unmap(void *t, bus_space_handle_t bsh, bus_size_t size)
159 1.1 reinoud {
160 1.5 bjh21
161 1.1 reinoud /*
162 1.1 reinoud * Temporary implementation
163 1.1 reinoud */
164 1.1 reinoud }
165 1.1 reinoud
166 1.1 reinoud void
167 1.5 bjh21 iomd_bs_free(void *t, bus_space_handle_t bsh, bus_size_t size)
168 1.1 reinoud {
169 1.1 reinoud
170 1.2 provos panic("iomd_free(): Help!");
171 1.1 reinoud /* iomd_unmap() does all that we need to do. */
172 1.1 reinoud /* iomd_unmap(t, bsh, size);*/
173 1.1 reinoud }
174 1.1 reinoud
175 1.1 reinoud int
176 1.5 bjh21 iomd_bs_subregion(void *t, bus_space_handle_t bsh, bus_size_t offset,
177 1.5 bjh21 bus_size_t size, bus_space_handle_t *nbshp)
178 1.1 reinoud {
179 1.1 reinoud
180 1.1 reinoud *nbshp = bsh + (offset << 2);
181 1.5 bjh21 return 0;
182 1.1 reinoud }
183 1.1 reinoud
184 1.1 reinoud void
185 1.5 bjh21 iomd_bs_barrier(void *t, bus_space_handle_t bsh, bus_size_t offset,
186 1.5 bjh21 bus_size_t len, int flags)
187 1.1 reinoud {
188 1.5 bjh21
189 1.1 reinoud }
190 1.1 reinoud
191 1.1 reinoud /* End of iomd_io.c */
192