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