aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHuang Shijie <b32955@freescale.com>2013-08-15 22:10:08 -0400
committerDavid Woodhouse <David.Woodhouse@intel.com>2013-08-30 16:38:27 -0400
commitf720e7ce510bf79f029be45ce200ccfce5551280 (patch)
treeadb9efe0174b65f710e07d8e868502b8d9e7dafc
parent4204cccde5e754745bbf30b077060c2033d29efa (diff)
mtd: gpmi: remove the nand_scan()
In order to make the nand_scan() work, the current code uses the hack code to init the @nand_chip->ecc.size and the @nand_chip->ecc.strength. and re-init some the ECC info in the gpmi_pre_bbt_scan(). This code is really a little ugly. The patch does following changes: (1) Use the nand_scan_ident()/nand_scan_tail() to replace the nand_scan(). (2) Init all the necessary values in the gpmi_init_last() before we call the nand_scan_tail(). (3) remove the code setting the ECC info, let the mtd layer to do the real job. (4) remove the gpmi_scan_bbt(). we do not need this function any more. Signed-off-by: Huang Shijie <b32955@freescale.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
-rw-r--r--drivers/mtd/nand/gpmi-nand/gpmi-nand.c65
1 files changed, 35 insertions, 30 deletions
diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
index 2ab6b3fe76ba..59ab0692f0b9 100644
--- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
+++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
@@ -214,7 +214,6 @@ static bool set_geometry_by_ecc_info(struct gpmi_nand_data *this)
214 if (geo->page_size < mtd->writesize + mtd->oobsize) { 214 if (geo->page_size < mtd->writesize + mtd->oobsize) {
215 of->offset = geo->page_size - mtd->writesize; 215 of->offset = geo->page_size - mtd->writesize;
216 of->length = mtd->oobsize - of->offset; 216 of->length = mtd->oobsize - of->offset;
217 mtd->oobavail = gpmi_hw_ecclayout.oobavail = of->length;
218 } 217 }
219 218
220 geo->payload_size = mtd->writesize; 219 geo->payload_size = mtd->writesize;
@@ -1582,19 +1581,22 @@ static int gpmi_pre_bbt_scan(struct gpmi_nand_data *this)
1582 if (ret) 1581 if (ret)
1583 return ret; 1582 return ret;
1584 1583
1585 /* Adjust the ECC strength according to the chip. */
1586 this->nand.ecc.strength = this->bch_geometry.ecc_strength;
1587 this->mtd.ecc_strength = this->bch_geometry.ecc_strength;
1588 this->mtd.bitflip_threshold = this->bch_geometry.ecc_strength;
1589
1590 /* NAND boot init, depends on the gpmi_set_geometry(). */ 1584 /* NAND boot init, depends on the gpmi_set_geometry(). */
1591 return nand_boot_init(this); 1585 return nand_boot_init(this);
1592} 1586}
1593 1587
1594static int gpmi_scan_bbt(struct mtd_info *mtd) 1588static void gpmi_nfc_exit(struct gpmi_nand_data *this)
1589{
1590 nand_release(&this->mtd);
1591 gpmi_free_dma_buffer(this);
1592}
1593
1594static int gpmi_init_last(struct gpmi_nand_data *this)
1595{ 1595{
1596 struct mtd_info *mtd = &this->mtd;
1596 struct nand_chip *chip = mtd->priv; 1597 struct nand_chip *chip = mtd->priv;
1597 struct gpmi_nand_data *this = chip->priv; 1598 struct nand_ecc_ctrl *ecc = &chip->ecc;
1599 struct bch_geometry *bch_geo = &this->bch_geometry;
1598 int ret; 1600 int ret;
1599 1601
1600 /* Prepare for the BBT scan. */ 1602 /* Prepare for the BBT scan. */
@@ -1602,6 +1604,16 @@ static int gpmi_scan_bbt(struct mtd_info *mtd)
1602 if (ret) 1604 if (ret)
1603 return ret; 1605 return ret;
1604 1606
1607 /* Init the nand_ecc_ctrl{} */
1608 ecc->read_page = gpmi_ecc_read_page;
1609 ecc->write_page = gpmi_ecc_write_page;
1610 ecc->read_oob = gpmi_ecc_read_oob;
1611 ecc->write_oob = gpmi_ecc_write_oob;
1612 ecc->mode = NAND_ECC_HW;
1613 ecc->size = bch_geo->ecc_chunk_size;
1614 ecc->strength = bch_geo->ecc_strength;
1615 ecc->layout = &gpmi_hw_ecclayout;
1616
1605 /* 1617 /*
1606 * Can we enable the extra features? such as EDO or Sync mode. 1618 * Can we enable the extra features? such as EDO or Sync mode.
1607 * 1619 *
@@ -1610,14 +1622,7 @@ static int gpmi_scan_bbt(struct mtd_info *mtd)
1610 */ 1622 */
1611 gpmi_extra_init(this); 1623 gpmi_extra_init(this);
1612 1624
1613 /* use the default BBT implementation */ 1625 return 0;
1614 return nand_default_bbt(mtd);
1615}
1616
1617static void gpmi_nfc_exit(struct gpmi_nand_data *this)
1618{
1619 nand_release(&this->mtd);
1620 gpmi_free_dma_buffer(this);
1621} 1626}
1622 1627
1623static int gpmi_nfc_init(struct gpmi_nand_data *this) 1628static int gpmi_nfc_init(struct gpmi_nand_data *this)
@@ -1643,33 +1648,33 @@ static int gpmi_nfc_init(struct gpmi_nand_data *this)
1643 chip->read_byte = gpmi_read_byte; 1648 chip->read_byte = gpmi_read_byte;
1644 chip->read_buf = gpmi_read_buf; 1649 chip->read_buf = gpmi_read_buf;
1645 chip->write_buf = gpmi_write_buf; 1650 chip->write_buf = gpmi_write_buf;
1646 chip->ecc.read_page = gpmi_ecc_read_page;
1647 chip->ecc.write_page = gpmi_ecc_write_page;
1648 chip->ecc.read_oob = gpmi_ecc_read_oob;
1649 chip->ecc.write_oob = gpmi_ecc_write_oob;
1650 chip->scan_bbt = gpmi_scan_bbt;
1651 chip->badblock_pattern = &gpmi_bbt_descr; 1651 chip->badblock_pattern = &gpmi_bbt_descr;
1652 chip->block_markbad = gpmi_block_markbad; 1652 chip->block_markbad = gpmi_block_markbad;
1653 chip->options |= NAND_NO_SUBPAGE_WRITE; 1653 chip->options |= NAND_NO_SUBPAGE_WRITE;
1654 chip->ecc.mode = NAND_ECC_HW;
1655 chip->ecc.size = 1;
1656 chip->ecc.strength = 8;
1657 chip->ecc.layout = &gpmi_hw_ecclayout;
1658 if (of_get_nand_on_flash_bbt(this->dev->of_node)) 1654 if (of_get_nand_on_flash_bbt(this->dev->of_node))
1659 chip->bbt_options |= NAND_BBT_USE_FLASH | NAND_BBT_NO_OOB; 1655 chip->bbt_options |= NAND_BBT_USE_FLASH | NAND_BBT_NO_OOB;
1660 1656
1661 /* Allocate a temporary DMA buffer for reading ID in the nand_scan() */ 1657 /*
1658 * Allocate a temporary DMA buffer for reading ID in the
1659 * nand_scan_ident().
1660 */
1662 this->bch_geometry.payload_size = 1024; 1661 this->bch_geometry.payload_size = 1024;
1663 this->bch_geometry.auxiliary_size = 128; 1662 this->bch_geometry.auxiliary_size = 128;
1664 ret = gpmi_alloc_dma_buffer(this); 1663 ret = gpmi_alloc_dma_buffer(this);
1665 if (ret) 1664 if (ret)
1666 goto err_out; 1665 goto err_out;
1667 1666
1668 ret = nand_scan(mtd, 1); 1667 ret = nand_scan_ident(mtd, 1, NULL);
1669 if (ret) { 1668 if (ret)
1670 pr_err("Chip scan failed\n"); 1669 goto err_out;
1670
1671 ret = gpmi_init_last(this);
1672 if (ret)
1673 goto err_out;
1674
1675 ret = nand_scan_tail(mtd);
1676 if (ret)
1671 goto err_out; 1677 goto err_out;
1672 }
1673 1678
1674 ppdata.of_node = this->pdev->dev.of_node; 1679 ppdata.of_node = this->pdev->dev.of_node;
1675 ret = mtd_device_parse_register(mtd, NULL, &ppdata, NULL, 0); 1680 ret = mtd_device_parse_register(mtd, NULL, &ppdata, NULL, 0);