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