From patchwork Fri Feb 8 09:14:47 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Enric Balletbo Serra X-Patchwork-Id: 219072 X-Patchwork-Delegate: trini@ti.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 584022C008C for ; Fri, 8 Feb 2013 20:21:17 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D1F804A0F9; Fri, 8 Feb 2013 10:21:15 +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 WnFugiFZ4LAr; Fri, 8 Feb 2013 10:21:15 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 43ECF4A099; Fri, 8 Feb 2013 10:21:13 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 90B104A099 for ; Fri, 8 Feb 2013 10:21:10 +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 0vk4ZV9Sq9I0 for ; Fri, 8 Feb 2013 10:21:10 +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-wi0-f173.google.com (mail-wi0-f173.google.com [209.85.212.173]) by theia.denx.de (Postfix) with ESMTPS id 96FA54A0A9 for ; Fri, 8 Feb 2013 10:21:02 +0100 (CET) Received: by mail-wi0-f173.google.com with SMTP id hq4so556989wib.0 for ; Fri, 08 Feb 2013 01:21:01 -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=I9tmappDoKJ7N3qwmFd12kOVMAkFf4kHAqQt8FaD+DE=; b=g/08aLsBiQS+GKSMNJYdYkMsMD8HzCyW+8ewDtMl5073cke7QbviWDwZc9egnpJMVA Fc2qDc47Q/FiHEgL9+GrK1U2DXQA7/JB37x992PNWTWxTRKhM8nKb/exL6/GO4fKQLlp vbtAJzI5IWmdtcNPH5sfgYexjm2oKxAY60bmlOTcWGmiW8Ka5DASd/ibtusr223TMA6F JnYIMaI9lkZGWXICLAvCu7LPWrcnSQXy0xDZZBuiFLYmZNU/jKogpq7mMHUs7qsEi8hj iPoOsD4s3rmryGKiWzZ0Sf2oOPeiROPImhSXAh33HehCjwwJ2y6bZzWlHgusQdLtCi6B fg0w== X-Received: by 10.180.101.99 with SMTP id ff3mr999132wib.21.1360314915214; Fri, 08 Feb 2013 01:15:15 -0800 (PST) Received: from localhost.localdomain (43.Red-2-139-180.staticIP.rima-tde.net. [2.139.180.43]) by mx.google.com with ESMTPS id fx5sm14176704wib.11.2013.02.08.01.15.14 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 08 Feb 2013 01:15:14 -0800 (PST) From: Enric Balletbo i Serra To: u-boot@lists.denx.de, trini@ti.com, javier@dowhile0.org, elezegarcia@gmail.com Date: Fri, 8 Feb 2013 10:14:47 +0100 Message-Id: <1360314889-16955-3-git-send-email-eballetbo@gmail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1360314889-16955-1-git-send-email-eballetbo@gmail.com> References: <1360314889-16955-1-git-send-email-eballetbo@gmail.com> Cc: Enric Balletbo i Serra Subject: [U-Boot] [PATCHv2 2/4] SPL: ONENAND: Fix onenand_spl_load_image implementation. 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: Enric Balletbo i Serra Tested with an IGEPv2 board seems that current onenand_spl_load_image implementation doesn't work. This patch fixes this function changing the read loop and reading the onenand blocks from page to page. Tested with various IGEP based boards with a OneNAND from Numonyx. Signed-off-by: Enric Balletbo i Serra --- drivers/mtd/onenand/onenand_spl.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/mtd/onenand/onenand_spl.c b/drivers/mtd/onenand/onenand_spl.c index 50eaa71..4bec2c2 100644 --- a/drivers/mtd/onenand/onenand_spl.c +++ b/drivers/mtd/onenand/onenand_spl.c @@ -112,7 +112,7 @@ static int onenand_spl_read_page(uint32_t block, uint32_t page, uint32_t *buf, void onenand_spl_load_image(uint32_t offs, uint32_t size, void *dst) { uint32_t *addr = (uint32_t *)dst; - uint32_t total_pages; + uint32_t to_page; uint32_t block; uint32_t page, rpage; enum onenand_spl_pagesize pagesize; @@ -125,22 +125,20 @@ void onenand_spl_load_image(uint32_t offs, uint32_t size, void *dst) * pulling further unwanted functions into the SPL. */ if (pagesize == 2048) { - total_pages = DIV_ROUND_UP(size, 2048); page = offs / 2048; + to_page = page + DIV_ROUND_UP(size, 2048); } else { - total_pages = DIV_ROUND_UP(size, 4096); page = offs / 4096; + to_page = page + DIV_ROUND_UP(size, 4096); } - for (; page <= total_pages; page++) { + for (; page <= to_page; page++) { block = page / ONENAND_PAGES_PER_BLOCK; rpage = page & (ONENAND_PAGES_PER_BLOCK - 1); ret = onenand_spl_read_page(block, rpage, addr, pagesize); - if (ret) { - total_pages += ONENAND_PAGES_PER_BLOCK; + if (ret) page += ONENAND_PAGES_PER_BLOCK - 1; - } else { + else addr += pagesize / 4; - } } }