aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLin Ming <ming.m.lin@intel.com>2011-11-15 22:08:30 -0500
committerLen Brown <len.brown@intel.com>2012-01-17 03:36:28 -0500
commitffef68273b6278e98a99dd4051671d4854b20fe0 (patch)
treeb1a5c251a01743c8e35435bc5817d4a3bd20b800
parentc5bd6537329e66a8b36234f19a36d94b72d07394 (diff)
ACPI 5.0: New interfaces to allow driver access to AML mutex objects
Adds acpi_acquire_mutex, acpi_release_mutex external interfaces. New file, utxfmutex.c. Signed-off-by: Lin Ming <ming.m.lin@intel.com> Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Len Brown <len.brown@intel.com>
-rw-r--r--drivers/acpi/acpica/Makefile2
-rw-r--r--drivers/acpi/acpica/utxfmutex.c187
-rw-r--r--include/acpi/acpixf.h15
3 files changed, 201 insertions, 3 deletions
diff --git a/drivers/acpi/acpica/Makefile b/drivers/acpi/acpica/Makefile
index 301bd2d388ad..1bd466113dc8 100644
--- a/drivers/acpi/acpica/Makefile
+++ b/drivers/acpi/acpica/Makefile
@@ -45,4 +45,4 @@ acpi-y += tbxface.o tbinstal.o tbutils.o tbfind.o tbfadt.o tbxfroot.o
45acpi-y += utalloc.o utdebug.o uteval.o utinit.o utmisc.o utxface.o \ 45acpi-y += utalloc.o utdebug.o uteval.o utinit.o utmisc.o utxface.o \
46 utcopy.o utdelete.o utglobal.o utmath.o utobject.o \ 46 utcopy.o utdelete.o utglobal.o utmath.o utobject.o \
47 utstate.o utmutex.o utobject.o utresrc.o utlock.o utids.o \ 47 utstate.o utmutex.o utobject.o utresrc.o utlock.o utids.o \
48 utosi.o utxferror.o utdecode.o 48 utosi.o utxferror.o utdecode.o utxfmutex.o
diff --git a/drivers/acpi/acpica/utxfmutex.c b/drivers/acpi/acpica/utxfmutex.c
new file mode 100644
index 000000000000..1ea016b228bd
--- /dev/null
+++ b/drivers/acpi/acpica/utxfmutex.c
@@ -0,0 +1,187 @@
1/*******************************************************************************
2 *
3 * Module Name: utxfmutex - external AML mutex access functions
4 *
5 ******************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2011, Intel Corp.
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
44#include <acpi/acpi.h>
45#include "accommon.h"
46#include "acnamesp.h"
47
48#define _COMPONENT ACPI_UTILITIES
49ACPI_MODULE_NAME("utxfmutex")
50
51/* Local prototypes */
52static acpi_status
53acpi_ut_get_mutex_object(acpi_handle handle,
54 acpi_string pathname,
55 union acpi_operand_object **ret_obj);
56
57/*******************************************************************************
58 *
59 * FUNCTION: acpi_ut_get_mutex_object
60 *
61 * PARAMETERS: Handle - Mutex or prefix handle (optional)
62 * Pathname - Mutex pathname (optional)
63 * ret_obj - Where the mutex object is returned
64 *
65 * RETURN: Status
66 *
67 * DESCRIPTION: Get an AML mutex object. The mutex node is pointed to by
68 * Handle:Pathname. Either Handle or Pathname can be NULL, but
69 * not both.
70 *
71 ******************************************************************************/
72
73static acpi_status
74acpi_ut_get_mutex_object(acpi_handle handle,
75 acpi_string pathname,
76 union acpi_operand_object **ret_obj)
77{
78 struct acpi_namespace_node *mutex_node;
79 union acpi_operand_object *mutex_obj;
80 acpi_status status;
81
82 /* Parameter validation */
83
84 if (!ret_obj || (!handle && !pathname)) {
85 return (AE_BAD_PARAMETER);
86 }
87
88 /* Get a the namespace node for the mutex */
89
90 mutex_node = handle;
91 if (pathname != NULL) {
92 status = acpi_get_handle(handle, pathname,
93 ACPI_CAST_PTR(acpi_handle,
94 &mutex_node));
95 if (ACPI_FAILURE(status)) {
96 return (status);
97 }
98 }
99
100 /* Ensure that we actually have a Mutex object */
101
102 if (!mutex_node || (mutex_node->type != ACPI_TYPE_MUTEX)) {
103 return (AE_TYPE);
104 }
105
106 /* Get the low-level mutex object */
107
108 mutex_obj = acpi_ns_get_attached_object(mutex_node);
109 if (!mutex_obj) {
110 return (AE_NULL_OBJECT);
111 }
112
113 *ret_obj = mutex_obj;
114 return (AE_OK);
115}
116
117/*******************************************************************************
118 *
119 * FUNCTION: acpi_acquire_mutex
120 *
121 * PARAMETERS: Handle - Mutex or prefix handle (optional)
122 * Pathname - Mutex pathname (optional)
123 * Timeout - Max time to wait for the lock (millisec)
124 *
125 * RETURN: Status
126 *
127 * DESCRIPTION: Acquire an AML mutex. This is a device driver interface to
128 * AML mutex objects, and allows for transaction locking between
129 * drivers and AML code. The mutex node is pointed to by
130 * Handle:Pathname. Either Handle or Pathname can be NULL, but
131 * not both.
132 *
133 ******************************************************************************/
134
135acpi_status
136acpi_acquire_mutex(acpi_handle handle, acpi_string pathname, u16 timeout)
137{
138 acpi_status status;
139 union acpi_operand_object *mutex_obj;
140
141 /* Get the low-level mutex associated with Handle:Pathname */
142
143 status = acpi_ut_get_mutex_object(handle, pathname, &mutex_obj);
144 if (ACPI_FAILURE(status)) {
145 return (status);
146 }
147
148 /* Acquire the OS mutex */
149
150 status = acpi_os_acquire_mutex(mutex_obj->mutex.os_mutex, timeout);
151 return (status);
152}
153
154/*******************************************************************************
155 *
156 * FUNCTION: acpi_release_mutex
157 *
158 * PARAMETERS: Handle - Mutex or prefix handle (optional)
159 * Pathname - Mutex pathname (optional)
160 *
161 * RETURN: Status
162 *
163 * DESCRIPTION: Release an AML mutex. This is a device driver interface to
164 * AML mutex objects, and allows for transaction locking between
165 * drivers and AML code. The mutex node is pointed to by
166 * Handle:Pathname. Either Handle or Pathname can be NULL, but
167 * not both.
168 *
169 ******************************************************************************/
170
171acpi_status acpi_release_mutex(acpi_handle handle, acpi_string pathname)
172{
173 acpi_status status;
174 union acpi_operand_object *mutex_obj;
175
176 /* Get the low-level mutex associated with Handle:Pathname */
177
178 status = acpi_ut_get_mutex_object(handle, pathname, &mutex_obj);
179 if (ACPI_FAILURE(status)) {
180 return (status);
181 }
182
183 /* Release the OS mutex */
184
185 acpi_os_release_mutex(mutex_obj->mutex.os_mutex);
186 return (AE_OK);
187}
diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h
index 9ba2e3aff5c6..dd86610039b3 100644
--- a/include/acpi/acpixf.h
+++ b/include/acpi/acpixf.h
@@ -277,12 +277,23 @@ acpi_status acpi_install_exception_handler(acpi_exception_handler handler);
277acpi_status acpi_install_interface_handler(acpi_interface_handler handler); 277acpi_status acpi_install_interface_handler(acpi_interface_handler handler);
278 278
279/* 279/*
280 * Event interfaces 280 * Global Lock interfaces
281 */ 281 */
282acpi_status acpi_acquire_global_lock(u16 timeout, u32 * handle); 282acpi_status acpi_acquire_global_lock(u16 timeout, u32 * handle);
283 283
284acpi_status acpi_release_global_lock(u32 handle); 284acpi_status acpi_release_global_lock(u32 handle);
285 285
286/*
287 * Interfaces to AML mutex objects
288 */
289acpi_status
290acpi_acquire_mutex(acpi_handle handle, acpi_string pathname, u16 timeout);
291
292acpi_status acpi_release_mutex(acpi_handle handle, acpi_string pathname);
293
294/*
295 * Fixed Event interfaces
296 */
286acpi_status acpi_enable_event(u32 event, u32 flags); 297acpi_status acpi_enable_event(u32 event, u32 flags);
287 298
288acpi_status acpi_disable_event(u32 event, u32 flags); 299acpi_status acpi_disable_event(u32 event, u32 flags);
@@ -292,7 +303,7 @@ acpi_status acpi_clear_event(u32 event);
292acpi_status acpi_get_event_status(u32 event, acpi_event_status * event_status); 303acpi_status acpi_get_event_status(u32 event, acpi_event_status * event_status);
293 304
294/* 305/*
295 * GPE Interfaces 306 * General Purpose Event (GPE) Interfaces
296 */ 307 */
297acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number); 308acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number);
298 309