From patchwork Sat Jan 19 22:27:57 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 2007401 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 7B41B3FE1F for ; Sat, 19 Jan 2013 22:28:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752021Ab3ASW2n (ORCPT ); Sat, 19 Jan 2013 17:28:43 -0500 Received: from mail.free-electrons.com ([94.23.35.102]:49272 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751964Ab3ASW2m (ORCPT ); Sat, 19 Jan 2013 17:28:42 -0500 Received: by mail.free-electrons.com (Postfix, from userid 106) id 686F46669; Sat, 19 Jan 2013 23:28:40 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on mail.free-electrons.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.3.2 Received: from localhost.localdomain (20.222.3.200.ros.express.com.ar [200.3.222.20]) by mail.free-electrons.com (Postfix) with ESMTPA id 2CDEEEF8; Sat, 19 Jan 2013 23:28:35 +0100 (CET) From: Ezequiel Garcia To: linux-omap@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-mtd@lists.infradead.org, devicetree-discuss@lists.ozlabs.org, thomas.petazzoni@free-electrons.com, martinez.javier@gmail.com, zonque@gmail.com, grant.likely@secretlab.ca, eballetbo@gmail.com, matthias.bgg@googlemail.com, jon-hunter@ti.com, b-cousson@ti.com, tony@atomide.com, Ezequiel Garcia , Ezequiel Garcia Subject: [PATCH v2 3/3] arm: omap2: gpmc: add DT bindings for OneNAND Date: Sat, 19 Jan 2013 19:27:57 -0300 Message-Id: <1358634477-25868-3-git-send-email-ezequiel.garcia@free-electrons.com> X-Mailer: git-send-email 1.7.8.6 In-Reply-To: <1358634477-25868-1-git-send-email-ezequiel.garcia@free-electrons.com> References: <1358634477-25868-1-git-send-email-ezequiel.garcia@free-electrons.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org This patch adds device tree bindings for OMAP OneNAND devices. Tested on an OMAP3 3430 IGEPv2 board. Signed-off-by: Ezequiel Garcia --- Changes from v1: * Fix typo in Documentation/devicetree/bindings/mtd/gpmc-onenand.txt .../devicetree/bindings/mtd/gpmc-onenand.txt | 43 +++++++++++++++++++ arch/arm/mach-omap2/gpmc.c | 44 ++++++++++++++++++++ 2 files changed, 87 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/mtd/gpmc-onenand.txt diff --git a/Documentation/devicetree/bindings/mtd/gpmc-onenand.txt b/Documentation/devicetree/bindings/mtd/gpmc-onenand.txt new file mode 100644 index 0000000..deec9da --- /dev/null +++ b/Documentation/devicetree/bindings/mtd/gpmc-onenand.txt @@ -0,0 +1,43 @@ +Device tree bindings for GPMC connected OneNANDs + +GPMC connected OneNAND (found on OMAP boards) are represented as child nodes of +the GPMC controller with a name of "onenand". + +All timing relevant properties as well as generic gpmc child properties are +explained in a separate documents - please refer to +Documentation/devicetree/bindings/bus/ti-gpmc.txt + +Required properties: + + - reg: The CS line the peripheral is connected to + +Optional properties: + + - dma-channel: DMA Channel index + +For inline partiton table parsing (optional): + + - #address-cells: should be set to 1 + - #size-cells: should be set to 1 + +Example for an OMAP3430 board: + + gpmc: gpmc@6e000000 { + compatible = "ti,omap3430-gpmc"; + ti,hwmods = "gpmc"; + reg = <0x6e000000 0x1000000>; + interrupts = <20>; + gpmc,num-cs = <8>; + gpmc,num-waitpins = <4>; + #address-cells = <2>; + #size-cells = <1>; + + onenand@0 { + reg = <0 0 0>; /* CS0, offset 0 */ + + #address-cells = <1>; + #size-cells = <1>; + + /* partitions go here */ + }; + }; diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c index 01ce462..f7de9eb 100644 --- a/arch/arm/mach-omap2/gpmc.c +++ b/arch/arm/mach-omap2/gpmc.c @@ -39,6 +39,7 @@ #include "omap_device.h" #include "gpmc.h" #include "gpmc-nand.h" +#include "gpmc-onenand.h" #define DEVICE_NAME "omap-gpmc" @@ -1259,6 +1260,43 @@ static int gpmc_probe_nand_child(struct platform_device *pdev, } #endif +#ifdef 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 + static int gpmc_probe_dt(struct platform_device *pdev) { int ret; @@ -1276,6 +1314,12 @@ static int gpmc_probe_dt(struct platform_device *pdev) return ret; } + for_each_node_by_name(child, "onenand") { + ret = gpmc_probe_onenand_child(pdev, child); + of_node_put(child); + if (ret < 0) + return ret; + } return 0; } #else