xref: /titanic_50/usr/src/uts/common/sys/hotplug/hpctrl.h (revision bdfc6d18da790deeec2e0eb09c625902defe2498)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_HOTPLUG_HPCTRL_H
28 #define	_SYS_HOTPLUG_HPCTRL_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 /*
33  * ****************************************************************
34  * Hot Plug Controller interfaces for PCI and CompactPCI platforms.
35  * ****************************************************************
36  */
37 #include <sys/types.h>
38 
39 #ifdef	__cplusplus
40 extern "C" {
41 #endif
42 
43 /*
44  * Type definition for slot handle. This is an opaque pointer
45  * created by the HPS framework.
46  */
47 typedef void *hpc_slot_t;
48 
49 #define	HPC_SLOT_OPS_VERSION	0
50 
51 /*
52  * slot operations structure definition.
53  *
54  *	Function		Description
55  *	--------		-----------
56  *	xxx_op_connect		CONNECT the slot to the bus to enable
57  *				access to the adapter.
58  *	xxx_op_disconnect	DISCONNECT the slot from the bus. For PCI,
59  *				this disables the power to the slot.
60  *	xxx_op_insert		Prepare the slot for card insertion. This
61  *				may not be applicable for all bus types.
62  *	xxx_op_remove		Prepare the slot for card removal. This
63  *				may not be applicable for all bus types.
64  *	xxx_op_control		Perform misc. commands to control the
65  *				LEDs, get status information, etc.
66  */
67 typedef struct hpc_slot_ops {
68 	int	hpc_version;			/* HPC_SLOT_OPS_VERSION */
69 	int	(*hpc_op_connect)(caddr_t ops_arg, hpc_slot_t slot_hdl,
70 			void *data, uint_t flags);
71 	int	(*hpc_op_disconnect)(caddr_t ops_arg, hpc_slot_t slot_hdl,
72 			void *data, uint_t flags);
73 	int	(*hpc_op_insert)(caddr_t ops_arg, hpc_slot_t slot_hdl,
74 			void *data, uint_t flags);
75 	int	(*hpc_op_remove)(caddr_t ops_arg, hpc_slot_t slot_hdl,
76 			void *data, uint_t flags);
77 	int	(*hpc_op_control)(caddr_t ops_arg, hpc_slot_t slot_hdl,
78 			int request, caddr_t arg);
79 } hpc_slot_ops_t;
80 
81 #define	HPC_SLOT_INFO_VERSION	1
82 #define	PCI_SLOT_NAME_LEN	256
83 /*
84  * Slot information structure.
85  */
86 typedef struct hpc_slot_info {
87 	uint16_t	version;		/* HPC_SLOT_INFO_VERSION */
88 	uint16_t	slot_type;		/* slot type: PCI, ... */
89 	uint16_t	slot_flags;
90 	union {
91 	    /* pci bus slot */
92 	    struct pci_slot_info {
93 		uint16_t	device_number;		/* PCI device number */
94 		uint16_t	slot_capabilities;	/* 64bit, etc. */
95 		char		slot_logical_name[PCI_SLOT_NAME_LEN];
96 	    } pci;
97 	    struct sbd_slot_info {
98 		int		slot_num;
99 	    } sbd;
100 	    /* other bus types go here... */
101 	} slot;
102 } hpc_slot_info_t;
103 
104 /* short names for bus specific fields in hpc_slot_info structure */
105 #define	pci_dev_num		slot.pci.device_number
106 #define	pci_slot_name		slot.pci.slot_logical_name
107 #define	pci_slot_capabilities	slot.pci.slot_capabilities
108 
109 #define	sbd_slot_num		slot.sbd.slot_num
110 
111 /* slot_type definitions */
112 #define	HPC_SLOT_TYPE_PCI	0x1		/* PCI bus slot */
113 #define	HPC_SLOT_TYPE_CPCI	0x2		/* Compact PCI bus slot */
114 #define	HPC_SLOT_TYPE_SBD	0x3		/* System bus slot */
115 
116 /* bit definitions in slot_capabilities field for PCI or cPCI bus slots */
117 #define	HPC_SLOT_64BITS		0x0001	/* slot is a 64bit slot */
118 #define	HPC_SLOT_TEST		0x0002	/* testing capability on the slot */
119 
120 /* slot_flags definitions */
121 #define	HPC_SLOT_NO_AUTO_ENABLE	0x1	/* No auto-enable on registration */
122 #define	HPC_SLOT_CREATE_DEVLINK	0x2	/* create device link under /dev/cfg */
123 
124 /*
125  * xxx_op_control command definitions.
126  *
127  * 	Command (request)	   arg			Descritpion
128  *	-----------------	   ---			-----------
129  *	HPC_CTRL_GET_LED_STATE	   hpc_led_info *	Get state of an LED.
130  *	HPC_CTRL_SET_LED_STATE	   hpc_led_info *	Set state of an LED.
131  *	HPC_CTRL_GET_SLOT_STATE	   hpc_slot_state_t *	Get the slot state.
132  *	HPC_CTRL_DEV_CONFIGURED	   NULL 		Board is configured.
133  *	HPC_CTRL_DEV_UNCONFIGURED  NULL 		Board is unconfigured.
134  *	HPC_CTRL_DEV_CONFIG_FAILURE NULL	Board Configuration Failed
135  *	HPC_CTRL_DEV_UNCONFIG_FAILURE NULL	Board Unconfiguration Failed
136  *	HPC_CTRL_GET_BOARD_TYPE    hpc_board_type_t *	Get board type info.
137  *	HPC_CTRL_DISABLE_AUTOCFG   NULL			Disable auto config-
138  *							uration for this slot.
139  *	HPC_CTRL_ENABLE_AUTOCFG    NULL			Enable auto config-
140  *							uration for this slot.
141  *	HPC_CTRL_DISABLE_SLOT	   NULL			Disable the slot for
142  *							hot plug operations.
143  *	HPC_CTRL_ENABLE_SLOT	   NULL			ReEnable the slot for
144  *							hot plug operations.
145  */
146 #define	HPC_CTRL_GET_LED_STATE		0x1
147 #define	HPC_CTRL_SET_LED_STATE		0x2
148 #define	HPC_CTRL_GET_SLOT_STATE		0x3
149 #define	HPC_CTRL_DEV_CONFIGURED		0x4
150 #define	HPC_CTRL_DEV_UNCONFIGURED	0x5
151 #define	HPC_CTRL_GET_BOARD_TYPE		0x6
152 #define	HPC_CTRL_DISABLE_AUTOCFG	0x7
153 #define	HPC_CTRL_ENABLE_AUTOCFG		0x8
154 #define	HPC_CTRL_DISABLE_SLOT		0x9
155 #define	HPC_CTRL_ENABLE_SLOT		0xa
156 #define	HPC_CTRL_DISABLE_ENUM		0xb
157 #define	HPC_CTRL_ENABLE_ENUM		0xc
158 #define	HPC_CTRL_DEV_CONFIG_FAILURE	0xd
159 #define	HPC_CTRL_DEV_UNCONFIG_FAILURE	0xe
160 #define	HPC_CTRL_DEV_CONFIG_START	0xf
161 #define	HPC_CTRL_DEV_UNCONFIG_START	0x10
162 
163 /*
164  * type definitions for led information.
165  *
166  * Note: ATTN/ACTIVE leds are platform specific and they may not be
167  *	 available on all platforms.
168  */
169 typedef enum { HPC_FAULT_LED, HPC_POWER_LED, HPC_ATTN_LED,
170 	HPC_ACTIVE_LED} hpc_led_t;
171 
172 typedef enum { HPC_LED_OFF, HPC_LED_ON, HPC_LED_BLINK } hpc_led_state_t;
173 
174 typedef struct hpc_led_info {
175 	hpc_led_t	led;	/* led id: HPC_POWER_LED, HPC_FAULT_LED, ... */
176 	hpc_led_state_t	state;	/* led state: HPC_LED_ON, HPC_LED_OFF, ... */
177 } hpc_led_info_t;
178 
179 /*
180  * type definition for slot state.
181  *
182  *	HPC_SLOT_EMPTY		Slot has no card present.
183  *	HPC_SLOT_CONNECTED	Card is present in the slot and it is
184  *				connected to the bus.
185  *	HPC_SLOT_DISCONNECTED	Card is present in the slot and it is
186  *				disconnected from the bus.
187  *	HPC_SLOT_UNKNOWN	If the HPC driver can not figure out
188  *				the receptacle state. This is possible
189  *				on Compact PCI Hot Swap platform.
190  */
191 typedef enum { HPC_SLOT_EMPTY, HPC_SLOT_DISCONNECTED,
192 	HPC_SLOT_CONNECTED, HPC_SLOT_UNKNOWN } hpc_slot_state_t;
193 
194 /*
195  * type definition for board type.
196  *
197  *	HPC_BOARD_UNKNOWN	Board is either not present or unknown.
198  *	HPC_BOARD_PCI_HOTPLUG	PCI bus adapter.
199  *	HPC_BOARD_CPCI_NON_HS	Non Hot Swap cPCI board.
200  *	HPC_BOARD_CPCI_BASIC_HS	Basic Hot Swap cPCI board.
201  *	HPC_BOARD_CPCI_FULL_HS	Full Hot Swap cPCI board.
202  *	HPC_BOARD_CPCI_HS	Indicates if HSC driver can not determine
203  *				the type of Hot Swap board.
204  */
205 typedef enum { HPC_BOARD_UNKNOWN, HPC_BOARD_PCI_HOTPLUG,
206 	HPC_BOARD_CPCI_NON_HS, HPC_BOARD_CPCI_BASIC_HS,
207 	HPC_BOARD_CPCI_FULL_HS, HPC_BOARD_CPCI_HS } hpc_board_type_t;
208 
209 /*
210  * Event type definitions (for hpc_event_notify() interface).
211  *
212  *	Event			   Descritpion
213  *	-----			   -----------
214  *	HPC_EVENT_SLOT_INSERTION   Card is inserted in the slot.
215  *	HPC_EVENT_SLOT_REMOVAL	   Card is removed from the slot.
216  *	HPC_EVENT_SLOT_POWER_ON	   Slot is powered ON.
217  *	HPC_EVENT_SLOT_POWER_OFF   Slot is powered OFF.
218  *	HPC_EVENT_SLOT_LATCH_OPEN  LATCH on the slot is open.
219  *	HPC_EVENT_SLOT_LATCH_SHUT  LATCH on the slot is shut.
220  *	HPC_EVENT_SLOT_ENUM	   ENUM# signal is generated on the bus
221  *				   and it may be generated from this slot.
222  *	HPC_EVENT_SLOT_NOT_HEALTHY HEALTHY# signal is lost on this slot.
223  *	HPC_EVENT_SLOT_HEALTHY_OK  HEALTHY# signal on this slot is OK now.
224  *	HPC_EVENT_SLOT_CONFIGURE   Configure the occupant in the slot.
225  *	HPC_EVENT_SLOT_UNCONFIGURE Unconfigure the occupant in the slot.
226  */
227 #define	HPC_EVENT_SLOT_INSERTION	0x00000001
228 #define	HPC_EVENT_SLOT_REMOVAL		0x00000002
229 #define	HPC_EVENT_SLOT_POWER_ON		0x00000004
230 #define	HPC_EVENT_SLOT_POWER_OFF	0x00000008
231 #define	HPC_EVENT_SLOT_LATCH_OPEN	0x00000010
232 #define	HPC_EVENT_SLOT_LATCH_SHUT	0x00000020
233 #define	HPC_EVENT_SLOT_ENUM		0x00000040
234 #define	HPC_EVENT_SLOT_NOT_HEALTHY	0x00000080
235 #define	HPC_EVENT_SLOT_HEALTHY_OK	0x00000100
236 #define	HPC_EVENT_SLOT_CONFIGURE	0x00000200
237 #define	HPC_EVENT_SLOT_UNCONFIGURE	0x00000400
238 #define	HPC_EVENT_SLOT_BLUE_LED_ON	0x00000800
239 #define	HPC_EVENT_SLOT_BLUE_LED_OFF	0x00001000
240 #define	HPC_EVENT_CLEAR_ENUM		0x00002000
241 #define	HPC_EVENT_PROCESS_ENUM		0x00004000
242 #define	HPC_EVENT_ENABLE_ENUM		0x00008000
243 #define	HPC_EVENT_DISABLE_ENUM		0x00010000
244 #define	HPC_EVENT_BUS_ENUM		HPC_EVENT_SLOT_ENUM
245 
246 /*
247  * return values for errors from HPS framework interfaces.
248  */
249 #define	HPC_SUCCESS			0x0
250 #define	HPC_ERR_INVALID			0x1	/* invalid arguments */
251 #define	HPC_ERR_SLOT_NOTREGISTERED	0x2	/* slot is not registered */
252 #define	HPC_ERR_SLOT_DUPLICATE		0x3	/* slot is already registered */
253 #define	HPC_ERR_BUS_NOTREGISTERED	0x4	/* slot is not registered */
254 #define	HPC_ERR_BUS_DUPLICATE		0x5	/* slot is already registered */
255 #define	HPC_ERR_NOTSUPPORTED		0x6	/* operation not supported */
256 #define	HPC_ERR_FAILED			0x7	/* operation failed */
257 
258 /* return values for event notifications */
259 #define	HPC_EVENT_CLAIMED		0x10	/* HPC event is claimed */
260 #define	HPC_EVENT_UNCLAIMED		-1	/* HPC event is not claimed */
261 
262 /* definitions for slot (un)registration events */
263 #define	HPC_SLOT_ONLINE		1	/* slot is registered */
264 #define	HPC_SLOT_OFFLINE	2	/* slot is unregistered */
265 
266 /*
267  * function prototype definitions for interfaces between HPC driver
268  * and Hot Plug Services framework.
269  */
270 #ifdef	__STDC__
271 extern int hpc_slot_register(dev_info_t *dip, char *bus_path,
272 	hpc_slot_info_t *slot_info, hpc_slot_t *slot_hdl,
273 	hpc_slot_ops_t *slot_ops, caddr_t ops_arg, uint_t flags);
274 extern int hpc_slot_unregister(hpc_slot_t *slot_hdl);
275 extern struct hpc_slot_ops *hpc_alloc_slot_ops(int sleepflag);
276 extern void hpc_free_slot_ops(hpc_slot_ops_t *ops);
277 extern int hpc_slot_event_notify(hpc_slot_t slot_hdl, uint_t event,
278 	uint_t flags);
279 extern boolean_t hpc_bus_registered(hpc_slot_t slot_hdl);
280 #else
281 extern int hpc_slot_register();
282 extern int hpc_slot_unregister();
283 extern struct hpc_slot_ops *hpc_alloc_slot_ops();
284 extern void hpc_free_slot_ops();
285 extern int hpc_slot_event_notify();
286 extern boolean_t hpc_bus_registered();
287 #endif	/* __STDC__ */
288 
289 /*
290  * *****************************************************************
291  * Implementation specific data structures and definitons. These are
292  * the private interfaces between cfgadm plug-in and the PCI nexus
293  * driver.
294  * *****************************************************************
295  */
296 
297 /*
298  * Data structure used for DEVCTL_AP_CONTROL ioctl on the AP.
299  */
300 struct hpc_control_data {
301 	uint_t	cmd;		/* HPC_CTRL_* command */
302 	void	*data;		/* pointer to data that is exchanged */
303 };
304 
305 struct hpc_control32_data {
306 	uint_t	  cmd;		/* HPC_CTRL_* command */
307 	caddr32_t data;		/* pointer to data that is exchanged */
308 };
309 
310 /* misc. control commands for DEVCTL_AP_CONTROL ioctl interface */
311 #define	HPC_CTRL_GET_SLOT_INFO	0x100
312 #define	HPC_CTRL_GET_CARD_INFO	0x101
313 
314 /* card information structure to get data from the PCI config header */
315 typedef struct hpc_card_info {
316 	uint8_t	prog_class;	/* PCI_CONF_PROGCLASS byte */
317 	uint8_t	base_class;	/* PCI_CONF_BASCLASS byte */
318 	uint8_t	sub_class;	/* PCI_CONF_SUBCLASS byte */
319 	uint8_t	header_type;	/* PCI_CONF_HEADER byte */
320 } hpc_card_info_t;
321 
322 /* Slot occupant information structure */
323 #define	HPC_MAX_OCCUPANTS	128
324 typedef struct hpc_occupant_info {
325 	int	i;
326 	char	*id[HPC_MAX_OCCUPANTS];
327 } hpc_occupant_info_t;
328 
329 #ifdef	__cplusplus
330 }
331 #endif
332 
333 #endif	/* _SYS_HOTPLUG_HPCTRL_H */
334