mediatek: fix mtk parallel nand driver
[openwrt/openwrt.git] / target / linux / mediatek / patches-5.10 / 360-mtd-rawnand-mtk-Fix-WAITRDY-break-condition-and-time.patch
1 From 4a4854761c9dedeedbf72c25d1317ab2e7600d4f Mon Sep 17 00:00:00 2001
2 From: Hauke Mehrtens <hauke@hauke-m.de>
3 Date: Mon, 8 Mar 2021 23:16:17 +0100
4 Subject: [PATCH] mtd: rawnand: mtk: Fix WAITRDY break condition and timeout
5
6 This fixes NAND_OP_WAITRDY_INSTR operation in the driver. Without this
7 change the driver waits till the system is busy, but we should wait till
8 the busy flag is cleared. The readl_poll_timeout() function gets a break
9 condition, not a wait condition.
10
11 In addition fix the timeout. The timeout_ms is given in ms, but the
12 readl_poll_timeout() function takes the timeout in us. Multiple the
13 given timeout by 1000 to convert it.
14
15 Without this change, the driver does not work at all, it doesn't even
16 identify the NAND chip.
17
18 Fixes: 5197360f9e09 ("mtd: rawnand: mtk: Convert the driver to exec_op()")
19 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
20 ---
21 drivers/mtd/nand/raw/mtk_nand.c | 4 ++--
22 1 file changed, 2 insertions(+), 2 deletions(-)
23
24 --- a/drivers/mtd/nand/raw/mtk_nand.c
25 +++ b/drivers/mtd/nand/raw/mtk_nand.c
26 @@ -488,8 +488,8 @@ static int mtk_nfc_exec_instr(struct nan
27 return 0;
28 case NAND_OP_WAITRDY_INSTR:
29 return readl_poll_timeout(nfc->regs + NFI_STA, status,
30 - status & STA_BUSY, 20,
31 - instr->ctx.waitrdy.timeout_ms);
32 + !(status & STA_BUSY), 20,
33 + instr->ctx.waitrdy.timeout_ms * 1000);
34 default:
35 break;
36 }