xref: /onnv-gate/usr/src/uts/sun4u/io/px/px_hlib.c (revision 27:c1f182000c0a)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
50Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
60Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
70Sstevel@tonic-gate  * with the License.
80Sstevel@tonic-gate  *
90Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
100Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
110Sstevel@tonic-gate  * See the License for the specific language governing permissions
120Sstevel@tonic-gate  * and limitations under the License.
130Sstevel@tonic-gate  *
140Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
150Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
160Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
170Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
180Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
190Sstevel@tonic-gate  *
200Sstevel@tonic-gate  * CDDL HEADER END
210Sstevel@tonic-gate  */
220Sstevel@tonic-gate /*
230Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
240Sstevel@tonic-gate  * Use is subject to license terms.
250Sstevel@tonic-gate  */
260Sstevel@tonic-gate 
270Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #include <sys/types.h>
300Sstevel@tonic-gate #include <sys/cmn_err.h>
310Sstevel@tonic-gate #include <sys/vmsystm.h>
320Sstevel@tonic-gate #include <sys/vmem.h>
330Sstevel@tonic-gate #include <sys/machsystm.h>	/* lddphys() */
340Sstevel@tonic-gate #include <sys/iommutsb.h>
350Sstevel@tonic-gate #include <sys/pci.h>
360Sstevel@tonic-gate #include <pcie_pwr.h>
370Sstevel@tonic-gate #include <px_obj.h>
380Sstevel@tonic-gate #include "px_regs.h"
390Sstevel@tonic-gate #include "px_csr.h"
400Sstevel@tonic-gate #include "px_lib4u.h"
410Sstevel@tonic-gate 
420Sstevel@tonic-gate /*
430Sstevel@tonic-gate  * Registers that need to be saved and restored during suspend/resume.
440Sstevel@tonic-gate  */
450Sstevel@tonic-gate 
460Sstevel@tonic-gate /*
470Sstevel@tonic-gate  * Registers in the PEC Module.
480Sstevel@tonic-gate  * LPU_RESET should be set to 0ull during resume
490Sstevel@tonic-gate  */
500Sstevel@tonic-gate static uint64_t	pec_config_state_regs[] = {
510Sstevel@tonic-gate 	PEC_CORE_AND_BLOCK_INTERRUPT_ENABLE,
520Sstevel@tonic-gate 	ILU_ERROR_LOG_ENABLE,
530Sstevel@tonic-gate 	ILU_INTERRUPT_ENABLE,
540Sstevel@tonic-gate 	TLU_CONTROL,
550Sstevel@tonic-gate 	TLU_OTHER_EVENT_LOG_ENABLE,
560Sstevel@tonic-gate 	TLU_OTHER_EVENT_INTERRUPT_ENABLE,
570Sstevel@tonic-gate 	TLU_DEVICE_CONTROL,
580Sstevel@tonic-gate 	TLU_LINK_CONTROL,
590Sstevel@tonic-gate 	TLU_UNCORRECTABLE_ERROR_LOG_ENABLE,
600Sstevel@tonic-gate 	TLU_UNCORRECTABLE_ERROR_INTERRUPT_ENABLE,
610Sstevel@tonic-gate 	TLU_CORRECTABLE_ERROR_LOG_ENABLE,
620Sstevel@tonic-gate 	TLU_CORRECTABLE_ERROR_INTERRUPT_ENABLE,
63*27Sjchu 	LPU_LINK_LAYER_INTERRUPT_MASK,
64*27Sjchu 	LPU_PHY_INTERRUPT_MASK,
65*27Sjchu 	LPU_RECEIVE_PHY_INTERRUPT_MASK,
66*27Sjchu 	LPU_TRANSMIT_PHY_INTERRUPT_MASK,
67*27Sjchu 	LPU_GIGABLAZE_GLUE_INTERRUPT_MASK,
68*27Sjchu 	LPU_LTSSM_INTERRUPT_MASK,
69*27Sjchu 	LPU_RESET,
700Sstevel@tonic-gate 	LPU_DEBUG_CONFIG,
710Sstevel@tonic-gate 	LPU_INTERRUPT_MASK,
720Sstevel@tonic-gate 	LPU_LINK_LAYER_CONFIG,
730Sstevel@tonic-gate 	LPU_FLOW_CONTROL_UPDATE_CONTROL,
740Sstevel@tonic-gate 	LPU_TXLINK_FREQUENT_NAK_LATENCY_TIMER_THRESHOLD,
750Sstevel@tonic-gate 	LPU_TXLINK_REPLAY_TIMER_THRESHOLD,
760Sstevel@tonic-gate 	LPU_REPLAY_BUFFER_MAX_ADDRESS,
770Sstevel@tonic-gate 	LPU_TXLINK_RETRY_FIFO_POINTER,
780Sstevel@tonic-gate 	LPU_LTSSM_CONFIG2,
790Sstevel@tonic-gate 	LPU_LTSSM_CONFIG3,
800Sstevel@tonic-gate 	LPU_LTSSM_CONFIG4,
810Sstevel@tonic-gate 	LPU_LTSSM_CONFIG5,
820Sstevel@tonic-gate 	DMC_CORE_AND_BLOCK_INTERRUPT_ENABLE,
830Sstevel@tonic-gate 	DMC_DEBUG_SELECT_FOR_PORT_A,
840Sstevel@tonic-gate 	DMC_DEBUG_SELECT_FOR_PORT_B
850Sstevel@tonic-gate };
860Sstevel@tonic-gate #define	PEC_SIZE (sizeof (pec_config_state_regs))
870Sstevel@tonic-gate #define	PEC_KEYS (PEC_SIZE / sizeof (uint64_t))
880Sstevel@tonic-gate 
890Sstevel@tonic-gate /*
900Sstevel@tonic-gate  * Registers for the MMU module.
910Sstevel@tonic-gate  * MMU_TTE_CACHE_INVALIDATE needs to be cleared. (-1ull)
920Sstevel@tonic-gate  */
930Sstevel@tonic-gate static uint64_t mmu_config_state_regs[] = {
940Sstevel@tonic-gate 	MMU_TSB_CONTROL,
950Sstevel@tonic-gate 	MMU_CONTROL_AND_STATUS,
96*27Sjchu 	MMU_ERROR_LOG_ENABLE,
970Sstevel@tonic-gate 	MMU_INTERRUPT_ENABLE
980Sstevel@tonic-gate };
990Sstevel@tonic-gate #define	MMU_SIZE (sizeof (mmu_config_state_regs))
1000Sstevel@tonic-gate #define	MMU_KEYS (MMU_SIZE / sizeof (uint64_t))
1010Sstevel@tonic-gate 
1020Sstevel@tonic-gate /*
1030Sstevel@tonic-gate  * Registers for the IB Module
1040Sstevel@tonic-gate  */
1050Sstevel@tonic-gate static uint64_t ib_config_state_regs[] = {
1060Sstevel@tonic-gate 	IMU_ERROR_LOG_ENABLE,
1070Sstevel@tonic-gate 	IMU_INTERRUPT_ENABLE
1080Sstevel@tonic-gate };
1090Sstevel@tonic-gate #define	IB_SIZE (sizeof (ib_config_state_regs))
1100Sstevel@tonic-gate #define	IB_KEYS (IB_SIZE / sizeof (uint64_t))
1110Sstevel@tonic-gate #define	IB_MAP_SIZE (INTERRUPT_MAPPING_ENTRIES * sizeof (uint64_t))
1120Sstevel@tonic-gate 
1130Sstevel@tonic-gate /*
1140Sstevel@tonic-gate  * Registers for the CB module.
1150Sstevel@tonic-gate  * JBC_ERROR_STATUS_CLEAR needs to be cleared. (-1ull)
1160Sstevel@tonic-gate  */
1170Sstevel@tonic-gate static uint64_t	cb_config_state_regs[] = {
1180Sstevel@tonic-gate 	JBUS_PARITY_CONTROL,
1190Sstevel@tonic-gate 	JBC_FATAL_RESET_ENABLE,
1200Sstevel@tonic-gate 	JBC_CORE_AND_BLOCK_INTERRUPT_ENABLE,
1210Sstevel@tonic-gate 	JBC_ERROR_LOG_ENABLE,
1220Sstevel@tonic-gate 	JBC_INTERRUPT_ENABLE
1230Sstevel@tonic-gate };
1240Sstevel@tonic-gate #define	CB_SIZE (sizeof (cb_config_state_regs))
1250Sstevel@tonic-gate #define	CB_KEYS (CB_SIZE / sizeof (uint64_t))
1260Sstevel@tonic-gate 
1270Sstevel@tonic-gate static uint64_t	msiq_config_other_regs[] = {
1280Sstevel@tonic-gate 	ERR_COR_MAPPING,
1290Sstevel@tonic-gate 	ERR_NONFATAL_MAPPING,
1300Sstevel@tonic-gate 	ERR_FATAL_MAPPING,
1310Sstevel@tonic-gate 	PM_PME_MAPPING,
1320Sstevel@tonic-gate 	PME_TO_ACK_MAPPING,
1330Sstevel@tonic-gate 	MSI_32_BIT_ADDRESS,
1340Sstevel@tonic-gate 	MSI_64_BIT_ADDRESS
1350Sstevel@tonic-gate };
1360Sstevel@tonic-gate #define	MSIQ_OTHER_SIZE	(sizeof (msiq_config_other_regs))
1370Sstevel@tonic-gate #define	MSIQ_OTHER_KEYS	(MSIQ_OTHER_SIZE / sizeof (uint64_t))
1380Sstevel@tonic-gate 
1390Sstevel@tonic-gate #define	MSIQ_STATE_SIZE		(EVENT_QUEUE_STATE_ENTRIES * sizeof (uint64_t))
1400Sstevel@tonic-gate #define	MSIQ_MAPPING_SIZE	(MSI_MAPPING_ENTRIES * sizeof (uint64_t))
1410Sstevel@tonic-gate 
1420Sstevel@tonic-gate static uint64_t msiq_suspend(devhandle_t dev_hdl, pxu_t *pxu_p);
1430Sstevel@tonic-gate static void msiq_resume(devhandle_t dev_hdl, pxu_t *pxu_p);
1440Sstevel@tonic-gate 
145*27Sjchu /*
146*27Sjchu  * Initialize the module, but do not enable interrupts.
147*27Sjchu  */
1480Sstevel@tonic-gate /* ARGSUSED */
1490Sstevel@tonic-gate void
1500Sstevel@tonic-gate hvio_cb_init(caddr_t xbc_csr_base, pxu_t *pxu_p)
1510Sstevel@tonic-gate {
1520Sstevel@tonic-gate 	uint64_t val;
1530Sstevel@tonic-gate 
1540Sstevel@tonic-gate 	/* Check if we need to enable inverted parity */
1550Sstevel@tonic-gate 	val = (1ULL << JBUS_PARITY_CONTROL_P_EN);
1560Sstevel@tonic-gate 	CSR_XS(xbc_csr_base, JBUS_PARITY_CONTROL, val);
1570Sstevel@tonic-gate 	DBG(DBG_CB, NULL, "hvio_cb_init, JBUS_PARITY_CONTROL: 0x%llx\n",
158*27Sjchu 	    CSR_XR(xbc_csr_base, JBUS_PARITY_CONTROL));
159*27Sjchu 
160*27Sjchu 	val = (1 << JBC_FATAL_RESET_ENABLE_SPARE_P_INT_EN) |
161*27Sjchu 	    (1 << JBC_FATAL_RESET_ENABLE_MB_PEA_P_INT_EN) |
162*27Sjchu 	    (1 << JBC_FATAL_RESET_ENABLE_CPE_P_INT_EN) |
163*27Sjchu 	    (1 << JBC_FATAL_RESET_ENABLE_APE_P_INT_EN) |
164*27Sjchu 	    (1 << JBC_FATAL_RESET_ENABLE_PIO_CPE_INT_EN) |
165*27Sjchu 	    (1 << JBC_FATAL_RESET_ENABLE_JTCEEW_P_INT_EN) |
166*27Sjchu 	    (1 << JBC_FATAL_RESET_ENABLE_JTCEEI_P_INT_EN) |
167*27Sjchu 	    (1 << JBC_FATAL_RESET_ENABLE_JTCEER_P_INT_EN);
1680Sstevel@tonic-gate 	CSR_XS(xbc_csr_base, JBC_FATAL_RESET_ENABLE, val);
1690Sstevel@tonic-gate 	DBG(DBG_CB, NULL, "hvio_cb_init, JBC_FATAL_RESET_ENABLE: 0x%llx\n",
1700Sstevel@tonic-gate 		CSR_XR(xbc_csr_base, JBC_FATAL_RESET_ENABLE));
1710Sstevel@tonic-gate 
1720Sstevel@tonic-gate 	/*
1730Sstevel@tonic-gate 	 * Enable merge, jbc and dmc interrupts.
1740Sstevel@tonic-gate 	 */
1750Sstevel@tonic-gate 	CSR_XS(xbc_csr_base, JBC_CORE_AND_BLOCK_INTERRUPT_ENABLE, -1ull);
1760Sstevel@tonic-gate 	DBG(DBG_CB, NULL,
177*27Sjchu 	    "hvio_cb_init, JBC_CORE_AND_BLOCK_INTERRUPT_ENABLE: 0x%llx\n",
178*27Sjchu 	    CSR_XR(xbc_csr_base, JBC_CORE_AND_BLOCK_INTERRUPT_ENABLE));
1790Sstevel@tonic-gate 
1800Sstevel@tonic-gate 	/*
181*27Sjchu 	 * CSR_V CB's interrupt regs (log, enable, status, clear)
1820Sstevel@tonic-gate 	 */
183*27Sjchu 	DBG(DBG_CB, NULL, "hvio_cb_init, JBC_ERROR_LOG_ENABLE: 0x%llx\n",
184*27Sjchu 	    CSR_XR(xbc_csr_base, JBC_ERROR_LOG_ENABLE));
185*27Sjchu 
1860Sstevel@tonic-gate 	DBG(DBG_CB, NULL, "hvio_cb_init, JBC_INTERRUPT_ENABLE: 0x%llx\n",
187*27Sjchu 	    CSR_XR(xbc_csr_base, JBC_INTERRUPT_ENABLE));
188*27Sjchu 
189*27Sjchu 	DBG(DBG_CB, NULL, "hvio_cb_init, JBC_INTERRUPT_STATUS: 0x%llx\n",
190*27Sjchu 	    CSR_XR(xbc_csr_base, JBC_INTERRUPT_STATUS));
191*27Sjchu 
1920Sstevel@tonic-gate 	DBG(DBG_CB, NULL, "hvio_cb_init, JBC_ERROR_STATUS_CLEAR: 0x%llx\n",
193*27Sjchu 	    CSR_XR(xbc_csr_base, JBC_ERROR_STATUS_CLEAR));
1940Sstevel@tonic-gate }
1950Sstevel@tonic-gate 
196*27Sjchu /*
197*27Sjchu  * Initialize the module, but do not enable interrupts.
198*27Sjchu  */
1990Sstevel@tonic-gate /* ARGSUSED */
2000Sstevel@tonic-gate void
2010Sstevel@tonic-gate hvio_ib_init(caddr_t csr_base, pxu_t *pxu_p)
2020Sstevel@tonic-gate {
2030Sstevel@tonic-gate 	/*
204*27Sjchu 	 * CSR_V IB's interrupt regs (log, enable, status, clear)
2050Sstevel@tonic-gate 	 */
2060Sstevel@tonic-gate 	DBG(DBG_IB, NULL, "hvio_ib_init - IMU_ERROR_LOG_ENABLE: 0x%llx\n",
207*27Sjchu 	    CSR_XR(csr_base, IMU_ERROR_LOG_ENABLE));
208*27Sjchu 
2090Sstevel@tonic-gate 	DBG(DBG_IB, NULL, "hvio_ib_init - IMU_INTERRUPT_ENABLE: 0x%llx\n",
210*27Sjchu 	    CSR_XR(csr_base, IMU_INTERRUPT_ENABLE));
211*27Sjchu 
2120Sstevel@tonic-gate 	DBG(DBG_IB, NULL, "hvio_ib_init - IMU_INTERRUPT_STATUS: 0x%llx\n",
213*27Sjchu 	    CSR_XR(csr_base, IMU_INTERRUPT_STATUS));
214*27Sjchu 
2150Sstevel@tonic-gate 	DBG(DBG_IB, NULL, "hvio_ib_init - IMU_ERROR_STATUS_CLEAR: 0x%llx\n",
216*27Sjchu 	    CSR_XR(csr_base, IMU_ERROR_STATUS_CLEAR));
2170Sstevel@tonic-gate }
2180Sstevel@tonic-gate 
219*27Sjchu /*
220*27Sjchu  * Initialize the module, but do not enable interrupts.
221*27Sjchu  */
2220Sstevel@tonic-gate /* ARGSUSED */
2230Sstevel@tonic-gate static void
2240Sstevel@tonic-gate ilu_init(caddr_t csr_base, pxu_t *pxu_p)
2250Sstevel@tonic-gate {
2260Sstevel@tonic-gate 	/*
227*27Sjchu 	 * CSR_V ILU's interrupt regs (log, enable, status, clear)
2280Sstevel@tonic-gate 	 */
229*27Sjchu 	DBG(DBG_ILU, NULL, "ilu_init - ILU_ERROR_LOG_ENABLE: 0x%llx\n",
230*27Sjchu 	    CSR_XR(csr_base, ILU_ERROR_LOG_ENABLE));
231*27Sjchu 
2320Sstevel@tonic-gate 	DBG(DBG_ILU, NULL, "ilu_init - ILU_INTERRUPT_ENABLE: 0x%llx\n",
233*27Sjchu 	    CSR_XR(csr_base, ILU_INTERRUPT_ENABLE));
234*27Sjchu 
2350Sstevel@tonic-gate 	DBG(DBG_ILU, NULL, "ilu_init - ILU_INTERRUPT_STATUS: 0x%llx\n",
236*27Sjchu 	    CSR_XR(csr_base, ILU_INTERRUPT_STATUS));
237*27Sjchu 
2380Sstevel@tonic-gate 	DBG(DBG_ILU, NULL, "ilu_init - ILU_ERROR_STATUS_CLEAR: 0x%llx\n",
239*27Sjchu 	    CSR_XR(csr_base, ILU_ERROR_STATUS_CLEAR));
2400Sstevel@tonic-gate }
2410Sstevel@tonic-gate 
242*27Sjchu /*
243*27Sjchu  * Initialize the module, but do not enable interrupts.
244*27Sjchu  */
2450Sstevel@tonic-gate static void
2460Sstevel@tonic-gate tlu_init(caddr_t csr_base, pxu_t *pxu_p)
2470Sstevel@tonic-gate {
2480Sstevel@tonic-gate 	uint64_t val;
2490Sstevel@tonic-gate 
2500Sstevel@tonic-gate 	/*
2510Sstevel@tonic-gate 	 * CSR_V TLU_CONTROL Expect OBP ???
2520Sstevel@tonic-gate 	 */
2530Sstevel@tonic-gate 
2540Sstevel@tonic-gate 	/*
2550Sstevel@tonic-gate 	 * L0s entry default timer value - 7.0 us
2560Sstevel@tonic-gate 	 * Completion timeout select default value - 67.1 ms and
2570Sstevel@tonic-gate 	 * OBP will set this value.
2580Sstevel@tonic-gate 	 *
2590Sstevel@tonic-gate 	 * Configuration - Bit 0 should always be 0 for upstream port.
2600Sstevel@tonic-gate 	 * Bit 1 is clock - how is this related to the clock bit in TLU
2610Sstevel@tonic-gate 	 * Link Control register?  Both are hardware dependent and likely
2620Sstevel@tonic-gate 	 * set by OBP.
2630Sstevel@tonic-gate 	 *
2640Sstevel@tonic-gate 	 * Disable non-posted write bit - ordering by setting
2650Sstevel@tonic-gate 	 * NPWR_EN bit to force serialization of writes.
2660Sstevel@tonic-gate 	 */
2670Sstevel@tonic-gate 	val = CSR_XR(csr_base, TLU_CONTROL);
2680Sstevel@tonic-gate 
2690Sstevel@tonic-gate 	if (pxu_p->chip_id == FIRE_VER_10) {
2700Sstevel@tonic-gate 		val |= (TLU_CONTROL_L0S_TIM_DEFAULT <<
2710Sstevel@tonic-gate 		    FIRE10_TLU_CONTROL_L0S_TIM) |
2720Sstevel@tonic-gate 		    (1ull << FIRE10_TLU_CONTROL_NPWR_EN) |
2730Sstevel@tonic-gate 		    TLU_CONTROL_CONFIG_DEFAULT;
2740Sstevel@tonic-gate 	} else {
2750Sstevel@tonic-gate 		/* Default case is FIRE2.0 */
2760Sstevel@tonic-gate 		val |= (TLU_CONTROL_L0S_TIM_DEFAULT << TLU_CONTROL_L0S_TIM) |
2770Sstevel@tonic-gate 		    (1ull << TLU_CONTROL_NPWR_EN) | TLU_CONTROL_CONFIG_DEFAULT;
2780Sstevel@tonic-gate 	}
2790Sstevel@tonic-gate 
2800Sstevel@tonic-gate 	CSR_XS(csr_base, TLU_CONTROL, val);
2810Sstevel@tonic-gate 	DBG(DBG_TLU, NULL, "tlu_init - TLU_CONTROL: 0x%llx\n",
2820Sstevel@tonic-gate 	    CSR_XR(csr_base, TLU_CONTROL));
2830Sstevel@tonic-gate 
2840Sstevel@tonic-gate 	/*
2850Sstevel@tonic-gate 	 * CSR_V TLU_STATUS Expect HW 0x4
2860Sstevel@tonic-gate 	 */
2870Sstevel@tonic-gate 
2880Sstevel@tonic-gate 	/*
2890Sstevel@tonic-gate 	 * Only bit [7:0] are currently defined.  Bits [2:0]
2900Sstevel@tonic-gate 	 * are the state, which should likely be in state active,
2910Sstevel@tonic-gate 	 * 100b.  Bit three is 'recovery', which is not understood.
2920Sstevel@tonic-gate 	 * All other bits are reserved.
2930Sstevel@tonic-gate 	 */
2940Sstevel@tonic-gate 	DBG(DBG_TLU, NULL, "tlu_init - TLU_STATUS: 0x%llx\n",
295*27Sjchu 	    CSR_XR(csr_base, TLU_STATUS));
2960Sstevel@tonic-gate 
2970Sstevel@tonic-gate 	/*
2980Sstevel@tonic-gate 	 * CSR_V TLU_PME_TURN_OFF_GENERATE Expect HW 0x0
2990Sstevel@tonic-gate 	 */
3000Sstevel@tonic-gate 	DBG(DBG_TLU, NULL, "tlu_init - TLU_PME_TURN_OFF_GENERATE: 0x%llx\n",
301*27Sjchu 	    CSR_XR(csr_base, TLU_PME_TURN_OFF_GENERATE));
3020Sstevel@tonic-gate 
3030Sstevel@tonic-gate 	/*
3040Sstevel@tonic-gate 	 * CSR_V TLU_INGRESS_CREDITS_INITIAL Expect HW 0x10000200C0
3050Sstevel@tonic-gate 	 */
3060Sstevel@tonic-gate 
3070Sstevel@tonic-gate 	/*
3080Sstevel@tonic-gate 	 * Ingress credits initial register.  Bits [39:32] should be
3090Sstevel@tonic-gate 	 * 0x10, bits [19:12] should be 0x20, and bits [11:0] should
3100Sstevel@tonic-gate 	 * be 0xC0.  These are the reset values, and should be set by
3110Sstevel@tonic-gate 	 * HW.
3120Sstevel@tonic-gate 	 */
3130Sstevel@tonic-gate 	DBG(DBG_TLU, NULL, "tlu_init - TLU_INGRESS_CREDITS_INITIAL: 0x%llx\n",
314*27Sjchu 	    CSR_XR(csr_base, TLU_INGRESS_CREDITS_INITIAL));
3150Sstevel@tonic-gate 
3160Sstevel@tonic-gate 	/*
3170Sstevel@tonic-gate 	 * CSR_V TLU_DIAGNOSTIC Expect HW 0x0
3180Sstevel@tonic-gate 	 */
3190Sstevel@tonic-gate 
3200Sstevel@tonic-gate 	/*
3210Sstevel@tonic-gate 	 * Diagnostic register - always zero unless we are debugging.
3220Sstevel@tonic-gate 	 */
3230Sstevel@tonic-gate 	DBG(DBG_TLU, NULL, "tlu_init - TLU_DIAGNOSTIC: 0x%llx\n",
324*27Sjchu 	    CSR_XR(csr_base, TLU_DIAGNOSTIC));
3250Sstevel@tonic-gate 
3260Sstevel@tonic-gate 	/*
3270Sstevel@tonic-gate 	 * CSR_V TLU_EGRESS_CREDITS_CONSUMED Expect HW 0x0
3280Sstevel@tonic-gate 	 */
3290Sstevel@tonic-gate 	DBG(DBG_TLU, NULL, "tlu_init - TLU_EGRESS_CREDITS_CONSUMED: 0x%llx\n",
330*27Sjchu 	    CSR_XR(csr_base, TLU_EGRESS_CREDITS_CONSUMED));
3310Sstevel@tonic-gate 
3320Sstevel@tonic-gate 	/*
3330Sstevel@tonic-gate 	 * CSR_V TLU_EGRESS_CREDIT_LIMIT Expect HW 0x0
3340Sstevel@tonic-gate 	 */
3350Sstevel@tonic-gate 	DBG(DBG_TLU, NULL, "tlu_init - TLU_EGRESS_CREDIT_LIMIT: 0x%llx\n",
336*27Sjchu 	    CSR_XR(csr_base, TLU_EGRESS_CREDIT_LIMIT));
3370Sstevel@tonic-gate 
3380Sstevel@tonic-gate 	/*
3390Sstevel@tonic-gate 	 * CSR_V TLU_EGRESS_RETRY_BUFFER Expect HW 0x0
3400Sstevel@tonic-gate 	 */
3410Sstevel@tonic-gate 	DBG(DBG_TLU, NULL, "tlu_init - TLU_EGRESS_RETRY_BUFFER: 0x%llx\n",
342*27Sjchu 	    CSR_XR(csr_base, TLU_EGRESS_RETRY_BUFFER));
3430Sstevel@tonic-gate 
3440Sstevel@tonic-gate 	/*
3450Sstevel@tonic-gate 	 * CSR_V TLU_INGRESS_CREDITS_ALLOCATED Expected HW 0x0
3460Sstevel@tonic-gate 	 */
3470Sstevel@tonic-gate 	DBG(DBG_TLU, NULL,
348*27Sjchu 	    "tlu_init - TLU_INGRESS_CREDITS_ALLOCATED: 0x%llx\n",
349*27Sjchu 	    CSR_XR(csr_base, TLU_INGRESS_CREDITS_ALLOCATED));
3500Sstevel@tonic-gate 
3510Sstevel@tonic-gate 	/*
3520Sstevel@tonic-gate 	 * CSR_V TLU_INGRESS_CREDITS_RECEIVED Expected HW 0x0
3530Sstevel@tonic-gate 	 */
3540Sstevel@tonic-gate 	DBG(DBG_TLU, NULL,
355*27Sjchu 	    "tlu_init - TLU_INGRESS_CREDITS_RECEIVED: 0x%llx\n",
356*27Sjchu 	    CSR_XR(csr_base, TLU_INGRESS_CREDITS_RECEIVED));
3570Sstevel@tonic-gate 
3580Sstevel@tonic-gate 	/*
359*27Sjchu 	 * CSR_V TLU's interrupt regs (log, enable, status, clear)
3600Sstevel@tonic-gate 	 */
3610Sstevel@tonic-gate 	DBG(DBG_TLU, NULL,
362*27Sjchu 	    "tlu_init - TLU_OTHER_EVENT_LOG_ENABLE: 0x%llx\n",
363*27Sjchu 	    CSR_XR(csr_base, TLU_OTHER_EVENT_LOG_ENABLE));
364*27Sjchu 
3650Sstevel@tonic-gate 	DBG(DBG_TLU, NULL,
366*27Sjchu 	    "tlu_init - TLU_OTHER_EVENT_INTERRUPT_ENABLE: 0x%llx\n",
367*27Sjchu 	    CSR_XR(csr_base, TLU_OTHER_EVENT_INTERRUPT_ENABLE));
368*27Sjchu 
369*27Sjchu 	DBG(DBG_TLU, NULL,
370*27Sjchu 	    "tlu_init - TLU_OTHER_EVENT_INTERRUPT_STATUS: 0x%llx\n",
371*27Sjchu 	    CSR_XR(csr_base, TLU_OTHER_EVENT_INTERRUPT_STATUS));
372*27Sjchu 
373*27Sjchu 	DBG(DBG_TLU, NULL,
374*27Sjchu 	    "tlu_init - TLU_OTHER_EVENT_STATUS_CLEAR: 0x%llx\n",
375*27Sjchu 	    CSR_XR(csr_base, TLU_OTHER_EVENT_STATUS_CLEAR));
3760Sstevel@tonic-gate 
3770Sstevel@tonic-gate 	/*
3780Sstevel@tonic-gate 	 * CSR_V TLU_RECEIVE_OTHER_EVENT_HEADER1_LOG Expect HW 0x0
3790Sstevel@tonic-gate 	 */
3800Sstevel@tonic-gate 	DBG(DBG_TLU, NULL,
381*27Sjchu 	    "tlu_init - TLU_RECEIVE_OTHER_EVENT_HEADER1_LOG: 0x%llx\n",
382*27Sjchu 	    CSR_XR(csr_base, TLU_RECEIVE_OTHER_EVENT_HEADER1_LOG));
3830Sstevel@tonic-gate 
3840Sstevel@tonic-gate 	/*
3850Sstevel@tonic-gate 	 * CSR_V TLU_RECEIVE_OTHER_EVENT_HEADER2_LOG Expect HW 0x0
3860Sstevel@tonic-gate 	 */
3870Sstevel@tonic-gate 	DBG(DBG_TLU, NULL,
388*27Sjchu 	    "tlu_init - TLU_RECEIVE_OTHER_EVENT_HEADER2_LOG: 0x%llx\n",
389*27Sjchu 	    CSR_XR(csr_base, TLU_RECEIVE_OTHER_EVENT_HEADER2_LOG));
3900Sstevel@tonic-gate 
3910Sstevel@tonic-gate 	/*
3920Sstevel@tonic-gate 	 * CSR_V TLU_TRANSMIT_OTHER_EVENT_HEADER1_LOG Expect HW 0x0
3930Sstevel@tonic-gate 	 */
3940Sstevel@tonic-gate 	DBG(DBG_TLU, NULL,
395*27Sjchu 	    "tlu_init - TLU_TRANSMIT_OTHER_EVENT_HEADER1_LOG: 0x%llx\n",
396*27Sjchu 	    CSR_XR(csr_base, TLU_TRANSMIT_OTHER_EVENT_HEADER1_LOG));
3970Sstevel@tonic-gate 
3980Sstevel@tonic-gate 	/*
3990Sstevel@tonic-gate 	 * CSR_V TLU_TRANSMIT_OTHER_EVENT_HEADER2_LOG Expect HW 0x0
4000Sstevel@tonic-gate 	 */
4010Sstevel@tonic-gate 	DBG(DBG_TLU, NULL,
402*27Sjchu 	    "tlu_init - TLU_TRANSMIT_OTHER_EVENT_HEADER2_LOG: 0x%llx\n",
403*27Sjchu 	    CSR_XR(csr_base, TLU_TRANSMIT_OTHER_EVENT_HEADER2_LOG));
4040Sstevel@tonic-gate 
4050Sstevel@tonic-gate 	/*
4060Sstevel@tonic-gate 	 * CSR_V TLU_PERFORMANCE_COUNTER_SELECT Expect HW 0x0
4070Sstevel@tonic-gate 	 */
4080Sstevel@tonic-gate 	DBG(DBG_TLU, NULL,
409*27Sjchu 	    "tlu_init - TLU_PERFORMANCE_COUNTER_SELECT: 0x%llx\n",
410*27Sjchu 	    CSR_XR(csr_base, TLU_PERFORMANCE_COUNTER_SELECT));
4110Sstevel@tonic-gate 
4120Sstevel@tonic-gate 	/*
4130Sstevel@tonic-gate 	 * CSR_V TLU_PERFORMANCE_COUNTER_ZERO Expect HW 0x0
4140Sstevel@tonic-gate 	 */
4150Sstevel@tonic-gate 	DBG(DBG_TLU, NULL,
416*27Sjchu 	    "tlu_init - TLU_PERFORMANCE_COUNTER_ZERO: 0x%llx\n",
417*27Sjchu 	    CSR_XR(csr_base, TLU_PERFORMANCE_COUNTER_ZERO));
4180Sstevel@tonic-gate 
4190Sstevel@tonic-gate 	/*
4200Sstevel@tonic-gate 	 * CSR_V TLU_PERFORMANCE_COUNTER_ONE Expect HW 0x0
4210Sstevel@tonic-gate 	 */
4220Sstevel@tonic-gate 	DBG(DBG_TLU, NULL, "tlu_init - TLU_PERFORMANCE_COUNTER_ONE: 0x%llx\n",
423*27Sjchu 	    CSR_XR(csr_base, TLU_PERFORMANCE_COUNTER_ONE));
4240Sstevel@tonic-gate 
4250Sstevel@tonic-gate 	/*
4260Sstevel@tonic-gate 	 * CSR_V TLU_PERFORMANCE_COUNTER_TWO Expect HW 0x0
4270Sstevel@tonic-gate 	 */
4280Sstevel@tonic-gate 	DBG(DBG_TLU, NULL, "tlu_init - TLU_PERFORMANCE_COUNTER_TWO: 0x%llx\n",
429*27Sjchu 	    CSR_XR(csr_base, TLU_PERFORMANCE_COUNTER_TWO));
4300Sstevel@tonic-gate 
4310Sstevel@tonic-gate 	/*
4320Sstevel@tonic-gate 	 * CSR_V TLU_DEBUG_SELECT_A Expect HW 0x0
4330Sstevel@tonic-gate 	 */
4340Sstevel@tonic-gate 
4350Sstevel@tonic-gate 	DBG(DBG_TLU, NULL, "tlu_init - TLU_DEBUG_SELECT_A: 0x%llx\n",
436*27Sjchu 	    CSR_XR(csr_base, TLU_DEBUG_SELECT_A));
4370Sstevel@tonic-gate 
4380Sstevel@tonic-gate 	/*
4390Sstevel@tonic-gate 	 * CSR_V TLU_DEBUG_SELECT_B Expect HW 0x0
4400Sstevel@tonic-gate 	 */
4410Sstevel@tonic-gate 	DBG(DBG_TLU, NULL, "tlu_init - TLU_DEBUG_SELECT_B: 0x%llx\n",
442*27Sjchu 	    CSR_XR(csr_base, TLU_DEBUG_SELECT_B));
4430Sstevel@tonic-gate 
4440Sstevel@tonic-gate 	/*
4450Sstevel@tonic-gate 	 * CSR_V TLU_DEVICE_CAPABILITIES Expect HW 0xFC2
4460Sstevel@tonic-gate 	 */
4470Sstevel@tonic-gate 	DBG(DBG_TLU, NULL, "tlu_init - TLU_DEVICE_CAPABILITIES: 0x%llx\n",
448*27Sjchu 	    CSR_XR(csr_base, TLU_DEVICE_CAPABILITIES));
4490Sstevel@tonic-gate 
4500Sstevel@tonic-gate 	/*
4510Sstevel@tonic-gate 	 * CSR_V TLU_DEVICE_CONTROL Expect HW 0x0
4520Sstevel@tonic-gate 	 */
4530Sstevel@tonic-gate 
4540Sstevel@tonic-gate 	/*
4550Sstevel@tonic-gate 	 * Bits [14:12] are the Max Read Request Size, which is always 64
4560Sstevel@tonic-gate 	 * bytes which is 000b.  Bits [7:5] are Max Payload Size, which
4570Sstevel@tonic-gate 	 * start at 128 bytes which is 000b.  This may be revisited if
4580Sstevel@tonic-gate 	 * init_child finds greater values.
4590Sstevel@tonic-gate 	 */
4600Sstevel@tonic-gate 	val = 0x0ull;
4610Sstevel@tonic-gate 	CSR_XS(csr_base, TLU_DEVICE_CONTROL, val);
4620Sstevel@tonic-gate 	DBG(DBG_TLU, NULL, "tlu_init - TLU_DEVICE_CONTROL: 0x%llx\n",
463*27Sjchu 	    CSR_XR(csr_base, TLU_DEVICE_CONTROL));
4640Sstevel@tonic-gate 
4650Sstevel@tonic-gate 	/*
4660Sstevel@tonic-gate 	 * CSR_V TLU_DEVICE_STATUS Expect HW 0x0
4670Sstevel@tonic-gate 	 */
4680Sstevel@tonic-gate 	DBG(DBG_TLU, NULL, "tlu_init - TLU_DEVICE_STATUS: 0x%llx\n",
469*27Sjchu 	    CSR_XR(csr_base, TLU_DEVICE_STATUS));
4700Sstevel@tonic-gate 
4710Sstevel@tonic-gate 	/*
4720Sstevel@tonic-gate 	 * CSR_V TLU_LINK_CAPABILITIES Expect HW 0x15C81
4730Sstevel@tonic-gate 	 */
4740Sstevel@tonic-gate 	DBG(DBG_TLU, NULL, "tlu_init - TLU_LINK_CAPABILITIES: 0x%llx\n",
475*27Sjchu 	    CSR_XR(csr_base, TLU_LINK_CAPABILITIES));
4760Sstevel@tonic-gate 
4770Sstevel@tonic-gate 	/*
4780Sstevel@tonic-gate 	 * CSR_V TLU_LINK_CONTROL Expect OBP 0x40
4790Sstevel@tonic-gate 	 */
4800Sstevel@tonic-gate 
4810Sstevel@tonic-gate 	/*
4820Sstevel@tonic-gate 	 * The CLOCK bit should be set by OBP if the hardware dictates,
4830Sstevel@tonic-gate 	 * and if it is set then ASPM should be used since then L0s exit
4840Sstevel@tonic-gate 	 * latency should be lower than L1 exit latency.
4850Sstevel@tonic-gate 	 *
4860Sstevel@tonic-gate 	 * Note that we will not enable power management during bringup
4870Sstevel@tonic-gate 	 * since it has not been test and is creating some problems in
4880Sstevel@tonic-gate 	 * simulation.
4890Sstevel@tonic-gate 	 */
4900Sstevel@tonic-gate 	val = (1ull << TLU_LINK_CONTROL_CLOCK);
4910Sstevel@tonic-gate 
4920Sstevel@tonic-gate 	CSR_XS(csr_base, TLU_LINK_CONTROL, val);
4930Sstevel@tonic-gate 	DBG(DBG_TLU, NULL, "tlu_init - TLU_LINK_CONTROL: 0x%llx\n",
494*27Sjchu 	    CSR_XR(csr_base, TLU_LINK_CONTROL));
4950Sstevel@tonic-gate 
4960Sstevel@tonic-gate 	/*
4970Sstevel@tonic-gate 	 * CSR_V TLU_LINK_STATUS Expect OBP 0x1011
4980Sstevel@tonic-gate 	 */
4990Sstevel@tonic-gate 
5000Sstevel@tonic-gate 	/*
5010Sstevel@tonic-gate 	 * Not sure if HW or OBP will be setting this read only
5020Sstevel@tonic-gate 	 * register.  Bit 12 is Clock, and it should always be 1
5030Sstevel@tonic-gate 	 * signifying that the component uses the same physical
5040Sstevel@tonic-gate 	 * clock as the platform.  Bits [9:4] are for the width,
5050Sstevel@tonic-gate 	 * with the expected value above signifying a x1 width.
5060Sstevel@tonic-gate 	 * Bits [3:0] are the speed, with 1b signifying 2.5 Gb/s,
5070Sstevel@tonic-gate 	 * the only speed as yet supported by the PCI-E spec.
5080Sstevel@tonic-gate 	 */
5090Sstevel@tonic-gate 	DBG(DBG_TLU, NULL, "tlu_init - TLU_LINK_STATUS: 0x%llx\n",
510*27Sjchu 	    CSR_XR(csr_base, TLU_LINK_STATUS));
5110Sstevel@tonic-gate 
5120Sstevel@tonic-gate 	/*
5130Sstevel@tonic-gate 	 * CSR_V TLU_SLOT_CAPABILITIES Expect OBP ???
5140Sstevel@tonic-gate 	 */
5150Sstevel@tonic-gate 
5160Sstevel@tonic-gate 	/*
5170Sstevel@tonic-gate 	 * Power Limits for the slots.  Will be platform
5180Sstevel@tonic-gate 	 * dependent, and OBP will need to set after consulting
5190Sstevel@tonic-gate 	 * with the HW guys.
5200Sstevel@tonic-gate 	 *
5210Sstevel@tonic-gate 	 * Bits [16:15] are power limit scale, which most likely
5220Sstevel@tonic-gate 	 * will be 0b signifying 1x.  Bits [14:7] are the Set
5230Sstevel@tonic-gate 	 * Power Limit Value, which is a number which is multiplied
5240Sstevel@tonic-gate 	 * by the power limit scale to get the actual power limit.
5250Sstevel@tonic-gate 	 */
5260Sstevel@tonic-gate 	DBG(DBG_TLU, NULL, "tlu_init - TLU_SLOT_CAPABILITIES: 0x%llx\n",
527*27Sjchu 	    CSR_XR(csr_base, TLU_SLOT_CAPABILITIES));
5280Sstevel@tonic-gate 
5290Sstevel@tonic-gate 	/*
5300Sstevel@tonic-gate 	 * CSR_V TLU_UNCORRECTABLE_ERROR_LOG_ENABLE Expect Kernel 0x17F011
5310Sstevel@tonic-gate 	 */
5320Sstevel@tonic-gate 	DBG(DBG_TLU, NULL,
533*27Sjchu 	    "tlu_init - TLU_UNCORRECTABLE_ERROR_LOG_ENABLE: 0x%llx\n",
534*27Sjchu 	    CSR_XR(csr_base, TLU_UNCORRECTABLE_ERROR_LOG_ENABLE));
5350Sstevel@tonic-gate 
5360Sstevel@tonic-gate 	/*
537*27Sjchu 	 * CSR_V TLU_UNCORRECTABLE_ERROR_INTERRUPT_ENABLE Expect
538*27Sjchu 	 * Kernel 0x17F0110017F011
5390Sstevel@tonic-gate 	 */
5400Sstevel@tonic-gate 	DBG(DBG_TLU, NULL,
541*27Sjchu 	    "tlu_init - TLU_UNCORRECTABLE_ERROR_INTERRUPT_ENABLE: 0x%llx\n",
542*27Sjchu 	    CSR_XR(csr_base, TLU_UNCORRECTABLE_ERROR_INTERRUPT_ENABLE));
5430Sstevel@tonic-gate 
5440Sstevel@tonic-gate 	/*
5450Sstevel@tonic-gate 	 * CSR_V TLU_UNCORRECTABLE_ERROR_INTERRUPT_STATUS Expect HW 0x0
5460Sstevel@tonic-gate 	 */
5470Sstevel@tonic-gate 	DBG(DBG_TLU, NULL,
548*27Sjchu 	    "tlu_init - TLU_UNCORRECTABLE_ERROR_INTERRUPT_STATUS: 0x%llx\n",
549*27Sjchu 	    CSR_XR(csr_base, TLU_UNCORRECTABLE_ERROR_INTERRUPT_STATUS));
5500Sstevel@tonic-gate 
5510Sstevel@tonic-gate 	/*
5520Sstevel@tonic-gate 	 * CSR_V TLU_UNCORRECTABLE_ERROR_STATUS_CLEAR Expect HW 0x0
5530Sstevel@tonic-gate 	 */
5540Sstevel@tonic-gate 	DBG(DBG_TLU, NULL,
555*27Sjchu 	    "tlu_init - TLU_UNCORRECTABLE_ERROR_STATUS_CLEAR: 0x%llx\n",
556*27Sjchu 	    CSR_XR(csr_base, TLU_UNCORRECTABLE_ERROR_STATUS_CLEAR));
5570Sstevel@tonic-gate 
5580Sstevel@tonic-gate 	/*
5590Sstevel@tonic-gate 	 * CSR_V TLU_RECEIVE_UNCORRECTABLE_ERROR_HEADER1_LOG HW 0x0
5600Sstevel@tonic-gate 	 */
5610Sstevel@tonic-gate 	DBG(DBG_TLU, NULL,
5620Sstevel@tonic-gate 	    "tlu_init - TLU_RECEIVE_UNCORRECTABLE_ERROR_HEADER1_LOG: 0x%llx\n",
5630Sstevel@tonic-gate 	    CSR_XR(csr_base, TLU_RECEIVE_UNCORRECTABLE_ERROR_HEADER1_LOG));
5640Sstevel@tonic-gate 
5650Sstevel@tonic-gate 	/*
5660Sstevel@tonic-gate 	 * CSR_V TLU_RECEIVE_UNCORRECTABLE_ERROR_HEADER2_LOG HW 0x0
5670Sstevel@tonic-gate 	 */
5680Sstevel@tonic-gate 	DBG(DBG_TLU, NULL,
5690Sstevel@tonic-gate 	    "tlu_init - TLU_RECEIVE_UNCORRECTABLE_ERROR_HEADER2_LOG: 0x%llx\n",
5700Sstevel@tonic-gate 	    CSR_XR(csr_base, TLU_RECEIVE_UNCORRECTABLE_ERROR_HEADER2_LOG));
5710Sstevel@tonic-gate 
5720Sstevel@tonic-gate 	/*
5730Sstevel@tonic-gate 	 * CSR_V TLU_TRANSMIT_UNCORRECTABLE_ERROR_HEADER1_LOG HW 0x0
5740Sstevel@tonic-gate 	 */
5750Sstevel@tonic-gate 	DBG(DBG_TLU, NULL,
5760Sstevel@tonic-gate 	    "tlu_init - TLU_TRANSMIT_UNCORRECTABLE_ERROR_HEADER1_LOG: 0x%llx\n",
5770Sstevel@tonic-gate 	    CSR_XR(csr_base, TLU_TRANSMIT_UNCORRECTABLE_ERROR_HEADER1_LOG));
5780Sstevel@tonic-gate 
5790Sstevel@tonic-gate 	/*
5800Sstevel@tonic-gate 	 * CSR_V TLU_TRANSMIT_UNCORRECTABLE_ERROR_HEADER2_LOG HW 0x0
5810Sstevel@tonic-gate 	 */
5820Sstevel@tonic-gate 	DBG(DBG_TLU, NULL,
5830Sstevel@tonic-gate 	    "tlu_init - TLU_TRANSMIT_UNCORRECTABLE_ERROR_HEADER2_LOG: 0x%llx\n",
5840Sstevel@tonic-gate 	    CSR_XR(csr_base, TLU_TRANSMIT_UNCORRECTABLE_ERROR_HEADER2_LOG));
5850Sstevel@tonic-gate 
586*27Sjchu 
5870Sstevel@tonic-gate 	/*
588*27Sjchu 	 * CSR_V TLU's CE interrupt regs (log, enable, status, clear)
589*27Sjchu 	 * Plus header logs
5900Sstevel@tonic-gate 	 */
5910Sstevel@tonic-gate 
5920Sstevel@tonic-gate 	/*
593*27Sjchu 	 * CSR_V TLU_CORRECTABLE_ERROR_LOG_ENABLE Expect Kernel 0x11C1
5940Sstevel@tonic-gate 	 */
5950Sstevel@tonic-gate 	DBG(DBG_TLU, NULL,
596*27Sjchu 	    "tlu_init - TLU_CORRECTABLE_ERROR_LOG_ENABLE: 0x%llx\n",
597*27Sjchu 	    CSR_XR(csr_base, TLU_CORRECTABLE_ERROR_LOG_ENABLE));
5980Sstevel@tonic-gate 
5990Sstevel@tonic-gate 	/*
6000Sstevel@tonic-gate 	 * CSR_V TLU_CORRECTABLE_ERROR_INTERRUPT_ENABLE Kernel 0x11C1000011C1
6010Sstevel@tonic-gate 	 */
6020Sstevel@tonic-gate 	DBG(DBG_TLU, NULL,
603*27Sjchu 	    "tlu_init - TLU_CORRECTABLE_ERROR_INTERRUPT_ENABLE: 0x%llx\n",
604*27Sjchu 	    CSR_XR(csr_base, TLU_CORRECTABLE_ERROR_INTERRUPT_ENABLE));
6050Sstevel@tonic-gate 
6060Sstevel@tonic-gate 	/*
6070Sstevel@tonic-gate 	 * CSR_V TLU_CORRECTABLE_ERROR_INTERRUPT_STATUS Expect HW 0x0
6080Sstevel@tonic-gate 	 */
6090Sstevel@tonic-gate 	DBG(DBG_TLU, NULL,
610*27Sjchu 	    "tlu_init - TLU_CORRECTABLE_ERROR_INTERRUPT_STATUS: 0x%llx\n",
611*27Sjchu 	    CSR_XR(csr_base, TLU_CORRECTABLE_ERROR_INTERRUPT_STATUS));
6120Sstevel@tonic-gate 
6130Sstevel@tonic-gate 	/*
6140Sstevel@tonic-gate 	 * CSR_V TLU_CORRECTABLE_ERROR_STATUS_CLEAR Expect HW 0x0
6150Sstevel@tonic-gate 	 */
6160Sstevel@tonic-gate 	DBG(DBG_TLU, NULL,
617*27Sjchu 	    "tlu_init - TLU_CORRECTABLE_ERROR_STATUS_CLEAR: 0x%llx\n",
618*27Sjchu 	    CSR_XR(csr_base, TLU_CORRECTABLE_ERROR_STATUS_CLEAR));
6190Sstevel@tonic-gate }
6200Sstevel@tonic-gate 
6210Sstevel@tonic-gate static void
6220Sstevel@tonic-gate lpu_init(caddr_t csr_base, pxu_t *pxu_p)
6230Sstevel@tonic-gate {
6240Sstevel@tonic-gate 	/* Variables used to set the ACKNAK Latency Timer and Replay Timer */
6250Sstevel@tonic-gate 	int link_width, max_payload;
6260Sstevel@tonic-gate 
6270Sstevel@tonic-gate 	uint64_t val;
6280Sstevel@tonic-gate 
6290Sstevel@tonic-gate 	/*
6300Sstevel@tonic-gate 	 * ACKNAK Latency Threshold Table.
6310Sstevel@tonic-gate 	 * See Fire PRM 1.0 sections 1.2.11.1, table 1-17.
6320Sstevel@tonic-gate 	 */
6330Sstevel@tonic-gate 	int fire10_acknak_timer_table[LINK_MAX_PKT_ARR_SIZE]
6340Sstevel@tonic-gate 	    [LINK_WIDTH_ARR_SIZE] = {
6350Sstevel@tonic-gate 		{0xED,   0x76,  0x70,  0x58},
6360Sstevel@tonic-gate 		{0x1A0,  0x76,  0x6B,  0x61},
6370Sstevel@tonic-gate 		{0x22F,  0x9A,  0x6A,  0x6A},
6380Sstevel@tonic-gate 		{0x42F,  0x11A, 0x96,  0x96},
6390Sstevel@tonic-gate 		{0x82F,  0x21A, 0x116, 0x116},
6400Sstevel@tonic-gate 		{0x102F, 0x41A, 0x216, 0x216}
6410Sstevel@tonic-gate 	};
6420Sstevel@tonic-gate 
6430Sstevel@tonic-gate 	/*
6440Sstevel@tonic-gate 	 * TxLink Replay Timer Latency Table
6450Sstevel@tonic-gate 	 * See Fire PRM 1.0 sections 1.2.11.2, table 1-18.
6460Sstevel@tonic-gate 	 */
6470Sstevel@tonic-gate 	int fire10_replay_timer_table[LINK_MAX_PKT_ARR_SIZE]
6480Sstevel@tonic-gate 	    [LINK_WIDTH_ARR_SIZE] = {
6490Sstevel@tonic-gate 		{0x2C7,  0x108, 0xF6,  0xBD},
6500Sstevel@tonic-gate 		{0x4E0,  0x162, 0x141, 0xF1},
6510Sstevel@tonic-gate 		{0x68D,  0x1CE, 0x102, 0x102},
6520Sstevel@tonic-gate 		{0xC8D,  0x34E, 0x1C2, 0x1C2},
6530Sstevel@tonic-gate 		{0x188D, 0x64E, 0x342, 0x342},
6540Sstevel@tonic-gate 		{0x308D, 0xC4E, 0x642, 0x642}
6550Sstevel@tonic-gate 	};
6560Sstevel@tonic-gate 
6570Sstevel@tonic-gate 	/*
6580Sstevel@tonic-gate 	 * ACKNAK Latency Threshold Table.
6590Sstevel@tonic-gate 	 * See Fire PRM 2.0 section 1.2.12.2, table 1-17.
6600Sstevel@tonic-gate 	 */
6610Sstevel@tonic-gate 	int acknak_timer_table[LINK_MAX_PKT_ARR_SIZE][LINK_WIDTH_ARR_SIZE] = {
6620Sstevel@tonic-gate 		{0xED,   0x49,  0x43,  0x30},
6630Sstevel@tonic-gate 		{0x1A0,  0x76,  0x6B,  0x48},
6640Sstevel@tonic-gate 		{0x22F,  0x9A,  0x56,  0x56},
6650Sstevel@tonic-gate 		{0x42F,  0x11A, 0x96,  0x96},
6660Sstevel@tonic-gate 		{0x82F,  0x21A, 0x116, 0x116},
6670Sstevel@tonic-gate 		{0x102F, 0x41A, 0x216, 0x216}
6680Sstevel@tonic-gate 	};
6690Sstevel@tonic-gate 
6700Sstevel@tonic-gate 	/*
6710Sstevel@tonic-gate 	 * TxLink Replay Timer Latency Table
6720Sstevel@tonic-gate 	 * See Fire PRM 2.0 sections 1.2.12.3, table 1-18.
6730Sstevel@tonic-gate 	 */
6740Sstevel@tonic-gate 	int replay_timer_table[LINK_MAX_PKT_ARR_SIZE][LINK_WIDTH_ARR_SIZE] = {
6750Sstevel@tonic-gate 		{0x379,  0x112, 0xFC,  0xB4},
6760Sstevel@tonic-gate 		{0x618,  0x1BA, 0x192, 0x10E},
6770Sstevel@tonic-gate 		{0x831,  0x242, 0x143, 0x143},
6780Sstevel@tonic-gate 		{0xFB1,  0x422, 0x233, 0x233},
6790Sstevel@tonic-gate 		{0x1EB0, 0x7E1, 0x412, 0x412},
6800Sstevel@tonic-gate 		{0x3CB0, 0xF61, 0x7D2, 0x7D2}
6810Sstevel@tonic-gate 	};
6820Sstevel@tonic-gate 	/*
6830Sstevel@tonic-gate 	 * Get the Link Width.  See table above LINK_WIDTH_ARR_SIZE #define
6840Sstevel@tonic-gate 	 * Only Link Widths of x1, x4, and x8 are supported.
6850Sstevel@tonic-gate 	 * If any width is reported other than x8, set default to x8.
6860Sstevel@tonic-gate 	 */
6870Sstevel@tonic-gate 	link_width = CSR_FR(csr_base, TLU_LINK_STATUS, WIDTH);
6880Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - Link Width: x%d\n", link_width);
6890Sstevel@tonic-gate 
6900Sstevel@tonic-gate 	/*
6910Sstevel@tonic-gate 	 * Convert link_width to match timer array configuration.
6920Sstevel@tonic-gate 	 */
6930Sstevel@tonic-gate 	switch (link_width) {
6940Sstevel@tonic-gate 	case 1:
6950Sstevel@tonic-gate 		link_width = 0;
6960Sstevel@tonic-gate 		break;
6970Sstevel@tonic-gate 	case 4:
6980Sstevel@tonic-gate 		link_width = 1;
6990Sstevel@tonic-gate 		break;
7000Sstevel@tonic-gate 	case 8:
7010Sstevel@tonic-gate 		link_width = 2;
7020Sstevel@tonic-gate 		break;
7030Sstevel@tonic-gate 	case 16:
7040Sstevel@tonic-gate 		link_width = 3;
7050Sstevel@tonic-gate 		break;
7060Sstevel@tonic-gate 	default:
7070Sstevel@tonic-gate 		link_width = 0;
7080Sstevel@tonic-gate 	}
7090Sstevel@tonic-gate 
7100Sstevel@tonic-gate 	/*
7110Sstevel@tonic-gate 	 * Get the Max Payload Size.
7120Sstevel@tonic-gate 	 * See table above LINK_MAX_PKT_ARR_SIZE #define
7130Sstevel@tonic-gate 	 */
7140Sstevel@tonic-gate 	if (pxu_p->chip_id == FIRE_VER_10) {
7150Sstevel@tonic-gate 		max_payload = CSR_FR(csr_base,
7160Sstevel@tonic-gate 		    FIRE10_LPU_LINK_LAYER_CONFIG, MAX_PAYLOAD);
7170Sstevel@tonic-gate 	} else {
7180Sstevel@tonic-gate 		/* Default case is FIRE2.0 */
7190Sstevel@tonic-gate 		max_payload = ((CSR_FR(csr_base, TLU_CONTROL, CONFIG) &
7200Sstevel@tonic-gate 		    TLU_CONTROL_MPS_MASK) >> TLU_CONTROL_MPS_SHIFT);
7210Sstevel@tonic-gate 	}
7220Sstevel@tonic-gate 
7230Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - May Payload: %d\n",
7240Sstevel@tonic-gate 	    (0x80 << max_payload));
7250Sstevel@tonic-gate 
7260Sstevel@tonic-gate 	/* Make sure the packet size is not greater than 4096 */
7270Sstevel@tonic-gate 	max_payload = (max_payload >= LINK_MAX_PKT_ARR_SIZE) ?
7280Sstevel@tonic-gate 	    (LINK_MAX_PKT_ARR_SIZE - 1) : max_payload;
7290Sstevel@tonic-gate 
7300Sstevel@tonic-gate 	/*
7310Sstevel@tonic-gate 	 * CSR_V LPU_ID Expect HW 0x0
7320Sstevel@tonic-gate 	 */
7330Sstevel@tonic-gate 
7340Sstevel@tonic-gate 	/*
7350Sstevel@tonic-gate 	 * This register has link id, phy id and gigablaze id.
7360Sstevel@tonic-gate 	 * Should be set by HW.
7370Sstevel@tonic-gate 	 */
7380Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_ID: 0x%llx\n",
739*27Sjchu 	    CSR_XR(csr_base, LPU_ID));
7400Sstevel@tonic-gate 
7410Sstevel@tonic-gate 	/*
7420Sstevel@tonic-gate 	 * CSR_V LPU_RESET Expect Kernel 0x0
7430Sstevel@tonic-gate 	 */
7440Sstevel@tonic-gate 
7450Sstevel@tonic-gate 	/*
7460Sstevel@tonic-gate 	 * No reason to have any reset bits high until an error is
7470Sstevel@tonic-gate 	 * detected on the link.
7480Sstevel@tonic-gate 	 */
7490Sstevel@tonic-gate 	val = 0ull;
7500Sstevel@tonic-gate 	CSR_XS(csr_base, LPU_RESET, val);
7510Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_RESET: 0x%llx\n",
752*27Sjchu 	    CSR_XR(csr_base, LPU_RESET));
7530Sstevel@tonic-gate 
7540Sstevel@tonic-gate 	/*
7550Sstevel@tonic-gate 	 * CSR_V LPU_DEBUG_STATUS Expect HW 0x0
7560Sstevel@tonic-gate 	 */
7570Sstevel@tonic-gate 
7580Sstevel@tonic-gate 	/*
7590Sstevel@tonic-gate 	 * Bits [15:8] are Debug B, and bit [7:0] are Debug A.
7600Sstevel@tonic-gate 	 * They are read-only.  What do the 8 bits mean, and
7610Sstevel@tonic-gate 	 * how do they get set if they are read only?
7620Sstevel@tonic-gate 	 */
7630Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_DEBUG_STATUS: 0x%llx\n",
764*27Sjchu 	    CSR_XR(csr_base, LPU_DEBUG_STATUS));
7650Sstevel@tonic-gate 
7660Sstevel@tonic-gate 	/*
7670Sstevel@tonic-gate 	 * CSR_V LPU_DEBUG_CONFIG Expect Kernel 0x0
7680Sstevel@tonic-gate 	 */
7690Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_DEBUG_CONFIG: 0x%llx\n",
770*27Sjchu 	    CSR_XR(csr_base, LPU_DEBUG_CONFIG));
7710Sstevel@tonic-gate 
7720Sstevel@tonic-gate 	/*
7730Sstevel@tonic-gate 	 * CSR_V LPU_LTSSM_CONTROL Expect HW 0x0
7740Sstevel@tonic-gate 	 */
7750Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_LTSSM_CONTROL: 0x%llx\n",
776*27Sjchu 	    CSR_XR(csr_base, LPU_LTSSM_CONTROL));
7770Sstevel@tonic-gate 
7780Sstevel@tonic-gate 	/*
7790Sstevel@tonic-gate 	 * CSR_V LPU_LINK_STATUS Expect HW 0x101
7800Sstevel@tonic-gate 	 */
7810Sstevel@tonic-gate 
7820Sstevel@tonic-gate 	/*
7830Sstevel@tonic-gate 	 * This register has bits [9:4] for link width, and the
7840Sstevel@tonic-gate 	 * default 0x10, means a width of x16.  The problem is
7850Sstevel@tonic-gate 	 * this width is not supported according to the TLU
7860Sstevel@tonic-gate 	 * link status register.
7870Sstevel@tonic-gate 	 */
7880Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_LINK_STATUS: 0x%llx\n",
789*27Sjchu 	    CSR_XR(csr_base, LPU_LINK_STATUS));
7900Sstevel@tonic-gate 
7910Sstevel@tonic-gate 	/*
7920Sstevel@tonic-gate 	 * CSR_V LPU_INTERRUPT_STATUS Expect HW 0x0
7930Sstevel@tonic-gate 	 */
7940Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_INTERRUPT_STATUS: 0x%llx\n",
795*27Sjchu 	    CSR_XR(csr_base, LPU_INTERRUPT_STATUS));
7960Sstevel@tonic-gate 
7970Sstevel@tonic-gate 	/*
7980Sstevel@tonic-gate 	 * CSR_V LPU_INTERRUPT_MASK Expect HW 0x0
7990Sstevel@tonic-gate 	 */
8000Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_INTERRUPT_MASK: 0x%llx\n",
801*27Sjchu 	    CSR_XR(csr_base, LPU_INTERRUPT_MASK));
8020Sstevel@tonic-gate 
8030Sstevel@tonic-gate 	/*
8040Sstevel@tonic-gate 	 * CSR_V LPU_LINK_PERFORMANCE_COUNTER_SELECT Expect HW 0x0
8050Sstevel@tonic-gate 	 */
8060Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
807*27Sjchu 	    "lpu_init - LPU_LINK_PERFORMANCE_COUNTER_SELECT: 0x%llx\n",
808*27Sjchu 	    CSR_XR(csr_base, LPU_LINK_PERFORMANCE_COUNTER_SELECT));
8090Sstevel@tonic-gate 
8100Sstevel@tonic-gate 	/*
8110Sstevel@tonic-gate 	 * CSR_V LPU_LINK_PERFORMANCE_COUNTER_CONTROL Expect HW 0x0
8120Sstevel@tonic-gate 	 */
8130Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
814*27Sjchu 	    "lpu_init - LPU_LINK_PERFORMANCE_COUNTER_CONTROL: 0x%llx\n",
815*27Sjchu 	    CSR_XR(csr_base, LPU_LINK_PERFORMANCE_COUNTER_CONTROL));
8160Sstevel@tonic-gate 
8170Sstevel@tonic-gate 	/*
8180Sstevel@tonic-gate 	 * CSR_V LPU_LINK_PERFORMANCE_COUNTER1 Expect HW 0x0
8190Sstevel@tonic-gate 	 */
8200Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
821*27Sjchu 	    "lpu_init - LPU_LINK_PERFORMANCE_COUNTER1: 0x%llx\n",
822*27Sjchu 	    CSR_XR(csr_base, LPU_LINK_PERFORMANCE_COUNTER1));
8230Sstevel@tonic-gate 
8240Sstevel@tonic-gate 	/*
8250Sstevel@tonic-gate 	 * CSR_V LPU_LINK_PERFORMANCE_COUNTER1_TEST Expect HW 0x0
8260Sstevel@tonic-gate 	 */
8270Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
828*27Sjchu 	    "lpu_init - LPU_LINK_PERFORMANCE_COUNTER1_TEST: 0x%llx\n",
829*27Sjchu 	    CSR_XR(csr_base, LPU_LINK_PERFORMANCE_COUNTER1_TEST));
8300Sstevel@tonic-gate 
8310Sstevel@tonic-gate 	/*
8320Sstevel@tonic-gate 	 * CSR_V LPU_LINK_PERFORMANCE_COUNTER2 Expect HW 0x0
8330Sstevel@tonic-gate 	 */
8340Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
835*27Sjchu 	    "lpu_init - LPU_LINK_PERFORMANCE_COUNTER2: 0x%llx\n",
836*27Sjchu 	    CSR_XR(csr_base, LPU_LINK_PERFORMANCE_COUNTER2));
8370Sstevel@tonic-gate 
8380Sstevel@tonic-gate 	/*
8390Sstevel@tonic-gate 	 * CSR_V LPU_LINK_PERFORMANCE_COUNTER2_TEST Expect HW 0x0
8400Sstevel@tonic-gate 	 */
8410Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
842*27Sjchu 	    "lpu_init - LPU_LINK_PERFORMANCE_COUNTER2_TEST: 0x%llx\n",
843*27Sjchu 	    CSR_XR(csr_base, LPU_LINK_PERFORMANCE_COUNTER2_TEST));
8440Sstevel@tonic-gate 
8450Sstevel@tonic-gate 	/*
8460Sstevel@tonic-gate 	 * CSR_V LPU_LINK_LAYER_CONFIG Expect HW 0x100
8470Sstevel@tonic-gate 	 */
8480Sstevel@tonic-gate 
8490Sstevel@tonic-gate 	/*
8500Sstevel@tonic-gate 	 * This is another place where Max Payload can be set,
8510Sstevel@tonic-gate 	 * this time for the link layer.  It will be set to
8520Sstevel@tonic-gate 	 * 128B, which is the default, but this will need to
8530Sstevel@tonic-gate 	 * be revisited.
8540Sstevel@tonic-gate 	 */
8550Sstevel@tonic-gate 	val = (1ull << LPU_LINK_LAYER_CONFIG_VC0_EN);
8560Sstevel@tonic-gate 	CSR_XS(csr_base, LPU_LINK_LAYER_CONFIG, val);
8570Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_LINK_LAYER_CONFIG: 0x%llx\n",
858*27Sjchu 	    CSR_XR(csr_base, LPU_LINK_LAYER_CONFIG));
8590Sstevel@tonic-gate 
8600Sstevel@tonic-gate 	/*
8610Sstevel@tonic-gate 	 * CSR_V LPU_LINK_LAYER_STATUS Expect OBP 0x5
8620Sstevel@tonic-gate 	 */
8630Sstevel@tonic-gate 
8640Sstevel@tonic-gate 	/*
8650Sstevel@tonic-gate 	 * Another R/W status register.  Bit 3, DL up Status, will
8660Sstevel@tonic-gate 	 * be set high.  The link state machine status bits [2:0]
8670Sstevel@tonic-gate 	 * are set to 0x1, but the status bits are not defined in the
8680Sstevel@tonic-gate 	 * PRM.  What does 0x1 mean, what others values are possible
8690Sstevel@tonic-gate 	 * and what are thier meanings?
8700Sstevel@tonic-gate 	 *
8710Sstevel@tonic-gate 	 * This register has been giving us problems in simulation.
8720Sstevel@tonic-gate 	 * It has been mentioned that software should not program
8730Sstevel@tonic-gate 	 * any registers with WE bits except during debug.  So
8740Sstevel@tonic-gate 	 * this register will no longer be programmed.
8750Sstevel@tonic-gate 	 */
8760Sstevel@tonic-gate 
8770Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_LINK_LAYER_STATUS: 0x%llx\n",
878*27Sjchu 	    CSR_XR(csr_base, LPU_LINK_LAYER_STATUS));
8790Sstevel@tonic-gate 
8800Sstevel@tonic-gate 	/*
8810Sstevel@tonic-gate 	 * CSR_V LPU_LINK_LAYER_INTERRUPT_AND_STATUS_TEST Expect HW 0x0
8820Sstevel@tonic-gate 	 */
8830Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
884*27Sjchu 	    "lpu_init - LPU_LINK_LAYER_INTERRUPT_AND_STATUS_TEST: 0x%llx\n",
885*27Sjchu 	    CSR_XR(csr_base, LPU_LINK_LAYER_INTERRUPT_AND_STATUS_TEST));
8860Sstevel@tonic-gate 
8870Sstevel@tonic-gate 	/*
888*27Sjchu 	 * CSR_V LPU Link Layer interrupt regs (mask, status)
8890Sstevel@tonic-gate 	 */
8900Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
891*27Sjchu 	    "lpu_init - LPU_LINK_LAYER_INTERRUPT_MASK: 0x%llx\n",
892*27Sjchu 	    CSR_XR(csr_base, LPU_LINK_LAYER_INTERRUPT_MASK));
893*27Sjchu 
894*27Sjchu 	DBG(DBG_LPU, NULL,
895*27Sjchu 	    "lpu_init - LPU_LINK_LAYER_INTERRUPT_AND_STATUS: 0x%llx\n",
896*27Sjchu 	    CSR_XR(csr_base, LPU_LINK_LAYER_INTERRUPT_AND_STATUS));
8970Sstevel@tonic-gate 
8980Sstevel@tonic-gate 	/*
8990Sstevel@tonic-gate 	 * CSR_V LPU_FLOW_CONTROL_UPDATE_CONTROL Expect OBP 0x7
9000Sstevel@tonic-gate 	 */
9010Sstevel@tonic-gate 
9020Sstevel@tonic-gate 	/*
9030Sstevel@tonic-gate 	 * The PRM says that only the first two bits will be set
9040Sstevel@tonic-gate 	 * high by default, which will enable flow control for
9050Sstevel@tonic-gate 	 * posted and non-posted updates, but NOT completetion
9060Sstevel@tonic-gate 	 * updates.
9070Sstevel@tonic-gate 	 */
9080Sstevel@tonic-gate 	val = (1ull << LPU_FLOW_CONTROL_UPDATE_CONTROL_FC0_U_NP_EN) |
909*27Sjchu 	    (1ull << LPU_FLOW_CONTROL_UPDATE_CONTROL_FC0_U_P_EN);
9100Sstevel@tonic-gate 	CSR_XS(csr_base, LPU_FLOW_CONTROL_UPDATE_CONTROL, val);
9110Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
912*27Sjchu 	    "lpu_init - LPU_FLOW_CONTROL_UPDATE_CONTROL: 0x%llx\n",
913*27Sjchu 	    CSR_XR(csr_base, LPU_FLOW_CONTROL_UPDATE_CONTROL));
9140Sstevel@tonic-gate 
9150Sstevel@tonic-gate 	/*
9160Sstevel@tonic-gate 	 * CSR_V LPU_LINK_LAYER_FLOW_CONTROL_UPDATE_TIMEOUT_VALUE
9170Sstevel@tonic-gate 	 * Expect OBP 0x1D4C
9180Sstevel@tonic-gate 	 */
9190Sstevel@tonic-gate 
9200Sstevel@tonic-gate 	/*
9210Sstevel@tonic-gate 	 * This should be set by OBP.  We'll check to make sure.
9220Sstevel@tonic-gate 	 */
923*27Sjchu 	DBG(DBG_LPU, NULL, "lpu_init - "
924*27Sjchu 	    "LPU_LINK_LAYER_FLOW_CONTROL_UPDATE_TIMEOUT_VALUE: 0x%llx\n",
925*27Sjchu 	    CSR_XR(csr_base,
926*27Sjchu 	    LPU_LINK_LAYER_FLOW_CONTROL_UPDATE_TIMEOUT_VALUE));
9270Sstevel@tonic-gate 
9280Sstevel@tonic-gate 	/*
9290Sstevel@tonic-gate 	 * CSR_V LPU_LINK_LAYER_VC0_FLOW_CONTROL_UPDATE_TIMER0 Expect OBP ???
9300Sstevel@tonic-gate 	 */
9310Sstevel@tonic-gate 
9320Sstevel@tonic-gate 	/*
9330Sstevel@tonic-gate 	 * This register has Flow Control Update Timer values for
9340Sstevel@tonic-gate 	 * non-posted and posted requests, bits [30:16] and bits
9350Sstevel@tonic-gate 	 * [14:0], respectively.  These are read-only to SW so
9360Sstevel@tonic-gate 	 * either HW or OBP needs to set them.
9370Sstevel@tonic-gate 	 */
938*27Sjchu 	DBG(DBG_LPU, NULL, "lpu_init - "
939*27Sjchu 	    "LPU_LINK_LAYER_VC0_FLOW_CONTROL_UPDATE_TIMER0: 0x%llx\n",
940*27Sjchu 	    CSR_XR(csr_base,
941*27Sjchu 	    LPU_LINK_LAYER_VC0_FLOW_CONTROL_UPDATE_TIMER0));
9420Sstevel@tonic-gate 
9430Sstevel@tonic-gate 	/*
9440Sstevel@tonic-gate 	 * CSR_V LPU_LINK_LAYER_VC0_FLOW_CONTROL_UPDATE_TIMER1 Expect OBP ???
9450Sstevel@tonic-gate 	 */
9460Sstevel@tonic-gate 
9470Sstevel@tonic-gate 	/*
9480Sstevel@tonic-gate 	 * Same as timer0 register above, except for bits [14:0]
9490Sstevel@tonic-gate 	 * have the timer values for completetions.  Read-only to
9500Sstevel@tonic-gate 	 * SW; OBP or HW need to set it.
9510Sstevel@tonic-gate 	 */
952*27Sjchu 	DBG(DBG_LPU, NULL, "lpu_init - "
953*27Sjchu 	    "LPU_LINK_LAYER_VC0_FLOW_CONTROL_UPDATE_TIMER1: 0x%llx\n",
954*27Sjchu 	    CSR_XR(csr_base,
955*27Sjchu 	    LPU_LINK_LAYER_VC0_FLOW_CONTROL_UPDATE_TIMER1));
9560Sstevel@tonic-gate 
9570Sstevel@tonic-gate 	/*
9580Sstevel@tonic-gate 	 * CSR_V LPU_TXLINK_FREQUENT_NAK_LATENCY_TIMER_THRESHOLD
9590Sstevel@tonic-gate 	 */
9600Sstevel@tonic-gate 	if (pxu_p->chip_id == FIRE_VER_10) {
9610Sstevel@tonic-gate 		val = fire10_acknak_timer_table[max_payload][link_width];
9620Sstevel@tonic-gate 	} else {
9630Sstevel@tonic-gate 		/* Default case is FIRE2.0 */
9640Sstevel@tonic-gate 		val = acknak_timer_table[max_payload][link_width];
9650Sstevel@tonic-gate 	}
9660Sstevel@tonic-gate 
9670Sstevel@tonic-gate 	CSR_XS(csr_base,
9680Sstevel@tonic-gate 	    LPU_TXLINK_FREQUENT_NAK_LATENCY_TIMER_THRESHOLD, val);
9690Sstevel@tonic-gate 
9700Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - "
9710Sstevel@tonic-gate 	    "LPU_TXLINK_FREQUENT_NAK_LATENCY_TIMER_THRESHOLD: 0x%llx\n",
9720Sstevel@tonic-gate 	    CSR_XR(csr_base, LPU_TXLINK_FREQUENT_NAK_LATENCY_TIMER_THRESHOLD));
9730Sstevel@tonic-gate 
9740Sstevel@tonic-gate 	/*
9750Sstevel@tonic-gate 	 * CSR_V LPU_TXLINK_ACKNAK_LATENCY_TIMER Expect HW 0x0
9760Sstevel@tonic-gate 	 */
9770Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
978*27Sjchu 	    "lpu_init - LPU_TXLINK_ACKNAK_LATENCY_TIMER: 0x%llx\n",
979*27Sjchu 	    CSR_XR(csr_base, LPU_TXLINK_ACKNAK_LATENCY_TIMER));
9800Sstevel@tonic-gate 
9810Sstevel@tonic-gate 	/*
9820Sstevel@tonic-gate 	 * CSR_V LPU_TXLINK_REPLAY_TIMER_THRESHOLD
9830Sstevel@tonic-gate 	 */
9840Sstevel@tonic-gate 	if (pxu_p->chip_id == FIRE_VER_10) {
9850Sstevel@tonic-gate 		val = fire10_replay_timer_table[max_payload][link_width];
9860Sstevel@tonic-gate 	} else {
9870Sstevel@tonic-gate 		/* Default case is FIRE2.0 */
9880Sstevel@tonic-gate 		val = replay_timer_table[max_payload][link_width];
9890Sstevel@tonic-gate 	}
9900Sstevel@tonic-gate 
9910Sstevel@tonic-gate 	CSR_XS(csr_base, LPU_TXLINK_REPLAY_TIMER_THRESHOLD, val);
9920Sstevel@tonic-gate 
9930Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
9940Sstevel@tonic-gate 	    "lpu_init - LPU_TXLINK_REPLAY_TIMER_THRESHOLD: 0x%llx\n",
9950Sstevel@tonic-gate 	    CSR_XR(csr_base, LPU_TXLINK_REPLAY_TIMER_THRESHOLD));
9960Sstevel@tonic-gate 
9970Sstevel@tonic-gate 	/*
9980Sstevel@tonic-gate 	 * CSR_V LPU_TXLINK_REPLAY_TIMER Expect HW 0x0
9990Sstevel@tonic-gate 	 */
10000Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_TXLINK_REPLAY_TIMER: 0x%llx\n",
1001*27Sjchu 	    CSR_XR(csr_base, LPU_TXLINK_REPLAY_TIMER));
10020Sstevel@tonic-gate 
10030Sstevel@tonic-gate 	/*
10040Sstevel@tonic-gate 	 * CSR_V LPU_TXLINK_REPLAY_NUMBER_STATUS Expect OBP 0x3
10050Sstevel@tonic-gate 	 */
10060Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
1007*27Sjchu 	    "lpu_init - LPU_TXLINK_REPLAY_NUMBER_STATUS: 0x%llx\n",
1008*27Sjchu 	    CSR_XR(csr_base, LPU_TXLINK_REPLAY_NUMBER_STATUS));
10090Sstevel@tonic-gate 
10100Sstevel@tonic-gate 	/*
10110Sstevel@tonic-gate 	 * CSR_V LPU_REPLAY_BUFFER_MAX_ADDRESS Expect OBP 0xB3F
10120Sstevel@tonic-gate 	 */
10130Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
10140Sstevel@tonic-gate 	    "lpu_init - LPU_REPLAY_BUFFER_MAX_ADDRESS: 0x%llx\n",
10150Sstevel@tonic-gate 	    CSR_XR(csr_base, LPU_REPLAY_BUFFER_MAX_ADDRESS));
10160Sstevel@tonic-gate 
10170Sstevel@tonic-gate 	/*
10180Sstevel@tonic-gate 	 * CSR_V LPU_TXLINK_RETRY_FIFO_POINTER Expect OBP 0xFFFF0000
10190Sstevel@tonic-gate 	 */
10200Sstevel@tonic-gate 	val = ((LPU_TXLINK_RETRY_FIFO_POINTER_RTRY_FIFO_TLPTR_DEFAULT <<
1021*27Sjchu 	    LPU_TXLINK_RETRY_FIFO_POINTER_RTRY_FIFO_TLPTR) |
1022*27Sjchu 	    (LPU_TXLINK_RETRY_FIFO_POINTER_RTRY_FIFO_HDPTR_DEFAULT <<
1023*27Sjchu 	    LPU_TXLINK_RETRY_FIFO_POINTER_RTRY_FIFO_HDPTR));
10240Sstevel@tonic-gate 
10250Sstevel@tonic-gate 	CSR_XS(csr_base, LPU_TXLINK_RETRY_FIFO_POINTER, val);
10260Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
1027*27Sjchu 	    "lpu_init - LPU_TXLINK_RETRY_FIFO_POINTER: 0x%llx\n",
1028*27Sjchu 	    CSR_XR(csr_base, LPU_TXLINK_RETRY_FIFO_POINTER));
10290Sstevel@tonic-gate 
10300Sstevel@tonic-gate 	/*
10310Sstevel@tonic-gate 	 * CSR_V LPU_TXLINK_RETRY_FIFO_R_W_POINTER Expect OBP 0x0
10320Sstevel@tonic-gate 	 */
10330Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
10340Sstevel@tonic-gate 	    "lpu_init - LPU_TXLINK_RETRY_FIFO_R_W_POINTER: 0x%llx\n",
10350Sstevel@tonic-gate 	    CSR_XR(csr_base, LPU_TXLINK_RETRY_FIFO_R_W_POINTER));
10360Sstevel@tonic-gate 
10370Sstevel@tonic-gate 	/*
10380Sstevel@tonic-gate 	 * CSR_V LPU_TXLINK_RETRY_FIFO_CREDIT Expect HW 0x1580
10390Sstevel@tonic-gate 	 */
10400Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
1041*27Sjchu 	    "lpu_init - LPU_TXLINK_RETRY_FIFO_CREDIT: 0x%llx\n",
1042*27Sjchu 	    CSR_XR(csr_base, LPU_TXLINK_RETRY_FIFO_CREDIT));
10430Sstevel@tonic-gate 
10440Sstevel@tonic-gate 	/*
10450Sstevel@tonic-gate 	 * CSR_V LPU_TXLINK_SEQUENCE_COUNTER Expect OBP 0xFFF0000
10460Sstevel@tonic-gate 	 */
10470Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_TXLINK_SEQUENCE_COUNTER: 0x%llx\n",
1048*27Sjchu 	    CSR_XR(csr_base, LPU_TXLINK_SEQUENCE_COUNTER));
10490Sstevel@tonic-gate 
10500Sstevel@tonic-gate 	/*
10510Sstevel@tonic-gate 	 * CSR_V LPU_TXLINK_ACK_SENT_SEQUENCE_NUMBER Expect HW 0xFFF
10520Sstevel@tonic-gate 	 */
10530Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
1054*27Sjchu 	    "lpu_init - LPU_TXLINK_ACK_SENT_SEQUENCE_NUMBER: 0x%llx\n",
1055*27Sjchu 	    CSR_XR(csr_base, LPU_TXLINK_ACK_SENT_SEQUENCE_NUMBER));
10560Sstevel@tonic-gate 
10570Sstevel@tonic-gate 	/*
10580Sstevel@tonic-gate 	 * CSR_V LPU_TXLINK_SEQUENCE_COUNT_FIFO_MAX_ADDR Expect OBP 0x157
10590Sstevel@tonic-gate 	 */
10600Sstevel@tonic-gate 
10610Sstevel@tonic-gate 	/*
10620Sstevel@tonic-gate 	 * Test only register.  Will not be programmed.
10630Sstevel@tonic-gate 	 */
10640Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
1065*27Sjchu 	    "lpu_init - LPU_TXLINK_SEQUENCE_COUNT_FIFO_MAX_ADDR: 0x%llx\n",
1066*27Sjchu 	    CSR_XR(csr_base, LPU_TXLINK_SEQUENCE_COUNT_FIFO_MAX_ADDR));
10670Sstevel@tonic-gate 
10680Sstevel@tonic-gate 	/*
10690Sstevel@tonic-gate 	 * CSR_V LPU_TXLINK_SEQUENCE_COUNT_FIFO_POINTERS Expect HW 0xFFF0000
10700Sstevel@tonic-gate 	 */
10710Sstevel@tonic-gate 
10720Sstevel@tonic-gate 	/*
10730Sstevel@tonic-gate 	 * Test only register.  Will not be programmed.
10740Sstevel@tonic-gate 	 */
10750Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
1076*27Sjchu 	    "lpu_init - LPU_TXLINK_SEQUENCE_COUNT_FIFO_POINTERS: 0x%llx\n",
1077*27Sjchu 	    CSR_XR(csr_base, LPU_TXLINK_SEQUENCE_COUNT_FIFO_POINTERS));
10780Sstevel@tonic-gate 
10790Sstevel@tonic-gate 	/*
10800Sstevel@tonic-gate 	 * CSR_V LPU_TXLINK_SEQUENCE_COUNT_R_W_POINTERS Expect HW 0x0
10810Sstevel@tonic-gate 	 */
10820Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
1083*27Sjchu 	    "lpu_init - LPU_TXLINK_SEQUENCE_COUNT_R_W_POINTERS: 0x%llx\n",
1084*27Sjchu 	    CSR_XR(csr_base, LPU_TXLINK_SEQUENCE_COUNT_R_W_POINTERS));
10850Sstevel@tonic-gate 
10860Sstevel@tonic-gate 	/*
10870Sstevel@tonic-gate 	 * CSR_V LPU_TXLINK_TEST_CONTROL Expect HW 0x0
10880Sstevel@tonic-gate 	 */
10890Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_TXLINK_TEST_CONTROL: 0x%llx\n",
1090*27Sjchu 	    CSR_XR(csr_base, LPU_TXLINK_TEST_CONTROL));
10910Sstevel@tonic-gate 
10920Sstevel@tonic-gate 	/*
10930Sstevel@tonic-gate 	 * CSR_V LPU_TXLINK_MEMORY_ADDRESS_CONTROL Expect HW 0x0
10940Sstevel@tonic-gate 	 */
10950Sstevel@tonic-gate 
10960Sstevel@tonic-gate 	/*
10970Sstevel@tonic-gate 	 * Test only register.  Will not be programmed.
10980Sstevel@tonic-gate 	 */
10990Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
11000Sstevel@tonic-gate 	    "lpu_init - LPU_TXLINK_MEMORY_ADDRESS_CONTROL: 0x%llx\n",
11010Sstevel@tonic-gate 	    CSR_XR(csr_base, LPU_TXLINK_MEMORY_ADDRESS_CONTROL));
11020Sstevel@tonic-gate 
11030Sstevel@tonic-gate 	/*
11040Sstevel@tonic-gate 	 * CSR_V LPU_TXLINK_MEMORY_DATA_LOAD0 Expect HW 0x0
11050Sstevel@tonic-gate 	 */
11060Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
1107*27Sjchu 	    "lpu_init - LPU_TXLINK_MEMORY_DATA_LOAD0: 0x%llx\n",
1108*27Sjchu 	    CSR_XR(csr_base, LPU_TXLINK_MEMORY_DATA_LOAD0));
11090Sstevel@tonic-gate 
11100Sstevel@tonic-gate 	/*
11110Sstevel@tonic-gate 	 * CSR_V LPU_TXLINK_MEMORY_DATA_LOAD1 Expect HW 0x0
11120Sstevel@tonic-gate 	 */
11130Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
1114*27Sjchu 	    "lpu_init - LPU_TXLINK_MEMORY_DATA_LOAD1: 0x%llx\n",
1115*27Sjchu 	    CSR_XR(csr_base, LPU_TXLINK_MEMORY_DATA_LOAD1));
11160Sstevel@tonic-gate 
11170Sstevel@tonic-gate 	/*
11180Sstevel@tonic-gate 	 * CSR_V LPU_TXLINK_MEMORY_DATA_LOAD2 Expect HW 0x0
11190Sstevel@tonic-gate 	 */
11200Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
1121*27Sjchu 	    "lpu_init - LPU_TXLINK_MEMORY_DATA_LOAD2: 0x%llx\n",
1122*27Sjchu 	    CSR_XR(csr_base, LPU_TXLINK_MEMORY_DATA_LOAD2));
11230Sstevel@tonic-gate 
11240Sstevel@tonic-gate 	/*
11250Sstevel@tonic-gate 	 * CSR_V LPU_TXLINK_MEMORY_DATA_LOAD3 Expect HW 0x0
11260Sstevel@tonic-gate 	 */
11270Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
1128*27Sjchu 	    "lpu_init - LPU_TXLINK_MEMORY_DATA_LOAD3: 0x%llx\n",
1129*27Sjchu 	    CSR_XR(csr_base, LPU_TXLINK_MEMORY_DATA_LOAD3));
11300Sstevel@tonic-gate 
11310Sstevel@tonic-gate 	/*
11320Sstevel@tonic-gate 	 * CSR_V LPU_TXLINK_MEMORY_DATA_LOAD4 Expect HW 0x0
11330Sstevel@tonic-gate 	 */
11340Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
1135*27Sjchu 	    "lpu_init - LPU_TXLINK_MEMORY_DATA_LOAD4: 0x%llx\n",
1136*27Sjchu 	    CSR_XR(csr_base, LPU_TXLINK_MEMORY_DATA_LOAD4));
11370Sstevel@tonic-gate 
11380Sstevel@tonic-gate 	/*
11390Sstevel@tonic-gate 	 * CSR_V LPU_TXLINK_RETRY_DATA_COUNT Expect HW 0x0
11400Sstevel@tonic-gate 	 */
11410Sstevel@tonic-gate 
11420Sstevel@tonic-gate 	/*
11430Sstevel@tonic-gate 	 * Test only register.  Will not be programmed.
11440Sstevel@tonic-gate 	 */
11450Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_TXLINK_RETRY_DATA_COUNT: 0x%llx\n",
1146*27Sjchu 	    CSR_XR(csr_base, LPU_TXLINK_RETRY_DATA_COUNT));
11470Sstevel@tonic-gate 
11480Sstevel@tonic-gate 	/*
11490Sstevel@tonic-gate 	 * CSR_V LPU_TXLINK_SEQUENCE_BUFFER_COUNT Expect HW 0x0
11500Sstevel@tonic-gate 	 */
11510Sstevel@tonic-gate 
11520Sstevel@tonic-gate 	/*
11530Sstevel@tonic-gate 	 * Test only register.  Will not be programmed.
11540Sstevel@tonic-gate 	 */
11550Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
1156*27Sjchu 	    "lpu_init - LPU_TXLINK_SEQUENCE_BUFFER_COUNT: 0x%llx\n",
1157*27Sjchu 	    CSR_XR(csr_base, LPU_TXLINK_SEQUENCE_BUFFER_COUNT));
11580Sstevel@tonic-gate 
11590Sstevel@tonic-gate 	/*
11600Sstevel@tonic-gate 	 * CSR_V LPU_TXLINK_SEQUENCE_BUFFER_BOTTOM_DATA Expect HW 0x0
11610Sstevel@tonic-gate 	 */
11620Sstevel@tonic-gate 
11630Sstevel@tonic-gate 	/*
11640Sstevel@tonic-gate 	 * Test only register.
11650Sstevel@tonic-gate 	 */
11660Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
1167*27Sjchu 	    "lpu_init - LPU_TXLINK_SEQUENCE_BUFFER_BOTTOM_DATA: 0x%llx\n",
1168*27Sjchu 	    CSR_XR(csr_base, LPU_TXLINK_SEQUENCE_BUFFER_BOTTOM_DATA));
11690Sstevel@tonic-gate 
11700Sstevel@tonic-gate 	/*
11710Sstevel@tonic-gate 	 * CSR_V LPU_RXLINK_NEXT_RECEIVE_SEQUENCE_1_COUNTER Expect HW 0x0
11720Sstevel@tonic-gate 	 */
11730Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - "
1174*27Sjchu 	    "LPU_RXLINK_NEXT_RECEIVE_SEQUENCE_1_COUNTER: 0x%llx\n",
1175*27Sjchu 	    CSR_XR(csr_base, LPU_RXLINK_NEXT_RECEIVE_SEQUENCE_1_COUNTER));
11760Sstevel@tonic-gate 
11770Sstevel@tonic-gate 	/*
11780Sstevel@tonic-gate 	 * CSR_V LPU_RXLINK_UNSUPPORTED_DLLP_RECEIVED Expect HW 0x0
11790Sstevel@tonic-gate 	 */
11800Sstevel@tonic-gate 
11810Sstevel@tonic-gate 	/*
11820Sstevel@tonic-gate 	 * test only register.
11830Sstevel@tonic-gate 	 */
11840Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
1185*27Sjchu 	    "lpu_init - LPU_RXLINK_UNSUPPORTED_DLLP_RECEIVED: 0x%llx\n",
1186*27Sjchu 	    CSR_XR(csr_base, LPU_RXLINK_UNSUPPORTED_DLLP_RECEIVED));
11870Sstevel@tonic-gate 
11880Sstevel@tonic-gate 	/*
11890Sstevel@tonic-gate 	 * CSR_V LPU_RXLINK_TEST_CONTROL Expect HW 0x0
11900Sstevel@tonic-gate 	 */
11910Sstevel@tonic-gate 
11920Sstevel@tonic-gate 	/*
11930Sstevel@tonic-gate 	 * test only register.
11940Sstevel@tonic-gate 	 */
11950Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_RXLINK_TEST_CONTROL: 0x%llx\n",
1196*27Sjchu 	    CSR_XR(csr_base, LPU_RXLINK_TEST_CONTROL));
11970Sstevel@tonic-gate 
11980Sstevel@tonic-gate 	/*
11990Sstevel@tonic-gate 	 * CSR_V LPU_PHYSICAL_LAYER_CONFIGURATION Expect HW 0x10
12000Sstevel@tonic-gate 	 */
12010Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
1202*27Sjchu 	    "lpu_init - LPU_PHYSICAL_LAYER_CONFIGURATION: 0x%llx\n",
1203*27Sjchu 	    CSR_XR(csr_base, LPU_PHYSICAL_LAYER_CONFIGURATION));
12040Sstevel@tonic-gate 
12050Sstevel@tonic-gate 	/*
12060Sstevel@tonic-gate 	 * CSR_V LPU_PHY_LAYER_STATUS Expect HW 0x0
12070Sstevel@tonic-gate 	 */
12080Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_PHY_LAYER_STATUS: 0x%llx\n",
1209*27Sjchu 	    CSR_XR(csr_base, LPU_PHY_LAYER_STATUS));
12100Sstevel@tonic-gate 
12110Sstevel@tonic-gate 	/*
12120Sstevel@tonic-gate 	 * CSR_V LPU_PHY_INTERRUPT_AND_STATUS_TEST Expect HW 0x0
12130Sstevel@tonic-gate 	 */
12140Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
12150Sstevel@tonic-gate 	    "lpu_init - LPU_PHY_INTERRUPT_AND_STATUS_TEST: 0x%llx\n",
12160Sstevel@tonic-gate 	    CSR_XR(csr_base, LPU_PHY_INTERRUPT_AND_STATUS_TEST));
12170Sstevel@tonic-gate 
12180Sstevel@tonic-gate 	/*
1219*27Sjchu 	 * CSR_V LPU PHY LAYER interrupt regs (mask, status)
12200Sstevel@tonic-gate 	 */
12210Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_PHY_INTERRUPT_MASK: 0x%llx\n",
1222*27Sjchu 	    CSR_XR(csr_base, LPU_PHY_INTERRUPT_MASK));
1223*27Sjchu 
1224*27Sjchu 	DBG(DBG_LPU, NULL,
1225*27Sjchu 	    "lpu_init - LPU_PHY_LAYER_INTERRUPT_AND_STATUS: 0x%llx\n",
1226*27Sjchu 	    CSR_XR(csr_base, LPU_PHY_LAYER_INTERRUPT_AND_STATUS));
12270Sstevel@tonic-gate 
12280Sstevel@tonic-gate 	/*
12290Sstevel@tonic-gate 	 * CSR_V LPU_RECEIVE_PHY_CONFIG Expect HW 0x0
12300Sstevel@tonic-gate 	 */
12310Sstevel@tonic-gate 
12320Sstevel@tonic-gate 	/*
12330Sstevel@tonic-gate 	 * This also needs some explanation.  What is the best value
12340Sstevel@tonic-gate 	 * for the water mark?  Test mode enables which test mode?
12350Sstevel@tonic-gate 	 * Programming model needed for the Receiver Reset Lane N
12360Sstevel@tonic-gate 	 * bits.
12370Sstevel@tonic-gate 	 */
12380Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_RECEIVE_PHY_CONFIG: 0x%llx\n",
1239*27Sjchu 	    CSR_XR(csr_base, LPU_RECEIVE_PHY_CONFIG));
12400Sstevel@tonic-gate 
12410Sstevel@tonic-gate 	/*
12420Sstevel@tonic-gate 	 * CSR_V LPU_RECEIVE_PHY_STATUS1 Expect HW 0x0
12430Sstevel@tonic-gate 	 */
12440Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_RECEIVE_PHY_STATUS1: 0x%llx\n",
1245*27Sjchu 	    CSR_XR(csr_base, LPU_RECEIVE_PHY_STATUS1));
12460Sstevel@tonic-gate 
12470Sstevel@tonic-gate 	/*
12480Sstevel@tonic-gate 	 * CSR_V LPU_RECEIVE_PHY_STATUS2 Expect HW 0x0
12490Sstevel@tonic-gate 	 */
12500Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_RECEIVE_PHY_STATUS2: 0x%llx\n",
1251*27Sjchu 	    CSR_XR(csr_base, LPU_RECEIVE_PHY_STATUS2));
12520Sstevel@tonic-gate 
12530Sstevel@tonic-gate 	/*
12540Sstevel@tonic-gate 	 * CSR_V LPU_RECEIVE_PHY_STATUS3 Expect HW 0x0
12550Sstevel@tonic-gate 	 */
12560Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_RECEIVE_PHY_STATUS3: 0x%llx\n",
1257*27Sjchu 	    CSR_XR(csr_base, LPU_RECEIVE_PHY_STATUS3));
12580Sstevel@tonic-gate 
12590Sstevel@tonic-gate 	/*
12600Sstevel@tonic-gate 	 * CSR_V LPU_RECEIVE_PHY_INTERRUPT_AND_STATUS_TEST Expect HW 0x0
12610Sstevel@tonic-gate 	 */
12620Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
12630Sstevel@tonic-gate 	    "lpu_init - LPU_RECEIVE_PHY_INTERRUPT_AND_STATUS_TEST: 0x%llx\n",
12640Sstevel@tonic-gate 	    CSR_XR(csr_base, LPU_RECEIVE_PHY_INTERRUPT_AND_STATUS_TEST));
12650Sstevel@tonic-gate 
12660Sstevel@tonic-gate 	/*
1267*27Sjchu 	 * CSR_V LPU RX LAYER interrupt regs (mask, status)
12680Sstevel@tonic-gate 	 */
12690Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
1270*27Sjchu 	    "lpu_init - LPU_RECEIVE_PHY_INTERRUPT_MASK: 0x%llx\n",
1271*27Sjchu 	    CSR_XR(csr_base, LPU_RECEIVE_PHY_INTERRUPT_MASK));
1272*27Sjchu 
1273*27Sjchu 	DBG(DBG_LPU, NULL,
1274*27Sjchu 	    "lpu_init - LPU_RECEIVE_PHY_INTERRUPT_AND_STATUS: 0x%llx\n",
1275*27Sjchu 	    CSR_XR(csr_base, LPU_RECEIVE_PHY_INTERRUPT_AND_STATUS));
12760Sstevel@tonic-gate 
12770Sstevel@tonic-gate 	/*
12780Sstevel@tonic-gate 	 * CSR_V LPU_TRANSMIT_PHY_CONFIG Expect HW 0x0
12790Sstevel@tonic-gate 	 */
12800Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_TRANSMIT_PHY_CONFIG: 0x%llx\n",
1281*27Sjchu 	    CSR_XR(csr_base, LPU_TRANSMIT_PHY_CONFIG));
12820Sstevel@tonic-gate 
12830Sstevel@tonic-gate 	/*
12840Sstevel@tonic-gate 	 * CSR_V LPU_TRANSMIT_PHY_STATUS Expect HW 0x0
12850Sstevel@tonic-gate 	 */
12860Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_TRANSMIT_PHY_STATUS: 0x%llx\n",
12870Sstevel@tonic-gate 		CSR_XR(csr_base, LPU_TRANSMIT_PHY_STATUS));
12880Sstevel@tonic-gate 
12890Sstevel@tonic-gate 	/*
12900Sstevel@tonic-gate 	 * CSR_V LPU_TRANSMIT_PHY_INTERRUPT_AND_STATUS_TEST Expect HW 0x0
12910Sstevel@tonic-gate 	 */
12920Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
12930Sstevel@tonic-gate 	    "lpu_init - LPU_TRANSMIT_PHY_INTERRUPT_AND_STATUS_TEST: 0x%llx\n",
12940Sstevel@tonic-gate 	    CSR_XR(csr_base,
12950Sstevel@tonic-gate 	    LPU_TRANSMIT_PHY_INTERRUPT_AND_STATUS_TEST));
12960Sstevel@tonic-gate 
12970Sstevel@tonic-gate 	/*
1298*27Sjchu 	 * CSR_V LPU TX LAYER interrupt regs (mask, status)
12990Sstevel@tonic-gate 	 */
13000Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
1301*27Sjchu 	    "lpu_init - LPU_TRANSMIT_PHY_INTERRUPT_MASK: 0x%llx\n",
1302*27Sjchu 	    CSR_XR(csr_base, LPU_TRANSMIT_PHY_INTERRUPT_MASK));
1303*27Sjchu 
1304*27Sjchu 	DBG(DBG_LPU, NULL,
1305*27Sjchu 	    "lpu_init - LPU_TRANSMIT_PHY_INTERRUPT_AND_STATUS: 0x%llx\n",
1306*27Sjchu 	    CSR_XR(csr_base, LPU_TRANSMIT_PHY_INTERRUPT_AND_STATUS));
13070Sstevel@tonic-gate 
13080Sstevel@tonic-gate 	/*
13090Sstevel@tonic-gate 	 * CSR_V LPU_TRANSMIT_PHY_STATUS_2 Expect HW 0x0
13100Sstevel@tonic-gate 	 */
13110Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_TRANSMIT_PHY_STATUS_2: 0x%llx\n",
1312*27Sjchu 	    CSR_XR(csr_base, LPU_TRANSMIT_PHY_STATUS_2));
13130Sstevel@tonic-gate 
13140Sstevel@tonic-gate 	/*
13150Sstevel@tonic-gate 	 * CSR_V LPU_LTSSM_CONFIG1 Expect OBP 0x205
13160Sstevel@tonic-gate 	 */
13170Sstevel@tonic-gate 
13180Sstevel@tonic-gate 	/*
13190Sstevel@tonic-gate 	 * The new PRM has values for LTSSM 8 ns timeout value and
13200Sstevel@tonic-gate 	 * LTSSM 20 ns timeout value.  But what do these values mean?
13210Sstevel@tonic-gate 	 * Most of the other bits are questions as well.
13220Sstevel@tonic-gate 	 *
13230Sstevel@tonic-gate 	 * As such we will use the reset value.
13240Sstevel@tonic-gate 	 */
13250Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_LTSSM_CONFIG1: 0x%llx\n",
1326*27Sjchu 	    CSR_XR(csr_base, LPU_LTSSM_CONFIG1));
13270Sstevel@tonic-gate 
13280Sstevel@tonic-gate 	/*
13290Sstevel@tonic-gate 	 * CSR_V LPU_LTSSM_CONFIG2 Expect OBP 0x2DC6C0
13300Sstevel@tonic-gate 	 */
13310Sstevel@tonic-gate 
13320Sstevel@tonic-gate 	/*
13330Sstevel@tonic-gate 	 * Again, what does '12 ms timeout value mean'?
13340Sstevel@tonic-gate 	 */
13350Sstevel@tonic-gate 	val = (LPU_LTSSM_CONFIG2_LTSSM_12_TO_DEFAULT <<
1336*27Sjchu 	    LPU_LTSSM_CONFIG2_LTSSM_12_TO);
13370Sstevel@tonic-gate 	CSR_XS(csr_base, LPU_LTSSM_CONFIG2, val);
13380Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_LTSSM_CONFIG2: 0x%llx\n",
1339*27Sjchu 	    CSR_XR(csr_base, LPU_LTSSM_CONFIG2));
13400Sstevel@tonic-gate 
13410Sstevel@tonic-gate 	/*
13420Sstevel@tonic-gate 	 * CSR_V LPU_LTSSM_CONFIG3 Expect OBP 0x7A120
13430Sstevel@tonic-gate 	 */
13440Sstevel@tonic-gate 	val = (LPU_LTSSM_CONFIG3_LTSSM_2_TO_DEFAULT <<
1345*27Sjchu 	    LPU_LTSSM_CONFIG3_LTSSM_2_TO);
13460Sstevel@tonic-gate 	CSR_XS(csr_base, LPU_LTSSM_CONFIG3, val);
13470Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_LTSSM_CONFIG3: 0x%llx\n",
1348*27Sjchu 	    CSR_XR(csr_base, LPU_LTSSM_CONFIG3));
13490Sstevel@tonic-gate 
13500Sstevel@tonic-gate 	/*
13510Sstevel@tonic-gate 	 * CSR_V LPU_LTSSM_CONFIG4 Expect OBP 0x21300
13520Sstevel@tonic-gate 	 */
13530Sstevel@tonic-gate 	val = ((LPU_LTSSM_CONFIG4_DATA_RATE_DEFAULT <<
1354*27Sjchu 	    LPU_LTSSM_CONFIG4_DATA_RATE) |
13550Sstevel@tonic-gate 		(LPU_LTSSM_CONFIG4_N_FTS_DEFAULT <<
13560Sstevel@tonic-gate 		LPU_LTSSM_CONFIG4_N_FTS));
13570Sstevel@tonic-gate 	CSR_XS(csr_base, LPU_LTSSM_CONFIG4, val);
13580Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_LTSSM_CONFIG4: 0x%llx\n",
1359*27Sjchu 	    CSR_XR(csr_base, LPU_LTSSM_CONFIG4));
13600Sstevel@tonic-gate 
13610Sstevel@tonic-gate 	/*
13620Sstevel@tonic-gate 	 * CSR_V LPU_LTSSM_CONFIG5 Expect OBP 0x0
13630Sstevel@tonic-gate 	 */
13640Sstevel@tonic-gate 	val = 0ull;
13650Sstevel@tonic-gate 	CSR_XS(csr_base, LPU_LTSSM_CONFIG5, val);
13660Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_LTSSM_CONFIG5: 0x%llx\n",
1367*27Sjchu 	    CSR_XR(csr_base, LPU_LTSSM_CONFIG5));
13680Sstevel@tonic-gate 
13690Sstevel@tonic-gate 	/*
13700Sstevel@tonic-gate 	 * CSR_V LPU_LTSSM_STATUS1 Expect OBP 0x0
13710Sstevel@tonic-gate 	 */
13720Sstevel@tonic-gate 
13730Sstevel@tonic-gate 	/*
13740Sstevel@tonic-gate 	 * LTSSM Status registers are test only.
13750Sstevel@tonic-gate 	 */
13760Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_LTSSM_STATUS1: 0x%llx\n",
1377*27Sjchu 	    CSR_XR(csr_base, LPU_LTSSM_STATUS1));
13780Sstevel@tonic-gate 
13790Sstevel@tonic-gate 	/*
13800Sstevel@tonic-gate 	 * CSR_V LPU_LTSSM_STATUS2 Expect OBP 0x0
13810Sstevel@tonic-gate 	 */
13820Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_LTSSM_STATUS2: 0x%llx\n",
1383*27Sjchu 	    CSR_XR(csr_base, LPU_LTSSM_STATUS2));
13840Sstevel@tonic-gate 
13850Sstevel@tonic-gate 	/*
13860Sstevel@tonic-gate 	 * CSR_V LPU_LTSSM_INTERRUPT_AND_STATUS_TEST Expect HW 0x0
13870Sstevel@tonic-gate 	 */
13880Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
1389*27Sjchu 	    "lpu_init - LPU_LTSSM_INTERRUPT_AND_STATUS_TEST: 0x%llx\n",
1390*27Sjchu 	    CSR_XR(csr_base, LPU_LTSSM_INTERRUPT_AND_STATUS_TEST));
13910Sstevel@tonic-gate 
13920Sstevel@tonic-gate 	/*
1393*27Sjchu 	 * CSR_V LPU LTSSM  LAYER interrupt regs (mask, status)
13940Sstevel@tonic-gate 	 */
13950Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_LTSSM_INTERRUPT_MASK: 0x%llx\n",
1396*27Sjchu 	    CSR_XR(csr_base, LPU_LTSSM_INTERRUPT_MASK));
1397*27Sjchu 
1398*27Sjchu 	DBG(DBG_LPU, NULL,
1399*27Sjchu 	    "lpu_init - LPU_LTSSM_INTERRUPT_AND_STATUS: 0x%llx\n",
1400*27Sjchu 	    CSR_XR(csr_base, LPU_LTSSM_INTERRUPT_AND_STATUS));
14010Sstevel@tonic-gate 
14020Sstevel@tonic-gate 	/*
14030Sstevel@tonic-gate 	 * CSR_V LPU_LTSSM_STATUS_WRITE_ENABLE Expect OBP 0x0
14040Sstevel@tonic-gate 	 */
14050Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
1406*27Sjchu 	    "lpu_init - LPU_LTSSM_STATUS_WRITE_ENABLE: 0x%llx\n",
1407*27Sjchu 	    CSR_XR(csr_base, LPU_LTSSM_STATUS_WRITE_ENABLE));
14080Sstevel@tonic-gate 
14090Sstevel@tonic-gate 	/*
14100Sstevel@tonic-gate 	 * CSR_V LPU_GIGABLAZE_GLUE_CONFIG1 Expect OBP 0x88407
14110Sstevel@tonic-gate 	 */
14120Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_GIGABLAZE_GLUE_CONFIG1: 0x%llx\n",
1413*27Sjchu 	    CSR_XR(csr_base, LPU_GIGABLAZE_GLUE_CONFIG1));
14140Sstevel@tonic-gate 
14150Sstevel@tonic-gate 	/*
14160Sstevel@tonic-gate 	 * CSR_V LPU_GIGABLAZE_GLUE_CONFIG2 Expect OBP 0x35
14170Sstevel@tonic-gate 	 */
14180Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_GIGABLAZE_GLUE_CONFIG2: 0x%llx\n",
1419*27Sjchu 	    CSR_XR(csr_base, LPU_GIGABLAZE_GLUE_CONFIG2));
14200Sstevel@tonic-gate 
14210Sstevel@tonic-gate 	/*
14220Sstevel@tonic-gate 	 * CSR_V LPU_GIGABLAZE_GLUE_CONFIG3 Expect OBP 0x4400FA
14230Sstevel@tonic-gate 	 */
14240Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_GIGABLAZE_GLUE_CONFIG3: 0x%llx\n",
1425*27Sjchu 	    CSR_XR(csr_base, LPU_GIGABLAZE_GLUE_CONFIG3));
14260Sstevel@tonic-gate 
14270Sstevel@tonic-gate 	/*
14280Sstevel@tonic-gate 	 * CSR_V LPU_GIGABLAZE_GLUE_CONFIG4 Expect OBP 0x1E848
14290Sstevel@tonic-gate 	 */
14300Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_GIGABLAZE_GLUE_CONFIG4: 0x%llx\n",
1431*27Sjchu 	    CSR_XR(csr_base, LPU_GIGABLAZE_GLUE_CONFIG4));
14320Sstevel@tonic-gate 
14330Sstevel@tonic-gate 	/*
14340Sstevel@tonic-gate 	 * CSR_V LPU_GIGABLAZE_GLUE_STATUS Expect OBP 0x0
14350Sstevel@tonic-gate 	 */
14360Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_GIGABLAZE_GLUE_STATUS: 0x%llx\n",
1437*27Sjchu 	    CSR_XR(csr_base, LPU_GIGABLAZE_GLUE_STATUS));
14380Sstevel@tonic-gate 
14390Sstevel@tonic-gate 	/*
14400Sstevel@tonic-gate 	 * CSR_V LPU_GIGABLAZE_GLUE_INTERRUPT_AND_STATUS_TEST Expect OBP 0x0
14410Sstevel@tonic-gate 	 */
1442*27Sjchu 	DBG(DBG_LPU, NULL, "lpu_init - "
1443*27Sjchu 	    "LPU_GIGABLAZE_GLUE_INTERRUPT_AND_STATUS_TEST: 0x%llx\n",
1444*27Sjchu 	    CSR_XR(csr_base,
1445*27Sjchu 	    LPU_GIGABLAZE_GLUE_INTERRUPT_AND_STATUS_TEST));
14460Sstevel@tonic-gate 
14470Sstevel@tonic-gate 	/*
1448*27Sjchu 	 * CSR_V LPU GIGABLASE LAYER interrupt regs (mask, status)
14490Sstevel@tonic-gate 	 */
14500Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
14510Sstevel@tonic-gate 	    "lpu_init - LPU_GIGABLAZE_GLUE_INTERRUPT_MASK: 0x%llx\n",
14520Sstevel@tonic-gate 	    CSR_XR(csr_base, LPU_GIGABLAZE_GLUE_INTERRUPT_MASK));
14530Sstevel@tonic-gate 
1454*27Sjchu 	DBG(DBG_LPU, NULL,
1455*27Sjchu 	    "lpu_init - LPU_GIGABLAZE_GLUE_INTERRUPT_AND_STATUS: 0x%llx\n",
1456*27Sjchu 	    CSR_XR(csr_base, LPU_GIGABLAZE_GLUE_INTERRUPT_AND_STATUS));
1457*27Sjchu 
14580Sstevel@tonic-gate 	/*
14590Sstevel@tonic-gate 	 * CSR_V LPU_GIGABLAZE_GLUE_POWER_DOWN1 Expect HW 0x0
14600Sstevel@tonic-gate 	 */
14610Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
1462*27Sjchu 	    "lpu_init - LPU_GIGABLAZE_GLUE_POWER_DOWN1: 0x%llx\n",
1463*27Sjchu 	    CSR_XR(csr_base, LPU_GIGABLAZE_GLUE_POWER_DOWN1));
14640Sstevel@tonic-gate 
14650Sstevel@tonic-gate 	/*
14660Sstevel@tonic-gate 	 * CSR_V LPU_GIGABLAZE_GLUE_POWER_DOWN2 Expect HW 0x0
14670Sstevel@tonic-gate 	 */
14680Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
1469*27Sjchu 	    "lpu_init - LPU_GIGABLAZE_GLUE_POWER_DOWN2: 0x%llx\n",
1470*27Sjchu 	    CSR_XR(csr_base, LPU_GIGABLAZE_GLUE_POWER_DOWN2));
14710Sstevel@tonic-gate 
14720Sstevel@tonic-gate 	/*
14730Sstevel@tonic-gate 	 * CSR_V LPU_GIGABLAZE_GLUE_CONFIG5 Expect OBP 0x0
14740Sstevel@tonic-gate 	 */
14750Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_GIGABLAZE_GLUE_CONFIG5: 0x%llx\n",
1476*27Sjchu 	    CSR_XR(csr_base, LPU_GIGABLAZE_GLUE_CONFIG5));
14770Sstevel@tonic-gate }
14780Sstevel@tonic-gate 
14790Sstevel@tonic-gate /* ARGSUSED */
14800Sstevel@tonic-gate static void
14810Sstevel@tonic-gate dmc_init(caddr_t csr_base, pxu_t *pxu_p)
14820Sstevel@tonic-gate {
14830Sstevel@tonic-gate 	uint64_t val;
14840Sstevel@tonic-gate 
14850Sstevel@tonic-gate /*
14860Sstevel@tonic-gate  * CSR_V DMC_CORE_AND_BLOCK_INTERRUPT_ENABLE Expect OBP 0x8000000000000003
14870Sstevel@tonic-gate  */
14880Sstevel@tonic-gate 
14890Sstevel@tonic-gate 	val = -1ull;
14900Sstevel@tonic-gate 	CSR_XS(csr_base, DMC_CORE_AND_BLOCK_INTERRUPT_ENABLE, val);
14910Sstevel@tonic-gate 	DBG(DBG_DMC, NULL,
1492*27Sjchu 	    "dmc_init - DMC_CORE_AND_BLOCK_INTERRUPT_ENABLE: 0x%llx\n",
1493*27Sjchu 	    CSR_XR(csr_base, DMC_CORE_AND_BLOCK_INTERRUPT_ENABLE));
14940Sstevel@tonic-gate 
14950Sstevel@tonic-gate 	/*
14960Sstevel@tonic-gate 	 * CSR_V DMC_CORE_AND_BLOCK_ERROR_STATUS Expect HW 0x0
14970Sstevel@tonic-gate 	 */
14980Sstevel@tonic-gate 	DBG(DBG_DMC, NULL,
1499*27Sjchu 	    "dmc_init - DMC_CORE_AND_BLOCK_ERROR_STATUS: 0x%llx\n",
1500*27Sjchu 	    CSR_XR(csr_base, DMC_CORE_AND_BLOCK_ERROR_STATUS));
15010Sstevel@tonic-gate 
15020Sstevel@tonic-gate 	/*
15030Sstevel@tonic-gate 	 * CSR_V DMC_DEBUG_SELECT_FOR_PORT_A Expect HW 0x0
15040Sstevel@tonic-gate 	 */
15050Sstevel@tonic-gate 	val = 0x0ull;
15060Sstevel@tonic-gate 	CSR_XS(csr_base, DMC_DEBUG_SELECT_FOR_PORT_A, val);
15070Sstevel@tonic-gate 	DBG(DBG_DMC, NULL, "dmc_init - DMC_DEBUG_SELECT_FOR_PORT_A: 0x%llx\n",
1508*27Sjchu 	    CSR_XR(csr_base, DMC_DEBUG_SELECT_FOR_PORT_A));
15090Sstevel@tonic-gate 
15100Sstevel@tonic-gate 	/*
15110Sstevel@tonic-gate 	 * CSR_V DMC_DEBUG_SELECT_FOR_PORT_B Expect HW 0x0
15120Sstevel@tonic-gate 	 */
15130Sstevel@tonic-gate 	val = 0x0ull;
15140Sstevel@tonic-gate 	CSR_XS(csr_base, DMC_DEBUG_SELECT_FOR_PORT_B, val);
15150Sstevel@tonic-gate 	DBG(DBG_DMC, NULL, "dmc_init - DMC_DEBUG_SELECT_FOR_PORT_B: 0x%llx\n",
1516*27Sjchu 	    CSR_XR(csr_base, DMC_DEBUG_SELECT_FOR_PORT_B));
15170Sstevel@tonic-gate }
15180Sstevel@tonic-gate 
15190Sstevel@tonic-gate void
15200Sstevel@tonic-gate hvio_pec_init(caddr_t csr_base, pxu_t *pxu_p)
15210Sstevel@tonic-gate {
15220Sstevel@tonic-gate 	uint64_t val;
15230Sstevel@tonic-gate 
15240Sstevel@tonic-gate 	ilu_init(csr_base, pxu_p);
15250Sstevel@tonic-gate 	tlu_init(csr_base, pxu_p);
15260Sstevel@tonic-gate 	lpu_init(csr_base, pxu_p);
15270Sstevel@tonic-gate 	dmc_init(csr_base, pxu_p);
15280Sstevel@tonic-gate 
15290Sstevel@tonic-gate /*
15300Sstevel@tonic-gate  * CSR_V PEC_CORE_AND_BLOCK_INTERRUPT_ENABLE Expect Kernel 0x800000000000000F
15310Sstevel@tonic-gate  */
15320Sstevel@tonic-gate 
15330Sstevel@tonic-gate 	val = -1ull;
15340Sstevel@tonic-gate 	CSR_XS(csr_base, PEC_CORE_AND_BLOCK_INTERRUPT_ENABLE, val);
15350Sstevel@tonic-gate 	DBG(DBG_PEC, NULL,
1536*27Sjchu 	    "hvio_pec_init - PEC_CORE_AND_BLOCK_INTERRUPT_ENABLE: 0x%llx\n",
1537*27Sjchu 	    CSR_XR(csr_base, PEC_CORE_AND_BLOCK_INTERRUPT_ENABLE));
15380Sstevel@tonic-gate 
15390Sstevel@tonic-gate 	/*
15400Sstevel@tonic-gate 	 * CSR_V PEC_CORE_AND_BLOCK_INTERRUPT_STATUS Expect HW 0x0
15410Sstevel@tonic-gate 	 */
15420Sstevel@tonic-gate 	DBG(DBG_PEC, NULL,
1543*27Sjchu 	    "hvio_pec_init - PEC_CORE_AND_BLOCK_INTERRUPT_STATUS: 0x%llx\n",
1544*27Sjchu 	    CSR_XR(csr_base, PEC_CORE_AND_BLOCK_INTERRUPT_STATUS));
15450Sstevel@tonic-gate }
15460Sstevel@tonic-gate 
1547*27Sjchu /*
1548*27Sjchu  * Initialize the module, but do not enable interrupts.
1549*27Sjchu  */
15500Sstevel@tonic-gate void
15510Sstevel@tonic-gate hvio_mmu_init(caddr_t csr_base, pxu_t *pxu_p)
15520Sstevel@tonic-gate {
15530Sstevel@tonic-gate 	uint64_t	val, i, tsb_ctrl, obp_tsb_pa, *base_tte_addr;
15540Sstevel@tonic-gate 	uint_t		obp_tsb_entries, obp_tsb_size;
15550Sstevel@tonic-gate 
15560Sstevel@tonic-gate 	bzero(pxu_p->tsb_vaddr, pxu_p->tsb_size);
15570Sstevel@tonic-gate 
15580Sstevel@tonic-gate 	/*
15590Sstevel@tonic-gate 	 * Preserve OBP's TSB
15600Sstevel@tonic-gate 	 */
15610Sstevel@tonic-gate 	val = CSR_XR(csr_base, MMU_TSB_CONTROL);
15620Sstevel@tonic-gate 
15630Sstevel@tonic-gate 	tsb_ctrl = CSR_XR(csr_base, MMU_TSB_CONTROL);
15640Sstevel@tonic-gate 
15650Sstevel@tonic-gate 	obp_tsb_pa = tsb_ctrl &  0x7FFFFFFE000;
15660Sstevel@tonic-gate 	obp_tsb_size = tsb_ctrl & 0xF;
15670Sstevel@tonic-gate 
15680Sstevel@tonic-gate 	obp_tsb_entries = MMU_TSBSIZE_TO_TSBENTRIES(obp_tsb_size);
15690Sstevel@tonic-gate 
15700Sstevel@tonic-gate 	base_tte_addr = pxu_p->tsb_vaddr +
15710Sstevel@tonic-gate 		((pxu_p->tsb_size >> 3) - obp_tsb_entries);
15720Sstevel@tonic-gate 
15730Sstevel@tonic-gate 	for (i = 0; i < obp_tsb_entries; i++) {
15740Sstevel@tonic-gate 		uint64_t tte = lddphys(obp_tsb_pa + i * 8);
15750Sstevel@tonic-gate 
15760Sstevel@tonic-gate 		if (!MMU_TTE_VALID(tte))
15770Sstevel@tonic-gate 			continue;
15780Sstevel@tonic-gate 
15790Sstevel@tonic-gate 		base_tte_addr[i] = tte;
15800Sstevel@tonic-gate 	}
15810Sstevel@tonic-gate 
15820Sstevel@tonic-gate 	/*
15830Sstevel@tonic-gate 	 * Invalidate the TLB through the diagnostic register.
15840Sstevel@tonic-gate 	 */
15850Sstevel@tonic-gate 
15860Sstevel@tonic-gate 	CSR_XS(csr_base, MMU_TTE_CACHE_INVALIDATE, -1ull);
15870Sstevel@tonic-gate 
15880Sstevel@tonic-gate 	/*
15890Sstevel@tonic-gate 	 * Configure the Fire MMU TSB Control Register.  Determine
15900Sstevel@tonic-gate 	 * the encoding for either 8KB pages (0) or 64KB pages (1).
15910Sstevel@tonic-gate 	 *
15920Sstevel@tonic-gate 	 * Write the most significant 30 bits of the TSB physical address
15930Sstevel@tonic-gate 	 * and the encoded TSB table size.
15940Sstevel@tonic-gate 	 */
15950Sstevel@tonic-gate 	for (i = 8; i && (pxu_p->tsb_size < (0x2000 << i)); i--);
15960Sstevel@tonic-gate 
15970Sstevel@tonic-gate 	val = (((((va_to_pa(pxu_p->tsb_vaddr)) >> 13) << 13) |
15980Sstevel@tonic-gate 	    ((MMU_PAGE_SHIFT == 13) ? 0 : 1) << 8) | i);
15990Sstevel@tonic-gate 
16000Sstevel@tonic-gate 	CSR_XS(csr_base, MMU_TSB_CONTROL, val);
16010Sstevel@tonic-gate 
16020Sstevel@tonic-gate 	/*
16030Sstevel@tonic-gate 	 * Enable the MMU, set the "TSB Cache Snoop Enable",
16040Sstevel@tonic-gate 	 * the "Cache Mode", the "Bypass Enable" and
16050Sstevel@tonic-gate 	 * the "Translation Enable" bits.
16060Sstevel@tonic-gate 	 */
16070Sstevel@tonic-gate 	val = CSR_XR(csr_base, MMU_CONTROL_AND_STATUS);
16080Sstevel@tonic-gate 	val |= ((1ull << MMU_CONTROL_AND_STATUS_SE)
1609*27Sjchu 	    | (MMU_CONTROL_AND_STATUS_CM_MASK << MMU_CONTROL_AND_STATUS_CM)
1610*27Sjchu 	    | (1ull << MMU_CONTROL_AND_STATUS_BE)
1611*27Sjchu 	    | (1ull << MMU_CONTROL_AND_STATUS_TE));
16120Sstevel@tonic-gate 
16130Sstevel@tonic-gate 	CSR_XS(csr_base, MMU_CONTROL_AND_STATUS, val);
16140Sstevel@tonic-gate 
16150Sstevel@tonic-gate 	/*
16160Sstevel@tonic-gate 	 * Read the register here to ensure that the previous writes to
16170Sstevel@tonic-gate 	 * the Fire MMU registers have been flushed.  (Technically, this
16180Sstevel@tonic-gate 	 * is not entirely necessary here as we will likely do later reads
16190Sstevel@tonic-gate 	 * during Fire initialization, but it is a small price to pay for
16200Sstevel@tonic-gate 	 * more modular code.)
16210Sstevel@tonic-gate 	 */
16220Sstevel@tonic-gate 	(void) CSR_XR(csr_base, MMU_CONTROL_AND_STATUS);
16230Sstevel@tonic-gate 
16240Sstevel@tonic-gate 	/*
1625*27Sjchu 	 * CSR_V TLU's UE interrupt regs (log, enable, status, clear)
1626*27Sjchu 	 * Plus header logs
16270Sstevel@tonic-gate 	 */
1628*27Sjchu 	DBG(DBG_MMU, NULL, "mmu_init - MMU_ERROR_LOG_ENABLE: 0x%llx\n",
1629*27Sjchu 	    CSR_XR(csr_base, MMU_ERROR_LOG_ENABLE));
1630*27Sjchu 
1631*27Sjchu 	DBG(DBG_MMU, NULL, "mmu_init - MMU_INTERRUPT_ENABLE: 0x%llx\n",
1632*27Sjchu 	    CSR_XR(csr_base, MMU_INTERRUPT_ENABLE));
1633*27Sjchu 
1634*27Sjchu 	DBG(DBG_MMU, NULL, "mmu_init - MMU_INTERRUPT_STATUS: 0x%llx\n",
1635*27Sjchu 	    CSR_XR(csr_base, MMU_INTERRUPT_STATUS));
1636*27Sjchu 
1637*27Sjchu 	DBG(DBG_MMU, NULL, "mmu_init - MMU_ERROR_STATUS_CLEAR: 0x%llx\n",
1638*27Sjchu 	    CSR_XR(csr_base, MMU_ERROR_STATUS_CLEAR));
16390Sstevel@tonic-gate }
16400Sstevel@tonic-gate 
16410Sstevel@tonic-gate /*
16420Sstevel@tonic-gate  * Generic IOMMU Servies
16430Sstevel@tonic-gate  */
16440Sstevel@tonic-gate 
16450Sstevel@tonic-gate /* ARGSUSED */
16460Sstevel@tonic-gate uint64_t
16470Sstevel@tonic-gate hvio_iommu_map(devhandle_t dev_hdl, pxu_t *pxu_p, tsbid_t tsbid,
16480Sstevel@tonic-gate     pages_t pages, io_attributes_t io_attributes,
16490Sstevel@tonic-gate     void *addr, size_t pfn_index, int flag)
16500Sstevel@tonic-gate {
16510Sstevel@tonic-gate 	tsbindex_t	tsb_index = PCI_TSBID_TO_TSBINDEX(tsbid);
16520Sstevel@tonic-gate 	uint64_t	attr = MMU_TTE_V;
16530Sstevel@tonic-gate 	int		i;
16540Sstevel@tonic-gate 
16550Sstevel@tonic-gate 	if (io_attributes & PCI_MAP_ATTR_WRITE)
16560Sstevel@tonic-gate 		attr |= MMU_TTE_W;
16570Sstevel@tonic-gate 
16580Sstevel@tonic-gate 	if (flag == MMU_MAP_MP) {
16590Sstevel@tonic-gate 		ddi_dma_impl_t  *mp = (ddi_dma_impl_t *)addr;
16600Sstevel@tonic-gate 
16610Sstevel@tonic-gate 		for (i = 0; i < pages; i++, pfn_index++, tsb_index++) {
16620Sstevel@tonic-gate 			px_iopfn_t	pfn = PX_GET_MP_PFN(mp, pfn_index);
16630Sstevel@tonic-gate 
16640Sstevel@tonic-gate 			pxu_p->tsb_vaddr[tsb_index] =
16650Sstevel@tonic-gate 			    MMU_PTOB(pfn) | attr;
16660Sstevel@tonic-gate 		}
16670Sstevel@tonic-gate 	} else {
16680Sstevel@tonic-gate 		caddr_t a = (caddr_t)addr;
16690Sstevel@tonic-gate 
16700Sstevel@tonic-gate 		for (i = 0; i < pages; i++, a += MMU_PAGE_SIZE, tsb_index++) {
16710Sstevel@tonic-gate 			px_iopfn_t pfn = hat_getpfnum(kas.a_hat, a);
16720Sstevel@tonic-gate 
16730Sstevel@tonic-gate 			pxu_p->tsb_vaddr[tsb_index] =
16740Sstevel@tonic-gate 			    MMU_PTOB(pfn) | attr;
16750Sstevel@tonic-gate 		}
16760Sstevel@tonic-gate 	}
16770Sstevel@tonic-gate 
16780Sstevel@tonic-gate 	return (H_EOK);
16790Sstevel@tonic-gate }
16800Sstevel@tonic-gate 
16810Sstevel@tonic-gate /* ARGSUSED */
16820Sstevel@tonic-gate uint64_t
16830Sstevel@tonic-gate hvio_iommu_demap(devhandle_t dev_hdl, pxu_t *pxu_p, tsbid_t tsbid,
16840Sstevel@tonic-gate     pages_t pages)
16850Sstevel@tonic-gate {
16860Sstevel@tonic-gate 	tsbindex_t	tsb_index = PCI_TSBID_TO_TSBINDEX(tsbid);
16870Sstevel@tonic-gate 	int		i;
16880Sstevel@tonic-gate 
16890Sstevel@tonic-gate 	for (i = 0; i < pages; i++, tsb_index++) {
16900Sstevel@tonic-gate 		pxu_p->tsb_vaddr[tsb_index] = MMU_INVALID_TTE;
16910Sstevel@tonic-gate 	}
16920Sstevel@tonic-gate 
16930Sstevel@tonic-gate 	return (H_EOK);
16940Sstevel@tonic-gate }
16950Sstevel@tonic-gate 
16960Sstevel@tonic-gate /* ARGSUSED */
16970Sstevel@tonic-gate uint64_t
16980Sstevel@tonic-gate hvio_iommu_getmap(devhandle_t dev_hdl, pxu_t *pxu_p, tsbid_t tsbid,
16990Sstevel@tonic-gate     io_attributes_t *attributes_p, r_addr_t *r_addr_p)
17000Sstevel@tonic-gate {
17010Sstevel@tonic-gate 	tsbindex_t	tsb_index = PCI_TSBID_TO_TSBINDEX(tsbid);
17020Sstevel@tonic-gate 	uint64_t	*tte_addr;
17030Sstevel@tonic-gate 	uint64_t	ret = H_EOK;
17040Sstevel@tonic-gate 
17050Sstevel@tonic-gate 	tte_addr = (uint64_t *)(pxu_p->tsb_vaddr) + tsb_index;
17060Sstevel@tonic-gate 
17070Sstevel@tonic-gate 	if (*tte_addr & MMU_TTE_V) {
17080Sstevel@tonic-gate 		*r_addr_p = MMU_TTETOPA(*tte_addr);
17090Sstevel@tonic-gate 		*attributes_p = (*tte_addr & MMU_TTE_W) ?
17100Sstevel@tonic-gate 		    PCI_MAP_ATTR_WRITE:PCI_MAP_ATTR_READ;
17110Sstevel@tonic-gate 	} else {
17120Sstevel@tonic-gate 		*r_addr_p = 0;
17130Sstevel@tonic-gate 		*attributes_p = 0;
17140Sstevel@tonic-gate 		ret = H_ENOMAP;
17150Sstevel@tonic-gate 	}
17160Sstevel@tonic-gate 
17170Sstevel@tonic-gate 	return (ret);
17180Sstevel@tonic-gate }
17190Sstevel@tonic-gate 
17200Sstevel@tonic-gate /* ARGSUSED */
17210Sstevel@tonic-gate uint64_t
17220Sstevel@tonic-gate hvio_iommu_getbypass(devhandle_t dev_hdl, r_addr_t ra,
17230Sstevel@tonic-gate     io_attributes_t io_attributes, io_addr_t *io_addr_p)
17240Sstevel@tonic-gate {
17250Sstevel@tonic-gate 	uint64_t	pfn = MMU_BTOP(ra);
17260Sstevel@tonic-gate 
17270Sstevel@tonic-gate 	*io_addr_p = MMU_BYPASS_BASE | ra |
1728*27Sjchu 	    (pf_is_memory(pfn) ? 0 : MMU_BYPASS_NONCACHE);
17290Sstevel@tonic-gate 
17300Sstevel@tonic-gate 	return (H_EOK);
17310Sstevel@tonic-gate }
17320Sstevel@tonic-gate 
17330Sstevel@tonic-gate /*
17340Sstevel@tonic-gate  * Generic IO Interrupt Servies
17350Sstevel@tonic-gate  */
17360Sstevel@tonic-gate 
17370Sstevel@tonic-gate /*
17380Sstevel@tonic-gate  * Converts a device specific interrupt number given by the
17390Sstevel@tonic-gate  * arguments devhandle and devino into a system specific ino.
17400Sstevel@tonic-gate  */
17410Sstevel@tonic-gate /* ARGSUSED */
17420Sstevel@tonic-gate uint64_t
17430Sstevel@tonic-gate hvio_intr_devino_to_sysino(devhandle_t dev_hdl, pxu_t *pxu_p, devino_t devino,
17440Sstevel@tonic-gate     sysino_t *sysino)
17450Sstevel@tonic-gate {
17460Sstevel@tonic-gate 	if (devino > INTERRUPT_MAPPING_ENTRIES) {
17470Sstevel@tonic-gate 		DBG(DBG_IB, NULL, "ino %x is invalid\n", devino);
17480Sstevel@tonic-gate 		return (H_ENOINTR);
17490Sstevel@tonic-gate 	}
17500Sstevel@tonic-gate 
17510Sstevel@tonic-gate 	*sysino = DEVINO_TO_SYSINO(pxu_p->portid, devino);
17520Sstevel@tonic-gate 
17530Sstevel@tonic-gate 	return (H_EOK);
17540Sstevel@tonic-gate }
17550Sstevel@tonic-gate 
17560Sstevel@tonic-gate /*
17570Sstevel@tonic-gate  * Returns state in intr_valid_state if the interrupt defined by sysino
17580Sstevel@tonic-gate  * is valid (enabled) or not-valid (disabled).
17590Sstevel@tonic-gate  */
17600Sstevel@tonic-gate uint64_t
17610Sstevel@tonic-gate hvio_intr_getvalid(devhandle_t dev_hdl, sysino_t sysino,
17620Sstevel@tonic-gate     intr_valid_state_t *intr_valid_state)
17630Sstevel@tonic-gate {
17640Sstevel@tonic-gate 	if (CSRA_BR((caddr_t)dev_hdl, INTERRUPT_MAPPING,
17650Sstevel@tonic-gate 	    SYSINO_TO_DEVINO(sysino), ENTRIES_V)) {
17660Sstevel@tonic-gate 		*intr_valid_state = INTR_VALID;
17670Sstevel@tonic-gate 	} else {
17680Sstevel@tonic-gate 		*intr_valid_state = INTR_NOTVALID;
17690Sstevel@tonic-gate 	}
17700Sstevel@tonic-gate 
17710Sstevel@tonic-gate 	return (H_EOK);
17720Sstevel@tonic-gate }
17730Sstevel@tonic-gate 
17740Sstevel@tonic-gate /*
17750Sstevel@tonic-gate  * Sets the 'valid' state of the interrupt defined by
17760Sstevel@tonic-gate  * the argument sysino to the state defined by the
17770Sstevel@tonic-gate  * argument intr_valid_state.
17780Sstevel@tonic-gate  */
17790Sstevel@tonic-gate uint64_t
17800Sstevel@tonic-gate hvio_intr_setvalid(devhandle_t dev_hdl, sysino_t sysino,
17810Sstevel@tonic-gate     intr_valid_state_t intr_valid_state)
17820Sstevel@tonic-gate {
17830Sstevel@tonic-gate 	switch (intr_valid_state) {
17840Sstevel@tonic-gate 	case INTR_VALID:
17850Sstevel@tonic-gate 		CSRA_BS((caddr_t)dev_hdl, INTERRUPT_MAPPING,
17860Sstevel@tonic-gate 		    SYSINO_TO_DEVINO(sysino), ENTRIES_V);
17870Sstevel@tonic-gate 		break;
17880Sstevel@tonic-gate 	case INTR_NOTVALID:
17890Sstevel@tonic-gate 		CSRA_BC((caddr_t)dev_hdl, INTERRUPT_MAPPING,
17900Sstevel@tonic-gate 		    SYSINO_TO_DEVINO(sysino), ENTRIES_V);
17910Sstevel@tonic-gate 		break;
17920Sstevel@tonic-gate 	default:
17930Sstevel@tonic-gate 		return (EINVAL);
17940Sstevel@tonic-gate 	}
17950Sstevel@tonic-gate 
17960Sstevel@tonic-gate 	return (H_EOK);
17970Sstevel@tonic-gate }
17980Sstevel@tonic-gate 
17990Sstevel@tonic-gate /*
18000Sstevel@tonic-gate  * Returns the current state of the interrupt given by the sysino
18010Sstevel@tonic-gate  * argument.
18020Sstevel@tonic-gate  */
18030Sstevel@tonic-gate uint64_t
18040Sstevel@tonic-gate hvio_intr_getstate(devhandle_t dev_hdl, sysino_t sysino,
18050Sstevel@tonic-gate     intr_state_t *intr_state)
18060Sstevel@tonic-gate {
18070Sstevel@tonic-gate 	intr_state_t state;
18080Sstevel@tonic-gate 
18090Sstevel@tonic-gate 	state = CSRA_FR((caddr_t)dev_hdl, INTERRUPT_CLEAR,
18100Sstevel@tonic-gate 	    SYSINO_TO_DEVINO(sysino), ENTRIES_INT_STATE);
18110Sstevel@tonic-gate 
18120Sstevel@tonic-gate 	switch (state) {
18130Sstevel@tonic-gate 	case INTERRUPT_IDLE_STATE:
18140Sstevel@tonic-gate 		*intr_state = INTR_IDLE_STATE;
18150Sstevel@tonic-gate 		break;
18160Sstevel@tonic-gate 	case INTERRUPT_RECEIVED_STATE:
18170Sstevel@tonic-gate 		*intr_state = INTR_RECEIVED_STATE;
18180Sstevel@tonic-gate 		break;
18190Sstevel@tonic-gate 	case INTERRUPT_PENDING_STATE:
18200Sstevel@tonic-gate 		*intr_state = INTR_DELIVERED_STATE;
18210Sstevel@tonic-gate 		break;
18220Sstevel@tonic-gate 	default:
18230Sstevel@tonic-gate 		return (EINVAL);
18240Sstevel@tonic-gate 	}
18250Sstevel@tonic-gate 
18260Sstevel@tonic-gate 	return (H_EOK);
18270Sstevel@tonic-gate 
18280Sstevel@tonic-gate }
18290Sstevel@tonic-gate 
18300Sstevel@tonic-gate /*
18310Sstevel@tonic-gate  * Sets the current state of the interrupt given by the sysino
18320Sstevel@tonic-gate  * argument to the value given in the argument intr_state.
18330Sstevel@tonic-gate  *
18340Sstevel@tonic-gate  * Note: Setting the state to INTR_IDLE clears any pending
18350Sstevel@tonic-gate  * interrupt for sysino.
18360Sstevel@tonic-gate  */
18370Sstevel@tonic-gate uint64_t
18380Sstevel@tonic-gate hvio_intr_setstate(devhandle_t dev_hdl, sysino_t sysino,
18390Sstevel@tonic-gate     intr_state_t intr_state)
18400Sstevel@tonic-gate {
18410Sstevel@tonic-gate 	intr_state_t state;
18420Sstevel@tonic-gate 
18430Sstevel@tonic-gate 	switch (intr_state) {
18440Sstevel@tonic-gate 	case INTR_IDLE_STATE:
18450Sstevel@tonic-gate 		state = INTERRUPT_IDLE_STATE;
18460Sstevel@tonic-gate 		break;
18470Sstevel@tonic-gate 	case INTR_DELIVERED_STATE:
18480Sstevel@tonic-gate 		state = INTERRUPT_PENDING_STATE;
18490Sstevel@tonic-gate 		break;
18500Sstevel@tonic-gate 	default:
18510Sstevel@tonic-gate 		return (EINVAL);
18520Sstevel@tonic-gate 	}
18530Sstevel@tonic-gate 
18540Sstevel@tonic-gate 	CSRA_FS((caddr_t)dev_hdl, INTERRUPT_CLEAR,
18550Sstevel@tonic-gate 	    SYSINO_TO_DEVINO(sysino), ENTRIES_INT_STATE, state);
18560Sstevel@tonic-gate 
18570Sstevel@tonic-gate 	return (H_EOK);
18580Sstevel@tonic-gate }
18590Sstevel@tonic-gate 
18600Sstevel@tonic-gate /*
18610Sstevel@tonic-gate  * Returns the cpuid that is the current target of the
18620Sstevel@tonic-gate  * interrupt given by the sysino argument.
18630Sstevel@tonic-gate  *
18640Sstevel@tonic-gate  * The cpuid value returned is undefined if the target
18650Sstevel@tonic-gate  * has not been set via intr_settarget.
18660Sstevel@tonic-gate  */
18670Sstevel@tonic-gate uint64_t
18680Sstevel@tonic-gate hvio_intr_gettarget(devhandle_t dev_hdl, sysino_t sysino, cpuid_t *cpuid)
18690Sstevel@tonic-gate {
18700Sstevel@tonic-gate 	*cpuid = CSRA_FR((caddr_t)dev_hdl, INTERRUPT_MAPPING,
18710Sstevel@tonic-gate 	    SYSINO_TO_DEVINO(sysino), ENTRIES_T_JPID);
18720Sstevel@tonic-gate 
18730Sstevel@tonic-gate 	return (H_EOK);
18740Sstevel@tonic-gate }
18750Sstevel@tonic-gate 
18760Sstevel@tonic-gate /*
18770Sstevel@tonic-gate  * Set the target cpu for the interrupt defined by the argument
18780Sstevel@tonic-gate  * sysino to the target cpu value defined by the argument cpuid.
18790Sstevel@tonic-gate  */
18800Sstevel@tonic-gate uint64_t
18810Sstevel@tonic-gate hvio_intr_settarget(devhandle_t dev_hdl, sysino_t sysino, cpuid_t cpuid)
18820Sstevel@tonic-gate {
18830Sstevel@tonic-gate 
18840Sstevel@tonic-gate 	uint64_t	val, intr_controller;
18850Sstevel@tonic-gate 	uint32_t	ino = SYSINO_TO_DEVINO(sysino);
18860Sstevel@tonic-gate 
18870Sstevel@tonic-gate 	/*
18880Sstevel@tonic-gate 	 * For now, we assign interrupt controller in a round
18890Sstevel@tonic-gate 	 * robin fashion.  Later, we may need to come up with
18900Sstevel@tonic-gate 	 * a more efficient assignment algorithm.
18910Sstevel@tonic-gate 	 */
18920Sstevel@tonic-gate 	intr_controller = 0x1ull << (cpuid % 4);
18930Sstevel@tonic-gate 
18940Sstevel@tonic-gate 	val = (((cpuid & INTERRUPT_MAPPING_ENTRIES_T_JPID_MASK) <<
18950Sstevel@tonic-gate 	    INTERRUPT_MAPPING_ENTRIES_T_JPID) |
18960Sstevel@tonic-gate 	    ((intr_controller & INTERRUPT_MAPPING_ENTRIES_INT_CNTRL_NUM_MASK)
18970Sstevel@tonic-gate 	    << INTERRUPT_MAPPING_ENTRIES_INT_CNTRL_NUM));
18980Sstevel@tonic-gate 
18990Sstevel@tonic-gate 	/* For EQ interrupts, set DATA MONDO bit */
19000Sstevel@tonic-gate 	if ((ino >= PX_DEFAULT_MSIQ_1ST_DEVINO) &&
19010Sstevel@tonic-gate 	    (ino < (PX_DEFAULT_MSIQ_1ST_DEVINO + PX_DEFAULT_MSIQ_CNT)))
19020Sstevel@tonic-gate 		val |= (0x1ull << INTERRUPT_MAPPING_ENTRIES_MDO_MODE);
19030Sstevel@tonic-gate 
19040Sstevel@tonic-gate 	CSRA_XS((caddr_t)dev_hdl, INTERRUPT_MAPPING, ino, val);
19050Sstevel@tonic-gate 
19060Sstevel@tonic-gate 	return (H_EOK);
19070Sstevel@tonic-gate }
19080Sstevel@tonic-gate 
19090Sstevel@tonic-gate /*
19100Sstevel@tonic-gate  * MSIQ Functions:
19110Sstevel@tonic-gate  */
19120Sstevel@tonic-gate uint64_t
19130Sstevel@tonic-gate hvio_msiq_init(devhandle_t dev_hdl, pxu_t *pxu_p)
19140Sstevel@tonic-gate {
19150Sstevel@tonic-gate 	CSRA_XS((caddr_t)dev_hdl, EVENT_QUEUE_BASE_ADDRESS, 0,
19160Sstevel@tonic-gate 	    (uint64_t)pxu_p->msiq_mapped_p);
19170Sstevel@tonic-gate 	DBG(DBG_IB, NULL,
19180Sstevel@tonic-gate 	    "hvio_msiq_init: EVENT_QUEUE_BASE_ADDRESS 0x%llx\n",
19190Sstevel@tonic-gate 	    CSR_XR((caddr_t)dev_hdl, EVENT_QUEUE_BASE_ADDRESS));
19200Sstevel@tonic-gate 
19210Sstevel@tonic-gate 	CSRA_XS((caddr_t)dev_hdl, INTERRUPT_MONDO_DATA_0, 0,
19220Sstevel@tonic-gate 	    (uint64_t)ID_TO_IGN(pxu_p->portid) << INO_BITS);
19230Sstevel@tonic-gate 	DBG(DBG_IB, NULL, "hvio_msiq_init: "
19240Sstevel@tonic-gate 	    "INTERRUPT_MONDO_DATA_0: 0x%llx\n",
19250Sstevel@tonic-gate 	    CSR_XR((caddr_t)dev_hdl, INTERRUPT_MONDO_DATA_0));
19260Sstevel@tonic-gate 
19270Sstevel@tonic-gate 	return (H_EOK);
19280Sstevel@tonic-gate }
19290Sstevel@tonic-gate 
19300Sstevel@tonic-gate uint64_t
19310Sstevel@tonic-gate hvio_msiq_getvalid(devhandle_t dev_hdl, msiqid_t msiq_id,
19320Sstevel@tonic-gate     pci_msiq_valid_state_t *msiq_valid_state)
19330Sstevel@tonic-gate {
19340Sstevel@tonic-gate 	uint32_t	eq_state;
19350Sstevel@tonic-gate 	uint64_t	ret = H_EOK;
19360Sstevel@tonic-gate 
19370Sstevel@tonic-gate 	eq_state = CSRA_FR((caddr_t)dev_hdl, EVENT_QUEUE_STATE,
19380Sstevel@tonic-gate 	    msiq_id, ENTRIES_STATE);
19390Sstevel@tonic-gate 
19400Sstevel@tonic-gate 	switch (eq_state) {
19410Sstevel@tonic-gate 	case EQ_IDLE_STATE:
19420Sstevel@tonic-gate 		*msiq_valid_state = PCI_MSIQ_INVALID;
19430Sstevel@tonic-gate 		break;
19440Sstevel@tonic-gate 	case EQ_ACTIVE_STATE:
19450Sstevel@tonic-gate 	case EQ_ERROR_STATE:
19460Sstevel@tonic-gate 		*msiq_valid_state = PCI_MSIQ_VALID;
19470Sstevel@tonic-gate 		break;
19480Sstevel@tonic-gate 	default:
19490Sstevel@tonic-gate 		ret = H_EIO;
19500Sstevel@tonic-gate 		break;
19510Sstevel@tonic-gate 	}
19520Sstevel@tonic-gate 
19530Sstevel@tonic-gate 	return (ret);
19540Sstevel@tonic-gate }
19550Sstevel@tonic-gate 
19560Sstevel@tonic-gate uint64_t
19570Sstevel@tonic-gate hvio_msiq_setvalid(devhandle_t dev_hdl, msiqid_t msiq_id,
19580Sstevel@tonic-gate     pci_msiq_valid_state_t msiq_valid_state)
19590Sstevel@tonic-gate {
19600Sstevel@tonic-gate 	uint64_t	ret = H_EOK;
19610Sstevel@tonic-gate 
19620Sstevel@tonic-gate 	switch (msiq_valid_state) {
19630Sstevel@tonic-gate 	case PCI_MSIQ_INVALID:
19640Sstevel@tonic-gate 		CSRA_BS((caddr_t)dev_hdl, EVENT_QUEUE_CONTROL_CLEAR,
19650Sstevel@tonic-gate 		    msiq_id, ENTRIES_DIS);
19660Sstevel@tonic-gate 		break;
19670Sstevel@tonic-gate 	case PCI_MSIQ_VALID:
19680Sstevel@tonic-gate 		CSRA_BS((caddr_t)dev_hdl, EVENT_QUEUE_CONTROL_SET,
19690Sstevel@tonic-gate 		    msiq_id, ENTRIES_EN);
19700Sstevel@tonic-gate 		break;
19710Sstevel@tonic-gate 	default:
19720Sstevel@tonic-gate 		ret = H_EINVAL;
19730Sstevel@tonic-gate 		break;
19740Sstevel@tonic-gate 	}
19750Sstevel@tonic-gate 
19760Sstevel@tonic-gate 	return (ret);
19770Sstevel@tonic-gate }
19780Sstevel@tonic-gate 
19790Sstevel@tonic-gate uint64_t
19800Sstevel@tonic-gate hvio_msiq_getstate(devhandle_t dev_hdl, msiqid_t msiq_id,
19810Sstevel@tonic-gate     pci_msiq_state_t *msiq_state)
19820Sstevel@tonic-gate {
19830Sstevel@tonic-gate 	uint32_t	eq_state;
19840Sstevel@tonic-gate 	uint64_t	ret = H_EOK;
19850Sstevel@tonic-gate 
19860Sstevel@tonic-gate 	eq_state = CSRA_FR((caddr_t)dev_hdl, EVENT_QUEUE_STATE,
19870Sstevel@tonic-gate 	    msiq_id, ENTRIES_STATE);
19880Sstevel@tonic-gate 
19890Sstevel@tonic-gate 	switch (eq_state) {
19900Sstevel@tonic-gate 	case EQ_IDLE_STATE:
19910Sstevel@tonic-gate 	case EQ_ACTIVE_STATE:
19920Sstevel@tonic-gate 		*msiq_state = PCI_MSIQ_STATE_IDLE;
19930Sstevel@tonic-gate 		break;
19940Sstevel@tonic-gate 	case EQ_ERROR_STATE:
19950Sstevel@tonic-gate 		*msiq_state = PCI_MSIQ_STATE_ERROR;
19960Sstevel@tonic-gate 		break;
19970Sstevel@tonic-gate 	default:
19980Sstevel@tonic-gate 		ret = H_EIO;
19990Sstevel@tonic-gate 	}
20000Sstevel@tonic-gate 
20010Sstevel@tonic-gate 	return (ret);
20020Sstevel@tonic-gate }
20030Sstevel@tonic-gate 
20040Sstevel@tonic-gate uint64_t
20050Sstevel@tonic-gate hvio_msiq_setstate(devhandle_t dev_hdl, msiqid_t msiq_id,
20060Sstevel@tonic-gate     pci_msiq_state_t msiq_state)
20070Sstevel@tonic-gate {
20080Sstevel@tonic-gate 	uint32_t	eq_state;
20090Sstevel@tonic-gate 	uint64_t	ret = H_EOK;
20100Sstevel@tonic-gate 
20110Sstevel@tonic-gate 	eq_state = CSRA_FR((caddr_t)dev_hdl, EVENT_QUEUE_STATE,
20120Sstevel@tonic-gate 	    msiq_id, ENTRIES_STATE);
20130Sstevel@tonic-gate 
20140Sstevel@tonic-gate 	switch (eq_state) {
20150Sstevel@tonic-gate 	case EQ_IDLE_STATE:
20160Sstevel@tonic-gate 		if (msiq_state == PCI_MSIQ_STATE_ERROR)
20170Sstevel@tonic-gate 			ret = H_EIO;
20180Sstevel@tonic-gate 		break;
20190Sstevel@tonic-gate 	case EQ_ACTIVE_STATE:
20200Sstevel@tonic-gate 		if (msiq_state == PCI_MSIQ_STATE_ERROR)
20210Sstevel@tonic-gate 			CSRA_BS((caddr_t)dev_hdl, EVENT_QUEUE_CONTROL_SET,
20220Sstevel@tonic-gate 			    msiq_id, ENTRIES_ENOVERR);
20230Sstevel@tonic-gate 		else
20240Sstevel@tonic-gate 			ret = H_EIO;
20250Sstevel@tonic-gate 		break;
20260Sstevel@tonic-gate 	case EQ_ERROR_STATE:
20270Sstevel@tonic-gate 		if (msiq_state == PCI_MSIQ_STATE_IDLE)
20280Sstevel@tonic-gate 			CSRA_BS((caddr_t)dev_hdl, EVENT_QUEUE_CONTROL_CLEAR,
20290Sstevel@tonic-gate 			    msiq_id, ENTRIES_E2I);
20300Sstevel@tonic-gate 		else
20310Sstevel@tonic-gate 			ret = H_EIO;
20320Sstevel@tonic-gate 		break;
20330Sstevel@tonic-gate 	default:
20340Sstevel@tonic-gate 		ret = H_EIO;
20350Sstevel@tonic-gate 	}
20360Sstevel@tonic-gate 
20370Sstevel@tonic-gate 	return (ret);
20380Sstevel@tonic-gate }
20390Sstevel@tonic-gate 
20400Sstevel@tonic-gate uint64_t
20410Sstevel@tonic-gate hvio_msiq_gethead(devhandle_t dev_hdl, msiqid_t msiq_id,
20420Sstevel@tonic-gate     msiqhead_t *msiq_head)
20430Sstevel@tonic-gate {
20440Sstevel@tonic-gate 	*msiq_head = CSRA_FR((caddr_t)dev_hdl, EVENT_QUEUE_HEAD,
20450Sstevel@tonic-gate 	    msiq_id, ENTRIES_HEAD);
20460Sstevel@tonic-gate 
20470Sstevel@tonic-gate 	return (H_EOK);
20480Sstevel@tonic-gate }
20490Sstevel@tonic-gate 
20500Sstevel@tonic-gate uint64_t
20510Sstevel@tonic-gate hvio_msiq_sethead(devhandle_t dev_hdl, msiqid_t msiq_id,
20520Sstevel@tonic-gate     msiqhead_t msiq_head)
20530Sstevel@tonic-gate {
20540Sstevel@tonic-gate 	CSRA_FS((caddr_t)dev_hdl, EVENT_QUEUE_HEAD, msiq_id,
20550Sstevel@tonic-gate 	    ENTRIES_HEAD, msiq_head);
20560Sstevel@tonic-gate 
20570Sstevel@tonic-gate 	return (H_EOK);
20580Sstevel@tonic-gate }
20590Sstevel@tonic-gate 
20600Sstevel@tonic-gate uint64_t
20610Sstevel@tonic-gate hvio_msiq_gettail(devhandle_t dev_hdl, msiqid_t msiq_id,
20620Sstevel@tonic-gate     msiqtail_t *msiq_tail)
20630Sstevel@tonic-gate {
20640Sstevel@tonic-gate 	*msiq_tail = CSRA_FR((caddr_t)dev_hdl, EVENT_QUEUE_TAIL,
20650Sstevel@tonic-gate 	    msiq_id, ENTRIES_TAIL);
20660Sstevel@tonic-gate 
20670Sstevel@tonic-gate 	return (H_EOK);
20680Sstevel@tonic-gate }
20690Sstevel@tonic-gate 
20700Sstevel@tonic-gate /*
20710Sstevel@tonic-gate  * MSI Functions:
20720Sstevel@tonic-gate  */
20730Sstevel@tonic-gate uint64_t
20740Sstevel@tonic-gate hvio_msi_init(devhandle_t dev_hdl, uint64_t addr32, uint64_t addr64)
20750Sstevel@tonic-gate {
20760Sstevel@tonic-gate 	/* PCI MEM 32 resources to perform 32 bit MSI transactions */
20770Sstevel@tonic-gate 	CSRA_FS((caddr_t)dev_hdl, MSI_32_BIT_ADDRESS, 0,
20780Sstevel@tonic-gate 	    ADDR, (uint64_t)addr32 >> MSI_32_BIT_ADDRESS_ADDR);
20790Sstevel@tonic-gate 	DBG(DBG_IB, NULL, "hvio_msiq_init: MSI_32_BIT_ADDRESS: 0x%llx\n",
20800Sstevel@tonic-gate 	    CSR_XR((caddr_t)dev_hdl, MSI_32_BIT_ADDRESS));
20810Sstevel@tonic-gate 
20820Sstevel@tonic-gate 	/* Reserve PCI MEM 64 resources to perform 64 bit MSI transactions */
20830Sstevel@tonic-gate 	CSRA_FS((caddr_t)dev_hdl, MSI_64_BIT_ADDRESS, 0,
20840Sstevel@tonic-gate 	    ADDR, (uint64_t)addr64 >> MSI_64_BIT_ADDRESS_ADDR);
20850Sstevel@tonic-gate 	DBG(DBG_IB, NULL, "hvio_msiq_init: MSI_64_BIT_ADDRESS: 0x%llx\n",
20860Sstevel@tonic-gate 	    CSR_XR((caddr_t)dev_hdl, MSI_64_BIT_ADDRESS));
20870Sstevel@tonic-gate 
20880Sstevel@tonic-gate 	return (H_EOK);
20890Sstevel@tonic-gate }
20900Sstevel@tonic-gate 
20910Sstevel@tonic-gate uint64_t
20920Sstevel@tonic-gate hvio_msi_getmsiq(devhandle_t dev_hdl, msinum_t msi_num,
20930Sstevel@tonic-gate     msiqid_t *msiq_id)
20940Sstevel@tonic-gate {
20950Sstevel@tonic-gate 	*msiq_id = CSRA_FR((caddr_t)dev_hdl, MSI_MAPPING,
20960Sstevel@tonic-gate 	    msi_num, ENTRIES_EQNUM);
20970Sstevel@tonic-gate 
20980Sstevel@tonic-gate 	return (H_EOK);
20990Sstevel@tonic-gate }
21000Sstevel@tonic-gate 
21010Sstevel@tonic-gate uint64_t
21020Sstevel@tonic-gate hvio_msi_setmsiq(devhandle_t dev_hdl, msinum_t msi_num,
21030Sstevel@tonic-gate     msiqid_t msiq_id)
21040Sstevel@tonic-gate {
21050Sstevel@tonic-gate 	CSRA_FS((caddr_t)dev_hdl, MSI_MAPPING, msi_num,
21060Sstevel@tonic-gate 	    ENTRIES_EQNUM, msiq_id);
21070Sstevel@tonic-gate 
21080Sstevel@tonic-gate 	return (H_EOK);
21090Sstevel@tonic-gate }
21100Sstevel@tonic-gate 
21110Sstevel@tonic-gate uint64_t
21120Sstevel@tonic-gate hvio_msi_getvalid(devhandle_t dev_hdl, msinum_t msi_num,
21130Sstevel@tonic-gate     pci_msi_valid_state_t *msi_valid_state)
21140Sstevel@tonic-gate {
21150Sstevel@tonic-gate 	*msi_valid_state = CSRA_BR((caddr_t)dev_hdl, MSI_MAPPING,
21160Sstevel@tonic-gate 	    msi_num, ENTRIES_V);
21170Sstevel@tonic-gate 
21180Sstevel@tonic-gate 	return (H_EOK);
21190Sstevel@tonic-gate }
21200Sstevel@tonic-gate 
21210Sstevel@tonic-gate uint64_t
21220Sstevel@tonic-gate hvio_msi_setvalid(devhandle_t dev_hdl, msinum_t msi_num,
21230Sstevel@tonic-gate     pci_msi_valid_state_t msi_valid_state)
21240Sstevel@tonic-gate {
21250Sstevel@tonic-gate 	uint64_t	ret = H_EOK;
21260Sstevel@tonic-gate 
21270Sstevel@tonic-gate 	switch (msi_valid_state) {
21280Sstevel@tonic-gate 	case PCI_MSI_VALID:
21290Sstevel@tonic-gate 		CSRA_BS((caddr_t)dev_hdl, MSI_MAPPING, msi_num,
21300Sstevel@tonic-gate 		    ENTRIES_V);
21310Sstevel@tonic-gate 		break;
21320Sstevel@tonic-gate 	case PCI_MSI_INVALID:
21330Sstevel@tonic-gate 		CSRA_BC((caddr_t)dev_hdl, MSI_MAPPING, msi_num,
21340Sstevel@tonic-gate 		    ENTRIES_V);
21350Sstevel@tonic-gate 		break;
21360Sstevel@tonic-gate 	default:
21370Sstevel@tonic-gate 		ret = H_EINVAL;
21380Sstevel@tonic-gate 	}
21390Sstevel@tonic-gate 
21400Sstevel@tonic-gate 	return (ret);
21410Sstevel@tonic-gate }
21420Sstevel@tonic-gate 
21430Sstevel@tonic-gate uint64_t
21440Sstevel@tonic-gate hvio_msi_getstate(devhandle_t dev_hdl, msinum_t msi_num,
21450Sstevel@tonic-gate     pci_msi_state_t *msi_state)
21460Sstevel@tonic-gate {
21470Sstevel@tonic-gate 	*msi_state = CSRA_BR((caddr_t)dev_hdl, MSI_MAPPING,
21480Sstevel@tonic-gate 	    msi_num, ENTRIES_EQWR_N);
21490Sstevel@tonic-gate 
21500Sstevel@tonic-gate 	return (H_EOK);
21510Sstevel@tonic-gate }
21520Sstevel@tonic-gate 
21530Sstevel@tonic-gate uint64_t
21540Sstevel@tonic-gate hvio_msi_setstate(devhandle_t dev_hdl, msinum_t msi_num,
21550Sstevel@tonic-gate     pci_msi_state_t msi_state)
21560Sstevel@tonic-gate {
21570Sstevel@tonic-gate 	uint64_t	ret = H_EOK;
21580Sstevel@tonic-gate 
21590Sstevel@tonic-gate 	switch (msi_state) {
21600Sstevel@tonic-gate 	case PCI_MSI_STATE_IDLE:
21610Sstevel@tonic-gate 		CSRA_BS((caddr_t)dev_hdl, MSI_CLEAR, msi_num,
21620Sstevel@tonic-gate 		    ENTRIES_EQWR_N);
21630Sstevel@tonic-gate 		break;
21640Sstevel@tonic-gate 	case PCI_MSI_STATE_DELIVERED:
21650Sstevel@tonic-gate 	default:
21660Sstevel@tonic-gate 		ret = H_EINVAL;
21670Sstevel@tonic-gate 		break;
21680Sstevel@tonic-gate 	}
21690Sstevel@tonic-gate 
21700Sstevel@tonic-gate 	return (ret);
21710Sstevel@tonic-gate }
21720Sstevel@tonic-gate 
21730Sstevel@tonic-gate /*
21740Sstevel@tonic-gate  * MSG Functions:
21750Sstevel@tonic-gate  */
21760Sstevel@tonic-gate uint64_t
21770Sstevel@tonic-gate hvio_msg_getmsiq(devhandle_t dev_hdl, pcie_msg_type_t msg_type,
21780Sstevel@tonic-gate     msiqid_t *msiq_id)
21790Sstevel@tonic-gate {
21800Sstevel@tonic-gate 	uint64_t	ret = H_EOK;
21810Sstevel@tonic-gate 
21820Sstevel@tonic-gate 	switch (msg_type) {
21830Sstevel@tonic-gate 	case PCIE_PME_MSG:
21840Sstevel@tonic-gate 		*msiq_id = CSR_FR((caddr_t)dev_hdl, PM_PME_MAPPING, EQNUM);
21850Sstevel@tonic-gate 		break;
21860Sstevel@tonic-gate 	case PCIE_PME_ACK_MSG:
21870Sstevel@tonic-gate 		*msiq_id = CSR_FR((caddr_t)dev_hdl, PME_TO_ACK_MAPPING,
21880Sstevel@tonic-gate 		    EQNUM);
21890Sstevel@tonic-gate 		break;
21900Sstevel@tonic-gate 	case PCIE_CORR_MSG:
21910Sstevel@tonic-gate 		*msiq_id = CSR_FR((caddr_t)dev_hdl, ERR_COR_MAPPING, EQNUM);
21920Sstevel@tonic-gate 		break;
21930Sstevel@tonic-gate 	case PCIE_NONFATAL_MSG:
21940Sstevel@tonic-gate 		*msiq_id = CSR_FR((caddr_t)dev_hdl, ERR_NONFATAL_MAPPING,
21950Sstevel@tonic-gate 		    EQNUM);
21960Sstevel@tonic-gate 		break;
21970Sstevel@tonic-gate 	case PCIE_FATAL_MSG:
21980Sstevel@tonic-gate 		*msiq_id = CSR_FR((caddr_t)dev_hdl, ERR_FATAL_MAPPING, EQNUM);
21990Sstevel@tonic-gate 		break;
22000Sstevel@tonic-gate 	default:
22010Sstevel@tonic-gate 		ret = H_EINVAL;
22020Sstevel@tonic-gate 		break;
22030Sstevel@tonic-gate 	}
22040Sstevel@tonic-gate 
22050Sstevel@tonic-gate 	return (ret);
22060Sstevel@tonic-gate }
22070Sstevel@tonic-gate 
22080Sstevel@tonic-gate uint64_t
22090Sstevel@tonic-gate hvio_msg_setmsiq(devhandle_t dev_hdl, pcie_msg_type_t msg_type,
22100Sstevel@tonic-gate     msiqid_t msiq_id)
22110Sstevel@tonic-gate {
22120Sstevel@tonic-gate 	uint64_t	ret = H_EOK;
22130Sstevel@tonic-gate 
22140Sstevel@tonic-gate 	switch (msg_type) {
22150Sstevel@tonic-gate 	case PCIE_PME_MSG:
22160Sstevel@tonic-gate 		CSR_FS((caddr_t)dev_hdl, PM_PME_MAPPING, EQNUM, msiq_id);
22170Sstevel@tonic-gate 		break;
22180Sstevel@tonic-gate 	case PCIE_PME_ACK_MSG:
22190Sstevel@tonic-gate 		CSR_FS((caddr_t)dev_hdl, PME_TO_ACK_MAPPING, EQNUM, msiq_id);
22200Sstevel@tonic-gate 		break;
22210Sstevel@tonic-gate 	case PCIE_CORR_MSG:
22220Sstevel@tonic-gate 		CSR_FS((caddr_t)dev_hdl, ERR_COR_MAPPING, EQNUM, msiq_id);
22230Sstevel@tonic-gate 		break;
22240Sstevel@tonic-gate 	case PCIE_NONFATAL_MSG:
22250Sstevel@tonic-gate 		CSR_FS((caddr_t)dev_hdl, ERR_NONFATAL_MAPPING, EQNUM, msiq_id);
22260Sstevel@tonic-gate 		break;
22270Sstevel@tonic-gate 	case PCIE_FATAL_MSG:
22280Sstevel@tonic-gate 		CSR_FS((caddr_t)dev_hdl, ERR_FATAL_MAPPING, EQNUM, msiq_id);
22290Sstevel@tonic-gate 		break;
22300Sstevel@tonic-gate 	default:
22310Sstevel@tonic-gate 		ret = H_EINVAL;
22320Sstevel@tonic-gate 		break;
22330Sstevel@tonic-gate 	}
22340Sstevel@tonic-gate 
22350Sstevel@tonic-gate 	return (ret);
22360Sstevel@tonic-gate }
22370Sstevel@tonic-gate 
22380Sstevel@tonic-gate uint64_t
22390Sstevel@tonic-gate hvio_msg_getvalid(devhandle_t dev_hdl, pcie_msg_type_t msg_type,
22400Sstevel@tonic-gate     pcie_msg_valid_state_t *msg_valid_state)
22410Sstevel@tonic-gate {
22420Sstevel@tonic-gate 	uint64_t	ret = H_EOK;
22430Sstevel@tonic-gate 
22440Sstevel@tonic-gate 	switch (msg_type) {
22450Sstevel@tonic-gate 	case PCIE_PME_MSG:
22460Sstevel@tonic-gate 		*msg_valid_state = CSR_BR((caddr_t)dev_hdl, PM_PME_MAPPING, V);
22470Sstevel@tonic-gate 		break;
22480Sstevel@tonic-gate 	case PCIE_PME_ACK_MSG:
22490Sstevel@tonic-gate 		*msg_valid_state = CSR_BR((caddr_t)dev_hdl,
22500Sstevel@tonic-gate 		    PME_TO_ACK_MAPPING, V);
22510Sstevel@tonic-gate 		break;
22520Sstevel@tonic-gate 	case PCIE_CORR_MSG:
22530Sstevel@tonic-gate 		*msg_valid_state = CSR_BR((caddr_t)dev_hdl, ERR_COR_MAPPING, V);
22540Sstevel@tonic-gate 		break;
22550Sstevel@tonic-gate 	case PCIE_NONFATAL_MSG:
22560Sstevel@tonic-gate 		*msg_valid_state = CSR_BR((caddr_t)dev_hdl,
22570Sstevel@tonic-gate 		    ERR_NONFATAL_MAPPING, V);
22580Sstevel@tonic-gate 		break;
22590Sstevel@tonic-gate 	case PCIE_FATAL_MSG:
22600Sstevel@tonic-gate 		*msg_valid_state = CSR_BR((caddr_t)dev_hdl, ERR_FATAL_MAPPING,
22610Sstevel@tonic-gate 		    V);
22620Sstevel@tonic-gate 		break;
22630Sstevel@tonic-gate 	default:
22640Sstevel@tonic-gate 		ret = H_EINVAL;
22650Sstevel@tonic-gate 		break;
22660Sstevel@tonic-gate 	}
22670Sstevel@tonic-gate 
22680Sstevel@tonic-gate 	return (ret);
22690Sstevel@tonic-gate }
22700Sstevel@tonic-gate 
22710Sstevel@tonic-gate uint64_t
22720Sstevel@tonic-gate hvio_msg_setvalid(devhandle_t dev_hdl, pcie_msg_type_t msg_type,
22730Sstevel@tonic-gate     pcie_msg_valid_state_t msg_valid_state)
22740Sstevel@tonic-gate {
22750Sstevel@tonic-gate 	uint64_t	ret = H_EOK;
22760Sstevel@tonic-gate 
22770Sstevel@tonic-gate 	switch (msg_valid_state) {
22780Sstevel@tonic-gate 	case PCIE_MSG_VALID:
22790Sstevel@tonic-gate 		switch (msg_type) {
22800Sstevel@tonic-gate 		case PCIE_PME_MSG:
22810Sstevel@tonic-gate 			CSR_BS((caddr_t)dev_hdl, PM_PME_MAPPING, V);
22820Sstevel@tonic-gate 			break;
22830Sstevel@tonic-gate 		case PCIE_PME_ACK_MSG:
22840Sstevel@tonic-gate 			CSR_BS((caddr_t)dev_hdl, PME_TO_ACK_MAPPING, V);
22850Sstevel@tonic-gate 			break;
22860Sstevel@tonic-gate 		case PCIE_CORR_MSG:
22870Sstevel@tonic-gate 			CSR_BS((caddr_t)dev_hdl, ERR_COR_MAPPING, V);
22880Sstevel@tonic-gate 			break;
22890Sstevel@tonic-gate 		case PCIE_NONFATAL_MSG:
22900Sstevel@tonic-gate 			CSR_BS((caddr_t)dev_hdl, ERR_NONFATAL_MAPPING, V);
22910Sstevel@tonic-gate 			break;
22920Sstevel@tonic-gate 		case PCIE_FATAL_MSG:
22930Sstevel@tonic-gate 			CSR_BS((caddr_t)dev_hdl, ERR_FATAL_MAPPING, V);
22940Sstevel@tonic-gate 			break;
22950Sstevel@tonic-gate 		default:
22960Sstevel@tonic-gate 			ret = H_EINVAL;
22970Sstevel@tonic-gate 			break;
22980Sstevel@tonic-gate 		}
22990Sstevel@tonic-gate 
23000Sstevel@tonic-gate 		break;
23010Sstevel@tonic-gate 	case PCIE_MSG_INVALID:
23020Sstevel@tonic-gate 		switch (msg_type) {
23030Sstevel@tonic-gate 		case PCIE_PME_MSG:
23040Sstevel@tonic-gate 			CSR_BC((caddr_t)dev_hdl, PM_PME_MAPPING, V);
23050Sstevel@tonic-gate 			break;
23060Sstevel@tonic-gate 		case PCIE_PME_ACK_MSG:
23070Sstevel@tonic-gate 			CSR_BC((caddr_t)dev_hdl, PME_TO_ACK_MAPPING, V);
23080Sstevel@tonic-gate 			break;
23090Sstevel@tonic-gate 		case PCIE_CORR_MSG:
23100Sstevel@tonic-gate 			CSR_BC((caddr_t)dev_hdl, ERR_COR_MAPPING, V);
23110Sstevel@tonic-gate 			break;
23120Sstevel@tonic-gate 		case PCIE_NONFATAL_MSG:
23130Sstevel@tonic-gate 			CSR_BC((caddr_t)dev_hdl, ERR_NONFATAL_MAPPING, V);
23140Sstevel@tonic-gate 			break;
23150Sstevel@tonic-gate 		case PCIE_FATAL_MSG:
23160Sstevel@tonic-gate 			CSR_BC((caddr_t)dev_hdl, ERR_FATAL_MAPPING, V);
23170Sstevel@tonic-gate 			break;
23180Sstevel@tonic-gate 		default:
23190Sstevel@tonic-gate 			ret = H_EINVAL;
23200Sstevel@tonic-gate 			break;
23210Sstevel@tonic-gate 		}
23220Sstevel@tonic-gate 		break;
23230Sstevel@tonic-gate 	default:
23240Sstevel@tonic-gate 		ret = H_EINVAL;
23250Sstevel@tonic-gate 	}
23260Sstevel@tonic-gate 
23270Sstevel@tonic-gate 	return (ret);
23280Sstevel@tonic-gate }
23290Sstevel@tonic-gate 
23300Sstevel@tonic-gate /*
23310Sstevel@tonic-gate  * Suspend/Resume Functions:
23320Sstevel@tonic-gate  *	(pec, mmu, ib)
23330Sstevel@tonic-gate  *	cb
23340Sstevel@tonic-gate  * Registers saved have all been touched in the XXX_init functions.
23350Sstevel@tonic-gate  */
23360Sstevel@tonic-gate uint64_t
23370Sstevel@tonic-gate hvio_suspend(devhandle_t dev_hdl, pxu_t *pxu_p)
23380Sstevel@tonic-gate {
23390Sstevel@tonic-gate 	uint64_t	*config_state;
23400Sstevel@tonic-gate 	int		total_size;
23410Sstevel@tonic-gate 	int		i;
23420Sstevel@tonic-gate 
23430Sstevel@tonic-gate 	if (msiq_suspend(dev_hdl, pxu_p) != H_EOK)
23440Sstevel@tonic-gate 		return (H_EIO);
23450Sstevel@tonic-gate 
23460Sstevel@tonic-gate 	total_size = PEC_SIZE + MMU_SIZE + IB_SIZE + IB_MAP_SIZE;
23470Sstevel@tonic-gate 	config_state = kmem_zalloc(total_size, KM_NOSLEEP);
23480Sstevel@tonic-gate 
23490Sstevel@tonic-gate 	if (config_state == NULL) {
23500Sstevel@tonic-gate 		return (H_EIO);
23510Sstevel@tonic-gate 	}
23520Sstevel@tonic-gate 
23530Sstevel@tonic-gate 	/*
23540Sstevel@tonic-gate 	 * Soft state for suspend/resume  from pxu_t
23550Sstevel@tonic-gate 	 * uint64_t	*pec_config_state;
23560Sstevel@tonic-gate 	 * uint64_t	*mmu_config_state;
23570Sstevel@tonic-gate 	 * uint64_t	*ib_intr_map;
23580Sstevel@tonic-gate 	 * uint64_t	*ib_config_state;
23590Sstevel@tonic-gate 	 * uint64_t	*xcb_config_state;
23600Sstevel@tonic-gate 	 */
23610Sstevel@tonic-gate 
23620Sstevel@tonic-gate 	/* Save the PEC configuration states */
23630Sstevel@tonic-gate 	pxu_p->pec_config_state = config_state;
23640Sstevel@tonic-gate 	for (i = 0; i < PEC_KEYS; i++) {
23650Sstevel@tonic-gate 		pxu_p->pec_config_state[i] =
23660Sstevel@tonic-gate 		    CSR_XR((caddr_t)dev_hdl, pec_config_state_regs[i]);
23670Sstevel@tonic-gate 	}
23680Sstevel@tonic-gate 
23690Sstevel@tonic-gate 	/* Save the MMU configuration states */
23700Sstevel@tonic-gate 	pxu_p->mmu_config_state = pxu_p->pec_config_state + PEC_KEYS;
23710Sstevel@tonic-gate 	for (i = 0; i < MMU_KEYS; i++) {
23720Sstevel@tonic-gate 		pxu_p->mmu_config_state[i] =
23730Sstevel@tonic-gate 		    CSR_XR((caddr_t)dev_hdl, mmu_config_state_regs[i]);
23740Sstevel@tonic-gate 	}
23750Sstevel@tonic-gate 
23760Sstevel@tonic-gate 	/* Save the interrupt mapping registers */
23770Sstevel@tonic-gate 	pxu_p->ib_intr_map = pxu_p->mmu_config_state + MMU_KEYS;
23780Sstevel@tonic-gate 	for (i = 0; i < INTERRUPT_MAPPING_ENTRIES; i++) {
23790Sstevel@tonic-gate 		pxu_p->ib_intr_map[i] =
23800Sstevel@tonic-gate 		    CSRA_XR((caddr_t)dev_hdl, INTERRUPT_MAPPING, i);
23810Sstevel@tonic-gate 	}
23820Sstevel@tonic-gate 
23830Sstevel@tonic-gate 	/* Save the IB configuration states */
23840Sstevel@tonic-gate 	pxu_p->ib_config_state = pxu_p->ib_intr_map + INTERRUPT_MAPPING_ENTRIES;
23850Sstevel@tonic-gate 	for (i = 0; i < IB_KEYS; i++) {
23860Sstevel@tonic-gate 		pxu_p->ib_config_state[i] =
23870Sstevel@tonic-gate 		    CSR_XR((caddr_t)dev_hdl, ib_config_state_regs[i]);
23880Sstevel@tonic-gate 	}
23890Sstevel@tonic-gate 
23900Sstevel@tonic-gate 	return (H_EOK);
23910Sstevel@tonic-gate }
23920Sstevel@tonic-gate 
23930Sstevel@tonic-gate void
23940Sstevel@tonic-gate hvio_resume(devhandle_t dev_hdl, devino_t devino, pxu_t *pxu_p)
23950Sstevel@tonic-gate {
23960Sstevel@tonic-gate 	int		total_size;
23970Sstevel@tonic-gate 	sysino_t	sysino;
23980Sstevel@tonic-gate 	int		i;
23990Sstevel@tonic-gate 
24000Sstevel@tonic-gate 	/* Make sure that suspend actually did occur */
24010Sstevel@tonic-gate 	if (!pxu_p->pec_config_state) {
24020Sstevel@tonic-gate 		return;
24030Sstevel@tonic-gate 	}
24040Sstevel@tonic-gate 
24050Sstevel@tonic-gate 	/* Restore IB configuration states */
24060Sstevel@tonic-gate 	for (i = 0; i < IB_KEYS; i++) {
24070Sstevel@tonic-gate 		CSR_XS((caddr_t)dev_hdl, ib_config_state_regs[i],
24080Sstevel@tonic-gate 		    pxu_p->ib_config_state[i]);
24090Sstevel@tonic-gate 	}
24100Sstevel@tonic-gate 
24110Sstevel@tonic-gate 	/*
24120Sstevel@tonic-gate 	 * Restore the interrupt mapping registers
24130Sstevel@tonic-gate 	 * And make sure the intrs are idle.
24140Sstevel@tonic-gate 	 */
24150Sstevel@tonic-gate 	for (i = 0; i < INTERRUPT_MAPPING_ENTRIES; i++) {
24160Sstevel@tonic-gate 		CSRA_FS((caddr_t)dev_hdl, INTERRUPT_CLEAR, i,
24170Sstevel@tonic-gate 		    ENTRIES_INT_STATE, INTERRUPT_IDLE_STATE);
24180Sstevel@tonic-gate 		CSRA_XS((caddr_t)dev_hdl, INTERRUPT_MAPPING, i,
24190Sstevel@tonic-gate 		    pxu_p->ib_intr_map[i]);
24200Sstevel@tonic-gate 	}
24210Sstevel@tonic-gate 
24220Sstevel@tonic-gate 	/* Restore MMU configuration states */
24230Sstevel@tonic-gate 	/* Clear the cache. */
24240Sstevel@tonic-gate 	CSR_XS((caddr_t)dev_hdl, MMU_TTE_CACHE_INVALIDATE, -1ull);
24250Sstevel@tonic-gate 
24260Sstevel@tonic-gate 	for (i = 0; i < MMU_KEYS; i++) {
24270Sstevel@tonic-gate 		CSR_XS((caddr_t)dev_hdl, mmu_config_state_regs[i],
24280Sstevel@tonic-gate 		    pxu_p->mmu_config_state[i]);
24290Sstevel@tonic-gate 	}
24300Sstevel@tonic-gate 
24310Sstevel@tonic-gate 	/* Restore PEC configuration states */
24320Sstevel@tonic-gate 	/* Make sure all reset bits are low until error is detected */
24330Sstevel@tonic-gate 	CSR_XS((caddr_t)dev_hdl, LPU_RESET, 0ull);
24340Sstevel@tonic-gate 
24350Sstevel@tonic-gate 	for (i = 0; i < PEC_KEYS; i++) {
24360Sstevel@tonic-gate 		CSR_XS((caddr_t)dev_hdl, pec_config_state_regs[i],
24370Sstevel@tonic-gate 		    pxu_p->pec_config_state[i]);
24380Sstevel@tonic-gate 	}
24390Sstevel@tonic-gate 
24400Sstevel@tonic-gate 	/* Enable PCI-E interrupt */
24410Sstevel@tonic-gate 	(void) hvio_intr_devino_to_sysino(dev_hdl, pxu_p, devino, &sysino);
24420Sstevel@tonic-gate 
24430Sstevel@tonic-gate 	(void) hvio_intr_setstate(dev_hdl, sysino, INTR_IDLE_STATE);
24440Sstevel@tonic-gate 
24450Sstevel@tonic-gate 	total_size = PEC_SIZE + MMU_SIZE + IB_SIZE + IB_MAP_SIZE;
24460Sstevel@tonic-gate 	kmem_free(pxu_p->pec_config_state, total_size);
24470Sstevel@tonic-gate 
24480Sstevel@tonic-gate 	pxu_p->pec_config_state = NULL;
24490Sstevel@tonic-gate 	pxu_p->mmu_config_state = NULL;
24500Sstevel@tonic-gate 	pxu_p->ib_config_state = NULL;
24510Sstevel@tonic-gate 	pxu_p->ib_intr_map = NULL;
24520Sstevel@tonic-gate 
24530Sstevel@tonic-gate 	msiq_resume(dev_hdl, pxu_p);
24540Sstevel@tonic-gate }
24550Sstevel@tonic-gate 
24560Sstevel@tonic-gate uint64_t
24570Sstevel@tonic-gate hvio_cb_suspend(devhandle_t dev_hdl, pxu_t *pxu_p)
24580Sstevel@tonic-gate {
24590Sstevel@tonic-gate 	uint64_t	*config_state;
24600Sstevel@tonic-gate 	int		i;
24610Sstevel@tonic-gate 
24620Sstevel@tonic-gate 	config_state = kmem_zalloc(CB_SIZE, KM_NOSLEEP);
24630Sstevel@tonic-gate 
24640Sstevel@tonic-gate 	if (config_state == NULL) {
24650Sstevel@tonic-gate 		return (H_EIO);
24660Sstevel@tonic-gate 	}
24670Sstevel@tonic-gate 
24680Sstevel@tonic-gate 	/* Save the configuration states */
24690Sstevel@tonic-gate 	pxu_p->xcb_config_state = config_state;
24700Sstevel@tonic-gate 	for (i = 0; i < CB_KEYS; i++) {
24710Sstevel@tonic-gate 		pxu_p->xcb_config_state[i] =
24720Sstevel@tonic-gate 		    CSR_XR((caddr_t)dev_hdl, cb_config_state_regs[i]);
24730Sstevel@tonic-gate 	}
24740Sstevel@tonic-gate 
24750Sstevel@tonic-gate 	return (H_EOK);
24760Sstevel@tonic-gate }
24770Sstevel@tonic-gate 
24780Sstevel@tonic-gate void
24790Sstevel@tonic-gate hvio_cb_resume(devhandle_t pci_dev_hdl, devhandle_t xbus_dev_hdl,
24800Sstevel@tonic-gate     devino_t devino, pxu_t *pxu_p)
24810Sstevel@tonic-gate {
24820Sstevel@tonic-gate 	sysino_t	sysino;
24830Sstevel@tonic-gate 	int		i;
24840Sstevel@tonic-gate 
24850Sstevel@tonic-gate 	/*
24860Sstevel@tonic-gate 	 * No reason to have any reset bits high until an error is
24870Sstevel@tonic-gate 	 * detected on the link.
24880Sstevel@tonic-gate 	 */
24890Sstevel@tonic-gate 	CSR_XS((caddr_t)xbus_dev_hdl, JBC_ERROR_STATUS_CLEAR, -1ull);
24900Sstevel@tonic-gate 
24910Sstevel@tonic-gate 	ASSERT(pxu_p->xcb_config_state);
24920Sstevel@tonic-gate 
24930Sstevel@tonic-gate 	/* Restore the configuration states */
24940Sstevel@tonic-gate 	for (i = 0; i < CB_KEYS; i++) {
24950Sstevel@tonic-gate 		CSR_XS((caddr_t)xbus_dev_hdl, cb_config_state_regs[i],
24960Sstevel@tonic-gate 		    pxu_p->xcb_config_state[i]);
24970Sstevel@tonic-gate 	}
24980Sstevel@tonic-gate 
24990Sstevel@tonic-gate 	/* Enable XBC interrupt */
25000Sstevel@tonic-gate 	(void) hvio_intr_devino_to_sysino(pci_dev_hdl, pxu_p, devino, &sysino);
25010Sstevel@tonic-gate 
25020Sstevel@tonic-gate 	(void) hvio_intr_setstate(pci_dev_hdl, sysino, INTR_IDLE_STATE);
25030Sstevel@tonic-gate 
25040Sstevel@tonic-gate 	kmem_free(pxu_p->xcb_config_state, CB_SIZE);
25050Sstevel@tonic-gate 
25060Sstevel@tonic-gate 	pxu_p->xcb_config_state = NULL;
25070Sstevel@tonic-gate }
25080Sstevel@tonic-gate 
25090Sstevel@tonic-gate static uint64_t
25100Sstevel@tonic-gate msiq_suspend(devhandle_t dev_hdl, pxu_t *pxu_p)
25110Sstevel@tonic-gate {
25120Sstevel@tonic-gate 	size_t	bufsz;
25130Sstevel@tonic-gate 	volatile uint64_t *cur_p;
25140Sstevel@tonic-gate 	int i;
25150Sstevel@tonic-gate 
25160Sstevel@tonic-gate 	bufsz = MSIQ_STATE_SIZE + MSIQ_MAPPING_SIZE + MSIQ_OTHER_SIZE;
25170Sstevel@tonic-gate 	if ((pxu_p->msiq_config_state = kmem_zalloc(bufsz, KM_NOSLEEP)) ==
25180Sstevel@tonic-gate 	    NULL)
25190Sstevel@tonic-gate 		return (H_EIO);
25200Sstevel@tonic-gate 
25210Sstevel@tonic-gate 	cur_p = pxu_p->msiq_config_state;
25220Sstevel@tonic-gate 
25230Sstevel@tonic-gate 	/* Save each EQ state */
25240Sstevel@tonic-gate 	for (i = 0; i < EVENT_QUEUE_STATE_ENTRIES; i++, cur_p++)
25250Sstevel@tonic-gate 		*cur_p = CSRA_XR((caddr_t)dev_hdl, EVENT_QUEUE_STATE, i);
25260Sstevel@tonic-gate 
25270Sstevel@tonic-gate 	/* Save MSI mapping registers */
25280Sstevel@tonic-gate 	for (i = 0; i < MSI_MAPPING_ENTRIES; i++, cur_p++)
25290Sstevel@tonic-gate 		*cur_p = CSRA_XR((caddr_t)dev_hdl, MSI_MAPPING, i);
25300Sstevel@tonic-gate 
25310Sstevel@tonic-gate 	/* Save all other MSIQ registers */
25320Sstevel@tonic-gate 	for (i = 0; i < MSIQ_OTHER_KEYS; i++, cur_p++)
25330Sstevel@tonic-gate 		*cur_p = CSR_XR((caddr_t)dev_hdl, msiq_config_other_regs[i]);
25340Sstevel@tonic-gate 	return (H_EOK);
25350Sstevel@tonic-gate }
25360Sstevel@tonic-gate 
25370Sstevel@tonic-gate static void
25380Sstevel@tonic-gate msiq_resume(devhandle_t dev_hdl, pxu_t *pxu_p)
25390Sstevel@tonic-gate {
25400Sstevel@tonic-gate 	size_t	bufsz;
25410Sstevel@tonic-gate 	uint64_t *cur_p;
25420Sstevel@tonic-gate 	int i;
25430Sstevel@tonic-gate 
25440Sstevel@tonic-gate 	bufsz = MSIQ_STATE_SIZE + MSIQ_MAPPING_SIZE + MSIQ_OTHER_SIZE;
25450Sstevel@tonic-gate 	cur_p = pxu_p->msiq_config_state;
25460Sstevel@tonic-gate 	/*
25470Sstevel@tonic-gate 	 * Initialize EQ base address register and
25480Sstevel@tonic-gate 	 * Interrupt Mondo Data 0 register.
25490Sstevel@tonic-gate 	 */
25500Sstevel@tonic-gate 	(void) hvio_msiq_init(dev_hdl, pxu_p);
25510Sstevel@tonic-gate 
25520Sstevel@tonic-gate 	/* Restore EQ states */
25530Sstevel@tonic-gate 	for (i = 0; i < EVENT_QUEUE_STATE_ENTRIES; i++, cur_p++) {
25540Sstevel@tonic-gate 		if (((*cur_p) & EVENT_QUEUE_STATE_ENTRIES_STATE_MASK) ==
25550Sstevel@tonic-gate 		    EQ_ACTIVE_STATE) {
25560Sstevel@tonic-gate 			CSRA_BS((caddr_t)dev_hdl, EVENT_QUEUE_CONTROL_SET,
25570Sstevel@tonic-gate 			    i, ENTRIES_EN);
25580Sstevel@tonic-gate 		}
25590Sstevel@tonic-gate 	}
25600Sstevel@tonic-gate 
25610Sstevel@tonic-gate 	/* Restore MSI mapping */
25620Sstevel@tonic-gate 	for (i = 0; i < MSI_MAPPING_ENTRIES; i++, cur_p++)
25630Sstevel@tonic-gate 		CSRA_XS((caddr_t)dev_hdl, MSI_MAPPING, i, *cur_p);
25640Sstevel@tonic-gate 
25650Sstevel@tonic-gate 	/*
25660Sstevel@tonic-gate 	 * Restore all other registers. MSI 32 bit address and
25670Sstevel@tonic-gate 	 * MSI 64 bit address are restored as part of this.
25680Sstevel@tonic-gate 	 */
25690Sstevel@tonic-gate 	for (i = 0; i < MSIQ_OTHER_KEYS; i++, cur_p++)
25700Sstevel@tonic-gate 		CSR_XS((caddr_t)dev_hdl, msiq_config_other_regs[i], *cur_p);
25710Sstevel@tonic-gate 
25720Sstevel@tonic-gate 	kmem_free(pxu_p->msiq_config_state, bufsz);
25730Sstevel@tonic-gate 	pxu_p->msiq_config_state = NULL;
25740Sstevel@tonic-gate }
25750Sstevel@tonic-gate 
25760Sstevel@tonic-gate /*
25770Sstevel@tonic-gate  * sends PME_Turn_Off message to put the link in L2/L3 ready state.
25780Sstevel@tonic-gate  * called by px_goto_l23ready.
25790Sstevel@tonic-gate  * returns DDI_SUCCESS or DDI_FAILURE
25800Sstevel@tonic-gate  */
25810Sstevel@tonic-gate int
25820Sstevel@tonic-gate px_send_pme_turnoff(caddr_t csr_base)
25830Sstevel@tonic-gate {
25840Sstevel@tonic-gate 	volatile uint64_t reg;
25850Sstevel@tonic-gate 
25860Sstevel@tonic-gate 	/* TBD: Wait for link to be in L1 state (link status reg) */
25870Sstevel@tonic-gate 
25880Sstevel@tonic-gate 	reg = CSR_XR(csr_base, TLU_PME_TURN_OFF_GENERATE);
25890Sstevel@tonic-gate 	/* If already pending, return failure */
25900Sstevel@tonic-gate 	if (reg & (1ull << TLU_PME_TURN_OFF_GENERATE_PTO)) {
25910Sstevel@tonic-gate 		return (DDI_FAILURE);
25920Sstevel@tonic-gate 	}
2593*27Sjchu 
25940Sstevel@tonic-gate 	/* write to PME_Turn_off reg to boradcast */
25950Sstevel@tonic-gate 	reg |= (1ull << TLU_PME_TURN_OFF_GENERATE_PTO);
25960Sstevel@tonic-gate 	CSR_XS(csr_base,  TLU_PME_TURN_OFF_GENERATE, reg);
25970Sstevel@tonic-gate 	return (DDI_SUCCESS);
25980Sstevel@tonic-gate }
2599