Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * pci_bind.c - ACPI PCI Device Binding ($Revision: 2 $) | |
3 | * | |
4 | * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com> | |
5 | * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> | |
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 LT |
28 | #include <linux/pci.h> |
29 | #include <linux/acpi.h> | |
30 | #include <acpi/acpi_bus.h> | |
31 | #include <acpi/acpi_drivers.h> | |
32 | ||
1da177e4 | 33 | #define _COMPONENT ACPI_PCI_COMPONENT |
f52fd66d | 34 | ACPI_MODULE_NAME("pci_bind"); |
1da177e4 | 35 | |
c22d7f5a AC |
36 | static int acpi_pci_unbind(struct acpi_device *device) |
37 | { | |
499650de | 38 | struct pci_dev *dev; |
c22d7f5a | 39 | |
499650de | 40 | dev = acpi_get_pci_dev(device->handle); |
97719a87 AC |
41 | if (!dev || !dev->subordinate) |
42 | goto out; | |
43 | ||
44 | acpi_pci_irq_del_prt(dev->subordinate); | |
c22d7f5a | 45 | |
97719a87 AC |
46 | device->ops.bind = NULL; |
47 | device->ops.unbind = NULL; | |
c22d7f5a | 48 | |
97719a87 | 49 | out: |
499650de AC |
50 | pci_dev_put(dev); |
51 | return 0; | |
c22d7f5a AC |
52 | } |
53 | ||
ce597bb4 | 54 | static int acpi_pci_bind(struct acpi_device *device) |
1da177e4 | 55 | { |
087da3b4 | 56 | acpi_status status; |
087da3b4 | 57 | acpi_handle handle; |
859a3f86 | 58 | struct pci_bus *bus; |
499650de | 59 | struct pci_dev *dev; |
1da177e4 | 60 | |
499650de AC |
61 | dev = acpi_get_pci_dev(device->handle); |
62 | if (!dev) | |
63 | return 0; | |
1da177e4 LT |
64 | |
65 | /* | |
499650de AC |
66 | * Install the 'bind' function to facilitate callbacks for |
67 | * children of the P2P bridge. | |
1da177e4 | 68 | */ |
499650de | 69 | if (dev->subordinate) { |
4be44fcd | 70 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
21a53283 | 71 | "Device %04x:%02x:%02x.%d is a PCI bridge\n", |
499650de AC |
72 | pci_domain_nr(dev->bus), dev->bus->number, |
73 | PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn))); | |
1da177e4 LT |
74 | device->ops.bind = acpi_pci_bind; |
75 | device->ops.unbind = acpi_pci_unbind; | |
76 | } | |
77 | ||
78 | /* | |
499650de AC |
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. | |
1da177e4 LT |
83 | * |
84 | * TBD: Can _PRTs exist within the scope of non-bridge PCI devices? | |
85 | */ | |
86 | status = acpi_get_handle(device->handle, METHOD_NAME__PRT, &handle); | |
499650de AC |
87 | if (ACPI_FAILURE(status)) |
88 | goto out; | |
1da177e4 | 89 | |
499650de | 90 | if (dev->subordinate) |
859a3f86 | 91 | bus = dev->subordinate; |
499650de | 92 | else |
859a3f86 | 93 | bus = dev->bus; |
1da177e4 | 94 | |
859a3f86 | 95 | acpi_pci_irq_add_prt(device->handle, bus); |
1da177e4 | 96 | |
499650de AC |
97 | out: |
98 | pci_dev_put(dev); | |
99 | return 0; | |
100 | } | |
1da177e4 | 101 | |
499650de AC |
102 | int acpi_pci_bind_root(struct acpi_device *device) |
103 | { | |
1da177e4 LT |
104 | device->ops.bind = acpi_pci_bind; |
105 | device->ops.unbind = acpi_pci_unbind; | |
106 | ||
499650de | 107 | return 0; |
1da177e4 | 108 | } |