aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/pci_root.c
diff options
context:
space:
mode:
authorShaohua Li <shaohua.li@intel.com>2009-10-28 23:04:50 -0400
committerLen Brown <len.brown@intel.com>2009-12-16 14:05:11 -0500
commit3a9622dc4659af44a8098a233f65c51e495ff0a5 (patch)
tree8e0dd5d1f31ad6a9047b0ba5faf26a3759d9e2fd /drivers/acpi/pci_root.c
parent70023de88c58a81a730ab4d13c51a30e537ec76e (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>
Diffstat (limited to 'drivers/acpi/pci_root.c')
-rw-r--r--drivers/acpi/pci_root.c76
1 files changed, 14 insertions, 62 deletions
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index 1af808171d46..101cce3681d1 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
205static u8 OSC_UUID[16] = {0x5B, 0x4D, 0xDB, 0x33, 0xF7, 0x1F, 0x1C, 0x40, 205static u8 pci_osc_uuid_str[] = "33DB4D5B-1FF7-401C-9657-7441C03DD766";
206 0x96, 0x57, 0x74, 0x41, 0xC0, 0x3D, 0xD7, 0x66};
207 206
208static acpi_status acpi_pci_run_osc(acpi_handle handle, 207static 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 }
265out_success:
266 *retval = *((u32 *)(out_obj->buffer.pointer + 8));
267 status = AE_OK;
268
269out_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