From patchwork Tue Feb 26 22:37:45 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 223422 X-Patchwork-Delegate: scottwood@freescale.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id D9AD62C007E for ; Wed, 27 Feb 2013 09:44:50 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C220E4A03F; Tue, 26 Feb 2013 23:44:47 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PeaDlsVe2Rz4; Tue, 26 Feb 2013 23:44:47 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B68164A02E; Tue, 26 Feb 2013 23:44:44 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id EC0074A02E for ; Tue, 26 Feb 2013 23:44:42 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mqgchune17IG for ; Tue, 26 Feb 2013 23:44:42 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-gh0-f178.google.com (mail-gh0-f178.google.com [209.85.160.178]) by theia.denx.de (Postfix) with ESMTPS id D7A414A02D for ; Tue, 26 Feb 2013 23:44:40 +0100 (CET) Received: by mail-gh0-f178.google.com with SMTP id g24so804611ghb.9 for ; Tue, 26 Feb 2013 14:44:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=L/5uxF7gYeTbzqHC5BSl+DK7K1zOzGLX0DVkZEn6DLU=; b=F8oLudrvLXtFsVIk6m7uSmt7X41QofsSG6v1pDqA29l9FQhMbDeEXVR+vLsQHRYFsz rrZYLIOt+P20UJvnqlnke2I4hFTvplflVmRQdl3IPEffuqzh7C5/Q1YaKe7B0yT9M9C5 07SfwXYAbFx+vRIss5STPRiREU0o4kJN/Y0lJZ3ettkudTDtonW2rdxiqQ4KEsx26aDT O2QjLYB2fMeDPufi+UlP6tU6CGkGUUrNH56Dc7e5Pr0YKjiiD5EBcdMq96LqgHGNlIaj lQvYU4h/FcA4sBT0QngoXhQZDrewVzAfG95l7pL2Xc79ZZFl+rpiz14genPYn08UiQQy fKcg== X-Received: by 10.236.69.99 with SMTP id m63mr7681yhd.46.1361918280092; Tue, 26 Feb 2013 14:38:00 -0800 (PST) Received: from localhost.localdomain ([201.82.139.132]) by mx.google.com with ESMTPS id f3sm2310968ani.3.2013.02.26.14.37.57 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 26 Feb 2013 14:37:59 -0800 (PST) From: Fabio Estevam To: scottwood@freescale.com Date: Tue, 26 Feb 2013 19:37:45 -0300 Message-Id: <1361918265-28683-2-git-send-email-festevam@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1361918265-28683-1-git-send-email-festevam@gmail.com> References: <1361918265-28683-1-git-send-email-festevam@gmail.com> Cc: marex@denx.de, u-boot@lists.denx.de, Fabio Estevam Subject: [U-Boot] [PATCH v3 2/2] mtd: nand: mxc_nand: Fix is_16bit_nand() X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de From: Fabio Estevam Currently is_16bit_nand() is a per SoC function and it decides the bus nand width by reading some boot related registers. This method works when NAND is the boot medium, but does not work if another boot medium is used. For example: booting from a SD card and then using NAND to store the environment variables, would lead to the following error: NAND bus width 16 instead 8 bit No NAND device found!!! 0 MiB Use CONFIG_SYS_NAND_BUSWIDTH_16BIT symbol to decide the bus width. If it is defined in the board file, then consider 16-bit NAND bus-width, otherwise assume 8-bit NAND is used. This also aligns with Documentation/devicetree/bindings/mtd/nand.txt, which states: nand-bus-width : 8 or 16 bus width if not present 8 Signed-off-by: Fabio Estevam Reviewed-by: Benoît Thébaudeau --- Changes since v2: - Fix typo "if not present 82" Changes since v1: - Add an entry into README README | 3 ++- drivers/mtd/nand/mxc_nand.c | 37 +++---------------------------------- 2 files changed, 5 insertions(+), 35 deletions(-) diff --git a/README b/README index bdd2c81..1a6a7a5 100644 --- a/README +++ b/README @@ -3717,8 +3717,9 @@ Low Level (hardware related) configuration options: Defined to tell the NAND controller that the NAND chip is using a 16 bit bus. Not all NAND drivers use this symbol. - Example of driver that uses it: + Example of drivers that use it: - drivers/mtd/nand/ndfc.c + - drivers/mtd/nand/mxc_nand.c - CONFIG_SYS_NDFC_EBC0_CFG Sets the EBC0_CFG register for the NDFC. If not defined diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c index d0ded48..bb475f2 100644 --- a/drivers/mtd/nand/mxc_nand.c +++ b/drivers/mtd/nand/mxc_nand.c @@ -98,45 +98,14 @@ static struct nand_ecclayout nand_hw_eccoob2k = { #endif #endif -#ifdef CONFIG_MX27 static int is_16bit_nand(void) { - struct system_control_regs *sc_regs = - (struct system_control_regs *)IMX_SYSTEM_CTL_BASE; - - if (readl(&sc_regs->fmcr) & NF_16BIT_SEL) - return 1; - else - return 0; -} -#elif defined(CONFIG_MX31) -static int is_16bit_nand(void) -{ - struct clock_control_regs *sc_regs = - (struct clock_control_regs *)CCM_BASE; - - if (readl(&sc_regs->rcsr) & CCM_RCSR_NF16B) - return 1; - else - return 0; -} -#elif defined(CONFIG_MX25) || defined(CONFIG_MX35) -static int is_16bit_nand(void) -{ - struct ccm_regs *ccm = (struct ccm_regs *)IMX_CCM_BASE; - - if (readl(&ccm->rcsr) & CCM_RCSR_NF_16BIT_SEL) - return 1; - else - return 0; -} +#if defined(CONFIG_SYS_NAND_BUSWIDTH_16BIT) + return 1; #else -#warning "8/16 bit NAND autodetection not supported" -static int is_16bit_nand(void) -{ return 0; -} #endif +} static uint32_t *mxc_nand_memcpy32(uint32_t *dest, uint32_t *source, size_t size) {