blob: 9cb60fdc77e5061d3032eb46be40d08da9a7301b [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/******************************************************************************
2 *
Bob Moore42f8fb72013-01-11 13:08:51 +01003 * Module Name: evregion - Operation Region support
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 *
5 *****************************************************************************/
6
7/*
Bob Moorec8100dc2016-01-15 08:17:03 +08008 * Copyright (C) 2000 - 2016, Intel Corp.
Linus Torvalds1da177e2005-04-16 15:20:36 -07009 * 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
Linus Torvalds1da177e2005-04-16 15:20:36 -070044#include <acpi/acpi.h>
Len Browne2f7a772009-01-09 00:30:03 -050045#include "accommon.h"
46#include "acevents.h"
47#include "acnamesp.h"
48#include "acinterp.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
50#define _COMPONENT ACPI_EVENTS
Len Brown4be44fc2005-08-05 00:44:28 -040051ACPI_MODULE_NAME("evregion")
Linus Torvalds1da177e2005-04-16 15:20:36 -070052
Bob Moore42f8fb72013-01-11 13:08:51 +010053extern u8 acpi_gbl_default_address_spaces[];
54
Robert Moore44f6c012005-04-18 22:49:35 -040055/* Local prototypes */
Lin Ming74d3ec772009-10-13 10:29:30 +080056
Zhang Rui8f4f5e72013-05-30 10:02:13 +080057static void
58acpi_ev_orphan_ec_reg_method(struct acpi_namespace_node *ec_device_node);
Bob Mooree2066ca2011-04-13 13:22:04 +080059
Robert Moore44f6c012005-04-18 22:49:35 -040060static acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -040061acpi_ev_reg_run(acpi_handle obj_handle,
62 u32 level, void *context, void **return_value);
Robert Moore44f6c012005-04-18 22:49:35 -040063
Lin Ming74d3ec772009-10-13 10:29:30 +080064/*******************************************************************************
65 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070066 * FUNCTION: acpi_ev_initialize_op_regions
67 *
68 * PARAMETERS: None
69 *
70 * RETURN: Status
71 *
72 * DESCRIPTION: Execute _REG methods for all Operation Regions that have
73 * an installed default region handler.
74 *
75 ******************************************************************************/
76
Len Brown4be44fc2005-08-05 00:44:28 -040077acpi_status acpi_ev_initialize_op_regions(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070078{
Len Brown4be44fc2005-08-05 00:44:28 -040079 acpi_status status;
Bob Moore67a119f2008-06-10 13:42:13 +080080 u32 i;
Linus Torvalds1da177e2005-04-16 15:20:36 -070081
Bob Mooreb229cf92006-04-21 17:15:00 -040082 ACPI_FUNCTION_TRACE(ev_initialize_op_regions);
Linus Torvalds1da177e2005-04-16 15:20:36 -070083
Len Brown4be44fc2005-08-05 00:44:28 -040084 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
85 if (ACPI_FAILURE(status)) {
86 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -070087 }
88
Bob Moore9f15fc62008-11-12 16:01:56 +080089 /* Run the _REG methods for op_regions in each default address space */
Bob Moore52fc0b02006-10-02 00:00:00 -040090
Bob Moore9f15fc62008-11-12 16:01:56 +080091 for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++) {
92 /*
Lin Ming74d3ec772009-10-13 10:29:30 +080093 * Make sure the installed handler is the DEFAULT handler. If not the
94 * default, the _REG methods will have already been run (when the
95 * handler was installed)
Linus Torvalds1da177e2005-04-16 15:20:36 -070096 */
Lin Ming74d3ec772009-10-13 10:29:30 +080097 if (acpi_ev_has_default_handler(acpi_gbl_root_node,
98 acpi_gbl_default_address_spaces
99 [i])) {
Lv Zhengd8153462015-12-29 14:03:43 +0800100 acpi_ev_execute_reg_methods(acpi_gbl_root_node,
101 acpi_gbl_default_address_spaces
102 [i], ACPI_REG_CONNECT);
Lin Ming74d3ec772009-10-13 10:29:30 +0800103 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104 }
105
Len Brown4be44fc2005-08-05 00:44:28 -0400106 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
107 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108}
109
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110/*******************************************************************************
111 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112 * FUNCTION: acpi_ev_address_space_dispatch
113 *
114 * PARAMETERS: region_obj - Internal region object
Bob Moore9ce81782011-11-16 13:39:07 +0800115 * field_obj - Corresponding field. Can be NULL.
Bob Mooreba494be2012-07-12 09:40:10 +0800116 * function - Read or Write operation
Bob Mooref5407af2009-05-21 10:56:52 +0800117 * region_offset - Where in the region to read or write
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118 * bit_width - Field width in bits (8, 16, 32, or 64)
Bob Mooreba494be2012-07-12 09:40:10 +0800119 * value - Pointer to in or out value, must be
Bob Moore5df7e6c2010-01-21 10:06:32 +0800120 * a full 64-bit integer
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121 *
122 * RETURN: Status
123 *
124 * DESCRIPTION: Dispatch an address space or operation region access to
125 * a previously installed handler.
126 *
Bob Moore7b738062015-12-29 14:01:53 +0800127 * NOTE: During early initialization, we always install the default region
128 * handlers for Memory, I/O and PCI_Config. This ensures that these operation
129 * region address spaces are always available as per the ACPI specification.
130 * This is especially needed in order to support the execution of
131 * module-level AML code during loading of the ACPI tables.
132 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133 ******************************************************************************/
134
135acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400136acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj,
Bob Moore9ce81782011-11-16 13:39:07 +0800137 union acpi_operand_object *field_obj,
Len Brown4be44fc2005-08-05 00:44:28 -0400138 u32 function,
Bob Moore5df7e6c2010-01-21 10:06:32 +0800139 u32 region_offset, u32 bit_width, u64 *value)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140{
Len Brown4be44fc2005-08-05 00:44:28 -0400141 acpi_status status;
Len Brown4be44fc2005-08-05 00:44:28 -0400142 acpi_adr_space_handler handler;
143 acpi_adr_space_setup region_setup;
144 union acpi_operand_object *handler_desc;
145 union acpi_operand_object *region_obj2;
146 void *region_context = NULL;
Bob Moore9ce81782011-11-16 13:39:07 +0800147 struct acpi_connection_info *context;
Bob Moore75ec6e52014-09-23 10:35:47 +0800148 acpi_physical_address address;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149
Bob Mooreb229cf92006-04-21 17:15:00 -0400150 ACPI_FUNCTION_TRACE(ev_address_space_dispatch);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151
Len Brown4be44fc2005-08-05 00:44:28 -0400152 region_obj2 = acpi_ns_get_secondary_object(region_obj);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153 if (!region_obj2) {
Len Brown4be44fc2005-08-05 00:44:28 -0400154 return_ACPI_STATUS(AE_NOT_EXIST);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155 }
156
157 /* Ensure that there is a handler associated with this region */
158
159 handler_desc = region_obj->region.handler;
160 if (!handler_desc) {
Bob Mooreb8e4d892006-01-27 16:43:00 -0500161 ACPI_ERROR((AE_INFO,
162 "No handler for Region [%4.4s] (%p) [%s]",
163 acpi_ut_get_node_name(region_obj->region.node),
164 region_obj,
165 acpi_ut_get_region_name(region_obj->region.
166 space_id)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167
Len Brown4be44fc2005-08-05 00:44:28 -0400168 return_ACPI_STATUS(AE_NOT_EXIST);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169 }
170
Bob Moore9ce81782011-11-16 13:39:07 +0800171 context = handler_desc->address_space.context;
172
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173 /*
Bob Moore9f15fc62008-11-12 16:01:56 +0800174 * It may be the case that the region has never been initialized.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175 * Some types of regions require special init code
176 */
177 if (!(region_obj->region.flags & AOPOBJ_SETUP_COMPLETE)) {
Bob Moore9f15fc62008-11-12 16:01:56 +0800178
179 /* This region has not been initialized yet, do it */
180
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181 region_setup = handler_desc->address_space.setup;
182 if (!region_setup) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400183
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184 /* No initialization routine, exit with error */
185
Bob Mooreb8e4d892006-01-27 16:43:00 -0500186 ACPI_ERROR((AE_INFO,
187 "No init routine for region(%p) [%s]",
188 region_obj,
189 acpi_ut_get_region_name(region_obj->region.
190 space_id)));
Len Brown4be44fc2005-08-05 00:44:28 -0400191 return_ACPI_STATUS(AE_NOT_EXIST);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192 }
193
194 /*
Bob Moore9f15fc62008-11-12 16:01:56 +0800195 * We must exit the interpreter because the region setup will
196 * potentially execute control methods (for example, the _REG method
197 * for this region)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198 */
Bob Moore014d4332008-01-10 23:04:10 -0500199 acpi_ex_exit_interpreter();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200
Len Brown4be44fc2005-08-05 00:44:28 -0400201 status = region_setup(region_obj, ACPI_REGION_ACTIVATE,
Bob Moore9ce81782011-11-16 13:39:07 +0800202 context, &region_context);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203
204 /* Re-enter the interpreter */
205
Bob Moore014d4332008-01-10 23:04:10 -0500206 acpi_ex_enter_interpreter();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207
208 /* Check for failure of the Region Setup */
209
Len Brown4be44fc2005-08-05 00:44:28 -0400210 if (ACPI_FAILURE(status)) {
Bob Mooreb8e4d892006-01-27 16:43:00 -0500211 ACPI_EXCEPTION((AE_INFO, status,
212 "During region initialization: [%s]",
213 acpi_ut_get_region_name(region_obj->
214 region.
215 space_id)));
Len Brown4be44fc2005-08-05 00:44:28 -0400216 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700217 }
218
Bob Moore9f15fc62008-11-12 16:01:56 +0800219 /* Region initialization may have been completed by region_setup */
220
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221 if (!(region_obj->region.flags & AOPOBJ_SETUP_COMPLETE)) {
222 region_obj->region.flags |= AOPOBJ_SETUP_COMPLETE;
223
David E. Boxd2e7d072013-09-23 09:52:12 +0800224 /*
225 * Save the returned context for use in all accesses to
226 * the handler for this particular region
227 */
228 if (!(region_obj2->extra.region_context)) {
Len Brown4be44fc2005-08-05 00:44:28 -0400229 region_obj2->extra.region_context =
230 region_context;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231 }
232 }
233 }
234
235 /* We have everything we need, we can invoke the address space handler */
236
237 handler = handler_desc->address_space.handler;
Bob Moore75ec6e52014-09-23 10:35:47 +0800238 address = (region_obj->region.address + region_offset);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239
Bob Moore9ce81782011-11-16 13:39:07 +0800240 /*
241 * Special handling for generic_serial_bus and general_purpose_io:
242 * There are three extra parameters that must be passed to the
243 * handler via the context:
Bob Moore75ec6e52014-09-23 10:35:47 +0800244 * 1) Connection buffer, a resource template from Connection() op
245 * 2) Length of the above buffer
246 * 3) Actual access length from the access_as() op
247 *
248 * In addition, for general_purpose_io, the Address and bit_width fields
249 * are defined as follows:
250 * 1) Address is the pin number index of the field (bit offset from
251 * the previous Connection)
252 * 2) bit_width is the actual bit length of the field (number of pins)
Bob Moore9ce81782011-11-16 13:39:07 +0800253 */
Bob Moore75ec6e52014-09-23 10:35:47 +0800254 if ((region_obj->region.space_id == ACPI_ADR_SPACE_GSBUS) &&
Bob Moore9ce81782011-11-16 13:39:07 +0800255 context && field_obj) {
256
257 /* Get the Connection (resource_template) buffer */
258
259 context->connection = field_obj->field.resource_buffer;
260 context->length = field_obj->field.resource_length;
261 context->access_length = field_obj->field.access_length;
262 }
Bob Moore75ec6e52014-09-23 10:35:47 +0800263 if ((region_obj->region.space_id == ACPI_ADR_SPACE_GPIO) &&
264 context && field_obj) {
265
266 /* Get the Connection (resource_template) buffer */
267
268 context->connection = field_obj->field.resource_buffer;
269 context->length = field_obj->field.resource_length;
270 context->access_length = field_obj->field.access_length;
271 address = field_obj->field.pin_number_index;
272 bit_width = field_obj->field.bit_length;
273 }
274
275 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
276 "Handler %p (@%p) Address %8.8X%8.8X [%s]\n",
277 &region_obj->region.handler->address_space, handler,
Lv Zheng1d0a0b22015-04-13 11:48:52 +0800278 ACPI_FORMAT_UINT64(address),
Bob Moore75ec6e52014-09-23 10:35:47 +0800279 acpi_ut_get_region_name(region_obj->region.
280 space_id)));
Bob Moore9ce81782011-11-16 13:39:07 +0800281
Bob Moore616861242006-03-17 16:44:00 -0500282 if (!(handler_desc->address_space.handler_flags &
283 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700284 /*
285 * For handlers other than the default (supplied) handlers, we must
286 * exit the interpreter because the handler *might* block -- we don't
287 * know what it will do, so we can't hold the lock on the intepreter.
288 */
Bob Moore014d4332008-01-10 23:04:10 -0500289 acpi_ex_exit_interpreter();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700290 }
291
292 /* Call the handler */
293
Bob Moore75ec6e52014-09-23 10:35:47 +0800294 status = handler(function, address, bit_width, value, context,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295 region_obj2->extra.region_context);
296
Len Brown4be44fc2005-08-05 00:44:28 -0400297 if (ACPI_FAILURE(status)) {
Bob Mooreb8e4d892006-01-27 16:43:00 -0500298 ACPI_EXCEPTION((AE_INFO, status, "Returned by Handler for [%s]",
299 acpi_ut_get_region_name(region_obj->region.
300 space_id)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301 }
302
Bob Moore616861242006-03-17 16:44:00 -0500303 if (!(handler_desc->address_space.handler_flags &
304 ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305 /*
306 * We just returned from a non-default handler, we must re-enter the
307 * interpreter
308 */
Bob Moore014d4332008-01-10 23:04:10 -0500309 acpi_ex_enter_interpreter();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700310 }
311
Len Brown4be44fc2005-08-05 00:44:28 -0400312 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313}
314
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315/*******************************************************************************
316 *
317 * FUNCTION: acpi_ev_detach_region
318 *
319 * PARAMETERS: region_obj - Region Object
320 * acpi_ns_is_locked - Namespace Region Already Locked?
321 *
322 * RETURN: None
323 *
324 * DESCRIPTION: Break the association between the handler and the region
325 * this is a two way association.
326 *
327 ******************************************************************************/
328
329void
Len Brown4be44fc2005-08-05 00:44:28 -0400330acpi_ev_detach_region(union acpi_operand_object *region_obj,
331 u8 acpi_ns_is_locked)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700332{
Len Brown4be44fc2005-08-05 00:44:28 -0400333 union acpi_operand_object *handler_obj;
334 union acpi_operand_object *obj_desc;
Bob Mooref9535292014-02-26 10:33:47 +0800335 union acpi_operand_object *start_desc;
Len Brown4be44fc2005-08-05 00:44:28 -0400336 union acpi_operand_object **last_obj_ptr;
337 acpi_adr_space_setup region_setup;
338 void **region_context;
339 union acpi_operand_object *region_obj2;
340 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341
Bob Mooreb229cf92006-04-21 17:15:00 -0400342 ACPI_FUNCTION_TRACE(ev_detach_region);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343
Len Brown4be44fc2005-08-05 00:44:28 -0400344 region_obj2 = acpi_ns_get_secondary_object(region_obj);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345 if (!region_obj2) {
346 return_VOID;
347 }
348 region_context = &region_obj2->extra.region_context;
349
350 /* Get the address handler from the region object */
351
352 handler_obj = region_obj->region.handler;
353 if (!handler_obj) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400354
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355 /* This region has no handler, all done */
356
357 return_VOID;
358 }
359
360 /* Find this region in the handler's list */
361
362 obj_desc = handler_obj->address_space.region_list;
Bob Mooref9535292014-02-26 10:33:47 +0800363 start_desc = obj_desc;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700364 last_obj_ptr = &handler_obj->address_space.region_list;
365
366 while (obj_desc) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400367
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368 /* Is this the correct Region? */
369
370 if (obj_desc == region_obj) {
Len Brown4be44fc2005-08-05 00:44:28 -0400371 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
372 "Removing Region %p from address handler %p\n",
373 region_obj, handler_obj));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700374
375 /* This is it, remove it from the handler's list */
376
377 *last_obj_ptr = obj_desc->region.next;
Len Brown4be44fc2005-08-05 00:44:28 -0400378 obj_desc->region.next = NULL; /* Must clear field */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379
380 if (acpi_ns_is_locked) {
Len Brown4be44fc2005-08-05 00:44:28 -0400381 status =
382 acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
383 if (ACPI_FAILURE(status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700384 return_VOID;
385 }
386 }
387
388 /* Now stop region accesses by executing the _REG method */
389
Bob Mooree2066ca2011-04-13 13:22:04 +0800390 status =
391 acpi_ev_execute_reg_method(region_obj,
392 ACPI_REG_DISCONNECT);
Len Brown4be44fc2005-08-05 00:44:28 -0400393 if (ACPI_FAILURE(status)) {
Bob Mooreb8e4d892006-01-27 16:43:00 -0500394 ACPI_EXCEPTION((AE_INFO, status,
395 "from region _REG, [%s]",
396 acpi_ut_get_region_name
397 (region_obj->region.space_id)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700398 }
399
400 if (acpi_ns_is_locked) {
Len Brown4be44fc2005-08-05 00:44:28 -0400401 status =
402 acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
403 if (ACPI_FAILURE(status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404 return_VOID;
405 }
406 }
407
Bob Mooref6dd9222006-07-07 20:44:38 -0400408 /*
Bob Moore9f15fc62008-11-12 16:01:56 +0800409 * If the region has been activated, call the setup handler with
410 * the deactivate notification
Bob Mooref6dd9222006-07-07 20:44:38 -0400411 */
412 if (region_obj->region.flags & AOPOBJ_SETUP_COMPLETE) {
413 region_setup = handler_obj->address_space.setup;
414 status =
415 region_setup(region_obj,
416 ACPI_REGION_DEACTIVATE,
417 handler_obj->address_space.
418 context, region_context);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700419
David E. Boxd2e7d072013-09-23 09:52:12 +0800420 /*
421 * region_context should have been released by the deactivate
422 * operation. We don't need access to it anymore here.
423 */
424 if (region_context) {
425 *region_context = NULL;
426 }
427
Bob Mooref6dd9222006-07-07 20:44:38 -0400428 /* Init routine may fail, Just ignore errors */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700429
Bob Mooref6dd9222006-07-07 20:44:38 -0400430 if (ACPI_FAILURE(status)) {
431 ACPI_EXCEPTION((AE_INFO, status,
432 "from region handler - deactivate, [%s]",
433 acpi_ut_get_region_name
434 (region_obj->region.
435 space_id)));
436 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437
Bob Mooref6dd9222006-07-07 20:44:38 -0400438 region_obj->region.flags &=
439 ~(AOPOBJ_SETUP_COMPLETE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440 }
441
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442 /*
443 * Remove handler reference in the region
444 *
Bob Mooref6dd9222006-07-07 20:44:38 -0400445 * NOTE: this doesn't mean that the region goes away, the region
446 * is just inaccessible as indicated to the _REG method
Linus Torvalds1da177e2005-04-16 15:20:36 -0700447 *
Bob Mooref6dd9222006-07-07 20:44:38 -0400448 * If the region is on the handler's list, this must be the
449 * region's handler
Linus Torvalds1da177e2005-04-16 15:20:36 -0700450 */
451 region_obj->region.handler = NULL;
Len Brown4be44fc2005-08-05 00:44:28 -0400452 acpi_ut_remove_reference(handler_obj);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700453
454 return_VOID;
455 }
456
457 /* Walk the linked list of handlers */
458
459 last_obj_ptr = &obj_desc->region.next;
460 obj_desc = obj_desc->region.next;
Bob Mooref9535292014-02-26 10:33:47 +0800461
462 /* Prevent infinite loop if list is corrupted */
463
464 if (obj_desc == start_desc) {
465 ACPI_ERROR((AE_INFO,
466 "Circular handler list in region object %p",
467 region_obj));
468 return_VOID;
469 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470 }
471
472 /* If we get here, the region was not in the handler's region list */
473
Len Brown4be44fc2005-08-05 00:44:28 -0400474 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
475 "Cannot remove region %p from address handler %p\n",
476 region_obj, handler_obj));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477
478 return_VOID;
479}
480
Linus Torvalds1da177e2005-04-16 15:20:36 -0700481/*******************************************************************************
482 *
483 * FUNCTION: acpi_ev_attach_region
484 *
485 * PARAMETERS: handler_obj - Handler Object
486 * region_obj - Region Object
487 * acpi_ns_is_locked - Namespace Region Already Locked?
488 *
489 * RETURN: None
490 *
491 * DESCRIPTION: Create the association between the handler and the region
492 * this is a two way association.
493 *
494 ******************************************************************************/
495
496acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400497acpi_ev_attach_region(union acpi_operand_object *handler_obj,
498 union acpi_operand_object *region_obj,
499 u8 acpi_ns_is_locked)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700500{
501
Bob Mooreb229cf92006-04-21 17:15:00 -0400502 ACPI_FUNCTION_TRACE(ev_attach_region);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503
Lv Zheng1d65d9a2015-12-29 14:02:50 +0800504 /* Install the region's handler */
505
506 if (region_obj->region.handler) {
507 return_ACPI_STATUS(AE_ALREADY_EXISTS);
508 }
509
Len Brown4be44fc2005-08-05 00:44:28 -0400510 ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
511 "Adding Region [%4.4s] %p to address handler %p [%s]\n",
512 acpi_ut_get_node_name(region_obj->region.node),
513 region_obj, handler_obj,
514 acpi_ut_get_region_name(region_obj->region.
515 space_id)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700516
517 /* Link this region to the front of the handler's list */
518
519 region_obj->region.next = handler_obj->address_space.region_list;
520 handler_obj->address_space.region_list = region_obj;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700521 region_obj->region.handler = handler_obj;
Len Brown4be44fc2005-08-05 00:44:28 -0400522 acpi_ut_add_reference(handler_obj);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700523
Len Brown4be44fc2005-08-05 00:44:28 -0400524 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525}
526
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527/*******************************************************************************
528 *
Bob Moore42f8fb72013-01-11 13:08:51 +0100529 * FUNCTION: acpi_ev_execute_reg_method
Linus Torvalds1da177e2005-04-16 15:20:36 -0700530 *
Bob Moore42f8fb72013-01-11 13:08:51 +0100531 * PARAMETERS: region_obj - Region object
532 * function - Passed to _REG: On (1) or Off (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700533 *
534 * RETURN: Status
535 *
Bob Moore42f8fb72013-01-11 13:08:51 +0100536 * DESCRIPTION: Execute _REG method for a region
Linus Torvalds1da177e2005-04-16 15:20:36 -0700537 *
538 ******************************************************************************/
539
540acpi_status
Bob Moore42f8fb72013-01-11 13:08:51 +0100541acpi_ev_execute_reg_method(union acpi_operand_object *region_obj, u32 function)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700542{
Bob Moore42f8fb72013-01-11 13:08:51 +0100543 struct acpi_evaluate_info *info;
544 union acpi_operand_object *args[3];
545 union acpi_operand_object *region_obj2;
Lv Zhengd1461a12016-03-24 09:41:47 +0800546 const acpi_name *reg_name_ptr =
547 ACPI_CAST_PTR(acpi_name, METHOD_NAME__REG);
548 struct acpi_namespace_node *method_node;
549 struct acpi_namespace_node *node;
Len Brown4be44fc2005-08-05 00:44:28 -0400550 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700551
Bob Moore42f8fb72013-01-11 13:08:51 +0100552 ACPI_FUNCTION_TRACE(ev_execute_reg_method);
553
Lv Zhengd1461a12016-03-24 09:41:47 +0800554 if (!acpi_gbl_namespace_initialized ||
555 region_obj->region.handler == NULL) {
556 return_ACPI_STATUS(AE_OK);
557 }
558
Bob Moore42f8fb72013-01-11 13:08:51 +0100559 region_obj2 = acpi_ns_get_secondary_object(region_obj);
560 if (!region_obj2) {
561 return_ACPI_STATUS(AE_NOT_EXIST);
562 }
563
Lv Zhengd1461a12016-03-24 09:41:47 +0800564 /*
565 * Find any "_REG" method associated with this region definition.
566 * The method should always be updated as this function may be
567 * invoked after a namespace change.
568 */
569 node = region_obj->region.node->parent;
570 status =
571 acpi_ns_search_one_scope(*reg_name_ptr, node, ACPI_TYPE_METHOD,
572 &method_node);
573 if (ACPI_SUCCESS(status)) {
574 /*
575 * The _REG method is optional and there can be only one per
576 * region definition. This will be executed when the handler is
577 * attached or removed.
578 */
579 region_obj2->extra.method_REG = method_node;
580 }
581 if (region_obj2->extra.method_REG == NULL) {
Lv Zhengefaed9b2015-12-29 14:03:08 +0800582 return_ACPI_STATUS(AE_OK);
583 }
584
585 /* _REG(DISCONNECT) should be paired with _REG(CONNECT) */
586
587 if ((function == ACPI_REG_CONNECT &&
588 region_obj->common.flags & AOPOBJ_REG_CONNECTED) ||
589 (function == ACPI_REG_DISCONNECT &&
590 !(region_obj->common.flags & AOPOBJ_REG_CONNECTED))) {
Bob Moore42f8fb72013-01-11 13:08:51 +0100591 return_ACPI_STATUS(AE_OK);
592 }
593
594 /* Allocate and initialize the evaluation information block */
595
596 info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info));
597 if (!info) {
598 return_ACPI_STATUS(AE_NO_MEMORY);
599 }
600
601 info->prefix_node = region_obj2->extra.method_REG;
Bob Moore29a241c2013-05-30 10:00:01 +0800602 info->relative_pathname = NULL;
Bob Moore42f8fb72013-01-11 13:08:51 +0100603 info->parameters = args;
604 info->flags = ACPI_IGNORE_RETURN_VALUE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700605
606 /*
Bob Moore42f8fb72013-01-11 13:08:51 +0100607 * The _REG method has two arguments:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700608 *
Bob Moore42f8fb72013-01-11 13:08:51 +0100609 * arg0 - Integer:
610 * Operation region space ID Same value as region_obj->Region.space_id
611 *
612 * arg1 - Integer:
613 * connection status 1 for connecting the handler, 0 for disconnecting
614 * the handler (Passed as a parameter)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700615 */
Bob Moore42f8fb72013-01-11 13:08:51 +0100616 args[0] =
617 acpi_ut_create_integer_object((u64)region_obj->region.space_id);
618 if (!args[0]) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700619 status = AE_NO_MEMORY;
Bob Moore42f8fb72013-01-11 13:08:51 +0100620 goto cleanup1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700621 }
622
Bob Moore42f8fb72013-01-11 13:08:51 +0100623 args[1] = acpi_ut_create_integer_object((u64)function);
624 if (!args[1]) {
625 status = AE_NO_MEMORY;
626 goto cleanup2;
627 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700628
Bob Moore42f8fb72013-01-11 13:08:51 +0100629 args[2] = NULL; /* Terminate list */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700630
Bob Moore42f8fb72013-01-11 13:08:51 +0100631 /* Execute the method, no return value */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700632
Bob Moore42f8fb72013-01-11 13:08:51 +0100633 ACPI_DEBUG_EXEC(acpi_ut_display_init_pathname
634 (ACPI_TYPE_METHOD, info->prefix_node, NULL));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700635
Bob Moore42f8fb72013-01-11 13:08:51 +0100636 status = acpi_ns_evaluate(info);
637 acpi_ut_remove_reference(args[1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700638
Lv Zhengefaed9b2015-12-29 14:03:08 +0800639 if (ACPI_FAILURE(status)) {
640 goto cleanup2;
641 }
642
643 if (function == ACPI_REG_CONNECT) {
644 region_obj->common.flags |= AOPOBJ_REG_CONNECTED;
645 } else {
646 region_obj->common.flags &= ~AOPOBJ_REG_CONNECTED;
647 }
648
Lv Zheng10622bf2013-10-29 09:30:02 +0800649cleanup2:
Bob Moore42f8fb72013-01-11 13:08:51 +0100650 acpi_ut_remove_reference(args[0]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700651
Lv Zheng10622bf2013-10-29 09:30:02 +0800652cleanup1:
Bob Moore42f8fb72013-01-11 13:08:51 +0100653 ACPI_FREE(info);
Len Brown4be44fc2005-08-05 00:44:28 -0400654 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700655}
656
Linus Torvalds1da177e2005-04-16 15:20:36 -0700657/*******************************************************************************
658 *
659 * FUNCTION: acpi_ev_execute_reg_methods
660 *
Bob Mooreba494be2012-07-12 09:40:10 +0800661 * PARAMETERS: node - Namespace node for the device
Linus Torvalds1da177e2005-04-16 15:20:36 -0700662 * space_id - The address space ID
Lv Zhengd8153462015-12-29 14:03:43 +0800663 * function - Passed to _REG: On (1) or Off (0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700664 *
Lv Zhengd8153462015-12-29 14:03:43 +0800665 * RETURN: None
Linus Torvalds1da177e2005-04-16 15:20:36 -0700666 *
667 * DESCRIPTION: Run all _REG methods for the input Space ID;
668 * Note: assumes namespace is locked, or system init time.
669 *
670 ******************************************************************************/
671
Lv Zhengd8153462015-12-29 14:03:43 +0800672void
Len Brown4be44fc2005-08-05 00:44:28 -0400673acpi_ev_execute_reg_methods(struct acpi_namespace_node *node,
Lv Zhengd8153462015-12-29 14:03:43 +0800674 acpi_adr_space_type space_id, u32 function)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700675{
Bob Moore25823e72015-08-25 10:29:45 +0800676 struct acpi_reg_walk_info info;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700677
Bob Mooreb229cf92006-04-21 17:15:00 -0400678 ACPI_FUNCTION_TRACE(ev_execute_reg_methods);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700679
Bob Mooreaa343012018-10-03 11:45:38 -0700680 /*
681 * These address spaces do not need a call to _REG, since the ACPI
682 * specification defines them as: "must always be accessible". Since
683 * they never change state (never become unavailable), no need to ever
684 * call _REG on them. Also, a data_table is not a "real" address space,
685 * so do not call _REG. September 2018.
686 */
687 if ((space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) ||
688 (space_id == ACPI_ADR_SPACE_SYSTEM_IO) ||
689 (space_id == ACPI_ADR_SPACE_DATA_TABLE)) {
690 return_VOID;
691 }
692
Bob Moore25823e72015-08-25 10:29:45 +0800693 info.space_id = space_id;
Lv Zhengd8153462015-12-29 14:03:43 +0800694 info.function = function;
Bob Moore25823e72015-08-25 10:29:45 +0800695 info.reg_run_count = 0;
696
697 ACPI_DEBUG_PRINT_RAW((ACPI_DB_NAMES,
698 " Running _REG methods for SpaceId %s\n",
699 acpi_ut_get_region_name(info.space_id)));
700
Linus Torvalds1da177e2005-04-16 15:20:36 -0700701 /*
Bob Moore9f15fc62008-11-12 16:01:56 +0800702 * Run all _REG methods for all Operation Regions for this space ID. This
703 * is a separate walk in order to handle any interdependencies between
704 * regions and _REG methods. (i.e. handlers must be installed for all
705 * regions of this Space ID before we can run any _REG methods)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700706 */
Lv Zhengd8153462015-12-29 14:03:43 +0800707 (void)acpi_ns_walk_namespace(ACPI_TYPE_ANY, node, ACPI_UINT32_MAX,
708 ACPI_NS_WALK_UNLOCK, acpi_ev_reg_run, NULL,
709 &info, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700710
Bob Mooree2066ca2011-04-13 13:22:04 +0800711 /* Special case for EC: handle "orphan" _REG methods with no region */
712
713 if (space_id == ACPI_ADR_SPACE_EC) {
Zhang Rui8f4f5e72013-05-30 10:02:13 +0800714 acpi_ev_orphan_ec_reg_method(node);
Bob Mooree2066ca2011-04-13 13:22:04 +0800715 }
716
Bob Moore25823e72015-08-25 10:29:45 +0800717 ACPI_DEBUG_PRINT_RAW((ACPI_DB_NAMES,
718 " Executed %u _REG methods for SpaceId %s\n",
719 info.reg_run_count,
720 acpi_ut_get_region_name(info.space_id)));
721
Lv Zhengd8153462015-12-29 14:03:43 +0800722 return_VOID;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700723}
724
Linus Torvalds1da177e2005-04-16 15:20:36 -0700725/*******************************************************************************
726 *
727 * FUNCTION: acpi_ev_reg_run
728 *
729 * PARAMETERS: walk_namespace callback
730 *
Bob Mooreba494be2012-07-12 09:40:10 +0800731 * DESCRIPTION: Run _REG method for region objects of the requested spaceID
Linus Torvalds1da177e2005-04-16 15:20:36 -0700732 *
733 ******************************************************************************/
734
Robert Moore44f6c012005-04-18 22:49:35 -0400735static acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400736acpi_ev_reg_run(acpi_handle obj_handle,
737 u32 level, void *context, void **return_value)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700738{
Len Brown4be44fc2005-08-05 00:44:28 -0400739 union acpi_operand_object *obj_desc;
740 struct acpi_namespace_node *node;
Len Brown4be44fc2005-08-05 00:44:28 -0400741 acpi_status status;
Bob Moore25823e72015-08-25 10:29:45 +0800742 struct acpi_reg_walk_info *info;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700743
Bob Moore25823e72015-08-25 10:29:45 +0800744 info = ACPI_CAST_PTR(struct acpi_reg_walk_info, context);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700745
746 /* Convert and validate the device handle */
747
Bob Mooref24b6642009-12-11 14:57:00 +0800748 node = acpi_ns_validate_handle(obj_handle);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700749 if (!node) {
750 return (AE_BAD_PARAMETER);
751 }
752
753 /*
Bob Mooreaa343012018-10-03 11:45:38 -0700754 * We only care about regions and objects that are allowed to have
755 * address space handlers
Linus Torvalds1da177e2005-04-16 15:20:36 -0700756 */
Len Brown4be44fc2005-08-05 00:44:28 -0400757 if ((node->type != ACPI_TYPE_REGION) && (node != acpi_gbl_root_node)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700758 return (AE_OK);
759 }
760
761 /* Check for an existing internal object */
762
Len Brown4be44fc2005-08-05 00:44:28 -0400763 obj_desc = acpi_ns_get_attached_object(node);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700764 if (!obj_desc) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400765
Linus Torvalds1da177e2005-04-16 15:20:36 -0700766 /* No object, just exit */
767
768 return (AE_OK);
769 }
770
771 /* Object is a Region */
772
Bob Moore25823e72015-08-25 10:29:45 +0800773 if (obj_desc->region.space_id != info->space_id) {
Bob Moore9f15fc62008-11-12 16:01:56 +0800774
775 /* This region is for a different address space, just ignore it */
776
Linus Torvalds1da177e2005-04-16 15:20:36 -0700777 return (AE_OK);
778 }
779
Bob Moore25823e72015-08-25 10:29:45 +0800780 info->reg_run_count++;
Lv Zhengd8153462015-12-29 14:03:43 +0800781 status = acpi_ev_execute_reg_method(obj_desc, info->function);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700782 return (status);
783}
Bob Mooree2066ca2011-04-13 13:22:04 +0800784
785/*******************************************************************************
786 *
787 * FUNCTION: acpi_ev_orphan_ec_reg_method
788 *
Zhang Rui8f4f5e72013-05-30 10:02:13 +0800789 * PARAMETERS: ec_device_node - Namespace node for an EC device
Bob Mooree2066ca2011-04-13 13:22:04 +0800790 *
791 * RETURN: None
792 *
793 * DESCRIPTION: Execute an "orphan" _REG method that appears under the EC
794 * device. This is a _REG method that has no corresponding region
795 * within the EC device scope. The orphan _REG method appears to
796 * have been enabled by the description of the ECDT in the ACPI
797 * specification: "The availability of the region space can be
798 * detected by providing a _REG method object underneath the
799 * Embedded Controller device."
800 *
Zhang Rui8f4f5e72013-05-30 10:02:13 +0800801 * To quickly access the EC device, we use the ec_device_node used
802 * during EC handler installation. Otherwise, we would need to
803 * perform a time consuming namespace walk, executing _HID
804 * methods to find the EC device.
805 *
806 * MUTEX: Assumes the namespace is locked
Bob Mooree2066ca2011-04-13 13:22:04 +0800807 *
808 ******************************************************************************/
809
Zhang Rui8f4f5e72013-05-30 10:02:13 +0800810static void
811acpi_ev_orphan_ec_reg_method(struct acpi_namespace_node *ec_device_node)
Bob Mooree2066ca2011-04-13 13:22:04 +0800812{
Zhang Rui8f4f5e72013-05-30 10:02:13 +0800813 acpi_handle reg_method;
814 struct acpi_namespace_node *next_node;
Bob Mooree2066ca2011-04-13 13:22:04 +0800815 acpi_status status;
816 struct acpi_object_list args;
817 union acpi_object objects[2];
Bob Mooree2066ca2011-04-13 13:22:04 +0800818
819 ACPI_FUNCTION_TRACE(ev_orphan_ec_reg_method);
820
Zhang Rui8f4f5e72013-05-30 10:02:13 +0800821 if (!ec_device_node) {
Bob Mooree2066ca2011-04-13 13:22:04 +0800822 return_VOID;
823 }
824
825 /* Namespace is currently locked, must release */
826
827 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
828
Bob Mooree2066ca2011-04-13 13:22:04 +0800829 /* Get a handle to a _REG method immediately under the EC device */
830
Zhang Rui8f4f5e72013-05-30 10:02:13 +0800831 status = acpi_get_handle(ec_device_node, METHOD_NAME__REG, &reg_method);
Bob Mooree2066ca2011-04-13 13:22:04 +0800832 if (ACPI_FAILURE(status)) {
Zhang Rui8f4f5e72013-05-30 10:02:13 +0800833 goto exit; /* There is no _REG method present */
Bob Mooree2066ca2011-04-13 13:22:04 +0800834 }
835
836 /*
837 * Execute the _REG method only if there is no Operation Region in
838 * this scope with the Embedded Controller space ID. Otherwise, it
839 * will already have been executed. Note, this allows for Regions
840 * with other space IDs to be present; but the code below will then
Zhang Rui8f4f5e72013-05-30 10:02:13 +0800841 * execute the _REG method with the embedded_control space_ID argument.
Bob Mooree2066ca2011-04-13 13:22:04 +0800842 */
843 next_node = acpi_ns_get_next_node(ec_device_node, NULL);
844 while (next_node) {
845 if ((next_node->type == ACPI_TYPE_REGION) &&
846 (next_node->object) &&
847 (next_node->object->region.space_id == ACPI_ADR_SPACE_EC)) {
Zhang Rui8f4f5e72013-05-30 10:02:13 +0800848 goto exit; /* Do not execute the _REG */
Bob Mooree2066ca2011-04-13 13:22:04 +0800849 }
Zhang Rui8f4f5e72013-05-30 10:02:13 +0800850
Bob Mooree2066ca2011-04-13 13:22:04 +0800851 next_node = acpi_ns_get_next_node(ec_device_node, next_node);
852 }
853
Zhang Rui8f4f5e72013-05-30 10:02:13 +0800854 /* Evaluate the _REG(embedded_control,Connect) method */
Bob Mooree2066ca2011-04-13 13:22:04 +0800855
856 args.count = 2;
857 args.pointer = objects;
858 objects[0].type = ACPI_TYPE_INTEGER;
859 objects[0].integer.value = ACPI_ADR_SPACE_EC;
860 objects[1].type = ACPI_TYPE_INTEGER;
861 objects[1].integer.value = ACPI_REG_CONNECT;
862
863 status = acpi_evaluate_object(reg_method, NULL, &args, NULL);
864
Lv Zheng10622bf2013-10-29 09:30:02 +0800865exit:
Bob Mooree2066ca2011-04-13 13:22:04 +0800866 /* We ignore all errors from above, don't care */
867
868 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
869 return_VOID;
870}