cardbus_hp.c revision 0d282d1376eb7ba06504448622a6d65726e4bd3e
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * CDDL HEADER START
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 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * See the License for the specific language governing permissions
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * and limitations under the License.
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 * CDDL HEADER END
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Use is subject to license terms.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Copyright (c) * Copyright (c) 2001 Tadpole Technology plc
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * All rights reserved.
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * From "@(#)pcicfg.c 1.31 99/06/18 SMI"
3db86aab554edbb4244c8d1a1c90f152eee768afstevel#pragma ident "%Z%%M% %I% %E% SMI"
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * Cardbus hotplug module
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * ************************************************************************
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * *** Implementation specific data structures/definitions. ***
3db86aab554edbb4244c8d1a1c90f152eee768afstevel * ************************************************************************
3db86aab554edbb4244c8d1a1c90f152eee768afsteveltypedef struct hpc_occupant_info {
3db86aab554edbb4244c8d1a1c90f152eee768afstevel#define AP_MINOR_NUM(x) (((uint_t)(3) << 8) | ((x) & 0xFF))
3db86aab554edbb4244c8d1a1c90f152eee768afstevelstatic int cardbus_autocfg_enabled = 1; /* auto config is enabled by default */
3db86aab554edbb4244c8d1a1c90f152eee768afstevel/* static functions */
3db86aab554edbb4244c8d1a1c90f152eee768afstevelstatic int cardbus_event_handler(caddr_t slot_arg, uint_t event_mask);
3db86aab554edbb4244c8d1a1c90f152eee768afstevelstatic int cardbus_pci_control(caddr_t ops_arg, hpc_slot_t slot_hdl,
3db86aab554edbb4244c8d1a1c90f152eee768afstevelstatic int cardbus_new_slot_state(dev_info_t *dip, hpc_slot_t hdl,
3db86aab554edbb4244c8d1a1c90f152eee768afstevelstatic int cardbus_list_occupants(dev_info_t *dip, void *hdl);
3db86aab554edbb4244c8d1a1c90f152eee768afstevelstatic void create_occupant_props(dev_info_t *self, dev_t dev);
3db86aab554edbb4244c8d1a1c90f152eee768afstevelstatic void delete_occupant_props(dev_info_t *dip, dev_t dev);
3db86aab554edbb4244c8d1a1c90f152eee768afstevelstatic int cbus_unconfigure(dev_info_t *devi, int prim_bus);
cardbus_new_slot_state, 0) != 0) {
return (DDI_FAILURE);
return (DDI_FAILURE);
return (DDI_SUCCESS);
int cb_instance;
switch (event_mask) {
case HPC_EVENT_SLOT_INSERTION:
case HPC_EVENT_SLOT_CONFIGURE:
ap_minor));
case HPC_EVENT_SLOT_REMOVAL:
case HPC_EVENT_SLOT_POWER_ON:
case HPC_EVENT_SLOT_POWER_OFF:
return (rv);
switch (request) {
case HPC_CTRL_GET_SLOT_STATE:
(void *) hpc_slot_state);
case HPC_CTRL_GET_BOARD_TYPE:
case HPC_CTRL_DEV_CONFIGURED:
case HPC_CTRL_GET_LED_STATE:
case HPC_CTRL_SET_LED_STATE:
case HPC_CTRL_ENABLE_AUTOCFG:
case HPC_CTRL_DISABLE_AUTOCFG:
case HPC_CTRL_DISABLE_ENUM:
case HPC_CTRL_ENABLE_ENUM:
return (rval);
int cb_instance;
int ap_minor;
int rv = 0;
switch (slot_state) {
case HPC_SLOT_ONLINE:
0) == DDI_FAILURE) {
ap_minor));
case HPC_SLOT_OFFLINE:
return (rv);
return (DDI_WALK_CONTINUE);
occupant->i++;
return (DDI_WALK_PRUNECHILD);
int circular;
occupant.i = 0;
(void *)&occupant);
if (occupant.i == 0) {
for (i = 0; i < occupant.i; i++) {
!= DDI_PROP_SUCCESS)
int circular_count;
return (ENXIO);
if (cardbus_debug) {
return (rv);
return (ENXIO);
return (ENXIO);
return (EIO);
if (cardbus_debug) {
return (rv);
return (ENXIO);
B_TRUE);
return (rv);
return (DDI_WALK_CONTINUE);
return (DDI_WALK_PRUNECHILD);
return (DDI_WALK_TERMINATE);
return (DDI_WALK_CONTINUE);
return (DDI_WALK_CONTINUE);
return (DDI_WALK_PRUNECHILD);
return (DDI_WALK_CONTINUE);
return (NDI_SUCCESS);
int rc;
return (rc);
if (top_bridge)
return (NDI_SUCCESS);
return (NDI_FAILURE);
return (NDI_SUCCESS);
return (NDI_SUCCESS);
return (NDI_FAILURE);
return (NDI_SUCCESS);
return (NDI_FAILURE);
return (NDI_FAILURE);
return (NDI_SUCCESS);
int minor;
return (EINVAL);
return (ENXIO);
* Note: Needs review w.r.t exclusive access to AP or the bus.
return (EBUSY);
int minor;
return (EINVAL);
return (ENXIO);
int *rvalp)
int rv = 0;
int nrv = 0;
int ap_minor;
return (ENXIO);
return (EFAULT);
#ifdef CARDBUS_DEBUG
char *cmd_name;
switch (cmd) {
switch (cmd) {
case DEVCTL_DEVICE_GETSTATE:
case DEVCTL_DEVICE_ONLINE:
case DEVCTL_DEVICE_OFFLINE:
case DEVCTL_BUS_GETSTATE:
return (rv);
switch (cmd) {
case DEVCTL_DEVICE_RESET:
case DEVCTL_BUS_QUIESCE:
case DEVCTL_BUS_UNQUIESCE:
case DEVCTL_BUS_RESET:
case DEVCTL_BUS_RESETALL:
case DEVCTL_AP_CONNECT:
case DEVCTL_AP_DISCONNECT:
case DEVCTL_AP_INSERT:
case DEVCTL_AP_REMOVE:
switch (cmd) {
case DEVCTL_AP_INSERT:
case DEVCTL_AP_REMOVE:
case DEVCTL_AP_CONNECT:
NULL, 0)) == 0)
case DEVCTL_AP_DISCONNECT:
NULL, 0)) == 0)
switch (rv) {
case HPC_ERR_INVALID:
case HPC_ERR_NOTSUPPORTED:
case HPC_ERR_FAILED:
case DEVCTL_AP_CONFIGURE:
case DEVCTL_AP_UNCONFIGURE:
case DEVCTL_AP_GETSTATE:
int mutex_held;
if (mutex_held)
if (mutex_held)
if (mutex_held)
case DEVCTL_AP_CONTROL:
#ifdef _MULTI_DATAMODEL
sizeof (struct hpc_control32_data)) != 0) {
sizeof (struct hpc_control_data)) != 0) {
#ifdef CARDBUS_DEBUG
char *hpc_name;
case HPC_CTRL_GET_LED_STATE:
case HPC_CTRL_SET_LED_STATE:
case HPC_CTRL_ENABLE_SLOT:
case HPC_CTRL_DISABLE_SLOT:
case HPC_CTRL_ENABLE_AUTOCFG:
case HPC_CTRL_DISABLE_AUTOCFG:
case HPC_CTRL_GET_BOARD_TYPE:
case HPC_CTRL_GET_SLOT_INFO:
case HPC_CTRL_GET_CARD_INFO:
case HPC_CTRL_GET_LED_STATE:
sizeof (hpc_led_info_t)) != 0) {
sizeof (hpc_led_info_t)) != 0) {
case HPC_CTRL_SET_LED_STATE:
sizeof (hpc_led_info_t)) != 0) {
case HPC_CTRL_ENABLE_SLOT:
case HPC_CTRL_DISABLE_SLOT:
case HPC_CTRL_ENABLE_AUTOCFG:
case HPC_CTRL_DISABLE_AUTOCFG:
case HPC_CTRL_GET_BOARD_TYPE:
sizeof (hpc_board_type_t)) != 0) {
case HPC_CTRL_GET_SLOT_INFO:
sizeof (hpc_slot_info_t)) != 0) {
case HPC_CTRL_GET_CARD_INFO:
if (!child_dip) {
!= DDI_SUCCESS) {
sizeof (hpc_card_info_t)) != 0) {
return (rv);
struct cardbus_pci_desc {
char *name;
int (*cfg_get_func)();
char *fmt;