diff mbox series

[V2,3/3] mtd: rawnand: denali: Do not reset the block before booting the kernel

Message ID 20200121190311.3699-3-marex@denx.de
State Accepted
Commit 9925df051a7964e939298fe54df60153409b6352
Headers show
Series [V2,1/3] mtd: rawnand: denali-spl: Add missing hardware init on SoCFPGA | expand

Commit Message

Marek Vasut Jan. 21, 2020, 7:03 p.m. UTC
The register values programmed into the Denali NAND IP are not preserved
when the IP reset signal is asserted. Depending on whether the Denali NAND
IP implementation uses HW-assisted bootstrap or not, some of the register
values are restored automatically after the IP is released from reset.

If HW-assisted bootstrap is used, only RB_PIN_ENABLED, CHIP_ENABLE_DONT_CARE,
SPARE_AREA_SKIP_BYTES and SPARE_AREA_MARKER need to be restored after reset,
this is the case on Altera SoCFPGA. Otherwise, many more registers must be
restored. Since mainline Linux currently does not handle this correctly, do
not reset the Denali NAND IP before booting Linux. This permits Linux to use
the register values retained in the Denali NAND IP and thus correctly access
the NAND.

Fixes: ed784ac3822b ("mtd: rawnand: denali: add reset handling")
Signed-off-by: Marek Vasut <marex at denx.de>
Cc: Masahiro Yamada <yamada.masahiro at socionext.com>
Cc: Simon Goldschmidt <simon.k.r.goldschmidt at gmail.com>
---
V2: - Make resets into local variable
    - Update patch description
---
 drivers/mtd/nand/raw/denali.h    |  2 --
 drivers/mtd/nand/raw/denali_dt.c | 15 ++++-----------
 2 files changed, 4 insertions(+), 13 deletions(-)

Comments

Masahiro Yamada Jan. 26, 2020, 2:01 p.m. UTC | #1
On Wed, Jan 22, 2020 at 4:03 AM Marek Vasut <marex at denx.de> wrote:
>
> The register values programmed into the Denali NAND IP are not preserved
> when the IP reset signal is asserted. Depending on whether the Denali NAND
> IP implementation uses HW-assisted bootstrap or not, some of the register
> values are restored automatically after the IP is released from reset.
>
> If HW-assisted bootstrap is used, only RB_PIN_ENABLED, CHIP_ENABLE_DONT_CARE,
> SPARE_AREA_SKIP_BYTES and SPARE_AREA_MARKER need to be restored after reset,
> this is the case on Altera SoCFPGA. Otherwise, many more registers must be
> restored. Since mainline Linux currently does not handle this correctly, do
> not reset the Denali NAND IP before booting Linux. This permits Linux to use
> the register values retained in the Denali NAND IP and thus correctly access
> the NAND.
>
> Fixes: ed784ac3822b ("mtd: rawnand: denali: add reset handling")
> Signed-off-by: Marek Vasut <marex at denx.de>
> Cc: Masahiro Yamada <yamada.masahiro at socionext.com>
> Cc: Simon Goldschmidt <simon.k.r.goldschmidt at gmail.com>
> ---



I talked to Marek off-list, and he acked me
to reword the commit log like follows when applied.

------------------>8------------------
commit 9a230b0072504511454912a9e301f0beabc270c6 (HEAD -> uniphier,
origin/uniphier)
Author: Marek Vasut <marex at denx.de>
Date:   Tue Jan 21 20:03:11 2020 +0100

    mtd: rawnand: denali: Do not reset the block before booting the kernel

    The Denali NAND driver in mainline Linux currently cannot deassert the
    reset. The upcoming Linux 5.6 will support the reset controlling, and
    also set up SPARE_AREA_SKIP_BYTES correctly. So, the Denali driver in
    the future kernel will work without relying on any bootloader or firmware.
    However, we still need to take care of stable kernel versions for a while.
    U-boot should not assert the reset of this controller.

    Fixes: ed784ac3822b ("mtd: rawnand: denali: add reset handling")
    Signed-off-by: Marek Vasut <marex at denx.de>
    [yamada.masahiro: reword the commit description]
    Signed-off-by: Masahiro Yamada <yamada.masahiro at socionext.com>

------------------>8------------------

Applied to u-boot-uniphier.
Thanks.




