Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * This file is subject to the terms and conditions of the GNU General Public
0003  * License.  See the file "COPYING" in the main directory of this archive
0004  * for more details.
0005  *
0006  * Derived from IRIX <sys/SN/klconfig.h>.
0007  *
0008  * Copyright (C) 1992 - 1997, 1999, 2000 Silicon Graphics, Inc.
0009  * Copyright (C) 1999, 2000 by Ralf Baechle
0010  */
0011 #ifndef _ASM_SN_KLCONFIG_H
0012 #define _ASM_SN_KLCONFIG_H
0013 
0014 /*
0015  * The KLCONFIG structures store info about the various BOARDs found
0016  * during Hardware Discovery. In addition, it stores info about the
0017  * components found on the BOARDs.
0018  */
0019 
0020 /*
0021  * WARNING:
0022  *  Certain assembly language routines (notably xxxxx.s) in the IP27PROM
0023  *  will depend on the format of the data structures in this file.  In
0024  *  most cases, rearranging the fields can seriously break things.
0025  *  Adding fields in the beginning or middle can also break things.
0026  *  Add fields if necessary, to the end of a struct in such a way
0027  *  that offsets of existing fields do not change.
0028  */
0029 
0030 #include <linux/types.h>
0031 #include <asm/sn/types.h>
0032 
0033 #if defined(CONFIG_SGI_IP27)
0034 
0035 #include <asm/sn/sn0/addrs.h>
0036 //#include <sys/SN/router.h>
0037 // XXX Stolen from <sys/SN/router.h>:
0038 #define MAX_ROUTER_PORTS (6)    /* Max. number of ports on a router */
0039 #include <asm/sn/fru.h>
0040 //#include <sys/graph.h>
0041 //#include <sys/xtalk/xbow.h>
0042 
0043 #elif defined(CONFIG_SGI_IP35)
0044 
0045 #include <asm/sn/sn1/addrs.h>
0046 #include <sys/sn/router.h>
0047 #include <sys/graph.h>
0048 #include <asm/xtalk/xbow.h>
0049 
0050 #endif /* !CONFIG_SGI_IP27 && !CONFIG_SGI_IP35 */
0051 
0052 #if defined(CONFIG_SGI_IP27) || defined(CONFIG_SGI_IP35)
0053 #include <asm/sn/agent.h>
0054 #include <asm/fw/arc/types.h>
0055 #include <asm/fw/arc/hinv.h>
0056 #if defined(CONFIG_SGI_IP35)
0057 // The hack file has to be before vector and after sn0_fru....
0058 #include <asm/hack.h>
0059 #include <asm/sn/vector.h>
0060 #include <asm/xtalk/xtalk.h>
0061 #endif /* CONFIG_SGI_IP35 */
0062 #endif /* CONFIG_SGI_IP27 || CONFIG_SGI_IP35 */
0063 
0064 typedef u64  nic_t;
0065 
0066 #define KLCFGINFO_MAGIC 0xbeedbabe
0067 
0068 typedef s32 klconf_off_t;
0069 
0070 /*
0071  * Some IMPORTANT OFFSETS. These are the offsets on all NODES.
0072  */
0073 #define MAX_MODULE_ID       255
0074 #define SIZE_PAD        4096 /* 4k padding for structures */
0075 /*
0076  * 1 NODE brd, 2 Router brd (1 8p, 1 meta), 6 Widgets,
0077  * 2 Midplanes assuming no pci card cages
0078  */
0079 #define MAX_SLOTS_PER_NODE  (1 + 2 + 6 + 2)
0080 
0081 /* XXX if each node is guaranteed to have some memory */
0082 
0083 #define MAX_PCI_DEVS        8
0084 
0085 /* lboard_t->brd_flags fields */
0086 /* All bits in this field are currently used. Try the pad fields if
0087    you need more flag bits */
0088 
0089 #define ENABLE_BOARD        0x01
0090 #define FAILED_BOARD        0x02
0091 #define DUPLICATE_BOARD     0x04    /* Boards like midplanes/routers which
0092                        are discovered twice. Use one of them */
0093 #define VISITED_BOARD       0x08    /* Used for compact hub numbering. */
0094 #define LOCAL_MASTER_IO6    0x10    /* master io6 for that node */
0095 #define GLOBAL_MASTER_IO6   0x20
0096 #define THIRD_NIC_PRESENT   0x40    /* for future use */
0097 #define SECOND_NIC_PRESENT  0x80    /* addons like MIO are present */
0098 
0099 /* klinfo->flags fields */
0100 
0101 #define KLINFO_ENABLE       0x01    /* This component is enabled */
0102 #define KLINFO_FAILED       0x02    /* This component failed */
0103 #define KLINFO_DEVICE       0x04    /* This component is a device */
0104 #define KLINFO_VISITED      0x08    /* This component has been visited */
0105 #define KLINFO_CONTROLLER   0x10    /* This component is a device controller */
0106 #define KLINFO_INSTALL      0x20    /* Install a driver */
0107 #define KLINFO_HEADLESS     0x40    /* Headless (or hubless) component */
0108 #define IS_CONSOLE_IOC3(i)  ((((klinfo_t *)i)->flags) & KLINFO_INSTALL)
0109 
0110 #define GB2     0x80000000
0111 
0112 #define MAX_RSV_PTRS    32
0113 
0114 /* Structures to manage various data storage areas */
0115 /* The numbers must be contiguous since the array index i
0116    is used in the code to allocate various areas.
0117 */
0118 
0119 #define BOARD_STRUCT        0
0120 #define COMPONENT_STRUCT    1
0121 #define ERRINFO_STRUCT      2
0122 #define KLMALLOC_TYPE_MAX   (ERRINFO_STRUCT + 1)
0123 #define DEVICE_STRUCT       3
0124 
0125 
0126 typedef struct console_s {
0127     unsigned long   uart_base;
0128     unsigned long   config_base;
0129     unsigned long   memory_base;
0130     short       baud;
0131     short       flag;
0132     int     type;
0133     nasid_t     nasid;
0134     char        wid;
0135     char        npci;
0136     nic_t       baseio_nic;
0137 } console_t;
0138 
0139 typedef struct klc_malloc_hdr {
0140     klconf_off_t km_base;
0141     klconf_off_t km_limit;
0142     klconf_off_t km_current;
0143 } klc_malloc_hdr_t;
0144 
0145 /* Functions/macros needed to use this structure */
0146 
0147 typedef struct kl_config_hdr {
0148     u64     ch_magic;   /* set this to KLCFGINFO_MAGIC */
0149     u32     ch_version;    /* structure version number */
0150     klconf_off_t    ch_malloc_hdr_off; /* offset of ch_malloc_hdr */
0151     klconf_off_t    ch_cons_off;       /* offset of ch_cons */
0152     klconf_off_t    ch_board_info;  /* the link list of boards */
0153     console_t   ch_cons_info;   /* address info of the console */
0154     klc_malloc_hdr_t ch_malloc_hdr[KLMALLOC_TYPE_MAX];
0155     confidence_t    ch_sw_belief;   /* confidence that software is bad*/
0156     confidence_t    ch_sn0net_belief; /* confidence that sn0net is bad */
0157 } kl_config_hdr_t;
0158 
0159 
0160 #define KL_CONFIG_HDR(_nasid)   ((kl_config_hdr_t *)(KLCONFIG_ADDR(_nasid)))
0161 #define KL_CONFIG_INFO_OFFSET(_nasid)                   \
0162     (KL_CONFIG_HDR(_nasid)->ch_board_info)
0163 #define KL_CONFIG_INFO_SET_OFFSET(_nasid, _off)             \
0164     (KL_CONFIG_HDR(_nasid)->ch_board_info = (_off))
0165 
0166 #define KL_CONFIG_INFO(_nasid)                      \
0167     (lboard_t *)((KL_CONFIG_HDR(_nasid)->ch_board_info) ?       \
0168      NODE_OFFSET_TO_K1((_nasid), KL_CONFIG_HDR(_nasid)->ch_board_info) : \
0169      0)
0170 #define KL_CONFIG_MAGIC(_nasid)     (KL_CONFIG_HDR(_nasid)->ch_magic)
0171 
0172 #define KL_CONFIG_CHECK_MAGIC(_nasid)                   \
0173     (KL_CONFIG_HDR(_nasid)->ch_magic == KLCFGINFO_MAGIC)
0174 
0175 #define KL_CONFIG_HDR_INIT_MAGIC(_nasid)    \
0176           (KL_CONFIG_HDR(_nasid)->ch_magic = KLCFGINFO_MAGIC)
0177 
0178 /* --- New Macros for the changed kl_config_hdr_t structure --- */
0179 
0180 #define PTR_CH_MALLOC_HDR(_k)   ((klc_malloc_hdr_t *)\
0181             ((unsigned long)_k + (_k->ch_malloc_hdr_off)))
0182 
0183 #define KL_CONFIG_CH_MALLOC_HDR(_n)   PTR_CH_MALLOC_HDR(KL_CONFIG_HDR(_n))
0184 
0185 #define PTR_CH_CONS_INFO(_k)    ((console_t *)\
0186             ((unsigned long)_k + (_k->ch_cons_off)))
0187 
0188 #define KL_CONFIG_CH_CONS_INFO(_n)   PTR_CH_CONS_INFO(KL_CONFIG_HDR(_n))
0189 
0190 /* ------------------------------------------------------------- */
0191 
0192 #define KL_CONFIG_INFO_START(_nasid)    \
0193     (klconf_off_t)(KLCONFIG_OFFSET(_nasid) + sizeof(kl_config_hdr_t))
0194 
0195 #define KL_CONFIG_BOARD_NASID(_brd) ((_brd)->brd_nasid)
0196 #define KL_CONFIG_BOARD_SET_NEXT(_brd, _off)    ((_brd)->brd_next = (_off))
0197 
0198 #define KL_CONFIG_DUPLICATE_BOARD(_brd) ((_brd)->brd_flags & DUPLICATE_BOARD)
0199 
0200 #define XBOW_PORT_TYPE_HUB(_xbowp, _link)   \
0201            ((_xbowp)->xbow_port_info[(_link) - BASE_XBOW_PORT].port_flag & XBOW_PORT_HUB)
0202 #define XBOW_PORT_TYPE_IO(_xbowp, _link)    \
0203            ((_xbowp)->xbow_port_info[(_link) - BASE_XBOW_PORT].port_flag & XBOW_PORT_IO)
0204 
0205 #define XBOW_PORT_IS_ENABLED(_xbowp, _link) \
0206            ((_xbowp)->xbow_port_info[(_link) - BASE_XBOW_PORT].port_flag & XBOW_PORT_ENABLE)
0207 #define XBOW_PORT_NASID(_xbowp, _link)  \
0208            ((_xbowp)->xbow_port_info[(_link) - BASE_XBOW_PORT].port_nasid)
0209 
0210 #define XBOW_PORT_IO     0x1
0211 #define XBOW_PORT_HUB    0x2
0212 #define XBOW_PORT_ENABLE 0x4
0213 
0214 #define SN0_PORT_FENCE_SHFT 0
0215 #define SN0_PORT_FENCE_MASK (1 << SN0_PORT_FENCE_SHFT)
0216 
0217 /*
0218  * The KLCONFIG area is organized as a LINKED LIST of BOARDs. A BOARD
0219  * can be either 'LOCAL' or 'REMOTE'. LOCAL means it is attached to
0220  * the LOCAL/current NODE. REMOTE means it is attached to a different
0221  * node.(TBD - Need a way to treat ROUTER boards.)
0222  *
0223  * There are 2 different structures to represent these boards -
0224  * lboard - Local board, rboard - remote board. These 2 structures
0225  * can be arbitrarily mixed in the LINKED LIST of BOARDs. (Refer
0226  * Figure below). The first byte of the rboard or lboard structure
0227  * is used to find out its type - no unions are used.
0228  * If it is a lboard, then the config info of this board will be found
0229  * on the local node. (LOCAL NODE BASE + offset value gives pointer to
0230  * the structure.
0231  * If it is a rboard, the local structure contains the node number
0232  * and the offset of the beginning of the LINKED LIST on the remote node.
0233  * The details of the hardware on a remote node can be built locally,
0234  * if required, by reading the LINKED LIST on the remote node and
0235  * ignoring all the rboards on that node.
0236  *
0237  * The local node uses the REMOTE NODE NUMBER + OFFSET to point to the
0238  * First board info on the remote node. The remote node list is
0239  * traversed as the local list, using the REMOTE BASE ADDRESS and not
0240  * the local base address and ignoring all rboard values.
0241  *
0242  *
0243  KLCONFIG
0244 
0245  +------------+      +------------+  +------------+      +------------+
0246  |  lboard    |  +-->|   lboard   |  +-->|   rboard   |  +-->|   lboard   |
0247  +------------+  |   +------------+  |   +------------+  |   +------------+
0248  | board info |  |   | board info |  |   |errinfo,bptr|  |   | board info |
0249  +------------+  |   +------------+  |   +------------+  |   +------------+
0250  | offset     |--+   |  offset    |--+   |  offset    |--+   |offset=NULL |
0251  +------------+      +------------+  +------------+      +------------+
0252 
0253 
0254  +------------+
0255  | board info |
0256  +------------+       +--------------------------------+
0257  | compt 1    |------>| type, rev, diaginfo, size ...  |  (CPU)
0258  +------------+       +--------------------------------+
0259  | compt 2    |--+
0260  +------------+  |    +--------------------------------+
0261  |  ...       |  +--->| type, rev, diaginfo, size ...  |  (MEM_BANK)
0262  +------------+       +--------------------------------+
0263  | errinfo    |--+
0264  +------------+  |    +--------------------------------+
0265          +--->|r/l brd errinfo,compt err flags |
0266               +--------------------------------+
0267 
0268  *
0269  * Each BOARD consists of COMPONENTs and the BOARD structure has
0270  * pointers (offsets) to its COMPONENT structure.
0271  * The COMPONENT structure has version info, size and speed info, revision,
0272  * error info and the NIC info. This structure can accommodate any
0273  * BOARD with arbitrary COMPONENT composition.
0274  *
0275  * The ERRORINFO part of each BOARD has error information
0276  * that describes errors about the BOARD itself. It also has flags to
0277  * indicate the COMPONENT(s) on the board that have errors. The error
0278  * information specific to the COMPONENT is present in the respective
0279  * COMPONENT structure.
0280  *
0281  * The ERRORINFO structure is also treated like a COMPONENT, ie. the
0282  * BOARD has pointers(offset) to the ERRORINFO structure. The rboard
0283  * structure also has a pointer to the ERRORINFO structure. This is
0284  * the place to store ERRORINFO about a REMOTE NODE, if the HUB on
0285  * that NODE is not working or if the REMOTE MEMORY is BAD. In cases where
0286  * only the CPU of the REMOTE NODE is disabled, the ERRORINFO pointer can
0287  * be a NODE NUMBER, REMOTE OFFSET combination, pointing to error info
0288  * which is present on the REMOTE NODE.(TBD)
0289  * REMOTE ERRINFO can be stored on any of the nearest nodes
0290  * or on all the nearest nodes.(TBD)
0291  * Like BOARD structures, REMOTE ERRINFO structures can be built locally
0292  * using the rboard errinfo pointer.
0293  *
0294  * In order to get useful information from this Data organization, a set of
0295  * interface routines are provided (TBD). The important thing to remember while
0296  * manipulating the structures, is that, the NODE number information should
0297  * be used. If the NODE is non-zero (remote) then each offset should
0298  * be added to the REMOTE BASE ADDR else it should be added to the LOCAL BASE ADDR.
0299  * This includes offsets for BOARDS, COMPONENTS and ERRORINFO.
0300  *
0301  * Note that these structures do not provide much info about connectivity.
0302  * That info will be part of HWGRAPH, which is an extension of the cfg_t
0303  * data structure. (ref IP27prom/cfg.h) It has to be extended to include
0304  * the IO part of the Network(TBD).
0305  *
0306  * The data structures below define the above concepts.
0307  */
0308 
0309 /*
0310  * Values for CPU types
0311  */
0312 #define KL_CPU_R4000        0x1 /* Standard R4000 */
0313 #define KL_CPU_TFP      0x2 /* TFP processor */
0314 #define KL_CPU_R10000       0x3 /* R10000 (T5) */
0315 #define KL_CPU_NONE     (-1)    /* no cpu present in slot */
0316 
0317 /*
0318  * IP27 BOARD classes
0319  */
0320 
0321 #define KLCLASS_MASK    0xf0
0322 #define KLCLASS_NONE    0x00
0323 #define KLCLASS_NODE    0x10         /* CPU, Memory and HUB board */
0324 #define KLCLASS_CPU KLCLASS_NODE
0325 #define KLCLASS_IO  0x20         /* BaseIO, 4 ch SCSI, ethernet, FDDI
0326                         and the non-graphics widget boards */
0327 #define KLCLASS_ROUTER  0x30         /* Router board */
0328 #define KLCLASS_MIDPLANE 0x40        /* We need to treat this as a board
0329                         so that we can record error info */
0330 #define KLCLASS_GFX 0x50        /* graphics boards */
0331 
0332 #define KLCLASS_PSEUDO_GFX  0x60    /* HDTV type cards that use a gfx
0333                      * hw ifc to xtalk and are not gfx
0334                      * class for sw purposes */
0335 
0336 #define KLCLASS_MAX 7       /* Bump this if a new CLASS is added */
0337 #define KLTYPE_MAX  10      /* Bump this if a new CLASS is added */
0338 
0339 #define KLCLASS_UNKNOWN 0xf0
0340 
0341 #define KLCLASS(_x) ((_x) & KLCLASS_MASK)
0342 
0343 /*
0344  * IP27 board types
0345  */
0346 
0347 #define KLTYPE_MASK 0x0f
0348 #define KLTYPE_NONE 0x00
0349 #define KLTYPE_EMPTY    0x00
0350 
0351 #define KLTYPE_WEIRDCPU (KLCLASS_CPU | 0x0)
0352 #define KLTYPE_IP27 (KLCLASS_CPU | 0x1) /* 2 CPUs(R10K) per board */
0353 
0354 #define KLTYPE_WEIRDIO  (KLCLASS_IO  | 0x0)
0355 #define KLTYPE_BASEIO   (KLCLASS_IO  | 0x1) /* IOC3, SuperIO, Bridge, SCSI */
0356 #define KLTYPE_IO6  KLTYPE_BASEIO       /* Additional name */
0357 #define KLTYPE_4CHSCSI  (KLCLASS_IO  | 0x2)
0358 #define KLTYPE_MSCSI    KLTYPE_4CHSCSI      /* Additional name */
0359 #define KLTYPE_ETHERNET (KLCLASS_IO  | 0x3)
0360 #define KLTYPE_MENET    KLTYPE_ETHERNET     /* Additional name */
0361 #define KLTYPE_FDDI (KLCLASS_IO  | 0x4)
0362 #define KLTYPE_UNUSED   (KLCLASS_IO  | 0x5) /* XXX UNUSED */
0363 #define KLTYPE_HAROLD   (KLCLASS_IO  | 0x6) /* PCI SHOE BOX */
0364 #define KLTYPE_PCI  KLTYPE_HAROLD
0365 #define KLTYPE_VME  (KLCLASS_IO  | 0x7) /* Any 3rd party VME card */
0366 #define KLTYPE_MIO  (KLCLASS_IO  | 0x8)
0367 #define KLTYPE_FC   (KLCLASS_IO  | 0x9)
0368 #define KLTYPE_LINC (KLCLASS_IO  | 0xA)
0369 #define KLTYPE_TPU  (KLCLASS_IO  | 0xB) /* Tensor Processing Unit */
0370 #define KLTYPE_GSN_A    (KLCLASS_IO  | 0xC) /* Main GSN board */
0371 #define KLTYPE_GSN_B    (KLCLASS_IO  | 0xD) /* Auxiliary GSN board */
0372 
0373 #define KLTYPE_GFX  (KLCLASS_GFX | 0x0) /* unknown graphics type */
0374 #define KLTYPE_GFX_KONA (KLCLASS_GFX | 0x1) /* KONA graphics on IP27 */
0375 #define KLTYPE_GFX_MGRA (KLCLASS_GFX | 0x3) /* MGRAS graphics on IP27 */
0376 
0377 #define KLTYPE_WEIRDROUTER (KLCLASS_ROUTER | 0x0)
0378 #define KLTYPE_ROUTER     (KLCLASS_ROUTER | 0x1)
0379 #define KLTYPE_ROUTER2    KLTYPE_ROUTER     /* Obsolete! */
0380 #define KLTYPE_NULL_ROUTER (KLCLASS_ROUTER | 0x2)
0381 #define KLTYPE_META_ROUTER (KLCLASS_ROUTER | 0x3)
0382 
0383 #define KLTYPE_WEIRDMIDPLANE (KLCLASS_MIDPLANE | 0x0)
0384 #define KLTYPE_MIDPLANE8  (KLCLASS_MIDPLANE | 0x1) /* 8 slot backplane */
0385 #define KLTYPE_MIDPLANE    KLTYPE_MIDPLANE8
0386 #define KLTYPE_PBRICK_XBOW  (KLCLASS_MIDPLANE | 0x2)
0387 
0388 #define KLTYPE_IOBRICK      (KLCLASS_IOBRICK | 0x0)
0389 #define KLTYPE_IBRICK       (KLCLASS_IOBRICK | 0x1)
0390 #define KLTYPE_PBRICK       (KLCLASS_IOBRICK | 0x2)
0391 #define KLTYPE_XBRICK       (KLCLASS_IOBRICK | 0x3)
0392 
0393 #define KLTYPE_PBRICK_BRIDGE    KLTYPE_PBRICK
0394 
0395 /* The value of type should be more than 8 so that hinv prints
0396  * out the board name from the NIC string. For values less than
0397  * 8 the name of the board needs to be hard coded in a few places.
0398  * When bringup started nic names had not standardized and so we
0399  * had to hard code. (For people interested in history.)
0400  */
0401 #define KLTYPE_XTHD (KLCLASS_PSEUDO_GFX | 0x9)
0402 
0403 #define KLTYPE_UNKNOWN  (KLCLASS_UNKNOWN | 0xf)
0404 
0405 #define KLTYPE(_x)  ((_x) & KLTYPE_MASK)
0406 #define IS_MIO_PRESENT(l)   ((l->brd_type == KLTYPE_BASEIO) && \
0407                  (l->brd_flags & SECOND_NIC_PRESENT))
0408 #define IS_MIO_IOC3(l, n)   (IS_MIO_PRESENT(l) && (n > 2))
0409 
0410 /*
0411  * board structures
0412  */
0413 
0414 #define MAX_COMPTS_PER_BRD 24
0415 
0416 #define LOCAL_BOARD 1
0417 #define REMOTE_BOARD 2
0418 
0419 #define LBOARD_STRUCT_VERSION   2
0420 
0421 typedef struct lboard_s {
0422     klconf_off_t    brd_next;     /* Next BOARD */
0423     unsigned char   struct_type;      /* type of structure, local or remote */
0424     unsigned char   brd_type;     /* type+class */
0425     unsigned char   brd_sversion;     /* version of this structure */
0426     unsigned char   brd_brevision;    /* board revision */
0427     unsigned char   brd_promver;      /* board prom version, if any */
0428     unsigned char   brd_flags;    /* Enabled, Disabled etc */
0429     unsigned char   brd_slot;     /* slot number */
0430     unsigned short  brd_debugsw;      /* Debug switches */
0431     moduleid_t  brd_module;   /* module to which it belongs */
0432     partid_t    brd_partition;    /* Partition number */
0433     unsigned short  brd_diagval;      /* diagnostic value */
0434     unsigned short  brd_diagparm;     /* diagnostic parameter */
0435     unsigned char   brd_inventory;    /* inventory history */
0436     unsigned char   brd_numcompts;    /* Number of components */
0437     nic_t       brd_nic;      /* Number in CAN */
0438     nasid_t     brd_nasid;    /* passed parameter */
0439     klconf_off_t    brd_compts[MAX_COMPTS_PER_BRD]; /* pointers to COMPONENTS */
0440     klconf_off_t    brd_errinfo;      /* Board's error information */
0441     struct lboard_s *brd_parent;      /* Logical parent for this brd */
0442     vertex_hdl_t    brd_graph_link;   /* vertex hdl to connect extern compts */
0443     confidence_t    brd_confidence;   /* confidence that the board is bad */
0444     nasid_t     brd_owner;    /* who owns this board */
0445     unsigned char   brd_nic_flags;    /* To handle 8 more NICs */
0446     char        brd_name[32];
0447 } lboard_t;
0448 
0449 
0450 /*
0451  *  Make sure we pass back the calias space address for local boards.
0452  *  klconfig board traversal and error structure extraction defines.
0453  */
0454 
0455 #define BOARD_SLOT(_brd)    ((_brd)->brd_slot)
0456 
0457 #define KLCF_CLASS(_brd)    KLCLASS((_brd)->brd_type)
0458 #define KLCF_TYPE(_brd)     KLTYPE((_brd)->brd_type)
0459 #define KLCF_REMOTE(_brd)   (((_brd)->struct_type & LOCAL_BOARD) ? 0 : 1)
0460 #define KLCF_NUM_COMPS(_brd)    ((_brd)->brd_numcompts)
0461 #define KLCF_MODULE_ID(_brd)    ((_brd)->brd_module)
0462 
0463 #define KLCF_NEXT(_brd)     \
0464     ((_brd)->brd_next ? \
0465      (lboard_t *)(NODE_OFFSET_TO_K1(NASID_GET(_brd), (_brd)->brd_next)):\
0466      NULL)
0467 #define KLCF_COMP(_brd, _ndx)   \
0468         (klinfo_t *)(NODE_OFFSET_TO_K1(NASID_GET(_brd), \
0469                            (_brd)->brd_compts[(_ndx)]))
0470 
0471 #define KLCF_COMP_ERROR(_brd, _comp)    \
0472            (NODE_OFFSET_TO_K1(NASID_GET(_brd), (_comp)->errinfo))
0473 
0474 #define KLCF_COMP_TYPE(_comp)   ((_comp)->struct_type)
0475 #define KLCF_BRIDGE_W_ID(_comp) ((_comp)->physid)   /* Widget ID */
0476 
0477 
0478 
0479 /*
0480  * Generic info structure. This stores common info about a
0481  * component.
0482  */
0483 
0484 typedef struct klinfo_s {          /* Generic info */
0485     unsigned char   struct_type;       /* type of this structure */
0486     unsigned char   struct_version;    /* version of this structure */
0487     unsigned char   flags;        /* Enabled, disabled etc */
0488     unsigned char   revision;     /* component revision */
0489     unsigned short  diagval;      /* result of diagnostics */
0490     unsigned short  diagparm;     /* diagnostic parameter */
0491     unsigned char   inventory;    /* previous inventory status */
0492     nic_t       nic;          /* MUst be aligned properly */
0493     unsigned char   physid;       /* physical id of component */
0494     unsigned int    virtid;       /* virtual id as seen by system */
0495     unsigned char   widid;        /* Widget id - if applicable */
0496     nasid_t     nasid;        /* node number - from parent */
0497     char        pad1;         /* pad out structure. */
0498     char        pad2;         /* pad out structure. */
0499     COMPONENT   *arcs_compt;      /* ptr to the arcs struct for ease*/
0500     klconf_off_t    errinfo;      /* component specific errors */
0501     unsigned short  pad3;         /* pci fields have moved over to */
0502     unsigned short  pad4;         /* klbri_t */
0503 } klinfo_t ;
0504 
0505 #define KLCONFIG_INFO_ENABLED(_i)   ((_i)->flags & KLINFO_ENABLE)
0506 /*
0507  * Component structures.
0508  * Following are the currently identified components:
0509  *  CPU, HUB, MEM_BANK,
0510  *  XBOW(consists of 16 WIDGETs, each of which can be HUB or GRAPHICS or BRIDGE)
0511  *  BRIDGE, IOC3, SuperIO, SCSI, FDDI
0512  *  ROUTER
0513  *  GRAPHICS
0514  */
0515 #define KLSTRUCT_UNKNOWN    0
0516 #define KLSTRUCT_CPU        1
0517 #define KLSTRUCT_HUB        2
0518 #define KLSTRUCT_MEMBNK     3
0519 #define KLSTRUCT_XBOW       4
0520 #define KLSTRUCT_BRI        5
0521 #define KLSTRUCT_IOC3       6
0522 #define KLSTRUCT_PCI        7
0523 #define KLSTRUCT_VME        8
0524 #define KLSTRUCT_ROU        9
0525 #define KLSTRUCT_GFX        10
0526 #define KLSTRUCT_SCSI       11
0527 #define KLSTRUCT_FDDI       12
0528 #define KLSTRUCT_MIO        13
0529 #define KLSTRUCT_DISK       14
0530 #define KLSTRUCT_TAPE       15
0531 #define KLSTRUCT_CDROM      16
0532 #define KLSTRUCT_HUB_UART   17
0533 #define KLSTRUCT_IOC3ENET   18
0534 #define KLSTRUCT_IOC3UART   19
0535 #define KLSTRUCT_UNUSED     20 /* XXX UNUSED */
0536 #define KLSTRUCT_IOC3PCKM   21
0537 #define KLSTRUCT_RAD        22
0538 #define KLSTRUCT_HUB_TTY    23
0539 #define KLSTRUCT_IOC3_TTY   24
0540 
0541 /* Early Access IO proms are compatible
0542    only with KLSTRUCT values up to 24. */
0543 
0544 #define KLSTRUCT_FIBERCHANNEL   25
0545 #define KLSTRUCT_MOD_SERIAL_NUM 26
0546 #define KLSTRUCT_IOC3MS     27
0547 #define KLSTRUCT_TPU        28
0548 #define KLSTRUCT_GSN_A      29
0549 #define KLSTRUCT_GSN_B      30
0550 #define KLSTRUCT_XTHD       31
0551 
0552 /*
0553  * These are the indices of various components within a lboard structure.
0554  */
0555 
0556 #define IP27_CPU0_INDEX 0
0557 #define IP27_CPU1_INDEX 1
0558 #define IP27_HUB_INDEX 2
0559 #define IP27_MEM_INDEX 3
0560 
0561 #define BASEIO_BRIDGE_INDEX 0
0562 #define BASEIO_IOC3_INDEX 1
0563 #define BASEIO_SCSI1_INDEX 2
0564 #define BASEIO_SCSI2_INDEX 3
0565 
0566 #define MIDPLANE_XBOW_INDEX 0
0567 #define ROUTER_COMPONENT_INDEX 0
0568 
0569 #define CH4SCSI_BRIDGE_INDEX 0
0570 
0571 /* Info holders for various hardware components */
0572 
0573 typedef u64 *pci_t;
0574 typedef u64 *vmeb_t;
0575 typedef u64 *vmed_t;
0576 typedef u64 *fddi_t;
0577 typedef u64 *scsi_t;
0578 typedef u64 *mio_t;
0579 typedef u64 *graphics_t;
0580 typedef u64 *router_t;
0581 
0582 /*
0583  * The port info in ip27_cfg area translates to a lboart_t in the
0584  * KLCONFIG area. But since KLCONFIG does not use pointers, lboart_t
0585  * is stored in terms of a nasid and a offset from start of KLCONFIG
0586  * area  on that nasid.
0587  */
0588 typedef struct klport_s {
0589     nasid_t     port_nasid;
0590     unsigned char   port_flag;
0591     klconf_off_t    port_offset;
0592 } klport_t;
0593 
0594 typedef struct klcpu_s {              /* CPU */
0595     klinfo_t    cpu_info;
0596     unsigned short  cpu_prid;   /* Processor PRID value */
0597     unsigned short  cpu_fpirr;  /* FPU IRR value */
0598     unsigned short  cpu_speed;  /* Speed in MHZ */
0599     unsigned short  cpu_scachesz;   /* secondary cache size in MB */
0600     unsigned short  cpu_scachespeed;/* secondary cache speed in MHz */
0601 } klcpu_t ;
0602 
0603 #define CPU_STRUCT_VERSION   2
0604 
0605 typedef struct klhub_s {            /* HUB */
0606     klinfo_t    hub_info;
0607     unsigned int        hub_flags;      /* PCFG_HUB_xxx flags */
0608     klport_t    hub_port;       /* hub is connected to this */
0609     nic_t       hub_box_nic;        /* nic of containing box */
0610     klconf_off_t    hub_mfg_nic;        /* MFG NIC string */
0611     u64     hub_speed;      /* Speed of hub in HZ */
0612 } klhub_t ;
0613 
0614 typedef struct klhub_uart_s {           /* HUB */
0615     klinfo_t    hubuart_info;
0616     unsigned int        hubuart_flags;      /* PCFG_HUB_xxx flags */
0617     nic_t       hubuart_box_nic;    /* nic of containing box */
0618 } klhub_uart_t ;
0619 
0620 #define MEMORY_STRUCT_VERSION   2
0621 
0622 typedef struct klmembnk_s {         /* MEMORY BANK */
0623     klinfo_t    membnk_info;
0624     short       membnk_memsz;       /* Total memory in megabytes */
0625     short       membnk_dimm_select; /* bank to physical addr mapping*/
0626     short       membnk_bnksz[MD_MEM_BANKS]; /* Memory bank sizes */
0627     short       membnk_attr;
0628 } klmembnk_t ;
0629 
0630 #define KLCONFIG_MEMBNK_SIZE(_info, _bank)  \
0631                 ((_info)->membnk_bnksz[(_bank)])
0632 
0633 
0634 #define MEMBNK_PREMIUM 1
0635 #define KLCONFIG_MEMBNK_PREMIUM(_info, _bank)   \
0636                 ((_info)->membnk_attr & (MEMBNK_PREMIUM << (_bank)))
0637 
0638 #define MAX_SERIAL_NUM_SIZE 10
0639 
0640 typedef struct klmod_serial_num_s {
0641       klinfo_t        snum_info;
0642       union {
0643           char snum_str[MAX_SERIAL_NUM_SIZE];
0644           unsigned long long       snum_int;
0645       } snum;
0646 } klmod_serial_num_t;
0647 
0648 /* Macros needed to access serial number structure in lboard_t.
0649    Hard coded values are necessary since we cannot treat
0650    serial number struct as a component without losing compatibility
0651    between prom versions. */
0652 
0653 #define GET_SNUM_COMP(_l)   ((klmod_serial_num_t *)\
0654                 KLCF_COMP(_l, _l->brd_numcompts))
0655 
0656 #define MAX_XBOW_LINKS 16
0657 
0658 typedef struct klxbow_s {              /* XBOW */
0659     klinfo_t    xbow_info ;
0660     klport_t    xbow_port_info[MAX_XBOW_LINKS] ; /* Module number */
0661     int     xbow_master_hub_link;
0662     /* type of brd connected+component struct ptr+flags */
0663 } klxbow_t ;
0664 
0665 #define MAX_PCI_SLOTS 8
0666 
0667 typedef struct klpci_device_s {
0668     s32 pci_device_id;  /* 32 bits of vendor/device ID. */
0669     s32 pci_device_pad; /* 32 bits of padding. */
0670 } klpci_device_t;
0671 
0672 #define BRIDGE_STRUCT_VERSION   2
0673 
0674 typedef struct klbri_s {              /* BRIDGE */
0675     klinfo_t    bri_info ;
0676     unsigned char   bri_eprominfo ;    /* IO6prom connected to bridge */
0677     unsigned char   bri_bustype ;      /* PCI/VME BUS bridge/GIO */
0678     pci_t       pci_specific  ;    /* PCI Board config info */
0679     klpci_device_t  bri_devices[MAX_PCI_DEVS] ; /* PCI IDs */
0680     klconf_off_t    bri_mfg_nic ;
0681 } klbri_t ;
0682 
0683 #define MAX_IOC3_TTY    2
0684 
0685 typedef struct klioc3_s {              /* IOC3 */
0686     klinfo_t    ioc3_info ;
0687     unsigned char   ioc3_ssram ;        /* Info about ssram */
0688     unsigned char   ioc3_nvram ;        /* Info about nvram */
0689     klinfo_t    ioc3_superio ;      /* Info about superio */
0690     klconf_off_t    ioc3_tty_off ;
0691     klinfo_t    ioc3_enet ;
0692     klconf_off_t    ioc3_enet_off ;
0693     klconf_off_t    ioc3_kbd_off ;
0694 } klioc3_t ;
0695 
0696 #define MAX_VME_SLOTS 8
0697 
0698 typedef struct klvmeb_s {              /* VME BRIDGE - PCI CTLR */
0699     klinfo_t    vmeb_info ;
0700     vmeb_t      vmeb_specific ;
0701     klconf_off_t    vmeb_brdinfo[MAX_VME_SLOTS]   ;    /* VME Board config info */
0702 } klvmeb_t ;
0703 
0704 typedef struct klvmed_s {              /* VME DEVICE - VME BOARD */
0705     klinfo_t    vmed_info ;
0706     vmed_t      vmed_specific ;
0707     klconf_off_t    vmed_brdinfo[MAX_VME_SLOTS]   ;    /* VME Board config info */
0708 } klvmed_t ;
0709 
0710 #define ROUTER_VECTOR_VERS  2
0711 
0712 /* XXX - Don't we need the number of ports here?!? */
0713 typedef struct klrou_s {              /* ROUTER */
0714     klinfo_t    rou_info ;
0715     unsigned int        rou_flags ;       /* PCFG_ROUTER_xxx flags */
0716     nic_t       rou_box_nic ;         /* nic of the containing module */
0717     klport_t    rou_port[MAX_ROUTER_PORTS + 1] ; /* array index 1 to 6 */
0718     klconf_off_t    rou_mfg_nic ;     /* MFG NIC string */
0719     u64 rou_vector;   /* vector from master node */
0720 } klrou_t ;
0721 
0722 /*
0723  *  Graphics Controller/Device
0724  *
0725  *  (IP27/IO6) Prom versions 6.13 (and 6.5.1 kernels) and earlier
0726  *  used a couple different structures to store graphics information.
0727  *  For compatibility reasons, the newer data structure preserves some
0728  *  of the layout so that fields that are used in the old versions remain
0729  *  in the same place (with the same info).  Determination of what version
0730  *  of this structure we have is done by checking the cookie field.
0731  */
0732 #define KLGFX_COOKIE    0x0c0de000
0733 
0734 typedef struct klgfx_s {        /* GRAPHICS Device */
0735     klinfo_t    gfx_info;
0736     klconf_off_t    old_gndevs; /* for compatibility with older proms */
0737     klconf_off_t    old_gdoff0; /* for compatibility with older proms */
0738     unsigned int        cookie;     /* for compatibility with older proms */
0739     unsigned int        moduleslot;
0740     struct klgfx_s  *gfx_next_pipe;
0741     graphics_t  gfx_specific;
0742     klconf_off_t    pad0;       /* for compatibility with older proms */
0743     klconf_off_t    gfx_mfg_nic;
0744 } klgfx_t;
0745 
0746 typedef struct klxthd_s {
0747     klinfo_t    xthd_info ;
0748     klconf_off_t    xthd_mfg_nic ;        /* MFG NIC string */
0749 } klxthd_t ;
0750 
0751 typedef struct kltpu_s {             /* TPU board */
0752     klinfo_t    tpu_info ;
0753     klconf_off_t    tpu_mfg_nic ;        /* MFG NIC string */
0754 } kltpu_t ;
0755 
0756 typedef struct klgsn_s {             /* GSN board */
0757     klinfo_t    gsn_info ;
0758     klconf_off_t    gsn_mfg_nic ;        /* MFG NIC string */
0759 } klgsn_t ;
0760 
0761 #define MAX_SCSI_DEVS 16
0762 
0763 /*
0764  * NOTE: THis is the max sized kl* structure and is used in klmalloc.c
0765  * to allocate space of type COMPONENT. Make sure that if the size of
0766  * any other component struct becomes more than this, then redefine
0767  * that as the size to be klmalloced.
0768  */
0769 
0770 typedef struct klscsi_s {              /* SCSI Controller */
0771     klinfo_t    scsi_info ;
0772     scsi_t      scsi_specific   ;
0773     unsigned char   scsi_numdevs ;
0774     klconf_off_t    scsi_devinfo[MAX_SCSI_DEVS] ;
0775 } klscsi_t ;
0776 
0777 typedef struct klscdev_s {              /* SCSI device */
0778     klinfo_t    scdev_info ;
0779     struct scsidisk_data *scdev_cfg ; /* driver fills up this */
0780 } klscdev_t ;
0781 
0782 typedef struct klttydev_s {              /* TTY device */
0783     klinfo_t    ttydev_info ;
0784     struct terminal_data *ttydev_cfg ; /* driver fills up this */
0785 } klttydev_t ;
0786 
0787 typedef struct klenetdev_s {                  /* ENET device */
0788     klinfo_t    enetdev_info ;
0789     struct net_data *enetdev_cfg ; /* driver fills up this */
0790 } klenetdev_t ;
0791 
0792 typedef struct klkbddev_s {              /* KBD device */
0793     klinfo_t    kbddev_info ;
0794     struct keyboard_data *kbddev_cfg ; /* driver fills up this */
0795 } klkbddev_t ;
0796 
0797 typedef struct klmsdev_s {              /* mouse device */
0798     klinfo_t    msdev_info ;
0799     void        *msdev_cfg ;
0800 } klmsdev_t ;
0801 
0802 #define MAX_FDDI_DEVS 10 /* XXX Is this true */
0803 
0804 typedef struct klfddi_s {              /* FDDI */
0805     klinfo_t    fddi_info ;
0806     fddi_t      fddi_specific ;
0807     klconf_off_t    fddi_devinfo[MAX_FDDI_DEVS] ;
0808 } klfddi_t ;
0809 
0810 typedef struct klmio_s {              /* MIO */
0811     klinfo_t    mio_info ;
0812     mio_t       mio_specific   ;
0813 } klmio_t ;
0814 
0815 
0816 typedef union klcomp_s {
0817     klcpu_t     kc_cpu;
0818     klhub_t     kc_hub;
0819     klmembnk_t  kc_mem;
0820     klxbow_t    kc_xbow;
0821     klbri_t     kc_bri;
0822     klioc3_t    kc_ioc3;
0823     klvmeb_t    kc_vmeb;
0824     klvmed_t    kc_vmed;
0825     klrou_t     kc_rou;
0826     klgfx_t     kc_gfx;
0827     klscsi_t    kc_scsi;
0828     klscdev_t   kc_scsi_dev;
0829     klfddi_t    kc_fddi;
0830     klmio_t     kc_mio;
0831     klmod_serial_num_t kc_snum ;
0832 } klcomp_t;
0833 
0834 typedef union kldev_s {      /* for device structure allocation */
0835     klscdev_t   kc_scsi_dev ;
0836     klttydev_t  kc_tty_dev ;
0837     klenetdev_t kc_enet_dev ;
0838     klkbddev_t  kc_kbd_dev ;
0839 } kldev_t ;
0840 
0841 /* Data structure interface routines. TBD */
0842 
0843 /* Include launch info in this file itself? TBD */
0844 
0845 /*
0846  * TBD - Can the ARCS and device driver related info also be included in the
0847  * KLCONFIG area. On the IO4PROM, prom device driver info is part of cfgnode_t
0848  * structure, viz private to the IO4prom.
0849  */
0850 
0851 /*
0852  * TBD - Allocation issues.
0853  *
0854  * Do we need to Mark off sepatate heaps for lboard_t, rboard_t, component,
0855  * errinfo and allocate from them, or have a single heap and allocate all
0856  * structures from it. Debug is easier in the former method since we can
0857  * dump all similar structs in one command, but there will be lots of holes,
0858  * in memory and max limits are needed for number of structures.
0859  * Another way to make it organized, is to have a union of all components
0860  * and allocate a aligned chunk of memory greater than the biggest
0861  * component.
0862  */
0863 
0864 typedef union {
0865     lboard_t *lbinfo ;
0866 } biptr_t ;
0867 
0868 
0869 #define BRI_PER_XBOW 6
0870 #define PCI_PER_BRI  8
0871 #define DEV_PER_PCI  16
0872 
0873 
0874 /* Virtual dipswitch values (starting from switch "7"): */
0875 
0876 #define VDS_NOGFX       0x8000  /* Don't enable gfx and autoboot */
0877 #define VDS_NOMP        0x100   /* Don't start slave processors */
0878 #define VDS_MANUMODE        0x80    /* Manufacturing mode */
0879 #define VDS_NOARB       0x40    /* No bootmaster arbitration */
0880 #define VDS_PODMODE     0x20    /* Go straight to POD mode */
0881 #define VDS_NO_DIAGS        0x10    /* Don't run any diags after BM arb */
0882 #define VDS_DEFAULTS        0x08    /* Use default environment values */
0883 #define VDS_NOMEMCLEAR      0x04    /* Don't run mem cfg code */
0884 #define VDS_2ND_IO4     0x02    /* Boot from the second IO4 */
0885 #define VDS_DEBUG_PROM      0x01    /* Print PROM debugging messages */
0886 
0887 /* external declarations of Linux kernel functions. */
0888 
0889 extern lboard_t *find_lboard(lboard_t *start, unsigned char type);
0890 extern klinfo_t *find_component(lboard_t *brd, klinfo_t *kli, unsigned char type);
0891 extern klinfo_t *find_first_component(lboard_t *brd, unsigned char type);
0892 extern lboard_t *find_lboard_class(lboard_t *start, unsigned char brd_class);
0893 
0894 #endif /* _ASM_SN_KLCONFIG_H */