xref: /openbsd/sys/arch/mips64/include/loongson2.h (revision 404b540a)
1 /*	$OpenBSD: loongson2.h,v 1.1 2009/08/06 21:11:38 miod Exp $	*/
2 
3 /*
4  * Copyright (c) 2009 Miodrag Vallat.
5  *
6  * Permission to use, copy, modify, and distribute this software for any
7  * purpose with or without fee is hereby granted, provided that the above
8  * copyright notice and this permission notice appear in all copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 #ifndef	_MACHINE_LOONGSON2_H_
20 #define	_MACHINE_LOONGSON2_H_
21 
22 /*
23  * Loongson 2E/2F specific defines
24  */
25 
26 /*
27  * Address Window registers physical addresses
28  *
29  * The Loongson 2F processor has an AXI crossbar with four possible bus
30  * masters, each one having four programmable address windows.
31  *
32  * Each window is defined with three 64-bit registers:
33  * - a base address register, defining the address in the master address
34  *   space (base register).
35  * - an address mask register, defining which address bits are valid in this
36  *   window.  A given address matches a window if (addr & mask) == base.
37  * - the location of the window base in the target, as well at the target
38  *   number itself (mmap register). The lower 20 bits of the address are
39  *   forced as zeroes regardless of their value in this register.
40  *   The translated address is thus (addr & ~mask) | (mmap & ~0xfffff).
41  */
42 
43 #define	LOONGSON_AWR_BASE_ADDRESS	0x3ff00000
44 
45 #define	LOONGSON_AWR_BASE(master, window) \
46 	(LOONGSON_AWR_BASE_ADDRESS + (window) * 0x08 + (master) * 0x60 + 0x00)
47 #define	LOONGSON_AWR_SIZE(master, window) \
48 	(LOONGSON_AWR_BASE_ADDRESS + (window) * 0x08 + (master) * 0x60 + 0x20)
49 #define	LOONGSON_AWR_MMAP(master, window) \
50 	(LOONGSON_AWR_BASE_ADDRESS + (window) * 0x08 + (master) * 0x60 + 0x40)
51 
52 /*
53  * Bits in the diagnostic register
54  */
55 
56 #define	COP_0_DIAG_ITLB_CLEAR		0x04
57 #define	COP_0_DIAG_BTB_CLEAR		0x02
58 #define	COP_0_DIAG_RAS_CLEAR		0x01
59 
60 #endif	/* _MACHINE_LOONGSON2_H_ */
61