From patchwork Wed Apr 4 18:36:26 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martinez Canillas X-Patchwork-Id: 7632 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 7745523ED0 for ; Wed, 4 Apr 2012 18:37:18 +0000 (UTC) Received: from mail-yx0-f180.google.com (mail-yx0-f180.google.com [209.85.213.180]) by fiordland.canonical.com (Postfix) with ESMTP id 30002A189C1 for ; Wed, 4 Apr 2012 18:37:18 +0000 (UTC) Received: by yenl4 with SMTP id l4so460354yen.11 for ; Wed, 04 Apr 2012 11:37:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=kNl3ujVgjSkb4W2vsUFhTDThyeE3x+aSl4tmS/+FMUQ=; b=HxrlpkRZHVVIYZwpLn39VtQTXKAxiIJfjyzfoO+52IVnV+DzM2OiRtt5vbqZI2I1Dq mvcMELZ0WpnR7f2ptKJZxaEK7sX86kvVD9c6H4rXTDzYWsauNP78pjeEiuTfdQIVuIJp pyaurGLM+H0SE6a35cz29mAGcGkq+fImEVJQWMEgrOs2K/uh/cyusWfkTICqKm9/Ue+p R9G7CchTk+Bk/E1AK/nBbMuUZpCKlAMXS331VmCjiByy4nEcCn16nzN5ESZ8DNq8PKGc qvfmTYezLtrSTS/CBPRy3Xig/zSfNBlW9Xg3Cym7Xqb27uHAuimJncXBVrrMM8m7i3Sg NDrw== Received: by 10.50.51.197 with SMTP id m5mr2626711igo.38.1333564637481; Wed, 04 Apr 2012 11:37:17 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.164.217 with SMTP id f25csp53404iby; Wed, 4 Apr 2012 11:37:16 -0700 (PDT) Received: by 10.180.94.33 with SMTP id cz1mr7758122wib.13.1333564635293; Wed, 04 Apr 2012 11:37:15 -0700 (PDT) Received: from mail-wi0-f170.google.com (mail-wi0-f170.google.com [209.85.212.170]) by mx.google.com with ESMTPS id f1si3206814wie.41.2012.04.04.11.37.14 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 04 Apr 2012 11:37:15 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.170 is neither permitted nor denied by best guess record for domain of javier@dowhile0.org) client-ip=209.85.212.170; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.170 is neither permitted nor denied by best guess record for domain of javier@dowhile0.org) smtp.mail=javier@dowhile0.org Received: by wibhr17 with SMTP id hr17so742644wib.1 for ; Wed, 04 Apr 2012 11:37:14 -0700 (PDT) Received: by 10.216.133.234 with SMTP id q84mr2066602wei.102.1333564633636; Wed, 04 Apr 2012 11:37:13 -0700 (PDT) Received: from localhost.localdomain ([188.77.211.255]) by mx.google.com with ESMTPS id 17sm7060020wis.0.2012.04.04.11.37.11 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 04 Apr 2012 11:37:12 -0700 (PDT) From: Javier Martinez Canillas To: Tony Lindgren Cc: Russell King , =?UTF-8?q?Enric=20Balletb=C3=B2=20i=20Serra?= , linux-omap@vger.kernel.org, linaro-kernel@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linaro-dev@lists.linaro.org, patches@linaro.org, Javier Martinez Canillas Subject: [RESEND PATCH 2/2] OMAP3: igep0020: Add support for Micron NAND Flash storage memory Date: Wed, 4 Apr 2012 20:36:26 +0200 Message-Id: <1333564586-3259-2-git-send-email-javier@dowhile0.org> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <1333564586-3259-1-git-send-email-javier@dowhile0.org> References: <1333564586-3259-1-git-send-email-javier@dowhile0.org> X-Gm-Message-State: ALoCoQkhAInSGW/F4KOdSwWblFDij0FRSXSQ0npaO40G9ZmBcx+kTgNVnk480xsHNHR56yICfdOy IGEP-based boards can have two different flash memories, a OneNAND or a NAND device. The boot configuration pins (sys_boot) are used to specify which memory is available. Also, this patch removes unnecesary code for registering the OneNAND. Signed-off-by: Javier Martinez Canillas Acked-by: Enric Balletbo i Serra Tested-by: Enric Balletbo i Serra --- arch/arm/mach-omap2/board-igep0020.c | 75 ++++++++++++++-------------------- 1 files changed, 31 insertions(+), 44 deletions(-) diff --git a/arch/arm/mach-omap2/board-igep0020.c b/arch/arm/mach-omap2/board-igep0020.c index 930c0d3..4af615a 100644 --- a/arch/arm/mach-omap2/board-igep0020.c +++ b/arch/arm/mach-omap2/board-igep0020.c @@ -24,6 +24,8 @@ #include #include +#include + #include #include @@ -39,6 +41,8 @@ #include "hsmmc.h" #include "sdram-numonyx-m65kxxxxam.h" #include "common-board-devices.h" +#include "board-flash.h" +#include "control.h" #define IGEP2_SMSC911X_CS 5 #define IGEP2_SMSC911X_GPIO 176 @@ -60,6 +64,10 @@ #define IGEP3_GPIO_LED1_RED 16 #define IGEP3_GPIO_USBH_NRESET 183 +#define IGEP_SYSBOOT_MASK 0x1f +#define IGEP_SYSBOOT_NAND 0x0f +#define IGEP_SYSBOOT_ONENAND 0x10 + /* * IGEP2 Hardware Revision Table * @@ -110,8 +118,10 @@ static void __init igep2_get_revision(void) gpio_free(IGEP2_GPIO_LED1_RED); } -#if defined(CONFIG_MTD_ONENAND_OMAP2) || \ - defined(CONFIG_MTD_ONENAND_OMAP2_MODULE) +#if defined(CONFIG_MTD_ONENAND_OMAP2) || \ + defined(CONFIG_MTD_ONENAND_OMAP2_MODULE) || \ + defined(CONFIG_MTD_NAND_OMAP2) || \ + defined(CONFIG_MTD_NAND_OMAP2_MODULE) #define ONENAND_MAP 0x20000000 @@ -123,7 +133,7 @@ static void __init igep2_get_revision(void) * So MTD regards it as 4KiB page size and 256KiB block size 64*(2*2048) */ -static struct mtd_partition igep_onenand_partitions[] = { +static struct mtd_partition igep_flash_partitions[] = { { .name = "X-Loader", .offset = 0, @@ -151,50 +161,27 @@ static struct mtd_partition igep_onenand_partitions[] = { }, }; -static struct omap_onenand_platform_data igep_onenand_data = { - .parts = igep_onenand_partitions, - .nr_parts = ARRAY_SIZE(igep_onenand_partitions), - .dma_channel = -1, /* disable DMA in OMAP OneNAND driver */ -}; - -static struct platform_device igep_onenand_device = { - .name = "omap2-onenand", - .id = -1, - .dev = { - .platform_data = &igep_onenand_data, - }, -}; +static inline u32 igep_get_sysboot_value(void) +{ + return omap_ctrl_readl(OMAP343X_CONTROL_STATUS) & IGEP_SYSBOOT_MASK; +} static void __init igep_flash_init(void) { - u8 cs = 0; - u8 onenandcs = GPMC_CS_NUM + 1; - - for (cs = 0; cs < GPMC_CS_NUM; cs++) { - u32 ret; - ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1); - - /* Check if NAND/oneNAND is configured */ - if ((ret & 0xC00) == 0x800) - /* NAND found */ - pr_err("IGEP: Unsupported NAND found\n"); - else { - ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG7); - if ((ret & 0x3F) == (ONENAND_MAP >> 24)) - /* ONENAND found */ - onenandcs = cs; - } - } - - if (onenandcs > GPMC_CS_NUM) { - pr_err("IGEP: Unable to find configuration in GPMC\n"); - return; - } - - igep_onenand_data.cs = onenandcs; - - if (platform_device_register(&igep_onenand_device) < 0) - pr_err("IGEP: Unable to register OneNAND device\n"); + u32 mux; + mux = igep_get_sysboot_value(); + + if (mux == IGEP_SYSBOOT_NAND) { + pr_info("IGEP: initializing NAND memory device\n"); + board_nand_init(igep_flash_partitions, + ARRAY_SIZE(igep_flash_partitions), + 0, NAND_BUSWIDTH_16); + } else if (mux == IGEP_SYSBOOT_ONENAND) { + pr_info("IGEP: initializing OneNAND memory device\n"); + board_onenand_init(igep_flash_partitions, + ARRAY_SIZE(igep_flash_partitions), 0); + } else + pr_err("IGEP: Flash: unsupported sysboot sequence found\n"); } #else