xref: /titanic_51/usr/src/uts/common/io/cardbus/cardbus.h (revision 11c2b4c0e543fe2e1e5910cde1f4422cc3218160)
13db86aabSstevel /*
23db86aabSstevel  * CDDL HEADER START
33db86aabSstevel  *
43db86aabSstevel  * The contents of this file are subject to the terms of the
53db86aabSstevel  * Common Development and Distribution License (the "License").
63db86aabSstevel  * You may not use this file except in compliance with the License.
73db86aabSstevel  *
83db86aabSstevel  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
93db86aabSstevel  * or http://www.opensolaris.org/os/licensing.
103db86aabSstevel  * See the License for the specific language governing permissions
113db86aabSstevel  * and limitations under the License.
123db86aabSstevel  *
133db86aabSstevel  * When distributing Covered Code, include this CDDL HEADER in each
143db86aabSstevel  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
153db86aabSstevel  * If applicable, add the following below this CDDL HEADER, with the
163db86aabSstevel  * fields enclosed by brackets "[]" replaced with your own identifying
173db86aabSstevel  * information: Portions Copyright [yyyy] [name of copyright owner]
183db86aabSstevel  *
193db86aabSstevel  * CDDL HEADER END
203db86aabSstevel  */
213db86aabSstevel /*
22*11c2b4c0Srw148561  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
233db86aabSstevel  * Use is subject to license terms.
243db86aabSstevel  */
253db86aabSstevel /*
263db86aabSstevel  * Copyright (c)  * Copyright (c) 2001 Tadpole Technology plc
273db86aabSstevel  * All rights reserved.
283db86aabSstevel  */
293db86aabSstevel 
303db86aabSstevel #ifndef	_SYS_CARDBUS_H
313db86aabSstevel #define	_SYS_CARDBUS_H
323db86aabSstevel 
333db86aabSstevel #pragma ident	"%Z%%M%	%I%	%E% SMI"
343db86aabSstevel 
353db86aabSstevel #ifdef  __cplusplus
363db86aabSstevel extern "C" {
373db86aabSstevel #endif
383db86aabSstevel 
393db86aabSstevel #define	CB_BCNF_BCNTRL_ISA_INT_ENAB	0x0080
403db86aabSstevel #define	CB_BCNF_BCNTRL_MEM0_PREF	0x0100
413db86aabSstevel #define	CB_BCNF_BCNTRL_MEM1_PREF	0x0200
423db86aabSstevel #define	CB_BCNF_BCNTRL_WRITE_POST	0x0400
433db86aabSstevel 
443db86aabSstevel typedef struct cb_nexus_cb {
453db86aabSstevel 	void	(*enable_intr)(dev_info_t *);
463db86aabSstevel 	void	(*disable_intr)(dev_info_t *);
473db86aabSstevel } cb_nexus_cb_t;
483db86aabSstevel 
493db86aabSstevel typedef enum { PCIHP_SOFT_STATE_CLOSED, PCIHP_SOFT_STATE_OPEN,
503db86aabSstevel 		PCIHP_SOFT_STATE_OPEN_EXCL } cbhp_soft_state_t;
513db86aabSstevel 
523db86aabSstevel /*
533db86aabSstevel  * Main softstate per cardbus device
543db86aabSstevel  */
553db86aabSstevel typedef struct cardbus_dev {
563db86aabSstevel 	int	cb_instance;
573db86aabSstevel 	boolean_t fatal_problem;
583db86aabSstevel 	dev_info_t *cb_dip;
593db86aabSstevel 	kmutex_t cb_mutex;
603db86aabSstevel 	cb_nexus_cb_t *cb_nex_ops;
613db86aabSstevel 	struct dev_ops cb_dops;
623db86aabSstevel 	struct dev_ops *orig_dopsp;
633db86aabSstevel 	struct bus_ops *orig_bopsp;
643db86aabSstevel 	struct cb_deviceset_props *cb_dsp;
653db86aabSstevel 	ndi_event_hdl_t	cb_ndi_event_hdl;
663db86aabSstevel 	ndi_event_set_t	cb_ndi_events;
673db86aabSstevel #ifdef HOTPLUG
683db86aabSstevel 	/* Nexus specific variables */
693db86aabSstevel 	ap_rstate_t	rstate;		/* state of Receptacle */
703db86aabSstevel 	ap_ostate_t	ostate;		/* state of the Occupant */
713db86aabSstevel 	ap_condition_t	condition;	/* condition of the occupant */
723db86aabSstevel 	cbhp_soft_state_t	soft_state;
733db86aabSstevel 	uint32_t	event_mask;	/* last event mask registerd */
743db86aabSstevel 	boolean_t	auto_config;
753db86aabSstevel 	boolean_t	disabled;
763db86aabSstevel 	char	*name;
773db86aabSstevel 
783db86aabSstevel 	/* Slot specific variables */
793db86aabSstevel 	char	ap_id[32];		/* Attachment point name */
803db86aabSstevel 	char	*nexus_path;		/* Pathname of Nexus */
813db86aabSstevel 	hpc_slot_ops_t	*slot_ops;	/* Ptr HPC entry points */
823db86aabSstevel 	hpc_slot_info_t	slot_info;	/* Bus Specific SlotInfo */
833db86aabSstevel 	hpc_slot_t	slot_handle;	/* HPS slot handle */
843db86aabSstevel 	boolean_t card_present;
853db86aabSstevel 	hpc_led_state_t leds[4];
863db86aabSstevel #endif
873db86aabSstevel } cbus_t;
883db86aabSstevel 
893db86aabSstevel typedef struct cardbus_bus_range {
903db86aabSstevel 	uint32_t lo;
913db86aabSstevel 	uint32_t hi;
923db86aabSstevel } cardbus_bus_range_t;
933db86aabSstevel 
943db86aabSstevel typedef struct cardbus_range {
953db86aabSstevel 	uint32_t child_hi;
963db86aabSstevel 	uint32_t child_mid;
973db86aabSstevel 	uint32_t child_lo;
983db86aabSstevel 	uint32_t parent_hi;
993db86aabSstevel 	uint32_t parent_mid;
1003db86aabSstevel 	uint32_t parent_lo;
1013db86aabSstevel 	uint32_t size_hi;
1023db86aabSstevel 	uint32_t size_lo;
1033db86aabSstevel 
1043db86aabSstevel } cardbus_range_t;
1053db86aabSstevel 
1063db86aabSstevel #if defined(DEBUG)
1073db86aabSstevel #define	CARDBUS_DEBUG
1083db86aabSstevel #endif
1093db86aabSstevel 
1103db86aabSstevel #ifdef CARDBUS_DEBUG
1113db86aabSstevel extern void prom_printf(const char *, ...);
1123db86aabSstevel #endif
1133db86aabSstevel 
1143db86aabSstevel extern int cardbus_debug;
1153db86aabSstevel 
1163db86aabSstevel #ifdef _KERNEL
1173db86aabSstevel extern int cardbus_attach(dev_info_t *, cb_nexus_cb_t *);
1183db86aabSstevel extern boolean_t cardbus_load_cardbus(dev_info_t *, uint_t, uint32_t);
1193db86aabSstevel extern void cardbus_unload_cardbus(dev_info_t *);
1203db86aabSstevel extern void cardbus_err(dev_info_t *dip, int level, const char *fmt, ...);
1213db86aabSstevel 
1223db86aabSstevel /* The following only exists for hotplug support */
1233db86aabSstevel extern int cardbus_open(dev_t *, int, int, cred_t *);
1243db86aabSstevel extern int cardbus_close(dev_t, int, int, cred_t *);
1253db86aabSstevel extern int cardbus_ioctl(dev_t, int, intptr_t, int, cred_t *,
1263db86aabSstevel 	    int *);
1273db86aabSstevel extern boolean_t cardbus_is_cb_minor(dev_t);
128*11c2b4c0Srw148561 void cardbus_save_children(dev_info_t *dip);
129*11c2b4c0Srw148561 void cardbus_restore_children(dev_info_t *dip);
1303db86aabSstevel #endif
1313db86aabSstevel 
1323db86aabSstevel #ifdef  __cplusplus
1333db86aabSstevel }
1343db86aabSstevel #endif
1353db86aabSstevel 
1363db86aabSstevel #endif	/* _SYS_CARDBUS_H */
137