Skip to content

Commit 511d05e

Browse files
Boris Brezillonmiquelraynal
authored andcommitted
mtd: rawnand: sunxi: Handle the tREA > tRC / 2 case
In non-EDO, tREA should be less than tRP to guarantee that the controller does not sample the IO lines too early. Unfortunately, the sunxi NAND controller does not allow us to have different values for tRP and tREH (tRP = tREH = tRW / 2). We have 2 options to overcome this limitation: 1/ Extend tRC to fulfil the tREA <= tRC / 2 constraint 2/ Use EDO mode (only works if timings->tRLOH > 0) Signed-off-by: Boris Brezillon <[email protected]> Signed-off-by: Miquel Raynal <[email protected]>
1 parent f4cb4d7 commit 511d05e

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

drivers/mtd/nand/raw/sunxi_nand.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,6 +1442,20 @@ static int sunxi_nfc_setup_data_interface(struct nand_chip *nand, int csline,
14421442
if (timings->tRHW_min > (min_clk_period * 20))
14431443
min_clk_period = DIV_ROUND_UP(timings->tRHW_min, 20);
14441444

1445+
/*
1446+
* In non-EDO, tREA should be less than tRP to guarantee that the
1447+
* controller does not sample the IO lines too early. Unfortunately,
1448+
* the sunxi NAND controller does not allow us to have different
1449+
* values for tRP and tREH (tRP = tREH = tRW / 2).
1450+
*
1451+
* We have 2 options to overcome this limitation:
1452+
*
1453+
* 1/ Extend tRC to fulfil the tREA <= tRC / 2 constraint
1454+
* 2/ Use EDO mode (only works if timings->tRLOH > 0)
1455+
*/
1456+
if (timings->tREA_max > min_clk_period && !timings->tRLOH_min)
1457+
min_clk_period = timings->tREA_max;
1458+
14451459
tWB = sunxi_nand_lookup_timing(tWB_lut, timings->tWB_max,
14461460
min_clk_period);
14471461
if (tWB < 0) {
@@ -1497,14 +1511,16 @@ static int sunxi_nfc_setup_data_interface(struct nand_chip *nand, int csline,
14971511
return -EINVAL;
14981512
}
14991513

1514+
sunxi_nand->timing_ctl = 0;
1515+
15001516
/*
15011517
* ONFI specification 3.1, paragraph 4.15.2 dictates that EDO data
15021518
* output cycle timings shall be used if the host drives tRC less than
1503-
* 30 ns.
1519+
* 30 ns. We should also use EDO mode if tREA is bigger than tRP.
15041520
*/
15051521
min_clk_period = NSEC_PER_SEC / real_clk_rate;
1506-
sunxi_nand->timing_ctl = ((min_clk_period * 2) < 30) ?
1507-
NFC_TIMING_CTL_EDO : 0;
1522+
if (min_clk_period * 2 < 30 || min_clk_period * 1000 < timings->tREA_max)
1523+
sunxi_nand->timing_ctl = NFC_TIMING_CTL_EDO;
15081524

15091525
return 0;
15101526
}

0 commit comments

Comments
 (0)