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