From patchwork Tue Aug 6 08:57:38 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Shiyan X-Patchwork-Id: 264926 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from casper.infradead.org (unknown [IPv6:2001:770:15f::2]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A73052C0085 for ; Tue, 6 Aug 2013 19:00:30 +1000 (EST) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V6d7s-0005S5-7S; Tue, 06 Aug 2013 09:00:20 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V6d7n-0006tp-4E; Tue, 06 Aug 2013 09:00:15 +0000 Received: from fallback5.mail.ru ([94.100.176.59]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V6d7k-0006sf-70 for linux-mtd@lists.infradead.org; Tue, 06 Aug 2013 09:00:13 +0000 Received: from smtp46.i.mail.ru (smtp46.i.mail.ru [94.100.177.106]) by fallback5.mail.ru (mPOP.Fallback_MX) with ESMTP id 98BF6F146DF1; Tue, 6 Aug 2013 12:59:50 +0400 (MSK) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mail.ru; s=mail2; h=Message-Id:Date:Subject:Cc:To:From; bh=ZI6nCpShtniwJTJL72nmxR8QooWEINnt4o21afA+Aog=; b=fb0ESLcog4q4W1u5fCwdaBDMqAwhyRq4XmTlcsU5XG4fb8gYx9ZDV485WBFlaZrnVrOUc3mwWLmzJRON6t7DIAlKPXAu6nAzoNU6L+vl2MZbyZUKXW+aT8aL3axSVyorkOyvgvNYdXDna9pKRKXou0pfbF/Uk7q+HNSseDXk4o4=; Received: from [217.119.30.118] (port=61094 helo=shc.milas.spb.ru) by smtp46.i.mail.ru with esmtpa (envelope-from ) id 1V6d5u-0000TK-5H; Tue, 06 Aug 2013 12:58:18 +0400 From: Alexander Shiyan To: linux-mtd@lists.infradead.org Subject: [PATCH v3 1/4] mtd: nand: gpio: Add DT property to automatically determine bus width Date: Tue, 6 Aug 2013 12:57:38 +0400 Message-Id: <1375779459-32549-1-git-send-email-shc_work@mail.ru> X-Mailer: git-send-email 1.8.1.5 X-Spam: Not detected X-Mras: Ok X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130806_050012_568866_5B934228 X-CRM114-Status: GOOD ( 13.75 ) X-Spam-Score: 0.5 (/) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (0.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.8 RCVD_IN_SORBS_WEB RBL: SORBS: sender is an abusable web server [217.119.30.118 listed in dnsbl.sorbs.net] 1.7 KHOP_BIG_TO_CC Sent to 10+ recipients instaed of Bcc or a list 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (shc_work[at]mail.ru) -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [94.100.176.59 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: Mark Rutland , devicetree@vger.kernel.org, Ian Campbell , Pawel Moll , Stephen Warren , Artem Bityutskiy , Rob Herring , Alexander Shiyan , Grant Likely , Brian Norris , David Woodhouse X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org This patch adds a property to automatically determine the NAND bus width. This property works if the bus width is not specified explicitly. Signed-off-by: Alexander Shiyan --- .../devicetree/bindings/mtd/gpio-control-nand.txt | 2 ++ drivers/mtd/nand/gpio.c | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Documentation/devicetree/bindings/mtd/gpio-control-nand.txt b/Documentation/devicetree/bindings/mtd/gpio-control-nand.txt index 36ef07d..91070d0 100644 --- a/Documentation/devicetree/bindings/mtd/gpio-control-nand.txt +++ b/Documentation/devicetree/bindings/mtd/gpio-control-nand.txt @@ -19,6 +19,8 @@ Optional properties: defaults to 1 byte. - chip-delay : chip dependent delay for transferring data from array to read registers (tR). If not present then a default of 20us is used. +- gpio-control-nand,bank-width-auto : Device bus width is determined + automatically if "bank-width" is omitted (Boolean). - gpio-control-nand,io-sync-reg : A 64-bit physical address for a read location used to guard against bus reordering with regards to accesses to the GPIO's and the NAND flash data bus. If present, then after changing diff --git a/drivers/mtd/nand/gpio.c b/drivers/mtd/nand/gpio.c index 800a1cc..c75f92e 100644 --- a/drivers/mtd/nand/gpio.c +++ b/drivers/mtd/nand/gpio.c @@ -116,6 +116,10 @@ static int gpio_nand_get_config_of(const struct device *dev, dev_err(dev, "invalid bank-width %u\n", val); return -EINVAL; } + } else { + if (of_get_property(dev->of_node, + "gpio-control-nand,bank-width-auto", NULL)) + plat->options |= NAND_BUSWIDTH_AUTO; } plat->gpio_rdy = of_get_gpio(dev->of_node, 0); @@ -223,6 +227,14 @@ static int gpio_nand_probe(struct platform_device *pdev) if (IS_ERR(chip->IO_ADDR_R)) return PTR_ERR(chip->IO_ADDR_R); + ret = gpio_nand_get_config(&pdev->dev, &gpiomtd->plat); + if (ret) + return ret; + + if (resource_size(res) < 2) + gpiomtd->plat.options &= ~(NAND_BUSWIDTH_16 | + NAND_BUSWIDTH_AUTO); + res = gpio_nand_get_io_sync(pdev); if (res) { gpiomtd->io_sync = devm_ioremap_resource(&pdev->dev, res); @@ -230,10 +242,6 @@ static int gpio_nand_probe(struct platform_device *pdev) return PTR_ERR(gpiomtd->io_sync); } - ret = gpio_nand_get_config(&pdev->dev, &gpiomtd->plat); - if (ret) - return ret; - ret = devm_gpio_request(&pdev->dev, gpiomtd->plat.gpio_nce, "NAND NCE"); if (ret) return ret;