public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH] mtd: nand: Add support to dedicated function to set timings
@ 2022-02-01 17:45 Kory Maincent
  2022-02-01 17:59 ` Miquel Raynal
  0 siblings, 1 reply; 2+ messages in thread
From: Kory Maincent @ 2022-02-01 17:45 UTC (permalink / raw)
  To: u-boot
  Cc: thomas.petazzoni, miquel.raynal, Simon Glass, Wolfgang Denk,
	Patrice Chotard, Marek Behún

With the current code if the board have a NAND ONFI compliant without
support to the get and set features, U-boot return an ENOTSUP error and we
can not talk to the memory. Indeed onfi_set_features return ENOTSUP error
if set/get features is not supported. In the case of timings we should not
return ENOTSUP because we can use the default timings, the modification of
the NAND timings is optional.

Fixed it by adding an intermediate nand_onfi_set_timings function which
does nothing if set/get feature is not supported.

Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
---
 drivers/mtd/nand/raw/nand_base.c | 30 +++++++++++++++++++-----------
 1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
index f7616985d9..44fb33776f 100644
--- a/drivers/mtd/nand/raw/nand_base.c
+++ b/drivers/mtd/nand/raw/nand_base.c
@@ -974,6 +974,22 @@ static int nand_reset_data_interface(struct nand_chip *chip, int chipnr)
 	return ret;
 }
 
+static int nand_onfi_set_timings(struct mtd_info *mtd, struct nand_chip *chip)
+{
+	if (!chip->onfi_version ||
+	    !(le16_to_cpu(chip->onfi_params.opt_cmd)
+	      & ONFI_OPT_CMD_SET_GET_FEATURES))
+		return 0;
+
+	u8 tmode_param[ONFI_SUBFEATURE_PARAM_LEN] = {
+		chip->onfi_timing_mode_default,
+	};
+
+	return chip->onfi_set_features(mtd, chip,
+				       ONFI_FEATURE_ADDR_TIMING_MODE,
+				       tmode_param);
+}
+
 /**
  * nand_setup_data_interface - Setup the best data interface and timings
  * @chip: The NAND chip
@@ -999,17 +1015,9 @@ static int nand_setup_data_interface(struct nand_chip *chip, int chipnr)
 	 * Ensure the timing mode has been changed on the chip side
 	 * before changing timings on the controller side.
 	 */
-	if (chip->onfi_version) {
-		u8 tmode_param[ONFI_SUBFEATURE_PARAM_LEN] = {
-			chip->onfi_timing_mode_default,
-		};
-
-		ret = chip->onfi_set_features(mtd, chip,
-				ONFI_FEATURE_ADDR_TIMING_MODE,
-				tmode_param);
-		if (ret)
-			goto err;
-	}
+	ret = nand_onfi_set_timings(mtd, chip);
+	if (ret)
+		goto err;
 
 	ret = chip->setup_data_interface(mtd, chipnr, chip->data_interface);
 err:
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-02-01 17:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-01 17:45 [PATCH] mtd: nand: Add support to dedicated function to set timings Kory Maincent
2022-02-01 17:59 ` Miquel Raynal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox