From patchwork Fri Jan 12 13:16:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ladislav Michl X-Patchwork-Id: 859928 X-Patchwork-Delegate: boris.brezillon@free-electrons.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="SKNELI/u"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="wCm2ZliC"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zJ3rt5W9fz9s9Y for ; Sat, 13 Jan 2018 00:44:46 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=rC8X95p1J7ciWimJxYs4KNL6bKQSGJr62m23D9WTMwo=; b=SKNELI/uCZx5fV 8UmCFxoDGAjOQi0nfmuP+WG3XT8NtVLfXmssiofICSIiTI9HJHzdmaahP4WSRDd2wqdvndQI3haPK StswNfh+XUoxLvFX4vvyJYZabpU+/ArEINyzq9zzjrKDjM1/rtPA0b7p+dbY6q2XppJFEcvvD2fvp 7cFWjIT55Mwm1MaSXw2H4PF3AKxZ+pDcr02gAuVTdCiKcXkX8RZPcyHh0ZzniqQPdGynziNoUeQNV tLWl8g+smbmSFBxevpRF6fRNgZOGBscajgVKdqTDcDrskfHzIH1tJGj0FEWb9qu5f1sh5U4yYAli1 Bqb3DRS4zcHra6am7UPg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eZzdS-000240-Pd; Fri, 12 Jan 2018 13:44:42 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eZzdI-0001r9-14 for linux-mtd@bombadil.infradead.org; Fri, 12 Jan 2018 13:44:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Sender:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ZB9sav7Nz3Wh6tncY3lG8B3d/GVHsj6ztxatpUgPf8E=; b=wCm2ZliC23g0d6PAOX59NPY9p PhqPMJkfJF9BAgxCIh7fYbaZ8wAjJG5oQ+WAOYnAIdCURsxjT5s43MxqH08sVOfBf7IBcSByH4Exp XggEy+Y8GQqm6Vo6JydUriDyPGmWUjR9eMr5/aRPgpJ73TYp9WptBZUJM6rg73Iw9V/7aJGmNsozw Zb/oMrIrRyDQnZ0QBJmiLBHyloG6rhqJ0ruWbIJVltIVybwYI/zUjtzajbiDmyNqpi4jZCfo4TNLA NYtE94giKsBvoytUt+hjOdfR5lBr3+qW8q5rE/UnE6LcZA3sDETT9Aw/o5GhCVg32FUsbU9y6vzio N71SdewYg==; Received: from eddie.linux-mips.org ([148.251.95.138] helo=cvs.linux-mips.org) by merlin.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eZzCc-00045D-N2 for linux-mtd@lists.infradead.org; Fri, 12 Jan 2018 13:16:59 +0000 Received: (from localhost user: 'ladis' uid#1021 fake: STDIN (ladis@eddie.linux-mips.org)) by eddie.linux-mips.org id S23994659AbeALNQ6USI7d (ORCPT ); Fri, 12 Jan 2018 14:16:58 +0100 Date: Fri, 12 Jan 2018 14:16:57 +0100 From: Ladislav Michl To: linux-mtd@lists.infradead.org, linux-omap@vger.kernel.org Subject: [PATCH v6 12/14] mtd: onenand: omap2: Decouple DMA enabling from INT pin availability Message-ID: <20180112131657.GM13810@lenoch> References: <20180112131105.GA13810@lenoch> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20180112131105.GA13810@lenoch> User-Agent: Mutt/1.9.2 (2017-12-15) X-Spam-Note: CRM114 invocation failed X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.1 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [148.251.95.138 listed in list.dnswl.org] -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Boris Brezillon , Aaro Koskinen , Tony Lindgren , Peter Ujfalusi , Kyungmin Park , Roger Quadros Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org INT pin (gpio_irq) is not really needed for DMA but only for notification when a command that needs wait has completed. DMA memcpy can be still used even without gpio_irq available, so enable it unconditionally. Signed-off-by: Ladislav Michl Reviewed-by: Peter Ujfalusi Tested-by: Tony Lindgren Tested-by: Aaro Koskinen Acked-by: Tony Lindgren Acked-by: Roger Quadros --- Changes in v6: None Changes in v5: - rename patch and fix commit message Changes in v4: - new patch Changes in v3: None Changes in v2: None drivers/mtd/onenand/omap2.c | 52 ++++++++++++++++++--------------------------- 1 file changed, 21 insertions(+), 31 deletions(-) diff --git a/drivers/mtd/onenand/omap2.c b/drivers/mtd/onenand/omap2.c index e4857a41760d..1cd78a076759 100644 --- a/drivers/mtd/onenand/omap2.c +++ b/drivers/mtd/onenand/omap2.c @@ -152,17 +152,13 @@ static int omap2_onenand_wait(struct mtd_info *mtd, int state) } reinit_completion(&c->irq_done); - if (c->gpio_irq) { - result = gpio_get_value(c->gpio_irq); - if (result == -1) { - ctrl = read_reg(c, ONENAND_REG_CTRL_STATUS); - intr = read_reg(c, ONENAND_REG_INTERRUPT); - wait_err("gpio error", state, ctrl, intr); - return -EIO; - } - } else - result = 0; - if (result == 0) { + result = gpio_get_value(c->gpio_irq); + if (result < 0) { + ctrl = read_reg(c, ONENAND_REG_CTRL_STATUS); + intr = read_reg(c, ONENAND_REG_INTERRUPT); + wait_err("gpio error", state, ctrl, intr); + return -EIO; + } else if (result == 0) { int retry_cnt = 0; retry: if (!wait_for_completion_io_timeout(&c->irq_done, @@ -450,6 +446,7 @@ static void omap2_onenand_shutdown(struct platform_device *pdev) static int omap2_onenand_probe(struct platform_device *pdev) { + dma_cap_mask_t mask; struct omap_onenand_platform_data *pdata; struct omap2_onenand *c; struct onenand_chip *this; @@ -513,31 +510,25 @@ static int omap2_onenand_probe(struct platform_device *pdev) dev_err(&pdev->dev, "Failed to request GPIO%d for " "OneNAND\n", c->gpio_irq); goto err_iounmap; - } - gpio_direction_input(c->gpio_irq); + } + gpio_direction_input(c->gpio_irq); - if ((r = request_irq(gpio_to_irq(c->gpio_irq), - omap2_onenand_interrupt, IRQF_TRIGGER_RISING, - pdev->dev.driver->name, c)) < 0) - goto err_release_gpio; - } + if ((r = request_irq(gpio_to_irq(c->gpio_irq), + omap2_onenand_interrupt, IRQF_TRIGGER_RISING, + pdev->dev.driver->name, c)) < 0) + goto err_release_gpio; - if (pdata->dma_channel >= 0) { - dma_cap_mask_t mask; + this->wait = omap2_onenand_wait; + } - dma_cap_zero(mask); - dma_cap_set(DMA_MEMCPY, mask); + dma_cap_zero(mask); + dma_cap_set(DMA_MEMCPY, mask); - c->dma_chan = dma_request_channel(mask, NULL, NULL); - if (!c->dma_chan) - dev_info(&pdev->dev, - "failed to allocate DMA for OneNAND, " - "using PIO instead\n"); - } + c->dma_chan = dma_request_channel(mask, NULL, NULL); dev_info(&pdev->dev, "initializing on CS%d, phys base 0x%08lx, virtual " - "base %p, freq %d MHz\n", c->gpmc_cs, c->phys_base, - c->onenand.base, c->freq); + "base %p, freq %d MHz, %s mode\n", c->gpmc_cs, c->phys_base, + c->onenand.base, c->freq, c->dma_chan ? "DMA" : "PIO"); c->pdev = pdev; c->mtd.priv = &c->onenand; @@ -547,7 +538,6 @@ static int omap2_onenand_probe(struct platform_device *pdev) this = &c->onenand; if (c->dma_chan) { - this->wait = omap2_onenand_wait; this->read_bufferram = omap2_onenand_read_bufferram; this->write_bufferram = omap2_onenand_write_bufferram; }