From patchwork Fri Aug 16 07:19:42 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Shiyan X-Patchwork-Id: 267556 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 421932C01C5 for ; Fri, 16 Aug 2013 17:21:07 +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 1VAEL0-0003Ff-LW; Fri, 16 Aug 2013 07:20:46 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VAEKv-0002Lx-NV; Fri, 16 Aug 2013 07:20:41 +0000 Received: from smtp51.i.mail.ru ([94.100.177.111]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VAEKi-0002Jb-Vd for linux-mtd@lists.infradead.org; Fri, 16 Aug 2013 07:20:31 +0000 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=5jneKW5Tf3l6s7BOe8F/JYk6WkO8h5pnCEj2tfldruQ=; b=aMRYX4mcmzH+FJkNo3un/vra43DHL6mq7YNyI3co0a+S9emVBnuS10WxoUpm1V5ONjMVGKjPFw3eTZgMuOA5WB58lZP0uEyWGKAoG/VrWi5EO1/mxZKffyiPMzolVjiSpNTxIa9k/d/PWQZCCC3NPj8zRo5aNWm+36fV6jMWLjI=; Received: from [217.119.30.118] (port=33656 helo=shc.milas.spb.ru) by smtp51.i.mail.ru with esmtpa (envelope-from ) id 1VAEKK-0002fB-5F; Fri, 16 Aug 2013 11:20:04 +0400 From: Alexander Shiyan To: linux-mtd@lists.infradead.org Subject: [PATCH v4 1/4] mtd: nand: gpio: Add DT property to automatically determine bus width Date: Fri, 16 Aug 2013 11:19:42 +0400 Message-Id: <1376637583-12485-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-20130816_032029_488126_012EFF27 X-CRM114-Status: GOOD ( 13.14 ) X-Spam-Score: -1.2 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (shc_work[at]mail.ru) 0.8 RCVD_IN_SORBS_WEB RBL: SORBS: sender is an abusable web server [217.119.30.118 listed in dnsbl.sorbs.net] -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 e826f89..8eea181 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;