Skip to content

Commit 68cce21

Browse files
David Reganmiquelraynal
authored andcommitted
mtd: rawnand: NAND controller write protect
Allow NAND controller to be responsible for write protect pin handling during fast path and exec_op destructive operation when controller_wp flag is set. Signed-off-by: David Regan <dregan@broadcom.com> Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Link: https://lore.kernel.org/linux-mtd/20231125012438.15191-2-dregan@broadcom.com
1 parent 578dc96 commit 68cce21

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

drivers/mtd/nand/raw/nand_base.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,10 @@ static int nand_check_wp(struct nand_chip *chip)
366366
if (chip->options & NAND_BROKEN_XD)
367367
return 0;
368368

369+
/* controller responsible for NAND write protect */
370+
if (chip->controller->controller_wp)
371+
return 0;
372+
369373
/* Check the WP bit */
370374
ret = nand_status_op(chip, &status);
371375
if (ret)

include/linux/mtd/rawnand.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,6 +1115,7 @@ struct nand_controller_ops {
11151115
* the bus without restarting an entire read operation nor
11161116
* changing the column.
11171117
* @supported_op.cont_read: The controller supports sequential cache reads.
1118+
* @controller_wp: the controller is in charge of handling the WP pin.
11181119
*/
11191120
struct nand_controller {
11201121
struct mutex lock;
@@ -1123,6 +1124,7 @@ struct nand_controller {
11231124
unsigned int data_only_read: 1;
11241125
unsigned int cont_read: 1;
11251126
} supported_op;
1127+
bool controller_wp;
11261128
};
11271129

11281130
static inline void nand_controller_init(struct nand_controller *nfc)

0 commit comments

Comments
 (0)