xref: /netbsd-src/sys/arch/mips/ralink/ralink_bus.c (revision aec6f0cf2ee0e8ce1a23f9d46109cdee745ca66f)
1 /*	$NetBSD: ralink_bus.c,v 1.4 2022/09/29 07:00:47 skrll Exp $	*/
2 /*-
3  * Copyright (c) 2011 CradlePoint Technology, Inc.
4  * All rights reserved.
5  *
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
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  *
16  * THIS SOFTWARE IS PROVIDED BY CRADLEPOINT TECHNOLOGY, INC. AND CONTRIBUTORS
17  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
20  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26  * POSSIBILITY OF SUCH DAMAGE.
27  */
28 /*
29  * Copyright (c) 2006 Urbana-Champaign Independent Media Center.
30  * Copyright (c) 2006 Garrett D'Amore.
31  * All rights reserved.
32  *
33  * This code was written by Garrett D'Amore for the Champaign-Urbana
34  * Community Wireless Network Project.
35  *
36  * Redistribution and use in source and binary forms, with or
37  * without modification, are permitted provided that the following
38  * conditions are met:
39  * 1. Redistributions of source code must retain the above copyright
40  *    notice, this list of conditions and the following disclaimer.
41  * 2. Redistributions in binary form must reproduce the above
42  *    copyright notice, this list of conditions and the following
43  *    disclaimer in the documentation and/or other materials provided
44  *    with the distribution.
45  * 3. All advertising materials mentioning features or use of this
46  *    software must display the following acknowledgements:
47  *      This product includes software developed by the Urbana-Champaign
48  *      Independent Media Center.
49  *	This product includes software developed by Garrett D'Amore.
50  * 4. Urbana-Champaign Independent Media Center's name and Garrett
51  *    D'Amore's name may not be used to endorse or promote products
52  *    derived from this software without specific prior written permission.
53  *
54  * THIS SOFTWARE IS PROVIDED BY THE URBANA-CHAMPAIGN INDEPENDENT
55  * MEDIA CENTER AND GARRETT D'AMORE ``AS IS'' AND ANY EXPRESS OR
56  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
57  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
58  * ARE DISCLAIMED.  IN NO EVENT SHALL THE URBANA-CHAMPAIGN INDEPENDENT
59  * MEDIA CENTER OR GARRETT D'AMORE BE LIABLE FOR ANY DIRECT, INDIRECT,
60  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
63  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
64  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
66  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
67  */
68 
69 #include "locators.h"
70 
71 #include <sys/cdefs.h>
72 __KERNEL_RCSID(0, "$NetBSD: ralink_bus.c,v 1.4 2022/09/29 07:00:47 skrll Exp $");
73 #define	_MIPS_BUS_DMA_PRIVATE
74 
75 #include <sys/param.h>
76 #include <sys/bus.h>
77 #include <sys/device.h>
78 #include <sys/extent.h>
79 #include <sys/systm.h>
80 
81 #include <mips/ralink/ralink_reg.h>
82 #include <mips/ralink/ralink_var.h>
83 
84 static void ra_bus_bus_mem_init(bus_space_tag_t, void *);
85 
86 struct mips_bus_space	ra_bus_memt;
87 struct mips_bus_dma_tag	ra_bus_dmat = {
88 	._dmamap_ops = _BUS_DMAMAP_OPS_INITIALIZER,
89 	._dmamem_ops = _BUS_DMAMEM_OPS_INITIALIZER,
90 	._dmatag_ops = _BUS_DMATAG_OPS_INITIALIZER,
91 };
92 
93 const bus_space_handle_t ra_sysctl_bsh =
94     (bus_space_handle_t) RA_IOREG_VADDR(RA_SYSCTL_BASE, 0);
95 
96 void
ra_bus_init(void)97 ra_bus_init(void)
98 {
99 	ra_bus_bus_mem_init(&ra_bus_memt, NULL);
100 #ifdef DIAGNOSTIC
101 	bus_space_handle_t bsh = 0xdeadfa11;
102 	bus_space_map(&ra_bus_memt, RA_SYSCTL_BASE, 0x100, 0, &bsh);
103 	KASSERT(ra_sysctl_bsh == bsh);
104 #endif
105 }
106 
107 /*
108  * CPU memory/register stuff
109  *  defines ra_bus_bus_mem_init, which encompasses all of memory
110  */
111 
112 #define CHIP			ra_bus
113 #define CHIP_MEM		/* defined */
114 #define CHIP_W1_BUS_START(v)	0x00000000UL
115 #define CHIP_W1_BUS_END(v)	0x1fffffffUL
116 #define CHIP_W1_SYS_START(v)	CHIP_W1_BUS_START(v)
117 #define CHIP_W1_SYS_END(v)	CHIP_W1_BUS_END(v)
118 
119 #include <mips/mips/bus_space_alignstride_chipdep.c>
120