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