public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH 0/2] qspi: t210: fix claim_bus and clock/tap delays
@ 2020-03-17 17:03 twarren at nvidia.com
  2020-03-17 17:03 ` [PATCH 1/2] qspi: t210: Fix claim_bus's use of the wrong bus/device twarren at nvidia.com
  2020-03-17 17:03 ` [PATCH 2/2] qspi: t210: Fix QSPI clock and tap delays twarren at nvidia.com
  0 siblings, 2 replies; 3+ messages in thread
From: twarren at nvidia.com @ 2020-03-17 17:03 UTC (permalink / raw)
  To: u-boot

From: Tom Warren <twarren@nvidia.com>

These two patches fix a couple of problems encountered in the T210 QSPI 
driver discovered during Jetson Nano bringup.

Tom Warren (2):
  qspi: t210: Fix claim_bus's use of the wrong bus/device
  qspi: t210: Fix QSPI clock and tap delays

 drivers/spi/tegra210_qspi.c | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

-- 
1.8.2.1.610.g562af5b


-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information.  Any unauthorized review, use, disclosure or distribution
is prohibited.  If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] qspi: t210: Fix claim_bus's use of the wrong bus/device
  2020-03-17 17:03 [PATCH 0/2] qspi: t210: fix claim_bus and clock/tap delays twarren at nvidia.com
@ 2020-03-17 17:03 ` twarren at nvidia.com
  2020-03-17 17:03 ` [PATCH 2/2] qspi: t210: Fix QSPI clock and tap delays twarren at nvidia.com
  1 sibling, 0 replies; 3+ messages in thread
From: twarren at nvidia.com @ 2020-03-17 17:03 UTC (permalink / raw)
  To: u-boot

From: Tom Warren <twarren@nvidia.com>

claim_bus() is passed a udevice *dev, which is the bus device's parent.
In this driver, claim_bus assumed it was the bus, which caused the
'priv' info pointer to be wrong, and periph_id was incorrect. This in
turn caused the periph clock call to assign the wrong clock (PLLM
instead of PLLP0), which caused a kernel warning. I only saw the 'bad'
periph_id when enabling DEBUG due to an assert. Not sure how QSPI was
working w/this errant clock, but it was moot as QSPI wasn't active
unless you probed it, and that wasn't happening until I posted a patch
to enable env save to QSPI for Nano (coming soon).

Signed-off-by: Tom Warren <twarren@nvidia.com>
---
 drivers/spi/tegra210_qspi.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/tegra210_qspi.c b/drivers/spi/tegra210_qspi.c
index d82ecaa..2a77126 100644
--- a/drivers/spi/tegra210_qspi.c
+++ b/drivers/spi/tegra210_qspi.c
@@ -2,7 +2,8 @@
 /*
  * NVIDIA Tegra210 QSPI controller driver
  *
- * (C) Copyright 2015 NVIDIA Corporation <www.nvidia.com>
+ * (C) Copyright 2015-2019 NVIDIA Corporation <www.nvidia.com>
+ *
  */
 
 #include <common.h>
@@ -137,8 +138,9 @@ static int tegra210_qspi_probe(struct udevice *bus)
 	return 0;
 }
 
-static int tegra210_qspi_claim_bus(struct udevice *bus)
+static int tegra210_qspi_claim_bus(struct udevice *dev)
 {
+	struct udevice *bus = dev->parent;
 	struct tegra210_qspi_priv *priv = dev_get_priv(bus);
 	struct qspi_regs *regs = priv->regs;
 
-- 
1.8.2.1.610.g562af5b


-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information.  Any unauthorized review, use, disclosure or distribution
is prohibited.  If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] qspi: t210: Fix QSPI clock and tap delays
  2020-03-17 17:03 [PATCH 0/2] qspi: t210: fix claim_bus and clock/tap delays twarren at nvidia.com
  2020-03-17 17:03 ` [PATCH 1/2] qspi: t210: Fix claim_bus's use of the wrong bus/device twarren at nvidia.com
@ 2020-03-17 17:03 ` twarren at nvidia.com
  1 sibling, 0 replies; 3+ messages in thread
From: twarren at nvidia.com @ 2020-03-17 17:03 UTC (permalink / raw)
  To: u-boot

