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