Skip to contentSkip to conversation

mtd: nand: denali_dt: Add reset support

PATCH New Marek Vasut 3 participants 7 messages Aug 21, 2018 – Sep 7, 2018

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

PATCH 1/1 mtd: nand: denali_dt: Add reset support

Add optional reset support into the Denali NAND driver. In case there is a valid reset entry in the DT, the reset gets deasserted before the NAND controller gets used.

Cc Masahiro Yamada <[email protected]>
---
 drivers/mtd/nand/denali_dt.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/mtd/nand/denali_dt.c +9 -0
index 65a7797f0f..6fcd7d3843 100644
@@ -9,6 +9,7 @@
 #include <linux/io.h>
 #include <linux/ioport.h>
 #include <linux/printk.h>
+#include <reset.h>
 
 #include "denali.h"
 
@@ -64,6 +65,7 @@ static int denali_dt_probe(struct udevice *dev)
 	const struct denali_dt_data *data;
 	struct clk clk;
 	struct resource res;
+	struct reset_ctl reset_ctl;
 	int ret;
 
 	data = (void *)dev_get_driver_data(dev);
@@ -97,6 +99,13 @@ static int denali_dt_probe(struct udevice *dev)
 
 	denali->clk_x_rate = clk_get_rate(&clk);
 
+	ret = reset_get_by_index(dev, 0, &reset_ctl);
+	if (!ret) {
+		reset_assert(&reset_ctl);
+		udelay(2);
+		reset_deassert(&reset_ctl);
+	}
+
 	return denali_init(denali);
 }
 
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 mtd: nand: denali_dt: Add reset support

Hi Marek,

2018-08-21 22:57 GMT+09:00 Marek Vasut <[email protected]>:

Quoted 34 lines

Add optional reset support into the Denali NAND driver. In case there is a valid reset entry in the DT, the reset gets deasserted before the NAND controller gets used.

Cc Masahiro Yamada <[email protected]>
---
 drivers/mtd/nand/denali_dt.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/mtd/nand/denali_dt.c +2 -0
index 65a7797f0f..6fcd7d3843 100644
@@ -9,6 +9,7 @@
 #include <linux/io.h>
 #include <linux/ioport.h>
 #include <linux/printk.h>
+#include <reset.h>
 
 #include "denali.h"
 
@@ -64,6 +65,7 @@ static int denali_dt_probe(struct udevice *dev)
        const struct denali_dt_data *data;
        struct clk clk;
        struct resource res;
+       struct reset_ctl reset_ctl;
        int ret;
 
        data = (void *)dev_get_driver_data(dev);
@@ -97,6 +99,13 @@ static int denali_dt_probe(struct udevice *dev)
 
        denali->clk_x_rate = clk_get_rate(&clk);
 

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

Quoted 10 lines
drivers/mtd/nand/denali_dt.c +7 -0
+       ret = reset_get_by_index(dev, 0, &reset_ctl);
+       if (!ret) {
+               reset_assert(&reset_ctl);
+               udelay(2);
+               reset_deassert(&reset_ctl);
+       }
+
        return denali_init(denali);
 }
 

I was testing this patch today
because my SoC also has a reset line for NAND.

This patch looks trivial enough,
but if the NAND is reset here,
my board fails to boot with
"nand_base: timeout while waiting for chip to become ready"

I do not know why.
Please give me more time to figure out what is going on in my SoC.

U-Boot SPL 2018.09-rc2-00106-g5f0d7e5-dirty (Aug 24 2018 - 22:00:33 +0900) Trying to boot from NOR

U-Boot 2018.09-rc2-00106-g5f0d7e5-dirty (Aug 24 2018 - 22:00:33 +0900)

SoC:   LD4 (model 1, revision 3)
Model: UniPhier LD4 Reference Board
DRAM:  512 MiB
SC:    Micro Support Card (CPLD version 3.6)
NAND:  nand_base: timeout while waiting for chip to become ready
Signature · 2 lines
Best Regards
Masahiro Yamada
#2 lore raw

PATCH 1/1 mtd: nand: denali_dt: Add reset support

Quoted 1 line · Masahiro Yamada

Hi Marek,

Hi,

Quoted 51 lines

2018-08-21 22:57 GMT+09:00 Marek Vasut <[email protected]>:

Quoted 34 lines

Add optional reset support into the Denali NAND driver. In case there is a valid reset entry in the DT, the reset gets deasserted before the NAND controller gets used.

