[resend v2 08/19] drivers: mtd: nand: cadence: Add support for NAND_CMD_RESET

dinesh.maniyam at intel.com dinesh.maniyam at intel.com
Thu Dec 5 10:23:04 CET 2024


From: Dinesh Maniyam <dinesh.maniyam at intel.com>

Support nand reset command for Cadence Nand Driver.

Signed-off-by: Dinesh Maniyam <dinesh.maniyam at intel.com>

---
v2:
- remove the "this patch is to" commit phrases
---
---
 drivers/mtd/nand/raw/cadence_nand.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/drivers/mtd/nand/raw/cadence_nand.c b/drivers/mtd/nand/raw/cadence_nand.c
index 0775a8a0ce..74926560ad 100644
--- a/drivers/mtd/nand/raw/cadence_nand.c
+++ b/drivers/mtd/nand/raw/cadence_nand.c
@@ -1994,6 +1994,22 @@ static int cadence_nand_param(struct mtd_info *mtd, u8 offset_in_page, unsigned
 	return 0;
 }
 
+static int cadence_nand_reset(struct mtd_info *mtd, unsigned int command)
+{
+	struct nand_chip *chip = mtd_to_nand(mtd);
+	int ret = 0;
+
+	ret = cadence_nand_cmd_opcode(chip, command);
+	if (ret)
+		return ret;
+
+	ret = cadence_nand_waitfunc(mtd, chip);
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
 static void cadence_nand_cmdfunc(struct mtd_info *mtd, unsigned int command,
 				 int offset_in_page, int page)
 {
@@ -2014,6 +2030,10 @@ static void cadence_nand_cmdfunc(struct mtd_info *mtd, unsigned int command,
 	case NAND_CMD_PARAM:
 		ret = cadence_nand_param(mtd, offset_in_page, command);
 		break;
+
+	case NAND_CMD_RESET:
+		ret = cadence_nand_reset(mtd, command);
+		break;
 	/*
 	 * ecc will override other command for read, write and erase
 	 */
@@ -2021,6 +2041,12 @@ static void cadence_nand_cmdfunc(struct mtd_info *mtd, unsigned int command,
 		break;
 	}
 
+	if (cadence->cmd == NAND_CMD_RESET) {
+		ret = cadence_nand_select_target(chip);
+		if (ret)
+			dev_err(cadence->dev, "Chip select failure after reset\n");
+	}
+
 	if (ret != 0)
 		printf("ERROR:%s:command:0x%x\n", __func__, cadence->cmd);
 }
-- 
2.19.0



More information about the U-Boot mailing list