From patchwork Wed Jun 11 08:56:20 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 31737 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f72.google.com (mail-yh0-f72.google.com [209.85.213.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0517E203C2 for ; Wed, 11 Jun 2014 09:00:22 +0000 (UTC) Received: by mail-yh0-f72.google.com with SMTP id f10sf7116120yha.7 for ; Wed, 11 Jun 2014 02:00:22 -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=fa32lG63c4QgKO2rs4eW3FrBF0yzSU84yy9SJU6PsKA=; b=ToWAnnLWUwZptkh5kGKnjMf671sXEybK9bnD/I5pZ7xzIqTyxlUoeRTO16lwNMfmHs zRugg8NnbP6N2F7RJy3ET6I3OUR+g078NCVHbLR9vLkhEe6Yt64V1GWHw3X4J7drkObh 5E5RbfdZHWeSXNqYbM8TOYyn0Na3iVqqOxPPAVBpk909ZLCX+z3exr+NyRlrATxep0z7 d7Z1+BaUvXYMK3YOkFwO7qJhJwW7in/VsGLJ+vdtUYCuhGzt8lDrpIT3bjSDZyh2yMZO 5JLcSrjh/JZ+E+cwdsGpTD646sG5h6NYEr6BexqhiLXHbYqXEwm2/YJAZMT230kPOZul 6wZw== X-Gm-Message-State: ALoCoQnJ2sBD0xdNC3yP5YXCN2ExdqZPR7W5ndm7Fq+XWSUGiQb8BRs0XZYGNTnQCWESICIBcKI7 X-Received: by 10.236.141.11 with SMTP id f11mr466085yhj.54.1402477222601; Wed, 11 Jun 2014 02:00:22 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.107.97 with SMTP id g88ls2367481qgf.40.gmail; Wed, 11 Jun 2014 02:00:22 -0700 (PDT) X-Received: by 10.220.133.197 with SMTP id g5mr37583807vct.20.1402477222473; Wed, 11 Jun 2014 02:00:22 -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 db10si13997519vdb.49.2014.06.11.02.00.22 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 11 Jun 2014 02:00:22 -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 jz11so6242114veb.30 for ; Wed, 11 Jun 2014 02:00:22 -0700 (PDT) X-Received: by 10.52.110.105 with SMTP id hz9mr2294766vdb.9.1402477222375; Wed, 11 Jun 2014 02:00:22 -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 vs6csp286556vcb; Wed, 11 Jun 2014 02:00:21 -0700 (PDT) X-Received: by 10.140.109.201 with SMTP id l67mr47230967qgf.72.1402477221848; Wed, 11 Jun 2014 02:00:21 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id d4si30608604qai.92.2014.06.11.02.00.21 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Jun 2014 02:00:21 -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 1WueMT-0002Uz-RD; Wed, 11 Jun 2014 08:58:25 +0000 Received: from arroyo.ext.ti.com ([192.94.94.40]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WueM5-0001vZ-Lz; Wed, 11 Jun 2014 08:58:02 +0000 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id s5B8vgtW004405; Wed, 11 Jun 2014 03:57:42 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id s5B8vg4u021018; Wed, 11 Jun 2014 03:57:42 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.174.1; Wed, 11 Jun 2014 03:57:41 -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 s5B8uiSn020510; Wed, 11 Jun 2014 03:57:38 -0500 From: Roger Quadros To: , , Subject: [PATCH 15/36] ARM: OMAP2+: gpmc: Allow drivers to query GPMC_CLK period Date: Wed, 11 Jun 2014 11:56:20 +0300 Message-ID: <1402477001-31132-16-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_015801_810251_0537B43A X-CRM114-Status: GOOD ( 13.23 ) 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 ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [192.94.94.40 listed in wl.mailspike.net] -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [192.94.94.40 listed in list.dnswl.org] -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 GPMC_CLK is the external clock output pin that is used for syncronous accesses. Device drivers need to know the fastest possible GPMC_CLK period in order to calculate the most optimal device timings. Add the function omap_gpmc_get_clk_period() to allow drivers to get the nearset possible (equal to or greater than) GPMC_CLK period given the minimum clock period supported by the attached device. This is especially needed by the onenand driver as it calculates device timings on the fly for various onenand speed grades. Signed-off-by: Roger Quadros --- arch/arm/mach-omap2/gpmc.c | 38 +++++++++++++++++++++++++++++++++ include/linux/platform_data/gpmc-omap.h | 8 +++++++ 2 files changed, 46 insertions(+) diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c index 90b7686..50ef1a9 100644 --- a/arch/arm/mach-omap2/gpmc.c +++ b/arch/arm/mach-omap2/gpmc.c @@ -1578,6 +1578,44 @@ int omap_gpmc_retime(int cs, struct gpmc_settings *gpmc_s, } EXPORT_SYMBOL_GPL(omap_gpmc_retime); +/** + * omap_gpmc_get_clk_period - Get the nearest possible (equal to or higer) GPMC + * synchronous clock (GPMC_CLK) period. + * + * @cs Chip select number + * @min_ps Minimum synchronous clock period supporded by the device + * + * Returns the nearest possible GPMC clock period in picoseconds, equal to or + * higher than the requested period. 0 in case of error. + */ +unsigned long omap_gpmc_get_clk_period(int cs, + unsigned long min_ps) +{ + int div; + unsigned long clk_ps; + struct device *dev = gpmc_dev; + + if (!gpmc_dev) + return 0; + + if (cs < 0 || cs >= gpmc_cs_num) { + dev_err(dev, "%s: Invalid Chip Select\n", __func__); + return cs; + } + + div = gpmc_calc_divider(min_ps); + if (div < 0) { + dev_err(dev, "%s: Can't support requested clock period %lu ps\n", + __func__, min_ps); + return 0; + } + + clk_ps = gpmc_get_fclk_period() * div; + + return clk_ps; +} +EXPORT_SYMBOL_GPL(omap_gpmc_get_clk_period); + static struct omap3_gpmc_regs gpmc_context; void omap3_gpmc_save_context(void) diff --git a/include/linux/platform_data/gpmc-omap.h b/include/linux/platform_data/gpmc-omap.h index 0d40c2a..05e4b6f 100644 --- a/include/linux/platform_data/gpmc-omap.h +++ b/include/linux/platform_data/gpmc-omap.h @@ -169,6 +169,8 @@ struct gpmc_omap_platform_data { #ifdef CONFIG_ARCH_OMAP2PLUS int omap_gpmc_retime(int cs, struct gpmc_settings *gpmc_s, struct gpmc_device_timings *dev_t); +unsigned long omap_gpmc_get_clk_period(int cs, + unsigned long min_ps); #else static inline int omap_gpmc_retime(int cs, struct gpmc_settings *gpmc_s, @@ -176,6 +178,12 @@ static inline int omap_gpmc_retime(int cs, { return 0; } + +static inline unsigned long omap_gpmc_get_clk_period(int cs, + unsigned long min_ps) +{ + return 0; +} #endif /* CONFIG_ARCH_OMAP2PLUS */ #endif /* _GPMC_OMAP_H */