xref: /onnv-gate/usr/src/uts/sun4u/io/px/px_hlib.c (revision 1617:12ce27916e2c)
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
5*1617Sgovinda  * Common Development and Distribution License (the "License").
6*1617Sgovinda  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*1617Sgovinda  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
270Sstevel@tonic-gate 
280Sstevel@tonic-gate #include <sys/types.h>
290Sstevel@tonic-gate #include <sys/cmn_err.h>
300Sstevel@tonic-gate #include <sys/vmsystm.h>
310Sstevel@tonic-gate #include <sys/vmem.h>
320Sstevel@tonic-gate #include <sys/machsystm.h>	/* lddphys() */
330Sstevel@tonic-gate #include <sys/iommutsb.h>
340Sstevel@tonic-gate #include <sys/pci.h>
350Sstevel@tonic-gate #include <pcie_pwr.h>
360Sstevel@tonic-gate #include <px_obj.h>
370Sstevel@tonic-gate #include "px_regs.h"
380Sstevel@tonic-gate #include "px_csr.h"
390Sstevel@tonic-gate #include "px_lib4u.h"
400Sstevel@tonic-gate 
410Sstevel@tonic-gate /*
420Sstevel@tonic-gate  * Registers that need to be saved and restored during suspend/resume.
430Sstevel@tonic-gate  */
440Sstevel@tonic-gate 
450Sstevel@tonic-gate /*
460Sstevel@tonic-gate  * Registers in the PEC Module.
470Sstevel@tonic-gate  * LPU_RESET should be set to 0ull during resume
480Sstevel@tonic-gate  */
490Sstevel@tonic-gate static uint64_t	pec_config_state_regs[] = {
500Sstevel@tonic-gate 	PEC_CORE_AND_BLOCK_INTERRUPT_ENABLE,
510Sstevel@tonic-gate 	ILU_ERROR_LOG_ENABLE,
520Sstevel@tonic-gate 	ILU_INTERRUPT_ENABLE,
530Sstevel@tonic-gate 	TLU_CONTROL,
540Sstevel@tonic-gate 	TLU_OTHER_EVENT_LOG_ENABLE,
550Sstevel@tonic-gate 	TLU_OTHER_EVENT_INTERRUPT_ENABLE,
560Sstevel@tonic-gate 	TLU_DEVICE_CONTROL,
570Sstevel@tonic-gate 	TLU_LINK_CONTROL,
580Sstevel@tonic-gate 	TLU_UNCORRECTABLE_ERROR_LOG_ENABLE,
590Sstevel@tonic-gate 	TLU_UNCORRECTABLE_ERROR_INTERRUPT_ENABLE,
600Sstevel@tonic-gate 	TLU_CORRECTABLE_ERROR_LOG_ENABLE,
610Sstevel@tonic-gate 	TLU_CORRECTABLE_ERROR_INTERRUPT_ENABLE,
6227Sjchu 	LPU_LINK_LAYER_INTERRUPT_MASK,
6327Sjchu 	LPU_PHY_INTERRUPT_MASK,
6427Sjchu 	LPU_RECEIVE_PHY_INTERRUPT_MASK,
6527Sjchu 	LPU_TRANSMIT_PHY_INTERRUPT_MASK,
6627Sjchu 	LPU_GIGABLAZE_GLUE_INTERRUPT_MASK,
6727Sjchu 	LPU_LTSSM_INTERRUPT_MASK,
6827Sjchu 	LPU_RESET,
690Sstevel@tonic-gate 	LPU_DEBUG_CONFIG,
700Sstevel@tonic-gate 	LPU_INTERRUPT_MASK,
710Sstevel@tonic-gate 	LPU_LINK_LAYER_CONFIG,
720Sstevel@tonic-gate 	LPU_FLOW_CONTROL_UPDATE_CONTROL,
730Sstevel@tonic-gate 	LPU_TXLINK_FREQUENT_NAK_LATENCY_TIMER_THRESHOLD,
740Sstevel@tonic-gate 	LPU_TXLINK_REPLAY_TIMER_THRESHOLD,
750Sstevel@tonic-gate 	LPU_REPLAY_BUFFER_MAX_ADDRESS,
760Sstevel@tonic-gate 	LPU_TXLINK_RETRY_FIFO_POINTER,
770Sstevel@tonic-gate 	LPU_LTSSM_CONFIG2,
780Sstevel@tonic-gate 	LPU_LTSSM_CONFIG3,
790Sstevel@tonic-gate 	LPU_LTSSM_CONFIG4,
800Sstevel@tonic-gate 	LPU_LTSSM_CONFIG5,
810Sstevel@tonic-gate 	DMC_CORE_AND_BLOCK_INTERRUPT_ENABLE,
820Sstevel@tonic-gate 	DMC_DEBUG_SELECT_FOR_PORT_A,
830Sstevel@tonic-gate 	DMC_DEBUG_SELECT_FOR_PORT_B
840Sstevel@tonic-gate };
850Sstevel@tonic-gate #define	PEC_SIZE (sizeof (pec_config_state_regs))
860Sstevel@tonic-gate #define	PEC_KEYS (PEC_SIZE / sizeof (uint64_t))
870Sstevel@tonic-gate 
880Sstevel@tonic-gate /*
890Sstevel@tonic-gate  * Registers for the MMU module.
900Sstevel@tonic-gate  * MMU_TTE_CACHE_INVALIDATE needs to be cleared. (-1ull)
910Sstevel@tonic-gate  */
920Sstevel@tonic-gate static uint64_t mmu_config_state_regs[] = {
930Sstevel@tonic-gate 	MMU_TSB_CONTROL,
940Sstevel@tonic-gate 	MMU_CONTROL_AND_STATUS,
9527Sjchu 	MMU_ERROR_LOG_ENABLE,
960Sstevel@tonic-gate 	MMU_INTERRUPT_ENABLE
970Sstevel@tonic-gate };
980Sstevel@tonic-gate #define	MMU_SIZE (sizeof (mmu_config_state_regs))
990Sstevel@tonic-gate #define	MMU_KEYS (MMU_SIZE / sizeof (uint64_t))
1000Sstevel@tonic-gate 
1010Sstevel@tonic-gate /*
1020Sstevel@tonic-gate  * Registers for the IB Module
1030Sstevel@tonic-gate  */
1040Sstevel@tonic-gate static uint64_t ib_config_state_regs[] = {
1050Sstevel@tonic-gate 	IMU_ERROR_LOG_ENABLE,
1060Sstevel@tonic-gate 	IMU_INTERRUPT_ENABLE
1070Sstevel@tonic-gate };
1080Sstevel@tonic-gate #define	IB_SIZE (sizeof (ib_config_state_regs))
1090Sstevel@tonic-gate #define	IB_KEYS (IB_SIZE / sizeof (uint64_t))
1100Sstevel@tonic-gate #define	IB_MAP_SIZE (INTERRUPT_MAPPING_ENTRIES * sizeof (uint64_t))
1110Sstevel@tonic-gate 
1120Sstevel@tonic-gate /*
1130Sstevel@tonic-gate  * Registers for the CB module.
1140Sstevel@tonic-gate  * JBC_ERROR_STATUS_CLEAR needs to be cleared. (-1ull)
1150Sstevel@tonic-gate  */
1160Sstevel@tonic-gate static uint64_t	cb_config_state_regs[] = {
1170Sstevel@tonic-gate 	JBUS_PARITY_CONTROL,
1180Sstevel@tonic-gate 	JBC_FATAL_RESET_ENABLE,
1190Sstevel@tonic-gate 	JBC_CORE_AND_BLOCK_INTERRUPT_ENABLE,
1200Sstevel@tonic-gate 	JBC_ERROR_LOG_ENABLE,
1210Sstevel@tonic-gate 	JBC_INTERRUPT_ENABLE
1220Sstevel@tonic-gate };
1230Sstevel@tonic-gate #define	CB_SIZE (sizeof (cb_config_state_regs))
1240Sstevel@tonic-gate #define	CB_KEYS (CB_SIZE / sizeof (uint64_t))
1250Sstevel@tonic-gate 
1260Sstevel@tonic-gate static uint64_t	msiq_config_other_regs[] = {
1270Sstevel@tonic-gate 	ERR_COR_MAPPING,
1280Sstevel@tonic-gate 	ERR_NONFATAL_MAPPING,
1290Sstevel@tonic-gate 	ERR_FATAL_MAPPING,
1300Sstevel@tonic-gate 	PM_PME_MAPPING,
1310Sstevel@tonic-gate 	PME_TO_ACK_MAPPING,
1320Sstevel@tonic-gate 	MSI_32_BIT_ADDRESS,
1330Sstevel@tonic-gate 	MSI_64_BIT_ADDRESS
1340Sstevel@tonic-gate };
1350Sstevel@tonic-gate #define	MSIQ_OTHER_SIZE	(sizeof (msiq_config_other_regs))
1360Sstevel@tonic-gate #define	MSIQ_OTHER_KEYS	(MSIQ_OTHER_SIZE / sizeof (uint64_t))
1370Sstevel@tonic-gate 
1380Sstevel@tonic-gate #define	MSIQ_STATE_SIZE		(EVENT_QUEUE_STATE_ENTRIES * sizeof (uint64_t))
1390Sstevel@tonic-gate #define	MSIQ_MAPPING_SIZE	(MSI_MAPPING_ENTRIES * sizeof (uint64_t))
1400Sstevel@tonic-gate 
1410Sstevel@tonic-gate static uint64_t msiq_suspend(devhandle_t dev_hdl, pxu_t *pxu_p);
1420Sstevel@tonic-gate static void msiq_resume(devhandle_t dev_hdl, pxu_t *pxu_p);
1430Sstevel@tonic-gate 
14427Sjchu /*
14527Sjchu  * Initialize the module, but do not enable interrupts.
14627Sjchu  */
1470Sstevel@tonic-gate /* ARGSUSED */
1480Sstevel@tonic-gate void
1490Sstevel@tonic-gate hvio_cb_init(caddr_t xbc_csr_base, pxu_t *pxu_p)
1500Sstevel@tonic-gate {
1510Sstevel@tonic-gate 	uint64_t val;
1520Sstevel@tonic-gate 
1530Sstevel@tonic-gate 	/* Check if we need to enable inverted parity */
1540Sstevel@tonic-gate 	val = (1ULL << JBUS_PARITY_CONTROL_P_EN);
1550Sstevel@tonic-gate 	CSR_XS(xbc_csr_base, JBUS_PARITY_CONTROL, val);
1560Sstevel@tonic-gate 	DBG(DBG_CB, NULL, "hvio_cb_init, JBUS_PARITY_CONTROL: 0x%llx\n",
15727Sjchu 	    CSR_XR(xbc_csr_base, JBUS_PARITY_CONTROL));
15827Sjchu 
15927Sjchu 	val = (1 << JBC_FATAL_RESET_ENABLE_SPARE_P_INT_EN) |
16027Sjchu 	    (1 << JBC_FATAL_RESET_ENABLE_MB_PEA_P_INT_EN) |
16127Sjchu 	    (1 << JBC_FATAL_RESET_ENABLE_CPE_P_INT_EN) |
16227Sjchu 	    (1 << JBC_FATAL_RESET_ENABLE_APE_P_INT_EN) |
16327Sjchu 	    (1 << JBC_FATAL_RESET_ENABLE_PIO_CPE_INT_EN) |
16427Sjchu 	    (1 << JBC_FATAL_RESET_ENABLE_JTCEEW_P_INT_EN) |
16527Sjchu 	    (1 << JBC_FATAL_RESET_ENABLE_JTCEEI_P_INT_EN) |
16627Sjchu 	    (1 << JBC_FATAL_RESET_ENABLE_JTCEER_P_INT_EN);
1670Sstevel@tonic-gate 	CSR_XS(xbc_csr_base, JBC_FATAL_RESET_ENABLE, val);
1680Sstevel@tonic-gate 	DBG(DBG_CB, NULL, "hvio_cb_init, JBC_FATAL_RESET_ENABLE: 0x%llx\n",
1690Sstevel@tonic-gate 		CSR_XR(xbc_csr_base, JBC_FATAL_RESET_ENABLE));
1700Sstevel@tonic-gate 
1710Sstevel@tonic-gate 	/*
1720Sstevel@tonic-gate 	 * Enable merge, jbc and dmc interrupts.
1730Sstevel@tonic-gate 	 */
1740Sstevel@tonic-gate 	CSR_XS(xbc_csr_base, JBC_CORE_AND_BLOCK_INTERRUPT_ENABLE, -1ull);
1750Sstevel@tonic-gate 	DBG(DBG_CB, NULL,
17627Sjchu 	    "hvio_cb_init, JBC_CORE_AND_BLOCK_INTERRUPT_ENABLE: 0x%llx\n",
17727Sjchu 	    CSR_XR(xbc_csr_base, JBC_CORE_AND_BLOCK_INTERRUPT_ENABLE));
1780Sstevel@tonic-gate 
1790Sstevel@tonic-gate 	/*
18027Sjchu 	 * CSR_V CB's interrupt regs (log, enable, status, clear)
1810Sstevel@tonic-gate 	 */
18227Sjchu 	DBG(DBG_CB, NULL, "hvio_cb_init, JBC_ERROR_LOG_ENABLE: 0x%llx\n",
18327Sjchu 	    CSR_XR(xbc_csr_base, JBC_ERROR_LOG_ENABLE));
18427Sjchu 
1850Sstevel@tonic-gate 	DBG(DBG_CB, NULL, "hvio_cb_init, JBC_INTERRUPT_ENABLE: 0x%llx\n",
18627Sjchu 	    CSR_XR(xbc_csr_base, JBC_INTERRUPT_ENABLE));
18727Sjchu 
18827Sjchu 	DBG(DBG_CB, NULL, "hvio_cb_init, JBC_INTERRUPT_STATUS: 0x%llx\n",
18927Sjchu 	    CSR_XR(xbc_csr_base, JBC_INTERRUPT_STATUS));
19027Sjchu 
1910Sstevel@tonic-gate 	DBG(DBG_CB, NULL, "hvio_cb_init, JBC_ERROR_STATUS_CLEAR: 0x%llx\n",
19227Sjchu 	    CSR_XR(xbc_csr_base, JBC_ERROR_STATUS_CLEAR));
1930Sstevel@tonic-gate }
1940Sstevel@tonic-gate 
19527Sjchu /*
19627Sjchu  * Initialize the module, but do not enable interrupts.
19727Sjchu  */
1980Sstevel@tonic-gate /* ARGSUSED */
1990Sstevel@tonic-gate void
2000Sstevel@tonic-gate hvio_ib_init(caddr_t csr_base, pxu_t *pxu_p)
2010Sstevel@tonic-gate {
2020Sstevel@tonic-gate 	/*
20327Sjchu 	 * CSR_V IB's interrupt regs (log, enable, status, clear)
2040Sstevel@tonic-gate 	 */
2050Sstevel@tonic-gate 	DBG(DBG_IB, NULL, "hvio_ib_init - IMU_ERROR_LOG_ENABLE: 0x%llx\n",
20627Sjchu 	    CSR_XR(csr_base, IMU_ERROR_LOG_ENABLE));
20727Sjchu 
2080Sstevel@tonic-gate 	DBG(DBG_IB, NULL, "hvio_ib_init - IMU_INTERRUPT_ENABLE: 0x%llx\n",
20927Sjchu 	    CSR_XR(csr_base, IMU_INTERRUPT_ENABLE));
21027Sjchu 
2110Sstevel@tonic-gate 	DBG(DBG_IB, NULL, "hvio_ib_init - IMU_INTERRUPT_STATUS: 0x%llx\n",
21227Sjchu 	    CSR_XR(csr_base, IMU_INTERRUPT_STATUS));
21327Sjchu 
2140Sstevel@tonic-gate 	DBG(DBG_IB, NULL, "hvio_ib_init - IMU_ERROR_STATUS_CLEAR: 0x%llx\n",
21527Sjchu 	    CSR_XR(csr_base, IMU_ERROR_STATUS_CLEAR));
2160Sstevel@tonic-gate }
2170Sstevel@tonic-gate 
21827Sjchu /*
21927Sjchu  * Initialize the module, but do not enable interrupts.
22027Sjchu  */
2210Sstevel@tonic-gate /* ARGSUSED */
2220Sstevel@tonic-gate static void
2230Sstevel@tonic-gate ilu_init(caddr_t csr_base, pxu_t *pxu_p)
2240Sstevel@tonic-gate {
2250Sstevel@tonic-gate 	/*
22627Sjchu 	 * CSR_V ILU's interrupt regs (log, enable, status, clear)
2270Sstevel@tonic-gate 	 */
22827Sjchu 	DBG(DBG_ILU, NULL, "ilu_init - ILU_ERROR_LOG_ENABLE: 0x%llx\n",
22927Sjchu 	    CSR_XR(csr_base, ILU_ERROR_LOG_ENABLE));
23027Sjchu 
2310Sstevel@tonic-gate 	DBG(DBG_ILU, NULL, "ilu_init - ILU_INTERRUPT_ENABLE: 0x%llx\n",
23227Sjchu 	    CSR_XR(csr_base, ILU_INTERRUPT_ENABLE));
23327Sjchu 
2340Sstevel@tonic-gate 	DBG(DBG_ILU, NULL, "ilu_init - ILU_INTERRUPT_STATUS: 0x%llx\n",
23527Sjchu 	    CSR_XR(csr_base, ILU_INTERRUPT_STATUS));
23627Sjchu 
2370Sstevel@tonic-gate 	DBG(DBG_ILU, NULL, "ilu_init - ILU_ERROR_STATUS_CLEAR: 0x%llx\n",
23827Sjchu 	    CSR_XR(csr_base, ILU_ERROR_STATUS_CLEAR));
2390Sstevel@tonic-gate }
2400Sstevel@tonic-gate 
24127Sjchu /*
24227Sjchu  * Initialize the module, but do not enable interrupts.
24327Sjchu  */
244225Sess /* ARGSUSED */
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);
268225Sess 	val |= (TLU_CONTROL_L0S_TIM_DEFAULT << TLU_CONTROL_L0S_TIM) |
269225Sess 	    (1ull << TLU_CONTROL_NPWR_EN) | TLU_CONTROL_CONFIG_DEFAULT;
2700Sstevel@tonic-gate 
271118Sjchu 	/*
272118Sjchu 	 * Set Detect.Quiet. This will disable automatic link
273118Sjchu 	 * re-training, if the link goes down e.g. power management
274118Sjchu 	 * turns off power to the downstream device. This will enable
275118Sjchu 	 * Fire to go to Drain state, after link down. The drain state
276118Sjchu 	 * forces a reset to the FC state machine, which is required for
277118Sjchu 	 * proper link re-training.
278118Sjchu 	 */
279118Sjchu 	val |= (1ull << TLU_REMAIN_DETECT_QUIET);
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",
29527Sjchu 	    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",
30127Sjchu 	    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",
31427Sjchu 	    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",
32427Sjchu 	    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",
33027Sjchu 	    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",
33627Sjchu 	    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",
34227Sjchu 	    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,
34827Sjchu 	    "tlu_init - TLU_INGRESS_CREDITS_ALLOCATED: 0x%llx\n",
34927Sjchu 	    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,
35527Sjchu 	    "tlu_init - TLU_INGRESS_CREDITS_RECEIVED: 0x%llx\n",
35627Sjchu 	    CSR_XR(csr_base, TLU_INGRESS_CREDITS_RECEIVED));
3570Sstevel@tonic-gate 
3580Sstevel@tonic-gate 	/*
35927Sjchu 	 * CSR_V TLU's interrupt regs (log, enable, status, clear)
3600Sstevel@tonic-gate 	 */
3610Sstevel@tonic-gate 	DBG(DBG_TLU, NULL,
36227Sjchu 	    "tlu_init - TLU_OTHER_EVENT_LOG_ENABLE: 0x%llx\n",
36327Sjchu 	    CSR_XR(csr_base, TLU_OTHER_EVENT_LOG_ENABLE));
36427Sjchu 
3650Sstevel@tonic-gate 	DBG(DBG_TLU, NULL,
36627Sjchu 	    "tlu_init - TLU_OTHER_EVENT_INTERRUPT_ENABLE: 0x%llx\n",
36727Sjchu 	    CSR_XR(csr_base, TLU_OTHER_EVENT_INTERRUPT_ENABLE));
36827Sjchu 
36927Sjchu 	DBG(DBG_TLU, NULL,
37027Sjchu 	    "tlu_init - TLU_OTHER_EVENT_INTERRUPT_STATUS: 0x%llx\n",
37127Sjchu 	    CSR_XR(csr_base, TLU_OTHER_EVENT_INTERRUPT_STATUS));
37227Sjchu 
37327Sjchu 	DBG(DBG_TLU, NULL,
37427Sjchu 	    "tlu_init - TLU_OTHER_EVENT_STATUS_CLEAR: 0x%llx\n",
37527Sjchu 	    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,
38127Sjchu 	    "tlu_init - TLU_RECEIVE_OTHER_EVENT_HEADER1_LOG: 0x%llx\n",
38227Sjchu 	    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,
38827Sjchu 	    "tlu_init - TLU_RECEIVE_OTHER_EVENT_HEADER2_LOG: 0x%llx\n",
38927Sjchu 	    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,
39527Sjchu 	    "tlu_init - TLU_TRANSMIT_OTHER_EVENT_HEADER1_LOG: 0x%llx\n",
39627Sjchu 	    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,
40227Sjchu 	    "tlu_init - TLU_TRANSMIT_OTHER_EVENT_HEADER2_LOG: 0x%llx\n",
40327Sjchu 	    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,
40927Sjchu 	    "tlu_init - TLU_PERFORMANCE_COUNTER_SELECT: 0x%llx\n",
41027Sjchu 	    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,
41627Sjchu 	    "tlu_init - TLU_PERFORMANCE_COUNTER_ZERO: 0x%llx\n",
41727Sjchu 	    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",
42327Sjchu 	    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",
42927Sjchu 	    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",
43627Sjchu 	    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",
44227Sjchu 	    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",
44827Sjchu 	    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",
46327Sjchu 	    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",
46927Sjchu 	    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",
47527Sjchu 	    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",
49427Sjchu 	    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",
51027Sjchu 	    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",
52727Sjchu 	    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,
53327Sjchu 	    "tlu_init - TLU_UNCORRECTABLE_ERROR_LOG_ENABLE: 0x%llx\n",
53427Sjchu 	    CSR_XR(csr_base, TLU_UNCORRECTABLE_ERROR_LOG_ENABLE));
5350Sstevel@tonic-gate 
5360Sstevel@tonic-gate 	/*
53727Sjchu 	 * CSR_V TLU_UNCORRECTABLE_ERROR_INTERRUPT_ENABLE Expect
53827Sjchu 	 * Kernel 0x17F0110017F011
5390Sstevel@tonic-gate 	 */
5400Sstevel@tonic-gate 	DBG(DBG_TLU, NULL,
54127Sjchu 	    "tlu_init - TLU_UNCORRECTABLE_ERROR_INTERRUPT_ENABLE: 0x%llx\n",
54227Sjchu 	    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,
54827Sjchu 	    "tlu_init - TLU_UNCORRECTABLE_ERROR_INTERRUPT_STATUS: 0x%llx\n",
54927Sjchu 	    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,
55527Sjchu 	    "tlu_init - TLU_UNCORRECTABLE_ERROR_STATUS_CLEAR: 0x%llx\n",
55627Sjchu 	    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 
58627Sjchu 
5870Sstevel@tonic-gate 	/*
58827Sjchu 	 * CSR_V TLU's CE interrupt regs (log, enable, status, clear)
58927Sjchu 	 * Plus header logs
5900Sstevel@tonic-gate 	 */
5910Sstevel@tonic-gate 
5920Sstevel@tonic-gate 	/*
59327Sjchu 	 * CSR_V TLU_CORRECTABLE_ERROR_LOG_ENABLE Expect Kernel 0x11C1
5940Sstevel@tonic-gate 	 */
5950Sstevel@tonic-gate 	DBG(DBG_TLU, NULL,
59627Sjchu 	    "tlu_init - TLU_CORRECTABLE_ERROR_LOG_ENABLE: 0x%llx\n",
59727Sjchu 	    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,
60327Sjchu 	    "tlu_init - TLU_CORRECTABLE_ERROR_INTERRUPT_ENABLE: 0x%llx\n",
60427Sjchu 	    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,
61027Sjchu 	    "tlu_init - TLU_CORRECTABLE_ERROR_INTERRUPT_STATUS: 0x%llx\n",
61127Sjchu 	    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,
61727Sjchu 	    "tlu_init - TLU_CORRECTABLE_ERROR_STATUS_CLEAR: 0x%llx\n",
61827Sjchu 	    CSR_XR(csr_base, TLU_CORRECTABLE_ERROR_STATUS_CLEAR));
6190Sstevel@tonic-gate }
6200Sstevel@tonic-gate 
621225Sess /* ARGSUSED */
6220Sstevel@tonic-gate static void
6230Sstevel@tonic-gate lpu_init(caddr_t csr_base, pxu_t *pxu_p)
6240Sstevel@tonic-gate {
6250Sstevel@tonic-gate 	/* Variables used to set the ACKNAK Latency Timer and Replay Timer */
6260Sstevel@tonic-gate 	int link_width, max_payload;
6270Sstevel@tonic-gate 
6280Sstevel@tonic-gate 	uint64_t val;
6290Sstevel@tonic-gate 
6300Sstevel@tonic-gate 	/*
6310Sstevel@tonic-gate 	 * ACKNAK Latency Threshold Table.
6320Sstevel@tonic-gate 	 * See Fire PRM 2.0 section 1.2.12.2, table 1-17.
6330Sstevel@tonic-gate 	 */
6340Sstevel@tonic-gate 	int acknak_timer_table[LINK_MAX_PKT_ARR_SIZE][LINK_WIDTH_ARR_SIZE] = {
6350Sstevel@tonic-gate 		{0xED,   0x49,  0x43,  0x30},
6360Sstevel@tonic-gate 		{0x1A0,  0x76,  0x6B,  0x48},
6370Sstevel@tonic-gate 		{0x22F,  0x9A,  0x56,  0x56},
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 2.0 sections 1.2.12.3, table 1-18.
6460Sstevel@tonic-gate 	 */
6470Sstevel@tonic-gate 	int replay_timer_table[LINK_MAX_PKT_ARR_SIZE][LINK_WIDTH_ARR_SIZE] = {
6480Sstevel@tonic-gate 		{0x379,  0x112, 0xFC,  0xB4},
6490Sstevel@tonic-gate 		{0x618,  0x1BA, 0x192, 0x10E},
6500Sstevel@tonic-gate 		{0x831,  0x242, 0x143, 0x143},
6510Sstevel@tonic-gate 		{0xFB1,  0x422, 0x233, 0x233},
6520Sstevel@tonic-gate 		{0x1EB0, 0x7E1, 0x412, 0x412},
6530Sstevel@tonic-gate 		{0x3CB0, 0xF61, 0x7D2, 0x7D2}
6540Sstevel@tonic-gate 	};
655225Sess 
6560Sstevel@tonic-gate 	/*
6570Sstevel@tonic-gate 	 * Get the Link Width.  See table above LINK_WIDTH_ARR_SIZE #define
6580Sstevel@tonic-gate 	 * Only Link Widths of x1, x4, and x8 are supported.
6590Sstevel@tonic-gate 	 * If any width is reported other than x8, set default to x8.
6600Sstevel@tonic-gate 	 */
6610Sstevel@tonic-gate 	link_width = CSR_FR(csr_base, TLU_LINK_STATUS, WIDTH);
6620Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - Link Width: x%d\n", link_width);
6630Sstevel@tonic-gate 
6640Sstevel@tonic-gate 	/*
6650Sstevel@tonic-gate 	 * Convert link_width to match timer array configuration.
6660Sstevel@tonic-gate 	 */
6670Sstevel@tonic-gate 	switch (link_width) {
6680Sstevel@tonic-gate 	case 1:
6690Sstevel@tonic-gate 		link_width = 0;
6700Sstevel@tonic-gate 		break;
6710Sstevel@tonic-gate 	case 4:
6720Sstevel@tonic-gate 		link_width = 1;
6730Sstevel@tonic-gate 		break;
6740Sstevel@tonic-gate 	case 8:
6750Sstevel@tonic-gate 		link_width = 2;
6760Sstevel@tonic-gate 		break;
6770Sstevel@tonic-gate 	case 16:
6780Sstevel@tonic-gate 		link_width = 3;
6790Sstevel@tonic-gate 		break;
6800Sstevel@tonic-gate 	default:
6810Sstevel@tonic-gate 		link_width = 0;
6820Sstevel@tonic-gate 	}
6830Sstevel@tonic-gate 
6840Sstevel@tonic-gate 	/*
6850Sstevel@tonic-gate 	 * Get the Max Payload Size.
6860Sstevel@tonic-gate 	 * See table above LINK_MAX_PKT_ARR_SIZE #define
6870Sstevel@tonic-gate 	 */
688225Sess 	max_payload = ((CSR_FR(csr_base, TLU_CONTROL, CONFIG) &
689225Sess 	    TLU_CONTROL_MPS_MASK) >> TLU_CONTROL_MPS_SHIFT);
6900Sstevel@tonic-gate 
6910Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - May Payload: %d\n",
6920Sstevel@tonic-gate 	    (0x80 << max_payload));
6930Sstevel@tonic-gate 
6940Sstevel@tonic-gate 	/* Make sure the packet size is not greater than 4096 */
6950Sstevel@tonic-gate 	max_payload = (max_payload >= LINK_MAX_PKT_ARR_SIZE) ?
6960Sstevel@tonic-gate 	    (LINK_MAX_PKT_ARR_SIZE - 1) : max_payload;
6970Sstevel@tonic-gate 
6980Sstevel@tonic-gate 	/*
6990Sstevel@tonic-gate 	 * CSR_V LPU_ID Expect HW 0x0
7000Sstevel@tonic-gate 	 */
7010Sstevel@tonic-gate 
7020Sstevel@tonic-gate 	/*
7030Sstevel@tonic-gate 	 * This register has link id, phy id and gigablaze id.
7040Sstevel@tonic-gate 	 * Should be set by HW.
7050Sstevel@tonic-gate 	 */
7060Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_ID: 0x%llx\n",
70727Sjchu 	    CSR_XR(csr_base, LPU_ID));
7080Sstevel@tonic-gate 
7090Sstevel@tonic-gate 	/*
7100Sstevel@tonic-gate 	 * CSR_V LPU_RESET Expect Kernel 0x0
7110Sstevel@tonic-gate 	 */
7120Sstevel@tonic-gate 
7130Sstevel@tonic-gate 	/*
7140Sstevel@tonic-gate 	 * No reason to have any reset bits high until an error is
7150Sstevel@tonic-gate 	 * detected on the link.
7160Sstevel@tonic-gate 	 */
7170Sstevel@tonic-gate 	val = 0ull;
7180Sstevel@tonic-gate 	CSR_XS(csr_base, LPU_RESET, val);
7190Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_RESET: 0x%llx\n",
72027Sjchu 	    CSR_XR(csr_base, LPU_RESET));
7210Sstevel@tonic-gate 
7220Sstevel@tonic-gate 	/*
7230Sstevel@tonic-gate 	 * CSR_V LPU_DEBUG_STATUS Expect HW 0x0
7240Sstevel@tonic-gate 	 */
7250Sstevel@tonic-gate 
7260Sstevel@tonic-gate 	/*
7270Sstevel@tonic-gate 	 * Bits [15:8] are Debug B, and bit [7:0] are Debug A.
7280Sstevel@tonic-gate 	 * They are read-only.  What do the 8 bits mean, and
7290Sstevel@tonic-gate 	 * how do they get set if they are read only?
7300Sstevel@tonic-gate 	 */
7310Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_DEBUG_STATUS: 0x%llx\n",
73227Sjchu 	    CSR_XR(csr_base, LPU_DEBUG_STATUS));
7330Sstevel@tonic-gate 
7340Sstevel@tonic-gate 	/*
7350Sstevel@tonic-gate 	 * CSR_V LPU_DEBUG_CONFIG Expect Kernel 0x0
7360Sstevel@tonic-gate 	 */
7370Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_DEBUG_CONFIG: 0x%llx\n",
73827Sjchu 	    CSR_XR(csr_base, LPU_DEBUG_CONFIG));
7390Sstevel@tonic-gate 
7400Sstevel@tonic-gate 	/*
7410Sstevel@tonic-gate 	 * CSR_V LPU_LTSSM_CONTROL Expect HW 0x0
7420Sstevel@tonic-gate 	 */
7430Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_LTSSM_CONTROL: 0x%llx\n",
74427Sjchu 	    CSR_XR(csr_base, LPU_LTSSM_CONTROL));
7450Sstevel@tonic-gate 
7460Sstevel@tonic-gate 	/*
7470Sstevel@tonic-gate 	 * CSR_V LPU_LINK_STATUS Expect HW 0x101
7480Sstevel@tonic-gate 	 */
7490Sstevel@tonic-gate 
7500Sstevel@tonic-gate 	/*
7510Sstevel@tonic-gate 	 * This register has bits [9:4] for link width, and the
7520Sstevel@tonic-gate 	 * default 0x10, means a width of x16.  The problem is
7530Sstevel@tonic-gate 	 * this width is not supported according to the TLU
7540Sstevel@tonic-gate 	 * link status register.
7550Sstevel@tonic-gate 	 */
7560Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_LINK_STATUS: 0x%llx\n",
75727Sjchu 	    CSR_XR(csr_base, LPU_LINK_STATUS));
7580Sstevel@tonic-gate 
7590Sstevel@tonic-gate 	/*
7600Sstevel@tonic-gate 	 * CSR_V LPU_INTERRUPT_STATUS Expect HW 0x0
7610Sstevel@tonic-gate 	 */
7620Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_INTERRUPT_STATUS: 0x%llx\n",
76327Sjchu 	    CSR_XR(csr_base, LPU_INTERRUPT_STATUS));
7640Sstevel@tonic-gate 
7650Sstevel@tonic-gate 	/*
7660Sstevel@tonic-gate 	 * CSR_V LPU_INTERRUPT_MASK Expect HW 0x0
7670Sstevel@tonic-gate 	 */
7680Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_INTERRUPT_MASK: 0x%llx\n",
76927Sjchu 	    CSR_XR(csr_base, LPU_INTERRUPT_MASK));
7700Sstevel@tonic-gate 
7710Sstevel@tonic-gate 	/*
7720Sstevel@tonic-gate 	 * CSR_V LPU_LINK_PERFORMANCE_COUNTER_SELECT Expect HW 0x0
7730Sstevel@tonic-gate 	 */
7740Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
77527Sjchu 	    "lpu_init - LPU_LINK_PERFORMANCE_COUNTER_SELECT: 0x%llx\n",
77627Sjchu 	    CSR_XR(csr_base, LPU_LINK_PERFORMANCE_COUNTER_SELECT));
7770Sstevel@tonic-gate 
7780Sstevel@tonic-gate 	/*
7790Sstevel@tonic-gate 	 * CSR_V LPU_LINK_PERFORMANCE_COUNTER_CONTROL Expect HW 0x0
7800Sstevel@tonic-gate 	 */
7810Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
78227Sjchu 	    "lpu_init - LPU_LINK_PERFORMANCE_COUNTER_CONTROL: 0x%llx\n",
78327Sjchu 	    CSR_XR(csr_base, LPU_LINK_PERFORMANCE_COUNTER_CONTROL));
7840Sstevel@tonic-gate 
7850Sstevel@tonic-gate 	/*
7860Sstevel@tonic-gate 	 * CSR_V LPU_LINK_PERFORMANCE_COUNTER1 Expect HW 0x0
7870Sstevel@tonic-gate 	 */
7880Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
78927Sjchu 	    "lpu_init - LPU_LINK_PERFORMANCE_COUNTER1: 0x%llx\n",
79027Sjchu 	    CSR_XR(csr_base, LPU_LINK_PERFORMANCE_COUNTER1));
7910Sstevel@tonic-gate 
7920Sstevel@tonic-gate 	/*
7930Sstevel@tonic-gate 	 * CSR_V LPU_LINK_PERFORMANCE_COUNTER1_TEST Expect HW 0x0
7940Sstevel@tonic-gate 	 */
7950Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
79627Sjchu 	    "lpu_init - LPU_LINK_PERFORMANCE_COUNTER1_TEST: 0x%llx\n",
79727Sjchu 	    CSR_XR(csr_base, LPU_LINK_PERFORMANCE_COUNTER1_TEST));
7980Sstevel@tonic-gate 
7990Sstevel@tonic-gate 	/*
8000Sstevel@tonic-gate 	 * CSR_V LPU_LINK_PERFORMANCE_COUNTER2 Expect HW 0x0
8010Sstevel@tonic-gate 	 */
8020Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
80327Sjchu 	    "lpu_init - LPU_LINK_PERFORMANCE_COUNTER2: 0x%llx\n",
80427Sjchu 	    CSR_XR(csr_base, LPU_LINK_PERFORMANCE_COUNTER2));
8050Sstevel@tonic-gate 
8060Sstevel@tonic-gate 	/*
8070Sstevel@tonic-gate 	 * CSR_V LPU_LINK_PERFORMANCE_COUNTER2_TEST Expect HW 0x0
8080Sstevel@tonic-gate 	 */
8090Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
81027Sjchu 	    "lpu_init - LPU_LINK_PERFORMANCE_COUNTER2_TEST: 0x%llx\n",
81127Sjchu 	    CSR_XR(csr_base, LPU_LINK_PERFORMANCE_COUNTER2_TEST));
8120Sstevel@tonic-gate 
8130Sstevel@tonic-gate 	/*
8140Sstevel@tonic-gate 	 * CSR_V LPU_LINK_LAYER_CONFIG Expect HW 0x100
8150Sstevel@tonic-gate 	 */
8160Sstevel@tonic-gate 
8170Sstevel@tonic-gate 	/*
8180Sstevel@tonic-gate 	 * This is another place where Max Payload can be set,
8190Sstevel@tonic-gate 	 * this time for the link layer.  It will be set to
8200Sstevel@tonic-gate 	 * 128B, which is the default, but this will need to
8210Sstevel@tonic-gate 	 * be revisited.
8220Sstevel@tonic-gate 	 */
8230Sstevel@tonic-gate 	val = (1ull << LPU_LINK_LAYER_CONFIG_VC0_EN);
8240Sstevel@tonic-gate 	CSR_XS(csr_base, LPU_LINK_LAYER_CONFIG, val);
8250Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_LINK_LAYER_CONFIG: 0x%llx\n",
82627Sjchu 	    CSR_XR(csr_base, LPU_LINK_LAYER_CONFIG));
8270Sstevel@tonic-gate 
8280Sstevel@tonic-gate 	/*
8290Sstevel@tonic-gate 	 * CSR_V LPU_LINK_LAYER_STATUS Expect OBP 0x5
8300Sstevel@tonic-gate 	 */
8310Sstevel@tonic-gate 
8320Sstevel@tonic-gate 	/*
8330Sstevel@tonic-gate 	 * Another R/W status register.  Bit 3, DL up Status, will
8340Sstevel@tonic-gate 	 * be set high.  The link state machine status bits [2:0]
8350Sstevel@tonic-gate 	 * are set to 0x1, but the status bits are not defined in the
8360Sstevel@tonic-gate 	 * PRM.  What does 0x1 mean, what others values are possible
8370Sstevel@tonic-gate 	 * and what are thier meanings?
8380Sstevel@tonic-gate 	 *
8390Sstevel@tonic-gate 	 * This register has been giving us problems in simulation.
8400Sstevel@tonic-gate 	 * It has been mentioned that software should not program
8410Sstevel@tonic-gate 	 * any registers with WE bits except during debug.  So
8420Sstevel@tonic-gate 	 * this register will no longer be programmed.
8430Sstevel@tonic-gate 	 */
8440Sstevel@tonic-gate 
8450Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_LINK_LAYER_STATUS: 0x%llx\n",
84627Sjchu 	    CSR_XR(csr_base, LPU_LINK_LAYER_STATUS));
8470Sstevel@tonic-gate 
8480Sstevel@tonic-gate 	/*
8490Sstevel@tonic-gate 	 * CSR_V LPU_LINK_LAYER_INTERRUPT_AND_STATUS_TEST Expect HW 0x0
8500Sstevel@tonic-gate 	 */
8510Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
85227Sjchu 	    "lpu_init - LPU_LINK_LAYER_INTERRUPT_AND_STATUS_TEST: 0x%llx\n",
85327Sjchu 	    CSR_XR(csr_base, LPU_LINK_LAYER_INTERRUPT_AND_STATUS_TEST));
8540Sstevel@tonic-gate 
8550Sstevel@tonic-gate 	/*
85627Sjchu 	 * CSR_V LPU Link Layer interrupt regs (mask, status)
8570Sstevel@tonic-gate 	 */
8580Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
85927Sjchu 	    "lpu_init - LPU_LINK_LAYER_INTERRUPT_MASK: 0x%llx\n",
86027Sjchu 	    CSR_XR(csr_base, LPU_LINK_LAYER_INTERRUPT_MASK));
86127Sjchu 
86227Sjchu 	DBG(DBG_LPU, NULL,
86327Sjchu 	    "lpu_init - LPU_LINK_LAYER_INTERRUPT_AND_STATUS: 0x%llx\n",
86427Sjchu 	    CSR_XR(csr_base, LPU_LINK_LAYER_INTERRUPT_AND_STATUS));
8650Sstevel@tonic-gate 
8660Sstevel@tonic-gate 	/*
8670Sstevel@tonic-gate 	 * CSR_V LPU_FLOW_CONTROL_UPDATE_CONTROL Expect OBP 0x7
8680Sstevel@tonic-gate 	 */
8690Sstevel@tonic-gate 
8700Sstevel@tonic-gate 	/*
8710Sstevel@tonic-gate 	 * The PRM says that only the first two bits will be set
8720Sstevel@tonic-gate 	 * high by default, which will enable flow control for
8730Sstevel@tonic-gate 	 * posted and non-posted updates, but NOT completetion
8740Sstevel@tonic-gate 	 * updates.
8750Sstevel@tonic-gate 	 */
8760Sstevel@tonic-gate 	val = (1ull << LPU_FLOW_CONTROL_UPDATE_CONTROL_FC0_U_NP_EN) |
87727Sjchu 	    (1ull << LPU_FLOW_CONTROL_UPDATE_CONTROL_FC0_U_P_EN);
8780Sstevel@tonic-gate 	CSR_XS(csr_base, LPU_FLOW_CONTROL_UPDATE_CONTROL, val);
8790Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
88027Sjchu 	    "lpu_init - LPU_FLOW_CONTROL_UPDATE_CONTROL: 0x%llx\n",
88127Sjchu 	    CSR_XR(csr_base, LPU_FLOW_CONTROL_UPDATE_CONTROL));
8820Sstevel@tonic-gate 
8830Sstevel@tonic-gate 	/*
8840Sstevel@tonic-gate 	 * CSR_V LPU_LINK_LAYER_FLOW_CONTROL_UPDATE_TIMEOUT_VALUE
8850Sstevel@tonic-gate 	 * Expect OBP 0x1D4C
8860Sstevel@tonic-gate 	 */
8870Sstevel@tonic-gate 
8880Sstevel@tonic-gate 	/*
8890Sstevel@tonic-gate 	 * This should be set by OBP.  We'll check to make sure.
8900Sstevel@tonic-gate 	 */
89127Sjchu 	DBG(DBG_LPU, NULL, "lpu_init - "
89227Sjchu 	    "LPU_LINK_LAYER_FLOW_CONTROL_UPDATE_TIMEOUT_VALUE: 0x%llx\n",
89327Sjchu 	    CSR_XR(csr_base,
89427Sjchu 	    LPU_LINK_LAYER_FLOW_CONTROL_UPDATE_TIMEOUT_VALUE));
8950Sstevel@tonic-gate 
8960Sstevel@tonic-gate 	/*
8970Sstevel@tonic-gate 	 * CSR_V LPU_LINK_LAYER_VC0_FLOW_CONTROL_UPDATE_TIMER0 Expect OBP ???
8980Sstevel@tonic-gate 	 */
8990Sstevel@tonic-gate 
9000Sstevel@tonic-gate 	/*
9010Sstevel@tonic-gate 	 * This register has Flow Control Update Timer values for
9020Sstevel@tonic-gate 	 * non-posted and posted requests, bits [30:16] and bits
9030Sstevel@tonic-gate 	 * [14:0], respectively.  These are read-only to SW so
9040Sstevel@tonic-gate 	 * either HW or OBP needs to set them.
9050Sstevel@tonic-gate 	 */
90627Sjchu 	DBG(DBG_LPU, NULL, "lpu_init - "
90727Sjchu 	    "LPU_LINK_LAYER_VC0_FLOW_CONTROL_UPDATE_TIMER0: 0x%llx\n",
90827Sjchu 	    CSR_XR(csr_base,
90927Sjchu 	    LPU_LINK_LAYER_VC0_FLOW_CONTROL_UPDATE_TIMER0));
9100Sstevel@tonic-gate 
9110Sstevel@tonic-gate 	/*
9120Sstevel@tonic-gate 	 * CSR_V LPU_LINK_LAYER_VC0_FLOW_CONTROL_UPDATE_TIMER1 Expect OBP ???
9130Sstevel@tonic-gate 	 */
9140Sstevel@tonic-gate 
9150Sstevel@tonic-gate 	/*
9160Sstevel@tonic-gate 	 * Same as timer0 register above, except for bits [14:0]
9170Sstevel@tonic-gate 	 * have the timer values for completetions.  Read-only to
9180Sstevel@tonic-gate 	 * SW; OBP or HW need to set it.
9190Sstevel@tonic-gate 	 */
92027Sjchu 	DBG(DBG_LPU, NULL, "lpu_init - "
92127Sjchu 	    "LPU_LINK_LAYER_VC0_FLOW_CONTROL_UPDATE_TIMER1: 0x%llx\n",
92227Sjchu 	    CSR_XR(csr_base,
92327Sjchu 	    LPU_LINK_LAYER_VC0_FLOW_CONTROL_UPDATE_TIMER1));
9240Sstevel@tonic-gate 
9250Sstevel@tonic-gate 	/*
9260Sstevel@tonic-gate 	 * CSR_V LPU_TXLINK_FREQUENT_NAK_LATENCY_TIMER_THRESHOLD
9270Sstevel@tonic-gate 	 */
928225Sess 	val = acknak_timer_table[max_payload][link_width];
929225Sess 	CSR_XS(csr_base, LPU_TXLINK_FREQUENT_NAK_LATENCY_TIMER_THRESHOLD, val);
9300Sstevel@tonic-gate 
9310Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - "
9320Sstevel@tonic-gate 	    "LPU_TXLINK_FREQUENT_NAK_LATENCY_TIMER_THRESHOLD: 0x%llx\n",
9330Sstevel@tonic-gate 	    CSR_XR(csr_base, LPU_TXLINK_FREQUENT_NAK_LATENCY_TIMER_THRESHOLD));
9340Sstevel@tonic-gate 
9350Sstevel@tonic-gate 	/*
9360Sstevel@tonic-gate 	 * CSR_V LPU_TXLINK_ACKNAK_LATENCY_TIMER Expect HW 0x0
9370Sstevel@tonic-gate 	 */
9380Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
93927Sjchu 	    "lpu_init - LPU_TXLINK_ACKNAK_LATENCY_TIMER: 0x%llx\n",
94027Sjchu 	    CSR_XR(csr_base, LPU_TXLINK_ACKNAK_LATENCY_TIMER));
9410Sstevel@tonic-gate 
9420Sstevel@tonic-gate 	/*
9430Sstevel@tonic-gate 	 * CSR_V LPU_TXLINK_REPLAY_TIMER_THRESHOLD
9440Sstevel@tonic-gate 	 */
945225Sess 	val = replay_timer_table[max_payload][link_width];
9460Sstevel@tonic-gate 	CSR_XS(csr_base, LPU_TXLINK_REPLAY_TIMER_THRESHOLD, val);
9470Sstevel@tonic-gate 
9480Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
9490Sstevel@tonic-gate 	    "lpu_init - LPU_TXLINK_REPLAY_TIMER_THRESHOLD: 0x%llx\n",
9500Sstevel@tonic-gate 	    CSR_XR(csr_base, LPU_TXLINK_REPLAY_TIMER_THRESHOLD));
9510Sstevel@tonic-gate 
9520Sstevel@tonic-gate 	/*
9530Sstevel@tonic-gate 	 * CSR_V LPU_TXLINK_REPLAY_TIMER Expect HW 0x0
9540Sstevel@tonic-gate 	 */
9550Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_TXLINK_REPLAY_TIMER: 0x%llx\n",
95627Sjchu 	    CSR_XR(csr_base, LPU_TXLINK_REPLAY_TIMER));
9570Sstevel@tonic-gate 
9580Sstevel@tonic-gate 	/*
9590Sstevel@tonic-gate 	 * CSR_V LPU_TXLINK_REPLAY_NUMBER_STATUS Expect OBP 0x3
9600Sstevel@tonic-gate 	 */
9610Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
96227Sjchu 	    "lpu_init - LPU_TXLINK_REPLAY_NUMBER_STATUS: 0x%llx\n",
96327Sjchu 	    CSR_XR(csr_base, LPU_TXLINK_REPLAY_NUMBER_STATUS));
9640Sstevel@tonic-gate 
9650Sstevel@tonic-gate 	/*
9660Sstevel@tonic-gate 	 * CSR_V LPU_REPLAY_BUFFER_MAX_ADDRESS Expect OBP 0xB3F
9670Sstevel@tonic-gate 	 */
9680Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
9690Sstevel@tonic-gate 	    "lpu_init - LPU_REPLAY_BUFFER_MAX_ADDRESS: 0x%llx\n",
9700Sstevel@tonic-gate 	    CSR_XR(csr_base, LPU_REPLAY_BUFFER_MAX_ADDRESS));
9710Sstevel@tonic-gate 
9720Sstevel@tonic-gate 	/*
9730Sstevel@tonic-gate 	 * CSR_V LPU_TXLINK_RETRY_FIFO_POINTER Expect OBP 0xFFFF0000
9740Sstevel@tonic-gate 	 */
9750Sstevel@tonic-gate 	val = ((LPU_TXLINK_RETRY_FIFO_POINTER_RTRY_FIFO_TLPTR_DEFAULT <<
97627Sjchu 	    LPU_TXLINK_RETRY_FIFO_POINTER_RTRY_FIFO_TLPTR) |
97727Sjchu 	    (LPU_TXLINK_RETRY_FIFO_POINTER_RTRY_FIFO_HDPTR_DEFAULT <<
97827Sjchu 	    LPU_TXLINK_RETRY_FIFO_POINTER_RTRY_FIFO_HDPTR));
9790Sstevel@tonic-gate 
9800Sstevel@tonic-gate 	CSR_XS(csr_base, LPU_TXLINK_RETRY_FIFO_POINTER, val);
9810Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
98227Sjchu 	    "lpu_init - LPU_TXLINK_RETRY_FIFO_POINTER: 0x%llx\n",
98327Sjchu 	    CSR_XR(csr_base, LPU_TXLINK_RETRY_FIFO_POINTER));
9840Sstevel@tonic-gate 
9850Sstevel@tonic-gate 	/*
9860Sstevel@tonic-gate 	 * CSR_V LPU_TXLINK_RETRY_FIFO_R_W_POINTER Expect OBP 0x0
9870Sstevel@tonic-gate 	 */
9880Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
9890Sstevel@tonic-gate 	    "lpu_init - LPU_TXLINK_RETRY_FIFO_R_W_POINTER: 0x%llx\n",
9900Sstevel@tonic-gate 	    CSR_XR(csr_base, LPU_TXLINK_RETRY_FIFO_R_W_POINTER));
9910Sstevel@tonic-gate 
9920Sstevel@tonic-gate 	/*
9930Sstevel@tonic-gate 	 * CSR_V LPU_TXLINK_RETRY_FIFO_CREDIT Expect HW 0x1580
9940Sstevel@tonic-gate 	 */
9950Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
99627Sjchu 	    "lpu_init - LPU_TXLINK_RETRY_FIFO_CREDIT: 0x%llx\n",
99727Sjchu 	    CSR_XR(csr_base, LPU_TXLINK_RETRY_FIFO_CREDIT));
9980Sstevel@tonic-gate 
9990Sstevel@tonic-gate 	/*
10000Sstevel@tonic-gate 	 * CSR_V LPU_TXLINK_SEQUENCE_COUNTER Expect OBP 0xFFF0000
10010Sstevel@tonic-gate 	 */
10020Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_TXLINK_SEQUENCE_COUNTER: 0x%llx\n",
100327Sjchu 	    CSR_XR(csr_base, LPU_TXLINK_SEQUENCE_COUNTER));
10040Sstevel@tonic-gate 
10050Sstevel@tonic-gate 	/*
10060Sstevel@tonic-gate 	 * CSR_V LPU_TXLINK_ACK_SENT_SEQUENCE_NUMBER Expect HW 0xFFF
10070Sstevel@tonic-gate 	 */
10080Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
100927Sjchu 	    "lpu_init - LPU_TXLINK_ACK_SENT_SEQUENCE_NUMBER: 0x%llx\n",
101027Sjchu 	    CSR_XR(csr_base, LPU_TXLINK_ACK_SENT_SEQUENCE_NUMBER));
10110Sstevel@tonic-gate 
10120Sstevel@tonic-gate 	/*
10130Sstevel@tonic-gate 	 * CSR_V LPU_TXLINK_SEQUENCE_COUNT_FIFO_MAX_ADDR Expect OBP 0x157
10140Sstevel@tonic-gate 	 */
10150Sstevel@tonic-gate 
10160Sstevel@tonic-gate 	/*
10170Sstevel@tonic-gate 	 * Test only register.  Will not be programmed.
10180Sstevel@tonic-gate 	 */
10190Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
102027Sjchu 	    "lpu_init - LPU_TXLINK_SEQUENCE_COUNT_FIFO_MAX_ADDR: 0x%llx\n",
102127Sjchu 	    CSR_XR(csr_base, LPU_TXLINK_SEQUENCE_COUNT_FIFO_MAX_ADDR));
10220Sstevel@tonic-gate 
10230Sstevel@tonic-gate 	/*
10240Sstevel@tonic-gate 	 * CSR_V LPU_TXLINK_SEQUENCE_COUNT_FIFO_POINTERS Expect HW 0xFFF0000
10250Sstevel@tonic-gate 	 */
10260Sstevel@tonic-gate 
10270Sstevel@tonic-gate 	/*
10280Sstevel@tonic-gate 	 * Test only register.  Will not be programmed.
10290Sstevel@tonic-gate 	 */
10300Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
103127Sjchu 	    "lpu_init - LPU_TXLINK_SEQUENCE_COUNT_FIFO_POINTERS: 0x%llx\n",
103227Sjchu 	    CSR_XR(csr_base, LPU_TXLINK_SEQUENCE_COUNT_FIFO_POINTERS));
10330Sstevel@tonic-gate 
10340Sstevel@tonic-gate 	/*
10350Sstevel@tonic-gate 	 * CSR_V LPU_TXLINK_SEQUENCE_COUNT_R_W_POINTERS Expect HW 0x0
10360Sstevel@tonic-gate 	 */
10370Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
103827Sjchu 	    "lpu_init - LPU_TXLINK_SEQUENCE_COUNT_R_W_POINTERS: 0x%llx\n",
103927Sjchu 	    CSR_XR(csr_base, LPU_TXLINK_SEQUENCE_COUNT_R_W_POINTERS));
10400Sstevel@tonic-gate 
10410Sstevel@tonic-gate 	/*
10420Sstevel@tonic-gate 	 * CSR_V LPU_TXLINK_TEST_CONTROL Expect HW 0x0
10430Sstevel@tonic-gate 	 */
10440Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_TXLINK_TEST_CONTROL: 0x%llx\n",
104527Sjchu 	    CSR_XR(csr_base, LPU_TXLINK_TEST_CONTROL));
10460Sstevel@tonic-gate 
10470Sstevel@tonic-gate 	/*
10480Sstevel@tonic-gate 	 * CSR_V LPU_TXLINK_MEMORY_ADDRESS_CONTROL Expect HW 0x0
10490Sstevel@tonic-gate 	 */
10500Sstevel@tonic-gate 
10510Sstevel@tonic-gate 	/*
10520Sstevel@tonic-gate 	 * Test only register.  Will not be programmed.
10530Sstevel@tonic-gate 	 */
10540Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
10550Sstevel@tonic-gate 	    "lpu_init - LPU_TXLINK_MEMORY_ADDRESS_CONTROL: 0x%llx\n",
10560Sstevel@tonic-gate 	    CSR_XR(csr_base, LPU_TXLINK_MEMORY_ADDRESS_CONTROL));
10570Sstevel@tonic-gate 
10580Sstevel@tonic-gate 	/*
10590Sstevel@tonic-gate 	 * CSR_V LPU_TXLINK_MEMORY_DATA_LOAD0 Expect HW 0x0
10600Sstevel@tonic-gate 	 */
10610Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
106227Sjchu 	    "lpu_init - LPU_TXLINK_MEMORY_DATA_LOAD0: 0x%llx\n",
106327Sjchu 	    CSR_XR(csr_base, LPU_TXLINK_MEMORY_DATA_LOAD0));
10640Sstevel@tonic-gate 
10650Sstevel@tonic-gate 	/*
10660Sstevel@tonic-gate 	 * CSR_V LPU_TXLINK_MEMORY_DATA_LOAD1 Expect HW 0x0
10670Sstevel@tonic-gate 	 */
10680Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
106927Sjchu 	    "lpu_init - LPU_TXLINK_MEMORY_DATA_LOAD1: 0x%llx\n",
107027Sjchu 	    CSR_XR(csr_base, LPU_TXLINK_MEMORY_DATA_LOAD1));
10710Sstevel@tonic-gate 
10720Sstevel@tonic-gate 	/*
10730Sstevel@tonic-gate 	 * CSR_V LPU_TXLINK_MEMORY_DATA_LOAD2 Expect HW 0x0
10740Sstevel@tonic-gate 	 */
10750Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
107627Sjchu 	    "lpu_init - LPU_TXLINK_MEMORY_DATA_LOAD2: 0x%llx\n",
107727Sjchu 	    CSR_XR(csr_base, LPU_TXLINK_MEMORY_DATA_LOAD2));
10780Sstevel@tonic-gate 
10790Sstevel@tonic-gate 	/*
10800Sstevel@tonic-gate 	 * CSR_V LPU_TXLINK_MEMORY_DATA_LOAD3 Expect HW 0x0
10810Sstevel@tonic-gate 	 */
10820Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
108327Sjchu 	    "lpu_init - LPU_TXLINK_MEMORY_DATA_LOAD3: 0x%llx\n",
108427Sjchu 	    CSR_XR(csr_base, LPU_TXLINK_MEMORY_DATA_LOAD3));
10850Sstevel@tonic-gate 
10860Sstevel@tonic-gate 	/*
10870Sstevel@tonic-gate 	 * CSR_V LPU_TXLINK_MEMORY_DATA_LOAD4 Expect HW 0x0
10880Sstevel@tonic-gate 	 */
10890Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
109027Sjchu 	    "lpu_init - LPU_TXLINK_MEMORY_DATA_LOAD4: 0x%llx\n",
109127Sjchu 	    CSR_XR(csr_base, LPU_TXLINK_MEMORY_DATA_LOAD4));
10920Sstevel@tonic-gate 
10930Sstevel@tonic-gate 	/*
10940Sstevel@tonic-gate 	 * CSR_V LPU_TXLINK_RETRY_DATA_COUNT Expect HW 0x0
10950Sstevel@tonic-gate 	 */
10960Sstevel@tonic-gate 
10970Sstevel@tonic-gate 	/*
10980Sstevel@tonic-gate 	 * Test only register.  Will not be programmed.
10990Sstevel@tonic-gate 	 */
11000Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_TXLINK_RETRY_DATA_COUNT: 0x%llx\n",
110127Sjchu 	    CSR_XR(csr_base, LPU_TXLINK_RETRY_DATA_COUNT));
11020Sstevel@tonic-gate 
11030Sstevel@tonic-gate 	/*
11040Sstevel@tonic-gate 	 * CSR_V LPU_TXLINK_SEQUENCE_BUFFER_COUNT Expect HW 0x0
11050Sstevel@tonic-gate 	 */
11060Sstevel@tonic-gate 
11070Sstevel@tonic-gate 	/*
11080Sstevel@tonic-gate 	 * Test only register.  Will not be programmed.
11090Sstevel@tonic-gate 	 */
11100Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
111127Sjchu 	    "lpu_init - LPU_TXLINK_SEQUENCE_BUFFER_COUNT: 0x%llx\n",
111227Sjchu 	    CSR_XR(csr_base, LPU_TXLINK_SEQUENCE_BUFFER_COUNT));
11130Sstevel@tonic-gate 
11140Sstevel@tonic-gate 	/*
11150Sstevel@tonic-gate 	 * CSR_V LPU_TXLINK_SEQUENCE_BUFFER_BOTTOM_DATA Expect HW 0x0
11160Sstevel@tonic-gate 	 */
11170Sstevel@tonic-gate 
11180Sstevel@tonic-gate 	/*
11190Sstevel@tonic-gate 	 * Test only register.
11200Sstevel@tonic-gate 	 */
11210Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
112227Sjchu 	    "lpu_init - LPU_TXLINK_SEQUENCE_BUFFER_BOTTOM_DATA: 0x%llx\n",
112327Sjchu 	    CSR_XR(csr_base, LPU_TXLINK_SEQUENCE_BUFFER_BOTTOM_DATA));
11240Sstevel@tonic-gate 
11250Sstevel@tonic-gate 	/*
11260Sstevel@tonic-gate 	 * CSR_V LPU_RXLINK_NEXT_RECEIVE_SEQUENCE_1_COUNTER Expect HW 0x0
11270Sstevel@tonic-gate 	 */
11280Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - "
112927Sjchu 	    "LPU_RXLINK_NEXT_RECEIVE_SEQUENCE_1_COUNTER: 0x%llx\n",
113027Sjchu 	    CSR_XR(csr_base, LPU_RXLINK_NEXT_RECEIVE_SEQUENCE_1_COUNTER));
11310Sstevel@tonic-gate 
11320Sstevel@tonic-gate 	/*
11330Sstevel@tonic-gate 	 * CSR_V LPU_RXLINK_UNSUPPORTED_DLLP_RECEIVED Expect HW 0x0
11340Sstevel@tonic-gate 	 */
11350Sstevel@tonic-gate 
11360Sstevel@tonic-gate 	/*
11370Sstevel@tonic-gate 	 * test only register.
11380Sstevel@tonic-gate 	 */
11390Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
114027Sjchu 	    "lpu_init - LPU_RXLINK_UNSUPPORTED_DLLP_RECEIVED: 0x%llx\n",
114127Sjchu 	    CSR_XR(csr_base, LPU_RXLINK_UNSUPPORTED_DLLP_RECEIVED));
11420Sstevel@tonic-gate 
11430Sstevel@tonic-gate 	/*
11440Sstevel@tonic-gate 	 * CSR_V LPU_RXLINK_TEST_CONTROL Expect HW 0x0
11450Sstevel@tonic-gate 	 */
11460Sstevel@tonic-gate 
11470Sstevel@tonic-gate 	/*
11480Sstevel@tonic-gate 	 * test only register.
11490Sstevel@tonic-gate 	 */
11500Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_RXLINK_TEST_CONTROL: 0x%llx\n",
115127Sjchu 	    CSR_XR(csr_base, LPU_RXLINK_TEST_CONTROL));
11520Sstevel@tonic-gate 
11530Sstevel@tonic-gate 	/*
11540Sstevel@tonic-gate 	 * CSR_V LPU_PHYSICAL_LAYER_CONFIGURATION Expect HW 0x10
11550Sstevel@tonic-gate 	 */
11560Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
115727Sjchu 	    "lpu_init - LPU_PHYSICAL_LAYER_CONFIGURATION: 0x%llx\n",
115827Sjchu 	    CSR_XR(csr_base, LPU_PHYSICAL_LAYER_CONFIGURATION));
11590Sstevel@tonic-gate 
11600Sstevel@tonic-gate 	/*
11610Sstevel@tonic-gate 	 * CSR_V LPU_PHY_LAYER_STATUS Expect HW 0x0
11620Sstevel@tonic-gate 	 */
11630Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_PHY_LAYER_STATUS: 0x%llx\n",
116427Sjchu 	    CSR_XR(csr_base, LPU_PHY_LAYER_STATUS));
11650Sstevel@tonic-gate 
11660Sstevel@tonic-gate 	/*
11670Sstevel@tonic-gate 	 * CSR_V LPU_PHY_INTERRUPT_AND_STATUS_TEST Expect HW 0x0
11680Sstevel@tonic-gate 	 */
11690Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
11700Sstevel@tonic-gate 	    "lpu_init - LPU_PHY_INTERRUPT_AND_STATUS_TEST: 0x%llx\n",
11710Sstevel@tonic-gate 	    CSR_XR(csr_base, LPU_PHY_INTERRUPT_AND_STATUS_TEST));
11720Sstevel@tonic-gate 
11730Sstevel@tonic-gate 	/*
117427Sjchu 	 * CSR_V LPU PHY LAYER interrupt regs (mask, status)
11750Sstevel@tonic-gate 	 */
11760Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_PHY_INTERRUPT_MASK: 0x%llx\n",
117727Sjchu 	    CSR_XR(csr_base, LPU_PHY_INTERRUPT_MASK));
117827Sjchu 
117927Sjchu 	DBG(DBG_LPU, NULL,
118027Sjchu 	    "lpu_init - LPU_PHY_LAYER_INTERRUPT_AND_STATUS: 0x%llx\n",
118127Sjchu 	    CSR_XR(csr_base, LPU_PHY_LAYER_INTERRUPT_AND_STATUS));
11820Sstevel@tonic-gate 
11830Sstevel@tonic-gate 	/*
11840Sstevel@tonic-gate 	 * CSR_V LPU_RECEIVE_PHY_CONFIG Expect HW 0x0
11850Sstevel@tonic-gate 	 */
11860Sstevel@tonic-gate 
11870Sstevel@tonic-gate 	/*
11880Sstevel@tonic-gate 	 * This also needs some explanation.  What is the best value
11890Sstevel@tonic-gate 	 * for the water mark?  Test mode enables which test mode?
11900Sstevel@tonic-gate 	 * Programming model needed for the Receiver Reset Lane N
11910Sstevel@tonic-gate 	 * bits.
11920Sstevel@tonic-gate 	 */
11930Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_RECEIVE_PHY_CONFIG: 0x%llx\n",
119427Sjchu 	    CSR_XR(csr_base, LPU_RECEIVE_PHY_CONFIG));
11950Sstevel@tonic-gate 
11960Sstevel@tonic-gate 	/*
11970Sstevel@tonic-gate 	 * CSR_V LPU_RECEIVE_PHY_STATUS1 Expect HW 0x0
11980Sstevel@tonic-gate 	 */
11990Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_RECEIVE_PHY_STATUS1: 0x%llx\n",
120027Sjchu 	    CSR_XR(csr_base, LPU_RECEIVE_PHY_STATUS1));
12010Sstevel@tonic-gate 
12020Sstevel@tonic-gate 	/*
12030Sstevel@tonic-gate 	 * CSR_V LPU_RECEIVE_PHY_STATUS2 Expect HW 0x0
12040Sstevel@tonic-gate 	 */
12050Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_RECEIVE_PHY_STATUS2: 0x%llx\n",
120627Sjchu 	    CSR_XR(csr_base, LPU_RECEIVE_PHY_STATUS2));
12070Sstevel@tonic-gate 
12080Sstevel@tonic-gate 	/*
12090Sstevel@tonic-gate 	 * CSR_V LPU_RECEIVE_PHY_STATUS3 Expect HW 0x0
12100Sstevel@tonic-gate 	 */
12110Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_RECEIVE_PHY_STATUS3: 0x%llx\n",
121227Sjchu 	    CSR_XR(csr_base, LPU_RECEIVE_PHY_STATUS3));
12130Sstevel@tonic-gate 
12140Sstevel@tonic-gate 	/*
12150Sstevel@tonic-gate 	 * CSR_V LPU_RECEIVE_PHY_INTERRUPT_AND_STATUS_TEST Expect HW 0x0
12160Sstevel@tonic-gate 	 */
12170Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
12180Sstevel@tonic-gate 	    "lpu_init - LPU_RECEIVE_PHY_INTERRUPT_AND_STATUS_TEST: 0x%llx\n",
12190Sstevel@tonic-gate 	    CSR_XR(csr_base, LPU_RECEIVE_PHY_INTERRUPT_AND_STATUS_TEST));
12200Sstevel@tonic-gate 
12210Sstevel@tonic-gate 	/*
122227Sjchu 	 * CSR_V LPU RX LAYER interrupt regs (mask, status)
12230Sstevel@tonic-gate 	 */
12240Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
122527Sjchu 	    "lpu_init - LPU_RECEIVE_PHY_INTERRUPT_MASK: 0x%llx\n",
122627Sjchu 	    CSR_XR(csr_base, LPU_RECEIVE_PHY_INTERRUPT_MASK));
122727Sjchu 
122827Sjchu 	DBG(DBG_LPU, NULL,
122927Sjchu 	    "lpu_init - LPU_RECEIVE_PHY_INTERRUPT_AND_STATUS: 0x%llx\n",
123027Sjchu 	    CSR_XR(csr_base, LPU_RECEIVE_PHY_INTERRUPT_AND_STATUS));
12310Sstevel@tonic-gate 
12320Sstevel@tonic-gate 	/*
12330Sstevel@tonic-gate 	 * CSR_V LPU_TRANSMIT_PHY_CONFIG Expect HW 0x0
12340Sstevel@tonic-gate 	 */
12350Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_TRANSMIT_PHY_CONFIG: 0x%llx\n",
123627Sjchu 	    CSR_XR(csr_base, LPU_TRANSMIT_PHY_CONFIG));
12370Sstevel@tonic-gate 
12380Sstevel@tonic-gate 	/*
12390Sstevel@tonic-gate 	 * CSR_V LPU_TRANSMIT_PHY_STATUS Expect HW 0x0
12400Sstevel@tonic-gate 	 */
12410Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_TRANSMIT_PHY_STATUS: 0x%llx\n",
12420Sstevel@tonic-gate 		CSR_XR(csr_base, LPU_TRANSMIT_PHY_STATUS));
12430Sstevel@tonic-gate 
12440Sstevel@tonic-gate 	/*
12450Sstevel@tonic-gate 	 * CSR_V LPU_TRANSMIT_PHY_INTERRUPT_AND_STATUS_TEST Expect HW 0x0
12460Sstevel@tonic-gate 	 */
12470Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
12480Sstevel@tonic-gate 	    "lpu_init - LPU_TRANSMIT_PHY_INTERRUPT_AND_STATUS_TEST: 0x%llx\n",
12490Sstevel@tonic-gate 	    CSR_XR(csr_base,
12500Sstevel@tonic-gate 	    LPU_TRANSMIT_PHY_INTERRUPT_AND_STATUS_TEST));
12510Sstevel@tonic-gate 
12520Sstevel@tonic-gate 	/*
125327Sjchu 	 * CSR_V LPU TX LAYER interrupt regs (mask, status)
12540Sstevel@tonic-gate 	 */
12550Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
125627Sjchu 	    "lpu_init - LPU_TRANSMIT_PHY_INTERRUPT_MASK: 0x%llx\n",
125727Sjchu 	    CSR_XR(csr_base, LPU_TRANSMIT_PHY_INTERRUPT_MASK));
125827Sjchu 
125927Sjchu 	DBG(DBG_LPU, NULL,
126027Sjchu 	    "lpu_init - LPU_TRANSMIT_PHY_INTERRUPT_AND_STATUS: 0x%llx\n",
126127Sjchu 	    CSR_XR(csr_base, LPU_TRANSMIT_PHY_INTERRUPT_AND_STATUS));
12620Sstevel@tonic-gate 
12630Sstevel@tonic-gate 	/*
12640Sstevel@tonic-gate 	 * CSR_V LPU_TRANSMIT_PHY_STATUS_2 Expect HW 0x0
12650Sstevel@tonic-gate 	 */
12660Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_TRANSMIT_PHY_STATUS_2: 0x%llx\n",
126727Sjchu 	    CSR_XR(csr_base, LPU_TRANSMIT_PHY_STATUS_2));
12680Sstevel@tonic-gate 
12690Sstevel@tonic-gate 	/*
12700Sstevel@tonic-gate 	 * CSR_V LPU_LTSSM_CONFIG1 Expect OBP 0x205
12710Sstevel@tonic-gate 	 */
12720Sstevel@tonic-gate 
12730Sstevel@tonic-gate 	/*
12740Sstevel@tonic-gate 	 * The new PRM has values for LTSSM 8 ns timeout value and
12750Sstevel@tonic-gate 	 * LTSSM 20 ns timeout value.  But what do these values mean?
12760Sstevel@tonic-gate 	 * Most of the other bits are questions as well.
12770Sstevel@tonic-gate 	 *
12780Sstevel@tonic-gate 	 * As such we will use the reset value.
12790Sstevel@tonic-gate 	 */
12800Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_LTSSM_CONFIG1: 0x%llx\n",
128127Sjchu 	    CSR_XR(csr_base, LPU_LTSSM_CONFIG1));
12820Sstevel@tonic-gate 
12830Sstevel@tonic-gate 	/*
12840Sstevel@tonic-gate 	 * CSR_V LPU_LTSSM_CONFIG2 Expect OBP 0x2DC6C0
12850Sstevel@tonic-gate 	 */
12860Sstevel@tonic-gate 
12870Sstevel@tonic-gate 	/*
12880Sstevel@tonic-gate 	 * Again, what does '12 ms timeout value mean'?
12890Sstevel@tonic-gate 	 */
12900Sstevel@tonic-gate 	val = (LPU_LTSSM_CONFIG2_LTSSM_12_TO_DEFAULT <<
129127Sjchu 	    LPU_LTSSM_CONFIG2_LTSSM_12_TO);
12920Sstevel@tonic-gate 	CSR_XS(csr_base, LPU_LTSSM_CONFIG2, val);
12930Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_LTSSM_CONFIG2: 0x%llx\n",
129427Sjchu 	    CSR_XR(csr_base, LPU_LTSSM_CONFIG2));
12950Sstevel@tonic-gate 
12960Sstevel@tonic-gate 	/*
12970Sstevel@tonic-gate 	 * CSR_V LPU_LTSSM_CONFIG3 Expect OBP 0x7A120
12980Sstevel@tonic-gate 	 */
12990Sstevel@tonic-gate 	val = (LPU_LTSSM_CONFIG3_LTSSM_2_TO_DEFAULT <<
130027Sjchu 	    LPU_LTSSM_CONFIG3_LTSSM_2_TO);
13010Sstevel@tonic-gate 	CSR_XS(csr_base, LPU_LTSSM_CONFIG3, val);
13020Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_LTSSM_CONFIG3: 0x%llx\n",
130327Sjchu 	    CSR_XR(csr_base, LPU_LTSSM_CONFIG3));
13040Sstevel@tonic-gate 
13050Sstevel@tonic-gate 	/*
13060Sstevel@tonic-gate 	 * CSR_V LPU_LTSSM_CONFIG4 Expect OBP 0x21300
13070Sstevel@tonic-gate 	 */
13080Sstevel@tonic-gate 	val = ((LPU_LTSSM_CONFIG4_DATA_RATE_DEFAULT <<
130927Sjchu 	    LPU_LTSSM_CONFIG4_DATA_RATE) |
13100Sstevel@tonic-gate 		(LPU_LTSSM_CONFIG4_N_FTS_DEFAULT <<
13110Sstevel@tonic-gate 		LPU_LTSSM_CONFIG4_N_FTS));
13120Sstevel@tonic-gate 	CSR_XS(csr_base, LPU_LTSSM_CONFIG4, val);
13130Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_LTSSM_CONFIG4: 0x%llx\n",
131427Sjchu 	    CSR_XR(csr_base, LPU_LTSSM_CONFIG4));
13150Sstevel@tonic-gate 
13160Sstevel@tonic-gate 	/*
13170Sstevel@tonic-gate 	 * CSR_V LPU_LTSSM_CONFIG5 Expect OBP 0x0
13180Sstevel@tonic-gate 	 */
13190Sstevel@tonic-gate 	val = 0ull;
13200Sstevel@tonic-gate 	CSR_XS(csr_base, LPU_LTSSM_CONFIG5, val);
13210Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_LTSSM_CONFIG5: 0x%llx\n",
132227Sjchu 	    CSR_XR(csr_base, LPU_LTSSM_CONFIG5));
13230Sstevel@tonic-gate 
13240Sstevel@tonic-gate 	/*
13250Sstevel@tonic-gate 	 * CSR_V LPU_LTSSM_STATUS1 Expect OBP 0x0
13260Sstevel@tonic-gate 	 */
13270Sstevel@tonic-gate 
13280Sstevel@tonic-gate 	/*
13290Sstevel@tonic-gate 	 * LTSSM Status registers are test only.
13300Sstevel@tonic-gate 	 */
13310Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_LTSSM_STATUS1: 0x%llx\n",
133227Sjchu 	    CSR_XR(csr_base, LPU_LTSSM_STATUS1));
13330Sstevel@tonic-gate 
13340Sstevel@tonic-gate 	/*
13350Sstevel@tonic-gate 	 * CSR_V LPU_LTSSM_STATUS2 Expect OBP 0x0
13360Sstevel@tonic-gate 	 */
13370Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_LTSSM_STATUS2: 0x%llx\n",
133827Sjchu 	    CSR_XR(csr_base, LPU_LTSSM_STATUS2));
13390Sstevel@tonic-gate 
13400Sstevel@tonic-gate 	/*
13410Sstevel@tonic-gate 	 * CSR_V LPU_LTSSM_INTERRUPT_AND_STATUS_TEST Expect HW 0x0
13420Sstevel@tonic-gate 	 */
13430Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
134427Sjchu 	    "lpu_init - LPU_LTSSM_INTERRUPT_AND_STATUS_TEST: 0x%llx\n",
134527Sjchu 	    CSR_XR(csr_base, LPU_LTSSM_INTERRUPT_AND_STATUS_TEST));
13460Sstevel@tonic-gate 
13470Sstevel@tonic-gate 	/*
134827Sjchu 	 * CSR_V LPU LTSSM  LAYER interrupt regs (mask, status)
13490Sstevel@tonic-gate 	 */
13500Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_LTSSM_INTERRUPT_MASK: 0x%llx\n",
135127Sjchu 	    CSR_XR(csr_base, LPU_LTSSM_INTERRUPT_MASK));
135227Sjchu 
135327Sjchu 	DBG(DBG_LPU, NULL,
135427Sjchu 	    "lpu_init - LPU_LTSSM_INTERRUPT_AND_STATUS: 0x%llx\n",
135527Sjchu 	    CSR_XR(csr_base, LPU_LTSSM_INTERRUPT_AND_STATUS));
13560Sstevel@tonic-gate 
13570Sstevel@tonic-gate 	/*
13580Sstevel@tonic-gate 	 * CSR_V LPU_LTSSM_STATUS_WRITE_ENABLE Expect OBP 0x0
13590Sstevel@tonic-gate 	 */
13600Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
136127Sjchu 	    "lpu_init - LPU_LTSSM_STATUS_WRITE_ENABLE: 0x%llx\n",
136227Sjchu 	    CSR_XR(csr_base, LPU_LTSSM_STATUS_WRITE_ENABLE));
13630Sstevel@tonic-gate 
13640Sstevel@tonic-gate 	/*
13650Sstevel@tonic-gate 	 * CSR_V LPU_GIGABLAZE_GLUE_CONFIG1 Expect OBP 0x88407
13660Sstevel@tonic-gate 	 */
13670Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_GIGABLAZE_GLUE_CONFIG1: 0x%llx\n",
136827Sjchu 	    CSR_XR(csr_base, LPU_GIGABLAZE_GLUE_CONFIG1));
13690Sstevel@tonic-gate 
13700Sstevel@tonic-gate 	/*
13710Sstevel@tonic-gate 	 * CSR_V LPU_GIGABLAZE_GLUE_CONFIG2 Expect OBP 0x35
13720Sstevel@tonic-gate 	 */
13730Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_GIGABLAZE_GLUE_CONFIG2: 0x%llx\n",
137427Sjchu 	    CSR_XR(csr_base, LPU_GIGABLAZE_GLUE_CONFIG2));
13750Sstevel@tonic-gate 
13760Sstevel@tonic-gate 	/*
13770Sstevel@tonic-gate 	 * CSR_V LPU_GIGABLAZE_GLUE_CONFIG3 Expect OBP 0x4400FA
13780Sstevel@tonic-gate 	 */
13790Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_GIGABLAZE_GLUE_CONFIG3: 0x%llx\n",
138027Sjchu 	    CSR_XR(csr_base, LPU_GIGABLAZE_GLUE_CONFIG3));
13810Sstevel@tonic-gate 
13820Sstevel@tonic-gate 	/*
13830Sstevel@tonic-gate 	 * CSR_V LPU_GIGABLAZE_GLUE_CONFIG4 Expect OBP 0x1E848
13840Sstevel@tonic-gate 	 */
13850Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_GIGABLAZE_GLUE_CONFIG4: 0x%llx\n",
138627Sjchu 	    CSR_XR(csr_base, LPU_GIGABLAZE_GLUE_CONFIG4));
13870Sstevel@tonic-gate 
13880Sstevel@tonic-gate 	/*
13890Sstevel@tonic-gate 	 * CSR_V LPU_GIGABLAZE_GLUE_STATUS Expect OBP 0x0
13900Sstevel@tonic-gate 	 */
13910Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_GIGABLAZE_GLUE_STATUS: 0x%llx\n",
139227Sjchu 	    CSR_XR(csr_base, LPU_GIGABLAZE_GLUE_STATUS));
13930Sstevel@tonic-gate 
13940Sstevel@tonic-gate 	/*
13950Sstevel@tonic-gate 	 * CSR_V LPU_GIGABLAZE_GLUE_INTERRUPT_AND_STATUS_TEST Expect OBP 0x0
13960Sstevel@tonic-gate 	 */
139727Sjchu 	DBG(DBG_LPU, NULL, "lpu_init - "
139827Sjchu 	    "LPU_GIGABLAZE_GLUE_INTERRUPT_AND_STATUS_TEST: 0x%llx\n",
139927Sjchu 	    CSR_XR(csr_base,
140027Sjchu 	    LPU_GIGABLAZE_GLUE_INTERRUPT_AND_STATUS_TEST));
14010Sstevel@tonic-gate 
14020Sstevel@tonic-gate 	/*
140327Sjchu 	 * CSR_V LPU GIGABLASE LAYER interrupt regs (mask, status)
14040Sstevel@tonic-gate 	 */
14050Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
14060Sstevel@tonic-gate 	    "lpu_init - LPU_GIGABLAZE_GLUE_INTERRUPT_MASK: 0x%llx\n",
14070Sstevel@tonic-gate 	    CSR_XR(csr_base, LPU_GIGABLAZE_GLUE_INTERRUPT_MASK));
14080Sstevel@tonic-gate 
140927Sjchu 	DBG(DBG_LPU, NULL,
141027Sjchu 	    "lpu_init - LPU_GIGABLAZE_GLUE_INTERRUPT_AND_STATUS: 0x%llx\n",
141127Sjchu 	    CSR_XR(csr_base, LPU_GIGABLAZE_GLUE_INTERRUPT_AND_STATUS));
141227Sjchu 
14130Sstevel@tonic-gate 	/*
14140Sstevel@tonic-gate 	 * CSR_V LPU_GIGABLAZE_GLUE_POWER_DOWN1 Expect HW 0x0
14150Sstevel@tonic-gate 	 */
14160Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
141727Sjchu 	    "lpu_init - LPU_GIGABLAZE_GLUE_POWER_DOWN1: 0x%llx\n",
141827Sjchu 	    CSR_XR(csr_base, LPU_GIGABLAZE_GLUE_POWER_DOWN1));
14190Sstevel@tonic-gate 
14200Sstevel@tonic-gate 	/*
14210Sstevel@tonic-gate 	 * CSR_V LPU_GIGABLAZE_GLUE_POWER_DOWN2 Expect HW 0x0
14220Sstevel@tonic-gate 	 */
14230Sstevel@tonic-gate 	DBG(DBG_LPU, NULL,
142427Sjchu 	    "lpu_init - LPU_GIGABLAZE_GLUE_POWER_DOWN2: 0x%llx\n",
142527Sjchu 	    CSR_XR(csr_base, LPU_GIGABLAZE_GLUE_POWER_DOWN2));
14260Sstevel@tonic-gate 
14270Sstevel@tonic-gate 	/*
14280Sstevel@tonic-gate 	 * CSR_V LPU_GIGABLAZE_GLUE_CONFIG5 Expect OBP 0x0
14290Sstevel@tonic-gate 	 */
14300Sstevel@tonic-gate 	DBG(DBG_LPU, NULL, "lpu_init - LPU_GIGABLAZE_GLUE_CONFIG5: 0x%llx\n",
143127Sjchu 	    CSR_XR(csr_base, LPU_GIGABLAZE_GLUE_CONFIG5));
14320Sstevel@tonic-gate }
14330Sstevel@tonic-gate 
14340Sstevel@tonic-gate /* ARGSUSED */
14350Sstevel@tonic-gate static void
14360Sstevel@tonic-gate dmc_init(caddr_t csr_base, pxu_t *pxu_p)
14370Sstevel@tonic-gate {
14380Sstevel@tonic-gate 	uint64_t val;
14390Sstevel@tonic-gate 
14400Sstevel@tonic-gate /*
14410Sstevel@tonic-gate  * CSR_V DMC_CORE_AND_BLOCK_INTERRUPT_ENABLE Expect OBP 0x8000000000000003
14420Sstevel@tonic-gate  */
14430Sstevel@tonic-gate 
14440Sstevel@tonic-gate 	val = -1ull;
14450Sstevel@tonic-gate 	CSR_XS(csr_base, DMC_CORE_AND_BLOCK_INTERRUPT_ENABLE, val);
14460Sstevel@tonic-gate 	DBG(DBG_DMC, NULL,
144727Sjchu 	    "dmc_init - DMC_CORE_AND_BLOCK_INTERRUPT_ENABLE: 0x%llx\n",
144827Sjchu 	    CSR_XR(csr_base, DMC_CORE_AND_BLOCK_INTERRUPT_ENABLE));
14490Sstevel@tonic-gate 
14500Sstevel@tonic-gate 	/*
14510Sstevel@tonic-gate 	 * CSR_V DMC_CORE_AND_BLOCK_ERROR_STATUS Expect HW 0x0
14520Sstevel@tonic-gate 	 */
14530Sstevel@tonic-gate 	DBG(DBG_DMC, NULL,
145427Sjchu 	    "dmc_init - DMC_CORE_AND_BLOCK_ERROR_STATUS: 0x%llx\n",
145527Sjchu 	    CSR_XR(csr_base, DMC_CORE_AND_BLOCK_ERROR_STATUS));
14560Sstevel@tonic-gate 
14570Sstevel@tonic-gate 	/*
14580Sstevel@tonic-gate 	 * CSR_V DMC_DEBUG_SELECT_FOR_PORT_A Expect HW 0x0
14590Sstevel@tonic-gate 	 */
14600Sstevel@tonic-gate 	val = 0x0ull;
14610Sstevel@tonic-gate 	CSR_XS(csr_base, DMC_DEBUG_SELECT_FOR_PORT_A, val);
14620Sstevel@tonic-gate 	DBG(DBG_DMC, NULL, "dmc_init - DMC_DEBUG_SELECT_FOR_PORT_A: 0x%llx\n",
146327Sjchu 	    CSR_XR(csr_base, DMC_DEBUG_SELECT_FOR_PORT_A));
14640Sstevel@tonic-gate 
14650Sstevel@tonic-gate 	/*
14660Sstevel@tonic-gate 	 * CSR_V DMC_DEBUG_SELECT_FOR_PORT_B Expect HW 0x0
14670Sstevel@tonic-gate 	 */
14680Sstevel@tonic-gate 	val = 0x0ull;
14690Sstevel@tonic-gate 	CSR_XS(csr_base, DMC_DEBUG_SELECT_FOR_PORT_B, val);
14700Sstevel@tonic-gate 	DBG(DBG_DMC, NULL, "dmc_init - DMC_DEBUG_SELECT_FOR_PORT_B: 0x%llx\n",
147127Sjchu 	    CSR_XR(csr_base, DMC_DEBUG_SELECT_FOR_PORT_B));
14720Sstevel@tonic-gate }
14730Sstevel@tonic-gate 
14740Sstevel@tonic-gate void
14750Sstevel@tonic-gate hvio_pec_init(caddr_t csr_base, pxu_t *pxu_p)
14760Sstevel@tonic-gate {
14770Sstevel@tonic-gate 	uint64_t val;
14780Sstevel@tonic-gate 
14790Sstevel@tonic-gate 	ilu_init(csr_base, pxu_p);
14800Sstevel@tonic-gate 	tlu_init(csr_base, pxu_p);
14810Sstevel@tonic-gate 	lpu_init(csr_base, pxu_p);
14820Sstevel@tonic-gate 	dmc_init(csr_base, pxu_p);
14830Sstevel@tonic-gate 
14840Sstevel@tonic-gate /*
14850Sstevel@tonic-gate  * CSR_V PEC_CORE_AND_BLOCK_INTERRUPT_ENABLE Expect Kernel 0x800000000000000F
14860Sstevel@tonic-gate  */
14870Sstevel@tonic-gate 
14880Sstevel@tonic-gate 	val = -1ull;
14890Sstevel@tonic-gate 	CSR_XS(csr_base, PEC_CORE_AND_BLOCK_INTERRUPT_ENABLE, val);
14900Sstevel@tonic-gate 	DBG(DBG_PEC, NULL,
149127Sjchu 	    "hvio_pec_init - PEC_CORE_AND_BLOCK_INTERRUPT_ENABLE: 0x%llx\n",
149227Sjchu 	    CSR_XR(csr_base, PEC_CORE_AND_BLOCK_INTERRUPT_ENABLE));
14930Sstevel@tonic-gate 
14940Sstevel@tonic-gate 	/*
14950Sstevel@tonic-gate 	 * CSR_V PEC_CORE_AND_BLOCK_INTERRUPT_STATUS Expect HW 0x0
14960Sstevel@tonic-gate 	 */
14970Sstevel@tonic-gate 	DBG(DBG_PEC, NULL,
149827Sjchu 	    "hvio_pec_init - PEC_CORE_AND_BLOCK_INTERRUPT_STATUS: 0x%llx\n",
149927Sjchu 	    CSR_XR(csr_base, PEC_CORE_AND_BLOCK_INTERRUPT_STATUS));
15000Sstevel@tonic-gate }
15010Sstevel@tonic-gate 
150227Sjchu /*
150327Sjchu  * Initialize the module, but do not enable interrupts.
150427Sjchu  */
15050Sstevel@tonic-gate void
15060Sstevel@tonic-gate hvio_mmu_init(caddr_t csr_base, pxu_t *pxu_p)
15070Sstevel@tonic-gate {
15080Sstevel@tonic-gate 	uint64_t	val, i, tsb_ctrl, obp_tsb_pa, *base_tte_addr;
15090Sstevel@tonic-gate 	uint_t		obp_tsb_entries, obp_tsb_size;
15100Sstevel@tonic-gate 
15110Sstevel@tonic-gate 	bzero(pxu_p->tsb_vaddr, pxu_p->tsb_size);
15120Sstevel@tonic-gate 
15130Sstevel@tonic-gate 	/*
15140Sstevel@tonic-gate 	 * Preserve OBP's TSB
15150Sstevel@tonic-gate 	 */
15160Sstevel@tonic-gate 	val = CSR_XR(csr_base, MMU_TSB_CONTROL);
15170Sstevel@tonic-gate 
15180Sstevel@tonic-gate 	tsb_ctrl = CSR_XR(csr_base, MMU_TSB_CONTROL);
15190Sstevel@tonic-gate 
15200Sstevel@tonic-gate 	obp_tsb_pa = tsb_ctrl &  0x7FFFFFFE000;
15210Sstevel@tonic-gate 	obp_tsb_size = tsb_ctrl & 0xF;
15220Sstevel@tonic-gate 
15230Sstevel@tonic-gate 	obp_tsb_entries = MMU_TSBSIZE_TO_TSBENTRIES(obp_tsb_size);
15240Sstevel@tonic-gate 
15250Sstevel@tonic-gate 	base_tte_addr = pxu_p->tsb_vaddr +
15260Sstevel@tonic-gate 		((pxu_p->tsb_size >> 3) - obp_tsb_entries);
15270Sstevel@tonic-gate 
15280Sstevel@tonic-gate 	for (i = 0; i < obp_tsb_entries; i++) {
15290Sstevel@tonic-gate 		uint64_t tte = lddphys(obp_tsb_pa + i * 8);
15300Sstevel@tonic-gate 
15310Sstevel@tonic-gate 		if (!MMU_TTE_VALID(tte))
15320Sstevel@tonic-gate 			continue;
15330Sstevel@tonic-gate 
15340Sstevel@tonic-gate 		base_tte_addr[i] = tte;
15350Sstevel@tonic-gate 	}
15360Sstevel@tonic-gate 
15370Sstevel@tonic-gate 	/*
15380Sstevel@tonic-gate 	 * Invalidate the TLB through the diagnostic register.
15390Sstevel@tonic-gate 	 */
15400Sstevel@tonic-gate 
15410Sstevel@tonic-gate 	CSR_XS(csr_base, MMU_TTE_CACHE_INVALIDATE, -1ull);
15420Sstevel@tonic-gate 
15430Sstevel@tonic-gate 	/*
15440Sstevel@tonic-gate 	 * Configure the Fire MMU TSB Control Register.  Determine
15450Sstevel@tonic-gate 	 * the encoding for either 8KB pages (0) or 64KB pages (1).
15460Sstevel@tonic-gate 	 *
15470Sstevel@tonic-gate 	 * Write the most significant 30 bits of the TSB physical address
15480Sstevel@tonic-gate 	 * and the encoded TSB table size.
15490Sstevel@tonic-gate 	 */
15500Sstevel@tonic-gate 	for (i = 8; i && (pxu_p->tsb_size < (0x2000 << i)); i--);
15510Sstevel@tonic-gate 
15520Sstevel@tonic-gate 	val = (((((va_to_pa(pxu_p->tsb_vaddr)) >> 13) << 13) |
15530Sstevel@tonic-gate 	    ((MMU_PAGE_SHIFT == 13) ? 0 : 1) << 8) | i);
15540Sstevel@tonic-gate 
15550Sstevel@tonic-gate 	CSR_XS(csr_base, MMU_TSB_CONTROL, val);
15560Sstevel@tonic-gate 
15570Sstevel@tonic-gate 	/*
15580Sstevel@tonic-gate 	 * Enable the MMU, set the "TSB Cache Snoop Enable",
15590Sstevel@tonic-gate 	 * the "Cache Mode", the "Bypass Enable" and
15600Sstevel@tonic-gate 	 * the "Translation Enable" bits.
15610Sstevel@tonic-gate 	 */
15620Sstevel@tonic-gate 	val = CSR_XR(csr_base, MMU_CONTROL_AND_STATUS);
15630Sstevel@tonic-gate 	val |= ((1ull << MMU_CONTROL_AND_STATUS_SE)
156427Sjchu 	    | (MMU_CONTROL_AND_STATUS_CM_MASK << MMU_CONTROL_AND_STATUS_CM)
156527Sjchu 	    | (1ull << MMU_CONTROL_AND_STATUS_BE)
156627Sjchu 	    | (1ull << MMU_CONTROL_AND_STATUS_TE));
15670Sstevel@tonic-gate 
15680Sstevel@tonic-gate 	CSR_XS(csr_base, MMU_CONTROL_AND_STATUS, val);
15690Sstevel@tonic-gate 
15700Sstevel@tonic-gate 	/*
15710Sstevel@tonic-gate 	 * Read the register here to ensure that the previous writes to
15720Sstevel@tonic-gate 	 * the Fire MMU registers have been flushed.  (Technically, this
15730Sstevel@tonic-gate 	 * is not entirely necessary here as we will likely do later reads
15740Sstevel@tonic-gate 	 * during Fire initialization, but it is a small price to pay for
15750Sstevel@tonic-gate 	 * more modular code.)
15760Sstevel@tonic-gate 	 */
15770Sstevel@tonic-gate 	(void) CSR_XR(csr_base, MMU_CONTROL_AND_STATUS);
15780Sstevel@tonic-gate 
15790Sstevel@tonic-gate 	/*
158027Sjchu 	 * CSR_V TLU's UE interrupt regs (log, enable, status, clear)
158127Sjchu 	 * Plus header logs
15820Sstevel@tonic-gate 	 */
158327Sjchu 	DBG(DBG_MMU, NULL, "mmu_init - MMU_ERROR_LOG_ENABLE: 0x%llx\n",
158427Sjchu 	    CSR_XR(csr_base, MMU_ERROR_LOG_ENABLE));
158527Sjchu 
158627Sjchu 	DBG(DBG_MMU, NULL, "mmu_init - MMU_INTERRUPT_ENABLE: 0x%llx\n",
158727Sjchu 	    CSR_XR(csr_base, MMU_INTERRUPT_ENABLE));
158827Sjchu 
158927Sjchu 	DBG(DBG_MMU, NULL, "mmu_init - MMU_INTERRUPT_STATUS: 0x%llx\n",
159027Sjchu 	    CSR_XR(csr_base, MMU_INTERRUPT_STATUS));
159127Sjchu 
159227Sjchu 	DBG(DBG_MMU, NULL, "mmu_init - MMU_ERROR_STATUS_CLEAR: 0x%llx\n",
159327Sjchu 	    CSR_XR(csr_base, MMU_ERROR_STATUS_CLEAR));
15940Sstevel@tonic-gate }
15950Sstevel@tonic-gate 
15960Sstevel@tonic-gate /*
15970Sstevel@tonic-gate  * Generic IOMMU Servies
15980Sstevel@tonic-gate  */
15990Sstevel@tonic-gate 
16000Sstevel@tonic-gate /* ARGSUSED */
16010Sstevel@tonic-gate uint64_t
1602*1617Sgovinda hvio_iommu_map(devhandle_t dev_hdl, pxu_t *pxu_p, tsbid_t tsbid, pages_t pages,
1603*1617Sgovinda     io_attributes_t io_attr, void *addr, size_t pfn_index, int flags)
16040Sstevel@tonic-gate {
16050Sstevel@tonic-gate 	tsbindex_t	tsb_index = PCI_TSBID_TO_TSBINDEX(tsbid);
16060Sstevel@tonic-gate 	uint64_t	attr = MMU_TTE_V;
16070Sstevel@tonic-gate 	int		i;
16080Sstevel@tonic-gate 
1609*1617Sgovinda 	if (io_attr & PCI_MAP_ATTR_WRITE)
16100Sstevel@tonic-gate 		attr |= MMU_TTE_W;
16110Sstevel@tonic-gate 
1612*1617Sgovinda 	if (flags & MMU_MAP_PFN) {
1613*1617Sgovinda 		ddi_dma_impl_t	*mp = (ddi_dma_impl_t *)addr;
16140Sstevel@tonic-gate 		for (i = 0; i < pages; i++, pfn_index++, tsb_index++) {
1615*1617Sgovinda 			px_iopfn_t pfn = PX_GET_MP_PFN(mp, pfn_index);
1616*1617Sgovinda 			pxu_p->tsb_vaddr[tsb_index] = MMU_PTOB(pfn) | attr;
16170Sstevel@tonic-gate 		}
16180Sstevel@tonic-gate 	} else {
1619*1617Sgovinda 		caddr_t	a = (caddr_t)addr;
16200Sstevel@tonic-gate 		for (i = 0; i < pages; i++, a += MMU_PAGE_SIZE, tsb_index++) {
16210Sstevel@tonic-gate 			px_iopfn_t pfn = hat_getpfnum(kas.a_hat, a);
1622*1617Sgovinda 			pxu_p->tsb_vaddr[tsb_index] = MMU_PTOB(pfn) | attr;
16230Sstevel@tonic-gate 		}
16240Sstevel@tonic-gate 	}
16250Sstevel@tonic-gate 
16260Sstevel@tonic-gate 	return (H_EOK);
16270Sstevel@tonic-gate }
16280Sstevel@tonic-gate 
16290Sstevel@tonic-gate /* ARGSUSED */
16300Sstevel@tonic-gate uint64_t
16310Sstevel@tonic-gate hvio_iommu_demap(devhandle_t dev_hdl, pxu_t *pxu_p, tsbid_t tsbid,
16320Sstevel@tonic-gate     pages_t pages)
16330Sstevel@tonic-gate {
16340Sstevel@tonic-gate 	tsbindex_t	tsb_index = PCI_TSBID_TO_TSBINDEX(tsbid);
16350Sstevel@tonic-gate 	int		i;
16360Sstevel@tonic-gate 
1637*1617Sgovinda 	for (i = 0; i < pages; i++, tsb_index++)
16380Sstevel@tonic-gate 		pxu_p->tsb_vaddr[tsb_index] = MMU_INVALID_TTE;
16390Sstevel@tonic-gate 
16400Sstevel@tonic-gate 	return (H_EOK);
16410Sstevel@tonic-gate }
16420Sstevel@tonic-gate 
16430Sstevel@tonic-gate /* ARGSUSED */
16440Sstevel@tonic-gate uint64_t
16450Sstevel@tonic-gate hvio_iommu_getmap(devhandle_t dev_hdl, pxu_t *pxu_p, tsbid_t tsbid,
1646*1617Sgovinda     io_attributes_t *attr_p, r_addr_t *r_addr_p)
16470Sstevel@tonic-gate {
16480Sstevel@tonic-gate 	tsbindex_t	tsb_index = PCI_TSBID_TO_TSBINDEX(tsbid);
16490Sstevel@tonic-gate 	uint64_t	*tte_addr;
16500Sstevel@tonic-gate 	uint64_t	ret = H_EOK;
16510Sstevel@tonic-gate 
16520Sstevel@tonic-gate 	tte_addr = (uint64_t *)(pxu_p->tsb_vaddr) + tsb_index;
16530Sstevel@tonic-gate 
16540Sstevel@tonic-gate 	if (*tte_addr & MMU_TTE_V) {
16550Sstevel@tonic-gate 		*r_addr_p = MMU_TTETOPA(*tte_addr);
1656*1617Sgovinda 		*attr_p = (*tte_addr & MMU_TTE_W) ?
16570Sstevel@tonic-gate 		    PCI_MAP_ATTR_WRITE:PCI_MAP_ATTR_READ;
16580Sstevel@tonic-gate 	} else {
16590Sstevel@tonic-gate 		*r_addr_p = 0;
1660*1617Sgovinda 		*attr_p = 0;
16610Sstevel@tonic-gate 		ret = H_ENOMAP;
16620Sstevel@tonic-gate 	}
16630Sstevel@tonic-gate 
16640Sstevel@tonic-gate 	return (ret);
16650Sstevel@tonic-gate }
16660Sstevel@tonic-gate 
16670Sstevel@tonic-gate /* ARGSUSED */
16680Sstevel@tonic-gate uint64_t
1669*1617Sgovinda hvio_iommu_getbypass(devhandle_t dev_hdl, r_addr_t ra, io_attributes_t attr,
1670*1617Sgovinda     io_addr_t *io_addr_p)
16710Sstevel@tonic-gate {
16720Sstevel@tonic-gate 	uint64_t	pfn = MMU_BTOP(ra);
16730Sstevel@tonic-gate 
16740Sstevel@tonic-gate 	*io_addr_p = MMU_BYPASS_BASE | ra |
167527Sjchu 	    (pf_is_memory(pfn) ? 0 : MMU_BYPASS_NONCACHE);
16760Sstevel@tonic-gate 
16770Sstevel@tonic-gate 	return (H_EOK);
16780Sstevel@tonic-gate }
16790Sstevel@tonic-gate 
16800Sstevel@tonic-gate /*
16810Sstevel@tonic-gate  * Generic IO Interrupt Servies
16820Sstevel@tonic-gate  */
16830Sstevel@tonic-gate 
16840Sstevel@tonic-gate /*
16850Sstevel@tonic-gate  * Converts a device specific interrupt number given by the
16860Sstevel@tonic-gate  * arguments devhandle and devino into a system specific ino.
16870Sstevel@tonic-gate  */
16880Sstevel@tonic-gate /* ARGSUSED */
16890Sstevel@tonic-gate uint64_t
16900Sstevel@tonic-gate hvio_intr_devino_to_sysino(devhandle_t dev_hdl, pxu_t *pxu_p, devino_t devino,
16910Sstevel@tonic-gate     sysino_t *sysino)
16920Sstevel@tonic-gate {
16930Sstevel@tonic-gate 	if (devino > INTERRUPT_MAPPING_ENTRIES) {
16940Sstevel@tonic-gate 		DBG(DBG_IB, NULL, "ino %x is invalid\n", devino);
16950Sstevel@tonic-gate 		return (H_ENOINTR);
16960Sstevel@tonic-gate 	}
16970Sstevel@tonic-gate 
16980Sstevel@tonic-gate 	*sysino = DEVINO_TO_SYSINO(pxu_p->portid, devino);
16990Sstevel@tonic-gate 
17000Sstevel@tonic-gate 	return (H_EOK);
17010Sstevel@tonic-gate }
17020Sstevel@tonic-gate 
17030Sstevel@tonic-gate /*
17040Sstevel@tonic-gate  * Returns state in intr_valid_state if the interrupt defined by sysino
17050Sstevel@tonic-gate  * is valid (enabled) or not-valid (disabled).
17060Sstevel@tonic-gate  */
17070Sstevel@tonic-gate uint64_t
17080Sstevel@tonic-gate hvio_intr_getvalid(devhandle_t dev_hdl, sysino_t sysino,
17090Sstevel@tonic-gate     intr_valid_state_t *intr_valid_state)
17100Sstevel@tonic-gate {
17110Sstevel@tonic-gate 	if (CSRA_BR((caddr_t)dev_hdl, INTERRUPT_MAPPING,
17120Sstevel@tonic-gate 	    SYSINO_TO_DEVINO(sysino), ENTRIES_V)) {
17130Sstevel@tonic-gate 		*intr_valid_state = INTR_VALID;
17140Sstevel@tonic-gate 	} else {
17150Sstevel@tonic-gate 		*intr_valid_state = INTR_NOTVALID;
17160Sstevel@tonic-gate 	}
17170Sstevel@tonic-gate 
17180Sstevel@tonic-gate 	return (H_EOK);
17190Sstevel@tonic-gate }
17200Sstevel@tonic-gate 
17210Sstevel@tonic-gate /*
17220Sstevel@tonic-gate  * Sets the 'valid' state of the interrupt defined by
17230Sstevel@tonic-gate  * the argument sysino to the state defined by the
17240Sstevel@tonic-gate  * argument intr_valid_state.
17250Sstevel@tonic-gate  */
17260Sstevel@tonic-gate uint64_t
17270Sstevel@tonic-gate hvio_intr_setvalid(devhandle_t dev_hdl, sysino_t sysino,
17280Sstevel@tonic-gate     intr_valid_state_t intr_valid_state)
17290Sstevel@tonic-gate {
17300Sstevel@tonic-gate 	switch (intr_valid_state) {
17310Sstevel@tonic-gate 	case INTR_VALID:
17320Sstevel@tonic-gate 		CSRA_BS((caddr_t)dev_hdl, INTERRUPT_MAPPING,
17330Sstevel@tonic-gate 		    SYSINO_TO_DEVINO(sysino), ENTRIES_V);
17340Sstevel@tonic-gate 		break;
17350Sstevel@tonic-gate 	case INTR_NOTVALID:
17360Sstevel@tonic-gate 		CSRA_BC((caddr_t)dev_hdl, INTERRUPT_MAPPING,
17370Sstevel@tonic-gate 		    SYSINO_TO_DEVINO(sysino), ENTRIES_V);
17380Sstevel@tonic-gate 		break;
17390Sstevel@tonic-gate 	default:
17400Sstevel@tonic-gate 		return (EINVAL);
17410Sstevel@tonic-gate 	}
17420Sstevel@tonic-gate 
17430Sstevel@tonic-gate 	return (H_EOK);
17440Sstevel@tonic-gate }
17450Sstevel@tonic-gate 
17460Sstevel@tonic-gate /*
17470Sstevel@tonic-gate  * Returns the current state of the interrupt given by the sysino
17480Sstevel@tonic-gate  * argument.
17490Sstevel@tonic-gate  */
17500Sstevel@tonic-gate uint64_t
17510Sstevel@tonic-gate hvio_intr_getstate(devhandle_t dev_hdl, sysino_t sysino,
17520Sstevel@tonic-gate     intr_state_t *intr_state)
17530Sstevel@tonic-gate {
17540Sstevel@tonic-gate 	intr_state_t state;
17550Sstevel@tonic-gate 
17560Sstevel@tonic-gate 	state = CSRA_FR((caddr_t)dev_hdl, INTERRUPT_CLEAR,
17570Sstevel@tonic-gate 	    SYSINO_TO_DEVINO(sysino), ENTRIES_INT_STATE);
17580Sstevel@tonic-gate 
17590Sstevel@tonic-gate 	switch (state) {
17600Sstevel@tonic-gate 	case INTERRUPT_IDLE_STATE:
17610Sstevel@tonic-gate 		*intr_state = INTR_IDLE_STATE;
17620Sstevel@tonic-gate 		break;
17630Sstevel@tonic-gate 	case INTERRUPT_RECEIVED_STATE:
17640Sstevel@tonic-gate 		*intr_state = INTR_RECEIVED_STATE;
17650Sstevel@tonic-gate 		break;
17660Sstevel@tonic-gate 	case INTERRUPT_PENDING_STATE:
17670Sstevel@tonic-gate 		*intr_state = INTR_DELIVERED_STATE;
17680Sstevel@tonic-gate 		break;
17690Sstevel@tonic-gate 	default:
17700Sstevel@tonic-gate 		return (EINVAL);
17710Sstevel@tonic-gate 	}
17720Sstevel@tonic-gate 
17730Sstevel@tonic-gate 	return (H_EOK);
17740Sstevel@tonic-gate 
17750Sstevel@tonic-gate }
17760Sstevel@tonic-gate 
17770Sstevel@tonic-gate /*
17780Sstevel@tonic-gate  * Sets the current state of the interrupt given by the sysino
17790Sstevel@tonic-gate  * argument to the value given in the argument intr_state.
17800Sstevel@tonic-gate  *
17810Sstevel@tonic-gate  * Note: Setting the state to INTR_IDLE clears any pending
17820Sstevel@tonic-gate  * interrupt for sysino.
17830Sstevel@tonic-gate  */
17840Sstevel@tonic-gate uint64_t
17850Sstevel@tonic-gate hvio_intr_setstate(devhandle_t dev_hdl, sysino_t sysino,
17860Sstevel@tonic-gate     intr_state_t intr_state)
17870Sstevel@tonic-gate {
17880Sstevel@tonic-gate 	intr_state_t state;
17890Sstevel@tonic-gate 
17900Sstevel@tonic-gate 	switch (intr_state) {
17910Sstevel@tonic-gate 	case INTR_IDLE_STATE:
17920Sstevel@tonic-gate 		state = INTERRUPT_IDLE_STATE;
17930Sstevel@tonic-gate 		break;
17940Sstevel@tonic-gate 	case INTR_DELIVERED_STATE:
17950Sstevel@tonic-gate 		state = INTERRUPT_PENDING_STATE;
17960Sstevel@tonic-gate 		break;
17970Sstevel@tonic-gate 	default:
17980Sstevel@tonic-gate 		return (EINVAL);
17990Sstevel@tonic-gate 	}
18000Sstevel@tonic-gate 
18010Sstevel@tonic-gate 	CSRA_FS((caddr_t)dev_hdl, INTERRUPT_CLEAR,
18020Sstevel@tonic-gate 	    SYSINO_TO_DEVINO(sysino), ENTRIES_INT_STATE, state);
18030Sstevel@tonic-gate 
18040Sstevel@tonic-gate 	return (H_EOK);
18050Sstevel@tonic-gate }
18060Sstevel@tonic-gate 
18070Sstevel@tonic-gate /*
18080Sstevel@tonic-gate  * Returns the cpuid that is the current target of the
18090Sstevel@tonic-gate  * interrupt given by the sysino argument.
18100Sstevel@tonic-gate  *
18110Sstevel@tonic-gate  * The cpuid value returned is undefined if the target
18120Sstevel@tonic-gate  * has not been set via intr_settarget.
18130Sstevel@tonic-gate  */
18140Sstevel@tonic-gate uint64_t
18150Sstevel@tonic-gate hvio_intr_gettarget(devhandle_t dev_hdl, sysino_t sysino, cpuid_t *cpuid)
18160Sstevel@tonic-gate {
18170Sstevel@tonic-gate 	*cpuid = CSRA_FR((caddr_t)dev_hdl, INTERRUPT_MAPPING,
18180Sstevel@tonic-gate 	    SYSINO_TO_DEVINO(sysino), ENTRIES_T_JPID);
18190Sstevel@tonic-gate 
18200Sstevel@tonic-gate 	return (H_EOK);
18210Sstevel@tonic-gate }
18220Sstevel@tonic-gate 
18230Sstevel@tonic-gate /*
18240Sstevel@tonic-gate  * Set the target cpu for the interrupt defined by the argument
18250Sstevel@tonic-gate  * sysino to the target cpu value defined by the argument cpuid.
18260Sstevel@tonic-gate  */
18270Sstevel@tonic-gate uint64_t
18280Sstevel@tonic-gate hvio_intr_settarget(devhandle_t dev_hdl, sysino_t sysino, cpuid_t cpuid)
18290Sstevel@tonic-gate {
18300Sstevel@tonic-gate 
18310Sstevel@tonic-gate 	uint64_t	val, intr_controller;
18320Sstevel@tonic-gate 	uint32_t	ino = SYSINO_TO_DEVINO(sysino);
18330Sstevel@tonic-gate 
18340Sstevel@tonic-gate 	/*
18350Sstevel@tonic-gate 	 * For now, we assign interrupt controller in a round
18360Sstevel@tonic-gate 	 * robin fashion.  Later, we may need to come up with
18370Sstevel@tonic-gate 	 * a more efficient assignment algorithm.
18380Sstevel@tonic-gate 	 */
18390Sstevel@tonic-gate 	intr_controller = 0x1ull << (cpuid % 4);
18400Sstevel@tonic-gate 
18410Sstevel@tonic-gate 	val = (((cpuid & INTERRUPT_MAPPING_ENTRIES_T_JPID_MASK) <<
18420Sstevel@tonic-gate 	    INTERRUPT_MAPPING_ENTRIES_T_JPID) |
18430Sstevel@tonic-gate 	    ((intr_controller & INTERRUPT_MAPPING_ENTRIES_INT_CNTRL_NUM_MASK)
18440Sstevel@tonic-gate 	    << INTERRUPT_MAPPING_ENTRIES_INT_CNTRL_NUM));
18450Sstevel@tonic-gate 
18460Sstevel@tonic-gate 	/* For EQ interrupts, set DATA MONDO bit */
18470Sstevel@tonic-gate 	if ((ino >= PX_DEFAULT_MSIQ_1ST_DEVINO) &&
18480Sstevel@tonic-gate 	    (ino < (PX_DEFAULT_MSIQ_1ST_DEVINO + PX_DEFAULT_MSIQ_CNT)))
18490Sstevel@tonic-gate 		val |= (0x1ull << INTERRUPT_MAPPING_ENTRIES_MDO_MODE);
18500Sstevel@tonic-gate 
18510Sstevel@tonic-gate 	CSRA_XS((caddr_t)dev_hdl, INTERRUPT_MAPPING, ino, val);
18520Sstevel@tonic-gate 
18530Sstevel@tonic-gate 	return (H_EOK);
18540Sstevel@tonic-gate }
18550Sstevel@tonic-gate 
18560Sstevel@tonic-gate /*
18570Sstevel@tonic-gate  * MSIQ Functions:
18580Sstevel@tonic-gate  */
18590Sstevel@tonic-gate uint64_t
18600Sstevel@tonic-gate hvio_msiq_init(devhandle_t dev_hdl, pxu_t *pxu_p)
18610Sstevel@tonic-gate {
18620Sstevel@tonic-gate 	CSRA_XS((caddr_t)dev_hdl, EVENT_QUEUE_BASE_ADDRESS, 0,
18630Sstevel@tonic-gate 	    (uint64_t)pxu_p->msiq_mapped_p);
18640Sstevel@tonic-gate 	DBG(DBG_IB, NULL,
18650Sstevel@tonic-gate 	    "hvio_msiq_init: EVENT_QUEUE_BASE_ADDRESS 0x%llx\n",
18660Sstevel@tonic-gate 	    CSR_XR((caddr_t)dev_hdl, EVENT_QUEUE_BASE_ADDRESS));
18670Sstevel@tonic-gate 
18680Sstevel@tonic-gate 	CSRA_XS((caddr_t)dev_hdl, INTERRUPT_MONDO_DATA_0, 0,
18690Sstevel@tonic-gate 	    (uint64_t)ID_TO_IGN(pxu_p->portid) << INO_BITS);
18700Sstevel@tonic-gate 	DBG(DBG_IB, NULL, "hvio_msiq_init: "
18710Sstevel@tonic-gate 	    "INTERRUPT_MONDO_DATA_0: 0x%llx\n",
18720Sstevel@tonic-gate 	    CSR_XR((caddr_t)dev_hdl, INTERRUPT_MONDO_DATA_0));
18730Sstevel@tonic-gate 
18740Sstevel@tonic-gate 	return (H_EOK);
18750Sstevel@tonic-gate }
18760Sstevel@tonic-gate 
18770Sstevel@tonic-gate uint64_t
18780Sstevel@tonic-gate hvio_msiq_getvalid(devhandle_t dev_hdl, msiqid_t msiq_id,
18790Sstevel@tonic-gate     pci_msiq_valid_state_t *msiq_valid_state)
18800Sstevel@tonic-gate {
18810Sstevel@tonic-gate 	uint32_t	eq_state;
18820Sstevel@tonic-gate 	uint64_t	ret = H_EOK;
18830Sstevel@tonic-gate 
18840Sstevel@tonic-gate 	eq_state = CSRA_FR((caddr_t)dev_hdl, EVENT_QUEUE_STATE,
18850Sstevel@tonic-gate 	    msiq_id, ENTRIES_STATE);
18860Sstevel@tonic-gate 
18870Sstevel@tonic-gate 	switch (eq_state) {
18880Sstevel@tonic-gate 	case EQ_IDLE_STATE:
18890Sstevel@tonic-gate 		*msiq_valid_state = PCI_MSIQ_INVALID;
18900Sstevel@tonic-gate 		break;
18910Sstevel@tonic-gate 	case EQ_ACTIVE_STATE:
18920Sstevel@tonic-gate 	case EQ_ERROR_STATE:
18930Sstevel@tonic-gate 		*msiq_valid_state = PCI_MSIQ_VALID;
18940Sstevel@tonic-gate 		break;
18950Sstevel@tonic-gate 	default:
18960Sstevel@tonic-gate 		ret = H_EIO;
18970Sstevel@tonic-gate 		break;
18980Sstevel@tonic-gate 	}
18990Sstevel@tonic-gate 
19000Sstevel@tonic-gate 	return (ret);
19010Sstevel@tonic-gate }
19020Sstevel@tonic-gate 
19030Sstevel@tonic-gate uint64_t
19040Sstevel@tonic-gate hvio_msiq_setvalid(devhandle_t dev_hdl, msiqid_t msiq_id,
19050Sstevel@tonic-gate     pci_msiq_valid_state_t msiq_valid_state)
19060Sstevel@tonic-gate {
19070Sstevel@tonic-gate 	uint64_t	ret = H_EOK;
19080Sstevel@tonic-gate 
19090Sstevel@tonic-gate 	switch (msiq_valid_state) {
19100Sstevel@tonic-gate 	case PCI_MSIQ_INVALID:
19110Sstevel@tonic-gate 		CSRA_BS((caddr_t)dev_hdl, EVENT_QUEUE_CONTROL_CLEAR,
19120Sstevel@tonic-gate 		    msiq_id, ENTRIES_DIS);
19130Sstevel@tonic-gate 		break;
19140Sstevel@tonic-gate 	case PCI_MSIQ_VALID:
19150Sstevel@tonic-gate 		CSRA_BS((caddr_t)dev_hdl, EVENT_QUEUE_CONTROL_SET,
19160Sstevel@tonic-gate 		    msiq_id, ENTRIES_EN);
19170Sstevel@tonic-gate 		break;
19180Sstevel@tonic-gate 	default:
19190Sstevel@tonic-gate 		ret = H_EINVAL;
19200Sstevel@tonic-gate 		break;
19210Sstevel@tonic-gate 	}
19220Sstevel@tonic-gate 
19230Sstevel@tonic-gate 	return (ret);
19240Sstevel@tonic-gate }
19250Sstevel@tonic-gate 
19260Sstevel@tonic-gate uint64_t
19270Sstevel@tonic-gate hvio_msiq_getstate(devhandle_t dev_hdl, msiqid_t msiq_id,
19280Sstevel@tonic-gate     pci_msiq_state_t *msiq_state)
19290Sstevel@tonic-gate {
19300Sstevel@tonic-gate 	uint32_t	eq_state;
19310Sstevel@tonic-gate 	uint64_t	ret = H_EOK;
19320Sstevel@tonic-gate 
19330Sstevel@tonic-gate 	eq_state = CSRA_FR((caddr_t)dev_hdl, EVENT_QUEUE_STATE,
19340Sstevel@tonic-gate 	    msiq_id, ENTRIES_STATE);
19350Sstevel@tonic-gate 
19360Sstevel@tonic-gate 	switch (eq_state) {
19370Sstevel@tonic-gate 	case EQ_IDLE_STATE:
19380Sstevel@tonic-gate 	case EQ_ACTIVE_STATE:
19390Sstevel@tonic-gate 		*msiq_state = PCI_MSIQ_STATE_IDLE;
19400Sstevel@tonic-gate 		break;
19410Sstevel@tonic-gate 	case EQ_ERROR_STATE:
19420Sstevel@tonic-gate 		*msiq_state = PCI_MSIQ_STATE_ERROR;
19430Sstevel@tonic-gate 		break;
19440Sstevel@tonic-gate 	default:
19450Sstevel@tonic-gate 		ret = H_EIO;
19460Sstevel@tonic-gate 	}
19470Sstevel@tonic-gate 
19480Sstevel@tonic-gate 	return (ret);
19490Sstevel@tonic-gate }
19500Sstevel@tonic-gate 
19510Sstevel@tonic-gate uint64_t
19520Sstevel@tonic-gate hvio_msiq_setstate(devhandle_t dev_hdl, msiqid_t msiq_id,
19530Sstevel@tonic-gate     pci_msiq_state_t msiq_state)
19540Sstevel@tonic-gate {
19550Sstevel@tonic-gate 	uint32_t	eq_state;
19560Sstevel@tonic-gate 	uint64_t	ret = H_EOK;
19570Sstevel@tonic-gate 
19580Sstevel@tonic-gate 	eq_state = CSRA_FR((caddr_t)dev_hdl, EVENT_QUEUE_STATE,
19590Sstevel@tonic-gate 	    msiq_id, ENTRIES_STATE);
19600Sstevel@tonic-gate 
19610Sstevel@tonic-gate 	switch (eq_state) {
19620Sstevel@tonic-gate 	case EQ_IDLE_STATE:
19630Sstevel@tonic-gate 		if (msiq_state == PCI_MSIQ_STATE_ERROR)
19640Sstevel@tonic-gate 			ret = H_EIO;
19650Sstevel@tonic-gate 		break;
19660Sstevel@tonic-gate 	case EQ_ACTIVE_STATE:
19670Sstevel@tonic-gate 		if (msiq_state == PCI_MSIQ_STATE_ERROR)
19680Sstevel@tonic-gate 			CSRA_BS((caddr_t)dev_hdl, EVENT_QUEUE_CONTROL_SET,
19690Sstevel@tonic-gate 			    msiq_id, ENTRIES_ENOVERR);
19700Sstevel@tonic-gate 		else
19710Sstevel@tonic-gate 			ret = H_EIO;
19720Sstevel@tonic-gate 		break;
19730Sstevel@tonic-gate 	case EQ_ERROR_STATE:
19740Sstevel@tonic-gate 		if (msiq_state == PCI_MSIQ_STATE_IDLE)
19750Sstevel@tonic-gate 			CSRA_BS((caddr_t)dev_hdl, EVENT_QUEUE_CONTROL_CLEAR,
19760Sstevel@tonic-gate 			    msiq_id, ENTRIES_E2I);
19770Sstevel@tonic-gate 		else
19780Sstevel@tonic-gate 			ret = H_EIO;
19790Sstevel@tonic-gate 		break;
19800Sstevel@tonic-gate 	default:
19810Sstevel@tonic-gate 		ret = H_EIO;
19820Sstevel@tonic-gate 	}
19830Sstevel@tonic-gate 
19840Sstevel@tonic-gate 	return (ret);
19850Sstevel@tonic-gate }
19860Sstevel@tonic-gate 
19870Sstevel@tonic-gate uint64_t
19880Sstevel@tonic-gate hvio_msiq_gethead(devhandle_t dev_hdl, msiqid_t msiq_id,
19890Sstevel@tonic-gate     msiqhead_t *msiq_head)
19900Sstevel@tonic-gate {
19910Sstevel@tonic-gate 	*msiq_head = CSRA_FR((caddr_t)dev_hdl, EVENT_QUEUE_HEAD,
19920Sstevel@tonic-gate 	    msiq_id, ENTRIES_HEAD);
19930Sstevel@tonic-gate 
19940Sstevel@tonic-gate 	return (H_EOK);
19950Sstevel@tonic-gate }
19960Sstevel@tonic-gate 
19970Sstevel@tonic-gate uint64_t
19980Sstevel@tonic-gate hvio_msiq_sethead(devhandle_t dev_hdl, msiqid_t msiq_id,
19990Sstevel@tonic-gate     msiqhead_t msiq_head)
20000Sstevel@tonic-gate {
20010Sstevel@tonic-gate 	CSRA_FS((caddr_t)dev_hdl, EVENT_QUEUE_HEAD, msiq_id,
20020Sstevel@tonic-gate 	    ENTRIES_HEAD, msiq_head);
20030Sstevel@tonic-gate 
20040Sstevel@tonic-gate 	return (H_EOK);
20050Sstevel@tonic-gate }
20060Sstevel@tonic-gate 
20070Sstevel@tonic-gate uint64_t
20080Sstevel@tonic-gate hvio_msiq_gettail(devhandle_t dev_hdl, msiqid_t msiq_id,
20090Sstevel@tonic-gate     msiqtail_t *msiq_tail)
20100Sstevel@tonic-gate {
20110Sstevel@tonic-gate 	*msiq_tail = CSRA_FR((caddr_t)dev_hdl, EVENT_QUEUE_TAIL,
20120Sstevel@tonic-gate 	    msiq_id, ENTRIES_TAIL);
20130Sstevel@tonic-gate 
20140Sstevel@tonic-gate 	return (H_EOK);
20150Sstevel@tonic-gate }
20160Sstevel@tonic-gate 
20170Sstevel@tonic-gate /*
20180Sstevel@tonic-gate  * MSI Functions:
20190Sstevel@tonic-gate  */
20200Sstevel@tonic-gate uint64_t
20210Sstevel@tonic-gate hvio_msi_init(devhandle_t dev_hdl, uint64_t addr32, uint64_t addr64)
20220Sstevel@tonic-gate {
20230Sstevel@tonic-gate 	/* PCI MEM 32 resources to perform 32 bit MSI transactions */
20240Sstevel@tonic-gate 	CSRA_FS((caddr_t)dev_hdl, MSI_32_BIT_ADDRESS, 0,
20250Sstevel@tonic-gate 	    ADDR, (uint64_t)addr32 >> MSI_32_BIT_ADDRESS_ADDR);
20260Sstevel@tonic-gate 	DBG(DBG_IB, NULL, "hvio_msiq_init: MSI_32_BIT_ADDRESS: 0x%llx\n",
20270Sstevel@tonic-gate 	    CSR_XR((caddr_t)dev_hdl, MSI_32_BIT_ADDRESS));
20280Sstevel@tonic-gate 
20290Sstevel@tonic-gate 	/* Reserve PCI MEM 64 resources to perform 64 bit MSI transactions */
20300Sstevel@tonic-gate 	CSRA_FS((caddr_t)dev_hdl, MSI_64_BIT_ADDRESS, 0,
20310Sstevel@tonic-gate 	    ADDR, (uint64_t)addr64 >> MSI_64_BIT_ADDRESS_ADDR);
20320Sstevel@tonic-gate 	DBG(DBG_IB, NULL, "hvio_msiq_init: MSI_64_BIT_ADDRESS: 0x%llx\n",
20330Sstevel@tonic-gate 	    CSR_XR((caddr_t)dev_hdl, MSI_64_BIT_ADDRESS));
20340Sstevel@tonic-gate 
20350Sstevel@tonic-gate 	return (H_EOK);
20360Sstevel@tonic-gate }
20370Sstevel@tonic-gate 
20380Sstevel@tonic-gate uint64_t
20390Sstevel@tonic-gate hvio_msi_getmsiq(devhandle_t dev_hdl, msinum_t msi_num,
20400Sstevel@tonic-gate     msiqid_t *msiq_id)
20410Sstevel@tonic-gate {
20420Sstevel@tonic-gate 	*msiq_id = CSRA_FR((caddr_t)dev_hdl, MSI_MAPPING,
20430Sstevel@tonic-gate 	    msi_num, ENTRIES_EQNUM);
20440Sstevel@tonic-gate 
20450Sstevel@tonic-gate 	return (H_EOK);
20460Sstevel@tonic-gate }
20470Sstevel@tonic-gate 
20480Sstevel@tonic-gate uint64_t
20490Sstevel@tonic-gate hvio_msi_setmsiq(devhandle_t dev_hdl, msinum_t msi_num,
20500Sstevel@tonic-gate     msiqid_t msiq_id)
20510Sstevel@tonic-gate {
20520Sstevel@tonic-gate 	CSRA_FS((caddr_t)dev_hdl, MSI_MAPPING, msi_num,
20530Sstevel@tonic-gate 	    ENTRIES_EQNUM, msiq_id);
20540Sstevel@tonic-gate 
20550Sstevel@tonic-gate 	return (H_EOK);
20560Sstevel@tonic-gate }
20570Sstevel@tonic-gate 
20580Sstevel@tonic-gate uint64_t
20590Sstevel@tonic-gate hvio_msi_getvalid(devhandle_t dev_hdl, msinum_t msi_num,
20600Sstevel@tonic-gate     pci_msi_valid_state_t *msi_valid_state)
20610Sstevel@tonic-gate {
20620Sstevel@tonic-gate 	*msi_valid_state = CSRA_BR((caddr_t)dev_hdl, MSI_MAPPING,
20630Sstevel@tonic-gate 	    msi_num, ENTRIES_V);
20640Sstevel@tonic-gate 
20650Sstevel@tonic-gate 	return (H_EOK);
20660Sstevel@tonic-gate }
20670Sstevel@tonic-gate 
20680Sstevel@tonic-gate uint64_t
20690Sstevel@tonic-gate hvio_msi_setvalid(devhandle_t dev_hdl, msinum_t msi_num,
20700Sstevel@tonic-gate     pci_msi_valid_state_t msi_valid_state)
20710Sstevel@tonic-gate {
20720Sstevel@tonic-gate 	uint64_t	ret = H_EOK;
20730Sstevel@tonic-gate 
20740Sstevel@tonic-gate 	switch (msi_valid_state) {
20750Sstevel@tonic-gate 	case PCI_MSI_VALID:
20760Sstevel@tonic-gate 		CSRA_BS((caddr_t)dev_hdl, MSI_MAPPING, msi_num,
20770Sstevel@tonic-gate 		    ENTRIES_V);
20780Sstevel@tonic-gate 		break;
20790Sstevel@tonic-gate 	case PCI_MSI_INVALID:
20800Sstevel@tonic-gate 		CSRA_BC((caddr_t)dev_hdl, MSI_MAPPING, msi_num,
20810Sstevel@tonic-gate 		    ENTRIES_V);
20820Sstevel@tonic-gate 		break;
20830Sstevel@tonic-gate 	default:
20840Sstevel@tonic-gate 		ret = H_EINVAL;
20850Sstevel@tonic-gate 	}
20860Sstevel@tonic-gate 
20870Sstevel@tonic-gate 	return (ret);
20880Sstevel@tonic-gate }
20890Sstevel@tonic-gate 
20900Sstevel@tonic-gate uint64_t
20910Sstevel@tonic-gate hvio_msi_getstate(devhandle_t dev_hdl, msinum_t msi_num,
20920Sstevel@tonic-gate     pci_msi_state_t *msi_state)
20930Sstevel@tonic-gate {
20940Sstevel@tonic-gate 	*msi_state = CSRA_BR((caddr_t)dev_hdl, MSI_MAPPING,
20950Sstevel@tonic-gate 	    msi_num, ENTRIES_EQWR_N);
20960Sstevel@tonic-gate 
20970Sstevel@tonic-gate 	return (H_EOK);
20980Sstevel@tonic-gate }
20990Sstevel@tonic-gate 
21000Sstevel@tonic-gate uint64_t
21010Sstevel@tonic-gate hvio_msi_setstate(devhandle_t dev_hdl, msinum_t msi_num,
21020Sstevel@tonic-gate     pci_msi_state_t msi_state)
21030Sstevel@tonic-gate {
21040Sstevel@tonic-gate 	uint64_t	ret = H_EOK;
21050Sstevel@tonic-gate 
21060Sstevel@tonic-gate 	switch (msi_state) {
21070Sstevel@tonic-gate 	case PCI_MSI_STATE_IDLE:
21080Sstevel@tonic-gate 		CSRA_BS((caddr_t)dev_hdl, MSI_CLEAR, msi_num,
21090Sstevel@tonic-gate 		    ENTRIES_EQWR_N);
21100Sstevel@tonic-gate 		break;
21110Sstevel@tonic-gate 	case PCI_MSI_STATE_DELIVERED:
21120Sstevel@tonic-gate 	default:
21130Sstevel@tonic-gate 		ret = H_EINVAL;
21140Sstevel@tonic-gate 		break;
21150Sstevel@tonic-gate 	}
21160Sstevel@tonic-gate 
21170Sstevel@tonic-gate 	return (ret);
21180Sstevel@tonic-gate }
21190Sstevel@tonic-gate 
21200Sstevel@tonic-gate /*
21210Sstevel@tonic-gate  * MSG Functions:
21220Sstevel@tonic-gate  */
21230Sstevel@tonic-gate uint64_t
21240Sstevel@tonic-gate hvio_msg_getmsiq(devhandle_t dev_hdl, pcie_msg_type_t msg_type,
21250Sstevel@tonic-gate     msiqid_t *msiq_id)
21260Sstevel@tonic-gate {
21270Sstevel@tonic-gate 	uint64_t	ret = H_EOK;
21280Sstevel@tonic-gate 
21290Sstevel@tonic-gate 	switch (msg_type) {
21300Sstevel@tonic-gate 	case PCIE_PME_MSG:
21310Sstevel@tonic-gate 		*msiq_id = CSR_FR((caddr_t)dev_hdl, PM_PME_MAPPING, EQNUM);
21320Sstevel@tonic-gate 		break;
21330Sstevel@tonic-gate 	case PCIE_PME_ACK_MSG:
21340Sstevel@tonic-gate 		*msiq_id = CSR_FR((caddr_t)dev_hdl, PME_TO_ACK_MAPPING,
21350Sstevel@tonic-gate 		    EQNUM);
21360Sstevel@tonic-gate 		break;
21370Sstevel@tonic-gate 	case PCIE_CORR_MSG:
21380Sstevel@tonic-gate 		*msiq_id = CSR_FR((caddr_t)dev_hdl, ERR_COR_MAPPING, EQNUM);
21390Sstevel@tonic-gate 		break;
21400Sstevel@tonic-gate 	case PCIE_NONFATAL_MSG:
21410Sstevel@tonic-gate 		*msiq_id = CSR_FR((caddr_t)dev_hdl, ERR_NONFATAL_MAPPING,
21420Sstevel@tonic-gate 		    EQNUM);
21430Sstevel@tonic-gate 		break;
21440Sstevel@tonic-gate 	case PCIE_FATAL_MSG:
21450Sstevel@tonic-gate 		*msiq_id = CSR_FR((caddr_t)dev_hdl, ERR_FATAL_MAPPING, EQNUM);
21460Sstevel@tonic-gate 		break;
21470Sstevel@tonic-gate 	default:
21480Sstevel@tonic-gate 		ret = H_EINVAL;
21490Sstevel@tonic-gate 		break;
21500Sstevel@tonic-gate 	}
21510Sstevel@tonic-gate 
21520Sstevel@tonic-gate 	return (ret);
21530Sstevel@tonic-gate }
21540Sstevel@tonic-gate 
21550Sstevel@tonic-gate uint64_t
21560Sstevel@tonic-gate hvio_msg_setmsiq(devhandle_t dev_hdl, pcie_msg_type_t msg_type,
21570Sstevel@tonic-gate     msiqid_t msiq_id)
21580Sstevel@tonic-gate {
21590Sstevel@tonic-gate 	uint64_t	ret = H_EOK;
21600Sstevel@tonic-gate 
21610Sstevel@tonic-gate 	switch (msg_type) {
21620Sstevel@tonic-gate 	case PCIE_PME_MSG:
21630Sstevel@tonic-gate 		CSR_FS((caddr_t)dev_hdl, PM_PME_MAPPING, EQNUM, msiq_id);
21640Sstevel@tonic-gate 		break;
21650Sstevel@tonic-gate 	case PCIE_PME_ACK_MSG:
21660Sstevel@tonic-gate 		CSR_FS((caddr_t)dev_hdl, PME_TO_ACK_MAPPING, EQNUM, msiq_id);
21670Sstevel@tonic-gate 		break;
21680Sstevel@tonic-gate 	case PCIE_CORR_MSG:
21690Sstevel@tonic-gate 		CSR_FS((caddr_t)dev_hdl, ERR_COR_MAPPING, EQNUM, msiq_id);
21700Sstevel@tonic-gate 		break;
21710Sstevel@tonic-gate 	case PCIE_NONFATAL_MSG:
21720Sstevel@tonic-gate 		CSR_FS((caddr_t)dev_hdl, ERR_NONFATAL_MAPPING, EQNUM, msiq_id);
21730Sstevel@tonic-gate 		break;
21740Sstevel@tonic-gate 	case PCIE_FATAL_MSG:
21750Sstevel@tonic-gate 		CSR_FS((caddr_t)dev_hdl, ERR_FATAL_MAPPING, EQNUM, msiq_id);
21760Sstevel@tonic-gate 		break;
21770Sstevel@tonic-gate 	default:
21780Sstevel@tonic-gate 		ret = H_EINVAL;
21790Sstevel@tonic-gate 		break;
21800Sstevel@tonic-gate 	}
21810Sstevel@tonic-gate 
21820Sstevel@tonic-gate 	return (ret);
21830Sstevel@tonic-gate }
21840Sstevel@tonic-gate 
21850Sstevel@tonic-gate uint64_t
21860Sstevel@tonic-gate hvio_msg_getvalid(devhandle_t dev_hdl, pcie_msg_type_t msg_type,
21870Sstevel@tonic-gate     pcie_msg_valid_state_t *msg_valid_state)
21880Sstevel@tonic-gate {
21890Sstevel@tonic-gate 	uint64_t	ret = H_EOK;
21900Sstevel@tonic-gate 
21910Sstevel@tonic-gate 	switch (msg_type) {
21920Sstevel@tonic-gate 	case PCIE_PME_MSG:
21930Sstevel@tonic-gate 		*msg_valid_state = CSR_BR((caddr_t)dev_hdl, PM_PME_MAPPING, V);
21940Sstevel@tonic-gate 		break;
21950Sstevel@tonic-gate 	case PCIE_PME_ACK_MSG:
21960Sstevel@tonic-gate 		*msg_valid_state = CSR_BR((caddr_t)dev_hdl,
21970Sstevel@tonic-gate 		    PME_TO_ACK_MAPPING, V);
21980Sstevel@tonic-gate 		break;
21990Sstevel@tonic-gate 	case PCIE_CORR_MSG:
22000Sstevel@tonic-gate 		*msg_valid_state = CSR_BR((caddr_t)dev_hdl, ERR_COR_MAPPING, V);
22010Sstevel@tonic-gate 		break;
22020Sstevel@tonic-gate 	case PCIE_NONFATAL_MSG:
22030Sstevel@tonic-gate 		*msg_valid_state = CSR_BR((caddr_t)dev_hdl,
22040Sstevel@tonic-gate 		    ERR_NONFATAL_MAPPING, V);
22050Sstevel@tonic-gate 		break;
22060Sstevel@tonic-gate 	case PCIE_FATAL_MSG:
22070Sstevel@tonic-gate 		*msg_valid_state = CSR_BR((caddr_t)dev_hdl, ERR_FATAL_MAPPING,
22080Sstevel@tonic-gate 		    V);
22090Sstevel@tonic-gate 		break;
22100Sstevel@tonic-gate 	default:
22110Sstevel@tonic-gate 		ret = H_EINVAL;
22120Sstevel@tonic-gate 		break;
22130Sstevel@tonic-gate 	}
22140Sstevel@tonic-gate 
22150Sstevel@tonic-gate 	return (ret);
22160Sstevel@tonic-gate }
22170Sstevel@tonic-gate 
22180Sstevel@tonic-gate uint64_t
22190Sstevel@tonic-gate hvio_msg_setvalid(devhandle_t dev_hdl, pcie_msg_type_t msg_type,
22200Sstevel@tonic-gate     pcie_msg_valid_state_t msg_valid_state)
22210Sstevel@tonic-gate {
22220Sstevel@tonic-gate 	uint64_t	ret = H_EOK;
22230Sstevel@tonic-gate 
22240Sstevel@tonic-gate 	switch (msg_valid_state) {
22250Sstevel@tonic-gate 	case PCIE_MSG_VALID:
22260Sstevel@tonic-gate 		switch (msg_type) {
22270Sstevel@tonic-gate 		case PCIE_PME_MSG:
22280Sstevel@tonic-gate 			CSR_BS((caddr_t)dev_hdl, PM_PME_MAPPING, V);
22290Sstevel@tonic-gate 			break;
22300Sstevel@tonic-gate 		case PCIE_PME_ACK_MSG:
22310Sstevel@tonic-gate 			CSR_BS((caddr_t)dev_hdl, PME_TO_ACK_MAPPING, V);
22320Sstevel@tonic-gate 			break;
22330Sstevel@tonic-gate 		case PCIE_CORR_MSG:
22340Sstevel@tonic-gate 			CSR_BS((caddr_t)dev_hdl, ERR_COR_MAPPING, V);
22350Sstevel@tonic-gate 			break;
22360Sstevel@tonic-gate 		case PCIE_NONFATAL_MSG:
22370Sstevel@tonic-gate 			CSR_BS((caddr_t)dev_hdl, ERR_NONFATAL_MAPPING, V);
22380Sstevel@tonic-gate 			break;
22390Sstevel@tonic-gate 		case PCIE_FATAL_MSG:
22400Sstevel@tonic-gate 			CSR_BS((caddr_t)dev_hdl, ERR_FATAL_MAPPING, V);
22410Sstevel@tonic-gate 			break;
22420Sstevel@tonic-gate 		default:
22430Sstevel@tonic-gate 			ret = H_EINVAL;
22440Sstevel@tonic-gate 			break;
22450Sstevel@tonic-gate 		}
22460Sstevel@tonic-gate 
22470Sstevel@tonic-gate 		break;
22480Sstevel@tonic-gate 	case PCIE_MSG_INVALID:
22490Sstevel@tonic-gate 		switch (msg_type) {
22500Sstevel@tonic-gate 		case PCIE_PME_MSG:
22510Sstevel@tonic-gate 			CSR_BC((caddr_t)dev_hdl, PM_PME_MAPPING, V);
22520Sstevel@tonic-gate 			break;
22530Sstevel@tonic-gate 		case PCIE_PME_ACK_MSG:
22540Sstevel@tonic-gate 			CSR_BC((caddr_t)dev_hdl, PME_TO_ACK_MAPPING, V);
22550Sstevel@tonic-gate 			break;
22560Sstevel@tonic-gate 		case PCIE_CORR_MSG:
22570Sstevel@tonic-gate 			CSR_BC((caddr_t)dev_hdl, ERR_COR_MAPPING, V);
22580Sstevel@tonic-gate 			break;
22590Sstevel@tonic-gate 		case PCIE_NONFATAL_MSG:
22600Sstevel@tonic-gate 			CSR_BC((caddr_t)dev_hdl, ERR_NONFATAL_MAPPING, V);
22610Sstevel@tonic-gate 			break;
22620Sstevel@tonic-gate 		case PCIE_FATAL_MSG:
22630Sstevel@tonic-gate 			CSR_BC((caddr_t)dev_hdl, ERR_FATAL_MAPPING, V);
22640Sstevel@tonic-gate 			break;
22650Sstevel@tonic-gate 		default:
22660Sstevel@tonic-gate 			ret = H_EINVAL;
22670Sstevel@tonic-gate 			break;
22680Sstevel@tonic-gate 		}
22690Sstevel@tonic-gate 		break;
22700Sstevel@tonic-gate 	default:
22710Sstevel@tonic-gate 		ret = H_EINVAL;
22720Sstevel@tonic-gate 	}
22730Sstevel@tonic-gate 
22740Sstevel@tonic-gate 	return (ret);
22750Sstevel@tonic-gate }
22760Sstevel@tonic-gate 
22770Sstevel@tonic-gate /*
22780Sstevel@tonic-gate  * Suspend/Resume Functions:
22790Sstevel@tonic-gate  *	(pec, mmu, ib)
22800Sstevel@tonic-gate  *	cb
22810Sstevel@tonic-gate  * Registers saved have all been touched in the XXX_init functions.
22820Sstevel@tonic-gate  */
22830Sstevel@tonic-gate uint64_t
22840Sstevel@tonic-gate hvio_suspend(devhandle_t dev_hdl, pxu_t *pxu_p)
22850Sstevel@tonic-gate {
22860Sstevel@tonic-gate 	uint64_t	*config_state;
22870Sstevel@tonic-gate 	int		total_size;
22880Sstevel@tonic-gate 	int		i;
22890Sstevel@tonic-gate 
22900Sstevel@tonic-gate 	if (msiq_suspend(dev_hdl, pxu_p) != H_EOK)
22910Sstevel@tonic-gate 		return (H_EIO);
22920Sstevel@tonic-gate 
22930Sstevel@tonic-gate 	total_size = PEC_SIZE + MMU_SIZE + IB_SIZE + IB_MAP_SIZE;
22940Sstevel@tonic-gate 	config_state = kmem_zalloc(total_size, KM_NOSLEEP);
22950Sstevel@tonic-gate 
22960Sstevel@tonic-gate 	if (config_state == NULL) {
22970Sstevel@tonic-gate 		return (H_EIO);
22980Sstevel@tonic-gate 	}
22990Sstevel@tonic-gate 
23000Sstevel@tonic-gate 	/*
23010Sstevel@tonic-gate 	 * Soft state for suspend/resume  from pxu_t
23020Sstevel@tonic-gate 	 * uint64_t	*pec_config_state;
23030Sstevel@tonic-gate 	 * uint64_t	*mmu_config_state;
23040Sstevel@tonic-gate 	 * uint64_t	*ib_intr_map;
23050Sstevel@tonic-gate 	 * uint64_t	*ib_config_state;
23060Sstevel@tonic-gate 	 * uint64_t	*xcb_config_state;
23070Sstevel@tonic-gate 	 */
23080Sstevel@tonic-gate 
23090Sstevel@tonic-gate 	/* Save the PEC configuration states */
23100Sstevel@tonic-gate 	pxu_p->pec_config_state = config_state;
23110Sstevel@tonic-gate 	for (i = 0; i < PEC_KEYS; i++) {
23120Sstevel@tonic-gate 		pxu_p->pec_config_state[i] =
23130Sstevel@tonic-gate 		    CSR_XR((caddr_t)dev_hdl, pec_config_state_regs[i]);
23140Sstevel@tonic-gate 	}
23150Sstevel@tonic-gate 
23160Sstevel@tonic-gate 	/* Save the MMU configuration states */
23170Sstevel@tonic-gate 	pxu_p->mmu_config_state = pxu_p->pec_config_state + PEC_KEYS;
23180Sstevel@tonic-gate 	for (i = 0; i < MMU_KEYS; i++) {
23190Sstevel@tonic-gate 		pxu_p->mmu_config_state[i] =
23200Sstevel@tonic-gate 		    CSR_XR((caddr_t)dev_hdl, mmu_config_state_regs[i]);
23210Sstevel@tonic-gate 	}
23220Sstevel@tonic-gate 
23230Sstevel@tonic-gate 	/* Save the interrupt mapping registers */
23240Sstevel@tonic-gate 	pxu_p->ib_intr_map = pxu_p->mmu_config_state + MMU_KEYS;
23250Sstevel@tonic-gate 	for (i = 0; i < INTERRUPT_MAPPING_ENTRIES; i++) {
23260Sstevel@tonic-gate 		pxu_p->ib_intr_map[i] =
23270Sstevel@tonic-gate 		    CSRA_XR((caddr_t)dev_hdl, INTERRUPT_MAPPING, i);
23280Sstevel@tonic-gate 	}
23290Sstevel@tonic-gate 
23300Sstevel@tonic-gate 	/* Save the IB configuration states */
23310Sstevel@tonic-gate 	pxu_p->ib_config_state = pxu_p->ib_intr_map + INTERRUPT_MAPPING_ENTRIES;
23320Sstevel@tonic-gate 	for (i = 0; i < IB_KEYS; i++) {
23330Sstevel@tonic-gate 		pxu_p->ib_config_state[i] =
23340Sstevel@tonic-gate 		    CSR_XR((caddr_t)dev_hdl, ib_config_state_regs[i]);
23350Sstevel@tonic-gate 	}
23360Sstevel@tonic-gate 
23370Sstevel@tonic-gate 	return (H_EOK);
23380Sstevel@tonic-gate }
23390Sstevel@tonic-gate 
23400Sstevel@tonic-gate void
23410Sstevel@tonic-gate hvio_resume(devhandle_t dev_hdl, devino_t devino, pxu_t *pxu_p)
23420Sstevel@tonic-gate {
23430Sstevel@tonic-gate 	int		total_size;
23440Sstevel@tonic-gate 	sysino_t	sysino;
23450Sstevel@tonic-gate 	int		i;
23460Sstevel@tonic-gate 
23470Sstevel@tonic-gate 	/* Make sure that suspend actually did occur */
23480Sstevel@tonic-gate 	if (!pxu_p->pec_config_state) {
23490Sstevel@tonic-gate 		return;
23500Sstevel@tonic-gate 	}
23510Sstevel@tonic-gate 
23520Sstevel@tonic-gate 	/* Restore IB configuration states */
23530Sstevel@tonic-gate 	for (i = 0; i < IB_KEYS; i++) {
23540Sstevel@tonic-gate 		CSR_XS((caddr_t)dev_hdl, ib_config_state_regs[i],
23550Sstevel@tonic-gate 		    pxu_p->ib_config_state[i]);
23560Sstevel@tonic-gate 	}
23570Sstevel@tonic-gate 
23580Sstevel@tonic-gate 	/*
23590Sstevel@tonic-gate 	 * Restore the interrupt mapping registers
23600Sstevel@tonic-gate 	 * And make sure the intrs are idle.
23610Sstevel@tonic-gate 	 */
23620Sstevel@tonic-gate 	for (i = 0; i < INTERRUPT_MAPPING_ENTRIES; i++) {
23630Sstevel@tonic-gate 		CSRA_FS((caddr_t)dev_hdl, INTERRUPT_CLEAR, i,
23640Sstevel@tonic-gate 		    ENTRIES_INT_STATE, INTERRUPT_IDLE_STATE);
23650Sstevel@tonic-gate 		CSRA_XS((caddr_t)dev_hdl, INTERRUPT_MAPPING, i,
23660Sstevel@tonic-gate 		    pxu_p->ib_intr_map[i]);
23670Sstevel@tonic-gate 	}
23680Sstevel@tonic-gate 
23690Sstevel@tonic-gate 	/* Restore MMU configuration states */
23700Sstevel@tonic-gate 	/* Clear the cache. */
23710Sstevel@tonic-gate 	CSR_XS((caddr_t)dev_hdl, MMU_TTE_CACHE_INVALIDATE, -1ull);
23720Sstevel@tonic-gate 
23730Sstevel@tonic-gate 	for (i = 0; i < MMU_KEYS; i++) {
23740Sstevel@tonic-gate 		CSR_XS((caddr_t)dev_hdl, mmu_config_state_regs[i],
23750Sstevel@tonic-gate 		    pxu_p->mmu_config_state[i]);
23760Sstevel@tonic-gate 	}
23770Sstevel@tonic-gate 
23780Sstevel@tonic-gate 	/* Restore PEC configuration states */
23790Sstevel@tonic-gate 	/* Make sure all reset bits are low until error is detected */
23800Sstevel@tonic-gate 	CSR_XS((caddr_t)dev_hdl, LPU_RESET, 0ull);
23810Sstevel@tonic-gate 
23820Sstevel@tonic-gate 	for (i = 0; i < PEC_KEYS; i++) {
23830Sstevel@tonic-gate 		CSR_XS((caddr_t)dev_hdl, pec_config_state_regs[i],
23840Sstevel@tonic-gate 		    pxu_p->pec_config_state[i]);
23850Sstevel@tonic-gate 	}
23860Sstevel@tonic-gate 
23870Sstevel@tonic-gate 	/* Enable PCI-E interrupt */
23880Sstevel@tonic-gate 	(void) hvio_intr_devino_to_sysino(dev_hdl, pxu_p, devino, &sysino);
23890Sstevel@tonic-gate 
23900Sstevel@tonic-gate 	(void) hvio_intr_setstate(dev_hdl, sysino, INTR_IDLE_STATE);
23910Sstevel@tonic-gate 
23920Sstevel@tonic-gate 	total_size = PEC_SIZE + MMU_SIZE + IB_SIZE + IB_MAP_SIZE;
23930Sstevel@tonic-gate 	kmem_free(pxu_p->pec_config_state, total_size);
23940Sstevel@tonic-gate 
23950Sstevel@tonic-gate 	pxu_p->pec_config_state = NULL;
23960Sstevel@tonic-gate 	pxu_p->mmu_config_state = NULL;
23970Sstevel@tonic-gate 	pxu_p->ib_config_state = NULL;
23980Sstevel@tonic-gate 	pxu_p->ib_intr_map = NULL;
23990Sstevel@tonic-gate 
24000Sstevel@tonic-gate 	msiq_resume(dev_hdl, pxu_p);
24010Sstevel@tonic-gate }
24020Sstevel@tonic-gate 
24030Sstevel@tonic-gate uint64_t
24040Sstevel@tonic-gate hvio_cb_suspend(devhandle_t dev_hdl, pxu_t *pxu_p)
24050Sstevel@tonic-gate {
24060Sstevel@tonic-gate 	uint64_t	*config_state;
24070Sstevel@tonic-gate 	int		i;
24080Sstevel@tonic-gate 
24090Sstevel@tonic-gate 	config_state = kmem_zalloc(CB_SIZE, KM_NOSLEEP);
24100Sstevel@tonic-gate 
24110Sstevel@tonic-gate 	if (config_state == NULL) {
24120Sstevel@tonic-gate 		return (H_EIO);
24130Sstevel@tonic-gate 	}
24140Sstevel@tonic-gate 
24150Sstevel@tonic-gate 	/* Save the configuration states */
24160Sstevel@tonic-gate 	pxu_p->xcb_config_state = config_state;
24170Sstevel@tonic-gate 	for (i = 0; i < CB_KEYS; i++) {
24180Sstevel@tonic-gate 		pxu_p->xcb_config_state[i] =
24190Sstevel@tonic-gate 		    CSR_XR((caddr_t)dev_hdl, cb_config_state_regs[i]);
24200Sstevel@tonic-gate 	}
24210Sstevel@tonic-gate 
24220Sstevel@tonic-gate 	return (H_EOK);
24230Sstevel@tonic-gate }
24240Sstevel@tonic-gate 
24250Sstevel@tonic-gate void
24260Sstevel@tonic-gate hvio_cb_resume(devhandle_t pci_dev_hdl, devhandle_t xbus_dev_hdl,
24270Sstevel@tonic-gate     devino_t devino, pxu_t *pxu_p)
24280Sstevel@tonic-gate {
24290Sstevel@tonic-gate 	sysino_t	sysino;
24300Sstevel@tonic-gate 	int		i;
24310Sstevel@tonic-gate 
24320Sstevel@tonic-gate 	/*
24330Sstevel@tonic-gate 	 * No reason to have any reset bits high until an error is
24340Sstevel@tonic-gate 	 * detected on the link.
24350Sstevel@tonic-gate 	 */
24360Sstevel@tonic-gate 	CSR_XS((caddr_t)xbus_dev_hdl, JBC_ERROR_STATUS_CLEAR, -1ull);
24370Sstevel@tonic-gate 
24380Sstevel@tonic-gate 	ASSERT(pxu_p->xcb_config_state);
24390Sstevel@tonic-gate 
24400Sstevel@tonic-gate 	/* Restore the configuration states */
24410Sstevel@tonic-gate 	for (i = 0; i < CB_KEYS; i++) {
24420Sstevel@tonic-gate 		CSR_XS((caddr_t)xbus_dev_hdl, cb_config_state_regs[i],
24430Sstevel@tonic-gate 		    pxu_p->xcb_config_state[i]);
24440Sstevel@tonic-gate 	}
24450Sstevel@tonic-gate 
24460Sstevel@tonic-gate 	/* Enable XBC interrupt */
24470Sstevel@tonic-gate 	(void) hvio_intr_devino_to_sysino(pci_dev_hdl, pxu_p, devino, &sysino);
24480Sstevel@tonic-gate 
24490Sstevel@tonic-gate 	(void) hvio_intr_setstate(pci_dev_hdl, sysino, INTR_IDLE_STATE);
24500Sstevel@tonic-gate 
24510Sstevel@tonic-gate 	kmem_free(pxu_p->xcb_config_state, CB_SIZE);
24520Sstevel@tonic-gate 
24530Sstevel@tonic-gate 	pxu_p->xcb_config_state = NULL;
24540Sstevel@tonic-gate }
24550Sstevel@tonic-gate 
24560Sstevel@tonic-gate static uint64_t
24570Sstevel@tonic-gate msiq_suspend(devhandle_t dev_hdl, pxu_t *pxu_p)
24580Sstevel@tonic-gate {
24590Sstevel@tonic-gate 	size_t	bufsz;
24600Sstevel@tonic-gate 	volatile uint64_t *cur_p;
24610Sstevel@tonic-gate 	int i;
24620Sstevel@tonic-gate 
24630Sstevel@tonic-gate 	bufsz = MSIQ_STATE_SIZE + MSIQ_MAPPING_SIZE + MSIQ_OTHER_SIZE;
24640Sstevel@tonic-gate 	if ((pxu_p->msiq_config_state = kmem_zalloc(bufsz, KM_NOSLEEP)) ==
24650Sstevel@tonic-gate 	    NULL)
24660Sstevel@tonic-gate 		return (H_EIO);
24670Sstevel@tonic-gate 
24680Sstevel@tonic-gate 	cur_p = pxu_p->msiq_config_state;
24690Sstevel@tonic-gate 
24700Sstevel@tonic-gate 	/* Save each EQ state */
24710Sstevel@tonic-gate 	for (i = 0; i < EVENT_QUEUE_STATE_ENTRIES; i++, cur_p++)
24720Sstevel@tonic-gate 		*cur_p = CSRA_XR((caddr_t)dev_hdl, EVENT_QUEUE_STATE, i);
24730Sstevel@tonic-gate 
24740Sstevel@tonic-gate 	/* Save MSI mapping registers */
24750Sstevel@tonic-gate 	for (i = 0; i < MSI_MAPPING_ENTRIES; i++, cur_p++)
24760Sstevel@tonic-gate 		*cur_p = CSRA_XR((caddr_t)dev_hdl, MSI_MAPPING, i);
24770Sstevel@tonic-gate 
24780Sstevel@tonic-gate 	/* Save all other MSIQ registers */
24790Sstevel@tonic-gate 	for (i = 0; i < MSIQ_OTHER_KEYS; i++, cur_p++)
24800Sstevel@tonic-gate 		*cur_p = CSR_XR((caddr_t)dev_hdl, msiq_config_other_regs[i]);
24810Sstevel@tonic-gate 	return (H_EOK);
24820Sstevel@tonic-gate }
24830Sstevel@tonic-gate 
24840Sstevel@tonic-gate static void
24850Sstevel@tonic-gate msiq_resume(devhandle_t dev_hdl, pxu_t *pxu_p)
24860Sstevel@tonic-gate {
24870Sstevel@tonic-gate 	size_t	bufsz;
24881046Sjchu 	uint64_t *cur_p, state;
24890Sstevel@tonic-gate 	int i;
24900Sstevel@tonic-gate 
24910Sstevel@tonic-gate 	bufsz = MSIQ_STATE_SIZE + MSIQ_MAPPING_SIZE + MSIQ_OTHER_SIZE;
24920Sstevel@tonic-gate 	cur_p = pxu_p->msiq_config_state;
24930Sstevel@tonic-gate 	/*
24940Sstevel@tonic-gate 	 * Initialize EQ base address register and
24950Sstevel@tonic-gate 	 * Interrupt Mondo Data 0 register.
24960Sstevel@tonic-gate 	 */
24970Sstevel@tonic-gate 	(void) hvio_msiq_init(dev_hdl, pxu_p);
24980Sstevel@tonic-gate 
24990Sstevel@tonic-gate 	/* Restore EQ states */
25000Sstevel@tonic-gate 	for (i = 0; i < EVENT_QUEUE_STATE_ENTRIES; i++, cur_p++) {
25011046Sjchu 		state = (*cur_p) & EVENT_QUEUE_STATE_ENTRIES_STATE_MASK;
25021046Sjchu 		if ((state == EQ_ACTIVE_STATE) || (state == EQ_ERROR_STATE))
25030Sstevel@tonic-gate 			CSRA_BS((caddr_t)dev_hdl, EVENT_QUEUE_CONTROL_SET,
25040Sstevel@tonic-gate 			    i, ENTRIES_EN);
25050Sstevel@tonic-gate 	}
25060Sstevel@tonic-gate 
25070Sstevel@tonic-gate 	/* Restore MSI mapping */
25080Sstevel@tonic-gate 	for (i = 0; i < MSI_MAPPING_ENTRIES; i++, cur_p++)
25090Sstevel@tonic-gate 		CSRA_XS((caddr_t)dev_hdl, MSI_MAPPING, i, *cur_p);
25100Sstevel@tonic-gate 
25110Sstevel@tonic-gate 	/*
25120Sstevel@tonic-gate 	 * Restore all other registers. MSI 32 bit address and
25130Sstevel@tonic-gate 	 * MSI 64 bit address are restored as part of this.
25140Sstevel@tonic-gate 	 */
25150Sstevel@tonic-gate 	for (i = 0; i < MSIQ_OTHER_KEYS; i++, cur_p++)
25160Sstevel@tonic-gate 		CSR_XS((caddr_t)dev_hdl, msiq_config_other_regs[i], *cur_p);
25170Sstevel@tonic-gate 
25180Sstevel@tonic-gate 	kmem_free(pxu_p->msiq_config_state, bufsz);
25190Sstevel@tonic-gate 	pxu_p->msiq_config_state = NULL;
25200Sstevel@tonic-gate }
25210Sstevel@tonic-gate 
25220Sstevel@tonic-gate /*
25230Sstevel@tonic-gate  * sends PME_Turn_Off message to put the link in L2/L3 ready state.
25240Sstevel@tonic-gate  * called by px_goto_l23ready.
25250Sstevel@tonic-gate  * returns DDI_SUCCESS or DDI_FAILURE
25260Sstevel@tonic-gate  */
25270Sstevel@tonic-gate int
25280Sstevel@tonic-gate px_send_pme_turnoff(caddr_t csr_base)
25290Sstevel@tonic-gate {
25300Sstevel@tonic-gate 	volatile uint64_t reg;
25310Sstevel@tonic-gate 
25320Sstevel@tonic-gate 	reg = CSR_XR(csr_base, TLU_PME_TURN_OFF_GENERATE);
25330Sstevel@tonic-gate 	/* If already pending, return failure */
25340Sstevel@tonic-gate 	if (reg & (1ull << TLU_PME_TURN_OFF_GENERATE_PTO)) {
2535118Sjchu 		DBG(DBG_PWR, NULL, "send_pme_turnoff: pending PTO bit "
2536118Sjchu 		    "tlu_pme_turn_off_generate = %x\n", reg);
25370Sstevel@tonic-gate 		return (DDI_FAILURE);
25380Sstevel@tonic-gate 	}
253927Sjchu 
25400Sstevel@tonic-gate 	/* write to PME_Turn_off reg to boradcast */
25410Sstevel@tonic-gate 	reg |= (1ull << TLU_PME_TURN_OFF_GENERATE_PTO);
25420Sstevel@tonic-gate 	CSR_XS(csr_base,  TLU_PME_TURN_OFF_GENERATE, reg);
2543118Sjchu 
25440Sstevel@tonic-gate 	return (DDI_SUCCESS);
25450Sstevel@tonic-gate }
2546118Sjchu 
2547118Sjchu /*
2548118Sjchu  * Checks for link being in L1idle state.
2549118Sjchu  * Returns
2550118Sjchu  * DDI_SUCCESS - if the link is in L1idle
2551118Sjchu  * DDI_FAILURE - if the link is not in L1idle
2552118Sjchu  */
2553118Sjchu int
2554118Sjchu px_link_wait4l1idle(caddr_t csr_base)
2555118Sjchu {
2556118Sjchu 	uint8_t ltssm_state;
2557118Sjchu 	int ntries = px_max_l1_tries;
2558118Sjchu 
2559118Sjchu 	while (ntries > 0) {
2560118Sjchu 		ltssm_state = CSR_FR(csr_base, LPU_LTSSM_STATUS1, LTSSM_STATE);
2561118Sjchu 		if (ltssm_state == LPU_LTSSM_L1_IDLE || (--ntries <= 0))
2562118Sjchu 			break;
2563118Sjchu 		delay(1);
2564118Sjchu 	}
2565118Sjchu 	DBG(DBG_PWR, NULL, "check_for_l1idle: ltssm_state %x\n", ltssm_state);
2566118Sjchu 	return ((ltssm_state == LPU_LTSSM_L1_IDLE) ? DDI_SUCCESS : DDI_FAILURE);
2567118Sjchu }
2568118Sjchu 
2569118Sjchu /*
2570118Sjchu  * Tranisition the link to L0, after it is down.
2571118Sjchu  */
2572118Sjchu int
2573118Sjchu px_link_retrain(caddr_t csr_base)
2574118Sjchu {
2575118Sjchu 	volatile uint64_t reg;
2576118Sjchu 
2577118Sjchu 	reg = CSR_XR(csr_base, TLU_CONTROL);
2578118Sjchu 	if (!(reg & (1ull << TLU_REMAIN_DETECT_QUIET))) {
2579118Sjchu 		DBG(DBG_PWR, NULL, "retrain_link: detect.quiet bit not set\n");
2580118Sjchu 		return (DDI_FAILURE);
2581118Sjchu 	}
2582118Sjchu 
2583118Sjchu 	/* Clear link down bit in TLU Other Event Clear Status Register. */
2584118Sjchu 	CSR_BS(csr_base, TLU_OTHER_EVENT_STATUS_CLEAR, LDN_P);
2585118Sjchu 
2586118Sjchu 	/* Clear Drain bit in TLU Status Register */
2587118Sjchu 	CSR_BS(csr_base, TLU_STATUS, DRAIN);
2588118Sjchu 
2589118Sjchu 	/* Clear Remain in Detect.Quiet bit in TLU Control Register */
2590118Sjchu 	reg = CSR_XR(csr_base, TLU_CONTROL);
2591118Sjchu 	reg &= ~(1ull << TLU_REMAIN_DETECT_QUIET);
2592118Sjchu 	CSR_XS(csr_base, TLU_CONTROL, reg);
2593118Sjchu 
2594118Sjchu 	return (DDI_SUCCESS);
2595118Sjchu }
2596118Sjchu 
2597118Sjchu void
2598118Sjchu px_enable_detect_quiet(caddr_t csr_base)
2599118Sjchu {
2600118Sjchu 	volatile uint64_t tlu_ctrl;
2601118Sjchu 
2602118Sjchu 	tlu_ctrl = CSR_XR(csr_base, TLU_CONTROL);
2603118Sjchu 	tlu_ctrl |= (1ull << TLU_REMAIN_DETECT_QUIET);
2604118Sjchu 	CSR_XS(csr_base, TLU_CONTROL, tlu_ctrl);
2605118Sjchu }
2606