Skip to contentSkip to conversation

mtd: nand: raw: denali: Assert reset before deassert

PATCH Superseded Ley Foon Tan 3 participants 5 messages Jun 29, 2020 – Jul 10, 2020

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 mtd: nand: raw: denali: Assert reset before deassert

Always put the controller in reset, then take it out of reset. This is to make sure controller always in reset state in both SPL and proper Uboot.

This is preparation for the next patch to poll for reset completion (rst_comp) bit after reset.

---
 drivers/mtd/nand/raw/denali_dt.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/mtd/nand/raw/denali_dt.c +2 -0
index 2728e8098faa..75ad15b0758c 100644
@@ -148,6 +148,8 @@ static int denali_dt_probe(struct udevice *dev)
 	if (ret) {
 		dev_warn(dev, "Can't get reset: %d\n", ret);
 	} else {
+		reset_assert_bulk(&resets);
+		udelay(2);
 		reset_deassert_bulk(&resets);
 
 		/*
Signature · 1 line
2.19.0
#1 lore raw

PATCH 2/2 mtd: nand: raw: denali: Wait for reset completion status

Fixed delay 200us is not working in certain platforms. Change to poll for reset completion status to have more reliable reset process.

Controller will set the rst_comp bit in intr_status register after controller has completed its reset and initialization process.

---
 drivers/mtd/nand/raw/denali.c    | 11 +++++++++++
 drivers/mtd/nand/raw/denali.h    |  1 +
 drivers/mtd/nand/raw/denali_dt.c | 10 +++++++---
 3 files changed, 19 insertions(+), 3 deletions(-)
drivers/mtd/nand/raw/denali.c +11 -0
index 15e90291de09..ab91db85467d 100644
@@ -1220,6 +1220,17 @@ static int denali_multidev_fixup(struct denali_nand_info *denali)
 	return 0;
 }
 
+int denali_wait_reset_complete(struct denali_nand_info *denali)
+{
+	u32 irq_status;
+
+	irq_status = denali_wait_for_irq(denali, INTR__RST_COMP);
+	if (!(irq_status & INTR__RST_COMP))
+		return -EIO;
+
+	return 0;
+}
+
 int denali_init(struct denali_nand_info *denali)
 {
 	struct nand_chip *chip = &denali->nand;
drivers/mtd/nand/raw/denali.h +1 -0
index 019deda094e5..6cd02b2e26ee 100644
@@ -321,6 +321,7 @@ struct denali_nand_info {
 #define DENALI_CAP_DMA_64BIT			BIT(1)
 
 int denali_calc_ecc_bytes(int step_size, int strength);
+int denali_wait_reset_complete(struct denali_nand_info *denali);
 int denali_init(struct denali_nand_info *denali);
 
 #endif /* __DENALI_H__ */
drivers/mtd/nand/raw/denali_dt.c +7 -3
index 75ad15b0758c..8a6950f8a39f 100644
@@ -154,10 +154,14 @@ static int denali_dt_probe(struct udevice *dev)
 
 		/*
 		 * When the reset is deasserted, the initialization sequence is
-		 * kicked (bootstrap process). The driver must wait until it is
-		 * finished. Otherwise, it will result in unpredictable behavior.
+		 * kicked. The driver must wait until it is finished. Otherwise,
+		 * it will result in unpredictable behavior.
 		 */
-		udelay(200);
+		ret = denali_wait_reset_complete(denali);
+		if (ret) {
+			dev_err(denali->dev, "reset not completed.\n");
+			return ret;
+		}
 	}
 
 	return denali_init(denali);
Signature · 1 line
2.19.0
#2 lore raw

PATCH 2/2 mtd: nand: raw: denali: Wait for reset completion status

Quoted 54 lines · Ley Foon Tan

Fixed delay 200us is not working in certain platforms. Change to poll for reset completion status to have more reliable reset process.

Controller will set the rst_comp bit in intr_status register after controller has completed its reset and initialization process.

---
 drivers/mtd/nand/raw/denali.c    | 11 +++++++++++
 drivers/mtd/nand/raw/denali.h    |  1 +
 drivers/mtd/nand/raw/denali_dt.c | 10 +++++++---
 3 files changed, 19 insertions(+), 3 deletions(-)
drivers/mtd/nand/raw/denali.c +11 -0
index 15e90291de09..ab91db85467d 100644
@@ -1220,6 +1220,17 @@ static int denali_multidev_fixup(struct denali_nand_info *denali)
        return 0;
 }
 
+int denali_wait_reset_complete(struct denali_nand_info *denali)
+{
+       u32 irq_status;
+
+       irq_status = denali_wait_for_irq(denali, INTR__RST_COMP);
+       if (!(irq_status & INTR__RST_COMP))
+               return -EIO;
+
+       return 0;
+}
+
 int denali_init(struct denali_nand_info *denali)
 {
        struct nand_chip *chip = &denali->nand;
drivers/mtd/nand/raw/denali.h +1 -0
index 019deda094e5..6cd02b2e26ee 100644
@@ -321,6 +321,7 @@ struct denali_nand_info {
 #define DENALI_CAP_DMA_64BIT                   BIT(1)
 
 int denali_calc_ecc_bytes(int step_size, int strength);
+int denali_wait_reset_complete(struct denali_nand_info *denali);
 int denali_init(struct denali_nand_info *denali);
 
 #endif /* __DENALI_H__ */
drivers/mtd/nand/raw/denali_dt.c +0 -0
index 75ad15b0758c..8a6950f8a39f 100644

drivers/mtd/nand/raw/denali_dt.c static int denali_dt_probe(struct udevice *dev) · line 158

Quoted 7 lines
drivers/mtd/nand/raw/denali_dt.c +2 -2
@@ -154,10 +154,14 @@ static int denali_dt_probe(struct udevice *dev)
 
                /*
                 * When the reset is deasserted, the initialization sequence is
-                * kicked (bootstrap process). The driver must wait until it is
-                * finished. Otherwise, it will result in unpredictable behavior.
+                * kicked. The driver must wait until it is finished. Otherwise,
+                * it will result in unpredictable behavior.

What is your motivation for this hunk of change? (removal of "bootstrap process")

What was wrong with the current comment block?

The term "bootstrap" appears in the
Cadence (Denali) Flash Controller User Guide.

Quoted 11 lines
drivers/mtd/nand/raw/denali_dt.c +5 -2
                 */
-               udelay(200);
+               ret = denali_wait_reset_complete(denali);
+               if (ret) {
+                       dev_err(denali->dev, "reset not completed.\n");
+                       return ret;
+               }
        }
 
        return denali_init(denali);
--
Quoted 2 lines

2.19.0

I tested this patch on some of my socionext SoC boards, and I did not see regression.

But, please note this code will diverge from the Linux code.

Signature · 2 lines
Best Regards
Masahiro Yamada
#3 lore raw

PATCH 2/2 mtd: nand: raw: denali: Wait for reset completion status

Quoted 81 lines

-----Original Message-----
From: Masahiro Yamada <[email protected]>
Sent: Friday, July 10, 2020 12:27 AM
To: Tan, Ley Foon <[email protected]>
Cc: U-Boot Mailing List <[email protected]>; Simon Glass <[email protected]>; See, Chin Liang <[email protected]>; Bacrau, Radu <[email protected]>; Marek Vasut <[email protected]>
Subject: Re: [PATCH 2/2] mtd: nand: raw: denali: Wait for reset completion status

drivers/mtd/nand/raw/denali.c static int denali_multidev_fixup(struct

Quoted 21 lines · Ley Foon Tan

Fixed delay 200us is not working in certain platforms. Change to poll for reset completion status to have more reliable reset process.

Controller will set the rst_comp bit in intr_status register after controller has completed its reset and initialization process.

---
 drivers/mtd/nand/raw/denali.c    | 11 +++++++++++
 drivers/mtd/nand/raw/denali.h    |  1 +
 drivers/mtd/nand/raw/denali_dt.c | 10 +++++++---
 3 files changed, 19 insertions(+), 3 deletions(-)
(quoted diff) +0 -0

b/drivers/mtd/nand/raw/denali.c index 15e90291de09..ab91db85467d 100644

drivers/mtd/nand/raw/denali.c +0 -0
@@ -1220,6 +1220,17 @@ static int denali_multidev_fixup(struct

denali_nand_info *denali)

Quoted 33 lines
drivers/mtd/nand/raw/denali.c +10 -0
        return 0;
 }
 
+int denali_wait_reset_complete(struct denali_nand_info *denali) {
+       u32 irq_status;
+
+       irq_status = denali_wait_for_irq(denali, INTR__RST_COMP);
+       if (!(irq_status & INTR__RST_COMP))
+               return -EIO;
+
+       return 0;
+}
+
 int denali_init(struct denali_nand_info *denali)  {
        struct nand_chip *chip = &denali->nand; diff --git

a/drivers/mtd/nand/raw/denali.h b/drivers/mtd/nand/raw/denali.h index 019deda094e5..6cd02b2e26ee 100644

drivers/mtd/nand/raw/denali.h +1 -0
@@ -321,6 +321,7 @@ struct denali_nand_info {
 #define DENALI_CAP_DMA_64BIT                   BIT(1)
 
 int denali_calc_ecc_bytes(int step_size, int strength);
+int denali_wait_reset_complete(struct denali_nand_info *denali);
 int denali_init(struct denali_nand_info *denali);
 
 #endif /* __DENALI_H__ */
drivers/mtd/nand/raw/denali_dt.c +0 -0
index 75ad15b0758c..8a6950f8a39f 100644

drivers/mtd/nand/raw/denali_dt.c static int denali_dt_probe(struct udevice *dev) · line 158

Quoted 7 lines
drivers/mtd/nand/raw/denali_dt.c +2 -2
@@ -154,10 +154,14 @@ static int denali_dt_probe(struct udevice *dev)
 
                /*
                 * When the reset is deasserted, the initialization sequence is
-                * kicked (bootstrap process). The driver must wait until it is
-                * finished. Otherwise, it will result in unpredictable behavior.
+                * kicked. The driver must wait until it is finished. Otherwise,
+                * it will result in unpredictable behavior.

What is your motivation for this hunk of change?
(removal of "bootstrap process")

Quoted 5 lines

What was wrong with the current comment block?

The term "bootstrap" appears in the
Cadence (Denali) Flash Controller User Guide.

No special reason. Will send v2 patch to revert back "bootstrap process" in comment.

Thanks.

Regards
Ley Foon

#4 lore raw

PATCH 1/2 mtd: nand: raw: denali: Assert reset before deassert

In reply to Ley Foon Tan
Quoted 19 lines · Ley Foon Tan

Always put the controller in reset, then take it out of reset. This is to make sure controller always in reset state in both SPL and proper Uboot.

This is preparation for the next patch to poll for reset completion (rst_comp) bit after reset.

---
 drivers/mtd/nand/raw/denali_dt.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/mtd/nand/raw/denali_dt.c +0 -0
index 2728e8098faa..75ad15b0758c 100644

drivers/mtd/nand/raw/denali_dt.c static int denali_dt_probe(struct udevice *dev) · line 155

Quoted 8 lines
drivers/mtd/nand/raw/denali_dt.c +2 -0
@@ -148,6 +148,8 @@ static int denali_dt_probe(struct udevice *dev)
        if (ret) {
                dev_warn(dev, "Can't get reset: %d\n", ret);
        } else {
+               reset_assert_bulk(&resets);
+               udelay(2);
                reset_deassert_bulk(&resets);
 
                /*
Signature · 2 lines
Best Regards
Masahiro Yamada