xref: /netbsd-src/sys/arch/arm/gemini/gemini_a4x_space.c (revision 509197b672d5cd748873877ad33419fadde87740)
1*509197b6Sryo /*	$NetBSD: gemini_a4x_space.c,v 1.3 2018/03/16 17:56:31 ryo Exp $	*/
2f5d7ce3dSmatt 
3f5d7ce3dSmatt /* adapted from:
4f5d7ce3dSmatt  *	NetBSD: pxa2x0_a4x_space.c,v 1.4 2006/07/28 08:15:29 simonb Exp
5f5d7ce3dSmatt  */
6f5d7ce3dSmatt 
7f5d7ce3dSmatt /*
8f5d7ce3dSmatt  * Copyright (c) 2002  Genetec Corporation.  All rights reserved.
9f5d7ce3dSmatt  * Written by Hiroyuki Bessho for Genetec Corporation.
10f5d7ce3dSmatt  *
11f5d7ce3dSmatt  * Redistribution and use in source and binary forms, with or without
12f5d7ce3dSmatt  * modification, are permitted provided that the following conditions
13f5d7ce3dSmatt  * are met:
14f5d7ce3dSmatt  * 1. Redistributions of source code must retain the above copyright
15f5d7ce3dSmatt  *    notice, this list of conditions and the following disclaimer.
16f5d7ce3dSmatt  * 2. Redistributions in binary form must reproduce the above copyright
17f5d7ce3dSmatt  *    notice, this list of conditions and the following disclaimer in the
18f5d7ce3dSmatt  *    documentation and/or other materials provided with the distribution.
19f5d7ce3dSmatt  * 3. All advertising materials mentioning features or use of this software
20f5d7ce3dSmatt  *    must display the following acknowledgement:
21f5d7ce3dSmatt  *	This product includes software developed for the NetBSD Project by
22f5d7ce3dSmatt  *	Genetec Corporation.
23f5d7ce3dSmatt  * 4. The name of Genetec Corporation may not be used to endorse or
24f5d7ce3dSmatt  *    promote products derived from this software without specific prior
25f5d7ce3dSmatt  *    written permission.
26f5d7ce3dSmatt  *
27f5d7ce3dSmatt  * THIS SOFTWARE IS PROVIDED BY GENETEC CORPORATION ``AS IS'' AND
28f5d7ce3dSmatt  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29f5d7ce3dSmatt  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30f5d7ce3dSmatt  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL GENETEC CORPORATION
31f5d7ce3dSmatt  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32f5d7ce3dSmatt  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33f5d7ce3dSmatt  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34f5d7ce3dSmatt  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35f5d7ce3dSmatt  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36f5d7ce3dSmatt  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37f5d7ce3dSmatt  * POSSIBILITY OF SUCH DAMAGE.
38f5d7ce3dSmatt  */
39f5d7ce3dSmatt 
40f5d7ce3dSmatt /*
41f5d7ce3dSmatt  * Bus space tag for 8/16-bit devices on 32-bit bus.
42f5d7ce3dSmatt  * all registers are located at the address of multiple of 4.
43f5d7ce3dSmatt  */
44f5d7ce3dSmatt 
45f5d7ce3dSmatt #include <sys/cdefs.h>
46*509197b6Sryo __KERNEL_RCSID(0, "$NetBSD: gemini_a4x_space.c,v 1.3 2018/03/16 17:56:31 ryo Exp $");
47f5d7ce3dSmatt 
48f5d7ce3dSmatt #include <sys/param.h>
49f5d7ce3dSmatt #include <sys/systm.h>
50f5d7ce3dSmatt 
51f5d7ce3dSmatt #include <uvm/uvm_extern.h>
52f5d7ce3dSmatt 
53cf10107dSdyoung #include <sys/bus.h>
54f5d7ce3dSmatt 
55f5d7ce3dSmatt /* Prototypes for all the bus_space structure functions */
56f5d7ce3dSmatt bs_protos(gemini);
57f5d7ce3dSmatt bs_protos(a4x);
58f5d7ce3dSmatt bs_protos(generic);
59f5d7ce3dSmatt bs_protos(generic_armv4);
60f5d7ce3dSmatt bs_protos(bs_notimpl);
61f5d7ce3dSmatt 
62f5d7ce3dSmatt struct bus_space gemini_a4x_bs_tag = {
63f5d7ce3dSmatt 	/* cookie */
64*509197b6Sryo 	.bs_cookie = (void *) 0,
65f5d7ce3dSmatt 
66f5d7ce3dSmatt 	/* mapping/unmapping */
67*509197b6Sryo 	.bs_map = gemini_bs_map,
68*509197b6Sryo 	.bs_unmap = gemini_bs_unmap,
69*509197b6Sryo 	.bs_subregion = gemini_bs_subregion,
70f5d7ce3dSmatt 
71f5d7ce3dSmatt 	/* allocation/deallocation */
72*509197b6Sryo 	.bs_alloc = gemini_bs_alloc,	/* not implemented */
73*509197b6Sryo 	.bs_free = gemini_bs_free,	/* not implemented */
74f5d7ce3dSmatt 
75f5d7ce3dSmatt 	/* get kernel virtual address */
76*509197b6Sryo 	.bs_vaddr = gemini_bs_vaddr,
77f5d7ce3dSmatt 
78f5d7ce3dSmatt 	/* mmap */
79*509197b6Sryo 	.bs_mmap = bs_notimpl_bs_mmap,
80f5d7ce3dSmatt 
81f5d7ce3dSmatt 	/* barrier */
82*509197b6Sryo 	.bs_barrier = gemini_bs_barrier,
83f5d7ce3dSmatt 
84f5d7ce3dSmatt 	/* read (single) */
85*509197b6Sryo 	.bs_r_1 = a4x_bs_r_1,
86*509197b6Sryo 	.bs_r_2 = a4x_bs_r_2,
87*509197b6Sryo 	.bs_r_4 = a4x_bs_r_4,
88*509197b6Sryo 	.bs_r_8 = bs_notimpl_bs_r_8,
89f5d7ce3dSmatt 
90f5d7ce3dSmatt 	/* read multiple */
91*509197b6Sryo 	.bs_rm_1 = a4x_bs_rm_1,
92*509197b6Sryo 	.bs_rm_2 = a4x_bs_rm_2,
93*509197b6Sryo 	.bs_rm_4 = bs_notimpl_bs_rm_4,
94*509197b6Sryo 	.bs_rm_8 = bs_notimpl_bs_rm_8,
95f5d7ce3dSmatt 
96f5d7ce3dSmatt 	/* read region */
97*509197b6Sryo 	.bs_rr_1 = bs_notimpl_bs_rr_1,
98*509197b6Sryo 	.bs_rr_2 = bs_notimpl_bs_rr_2,
99*509197b6Sryo 	.bs_rr_4 = bs_notimpl_bs_rr_4,
100*509197b6Sryo 	.bs_rr_8 = bs_notimpl_bs_rr_8,
101f5d7ce3dSmatt 
102f5d7ce3dSmatt 	/* write (single) */
103*509197b6Sryo 	.bs_w_1 = a4x_bs_w_1,
104*509197b6Sryo 	.bs_w_2 = a4x_bs_w_2,
105*509197b6Sryo 	.bs_w_4 = a4x_bs_w_4,
106*509197b6Sryo 	.bs_w_8 = bs_notimpl_bs_w_8,
107f5d7ce3dSmatt 
108f5d7ce3dSmatt 	/* write multiple */
109*509197b6Sryo 	.bs_wm_1 = a4x_bs_wm_1,
110*509197b6Sryo 	.bs_wm_2 = a4x_bs_wm_2,
111*509197b6Sryo 	.bs_wm_4 = bs_notimpl_bs_wm_4,
112*509197b6Sryo 	.bs_wm_8 = bs_notimpl_bs_wm_8,
113f5d7ce3dSmatt 
114f5d7ce3dSmatt 	/* write region */
115*509197b6Sryo 	.bs_wr_1 = bs_notimpl_bs_wr_1,
116*509197b6Sryo 	.bs_wr_2 = bs_notimpl_bs_wr_2,
117*509197b6Sryo 	.bs_wr_4 = bs_notimpl_bs_wr_4,
118*509197b6Sryo 	.bs_wr_8 = bs_notimpl_bs_wr_8,
119f5d7ce3dSmatt 
120f5d7ce3dSmatt 	/* set multiple */
121*509197b6Sryo 	.bs_sm_1 = bs_notimpl_bs_sm_1,
122*509197b6Sryo 	.bs_sm_2 = bs_notimpl_bs_sm_2,
123*509197b6Sryo 	.bs_sm_4 = bs_notimpl_bs_sm_4,
124*509197b6Sryo 	.bs_sm_8 = bs_notimpl_bs_sm_8,
125f5d7ce3dSmatt 
126f5d7ce3dSmatt 	/* set region */
127*509197b6Sryo 	.bs_sr_1 = bs_notimpl_bs_sr_1,
128*509197b6Sryo 	.bs_sr_2 = bs_notimpl_bs_sr_2,
129*509197b6Sryo 	.bs_sr_4 = bs_notimpl_bs_sr_4,
130*509197b6Sryo 	.bs_sr_8 = bs_notimpl_bs_sr_8,
131f5d7ce3dSmatt 
132f5d7ce3dSmatt 	/* copy */
133*509197b6Sryo 	.bs_c_1 = bs_notimpl_bs_c_1,
134*509197b6Sryo 	.bs_c_2 = bs_notimpl_bs_c_2,
135*509197b6Sryo 	.bs_c_4 = bs_notimpl_bs_c_4,
136*509197b6Sryo 	.bs_c_8 = bs_notimpl_bs_c_8,
137f5d7ce3dSmatt };
138