xref: /onnv-gate/usr/src/uts/sun4u/starcat/sys/schpc.h (revision 1708:ea74d8598a3a)
1*1708Sstevel /*
2*1708Sstevel  * CDDL HEADER START
3*1708Sstevel  *
4*1708Sstevel  * The contents of this file are subject to the terms of the
5*1708Sstevel  * Common Development and Distribution License (the "License").
6*1708Sstevel  * You may not use this file except in compliance with the License.
7*1708Sstevel  *
8*1708Sstevel  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*1708Sstevel  * or http://www.opensolaris.org/os/licensing.
10*1708Sstevel  * See the License for the specific language governing permissions
11*1708Sstevel  * and limitations under the License.
12*1708Sstevel  *
13*1708Sstevel  * When distributing Covered Code, include this CDDL HEADER in each
14*1708Sstevel  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*1708Sstevel  * If applicable, add the following below this CDDL HEADER, with the
16*1708Sstevel  * fields enclosed by brackets "[]" replaced with your own identifying
17*1708Sstevel  * information: Portions Copyright [yyyy] [name of copyright owner]
18*1708Sstevel  *
19*1708Sstevel  * CDDL HEADER END
20*1708Sstevel  */
21*1708Sstevel 
22*1708Sstevel /*
23*1708Sstevel  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24*1708Sstevel  * Use is subject to license terms.
25*1708Sstevel  */
26*1708Sstevel 
27*1708Sstevel #ifndef	_SYS_SCHPC_H
28*1708Sstevel #define	_SYS_SCHPC_H
29*1708Sstevel 
30*1708Sstevel #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*1708Sstevel 
32*1708Sstevel #ifdef	__cplusplus
33*1708Sstevel extern "C" {
34*1708Sstevel #endif
35*1708Sstevel 
36*1708Sstevel #define	STARCAT_MAX_SLOTS	(18 * 4)
37*1708Sstevel 
38*1708Sstevel /*
39*1708Sstevel  * Slot LED Descriptor
40*1708Sstevel  *
41*1708Sstevel  * Each hot pluggable PCI/cPCI slot has three leds.  Each LED can
42*1708Sstevel  * be on, off, or flashing.
43*1708Sstevel  */
44*1708Sstevel typedef struct slot_led {
45*1708Sstevel 	char		led_power;
46*1708Sstevel 	char		led_service;
47*1708Sstevel 	char		led_fault;
48*1708Sstevel 	char		reserved;
49*1708Sstevel } slot_led_t;
50*1708Sstevel 
51*1708Sstevel #define	LED_OFF		0x00
52*1708Sstevel #define	LED_ON		0x01
53*1708Sstevel #define	LED_FLASH	0x02
54*1708Sstevel 
55*1708Sstevel /*
56*1708Sstevel  * LED Commands
57*1708Sstevel  */
58*1708Sstevel #define	POWER_LED_ON		0x00000001
59*1708Sstevel #define	POWER_LED_OFF		0x00000002
60*1708Sstevel #define	POWER_LED_FLASH		0x00000004
61*1708Sstevel #define	SERVICE_LED_ON		0x00000010
62*1708Sstevel #define	SERVICE_LED_OFF		0x00000020
63*1708Sstevel #define	SERVICE_LED_FLASH	0x00000040
64*1708Sstevel #define	FAULT_LED_ON		0x00000100
65*1708Sstevel #define	FAULT_LED_OFF		0x00000200
66*1708Sstevel #define	FAULT_LED_FLASH		0x00000400
67*1708Sstevel 
68*1708Sstevel 
69*1708Sstevel /*
70*1708Sstevel  * Hot Plug Slot Descriptor.  Each hot pluggable slot will have
71*1708Sstevel  * a schpc_slot_t structure allocated for it.
72*1708Sstevel  */
73*1708Sstevel typedef struct {
74*1708Sstevel 	dev_info_t	*devi;			/* Ptr to PCI dev_info */
75*1708Sstevel 	uint32_t	state;			/* Slot's Hot Plug State */
76*1708Sstevel 	uint16_t	pci_id;			/* PCI ID for slot */
77*1708Sstevel 	uint8_t		expander;		/* Centerplane Expander */
78*1708Sstevel 	uint8_t		board;			/* Number of IO Board 0/1 */
79*1708Sstevel 	uint8_t		schizo;			/* Number of Schizo 0/1 */
80*1708Sstevel 	uint8_t		leaf;			/* A or B (0 or 1) */
81*1708Sstevel 	uint8_t		slot;			/* Slot Number */
82*1708Sstevel 	slot_led_t	led;			/* Current LED state */
83*1708Sstevel 	hpc_slot_ops_t	*slot_ops;		/* Ptr HPC entry points */
84*1708Sstevel 	hpc_slot_info_t	slot_info;		/* Bus Specific SlotInfo */
85*1708Sstevel 	hpc_slot_t	slot_handle;		/* Handle used by HPS */
86*1708Sstevel 	char		nexus_path[MAXNAMELEN];	/* Pathname of Nexus */
87*1708Sstevel 	char		ap_id[MAXNAMELEN];	/* Attachment point name */
88*1708Sstevel 	caddr_t		saved_regs_va[3];	/* Reg set virtual addresses */
89*1708Sstevel 	ddi_acc_handle_t saved_handle[3];	/* Handle from map in */
90*1708Sstevel 	uint64_t	*saved_regs;		/* Ptr to saved off regs */
91*1708Sstevel 	int		saved_size;		/* Size of saved off regs */
92*1708Sstevel } schpc_slot_t;
93*1708Sstevel 
94*1708Sstevel /*
95*1708Sstevel  * PCI/cPCI Hot Plug states for an attachment point
96*1708Sstevel  */
97*1708Sstevel #define	SCHPC_SLOTSTATE_REC_GOOD	0x01	/* Receptacle is Good */
98*1708Sstevel #define	SCHPC_SLOTSTATE_OCC_GOOD	0x02	/* Occupant is Good */
99*1708Sstevel #define	SCHPC_SLOTSTATE_BAD_NEXUS	0x04	/* Invalid PCI Nexus */
100*1708Sstevel #define	SCHPC_SLOTSTATE_PRESENT		0x10	/* Occupant Present */
101*1708Sstevel #define	SCHPC_SLOTSTATE_CONNECTED	0x100	/* Receptacle Connected */
102*1708Sstevel #define	SCHPC_SLOTSTATE_CONFIGURED	0x1000	/* Occupant Configured */
103*1708Sstevel #define	SCHPC_SLOTSTATE_AUTOCFG_ENABLE	0x10000	/* Auto Configuration Enabled */
104*1708Sstevel #define	SCHPC_SLOTSTATE_ENUM		0x100000 /* ENUM Handling in progress */
105*1708Sstevel #define	SCHPC_SLOTSTATE_EXECUTING	0x200000 /* Executing a mailbox cmd */
106*1708Sstevel #define	SCHPC_SLOTSTATE_HPCINITED	0x400000 /* Ready to accept commands */
107*1708Sstevel 
108*1708Sstevel /*
109*1708Sstevel  * Soft state structure definition for each schpc instance.
110*1708Sstevel  * There will be a single soft state stucture for each IO Board.
111*1708Sstevel  */
112*1708Sstevel typedef struct schpc {
113*1708Sstevel 	uint32_t	schpc_instance;		/* Instance # */
114*1708Sstevel 	dev_info_t	*schpc_devi;		/* Ptr to dev_info */
115*1708Sstevel 	kmutex_t	schpc_mutex;		/* Mutex to protect struct */
116*1708Sstevel 	kcondvar_t	schpc_cv;		/* Conditional Variable */
117*1708Sstevel 	char		*schpc_property;	/* Ptr to slot-table */
118*1708Sstevel 	uint32_t	schpc_property_size;	/* Size of slot-table */
119*1708Sstevel 	uint32_t	schpc_hotplugmodel;	/* Type of Hot Plug */
120*1708Sstevel 	uint16_t	schpc_transid;		/* Current transaction ID */
121*1708Sstevel 	uint16_t	schpc_number_of_slots;	/* Slot on IO Board */
122*1708Sstevel 	struct schpc	*schpc_next;		/* Ptr to next schpc */
123*1708Sstevel 	schpc_slot_t	*schpc_slot;		/* Slot Specific stuff */
124*1708Sstevel } schpc_t;
125*1708Sstevel 
126*1708Sstevel /*
127*1708Sstevel  * Types of Hot Plug/Hot Swap Models
128*1708Sstevel  */
129*1708Sstevel #define	SCHPC_HOTPLUGTYPE_NOTHOTPLUGGABLE	0
130*1708Sstevel #define	SCHPC_HOTPLUGTYPE_CPCIHOTPLUG		1
131*1708Sstevel #define	SCHPC_HOTPLUGTYPE_CPCIHOTSWAPBASIC	2
132*1708Sstevel #define	SCHPC_HOTPLUGTYPE_CPCIHOTSWAPFULL	3
133*1708Sstevel #define	SCHPC_HOTPLUGTYPE_PCIHOTPLUG		4
134*1708Sstevel 
135*1708Sstevel /*
136*1708Sstevel  * schpc_t's slot table, schpc_slot[], is indexed by
137*1708Sstevel  * a value in the range [0,STARCAT_MAX_SLOTS).
138*1708Sstevel  *
139*1708Sstevel  * That index is composed of these bit-fields:
140*1708Sstevel  *
141*1708Sstevel  *                   <-- slot num  -->
142*1708Sstevel  *      |----------------------------|
143*1708Sstevel  *      |  expander  | schizo | leaf |
144*1708Sstevel  *      |------------|--------|------|
145*1708Sstevel  *       7          2     1       0
146*1708Sstevel  *
147*1708Sstevel  */
148*1708Sstevel /* Extract various bit-fields from a slot table index: */
149*1708Sstevel #define	SCHPC_SLOT_EXPANDER(idx)	(((idx) & 0xfc) >> 2)
150*1708Sstevel #define	SCHPC_SLOT_SCHIZO(idx)		(((idx) & 0x2) >> 1)
151*1708Sstevel #define	SCHPC_SLOT_LEAF(idx)		((idx) & 0x1)
152*1708Sstevel #define	SCHPC_SLOT_NUM(idx)		((idx) & (0x1 | 0x2))
153*1708Sstevel 
154*1708Sstevel /* Build a slot index from component bit-fields: */
155*1708Sstevel #define	SCHPC_MAKE_SLOT_INDEX2(expander, slot_num)\
156*1708Sstevel 	(((expander) << 2) | (slot_num))
157*1708Sstevel #define	SCHPC_MAKE_SLOT_INDEX3(expander, schizo, leaf)\
158*1708Sstevel 	(((expander) << 2) | ((schizo) << 1) | (leaf))
159*1708Sstevel 
160*1708Sstevel /*
161*1708Sstevel  * Integer values for the clock-frequency property.
162*1708Sstevel  */
163*1708Sstevel #define	SCHPC_33MHZ	(33 * 1000 * 1000)
164*1708Sstevel #define	SCHPC_66MHZ	(66 * 1000 * 1000)
165*1708Sstevel #define	SCHPC_90MHZ	(90 * 1000 * 1000)
166*1708Sstevel #define	SCHPC_133MHZ	(133 * 1000 * 1000)
167*1708Sstevel 
168*1708Sstevel /*
169*1708Sstevel  * module-revision# for the XMITS versions
170*1708Sstevel  */
171*1708Sstevel #define	XMITS_10	1
172*1708Sstevel #define	XMITS_20	2
173*1708Sstevel #define	XMITS_21	3
174*1708Sstevel #define	XMITS_30	4
175*1708Sstevel #define	XMITS_31	5
176*1708Sstevel 
177*1708Sstevel extern int schpc_add_pci(dev_info_t *);
178*1708Sstevel extern int schpc_remove_pci(dev_info_t *);
179*1708Sstevel 
180*1708Sstevel #ifdef __cplusplus
181*1708Sstevel }
182*1708Sstevel #endif
183*1708Sstevel 
184*1708Sstevel #endif /* _SYS_SCHPC_H */
185