xref: /titanic_52/usr/src/uts/sun4u/sys/sysiosbus.h (revision 9c75c6bf17b72bb057d7a8879feba77ece65241a)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*
237c478bd9Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate #ifndef _SYS_SYSIOSBUS_H
287c478bd9Sstevel@tonic-gate #define	_SYS_SYSIOSBUS_H
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate #ifndef _ASM
337c478bd9Sstevel@tonic-gate #include <sys/avintr.h>
347c478bd9Sstevel@tonic-gate #include <sys/vmem.h>
357c478bd9Sstevel@tonic-gate #include <sys/ontrap.h>
367c478bd9Sstevel@tonic-gate #include <sys/machsystm.h>
377c478bd9Sstevel@tonic-gate #endif
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
407c478bd9Sstevel@tonic-gate extern "C" {
417c478bd9Sstevel@tonic-gate #endif
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate /* Things for debugging */
447c478bd9Sstevel@tonic-gate #ifdef SYSIO_MEM_DEBUG
457c478bd9Sstevel@tonic-gate #define	IO_MEMUSAGE
467c478bd9Sstevel@tonic-gate #endif /* SYSIO_MEM_DEBUG */
477c478bd9Sstevel@tonic-gate 
487c478bd9Sstevel@tonic-gate /*
497c478bd9Sstevel@tonic-gate  * sysio sbus constant definitions.
507c478bd9Sstevel@tonic-gate  */
517c478bd9Sstevel@tonic-gate #define	NATURAL_REG_SIZE	0x8	/* 8 Bytes is Fusion reg size */
527c478bd9Sstevel@tonic-gate #define	MIN_REG_SIZE		0x4	/* Smallest Fusion reg size */
537c478bd9Sstevel@tonic-gate #define	OFF_SYSIO_CTRL_REG	0x10
547c478bd9Sstevel@tonic-gate #define	SYSIO_CTRL_REG_SIZE	(NATURAL_REG_SIZE)
557c478bd9Sstevel@tonic-gate #define	OFF_SBUS_CTRL_REG	0x2000
567c478bd9Sstevel@tonic-gate #define	SBUS_CTRL_REG_SIZE	(NATURAL_REG_SIZE)
577c478bd9Sstevel@tonic-gate #define	OFF_SBUS_SLOT_CONFIG	0x2020
587c478bd9Sstevel@tonic-gate #define	SBUS_SLOT_CONFIG_SIZE	(NATURAL_REG_SIZE * 7)
597c478bd9Sstevel@tonic-gate #define	OFF_INTR_MAPPING_REG	0x2c00
607c478bd9Sstevel@tonic-gate /* #define	INTR_MAPPING_REG_SIZE	(NATURAL_REG_SIZE * 16 * 8)  */
617c478bd9Sstevel@tonic-gate #define	INTR_MAPPING_REG_SIZE	0x490
627c478bd9Sstevel@tonic-gate #define	OFF_CLR_INTR_REG	0x3408
637c478bd9Sstevel@tonic-gate /* #define	CLR_INTR_REG_SIZE	(NATURAL_REG_SIZE * 16 * 8) */
647c478bd9Sstevel@tonic-gate #define	CLR_INTR_REG_SIZE	0x488
657c478bd9Sstevel@tonic-gate #define	OFF_INTR_RETRY_REG	0x2c20
667c478bd9Sstevel@tonic-gate #define	INTR_RETRY_REG_SIZE	(MIN_REG_SIZE)
677c478bd9Sstevel@tonic-gate #define	OFF_SBUS_INTR_STATE_REG	0x4800
687c478bd9Sstevel@tonic-gate #define	SBUS_INTR_STATE_REG_SIZE (NATURAL_REG_SIZE * 2)
697c478bd9Sstevel@tonic-gate #define	SYSIO_IGN		46
707c478bd9Sstevel@tonic-gate #define	SBUS_ARBIT_ALL		0x3full
717c478bd9Sstevel@tonic-gate #define	SYSIO_VER_SHIFT		56
727c478bd9Sstevel@tonic-gate 
737c478bd9Sstevel@tonic-gate /* Error registers */
747c478bd9Sstevel@tonic-gate #define	OFF_SYSIO_ECC_REGS	0x20
757c478bd9Sstevel@tonic-gate #define	SYSIO_ECC_REGS_SIZE	NATURAL_REG_SIZE
767c478bd9Sstevel@tonic-gate #define	OFF_SYSIO_UE_REGS	0x30
777c478bd9Sstevel@tonic-gate #define	SYSIO_UE_REGS_SIZE	(NATURAL_REG_SIZE * 2)
787c478bd9Sstevel@tonic-gate #define	OFF_SYSIO_CE_REGS	0x40
797c478bd9Sstevel@tonic-gate #define	SYSIO_CE_REGS_SIZE	(NATURAL_REG_SIZE * 2)
807c478bd9Sstevel@tonic-gate #define	OFF_SBUS_ERR_REGS	0x2010
817c478bd9Sstevel@tonic-gate #define	SBUS_ERR_REGS_SIZE	(NATURAL_REG_SIZE * 2)
827c478bd9Sstevel@tonic-gate 
837c478bd9Sstevel@tonic-gate /* Interrupts */
847c478bd9Sstevel@tonic-gate #define	INTERRUPT_CPU_FIELD	26	/* Bit shift for mondo TID field */
857c478bd9Sstevel@tonic-gate #define	INTERRUPT_GROUP_NUMBER	6	/* Bit shift for mondo IGN field */
867c478bd9Sstevel@tonic-gate #define	INTERRUPT_VALID		0x80000000ull /* Mondo valid bit */
877c478bd9Sstevel@tonic-gate #define	SBUS_INTR_IDLE		0ull
887c478bd9Sstevel@tonic-gate #define	INT_PENDING 		3	/* state of the interrupt dispatch */
897c478bd9Sstevel@tonic-gate /*
907c478bd9Sstevel@tonic-gate  * Fix these (RAZ)
917c478bd9Sstevel@tonic-gate  * Interrupt Mapping Register defines
927c478bd9Sstevel@tonic-gate  */
937c478bd9Sstevel@tonic-gate #define	IMR_VALID		0x80000000ull	/* Valid bit */
947c478bd9Sstevel@tonic-gate #define	IMR_TID			0x7C000000ull	/* TID bits */
957c478bd9Sstevel@tonic-gate #define	IMR_IGN			0x000007C0ull	/* IGN bits */
967c478bd9Sstevel@tonic-gate #define	IMR_INO			0x0000003Full	/* INO bits */
977c478bd9Sstevel@tonic-gate #define	IMR_TID_SHIFT		26		/* Bit shift for TID field */
987c478bd9Sstevel@tonic-gate #define	IMR_IGN_SHIFT		6		/* Bit shift for IGN field */
997c478bd9Sstevel@tonic-gate 
1007c478bd9Sstevel@tonic-gate #define	MAX_SBUS		(30)
1017c478bd9Sstevel@tonic-gate #define	MAX_SBUS_LEVEL		(7)
1027c478bd9Sstevel@tonic-gate #define	MAX_SBUS_SLOTS	(7)		/* 4 external slots + 3 internal */
1037c478bd9Sstevel@tonic-gate #define	EXT_SBUS_SLOTS		4	/* Number of external sbus slots */
1047c478bd9Sstevel@tonic-gate #define	MAX_SBUS_SLOT_ADDR	0x10	/* Max slot address on SYSIO */
1057c478bd9Sstevel@tonic-gate #define	SYSIO_BURST_RANGE	(0x7f)	/* 32 bit: 64 Byte to 1 Byte burst */
1067c478bd9Sstevel@tonic-gate #define	SYSIO64_BURST_RANGE	(0x78)	/* 64 bit: 64 Byte to 8 Byte burst */
1077c478bd9Sstevel@tonic-gate #define	SYSIO_BURST_MASK	0xffff
1087c478bd9Sstevel@tonic-gate #define	SYSIO64_BURST_MASK	0xffff0000
1097c478bd9Sstevel@tonic-gate #define	SYSIO64_BURST_SHIFT	16
1107c478bd9Sstevel@tonic-gate #define	MAX_PIL			16
1117c478bd9Sstevel@tonic-gate 
1127c478bd9Sstevel@tonic-gate /* Slot config register defines */
1137c478bd9Sstevel@tonic-gate #define	SBUS_ETM		0x4000ull
1147c478bd9Sstevel@tonic-gate #define	SYSIO_SLAVEBURST_MASK	0x1e	/* Mask for hardware register */
1157c478bd9Sstevel@tonic-gate #define	SYSIO_SLAVEBURST_RANGE	(0x78)	/* 32 bit: 64 Byte to 8 Byte burst */
1167c478bd9Sstevel@tonic-gate #define	SYSIO64_SLAVEBURST_RANGE (0x78)	/* 64 bit: 64 Byte to 8 Byte burst */
1177c478bd9Sstevel@tonic-gate #define	SYSIO_SLAVEBURST_REGSHIFT 2	/* Convert bit positions 2**8 to 2**1 */
1187c478bd9Sstevel@tonic-gate 
1197c478bd9Sstevel@tonic-gate /*
1207c478bd9Sstevel@tonic-gate  * Offsets of sysio, sbus, registers
1217c478bd9Sstevel@tonic-gate  */
1227c478bd9Sstevel@tonic-gate /* Slot configuration register mapping offsets */
1237c478bd9Sstevel@tonic-gate #define	SBUS_SLOT0_CONFIG	0x0
1247c478bd9Sstevel@tonic-gate #define	SBUS_SLOT1_CONFIG	0x1
1257c478bd9Sstevel@tonic-gate #define	SBUS_SLOT2_CONFIG	0x2
1267c478bd9Sstevel@tonic-gate #define	SBUS_SLOT3_CONFIG	0x3
1277c478bd9Sstevel@tonic-gate #define	SBUS_SLOT4_CONFIG	0x4
1287c478bd9Sstevel@tonic-gate #define	SBUS_SLOT5_CONFIG	0x5
1297c478bd9Sstevel@tonic-gate #define	SBUS_SLOT6_CONFIG	0x6
1307c478bd9Sstevel@tonic-gate 
1317c478bd9Sstevel@tonic-gate /* Interrupt mapping register mapping offsets */
1327c478bd9Sstevel@tonic-gate #define	SBUS_SLOT0_MAPREG	0x0
1337c478bd9Sstevel@tonic-gate #define	SBUS_SLOT1_MAPREG	0x1
1347c478bd9Sstevel@tonic-gate #define	SBUS_SLOT2_MAPREG	0x2
1357c478bd9Sstevel@tonic-gate #define	SBUS_SLOT3_MAPREG	0x3
1367c478bd9Sstevel@tonic-gate #define	ESP_MAPREG		0x80
1377c478bd9Sstevel@tonic-gate #define	ETHER_MAPREG		0x81
1387c478bd9Sstevel@tonic-gate #define	PP_MAPREG		0x82
1397c478bd9Sstevel@tonic-gate #define	AUDIO_MAPREG		0x83
1407c478bd9Sstevel@tonic-gate #define	KBDMOUSE_MAPREG		0x85
1417c478bd9Sstevel@tonic-gate #define	FLOPPY_MAPREG		0x86
1427c478bd9Sstevel@tonic-gate #define	THERMAL_MAPREG		0x87
1437c478bd9Sstevel@tonic-gate #define	TIMER0_MAPREG		0x8C
1447c478bd9Sstevel@tonic-gate #define	TIMER1_MAPREG		0x8D
1457c478bd9Sstevel@tonic-gate #define	UE_ECC_MAPREG		0x8E
1467c478bd9Sstevel@tonic-gate #define	CE_ECC_MAPREG		0x8F
1477c478bd9Sstevel@tonic-gate #define	SBUS_ERR_MAPREG		0x90
1487c478bd9Sstevel@tonic-gate #define	PM_WAKEUP_MAPREG	0x91
1497c478bd9Sstevel@tonic-gate #define	FFB_MAPPING_REG		0x92
1507c478bd9Sstevel@tonic-gate #define	EXP_MAPPING_REG		0x93
1517c478bd9Sstevel@tonic-gate 
1527c478bd9Sstevel@tonic-gate /* Interrupt clear register mapping offsets */
1537c478bd9Sstevel@tonic-gate #define	SBUS_SLOT0_L1_CLEAR	0x0
1547c478bd9Sstevel@tonic-gate #define	SBUS_SLOT0_L2_CLEAR	0x1
1557c478bd9Sstevel@tonic-gate #define	SBUS_SLOT0_L3_CLEAR	0x2
1567c478bd9Sstevel@tonic-gate #define	SBUS_SLOT0_L4_CLEAR	0x3
1577c478bd9Sstevel@tonic-gate #define	SBUS_SLOT0_L5_CLEAR	0x4
1587c478bd9Sstevel@tonic-gate #define	SBUS_SLOT0_L6_CLEAR	0x5
1597c478bd9Sstevel@tonic-gate #define	SBUS_SLOT0_L7_CLEAR	0x6
1607c478bd9Sstevel@tonic-gate #define	SBUS_SLOT1_L1_CLEAR	0x8
1617c478bd9Sstevel@tonic-gate #define	SBUS_SLOT1_L2_CLEAR	0x9
1627c478bd9Sstevel@tonic-gate #define	SBUS_SLOT1_L3_CLEAR	0xa
1637c478bd9Sstevel@tonic-gate #define	SBUS_SLOT1_L4_CLEAR	0xb
1647c478bd9Sstevel@tonic-gate #define	SBUS_SLOT1_L5_CLEAR	0xc
1657c478bd9Sstevel@tonic-gate #define	SBUS_SLOT1_L6_CLEAR	0xd
1667c478bd9Sstevel@tonic-gate #define	SBUS_SLOT1_L7_CLEAR	0xe
1677c478bd9Sstevel@tonic-gate #define	SBUS_SLOT2_L1_CLEAR	0x10
1687c478bd9Sstevel@tonic-gate #define	SBUS_SLOT2_L2_CLEAR	0x11
1697c478bd9Sstevel@tonic-gate #define	SBUS_SLOT2_L3_CLEAR	0x12
1707c478bd9Sstevel@tonic-gate #define	SBUS_SLOT2_L4_CLEAR	0x13
1717c478bd9Sstevel@tonic-gate #define	SBUS_SLOT2_L5_CLEAR	0x14
1727c478bd9Sstevel@tonic-gate #define	SBUS_SLOT2_L6_CLEAR	0x15
1737c478bd9Sstevel@tonic-gate #define	SBUS_SLOT2_L7_CLEAR	0x16
1747c478bd9Sstevel@tonic-gate #define	SBUS_SLOT3_L1_CLEAR	0x18
1757c478bd9Sstevel@tonic-gate #define	SBUS_SLOT3_L2_CLEAR	0x19
1767c478bd9Sstevel@tonic-gate #define	SBUS_SLOT3_L3_CLEAR	0x1a
1777c478bd9Sstevel@tonic-gate #define	SBUS_SLOT3_L4_CLEAR	0x1b
1787c478bd9Sstevel@tonic-gate #define	SBUS_SLOT3_L5_CLEAR	0x1c
1797c478bd9Sstevel@tonic-gate #define	SBUS_SLOT3_L6_CLEAR	0x1d
1807c478bd9Sstevel@tonic-gate #define	SBUS_SLOT3_L7_CLEAR	0x1e
1817c478bd9Sstevel@tonic-gate #define	ESP_CLEAR		0x7f
1827c478bd9Sstevel@tonic-gate #define	ETHER_CLEAR		0x80
1837c478bd9Sstevel@tonic-gate #define	PP_CLEAR		0x81
1847c478bd9Sstevel@tonic-gate #define	AUDIO_CLEAR		0x82
1857c478bd9Sstevel@tonic-gate #define	KBDMOUSE_CLEAR		0x84
1867c478bd9Sstevel@tonic-gate #define	FLOPPY_CLEAR		0x85
1877c478bd9Sstevel@tonic-gate #define	THERMAL_CLEAR		0x86
1887c478bd9Sstevel@tonic-gate #define	TIMER0_CLEAR		0x8B
1897c478bd9Sstevel@tonic-gate #define	TIMER1_CLEAR		0x8C
1907c478bd9Sstevel@tonic-gate #define	UE_ECC_CLEAR		0x8D
1917c478bd9Sstevel@tonic-gate #define	CE_ECC_CLEAR		0x8E
1927c478bd9Sstevel@tonic-gate #define	SBUS_ERR_CLEAR		0x8F
1937c478bd9Sstevel@tonic-gate #define	PM_WAKEUP_CLEAR		0x90
1947c478bd9Sstevel@tonic-gate 
1957c478bd9Sstevel@tonic-gate /*
1967c478bd9Sstevel@tonic-gate  * Bit shift for accessing the keyboard mouse interrupt state reg.
1977c478bd9Sstevel@tonic-gate  * note - The external devices are the only other devices where
1987c478bd9Sstevel@tonic-gate  * we need to check the interrupt state before adding or removing
1997c478bd9Sstevel@tonic-gate  * interrupts.  There is an algorithm to calculate their bit shift.
2007c478bd9Sstevel@tonic-gate  */
2017c478bd9Sstevel@tonic-gate #define	ESP_INTR_STATE_SHIFT		0
2027c478bd9Sstevel@tonic-gate #define	ETHER_INTR_STATE_SHIFT		2
2037c478bd9Sstevel@tonic-gate #define	PP_INTR_STATE_SHIFT		4
2047c478bd9Sstevel@tonic-gate #define	AUDIO_INTR_STATE_SHIFT		6
2057c478bd9Sstevel@tonic-gate #define	KBDMOUSE_INTR_STATE_SHIFT	10
2067c478bd9Sstevel@tonic-gate #define	FLOPPY_INTR_STATE_SHIFT		12
2077c478bd9Sstevel@tonic-gate #define	THERMAL_INTR_STATE_SHIFT	14
2087c478bd9Sstevel@tonic-gate #define	TIMER0_INTR_STATE_SHIFT		22
2097c478bd9Sstevel@tonic-gate #define	TIMER1_INTR_STATE_SHIFT		24
2107c478bd9Sstevel@tonic-gate #define	UE_INTR_STATE_SHIFT		26
2117c478bd9Sstevel@tonic-gate #define	CE_INTR_STATE_SHIFT		28
2127c478bd9Sstevel@tonic-gate #define	SERR_INTR_STATE_SHIFT		30
2137c478bd9Sstevel@tonic-gate #define	PM_INTR_STATE_SHIFT		32
2147c478bd9Sstevel@tonic-gate 
2157c478bd9Sstevel@tonic-gate #define	MAX_INO_TABLE_SIZE	58	/* Max num of sbus devices on sysio */
2167c478bd9Sstevel@tonic-gate #define	MAX_MONDO_EXTERNAL	0x1f
2177c478bd9Sstevel@tonic-gate #define	SBUS_MAX_INO		0x3f
2187c478bd9Sstevel@tonic-gate #define	THERMAL_MONDO		0x2a
2197c478bd9Sstevel@tonic-gate #define	UE_ECC_MONDO		0x34
2207c478bd9Sstevel@tonic-gate #define	CE_ECC_MONDO		0x35
2217c478bd9Sstevel@tonic-gate #define	SBUS_ERR_MONDO		0x36
2227c478bd9Sstevel@tonic-gate 
2237c478bd9Sstevel@tonic-gate /* used for the picN kstats */
2247c478bd9Sstevel@tonic-gate #define	SBUS_NUM_PICS	2
2257c478bd9Sstevel@tonic-gate #define	SBUS_NUM_EVENTS	14
2267c478bd9Sstevel@tonic-gate #define	SBUS_PIC0_MASK	0x00000000FFFFFFFFULL	/* pic0 bits of %pic */
2277c478bd9Sstevel@tonic-gate 
2287c478bd9Sstevel@tonic-gate /* Offsets for Performance registers */
2297c478bd9Sstevel@tonic-gate #define	OFF_SBUS_PCR	0x100
2307c478bd9Sstevel@tonic-gate #define	OFF_SBUS_PIC	0x108
2317c478bd9Sstevel@tonic-gate 
2327c478bd9Sstevel@tonic-gate /*
2337c478bd9Sstevel@tonic-gate  * used to build array of event-names and pcr-mask values
2347c478bd9Sstevel@tonic-gate  */
2357c478bd9Sstevel@tonic-gate typedef	struct	sbus_event_mask {
2367c478bd9Sstevel@tonic-gate 	char	*event_name;
2377c478bd9Sstevel@tonic-gate 	uint64_t pcr_mask;
2387c478bd9Sstevel@tonic-gate } sbus_event_mask_t;
2397c478bd9Sstevel@tonic-gate 
2407c478bd9Sstevel@tonic-gate /*
2417c478bd9Sstevel@tonic-gate  * This type is used to describe addresses that we expect a device
2427c478bd9Sstevel@tonic-gate  * to place on a bus i.e. addresses from the iommu address space.
2437c478bd9Sstevel@tonic-gate  */
2447c478bd9Sstevel@tonic-gate typedef	uint32_t	ioaddr_t;
2457c478bd9Sstevel@tonic-gate 
2467c478bd9Sstevel@tonic-gate 
2477c478bd9Sstevel@tonic-gate /*
2487c478bd9Sstevel@tonic-gate  * sysio sbus soft state data structure.
2497c478bd9Sstevel@tonic-gate  * We use the sbus_ctrl_reg to flush hardware store buffers because
2507c478bd9Sstevel@tonic-gate  * there is very little hardware contention on this register.
2517c478bd9Sstevel@tonic-gate  */
2527c478bd9Sstevel@tonic-gate struct sbus_soft_state {
2537c478bd9Sstevel@tonic-gate 	dev_info_t *dip;		/* dev info of myself */
2547c478bd9Sstevel@tonic-gate 	int upa_id;			/* UPA ID of this SYSIO */
2557c478bd9Sstevel@tonic-gate 
2567c478bd9Sstevel@tonic-gate 	/*
2577c478bd9Sstevel@tonic-gate 	 * device node address property:
2587c478bd9Sstevel@tonic-gate 	 */
2597c478bd9Sstevel@tonic-gate 	caddr_t address;
2607c478bd9Sstevel@tonic-gate 
2617c478bd9Sstevel@tonic-gate 	/*
2627c478bd9Sstevel@tonic-gate 	 * access handles in case we need to map the registers ourself:
2637c478bd9Sstevel@tonic-gate 	 */
2647c478bd9Sstevel@tonic-gate 	ddi_acc_handle_t ac;
2657c478bd9Sstevel@tonic-gate 
2667c478bd9Sstevel@tonic-gate 	volatile uint64_t *iommu_flush_reg; /* IOMMU regs */
2677c478bd9Sstevel@tonic-gate 	volatile uint64_t *iommu_ctrl_reg;
2687c478bd9Sstevel@tonic-gate 	volatile uint64_t *tsb_base_addr;  /* Hardware reg for phys TSB base */
2697c478bd9Sstevel@tonic-gate 	volatile uint64_t *soft_tsb_base_addr; /* virtual address of TSB base */
2707c478bd9Sstevel@tonic-gate 	volatile uint64_t *iommu_tlb_tag;
2717c478bd9Sstevel@tonic-gate 	volatile uint64_t *iommu_tlb_data;
2727c478bd9Sstevel@tonic-gate 
2737c478bd9Sstevel@tonic-gate 	size_t iommu_dvma_size;
2747c478bd9Sstevel@tonic-gate 	ioaddr_t iommu_dvma_base;
2757c478bd9Sstevel@tonic-gate 	uint16_t iommu_tsb_cookie;
2767c478bd9Sstevel@tonic-gate 
2777c478bd9Sstevel@tonic-gate 
2787c478bd9Sstevel@tonic-gate 	volatile uint64_t *sysio_ctrl_reg;	/* sysio regs */
2797c478bd9Sstevel@tonic-gate 	volatile uint64_t *sbus_ctrl_reg;   /* also used to flush store bufs */
2807c478bd9Sstevel@tonic-gate 	volatile uint64_t *sbus_slot_config_reg;
2817c478bd9Sstevel@tonic-gate 	uint_t sbus_slave_burstsizes[MAX_SBUS_SLOTS];
2827c478bd9Sstevel@tonic-gate 
2837c478bd9Sstevel@tonic-gate 	volatile uint64_t *intr_mapping_reg;	/* Interrupt regs */
2847c478bd9Sstevel@tonic-gate 	volatile uint64_t *clr_intr_reg;
2857c478bd9Sstevel@tonic-gate 	volatile uint64_t *intr_retry_reg;
2867c478bd9Sstevel@tonic-gate 	volatile uint64_t *sbus_intr_state;
2877c478bd9Sstevel@tonic-gate 	volatile uint64_t *obio_intr_state;
2887c478bd9Sstevel@tonic-gate 	int8_t intr_hndlr_cnt[MAX_SBUS_SLOT_ADDR]; /* intmapreg cntr by slot */
2897c478bd9Sstevel@tonic-gate 	uchar_t spurious_cntrs[MAX_PIL + 1];	/* Spurious intr counter */
2907c478bd9Sstevel@tonic-gate 
2917c478bd9Sstevel@tonic-gate 	volatile uint64_t *sysio_ecc_reg;	/* sysio ecc control reg */
2927c478bd9Sstevel@tonic-gate 	volatile uint64_t *sysio_ue_reg;	/* sysio ue ecc error regs */
2937c478bd9Sstevel@tonic-gate 	volatile uint64_t *sysio_ce_reg;	/* sysio ce ecc error regs */
2947c478bd9Sstevel@tonic-gate 	volatile uint64_t *sbus_err_reg;	/* sbus async error regs */
2957c478bd9Sstevel@tonic-gate 
2967c478bd9Sstevel@tonic-gate 	volatile uint64_t *str_buf_ctrl_reg;	/* streaming buffer regs */
2977c478bd9Sstevel@tonic-gate 	volatile uint64_t *str_buf_flush_reg;
2987c478bd9Sstevel@tonic-gate 	volatile uint64_t *str_buf_sync_reg;
2997c478bd9Sstevel@tonic-gate 	volatile uint64_t *str_buf_pg_tag_diag;
3007c478bd9Sstevel@tonic-gate 	kmutex_t sync_reg_lock;			/* lock around sync flush reg */
3017c478bd9Sstevel@tonic-gate 	int stream_buf_off;
3027c478bd9Sstevel@tonic-gate 
3037c478bd9Sstevel@tonic-gate 	uint_t sbus_burst_sizes;
3047c478bd9Sstevel@tonic-gate 	uint_t sbus64_burst_sizes;
3057c478bd9Sstevel@tonic-gate 
3067c478bd9Sstevel@tonic-gate 	vmem_t *dvma_arena;		/* DVMA arena for this IOMMU */
3077c478bd9Sstevel@tonic-gate 	uintptr_t dvma_call_list_id;	/* DVMA callback list */
3087c478bd9Sstevel@tonic-gate 	kmutex_t dma_pool_lock;
3097c478bd9Sstevel@tonic-gate 	caddr_t dmaimplbase;		/* dma_pool_lock protects this */
3107c478bd9Sstevel@tonic-gate 	int	dma_reserve;		/* Size reserved for fast DVMA */
3117c478bd9Sstevel@tonic-gate 
3127c478bd9Sstevel@tonic-gate 	struct sbus_wrapper_arg *intr_list[MAX_INO_TABLE_SIZE];
3137c478bd9Sstevel@tonic-gate 	kmutex_t intr_poll_list_lock;	/* to add/rem to intr poll list */
3147c478bd9Sstevel@tonic-gate 	kmutex_t pokefault_mutex;	/* mutex for pokefaults */
3157c478bd9Sstevel@tonic-gate 	on_trap_data_t *ontrap_data;	/* Data used to handle poke faults */
3167c478bd9Sstevel@tonic-gate 	hrtime_t bto_timestamp;		/* time of first timeout */
3177c478bd9Sstevel@tonic-gate 	int bto_ctr;			/* counter for timeouts thereafter */
3187c478bd9Sstevel@tonic-gate 	pfn_t sbus_io_lo_pfn;
3197c478bd9Sstevel@tonic-gate 	pfn_t sbus_io_hi_pfn;
3207c478bd9Sstevel@tonic-gate 	struct iophyslist *sbus_io_ranges;
3217c478bd9Sstevel@tonic-gate 	int intr_mapping_ign;		/* placeholder for the IGN */
3227c478bd9Sstevel@tonic-gate #ifdef	_STARFIRE
3237c478bd9Sstevel@tonic-gate 	caddr_t ittrans_cookie;		/* starfire intr target translation */
3247c478bd9Sstevel@tonic-gate #endif	/* _STARFIRE */
3257c478bd9Sstevel@tonic-gate #ifdef	DEBUG
3267c478bd9Sstevel@tonic-gate 	kmutex_t iomemlock;		/* Memory usage lock (debug only) */
3277c478bd9Sstevel@tonic-gate 	struct io_mem_list *iomem;	/* Memory usage list (debug only) */
3287c478bd9Sstevel@tonic-gate #endif /* DEBUG */
3297c478bd9Sstevel@tonic-gate 	/*
3307c478bd9Sstevel@tonic-gate 	 * Performance registers and kstat.
3317c478bd9Sstevel@tonic-gate 	 */
3327c478bd9Sstevel@tonic-gate 	volatile uint64_t *sbus_pcr;	/* perf counter control */
3337c478bd9Sstevel@tonic-gate 	volatile uint64_t *sbus_pic; 	/* perf counter register */
3347c478bd9Sstevel@tonic-gate 	kstat_t	*sbus_counters_ksp;	/* perf counter kstat */
3357c478bd9Sstevel@tonic-gate };
3367c478bd9Sstevel@tonic-gate 
3377c478bd9Sstevel@tonic-gate 
3387c478bd9Sstevel@tonic-gate /*
3397c478bd9Sstevel@tonic-gate  * Ugly interrupt cruft due to sysio inconsistencies.
3407c478bd9Sstevel@tonic-gate  */
3417c478bd9Sstevel@tonic-gate struct sbus_slot_entry {
3427c478bd9Sstevel@tonic-gate 	uint64_t slot_config;
3437c478bd9Sstevel@tonic-gate 	uint64_t mapping_reg;
3447c478bd9Sstevel@tonic-gate 	uint64_t clear_reg;
3457c478bd9Sstevel@tonic-gate 	int diagreg_shift;
3467c478bd9Sstevel@tonic-gate };
3477c478bd9Sstevel@tonic-gate 
3487c478bd9Sstevel@tonic-gate struct sbus_intr_handler {
3497c478bd9Sstevel@tonic-gate 	dev_info_t *dip;
3507c478bd9Sstevel@tonic-gate 	uint32_t inum;
3517c478bd9Sstevel@tonic-gate 	uint_t (*funcp)();
3527c478bd9Sstevel@tonic-gate 	caddr_t arg1;
3537c478bd9Sstevel@tonic-gate 	caddr_t arg2;
3547c478bd9Sstevel@tonic-gate 	uint_t	intr_state;
3557c478bd9Sstevel@tonic-gate 	struct sbus_intr_handler *next;
3567c478bd9Sstevel@tonic-gate };
3577c478bd9Sstevel@tonic-gate 
3587c478bd9Sstevel@tonic-gate /* sbus Interrupt routine wrapper structure */
3597c478bd9Sstevel@tonic-gate struct sbus_wrapper_arg {
3607c478bd9Sstevel@tonic-gate 	struct sbus_soft_state *softsp;
3617c478bd9Sstevel@tonic-gate 	volatile uint64_t *clear_reg;
3627c478bd9Sstevel@tonic-gate 	uint32_t pil;
3637c478bd9Sstevel@tonic-gate 	struct sbus_intr_handler *handler_list;
3647c478bd9Sstevel@tonic-gate };
3657c478bd9Sstevel@tonic-gate 
3667c478bd9Sstevel@tonic-gate 
3677c478bd9Sstevel@tonic-gate /*
3687c478bd9Sstevel@tonic-gate  * SYSIO parent private data structure contains register, interrupt, property
3697c478bd9Sstevel@tonic-gate  * and range information.
3707c478bd9Sstevel@tonic-gate  * Note: the only thing different from the "generic" sbus parent private
3717c478bd9Sstevel@tonic-gate  * data is the interrupt specification.
3727c478bd9Sstevel@tonic-gate  */
3737c478bd9Sstevel@tonic-gate struct sysio_parent_private_data {
3747c478bd9Sstevel@tonic-gate 	int par_nreg;			/* number of regs */
3757c478bd9Sstevel@tonic-gate 	struct regspec *par_reg;	/* array of regs */
3767c478bd9Sstevel@tonic-gate 	int par_nintr;			/* number of interrupts */
377*9c75c6bfSgovinda 	struct sysiointrspec *par_intr;	/* array of possible interrupts */
3787c478bd9Sstevel@tonic-gate 	int par_nrng;			/* number of ranges */
3797c478bd9Sstevel@tonic-gate 	struct rangespec *par_rng;	/* array of ranges */
3807c478bd9Sstevel@tonic-gate 	uint_t slot;			/* Slot number, on this sbus */
3817c478bd9Sstevel@tonic-gate 	uint_t offset;			/* Offset of first real "reg" */
3827c478bd9Sstevel@tonic-gate };
3837c478bd9Sstevel@tonic-gate #define	SYSIO_PD(d)	\
3847c478bd9Sstevel@tonic-gate 	((struct sysio_parent_private_data *)DEVI((d))->devi_parent_data)
3857c478bd9Sstevel@tonic-gate 
3867c478bd9Sstevel@tonic-gate #define	sysio_pd_getnreg(dev)		(SYSIO_PD(dev)->par_nreg)
3877c478bd9Sstevel@tonic-gate #define	sysio_pd_getnintr(dev)		(SYSIO_PD(dev)->par_nintr)
3887c478bd9Sstevel@tonic-gate #define	sysio_pd_getnrng(dev)		(SYSIO_PD(dev)->par_nrng)
3897c478bd9Sstevel@tonic-gate #define	sysio_pd_getslot(dev)		(SYSIO_PD(dev)->slot)
3907c478bd9Sstevel@tonic-gate #define	sysio_pd_getoffset(dev)		(SYSIO_PD(dev)->offset)
3917c478bd9Sstevel@tonic-gate 
3927c478bd9Sstevel@tonic-gate #define	sysio_pd_getreg(dev, n)		(&SYSIO_PD(dev)->par_reg[(n)])
3937c478bd9Sstevel@tonic-gate #define	sysio_pd_getintr(dev, n)	(&SYSIO_PD(dev)->par_intr[(n)])
3947c478bd9Sstevel@tonic-gate #define	sysio_pd_getrng(dev, n)		(&SYSIO_PD(dev)->par_rng[(n)])
3957c478bd9Sstevel@tonic-gate 
3967c478bd9Sstevel@tonic-gate #define	IS_INTRA_SBUS(softsp, pfn)	(pfn >= softsp->sbus_io_lo_pfn && \
3977c478bd9Sstevel@tonic-gate 					    pfn <= softsp->sbus_io_hi_pfn)
3987c478bd9Sstevel@tonic-gate 
3997c478bd9Sstevel@tonic-gate /* Used for legacy interrupts */
4007c478bd9Sstevel@tonic-gate #define	SBUS_INTR_STATE_DISABLE		0	/* disabled */
4017c478bd9Sstevel@tonic-gate #define	SBUS_INTR_STATE_ENABLE		1	/* enabled */
4027c478bd9Sstevel@tonic-gate 
4037c478bd9Sstevel@tonic-gate struct io_mem_list {
4047c478bd9Sstevel@tonic-gate 	dev_info_t *rdip;
4057c478bd9Sstevel@tonic-gate 	ulong_t	ioaddr;
4067c478bd9Sstevel@tonic-gate 	ulong_t	addr;
4077c478bd9Sstevel@tonic-gate 	pgcnt_t npages;
4087c478bd9Sstevel@tonic-gate 	pfn_t *pfn;
4097c478bd9Sstevel@tonic-gate 	struct io_mem_list *next;
4107c478bd9Sstevel@tonic-gate };
4117c478bd9Sstevel@tonic-gate 
4127c478bd9Sstevel@tonic-gate /*
4137c478bd9Sstevel@tonic-gate  * Function prototypes.
4147c478bd9Sstevel@tonic-gate  */
4157c478bd9Sstevel@tonic-gate 
4167c478bd9Sstevel@tonic-gate 
4177c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
4187c478bd9Sstevel@tonic-gate }
4197c478bd9Sstevel@tonic-gate #endif
4207c478bd9Sstevel@tonic-gate 
4217c478bd9Sstevel@tonic-gate #endif	/* _SYS_SYSIOSBUS_H */
422