blob: ebce26c37049ad5ccc0483da56d3df682f865414 [file] [log] [blame]
Zhang, Yanmin6c2b3742006-07-31 15:21:33 +08001/*
2 * Access ACPI _OSC method
3 *
4 * Copyright (C) 2006 Intel Corp.
5 * Tom Long Nguyen (tom.l.nguyen@intel.com)
6 * Zhang Yanmin (yanmin.zhang@intel.com)
7 *
8 */
9
10#include <linux/module.h>
11#include <linux/pci.h>
12#include <linux/kernel.h>
13#include <linux/errno.h>
14#include <linux/pm.h>
15#include <linux/suspend.h>
16#include <linux/acpi.h>
17#include <linux/pci-acpi.h>
18#include <linux/delay.h>
19#include "aerdrv.h"
20
21/**
22 * aer_osc_setup - run ACPI _OSC method
Zhang, Yanmin8d29bfb2007-06-06 11:44:16 +080023 * @pciedev: pcie_device which AER is being enabled on
Zhang, Yanmin6c2b3742006-07-31 15:21:33 +080024 *
Zhang, Yanmin8d29bfb2007-06-06 11:44:16 +080025 * @return: Zero on success. Nonzero otherwise.
Zhang, Yanmin6c2b3742006-07-31 15:21:33 +080026 *
27 * Invoked when PCIE bus loads AER service driver. To avoid conflict with
28 * BIOS AER support requires BIOS to yield AER control to OS native driver.
29 **/
Zhang, Yanmin8d29bfb2007-06-06 11:44:16 +080030int aer_osc_setup(struct pcie_device *pciedev)
Zhang, Yanmin6c2b3742006-07-31 15:21:33 +080031{
Zhang, Yanmin8d29bfb2007-06-06 11:44:16 +080032 acpi_status status = AE_NOT_FOUND;
33 struct pci_dev *pdev = pciedev->port;
Harvey Harrisona01e0352008-04-28 16:50:04 -070034 acpi_handle handle = NULL;
Zhang, Yanmin6c2b3742006-07-31 15:21:33 +080035
Yinghai Lu4c44bac2008-02-02 22:24:47 -080036 if (acpi_pci_disabled)
37 return -1;
38
Jiri Slaby056c58e2008-08-18 20:22:54 +020039 handle = acpi_find_root_bridge_handle(pdev);
Zhang, Yanmin8d29bfb2007-06-06 11:44:16 +080040 if (handle) {
Zhang, Yanmin8d29bfb2007-06-06 11:44:16 +080041 status = pci_osc_control_set(handle,
42 OSC_PCI_EXPRESS_AER_CONTROL |
43 OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL);
Zhang, Yanmin6c2b3742006-07-31 15:21:33 +080044 }
45
Zhang, Yanmin8d29bfb2007-06-06 11:44:16 +080046 if (ACPI_FAILURE(status)) {
Bjorn Helgaas531f2542008-06-13 10:52:12 -060047 dev_printk(KERN_DEBUG, &pciedev->device, "AER service couldn't "
48 "init device: %s\n",
49 (status == AE_SUPPORT || status == AE_NOT_FOUND) ?
50 "no _OSC support" : "_OSC failed");
Zhang, Yanmin8d29bfb2007-06-06 11:44:16 +080051 return -1;
52 }
Zhang, Yanmin6c2b3742006-07-31 15:21:33 +080053
Zhang, Yanmin8d29bfb2007-06-06 11:44:16 +080054 return 0;
55}