Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Module Name: evxfevnt - External Interfaces, ACPI event disable/enable |
| 4 | * |
| 5 | *****************************************************************************/ |
| 6 | |
| 7 | /* |
Bob Moore | c8100dc | 2016-01-15 08:17:03 +0800 | [diff] [blame] | 8 | * Copyright (C) 2000 - 2016, Intel Corp. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | * All rights reserved. |
| 10 | * |
| 11 | * Redistribution and use in source and binary forms, with or without |
| 12 | * modification, are permitted provided that the following conditions |
| 13 | * are met: |
| 14 | * 1. Redistributions of source code must retain the above copyright |
| 15 | * notice, this list of conditions, and the following disclaimer, |
| 16 | * without modification. |
| 17 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer |
| 18 | * substantially similar to the "NO WARRANTY" disclaimer below |
| 19 | * ("Disclaimer") and any redistribution must be conditioned upon |
| 20 | * including a substantially similar Disclaimer requirement for further |
| 21 | * binary redistribution. |
| 22 | * 3. Neither the names of the above-listed copyright holders nor the names |
| 23 | * of any contributors may be used to endorse or promote products derived |
| 24 | * from this software without specific prior written permission. |
| 25 | * |
| 26 | * Alternatively, this software may be distributed under the terms of the |
| 27 | * GNU General Public License ("GPL") version 2 as published by the Free |
| 28 | * Software Foundation. |
| 29 | * |
| 30 | * NO WARRANTY |
| 31 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 32 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 33 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR |
| 34 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 35 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 36 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 37 | * 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) ARISING |
| 40 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 41 | * POSSIBILITY OF SUCH DAMAGES. |
| 42 | */ |
| 43 | |
Lv Zheng | 839e928 | 2013-10-29 09:29:51 +0800 | [diff] [blame] | 44 | #define EXPORT_ACPI_INTERFACES |
| 45 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | #include <acpi/acpi.h> |
Len Brown | e2f7a77 | 2009-01-09 00:30:03 -0500 | [diff] [blame] | 47 | #include "accommon.h" |
Len Brown | e2f7a77 | 2009-01-09 00:30:03 -0500 | [diff] [blame] | 48 | #include "actables.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | |
| 50 | #define _COMPONENT ACPI_EVENTS |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 51 | ACPI_MODULE_NAME("evxfevnt") |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | |
Bob Moore | 33620c5 | 2012-02-14 18:14:27 +0800 | [diff] [blame] | 53 | #if (!ACPI_REDUCED_HARDWARE) /* Entire module */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | /******************************************************************************* |
| 55 | * |
| 56 | * FUNCTION: acpi_enable |
| 57 | * |
| 58 | * PARAMETERS: None |
| 59 | * |
| 60 | * RETURN: Status |
| 61 | * |
| 62 | * DESCRIPTION: Transfers the system into ACPI mode. |
| 63 | * |
| 64 | ******************************************************************************/ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 65 | acpi_status acpi_enable(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | { |
Len Brown | b430acb | 2010-05-06 17:41:08 -0400 | [diff] [blame] | 67 | acpi_status status; |
Len Brown | 3d69583 | 2010-06-28 20:55:01 -0400 | [diff] [blame] | 68 | int retry; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 70 | ACPI_FUNCTION_TRACE(acpi_enable); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | |
Bob Moore | c857303 | 2007-02-02 19:48:23 +0300 | [diff] [blame] | 72 | /* ACPI tables must be present */ |
| 73 | |
Lv Zheng | 62fcce9 | 2015-10-14 13:53:57 +0800 | [diff] [blame] | 74 | if (acpi_gbl_fadt_index == ACPI_INVALID_TABLE_INDEX) { |
Bob Moore | c857303 | 2007-02-02 19:48:23 +0300 | [diff] [blame] | 75 | return_ACPI_STATUS(AE_NO_ACPI_TABLES); |
| 76 | } |
| 77 | |
Bob Moore | c39660b | 2013-03-08 09:22:14 +0000 | [diff] [blame] | 78 | /* If the Hardware Reduced flag is set, machine is always in acpi mode */ |
| 79 | |
| 80 | if (acpi_gbl_reduced_hardware) { |
| 81 | return_ACPI_STATUS(AE_OK); |
| 82 | } |
| 83 | |
Bob Moore | c857303 | 2007-02-02 19:48:23 +0300 | [diff] [blame] | 84 | /* Check current mode */ |
| 85 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | if (acpi_hw_get_mode() == ACPI_SYS_MODE_ACPI) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 87 | ACPI_DEBUG_PRINT((ACPI_DB_INIT, |
| 88 | "System is already in ACPI mode\n")); |
Len Brown | b430acb | 2010-05-06 17:41:08 -0400 | [diff] [blame] | 89 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | } |
| 91 | |
Len Brown | b430acb | 2010-05-06 17:41:08 -0400 | [diff] [blame] | 92 | /* Transition to ACPI mode */ |
| 93 | |
| 94 | status = acpi_hw_set_mode(ACPI_SYS_MODE_ACPI); |
| 95 | if (ACPI_FAILURE(status)) { |
| 96 | ACPI_ERROR((AE_INFO, |
| 97 | "Could not transition to ACPI mode")); |
| 98 | return_ACPI_STATUS(status); |
| 99 | } |
| 100 | |
| 101 | /* Sanity check that transition succeeded */ |
| 102 | |
Len Brown | 3d69583 | 2010-06-28 20:55:01 -0400 | [diff] [blame] | 103 | for (retry = 0; retry < 30000; ++retry) { |
| 104 | if (acpi_hw_get_mode() == ACPI_SYS_MODE_ACPI) { |
| 105 | if (retry != 0) |
| 106 | ACPI_WARNING((AE_INFO, |
| 107 | "Platform took > %d00 usec to enter ACPI mode", retry)); |
| 108 | return_ACPI_STATUS(AE_OK); |
| 109 | } |
| 110 | acpi_os_stall(100); /* 100 usec */ |
Len Brown | b430acb | 2010-05-06 17:41:08 -0400 | [diff] [blame] | 111 | } |
| 112 | |
Len Brown | 3d69583 | 2010-06-28 20:55:01 -0400 | [diff] [blame] | 113 | ACPI_ERROR((AE_INFO, "Hardware did not enter ACPI mode")); |
| 114 | return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | } |
| 116 | |
Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 117 | ACPI_EXPORT_SYMBOL(acpi_enable) |
| 118 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | /******************************************************************************* |
| 120 | * |
| 121 | * FUNCTION: acpi_disable |
| 122 | * |
| 123 | * PARAMETERS: None |
| 124 | * |
| 125 | * RETURN: Status |
| 126 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 127 | * DESCRIPTION: Transfers the system into LEGACY (non-ACPI) mode. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | * |
| 129 | ******************************************************************************/ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 130 | acpi_status acpi_disable(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 132 | acpi_status status = AE_OK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 134 | ACPI_FUNCTION_TRACE(acpi_disable); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | |
Bob Moore | c39660b | 2013-03-08 09:22:14 +0000 | [diff] [blame] | 136 | /* If the Hardware Reduced flag is set, machine is always in acpi mode */ |
| 137 | |
| 138 | if (acpi_gbl_reduced_hardware) { |
| 139 | return_ACPI_STATUS(AE_OK); |
| 140 | } |
| 141 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 142 | if (acpi_hw_get_mode() == ACPI_SYS_MODE_LEGACY) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 143 | ACPI_DEBUG_PRINT((ACPI_DB_INIT, |
| 144 | "System is already in legacy (non-ACPI) mode\n")); |
| 145 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | /* Transition to LEGACY mode */ |
| 147 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 148 | status = acpi_hw_set_mode(ACPI_SYS_MODE_LEGACY); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 149 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 150 | if (ACPI_FAILURE(status)) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 151 | ACPI_ERROR((AE_INFO, |
| 152 | "Could not exit ACPI mode to legacy mode")); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 153 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | } |
| 155 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 156 | ACPI_DEBUG_PRINT((ACPI_DB_INIT, "ACPI mode disabled\n")); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | } |
| 158 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 159 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | } |
| 161 | |
Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 162 | ACPI_EXPORT_SYMBOL(acpi_disable) |
| 163 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | /******************************************************************************* |
| 165 | * |
| 166 | * FUNCTION: acpi_enable_event |
| 167 | * |
Bob Moore | ba494be | 2012-07-12 09:40:10 +0800 | [diff] [blame] | 168 | * PARAMETERS: event - The fixed eventto be enabled |
| 169 | * flags - Reserved |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 170 | * |
| 171 | * RETURN: Status |
| 172 | * |
| 173 | * DESCRIPTION: Enable an ACPI event (fixed) |
| 174 | * |
| 175 | ******************************************************************************/ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 176 | acpi_status acpi_enable_event(u32 event, u32 flags) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 177 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 178 | acpi_status status = AE_OK; |
| 179 | u32 value; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 181 | ACPI_FUNCTION_TRACE(acpi_enable_event); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | |
| 183 | /* Decode the Fixed Event */ |
| 184 | |
| 185 | if (event > ACPI_EVENT_MAX) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 186 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 | } |
| 188 | |
| 189 | /* |
Bob Moore | 9f15fc6 | 2008-11-12 16:01:56 +0800 | [diff] [blame] | 190 | * Enable the requested fixed event (by writing a one to the enable |
| 191 | * register bit) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 192 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 193 | status = |
Bob Moore | 50ffba1 | 2009-02-23 15:02:07 +0800 | [diff] [blame] | 194 | acpi_write_bit_register(acpi_gbl_fixed_event_info[event]. |
Bob Moore | 768aaaf | 2009-03-06 09:49:25 +0800 | [diff] [blame] | 195 | enable_register_id, ACPI_ENABLE_EVENT); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 196 | if (ACPI_FAILURE(status)) { |
| 197 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | } |
| 199 | |
| 200 | /* Make sure that the hardware responded */ |
| 201 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 202 | status = |
Bob Moore | 50ffba1 | 2009-02-23 15:02:07 +0800 | [diff] [blame] | 203 | acpi_read_bit_register(acpi_gbl_fixed_event_info[event]. |
| 204 | enable_register_id, &value); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 205 | if (ACPI_FAILURE(status)) { |
| 206 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 207 | } |
| 208 | |
| 209 | if (value != 1) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 210 | ACPI_ERROR((AE_INFO, |
| 211 | "Could not enable %s event", |
| 212 | acpi_ut_get_event_name(event))); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 213 | return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 214 | } |
| 215 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 216 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 218 | |
Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 219 | ACPI_EXPORT_SYMBOL(acpi_enable_event) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 220 | |
| 221 | /******************************************************************************* |
| 222 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 223 | * FUNCTION: acpi_disable_event |
| 224 | * |
Lv Zheng | 75c8044 | 2012-12-19 05:36:49 +0000 | [diff] [blame] | 225 | * PARAMETERS: event - The fixed event to be disabled |
| 226 | * flags - Reserved |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | * |
| 228 | * RETURN: Status |
| 229 | * |
| 230 | * DESCRIPTION: Disable an ACPI event (fixed) |
| 231 | * |
| 232 | ******************************************************************************/ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 233 | acpi_status acpi_disable_event(u32 event, u32 flags) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 234 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 235 | acpi_status status = AE_OK; |
| 236 | u32 value; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 238 | ACPI_FUNCTION_TRACE(acpi_disable_event); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 239 | |
| 240 | /* Decode the Fixed Event */ |
| 241 | |
| 242 | if (event > ACPI_EVENT_MAX) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 243 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 244 | } |
| 245 | |
| 246 | /* |
Bob Moore | 9f15fc6 | 2008-11-12 16:01:56 +0800 | [diff] [blame] | 247 | * Disable the requested fixed event (by writing a zero to the enable |
| 248 | * register bit) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 249 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 250 | status = |
Bob Moore | 50ffba1 | 2009-02-23 15:02:07 +0800 | [diff] [blame] | 251 | acpi_write_bit_register(acpi_gbl_fixed_event_info[event]. |
Bob Moore | 768aaaf | 2009-03-06 09:49:25 +0800 | [diff] [blame] | 252 | enable_register_id, ACPI_DISABLE_EVENT); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 253 | if (ACPI_FAILURE(status)) { |
| 254 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 255 | } |
| 256 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 257 | status = |
Bob Moore | 50ffba1 | 2009-02-23 15:02:07 +0800 | [diff] [blame] | 258 | acpi_read_bit_register(acpi_gbl_fixed_event_info[event]. |
| 259 | enable_register_id, &value); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 260 | if (ACPI_FAILURE(status)) { |
| 261 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 262 | } |
| 263 | |
| 264 | if (value != 0) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 265 | ACPI_ERROR((AE_INFO, |
| 266 | "Could not disable %s events", |
| 267 | acpi_ut_get_event_name(event))); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 268 | return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | } |
| 270 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 271 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 273 | |
Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 274 | ACPI_EXPORT_SYMBOL(acpi_disable_event) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | |
| 276 | /******************************************************************************* |
| 277 | * |
| 278 | * FUNCTION: acpi_clear_event |
| 279 | * |
Bob Moore | ba494be | 2012-07-12 09:40:10 +0800 | [diff] [blame] | 280 | * PARAMETERS: event - The fixed event to be cleared |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 281 | * |
| 282 | * RETURN: Status |
| 283 | * |
| 284 | * DESCRIPTION: Clear an ACPI event (fixed) |
| 285 | * |
| 286 | ******************************************************************************/ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 287 | acpi_status acpi_clear_event(u32 event) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 289 | acpi_status status = AE_OK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 290 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 291 | ACPI_FUNCTION_TRACE(acpi_clear_event); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 292 | |
| 293 | /* Decode the Fixed Event */ |
| 294 | |
| 295 | if (event > ACPI_EVENT_MAX) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 296 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | } |
| 298 | |
| 299 | /* |
Bob Moore | 9f15fc6 | 2008-11-12 16:01:56 +0800 | [diff] [blame] | 300 | * Clear the requested fixed event (By writing a one to the status |
| 301 | * register bit) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 302 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 303 | status = |
Bob Moore | 50ffba1 | 2009-02-23 15:02:07 +0800 | [diff] [blame] | 304 | acpi_write_bit_register(acpi_gbl_fixed_event_info[event]. |
Bob Moore | 768aaaf | 2009-03-06 09:49:25 +0800 | [diff] [blame] | 305 | status_register_id, ACPI_CLEAR_STATUS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 307 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 309 | |
Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 310 | ACPI_EXPORT_SYMBOL(acpi_clear_event) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 | |
| 312 | /******************************************************************************* |
| 313 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | * FUNCTION: acpi_get_event_status |
| 315 | * |
Bob Moore | ba494be | 2012-07-12 09:40:10 +0800 | [diff] [blame] | 316 | * PARAMETERS: event - The fixed event |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 317 | * event_status - Where the current status of the event will |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 318 | * be returned |
| 319 | * |
| 320 | * RETURN: Status |
| 321 | * |
| 322 | * DESCRIPTION: Obtains and returns the current status of the event |
| 323 | * |
| 324 | ******************************************************************************/ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 325 | acpi_status acpi_get_event_status(u32 event, acpi_event_status * event_status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 326 | { |
Lv Zheng | a08f813 | 2014-10-10 10:39:57 +0800 | [diff] [blame] | 327 | acpi_status status; |
| 328 | acpi_event_status local_event_status = 0; |
| 329 | u32 in_byte; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 330 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 331 | ACPI_FUNCTION_TRACE(acpi_get_event_status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 332 | |
| 333 | if (!event_status) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 334 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | } |
| 336 | |
| 337 | /* Decode the Fixed Event */ |
| 338 | |
| 339 | if (event > ACPI_EVENT_MAX) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 340 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | } |
| 342 | |
Lv Zheng | a08f813 | 2014-10-10 10:39:57 +0800 | [diff] [blame] | 343 | /* Fixed event currently can be dispatched? */ |
| 344 | |
| 345 | if (acpi_gbl_fixed_event_handlers[event].handler) { |
Lv Zheng | 2f85723 | 2014-10-10 10:40:05 +0800 | [diff] [blame] | 346 | local_event_status |= ACPI_EVENT_FLAG_HAS_HANDLER; |
Lv Zheng | a08f813 | 2014-10-10 10:39:57 +0800 | [diff] [blame] | 347 | } |
| 348 | |
| 349 | /* Fixed event currently enabled? */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 350 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 351 | status = |
Bob Moore | 50ffba1 | 2009-02-23 15:02:07 +0800 | [diff] [blame] | 352 | acpi_read_bit_register(acpi_gbl_fixed_event_info[event]. |
Lv Zheng | a08f813 | 2014-10-10 10:39:57 +0800 | [diff] [blame] | 353 | enable_register_id, &in_byte); |
| 354 | if (ACPI_FAILURE(status)) { |
Zhang Rui | 71b58cb | 2008-06-20 09:42:47 +0800 | [diff] [blame] | 355 | return_ACPI_STATUS(status); |
Lv Zheng | a08f813 | 2014-10-10 10:39:57 +0800 | [diff] [blame] | 356 | } |
Zhang Rui | 71b58cb | 2008-06-20 09:42:47 +0800 | [diff] [blame] | 357 | |
Lv Zheng | a08f813 | 2014-10-10 10:39:57 +0800 | [diff] [blame] | 358 | if (in_byte) { |
Lv Zheng | 09af8e8 | 2015-04-13 11:49:13 +0800 | [diff] [blame] | 359 | local_event_status |= |
| 360 | (ACPI_EVENT_FLAG_ENABLED | ACPI_EVENT_FLAG_ENABLE_SET); |
Lv Zheng | a08f813 | 2014-10-10 10:39:57 +0800 | [diff] [blame] | 361 | } |
| 362 | |
| 363 | /* Fixed event currently active? */ |
Zhang Rui | 71b58cb | 2008-06-20 09:42:47 +0800 | [diff] [blame] | 364 | |
| 365 | status = |
Bob Moore | 50ffba1 | 2009-02-23 15:02:07 +0800 | [diff] [blame] | 366 | acpi_read_bit_register(acpi_gbl_fixed_event_info[event]. |
Lv Zheng | a08f813 | 2014-10-10 10:39:57 +0800 | [diff] [blame] | 367 | status_register_id, &in_byte); |
| 368 | if (ACPI_FAILURE(status)) { |
Zhang Rui | 71b58cb | 2008-06-20 09:42:47 +0800 | [diff] [blame] | 369 | return_ACPI_STATUS(status); |
Lv Zheng | a08f813 | 2014-10-10 10:39:57 +0800 | [diff] [blame] | 370 | } |
Zhang Rui | 71b58cb | 2008-06-20 09:42:47 +0800 | [diff] [blame] | 371 | |
Lv Zheng | a08f813 | 2014-10-10 10:39:57 +0800 | [diff] [blame] | 372 | if (in_byte) { |
Lv Zheng | 09af8e8 | 2015-04-13 11:49:13 +0800 | [diff] [blame] | 373 | local_event_status |= ACPI_EVENT_FLAG_STATUS_SET; |
Lv Zheng | a08f813 | 2014-10-10 10:39:57 +0800 | [diff] [blame] | 374 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 375 | |
Lv Zheng | a08f813 | 2014-10-10 10:39:57 +0800 | [diff] [blame] | 376 | (*event_status) = local_event_status; |
| 377 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 378 | } |
| 379 | |
Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 380 | ACPI_EXPORT_SYMBOL(acpi_get_event_status) |
Bob Moore | 33620c5 | 2012-02-14 18:14:27 +0800 | [diff] [blame] | 381 | #endif /* !ACPI_REDUCED_HARDWARE */ |