]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * pci_bind.c - ACPI PCI Device Binding ($Revision: 2 $) | |
3 | * | |
4 | * Copyright (C) 2001, 2002 Andy Grover <[email protected]> | |
5 | * Copyright (C) 2001, 2002 Paul Diefenbaugh <[email protected]> | |
6 | * | |
7 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
8 | * | |
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. | |
13 | * | |
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. | |
18 | * | |
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. | |
22 | * | |
23 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
24 | */ | |
25 | ||
26 | #include <linux/kernel.h> | |
1da177e4 | 27 | #include <linux/types.h> |
1da177e4 | 28 | #include <linux/pci.h> |
b67ea761 | 29 | #include <linux/pci-acpi.h> |
1da177e4 | 30 | #include <linux/acpi.h> |
b67ea761 | 31 | #include <linux/pm_runtime.h> |
1da177e4 LT |
32 | #include <acpi/acpi_bus.h> |
33 | #include <acpi/acpi_drivers.h> | |
34 | ||
1da177e4 | 35 | #define _COMPONENT ACPI_PCI_COMPONENT |
f52fd66d | 36 | ACPI_MODULE_NAME("pci_bind"); |
1da177e4 | 37 | |
c22d7f5a AC |
38 | static int acpi_pci_unbind(struct acpi_device *device) |
39 | { | |
499650de | 40 | struct pci_dev *dev; |
c22d7f5a | 41 | |
499650de | 42 | dev = acpi_get_pci_dev(device->handle); |
b67ea761 RW |
43 | if (!dev) |
44 | goto out; | |
45 | ||
46 | device_set_run_wake(&dev->dev, false); | |
47 | pci_acpi_remove_pm_notifier(device); | |
48 | ||
49 | if (!dev->subordinate) | |
97719a87 AC |
50 | goto out; |
51 | ||
52 | acpi_pci_irq_del_prt(dev->subordinate); | |
c22d7f5a | 53 | |
97719a87 AC |
54 | device->ops.bind = NULL; |
55 | device->ops.unbind = NULL; | |
c22d7f5a | 56 | |
97719a87 | 57 | out: |
499650de AC |
58 | pci_dev_put(dev); |
59 | return 0; | |
c22d7f5a AC |
60 | } |
61 | ||
ce597bb4 | 62 | static int acpi_pci_bind(struct acpi_device *device) |
1da177e4 | 63 | { |
087da3b4 | 64 | acpi_status status; |
087da3b4 | 65 | acpi_handle handle; |
859a3f86 | 66 | struct pci_bus *bus; |
499650de | 67 | struct pci_dev *dev; |
1da177e4 | 68 | |
499650de AC |
69 | dev = acpi_get_pci_dev(device->handle); |
70 | if (!dev) | |
71 | return 0; | |
1da177e4 | 72 | |
b67ea761 RW |
73 | pci_acpi_add_pm_notifier(device, dev); |
74 | if (device->wakeup.flags.run_wake) | |
75 | device_set_run_wake(&dev->dev, true); | |
76 | ||
1da177e4 | 77 | /* |
499650de AC |
78 | * Install the 'bind' function to facilitate callbacks for |
79 | * children of the P2P bridge. | |
1da177e4 | 80 | */ |
499650de | 81 | if (dev->subordinate) { |
4be44fcd | 82 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
21a53283 | 83 | "Device %04x:%02x:%02x.%d is a PCI bridge\n", |
499650de AC |
84 | pci_domain_nr(dev->bus), dev->bus->number, |
85 | PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn))); | |
1da177e4 LT |
86 | device->ops.bind = acpi_pci_bind; |
87 | device->ops.unbind = acpi_pci_unbind; | |
88 | } | |
89 | ||
90 | /* | |
499650de AC |
91 | * Evaluate and parse _PRT, if exists. This code allows parsing of |
92 | * _PRT objects within the scope of non-bridge devices. Note that | |
93 | * _PRTs within the scope of a PCI bridge assume the bridge's | |
94 | * subordinate bus number. | |
1da177e4 LT |
95 | * |
96 | * TBD: Can _PRTs exist within the scope of non-bridge PCI devices? | |
97 | */ | |
98 | status = acpi_get_handle(device->handle, METHOD_NAME__PRT, &handle); | |
499650de AC |
99 | if (ACPI_FAILURE(status)) |
100 | goto out; | |
1da177e4 | 101 | |
499650de | 102 | if (dev->subordinate) |
859a3f86 | 103 | bus = dev->subordinate; |
499650de | 104 | else |
859a3f86 | 105 | bus = dev->bus; |
1da177e4 | 106 | |
859a3f86 | 107 | acpi_pci_irq_add_prt(device->handle, bus); |
1da177e4 | 108 | |
499650de AC |
109 | out: |
110 | pci_dev_put(dev); | |
111 | return 0; | |
112 | } | |
1da177e4 | 113 | |
499650de AC |
114 | int acpi_pci_bind_root(struct acpi_device *device) |
115 | { | |
1da177e4 LT |
116 | device->ops.bind = acpi_pci_bind; |
117 | device->ops.unbind = acpi_pci_unbind; | |
118 | ||
499650de | 119 | return 0; |
1da177e4 | 120 | } |