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: 358555 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 7959B1400AB for ; Wed, 11 Jun 2014 19:01:48 +1000 (EST) 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: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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