diff mbox series

[08/19] drivers: mtd: nand: cadence: Support NAND_CMD_RESET

Message ID 20240919035512.13854-9-dinesh.maniyam@intel.com
State New
Delegated to: Dario Binacchi
Headers show
Series Add Cadence NAND Driver support | expand

Commit Message

Maniyam, Dinesh Sept. 19, 2024, 3:55 a.m. UTC
From: Dinesh Maniyam <dinesh.maniyam@intel.com>

The patch is to support nand reset command for Cadence Nand Driver.

Signed-off-by: Dinesh Maniyam <dinesh.maniyam@intel.com>
---
 drivers/mtd/nand/raw/cadence_nand.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
diff mbox series

Patch

diff --git a/drivers/mtd/nand/raw/cadence_nand.c b/drivers/mtd/nand/raw/cadence_nand.c
index 1b5cda1955..1b1335af68 100644
--- a/drivers/mtd/nand/raw/cadence_nand.c
+++ b/drivers/mtd/nand/raw/cadence_nand.c
@@ -1965,10 +1965,28 @@  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 cadence_nand_info *cadence = mtd_to_cadence(mtd);
+	struct nand_chip *chip = mtd_to_nand(mtd);
+	int ret = 0;
+
+	ret = cadence_nand_cmd_opcode(cadence, 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)
 {
 	struct cadence_nand_info *cadence = mtd_to_cadence(mtd);
+	struct nand_chip *chip = mtd_to_nand(mtd);
 	int ret = 0;
 
 	cadence->cmd = command;
@@ -1984,6 +2002,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
 	 */
@@ -1991,6 +2013,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(cadence, 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);
 }