diff options
author | Bean Huo <beanhuo@outlook.com> | 2014-07-16 12:05:26 -0400 |
---|---|---|
committer | Brian Norris <computersforpeace@gmail.com> | 2014-07-16 14:03:38 -0400 |
commit | 6534e6809e6c9d48114b537afe03bee3fd33bf01 (patch) | |
tree | 52946f6468bcdc0b3b6e408ee3dba411db016461 /drivers/mtd | |
parent | d68a5c3d2db408a83e69f12b57b8e19c086d1aee (diff) |
mtd: cfi_cmdset_0002: fix do_write_buffer() timeout error
For some NOR flashes, the size of the buffer program has been increased
from 256 bytes to 512 bytes, and so 2ms maximum timeout can may not be
sufficient for all different vendor's NOR flash. There is maximum
timeout information in the CFI area, so we instead of picking a fixed
value, we can calculate this according to the standard CFI parameters
parsed at probe time. If we haven't probed this information, or it is
smaller than 2000us, then specify a minimum value 2000us.
Tested with Micron JS28F512M29EWx and Micron MT28EW512ABA flash devices.
Signed-off-by: Bean Huo <beanhuo@outlook.com>
[Brian: fix up comments, use 'max()']
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/chips/cfi_cmdset_0002.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c index bf313be6ee26..5a4bfe33112a 100644 --- a/drivers/mtd/chips/cfi_cmdset_0002.c +++ b/drivers/mtd/chips/cfi_cmdset_0002.c | |||
@@ -645,6 +645,23 @@ struct mtd_info *cfi_cmdset_0002(struct map_info *map, int primary) | |||
645 | cfi->chips[i].word_write_time = 1<<cfi->cfiq->WordWriteTimeoutTyp; | 645 | cfi->chips[i].word_write_time = 1<<cfi->cfiq->WordWriteTimeoutTyp; |
646 | cfi->chips[i].buffer_write_time = 1<<cfi->cfiq->BufWriteTimeoutTyp; | 646 | cfi->chips[i].buffer_write_time = 1<<cfi->cfiq->BufWriteTimeoutTyp; |
647 | cfi->chips[i].erase_time = 1<<cfi->cfiq->BlockEraseTimeoutTyp; | 647 | cfi->chips[i].erase_time = 1<<cfi->cfiq->BlockEraseTimeoutTyp; |
648 | /* | ||
649 | * First calculate the timeout max according to timeout field | ||
650 | * of struct cfi_ident that probed from chip's CFI aera, if | ||
651 | * available. Specify a minimum of 2000us, in case the CFI data | ||
652 | * is wrong. | ||
653 | */ | ||
654 | if (cfi->cfiq->BufWriteTimeoutTyp && | ||
655 | cfi->cfiq->BufWriteTimeoutMax) | ||
656 | cfi->chips[i].buffer_write_time_max = | ||
657 | 1 << (cfi->cfiq->BufWriteTimeoutTyp + | ||
658 | cfi->cfiq->BufWriteTimeoutMax); | ||
659 | else | ||
660 | cfi->chips[i].buffer_write_time_max = 0; | ||
661 | |||
662 | cfi->chips[i].buffer_write_time_max = | ||
663 | max(cfi->chips[i].buffer_write_time_max, 2000); | ||
664 | |||
648 | cfi->chips[i].ref_point_counter = 0; | 665 | cfi->chips[i].ref_point_counter = 0; |
649 | init_waitqueue_head(&(cfi->chips[i].wq)); | 666 | init_waitqueue_head(&(cfi->chips[i].wq)); |
650 | } | 667 | } |
@@ -1774,8 +1791,12 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip, | |||
1774 | { | 1791 | { |
1775 | struct cfi_private *cfi = map->fldrv_priv; | 1792 | struct cfi_private *cfi = map->fldrv_priv; |
1776 | unsigned long timeo = jiffies + HZ; | 1793 | unsigned long timeo = jiffies + HZ; |
1777 | /* see comments in do_write_oneword() regarding uWriteTimeo. */ | 1794 | /* |
1778 | unsigned long uWriteTimeout = ( HZ / 1000 ) + 1; | 1795 | * Timeout is calculated according to CFI data, if available. |
1796 | * See more comments in cfi_cmdset_0002(). | ||
1797 | */ | ||
1798 | unsigned long uWriteTimeout = | ||
1799 | usecs_to_jiffies(chip->buffer_write_time_max); | ||
1779 | int ret = -EIO; | 1800 | int ret = -EIO; |
1780 | unsigned long cmd_adr; | 1801 | unsigned long cmd_adr; |
1781 | int z, words; | 1802 | int z, words; |