From patchwork Fri Aug 7 05:28:34 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Dubov X-Patchwork-Id: 71671 X-Patchwork-Delegate: galak@kernel.crashing.org Return-Path: X-Original-To: wd@gemini.denx.de Delivered-To: wd@gemini.denx.de Received: from diddl.denx.de (diddl.denx.de [10.0.0.6]) by gemini.denx.de (Postfix) with ESMTP id 0F7D7832E425 for ; Fri, 7 Aug 2009 07:30:02 +0200 (CEST) Received: from diddl.denx.de (localhost.localdomain [127.0.0.1]) by diddl.denx.de (Postfix) with ESMTP id 00042C960221 for ; Fri, 7 Aug 2009 07:30:01 +0200 (CEST) Received: from pop.mnet-online.de by diddl.denx.de with POP3 (fetchmail-6.3.8) for (single-drop); Fri, 07 Aug 2009 07:30:02 +0200 (CEST) Received: from murder (svr19.m-online.net [192.168.3.147]) by backend2 (Cyrus v2.2.12) with LMTPA; Fri, 07 Aug 2009 07:31:42 +0200 X-Sieve: CMU Sieve 2.2 Received: from mail.m-online.net (localhost [127.0.0.1]) by frontend3.pop.m-online.net (Cyrus v2.2.13) with LMTPA; Fri, 07 Aug 2009 07:29:25 +0200 Received: from scanner-3.m-online.net (scanner-3.m-online.net [192.168.1.20]) by mail.m-online.net (Postfix) with ESMTP id 68364200168; Fri, 7 Aug 2009 07:29:25 +0200 (CEST) Received: from mxin-3.m-online.net ([192.168.1.19]) by scanner-3.m-online.net (scanner-3.m-online.net [192.168.1.20]) (amavisd-new, port 10026) with ESMTP id 20521-07-2; Fri, 7 Aug 2009 07:29:24 +0200 (CEST) Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by mxin-3.m-online.net (Postfix) with ESMTP id 8E44046C0A9; Fri, 7 Aug 2009 07:29:23 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 40892280B0; Fri, 7 Aug 2009 07:29:08 +0200 (CEST) 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 TxgCnlEsV-H1; Fri, 7 Aug 2009 07:29:07 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B4BC328093; Fri, 7 Aug 2009 07:29:00 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id F0F1A28082 for ; Fri, 7 Aug 2009 07:28:57 +0200 (CEST) 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 k5Bcn7ajDlNY for ; Fri, 7 Aug 2009 07:28:57 +0200 (CEST) Received: from nskntmtas02p.mx.bigpond.com (nskntmtas02p.mx.bigpond.com [61.9.168.140]) by theia.denx.de (Postfix) with ESMTP id 06F9928081 for ; Fri, 7 Aug 2009 07:28:53 +0200 (CEST) Received: from nskntotgx03p.mx.bigpond.com ([203.45.25.144]) by nskntmtas02p.mx.bigpond.com with ESMTP id <20090807052850.OZST1957.nskntmtas02p.mx.bigpond.com@nskntotgx03p.mx.bigpond.com>; Fri, 7 Aug 2009 05:28:50 +0000 Received: from mail.starintellect.com.au ([203.45.25.144]) by nskntotgx03p.mx.bigpond.com with ESMTP id <20090807052850.FJNM21119.nskntotgx03p.mx.bigpond.com@mail.starintellect.com.au>; Fri, 7 Aug 2009 05:28:50 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.starintellect.com (Postfix) with ESMTP id 019BB76022C; Fri, 7 Aug 2009 15:28:50 +1000 (EST) Received: from mail.starintellect.com.au ([127.0.0.1]) by localhost (mail.starintellect.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Xfdq+6aW-Gbu; Fri, 7 Aug 2009 15:28:44 +1000 (EST) Received: from localhost.localdomain (sunapp.starintellect.com [192.168.1.14]) by mail.starintellect.com (Postfix) with ESMTP id 00965760231; Fri, 7 Aug 2009 15:28:43 +1000 (EST) From: oakad@yahoo.com To: u-boot@lists.denx.de Date: Fri, 7 Aug 2009 15:28:34 +1000 Message-Id: <1249622915-1473-4-git-send-email-oakad@yahoo.com> X-Mailer: git-send-email 1.5.6.4 In-Reply-To: <1249622915-1473-3-git-send-email-oakad@yahoo.com> References: <1249622915-1473-1-git-send-email-oakad@yahoo.com> <1249622915-1473-2-git-send-email-oakad@yahoo.com> <1249622915-1473-3-git-send-email-oakad@yahoo.com> X-RPD-ScanID: Class unknown; VirusThreatLevel unknown, RefID str=0001.0A150202.4A7BBB92.00E1,ss=1,fgs=0 Cc: Alex Dubov Subject: [U-Boot] [PATCH 3/4] stx: factor out common DIMM enumeration code 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: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de X-Virus-Scanned: by amavisd-new at m-online.net From: Alex Dubov Board specific ddr options are moved to the main board configuration file. Common DIMM enumeration code is factored out. Signed-off-by: Alex Dubov --- board/stx/common/Makefile | 1 + board/stx/common/ddr.c | 43 +++++++++++++++++++++++++ board/stx/stxgp3/Makefile | 1 - board/stx/stxgp3/ddr.c | 76 --------------------------------------------- board/stx/stxgp3/stxgp3.c | 33 +++++++++++++++++++ board/stx/stxssa/Makefile | 1 - board/stx/stxssa/ddr.c | 76 --------------------------------------------- board/stx/stxssa/stxssa.c | 33 +++++++++++++++++++ 8 files changed, 110 insertions(+), 154 deletions(-) create mode 100644 board/stx/common/ddr.c delete mode 100644 board/stx/stxgp3/ddr.c delete mode 100644 board/stx/stxssa/ddr.c diff --git a/board/stx/common/Makefile b/board/stx/common/Makefile index 73c6e46..b80570c 100644 --- a/board/stx/common/Makefile +++ b/board/stx/common/Makefile @@ -30,6 +30,7 @@ endif LIB = $(obj)lib$(VENDOR).a COBJS-${CONFIG_MPC85xx} += law.o +COBJS-${CONFIG_MPC85xx} += ddr.o SRCS := $(SOBJS:.o=.S) $(COBJS-y:.o=.c) OBJS := $(addprefix $(obj),$(COBJS-y)) diff --git a/board/stx/common/ddr.c b/board/stx/common/ddr.c new file mode 100644 index 0000000..401f632 --- /dev/null +++ b/board/stx/common/ddr.c @@ -0,0 +1,43 @@ +/* + * Copyright 2008 Freescale Semiconductor, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * Version 2 as published by the Free Software Foundation. + */ + +#include +#include + +#include +#include + +static void +get_spd(ddr1_spd_eeprom_t *spd, unsigned char i2c_address) +{ + i2c_read(i2c_address, 0, 1, (uchar *)spd, sizeof(ddr1_spd_eeprom_t)); +} + + +unsigned int +fsl_ddr_get_mem_data_rate(void) +{ + return get_ddr_freq(0); +} + + +void +fsl_ddr_get_spd(ddr1_spd_eeprom_t *ctrl_dimms_spd, + unsigned int ctrl_num) +{ + unsigned int i; + unsigned int i2c_address = 0; + + for (i = 0; i < CONFIG_DIMM_SLOTS_PER_CTLR; i++) { + if (ctrl_num == 0 && i == 0) { + i2c_address = SPD_EEPROM_ADDRESS; + } + get_spd(&(ctrl_dimms_spd[i]), i2c_address); + } +} + diff --git a/board/stx/stxgp3/Makefile b/board/stx/stxgp3/Makefile index 0aae375..528fa2a 100644 --- a/board/stx/stxgp3/Makefile +++ b/board/stx/stxgp3/Makefile @@ -28,7 +28,6 @@ LIB = $(obj)lib$(BOARD).a COBJS-y += $(BOARD).o COBJS-y += tlb.o COBJS-y += flash.o -COBJS-$(CONFIG_FSL_DDR1) += ddr.o SRCS := $(SOBJS:.o=.S) $(COBJS-y:.o=.c) OBJS := $(addprefix $(obj),$(COBJS-y)) diff --git a/board/stx/stxgp3/ddr.c b/board/stx/stxgp3/ddr.c deleted file mode 100644 index 93d1100..0000000 --- a/board/stx/stxgp3/ddr.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2008 Freescale Semiconductor, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * Version 2 as published by the Free Software Foundation. - */ - -#include -#include - -#include -#include - -static void -get_spd(ddr1_spd_eeprom_t *spd, unsigned char i2c_address) -{ - i2c_read(i2c_address, 0, 1, (uchar *)spd, sizeof(ddr1_spd_eeprom_t)); -} - - -unsigned int -fsl_ddr_get_mem_data_rate(void) -{ - return get_ddr_freq(0); -} - - -void -fsl_ddr_get_spd(ddr1_spd_eeprom_t *ctrl_dimms_spd, - unsigned int ctrl_num) -{ - unsigned int i; - unsigned int i2c_address = 0; - - for (i = 0; i < CONFIG_DIMM_SLOTS_PER_CTLR; i++) { - if (ctrl_num == 0 && i == 0) { - i2c_address = SPD_EEPROM_ADDRESS; - } - get_spd(&(ctrl_dimms_spd[i]), i2c_address); - } -} - -void fsl_ddr_board_options(memctl_options_t *popts, - dimm_params_t *pdimm, - unsigned int ctrl_num) -{ - /* - * Factors to consider for CPO: - * - frequency - * - ddr1 vs. ddr2 - */ - popts->cpo_override = 0; - - /* - * Factors to consider for write data delay: - * - number of DIMMs - * - * 1 = 1/4 clock delay - * 2 = 1/2 clock delay - * 3 = 3/4 clock delay - * 4 = 1 clock delay - * 5 = 5/4 clock delay - * 6 = 3/2 clock delay - */ - popts->write_data_delay = 3; - - /* 2T timing enable */ - popts->twoT_en = 1; - - /* - * Factors to consider for half-strength driver enable: - * - number of DIMMs installed - */ - popts->half_strength_driver_enable = 0; -} diff --git a/board/stx/stxgp3/stxgp3.c b/board/stx/stxgp3/stxgp3.c index 3804fe0..3f626c1 100644 --- a/board/stx/stxgp3/stxgp3.c +++ b/board/stx/stxgp3/stxgp3.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -307,6 +308,38 @@ initdram (int board_type) return dram_size; } +void fsl_ddr_board_options(memctl_options_t *popts, dimm_params_t *pdimm, + unsigned int ctrl_num) +{ + /* + * Factors to consider for CPO: + * - frequency + * - ddr1 vs. ddr2 + */ + popts->cpo_override = 0; + + /* + * Factors to consider for write data delay: + * - number of DIMMs + * + * 1 = 1/4 clock delay + * 2 = 1/2 clock delay + * 3 = 3/4 clock delay + * 4 = 1 clock delay + * 5 = 5/4 clock delay + * 6 = 3/2 clock delay + */ + popts->write_data_delay = 3; + + /* 2T timing enable */ + popts->twoT_en = 1; + + /* + * Factors to consider for half-strength driver enable: + * - number of DIMMs installed + */ + popts->half_strength_driver_enable = 0; +} #if defined(CONFIG_SYS_DRAM_TEST) int testdram (void) diff --git a/board/stx/stxssa/Makefile b/board/stx/stxssa/Makefile index 432d4b4..d05a72b 100644 --- a/board/stx/stxssa/Makefile +++ b/board/stx/stxssa/Makefile @@ -27,7 +27,6 @@ LIB = $(obj)lib$(BOARD).a COBJS-y += $(BOARD).o COBJS-y += tlb.o -COBJS-$(CONFIG_FSL_DDR1) += ddr.o SRCS := $(SOBJS:.o=.S) $(COBJS-y:.o=.c) OBJS := $(addprefix $(obj),$(COBJS-y)) diff --git a/board/stx/stxssa/ddr.c b/board/stx/stxssa/ddr.c deleted file mode 100644 index 93d1100..0000000 --- a/board/stx/stxssa/ddr.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2008 Freescale Semiconductor, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * Version 2 as published by the Free Software Foundation. - */ - -#include -#include - -#include -#include - -static void -get_spd(ddr1_spd_eeprom_t *spd, unsigned char i2c_address) -{ - i2c_read(i2c_address, 0, 1, (uchar *)spd, sizeof(ddr1_spd_eeprom_t)); -} - - -unsigned int -fsl_ddr_get_mem_data_rate(void) -{ - return get_ddr_freq(0); -} - - -void -fsl_ddr_get_spd(ddr1_spd_eeprom_t *ctrl_dimms_spd, - unsigned int ctrl_num) -{ - unsigned int i; - unsigned int i2c_address = 0; - - for (i = 0; i < CONFIG_DIMM_SLOTS_PER_CTLR; i++) { - if (ctrl_num == 0 && i == 0) { - i2c_address = SPD_EEPROM_ADDRESS; - } - get_spd(&(ctrl_dimms_spd[i]), i2c_address); - } -} - -void fsl_ddr_board_options(memctl_options_t *popts, - dimm_params_t *pdimm, - unsigned int ctrl_num) -{ - /* - * Factors to consider for CPO: - * - frequency - * - ddr1 vs. ddr2 - */ - popts->cpo_override = 0; - - /* - * Factors to consider for write data delay: - * - number of DIMMs - * - * 1 = 1/4 clock delay - * 2 = 1/2 clock delay - * 3 = 3/4 clock delay - * 4 = 1 clock delay - * 5 = 5/4 clock delay - * 6 = 3/2 clock delay - */ - popts->write_data_delay = 3; - - /* 2T timing enable */ - popts->twoT_en = 1; - - /* - * Factors to consider for half-strength driver enable: - * - number of DIMMs installed - */ - popts->half_strength_driver_enable = 0; -} diff --git a/board/stx/stxssa/stxssa.c b/board/stx/stxssa/stxssa.c index 73dddf3..a00087d 100644 --- a/board/stx/stxssa/stxssa.c +++ b/board/stx/stxssa/stxssa.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -324,6 +325,38 @@ initdram (int board_type) return dram_size; } +void fsl_ddr_board_options(memctl_options_t *popts, dimm_params_t *pdimm, + unsigned int ctrl_num) +{ + /* + * Factors to consider for CPO: + * - frequency + * - ddr1 vs. ddr2 + */ + popts->cpo_override = 0; + + /* + * Factors to consider for write data delay: + * - number of DIMMs + * + * 1 = 1/4 clock delay + * 2 = 1/2 clock delay + * 3 = 3/4 clock delay + * 4 = 1 clock delay + * 5 = 5/4 clock delay + * 6 = 3/2 clock delay + */ + popts->write_data_delay = 3; + + /* 2T timing enable */ + popts->twoT_en = 1; + + /* + * Factors to consider for half-strength driver enable: + * - number of DIMMs installed + */ + popts->half_strength_driver_enable = 0; +} #if defined(CONFIG_SYS_DRAM_TEST) int testdram (void)