Merge by hand (conflicts in sd.c)
[linux-2.6.22.y-op.git] / drivers / acpi / events / evsci.c
blobf3123c26ae987be2e4d489268283417aa36ebbb6
1 /*******************************************************************************
3 * Module Name: evsci - System Control Interrupt configuration and
4 * legacy to ACPI mode state transition functions
6 ******************************************************************************/
8 /*
9 * Copyright (C) 2000 - 2005, R. Byron Moore
10 * All rights reserved.
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions, and the following disclaimer,
17 * without modification.
18 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19 * substantially similar to the "NO WARRANTY" disclaimer below
20 * ("Disclaimer") and any redistribution must be conditioned upon
21 * including a substantially similar Disclaimer requirement for further
22 * binary redistribution.
23 * 3. Neither the names of the above-listed copyright holders nor the names
24 * of any contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
27 * Alternatively, this software may be distributed under the terms of the
28 * GNU General Public License ("GPL") version 2 as published by the Free
29 * Software Foundation.
31 * NO WARRANTY
32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42 * POSSIBILITY OF SUCH DAMAGES.
45 #include <acpi/acpi.h>
46 #include <acpi/acevents.h>
49 #define _COMPONENT ACPI_EVENTS
50 ACPI_MODULE_NAME ("evsci")
52 /* Local prototypes */
54 static u32 ACPI_SYSTEM_XFACE
55 acpi_ev_sci_xrupt_handler (
56 void *context);
59 /*******************************************************************************
61 * FUNCTION: acpi_ev_sci_xrupt_handler
63 * PARAMETERS: Context - Calling Context
65 * RETURN: Status code indicates whether interrupt was handled.
67 * DESCRIPTION: Interrupt handler that will figure out what function or
68 * control method to call to deal with a SCI.
70 ******************************************************************************/
72 static u32 ACPI_SYSTEM_XFACE
73 acpi_ev_sci_xrupt_handler (
74 void *context)
76 struct acpi_gpe_xrupt_info *gpe_xrupt_list = context;
77 u32 interrupt_handled = ACPI_INTERRUPT_NOT_HANDLED;
80 ACPI_FUNCTION_TRACE("ev_sci_xrupt_handler");
84 * We are guaranteed by the ACPI CA initialization/shutdown code that
85 * if this interrupt handler is installed, ACPI is enabled.
89 * Fixed Events:
90 * Check for and dispatch any Fixed Events that have occurred
92 interrupt_handled |= acpi_ev_fixed_event_detect ();
95 * General Purpose Events:
96 * Check for and dispatch any GPEs that have occurred
98 interrupt_handled |= acpi_ev_gpe_detect (gpe_xrupt_list);
100 return_VALUE (interrupt_handled);
104 /*******************************************************************************
106 * FUNCTION: acpi_ev_gpe_xrupt_handler
108 * PARAMETERS: Context - Calling Context
110 * RETURN: Status code indicates whether interrupt was handled.
112 * DESCRIPTION: Handler for GPE Block Device interrupts
114 ******************************************************************************/
116 u32 ACPI_SYSTEM_XFACE
117 acpi_ev_gpe_xrupt_handler (
118 void *context)
120 struct acpi_gpe_xrupt_info *gpe_xrupt_list = context;
121 u32 interrupt_handled = ACPI_INTERRUPT_NOT_HANDLED;
124 ACPI_FUNCTION_TRACE("ev_gpe_xrupt_handler");
128 * We are guaranteed by the ACPI CA initialization/shutdown code that
129 * if this interrupt handler is installed, ACPI is enabled.
133 * GPEs:
134 * Check for and dispatch any GPEs that have occurred
136 interrupt_handled |= acpi_ev_gpe_detect (gpe_xrupt_list);
138 return_VALUE (interrupt_handled);
142 /******************************************************************************
144 * FUNCTION: acpi_ev_install_sci_handler
146 * PARAMETERS: none
148 * RETURN: Status
150 * DESCRIPTION: Installs SCI handler.
152 ******************************************************************************/
155 acpi_ev_install_sci_handler (
156 void)
158 u32 status = AE_OK;
161 ACPI_FUNCTION_TRACE ("ev_install_sci_handler");
164 status = acpi_os_install_interrupt_handler ((u32) acpi_gbl_FADT->sci_int,
165 acpi_ev_sci_xrupt_handler, acpi_gbl_gpe_xrupt_list_head);
166 return_ACPI_STATUS (status);
170 /******************************************************************************
172 * FUNCTION: acpi_ev_remove_sci_handler
174 * PARAMETERS: none
176 * RETURN: E_OK if handler uninstalled OK, E_ERROR if handler was not
177 * installed to begin with
179 * DESCRIPTION: Remove the SCI interrupt handler. No further SCIs will be
180 * taken.
182 * Note: It doesn't seem important to disable all events or set the event
183 * enable registers to their original values. The OS should disable
184 * the SCI interrupt level when the handler is removed, so no more
185 * events will come in.
187 ******************************************************************************/
189 acpi_status
190 acpi_ev_remove_sci_handler (
191 void)
193 acpi_status status;
196 ACPI_FUNCTION_TRACE ("ev_remove_sci_handler");
199 /* Just let the OS remove the handler and disable the level */
201 status = acpi_os_remove_interrupt_handler ((u32) acpi_gbl_FADT->sci_int,
202 acpi_ev_sci_xrupt_handler);
204 return_ACPI_STATUS (status);