pciehpc.c revision 28cae8e27cd02e5b8df9666bb34af9786c217a1a
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * CDDL HEADER START
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * The contents of this file are subject to the terms of the
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * Common Development and Distribution License (the "License").
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * You may not use this file except in compliance with the License.
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * See the License for the specific language governing permissions
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * and limitations under the License.
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * When distributing Covered Code, include this CDDL HEADER in each
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * If applicable, add the following below this CDDL HEADER, with the
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * fields enclosed by brackets "[]" replaced with your own identifying
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * information: Portions Copyright [yyyy] [name of copyright owner]
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * CDDL HEADER END
81af778e872fc2ec5f0ac36e7b25bdb24ebd2d6aCasper H.S. Dik * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * Use is subject to license terms.
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin#pragma ident "%Z%%M% %I% %E% SMI"
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * PCIEHPC - The Standard PCI Express HotPlug Controller driver module. This
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * driver can be used with PCI Express HotPlug controllers that
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin * are compatible with the PCI Express ver 1.0a specification.
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin/* mutex to protect pciehpc_head list */
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin/* pointer to linked list of pciehpc structures */
81af778e872fc2ec5f0ac36e7b25bdb24ebd2d6aCasper H.S. Dik/* mutex to protect init/uninit controllers */
81af778e872fc2ec5f0ac36e7b25bdb24ebd2d6aCasper H.S. Dikstatic int pciehpc_init_count = 0; /* count of pciehpc instances in use */
81af778e872fc2ec5f0ac36e7b25bdb24ebd2d6aCasper H.S. Dikstatic pciehpc_t *pciehpc_create_soft_state(dev_info_t *dip);
81af778e872fc2ec5f0ac36e7b25bdb24ebd2d6aCasper H.S. Dikstatic pciehpc_t *pciehpc_get_soft_state(dev_info_t *dip);
81af778e872fc2ec5f0ac36e7b25bdb24ebd2d6aCasper H.S. Dikstatic void pciehpc_destroy_soft_state(dev_info_t *dip);
81af778e872fc2ec5f0ac36e7b25bdb24ebd2d6aCasper H.S. Dikstatic char *pciehpc_led_state_text(hpc_led_state_t state);
81af778e872fc2ec5f0ac36e7b25bdb24ebd2d6aCasper H.S. Dikstatic void pciehpc_attn_btn_handler(pciehpc_t *ctrl_p);
81af778e872fc2ec5f0ac36e7b25bdb24ebd2d6aCasper H.S. Dikstatic void pciehpc_dev_info(pciehpc_t *ctrl_p);
81af778e872fc2ec5f0ac36e7b25bdb24ebd2d6aCasper H.S. Dikstatic int pciehpc_pcie_dev(dev_info_t *dip, ddi_acc_handle_t handle);
81af778e872fc2ec5f0ac36e7b25bdb24ebd2d6aCasper H.S. Dikstatic void pciehpc_disable_errors(pciehpc_t *ctrl_p);
81af778e872fc2ec5f0ac36e7b25bdb24ebd2d6aCasper H.S. Dikstatic void pciehpc_enable_errors(pciehpc_t *ctrl_p);
81af778e872fc2ec5f0ac36e7b25bdb24ebd2d6aCasper H.S. Dikstatic void pciehpc_dump_hpregs(pciehpc_t *ctrl_p);
81af778e872fc2ec5f0ac36e7b25bdb24ebd2d6aCasper H.S. Dik * Module linkage information for the kernel.
81af778e872fc2ec5f0ac36e7b25bdb24ebd2d6aCasper H.S. Dik "PCIe hotplug driver v%I%",
_init(void)
int error;
return (error);
_fini(void)
int error;
if (pciehpc_init_count != 0) {
return (EBUSY);
if (error != 0) {
return (error);
(void *)dip));
return (DDI_SUCCESS);
goto cleanup;
goto cleanup1;
goto cleanup1;
goto cleanup2;
goto cleanup3;
#ifdef DEBUG
/* enable hot plug interrupts/event */
return (DDI_SUCCESS);
return (DDI_FAILURE);
(void *)dip));
return (DDI_FAILURE);
return (DDI_SUCCESS);
return (DDI_FAILURE);
return (DDI_SUCCESS);
return (DDI_FAILURE);
/* set slot-name/slot-number info */
return (DDI_SUCCESS);
return (DDI_SUCCESS);
p->power_led_state =
p->attn_led_state =
static pciehpc_t *
while (ctrl_p) {
return (ctrl_p);
return (NULL);
static pciehpc_t *
return (ctrl_p);
pciehpc_t *p;
switch (state) {
return (HPC_LED_ON);
return (HPC_LED_BLINK);
return (HPC_LED_OFF);
switch (state) {
case HPC_LED_ON:
return (PCIE_SLOTCTL_INDICATOR_STATE_ON);
case HPC_LED_BLINK:
return (PCIE_SLOTCTL_INDICATOR_STATE_BLINK);
case HPC_LED_OFF:
return (PCIE_SLOTCTL_INDICATOR_STATE_OFF);
(void *)PCIEHPC_INTR_PRI);
return (DDI_SUCCESS);
return (DDI_SUCCESS);
return (DDI_SUCCESS);
return (DDI_SUCCESS);
p->slotNum));
return (DDI_FAILURE);
return (DDI_SUCCESS);
p->slotNum));
return (DDI_FAILURE);
return (DDI_SUCCESS);
return (DDI_INTR_UNCLAIMED);
return (DDI_INTR_UNCLAIMED);
return (DDI_INTR_UNCLAIMED);
return (DDI_INTR_UNCLAIMED);
return (DDI_INTR_CLAIMED);
#ifdef DEBUG
switch (state) {
case HPC_LED_ON:
case HPC_LED_OFF:
case HPC_LED_BLINK:
return (HPC_SUCCESS);
goto cleanup;
goto cleanup;
return (HPC_SUCCESS);
ddi_get_lbolt() +
goto cleanup2;
goto cleanup1;
return (HPC_SUCCESS);
return (HPC_ERR_FAILED);
return (HPC_SUCCESS);
goto cleanup;
#ifdef DEBUG
return (HPC_SUCCESS);
return (HPC_ERR_FAILED);
switch (request) {
case HPC_CTRL_GET_SLOT_STATE:
case HPC_CTRL_GET_BOARD_TYPE:
case HPC_CTRL_GET_LED_STATE:
case HPC_ATTN_LED:
case HPC_POWER_LED:
case HPC_FAULT_LED:
case HPC_ACTIVE_LED:
case HPC_CTRL_SET_LED_STATE:
case HPC_ATTN_LED:
case HPC_POWER_LED:
case HPC_FAULT_LED:
case HPC_ACTIVE_LED:
case HPC_CTRL_ENABLE_AUTOCFG:
case HPC_CTRL_DISABLE_AUTOCFG:
case HPC_CTRL_DISABLE_SLOT:
case HPC_CTRL_ENABLE_SLOT:
case HPC_CTRL_DEV_CONFIGURED:
return (ret);
switch (led) {
case HPC_POWER_LED:
case HPC_ATTN_LED:
return (HPC_LED_OFF);
switch (state) {
return (HPC_LED_ON);
return (HPC_LED_BLINK);
return (HPC_LED_OFF);
switch (led) {
case HPC_POWER_LED:
case HPC_ATTN_LED:
switch (state) {
case HPC_LED_ON:
case HPC_LED_OFF:
case HPC_LED_BLINK:
#ifdef DEBUG
* 1) If Command Complete events/interrupts are supported then software
* 2) If Command Complete events/interrupts are not supported then
control);
while (retry--) {
status);
status);
(void) hpc_slot_event_notify(
thread_exit();
int reglen;
* setup slot name/slot-number info.
int *slotnum;
int len;
int invalid_slotnum = 0;
p->slotNum);
char *device_type;
int rc;
!= DDI_PROP_SUCCESS) {
return (DDI_FAILURE);
return (rc);