From patchwork Wed May 21 11:20:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 30534 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f197.google.com (mail-ob0-f197.google.com [209.85.214.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3A77A20671 for ; Wed, 21 May 2014 11:22:44 +0000 (UTC) Received: by mail-ob0-f197.google.com with SMTP id vb8sf7849188obc.8 for ; Wed, 21 May 2014 04:22:43 -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:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=cnhxbXG0WFV1FN9E2hcfDGyUwGui3upSRhhOXsLAqNQ=; b=P1rqoHQOfTR2acwfq/HQ840bo3kVlYgSP39xo2inVjmrfFWDmhPG/YrCUt9ddAwj0d O2KctxHn8ev7/C+t2TgKtbLikF2Sy/6tz8S13f24EpZ0zb9vzWQkTwqmK3eAjuweAEXO hId5UfgYobd2b36DX6vuj9n2dR98txtGASdcWUHHsS2mLhIPFtcAQnADRT2nBIl3R0kV /E9FvG6SmmKW/6uU1FNbd9t1h2mt2BHXG6jAb9equpNWeWho5wkSQbBR0l2S821fMH+f LN15mlIgdsahw78Dlaszj5Woej8jgDVc2doPdnBCKvqknKrGKGd1eLRJEaB1Xx9Dgyd8 Texg== X-Gm-Message-State: ALoCoQn9Lb35uKCEGBsF0nqvm/Tob9zyw6qqZnqmblE6W2FMllFwPrO+I4MaN3tL66A8fUQq+AXd X-Received: by 10.43.124.136 with SMTP id go8mr709757icc.26.1400671363793; Wed, 21 May 2014 04:22:43 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.39.37 with SMTP id u34ls654957qgu.4.gmail; Wed, 21 May 2014 04:22:43 -0700 (PDT) X-Received: by 10.220.105.4 with SMTP id r4mr9196144vco.27.1400671363617; Wed, 21 May 2014 04:22:43 -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 r1si2692149vcx.25.2014.05.21.04.22.43 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 21 May 2014 04:22:43 -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 oz11so2300624veb.30 for ; Wed, 21 May 2014 04:22:43 -0700 (PDT) X-Received: by 10.58.135.136 with SMTP id ps8mr15617434veb.18.1400671363514; Wed, 21 May 2014 04:22:43 -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.220.221.72 with SMTP id ib8csp104580vcb; Wed, 21 May 2014 04:22:43 -0700 (PDT) X-Received: by 10.68.139.137 with SMTP id qy9mr57558064pbb.11.1400671362625; Wed, 21 May 2014 04:22:42 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id vx5si28721296pab.104.2014.05.21.04.22.42; Wed, 21 May 2014 04:22:42 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752603AbaEULWb (ORCPT + 27 others); Wed, 21 May 2014 07:22:31 -0400 Received: from bear.ext.ti.com ([192.94.94.41]:53419 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752531AbaEULW0 (ORCPT ); Wed, 21 May 2014 07:22:26 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id s4LBLPTp010602; Wed, 21 May 2014 06:21:25 -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 s4LBLP86021037; Wed, 21 May 2014 06:21:25 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.3.174.1; Wed, 21 May 2014 06:21:25 -0500 Received: from localhost.localdomain (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id s4LBLAAY018495; Wed, 21 May 2014 06:21:22 -0500 From: Roger Quadros To: , CC: , , , , , , , , , , , Roger Quadros Subject: [RFC PATCH 03/16] ARM: OMAP2+: gmpc: add gpmc_generic_init() Date: Wed, 21 May 2014 14:20:51 +0300 Message-ID: <1400671264-10702-4-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1400671264-10702-1-git-send-email-rogerq@ti.com> References: <1400671264-10702-1-git-send-email-rogerq@ti.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 | 69 ++++++++++++++++++++++++++++++++++++++++++++++ arch/arm/mach-omap2/gpmc.h | 6 ++++ 2 files changed, 75 insertions(+) diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c index 9fe8c94..6b4a322 100644 --- a/arch/arm/mach-omap2/gpmc.c +++ b/arch/arm/mach-omap2/gpmc.c @@ -115,6 +115,8 @@ */ #define GPMC_NR_IRQ 2 +static struct gpmc_omap_platform_data gpmc_pdata; + struct gpmc_client_irq { unsigned irq; u32 bitmask; @@ -1787,6 +1789,73 @@ 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 + * @type GPMC_OMAP_TYPE + * @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, enum gpmc_omap_type type, + 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; + struct gpmc_device_timings *gpmc_dev_t; + 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) + return -ENOMEM; + + 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) + return -ENOMEM; + + gpmc_pdata.cs[cs].gpmc_timings = gpmc_t; + } + + gpmc_pdata.cs[cs].type = type; + gpmc_pdata.cs[cs].pdev = pdev; + gpmc_pdata.cs[cs].pdata_size = pdata_size; + gpmc_pdata.cs[cs].valid = true; + + return 0; +} + static irqreturn_t gpmc_handle_irq(int irq, void *dev) { int i; diff --git a/arch/arm/mach-omap2/gpmc.h b/arch/arm/mach-omap2/gpmc.h index 681977f..c18b022 100644 --- a/arch/arm/mach-omap2/gpmc.h +++ b/arch/arm/mach-omap2/gpmc.h @@ -100,5 +100,11 @@ extern void omap3_gpmc_restore_context(void); extern int gpmc_configure(int cmd, int wval); extern void gpmc_read_settings_dt(struct device_node *np, struct gpmc_settings *p); +extern int gpmc_generic_init(int cs, enum gpmc_omap_type type, + struct gpmc_settings *settings, + struct gpmc_device_timings *device_timings, + struct gpmc_timings *gpmc_timings, + struct platform_device *pdev, + unsigned pdata_size); #endif