Commit e81995bb authored by Bjorn Helgaas's avatar Bjorn Helgaas Committed by Jesse Barnes

PCI hotplug: acpiphp: use generic pci_configure_slot()

Use the generic pci_configure_slot() rather than the acpiphp-specific
decode_hpp() and program_hpp().

Unlike the previous acpiphp-specific code, pci_configure_slot() programs
PCIe settings when an _HPX method provides them, so acpiphp-managed PCIe
devices can now be configured.
Signed-off-by: default avatarBjorn Helgaas <bjorn.helgaas@hp.com>
Reviewed-by: default avatarKenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
Acked-by: default avatarKenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
Signed-off-by: default avatarJesse Barnes <jbarnes@virtuousgeek.org>
parent 11876e52
...@@ -322,13 +322,12 @@ static acpi_status acpi_run_oshp(acpi_handle handle) ...@@ -322,13 +322,12 @@ static acpi_status acpi_run_oshp(acpi_handle handle)
return status; return status;
} }
/* acpi_get_hp_params_from_firmware /* pci_get_hp_params
* *
* @dev - the pci_dev for which we want parameters * @dev - the pci_dev for which we want parameters
* @hpp - allocated by the caller * @hpp - allocated by the caller
*/ */
int acpi_get_hp_params_from_firmware(struct pci_dev *dev, int pci_get_hp_params(struct pci_dev *dev, struct hotplug_params *hpp)
struct hotplug_params *hpp)
{ {
acpi_status status; acpi_status status;
acpi_handle handle, phandle; acpi_handle handle, phandle;
...@@ -345,7 +344,7 @@ int acpi_get_hp_params_from_firmware(struct pci_dev *dev, ...@@ -345,7 +344,7 @@ int acpi_get_hp_params_from_firmware(struct pci_dev *dev,
* _HPP settings apply to all child buses, until another _HPP is * _HPP settings apply to all child buses, until another _HPP is
* encountered. If we don't find an _HPP for the input pci dev, * encountered. If we don't find an _HPP for the input pci dev,
* look for it in the parent device scope since that would apply to * look for it in the parent device scope since that would apply to
* this pci dev. If we don't find any _HPP, use hardcoded defaults * this pci dev.
*/ */
while (handle) { while (handle) {
status = acpi_run_hpx(handle, hpp); status = acpi_run_hpx(handle, hpp);
...@@ -363,7 +362,7 @@ int acpi_get_hp_params_from_firmware(struct pci_dev *dev, ...@@ -363,7 +362,7 @@ int acpi_get_hp_params_from_firmware(struct pci_dev *dev,
} }
return -ENODEV; return -ENODEV;
} }
EXPORT_SYMBOL_GPL(acpi_get_hp_params_from_firmware); EXPORT_SYMBOL_GPL(pci_get_hp_params);
/** /**
* acpi_get_hp_hw_control_from_firmware * acpi_get_hp_hw_control_from_firmware
......
...@@ -271,29 +271,6 @@ static int detect_ejectable_slots(acpi_handle handle) ...@@ -271,29 +271,6 @@ static int detect_ejectable_slots(acpi_handle handle)
return found; return found;
} }
/* decode ACPI 2.0 _HPP hot plug parameters */
static void decode_hpp(struct pci_dev *dev, struct hotplug_params *hpp)
{
int ret;
ret = acpi_get_hp_params_from_firmware(dev, hpp);
if (ret || !hpp->t0 || (hpp->t0->revision > 1)) {
/* use default numbers */
printk(KERN_WARNING
"%s: Could not get hotplug parameters. Use defaults\n",
__func__);
hpp->t0 = &hpp->type0_data;
hpp->t0->revision = 0;
hpp->t0->cache_line_size = 0x10;
hpp->t0->latency_timer = 0x40;
hpp->t0->enable_serr = 0;
hpp->t0->enable_perr = 0;
}
}
/* initialize miscellaneous stuff for both root and PCI-to-PCI bridge */ /* initialize miscellaneous stuff for both root and PCI-to-PCI bridge */
static void init_bridge_misc(struct acpiphp_bridge *bridge) static void init_bridge_misc(struct acpiphp_bridge *bridge)
{ {
...@@ -1247,66 +1224,12 @@ static int acpiphp_check_bridge(struct acpiphp_bridge *bridge) ...@@ -1247,66 +1224,12 @@ static int acpiphp_check_bridge(struct acpiphp_bridge *bridge)
return retval; return retval;
} }
static void program_hpp(struct pci_dev *dev, struct hotplug_params *hpp)
{
u16 pci_cmd, pci_bctl;
struct pci_dev *cdev;
/* Program hpp values for this device */
if (!(dev->hdr_type == PCI_HEADER_TYPE_NORMAL ||
(dev->hdr_type == PCI_HEADER_TYPE_BRIDGE &&
(dev->class >> 8) == PCI_CLASS_BRIDGE_PCI)))
return;
if ((dev->class >> 8) == PCI_CLASS_BRIDGE_HOST)
return;
pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE,
hpp->t0->cache_line_size);
pci_write_config_byte(dev, PCI_LATENCY_TIMER,
hpp->t0->latency_timer);
pci_read_config_word(dev, PCI_COMMAND, &pci_cmd);
if (hpp->t0->enable_serr)
pci_cmd |= PCI_COMMAND_SERR;
else
pci_cmd &= ~PCI_COMMAND_SERR;
if (hpp->t0->enable_perr)
pci_cmd |= PCI_COMMAND_PARITY;
else
pci_cmd &= ~PCI_COMMAND_PARITY;
pci_write_config_word(dev, PCI_COMMAND, pci_cmd);
/* Program bridge control value and child devices */
if ((dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) {
pci_write_config_byte(dev, PCI_SEC_LATENCY_TIMER,
hpp->t0->latency_timer);
pci_read_config_word(dev, PCI_BRIDGE_CONTROL, &pci_bctl);
if (hpp->t0->enable_serr)
pci_bctl |= PCI_BRIDGE_CTL_SERR;
else
pci_bctl &= ~PCI_BRIDGE_CTL_SERR;
if (hpp->t0->enable_perr)
pci_bctl |= PCI_BRIDGE_CTL_PARITY;
else
pci_bctl &= ~PCI_BRIDGE_CTL_PARITY;
pci_write_config_word(dev, PCI_BRIDGE_CONTROL, pci_bctl);
if (dev->subordinate) {
list_for_each_entry(cdev, &dev->subordinate->devices,
bus_list)
program_hpp(cdev, hpp);
}
}
}
static void acpiphp_set_hpp_values(struct pci_bus *bus) static void acpiphp_set_hpp_values(struct pci_bus *bus)
{ {
struct pci_dev *dev; struct pci_dev *dev;
struct hotplug_params hpp;
list_for_each_entry(dev, &bus->devices, bus_list) { list_for_each_entry(dev, &bus->devices, bus_list)
decode_hpp(dev, &hpp); pci_configure_slot(dev);
program_hpp(dev, &hpp);
}
} }
/* /*
......
...@@ -227,12 +227,10 @@ struct hotplug_params { ...@@ -227,12 +227,10 @@ struct hotplug_params {
#ifdef CONFIG_ACPI #ifdef CONFIG_ACPI
#include <acpi/acpi.h> #include <acpi/acpi.h>
#include <acpi/acpi_bus.h> #include <acpi/acpi_bus.h>
int acpi_get_hp_params_from_firmware(struct pci_dev *dev, int pci_get_hp_params(struct pci_dev *dev, struct hotplug_params *hpp);
struct hotplug_params *hpp);
int acpi_get_hp_hw_control_from_firmware(struct pci_dev *dev, u32 flags); int acpi_get_hp_hw_control_from_firmware(struct pci_dev *dev, u32 flags);
int acpi_pci_check_ejectable(struct pci_bus *pbus, acpi_handle handle); int acpi_pci_check_ejectable(struct pci_bus *pbus, acpi_handle handle);
int acpi_pci_detect_ejectable(acpi_handle handle); int acpi_pci_detect_ejectable(acpi_handle handle);
#define pci_get_hp_params(dev, hpp) acpi_get_hp_params_from_firmware(dev, hpp)
#else #else
static inline int pci_get_hp_params(struct pci_dev *dev, static inline int pci_get_hp_params(struct pci_dev *dev,
struct hotplug_params *hpp) struct hotplug_params *hpp)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment