From patchwork Fri Jun 12 12:07:59 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Hunter X-Patchwork-Id: 29757 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n5CC8EfP029124 for ; Fri, 12 Jun 2009 12:08:15 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753780AbZFLMHx (ORCPT ); Fri, 12 Jun 2009 08:07:53 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754409AbZFLMHx (ORCPT ); Fri, 12 Jun 2009 08:07:53 -0400 Received: from smtp.nokia.com ([192.100.105.134]:43356 "EHLO mgw-mx09.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753780AbZFLMHw (ORCPT ); Fri, 12 Jun 2009 08:07:52 -0400 Received: from vaebh106.NOE.Nokia.com (vaebh106.europe.nokia.com [10.160.244.32]) by mgw-mx09.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id n5CC7hO4020621; Fri, 12 Jun 2009 07:07:56 -0500 Received: from vaepf101.NOE.Nokia.com ([10.160.244.86]) by vaebh106.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 12 Jun 2009 15:07:06 +0300 Received: from [172.21.41.224] ([172.21.41.224]) by vaepf101.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 12 Jun 2009 15:07:06 +0300 Message-ID: <4A32451F.2010504@nokia.com> Date: Fri, 12 Jun 2009 15:07:59 +0300 From: Adrian Hunter User-Agent: Thunderbird 2.0.0.21 (X11/20090318) MIME-Version: 1.0 To: Tony Lindgren CC: linux-omap Mailing List Subject: [PATCH] OMAP: gpmc-onenand: correct use of async timings X-OriginalArrivalTime: 12 Jun 2009 12:07:06.0922 (UTC) FILETIME=[4E3EC0A0:01C9EB56] X-Nokia-AV: Clean Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org From 2766ff4a4087bae99463813b4a018ef9ebe498fc Mon Sep 17 00:00:00 2001 From: Adrian Hunter Date: Fri, 12 Jun 2009 14:39:22 +0300 Subject: [PATCH] OMAP: gpmc-onenand: correct use of async timings Use async timings when sync timings are not requested. Also ensure that OneNAND is in async mode when async timings are used. Signed-off-by: Adrian Hunter --- arch/arm/mach-omap2/gpmc-onenand.c | 21 +++++++++++++++++++-- 1 files changed, 19 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-omap2/gpmc-onenand.c b/arch/arm/mach-omap2/gpmc-onenand.c index 2fd22f9..54fec53 100644 --- a/arch/arm/mach-omap2/gpmc-onenand.c +++ b/arch/arm/mach-omap2/gpmc-onenand.c @@ -31,6 +31,8 @@ static struct platform_device gpmc_onenand_device = { static int omap2_onenand_set_async_mode(int cs, void __iomem *onenand_base) { struct gpmc_timings t; + u32 reg; + int err; const int t_cer = 15; const int t_avdp = 12; @@ -43,6 +45,11 @@ static int omap2_onenand_set_async_mode(int cs, void __iomem *onenand_base) const int t_wpl = 40; const int t_wph = 30; + /* Ensure sync read and sync write are disabled */ + reg = readw(onenand_base + ONENAND_REG_SYS_CFG1); + reg &= ~ONENAND_SYS_CFG1_SYNC_READ & ~ONENAND_SYS_CFG1_SYNC_WRITE; + writew(reg, onenand_base + ONENAND_REG_SYS_CFG1); + memset(&t, 0, sizeof(t)); t.sync_clk = 0; t.cs_on = 0; @@ -74,7 +81,16 @@ static int omap2_onenand_set_async_mode(int cs, void __iomem *onenand_base) GPMC_CONFIG1_DEVICESIZE_16 | GPMC_CONFIG1_MUXADDDATA); - return gpmc_cs_set_timings(cs, &t); + err = gpmc_cs_set_timings(cs, &t); + if (err) + return err; + + /* Ensure sync read and sync write are disabled */ + reg = readw(onenand_base + ONENAND_REG_SYS_CFG1); + reg &= ~ONENAND_SYS_CFG1_SYNC_READ & ~ONENAND_SYS_CFG1_SYNC_WRITE; + writew(reg, onenand_base + ONENAND_REG_SYS_CFG1); + + return 0; } static void set_onenand_cfg(void __iomem *onenand_base, int latency, @@ -124,7 +140,8 @@ static int omap2_onenand_set_sync_mode(struct omap_onenand_platform_data *cfg, } else if (cfg->flags & ONENAND_SYNC_READWRITE) { sync_read = 1; sync_write = 1; - } + } else + return omap2_onenand_set_async_mode(cs, onenand_base); if (!freq) { /* Very first call freq is not known */