xref: /onnv-gate/usr/src/uts/common/io/cardbus/cardbus.h (revision 7151:8ef38730cb56)
12305Sstevel /*
22305Sstevel  * CDDL HEADER START
32305Sstevel  *
42305Sstevel  * The contents of this file are subject to the terms of the
52305Sstevel  * Common Development and Distribution License (the "License").
62305Sstevel  * You may not use this file except in compliance with the License.
72305Sstevel  *
82305Sstevel  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
92305Sstevel  * or http://www.opensolaris.org/os/licensing.
102305Sstevel  * See the License for the specific language governing permissions
112305Sstevel  * and limitations under the License.
122305Sstevel  *
132305Sstevel  * When distributing Covered Code, include this CDDL HEADER in each
142305Sstevel  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
152305Sstevel  * If applicable, add the following below this CDDL HEADER, with the
162305Sstevel  * fields enclosed by brackets "[]" replaced with your own identifying
172305Sstevel  * information: Portions Copyright [yyyy] [name of copyright owner]
182305Sstevel  *
192305Sstevel  * CDDL HEADER END
202305Sstevel  */
212305Sstevel /*
22*7151Srw148561  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
232305Sstevel  * Use is subject to license terms.
242305Sstevel  */
252305Sstevel /*
262305Sstevel  * Copyright (c)  * Copyright (c) 2001 Tadpole Technology plc
272305Sstevel  * All rights reserved.
282305Sstevel  */
292305Sstevel 
302305Sstevel #ifndef	_SYS_CARDBUS_H
312305Sstevel #define	_SYS_CARDBUS_H
322305Sstevel 
332305Sstevel #pragma ident	"%Z%%M%	%I%	%E% SMI"
342305Sstevel 
352305Sstevel #ifdef  __cplusplus
362305Sstevel extern "C" {
372305Sstevel #endif
382305Sstevel 
392305Sstevel #define	CB_BCNF_BCNTRL_ISA_INT_ENAB	0x0080
402305Sstevel #define	CB_BCNF_BCNTRL_MEM0_PREF	0x0100
412305Sstevel #define	CB_BCNF_BCNTRL_MEM1_PREF	0x0200
422305Sstevel #define	CB_BCNF_BCNTRL_WRITE_POST	0x0400
432305Sstevel 
442305Sstevel typedef struct cb_nexus_cb {
452305Sstevel 	void	(*enable_intr)(dev_info_t *);
462305Sstevel 	void	(*disable_intr)(dev_info_t *);
472305Sstevel } cb_nexus_cb_t;
482305Sstevel 
492305Sstevel typedef enum { PCIHP_SOFT_STATE_CLOSED, PCIHP_SOFT_STATE_OPEN,
502305Sstevel 		PCIHP_SOFT_STATE_OPEN_EXCL } cbhp_soft_state_t;
512305Sstevel 
522305Sstevel /*
532305Sstevel  * Main softstate per cardbus device
542305Sstevel  */
552305Sstevel typedef struct cardbus_dev {
562305Sstevel 	int	cb_instance;
572305Sstevel 	boolean_t fatal_problem;
582305Sstevel 	dev_info_t *cb_dip;
592305Sstevel 	kmutex_t cb_mutex;
602305Sstevel 	cb_nexus_cb_t *cb_nex_ops;
612305Sstevel 	struct dev_ops cb_dops;
622305Sstevel 	struct dev_ops *orig_dopsp;
632305Sstevel 	struct bus_ops *orig_bopsp;
642305Sstevel 	struct cb_deviceset_props *cb_dsp;
652305Sstevel 	ndi_event_hdl_t	cb_ndi_event_hdl;
662305Sstevel 	ndi_event_set_t	cb_ndi_events;
672305Sstevel #ifdef HOTPLUG
682305Sstevel 	/* Nexus specific variables */
692305Sstevel 	ap_rstate_t	rstate;		/* state of Receptacle */
702305Sstevel 	ap_ostate_t	ostate;		/* state of the Occupant */
712305Sstevel 	ap_condition_t	condition;	/* condition of the occupant */
722305Sstevel 	cbhp_soft_state_t	soft_state;
732305Sstevel 	uint32_t	event_mask;	/* last event mask registerd */
742305Sstevel 	boolean_t	auto_config;
752305Sstevel 	boolean_t	disabled;
762305Sstevel 	char	*name;
772305Sstevel 
782305Sstevel 	/* Slot specific variables */
792305Sstevel 	char	ap_id[32];		/* Attachment point name */
802305Sstevel 	char	*nexus_path;		/* Pathname of Nexus */
812305Sstevel 	hpc_slot_ops_t	*slot_ops;	/* Ptr HPC entry points */
822305Sstevel 	hpc_slot_info_t	slot_info;	/* Bus Specific SlotInfo */
832305Sstevel 	hpc_slot_t	slot_handle;	/* HPS slot handle */
842305Sstevel 	boolean_t card_present;
852305Sstevel 	hpc_led_state_t leds[4];
862305Sstevel #endif
872305Sstevel } cbus_t;
882305Sstevel 
892305Sstevel typedef struct cardbus_bus_range {
902305Sstevel 	uint32_t lo;
912305Sstevel 	uint32_t hi;
922305Sstevel } cardbus_bus_range_t;
932305Sstevel 
942305Sstevel typedef struct cardbus_range {
952305Sstevel 	uint32_t child_hi;
962305Sstevel 	uint32_t child_mid;
972305Sstevel 	uint32_t child_lo;
982305Sstevel 	uint32_t parent_hi;
992305Sstevel 	uint32_t parent_mid;
1002305Sstevel 	uint32_t parent_lo;
1012305Sstevel 	uint32_t size_hi;
1022305Sstevel 	uint32_t size_lo;
1032305Sstevel 
1042305Sstevel } cardbus_range_t;
1052305Sstevel 
1062305Sstevel #if defined(DEBUG)
1072305Sstevel #define	CARDBUS_DEBUG
1082305Sstevel #endif
1092305Sstevel 
1102305Sstevel #ifdef CARDBUS_DEBUG
1112305Sstevel extern void prom_printf(const char *, ...);
1122305Sstevel #endif
1132305Sstevel 
1142305Sstevel extern int cardbus_debug;
1152305Sstevel 
1162305Sstevel #ifdef _KERNEL
1172305Sstevel extern int cardbus_attach(dev_info_t *, cb_nexus_cb_t *);
1182305Sstevel extern boolean_t cardbus_load_cardbus(dev_info_t *, uint_t, uint32_t);
1192305Sstevel extern void cardbus_unload_cardbus(dev_info_t *);
1202305Sstevel extern void cardbus_err(dev_info_t *dip, int level, const char *fmt, ...);
1212305Sstevel 
1222305Sstevel /* The following only exists for hotplug support */
1232305Sstevel extern int cardbus_open(dev_t *, int, int, cred_t *);
1242305Sstevel extern int cardbus_close(dev_t, int, int, cred_t *);
1252305Sstevel extern int cardbus_ioctl(dev_t, int, intptr_t, int, cred_t *,
1262305Sstevel 	    int *);
1272305Sstevel extern boolean_t cardbus_is_cb_minor(dev_t);
128*7151Srw148561 void cardbus_save_children(dev_info_t *dip);
129*7151Srw148561 void cardbus_restore_children(dev_info_t *dip);
1302305Sstevel #endif
1312305Sstevel 
1322305Sstevel #ifdef  __cplusplus
1332305Sstevel }
1342305Sstevel #endif
1352305Sstevel 
1362305Sstevel #endif	/* _SYS_CARDBUS_H */
137