From patchwork Wed Sep 7 08:16:23 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aneesh V X-Patchwork-Id: 113719 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 DF53AB6F83 for ; Wed, 7 Sep 2011 18:18:20 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 10BC8280A5; Wed, 7 Sep 2011 10:18:17 +0200 (CEST) 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 BxYX5hYJwYf7; Wed, 7 Sep 2011 10:18:16 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2EA9C28090; Wed, 7 Sep 2011 10:18:14 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A783128090 for ; Wed, 7 Sep 2011 10:18:11 +0200 (CEST) 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 QHn7Biob5nhA for ; Wed, 7 Sep 2011 10:18:08 +0200 (CEST) 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 bear.ext.ti.com (bear.ext.ti.com [192.94.94.41]) by theia.denx.de (Postfix) with ESMTPS id 865F328091 for ; Wed, 7 Sep 2011 10:18:06 +0200 (CEST) Received: from dbdp20.itg.ti.com ([172.24.170.38]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id p878I1do007463 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 7 Sep 2011 03:18:04 -0500 Received: from dbde70.ent.ti.com (localhost [127.0.0.1]) by dbdp20.itg.ti.com (8.13.8/8.13.8) with ESMTP id p878I0Nv002032 for ; Wed, 7 Sep 2011 13:48:01 +0530 (IST) Received: from dbdp31.itg.ti.com (172.24.170.98) by DBDE70.ent.ti.com (172.24.170.148) with Microsoft SMTP Server id 8.3.106.1; Wed, 7 Sep 2011 13:48:00 +0530 Received: from localhost (a0393566pc.apr.dhcp.ti.com [172.24.137.55]) by dbdp31.itg.ti.com (8.13.8/8.13.8) with ESMTP id p878I0VY016374; Wed, 7 Sep 2011 13:48:00 +0530 (IST) From: Aneesh V To: Date: Wed, 7 Sep 2011 13:46:23 +0530 Message-ID: <1315383384-29332-2-git-send-email-aneesh@ti.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1312893821-29250-1-git-send-email-aneesh@ti.com> References: <1312893821-29250-1-git-send-email-aneesh@ti.com> MIME-Version: 1.0 Cc: santosh.shilimkar@ti.com Subject: [U-Boot] [PATCH v3 2/3] omap4: make SDRAM init work for ES1.0 silicon X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de SDRAM init was not working on ES1.0 due to a programming error. A pointer that was passed by value to a function was set in function emif_get_device_details(), but the effect wouldn't be seen in the calling function. The issue came out while testing for ES1.0 because ES1.0 doesn't have any SDRAM chips connected to CS1 Signed-off-by: Aneesh V --- V2: * Rebased on latest HEAD of u-boot-ti master --- arch/arm/cpu/armv7/omap4/emif.c | 47 +++++------------------------- arch/arm/cpu/armv7/omap4/sdram_elpida.c | 24 ++++++++-------- arch/arm/include/asm/arch-omap4/emif.h | 5 +-- 3 files changed, 22 insertions(+), 54 deletions(-) diff --git a/arch/arm/cpu/armv7/omap4/emif.c b/arch/arm/cpu/armv7/omap4/emif.c index 487ec42..8c46464 100644 --- a/arch/arm/cpu/armv7/omap4/emif.c +++ b/arch/arm/cpu/armv7/omap4/emif.c @@ -963,10 +963,11 @@ static u8 is_lpddr2_sdram_present(u32 base, u32 cs, return 1; } -static struct lpddr2_device_details *get_lpddr2_details(u32 base, u8 cs, +struct lpddr2_device_details *emif_get_device_details(u32 emif_nr, u8 cs, struct lpddr2_device_details *lpddr2_dev_details) { u32 phy; + u32 base = (emif_nr == 1) ? OMAP44XX_EMIF1 : OMAP44XX_EMIF2; struct emif_reg_struct *emif = (struct emif_reg_struct *)base; if (!lpddr2_dev_details) @@ -985,40 +986,6 @@ static struct lpddr2_device_details *get_lpddr2_details(u32 base, u8 cs, return lpddr2_dev_details; } - -void emif_get_device_details(u32 emif_nr, - struct lpddr2_device_details *cs0_device_details, - struct lpddr2_device_details *cs1_device_details) -{ - u32 base = (emif_nr == 1) ? OMAP44XX_EMIF1 : OMAP44XX_EMIF2; - - if (running_from_sdram()) { - /* - * We can not do automatic discovery running from SDRAM - * Most likely we came here by mistake. Indicate error - * by returning NULL - */ - cs0_device_details = NULL; - cs1_device_details = NULL; - } else { - /* - * Automatically find the device details: - * - * Reset the PHY after each call to get_lpddr2_details(). - * If there is nothing connected to a given chip select - * (typically CS1) mode register reads will mess up with - * the PHY state and subsequent initialization won't work. - * PHY reset brings back PHY to a good state. - */ - cs0_device_details = - get_lpddr2_details(base, CS0, cs0_device_details); - emif_reset_phy(base); - - cs1_device_details = - get_lpddr2_details(base, CS1, cs1_device_details); - emif_reset_phy(base); - } -} #endif /* CONFIG_SYS_AUTOMATIC_SDRAM_DETECTION */ static void do_sdram_init(u32 base) @@ -1051,10 +1018,12 @@ static void do_sdram_init(u32 base) * - Obtained from user otherwise */ struct lpddr2_device_details cs0_dev_details, cs1_dev_details; - emif_get_device_details(emif_nr, &cs0_dev_details, - &cs1_dev_details); - dev_details.cs0_device_details = &cs0_dev_details; - dev_details.cs1_device_details = &cs1_dev_details; + emif_reset_phy(base); + dev_details.cs0_device_details = emif_get_device_details(base, CS0, + &cs0_dev_details); + dev_details.cs1_device_details = emif_get_device_details(base, CS1, + &cs1_dev_details); + emif_reset_phy(base); /* Return if no devices on this EMIF */ if (!dev_details.cs0_device_details && diff --git a/arch/arm/cpu/armv7/omap4/sdram_elpida.c b/arch/arm/cpu/armv7/omap4/sdram_elpida.c index 7757aad..edc5326 100644 --- a/arch/arm/cpu/armv7/omap4/sdram_elpida.c +++ b/arch/arm/cpu/armv7/omap4/sdram_elpida.c @@ -141,24 +141,24 @@ static const struct lpddr2_device_details elpida_2G_S4_details = { .manufacturer = LPDDR2_MANUFACTURER_ELPIDA }; -static void emif_get_device_details_sdp(u32 emif_nr, - struct lpddr2_device_details *cs0_device_details, - struct lpddr2_device_details *cs1_device_details) +struct lpddr2_device_details *emif_get_device_details_sdp(u32 emif_nr, u8 cs, + struct lpddr2_device_details *lpddr2_dev_details) { u32 omap_rev = omap_revision(); /* EMIF1 & EMIF2 have identical configuration */ - *cs0_device_details = elpida_2G_S4_details; - - if (omap_rev == OMAP4430_ES1_0) - cs1_device_details = NULL; - else - *cs1_device_details = elpida_2G_S4_details; + if ((omap_rev == OMAP4430_ES1_0) && (cs == CS1)) { + /* Nothing connected on CS1 for ES1.0 */ + return NULL; + } else { + /* In all other cases Elpida 2G device */ + *lpddr2_dev_details = elpida_2G_S4_details; + return lpddr2_dev_details; + } } -void emif_get_device_details(u32 emif_nr, - struct lpddr2_device_details *cs0_device_details, - struct lpddr2_device_details *cs1_device_details) +struct lpddr2_device_details *emif_get_device_details(u32 emif_nr, u8 cs, + struct lpddr2_device_details *lpddr2_dev_details) __attribute__((weak, alias("emif_get_device_details_sdp"))); #endif /* CONFIG_SYS_EMIF_PRECALCULATED_TIMING_REGS */ diff --git a/arch/arm/include/asm/arch-omap4/emif.h b/arch/arm/include/asm/arch-omap4/emif.h index 37ad1fd..6845c65 100644 --- a/arch/arm/include/asm/arch-omap4/emif.h +++ b/arch/arm/include/asm/arch-omap4/emif.h @@ -1029,9 +1029,8 @@ struct emif_regs { void emif_get_reg_dump(u32 emif_nr, const struct emif_regs **regs); void emif_get_dmm_regs(const struct dmm_lisa_map_regs **dmm_lisa_regs); #else -void emif_get_device_details(u32 emif_nr, - struct lpddr2_device_details *cs0_device_details, - struct lpddr2_device_details *cs1_device_details); +struct lpddr2_device_details *emif_get_device_details(u32 emif_nr, u8 cs, + struct lpddr2_device_details *lpddr2_dev_details); void emif_get_device_timings(u32 emif_nr, const struct lpddr2_device_timings **cs0_device_timings, const struct lpddr2_device_timings **cs1_device_timings);