/*******************************************************************************1*2* Module Name: evsci - System Control Interrupt configuration and3* legacy to ACPI mode state transition functions4*5******************************************************************************/67/*8* Copyright (C) 2000 - 2011, Intel Corp.9* All rights reserved.10*11* Redistribution and use in source and binary forms, with or without12* modification, are permitted provided that the following conditions13* are met:14* 1. Redistributions of source code must retain the above copyright15* notice, this list of conditions, and the following disclaimer,16* without modification.17* 2. Redistributions in binary form must reproduce at minimum a disclaimer18* substantially similar to the "NO WARRANTY" disclaimer below19* ("Disclaimer") and any redistribution must be conditioned upon20* including a substantially similar Disclaimer requirement for further21* binary redistribution.22* 3. Neither the names of the above-listed copyright holders nor the names23* of any contributors may be used to endorse or promote products derived24* from this software without specific prior written permission.25*26* Alternatively, this software may be distributed under the terms of the27* GNU General Public License ("GPL") version 2 as published by the Free28* Software Foundation.29*30* NO WARRANTY31* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS32* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT33* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR34* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT35* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL36* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS37* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)38* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,39* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING40* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE41* POSSIBILITY OF SUCH DAMAGES.42*/4344#include <acpi/acpi.h>45#include "accommon.h"46#include "acevents.h"4748#define _COMPONENT ACPI_EVENTS49ACPI_MODULE_NAME("evsci")5051/* Local prototypes */52static u32 ACPI_SYSTEM_XFACE acpi_ev_sci_xrupt_handler(void *context);5354/*******************************************************************************55*56* FUNCTION: acpi_ev_sci_xrupt_handler57*58* PARAMETERS: Context - Calling Context59*60* RETURN: Status code indicates whether interrupt was handled.61*62* DESCRIPTION: Interrupt handler that will figure out what function or63* control method to call to deal with a SCI.64*65******************************************************************************/6667static u32 ACPI_SYSTEM_XFACE acpi_ev_sci_xrupt_handler(void *context)68{69struct acpi_gpe_xrupt_info *gpe_xrupt_list = context;70u32 interrupt_handled = ACPI_INTERRUPT_NOT_HANDLED;7172ACPI_FUNCTION_TRACE(ev_sci_xrupt_handler);7374/*75* We are guaranteed by the ACPI CA initialization/shutdown code that76* if this interrupt handler is installed, ACPI is enabled.77*/7879/*80* Fixed Events:81* Check for and dispatch any Fixed Events that have occurred82*/83interrupt_handled |= acpi_ev_fixed_event_detect();8485/*86* General Purpose Events:87* Check for and dispatch any GPEs that have occurred88*/89interrupt_handled |= acpi_ev_gpe_detect(gpe_xrupt_list);9091return_UINT32(interrupt_handled);92}9394/*******************************************************************************95*96* FUNCTION: acpi_ev_gpe_xrupt_handler97*98* PARAMETERS: Context - Calling Context99*100* RETURN: Status code indicates whether interrupt was handled.101*102* DESCRIPTION: Handler for GPE Block Device interrupts103*104******************************************************************************/105106u32 ACPI_SYSTEM_XFACE acpi_ev_gpe_xrupt_handler(void *context)107{108struct acpi_gpe_xrupt_info *gpe_xrupt_list = context;109u32 interrupt_handled = ACPI_INTERRUPT_NOT_HANDLED;110111ACPI_FUNCTION_TRACE(ev_gpe_xrupt_handler);112113/*114* We are guaranteed by the ACPI CA initialization/shutdown code that115* if this interrupt handler is installed, ACPI is enabled.116*/117118/* GPEs: Check for and dispatch any GPEs that have occurred */119120interrupt_handled |= acpi_ev_gpe_detect(gpe_xrupt_list);121122return_UINT32(interrupt_handled);123}124125/******************************************************************************126*127* FUNCTION: acpi_ev_install_sci_handler128*129* PARAMETERS: none130*131* RETURN: Status132*133* DESCRIPTION: Installs SCI handler.134*135******************************************************************************/136137u32 acpi_ev_install_sci_handler(void)138{139u32 status = AE_OK;140141ACPI_FUNCTION_TRACE(ev_install_sci_handler);142143status =144acpi_os_install_interrupt_handler((u32) acpi_gbl_FADT.sci_interrupt,145acpi_ev_sci_xrupt_handler,146acpi_gbl_gpe_xrupt_list_head);147return_ACPI_STATUS(status);148}149150/******************************************************************************151*152* FUNCTION: acpi_ev_remove_sci_handler153*154* PARAMETERS: none155*156* RETURN: E_OK if handler uninstalled OK, E_ERROR if handler was not157* installed to begin with158*159* DESCRIPTION: Remove the SCI interrupt handler. No further SCIs will be160* taken.161*162* Note: It doesn't seem important to disable all events or set the event163* enable registers to their original values. The OS should disable164* the SCI interrupt level when the handler is removed, so no more165* events will come in.166*167******************************************************************************/168169acpi_status acpi_ev_remove_sci_handler(void)170{171acpi_status status;172173ACPI_FUNCTION_TRACE(ev_remove_sci_handler);174175/* Just let the OS remove the handler and disable the level */176177status =178acpi_os_remove_interrupt_handler((u32) acpi_gbl_FADT.sci_interrupt,179acpi_ev_sci_xrupt_handler);180181return_ACPI_STATUS(status);182}183184185