aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMika Westerberg <mika.westerberg@linux.intel.com>2018-05-31 12:42:11 -0400
committerBjorn Helgaas <bhelgaas@google.com>2018-06-04 13:08:06 -0400
commit90cc0c3cc7092ea4c7871fdd5fb00a9ba62842e3 (patch)
tree8593d15501ff0b65aadbe7840e9ce3d600469508
parentbed4e9cfab93a0f3d0144cb919820e6d5c40b8b1 (diff)
PCI: shpchp: Add shpchp_is_native()
In the same way we do for pciehp, add shpchp_is_native(), which returns true if the bridge should be handled by the native SHPC driver. Then convert the driver to use this function. Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
-rw-r--r--drivers/pci/hotplug/acpi_pcihp.c4
-rw-r--r--drivers/pci/hotplug/shpchp.h1
-rw-r--r--drivers/pci/hotplug/shpchp_core.c14
-rw-r--r--drivers/pci/pci-acpi.c29
-rw-r--r--include/linux/pci_hotplug.h2
-rw-r--r--include/linux/pci_ids.h1
6 files changed, 35 insertions, 16 deletions
diff --git a/drivers/pci/hotplug/acpi_pcihp.c b/drivers/pci/hotplug/acpi_pcihp.c
index 597d22aeefc1..3979f89b250a 100644
--- a/drivers/pci/hotplug/acpi_pcihp.c
+++ b/drivers/pci/hotplug/acpi_pcihp.c
@@ -83,11 +83,11 @@ int acpi_get_hp_hw_control_from_firmware(struct pci_dev *pdev)
83 * OSHP within the scope of the hotplug controller and its parents, 83 * OSHP within the scope of the hotplug controller and its parents,
84 * up to the host bridge under which this controller exists. 84 * up to the host bridge under which this controller exists.
85 */ 85 */
86 host = pci_find_host_bridge(pdev->bus); 86 if (shpchp_is_native(pdev))
87 if (host->native_shpc_hotplug)
88 return 0; 87 return 0;
89 88
90 /* If _OSC exists, we should not evaluate OSHP */ 89 /* If _OSC exists, we should not evaluate OSHP */
90 host = pci_find_host_bridge(pdev->bus);
91 root = acpi_pci_find_root(ACPI_HANDLE(&host->dev)); 91 root = acpi_pci_find_root(ACPI_HANDLE(&host->dev));
92 if (root->osc_support_set) 92 if (root->osc_support_set)
93 goto no_control; 93 goto no_control;
diff --git a/drivers/pci/hotplug/shpchp.h b/drivers/pci/hotplug/shpchp.h
index 9675ab757323..516e4835019c 100644
--- a/drivers/pci/hotplug/shpchp.h
+++ b/drivers/pci/hotplug/shpchp.h
@@ -105,7 +105,6 @@ struct controller {
105}; 105};
106 106
107/* Define AMD SHPC ID */ 107/* Define AMD SHPC ID */
108#define PCI_DEVICE_ID_AMD_GOLAM_7450 0x7450
109#define PCI_DEVICE_ID_AMD_POGO_7458 0x7458 108#define PCI_DEVICE_ID_AMD_POGO_7458 0x7458
110 109
111/* AMD PCI-X bridge registers */ 110/* AMD PCI-X bridge registers */
diff --git a/drivers/pci/hotplug/shpchp_core.c b/drivers/pci/hotplug/shpchp_core.c
index 47decc9b3bb3..e91be287f292 100644
--- a/drivers/pci/hotplug/shpchp_core.c
+++ b/drivers/pci/hotplug/shpchp_core.c
@@ -270,24 +270,12 @@ static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value)
270 return 0; 270 return 0;
271} 271}
272 272
273static int is_shpc_capable(struct pci_dev *dev)
274{
275 if (dev->vendor == PCI_VENDOR_ID_AMD &&
276 dev->device == PCI_DEVICE_ID_AMD_GOLAM_7450)
277 return 1;
278 if (!pci_find_capability(dev, PCI_CAP_ID_SHPC))
279 return 0;
280 if (acpi_get_hp_hw_control_from_firmware(dev))
281 return 0;
282 return 1;
283}
284
285static int shpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 273static int shpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
286{ 274{
287 int rc; 275 int rc;
288 struct controller *ctrl; 276 struct controller *ctrl;
289 277
290 if (!is_shpc_capable(pdev)) 278 if (acpi_get_hp_hw_control_from_firmware(pdev))
291 return -ENODEV; 279 return -ENODEV;
292 280
293 ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL); 281 ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL);
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index 52b8434d4d6e..65113b6eed14 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -395,6 +395,35 @@ bool pciehp_is_native(struct pci_dev *bridge)
395} 395}
396 396
397/** 397/**
398 * shpchp_is_native - Check whether a hotplug port is handled by the OS
399 * @bridge: Hotplug port to check
400 *
401 * Returns true if the given @bridge is handled by the native SHPC hotplug
402 * driver.
403 */
404bool shpchp_is_native(struct pci_dev *bridge)
405{
406 const struct pci_host_bridge *host;
407
408 if (!IS_ENABLED(CONFIG_HOTPLUG_PCI_SHPC))
409 return false;
410
411 /*
412 * It is assumed that AMD GOLAM chips support SHPC but they do not
413 * have SHPC capability.
414 */
415 if (bridge->vendor == PCI_VENDOR_ID_AMD &&
416 bridge->device == PCI_DEVICE_ID_AMD_GOLAM_7450)
417 return true;
418
419 if (!pci_find_capability(bridge, PCI_CAP_ID_SHPC))
420 return false;
421
422 host = pci_find_host_bridge(bridge->bus);
423 return host->native_shpc_hotplug;
424}
425
426/**
398 * pci_acpi_wake_bus - Root bus wakeup notification fork function. 427 * pci_acpi_wake_bus - Root bus wakeup notification fork function.
399 * @context: Device wakeup context. 428 * @context: Device wakeup context.
400 */ 429 */
diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
index 1f5c935eb0de..4c378368215c 100644
--- a/include/linux/pci_hotplug.h
+++ b/include/linux/pci_hotplug.h
@@ -164,6 +164,7 @@ struct hotplug_params {
164int pci_get_hp_params(struct pci_dev *dev, struct hotplug_params *hpp); 164int pci_get_hp_params(struct pci_dev *dev, struct hotplug_params *hpp);
165bool pciehp_is_native(struct pci_dev *bridge); 165bool pciehp_is_native(struct pci_dev *bridge);
166int acpi_get_hp_hw_control_from_firmware(struct pci_dev *bridge); 166int acpi_get_hp_hw_control_from_firmware(struct pci_dev *bridge);
167bool shpchp_is_native(struct pci_dev *bridge);
167int acpi_pci_check_ejectable(struct pci_bus *pbus, acpi_handle handle); 168int acpi_pci_check_ejectable(struct pci_bus *pbus, acpi_handle handle);
168int acpi_pci_detect_ejectable(acpi_handle handle); 169int acpi_pci_detect_ejectable(acpi_handle handle);
169#else 170#else
@@ -178,5 +179,6 @@ static inline int acpi_get_hp_hw_control_from_firmware(struct pci_dev *bridge)
178 return 0; 179 return 0;
179} 180}
180static inline bool pciehp_is_native(struct pci_dev *bridge) { return true; } 181static inline bool pciehp_is_native(struct pci_dev *bridge) { return true; }
182static inline bool shpchp_is_native(struct pci_dev *bridge) { return true; }
181#endif 183#endif
182#endif 184#endif
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index 883cb7bf78aa..5aace6cca0d7 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -561,6 +561,7 @@
561#define PCI_DEVICE_ID_AMD_OPUS_7443 0x7443 561#define PCI_DEVICE_ID_AMD_OPUS_7443 0x7443
562#define PCI_DEVICE_ID_AMD_VIPER_7443 0x7443 562#define PCI_DEVICE_ID_AMD_VIPER_7443 0x7443
563#define PCI_DEVICE_ID_AMD_OPUS_7445 0x7445 563#define PCI_DEVICE_ID_AMD_OPUS_7445 0x7445
564#define PCI_DEVICE_ID_AMD_GOLAM_7450 0x7450
564#define PCI_DEVICE_ID_AMD_8111_PCI 0x7460 565#define PCI_DEVICE_ID_AMD_8111_PCI 0x7460
565#define PCI_DEVICE_ID_AMD_8111_LPC 0x7468 566#define PCI_DEVICE_ID_AMD_8111_LPC 0x7468
566#define PCI_DEVICE_ID_AMD_8111_IDE 0x7469 567#define PCI_DEVICE_ID_AMD_8111_IDE 0x7469