1 /* $NetBSD: rsbus_io.c,v 1.1.4.3 2004/09/21 13:11:27 skrll Exp $ */
4 * Copyright (c) 1997 Mark Brinicombe.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Mark Brinicombe.
18 * 4. The name of the company nor the name of the author may be used to
19 * endorse or promote products derived from this software without specific
20 * prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
23 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
26 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * bus_space I/O functions for rsbus
39 #include <sys/cdefs.h>
40 __KERNEL_RCSID(0, "$NetBSD: rsbus_io.c,v 1.1.4.3 2004/09/21 13:11:27 skrll Exp $");
42 #include <sys/param.h>
43 #include <sys/systm.h>
44 #include <machine/bus.h>
46 /* Proto types for all the bus_space structure functions */
49 bs_protos(bs_notimpl
);
52 /* Declare the rsbus bus space tag */
53 struct bus_space rsbus_bs_tag
= {
55 (void *) 2, /* Shift to apply to registers */
57 /* mapping/unmapping */
62 /* allocation/deallocation */
66 /* get kernel virtual address */
67 0, /* there is no linear mapping */
69 /* mmap bus space for userland */
130 /* bus space functions */
132 /* Rough-and-ready implementations from arm26 */
134 rsbus_bs_rr_1(void *cookie
, bus_space_handle_t bsh
,
135 bus_size_t offset
, u_int8_t
*datap
, bus_size_t count
)
139 for (i
= 0; i
< count
; i
++)
140 datap
[i
] = rsbus_bs_r_1(cookie
, bsh
, offset
+ i
);
144 rsbus_bs_rr_2(void *cookie
, bus_space_handle_t bsh
,
145 bus_size_t offset
, u_int16_t
*datap
, bus_size_t count
)
149 for (i
= 0; i
< count
; i
++)
150 datap
[i
] = rsbus_bs_r_2(cookie
, bsh
, offset
+ i
);
154 rsbus_bs_wr_1(void *cookie
, bus_space_handle_t bsh
,
155 bus_size_t offset
, u_int8_t
const *datap
,
160 for (i
= 0; i
< count
; i
++)
161 rsbus_bs_w_1(cookie
, bsh
, offset
+ i
, datap
[i
]);
165 rsbus_bs_wr_2(void *cookie
, bus_space_handle_t bsh
,
166 bus_size_t offset
, u_int16_t
const *datap
,
171 for (i
= 0; i
< count
; i
++)
172 rsbus_bs_w_2(cookie
, bsh
, offset
+ i
, datap
[i
]);
176 rsbus_bs_sr_1(void *cookie
, bus_space_handle_t bsh
,
177 bus_size_t offset
, u_int8_t value
, bus_size_t count
)
181 for (i
= 0; i
< count
; i
++)
182 rsbus_bs_w_1(cookie
, bsh
, offset
+ i
, value
);
186 rsbus_bs_sr_2(void *cookie
, bus_space_handle_t bsh
,
187 bus_size_t offset
, u_int16_t value
, bus_size_t count
)
191 for (i
= 0; i
< count
; i
++)
192 rsbus_bs_w_2(cookie
, bsh
, offset
+ i
, value
);