mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-05 18:39:59 +00:00
Merge branch 'pci/enumeration'
- Add and use pci_get_base_class() to search for all PCI_BASE_CLASS_DISPLAY devices (Sui Jingfeng) - Fix a vmd check for multi-function devices (Ilpo Järvinen) - Add PCI_HEADER_TYPE_MFD and use it to replace literals (Ilpo Järvinen) - Use acpi_evaluate_dsm_typed() instead of open-coding it (Andy Shevchenko) - Keep .remove() and .probe() callbacks (previously marked __init) in case they're used via sysfs (Uwe Kleine-König) * pci/enumeration: PCI: keystone: Don't discard .probe() callback PCI: keystone: Don't discard .remove() callback PCI: kirin: Don't discard .remove() callback PCI: exynos: Don't discard .remove() callback PCI/ACPI: Use acpi_evaluate_dsm_typed() PCI: Use PCI_HEADER_TYPE_* instead of literals PCI: Add PCI_HEADER_TYPE_MFD definition PCI: vmd: Correct PCI Header Type Register's multi-function check drm/radeon: Use pci_get_base_class() to reduce duplicated code drm/amdgpu: Use pci_get_base_class() to reduce duplicated code drm/nouveau: Use pci_get_base_class() to reduce duplicated code ALSA: hda: Use pci_get_base_class() to reduce duplicated code PCI: Add pci_get_base_class() helper
This commit is contained in:
commit
553b84bf46
24 changed files with 104 additions and 98 deletions
|
@ -1389,14 +1389,11 @@ void amdgpu_acpi_detect(void)
|
||||||
struct pci_dev *pdev = NULL;
|
struct pci_dev *pdev = NULL;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, pdev)) != NULL) {
|
while ((pdev = pci_get_base_class(PCI_BASE_CLASS_DISPLAY, pdev))) {
|
||||||
if (!atif->handle)
|
if ((pdev->class != PCI_CLASS_DISPLAY_VGA << 8) &&
|
||||||
amdgpu_atif_pci_probe_handle(pdev);
|
(pdev->class != PCI_CLASS_DISPLAY_OTHER << 8))
|
||||||
if (!atcs->handle)
|
continue;
|
||||||
amdgpu_atcs_pci_probe_handle(pdev);
|
|
||||||
}
|
|
||||||
|
|
||||||
while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_OTHER << 8, pdev)) != NULL) {
|
|
||||||
if (!atif->handle)
|
if (!atif->handle)
|
||||||
amdgpu_atif_pci_probe_handle(pdev);
|
amdgpu_atif_pci_probe_handle(pdev);
|
||||||
if (!atcs->handle)
|
if (!atcs->handle)
|
||||||
|
|
|
@ -287,7 +287,11 @@ static bool amdgpu_atrm_get_bios(struct amdgpu_device *adev)
|
||||||
if (adev->flags & AMD_IS_APU)
|
if (adev->flags & AMD_IS_APU)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, pdev)) != NULL) {
|
while ((pdev = pci_get_base_class(PCI_BASE_CLASS_DISPLAY, pdev))) {
|
||||||
|
if ((pdev->class != PCI_CLASS_DISPLAY_VGA << 8) &&
|
||||||
|
(pdev->class != PCI_CLASS_DISPLAY_OTHER << 8))
|
||||||
|
continue;
|
||||||
|
|
||||||
dhandle = ACPI_HANDLE(&pdev->dev);
|
dhandle = ACPI_HANDLE(&pdev->dev);
|
||||||
if (!dhandle)
|
if (!dhandle)
|
||||||
continue;
|
continue;
|
||||||
|
@ -299,20 +303,6 @@ static bool amdgpu_atrm_get_bios(struct amdgpu_device *adev)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found) {
|
|
||||||
while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_OTHER << 8, pdev)) != NULL) {
|
|
||||||
dhandle = ACPI_HANDLE(&pdev->dev);
|
|
||||||
if (!dhandle)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
status = acpi_get_handle(dhandle, "ATRM", &atrm_handle);
|
|
||||||
if (ACPI_SUCCESS(status)) {
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!found)
|
if (!found)
|
||||||
return false;
|
return false;
|
||||||
pci_dev_put(pdev);
|
pci_dev_put(pdev);
|
||||||
|
|
|
@ -284,14 +284,11 @@ static bool nouveau_dsm_detect(void)
|
||||||
printk("MXM: GUID detected in BIOS\n");
|
printk("MXM: GUID detected in BIOS\n");
|
||||||
|
|
||||||
/* now do DSM detection */
|
/* now do DSM detection */
|
||||||
while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, pdev)) != NULL) {
|
while ((pdev = pci_get_base_class(PCI_BASE_CLASS_DISPLAY, pdev))) {
|
||||||
vga_count++;
|
if ((pdev->class != PCI_CLASS_DISPLAY_VGA << 8) &&
|
||||||
|
(pdev->class != PCI_CLASS_DISPLAY_3D << 8))
|
||||||
|
continue;
|
||||||
|
|
||||||
nouveau_dsm_pci_probe(pdev, &dhandle, &has_mux, &has_optimus,
|
|
||||||
&has_optimus_flags, &has_power_resources);
|
|
||||||
}
|
|
||||||
|
|
||||||
while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_3D << 8, pdev)) != NULL) {
|
|
||||||
vga_count++;
|
vga_count++;
|
||||||
|
|
||||||
nouveau_dsm_pci_probe(pdev, &dhandle, &has_mux, &has_optimus,
|
nouveau_dsm_pci_probe(pdev, &dhandle, &has_mux, &has_optimus,
|
||||||
|
|
|
@ -199,7 +199,11 @@ static bool radeon_atrm_get_bios(struct radeon_device *rdev)
|
||||||
if (rdev->flags & RADEON_IS_IGP)
|
if (rdev->flags & RADEON_IS_IGP)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, pdev)) != NULL) {
|
while ((pdev = pci_get_base_class(PCI_BASE_CLASS_DISPLAY, pdev))) {
|
||||||
|
if ((pdev->class != PCI_CLASS_DISPLAY_VGA << 8) &&
|
||||||
|
(pdev->class != PCI_CLASS_DISPLAY_OTHER << 8))
|
||||||
|
continue;
|
||||||
|
|
||||||
dhandle = ACPI_HANDLE(&pdev->dev);
|
dhandle = ACPI_HANDLE(&pdev->dev);
|
||||||
if (!dhandle)
|
if (!dhandle)
|
||||||
continue;
|
continue;
|
||||||
|
@ -211,20 +215,6 @@ static bool radeon_atrm_get_bios(struct radeon_device *rdev)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found) {
|
|
||||||
while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_OTHER << 8, pdev)) != NULL) {
|
|
||||||
dhandle = ACPI_HANDLE(&pdev->dev);
|
|
||||||
if (!dhandle)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
status = acpi_get_handle(dhandle, "ATRM", &atrm_handle);
|
|
||||||
if (ACPI_SUCCESS(status)) {
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!found)
|
if (!found)
|
||||||
return false;
|
return false;
|
||||||
pci_dev_put(pdev);
|
pci_dev_put(pdev);
|
||||||
|
|
|
@ -375,7 +375,7 @@ static int exynos_pcie_probe(struct platform_device *pdev)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __exit exynos_pcie_remove(struct platform_device *pdev)
|
static int exynos_pcie_remove(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct exynos_pcie *ep = platform_get_drvdata(pdev);
|
struct exynos_pcie *ep = platform_get_drvdata(pdev);
|
||||||
|
|
||||||
|
@ -431,7 +431,7 @@ static const struct of_device_id exynos_pcie_of_match[] = {
|
||||||
|
|
||||||
static struct platform_driver exynos_pcie_driver = {
|
static struct platform_driver exynos_pcie_driver = {
|
||||||
.probe = exynos_pcie_probe,
|
.probe = exynos_pcie_probe,
|
||||||
.remove = __exit_p(exynos_pcie_remove),
|
.remove = exynos_pcie_remove,
|
||||||
.driver = {
|
.driver = {
|
||||||
.name = "exynos-pcie",
|
.name = "exynos-pcie",
|
||||||
.of_match_table = exynos_pcie_of_match,
|
.of_match_table = exynos_pcie_of_match,
|
||||||
|
|
|
@ -1100,7 +1100,7 @@ static const struct of_device_id ks_pcie_of_match[] = {
|
||||||
{ },
|
{ },
|
||||||
};
|
};
|
||||||
|
|
||||||
static int __init ks_pcie_probe(struct platform_device *pdev)
|
static int ks_pcie_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
const struct dw_pcie_host_ops *host_ops;
|
const struct dw_pcie_host_ops *host_ops;
|
||||||
const struct dw_pcie_ep_ops *ep_ops;
|
const struct dw_pcie_ep_ops *ep_ops;
|
||||||
|
@ -1302,7 +1302,7 @@ static int __init ks_pcie_probe(struct platform_device *pdev)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __exit ks_pcie_remove(struct platform_device *pdev)
|
static int ks_pcie_remove(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct keystone_pcie *ks_pcie = platform_get_drvdata(pdev);
|
struct keystone_pcie *ks_pcie = platform_get_drvdata(pdev);
|
||||||
struct device_link **link = ks_pcie->link;
|
struct device_link **link = ks_pcie->link;
|
||||||
|
@ -1318,9 +1318,9 @@ static int __exit ks_pcie_remove(struct platform_device *pdev)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct platform_driver ks_pcie_driver __refdata = {
|
static struct platform_driver ks_pcie_driver = {
|
||||||
.probe = ks_pcie_probe,
|
.probe = ks_pcie_probe,
|
||||||
.remove = __exit_p(ks_pcie_remove),
|
.remove = ks_pcie_remove,
|
||||||
.driver = {
|
.driver = {
|
||||||
.name = "keystone-pcie",
|
.name = "keystone-pcie",
|
||||||
.of_match_table = ks_pcie_of_match,
|
.of_match_table = ks_pcie_of_match,
|
||||||
|
|
|
@ -58,7 +58,7 @@ static bool ls_pcie_is_bridge(struct ls_pcie *pcie)
|
||||||
u32 header_type;
|
u32 header_type;
|
||||||
|
|
||||||
header_type = ioread8(pci->dbi_base + PCI_HEADER_TYPE);
|
header_type = ioread8(pci->dbi_base + PCI_HEADER_TYPE);
|
||||||
header_type &= 0x7f;
|
header_type &= PCI_HEADER_TYPE_MASK;
|
||||||
|
|
||||||
return header_type == PCI_HEADER_TYPE_BRIDGE;
|
return header_type == PCI_HEADER_TYPE_BRIDGE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -741,7 +741,7 @@ static int kirin_pcie_power_on(struct platform_device *pdev,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __exit kirin_pcie_remove(struct platform_device *pdev)
|
static int kirin_pcie_remove(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct kirin_pcie *kirin_pcie = platform_get_drvdata(pdev);
|
struct kirin_pcie *kirin_pcie = platform_get_drvdata(pdev);
|
||||||
|
|
||||||
|
@ -818,7 +818,7 @@ static int kirin_pcie_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
static struct platform_driver kirin_pcie_driver = {
|
static struct platform_driver kirin_pcie_driver = {
|
||||||
.probe = kirin_pcie_probe,
|
.probe = kirin_pcie_probe,
|
||||||
.remove = __exit_p(kirin_pcie_remove),
|
.remove = kirin_pcie_remove,
|
||||||
.driver = {
|
.driver = {
|
||||||
.name = "kirin-pcie",
|
.name = "kirin-pcie",
|
||||||
.of_match_table = kirin_pcie_match,
|
.of_match_table = kirin_pcie_match,
|
||||||
|
|
|
@ -539,7 +539,7 @@ static bool mobiveil_pcie_is_bridge(struct mobiveil_pcie *pcie)
|
||||||
u32 header_type;
|
u32 header_type;
|
||||||
|
|
||||||
header_type = mobiveil_csr_readb(pcie, PCI_HEADER_TYPE);
|
header_type = mobiveil_csr_readb(pcie, PCI_HEADER_TYPE);
|
||||||
header_type &= 0x7f;
|
header_type &= PCI_HEADER_TYPE_MASK;
|
||||||
|
|
||||||
return header_type == PCI_HEADER_TYPE_BRIDGE;
|
return header_type == PCI_HEADER_TYPE_BRIDGE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -783,7 +783,7 @@ static int iproc_pcie_check_link(struct iproc_pcie *pcie)
|
||||||
|
|
||||||
/* make sure we are not in EP mode */
|
/* make sure we are not in EP mode */
|
||||||
iproc_pci_raw_config_read32(pcie, 0, PCI_HEADER_TYPE, 1, &hdr_type);
|
iproc_pci_raw_config_read32(pcie, 0, PCI_HEADER_TYPE, 1, &hdr_type);
|
||||||
if ((hdr_type & 0x7f) != PCI_HEADER_TYPE_BRIDGE) {
|
if ((hdr_type & PCI_HEADER_TYPE_MASK) != PCI_HEADER_TYPE_BRIDGE) {
|
||||||
dev_err(dev, "in EP mode, hdr=%#02x\n", hdr_type);
|
dev_err(dev, "in EP mode, hdr=%#02x\n", hdr_type);
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ static void rcar_pcie_ep_hw_init(struct rcar_pcie *pcie)
|
||||||
rcar_rmw32(pcie, REXPCAP(0), 0xff, PCI_CAP_ID_EXP);
|
rcar_rmw32(pcie, REXPCAP(0), 0xff, PCI_CAP_ID_EXP);
|
||||||
rcar_rmw32(pcie, REXPCAP(PCI_EXP_FLAGS),
|
rcar_rmw32(pcie, REXPCAP(PCI_EXP_FLAGS),
|
||||||
PCI_EXP_FLAGS_TYPE, PCI_EXP_TYPE_ENDPOINT << 4);
|
PCI_EXP_FLAGS_TYPE, PCI_EXP_TYPE_ENDPOINT << 4);
|
||||||
rcar_rmw32(pcie, RCONF(PCI_HEADER_TYPE), 0x7f,
|
rcar_rmw32(pcie, RCONF(PCI_HEADER_TYPE), PCI_HEADER_TYPE_MASK,
|
||||||
PCI_HEADER_TYPE_NORMAL);
|
PCI_HEADER_TYPE_NORMAL);
|
||||||
|
|
||||||
/* Write out the physical slot number = 0 */
|
/* Write out the physical slot number = 0 */
|
||||||
|
|
|
@ -460,7 +460,7 @@ static int rcar_pcie_hw_init(struct rcar_pcie *pcie)
|
||||||
rcar_rmw32(pcie, REXPCAP(0), 0xff, PCI_CAP_ID_EXP);
|
rcar_rmw32(pcie, REXPCAP(0), 0xff, PCI_CAP_ID_EXP);
|
||||||
rcar_rmw32(pcie, REXPCAP(PCI_EXP_FLAGS),
|
rcar_rmw32(pcie, REXPCAP(PCI_EXP_FLAGS),
|
||||||
PCI_EXP_FLAGS_TYPE, PCI_EXP_TYPE_ROOT_PORT << 4);
|
PCI_EXP_FLAGS_TYPE, PCI_EXP_TYPE_ROOT_PORT << 4);
|
||||||
rcar_rmw32(pcie, RCONF(PCI_HEADER_TYPE), 0x7f,
|
rcar_rmw32(pcie, RCONF(PCI_HEADER_TYPE), PCI_HEADER_TYPE_MASK,
|
||||||
PCI_HEADER_TYPE_BRIDGE);
|
PCI_HEADER_TYPE_BRIDGE);
|
||||||
|
|
||||||
/* Enable data link layer active state reporting */
|
/* Enable data link layer active state reporting */
|
||||||
|
|
|
@ -525,10 +525,9 @@ static void vmd_domain_reset(struct vmd_dev *vmd)
|
||||||
base = vmd->cfgbar + PCIE_ECAM_OFFSET(bus,
|
base = vmd->cfgbar + PCIE_ECAM_OFFSET(bus,
|
||||||
PCI_DEVFN(dev, 0), 0);
|
PCI_DEVFN(dev, 0), 0);
|
||||||
|
|
||||||
hdr_type = readb(base + PCI_HEADER_TYPE) &
|
hdr_type = readb(base + PCI_HEADER_TYPE);
|
||||||
PCI_HEADER_TYPE_MASK;
|
|
||||||
|
|
||||||
functions = (hdr_type & 0x80) ? 8 : 1;
|
functions = (hdr_type & PCI_HEADER_TYPE_MFD) ? 8 : 1;
|
||||||
for (fn = 0; fn < functions; fn++) {
|
for (fn = 0; fn < functions; fn++) {
|
||||||
base = vmd->cfgbar + PCIE_ECAM_OFFSET(bus,
|
base = vmd->cfgbar + PCIE_ECAM_OFFSET(bus,
|
||||||
PCI_DEVFN(dev, fn), 0);
|
PCI_DEVFN(dev, fn), 0);
|
||||||
|
|
|
@ -2059,7 +2059,7 @@ int cpqhp_process_SS(struct controller *ctrl, struct pci_func *func)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
/* If it's a bridge, check the VGA Enable bit */
|
/* If it's a bridge, check the VGA Enable bit */
|
||||||
if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) {
|
if ((header_type & PCI_HEADER_TYPE_MASK) == PCI_HEADER_TYPE_BRIDGE) {
|
||||||
rc = pci_bus_read_config_byte(pci_bus, devfn, PCI_BRIDGE_CONTROL, &BCR);
|
rc = pci_bus_read_config_byte(pci_bus, devfn, PCI_BRIDGE_CONTROL, &BCR);
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -2342,7 +2342,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
if ((temp_byte & 0x7F) == PCI_HEADER_TYPE_BRIDGE) {
|
if ((temp_byte & PCI_HEADER_TYPE_MASK) == PCI_HEADER_TYPE_BRIDGE) {
|
||||||
/* set Primary bus */
|
/* set Primary bus */
|
||||||
dbg("set Primary bus = %d\n", func->bus);
|
dbg("set Primary bus = %d\n", func->bus);
|
||||||
rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_PRIMARY_BUS, func->bus);
|
rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_PRIMARY_BUS, func->bus);
|
||||||
|
@ -2739,7 +2739,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
|
||||||
* PCI_BRIDGE_CTL_SERR |
|
* PCI_BRIDGE_CTL_SERR |
|
||||||
* PCI_BRIDGE_CTL_NO_ISA */
|
* PCI_BRIDGE_CTL_NO_ISA */
|
||||||
rc = pci_bus_write_config_word(pci_bus, devfn, PCI_BRIDGE_CONTROL, command);
|
rc = pci_bus_write_config_word(pci_bus, devfn, PCI_BRIDGE_CONTROL, command);
|
||||||
} else if ((temp_byte & 0x7F) == PCI_HEADER_TYPE_NORMAL) {
|
} else if ((temp_byte & PCI_HEADER_TYPE_MASK) == PCI_HEADER_TYPE_NORMAL) {
|
||||||
/* Standard device */
|
/* Standard device */
|
||||||
rc = pci_bus_read_config_byte(pci_bus, devfn, 0x0B, &class_code);
|
rc = pci_bus_read_config_byte(pci_bus, devfn, 0x0B, &class_code);
|
||||||
|
|
||||||
|
|
|
@ -363,7 +363,7 @@ int cpqhp_save_config(struct controller *ctrl, int busnumber, int is_hot_plug)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
/* If multi-function device, set max_functions to 8 */
|
/* If multi-function device, set max_functions to 8 */
|
||||||
if (header_type & 0x80)
|
if (header_type & PCI_HEADER_TYPE_MFD)
|
||||||
max_functions = 8;
|
max_functions = 8;
|
||||||
else
|
else
|
||||||
max_functions = 1;
|
max_functions = 1;
|
||||||
|
@ -372,7 +372,7 @@ int cpqhp_save_config(struct controller *ctrl, int busnumber, int is_hot_plug)
|
||||||
|
|
||||||
do {
|
do {
|
||||||
DevError = 0;
|
DevError = 0;
|
||||||
if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) {
|
if ((header_type & PCI_HEADER_TYPE_MASK) == PCI_HEADER_TYPE_BRIDGE) {
|
||||||
/* Recurse the subordinate bus
|
/* Recurse the subordinate bus
|
||||||
* get the subordinate bus number
|
* get the subordinate bus number
|
||||||
*/
|
*/
|
||||||
|
@ -487,13 +487,13 @@ int cpqhp_save_slot_config(struct controller *ctrl, struct pci_func *new_slot)
|
||||||
pci_bus_read_config_byte(ctrl->pci_bus, PCI_DEVFN(new_slot->device, 0), 0x0B, &class_code);
|
pci_bus_read_config_byte(ctrl->pci_bus, PCI_DEVFN(new_slot->device, 0), 0x0B, &class_code);
|
||||||
pci_bus_read_config_byte(ctrl->pci_bus, PCI_DEVFN(new_slot->device, 0), PCI_HEADER_TYPE, &header_type);
|
pci_bus_read_config_byte(ctrl->pci_bus, PCI_DEVFN(new_slot->device, 0), PCI_HEADER_TYPE, &header_type);
|
||||||
|
|
||||||
if (header_type & 0x80) /* Multi-function device */
|
if (header_type & PCI_HEADER_TYPE_MFD)
|
||||||
max_functions = 8;
|
max_functions = 8;
|
||||||
else
|
else
|
||||||
max_functions = 1;
|
max_functions = 1;
|
||||||
|
|
||||||
while (function < max_functions) {
|
while (function < max_functions) {
|
||||||
if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) {
|
if ((header_type & PCI_HEADER_TYPE_MASK) == PCI_HEADER_TYPE_BRIDGE) {
|
||||||
/* Recurse the subordinate bus */
|
/* Recurse the subordinate bus */
|
||||||
pci_bus_read_config_byte(ctrl->pci_bus, PCI_DEVFN(new_slot->device, function), PCI_SECONDARY_BUS, &secondary_bus);
|
pci_bus_read_config_byte(ctrl->pci_bus, PCI_DEVFN(new_slot->device, function), PCI_SECONDARY_BUS, &secondary_bus);
|
||||||
|
|
||||||
|
@ -571,7 +571,7 @@ int cpqhp_save_base_addr_length(struct controller *ctrl, struct pci_func *func)
|
||||||
/* Check for Bridge */
|
/* Check for Bridge */
|
||||||
pci_bus_read_config_byte(pci_bus, devfn, PCI_HEADER_TYPE, &header_type);
|
pci_bus_read_config_byte(pci_bus, devfn, PCI_HEADER_TYPE, &header_type);
|
||||||
|
|
||||||
if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) {
|
if ((header_type & PCI_HEADER_TYPE_MASK) == PCI_HEADER_TYPE_BRIDGE) {
|
||||||
pci_bus_read_config_byte(pci_bus, devfn, PCI_SECONDARY_BUS, &secondary_bus);
|
pci_bus_read_config_byte(pci_bus, devfn, PCI_SECONDARY_BUS, &secondary_bus);
|
||||||
|
|
||||||
sub_bus = (int) secondary_bus;
|
sub_bus = (int) secondary_bus;
|
||||||
|
@ -625,7 +625,7 @@ int cpqhp_save_base_addr_length(struct controller *ctrl, struct pci_func *func)
|
||||||
|
|
||||||
} /* End of base register loop */
|
} /* End of base register loop */
|
||||||
|
|
||||||
} else if ((header_type & 0x7F) == 0x00) {
|
} else if ((header_type & PCI_HEADER_TYPE_MASK) == PCI_HEADER_TYPE_NORMAL) {
|
||||||
/* Figure out IO and memory base lengths */
|
/* Figure out IO and memory base lengths */
|
||||||
for (cloop = 0x10; cloop <= 0x24; cloop += 4) {
|
for (cloop = 0x10; cloop <= 0x24; cloop += 4) {
|
||||||
temp_register = 0xFFFFFFFF;
|
temp_register = 0xFFFFFFFF;
|
||||||
|
@ -723,7 +723,7 @@ int cpqhp_save_used_resources(struct controller *ctrl, struct pci_func *func)
|
||||||
/* Check for Bridge */
|
/* Check for Bridge */
|
||||||
pci_bus_read_config_byte(pci_bus, devfn, PCI_HEADER_TYPE, &header_type);
|
pci_bus_read_config_byte(pci_bus, devfn, PCI_HEADER_TYPE, &header_type);
|
||||||
|
|
||||||
if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) {
|
if ((header_type & PCI_HEADER_TYPE_MASK) == PCI_HEADER_TYPE_BRIDGE) {
|
||||||
/* Clear Bridge Control Register */
|
/* Clear Bridge Control Register */
|
||||||
command = 0x00;
|
command = 0x00;
|
||||||
pci_bus_write_config_word(pci_bus, devfn, PCI_BRIDGE_CONTROL, command);
|
pci_bus_write_config_word(pci_bus, devfn, PCI_BRIDGE_CONTROL, command);
|
||||||
|
@ -858,7 +858,7 @@ int cpqhp_save_used_resources(struct controller *ctrl, struct pci_func *func)
|
||||||
}
|
}
|
||||||
} /* End of base register loop */
|
} /* End of base register loop */
|
||||||
/* Standard header */
|
/* Standard header */
|
||||||
} else if ((header_type & 0x7F) == 0x00) {
|
} else if ((header_type & PCI_HEADER_TYPE_MASK) == PCI_HEADER_TYPE_NORMAL) {
|
||||||
/* Figure out IO and memory base lengths */
|
/* Figure out IO and memory base lengths */
|
||||||
for (cloop = 0x10; cloop <= 0x24; cloop += 4) {
|
for (cloop = 0x10; cloop <= 0x24; cloop += 4) {
|
||||||
pci_bus_read_config_dword(pci_bus, devfn, cloop, &save_base);
|
pci_bus_read_config_dword(pci_bus, devfn, cloop, &save_base);
|
||||||
|
@ -975,7 +975,7 @@ int cpqhp_configure_board(struct controller *ctrl, struct pci_func *func)
|
||||||
pci_bus_read_config_byte(pci_bus, devfn, PCI_HEADER_TYPE, &header_type);
|
pci_bus_read_config_byte(pci_bus, devfn, PCI_HEADER_TYPE, &header_type);
|
||||||
|
|
||||||
/* If this is a bridge device, restore subordinate devices */
|
/* If this is a bridge device, restore subordinate devices */
|
||||||
if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) {
|
if ((header_type & PCI_HEADER_TYPE_MASK) == PCI_HEADER_TYPE_BRIDGE) {
|
||||||
pci_bus_read_config_byte(pci_bus, devfn, PCI_SECONDARY_BUS, &secondary_bus);
|
pci_bus_read_config_byte(pci_bus, devfn, PCI_SECONDARY_BUS, &secondary_bus);
|
||||||
|
|
||||||
sub_bus = (int) secondary_bus;
|
sub_bus = (int) secondary_bus;
|
||||||
|
@ -1067,7 +1067,7 @@ int cpqhp_valid_replace(struct controller *ctrl, struct pci_func *func)
|
||||||
/* Check for Bridge */
|
/* Check for Bridge */
|
||||||
pci_bus_read_config_byte(pci_bus, devfn, PCI_HEADER_TYPE, &header_type);
|
pci_bus_read_config_byte(pci_bus, devfn, PCI_HEADER_TYPE, &header_type);
|
||||||
|
|
||||||
if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) {
|
if ((header_type & PCI_HEADER_TYPE_MASK) == PCI_HEADER_TYPE_BRIDGE) {
|
||||||
/* In order to continue checking, we must program the
|
/* In order to continue checking, we must program the
|
||||||
* bus registers in the bridge to respond to accesses
|
* bus registers in the bridge to respond to accesses
|
||||||
* for its subordinate bus(es)
|
* for its subordinate bus(es)
|
||||||
|
@ -1090,7 +1090,7 @@ int cpqhp_valid_replace(struct controller *ctrl, struct pci_func *func)
|
||||||
|
|
||||||
}
|
}
|
||||||
/* Check to see if it is a standard config header */
|
/* Check to see if it is a standard config header */
|
||||||
else if ((header_type & 0x7F) == PCI_HEADER_TYPE_NORMAL) {
|
else if ((header_type & PCI_HEADER_TYPE_MASK) == PCI_HEADER_TYPE_NORMAL) {
|
||||||
/* Check subsystem vendor and ID */
|
/* Check subsystem vendor and ID */
|
||||||
pci_bus_read_config_dword(pci_bus, devfn, PCI_SUBSYSTEM_VENDOR_ID, &temp_register);
|
pci_bus_read_config_dword(pci_bus, devfn, PCI_SUBSYSTEM_VENDOR_ID, &temp_register);
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <linux/pci_hotplug.h>
|
#include <linux/pci_hotplug.h>
|
||||||
|
#include <linux/pci_regs.h>
|
||||||
|
|
||||||
extern int ibmphp_debug;
|
extern int ibmphp_debug;
|
||||||
|
|
||||||
|
@ -286,8 +287,8 @@ int ibmphp_register_pci(void);
|
||||||
|
|
||||||
/* pci specific defines */
|
/* pci specific defines */
|
||||||
#define PCI_VENDOR_ID_NOTVALID 0xFFFF
|
#define PCI_VENDOR_ID_NOTVALID 0xFFFF
|
||||||
#define PCI_HEADER_TYPE_MULTIDEVICE 0x80
|
#define PCI_HEADER_TYPE_MULTIDEVICE (PCI_HEADER_TYPE_MFD|PCI_HEADER_TYPE_NORMAL)
|
||||||
#define PCI_HEADER_TYPE_MULTIBRIDGE 0x81
|
#define PCI_HEADER_TYPE_MULTIBRIDGE (PCI_HEADER_TYPE_MFD|PCI_HEADER_TYPE_BRIDGE)
|
||||||
|
|
||||||
#define LATENCY 0x64
|
#define LATENCY 0x64
|
||||||
#define CACHE 64
|
#define CACHE 64
|
||||||
|
|
|
@ -1087,7 +1087,7 @@ static struct res_needed *scan_behind_bridge(struct pci_func *func, u8 busno)
|
||||||
pci_bus_read_config_dword(ibmphp_pci_bus, devfn, PCI_CLASS_REVISION, &class);
|
pci_bus_read_config_dword(ibmphp_pci_bus, devfn, PCI_CLASS_REVISION, &class);
|
||||||
|
|
||||||
debug("hdr_type behind the bridge is %x\n", hdr_type);
|
debug("hdr_type behind the bridge is %x\n", hdr_type);
|
||||||
if ((hdr_type & 0x7f) == PCI_HEADER_TYPE_BRIDGE) {
|
if ((hdr_type & PCI_HEADER_TYPE_MASK) == PCI_HEADER_TYPE_BRIDGE) {
|
||||||
err("embedded bridges not supported for hot-plugging.\n");
|
err("embedded bridges not supported for hot-plugging.\n");
|
||||||
amount->not_correct = 1;
|
amount->not_correct = 1;
|
||||||
return amount;
|
return amount;
|
||||||
|
|
|
@ -1215,12 +1215,12 @@ void acpi_pci_add_bus(struct pci_bus *bus)
|
||||||
if (!pci_is_root_bus(bus))
|
if (!pci_is_root_bus(bus))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
obj = acpi_evaluate_dsm(ACPI_HANDLE(bus->bridge), &pci_acpi_dsm_guid, 3,
|
obj = acpi_evaluate_dsm_typed(ACPI_HANDLE(bus->bridge), &pci_acpi_dsm_guid, 3,
|
||||||
DSM_PCI_POWER_ON_RESET_DELAY, NULL);
|
DSM_PCI_POWER_ON_RESET_DELAY, NULL, ACPI_TYPE_INTEGER);
|
||||||
if (!obj)
|
if (!obj)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (obj->type == ACPI_TYPE_INTEGER && obj->integer.value == 1) {
|
if (obj->integer.value == 1) {
|
||||||
bridge = pci_find_host_bridge(bus);
|
bridge = pci_find_host_bridge(bus);
|
||||||
bridge->ignore_reset_delay = 1;
|
bridge->ignore_reset_delay = 1;
|
||||||
}
|
}
|
||||||
|
@ -1376,12 +1376,13 @@ static void pci_acpi_optimize_delay(struct pci_dev *pdev,
|
||||||
if (bridge->ignore_reset_delay)
|
if (bridge->ignore_reset_delay)
|
||||||
pdev->d3cold_delay = 0;
|
pdev->d3cold_delay = 0;
|
||||||
|
|
||||||
obj = acpi_evaluate_dsm(handle, &pci_acpi_dsm_guid, 3,
|
obj = acpi_evaluate_dsm_typed(handle, &pci_acpi_dsm_guid, 3,
|
||||||
DSM_PCI_DEVICE_READINESS_DURATIONS, NULL);
|
DSM_PCI_DEVICE_READINESS_DURATIONS, NULL,
|
||||||
|
ACPI_TYPE_PACKAGE);
|
||||||
if (!obj)
|
if (!obj)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (obj->type == ACPI_TYPE_PACKAGE && obj->package.count == 5) {
|
if (obj->package.count == 5) {
|
||||||
elements = obj->package.elements;
|
elements = obj->package.elements;
|
||||||
if (elements[0].type == ACPI_TYPE_INTEGER) {
|
if (elements[0].type == ACPI_TYPE_INTEGER) {
|
||||||
value = (int)elements[0].integer.value / 1000;
|
value = (int)elements[0].integer.value / 1000;
|
||||||
|
|
|
@ -534,7 +534,7 @@ u8 pci_bus_find_capability(struct pci_bus *bus, unsigned int devfn, int cap)
|
||||||
|
|
||||||
pci_bus_read_config_byte(bus, devfn, PCI_HEADER_TYPE, &hdr_type);
|
pci_bus_read_config_byte(bus, devfn, PCI_HEADER_TYPE, &hdr_type);
|
||||||
|
|
||||||
pos = __pci_bus_find_cap_start(bus, devfn, hdr_type & 0x7f);
|
pos = __pci_bus_find_cap_start(bus, devfn, hdr_type & PCI_HEADER_TYPE_MASK);
|
||||||
if (pos)
|
if (pos)
|
||||||
pos = __pci_find_next_cap(bus, devfn, pos, cap);
|
pos = __pci_find_next_cap(bus, devfn, pos, cap);
|
||||||
|
|
||||||
|
|
|
@ -1844,8 +1844,8 @@ static void quirk_jmicron_ata(struct pci_dev *pdev)
|
||||||
|
|
||||||
/* Update pdev accordingly */
|
/* Update pdev accordingly */
|
||||||
pci_read_config_byte(pdev, PCI_HEADER_TYPE, &hdr);
|
pci_read_config_byte(pdev, PCI_HEADER_TYPE, &hdr);
|
||||||
pdev->hdr_type = hdr & 0x7f;
|
pdev->hdr_type = hdr & PCI_HEADER_TYPE_MASK;
|
||||||
pdev->multifunction = !!(hdr & 0x80);
|
pdev->multifunction = FIELD_GET(PCI_HEADER_TYPE_MFD, hdr);
|
||||||
|
|
||||||
pci_read_config_dword(pdev, PCI_CLASS_REVISION, &class);
|
pci_read_config_dword(pdev, PCI_CLASS_REVISION, &class);
|
||||||
pdev->class = class >> 8;
|
pdev->class = class >> 8;
|
||||||
|
@ -5687,7 +5687,7 @@ static void quirk_nvidia_hda(struct pci_dev *gpu)
|
||||||
|
|
||||||
/* The GPU becomes a multi-function device when the HDA is enabled */
|
/* The GPU becomes a multi-function device when the HDA is enabled */
|
||||||
pci_read_config_byte(gpu, PCI_HEADER_TYPE, &hdr_type);
|
pci_read_config_byte(gpu, PCI_HEADER_TYPE, &hdr_type);
|
||||||
gpu->multifunction = !!(hdr_type & 0x80);
|
gpu->multifunction = FIELD_GET(PCI_HEADER_TYPE_MFD, hdr_type);
|
||||||
}
|
}
|
||||||
DECLARE_PCI_FIXUP_CLASS_HEADER(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID,
|
DECLARE_PCI_FIXUP_CLASS_HEADER(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID,
|
||||||
PCI_BASE_CLASS_DISPLAY, 16, quirk_nvidia_hda);
|
PCI_BASE_CLASS_DISPLAY, 16, quirk_nvidia_hda);
|
||||||
|
|
|
@ -363,6 +363,37 @@ struct pci_dev *pci_get_class(unsigned int class, struct pci_dev *from)
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(pci_get_class);
|
EXPORT_SYMBOL(pci_get_class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* pci_get_base_class - searching for a PCI device by matching against the base class code only
|
||||||
|
* @class: search for a PCI device with this base class code
|
||||||
|
* @from: Previous PCI device found in search, or %NULL for new search.
|
||||||
|
*
|
||||||
|
* Iterates through the list of known PCI devices. If a PCI device is found
|
||||||
|
* with a matching base class code, the reference count to the device is
|
||||||
|
* incremented. See pci_match_one_device() to figure out how does this works.
|
||||||
|
* A new search is initiated by passing %NULL as the @from argument.
|
||||||
|
* Otherwise if @from is not %NULL, searches continue from next device on the
|
||||||
|
* global list. The reference count for @from is always decremented if it is
|
||||||
|
* not %NULL.
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
* A pointer to a matched PCI device, %NULL Otherwise.
|
||||||
|
*/
|
||||||
|
struct pci_dev *pci_get_base_class(unsigned int class, struct pci_dev *from)
|
||||||
|
{
|
||||||
|
struct pci_device_id id = {
|
||||||
|
.vendor = PCI_ANY_ID,
|
||||||
|
.device = PCI_ANY_ID,
|
||||||
|
.subvendor = PCI_ANY_ID,
|
||||||
|
.subdevice = PCI_ANY_ID,
|
||||||
|
.class_mask = 0xFF0000,
|
||||||
|
.class = class << 16,
|
||||||
|
};
|
||||||
|
|
||||||
|
return pci_get_dev_by_id(&id, from);
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(pci_get_base_class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pci_dev_present - Returns 1 if device matching the device list is present, 0 if not.
|
* pci_dev_present - Returns 1 if device matching the device list is present, 0 if not.
|
||||||
* @ids: A pointer to a null terminated list of struct pci_device_id structures
|
* @ids: A pointer to a null terminated list of struct pci_device_id structures
|
||||||
|
|
|
@ -1181,6 +1181,8 @@ struct pci_dev *pci_get_slot(struct pci_bus *bus, unsigned int devfn);
|
||||||
struct pci_dev *pci_get_domain_bus_and_slot(int domain, unsigned int bus,
|
struct pci_dev *pci_get_domain_bus_and_slot(int domain, unsigned int bus,
|
||||||
unsigned int devfn);
|
unsigned int devfn);
|
||||||
struct pci_dev *pci_get_class(unsigned int class, struct pci_dev *from);
|
struct pci_dev *pci_get_class(unsigned int class, struct pci_dev *from);
|
||||||
|
struct pci_dev *pci_get_base_class(unsigned int class, struct pci_dev *from);
|
||||||
|
|
||||||
int pci_dev_present(const struct pci_device_id *ids);
|
int pci_dev_present(const struct pci_device_id *ids);
|
||||||
|
|
||||||
int pci_bus_read_config_byte(struct pci_bus *bus, unsigned int devfn,
|
int pci_bus_read_config_byte(struct pci_bus *bus, unsigned int devfn,
|
||||||
|
@ -1924,6 +1926,9 @@ static inline struct pci_dev *pci_get_class(unsigned int class,
|
||||||
struct pci_dev *from)
|
struct pci_dev *from)
|
||||||
{ return NULL; }
|
{ return NULL; }
|
||||||
|
|
||||||
|
static inline struct pci_dev *pci_get_base_class(unsigned int class,
|
||||||
|
struct pci_dev *from)
|
||||||
|
{ return NULL; }
|
||||||
|
|
||||||
static inline int pci_dev_present(const struct pci_device_id *ids)
|
static inline int pci_dev_present(const struct pci_device_id *ids)
|
||||||
{ return 0; }
|
{ return 0; }
|
||||||
|
|
|
@ -80,6 +80,7 @@
|
||||||
#define PCI_HEADER_TYPE_NORMAL 0
|
#define PCI_HEADER_TYPE_NORMAL 0
|
||||||
#define PCI_HEADER_TYPE_BRIDGE 1
|
#define PCI_HEADER_TYPE_BRIDGE 1
|
||||||
#define PCI_HEADER_TYPE_CARDBUS 2
|
#define PCI_HEADER_TYPE_CARDBUS 2
|
||||||
|
#define PCI_HEADER_TYPE_MFD 0x80 /* Multi-Function Device (possible) */
|
||||||
|
|
||||||
#define PCI_BIST 0x0f /* 8 bits */
|
#define PCI_BIST 0x0f /* 8 bits */
|
||||||
#define PCI_BIST_CODE_MASK 0x0f /* Return result */
|
#define PCI_BIST_CODE_MASK 0x0f /* Return result */
|
||||||
|
|
|
@ -1417,17 +1417,11 @@ static bool atpx_present(void)
|
||||||
acpi_handle dhandle, atpx_handle;
|
acpi_handle dhandle, atpx_handle;
|
||||||
acpi_status status;
|
acpi_status status;
|
||||||
|
|
||||||
while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, pdev)) != NULL) {
|
while ((pdev = pci_get_base_class(PCI_BASE_CLASS_DISPLAY, pdev))) {
|
||||||
dhandle = ACPI_HANDLE(&pdev->dev);
|
if ((pdev->class != PCI_CLASS_DISPLAY_VGA << 8) &&
|
||||||
if (dhandle) {
|
(pdev->class != PCI_CLASS_DISPLAY_OTHER << 8))
|
||||||
status = acpi_get_handle(dhandle, "ATPX", &atpx_handle);
|
continue;
|
||||||
if (ACPI_SUCCESS(status)) {
|
|
||||||
pci_dev_put(pdev);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_OTHER << 8, pdev)) != NULL) {
|
|
||||||
dhandle = ACPI_HANDLE(&pdev->dev);
|
dhandle = ACPI_HANDLE(&pdev->dev);
|
||||||
if (dhandle) {
|
if (dhandle) {
|
||||||
status = acpi_get_handle(dhandle, "ATPX", &atpx_handle);
|
status = acpi_get_handle(dhandle, "ATPX", &atpx_handle);
|
||||||
|
|
Loading…
Reference in a new issue