195b482a8SLen Brown /******************************************************************************* 295b482a8SLen Brown * 395b482a8SLen Brown * Module Name: evsci - System Control Interrupt configuration and 495b482a8SLen Brown * legacy to ACPI mode state transition functions 595b482a8SLen Brown * 695b482a8SLen Brown ******************************************************************************/ 795b482a8SLen Brown 895b482a8SLen Brown /* 977848130SBob Moore * Copyright (C) 2000 - 2012, Intel Corp. 1095b482a8SLen Brown * All rights reserved. 1195b482a8SLen Brown * 1295b482a8SLen Brown * Redistribution and use in source and binary forms, with or without 1395b482a8SLen Brown * modification, are permitted provided that the following conditions 1495b482a8SLen Brown * are met: 1595b482a8SLen Brown * 1. Redistributions of source code must retain the above copyright 1695b482a8SLen Brown * notice, this list of conditions, and the following disclaimer, 1795b482a8SLen Brown * without modification. 1895b482a8SLen Brown * 2. Redistributions in binary form must reproduce at minimum a disclaimer 1995b482a8SLen Brown * substantially similar to the "NO WARRANTY" disclaimer below 2095b482a8SLen Brown * ("Disclaimer") and any redistribution must be conditioned upon 2195b482a8SLen Brown * including a substantially similar Disclaimer requirement for further 2295b482a8SLen Brown * binary redistribution. 2395b482a8SLen Brown * 3. Neither the names of the above-listed copyright holders nor the names 2495b482a8SLen Brown * of any contributors may be used to endorse or promote products derived 2595b482a8SLen Brown * from this software without specific prior written permission. 2695b482a8SLen Brown * 2795b482a8SLen Brown * Alternatively, this software may be distributed under the terms of the 2895b482a8SLen Brown * GNU General Public License ("GPL") version 2 as published by the Free 2995b482a8SLen Brown * Software Foundation. 3095b482a8SLen Brown * 3195b482a8SLen Brown * NO WARRANTY 3295b482a8SLen Brown * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 3395b482a8SLen Brown * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 3495b482a8SLen Brown * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 3595b482a8SLen Brown * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 3695b482a8SLen Brown * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 3795b482a8SLen Brown * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 3895b482a8SLen Brown * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3995b482a8SLen Brown * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 4095b482a8SLen Brown * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 4195b482a8SLen Brown * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 4295b482a8SLen Brown * POSSIBILITY OF SUCH DAMAGES. 4395b482a8SLen Brown */ 4495b482a8SLen Brown 4595b482a8SLen Brown #include <acpi/acpi.h> 46e2f7a777SLen Brown #include "accommon.h" 47e2f7a777SLen Brown #include "acevents.h" 4895b482a8SLen Brown 4995b482a8SLen Brown #define _COMPONENT ACPI_EVENTS 5095b482a8SLen Brown ACPI_MODULE_NAME("evsci") 5133620c54SBob Moore #if (!ACPI_REDUCED_HARDWARE) /* Entire module */ 5295b482a8SLen Brown /* Local prototypes */ 5395b482a8SLen Brown static u32 ACPI_SYSTEM_XFACE acpi_ev_sci_xrupt_handler(void *context); 5495b482a8SLen Brown 5595b482a8SLen Brown /******************************************************************************* 5695b482a8SLen Brown * 5795b482a8SLen Brown * FUNCTION: acpi_ev_sci_xrupt_handler 5895b482a8SLen Brown * 59*ba494beeSBob Moore * PARAMETERS: context - Calling Context 6095b482a8SLen Brown * 6195b482a8SLen Brown * RETURN: Status code indicates whether interrupt was handled. 6295b482a8SLen Brown * 6395b482a8SLen Brown * DESCRIPTION: Interrupt handler that will figure out what function or 6495b482a8SLen Brown * control method to call to deal with a SCI. 6595b482a8SLen Brown * 6695b482a8SLen Brown ******************************************************************************/ 6795b482a8SLen Brown 6895b482a8SLen Brown static u32 ACPI_SYSTEM_XFACE acpi_ev_sci_xrupt_handler(void *context) 6995b482a8SLen Brown { 7095b482a8SLen Brown struct acpi_gpe_xrupt_info *gpe_xrupt_list = context; 7195b482a8SLen Brown u32 interrupt_handled = ACPI_INTERRUPT_NOT_HANDLED; 7295b482a8SLen Brown 7395b482a8SLen Brown ACPI_FUNCTION_TRACE(ev_sci_xrupt_handler); 7495b482a8SLen Brown 7595b482a8SLen Brown /* 7695b482a8SLen Brown * We are guaranteed by the ACPI CA initialization/shutdown code that 7795b482a8SLen Brown * if this interrupt handler is installed, ACPI is enabled. 7895b482a8SLen Brown */ 7995b482a8SLen Brown 8095b482a8SLen Brown /* 8195b482a8SLen Brown * Fixed Events: 8295b482a8SLen Brown * Check for and dispatch any Fixed Events that have occurred 8395b482a8SLen Brown */ 8495b482a8SLen Brown interrupt_handled |= acpi_ev_fixed_event_detect(); 8595b482a8SLen Brown 8695b482a8SLen Brown /* 8795b482a8SLen Brown * General Purpose Events: 8895b482a8SLen Brown * Check for and dispatch any GPEs that have occurred 8995b482a8SLen Brown */ 9095b482a8SLen Brown interrupt_handled |= acpi_ev_gpe_detect(gpe_xrupt_list); 9195b482a8SLen Brown 9295b482a8SLen Brown return_UINT32(interrupt_handled); 9395b482a8SLen Brown } 9495b482a8SLen Brown 9595b482a8SLen Brown /******************************************************************************* 9695b482a8SLen Brown * 9795b482a8SLen Brown * FUNCTION: acpi_ev_gpe_xrupt_handler 9895b482a8SLen Brown * 99*ba494beeSBob Moore * PARAMETERS: context - Calling Context 10095b482a8SLen Brown * 10195b482a8SLen Brown * RETURN: Status code indicates whether interrupt was handled. 10295b482a8SLen Brown * 10395b482a8SLen Brown * DESCRIPTION: Handler for GPE Block Device interrupts 10495b482a8SLen Brown * 10595b482a8SLen Brown ******************************************************************************/ 10695b482a8SLen Brown 10795b482a8SLen Brown u32 ACPI_SYSTEM_XFACE acpi_ev_gpe_xrupt_handler(void *context) 10895b482a8SLen Brown { 10995b482a8SLen Brown struct acpi_gpe_xrupt_info *gpe_xrupt_list = context; 11095b482a8SLen Brown u32 interrupt_handled = ACPI_INTERRUPT_NOT_HANDLED; 11195b482a8SLen Brown 11295b482a8SLen Brown ACPI_FUNCTION_TRACE(ev_gpe_xrupt_handler); 11395b482a8SLen Brown 11495b482a8SLen Brown /* 11595b482a8SLen Brown * We are guaranteed by the ACPI CA initialization/shutdown code that 11695b482a8SLen Brown * if this interrupt handler is installed, ACPI is enabled. 11795b482a8SLen Brown */ 11895b482a8SLen Brown 11995b482a8SLen Brown /* GPEs: Check for and dispatch any GPEs that have occurred */ 12095b482a8SLen Brown 12195b482a8SLen Brown interrupt_handled |= acpi_ev_gpe_detect(gpe_xrupt_list); 12295b482a8SLen Brown 12395b482a8SLen Brown return_UINT32(interrupt_handled); 12495b482a8SLen Brown } 12595b482a8SLen Brown 12695b482a8SLen Brown /****************************************************************************** 12795b482a8SLen Brown * 12895b482a8SLen Brown * FUNCTION: acpi_ev_install_sci_handler 12995b482a8SLen Brown * 13095b482a8SLen Brown * PARAMETERS: none 13195b482a8SLen Brown * 13295b482a8SLen Brown * RETURN: Status 13395b482a8SLen Brown * 13495b482a8SLen Brown * DESCRIPTION: Installs SCI handler. 13595b482a8SLen Brown * 13695b482a8SLen Brown ******************************************************************************/ 13795b482a8SLen Brown 13895b482a8SLen Brown u32 acpi_ev_install_sci_handler(void) 13995b482a8SLen Brown { 14095b482a8SLen Brown u32 status = AE_OK; 14195b482a8SLen Brown 14295b482a8SLen Brown ACPI_FUNCTION_TRACE(ev_install_sci_handler); 14395b482a8SLen Brown 14495b482a8SLen Brown status = 14595b482a8SLen Brown acpi_os_install_interrupt_handler((u32) acpi_gbl_FADT.sci_interrupt, 14695b482a8SLen Brown acpi_ev_sci_xrupt_handler, 14795b482a8SLen Brown acpi_gbl_gpe_xrupt_list_head); 14895b482a8SLen Brown return_ACPI_STATUS(status); 14995b482a8SLen Brown } 15095b482a8SLen Brown 15195b482a8SLen Brown /****************************************************************************** 15295b482a8SLen Brown * 15395b482a8SLen Brown * FUNCTION: acpi_ev_remove_sci_handler 15495b482a8SLen Brown * 15595b482a8SLen Brown * PARAMETERS: none 15695b482a8SLen Brown * 15795b482a8SLen Brown * RETURN: E_OK if handler uninstalled OK, E_ERROR if handler was not 15895b482a8SLen Brown * installed to begin with 15995b482a8SLen Brown * 16095b482a8SLen Brown * DESCRIPTION: Remove the SCI interrupt handler. No further SCIs will be 16195b482a8SLen Brown * taken. 16295b482a8SLen Brown * 16395b482a8SLen Brown * Note: It doesn't seem important to disable all events or set the event 16495b482a8SLen Brown * enable registers to their original values. The OS should disable 16595b482a8SLen Brown * the SCI interrupt level when the handler is removed, so no more 16695b482a8SLen Brown * events will come in. 16795b482a8SLen Brown * 16895b482a8SLen Brown ******************************************************************************/ 16995b482a8SLen Brown 17095b482a8SLen Brown acpi_status acpi_ev_remove_sci_handler(void) 17195b482a8SLen Brown { 17295b482a8SLen Brown acpi_status status; 17395b482a8SLen Brown 17495b482a8SLen Brown ACPI_FUNCTION_TRACE(ev_remove_sci_handler); 17595b482a8SLen Brown 17695b482a8SLen Brown /* Just let the OS remove the handler and disable the level */ 17795b482a8SLen Brown 17895b482a8SLen Brown status = 17995b482a8SLen Brown acpi_os_remove_interrupt_handler((u32) acpi_gbl_FADT.sci_interrupt, 18095b482a8SLen Brown acpi_ev_sci_xrupt_handler); 18195b482a8SLen Brown 18295b482a8SLen Brown return_ACPI_STATUS(status); 18395b482a8SLen Brown } 18433620c54SBob Moore 18533620c54SBob Moore #endif /* !ACPI_REDUCED_HARDWARE */ 186