summaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand
diff options
context:
space:
mode:
authorMasahiro Yamada <yamada.masahiro@socionext.com>2017-03-22 16:07:20 -0400
committerBoris Brezillon <boris.brezillon@free-electrons.com>2017-03-27 11:58:11 -0400
commit6da27b469317435b776114649439e32384165aa5 (patch)
treed185ff41f12d8a4f67a539a5c8e90a20ed811460 /drivers/mtd/nand
parent63757d463ea683b469c1976032054d46cecdef09 (diff)
mtd: nand: denali: move multi device fixup code to a helper function
Collect multi NAND fixups into a helper function instead of scattering them in denali_init(). I am rewording the comment block to clearly explain what is called "multi device". Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Diffstat (limited to 'drivers/mtd/nand')
-rw-r--r--drivers/mtd/nand/denali.c54
1 files changed, 33 insertions, 21 deletions
diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
index f120f143539b..2b5edd39248b 100644
--- a/drivers/mtd/nand/denali.c
+++ b/drivers/mtd/nand/denali.c
@@ -1403,6 +1403,36 @@ static void denali_drv_init(struct denali_nand_info *denali)
1403 denali->irq_status = 0; 1403 denali->irq_status = 0;
1404} 1404}
1405 1405
1406static void denali_multidev_fixup(struct denali_nand_info *denali)
1407{
1408 struct nand_chip *chip = &denali->nand;
1409 struct mtd_info *mtd = nand_to_mtd(chip);
1410
1411 /*
1412 * Support for multi device:
1413 * When the IP configuration is x16 capable and two x8 chips are
1414 * connected in parallel, DEVICES_CONNECTED should be set to 2.
1415 * In this case, the core framework knows nothing about this fact,
1416 * so we should tell it the _logical_ pagesize and anything necessary.
1417 */
1418 denali->devnum = ioread32(denali->flash_reg + DEVICES_CONNECTED);
1419
1420 mtd->size <<= denali->devnum - 1;
1421 mtd->erasesize <<= denali->devnum - 1;
1422 mtd->writesize <<= denali->devnum - 1;
1423 mtd->oobsize <<= denali->devnum - 1;
1424 chip->chipsize <<= denali->devnum - 1;
1425 chip->page_shift += denali->devnum - 1;
1426 chip->phys_erase_shift += denali->devnum - 1;
1427 chip->bbt_erase_shift += denali->devnum - 1;
1428 chip->chip_shift += denali->devnum - 1;
1429 chip->pagemask <<= denali->devnum - 1;
1430 chip->ecc.size *= denali->devnum;
1431 chip->ecc.bytes *= denali->devnum;
1432 chip->ecc.strength *= denali->devnum;
1433 denali->bbtskipbytes *= denali->devnum;
1434}
1435
1406int denali_init(struct denali_nand_info *denali) 1436int denali_init(struct denali_nand_info *denali)
1407{ 1437{
1408 struct nand_chip *chip = &denali->nand; 1438 struct nand_chip *chip = &denali->nand;
@@ -1485,24 +1515,6 @@ int denali_init(struct denali_nand_info *denali)
1485 } 1515 }
1486 1516
1487 /* 1517 /*
1488 * support for multi nand
1489 * MTD known nothing about multi nand, so we should tell it
1490 * the real pagesize and anything necessery
1491 */
1492 denali->devnum = ioread32(denali->flash_reg + DEVICES_CONNECTED);
1493 chip->chipsize <<= denali->devnum - 1;
1494 chip->page_shift += denali->devnum - 1;
1495 chip->pagemask = (chip->chipsize >> chip->page_shift) - 1;
1496 chip->bbt_erase_shift += denali->devnum - 1;
1497 chip->phys_erase_shift = chip->bbt_erase_shift;
1498 chip->chip_shift += denali->devnum - 1;
1499 mtd->writesize <<= denali->devnum - 1;
1500 mtd->oobsize <<= denali->devnum - 1;
1501 mtd->erasesize <<= denali->devnum - 1;
1502 mtd->size = chip->numchips * chip->chipsize;
1503 denali->bbtskipbytes *= denali->devnum;
1504
1505 /*
1506 * second stage of the NAND scan 1518 * second stage of the NAND scan
1507 * this stage requires information regarding ECC and 1519 * this stage requires information regarding ECC and
1508 * bad block management. 1520 * bad block management.
@@ -1545,11 +1557,9 @@ int denali_init(struct denali_nand_info *denali)
1545 } 1557 }
1546 1558
1547 mtd_set_ooblayout(mtd, &denali_ooblayout_ops); 1559 mtd_set_ooblayout(mtd, &denali_ooblayout_ops);
1548 chip->ecc.bytes *= denali->devnum;
1549 chip->ecc.strength *= denali->devnum;
1550 1560
1551 /* override the default read operations */ 1561 /* override the default read operations */
1552 chip->ecc.size = ECC_SECTOR_SIZE * denali->devnum; 1562 chip->ecc.size = ECC_SECTOR_SIZE;
1553 chip->ecc.read_page = denali_read_page; 1563 chip->ecc.read_page = denali_read_page;
1554 chip->ecc.read_page_raw = denali_read_page_raw; 1564 chip->ecc.read_page_raw = denali_read_page_raw;
1555 chip->ecc.write_page = denali_write_page; 1565 chip->ecc.write_page = denali_write_page;
@@ -1558,6 +1568,8 @@ int denali_init(struct denali_nand_info *denali)
1558 chip->ecc.write_oob = denali_write_oob; 1568 chip->ecc.write_oob = denali_write_oob;
1559 chip->erase = denali_erase; 1569 chip->erase = denali_erase;
1560 1570
1571 denali_multidev_fixup(denali);
1572
1561 ret = nand_scan_tail(mtd); 1573 ret = nand_scan_tail(mtd);
1562 if (ret) 1574 if (ret)
1563 goto failed_req_irq; 1575 goto failed_req_irq;