Merge tag 'mtd/for-5.1' of git://git.infradead.org/linux-mtd
[linux-2.6-microblaze.git] / drivers / mtd / nand / raw / fsmc_nand.c
index c9149a3..6c7ca41 100644 (file)
@@ -965,6 +965,19 @@ static const struct nand_controller_ops fsmc_nand_controller_ops = {
        .setup_data_interface = fsmc_setup_data_interface,
 };
 
+/**
+ * fsmc_nand_disable() - Disables the NAND bank
+ * @host: The instance to disable
+ */
+static void fsmc_nand_disable(struct fsmc_nand_data *host)
+{
+       u32 val;
+
+       val = readl(host->regs_va + FSMC_PC);
+       val &= ~FSMC_ENABLE;
+       writel(val, host->regs_va + FSMC_PC);
+}
+
 /*
  * fsmc_nand_probe - Probe function
  * @pdev:       platform device structure
@@ -1120,6 +1133,7 @@ release_dma_read_chan:
        if (host->mode == USE_DMA_ACCESS)
                dma_release_channel(host->read_dma_chan);
 disable_clk:
+       fsmc_nand_disable(host);
        clk_disable_unprepare(host->clk);
 
        return ret;
@@ -1134,6 +1148,7 @@ static int fsmc_nand_remove(struct platform_device *pdev)
 
        if (host) {
                nand_release(&host->nand);
+               fsmc_nand_disable(host);
 
                if (host->mode == USE_DMA_ACCESS) {
                        dma_release_channel(host->write_dma_chan);
@@ -1164,6 +1179,7 @@ static int fsmc_nand_resume(struct device *dev)
                clk_prepare_enable(host->clk);
                if (host->dev_timings)
                        fsmc_nand_setup(host, host->dev_timings);
+               nand_reset(&host->nand, 0);
        }
 
        return 0;