From patchwork Wed Jun 11 08:56:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 31746 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f200.google.com (mail-ie0-f200.google.com [209.85.223.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 520A2203C2 for ; Wed, 11 Jun 2014 09:02:29 +0000 (UTC) Received: by mail-ie0-f200.google.com with SMTP id tr6sf19380081ieb.7 for ; Wed, 11 Jun 2014 02:02:28 -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=URy50muPc4+3UNWMP5UXm61sY7KwJuuHyziTKv2UHBM=; b=aI0OmSIKsUJodfytnjTbhRUUkjSIcCjiwTtMJeUAo6F3OS6bVgu1HN7wPPI1qlclX+ 65o8eSAhqLqxD3klI/LJDn5qs2KjAcK66bdunpsbV0odw7BV0qAOTM0vqNlFnpS2X0DV jkm3m2gk42AL0WNmHuUIcSnQ8s35GtUfHbZ3j7Z3tK8F2Pb41LCtRNQ2WfcN4/SHxmMb Meo3NqaE18q15HjFOTTWp+hSaU3wSGFfEndiax/b/gkSlZ1L1RmwaCqtuasXqxWQ/jW4 QZVF0w2eiaviAFPlGFL6y9YUva/lbY4e0m6cuHbkMlB76NVyT2JjfFcqKbt0aFYHejRd n5zg== X-Gm-Message-State: ALoCoQncS+LeMgmbwzRrLRw7oH1nVZ4JyHjXHiaL8ql8c/ldhhSdDYwJd2Aa8j8bGBX9MMXIXuVc X-Received: by 10.42.136.1 with SMTP id r1mr285132ict.24.1402477348845; Wed, 11 Jun 2014 02:02:28 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.50.16 with SMTP id r16ls2662134qga.71.gmail; Wed, 11 Jun 2014 02:02:28 -0700 (PDT) X-Received: by 10.52.232.133 with SMTP id to5mr1990099vdc.16.1402477348740; Wed, 11 Jun 2014 02:02:28 -0700 (PDT) Received: from mail-ve0-f171.google.com (mail-ve0-f171.google.com [209.85.128.171]) by mx.google.com with ESMTPS id o6si12753700vcn.83.2014.06.11.02.02.28 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 11 Jun 2014 02:02:28 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.171 as permitted sender) client-ip=209.85.128.171; Received: by mail-ve0-f171.google.com with SMTP id jz11so6125798veb.2 for ; Wed, 11 Jun 2014 02:02:28 -0700 (PDT) X-Received: by 10.52.121.19 with SMTP id lg19mr706011vdb.54.1402477348653; Wed, 11 Jun 2014 02:02:28 -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 vs6csp286733vcb; Wed, 11 Jun 2014 02:02:28 -0700 (PDT) X-Received: by 10.140.85.166 with SMTP id n35mr46148445qgd.67.1402477348187; Wed, 11 Jun 2014 02:02:28 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id k10si30655185qaj.33.2014.06.11.02.02.28 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Jun 2014 02:02:28 -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 1WueNg-0003nS-An; Wed, 11 Jun 2014 08:59:40 +0000 Received: from devils.ext.ti.com ([198.47.26.153]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WueMY-0002GV-W0; Wed, 11 Jun 2014 08:58:32 +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 s5B8w7qP027762; Wed, 11 Jun 2014 03:58:07 -0500 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id s5B8w7kc009452; Wed, 11 Jun 2014 03:58:07 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.174.1; Wed, 11 Jun 2014 03:58:06 -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 s5B8uiSu020510; Wed, 11 Jun 2014 03:58:03 -0500 From: Roger Quadros To: , , Subject: [PATCH 22/36] ARM: OMAP2+: gmpc: add gpmc_generic_init() Date: Wed, 11 Jun 2014 11:56:27 +0300 Message-ID: <1402477001-31132-23-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_015831_145292_ACB1E5FC X-CRM114-Status: GOOD ( 10.33 ) X-Spam-Score: -5.7 (-----) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-5.7 points) 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.0 SPF_PASS SPF: sender matches SPF record -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -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.171 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 This function populates platform data for the specified Chip Select. It should be called by board init code. Signed-off-by: Roger Quadros --- arch/arm/mach-omap2/gpmc.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++ arch/arm/mach-omap2/gpmc.h | 6 ++++ 2 files changed, 85 insertions(+) diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c index ee030cd..d3a64ed 100644 --- a/arch/arm/mach-omap2/gpmc.c +++ b/arch/arm/mach-omap2/gpmc.c @@ -30,6 +30,7 @@ #include #include #include +#include #include @@ -108,6 +109,8 @@ #define GPMC_NR_WAITPINS 4 +static struct gpmc_omap_platform_data gpmc_pdata; + /* Structure to save gpmc cs context */ struct gpmc_cs_config { u32 config1; @@ -1510,6 +1513,82 @@ static int __init omap_gpmc_init(void) omap_postcore_initcall(omap_gpmc_init); /** + * gpmc_generic_init - Initialize platform data for a Chip Select + * + * @cs chip select number + * @is_nand true if device is NAND flash. + * @settings GPMC settings + * @device_timings device timings for device on this CS + * @gpmc_timings GPMC timings + * @pdev platform device for the device on this CS + * @pdata_size platform data size for the platform device + */ +int gpmc_generic_init(int cs, bool is_nand, + struct gpmc_settings *settings, + struct gpmc_device_timings *device_timings, + struct gpmc_timings *gpmc_timings, + struct platform_device *pdev, unsigned pdata_size) +{ + struct gpmc_settings *gpmc_s = NULL; + struct gpmc_device_timings *gpmc_dev_t = NULL; + struct gpmc_timings *gpmc_t; + + if (cs >= GPMC_CS_NUM) { + pr_err("%s: Invalid cs specified. Max CS = %d\n", + __func__, GPMC_CS_NUM); + return -EINVAL; + } + + if (gpmc_pdata.cs[cs].valid) { + pr_err("%s: cs %d already requested, ignoring new request\n", + __func__, cs); + return -EINVAL; + } + + if (settings) { + gpmc_s = kmemdup(settings, sizeof(*settings), GFP_KERNEL); + if (!gpmc_s) + return -ENOMEM; + + gpmc_pdata.cs[cs].settings = gpmc_s; + } + + if (device_timings) { + gpmc_dev_t = kmemdup(device_timings, sizeof(*device_timings), + GFP_KERNEL); + if (!gpmc_dev_t) + goto dev_t_fail; + + gpmc_pdata.cs[cs].device_timings = gpmc_dev_t; + } + + if (gpmc_timings) { + gpmc_t = kmemdup(gpmc_timings, sizeof(*gpmc_timings), + GFP_KERNEL); + if (!gpmc_t) + goto gpmc_t_fail; + + gpmc_pdata.cs[cs].gpmc_timings = gpmc_t; + } + + gpmc_pdata.cs[cs].is_nand = is_nand; + gpmc_pdata.cs[cs].pdev = pdev; + gpmc_pdata.cs[cs].pdata_size = pdata_size; + gpmc_pdata.cs[cs].valid = true; + + return 0; + +gpmc_t_fail: + if (device_timings) + kfree(gpmc_dev_t); +dev_t_fail: + if (settings) + kfree(gpmc_s); + + return -ENOMEM; +} + +/** * omap_gpmc_retime - Reconfigre GPMC timings for the device * * @cs Chip select number diff --git a/arch/arm/mach-omap2/gpmc.h b/arch/arm/mach-omap2/gpmc.h index 6204913..301bc66 100644 --- a/arch/arm/mach-omap2/gpmc.h +++ b/arch/arm/mach-omap2/gpmc.h @@ -77,5 +77,11 @@ extern void omap3_gpmc_save_context(void); extern void omap3_gpmc_restore_context(void); extern void gpmc_read_settings_dt(struct device_node *np, struct gpmc_settings *p); +int gpmc_generic_init(int cs, bool is_nand, + struct gpmc_settings *settings, + struct gpmc_device_timings *device_timings, + struct gpmc_timings *gpmc_timings, + struct platform_device *pdev, + unsigned pdata_size); #endif