From patchwork Wed Jun 11 08:56:25 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 31743 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f199.google.com (mail-qc0-f199.google.com [209.85.216.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 67BA3203C2 for ; Wed, 11 Jun 2014 09:02:02 +0000 (UTC) Received: by mail-qc0-f199.google.com with SMTP id i17sf11376022qcy.2 for ; Wed, 11 Jun 2014 02:02:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :in-reply-to:references:mime-version:cc:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:content-type :content-transfer-encoding; bh=2pax3NGIpqtLyv8gTwSXPCF97ZDjjDmJ7UZ+DrcWcMA=; b=gdTCT/BRVvdLTgsgt8hI8FYCzNpn/erhwH/qNVHFkZ+pMKlNrWPWFRYM1ioqzPdwxz MVg344tjrW7RY5QaAy4iVi1tArYGMr5NuCoP9LiQpDfl/oYJPSKyeT7D2EFuaiTspTPV +RIn+FdasESh13Cy0SwiC6WTiXVYNTds6X9s0PUOF+NXdnaywWh9te04Oh51CS14phvd Hpv5iZy1MREjeW1Urk2ExnEb010y7PlH4I3Q5NJ6egDzS3KEsdv1ac4o45MRHdx83eTp epYPZsd+GBwspZO2q7JVAXgdyhhT+bXcMSUgA55XIFqpaCw9XYD9qQsa6P9aqkvWiGNE Wo3g== X-Gm-Message-State: ALoCoQmrbcv2Uf2gU0tbKNCUpeArX2FQ2LleLyu4bsKNZ0hwnMrJpVGb4JVmL6Zqj9EghQpmO6uA X-Received: by 10.58.37.164 with SMTP id z4mr41957vej.28.1402477322256; Wed, 11 Jun 2014 02:02:02 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.88.165 with SMTP id t34ls156809qgd.93.gmail; Wed, 11 Jun 2014 02:02:02 -0700 (PDT) X-Received: by 10.220.165.6 with SMTP id g6mr37328838vcy.17.1402477322094; Wed, 11 Jun 2014 02:02:02 -0700 (PDT) Received: from mail-ve0-f181.google.com (mail-ve0-f181.google.com [209.85.128.181]) by mx.google.com with ESMTPS id sk10si1489273vec.81.2014.06.11.02.02.02 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 11 Jun 2014 02:02:02 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.181 as permitted sender) client-ip=209.85.128.181; Received: by mail-ve0-f181.google.com with SMTP id db11so4741407veb.26 for ; Wed, 11 Jun 2014 02:02:02 -0700 (PDT) X-Received: by 10.58.210.68 with SMTP id ms4mr9747891vec.6.1402477321971; Wed, 11 Jun 2014 02:02:01 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.54.6 with SMTP id vs6csp286695vcb; Wed, 11 Jun 2014 02:02:01 -0700 (PDT) X-Received: by 10.224.60.137 with SMTP id p9mr20564411qah.92.1402477321312; Wed, 11 Jun 2014 02:02:01 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id 107si29759196qgn.94.2014.06.11.02.02.01 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Jun 2014 02:02:01 -0700 (PDT) Received-SPF: none (google.com: linux-mtd-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WueNQ-0003TY-7w; Wed, 11 Jun 2014 08:59:24 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WueMY-0002YE-4e for linux-mtd@bombadil.infradead.org; Wed, 11 Jun 2014 08:58:30 +0000 Received: from devils.ext.ti.com ([198.47.26.153]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WueMU-0006zR-Oc for linux-mtd@lists.infradead.org; Wed, 11 Jun 2014 08:58:27 +0000 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id s5B8w09A027754; Wed, 11 Jun 2014 03:58:00 -0500 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id s5B8w0Yt008831; Wed, 11 Jun 2014 03:58:00 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.3.174.1; Wed, 11 Jun 2014 03:57:59 -0500 Received: from localhost.localdomain (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id s5B8uiSs020510; Wed, 11 Jun 2014 03:57:56 -0500 From: Roger Quadros To: , , Subject: [PATCH 20/36] mtd: onenand: omap: Clean up device tree support Date: Wed, 11 Jun 2014 11:56:25 +0300 Message-ID: <1402477001-31132-21-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1402477001-31132-1-git-send-email-rogerq@ti.com> References: <1402477001-31132-1-git-send-email-rogerq@ti.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140611_095827_145546_576742BA X-CRM114-Status: GOOD ( 27.62 ) X-Spam-Score: -7.6 (-------) X-Spam-Report: SpamAssassin version 3.4.0 on casper.infradead.org summary: Content analysis details: (-7.6 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [198.47.26.153 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [198.47.26.153 listed in wl.mailspike.net] -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -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.0 RCVD_IN_MSPIKE_WL Mailspike good senders Cc: devicetree@vger.kernel.org, nsekhar@ti.com, linux-kernel@vger.kernel.org, kyungmin.park@samsung.com, linux-mtd@lists.infradead.org, pekon@ti.com, ezequiel.garcia@free-electrons.com, javier@dowhile0.org, linux-omap@vger.kernel.org, Roger Quadros X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: rogerq@ti.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.181 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Move OneNAND specific device tree parsing to NAND driver. The OneNAND device node must have its own compatible id. Add a new property 'ti,onenand-sync-rw' to indicate synchronous read + write support. Default mode would be only synchronous reads. Signed-off-by: Roger Quadros --- .../devicetree/bindings/mtd/gpmc-onenand.txt | 4 + arch/arm/mach-omap2/gpmc-onenand.c | 14 ---- arch/arm/mach-omap2/gpmc.c | 55 +++---------- drivers/mtd/onenand/omap2.c | 90 ++++++++++++++++------ include/linux/platform_data/mtd-onenand-omap2.h | 4 +- 5 files changed, 84 insertions(+), 83 deletions(-) diff --git a/Documentation/devicetree/bindings/mtd/gpmc-onenand.txt b/Documentation/devicetree/bindings/mtd/gpmc-onenand.txt index b752942..7fc9c13 100644 --- a/Documentation/devicetree/bindings/mtd/gpmc-onenand.txt +++ b/Documentation/devicetree/bindings/mtd/gpmc-onenand.txt @@ -9,9 +9,12 @@ Documentation/devicetree/bindings/bus/ti-gpmc.txt Required properties: + - compatible: "ti,omap2-onenand" - reg: The CS line the peripheral is connected to - gpmc,device-width Width of the ONENAND device connected to the GPMC in bytes. Must be 1 or 2. + - ti,onenand-sync-rw: Bool. Enable synchronous Read and Write. If not + present, only Synchronous Read is enabled. Optional properties: @@ -35,6 +38,7 @@ Example for an OMAP3430 board: #size-cells = <1>; onenand@0 { + compatible = "ti,omap2-onenand" reg = <0 0 0>; /* CS0, offset 0 */ gpmc,device-width = <2>; diff --git a/arch/arm/mach-omap2/gpmc-onenand.c b/arch/arm/mach-omap2/gpmc-onenand.c index d09c342..37ed4f1 100644 --- a/arch/arm/mach-omap2/gpmc-onenand.c +++ b/arch/arm/mach-omap2/gpmc-onenand.c @@ -75,20 +75,6 @@ static int omap2_onenand_setup_async(struct omap_onenand_platform_data struct gpmc_device_timings dev_t; int ret; - if (gpmc_onenand_data->of_node) { - gpmc_read_settings_dt(gpmc_onenand_data->of_node, - &onenand_async); - if (onenand_async.sync_read || onenand_async.sync_write) { - if (onenand_async.sync_write) - gpmc_onenand_data->flags |= - ONENAND_SYNC_READWRITE; - else - gpmc_onenand_data->flags |= ONENAND_SYNC_READ; - onenand_async.sync_read = false; - onenand_async.sync_write = false; - } - } - ret = gpmc_cs_program_settings(gpmc_onenand_data->cs, &onenand_async); if (ret < 0) return ret; diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c index 50ef1a9..ee030cd 100644 --- a/arch/arm/mach-omap2/gpmc.c +++ b/arch/arm/mach-omap2/gpmc.c @@ -39,7 +39,6 @@ #include "common.h" #include "omap_device.h" #include "gpmc.h" -#include "gpmc-onenand.h" #define DEVICE_NAME "omap-gpmc" @@ -1166,43 +1165,6 @@ static void __maybe_unused gpmc_read_timings_dt(struct device_node *np, of_property_read_bool(np, "gpmc,time-para-granularity"); } -#if IS_ENABLED(CONFIG_MTD_ONENAND) -static int gpmc_probe_onenand_child(struct platform_device *pdev, - struct device_node *child) -{ - u32 val; - struct omap_onenand_platform_data *gpmc_onenand_data; - - if (of_property_read_u32(child, "reg", &val) < 0) { - dev_err(&pdev->dev, "%s has no 'reg' property\n", - child->full_name); - return -ENODEV; - } - - gpmc_onenand_data = devm_kzalloc(&pdev->dev, sizeof(*gpmc_onenand_data), - GFP_KERNEL); - if (!gpmc_onenand_data) - return -ENOMEM; - - gpmc_onenand_data->cs = val; - gpmc_onenand_data->of_node = child; - gpmc_onenand_data->dma_channel = -1; - - if (!of_property_read_u32(child, "dma-channel", &val)) - gpmc_onenand_data->dma_channel = val; - - gpmc_onenand_init(gpmc_onenand_data); - - return 0; -} -#else -static int gpmc_probe_onenand_child(struct platform_device *pdev, - struct device_node *child) -{ - return 0; -} -#endif - /** * gpmc_probe_generic_child - configures the gpmc for a child device * @pdev: pointer to gpmc platform device @@ -1292,6 +1254,12 @@ static int gpmc_probe_generic_child(struct platform_device *pdev, } gpmc_s.device_nand = true; + + } else if (of_node_cmp(child->name, "onenand") == 0) { + /* DT incorrectly sets sync modes, onenand default is async */ + gpmc_s.sync_read = false; + gpmc_s.sync_write = false; + } else { if (of_property_read_u32(child, "bank-width", &gpmc_s.device_width)) { @@ -1363,12 +1331,11 @@ static int gpmc_probe_dt(struct platform_device *pdev) if (!child->name) continue; - if (of_node_cmp(child->name, "onenand") == 0) - ret = gpmc_probe_onenand_child(pdev, child); - else if (of_node_cmp(child->name, "ethernet") == 0 || - of_node_cmp(child->name, "nor") == 0 || - of_node_cmp(child->name, "uart") == 0 || - of_node_cmp(child->name, "nand") == 0) + if (of_node_cmp(child->name, "ethernet") == 0 || + of_node_cmp(child->name, "nor") == 0 || + of_node_cmp(child->name, "uart") == 0 || + of_node_cmp(child->name, "nand") == 0 || + of_node_cmp(child->name, "onenand") == 0) ret = gpmc_probe_generic_child(pdev, child); if (WARN(ret < 0, "%s: probing gpmc child %s failed\n", diff --git a/drivers/mtd/onenand/omap2.c b/drivers/mtd/onenand/omap2.c index b6a9ec0..35d2d39 100644 --- a/drivers/mtd/onenand/omap2.c +++ b/drivers/mtd/onenand/omap2.c @@ -40,6 +40,10 @@ #include #include #include +#include +#include +#include +#include #define DRIVER_NAME "omap2-onenand" @@ -826,9 +830,33 @@ static void omap2_onenand_shutdown(struct platform_device *pdev) memset((__force void *)c->onenand.base, 0, ONENAND_BUFRAM_SIZE); } +static int omap2_onenand_get_dt_info(struct device *dev, + struct omap2_onenand *c) +{ + struct device_node *node = dev->of_node; + + /* Chip Select number */ + if (of_property_read_u32(node, "reg", &c->gpmc_cs) < 0) { + dev_err(dev, "No 'reg' property\n"); + return -EINVAL; + } + + /* Enable synchronous read by default */ + c->flags = ONENAND_SYNC_READ; + /* Enable synchronous write only if indicated by DT */ + if (of_property_read_bool(node, "ti,onenand-sync-rw")) + c->flags = ONENAND_SYNC_READWRITE; + + /* TODO: DMA channel, GPIO IRQ for wait */ + c->dma_channel = -1; + c->gpio_irq = -EINVAL; + + return 0; +} + static int omap2_onenand_probe(struct platform_device *pdev) { - struct omap_onenand_platform_data *pdata; + struct omap_onenand_platform_data *pdata = NULL; struct omap2_onenand *c; struct onenand_chip *this; int r; @@ -836,28 +864,40 @@ static int omap2_onenand_probe(struct platform_device *pdev) struct mtd_part_parser_data ppdata = {}; struct device *dev = &pdev->dev; - pdata = dev_get_platdata(&pdev->dev); - if (pdata == NULL) { - dev_err(&pdev->dev, "platform data missing\n"); - return -ENODEV; - } - c = devm_kzalloc(dev, sizeof(struct omap2_onenand), GFP_KERNEL); if (!c) return -ENOMEM; - init_completion(&c->irq_done); - init_completion(&c->dma_done); - c->pdev = pdev; - c->flags = pdata->flags; - c->gpmc_cs = pdata->cs; - c->gpio_irq = pdata->gpio_irq; - c->dma_channel = pdata->dma_channel; + this = &c->onenand; + + if (dev->of_node) { + if (omap2_onenand_get_dt_info(dev, c)) + return -EINVAL; + + } else { + pdata = dev_get_platdata(dev); + if (pdata == NULL) { + dev_err(dev, "platform data missing\n"); + return -ENODEV; + } + + c->flags = pdata->flags; + c->gpio_irq = pdata->gpio_irq; + c->dma_channel = pdata->dma_channel; + + if (pdata->skip_initial_unlocking) + this->options |= ONENAND_SKIP_INITIAL_UNLOCKING; + } + if (c->dma_channel < 0) { /* if -1, don't use DMA */ c->gpio_irq = -EINVAL; } + init_completion(&c->irq_done); + init_completion(&c->dma_done); + c->pdev = pdev; + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); c->onenand.base = devm_ioremap_resource(dev, res); if (IS_ERR(c->onenand.base)) @@ -921,7 +961,6 @@ static int omap2_onenand_probe(struct platform_device *pdev) c->mtd.dev.parent = &pdev->dev; - this = &c->onenand; if (c->dma_channel >= 0) { this->wait = omap2_onenand_wait; if (c->flags & ONENAND_IN_OMAP34XX) { @@ -933,19 +972,20 @@ static int omap2_onenand_probe(struct platform_device *pdev) } } - if (pdata->skip_initial_unlocking) - this->options |= ONENAND_SKIP_INITIAL_UNLOCKING; - r = onenand_scan(&c->mtd, 1); if (r) { dev_err(dev, "OneNAND scan failed :%d\n", r); goto err_release_dma; } - ppdata.of_node = pdata->of_node; - r = mtd_device_parse_register(&c->mtd, NULL, &ppdata, - pdata ? pdata->parts : NULL, - pdata ? pdata->nr_parts : 0); + if (dev->of_node) { + ppdata.of_node = dev->of_node; + r = mtd_device_parse_register(&c->mtd, NULL, &ppdata, NULL, 0); + + } else { + r = mtd_device_register(&c->mtd, pdata->parts, pdata->nr_parts); + } + if (r) goto err_release_onenand; @@ -974,6 +1014,11 @@ static int omap2_onenand_remove(struct platform_device *pdev) return 0; } +static const struct of_device_id omap2_onenand_ids[] = { + { .compatible = "ti,omap2-onenand", }, + {}, +}; + static struct platform_driver omap2_onenand_driver = { .probe = omap2_onenand_probe, .remove = omap2_onenand_remove, @@ -981,6 +1026,7 @@ static struct platform_driver omap2_onenand_driver = { .driver = { .name = DRIVER_NAME, .owner = THIS_MODULE, + .of_match_table = of_match_ptr(omap2_onenand_ids), }, }; diff --git a/include/linux/platform_data/mtd-onenand-omap2.h b/include/linux/platform_data/mtd-onenand-omap2.h index ac1e6f3..99d8716 100644 --- a/include/linux/platform_data/mtd-onenand-omap2.h +++ b/include/linux/platform_data/mtd-onenand-omap2.h @@ -26,10 +26,8 @@ struct omap_onenand_platform_data { u8 flags; u8 skip_initial_unlocking; - /* for passing the partitions */ - struct device_node *of_node; - u8 regulator_can_sleep; /* deprecated */ int (*onenand_setup)(void __iomem *, int *freq_ptr); /* deprecated */ + struct device_node *of_node; /* deprecated */ }; #endif