3db86aab554edbb4244c8d1a1c90f152eee768afstevel/*
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * CDDL HEADER START
3db86aab554edbb4244c8d1a1c90f152eee768afstevel *
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * The contents of this file are subject to the terms of the
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Common Development and Distribution License (the "License").
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * You may not use this file except in compliance with the License.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel *
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * or http://www.opensolaris.org/os/licensing.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * See the License for the specific language governing permissions
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * and limitations under the License.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel *
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * When distributing Covered Code, include this CDDL HEADER in each
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * If applicable, add the following below this CDDL HEADER, with the
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * fields enclosed by brackets "[]" replaced with your own identifying
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * information: Portions Copyright [yyyy] [name of copyright owner]
3db86aab554edbb4244c8d1a1c90f152eee768afstevel *
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * CDDL HEADER END
3db86aab554edbb4244c8d1a1c90f152eee768afstevel */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel/*
11c2b4c0e543fe2e1e5910cde1f4422cc3218160rw * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Use is subject to license terms.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel/*
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Copyright (c) * Copyright (c) 2001 Tadpole Technology plc
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * All rights reserved.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel
3db86aab554edbb4244c8d1a1c90f152eee768afstevel#ifndef _SYS_CARDBUS_H
3db86aab554edbb4244c8d1a1c90f152eee768afstevel#define _SYS_CARDBUS_H
3db86aab554edbb4244c8d1a1c90f152eee768afstevel
3db86aab554edbb4244c8d1a1c90f152eee768afstevel#pragma ident "%Z%%M% %I% %E% SMI"
3db86aab554edbb4244c8d1a1c90f152eee768afstevel
3db86aab554edbb4244c8d1a1c90f152eee768afstevel#ifdef __cplusplus
3db86aab554edbb4244c8d1a1c90f152eee768afstevelextern "C" {
3db86aab554edbb4244c8d1a1c90f152eee768afstevel#endif
3db86aab554edbb4244c8d1a1c90f152eee768afstevel
3db86aab554edbb4244c8d1a1c90f152eee768afstevel#define CB_BCNF_BCNTRL_ISA_INT_ENAB 0x0080
3db86aab554edbb4244c8d1a1c90f152eee768afstevel#define CB_BCNF_BCNTRL_MEM0_PREF 0x0100
3db86aab554edbb4244c8d1a1c90f152eee768afstevel#define CB_BCNF_BCNTRL_MEM1_PREF 0x0200
3db86aab554edbb4244c8d1a1c90f152eee768afstevel#define CB_BCNF_BCNTRL_WRITE_POST 0x0400
3db86aab554edbb4244c8d1a1c90f152eee768afstevel
3db86aab554edbb4244c8d1a1c90f152eee768afsteveltypedef struct cb_nexus_cb {
3db86aab554edbb4244c8d1a1c90f152eee768afstevel void (*enable_intr)(dev_info_t *);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel void (*disable_intr)(dev_info_t *);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel} cb_nexus_cb_t;
3db86aab554edbb4244c8d1a1c90f152eee768afstevel
3db86aab554edbb4244c8d1a1c90f152eee768afsteveltypedef enum { PCIHP_SOFT_STATE_CLOSED, PCIHP_SOFT_STATE_OPEN,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel PCIHP_SOFT_STATE_OPEN_EXCL } cbhp_soft_state_t;
3db86aab554edbb4244c8d1a1c90f152eee768afstevel
3db86aab554edbb4244c8d1a1c90f152eee768afstevel/*
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Main softstate per cardbus device
3db86aab554edbb4244c8d1a1c90f152eee768afstevel */
3db86aab554edbb4244c8d1a1c90f152eee768afsteveltypedef struct cardbus_dev {
3db86aab554edbb4244c8d1a1c90f152eee768afstevel int cb_instance;
3db86aab554edbb4244c8d1a1c90f152eee768afstevel boolean_t fatal_problem;
3db86aab554edbb4244c8d1a1c90f152eee768afstevel dev_info_t *cb_dip;
3db86aab554edbb4244c8d1a1c90f152eee768afstevel kmutex_t cb_mutex;
3db86aab554edbb4244c8d1a1c90f152eee768afstevel cb_nexus_cb_t *cb_nex_ops;
3db86aab554edbb4244c8d1a1c90f152eee768afstevel struct dev_ops cb_dops;
3db86aab554edbb4244c8d1a1c90f152eee768afstevel struct dev_ops *orig_dopsp;
3db86aab554edbb4244c8d1a1c90f152eee768afstevel struct bus_ops *orig_bopsp;
3db86aab554edbb4244c8d1a1c90f152eee768afstevel struct cb_deviceset_props *cb_dsp;
3db86aab554edbb4244c8d1a1c90f152eee768afstevel ndi_event_hdl_t cb_ndi_event_hdl;
3db86aab554edbb4244c8d1a1c90f152eee768afstevel ndi_event_set_t cb_ndi_events;
3db86aab554edbb4244c8d1a1c90f152eee768afstevel#ifdef HOTPLUG
3db86aab554edbb4244c8d1a1c90f152eee768afstevel /* Nexus specific variables */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel ap_rstate_t rstate; /* state of Receptacle */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel ap_ostate_t ostate; /* state of the Occupant */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel ap_condition_t condition; /* condition of the occupant */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel cbhp_soft_state_t soft_state;
3db86aab554edbb4244c8d1a1c90f152eee768afstevel uint32_t event_mask; /* last event mask registerd */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel boolean_t auto_config;
3db86aab554edbb4244c8d1a1c90f152eee768afstevel boolean_t disabled;
3db86aab554edbb4244c8d1a1c90f152eee768afstevel char *name;
3db86aab554edbb4244c8d1a1c90f152eee768afstevel
3db86aab554edbb4244c8d1a1c90f152eee768afstevel /* Slot specific variables */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel char ap_id[32]; /* Attachment point name */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel char *nexus_path; /* Pathname of Nexus */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel hpc_slot_ops_t *slot_ops; /* Ptr HPC entry points */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel hpc_slot_info_t slot_info; /* Bus Specific SlotInfo */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel hpc_slot_t slot_handle; /* HPS slot handle */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel boolean_t card_present;
3db86aab554edbb4244c8d1a1c90f152eee768afstevel hpc_led_state_t leds[4];
3db86aab554edbb4244c8d1a1c90f152eee768afstevel#endif
3db86aab554edbb4244c8d1a1c90f152eee768afstevel} cbus_t;
3db86aab554edbb4244c8d1a1c90f152eee768afstevel
3db86aab554edbb4244c8d1a1c90f152eee768afsteveltypedef struct cardbus_bus_range {
3db86aab554edbb4244c8d1a1c90f152eee768afstevel uint32_t lo;
3db86aab554edbb4244c8d1a1c90f152eee768afstevel uint32_t hi;
3db86aab554edbb4244c8d1a1c90f152eee768afstevel} cardbus_bus_range_t;
3db86aab554edbb4244c8d1a1c90f152eee768afstevel
3db86aab554edbb4244c8d1a1c90f152eee768afsteveltypedef struct cardbus_range {
3db86aab554edbb4244c8d1a1c90f152eee768afstevel uint32_t child_hi;
3db86aab554edbb4244c8d1a1c90f152eee768afstevel uint32_t child_mid;
3db86aab554edbb4244c8d1a1c90f152eee768afstevel uint32_t child_lo;
3db86aab554edbb4244c8d1a1c90f152eee768afstevel uint32_t parent_hi;
3db86aab554edbb4244c8d1a1c90f152eee768afstevel uint32_t parent_mid;
3db86aab554edbb4244c8d1a1c90f152eee768afstevel uint32_t parent_lo;
3db86aab554edbb4244c8d1a1c90f152eee768afstevel uint32_t size_hi;
3db86aab554edbb4244c8d1a1c90f152eee768afstevel uint32_t size_lo;
3db86aab554edbb4244c8d1a1c90f152eee768afstevel
3db86aab554edbb4244c8d1a1c90f152eee768afstevel} cardbus_range_t;
3db86aab554edbb4244c8d1a1c90f152eee768afstevel
3db86aab554edbb4244c8d1a1c90f152eee768afstevel#if defined(DEBUG)
3db86aab554edbb4244c8d1a1c90f152eee768afstevel#define CARDBUS_DEBUG
3db86aab554edbb4244c8d1a1c90f152eee768afstevel#endif
3db86aab554edbb4244c8d1a1c90f152eee768afstevel
3db86aab554edbb4244c8d1a1c90f152eee768afstevel#ifdef CARDBUS_DEBUG
3db86aab554edbb4244c8d1a1c90f152eee768afstevelextern void prom_printf(const char *, ...);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel#endif
3db86aab554edbb4244c8d1a1c90f152eee768afstevel
3db86aab554edbb4244c8d1a1c90f152eee768afstevelextern int cardbus_debug;
3db86aab554edbb4244c8d1a1c90f152eee768afstevel
3db86aab554edbb4244c8d1a1c90f152eee768afstevel#ifdef _KERNEL
3db86aab554edbb4244c8d1a1c90f152eee768afstevelextern int cardbus_attach(dev_info_t *, cb_nexus_cb_t *);
3db86aab554edbb4244c8d1a1c90f152eee768afstevelextern boolean_t cardbus_load_cardbus(dev_info_t *, uint_t, uint32_t);
3db86aab554edbb4244c8d1a1c90f152eee768afstevelextern void cardbus_unload_cardbus(dev_info_t *);
3db86aab554edbb4244c8d1a1c90f152eee768afstevelextern void cardbus_err(dev_info_t *dip, int level, const char *fmt, ...);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel
3db86aab554edbb4244c8d1a1c90f152eee768afstevel/* The following only exists for hotplug support */
3db86aab554edbb4244c8d1a1c90f152eee768afstevelextern int cardbus_open(dev_t *, int, int, cred_t *);
3db86aab554edbb4244c8d1a1c90f152eee768afstevelextern int cardbus_close(dev_t, int, int, cred_t *);
3db86aab554edbb4244c8d1a1c90f152eee768afstevelextern int cardbus_ioctl(dev_t, int, intptr_t, int, cred_t *,
3db86aab554edbb4244c8d1a1c90f152eee768afstevel int *);
3db86aab554edbb4244c8d1a1c90f152eee768afstevelextern boolean_t cardbus_is_cb_minor(dev_t);
11c2b4c0e543fe2e1e5910cde1f4422cc3218160rwvoid cardbus_save_children(dev_info_t *dip);
11c2b4c0e543fe2e1e5910cde1f4422cc3218160rwvoid cardbus_restore_children(dev_info_t *dip);
3db86aab554edbb4244c8d1a1c90f152eee768afstevel#endif
3db86aab554edbb4244c8d1a1c90f152eee768afstevel
3db86aab554edbb4244c8d1a1c90f152eee768afstevel#ifdef __cplusplus
3db86aab554edbb4244c8d1a1c90f152eee768afstevel}
3db86aab554edbb4244c8d1a1c90f152eee768afstevel#endif
3db86aab554edbb4244c8d1a1c90f152eee768afstevel
3db86aab554edbb4244c8d1a1c90f152eee768afstevel#endif /* _SYS_CARDBUS_H */