From patchwork Wed Aug 9 20:12:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcel Ziswiler X-Patchwork-Id: 799919 X-Patchwork-Delegate: twarren@nvidia.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3xSMvz2KKkz9s0Z for ; Thu, 10 Aug 2017 06:15:43 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 0EB56C21D83; Wed, 9 Aug 2017 20:14:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 3B07AC21DCB; Wed, 9 Aug 2017 20:13:43 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 29263C21D56; Wed, 9 Aug 2017 20:13:35 +0000 (UTC) Received: from mout.perfora.net (mout.perfora.net [74.208.4.194]) by lists.denx.de (Postfix) with ESMTPS id D83C1C21C8F for ; Wed, 9 Aug 2017 20:13:34 +0000 (UTC) Received: from localhost.localdomain.ziswiler.net ([89.217.76.191]) by mrelay.perfora.net (mreueus001 [74.208.5.2]) with ESMTPA (Nemesis) id 0MWyu2-1eBLPs46Me-00Vz2D; Wed, 09 Aug 2017 22:13:09 +0200 From: Marcel Ziswiler To: u-boot@lists.denx.de Date: Wed, 9 Aug 2017 22:12:40 +0200 Message-Id: <20170809201242.16355-5-marcel@ziswiler.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170809201242.16355-1-marcel@ziswiler.com> References: <20170809201242.16355-1-marcel@ziswiler.com> X-Provags-ID: V03:K0:+Q63ilaNAJEVhXSEvbZXXdbpUZfZLk3yePam3lvI6xbFIhioa4S COf0uexgKFH8YMzK33OhKTGfYE7UeDIZgXD6ZnvkqIS9maUCKQFFTPTT3o7EXXTnYTwz42W BMAnnKGLKJmcldP1bze9p4RoFLW/oscP1T2uBrageVe493HpPXWO+z9+DpRpBmKRD6qFoaa mWipP95JQNcmLftg7+/1w== X-UI-Out-Filterresults: notjunk:1; V01:K0:vN1I3HFtyPo=:mLJuWCfNbVxAgiKezEvaj9 wW7xm2ZKm6yai5Uf79Z8RZorpO9sql6Rg/vDHQG2CPr/C4GT0w5UoFOk3vU8Ukd7OuNh0/SG1 LpTDtaBt+DuNmS9BlPam8/s2zjsHHfUg+oR58hH5cN4np3yLIdn5uivHz8L7Dti3DPKtlvZgY wCFWeDeypljCGkRxp+7+qNjyAEvz8dJEG8DqQLeacfVZhc0olX98mZsxQdI0hH8B5Jxitvc+y CXIWHzKatPYRCLTO31KnEl8VHXpD3EbIdklvN8GKSdbkVPOXG75XuU5julULyOzyBu9c7FGsC OpccMknNYBYkV+Hlbez7Wvg+Q3yXusQIsjA714TLIAKFaJG1udP64Z6W3T/SMxWvkWLMeYECd N6RzdfW+hSA2nAH0bXA1BJ7U9Q8Cxd4iCKWojA4tnbXFasJh+AfRFqHK6seaXU5YOqeYHXY/P XYUKxzi92j7ATE1flF0Zpp6LTjPMooijrf7FK3MVtBayBIJc1Kq7VOtPyRgj1qeyWgOvIIrQO CSUaR3tBCTRgGJcl5rn9cXXPRjedqJ/2ow//grFQ+MjZsG+v9lQ7aMogLC3GVZk60hY0DLGi8 OPE1lixmN1tuU5PARXScJpRXpU4QjydI/uJ9KPKUwf6MSRHo30vXYDKXKYOK94obEIrgQGdqt 5fLIyEUXnZVusvM/xGgPBmmndC41tAXQmd3aSYuVLYsfr98N5mk2jrwFOV87OvNIK/XdLEfgp u+rtpEsEsZyCfoJPdg8kIJAcnvZeWECkeX+OXQ== Cc: Stephen Warren , Marcel Ziswiler , Tom Warren Subject: [U-Boot] [PATCH v4 4/6] pci: tegra: introduce weak tegra_pcie_board_port_reset() function X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" From: Marcel Ziswiler 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 Acked-by: Stephen Warren --- Changes in v4: - Revert previously missed (struct tegra_pcie_port *) casts as reported by Stephen. Changes in v3: - Stick to struct tegra_pcie_port as suggested by Stephen. Changes in v2: - Incorporate Stephen's review feedback by introducing a tegra_pcie_port_index_of_port() function as well as a board-specific reset override function. drivers/pci/pci_tegra.c | 17 ++++++++++++++--- include/pci_tegra.h | 11 +++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 include/pci_tegra.h diff --git a/drivers/pci/pci_tegra.c b/drivers/pci/pci_tegra.c index cb5cf8b..e371c0b 100644 --- a/drivers/pci/pci_tegra.c +++ b/drivers/pci/pci_tegra.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -893,7 +894,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; @@ -910,6 +911,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; @@ -928,7 +939,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); @@ -979,7 +990,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 index 0000000..2bf1f59 --- /dev/null +++ b/include/pci_tegra.h @@ -0,0 +1,11 @@ +/* + * Copyright (c) 2017 Toradex, Inc. + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +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);