/*1* pci_bind.c - ACPI PCI Device Binding ($Revision: 2 $)2*3* Copyright (C) 2001, 2002 Andy Grover <[email protected]>4* Copyright (C) 2001, 2002 Paul Diefenbaugh <[email protected]>5*6* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~7*8* This program is free software; you can redistribute it and/or modify9* it under the terms of the GNU General Public License as published by10* the Free Software Foundation; either version 2 of the License, or (at11* your option) any later version.12*13* This program is distributed in the hope that it will be useful, but14* WITHOUT ANY WARRANTY; without even the implied warranty of15* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU16* General Public License for more details.17*18* You should have received a copy of the GNU General Public License along19* with this program; if not, write to the Free Software Foundation, Inc.,20* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.21*22* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~23*/2425#include <linux/kernel.h>26#include <linux/types.h>27#include <linux/pci.h>28#include <linux/pci-acpi.h>29#include <linux/acpi.h>30#include <linux/pm_runtime.h>31#include <acpi/acpi_bus.h>32#include <acpi/acpi_drivers.h>3334#define _COMPONENT ACPI_PCI_COMPONENT35ACPI_MODULE_NAME("pci_bind");3637static int acpi_pci_unbind(struct acpi_device *device)38{39struct pci_dev *dev;4041dev = acpi_get_pci_dev(device->handle);42if (!dev)43goto out;4445device_set_run_wake(&dev->dev, false);46pci_acpi_remove_pm_notifier(device);4748if (!dev->subordinate)49goto out;5051acpi_pci_irq_del_prt(dev->subordinate);5253device->ops.bind = NULL;54device->ops.unbind = NULL;5556out:57pci_dev_put(dev);58return 0;59}6061static int acpi_pci_bind(struct acpi_device *device)62{63acpi_status status;64acpi_handle handle;65struct pci_bus *bus;66struct pci_dev *dev;6768dev = acpi_get_pci_dev(device->handle);69if (!dev)70return 0;7172pci_acpi_add_pm_notifier(device, dev);73if (device->wakeup.flags.run_wake)74device_set_run_wake(&dev->dev, true);7576/*77* Install the 'bind' function to facilitate callbacks for78* children of the P2P bridge.79*/80if (dev->subordinate) {81ACPI_DEBUG_PRINT((ACPI_DB_INFO,82"Device %04x:%02x:%02x.%d is a PCI bridge\n",83pci_domain_nr(dev->bus), dev->bus->number,84PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn)));85device->ops.bind = acpi_pci_bind;86device->ops.unbind = acpi_pci_unbind;87}8889/*90* Evaluate and parse _PRT, if exists. This code allows parsing of91* _PRT objects within the scope of non-bridge devices. Note that92* _PRTs within the scope of a PCI bridge assume the bridge's93* subordinate bus number.94*95* TBD: Can _PRTs exist within the scope of non-bridge PCI devices?96*/97status = acpi_get_handle(device->handle, METHOD_NAME__PRT, &handle);98if (ACPI_FAILURE(status))99goto out;100101if (dev->subordinate)102bus = dev->subordinate;103else104bus = dev->bus;105106acpi_pci_irq_add_prt(device->handle, bus);107108out:109pci_dev_put(dev);110return 0;111}112113int acpi_pci_bind_root(struct acpi_device *device)114{115device->ops.bind = acpi_pci_bind;116device->ops.unbind = acpi_pci_unbind;117118return 0;119}120121122