* ========== Copyright Header Begin ==========================================
* OpenSPARC T2 Processor File: PCIeIommu4VBadTr2.s
* Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved
* 4150 Network Circle, Santa Clara, California 95054, U.S.A.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* For the avoidance of doubt, and except that if any non-GPL license
* choice is available it will apply instead, Sun elects to use only
* the General Public License version 2 (GPLv2) at this time for any
* software where a choice of GPL license versions is made
* available with the language indicating that GPLv2 or any later version
* may be used, or where a choice of which version of the GPL is applied is
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* ========== Copyright Header End ============================================
#define ENABLE_PCIE_LINK_TRAINING
#define ENABLE_PCIE_MPS_512
#define MAIN_PAGE_HV_ALSO
#define H_HT0_Interrupt_0x60
#define My_HT0_Interrupt_0x60 \
#define MEM32_WR_ADDR mpeval(N2_PCIE_BASE_ADDR + MEM32_OFFSET_BASE_REG_DATA)
#define DMA_DATA_ADDR 0x000000000
#define IOMMU_TTE_ADDR 0x008000000
! Bits 6:4 = Page Size: 0=8KB, 1=64KB, 3=4MB, 5=256MB, othere are invalid
! Bits 3:0 = TSB Table size: 6=64k entries
#define IOTSBDESC_1_DATA mpeval((1<<63)|(IOMMU_TTE_ADDR << 21) | (0 << 4) | 0x2)
#define IOTSBDESC_2_DATA mpeval((1<<63)|(IOMMU_TTE_ADDR << 21) | (1 << 4) | 0x3)
#define IOTSBDESC_3_DATA mpeval((1<<63)|(IOMMU_TTE_ADDR << 21) | (2 << 4) | 0x4)
#define IOTSBDESC_4_DATA mpeval((1<<63)|(IOMMU_TTE_ADDR << 21) | (3 << 4) | 0x5)
#define IOTSBDESC_5_DATA mpeval((1<<63)|(IOMMU_TTE_ADDR << 21) | (4 << 4) | 0x6)
#define IOTSBDESC_6_DATA mpeval((1<<63)|(IOMMU_TTE_ADDR << 21) | (5 << 4) | 0x7)
#define IOTSBDESC_7_DATA mpeval((1<<63)|(IOMMU_TTE_ADDR << 21) | (6 << 4) | 0x8)
#define IOTSBDESC_8_DATA mpeval((1<<63)|(IOMMU_TTE_ADDR << 21) | (7 << 4) | 0x9)
/************************************************************************
************************************************************************/
! enable interrupts & provide basic handler (like piu_rupt_enable.s)
no_intr: ! Disable interrupts
xor %g7, 0x2, %g7 ! Reset interrupt enable
! Initialize NCU's Mondo Interrupt Vector Register
setx MONDO_INT_VEC, %g2, %g3
! Clear NCU's Mondo Interrupt Busy registers.
setx MONDO_INT_ABUSY, %g1, %g2
mmu_intr_enable_reg_init:
setx PCI_E_MMU_INT_ENB_ADDR, %g1, %g2
imu_intr_enable_reg_init:
setx PCI_E_IMU_INT_ENB_ADDR, %g1, %g2
! Initialize Interrupt Mapping register for Mondos 62 and 63
! Valid, thread ID 0, no interrupt controller
setx PCI_E_INT_MAP_ADDR, %g1, %g7
setx PCI_E_INT_MAP_MONDO_62_OFFSET, %g1, %g3
best_set_reg(0x80000040, %g1, %g6) ! valid = 1, thread id = 0
stx %g6, [%g7] ! interrupt controller = 1
add %g7, PCI_E_INT_MAP_STEP, %g7
best_set_reg(0x80000080, %g1, %g6) ! valid = 1, thread id = 0
stx %g6, [%g7] ! interrupt controller = 2
or %g7, 0x2, %g7 ! Set interrupt enable
! Enable IMU, MMU interrupts in the DMU Core and Block
! Interrupt Enable register.
setx PCI_E_DMU_CORE_BLK_INT_ENB_ADDR, %g1, %g2
! enable SUN4U translation in the IOMMU
setx FIRE_DLC_MMU_CSR_A_CTL_ADDR, %g1, %g2
setx 0x00307, %g1, %g3 ! 9:8 11 = Cache enabled,
! 3: 1 = Busid Select, 1 = use busid[5:0] for DEV2IOTSB index
! 0: 1 = translation enabled
! setup the DEV2IOTSB - the all busids map to IOTSBDESC ram entry 1
! (currently it looks like the denali transactor (or vera wrapper) is generating
! a random busid, so map them all to IOTSB 1.
setx FIRE_DLC_MMU_CSR_A_DEV2IOTSB_ADDR, %g1, %g2
setx 0x0001020304050607, %g1, %g3
! setup entry 1 of the IOTSBDESC ram
setx FIRE_DLC_MMU_CSR_A_IOTSBDESC_ADDR, %g1, %g2
setx IOTSBDESC_1_DATA, %g1, %g3
setx IOTSBDESC_2_DATA, %g1, %g4
setx IOTSBDESC_3_DATA, %g1, %g5
setx IOTSBDESC_4_DATA, %g1, %g6
setx IOTSBDESC_5_DATA, %g1, %g3
setx IOTSBDESC_6_DATA, %g1, %g4
setx IOTSBDESC_7_DATA, %g1, %g5
setx IOTSBDESC_8_DATA, %g1, %g6
! Trigger some DMA Writes which are not bypass addresses, because bits
! $EV trig_pc_d(1,@VA(.MAIN.DMAWR1)) -> EnablePCIeIgCmd("DMAWR", fffe000000000000, fffe0000ffffffff, "64'h100",1)
! $EV trig_pc_d(1,@VA(.MAIN.DMAWR2)) -> EnablePCIeIgCmd("DMAWR", fffd000000000000, fffd0000ffffffff, "64'h100",1)
! $EV trig_pc_d(1,@VA(.MAIN.DMAWR3)) -> EnablePCIeIgCmd("DMAWR", fffc800000000000, fffc8000ffffffff, "64'h100",1)
! $EV trig_pc_d(1,@VA(.MAIN.DMAWR4)) -> EnablePCIeIgCmd("DMAWR", fffc400000000000, fffc4000ffffffff, "64'h100",1)
! $EV trig_pc_d(1,@VA(.MAIN.DMAWR5)) -> EnablePCIeIgCmd("DMAWR", fffc200000000000, fffc2000ffffffff, "64'h100",1)
! $EV trig_pc_d(1,@VA(.MAIN.DMAWR6)) -> EnablePCIeIgCmd("DMAWR", fffc100000000000, fffc1000ffffffff, "64'h100",1)
! $EV trig_pc_d(1,@VA(.MAIN.DMAWR7)) -> EnablePCIeIgCmd("DMAWR", fffc080000000000, fffc0800ffffffff, "64'h100",1)
! $EV trig_pc_d(1,@VA(.MAIN.DMAWR8)) -> EnablePCIeIgCmd("DMAWR", fffc040000000000, fffc0400ffffffff, "64'h100",1)
! $EV trig_pc_d(1,@VA(.MAIN.DMAWR9)) -> EnablePCIeIgCmd("DMAWR", fffc020000000000, fffc0200ffffffff, "64'h100",1)
! $EV trig_pc_d(1,@VA(.MAIN.DMAWRa)) -> EnablePCIeIgCmd("DMAWR", fffc010000000000, fffc0100ffffffff, "64'h100",1)
! Trigger some DMA Reads of various lengths
setx 0x00001F00, %g1, %g2 ! DMA start address
setx 0x00001F00, %g1, %g3 ! page size
#define DMA_ADDR_01 mpeval(0x0000001F00 + 0,16,16)
#define DMA_ADDR_02 mpeval(0x0000001F00 + 64,16,16)
! $EV trig_pc_d(1,@VA(.MAIN.DMA0)) -> EnablePCIeIgCmd("DMARD", DMA_ADDR_01, DMA_ADDR_02, "64'h100",1)
#define DMA_ADDR_11 mpeval(0x0000002F00 + 0,16,16)
#define DMA_ADDR_12 mpeval(0x0000002F00 + 64,16,16)
! $EV trig_pc_d(1,@VA(.MAIN.DMA1)) -> EnablePCIeIgCmd("DMARD", DMA_ADDR_11, DMA_ADDR_12, "64'h100",1)
#define DMA_ADDR_21 mpeval(0x0000003F00 + 0,16,16)
#define DMA_ADDR_22 mpeval(0x0000003F00 + 64,16,16)
! $EV trig_pc_d(1,@VA(.MAIN.DMA2)) -> EnablePCIeIgCmd("DMARD", DMA_ADDR_21, DMA_ADDR_22, "64'h100",1)
#define DMA_ADDR_31 mpeval(0x0000004F00 + 0,16,16)
#define DMA_ADDR_32 mpeval(0x0000004F00 + 64,16,16)
! $EV trig_pc_d(1,@VA(.MAIN.DMA3)) -> EnablePCIeIgCmd("DMARD", DMA_ADDR_31, DMA_ADDR_32, "64'h100",1)
#define DMA_ADDR_41 mpeval(0x0000005F00 + 0,16,16)
#define DMA_ADDR_42 mpeval(0x0000005F00 + 64,16,16)
! $EV trig_pc_d(1,@VA(.MAIN.DMA4)) -> EnablePCIeIgCmd("DMARD", DMA_ADDR_41, DMA_ADDR_42, "64'h100",1)
#define DMA_ADDR_51 mpeval(0x0000006F00 + 0,16,16)
#define DMA_ADDR_52 mpeval(0x0000006F00 + 64,16,16)
! $EV trig_pc_d(1,@VA(.MAIN.DMA5)) -> EnablePCIeIgCmd("DMARD", DMA_ADDR_51, DMA_ADDR_52, "64'h100",1)
! select a MEM32 address in PCI address range and transmit the command to NCU
setx MEM32_WR_ADDR, %g1, %g2
set 5, %g4 ! loop 5 times
stx %g2, [%g2] ! MEM32 PIO Write
ldx [%g2], %l0 ! MEM32 PIO READ
add %g2, 8, %g2 ! increment PIO address
dec %g4 ! decrement counter
brnz %g4, delay_loop ! loop if not zero
/**********************************************************************
**********************************************************************/
! read DMU error status registers
setx FIRE_DLC_IMU_ICS_CSR_A_IMU_ERROR_LOG_EN_REG_ADDR, %g1, %g5 ! 631000
ldx [%g5+0x808], %l7 ! 631808 - DMU Core and Block Error Status Reg
bz test_failed ! if 0, must be a PEU interrupt
and %l7, 0x2, %l6 ! test if the MMU has an interrupt
ldx [%g5+0x10], %l3 ! 631010 - IMU Interrupt Status Reg
ldx [%g5+0x28], %l4 ! 631028 - IMU RDS Error Log Reg
ldx [%g5+0x30], %l5 ! 631030 - IMU SCS Error Log Reg
ldx [%g5+0x38], %l6 ! 631038 - IMU EQS Error Log Reg
ba test_failed ! No errors expected - go to bad trap
setx FIRE_DLC_MMU_CSR_A_LOG_ADDR, %g1, %g6 ! 641000
ldx [%g6+0x10], %l0 ! 641010 - MMU Interrupt Status Reg
stx %l0, [%g6+0x18] ! 641018 - MMU Status Clear Reg
ldx [%g6+0x28], %l1 ! 641028 - MMU Translation Fault Address Reg
ldx [%g6+0x30], %l2 ! 641030 - MMU Translation Fault Status Reg
best_set_reg(mpeval(PCI_E_INT_CLEAR_ADDR+PCI_E_INT_CLEAR_MONDO_62_OFFSET), %g1, %g6)
ldx [%g6], %g1 ! get mondo62 int state
stx %g0, [%g6] ! clear mondo 62 int state
ldx [%g6+8], %g1 ! get mondo63 int state
stx %g0, [%g6+8] ! clear mondo 63 int state
best_set_reg(MONDO_INT_ABUSY, %g1, %g7)
ldxa [%g0]ASI_SWVR_INTR_R, %l5
/************************************************************************
************************************************************************/
/************************************************************************
63: 48 DEV KEY - set to 0
47: 39 reserved - set to 0
38: 13 DATA PA - set to VA for VA=RA
12: 7 DATA_SOFT - set to 0
2: 2 KEY VALID - set to 0
************************************************************************/
SECTION .DATA2 DATA_VA=IOMMU_TTE_ADDR
init_mem(0x0000000000000003, 66, 8, +, 0, +, 0x0000000010000000)
/************************************************************************/