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

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


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

Support NAND_CMD_SET_FEATURES & NAND_CMD_GET_FEATURES.
These commands is one of the basic commands of NAND. The parameters 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>

---
v2:
- remove the "this patch is to" commit phrases
---
---
 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 74926560ad..895ee77320 100644
--- a/drivers/mtd/nand/raw/cadence_nand.c
+++ b/drivers/mtd/nand/raw/cadence_nand.c
@@ -2010,6 +2010,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 nand_chip *chip = mtd_to_nand(mtd);
+	int ret = 0;
+
+	ret = cadence_nand_cmd_opcode(chip, command);
+	if (ret)
+		return ret;
+
+	ret = cadence_nand_cmd_address(chip, ONE_CYCLE, &offset_in_page);
+	if (ret)
+		return ret;
+
+	if (command == NAND_CMD_GET_FEATURES)
+		ret = cadence_nand_cmd_data(chip, ONFI_SUBFEATURE_PARAM_LEN,
+					    GCMD_DIR_READ);
+	else
+		ret = cadence_nand_cmd_data(chip, 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)
 {
@@ -2034,6 +2057,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
 	 */
@@ -2076,6 +2104,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.19.0



More information about the U-Boot mailing list