* [PATCH 2/2] mtd: rawnand: fsmc: Disable NAND on remove()
@ 2019-01-18 21:06 Linus Walleij
2019-01-21 8:22 ` Boris Brezillon
0 siblings, 1 reply; 2+ messages in thread
From: Linus Walleij @ 2019-01-18 21:06 UTC (permalink / raw)
To: David Woodhouse, Brian Norris, Boris Brezillon, Marek Vasut,
Richard Weinberger, linux-mtd
Cc: Linus Walleij
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);
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);
--
2.19.2
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 2/2] mtd: rawnand: fsmc: Disable NAND on remove()
2019-01-18 21:06 [PATCH 2/2] mtd: rawnand: fsmc: Disable NAND on remove() Linus Walleij
@ 2019-01-21 8:22 ` Boris Brezillon
0 siblings, 0 replies; 2+ messages in thread
From: Boris Brezillon @ 2019-01-21 8:22 UTC (permalink / raw)
To: Linus Walleij
Cc: Marek Vasut, Brian Norris, David Woodhouse, linux-mtd,
Richard Weinberger
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/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-01-21 8:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-18 21:06 [PATCH 2/2] mtd: rawnand: fsmc: Disable NAND on remove() Linus Walleij
2019-01-21 8:22 ` Boris Brezillon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).