diff mbox series

[U-Boot,RESEND] mtd: nand: zynq: Add support for the NAND lock/unlock operation

Message ID 1510020970-11282-1-git-send-email-wilson.lee@ni.com
State Accepted
Delegated to: Michal Simek
Headers show
Series [U-Boot,RESEND] mtd: nand: zynq: Add support for the NAND lock/unlock operation | expand

Commit Message

Wilson Lee Nov. 7, 2017, 2:16 a.m. UTC
From: Joe Hershberger <joe.hershberger@ni.com>

Zynq NAND driver is not support for NAND lock or unlock operation.
Hence, accidentally write into the critical NAND region might cause
data corruption to occur.

This commit is to add NAND lock/unlock command into NAND SMC register
set for NAND lock/unlock operaion.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Signed-off-by: Keng Soon Cheah <keng.soon.cheah@ni.com>
Cc: Chen Yee Chew <chen.yee.chew@ni.com>
Cc: Siva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>
Cc: Michal Simek <michal.simek@xilinx.com>
Cc: Scott Wood <oss@buserror.net>
---
 drivers/mtd/nand/zynq_nand.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Michal Simek Nov. 16, 2017, 3:33 p.m. UTC | #1
On 7.11.2017 03:16, Wilson Lee wrote:
> From: Joe Hershberger <joe.hershberger@ni.com>
> 
> Zynq NAND driver is not support for NAND lock or unlock operation.
> Hence, accidentally write into the critical NAND region might cause
> data corruption to occur.
> 
> This commit is to add NAND lock/unlock command into NAND SMC register
> set for NAND lock/unlock operaion.
> 
> Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
> Signed-off-by: Keng Soon Cheah <keng.soon.cheah@ni.com>
> Cc: Chen Yee Chew <chen.yee.chew@ni.com>
> Cc: Siva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>
> Cc: Michal Simek <michal.simek@xilinx.com>
> Cc: Scott Wood <oss@buserror.net>
> ---
>  drivers/mtd/nand/zynq_nand.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)

Applied.

Thanks,
Michal
diff mbox series

Patch

diff --git a/drivers/mtd/nand/zynq_nand.c b/drivers/mtd/nand/zynq_nand.c
index 948f059..484f1bb 100644
--- a/drivers/mtd/nand/zynq_nand.c
+++ b/drivers/mtd/nand/zynq_nand.c
@@ -81,6 +81,13 @@ 
 #define ZYNQ_NAND_ECC_BUSY	(1 << 6)	/* ECC block is busy */
 #define ZYNQ_NAND_ECC_MASK	0x00FFFFFF	/* ECC value mask */
 
+#ifndef NAND_CMD_LOCK_TIGHT
+#define NAND_CMD_LOCK_TIGHT 0x2c
+#endif
+
+#ifndef NAND_CMD_LOCK_STATUS
+#define NAND_CMD_LOCK_STATUS 0x7a
+#endif
 
 /* SMC register set */
 struct zynq_nand_smc_regs {
@@ -141,6 +148,11 @@  static const struct zynq_nand_command_format zynq_nand_commands[] = {
 	{NAND_CMD_PARAM, NAND_CMD_NONE, 1, 0},
 	{NAND_CMD_GET_FEATURES, NAND_CMD_NONE, 1, 0},
 	{NAND_CMD_SET_FEATURES, NAND_CMD_NONE, 1, 0},
+	{NAND_CMD_LOCK, NAND_CMD_NONE, 0, 0},
+	{NAND_CMD_LOCK_TIGHT, NAND_CMD_NONE, 0, 0},
+	{NAND_CMD_UNLOCK1, NAND_CMD_NONE, 3, 0},
+	{NAND_CMD_UNLOCK2, NAND_CMD_NONE, 3, 0},
+	{NAND_CMD_LOCK_STATUS, NAND_CMD_NONE, 3, 0},
 	{NAND_CMD_NONE, NAND_CMD_NONE, 0, 0},
 	/* Add all the flash commands supported by the flash device */
 };