@@ -1402,6 +1402,46 @@ int pci_acpi_request_aux_power_for_d3cold(struct pci_dev *pdev, int arg)
}
EXPORT_SYMBOL_GPL(pci_acpi_request_aux_power_for_d3cold);
+/**
+ * pci_acpi_set_perst_delay - Set the assertion delay for the PERST# signal
+ * @pdev: PCI device to set the delay for
+ * @arg: Delay value in microseconds
+ *
+ * This function sets the delay for the PERST# signal of the given PCI device.
+ * The delay value is specified in microseconds through the @arg parameter.
+ * The maximum delay value is 10000 microseconds.
+ *
+ * Return: 0 on success, negative error code on failure
+ */
+int pci_acpi_set_perst_delay(struct pci_dev *pdev, int arg)
+{
+ struct acpi_device *adev = ACPI_COMPANION(&pdev->dev);
+ union acpi_object *obj;
+ union acpi_object argv4 = {
+ .integer.type = ACPI_TYPE_INTEGER,
+ .integer.value = arg,
+ };
+ int val;
+
+ if (!acpi_check_dsm(adev->handle, &pci_acpi_dsm_guid,
+ pci_acpi_dsm_rev, 1 << DSM_PCI_ADD_PERST_DELAY))
+ return -ENODEV;
+
+ if (arg > 10000)
+ return -EINVAL;
+
+ obj = acpi_evaluate_dsm_typed(adev->handle, &pci_acpi_dsm_guid,
+ pci_acpi_dsm_rev, DSM_PCI_ADD_PERST_DELAY,
+ &argv4, ACPI_TYPE_INTEGER);
+ if (!obj)
+ return -EIO;
+
+ val = obj->integer.value;
+ ACPI_FREE(obj);
+ return (val == arg) ? 0 : -EINVAL;
+}
+EXPORT_SYMBOL_GPL(pci_acpi_set_perst_delay);
+
/**
* pci_acpi_optimize_delay - optimize PCI D3 and D3cold delay from ACPI
* @pdev: the PCI device whose delay is to be updated
@@ -123,12 +123,14 @@ extern const int pci_acpi_dsm_rev;
#define DSM_PCI_POWER_ON_RESET_DELAY 0x08
#define DSM_PCI_DEVICE_READINESS_DURATIONS 0x09
#define DSM_PCI_REQUEST_D3COLD_AUX_POWER 0x0A
+#define DSM_PCI_ADD_PERST_DELAY 0x0B
#define PCI_D3COLD_AUX_DENIED 0
#define PCI_D3COLD_AUX_GRANTED 1
#define PCI_D3COLD_AUX_NO_MAIN_POWER_REMOVAL 2
int pci_acpi_request_aux_power_for_d3cold(struct pci_dev *pdev, int arg);
+int pci_acpi_set_perst_delay(struct pci_dev *pdev, int arg);
#ifdef CONFIG_PCIE_EDR
void pci_acpi_add_edr_notifier(struct pci_dev *pdev);
The PCI firmware specification includes support for a _DSM function to specify a PERST# assertion delay. "The Add PERST# Assertion Delay function is used to convey the requirement for a fixed delay in timing between the time the PME_TO_Ack message is received at the PCI Express Downstream Port that originated the PME_Turn_Off message, and the time the platform asserts PERST# to the slot during the corresponding Endpoint’s or PCI Express Upstream Port’s transition to D3cold while the system is in an ACPI operational state." Add API for callers to utilize this _DSM. Link: https://members.pcisig.com/wg/PCI-SIG/document/15350 PCI Firmware specification 3.3, section 4.6.11 Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> --- drivers/pci/pci-acpi.c | 40 ++++++++++++++++++++++++++++++++++++++++ include/linux/pci-acpi.h | 2 ++ 2 files changed, 42 insertions(+)