linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: Mathias Nyman <mathias.nyman@intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jon Hunter <jonathanh@nvidia.com>, JC Kuo <jckuo@nvidia.com>,
	Nagarjuna Kristam <nkristam@nvidia.com>,
	Sowjanya Komatineni <skomatineni@nvidia.com>,
	linux-usb@vger.kernel.org, linux-tegra@vger.kernel.org
Subject: [PATCH 06/10] usb: host: xhci-tegra: Reuse stored register base address
Date: Mon, 25 Nov 2019 13:32:06 +0100	[thread overview]
Message-ID: <20191125123210.1564323-7-thierry.reding@gmail.com> (raw)
In-Reply-To: <20191125123210.1564323-1-thierry.reding@gmail.com>

From: Thierry Reding <treding@nvidia.com>

The base address of the XUSB controller's registers is already stored in
the HCD. Move assignment to the HCD fields to an earlier point so that
they can be reused in the tegra_xusb_config() function. This avoids the
need to pass the base address as an extra parameter, which in turn comes
in handy in subsequent patches that need to call this function from the
suspend/resume paths where these values are no longer readily available.

Based on work by JC Kuo <jckuo@nvidia.com>.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/usb/host/xhci-tegra.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c
index 4244367d3573..5eca3ea0e8b2 100644
--- a/drivers/usb/host/xhci-tegra.c
+++ b/drivers/usb/host/xhci-tegra.c
@@ -625,9 +625,9 @@ static irqreturn_t tegra_xusb_mbox_thread(int irq, void *data)
 	return IRQ_HANDLED;
 }
 
-static void tegra_xusb_config(struct tegra_xusb *tegra,
-			      struct resource *regs)
+static void tegra_xusb_config(struct tegra_xusb *tegra)
 {
+	u32 regs = tegra->hcd->rsrc_start;
 	u32 value;
 
 	if (tegra->soc->has_ipfs) {
@@ -641,7 +641,7 @@ static void tegra_xusb_config(struct tegra_xusb *tegra,
 	/* Program BAR0 space */
 	value = fpci_readl(tegra, XUSB_CFG_4);
 	value &= ~(XUSB_BASE_ADDR_MASK << XUSB_BASE_ADDR_SHIFT);
-	value |= regs->start & (XUSB_BASE_ADDR_MASK << XUSB_BASE_ADDR_SHIFT);
+	value |= regs & (XUSB_BASE_ADDR_MASK << XUSB_BASE_ADDR_SHIFT);
 	fpci_writel(tegra, value, XUSB_CFG_4);
 
 	usleep_range(100, 200);
@@ -1230,6 +1230,10 @@ static int tegra_xusb_probe(struct platform_device *pdev)
 		goto put_powerdomains;
 	}
 
+	tegra->hcd->regs = tegra->regs;
+	tegra->hcd->rsrc_start = regs->start;
+	tegra->hcd->rsrc_len = resource_size(regs);
+
 	/*
 	 * This must happen after usb_create_hcd(), because usb_create_hcd()
 	 * will overwrite the drvdata of the device with the hcd it creates.
@@ -1253,7 +1257,7 @@ static int tegra_xusb_probe(struct platform_device *pdev)
 		goto disable_phy;
 	}
 
-	tegra_xusb_config(tegra, regs);
+	tegra_xusb_config(tegra);
 
 	/*
 	 * The XUSB Falcon microcontroller can only address 40 bits, so set
@@ -1277,10 +1281,6 @@ static int tegra_xusb_probe(struct platform_device *pdev)
 		goto free_firmware;
 	}
 
-	tegra->hcd->regs = tegra->regs;
-	tegra->hcd->rsrc_start = regs->start;
-	tegra->hcd->rsrc_len = resource_size(regs);
-
 	err = usb_add_hcd(tegra->hcd, tegra->xhci_irq, IRQF_SHARED);
 	if (err < 0) {
 		dev_err(&pdev->dev, "failed to add USB HCD: %d\n", err);
-- 
2.23.0


  parent reply	other threads:[~2019-11-25 12:32 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-25 12:32 [PATCH 00/10] usb: host: xhci-tegra: Implement basic ELPG support Thierry Reding
2019-11-25 12:32 ` [PATCH 01/10] usb: host: xhci-tegra: Fix "tega" -> "tegra" typo Thierry Reding
2019-11-26  2:50   ` JC Kuo
2019-11-25 12:32 ` [PATCH 02/10] usb: host: xhci-tegra: Separate firmware request and load Thierry Reding
2019-11-25 12:32 ` [PATCH 03/10] usb: host: xhci-tegra: Avoid a fixed duration sleep Thierry Reding
2019-11-25 13:33   ` Mikko Perttunen
2019-11-25 12:32 ` [PATCH 04/10] usb: host: xhci-tegra: Use CNR as firmware ready indicator Thierry Reding
2019-11-25 12:32 ` [PATCH 05/10] usb: host: xhci-tegra: Extract firmware enable helper Thierry Reding
2019-11-25 12:32 ` Thierry Reding [this message]
2019-11-25 12:32 ` [PATCH 07/10] usb: host: xhci-tegra: Enable runtime PM as late as possible Thierry Reding
2019-11-25 12:32 ` [PATCH 08/10] usb: host: xhci-tegra: Add support for XUSB context save/restore Thierry Reding
2019-11-25 12:32 ` [PATCH 09/10] usb: host: xhci-tegra: Add XUSB controller context Thierry Reding
2019-11-25 12:32 ` [PATCH 10/10] usb: host: xhci-tegra: Implement basic ELPG support Thierry Reding
2019-11-26 15:43   ` Mathias Nyman
2019-12-06 14:27     ` Thierry Reding

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191125123210.1564323-7-thierry.reding@gmail.com \
    --to=thierry.reding@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jckuo@nvidia.com \
    --cc=jonathanh@nvidia.com \
    --cc=linux-tegra@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@intel.com \
    --cc=nkristam@nvidia.com \
    --cc=skomatineni@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).