From patchwork Sun Oct 15 23:18:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ladislav Michl X-Patchwork-Id: 10007323 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 16C4560230 for ; Sun, 15 Oct 2017 23:18:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0668626212 for ; Sun, 15 Oct 2017 23:18:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EDE15262FF; Sun, 15 Oct 2017 23:18:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 63A5926212 for ; Sun, 15 Oct 2017 23:18:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751358AbdJOXSq (ORCPT ); Sun, 15 Oct 2017 19:18:46 -0400 Received: from eddie.linux-mips.org ([148.251.95.138]:44780 "EHLO cvs.linux-mips.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751235AbdJOXSq (ORCPT ); Sun, 15 Oct 2017 19:18:46 -0400 Received: (from localhost user: 'ladis' uid#1021 fake: STDIN (ladis@eddie.linux-mips.org)) by eddie.linux-mips.org id S23990398AbdJOXSpCeBFK (ORCPT ); Mon, 16 Oct 2017 01:18:45 +0200 Date: Mon, 16 Oct 2017 01:18:44 +0200 From: Ladislav Michl To: linux-omap@vger.kernel.org Cc: Roger Quadros , Tony Lindgren Subject: [PATCH 03/11] ARM: OMAP2+: gpmc-onenand: Drop global latency variable Message-ID: <20171015231844.5e443ncnf25r7cqd@lenoch> References: <20171015231641.zt5fz6fidp5eczf6@lenoch> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20171015231641.zt5fz6fidp5eczf6@lenoch> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP As latency is needed only to set ONENAND_REG_SYS_CFG1, it does not to be a global variable. Return it from sync timings calculation function. Also first set_onenand_cfg call from omap2_onenand_setup_sync is useless as latency was zero at that time and OneNAND SYS_CFG1 register was updated later in setup function with proper value. HF and VHF SYS_CFG1 flags are based on latency, so drop their global flags and set them from latency parameter directly in set_onenand_cfg. Signed-off-by: Ladislav Michl --- arch/arm/mach-omap2/gpmc-onenand.c | 48 ++++++++++++++------------------------ 1 file changed, 18 insertions(+), 30 deletions(-) diff --git a/arch/arm/mach-omap2/gpmc-onenand.c b/arch/arm/mach-omap2/gpmc-onenand.c index 3b50b9b5cb2f..9f3828cc2734 100644 --- a/arch/arm/mach-omap2/gpmc-onenand.c +++ b/arch/arm/mach-omap2/gpmc-onenand.c @@ -27,11 +27,8 @@ #define ONENAND_FLAG_SYNCREAD (1 << 0) #define ONENAND_FLAG_SYNCWRITE (1 << 1) -#define ONENAND_FLAG_HF (1 << 2) -#define ONENAND_FLAG_VHF (1 << 3) static unsigned onenand_flags; -static unsigned latency; static struct omap_onenand_platform_data *gpmc_onenand_data; @@ -86,12 +83,16 @@ static void omap2_onenand_set_async_mode(void __iomem *onenand_base) writew(reg, onenand_base + ONENAND_REG_SYS_CFG1); } -static void set_onenand_cfg(void __iomem *onenand_base) +static void set_onenand_cfg(void __iomem *onenand_base, int latency) { u32 reg = ONENAND_SYS_CFG1_RDY | ONENAND_SYS_CFG1_INT; - reg |= (latency << ONENAND_SYS_CFG1_BRL_SHIFT) | + reg |= (latency << ONENAND_SYS_CFG1_BRL_SHIFT) | ONENAND_SYS_CFG1_BL_16; + if (latency > 5) + reg |= ONENAND_SYS_CFG1_HF; + if (latency > 7) + reg |= ONENAND_SYS_CFG1_VHF; if (onenand_flags & ONENAND_FLAG_SYNCREAD) reg |= ONENAND_SYS_CFG1_SYNC_READ; else @@ -100,14 +101,6 @@ static void set_onenand_cfg(void __iomem *onenand_base) reg |= ONENAND_SYS_CFG1_SYNC_WRITE; else reg &= ~ONENAND_SYS_CFG1_SYNC_WRITE; - if (onenand_flags & ONENAND_FLAG_HF) - reg |= ONENAND_SYS_CFG1_HF; - else - reg &= ~ONENAND_SYS_CFG1_HF; - if (onenand_flags & ONENAND_FLAG_VHF) - reg |= ONENAND_SYS_CFG1_VHF; - else - reg &= ~ONENAND_SYS_CFG1_VHF; writew(reg, onenand_base + ONENAND_REG_SYS_CFG1); } @@ -142,7 +135,7 @@ static int omap2_onenand_get_freq(struct omap_onenand_platform_data *cfg, return freq; } -static void omap2_onenand_calc_sync_timings(struct gpmc_timings *t, +static int omap2_onenand_calc_sync_timings(struct gpmc_timings *t, struct gpmc_settings *s, unsigned int flags, int freq) @@ -154,7 +147,7 @@ static void omap2_onenand_calc_sync_timings(struct gpmc_timings *t, const int t_wpl = 40; const int t_wph = 30; int min_gpmc_clk_period, t_ces, t_avds, t_avdh, t_ach, t_aavdh, t_rdyo; - int div, gpmc_clk_ns; + int div, gpmc_clk_ns, latency; if (flags & ONENAND_SYNC_READ) onenand_flags = ONENAND_FLAG_SYNCREAD; @@ -203,19 +196,11 @@ static void omap2_onenand_calc_sync_timings(struct gpmc_timings *t, div = gpmc_calc_divider(min_gpmc_clk_period); gpmc_clk_ns = gpmc_ticks_to_ns(div); - if (gpmc_clk_ns < 15) /* >66MHz */ - onenand_flags |= ONENAND_FLAG_HF; - else - onenand_flags &= ~ONENAND_FLAG_HF; - if (gpmc_clk_ns < 12) /* >83MHz */ - onenand_flags |= ONENAND_FLAG_VHF; - else - onenand_flags &= ~ONENAND_FLAG_VHF; - if (onenand_flags & ONENAND_FLAG_VHF) + if (gpmc_clk_ns < 12) /* >83 MHz */ latency = 8; - else if (onenand_flags & ONENAND_FLAG_HF) + else if (gpmc_clk_ns < 15) /* >66 MHz */ latency = 6; - else if (gpmc_clk_ns >= 25) /* 40 MHz*/ + else if (gpmc_clk_ns >= 25) /* 40 MHz */ latency = 3; else latency = 4; @@ -251,6 +236,8 @@ static void omap2_onenand_calc_sync_timings(struct gpmc_timings *t, dev_t.t_rdyo = t_rdyo * 1000 + min_gpmc_clk_period; gpmc_calc_timings(t, s, &dev_t); + + return latency; } static int omap2_onenand_setup_async(void __iomem *onenand_base) @@ -291,7 +278,7 @@ static int omap2_onenand_setup_async(void __iomem *onenand_base) static int omap2_onenand_setup_sync(void __iomem *onenand_base, int *freq_ptr) { - int ret, freq = *freq_ptr; + int ret, latency, freq = *freq_ptr; struct gpmc_timings t; struct gpmc_settings s; @@ -300,12 +287,13 @@ static int omap2_onenand_setup_sync(void __iomem *onenand_base, int *freq_ptr) freq = omap2_onenand_get_freq(gpmc_onenand_data, onenand_base); if (!freq) return -ENODEV; - set_onenand_cfg(onenand_base); } gpmc_read_settings_dt(gpmc_onenand_data->of_node, &s); - omap2_onenand_calc_sync_timings(&t, &s, gpmc_onenand_data->flags, freq); + latency = omap2_onenand_calc_sync_timings(&t, &s, + gpmc_onenand_data->flags, + freq); ret = gpmc_cs_program_settings(gpmc_onenand_data->cs, &s); if (ret < 0) @@ -315,7 +303,7 @@ static int omap2_onenand_setup_sync(void __iomem *onenand_base, int *freq_ptr) if (ret < 0) return ret; - set_onenand_cfg(onenand_base); + set_onenand_cfg(onenand_base, latency); *freq_ptr = freq;