From patchwork Tue Oct 23 20:57:48 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Troy Kisky X-Patchwork-Id: 193568 X-Patchwork-Delegate: sbabic@denx.de 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 4B9A52C008A for ; Wed, 24 Oct 2012 07:58:10 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 47B924A32A; Tue, 23 Oct 2012 22:57:58 +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 fEgZJWg-WVPg; Tue, 23 Oct 2012 22:57:58 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3C78B4A333; Tue, 23 Oct 2012 22:57:47 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 87EAE4A313 for ; Tue, 23 Oct 2012 22:57:39 +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 CamcSzixDM2r for ; Tue, 23 Oct 2012 22:57:37 +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 mail-pb0-f44.google.com (mail-pb0-f44.google.com [209.85.160.44]) by theia.denx.de (Postfix) with ESMTPS id 47E284A329 for ; Tue, 23 Oct 2012 22:57:28 +0200 (CEST) Received: by mail-pb0-f44.google.com with SMTP id ro8so690657pbb.3 for ; Tue, 23 Oct 2012 13:57:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=pfqnSClkM/6q+rOEq7J4lHbxBSeySy4SJBwRnrxjU0M=; b=o8Jg0ZsPdn2EFLjJo+lDiKXbS/4D5TAWsqAnr0UeO4D8P0++wq2y4P/o8Q/r/BAQ0E apYehzZkIzSO+28DC1f1tWVLuAgTZbveeu9seUf+tmowy04R5kHxxNNjJ2XzUqrmqPfP vx6c3nT10LjtkWCbKdXSGaLWjYVUsyPo6quSDX+07D2UIyxeheHlnkZwyHx6HqcvhsHR RduwVUdoLgTiqCNfV5BFkwVFwM+pPVzFlseVyJL3KJ9GPrhDYBEic3lVfRVbfomeNoTR I47u+o8kCl3wdRteE2Dl/O+2zMhqJXYGq1sytYOeBMe1HXUAH175Vnvkcu4fdZ1tHZxB InuA== Received: by 10.68.138.198 with SMTP id qs6mr43928091pbb.151.1351025845370; Tue, 23 Oct 2012 13:57:25 -0700 (PDT) Received: from officeserver-2 ([70.96.116.236]) by mx.google.com with ESMTPS id w4sm8245891pav.27.2012.10.23.13.57.22 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 23 Oct 2012 13:57:24 -0700 (PDT) Received: from tkisky by officeserver-2 with local (Exim 4.76) (envelope-from ) id 1TQlXs-0003kt-Q0; Tue, 23 Oct 2012 13:57:52 -0700 From: Troy Kisky To: sbabic@denx.de Date: Tue, 23 Oct 2012 13:57:48 -0700 Message-Id: <1351025870-14394-4-git-send-email-troy.kisky@boundarydevices.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1351025870-14394-1-git-send-email-troy.kisky@boundarydevices.com> References: <1351025870-14394-1-git-send-email-troy.kisky@boundarydevices.com> X-Gm-Message-State: ALoCoQkxiV5sKFVSXICGgUOpwTpdB/pPB1oxBq3ERV6mE6/CqgCB2rWYEqX7G5NCxYtesV3gkant Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH V1 3/5] imx-common: cpu: add imx_ddr_size 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 Read memory setup registers to determine size of available ram. This routine works for mx53/mx6x I need this because when mx6solo called get_ram_size with a too large maximum size, the system hanged. Signed-off-by: Troy Kisky --- --- arch/arm/imx-common/cpu.c | 50 +++++++++++++++++++++++++++++ arch/arm/include/asm/arch-mx5/sys_proto.h | 1 + arch/arm/include/asm/arch-mx6/sys_proto.h | 1 + 3 files changed, 52 insertions(+) diff --git a/arch/arm/imx-common/cpu.c b/arch/arm/imx-common/cpu.c index 102c254..5081908 100644 --- a/arch/arm/imx-common/cpu.c +++ b/arch/arm/imx-common/cpu.c @@ -65,6 +65,56 @@ char *get_reset_cause(void) } } +#if defined(CONFIG_MX53) || defined(CONFIG_MX6) +#if defined(CONFIG_MX53) +#define MEMCTL_BASE ESDCTL_BASE_ADDR; +#else +#define MEMCTL_BASE MMDC_P0_BASE_ADDR; +#endif +static const unsigned char col_lookup[] = {9, 10, 11, 8, 12, 9, 9, 9}; +static const unsigned char bank_lookup[] = {3, 2}; + +struct esd_mmdc_regs { + uint32_t ctl; + uint32_t pdc; + uint32_t otc; + uint32_t cfg0; + uint32_t cfg1; + uint32_t cfg2; + uint32_t misc; + uint32_t scr; + uint32_t ref; + uint32_t rsvd1; + uint32_t rsvd2; + uint32_t rwd; + uint32_t or; + uint32_t mrr; + uint32_t cfg3lp; + uint32_t mr4; +}; + +#define ESD_MMDC_CTL_GET_ROW(mdctl) ((ctl >> 24) & 7) +#define ESD_MMDC_CTL_GET_COLUMN(mdctl) ((ctl >> 20) & 7) +#define ESD_MMDC_CTL_GET_WIDTH(mdctl) ((ctl >> 16) & 3) +#define ESD_MMDC_CTL_GET_CS1(mdctl) ((ctl >> 30) & 1) +#define ESD_MMDC_MISC_GET_BANK(mdmisc) ((misc >> 5) & 1) + +unsigned imx_ddr_size(void) +{ + struct esd_mmdc_regs *mem = (struct esd_mmdc_regs *)MEMCTL_BASE; + unsigned ctl = readl(&mem->ctl); + unsigned misc = readl(&mem->misc); + int bits = 11 + 0 + 0 + 1; /* row + col + bank + width */ + + bits += ESD_MMDC_CTL_GET_ROW(ctl); + bits += col_lookup[ESD_MMDC_CTL_GET_COLUMN(ctl)]; + bits += bank_lookup[ESD_MMDC_MISC_GET_BANK(misc)]; + bits += ESD_MMDC_CTL_GET_WIDTH(ctl); + bits += ESD_MMDC_CTL_GET_CS1(ctl); + return 1 << bits; +} +#endif + #if defined(CONFIG_DISPLAY_CPUINFO) const char *get_imx_type(u32 imxtype) diff --git a/arch/arm/include/asm/arch-mx5/sys_proto.h b/arch/arm/include/asm/arch-mx5/sys_proto.h index 4435be1..93ad1c6 100644 --- a/arch/arm/include/asm/arch-mx5/sys_proto.h +++ b/arch/arm/include/asm/arch-mx5/sys_proto.h @@ -33,6 +33,7 @@ #define is_soc_rev(rev) ((get_cpu_rev() & 0xFF) - rev) u32 get_cpu_rev(void); +unsigned imx_ddr_size(void); void sdelay(unsigned long); void set_chipselect_size(int const); diff --git a/arch/arm/include/asm/arch-mx6/sys_proto.h b/arch/arm/include/asm/arch-mx6/sys_proto.h index 6627bbc..3193297 100644 --- a/arch/arm/include/asm/arch-mx6/sys_proto.h +++ b/arch/arm/include/asm/arch-mx6/sys_proto.h @@ -34,6 +34,7 @@ #define is_soc_rev(rev) ((get_cpu_rev() & 0xFF) - rev) u32 get_cpu_rev(void); const char *get_imx_type(u32 imxtype); +unsigned imx_ddr_size(void); void set_vddsoc(u32 mv);