xref: /netbsd/sys/arch/sh3/include/bus_funcs.h (revision f5d9a1e6)
1*f5d9a1e6Sdyoung /*	$NetBSD: bus_funcs.h,v 1.4 2011/07/25 21:12:23 dyoung Exp $	*/
2e57d534eSdyoung 
3e57d534eSdyoung /*-
4e57d534eSdyoung  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
5e57d534eSdyoung  * All rights reserved.
6e57d534eSdyoung  *
7e57d534eSdyoung  * This code is derived from software contributed to The NetBSD Foundation
8e57d534eSdyoung  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9e57d534eSdyoung  * NASA Ames Research Center.
10e57d534eSdyoung  *
11e57d534eSdyoung  * Redistribution and use in source and binary forms, with or without
12e57d534eSdyoung  * modification, are permitted provided that the following conditions
13e57d534eSdyoung  * are met:
14e57d534eSdyoung  * 1. Redistributions of source code must retain the above copyright
15e57d534eSdyoung  *    notice, this list of conditions and the following disclaimer.
16e57d534eSdyoung  * 2. Redistributions in binary form must reproduce the above copyright
17e57d534eSdyoung  *    notice, this list of conditions and the following disclaimer in the
18e57d534eSdyoung  *    documentation and/or other materials provided with the distribution.
19e57d534eSdyoung  *
20e57d534eSdyoung  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21e57d534eSdyoung  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22e57d534eSdyoung  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23e57d534eSdyoung  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24e57d534eSdyoung  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25e57d534eSdyoung  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26e57d534eSdyoung  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27e57d534eSdyoung  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28e57d534eSdyoung  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29e57d534eSdyoung  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30e57d534eSdyoung  * POSSIBILITY OF SUCH DAMAGE.
31e57d534eSdyoung  */
32e57d534eSdyoung 
33e57d534eSdyoung /*
34e57d534eSdyoung  * Copyright (c) 1996 Charles M. Hannum.  All rights reserved.
35e57d534eSdyoung  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
36e57d534eSdyoung  *
37e57d534eSdyoung  * Redistribution and use in source and binary forms, with or without
38e57d534eSdyoung  * modification, are permitted provided that the following conditions
39e57d534eSdyoung  * are met:
40e57d534eSdyoung  * 1. Redistributions of source code must retain the above copyright
41e57d534eSdyoung  *    notice, this list of conditions and the following disclaimer.
42e57d534eSdyoung  * 2. Redistributions in binary form must reproduce the above copyright
43e57d534eSdyoung  *    notice, this list of conditions and the following disclaimer in the
44e57d534eSdyoung  *    documentation and/or other materials provided with the distribution.
45e57d534eSdyoung  * 3. All advertising materials mentioning features or use of this software
46e57d534eSdyoung  *    must display the following acknowledgement:
47e57d534eSdyoung  *      This product includes software developed by Christopher G. Demetriou
48e57d534eSdyoung  *	for the NetBSD Project.
49e57d534eSdyoung  * 4. The name of the author may not be used to endorse or promote products
50e57d534eSdyoung  *    derived from this software without specific prior written permission
51e57d534eSdyoung  *
52e57d534eSdyoung  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
53e57d534eSdyoung  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
54e57d534eSdyoung  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
55e57d534eSdyoung  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
56e57d534eSdyoung  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
57e57d534eSdyoung  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
58e57d534eSdyoung  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
59e57d534eSdyoung  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
60e57d534eSdyoung  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
61e57d534eSdyoung  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
62e57d534eSdyoung  */
63e57d534eSdyoung 
64e57d534eSdyoung #ifndef _SH3_BUS_FUNCS_H_
65e57d534eSdyoung #define	_SH3_BUS_FUNCS_H_
66e57d534eSdyoung 
67e57d534eSdyoung #ifdef SH4_PCMCIA
68e57d534eSdyoung int shpcmcia_memio_map(bus_space_tag_t, bus_addr_t, bus_size_t size,
69e57d534eSdyoung     int, bus_space_handle_t *);
70e57d534eSdyoung 
71e57d534eSdyoung int shpcmcia_mem_add_mapping(bus_addr_t, bus_size_t, int,
72e57d534eSdyoung     bus_space_handle_t *);
73e57d534eSdyoung void shpcmcia_memio_unmap(bus_space_tag_t, bus_space_handle_t,
74e57d534eSdyoung     bus_size_t);
75e57d534eSdyoung void shpcmcia_memio_free(bus_space_tag_t, bus_space_handle_t,
76e57d534eSdyoung     bus_size_t);
77e57d534eSdyoung int shpcmcia_memio_subregion(bus_space_tag_t, bus_space_handle_t,
78e57d534eSdyoung     bus_size_t, bus_size_t, bus_space_handle_t *);
79e57d534eSdyoung #endif
80e57d534eSdyoung 
81b80e6406Sdyoung int sh_memio_alloc(bus_space_tag_t, bus_addr_t, bus_addr_t, bus_size_t,
82b80e6406Sdyoung     bus_size_t, bus_size_t, int, bus_addr_t *, bus_space_handle_t *);
83b80e6406Sdyoung void sh_memio_free(bus_space_tag_t, bus_space_handle_t, bus_size_t);
84b80e6406Sdyoung void sh_memio_unmap(bus_space_tag_t, bus_space_handle_t, bus_size_t);
85b80e6406Sdyoung int sh_memio_subregion(bus_space_tag_t, bus_space_handle_t,
86b80e6406Sdyoung     bus_size_t, bus_size_t, bus_space_handle_t *);
87b80e6406Sdyoung 
88e57d534eSdyoung /*
89*f5d9a1e6Sdyoung  *	int bus_space_alloc(bus_space_tag_t t, bus_addr_t rstart,
90*f5d9a1e6Sdyoung  *	    bus_addr_t rend, bus_size_t size, bus_size_t align,
91*f5d9a1e6Sdyoung  *	    bus_size_t boundary, int flags, bus_addr_t *addrp,
92*f5d9a1e6Sdyoung  *	    bus_space_handle_t *bshp);
93*f5d9a1e6Sdyoung  *
94*f5d9a1e6Sdyoung  * Allocate a region of bus space.
95*f5d9a1e6Sdyoung  */
96*f5d9a1e6Sdyoung 
97*f5d9a1e6Sdyoung #define	bus_space_alloc(t, rs, re, s, a, b, f, ap, hp)			\
98*f5d9a1e6Sdyoung 	sh_memio_alloc((t), (rs), (re), (s), (a), (b), (f), (ap), (hp))
99*f5d9a1e6Sdyoung 
100*f5d9a1e6Sdyoung /*
101*f5d9a1e6Sdyoung  *	int bus_space_free(bus_space_tag_t t,
102*f5d9a1e6Sdyoung  *	    bus_space_handle_t bsh, bus_size_t size);
103*f5d9a1e6Sdyoung  *
104*f5d9a1e6Sdyoung  * Free a region of bus space.
105*f5d9a1e6Sdyoung  */
106*f5d9a1e6Sdyoung 
107*f5d9a1e6Sdyoung #define	bus_space_free(t, h, s)						\
108*f5d9a1e6Sdyoung 	sh_memio_free((t), (h), (s))
109*f5d9a1e6Sdyoung 
110*f5d9a1e6Sdyoung /*
111*f5d9a1e6Sdyoung  *	int bus_space_unmap(bus_space_tag_t t,
112*f5d9a1e6Sdyoung  *	    bus_space_handle_t bsh, bus_size_t size);
113*f5d9a1e6Sdyoung  *
114*f5d9a1e6Sdyoung  * Unmap a region of bus space.
115*f5d9a1e6Sdyoung  */
116*f5d9a1e6Sdyoung 
117*f5d9a1e6Sdyoung #define	bus_space_unmap(t, h, s)					\
118*f5d9a1e6Sdyoung 	sh_memio_unmap((t), (h), (s))
119*f5d9a1e6Sdyoung 
120*f5d9a1e6Sdyoung /*
121*f5d9a1e6Sdyoung  *	int bus_space_subregion(bus_space_tag_t t,
122*f5d9a1e6Sdyoung  *	    bus_space_handle_t bsh, bus_size_t offset, bus_size_t size,
123*f5d9a1e6Sdyoung  *	    bus_space_handle_t *nbshp);
124*f5d9a1e6Sdyoung  *
125*f5d9a1e6Sdyoung  * Get a new handle for a subregion of an already-mapped area of bus space.
126*f5d9a1e6Sdyoung  */
127*f5d9a1e6Sdyoung 
128*f5d9a1e6Sdyoung #define	bus_space_subregion(t, h, o, s, nhp)				\
129*f5d9a1e6Sdyoung 	sh_memio_subregion((t), (h), (o), (s), (nhp))
130*f5d9a1e6Sdyoung 
131*f5d9a1e6Sdyoung /*
132e57d534eSdyoung  * Bus read/write barrier methods.
133e57d534eSdyoung  *
134e57d534eSdyoung  *	void bus_space_barrier(bus_space_tag_t tag,
135e57d534eSdyoung  *	    bus_space_handle_t bsh, bus_size_t offset,
136e57d534eSdyoung  *	    bus_size_t len, int flags);
137e57d534eSdyoung  *
138e57d534eSdyoung  * Note: the sh3 does not currently require barriers, but we must
139e57d534eSdyoung  * provide the flags to MI code.
140e57d534eSdyoung  */
141e57d534eSdyoung #define	bus_space_barrier(t, h, o, l, f)	\
142e57d534eSdyoung 	((void)((void)(t), (void)(h), (void)(o), (void)(l), (void)(f)))
143e57d534eSdyoung 
144e57d534eSdyoung #endif /* _SH3_BUS_FUNCS_H_ */
145