Cc Masahiro Yamada <[email protected]>
---
 drivers/mtd/nand/denali_dt.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/mtd/nand/denali_dt.c +2 -0
index 65a7797f0f..6fcd7d3843 100644
@@ -9,6 +9,7 @@
 #include <linux/io.h>
 #include <linux/ioport.h>
 #include <linux/printk.h>
+#include <reset.h>
 
 #include "denali.h"
 
@@ -64,6 +65,7 @@ static int denali_dt_probe(struct udevice *dev)
        const struct denali_dt_data *data;
        struct clk clk;
        struct resource res;
+       struct reset_ctl reset_ctl;
        int ret;
 
        data = (void *)dev_get_driver_data(dev);
@@ -97,6 +99,13 @@ static int denali_dt_probe(struct udevice *dev)
 
        denali->clk_x_rate = clk_get_rate(&clk);
 

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

Quoted 10 lines
drivers/mtd/nand/denali_dt.c +7 -0
+       ret = reset_get_by_index(dev, 0, &reset_ctl);
+       if (!ret) {
+               reset_assert(&reset_ctl);
+               udelay(2);
+               reset_deassert(&reset_ctl);
+       }
+
        return denali_init(denali);
 }
 

I was testing this patch today
because my SoC also has a reset line for NAND.

Quoted 8 lines

This patch looks trivial enough,
but if the NAND is reset here,
my board fails to boot with
"nand_base: timeout while waiting for chip to become ready"

I do not know why.
Please give me more time to figure out what is going on in my SoC.

Sure. Maybe you need to un-reset more stuff or the reset polarity is wrong ?

Signature · 2 lines
Best regards,
Marek Vasut
#3 lore raw

PATCH 1/1 mtd: nand: denali_dt: Add reset support

Quoted 62 lines · Marek Vasut
Quoted 1 line · Masahiro Yamada

Hi Marek,

Hi,

Quoted 57 lines

2018-08-21 22:57 GMT+09:00 Marek Vasut <[email protected]>:

Quoted 34 lines

Add optional reset support into the Denali NAND driver. In case there is a valid reset entry in the DT, the reset gets deasserted before the NAND controller gets used.

Cc Masahiro Yamada <[email protected]>
---
 drivers/mtd/nand/denali_dt.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/mtd/nand/denali_dt.c +2 -0
index 65a7797f0f..6fcd7d3843 100644
@@ -9,6 +9,7 @@
 #include <linux/io.h>
 #include <linux/ioport.h>
 #include <linux/printk.h>
+#include <reset.h>
 
 #include "denali.h"
 
@@ -64,6 +65,7 @@ static int denali_dt_probe(struct udevice *dev)
        const struct denali_dt_data *data;
        struct clk clk;
        struct resource res;
+       struct reset_ctl reset_ctl;
        int ret;
 
        data = (void *)dev_get_driver_data(dev);
@@ -97,6 +99,13 @@ static int denali_dt_probe(struct udevice *dev)
 
        denali->clk_x_rate = clk_get_rate(&clk);
 

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

Quoted 10 lines
drivers/mtd/nand/denali_dt.c +7 -0
+       ret = reset_get_by_index(dev, 0, &reset_ctl);
+       if (!ret) {
+               reset_assert(&reset_ctl);
+               udelay(2);
+               reset_deassert(&reset_ctl);
+       }
+
        return denali_init(denali);
 }
 

I was testing this patch today
because my SoC also has a reset line for NAND.

This patch looks trivial enough,
but if the NAND is reset here,
my board fails to boot with
"nand_base: timeout while waiting for chip to become ready"

Quoted 4 lines
Quoted 2 lines

I do not know why.
Please give me more time to figure out what is going on in my SoC.

Sure. Maybe you need to un-reset more stuff or the reset polarity is wrong ?

Did you figure something out ?

Signature · 2 lines
Best regards,
Marek Vasut
#4 lore raw

PATCH 1/1 mtd: nand: denali_dt: Add reset support

2018-09-05 17:31 GMT+09:00 Marek Vasut <[email protected]>:

Quoted 63 lines · Marek Vasut
Quoted 62 lines · Masahiro Yamada
Quoted 1 line

Hi Marek,

Hi,

Quoted 57 lines

2018-08-21 22:57 GMT+09:00 Marek Vasut <[email protected]>:

Quoted 34 lines

