Skip to content

Commit 2d43457

Browse files
author
Boris Brezillon
committed
mtd: nand: sunxi: fix EDO mode selection
The ONFI spec says that EDO should be enabled if the host drives tRC less than 30ns, but the code just tests for the tRC_min value extracted from the timings exposed by the NAND chip not the timings actually configured in the NAND controller. Fix that by first rounding down the requested clk_rate with clk_round_rate() and then checking if tRC is actually smaller than 30ns. Signed-off-by: Boris Brezillon <[email protected]>
1 parent 2f9992e commit 2d43457

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

drivers/mtd/nand/sunxi_nand.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,6 +1100,7 @@ static int sunxi_nand_chip_set_timings(struct sunxi_nand_chip *chip,
11001100
struct sunxi_nfc *nfc = to_sunxi_nfc(chip->nand.controller);
11011101
u32 min_clk_period = 0;
11021102
s32 tWB, tADL, tWHR, tRHW, tCAD;
1103+
long real_clk_rate;
11031104

11041105
/* T1 <=> tCLS */
11051106
if (timings->tCLS_min > min_clk_period)
@@ -1197,13 +1198,6 @@ static int sunxi_nand_chip_set_timings(struct sunxi_nand_chip *chip,
11971198
/* TODO: A83 has some more bits for CDQSS, CS, CLHZ, CCS, WC */
11981199
chip->timing_cfg = NFC_TIMING_CFG(tWB, tADL, tWHR, tRHW, tCAD);
11991200

1200-
/*
1201-
* ONFI specification 3.1, paragraph 4.15.2 dictates that EDO data
1202-
* output cycle timings shall be used if the host drives tRC less than
1203-
* 30 ns.
1204-
*/
1205-
chip->timing_ctl = (timings->tRC_min < 30000) ? NFC_TIMING_CTL_EDO : 0;
1206-
12071201
/* Convert min_clk_period from picoseconds to nanoseconds */
12081202
min_clk_period = DIV_ROUND_UP(min_clk_period, 1000);
12091203

@@ -1214,6 +1208,16 @@ static int sunxi_nand_chip_set_timings(struct sunxi_nand_chip *chip,
12141208
* Allwinner engineers.
12151209
*/
12161210
chip->clk_rate = NSEC_PER_SEC / min_clk_period;
1211+
real_clk_rate = clk_round_rate(nfc->mod_clk, chip->clk_rate);
1212+
1213+
/*
1214+
* ONFI specification 3.1, paragraph 4.15.2 dictates that EDO data
1215+
* output cycle timings shall be used if the host drives tRC less than
1216+
* 30 ns.
1217+
*/
1218+
min_clk_period = NSEC_PER_SEC / real_clk_rate;
1219+
chip->timing_ctl = ((min_clk_period * 2) < 30) ?
1220+
NFC_TIMING_CTL_EDO : 0;
12171221

12181222
return 0;
12191223
}

0 commit comments

Comments
 (0)