aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/mtd/nand/raw/lpc32xx_mlc.c61
1 files changed, 33 insertions, 28 deletions
diff --git a/drivers/mtd/nand/raw/lpc32xx_mlc.c b/drivers/mtd/nand/raw/lpc32xx_mlc.c
index 052d123a8304..e82abada130a 100644
--- a/drivers/mtd/nand/raw/lpc32xx_mlc.c
+++ b/drivers/mtd/nand/raw/lpc32xx_mlc.c
@@ -184,6 +184,7 @@ static struct nand_bbt_descr lpc32xx_nand_bbt_mirror = {
184}; 184};
185 185
186struct lpc32xx_nand_host { 186struct lpc32xx_nand_host {
187 struct platform_device *pdev;
187 struct nand_chip nand_chip; 188 struct nand_chip nand_chip;
188 struct lpc32xx_mlc_platform_data *pdata; 189 struct lpc32xx_mlc_platform_data *pdata;
189 struct clk *clk; 190 struct clk *clk;
@@ -653,6 +654,32 @@ static struct lpc32xx_nand_cfg_mlc *lpc32xx_parse_dt(struct device *dev)
653 return ncfg; 654 return ncfg;
654} 655}
655 656
657static int lpc32xx_nand_attach_chip(struct nand_chip *chip)
658{
659 struct mtd_info *mtd = nand_to_mtd(chip);
660 struct lpc32xx_nand_host *host = nand_get_controller_data(chip);
661 struct device *dev = &host->pdev->dev;
662
663 host->dma_buf = devm_kzalloc(dev, mtd->writesize, GFP_KERNEL);
664 if (!host->dma_buf)
665 return -ENOMEM;
666
667 host->dummy_buf = devm_kzalloc(dev, mtd->writesize, GFP_KERNEL);
668 if (!host->dummy_buf)
669 return -ENOMEM;
670
671 chip->ecc.mode = NAND_ECC_HW;
672 chip->ecc.size = 512;
673 mtd_set_ooblayout(mtd, &lpc32xx_ooblayout_ops);
674 host->mlcsubpages = mtd->writesize / 512;
675
676 return 0;
677}
678
679static const struct nand_controller_ops lpc32xx_nand_controller_ops = {
680 .attach_chip = lpc32xx_nand_attach_chip,
681};
682
656/* 683/*
657 * Probe for NAND controller 684 * Probe for NAND controller
658 */ 685 */
@@ -669,6 +696,8 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)
669 if (!host) 696 if (!host)
670 return -ENOMEM; 697 return -ENOMEM;
671 698
699 host->pdev = pdev;
700
672 rc = platform_get_resource(pdev, IORESOURCE_MEM, 0); 701 rc = platform_get_resource(pdev, IORESOURCE_MEM, 0);
673 host->io_base = devm_ioremap_resource(&pdev->dev, rc); 702 host->io_base = devm_ioremap_resource(&pdev->dev, rc);
674 if (IS_ERR(host->io_base)) 703 if (IS_ERR(host->io_base))
@@ -748,31 +777,6 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)
748 } 777 }
749 } 778 }
750 779
751 /*
752 * Scan to find existance of the device and
753 * Get the type of NAND device SMALL block or LARGE block
754 */
755 res = nand_scan_ident(mtd, 1, NULL);
756 if (res)
757 goto release_dma_chan;
758
759 host->dma_buf = devm_kzalloc(&pdev->dev, mtd->writesize, GFP_KERNEL);
760 if (!host->dma_buf) {
761 res = -ENOMEM;
762 goto release_dma_chan;
763 }
764
765 host->dummy_buf = devm_kzalloc(&pdev->dev, mtd->writesize, GFP_KERNEL);
766 if (!host->dummy_buf) {
767 res = -ENOMEM;
768 goto release_dma_chan;
769 }
770
771 nand_chip->ecc.mode = NAND_ECC_HW;
772 nand_chip->ecc.size = 512;
773 mtd_set_ooblayout(mtd, &lpc32xx_ooblayout_ops);
774 host->mlcsubpages = mtd->writesize / 512;
775
776 /* initially clear interrupt status */ 780 /* initially clear interrupt status */
777 readb(MLC_IRQ_SR(host->io_base)); 781 readb(MLC_IRQ_SR(host->io_base));
778 782
@@ -794,10 +798,11 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)
794 } 798 }
795 799
796 /* 800 /*
797 * Fills out all the uninitialized function pointers with the defaults 801 * Scan to find existence of the device and get the type of NAND device:
798 * And scans for a bad block table if appropriate. 802 * SMALL block or LARGE block.
799 */ 803 */
800 res = nand_scan_tail(mtd); 804 nand_chip->dummy_controller.ops = &lpc32xx_nand_controller_ops;
805 res = nand_scan(mtd, 1);
801 if (res) 806 if (res)
802 goto free_irq; 807 goto free_irq;
803 808