xref: /OK3568_Linux_fs/kernel/arch/mips/include/asm/sn/klconfig.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * This file is subject to the terms and conditions of the GNU General Public
3*4882a593Smuzhiyun  * License.  See the file "COPYING" in the main directory of this archive
4*4882a593Smuzhiyun  * for more details.
5*4882a593Smuzhiyun  *
6*4882a593Smuzhiyun  * Derived from IRIX <sys/SN/klconfig.h>.
7*4882a593Smuzhiyun  *
8*4882a593Smuzhiyun  * Copyright (C) 1992 - 1997, 1999, 2000 Silicon Graphics, Inc.
9*4882a593Smuzhiyun  * Copyright (C) 1999, 2000 by Ralf Baechle
10*4882a593Smuzhiyun  */
11*4882a593Smuzhiyun #ifndef _ASM_SN_KLCONFIG_H
12*4882a593Smuzhiyun #define _ASM_SN_KLCONFIG_H
13*4882a593Smuzhiyun 
14*4882a593Smuzhiyun /*
15*4882a593Smuzhiyun  * The KLCONFIG structures store info about the various BOARDs found
16*4882a593Smuzhiyun  * during Hardware Discovery. In addition, it stores info about the
17*4882a593Smuzhiyun  * components found on the BOARDs.
18*4882a593Smuzhiyun  */
19*4882a593Smuzhiyun 
20*4882a593Smuzhiyun /*
21*4882a593Smuzhiyun  * WARNING:
22*4882a593Smuzhiyun  *	Certain assembly language routines (notably xxxxx.s) in the IP27PROM
23*4882a593Smuzhiyun  *	will depend on the format of the data structures in this file.	In
24*4882a593Smuzhiyun  *	most cases, rearranging the fields can seriously break things.
25*4882a593Smuzhiyun  *	Adding fields in the beginning or middle can also break things.
26*4882a593Smuzhiyun  *	Add fields if necessary, to the end of a struct in such a way
27*4882a593Smuzhiyun  *	that offsets of existing fields do not change.
28*4882a593Smuzhiyun  */
29*4882a593Smuzhiyun 
30*4882a593Smuzhiyun #include <linux/types.h>
31*4882a593Smuzhiyun #include <asm/sn/types.h>
32*4882a593Smuzhiyun 
33*4882a593Smuzhiyun #if defined(CONFIG_SGI_IP27)
34*4882a593Smuzhiyun 
35*4882a593Smuzhiyun #include <asm/sn/sn0/addrs.h>
36*4882a593Smuzhiyun //#include <sys/SN/router.h>
37*4882a593Smuzhiyun // XXX Stolen from <sys/SN/router.h>:
38*4882a593Smuzhiyun #define MAX_ROUTER_PORTS (6)	/* Max. number of ports on a router */
39*4882a593Smuzhiyun #include <asm/sn/fru.h>
40*4882a593Smuzhiyun //#include <sys/graph.h>
41*4882a593Smuzhiyun //#include <sys/xtalk/xbow.h>
42*4882a593Smuzhiyun 
43*4882a593Smuzhiyun #elif defined(CONFIG_SGI_IP35)
44*4882a593Smuzhiyun 
45*4882a593Smuzhiyun #include <asm/sn/sn1/addrs.h>
46*4882a593Smuzhiyun #include <sys/sn/router.h>
47*4882a593Smuzhiyun #include <sys/graph.h>
48*4882a593Smuzhiyun #include <asm/xtalk/xbow.h>
49*4882a593Smuzhiyun 
50*4882a593Smuzhiyun #endif /* !CONFIG_SGI_IP27 && !CONFIG_SGI_IP35 */
51*4882a593Smuzhiyun 
52*4882a593Smuzhiyun #if defined(CONFIG_SGI_IP27) || defined(CONFIG_SGI_IP35)
53*4882a593Smuzhiyun #include <asm/sn/agent.h>
54*4882a593Smuzhiyun #include <asm/fw/arc/types.h>
55*4882a593Smuzhiyun #include <asm/fw/arc/hinv.h>
56*4882a593Smuzhiyun #if defined(CONFIG_SGI_IP35)
57*4882a593Smuzhiyun // The hack file has to be before vector and after sn0_fru....
58*4882a593Smuzhiyun #include <asm/hack.h>
59*4882a593Smuzhiyun #include <asm/sn/vector.h>
60*4882a593Smuzhiyun #include <asm/xtalk/xtalk.h>
61*4882a593Smuzhiyun #endif /* CONFIG_SGI_IP35 */
62*4882a593Smuzhiyun #endif /* CONFIG_SGI_IP27 || CONFIG_SGI_IP35 */
63*4882a593Smuzhiyun 
64*4882a593Smuzhiyun typedef u64  nic_t;
65*4882a593Smuzhiyun 
66*4882a593Smuzhiyun #define KLCFGINFO_MAGIC 0xbeedbabe
67*4882a593Smuzhiyun 
68*4882a593Smuzhiyun typedef s32 klconf_off_t;
69*4882a593Smuzhiyun 
70*4882a593Smuzhiyun /*
71*4882a593Smuzhiyun  * Some IMPORTANT OFFSETS. These are the offsets on all NODES.
72*4882a593Smuzhiyun  */
73*4882a593Smuzhiyun #define MAX_MODULE_ID		255
74*4882a593Smuzhiyun #define SIZE_PAD		4096 /* 4k padding for structures */
75*4882a593Smuzhiyun /*
76*4882a593Smuzhiyun  * 1 NODE brd, 2 Router brd (1 8p, 1 meta), 6 Widgets,
77*4882a593Smuzhiyun  * 2 Midplanes assuming no pci card cages
78*4882a593Smuzhiyun  */
79*4882a593Smuzhiyun #define MAX_SLOTS_PER_NODE	(1 + 2 + 6 + 2)
80*4882a593Smuzhiyun 
81*4882a593Smuzhiyun /* XXX if each node is guaranteed to have some memory */
82*4882a593Smuzhiyun 
83*4882a593Smuzhiyun #define MAX_PCI_DEVS		8
84*4882a593Smuzhiyun 
85*4882a593Smuzhiyun /* lboard_t->brd_flags fields */
86*4882a593Smuzhiyun /* All bits in this field are currently used. Try the pad fields if
87*4882a593Smuzhiyun    you need more flag bits */
88*4882a593Smuzhiyun 
89*4882a593Smuzhiyun #define ENABLE_BOARD		0x01
90*4882a593Smuzhiyun #define FAILED_BOARD		0x02
91*4882a593Smuzhiyun #define DUPLICATE_BOARD		0x04	/* Boards like midplanes/routers which
92*4882a593Smuzhiyun 					   are discovered twice. Use one of them */
93*4882a593Smuzhiyun #define VISITED_BOARD		0x08	/* Used for compact hub numbering. */
94*4882a593Smuzhiyun #define LOCAL_MASTER_IO6	0x10	/* master io6 for that node */
95*4882a593Smuzhiyun #define GLOBAL_MASTER_IO6	0x20
96*4882a593Smuzhiyun #define THIRD_NIC_PRESENT	0x40	/* for future use */
97*4882a593Smuzhiyun #define SECOND_NIC_PRESENT	0x80	/* addons like MIO are present */
98*4882a593Smuzhiyun 
99*4882a593Smuzhiyun /* klinfo->flags fields */
100*4882a593Smuzhiyun 
101*4882a593Smuzhiyun #define KLINFO_ENABLE		0x01	/* This component is enabled */
102*4882a593Smuzhiyun #define KLINFO_FAILED		0x02	/* This component failed */
103*4882a593Smuzhiyun #define KLINFO_DEVICE		0x04	/* This component is a device */
104*4882a593Smuzhiyun #define KLINFO_VISITED		0x08	/* This component has been visited */
105*4882a593Smuzhiyun #define KLINFO_CONTROLLER	0x10	/* This component is a device controller */
106*4882a593Smuzhiyun #define KLINFO_INSTALL		0x20	/* Install a driver */
107*4882a593Smuzhiyun #define KLINFO_HEADLESS		0x40	/* Headless (or hubless) component */
108*4882a593Smuzhiyun #define IS_CONSOLE_IOC3(i)	((((klinfo_t *)i)->flags) & KLINFO_INSTALL)
109*4882a593Smuzhiyun 
110*4882a593Smuzhiyun #define GB2		0x80000000
111*4882a593Smuzhiyun 
112*4882a593Smuzhiyun #define MAX_RSV_PTRS	32
113*4882a593Smuzhiyun 
114*4882a593Smuzhiyun /* Structures to manage various data storage areas */
115*4882a593Smuzhiyun /* The numbers must be contiguous since the array index i
116*4882a593Smuzhiyun    is used in the code to allocate various areas.
117*4882a593Smuzhiyun */
118*4882a593Smuzhiyun 
119*4882a593Smuzhiyun #define BOARD_STRUCT		0
120*4882a593Smuzhiyun #define COMPONENT_STRUCT	1
121*4882a593Smuzhiyun #define ERRINFO_STRUCT		2
122*4882a593Smuzhiyun #define KLMALLOC_TYPE_MAX	(ERRINFO_STRUCT + 1)
123*4882a593Smuzhiyun #define DEVICE_STRUCT		3
124*4882a593Smuzhiyun 
125*4882a593Smuzhiyun 
126*4882a593Smuzhiyun typedef struct console_s {
127*4882a593Smuzhiyun 	unsigned long	uart_base;
128*4882a593Smuzhiyun 	unsigned long	config_base;
129*4882a593Smuzhiyun 	unsigned long	memory_base;
130*4882a593Smuzhiyun 	short		baud;
131*4882a593Smuzhiyun 	short		flag;
132*4882a593Smuzhiyun 	int		type;
133*4882a593Smuzhiyun 	nasid_t		nasid;
134*4882a593Smuzhiyun 	char		wid;
135*4882a593Smuzhiyun 	char		npci;
136*4882a593Smuzhiyun 	nic_t		baseio_nic;
137*4882a593Smuzhiyun } console_t;
138*4882a593Smuzhiyun 
139*4882a593Smuzhiyun typedef struct klc_malloc_hdr {
140*4882a593Smuzhiyun 	klconf_off_t km_base;
141*4882a593Smuzhiyun 	klconf_off_t km_limit;
142*4882a593Smuzhiyun 	klconf_off_t km_current;
143*4882a593Smuzhiyun } klc_malloc_hdr_t;
144*4882a593Smuzhiyun 
145*4882a593Smuzhiyun /* Functions/macros needed to use this structure */
146*4882a593Smuzhiyun 
147*4882a593Smuzhiyun typedef struct kl_config_hdr {
148*4882a593Smuzhiyun 	u64		ch_magic;	/* set this to KLCFGINFO_MAGIC */
149*4882a593Smuzhiyun 	u32		ch_version;    /* structure version number */
150*4882a593Smuzhiyun 	klconf_off_t	ch_malloc_hdr_off; /* offset of ch_malloc_hdr */
151*4882a593Smuzhiyun 	klconf_off_t	ch_cons_off;	   /* offset of ch_cons */
152*4882a593Smuzhiyun 	klconf_off_t	ch_board_info;	/* the link list of boards */
153*4882a593Smuzhiyun 	console_t	ch_cons_info;	/* address info of the console */
154*4882a593Smuzhiyun 	klc_malloc_hdr_t ch_malloc_hdr[KLMALLOC_TYPE_MAX];
155*4882a593Smuzhiyun 	confidence_t	ch_sw_belief;	/* confidence that software is bad*/
156*4882a593Smuzhiyun 	confidence_t	ch_sn0net_belief; /* confidence that sn0net is bad */
157*4882a593Smuzhiyun } kl_config_hdr_t;
158*4882a593Smuzhiyun 
159*4882a593Smuzhiyun 
160*4882a593Smuzhiyun #define KL_CONFIG_HDR(_nasid)	((kl_config_hdr_t *)(KLCONFIG_ADDR(_nasid)))
161*4882a593Smuzhiyun #define KL_CONFIG_INFO_OFFSET(_nasid)					\
162*4882a593Smuzhiyun 	(KL_CONFIG_HDR(_nasid)->ch_board_info)
163*4882a593Smuzhiyun #define KL_CONFIG_INFO_SET_OFFSET(_nasid, _off)				\
164*4882a593Smuzhiyun 	(KL_CONFIG_HDR(_nasid)->ch_board_info = (_off))
165*4882a593Smuzhiyun 
166*4882a593Smuzhiyun #define KL_CONFIG_INFO(_nasid)						\
167*4882a593Smuzhiyun 	(lboard_t *)((KL_CONFIG_HDR(_nasid)->ch_board_info) ?		\
168*4882a593Smuzhiyun 	 NODE_OFFSET_TO_K1((_nasid), KL_CONFIG_HDR(_nasid)->ch_board_info) : \
169*4882a593Smuzhiyun 	 0)
170*4882a593Smuzhiyun #define KL_CONFIG_MAGIC(_nasid)		(KL_CONFIG_HDR(_nasid)->ch_magic)
171*4882a593Smuzhiyun 
172*4882a593Smuzhiyun #define KL_CONFIG_CHECK_MAGIC(_nasid)					\
173*4882a593Smuzhiyun 	(KL_CONFIG_HDR(_nasid)->ch_magic == KLCFGINFO_MAGIC)
174*4882a593Smuzhiyun 
175*4882a593Smuzhiyun #define KL_CONFIG_HDR_INIT_MAGIC(_nasid)	\
176*4882a593Smuzhiyun 		  (KL_CONFIG_HDR(_nasid)->ch_magic = KLCFGINFO_MAGIC)
177*4882a593Smuzhiyun 
178*4882a593Smuzhiyun /* --- New Macros for the changed kl_config_hdr_t structure --- */
179*4882a593Smuzhiyun 
180*4882a593Smuzhiyun #define PTR_CH_MALLOC_HDR(_k)	((klc_malloc_hdr_t *)\
181*4882a593Smuzhiyun 			((unsigned long)_k + (_k->ch_malloc_hdr_off)))
182*4882a593Smuzhiyun 
183*4882a593Smuzhiyun #define KL_CONFIG_CH_MALLOC_HDR(_n)   PTR_CH_MALLOC_HDR(KL_CONFIG_HDR(_n))
184*4882a593Smuzhiyun 
185*4882a593Smuzhiyun #define PTR_CH_CONS_INFO(_k)	((console_t *)\
186*4882a593Smuzhiyun 			((unsigned long)_k + (_k->ch_cons_off)))
187*4882a593Smuzhiyun 
188*4882a593Smuzhiyun #define KL_CONFIG_CH_CONS_INFO(_n)   PTR_CH_CONS_INFO(KL_CONFIG_HDR(_n))
189*4882a593Smuzhiyun 
190*4882a593Smuzhiyun /* ------------------------------------------------------------- */
191*4882a593Smuzhiyun 
192*4882a593Smuzhiyun #define KL_CONFIG_INFO_START(_nasid)	\
193*4882a593Smuzhiyun 	(klconf_off_t)(KLCONFIG_OFFSET(_nasid) + sizeof(kl_config_hdr_t))
194*4882a593Smuzhiyun 
195*4882a593Smuzhiyun #define KL_CONFIG_BOARD_NASID(_brd)	((_brd)->brd_nasid)
196*4882a593Smuzhiyun #define KL_CONFIG_BOARD_SET_NEXT(_brd, _off)	((_brd)->brd_next = (_off))
197*4882a593Smuzhiyun 
198*4882a593Smuzhiyun #define KL_CONFIG_DUPLICATE_BOARD(_brd) ((_brd)->brd_flags & DUPLICATE_BOARD)
199*4882a593Smuzhiyun 
200*4882a593Smuzhiyun #define XBOW_PORT_TYPE_HUB(_xbowp, _link)	\
201*4882a593Smuzhiyun 	       ((_xbowp)->xbow_port_info[(_link) - BASE_XBOW_PORT].port_flag & XBOW_PORT_HUB)
202*4882a593Smuzhiyun #define XBOW_PORT_TYPE_IO(_xbowp, _link)	\
203*4882a593Smuzhiyun 	       ((_xbowp)->xbow_port_info[(_link) - BASE_XBOW_PORT].port_flag & XBOW_PORT_IO)
204*4882a593Smuzhiyun 
205*4882a593Smuzhiyun #define XBOW_PORT_IS_ENABLED(_xbowp, _link)	\
206*4882a593Smuzhiyun 	       ((_xbowp)->xbow_port_info[(_link) - BASE_XBOW_PORT].port_flag & XBOW_PORT_ENABLE)
207*4882a593Smuzhiyun #define XBOW_PORT_NASID(_xbowp, _link)	\
208*4882a593Smuzhiyun 	       ((_xbowp)->xbow_port_info[(_link) - BASE_XBOW_PORT].port_nasid)
209*4882a593Smuzhiyun 
210*4882a593Smuzhiyun #define XBOW_PORT_IO	 0x1
211*4882a593Smuzhiyun #define XBOW_PORT_HUB	 0x2
212*4882a593Smuzhiyun #define XBOW_PORT_ENABLE 0x4
213*4882a593Smuzhiyun 
214*4882a593Smuzhiyun #define SN0_PORT_FENCE_SHFT	0
215*4882a593Smuzhiyun #define SN0_PORT_FENCE_MASK	(1 << SN0_PORT_FENCE_SHFT)
216*4882a593Smuzhiyun 
217*4882a593Smuzhiyun /*
218*4882a593Smuzhiyun  * The KLCONFIG area is organized as a LINKED LIST of BOARDs. A BOARD
219*4882a593Smuzhiyun  * can be either 'LOCAL' or 'REMOTE'. LOCAL means it is attached to
220*4882a593Smuzhiyun  * the LOCAL/current NODE. REMOTE means it is attached to a different
221*4882a593Smuzhiyun  * node.(TBD - Need a way to treat ROUTER boards.)
222*4882a593Smuzhiyun  *
223*4882a593Smuzhiyun  * There are 2 different structures to represent these boards -
224*4882a593Smuzhiyun  * lboard - Local board, rboard - remote board. These 2 structures
225*4882a593Smuzhiyun  * can be arbitrarily mixed in the LINKED LIST of BOARDs. (Refer
226*4882a593Smuzhiyun  * Figure below). The first byte of the rboard or lboard structure
227*4882a593Smuzhiyun  * is used to find out its type - no unions are used.
228*4882a593Smuzhiyun  * If it is a lboard, then the config info of this board will be found
229*4882a593Smuzhiyun  * on the local node. (LOCAL NODE BASE + offset value gives pointer to
230*4882a593Smuzhiyun  * the structure.
231*4882a593Smuzhiyun  * If it is a rboard, the local structure contains the node number
232*4882a593Smuzhiyun  * and the offset of the beginning of the LINKED LIST on the remote node.
233*4882a593Smuzhiyun  * The details of the hardware on a remote node can be built locally,
234*4882a593Smuzhiyun  * if required, by reading the LINKED LIST on the remote node and
235*4882a593Smuzhiyun  * ignoring all the rboards on that node.
236*4882a593Smuzhiyun  *
237*4882a593Smuzhiyun  * The local node uses the REMOTE NODE NUMBER + OFFSET to point to the
238*4882a593Smuzhiyun  * First board info on the remote node. The remote node list is
239*4882a593Smuzhiyun  * traversed as the local list, using the REMOTE BASE ADDRESS and not
240*4882a593Smuzhiyun  * the local base address and ignoring all rboard values.
241*4882a593Smuzhiyun  *
242*4882a593Smuzhiyun  *
243*4882a593Smuzhiyun  KLCONFIG
244*4882a593Smuzhiyun 
245*4882a593Smuzhiyun  +------------+	     +------------+	 +------------+	     +------------+
246*4882a593Smuzhiyun  |  lboard    |	 +-->|	 lboard	  |  +-->|   rboard   |	 +-->|	 lboard	  |
247*4882a593Smuzhiyun  +------------+	 |   +------------+  |	 +------------+	 |   +------------+
248*4882a593Smuzhiyun  | board info |	 |   | board info |  |	 |errinfo,bptr|	 |   | board info |
249*4882a593Smuzhiyun  +------------+	 |   +------------+  |	 +------------+	 |   +------------+
250*4882a593Smuzhiyun  | offset     |--+   |	offset	  |--+	 |  offset    |--+   |offset=NULL |
251*4882a593Smuzhiyun  +------------+	     +------------+	 +------------+	     +------------+
252*4882a593Smuzhiyun 
253*4882a593Smuzhiyun 
254*4882a593Smuzhiyun  +------------+
255*4882a593Smuzhiyun  | board info |
256*4882a593Smuzhiyun  +------------+	      +--------------------------------+
257*4882a593Smuzhiyun  | compt 1    |------>| type, rev, diaginfo, size ...  |  (CPU)
258*4882a593Smuzhiyun  +------------+	      +--------------------------------+
259*4882a593Smuzhiyun  | compt 2    |--+
260*4882a593Smuzhiyun  +------------+	 |    +--------------------------------+
261*4882a593Smuzhiyun  |  ...	      |	 +--->| type, rev, diaginfo, size ...  |  (MEM_BANK)
262*4882a593Smuzhiyun  +------------+	      +--------------------------------+
263*4882a593Smuzhiyun  | errinfo    |--+
264*4882a593Smuzhiyun  +------------+	 |    +--------------------------------+
265*4882a593Smuzhiyun 		 +--->|r/l brd errinfo,compt err flags |
266*4882a593Smuzhiyun 		      +--------------------------------+
267*4882a593Smuzhiyun 
268*4882a593Smuzhiyun  *
269*4882a593Smuzhiyun  * Each BOARD consists of COMPONENTs and the BOARD structure has
270*4882a593Smuzhiyun  * pointers (offsets) to its COMPONENT structure.
271*4882a593Smuzhiyun  * The COMPONENT structure has version info, size and speed info, revision,
272*4882a593Smuzhiyun  * error info and the NIC info. This structure can accommodate any
273*4882a593Smuzhiyun  * BOARD with arbitrary COMPONENT composition.
274*4882a593Smuzhiyun  *
275*4882a593Smuzhiyun  * The ERRORINFO part of each BOARD has error information
276*4882a593Smuzhiyun  * that describes errors about the BOARD itself. It also has flags to
277*4882a593Smuzhiyun  * indicate the COMPONENT(s) on the board that have errors. The error
278*4882a593Smuzhiyun  * information specific to the COMPONENT is present in the respective
279*4882a593Smuzhiyun  * COMPONENT structure.
280*4882a593Smuzhiyun  *
281*4882a593Smuzhiyun  * The ERRORINFO structure is also treated like a COMPONENT, ie. the
282*4882a593Smuzhiyun  * BOARD has pointers(offset) to the ERRORINFO structure. The rboard
283*4882a593Smuzhiyun  * structure also has a pointer to the ERRORINFO structure. This is
284*4882a593Smuzhiyun  * the place to store ERRORINFO about a REMOTE NODE, if the HUB on
285*4882a593Smuzhiyun  * that NODE is not working or if the REMOTE MEMORY is BAD. In cases where
286*4882a593Smuzhiyun  * only the CPU of the REMOTE NODE is disabled, the ERRORINFO pointer can
287*4882a593Smuzhiyun  * be a NODE NUMBER, REMOTE OFFSET combination, pointing to error info
288*4882a593Smuzhiyun  * which is present on the REMOTE NODE.(TBD)
289*4882a593Smuzhiyun  * REMOTE ERRINFO can be stored on any of the nearest nodes
290*4882a593Smuzhiyun  * or on all the nearest nodes.(TBD)
291*4882a593Smuzhiyun  * Like BOARD structures, REMOTE ERRINFO structures can be built locally
292*4882a593Smuzhiyun  * using the rboard errinfo pointer.
293*4882a593Smuzhiyun  *
294*4882a593Smuzhiyun  * In order to get useful information from this Data organization, a set of
295*4882a593Smuzhiyun  * interface routines are provided (TBD). The important thing to remember while
296*4882a593Smuzhiyun  * manipulating the structures, is that, the NODE number information should
297*4882a593Smuzhiyun  * be used. If the NODE is non-zero (remote) then each offset should
298*4882a593Smuzhiyun  * be added to the REMOTE BASE ADDR else it should be added to the LOCAL BASE ADDR.
299*4882a593Smuzhiyun  * This includes offsets for BOARDS, COMPONENTS and ERRORINFO.
300*4882a593Smuzhiyun  *
301*4882a593Smuzhiyun  * Note that these structures do not provide much info about connectivity.
302*4882a593Smuzhiyun  * That info will be part of HWGRAPH, which is an extension of the cfg_t
303*4882a593Smuzhiyun  * data structure. (ref IP27prom/cfg.h) It has to be extended to include
304*4882a593Smuzhiyun  * the IO part of the Network(TBD).
305*4882a593Smuzhiyun  *
306*4882a593Smuzhiyun  * The data structures below define the above concepts.
307*4882a593Smuzhiyun  */
308*4882a593Smuzhiyun 
309*4882a593Smuzhiyun /*
310*4882a593Smuzhiyun  * Values for CPU types
311*4882a593Smuzhiyun  */
312*4882a593Smuzhiyun #define KL_CPU_R4000		0x1	/* Standard R4000 */
313*4882a593Smuzhiyun #define KL_CPU_TFP		0x2	/* TFP processor */
314*4882a593Smuzhiyun #define KL_CPU_R10000		0x3	/* R10000 (T5) */
315*4882a593Smuzhiyun #define KL_CPU_NONE		(-1)	/* no cpu present in slot */
316*4882a593Smuzhiyun 
317*4882a593Smuzhiyun /*
318*4882a593Smuzhiyun  * IP27 BOARD classes
319*4882a593Smuzhiyun  */
320*4882a593Smuzhiyun 
321*4882a593Smuzhiyun #define KLCLASS_MASK	0xf0
322*4882a593Smuzhiyun #define KLCLASS_NONE	0x00
323*4882a593Smuzhiyun #define KLCLASS_NODE	0x10		 /* CPU, Memory and HUB board */
324*4882a593Smuzhiyun #define KLCLASS_CPU	KLCLASS_NODE
325*4882a593Smuzhiyun #define KLCLASS_IO	0x20		 /* BaseIO, 4 ch SCSI, ethernet, FDDI
326*4882a593Smuzhiyun 					    and the non-graphics widget boards */
327*4882a593Smuzhiyun #define KLCLASS_ROUTER	0x30		 /* Router board */
328*4882a593Smuzhiyun #define KLCLASS_MIDPLANE 0x40		 /* We need to treat this as a board
329*4882a593Smuzhiyun 					    so that we can record error info */
330*4882a593Smuzhiyun #define KLCLASS_GFX	0x50		/* graphics boards */
331*4882a593Smuzhiyun 
332*4882a593Smuzhiyun #define KLCLASS_PSEUDO_GFX	0x60	/* HDTV type cards that use a gfx
333*4882a593Smuzhiyun 					 * hw ifc to xtalk and are not gfx
334*4882a593Smuzhiyun 					 * class for sw purposes */
335*4882a593Smuzhiyun 
336*4882a593Smuzhiyun #define KLCLASS_MAX	7		/* Bump this if a new CLASS is added */
337*4882a593Smuzhiyun #define KLTYPE_MAX	10		/* Bump this if a new CLASS is added */
338*4882a593Smuzhiyun 
339*4882a593Smuzhiyun #define KLCLASS_UNKNOWN 0xf0
340*4882a593Smuzhiyun 
341*4882a593Smuzhiyun #define KLCLASS(_x) ((_x) & KLCLASS_MASK)
342*4882a593Smuzhiyun 
343*4882a593Smuzhiyun /*
344*4882a593Smuzhiyun  * IP27 board types
345*4882a593Smuzhiyun  */
346*4882a593Smuzhiyun 
347*4882a593Smuzhiyun #define KLTYPE_MASK	0x0f
348*4882a593Smuzhiyun #define KLTYPE_NONE	0x00
349*4882a593Smuzhiyun #define KLTYPE_EMPTY	0x00
350*4882a593Smuzhiyun 
351*4882a593Smuzhiyun #define KLTYPE_WEIRDCPU (KLCLASS_CPU | 0x0)
352*4882a593Smuzhiyun #define KLTYPE_IP27	(KLCLASS_CPU | 0x1) /* 2 CPUs(R10K) per board */
353*4882a593Smuzhiyun 
354*4882a593Smuzhiyun #define KLTYPE_WEIRDIO	(KLCLASS_IO  | 0x0)
355*4882a593Smuzhiyun #define KLTYPE_BASEIO	(KLCLASS_IO  | 0x1) /* IOC3, SuperIO, Bridge, SCSI */
356*4882a593Smuzhiyun #define KLTYPE_IO6	KLTYPE_BASEIO	    /* Additional name */
357*4882a593Smuzhiyun #define KLTYPE_4CHSCSI	(KLCLASS_IO  | 0x2)
358*4882a593Smuzhiyun #define KLTYPE_MSCSI	KLTYPE_4CHSCSI	    /* Additional name */
359*4882a593Smuzhiyun #define KLTYPE_ETHERNET (KLCLASS_IO  | 0x3)
360*4882a593Smuzhiyun #define KLTYPE_MENET	KLTYPE_ETHERNET	    /* Additional name */
361*4882a593Smuzhiyun #define KLTYPE_FDDI	(KLCLASS_IO  | 0x4)
362*4882a593Smuzhiyun #define KLTYPE_UNUSED	(KLCLASS_IO  | 0x5) /* XXX UNUSED */
363*4882a593Smuzhiyun #define KLTYPE_HAROLD	(KLCLASS_IO  | 0x6) /* PCI SHOE BOX */
364*4882a593Smuzhiyun #define KLTYPE_PCI	KLTYPE_HAROLD
365*4882a593Smuzhiyun #define KLTYPE_VME	(KLCLASS_IO  | 0x7) /* Any 3rd party VME card */
366*4882a593Smuzhiyun #define KLTYPE_MIO	(KLCLASS_IO  | 0x8)
367*4882a593Smuzhiyun #define KLTYPE_FC	(KLCLASS_IO  | 0x9)
368*4882a593Smuzhiyun #define KLTYPE_LINC	(KLCLASS_IO  | 0xA)
369*4882a593Smuzhiyun #define KLTYPE_TPU	(KLCLASS_IO  | 0xB) /* Tensor Processing Unit */
370*4882a593Smuzhiyun #define KLTYPE_GSN_A	(KLCLASS_IO  | 0xC) /* Main GSN board */
371*4882a593Smuzhiyun #define KLTYPE_GSN_B	(KLCLASS_IO  | 0xD) /* Auxiliary GSN board */
372*4882a593Smuzhiyun 
373*4882a593Smuzhiyun #define KLTYPE_GFX	(KLCLASS_GFX | 0x0) /* unknown graphics type */
374*4882a593Smuzhiyun #define KLTYPE_GFX_KONA (KLCLASS_GFX | 0x1) /* KONA graphics on IP27 */
375*4882a593Smuzhiyun #define KLTYPE_GFX_MGRA (KLCLASS_GFX | 0x3) /* MGRAS graphics on IP27 */
376*4882a593Smuzhiyun 
377*4882a593Smuzhiyun #define KLTYPE_WEIRDROUTER (KLCLASS_ROUTER | 0x0)
378*4882a593Smuzhiyun #define KLTYPE_ROUTER	  (KLCLASS_ROUTER | 0x1)
379*4882a593Smuzhiyun #define KLTYPE_ROUTER2	  KLTYPE_ROUTER		/* Obsolete! */
380*4882a593Smuzhiyun #define KLTYPE_NULL_ROUTER (KLCLASS_ROUTER | 0x2)
381*4882a593Smuzhiyun #define KLTYPE_META_ROUTER (KLCLASS_ROUTER | 0x3)
382*4882a593Smuzhiyun 
383*4882a593Smuzhiyun #define KLTYPE_WEIRDMIDPLANE (KLCLASS_MIDPLANE | 0x0)
384*4882a593Smuzhiyun #define KLTYPE_MIDPLANE8  (KLCLASS_MIDPLANE | 0x1) /* 8 slot backplane */
385*4882a593Smuzhiyun #define KLTYPE_MIDPLANE	   KLTYPE_MIDPLANE8
386*4882a593Smuzhiyun #define KLTYPE_PBRICK_XBOW	(KLCLASS_MIDPLANE | 0x2)
387*4882a593Smuzhiyun 
388*4882a593Smuzhiyun #define KLTYPE_IOBRICK		(KLCLASS_IOBRICK | 0x0)
389*4882a593Smuzhiyun #define KLTYPE_IBRICK		(KLCLASS_IOBRICK | 0x1)
390*4882a593Smuzhiyun #define KLTYPE_PBRICK		(KLCLASS_IOBRICK | 0x2)
391*4882a593Smuzhiyun #define KLTYPE_XBRICK		(KLCLASS_IOBRICK | 0x3)
392*4882a593Smuzhiyun 
393*4882a593Smuzhiyun #define KLTYPE_PBRICK_BRIDGE	KLTYPE_PBRICK
394*4882a593Smuzhiyun 
395*4882a593Smuzhiyun /* The value of type should be more than 8 so that hinv prints
396*4882a593Smuzhiyun  * out the board name from the NIC string. For values less than
397*4882a593Smuzhiyun  * 8 the name of the board needs to be hard coded in a few places.
398*4882a593Smuzhiyun  * When bringup started nic names had not standardized and so we
399*4882a593Smuzhiyun  * had to hard code. (For people interested in history.)
400*4882a593Smuzhiyun  */
401*4882a593Smuzhiyun #define KLTYPE_XTHD	(KLCLASS_PSEUDO_GFX | 0x9)
402*4882a593Smuzhiyun 
403*4882a593Smuzhiyun #define KLTYPE_UNKNOWN	(KLCLASS_UNKNOWN | 0xf)
404*4882a593Smuzhiyun 
405*4882a593Smuzhiyun #define KLTYPE(_x)	((_x) & KLTYPE_MASK)
406*4882a593Smuzhiyun #define IS_MIO_PRESENT(l)	((l->brd_type == KLTYPE_BASEIO) && \
407*4882a593Smuzhiyun 				 (l->brd_flags & SECOND_NIC_PRESENT))
408*4882a593Smuzhiyun #define IS_MIO_IOC3(l, n)	(IS_MIO_PRESENT(l) && (n > 2))
409*4882a593Smuzhiyun 
410*4882a593Smuzhiyun /*
411*4882a593Smuzhiyun  * board structures
412*4882a593Smuzhiyun  */
413*4882a593Smuzhiyun 
414*4882a593Smuzhiyun #define MAX_COMPTS_PER_BRD 24
415*4882a593Smuzhiyun 
416*4882a593Smuzhiyun #define LOCAL_BOARD 1
417*4882a593Smuzhiyun #define REMOTE_BOARD 2
418*4882a593Smuzhiyun 
419*4882a593Smuzhiyun #define LBOARD_STRUCT_VERSION	2
420*4882a593Smuzhiyun 
421*4882a593Smuzhiyun typedef struct lboard_s {
422*4882a593Smuzhiyun 	klconf_off_t	brd_next;	  /* Next BOARD */
423*4882a593Smuzhiyun 	unsigned char	struct_type;	  /* type of structure, local or remote */
424*4882a593Smuzhiyun 	unsigned char	brd_type;	  /* type+class */
425*4882a593Smuzhiyun 	unsigned char	brd_sversion;	  /* version of this structure */
426*4882a593Smuzhiyun 	unsigned char	brd_brevision;	  /* board revision */
427*4882a593Smuzhiyun 	unsigned char	brd_promver;	  /* board prom version, if any */
428*4882a593Smuzhiyun 	unsigned char	brd_flags;	  /* Enabled, Disabled etc */
429*4882a593Smuzhiyun 	unsigned char	brd_slot;	  /* slot number */
430*4882a593Smuzhiyun 	unsigned short	brd_debugsw;	  /* Debug switches */
431*4882a593Smuzhiyun 	moduleid_t	brd_module;	  /* module to which it belongs */
432*4882a593Smuzhiyun 	partid_t	brd_partition;	  /* Partition number */
433*4882a593Smuzhiyun 	unsigned short	brd_diagval;	  /* diagnostic value */
434*4882a593Smuzhiyun 	unsigned short	brd_diagparm;	  /* diagnostic parameter */
435*4882a593Smuzhiyun 	unsigned char	brd_inventory;	  /* inventory history */
436*4882a593Smuzhiyun 	unsigned char	brd_numcompts;	  /* Number of components */
437*4882a593Smuzhiyun 	nic_t		brd_nic;	  /* Number in CAN */
438*4882a593Smuzhiyun 	nasid_t		brd_nasid;	  /* passed parameter */
439*4882a593Smuzhiyun 	klconf_off_t	brd_compts[MAX_COMPTS_PER_BRD]; /* pointers to COMPONENTS */
440*4882a593Smuzhiyun 	klconf_off_t	brd_errinfo;	  /* Board's error information */
441*4882a593Smuzhiyun 	struct lboard_s *brd_parent;	  /* Logical parent for this brd */
442*4882a593Smuzhiyun 	vertex_hdl_t	brd_graph_link;	  /* vertex hdl to connect extern compts */
443*4882a593Smuzhiyun 	confidence_t	brd_confidence;	  /* confidence that the board is bad */
444*4882a593Smuzhiyun 	nasid_t		brd_owner;	  /* who owns this board */
445*4882a593Smuzhiyun 	unsigned char	brd_nic_flags;	  /* To handle 8 more NICs */
446*4882a593Smuzhiyun 	char		brd_name[32];
447*4882a593Smuzhiyun } lboard_t;
448*4882a593Smuzhiyun 
449*4882a593Smuzhiyun 
450*4882a593Smuzhiyun /*
451*4882a593Smuzhiyun  *	Make sure we pass back the calias space address for local boards.
452*4882a593Smuzhiyun  *	klconfig board traversal and error structure extraction defines.
453*4882a593Smuzhiyun  */
454*4882a593Smuzhiyun 
455*4882a593Smuzhiyun #define BOARD_SLOT(_brd)	((_brd)->brd_slot)
456*4882a593Smuzhiyun 
457*4882a593Smuzhiyun #define KLCF_CLASS(_brd)	KLCLASS((_brd)->brd_type)
458*4882a593Smuzhiyun #define KLCF_TYPE(_brd)		KLTYPE((_brd)->brd_type)
459*4882a593Smuzhiyun #define KLCF_REMOTE(_brd)	(((_brd)->struct_type & LOCAL_BOARD) ? 0 : 1)
460*4882a593Smuzhiyun #define KLCF_NUM_COMPS(_brd)	((_brd)->brd_numcompts)
461*4882a593Smuzhiyun #define KLCF_MODULE_ID(_brd)	((_brd)->brd_module)
462*4882a593Smuzhiyun 
463*4882a593Smuzhiyun #define KLCF_NEXT(_brd)		\
464*4882a593Smuzhiyun 	((_brd)->brd_next ?	\
465*4882a593Smuzhiyun 	 (lboard_t *)(NODE_OFFSET_TO_K1(NASID_GET(_brd), (_brd)->brd_next)):\
466*4882a593Smuzhiyun 	 NULL)
467*4882a593Smuzhiyun #define KLCF_COMP(_brd, _ndx)	\
468*4882a593Smuzhiyun 		(klinfo_t *)(NODE_OFFSET_TO_K1(NASID_GET(_brd), \
469*4882a593Smuzhiyun 					       (_brd)->brd_compts[(_ndx)]))
470*4882a593Smuzhiyun 
471*4882a593Smuzhiyun #define KLCF_COMP_ERROR(_brd, _comp)	\
472*4882a593Smuzhiyun 	       (NODE_OFFSET_TO_K1(NASID_GET(_brd), (_comp)->errinfo))
473*4882a593Smuzhiyun 
474*4882a593Smuzhiyun #define KLCF_COMP_TYPE(_comp)	((_comp)->struct_type)
475*4882a593Smuzhiyun #define KLCF_BRIDGE_W_ID(_comp) ((_comp)->physid)	/* Widget ID */
476*4882a593Smuzhiyun 
477*4882a593Smuzhiyun 
478*4882a593Smuzhiyun 
479*4882a593Smuzhiyun /*
480*4882a593Smuzhiyun  * Generic info structure. This stores common info about a
481*4882a593Smuzhiyun  * component.
482*4882a593Smuzhiyun  */
483*4882a593Smuzhiyun 
484*4882a593Smuzhiyun typedef struct klinfo_s {		   /* Generic info */
485*4882a593Smuzhiyun 	unsigned char	struct_type;	   /* type of this structure */
486*4882a593Smuzhiyun 	unsigned char	struct_version;	   /* version of this structure */
487*4882a593Smuzhiyun 	unsigned char	flags;		  /* Enabled, disabled etc */
488*4882a593Smuzhiyun 	unsigned char	revision;	  /* component revision */
489*4882a593Smuzhiyun 	unsigned short	diagval;	  /* result of diagnostics */
490*4882a593Smuzhiyun 	unsigned short	diagparm;	  /* diagnostic parameter */
491*4882a593Smuzhiyun 	unsigned char	inventory;	  /* previous inventory status */
492*4882a593Smuzhiyun 	nic_t		nic;		  /* MUst be aligned properly */
493*4882a593Smuzhiyun 	unsigned char	physid;		  /* physical id of component */
494*4882a593Smuzhiyun 	unsigned int	virtid;		  /* virtual id as seen by system */
495*4882a593Smuzhiyun 	unsigned char	widid;		  /* Widget id - if applicable */
496*4882a593Smuzhiyun 	nasid_t		nasid;		  /* node number - from parent */
497*4882a593Smuzhiyun 	char		pad1;		  /* pad out structure. */
498*4882a593Smuzhiyun 	char		pad2;		  /* pad out structure. */
499*4882a593Smuzhiyun 	COMPONENT	*arcs_compt;	  /* ptr to the arcs struct for ease*/
500*4882a593Smuzhiyun 	klconf_off_t	errinfo;	  /* component specific errors */
501*4882a593Smuzhiyun 	unsigned short	pad3;		  /* pci fields have moved over to */
502*4882a593Smuzhiyun 	unsigned short	pad4;		  /* klbri_t */
503*4882a593Smuzhiyun } klinfo_t ;
504*4882a593Smuzhiyun 
505*4882a593Smuzhiyun #define KLCONFIG_INFO_ENABLED(_i)	((_i)->flags & KLINFO_ENABLE)
506*4882a593Smuzhiyun /*
507*4882a593Smuzhiyun  * Component structures.
508*4882a593Smuzhiyun  * Following are the currently identified components:
509*4882a593Smuzhiyun  *	CPU, HUB, MEM_BANK,
510*4882a593Smuzhiyun  *	XBOW(consists of 16 WIDGETs, each of which can be HUB or GRAPHICS or BRIDGE)
511*4882a593Smuzhiyun  *	BRIDGE, IOC3, SuperIO, SCSI, FDDI
512*4882a593Smuzhiyun  *	ROUTER
513*4882a593Smuzhiyun  *	GRAPHICS
514*4882a593Smuzhiyun  */
515*4882a593Smuzhiyun #define KLSTRUCT_UNKNOWN	0
516*4882a593Smuzhiyun #define KLSTRUCT_CPU		1
517*4882a593Smuzhiyun #define KLSTRUCT_HUB		2
518*4882a593Smuzhiyun #define KLSTRUCT_MEMBNK		3
519*4882a593Smuzhiyun #define KLSTRUCT_XBOW		4
520*4882a593Smuzhiyun #define KLSTRUCT_BRI		5
521*4882a593Smuzhiyun #define KLSTRUCT_IOC3		6
522*4882a593Smuzhiyun #define KLSTRUCT_PCI		7
523*4882a593Smuzhiyun #define KLSTRUCT_VME		8
524*4882a593Smuzhiyun #define KLSTRUCT_ROU		9
525*4882a593Smuzhiyun #define KLSTRUCT_GFX		10
526*4882a593Smuzhiyun #define KLSTRUCT_SCSI		11
527*4882a593Smuzhiyun #define KLSTRUCT_FDDI		12
528*4882a593Smuzhiyun #define KLSTRUCT_MIO		13
529*4882a593Smuzhiyun #define KLSTRUCT_DISK		14
530*4882a593Smuzhiyun #define KLSTRUCT_TAPE		15
531*4882a593Smuzhiyun #define KLSTRUCT_CDROM		16
532*4882a593Smuzhiyun #define KLSTRUCT_HUB_UART	17
533*4882a593Smuzhiyun #define KLSTRUCT_IOC3ENET	18
534*4882a593Smuzhiyun #define KLSTRUCT_IOC3UART	19
535*4882a593Smuzhiyun #define KLSTRUCT_UNUSED		20 /* XXX UNUSED */
536*4882a593Smuzhiyun #define KLSTRUCT_IOC3PCKM	21
537*4882a593Smuzhiyun #define KLSTRUCT_RAD		22
538*4882a593Smuzhiyun #define KLSTRUCT_HUB_TTY	23
539*4882a593Smuzhiyun #define KLSTRUCT_IOC3_TTY	24
540*4882a593Smuzhiyun 
541*4882a593Smuzhiyun /* Early Access IO proms are compatible
542*4882a593Smuzhiyun    only with KLSTRUCT values up to 24. */
543*4882a593Smuzhiyun 
544*4882a593Smuzhiyun #define KLSTRUCT_FIBERCHANNEL	25
545*4882a593Smuzhiyun #define KLSTRUCT_MOD_SERIAL_NUM 26
546*4882a593Smuzhiyun #define KLSTRUCT_IOC3MS		27
547*4882a593Smuzhiyun #define KLSTRUCT_TPU		28
548*4882a593Smuzhiyun #define KLSTRUCT_GSN_A		29
549*4882a593Smuzhiyun #define KLSTRUCT_GSN_B		30
550*4882a593Smuzhiyun #define KLSTRUCT_XTHD		31
551*4882a593Smuzhiyun 
552*4882a593Smuzhiyun /*
553*4882a593Smuzhiyun  * These are the indices of various components within a lboard structure.
554*4882a593Smuzhiyun  */
555*4882a593Smuzhiyun 
556*4882a593Smuzhiyun #define IP27_CPU0_INDEX 0
557*4882a593Smuzhiyun #define IP27_CPU1_INDEX 1
558*4882a593Smuzhiyun #define IP27_HUB_INDEX 2
559*4882a593Smuzhiyun #define IP27_MEM_INDEX 3
560*4882a593Smuzhiyun 
561*4882a593Smuzhiyun #define BASEIO_BRIDGE_INDEX 0
562*4882a593Smuzhiyun #define BASEIO_IOC3_INDEX 1
563*4882a593Smuzhiyun #define BASEIO_SCSI1_INDEX 2
564*4882a593Smuzhiyun #define BASEIO_SCSI2_INDEX 3
565*4882a593Smuzhiyun 
566*4882a593Smuzhiyun #define MIDPLANE_XBOW_INDEX 0
567*4882a593Smuzhiyun #define ROUTER_COMPONENT_INDEX 0
568*4882a593Smuzhiyun 
569*4882a593Smuzhiyun #define CH4SCSI_BRIDGE_INDEX 0
570*4882a593Smuzhiyun 
571*4882a593Smuzhiyun /* Info holders for various hardware components */
572*4882a593Smuzhiyun 
573*4882a593Smuzhiyun typedef u64 *pci_t;
574*4882a593Smuzhiyun typedef u64 *vmeb_t;
575*4882a593Smuzhiyun typedef u64 *vmed_t;
576*4882a593Smuzhiyun typedef u64 *fddi_t;
577*4882a593Smuzhiyun typedef u64 *scsi_t;
578*4882a593Smuzhiyun typedef u64 *mio_t;
579*4882a593Smuzhiyun typedef u64 *graphics_t;
580*4882a593Smuzhiyun typedef u64 *router_t;
581*4882a593Smuzhiyun 
582*4882a593Smuzhiyun /*
583*4882a593Smuzhiyun  * The port info in ip27_cfg area translates to a lboart_t in the
584*4882a593Smuzhiyun  * KLCONFIG area. But since KLCONFIG does not use pointers, lboart_t
585*4882a593Smuzhiyun  * is stored in terms of a nasid and a offset from start of KLCONFIG
586*4882a593Smuzhiyun  * area	 on that nasid.
587*4882a593Smuzhiyun  */
588*4882a593Smuzhiyun typedef struct klport_s {
589*4882a593Smuzhiyun 	nasid_t		port_nasid;
590*4882a593Smuzhiyun 	unsigned char	port_flag;
591*4882a593Smuzhiyun 	klconf_off_t	port_offset;
592*4882a593Smuzhiyun } klport_t;
593*4882a593Smuzhiyun 
594*4882a593Smuzhiyun typedef struct klcpu_s {			  /* CPU */
595*4882a593Smuzhiyun 	klinfo_t	cpu_info;
596*4882a593Smuzhiyun 	unsigned short	cpu_prid;	/* Processor PRID value */
597*4882a593Smuzhiyun 	unsigned short	cpu_fpirr;	/* FPU IRR value */
598*4882a593Smuzhiyun 	unsigned short	cpu_speed;	/* Speed in MHZ */
599*4882a593Smuzhiyun 	unsigned short	cpu_scachesz;	/* secondary cache size in MB */
600*4882a593Smuzhiyun 	unsigned short	cpu_scachespeed;/* secondary cache speed in MHz */
601*4882a593Smuzhiyun } klcpu_t ;
602*4882a593Smuzhiyun 
603*4882a593Smuzhiyun #define CPU_STRUCT_VERSION   2
604*4882a593Smuzhiyun 
605*4882a593Smuzhiyun typedef struct klhub_s {			/* HUB */
606*4882a593Smuzhiyun 	klinfo_t	hub_info;
607*4882a593Smuzhiyun 	unsigned int		hub_flags;		/* PCFG_HUB_xxx flags */
608*4882a593Smuzhiyun 	klport_t	hub_port;		/* hub is connected to this */
609*4882a593Smuzhiyun 	nic_t		hub_box_nic;		/* nic of containing box */
610*4882a593Smuzhiyun 	klconf_off_t	hub_mfg_nic;		/* MFG NIC string */
611*4882a593Smuzhiyun 	u64		hub_speed;		/* Speed of hub in HZ */
612*4882a593Smuzhiyun } klhub_t ;
613*4882a593Smuzhiyun 
614*4882a593Smuzhiyun typedef struct klhub_uart_s {			/* HUB */
615*4882a593Smuzhiyun 	klinfo_t	hubuart_info;
616*4882a593Smuzhiyun 	unsigned int		hubuart_flags;		/* PCFG_HUB_xxx flags */
617*4882a593Smuzhiyun 	nic_t		hubuart_box_nic;	/* nic of containing box */
618*4882a593Smuzhiyun } klhub_uart_t ;
619*4882a593Smuzhiyun 
620*4882a593Smuzhiyun #define MEMORY_STRUCT_VERSION	2
621*4882a593Smuzhiyun 
622*4882a593Smuzhiyun typedef struct klmembnk_s {			/* MEMORY BANK */
623*4882a593Smuzhiyun 	klinfo_t	membnk_info;
624*4882a593Smuzhiyun 	short		membnk_memsz;		/* Total memory in megabytes */
625*4882a593Smuzhiyun 	short		membnk_dimm_select; /* bank to physical addr mapping*/
626*4882a593Smuzhiyun 	short		membnk_bnksz[MD_MEM_BANKS]; /* Memory bank sizes */
627*4882a593Smuzhiyun 	short		membnk_attr;
628*4882a593Smuzhiyun } klmembnk_t ;
629*4882a593Smuzhiyun 
630*4882a593Smuzhiyun #define KLCONFIG_MEMBNK_SIZE(_info, _bank)	\
631*4882a593Smuzhiyun 			    ((_info)->membnk_bnksz[(_bank)])
632*4882a593Smuzhiyun 
633*4882a593Smuzhiyun 
634*4882a593Smuzhiyun #define MEMBNK_PREMIUM 1
635*4882a593Smuzhiyun #define KLCONFIG_MEMBNK_PREMIUM(_info, _bank)	\
636*4882a593Smuzhiyun 			    ((_info)->membnk_attr & (MEMBNK_PREMIUM << (_bank)))
637*4882a593Smuzhiyun 
638*4882a593Smuzhiyun #define MAX_SERIAL_NUM_SIZE 10
639*4882a593Smuzhiyun 
640*4882a593Smuzhiyun typedef struct klmod_serial_num_s {
641*4882a593Smuzhiyun       klinfo_t	      snum_info;
642*4882a593Smuzhiyun       union {
643*4882a593Smuzhiyun 	      char snum_str[MAX_SERIAL_NUM_SIZE];
644*4882a593Smuzhiyun 	      unsigned long long       snum_int;
645*4882a593Smuzhiyun       } snum;
646*4882a593Smuzhiyun } klmod_serial_num_t;
647*4882a593Smuzhiyun 
648*4882a593Smuzhiyun /* Macros needed to access serial number structure in lboard_t.
649*4882a593Smuzhiyun    Hard coded values are necessary since we cannot treat
650*4882a593Smuzhiyun    serial number struct as a component without losing compatibility
651*4882a593Smuzhiyun    between prom versions. */
652*4882a593Smuzhiyun 
653*4882a593Smuzhiyun #define GET_SNUM_COMP(_l)	((klmod_serial_num_t *)\
654*4882a593Smuzhiyun 				KLCF_COMP(_l, _l->brd_numcompts))
655*4882a593Smuzhiyun 
656*4882a593Smuzhiyun #define MAX_XBOW_LINKS 16
657*4882a593Smuzhiyun 
658*4882a593Smuzhiyun typedef struct klxbow_s {			   /* XBOW */
659*4882a593Smuzhiyun 	klinfo_t	xbow_info ;
660*4882a593Smuzhiyun 	klport_t	xbow_port_info[MAX_XBOW_LINKS] ; /* Module number */
661*4882a593Smuzhiyun 	int		xbow_master_hub_link;
662*4882a593Smuzhiyun 	/* type of brd connected+component struct ptr+flags */
663*4882a593Smuzhiyun } klxbow_t ;
664*4882a593Smuzhiyun 
665*4882a593Smuzhiyun #define MAX_PCI_SLOTS 8
666*4882a593Smuzhiyun 
667*4882a593Smuzhiyun typedef struct klpci_device_s {
668*4882a593Smuzhiyun 	s32	pci_device_id;	/* 32 bits of vendor/device ID. */
669*4882a593Smuzhiyun 	s32	pci_device_pad; /* 32 bits of padding. */
670*4882a593Smuzhiyun } klpci_device_t;
671*4882a593Smuzhiyun 
672*4882a593Smuzhiyun #define BRIDGE_STRUCT_VERSION	2
673*4882a593Smuzhiyun 
674*4882a593Smuzhiyun typedef struct klbri_s {			  /* BRIDGE */
675*4882a593Smuzhiyun 	klinfo_t	bri_info ;
676*4882a593Smuzhiyun 	unsigned char	bri_eprominfo ;	   /* IO6prom connected to bridge */
677*4882a593Smuzhiyun 	unsigned char	bri_bustype ;	   /* PCI/VME BUS bridge/GIO */
678*4882a593Smuzhiyun 	pci_t		pci_specific  ;	   /* PCI Board config info */
679*4882a593Smuzhiyun 	klpci_device_t	bri_devices[MAX_PCI_DEVS] ;	/* PCI IDs */
680*4882a593Smuzhiyun 	klconf_off_t	bri_mfg_nic ;
681*4882a593Smuzhiyun } klbri_t ;
682*4882a593Smuzhiyun 
683*4882a593Smuzhiyun #define MAX_IOC3_TTY	2
684*4882a593Smuzhiyun 
685*4882a593Smuzhiyun typedef struct klioc3_s {			   /* IOC3 */
686*4882a593Smuzhiyun 	klinfo_t	ioc3_info ;
687*4882a593Smuzhiyun 	unsigned char	ioc3_ssram ;	    /* Info about ssram */
688*4882a593Smuzhiyun 	unsigned char	ioc3_nvram ;	    /* Info about nvram */
689*4882a593Smuzhiyun 	klinfo_t	ioc3_superio ;	    /* Info about superio */
690*4882a593Smuzhiyun 	klconf_off_t	ioc3_tty_off ;
691*4882a593Smuzhiyun 	klinfo_t	ioc3_enet ;
692*4882a593Smuzhiyun 	klconf_off_t	ioc3_enet_off ;
693*4882a593Smuzhiyun 	klconf_off_t	ioc3_kbd_off ;
694*4882a593Smuzhiyun } klioc3_t ;
695*4882a593Smuzhiyun 
696*4882a593Smuzhiyun #define MAX_VME_SLOTS 8
697*4882a593Smuzhiyun 
698*4882a593Smuzhiyun typedef struct klvmeb_s {			   /* VME BRIDGE - PCI CTLR */
699*4882a593Smuzhiyun 	klinfo_t	vmeb_info ;
700*4882a593Smuzhiyun 	vmeb_t		vmeb_specific ;
701*4882a593Smuzhiyun 	klconf_off_t	vmeb_brdinfo[MAX_VME_SLOTS]   ;	   /* VME Board config info */
702*4882a593Smuzhiyun } klvmeb_t ;
703*4882a593Smuzhiyun 
704*4882a593Smuzhiyun typedef struct klvmed_s {			   /* VME DEVICE - VME BOARD */
705*4882a593Smuzhiyun 	klinfo_t	vmed_info ;
706*4882a593Smuzhiyun 	vmed_t		vmed_specific ;
707*4882a593Smuzhiyun 	klconf_off_t	vmed_brdinfo[MAX_VME_SLOTS]   ;	   /* VME Board config info */
708*4882a593Smuzhiyun } klvmed_t ;
709*4882a593Smuzhiyun 
710*4882a593Smuzhiyun #define ROUTER_VECTOR_VERS	2
711*4882a593Smuzhiyun 
712*4882a593Smuzhiyun /* XXX - Don't we need the number of ports here?!? */
713*4882a593Smuzhiyun typedef struct klrou_s {			  /* ROUTER */
714*4882a593Smuzhiyun 	klinfo_t	rou_info ;
715*4882a593Smuzhiyun 	unsigned int		rou_flags ;	      /* PCFG_ROUTER_xxx flags */
716*4882a593Smuzhiyun 	nic_t		rou_box_nic ;	      /* nic of the containing module */
717*4882a593Smuzhiyun 	klport_t	rou_port[MAX_ROUTER_PORTS + 1] ; /* array index 1 to 6 */
718*4882a593Smuzhiyun 	klconf_off_t	rou_mfg_nic ;	  /* MFG NIC string */
719*4882a593Smuzhiyun 	u64	rou_vector;	  /* vector from master node */
720*4882a593Smuzhiyun } klrou_t ;
721*4882a593Smuzhiyun 
722*4882a593Smuzhiyun /*
723*4882a593Smuzhiyun  *  Graphics Controller/Device
724*4882a593Smuzhiyun  *
725*4882a593Smuzhiyun  *  (IP27/IO6) Prom versions 6.13 (and 6.5.1 kernels) and earlier
726*4882a593Smuzhiyun  *  used a couple different structures to store graphics information.
727*4882a593Smuzhiyun  *  For compatibility reasons, the newer data structure preserves some
728*4882a593Smuzhiyun  *  of the layout so that fields that are used in the old versions remain
729*4882a593Smuzhiyun  *  in the same place (with the same info).  Determination of what version
730*4882a593Smuzhiyun  *  of this structure we have is done by checking the cookie field.
731*4882a593Smuzhiyun  */
732*4882a593Smuzhiyun #define KLGFX_COOKIE	0x0c0de000
733*4882a593Smuzhiyun 
734*4882a593Smuzhiyun typedef struct klgfx_s {		/* GRAPHICS Device */
735*4882a593Smuzhiyun 	klinfo_t	gfx_info;
736*4882a593Smuzhiyun 	klconf_off_t	old_gndevs;	/* for compatibility with older proms */
737*4882a593Smuzhiyun 	klconf_off_t	old_gdoff0;	/* for compatibility with older proms */
738*4882a593Smuzhiyun 	unsigned int		cookie;		/* for compatibility with older proms */
739*4882a593Smuzhiyun 	unsigned int		moduleslot;
740*4882a593Smuzhiyun 	struct klgfx_s	*gfx_next_pipe;
741*4882a593Smuzhiyun 	graphics_t	gfx_specific;
742*4882a593Smuzhiyun 	klconf_off_t	pad0;		/* for compatibility with older proms */
743*4882a593Smuzhiyun 	klconf_off_t	gfx_mfg_nic;
744*4882a593Smuzhiyun } klgfx_t;
745*4882a593Smuzhiyun 
746*4882a593Smuzhiyun typedef struct klxthd_s {
747*4882a593Smuzhiyun 	klinfo_t	xthd_info ;
748*4882a593Smuzhiyun 	klconf_off_t	xthd_mfg_nic ;	      /* MFG NIC string */
749*4882a593Smuzhiyun } klxthd_t ;
750*4882a593Smuzhiyun 
751*4882a593Smuzhiyun typedef struct kltpu_s {		     /* TPU board */
752*4882a593Smuzhiyun 	klinfo_t	tpu_info ;
753*4882a593Smuzhiyun 	klconf_off_t	tpu_mfg_nic ;	     /* MFG NIC string */
754*4882a593Smuzhiyun } kltpu_t ;
755*4882a593Smuzhiyun 
756*4882a593Smuzhiyun typedef struct klgsn_s {		     /* GSN board */
757*4882a593Smuzhiyun 	klinfo_t	gsn_info ;
758*4882a593Smuzhiyun 	klconf_off_t	gsn_mfg_nic ;	     /* MFG NIC string */
759*4882a593Smuzhiyun } klgsn_t ;
760*4882a593Smuzhiyun 
761*4882a593Smuzhiyun #define MAX_SCSI_DEVS 16
762*4882a593Smuzhiyun 
763*4882a593Smuzhiyun /*
764*4882a593Smuzhiyun  * NOTE: THis is the max sized kl* structure and is used in klmalloc.c
765*4882a593Smuzhiyun  * to allocate space of type COMPONENT. Make sure that if the size of
766*4882a593Smuzhiyun  * any other component struct becomes more than this, then redefine
767*4882a593Smuzhiyun  * that as the size to be klmalloced.
768*4882a593Smuzhiyun  */
769*4882a593Smuzhiyun 
770*4882a593Smuzhiyun typedef struct klscsi_s {			   /* SCSI Controller */
771*4882a593Smuzhiyun 	klinfo_t	scsi_info ;
772*4882a593Smuzhiyun 	scsi_t		scsi_specific	;
773*4882a593Smuzhiyun 	unsigned char	scsi_numdevs ;
774*4882a593Smuzhiyun 	klconf_off_t	scsi_devinfo[MAX_SCSI_DEVS] ;
775*4882a593Smuzhiyun } klscsi_t ;
776*4882a593Smuzhiyun 
777*4882a593Smuzhiyun typedef struct klscdev_s {			    /* SCSI device */
778*4882a593Smuzhiyun 	klinfo_t	scdev_info ;
779*4882a593Smuzhiyun 	struct scsidisk_data *scdev_cfg ; /* driver fills up this */
780*4882a593Smuzhiyun } klscdev_t ;
781*4882a593Smuzhiyun 
782*4882a593Smuzhiyun typedef struct klttydev_s {			     /* TTY device */
783*4882a593Smuzhiyun 	klinfo_t	ttydev_info ;
784*4882a593Smuzhiyun 	struct terminal_data *ttydev_cfg ; /* driver fills up this */
785*4882a593Smuzhiyun } klttydev_t ;
786*4882a593Smuzhiyun 
787*4882a593Smuzhiyun typedef struct klenetdev_s {			      /* ENET device */
788*4882a593Smuzhiyun 	klinfo_t	enetdev_info ;
789*4882a593Smuzhiyun 	struct net_data *enetdev_cfg ; /* driver fills up this */
790*4882a593Smuzhiyun } klenetdev_t ;
791*4882a593Smuzhiyun 
792*4882a593Smuzhiyun typedef struct klkbddev_s {			     /* KBD device */
793*4882a593Smuzhiyun 	klinfo_t	kbddev_info ;
794*4882a593Smuzhiyun 	struct keyboard_data *kbddev_cfg ; /* driver fills up this */
795*4882a593Smuzhiyun } klkbddev_t ;
796*4882a593Smuzhiyun 
797*4882a593Smuzhiyun typedef struct klmsdev_s {			    /* mouse device */
798*4882a593Smuzhiyun 	klinfo_t	msdev_info ;
799*4882a593Smuzhiyun 	void		*msdev_cfg ;
800*4882a593Smuzhiyun } klmsdev_t ;
801*4882a593Smuzhiyun 
802*4882a593Smuzhiyun #define MAX_FDDI_DEVS 10 /* XXX Is this true */
803*4882a593Smuzhiyun 
804*4882a593Smuzhiyun typedef struct klfddi_s {			   /* FDDI */
805*4882a593Smuzhiyun 	klinfo_t	fddi_info ;
806*4882a593Smuzhiyun 	fddi_t		fddi_specific ;
807*4882a593Smuzhiyun 	klconf_off_t	fddi_devinfo[MAX_FDDI_DEVS] ;
808*4882a593Smuzhiyun } klfddi_t ;
809*4882a593Smuzhiyun 
810*4882a593Smuzhiyun typedef struct klmio_s {			  /* MIO */
811*4882a593Smuzhiyun 	klinfo_t	mio_info ;
812*4882a593Smuzhiyun 	mio_t		mio_specific   ;
813*4882a593Smuzhiyun } klmio_t ;
814*4882a593Smuzhiyun 
815*4882a593Smuzhiyun 
816*4882a593Smuzhiyun typedef union klcomp_s {
817*4882a593Smuzhiyun 	klcpu_t		kc_cpu;
818*4882a593Smuzhiyun 	klhub_t		kc_hub;
819*4882a593Smuzhiyun 	klmembnk_t	kc_mem;
820*4882a593Smuzhiyun 	klxbow_t	kc_xbow;
821*4882a593Smuzhiyun 	klbri_t		kc_bri;
822*4882a593Smuzhiyun 	klioc3_t	kc_ioc3;
823*4882a593Smuzhiyun 	klvmeb_t	kc_vmeb;
824*4882a593Smuzhiyun 	klvmed_t	kc_vmed;
825*4882a593Smuzhiyun 	klrou_t		kc_rou;
826*4882a593Smuzhiyun 	klgfx_t		kc_gfx;
827*4882a593Smuzhiyun 	klscsi_t	kc_scsi;
828*4882a593Smuzhiyun 	klscdev_t	kc_scsi_dev;
829*4882a593Smuzhiyun 	klfddi_t	kc_fddi;
830*4882a593Smuzhiyun 	klmio_t		kc_mio;
831*4882a593Smuzhiyun 	klmod_serial_num_t kc_snum ;
832*4882a593Smuzhiyun } klcomp_t;
833*4882a593Smuzhiyun 
834*4882a593Smuzhiyun typedef union kldev_s {	     /* for device structure allocation */
835*4882a593Smuzhiyun 	klscdev_t	kc_scsi_dev ;
836*4882a593Smuzhiyun 	klttydev_t	kc_tty_dev ;
837*4882a593Smuzhiyun 	klenetdev_t	kc_enet_dev ;
838*4882a593Smuzhiyun 	klkbddev_t	kc_kbd_dev ;
839*4882a593Smuzhiyun } kldev_t ;
840*4882a593Smuzhiyun 
841*4882a593Smuzhiyun /* Data structure interface routines. TBD */
842*4882a593Smuzhiyun 
843*4882a593Smuzhiyun /* Include launch info in this file itself? TBD */
844*4882a593Smuzhiyun 
845*4882a593Smuzhiyun /*
846*4882a593Smuzhiyun  * TBD - Can the ARCS and device driver related info also be included in the
847*4882a593Smuzhiyun  * KLCONFIG area. On the IO4PROM, prom device driver info is part of cfgnode_t
848*4882a593Smuzhiyun  * structure, viz private to the IO4prom.
849*4882a593Smuzhiyun  */
850*4882a593Smuzhiyun 
851*4882a593Smuzhiyun /*
852*4882a593Smuzhiyun  * TBD - Allocation issues.
853*4882a593Smuzhiyun  *
854*4882a593Smuzhiyun  * Do we need to Mark off sepatate heaps for lboard_t, rboard_t, component,
855*4882a593Smuzhiyun  * errinfo and allocate from them, or have a single heap and allocate all
856*4882a593Smuzhiyun  * structures from it. Debug is easier in the former method since we can
857*4882a593Smuzhiyun  * dump all similar structs in one command, but there will be lots of holes,
858*4882a593Smuzhiyun  * in memory and max limits are needed for number of structures.
859*4882a593Smuzhiyun  * Another way to make it organized, is to have a union of all components
860*4882a593Smuzhiyun  * and allocate a aligned chunk of memory greater than the biggest
861*4882a593Smuzhiyun  * component.
862*4882a593Smuzhiyun  */
863*4882a593Smuzhiyun 
864*4882a593Smuzhiyun typedef union {
865*4882a593Smuzhiyun 	lboard_t *lbinfo ;
866*4882a593Smuzhiyun } biptr_t ;
867*4882a593Smuzhiyun 
868*4882a593Smuzhiyun 
869*4882a593Smuzhiyun #define BRI_PER_XBOW 6
870*4882a593Smuzhiyun #define PCI_PER_BRI  8
871*4882a593Smuzhiyun #define DEV_PER_PCI  16
872*4882a593Smuzhiyun 
873*4882a593Smuzhiyun 
874*4882a593Smuzhiyun /* Virtual dipswitch values (starting from switch "7"): */
875*4882a593Smuzhiyun 
876*4882a593Smuzhiyun #define VDS_NOGFX		0x8000	/* Don't enable gfx and autoboot */
877*4882a593Smuzhiyun #define VDS_NOMP		0x100	/* Don't start slave processors */
878*4882a593Smuzhiyun #define VDS_MANUMODE		0x80	/* Manufacturing mode */
879*4882a593Smuzhiyun #define VDS_NOARB		0x40	/* No bootmaster arbitration */
880*4882a593Smuzhiyun #define VDS_PODMODE		0x20	/* Go straight to POD mode */
881*4882a593Smuzhiyun #define VDS_NO_DIAGS		0x10	/* Don't run any diags after BM arb */
882*4882a593Smuzhiyun #define VDS_DEFAULTS		0x08	/* Use default environment values */
883*4882a593Smuzhiyun #define VDS_NOMEMCLEAR		0x04	/* Don't run mem cfg code */
884*4882a593Smuzhiyun #define VDS_2ND_IO4		0x02	/* Boot from the second IO4 */
885*4882a593Smuzhiyun #define VDS_DEBUG_PROM		0x01	/* Print PROM debugging messages */
886*4882a593Smuzhiyun 
887*4882a593Smuzhiyun /* external declarations of Linux kernel functions. */
888*4882a593Smuzhiyun 
889*4882a593Smuzhiyun extern lboard_t *find_lboard(lboard_t *start, unsigned char type);
890*4882a593Smuzhiyun extern klinfo_t *find_component(lboard_t *brd, klinfo_t *kli, unsigned char type);
891*4882a593Smuzhiyun extern klinfo_t *find_first_component(lboard_t *brd, unsigned char type);
892*4882a593Smuzhiyun extern lboard_t *find_lboard_class(lboard_t *start, unsigned char brd_class);
893*4882a593Smuzhiyun 
894*4882a593Smuzhiyun #endif /* _ASM_SN_KLCONFIG_H */
895