From patchwork Mon Jul 27 20:51:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 500785 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 D94ED1402B7 for ; Tue, 28 Jul 2015 07:10:58 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id CF6794BA5D; Mon, 27 Jul 2015 23:05:37 +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 n9988pkpO8Xo; Mon, 27 Jul 2015 23:05:37 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id DC3F14BA42; Mon, 27 Jul 2015 23:02:19 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2CD274B7F6 for ; Mon, 27 Jul 2015 22:54:21 +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 kyZUdWXWAU1d for ; Mon, 27 Jul 2015 22:54:21 +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.10]) by theia.denx.de (Postfix) with ESMTPS id 0BC404B76A for ; Mon, 27 Jul 2015 22:53:54 +0200 (CEST) Received: from mail.nefkom.net (unknown [192.168.8.184]) by mail-out.m-online.net (Postfix) with ESMTP id 3mgCzP5lxDz3hkPF; Mon, 27 Jul 2015 22:53:53 +0200 (CEST) X-Auth-Info: vgEMqgJsuKEPP71I2J93O+K6zM7TLK/FuPehDZg4Cm4= 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 3mgCzN5ZtFzvdWS; Mon, 27 Jul 2015 22:53:52 +0200 (CEST) From: Marek Vasut To: u-boot@lists.denx.de Date: Mon, 27 Jul 2015 22:51:41 +0200 Message-Id: <1438030335-10631-139-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 138/172] ddr: altera: Clean up rw_mgr_mem_calibrate_read_test_all_ranks() 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" Signed-off-by: Marek Vasut --- drivers/ddr/altera/sequencer.c | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/drivers/ddr/altera/sequencer.c b/drivers/ddr/altera/sequencer.c index 6999504..f7e2e40 100644 --- a/drivers/ddr/altera/sequencer.c +++ b/drivers/ddr/altera/sequencer.c @@ -1278,12 +1278,23 @@ static uint32_t rw_mgr_mem_calibrate_read_test(uint32_t rank_bgn, uint32_t group } } -static uint32_t rw_mgr_mem_calibrate_read_test_all_ranks(uint32_t group, - uint32_t num_tries, uint32_t all_correct, uint32_t *bit_chk, - uint32_t all_groups) +/** + * rw_mgr_mem_calibrate_read_test_all_ranks() - Perform READ test on all ranks + * @grp: Read/Write group + * @num_tries: Number of retries of the test + * @all_correct: All bits must be correct in the mask + * @all_groups: Test all R/W groups + * + * Perform a READ test across all memory ranks. + */ +static int +rw_mgr_mem_calibrate_read_test_all_ranks(const u32 grp, const u32 num_tries, + const u32 all_correct, + const u32 all_groups) { - return rw_mgr_mem_calibrate_read_test(0, group, num_tries, all_correct, - bit_chk, all_groups, 1); + u32 bit_chk; + return rw_mgr_mem_calibrate_read_test(0, grp, num_tries, all_correct, + &bit_chk, all_groups, 1); } /** @@ -1319,13 +1330,13 @@ static void rw_mgr_decr_vfifo(const u32 grp) */ static int find_vfifo_failing_read(const u32 grp) { - u32 v, ret, bit_chk, fail_cnt = 0; + u32 v, ret, fail_cnt = 0; for (v = 0; v < VFIFO_SIZE; v++) { debug_cond(DLEVEL == 2, "%s:%d: vfifo %u\n", __func__, __LINE__, v); ret = rw_mgr_mem_calibrate_read_test_all_ranks(grp, 1, - PASS_ONE_BIT, &bit_chk, 0); + PASS_ONE_BIT, 0); if (!ret) { fail_cnt++; @@ -1357,7 +1368,7 @@ static int sdr_find_phase_delay(int working, int delay, const u32 grp, u32 *work, const u32 work_inc, u32 *pd) { const u32 max = delay ? IO_DQS_EN_DELAY_MAX : IO_DQS_EN_PHASE_MAX; - u32 ret, bit_chk; + u32 ret; for (; *pd <= max; (*pd)++) { if (delay) @@ -1366,7 +1377,7 @@ static int sdr_find_phase_delay(int working, int delay, const u32 grp, scc_mgr_set_dqs_en_phase_all_ranks(grp, *pd); ret = rw_mgr_mem_calibrate_read_test_all_ranks(grp, 1, - PASS_ONE_BIT, &bit_chk, 0); + PASS_ONE_BIT, 0); if (!working) ret = !ret; @@ -1459,7 +1470,7 @@ static int sdr_working_phase(const u32 grp, u32 *work_bgn, u32 *d, */ static void sdr_backup_phase(const u32 grp, u32 *work_bgn, u32 *p) { - u32 tmp_delay, bit_chk, d; + u32 tmp_delay, d; int ret; /* Special case code for backing up a phase */ @@ -1476,7 +1487,7 @@ static void sdr_backup_phase(const u32 grp, u32 *work_bgn, u32 *p) scc_mgr_set_dqs_en_delay_all_ranks(grp, d); ret = rw_mgr_mem_calibrate_read_test_all_ranks(grp, 1, - PASS_ONE_BIT, &bit_chk, 0); + PASS_ONE_BIT, 0); if (ret) { *work_bgn = tmp_delay; break; @@ -1537,7 +1548,7 @@ static int sdr_nonworking_phase(const u32 grp, u32 *work_end, u32 *p, u32 *i) static int sdr_find_window_center(const u32 grp, const u32 work_bgn, const u32 work_end) { - u32 bit_chk, work_mid; + u32 work_mid; int tmp_delay = 0; int i, p, d; @@ -1577,7 +1588,7 @@ static int sdr_find_window_center(const u32 grp, const u32 work_bgn, debug_cond(DLEVEL == 2, "find_dqs_en_phase: center\n"); if (rw_mgr_mem_calibrate_read_test_all_ranks(grp, 1, PASS_ONE_BIT, - &bit_chk, 0)) { + 0)) { debug_cond(DLEVEL == 2, "%s:%d center: found: ptap=%u dtap=%u\n", __func__, __LINE__, p, d); @@ -2427,7 +2438,6 @@ static uint32_t rw_mgr_mem_calibrate_vfifo_end(uint32_t read_group, static uint32_t rw_mgr_mem_calibrate_lfifo(void) { uint32_t found_one; - uint32_t bit_chk; debug("%s:%d\n", __func__, __LINE__); @@ -2447,7 +2457,7 @@ static uint32_t rw_mgr_mem_calibrate_lfifo(void) if (!rw_mgr_mem_calibrate_read_test_all_ranks(0, NUM_READ_TESTS, PASS_ALL_BITS, - &bit_chk, 1)) { + 1)) { break; }