> V2: - Make resets into local variable
>     - Update patch description
> ---
>  drivers/mtd/nand/raw/denali.h    |  2 --
>  drivers/mtd/nand/raw/denali_dt.c | 15 ++++-----------
>  2 files changed, 4 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/mtd/nand/raw/denali.h b/drivers/mtd/nand/raw/denali.h
> index 63ae828768..019deda094 100644
> --- a/drivers/mtd/nand/raw/denali.h
> +++ b/drivers/mtd/nand/raw/denali.h
> @@ -10,7 +10,6 @@
>  #include <linux/bitops.h>
>  #include <linux/mtd/rawnand.h>
>  #include <linux/types.h>
> -#include <reset.h>
>
>  #define DEVICE_RESET                           0x0
>  #define     DEVICE_RESET__BANK(bank)                   BIT(bank)
> @@ -316,7 +315,6 @@ struct denali_nand_info {
>         void (*host_write)(struct denali_nand_info *denali, u32 addr, u32 data);
>         void (*setup_dma)(struct denali_nand_info *denali, dma_addr_t dma_addr,
>                           int page, int write);
> -       struct reset_ctl_bulk resets;
>  };
>
>  #define DENALI_CAP_HW_ECC_FIXUP                        BIT(0)
> diff --git a/drivers/mtd/nand/raw/denali_dt.c b/drivers/mtd/nand/raw/denali_dt.c
> index b1e14982c4..91d0f20aae 100644
> --- a/drivers/mtd/nand/raw/denali_dt.c
> +++ b/drivers/mtd/nand/raw/denali_dt.c
> @@ -9,6 +9,7 @@
>  #include <linux/io.h>
>  #include <linux/ioport.h>
>  #include <linux/printk.h>
> +#include <reset.h>
>
>  #include "denali.h"
>
> @@ -63,6 +64,7 @@ static int denali_dt_probe(struct udevice *dev)
>         struct denali_nand_info *denali = dev_get_priv(dev);
>         const struct denali_dt_data *data;
>         struct clk clk, clk_x, clk_ecc;
> +       struct reset_ctl_bulk resets;
>         struct resource res;
>         int ret;
>
> @@ -133,30 +135,21 @@ static int denali_dt_probe(struct udevice *dev)
>                 denali->clk_x_rate = 200000000;
>         }
>
> -       ret = reset_get_bulk(dev, &denali->resets);
> +       ret = reset_get_bulk(dev, &resets);
>         if (ret)
>                 dev_warn(dev, "Can't get reset: %d\n", ret);
>         else
> -               reset_deassert_bulk(&denali->resets);
> +               reset_deassert_bulk(&resets);
>
>         return denali_init(denali);
>  }
>
> -static int denali_dt_remove(struct udevice *dev)
> -{
> -       struct denali_nand_info *denali = dev_get_priv(dev);
> -
> -       return reset_release_bulk(&denali->resets);
> -}
> -
>  U_BOOT_DRIVER(denali_nand_dt) = {
>         .name = "denali-nand-dt",
>         .id = UCLASS_MISC,
>         .of_match = denali_nand_dt_ids,
>         .probe = denali_dt_probe,
>         .priv_auto_alloc_size = sizeof(struct denali_nand_info),
> -       .remove = denali_dt_remove,
> -       .flags = DM_FLAG_OS_PREPARE,
>  };
>
>  void board_nand_init(void)
> --
> 2.24.1
>


--
Best Regards
Masahiro Yamada
diff mbox series

Patch

diff --git a/drivers/mtd/nand/raw/denali.h b/drivers/mtd/nand/raw/denali.h
index 63ae828768..019deda094 100644
--- a/drivers/mtd/nand/raw/denali.h
+++ b/drivers/mtd/nand/raw/denali.h
@@ -10,7 +10,6 @@ 
 #include <linux/bitops.h>
 #include <linux/mtd/rawnand.h>
 #include <linux/types.h>
-#include <reset.h>
 
 #define DEVICE_RESET				0x0
 #define     DEVICE_RESET__BANK(bank)			BIT(bank)
@@ -316,7 +315,6 @@  struct denali_nand_info {
 	void (*host_write)(struct denali_nand_info *denali, u32 addr, u32 data);
 	void (*setup_dma)(struct denali_nand_info *denali, dma_addr_t dma_addr,
 			  int page, int write);
-	struct reset_ctl_bulk resets;
 };
 
 #define DENALI_CAP_HW_ECC_FIXUP			BIT(0)
diff --git a/drivers/mtd/nand/raw/denali_dt.c b/drivers/mtd/nand/raw/denali_dt.c
index b1e14982c4..91d0f20aae 100644
--- a/drivers/mtd/nand/raw/denali_dt.c
+++ b/drivers/mtd/nand/raw/denali_dt.c
@@ -9,6 +9,7 @@ 
 #include <linux/io.h>
 #include <linux/ioport.h>
 #include <linux/printk.h>
+#include <reset.h>
 
 #include "denali.h"
 
@@ -63,6 +64,7 @@  static int denali_dt_probe(struct udevice *dev)
 	struct denali_nand_info *denali = dev_get_priv(dev);
 	const struct denali_dt_data *data;
 	struct clk clk, clk_x, clk_ecc;
+	struct reset_ctl_bulk resets;
 	struct resource res;
 	int ret;
 
@@ -133,30 +135,21 @@  static int denali_dt_probe(struct udevice *dev)
 		denali->clk_x_rate = 200000000;
 	}
 
-	ret = reset_get_bulk(dev, &denali->resets);
+	ret = reset_get_bulk(dev, &resets);
 	if (ret)
 		dev_warn(dev, "Can't get reset: %d\n", ret);
 	else
-		reset_deassert_bulk(&denali->resets);
+		reset_deassert_bulk(&resets);
 
 	return denali_init(denali);
 }
 
-static int denali_dt_remove(struct udevice *dev)
-{
-	struct denali_nand_info *denali = dev_get_priv(dev);
-
-	return reset_release_bulk(&denali->resets);
-}
-
 U_BOOT_DRIVER(denali_nand_dt) = {
 	.name = "denali-nand-dt",
 	.id = UCLASS_MISC,
 	.of_match = denali_nand_dt_ids,
 	.probe = denali_dt_probe,
 	.priv_auto_alloc_size = sizeof(struct denali_nand_info),
-	.remove = denali_dt_remove,
-	.flags = DM_FLAG_OS_PREPARE,
 };
 
 void board_nand_init(void)