blob: b5fc8055a473f7909a3bf7af0d3822dac20ffefc [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*******************************************************************************
2 *
3 * Module Name: evsci - System Control Interrupt configuration and
4 * legacy to ACPI mode state transition functions
5 *
6 ******************************************************************************/
7
8/*
Len Brown75a44ce2008-04-23 23:00:13 -04009 * Copyright (C) 2000 - 2008, Intel Corp.
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 * All rights reserved.
11 *
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.
26 *
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.
30 *
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.
43 */
44
45#include <acpi/acpi.h>
46#include <acpi/acevents.h>
47
Linus Torvalds1da177e2005-04-16 15:20:36 -070048#define _COMPONENT ACPI_EVENTS
Len Brown4be44fc2005-08-05 00:44:28 -040049ACPI_MODULE_NAME("evsci")
Linus Torvalds1da177e2005-04-16 15:20:36 -070050
Robert Moore44f6c012005-04-18 22:49:35 -040051/* Local prototypes */
Len Brown4be44fc2005-08-05 00:44:28 -040052static u32 ACPI_SYSTEM_XFACE acpi_ev_sci_xrupt_handler(void *context);
Linus Torvalds1da177e2005-04-16 15:20:36 -070053
54/*******************************************************************************
55 *
56 * FUNCTION: acpi_ev_sci_xrupt_handler
57 *
58 * PARAMETERS: Context - Calling Context
59 *
60 * RETURN: Status code indicates whether interrupt was handled.
61 *
62 * DESCRIPTION: Interrupt handler that will figure out what function or
63 * control method to call to deal with a SCI.
64 *
65 ******************************************************************************/
66
Len Brown4be44fc2005-08-05 00:44:28 -040067static u32 ACPI_SYSTEM_XFACE acpi_ev_sci_xrupt_handler(void *context)
Linus Torvalds1da177e2005-04-16 15:20:36 -070068{
Len Brown4be44fc2005-08-05 00:44:28 -040069 struct acpi_gpe_xrupt_info *gpe_xrupt_list = context;
70 u32 interrupt_handled = ACPI_INTERRUPT_NOT_HANDLED;
Linus Torvalds1da177e2005-04-16 15:20:36 -070071
Bob Mooreb229cf92006-04-21 17:15:00 -040072 ACPI_FUNCTION_TRACE(ev_sci_xrupt_handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -070073
Linus Torvalds1da177e2005-04-16 15:20:36 -070074 /*
75 * We are guaranteed by the ACPI CA initialization/shutdown code that
76 * if this interrupt handler is installed, ACPI is enabled.
77 */
78
79 /*
80 * Fixed Events:
81 * Check for and dispatch any Fixed Events that have occurred
82 */
Len Brown4be44fc2005-08-05 00:44:28 -040083 interrupt_handled |= acpi_ev_fixed_event_detect();
Linus Torvalds1da177e2005-04-16 15:20:36 -070084
85 /*
86 * General Purpose Events:
87 * Check for and dispatch any GPEs that have occurred
88 */
Len Brown4be44fc2005-08-05 00:44:28 -040089 interrupt_handled |= acpi_ev_gpe_detect(gpe_xrupt_list);
Linus Torvalds1da177e2005-04-16 15:20:36 -070090
Bob Moore50eca3e2005-09-30 19:03:00 -040091 return_UINT32(interrupt_handled);
Linus Torvalds1da177e2005-04-16 15:20:36 -070092}
93
Linus Torvalds1da177e2005-04-16 15:20:36 -070094/*******************************************************************************
95 *
96 * FUNCTION: acpi_ev_gpe_xrupt_handler
97 *
98 * PARAMETERS: Context - Calling Context
99 *
100 * RETURN: Status code indicates whether interrupt was handled.
101 *
102 * DESCRIPTION: Handler for GPE Block Device interrupts
103 *
104 ******************************************************************************/
105
Len Brown4be44fc2005-08-05 00:44:28 -0400106u32 ACPI_SYSTEM_XFACE acpi_ev_gpe_xrupt_handler(void *context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107{
Len Brown4be44fc2005-08-05 00:44:28 -0400108 struct acpi_gpe_xrupt_info *gpe_xrupt_list = context;
109 u32 interrupt_handled = ACPI_INTERRUPT_NOT_HANDLED;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110
Bob Mooreb229cf92006-04-21 17:15:00 -0400111 ACPI_FUNCTION_TRACE(ev_gpe_xrupt_handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113 /*
114 * We are guaranteed by the ACPI CA initialization/shutdown code that
115 * if this interrupt handler is installed, ACPI is enabled.
116 */
117
Bob Moore9f15fc62008-11-12 16:01:56 +0800118 /* GPEs: Check for and dispatch any GPEs that have occurred */
119
Len Brown4be44fc2005-08-05 00:44:28 -0400120 interrupt_handled |= acpi_ev_gpe_detect(gpe_xrupt_list);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121
Bob Moore50eca3e2005-09-30 19:03:00 -0400122 return_UINT32(interrupt_handled);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123}
124
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125/******************************************************************************
126 *
127 * FUNCTION: acpi_ev_install_sci_handler
128 *
129 * PARAMETERS: none
130 *
131 * RETURN: Status
132 *
133 * DESCRIPTION: Installs SCI handler.
134 *
135 ******************************************************************************/
136
Len Brown4be44fc2005-08-05 00:44:28 -0400137u32 acpi_ev_install_sci_handler(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138{
Len Brown4be44fc2005-08-05 00:44:28 -0400139 u32 status = AE_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140
Bob Mooreb229cf92006-04-21 17:15:00 -0400141 ACPI_FUNCTION_TRACE(ev_install_sci_handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142
Bob Mooref3d2e782007-02-02 19:48:18 +0300143 status =
144 acpi_os_install_interrupt_handler((u32) acpi_gbl_FADT.sci_interrupt,
145 acpi_ev_sci_xrupt_handler,
146 acpi_gbl_gpe_xrupt_list_head);
Len Brown4be44fc2005-08-05 00:44:28 -0400147 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148}
149
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150/******************************************************************************
151 *
152 * FUNCTION: acpi_ev_remove_sci_handler
153 *
154 * PARAMETERS: none
155 *
156 * RETURN: E_OK if handler uninstalled OK, E_ERROR if handler was not
157 * installed to begin with
158 *
Bob Moore9f15fc62008-11-12 16:01:56 +0800159 * DESCRIPTION: Remove the SCI interrupt handler. No further SCIs will be
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160 * taken.
161 *
162 * Note: It doesn't seem important to disable all events or set the event
Bob Moore9f15fc62008-11-12 16:01:56 +0800163 * enable registers to their original values. The OS should disable
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164 * the SCI interrupt level when the handler is removed, so no more
165 * events will come in.
166 *
167 ******************************************************************************/
168
Len Brown4be44fc2005-08-05 00:44:28 -0400169acpi_status acpi_ev_remove_sci_handler(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170{
Len Brown4be44fc2005-08-05 00:44:28 -0400171 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172
Bob Mooreb229cf92006-04-21 17:15:00 -0400173 ACPI_FUNCTION_TRACE(ev_remove_sci_handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174
175 /* Just let the OS remove the handler and disable the level */
176
Bob Mooref3d2e782007-02-02 19:48:18 +0300177 status =
178 acpi_os_remove_interrupt_handler((u32) acpi_gbl_FADT.sci_interrupt,
179 acpi_ev_sci_xrupt_handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180
Len Brown4be44fc2005-08-05 00:44:28 -0400181 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182}