xref: /titanic_52/usr/src/uts/common/io/cardbus/cardbus.h (revision e61a481d2b9ca0c0f387e11b15dcabfc982bb464)
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  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 /*
26  * Copyright (c)  * Copyright (c) 2001 Tadpole Technology plc
27  * All rights reserved.
28  */
29 
30 #ifndef	_SYS_CARDBUS_H
31 #define	_SYS_CARDBUS_H
32 
33 #pragma ident	"%Z%%M%	%I%	%E% SMI"
34 
35 #ifdef  __cplusplus
36 extern "C" {
37 #endif
38 
39 #define	CB_BCNF_BCNTRL_ISA_INT_ENAB	0x0080
40 #define	CB_BCNF_BCNTRL_MEM0_PREF	0x0100
41 #define	CB_BCNF_BCNTRL_MEM1_PREF	0x0200
42 #define	CB_BCNF_BCNTRL_WRITE_POST	0x0400
43 
44 typedef struct cb_nexus_cb {
45 	void	(*enable_intr)(dev_info_t *);
46 	void	(*disable_intr)(dev_info_t *);
47 } cb_nexus_cb_t;
48 
49 typedef enum { PCIHP_SOFT_STATE_CLOSED, PCIHP_SOFT_STATE_OPEN,
50 		PCIHP_SOFT_STATE_OPEN_EXCL } cbhp_soft_state_t;
51 
52 /*
53  * Main softstate per cardbus device
54  */
55 typedef struct cardbus_dev {
56 	int	cb_instance;
57 	boolean_t fatal_problem;
58 	dev_info_t *cb_dip;
59 	kmutex_t cb_mutex;
60 	cb_nexus_cb_t *cb_nex_ops;
61 	struct dev_ops cb_dops;
62 	struct dev_ops *orig_dopsp;
63 	struct bus_ops *orig_bopsp;
64 	struct cb_deviceset_props *cb_dsp;
65 	ndi_event_hdl_t	cb_ndi_event_hdl;
66 	ndi_event_set_t	cb_ndi_events;
67 #ifdef HOTPLUG
68 	/* Nexus specific variables */
69 	ap_rstate_t	rstate;		/* state of Receptacle */
70 	ap_ostate_t	ostate;		/* state of the Occupant */
71 	ap_condition_t	condition;	/* condition of the occupant */
72 	cbhp_soft_state_t	soft_state;
73 	uint32_t	event_mask;	/* last event mask registerd */
74 	boolean_t	auto_config;
75 	boolean_t	disabled;
76 	char	*name;
77 
78 	/* Slot specific variables */
79 	char	ap_id[32];		/* Attachment point name */
80 	char	*nexus_path;		/* Pathname of Nexus */
81 	hpc_slot_ops_t	*slot_ops;	/* Ptr HPC entry points */
82 	hpc_slot_info_t	slot_info;	/* Bus Specific SlotInfo */
83 	hpc_slot_t	slot_handle;	/* HPS slot handle */
84 	boolean_t card_present;
85 	hpc_led_state_t leds[4];
86 #endif
87 } cbus_t;
88 
89 typedef struct cardbus_bus_range {
90 	uint32_t lo;
91 	uint32_t hi;
92 } cardbus_bus_range_t;
93 
94 typedef struct cardbus_range {
95 	uint32_t child_hi;
96 	uint32_t child_mid;
97 	uint32_t child_lo;
98 	uint32_t parent_hi;
99 	uint32_t parent_mid;
100 	uint32_t parent_lo;
101 	uint32_t size_hi;
102 	uint32_t size_lo;
103 
104 } cardbus_range_t;
105 
106 #if defined(DEBUG)
107 #define	CARDBUS_DEBUG
108 #endif
109 
110 #ifdef CARDBUS_DEBUG
111 extern void prom_printf(const char *, ...);
112 #endif
113 
114 extern int cardbus_debug;
115 
116 #ifdef _KERNEL
117 extern int cardbus_attach(dev_info_t *, cb_nexus_cb_t *);
118 extern boolean_t cardbus_load_cardbus(dev_info_t *, uint_t, uint32_t);
119 extern void cardbus_unload_cardbus(dev_info_t *);
120 extern void cardbus_err(dev_info_t *dip, int level, const char *fmt, ...);
121 
122 /* The following only exists for hotplug support */
123 extern int cardbus_open(dev_t *, int, int, cred_t *);
124 extern int cardbus_close(dev_t, int, int, cred_t *);
125 extern int cardbus_ioctl(dev_t, int, intptr_t, int, cred_t *,
126 	    int *);
127 extern boolean_t cardbus_is_cb_minor(dev_t);
128 void cardbus_save_children(dev_info_t *dip);
129 void cardbus_restore_children(dev_info_t *dip);
130 #endif
131 
132 #ifdef  __cplusplus
133 }
134 #endif
135 
136 #endif	/* _SYS_CARDBUS_H */
137