mtd: nand: Add function to convert ONFI mode to data_interface

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Sat Oct 8 21:59:04 PDT 2016


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=b88730ada99bfe243862add360720a3550b0edbf
Commit:     b88730ada99bfe243862add360720a3550b0edbf
Parent:     b1dd3ca203fccd111926c3f6ac59bf903ec62b05
Author:     Sascha Hauer <s.hauer at pengutronix.de>
AuthorDate: Thu Sep 15 10:32:48 2016 +0200
Committer:  Boris Brezillon <boris.brezillon at free-electrons.com>
CommitDate: Fri Sep 23 09:35:16 2016 +0200

    mtd: nand: Add function to convert ONFI mode to data_interface
    
    onfi_init_data_interface() initializes a data interface with
    values from a given ONFI mode.
    
    Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
    Signed-off-by: Boris Brezillon <boris.brezillon at free-electrons.com>
---
 drivers/mtd/nand/nand_timings.c | 29 +++++++++++++++++++++++++++++
 include/linux/mtd/nand.h        |  5 +++++
 2 files changed, 34 insertions(+)

diff --git a/drivers/mtd/nand/nand_timings.c b/drivers/mtd/nand/nand_timings.c
index 878fe0d..7441d68 100644
--- a/drivers/mtd/nand/nand_timings.c
+++ b/drivers/mtd/nand/nand_timings.c
@@ -269,3 +269,32 @@ const struct nand_sdr_timings *onfi_async_timing_mode_to_sdr_timings(int mode)
 	return &onfi_sdr_timings[mode].timings.sdr;
 }
 EXPORT_SYMBOL(onfi_async_timing_mode_to_sdr_timings);
+
+/**
+ * onfi_init_data_interface - [NAND Interface] Initialize a data interface from
+ * given ONFI mode
+ * @iface: The data interface to be initialized
+ * @mode: The ONFI timing mode
+ */
+int onfi_init_data_interface(struct nand_chip *chip,
+			     struct nand_data_interface *iface,
+			     enum nand_data_interface_type type,
+			     int timing_mode)
+{
+	if (type != NAND_SDR_IFACE)
+		return -EINVAL;
+
+	if (timing_mode < 0 || timing_mode >= ARRAY_SIZE(onfi_sdr_timings))
+		return -EINVAL;
+
+	*iface = onfi_sdr_timings[timing_mode];
+
+	/*
+	 * TODO: initialize timings that cannot be deduced from timing mode:
+	 * tR, tPROG, tCCS, ...
+	 * These information are part of the ONFI parameter page.
+	 */
+
+	return 0;
+}
+EXPORT_SYMBOL(onfi_init_data_interface);
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index a625e96..1f34c04 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -1112,6 +1112,11 @@ static inline int onfi_get_sync_timing_mode(struct nand_chip *chip)
 	return le16_to_cpu(chip->onfi_params.src_sync_timing_mode);
 }
 
+int onfi_init_data_interface(struct nand_chip *chip,
+			     struct nand_data_interface *iface,
+			     enum nand_data_interface_type type,
+			     int timing_mode);
+
 /*
  * Check if it is a SLC nand.
  * The !nand_is_slc() can be used to check the MLC/TLC nand chips.



More information about the linux-mtd-cvs mailing list