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