Commit e93c1640 authored by Masahiro Yamada's avatar Masahiro Yamada Committed by Boris Brezillon

mtd: nand: denali: simplify multi device fixup code

The available configuration of the IP bus width is x8 or x16, so the
possible value for denali->devnum is 1 or 2.

If the value is 1, there is nothing to do.  Fixup parameters only
when denali->devnum is 2.
Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: default avatarBoris Brezillon <boris.brezillon@free-electrons.com>
parent 6da27b46
...@@ -1403,7 +1403,7 @@ static void denali_drv_init(struct denali_nand_info *denali) ...@@ -1403,7 +1403,7 @@ static void denali_drv_init(struct denali_nand_info *denali)
denali->irq_status = 0; denali->irq_status = 0;
} }
static void denali_multidev_fixup(struct denali_nand_info *denali) static int denali_multidev_fixup(struct denali_nand_info *denali)
{ {
struct nand_chip *chip = &denali->nand; struct nand_chip *chip = &denali->nand;
struct mtd_info *mtd = nand_to_mtd(chip); struct mtd_info *mtd = nand_to_mtd(chip);
...@@ -1417,20 +1417,32 @@ static void denali_multidev_fixup(struct denali_nand_info *denali) ...@@ -1417,20 +1417,32 @@ static void denali_multidev_fixup(struct denali_nand_info *denali)
*/ */
denali->devnum = ioread32(denali->flash_reg + DEVICES_CONNECTED); denali->devnum = ioread32(denali->flash_reg + DEVICES_CONNECTED);
mtd->size <<= denali->devnum - 1; if (denali->devnum == 1)
mtd->erasesize <<= denali->devnum - 1; return 0;
mtd->writesize <<= denali->devnum - 1;
mtd->oobsize <<= denali->devnum - 1; if (denali->devnum != 2) {
chip->chipsize <<= denali->devnum - 1; dev_err(denali->dev, "unsupported number of devices %d\n",
chip->page_shift += denali->devnum - 1; denali->devnum);
chip->phys_erase_shift += denali->devnum - 1; return -EINVAL;
chip->bbt_erase_shift += denali->devnum - 1; }
chip->chip_shift += denali->devnum - 1;
chip->pagemask <<= denali->devnum - 1; /* 2 chips in parallel */
chip->ecc.size *= denali->devnum; mtd->size <<= 1;
chip->ecc.bytes *= denali->devnum; mtd->erasesize <<= 1;
chip->ecc.strength *= denali->devnum; mtd->writesize <<= 1;
denali->bbtskipbytes *= denali->devnum; mtd->oobsize <<= 1;
chip->chipsize <<= 1;
chip->page_shift += 1;
chip->phys_erase_shift += 1;
chip->bbt_erase_shift += 1;
chip->chip_shift += 1;
chip->pagemask <<= 1;
chip->ecc.size <<= 1;
chip->ecc.bytes <<= 1;
chip->ecc.strength <<= 1;
denali->bbtskipbytes <<= 1;
return 0;
} }
int denali_init(struct denali_nand_info *denali) int denali_init(struct denali_nand_info *denali)
...@@ -1568,7 +1580,9 @@ int denali_init(struct denali_nand_info *denali) ...@@ -1568,7 +1580,9 @@ int denali_init(struct denali_nand_info *denali)
chip->ecc.write_oob = denali_write_oob; chip->ecc.write_oob = denali_write_oob;
chip->erase = denali_erase; chip->erase = denali_erase;
denali_multidev_fixup(denali); ret = denali_multidev_fixup(denali);
if (ret)
goto failed_req_irq;
ret = nand_scan_tail(mtd); ret = nand_scan_tail(mtd);
if (ret) if (ret)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment