From patchwork Mon Jul 27 20:50:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 500745 X-Patchwork-Delegate: marek.vasut@gmail.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 B53F3140318 for ; Tue, 28 Jul 2015 07:04:21 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0FB384B90E; Mon, 27 Jul 2015 23:01:27 +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 uXbfKorp3bjb; Mon, 27 Jul 2015 23:01:26 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id AF2474B832; Mon, 27 Jul 2015 22:58:10 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 20DA84B77D for ; Mon, 27 Jul 2015 22:53:54 +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 3a4dumqA7sUA for ; Mon, 27 Jul 2015 22:53:54 +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-out.m-online.net (mail-out.m-online.net [212.18.0.9]) by theia.denx.de (Postfix) with ESMTPS id F137E4B7B6 for ; Mon, 27 Jul 2015 22:53:29 +0200 (CEST) Received: from mail.nefkom.net (unknown [192.168.8.184]) by mail-out.m-online.net (Postfix) with ESMTP id 3mgCyx5JrQz3hjXs; Mon, 27 Jul 2015 22:53:29 +0200 (CEST) X-Auth-Info: V+XiXTkKdrtdoOChwlt54PrZLEV9eedBDPUkzIY0EaE= Received: from chi.lan (host-82-135-33-74.customer.m-online.net [82.135.33.74]) by smtp-auth.mnet-online.de (Postfix) with ESMTPA id 3mgCyx3MZJzvdWS; Mon, 27 Jul 2015 22:53:29 +0200 (CEST) From: Marek Vasut To: u-boot@lists.denx.de Date: Mon, 27 Jul 2015 22:50:42 +0200 Message-Id: <1438030335-10631-80-git-send-email-marex@denx.de> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1438030335-10631-1-git-send-email-marex@denx.de> References: <1438030335-10631-1-git-send-email-marex@denx.de> Cc: Marek Vasut , trini@konsulko.com Subject: [U-Boot] [PATCH 079/172] ddr: altera: Rework initialize_tracking() X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Clean the function up by getting rid of all the insane XOR-leftshift combos when assembling register values. While at it, remove all the ad-hoc variables necessary for this XOR-leftshift voodoo. Finally, get rid of the iterative division implementation of two constants and replace it with a DIV_ROUND_UP() macro :-) Signed-off-by: Marek Vasut --- drivers/ddr/altera/sequencer.c | 88 +++++++++++++++++------------------------- 1 file changed, 35 insertions(+), 53 deletions(-) diff --git a/drivers/ddr/altera/sequencer.c b/drivers/ddr/altera/sequencer.c index 28e32ff..aceb6a0 100644 --- a/drivers/ddr/altera/sequencer.c +++ b/drivers/ddr/altera/sequencer.c @@ -3612,65 +3612,47 @@ static void initialize_hps_phy(void) writel(reg, &sdr_ctrl->phy_ctrl2); } +/** + * initialize_tracking() - Initialize tracking + * + * Initialize the register file with usable initial data. + */ static void initialize_tracking(void) { - uint32_t concatenated_longidle = 0x0; - uint32_t concatenated_delays = 0x0; - uint32_t concatenated_rw_addr = 0x0; - uint32_t concatenated_refresh = 0x0; - uint32_t trk_sample_count = 7500; - uint32_t dtaps_per_ptap; - uint32_t tmp_delay; + /* + * Initialize the register file with the correct data. + * Compute usable version of value in case we skip full + * computation later. + */ + writel(DIV_ROUND_UP(IO_DELAY_PER_OPA_TAP, IO_DELAY_PER_DCHAIN_TAP) - 1, + &sdr_reg_file->dtaps_per_ptap); + + /* trk_sample_count */ + writel(7500, &sdr_reg_file->trk_sample_count); + + /* longidle outer loop [15:0] */ + writel((10 << 16) | (100 << 0), &sdr_reg_file->trk_longidle); /* - * compute usable version of value in case we skip full - * computation later + * longidle sample count [31:24] + * trfc, worst case of 933Mhz 4Gb [23:16] + * trcd, worst case [15:8] + * vfifo wait [7:0] */ - dtaps_per_ptap = 0; - tmp_delay = 0; - while (tmp_delay < IO_DELAY_PER_OPA_TAP) { - dtaps_per_ptap++; - tmp_delay += IO_DELAY_PER_DCHAIN_TAP; - } - dtaps_per_ptap--; - - concatenated_longidle = concatenated_longidle ^ 10; - /*longidle outer loop */ - concatenated_longidle = concatenated_longidle << 16; - concatenated_longidle = concatenated_longidle ^ 100; - /*longidle sample count */ - concatenated_delays = concatenated_delays ^ 243; - /* trfc, worst case of 933Mhz 4Gb */ - concatenated_delays = concatenated_delays << 8; - concatenated_delays = concatenated_delays ^ 14; - /* trcd, worst case */ - concatenated_delays = concatenated_delays << 8; - concatenated_delays = concatenated_delays ^ 10; - /* vfifo wait */ - concatenated_delays = concatenated_delays << 8; - concatenated_delays = concatenated_delays ^ 4; - /* mux delay */ - - concatenated_rw_addr = concatenated_rw_addr ^ RW_MGR_IDLE; - concatenated_rw_addr = concatenated_rw_addr << 8; - concatenated_rw_addr = concatenated_rw_addr ^ RW_MGR_ACTIVATE_1; - concatenated_rw_addr = concatenated_rw_addr << 8; - concatenated_rw_addr = concatenated_rw_addr ^ RW_MGR_SGLE_READ; - concatenated_rw_addr = concatenated_rw_addr << 8; - concatenated_rw_addr = concatenated_rw_addr ^ RW_MGR_PRECHARGE_ALL; - - concatenated_refresh = concatenated_refresh ^ RW_MGR_REFRESH_ALL; - concatenated_refresh = concatenated_refresh << 24; - concatenated_refresh = concatenated_refresh ^ 1000; /* trefi */ + writel((243 << 24) | (14 << 16) | (10 << 8) | (4 << 0), + &sdr_reg_file->delays); - /* Initialize the register file with the correct data */ - writel(dtaps_per_ptap, &sdr_reg_file->dtaps_per_ptap); - writel(trk_sample_count, &sdr_reg_file->trk_sample_count); - writel(concatenated_longidle, &sdr_reg_file->trk_longidle); - writel(concatenated_delays, &sdr_reg_file->delays); - writel(concatenated_rw_addr, &sdr_reg_file->trk_rw_mgr_addr); - writel(RW_MGR_MEM_IF_READ_DQS_WIDTH, &sdr_reg_file->trk_read_dqs_width); - writel(concatenated_refresh, &sdr_reg_file->trk_rfsh); + /* mux delay */ + writel((RW_MGR_IDLE << 24) | (RW_MGR_ACTIVATE_1 << 16) | + (RW_MGR_SGLE_READ << 8) | (RW_MGR_PRECHARGE_ALL << 0), + &sdr_reg_file->trk_rw_mgr_addr); + + writel(RW_MGR_MEM_IF_READ_DQS_WIDTH, + &sdr_reg_file->trk_read_dqs_width); + + /* trefi [7:0] */ + writel((RW_MGR_REFRESH_ALL << 24) | (1000 << 0), + &sdr_reg_file->trk_rfsh); } int sdram_calibration_full(void)