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