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