aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi')
-rw-r--r--drivers/acpi/Kconfig9
-rw-r--r--drivers/acpi/Makefile1
-rw-r--r--drivers/acpi/acpica/Makefile4
-rw-r--r--drivers/acpi/acpica/accommon.h1
-rw-r--r--drivers/acpi/acpica/acconfig.h231
-rw-r--r--drivers/acpi/acpica/acdebug.h8
-rw-r--r--drivers/acpi/acpica/acevents.h21
-rw-r--r--drivers/acpi/acpica/acglobal.h11
-rw-r--r--drivers/acpi/acpica/achware.h32
-rw-r--r--drivers/acpi/acpica/aclocal.h1
-rw-r--r--drivers/acpi/acpica/acmacros.h6
-rw-r--r--drivers/acpi/acpica/acnamesp.h5
-rw-r--r--drivers/acpi/acpica/actables.h5
-rw-r--r--drivers/acpi/acpica/evevent.c4
-rw-r--r--drivers/acpi/acpica/evglock.c4
-rw-r--r--drivers/acpi/acpica/evgpe.c4
-rw-r--r--drivers/acpi/acpica/evgpeblk.c4
-rw-r--r--drivers/acpi/acpica/evgpeinit.c4
-rw-r--r--drivers/acpi/acpica/evgpeutil.c3
-rw-r--r--drivers/acpi/acpica/evmisc.c26
-rw-r--r--drivers/acpi/acpica/evsci.c4
-rw-r--r--drivers/acpi/acpica/evxface.c436
-rw-r--r--drivers/acpi/acpica/evxfevnt.c2
-rw-r--r--drivers/acpi/acpica/evxfgpe.c2
-rw-r--r--drivers/acpi/acpica/hwacpi.c3
-rw-r--r--drivers/acpi/acpica/hwesleep.c247
-rw-r--r--drivers/acpi/acpica/hwgpe.c4
-rw-r--r--drivers/acpi/acpica/hwregs.c16
-rw-r--r--drivers/acpi/acpica/hwsleep.c391
-rw-r--r--drivers/acpi/acpica/hwtimer.c2
-rw-r--r--drivers/acpi/acpica/hwxface.c50
-rw-r--r--drivers/acpi/acpica/hwxfsleep.c431
-rw-r--r--drivers/acpi/acpica/nsdump.c15
-rw-r--r--drivers/acpi/acpica/nsdumpdv.c2
-rw-r--r--drivers/acpi/acpica/nspredef.c4
-rw-r--r--drivers/acpi/acpica/nsrepair.c159
-rw-r--r--drivers/acpi/acpica/nsutils.c2
-rw-r--r--drivers/acpi/acpica/tbfadt.c8
-rw-r--r--drivers/acpi/acpica/tbinstal.c117
-rw-r--r--drivers/acpi/acpica/tbutils.c95
-rw-r--r--drivers/acpi/acpica/utdecode.c34
-rw-r--r--drivers/acpi/acpica/utglobal.c9
-rw-r--r--drivers/acpi/acpica/utinit.c37
-rw-r--r--drivers/acpi/acpica/utxface.c6
-rw-r--r--drivers/acpi/apei/apei-base.c4
-rw-r--r--drivers/acpi/bgrt.c175
-rw-r--r--drivers/acpi/bus.c1
-rw-r--r--drivers/acpi/ec.c8
-rw-r--r--drivers/acpi/nvs.c4
-rw-r--r--drivers/acpi/osl.c100
-rw-r--r--drivers/acpi/processor_driver.c14
-rw-r--r--drivers/acpi/processor_idle.c34
-rw-r--r--drivers/acpi/processor_thermal.c45
-rw-r--r--drivers/acpi/processor_throttling.c5
-rw-r--r--drivers/acpi/reboot.c3
-rw-r--r--drivers/acpi/scan.c5
-rw-r--r--drivers/acpi/sleep.c41
-rw-r--r--drivers/acpi/thermal.c8
-rw-r--r--drivers/acpi/video.c50
59 files changed, 1755 insertions, 1202 deletions
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 7556913aba45..47768ff87343 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -384,6 +384,15 @@ config ACPI_CUSTOM_METHOD
384 load additional kernel modules after boot, this feature may be used 384 load additional kernel modules after boot, this feature may be used
385 to override that restriction). 385 to override that restriction).
386 386
387config ACPI_BGRT
388 tristate "Boottime Graphics Resource Table support"
389 default n
390 help
391 This driver adds support for exposing the ACPI Boottime Graphics
392 Resource Table, which allows the operating system to obtain
393 data from the firmware boot splash. It will appear under
394 /sys/firmware/acpi/bgrt/ .
395
387source "drivers/acpi/apei/Kconfig" 396source "drivers/acpi/apei/Kconfig"
388 397
389endif # ACPI 398endif # ACPI
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index 1567028d2038..47199e2a9130 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -62,6 +62,7 @@ obj-$(CONFIG_ACPI_SBS) += sbs.o
62obj-$(CONFIG_ACPI_HED) += hed.o 62obj-$(CONFIG_ACPI_HED) += hed.o
63obj-$(CONFIG_ACPI_EC_DEBUGFS) += ec_sys.o 63obj-$(CONFIG_ACPI_EC_DEBUGFS) += ec_sys.o
64obj-$(CONFIG_ACPI_CUSTOM_METHOD)+= custom_method.o 64obj-$(CONFIG_ACPI_CUSTOM_METHOD)+= custom_method.o
65obj-$(CONFIG_ACPI_BGRT) += bgrt.o
65 66
66# processor has its own "processor." module_param namespace 67# processor has its own "processor." module_param namespace
67processor-y := processor_driver.o processor_throttling.o 68processor-y := processor_driver.o processor_throttling.o
diff --git a/drivers/acpi/acpica/Makefile b/drivers/acpi/acpica/Makefile
index 0ca208b6dcf0..793b8cc8e256 100644
--- a/drivers/acpi/acpica/Makefile
+++ b/drivers/acpi/acpica/Makefile
@@ -68,12 +68,14 @@ acpi-y += \
68 68
69acpi-y += \ 69acpi-y += \
70 hwacpi.o \ 70 hwacpi.o \
71 hwesleep.o \
71 hwgpe.o \ 72 hwgpe.o \
72 hwpci.o \ 73 hwpci.o \
73 hwregs.o \ 74 hwregs.o \
74 hwsleep.o \ 75 hwsleep.o \
75 hwvalid.o \ 76 hwvalid.o \
76 hwxface.o 77 hwxface.o \
78 hwxfsleep.o
77 79
78acpi-$(ACPI_FUTURE_USAGE) += hwtimer.o 80acpi-$(ACPI_FUTURE_USAGE) += hwtimer.o
79 81
diff --git a/drivers/acpi/acpica/accommon.h b/drivers/acpi/acpica/accommon.h
index a44bd424f9f4..8a7d51bfb3b3 100644
--- a/drivers/acpi/acpica/accommon.h
+++ b/drivers/acpi/acpica/accommon.h
@@ -51,7 +51,6 @@
51 * 51 *
52 * Note: The order of these include files is important. 52 * Note: The order of these include files is important.
53 */ 53 */
54#include "acconfig.h" /* Global configuration constants */
55#include "acmacros.h" /* C macros */ 54#include "acmacros.h" /* C macros */
56#include "aclocal.h" /* Internal data types */ 55#include "aclocal.h" /* Internal data types */
57#include "acobject.h" /* ACPI internal object */ 56#include "acobject.h" /* ACPI internal object */
diff --git a/drivers/acpi/acpica/acconfig.h b/drivers/acpi/acpica/acconfig.h
deleted file mode 100644
index 1f30af613e87..000000000000
--- a/drivers/acpi/acpica/acconfig.h
+++ /dev/null
@@ -1,231 +0,0 @@
1/******************************************************************************
2 *
3 * Name: acconfig.h - Global configuration constants
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2012, 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#ifndef _ACCONFIG_H
45#define _ACCONFIG_H
46
47/******************************************************************************
48 *
49 * Configuration options
50 *
51 *****************************************************************************/
52
53/*
54 * ACPI_DEBUG_OUTPUT - This switch enables all the debug facilities of the
55 * ACPI subsystem. This includes the DEBUG_PRINT output
56 * statements. When disabled, all DEBUG_PRINT
57 * statements are compiled out.
58 *
59 * ACPI_APPLICATION - Use this switch if the subsystem is going to be run
60 * at the application level.
61 *
62 */
63
64/*
65 * OS name, used for the _OS object. The _OS object is essentially obsolete,
66 * but there is a large base of ASL/AML code in existing machines that check
67 * for the string below. The use of this string usually guarantees that
68 * the ASL will execute down the most tested code path. Also, there is some
69 * code that will not execute the _OSI method unless _OS matches the string
70 * below. Therefore, change this string at your own risk.
71 */
72#define ACPI_OS_NAME "Microsoft Windows NT"
73
74/* Maximum objects in the various object caches */
75
76#define ACPI_MAX_STATE_CACHE_DEPTH 96 /* State objects */
77#define ACPI_MAX_PARSE_CACHE_DEPTH 96 /* Parse tree objects */
78#define ACPI_MAX_EXTPARSE_CACHE_DEPTH 96 /* Parse tree objects */
79#define ACPI_MAX_OBJECT_CACHE_DEPTH 96 /* Interpreter operand objects */
80#define ACPI_MAX_NAMESPACE_CACHE_DEPTH 96 /* Namespace objects */
81
82/*
83 * Should the subsystem abort the loading of an ACPI table if the
84 * table checksum is incorrect?
85 */
86#define ACPI_CHECKSUM_ABORT FALSE
87
88/******************************************************************************
89 *
90 * Subsystem Constants
91 *
92 *****************************************************************************/
93
94/* Version of ACPI supported */
95
96#define ACPI_CA_SUPPORT_LEVEL 3
97
98/* Maximum count for a semaphore object */
99
100#define ACPI_MAX_SEMAPHORE_COUNT 256
101
102/* Maximum object reference count (detects object deletion issues) */
103
104#define ACPI_MAX_REFERENCE_COUNT 0x1000
105
106/* Default page size for use in mapping memory for operation regions */
107
108#define ACPI_DEFAULT_PAGE_SIZE 4096 /* Must be power of 2 */
109
110/* owner_id tracking. 8 entries allows for 255 owner_ids */
111
112#define ACPI_NUM_OWNERID_MASKS 8
113
114/* Size of the root table array is increased by this increment */
115
116#define ACPI_ROOT_TABLE_SIZE_INCREMENT 4
117
118/* Maximum number of While() loop iterations before forced abort */
119
120#define ACPI_MAX_LOOP_ITERATIONS 0xFFFF
121
122/* Maximum sleep allowed via Sleep() operator */
123
124#define ACPI_MAX_SLEEP 2000 /* Two seconds */
125
126/* Address Range lists are per-space_id (Memory and I/O only) */
127
128#define ACPI_ADDRESS_RANGE_MAX 2
129
130/******************************************************************************
131 *
132 * ACPI Specification constants (Do not change unless the specification changes)
133 *
134 *****************************************************************************/
135
136/* Number of distinct GPE register blocks and register width */
137
138#define ACPI_MAX_GPE_BLOCKS 2
139#define ACPI_GPE_REGISTER_WIDTH 8
140
141/* Method info (in WALK_STATE), containing local variables and argumetns */
142
143#define ACPI_METHOD_NUM_LOCALS 8
144#define ACPI_METHOD_MAX_LOCAL 7
145
146#define ACPI_METHOD_NUM_ARGS 7
147#define ACPI_METHOD_MAX_ARG 6
148
149/* Length of _HID, _UID, _CID, and UUID values */
150
151#define ACPI_DEVICE_ID_LENGTH 0x09
152#define ACPI_MAX_CID_LENGTH 48
153#define ACPI_UUID_LENGTH 16
154
155/*
156 * Operand Stack (in WALK_STATE), Must be large enough to contain METHOD_MAX_ARG
157 */
158#define ACPI_OBJ_NUM_OPERANDS 8
159#define ACPI_OBJ_MAX_OPERAND 7
160
161/* Number of elements in the Result Stack frame, can be an arbitrary value */
162
163#define ACPI_RESULTS_FRAME_OBJ_NUM 8
164
165/*
166 * Maximal number of elements the Result Stack can contain,
167 * it may be an arbitray value not exceeding the types of
168 * result_size and result_count (now u8).
169 */
170#define ACPI_RESULTS_OBJ_NUM_MAX 255
171
172/* Names within the namespace are 4 bytes long */
173
174#define ACPI_NAME_SIZE 4
175#define ACPI_PATH_SEGMENT_LENGTH 5 /* 4 chars for name + 1 char for separator */
176#define ACPI_PATH_SEPARATOR '.'
177
178/* Sizes for ACPI table headers */
179
180#define ACPI_OEM_ID_SIZE 6
181#define ACPI_OEM_TABLE_ID_SIZE 8
182
183/* Constants used in searching for the RSDP in low memory */
184
185#define ACPI_EBDA_PTR_LOCATION 0x0000040E /* Physical Address */
186#define ACPI_EBDA_PTR_LENGTH 2
187#define ACPI_EBDA_WINDOW_SIZE 1024
188#define ACPI_HI_RSDP_WINDOW_BASE 0x000E0000 /* Physical Address */
189#define ACPI_HI_RSDP_WINDOW_SIZE 0x00020000
190#define ACPI_RSDP_SCAN_STEP 16
191
192/* Operation regions */
193
194#define ACPI_USER_REGION_BEGIN 0x80
195
196/* Maximum space_ids for Operation Regions */
197
198#define ACPI_MAX_ADDRESS_SPACE 255
199
200/* Array sizes. Used for range checking also */
201
202#define ACPI_MAX_MATCH_OPCODE 5
203
204/* RSDP checksums */
205
206#define ACPI_RSDP_CHECKSUM_LENGTH 20
207#define ACPI_RSDP_XCHECKSUM_LENGTH 36
208
209/* SMBus, GSBus and IPMI bidirectional buffer size */
210
211#define ACPI_SMBUS_BUFFER_SIZE 34
212#define ACPI_GSBUS_BUFFER_SIZE 34
213#define ACPI_IPMI_BUFFER_SIZE 66
214
215/* _sx_d and _sx_w control methods */
216
217#define ACPI_NUM_sx_d_METHODS 4
218#define ACPI_NUM_sx_w_METHODS 5
219
220/******************************************************************************
221 *
222 * ACPI AML Debugger
223 *
224 *****************************************************************************/
225
226#define ACPI_DEBUGGER_MAX_ARGS 8 /* Must be max method args + 1 */
227
228#define ACPI_DEBUGGER_COMMAND_PROMPT '-'
229#define ACPI_DEBUGGER_EXECUTE_PROMPT '%'
230
231#endif /* _ACCONFIG_H */
diff --git a/drivers/acpi/acpica/acdebug.h b/drivers/acpi/acpica/acdebug.h
index deaa81979561..5e8abb07724f 100644
--- a/drivers/acpi/acpica/acdebug.h
+++ b/drivers/acpi/acpica/acdebug.h
@@ -111,7 +111,7 @@ acpi_status acpi_db_find_name_in_namespace(char *name_arg);
111 111
112void acpi_db_set_scope(char *name); 112void acpi_db_set_scope(char *name);
113 113
114acpi_status acpi_db_sleep(char *object_arg); 114ACPI_HW_DEPENDENT_RETURN_OK(acpi_status acpi_db_sleep(char *object_arg))
115 115
116void acpi_db_find_references(char *object_arg); 116void acpi_db_find_references(char *object_arg);
117 117
@@ -119,11 +119,13 @@ void acpi_db_display_locks(void);
119 119
120void acpi_db_display_resources(char *object_arg); 120void acpi_db_display_resources(char *object_arg);
121 121
122void acpi_db_display_gpes(void); 122ACPI_HW_DEPENDENT_RETURN_VOID(void acpi_db_display_gpes(void))
123 123
124void acpi_db_check_integrity(void); 124void acpi_db_check_integrity(void);
125 125
126void acpi_db_generate_gpe(char *gpe_arg, char *block_arg); 126ACPI_HW_DEPENDENT_RETURN_VOID(void
127 acpi_db_generate_gpe(char *gpe_arg,
128 char *block_arg))
127 129
128void acpi_db_check_predefined_names(void); 130void acpi_db_check_predefined_names(void);
129 131
diff --git a/drivers/acpi/acpica/acevents.h b/drivers/acpi/acpica/acevents.h
index c53caa521a30..d700f63e4701 100644
--- a/drivers/acpi/acpica/acevents.h
+++ b/drivers/acpi/acpica/acevents.h
@@ -69,11 +69,10 @@ acpi_ev_queue_notify_request(struct acpi_namespace_node *node,
69 */ 69 */
70acpi_status acpi_ev_init_global_lock_handler(void); 70acpi_status acpi_ev_init_global_lock_handler(void);
71 71
72acpi_status acpi_ev_acquire_global_lock(u16 timeout); 72ACPI_HW_DEPENDENT_RETURN_OK(acpi_status
73 73 acpi_ev_acquire_global_lock(u16 timeout))
74acpi_status acpi_ev_release_global_lock(void); 74 ACPI_HW_DEPENDENT_RETURN_OK(acpi_status acpi_ev_release_global_lock(void))
75 75 acpi_status acpi_ev_remove_global_lock_handler(void);
76acpi_status acpi_ev_remove_global_lock_handler(void);
77 76
78/* 77/*
79 * evgpe - Low-level GPE support 78 * evgpe - Low-level GPE support
@@ -114,7 +113,9 @@ acpi_ev_initialize_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
114 struct acpi_gpe_block_info *gpe_block, 113 struct acpi_gpe_block_info *gpe_block,
115 void *context); 114 void *context);
116 115
117acpi_status acpi_ev_delete_gpe_block(struct acpi_gpe_block_info *gpe_block); 116ACPI_HW_DEPENDENT_RETURN_OK(acpi_status
117 acpi_ev_delete_gpe_block(struct acpi_gpe_block_info
118 *gpe_block))
118 119
119u32 120u32
120acpi_ev_gpe_dispatch(struct acpi_namespace_node *gpe_device, 121acpi_ev_gpe_dispatch(struct acpi_namespace_node *gpe_device,
@@ -126,9 +127,10 @@ acpi_ev_gpe_dispatch(struct acpi_namespace_node *gpe_device,
126 */ 127 */
127acpi_status acpi_ev_gpe_initialize(void); 128acpi_status acpi_ev_gpe_initialize(void);
128 129
129void acpi_ev_update_gpes(acpi_owner_id table_owner_id); 130ACPI_HW_DEPENDENT_RETURN_VOID(void
131 acpi_ev_update_gpes(acpi_owner_id table_owner_id))
130 132
131acpi_status 133 acpi_status
132acpi_ev_match_gpe_method(acpi_handle obj_handle, 134acpi_ev_match_gpe_method(acpi_handle obj_handle,
133 u32 level, void *context, void **return_value); 135 u32 level, void *context, void **return_value);
134 136
@@ -237,6 +239,5 @@ acpi_status acpi_ev_remove_sci_handler(void);
237 239
238u32 acpi_ev_initialize_sCI(u32 program_sCI); 240u32 acpi_ev_initialize_sCI(u32 program_sCI);
239 241
240void acpi_ev_terminate(void); 242ACPI_HW_DEPENDENT_RETURN_VOID(void acpi_ev_terminate(void))
241
242#endif /* __ACEVENTS_H__ */ 243#endif /* __ACEVENTS_H__ */
diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h
index 2853f7673f3b..4f7d3f57d05c 100644
--- a/drivers/acpi/acpica/acglobal.h
+++ b/drivers/acpi/acpica/acglobal.h
@@ -147,7 +147,7 @@ u8 acpi_gbl_system_awake_and_running;
147 */ 147 */
148u8 acpi_gbl_reduced_hardware; 148u8 acpi_gbl_reduced_hardware;
149 149
150#endif 150#endif /* DEFINE_ACPI_GLOBALS */
151 151
152/* Do not disassemble buffers to resource descriptors */ 152/* Do not disassemble buffers to resource descriptors */
153 153
@@ -184,8 +184,12 @@ ACPI_EXTERN u32 acpi_gbl_trace_dbg_layer;
184 * found in the RSDT/XSDT. 184 * found in the RSDT/XSDT.
185 */ 185 */
186ACPI_EXTERN struct acpi_table_list acpi_gbl_root_table_list; 186ACPI_EXTERN struct acpi_table_list acpi_gbl_root_table_list;
187
188#if (!ACPI_REDUCED_HARDWARE)
187ACPI_EXTERN struct acpi_table_facs *acpi_gbl_FACS; 189ACPI_EXTERN struct acpi_table_facs *acpi_gbl_FACS;
188 190
191#endif /* !ACPI_REDUCED_HARDWARE */
192
189/* These addresses are calculated from the FADT Event Block addresses */ 193/* These addresses are calculated from the FADT Event Block addresses */
190 194
191ACPI_EXTERN struct acpi_generic_address acpi_gbl_xpm1a_status; 195ACPI_EXTERN struct acpi_generic_address acpi_gbl_xpm1a_status;
@@ -397,10 +401,15 @@ ACPI_EXTERN struct acpi_fixed_event_handler
397ACPI_EXTERN struct acpi_gpe_xrupt_info *acpi_gbl_gpe_xrupt_list_head; 401ACPI_EXTERN struct acpi_gpe_xrupt_info *acpi_gbl_gpe_xrupt_list_head;
398ACPI_EXTERN struct acpi_gpe_block_info 402ACPI_EXTERN struct acpi_gpe_block_info
399*acpi_gbl_gpe_fadt_blocks[ACPI_MAX_GPE_BLOCKS]; 403*acpi_gbl_gpe_fadt_blocks[ACPI_MAX_GPE_BLOCKS];
404
405#if (!ACPI_REDUCED_HARDWARE)
406
400ACPI_EXTERN u8 acpi_gbl_all_gpes_initialized; 407ACPI_EXTERN u8 acpi_gbl_all_gpes_initialized;
401ACPI_EXTERN ACPI_GBL_EVENT_HANDLER acpi_gbl_global_event_handler; 408ACPI_EXTERN ACPI_GBL_EVENT_HANDLER acpi_gbl_global_event_handler;
402ACPI_EXTERN void *acpi_gbl_global_event_handler_context; 409ACPI_EXTERN void *acpi_gbl_global_event_handler_context;
403 410
411#endif /* !ACPI_REDUCED_HARDWARE */
412
404/***************************************************************************** 413/*****************************************************************************
405 * 414 *
406 * Debugger globals 415 * Debugger globals
diff --git a/drivers/acpi/acpica/achware.h b/drivers/acpi/acpica/achware.h
index 677793e938f5..5ccb99ae3a6f 100644
--- a/drivers/acpi/acpica/achware.h
+++ b/drivers/acpi/acpica/achware.h
@@ -81,6 +81,26 @@ acpi_status acpi_hw_register_write(u32 register_id, u32 value);
81acpi_status acpi_hw_clear_acpi_status(void); 81acpi_status acpi_hw_clear_acpi_status(void);
82 82
83/* 83/*
84 * hwsleep - sleep/wake support (Legacy sleep registers)
85 */
86acpi_status acpi_hw_legacy_sleep(u8 sleep_state, u8 flags);
87
88acpi_status acpi_hw_legacy_wake_prep(u8 sleep_state, u8 flags);
89
90acpi_status acpi_hw_legacy_wake(u8 sleep_state, u8 flags);
91
92/*
93 * hwesleep - sleep/wake support (Extended FADT-V5 sleep registers)
94 */
95void acpi_hw_execute_sleep_method(char *method_name, u32 integer_argument);
96
97acpi_status acpi_hw_extended_sleep(u8 sleep_state, u8 flags);
98
99acpi_status acpi_hw_extended_wake_prep(u8 sleep_state, u8 flags);
100
101acpi_status acpi_hw_extended_wake(u8 sleep_state, u8 flags);
102
103/*
84 * hwvalid - Port I/O with validation 104 * hwvalid - Port I/O with validation
85 */ 105 */
86acpi_status acpi_hw_read_port(acpi_io_address address, u32 *value, u32 width); 106acpi_status acpi_hw_read_port(acpi_io_address address, u32 *value, u32 width);
@@ -128,16 +148,4 @@ acpi_status
128acpi_hw_derive_pci_id(struct acpi_pci_id *pci_id, 148acpi_hw_derive_pci_id(struct acpi_pci_id *pci_id,
129 acpi_handle root_pci_device, acpi_handle pci_region); 149 acpi_handle root_pci_device, acpi_handle pci_region);
130 150
131#ifdef ACPI_FUTURE_USAGE
132/*
133 * hwtimer - ACPI Timer prototypes
134 */
135acpi_status acpi_get_timer_resolution(u32 * resolution);
136
137acpi_status acpi_get_timer(u32 * ticks);
138
139acpi_status
140acpi_get_timer_duration(u32 start_ticks, u32 end_ticks, u32 * time_elapsed);
141#endif /* ACPI_FUTURE_USAGE */
142
143#endif /* __ACHWARE_H__ */ 151#endif /* __ACHWARE_H__ */
diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h
index 3f24068837d5..e3922ca20e7f 100644
--- a/drivers/acpi/acpica/aclocal.h
+++ b/drivers/acpi/acpica/aclocal.h
@@ -370,6 +370,7 @@ struct acpi_predefined_data {
370/* Defines for Flags field above */ 370/* Defines for Flags field above */
371 371
372#define ACPI_OBJECT_REPAIRED 1 372#define ACPI_OBJECT_REPAIRED 1
373#define ACPI_OBJECT_WRAPPED 2
373 374
374/* 375/*
375 * Bitmapped return value types 376 * Bitmapped return value types
diff --git a/drivers/acpi/acpica/acmacros.h b/drivers/acpi/acpica/acmacros.h
index ef338a96f5b2..f119f473f71a 100644
--- a/drivers/acpi/acpica/acmacros.h
+++ b/drivers/acpi/acpica/acmacros.h
@@ -516,6 +516,12 @@
516 516
517#endif /* ACPI_DEBUG_OUTPUT */ 517#endif /* ACPI_DEBUG_OUTPUT */
518 518
519#if (!ACPI_REDUCED_HARDWARE)
520#define ACPI_HW_OPTIONAL_FUNCTION(addr) addr
521#else
522#define ACPI_HW_OPTIONAL_FUNCTION(addr) NULL
523#endif
524
519/* 525/*
520 * Some code only gets executed when the debugger is built in. 526 * Some code only gets executed when the debugger is built in.
521 * Note that this is entirely independent of whether the 527 * Note that this is entirely independent of whether the
diff --git a/drivers/acpi/acpica/acnamesp.h b/drivers/acpi/acpica/acnamesp.h
index 2c9e0f049523..9b19d4b86424 100644
--- a/drivers/acpi/acpica/acnamesp.h
+++ b/drivers/acpi/acpica/acnamesp.h
@@ -283,8 +283,9 @@ acpi_ns_repair_object(struct acpi_predefined_data *data,
283 union acpi_operand_object **return_object_ptr); 283 union acpi_operand_object **return_object_ptr);
284 284
285acpi_status 285acpi_status
286acpi_ns_repair_package_list(struct acpi_predefined_data *data, 286acpi_ns_wrap_with_package(struct acpi_predefined_data *data,
287 union acpi_operand_object **obj_desc_ptr); 287 union acpi_operand_object *original_object,
288 union acpi_operand_object **obj_desc_ptr);
288 289
289acpi_status 290acpi_status
290acpi_ns_repair_null_element(struct acpi_predefined_data *data, 291acpi_ns_repair_null_element(struct acpi_predefined_data *data,
diff --git a/drivers/acpi/acpica/actables.h b/drivers/acpi/acpica/actables.h
index d5bec304c823..6712965ba8ae 100644
--- a/drivers/acpi/acpica/actables.h
+++ b/drivers/acpi/acpica/actables.h
@@ -67,6 +67,11 @@ acpi_status acpi_tb_resize_root_table_list(void);
67 67
68acpi_status acpi_tb_verify_table(struct acpi_table_desc *table_desc); 68acpi_status acpi_tb_verify_table(struct acpi_table_desc *table_desc);
69 69
70struct acpi_table_header *acpi_tb_table_override(struct acpi_table_header
71 *table_header,
72 struct acpi_table_desc
73 *table_desc);
74
70acpi_status 75acpi_status
71acpi_tb_add_table(struct acpi_table_desc *table_desc, u32 *table_index); 76acpi_tb_add_table(struct acpi_table_desc *table_desc, u32 *table_index);
72 77
diff --git a/drivers/acpi/acpica/evevent.c b/drivers/acpi/acpica/evevent.c
index 6729ebe2f1e6..07e4dc44f81c 100644
--- a/drivers/acpi/acpica/evevent.c
+++ b/drivers/acpi/acpica/evevent.c
@@ -47,7 +47,7 @@
47 47
48#define _COMPONENT ACPI_EVENTS 48#define _COMPONENT ACPI_EVENTS
49ACPI_MODULE_NAME("evevent") 49ACPI_MODULE_NAME("evevent")
50 50#if (!ACPI_REDUCED_HARDWARE) /* Entire module */
51/* Local prototypes */ 51/* Local prototypes */
52static acpi_status acpi_ev_fixed_event_initialize(void); 52static acpi_status acpi_ev_fixed_event_initialize(void);
53 53
@@ -291,3 +291,5 @@ static u32 acpi_ev_fixed_event_dispatch(u32 event)
291 return ((acpi_gbl_fixed_event_handlers[event]. 291 return ((acpi_gbl_fixed_event_handlers[event].
292 handler) (acpi_gbl_fixed_event_handlers[event].context)); 292 handler) (acpi_gbl_fixed_event_handlers[event].context));
293} 293}
294
295#endif /* !ACPI_REDUCED_HARDWARE */
diff --git a/drivers/acpi/acpica/evglock.c b/drivers/acpi/acpica/evglock.c
index 5e5683cb1f0d..cfeab38795d8 100644
--- a/drivers/acpi/acpica/evglock.c
+++ b/drivers/acpi/acpica/evglock.c
@@ -48,7 +48,7 @@
48 48
49#define _COMPONENT ACPI_EVENTS 49#define _COMPONENT ACPI_EVENTS
50ACPI_MODULE_NAME("evglock") 50ACPI_MODULE_NAME("evglock")
51 51#if (!ACPI_REDUCED_HARDWARE) /* Entire module */
52/* Local prototypes */ 52/* Local prototypes */
53static u32 acpi_ev_global_lock_handler(void *context); 53static u32 acpi_ev_global_lock_handler(void *context);
54 54
@@ -339,3 +339,5 @@ acpi_status acpi_ev_release_global_lock(void)
339 acpi_os_release_mutex(acpi_gbl_global_lock_mutex->mutex.os_mutex); 339 acpi_os_release_mutex(acpi_gbl_global_lock_mutex->mutex.os_mutex);
340 return_ACPI_STATUS(status); 340 return_ACPI_STATUS(status);
341} 341}
342
343#endif /* !ACPI_REDUCED_HARDWARE */
diff --git a/drivers/acpi/acpica/evgpe.c b/drivers/acpi/acpica/evgpe.c
index 9e88cb6fb25e..8ba0e5f17091 100644
--- a/drivers/acpi/acpica/evgpe.c
+++ b/drivers/acpi/acpica/evgpe.c
@@ -48,7 +48,7 @@
48 48
49#define _COMPONENT ACPI_EVENTS 49#define _COMPONENT ACPI_EVENTS
50ACPI_MODULE_NAME("evgpe") 50ACPI_MODULE_NAME("evgpe")
51 51#if (!ACPI_REDUCED_HARDWARE) /* Entire module */
52/* Local prototypes */ 52/* Local prototypes */
53static void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context); 53static void ACPI_SYSTEM_XFACE acpi_ev_asynch_execute_gpe_method(void *context);
54 54
@@ -766,3 +766,5 @@ acpi_ev_gpe_dispatch(struct acpi_namespace_node *gpe_device,
766 766
767 return_UINT32(ACPI_INTERRUPT_HANDLED); 767 return_UINT32(ACPI_INTERRUPT_HANDLED);
768} 768}
769
770#endif /* !ACPI_REDUCED_HARDWARE */
diff --git a/drivers/acpi/acpica/evgpeblk.c b/drivers/acpi/acpica/evgpeblk.c
index be75339cd5dd..23a3ca86b2eb 100644
--- a/drivers/acpi/acpica/evgpeblk.c
+++ b/drivers/acpi/acpica/evgpeblk.c
@@ -48,7 +48,7 @@
48 48
49#define _COMPONENT ACPI_EVENTS 49#define _COMPONENT ACPI_EVENTS
50ACPI_MODULE_NAME("evgpeblk") 50ACPI_MODULE_NAME("evgpeblk")
51 51#if (!ACPI_REDUCED_HARDWARE) /* Entire module */
52/* Local prototypes */ 52/* Local prototypes */
53static acpi_status 53static acpi_status
54acpi_ev_install_gpe_block(struct acpi_gpe_block_info *gpe_block, 54acpi_ev_install_gpe_block(struct acpi_gpe_block_info *gpe_block,
@@ -504,3 +504,5 @@ acpi_ev_initialize_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
504 504
505 return_ACPI_STATUS(AE_OK); 505 return_ACPI_STATUS(AE_OK);
506} 506}
507
508#endif /* !ACPI_REDUCED_HARDWARE */
diff --git a/drivers/acpi/acpica/evgpeinit.c b/drivers/acpi/acpica/evgpeinit.c
index adf7494da9db..da0add858f81 100644
--- a/drivers/acpi/acpica/evgpeinit.c
+++ b/drivers/acpi/acpica/evgpeinit.c
@@ -48,7 +48,7 @@
48 48
49#define _COMPONENT ACPI_EVENTS 49#define _COMPONENT ACPI_EVENTS
50ACPI_MODULE_NAME("evgpeinit") 50ACPI_MODULE_NAME("evgpeinit")
51 51#if (!ACPI_REDUCED_HARDWARE) /* Entire module */
52/* 52/*
53 * Note: History of _PRW support in ACPICA 53 * Note: History of _PRW support in ACPICA
54 * 54 *
@@ -440,3 +440,5 @@ acpi_ev_match_gpe_method(acpi_handle obj_handle,
440 name, gpe_number)); 440 name, gpe_number));
441 return_ACPI_STATUS(AE_OK); 441 return_ACPI_STATUS(AE_OK);
442} 442}
443
444#endif /* !ACPI_REDUCED_HARDWARE */
diff --git a/drivers/acpi/acpica/evgpeutil.c b/drivers/acpi/acpica/evgpeutil.c
index 25073932aa10..3c43796b8361 100644
--- a/drivers/acpi/acpica/evgpeutil.c
+++ b/drivers/acpi/acpica/evgpeutil.c
@@ -48,6 +48,7 @@
48#define _COMPONENT ACPI_EVENTS 48#define _COMPONENT ACPI_EVENTS
49ACPI_MODULE_NAME("evgpeutil") 49ACPI_MODULE_NAME("evgpeutil")
50 50
51#if (!ACPI_REDUCED_HARDWARE) /* Entire module */
51/******************************************************************************* 52/*******************************************************************************
52 * 53 *
53 * FUNCTION: acpi_ev_walk_gpe_list 54 * FUNCTION: acpi_ev_walk_gpe_list
@@ -374,3 +375,5 @@ acpi_ev_delete_gpe_handlers(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
374 375
375 return_ACPI_STATUS(AE_OK); 376 return_ACPI_STATUS(AE_OK);
376} 377}
378
379#endif /* !ACPI_REDUCED_HARDWARE */
diff --git a/drivers/acpi/acpica/evmisc.c b/drivers/acpi/acpica/evmisc.c
index 84966f416463..51ef9f5e002d 100644
--- a/drivers/acpi/acpica/evmisc.c
+++ b/drivers/acpi/acpica/evmisc.c
@@ -108,27 +108,30 @@ acpi_ev_queue_notify_request(struct acpi_namespace_node * node,
108 ACPI_FUNCTION_NAME(ev_queue_notify_request); 108 ACPI_FUNCTION_NAME(ev_queue_notify_request);
109 109
110 /* 110 /*
111 * For value 3 (Ejection Request), some device method may need to be run. 111 * For value 0x03 (Ejection Request), may need to run a device method.
112 * For value 2 (Device Wake) if _PRW exists, the _PS0 method may need 112 * For value 0x02 (Device Wake), if _PRW exists, may need to run
113 * to be run. 113 * the _PS0 method.
114 * For value 0x80 (Status Change) on the power button or sleep button, 114 * For value 0x80 (Status Change) on the power button or sleep button,
115 * initiate soft-off or sleep operation? 115 * initiate soft-off or sleep operation.
116 *
117 * For all cases, simply dispatch the notify to the handler.
116 */ 118 */
117 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 119 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
118 "Dispatching Notify on [%4.4s] Node %p Value 0x%2.2X (%s)\n", 120 "Dispatching Notify on [%4.4s] (%s) Value 0x%2.2X (%s) Node %p\n",
119 acpi_ut_get_node_name(node), node, notify_value, 121 acpi_ut_get_node_name(node),
120 acpi_ut_get_notify_name(notify_value))); 122 acpi_ut_get_type_name(node->type), notify_value,
123 acpi_ut_get_notify_name(notify_value), node));
121 124
122 /* Get the notify object attached to the NS Node */ 125 /* Get the notify object attached to the NS Node */
123 126
124 obj_desc = acpi_ns_get_attached_object(node); 127 obj_desc = acpi_ns_get_attached_object(node);
125 if (obj_desc) { 128 if (obj_desc) {
126 129
127 /* We have the notify object, Get the right handler */ 130 /* We have the notify object, Get the correct handler */
128 131
129 switch (node->type) { 132 switch (node->type) {
130 133
131 /* Notify allowed only on these types */ 134 /* Notify is allowed only on these types */
132 135
133 case ACPI_TYPE_DEVICE: 136 case ACPI_TYPE_DEVICE:
134 case ACPI_TYPE_THERMAL: 137 case ACPI_TYPE_THERMAL:
@@ -152,7 +155,7 @@ acpi_ev_queue_notify_request(struct acpi_namespace_node * node,
152 } 155 }
153 156
154 /* 157 /*
155 * If there is any handler to run, schedule the dispatcher. 158 * If there is a handler to run, schedule the dispatcher.
156 * Check for: 159 * Check for:
157 * 1) Global system notify handler 160 * 1) Global system notify handler
158 * 2) Global device notify handler 161 * 2) Global device notify handler
@@ -270,6 +273,7 @@ static void ACPI_SYSTEM_XFACE acpi_ev_notify_dispatch(void *context)
270 acpi_ut_delete_generic_state(notify_info); 273 acpi_ut_delete_generic_state(notify_info);
271} 274}
272 275
276#if (!ACPI_REDUCED_HARDWARE)
273/****************************************************************************** 277/******************************************************************************
274 * 278 *
275 * FUNCTION: acpi_ev_terminate 279 * FUNCTION: acpi_ev_terminate
@@ -338,3 +342,5 @@ void acpi_ev_terminate(void)
338 } 342 }
339 return_VOID; 343 return_VOID;
340} 344}
345
346#endif /* !ACPI_REDUCED_HARDWARE */
diff --git a/drivers/acpi/acpica/evsci.c b/drivers/acpi/acpica/evsci.c
index 26065c612e76..6a57aa2d70d1 100644
--- a/drivers/acpi/acpica/evsci.c
+++ b/drivers/acpi/acpica/evsci.c
@@ -48,7 +48,7 @@
48 48
49#define _COMPONENT ACPI_EVENTS 49#define _COMPONENT ACPI_EVENTS
50ACPI_MODULE_NAME("evsci") 50ACPI_MODULE_NAME("evsci")
51 51#if (!ACPI_REDUCED_HARDWARE) /* Entire module */
52/* Local prototypes */ 52/* Local prototypes */
53static u32 ACPI_SYSTEM_XFACE acpi_ev_sci_xrupt_handler(void *context); 53static u32 ACPI_SYSTEM_XFACE acpi_ev_sci_xrupt_handler(void *context);
54 54
@@ -181,3 +181,5 @@ acpi_status acpi_ev_remove_sci_handler(void)
181 181
182 return_ACPI_STATUS(status); 182 return_ACPI_STATUS(status);
183} 183}
184
185#endif /* !ACPI_REDUCED_HARDWARE */
diff --git a/drivers/acpi/acpica/evxface.c b/drivers/acpi/acpica/evxface.c
index 61944e89565a..44bef5744ebb 100644
--- a/drivers/acpi/acpica/evxface.c
+++ b/drivers/acpi/acpica/evxface.c
@@ -51,222 +51,6 @@
51#define _COMPONENT ACPI_EVENTS 51#define _COMPONENT ACPI_EVENTS
52ACPI_MODULE_NAME("evxface") 52ACPI_MODULE_NAME("evxface")
53 53
54/*******************************************************************************
55 *
56 * FUNCTION: acpi_install_exception_handler
57 *
58 * PARAMETERS: Handler - Pointer to the handler function for the
59 * event
60 *
61 * RETURN: Status
62 *
63 * DESCRIPTION: Saves the pointer to the handler function
64 *
65 ******************************************************************************/
66#ifdef ACPI_FUTURE_USAGE
67acpi_status acpi_install_exception_handler(acpi_exception_handler handler)
68{
69 acpi_status status;
70
71 ACPI_FUNCTION_TRACE(acpi_install_exception_handler);
72
73 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
74 if (ACPI_FAILURE(status)) {
75 return_ACPI_STATUS(status);
76 }
77
78 /* Don't allow two handlers. */
79
80 if (acpi_gbl_exception_handler) {
81 status = AE_ALREADY_EXISTS;
82 goto cleanup;
83 }
84
85 /* Install the handler */
86
87 acpi_gbl_exception_handler = handler;
88
89 cleanup:
90 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
91 return_ACPI_STATUS(status);
92}
93
94ACPI_EXPORT_SYMBOL(acpi_install_exception_handler)
95#endif /* ACPI_FUTURE_USAGE */
96
97/*******************************************************************************
98 *
99 * FUNCTION: acpi_install_global_event_handler
100 *
101 * PARAMETERS: Handler - Pointer to the global event handler function
102 * Context - Value passed to the handler on each event
103 *
104 * RETURN: Status
105 *
106 * DESCRIPTION: Saves the pointer to the handler function. The global handler
107 * is invoked upon each incoming GPE and Fixed Event. It is
108 * invoked at interrupt level at the time of the event dispatch.
109 * Can be used to update event counters, etc.
110 *
111 ******************************************************************************/
112acpi_status
113acpi_install_global_event_handler(ACPI_GBL_EVENT_HANDLER handler, void *context)
114{
115 acpi_status status;
116
117 ACPI_FUNCTION_TRACE(acpi_install_global_event_handler);
118
119 /* Parameter validation */
120
121 if (!handler) {
122 return_ACPI_STATUS(AE_BAD_PARAMETER);
123 }
124
125 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
126 if (ACPI_FAILURE(status)) {
127 return_ACPI_STATUS(status);
128 }
129
130 /* Don't allow two handlers. */
131
132 if (acpi_gbl_global_event_handler) {
133 status = AE_ALREADY_EXISTS;
134 goto cleanup;
135 }
136
137 acpi_gbl_global_event_handler = handler;
138 acpi_gbl_global_event_handler_context = context;
139
140 cleanup:
141 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
142 return_ACPI_STATUS(status);
143}
144
145ACPI_EXPORT_SYMBOL(acpi_install_global_event_handler)
146
147/*******************************************************************************
148 *
149 * FUNCTION: acpi_install_fixed_event_handler
150 *
151 * PARAMETERS: Event - Event type to enable.
152 * Handler - Pointer to the handler function for the
153 * event
154 * Context - Value passed to the handler on each GPE
155 *
156 * RETURN: Status
157 *
158 * DESCRIPTION: Saves the pointer to the handler function and then enables the
159 * event.
160 *
161 ******************************************************************************/
162acpi_status
163acpi_install_fixed_event_handler(u32 event,
164 acpi_event_handler handler, void *context)
165{
166 acpi_status status;
167
168 ACPI_FUNCTION_TRACE(acpi_install_fixed_event_handler);
169
170 /* Parameter validation */
171
172 if (event > ACPI_EVENT_MAX) {
173 return_ACPI_STATUS(AE_BAD_PARAMETER);
174 }
175
176 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
177 if (ACPI_FAILURE(status)) {
178 return_ACPI_STATUS(status);
179 }
180
181 /* Don't allow two handlers. */
182
183 if (NULL != acpi_gbl_fixed_event_handlers[event].handler) {
184 status = AE_ALREADY_EXISTS;
185 goto cleanup;
186 }
187
188 /* Install the handler before enabling the event */
189
190 acpi_gbl_fixed_event_handlers[event].handler = handler;
191 acpi_gbl_fixed_event_handlers[event].context = context;
192
193 status = acpi_clear_event(event);
194 if (ACPI_SUCCESS(status))
195 status = acpi_enable_event(event, 0);
196 if (ACPI_FAILURE(status)) {
197 ACPI_WARNING((AE_INFO, "Could not enable fixed event 0x%X",
198 event));
199
200 /* Remove the handler */
201
202 acpi_gbl_fixed_event_handlers[event].handler = NULL;
203 acpi_gbl_fixed_event_handlers[event].context = NULL;
204 } else {
205 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
206 "Enabled fixed event %X, Handler=%p\n", event,
207 handler));
208 }
209
210 cleanup:
211 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
212 return_ACPI_STATUS(status);
213}
214
215ACPI_EXPORT_SYMBOL(acpi_install_fixed_event_handler)
216
217/*******************************************************************************
218 *
219 * FUNCTION: acpi_remove_fixed_event_handler
220 *
221 * PARAMETERS: Event - Event type to disable.
222 * Handler - Address of the handler
223 *
224 * RETURN: Status
225 *
226 * DESCRIPTION: Disables the event and unregisters the event handler.
227 *
228 ******************************************************************************/
229acpi_status
230acpi_remove_fixed_event_handler(u32 event, acpi_event_handler handler)
231{
232 acpi_status status = AE_OK;
233
234 ACPI_FUNCTION_TRACE(acpi_remove_fixed_event_handler);
235
236 /* Parameter validation */
237
238 if (event > ACPI_EVENT_MAX) {
239 return_ACPI_STATUS(AE_BAD_PARAMETER);
240 }
241
242 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
243 if (ACPI_FAILURE(status)) {
244 return_ACPI_STATUS(status);
245 }
246
247 /* Disable the event before removing the handler */
248
249 status = acpi_disable_event(event, 0);
250
251 /* Always Remove the handler */
252
253 acpi_gbl_fixed_event_handlers[event].handler = NULL;
254 acpi_gbl_fixed_event_handlers[event].context = NULL;
255
256 if (ACPI_FAILURE(status)) {
257 ACPI_WARNING((AE_INFO,
258 "Could not write to fixed event enable register 0x%X",
259 event));
260 } else {
261 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Disabled fixed event %X\n",
262 event));
263 }
264
265 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
266 return_ACPI_STATUS(status);
267}
268
269ACPI_EXPORT_SYMBOL(acpi_remove_fixed_event_handler)
270 54
271/******************************************************************************* 55/*******************************************************************************
272 * 56 *
@@ -334,6 +118,7 @@ acpi_add_handler_object(struct acpi_object_notify_handler *parent_obj,
334 return AE_OK; 118 return AE_OK;
335} 119}
336 120
121
337/******************************************************************************* 122/*******************************************************************************
338 * 123 *
339 * FUNCTION: acpi_install_notify_handler 124 * FUNCTION: acpi_install_notify_handler
@@ -705,6 +490,224 @@ ACPI_EXPORT_SYMBOL(acpi_remove_notify_handler)
705 490
706/******************************************************************************* 491/*******************************************************************************
707 * 492 *
493 * FUNCTION: acpi_install_exception_handler
494 *
495 * PARAMETERS: Handler - Pointer to the handler function for the
496 * event
497 *
498 * RETURN: Status
499 *
500 * DESCRIPTION: Saves the pointer to the handler function
501 *
502 ******************************************************************************/
503#ifdef ACPI_FUTURE_USAGE
504acpi_status acpi_install_exception_handler(acpi_exception_handler handler)
505{
506 acpi_status status;
507
508 ACPI_FUNCTION_TRACE(acpi_install_exception_handler);
509
510 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
511 if (ACPI_FAILURE(status)) {
512 return_ACPI_STATUS(status);
513 }
514
515 /* Don't allow two handlers. */
516
517 if (acpi_gbl_exception_handler) {
518 status = AE_ALREADY_EXISTS;
519 goto cleanup;
520 }
521
522 /* Install the handler */
523
524 acpi_gbl_exception_handler = handler;
525
526 cleanup:
527 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
528 return_ACPI_STATUS(status);
529}
530
531ACPI_EXPORT_SYMBOL(acpi_install_exception_handler)
532#endif /* ACPI_FUTURE_USAGE */
533
534#if (!ACPI_REDUCED_HARDWARE)
535/*******************************************************************************
536 *
537 * FUNCTION: acpi_install_global_event_handler
538 *
539 * PARAMETERS: Handler - Pointer to the global event handler function
540 * Context - Value passed to the handler on each event
541 *
542 * RETURN: Status
543 *
544 * DESCRIPTION: Saves the pointer to the handler function. The global handler
545 * is invoked upon each incoming GPE and Fixed Event. It is
546 * invoked at interrupt level at the time of the event dispatch.
547 * Can be used to update event counters, etc.
548 *
549 ******************************************************************************/
550acpi_status
551acpi_install_global_event_handler(ACPI_GBL_EVENT_HANDLER handler, void *context)
552{
553 acpi_status status;
554
555 ACPI_FUNCTION_TRACE(acpi_install_global_event_handler);
556
557 /* Parameter validation */
558
559 if (!handler) {
560 return_ACPI_STATUS(AE_BAD_PARAMETER);
561 }
562
563 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
564 if (ACPI_FAILURE(status)) {
565 return_ACPI_STATUS(status);
566 }
567
568 /* Don't allow two handlers. */
569
570 if (acpi_gbl_global_event_handler) {
571 status = AE_ALREADY_EXISTS;
572 goto cleanup;
573 }
574
575 acpi_gbl_global_event_handler = handler;
576 acpi_gbl_global_event_handler_context = context;
577
578 cleanup:
579 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
580 return_ACPI_STATUS(status);
581}
582
583ACPI_EXPORT_SYMBOL(acpi_install_global_event_handler)
584
585/*******************************************************************************
586 *
587 * FUNCTION: acpi_install_fixed_event_handler
588 *
589 * PARAMETERS: Event - Event type to enable.
590 * Handler - Pointer to the handler function for the
591 * event
592 * Context - Value passed to the handler on each GPE
593 *
594 * RETURN: Status
595 *
596 * DESCRIPTION: Saves the pointer to the handler function and then enables the
597 * event.
598 *
599 ******************************************************************************/
600acpi_status
601acpi_install_fixed_event_handler(u32 event,
602 acpi_event_handler handler, void *context)
603{
604 acpi_status status;
605
606 ACPI_FUNCTION_TRACE(acpi_install_fixed_event_handler);
607
608 /* Parameter validation */
609
610 if (event > ACPI_EVENT_MAX) {
611 return_ACPI_STATUS(AE_BAD_PARAMETER);
612 }
613
614 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
615 if (ACPI_FAILURE(status)) {
616 return_ACPI_STATUS(status);
617 }
618
619 /* Don't allow two handlers. */
620
621 if (NULL != acpi_gbl_fixed_event_handlers[event].handler) {
622 status = AE_ALREADY_EXISTS;
623 goto cleanup;
624 }
625
626 /* Install the handler before enabling the event */
627
628 acpi_gbl_fixed_event_handlers[event].handler = handler;
629 acpi_gbl_fixed_event_handlers[event].context = context;
630
631 status = acpi_clear_event(event);
632 if (ACPI_SUCCESS(status))
633 status = acpi_enable_event(event, 0);
634 if (ACPI_FAILURE(status)) {
635 ACPI_WARNING((AE_INFO, "Could not enable fixed event 0x%X",
636 event));
637
638 /* Remove the handler */
639
640 acpi_gbl_fixed_event_handlers[event].handler = NULL;
641 acpi_gbl_fixed_event_handlers[event].context = NULL;
642 } else {
643 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
644 "Enabled fixed event %X, Handler=%p\n", event,
645 handler));
646 }
647
648 cleanup:
649 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
650 return_ACPI_STATUS(status);
651}
652
653ACPI_EXPORT_SYMBOL(acpi_install_fixed_event_handler)
654
655/*******************************************************************************
656 *
657 * FUNCTION: acpi_remove_fixed_event_handler
658 *
659 * PARAMETERS: Event - Event type to disable.
660 * Handler - Address of the handler
661 *
662 * RETURN: Status
663 *
664 * DESCRIPTION: Disables the event and unregisters the event handler.
665 *
666 ******************************************************************************/
667acpi_status
668acpi_remove_fixed_event_handler(u32 event, acpi_event_handler handler)
669{
670 acpi_status status = AE_OK;
671
672 ACPI_FUNCTION_TRACE(acpi_remove_fixed_event_handler);
673
674 /* Parameter validation */
675
676 if (event > ACPI_EVENT_MAX) {
677 return_ACPI_STATUS(AE_BAD_PARAMETER);
678 }
679
680 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
681 if (ACPI_FAILURE(status)) {
682 return_ACPI_STATUS(status);
683 }
684
685 /* Disable the event before removing the handler */
686
687 status = acpi_disable_event(event, 0);
688
689 /* Always Remove the handler */
690
691 acpi_gbl_fixed_event_handlers[event].handler = NULL;
692 acpi_gbl_fixed_event_handlers[event].context = NULL;
693
694 if (ACPI_FAILURE(status)) {
695 ACPI_WARNING((AE_INFO,
696 "Could not write to fixed event enable register 0x%X",
697 event));
698 } else {
699 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Disabled fixed event %X\n",
700 event));
701 }
702
703 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
704 return_ACPI_STATUS(status);
705}
706
707ACPI_EXPORT_SYMBOL(acpi_remove_fixed_event_handler)
708
709/*******************************************************************************
710 *
708 * FUNCTION: acpi_install_gpe_handler 711 * FUNCTION: acpi_install_gpe_handler
709 * 712 *
710 * PARAMETERS: gpe_device - Namespace node for the GPE (NULL for FADT 713 * PARAMETERS: gpe_device - Namespace node for the GPE (NULL for FADT
@@ -984,3 +987,4 @@ acpi_status acpi_release_global_lock(u32 handle)
984} 987}
985 988
986ACPI_EXPORT_SYMBOL(acpi_release_global_lock) 989ACPI_EXPORT_SYMBOL(acpi_release_global_lock)
990#endif /* !ACPI_REDUCED_HARDWARE */
diff --git a/drivers/acpi/acpica/evxfevnt.c b/drivers/acpi/acpica/evxfevnt.c
index 1768bbec1002..77cee5a5e891 100644
--- a/drivers/acpi/acpica/evxfevnt.c
+++ b/drivers/acpi/acpica/evxfevnt.c
@@ -49,6 +49,7 @@
49#define _COMPONENT ACPI_EVENTS 49#define _COMPONENT ACPI_EVENTS
50ACPI_MODULE_NAME("evxfevnt") 50ACPI_MODULE_NAME("evxfevnt")
51 51
52#if (!ACPI_REDUCED_HARDWARE) /* Entire module */
52/******************************************************************************* 53/*******************************************************************************
53 * 54 *
54 * FUNCTION: acpi_enable 55 * FUNCTION: acpi_enable
@@ -352,3 +353,4 @@ acpi_status acpi_get_event_status(u32 event, acpi_event_status * event_status)
352} 353}
353 354
354ACPI_EXPORT_SYMBOL(acpi_get_event_status) 355ACPI_EXPORT_SYMBOL(acpi_get_event_status)
356#endif /* !ACPI_REDUCED_HARDWARE */
diff --git a/drivers/acpi/acpica/evxfgpe.c b/drivers/acpi/acpica/evxfgpe.c
index 33388fd69df4..86f9b343ebd4 100644
--- a/drivers/acpi/acpica/evxfgpe.c
+++ b/drivers/acpi/acpica/evxfgpe.c
@@ -50,6 +50,7 @@
50#define _COMPONENT ACPI_EVENTS 50#define _COMPONENT ACPI_EVENTS
51ACPI_MODULE_NAME("evxfgpe") 51ACPI_MODULE_NAME("evxfgpe")
52 52
53#if (!ACPI_REDUCED_HARDWARE) /* Entire module */
53/****************************************************************************** 54/******************************************************************************
54 * 55 *
55 * FUNCTION: acpi_update_all_gpes 56 * FUNCTION: acpi_update_all_gpes
@@ -695,3 +696,4 @@ acpi_get_gpe_device(u32 index, acpi_handle *gpe_device)
695} 696}
696 697
697ACPI_EXPORT_SYMBOL(acpi_get_gpe_device) 698ACPI_EXPORT_SYMBOL(acpi_get_gpe_device)
699#endif /* !ACPI_REDUCED_HARDWARE */
diff --git a/drivers/acpi/acpica/hwacpi.c b/drivers/acpi/acpica/hwacpi.c
index d21ec5f0b3a9..d0b9ed5df97e 100644
--- a/drivers/acpi/acpica/hwacpi.c
+++ b/drivers/acpi/acpica/hwacpi.c
@@ -48,6 +48,7 @@
48#define _COMPONENT ACPI_HARDWARE 48#define _COMPONENT ACPI_HARDWARE
49ACPI_MODULE_NAME("hwacpi") 49ACPI_MODULE_NAME("hwacpi")
50 50
51#if (!ACPI_REDUCED_HARDWARE) /* Entire module */
51/****************************************************************************** 52/******************************************************************************
52 * 53 *
53 * FUNCTION: acpi_hw_set_mode 54 * FUNCTION: acpi_hw_set_mode
@@ -166,3 +167,5 @@ u32 acpi_hw_get_mode(void)
166 return_UINT32(ACPI_SYS_MODE_LEGACY); 167 return_UINT32(ACPI_SYS_MODE_LEGACY);
167 } 168 }
168} 169}
170
171#endif /* !ACPI_REDUCED_HARDWARE */
diff --git a/drivers/acpi/acpica/hwesleep.c b/drivers/acpi/acpica/hwesleep.c
new file mode 100644
index 000000000000..29e859293edd
--- /dev/null
+++ b/drivers/acpi/acpica/hwesleep.c
@@ -0,0 +1,247 @@
1/******************************************************************************
2 *
3 * Name: hwesleep.c - ACPI Hardware Sleep/Wake Support functions for the
4 * extended FADT-V5 sleep registers.
5 *
6 *****************************************************************************/
7
8/*
9 * Copyright (C) 2000 - 2012, Intel Corp.
10 * 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 "accommon.h"
47
48#define _COMPONENT ACPI_HARDWARE
49ACPI_MODULE_NAME("hwesleep")
50
51/*******************************************************************************
52 *
53 * FUNCTION: acpi_hw_execute_sleep_method
54 *
55 * PARAMETERS: method_pathname - Pathname of method to execute
56 * integer_argument - Argument to pass to the method
57 *
58 * RETURN: None
59 *
60 * DESCRIPTION: Execute a sleep/wake related method with one integer argument
61 * and no return value.
62 *
63 ******************************************************************************/
64void acpi_hw_execute_sleep_method(char *method_pathname, u32 integer_argument)
65{
66 struct acpi_object_list arg_list;
67 union acpi_object arg;
68 acpi_status status;
69
70 ACPI_FUNCTION_TRACE(hw_execute_sleep_method);
71
72 /* One argument, integer_argument; No return value expected */
73
74 arg_list.count = 1;
75 arg_list.pointer = &arg;
76 arg.type = ACPI_TYPE_INTEGER;
77 arg.integer.value = (u64)integer_argument;
78
79 status = acpi_evaluate_object(NULL, method_pathname, &arg_list, NULL);
80 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
81 ACPI_EXCEPTION((AE_INFO, status, "While executing method %s",
82 method_pathname));
83 }
84
85 return_VOID;
86}
87
88/*******************************************************************************
89 *
90 * FUNCTION: acpi_hw_extended_sleep
91 *
92 * PARAMETERS: sleep_state - Which sleep state to enter
93 * Flags - ACPI_EXECUTE_GTS to run optional method
94 *
95 * RETURN: Status
96 *
97 * DESCRIPTION: Enter a system sleep state via the extended FADT sleep
98 * registers (V5 FADT).
99 * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
100 *
101 ******************************************************************************/
102
103acpi_status acpi_hw_extended_sleep(u8 sleep_state, u8 flags)
104{
105 acpi_status status;
106 u8 sleep_type_value;
107 u64 sleep_status;
108
109 ACPI_FUNCTION_TRACE(hw_extended_sleep);
110
111 /* Extended sleep registers must be valid */
112
113 if (!acpi_gbl_FADT.sleep_control.address ||
114 !acpi_gbl_FADT.sleep_status.address) {
115 return_ACPI_STATUS(AE_NOT_EXIST);
116 }
117
118 /* Clear wake status (WAK_STS) */
119
120 status = acpi_write(ACPI_X_WAKE_STATUS, &acpi_gbl_FADT.sleep_status);
121 if (ACPI_FAILURE(status)) {
122 return_ACPI_STATUS(status);
123 }
124
125 acpi_gbl_system_awake_and_running = FALSE;
126
127 /* Optionally execute _GTS (Going To Sleep) */
128
129 if (flags & ACPI_EXECUTE_GTS) {
130 acpi_hw_execute_sleep_method(METHOD_PATHNAME__GTS, sleep_state);
131 }
132
133 /* Flush caches, as per ACPI specification */
134
135 ACPI_FLUSH_CPU_CACHE();
136
137 /*
138 * Set the SLP_TYP and SLP_EN bits.
139 *
140 * Note: We only use the first value returned by the \_Sx method
141 * (acpi_gbl_sleep_type_a) - As per ACPI specification.
142 */
143 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
144 "Entering sleep state [S%u]\n", sleep_state));
145
146 sleep_type_value =
147 ((acpi_gbl_sleep_type_a << ACPI_X_SLEEP_TYPE_POSITION) &
148 ACPI_X_SLEEP_TYPE_MASK);
149
150 status = acpi_write((sleep_type_value | ACPI_X_SLEEP_ENABLE),
151 &acpi_gbl_FADT.sleep_control);
152 if (ACPI_FAILURE(status)) {
153 return_ACPI_STATUS(status);
154 }
155
156 /* Wait for transition back to Working State */
157
158 do {
159 status = acpi_read(&sleep_status, &acpi_gbl_FADT.sleep_status);
160 if (ACPI_FAILURE(status)) {
161 return_ACPI_STATUS(status);
162 }
163
164 } while (!(((u8)sleep_status) & ACPI_X_WAKE_STATUS));
165
166 return_ACPI_STATUS(AE_OK);
167}
168
169/*******************************************************************************
170 *
171 * FUNCTION: acpi_hw_extended_wake_prep
172 *
173 * PARAMETERS: sleep_state - Which sleep state we just exited
174 * Flags - ACPI_EXECUTE_BFS to run optional method
175 *
176 * RETURN: Status
177 *
178 * DESCRIPTION: Perform first part of OS-independent ACPI cleanup after
179 * a sleep. Called with interrupts ENABLED.
180 *
181 ******************************************************************************/
182
183acpi_status acpi_hw_extended_wake_prep(u8 sleep_state, u8 flags)
184{
185 acpi_status status;
186 u8 sleep_type_value;
187
188 ACPI_FUNCTION_TRACE(hw_extended_wake_prep);
189
190 status = acpi_get_sleep_type_data(ACPI_STATE_S0,
191 &acpi_gbl_sleep_type_a,
192 &acpi_gbl_sleep_type_b);
193 if (ACPI_SUCCESS(status)) {
194 sleep_type_value =
195 ((acpi_gbl_sleep_type_a << ACPI_X_SLEEP_TYPE_POSITION) &
196 ACPI_X_SLEEP_TYPE_MASK);
197
198 (void)acpi_write((sleep_type_value | ACPI_X_SLEEP_ENABLE),
199 &acpi_gbl_FADT.sleep_control);
200 }
201
202 /* Optionally execute _BFS (Back From Sleep) */
203
204 if (flags & ACPI_EXECUTE_BFS) {
205 acpi_hw_execute_sleep_method(METHOD_PATHNAME__BFS, sleep_state);
206 }
207 return_ACPI_STATUS(AE_OK);
208}
209
210/*******************************************************************************
211 *
212 * FUNCTION: acpi_hw_extended_wake
213 *
214 * PARAMETERS: sleep_state - Which sleep state we just exited
215 * Flags - Reserved, set to zero
216 *
217 * RETURN: Status
218 *
219 * DESCRIPTION: Perform OS-independent ACPI cleanup after a sleep
220 * Called with interrupts ENABLED.
221 *
222 ******************************************************************************/
223
224acpi_status acpi_hw_extended_wake(u8 sleep_state, u8 flags)
225{
226 ACPI_FUNCTION_TRACE(hw_extended_wake);
227
228 /* Ensure enter_sleep_state_prep -> enter_sleep_state ordering */
229
230 acpi_gbl_sleep_type_a = ACPI_SLEEP_TYPE_INVALID;
231
232 /* Execute the wake methods */
233
234 acpi_hw_execute_sleep_method(METHOD_PATHNAME__SST, ACPI_SST_WAKING);
235 acpi_hw_execute_sleep_method(METHOD_PATHNAME__WAK, sleep_state);
236
237 /*
238 * Some BIOS code assumes that WAK_STS will be cleared on resume
239 * and use it to determine whether the system is rebooting or
240 * resuming. Clear WAK_STS for compatibility.
241 */
242 (void)acpi_write(ACPI_X_WAKE_STATUS, &acpi_gbl_FADT.sleep_status);
243 acpi_gbl_system_awake_and_running = TRUE;
244
245 acpi_hw_execute_sleep_method(METHOD_PATHNAME__SST, ACPI_SST_WORKING);
246 return_ACPI_STATUS(AE_OK);
247}
diff --git a/drivers/acpi/acpica/hwgpe.c b/drivers/acpi/acpica/hwgpe.c
index 1a6894afef79..25bd28c4ae8d 100644
--- a/drivers/acpi/acpica/hwgpe.c
+++ b/drivers/acpi/acpica/hwgpe.c
@@ -48,7 +48,7 @@
48 48
49#define _COMPONENT ACPI_HARDWARE 49#define _COMPONENT ACPI_HARDWARE
50ACPI_MODULE_NAME("hwgpe") 50ACPI_MODULE_NAME("hwgpe")
51 51#if (!ACPI_REDUCED_HARDWARE) /* Entire module */
52/* Local prototypes */ 52/* Local prototypes */
53static acpi_status 53static acpi_status
54acpi_hw_enable_wakeup_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info, 54acpi_hw_enable_wakeup_gpe_block(struct acpi_gpe_xrupt_info *gpe_xrupt_info,
@@ -479,3 +479,5 @@ acpi_status acpi_hw_enable_all_wakeup_gpes(void)
479 status = acpi_ev_walk_gpe_list(acpi_hw_enable_wakeup_gpe_block, NULL); 479 status = acpi_ev_walk_gpe_list(acpi_hw_enable_wakeup_gpe_block, NULL);
480 return_ACPI_STATUS(status); 480 return_ACPI_STATUS(status);
481} 481}
482
483#endif /* !ACPI_REDUCED_HARDWARE */
diff --git a/drivers/acpi/acpica/hwregs.c b/drivers/acpi/acpica/hwregs.c
index 4ea4eeb51bfd..6b6c83b87b52 100644
--- a/drivers/acpi/acpica/hwregs.c
+++ b/drivers/acpi/acpica/hwregs.c
@@ -51,6 +51,7 @@
51#define _COMPONENT ACPI_HARDWARE 51#define _COMPONENT ACPI_HARDWARE
52ACPI_MODULE_NAME("hwregs") 52ACPI_MODULE_NAME("hwregs")
53 53
54#if (!ACPI_REDUCED_HARDWARE)
54/* Local Prototypes */ 55/* Local Prototypes */
55static acpi_status 56static acpi_status
56acpi_hw_read_multiple(u32 *value, 57acpi_hw_read_multiple(u32 *value,
@@ -62,6 +63,8 @@ acpi_hw_write_multiple(u32 value,
62 struct acpi_generic_address *register_a, 63 struct acpi_generic_address *register_a,
63 struct acpi_generic_address *register_b); 64 struct acpi_generic_address *register_b);
64 65
66#endif /* !ACPI_REDUCED_HARDWARE */
67
65/****************************************************************************** 68/******************************************************************************
66 * 69 *
67 * FUNCTION: acpi_hw_validate_register 70 * FUNCTION: acpi_hw_validate_register
@@ -154,6 +157,7 @@ acpi_hw_validate_register(struct acpi_generic_address *reg,
154acpi_status acpi_hw_read(u32 *value, struct acpi_generic_address *reg) 157acpi_status acpi_hw_read(u32 *value, struct acpi_generic_address *reg)
155{ 158{
156 u64 address; 159 u64 address;
160 u64 value64;
157 acpi_status status; 161 acpi_status status;
158 162
159 ACPI_FUNCTION_NAME(hw_read); 163 ACPI_FUNCTION_NAME(hw_read);
@@ -175,7 +179,9 @@ acpi_status acpi_hw_read(u32 *value, struct acpi_generic_address *reg)
175 */ 179 */
176 if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) { 180 if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) {
177 status = acpi_os_read_memory((acpi_physical_address) 181 status = acpi_os_read_memory((acpi_physical_address)
178 address, value, reg->bit_width); 182 address, &value64, reg->bit_width);
183
184 *value = (u32)value64;
179 } else { /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ 185 } else { /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */
180 186
181 status = acpi_hw_read_port((acpi_io_address) 187 status = acpi_hw_read_port((acpi_io_address)
@@ -225,7 +231,8 @@ acpi_status acpi_hw_write(u32 value, struct acpi_generic_address *reg)
225 */ 231 */
226 if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) { 232 if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) {
227 status = acpi_os_write_memory((acpi_physical_address) 233 status = acpi_os_write_memory((acpi_physical_address)
228 address, value, reg->bit_width); 234 address, (u64)value,
235 reg->bit_width);
229 } else { /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ 236 } else { /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */
230 237
231 status = acpi_hw_write_port((acpi_io_address) 238 status = acpi_hw_write_port((acpi_io_address)
@@ -240,6 +247,7 @@ acpi_status acpi_hw_write(u32 value, struct acpi_generic_address *reg)
240 return (status); 247 return (status);
241} 248}
242 249
250#if (!ACPI_REDUCED_HARDWARE)
243/******************************************************************************* 251/*******************************************************************************
244 * 252 *
245 * FUNCTION: acpi_hw_clear_acpi_status 253 * FUNCTION: acpi_hw_clear_acpi_status
@@ -285,7 +293,7 @@ exit:
285 293
286/******************************************************************************* 294/*******************************************************************************
287 * 295 *
288 * FUNCTION: acpi_hw_get_register_bit_mask 296 * FUNCTION: acpi_hw_get_bit_register_info
289 * 297 *
290 * PARAMETERS: register_id - Index of ACPI Register to access 298 * PARAMETERS: register_id - Index of ACPI Register to access
291 * 299 *
@@ -658,3 +666,5 @@ acpi_hw_write_multiple(u32 value,
658 666
659 return (status); 667 return (status);
660} 668}
669
670#endif /* !ACPI_REDUCED_HARDWARE */
diff --git a/drivers/acpi/acpica/hwsleep.c b/drivers/acpi/acpica/hwsleep.c
index 3c4a922a9fc2..8ab325cefa68 100644
--- a/drivers/acpi/acpica/hwsleep.c
+++ b/drivers/acpi/acpica/hwsleep.c
@@ -1,7 +1,7 @@
1
2/****************************************************************************** 1/******************************************************************************
3 * 2 *
4 * Name: hwsleep.c - ACPI Hardware Sleep/Wake Interface 3 * Name: hwsleep.c - ACPI Hardware Sleep/Wake Support functions for the
4 * original/legacy sleep/PM registers.
5 * 5 *
6 *****************************************************************************/ 6 *****************************************************************************/
7 7
@@ -44,212 +44,36 @@
44 44
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include "accommon.h" 46#include "accommon.h"
47#include "actables.h"
48#include <linux/tboot.h> 47#include <linux/tboot.h>
49#include <linux/module.h> 48#include <linux/module.h>
50 49
51#define _COMPONENT ACPI_HARDWARE 50#define _COMPONENT ACPI_HARDWARE
52ACPI_MODULE_NAME("hwsleep") 51ACPI_MODULE_NAME("hwsleep")
53 52
53#if (!ACPI_REDUCED_HARDWARE) /* Entire module */
54/******************************************************************************* 54/*******************************************************************************
55 * 55 *
56 * FUNCTION: acpi_set_firmware_waking_vector 56 * FUNCTION: acpi_hw_legacy_sleep
57 *
58 * PARAMETERS: physical_address - 32-bit physical address of ACPI real mode
59 * entry point.
60 *
61 * RETURN: Status
62 *
63 * DESCRIPTION: Sets the 32-bit firmware_waking_vector field of the FACS
64 *
65 ******************************************************************************/
66acpi_status
67acpi_set_firmware_waking_vector(u32 physical_address)
68{
69 ACPI_FUNCTION_TRACE(acpi_set_firmware_waking_vector);
70
71
72 /*
73 * According to the ACPI specification 2.0c and later, the 64-bit
74 * waking vector should be cleared and the 32-bit waking vector should
75 * be used, unless we want the wake-up code to be called by the BIOS in
76 * Protected Mode. Some systems (for example HP dv5-1004nr) are known
77 * to fail to resume if the 64-bit vector is used.
78 */
79
80 /* Set the 32-bit vector */
81
82 acpi_gbl_FACS->firmware_waking_vector = physical_address;
83
84 /* Clear the 64-bit vector if it exists */
85
86 if ((acpi_gbl_FACS->length > 32) && (acpi_gbl_FACS->version >= 1)) {
87 acpi_gbl_FACS->xfirmware_waking_vector = 0;
88 }
89
90 return_ACPI_STATUS(AE_OK);
91}
92
93ACPI_EXPORT_SYMBOL(acpi_set_firmware_waking_vector)
94
95#if ACPI_MACHINE_WIDTH == 64
96/*******************************************************************************
97 *
98 * FUNCTION: acpi_set_firmware_waking_vector64
99 *
100 * PARAMETERS: physical_address - 64-bit physical address of ACPI protected
101 * mode entry point.
102 *
103 * RETURN: Status
104 *
105 * DESCRIPTION: Sets the 64-bit X_firmware_waking_vector field of the FACS, if
106 * it exists in the table. This function is intended for use with
107 * 64-bit host operating systems.
108 *
109 ******************************************************************************/
110acpi_status
111acpi_set_firmware_waking_vector64(u64 physical_address)
112{
113 ACPI_FUNCTION_TRACE(acpi_set_firmware_waking_vector64);
114
115
116 /* Determine if the 64-bit vector actually exists */
117
118 if ((acpi_gbl_FACS->length <= 32) || (acpi_gbl_FACS->version < 1)) {
119 return_ACPI_STATUS(AE_NOT_EXIST);
120 }
121
122 /* Clear 32-bit vector, set the 64-bit X_ vector */
123
124 acpi_gbl_FACS->firmware_waking_vector = 0;
125 acpi_gbl_FACS->xfirmware_waking_vector = physical_address;
126
127 return_ACPI_STATUS(AE_OK);
128}
129
130ACPI_EXPORT_SYMBOL(acpi_set_firmware_waking_vector64)
131#endif
132
133/*******************************************************************************
134 *
135 * FUNCTION: acpi_enter_sleep_state_prep
136 * 57 *
137 * PARAMETERS: sleep_state - Which sleep state to enter 58 * PARAMETERS: sleep_state - Which sleep state to enter
59 * Flags - ACPI_EXECUTE_GTS to run optional method
138 * 60 *
139 * RETURN: Status 61 * RETURN: Status
140 * 62 *
141 * DESCRIPTION: Prepare to enter a system sleep state (see ACPI 2.0 spec p 231) 63 * DESCRIPTION: Enter a system sleep state via the legacy FADT PM registers
142 * This function must execute with interrupts enabled.
143 * We break sleeping into 2 stages so that OSPM can handle
144 * various OS-specific tasks between the two steps.
145 *
146 ******************************************************************************/
147acpi_status acpi_enter_sleep_state_prep(u8 sleep_state)
148{
149 acpi_status status;
150 struct acpi_object_list arg_list;
151 union acpi_object arg;
152
153 ACPI_FUNCTION_TRACE(acpi_enter_sleep_state_prep);
154
155 /* _PSW methods could be run here to enable wake-on keyboard, LAN, etc. */
156
157 status = acpi_get_sleep_type_data(sleep_state,
158 &acpi_gbl_sleep_type_a,
159 &acpi_gbl_sleep_type_b);
160 if (ACPI_FAILURE(status)) {
161 return_ACPI_STATUS(status);
162 }
163
164 /* Setup parameter object */
165
166 arg_list.count = 1;
167 arg_list.pointer = &arg;
168
169 arg.type = ACPI_TYPE_INTEGER;
170 arg.integer.value = sleep_state;
171
172 /* Run the _PTS method */
173
174 status = acpi_evaluate_object(NULL, METHOD_NAME__PTS, &arg_list, NULL);
175 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
176 return_ACPI_STATUS(status);
177 }
178
179 /* Setup the argument to _SST */
180
181 switch (sleep_state) {
182 case ACPI_STATE_S0:
183 arg.integer.value = ACPI_SST_WORKING;
184 break;
185
186 case ACPI_STATE_S1:
187 case ACPI_STATE_S2:
188 case ACPI_STATE_S3:
189 arg.integer.value = ACPI_SST_SLEEPING;
190 break;
191
192 case ACPI_STATE_S4:
193 arg.integer.value = ACPI_SST_SLEEP_CONTEXT;
194 break;
195
196 default:
197 arg.integer.value = ACPI_SST_INDICATOR_OFF; /* Default is off */
198 break;
199 }
200
201 /*
202 * Set the system indicators to show the desired sleep state.
203 * _SST is an optional method (return no error if not found)
204 */
205 status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL);
206 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
207 ACPI_EXCEPTION((AE_INFO, status,
208 "While executing method _SST"));
209 }
210
211 return_ACPI_STATUS(AE_OK);
212}
213
214ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state_prep)
215
216static unsigned int gts, bfs;
217module_param(gts, uint, 0644);
218module_param(bfs, uint, 0644);
219MODULE_PARM_DESC(gts, "Enable evaluation of _GTS on suspend.");
220MODULE_PARM_DESC(bfs, "Enable evaluation of _BFS on resume".);
221
222/*******************************************************************************
223 *
224 * FUNCTION: acpi_enter_sleep_state
225 *
226 * PARAMETERS: sleep_state - Which sleep state to enter
227 *
228 * RETURN: Status
229 *
230 * DESCRIPTION: Enter a system sleep state (see ACPI 2.0 spec p 231)
231 * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED 64 * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
232 * 65 *
233 ******************************************************************************/ 66 ******************************************************************************/
234acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state) 67acpi_status acpi_hw_legacy_sleep(u8 sleep_state, u8 flags)
235{ 68{
236 u32 pm1a_control;
237 u32 pm1b_control;
238 struct acpi_bit_register_info *sleep_type_reg_info; 69 struct acpi_bit_register_info *sleep_type_reg_info;
239 struct acpi_bit_register_info *sleep_enable_reg_info; 70 struct acpi_bit_register_info *sleep_enable_reg_info;
71 u32 pm1a_control;
72 u32 pm1b_control;
240 u32 in_value; 73 u32 in_value;
241 struct acpi_object_list arg_list;
242 union acpi_object arg;
243 acpi_status status; 74 acpi_status status;
244 75
245 ACPI_FUNCTION_TRACE(acpi_enter_sleep_state); 76 ACPI_FUNCTION_TRACE(hw_legacy_sleep);
246
247 if ((acpi_gbl_sleep_type_a > ACPI_SLEEP_TYPE_MAX) ||
248 (acpi_gbl_sleep_type_b > ACPI_SLEEP_TYPE_MAX)) {
249 ACPI_ERROR((AE_INFO, "Sleep values out of range: A=0x%X B=0x%X",
250 acpi_gbl_sleep_type_a, acpi_gbl_sleep_type_b));
251 return_ACPI_STATUS(AE_AML_OPERAND_VALUE);
252 }
253 77
254 sleep_type_reg_info = 78 sleep_type_reg_info =
255 acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_TYPE); 79 acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_TYPE);
@@ -271,6 +95,18 @@ acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state)
271 return_ACPI_STATUS(status); 95 return_ACPI_STATUS(status);
272 } 96 }
273 97
98 if (sleep_state != ACPI_STATE_S5) {
99 /*
100 * Disable BM arbitration. This feature is contained within an
101 * optional register (PM2 Control), so ignore a BAD_ADDRESS
102 * exception.
103 */
104 status = acpi_write_bit_register(ACPI_BITREG_ARB_DISABLE, 1);
105 if (ACPI_FAILURE(status) && (status != AE_BAD_ADDRESS)) {
106 return_ACPI_STATUS(status);
107 }
108 }
109
274 /* 110 /*
275 * 1) Disable/Clear all GPEs 111 * 1) Disable/Clear all GPEs
276 * 2) Enable all wakeup GPEs 112 * 2) Enable all wakeup GPEs
@@ -286,18 +122,10 @@ acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state)
286 return_ACPI_STATUS(status); 122 return_ACPI_STATUS(status);
287 } 123 }
288 124
289 if (gts) { 125 /* Optionally execute _GTS (Going To Sleep) */
290 /* Execute the _GTS method */
291 126
292 arg_list.count = 1; 127 if (flags & ACPI_EXECUTE_GTS) {
293 arg_list.pointer = &arg; 128 acpi_hw_execute_sleep_method(METHOD_PATHNAME__GTS, sleep_state);
294 arg.type = ACPI_TYPE_INTEGER;
295 arg.integer.value = sleep_state;
296
297 status = acpi_evaluate_object(NULL, METHOD_NAME__GTS, &arg_list, NULL);
298 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
299 return_ACPI_STATUS(status);
300 }
301 } 129 }
302 130
303 /* Get current value of PM1A control */ 131 /* Get current value of PM1A control */
@@ -375,114 +203,44 @@ acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state)
375 } 203 }
376 } 204 }
377 205
378 /* Wait until we enter sleep state */ 206 /* Wait for transition back to Working State */
379 207
380 do { 208 do {
381 status = acpi_read_bit_register(ACPI_BITREG_WAKE_STATUS,
382 &in_value);
383 if (ACPI_FAILURE(status)) {
384 return_ACPI_STATUS(status);
385 }
386
387 /* Spin until we wake */
388
389 } while (!in_value);
390
391 return_ACPI_STATUS(AE_OK);
392}
393
394ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state)
395
396/*******************************************************************************
397 *
398 * FUNCTION: acpi_enter_sleep_state_s4bios
399 *
400 * PARAMETERS: None
401 *
402 * RETURN: Status
403 *
404 * DESCRIPTION: Perform a S4 bios request.
405 * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
406 *
407 ******************************************************************************/
408acpi_status asmlinkage acpi_enter_sleep_state_s4bios(void)
409{
410 u32 in_value;
411 acpi_status status;
412
413 ACPI_FUNCTION_TRACE(acpi_enter_sleep_state_s4bios);
414
415 /* Clear the wake status bit (PM1) */
416
417 status =
418 acpi_write_bit_register(ACPI_BITREG_WAKE_STATUS, ACPI_CLEAR_STATUS);
419 if (ACPI_FAILURE(status)) {
420 return_ACPI_STATUS(status);
421 }
422
423 status = acpi_hw_clear_acpi_status();
424 if (ACPI_FAILURE(status)) {
425 return_ACPI_STATUS(status);
426 }
427
428 /*
429 * 1) Disable/Clear all GPEs
430 * 2) Enable all wakeup GPEs
431 */
432 status = acpi_hw_disable_all_gpes();
433 if (ACPI_FAILURE(status)) {
434 return_ACPI_STATUS(status);
435 }
436 acpi_gbl_system_awake_and_running = FALSE;
437
438 status = acpi_hw_enable_all_wakeup_gpes();
439 if (ACPI_FAILURE(status)) {
440 return_ACPI_STATUS(status);
441 }
442
443 ACPI_FLUSH_CPU_CACHE();
444
445 status = acpi_hw_write_port(acpi_gbl_FADT.smi_command,
446 (u32) acpi_gbl_FADT.S4bios_request, 8);
447
448 do {
449 acpi_os_stall(1000);
450 status = 209 status =
451 acpi_read_bit_register(ACPI_BITREG_WAKE_STATUS, &in_value); 210 acpi_read_bit_register(ACPI_BITREG_WAKE_STATUS, &in_value);
452 if (ACPI_FAILURE(status)) { 211 if (ACPI_FAILURE(status)) {
453 return_ACPI_STATUS(status); 212 return_ACPI_STATUS(status);
454 } 213 }
214
455 } while (!in_value); 215 } while (!in_value);
456 216
457 return_ACPI_STATUS(AE_OK); 217 return_ACPI_STATUS(AE_OK);
458} 218}
459 219
460ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state_s4bios)
461
462/******************************************************************************* 220/*******************************************************************************
463 * 221 *
464 * FUNCTION: acpi_leave_sleep_state_prep 222 * FUNCTION: acpi_hw_legacy_wake_prep
465 * 223 *
466 * PARAMETERS: sleep_state - Which sleep state we are exiting 224 * PARAMETERS: sleep_state - Which sleep state we just exited
225 * Flags - ACPI_EXECUTE_BFS to run optional method
467 * 226 *
468 * RETURN: Status 227 * RETURN: Status
469 * 228 *
470 * DESCRIPTION: Perform the first state of OS-independent ACPI cleanup after a 229 * DESCRIPTION: Perform the first state of OS-independent ACPI cleanup after a
471 * sleep. 230 * sleep.
472 * Called with interrupts DISABLED. 231 * Called with interrupts ENABLED.
473 * 232 *
474 ******************************************************************************/ 233 ******************************************************************************/
475acpi_status acpi_leave_sleep_state_prep(u8 sleep_state) 234
235acpi_status acpi_hw_legacy_wake_prep(u8 sleep_state, u8 flags)
476{ 236{
477 struct acpi_object_list arg_list;
478 union acpi_object arg;
479 acpi_status status; 237 acpi_status status;
480 struct acpi_bit_register_info *sleep_type_reg_info; 238 struct acpi_bit_register_info *sleep_type_reg_info;
481 struct acpi_bit_register_info *sleep_enable_reg_info; 239 struct acpi_bit_register_info *sleep_enable_reg_info;
482 u32 pm1a_control; 240 u32 pm1a_control;
483 u32 pm1b_control; 241 u32 pm1b_control;
484 242
485 ACPI_FUNCTION_TRACE(acpi_leave_sleep_state_prep); 243 ACPI_FUNCTION_TRACE(hw_legacy_wake_prep);
486 244
487 /* 245 /*
488 * Set SLP_TYPE and SLP_EN to state S0. 246 * Set SLP_TYPE and SLP_EN to state S0.
@@ -525,27 +283,20 @@ acpi_status acpi_leave_sleep_state_prep(u8 sleep_state)
525 } 283 }
526 } 284 }
527 285
528 if (bfs) { 286 /* Optionally execute _BFS (Back From Sleep) */
529 /* Execute the _BFS method */
530 287
531 arg_list.count = 1; 288 if (flags & ACPI_EXECUTE_BFS) {
532 arg_list.pointer = &arg; 289 acpi_hw_execute_sleep_method(METHOD_PATHNAME__BFS, sleep_state);
533 arg.type = ACPI_TYPE_INTEGER;
534 arg.integer.value = sleep_state;
535
536 status = acpi_evaluate_object(NULL, METHOD_NAME__BFS, &arg_list, NULL);
537 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
538 ACPI_EXCEPTION((AE_INFO, status, "During Method _BFS"));
539 }
540 } 290 }
541 return_ACPI_STATUS(status); 291 return_ACPI_STATUS(status);
542} 292}
543 293
544/******************************************************************************* 294/*******************************************************************************
545 * 295 *
546 * FUNCTION: acpi_leave_sleep_state 296 * FUNCTION: acpi_hw_legacy_wake
547 * 297 *
548 * PARAMETERS: sleep_state - Which sleep state we just exited 298 * PARAMETERS: sleep_state - Which sleep state we just exited
299 * Flags - Reserved, set to zero
549 * 300 *
550 * RETURN: Status 301 * RETURN: Status
551 * 302 *
@@ -553,31 +304,17 @@ acpi_status acpi_leave_sleep_state_prep(u8 sleep_state)
553 * Called with interrupts ENABLED. 304 * Called with interrupts ENABLED.
554 * 305 *
555 ******************************************************************************/ 306 ******************************************************************************/
556acpi_status acpi_leave_sleep_state(u8 sleep_state) 307
308acpi_status acpi_hw_legacy_wake(u8 sleep_state, u8 flags)
557{ 309{
558 struct acpi_object_list arg_list;
559 union acpi_object arg;
560 acpi_status status; 310 acpi_status status;
561 311
562 ACPI_FUNCTION_TRACE(acpi_leave_sleep_state); 312 ACPI_FUNCTION_TRACE(hw_legacy_wake);
563 313
564 /* Ensure enter_sleep_state_prep -> enter_sleep_state ordering */ 314 /* Ensure enter_sleep_state_prep -> enter_sleep_state ordering */
565 315
566 acpi_gbl_sleep_type_a = ACPI_SLEEP_TYPE_INVALID; 316 acpi_gbl_sleep_type_a = ACPI_SLEEP_TYPE_INVALID;
567 317 acpi_hw_execute_sleep_method(METHOD_PATHNAME__SST, ACPI_SST_WAKING);
568 /* Setup parameter object */
569
570 arg_list.count = 1;
571 arg_list.pointer = &arg;
572 arg.type = ACPI_TYPE_INTEGER;
573
574 /* Ignore any errors from these methods */
575
576 arg.integer.value = ACPI_SST_WAKING;
577 status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL);
578 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
579 ACPI_EXCEPTION((AE_INFO, status, "During Method _SST"));
580 }
581 318
582 /* 319 /*
583 * GPEs must be enabled before _WAK is called as GPEs 320 * GPEs must be enabled before _WAK is called as GPEs
@@ -591,46 +328,50 @@ acpi_status acpi_leave_sleep_state(u8 sleep_state)
591 if (ACPI_FAILURE(status)) { 328 if (ACPI_FAILURE(status)) {
592 return_ACPI_STATUS(status); 329 return_ACPI_STATUS(status);
593 } 330 }
331
594 status = acpi_hw_enable_all_runtime_gpes(); 332 status = acpi_hw_enable_all_runtime_gpes();
595 if (ACPI_FAILURE(status)) { 333 if (ACPI_FAILURE(status)) {
596 return_ACPI_STATUS(status); 334 return_ACPI_STATUS(status);
597 } 335 }
598 336
599 arg.integer.value = sleep_state; 337 /*
600 status = acpi_evaluate_object(NULL, METHOD_NAME__WAK, &arg_list, NULL); 338 * Now we can execute _WAK, etc. Some machines require that the GPEs
601 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { 339 * are enabled before the wake methods are executed.
602 ACPI_EXCEPTION((AE_INFO, status, "During Method _WAK")); 340 */
603 } 341 acpi_hw_execute_sleep_method(METHOD_PATHNAME__WAK, sleep_state);
604 /* TBD: _WAK "sometimes" returns stuff - do we want to look at it? */
605 342
606 /* 343 /*
607 * Some BIOSes assume that WAK_STS will be cleared on resume and use 344 * Some BIOS code assumes that WAK_STS will be cleared on resume
608 * it to determine whether the system is rebooting or resuming. Clear 345 * and use it to determine whether the system is rebooting or
609 * it for compatibility. 346 * resuming. Clear WAK_STS for compatibility.
610 */ 347 */
611 acpi_write_bit_register(ACPI_BITREG_WAKE_STATUS, 1); 348 acpi_write_bit_register(ACPI_BITREG_WAKE_STATUS, 1);
612
613 acpi_gbl_system_awake_and_running = TRUE; 349 acpi_gbl_system_awake_and_running = TRUE;
614 350
615 /* Enable power button */ 351 /* Enable power button */
616 352
617 (void) 353 (void)
618 acpi_write_bit_register(acpi_gbl_fixed_event_info 354 acpi_write_bit_register(acpi_gbl_fixed_event_info
619 [ACPI_EVENT_POWER_BUTTON]. 355 [ACPI_EVENT_POWER_BUTTON].
620 enable_register_id, ACPI_ENABLE_EVENT); 356 enable_register_id, ACPI_ENABLE_EVENT);
621 357
622 (void) 358 (void)
623 acpi_write_bit_register(acpi_gbl_fixed_event_info 359 acpi_write_bit_register(acpi_gbl_fixed_event_info
624 [ACPI_EVENT_POWER_BUTTON]. 360 [ACPI_EVENT_POWER_BUTTON].
625 status_register_id, ACPI_CLEAR_STATUS); 361 status_register_id, ACPI_CLEAR_STATUS);
626 362
627 arg.integer.value = ACPI_SST_WORKING; 363 /*
628 status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL); 364 * Enable BM arbitration. This feature is contained within an
629 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { 365 * optional register (PM2 Control), so ignore a BAD_ADDRESS
630 ACPI_EXCEPTION((AE_INFO, status, "During Method _SST")); 366 * exception.
367 */
368 status = acpi_write_bit_register(ACPI_BITREG_ARB_DISABLE, 0);
369 if (ACPI_FAILURE(status) && (status != AE_BAD_ADDRESS)) {
370 return_ACPI_STATUS(status);
631 } 371 }
632 372
373 acpi_hw_execute_sleep_method(METHOD_PATHNAME__SST, ACPI_SST_WORKING);
633 return_ACPI_STATUS(status); 374 return_ACPI_STATUS(status);
634} 375}
635 376
636ACPI_EXPORT_SYMBOL(acpi_leave_sleep_state) 377#endif /* !ACPI_REDUCED_HARDWARE */
diff --git a/drivers/acpi/acpica/hwtimer.c b/drivers/acpi/acpica/hwtimer.c
index d4973d9da9f1..f1b2c3b94cac 100644
--- a/drivers/acpi/acpica/hwtimer.c
+++ b/drivers/acpi/acpica/hwtimer.c
@@ -49,6 +49,7 @@
49#define _COMPONENT ACPI_HARDWARE 49#define _COMPONENT ACPI_HARDWARE
50ACPI_MODULE_NAME("hwtimer") 50ACPI_MODULE_NAME("hwtimer")
51 51
52#if (!ACPI_REDUCED_HARDWARE) /* Entire module */
52/****************************************************************************** 53/******************************************************************************
53 * 54 *
54 * FUNCTION: acpi_get_timer_resolution 55 * FUNCTION: acpi_get_timer_resolution
@@ -187,3 +188,4 @@ acpi_get_timer_duration(u32 start_ticks, u32 end_ticks, u32 * time_elapsed)
187} 188}
188 189
189ACPI_EXPORT_SYMBOL(acpi_get_timer_duration) 190ACPI_EXPORT_SYMBOL(acpi_get_timer_duration)
191#endif /* !ACPI_REDUCED_HARDWARE */
diff --git a/drivers/acpi/acpica/hwxface.c b/drivers/acpi/acpica/hwxface.c
index 9d38eb6c0d0b..ab513a972c95 100644
--- a/drivers/acpi/acpica/hwxface.c
+++ b/drivers/acpi/acpica/hwxface.c
@@ -74,8 +74,7 @@ acpi_status acpi_reset(void)
74 74
75 /* Check if the reset register is supported */ 75 /* Check if the reset register is supported */
76 76
77 if (!(acpi_gbl_FADT.flags & ACPI_FADT_RESET_REGISTER) || 77 if (!reset_reg->address) {
78 !reset_reg->address) {
79 return_ACPI_STATUS(AE_NOT_EXIST); 78 return_ACPI_STATUS(AE_NOT_EXIST);
80 } 79 }
81 80
@@ -138,11 +137,6 @@ acpi_status acpi_read(u64 *return_value, struct acpi_generic_address *reg)
138 return (status); 137 return (status);
139 } 138 }
140 139
141 width = reg->bit_width;
142 if (width == 64) {
143 width = 32; /* Break into two 32-bit transfers */
144 }
145
146 /* Initialize entire 64-bit return value to zero */ 140 /* Initialize entire 64-bit return value to zero */
147 141
148 *return_value = 0; 142 *return_value = 0;
@@ -154,24 +148,17 @@ acpi_status acpi_read(u64 *return_value, struct acpi_generic_address *reg)
154 */ 148 */
155 if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) { 149 if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) {
156 status = acpi_os_read_memory((acpi_physical_address) 150 status = acpi_os_read_memory((acpi_physical_address)
157 address, &value, width); 151 address, return_value,
152 reg->bit_width);
158 if (ACPI_FAILURE(status)) { 153 if (ACPI_FAILURE(status)) {
159 return (status); 154 return (status);
160 } 155 }
161 *return_value = value; 156 } else { /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */
162
163 if (reg->bit_width == 64) {
164
165 /* Read the top 32 bits */
166 157
167 status = acpi_os_read_memory((acpi_physical_address) 158 width = reg->bit_width;
168 (address + 4), &value, 32); 159 if (width == 64) {
169 if (ACPI_FAILURE(status)) { 160 width = 32; /* Break into two 32-bit transfers */
170 return (status);
171 }
172 *return_value |= ((u64)value << 32);
173 } 161 }
174 } else { /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */
175 162
176 status = acpi_hw_read_port((acpi_io_address) 163 status = acpi_hw_read_port((acpi_io_address)
177 address, &value, width); 164 address, &value, width);
@@ -231,32 +218,22 @@ acpi_status acpi_write(u64 value, struct acpi_generic_address *reg)
231 return (status); 218 return (status);
232 } 219 }
233 220
234 width = reg->bit_width;
235 if (width == 64) {
236 width = 32; /* Break into two 32-bit transfers */
237 }
238
239 /* 221 /*
240 * Two address spaces supported: Memory or IO. PCI_Config is 222 * Two address spaces supported: Memory or IO. PCI_Config is
241 * not supported here because the GAS structure is insufficient 223 * not supported here because the GAS structure is insufficient
242 */ 224 */
243 if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) { 225 if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) {
244 status = acpi_os_write_memory((acpi_physical_address) 226 status = acpi_os_write_memory((acpi_physical_address)
245 address, ACPI_LODWORD(value), 227 address, value, reg->bit_width);
246 width);
247 if (ACPI_FAILURE(status)) { 228 if (ACPI_FAILURE(status)) {
248 return (status); 229 return (status);
249 } 230 }
231 } else { /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */
250 232
251 if (reg->bit_width == 64) { 233 width = reg->bit_width;
252 status = acpi_os_write_memory((acpi_physical_address) 234 if (width == 64) {
253 (address + 4), 235 width = 32; /* Break into two 32-bit transfers */
254 ACPI_HIDWORD(value), 32);
255 if (ACPI_FAILURE(status)) {
256 return (status);
257 }
258 } 236 }
259 } else { /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */
260 237
261 status = acpi_hw_write_port((acpi_io_address) 238 status = acpi_hw_write_port((acpi_io_address)
262 address, ACPI_LODWORD(value), 239 address, ACPI_LODWORD(value),
@@ -286,6 +263,7 @@ acpi_status acpi_write(u64 value, struct acpi_generic_address *reg)
286 263
287ACPI_EXPORT_SYMBOL(acpi_write) 264ACPI_EXPORT_SYMBOL(acpi_write)
288 265
266#if (!ACPI_REDUCED_HARDWARE)
289/******************************************************************************* 267/*******************************************************************************
290 * 268 *
291 * FUNCTION: acpi_read_bit_register 269 * FUNCTION: acpi_read_bit_register
@@ -453,7 +431,7 @@ unlock_and_exit:
453} 431}
454 432
455ACPI_EXPORT_SYMBOL(acpi_write_bit_register) 433ACPI_EXPORT_SYMBOL(acpi_write_bit_register)
456 434#endif /* !ACPI_REDUCED_HARDWARE */
457/******************************************************************************* 435/*******************************************************************************
458 * 436 *
459 * FUNCTION: acpi_get_sleep_type_data 437 * FUNCTION: acpi_get_sleep_type_data
diff --git a/drivers/acpi/acpica/hwxfsleep.c b/drivers/acpi/acpica/hwxfsleep.c
new file mode 100644
index 000000000000..762d059bb508
--- /dev/null
+++ b/drivers/acpi/acpica/hwxfsleep.c
@@ -0,0 +1,431 @@
1/******************************************************************************
2 *
3 * Name: hwxfsleep.c - ACPI Hardware Sleep/Wake External Interfaces
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2012, 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 <linux/module.h>
47
48#define _COMPONENT ACPI_HARDWARE
49ACPI_MODULE_NAME("hwxfsleep")
50
51/* Local prototypes */
52static acpi_status
53acpi_hw_sleep_dispatch(u8 sleep_state, u8 flags, u32 function_id);
54
55/*
56 * Dispatch table used to efficiently branch to the various sleep
57 * functions.
58 */
59#define ACPI_SLEEP_FUNCTION_ID 0
60#define ACPI_WAKE_PREP_FUNCTION_ID 1
61#define ACPI_WAKE_FUNCTION_ID 2
62
63/* Legacy functions are optional, based upon ACPI_REDUCED_HARDWARE */
64
65static struct acpi_sleep_functions acpi_sleep_dispatch[] = {
66 {ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_sleep),
67 acpi_hw_extended_sleep},
68 {ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_wake_prep),
69 acpi_hw_extended_wake_prep},
70 {ACPI_HW_OPTIONAL_FUNCTION(acpi_hw_legacy_wake), acpi_hw_extended_wake}
71};
72
73/*
74 * These functions are removed for the ACPI_REDUCED_HARDWARE case:
75 * acpi_set_firmware_waking_vector
76 * acpi_set_firmware_waking_vector64
77 * acpi_enter_sleep_state_s4bios
78 */
79
80#if (!ACPI_REDUCED_HARDWARE)
81/*******************************************************************************
82 *
83 * FUNCTION: acpi_set_firmware_waking_vector
84 *
85 * PARAMETERS: physical_address - 32-bit physical address of ACPI real mode
86 * entry point.
87 *
88 * RETURN: Status
89 *
90 * DESCRIPTION: Sets the 32-bit firmware_waking_vector field of the FACS
91 *
92 ******************************************************************************/
93
94acpi_status acpi_set_firmware_waking_vector(u32 physical_address)
95{
96 ACPI_FUNCTION_TRACE(acpi_set_firmware_waking_vector);
97
98
99 /*
100 * According to the ACPI specification 2.0c and later, the 64-bit
101 * waking vector should be cleared and the 32-bit waking vector should
102 * be used, unless we want the wake-up code to be called by the BIOS in
103 * Protected Mode. Some systems (for example HP dv5-1004nr) are known
104 * to fail to resume if the 64-bit vector is used.
105 */
106
107 /* Set the 32-bit vector */
108
109 acpi_gbl_FACS->firmware_waking_vector = physical_address;
110
111 /* Clear the 64-bit vector if it exists */
112
113 if ((acpi_gbl_FACS->length > 32) && (acpi_gbl_FACS->version >= 1)) {
114 acpi_gbl_FACS->xfirmware_waking_vector = 0;
115 }
116
117 return_ACPI_STATUS(AE_OK);
118}
119
120ACPI_EXPORT_SYMBOL(acpi_set_firmware_waking_vector)
121
122#if ACPI_MACHINE_WIDTH == 64
123/*******************************************************************************
124 *
125 * FUNCTION: acpi_set_firmware_waking_vector64
126 *
127 * PARAMETERS: physical_address - 64-bit physical address of ACPI protected
128 * mode entry point.
129 *
130 * RETURN: Status
131 *
132 * DESCRIPTION: Sets the 64-bit X_firmware_waking_vector field of the FACS, if
133 * it exists in the table. This function is intended for use with
134 * 64-bit host operating systems.
135 *
136 ******************************************************************************/
137acpi_status acpi_set_firmware_waking_vector64(u64 physical_address)
138{
139 ACPI_FUNCTION_TRACE(acpi_set_firmware_waking_vector64);
140
141
142 /* Determine if the 64-bit vector actually exists */
143
144 if ((acpi_gbl_FACS->length <= 32) || (acpi_gbl_FACS->version < 1)) {
145 return_ACPI_STATUS(AE_NOT_EXIST);
146 }
147
148 /* Clear 32-bit vector, set the 64-bit X_ vector */
149
150 acpi_gbl_FACS->firmware_waking_vector = 0;
151 acpi_gbl_FACS->xfirmware_waking_vector = physical_address;
152 return_ACPI_STATUS(AE_OK);
153}
154
155ACPI_EXPORT_SYMBOL(acpi_set_firmware_waking_vector64)
156#endif
157
158/*******************************************************************************
159 *
160 * FUNCTION: acpi_enter_sleep_state_s4bios
161 *
162 * PARAMETERS: None
163 *
164 * RETURN: Status
165 *
166 * DESCRIPTION: Perform a S4 bios request.
167 * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
168 *
169 ******************************************************************************/
170acpi_status asmlinkage acpi_enter_sleep_state_s4bios(void)
171{
172 u32 in_value;
173 acpi_status status;
174
175 ACPI_FUNCTION_TRACE(acpi_enter_sleep_state_s4bios);
176
177 /* Clear the wake status bit (PM1) */
178
179 status =
180 acpi_write_bit_register(ACPI_BITREG_WAKE_STATUS, ACPI_CLEAR_STATUS);
181 if (ACPI_FAILURE(status)) {
182 return_ACPI_STATUS(status);
183 }
184
185 status = acpi_hw_clear_acpi_status();
186 if (ACPI_FAILURE(status)) {
187 return_ACPI_STATUS(status);
188 }
189
190 /*
191 * 1) Disable/Clear all GPEs
192 * 2) Enable all wakeup GPEs
193 */
194 status = acpi_hw_disable_all_gpes();
195 if (ACPI_FAILURE(status)) {
196 return_ACPI_STATUS(status);
197 }
198 acpi_gbl_system_awake_and_running = FALSE;
199
200 status = acpi_hw_enable_all_wakeup_gpes();
201 if (ACPI_FAILURE(status)) {
202 return_ACPI_STATUS(status);
203 }
204
205 ACPI_FLUSH_CPU_CACHE();
206
207 status = acpi_hw_write_port(acpi_gbl_FADT.smi_command,
208 (u32)acpi_gbl_FADT.S4bios_request, 8);
209
210 do {
211 acpi_os_stall(1000);
212 status =
213 acpi_read_bit_register(ACPI_BITREG_WAKE_STATUS, &in_value);
214 if (ACPI_FAILURE(status)) {
215 return_ACPI_STATUS(status);
216 }
217 } while (!in_value);
218
219 return_ACPI_STATUS(AE_OK);
220}
221
222ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state_s4bios)
223#endif /* !ACPI_REDUCED_HARDWARE */
224/*******************************************************************************
225 *
226 * FUNCTION: acpi_hw_sleep_dispatch
227 *
228 * PARAMETERS: sleep_state - Which sleep state to enter/exit
229 * function_id - Sleep, wake_prep, or Wake
230 *
231 * RETURN: Status from the invoked sleep handling function.
232 *
233 * DESCRIPTION: Dispatch a sleep/wake request to the appropriate handling
234 * function.
235 *
236 ******************************************************************************/
237static acpi_status
238acpi_hw_sleep_dispatch(u8 sleep_state, u8 flags, u32 function_id)
239{
240 acpi_status status;
241 struct acpi_sleep_functions *sleep_functions =
242 &acpi_sleep_dispatch[function_id];
243
244#if (!ACPI_REDUCED_HARDWARE)
245
246 /*
247 * If the Hardware Reduced flag is set (from the FADT), we must
248 * use the extended sleep registers
249 */
250 if (acpi_gbl_reduced_hardware || acpi_gbl_FADT.sleep_control.address) {
251 status = sleep_functions->extended_function(sleep_state, flags);
252 } else {
253 /* Legacy sleep */
254
255 status = sleep_functions->legacy_function(sleep_state, flags);
256 }
257
258 return (status);
259
260#else
261 /*
262 * For the case where reduced-hardware-only code is being generated,
263 * we know that only the extended sleep registers are available
264 */
265 status = sleep_functions->extended_function(sleep_state, flags);
266 return (status);
267
268#endif /* !ACPI_REDUCED_HARDWARE */
269}
270
271/*******************************************************************************
272 *
273 * FUNCTION: acpi_enter_sleep_state_prep
274 *
275 * PARAMETERS: sleep_state - Which sleep state to enter
276 *
277 * RETURN: Status
278 *
279 * DESCRIPTION: Prepare to enter a system sleep state.
280 * This function must execute with interrupts enabled.
281 * We break sleeping into 2 stages so that OSPM can handle
282 * various OS-specific tasks between the two steps.
283 *
284 ******************************************************************************/
285
286acpi_status acpi_enter_sleep_state_prep(u8 sleep_state)
287{
288 acpi_status status;
289 struct acpi_object_list arg_list;
290 union acpi_object arg;
291 u32 sst_value;
292
293 ACPI_FUNCTION_TRACE(acpi_enter_sleep_state_prep);
294
295 status = acpi_get_sleep_type_data(sleep_state,
296 &acpi_gbl_sleep_type_a,
297 &acpi_gbl_sleep_type_b);
298 if (ACPI_FAILURE(status)) {
299 return_ACPI_STATUS(status);
300 }
301
302 /* Execute the _PTS method (Prepare To Sleep) */
303
304 arg_list.count = 1;
305 arg_list.pointer = &arg;
306 arg.type = ACPI_TYPE_INTEGER;
307 arg.integer.value = sleep_state;
308
309 status =
310 acpi_evaluate_object(NULL, METHOD_PATHNAME__PTS, &arg_list, NULL);
311 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
312 return_ACPI_STATUS(status);
313 }
314
315 /* Setup the argument to the _SST method (System STatus) */
316
317 switch (sleep_state) {
318 case ACPI_STATE_S0:
319 sst_value = ACPI_SST_WORKING;
320 break;
321
322 case ACPI_STATE_S1:
323 case ACPI_STATE_S2:
324 case ACPI_STATE_S3:
325 sst_value = ACPI_SST_SLEEPING;
326 break;
327
328 case ACPI_STATE_S4:
329 sst_value = ACPI_SST_SLEEP_CONTEXT;
330 break;
331
332 default:
333 sst_value = ACPI_SST_INDICATOR_OFF; /* Default is off */
334 break;
335 }
336
337 /*
338 * Set the system indicators to show the desired sleep state.
339 * _SST is an optional method (return no error if not found)
340 */
341 acpi_hw_execute_sleep_method(METHOD_PATHNAME__SST, sst_value);
342 return_ACPI_STATUS(AE_OK);
343}
344
345ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state_prep)
346
347/*******************************************************************************
348 *
349 * FUNCTION: acpi_enter_sleep_state
350 *
351 * PARAMETERS: sleep_state - Which sleep state to enter
352 * Flags - ACPI_EXECUTE_GTS to run optional method
353 *
354 * RETURN: Status
355 *
356 * DESCRIPTION: Enter a system sleep state (see ACPI 2.0 spec p 231)
357 * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
358 *
359 ******************************************************************************/
360acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state, u8 flags)
361{
362 acpi_status status;
363
364 ACPI_FUNCTION_TRACE(acpi_enter_sleep_state);
365
366 if ((acpi_gbl_sleep_type_a > ACPI_SLEEP_TYPE_MAX) ||
367 (acpi_gbl_sleep_type_b > ACPI_SLEEP_TYPE_MAX)) {
368 ACPI_ERROR((AE_INFO, "Sleep values out of range: A=0x%X B=0x%X",
369 acpi_gbl_sleep_type_a, acpi_gbl_sleep_type_b));
370 return_ACPI_STATUS(AE_AML_OPERAND_VALUE);
371 }
372
373 status =
374 acpi_hw_sleep_dispatch(sleep_state, flags, ACPI_SLEEP_FUNCTION_ID);
375 return_ACPI_STATUS(status);
376}
377
378ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state)
379
380/*******************************************************************************
381 *
382 * FUNCTION: acpi_leave_sleep_state_prep
383 *
384 * PARAMETERS: sleep_state - Which sleep state we are exiting
385 * Flags - ACPI_EXECUTE_BFS to run optional method
386 *
387 * RETURN: Status
388 *
389 * DESCRIPTION: Perform the first state of OS-independent ACPI cleanup after a
390 * sleep.
391 * Called with interrupts DISABLED.
392 *
393 ******************************************************************************/
394acpi_status acpi_leave_sleep_state_prep(u8 sleep_state, u8 flags)
395{
396 acpi_status status;
397
398 ACPI_FUNCTION_TRACE(acpi_leave_sleep_state_prep);
399
400 status =
401 acpi_hw_sleep_dispatch(sleep_state, flags,
402 ACPI_WAKE_PREP_FUNCTION_ID);
403 return_ACPI_STATUS(status);
404}
405
406ACPI_EXPORT_SYMBOL(acpi_leave_sleep_state_prep)
407
408/*******************************************************************************
409 *
410 * FUNCTION: acpi_leave_sleep_state
411 *
412 * PARAMETERS: sleep_state - Which sleep state we are exiting
413 *
414 * RETURN: Status
415 *
416 * DESCRIPTION: Perform OS-independent ACPI cleanup after a sleep
417 * Called with interrupts ENABLED.
418 *
419 ******************************************************************************/
420acpi_status acpi_leave_sleep_state(u8 sleep_state)
421{
422 acpi_status status;
423
424 ACPI_FUNCTION_TRACE(acpi_leave_sleep_state);
425
426
427 status = acpi_hw_sleep_dispatch(sleep_state, 0, ACPI_WAKE_FUNCTION_ID);
428 return_ACPI_STATUS(status);
429}
430
431ACPI_EXPORT_SYMBOL(acpi_leave_sleep_state)
diff --git a/drivers/acpi/acpica/nsdump.c b/drivers/acpi/acpica/nsdump.c
index b7f2b3be79ac..3f7f3f6e7dd5 100644
--- a/drivers/acpi/acpica/nsdump.c
+++ b/drivers/acpi/acpica/nsdump.c
@@ -242,7 +242,20 @@ acpi_ns_dump_one_object(acpi_handle obj_handle,
242 242
243 if (!obj_desc) { 243 if (!obj_desc) {
244 244
245 /* No attached object, we are done */ 245 /* No attached object. Some types should always have an object */
246
247 switch (type) {
248 case ACPI_TYPE_INTEGER:
249 case ACPI_TYPE_PACKAGE:
250 case ACPI_TYPE_BUFFER:
251 case ACPI_TYPE_STRING:
252 case ACPI_TYPE_METHOD:
253 acpi_os_printf("<No attached object>");
254 break;
255
256 default:
257 break;
258 }
246 259
247 acpi_os_printf("\n"); 260 acpi_os_printf("\n");
248 return (AE_OK); 261 return (AE_OK);
diff --git a/drivers/acpi/acpica/nsdumpdv.c b/drivers/acpi/acpica/nsdumpdv.c
index 30ea5bc53a78..3b5acb0eb406 100644
--- a/drivers/acpi/acpica/nsdumpdv.c
+++ b/drivers/acpi/acpica/nsdumpdv.c
@@ -121,7 +121,7 @@ void acpi_ns_dump_root_devices(void)
121 return; 121 return;
122 } 122 }
123 123
124 status = acpi_get_handle(NULL, ACPI_NS_SYSTEM_BUS, &sys_bus_handle); 124 status = acpi_get_handle(NULL, METHOD_NAME__SB_, &sys_bus_handle);
125 if (ACPI_FAILURE(status)) { 125 if (ACPI_FAILURE(status)) {
126 return; 126 return;
127 } 127 }
diff --git a/drivers/acpi/acpica/nspredef.c b/drivers/acpi/acpica/nspredef.c
index bbe46a447d34..23ce09686418 100644
--- a/drivers/acpi/acpica/nspredef.c
+++ b/drivers/acpi/acpica/nspredef.c
@@ -638,8 +638,8 @@ acpi_ns_check_package(struct acpi_predefined_data *data,
638 /* Create the new outer package and populate it */ 638 /* Create the new outer package and populate it */
639 639
640 status = 640 status =
641 acpi_ns_repair_package_list(data, 641 acpi_ns_wrap_with_package(data, *elements,
642 return_object_ptr); 642 return_object_ptr);
643 if (ACPI_FAILURE(status)) { 643 if (ACPI_FAILURE(status)) {
644 return (status); 644 return (status);
645 } 645 }
diff --git a/drivers/acpi/acpica/nsrepair.c b/drivers/acpi/acpica/nsrepair.c
index 9c35d20eb52b..5519a64a353f 100644
--- a/drivers/acpi/acpica/nsrepair.c
+++ b/drivers/acpi/acpica/nsrepair.c
@@ -71,11 +71,10 @@ ACPI_MODULE_NAME("nsrepair")
71 * Buffer -> String 71 * Buffer -> String
72 * Buffer -> Package of Integers 72 * Buffer -> Package of Integers
73 * Package -> Package of one Package 73 * Package -> Package of one Package
74 * An incorrect standalone object is wrapped with required outer package
74 * 75 *
75 * Additional possible repairs: 76 * Additional possible repairs:
76 *
77 * Required package elements that are NULL replaced by Integer/String/Buffer 77 * Required package elements that are NULL replaced by Integer/String/Buffer
78 * Incorrect standalone package wrapped with required outer package
79 * 78 *
80 ******************************************************************************/ 79 ******************************************************************************/
81/* Local prototypes */ 80/* Local prototypes */
@@ -91,10 +90,6 @@ static acpi_status
91acpi_ns_convert_to_buffer(union acpi_operand_object *original_object, 90acpi_ns_convert_to_buffer(union acpi_operand_object *original_object,
92 union acpi_operand_object **return_object); 91 union acpi_operand_object **return_object);
93 92
94static acpi_status
95acpi_ns_convert_to_package(union acpi_operand_object *original_object,
96 union acpi_operand_object **return_object);
97
98/******************************************************************************* 93/*******************************************************************************
99 * 94 *
100 * FUNCTION: acpi_ns_repair_object 95 * FUNCTION: acpi_ns_repair_object
@@ -151,9 +146,24 @@ acpi_ns_repair_object(struct acpi_predefined_data *data,
151 } 146 }
152 } 147 }
153 if (expected_btypes & ACPI_RTYPE_PACKAGE) { 148 if (expected_btypes & ACPI_RTYPE_PACKAGE) {
154 status = acpi_ns_convert_to_package(return_object, &new_object); 149 /*
150 * A package is expected. We will wrap the existing object with a
151 * new package object. It is often the case that if a variable-length
152 * package is required, but there is only a single object needed, the
153 * BIOS will return that object instead of wrapping it with a Package
154 * object. Note: after the wrapping, the package will be validated
155 * for correct contents (expected object type or types).
156 */
157 status =
158 acpi_ns_wrap_with_package(data, return_object, &new_object);
155 if (ACPI_SUCCESS(status)) { 159 if (ACPI_SUCCESS(status)) {
156 goto object_repaired; 160 /*
161 * The original object just had its reference count
162 * incremented for being inserted into the new package.
163 */
164 *return_object_ptr = new_object; /* New Package object */
165 data->flags |= ACPI_OBJECT_REPAIRED;
166 return (AE_OK);
157 } 167 }
158 } 168 }
159 169
@@ -165,22 +175,27 @@ acpi_ns_repair_object(struct acpi_predefined_data *data,
165 175
166 /* Object was successfully repaired */ 176 /* Object was successfully repaired */
167 177
168 /*
169 * If the original object is a package element, we need to:
170 * 1. Set the reference count of the new object to match the
171 * reference count of the old object.
172 * 2. Decrement the reference count of the original object.
173 */
174 if (package_index != ACPI_NOT_PACKAGE_ELEMENT) { 178 if (package_index != ACPI_NOT_PACKAGE_ELEMENT) {
175 new_object->common.reference_count = 179 /*
176 return_object->common.reference_count; 180 * The original object is a package element. We need to
181 * decrement the reference count of the original object,
182 * for removing it from the package.
183 *
184 * However, if the original object was just wrapped with a
185 * package object as part of the repair, we don't need to
186 * change the reference count.
187 */
188 if (!(data->flags & ACPI_OBJECT_WRAPPED)) {
189 new_object->common.reference_count =
190 return_object->common.reference_count;
177 191
178 if (return_object->common.reference_count > 1) { 192 if (return_object->common.reference_count > 1) {
179 return_object->common.reference_count--; 193 return_object->common.reference_count--;
194 }
180 } 195 }
181 196
182 ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, 197 ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
183 "%s: Converted %s to expected %s at index %u\n", 198 "%s: Converted %s to expected %s at Package index %u\n",
184 data->pathname, 199 data->pathname,
185 acpi_ut_get_object_type_name(return_object), 200 acpi_ut_get_object_type_name(return_object),
186 acpi_ut_get_object_type_name(new_object), 201 acpi_ut_get_object_type_name(new_object),
@@ -453,65 +468,6 @@ acpi_ns_convert_to_buffer(union acpi_operand_object *original_object,
453 468
454/******************************************************************************* 469/*******************************************************************************
455 * 470 *
456 * FUNCTION: acpi_ns_convert_to_package
457 *
458 * PARAMETERS: original_object - Object to be converted
459 * return_object - Where the new converted object is returned
460 *
461 * RETURN: Status. AE_OK if conversion was successful.
462 *
463 * DESCRIPTION: Attempt to convert a Buffer object to a Package. Each byte of
464 * the buffer is converted to a single integer package element.
465 *
466 ******************************************************************************/
467
468static acpi_status
469acpi_ns_convert_to_package(union acpi_operand_object *original_object,
470 union acpi_operand_object **return_object)
471{
472 union acpi_operand_object *new_object;
473 union acpi_operand_object **elements;
474 u32 length;
475 u8 *buffer;
476
477 switch (original_object->common.type) {
478 case ACPI_TYPE_BUFFER:
479
480 /* Buffer-to-Package conversion */
481
482 length = original_object->buffer.length;
483 new_object = acpi_ut_create_package_object(length);
484 if (!new_object) {
485 return (AE_NO_MEMORY);
486 }
487
488 /* Convert each buffer byte to an integer package element */
489
490 elements = new_object->package.elements;
491 buffer = original_object->buffer.pointer;
492
493 while (length--) {
494 *elements =
495 acpi_ut_create_integer_object((u64) *buffer);
496 if (!*elements) {
497 acpi_ut_remove_reference(new_object);
498 return (AE_NO_MEMORY);
499 }
500 elements++;
501 buffer++;
502 }
503 break;
504
505 default:
506 return (AE_AML_OPERAND_TYPE);
507 }
508
509 *return_object = new_object;
510 return (AE_OK);
511}
512
513/*******************************************************************************
514 *
515 * FUNCTION: acpi_ns_repair_null_element 471 * FUNCTION: acpi_ns_repair_null_element
516 * 472 *
517 * PARAMETERS: Data - Pointer to validation data structure 473 * PARAMETERS: Data - Pointer to validation data structure
@@ -677,55 +633,56 @@ acpi_ns_remove_null_elements(struct acpi_predefined_data *data,
677 633
678/******************************************************************************* 634/*******************************************************************************
679 * 635 *
680 * FUNCTION: acpi_ns_repair_package_list 636 * FUNCTION: acpi_ns_wrap_with_package
681 * 637 *
682 * PARAMETERS: Data - Pointer to validation data structure 638 * PARAMETERS: Data - Pointer to validation data structure
683 * obj_desc_ptr - Pointer to the object to repair. The new 639 * original_object - Pointer to the object to repair.
684 * package object is returned here, 640 * obj_desc_ptr - The new package object is returned here
685 * overwriting the old object.
686 * 641 *
687 * RETURN: Status, new object in *obj_desc_ptr 642 * RETURN: Status, new object in *obj_desc_ptr
688 * 643 *
689 * DESCRIPTION: Repair a common problem with objects that are defined to return 644 * DESCRIPTION: Repair a common problem with objects that are defined to
690 * a variable-length Package of Packages. If the variable-length 645 * return a variable-length Package of sub-objects. If there is
691 * is one, some BIOS code mistakenly simply declares a single 646 * only one sub-object, some BIOS code mistakenly simply declares
692 * Package instead of a Package with one sub-Package. This 647 * the single object instead of a Package with one sub-object.
693 * function attempts to repair this error by wrapping a Package 648 * This function attempts to repair this error by wrapping a
694 * object around the original Package, creating the correct 649 * Package object around the original object, creating the
695 * Package with one sub-Package. 650 * correct and expected Package with one sub-object.
696 * 651 *
697 * Names that can be repaired in this manner include: 652 * Names that can be repaired in this manner include:
698 * _ALR, _CSD, _HPX, _MLS, _PRT, _PSS, _TRT, TSS 653 * _ALR, _CSD, _HPX, _MLS, _PLD, _PRT, _PSS, _TRT, _TSS,
654 * _BCL, _DOD, _FIX, _Sx
699 * 655 *
700 ******************************************************************************/ 656 ******************************************************************************/
701 657
702acpi_status 658acpi_status
703acpi_ns_repair_package_list(struct acpi_predefined_data *data, 659acpi_ns_wrap_with_package(struct acpi_predefined_data *data,
704 union acpi_operand_object **obj_desc_ptr) 660 union acpi_operand_object *original_object,
661 union acpi_operand_object **obj_desc_ptr)
705{ 662{
706 union acpi_operand_object *pkg_obj_desc; 663 union acpi_operand_object *pkg_obj_desc;
707 664
708 ACPI_FUNCTION_NAME(ns_repair_package_list); 665 ACPI_FUNCTION_NAME(ns_wrap_with_package);
709 666
710 /* 667 /*
711 * Create the new outer package and populate it. The new package will 668 * Create the new outer package and populate it. The new package will
712 * have a single element, the lone subpackage. 669 * have a single element, the lone sub-object.
713 */ 670 */
714 pkg_obj_desc = acpi_ut_create_package_object(1); 671 pkg_obj_desc = acpi_ut_create_package_object(1);
715 if (!pkg_obj_desc) { 672 if (!pkg_obj_desc) {
716 return (AE_NO_MEMORY); 673 return (AE_NO_MEMORY);
717 } 674 }
718 675
719 pkg_obj_desc->package.elements[0] = *obj_desc_ptr; 676 pkg_obj_desc->package.elements[0] = original_object;
677
678 ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
679 "%s: Wrapped %s with expected Package object\n",
680 data->pathname,
681 acpi_ut_get_object_type_name(original_object)));
720 682
721 /* Return the new object in the object pointer */ 683 /* Return the new object in the object pointer */
722 684
723 *obj_desc_ptr = pkg_obj_desc; 685 *obj_desc_ptr = pkg_obj_desc;
724 data->flags |= ACPI_OBJECT_REPAIRED; 686 data->flags |= ACPI_OBJECT_REPAIRED | ACPI_OBJECT_WRAPPED;
725
726 ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
727 "%s: Repaired incorrectly formed Package\n",
728 data->pathname));
729
730 return (AE_OK); 687 return (AE_OK);
731} 688}
diff --git a/drivers/acpi/acpica/nsutils.c b/drivers/acpi/acpica/nsutils.c
index a535b7afda5c..75113759f69d 100644
--- a/drivers/acpi/acpica/nsutils.c
+++ b/drivers/acpi/acpica/nsutils.c
@@ -341,7 +341,7 @@ acpi_status acpi_ns_build_internal_name(struct acpi_namestring_info *info)
341 341
342 if (!acpi_ns_valid_path_separator(*external_name) && 342 if (!acpi_ns_valid_path_separator(*external_name) &&
343 (*external_name != 0)) { 343 (*external_name != 0)) {
344 return_ACPI_STATUS(AE_BAD_PARAMETER); 344 return_ACPI_STATUS(AE_BAD_PATHNAME);
345 } 345 }
346 346
347 /* Move on the next segment */ 347 /* Move on the next segment */
diff --git a/drivers/acpi/acpica/tbfadt.c b/drivers/acpi/acpica/tbfadt.c
index c5d870406f41..4c9c760db4a4 100644
--- a/drivers/acpi/acpica/tbfadt.c
+++ b/drivers/acpi/acpica/tbfadt.c
@@ -363,10 +363,6 @@ static void acpi_tb_convert_fadt(void)
363 u32 address32; 363 u32 address32;
364 u32 i; 364 u32 i;
365 365
366 /* Update the local FADT table header length */
367
368 acpi_gbl_FADT.header.length = sizeof(struct acpi_table_fadt);
369
370 /* 366 /*
371 * Expand the 32-bit FACS and DSDT addresses to 64-bit as necessary. 367 * Expand the 32-bit FACS and DSDT addresses to 64-bit as necessary.
372 * Later code will always use the X 64-bit field. Also, check for an 368 * Later code will always use the X 64-bit field. Also, check for an
@@ -408,6 +404,10 @@ static void acpi_tb_convert_fadt(void)
408 acpi_gbl_FADT.boot_flags = 0; 404 acpi_gbl_FADT.boot_flags = 0;
409 } 405 }
410 406
407 /* Update the local FADT table header length */
408
409 acpi_gbl_FADT.header.length = sizeof(struct acpi_table_fadt);
410
411 /* 411 /*
412 * Expand the ACPI 1.0 32-bit addresses to the ACPI 2.0 64-bit "X" 412 * Expand the ACPI 1.0 32-bit addresses to the ACPI 2.0 64-bit "X"
413 * generic address structures as necessary. Later code will always use 413 * generic address structures as necessary. Later code will always use
diff --git a/drivers/acpi/acpica/tbinstal.c b/drivers/acpi/acpica/tbinstal.c
index 1aecf7baa4e0..c03500b4cc7a 100644
--- a/drivers/acpi/acpica/tbinstal.c
+++ b/drivers/acpi/acpica/tbinstal.c
@@ -114,7 +114,6 @@ acpi_tb_add_table(struct acpi_table_desc *table_desc, u32 *table_index)
114{ 114{
115 u32 i; 115 u32 i;
116 acpi_status status = AE_OK; 116 acpi_status status = AE_OK;
117 struct acpi_table_header *override_table = NULL;
118 117
119 ACPI_FUNCTION_TRACE(tb_add_table); 118 ACPI_FUNCTION_TRACE(tb_add_table);
120 119
@@ -224,25 +223,10 @@ acpi_tb_add_table(struct acpi_table_desc *table_desc, u32 *table_index)
224 /* 223 /*
225 * ACPI Table Override: 224 * ACPI Table Override:
226 * Allow the host to override dynamically loaded tables. 225 * Allow the host to override dynamically loaded tables.
226 * NOTE: the table is fully mapped at this point, and the mapping will
227 * be deleted by tb_table_override if the table is actually overridden.
227 */ 228 */
228 status = acpi_os_table_override(table_desc->pointer, &override_table); 229 (void)acpi_tb_table_override(table_desc->pointer, table_desc);
229 if (ACPI_SUCCESS(status) && override_table) {
230 ACPI_INFO((AE_INFO,
231 "%4.4s @ 0x%p Table override, replaced with:",
232 table_desc->pointer->signature,
233 ACPI_CAST_PTR(void, table_desc->address)));
234
235 /* We can delete the table that was passed as a parameter */
236
237 acpi_tb_delete_table(table_desc);
238
239 /* Setup descriptor for the new table */
240
241 table_desc->address = ACPI_PTR_TO_PHYSADDR(override_table);
242 table_desc->pointer = override_table;
243 table_desc->length = override_table->length;
244 table_desc->flags = ACPI_TABLE_ORIGIN_OVERRIDE;
245 }
246 230
247 /* Add the table to the global root table list */ 231 /* Add the table to the global root table list */
248 232
@@ -263,6 +247,95 @@ acpi_tb_add_table(struct acpi_table_desc *table_desc, u32 *table_index)
263 247
264/******************************************************************************* 248/*******************************************************************************
265 * 249 *
250 * FUNCTION: acpi_tb_table_override
251 *
252 * PARAMETERS: table_header - Header for the original table
253 * table_desc - Table descriptor initialized for the
254 * original table. May or may not be mapped.
255 *
256 * RETURN: Pointer to the entire new table. NULL if table not overridden.
257 * If overridden, installs the new table within the input table
258 * descriptor.
259 *
260 * DESCRIPTION: Attempt table override by calling the OSL override functions.
261 * Note: If the table is overridden, then the entire new table
262 * is mapped and returned by this function.
263 *
264 ******************************************************************************/
265
266struct acpi_table_header *acpi_tb_table_override(struct acpi_table_header
267 *table_header,
268 struct acpi_table_desc
269 *table_desc)
270{
271 acpi_status status;
272 struct acpi_table_header *new_table = NULL;
273 acpi_physical_address new_address = 0;
274 u32 new_table_length = 0;
275 u8 new_flags;
276 char *override_type;
277
278 /* (1) Attempt logical override (returns a logical address) */
279
280 status = acpi_os_table_override(table_header, &new_table);
281 if (ACPI_SUCCESS(status) && new_table) {
282 new_address = ACPI_PTR_TO_PHYSADDR(new_table);
283 new_table_length = new_table->length;
284 new_flags = ACPI_TABLE_ORIGIN_OVERRIDE;
285 override_type = "Logical";
286 goto finish_override;
287 }
288
289 /* (2) Attempt physical override (returns a physical address) */
290
291 status = acpi_os_physical_table_override(table_header,
292 &new_address,
293 &new_table_length);
294 if (ACPI_SUCCESS(status) && new_address && new_table_length) {
295
296 /* Map the entire new table */
297
298 new_table = acpi_os_map_memory(new_address, new_table_length);
299 if (!new_table) {
300 ACPI_EXCEPTION((AE_INFO, AE_NO_MEMORY,
301 "%4.4s %p Attempted physical table override failed",
302 table_header->signature,
303 ACPI_CAST_PTR(void,
304 table_desc->address)));
305 return (NULL);
306 }
307
308 override_type = "Physical";
309 new_flags = ACPI_TABLE_ORIGIN_MAPPED;
310 goto finish_override;
311 }
312
313 return (NULL); /* There was no override */
314
315 finish_override:
316
317 ACPI_INFO((AE_INFO,
318 "%4.4s %p %s table override, new table: %p",
319 table_header->signature,
320 ACPI_CAST_PTR(void, table_desc->address),
321 override_type, new_table));
322
323 /* We can now unmap/delete the original table (if fully mapped) */
324
325 acpi_tb_delete_table(table_desc);
326
327 /* Setup descriptor for the new table */
328
329 table_desc->address = new_address;
330 table_desc->pointer = new_table;
331 table_desc->length = new_table_length;
332 table_desc->flags = new_flags;
333
334 return (new_table);
335}
336
337/*******************************************************************************
338 *
266 * FUNCTION: acpi_tb_resize_root_table_list 339 * FUNCTION: acpi_tb_resize_root_table_list
267 * 340 *
268 * PARAMETERS: None 341 * PARAMETERS: None
@@ -396,7 +469,11 @@ void acpi_tb_delete_table(struct acpi_table_desc *table_desc)
396 case ACPI_TABLE_ORIGIN_ALLOCATED: 469 case ACPI_TABLE_ORIGIN_ALLOCATED:
397 ACPI_FREE(table_desc->pointer); 470 ACPI_FREE(table_desc->pointer);
398 break; 471 break;
399 default:; 472
473 /* Not mapped or allocated, there is nothing we can do */
474
475 default:
476 return;
400 } 477 }
401 478
402 table_desc->pointer = NULL; 479 table_desc->pointer = NULL;
diff --git a/drivers/acpi/acpica/tbutils.c b/drivers/acpi/acpica/tbutils.c
index 09ca39e14337..0a706cac37de 100644
--- a/drivers/acpi/acpica/tbutils.c
+++ b/drivers/acpi/acpica/tbutils.c
@@ -118,6 +118,7 @@ acpi_tb_check_xsdt(acpi_physical_address address)
118 return AE_OK; 118 return AE_OK;
119} 119}
120 120
121#if (!ACPI_REDUCED_HARDWARE)
121/******************************************************************************* 122/*******************************************************************************
122 * 123 *
123 * FUNCTION: acpi_tb_initialize_facs 124 * FUNCTION: acpi_tb_initialize_facs
@@ -148,6 +149,7 @@ acpi_status acpi_tb_initialize_facs(void)
148 &acpi_gbl_FACS)); 149 &acpi_gbl_FACS));
149 return status; 150 return status;
150} 151}
152#endif /* !ACPI_REDUCED_HARDWARE */
151 153
152/******************************************************************************* 154/*******************************************************************************
153 * 155 *
@@ -444,7 +446,7 @@ struct acpi_table_header *acpi_tb_copy_dsdt(u32 table_index)
444 * RETURN: None 446 * RETURN: None
445 * 447 *
446 * DESCRIPTION: Install an ACPI table into the global data structure. The 448 * DESCRIPTION: Install an ACPI table into the global data structure. The
447 * table override mechanism is implemented here to allow the host 449 * table override mechanism is called to allow the host
448 * OS to replace any table before it is installed in the root 450 * OS to replace any table before it is installed in the root
449 * table array. 451 * table array.
450 * 452 *
@@ -454,11 +456,9 @@ void
454acpi_tb_install_table(acpi_physical_address address, 456acpi_tb_install_table(acpi_physical_address address,
455 char *signature, u32 table_index) 457 char *signature, u32 table_index)
456{ 458{
457 u8 flags; 459 struct acpi_table_header *table;
458 acpi_status status; 460 struct acpi_table_header *final_table;
459 struct acpi_table_header *table_to_install; 461 struct acpi_table_desc *table_desc;
460 struct acpi_table_header *mapped_table;
461 struct acpi_table_header *override_table = NULL;
462 462
463 if (!address) { 463 if (!address) {
464 ACPI_ERROR((AE_INFO, 464 ACPI_ERROR((AE_INFO,
@@ -469,69 +469,78 @@ acpi_tb_install_table(acpi_physical_address address,
469 469
470 /* Map just the table header */ 470 /* Map just the table header */
471 471
472 mapped_table = 472 table = acpi_os_map_memory(address, sizeof(struct acpi_table_header));
473 acpi_os_map_memory(address, sizeof(struct acpi_table_header)); 473 if (!table) {
474 if (!mapped_table) { 474 ACPI_ERROR((AE_INFO,
475 "Could not map memory for table [%s] at %p",
476 signature, ACPI_CAST_PTR(void, address)));
475 return; 477 return;
476 } 478 }
477 479
478 /* If a particular signature is expected (DSDT/FACS), it must match */ 480 /* If a particular signature is expected (DSDT/FACS), it must match */
479 481
480 if (signature && !ACPI_COMPARE_NAME(mapped_table->signature, signature)) { 482 if (signature && !ACPI_COMPARE_NAME(table->signature, signature)) {
481 ACPI_ERROR((AE_INFO, 483 ACPI_ERROR((AE_INFO,
482 "Invalid signature 0x%X for ACPI table, expected [%s]", 484 "Invalid signature 0x%X for ACPI table, expected [%s]",
483 *ACPI_CAST_PTR(u32, mapped_table->signature), 485 *ACPI_CAST_PTR(u32, table->signature), signature));
484 signature));
485 goto unmap_and_exit; 486 goto unmap_and_exit;
486 } 487 }
487 488
488 /* 489 /*
490 * Initialize the table entry. Set the pointer to NULL, since the
491 * table is not fully mapped at this time.
492 */
493 table_desc = &acpi_gbl_root_table_list.tables[table_index];
494
495 table_desc->address = address;
496 table_desc->pointer = NULL;
497 table_desc->length = table->length;
498 table_desc->flags = ACPI_TABLE_ORIGIN_MAPPED;
499 ACPI_MOVE_32_TO_32(table_desc->signature.ascii, table->signature);
500
501 /*
489 * ACPI Table Override: 502 * ACPI Table Override:
490 * 503 *
491 * Before we install the table, let the host OS override it with a new 504 * Before we install the table, let the host OS override it with a new
492 * one if desired. Any table within the RSDT/XSDT can be replaced, 505 * one if desired. Any table within the RSDT/XSDT can be replaced,
493 * including the DSDT which is pointed to by the FADT. 506 * including the DSDT which is pointed to by the FADT.
507 *
508 * NOTE: If the table is overridden, then final_table will contain a
509 * mapped pointer to the full new table. If the table is not overridden,
510 * or if there has been a physical override, then the table will be
511 * fully mapped later (in verify table). In any case, we must
512 * unmap the header that was mapped above.
494 */ 513 */
495 status = acpi_os_table_override(mapped_table, &override_table); 514 final_table = acpi_tb_table_override(table, table_desc);
496 if (ACPI_SUCCESS(status) && override_table) { 515 if (!final_table) {
497 ACPI_INFO((AE_INFO, 516 final_table = table; /* There was no override */
498 "%4.4s @ 0x%p Table override, replaced with:",
499 mapped_table->signature, ACPI_CAST_PTR(void,
500 address)));
501
502 acpi_gbl_root_table_list.tables[table_index].pointer =
503 override_table;
504 address = ACPI_PTR_TO_PHYSADDR(override_table);
505
506 table_to_install = override_table;
507 flags = ACPI_TABLE_ORIGIN_OVERRIDE;
508 } else {
509 table_to_install = mapped_table;
510 flags = ACPI_TABLE_ORIGIN_MAPPED;
511 } 517 }
512 518
513 /* Initialize the table entry */ 519 acpi_tb_print_table_header(table_desc->address, final_table);
514 520
515 acpi_gbl_root_table_list.tables[table_index].address = address; 521 /* Set the global integer width (based upon revision of the DSDT) */
516 acpi_gbl_root_table_list.tables[table_index].length =
517 table_to_install->length;
518 acpi_gbl_root_table_list.tables[table_index].flags = flags;
519
520 ACPI_MOVE_32_TO_32(&
521 (acpi_gbl_root_table_list.tables[table_index].
522 signature), table_to_install->signature);
523
524 acpi_tb_print_table_header(address, table_to_install);
525 522
526 if (table_index == ACPI_TABLE_INDEX_DSDT) { 523 if (table_index == ACPI_TABLE_INDEX_DSDT) {
524 acpi_ut_set_integer_width(final_table->revision);
525 }
527 526
528 /* Global integer width is based upon revision of the DSDT */ 527 /*
529 528 * If we have a physical override during this early loading of the ACPI
530 acpi_ut_set_integer_width(table_to_install->revision); 529 * tables, unmap the table for now. It will be mapped again later when
530 * it is actually used. This supports very early loading of ACPI tables,
531 * before virtual memory is fully initialized and running within the
532 * host OS. Note: A logical override has the ACPI_TABLE_ORIGIN_OVERRIDE
533 * flag set and will not be deleted below.
534 */
535 if (final_table != table) {
536 acpi_tb_delete_table(table_desc);
531 } 537 }
532 538
533 unmap_and_exit: 539 unmap_and_exit:
534 acpi_os_unmap_memory(mapped_table, sizeof(struct acpi_table_header)); 540
541 /* Always unmap the table header that we mapped above */
542
543 acpi_os_unmap_memory(table, sizeof(struct acpi_table_header));
535} 544}
536 545
537/******************************************************************************* 546/*******************************************************************************
diff --git a/drivers/acpi/acpica/utdecode.c b/drivers/acpi/acpica/utdecode.c
index d42ede5260c7..684849949bf3 100644
--- a/drivers/acpi/acpica/utdecode.c
+++ b/drivers/acpi/acpica/utdecode.c
@@ -497,19 +497,20 @@ char *acpi_ut_get_mutex_name(u32 mutex_id)
497 497
498/* Names for Notify() values, used for debug output */ 498/* Names for Notify() values, used for debug output */
499 499
500static const char *acpi_gbl_notify_value_names[] = { 500static const char *acpi_gbl_notify_value_names[ACPI_NOTIFY_MAX + 1] = {
501 "Bus Check", 501 /* 00 */ "Bus Check",
502 "Device Check", 502 /* 01 */ "Device Check",
503 "Device Wake", 503 /* 02 */ "Device Wake",
504 "Eject Request", 504 /* 03 */ "Eject Request",
505 "Device Check Light", 505 /* 04 */ "Device Check Light",
506 "Frequency Mismatch", 506 /* 05 */ "Frequency Mismatch",
507 "Bus Mode Mismatch", 507 /* 06 */ "Bus Mode Mismatch",
508 "Power Fault", 508 /* 07 */ "Power Fault",
509 "Capabilities Check", 509 /* 08 */ "Capabilities Check",
510 "Device PLD Check", 510 /* 09 */ "Device PLD Check",
511 "Reserved", 511 /* 10 */ "Reserved",
512 "System Locality Update" 512 /* 11 */ "System Locality Update",
513 /* 12 */ "Shutdown Request"
513}; 514};
514 515
515const char *acpi_ut_get_notify_name(u32 notify_value) 516const char *acpi_ut_get_notify_name(u32 notify_value)
@@ -519,9 +520,10 @@ const char *acpi_ut_get_notify_name(u32 notify_value)
519 return (acpi_gbl_notify_value_names[notify_value]); 520 return (acpi_gbl_notify_value_names[notify_value]);
520 } else if (notify_value <= ACPI_MAX_SYS_NOTIFY) { 521 } else if (notify_value <= ACPI_MAX_SYS_NOTIFY) {
521 return ("Reserved"); 522 return ("Reserved");
522 } else { /* Greater or equal to 0x80 */ 523 } else if (notify_value <= ACPI_MAX_DEVICE_SPECIFIC_NOTIFY) {
523 524 return ("Device Specific");
524 return ("**Device Specific**"); 525 } else {
526 return ("Hardware Specific");
525 } 527 }
526} 528}
527#endif 529#endif
diff --git a/drivers/acpi/acpica/utglobal.c b/drivers/acpi/acpica/utglobal.c
index 4153584cf526..90f53b42eca9 100644
--- a/drivers/acpi/acpica/utglobal.c
+++ b/drivers/acpi/acpica/utglobal.c
@@ -140,6 +140,7 @@ const struct acpi_predefined_names acpi_gbl_pre_defined_names[] = {
140 {NULL, ACPI_TYPE_ANY, NULL} 140 {NULL, ACPI_TYPE_ANY, NULL}
141}; 141};
142 142
143#if (!ACPI_REDUCED_HARDWARE)
143/****************************************************************************** 144/******************************************************************************
144 * 145 *
145 * Event and Hardware globals 146 * Event and Hardware globals
@@ -236,6 +237,7 @@ struct acpi_fixed_event_info acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVENTS] =
236 ACPI_BITMASK_RT_CLOCK_STATUS, 237 ACPI_BITMASK_RT_CLOCK_STATUS,
237 ACPI_BITMASK_RT_CLOCK_ENABLE}, 238 ACPI_BITMASK_RT_CLOCK_ENABLE},
238}; 239};
240#endif /* !ACPI_REDUCED_HARDWARE */
239 241
240/******************************************************************************* 242/*******************************************************************************
241 * 243 *
@@ -286,6 +288,8 @@ acpi_status acpi_ut_init_globals(void)
286 288
287 acpi_gbl_owner_id_mask[ACPI_NUM_OWNERID_MASKS - 1] = 0x80000000; 289 acpi_gbl_owner_id_mask[ACPI_NUM_OWNERID_MASKS - 1] = 0x80000000;
288 290
291#if (!ACPI_REDUCED_HARDWARE)
292
289 /* GPE support */ 293 /* GPE support */
290 294
291 acpi_gbl_gpe_xrupt_list_head = NULL; 295 acpi_gbl_gpe_xrupt_list_head = NULL;
@@ -294,6 +298,10 @@ acpi_status acpi_ut_init_globals(void)
294 acpi_current_gpe_count = 0; 298 acpi_current_gpe_count = 0;
295 acpi_gbl_all_gpes_initialized = FALSE; 299 acpi_gbl_all_gpes_initialized = FALSE;
296 300
301 acpi_gbl_global_event_handler = NULL;
302
303#endif /* !ACPI_REDUCED_HARDWARE */
304
297 /* Global handlers */ 305 /* Global handlers */
298 306
299 acpi_gbl_system_notify.handler = NULL; 307 acpi_gbl_system_notify.handler = NULL;
@@ -302,7 +310,6 @@ acpi_status acpi_ut_init_globals(void)
302 acpi_gbl_init_handler = NULL; 310 acpi_gbl_init_handler = NULL;
303 acpi_gbl_table_handler = NULL; 311 acpi_gbl_table_handler = NULL;
304 acpi_gbl_interface_handler = NULL; 312 acpi_gbl_interface_handler = NULL;
305 acpi_gbl_global_event_handler = NULL;
306 313
307 /* Global Lock support */ 314 /* Global Lock support */
308 315
diff --git a/drivers/acpi/acpica/utinit.c b/drivers/acpi/acpica/utinit.c
index 8359c0c5dc98..246798e4c938 100644
--- a/drivers/acpi/acpica/utinit.c
+++ b/drivers/acpi/acpica/utinit.c
@@ -53,27 +53,35 @@ ACPI_MODULE_NAME("utinit")
53/* Local prototypes */ 53/* Local prototypes */
54static void acpi_ut_terminate(void); 54static void acpi_ut_terminate(void);
55 55
56#if (!ACPI_REDUCED_HARDWARE)
57
58static void acpi_ut_free_gpe_lists(void);
59
60#else
61
62#define acpi_ut_free_gpe_lists()
63#endif /* !ACPI_REDUCED_HARDWARE */
64
65#if (!ACPI_REDUCED_HARDWARE)
56/****************************************************************************** 66/******************************************************************************
57 * 67 *
58 * FUNCTION: acpi_ut_terminate 68 * FUNCTION: acpi_ut_free_gpe_lists
59 * 69 *
60 * PARAMETERS: none 70 * PARAMETERS: none
61 * 71 *
62 * RETURN: none 72 * RETURN: none
63 * 73 *
64 * DESCRIPTION: Free global memory 74 * DESCRIPTION: Free global GPE lists
65 * 75 *
66 ******************************************************************************/ 76 ******************************************************************************/
67 77
68static void acpi_ut_terminate(void) 78static void acpi_ut_free_gpe_lists(void)
69{ 79{
70 struct acpi_gpe_block_info *gpe_block; 80 struct acpi_gpe_block_info *gpe_block;
71 struct acpi_gpe_block_info *next_gpe_block; 81 struct acpi_gpe_block_info *next_gpe_block;
72 struct acpi_gpe_xrupt_info *gpe_xrupt_info; 82 struct acpi_gpe_xrupt_info *gpe_xrupt_info;
73 struct acpi_gpe_xrupt_info *next_gpe_xrupt_info; 83 struct acpi_gpe_xrupt_info *next_gpe_xrupt_info;
74 84
75 ACPI_FUNCTION_TRACE(ut_terminate);
76
77 /* Free global GPE blocks and related info structures */ 85 /* Free global GPE blocks and related info structures */
78 86
79 gpe_xrupt_info = acpi_gbl_gpe_xrupt_list_head; 87 gpe_xrupt_info = acpi_gbl_gpe_xrupt_list_head;
@@ -91,7 +99,26 @@ static void acpi_ut_terminate(void)
91 ACPI_FREE(gpe_xrupt_info); 99 ACPI_FREE(gpe_xrupt_info);
92 gpe_xrupt_info = next_gpe_xrupt_info; 100 gpe_xrupt_info = next_gpe_xrupt_info;
93 } 101 }
102}
103#endif /* !ACPI_REDUCED_HARDWARE */
104
105/******************************************************************************
106 *
107 * FUNCTION: acpi_ut_terminate
108 *
109 * PARAMETERS: none
110 *
111 * RETURN: none
112 *
113 * DESCRIPTION: Free global memory
114 *
115 ******************************************************************************/
116
117static void acpi_ut_terminate(void)
118{
119 ACPI_FUNCTION_TRACE(ut_terminate);
94 120
121 acpi_ut_free_gpe_lists();
95 acpi_ut_delete_address_lists(); 122 acpi_ut_delete_address_lists();
96 return_VOID; 123 return_VOID;
97} 124}
diff --git a/drivers/acpi/acpica/utxface.c b/drivers/acpi/acpica/utxface.c
index 644e8c8ebc4b..afa94f51ff0b 100644
--- a/drivers/acpi/acpica/utxface.c
+++ b/drivers/acpi/acpica/utxface.c
@@ -145,6 +145,8 @@ acpi_status acpi_enable_subsystem(u32 flags)
145 145
146 ACPI_FUNCTION_TRACE(acpi_enable_subsystem); 146 ACPI_FUNCTION_TRACE(acpi_enable_subsystem);
147 147
148#if (!ACPI_REDUCED_HARDWARE)
149
148 /* Enable ACPI mode */ 150 /* Enable ACPI mode */
149 151
150 if (!(flags & ACPI_NO_ACPI_ENABLE)) { 152 if (!(flags & ACPI_NO_ACPI_ENABLE)) {
@@ -169,6 +171,7 @@ acpi_status acpi_enable_subsystem(u32 flags)
169 ACPI_WARNING((AE_INFO, "Could not map the FACS table")); 171 ACPI_WARNING((AE_INFO, "Could not map the FACS table"));
170 return_ACPI_STATUS(status); 172 return_ACPI_STATUS(status);
171 } 173 }
174#endif /* !ACPI_REDUCED_HARDWARE */
172 175
173 /* 176 /*
174 * Install the default op_region handlers. These are installed unless 177 * Install the default op_region handlers. These are installed unless
@@ -184,7 +187,7 @@ acpi_status acpi_enable_subsystem(u32 flags)
184 return_ACPI_STATUS(status); 187 return_ACPI_STATUS(status);
185 } 188 }
186 } 189 }
187 190#if (!ACPI_REDUCED_HARDWARE)
188 /* 191 /*
189 * Initialize ACPI Event handling (Fixed and General Purpose) 192 * Initialize ACPI Event handling (Fixed and General Purpose)
190 * 193 *
@@ -220,6 +223,7 @@ acpi_status acpi_enable_subsystem(u32 flags)
220 return_ACPI_STATUS(status); 223 return_ACPI_STATUS(status);
221 } 224 }
222 } 225 }
226#endif /* !ACPI_REDUCED_HARDWARE */
223 227
224 return_ACPI_STATUS(status); 228 return_ACPI_STATUS(status);
225} 229}
diff --git a/drivers/acpi/apei/apei-base.c b/drivers/acpi/apei/apei-base.c
index e5d53b7ddc7e..ca773683d87e 100644
--- a/drivers/acpi/apei/apei-base.c
+++ b/drivers/acpi/apei/apei-base.c
@@ -605,7 +605,7 @@ int apei_read(u64 *val, struct acpi_generic_address *reg)
605 *val = 0; 605 *val = 0;
606 switch(reg->space_id) { 606 switch(reg->space_id) {
607 case ACPI_ADR_SPACE_SYSTEM_MEMORY: 607 case ACPI_ADR_SPACE_SYSTEM_MEMORY:
608 status = acpi_os_read_memory64((acpi_physical_address) 608 status = acpi_os_read_memory((acpi_physical_address)
609 address, val, reg->bit_width); 609 address, val, reg->bit_width);
610 if (ACPI_FAILURE(status)) 610 if (ACPI_FAILURE(status))
611 return -EIO; 611 return -EIO;
@@ -636,7 +636,7 @@ int apei_write(u64 val, struct acpi_generic_address *reg)
636 636
637 switch (reg->space_id) { 637 switch (reg->space_id) {
638 case ACPI_ADR_SPACE_SYSTEM_MEMORY: 638 case ACPI_ADR_SPACE_SYSTEM_MEMORY:
639 status = acpi_os_write_memory64((acpi_physical_address) 639 status = acpi_os_write_memory((acpi_physical_address)
640 address, val, reg->bit_width); 640 address, val, reg->bit_width);
641 if (ACPI_FAILURE(status)) 641 if (ACPI_FAILURE(status))
642 return -EIO; 642 return -EIO;
diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
new file mode 100644
index 000000000000..8cf6c46e99fb
--- /dev/null
+++ b/drivers/acpi/bgrt.c
@@ -0,0 +1,175 @@
1/*
2 * Copyright 2012 Red Hat, Inc <mjg@redhat.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8
9#include <linux/kernel.h>
10#include <linux/module.h>
11#include <linux/init.h>
12#include <linux/device.h>
13#include <linux/sysfs.h>
14#include <acpi/acpi.h>
15#include <acpi/acpi_bus.h>
16
17static struct acpi_table_bgrt *bgrt_tab;
18static struct kobject *bgrt_kobj;
19
20struct bmp_header {
21 u16 id;
22 u32 size;
23} __attribute ((packed));
24
25static struct bmp_header bmp_header;
26
27static ssize_t show_version(struct device *dev,
28 struct device_attribute *attr, char *buf)
29{
30 return snprintf(buf, PAGE_SIZE, "%d\n", bgrt_tab->version);
31}
32static DEVICE_ATTR(version, S_IRUGO, show_version, NULL);
33
34static ssize_t show_status(struct device *dev,
35 struct device_attribute *attr, char *buf)
36{
37 return snprintf(buf, PAGE_SIZE, "%d\n", bgrt_tab->status);
38}
39static DEVICE_ATTR(status, S_IRUGO, show_status, NULL);
40
41static ssize_t show_type(struct device *dev,
42 struct device_attribute *attr, char *buf)
43{
44 return snprintf(buf, PAGE_SIZE, "%d\n", bgrt_tab->image_type);
45}
46static DEVICE_ATTR(type, S_IRUGO, show_type, NULL);
47
48static ssize_t show_xoffset(struct device *dev,
49 struct device_attribute *attr, char *buf)
50{
51 return snprintf(buf, PAGE_SIZE, "%d\n", bgrt_tab->image_offset_x);
52}
53static DEVICE_ATTR(xoffset, S_IRUGO, show_xoffset, NULL);
54
55static ssize_t show_yoffset(struct device *dev,
56 struct device_attribute *attr, char *buf)
57{
58 return snprintf(buf, PAGE_SIZE, "%d\n", bgrt_tab->image_offset_y);
59}
60static DEVICE_ATTR(yoffset, S_IRUGO, show_yoffset, NULL);
61
62static ssize_t show_image(struct file *file, struct kobject *kobj,
63 struct bin_attribute *attr, char *buf, loff_t off, size_t count)
64{
65 int size = attr->size;
66 void __iomem *image = attr->private;
67
68 if (off >= size) {
69 count = 0;
70 } else {
71 if (off + count > size)
72 count = size - off;
73
74 memcpy_fromio(buf, image+off, count);
75 }
76
77 return count;
78}
79
80static struct bin_attribute image_attr = {
81 .attr = {
82 .name = "image",
83 .mode = S_IRUGO,
84 },
85 .read = show_image,
86};
87
88static struct attribute *bgrt_attributes[] = {
89 &dev_attr_version.attr,
90 &dev_attr_status.attr,
91 &dev_attr_type.attr,
92 &dev_attr_xoffset.attr,
93 &dev_attr_yoffset.attr,
94 NULL,
95};
96
97static struct attribute_group bgrt_attribute_group = {
98 .attrs = bgrt_attributes,
99};
100
101static int __init bgrt_init(void)
102{
103 acpi_status status;
104 int ret;
105 void __iomem *bgrt;
106
107 if (acpi_disabled)
108 return -ENODEV;
109
110 status = acpi_get_table("BGRT", 0,
111 (struct acpi_table_header **)&bgrt_tab);
112
113 if (ACPI_FAILURE(status))
114 return -ENODEV;
115
116 sysfs_bin_attr_init(&image_attr);
117
118 bgrt = ioremap(bgrt_tab->image_address, sizeof(struct bmp_header));
119
120 if (!bgrt) {
121 ret = -EINVAL;
122 goto out_err;
123 }
124
125 memcpy_fromio(&bmp_header, bgrt, sizeof(bmp_header));
126 image_attr.size = bmp_header.size;
127 iounmap(bgrt);
128
129 image_attr.private = ioremap(bgrt_tab->image_address, image_attr.size);
130
131 if (!image_attr.private) {
132 ret = -EINVAL;
133 goto out_err;
134 }
135
136
137 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
138 if (!bgrt_kobj) {
139 ret = -EINVAL;
140 goto out_iounmap;
141 }
142
143 ret = sysfs_create_group(bgrt_kobj, &bgrt_attribute_group);
144 if (ret)
145 goto out_kobject;
146
147 ret = sysfs_create_bin_file(bgrt_kobj, &image_attr);
148 if (ret)
149 goto out_group;
150
151 return 0;
152
153out_group:
154 sysfs_remove_group(bgrt_kobj, &bgrt_attribute_group);
155out_kobject:
156 kobject_put(bgrt_kobj);
157out_iounmap:
158 iounmap(image_attr.private);
159out_err:
160 return ret;
161}
162
163static void __exit bgrt_exit(void)
164{
165 iounmap(image_attr.private);
166 sysfs_remove_group(bgrt_kobj, &bgrt_attribute_group);
167 sysfs_remove_bin_file(bgrt_kobj, &image_attr);
168}
169
170module_init(bgrt_init);
171module_exit(bgrt_exit);
172
173MODULE_AUTHOR("Matthew Garrett");
174MODULE_DESCRIPTION("BGRT boot graphic support");
175MODULE_LICENSE("GPL");
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 9ecec98bc76e..3263b68cdfa3 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -1010,6 +1010,7 @@ static int __init acpi_bus_init(void)
1010} 1010}
1011 1011
1012struct kobject *acpi_kobj; 1012struct kobject *acpi_kobj;
1013EXPORT_SYMBOL_GPL(acpi_kobj);
1013 1014
1014static int __init acpi_init(void) 1015static int __init acpi_init(void)
1015{ 1016{
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index b19a18dd994f..3268dcfbaa9b 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -812,10 +812,10 @@ static int acpi_ec_add(struct acpi_device *device)
812 first_ec = ec; 812 first_ec = ec;
813 device->driver_data = ec; 813 device->driver_data = ec;
814 814
815 WARN(!request_region(ec->data_addr, 1, "EC data"), 815 ret = !!request_region(ec->data_addr, 1, "EC data");
816 "Could not request EC data io port 0x%lx", ec->data_addr); 816 WARN(!ret, "Could not request EC data io port 0x%lx", ec->data_addr);
817 WARN(!request_region(ec->command_addr, 1, "EC cmd"), 817 ret = !!request_region(ec->command_addr, 1, "EC cmd");
818 "Could not request EC cmd io port 0x%lx", ec->command_addr); 818 WARN(!ret, "Could not request EC cmd io port 0x%lx", ec->command_addr);
819 819
820 pr_info(PREFIX "GPE = 0x%lx, I/O: command/status = 0x%lx, data = 0x%lx\n", 820 pr_info(PREFIX "GPE = 0x%lx, I/O: command/status = 0x%lx, data = 0x%lx\n",
821 ec->gpe, ec->command_addr, ec->data_addr); 821 ec->gpe, ec->command_addr, ec->data_addr);
diff --git a/drivers/acpi/nvs.c b/drivers/acpi/nvs.c
index 7a2035fa8c71..266bc58ce0ce 100644
--- a/drivers/acpi/nvs.c
+++ b/drivers/acpi/nvs.c
@@ -95,8 +95,8 @@ static int suspend_nvs_register(unsigned long start, unsigned long size)
95{ 95{
96 struct nvs_page *entry, *next; 96 struct nvs_page *entry, *next;
97 97
98 pr_info("PM: Registering ACPI NVS region at %lx (%ld bytes)\n", 98 pr_info("PM: Registering ACPI NVS region [mem %#010lx-%#010lx] (%ld bytes)\n",
99 start, size); 99 start, start + size - 1, size);
100 100
101 while (size > 0) { 101 while (size > 0) {
102 unsigned int nr_bytes; 102 unsigned int nr_bytes;
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 412a1e04a922..9fddb55764f3 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -347,7 +347,7 @@ static void acpi_unmap(acpi_physical_address pg_off, void __iomem *vaddr)
347 unsigned long pfn; 347 unsigned long pfn;
348 348
349 pfn = pg_off >> PAGE_SHIFT; 349 pfn = pg_off >> PAGE_SHIFT;
350 if (page_is_ram(pfn)) 350 if (should_use_kmap(pfn))
351 kunmap(pfn_to_page(pfn)); 351 kunmap(pfn_to_page(pfn));
352 else 352 else
353 iounmap(vaddr); 353 iounmap(vaddr);
@@ -554,6 +554,15 @@ acpi_os_table_override(struct acpi_table_header * existing_table,
554 return AE_OK; 554 return AE_OK;
555} 555}
556 556
557acpi_status
558acpi_os_physical_table_override(struct acpi_table_header *existing_table,
559 acpi_physical_address * new_address,
560 u32 *new_table_length)
561{
562 return AE_SUPPORT;
563}
564
565
557static irqreturn_t acpi_irq(int irq, void *dev_id) 566static irqreturn_t acpi_irq(int irq, void *dev_id)
558{ 567{
559 u32 handled; 568 u32 handled;
@@ -595,7 +604,8 @@ acpi_os_install_interrupt_handler(u32 gsi, acpi_osd_handler handler,
595 604
596 acpi_irq_handler = handler; 605 acpi_irq_handler = handler;
597 acpi_irq_context = context; 606 acpi_irq_context = context;
598 if (request_irq(irq, acpi_irq, IRQF_SHARED, "acpi", acpi_irq)) { 607 if (request_threaded_irq(irq, NULL, acpi_irq, IRQF_SHARED, "acpi",
608 acpi_irq)) {
599 printk(KERN_ERR PREFIX "SCI (IRQ%d) allocation failed\n", irq); 609 printk(KERN_ERR PREFIX "SCI (IRQ%d) allocation failed\n", irq);
600 acpi_irq_handler = NULL; 610 acpi_irq_handler = NULL;
601 return AE_NOT_ACQUIRED; 611 return AE_NOT_ACQUIRED;
@@ -699,49 +709,6 @@ acpi_status acpi_os_write_port(acpi_io_address port, u32 value, u32 width)
699 709
700EXPORT_SYMBOL(acpi_os_write_port); 710EXPORT_SYMBOL(acpi_os_write_port);
701 711
702acpi_status
703acpi_os_read_memory(acpi_physical_address phys_addr, u32 * value, u32 width)
704{
705 void __iomem *virt_addr;
706 unsigned int size = width / 8;
707 bool unmap = false;
708 u32 dummy;
709
710 rcu_read_lock();
711 virt_addr = acpi_map_vaddr_lookup(phys_addr, size);
712 if (!virt_addr) {
713 rcu_read_unlock();
714 virt_addr = acpi_os_ioremap(phys_addr, size);
715 if (!virt_addr)
716 return AE_BAD_ADDRESS;
717 unmap = true;
718 }
719
720 if (!value)
721 value = &dummy;
722
723 switch (width) {
724 case 8:
725 *(u8 *) value = readb(virt_addr);
726 break;
727 case 16:
728 *(u16 *) value = readw(virt_addr);
729 break;
730 case 32:
731 *(u32 *) value = readl(virt_addr);
732 break;
733 default:
734 BUG();
735 }
736
737 if (unmap)
738 iounmap(virt_addr);
739 else
740 rcu_read_unlock();
741
742 return AE_OK;
743}
744
745#ifdef readq 712#ifdef readq
746static inline u64 read64(const volatile void __iomem *addr) 713static inline u64 read64(const volatile void __iomem *addr)
747{ 714{
@@ -758,7 +725,7 @@ static inline u64 read64(const volatile void __iomem *addr)
758#endif 725#endif
759 726
760acpi_status 727acpi_status
761acpi_os_read_memory64(acpi_physical_address phys_addr, u64 *value, u32 width) 728acpi_os_read_memory(acpi_physical_address phys_addr, u64 *value, u32 width)
762{ 729{
763 void __iomem *virt_addr; 730 void __iomem *virt_addr;
764 unsigned int size = width / 8; 731 unsigned int size = width / 8;
@@ -803,45 +770,6 @@ acpi_os_read_memory64(acpi_physical_address phys_addr, u64 *value, u32 width)
803 return AE_OK; 770 return AE_OK;
804} 771}
805 772
806acpi_status
807acpi_os_write_memory(acpi_physical_address phys_addr, u32 value, u32 width)
808{
809 void __iomem *virt_addr;
810 unsigned int size = width / 8;
811 bool unmap = false;
812
813 rcu_read_lock();
814 virt_addr = acpi_map_vaddr_lookup(phys_addr, size);
815 if (!virt_addr) {
816 rcu_read_unlock();
817 virt_addr = acpi_os_ioremap(phys_addr, size);
818 if (!virt_addr)
819 return AE_BAD_ADDRESS;
820 unmap = true;
821 }
822
823 switch (width) {
824 case 8:
825 writeb(value, virt_addr);
826 break;
827 case 16:
828 writew(value, virt_addr);
829 break;
830 case 32:
831 writel(value, virt_addr);
832 break;
833 default:
834 BUG();
835 }
836
837 if (unmap)
838 iounmap(virt_addr);
839 else
840 rcu_read_unlock();
841
842 return AE_OK;
843}
844
845#ifdef writeq 773#ifdef writeq
846static inline void write64(u64 val, volatile void __iomem *addr) 774static inline void write64(u64 val, volatile void __iomem *addr)
847{ 775{
@@ -856,7 +784,7 @@ static inline void write64(u64 val, volatile void __iomem *addr)
856#endif 784#endif
857 785
858acpi_status 786acpi_status
859acpi_os_write_memory64(acpi_physical_address phys_addr, u64 value, u32 width) 787acpi_os_write_memory(acpi_physical_address phys_addr, u64 value, u32 width)
860{ 788{
861 void __iomem *virt_addr; 789 void __iomem *virt_addr;
862 unsigned int size = width / 8; 790 unsigned int size = width / 8;
diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
index 50be27739fe8..41de1355edcd 100644
--- a/drivers/acpi/processor_driver.c
+++ b/drivers/acpi/processor_driver.c
@@ -536,8 +536,8 @@ static int __cpuinit acpi_processor_add(struct acpi_device *device)
536 return -ENOMEM; 536 return -ENOMEM;
537 537
538 if (!zalloc_cpumask_var(&pr->throttling.shared_cpu_map, GFP_KERNEL)) { 538 if (!zalloc_cpumask_var(&pr->throttling.shared_cpu_map, GFP_KERNEL)) {
539 kfree(pr); 539 result = -ENOMEM;
540 return -ENOMEM; 540 goto err_free_pr;
541 } 541 }
542 542
543 pr->handle = device->handle; 543 pr->handle = device->handle;
@@ -577,7 +577,7 @@ static int __cpuinit acpi_processor_add(struct acpi_device *device)
577 dev = get_cpu_device(pr->id); 577 dev = get_cpu_device(pr->id);
578 if (sysfs_create_link(&device->dev.kobj, &dev->kobj, "sysdev")) { 578 if (sysfs_create_link(&device->dev.kobj, &dev->kobj, "sysdev")) {
579 result = -EFAULT; 579 result = -EFAULT;
580 goto err_free_cpumask; 580 goto err_clear_processor;
581 } 581 }
582 582
583 /* 583 /*
@@ -595,9 +595,15 @@ static int __cpuinit acpi_processor_add(struct acpi_device *device)
595 595
596err_remove_sysfs: 596err_remove_sysfs:
597 sysfs_remove_link(&device->dev.kobj, "sysdev"); 597 sysfs_remove_link(&device->dev.kobj, "sysdev");
598err_clear_processor:
599 /*
600 * processor_device_array is not cleared to allow checks for buggy BIOS
601 */
602 per_cpu(processors, pr->id) = NULL;
598err_free_cpumask: 603err_free_cpumask:
599 free_cpumask_var(pr->throttling.shared_cpu_map); 604 free_cpumask_var(pr->throttling.shared_cpu_map);
600 605err_free_pr:
606 kfree(pr);
601 return result; 607 return result;
602} 608}
603 609
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index 0e8e2de2ed3e..b3447f63e46b 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -770,6 +770,35 @@ static int acpi_idle_enter_c1(struct cpuidle_device *dev,
770 return index; 770 return index;
771} 771}
772 772
773
774/**
775 * acpi_idle_play_dead - enters an ACPI state for long-term idle (i.e. off-lining)
776 * @dev: the target CPU
777 * @index: the index of suggested state
778 */
779static int acpi_idle_play_dead(struct cpuidle_device *dev, int index)
780{
781 struct cpuidle_state_usage *state_usage = &dev->states_usage[index];
782 struct acpi_processor_cx *cx = cpuidle_get_statedata(state_usage);
783
784 ACPI_FLUSH_CPU_CACHE();
785
786 while (1) {
787
788 if (cx->entry_method == ACPI_CSTATE_HALT)
789 halt();
790 else if (cx->entry_method == ACPI_CSTATE_SYSTEMIO) {
791 inb(cx->address);
792 /* See comment in acpi_idle_do_entry() */
793 inl(acpi_gbl_FADT.xpm_timer_block.address);
794 } else
795 return -ENODEV;
796 }
797
798 /* Never reached */
799 return 0;
800}
801
773/** 802/**
774 * acpi_idle_enter_simple - enters an ACPI state without BM handling 803 * acpi_idle_enter_simple - enters an ACPI state without BM handling
775 * @dev: the target CPU 804 * @dev: the target CPU
@@ -1077,12 +1106,14 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
1077 state->flags |= CPUIDLE_FLAG_TIME_VALID; 1106 state->flags |= CPUIDLE_FLAG_TIME_VALID;
1078 1107
1079 state->enter = acpi_idle_enter_c1; 1108 state->enter = acpi_idle_enter_c1;
1109 state->enter_dead = acpi_idle_play_dead;
1080 drv->safe_state_index = count; 1110 drv->safe_state_index = count;
1081 break; 1111 break;
1082 1112
1083 case ACPI_STATE_C2: 1113 case ACPI_STATE_C2:
1084 state->flags |= CPUIDLE_FLAG_TIME_VALID; 1114 state->flags |= CPUIDLE_FLAG_TIME_VALID;
1085 state->enter = acpi_idle_enter_simple; 1115 state->enter = acpi_idle_enter_simple;
1116 state->enter_dead = acpi_idle_play_dead;
1086 drv->safe_state_index = count; 1117 drv->safe_state_index = count;
1087 break; 1118 break;
1088 1119
@@ -1159,8 +1190,7 @@ int acpi_processor_cst_has_changed(struct acpi_processor *pr)
1159 * to make the code that updates C-States be called once. 1190 * to make the code that updates C-States be called once.
1160 */ 1191 */
1161 1192
1162 if (smp_processor_id() == 0 && 1193 if (pr->id == 0 && cpuidle_get_driver() == &acpi_idle_driver) {
1163 cpuidle_get_driver() == &acpi_idle_driver) {
1164 1194
1165 cpuidle_pause_and_lock(); 1195 cpuidle_pause_and_lock();
1166 /* Protect against cpu-hotplug */ 1196 /* Protect against cpu-hotplug */
diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_thermal.c
index 3b599abf2b40..641b5450a0db 100644
--- a/drivers/acpi/processor_thermal.c
+++ b/drivers/acpi/processor_thermal.c
@@ -57,6 +57,27 @@ ACPI_MODULE_NAME("processor_thermal");
57static DEFINE_PER_CPU(unsigned int, cpufreq_thermal_reduction_pctg); 57static DEFINE_PER_CPU(unsigned int, cpufreq_thermal_reduction_pctg);
58static unsigned int acpi_thermal_cpufreq_is_init = 0; 58static unsigned int acpi_thermal_cpufreq_is_init = 0;
59 59
60#define reduction_pctg(cpu) \
61 per_cpu(cpufreq_thermal_reduction_pctg, phys_package_first_cpu(cpu))
62
63/*
64 * Emulate "per package data" using per cpu data (which should really be
65 * provided elsewhere)
66 *
67 * Note we can lose a CPU on cpu hotunplug, in this case we forget the state
68 * temporarily. Fortunately that's not a big issue here (I hope)
69 */
70static int phys_package_first_cpu(int cpu)
71{
72 int i;
73 int id = topology_physical_package_id(cpu);
74
75 for_each_online_cpu(i)
76 if (topology_physical_package_id(i) == id)
77 return i;
78 return 0;
79}
80
60static int cpu_has_cpufreq(unsigned int cpu) 81static int cpu_has_cpufreq(unsigned int cpu)
61{ 82{
62 struct cpufreq_policy policy; 83 struct cpufreq_policy policy;
@@ -76,7 +97,7 @@ static int acpi_thermal_cpufreq_notifier(struct notifier_block *nb,
76 97
77 max_freq = ( 98 max_freq = (
78 policy->cpuinfo.max_freq * 99 policy->cpuinfo.max_freq *
79 (100 - per_cpu(cpufreq_thermal_reduction_pctg, policy->cpu) * 20) 100 (100 - reduction_pctg(policy->cpu) * 20)
80 ) / 100; 101 ) / 100;
81 102
82 cpufreq_verify_within_limits(policy, 0, max_freq); 103 cpufreq_verify_within_limits(policy, 0, max_freq);
@@ -102,16 +123,28 @@ static int cpufreq_get_cur_state(unsigned int cpu)
102 if (!cpu_has_cpufreq(cpu)) 123 if (!cpu_has_cpufreq(cpu))
103 return 0; 124 return 0;
104 125
105 return per_cpu(cpufreq_thermal_reduction_pctg, cpu); 126 return reduction_pctg(cpu);
106} 127}
107 128
108static int cpufreq_set_cur_state(unsigned int cpu, int state) 129static int cpufreq_set_cur_state(unsigned int cpu, int state)
109{ 130{
131 int i;
132
110 if (!cpu_has_cpufreq(cpu)) 133 if (!cpu_has_cpufreq(cpu))
111 return 0; 134 return 0;
112 135
113 per_cpu(cpufreq_thermal_reduction_pctg, cpu) = state; 136 reduction_pctg(cpu) = state;
114 cpufreq_update_policy(cpu); 137
138 /*
139 * Update all the CPUs in the same package because they all
140 * contribute to the temperature and often share the same
141 * frequency.
142 */
143 for_each_online_cpu(i) {
144 if (topology_physical_package_id(i) ==
145 topology_physical_package_id(cpu))
146 cpufreq_update_policy(i);
147 }
115 return 0; 148 return 0;
116} 149}
117 150
@@ -119,10 +152,6 @@ void acpi_thermal_cpufreq_init(void)
119{ 152{
120 int i; 153 int i;
121 154
122 for (i = 0; i < nr_cpu_ids; i++)
123 if (cpu_present(i))
124 per_cpu(cpufreq_thermal_reduction_pctg, i) = 0;
125
126 i = cpufreq_register_notifier(&acpi_thermal_cpufreq_notifier_block, 155 i = cpufreq_register_notifier(&acpi_thermal_cpufreq_notifier_block,
127 CPUFREQ_POLICY_NOTIFIER); 156 CPUFREQ_POLICY_NOTIFIER);
128 if (!i) 157 if (!i)
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index 605a2954ef17..1d02b7b5ade0 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -769,7 +769,7 @@ static int acpi_read_throttling_status(struct acpi_processor *pr,
769 u64 *value) 769 u64 *value)
770{ 770{
771 u32 bit_width, bit_offset; 771 u32 bit_width, bit_offset;
772 u64 ptc_value; 772 u32 ptc_value;
773 u64 ptc_mask; 773 u64 ptc_mask;
774 struct acpi_processor_throttling *throttling; 774 struct acpi_processor_throttling *throttling;
775 int ret = -1; 775 int ret = -1;
@@ -777,12 +777,11 @@ static int acpi_read_throttling_status(struct acpi_processor *pr,
777 throttling = &pr->throttling; 777 throttling = &pr->throttling;
778 switch (throttling->status_register.space_id) { 778 switch (throttling->status_register.space_id) {
779 case ACPI_ADR_SPACE_SYSTEM_IO: 779 case ACPI_ADR_SPACE_SYSTEM_IO:
780 ptc_value = 0;
781 bit_width = throttling->status_register.bit_width; 780 bit_width = throttling->status_register.bit_width;
782 bit_offset = throttling->status_register.bit_offset; 781 bit_offset = throttling->status_register.bit_offset;
783 782
784 acpi_os_read_port((acpi_io_address) throttling->status_register. 783 acpi_os_read_port((acpi_io_address) throttling->status_register.
785 address, (u32 *) &ptc_value, 784 address, &ptc_value,
786 (u32) (bit_width + bit_offset)); 785 (u32) (bit_width + bit_offset));
787 ptc_mask = (1 << bit_width) - 1; 786 ptc_mask = (1 << bit_width) - 1;
788 *value = (u64) ((ptc_value >> bit_offset) & ptc_mask); 787 *value = (u64) ((ptc_value >> bit_offset) & ptc_mask);
diff --git a/drivers/acpi/reboot.c b/drivers/acpi/reboot.c
index a6c77e8b37bd..c1d612435939 100644
--- a/drivers/acpi/reboot.c
+++ b/drivers/acpi/reboot.c
@@ -23,8 +23,7 @@ void acpi_reboot(void)
23 /* Is the reset register supported? The spec says we should be 23 /* Is the reset register supported? The spec says we should be
24 * checking the bit width and bit offset, but Windows ignores 24 * checking the bit width and bit offset, but Windows ignores
25 * these fields */ 25 * these fields */
26 if (!(acpi_gbl_FADT.flags & ACPI_FADT_RESET_REGISTER)) 26 /* Ignore also acpi_gbl_FADT.flags.ACPI_FADT_RESET_REGISTER */
27 return;
28 27
29 reset_value = acpi_gbl_FADT.reset_value; 28 reset_value = acpi_gbl_FADT.reset_value;
30 29
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 8ab80bafe3f1..5d24a17aa854 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -880,7 +880,6 @@ static int acpi_bus_get_power_flags(struct acpi_device *device)
880 int j; 880 int j;
881 881
882 device->power.flags.power_resources = 1; 882 device->power.flags.power_resources = 1;
883 ps->flags.valid = 1;
884 for (j = 0; j < ps->resources.count; j++) 883 for (j = 0; j < ps->resources.count; j++)
885 acpi_bus_add_power_resource(ps->resources.handles[j]); 884 acpi_bus_add_power_resource(ps->resources.handles[j]);
886 } 885 }
@@ -888,10 +887,8 @@ static int acpi_bus_get_power_flags(struct acpi_device *device)
888 /* Evaluate "_PSx" to see if we can do explicit sets */ 887 /* Evaluate "_PSx" to see if we can do explicit sets */
889 object_name[2] = 'S'; 888 object_name[2] = 'S';
890 status = acpi_get_handle(device->handle, object_name, &handle); 889 status = acpi_get_handle(device->handle, object_name, &handle);
891 if (ACPI_SUCCESS(status)) { 890 if (ACPI_SUCCESS(status))
892 ps->flags.explicit_set = 1; 891 ps->flags.explicit_set = 1;
893 ps->flags.valid = 1;
894 }
895 892
896 /* State is valid if we have some power control */ 893 /* State is valid if we have some power control */
897 if (ps->resources.count || ps->flags.explicit_set) 894 if (ps->resources.count || ps->flags.explicit_set)
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index ca191ff97844..acf81fe86b53 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -17,6 +17,7 @@
17#include <linux/suspend.h> 17#include <linux/suspend.h>
18#include <linux/reboot.h> 18#include <linux/reboot.h>
19#include <linux/acpi.h> 19#include <linux/acpi.h>
20#include <linux/module.h>
20 21
21#include <asm/io.h> 22#include <asm/io.h>
22 23
@@ -26,6 +27,24 @@
26#include "internal.h" 27#include "internal.h"
27#include "sleep.h" 28#include "sleep.h"
28 29
30static unsigned int gts, bfs;
31module_param(gts, uint, 0644);
32module_param(bfs, uint, 0644);
33MODULE_PARM_DESC(gts, "Enable evaluation of _GTS on suspend.");
34MODULE_PARM_DESC(bfs, "Enable evaluation of _BFS on resume".);
35
36static u8 wake_sleep_flags(void)
37{
38 u8 flags = ACPI_NO_OPTIONAL_METHODS;
39
40 if (gts)
41 flags |= ACPI_EXECUTE_GTS;
42 if (bfs)
43 flags |= ACPI_EXECUTE_BFS;
44
45 return flags;
46}
47
29static u8 sleep_states[ACPI_S_STATE_COUNT]; 48static u8 sleep_states[ACPI_S_STATE_COUNT];
30 49
31static void acpi_sleep_tts_switch(u32 acpi_state) 50static void acpi_sleep_tts_switch(u32 acpi_state)
@@ -243,6 +262,7 @@ static int acpi_suspend_enter(suspend_state_t pm_state)
243{ 262{
244 acpi_status status = AE_OK; 263 acpi_status status = AE_OK;
245 u32 acpi_state = acpi_target_sleep_state; 264 u32 acpi_state = acpi_target_sleep_state;
265 u8 flags = wake_sleep_flags();
246 int error; 266 int error;
247 267
248 ACPI_FLUSH_CPU_CACHE(); 268 ACPI_FLUSH_CPU_CACHE();
@@ -250,7 +270,7 @@ static int acpi_suspend_enter(suspend_state_t pm_state)
250 switch (acpi_state) { 270 switch (acpi_state) {
251 case ACPI_STATE_S1: 271 case ACPI_STATE_S1:
252 barrier(); 272 barrier();
253 status = acpi_enter_sleep_state(acpi_state); 273 status = acpi_enter_sleep_state(acpi_state, flags);
254 break; 274 break;
255 275
256 case ACPI_STATE_S3: 276 case ACPI_STATE_S3:
@@ -265,7 +285,7 @@ static int acpi_suspend_enter(suspend_state_t pm_state)
265 acpi_write_bit_register(ACPI_BITREG_SCI_ENABLE, 1); 285 acpi_write_bit_register(ACPI_BITREG_SCI_ENABLE, 1);
266 286
267 /* Reprogram control registers and execute _BFS */ 287 /* Reprogram control registers and execute _BFS */
268 acpi_leave_sleep_state_prep(acpi_state); 288 acpi_leave_sleep_state_prep(acpi_state, flags);
269 289
270 /* ACPI 3.0 specs (P62) says that it's the responsibility 290 /* ACPI 3.0 specs (P62) says that it's the responsibility
271 * of the OSPM to clear the status bit [ implying that the 291 * of the OSPM to clear the status bit [ implying that the
@@ -529,27 +549,30 @@ static int acpi_hibernation_begin(void)
529 549
530static int acpi_hibernation_enter(void) 550static int acpi_hibernation_enter(void)
531{ 551{
552 u8 flags = wake_sleep_flags();
532 acpi_status status = AE_OK; 553 acpi_status status = AE_OK;
533 554
534 ACPI_FLUSH_CPU_CACHE(); 555 ACPI_FLUSH_CPU_CACHE();
535 556
536 /* This shouldn't return. If it returns, we have a problem */ 557 /* This shouldn't return. If it returns, we have a problem */
537 status = acpi_enter_sleep_state(ACPI_STATE_S4); 558 status = acpi_enter_sleep_state(ACPI_STATE_S4, flags);
538 /* Reprogram control registers and execute _BFS */ 559 /* Reprogram control registers and execute _BFS */
539 acpi_leave_sleep_state_prep(ACPI_STATE_S4); 560 acpi_leave_sleep_state_prep(ACPI_STATE_S4, flags);
540 561
541 return ACPI_SUCCESS(status) ? 0 : -EFAULT; 562 return ACPI_SUCCESS(status) ? 0 : -EFAULT;
542} 563}
543 564
544static void acpi_hibernation_leave(void) 565static void acpi_hibernation_leave(void)
545{ 566{
567 u8 flags = wake_sleep_flags();
568
546 /* 569 /*
547 * If ACPI is not enabled by the BIOS and the boot kernel, we need to 570 * If ACPI is not enabled by the BIOS and the boot kernel, we need to
548 * enable it here. 571 * enable it here.
549 */ 572 */
550 acpi_enable(); 573 acpi_enable();
551 /* Reprogram control registers and execute _BFS */ 574 /* Reprogram control registers and execute _BFS */
552 acpi_leave_sleep_state_prep(ACPI_STATE_S4); 575 acpi_leave_sleep_state_prep(ACPI_STATE_S4, flags);
553 /* Check the hardware signature */ 576 /* Check the hardware signature */
554 if (facs && s4_hardware_signature != facs->hardware_signature) { 577 if (facs && s4_hardware_signature != facs->hardware_signature) {
555 printk(KERN_EMERG "ACPI: Hardware changed while hibernated, " 578 printk(KERN_EMERG "ACPI: Hardware changed while hibernated, "
@@ -770,10 +793,12 @@ static void acpi_power_off_prepare(void)
770 793
771static void acpi_power_off(void) 794static void acpi_power_off(void)
772{ 795{
796 u8 flags = wake_sleep_flags();
797
773 /* acpi_sleep_prepare(ACPI_STATE_S5) should have already been called */ 798 /* acpi_sleep_prepare(ACPI_STATE_S5) should have already been called */
774 printk(KERN_DEBUG "%s called\n", __func__); 799 printk(KERN_DEBUG "%s called\n", __func__);
775 local_irq_disable(); 800 local_irq_disable();
776 acpi_enter_sleep_state(ACPI_STATE_S5); 801 acpi_enter_sleep_state(ACPI_STATE_S5, flags);
777} 802}
778 803
779/* 804/*
@@ -788,13 +813,13 @@ static void __init acpi_gts_bfs_check(void)
788{ 813{
789 acpi_handle dummy; 814 acpi_handle dummy;
790 815
791 if (ACPI_SUCCESS(acpi_get_handle(ACPI_ROOT_OBJECT, METHOD_NAME__GTS, &dummy))) 816 if (ACPI_SUCCESS(acpi_get_handle(ACPI_ROOT_OBJECT, METHOD_PATHNAME__GTS, &dummy)))
792 { 817 {
793 printk(KERN_NOTICE PREFIX "BIOS offers _GTS\n"); 818 printk(KERN_NOTICE PREFIX "BIOS offers _GTS\n");
794 printk(KERN_NOTICE PREFIX "If \"acpi.gts=1\" improves suspend, " 819 printk(KERN_NOTICE PREFIX "If \"acpi.gts=1\" improves suspend, "
795 "please notify linux-acpi@vger.kernel.org\n"); 820 "please notify linux-acpi@vger.kernel.org\n");
796 } 821 }
797 if (ACPI_SUCCESS(acpi_get_handle(ACPI_ROOT_OBJECT, METHOD_NAME__BFS, &dummy))) 822 if (ACPI_SUCCESS(acpi_get_handle(ACPI_ROOT_OBJECT, METHOD_PATHNAME__BFS, &dummy)))
798 { 823 {
799 printk(KERN_NOTICE PREFIX "BIOS offers _BFS\n"); 824 printk(KERN_NOTICE PREFIX "BIOS offers _BFS\n");
800 printk(KERN_NOTICE PREFIX "If \"acpi.bfs=1\" improves resume, " 825 printk(KERN_NOTICE PREFIX "If \"acpi.bfs=1\" improves resume, "
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index 48fbc647b178..7dbebea1ec31 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -941,13 +941,13 @@ static int acpi_thermal_get_info(struct acpi_thermal *tz)
941 if (!tz) 941 if (!tz)
942 return -EINVAL; 942 return -EINVAL;
943 943
944 /* Get temperature [_TMP] (required) */ 944 /* Get trip points [_CRT, _PSV, etc.] (required) */
945 result = acpi_thermal_get_temperature(tz); 945 result = acpi_thermal_get_trip_points(tz);
946 if (result) 946 if (result)
947 return result; 947 return result;
948 948
949 /* Get trip points [_CRT, _PSV, etc.] (required) */ 949 /* Get temperature [_TMP] (required) */
950 result = acpi_thermal_get_trip_points(tz); 950 result = acpi_thermal_get_temperature(tz);
951 if (result) 951 if (result)
952 return result; 952 return result;
953 953
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index eaef02afc7cf..9577b6fa2650 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -548,27 +548,27 @@ acpi_video_device_EDID(struct acpi_video_device *device,
548 * 1. The system BIOS should NOT automatically control the brightness 548 * 1. The system BIOS should NOT automatically control the brightness
549 * level of the LCD when the power changes from AC to DC. 549 * level of the LCD when the power changes from AC to DC.
550 * Return Value: 550 * Return Value:
551 * -1 wrong arg. 551 * -EINVAL wrong arg.
552 */ 552 */
553 553
554static int 554static int
555acpi_video_bus_DOS(struct acpi_video_bus *video, int bios_flag, int lcd_flag) 555acpi_video_bus_DOS(struct acpi_video_bus *video, int bios_flag, int lcd_flag)
556{ 556{
557 u64 status = 0; 557 acpi_status status;
558 union acpi_object arg0 = { ACPI_TYPE_INTEGER }; 558 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
559 struct acpi_object_list args = { 1, &arg0 }; 559 struct acpi_object_list args = { 1, &arg0 };
560 560
561 561
562 if (bios_flag < 0 || bios_flag > 3 || lcd_flag < 0 || lcd_flag > 1) { 562 if (bios_flag < 0 || bios_flag > 3 || lcd_flag < 0 || lcd_flag > 1)
563 status = -1; 563 return -EINVAL;
564 goto Failed;
565 }
566 arg0.integer.value = (lcd_flag << 2) | bios_flag; 564 arg0.integer.value = (lcd_flag << 2) | bios_flag;
567 video->dos_setting = arg0.integer.value; 565 video->dos_setting = arg0.integer.value;
568 acpi_evaluate_object(video->device->handle, "_DOS", &args, NULL); 566 status = acpi_evaluate_object(video->device->handle, "_DOS",
567 &args, NULL);
568 if (ACPI_FAILURE(status))
569 return -EIO;
569 570
570 Failed: 571 return 0;
571 return status;
572} 572}
573 573
574/* 574/*
@@ -1343,15 +1343,17 @@ static int
1343acpi_video_bus_get_devices(struct acpi_video_bus *video, 1343acpi_video_bus_get_devices(struct acpi_video_bus *video,
1344 struct acpi_device *device) 1344 struct acpi_device *device)
1345{ 1345{
1346 int status = 0; 1346 int status;
1347 struct acpi_device *dev; 1347 struct acpi_device *dev;
1348 1348
1349 acpi_video_device_enumerate(video); 1349 status = acpi_video_device_enumerate(video);
1350 if (status)
1351 return status;
1350 1352
1351 list_for_each_entry(dev, &device->children, node) { 1353 list_for_each_entry(dev, &device->children, node) {
1352 1354
1353 status = acpi_video_bus_get_one_device(dev, video); 1355 status = acpi_video_bus_get_one_device(dev, video);
1354 if (ACPI_FAILURE(status)) { 1356 if (status) {
1355 printk(KERN_WARNING PREFIX 1357 printk(KERN_WARNING PREFIX
1356 "Can't attach device\n"); 1358 "Can't attach device\n");
1357 continue; 1359 continue;
@@ -1653,15 +1655,20 @@ static int acpi_video_bus_add(struct acpi_device *device)
1653 mutex_init(&video->device_list_lock); 1655 mutex_init(&video->device_list_lock);
1654 INIT_LIST_HEAD(&video->video_device_list); 1656 INIT_LIST_HEAD(&video->video_device_list);
1655 1657
1656 acpi_video_bus_get_devices(video, device); 1658 error = acpi_video_bus_get_devices(video, device);
1657 acpi_video_bus_start_devices(video); 1659 if (error)
1660 goto err_free_video;
1658 1661
1659 video->input = input = input_allocate_device(); 1662 video->input = input = input_allocate_device();
1660 if (!input) { 1663 if (!input) {
1661 error = -ENOMEM; 1664 error = -ENOMEM;
1662 goto err_stop_video; 1665 goto err_put_video;
1663 } 1666 }
1664 1667
1668 error = acpi_video_bus_start_devices(video);
1669 if (error)
1670 goto err_free_input_dev;
1671
1665 snprintf(video->phys, sizeof(video->phys), 1672 snprintf(video->phys, sizeof(video->phys),
1666 "%s/video/input0", acpi_device_hid(video->device)); 1673 "%s/video/input0", acpi_device_hid(video->device));
1667 1674
@@ -1682,7 +1689,7 @@ static int acpi_video_bus_add(struct acpi_device *device)
1682 1689
1683 error = input_register_device(input); 1690 error = input_register_device(input);
1684 if (error) 1691 if (error)
1685 goto err_free_input_dev; 1692 goto err_stop_video;
1686 1693
1687 printk(KERN_INFO PREFIX "%s [%s] (multi-head: %s rom: %s post: %s)\n", 1694 printk(KERN_INFO PREFIX "%s [%s] (multi-head: %s rom: %s post: %s)\n",
1688 ACPI_VIDEO_DEVICE_NAME, acpi_device_bid(device), 1695 ACPI_VIDEO_DEVICE_NAME, acpi_device_bid(device),
@@ -1692,14 +1699,19 @@ static int acpi_video_bus_add(struct acpi_device *device)
1692 1699
1693 video->pm_nb.notifier_call = acpi_video_resume; 1700 video->pm_nb.notifier_call = acpi_video_resume;
1694 video->pm_nb.priority = 0; 1701 video->pm_nb.priority = 0;
1695 register_pm_notifier(&video->pm_nb); 1702 error = register_pm_notifier(&video->pm_nb);
1703 if (error)
1704 goto err_unregister_input_dev;
1696 1705
1697 return 0; 1706 return 0;
1698 1707
1699 err_free_input_dev: 1708 err_unregister_input_dev:
1700 input_free_device(input); 1709 input_unregister_device(input);
1701 err_stop_video: 1710 err_stop_video:
1702 acpi_video_bus_stop_devices(video); 1711 acpi_video_bus_stop_devices(video);
1712 err_free_input_dev:
1713 input_free_device(input);
1714 err_put_video:
1703 acpi_video_bus_put_devices(video); 1715 acpi_video_bus_put_devices(video);
1704 kfree(video->attached_array); 1716 kfree(video->attached_array);
1705 err_free_video: 1717 err_free_video: