From patchwork Mon Jul 27 20:51:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 500810 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 D00C31402B7 for ; Tue, 28 Jul 2015 07:15:22 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E6C314BB3E; Mon, 27 Jul 2015 23:08:15 +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 AK3surAvyF4s; Mon, 27 Jul 2015 23:08:15 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B15F74BC23; Mon, 27 Jul 2015 23:05:11 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A07D94B7E0 for ; Mon, 27 Jul 2015 22:53:59 +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 Q4MPvbLwa-uP for ; Mon, 27 Jul 2015 22:53:59 +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 326F34B7E7 for ; Mon, 27 Jul 2015 22:53:43 +0200 (CEST) Received: from mail.nefkom.net (unknown [192.168.8.184]) by mail-out.m-online.net (Postfix) with ESMTP id 3mgCzB6trvz3hjZT; Mon, 27 Jul 2015 22:53:42 +0200 (CEST) X-Auth-Info: nKgXQoj/KW2zKTtAvJYDl7/WA30NlSMsNO/bYbW6c/o= 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 3mgCzB51HlzvdWS; Mon, 27 Jul 2015 22:53:42 +0200 (CEST) From: Marek Vasut To: u-boot@lists.denx.de Date: Mon, 27 Jul 2015 22:51:14 +0200 Message-Id: <1438030335-10631-112-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 111/172] ddr: altera: Clean up rw_mgr_mem_calibrate_vfifo_find_dqs_en_phase_sweep_dq_in_delay() part 1 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" Start cleaning up this function. In the first part, just fix the incorrectly broken debug strings and fix return value to respect the common convention. Signed-off-by: Marek Vasut --- drivers/ddr/altera/sequencer.c | 61 +++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/drivers/ddr/altera/sequencer.c b/drivers/ddr/altera/sequencer.c index 8674a05..c33a12a 100644 --- a/drivers/ddr/altera/sequencer.c +++ b/drivers/ddr/altera/sequencer.c @@ -1770,57 +1770,59 @@ static uint32_t rw_mgr_mem_calibrate_vfifo_find_dqs_en_phase(uint32_t grp) * Try rw_mgr_mem_calibrate_vfifo_find_dqs_en_phase across different * dq_in_delay values */ -static uint32_t +static int rw_mgr_mem_calibrate_vfifo_find_dqs_en_phase_sweep_dq_in_delay (uint32_t write_group, uint32_t read_group, uint32_t test_bgn) { - uint32_t found; - uint32_t i; - uint32_t p; - uint32_t d; - uint32_t r; - - const uint32_t delay_step = IO_IO_IN_DELAY_MAX / - (RW_MGR_MEM_DQ_PER_READ_DQS-1); - /* we start at zero, so have one less dq to devide among */ + /* We start at zero, so have one less dq to devide among */ + const u32 delay_step = IO_IO_IN_DELAY_MAX / + (RW_MGR_MEM_DQ_PER_READ_DQS - 1); + int found; + u32 i, p, d, r; - debug("%s:%d (%u,%u,%u)", __func__, __LINE__, write_group, read_group, - test_bgn); - - /* try different dq_in_delays since the dq path is shorter than dqs */ + debug("%s:%d (%u,%u,%u)\n", __func__, __LINE__, + write_group, read_group, test_bgn); + /* Try different dq_in_delays since the DQ path is shorter than DQS. */ for (r = 0; r < RW_MGR_MEM_NUMBER_OF_RANKS; r += NUM_RANKS_PER_SHADOW_REG) { - for (i = 0, p = test_bgn, d = 0; i < RW_MGR_MEM_DQ_PER_READ_DQS; i++, p++, d += delay_step) { - debug_cond(DLEVEL == 1, "%s:%d rw_mgr_mem_calibrate_\ - vfifo_find_dqs_", __func__, __LINE__); - debug_cond(DLEVEL == 1, "en_phase_sweep_dq_in_delay: g=%u/%u ", - write_group, read_group); - debug_cond(DLEVEL == 1, "r=%u, i=%u p=%u d=%u\n", r, i , p, d); + for (i = 0, p = test_bgn, d = 0; + i < RW_MGR_MEM_DQ_PER_READ_DQS; + i++, p++, d += delay_step) { + debug_cond(DLEVEL == 1, + "%s:%d: g=%u/%u r=%u i=%u p=%u d=%u\n", + __func__, __LINE__, write_group, read_group, + r, i, p, d); + scc_mgr_set_dq_in_delay(p, d); scc_mgr_load_dq(p); } + writel(0, &sdr_scc_mgr->update); } found = rw_mgr_mem_calibrate_vfifo_find_dqs_en_phase(read_group); - debug_cond(DLEVEL == 1, "%s:%d rw_mgr_mem_calibrate_vfifo_find_dqs_\ - en_phase_sweep_dq", __func__, __LINE__); - debug_cond(DLEVEL == 1, "_in_delay: g=%u/%u found=%u; Reseting delay \ - chain to zero\n", write_group, read_group, found); + debug_cond(DLEVEL == 1, + "%s:%d: g=%u/%u found=%u; Reseting delay chain to zero\n", + __func__, __LINE__, write_group, read_group, found); for (r = 0; r < RW_MGR_MEM_NUMBER_OF_RANKS; r += NUM_RANKS_PER_SHADOW_REG) { - for (i = 0, p = test_bgn; i < RW_MGR_MEM_DQ_PER_READ_DQS; - i++, p++) { + for (i = 0, p = test_bgn; + i < RW_MGR_MEM_DQ_PER_READ_DQS; + i++, p++) { scc_mgr_set_dq_in_delay(p, 0); scc_mgr_load_dq(p); } + writel(0, &sdr_scc_mgr->update); } - return found; + if (!found) + return -EINVAL; + + return 0; } /* per-bit deskew DQ and center */ @@ -2258,10 +2260,7 @@ static int rw_mgr_mem_calibrate_dqs_enable_calibration(const u32 rw_group, */ ret = rw_mgr_mem_calibrate_vfifo_find_dqs_en_phase_sweep_dq_in_delay( rw_group, rw_group, test_bgn); - if (!ret) /* FIXME: 0 means failure in this old code :-( */ - return -EIO; - - return 0; + return ret; } /**