1*29949e86Sstevel /* 2*29949e86Sstevel * CDDL HEADER START 3*29949e86Sstevel * 4*29949e86Sstevel * The contents of this file are subject to the terms of the 5*29949e86Sstevel * Common Development and Distribution License (the "License"). 6*29949e86Sstevel * You may not use this file except in compliance with the License. 7*29949e86Sstevel * 8*29949e86Sstevel * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*29949e86Sstevel * or http://www.opensolaris.org/os/licensing. 10*29949e86Sstevel * See the License for the specific language governing permissions 11*29949e86Sstevel * and limitations under the License. 12*29949e86Sstevel * 13*29949e86Sstevel * When distributing Covered Code, include this CDDL HEADER in each 14*29949e86Sstevel * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*29949e86Sstevel * If applicable, add the following below this CDDL HEADER, with the 16*29949e86Sstevel * fields enclosed by brackets "[]" replaced with your own identifying 17*29949e86Sstevel * information: Portions Copyright [yyyy] [name of copyright owner] 18*29949e86Sstevel * 19*29949e86Sstevel * CDDL HEADER END 20*29949e86Sstevel */ 21*29949e86Sstevel 22*29949e86Sstevel /* 23*29949e86Sstevel * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24*29949e86Sstevel * Use is subject to license terms. 25*29949e86Sstevel */ 26*29949e86Sstevel 27*29949e86Sstevel #ifndef _SYS_FHC_H 28*29949e86Sstevel #define _SYS_FHC_H 29*29949e86Sstevel 30*29949e86Sstevel #pragma ident "%Z%%M% %I% %E% SMI" 31*29949e86Sstevel 32*29949e86Sstevel #ifdef __cplusplus 33*29949e86Sstevel extern "C" { 34*29949e86Sstevel #endif 35*29949e86Sstevel 36*29949e86Sstevel #include <sys/types32.h> 37*29949e86Sstevel #include <sys/dditypes.h> 38*29949e86Sstevel 39*29949e86Sstevel /* useful debugging stuff */ 40*29949e86Sstevel #define FHC_ATTACH_DEBUG 0x1 41*29949e86Sstevel #define FHC_INTERRUPT_DEBUG 0x2 42*29949e86Sstevel #define FHC_REGISTERS_DEBUG 0x4 43*29949e86Sstevel #define FHC_CTLOPS_DEBUG 0x8 44*29949e86Sstevel 45*29949e86Sstevel #define FHC_BOARDS 0 46*29949e86Sstevel #define FHC_CLOCKS 1 47*29949e86Sstevel 48*29949e86Sstevel /* 49*29949e86Sstevel * OBP supplies us with 6 register sets for the FHC. The code for the fhc 50*29949e86Sstevel * driver relies on these register sets being presented by the PROM in the 51*29949e86Sstevel * order specified below. If this changes, the following comments must be 52*29949e86Sstevel * revised and the code in fhc_init() must be changed to reflect these 53*29949e86Sstevel * revisions. 54*29949e86Sstevel * 55*29949e86Sstevel * They are: 56*29949e86Sstevel * 0 FHC internal registers 57*29949e86Sstevel * 1 IGR Interrupt Group Number 58*29949e86Sstevel * 2 FanFail IMR, ISMR 59*29949e86Sstevel * 3 System IMR, ISMR 60*29949e86Sstevel * 4 UART IMR, ISMR 61*29949e86Sstevel * 5 TOD IMR, ISMR 62*29949e86Sstevel */ 63*29949e86Sstevel 64*29949e86Sstevel /* 65*29949e86Sstevel * The offsets are defined as offsets from the base of the OBP register 66*29949e86Sstevel * set which the register belongs to. 67*29949e86Sstevel */ 68*29949e86Sstevel 69*29949e86Sstevel /* Register set 0 */ 70*29949e86Sstevel #define FHC_OFF_ID 0x0 /* FHC ID register */ 71*29949e86Sstevel #define FHC_OFF_RCTRL 0x10 /* FHC Reset Control and Status */ 72*29949e86Sstevel #define FHC_OFF_CTRL 0x20 /* FHC Control and Status */ 73*29949e86Sstevel #define FHC_OFF_BSR 0x30 /* FHC Board Status Register */ 74*29949e86Sstevel #define FHC_OFF_JTAG_CTRL 0xF0 /* JTAG Control Register */ 75*29949e86Sstevel #define FHC_OFF_JTAG_CMD 0x100 /* JTAG Comamnd Register */ 76*29949e86Sstevel 77*29949e86Sstevel /* Register sets 2-5, the ISMR offset is the same */ 78*29949e86Sstevel #define FHC_OFF_ISMR 0x10 /* FHC Interrupt State Machine */ 79*29949e86Sstevel 80*29949e86Sstevel /* Bit field defines for FHC Control and Status Register */ 81*29949e86Sstevel #define FHC_CENTERDIS 0x00100000 82*29949e86Sstevel 83*29949e86Sstevel /* NOTE: this bit is only used by firmware and must always be cleared by OS */ 84*29949e86Sstevel #define FHC_CSR_SYNC 0x00010000 85*29949e86Sstevel #define FHC_MOD_OFF 0x00008000 86*29949e86Sstevel #define FHC_ACDC_OFF 0x00004000 87*29949e86Sstevel #define FHC_FHC_OFF 0x00002000 88*29949e86Sstevel #define FHC_EPDA_OFF 0x00001000 89*29949e86Sstevel #define FHC_EPDB_OFF 0x00000800 90*29949e86Sstevel #define FHC_PS_OFF 0x00000400 91*29949e86Sstevel #define FHC_NOT_BRD_PRES 0x00000200 92*29949e86Sstevel #define FHC_LED_LEFT 0x00000040 93*29949e86Sstevel #define FHC_LED_MID 0x00000020 94*29949e86Sstevel #define FHC_LED_RIGHT 0x00000010 95*29949e86Sstevel 96*29949e86Sstevel /* Bit field defines for FHC Reset Control and Status Register */ 97*29949e86Sstevel #define FHC_POR 0x80000000 98*29949e86Sstevel #define FHC_SOFT_POR 0x40000000 99*29949e86Sstevel #define FHC_SOFT_XIR 0x20000000 100*29949e86Sstevel 101*29949e86Sstevel /* Bit field defines for the JTAG control register. */ 102*29949e86Sstevel #define JTAG_MASTER_EN 0x80000000 103*29949e86Sstevel #define JTAG_MASTER_NPRES 0x40000000 104*29949e86Sstevel 105*29949e86Sstevel 106*29949e86Sstevel /* Macros for decoding UPA speed pins from the Board Status Register */ 107*29949e86Sstevel #define CPU_0_PINS(bsr) (((bsr) >> 10) & 0x7) 108*29949e86Sstevel #define CPU_1_PINS(bsr) (((bsr) >> 7) & 0x7) 109*29949e86Sstevel 110*29949e86Sstevel #define CID_REV_MASK 0x0fffffff 111*29949e86Sstevel #define ULTRAI_COMPID 0x0002502f 112*29949e86Sstevel #define ULTRAII_COMPID 0x0003602f 113*29949e86Sstevel 114*29949e86Sstevel /* Macro for extracting the "plus" bit from the Board Status Register */ 115*29949e86Sstevel #define ISPLUSBRD(bsr) (((bsr) & 1) == 0) 116*29949e86Sstevel 117*29949e86Sstevel /* Macros for physical access */ 118*29949e86Sstevel #define FHC_OFFSET 0xf8000000ull 119*29949e86Sstevel #define FHC_REGOFF 0x800000ull 120*29949e86Sstevel #define FHC_OFF_IGN 0x2000ull 121*29949e86Sstevel #define FHC_OFF_SIM 0x6000ull 122*29949e86Sstevel #define FHC_OFF_SSM 0x6010ull 123*29949e86Sstevel #define FHC_OFF_UIM 0x8000ull 124*29949e86Sstevel #define FHC_OFF_USM 0x8010ull 125*29949e86Sstevel #define FHC_CTRL(board) (FHC_BOARD_BASE(2*(board)) + FHC_OFFSET + \ 126*29949e86Sstevel FHC_REGOFF + FHC_OFF_CTRL) 127*29949e86Sstevel #define FHC_JTAG_CTRL(board) (FHC_BOARD_BASE(2*(board)) + FHC_OFFSET + \ 128*29949e86Sstevel FHC_REGOFF + FHC_OFF_JTAG_CTRL) 129*29949e86Sstevel #define FHC_IGN(board) (FHC_BOARD_BASE(2*(board)) + FHC_OFFSET + \ 130*29949e86Sstevel FHC_REGOFF + FHC_OFF_IGN) 131*29949e86Sstevel #define FHC_SIM(board) (FHC_BOARD_BASE(2*(board)) + FHC_OFFSET + \ 132*29949e86Sstevel FHC_REGOFF + FHC_OFF_SIM) 133*29949e86Sstevel #define FHC_SSM(board) (FHC_BOARD_BASE(2*(board)) + FHC_OFFSET + \ 134*29949e86Sstevel FHC_REGOFF + FHC_OFF_SSM) 135*29949e86Sstevel #define FHC_UIM(board) (FHC_BOARD_BASE(2*(board)) + FHC_OFFSET + \ 136*29949e86Sstevel FHC_REGOFF + FHC_OFF_UIM) 137*29949e86Sstevel #define FHC_USM(board) (FHC_BOARD_BASE(2*(board)) + FHC_OFFSET + \ 138*29949e86Sstevel FHC_REGOFF + FHC_OFF_USM) 139*29949e86Sstevel 140*29949e86Sstevel /* 141*29949e86Sstevel * the foolowing defines are used for trans phy-addr to board number 142*29949e86Sstevel */ 143*29949e86Sstevel #define BOARD_PHYADDR_SHIFT 24 144*29949e86Sstevel #define CLOCKBOARD_PHYADDR_BITS 0x1fff8 145*29949e86Sstevel #define IO_BOARD_NUMBER_SHIFT 10 146*29949e86Sstevel #define IO_BOARD_NUMBER_MASK 0xf 147*29949e86Sstevel 148*29949e86Sstevel /* 149*29949e86Sstevel * The following defines are used by the fhc driver to determine the 150*29949e86Sstevel * difference between IO and CPU type boards. This will be replaced 151*29949e86Sstevel * later by JTAG scan to determine board type. 152*29949e86Sstevel */ 153*29949e86Sstevel 154*29949e86Sstevel /* XXX */ 155*29949e86Sstevel #define FHC_UPADATA64A 0x40000 156*29949e86Sstevel #define FHC_UPADATA64B 0x20000 157*29949e86Sstevel /* XXX */ 158*29949e86Sstevel 159*29949e86Sstevel /* Bit field defines for Board Status Register */ 160*29949e86Sstevel #define FHC_DIAG_MODE 0x40 161*29949e86Sstevel 162*29949e86Sstevel /* Bit field defines for the FHC Board Status Register when on a disk board */ 163*29949e86Sstevel #define FHC_FANFAIL 0x00000040 164*29949e86Sstevel #define FHC_SCSI_VDD_OK 0x00000001 165*29949e86Sstevel 166*29949e86Sstevel /* Size of temperature recording array */ 167*29949e86Sstevel #define MAX_TEMP_HISTORY 16 168*29949e86Sstevel 169*29949e86Sstevel /* Maximum number of boards in system */ 170*29949e86Sstevel #define MAX_BOARDS 16 171*29949e86Sstevel 172*29949e86Sstevel /* Maximum number of Board Power Supplies. */ 173*29949e86Sstevel #define MAX_PS_COUNT 8 174*29949e86Sstevel 175*29949e86Sstevel /* Use predefined strings to name the kstats from this driver. */ 176*29949e86Sstevel #define FHC_KSTAT_NAME "fhc" 177*29949e86Sstevel #define CSR_KSTAT_NAMED "csr" 178*29949e86Sstevel #define BSR_KSTAT_NAMED "bsr" 179*29949e86Sstevel 180*29949e86Sstevel /* 181*29949e86Sstevel * The following defines are for the AC chip, but are needed to be global, 182*29949e86Sstevel * so have been put in the fhc header file. 183*29949e86Sstevel */ 184*29949e86Sstevel 185*29949e86Sstevel /* 186*29949e86Sstevel * Most Sunfire ASICs have the chip rev encoded into bits 31-28 of the 187*29949e86Sstevel * component ID register. 188*29949e86Sstevel */ 189*29949e86Sstevel #define CHIP_REV(c) ((c) >> 28) 190*29949e86Sstevel 191*29949e86Sstevel #ifndef _ASM 192*29949e86Sstevel 193*29949e86Sstevel /* Use predefined strings to name the kstats from this driver. */ 194*29949e86Sstevel 195*29949e86Sstevel /* Bit field defines for Interrupt Mapping registers */ 196*29949e86Sstevel #define IMR_VALID ((uint_t)1 << INR_EN_SHIFT) /* Mondo valid bit */ 197*29949e86Sstevel 198*29949e86Sstevel /* Bit defines for Interrupt State Machine Register */ 199*29949e86Sstevel #define INT_PENDING 3 /* state of the interrupt dispatch */ 200*29949e86Sstevel 201*29949e86Sstevel struct intr_regs { 202*29949e86Sstevel volatile uint_t *mapping_reg; 203*29949e86Sstevel volatile uint_t *clear_reg; 204*29949e86Sstevel uint_t mapping_reg_cache; /* cache current value for CPR */ 205*29949e86Sstevel }; 206*29949e86Sstevel 207*29949e86Sstevel #define BD_IVINTR_SHFT 0x7 208*29949e86Sstevel 209*29949e86Sstevel /* 210*29949e86Sstevel * Convert the Board Number field in the FHC Board Status Register to 211*29949e86Sstevel * a board number. The field in the register is bits 0,3-1 of the board 212*29949e86Sstevel * number. Therefore a macro is necessary to extract the board number. 213*29949e86Sstevel */ 214*29949e86Sstevel #define FHC_BSR_TO_BD(bsr) ((((bsr) >> 16) & 0x1) | \ 215*29949e86Sstevel (((bsr) >> 12) & 0xE)) 216*29949e86Sstevel 217*29949e86Sstevel #define FHC_INO(ino) ((ino) & 0x7) 218*29949e86Sstevel #define FHC_CPU2BOARD(cpuid) ((cpuid) >> 1) 219*29949e86Sstevel #define FHC_CPU_IS_A(cpuid) (!((cpuid) & 1)) 220*29949e86Sstevel #define FHC_CPU_IS_B(cpuid) ((cpuid) & 1) 221*29949e86Sstevel #define FHC_BOARD2CPU_A(board) ((board) << 1) 222*29949e86Sstevel #define FHC_BOARD2CPU_B(board) (((board) << 1) + 1) 223*29949e86Sstevel #define FHC_PS2BOARD(ps) ((((ps) & 0x6) << 1) | ((ps) & 0x1)) 224*29949e86Sstevel #define FHC_BOARD2PS(board) ((((board) & 0xc) >> 1) | ((board) & 0x1)) 225*29949e86Sstevel #define FHC_OTHER_CPU_ID(cpuid) ((cpuid) ^ 1) 226*29949e86Sstevel 227*29949e86Sstevel /* this base address is assumed to never map to real memory */ 228*29949e86Sstevel #define FHC_BASE_NOMEM (1ull << 40) 229*29949e86Sstevel #define FHC_MAX_ECACHE_SIZE (16 * 1024 * 1024) 230*29949e86Sstevel 231*29949e86Sstevel #define FHC_BOARD_0 0x1c000000000ull 232*29949e86Sstevel #define FHC_BOARD_SPAN 0x200000000ull 233*29949e86Sstevel #define FHC_DTAG_OFFSET 0xfa000000ull 234*29949e86Sstevel #define FHC_BOARD_BASE(cpuid) (FHC_BOARD_0 + (cpuid) * FHC_BOARD_SPAN) 235*29949e86Sstevel #define FHC_DTAG_BASE(cpuid) (FHC_BOARD_BASE(cpuid) + FHC_DTAG_OFFSET) 236*29949e86Sstevel #define FHC_DTAG_LOW 0x300000000ull 237*29949e86Sstevel #define FHC_DTAG_HIGH 0x3ull 238*29949e86Sstevel #define FHC_DTAG_SIZE (16 * 1024 * 1024) 239*29949e86Sstevel #define FHC_DTAG_SKIP 64 240*29949e86Sstevel 241*29949e86Sstevel /* 242*29949e86Sstevel * Each Sunfire CPU Board has 32Kbytes of SRAM on the FireHose Bus. 243*29949e86Sstevel * 244*29949e86Sstevel * The SRAM is allocated as follows: 245*29949e86Sstevel * 246*29949e86Sstevel * 0x1ff.f020.0000 - 0x1ff.f020.5fff scratch/stacks 247*29949e86Sstevel * 0x1ff.f020.6000 - 0x1ff.f020.67ff reset info (2K bytes) 248*29949e86Sstevel * 0x1ff.f020.6800 - 0x1ff.f020.6fff POST private (2K bytes) 249*29949e86Sstevel * 0x1ff.f020.7000 - 0x1ff.f020.77ff OS private (2K bytes) 250*29949e86Sstevel * 0x1ff.f020.7800 - 0x1ff.f020.7fff OBP private (2K bytes) 251*29949e86Sstevel */ 252*29949e86Sstevel #define FHC_LOCAL_SRAM_BASE 0x1fff0200000ull 253*29949e86Sstevel #define FHC_GLOBAL_SRAM_BASE 0x1c0f8200000ull 254*29949e86Sstevel #define FHC_CPU2GLOBAL_SRAM(mid) \ 255*29949e86Sstevel (FHC_GLOBAL_SRAM_BASE + (mid) * 0x200000000ull) 256*29949e86Sstevel 257*29949e86Sstevel #define FHC_SRAM_OS_BASE 0x7000 258*29949e86Sstevel #define FHC_LOCAL_OS_PAGEBASE ((FHC_LOCAL_SRAM_BASE + FHC_SRAM_OS_BASE) & \ 259*29949e86Sstevel MMU_PAGEMASK) 260*29949e86Sstevel #define FHC_SRAM_OS_OFFSET ((FHC_LOCAL_SRAM_BASE + FHC_SRAM_OS_BASE) & \ 261*29949e86Sstevel MMU_PAGEOFFSET) 262*29949e86Sstevel 263*29949e86Sstevel #define FHC_SHUTDOWN_WAIT_MSEC 1000 264*29949e86Sstevel 265*29949e86Sstevel #define FHC_MAX_INO 4 266*29949e86Sstevel 267*29949e86Sstevel #define FHC_SYS_INO 0x0 268*29949e86Sstevel #define FHC_UART_INO 0x1 269*29949e86Sstevel #define FHC_TOD_INO 0x2 270*29949e86Sstevel #define FHC_FANFAIL_INO 0x3 271*29949e86Sstevel 272*29949e86Sstevel /* 273*29949e86Sstevel * Defines for the kstats created for passing temperature values and 274*29949e86Sstevel * history out to user level programs. All temperatures passed out 275*29949e86Sstevel * will be in degrees Centigrade, corrected for the board type the 276*29949e86Sstevel * temperature was read from. Since each Board type has a different 277*29949e86Sstevel * response curve for the A/D convertor, the temperatures are all 278*29949e86Sstevel * calibrated inside the kernel. 279*29949e86Sstevel */ 280*29949e86Sstevel 281*29949e86Sstevel #define OVERTEMP_KSTAT_NAME "temperature" 282*29949e86Sstevel 283*29949e86Sstevel /* 284*29949e86Sstevel * This kstat is used for manually overriding temperatures. 285*29949e86Sstevel */ 286*29949e86Sstevel 287*29949e86Sstevel #define TEMP_OVERRIDE_KSTAT_NAME "temperature override" 288*29949e86Sstevel 289*29949e86Sstevel /* 290*29949e86Sstevel * Time averaging based method of recording temperature history. 291*29949e86Sstevel * Higher level temperature arrays are composed of temperature averages 292*29949e86Sstevel * of the array one level below. When the lower array completes a 293*29949e86Sstevel * set of data, the data is averaged and placed into the higher 294*29949e86Sstevel * level array. Then the lower level array is overwritten until 295*29949e86Sstevel * it is once again complete, where the process repeats. 296*29949e86Sstevel * 297*29949e86Sstevel * This method gives a user a fine grained view of the last minute, 298*29949e86Sstevel * and larger grained views of the temperature as one goes back in 299*29949e86Sstevel * time. 300*29949e86Sstevel * 301*29949e86Sstevel * The time units for the longer samples are based on the value 302*29949e86Sstevel * of the OVERTEMP_TIMEOUT_SEC and the number of elements in each 303*29949e86Sstevel * of the arrays between level 1 and the higher level. 304*29949e86Sstevel */ 305*29949e86Sstevel 306*29949e86Sstevel #define OVERTEMP_TIMEOUT_SEC 2 307*29949e86Sstevel 308*29949e86Sstevel /* definition of the clock board index */ 309*29949e86Sstevel #define CLOCK_BOARD_INDEX 16 310*29949e86Sstevel 311*29949e86Sstevel #define L1_SZ 30 /* # of OVERTEMP_TIMEOUT_SEC samples */ 312*29949e86Sstevel #define L2_SZ 15 /* size of array for level 2 samples */ 313*29949e86Sstevel #define L3_SZ 12 /* size of array for level 3 samples */ 314*29949e86Sstevel #define L4_SZ 4 /* size of array for level 4 samples */ 315*29949e86Sstevel #define L5_SZ 2 /* size of array for level 5 samples */ 316*29949e86Sstevel 317*29949e86Sstevel /* 318*29949e86Sstevel * Macros for determining when to do the temperature averaging of arrays. 319*29949e86Sstevel */ 320*29949e86Sstevel #define L2_INDEX(i) ((i) / L1_SZ) 321*29949e86Sstevel #define L2_REM(i) ((i) % L1_SZ) 322*29949e86Sstevel #define L3_INDEX(i) ((i) / (L1_SZ * L2_SZ)) 323*29949e86Sstevel #define L3_REM(i) ((i) % (L1_SZ * L2_SZ)) 324*29949e86Sstevel #define L4_INDEX(i) ((i) / (L1_SZ * L2_SZ * L3_SZ)) 325*29949e86Sstevel #define L4_REM(i) ((i) % (L1_SZ * L2_SZ * L3_SZ)) 326*29949e86Sstevel #define L5_INDEX(i) ((i) / (L1_SZ * L2_SZ * L3_SZ * L4_SZ)) 327*29949e86Sstevel #define L5_REM(i) ((i) % (L1_SZ * L2_SZ * L3_SZ * L4_SZ)) 328*29949e86Sstevel 329*29949e86Sstevel /* 330*29949e86Sstevel * define for an illegal temperature. This temperature will never be seen 331*29949e86Sstevel * in a real system, so it is used as an illegal value in the various 332*29949e86Sstevel * functions processing the temperature data structure. 333*29949e86Sstevel */ 334*29949e86Sstevel #define NA_TEMP 0x7FFF 335*29949e86Sstevel 336*29949e86Sstevel /* 337*29949e86Sstevel * State variable for board temperature. Each board has its own 338*29949e86Sstevel * temperature state. State transitions from OK -> bad direction 339*29949e86Sstevel * happen instantaneously, but use a counter in the opposite 340*29949e86Sstevel * direction, so that noise in the A/D counters does not cause 341*29949e86Sstevel * a large number of messages to appear. 342*29949e86Sstevel */ 343*29949e86Sstevel enum temp_state { TEMP_OK = 0, /* normal board temperature */ 344*29949e86Sstevel TEMP_WARN = 1, /* start warning operator */ 345*29949e86Sstevel TEMP_DANGER = 2 }; /* get ready to shutdown */ 346*29949e86Sstevel 347*29949e86Sstevel /* 348*29949e86Sstevel * Number of temperature poll counts to wait before printing that the 349*29949e86Sstevel * system has cooled down. 350*29949e86Sstevel */ 351*29949e86Sstevel #define TEMP_STATE_TIMEOUT_SEC 20 352*29949e86Sstevel #define TEMP_STATE_COUNT ((TEMP_STATE_TIMEOUT_SEC) / \ 353*29949e86Sstevel (OVERTEMP_TIMEOUT_SEC)) 354*29949e86Sstevel 355*29949e86Sstevel /* 356*29949e86Sstevel * Number of poll counts that a system temperature must be at or above danger 357*29949e86Sstevel * temperature before system is halted and powers down. 358*29949e86Sstevel */ 359*29949e86Sstevel #define SHUTDOWN_TIMEOUT_SEC 20 360*29949e86Sstevel #define SHUTDOWN_COUNT ((SHUTDOWN_TIMEOUT_SEC) / \ 361*29949e86Sstevel (OVERTEMP_TIMEOUT_SEC)) 362*29949e86Sstevel 363*29949e86Sstevel /* 364*29949e86Sstevel * State variable for temperature trend. Each state represents the 365*29949e86Sstevel * current temperature trend for a given device. 366*29949e86Sstevel */ 367*29949e86Sstevel enum temp_trend { TREND_UNKNOWN = 0, /* Unknown temperature trend */ 368*29949e86Sstevel TREND_RAPID_FALL = 1, /* Rapidly falling temp. */ 369*29949e86Sstevel TREND_FALL = 2, /* Falling temperature */ 370*29949e86Sstevel TREND_STABLE = 3, /* Stable temperature */ 371*29949e86Sstevel TREND_RISE = 4, /* Rising temperature */ 372*29949e86Sstevel TREND_RAPID_RISE = 5, /* Rapidly rising temperature */ 373*29949e86Sstevel TREND_NOISY = 6 }; /* Unknown trend (noisy) */ 374*29949e86Sstevel 375*29949e86Sstevel /* Thresholds for temperature trend */ 376*29949e86Sstevel #define NOISE_THRESH 2 377*29949e86Sstevel #define RAPID_RISE_THRESH 4 378*29949e86Sstevel #define RAPID_FALL_THRESH 4 379*29949e86Sstevel 380*29949e86Sstevel /* 381*29949e86Sstevel * Main structure for passing the calibrated and time averaged temperature 382*29949e86Sstevel * values to user processes. This structure is copied out via the kstat 383*29949e86Sstevel * mechanism. 384*29949e86Sstevel */ 385*29949e86Sstevel #define TEMP_KSTAT_VERSION 3 /* version of temp_stats structure */ 386*29949e86Sstevel struct temp_stats { 387*29949e86Sstevel uint_t index; /* index of current temperature */ 388*29949e86Sstevel short l1[L1_SZ]; /* OVERTEMP_TIMEOUT_SEC samples */ 389*29949e86Sstevel short l2[L2_SZ]; /* level 2 samples */ 390*29949e86Sstevel short l3[L3_SZ]; /* level 3 samples */ 391*29949e86Sstevel short l4[L4_SZ]; /* level 4 samples */ 392*29949e86Sstevel short l5[L5_SZ]; /* level 5 samples */ 393*29949e86Sstevel short max; /* maximum temperature recorded */ 394*29949e86Sstevel short min; /* minimum temperature recorded */ 395*29949e86Sstevel enum temp_state state; /* state of board temperature */ 396*29949e86Sstevel int temp_cnt; /* counter for state changes */ 397*29949e86Sstevel int shutdown_cnt; /* counter for overtemp shutdown */ 398*29949e86Sstevel int version; /* version of this structure */ 399*29949e86Sstevel enum temp_trend trend; /* temperature trend for board */ 400*29949e86Sstevel short override; /* override temperature for testing */ 401*29949e86Sstevel }; 402*29949e86Sstevel 403*29949e86Sstevel /* The variable fhc_cpu_warning_temp_threshold is initialized to this value. */ 404*29949e86Sstevel #define FHC_CPU_WARNING_TEMP_THRESHOLD 45 405*29949e86Sstevel 406*29949e86Sstevel /* 407*29949e86Sstevel * Fault list management. 408*29949e86Sstevel * 409*29949e86Sstevel * The following defines and enum definitions have been created to support 410*29949e86Sstevel * the fault list (struct ft_list). These defines must match with the 411*29949e86Sstevel * fault string table in fhc.c. If any faults are added, they must be 412*29949e86Sstevel * added at the end of this list, and the table must be modified 413*29949e86Sstevel * accordingly. 414*29949e86Sstevel */ 415*29949e86Sstevel enum ft_type { 416*29949e86Sstevel FT_CORE_PS = 0, /* Core power supply */ 417*29949e86Sstevel FT_OVERTEMP, /* Temperature */ 418*29949e86Sstevel FT_AC_PWR, /* AC power Supply */ 419*29949e86Sstevel FT_PPS, /* Peripheral Power Supply */ 420*29949e86Sstevel FT_CLK_33, /* System 3.3 Volt Power */ 421*29949e86Sstevel FT_CLK_50, /* System 5.0 Volt Power */ 422*29949e86Sstevel FT_V5_P, /* Peripheral 5V Power */ 423*29949e86Sstevel FT_V12_P, /* Peripheral 12V Power */ 424*29949e86Sstevel FT_V5_AUX, /* Auxiliary 5V Power */ 425*29949e86Sstevel FT_V5_P_PCH, /* Peripheral 5V Precharge */ 426*29949e86Sstevel FT_V12_P_PCH, /* Peripheral 12V Precharge */ 427*29949e86Sstevel FT_V3_PCH, /* System 3V Precharge */ 428*29949e86Sstevel FT_V5_PCH, /* System 5V Precharge */ 429*29949e86Sstevel FT_PPS_FAN, /* Peripheral Power Supply Fan */ 430*29949e86Sstevel FT_RACK_EXH, /* Rack Exhaust Fan */ 431*29949e86Sstevel FT_DSK_FAN, /* 4 (or 5) Slot Disk Fan */ 432*29949e86Sstevel FT_AC_FAN, /* AC Box Fan */ 433*29949e86Sstevel FT_KEYSW_FAN, /* Key Switch Fan */ 434*29949e86Sstevel FT_INSUFFICIENT_POWER, /* System has insufficient power */ 435*29949e86Sstevel FT_PROM, /* fault inherited from PROM */ 436*29949e86Sstevel FT_HOT_PLUG, /* hot plug unavailable */ 437*29949e86Sstevel FT_TODFAULT /* tod error detection */ 438*29949e86Sstevel }; 439*29949e86Sstevel 440*29949e86Sstevel enum ft_class { 441*29949e86Sstevel FT_BOARD, 442*29949e86Sstevel FT_SYSTEM 443*29949e86Sstevel }; 444*29949e86Sstevel 445*29949e86Sstevel /* 446*29949e86Sstevel * This extern allows other drivers to use the ft_str_table if they 447*29949e86Sstevel * have fhc specified as a depends_on driver. 448*29949e86Sstevel */ 449*29949e86Sstevel extern char *ft_str_table[]; 450*29949e86Sstevel 451*29949e86Sstevel /* Maximum length of string table entries */ 452*29949e86Sstevel #define MAX_FT_DESC 64 453*29949e86Sstevel 454*29949e86Sstevel #define FT_LIST_KSTAT_NAME "fault_list" 455*29949e86Sstevel 456*29949e86Sstevel /* 457*29949e86Sstevel * The fault list structure is a structure for holding information on 458*29949e86Sstevel * kernel detected faults. The fault list structures are linked into 459*29949e86Sstevel * a list and the list is protected by the ftlist_mutex. There are 460*29949e86Sstevel * also several routines for manipulating the fault list. 461*29949e86Sstevel */ 462*29949e86Sstevel struct ft_list { 463*29949e86Sstevel int32_t unit; /* unit number of faulting device */ 464*29949e86Sstevel enum ft_type type; /* type of faulting device */ 465*29949e86Sstevel int32_t pad; /* padding to replace old next pointer */ 466*29949e86Sstevel enum ft_class fclass; /* System or board class fault */ 467*29949e86Sstevel time32_t create_time; /* Time stamp at fault detection */ 468*29949e86Sstevel char msg[MAX_FT_DESC]; /* fault string */ 469*29949e86Sstevel }; 470*29949e86Sstevel 471*29949e86Sstevel /* 472*29949e86Sstevel * Allow binary compatibility between ILP32 and LP64 by 473*29949e86Sstevel * eliminating the next pointer and making ft_list a fixed size. 474*29949e86Sstevel * The structure name "ft_list" remains unchanged for 475*29949e86Sstevel * source compatibility of kstat applications. 476*29949e86Sstevel */ 477*29949e86Sstevel struct ft_link_list { 478*29949e86Sstevel struct ft_list f; 479*29949e86Sstevel struct ft_link_list *next; 480*29949e86Sstevel }; 481*29949e86Sstevel 482*29949e86Sstevel /* 483*29949e86Sstevel * Board list management. 484*29949e86Sstevel * 485*29949e86Sstevel * Enumerated types for defining type of system and clock 486*29949e86Sstevel * boards. It is used by both the kernel and user programs. 487*29949e86Sstevel */ 488*29949e86Sstevel enum board_type { 489*29949e86Sstevel UNINIT_BOARD = 0, /* Uninitialized board type */ 490*29949e86Sstevel UNKNOWN_BOARD, /* Unknown board type */ 491*29949e86Sstevel CPU_BOARD, /* System board CPU(s) */ 492*29949e86Sstevel MEM_BOARD, /* System board no CPUs */ 493*29949e86Sstevel IO_2SBUS_BOARD, /* 2 SBus & SOC IO Board */ 494*29949e86Sstevel IO_SBUS_FFB_BOARD, /* SBus & FFB SOC IO Board */ 495*29949e86Sstevel IO_PCI_BOARD, /* PCI IO Board */ 496*29949e86Sstevel DISK_BOARD, /* Disk Drive Board */ 497*29949e86Sstevel CLOCK_BOARD, /* System Clock board */ 498*29949e86Sstevel IO_2SBUS_SOCPLUS_BOARD, /* 2 SBus & SOC+ IO board */ 499*29949e86Sstevel IO_SBUS_FFB_SOCPLUS_BOARD /* SBus&FFB&SOC+ board */ 500*29949e86Sstevel }; 501*29949e86Sstevel 502*29949e86Sstevel /* 503*29949e86Sstevel * Defined strings for comparing with OBP board-type property. If OBP ever 504*29949e86Sstevel * changes the board-type properties, these string defines must be changed 505*29949e86Sstevel * as well. 506*29949e86Sstevel */ 507*29949e86Sstevel #define CPU_BD_NAME "cpu" 508*29949e86Sstevel #define MEM_BD_NAME "mem" 509*29949e86Sstevel #define IO_2SBUS_BD_NAME "dual-sbus" 510*29949e86Sstevel #define IO_SBUS_FFB_BD_NAME "upa-sbus" 511*29949e86Sstevel #define IO_PCI_BD_NAME "dual-pci" 512*29949e86Sstevel #define DISK_BD_NAME "disk" 513*29949e86Sstevel #define IO_2SBUS_SOCPLUS_BD_NAME "dual-sbus-soc+" 514*29949e86Sstevel #define IO_SBUS_FFB_SOCPLUS_BD_NAME "upa-sbus-soc+" 515*29949e86Sstevel 516*29949e86Sstevel /* 517*29949e86Sstevel * The following structures and union are needed because the bd_info 518*29949e86Sstevel * structure describes all types of system boards. 519*29949e86Sstevel * XXX - We cannot determine Spitfire rev from JTAG scan, so it is 520*29949e86Sstevel * left blank for now. Future implementations might fill in this info. 521*29949e86Sstevel */ 522*29949e86Sstevel struct cpu_info { 523*29949e86Sstevel int cpu_rev; /* CPU revision */ 524*29949e86Sstevel int cpu_speed; /* rated speed of CPU in MHz */ 525*29949e86Sstevel int cpu_compid; /* CPU component ID */ 526*29949e86Sstevel int sdb0_compid; /* SDB component ID */ 527*29949e86Sstevel int sdb1_compid; /* SDB component ID */ 528*29949e86Sstevel int ec_compid; /* Ecache RAM ID, needed for cache size */ 529*29949e86Sstevel int cache_size; /* Cache size in bytes */ 530*29949e86Sstevel int cpu_sram_mode; /* module's sram mode */ 531*29949e86Sstevel int cpu_detected; /* Something on the CPU JTAG ring. */ 532*29949e86Sstevel }; 533*29949e86Sstevel 534*29949e86Sstevel struct io1_info { 535*29949e86Sstevel int sio0_compid; /* Sysio component ID */ 536*29949e86Sstevel int sio1_compid; /* Sysio component ID */ 537*29949e86Sstevel int hme_compid; /* several revs in existence */ 538*29949e86Sstevel int soc_compid; /* SOC */ 539*29949e86Sstevel }; 540*29949e86Sstevel 541*29949e86Sstevel struct io1plus_info { 542*29949e86Sstevel int sio0_compid; /* Sysio component ID */ 543*29949e86Sstevel int sio1_compid; /* Sysio component ID */ 544*29949e86Sstevel int hme_compid; /* several revs in existence */ 545*29949e86Sstevel int socplus_compid; /* SOC+ */ 546*29949e86Sstevel }; 547*29949e86Sstevel 548*29949e86Sstevel /* Defines for the FFB size field */ 549*29949e86Sstevel #define FFB_FAILED -1 550*29949e86Sstevel #define FFB_NOT_FOUND 0 551*29949e86Sstevel #define FFB_SINGLE 1 552*29949e86Sstevel #define FFB_DOUBLE 2 553*29949e86Sstevel 554*29949e86Sstevel struct io2_info { 555*29949e86Sstevel int fbc_compid; /* FBC component ID */ 556*29949e86Sstevel int ffb_size; /* not present, single or dbl buffered */ 557*29949e86Sstevel int sio1_compid; /* Sysio component ID */ 558*29949e86Sstevel int hme_compid; /* several revs in existence */ 559*29949e86Sstevel int soc_compid; /* SOC component ID */ 560*29949e86Sstevel }; 561*29949e86Sstevel 562*29949e86Sstevel struct io2plus_info { 563*29949e86Sstevel int fbc_compid; /* FBC component ID */ 564*29949e86Sstevel int ffb_size; /* not present, single or dbl buffered */ 565*29949e86Sstevel int sio1_compid; /* Sysio component ID */ 566*29949e86Sstevel int hme_compid; /* several revs in existence */ 567*29949e86Sstevel int socplus_compid; /* or SOC+ component ID */ 568*29949e86Sstevel }; 569*29949e86Sstevel 570*29949e86Sstevel struct io3_info { 571*29949e86Sstevel int psyo0_compid; /* Psycho+ component ID */ 572*29949e86Sstevel int psyo1_compid; /* Psycho+ component ID */ 573*29949e86Sstevel int cheo_compid; /* Cheerio component ID */ 574*29949e86Sstevel }; 575*29949e86Sstevel 576*29949e86Sstevel struct dsk_info { 577*29949e86Sstevel int disk_pres[2]; 578*29949e86Sstevel int disk_id[2]; 579*29949e86Sstevel }; 580*29949e86Sstevel 581*29949e86Sstevel union bd_un { 582*29949e86Sstevel struct cpu_info cpu[2]; 583*29949e86Sstevel struct io1_info io1; 584*29949e86Sstevel struct io2_info io2; 585*29949e86Sstevel struct io3_info io3; 586*29949e86Sstevel struct dsk_info dsk; 587*29949e86Sstevel struct io1plus_info io1plus; 588*29949e86Sstevel struct io2plus_info io2plus; 589*29949e86Sstevel }; 590*29949e86Sstevel 591*29949e86Sstevel /* 592*29949e86Sstevel * board_state and bd_info are maintained for backward 593*29949e86Sstevel * compatibility with prtdiag and others user programs that may rely 594*29949e86Sstevel * on them. 595*29949e86Sstevel */ 596*29949e86Sstevel enum board_state { 597*29949e86Sstevel UNKNOWN_STATE = 0, /* Unknown board */ 598*29949e86Sstevel ACTIVE_STATE, /* active and working */ 599*29949e86Sstevel HOTPLUG_STATE, /* Hot plugged board */ 600*29949e86Sstevel LOWPOWER_STATE, /* Powered down board */ 601*29949e86Sstevel DISABLED_STATE, /* Board disabled by PROM */ 602*29949e86Sstevel FAILED_STATE /* Board failed by POST */ 603*29949e86Sstevel }; 604*29949e86Sstevel 605*29949e86Sstevel struct bd_info { 606*29949e86Sstevel enum board_type type; /* Type of board */ 607*29949e86Sstevel enum board_state state; /* current state of this board */ 608*29949e86Sstevel int board; /* board number */ 609*29949e86Sstevel int fhc_compid; /* fhc component id */ 610*29949e86Sstevel int ac_compid; /* ac component id */ 611*29949e86Sstevel char prom_rev[64]; /* best guess as to what is needed */ 612*29949e86Sstevel union bd_un bd; 613*29949e86Sstevel }; 614*29949e86Sstevel 615*29949e86Sstevel /* 616*29949e86Sstevel * Config admin interface. 617*29949e86Sstevel * 618*29949e86Sstevel * Receptacle states. 619*29949e86Sstevel */ 620*29949e86Sstevel typedef enum { 621*29949e86Sstevel SYSC_CFGA_RSTATE_EMPTY = 0, /* Empty state */ 622*29949e86Sstevel SYSC_CFGA_RSTATE_DISCONNECTED, /* DISCONNECTED state */ 623*29949e86Sstevel SYSC_CFGA_RSTATE_CONNECTED /* CONNECTED state */ 624*29949e86Sstevel } sysc_cfga_rstate_t; 625*29949e86Sstevel 626*29949e86Sstevel /* 627*29949e86Sstevel * Occupant states. 628*29949e86Sstevel */ 629*29949e86Sstevel typedef enum { 630*29949e86Sstevel SYSC_CFGA_OSTATE_UNCONFIGURED = 0, /* UNCONFIGURED state */ 631*29949e86Sstevel SYSC_CFGA_OSTATE_CONFIGURED /* CONFIGURED state */ 632*29949e86Sstevel } sysc_cfga_ostate_t; 633*29949e86Sstevel 634*29949e86Sstevel /* 635*29949e86Sstevel * Receptacle/Occupant condition. 636*29949e86Sstevel */ 637*29949e86Sstevel typedef enum { 638*29949e86Sstevel SYSC_CFGA_COND_UNKNOWN = 0, /* Unknown condition */ 639*29949e86Sstevel SYSC_CFGA_COND_OK, /* Condition OK */ 640*29949e86Sstevel SYSC_CFGA_COND_FAILING, /* Failing */ 641*29949e86Sstevel SYSC_CFGA_COND_FAILED, /* Failed */ 642*29949e86Sstevel SYSC_CFGA_COND_UNUSABLE /* Unusable */ 643*29949e86Sstevel } sysc_cfga_cond_t; 644*29949e86Sstevel 645*29949e86Sstevel /* 646*29949e86Sstevel * Error definitions for CFGADM platform library 647*29949e86Sstevel */ 648*29949e86Sstevel typedef enum { 649*29949e86Sstevel SYSC_ERR_DEFAULT = 0, /* generic errors */ 650*29949e86Sstevel SYSC_ERR_INTRANS, /* hardware in transition */ 651*29949e86Sstevel SYSC_ERR_UTHREAD, /* can't stop user thread */ 652*29949e86Sstevel SYSC_ERR_KTHREAD, /* can't stop kernel thread */ 653*29949e86Sstevel SYSC_ERR_SUSPEND, /* can't suspend a device */ 654*29949e86Sstevel SYSC_ERR_RESUME, /* can't resume a device */ 655*29949e86Sstevel SYSC_ERR_POWER, /* not enough power for slot */ 656*29949e86Sstevel SYSC_ERR_COOLING, /* not enough cooling for slot */ 657*29949e86Sstevel SYSC_ERR_PRECHARGE, /* not enough precharge for slot */ 658*29949e86Sstevel SYSC_ERR_HOTPLUG, /* Hot Plug Unavailable */ 659*29949e86Sstevel SYSC_ERR_HW_COMPAT, /* incompatible hardware found during dr */ 660*29949e86Sstevel SYSC_ERR_NON_DR_PROM, /* prom not support Dynamic Reconfiguration */ 661*29949e86Sstevel SYSC_ERR_CORE_RESOURCE, /* core resource cannot be removed */ 662*29949e86Sstevel SYSC_ERR_PROM, /* error encountered in OBP/POST */ 663*29949e86Sstevel SYSC_ERR_DR_INIT, /* error encountered in sysc_dr_init op */ 664*29949e86Sstevel SYSC_ERR_NDI_ATTACH, /* error encountered in NDI attach operations */ 665*29949e86Sstevel SYSC_ERR_NDI_DETACH, /* error encountered in NDI detach operations */ 666*29949e86Sstevel SYSC_ERR_RSTATE, /* wrong receptacle state */ 667*29949e86Sstevel SYSC_ERR_OSTATE, /* wrong occupant state */ 668*29949e86Sstevel SYSC_ERR_COND /* invalid condition */ 669*29949e86Sstevel } sysc_err_t; 670*29949e86Sstevel 671*29949e86Sstevel /* 672*29949e86Sstevel * Config admin structure. 673*29949e86Sstevel */ 674*29949e86Sstevel typedef struct sysc_cfga_stat { 675*29949e86Sstevel /* generic representation of the attachment point below */ 676*29949e86Sstevel sysc_cfga_rstate_t rstate; /* current receptacle state */ 677*29949e86Sstevel sysc_cfga_ostate_t ostate; /* current occupant state */ 678*29949e86Sstevel sysc_cfga_cond_t condition; /* current board condition */ 679*29949e86Sstevel time32_t last_change; /* last state/condition change */ 680*29949e86Sstevel uint_t in_transition:1; /* board is in_transition */ 681*29949e86Sstevel 682*29949e86Sstevel /* platform specific below */ 683*29949e86Sstevel enum board_type type; /* Type of board */ 684*29949e86Sstevel int board; /* board number */ 685*29949e86Sstevel int fhc_compid; /* fhc component id */ 686*29949e86Sstevel int ac_compid; /* ac component id */ 687*29949e86Sstevel char prom_rev[64]; /* best guess as to what is needed */ 688*29949e86Sstevel union bd_un bd; 689*29949e86Sstevel uint_t no_detach:1; /* board is non_detachable */ 690*29949e86Sstevel uint_t plus_board:1; /* board is 98 MHz capable */ 691*29949e86Sstevel } sysc_cfga_stat_t; 692*29949e86Sstevel 693*29949e86Sstevel /* 694*29949e86Sstevel * Config admin command structure for SYSC_CFGA ioctls. 695*29949e86Sstevel */ 696*29949e86Sstevel typedef struct sysc_cfga_cmd { 697*29949e86Sstevel uint_t force:1; /* force this state transition */ 698*29949e86Sstevel uint_t test:1; /* Need to test hardware */ 699*29949e86Sstevel int arg; /* generic data for test */ 700*29949e86Sstevel sysc_err_t errtype; /* error code returned */ 701*29949e86Sstevel char *outputstr; /* output returned from ioctl */ 702*29949e86Sstevel } sysc_cfga_cmd_t; 703*29949e86Sstevel 704*29949e86Sstevel typedef struct sysc_cfga_cmd32 { 705*29949e86Sstevel uint_t force:1; /* force this state transition */ 706*29949e86Sstevel uint_t test:1; /* Need to test hardware */ 707*29949e86Sstevel int arg; /* generic data for test */ 708*29949e86Sstevel sysc_err_t errtype; /* error code returned */ 709*29949e86Sstevel caddr32_t outputstr; /* output returned from ioctl */ 710*29949e86Sstevel } sysc_cfga_cmd32_t; 711*29949e86Sstevel 712*29949e86Sstevel typedef struct sysc_cfga_pkt { 713*29949e86Sstevel sysc_cfga_cmd_t cmd_cfga; 714*29949e86Sstevel char *errbuf; /* internal error buffer */ 715*29949e86Sstevel } sysc_cfga_pkt_t; 716*29949e86Sstevel 717*29949e86Sstevel /* 718*29949e86Sstevel * Sysctrl DR sequencer interface. 719*29949e86Sstevel */ 720*29949e86Sstevel typedef struct sysc_dr_handle { 721*29949e86Sstevel dev_info_t **dip_list; /* list of top dips for board */ 722*29949e86Sstevel int dip_list_len; /* length devinfo list */ 723*29949e86Sstevel int flags; /* dr specific flags */ 724*29949e86Sstevel int error; /* dr operation error */ 725*29949e86Sstevel char *errstr; /* dr config/unfig error message */ 726*29949e86Sstevel } sysc_dr_handle_t; 727*29949e86Sstevel 728*29949e86Sstevel #define SYSC_DR_MAX_NODE 32 729*29949e86Sstevel #define SYSC_DR_FHC 0x1 /* connect phase init (fhc) */ 730*29949e86Sstevel #define SYSC_DR_DEVS 0x2 /* config phase init (devices) */ 731*29949e86Sstevel #define SYSC_DR_FORCE 0x4 /* force detach */ 732*29949e86Sstevel #define SYSC_DR_REMOVE 0x8 /* remove dev_info */ 733*29949e86Sstevel 734*29949e86Sstevel #define SYSC_DR_HANDLE_FHC 0x0 735*29949e86Sstevel #define SYSC_DR_HANDLE_DEVS 0x1 736*29949e86Sstevel 737*29949e86Sstevel /* 738*29949e86Sstevel * Sysctrl event interface. 739*29949e86Sstevel */ 740*29949e86Sstevel typedef enum sysc_evt { 741*29949e86Sstevel SYSC_EVT_BD_EMPTY = 0, 742*29949e86Sstevel SYSC_EVT_BD_PRESENT, 743*29949e86Sstevel SYSC_EVT_BD_DISABLED, 744*29949e86Sstevel SYSC_EVT_BD_FAILED, 745*29949e86Sstevel SYSC_EVT_BD_OVERTEMP, 746*29949e86Sstevel SYSC_EVT_BD_TEMP_OK, 747*29949e86Sstevel SYSC_EVT_BD_PS_CHANGE, 748*29949e86Sstevel SYSC_EVT_BD_INS_FAILED, 749*29949e86Sstevel SYSC_EVT_BD_INSERTED, 750*29949e86Sstevel SYSC_EVT_BD_REMOVED, 751*29949e86Sstevel SYSC_EVT_BD_HP_DISABLED, 752*29949e86Sstevel SYSC_EVT_BD_CORE_RESOURCE_DISCONNECT 753*29949e86Sstevel } sysc_evt_t; 754*29949e86Sstevel 755*29949e86Sstevel /* 756*29949e86Sstevel * sysctrl audit message events 757*29949e86Sstevel */ 758*29949e86Sstevel typedef enum sysc_audit_evt { 759*29949e86Sstevel SYSC_AUDIT_RSTATE_EMPTY = 0, 760*29949e86Sstevel SYSC_AUDIT_RSTATE_CONNECT, 761*29949e86Sstevel SYSC_AUDIT_RSTATE_DISCONNECT, 762*29949e86Sstevel SYSC_AUDIT_RSTATE_SUCCEEDED, 763*29949e86Sstevel SYSC_AUDIT_RSTATE_EMPTY_FAILED, 764*29949e86Sstevel SYSC_AUDIT_RSTATE_CONNECT_FAILED, 765*29949e86Sstevel SYSC_AUDIT_RSTATE_DISCONNECT_FAILED, 766*29949e86Sstevel SYSC_AUDIT_OSTATE_CONFIGURE, 767*29949e86Sstevel SYSC_AUDIT_OSTATE_UNCONFIGURE, 768*29949e86Sstevel SYSC_AUDIT_OSTATE_SUCCEEDED, 769*29949e86Sstevel SYSC_AUDIT_OSTATE_CONFIGURE_FAILED, 770*29949e86Sstevel SYSC_AUDIT_OSTATE_UNCONFIGURE_FAILED 771*29949e86Sstevel } sysc_audit_evt_t; 772*29949e86Sstevel 773*29949e86Sstevel typedef struct { 774*29949e86Sstevel void (*update)(void *, sysc_cfga_stat_t *, sysc_evt_t); 775*29949e86Sstevel void *soft; 776*29949e86Sstevel } sysc_evt_handle_t; 777*29949e86Sstevel 778*29949e86Sstevel void fhc_bd_sc_register(void f(void *, sysc_cfga_stat_t *, sysc_evt_t), void *); 779*29949e86Sstevel 780*29949e86Sstevel /* 781*29949e86Sstevel * The board list structure is the central storage for the kernel's 782*29949e86Sstevel * knowledge of normally booted and hotplugged boards. 783*29949e86Sstevel */ 784*29949e86Sstevel typedef struct bd_list { 785*29949e86Sstevel struct fhc_soft_state *softsp; /* handle for DDI soft state */ 786*29949e86Sstevel sysc_cfga_stat_t sc; /* board info */ 787*29949e86Sstevel sysc_dr_handle_t sh[2]; /* sysctrl dr interface */ 788*29949e86Sstevel void *dev_softsp; /* opaque pointer to device state */ 789*29949e86Sstevel void *ac_softsp; /* opaque pointer to our AC */ 790*29949e86Sstevel struct kstat *ksp; /* pointer used in kstat destroy */ 791*29949e86Sstevel int fault; /* failure on this board? */ 792*29949e86Sstevel int flags; /* board state flags */ 793*29949e86Sstevel } fhc_bd_t; 794*29949e86Sstevel 795*29949e86Sstevel /* 796*29949e86Sstevel * Fhc_bd.c holds 2 resizable arrays of boards. First for clock 797*29949e86Sstevel * boards under central and second for normally booted and 798*29949e86Sstevel * hotplugged boards. 799*29949e86Sstevel */ 800*29949e86Sstevel typedef struct resizable_bd_list { 801*29949e86Sstevel fhc_bd_t **boards; 802*29949e86Sstevel int size; 803*29949e86Sstevel int last; 804*29949e86Sstevel int sorted; 805*29949e86Sstevel } fhc_bd_resizable_t; 806*29949e86Sstevel 807*29949e86Sstevel #define BDF_VALID 0x1 /* board entry valid */ 808*29949e86Sstevel #define BDF_DETACH 0x2 /* board detachable */ 809*29949e86Sstevel #define BDF_DISABLED 0x4 /* board disabled */ 810*29949e86Sstevel 811*29949e86Sstevel #define SYSC_OUTPUT_LEN MAXPATHLEN /* output str len */ 812*29949e86Sstevel 813*29949e86Sstevel /* 814*29949e86Sstevel * Board list management interface. 815*29949e86Sstevel */ 816*29949e86Sstevel int fhc_max_boards(void); 817*29949e86Sstevel void fhc_bdlist_init(void); 818*29949e86Sstevel void fhc_bdlist_fini(void); 819*29949e86Sstevel void fhc_bdlist_prime(int, int, int); 820*29949e86Sstevel fhc_bd_t *fhc_bdlist_lock(int); 821*29949e86Sstevel void fhc_bdlist_unlock(void); 822*29949e86Sstevel 823*29949e86Sstevel void fhc_bd_init(struct fhc_soft_state *, int, enum board_type); 824*29949e86Sstevel fhc_bd_t *fhc_bd(int); 825*29949e86Sstevel fhc_bd_t *fhc_bd_clock(void); 826*29949e86Sstevel fhc_bd_t *fhc_bd_first(void); 827*29949e86Sstevel fhc_bd_t *fhc_bd_next(fhc_bd_t *); 828*29949e86Sstevel enum board_type fhc_bd_type(int); 829*29949e86Sstevel char *fhc_bd_typestr(enum board_type); 830*29949e86Sstevel int fhc_bd_valid(int); 831*29949e86Sstevel int fhc_bd_detachable(int); 832*29949e86Sstevel 833*29949e86Sstevel int fhc_bd_insert_scan(void); 834*29949e86Sstevel int fhc_bd_remove_scan(void); 835*29949e86Sstevel int fhc_bd_test(int, sysc_cfga_pkt_t *); 836*29949e86Sstevel int fhc_bd_test_set_cond(int, sysc_cfga_pkt_t *); 837*29949e86Sstevel void fhc_bd_update(int, sysc_evt_t); 838*29949e86Sstevel void fhc_bd_env_set(int, void *); 839*29949e86Sstevel 840*29949e86Sstevel int fhc_bdlist_locked(void); 841*29949e86Sstevel int fhc_bd_busy(int); 842*29949e86Sstevel int fhc_bd_is_jtag_master(int); 843*29949e86Sstevel int fhc_bd_is_plus(int); 844*29949e86Sstevel 845*29949e86Sstevel #if defined(_KERNEL) 846*29949e86Sstevel 847*29949e86Sstevel /* 848*29949e86Sstevel * In order to indicate that we are in an environmental chamber, or 849*29949e86Sstevel * oven, the test people will set the 'mfg-mode' property in the 850*29949e86Sstevel * options node to 'chamber'. Therefore we have the following define. 851*29949e86Sstevel */ 852*29949e86Sstevel #define CHAMBER_VALUE "chamber" 853*29949e86Sstevel 854*29949e86Sstevel /* 855*29949e86Sstevel * zs design for fhc has two zs' interrupting on same interrupt mondo 856*29949e86Sstevel * This requires us to poll for zs and zs alone. The poll list has been 857*29949e86Sstevel * defined as a fixed size for simplicity. 858*29949e86Sstevel */ 859*29949e86Sstevel #define MAX_ZS_CNT 2 860*29949e86Sstevel 861*29949e86Sstevel /* FHC Interrupt routine wrapper structure */ 862*29949e86Sstevel struct fhc_wrapper_arg { 863*29949e86Sstevel struct fhc_soft_state *softsp; 864*29949e86Sstevel volatile uint_t *clear_reg; 865*29949e86Sstevel volatile uint_t *mapping_reg; 866*29949e86Sstevel dev_info_t *child; 867*29949e86Sstevel uint32_t inum; 868*29949e86Sstevel uint_t (*funcp)(caddr_t, caddr_t); 869*29949e86Sstevel caddr_t arg1; 870*29949e86Sstevel caddr_t arg2; 871*29949e86Sstevel }; 872*29949e86Sstevel 873*29949e86Sstevel /* 874*29949e86Sstevel * The JTAG master command structure. It contains the address of the 875*29949e86Sstevel * the JTAG controller on this system board. The controller can only 876*29949e86Sstevel * be used if this FHC holds the JTAG master signal. This is checked 877*29949e86Sstevel * by reading the JTAG control register on this FHC. 878*29949e86Sstevel */ 879*29949e86Sstevel struct jt_mstr { 880*29949e86Sstevel volatile uint_t *jtag_cmd; 881*29949e86Sstevel int is_master; 882*29949e86Sstevel kmutex_t lock; 883*29949e86Sstevel }; 884*29949e86Sstevel 885*29949e86Sstevel /* Functions exported to manage the fault list */ 886*29949e86Sstevel void reg_fault(int, enum ft_type, enum ft_class); 887*29949e86Sstevel void clear_fault(int, enum ft_type, enum ft_class); 888*29949e86Sstevel int process_fault_list(void); 889*29949e86Sstevel void create_ft_kstats(int); 890*29949e86Sstevel 891*29949e86Sstevel /* memloc's are protected under the bdlist lock */ 892*29949e86Sstevel struct fhc_memloc { 893*29949e86Sstevel struct fhc_memloc *next; 894*29949e86Sstevel int board; /* reference our board element */ 895*29949e86Sstevel uint_t pa; /* base PA of this segment (in MB) */ 896*29949e86Sstevel uint_t size; /* size of this segment (in MB) */ 897*29949e86Sstevel }; 898*29949e86Sstevel 899*29949e86Sstevel /* Functions used to manage memory 'segments' */ 900*29949e86Sstevel #define FHC_MEMLOC_SHIFT 20 901*29949e86Sstevel #define FHC_MEMLOC_MAX (0x10000000000ull >> FHC_MEMLOC_SHIFT) 902*29949e86Sstevel void fhc_add_memloc(int board, uint64_t pa, uint_t size); 903*29949e86Sstevel void fhc_del_memloc(int board); 904*29949e86Sstevel uint64_t fhc_find_memloc_gap(uint_t size); 905*29949e86Sstevel void fhc_program_memory(int board, uint64_t base); 906*29949e86Sstevel 907*29949e86Sstevel /* Structures used in the driver to manage the hardware */ 908*29949e86Sstevel struct fhc_soft_state { 909*29949e86Sstevel dev_info_t *dip; /* dev info of myself */ 910*29949e86Sstevel struct bd_list *list; /* pointer to board list entry */ 911*29949e86Sstevel int is_central; /* A central space instance of FHC */ 912*29949e86Sstevel volatile uint_t *id; /* FHC ID register */ 913*29949e86Sstevel volatile uint_t *rctrl; /* FHC Reset Control and Status */ 914*29949e86Sstevel volatile uint_t *bsr; /* FHC Board Status register */ 915*29949e86Sstevel volatile uint_t *jtag_ctrl; /* JTAG Control register */ 916*29949e86Sstevel volatile uint_t *igr; /* Interrupt Group Number */ 917*29949e86Sstevel struct intr_regs intr_regs[FHC_MAX_INO]; 918*29949e86Sstevel struct fhc_wrapper_arg poll_list[MAX_ZS_CNT]; 919*29949e86Sstevel struct fhc_wrapper_arg *intr_list[FHC_MAX_INO]; 920*29949e86Sstevel kmutex_t poll_list_lock; 921*29949e86Sstevel uchar_t spurious_zs_cntr; /* Spurious counter for zs devices */ 922*29949e86Sstevel kmutex_t pokefault_mutex; 923*29949e86Sstevel int pokefault; 924*29949e86Sstevel 925*29949e86Sstevel /* this lock protects the following data */ 926*29949e86Sstevel /* ! non interrupt use only ! */ 927*29949e86Sstevel kmutex_t ctrl_lock; /* lock for access to FHC CSR */ 928*29949e86Sstevel volatile uint_t *ctrl; /* FHC Control and Status */ 929*29949e86Sstevel 930*29949e86Sstevel /* The JTAG master structure has internal locking */ 931*29949e86Sstevel struct jt_mstr jt_master; 932*29949e86Sstevel 933*29949e86Sstevel /* the pointer to the kstat is stored for deletion upon detach */ 934*29949e86Sstevel kstat_t *fhc_ksp; 935*29949e86Sstevel }; 936*29949e86Sstevel 937*29949e86Sstevel /* 938*29949e86Sstevel * Function shared with child drivers which require fhc 939*29949e86Sstevel * support. They gain access to this function through the use of the 940*29949e86Sstevel * _depends_on variable. 941*29949e86Sstevel */ 942*29949e86Sstevel enum board_type get_board_type(int board); 943*29949e86Sstevel void update_temp(dev_info_t *pdip, struct temp_stats *envstat, uchar_t value); 944*29949e86Sstevel enum temp_trend temp_trend(struct temp_stats *); 945*29949e86Sstevel void fhc_reboot(void); 946*29949e86Sstevel int overtemp_kstat_update(kstat_t *ksp, int rw); 947*29949e86Sstevel int temp_override_kstat_update(kstat_t *ksp, int rw); 948*29949e86Sstevel void init_temp_arrays(struct temp_stats *envstat); 949*29949e86Sstevel void update_board_leds(fhc_bd_t *, uint_t, uint_t); 950*29949e86Sstevel struct jt_mstr *jtag_master_lock(void); 951*29949e86Sstevel void jtag_master_unlock(struct jt_mstr *); 952*29949e86Sstevel extern int fhc_board_poweroffcpus(int board, char *errbuf, int cpu_flags); 953*29949e86Sstevel 954*29949e86Sstevel 955*29949e86Sstevel /* FHC interrupt specification */ 956*29949e86Sstevel struct fhcintrspec { 957*29949e86Sstevel uint_t mondo; 958*29949e86Sstevel uint_t pil; 959*29949e86Sstevel dev_info_t *child; 960*29949e86Sstevel struct fhc_wrapper_arg *handler_arg; 961*29949e86Sstevel }; 962*29949e86Sstevel 963*29949e86Sstevel /* kstat structure used by fhc to pass data to user programs. */ 964*29949e86Sstevel struct fhc_kstat { 965*29949e86Sstevel struct kstat_named csr; /* FHC Control and Status Register */ 966*29949e86Sstevel struct kstat_named bsr; /* FHC Board Status Register */ 967*29949e86Sstevel }; 968*29949e86Sstevel 969*29949e86Sstevel #endif /* _KERNEL */ 970*29949e86Sstevel 971*29949e86Sstevel #endif /* _ASM */ 972*29949e86Sstevel 973*29949e86Sstevel #ifdef __cplusplus 974*29949e86Sstevel } 975*29949e86Sstevel #endif 976*29949e86Sstevel 977*29949e86Sstevel #endif /* _SYS_FHC_H */ 978