diff options
author | Shaohua Li <shaohua.li@intel.com> | 2009-10-28 23:04:50 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2009-12-16 14:05:11 -0500 |
commit | 3a9622dc4659af44a8098a233f65c51e495ff0a5 (patch) | |
tree | 8e0dd5d1f31ad6a9047b0ba5faf26a3759d9e2fd | |
parent | 70023de88c58a81a730ab4d13c51a30e537ec76e (diff) |
ACPI: cleanup pci_root _OSC code.
Signed-off-by: Shaohua Li <shaohua.li@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
-rw-r--r-- | drivers/acpi/pci_root.c | 76 | ||||
-rw-r--r-- | include/linux/acpi.h | 5 |
2 files changed, 17 insertions, 64 deletions
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index 1af808171d4..101cce3681d 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c | |||
@@ -202,72 +202,24 @@ static void acpi_pci_bridge_scan(struct acpi_device *device) | |||
202 | } | 202 | } |
203 | } | 203 | } |
204 | 204 | ||
205 | static u8 OSC_UUID[16] = {0x5B, 0x4D, 0xDB, 0x33, 0xF7, 0x1F, 0x1C, 0x40, | 205 | static u8 pci_osc_uuid_str[] = "33DB4D5B-1FF7-401C-9657-7441C03DD766"; |
206 | 0x96, 0x57, 0x74, 0x41, 0xC0, 0x3D, 0xD7, 0x66}; | ||
207 | 206 | ||
208 | static acpi_status acpi_pci_run_osc(acpi_handle handle, | 207 | static acpi_status acpi_pci_run_osc(acpi_handle handle, |
209 | const u32 *capbuf, u32 *retval) | 208 | const u32 *capbuf, u32 *retval) |
210 | { | 209 | { |
210 | struct acpi_osc_context context = { | ||
211 | .uuid_str = pci_osc_uuid_str, | ||
212 | .rev = 1, | ||
213 | .cap.length = 12, | ||
214 | .cap.pointer = (void *)capbuf, | ||
215 | }; | ||
211 | acpi_status status; | 216 | acpi_status status; |
212 | struct acpi_object_list input; | ||
213 | union acpi_object in_params[4]; | ||
214 | struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER, NULL}; | ||
215 | union acpi_object *out_obj; | ||
216 | u32 errors; | ||
217 | |||
218 | /* Setting up input parameters */ | ||
219 | input.count = 4; | ||
220 | input.pointer = in_params; | ||
221 | in_params[0].type = ACPI_TYPE_BUFFER; | ||
222 | in_params[0].buffer.length = 16; | ||
223 | in_params[0].buffer.pointer = OSC_UUID; | ||
224 | in_params[1].type = ACPI_TYPE_INTEGER; | ||
225 | in_params[1].integer.value = 1; | ||
226 | in_params[2].type = ACPI_TYPE_INTEGER; | ||
227 | in_params[2].integer.value = 3; | ||
228 | in_params[3].type = ACPI_TYPE_BUFFER; | ||
229 | in_params[3].buffer.length = 12; | ||
230 | in_params[3].buffer.pointer = (u8 *)capbuf; | ||
231 | |||
232 | status = acpi_evaluate_object(handle, "_OSC", &input, &output); | ||
233 | if (ACPI_FAILURE(status)) | ||
234 | return status; | ||
235 | 217 | ||
236 | if (!output.length) | 218 | status = acpi_run_osc(handle, &context); |
237 | return AE_NULL_OBJECT; | 219 | if (ACPI_SUCCESS(status)) { |
238 | 220 | *retval = *((u32 *)(context.ret.pointer + 8)); | |
239 | out_obj = output.pointer; | 221 | kfree(context.ret.pointer); |
240 | if (out_obj->type != ACPI_TYPE_BUFFER) { | ||
241 | printk(KERN_DEBUG "_OSC evaluation returned wrong type\n"); | ||
242 | status = AE_TYPE; | ||
243 | goto out_kfree; | ||
244 | } | ||
245 | /* Need to ignore the bit0 in result code */ | ||
246 | errors = *((u32 *)out_obj->buffer.pointer) & ~(1 << 0); | ||
247 | if (errors) { | ||
248 | if (errors & OSC_REQUEST_ERROR) | ||
249 | printk(KERN_DEBUG "_OSC request failed\n"); | ||
250 | if (errors & OSC_INVALID_UUID_ERROR) | ||
251 | printk(KERN_DEBUG "_OSC invalid UUID\n"); | ||
252 | if (errors & OSC_INVALID_REVISION_ERROR) | ||
253 | printk(KERN_DEBUG "_OSC invalid revision\n"); | ||
254 | if (errors & OSC_CAPABILITIES_MASK_ERROR) { | ||
255 | if (capbuf[OSC_QUERY_TYPE] & OSC_QUERY_ENABLE) | ||
256 | goto out_success; | ||
257 | printk(KERN_DEBUG | ||
258 | "Firmware did not grant requested _OSC control\n"); | ||
259 | status = AE_SUPPORT; | ||
260 | goto out_kfree; | ||
261 | } | ||
262 | status = AE_ERROR; | ||
263 | goto out_kfree; | ||
264 | } | 222 | } |
265 | out_success: | ||
266 | *retval = *((u32 *)(out_obj->buffer.pointer + 8)); | ||
267 | status = AE_OK; | ||
268 | |||
269 | out_kfree: | ||
270 | kfree(output.pointer); | ||
271 | return status; | 223 | return status; |
272 | } | 224 | } |
273 | 225 | ||
@@ -277,10 +229,10 @@ static acpi_status acpi_pci_query_osc(struct acpi_pci_root *root, u32 flags) | |||
277 | u32 support_set, result, capbuf[3]; | 229 | u32 support_set, result, capbuf[3]; |
278 | 230 | ||
279 | /* do _OSC query for all possible controls */ | 231 | /* do _OSC query for all possible controls */ |
280 | support_set = root->osc_support_set | (flags & OSC_SUPPORT_MASKS); | 232 | support_set = root->osc_support_set | (flags & OSC_PCI_SUPPORT_MASKS); |
281 | capbuf[OSC_QUERY_TYPE] = OSC_QUERY_ENABLE; | 233 | capbuf[OSC_QUERY_TYPE] = OSC_QUERY_ENABLE; |
282 | capbuf[OSC_SUPPORT_TYPE] = support_set; | 234 | capbuf[OSC_SUPPORT_TYPE] = support_set; |
283 | capbuf[OSC_CONTROL_TYPE] = OSC_CONTROL_MASKS; | 235 | capbuf[OSC_CONTROL_TYPE] = OSC_PCI_CONTROL_MASKS; |
284 | 236 | ||
285 | status = acpi_pci_run_osc(root->device->handle, capbuf, &result); | 237 | status = acpi_pci_run_osc(root->device->handle, capbuf, &result); |
286 | if (ACPI_SUCCESS(status)) { | 238 | if (ACPI_SUCCESS(status)) { |
@@ -427,7 +379,7 @@ acpi_status acpi_pci_osc_control_set(acpi_handle handle, u32 flags) | |||
427 | if (ACPI_FAILURE(status)) | 379 | if (ACPI_FAILURE(status)) |
428 | return status; | 380 | return status; |
429 | 381 | ||
430 | control_req = (flags & OSC_CONTROL_MASKS); | 382 | control_req = (flags & OSC_PCI_CONTROL_MASKS); |
431 | if (!control_req) | 383 | if (!control_req) |
432 | return AE_TYPE; | 384 | return AE_TYPE; |
433 | 385 | ||
diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 3247e09db20..535beecc37c 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h | |||
@@ -263,7 +263,6 @@ struct acpi_osc_context { | |||
263 | #define OSC_QUERY_TYPE 0 | 263 | #define OSC_QUERY_TYPE 0 |
264 | #define OSC_SUPPORT_TYPE 1 | 264 | #define OSC_SUPPORT_TYPE 1 |
265 | #define OSC_CONTROL_TYPE 2 | 265 | #define OSC_CONTROL_TYPE 2 |
266 | #define OSC_SUPPORT_MASKS 0x1f | ||
267 | 266 | ||
268 | /* _OSC DW0 Definition */ | 267 | /* _OSC DW0 Definition */ |
269 | #define OSC_QUERY_ENABLE 1 | 268 | #define OSC_QUERY_ENABLE 1 |
@@ -274,12 +273,14 @@ struct acpi_osc_context { | |||
274 | 273 | ||
275 | acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context); | 274 | acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context); |
276 | 275 | ||
276 | /* PCI defined _OSC bits */ | ||
277 | /* _OSC DW1 Definition (OS Support Fields) */ | 277 | /* _OSC DW1 Definition (OS Support Fields) */ |
278 | #define OSC_EXT_PCI_CONFIG_SUPPORT 1 | 278 | #define OSC_EXT_PCI_CONFIG_SUPPORT 1 |
279 | #define OSC_ACTIVE_STATE_PWR_SUPPORT 2 | 279 | #define OSC_ACTIVE_STATE_PWR_SUPPORT 2 |
280 | #define OSC_CLOCK_PWR_CAPABILITY_SUPPORT 4 | 280 | #define OSC_CLOCK_PWR_CAPABILITY_SUPPORT 4 |
281 | #define OSC_PCI_SEGMENT_GROUPS_SUPPORT 8 | 281 | #define OSC_PCI_SEGMENT_GROUPS_SUPPORT 8 |
282 | #define OSC_MSI_SUPPORT 16 | 282 | #define OSC_MSI_SUPPORT 16 |
283 | #define OSC_PCI_SUPPORT_MASKS 0x1f | ||
283 | 284 | ||
284 | /* _OSC DW1 Definition (OS Control Fields) */ | 285 | /* _OSC DW1 Definition (OS Control Fields) */ |
285 | #define OSC_PCI_EXPRESS_NATIVE_HP_CONTROL 1 | 286 | #define OSC_PCI_EXPRESS_NATIVE_HP_CONTROL 1 |
@@ -288,7 +289,7 @@ acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context); | |||
288 | #define OSC_PCI_EXPRESS_AER_CONTROL 8 | 289 | #define OSC_PCI_EXPRESS_AER_CONTROL 8 |
289 | #define OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL 16 | 290 | #define OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL 16 |
290 | 291 | ||
291 | #define OSC_CONTROL_MASKS (OSC_PCI_EXPRESS_NATIVE_HP_CONTROL | \ | 292 | #define OSC_PCI_CONTROL_MASKS (OSC_PCI_EXPRESS_NATIVE_HP_CONTROL | \ |
292 | OSC_SHPC_NATIVE_HP_CONTROL | \ | 293 | OSC_SHPC_NATIVE_HP_CONTROL | \ |
293 | OSC_PCI_EXPRESS_PME_CONTROL | \ | 294 | OSC_PCI_EXPRESS_PME_CONTROL | \ |
294 | OSC_PCI_EXPRESS_AER_CONTROL | \ | 295 | OSC_PCI_EXPRESS_AER_CONTROL | \ |