Add optional reset support into the Denali NAND driver. In case there is a valid reset entry in the DT, the reset gets deasserted before the NAND controller gets used.

Cc Masahiro Yamada <[email protected]>
---
 drivers/mtd/nand/denali_dt.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/mtd/nand/denali_dt.c +2 -0
index 65a7797f0f..6fcd7d3843 100644
@@ -9,6 +9,7 @@
 #include <linux/io.h>
 #include <linux/ioport.h>
 #include <linux/printk.h>
+#include <reset.h>
 
 #include "denali.h"
 
@@ -64,6 +65,7 @@ static int denali_dt_probe(struct udevice *dev)
        const struct denali_dt_data *data;
        struct clk clk;
        struct resource res;
+       struct reset_ctl reset_ctl;
        int ret;
 
        data = (void *)dev_get_driver_data(dev);
@@ -97,6 +99,13 @@ static int denali_dt_probe(struct udevice *dev)
 
        denali->clk_x_rate = clk_get_rate(&clk);
 

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

Quoted 10 lines
drivers/mtd/nand/denali_dt.c +7 -0
+       ret = reset_get_by_index(dev, 0, &reset_ctl);
+       if (!ret) {
+               reset_assert(&reset_ctl);
+               udelay(2);
+               reset_deassert(&reset_ctl);
+       }
+
        return denali_init(denali);
 }
 

I was testing this patch today
because my SoC also has a reset line for NAND.

This patch looks trivial enough,
but if the NAND is reset here,
my board fails to boot with
"nand_base: timeout while waiting for chip to become ready"

Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

I do not know why.
Please give me more time to figure out what is going on in my SoC.

Sure. Maybe you need to un-reset more stuff or the reset polarity is wrong ?

I do not think so.

The reset sequence of Denali is not so simple as you may think because the HW sequencer runs after the reset de-assertion. It includes some SoC-dependent parts.

Quoted 3 lines

Did you figure something out ?

Just testing one of my boards.

It booted by adding mdelay() after reset_deassert().

        reset_assert(&reset_ctl);
        udelay(2);
        reset_deassert(&reset_ctl);
        mdelay(1);           /* Why is this long delay required? */

I will read HW docs more,
and talk to HW engineers
to figure out the right solution.

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

PATCH 1/1 mtd: nand: denali_dt: Add reset support

Quoted 85 lines · Masahiro Yamada

2018-09-05 17:31 GMT+09:00 Marek Vasut <[email protected]>:

Quoted 63 lines · Marek Vasut
Quoted 62 lines · Masahiro Yamada
Quoted 1 line

Hi Marek,

Hi,

Quoted 57 lines

2018-08-21 22:57 GMT+09:00 Marek Vasut <[email protected]>:

Quoted 34 lines

Add optional reset support into the Denali NAND driver. In case there is a valid reset entry in the DT, the reset gets deasserted before the NAND controller gets used.

Cc Masahiro Yamada <[email protected]>
---
 drivers/mtd/nand/denali_dt.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/mtd/nand/denali_dt.c +2 -0
index 65a7797f0f..6fcd7d3843 100644
@@ -9,6 +9,7 @@
 #include <linux/io.h>
 #include <linux/ioport.h>
 #include <linux/printk.h>
+#include <reset.h>
 
 #include "denali.h"
 
@@ -64,6 +65,7 @@ static int denali_dt_probe(struct udevice *dev)
        const struct denali_dt_data *data;
        struct clk clk;
        struct resource res;
+       struct reset_ctl reset_ctl;
        int ret;
 
        data = (void *)dev_get_driver_data(dev);
@@ -97,6 +99,13 @@ static int denali_dt_probe(struct udevice *dev)
 
        denali->clk_x_rate = clk_get_rate(&clk);
 

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

Quoted 10 lines
drivers/mtd/nand/denali_dt.c +7 -0
+       ret = reset_get_by_index(dev, 0, &reset_ctl);
+       if (!ret) {
+               reset_assert(&reset_ctl);
+               udelay(2);
+               reset_deassert(&reset_ctl);
+       }
+
        return denali_init(denali);
 }
 

I was testing this patch today
because my SoC also has a reset line for NAND.

This patch looks trivial enough,
but if the NAND is reset here,
my board fails to boot with
"nand_base: timeout while waiting for chip to become ready"

Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

I do not know why.
Please give me more time to figure out what is going on in my SoC.

Sure. Maybe you need to un-reset more stuff or the reset polarity is wrong ?

