From 3588d40c5385e0487800764902dbaaa766699816 Mon Sep 17 00:00:00 2001 From: Uwe Kleine-König Date: Thu, 22 Oct 2020 14:25:22 +0200 Subject: mtd: nand-imx: repair reading the oob area MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After sending the READOOB command the core (in nand_read_oob_std()) uses the read_buf callback to fetch the result. So in the imx driver it is necessary to emit the NFC_OUTPUT command to make the controller actually read the requested data into the internal buffer and then copy the data to the location where read_buf expects it. This fixes reading from /dev/nand0.oob and also (somewhat) reading bad block markers in the absence of a bad block table. Signed-off-by: Uwe Kleine-König Tested-by: Sascha Hauer Signed-off-by: Sascha Hauer --- drivers/mtd/nand/nand_imx.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/mtd/nand/nand_imx.c b/drivers/mtd/nand/nand_imx.c index d69a012f01..f9d3c2e34a 100644 --- a/drivers/mtd/nand/nand_imx.c +++ b/drivers/mtd/nand/nand_imx.c @@ -996,14 +996,23 @@ static void imx_nand_command(struct mtd_info *mtd, unsigned command, else host->buf_start = column + mtd->writesize; - command = NAND_CMD_READ0; - - host->send_cmd(host, command); + host->send_cmd(host, NAND_CMD_READ0); mxc_do_addr_cycle(mtd, column, page_addr); if (host->pagesize_2k) /* send read confirm command */ host->send_cmd(host, NAND_CMD_READSTART); + + /* + * After the core issued READOOB the result is read using + * .read_buf, so we have to make sure the data is actually + * there. + */ + if (command == NAND_CMD_READOOB) { + host->send_page(host, NFC_OUTPUT); + copy_spare(mtd, 1, host->data_buf + mtd->writesize); + } + break; case NAND_CMD_SEQIN: -- cgit v1.2.3