[U-Boot] [PATCH v1 3/9] mtd: nand: mxs_nand: separate board/controller init
Stefan Agner
stefan at agner.ch
Fri Apr 20 15:53:08 UTC 2018
From: Stefan Agner <stefan.agner at toradex.com>
In preparation for device tree support separate board init
from controller init similar to other raw NAND drivers.
Signed-off-by: Stefan Agner <stefan.agner at toradex.com>
---
drivers/mtd/nand/mxs_nand.c | 33 ++++++++++++++++++++-------------
1 file changed, 20 insertions(+), 13 deletions(-)
diff --git a/drivers/mtd/nand/mxs_nand.c b/drivers/mtd/nand/mxs_nand.c
index 3f97da5e8f..b5fd0fdd62 100644
--- a/drivers/mtd/nand/mxs_nand.c
+++ b/drivers/mtd/nand/mxs_nand.c
@@ -1193,22 +1193,12 @@ err1:
return ret;
}
-void board_nand_init(void)
+int mxs_nand_init(struct mxs_nand_info *nand_info)
{
struct mtd_info *mtd;
- struct mxs_nand_info *nand_info;
struct nand_chip *nand;
int err;
- nand_info = malloc(sizeof(struct mxs_nand_info));
- if (!nand_info) {
- printf("MXS NAND: Failed to allocate private data\n");
- return;
- }
- memset(nand_info, 0, sizeof(struct mxs_nand_info));
-
- nand_info->gpmi_regs = (struct mxs_gpmi_regs *)MXS_GPMI_BASE;
- nand_info->bch_regs = (struct mxs_bch_regs *)MXS_BCH_BASE;
nand = &nand_info->chip;
mtd = nand_to_mtd(nand);
err = mxs_nand_alloc_buffers(nand_info);
@@ -1265,12 +1255,29 @@ void board_nand_init(void)
if (err)
goto err2;
- return;
+ return 0;
err2:
free(nand_info->data_buf);
free(nand_info->cmd_buf);
err1:
free(nand_info);
- return;
+ return err;
+}
+
+void board_nand_init(void)
+{
+ struct mxs_nand_info *nand_info;
+
+ nand_info = malloc(sizeof(struct mxs_nand_info));
+ if (!nand_info) {
+ printf("MXS NAND: Failed to allocate private data\n");
+ return;
+ }
+ memset(nand_info, 0, sizeof(struct mxs_nand_info));
+
+ nand_info->gpmi_regs = (struct mxs_gpmi_regs *)MXS_GPMI_BASE;
+ nand_info->bch_regs = (struct mxs_bch_regs *)MXS_BCH_BASE;
+
+ mxs_nand_init(nand_info);
}
--
2.17.0
More information about the U-Boot
mailing list