From: Tom Warren <twarren@nvidia.com>

When claim_bus was setting the clock, it reset the QSPI controller,
which wipes out any tap delays set by previous bootloaders (nvtboot,
CBoot for example on Nano). Instead of doing that in claim_bus, which
gets called a lot, moved clock setting to probe(), and set tap delays
there, too. Also updated clock to 80MHz to match CBoot. Now QSPI env
save will work reliably again on Nano.

Signed-off-by: Tom Warren <twarren@nvidia.com>
---
 drivers/spi/tegra210_qspi.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/spi/tegra210_qspi.c b/drivers/spi/tegra210_qspi.c
index 2a77126..4284ea9 100644
--- a/drivers/spi/tegra210_qspi.c
+++ b/drivers/spi/tegra210_qspi.c
@@ -42,10 +42,10 @@ DECLARE_GLOBAL_DATA_PTR;
 #define QSPI_CMD1_BITLEN_SHIFT		0
 
 /* COMMAND2 */
-#define QSPI_CMD2_TX_CLK_TAP_DELAY	BIT(6)
-#define QSPI_CMD2_TX_CLK_TAP_DELAY_MASK	GENMASK(11,6)
-#define QSPI_CMD2_RX_CLK_TAP_DELAY	BIT(0)
-#define QSPI_CMD2_RX_CLK_TAP_DELAY_MASK	GENMASK(5,0)
+#define QSPI_CMD2_TX_CLK_TAP_DELAY_SHIFT	10
+#define QSPI_CMD2_TX_CLK_TAP_DELAY_MASK	GENMASK(14,10)
+#define QSPI_CMD2_RX_CLK_TAP_DELAY_SHIFT	0
+#define QSPI_CMD2_RX_CLK_TAP_DELAY_MASK	GENMASK(7,0)
 
 /* TRANSFER STATUS */
 #define QSPI_XFER_STS_RDY		BIT(30)
@@ -127,14 +127,22 @@ static int tegra210_qspi_probe(struct udevice *bus)
 	struct tegra210_qspi_priv *priv = dev_get_priv(bus);
 
 	priv->regs = (struct qspi_regs *)plat->base;
+	struct qspi_regs *regs = priv->regs;
 
 	priv->last_transaction_us = timer_get_us();
 	priv->freq = plat->frequency;
 	priv->periph_id = plat->periph_id;
 
+	debug("%s: Freq = %u, id = %d\n", __func__, priv->freq, priv->periph_id);
 	/* Change SPI clock to correct frequency, PLLP_OUT0 source */
 	clock_start_periph_pll(priv->periph_id, CLOCK_ID_PERIPH, priv->freq);
 
+	/* Set tap delays here, clock change above resets QSPI controller */
+	u32 reg = (0x09 << QSPI_CMD2_TX_CLK_TAP_DELAY_SHIFT) |
+		   (0x0C << QSPI_CMD2_RX_CLK_TAP_DELAY_SHIFT);
+	writel(reg, &regs->command2);
+	debug("%s: COMMAND2 = %08x\n", __func__, readl(&regs->command2));
+
 	return 0;
 }
 
@@ -144,9 +152,6 @@ static int tegra210_qspi_claim_bus(struct udevice *dev)
 	struct tegra210_qspi_priv *priv = dev_get_priv(bus);
 	struct qspi_regs *regs = priv->regs;
 
-	/* Change SPI clock to correct frequency, PLLP_OUT0 source */
-	clock_start_periph_pll(priv->periph_id, CLOCK_ID_PERIPH, priv->freq);
-
 	debug("%s: FIFO STATUS = %08x\n", __func__, readl(&regs->fifo_status));
 
 	/* Set master mode and sw controlled CS */
-- 
1.8.2.1.610.g562af5b


-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information.  Any unauthorized review, use, disclosure or distribution
is prohibited.  If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-03-17 17:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-17 17:03 [PATCH 0/2] qspi: t210: fix claim_bus and clock/tap delays twarren at nvidia.com
2020-03-17 17:03 ` [PATCH 1/2] qspi: t210: Fix claim_bus's use of the wrong bus/device twarren at nvidia.com
2020-03-17 17:03 ` [PATCH 2/2] qspi: t210: Fix QSPI clock and tap delays twarren at nvidia.com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox