Skip to contentSkip to conversation

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

PATCH New Ley Foon Tan 3 participants 5 messages Jul 10, 2020 – Jul 14, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 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.

---
v2:
- Added "Tested-by" in commit message.

---
 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 v2 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.

---
v2:
- Added "Tested-by" in commit message.
- Restore "bootstrap process" in comment.

---
 drivers/mtd/nand/raw/denali.c    | 11 +++++++++++
 drivers/mtd/nand/raw/denali.h    |  1 +
 drivers/mtd/nand/raw/denali_dt.c | 11 ++++++++---
 3 files changed, 20 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 +8 -3
index 75ad15b0758c..c22b05940df6 100644
@@ -154,10 +154,15 @@ 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 (bootstrap proccess). 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 v2 2/2 mtd: nand: raw: denali: Wait for reset completion status

Quoted 60 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.

---
v2:
- Added "Tested-by" in commit message.
- Restore "bootstrap process" in comment.

---
 drivers/mtd/nand/raw/denali.c    | 11 +++++++++++
 drivers/mtd/nand/raw/denali.h    |  1 +
 drivers/mtd/nand/raw/denali_dt.c | 11 ++++++++---
 3 files changed, 20 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..c22b05940df6 100644

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

Quoted 6 lines
drivers/mtd/nand/raw/denali_dt.c +1 -2
@@ -154,10 +154,15 @@ 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 (bootstrap proccess). The driver must wait until it

Again, you are touching this comment line with no good reason. "proccess" is a typo.

I fixed it up and applied.
Thanks.

Quoted 15 lines
drivers/mtd/nand/raw/denali_dt.c +7 -2
+                * 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);
--

2.19.0

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

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

Quoted 88 lines

-----Original Message-----
From: Masahiro Yamada <[email protected]>
Sent: Friday, July 10, 2020 9:08 PM
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 v2 2/2] mtd: nand: raw: denali: Wait for reset completion status

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

Quoted 27 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.

---
v2:
- Added "Tested-by" in commit message.
- Restore "bootstrap process" in comment.

---
 drivers/mtd/nand/raw/denali.c    | 11 +++++++++++
 drivers/mtd/nand/raw/denali.h    |  1 +
 drivers/mtd/nand/raw/denali_dt.c | 11 ++++++++---
 3 files changed, 20 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..c22b05940df6 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,15 @@ 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 (bootstrap proccess). The driver must wait
+ until it

Again, you are touching this comment line with no good reason. "proccess" is a typo.

Quoted 2 lines

I fixed it up and applied.
Thanks.

Thanks.

Regards
Ley Foon

#4 lore raw

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

In reply to Ley Foon Tan
Quoted 11 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.

I will include this in my next pull request.

Applied.
Thanks.

Signature · 2 lines
Best Regards
Masahiro Yamada