[2/2] mtd: rawnand: fsmc: Disable NAND on remove()

Message ID 20190118210615.8286-1-linus.walleij@linaro.org
State New
Headers show
Series
  • [1/2] mtd: rawnand: fsmc: Reset NAND timings on resume()
Related show

Commit Message

Linus Walleij Jan. 18, 2019, 9:06 p.m.
This disables the NAND on remove() and the errorpath,
making sure the chipselect gets deasserted when the
NAND is not in use.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

---
 drivers/mtd/nand/raw/fsmc_nand.c | 9 +++++++++
 1 file changed, 9 insertions(+)

-- 
2.19.2


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

Comments

Boris Brezillon Jan. 21, 2019, 8:22 a.m. | #1
On Fri, 18 Jan 2019 22:06:15 +0100
Linus Walleij <linus.walleij@linaro.org> wrote:

> This disables the NAND on remove() and the errorpath,

> making sure the chipselect gets deasserted when the

> NAND is not in use.

> 

> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

> ---

>  drivers/mtd/nand/raw/fsmc_nand.c | 9 +++++++++

>  1 file changed, 9 insertions(+)

> 

> diff --git a/drivers/mtd/nand/raw/fsmc_nand.c b/drivers/mtd/nand/raw/fsmc_nand.c

> index 4050843dd35e..118b1b1cd8da 100644

> --- a/drivers/mtd/nand/raw/fsmc_nand.c

> +++ b/drivers/mtd/nand/raw/fsmc_nand.c

> @@ -979,6 +979,7 @@ static int __init fsmc_nand_probe(struct platform_device *pdev)

>  	dma_cap_mask_t mask;

>  	int ret = 0;

>  	u32 pid;

> +	u32 val;

>  	int i;

>  

>  	/* Allocate memory for the device structure (and zero it) */

> @@ -1120,6 +1121,9 @@ static int __init fsmc_nand_probe(struct platform_device *pdev)

>  	if (host->mode == USE_DMA_ACCESS)

>  		dma_release_channel(host->read_dma_chan);

>  disable_clk:

> +	val = readl(host->regs_va + FSMC_PC);

> +	val &= ~FSMC_ENABLE;

> +	writel(val, host->regs_va + FSMC_PC);


Can you move this code in a separate function so that you don't have to
duplicate the logic in fsmc_nand_remove()?

>  	clk_disable_unprepare(host->clk);

>  

>  	return ret;

> @@ -1131,10 +1135,15 @@ static int __init fsmc_nand_probe(struct platform_device *pdev)

>  static int fsmc_nand_remove(struct platform_device *pdev)

>  {

>  	struct fsmc_nand_data *host = platform_get_drvdata(pdev);

> +	u32 val;

>  

>  	if (host) {

>  		nand_release(&host->nand);

>  

> +		val = readl(host->regs_va + FSMC_PC);

> +		val &= ~FSMC_ENABLE;

> +		writel(val, host->regs_va + FSMC_PC);

> +

>  		if (host->mode == USE_DMA_ACCESS) {

>  			dma_release_channel(host->write_dma_chan);

>  			dma_release_channel(host->read_dma_chan);



______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

Patch

diff --git a/drivers/mtd/nand/raw/fsmc_nand.c b/drivers/mtd/nand/raw/fsmc_nand.c
index 4050843dd35e..118b1b1cd8da 100644
--- a/drivers/mtd/nand/raw/fsmc_nand.c
+++ b/drivers/mtd/nand/raw/fsmc_nand.c
@@ -979,6 +979,7 @@  static int __init fsmc_nand_probe(struct platform_device *pdev)
 	dma_cap_mask_t mask;
 	int ret = 0;
 	u32 pid;
+	u32 val;
 	int i;
 
 	/* Allocate memory for the device structure (and zero it) */
@@ -1120,6 +1121,9 @@  static int __init fsmc_nand_probe(struct platform_device *pdev)
 	if (host->mode == USE_DMA_ACCESS)
 		dma_release_channel(host->read_dma_chan);
 disable_clk:
+	val = readl(host->regs_va + FSMC_PC);
+	val &= ~FSMC_ENABLE;
+	writel(val, host->regs_va + FSMC_PC);
 	clk_disable_unprepare(host->clk);
 
 	return ret;
@@ -1131,10 +1135,15 @@  static int __init fsmc_nand_probe(struct platform_device *pdev)
 static int fsmc_nand_remove(struct platform_device *pdev)
 {
 	struct fsmc_nand_data *host = platform_get_drvdata(pdev);
+	u32 val;
 
 	if (host) {
 		nand_release(&host->nand);
 
+		val = readl(host->regs_va + FSMC_PC);
+		val &= ~FSMC_ENABLE;
+		writel(val, host->regs_va + FSMC_PC);
+
 		if (host->mode == USE_DMA_ACCESS) {
 			dma_release_channel(host->write_dma_chan);
 			dma_release_channel(host->read_dma_chan);