Skip to content

Commit 578dc96

Browse files
bbrezillonmiquelraynal
authored andcommitted
mtd: rawnand: Add destructive operation
Erase and program operations need the write protect (wp) pin to be de-asserted to take effect. Add the concept of destructive operation and pass the information to exec_op() so controllers know when they should de-assert this pin without having to decode the command opcode. Signed-off-by: Boris Brezillon <bbrezillon@kernel.org> 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-1-dregan@broadcom.com
1 parent 2082b69 commit 578dc96

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

drivers/mtd/nand/raw/nand_base.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1493,7 +1493,8 @@ static int nand_exec_prog_page_op(struct nand_chip *chip, unsigned int page,
14931493
NAND_COMMON_TIMING_NS(conf, tWB_max)),
14941494
NAND_OP_WAIT_RDY(NAND_COMMON_TIMING_MS(conf, tPROG_max), 0),
14951495
};
1496-
struct nand_operation op = NAND_OPERATION(chip->cur_cs, instrs);
1496+
struct nand_operation op = NAND_DESTRUCTIVE_OPERATION(chip->cur_cs,
1497+
instrs);
14971498
int naddrs = nand_fill_column_cycles(chip, addrs, offset_in_page);
14981499

14991500
if (naddrs < 0)
@@ -1916,7 +1917,8 @@ int nand_erase_op(struct nand_chip *chip, unsigned int eraseblock)
19161917
NAND_OP_WAIT_RDY(NAND_COMMON_TIMING_MS(conf, tBERS_max),
19171918
0),
19181919
};
1919-
struct nand_operation op = NAND_OPERATION(chip->cur_cs, instrs);
1920+
struct nand_operation op = NAND_DESTRUCTIVE_OPERATION(chip->cur_cs,
1921+
instrs);
19201922

19211923
if (chip->options & NAND_ROW_ADDR_3)
19221924
instrs[1].ctx.addr.naddrs++;

include/linux/mtd/rawnand.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,13 +1003,16 @@ struct nand_op_parser {
10031003
/**
10041004
* struct nand_operation - NAND operation descriptor
10051005
* @cs: the CS line to select for this NAND operation
1006+
* @deassert_wp: set to true when the operation requires the WP pin to be
1007+
* de-asserted (ERASE, PROG, ...)
10061008
* @instrs: array of instructions to execute
10071009
* @ninstrs: length of the @instrs array
10081010
*
10091011
* The actual operation structure that will be passed to chip->exec_op().
10101012
*/
10111013
struct nand_operation {
10121014
unsigned int cs;
1015+
bool deassert_wp;
10131016
const struct nand_op_instr *instrs;
10141017
unsigned int ninstrs;
10151018
};
@@ -1021,6 +1024,14 @@ struct nand_operation {
10211024
.ninstrs = ARRAY_SIZE(_instrs), \
10221025
}
10231026

1027+
#define NAND_DESTRUCTIVE_OPERATION(_cs, _instrs) \
1028+
{ \
1029+
.cs = _cs, \
1030+
.deassert_wp = true, \
1031+
.instrs = _instrs, \
1032+
.ninstrs = ARRAY_SIZE(_instrs), \
1033+
}
1034+
10241035
int nand_op_parser_exec_op(struct nand_chip *chip,
10251036
const struct nand_op_parser *parser,
10261037
const struct nand_operation *op, bool check_only);

0 commit comments

Comments
 (0)