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