All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
To: horms@verge.net.au, bhelgaas@google.com,
	linux-pci@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
	Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Subject: [PATCH 1/4] pcie-rcar: poll PHYRDY in rcar_pcie_hw_init()
Date: Fri, 6 Apr 2018 14:02:52 +0300	[thread overview]
Message-ID: <35e8fb4a-4b43-dac9-7a6f-cc7083c06453@cogentembedded.com> (raw)
In-Reply-To: <23335d95-63ca-b107-e43d-f4c2621adc2c@cogentembedded.com>

In  all the R-Car gen1/2/3 manuals, we are instructed to poll PCIEPHYSR
for PHYRDY=1  at  an early stage of the PCIEC initialization -- while
the driver only does this on R-Car H1 (polling a PHY specific register).
Add the PHYRDY polling to rcar_pcie_hw_init(). Note that without the
special PHY driver on the R-Car V3H the PCIEC initialization just freezes
the kernel --  adding the PHYRDY polling allows the init code to exit
gracefully on timeout (PHY starts powered down after reset on this SoC).

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>

---
 drivers/pci/host/pcie-rcar.c |   20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

Index: pci/drivers/pci/host/pcie-rcar.c
===================================================================
--- pci.orig/drivers/pci/host/pcie-rcar.c
+++ pci/drivers/pci/host/pcie-rcar.c
@@ -36,6 +36,8 @@
 #define PCIECDR			0x000020
 #define PCIEMSR			0x000028
 #define PCIEINTXR		0x000400
+#define PCIEPHYSR		0x0007f0
+#define  PHYRDY			1
 #define PCIEMSITXR		0x000840
 
 /* Transfer control */
@@ -527,6 +529,20 @@ static void phy_write_reg(struct rcar_pc
 	phy_wait_for_ack(pcie);
 }
 
+static int rcar_pcie_wait_for_phyrdy(struct rcar_pcie *pcie)
+{
+	unsigned int timeout = 10;
+
+	while (timeout--) {
+		if (rcar_pci_read_reg(pcie, PCIEPHYSR) & PHYRDY)
+			return 0;
+
+		msleep(5);
+	}
+
+	return -ETIMEDOUT;
+}
+
 static int rcar_pcie_wait_for_dl(struct rcar_pcie *pcie)
 {
 	unsigned int timeout = 10;
@@ -551,6 +567,10 @@ static int rcar_pcie_hw_init(struct rcar
 	/* Set mode */
 	rcar_pci_write_reg(pcie, 1, PCIEMSR);
 
+	err = rcar_pcie_wait_for_phyrdy(pcie);
+	if (err)
+		return err;
+
 	/*
 	 * Initial header for port config space is type 1, set the device
 	 * class to match. Hardware takes care of propagating the IDSETR

  reply	other threads:[~2018-04-06 11:02 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-06 10:58 [PATCH 0/4] Add R8A77980 PCIe support & some driver cleanups Sergei Shtylyov
2018-04-06 11:02 ` Sergei Shtylyov [this message]
2018-04-09 10:54   ` [PATCH 1/4] pcie-rcar: poll PHYRDY in rcar_pcie_hw_init() Simon Horman
2018-04-09 10:55     ` Simon Horman
2018-04-09 11:24     ` Simon Horman
2018-04-09 15:45     ` Sergei Shtylyov
2018-04-06 11:04 ` [PATCH 2/4] pcie-rcar: remove PHYRDY polling from rcar_pcie_hw_init_h1() Sergei Shtylyov
2018-04-09 10:56   ` Simon Horman
2018-04-09 15:33     ` Sergei Shtylyov
2018-04-06 11:08 ` [PATCH 3/4] pcie-rcar: add R-Car gen3 PHY support Sergei Shtylyov
2018-04-07 18:35   ` Sergei Shtylyov
2018-04-09 11:00   ` Simon Horman
2018-04-06 11:10 ` [PATCH 4/4] pcie-rcar: factor out rcar_pcie_hw_init() call Sergei Shtylyov
2018-04-09  8:34   ` Geert Uytterhoeven
2018-04-09 11:04   ` Simon Horman
2018-04-09 15:21     ` Sergei Shtylyov
2018-04-06 11:24 ` [PATCH 0/4] Add R8A77980 PCIe support & some driver cleanups Sergei Shtylyov

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=35e8fb4a-4b43-dac9-7a6f-cc7083c06453@cogentembedded.com \
    --to=sergei.shtylyov@cogentembedded.com \
    --cc=bhelgaas@google.com \
    --cc=horms@verge.net.au \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.