1 /* $Id$
2  *
3  * This file is subject to the terms and conditions of the GNU General Public
4  * License.  See the file "COPYING" in the main directory of this archive
5  * for more details.
6  *
7  * Copyright (C) 1992-1997,2000-2003 Silicon Graphics, Inc. All Rights Reserved.
8  */
9 #ifndef _ASM_SN_XTALK_XTALKADDRS_H
10 #define _ASM_SN_XTALK_XTALKADDRS_H
11 
12 
13 /*
14  * CrossTalk to SN0 Hub addressing support
15  *
16  * This file defines the mapping conventions used by the Hub's
17  * I/O interface when it receives a read or write request from
18  * a CrossTalk widget.
19  *
20  * Format for non-Memory accesses:
21  *
22  *  +--------------+------------------------------------------------+
23  *  | 0  | XXXXX   |        SN0Addr                                |
24  *  +----+---------+------------------------------------------------+
25  *    47  46     40 39                                             0
26  *	bit 47 indicates Memory (0)
27  *	bits 46..40 are unused
28  *	bits 39..0 hold the memory address
29  *			(bits 39..31 hold the nodeID in N mode
30  *			 bits 39..32 hold the nodeID in M mode
31  * By design, this looks exactly like a 0-extended SN0 Address, so
32  * we don't need to do any conversions.
33  *
34  *
35  *
36  * Format for non-Memory accesses:
37  *
38  *  +--------------+------+---------+------+--+---------------------+
39  *  | 1  | DstNode | XXXX | BigW=0  | SW=1 | 1|   Addr              |
40  *  +----+---------+------+---------+------+--+---------------------+
41  *    47  46     38 37  31 30     28 27  24 23 22                  0
42  *
43  *	bit 47 indicates IO (1)
44  *      bits 46..38 hold the destination node ID
45  *      bits 37..31 are unused
46  *      bits 30..28 hold the big window being addressed
47  *      bits 27..24 hold the small window being addressed
48  *                  0 always refers to the xbow
49  *                  1 always refers to the hub itself
50  *      bit 23 indicates local (0) or remote (1)
51  *             no accessing checks are done if this bit is 0
52  *      bits 22..0 hold the register address
53  *                 bits 22..21 determine which section of the hub
54  *                              00 -> PI
55  *                              01 -> MD
56  *                              10 -> IO
57  *                              11 -> NI
58  * This looks very much like a REMOTE_HUB access, except the nodeID
59  * is in a different place, and the highest xtalk bit is set.
60  */
61 /* Hub-specific xtalk definitions */
62 
63 #define HX_MEM_BIT		0L	/* Hub's idea of xtalk memory access */
64 #define HX_IO_BIT		1L	/* Hub's idea of xtalk register access */
65 #define HX_ACCTYPE_SHIFT	47
66 
67 #define HX_NODE_SHIFT		39
68 
69 #define HX_BIGWIN_SHIFT		28
70 #define HX_SWIN_SHIFT		23
71 
72 #define HX_LOCACC		0L	/* local access */
73 #define HX_REMACC		1L	/* remote access */
74 #define HX_ACCESS_SHIFT		23
75 
76 /*
77  * Pre-calculate the fixed portion of a crosstalk address that maps
78  * to local register space on a hub.
79  */
80 #define HX_REG_BASE		((HX_IO_BIT<<HX_ACCTYPE_SHIFT) + \
81 				(0L<<HX_BIGWIN_SHIFT) + \
82 				(1L<<HX_SWIN_SHIFT) + IALIAS_SIZE + \
83 				(HX_REMACC<<HX_ACCESS_SHIFT))
84 
85 /*
86  * Return a crosstalk address which a widget can use to access a
87  * designated register on a designated node.
88  */
89 #define HUBREG_AS_XTALKADDR(nasid, regaddr) \
90 	((iopaddr_t)(HX_REG_BASE + (((long)nasid)<<HX_NODE_SHIFT) + ((long)regaddr)))
91 
92 #if TBD
93 #assert sizeof(iopaddr_t) == 8
94 #endif /* TBD */
95 
96 /*
97  * Get widget part number, given node id and widget id.
98  * Always do a 32-bit read, because some widgets, e.g., Bridge, require so.
99  * Widget ID is at offset 0 for 64-bit access.  Add 4 to get lower 32 bits
100  * in big endian mode.
101  * XXX Double check this with Hub, Xbow, Bridge and other hardware folks.
102  */
103 #define XWIDGET_ID_READ(nasid, widget) \
104         (widgetreg_t)(*(volatile uint32_t *)(NODE_SWIN_BASE(nasid, widget) + WIDGET_ID))
105 
106 
107 #endif /* _ASM_SN_XTALK_XTALKADDRS_H */
108