[PATCH 09/19] drivers: mtd: nand: cadence: Support cmd SET_FEATURES & GET_FEATURES

dinesh.maniyam at intel.com dinesh.maniyam at intel.com
Thu Sep 19 05:55:02 CEST 2024


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

This patch is to support NAND_CMD_SET_FEATURES & NAND_CMD_GET_FEATURES.
These commands is one of the basic commands of NAND. Params get from
these commands will be used to set timing mode of NAND data interface.

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

diff --git a/drivers/mtd/nand/raw/cadence_nand.c b/drivers/mtd/nand/raw/cadence_nand.c
index 1b1335af68..108e1fa965 100644
--- a/drivers/mtd/nand/raw/cadence_nand.c
+++ b/drivers/mtd/nand/raw/cadence_nand.c
@@ -1982,6 +1982,29 @@ static int cadence_nand_reset(struct mtd_info *mtd, unsigned int command)
 	return 0;
 }
 
+static int cadence_nand_features(struct mtd_info *mtd, u8 offset_in_page, u32 command)
+{
+	struct cadence_nand_info *cadence = mtd_to_cadence(mtd);
+	int ret = 0;
+
+	ret = cadence_nand_cmd_opcode(cadence, command);
+	if (ret)
+		return ret;
+
+	ret = cadence_nand_cmd_address(cadence, ONE_CYCLE, &offset_in_page);
+	if (ret)
+		return ret;
+
+	if (command == NAND_CMD_GET_FEATURES)
+		ret = cadence_nand_cmd_data(cadence, ONFI_SUBFEATURE_PARAM_LEN,
+					    GCMD_DIR_READ);
+	else
+		ret = cadence_nand_cmd_data(cadence, ONFI_SUBFEATURE_PARAM_LEN,
+					    GCMD_DIR_WRITE);
+
+	return ret;
+}
+
 static void cadence_nand_cmdfunc(struct mtd_info *mtd, unsigned int command,
 				 int offset_in_page, int page)
 {
@@ -2006,6 +2029,11 @@ static void cadence_nand_cmdfunc(struct mtd_info *mtd, unsigned int command,
 	case NAND_CMD_RESET:
 		ret = cadence_nand_reset(mtd, command);
 		break;
+
+	case NAND_CMD_SET_FEATURES:
+	case NAND_CMD_GET_FEATURES:
+		ret = cadence_nand_features(mtd, offset_in_page, command);
+		break;
 	/*
 	 * ecc will override other command for read, write and erase
 	 */
@@ -2046,6 +2074,8 @@ static u8 cadence_nand_read_byte(struct mtd_info *mtd)
 			size = 8;
 		else if (cadence->cmd == NAND_CMD_PARAM)
 			size = sizeof(struct nand_jedec_params);
+		else if (cadence->cmd == NAND_CMD_GET_FEATURES)
+			size = ONFI_SUBFEATURE_PARAM_LEN;
 
 		cadence_nand_read_buf(mtd, &cadence->buf[0], size);
 	}
-- 
2.26.2



More information about the U-Boot mailing list