pciehpc_acpi.c revision ed11b5015754f34571b1ea0fef3f0faad03a1e45
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* ACPI interface related functions used in PCIEHPC driver module.
*
*/
#include <sys/ddi_impldefs.h>
#include <sys/pci_impl.h>
#include <sys/pcie_acpi.h>
/* local static functions */
void *context);
/*
* Update ops vector with platform specific (ACPI, CK8-04,...) functions.
*/
void
{
/*
* Call _OSC method to determine if hotplug mode is native or ACPI.
* If _OSC method succeeds hp_native_mode below will be set according to
* if native hotplug control was granted or not by BIOS.
*
* If _OSC method fails for any reason or if native hotplug control was
* not granted assume it's ACPI mode and update platform specific
* (ACPI, CK8-04,...) impl. ops
*/
}
if (!hp_native_mode) {
/* update ops vector for ACPI mode */
}
}
void
{
}
/*
* Intialize hot plug control for ACPI mode.
*/
static int
{
uint16_t bus_methods = 0;
uint16_t slot_methods = 0;
/* get the ACPI object for the bus node */
return (DDI_FAILURE);
/* get the ACPI object handle for the child node */
NULL, &slot_dev_obj);
PCIE_DBG("pciehpc_acpi_hpc_init: Get ACPI object failed\n");
return (DDI_FAILURE);
}
/*
* gather the info about the ACPI methods present on the bus node
* and the child nodes.
*/
/* save ACPI object handles, etc. */
return (DDI_SUCCESS);
}
/*
* Uninitialize HPC.
*/
static int
{
/* free up buffer used for misc_data */
if (ctrl_p->hc_misc_data) {
}
return (DDI_SUCCESS);
}
/*
* Enable interrupts. For ACPI hot plug this is a NOP.
* Just return DDI_SUCCESS.
*/
/*ARGSUSED*/
static int
{
return (DDI_SUCCESS);
}
/*
* Disable interrupts. For ACPI hot plug this is a NOP.
* Just return DDI_SUCCESS.
*/
/*ARGSUSED*/
static int
{
return (DDI_SUCCESS);
}
/*
* This function is similar to pciehpc_slotinfo_init() with some
* changes:
* - no need for kernel thread to handle ATTN button events
* - function ops for connect/disconnect are different
*
* ASSUMPTION: No conflict in doing reads to HP registers directly.
* Otherwise, there are no ACPI interfaces to do LED control or to get
* the hot plug capabilities (ATTN button, MRL, etc.).
*/
static int
{
/*
* setup DDI HP framework slot information structure
*/
slot_p->hs_device_num = 0;
/* read Slot Capabilities Register */
/* check if Attn Button present */
/* check if Manual Retention Latch sensor present */
/*
* PCI-E (draft) version 1.1 defines EMI Lock Present bit
* in Slot Capabilities register. Check for it.
*/
/* get current slot state from the hw */
/* setup Notify() handler for hot plug events from ACPI BIOS */
return (DDI_FAILURE);
PCIE_DBG("ACPI hot plug is enabled for slot #%d\n",
return (DDI_SUCCESS);
}
/*
* This function is similar to pciehcp_slotinfo_uninit() but has ACPI
* specific cleanup.
*/
static int
{
/* uninstall Notify() event handler */
return (DDI_SUCCESS);
}
/*
* This function is same as pciehpc_slot_poweron() except that it
* uses ACPI method PS0 to enable power to the slot. If no PS0 method
* is present then it returns DDI_FAILURE.
*/
/*ARGSUSED*/
static int
{
/* get the current state of the slot */
/* check if the slot is already in the 'ENABLED' state */
/* slot is already in the 'connected' state */
PCIE_DBG("slot %d already connected\n",
return (DDI_SUCCESS);
}
/* read the Slot Status Register */
/* make sure the MRL switch is closed if present */
/* MRL switch is open */
goto cleanup;
}
/* make sure the slot has a device present */
if (!(status & PCIE_SLOTSTS_PRESENCE_DETECTED)) {
/* slot is empty */
goto cleanup;
}
/* get the current state of Slot Control Register */
/* check if the slot's power state is ON */
if (!(control & PCIE_SLOTCTL_PWR_CONTROL)) {
/* slot is already powered up */
PCIE_DBG("slot %d already connected\n",
return (DDI_SUCCESS);
}
/* turn on power to the slot using ACPI method (PS0) */
goto cleanup;
return (DDI_SUCCESS);
return (DDI_FAILURE);
}
/*
* This function is same as pciehpc_slot_poweroff() except that it
* uses ACPI method EJ0 to disable power to the slot. If no EJ0 method
* is present then it returns DDI_FAILURE.
*/
/*ARGSUSED*/
static int
{
/* get the current state of the slot */
/* check if the slot is already in the state less than 'powered' */
/* slot is in the 'disconnected' state */
PCIE_DBG("slot %d already disconnected\n",
return (DDI_SUCCESS);
}
/* read the Slot Status Register */
/* make sure the slot has a device present */
if (!(status & PCIE_SLOTSTS_PRESENCE_DETECTED)) {
/* slot is empty */
goto cleanup;
}
/* turn off power to the slot using ACPI method (EJ0) */
goto cleanup;
/* get the current state of the slot */
return (DDI_SUCCESS);
return (DDI_FAILURE);
}
/*
* Install event handler for the hot plug events on the bus node as well
* as device function (dev=0,func=0).
*/
static ACPI_STATUS
{
PCIE_DBG("install event handler for slot %d\n",
return (AE_NOT_FOUND);
/*
* Install event hanlder for events on the bus object.
* (Note: Insert event (hot-insert) is delivered on this object)
*/
goto cleanup;
/*
* Install event hanlder for events on the device function object.
* (Note: Eject device event (hot-remove) is delivered on this object)
*
* NOTE: Here the assumption is that Notify events are delivered
* on all of the 8 possible device functions so, subscribing to
* one of them is sufficient.
*/
return (status);
return (status);
}
/*ARGSUSED*/
static void
{
int dev_state = 0;
PCIE_DBG("received Notify(%d) event on slot #%d\n",
/*
* get the state of the device (from _STA method)
*/
}
PCIE_DBG("(1)device state on slot #%d: 0x%x\n",
switch (val) {
case 0: /* (re)enumerate the device */
case 3: /* Request Eject */
{
/*
* Ignore the event if ATTN button is not present (ACPI BIOS
* problem).
*
* NOTE: This situation has been observed on some platforms
* where the ACPI BIOS is generating the event for some other
* (non hot-plug) operations (bug).
*/
PCIE_DBG("Ignore the unexpected event "
"on slot #%d (state 0x%x)",
break;
}
/* send the event to DDI Hotplug framework */
if (curr_state < DDI_HP_CN_STATE_POWERED) {
/* Insertion. Upgrade state to ENABLED */
/*
* When pressing ATTN button to enable a card, the slot
* could be powered. Keep the slot state on PWOERED
* other than ENABLED.
*/
} else {
/* Want to remove; Power off Connection */
}
break;
}
default:
break;
}
}
static void
{
PCIE_DBG("Uninstall event handler for slot #%d\n",
}
/*
* Run _PS0 method to turn on power to the slot.
*/
static ACPI_STATUS
{
int dev_state = 0;
/* get the state of the device (from _STA method) */
}
PCIE_DBG("(3)device state on slot #%d: 0x%x\n",
"(dev_state 0x%x, ACPI_STATUS 0x%x)",
return (AE_ERROR);
}
return (status);
}
/*
* Run _EJ0 method to turn off power to the slot.
*/
static ACPI_STATUS
{
int dev_state = 0;
/* get the state of the device (from _STA method) */
}
PCIE_DBG("(2)device state on slot #%d: 0x%x\n",
"(dev_state 0x%x, ACPI_STATUS 0x%x)",
return (AE_ERROR);
}
return (status);
}
/*
* Get the status info (as returned by _STA method) for the device.
*/
static ACPI_STATUS
{
/*
* Get device info object
*/
return (ret);
} else {
/*
* no _STA present; assume the device status is normal
* (i.e present, enabled, shown in UI and functioning).
* See section 6.3.7 of ACPI 3.0 spec.
*/
*statusp = STATUS_NORMAL;
}
return (ret);
}