I do not think so.

The reset sequence of Denali is not so simple as you may think because the HW sequencer runs after the reset de-assertion. It includes some SoC-dependent parts.

Quoted 3 lines

Did you figure something out ?

Just testing one of my boards.

Quoted 8 lines

It booted by adding mdelay() after reset_deassert().

        reset_assert(&reset_ctl);
        udelay(2);
        reset_deassert(&reset_ctl);
        mdelay(1);           /* Why is this long delay required? */

It works right away after ungating the reset on my board.

Quoted 3 lines

I will read HW docs more,
and talk to HW engineers
to figure out the right solution.

OK

Signature · 2 lines
Best regards,
Marek Vasut
#6 lore raw

PATCH 1/1 mtd: nand: denali_dt: Add reset support

Hi Marek,

2018-09-06 17:02 GMT+09:00 Marek Vasut <[email protected]>:

Quoted 90 lines · Masahiro Yamada
Quoted 89 lines

2018-09-05 17:31 GMT+09:00 Marek Vasut <[email protected]>:

Quoted 63 lines · Marek Vasut
Quoted 62 lines · Masahiro Yamada
Quoted 1 line

Hi Marek,

Hi,

Quoted 57 lines

2018-08-21 22:57 GMT+09:00 Marek Vasut <[email protected]>:

Quoted 34 lines

Add optional reset support into the Denali NAND driver. In case there is a valid reset entry in the DT, the reset gets deasserted before the NAND controller gets used.

Cc Masahiro Yamada <[email protected]>
---
 drivers/mtd/nand/denali_dt.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/mtd/nand/denali_dt.c +2 -0
index 65a7797f0f..6fcd7d3843 100644
@@ -9,6 +9,7 @@
 #include <linux/io.h>
 #include <linux/ioport.h>
 #include <linux/printk.h>
+#include <reset.h>
 
 #include "denali.h"
 
@@ -64,6 +65,7 @@ static int denali_dt_probe(struct udevice *dev)
        const struct denali_dt_data *data;
        struct clk clk;
        struct resource res;
+       struct reset_ctl reset_ctl;
        int ret;
 
        data = (void *)dev_get_driver_data(dev);
@@ -97,6 +99,13 @@ static int denali_dt_probe(struct udevice *dev)
 
        denali->clk_x_rate = clk_get_rate(&clk);
 

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

Quoted 10 lines
drivers/mtd/nand/denali_dt.c +7 -0
+       ret = reset_get_by_index(dev, 0, &reset_ctl);
+       if (!ret) {
+               reset_assert(&reset_ctl);
+               udelay(2);
+               reset_deassert(&reset_ctl);
+       }
+
        return denali_init(denali);
 }
 

I was testing this patch today
because my SoC also has a reset line for NAND.

This patch looks trivial enough,
but if the NAND is reset here,
my board fails to boot with
"nand_base: timeout while waiting for chip to become ready"

Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

I do not know why.
Please give me more time to figure out what is going on in my SoC.

Sure. Maybe you need to un-reset more stuff or the reset polarity is wrong ?

I do not think so.

The reset sequence of Denali is not so simple as you may think because the HW sequencer runs after the reset de-assertion. It includes some SoC-dependent parts.

Quoted 3 lines

Did you figure something out ?

Just testing one of my boards.

It booted by adding mdelay() after reset_deassert().

Quoted 6 lines
Quoted 4 lines
        reset_assert(&reset_ctl);
        udelay(2);
        reset_deassert(&reset_ctl);
        mdelay(1);           /* Why is this long delay required? */

It works right away after ungating the reset on my board.

With my further tests, it typically takes 200 usec
for the chip identification sequence after the reset de-assertion.

The number is for my UniPhier SoC family.

This part is SoC-dependent,
so the situation is probably different for SOCFPGA.

I'd like to suggest the following sequence.

         reset_assert(&reset_ctl);
         udelay(1);
         reset_deassert(&reset_ctl);
         udelay(200);

Is this OK with you?

The IP datasheet says that the reset lines should be
kept 10 clock cycles. I think udelay(1) is good enough for reset assertion.

BTW, are you applying this patch to your tree?

Or, do you want me to pick this up?

Quoted 5 lines
Quoted 3 lines

I will read HW docs more,
and talk to HW engineers
to figure out the right solution.

OK

Signature · 2 lines
Best Regards
Masahiro Yamada