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/SN0/hubmd.h>, revision 1.59.
0007  *
0008  * Copyright (C) 1992 - 1997, 1999 Silicon Graphics, Inc.
0009  * Copyright (C) 1999 by Ralf Baechle
0010  */
0011 #ifndef _ASM_SN_SN0_HUBMD_H
0012 #define _ASM_SN_SN0_HUBMD_H
0013 
0014 
0015 /*
0016  * Hub Memory/Directory interface registers
0017  */
0018 #define CACHE_SLINE_SIZE    128 /* Secondary cache line size on SN0 */
0019 
0020 #define MAX_REGIONS     64
0021 
0022 /* Hardware page size and shift */
0023 
0024 #define MD_PAGE_SIZE        4096     /* Page size in bytes          */
0025 #define MD_PAGE_NUM_SHFT    12   /* Address to page number shift    */
0026 
0027 /* Register offsets from LOCAL_HUB or REMOTE_HUB */
0028 
0029 #define MD_BASE         0x200000
0030 #define MD_BASE_PERF        0x210000
0031 #define MD_BASE_JUNK        0x220000
0032 
0033 #define MD_IO_PROTECT       0x200000 /* MD and core register protection */
0034 #define MD_IO_PROT_OVRRD    0x200008 /* Clear my bit in MD_IO_PROTECT   */
0035 #define MD_HSPEC_PROTECT    0x200010 /* BDDIR, LBOOT, RBOOT protection  */
0036 #define MD_MEMORY_CONFIG    0x200018 /* Memory/Directory DIMM control   */
0037 #define MD_REFRESH_CONTROL  0x200020 /* Memory/Directory refresh ctrl   */
0038 #define MD_FANDOP_CAC_STAT  0x200028 /* Fetch-and-op cache status       */
0039 #define MD_MIG_DIFF_THRESH  0x200030 /* Page migr. count diff thresh.   */
0040 #define MD_MIG_VALUE_THRESH 0x200038 /* Page migr. count abs. thresh.   */
0041 #define MD_MIG_CANDIDATE    0x200040 /* Latest page migration candidate */
0042 #define MD_MIG_CANDIDATE_CLR    0x200048 /* Clear page migration candidate  */
0043 #define MD_DIR_ERROR        0x200050 /* Directory DIMM error        */
0044 #define MD_DIR_ERROR_CLR    0x200058 /* Directory DIMM error clear      */
0045 #define MD_PROTOCOL_ERROR   0x200060 /* Directory protocol error        */
0046 #define MD_PROTOCOL_ERROR_CLR   0x200068 /* Directory protocol error clear  */
0047 #define MD_MEM_ERROR        0x200070 /* Memory DIMM error           */
0048 #define MD_MEM_ERROR_CLR    0x200078 /* Memory DIMM error clear     */
0049 #define MD_MISC_ERROR       0x200080 /* Miscellaneous MD error      */
0050 #define MD_MISC_ERROR_CLR   0x200088 /* Miscellaneous MD error clear    */
0051 #define MD_MEM_DIMM_INIT    0x200090 /* Memory DIMM mode initization.   */
0052 #define MD_DIR_DIMM_INIT    0x200098 /* Directory DIMM mode init.       */
0053 #define MD_MOQ_SIZE     0x2000a0 /* MD outgoing queue size      */
0054 #define MD_MLAN_CTL     0x2000a8 /* NIC (Microlan) control register */
0055 
0056 #define MD_PERF_SEL     0x210000 /* Select perf monitor events      */
0057 #define MD_PERF_CNT0        0x210010 /* Performance counter 0       */
0058 #define MD_PERF_CNT1        0x210018 /* Performance counter 1       */
0059 #define MD_PERF_CNT2        0x210020 /* Performance counter 2       */
0060 #define MD_PERF_CNT3        0x210028 /* Performance counter 3       */
0061 #define MD_PERF_CNT4        0x210030 /* Performance counter 4       */
0062 #define MD_PERF_CNT5        0x210038 /* Performance counter 5       */
0063 
0064 #define MD_UREG0_0      0x220000 /* uController/UART 0 register     */
0065 #define MD_UREG0_1      0x220008 /* uController/UART 0 register     */
0066 #define MD_UREG0_2      0x220010 /* uController/UART 0 register     */
0067 #define MD_UREG0_3      0x220018 /* uController/UART 0 register     */
0068 #define MD_UREG0_4      0x220020 /* uController/UART 0 register     */
0069 #define MD_UREG0_5      0x220028 /* uController/UART 0 register     */
0070 #define MD_UREG0_6      0x220030 /* uController/UART 0 register     */
0071 #define MD_UREG0_7      0x220038 /* uController/UART 0 register     */
0072 
0073 #define MD_SLOTID_USTAT     0x220048 /* Hub slot ID & UART/uCtlr status */
0074 #define MD_LED0         0x220050 /* Eight-bit LED for CPU A     */
0075 #define MD_LED1         0x220058 /* Eight-bit LED for CPU B     */
0076 
0077 #define MD_UREG1_0      0x220080 /* uController/UART 1 register     */
0078 #define MD_UREG1_1      0x220088 /* uController/UART 1 register     */
0079 #define MD_UREG1_2      0x220090 /* uController/UART 1 register     */
0080 #define MD_UREG1_3      0x220098 /* uController/UART 1 register     */
0081 #define MD_UREG1_4      0x2200a0 /* uController/UART 1 register     */
0082 #define MD_UREG1_5      0x2200a8 /* uController/UART 1 register     */
0083 #define MD_UREG1_6      0x2200b0 /* uController/UART 1 register     */
0084 #define MD_UREG1_7      0x2200b8 /* uController/UART 1 register     */
0085 #define MD_UREG1_8      0x2200c0 /* uController/UART 1 register     */
0086 #define MD_UREG1_9      0x2200c8 /* uController/UART 1 register     */
0087 #define MD_UREG1_10     0x2200d0 /* uController/UART 1 register     */
0088 #define MD_UREG1_11     0x2200d8 /* uController/UART 1 register     */
0089 #define MD_UREG1_12     0x2200e0 /* uController/UART 1 register     */
0090 #define MD_UREG1_13     0x2200e8 /* uController/UART 1 register     */
0091 #define MD_UREG1_14     0x2200f0 /* uController/UART 1 register     */
0092 #define MD_UREG1_15     0x2200f8 /* uController/UART 1 register     */
0093 
0094 #ifdef CONFIG_SGI_SN_N_MODE
0095 #define MD_MEM_BANKS        4    /* 4 banks of memory max in N mode */
0096 #else
0097 #define MD_MEM_BANKS        8    /* 8 banks of memory max in M mode */
0098 #endif
0099 
0100 /*
0101  * MD_MEMORY_CONFIG fields
0102  *
0103  *   MD_SIZE_xxx are useful for representing the size of a SIMM or bank
0104  *   (SIMM pair).  They correspond to the values needed for the bit
0105  *   triplets (MMC_BANK_MASK) in the MD_MEMORY_CONFIG register for bank size.
0106  *   Bits not used by the MD are used by software.
0107  */
0108 
0109 #define MD_SIZE_EMPTY       0   /* Valid in MEMORY_CONFIG       */
0110 #define MD_SIZE_8MB     1
0111 #define MD_SIZE_16MB        2
0112 #define MD_SIZE_32MB        3   /* Broken in Hub 1          */
0113 #define MD_SIZE_64MB        4   /* Valid in MEMORY_CONFIG       */
0114 #define MD_SIZE_128MB       5   /* Valid in MEMORY_CONFIG       */
0115 #define MD_SIZE_256MB       6
0116 #define MD_SIZE_512MB       7   /* Valid in MEMORY_CONFIG       */
0117 #define MD_SIZE_1GB     8
0118 #define MD_SIZE_2GB     9
0119 #define MD_SIZE_4GB     10
0120 
0121 #define MD_SIZE_BYTES(size) ((size) == 0 ? 0 : 0x400000L << (size))
0122 #define MD_SIZE_MBYTES(size)    ((size) == 0 ? 0 :   4       << (size))
0123 
0124 #define MMC_FPROM_CYC_SHFT  49  /* Have to use UINT64_CAST, instead */
0125 #define MMC_FPROM_CYC_MASK  (UINT64_CAST 31 << 49)  /* of 'L' suffix,   */
0126 #define MMC_FPROM_WR_SHFT   44          /* for assembler    */
0127 #define MMC_FPROM_WR_MASK   (UINT64_CAST 31 << 44)
0128 #define MMC_UCTLR_CYC_SHFT  39
0129 #define MMC_UCTLR_CYC_MASK  (UINT64_CAST 31 << 39)
0130 #define MMC_UCTLR_WR_SHFT   34
0131 #define MMC_UCTLR_WR_MASK   (UINT64_CAST 31 << 34)
0132 #define MMC_DIMM0_SEL_SHFT  32
0133 #define MMC_DIMM0_SEL_MASK  (UINT64_CAST 3 << 32)
0134 #define MMC_IO_PROT_EN_SHFT 31
0135 #define MMC_IO_PROT_EN_MASK (UINT64_CAST 1 << 31)
0136 #define MMC_IO_PROT     (UINT64_CAST 1 << 31)
0137 #define MMC_ARB_MLSS_SHFT   30
0138 #define MMC_ARB_MLSS_MASK   (UINT64_CAST 1 << 30)
0139 #define MMC_ARB_MLSS        (UINT64_CAST 1 << 30)
0140 #define MMC_IGNORE_ECC_SHFT 29
0141 #define MMC_IGNORE_ECC_MASK (UINT64_CAST 1 << 29)
0142 #define MMC_IGNORE_ECC      (UINT64_CAST 1 << 29)
0143 #define MMC_DIR_PREMIUM_SHFT    28
0144 #define MMC_DIR_PREMIUM_MASK    (UINT64_CAST 1 << 28)
0145 #define MMC_DIR_PREMIUM     (UINT64_CAST 1 << 28)
0146 #define MMC_REPLY_GUAR_SHFT 24
0147 #define MMC_REPLY_GUAR_MASK (UINT64_CAST 15 << 24)
0148 #define MMC_BANK_SHFT(_b)   ((_b) * 3)
0149 #define MMC_BANK_MASK(_b)   (UINT64_CAST 7 << MMC_BANK_SHFT(_b))
0150 #define MMC_BANK_ALL_MASK   0xffffff
0151 #define MMC_RESET_DEFAULTS  (UINT64_CAST 0x0f << MMC_FPROM_CYC_SHFT | \
0152                  UINT64_CAST 0x07 << MMC_FPROM_WR_SHFT | \
0153                  UINT64_CAST 0x1f << MMC_UCTLR_CYC_SHFT | \
0154                  UINT64_CAST 0x0f << MMC_UCTLR_WR_SHFT | \
0155                  MMC_IGNORE_ECC | MMC_DIR_PREMIUM | \
0156                  UINT64_CAST 0x0f << MMC_REPLY_GUAR_SHFT | \
0157                  MMC_BANK_ALL_MASK)
0158 
0159 /* MD_REFRESH_CONTROL fields */
0160 
0161 #define MRC_ENABLE_SHFT     63
0162 #define MRC_ENABLE_MASK     (UINT64_CAST 1 << 63)
0163 #define MRC_ENABLE      (UINT64_CAST 1 << 63)
0164 #define MRC_COUNTER_SHFT    12
0165 #define MRC_COUNTER_MASK    (UINT64_CAST 0xfff << 12)
0166 #define MRC_CNT_THRESH_MASK 0xfff
0167 #define MRC_RESET_DEFAULTS  (UINT64_CAST 0x400)
0168 
0169 /* MD_MEM_DIMM_INIT and MD_DIR_DIMM_INIT fields */
0170 
0171 #define MDI_SELECT_SHFT     32
0172 #define MDI_SELECT_MASK     (UINT64_CAST 0x0f << 32)
0173 #define MDI_DIMM_MODE_MASK  (UINT64_CAST 0xfff)
0174 
0175 /* MD_MOQ_SIZE fields */
0176 
0177 #define MMS_RP_SIZE_SHFT    8
0178 #define MMS_RP_SIZE_MASK    (UINT64_CAST 0x3f << 8)
0179 #define MMS_RQ_SIZE_SHFT    0
0180 #define MMS_RQ_SIZE_MASK    (UINT64_CAST 0x1f)
0181 #define MMS_RESET_DEFAULTS  (0x32 << 8 | 0x12)
0182 
0183 /* MD_FANDOP_CAC_STAT fields */
0184 
0185 #define MFC_VALID_SHFT      63
0186 #define MFC_VALID_MASK      (UINT64_CAST 1 << 63)
0187 #define MFC_VALID       (UINT64_CAST 1 << 63)
0188 #define MFC_ADDR_SHFT       6
0189 #define MFC_ADDR_MASK       (UINT64_CAST 0x3ffffff)
0190 
0191 /* MD_MLAN_CTL fields */
0192 
0193 #define MLAN_PHI1_SHFT      27
0194 #define MLAN_PHI1_MASK      (UINT64_CAST 0x7f << 27)
0195 #define MLAN_PHI0_SHFT      20
0196 #define MLAN_PHI0_MASK      (UINT64_CAST 0x7f << 27)
0197 #define MLAN_PULSE_SHFT     10
0198 #define MLAN_PULSE_MASK     (UINT64_CAST 0x3ff << 10)
0199 #define MLAN_SAMPLE_SHFT    2
0200 #define MLAN_SAMPLE_MASK    (UINT64_CAST 0xff << 2)
0201 #define MLAN_DONE_SHFT      1
0202 #define MLAN_DONE_MASK      2
0203 #define MLAN_DONE       (UINT64_CAST 0x02)
0204 #define MLAN_RD_DATA        (UINT64_CAST 0x01)
0205 #define MLAN_RESET_DEFAULTS (UINT64_CAST 0x31 << MLAN_PHI1_SHFT | \
0206                  UINT64_CAST 0x31 << MLAN_PHI0_SHFT)
0207 
0208 /* MD_SLOTID_USTAT bit definitions */
0209 
0210 #define MSU_CORECLK_TST_SHFT    7   /* You don't wanna know         */
0211 #define MSU_CORECLK_TST_MASK    (UINT64_CAST 1 << 7)
0212 #define MSU_CORECLK_TST     (UINT64_CAST 1 << 7)
0213 #define MSU_CORECLK_SHFT    6   /* You don't wanna know         */
0214 #define MSU_CORECLK_MASK    (UINT64_CAST 1 << 6)
0215 #define MSU_CORECLK     (UINT64_CAST 1 << 6)
0216 #define MSU_NETSYNC_SHFT    5   /* You don't wanna know         */
0217 #define MSU_NETSYNC_MASK    (UINT64_CAST 1 << 5)
0218 #define MSU_NETSYNC     (UINT64_CAST 1 << 5)
0219 #define MSU_FPROMRDY_SHFT   4   /* Flash PROM ready bit         */
0220 #define MSU_FPROMRDY_MASK   (UINT64_CAST 1 << 4)
0221 #define MSU_FPROMRDY        (UINT64_CAST 1 << 4)
0222 #define MSU_I2CINTR_SHFT        3   /* I2C interrupt bit   */
0223 #define MSU_I2CINTR_MASK        (UINT64_CAST 1 << 3)
0224 #define MSU_I2CINTR     (UINT64_CAST 1 << 3)
0225 #define MSU_SLOTID_MASK     0xff
0226 #define MSU_SN0_SLOTID_SHFT 0   /* Slot ID              */
0227 #define MSU_SN0_SLOTID_MASK (UINT64_CAST 7)
0228 #define MSU_SN00_SLOTID_SHFT    7
0229 #define MSU_SN00_SLOTID_MASK    (UINT64_CAST 0x80)
0230 
0231 #define MSU_PIMM_PSC_SHFT   4
0232 #define MSU_PIMM_PSC_MASK   (0xf << MSU_PIMM_PSC_SHFT)
0233 
0234 /* MD_MIG_DIFF_THRESH bit definitions */
0235 
0236 #define MD_MIG_DIFF_THRES_VALID_MASK (UINT64_CAST 0x1 << 63)
0237 #define MD_MIG_DIFF_THRES_VALID_SHFT 63
0238 #define MD_MIG_DIFF_THRES_VALUE_MASK (UINT64_CAST 0xfffff)
0239 
0240 /* MD_MIG_VALUE_THRESH bit definitions */
0241 
0242 #define MD_MIG_VALUE_THRES_VALID_MASK (UINT64_CAST 0x1 << 63)
0243 #define MD_MIG_VALUE_THRES_VALID_SHFT 63
0244 #define MD_MIG_VALUE_THRES_VALUE_MASK (UINT64_CAST 0xfffff)
0245 
0246 /* MD_MIG_CANDIDATE bit definitions */
0247 
0248 #define MD_MIG_CANDIDATE_VALID_MASK (UINT64_CAST 0x1 << 63)
0249 #define MD_MIG_CANDIDATE_VALID_SHFT 63
0250 #define MD_MIG_CANDIDATE_TYPE_MASK (UINT64_CAST 0x1 << 30)
0251 #define MD_MIG_CANDIDATE_TYPE_SHFT 30
0252 #define MD_MIG_CANDIDATE_OVERRUN_MASK (UINT64_CAST 0x1 << 29)
0253 #define MD_MIG_CANDIDATE_OVERRUN_SHFT 29
0254 #define MD_MIG_CANDIDATE_INITIATOR_MASK (UINT64_CAST 0x7ff << 18)
0255 #define MD_MIG_CANDIDATE_INITIATOR_SHFT 18
0256 #define MD_MIG_CANDIDATE_NODEID_MASK (UINT64_CAST 0x1ff << 20)
0257 #define MD_MIG_CANDIDATE_NODEID_SHFT 20
0258 #define MD_MIG_CANDIDATE_ADDR_MASK (UINT64_CAST 0x3ffff)
0259 #define MD_MIG_CANDIDATE_ADDR_SHFT 14  /* The address starts at bit 14 */
0260 
0261 /* Other MD definitions */
0262 
0263 #define MD_BANK_SHFT        29          /* log2(512 MB)     */
0264 #define MD_BANK_MASK        (UINT64_CAST 7 << 29)
0265 #define MD_BANK_SIZE        (UINT64_CAST 1 << MD_BANK_SHFT)   /* 512 MB */
0266 #define MD_BANK_OFFSET(_b)  (UINT64_CAST (_b) << MD_BANK_SHFT)
0267 
0268 /*
0269  * The following definitions cover the bit field definitions for the
0270  * various MD registers.  For multi-bit registers, we define both
0271  * a shift amount and a mask value.  By convention, if you want to
0272  * isolate a field, you should mask the field and then shift it down,
0273  * since this makes the masks useful without a shift.
0274  */
0275 
0276 /* Directory entry states for both premium and standard SIMMs. */
0277 
0278 #define MD_DIR_SHARED       (UINT64_CAST 0x0)   /* 000 */
0279 #define MD_DIR_POISONED     (UINT64_CAST 0x1)   /* 001 */
0280 #define MD_DIR_EXCLUSIVE    (UINT64_CAST 0x2)   /* 010 */
0281 #define MD_DIR_BUSY_SHARED  (UINT64_CAST 0x3)   /* 011 */
0282 #define MD_DIR_BUSY_EXCL    (UINT64_CAST 0x4)   /* 100 */
0283 #define MD_DIR_WAIT     (UINT64_CAST 0x5)   /* 101 */
0284 #define MD_DIR_UNOWNED      (UINT64_CAST 0x7)   /* 111 */
0285 
0286 /*
0287  * The MD_DIR_FORCE_ECC bit can be added directory entry write data
0288  * to forcing the ECC to be written as-is instead of recalculated.
0289  */
0290 
0291 #define MD_DIR_FORCE_ECC    (UINT64_CAST 1 << 63)
0292 
0293 /*
0294  * Premium SIMM directory entry shifts and masks.  Each is valid only in the
0295  * context(s) indicated, where A, B, and C indicate the directory entry format
0296  * as shown, and low and/or high indicates which double-word of the entry.
0297  *
0298  * Format A:  STATE = shared, FINE = 1
0299  * Format B:  STATE = shared, FINE = 0
0300  * Format C:  STATE != shared (FINE must be 0)
0301  */
0302 
0303 #define MD_PDIR_MASK        0xffffffffffff      /* Whole entry      */
0304 #define MD_PDIR_ECC_SHFT    0           /* ABC low or high  */
0305 #define MD_PDIR_ECC_MASK    0x7f
0306 #define MD_PDIR_PRIO_SHFT   8           /* ABC low      */
0307 #define MD_PDIR_PRIO_MASK   (0xf << 8)
0308 #define MD_PDIR_AX_SHFT     7           /* ABC low      */
0309 #define MD_PDIR_AX_MASK     (1 << 7)
0310 #define MD_PDIR_AX      (1 << 7)
0311 #define MD_PDIR_FINE_SHFT   12          /* ABC low      */
0312 #define MD_PDIR_FINE_MASK   (1 << 12)
0313 #define MD_PDIR_FINE        (1 << 12)
0314 #define MD_PDIR_OCT_SHFT    13          /* A low        */
0315 #define MD_PDIR_OCT_MASK    (7 << 13)
0316 #define MD_PDIR_STATE_SHFT  13          /* BC low       */
0317 #define MD_PDIR_STATE_MASK  (7 << 13)
0318 #define MD_PDIR_ONECNT_SHFT 16          /* BC low       */
0319 #define MD_PDIR_ONECNT_MASK (0x3f << 16)
0320 #define MD_PDIR_PTR_SHFT    22          /* C low        */
0321 #define MD_PDIR_PTR_MASK    (UINT64_CAST 0x7ff << 22)
0322 #define MD_PDIR_VECMSB_SHFT 22          /* AB low       */
0323 #define MD_PDIR_VECMSB_BITMASK  0x3ffffff
0324 #define MD_PDIR_VECMSB_BITSHFT  27
0325 #define MD_PDIR_VECMSB_MASK (UINT64_CAST MD_PDIR_VECMSB_BITMASK << 22)
0326 #define MD_PDIR_CWOFF_SHFT  7           /* C high       */
0327 #define MD_PDIR_CWOFF_MASK  (7 << 7)
0328 #define MD_PDIR_VECLSB_SHFT 10          /* AB high      */
0329 #define MD_PDIR_VECLSB_BITMASK  (UINT64_CAST 0x3fffffffff)
0330 #define MD_PDIR_VECLSB_BITSHFT  0
0331 #define MD_PDIR_VECLSB_MASK (MD_PDIR_VECLSB_BITMASK << 10)
0332 
0333 /*
0334  * Directory initialization values
0335  */
0336 
0337 #define MD_PDIR_INIT_LO     (MD_DIR_UNOWNED << MD_PDIR_STATE_SHFT | \
0338                  MD_PDIR_AX)
0339 #define MD_PDIR_INIT_HI     0
0340 #define MD_PDIR_INIT_PROT   (MD_PROT_RW << MD_PPROT_IO_SHFT | \
0341                  MD_PROT_RW << MD_PPROT_SHFT)
0342 
0343 /*
0344  * Standard SIMM directory entry shifts and masks.  Each is valid only in the
0345  * context(s) indicated, where A and C indicate the directory entry format
0346  * as shown, and low and/or high indicates which double-word of the entry.
0347  *
0348  * Format A:  STATE == shared
0349  * Format C:  STATE != shared
0350  */
0351 
0352 #define MD_SDIR_MASK        0xffff          /* Whole entry      */
0353 #define MD_SDIR_ECC_SHFT    0           /* AC low or high   */
0354 #define MD_SDIR_ECC_MASK    0x1f
0355 #define MD_SDIR_PRIO_SHFT   6           /* AC low       */
0356 #define MD_SDIR_PRIO_MASK   (1 << 6)
0357 #define MD_SDIR_AX_SHFT     5           /* AC low       */
0358 #define MD_SDIR_AX_MASK     (1 << 5)
0359 #define MD_SDIR_AX      (1 << 5)
0360 #define MD_SDIR_STATE_SHFT  7           /* AC low       */
0361 #define MD_SDIR_STATE_MASK  (7 << 7)
0362 #define MD_SDIR_PTR_SHFT    10          /* C low        */
0363 #define MD_SDIR_PTR_MASK    (0x3f << 10)
0364 #define MD_SDIR_CWOFF_SHFT  5           /* C high       */
0365 #define MD_SDIR_CWOFF_MASK  (7 << 5)
0366 #define MD_SDIR_VECMSB_SHFT 11          /* A low        */
0367 #define MD_SDIR_VECMSB_BITMASK  0x1f
0368 #define MD_SDIR_VECMSB_BITSHFT  7
0369 #define MD_SDIR_VECMSB_MASK (MD_SDIR_VECMSB_BITMASK << 11)
0370 #define MD_SDIR_VECLSB_SHFT 5           /* A high       */
0371 #define MD_SDIR_VECLSB_BITMASK  0x7ff
0372 #define MD_SDIR_VECLSB_BITSHFT  0
0373 #define MD_SDIR_VECLSB_MASK (MD_SDIR_VECLSB_BITMASK << 5)
0374 
0375 /*
0376  * Directory initialization values
0377  */
0378 
0379 #define MD_SDIR_INIT_LO     (MD_DIR_UNOWNED << MD_SDIR_STATE_SHFT | \
0380                  MD_SDIR_AX)
0381 #define MD_SDIR_INIT_HI     0
0382 #define MD_SDIR_INIT_PROT   (MD_PROT_RW << MD_SPROT_SHFT)
0383 
0384 /* Protection and migration field values */
0385 
0386 #define MD_PROT_RW      (UINT64_CAST 0x6)
0387 #define MD_PROT_RO      (UINT64_CAST 0x3)
0388 #define MD_PROT_NO      (UINT64_CAST 0x0)
0389 #define MD_PROT_BAD     (UINT64_CAST 0x5)
0390 
0391 /* Premium SIMM protection entry shifts and masks. */
0392 
0393 #define MD_PPROT_SHFT       0           /* Prot. field      */
0394 #define MD_PPROT_MASK       7
0395 #define MD_PPROT_MIGMD_SHFT 3           /* Migration mode   */
0396 #define MD_PPROT_MIGMD_MASK (3 << 3)
0397 #define MD_PPROT_REFCNT_SHFT    5           /* Reference count  */
0398 #define MD_PPROT_REFCNT_WIDTH   0x7ffff
0399 #define MD_PPROT_REFCNT_MASK    (MD_PPROT_REFCNT_WIDTH << 5)
0400 
0401 #define MD_PPROT_IO_SHFT    45          /* I/O Prot field   */
0402 #define MD_PPROT_IO_MASK    (UINT64_CAST 7 << 45)
0403 
0404 /* Standard SIMM protection entry shifts and masks. */
0405 
0406 #define MD_SPROT_SHFT       0           /* Prot. field      */
0407 #define MD_SPROT_MASK       7
0408 #define MD_SPROT_MIGMD_SHFT 3           /* Migration mode   */
0409 #define MD_SPROT_MIGMD_MASK (3 << 3)
0410 #define MD_SPROT_REFCNT_SHFT    5           /* Reference count  */
0411 #define MD_SPROT_REFCNT_WIDTH   0x7ff
0412 #define MD_SPROT_REFCNT_MASK    (MD_SPROT_REFCNT_WIDTH << 5)
0413 
0414 /* Migration modes used in protection entries */
0415 
0416 #define MD_PROT_MIGMD_IREL  (UINT64_CAST 0x3 << 3)
0417 #define MD_PROT_MIGMD_IABS  (UINT64_CAST 0x2 << 3)
0418 #define MD_PROT_MIGMD_PREL  (UINT64_CAST 0x1 << 3)
0419 #define MD_PROT_MIGMD_OFF   (UINT64_CAST 0x0 << 3)
0420 
0421 
0422 /*
0423  * Operations on page migration threshold register
0424  */
0425 
0426 #ifndef __ASSEMBLY__
0427 
0428 /*
0429  * LED register macros
0430  */
0431 
0432 #define CPU_LED_ADDR(_nasid, _slice)                       \
0433     (private.p_sn00 ?                          \
0434      REMOTE_HUB_ADDR((_nasid), MD_UREG1_0 + ((_slice) << 5)) :     \
0435      REMOTE_HUB_ADDR((_nasid), MD_LED0    + ((_slice) << 3)))
0436 
0437 #define SET_CPU_LEDS(_nasid, _slice,  _val)                \
0438     (HUB_S(CPU_LED_ADDR(_nasid, _slice), (_val)))
0439 
0440 #define SET_MY_LEDS(_v)                            \
0441     SET_CPU_LEDS(get_nasid(), get_slice(), (_v))
0442 
0443 /*
0444  * Operations on Memory/Directory DIMM control register
0445  */
0446 
0447 #define DIRTYPE_PREMIUM 1
0448 #define DIRTYPE_STANDARD 0
0449 #define MD_MEMORY_CONFIG_DIR_TYPE_GET(region) (\
0450     (REMOTE_HUB_L(region, MD_MEMORY_CONFIG) & MMC_DIR_PREMIUM_MASK) >> \
0451     MMC_DIR_PREMIUM_SHFT)
0452 
0453 
0454 /*
0455  * Operations on page migration count difference and absolute threshold
0456  * registers
0457  */
0458 
0459 #define MD_MIG_DIFF_THRESH_GET(region) ( \
0460     REMOTE_HUB_L((region), MD_MIG_DIFF_THRESH) & \
0461     MD_MIG_DIFF_THRES_VALUE_MASK)
0462 
0463 #define MD_MIG_DIFF_THRESH_SET(region, value) (             \
0464     REMOTE_HUB_S((region), MD_MIG_DIFF_THRESH,          \
0465         MD_MIG_DIFF_THRES_VALID_MASK | (value)))
0466 
0467 #define MD_MIG_DIFF_THRESH_DISABLE(region) (            \
0468     REMOTE_HUB_S((region), MD_MIG_DIFF_THRESH,          \
0469         REMOTE_HUB_L((region), MD_MIG_DIFF_THRESH)      \
0470                  & ~MD_MIG_DIFF_THRES_VALID_MASK))
0471 
0472 #define MD_MIG_DIFF_THRESH_ENABLE(region) (         \
0473     REMOTE_HUB_S((region), MD_MIG_DIFF_THRESH,          \
0474         REMOTE_HUB_L((region), MD_MIG_DIFF_THRESH)      \
0475                  | MD_MIG_DIFF_THRES_VALID_MASK))
0476 
0477 #define MD_MIG_DIFF_THRESH_IS_ENABLED(region) (             \
0478     REMOTE_HUB_L((region), MD_MIG_DIFF_THRESH) &            \
0479            MD_MIG_DIFF_THRES_VALID_MASK)
0480 
0481 #define MD_MIG_VALUE_THRESH_GET(region) (               \
0482     REMOTE_HUB_L((region), MD_MIG_VALUE_THRESH) &  \
0483     MD_MIG_VALUE_THRES_VALUE_MASK)
0484 
0485 #define MD_MIG_VALUE_THRESH_SET(region, value) (            \
0486     REMOTE_HUB_S((region), MD_MIG_VALUE_THRESH,         \
0487         MD_MIG_VALUE_THRES_VALID_MASK | (value)))
0488 
0489 #define MD_MIG_VALUE_THRESH_DISABLE(region) (           \
0490     REMOTE_HUB_S((region), MD_MIG_VALUE_THRESH,         \
0491         REMOTE_HUB_L(region, MD_MIG_VALUE_THRESH)       \
0492                  & ~MD_MIG_VALUE_THRES_VALID_MASK))
0493 
0494 #define MD_MIG_VALUE_THRESH_ENABLE(region) (            \
0495     REMOTE_HUB_S((region), MD_MIG_VALUE_THRESH,         \
0496         REMOTE_HUB_L((region), MD_MIG_VALUE_THRESH)     \
0497                  | MD_MIG_VALUE_THRES_VALID_MASK))
0498 
0499 #define MD_MIG_VALUE_THRESH_IS_ENABLED(region) (            \
0500     REMOTE_HUB_L((region), MD_MIG_VALUE_THRESH) &            \
0501            MD_MIG_VALUE_THRES_VALID_MASK)
0502 
0503 /*
0504  * Operations on page migration candidate register
0505  */
0506 
0507 #define MD_MIG_CANDIDATE_GET(my_region_id) ( \
0508     REMOTE_HUB_L((my_region_id), MD_MIG_CANDIDATE_CLR))
0509 
0510 #define MD_MIG_CANDIDATE_HWPFN(value) ((value) & MD_MIG_CANDIDATE_ADDR_MASK)
0511 
0512 #define MD_MIG_CANDIDATE_NODEID(value) ( \
0513     ((value) & MD_MIG_CANDIDATE_NODEID_MASK) >> MD_MIG_CANDIDATE_NODEID_SHFT)
0514 
0515 #define MD_MIG_CANDIDATE_TYPE(value) ( \
0516     ((value) & MD_MIG_CANDIDATE_TYPE_MASK) >> MD_MIG_CANDIDATE_TYPE_SHFT)
0517 
0518 #define MD_MIG_CANDIDATE_VALID(value) ( \
0519     ((value) & MD_MIG_CANDIDATE_VALID_MASK) >> MD_MIG_CANDIDATE_VALID_SHFT)
0520 
0521 /*
0522  * Macros to retrieve fields in the protection entry
0523  */
0524 
0525 /* for Premium SIMM */
0526 #define MD_PPROT_REFCNT_GET(value) ( \
0527     ((value) & MD_PPROT_REFCNT_MASK) >> MD_PPROT_REFCNT_SHFT)
0528 
0529 #define MD_PPROT_MIGMD_GET(value) ( \
0530     ((value) & MD_PPROT_MIGMD_MASK) >> MD_PPROT_MIGMD_SHFT)
0531 
0532 /* for Standard SIMM */
0533 #define MD_SPROT_REFCNT_GET(value) ( \
0534     ((value) & MD_SPROT_REFCNT_MASK) >> MD_SPROT_REFCNT_SHFT)
0535 
0536 #define MD_SPROT_MIGMD_GET(value) ( \
0537     ((value) & MD_SPROT_MIGMD_MASK) >> MD_SPROT_MIGMD_SHFT)
0538 
0539 /*
0540  * Format of dir_error, mem_error, protocol_error and misc_error registers
0541  */
0542 
0543 struct dir_error_reg {
0544     u64 uce_vld:   1,   /*    63: valid directory uce   */
0545         ae_vld:    1,   /*    62: valid dir prot ecc error */
0546         ce_vld:    1,   /*    61: valid correctable ECC err*/
0547         rsvd1:    19,   /* 60-42: reserved      */
0548         bad_prot:  3,   /* 41-39: encoding, bad access rights*/
0549         bad_syn:   7,   /* 38-32: bad dir syndrome  */
0550         rsvd2:     2,   /* 31-30: reserved      */
0551         hspec_addr:27,  /* 29-03: bddir space bad entry */
0552         uce_ovr:   1,   /*     2: multiple dir uce's    */
0553         ae_ovr:    1,   /*     1: multiple prot ecc errs*/
0554         ce_ovr:    1;   /*     0: multiple correctable errs */
0555 };
0556 
0557 typedef union md_dir_error {
0558     u64 derr_reg;   /* the entire register      */
0559     struct dir_error_reg derr_fmt;  /* the register format      */
0560 } md_dir_error_t;
0561 
0562 
0563 struct mem_error_reg {
0564     u64 uce_vld:   1,   /*    63: valid memory uce  */
0565         ce_vld:    1,   /*    62: valid correctable ECC err*/
0566         rsvd1:    22,   /* 61-40: reserved      */
0567         bad_syn:   8,   /* 39-32: bad mem ecc syndrome  */
0568         address:  29,   /* 31-03: bad entry pointer */
0569         rsvd2:     1,   /*     2: reserved      */
0570         uce_ovr:   1,   /*     1: multiple mem uce's    */
0571         ce_ovr:    1;   /*     0: multiple correctable errs */
0572 };
0573 
0574 
0575 typedef union md_mem_error {
0576     u64 merr_reg;   /* the entire register      */
0577     struct mem_error_reg  merr_fmt; /* format of the mem_error reg  */
0578 } md_mem_error_t;
0579 
0580 
0581 struct proto_error_reg {
0582     u64 valid:     1,   /*    63: valid protocol error  */
0583         rsvd1:     2,   /* 62-61: reserved      */
0584         initiator:11,   /* 60-50: id of request initiator*/
0585         backoff:   2,   /* 49-48: backoff control   */
0586         msg_type:  8,   /* 47-40: type of request   */
0587         access:    2,   /* 39-38: access rights of initiator*/
0588         priority:  1,   /*    37: priority level of requestor*/
0589         dir_state: 4,   /* 36-33: state of directory    */
0590         pointer_me:1,   /*    32: initiator same as dir ptr */
0591         address:  29,   /* 31-03: request address   */
0592         rsvd2:     2,   /* 02-01: reserved      */
0593         overrun:   1;   /*     0: multiple protocol errs */
0594 };
0595 
0596 typedef union md_proto_error {
0597     u64 perr_reg;   /* the entire register      */
0598     struct proto_error_reg  perr_fmt; /* format of the register */
0599 } md_proto_error_t;
0600 
0601 
0602 struct md_sdir_high_fmt {
0603     unsigned short sd_hi_bvec : 11,
0604                sd_hi_ecc  : 5;
0605 };
0606 
0607 
0608 typedef union md_sdir_high {
0609     /* The 16 bits of standard directory, upper word */
0610     unsigned short sd_hi_val;
0611     struct  md_sdir_high_fmt sd_hi_fmt;
0612 }md_sdir_high_t;
0613 
0614 
0615 struct md_sdir_low_shared_fmt {
0616     /* The meaning of lower directory, shared */
0617     unsigned short  sds_lo_bvec  : 5,
0618             sds_lo_unused: 1,
0619             sds_lo_state : 3,
0620             sds_lo_prio  : 1,
0621             sds_lo_ax    : 1,
0622             sds_lo_ecc   : 5;
0623 };
0624 
0625 struct md_sdir_low_exclusive_fmt {
0626     /* The meaning of lower directory, exclusive */
0627     unsigned short  sde_lo_ptr   : 6,
0628             sde_lo_state : 3,
0629             sde_lo_prio  : 1,
0630             sde_lo_ax    : 1,
0631             sde_lo_ecc   : 5;
0632 };
0633 
0634 
0635 typedef union md_sdir_low {
0636     /* The 16 bits of standard directory, lower word */
0637     unsigned short  sd_lo_val;
0638     struct  md_sdir_low_exclusive_fmt sde_lo_fmt;
0639     struct  md_sdir_low_shared_fmt sds_lo_fmt;
0640 }md_sdir_low_t;
0641 
0642 
0643 
0644 struct md_pdir_high_fmt {
0645     u64 pd_hi_unused   : 16,
0646         pd_hi_bvec     : 38,
0647         pd_hi_unused1  : 3,
0648         pd_hi_ecc      : 7;
0649 };
0650 
0651 
0652 typedef union md_pdir_high {
0653     /* The 48 bits of standard directory, upper word */
0654     u64 pd_hi_val;
0655     struct md_pdir_high_fmt pd_hi_fmt;
0656 }md_pdir_high_t;
0657 
0658 
0659 struct md_pdir_low_shared_fmt {
0660     /* The meaning of lower directory, shared */
0661     u64 pds_lo_unused   : 16,
0662         pds_lo_bvec : 26,
0663         pds_lo_cnt  :  6,
0664         pds_lo_state    :  3,
0665         pds_lo_ste  :  1,
0666         pds_lo_prio :  4,
0667         pds_lo_ax   :  1,
0668         pds_lo_ecc  :  7;
0669 };
0670 
0671 struct md_pdir_low_exclusive_fmt {
0672     /* The meaning of lower directory, exclusive */
0673     u64 pde_lo_unused   : 31,
0674         pde_lo_ptr  : 11,
0675         pde_lo_unused1  :  6,
0676         pde_lo_state    :  3,
0677         pde_lo_ste  :  1,
0678         pde_lo_prio :  4,
0679         pde_lo_ax   :  1,
0680         pde_lo_ecc  :  7;
0681 };
0682 
0683 
0684 typedef union md_pdir_loent {
0685     /* The 48 bits of premium directory, lower word */
0686     u64 pd_lo_val;
0687     struct md_pdir_low_exclusive_fmt pde_lo_fmt;
0688     struct md_pdir_low_shared_fmt   pds_lo_fmt;
0689 }md_pdir_low_t;
0690 
0691 
0692 /*
0693  *   the following two "union" definitions and two
0694  *   "struct" definitions are used in vmdump.c to
0695  *   represent directory memory information.
0696  */
0697 
0698 typedef union   md_dir_high {
0699     md_sdir_high_t  md_sdir_high;
0700     md_pdir_high_t  md_pdir_high;
0701 } md_dir_high_t;
0702 
0703 typedef union   md_dir_low  {
0704     md_sdir_low_t   md_sdir_low;
0705     md_pdir_low_t   md_pdir_low;
0706 } md_dir_low_t;
0707 
0708 typedef struct  bddir_entry {
0709     md_dir_low_t    md_dir_low;
0710     md_dir_high_t   md_dir_high;
0711 } bddir_entry_t;
0712 
0713 typedef struct  dir_mem_entry   {
0714     u64     prcpf[MAX_REGIONS];
0715     bddir_entry_t   directory_words[MD_PAGE_SIZE/CACHE_SLINE_SIZE];
0716 } dir_mem_entry_t;
0717 
0718 
0719 
0720 typedef union md_perf_sel {
0721     u64 perf_sel_reg;
0722     struct  {
0723         u64 perf_rsvd : 60,
0724             perf_en   :  1,
0725             perf_sel  :  3;
0726     } perf_sel_bits;
0727 } md_perf_sel_t;
0728 
0729 typedef union md_perf_cnt {
0730     u64 perf_cnt;
0731     struct  {
0732         u64 perf_rsvd : 44,
0733             perf_cnt  : 20;
0734     } perf_cnt_bits;
0735 } md_perf_cnt_t;
0736 
0737 
0738 #endif /* !__ASSEMBLY__ */
0739 
0740 
0741 #define DIR_ERROR_VALID_MASK    0xe000000000000000
0742 #define DIR_ERROR_VALID_SHFT    61
0743 #define DIR_ERROR_VALID_UCE 0x8000000000000000
0744 #define DIR_ERROR_VALID_AE  0x4000000000000000
0745 #define DIR_ERROR_VALID_CE  0x2000000000000000
0746 
0747 #define MEM_ERROR_VALID_MASK    0xc000000000000000
0748 #define MEM_ERROR_VALID_SHFT    62
0749 #define MEM_ERROR_VALID_UCE 0x8000000000000000
0750 #define MEM_ERROR_VALID_CE  0x4000000000000000
0751 
0752 #define PROTO_ERROR_VALID_MASK  0x8000000000000000
0753 
0754 #define MISC_ERROR_VALID_MASK   0x3ff
0755 
0756 /*
0757  * Mask for hspec address that is stored in the dir error register.
0758  * This represents bits 29 through 3.
0759  */
0760 #define DIR_ERR_HSPEC_MASK  0x3ffffff8
0761 #define ERROR_HSPEC_MASK    0x3ffffff8
0762 #define ERROR_HSPEC_SHFT    3
0763 #define ERROR_ADDR_MASK     0xfffffff8
0764 #define ERROR_ADDR_SHFT     3
0765 
0766 /*
0767  * MD_MISC_ERROR register defines.
0768  */
0769 
0770 #define MMCE_VALID_MASK     0x3ff
0771 #define MMCE_ILL_MSG_SHFT   8
0772 #define MMCE_ILL_MSG_MASK   (UINT64_CAST 0x03 << MMCE_ILL_MSG_SHFT)
0773 #define MMCE_ILL_REV_SHFT   6
0774 #define MMCE_ILL_REV_MASK   (UINT64_CAST 0x03 << MMCE_ILL_REV_SHFT)
0775 #define MMCE_LONG_PACK_SHFT 4
0776 #define MMCE_LONG_PACK_MASK (UINT64_CAST 0x03 << MMCE_lONG_PACK_SHFT)
0777 #define MMCE_SHORT_PACK_SHFT    2
0778 #define MMCE_SHORT_PACK_MASK    (UINT64_CAST 0x03 << MMCE_SHORT_PACK_SHFT)
0779 #define MMCE_BAD_DATA_SHFT  0
0780 #define MMCE_BAD_DATA_MASK  (UINT64_CAST 0x03 << MMCE_BAD_DATA_SHFT)
0781 
0782 
0783 #define MD_PERF_COUNTERS    6
0784 #define MD_PERF_SETS        6
0785 
0786 #define MEM_DIMM_MASK               0xe0000000
0787 #define MEM_DIMM_SHFT               29
0788 
0789 #endif /* _ASM_SN_SN0_HUBMD_H */