From: "Pali Rohár" <pali@kernel.org>
To: Priyanka Jain <priyanka.jain@nxp.com>, Wolfgang Denk <wd@denx.de>
Cc: Michal Simek <michal.simek@xilinx.com>,
Simon Glass <sjg@chromium.org>,
u-boot@lists.denx.de
Subject: [PATCH 2/5] mtd: rawnand: fsl_elbc: Add device tree support
Date: Mon, 4 Apr 2022 18:17:19 +0200 [thread overview]
Message-ID: <20220404161722.4884-3-pali@kernel.org> (raw)
In-Reply-To: <20220404161722.4884-1-pali@kernel.org>
This allows boards to specify NAND settings via standard DT properties.
Signed-off-by: Pali Rohár <pali@kernel.org>
---
drivers/mtd/nand/raw/Kconfig | 4 +++
drivers/mtd/nand/raw/fsl_elbc_nand.c | 42 ++++++++++++++++++++++++++--
2 files changed, 44 insertions(+), 2 deletions(-)
diff --git a/drivers/mtd/nand/raw/Kconfig b/drivers/mtd/nand/raw/Kconfig
index 0e826c192986..fb71a759591b 100644
--- a/drivers/mtd/nand/raw/Kconfig
+++ b/drivers/mtd/nand/raw/Kconfig
@@ -152,6 +152,10 @@ config NAND_FSL_ELBC
help
Enable the Freescale Enhanced Local Bus Controller FCM NAND driver.
+config NAND_FSL_ELBC_DT
+ bool "Support Freescale Enhanced Local Bus Controller FCM NAND driver (DT mode)"
+ depends on NAND_FSL_ELBC
+
config NAND_FSL_IFC
bool "Support Freescale Integrated Flash Controller NAND driver"
select TPL_SYS_NAND_SELF_INIT if TPL_NAND_SUPPORT
diff --git a/drivers/mtd/nand/raw/fsl_elbc_nand.c b/drivers/mtd/nand/raw/fsl_elbc_nand.c
index f8698ec0158a..f8d2bdfb1309 100644
--- a/drivers/mtd/nand/raw/fsl_elbc_nand.c
+++ b/drivers/mtd/nand/raw/fsl_elbc_nand.c
@@ -20,6 +20,10 @@
#include <asm/io.h>
#include <linux/errno.h>
+#ifdef CONFIG_NAND_FSL_ELBC_DT
+#include <dm/read.h>
+#endif
+
#ifdef VERBOSE_DEBUG
#define DEBUG_ELBC
#define vdbg(format, arg...) printf("DEBUG: " format, ##arg)
@@ -664,7 +668,7 @@ static void fsl_elbc_ctrl_init(void)
elbc_ctrl->addr = NULL;
}
-static int fsl_elbc_chip_init(int devnum, u8 *addr)
+static int fsl_elbc_chip_init(int devnum, u8 *addr, ofnode flash_node)
{
struct mtd_info *mtd;
struct nand_chip *nand;
@@ -712,6 +716,8 @@ static int fsl_elbc_chip_init(int devnum, u8 *addr)
elbc_ctrl->chips[priv->bank] = priv;
/* fill in nand_chip structure */
+ nand->flash_node = flash_node;
+
/* set up function call table */
nand->read_byte = fsl_elbc_read_byte;
nand->write_buf = fsl_elbc_write_buf;
@@ -804,6 +810,8 @@ static int fsl_elbc_chip_init(int devnum, u8 *addr)
return 0;
}
+#ifndef CONFIG_NAND_FSL_ELBC_DT
+
#ifndef CONFIG_SYS_NAND_BASE_LIST
#define CONFIG_SYS_NAND_BASE_LIST { CONFIG_SYS_NAND_BASE }
#endif
@@ -816,5 +824,35 @@ void board_nand_init(void)
int i;
for (i = 0; i < CONFIG_SYS_MAX_NAND_DEVICE; i++)
- fsl_elbc_chip_init(i, (u8 *)base_address[i]);
+ fsl_elbc_chip_init(i, (u8 *)base_address[i], ofnode_null());
+}
+
+#else
+
+static int fsl_elbc_nand_probe(struct udevice *dev)
+{
+ return fsl_elbc_chip_init(0, (void *)dev_read_addr(dev), dev_ofnode(dev));
+}
+
+static const struct udevice_id fsl_elbc_nand_dt_ids[] = {
+ { .compatible = "fsl,elbc-fcm-nand", },
+ {}
+};
+
+U_BOOT_DRIVER(fsl_elbc_nand) = {
+ .name = "fsl_elbc_nand",
+ .id = UCLASS_MTD,
+ .of_match = fsl_elbc_nand_dt_ids,
+ .probe = fsl_elbc_nand_probe,
+};
+
+void board_nand_init(void)
+{
+ struct udevice *dev;
+ int ret;
+
+ ret = uclass_get_device_by_driver(UCLASS_MTD, DM_DRIVER_GET(fsl_elbc_nand), &dev);
+ if (ret && ret != -ENODEV)
+ printf("Failed to initialize fsl_elbc_nand NAND controller. (error %d)\n", ret);
}
+#endif
--
2.20.1
next prev parent reply other threads:[~2022-04-04 16:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-04 16:17 [PATCH 0/5] mtd: rawnand: fsl_elbc: Device tree support Pali Rohár
2022-04-04 16:17 ` [PATCH 1/5] mtd: rawnand: fsl_elbc: Implement RNDOUT command Pali Rohár
2022-04-04 16:17 ` Pali Rohár [this message]
2022-04-04 16:17 ` [PATCH 3/5] mtd: rawnand: fsl_elbc: Use ECC configuration from device tree Pali Rohár
2022-04-04 16:17 ` [PATCH 4/5] mtd: nand: raw: Add support for DT property nand-ecc-algo=bch Pali Rohár
2022-04-04 16:17 ` [PATCH 5/5] powerpc: dts: p2020: Add localbus node Pali Rohár
2022-04-05 9:15 ` [PATCH v2] " Pali Rohár
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220404161722.4884-3-pali@kernel.org \
--to=pali@kernel.org \
--cc=michal.simek@xilinx.com \
--cc=priyanka.jain@nxp.com \
--cc=sjg@chromium.org \
--cc=u-boot@lists.denx.de \
--cc=wd@denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox