@@ -137,6 +137,31 @@ int of_pci_get_max_link_speed(struct device_node *node)
}
EXPORT_SYMBOL_GPL(of_pci_get_max_link_speed);
+/**
+ * This function returns true if the PCIe controller should assert PCIe Reset
+ * (PERST#) when entering system suspend (e.g., S3).
+ *
+ * @node: device tree node with the reset property
+ *
+ * Returns 1 (meaning "assert reset") or 0 ("don't assert reset"), if the DT
+ * defined a valid behavior. Otherwise, returns a negative error code.
+ */
+int of_pci_get_pcie_reset_suspend(struct device_node *node)
+{
+ int ret;
+ u32 val;
+
+ ret = of_property_read_u32(node, "pcie-reset-suspend", &val);
+ if (ret)
+ return ret;
+
+ if (val > 1)
+ return -EINVAL;
+
+ return val;
+}
+EXPORT_SYMBOL_GPL(of_pci_get_pcie_reset_suspend);
+
/**
* of_pci_check_probe_only - Setup probe only mode if linux,pci-probe-only
* is present and valid
@@ -17,6 +17,7 @@ int of_irq_parse_and_map_pci(const struct pci_dev *dev, u8 slot, u8 pin);
int of_pci_parse_bus_range(struct device_node *node, struct resource *res);
int of_get_pci_domain_nr(struct device_node *node);
int of_pci_get_max_link_speed(struct device_node *node);
+int of_pci_get_pcie_reset_suspend(struct device_node *node);
void of_pci_check_probe_only(void);
int of_pci_map_rid(struct device_node *np, u32 rid,
const char *map_name, const char *map_mask_name,
@@ -69,6 +70,12 @@ of_pci_get_max_link_speed(struct device_node *node)
return -EINVAL;
}
+static inline int
+of_pci_get_pcie_reset_suspend(struct device_node *node)
+{
+ return -EINVAL;
+}
+
static inline void of_pci_check_probe_only(void) { }
#endif
This helper can be used by drivers to determine the expected PERST# behavior when in low-power system suspend (e.g., S3). I've found the expected behavior to vary across a few different endpoint implementations. Signed-off-by: Brian Norris <briannorris@chromium.org> --- drivers/of/of_pci.c | 25 +++++++++++++++++++++++++ include/linux/of_pci.h | 7 +++++++ 2 files changed, 32 insertions(+)