OMAP3: PM: decouple PER and CORE context save and restore
[linux-ginger.git] / drivers / acpi / pci_bind.c
bloba5a77b78a7237cbbb6e77a707f73a0861426718d
1 /*
2 * pci_bind.c - ACPI PCI Device Binding ($Revision: 2 $)
4 * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
5 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
7 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or (at
12 * your option) any later version.
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
23 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
26 #include <linux/kernel.h>
27 #include <linux/types.h>
28 #include <linux/pci.h>
29 #include <linux/acpi.h>
30 #include <acpi/acpi_bus.h>
31 #include <acpi/acpi_drivers.h>
33 #define _COMPONENT ACPI_PCI_COMPONENT
34 ACPI_MODULE_NAME("pci_bind");
36 static int acpi_pci_unbind(struct acpi_device *device)
38 struct pci_dev *dev;
40 dev = acpi_get_pci_dev(device->handle);
41 if (!dev || !dev->subordinate)
42 goto out;
44 acpi_pci_irq_del_prt(dev->subordinate);
46 device->ops.bind = NULL;
47 device->ops.unbind = NULL;
49 out:
50 pci_dev_put(dev);
51 return 0;
54 static int acpi_pci_bind(struct acpi_device *device)
56 acpi_status status;
57 acpi_handle handle;
58 struct pci_bus *bus;
59 struct pci_dev *dev;
61 dev = acpi_get_pci_dev(device->handle);
62 if (!dev)
63 return 0;
66 * Install the 'bind' function to facilitate callbacks for
67 * children of the P2P bridge.
69 if (dev->subordinate) {
70 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
71 "Device %04x:%02x:%02x.%d is a PCI bridge\n",
72 pci_domain_nr(dev->bus), dev->bus->number,
73 PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn)));
74 device->ops.bind = acpi_pci_bind;
75 device->ops.unbind = acpi_pci_unbind;
79 * Evaluate and parse _PRT, if exists. This code allows parsing of
80 * _PRT objects within the scope of non-bridge devices. Note that
81 * _PRTs within the scope of a PCI bridge assume the bridge's
82 * subordinate bus number.
84 * TBD: Can _PRTs exist within the scope of non-bridge PCI devices?
86 status = acpi_get_handle(device->handle, METHOD_NAME__PRT, &handle);
87 if (ACPI_FAILURE(status))
88 goto out;
90 if (dev->subordinate)
91 bus = dev->subordinate;
92 else
93 bus = dev->bus;
95 acpi_pci_irq_add_prt(device->handle, bus);
97 out:
98 pci_dev_put(dev);
99 return 0;
102 int acpi_pci_bind_root(struct acpi_device *device)
104 device->ops.bind = acpi_pci_bind;
105 device->ops.unbind = acpi_pci_unbind;
107 return 0;