1191084Sgonzo/*      $NetBSD: bus.h,v 1.12 1997/10/01 08:25:15 fvdl Exp $    */
2191084Sgonzo/*-
3191084Sgonzo * $Id: bus.h,v 1.6 2007/08/09 11:23:32 katta Exp $
4191084Sgonzo *
5191084Sgonzo * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
6191084Sgonzo * All rights reserved.
7191084Sgonzo *
8191084Sgonzo * This code is derived from software contributed to The NetBSD Foundation
9191084Sgonzo * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
10191084Sgonzo * NASA Ames Research Center.
11191084Sgonzo *
12191084Sgonzo * Redistribution and use in source and binary forms, with or without
13191084Sgonzo * modification, are permitted provided that the following conditions
14191084Sgonzo * are met:
15191084Sgonzo * 1. Redistributions of source code must retain the above copyright
16191084Sgonzo *    notice, this list of conditions and the following disclaimer.
17191084Sgonzo * 2. Redistributions in binary form must reproduce the above copyright
18191084Sgonzo *    notice, this list of conditions and the following disclaimer in the
19191084Sgonzo *    documentation and/or other materials provided with the distribution.
20191084Sgonzo *
21191084Sgonzo * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
22191084Sgonzo * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23191084Sgonzo * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24191084Sgonzo * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
25191084Sgonzo * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26191084Sgonzo * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27191084Sgonzo * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28191084Sgonzo * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29191084Sgonzo * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30191084Sgonzo * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31191084Sgonzo * POSSIBILITY OF SUCH DAMAGE.
32191084Sgonzo */
33191084Sgonzo
34191084Sgonzo/*
35191084Sgonzo * Copyright (c) 1996 Charles M. Hannum.  All rights reserved.
36191084Sgonzo * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
37191084Sgonzo *
38191084Sgonzo * Redistribution and use in source and binary forms, with or without
39191084Sgonzo * modification, are permitted provided that the following conditions
40191084Sgonzo * are met:
41191084Sgonzo * 1. Redistributions of source code must retain the above copyright
42191084Sgonzo *    notice, this list of conditions and the following disclaimer.
43191084Sgonzo * 2. Redistributions in binary form must reproduce the above copyright
44191084Sgonzo *    notice, this list of conditions and the following disclaimer in the
45191084Sgonzo *    documentation and/or other materials provided with the distribution.
46191084Sgonzo * 3. All advertising materials mentioning features or use of this software
47191084Sgonzo *    must display the following acknowledgement:
48191084Sgonzo *      This product includes software developed by Christopher G. Demetriou
49191084Sgonzo *	for the NetBSD Project.
50191084Sgonzo * 4. The name of the author may not be used to endorse or promote products
51191084Sgonzo *    derived from this software without specific prior written permission
52191084Sgonzo *
53191084Sgonzo * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
54191084Sgonzo * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
55191084Sgonzo * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
56191084Sgonzo * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
57191084Sgonzo * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
58191084Sgonzo * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
59191084Sgonzo * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
60191084Sgonzo * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
61191084Sgonzo * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
62191084Sgonzo * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
63191084Sgonzo *
64191084Sgonzo *	from: src/sys/alpha/include/bus.h,v 1.5 1999/08/28 00:38:40 peter
65191084Sgonzo * $FreeBSD$
66191084Sgonzo */
67191084Sgonzo#include <sys/cdefs.h>
68191084Sgonzo__FBSDID("$FreeBSD$");
69191084Sgonzo
70191084Sgonzo#include <sys/param.h>
71191084Sgonzo#include <sys/systm.h>
72191084Sgonzo#include <sys/bus.h>
73191084Sgonzo#include <sys/kernel.h>
74191084Sgonzo#include <sys/malloc.h>
75191084Sgonzo#include <sys/ktr.h>
76191084Sgonzo
77191084Sgonzo#include <vm/vm.h>
78191084Sgonzo#include <vm/pmap.h>
79191084Sgonzo#include <vm/vm_kern.h>
80191084Sgonzo#include <vm/vm_extern.h>
81191084Sgonzo
82191084Sgonzo#include <machine/bus.h>
83191084Sgonzo#include <machine/cache.h>
84191084Sgonzo
85245332Srwatsonstatic int	fdt_bs_map(void *, bus_addr_t, bus_size_t, int,
86245332Srwatson		    bus_space_handle_t *);
87245332Srwatson
88245332Srwatsonstatic struct bus_space fdt_space = {
89191084Sgonzo	/* cookie */
90250420Sbz	.bs_cookie =	(void *) 0,
91191084Sgonzo
92191084Sgonzo	/* mapping/unmapping */
93250420Sbz	.bs_map =	fdt_bs_map,
94250420Sbz	.bs_unmap =	generic_bs_unmap,
95250420Sbz	.bs_subregion =	generic_bs_subregion,
96191084Sgonzo
97191084Sgonzo	/* allocation/deallocation */
98250420Sbz	.bs_alloc =	generic_bs_alloc,
99250420Sbz	.bs_free =	generic_bs_free,
100191084Sgonzo
101191084Sgonzo	/* barrier */
102250420Sbz	.bs_barrier =	generic_bs_barrier,
103191084Sgonzo
104191084Sgonzo	/* read (single) */
105250420Sbz	.bs_r_1 =	generic_bs_r_1,
106250420Sbz	.bs_r_2 =	generic_bs_r_2,
107250420Sbz	.bs_r_4 =	generic_bs_r_4,
108250420Sbz	.bs_r_8 =	generic_bs_r_8,
109191084Sgonzo
110191084Sgonzo	/* read multiple */
111250420Sbz	.bs_rm_1 =	generic_bs_rm_1,
112250420Sbz	.bs_rm_2 =	generic_bs_rm_2,
113250420Sbz	.bs_rm_4 =	generic_bs_rm_4,
114250420Sbz	.bs_rm_8 =	generic_bs_rm_8,
115191084Sgonzo
116191084Sgonzo	/* read region */
117250420Sbz	.bs_rr_1 =	generic_bs_rr_1,
118250420Sbz	.bs_rr_2 =	generic_bs_rr_2,
119250420Sbz	.bs_rr_4 =	generic_bs_rr_4,
120250420Sbz	.bs_rr_8 =	generic_bs_rr_8,
121191084Sgonzo
122191084Sgonzo	/* write (single) */
123250420Sbz	.bs_w_1 =	generic_bs_w_1,
124250420Sbz	.bs_w_2 =	generic_bs_w_2,
125250420Sbz	.bs_w_4 =	generic_bs_w_4,
126250420Sbz	.bs_w_8 =	generic_bs_w_8,
127191084Sgonzo
128191084Sgonzo	/* write multiple */
129250420Sbz	.bs_wm_1 =	generic_bs_wm_1,
130250420Sbz	.bs_wm_2 =	generic_bs_wm_2,
131250420Sbz	.bs_wm_4 =	generic_bs_wm_4,
132250420Sbz	.bs_wm_8 =	generic_bs_wm_8,
133191084Sgonzo
134191084Sgonzo	/* write region */
135250420Sbz	.bs_wr_1 =	generic_bs_wr_1,
136250420Sbz	.bs_wr_2 =	generic_bs_wr_2,
137250420Sbz	.bs_wr_4 =	generic_bs_wr_4,
138250420Sbz	.bs_wr_8 =	generic_bs_wr_8,
139191084Sgonzo
140191084Sgonzo	/* set multiple */
141250420Sbz	.bs_sm_1 =	generic_bs_sm_1,
142250420Sbz	.bs_sm_2 =	generic_bs_sm_2,
143250420Sbz	.bs_sm_4 =	generic_bs_sm_4,
144250420Sbz	.bs_sm_8 =	generic_bs_sm_8,
145191084Sgonzo
146191084Sgonzo	/* set region */
147250420Sbz	.bs_sr_1 =	generic_bs_sr_1,
148250420Sbz	.bs_sr_2 =	generic_bs_sr_2,
149250420Sbz	.bs_sr_4 =	generic_bs_sr_4,
150250420Sbz	.bs_sr_8 =	generic_bs_sr_8,
151191084Sgonzo
152191084Sgonzo	/* copy */
153250420Sbz	.bs_c_1 =	generic_bs_c_1,
154250420Sbz	.bs_c_2 =	generic_bs_c_2,
155250420Sbz	.bs_c_4 =	generic_bs_c_4,
156250420Sbz	.bs_c_8 =	generic_bs_c_8,
157191084Sgonzo
158191084Sgonzo	/* read (single) stream */
159250420Sbz	.bs_r_1_s =	generic_bs_r_1,
160250420Sbz	.bs_r_2_s =	generic_bs_r_2,
161250420Sbz	.bs_r_4_s =	generic_bs_r_4,
162250420Sbz	.bs_r_8_s =	generic_bs_r_8,
163191084Sgonzo
164191084Sgonzo	/* read multiple stream */
165250420Sbz	.bs_rm_1_s =	generic_bs_rm_1,
166250420Sbz	.bs_rm_2_s =	generic_bs_rm_2,
167250420Sbz	.bs_rm_4_s =	generic_bs_rm_4,
168250420Sbz	.bs_rm_8_s =	generic_bs_rm_8,
169191084Sgonzo
170191084Sgonzo	/* read region stream */
171250420Sbz	.bs_rr_1_s =	generic_bs_rr_1,
172250420Sbz	.bs_rr_2_s =	generic_bs_rr_2,
173250420Sbz	.bs_rr_4_s =	generic_bs_rr_4,
174250420Sbz	.bs_rr_8_s =	generic_bs_rr_8,
175191084Sgonzo
176191084Sgonzo	/* write (single) stream */
177250420Sbz	.bs_w_1_s =	generic_bs_w_1,
178250420Sbz	.bs_w_2_s =	generic_bs_w_2,
179250420Sbz	.bs_w_4_s =	generic_bs_w_4,
180250420Sbz	.bs_w_8_s =	generic_bs_w_8,
181191084Sgonzo
182191084Sgonzo	/* write multiple stream */
183250420Sbz	.bs_wm_1_s =	generic_bs_wm_1,
184250420Sbz	.bs_wm_2_s =	generic_bs_wm_2,
185250420Sbz	.bs_wm_4_s =	generic_bs_wm_4,
186250420Sbz	.bs_wm_8_s =	generic_bs_wm_8,
187191084Sgonzo
188191084Sgonzo	/* write region stream */
189250420Sbz	.bs_wr_1_s =	generic_bs_wr_1,
190250420Sbz	.bs_wr_2_s =	generic_bs_wr_2,
191250420Sbz	.bs_wr_4_s =	generic_bs_wr_4,
192250420Sbz	.bs_wr_8_s =	generic_bs_wr_8,
193191084Sgonzo};
194191084Sgonzo
195191282Sgonzo/* generic bus_space tag */
196245332Srwatsonbus_space_tag_t	mips_bus_space_fdt = &fdt_space;
197191084Sgonzo
198245332Srwatsonstatic int
199245332Srwatsonfdt_bs_map(void *t __unused, bus_addr_t addr, bus_size_t size __unused,
200245332Srwatson    int flags __unused, bus_space_handle_t *bshp)
201191084Sgonzo{
202191084Sgonzo
203245332Srwatson	*bshp = MIPS_PHYS_TO_DIRECT_UNCACHED(addr);
204191084Sgonzo	return (0);
205191084Sgonzo}
206