xref: /onnv-gate/usr/src/uts/sun4/io/px/px_var.h (revision 11596:e9010337bcd3)
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
51540Skini  * Common Development and Distribution License (the "License").
61540Skini  * 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*11596SJason.Beloro@Sun.COM  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef _SYS_PX_VAR_H
270Sstevel@tonic-gate #define	_SYS_PX_VAR_H
280Sstevel@tonic-gate 
29435Sjchu #include <sys/callb.h>
30435Sjchu 
310Sstevel@tonic-gate #ifdef	__cplusplus
320Sstevel@tonic-gate extern "C" {
330Sstevel@tonic-gate #endif
340Sstevel@tonic-gate 
350Sstevel@tonic-gate /*
360Sstevel@tonic-gate  * offsets of PCI address spaces from base address:
370Sstevel@tonic-gate  */
3827Sjchu #define	PX_CONFIG		0x001000000ull
390Sstevel@tonic-gate #define	PX_A_IO			0x002000000ull
400Sstevel@tonic-gate #define	PX_B_IO			0x002010000ull
4127Sjchu #define	PX_A_MEMORY		0x100000000ull
4227Sjchu #define	PX_B_MEMORY		0x180000000ull
4327Sjchu #define	PX_IO_SIZE		0x000010000ull
4427Sjchu #define	PX_MEM_SIZE		0x080000000ull
4527Sjchu 
460Sstevel@tonic-gate /*
470Sstevel@tonic-gate  * The following typedef is used to represent a
4827Sjchu  * 1275 "reg" property of a PCI nexus.
4927Sjchu  */
5027Sjchu typedef struct px_nexus_regspec {
5127Sjchu 	uint64_t phys_addr;
5227Sjchu 	uint64_t size;
5327Sjchu } px_nexus_regspec_t;
5427Sjchu 
551648Sjchu typedef enum {
561648Sjchu 	PX_ATTACHED = 1,
571648Sjchu 	PX_DETACHED,
581648Sjchu 	PX_SUSPENDED
591648Sjchu } px_state_t;
601648Sjchu 
611772Sjl139090 enum { PX_INTR_XBC, PX_INTR_PEC, PX_INTR_HOTPLUG };
620Sstevel@tonic-gate 
630Sstevel@tonic-gate #define	PX_ATTACH_RETCODE(obj, op, err) \
640Sstevel@tonic-gate 	((err) ? (obj) << 8 | (op) << 4 | (err) & 0xf : DDI_SUCCESS)
650Sstevel@tonic-gate 
660Sstevel@tonic-gate /*
670Sstevel@tonic-gate  * px soft state structure:
680Sstevel@tonic-gate  *
690Sstevel@tonic-gate  * Each px node has a px soft state structure.
700Sstevel@tonic-gate  */
710Sstevel@tonic-gate struct px {
720Sstevel@tonic-gate 	/*
730Sstevel@tonic-gate 	 * State flags and mutex:
740Sstevel@tonic-gate 	 */
750Sstevel@tonic-gate 	px_state_t px_state;
760Sstevel@tonic-gate 	uint_t px_soft_state;
770Sstevel@tonic-gate 	kmutex_t px_mutex;
780Sstevel@tonic-gate 
790Sstevel@tonic-gate 	/*
800Sstevel@tonic-gate 	 * Links to other state structures:
810Sstevel@tonic-gate 	 */
820Sstevel@tonic-gate 	dev_info_t *px_dip;		/* devinfo structure */
830Sstevel@tonic-gate 	devhandle_t px_dev_hdl;		/* device handle */
841648Sjchu 	px_ib_t *px_ib_p;		/* interrupt block */
850Sstevel@tonic-gate 	px_pec_t *px_pec_p;		/* PEC block */
860Sstevel@tonic-gate 	px_mmu_t *px_mmu_p;		/* IOMMU block */
870Sstevel@tonic-gate 
880Sstevel@tonic-gate 	/*
890Sstevel@tonic-gate 	 * px device node properties:
900Sstevel@tonic-gate 	 */
913613Set142600 	pcie_req_id_t px_bdf;
9210923SEvan.Yan@Sun.COM 	pci_bus_range_t px_bus_range;	/* "bus-range" */
9310923SEvan.Yan@Sun.COM 	pci_ranges_t *px_ranges_p;	/* "ranges" data & length */
940Sstevel@tonic-gate 	int px_ranges_length;
950Sstevel@tonic-gate 	devino_t *px_inos;		/* inos from "interrupts" prop */
960Sstevel@tonic-gate 	int px_inos_len;		/* "interrupts" length */
970Sstevel@tonic-gate 
980Sstevel@tonic-gate 	/* Error handling */
991648Sjchu 	px_fault_t	px_fault;
1001648Sjchu 	px_fault_t	px_cb_fault;
1010Sstevel@tonic-gate 
1020Sstevel@tonic-gate 	/* FMA */
1031648Sjchu 	int		px_fm_cap;
1041648Sjchu 	kmutex_t	px_fm_mutex;
1053726Sdwoods 	kthread_t	*px_fm_mutex_owner;
1060Sstevel@tonic-gate 	ddi_iblock_cookie_t px_fm_ibc;
1076313Skrishnae 	pf_data_t	px_pfd_arr[5];
1086313Skrishnae 	int		px_pfd_idx;
1090Sstevel@tonic-gate 
1101531Skini 	uint32_t	px_dev_caps;
1111531Skini 
1120Sstevel@tonic-gate 	/* Platform specific information */
1136313Skrishnae 	void		*px_plat_p;
114118Sjchu 
115*11596SJason.Beloro@Sun.COM 	/* Interrupt types supported by the fabric */
116*11596SJason.Beloro@Sun.COM 	int		px_supp_intr_types;
117*11596SJason.Beloro@Sun.COM 
118118Sjchu 	/* Power Management fields */
119118Sjchu 	kmutex_t	px_l23ready_lock; /* used in PME_To_ACK interrupt */
120118Sjchu 	kcondvar_t	px_l23ready_cv;	/* used in PME_TO_ACK timeout */
1211147Sjchu 	volatile uint32_t	px_lup_pending;
122118Sjchu 	int		px_pm_flags;
123118Sjchu 	msiqid_t	px_pm_msiq_id;	/* EQ id for PCIE_PME_ACK_MSG Message */
124118Sjchu 	uint32_t	px_pmetoack_ignored; /* count of PME_To_ACKs ignored */
125118Sjchu 
126435Sjchu 	/* CPR callback id */
127435Sjchu 	callb_id_t	px_cprcb_id;
1283107Saa72041 	uint32_t	px_dma_sync_opt; /* DMA syncing req. of hw */
1293274Set142600 
1303274Set142600 	/* Handle for soft intr */
1313274Set142600 	ddi_softint_handle_t    px_dbg_hdl; /* HDL for dbg printing */
1320Sstevel@tonic-gate };
1330Sstevel@tonic-gate 
1341531Skini /* px_dev_caps definition */
1353107Saa72041 #define	PX_BYPASS_DMA_ALLOWED		1
1363107Saa72041 #define	PX_DMA_SYNC_REQUIRED		4
1370Sstevel@tonic-gate 
138287Smg140465 /* px_pm_flags definitions used with interrupts and FMA code */
139287Smg140465 #define	PX_PMETOACK_RECVD		0x01 /* With PME_To_ACK interrupt */
140287Smg140465 #define	PX_PME_TURNOFF_PENDING		0x02 /* With PME_To_ACK interrupt */
1411147Sjchu #define	PX_LDN_EXPECTED			0x04 /* With FMA code */
142118Sjchu 
1430Sstevel@tonic-gate #define	DIP_TO_INST(dip)	ddi_get_instance(dip)
1440Sstevel@tonic-gate #define	INST_TO_STATE(inst)	ddi_get_soft_state(px_state_p, inst)
1450Sstevel@tonic-gate #define	DIP_TO_STATE(dip)	INST_TO_STATE(DIP_TO_INST(dip))
1460Sstevel@tonic-gate 
147909Segillett #define	PX_DEV_TO_SOFTSTATE(dev)	((px_t *)ddi_get_soft_state( \
14810923SEvan.Yan@Sun.COM 	px_state_p, PCI_MINOR_NUM_TO_INSTANCE(getminor(dev))))
1490Sstevel@tonic-gate 
1500Sstevel@tonic-gate extern void *px_state_p;
1510Sstevel@tonic-gate 
1520Sstevel@tonic-gate /*
1530Sstevel@tonic-gate  * function prototypes for bus ops routines:
1540Sstevel@tonic-gate  */
1550Sstevel@tonic-gate extern int
1560Sstevel@tonic-gate px_map(dev_info_t *dip, dev_info_t *rdip, ddi_map_req_t *mp,
1570Sstevel@tonic-gate 	off_t offset, off_t len, caddr_t *addrp);
1580Sstevel@tonic-gate extern int
1590Sstevel@tonic-gate px_dma_setup(dev_info_t *dip, dev_info_t *rdip,
1600Sstevel@tonic-gate 	ddi_dma_req_t *dmareq, ddi_dma_handle_t *handlep);
1610Sstevel@tonic-gate extern int
1620Sstevel@tonic-gate px_dma_allochdl(dev_info_t *dip, dev_info_t *rdip, ddi_dma_attr_t *attrp,
1630Sstevel@tonic-gate 	int (*waitfp)(caddr_t), caddr_t arg, ddi_dma_handle_t *handlep);
1640Sstevel@tonic-gate extern int
1650Sstevel@tonic-gate px_dma_bindhdl(dev_info_t *dip, dev_info_t *rdip,
1660Sstevel@tonic-gate 	ddi_dma_handle_t handle, ddi_dma_req_t *dmareq,
1670Sstevel@tonic-gate 	ddi_dma_cookie_t *cookiep, uint_t *ccountp);
1680Sstevel@tonic-gate extern int
1690Sstevel@tonic-gate px_dma_unbindhdl(dev_info_t *dip, dev_info_t *rdip,
1700Sstevel@tonic-gate 	ddi_dma_handle_t handle);
1710Sstevel@tonic-gate extern int
1720Sstevel@tonic-gate px_dma_ctlops(dev_info_t *dip, dev_info_t *rdip, ddi_dma_handle_t handle,
1730Sstevel@tonic-gate 	enum ddi_dma_ctlops cmd, off_t *offp, size_t *lenp, caddr_t *objp,
1740Sstevel@tonic-gate 	uint_t cache_flags);
1750Sstevel@tonic-gate extern int
1760Sstevel@tonic-gate px_ctlops(dev_info_t *dip, dev_info_t *rdip,
1770Sstevel@tonic-gate 	ddi_ctl_enum_t op, void *arg, void *result);
1780Sstevel@tonic-gate extern int
1790Sstevel@tonic-gate px_intr_ops(dev_info_t *dip, dev_info_t *rdip, ddi_intr_op_t intr_op,
1800Sstevel@tonic-gate 	ddi_intr_handle_impl_t *handle, void *result);
1810Sstevel@tonic-gate 
1820Sstevel@tonic-gate #ifdef	__cplusplus
1830Sstevel@tonic-gate }
1840Sstevel@tonic-gate #endif
1850Sstevel@tonic-gate 
1860Sstevel@tonic-gate #endif	/* _SYS_PX_VAR_H */
187