pci: tegra: introduce weak tegra_pcie_board_port_reset() function
authorMarcel Ziswiler <marcel.ziswiler@toradex.com>
Tue, 8 May 2018 15:34:09 +0000 (17:34 +0200)
committerTom Warren <twarren@nvidia.com>
Thu, 10 May 2018 23:34:21 +0000 (16:34 -0700)
Introduce a weak tegra_pcie_board_port_reset() function by default
calling the existing tegra_pcie_port_reset() function. Additionally add
a tegra_pcie_port_index_of_port() function to retrieve the specific PCIe
port index if required. This allows overriding the PCIe port reset
functionality from board specific code as e.g. required for Apalis T30
and Apalis TK1.

Signed-off-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Acked-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Tom Warren <twarren@nvidia.com>
drivers/pci/pci_tegra.c
include/pci_tegra.h [new file with mode: 0644]

index b325914b151ea828a703a867d387ba6efa9123af..56c08585e6da54ae841af86b743f1e127cb80bd0 100644 (file)
@@ -17,6 +17,7 @@
 #include <errno.h>
 #include <malloc.h>
 #include <pci.h>
+#include <pci_tegra.h>
 #include <power-domain.h>
 #include <reset.h>
 
@@ -888,7 +889,7 @@ static unsigned long tegra_pcie_port_get_pex_ctrl(struct tegra_pcie_port *port)
        return ret;
 }
 
-static void tegra_pcie_port_reset(struct tegra_pcie_port *port)
+void tegra_pcie_port_reset(struct tegra_pcie_port *port)
 {
        unsigned long ctrl = tegra_pcie_port_get_pex_ctrl(port);
        unsigned long value;
@@ -905,6 +906,16 @@ static void tegra_pcie_port_reset(struct tegra_pcie_port *port)
        afi_writel(port->pcie, value, ctrl);
 }
 
+int tegra_pcie_port_index_of_port(struct tegra_pcie_port *port)
+{
+       return port->index;
+}
+
+void __weak tegra_pcie_board_port_reset(struct tegra_pcie_port *port)
+{
+       tegra_pcie_port_reset(port);
+}
+
 static void tegra_pcie_port_enable(struct tegra_pcie_port *port)
 {
        struct tegra_pcie *pcie = port->pcie;
@@ -923,7 +934,7 @@ static void tegra_pcie_port_enable(struct tegra_pcie_port *port)
 
        afi_writel(pcie, value, ctrl);
 
-       tegra_pcie_port_reset(port);
+       tegra_pcie_board_port_reset(port);
 
        if (soc->force_pca_enable) {
                value = rp_readl(port, RP_VEND_CTL2);
@@ -974,7 +985,7 @@ static bool tegra_pcie_port_check_link(struct tegra_pcie_port *port)
                } while (--timeout);
 
 retry:
-               tegra_pcie_port_reset(port);
+               tegra_pcie_board_port_reset(port);
        } while (--retries);
 
        return false;
diff --git a/include/pci_tegra.h b/include/pci_tegra.h
new file mode 100644 (file)
index 0000000..11e92fc
--- /dev/null
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2018 Toradex, Inc.
+ */
+
+struct tegra_pcie_port;
+
+int tegra_pcie_port_index_of_port(struct tegra_pcie_port *port);
+
+void tegra_pcie_port_reset(struct tegra_pcie_port *port);