// SPDX-License-Identifier: GPL-2.0
/*
 * Copyright (C) 2020 Marvell International Ltd.
 */

#include <command.h>
#include <dm.h>
#include <hang.h>
#include <i2c.h>
#include <ram.h>
#include <time.h>

#include <linux/bitops.h>
#include <linux/io.h>

#include <mach/octeon_ddr.h>

/* Random number generator stuff */

#define CVMX_OCT_DID_RNG	8ULL

static u64 cvmx_rng_get_random64(void)
{
	return csr_rd(cvmx_build_io_address(CVMX_OCT_DID_RNG, 0));
}

static void cvmx_rng_enable(void)
{
	u64 val;

	val = csr_rd(CVMX_RNM_CTL_STATUS);
	val |= BIT(0) | BIT(1);
	csr_wr(CVMX_RNM_CTL_STATUS, val);
}

#define RLEVEL_PRINTALL_DEFAULT		1
#define WLEVEL_PRINTALL_DEFAULT		1

/*
 * Define how many HW WL samples to take for majority voting.
 * MUST BE odd!!
 * Assume there should only be 2 possible values that will show up,
 * so treat ties as a problem!!!
 * NOTE: Do not change this without checking the code!!!
 */
#define WLEVEL_LOOPS_DEFAULT		5

#define ENABLE_COMPUTED_VREF_ADJUSTMENT	1
#define SW_WLEVEL_HW_DEFAULT		1
#define DEFAULT_BEST_RANK_SCORE		9999999
#define MAX_RANK_SCORE_LIMIT		99

/*
 * Define how many HW RL samples per rank to take multiple samples will
 * allow looking for the best sample score
 */
#define RLEVEL_SAMPLES_DEFAULT		3

#define ddr_seq_print(format, ...) do {} while (0)

struct wlevel_bitcnt {
	int bitcnt[4];
};

static void display_dac_dbi_settings(int lmc, int dac_or_dbi,
				     int ecc_ena, int *settings, char *title);

static unsigned short load_dac_override(struct ddr_priv *priv, int if_num,
					int dac_value, int byte);

/* "mode" arg */
#define DBTRAIN_TEST 0
#define DBTRAIN_DBI  1
#define DBTRAIN_LFSR 2

static int run_best_hw_patterns(struct ddr_priv *priv, int lmc, u64 phys_addr,
				int mode, u64 *xor_data);

#define LMC_DDR3_RESET_ASSERT   0
#define LMC_DDR3_RESET_DEASSERT 1

static void cn7xxx_lmc_ddr3_reset(struct ddr_priv *priv, int if_num, int reset)
{
	union cvmx_lmcx_reset_ctl reset_ctl;

	/*
	 * 4. Deassert DDRn_RESET_L pin by writing
	 *    LMC(0..3)_RESET_CTL[DDR3RST] = 1
	 *    without modifying any other LMC(0..3)_RESET_CTL fields.
	 * 5. Read LMC(0..3)_RESET_CTL and wait for the result.
	 * 6. Wait a minimum of 500us. This guarantees the necessary T = 500us
	 *    delay between DDRn_RESET_L deassertion and DDRn_DIMM*_CKE*
	 *    assertion.
	 */
	debug("LMC%d %s DDR_RESET_L\n", if_num,
	      (reset ==
	       LMC_DDR3_RESET_DEASSERT) ? "De-asserting" : "Asserting");

	reset_ctl.u64 = lmc_rd(priv, CVMX_LMCX_RESET_CTL(if_num));
	reset_ctl.cn78xx.ddr3rst = reset;
	lmc_wr(priv, CVMX_LMCX_RESET_CTL(if_num), reset_ctl.u64);

	lmc_rd(priv, CVMX_LMCX_RESET_CTL(if_num));

	udelay(500);
}

static void perform_lmc_reset(struct ddr_priv *priv, int node, int if_num)
{
	/*
	 * 5.9.6 LMC RESET Initialization
	 *
	 * The purpose of this step is to assert/deassert the RESET# pin at the
	 * DDR3/DDR4 parts.
	 *
	 * This LMC RESET step is done for all enabled LMCs.
	 *
	 * It may be appropriate to skip this step if the DDR3/DDR4 DRAM parts
	 * are in self refresh and are currently preserving their
	 * contents. (Software can determine this via
	 * LMC(0..3)_RESET_CTL[DDR3PSV] in some circumstances.) The remainder of
	 * this section assumes that the DRAM contents need not be preserved.
	 *
	 * The remainder of this section assumes that the CN78XX DDRn_RESET_L
	 * pin is attached to the RESET# pin of the attached DDR3/DDR4 parts,
	 * as will be appropriate in many systems.
	 *
	 * (In other systems, such as ones that can preserve DDR3/DDR4 part
	 * contents while CN78XX is powered down, it will not be appropriate to
	 * directly attach the CN78XX DDRn_RESET_L pin to DRESET# of the
	 * DDR3/DDR4 parts, and this section may not apply.)
	 *
	 * The remainder of this section describes the sequence for LMCn.
	 *
	 * Perform the following six substeps for LMC reset initialization:
	 *
	 * 1. If not done already, assert DDRn_RESET_L pin by writing
	 * LMC(0..3)_RESET_ CTL[DDR3RST] = 0 without modifying any other
	 * LMC(0..3)_RESET_CTL fields.
	 */

	if (!ddr_memory_preserved(priv)) {
		/*
		 * 2. Read LMC(0..3)_RESET_CTL and wait for the result.
		 */

		lmc_rd(priv, CVMX_LMCX_RESET_CTL(if_num));

		/*
		 * 3. Wait until RESET# assertion-time requirement from JEDEC
		 * DDR3/DDR4 specification is satisfied (200 us during a
		 * power-on ramp, 100ns when power is already stable).
		 */

		udelay(200);

		/*
		 * 4. Deassert DDRn_RESET_L pin by writing
		 *    LMC(0..3)_RESET_CTL[DDR3RST] = 1
		 *    without modifying any other LMC(0..3)_RESET_CTL fields.
		 * 5. Read LMC(0..3)_RESET_CTL and wait for the result.
		 * 6. Wait a minimum of 500us. This guarantees the necessary
		 *    T = 500us delay between DDRn_RESET_L deassertion and
		 *    DDRn_DIMM*_CKE* assertion.
		 */
		cn7xxx_lmc_ddr3_reset(priv, if_num, LMC_DDR3_RESET_DEASSERT);

		/* Toggle Reset Again */
		/* That is, assert, then de-assert, one more time */
		cn7xxx_lmc_ddr3_reset(priv, if_num, LMC_DDR3_RESET_ASSERT);
		cn7xxx_lmc_ddr3_reset(priv, if_num, LMC_DDR3_RESET_DEASSERT);
	}
}

void oct3_ddr3_seq(struct ddr_priv *priv, int rank_mask, int if_num,
		   int sequence)
{
	/*
	 * 3. Without changing any other fields in LMC(0)_CONFIG, write
	 *    LMC(0)_CONFIG[RANKMASK] then write both
	 *    LMC(0)_SEQ_CTL[SEQ_SEL,INIT_START] = 1 with a single CSR write
	 *    operation. LMC(0)_CONFIG[RANKMASK] bits should be set to indicate
	 *    the ranks that will participate in the sequence.
	 *
	 *    The LMC(0)_SEQ_CTL[SEQ_SEL] value should select power-up/init or
	 *    selfrefresh exit, depending on whether the DRAM parts are in
	 *    self-refresh and whether their contents should be preserved. While
	 *    LMC performs these sequences, it will not perform any other DDR3
	 *    transactions. When the sequence is complete, hardware sets the
	 *    LMC(0)_CONFIG[INIT_STATUS] bits for the ranks that have been
	 *    initialized.
	 *
	 *    If power-up/init is selected immediately following a DRESET
	 *    assertion, LMC executes the sequence described in the "Reset and
	 *    Initialization Procedure" section of the JEDEC DDR3
	 *    specification. This includes activating CKE, writing all four DDR3
	 *    mode registers on all selected ranks, and issuing the required
	 *    ZQCL
	 *    command. The LMC(0)_CONFIG[RANKMASK] value should select all ranks
	 *    with attached DRAM in this case. If LMC(0)_CONTROL[RDIMM_ENA] = 1,
	 *    LMC writes the JEDEC standard SSTE32882 control words selected by
	 *    LMC(0)_DIMM_CTL[DIMM*_WMASK] between DDR_CKE* signal assertion and
	 *    the first DDR3 mode register write operation.
	 *    LMC(0)_DIMM_CTL[DIMM*_WMASK] should be cleared to 0 if the
	 *    corresponding DIMM is not present.
	 *
	 *    If self-refresh exit is selected, LMC executes the required SRX
	 *    command followed by a refresh and ZQ calibration. Section 4.5
	 *    describes behavior of a REF + ZQCS.  LMC does not write the DDR3
	 *    mode registers as part of this sequence, and the mode register
	 *    parameters must match at self-refresh entry and exit times.
	 *
	 * 4. Read LMC(0)_SEQ_CTL and wait for LMC(0)_SEQ_CTL[SEQ_COMPLETE]
	 *    to be set.
	 *
	 * 5. Read LMC(0)_CONFIG[INIT_STATUS] and confirm that all ranks have
	 *    been initialized.
	 */

	union cvmx_lmcx_seq_ctl seq_ctl;
	union cvmx_lmcx_config lmc_config;
	int timeout;

	lmc_config.u64 = lmc_rd(priv, CVMX_LMCX_CONFIG(if_num));
	lmc_config.s.rankmask = rank_mask;
	lmc_wr(priv, CVMX_LMCX_CONFIG(if_num), lmc_config.u64);

	seq_ctl.u64 = 0;

	seq_ctl.s.init_start = 1;
	seq_ctl.s.seq_sel = sequence;

	ddr_seq_print
	    ("Performing LMC sequence: rank_mask=0x%02x, sequence=0x%x, %s\n",
	     rank_mask, sequence, sequence_str[sequence]);

	if (seq_ctl.s.seq_sel == 3)
		debug("LMC%d: Exiting Self-refresh Rank_mask:%x\n", if_num,
		      rank_mask);

	lmc_wr(priv, CVMX_LMCX_SEQ_CTL(if_num), seq_ctl.u64);
	lmc_rd(priv, CVMX_LMCX_SEQ_CTL(if_num));

	timeout = 100;
	do {
		udelay(100);	/* Wait a while */
		seq_ctl.u64 = lmc_rd(priv, CVMX_LMCX_SEQ_CTL(if_num));
		if (--timeout == 0) {
			printf("Sequence %d timed out\n", sequence);
			break;
		}
	} while (seq_ctl.s.seq_complete != 1);

	ddr_seq_print("           LMC sequence=%x: Completed.\n", sequence);
}

#define bdk_numa_get_address(n, p)	((p) | ((u64)n) << CVMX_NODE_MEM_SHIFT)
#define AREA_BASE_OFFSET		BIT_ULL(26)

static int test_dram_byte64(struct ddr_priv *priv, int lmc, u64 p,
			    u64 bitmask, u64 *xor_data)
{
	u64 p1, p2, d1, d2;
	u64 v, v1;
	u64 p2offset = (1ULL << 26);	// offset to area 2
	u64 datamask;
	u64 xor;
	u64 i, j, k;
	u64 ii;
	int errors = 0;
	//u64 index;
	u64 pattern1 = cvmx_rng_get_random64();
	u64 pattern2 = 0;
	u64 bad_bits[2] = { 0, 0 };
	int kbitno = (octeon_is_cpuid(OCTEON_CN7XXX)) ? 20 : 18;
	union cvmx_l2c_ctl l2c_ctl;
	int burst;
	int saved_dissblkdty;
	int node = 0;

	// Force full cacheline write-backs to boost traffic
	l2c_ctl.u64 = l2c_rd(priv, CVMX_L2C_CTL_REL);
	saved_dissblkdty = l2c_ctl.cn78xx.dissblkdty;
	l2c_ctl.cn78xx.dissblkdty = 1;
	l2c_wr(priv, CVMX_L2C_CTL_REL, l2c_ctl.u64);

	if (octeon_is_cpuid(OCTEON_CN73XX) || octeon_is_cpuid(OCTEON_CNF75XX))
		kbitno = 18;

	// Byte lanes may be clear in the mask to indicate no testing on that
	//lane.
	datamask = bitmask;

	/*
	 * Add offset to both test regions to not clobber boot stuff
	 * when running from L2 for NAND boot.
	 */
	p += AREA_BASE_OFFSET;	// make sure base is out of the way of boot

	// final address must include LMC and node
	p |= (lmc << 7);	/* Map address into proper interface */
	p = bdk_numa_get_address(node, p);	/* Map to node */
	p |= 1ull << 63;

#define II_INC BIT_ULL(22)
#define II_MAX BIT_ULL(22)
#define K_INC  BIT_ULL(14)
#define K_MAX  BIT_ULL(kbitno)
#define J_INC  BIT_ULL(9)
#define J_MAX  BIT_ULL(12)
#define I_INC  BIT_ULL(3)
#define I_MAX  BIT_ULL(7)

	debug("N%d.LMC%d: %s: phys_addr=0x%llx/0x%llx (0x%llx)\n",
	      node, lmc, __func__, p, p + p2offset, 1ULL << kbitno);

	// loops are ordered so that only a single 64-bit slot is written to
	// each cacheline at one time, then the cachelines are forced out;
	// this should maximize read/write traffic

	// FIXME? extend the range of memory tested!!
	for (ii = 0; ii < II_MAX; ii += II_INC) {
		for (i = 0; i < I_MAX; i += I_INC) {
			for (k = 0; k < K_MAX; k += K_INC) {
				for (j = 0; j < J_MAX; j += J_INC) {
					p1 = p + ii + k + j;
					p2 = p1 + p2offset;

					v = pattern1 * (p1 + i);
					// write the same thing to both areas
					v1 = v;

					cvmx_write64_uint64(p1 + i, v);
					cvmx_write64_uint64(p2 + i, v1);

					CVMX_CACHE_WBIL2(p1, 0);
					CVMX_CACHE_WBIL2(p2, 0);
				}
			}
		}
	}

	CVMX_DCACHE_INVALIDATE;

	debug("N%d.LMC%d: dram_tuning_mem_xor: done INIT loop\n", node, lmc);

	/* Make a series of passes over the memory areas. */

	for (burst = 0; burst < 1 /* was: dram_tune_use_bursts */ ; burst++) {
		u64 this_pattern = cvmx_rng_get_random64();

		pattern2 ^= this_pattern;

		/*
		 * XOR the data with a random value, applying the change to both
		 * memory areas.
		 */

		// FIXME? extend the range of memory tested!!
		for (ii = 0; ii < II_MAX; ii += II_INC) {
			// FIXME: rearranged, did not make much difference?
			for (i = 0; i < I_MAX; i += I_INC) {
				for (k = 0; k < K_MAX; k += K_INC) {
					for (j = 0; j < J_MAX; j += J_INC) {
						p1 = p + ii + k + j;
						p2 = p1 + p2offset;

						v = cvmx_read64_uint64(p1 +
								      i) ^
						    this_pattern;
						v1 = cvmx_read64_uint64(p2 +
								       i) ^
						    this_pattern;

						cvmx_write64_uint64(p1 + i, v);
						cvmx_write64_uint64(p2 + i, v1);

						CVMX_CACHE_WBIL2(p1, 0);
						CVMX_CACHE_WBIL2(p2, 0);
					}
				}
			}
		}

		CVMX_DCACHE_INVALIDATE;

		debug("N%d.LMC%d: dram_tuning_mem_xor: done MODIFY loop\n",
		      node, lmc);

		/*
		 * Look for differences in the areas. If there is a mismatch,
		 * reset both memory locations with the same pattern. Failing
		 * to do so means that on all subsequent passes the pair of
		 * locations remain out of sync giving spurious errors.
		 */

		// FIXME: Change the loop order so that an entire cache line
		//        is compared at one time. This is so that a read
		//        error that occurs *anywhere* on the cacheline will
		//        be caught, rather than comparing only 1 cacheline
		//        slot at a time, where an error on a different
		//        slot will be missed that time around
		// Does the above make sense?

		// FIXME? extend the range of memory tested!!
		for (ii = 0; ii < II_MAX; ii += II_INC) {
			for (k = 0; k < K_MAX; k += K_INC) {
				for (j = 0; j < J_MAX; j += J_INC) {
					p1 = p + ii + k + j;
					p2 = p1 + p2offset;

					// process entire cachelines in the
					//innermost loop
					for (i = 0; i < I_MAX; i += I_INC) {
						int bybit = 1;
						// start in byte lane 0
						u64 bymsk = 0xffULL;

						// FIXME: this should predict
						// what we find...???
						v = ((p1 + i) * pattern1) ^
							pattern2;
						d1 = cvmx_read64_uint64(p1 + i);
						d2 = cvmx_read64_uint64(p2 + i);

						// union of error bits only in
						// active byte lanes
						xor = ((d1 ^ v) | (d2 ^ v)) &
							datamask;

						if (!xor)
							continue;

						// accumulate bad bits
						bad_bits[0] |= xor;

						while (xor != 0) {
							debug("ERROR(%03d): [0x%016llX] [0x%016llX]  expected 0x%016llX d1 %016llX d2 %016llX\n",
							      burst, p1, p2, v,
							      d1, d2);
							// error(s) in this lane
							if (xor & bymsk) {
								// set the byte
								// error bit
								errors |= bybit;
								// clear byte
								// lane in
								// error bits
								xor &= ~bymsk;
								// clear the
								// byte lane in
								// the mask
								datamask &= ~bymsk;
#if EXIT_WHEN_ALL_LANES_HAVE_ERRORS
								// nothing
								// left to do
								if (datamask == 0) {
									return errors;
								}
#endif /* EXIT_WHEN_ALL_LANES_HAVE_ERRORS */
							}
							// move mask into
							// next byte lane
							bymsk <<= 8;
							// move bit into next
							// byte position
							bybit <<= 1;
						}
					}
					CVMX_CACHE_WBIL2(p1, 0);
					CVMX_CACHE_WBIL2(p2, 0);
				}
			}
		}

		debug("N%d.LMC%d: dram_tuning_mem_xor: done TEST loop\n",
		      node, lmc);
	}

	if (xor_data) {		// send the bad bits back...
		xor_data[0] = bad_bits[0];
		xor_data[1] = bad_bits[1];	// let it be zeroed
	}

	// Restore original setting that could enable partial cacheline writes
	l2c_ctl.u64 = l2c_rd(priv, CVMX_L2C_CTL_REL);
	l2c_ctl.cn78xx.dissblkdty = saved_dissblkdty;
	l2c_wr(priv, CVMX_L2C_CTL_REL, l2c_ctl.u64);

	return errors;
}

static void ddr4_mrw(struct ddr_priv *priv, int if_num, int rank,
		     int mr_wr_addr, int mr_wr_sel, int mr_wr_bg1)
{
	union cvmx_lmcx_mr_mpr_ctl lmc_mr_mpr_ctl;

	lmc_mr_mpr_ctl.u64 = 0;
	lmc_mr_mpr_ctl.cn78xx.mr_wr_addr = (mr_wr_addr == -1) ? 0 : mr_wr_addr;
	lmc_mr_mpr_ctl.cn78xx.mr_wr_sel = mr_wr_sel;
	lmc_mr_mpr_ctl.cn78xx.mr_wr_rank = rank;
	lmc_mr_mpr_ctl.cn78xx.mr_wr_use_default_value =
		(mr_wr_addr == -1) ? 1 : 0;
	lmc_mr_mpr_ctl.cn78xx.mr_wr_bg1 = mr_wr_bg1;
	lmc_wr(priv, CVMX_LMCX_MR_MPR_CTL(if_num), lmc_mr_mpr_ctl.u64);

	/* Mode Register Write */
	oct3_ddr3_seq(priv, 1 << rank, if_num, 0x8);
}

#define INV_A0_17(x)	((x) ^ 0x22bf8)

static void set_mpr_mode(struct ddr_priv *priv, int rank_mask,
			 int if_num, int dimm_count, int mpr, int bg1)
{
	int rankx;

	debug("All Ranks: Set mpr mode = %x %c-side\n",
	      mpr, (bg1 == 0) ? 'A' : 'B');

	for (rankx = 0; rankx < dimm_count * 4; rankx++) {
		if (!(rank_mask & (1 << rankx)))
			continue;
		if (bg1 == 0) {
			/* MR3 A-side */
			ddr4_mrw(priv, if_num, rankx, mpr << 2, 3, bg1);
		} else {
			/* MR3 B-side */
			ddr4_mrw(priv, if_num, rankx, INV_A0_17(mpr << 2), ~3,
				 bg1);
		}
	}
}

static void do_ddr4_mpr_read(struct ddr_priv *priv, int if_num,
			     int rank, int page, int location)
{
	union cvmx_lmcx_mr_mpr_ctl lmc_mr_mpr_ctl;

	lmc_mr_mpr_ctl.u64 = lmc_rd(priv, CVMX_LMCX_MR_MPR_CTL(if_num));
	lmc_mr_mpr_ctl.cn70xx.mr_wr_addr = 0;
	lmc_mr_mpr_ctl.cn70xx.mr_wr_sel = page;	/* Page */
	lmc_mr_mpr_ctl.cn70xx.mr_wr_rank = rank;
	lmc_mr_mpr_ctl.cn70xx.mpr_loc = location;
	lmc_mr_mpr_ctl.cn70xx.mpr_wr = 0;	/* Read=0, Write=1 */
	lmc_wr(priv, CVMX_LMCX_MR_MPR_CTL(if_num), lmc_mr_mpr_ctl.u64);

	/* MPR register access sequence */
	oct3_ddr3_seq(priv, 1 << rank, if_num, 0x9);

	debug("LMC_MR_MPR_CTL                  : 0x%016llx\n",
	      lmc_mr_mpr_ctl.u64);
	debug("lmc_mr_mpr_ctl.cn70xx.mr_wr_addr: 0x%02x\n",
	      lmc_mr_mpr_ctl.cn70xx.mr_wr_addr);
	debug("lmc_mr_mpr_ctl.cn70xx.mr_wr_sel : 0x%02x\n",
	      lmc_mr_mpr_ctl.cn70xx.mr_wr_sel);
	debug("lmc_mr_mpr_ctl.cn70xx.mpr_loc   : 0x%02x\n",
	      lmc_mr_mpr_ctl.cn70xx.mpr_loc);
	debug("lmc_mr_mpr_ctl.cn70xx.mpr_wr    : 0x%02x\n",
	      lmc_mr_mpr_ctl.cn70xx.mpr_wr);
}

static int set_rdimm_mode(struct ddr_priv *priv, int if_num, int enable)
{
	union cvmx_lmcx_control lmc_control;
	int save_rdimm_mode;

	lmc_control.u64 = lmc_rd(priv, CVMX_LMCX_CONTROL(if_num));
	save_rdimm_mode = lmc_control.s.rdimm_ena;
	lmc_control.s.rdimm_ena = enable;
	debug("Setting RDIMM_ENA = %x\n", enable);
	lmc_wr(priv, CVMX_LMCX_CONTROL(if_num), lmc_control.u64);

	return save_rdimm_mode;
}

static void ddr4_mpr_read(struct ddr_priv *priv, int if_num, int rank,
			  int page, int location, u64 *mpr_data)
{
	do_ddr4_mpr_read(priv, if_num, rank, page, location);

	mpr_data[0] = lmc_rd(priv, CVMX_LMCX_MPR_DATA0(if_num));
}

/* Display MPR values for Page */
static void display_mpr_page(struct ddr_priv *priv, int rank_mask,
			     int if_num, int page)
{
	int rankx, location;
	u64 mpr_data[3];

	for (rankx = 0; rankx < 4; rankx++) {
		if (!(rank_mask & (1 << rankx)))
			continue;

		debug("N0.LMC%d.R%d: MPR Page %d loc [0:3]: ",
		      if_num, rankx, page);
		for (location = 0; location < 4; location++) {
			ddr4_mpr_read(priv, if_num, rankx, page, location,
				      mpr_data);
			debug("0x%02llx ", mpr_data[0] & 0xFF);
		}
		debug("\n");

	}			/* for (rankx = 0; rankx < 4; rankx++) */
}

static void ddr4_mpr_write(struct ddr_priv *priv, int if_num, int rank,
			   int page, int location, u8 mpr_data)
{
	union cvmx_lmcx_mr_mpr_ctl lmc_mr_mpr_ctl;

	lmc_mr_mpr_ctl.u64 = 0;
	lmc_mr_mpr_ctl.cn70xx.mr_wr_addr = mpr_data;
	lmc_mr_mpr_ctl.cn70xx.mr_wr_sel = page;	/* Page */
	lmc_mr_mpr_ctl.cn70xx.mr_wr_rank = rank;
	lmc_mr_mpr_ctl.cn70xx.mpr_loc = location;
	lmc_mr_mpr_ctl.cn70xx.mpr_wr = 1;	/* Read=0, Write=1 */
	lmc_wr(priv, CVMX_LMCX_MR_MPR_CTL(if_num), lmc_mr_mpr_ctl.u64);

	/* MPR register access sequence */
	oct3_ddr3_seq(priv, 1 << rank, if_num, 0x9);

	debug("LMC_MR_MPR_CTL                  : 0x%016llx\n",
	      lmc_mr_mpr_ctl.u64);
	debug("lmc_mr_mpr_ctl.cn70xx.mr_wr_addr: 0x%02x\n",
	      lmc_mr_mpr_ctl.cn70xx.mr_wr_addr);
	debug("lmc_mr_mpr_ctl.cn70xx.mr_wr_sel : 0x%02x\n",
	      lmc_mr_mpr_ctl.cn70xx.mr_wr_sel);
	debug("lmc_mr_mpr_ctl.cn70xx.mpr_loc   : 0x%02x\n",
	      lmc_mr_mpr_ctl.cn70xx.mpr_loc);
	debug("lmc_mr_mpr_ctl.cn70xx.mpr_wr    : 0x%02x\n",
	      lmc_mr_mpr_ctl.cn70xx.mpr_wr);
}

static void set_vref(struct ddr_priv *priv, int if_num, int rank,
		     int range, int value)
{
	union cvmx_lmcx_mr_mpr_ctl lmc_mr_mpr_ctl;
	union cvmx_lmcx_modereg_params3 lmc_modereg_params3;
	int mr_wr_addr = 0;

	lmc_mr_mpr_ctl.u64 = 0;
	lmc_modereg_params3.u64 = lmc_rd(priv,
					 CVMX_LMCX_MODEREG_PARAMS3(if_num));

	/* A12:A10 tCCD_L */
	mr_wr_addr |= lmc_modereg_params3.s.tccd_l << 10;
	mr_wr_addr |= 1 << 7;	/* A7 1 = Enable(Training Mode) */
	mr_wr_addr |= range << 6;	/* A6 vrefDQ Training Range */
	mr_wr_addr |= value << 0;	/* A5:A0 vrefDQ Training Value */

	lmc_mr_mpr_ctl.cn70xx.mr_wr_addr = mr_wr_addr;
	lmc_mr_mpr_ctl.cn70xx.mr_wr_sel = 6;	/* Write MR6 */
	lmc_mr_mpr_ctl.cn70xx.mr_wr_rank = rank;
	lmc_wr(priv, CVMX_LMCX_MR_MPR_CTL(if_num), lmc_mr_mpr_ctl.u64);

	/* 0x8 = Mode Register Write */
	oct3_ddr3_seq(priv, 1 << rank, if_num, 0x8);

	/*
	 * It is vendor specific whether vref_value is captured with A7=1.
	 * A subsequent MRS might be necessary.
	 */
	oct3_ddr3_seq(priv, 1 << rank, if_num, 0x8);

	mr_wr_addr &= ~(1 << 7);	/* A7 0 = Disable(Training Mode) */
	lmc_mr_mpr_ctl.cn70xx.mr_wr_addr = mr_wr_addr;
	lmc_wr(priv, CVMX_LMCX_MR_MPR_CTL(if_num), lmc_mr_mpr_ctl.u64);
}

static void set_dram_output_inversion(struct ddr_priv *priv, int if_num,
				      int dimm_count, int rank_mask,
				      int inversion)
{
	union cvmx_lmcx_ddr4_dimm_ctl lmc_ddr4_dimm_ctl;
	union cvmx_lmcx_dimmx_params lmc_dimmx_params;
	union cvmx_lmcx_dimm_ctl lmc_dimm_ctl;
	int dimm_no;

	/* Don't touch extenced register control words */
	lmc_ddr4_dimm_ctl.u64 = 0;
	lmc_wr(priv, CVMX_LMCX_DDR4_DIMM_CTL(if_num), lmc_ddr4_dimm_ctl.u64);

	debug("All DIMMs: Register Control Word          RC0 : %x\n",
	      (inversion & 1));

	for (dimm_no = 0; dimm_no < dimm_count; ++dimm_no) {
		lmc_dimmx_params.u64 =
		    lmc_rd(priv, CVMX_LMCX_DIMMX_PARAMS(dimm_no, if_num));
		lmc_dimmx_params.s.rc0 =
		    (lmc_dimmx_params.s.rc0 & ~1) | (inversion & 1);

		lmc_wr(priv,
		       CVMX_LMCX_DIMMX_PARAMS(dimm_no, if_num),
		       lmc_dimmx_params.u64);
	}

	/* LMC0_DIMM_CTL */
	lmc_dimm_ctl.u64 = lmc_rd(priv, CVMX_LMCX_DIMM_CTL(if_num));
	lmc_dimm_ctl.s.dimm0_wmask = 0x1;
	lmc_dimm_ctl.s.dimm1_wmask = (dimm_count > 1) ? 0x0001 : 0x0000;

	debug("LMC DIMM_CTL                                  : 0x%016llx\n",
	      lmc_dimm_ctl.u64);
	lmc_wr(priv, CVMX_LMCX_DIMM_CTL(if_num), lmc_dimm_ctl.u64);

	oct3_ddr3_seq(priv, rank_mask, if_num, 0x7);	/* Init RCW */
}

static void write_mpr_page0_pattern(struct ddr_priv *priv, int rank_mask,
				    int if_num, int dimm_count, int pattern,
				    int location_mask)
{
	int rankx;
	int location;

	for (rankx = 0; rankx < dimm_count * 4; rankx++) {
		if (!(rank_mask & (1 << rankx)))
			continue;
		for (location = 0; location < 4; ++location) {
			if (!(location_mask & (1 << location)))
				continue;

			ddr4_mpr_write(priv, if_num, rankx,
				       /* page */ 0, /* location */ location,
				       pattern);
		}
	}
}

static void change_rdimm_mpr_pattern(struct ddr_priv *priv, int rank_mask,
				     int if_num, int dimm_count)
{
	int save_ref_zqcs_int;
	union cvmx_lmcx_config lmc_config;

	/*
	 * Okay, here is the latest sequence.  This should work for all
	 * chips and passes (78,88,73,etc).  This sequence should be run
	 * immediately after DRAM INIT.  The basic idea is to write the
	 * same pattern into each of the 4 MPR locations in the DRAM, so
	 * that the same value is returned when doing MPR reads regardless
	 * of the inversion state.  My advice is to put this into a
	 * function, change_rdimm_mpr_pattern or something like that, so
	 * that it can be called multiple times, as I think David wants a
	 * clock-like pattern for OFFSET training, but does not want a
	 * clock pattern for Bit-Deskew.  You should then be able to call
	 * this at any point in the init sequence (after DRAM init) to
	 * change the pattern to a new value.
	 * Mike
	 *
	 * A correction: PHY doesn't need any pattern during offset
	 * training, but needs clock like pattern for internal vref and
	 * bit-dskew training.  So for that reason, these steps below have
	 * to be conducted before those trainings to pre-condition
	 * the pattern.  David
	 *
	 * Note: Step 3, 4, 8 and 9 have to be done through RDIMM
	 * sequence. If you issue MRW sequence to do RCW write (in o78 pass
	 * 1 at least), LMC will still do two commands because
	 * CONTROL[RDIMM_ENA] is still set high. We don't want it to have
	 * any unintentional mode register write so it's best to do what
	 * Mike is doing here.
	 * Andrew
	 */

	/* 1) Disable refresh (REF_ZQCS_INT = 0) */

	debug("1) Disable refresh (REF_ZQCS_INT = 0)\n");

	lmc_config.u64 = lmc_rd(priv, CVMX_LMCX_CONFIG(if_num));
	save_ref_zqcs_int = lmc_config.cn78xx.ref_zqcs_int;
	lmc_config.cn78xx.ref_zqcs_int = 0;
	lmc_wr(priv, CVMX_LMCX_CONFIG(if_num), lmc_config.u64);

	/*
	 * 2) Put all devices in MPR mode (Run MRW sequence (sequence=8)
	 * with MODEREG_PARAMS0[MPRLOC]=0,
	 * MODEREG_PARAMS0[MPR]=1, MR_MPR_CTL[MR_WR_SEL]=3, and
	 * MR_MPR_CTL[MR_WR_USE_DEFAULT_VALUE]=1)
	 */

	debug("2) Put all devices in MPR mode (Run MRW sequence (sequence=8)\n");

	/* A-side */
	set_mpr_mode(priv, rank_mask, if_num, dimm_count, 1, 0);
	/* B-side */
	set_mpr_mode(priv, rank_mask, if_num, dimm_count, 1, 1);

	/*
	 * a. Or you can set MR_MPR_CTL[MR_WR_USE_DEFAULT_VALUE]=0 and set
	 * the value you would like directly into
	 * MR_MPR_CTL[MR_WR_ADDR]
	 */

	/*
	 * 3) Disable RCD Parity (if previously enabled) - parity does not
	 * work if inversion disabled
	 */

	debug("3) Disable RCD Parity\n");

	/*
	 * 4) Disable Inversion in the RCD.
	 * a. I did (3&4) via the RDIMM sequence (seq_sel=7), but it
	 * may be easier to use the MRW sequence (seq_sel=8).  Just set
	 * MR_MPR_CTL[MR_WR_SEL]=7, MR_MPR_CTL[MR_WR_ADDR][3:0]=data,
	 * MR_MPR_CTL[MR_WR_ADDR][7:4]=RCD reg
	 */

	debug("4) Disable Inversion in the RCD.\n");

	set_dram_output_inversion(priv, if_num, dimm_count, rank_mask, 1);

	/*
	 * 5) Disable CONTROL[RDIMM_ENA] so that MR sequence goes out
	 * non-inverted.
	 */

	debug("5) Disable CONTROL[RDIMM_ENA]\n");

	set_rdimm_mode(priv, if_num, 0);

	/*
	 * 6) Write all 4 MPR registers with the desired pattern (have to
	 * do this for all enabled ranks)
	 * a. MR_MPR_CTL.MPR_WR=1, MR_MPR_CTL.MPR_LOC=0..3,
	 * MR_MPR_CTL.MR_WR_SEL=0, MR_MPR_CTL.MR_WR_ADDR[7:0]=pattern
	 */

	debug("6) Write all 4 MPR page 0 Training Patterns\n");

	write_mpr_page0_pattern(priv, rank_mask, if_num, dimm_count, 0x55, 0x8);

	/* 7) Re-enable RDIMM_ENA */

	debug("7) Re-enable RDIMM_ENA\n");

	set_rdimm_mode(priv, if_num, 1);

	/* 8) Re-enable RDIMM inversion */

	debug("8) Re-enable RDIMM inversion\n");

	set_dram_output_inversion(priv, if_num, dimm_count, rank_mask, 0);

	/* 9) Re-enable RDIMM parity (if desired) */

	debug("9) Re-enable RDIMM parity (if desired)\n");

	/*
	 * 10)Take B-side devices out of MPR mode (Run MRW sequence
	 * (sequence=8) with MODEREG_PARAMS0[MPRLOC]=0,
	 * MODEREG_PARAMS0[MPR]=0, MR_MPR_CTL[MR_WR_SEL]=3, and
	 * MR_MPR_CTL[MR_WR_USE_DEFAULT_VALUE]=1)
	 */

	debug("10)Take B-side devices out of MPR mode\n");

	set_mpr_mode(priv, rank_mask, if_num, dimm_count,
		     /* mpr */ 0, /* bg1 */ 1);

	/*
	 * a. Or you can set MR_MPR_CTL[MR_WR_USE_DEFAULT_VALUE]=0 and
	 * set the value you would like directly into MR_MPR_CTL[MR_WR_ADDR]
	 */

	/* 11)Re-enable refresh (REF_ZQCS_INT=previous value) */

	debug("11)Re-enable refresh (REF_ZQCS_INT=previous value)\n");

	lmc_config.u64 = lmc_rd(priv, CVMX_LMCX_CONFIG(if_num));
	lmc_config.cn78xx.ref_zqcs_int = save_ref_zqcs_int;
	lmc_wr(priv, CVMX_LMCX_CONFIG(if_num), lmc_config.u64);
}

static int validate_hwl_seq(int *wl, int *seq)
{
	// sequence index, step through the sequence array
	int seqx;
	int bitnum;

	seqx = 0;

	while (seq[seqx + 1] >= 0) {	// stop on next seq entry == -1
		// but now, check current versus next
		bitnum = (wl[seq[seqx]] << 2) | wl[seq[seqx + 1]];
		// magic validity number (see matrix above)
		if (!((1 << bitnum) & 0xBDE7))
			return 1;
		seqx++;
	}

	return 0;
}

static int validate_hw_wl_settings(int if_num,
				   union cvmx_lmcx_wlevel_rankx
				   *lmc_wlevel_rank, int is_rdimm, int ecc_ena)
{
	int wl[9], byte, errors;

	// arrange the sequences so
	// index 0 has byte 0, etc, ECC in middle
	int useq[] = { 0, 1, 2, 3, 8, 4, 5, 6, 7, -1 };
	// index 0 is ECC, then go down
	int rseq1[] = { 8, 3, 2, 1, 0, -1 };
	// index 0 has byte 4, then go up
	int rseq2[] = { 4, 5, 6, 7, -1 };
	// index 0 has byte 0, etc, no ECC
	int useqno[] = { 0, 1, 2, 3, 4, 5, 6, 7, -1 };
	// index 0 is byte 3, then go down, no ECC
	int rseq1no[] = { 3, 2, 1, 0, -1 };

	// in the CSR, bytes 0-7 are always data, byte 8 is ECC
	for (byte = 0; byte < (8 + ecc_ena); byte++) {
		// preprocess :-)
		wl[byte] = (get_wl_rank(lmc_wlevel_rank, byte) >>
			    1) & 3;
	}

	errors = 0;
	if (is_rdimm) {		// RDIMM order
		errors = validate_hwl_seq(wl, (ecc_ena) ? rseq1 : rseq1no);
		errors += validate_hwl_seq(wl, rseq2);
	} else {		// UDIMM order
		errors = validate_hwl_seq(wl, (ecc_ena) ? useq : useqno);
	}

	return errors;
}

static unsigned int extr_wr(u64 u, int x)
{
	return (unsigned int)(((u >> (x * 12 + 5)) & 0x3ULL) |
			      ((u >> (51 + x - 2)) & 0x4ULL));
}

static void insrt_wr(u64 *up, int x, int v)
{
	u64 u = *up;

	u &= ~(((0x3ULL) << (x * 12 + 5)) | ((0x1ULL) << (51 + x)));
	*up = (u | ((v & 0x3ULL) << (x * 12 + 5)) |
	       ((v & 0x4ULL) << (51 + x - 2)));
}

/* Read out Deskew Settings for DDR */

struct deskew_bytes {
	u16 bits[8];
};

struct deskew_data {
	struct deskew_bytes bytes[9];
};

struct dac_data {
	int bytes[9];
};

// T88 pass 1, skip 4=DAC
static const u8 dsk_bit_seq_p1[8] = { 0, 1, 2, 3, 5, 6, 7, 8 };
// T88 Pass 2, skip 4=DAC and 5=DBI
static const u8 dsk_bit_seq_p2[8] = { 0, 1, 2, 3, 6, 7, 8, 9 };

static void get_deskew_settings(struct ddr_priv *priv, int if_num,
				struct deskew_data *dskdat)
{
	union cvmx_lmcx_phy_ctl phy_ctl;
	union cvmx_lmcx_config lmc_config;
	int bit_index;
	int byte_lane, byte_limit;
	// NOTE: these are for pass 2.x
	int is_o78p2 = !octeon_is_cpuid(OCTEON_CN78XX_PASS1_X);
	const u8 *bit_seq = (is_o78p2) ? dsk_bit_seq_p2 : dsk_bit_seq_p1;

	lmc_config.u64 = lmc_rd(priv, CVMX_LMCX_CONFIG(if_num));
	byte_limit = ((!lmc_config.s.mode32b) ? 8 : 4) + lmc_config.s.ecc_ena;

	memset(dskdat, 0, sizeof(*dskdat));

	phy_ctl.u64 = lmc_rd(priv, CVMX_LMCX_PHY_CTL(if_num));
	phy_ctl.s.dsk_dbg_clk_scaler = 3;

	for (byte_lane = 0; byte_lane < byte_limit; byte_lane++) {
		phy_ctl.s.dsk_dbg_byte_sel = byte_lane;	// set byte lane

		for (bit_index = 0; bit_index < 8; ++bit_index) {
			// set bit number and start read sequence
			phy_ctl.s.dsk_dbg_bit_sel = bit_seq[bit_index];
			phy_ctl.s.dsk_dbg_rd_start = 1;
			lmc_wr(priv, CVMX_LMCX_PHY_CTL(if_num), phy_ctl.u64);

			// poll for read sequence to complete
			do {
				phy_ctl.u64 =
					lmc_rd(priv, CVMX_LMCX_PHY_CTL(if_num));
			} while (phy_ctl.s.dsk_dbg_rd_complete != 1);

			// record the data
			dskdat->bytes[byte_lane].bits[bit_index] =
				phy_ctl.s.dsk_dbg_rd_data & 0x3ff;
		}
	}
}

static void display_deskew_settings(struct ddr_priv *priv, int if_num,
				    struct deskew_data *dskdat,
				    int print_enable)
{
	int byte_lane;
	int bit_num;
	u16 flags, deskew;
	union cvmx_lmcx_config lmc_config;
	int byte_limit;
	const char *fc = " ?-=+*#&";

	lmc_config.u64 = lmc_rd(priv, CVMX_LMCX_CONFIG(if_num));
	byte_limit = ((lmc_config.s.mode32b) ? 4 : 8) + lmc_config.s.ecc_ena;

	if (print_enable) {
		debug("N0.LMC%d: Deskew Data:              Bit =>      :",
		      if_num);
		for (bit_num = 7; bit_num >= 0; --bit_num)
			debug(" %3d  ", bit_num);
		debug("\n");
	}

	for (byte_lane = 0; byte_lane < byte_limit; byte_lane++) {
		if (print_enable)
			debug("N0.LMC%d: Bit Deskew Byte %d %s               :",
			      if_num, byte_lane,
			      (print_enable >= 3) ? "FINAL" : "     ");

		for (bit_num = 7; bit_num >= 0; --bit_num) {
			flags = dskdat->bytes[byte_lane].bits[bit_num] & 7;
			deskew = dskdat->bytes[byte_lane].bits[bit_num] >> 3;

			if (print_enable)
				debug(" %3d %c", deskew, fc[flags ^ 1]);

		}		/* for (bit_num = 7; bit_num >= 0; --bit_num) */

		if (print_enable)
			debug("\n");
	}
}

static void override_deskew_settings(struct ddr_priv *priv, int if_num,
				     struct deskew_data *dskdat)
{
	union cvmx_lmcx_phy_ctl phy_ctl;
	union cvmx_lmcx_config lmc_config;

	int bit, byte_lane, byte_limit;
	u64 csr_data;

	lmc_config.u64 = lmc_rd(priv, CVMX_LMCX_CONFIG(if_num));
	byte_limit = ((lmc_config.s.mode32b) ? 4 : 8) + lmc_config.s.ecc_ena;

	phy_ctl.u64 = lmc_rd(priv, CVMX_LMCX_PHY_CTL(if_num));

	phy_ctl.s.phy_reset = 0;
	phy_ctl.s.dsk_dbg_num_bits_sel = 1;
	phy_ctl.s.dsk_dbg_offset = 0;
	phy_ctl.s.dsk_dbg_clk_scaler = 3;

	phy_ctl.s.dsk_dbg_wr_mode = 1;
	phy_ctl.s.dsk_dbg_load_dis = 0;
	phy_ctl.s.dsk_dbg_overwrt_ena = 0;

	phy_ctl.s.phy_dsk_reset = 0;

	lmc_wr(priv, CVMX_LMCX_PHY_CTL(if_num), phy_ctl.u64);
	lmc_rd(priv, CVMX_LMCX_PHY_CTL(if_num));

	for (byte_lane = 0; byte_lane < byte_limit; byte_lane++) {
		csr_data = 0;
		// FIXME: can we ignore DBI?
		for (bit = 0; bit < 8; ++bit) {
			// fetch input and adjust
			u64 bits = (dskdat->bytes[byte_lane].bits[bit] >> 3) &
				0x7F;

			/*
			 * lmc_general_purpose0.data[6:0]    // DQ0
			 * lmc_general_purpose0.data[13:7]   // DQ1
			 * lmc_general_purpose0.data[20:14]  // DQ2
			 * lmc_general_purpose0.data[27:21]  // DQ3
			 * lmc_general_purpose0.data[34:28]  // DQ4
			 * lmc_general_purpose0.data[41:35]  // DQ5
			 * lmc_general_purpose0.data[48:42]  // DQ6
			 * lmc_general_purpose0.data[55:49]  // DQ7
			 * lmc_general_purpose0.data[62:56]  // DBI
			 */
			csr_data |= (bits << (7 * bit));

		} /* for (bit = 0; bit < 8; ++bit) */

		// update GP0 with the bit data for this byte lane
		lmc_wr(priv, CVMX_LMCX_GENERAL_PURPOSE0(if_num), csr_data);
		lmc_rd(priv, CVMX_LMCX_GENERAL_PURPOSE0(if_num));

		// start the deskew load sequence
		phy_ctl.s.dsk_dbg_byte_sel = byte_lane;
		phy_ctl.s.dsk_dbg_rd_start = 1;
		lmc_wr(priv, CVMX_LMCX_PHY_CTL(if_num), phy_ctl.u64);

		// poll for read sequence to complete
		do {
			udelay(100);
			phy_ctl.u64 = lmc_rd(priv, CVMX_LMCX_PHY_CTL(if_num));
		} while (phy_ctl.s.dsk_dbg_rd_complete != 1);
	}

	// tell phy to use the new settings
	phy_ctl.s.dsk_dbg_overwrt_ena = 1;
	phy_ctl.s.dsk_dbg_rd_start = 0;
	lmc_wr(priv, CVMX_LMCX_PHY_CTL(if_num), phy_ctl.u64);

	phy_ctl.s.dsk_dbg_wr_mode = 0;
	lmc_wr(priv, CVMX_LMCX_PHY_CTL(if_num), phy_ctl.u64);
}

static void process_by_rank_dac(struct ddr_priv *priv, int if_num,
				int rank_mask, struct dac_data *dacdat)
{
	union cvmx_lmcx_config lmc_config;
	int rankx, byte_lane;
	int byte_limit;
	int rank_count;
	struct dac_data dacsum;
	int lane_probs;

	lmc_config.u64 = lmc_rd(priv, CVMX_LMCX_CONFIG(if_num));
	byte_limit = ((lmc_config.s.mode32b) ? 4 : 8) + lmc_config.s.ecc_ena;

	memset((void *)&dacsum, 0, sizeof(dacsum));
	rank_count = 0;
	lane_probs = 0;

	for (rankx = 0; rankx < 4; rankx++) {
		if (!(rank_mask & (1 << rankx)))
			continue;
		rank_count++;

		display_dac_dbi_settings(if_num, /*dac */ 1,
					 lmc_config.s.ecc_ena,
					 &dacdat[rankx].bytes[0],
					 "By-Ranks VREF");
		// sum
		for (byte_lane = 0; byte_lane < byte_limit; byte_lane++) {
			if (rank_count == 2) {
				int ranks_diff =
				    abs((dacsum.bytes[byte_lane] -
					 dacdat[rankx].bytes[byte_lane]));

				// FIXME: is 19 a good number?
				if (ranks_diff > 19)
					lane_probs |= (1 << byte_lane);
			}
			dacsum.bytes[byte_lane] +=
			    dacdat[rankx].bytes[byte_lane];
		}
	}

	// average
	for (byte_lane = 0; byte_lane < byte_limit; byte_lane++)
		dacsum.bytes[byte_lane] /= rank_count;	// FIXME: nint?

	display_dac_dbi_settings(if_num, /*dac */ 1, lmc_config.s.ecc_ena,
				 &dacsum.bytes[0], "All-Rank VREF");

	if (lane_probs) {
		debug("N0.LMC%d: All-Rank VREF DAC Problem Bytelane(s): 0x%03x\n",
		      if_num, lane_probs);
	}

	// finally, write the averaged DAC values
	for (byte_lane = 0; byte_lane < byte_limit; byte_lane++) {
		load_dac_override(priv, if_num, dacsum.bytes[byte_lane],
				  byte_lane);
	}
}

static void process_by_rank_dsk(struct ddr_priv *priv, int if_num,
				int rank_mask, struct deskew_data *dskdat)
{
	union cvmx_lmcx_config lmc_config;
	int rankx, lane, bit;
	int byte_limit;
	struct deskew_data dsksum, dskcnt;
	u16 deskew;

	lmc_config.u64 = lmc_rd(priv, CVMX_LMCX_CONFIG(if_num));
	byte_limit = ((lmc_config.s.mode32b) ? 4 : 8) + lmc_config.s.ecc_ena;

	memset((void *)&dsksum, 0, sizeof(dsksum));
	memset((void *)&dskcnt, 0, sizeof(dskcnt));

	for (rankx = 0; rankx < 4; rankx++) {
		if (!(rank_mask & (1 << rankx)))
			continue;

		// sum ranks
		for (lane = 0; lane < byte_limit; lane++) {
			for (bit = 0; bit < 8; ++bit) {
				deskew = dskdat[rankx].bytes[lane].bits[bit];
				// if flags indicate sat hi or lo, skip it
				if (deskew & 6)
					continue;

				// clear flags
				dsksum.bytes[lane].bits[bit] +=
					deskew & ~7;
				// count entries
				dskcnt.bytes[lane].bits[bit] += 1;
			}
		}
	}

	// average ranks
	for (lane = 0; lane < byte_limit; lane++) {
		for (bit = 0; bit < 8; ++bit) {
			int div = dskcnt.bytes[lane].bits[bit];

			if (div > 0) {
				dsksum.bytes[lane].bits[bit] /= div;
				// clear flags
				dsksum.bytes[lane].bits[bit] &= ~7;
				// set LOCK
				dsksum.bytes[lane].bits[bit] |= 1;
			} else {
				// FIXME? use reset value?
				dsksum.bytes[lane].bits[bit] =
					(64 << 3) | 1;
			}
		}
	}

	// TME for FINAL version
	display_deskew_settings(priv, if_num, &dsksum, /*VBL_TME */ 3);

	// finally, write the averaged DESKEW values
	override_deskew_settings(priv, if_num, &dsksum);
}

struct deskew_counts {
	int saturated;		// number saturated
	int unlocked;		// number unlocked
	int nibrng_errs;	// nibble range errors
	int nibunl_errs;	// nibble unlocked errors
	int bitval_errs;	// bit value errors
};

#define MIN_BITVAL  17
#define MAX_BITVAL 110

static void validate_deskew_training(struct ddr_priv *priv, int rank_mask,
				     int if_num, struct deskew_counts *counts,
				     int print_flags)
{
	int byte_lane, bit_index, nib_num;
	int nibrng_errs, nibunl_errs, bitval_errs;
	union cvmx_lmcx_config lmc_config;
	s16 nib_min[2], nib_max[2], nib_unl[2];
	int byte_limit;
	int print_enable = print_flags & 1;
	struct deskew_data dskdat;
	s16 flags, deskew;
	const char *fc = " ?-=+*#&";
	int bit_last;

	lmc_config.u64 = lmc_rd(priv, CVMX_LMCX_CONFIG(if_num));
	byte_limit = ((!lmc_config.s.mode32b) ? 8 : 4) + lmc_config.s.ecc_ena;

	memset(counts, 0, sizeof(struct deskew_counts));

	get_deskew_settings(priv, if_num, &dskdat);

	if (print_enable) {
		debug("N0.LMC%d: Deskew Settings:          Bit =>      :",
		      if_num);
		for (bit_index = 7; bit_index >= 0; --bit_index)
			debug(" %3d  ", bit_index);
		debug("\n");
	}

	for (byte_lane = 0; byte_lane < byte_limit; byte_lane++) {
		if (print_enable)
			debug("N0.LMC%d: Bit Deskew Byte %d %s               :",
			      if_num, byte_lane,
			      (print_flags & 2) ? "FINAL" : "     ");

		nib_min[0] = 127;
		nib_min[1] = 127;
		nib_max[0] = 0;
		nib_max[1] = 0;
		nib_unl[0] = 0;
		nib_unl[1] = 0;

		if (lmc_config.s.mode32b == 1 && byte_lane == 4) {
			bit_last = 3;
			if (print_enable)
				debug("                        ");
		} else {
			bit_last = 7;
		}

		for (bit_index = bit_last; bit_index >= 0; --bit_index) {
			nib_num = (bit_index > 3) ? 1 : 0;

			flags = dskdat.bytes[byte_lane].bits[bit_index] & 7;
			deskew = dskdat.bytes[byte_lane].bits[bit_index] >> 3;

			counts->saturated += !!(flags & 6);

			// Do range calc even when locked; it could happen
			// that a bit is still unlocked after final retry,
			// and we want to have an external retry if a RANGE
			// error is present at exit...
			nib_min[nib_num] = min(nib_min[nib_num], deskew);
			nib_max[nib_num] = max(nib_max[nib_num], deskew);

			if (!(flags & 1)) {	// only when not locked
				counts->unlocked += 1;
				nib_unl[nib_num] += 1;
			}

			if (print_enable)
				debug(" %3d %c", deskew, fc[flags ^ 1]);
		}

		/*
		 * Now look for nibble errors
		 *
		 * For bit 55, it looks like a bit deskew problem. When the
		 * upper nibble of byte 6 needs to go to saturation, bit 7
		 * of byte 6 locks prematurely at 64. For DIMMs with raw
		 * card A and B, can we reset the deskew training when we
		 * encounter this case? The reset criteria should be looking
		 * at one nibble at a time for raw card A and B; if the
		 * bit-deskew setting within a nibble is different by > 33,
		 * we'll issue a reset to the bit deskew training.
		 *
		 * LMC0 Bit Deskew Byte(6): 64 0 - 0 - 0 - 26 61 35 64
		 */
		// upper nibble range, then lower nibble range
		nibrng_errs = ((nib_max[1] - nib_min[1]) > 33) ? 1 : 0;
		nibrng_errs |= ((nib_max[0] - nib_min[0]) > 33) ? 1 : 0;

		// check for nibble all unlocked
		nibunl_errs = ((nib_unl[0] == 4) || (nib_unl[1] == 4)) ? 1 : 0;

		// check for bit value errors, ie < 17 or > 110
		// FIXME? assume max always > MIN_BITVAL and min < MAX_BITVAL
		bitval_errs = ((nib_max[1] > MAX_BITVAL) ||
			       (nib_max[0] > MAX_BITVAL)) ? 1 : 0;
		bitval_errs |= ((nib_min[1] < MIN_BITVAL) ||
				(nib_min[0] < MIN_BITVAL)) ? 1 : 0;

		if ((nibrng_errs != 0 || nibunl_errs != 0 ||
		     bitval_errs != 0) && print_enable) {
			debug(" %c%c%c",
			      (nibrng_errs) ? 'R' : ' ',
			      (nibunl_errs) ? 'U' : ' ',
			      (bitval_errs) ? 'V' : ' ');
		}

		if (print_enable)
			debug("\n");

		counts->nibrng_errs |= (nibrng_errs << byte_lane);
		counts->nibunl_errs |= (nibunl_errs << byte_lane);
		counts->bitval_errs |= (bitval_errs << byte_lane);
	}
}

static unsigned short load_dac_override(struct ddr_priv *priv, int if_num,
					int dac_value, int byte)
{
	union cvmx_lmcx_dll_ctl3 ddr_dll_ctl3;
	// single bytelanes incr by 1; A is for ALL
	int bytex = (byte == 0x0A) ? byte : byte + 1;

	ddr_dll_ctl3.u64 = lmc_rd(priv, CVMX_LMCX_DLL_CTL3(if_num));

	SET_DDR_DLL_CTL3(byte_sel, bytex);
	SET_DDR_DLL_CTL3(offset, dac_value >> 1);

	ddr_dll_ctl3.cn73xx.bit_select = 0x9;	/* No-op */
	lmc_wr(priv, CVMX_LMCX_DLL_CTL3(if_num), ddr_dll_ctl3.u64);

	ddr_dll_ctl3.cn73xx.bit_select = 0xC;	/* vref bypass setting load */
	lmc_wr(priv, CVMX_LMCX_DLL_CTL3(if_num), ddr_dll_ctl3.u64);

	ddr_dll_ctl3.cn73xx.bit_select = 0xD;	/* vref bypass on. */
	lmc_wr(priv, CVMX_LMCX_DLL_CTL3(if_num), ddr_dll_ctl3.u64);

	ddr_dll_ctl3.cn73xx.bit_select = 0x9;	/* No-op */
	lmc_wr(priv, CVMX_LMCX_DLL_CTL3(if_num), ddr_dll_ctl3.u64);

	lmc_rd(priv, CVMX_LMCX_DLL_CTL3(if_num));	// flush writes

	return (unsigned short)GET_DDR_DLL_CTL3(offset);
}

// arg dac_or_dbi is 1 for DAC, 0 for DBI
// returns 9 entries (bytelanes 0 through 8) in settings[]
// returns 0 if OK, -1 if a problem
static int read_dac_dbi_settings(struct ddr_priv *priv, int if_num,
				 int dac_or_dbi, int *settings)
{
	union cvmx_lmcx_phy_ctl phy_ctl;
	int byte_lane, bit_num;
	int deskew;
	int dac_value;
	int new_deskew_layout = 0;

	new_deskew_layout = octeon_is_cpuid(OCTEON_CN73XX) ||
		octeon_is_cpuid(OCTEON_CNF75XX);
	new_deskew_layout |= (octeon_is_cpuid(OCTEON_CN78XX) &&
			      !octeon_is_cpuid(OCTEON_CN78XX_PASS1_X));

	phy_ctl.u64 = lmc_rd(priv, CVMX_LMCX_PHY_CTL(if_num));
	phy_ctl.s.dsk_dbg_clk_scaler = 3;
	lmc_wr(priv, CVMX_LMCX_PHY_CTL(if_num), phy_ctl.u64);

	bit_num = (dac_or_dbi) ? 4 : 5;
	// DBI not available
	if (bit_num == 5 && !new_deskew_layout)
		return -1;

	// FIXME: always assume ECC is available
	for (byte_lane = 8; byte_lane >= 0; --byte_lane) {
		//set byte lane and bit to read
		phy_ctl.s.dsk_dbg_bit_sel = bit_num;
		phy_ctl.s.dsk_dbg_byte_sel = byte_lane;
		lmc_wr(priv, CVMX_LMCX_PHY_CTL(if_num), phy_ctl.u64);

		//start read sequence
		phy_ctl.u64 = lmc_rd(priv, CVMX_LMCX_PHY_CTL(if_num));
		phy_ctl.s.dsk_dbg_rd_start = 1;
		lmc_wr(priv, CVMX_LMCX_PHY_CTL(if_num), phy_ctl.u64);

		//poll for read sequence to complete
		do {
			phy_ctl.u64 = lmc_rd(priv, CVMX_LMCX_PHY_CTL(if_num));
		} while (phy_ctl.s.dsk_dbg_rd_complete != 1);

		// keep the flag bits where they are for DBI
		deskew = phy_ctl.s.dsk_dbg_rd_data; /* >> 3 */
		dac_value = phy_ctl.s.dsk_dbg_rd_data & 0xff;

		settings[byte_lane] = (dac_or_dbi) ? dac_value : deskew;
	}

	return 0;
}

// print out the DBI settings array
// arg dac_or_dbi is 1 for DAC, 0 for DBI
static void display_dac_dbi_settings(int lmc, int dac_or_dbi,
				     int ecc_ena, int *settings, char *title)
{
	int byte;
	int flags;
	int deskew;
	const char *fc = " ?-=+*#&";

	debug("N0.LMC%d: %s %s Settings %d:0 :",
	      lmc, title, (dac_or_dbi) ? "DAC" : "DBI", 7 + ecc_ena);
	// FIXME: what about 32-bit mode?
	for (byte = (7 + ecc_ena); byte >= 0; --byte) {
		if (dac_or_dbi) {	// DAC
			flags = 1;	// say its locked to get blank
			deskew = settings[byte] & 0xff;
		} else {	// DBI
			flags = settings[byte] & 7;
			deskew = (settings[byte] >> 3) & 0x7f;
		}
		debug(" %3d %c", deskew, fc[flags ^ 1]);
	}
	debug("\n");
}

// Find a HWL majority
static int find_wl_majority(struct wlevel_bitcnt *bc, int *mx, int *mc,
			    int *xc, int *cc)
{
	int ix, ic;

	*mx = -1;
	*mc = 0;
	*xc = 0;
	*cc = 0;

	for (ix = 0; ix < 4; ix++) {
		ic = bc->bitcnt[ix];

		// make a bitmask of the ones with a count
		if (ic > 0) {
			*mc |= (1 << ix);
			*cc += 1;	// count how many had non-zero counts
		}

		// find the majority
		if (ic > *xc) {	// new max?
			*xc = ic;	// yes
			*mx = ix;	// set its index
		}
	}

	return (*mx << 1);
}

// Evaluate the DAC settings array
static int evaluate_dac_settings(int if_64b, int ecc_ena, int *settings)
{
	int byte, lane, dac, comp;
	int last = (if_64b) ? 7 : 3;

	// FIXME: change the check...???
	// this looks only for sets of DAC values whose max/min differ by a lot
	// let any EVEN go so long as it is within range...
	for (byte = (last + ecc_ena); byte >= 0; --byte) {
		dac = settings[byte] & 0xff;

		for (lane = (last + ecc_ena); lane >= 0; --lane) {
			comp = settings[lane] & 0xff;
			if (abs((dac - comp)) > 25)
				return 1;
		}
	}

	return 0;
}

static void perform_offset_training(struct ddr_priv *priv, int rank_mask,
				    int if_num)
{
	union cvmx_lmcx_phy_ctl lmc_phy_ctl;
	u64 orig_phy_ctl;
	const char *s;

	/*
	 * 4.8.6 LMC Offset Training
	 *
	 * LMC requires input-receiver offset training.
	 *
	 * 1. Write LMC(0)_PHY_CTL[DAC_ON] = 1
	 */
	lmc_phy_ctl.u64 = lmc_rd(priv, CVMX_LMCX_PHY_CTL(if_num));
	orig_phy_ctl = lmc_phy_ctl.u64;
	lmc_phy_ctl.s.dac_on = 1;

	// allow full CSR override
	s = lookup_env_ull(priv, "ddr_phy_ctl");
	if (s)
		lmc_phy_ctl.u64 = strtoull(s, NULL, 0);

	// do not print or write if CSR does not change...
	if (lmc_phy_ctl.u64 != orig_phy_ctl) {
		debug("PHY_CTL                                       : 0x%016llx\n",
		      lmc_phy_ctl.u64);
		lmc_wr(priv, CVMX_LMCX_PHY_CTL(if_num), lmc_phy_ctl.u64);
	}

	/*
	 * 2. Write LMC(0)_SEQ_CTL[SEQ_SEL] = 0x0B and
	 *    LMC(0)_SEQ_CTL[INIT_START] = 1.
	 *
	 * 3. Wait for LMC(0)_SEQ_CTL[SEQ_COMPLETE] to be set to 1.
	 */
	/* Start Offset training sequence */
	oct3_ddr3_seq(priv, rank_mask, if_num, 0x0B);
}

static void perform_internal_vref_training(struct ddr_priv *priv,
					   int rank_mask, int if_num)
{
	union cvmx_lmcx_ext_config ext_config;
	union cvmx_lmcx_dll_ctl3 ddr_dll_ctl3;

	// First, make sure all byte-lanes are out of VREF bypass mode
	ddr_dll_ctl3.u64 = lmc_rd(priv, CVMX_LMCX_DLL_CTL3(if_num));

	ddr_dll_ctl3.cn78xx.byte_sel = 0x0A;	/* all byte-lanes */
	ddr_dll_ctl3.cn78xx.bit_select = 0x09;	/* No-op */
	lmc_wr(priv, CVMX_LMCX_DLL_CTL3(if_num), ddr_dll_ctl3.u64);

	ddr_dll_ctl3.cn78xx.bit_select = 0x0E;	/* vref bypass off. */
	lmc_wr(priv, CVMX_LMCX_DLL_CTL3(if_num), ddr_dll_ctl3.u64);

	ddr_dll_ctl3.cn78xx.bit_select = 0x09;	/* No-op */
	lmc_wr(priv, CVMX_LMCX_DLL_CTL3(if_num), ddr_dll_ctl3.u64);

	/*
	 * 4.8.7 LMC Internal vref Training
	 *
	 * LMC requires input-reference-voltage training.
	 *
	 * 1. Write LMC(0)_EXT_CONFIG[VREFINT_SEQ_DESKEW] = 0.
	 */
	ext_config.u64 = lmc_rd(priv, CVMX_LMCX_EXT_CONFIG(if_num));
	ext_config.s.vrefint_seq_deskew = 0;

	ddr_seq_print("Performing LMC sequence: vrefint_seq_deskew = %d\n",
		      ext_config.s.vrefint_seq_deskew);

	lmc_wr(priv, CVMX_LMCX_EXT_CONFIG(if_num), ext_config.u64);

	/*
	 * 2. Write LMC(0)_SEQ_CTL[SEQ_SEL] = 0x0a and
	 *    LMC(0)_SEQ_CTL[INIT_START] = 1.
	 *
	 * 3. Wait for LMC(0)_SEQ_CTL[SEQ_COMPLETE] to be set to 1.
	 */
	/* Start LMC Internal vref Training */
	oct3_ddr3_seq(priv, rank_mask, if_num, 0x0A);
}

#define dbg_avg(format, ...)	// debug(format, ##__VA_ARGS__)

static int process_samples_average(s16 *bytes, int num_samples,
				   int lmc, int lane_no)
{
	int i, sadj, sum = 0, ret, asum, trunc;
	s16 smin = 32767, smax = -32768;
	int nmin, nmax;
	//int rng;

	dbg_avg("DBG_AVG%d.%d: ", lmc, lane_no);

	for (i = 0; i < num_samples; i++) {
		sum += bytes[i];
		if (bytes[i] < smin)
			smin = bytes[i];
		if (bytes[i] > smax)
			smax = bytes[i];
		dbg_avg(" %3d", bytes[i]);
	}

	nmin = 0;
	nmax = 0;
	for (i = 0; i < num_samples; i++) {
		if (bytes[i] == smin)
			nmin += 1;
		if (bytes[i] == smax)
			nmax += 1;
	}
	dbg_avg(" (min=%3d/%d, max=%3d/%d, range=%2d, samples=%2d)",
		smin, nmin, smax, nmax, rng, num_samples);

	asum = sum - smin - smax;

	sadj = divide_nint(asum * 10, (num_samples - 2));

	trunc = asum / (num_samples - 2);

	dbg_avg(" [%3d.%d, %3d]", sadj / 10, sadj % 10, trunc);

	sadj = divide_nint(sadj, 10);
	if (trunc & 1)
		ret = trunc;
	else if (sadj & 1)
		ret = sadj;
	else
		ret = trunc + 1;

	dbg_avg(" -> %3d\n", ret);

	return ret;
}

#define DEFAULT_SAT_RETRY_LIMIT    11	// 1 + 10 retries

#define default_lock_retry_limit   20	// 20 retries
#define deskew_validation_delay    10000	// 10 millisecs

static int perform_deskew_training(struct ddr_priv *priv, int rank_mask,
				   int if_num, int spd_rawcard_aorb)
{
	int unsaturated, locked;
	int sat_retries, sat_retries_limit;
	int lock_retries, lock_retries_total, lock_retries_limit;
	int print_first;
	int print_them_all;
	struct deskew_counts dsk_counts;
	union cvmx_lmcx_phy_ctl phy_ctl;
	char *s;
	int has_no_sat = octeon_is_cpuid(OCTEON_CN78XX_PASS2_X) ||
		octeon_is_cpuid(OCTEON_CNF75XX);
	int disable_bitval_retries = 1;	// default to disabled

	debug("N0.LMC%d: Performing Deskew Training.\n", if_num);

	sat_retries = 0;
	sat_retries_limit = (has_no_sat) ? 5 : DEFAULT_SAT_RETRY_LIMIT;

	lock_retries_total = 0;
	unsaturated = 0;
	print_first = 1;	// print the first one
	// set to true for printing all normal deskew attempts
	print_them_all = 0;

	// provide override for bitval_errs causing internal VREF retries
	s = env_get("ddr_disable_bitval_retries");
	if (s)
		disable_bitval_retries = !!simple_strtoul(s, NULL, 0);

	lock_retries_limit = default_lock_retry_limit;
	if ((octeon_is_cpuid(OCTEON_CN78XX_PASS2_X)) ||
	    (octeon_is_cpuid(OCTEON_CN73XX)) ||
	    (octeon_is_cpuid(OCTEON_CNF75XX)))
		lock_retries_limit *= 2;	// give new chips twice as many

	do {			/* while (sat_retries < sat_retry_limit) */
		/*
		 * 4.8.8 LMC Deskew Training
		 *
		 * LMC requires input-read-data deskew training.
		 *
		 * 1. Write LMC(0)_EXT_CONFIG[VREFINT_SEQ_DESKEW] = 1.
		 */

		union cvmx_lmcx_ext_config ext_config;

		ext_config.u64 = lmc_rd(priv, CVMX_LMCX_EXT_CONFIG(if_num));
		ext_config.s.vrefint_seq_deskew = 1;

		ddr_seq_print
		    ("Performing LMC sequence: vrefint_seq_deskew = %d\n",
		     ext_config.s.vrefint_seq_deskew);

		lmc_wr(priv, CVMX_LMCX_EXT_CONFIG(if_num), ext_config.u64);

		/*
		 * 2. Write LMC(0)_SEQ_CTL[SEQ_SEL] = 0x0A and
		 *    LMC(0)_SEQ_CTL[INIT_START] = 1.
		 *
		 * 3. Wait for LMC(0)_SEQ_CTL[SEQ_COMPLETE] to be set to 1.
		 */

		phy_ctl.u64 = lmc_rd(priv, CVMX_LMCX_PHY_CTL(if_num));
		phy_ctl.s.phy_dsk_reset = 1;	/* RESET Deskew sequence */
		lmc_wr(priv, CVMX_LMCX_PHY_CTL(if_num), phy_ctl.u64);

		/* LMC Deskew Training */
		oct3_ddr3_seq(priv, rank_mask, if_num, 0x0A);

		lock_retries = 0;

perform_deskew_training:

		phy_ctl.u64 = lmc_rd(priv, CVMX_LMCX_PHY_CTL(if_num));
		phy_ctl.s.phy_dsk_reset = 0;	/* Normal Deskew sequence */
		lmc_wr(priv, CVMX_LMCX_PHY_CTL(if_num), phy_ctl.u64);

		/* LMC Deskew Training */
		oct3_ddr3_seq(priv, rank_mask, if_num, 0x0A);

		// Moved this from validate_deskew_training
		/* Allow deskew results to stabilize before evaluating them. */
		udelay(deskew_validation_delay);

		// Now go look at lock and saturation status...
		validate_deskew_training(priv, rank_mask, if_num, &dsk_counts,
					 print_first);
		// after printing the first and not doing them all, no more
		if (print_first && !print_them_all)
			print_first = 0;

		unsaturated = (dsk_counts.saturated == 0);
		locked = (dsk_counts.unlocked == 0);

		// only do locking retries if unsaturated or rawcard A or B,
		// otherwise full SAT retry
		if (unsaturated || (spd_rawcard_aorb && !has_no_sat)) {
			if (!locked) {	// and not locked
				lock_retries++;
				lock_retries_total++;
				if (lock_retries <= lock_retries_limit) {
					goto perform_deskew_training;
				} else {
					debug("N0.LMC%d: LOCK RETRIES failed after %d retries\n",
					      if_num, lock_retries_limit);
				}
			} else {
				// only print if we did try
				if (lock_retries_total > 0)
					debug("N0.LMC%d: LOCK RETRIES successful after %d retries\n",
					      if_num, lock_retries);
			}
		}		/* if (unsaturated || spd_rawcard_aorb) */

		++sat_retries;

		/*
		 * At this point, check for a DDR4 RDIMM that will not
		 * benefit from SAT retries; if so, exit
		 */
		if (spd_rawcard_aorb && !has_no_sat) {
			debug("N0.LMC%d: Deskew Training Loop: Exiting for RAWCARD == A or B.\n",
			      if_num);
			break;	// no sat or lock retries
		}

	} while (!unsaturated && (sat_retries < sat_retries_limit));

	debug("N0.LMC%d: Deskew Training %s. %d sat-retries, %d lock-retries\n",
	      if_num, (sat_retries >= DEFAULT_SAT_RETRY_LIMIT) ?
	      "Timed Out" : "Completed", sat_retries - 1, lock_retries_total);

	// FIXME? add saturation to reasons for fault return - give it a
	// chance via Internal VREF
	// FIXME? add OPTIONAL bit value to reasons for fault return -
	// give it a chance via Internal VREF
	if (dsk_counts.nibrng_errs != 0 || dsk_counts.nibunl_errs != 0 ||
	    (dsk_counts.bitval_errs != 0 && !disable_bitval_retries) ||
	    !unsaturated) {
		debug("N0.LMC%d: Nibble or Saturation Error(s) found, returning FAULT\n",
		      if_num);
		// FIXME: do we want this output always for errors?
		validate_deskew_training(priv, rank_mask, if_num,
					 &dsk_counts, 1);
		return -1;	// we did retry locally, they did not help
	}

	// NOTE: we (currently) always print one last training validation
	// before starting Read Leveling...

	return 0;
}

#define SCALING_FACTOR (1000)

// NOTE: this gets called for 1-rank and 2-rank DIMMs in single-slot config
static int compute_vref_1slot_2rank(int rtt_wr, int rtt_park, int dqx_ctl,
				    int rank_count, int dram_connection)
{
	u64 reff_s;
	u64 rser_s = (dram_connection) ? 0 : 15;
	u64 vdd = 1200;
	u64 vref;
	// 99 == HiZ
	u64 rtt_wr_s = (((rtt_wr == 0) || rtt_wr == 99) ?
			1 * 1024 * 1024 : rtt_wr);
	u64 rtt_park_s = (((rtt_park == 0) || ((rank_count == 1) &&
					       (rtt_wr != 0))) ?
			  1 * 1024 * 1024 : rtt_park);
	u64 dqx_ctl_s = (dqx_ctl == 0 ? 1 * 1024 * 1024 : dqx_ctl);
	int vref_value;
	u64 rangepc = 6000;	// range1 base
	u64 vrefpc;
	int vref_range = 0;

	reff_s = divide_nint((rtt_wr_s * rtt_park_s), (rtt_wr_s + rtt_park_s));

	vref = (((rser_s + dqx_ctl_s) * SCALING_FACTOR) /
		(rser_s + dqx_ctl_s + reff_s)) + SCALING_FACTOR;

	vref = (vref * vdd) / 2 / SCALING_FACTOR;

	vrefpc = (vref * 100 * 100) / vdd;

	if (vrefpc < rangepc) {	// < range1 base, use range2
		vref_range = 1 << 6;	// set bit A6 for range2
		rangepc = 4500;	// range2 base is 45%
	}

	vref_value = divide_nint(vrefpc - rangepc, 65);
	if (vref_value < 0)
		vref_value = vref_range;	// set to base of range
	else
		vref_value |= vref_range;

	debug("rtt_wr: %d, rtt_park: %d, dqx_ctl: %d, rank_count: %d\n",
	      rtt_wr, rtt_park, dqx_ctl, rank_count);
	debug("rtt_wr_s: %lld, rtt_park_s: %lld, dqx_ctl_s: %lld, vref_value: 0x%x, range: %d\n",
	      rtt_wr_s, rtt_park_s, dqx_ctl_s, vref_value ^ vref_range,
	      vref_range ? 2 : 1);

	return vref_value;
}

// NOTE: this gets called for 1-rank and 2-rank DIMMs in two-slot configs
static int compute_vref_2slot_2rank(int rtt_wr, int rtt_park_00,
				    int rtt_park_01,
				    int dqx_ctl, int rtt_nom,
				    int dram_connection)
{
	u64 rser = (dram_connection) ? 0 : 15;
	u64 vdd = 1200;
	u64 vl, vlp, vcm;
	u64 rd0, rd1, rpullup;
	// 99 == HiZ
	u64 rtt_wr_s = (((rtt_wr == 0) || rtt_wr == 99) ?
			1 * 1024 * 1024 : rtt_wr);
	u64 rtt_park_00_s = (rtt_park_00 == 0 ? 1 * 1024 * 1024 : rtt_park_00);
	u64 rtt_park_01_s = (rtt_park_01 == 0 ? 1 * 1024 * 1024 : rtt_park_01);
	u64 dqx_ctl_s = (dqx_ctl == 0 ? 1 * 1024 * 1024 : dqx_ctl);
	u64 rtt_nom_s = (rtt_nom == 0 ? 1 * 1024 * 1024 : rtt_nom);
	int vref_value;
	u64 rangepc = 6000;	// range1 base
	u64 vrefpc;
	int vref_range = 0;

	// rd0 = (RTT_NOM (parallel) RTT_WR) +  =
	// ((RTT_NOM * RTT_WR) / (RTT_NOM + RTT_WR)) + RSER
	rd0 = divide_nint((rtt_nom_s * rtt_wr_s),
			  (rtt_nom_s + rtt_wr_s)) + rser;

	// rd1 = (RTT_PARK_00 (parallel) RTT_PARK_01) + RSER =
	// ((RTT_PARK_00 * RTT_PARK_01) / (RTT_PARK_00 + RTT_PARK_01)) + RSER
	rd1 = divide_nint((rtt_park_00_s * rtt_park_01_s),
			  (rtt_park_00_s + rtt_park_01_s)) + rser;

	// rpullup = rd0 (parallel) rd1 = (rd0 * rd1) / (rd0 + rd1)
	rpullup = divide_nint((rd0 * rd1), (rd0 + rd1));

	// vl = (DQX_CTL / (DQX_CTL + rpullup)) * 1.2
	vl = divide_nint((dqx_ctl_s * vdd), (dqx_ctl_s + rpullup));

	// vlp = ((RSER / rd0) * (1.2 - vl)) + vl
	vlp = divide_nint((rser * (vdd - vl)), rd0) + vl;

	// vcm = (vlp + 1.2) / 2
	vcm = divide_nint((vlp + vdd), 2);

	// vrefpc = (vcm / 1.2) * 100
	vrefpc = divide_nint((vcm * 100 * 100), vdd);

	if (vrefpc < rangepc) {	// < range1 base, use range2
		vref_range = 1 << 6;	// set bit A6 for range2
		rangepc = 4500;	// range2 base is 45%
	}

	vref_value = divide_nint(vrefpc - rangepc, 65);
	if (vref_value < 0)
		vref_value = vref_range;	// set to base of range
	else
		vref_value |= vref_range;

	debug("rtt_wr:%d, rtt_park_00:%d, rtt_park_01:%d, dqx_ctl:%d, rtt_nom:%d, vref_value:%d (0x%x)\n",
	      rtt_wr, rtt_park_00, rtt_park_01, dqx_ctl, rtt_nom, vref_value,
	      vref_value);

	return vref_value;
}

// NOTE: only call this for DIMMs with 1 or 2 ranks, not 4.
static int compute_vref_val(struct ddr_priv *priv, int if_num, int rankx,
			    int dimm_count, int rank_count,
			    struct impedence_values *imp_values,
			    int is_stacked_die, int dram_connection)
{
	int computed_final_vref_value = 0;
	int enable_adjust = ENABLE_COMPUTED_VREF_ADJUSTMENT;
	const char *s;
	int rtt_wr, dqx_ctl, rtt_nom, index;
	union cvmx_lmcx_modereg_params1 lmc_modereg_params1;
	union cvmx_lmcx_modereg_params2 lmc_modereg_params2;
	union cvmx_lmcx_comp_ctl2 comp_ctl2;
	int rtt_park;
	int rtt_park_00;
	int rtt_park_01;

	debug("N0.LMC%d.R%d: %s(...dram_connection = %d)\n",
	      if_num, rankx, __func__, dram_connection);

	// allow some overrides...
	s = env_get("ddr_adjust_computed_vref");
	if (s) {
		enable_adjust = !!simple_strtoul(s, NULL, 0);
		if (!enable_adjust) {
			debug("N0.LMC%d.R%d: DISABLE adjustment of computed VREF\n",
			      if_num, rankx);
		}
	}

	s = env_get("ddr_set_computed_vref");
	if (s) {
		int new_vref = simple_strtoul(s, NULL, 0);

		debug("N0.LMC%d.R%d: OVERRIDE computed VREF to 0x%x (%d)\n",
		      if_num, rankx, new_vref, new_vref);
		return new_vref;
	}

	/*
	 * Calculate an alternative to the measured vref value
	 * but only for configurations we know how to...
	 */
	// We have code for 2-rank DIMMs in both 1-slot or 2-slot configs,
	// and can use the 2-rank 1-slot code for 1-rank DIMMs in 1-slot
	// configs, and can use the 2-rank 2-slot code for 1-rank DIMMs
	// in 2-slot configs.

	lmc_modereg_params1.u64 =
	    lmc_rd(priv, CVMX_LMCX_MODEREG_PARAMS1(if_num));
	lmc_modereg_params2.u64 =
	    lmc_rd(priv, CVMX_LMCX_MODEREG_PARAMS2(if_num));
	comp_ctl2.u64 = lmc_rd(priv, CVMX_LMCX_COMP_CTL2(if_num));
	dqx_ctl = imp_values->dqx_strength[comp_ctl2.s.dqx_ctl];

	// WR always comes from the current rank
	index = (lmc_modereg_params1.u64 >> (rankx * 12 + 5)) & 0x03;
	if (!octeon_is_cpuid(OCTEON_CN78XX_PASS1_X))
		index |= lmc_modereg_params1.u64 >> (51 + rankx - 2) & 0x04;
	rtt_wr = imp_values->rtt_wr_ohms[index];

	// separate calculations for 1 vs 2 DIMMs per LMC
	if (dimm_count == 1) {
		// PARK comes from this rank if 1-rank, otherwise other rank
		index =
		    (lmc_modereg_params2.u64 >>
		     ((rankx ^ (rank_count - 1)) * 10 + 0)) & 0x07;
		rtt_park = imp_values->rtt_nom_ohms[index];
		computed_final_vref_value =
		    compute_vref_1slot_2rank(rtt_wr, rtt_park, dqx_ctl,
					     rank_count, dram_connection);
	} else {
		// get both PARK values from the other DIMM
		index =
		    (lmc_modereg_params2.u64 >> ((rankx ^ 0x02) * 10 + 0)) &
		    0x07;
		rtt_park_00 = imp_values->rtt_nom_ohms[index];
		index =
		    (lmc_modereg_params2.u64 >> ((rankx ^ 0x03) * 10 + 0)) &
		    0x07;
		rtt_park_01 = imp_values->rtt_nom_ohms[index];
		// NOM comes from this rank if 1-rank, otherwise other rank
		index =
		    (lmc_modereg_params1.u64 >>
		     ((rankx ^ (rank_count - 1)) * 12 + 9)) & 0x07;
		rtt_nom = imp_values->rtt_nom_ohms[index];
		computed_final_vref_value =
		    compute_vref_2slot_2rank(rtt_wr, rtt_park_00, rtt_park_01,
					     dqx_ctl, rtt_nom, dram_connection);
	}

	if (enable_adjust) {
		union cvmx_lmcx_config lmc_config;
		union cvmx_lmcx_control lmc_control;

		lmc_config.u64 = lmc_rd(priv, CVMX_LMCX_CONFIG(if_num));
		lmc_control.u64 = lmc_rd(priv, CVMX_LMCX_CONTROL(if_num));

		/*
		 *  New computed vref = existing computed vref – X
		 *
		 * The value of X is depending on different conditions.
		 * Both #122 and #139 are 2Rx4 RDIMM, while #124 is stacked
		 * die 2Rx4, so I conclude the results into two conditions:
		 *
		 * 1. Stacked Die: 2Rx4
		 * 1-slot: offset = 7. i, e New computed vref = existing
		 * computed vref – 7
		 * 2-slot: offset = 6
		 *
		 * 2. Regular: 2Rx4
		 * 1-slot: offset = 3
		 * 2-slot:  offset = 2
		 */
		// we know we never get called unless DDR4, so test just
		// the other conditions
		if (lmc_control.s.rdimm_ena == 1 &&
		    rank_count == 2 && lmc_config.s.mode_x4dev) {
			// it must first be RDIMM and 2-rank and x4
			int adj;

			// now do according to stacked die or not...
			if (is_stacked_die)
				adj = (dimm_count == 1) ? -7 : -6;
			else
				adj = (dimm_count == 1) ? -3 : -2;

			// we must have adjusted it, so print it out if
			// verbosity is right
			debug("N0.LMC%d.R%d: adjusting computed vref from %2d (0x%02x) to %2d (0x%02x)\n",
			      if_num, rankx, computed_final_vref_value,
			      computed_final_vref_value,
			      computed_final_vref_value + adj,
			      computed_final_vref_value + adj);
			computed_final_vref_value += adj;
		}
	}

	return computed_final_vref_value;
}

static void unpack_rlevel_settings(int if_bytemask, int ecc_ena,
				   struct rlevel_byte_data *rlevel_byte,
				   union cvmx_lmcx_rlevel_rankx lmc_rlevel_rank)
{
	if ((if_bytemask & 0xff) == 0xff) {
		if (ecc_ena) {
			rlevel_byte[8].delay = lmc_rlevel_rank.s.byte7;
			rlevel_byte[7].delay = lmc_rlevel_rank.s.byte6;
			rlevel_byte[6].delay = lmc_rlevel_rank.s.byte5;
			rlevel_byte[5].delay = lmc_rlevel_rank.s.byte4;
			/* ECC */
			rlevel_byte[4].delay = lmc_rlevel_rank.s.byte8;
		} else {
			rlevel_byte[7].delay = lmc_rlevel_rank.s.byte7;
			rlevel_byte[6].delay = lmc_rlevel_rank.s.byte6;
			rlevel_byte[5].delay = lmc_rlevel_rank.s.byte5;
			rlevel_byte[4].delay = lmc_rlevel_rank.s.byte4;
		}
	} else {
		rlevel_byte[8].delay = lmc_rlevel_rank.s.byte8;	/* unused */
		rlevel_byte[7].delay = lmc_rlevel_rank.s.byte7;	/* unused */
		rlevel_byte[6].delay = lmc_rlevel_rank.s.byte6;	/* unused */
		rlevel_byte[5].delay = lmc_rlevel_rank.s.byte5;	/* unused */
		rlevel_byte[4].delay = lmc_rlevel_rank.s.byte4;	/* ECC */
	}

	rlevel_byte[3].delay = lmc_rlevel_rank.s.byte3;
	rlevel_byte[2].delay = lmc_rlevel_rank.s.byte2;
	rlevel_byte[1].delay = lmc_rlevel_rank.s.byte1;
	rlevel_byte[0].delay = lmc_rlevel_rank.s.byte0;
}

static void pack_rlevel_settings(int if_bytemask, int ecc_ena,
				 struct rlevel_byte_data *rlevel_byte,
				 union cvmx_lmcx_rlevel_rankx
				 *final_rlevel_rank)
{
	union cvmx_lmcx_rlevel_rankx lmc_rlevel_rank = *final_rlevel_rank;

	if ((if_bytemask & 0xff) == 0xff) {
		if (ecc_ena) {
			lmc_rlevel_rank.s.byte7 = rlevel_byte[8].delay;
			lmc_rlevel_rank.s.byte6 = rlevel_byte[7].delay;
			lmc_rlevel_rank.s.byte5 = rlevel_byte[6].delay;
			lmc_rlevel_rank.s.byte4 = rlevel_byte[5].delay;
			/* ECC */
			lmc_rlevel_rank.s.byte8 = rlevel_byte[4].delay;
		} else {
			lmc_rlevel_rank.s.byte7 = rlevel_byte[7].delay;
			lmc_rlevel_rank.s.byte6 = rlevel_byte[6].delay;
			lmc_rlevel_rank.s.byte5 = rlevel_byte[5].delay;
			lmc_rlevel_rank.s.byte4 = rlevel_byte[4].delay;
		}
	} else {
		lmc_rlevel_rank.s.byte8 = rlevel_byte[8].delay;
		lmc_rlevel_rank.s.byte7 = rlevel_byte[7].delay;
		lmc_rlevel_rank.s.byte6 = rlevel_byte[6].delay;
		lmc_rlevel_rank.s.byte5 = rlevel_byte[5].delay;
		lmc_rlevel_rank.s.byte4 = rlevel_byte[4].delay;
	}

	lmc_rlevel_rank.s.byte3 = rlevel_byte[3].delay;
	lmc_rlevel_rank.s.byte2 = rlevel_byte[2].delay;
	lmc_rlevel_rank.s.byte1 = rlevel_byte[1].delay;
	lmc_rlevel_rank.s.byte0 = rlevel_byte[0].delay;

	*final_rlevel_rank = lmc_rlevel_rank;
}

/////////////////// These are the RLEVEL settings display routines

// flags
#define WITH_NOTHING 0
#define WITH_SCORE   1
#define WITH_AVERAGE 2
#define WITH_FINAL   4
#define WITH_COMPUTE 8

static void do_display_rl(int if_num,
			  union cvmx_lmcx_rlevel_rankx lmc_rlevel_rank,
			  int rank, int flags, int score)
{
	char score_buf[16];
	char *msg_buf;
	char hex_buf[20];

	if (flags & WITH_SCORE) {
		snprintf(score_buf, sizeof(score_buf), "(%d)", score);
	} else {
		score_buf[0] = ' ';
		score_buf[1] = 0;
	}

	if (flags & WITH_AVERAGE) {
		msg_buf = "  DELAY AVERAGES  ";
	} else if (flags & WITH_FINAL) {
		msg_buf = "  FINAL SETTINGS  ";
	} else if (flags & WITH_COMPUTE) {
		msg_buf = "  COMPUTED DELAYS ";
	} else {
		snprintf(hex_buf, sizeof(hex_buf), "0x%016llX",
			 (unsigned long long)lmc_rlevel_rank.u64);
		msg_buf = hex_buf;
	}

	debug("N0.LMC%d.R%d: Rlevel Rank %#4x, %s  : %5d %5d %5d %5d %5d %5d %5d %5d %5d %s\n",
	      if_num, rank, lmc_rlevel_rank.s.status, msg_buf,
	      lmc_rlevel_rank.s.byte8, lmc_rlevel_rank.s.byte7,
	      lmc_rlevel_rank.s.byte6, lmc_rlevel_rank.s.byte5,
	      lmc_rlevel_rank.s.byte4, lmc_rlevel_rank.s.byte3,
	      lmc_rlevel_rank.s.byte2, lmc_rlevel_rank.s.byte1,
	      lmc_rlevel_rank.s.byte0, score_buf);
}

static void display_rl(int if_num,
		       union cvmx_lmcx_rlevel_rankx lmc_rlevel_rank, int rank)
{
	do_display_rl(if_num, lmc_rlevel_rank, rank, 0, 0);
}

static void display_rl_with_score(int if_num,
				  union cvmx_lmcx_rlevel_rankx lmc_rlevel_rank,
				  int rank, int score)
{
	do_display_rl(if_num, lmc_rlevel_rank, rank, 1, score);
}

static void display_rl_with_final(int if_num,
				  union cvmx_lmcx_rlevel_rankx lmc_rlevel_rank,
				  int rank)
{
	do_display_rl(if_num, lmc_rlevel_rank, rank, 4, 0);
}

static void display_rl_with_computed(int if_num,
				     union cvmx_lmcx_rlevel_rankx
				     lmc_rlevel_rank, int rank, int score)
{
	do_display_rl(if_num, lmc_rlevel_rank, rank, 9, score);
}

// flag values
#define WITH_RODT_BLANK      0
#define WITH_RODT_SKIPPING   1
#define WITH_RODT_BESTROW    2
#define WITH_RODT_BESTSCORE  3
// control
#define SKIP_SKIPPING 1

static const char *with_rodt_canned_msgs[4] = {
	"          ", "SKIPPING  ", "BEST ROW  ", "BEST SCORE"
};

static void display_rl_with_rodt(int if_num,
				 union cvmx_lmcx_rlevel_rankx lmc_rlevel_rank,
				 int rank, int score,
				 int nom_ohms, int rodt_ohms, int flag)
{
	const char *msg_buf;
	char set_buf[20];

#if SKIP_SKIPPING
	if (flag == WITH_RODT_SKIPPING)
		return;
#endif

	msg_buf = with_rodt_canned_msgs[flag];
	if (nom_ohms < 0) {
		snprintf(set_buf, sizeof(set_buf), "    RODT %3d    ",
			 rodt_ohms);
	} else {
		snprintf(set_buf, sizeof(set_buf), "NOM %3d RODT %3d", nom_ohms,
			 rodt_ohms);
	}

	debug("N0.LMC%d.R%d: Rlevel %s   %s  : %5d %5d %5d %5d %5d %5d %5d %5d %5d (%d)\n",
	      if_num, rank, set_buf, msg_buf, lmc_rlevel_rank.s.byte8,
	      lmc_rlevel_rank.s.byte7, lmc_rlevel_rank.s.byte6,
	      lmc_rlevel_rank.s.byte5, lmc_rlevel_rank.s.byte4,
	      lmc_rlevel_rank.s.byte3, lmc_rlevel_rank.s.byte2,
	      lmc_rlevel_rank.s.byte1, lmc_rlevel_rank.s.byte0, score);
}

static void do_display_wl(int if_num,
			  union cvmx_lmcx_wlevel_rankx lmc_wlevel_rank,
			  int rank, int flags)
{
	char *msg_buf;
	char hex_buf[20];

	if (flags & WITH_FINAL) {
		msg_buf = "  FINAL SETTINGS  ";
	} else {
		snprintf(hex_buf, sizeof(hex_buf), "0x%016llX",
			 (unsigned long long)lmc_wlevel_rank.u64);
		msg_buf = hex_buf;
	}

	debug("N0.LMC%d.R%d: Wlevel Rank %#4x, %s  : %5d %5d %5d %5d %5d %5d %5d %5d %5d\n",
	      if_num, rank, lmc_wlevel_rank.s.status, msg_buf,
	      lmc_wlevel_rank.s.byte8, lmc_wlevel_rank.s.byte7,
	      lmc_wlevel_rank.s.byte6, lmc_wlevel_rank.s.byte5,
	      lmc_wlevel_rank.s.byte4, lmc_wlevel_rank.s.byte3,
	      lmc_wlevel_rank.s.byte2, lmc_wlevel_rank.s.byte1,
	      lmc_wlevel_rank.s.byte0);
}

static void display_wl(int if_num,
		       union cvmx_lmcx_wlevel_rankx lmc_wlevel_rank, int rank)
{
	do_display_wl(if_num, lmc_wlevel_rank, rank, WITH_NOTHING);
}

static void display_wl_with_final(int if_num,
				  union cvmx_lmcx_wlevel_rankx lmc_wlevel_rank,
				  int rank)
{
	do_display_wl(if_num, lmc_wlevel_rank, rank, WITH_FINAL);
}

// pretty-print bitmask adjuster
static u64 ppbm(u64 bm)
{
	if (bm != 0ul) {
		while ((bm & 0x0fful) == 0ul)
			bm >>= 4;
	}

	return bm;
}

// xlate PACKED index to UNPACKED index to use with rlevel_byte
#define XPU(i, e) (((i) < 4) ? (i) : (((i) < 8) ? (i) + (e) : 4))
// xlate UNPACKED index to PACKED index to use with rlevel_bitmask
#define XUP(i, e) (((i) < 4) ? (i) : (e) ? (((i) > 4) ? (i) - 1 : 8) : (i))

// flag values
#define WITH_WL_BITMASKS      0
#define WITH_RL_BITMASKS      1
#define WITH_RL_MASK_SCORES   2
#define WITH_RL_SEQ_SCORES    3

static void do_display_bm(int if_num, int rank, void *bm,
			  int flags, int ecc)
{
	if (flags == WITH_WL_BITMASKS) {
		// wlevel_bitmask array in PACKED index order, so just
		// print them
		int *bitmasks = (int *)bm;

		debug("N0.LMC%d.R%d: Wlevel Debug Bitmasks                 : %05x %05x %05x %05x %05x %05x %05x %05x %05x\n",
		      if_num, rank, bitmasks[8], bitmasks[7], bitmasks[6],
		      bitmasks[5], bitmasks[4], bitmasks[3], bitmasks[2],
		      bitmasks[1], bitmasks[0]
			);
	} else if (flags == WITH_RL_BITMASKS) {
		// rlevel_bitmask array in PACKED index order, so just
		// print them
		struct rlevel_bitmask *rlevel_bitmask =
			(struct rlevel_bitmask *)bm;

		debug("N0.LMC%d.R%d: Rlevel Debug Bitmasks        8:0      : %05llx %05llx %05llx %05llx %05llx %05llx %05llx %05llx %05llx\n",
		      if_num, rank, ppbm(rlevel_bitmask[8].bm),
		      ppbm(rlevel_bitmask[7].bm), ppbm(rlevel_bitmask[6].bm),
		      ppbm(rlevel_bitmask[5].bm), ppbm(rlevel_bitmask[4].bm),
		      ppbm(rlevel_bitmask[3].bm), ppbm(rlevel_bitmask[2].bm),
		      ppbm(rlevel_bitmask[1].bm), ppbm(rlevel_bitmask[0].bm)
			);
	} else if (flags == WITH_RL_MASK_SCORES) {
		// rlevel_bitmask array in PACKED index order, so just
		// print them
		struct rlevel_bitmask *rlevel_bitmask =
			(struct rlevel_bitmask *)bm;

		debug("N0.LMC%d.R%d: Rlevel Debug Bitmask Scores  8:0      : %5d %5d %5d %5d %5d %5d %5d %5d %5d\n",
		      if_num, rank, rlevel_bitmask[8].errs,
		      rlevel_bitmask[7].errs, rlevel_bitmask[6].errs,
		      rlevel_bitmask[5].errs, rlevel_bitmask[4].errs,
		      rlevel_bitmask[3].errs, rlevel_bitmask[2].errs,
		      rlevel_bitmask[1].errs, rlevel_bitmask[0].errs);
	} else if (flags == WITH_RL_SEQ_SCORES) {
		// rlevel_byte array in UNPACKED index order, so xlate
		// and print them
		struct rlevel_byte_data *rlevel_byte =
			(struct rlevel_byte_data *)bm;

		debug("N0.LMC%d.R%d: Rlevel Debug Non-seq Scores  8:0      : %5d %5d %5d %5d %5d %5d %5d %5d %5d\n",
		      if_num, rank, rlevel_byte[XPU(8, ecc)].sqerrs,
		      rlevel_byte[XPU(7, ecc)].sqerrs,
		      rlevel_byte[XPU(6, ecc)].sqerrs,
		      rlevel_byte[XPU(5, ecc)].sqerrs,
		      rlevel_byte[XPU(4, ecc)].sqerrs,
		      rlevel_byte[XPU(3, ecc)].sqerrs,
		      rlevel_byte[XPU(2, ecc)].sqerrs,
		      rlevel_byte[XPU(1, ecc)].sqerrs,
		      rlevel_byte[XPU(0, ecc)].sqerrs);
	}
}

static void display_wl_bm(int if_num, int rank, int *bitmasks)
{
	do_display_bm(if_num, rank, (void *)bitmasks, WITH_WL_BITMASKS, 0);
}

static void display_rl_bm(int if_num, int rank,
			  struct rlevel_bitmask *bitmasks, int ecc_ena)
{
	do_display_bm(if_num, rank, (void *)bitmasks, WITH_RL_BITMASKS,
		      ecc_ena);
}

static void display_rl_bm_scores(int if_num, int rank,
				 struct rlevel_bitmask *bitmasks, int ecc_ena)
{
	do_display_bm(if_num, rank, (void *)bitmasks, WITH_RL_MASK_SCORES,
		      ecc_ena);
}

static void display_rl_seq_scores(int if_num, int rank,
				  struct rlevel_byte_data *bytes, int ecc_ena)
{
	do_display_bm(if_num, rank, (void *)bytes, WITH_RL_SEQ_SCORES, ecc_ena);
}

#define RODT_OHMS_COUNT        8
#define RTT_NOM_OHMS_COUNT     8
#define RTT_NOM_TABLE_COUNT    8
#define RTT_WR_OHMS_COUNT      8
#define DIC_OHMS_COUNT         3
#define DRIVE_STRENGTH_COUNT  15

static unsigned char ddr4_rodt_ohms[RODT_OHMS_COUNT] = {
	0, 40, 60, 80, 120, 240, 34, 48 };
static unsigned char ddr4_rtt_nom_ohms[RTT_NOM_OHMS_COUNT] = {
	0, 60, 120, 40, 240, 48, 80, 34 };
static unsigned char ddr4_rtt_nom_table[RTT_NOM_TABLE_COUNT] = {
	0, 4, 2, 6, 1, 5, 3, 7 };
// setting HiZ ohms to 99 for computed vref
static unsigned char ddr4_rtt_wr_ohms[RTT_WR_OHMS_COUNT] = {
	0, 120, 240, 99, 80 };
static unsigned char ddr4_dic_ohms[DIC_OHMS_COUNT] = { 34, 48 };
static short ddr4_drive_strength[DRIVE_STRENGTH_COUNT] = {
	0, 0, 26, 30, 34, 40, 48, 68, 0, 0, 0, 0, 0, 0, 0 };
static short ddr4_dqx_strength[DRIVE_STRENGTH_COUNT] = {
	0, 24, 27, 30, 34, 40, 48, 60, 0, 0, 0, 0, 0, 0, 0 };
struct impedence_values ddr4_impedence_val = {
	.rodt_ohms = ddr4_rodt_ohms,
	.rtt_nom_ohms = ddr4_rtt_nom_ohms,
	.rtt_nom_table = ddr4_rtt_nom_table,
	.rtt_wr_ohms = ddr4_rtt_wr_ohms,
	.dic_ohms = ddr4_dic_ohms,
	.drive_strength = ddr4_drive_strength,
	.dqx_strength = ddr4_dqx_strength,
};

static unsigned char ddr3_rodt_ohms[RODT_OHMS_COUNT] = {
	0, 20, 30, 40, 60, 120, 0, 0 };
static unsigned char ddr3_rtt_nom_ohms[RTT_NOM_OHMS_COUNT] = {
	0, 60, 120, 40, 20, 30, 0, 0 };
static unsigned char ddr3_rtt_nom_table[RTT_NOM_TABLE_COUNT] = {
	0, 2, 1, 3, 5, 4, 0, 0 };
static unsigned char ddr3_rtt_wr_ohms[RTT_WR_OHMS_COUNT] = { 0, 60, 120 };
static unsigned char ddr3_dic_ohms[DIC_OHMS_COUNT] = { 40, 34 };
static short ddr3_drive_strength[DRIVE_STRENGTH_COUNT] = {
	0, 24, 27, 30, 34, 40, 48, 60, 0, 0, 0, 0, 0, 0, 0 };
static struct impedence_values ddr3_impedence_val = {
	.rodt_ohms = ddr3_rodt_ohms,
	.rtt_nom_ohms = ddr3_rtt_nom_ohms,
	.rtt_nom_table = ddr3_rtt_nom_table,
	.rtt_wr_ohms = ddr3_rtt_wr_ohms,
	.dic_ohms = ddr3_dic_ohms,
	.drive_strength = ddr3_drive_strength,
	.dqx_strength = ddr3_drive_strength,
};

static u64 hertz_to_psecs(u64 hertz)
{
	/* Clock in psecs */
	return divide_nint((u64)1000 * 1000 * 1000 * 1000, hertz);
}

#define DIVIDEND_SCALE 1000	/* Scale to avoid rounding error. */

static u64 psecs_to_mts(u64 psecs)
{
	return divide_nint(divide_nint((u64)(2 * 1000000 * DIVIDEND_SCALE),
				       psecs), DIVIDEND_SCALE);
}

#define WITHIN(v, b, m) (((v) >= ((b) - (m))) && ((v) <= ((b) + (m))))

static unsigned long pretty_psecs_to_mts(u64 psecs)
{
	u64 ret = 0;		// default to error

	if (WITHIN(psecs, 2500, 1))
		ret = 800;
	else if (WITHIN(psecs, 1875, 1))
		ret = 1066;
	else if (WITHIN(psecs, 1500, 1))
		ret = 1333;
	else if (WITHIN(psecs, 1250, 1))
		ret = 1600;
	else if (WITHIN(psecs, 1071, 1))
		ret = 1866;
	else if (WITHIN(psecs, 937, 1))
		ret = 2133;
	else if (WITHIN(psecs, 833, 1))
		ret = 2400;
	else if (WITHIN(psecs, 750, 1))
		ret = 2666;
	return ret;
}

static u64 mts_to_hertz(u64 mts)
{
	return ((mts * 1000 * 1000) / 2);
}

static int compute_rc3x(int64_t tclk_psecs)
{
	long speed;
	long tclk_psecs_min, tclk_psecs_max;
	long data_rate_mhz, data_rate_mhz_min, data_rate_mhz_max;
	int rc3x;

#define ENCODING_BASE 1240

	data_rate_mhz = psecs_to_mts(tclk_psecs);

	/*
	 * 2400 MT/s is a special case. Using integer arithmetic it rounds
	 * from 833 psecs to 2401 MT/s. Force it to 2400 to pick the
	 * proper setting from the table.
	 */
	if (tclk_psecs == 833)
		data_rate_mhz = 2400;

	for (speed = ENCODING_BASE; speed < 3200; speed += 20) {
		int error = 0;

		/* Clock in psecs */
		tclk_psecs_min = hertz_to_psecs(mts_to_hertz(speed + 00));
		/* Clock in psecs */
		tclk_psecs_max = hertz_to_psecs(mts_to_hertz(speed + 18));

		data_rate_mhz_min = psecs_to_mts(tclk_psecs_min);
		data_rate_mhz_max = psecs_to_mts(tclk_psecs_max);

		/* Force alingment to multiple to avound rounding errors. */
		data_rate_mhz_min = ((data_rate_mhz_min + 18) / 20) * 20;
		data_rate_mhz_max = ((data_rate_mhz_max + 18) / 20) * 20;

		error += (speed + 00 != data_rate_mhz_min);
		error += (speed + 20 != data_rate_mhz_max);

		rc3x = (speed - ENCODING_BASE) / 20;

		if (data_rate_mhz <= (speed + 20))
			break;
	}

	return rc3x;
}

/*
 * static global variables needed, so that functions (loops) can be
 * restructured from the main huge function. Its not elegant, but the
 * only way to break the original functions like init_octeon3_ddr3_interface()
 * into separate logical smaller functions with less indentation levels.
 */
static int if_num __section(".data");
static u32 if_mask __section(".data");
static int ddr_hertz __section(".data");

static struct ddr_conf *ddr_conf __section(".data");
static const struct dimm_odt_config *odt_1rank_config __section(".data");
static const struct dimm_odt_config *odt_2rank_config __section(".data");
static const struct dimm_odt_config *odt_4rank_config __section(".data");
static struct dimm_config *dimm_config_table __section(".data");
static const struct dimm_odt_config *odt_config __section(".data");
static const struct ddr3_custom_config *c_cfg __section(".data");

static int odt_idx __section(".data");

static ulong tclk_psecs __section(".data");
static ulong eclk_psecs __section(".data");

static int row_bits __section(".data");
static int col_bits __section(".data");
static int num_banks __section(".data");
static int num_ranks __section(".data");
static int dram_width __section(".data");
static int dimm_count __section(".data");
/* Accumulate and report all the errors before giving up */
static int fatal_error __section(".data");
/* Flag that indicates safe DDR settings should be used */
static int safe_ddr_flag __section(".data");
/* Octeon II Default: 64bit interface width */
static int if_64b __section(".data");
static int if_bytemask __section(".data");
static u32 mem_size_mbytes __section(".data");
static unsigned int didx __section(".data");
static int bank_bits __section(".data");
static int bunk_enable __section(".data");
static int rank_mask __section(".data");
static int column_bits_start __section(".data");
static int row_lsb __section(".data");
static int pbank_lsb __section(".data");
static int use_ecc __section(".data");
static int mtb_psec __section(".data");
static short ftb_dividend __section(".data");
static short ftb_divisor __section(".data");
static int taamin __section(".data");
static int tckmin __section(".data");
static int cl __section(".data");
static int min_cas_latency __section(".data");
static int max_cas_latency __section(".data");
static int override_cas_latency __section(".data");
static int ddr_rtt_nom_auto __section(".data");
static int ddr_rodt_ctl_auto __section(".data");

static int spd_addr __section(".data");
static int spd_org __section(".data");
static int spd_banks __section(".data");
static int spd_rdimm __section(".data");
static int spd_dimm_type __section(".data");
static int spd_ecc __section(".data");
static u32 spd_cas_latency __section(".data");
static int spd_mtb_dividend __section(".data");
static int spd_mtb_divisor __section(".data");
static int spd_tck_min __section(".data");
static int spd_taa_min __section(".data");
static int spd_twr __section(".data");
static int spd_trcd __section(".data");
static int spd_trrd __section(".data");
static int spd_trp __section(".data");
static int spd_tras __section(".data");
static int spd_trc __section(".data");
static int spd_trfc __section(".data");
static int spd_twtr __section(".data");
static int spd_trtp __section(".data");
static int spd_tfaw __section(".data");
static int spd_addr_mirror __section(".data");
static int spd_package __section(".data");
static int spd_rawcard __section(".data");
static int spd_rawcard_aorb __section(".data");
static int spd_rdimm_registers __section(".data");
static int spd_thermal_sensor __section(".data");

static int is_stacked_die __section(".data");
static int is_3ds_dimm __section(".data");
// 3DS: logical ranks per package rank
static int lranks_per_prank __section(".data");
// 3DS: logical ranks bits
static int lranks_bits __section(".data");
// in Mbits; only used for 3DS
static int die_capacity __section(".data");

static enum ddr_type ddr_type __section(".data");

static int twr __section(".data");
static int trcd __section(".data");
static int trrd __section(".data");
static int trp __section(".data");
static int tras __section(".data");
static int trc __section(".data");
static int trfc __section(".data");
static int twtr __section(".data");
static int trtp __section(".data");
static int tfaw __section(".data");

static int ddr4_tckavgmin __section(".data");
static int ddr4_tckavgmax __section(".data");
static int ddr4_trdcmin __section(".data");
static int ddr4_trpmin __section(".data");
static int ddr4_trasmin __section(".data");
static int ddr4_trcmin __section(".data");
static int ddr4_trfc1min __section(".data");
static int ddr4_trfc2min __section(".data");
static int ddr4_trfc4min __section(".data");
static int ddr4_tfawmin __section(".data");
static int ddr4_trrd_smin __section(".data");
static int ddr4_trrd_lmin __section(".data");
static int ddr4_tccd_lmin __section(".data");

static int wl_mask_err __section(".data");
static int wl_loops __section(".data");
static int default_rtt_nom[4] __section(".data");
static int dyn_rtt_nom_mask __section(".data");
static struct impedence_values *imp_val __section(".data");
static char default_rodt_ctl __section(".data");
// default to disabled (ie, try LMC restart, not chip reset)
static int ddr_disable_chip_reset __section(".data");
static const char *dimm_type_name __section(".data");
static int match_wl_rtt_nom __section(".data");

struct hwl_alt_by_rank {
	u16 hwl_alt_mask;	// mask of bytelanes with alternate
	u16 hwl_alt_delay[9];	// bytelane alternate avail if mask=1
};

static struct hwl_alt_by_rank hwl_alts[4] __section(".data");

#define DEFAULT_INTERNAL_VREF_TRAINING_LIMIT 3	// was: 5
static int internal_retries __section(".data");

static int deskew_training_errors __section(".data");
static struct deskew_counts deskew_training_results __section(".data");
static int disable_deskew_training __section(".data");
static int restart_if_dsk_incomplete __section(".data");
static int dac_eval_retries __section(".data");
static int dac_settings[9] __section(".data");
static int num_samples __section(".data");
static int sample __section(".data");
static int lane __section(".data");
static int last_lane __section(".data");
static int total_dac_eval_retries __section(".data");
static int dac_eval_exhausted __section(".data");

#define DEFAULT_DAC_SAMPLES 7	// originally was 5
#define DAC_RETRIES_LIMIT   2

struct bytelane_sample {
	s16 bytes[DEFAULT_DAC_SAMPLES];
};

static struct bytelane_sample lanes[9] __section(".data");

static char disable_sequential_delay_check __section(".data");
static int wl_print __section(".data");

static int enable_by_rank_init __section(".data");
static int saved_rank_mask __section(".data");
static int by_rank __section(".data");
static struct deskew_data rank_dsk[4] __section(".data");
static struct dac_data rank_dac[4] __section(".data");

// todo: perhaps remove node at some time completely?
static int node __section(".data");
static int base_cl __section(".data");

/* Parameters from DDR3 Specifications */
#define DDR3_TREFI         7800000	/* 7.8 us */
#define DDR3_ZQCS          80000ull	/* 80 ns */
#define DDR3_ZQCS_INTERNAL 1280000000ull	/* 128ms/100 */
#define DDR3_TCKE          5000	/* 5 ns */
#define DDR3_TMRD          4	/* 4 nCK */
#define DDR3_TDLLK         512	/* 512 nCK */
#define DDR3_TMPRR         1	/* 1 nCK */
#define DDR3_TWLMRD        40	/* 40 nCK */
#define DDR3_TWLDQSEN      25	/* 25 nCK */

/* Parameters from DDR4 Specifications */
#define DDR4_TMRD          8	/* 8 nCK */
#define DDR4_TDLLK         768	/* 768 nCK */

static void lmc_config(struct ddr_priv *priv)
{
	union cvmx_lmcx_config cfg;
	char *s;

	cfg.u64 = 0;

	cfg.cn78xx.ecc_ena = use_ecc;
	cfg.cn78xx.row_lsb = encode_row_lsb_ddr3(row_lsb);
	cfg.cn78xx.pbank_lsb = encode_pbank_lsb_ddr3(pbank_lsb);

	cfg.cn78xx.idlepower = 0;	/* Disabled */

	s = lookup_env(priv, "ddr_idlepower");
	if (s)
		cfg.cn78xx.idlepower = simple_strtoul(s, NULL, 0);

	cfg.cn78xx.forcewrite = 0;	/* Disabled */
	/* Include memory reference address in the ECC */
	cfg.cn78xx.ecc_adr = 1;

	s = lookup_env(priv, "ddr_ecc_adr");
	if (s)
		cfg.cn78xx.ecc_adr = simple_strtoul(s, NULL, 0);

	cfg.cn78xx.reset = 0;

	/*
	 * Program LMC0_CONFIG[24:18], ref_zqcs_int(6:0) to
	 * RND-DN(tREFI/clkPeriod/512) Program LMC0_CONFIG[36:25],
	 * ref_zqcs_int(18:7) to
	 * RND-DN(ZQCS_Interval/clkPeriod/(512*128)). Note that this
	 * value should always be greater than 32, to account for
	 * resistor calibration delays.
	 */

	cfg.cn78xx.ref_zqcs_int = ((DDR3_TREFI / tclk_psecs / 512) & 0x7f);
	cfg.cn78xx.ref_zqcs_int |=
		((max(33ull, (DDR3_ZQCS_INTERNAL / (tclk_psecs / 100) /
			      (512 * 128))) & 0xfff) << 7);

	cfg.cn78xx.early_dqx = 1;	/* Default to enabled */

	s = lookup_env(priv, "ddr_early_dqx");
	if (!s)
		s = lookup_env(priv, "ddr%d_early_dqx", if_num);

	if (s)
		cfg.cn78xx.early_dqx = simple_strtoul(s, NULL, 0);

	cfg.cn78xx.sref_with_dll = 0;

	cfg.cn78xx.rank_ena = bunk_enable;
	cfg.cn78xx.rankmask = rank_mask;	/* Set later */
	cfg.cn78xx.mirrmask = (spd_addr_mirror << 1 | spd_addr_mirror << 3) &
		rank_mask;
	/* Set once and don't change it. */
	cfg.cn78xx.init_status = rank_mask;
	cfg.cn78xx.early_unload_d0_r0 = 0;
	cfg.cn78xx.early_unload_d0_r1 = 0;
	cfg.cn78xx.early_unload_d1_r0 = 0;
	cfg.cn78xx.early_unload_d1_r1 = 0;
	cfg.cn78xx.scrz = 0;
	if (octeon_is_cpuid(OCTEON_CN70XX))
		cfg.cn78xx.mode32b = 1;	/* Read-only. Always 1. */
	cfg.cn78xx.mode_x4dev = (dram_width == 4) ? 1 : 0;
	cfg.cn78xx.bg2_enable = ((ddr_type == DDR4_DRAM) &&
				 (dram_width == 16)) ? 0 : 1;

	s = lookup_env_ull(priv, "ddr_config");
	if (s)
		cfg.u64 = simple_strtoull(s, NULL, 0);
	debug("LMC_CONFIG                                    : 0x%016llx\n",
	      cfg.u64);
	lmc_wr(priv, CVMX_LMCX_CONFIG(if_num), cfg.u64);
}

static void lmc_control(struct ddr_priv *priv)
{
	union cvmx_lmcx_control ctrl;
	char *s;

	ctrl.u64 = lmc_rd(priv, CVMX_LMCX_CONTROL(if_num));
	ctrl.s.rdimm_ena = spd_rdimm;
	ctrl.s.bwcnt = 0;	/* Clear counter later */
	if (spd_rdimm)
		ctrl.s.ddr2t = (safe_ddr_flag ? 1 : c_cfg->ddr2t_rdimm);
	else
		ctrl.s.ddr2t = (safe_ddr_flag ? 1 : c_cfg->ddr2t_udimm);
	ctrl.s.pocas = 0;
	ctrl.s.fprch2 = (safe_ddr_flag ? 2 : c_cfg->fprch2);
	ctrl.s.throttle_rd = safe_ddr_flag ? 1 : 0;
	ctrl.s.throttle_wr = safe_ddr_flag ? 1 : 0;
	ctrl.s.inorder_rd = safe_ddr_flag ? 1 : 0;
	ctrl.s.inorder_wr = safe_ddr_flag ? 1 : 0;
	ctrl.s.elev_prio_dis = safe_ddr_flag ? 1 : 0;
	/* discards writes to addresses that don't exist in the DRAM */
	ctrl.s.nxm_write_en = 0;
	ctrl.s.max_write_batch = 8;
	ctrl.s.xor_bank = 1;
	ctrl.s.auto_dclkdis = 1;
	ctrl.s.int_zqcs_dis = 0;
	ctrl.s.ext_zqcs_dis = 0;
	ctrl.s.bprch = 1;
	ctrl.s.wodt_bprch = 1;
	ctrl.s.rodt_bprch = 1;

	s = lookup_env(priv, "ddr_xor_bank");
	if (s)
		ctrl.s.xor_bank = simple_strtoul(s, NULL, 0);

	s = lookup_env(priv, "ddr_2t");
	if (s)
		ctrl.s.ddr2t = simple_strtoul(s, NULL, 0);

	s = lookup_env(priv, "ddr_fprch2");
	if (s)
		ctrl.s.fprch2 = simple_strtoul(s, NULL, 0);

	s = lookup_env(priv, "ddr_bprch");
	if (s)
		ctrl.s.bprch = simple_strtoul(s, NULL, 0);

	s = lookup_env(priv, "ddr_wodt_bprch");
	if (s)
		ctrl.s.wodt_bprch = simple_strtoul(s, NULL, 0);

	s = lookup_env(priv, "ddr_rodt_bprch");
	if (s)
		ctrl.s.rodt_bprch = simple_strtoul(s, NULL, 0);

	s = lookup_env(priv, "ddr_int_zqcs_dis");
	if (s)
		ctrl.s.int_zqcs_dis = simple_strtoul(s, NULL, 0);

	s = lookup_env(priv, "ddr_ext_zqcs_dis");
	if (s)
		ctrl.s.ext_zqcs_dis = simple_strtoul(s, NULL, 0);

	s = lookup_env_ull(priv, "ddr_control");
	if (s)
		ctrl.u64 = simple_strtoull(s, NULL, 0);

	debug("LMC_CONTROL                                   : 0x%016llx\n",
	      ctrl.u64);
	lmc_wr(priv, CVMX_LMCX_CONTROL(if_num), ctrl.u64);
}

static void lmc_timing_params0(struct ddr_priv *priv)
{
	union cvmx_lmcx_timing_params0 tp0;
	unsigned int trp_value;
	char *s;

	tp0.u64 = lmc_rd(priv, CVMX_LMCX_TIMING_PARAMS0(if_num));

	trp_value = divide_roundup(trp, tclk_psecs) - 1;
	debug("TIMING_PARAMS0[TRP]: NEW 0x%x, OLD 0x%x\n", trp_value,
	      trp_value +
	      (unsigned int)(divide_roundup(max(4ull * tclk_psecs, 7500ull),
					    tclk_psecs)) - 4);
	s = lookup_env_ull(priv, "ddr_use_old_trp");
	if (s) {
		if (!!simple_strtoull(s, NULL, 0)) {
			trp_value +=
			    divide_roundup(max(4ull * tclk_psecs, 7500ull),
					   tclk_psecs) - 4;
			debug("TIMING_PARAMS0[trp]: USING OLD 0x%x\n",
			      trp_value);
		}
	}

	tp0.cn78xx.txpr =
	    divide_roundup(max(5ull * tclk_psecs, trfc + 10000ull),
			   16 * tclk_psecs);
	tp0.cn78xx.trp = trp_value & 0x1f;
	tp0.cn78xx.tcksre =
	    divide_roundup(max(5ull * tclk_psecs, 10000ull), tclk_psecs) - 1;

	if (ddr_type == DDR4_DRAM) {
		int tzqinit = 4;	// Default to 4, for all DDR4 speed bins

		s = lookup_env(priv, "ddr_tzqinit");
		if (s)
			tzqinit = simple_strtoul(s, NULL, 0);

		tp0.cn78xx.tzqinit = tzqinit;
		/* Always 8. */
		tp0.cn78xx.tzqcs = divide_roundup(128 * tclk_psecs,
						  (16 * tclk_psecs));
		tp0.cn78xx.tcke =
		    divide_roundup(max(3 * tclk_psecs, (ulong)DDR3_TCKE),
				   tclk_psecs) - 1;
		tp0.cn78xx.tmrd =
		    divide_roundup((DDR4_TMRD * tclk_psecs), tclk_psecs) - 1;
		tp0.cn78xx.tmod = 25;	/* 25 is the max allowed */
		tp0.cn78xx.tdllk = divide_roundup(DDR4_TDLLK, 256);
	} else {
		tp0.cn78xx.tzqinit =
		    divide_roundup(max(512ull * tclk_psecs, 640000ull),
				   (256 * tclk_psecs));
		tp0.cn78xx.tzqcs =
		    divide_roundup(max(64ull * tclk_psecs, DDR3_ZQCS),
				   (16 * tclk_psecs));
		tp0.cn78xx.tcke = divide_roundup(DDR3_TCKE, tclk_psecs) - 1;
		tp0.cn78xx.tmrd =
		    divide_roundup((DDR3_TMRD * tclk_psecs), tclk_psecs) - 1;
		tp0.cn78xx.tmod =
		    divide_roundup(max(12ull * tclk_psecs, 15000ull),
				   tclk_psecs) - 1;
		tp0.cn78xx.tdllk = divide_roundup(DDR3_TDLLK, 256);
	}

	s = lookup_env_ull(priv, "ddr_timing_params0");
	if (s)
		tp0.u64 = simple_strtoull(s, NULL, 0);
	debug("TIMING_PARAMS0                                : 0x%016llx\n",
	      tp0.u64);
	lmc_wr(priv, CVMX_LMCX_TIMING_PARAMS0(if_num), tp0.u64);
}

static void lmc_timing_params1(struct ddr_priv *priv)
{
	union cvmx_lmcx_timing_params1 tp1;
	unsigned int txp, temp_trcd, trfc_dlr;
	char *s;

	tp1.u64 = lmc_rd(priv, CVMX_LMCX_TIMING_PARAMS1(if_num));

	/* .cn70xx. */
	tp1.s.tmprr = divide_roundup(DDR3_TMPRR * tclk_psecs, tclk_psecs) - 1;

	tp1.cn78xx.tras = divide_roundup(tras, tclk_psecs) - 1;

	temp_trcd = divide_roundup(trcd, tclk_psecs);
	if (temp_trcd > 15) {
		debug("TIMING_PARAMS1[trcd]: need extension bit for 0x%x\n",
		      temp_trcd);
	}
	if (octeon_is_cpuid(OCTEON_CN78XX_PASS1_X) && temp_trcd > 15) {
		/*
		 * Let .trcd=0 serve as a flag that the field has
		 * overflowed. Must use Additive Latency mode as a
		 * workaround.
		 */
		temp_trcd = 0;
	}
	tp1.cn78xx.trcd = (temp_trcd >> 0) & 0xf;
	tp1.cn78xx.trcd_ext = (temp_trcd >> 4) & 0x1;

	tp1.cn78xx.twtr = divide_roundup(twtr, tclk_psecs) - 1;
	tp1.cn78xx.trfc = divide_roundup(trfc, 8 * tclk_psecs);

	if (ddr_type == DDR4_DRAM) {
		/* Workaround bug 24006. Use Trrd_l. */
		tp1.cn78xx.trrd =
		    divide_roundup(ddr4_trrd_lmin, tclk_psecs) - 2;
	} else {
		tp1.cn78xx.trrd = divide_roundup(trrd, tclk_psecs) - 2;
	}

	/*
	 * tXP = max( 3nCK, 7.5 ns)     DDR3-800   tCLK = 2500 psec
	 * tXP = max( 3nCK, 7.5 ns)     DDR3-1066  tCLK = 1875 psec
	 * tXP = max( 3nCK, 6.0 ns)     DDR3-1333  tCLK = 1500 psec
	 * tXP = max( 3nCK, 6.0 ns)     DDR3-1600  tCLK = 1250 psec
	 * tXP = max( 3nCK, 6.0 ns)     DDR3-1866  tCLK = 1071 psec
	 * tXP = max( 3nCK, 6.0 ns)     DDR3-2133  tCLK =  937 psec
	 */
	txp = (tclk_psecs < 1875) ? 6000 : 7500;
	txp = divide_roundup(max((unsigned int)(3 * tclk_psecs), txp),
			     tclk_psecs) - 1;
	if (txp > 7) {
		debug("TIMING_PARAMS1[txp]: need extension bit for 0x%x\n",
		      txp);
	}
	if (octeon_is_cpuid(OCTEON_CN78XX_PASS1_X) && txp > 7)
		txp = 7;	// max it out
	tp1.cn78xx.txp = (txp >> 0) & 7;
	tp1.cn78xx.txp_ext = (txp >> 3) & 1;

	tp1.cn78xx.twlmrd = divide_roundup(DDR3_TWLMRD * tclk_psecs,
					   4 * tclk_psecs);
	tp1.cn78xx.twldqsen = divide_roundup(DDR3_TWLDQSEN * tclk_psecs,
					     4 * tclk_psecs);
	tp1.cn78xx.tfaw = divide_roundup(tfaw, 4 * tclk_psecs);
	tp1.cn78xx.txpdll = divide_roundup(max(10ull * tclk_psecs, 24000ull),
					   tclk_psecs) - 1;

	if (ddr_type == DDR4_DRAM && is_3ds_dimm) {
		/*
		 * 4 Gb: tRFC_DLR = 90 ns
		 * 8 Gb: tRFC_DLR = 120 ns
		 * 16 Gb: tRFC_DLR = 190 ns FIXME?
		 */
		if (die_capacity == 0x1000)	// 4 Gbit
			trfc_dlr = 90;
		else if (die_capacity == 0x2000)	// 8 Gbit
			trfc_dlr = 120;
		else if (die_capacity == 0x4000)	// 16 Gbit
			trfc_dlr = 190;
		else
			trfc_dlr = 0;

		if (trfc_dlr == 0) {
			debug("N%d.LMC%d: ERROR: tRFC_DLR: die_capacity %u Mbit is illegal\n",
			      node, if_num, die_capacity);
		} else {
			tp1.cn78xx.trfc_dlr =
			    divide_roundup(trfc_dlr * 1000UL, 8 * tclk_psecs);
			debug("N%d.LMC%d: TIMING_PARAMS1[trfc_dlr] set to %u\n",
			      node, if_num, tp1.cn78xx.trfc_dlr);
		}
	}

	s = lookup_env_ull(priv, "ddr_timing_params1");
	if (s)
		tp1.u64 = simple_strtoull(s, NULL, 0);

	debug("TIMING_PARAMS1                                : 0x%016llx\n",
	      tp1.u64);
	lmc_wr(priv, CVMX_LMCX_TIMING_PARAMS1(if_num), tp1.u64);
}

static void lmc_timing_params2(struct ddr_priv *priv)
{
	if (ddr_type == DDR4_DRAM) {
		union cvmx_lmcx_timing_params1 tp1;
		union cvmx_lmcx_timing_params2 tp2;
		int temp_trrd_l;

		tp1.u64 = lmc_rd(priv, CVMX_LMCX_TIMING_PARAMS1(if_num));
		tp2.u64 = lmc_rd(priv, CVMX_LMCX_TIMING_PARAMS2(if_num));
		debug("TIMING_PARAMS2                                : 0x%016llx\n",
		      tp2.u64);

		temp_trrd_l = divide_roundup(ddr4_trrd_lmin, tclk_psecs) - 2;
		if (temp_trrd_l > 7)
			debug("TIMING_PARAMS2[trrd_l]: need extension bit for 0x%x\n",
			      temp_trrd_l);
		if (octeon_is_cpuid(OCTEON_CN78XX_PASS1_X) && temp_trrd_l > 7)
			temp_trrd_l = 7;	// max it out
		tp2.cn78xx.trrd_l = (temp_trrd_l >> 0) & 7;
		tp2.cn78xx.trrd_l_ext = (temp_trrd_l >> 3) & 1;

		// correct for 1600-2400
		tp2.s.twtr_l = divide_nint(max(4ull * tclk_psecs, 7500ull),
					   tclk_psecs) - 1;
		tp2.s.t_rw_op_max = 7;
		tp2.s.trtp = divide_roundup(max(4ull * tclk_psecs, 7500ull),
					    tclk_psecs) - 1;

		debug("TIMING_PARAMS2                                : 0x%016llx\n",
		      tp2.u64);
		lmc_wr(priv, CVMX_LMCX_TIMING_PARAMS2(if_num), tp2.u64);

		/*
		 * Workaround Errata 25823 - LMC: Possible DDR4 tWTR_L not met
		 * for Write-to-Read operations to the same Bank Group
		 */
		if (tp1.cn78xx.twtr < (tp2.s.twtr_l - 4)) {
			tp1.cn78xx.twtr = tp2.s.twtr_l - 4;
			debug("ERRATA 25823: NEW: TWTR: %d, TWTR_L: %d\n",
			      tp1.cn78xx.twtr, tp2.s.twtr_l);
			debug("TIMING_PARAMS1                                : 0x%016llx\n",
			      tp1.u64);
			lmc_wr(priv, CVMX_LMCX_TIMING_PARAMS1(if_num), tp1.u64);
		}
	}
}

static void lmc_modereg_params0(struct ddr_priv *priv)
{
	union cvmx_lmcx_modereg_params0 mp0;
	int param;
	char *s;

	mp0.u64 = lmc_rd(priv, CVMX_LMCX_MODEREG_PARAMS0(if_num));

	if (ddr_type == DDR4_DRAM) {
		mp0.s.cwl = 0;	/* 1600 (1250ps) */
		if (tclk_psecs < 1250)
			mp0.s.cwl = 1;	/* 1866 (1072ps) */
		if (tclk_psecs < 1072)
			mp0.s.cwl = 2;	/* 2133 (938ps) */
		if (tclk_psecs < 938)
			mp0.s.cwl = 3;	/* 2400 (833ps) */
		if (tclk_psecs < 833)
			mp0.s.cwl = 4;	/* 2666 (750ps) */
		if (tclk_psecs < 750)
			mp0.s.cwl = 5;	/* 3200 (625ps) */
	} else {
		/*
		 ** CSR   CWL         CAS write Latency
		 ** ===   ===   =================================
		 **  0      5   (           tCK(avg) >=   2.5 ns)
		 **  1      6   (2.5 ns   > tCK(avg) >= 1.875 ns)
		 **  2      7   (1.875 ns > tCK(avg) >= 1.5   ns)
		 **  3      8   (1.5 ns   > tCK(avg) >= 1.25  ns)
		 **  4      9   (1.25 ns  > tCK(avg) >= 1.07  ns)
		 **  5     10   (1.07 ns  > tCK(avg) >= 0.935 ns)
		 **  6     11   (0.935 ns > tCK(avg) >= 0.833 ns)
		 **  7     12   (0.833 ns > tCK(avg) >= 0.75  ns)
		 */

		mp0.s.cwl = 0;
		if (tclk_psecs < 2500)
			mp0.s.cwl = 1;
		if (tclk_psecs < 1875)
			mp0.s.cwl = 2;
		if (tclk_psecs < 1500)
			mp0.s.cwl = 3;
		if (tclk_psecs < 1250)
			mp0.s.cwl = 4;
		if (tclk_psecs < 1070)
			mp0.s.cwl = 5;
		if (tclk_psecs < 935)
			mp0.s.cwl = 6;
		if (tclk_psecs < 833)
			mp0.s.cwl = 7;
	}

	s = lookup_env(priv, "ddr_cwl");
	if (s)
		mp0.s.cwl = simple_strtoul(s, NULL, 0) - 5;

	if (ddr_type == DDR4_DRAM) {
		debug("%-45s : %d, [0x%x]\n", "CAS Write Latency CWL, [CSR]",
		      mp0.s.cwl + 9
		      + ((mp0.s.cwl > 2) ? (mp0.s.cwl - 3) * 2 : 0), mp0.s.cwl);
	} else {
		debug("%-45s : %d, [0x%x]\n", "CAS Write Latency CWL, [CSR]",
		      mp0.s.cwl + 5, mp0.s.cwl);
	}

	mp0.s.mprloc = 0;
	mp0.s.mpr = 0;
	mp0.s.dll = (ddr_type == DDR4_DRAM);	/* 0 for DDR3 and 1 for DDR4 */
	mp0.s.al = 0;
	mp0.s.wlev = 0;		/* Read Only */
	if (octeon_is_cpuid(OCTEON_CN70XX) || ddr_type == DDR4_DRAM)
		mp0.s.tdqs = 0;
	else
		mp0.s.tdqs = 1;
	mp0.s.qoff = 0;

	s = lookup_env(priv, "ddr_cl");
	if (s) {
		cl = simple_strtoul(s, NULL, 0);
		debug("CAS Latency                                   : %6d\n",
		      cl);
	}

	if (ddr_type == DDR4_DRAM) {
		mp0.s.cl = 0x0;
		if (cl > 9)
			mp0.s.cl = 0x1;
		if (cl > 10)
			mp0.s.cl = 0x2;
		if (cl > 11)
			mp0.s.cl = 0x3;
		if (cl > 12)
			mp0.s.cl = 0x4;
		if (cl > 13)
			mp0.s.cl = 0x5;
		if (cl > 14)
			mp0.s.cl = 0x6;
		if (cl > 15)
			mp0.s.cl = 0x7;
		if (cl > 16)
			mp0.s.cl = 0x8;
		if (cl > 18)
			mp0.s.cl = 0x9;
		if (cl > 20)
			mp0.s.cl = 0xA;
		if (cl > 24)
			mp0.s.cl = 0xB;
	} else {
		mp0.s.cl = 0x2;
		if (cl > 5)
			mp0.s.cl = 0x4;
		if (cl > 6)
			mp0.s.cl = 0x6;
		if (cl > 7)
			mp0.s.cl = 0x8;
		if (cl > 8)
			mp0.s.cl = 0xA;
		if (cl > 9)
			mp0.s.cl = 0xC;
		if (cl > 10)
			mp0.s.cl = 0xE;
		if (cl > 11)
			mp0.s.cl = 0x1;
		if (cl > 12)
			mp0.s.cl = 0x3;
		if (cl > 13)
			mp0.s.cl = 0x5;
		if (cl > 14)
			mp0.s.cl = 0x7;
		if (cl > 15)
			mp0.s.cl = 0x9;
	}

	mp0.s.rbt = 0;		/* Read Only. */
	mp0.s.tm = 0;
	mp0.s.dllr = 0;

	param = divide_roundup(twr, tclk_psecs);

	if (ddr_type == DDR4_DRAM) {	/* DDR4 */
		mp0.s.wrp = 1;
		if (param > 12)
			mp0.s.wrp = 2;
		if (param > 14)
			mp0.s.wrp = 3;
		if (param > 16)
			mp0.s.wrp = 4;
		if (param > 18)
			mp0.s.wrp = 5;
		if (param > 20)
			mp0.s.wrp = 6;
		if (param > 24)	/* RESERVED in DDR4 spec */
			mp0.s.wrp = 7;
	} else {		/* DDR3 */
		mp0.s.wrp = 1;
		if (param > 5)
			mp0.s.wrp = 2;
		if (param > 6)
			mp0.s.wrp = 3;
		if (param > 7)
			mp0.s.wrp = 4;
		if (param > 8)
			mp0.s.wrp = 5;
		if (param > 10)
			mp0.s.wrp = 6;
		if (param > 12)
			mp0.s.wrp = 7;
	}

	mp0.s.ppd = 0;

	s = lookup_env(priv, "ddr_wrp");
	if (s)
		mp0.s.wrp = simple_strtoul(s, NULL, 0);

	debug("%-45s : %d, [0x%x]\n",
	      "Write recovery for auto precharge WRP, [CSR]", param, mp0.s.wrp);

	s = lookup_env_ull(priv, "ddr_modereg_params0");
	if (s)
		mp0.u64 = simple_strtoull(s, NULL, 0);

	debug("MODEREG_PARAMS0                               : 0x%016llx\n",
	      mp0.u64);
	lmc_wr(priv, CVMX_LMCX_MODEREG_PARAMS0(if_num), mp0.u64);
}

static void lmc_modereg_params1(struct ddr_priv *priv)
{
	union cvmx_lmcx_modereg_params1 mp1;
	char *s;
	int i;

	mp1.u64 = odt_config[odt_idx].modereg_params1.u64;

	/*
	 * Special request: mismatched DIMM support. Slot 0: 2-Rank,
	 * Slot 1: 1-Rank
	 */
	if (rank_mask == 0x7) {	/* 2-Rank, 1-Rank */
		mp1.s.rtt_nom_00 = 0;
		mp1.s.rtt_nom_01 = 3;	/* rttnom_40ohm */
		mp1.s.rtt_nom_10 = 3;	/* rttnom_40ohm */
		mp1.s.rtt_nom_11 = 0;
		dyn_rtt_nom_mask = 0x6;
	}

	s = lookup_env(priv, "ddr_rtt_nom_mask");
	if (s)
		dyn_rtt_nom_mask = simple_strtoul(s, NULL, 0);

	/*
	 * Save the original rtt_nom settings before sweeping through
	 * settings.
	 */
	default_rtt_nom[0] = mp1.s.rtt_nom_00;
	default_rtt_nom[1] = mp1.s.rtt_nom_01;
	default_rtt_nom[2] = mp1.s.rtt_nom_10;
	default_rtt_nom[3] = mp1.s.rtt_nom_11;

	ddr_rtt_nom_auto = c_cfg->ddr_rtt_nom_auto;

	for (i = 0; i < 4; ++i) {
		u64 value;

		s = lookup_env(priv, "ddr_rtt_nom_%1d%1d", !!(i & 2),
			       !!(i & 1));
		if (!s)
			s = lookup_env(priv, "ddr%d_rtt_nom_%1d%1d", if_num,
				       !!(i & 2), !!(i & 1));
		if (s) {
			value = simple_strtoul(s, NULL, 0);
			mp1.u64 &= ~((u64)0x7 << (i * 12 + 9));
			mp1.u64 |= ((value & 0x7) << (i * 12 + 9));
			default_rtt_nom[i] = value;
			ddr_rtt_nom_auto = 0;
		}
	}

	s = lookup_env(priv, "ddr_rtt_nom");
	if (!s)
		s = lookup_env(priv, "ddr%d_rtt_nom", if_num);
	if (s) {
		u64 value;

		value = simple_strtoul(s, NULL, 0);

		if (dyn_rtt_nom_mask & 1) {
			default_rtt_nom[0] = value;
			mp1.s.rtt_nom_00 = value;
		}
		if (dyn_rtt_nom_mask & 2) {
			default_rtt_nom[1] = value;
			mp1.s.rtt_nom_01 = value;
		}
		if (dyn_rtt_nom_mask & 4) {
			default_rtt_nom[2] = value;
			mp1.s.rtt_nom_10 = value;
		}
		if (dyn_rtt_nom_mask & 8) {
			default_rtt_nom[3] = value;
			mp1.s.rtt_nom_11 = value;
		}

		ddr_rtt_nom_auto = 0;
	}

	for (i = 0; i < 4; ++i) {
		u64 value;

		s = lookup_env(priv, "ddr_rtt_wr_%1d%1d", !!(i & 2), !!(i & 1));
		if (!s)
			s = lookup_env(priv, "ddr%d_rtt_wr_%1d%1d", if_num,
				       !!(i & 2), !!(i & 1));
		if (s) {
			value = simple_strtoul(s, NULL, 0);
			insrt_wr(&mp1.u64, i, value);
		}
	}

	// Make sure 78XX pass 1 has valid RTT_WR settings, because
	// configuration files may be set-up for later chips, and
	// 78XX pass 1 supports no RTT_WR extension bits
	if (octeon_is_cpuid(OCTEON_CN78XX_PASS1_X)) {
		for (i = 0; i < 4; ++i) {
			// if 80 or undefined
			if (extr_wr(mp1.u64, i) > 3) {
				// FIXME? always insert 120
				insrt_wr(&mp1.u64, i, 1);
				debug("RTT_WR_%d%d set to 120 for CN78XX pass 1\n",
				      !!(i & 2), i & 1);
			}
		}
	}

	s = lookup_env(priv, "ddr_dic");
	if (s) {
		u64 value = simple_strtoul(s, NULL, 0);

		for (i = 0; i < 4; ++i) {
			mp1.u64 &= ~((u64)0x3 << (i * 12 + 7));
			mp1.u64 |= ((value & 0x3) << (i * 12 + 7));
		}
	}

	for (i = 0; i < 4; ++i) {
		u64 value;

		s = lookup_env(priv, "ddr_dic_%1d%1d", !!(i & 2), !!(i & 1));
		if (s) {
			value = simple_strtoul(s, NULL, 0);
			mp1.u64 &= ~((u64)0x3 << (i * 12 + 7));
			mp1.u64 |= ((value & 0x3) << (i * 12 + 7));
		}
	}

	s = lookup_env_ull(priv, "ddr_modereg_params1");
	if (s)
		mp1.u64 = simple_strtoull(s, NULL, 0);

	debug("RTT_NOM     %3d, %3d, %3d, %3d ohms           :  %x,%x,%x,%x\n",
	      imp_val->rtt_nom_ohms[mp1.s.rtt_nom_11],
	      imp_val->rtt_nom_ohms[mp1.s.rtt_nom_10],
	      imp_val->rtt_nom_ohms[mp1.s.rtt_nom_01],
	      imp_val->rtt_nom_ohms[mp1.s.rtt_nom_00],
	      mp1.s.rtt_nom_11,
	      mp1.s.rtt_nom_10, mp1.s.rtt_nom_01, mp1.s.rtt_nom_00);

	debug("RTT_WR      %3d, %3d, %3d, %3d ohms           :  %x,%x,%x,%x\n",
	      imp_val->rtt_wr_ohms[extr_wr(mp1.u64, 3)],
	      imp_val->rtt_wr_ohms[extr_wr(mp1.u64, 2)],
	      imp_val->rtt_wr_ohms[extr_wr(mp1.u64, 1)],
	      imp_val->rtt_wr_ohms[extr_wr(mp1.u64, 0)],
	      extr_wr(mp1.u64, 3),
	      extr_wr(mp1.u64, 2), extr_wr(mp1.u64, 1), extr_wr(mp1.u64, 0));

	debug("DIC         %3d, %3d, %3d, %3d ohms           :  %x,%x,%x,%x\n",
	      imp_val->dic_ohms[mp1.s.dic_11],
	      imp_val->dic_ohms[mp1.s.dic_10],
	      imp_val->dic_ohms[mp1.s.dic_01],
	      imp_val->dic_ohms[mp1.s.dic_00],
	      mp1.s.dic_11, mp1.s.dic_10, mp1.s.dic_01, mp1.s.dic_00);

	debug("MODEREG_PARAMS1                               : 0x%016llx\n",
	      mp1.u64);
	lmc_wr(priv, CVMX_LMCX_MODEREG_PARAMS1(if_num), mp1.u64);
}

static void lmc_modereg_params2(struct ddr_priv *priv)
{
	char *s;
	int i;

	if (ddr_type == DDR4_DRAM) {
		union cvmx_lmcx_modereg_params2 mp2;

		mp2.u64 = odt_config[odt_idx].modereg_params2.u64;

		s = lookup_env(priv, "ddr_rtt_park");
		if (s) {
			u64 value = simple_strtoul(s, NULL, 0);

			for (i = 0; i < 4; ++i) {
				mp2.u64 &= ~((u64)0x7 << (i * 10 + 0));
				mp2.u64 |= ((value & 0x7) << (i * 10 + 0));
			}
		}

		for (i = 0; i < 4; ++i) {
			u64 value;

			s = lookup_env(priv, "ddr_rtt_park_%1d%1d", !!(i & 2),
				       !!(i & 1));
			if (s) {
				value = simple_strtoul(s, NULL, 0);
				mp2.u64 &= ~((u64)0x7 << (i * 10 + 0));
				mp2.u64 |= ((value & 0x7) << (i * 10 + 0));
			}
		}

		s = lookup_env_ull(priv, "ddr_modereg_params2");
		if (s)
			mp2.u64 = simple_strtoull(s, NULL, 0);

		debug("RTT_PARK    %3d, %3d, %3d, %3d ohms           :  %x,%x,%x,%x\n",
		      imp_val->rtt_nom_ohms[mp2.s.rtt_park_11],
		      imp_val->rtt_nom_ohms[mp2.s.rtt_park_10],
		      imp_val->rtt_nom_ohms[mp2.s.rtt_park_01],
		      imp_val->rtt_nom_ohms[mp2.s.rtt_park_00],
		      mp2.s.rtt_park_11, mp2.s.rtt_park_10, mp2.s.rtt_park_01,
		      mp2.s.rtt_park_00);

		debug("%-45s :  0x%x,0x%x,0x%x,0x%x\n", "VREF_RANGE",
		      mp2.s.vref_range_11,
		      mp2.s.vref_range_10,
		      mp2.s.vref_range_01, mp2.s.vref_range_00);

		debug("%-45s :  0x%x,0x%x,0x%x,0x%x\n", "VREF_VALUE",
		      mp2.s.vref_value_11,
		      mp2.s.vref_value_10,
		      mp2.s.vref_value_01, mp2.s.vref_value_00);

		debug("MODEREG_PARAMS2                               : 0x%016llx\n",
		      mp2.u64);
		lmc_wr(priv, CVMX_LMCX_MODEREG_PARAMS2(if_num), mp2.u64);
	}
}

static void lmc_modereg_params3(struct ddr_priv *priv)
{
	char *s;

	if (ddr_type == DDR4_DRAM) {
		union cvmx_lmcx_modereg_params3 mp3;

		mp3.u64 = lmc_rd(priv, CVMX_LMCX_MODEREG_PARAMS3(if_num));
		/* Disable as workaround to Errata 20547 */
		mp3.s.rd_dbi = 0;
		mp3.s.tccd_l = max(divide_roundup(ddr4_tccd_lmin, tclk_psecs),
				   5ull) - 4;

		s = lookup_env(priv, "ddr_rd_preamble");
		if (s)
			mp3.s.rd_preamble = !!simple_strtoul(s, NULL, 0);

		if (!octeon_is_cpuid(OCTEON_CN78XX_PASS1_X)) {
			int delay = 0;

			if (lranks_per_prank == 4 && ddr_hertz >= 1000000000)
				delay = 1;

			mp3.s.xrank_add_tccd_l = delay;
			mp3.s.xrank_add_tccd_s = delay;
		}

		lmc_wr(priv, CVMX_LMCX_MODEREG_PARAMS3(if_num), mp3.u64);
		debug("MODEREG_PARAMS3                               : 0x%016llx\n",
		      mp3.u64);
	}
}

static void lmc_nxm(struct ddr_priv *priv)
{
	union cvmx_lmcx_nxm lmc_nxm;
	int num_bits = row_lsb + row_bits + lranks_bits - 26;
	char *s;

	lmc_nxm.u64 = lmc_rd(priv, CVMX_LMCX_NXM(if_num));

	/* .cn78xx. */
	if (rank_mask & 0x1)
		lmc_nxm.cn78xx.mem_msb_d0_r0 = num_bits;
	if (rank_mask & 0x2)
		lmc_nxm.cn78xx.mem_msb_d0_r1 = num_bits;
	if (rank_mask & 0x4)
		lmc_nxm.cn78xx.mem_msb_d1_r0 = num_bits;
	if (rank_mask & 0x8)
		lmc_nxm.cn78xx.mem_msb_d1_r1 = num_bits;

	/* Set the mask for non-existent ranks. */
	lmc_nxm.cn78xx.cs_mask = ~rank_mask & 0xff;

	s = lookup_env_ull(priv, "ddr_nxm");
	if (s)
		lmc_nxm.u64 = simple_strtoull(s, NULL, 0);

	debug("LMC_NXM                                       : 0x%016llx\n",
	      lmc_nxm.u64);
	lmc_wr(priv, CVMX_LMCX_NXM(if_num), lmc_nxm.u64);
}

static void lmc_wodt_mask(struct ddr_priv *priv)
{
	union cvmx_lmcx_wodt_mask wodt_mask;
	char *s;

	wodt_mask.u64 = odt_config[odt_idx].odt_mask;

	s = lookup_env_ull(priv, "ddr_wodt_mask");
	if (s)
		wodt_mask.u64 = simple_strtoull(s, NULL, 0);

	debug("WODT_MASK                                     : 0x%016llx\n",
	      wodt_mask.u64);
	lmc_wr(priv, CVMX_LMCX_WODT_MASK(if_num), wodt_mask.u64);
}

static void lmc_rodt_mask(struct ddr_priv *priv)
{
	union cvmx_lmcx_rodt_mask rodt_mask;
	int rankx;
	char *s;

	rodt_mask.u64 = odt_config[odt_idx].rodt_ctl;

	s = lookup_env_ull(priv, "ddr_rodt_mask");
	if (s)
		rodt_mask.u64 = simple_strtoull(s, NULL, 0);

	debug("%-45s : 0x%016llx\n", "RODT_MASK", rodt_mask.u64);
	lmc_wr(priv, CVMX_LMCX_RODT_MASK(if_num), rodt_mask.u64);

	dyn_rtt_nom_mask = 0;
	for (rankx = 0; rankx < dimm_count * 4; rankx++) {
		if (!(rank_mask & (1 << rankx)))
			continue;
		dyn_rtt_nom_mask |= ((rodt_mask.u64 >> (8 * rankx)) & 0xff);
	}
	if (num_ranks == 4) {
		/*
		 * Normally ODT1 is wired to rank 1. For quad-ranked DIMMs
		 * ODT1 is wired to the third rank (rank 2).  The mask,
		 * dyn_rtt_nom_mask, is used to indicate for which ranks
		 * to sweep RTT_NOM during read-leveling. Shift the bit
		 * from the ODT1 position over to the "ODT2" position so
		 * that the read-leveling analysis comes out right.
		 */
		int odt1_bit = dyn_rtt_nom_mask & 2;

		dyn_rtt_nom_mask &= ~2;
		dyn_rtt_nom_mask |= odt1_bit << 1;
	}
	debug("%-45s : 0x%02x\n", "DYN_RTT_NOM_MASK", dyn_rtt_nom_mask);
}

static void lmc_comp_ctl2(struct ddr_priv *priv)
{
	union cvmx_lmcx_comp_ctl2 cc2;
	char *s;

	cc2.u64 = lmc_rd(priv, CVMX_LMCX_COMP_CTL2(if_num));

	cc2.cn78xx.dqx_ctl = odt_config[odt_idx].odt_ena;
	/* Default 4=34.3 ohm */
	cc2.cn78xx.ck_ctl = (c_cfg->ck_ctl == 0) ? 4 : c_cfg->ck_ctl;
	/* Default 4=34.3 ohm */
	cc2.cn78xx.cmd_ctl = (c_cfg->cmd_ctl == 0) ? 4 : c_cfg->cmd_ctl;
	/* Default 4=34.3 ohm */
	cc2.cn78xx.control_ctl = (c_cfg->ctl_ctl == 0) ? 4 : c_cfg->ctl_ctl;

	ddr_rodt_ctl_auto = c_cfg->ddr_rodt_ctl_auto;
	s = lookup_env(priv, "ddr_rodt_ctl_auto");
	if (s)
		ddr_rodt_ctl_auto = !!simple_strtoul(s, NULL, 0);

	default_rodt_ctl = odt_config[odt_idx].qs_dic;
	s = lookup_env(priv, "ddr_rodt_ctl");
	if (!s)
		s = lookup_env(priv, "ddr%d_rodt_ctl", if_num);
	if (s) {
		default_rodt_ctl = simple_strtoul(s, NULL, 0);
		ddr_rodt_ctl_auto = 0;
	}

	cc2.cn70xx.rodt_ctl = default_rodt_ctl;

	// if DDR4, force CK_CTL to 26 ohms if it is currently 34 ohms,
	// and DCLK speed is 1 GHz or more...
	if (ddr_type == DDR4_DRAM && cc2.s.ck_ctl == ddr4_driver_34_ohm &&
	    ddr_hertz >= 1000000000) {
		// lowest for DDR4 is 26 ohms
		cc2.s.ck_ctl = ddr4_driver_26_ohm;
		debug("N%d.LMC%d: Forcing DDR4 COMP_CTL2[CK_CTL] to %d, %d ohms\n",
		      node, if_num, cc2.s.ck_ctl,
		      imp_val->drive_strength[cc2.s.ck_ctl]);
	}

	// if DDR4, 2DPC, UDIMM, force CONTROL_CTL and CMD_CTL to 26 ohms,
	// if DCLK speed is 1 GHz or more...
	if (ddr_type == DDR4_DRAM && dimm_count == 2 &&
	    (spd_dimm_type == 2 || spd_dimm_type == 6) &&
	    ddr_hertz >= 1000000000) {
		// lowest for DDR4 is 26 ohms
		cc2.cn78xx.control_ctl = ddr4_driver_26_ohm;
		// lowest for DDR4 is 26 ohms
		cc2.cn78xx.cmd_ctl = ddr4_driver_26_ohm;
		debug("N%d.LMC%d: Forcing DDR4 COMP_CTL2[CONTROL_CTL,CMD_CTL] to %d, %d ohms\n",
		      node, if_num, ddr4_driver_26_ohm,
		      imp_val->drive_strength[ddr4_driver_26_ohm]);
	}

	s = lookup_env(priv, "ddr_ck_ctl");
	if (s)
		cc2.cn78xx.ck_ctl = simple_strtoul(s, NULL, 0);

	s = lookup_env(priv, "ddr_cmd_ctl");
	if (s)
		cc2.cn78xx.cmd_ctl = simple_strtoul(s, NULL, 0);

	s = lookup_env(priv, "ddr_control_ctl");
	if (s)
		cc2.cn70xx.control_ctl = simple_strtoul(s, NULL, 0);

	s = lookup_env(priv, "ddr_dqx_ctl");
	if (s)
		cc2.cn78xx.dqx_ctl = simple_strtoul(s, NULL, 0);

	debug("%-45s : %d, %d ohms\n", "DQX_CTL           ", cc2.cn78xx.dqx_ctl,
	      imp_val->drive_strength[cc2.cn78xx.dqx_ctl]);
	debug("%-45s : %d, %d ohms\n", "CK_CTL            ", cc2.cn78xx.ck_ctl,
	      imp_val->drive_strength[cc2.cn78xx.ck_ctl]);
	debug("%-45s : %d, %d ohms\n", "CMD_CTL           ", cc2.cn78xx.cmd_ctl,
	      imp_val->drive_strength[cc2.cn78xx.cmd_ctl]);
	debug("%-45s : %d, %d ohms\n", "CONTROL_CTL       ",
	      cc2.cn78xx.control_ctl,
	      imp_val->drive_strength[cc2.cn78xx.control_ctl]);
	debug("Read ODT_CTL                                  : 0x%x (%d ohms)\n",
	      cc2.cn78xx.rodt_ctl, imp_val->rodt_ohms[cc2.cn78xx.rodt_ctl]);

	debug("%-45s : 0x%016llx\n", "COMP_CTL2", cc2.u64);
	lmc_wr(priv, CVMX_LMCX_COMP_CTL2(if_num), cc2.u64);
}

static void lmc_phy_ctl(struct ddr_priv *priv)
{
	union cvmx_lmcx_phy_ctl phy_ctl;

	phy_ctl.u64 = lmc_rd(priv, CVMX_LMCX_PHY_CTL(if_num));
	phy_ctl.s.ts_stagger = 0;
	// FIXME: are there others TBD?
	phy_ctl.s.dsk_dbg_overwrt_ena = 0;

	if (!octeon_is_cpuid(OCTEON_CN78XX_PASS1_X) && lranks_per_prank > 1) {
		// C0 is TEN, C1 is A17
		phy_ctl.s.c0_sel = 2;
		phy_ctl.s.c1_sel = 2;
		debug("N%d.LMC%d: 3DS: setting PHY_CTL[cx_csel] = %d\n",
		      node, if_num, phy_ctl.s.c1_sel);
	}

	debug("PHY_CTL                                       : 0x%016llx\n",
	      phy_ctl.u64);
	lmc_wr(priv, CVMX_LMCX_PHY_CTL(if_num), phy_ctl.u64);
}

static void lmc_ext_config(struct ddr_priv *priv)
{
	union cvmx_lmcx_ext_config ext_cfg;
	char *s;

	ext_cfg.u64 = lmc_rd(priv, CVMX_LMCX_EXT_CONFIG(if_num));
	ext_cfg.s.vrefint_seq_deskew = 0;
	ext_cfg.s.read_ena_bprch = 1;
	ext_cfg.s.read_ena_fprch = 1;
	ext_cfg.s.drive_ena_fprch = 1;
	ext_cfg.s.drive_ena_bprch = 1;
	// make sure this is OFF for all current chips
	ext_cfg.s.invert_data = 0;

	s = lookup_env(priv, "ddr_read_fprch");
	if (s)
		ext_cfg.s.read_ena_fprch = strtoul(s, NULL, 0);

	s = lookup_env(priv, "ddr_read_bprch");
	if (s)
		ext_cfg.s.read_ena_bprch = strtoul(s, NULL, 0);

	s = lookup_env(priv, "ddr_drive_fprch");
	if (s)
		ext_cfg.s.drive_ena_fprch = strtoul(s, NULL, 0);

	s = lookup_env(priv, "ddr_drive_bprch");
	if (s)
		ext_cfg.s.drive_ena_bprch = strtoul(s, NULL, 0);

	if (!octeon_is_cpuid(OCTEON_CN78XX_PASS1_X) && lranks_per_prank > 1) {
		ext_cfg.s.dimm0_cid = lranks_bits;
		ext_cfg.s.dimm1_cid = lranks_bits;
		debug("N%d.LMC%d: 3DS: setting EXT_CONFIG[dimmx_cid] = %d\n",
		      node, if_num, ext_cfg.s.dimm0_cid);
	}

	lmc_wr(priv, CVMX_LMCX_EXT_CONFIG(if_num), ext_cfg.u64);
	debug("%-45s : 0x%016llx\n", "EXT_CONFIG", ext_cfg.u64);
}

static void lmc_ext_config2(struct ddr_priv *priv)
{
	char *s;

	// NOTE: all chips have this register, but not necessarily the
	// fields we modify...
	if (!octeon_is_cpuid(OCTEON_CN78XX_PASS1_X) &&
	    !octeon_is_cpuid(OCTEON_CN73XX)) {
		union cvmx_lmcx_ext_config2 ext_cfg2;
		int value = 1;	// default to 1

		ext_cfg2.u64 = lmc_rd(priv, CVMX_LMCX_EXT_CONFIG2(if_num));

		s = lookup_env(priv, "ddr_ext2_delay_unload");
		if (s)
			value = !!simple_strtoul(s, NULL, 0);

		ext_cfg2.s.delay_unload_r0 = value;
		ext_cfg2.s.delay_unload_r1 = value;
		ext_cfg2.s.delay_unload_r2 = value;
		ext_cfg2.s.delay_unload_r3 = value;

		lmc_wr(priv, CVMX_LMCX_EXT_CONFIG2(if_num), ext_cfg2.u64);
		debug("%-45s : 0x%016llx\n", "EXT_CONFIG2", ext_cfg2.u64);
	}
}

static void lmc_dimm01_params_loop(struct ddr_priv *priv)
{
	union cvmx_lmcx_dimmx_params dimm_p;
	int dimmx = didx;
	char *s;
	int rc;
	int i;

	dimm_p.u64 = lmc_rd(priv, CVMX_LMCX_DIMMX_PARAMS(dimmx, if_num));

	if (ddr_type == DDR4_DRAM) {
		union cvmx_lmcx_dimmx_ddr4_params0 ddr4_p0;
		union cvmx_lmcx_dimmx_ddr4_params1 ddr4_p1;
		union cvmx_lmcx_ddr4_dimm_ctl ddr4_ctl;

		dimm_p.s.rc0 = 0;
		dimm_p.s.rc1 = 0;
		dimm_p.s.rc2 = 0;

		rc = read_spd(&dimm_config_table[didx], 0,
			      DDR4_SPD_RDIMM_REGISTER_DRIVE_STRENGTH_CTL);
		dimm_p.s.rc3 = (rc >> 4) & 0xf;
		dimm_p.s.rc4 = ((rc >> 0) & 0x3) << 2;
		dimm_p.s.rc4 |= ((rc >> 2) & 0x3) << 0;

		rc = read_spd(&dimm_config_table[didx], 0,
			      DDR4_SPD_RDIMM_REGISTER_DRIVE_STRENGTH_CK);
		dimm_p.s.rc5 = ((rc >> 0) & 0x3) << 2;
		dimm_p.s.rc5 |= ((rc >> 2) & 0x3) << 0;

		dimm_p.s.rc6 = 0;
		dimm_p.s.rc7 = 0;
		dimm_p.s.rc8 = 0;
		dimm_p.s.rc9 = 0;

		/*
		 * rc10               DDR4 RDIMM Operating Speed
		 * ===  ===================================================
		 *  0               tclk_psecs >= 1250 psec DDR4-1600 (1250 ps)
		 *  1   1250 psec > tclk_psecs >= 1071 psec DDR4-1866 (1071 ps)
		 *  2   1071 psec > tclk_psecs >=  938 psec DDR4-2133 ( 938 ps)
		 *  3    938 psec > tclk_psecs >=  833 psec DDR4-2400 ( 833 ps)
		 *  4    833 psec > tclk_psecs >=  750 psec DDR4-2666 ( 750 ps)
		 *  5    750 psec > tclk_psecs >=  625 psec DDR4-3200 ( 625 ps)
		 */
		dimm_p.s.rc10 = 0;
		if (tclk_psecs < 1250)
			dimm_p.s.rc10 = 1;
		if (tclk_psecs < 1071)
			dimm_p.s.rc10 = 2;
		if (tclk_psecs < 938)
			dimm_p.s.rc10 = 3;
		if (tclk_psecs < 833)
			dimm_p.s.rc10 = 4;
		if (tclk_psecs < 750)
			dimm_p.s.rc10 = 5;

		dimm_p.s.rc11 = 0;
		dimm_p.s.rc12 = 0;
		/* 0=LRDIMM, 1=RDIMM */
		dimm_p.s.rc13 = (spd_dimm_type == 4) ? 0 : 4;
		dimm_p.s.rc13 |= (ddr_type == DDR4_DRAM) ?
			(spd_addr_mirror << 3) : 0;
		dimm_p.s.rc14 = 0;
		dimm_p.s.rc15 = 0;	/* 1 nCK latency adder */

		ddr4_p0.u64 = 0;

		ddr4_p0.s.rc8x = 0;
		ddr4_p0.s.rc7x = 0;
		ddr4_p0.s.rc6x = 0;
		ddr4_p0.s.rc5x = 0;
		ddr4_p0.s.rc4x = 0;

		ddr4_p0.s.rc3x = compute_rc3x(tclk_psecs);

		ddr4_p0.s.rc2x = 0;
		ddr4_p0.s.rc1x = 0;

		ddr4_p1.u64 = 0;

		ddr4_p1.s.rcbx = 0;
		ddr4_p1.s.rcax = 0;
		ddr4_p1.s.rc9x = 0;

		ddr4_ctl.u64 = 0;
		ddr4_ctl.cn70xx.ddr4_dimm0_wmask = 0x004;
		ddr4_ctl.cn70xx.ddr4_dimm1_wmask =
		    (dimm_count > 1) ? 0x004 : 0x0000;

		/*
		 * Handle any overrides from envvars here...
		 */
		s = lookup_env(priv, "ddr_ddr4_params0");
		if (s)
			ddr4_p0.u64 = simple_strtoul(s, NULL, 0);

		s = lookup_env(priv, "ddr_ddr4_params1");
		if (s)
			ddr4_p1.u64 = simple_strtoul(s, NULL, 0);

		s = lookup_env(priv, "ddr_ddr4_dimm_ctl");
		if (s)
			ddr4_ctl.u64 = simple_strtoul(s, NULL, 0);

		for (i = 0; i < 11; ++i) {
			u64 value;

			s = lookup_env(priv, "ddr_ddr4_rc%1xx", i + 1);
			if (s) {
				value = simple_strtoul(s, NULL, 0);
				if (i < 8) {
					ddr4_p0.u64 &= ~((u64)0xff << (i * 8));
					ddr4_p0.u64 |= (value << (i * 8));
				} else {
					ddr4_p1.u64 &=
					    ~((u64)0xff << ((i - 8) * 8));
					ddr4_p1.u64 |= (value << ((i - 8) * 8));
				}
			}
		}

		/*
		 * write the final CSR values
		 */
		lmc_wr(priv, CVMX_LMCX_DIMMX_DDR4_PARAMS0(dimmx, if_num),
		       ddr4_p0.u64);

		lmc_wr(priv, CVMX_LMCX_DDR4_DIMM_CTL(if_num), ddr4_ctl.u64);

		lmc_wr(priv, CVMX_LMCX_DIMMX_DDR4_PARAMS1(dimmx, if_num),
		       ddr4_p1.u64);

		debug("DIMM%d Register Control Words        RCBx:RC1x : %x %x %x %x %x %x %x %x %x %x %x\n",
		      dimmx, ddr4_p1.s.rcbx, ddr4_p1.s.rcax,
		      ddr4_p1.s.rc9x, ddr4_p0.s.rc8x,
		      ddr4_p0.s.rc7x, ddr4_p0.s.rc6x,
		      ddr4_p0.s.rc5x, ddr4_p0.s.rc4x,
		      ddr4_p0.s.rc3x, ddr4_p0.s.rc2x, ddr4_p0.s.rc1x);

	} else {
		rc = read_spd(&dimm_config_table[didx], 0, 69);
		dimm_p.s.rc0 = (rc >> 0) & 0xf;
		dimm_p.s.rc1 = (rc >> 4) & 0xf;

		rc = read_spd(&dimm_config_table[didx], 0, 70);
		dimm_p.s.rc2 = (rc >> 0) & 0xf;
		dimm_p.s.rc3 = (rc >> 4) & 0xf;

		rc = read_spd(&dimm_config_table[didx], 0, 71);
		dimm_p.s.rc4 = (rc >> 0) & 0xf;
		dimm_p.s.rc5 = (rc >> 4) & 0xf;

		rc = read_spd(&dimm_config_table[didx], 0, 72);
		dimm_p.s.rc6 = (rc >> 0) & 0xf;
		dimm_p.s.rc7 = (rc >> 4) & 0xf;

		rc = read_spd(&dimm_config_table[didx], 0, 73);
		dimm_p.s.rc8 = (rc >> 0) & 0xf;
		dimm_p.s.rc9 = (rc >> 4) & 0xf;

		rc = read_spd(&dimm_config_table[didx], 0, 74);
		dimm_p.s.rc10 = (rc >> 0) & 0xf;
		dimm_p.s.rc11 = (rc >> 4) & 0xf;

		rc = read_spd(&dimm_config_table[didx], 0, 75);
		dimm_p.s.rc12 = (rc >> 0) & 0xf;
		dimm_p.s.rc13 = (rc >> 4) & 0xf;

		rc = read_spd(&dimm_config_table[didx], 0, 76);
		dimm_p.s.rc14 = (rc >> 0) & 0xf;
		dimm_p.s.rc15 = (rc >> 4) & 0xf;

		s = ddr_getenv_debug(priv, "ddr_clk_drive");
		if (s) {
			if (strcmp(s, "light") == 0)
				dimm_p.s.rc5 = 0x0;	/* Light Drive */
			if (strcmp(s, "moderate") == 0)
				dimm_p.s.rc5 = 0x5;	/* Moderate Drive */
			if (strcmp(s, "strong") == 0)
				dimm_p.s.rc5 = 0xA;	/* Strong Drive */
			printf("Parameter found in environment. ddr_clk_drive = %s\n",
			       s);
		}

		s = ddr_getenv_debug(priv, "ddr_cmd_drive");
		if (s) {
			if (strcmp(s, "light") == 0)
				dimm_p.s.rc3 = 0x0;	/* Light Drive */
			if (strcmp(s, "moderate") == 0)
				dimm_p.s.rc3 = 0x5;	/* Moderate Drive */
			if (strcmp(s, "strong") == 0)
				dimm_p.s.rc3 = 0xA;	/* Strong Drive */
			printf("Parameter found in environment. ddr_cmd_drive = %s\n",
			       s);
		}

		s = ddr_getenv_debug(priv, "ddr_ctl_drive");
		if (s) {
			if (strcmp(s, "light") == 0)
				dimm_p.s.rc4 = 0x0;	/* Light Drive */
			if (strcmp(s, "moderate") == 0)
				dimm_p.s.rc4 = 0x5;	/* Moderate Drive */
			printf("Parameter found in environment. ddr_ctl_drive = %s\n",
			       s);
		}

		/*
		 * rc10               DDR3 RDIMM Operating Speed
		 * ==   =====================================================
		 *  0               tclk_psecs >= 2500 psec DDR3/DDR3L-800 def
		 *  1   2500 psec > tclk_psecs >= 1875 psec DDR3/DDR3L-1066
		 *  2   1875 psec > tclk_psecs >= 1500 psec DDR3/DDR3L-1333
		 *  3   1500 psec > tclk_psecs >= 1250 psec DDR3/DDR3L-1600
		 *  4   1250 psec > tclk_psecs >= 1071 psec DDR3-1866
		 */
		dimm_p.s.rc10 = 0;
		if (tclk_psecs < 2500)
			dimm_p.s.rc10 = 1;
		if (tclk_psecs < 1875)
			dimm_p.s.rc10 = 2;
		if (tclk_psecs < 1500)
			dimm_p.s.rc10 = 3;
		if (tclk_psecs < 1250)
			dimm_p.s.rc10 = 4;
	}

	s = lookup_env(priv, "ddr_dimmx_params", i);
	if (s)
		dimm_p.u64 = simple_strtoul(s, NULL, 0);

	for (i = 0; i < 16; ++i) {
		u64 value;

		s = lookup_env(priv, "ddr_rc%d", i);
		if (s) {
			value = simple_strtoul(s, NULL, 0);
			dimm_p.u64 &= ~((u64)0xf << (i * 4));
			dimm_p.u64 |= (value << (i * 4));
		}
	}

	lmc_wr(priv, CVMX_LMCX_DIMMX_PARAMS(dimmx, if_num), dimm_p.u64);

	debug("DIMM%d Register Control Words         RC15:RC0 : %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x\n",
	      dimmx, dimm_p.s.rc15, dimm_p.s.rc14, dimm_p.s.rc13,
	      dimm_p.s.rc12, dimm_p.s.rc11, dimm_p.s.rc10,
	      dimm_p.s.rc9, dimm_p.s.rc8, dimm_p.s.rc7,
	      dimm_p.s.rc6, dimm_p.s.rc5, dimm_p.s.rc4,
	      dimm_p.s.rc3, dimm_p.s.rc2, dimm_p.s.rc1, dimm_p.s.rc0);

	// FIXME: recognize a DDR3 RDIMM with 4 ranks and 2 registers,
	// and treat it specially
	if (ddr_type == DDR3_DRAM && num_ranks == 4 &&
	    spd_rdimm_registers == 2 && dimmx == 0) {
		debug("DDR3: Copying DIMM0_PARAMS to DIMM1_PARAMS for pseudo-DIMM #1...\n");
		lmc_wr(priv, CVMX_LMCX_DIMMX_PARAMS(1, if_num), dimm_p.u64);
	}
}

static void lmc_dimm01_params(struct ddr_priv *priv)
{
	union cvmx_lmcx_dimm_ctl dimm_ctl;
	char *s;

	if (spd_rdimm) {
		for (didx = 0; didx < (unsigned int)dimm_count; ++didx)
			lmc_dimm01_params_loop(priv);

		if (ddr_type == DDR4_DRAM) {
			/* LMC0_DIMM_CTL */
			dimm_ctl.u64 = lmc_rd(priv, CVMX_LMCX_DIMM_CTL(if_num));
			dimm_ctl.s.dimm0_wmask = 0xdf3f;
			dimm_ctl.s.dimm1_wmask =
			    (dimm_count > 1) ? 0xdf3f : 0x0000;
			dimm_ctl.s.tcws = 0x4e0;
			dimm_ctl.s.parity = c_cfg->parity;

			s = lookup_env(priv, "ddr_dimm0_wmask");
			if (s) {
				dimm_ctl.s.dimm0_wmask =
				    simple_strtoul(s, NULL, 0);
			}

			s = lookup_env(priv, "ddr_dimm1_wmask");
			if (s) {
				dimm_ctl.s.dimm1_wmask =
				    simple_strtoul(s, NULL, 0);
			}

			s = lookup_env(priv, "ddr_dimm_ctl_parity");
			if (s)
				dimm_ctl.s.parity = simple_strtoul(s, NULL, 0);

			s = lookup_env(priv, "ddr_dimm_ctl_tcws");
			if (s)
				dimm_ctl.s.tcws = simple_strtoul(s, NULL, 0);

			debug("LMC DIMM_CTL                                  : 0x%016llx\n",
			      dimm_ctl.u64);
			lmc_wr(priv, CVMX_LMCX_DIMM_CTL(if_num), dimm_ctl.u64);

			/* Init RCW */
			oct3_ddr3_seq(priv, rank_mask, if_num, 0x7);

			/* Write RC0D last */
			dimm_ctl.s.dimm0_wmask = 0x2000;
			dimm_ctl.s.dimm1_wmask = (dimm_count > 1) ?
				0x2000 : 0x0000;
			debug("LMC DIMM_CTL                                  : 0x%016llx\n",
			      dimm_ctl.u64);
			lmc_wr(priv, CVMX_LMCX_DIMM_CTL(if_num), dimm_ctl.u64);

			/*
			 * Don't write any extended registers the second time
			 */
			lmc_wr(priv, CVMX_LMCX_DDR4_DIMM_CTL(if_num), 0);

			/* Init RCW */
			oct3_ddr3_seq(priv, rank_mask, if_num, 0x7);
		} else {
			/* LMC0_DIMM_CTL */
			dimm_ctl.u64 = lmc_rd(priv, CVMX_LMCX_DIMM_CTL(if_num));
			dimm_ctl.s.dimm0_wmask = 0xffff;
			// FIXME: recognize a DDR3 RDIMM with 4 ranks and 2
			// registers, and treat it specially
			if (num_ranks == 4 && spd_rdimm_registers == 2) {
				debug("DDR3: Activating DIMM_CTL[dimm1_mask] bits...\n");
				dimm_ctl.s.dimm1_wmask = 0xffff;
			} else {
				dimm_ctl.s.dimm1_wmask =
				    (dimm_count > 1) ? 0xffff : 0x0000;
			}
			dimm_ctl.s.tcws = 0x4e0;
			dimm_ctl.s.parity = c_cfg->parity;

			s = lookup_env(priv, "ddr_dimm0_wmask");
			if (s) {
				dimm_ctl.s.dimm0_wmask =
				    simple_strtoul(s, NULL, 0);
			}

			s = lookup_env(priv, "ddr_dimm1_wmask");
			if (s) {
				dimm_ctl.s.dimm1_wmask =
				    simple_strtoul(s, NULL, 0);
			}

			s = lookup_env(priv, "ddr_dimm_ctl_parity");
			if (s)
				dimm_ctl.s.parity = simple_strtoul(s, NULL, 0);

			s = lookup_env(priv, "ddr_dimm_ctl_tcws");
			if (s)
				dimm_ctl.s.tcws = simple_strtoul(s, NULL, 0);

			debug("LMC DIMM_CTL                                  : 0x%016llx\n",
			      dimm_ctl.u64);
			lmc_wr(priv, CVMX_LMCX_DIMM_CTL(if_num), dimm_ctl.u64);

			/* Init RCW */
			oct3_ddr3_seq(priv, rank_mask, if_num, 0x7);
		}

	} else {
		/* Disable register control writes for unbuffered */
		union cvmx_lmcx_dimm_ctl dimm_ctl;

		dimm_ctl.u64 = lmc_rd(priv, CVMX_LMCX_DIMM_CTL(if_num));
		dimm_ctl.s.dimm0_wmask = 0;
		dimm_ctl.s.dimm1_wmask = 0;
		lmc_wr(priv, CVMX_LMCX_DIMM_CTL(if_num), dimm_ctl.u64);
	}
}

static int lmc_rank_init(struct ddr_priv *priv)
{
	char *s;

	if (enable_by_rank_init) {
		by_rank = 3;
		saved_rank_mask = rank_mask;
	}

start_by_rank_init:

	if (enable_by_rank_init) {
		rank_mask = (1 << by_rank);
		if (!(rank_mask & saved_rank_mask))
			goto end_by_rank_init;
		if (by_rank == 0)
			rank_mask = saved_rank_mask;

		debug("\n>>>>> BY_RANK: starting rank %d with mask 0x%02x\n\n",
		      by_rank, rank_mask);
	}

	/*
	 * Comments (steps 3 through 5) continue in oct3_ddr3_seq()
	 */
	union cvmx_lmcx_modereg_params0 mp0;

	if (ddr_memory_preserved(priv)) {
		/*
		 * Contents are being preserved. Take DRAM out of self-refresh
		 * first. Then init steps can procede normally
		 */
		/* self-refresh exit */
		oct3_ddr3_seq(priv, rank_mask, if_num, 3);
	}

	mp0.u64 = lmc_rd(priv, CVMX_LMCX_MODEREG_PARAMS0(if_num));
	mp0.s.dllr = 1;		/* Set during first init sequence */
	lmc_wr(priv, CVMX_LMCX_MODEREG_PARAMS0(if_num), mp0.u64);

	ddr_init_seq(priv, rank_mask, if_num);

	mp0.s.dllr = 0;		/* Clear for normal operation */
	lmc_wr(priv, CVMX_LMCX_MODEREG_PARAMS0(if_num), mp0.u64);

	if (spd_rdimm && ddr_type == DDR4_DRAM &&
	    octeon_is_cpuid(OCTEON_CN7XXX)) {
		debug("Running init sequence 1\n");
		change_rdimm_mpr_pattern(priv, rank_mask, if_num, dimm_count);
	}

	memset(lanes, 0, sizeof(lanes));
	for (lane = 0; lane < last_lane; lane++) {
		// init all lanes to reset value
		dac_settings[lane] = 127;
	}

	// FIXME: disable internal VREF if deskew is disabled?
	if (disable_deskew_training) {
		debug("N%d.LMC%d: internal VREF Training disabled, leaving them in RESET.\n",
		      node, if_num);
		num_samples = 0;
	} else if (ddr_type == DDR4_DRAM &&
		   !octeon_is_cpuid(OCTEON_CN78XX_PASS1_X)) {
		num_samples = DEFAULT_DAC_SAMPLES;
	} else {
		// if DDR3 or no ability to write DAC values
		num_samples = 1;
	}

perform_internal_vref_training:

	total_dac_eval_retries = 0;
	dac_eval_exhausted = 0;

	for (sample = 0; sample < num_samples; sample++) {
		dac_eval_retries = 0;

		// make offset and internal vref training repeatable
		do {
			/*
			 * 6.9.8 LMC Offset Training
			 * LMC requires input-receiver offset training.
			 */
			perform_offset_training(priv, rank_mask, if_num);

			/*
			 * 6.9.9 LMC Internal vref Training
			 * LMC requires input-reference-voltage training.
			 */
			perform_internal_vref_training(priv, rank_mask, if_num);

			// read and maybe display the DAC values for a sample
			read_dac_dbi_settings(priv, if_num, /*DAC*/ 1,
					      dac_settings);
			if (num_samples == 1 || ddr_verbose(priv)) {
				display_dac_dbi_settings(if_num, /*DAC*/ 1,
							 use_ecc, dac_settings,
							 "Internal VREF");
			}

			// for DDR4, evaluate the DAC settings and retry
			// if any issues
			if (ddr_type == DDR4_DRAM) {
				if (evaluate_dac_settings
				    (if_64b, use_ecc, dac_settings)) {
					dac_eval_retries += 1;
					if (dac_eval_retries >
					    DAC_RETRIES_LIMIT) {
						debug("N%d.LMC%d: DDR4 internal VREF DAC settings: retries exhausted; continuing...\n",
						      node, if_num);
						dac_eval_exhausted += 1;
					} else {
						debug("N%d.LMC%d: DDR4 internal VREF DAC settings inconsistent; retrying....\n",
						      node, if_num);
						total_dac_eval_retries += 1;
						// try another sample
						continue;
					}
				}

				// taking multiple samples, otherwise do nothing
				if (num_samples > 1) {
					// good sample or exhausted retries,
					// record it
					for (lane = 0; lane < last_lane;
					     lane++) {
						lanes[lane].bytes[sample] =
						    dac_settings[lane];
					}
				}
			}
			// done if DDR3, or good sample, or exhausted retries
			break;
		} while (1);
	}

	if (ddr_type == DDR4_DRAM && dac_eval_exhausted > 0) {
		debug("N%d.LMC%d: DDR internal VREF DAC settings: total retries %d, exhausted %d\n",
		      node, if_num, total_dac_eval_retries, dac_eval_exhausted);
	}

	if (num_samples > 1) {
		debug("N%d.LMC%d: DDR4 internal VREF DAC settings: processing multiple samples...\n",
		      node, if_num);

		for (lane = 0; lane < last_lane; lane++) {
			dac_settings[lane] =
			    process_samples_average(&lanes[lane].bytes[0],
						    num_samples, if_num, lane);
		}
		display_dac_dbi_settings(if_num, /*DAC*/ 1, use_ecc,
					 dac_settings, "Averaged VREF");

		// finally, write the final DAC values
		for (lane = 0; lane < last_lane; lane++) {
			load_dac_override(priv, if_num, dac_settings[lane],
					  lane);
		}
	}

	// allow override of any byte-lane internal VREF
	int overrode_vref_dac = 0;

	for (lane = 0; lane < last_lane; lane++) {
		s = lookup_env(priv, "ddr%d_vref_dac_byte%d", if_num, lane);
		if (s) {
			dac_settings[lane] = simple_strtoul(s, NULL, 0);
			overrode_vref_dac = 1;
			// finally, write the new DAC value
			load_dac_override(priv, if_num, dac_settings[lane],
					  lane);
		}
	}
	if (overrode_vref_dac) {
		display_dac_dbi_settings(if_num, /*DAC*/ 1, use_ecc,
					 dac_settings, "Override VREF");
	}

	// as a second step, after internal VREF training, before starting
	// deskew training:
	// for DDR3 and OCTEON3 not O78 pass 1.x, override the DAC setting
	// to 127
	if (ddr_type == DDR3_DRAM && !octeon_is_cpuid(OCTEON_CN78XX_PASS1_X) &&
	    !disable_deskew_training) {
		load_dac_override(priv, if_num, 127, /* all */ 0x0A);
		debug("N%d.LMC%d: Overriding DDR3 internal VREF DAC settings to 127.\n",
		      node, if_num);
	}

	/*
	 * 4.8.8 LMC Deskew Training
	 *
	 * LMC requires input-read-data deskew training.
	 */
	if (!disable_deskew_training) {
		deskew_training_errors =
		    perform_deskew_training(priv, rank_mask, if_num,
					    spd_rawcard_aorb);

		// All the Deskew lock and saturation retries (may) have
		// been done, but we ended up with nibble errors; so,
		// as a last ditch effort, try the Internal vref
		// Training again...
		if (deskew_training_errors) {
			if (internal_retries <
			    DEFAULT_INTERNAL_VREF_TRAINING_LIMIT) {
				internal_retries++;
				debug("N%d.LMC%d: Deskew training results still unsettled - retrying internal vref training (%d)\n",
				      node, if_num, internal_retries);
				goto perform_internal_vref_training;
			} else {
				if (restart_if_dsk_incomplete) {
					debug("N%d.LMC%d: INFO: Deskew training incomplete - %d retries exhausted, Restarting LMC init...\n",
					      node, if_num, internal_retries);
					return -EAGAIN;
				}
				debug("N%d.LMC%d: Deskew training incomplete - %d retries exhausted, but continuing...\n",
				      node, if_num, internal_retries);
			}
		}		/* if (deskew_training_errors) */

		// FIXME: treat this as the final DSK print from now on,
		// and print if VBL_NORM or above also, save the results
		// of the original training in case we want them later
		validate_deskew_training(priv, rank_mask, if_num,
					 &deskew_training_results, 1);
	} else {		/* if (! disable_deskew_training) */
		debug("N%d.LMC%d: Deskew Training disabled, printing settings before HWL.\n",
		      node, if_num);
		validate_deskew_training(priv, rank_mask, if_num,
					 &deskew_training_results, 1);
	}			/* if (! disable_deskew_training) */

	if (enable_by_rank_init) {
		read_dac_dbi_settings(priv, if_num, /*dac */ 1,
				      &rank_dac[by_rank].bytes[0]);
		get_deskew_settings(priv, if_num, &rank_dsk[by_rank]);
		debug("\n>>>>> BY_RANK: ending rank %d\n\n", by_rank);
	}

end_by_rank_init:

	if (enable_by_rank_init) {
		//debug("\n>>>>> BY_RANK: ending rank %d\n\n", by_rank);

		by_rank--;
		if (by_rank >= 0)
			goto start_by_rank_init;

		rank_mask = saved_rank_mask;
		ddr_init_seq(priv, rank_mask, if_num);

		process_by_rank_dac(priv, if_num, rank_mask, rank_dac);
		process_by_rank_dsk(priv, if_num, rank_mask, rank_dsk);

		// FIXME: set this to prevent later checking!!!
		disable_deskew_training = 1;

		debug("\n>>>>> BY_RANK: FINISHED!!\n\n");
	}

	return 0;
}

static void lmc_config_2(struct ddr_priv *priv)
{
	union cvmx_lmcx_config lmc_config;
	int save_ref_zqcs_int;
	u64 temp_delay_usecs;

	lmc_config.u64 = lmc_rd(priv, CVMX_LMCX_CONFIG(if_num));

	/*
	 * Temporarily select the minimum ZQCS interval and wait
	 * long enough for a few ZQCS calibrations to occur.  This
	 * should ensure that the calibration circuitry is
	 * stabilized before read/write leveling occurs.
	 */
	if (octeon_is_cpuid(OCTEON_CN7XXX)) {
		save_ref_zqcs_int = lmc_config.cn78xx.ref_zqcs_int;
		/* set smallest interval */
		lmc_config.cn78xx.ref_zqcs_int = 1 | (32 << 7);
	} else {
		save_ref_zqcs_int = lmc_config.cn63xx.ref_zqcs_int;
		/* set smallest interval */
		lmc_config.cn63xx.ref_zqcs_int = 1 | (32 << 7);
	}
	lmc_wr(priv, CVMX_LMCX_CONFIG(if_num), lmc_config.u64);
	lmc_rd(priv, CVMX_LMCX_CONFIG(if_num));

	/*
	 * Compute an appropriate delay based on the current ZQCS
	 * interval. The delay should be long enough for the
	 * current ZQCS delay counter to expire plus ten of the
	 * minimum intarvals to ensure that some calibrations
	 * occur.
	 */
	temp_delay_usecs = (((u64)save_ref_zqcs_int >> 7) * tclk_psecs *
			    100 * 512 * 128) / (10000 * 10000) + 10 *
		((u64)32 * tclk_psecs * 100 * 512 * 128) / (10000 * 10000);

	debug("Waiting %lld usecs for ZQCS calibrations to start\n",
	      temp_delay_usecs);
	udelay(temp_delay_usecs);

	if (octeon_is_cpuid(OCTEON_CN7XXX)) {
		/* Restore computed interval */
		lmc_config.cn78xx.ref_zqcs_int = save_ref_zqcs_int;
	} else {
		/* Restore computed interval */
		lmc_config.cn63xx.ref_zqcs_int = save_ref_zqcs_int;
	}

	lmc_wr(priv, CVMX_LMCX_CONFIG(if_num), lmc_config.u64);
	lmc_rd(priv, CVMX_LMCX_CONFIG(if_num));
}

static union cvmx_lmcx_wlevel_ctl wl_ctl __section(".data");
static union cvmx_lmcx_wlevel_rankx wl_rank __section(".data");
static union cvmx_lmcx_modereg_params1 mp1 __section(".data");

static int wl_mask[9] __section(".data");
static int byte_idx __section(".data");
static int ecc_ena __section(".data");
static int wl_roundup __section(".data");
static int save_mode32b __section(".data");
static int disable_hwl_validity __section(".data");
static int default_wl_rtt_nom __section(".data");
static int wl_pbm_pump __section(".data");

static void lmc_write_leveling_loop(struct ddr_priv *priv, int rankx)
{
	int wloop = 0;
	// retries per sample for HW-related issues with bitmasks or values
	int wloop_retries = 0;
	int wloop_retries_total = 0;
	int wloop_retries_exhausted = 0;
#define WLOOP_RETRIES_DEFAULT 5
	int wl_val_err;
	int wl_mask_err_rank = 0;
	int wl_val_err_rank = 0;
	// array to collect counts of byte-lane values
	// assume low-order 3 bits and even, so really only 2-bit values
	struct wlevel_bitcnt wl_bytes[9], wl_bytes_extra[9];
	int extra_bumps, extra_mask;
	int rank_nom = 0;

	if (!(rank_mask & (1 << rankx)))
		return;

	if (match_wl_rtt_nom) {
		if (rankx == 0)
			rank_nom = mp1.s.rtt_nom_00;
		if (rankx == 1)
			rank_nom = mp1.s.rtt_nom_01;
		if (rankx == 2)
			rank_nom = mp1.s.rtt_nom_10;
		if (rankx == 3)
			rank_nom = mp1.s.rtt_nom_11;

		debug("N%d.LMC%d.R%d: Setting WLEVEL_CTL[rtt_nom] to %d (%d)\n",
		      node, if_num, rankx, rank_nom,
		      imp_val->rtt_nom_ohms[rank_nom]);
	}

	memset(wl_bytes, 0, sizeof(wl_bytes));
	memset(wl_bytes_extra, 0, sizeof(wl_bytes_extra));

	// restructure the looping so we can keep trying until we get the
	// samples we want
	while (wloop < wl_loops) {
		wl_ctl.u64 = lmc_rd(priv, CVMX_LMCX_WLEVEL_CTL(if_num));

		wl_ctl.cn78xx.rtt_nom =
		    (default_wl_rtt_nom > 0) ? (default_wl_rtt_nom - 1) : 7;

		if (match_wl_rtt_nom) {
			wl_ctl.cn78xx.rtt_nom =
			    (rank_nom > 0) ? (rank_nom - 1) : 7;
		}

		/* Clear write-level delays */
		lmc_wr(priv, CVMX_LMCX_WLEVEL_RANKX(rankx, if_num), 0);

		wl_mask_err = 0;	/* Reset error counters */
		wl_val_err = 0;

		for (byte_idx = 0; byte_idx < 9; ++byte_idx)
			wl_mask[byte_idx] = 0;	/* Reset bitmasks */

		// do all the byte-lanes at the same time
		wl_ctl.cn78xx.lanemask = 0x1ff;

		lmc_wr(priv, CVMX_LMCX_WLEVEL_CTL(if_num), wl_ctl.u64);

		/*
		 * Read and write values back in order to update the
		 * status field. This insures that we read the updated
		 * values after write-leveling has completed.
		 */
		lmc_wr(priv, CVMX_LMCX_WLEVEL_RANKX(rankx, if_num),
		       lmc_rd(priv, CVMX_LMCX_WLEVEL_RANKX(rankx, if_num)));

		/* write-leveling */
		oct3_ddr3_seq(priv, 1 << rankx, if_num, 6);

		do {
			wl_rank.u64 = lmc_rd(priv,
					     CVMX_LMCX_WLEVEL_RANKX(rankx,
								    if_num));
		} while (wl_rank.cn78xx.status != 3);

		wl_rank.u64 = lmc_rd(priv, CVMX_LMCX_WLEVEL_RANKX(rankx,
								  if_num));

		for (byte_idx = 0; byte_idx < (8 + ecc_ena); ++byte_idx) {
			wl_mask[byte_idx] = lmc_ddr3_wl_dbg_read(priv,
								 if_num,
								 byte_idx);
			if (wl_mask[byte_idx] == 0)
				++wl_mask_err;
		}

		// check validity only if no bitmask errors
		if (wl_mask_err == 0) {
			if ((spd_dimm_type == 1 || spd_dimm_type == 2) &&
			    dram_width != 16 && if_64b &&
			    !disable_hwl_validity) {
				// bypass if [mini|SO]-[RU]DIMM or x16 or
				// 32-bit
				wl_val_err =
				    validate_hw_wl_settings(if_num,
							    &wl_rank,
							    spd_rdimm, ecc_ena);
				wl_val_err_rank += (wl_val_err != 0);
			}
		} else {
			wl_mask_err_rank++;
		}

		// before we print, if we had bitmask or validity errors,
		// do a retry...
		if (wl_mask_err != 0 || wl_val_err != 0) {
			if (wloop_retries < WLOOP_RETRIES_DEFAULT) {
				wloop_retries++;
				wloop_retries_total++;
				// this printout is per-retry: only when VBL
				// is high enough (DEV?)
				// FIXME: do we want to show the bad bitmaps
				// or delays here also?
				debug("N%d.LMC%d.R%d: H/W Write-Leveling had %s errors - retrying...\n",
				      node, if_num, rankx,
				      (wl_mask_err) ? "Bitmask" : "Validity");
				// this takes us back to the top without
				// counting a sample
				return;
			}

			// retries exhausted, do not print at normal VBL
			debug("N%d.LMC%d.R%d: H/W Write-Leveling issues: %s errors\n",
			      node, if_num, rankx,
			      (wl_mask_err) ? "Bitmask" : "Validity");
			wloop_retries_exhausted++;
		}
		// no errors or exhausted retries, use this sample
		wloop_retries = 0;	//reset for next sample

		// when only 1 sample or forced, print the bitmasks then
		// current HW WL
		if (wl_loops == 1 || wl_print) {
			if (wl_print > 1)
				display_wl_bm(if_num, rankx, wl_mask);
			display_wl(if_num, wl_rank, rankx);
		}

		if (wl_roundup) {	/* Round up odd bitmask delays */
			for (byte_idx = 0; byte_idx < (8 + ecc_ena);
			     ++byte_idx) {
				if (!(if_bytemask & (1 << byte_idx)))
					return;
				upd_wl_rank(&wl_rank, byte_idx,
					    roundup_ddr3_wlevel_bitmask
					    (wl_mask[byte_idx]));
			}
			lmc_wr(priv, CVMX_LMCX_WLEVEL_RANKX(rankx, if_num),
			       wl_rank.u64);
			display_wl(if_num, wl_rank, rankx);
		}

		// OK, we have a decent sample, no bitmask or validity errors
		extra_bumps = 0;
		extra_mask = 0;
		for (byte_idx = 0; byte_idx < (8 + ecc_ena); ++byte_idx) {
			int ix;

			if (!(if_bytemask & (1 << byte_idx)))
				return;

			// increment count of byte-lane value
			// only 4 values
			ix = (get_wl_rank(&wl_rank, byte_idx) >> 1) & 3;
			wl_bytes[byte_idx].bitcnt[ix]++;
			wl_bytes_extra[byte_idx].bitcnt[ix]++;
			// if perfect...
			if (__builtin_popcount(wl_mask[byte_idx]) == 4) {
				wl_bytes_extra[byte_idx].bitcnt[ix] +=
				    wl_pbm_pump;
				extra_bumps++;
				extra_mask |= 1 << byte_idx;
			}
		}

		if (extra_bumps) {
			if (wl_print > 1) {
				debug("N%d.LMC%d.R%d: HWL sample had %d bumps (0x%02x).\n",
				      node, if_num, rankx, extra_bumps,
				      extra_mask);
			}
		}

		// if we get here, we have taken a decent sample
		wloop++;

	}			/* while (wloop < wl_loops) */

	// if we did sample more than once, try to pick a majority vote
	if (wl_loops > 1) {
		// look for the majority in each byte-lane
		for (byte_idx = 0; byte_idx < (8 + ecc_ena); ++byte_idx) {
			int mx, mc, xc, cc;
			int ix, alts;
			int maj, xmaj, xmx, xmc, xxc, xcc;

			if (!(if_bytemask & (1 << byte_idx)))
				return;
			maj = find_wl_majority(&wl_bytes[byte_idx], &mx,
					       &mc, &xc, &cc);
			xmaj = find_wl_majority(&wl_bytes_extra[byte_idx],
						&xmx, &xmc, &xxc, &xcc);
			if (maj != xmaj) {
				if (wl_print) {
					debug("N%d.LMC%d.R%d: Byte %d: HWL maj %d(%d), USING xmaj %d(%d)\n",
					      node, if_num, rankx,
					      byte_idx, maj, xc, xmaj, xxc);
				}
				mx = xmx;
				mc = xmc;
				xc = xxc;
				cc = xcc;
			}

			// see if there was an alternate
			// take out the majority choice
			alts = (mc & ~(1 << mx));
			if (alts != 0) {
				for (ix = 0; ix < 4; ix++) {
					// FIXME: could be done multiple times?
					// bad if so
					if (alts & (1 << ix)) {
						// set the mask
						hwl_alts[rankx].hwl_alt_mask |=
							(1 << byte_idx);
						// record the value
						hwl_alts[rankx].hwl_alt_delay[byte_idx] =
							ix << 1;
						if (wl_print > 1) {
							debug("N%d.LMC%d.R%d: SWL_TRY_HWL_ALT: Byte %d maj %d (%d) alt %d (%d).\n",
							      node,
							      if_num,
							      rankx,
							      byte_idx,
							      mx << 1,
							      xc,
							      ix << 1,
							      wl_bytes
							      [byte_idx].bitcnt
							      [ix]);
						}
					}
				}
			}

			if (cc > 2) {	// unlikely, but...
				// assume: counts for 3 indices are all 1
				// possiblities are: 0/2/4, 2/4/6, 0/4/6, 0/2/6
				// and the desired?:   2  ,   4  ,     6, 0
				// we choose the middle, assuming one of the
				// outliers is bad
				// NOTE: this is an ugly hack at the moment;
				// there must be a better way
				switch (mc) {
				case 0x7:
					mx = 1;
					break;	// was 0/2/4, choose 2
				case 0xb:
					mx = 0;
					break;	// was 0/2/6, choose 0
				case 0xd:
					mx = 3;
					break;	// was 0/4/6, choose 6
				case 0xe:
					mx = 2;
					break;	// was 2/4/6, choose 4
				default:
				case 0xf:
					mx = 1;
					break;	// was 0/2/4/6, choose 2?
				}
				printf("N%d.LMC%d.R%d: HW WL MAJORITY: bad byte-lane %d (0x%x), using %d.\n",
				       node, if_num, rankx, byte_idx, mc,
				       mx << 1);
			}
			upd_wl_rank(&wl_rank, byte_idx, mx << 1);
		}

		lmc_wr(priv, CVMX_LMCX_WLEVEL_RANKX(rankx, if_num),
		       wl_rank.u64);
		display_wl_with_final(if_num, wl_rank, rankx);

		// FIXME: does this help make the output a little easier
		// to focus?
		if (wl_print > 0)
			debug("-----------\n");

	}			/* if (wl_loops > 1) */

	// maybe print an error summary for the rank
	if (wl_mask_err_rank != 0 || wl_val_err_rank != 0) {
		debug("N%d.LMC%d.R%d: H/W Write-Leveling errors - %d bitmask, %d validity, %d retries, %d exhausted\n",
		      node, if_num, rankx, wl_mask_err_rank,
		      wl_val_err_rank, wloop_retries_total,
		      wloop_retries_exhausted);
	}
}

static void lmc_write_leveling(struct ddr_priv *priv)
{
	union cvmx_lmcx_config cfg;
	int rankx;
	char *s;

	/*
	 * 4.8.9 LMC Write Leveling
	 *
	 * LMC supports an automatic write leveling like that described in the
	 * JEDEC DDR3 specifications separately per byte-lane.
	 *
	 * All of DDR PLL, LMC CK, LMC DRESET, and early LMC initializations
	 * must be completed prior to starting this LMC write-leveling sequence.
	 *
	 * There are many possible procedures that will write-level all the
	 * attached DDR3 DRAM parts. One possibility is for software to simply
	 * write the desired values into LMC(0)_WLEVEL_RANK(0..3). This section
	 * describes one possible sequence that uses LMC's autowrite-leveling
	 * capabilities.
	 *
	 * 1. If the DQS/DQ delays on the board may be more than the ADD/CMD
	 *    delays, then ensure that LMC(0)_CONFIG[EARLY_DQX] is set at this
	 *    point.
	 *
	 * Do the remaining steps 2-7 separately for each rank i with attached
	 * DRAM.
	 *
	 * 2. Write LMC(0)_WLEVEL_RANKi = 0.
	 *
	 * 3. For x8 parts:
	 *
	 *    Without changing any other fields in LMC(0)_WLEVEL_CTL, write
	 *    LMC(0)_WLEVEL_CTL[LANEMASK] to select all byte lanes with attached
	 *    DRAM.
	 *
	 *    For x16 parts:
	 *
	 *    Without changing any other fields in LMC(0)_WLEVEL_CTL, write
	 *    LMC(0)_WLEVEL_CTL[LANEMASK] to select all even byte lanes with
	 *    attached DRAM.
	 *
	 * 4. Without changing any other fields in LMC(0)_CONFIG,
	 *
	 *    o write LMC(0)_SEQ_CTL[SEQ_SEL] to select write-leveling
	 *
	 *    o write LMC(0)_CONFIG[RANKMASK] = (1 << i)
	 *
	 *    o write LMC(0)_SEQ_CTL[INIT_START] = 1
	 *
	 *    LMC will initiate write-leveling at this point. Assuming
	 *    LMC(0)_WLEVEL_CTL [SSET] = 0, LMC first enables write-leveling on
	 *    the selected DRAM rank via a DDR3 MR1 write, then sequences
	 *    through
	 *    and accumulates write-leveling results for eight different delay
	 *    settings twice, starting at a delay of zero in this case since
	 *    LMC(0)_WLEVEL_RANKi[BYTE*<4:3>] = 0, increasing by 1/8 CK each
	 *    setting, covering a total distance of one CK, then disables the
	 *    write-leveling via another DDR3 MR1 write.
	 *
	 *    After the sequence through 16 delay settings is complete:
	 *
	 *    o LMC sets LMC(0)_WLEVEL_RANKi[STATUS] = 3
	 *
	 *    o LMC sets LMC(0)_WLEVEL_RANKi[BYTE*<2:0>] (for all ranks selected
	 *      by LMC(0)_WLEVEL_CTL[LANEMASK]) to indicate the first write
	 *      leveling result of 1 that followed result of 0 during the
	 *      sequence, except that the LMC always writes
	 *      LMC(0)_WLEVEL_RANKi[BYTE*<0>]=0.
	 *
	 *    o Software can read the eight write-leveling results from the
	 *      first pass through the delay settings by reading
	 *      LMC(0)_WLEVEL_DBG[BITMASK] (after writing
	 *      LMC(0)_WLEVEL_DBG[BYTE]). (LMC does not retain the writeleveling
	 *      results from the second pass through the eight delay
	 *      settings. They should often be identical to the
	 *      LMC(0)_WLEVEL_DBG[BITMASK] results, though.)
	 *
	 * 5. Wait until LMC(0)_WLEVEL_RANKi[STATUS] != 2.
	 *
	 *    LMC will have updated LMC(0)_WLEVEL_RANKi[BYTE*<2:0>] for all byte
	 *    lanes selected by LMC(0)_WLEVEL_CTL[LANEMASK] at this point.
	 *    LMC(0)_WLEVEL_RANKi[BYTE*<4:3>] will still be the value that
	 *    software wrote in substep 2 above, which is 0.
	 *
	 * 6. For x16 parts:
	 *
	 *    Without changing any other fields in LMC(0)_WLEVEL_CTL, write
	 *    LMC(0)_WLEVEL_CTL[LANEMASK] to select all odd byte lanes with
	 *    attached DRAM.
	 *
	 *    Repeat substeps 4 and 5 with this new LMC(0)_WLEVEL_CTL[LANEMASK]
	 *    setting. Skip to substep 7 if this has already been done.
	 *
	 *    For x8 parts:
	 *
	 *    Skip this substep. Go to substep 7.
	 *
	 * 7. Calculate LMC(0)_WLEVEL_RANKi[BYTE*<4:3>] settings for all byte
	 *    lanes on all ranks with attached DRAM.
	 *
	 *    At this point, all byte lanes on rank i with attached DRAM should
	 *    have been write-leveled, and LMC(0)_WLEVEL_RANKi[BYTE*<2:0>] has
	 *    the result for each byte lane.
	 *
	 *    But note that the DDR3 write-leveling sequence will only determine
	 *    the delay modulo the CK cycle time, and cannot determine how many
	 *    additional CK cycles of delay are present. Software must calculate
	 *    the number of CK cycles, or equivalently, the
	 *    LMC(0)_WLEVEL_RANKi[BYTE*<4:3>] settings.
	 *
	 *    This BYTE*<4:3> calculation is system/board specific.
	 *
	 * Many techniques can be used to calculate write-leveling BYTE*<4:3>
	 * values, including:
	 *
	 *    o Known values for some byte lanes.
	 *
	 *    o Relative values for some byte lanes relative to others.
	 *
	 *    For example, suppose lane X is likely to require a larger
	 *    write-leveling delay than lane Y. A BYTEX<2:0> value that is much
	 *    smaller than the BYTEY<2:0> value may then indicate that the
	 *    required lane X delay wrapped into the next CK, so BYTEX<4:3>
	 *    should be set to BYTEY<4:3>+1.
	 *
	 *    When ECC DRAM is not present (i.e. when DRAM is not attached to
	 *    the DDR_CBS_0_* and DDR_CB<7:0> chip signals, or the
	 *    DDR_DQS_<4>_* and DDR_DQ<35:32> chip signals), write
	 *    LMC(0)_WLEVEL_RANK*[BYTE8] = LMC(0)_WLEVEL_RANK*[BYTE0],
	 *    using the final calculated BYTE0 value.
	 *    Write LMC(0)_WLEVEL_RANK*[BYTE4] = LMC(0)_WLEVEL_RANK*[BYTE0],
	 *    using the final calculated BYTE0 value.
	 *
	 * 8. Initialize LMC(0)_WLEVEL_RANK* values for all unused ranks.
	 *
	 *    Let rank i be a rank with attached DRAM.
	 *
	 *    For all ranks j that do not have attached DRAM, set
	 *    LMC(0)_WLEVEL_RANKj = LMC(0)_WLEVEL_RANKi.
	 */

	rankx = 0;
	wl_roundup = 0;
	disable_hwl_validity = 0;

	// wl_pbm_pump: weight for write-leveling PBMs...
	// 0 causes original behavior
	// 1 allows a minority of 2 pbms to outscore a majority of 3 non-pbms
	// 4 would allow a minority of 1 pbm to outscore a majority of 4
	// non-pbms
	wl_pbm_pump = 4;	// FIXME: is 4 too much?

	if (wl_loops) {
		debug("N%d.LMC%d: Performing Hardware Write-Leveling\n", node,
		      if_num);
	} else {
		/* Force software write-leveling to run */
		wl_mask_err = 1;
		debug("N%d.LMC%d: Forcing software Write-Leveling\n", node,
		      if_num);
	}

	default_wl_rtt_nom = (ddr_type == DDR3_DRAM) ?
		rttnom_20ohm : ddr4_rttnom_40ohm;

	cfg.u64 = lmc_rd(priv, CVMX_LMCX_CONFIG(if_num));
	ecc_ena = cfg.s.ecc_ena;
	save_mode32b = cfg.cn78xx.mode32b;
	cfg.cn78xx.mode32b = (!if_64b);
	lmc_wr(priv, CVMX_LMCX_CONFIG(if_num), cfg.u64);
	debug("%-45s : %d\n", "MODE32B", cfg.cn78xx.mode32b);

	s = lookup_env(priv, "ddr_wlevel_roundup");
	if (s)
		wl_roundup = simple_strtoul(s, NULL, 0);

	s = lookup_env(priv, "ddr_wlevel_printall");
	if (s)
		wl_print = strtoul(s, NULL, 0);

	s = lookup_env(priv, "ddr_wlevel_pbm_bump");
	if (s)
		wl_pbm_pump = strtoul(s, NULL, 0);

	// default to disable when RL sequential delay check is disabled
	disable_hwl_validity = disable_sequential_delay_check;
	s = lookup_env(priv, "ddr_disable_hwl_validity");
	if (s)
		disable_hwl_validity = !!strtoul(s, NULL, 0);

	s = lookup_env(priv, "ddr_wl_rtt_nom");
	if (s)
		default_wl_rtt_nom = simple_strtoul(s, NULL, 0);

	s = lookup_env(priv, "ddr_match_wl_rtt_nom");
	if (s)
		match_wl_rtt_nom = !!simple_strtoul(s, NULL, 0);

	if (match_wl_rtt_nom)
		mp1.u64 = lmc_rd(priv, CVMX_LMCX_MODEREG_PARAMS1(if_num));

	// For DDR3, we do not touch WLEVEL_CTL fields OR_DIS or BITMASK
	// For DDR4, we touch WLEVEL_CTL fields OR_DIS or BITMASK here
	if (ddr_type == DDR4_DRAM) {
		int default_or_dis = 1;
		int default_bitmask = 0xff;

		// when x4, use only the lower nibble
		if (dram_width == 4) {
			default_bitmask = 0x0f;
			if (wl_print) {
				debug("N%d.LMC%d: WLEVEL_CTL: default bitmask is 0x%02x for DDR4 x4\n",
				      node, if_num, default_bitmask);
			}
		}

		wl_ctl.u64 = lmc_rd(priv, CVMX_LMCX_WLEVEL_CTL(if_num));
		wl_ctl.s.or_dis = default_or_dis;
		wl_ctl.s.bitmask = default_bitmask;

		// allow overrides
		s = lookup_env(priv, "ddr_wlevel_ctl_or_dis");
		if (s)
			wl_ctl.s.or_dis = !!strtoul(s, NULL, 0);

		s = lookup_env(priv, "ddr_wlevel_ctl_bitmask");
		if (s)
			wl_ctl.s.bitmask = simple_strtoul(s, NULL, 0);

		// print only if not defaults
		if (wl_ctl.s.or_dis != default_or_dis ||
		    wl_ctl.s.bitmask != default_bitmask) {
			debug("N%d.LMC%d: WLEVEL_CTL: or_dis=%d, bitmask=0x%02x\n",
			      node, if_num, wl_ctl.s.or_dis, wl_ctl.s.bitmask);
		}

		// always write
		lmc_wr(priv, CVMX_LMCX_WLEVEL_CTL(if_num), wl_ctl.u64);
	}

	// Start the hardware write-leveling loop per rank
	for (rankx = 0; rankx < dimm_count * 4; rankx++)
		lmc_write_leveling_loop(priv, rankx);

	cfg.u64 = lmc_rd(priv, CVMX_LMCX_CONFIG(if_num));
	cfg.cn78xx.mode32b = save_mode32b;
	lmc_wr(priv, CVMX_LMCX_CONFIG(if_num), cfg.u64);
	debug("%-45s : %d\n", "MODE32B", cfg.cn78xx.mode32b);

	// At the end of HW Write Leveling, check on some DESKEW things...
	if (!disable_deskew_training) {
		struct deskew_counts dsk_counts;
		int retry_count = 0;

		debug("N%d.LMC%d: Check Deskew Settings before Read-Leveling.\n",
		      node, if_num);

		do {
			validate_deskew_training(priv, rank_mask, if_num,
						 &dsk_counts, 1);

			// only RAWCARD A or B will not benefit from
			// retraining if there's only saturation
			// or any rawcard if there is a nibble error
			if ((!spd_rawcard_aorb && dsk_counts.saturated > 0) ||
			    (dsk_counts.nibrng_errs != 0 ||
			     dsk_counts.nibunl_errs != 0)) {
				retry_count++;
				debug("N%d.LMC%d: Deskew Status indicates saturation or nibble errors - retry %d Training.\n",
				      node, if_num, retry_count);
				perform_deskew_training(priv, rank_mask, if_num,
							spd_rawcard_aorb);
			} else {
				break;
			}
		} while (retry_count < 5);
	}
}

static void lmc_workaround(struct ddr_priv *priv)
{
	/* Workaround Trcd overflow by using Additive latency. */
	if (octeon_is_cpuid(OCTEON_CN78XX_PASS1_X)) {
		union cvmx_lmcx_modereg_params0 mp0;
		union cvmx_lmcx_timing_params1 tp1;
		union cvmx_lmcx_control ctrl;
		int rankx;

		tp1.u64 = lmc_rd(priv, CVMX_LMCX_TIMING_PARAMS1(if_num));
		mp0.u64 = lmc_rd(priv, CVMX_LMCX_MODEREG_PARAMS0(if_num));
		ctrl.u64 = lmc_rd(priv, CVMX_LMCX_CONTROL(if_num));

		if (tp1.cn78xx.trcd == 0) {
			debug("Workaround Trcd overflow by using Additive latency.\n");
			/* Hard code this to 12 and enable additive latency */
			tp1.cn78xx.trcd = 12;
			mp0.s.al = 2;	/* CL-2 */
			ctrl.s.pocas = 1;

			debug("MODEREG_PARAMS0                               : 0x%016llx\n",
			      mp0.u64);
			lmc_wr(priv, CVMX_LMCX_MODEREG_PARAMS0(if_num),
			       mp0.u64);
			debug("TIMING_PARAMS1                                : 0x%016llx\n",
			      tp1.u64);
			lmc_wr(priv, CVMX_LMCX_TIMING_PARAMS1(if_num), tp1.u64);

			debug("LMC_CONTROL                                   : 0x%016llx\n",
			      ctrl.u64);
			lmc_wr(priv, CVMX_LMCX_CONTROL(if_num), ctrl.u64);

			for (rankx = 0; rankx < dimm_count * 4; rankx++) {
				if (!(rank_mask & (1 << rankx)))
					continue;

				/* MR1 */
				ddr4_mrw(priv, if_num, rankx, -1, 1, 0);
			}
		}
	}

	// this is here just for output, to allow check of the Deskew
	// settings one last time...
	if (!disable_deskew_training) {
		struct deskew_counts dsk_counts;

		debug("N%d.LMC%d: Check Deskew Settings before software Write-Leveling.\n",
		      node, if_num);
		validate_deskew_training(priv, rank_mask, if_num, &dsk_counts,
					 3);
	}

	/*
	 * Workaround Errata 26304 (T88@2.0, O75@1.x, O78@2.x)
	 *
	 * When the CSRs LMCX_DLL_CTL3[WR_DESKEW_ENA] = 1 AND
	 * LMCX_PHY_CTL2[DQS[0..8]_DSK_ADJ] > 4, set
	 * LMCX_EXT_CONFIG[DRIVE_ENA_BPRCH] = 1.
	 */
	if (octeon_is_cpuid(OCTEON_CN78XX_PASS2_X) ||
	    octeon_is_cpuid(OCTEON_CNF75XX_PASS1_X)) {
		union cvmx_lmcx_dll_ctl3 dll_ctl3;
		union cvmx_lmcx_phy_ctl2 phy_ctl2;
		union cvmx_lmcx_ext_config ext_cfg;
		int increased_dsk_adj = 0;
		int byte;

		phy_ctl2.u64 = lmc_rd(priv, CVMX_LMCX_PHY_CTL2(if_num));
		ext_cfg.u64 = lmc_rd(priv, CVMX_LMCX_EXT_CONFIG(if_num));
		dll_ctl3.u64 = lmc_rd(priv, CVMX_LMCX_DLL_CTL3(if_num));

		for (byte = 0; byte < 8; ++byte) {
			if (!(if_bytemask & (1 << byte)))
				continue;
			increased_dsk_adj |=
			    (((phy_ctl2.u64 >> (byte * 3)) & 0x7) > 4);
		}

		if (dll_ctl3.s.wr_deskew_ena == 1 && increased_dsk_adj) {
			ext_cfg.s.drive_ena_bprch = 1;
			lmc_wr(priv, CVMX_LMCX_EXT_CONFIG(if_num), ext_cfg.u64);
			debug("LMC%d: Forcing DRIVE_ENA_BPRCH for Workaround Errata 26304.\n",
			      if_num);
		}
	}
}

// Software Write-Leveling block

#define VREF_RANGE1_LIMIT 0x33	// range1 is valid for 0x00 - 0x32
#define VREF_RANGE2_LIMIT 0x18	// range2 is valid for 0x00 - 0x17
// full window is valid for 0x00 to 0x4A
// let 0x00 - 0x17 be range2, 0x18 - 0x4a be range 1
#define VREF_LIMIT        (VREF_RANGE1_LIMIT + VREF_RANGE2_LIMIT)
#define VREF_FINAL        (VREF_LIMIT - 1)

enum sw_wl_status {
	WL_ESTIMATED = 0, /* HW/SW wleveling failed. Reslt estimated */
	WL_HARDWARE = 1,	/* H/W wleveling succeeded */
	WL_SOFTWARE = 2, /* S/W wleveling passed 2 contiguous setting */
	WL_SOFTWARE1 = 3, /* S/W wleveling passed 1 marginal setting */
};

static u64 rank_addr __section(".data");
static int vref_val __section(".data");
static int final_vref_val __section(".data");
static int final_vref_range __section(".data");
static int start_vref_val __section(".data");
static int computed_final_vref_val __section(".data");
static char best_vref_val_count __section(".data");
static char vref_val_count __section(".data");
static char best_vref_val_start __section(".data");
static char vref_val_start __section(".data");
static int bytes_failed __section(".data");
static enum sw_wl_status byte_test_status[9] __section(".data");
static enum sw_wl_status sw_wl_rank_status __section(".data");
static int sw_wl_failed __section(".data");
static int sw_wl_hw __section(".data");
static int measured_vref_flag __section(".data");

static void ddr4_vref_loop(struct ddr_priv *priv, int rankx)
{
	char *s;

	if (vref_val < VREF_FINAL) {
		int vrange, vvalue;

		if (vref_val < VREF_RANGE2_LIMIT) {
			vrange = 1;
			vvalue = vref_val;
		} else {
			vrange = 0;
			vvalue = vref_val - VREF_RANGE2_LIMIT;
		}

		set_vref(priv, if_num, rankx, vrange, vvalue);
	} else {		/* if (vref_val < VREF_FINAL) */
		/* Print the final vref value first. */

		/* Always print the computed first if its valid */
		if (computed_final_vref_val >= 0) {
			debug("N%d.LMC%d.R%d: vref Computed Summary                 :              %2d (0x%02x)\n",
			      node, if_num, rankx,
			      computed_final_vref_val, computed_final_vref_val);
		}

		if (!measured_vref_flag) {	// setup to use the computed
			best_vref_val_count = 1;
			final_vref_val = computed_final_vref_val;
		} else {	// setup to use the measured
			if (best_vref_val_count > 0) {
				best_vref_val_count =
				    max(best_vref_val_count, (char)2);
				final_vref_val = best_vref_val_start +
					divide_nint(best_vref_val_count - 1, 2);

				if (final_vref_val < VREF_RANGE2_LIMIT) {
					final_vref_range = 1;
				} else {
					final_vref_range = 0;
					final_vref_val -= VREF_RANGE2_LIMIT;
				}

				int vvlo = best_vref_val_start;
				int vrlo;
				int vvhi = best_vref_val_start +
					best_vref_val_count - 1;
				int vrhi;

				if (vvlo < VREF_RANGE2_LIMIT) {
					vrlo = 2;
				} else {
					vrlo = 1;
					vvlo -= VREF_RANGE2_LIMIT;
				}

				if (vvhi < VREF_RANGE2_LIMIT) {
					vrhi = 2;
				} else {
					vrhi = 1;
					vvhi -= VREF_RANGE2_LIMIT;
				}
				debug("N%d.LMC%d.R%d: vref Training Summary                 :  0x%02x/%1d <----- 0x%02x/%1d -----> 0x%02x/%1d, range: %2d\n",
				      node, if_num, rankx, vvlo, vrlo,
				      final_vref_val,
				      final_vref_range + 1, vvhi, vrhi,
				      best_vref_val_count - 1);

			} else {
				/*
				 * If nothing passed use the default vref
				 * value for this rank
				 */
				union cvmx_lmcx_modereg_params2 mp2;

				mp2.u64 =
					lmc_rd(priv,
					       CVMX_LMCX_MODEREG_PARAMS2(if_num));
				final_vref_val = (mp2.u64 >>
						  (rankx * 10 + 3)) & 0x3f;
				final_vref_range = (mp2.u64 >>
						    (rankx * 10 + 9)) & 0x01;

				debug("N%d.LMC%d.R%d: vref Using Default                    :    %2d <----- %2d (0x%02x) -----> %2d, range%1d\n",
				      node, if_num, rankx, final_vref_val,
				      final_vref_val, final_vref_val,
				      final_vref_val, final_vref_range + 1);
			}
		}

		// allow override
		s = lookup_env(priv, "ddr%d_vref_val_%1d%1d",
			       if_num, !!(rankx & 2), !!(rankx & 1));
		if (s)
			final_vref_val = strtoul(s, NULL, 0);

		set_vref(priv, if_num, rankx, final_vref_range, final_vref_val);
	}
}

#define WL_MIN_NO_ERRORS_COUNT 3	// FIXME? three passes without errors

static int errors __section(".data");
static int byte_delay[9] __section(".data");
static u64 bytemask __section(".data");
static int bytes_todo __section(".data");
static int no_errors_count __section(".data");
static u64 bad_bits[2] __section(".data");
static u64 sum_dram_dclk __section(".data");
static u64 sum_dram_ops __section(".data");
static u64 start_dram_dclk __section(".data");
static u64 stop_dram_dclk __section(".data");
static u64 start_dram_ops __section(".data");
static u64 stop_dram_ops __section(".data");

static void lmc_sw_write_leveling_loop(struct ddr_priv *priv, int rankx)
{
	int delay;
	int b;

	// write the current set of WL delays
	lmc_wr(priv, CVMX_LMCX_WLEVEL_RANKX(rankx, if_num), wl_rank.u64);
	wl_rank.u64 = lmc_rd(priv, CVMX_LMCX_WLEVEL_RANKX(rankx, if_num));

	// do the test
	if (sw_wl_hw) {
		errors = run_best_hw_patterns(priv, if_num, rank_addr,
					      DBTRAIN_TEST, bad_bits);
		errors &= bytes_todo;	// keep only the ones we are still doing
	} else {
		start_dram_dclk = lmc_rd(priv, CVMX_LMCX_DCLK_CNT(if_num));
		start_dram_ops = lmc_rd(priv, CVMX_LMCX_OPS_CNT(if_num));
		errors = test_dram_byte64(priv, if_num, rank_addr, bytemask,
					  bad_bits);

		stop_dram_dclk = lmc_rd(priv, CVMX_LMCX_DCLK_CNT(if_num));
		stop_dram_ops = lmc_rd(priv, CVMX_LMCX_OPS_CNT(if_num));
		sum_dram_dclk += stop_dram_dclk - start_dram_dclk;
		sum_dram_ops += stop_dram_ops - start_dram_ops;
	}

	debug("WL pass1: test_dram_byte returned 0x%x\n", errors);

	// remember, errors will not be returned for byte-lanes that have
	// maxxed out...
	if (errors == 0) {
		no_errors_count++;	// bump
		// bypass check/update completely
		if (no_errors_count > 1)
			return;	// to end of do-while
	} else {
		no_errors_count = 0;	// reset
	}

	// check errors by byte
	for (b = 0; b < 9; ++b) {
		if (!(bytes_todo & (1 << b)))
			continue;

		delay = byte_delay[b];
		// yes, an error in this byte lane
		if (errors & (1 << b)) {
			debug("        byte %d delay %2d Errors\n", b, delay);
			// since this byte had an error, we move to the next
			// delay value, unless done with it
			delay += 8;	// incr by 8 to do delay high-order bits
			if (delay < 32) {
				upd_wl_rank(&wl_rank, b, delay);
				debug("        byte %d delay %2d New\n",
				      b, delay);
				byte_delay[b] = delay;
			} else {
				// reached max delay, maybe really done with
				// this byte
				// consider an alt only for computed VREF and
				if (!measured_vref_flag &&
				    (hwl_alts[rankx].hwl_alt_mask & (1 << b))) {
					// if an alt exists...
					// just orig low-3 bits
					int bad_delay = delay & 0x6;

					// yes, use it
					delay =	hwl_alts[rankx].hwl_alt_delay[b];
					// clear that flag
					hwl_alts[rankx].hwl_alt_mask &=
						~(1 << b);
					upd_wl_rank(&wl_rank, b, delay);
					byte_delay[b] = delay;
					debug("        byte %d delay %2d ALTERNATE\n",
					      b, delay);
					debug("N%d.LMC%d.R%d: SWL: Byte %d: %d FAIL, trying ALTERNATE %d\n",
					      node, if_num,
					      rankx, b, bad_delay, delay);

				} else {
					unsigned int bits_bad;

					if (b < 8) {
						// test no longer, remove from
						// byte mask
						bytemask &=
							~(0xffULL << (8 * b));
						bits_bad = (unsigned int)
							((bad_bits[0] >>
							  (8 * b)) & 0xffUL);
					} else {
						bits_bad = (unsigned int)
						    (bad_bits[1] & 0xffUL);
					}

					// remove from bytes to do
					bytes_todo &= ~(1 << b);
					// make sure this is set for this case
					byte_test_status[b] = WL_ESTIMATED;
					debug("        byte %d delay %2d Exhausted\n",
					      b, delay);
					if (!measured_vref_flag) {
						// this is too noisy when doing
						// measured VREF
						debug("N%d.LMC%d.R%d: SWL: Byte %d (0x%02x): delay %d EXHAUSTED\n",
						      node, if_num, rankx,
						      b, bits_bad, delay);
					}
				}
			}
		} else {
			// no error, stay with current delay, but keep testing
			// it...
			debug("        byte %d delay %2d Passed\n", b, delay);
			byte_test_status[b] = WL_HARDWARE;	// change status
		}
	}			/* for (b = 0; b < 9; ++b) */
}

static void sw_write_lvl_use_ecc(struct ddr_priv *priv, int rankx)
{
	int save_byte8 = wl_rank.s.byte8;

	byte_test_status[8] = WL_HARDWARE;	/* H/W delay value */

	if (save_byte8 != wl_rank.s.byte3 &&
	    save_byte8 != wl_rank.s.byte4) {
		int test_byte8 = save_byte8;
		int test_byte8_error;
		int byte8_error = 0x1f;
		int adder;
		int avg_bytes = divide_nint(wl_rank.s.byte3 + wl_rank.s.byte4,
					    2);

		for (adder = 0; adder <= 32; adder += 8) {
			test_byte8_error = abs((adder + save_byte8) -
					       avg_bytes);
			if (test_byte8_error < byte8_error) {
				byte8_error = test_byte8_error;
				test_byte8 = save_byte8 + adder;
			}
		}

		// only do the check if we are not using measured VREF
		if (!measured_vref_flag) {
			/* Use only even settings, rounding down... */
			test_byte8 &= ~1;

			// do validity check on the calculated ECC delay value
			// this depends on the DIMM type
			if (spd_rdimm) {	// RDIMM
				// but not mini-RDIMM
				if (spd_dimm_type != 5) {
					// it can be > byte4, but should never
					// be > byte3
					if (test_byte8 > wl_rank.s.byte3) {
						/* say it is still estimated */
						byte_test_status[8] =
							WL_ESTIMATED;
					}
				}
			} else {	// UDIMM
				if (test_byte8 < wl_rank.s.byte3 ||
				    test_byte8 > wl_rank.s.byte4) {
					// should never be outside the
					// byte 3-4 range
					/* say it is still estimated */
					byte_test_status[8] = WL_ESTIMATED;
				}
			}
			/*
			 * Report whenever the calculation appears bad.
			 * This happens if some of the original values were off,
			 * or unexpected geometry from DIMM type, or custom
			 * circuitry (NIC225E, I am looking at you!).
			 * We will trust the calculated value, and depend on
			 * later testing to catch any instances when that
			 * value is truly bad.
			 */
			// ESTIMATED means there may be an issue
			if (byte_test_status[8] == WL_ESTIMATED) {
				debug("N%d.LMC%d.R%d: SWL: (%cDIMM): calculated ECC delay unexpected (%d/%d/%d)\n",
				      node, if_num, rankx,
				      (spd_rdimm ? 'R' : 'U'), wl_rank.s.byte4,
				      test_byte8, wl_rank.s.byte3);
				byte_test_status[8] = WL_HARDWARE;
			}
		}
		/* Use only even settings */
		wl_rank.s.byte8 = test_byte8 & ~1;
	}

	if (wl_rank.s.byte8 != save_byte8) {
		/* Change the status if s/w adjusted the delay */
		byte_test_status[8] = WL_SOFTWARE;	/* Estimated delay */
	}
}

static __maybe_unused void parallel_wl_block_delay(struct ddr_priv *priv,
						   int rankx)
{
	int errors;
	int byte_delay[8];
	int byte_passed[8];
	u64 bytemask;
	u64 bitmask;
	int wl_offset;
	int bytes_todo;
	int sw_wl_offset = 1;
	int delay;
	int b;

	for (b = 0; b < 8; ++b)
		byte_passed[b] = 0;

	bytes_todo = if_bytemask;

	for (wl_offset = sw_wl_offset; wl_offset >= 0; --wl_offset) {
		debug("Starting wl_offset for-loop: %d\n", wl_offset);

		bytemask = 0;

		for (b = 0; b < 8; ++b) {
			byte_delay[b] = 0;
			// this does not contain fully passed bytes
			if (!(bytes_todo & (1 << b)))
				continue;

			// reset across passes if not fully passed
			byte_passed[b] = 0;
			upd_wl_rank(&wl_rank, b, 0);	// all delays start at 0
			bitmask = ((!if_64b) && (b == 4)) ? 0x0f : 0xff;
			// set the bytes bits in the bytemask
			bytemask |= bitmask << (8 * b);
		}		/* for (b = 0; b < 8; ++b) */

		// start a pass if there is any byte lane to test
		while (bytemask != 0) {
			debug("Starting bytemask while-loop: 0x%llx\n",
			      bytemask);

			// write this set of WL delays
			lmc_wr(priv, CVMX_LMCX_WLEVEL_RANKX(rankx, if_num),
			       wl_rank.u64);
			wl_rank.u64 = lmc_rd(priv,
					     CVMX_LMCX_WLEVEL_RANKX(rankx,
								    if_num));

			// do the test
			if (sw_wl_hw) {
				errors = run_best_hw_patterns(priv, if_num,
							      rank_addr,
							      DBTRAIN_TEST,
							      NULL) & 0xff;
			} else {
				errors = test_dram_byte64(priv, if_num,
							  rank_addr, bytemask,
							  NULL);
			}

			debug("test_dram_byte returned 0x%x\n", errors);

			// check errors by byte
			for (b = 0; b < 8; ++b) {
				if (!(bytes_todo & (1 << b)))
					continue;

				delay = byte_delay[b];
				if (errors & (1 << b)) {	// yes, an error
					debug("        byte %d delay %2d Errors\n",
					      b, delay);
					byte_passed[b] = 0;
				} else {	// no error
					byte_passed[b] += 1;
					// Look for consecutive working settings
					if (byte_passed[b] == (1 + wl_offset)) {
						debug("        byte %d delay %2d FULLY Passed\n",
						      b, delay);
						if (wl_offset == 1) {
							byte_test_status[b] =
								WL_SOFTWARE;
						} else if (wl_offset == 0) {
							byte_test_status[b] =
								WL_SOFTWARE1;
						}

						// test no longer, remove
						// from byte mask this pass
						bytemask &= ~(0xffULL <<
							      (8 * b));
						// remove completely from
						// concern
						bytes_todo &= ~(1 << b);
						// on to the next byte, bypass
						// delay updating!!
						continue;
					} else {
						debug("        byte %d delay %2d Passed\n",
						      b, delay);
					}
				}

				// error or no, here we move to the next delay
				// value for this byte, unless done all delays
				// only a byte that has "fully passed" will
				// bypass around this,
				delay += 2;
				if (delay < 32) {
					upd_wl_rank(&wl_rank, b, delay);
					debug("        byte %d delay %2d New\n",
					      b, delay);
					byte_delay[b] = delay;
				} else {
					// reached max delay, done with this
					// byte
					debug("        byte %d delay %2d Exhausted\n",
					      b, delay);
					// test no longer, remove from byte
					// mask this pass
					bytemask &= ~(0xffULL << (8 * b));
				}
			}	/* for (b = 0; b < 8; ++b) */
			debug("End of for-loop: bytemask 0x%llx\n", bytemask);
		}		/* while (bytemask != 0) */
	}

	for (b = 0; b < 8; ++b) {
		// any bytes left in bytes_todo did not pass
		if (bytes_todo & (1 << b)) {
			union cvmx_lmcx_rlevel_rankx lmc_rlevel_rank;

			/*
			 * Last resort. Use Rlevel settings to estimate
			 * Wlevel if software write-leveling fails
			 */
			debug("Using RLEVEL as WLEVEL estimate for byte %d\n",
			      b);
			lmc_rlevel_rank.u64 =
				lmc_rd(priv, CVMX_LMCX_RLEVEL_RANKX(rankx,
								    if_num));
			rlevel_to_wlevel(&lmc_rlevel_rank, &wl_rank, b);
		}
	}			/* for (b = 0; b < 8; ++b) */
}

static int lmc_sw_write_leveling(struct ddr_priv *priv)
{
	/* Try to determine/optimize write-level delays experimentally. */
	union cvmx_lmcx_wlevel_rankx wl_rank_hw_res;
	union cvmx_lmcx_config cfg;
	int rankx;
	int byte;
	char *s;
	int i;

	int active_rank;
	int sw_wl_enable = 1;	/* FIX... Should be customizable. */
	int interfaces;

	static const char * const wl_status_strings[] = {
		"(e)",
		"   ",
		"   ",
		"(1)"
	};

	// FIXME: make HW-assist the default now?
	int sw_wl_hw_default = SW_WLEVEL_HW_DEFAULT;
	int dram_connection = c_cfg->dram_connection;

	s = lookup_env(priv, "ddr_sw_wlevel_hw");
	if (s)
		sw_wl_hw_default = !!strtoul(s, NULL, 0);
	if (!if_64b)		// must use SW algo if 32-bit mode
		sw_wl_hw_default = 0;

	// can never use hw-assist
	if (octeon_is_cpuid(OCTEON_CN78XX_PASS1_X))
		sw_wl_hw_default = 0;

	s = lookup_env(priv, "ddr_software_wlevel");
	if (s)
		sw_wl_enable = strtoul(s, NULL, 0);

	s = lookup_env(priv, "ddr%d_dram_connection", if_num);
	if (s)
		dram_connection = !!strtoul(s, NULL, 0);

	cvmx_rng_enable();

	/*
	 * Get the measured_vref setting from the config, check for an
	 * override...
	 */
	/* NOTE: measured_vref=1 (ON) means force use of MEASURED vref... */
	// NOTE: measured VREF can only be done for DDR4
	if (ddr_type == DDR4_DRAM) {
		measured_vref_flag = c_cfg->measured_vref;
		s = lookup_env(priv, "ddr_measured_vref");
		if (s)
			measured_vref_flag = !!strtoul(s, NULL, 0);
	} else {
		measured_vref_flag = 0;	// OFF for DDR3
	}

	/*
	 * Ensure disabled ECC for DRAM tests using the SW algo, else leave
	 * it untouched
	 */
	if (!sw_wl_hw_default) {
		cfg.u64 = lmc_rd(priv, CVMX_LMCX_CONFIG(if_num));
		cfg.cn78xx.ecc_ena = 0;
		lmc_wr(priv, CVMX_LMCX_CONFIG(if_num), cfg.u64);
	}

	/*
	 * We need to track absolute rank number, as well as how many
	 * active ranks we have.  Two single rank DIMMs show up as
	 * ranks 0 and 2, but only 2 ranks are active.
	 */
	active_rank = 0;

	interfaces = __builtin_popcount(if_mask);

	for (rankx = 0; rankx < dimm_count * 4; rankx++) {
		final_vref_range = 0;
		start_vref_val = 0;
		computed_final_vref_val = -1;
		sw_wl_rank_status = WL_HARDWARE;
		sw_wl_failed = 0;
		sw_wl_hw = sw_wl_hw_default;

		if (!sw_wl_enable)
			break;

		if (!(rank_mask & (1 << rankx)))
			continue;

		debug("N%d.LMC%d.R%d: Performing Software Write-Leveling %s\n",
		      node, if_num, rankx,
		      (sw_wl_hw) ? "with H/W assist" :
		      "with S/W algorithm");

		if (ddr_type == DDR4_DRAM && num_ranks != 4) {
			// always compute when we can...
			computed_final_vref_val =
			    compute_vref_val(priv, if_num, rankx, dimm_count,
					     num_ranks, imp_val,
					     is_stacked_die, dram_connection);

			// but only use it if allowed
			if (!measured_vref_flag) {
				// skip all the measured vref processing,
				// just the final setting
				start_vref_val = VREF_FINAL;
			}
		}

		/* Save off the h/w wl results */
		wl_rank_hw_res.u64 = lmc_rd(priv,
					    CVMX_LMCX_WLEVEL_RANKX(rankx,
								   if_num));

		vref_val_count = 0;
		vref_val_start = 0;
		best_vref_val_count = 0;
		best_vref_val_start = 0;

		/* Loop one extra time using the Final vref value. */
		for (vref_val = start_vref_val; vref_val < VREF_LIMIT;
		     ++vref_val) {
			if (ddr_type == DDR4_DRAM)
				ddr4_vref_loop(priv, rankx);

			/* Restore the saved value */
			wl_rank.u64 = wl_rank_hw_res.u64;

			for (byte = 0; byte < 9; ++byte)
				byte_test_status[byte] = WL_ESTIMATED;

			if (wl_mask_err == 0) {
				/*
				 * Determine address of DRAM to test for
				 * pass 1 of software write leveling.
				 */
				rank_addr = active_rank *
					(1ull << (pbank_lsb - bunk_enable +
						  (interfaces / 2)));

				/*
				 * Adjust address for boot bus hole in memory
				 * map.
				 */
				if (rank_addr > 0x10000000)
					rank_addr += 0x10000000;

				debug("N%d.LMC%d.R%d: Active Rank %d Address: 0x%llx\n",
				      node, if_num, rankx, active_rank,
				      rank_addr);

				// start parallel write-leveling block for
				// delay high-order bits
				errors = 0;
				no_errors_count = 0;
				sum_dram_dclk = 0;
				sum_dram_ops = 0;

				if (if_64b) {
					bytes_todo = (sw_wl_hw) ?
						if_bytemask : 0xFF;
					bytemask = ~0ULL;
				} else {
					// 32-bit, must be using SW algo,
					// only data bytes
					bytes_todo = 0x0f;
					bytemask = 0x00000000ffffffffULL;
				}

				for (byte = 0; byte < 9; ++byte) {
					if (!(bytes_todo & (1 << byte))) {
						byte_delay[byte] = 0;
					} else {
						byte_delay[byte] =
						    get_wl_rank(&wl_rank, byte);
					}
				}	/* for (byte = 0; byte < 9; ++byte) */

				do {
					lmc_sw_write_leveling_loop(priv, rankx);
				} while (no_errors_count <
					 WL_MIN_NO_ERRORS_COUNT);

				if (!sw_wl_hw) {
					u64 percent_x10;

					if (sum_dram_dclk == 0)
						sum_dram_dclk = 1;
					percent_x10 = sum_dram_ops * 1000 /
						sum_dram_dclk;
					debug("N%d.LMC%d.R%d: ops %llu, cycles %llu, used %llu.%llu%%\n",
					      node, if_num, rankx, sum_dram_ops,
					      sum_dram_dclk, percent_x10 / 10,
					      percent_x10 % 10);
				}
				if (errors) {
					debug("End WLEV_64 while loop: vref_val %d(0x%x), errors 0x%02x\n",
					      vref_val, vref_val, errors);
				}
				// end parallel write-leveling block for
				// delay high-order bits

				// if we used HW-assist, we did the ECC byte
				// when approp.
				if (sw_wl_hw) {
					if (wl_print) {
						debug("N%d.LMC%d.R%d: HW-assisted SWL - ECC estimate not needed.\n",
						      node, if_num, rankx);
					}
					goto no_ecc_estimate;
				}

				if ((if_bytemask & 0xff) == 0xff) {
					if (use_ecc) {
						sw_write_lvl_use_ecc(priv,
								     rankx);
					} else {
						/* H/W delay value */
						byte_test_status[8] =
							WL_HARDWARE;
						/* ECC is not used */
						wl_rank.s.byte8 =
							wl_rank.s.byte0;
					}
				} else {
					if (use_ecc) {
						/* Estimate the ECC byte dly */
						// add hi-order to b4
						wl_rank.s.byte4 |=
							(wl_rank.s.byte3 &
							 0x38);
						if ((wl_rank.s.byte4 & 0x06) <
						    (wl_rank.s.byte3 & 0x06)) {
							// must be next clock
							wl_rank.s.byte4 += 8;
						}
					} else {
						/* ECC is not used */
						wl_rank.s.byte4 =
							wl_rank.s.byte0;
					}

					/*
					 * Change the status if s/w adjusted
					 * the delay
					 */
					/* Estimated delay */
					byte_test_status[4] = WL_SOFTWARE;
				}	/* if ((if_bytemask & 0xff) == 0xff) */
			}	/* if (wl_mask_err == 0) */

no_ecc_estimate:

			bytes_failed = 0;
			for (byte = 0; byte < 9; ++byte) {
				/* Don't accumulate errors for untested bytes */
				if (!(if_bytemask & (1 << byte)))
					continue;
				bytes_failed +=
				    (byte_test_status[byte] == WL_ESTIMATED);
			}

			/* vref training loop is only used for DDR4  */
			if (ddr_type != DDR4_DRAM)
				break;

			if (bytes_failed == 0) {
				if (vref_val_count == 0)
					vref_val_start = vref_val;

				++vref_val_count;
				if (vref_val_count > best_vref_val_count) {
					best_vref_val_count = vref_val_count;
					best_vref_val_start = vref_val_start;
					debug("N%d.LMC%d.R%d: vref Training                    (%2d) :    0x%02x <----- ???? -----> 0x%02x\n",
					      node, if_num, rankx, vref_val,
					      best_vref_val_start,
					      best_vref_val_start +
					      best_vref_val_count - 1);
				}
			} else {
				vref_val_count = 0;
				debug("N%d.LMC%d.R%d: vref Training                    (%2d) :    failed\n",
				      node, if_num, rankx, vref_val);
			}
		}

		/*
		 * Determine address of DRAM to test for software write
		 * leveling.
		 */
		rank_addr = active_rank * (1ull << (pbank_lsb - bunk_enable +
						    (interfaces / 2)));
		/* Adjust address for boot bus hole in memory map. */
		if (rank_addr > 0x10000000)
			rank_addr += 0x10000000;

		debug("Rank Address: 0x%llx\n", rank_addr);

		if (bytes_failed) {
			// FIXME? the big hammer, did not even try SW WL pass2,
			// assume only chip reset will help
			debug("N%d.LMC%d.R%d: S/W write-leveling pass 1 failed\n",
			      node, if_num, rankx);
			sw_wl_failed = 1;
		} else {	/* if (bytes_failed) */
			// SW WL pass 1 was OK, write the settings
			lmc_wr(priv, CVMX_LMCX_WLEVEL_RANKX(rankx, if_num),
			       wl_rank.u64);
			wl_rank.u64 = lmc_rd(priv,
					     CVMX_LMCX_WLEVEL_RANKX(rankx,
								    if_num));

			// do validity check on the delay values by running
			// the test 1 more time...
			// FIXME: we really need to check the ECC byte setting
			// here as well, so we need to enable ECC for this test!
			// if there are any errors, claim SW WL failure
			u64 datamask = (if_64b) ? 0xffffffffffffffffULL :
				0x00000000ffffffffULL;
			int errors;

			// do the test
			if (sw_wl_hw) {
				errors = run_best_hw_patterns(priv, if_num,
							      rank_addr,
							      DBTRAIN_TEST,
							      NULL) & 0xff;
			} else {
				errors = test_dram_byte64(priv, if_num,
							  rank_addr, datamask,
							  NULL);
			}

			if (errors) {
				debug("N%d.LMC%d.R%d: Wlevel Rank Final Test errors 0x%03x\n",
				      node, if_num, rankx, errors);
				sw_wl_failed = 1;
			}
		}		/* if (bytes_failed) */

		// FIXME? dump the WL settings, so we get more of a clue
		// as to what happened where
		debug("N%d.LMC%d.R%d: Wlevel Rank %#4x, 0x%016llX  : %2d%3s %2d%3s %2d%3s %2d%3s %2d%3s %2d%3s %2d%3s %2d%3s %2d%3s %s\n",
		      node, if_num, rankx, wl_rank.s.status, wl_rank.u64,
		      wl_rank.s.byte8, wl_status_strings[byte_test_status[8]],
		      wl_rank.s.byte7, wl_status_strings[byte_test_status[7]],
		      wl_rank.s.byte6, wl_status_strings[byte_test_status[6]],
		      wl_rank.s.byte5, wl_status_strings[byte_test_status[5]],
		      wl_rank.s.byte4, wl_status_strings[byte_test_status[4]],
		      wl_rank.s.byte3, wl_status_strings[byte_test_status[3]],
		      wl_rank.s.byte2, wl_status_strings[byte_test_status[2]],
		      wl_rank.s.byte1, wl_status_strings[byte_test_status[1]],
		      wl_rank.s.byte0, wl_status_strings[byte_test_status[0]],
		      (sw_wl_rank_status == WL_HARDWARE) ? "" : "(s)");

		// finally, check for fatal conditions: either chip reset
		// right here, or return error flag
		if ((ddr_type == DDR4_DRAM && best_vref_val_count == 0) ||
		    sw_wl_failed) {
			if (!ddr_disable_chip_reset) {	// do chip RESET
				printf("N%d.LMC%d.R%d: INFO: Short memory test indicates a retry is needed. Resetting node...\n",
				       node, if_num, rankx);
				mdelay(500);
				do_reset(NULL, 0, 0, NULL);
			} else {
				// return error flag so LMC init can be retried.
				debug("N%d.LMC%d.R%d: INFO: Short memory test indicates a retry is needed. Restarting LMC init...\n",
				      node, if_num, rankx);
				return -EAGAIN;	// 0 indicates restart possible.
			}
		}
		active_rank++;
	}

	for (rankx = 0; rankx < dimm_count * 4; rankx++) {
		int parameter_set = 0;
		u64 value;

		if (!(rank_mask & (1 << rankx)))
			continue;

		wl_rank.u64 = lmc_rd(priv, CVMX_LMCX_WLEVEL_RANKX(rankx,
								  if_num));

		for (i = 0; i < 9; ++i) {
			s = lookup_env(priv, "ddr%d_wlevel_rank%d_byte%d",
				       if_num, rankx, i);
			if (s) {
				parameter_set |= 1;
				value = strtoul(s, NULL, 0);

				upd_wl_rank(&wl_rank, i, value);
			}
		}

		s = lookup_env_ull(priv, "ddr%d_wlevel_rank%d", if_num, rankx);
		if (s) {
			parameter_set |= 1;
			value = strtoull(s, NULL, 0);
			wl_rank.u64 = value;
		}

		if (parameter_set) {
			lmc_wr(priv, CVMX_LMCX_WLEVEL_RANKX(rankx, if_num),
			       wl_rank.u64);
			wl_rank.u64 =
			    lmc_rd(priv, CVMX_LMCX_WLEVEL_RANKX(rankx, if_num));
			display_wl(if_num, wl_rank, rankx);
		}
		// if there are unused entries to be filled
		if ((rank_mask & 0x0F) != 0x0F) {
			if (rankx < 3) {
				debug("N%d.LMC%d.R%d: checking for WLEVEL_RANK unused entries.\n",
				      node, if_num, rankx);

				// if rank 0, write ranks 1 and 2 here if empty
				if (rankx == 0) {
					// check that rank 1 is empty
					if (!(rank_mask & (1 << 1))) {
						debug("N%d.LMC%d.R%d: writing WLEVEL_RANK unused entry R%d.\n",
						      node, if_num, rankx, 1);
						lmc_wr(priv,
						       CVMX_LMCX_WLEVEL_RANKX(1,
								if_num),
						       wl_rank.u64);
					}

					// check that rank 2 is empty
					if (!(rank_mask & (1 << 2))) {
						debug("N%d.LMC%d.R%d: writing WLEVEL_RANK unused entry R%d.\n",
						      node, if_num, rankx, 2);
						lmc_wr(priv,
						       CVMX_LMCX_WLEVEL_RANKX(2,
								if_num),
						       wl_rank.u64);
					}
				}

				// if rank 0, 1 or 2, write rank 3 here if empty
				// check that rank 3 is empty
				if (!(rank_mask & (1 << 3))) {
					debug("N%d.LMC%d.R%d: writing WLEVEL_RANK unused entry R%d.\n",
					      node, if_num, rankx, 3);
					lmc_wr(priv,
					       CVMX_LMCX_WLEVEL_RANKX(3,
								      if_num),
					       wl_rank.u64);
				}
			}
		}
	}

	/* Enable 32-bit mode if required. */
	cfg.u64 = lmc_rd(priv, CVMX_LMCX_CONFIG(if_num));
	cfg.cn78xx.mode32b = (!if_64b);
	debug("%-45s : %d\n", "MODE32B", cfg.cn78xx.mode32b);

	/* Restore the ECC configuration */
	if (!sw_wl_hw_default)
		cfg.cn78xx.ecc_ena = use_ecc;

	lmc_wr(priv, CVMX_LMCX_CONFIG(if_num), cfg.u64);

	return 0;
}

static void lmc_dll(struct ddr_priv *priv)
{
	union cvmx_lmcx_dll_ctl3 ddr_dll_ctl3;
	int setting[9];
	int i;

	ddr_dll_ctl3.u64 = lmc_rd(priv, CVMX_LMCX_DLL_CTL3(if_num));

	for (i = 0; i < 9; ++i) {
		SET_DDR_DLL_CTL3(dll90_byte_sel, ENCODE_DLL90_BYTE_SEL(i));
		lmc_wr(priv, CVMX_LMCX_DLL_CTL3(if_num), ddr_dll_ctl3.u64);
		lmc_rd(priv, CVMX_LMCX_DLL_CTL3(if_num));
		ddr_dll_ctl3.u64 = lmc_rd(priv, CVMX_LMCX_DLL_CTL3(if_num));
		setting[i] = GET_DDR_DLL_CTL3(dll90_setting);
		debug("%d. LMC%d_DLL_CTL3[%d] = %016llx %d\n", i, if_num,
		      GET_DDR_DLL_CTL3(dll90_byte_sel), ddr_dll_ctl3.u64,
		      setting[i]);
	}

	debug("N%d.LMC%d: %-36s : %5d %5d %5d %5d %5d %5d %5d %5d %5d\n",
	      node, if_num, "DLL90 Setting 8:0",
	      setting[8], setting[7], setting[6], setting[5], setting[4],
	      setting[3], setting[2], setting[1], setting[0]);

	process_custom_dll_offsets(priv, if_num, "ddr_dll_write_offset",
				   c_cfg->dll_write_offset,
				   "ddr%d_dll_write_offset_byte%d", 1);
	process_custom_dll_offsets(priv, if_num, "ddr_dll_read_offset",
				   c_cfg->dll_read_offset,
				   "ddr%d_dll_read_offset_byte%d", 2);
}

#define SLOT_CTL_INCR(csr, chip, field, incr)				\
	csr.chip.field = (csr.chip.field < (64 - incr)) ?		\
		(csr.chip.field + incr) : 63

#define INCR(csr, chip, field, incr)                                    \
	csr.chip.field = (csr.chip.field < (64 - incr)) ?		\
		(csr.chip.field + incr) : 63

static void lmc_workaround_2(struct ddr_priv *priv)
{
	/* Workaround Errata 21063 */
	if (octeon_is_cpuid(OCTEON_CN78XX) ||
	    octeon_is_cpuid(OCTEON_CN70XX_PASS1_X)) {
		union cvmx_lmcx_slot_ctl0 slot_ctl0;
		union cvmx_lmcx_slot_ctl1 slot_ctl1;
		union cvmx_lmcx_slot_ctl2 slot_ctl2;
		union cvmx_lmcx_ext_config ext_cfg;

		slot_ctl0.u64 = lmc_rd(priv, CVMX_LMCX_SLOT_CTL0(if_num));
		slot_ctl1.u64 = lmc_rd(priv, CVMX_LMCX_SLOT_CTL1(if_num));
		slot_ctl2.u64 = lmc_rd(priv, CVMX_LMCX_SLOT_CTL2(if_num));

		ext_cfg.u64 = lmc_rd(priv, CVMX_LMCX_EXT_CONFIG(if_num));

		/* When ext_cfg.s.read_ena_bprch is set add 1 */
		if (ext_cfg.s.read_ena_bprch) {
			SLOT_CTL_INCR(slot_ctl0, cn78xx, r2w_init, 1);
			SLOT_CTL_INCR(slot_ctl0, cn78xx, r2w_l_init, 1);
			SLOT_CTL_INCR(slot_ctl1, cn78xx, r2w_xrank_init, 1);
			SLOT_CTL_INCR(slot_ctl2, cn78xx, r2w_xdimm_init, 1);
		}

		/* Always add 2 */
		SLOT_CTL_INCR(slot_ctl1, cn78xx, w2r_xrank_init, 2);
		SLOT_CTL_INCR(slot_ctl2, cn78xx, w2r_xdimm_init, 2);

		lmc_wr(priv, CVMX_LMCX_SLOT_CTL0(if_num), slot_ctl0.u64);
		lmc_wr(priv, CVMX_LMCX_SLOT_CTL1(if_num), slot_ctl1.u64);
		lmc_wr(priv, CVMX_LMCX_SLOT_CTL2(if_num), slot_ctl2.u64);
	}

	/* Workaround Errata 21216 */
	if (octeon_is_cpuid(OCTEON_CN78XX_PASS1_X) ||
	    octeon_is_cpuid(OCTEON_CN70XX_PASS1_X)) {
		union cvmx_lmcx_slot_ctl1 slot_ctl1;
		union cvmx_lmcx_slot_ctl2 slot_ctl2;

		slot_ctl1.u64 = lmc_rd(priv, CVMX_LMCX_SLOT_CTL1(if_num));
		slot_ctl1.cn78xx.w2w_xrank_init =
		    max(10, (int)slot_ctl1.cn78xx.w2w_xrank_init);
		lmc_wr(priv, CVMX_LMCX_SLOT_CTL1(if_num), slot_ctl1.u64);

		slot_ctl2.u64 = lmc_rd(priv, CVMX_LMCX_SLOT_CTL2(if_num));
		slot_ctl2.cn78xx.w2w_xdimm_init =
		    max(10, (int)slot_ctl2.cn78xx.w2w_xdimm_init);
		lmc_wr(priv, CVMX_LMCX_SLOT_CTL2(if_num), slot_ctl2.u64);
	}
}

static void lmc_final(struct ddr_priv *priv)
{
	/*
	 * 4.8.11 Final LMC Initialization
	 *
	 * Early LMC initialization, LMC write-leveling, and LMC read-leveling
	 * must be completed prior to starting this final LMC initialization.
	 *
	 * LMC hardware updates the LMC(0)_SLOT_CTL0, LMC(0)_SLOT_CTL1,
	 * LMC(0)_SLOT_CTL2 CSRs with minimum values based on the selected
	 * readleveling and write-leveling settings. Software should not write
	 * the final LMC(0)_SLOT_CTL0, LMC(0)_SLOT_CTL1, and LMC(0)_SLOT_CTL2
	 * values until after the final read-leveling and write-leveling
	 * settings are written.
	 *
	 * Software must ensure the LMC(0)_SLOT_CTL0, LMC(0)_SLOT_CTL1, and
	 * LMC(0)_SLOT_CTL2 CSR values are appropriate for this step. These CSRs
	 * select the minimum gaps between read operations and write operations
	 * of various types.
	 *
	 * Software must not reduce the values in these CSR fields below the
	 * values previously selected by the LMC hardware (during write-leveling
	 * and read-leveling steps above).
	 *
	 * All sections in this chapter may be used to derive proper settings
	 * for these registers.
	 *
	 * For minimal read latency, L2C_CTL[EF_ENA,EF_CNT] should be programmed
	 * properly. This should be done prior to the first read.
	 */

	/* Clear any residual ECC errors */
	int num_tads = 1;
	int tad;
	int num_mcis = 1;
	int mci;

	if (octeon_is_cpuid(OCTEON_CN78XX)) {
		num_tads = 8;
		num_mcis = 4;
	} else if (octeon_is_cpuid(OCTEON_CN70XX)) {
		num_tads = 1;
		num_mcis = 1;
	} else if (octeon_is_cpuid(OCTEON_CN73XX) ||
		   octeon_is_cpuid(OCTEON_CNF75XX)) {
		num_tads = 4;
		num_mcis = 3;
	}

	lmc_wr(priv, CVMX_LMCX_INT(if_num), -1ULL);
	lmc_rd(priv, CVMX_LMCX_INT(if_num));

	for (tad = 0; tad < num_tads; tad++) {
		l2c_wr(priv, CVMX_L2C_TADX_INT_REL(tad),
		       l2c_rd(priv, CVMX_L2C_TADX_INT_REL(tad)));
		debug("%-45s : (%d) 0x%08llx\n", "CVMX_L2C_TAD_INT", tad,
		      l2c_rd(priv, CVMX_L2C_TADX_INT_REL(tad)));
	}

	for (mci = 0; mci < num_mcis; mci++) {
		l2c_wr(priv, CVMX_L2C_MCIX_INT_REL(mci),
		       l2c_rd(priv, CVMX_L2C_MCIX_INT_REL(mci)));
		debug("%-45s : (%d) 0x%08llx\n", "L2C_MCI_INT", mci,
		      l2c_rd(priv, CVMX_L2C_MCIX_INT_REL(mci)));
	}

	debug("%-45s : 0x%08llx\n", "LMC_INT",
	      lmc_rd(priv, CVMX_LMCX_INT(if_num)));
}

static void lmc_scrambling(struct ddr_priv *priv)
{
	// Make sure scrambling is disabled during init...
	union cvmx_lmcx_control ctrl;
	union cvmx_lmcx_scramble_cfg0 lmc_scramble_cfg0;
	union cvmx_lmcx_scramble_cfg1 lmc_scramble_cfg1;
	union cvmx_lmcx_scramble_cfg2 lmc_scramble_cfg2;
	union cvmx_lmcx_ns_ctl lmc_ns_ctl;
	int use_scramble = 0;	// default OFF
	char *s;

	ctrl.u64 = lmc_rd(priv, CVMX_LMCX_CONTROL(if_num));
	lmc_scramble_cfg0.u64 = lmc_rd(priv, CVMX_LMCX_SCRAMBLE_CFG0(if_num));
	lmc_scramble_cfg1.u64 = lmc_rd(priv, CVMX_LMCX_SCRAMBLE_CFG1(if_num));
	lmc_scramble_cfg2.u64 = 0;	// quiet compiler
	if (!octeon_is_cpuid(OCTEON_CN78XX_PASS1_X)) {
		lmc_scramble_cfg2.u64 =
		    lmc_rd(priv, CVMX_LMCX_SCRAMBLE_CFG2(if_num));
	}
	lmc_ns_ctl.u64 = lmc_rd(priv, CVMX_LMCX_NS_CTL(if_num));

	s = lookup_env_ull(priv, "ddr_use_scramble");
	if (s)
		use_scramble = simple_strtoull(s, NULL, 0);

	/* Generate random values if scrambling is needed */
	if (use_scramble) {
		lmc_scramble_cfg0.u64 = cvmx_rng_get_random64();
		lmc_scramble_cfg1.u64 = cvmx_rng_get_random64();
		lmc_scramble_cfg2.u64 = cvmx_rng_get_random64();
		lmc_ns_ctl.s.ns_scramble_dis = 0;
		lmc_ns_ctl.s.adr_offset = 0;
		ctrl.s.scramble_ena = 1;
	}

	s = lookup_env_ull(priv, "ddr_scramble_cfg0");
	if (s) {
		lmc_scramble_cfg0.u64 = simple_strtoull(s, NULL, 0);
		ctrl.s.scramble_ena = 1;
	}
	debug("%-45s : 0x%016llx\n", "LMC_SCRAMBLE_CFG0",
	      lmc_scramble_cfg0.u64);

	lmc_wr(priv, CVMX_LMCX_SCRAMBLE_CFG0(if_num), lmc_scramble_cfg0.u64);

	s = lookup_env_ull(priv, "ddr_scramble_cfg1");
	if (s) {
		lmc_scramble_cfg1.u64 = simple_strtoull(s, NULL, 0);
		ctrl.s.scramble_ena = 1;
	}
	debug("%-45s : 0x%016llx\n", "LMC_SCRAMBLE_CFG1",
	      lmc_scramble_cfg1.u64);
	lmc_wr(priv, CVMX_LMCX_SCRAMBLE_CFG1(if_num), lmc_scramble_cfg1.u64);

	if (!octeon_is_cpuid(OCTEON_CN78XX_PASS1_X)) {
		s = lookup_env_ull(priv, "ddr_scramble_cfg2");
		if (s) {
			lmc_scramble_cfg2.u64 = simple_strtoull(s, NULL, 0);
			ctrl.s.scramble_ena = 1;
		}
		debug("%-45s : 0x%016llx\n", "LMC_SCRAMBLE_CFG2",
		      lmc_scramble_cfg1.u64);
		lmc_wr(priv, CVMX_LMCX_SCRAMBLE_CFG2(if_num),
		       lmc_scramble_cfg2.u64);
	}

	s = lookup_env_ull(priv, "ddr_ns_ctl");
	if (s)
		lmc_ns_ctl.u64 = simple_strtoull(s, NULL, 0);
	debug("%-45s : 0x%016llx\n", "LMC_NS_CTL", lmc_ns_ctl.u64);
	lmc_wr(priv, CVMX_LMCX_NS_CTL(if_num), lmc_ns_ctl.u64);

	lmc_wr(priv, CVMX_LMCX_CONTROL(if_num), ctrl.u64);
}

struct rl_score {
	u64 setting;
	int score;
};

static union cvmx_lmcx_rlevel_rankx rl_rank __section(".data");
static union cvmx_lmcx_rlevel_ctl rl_ctl __section(".data");
static unsigned char rodt_ctl __section(".data");

static int rl_rodt_err __section(".data");
static unsigned char rtt_nom __section(".data");
static unsigned char rtt_idx __section(".data");
static char min_rtt_nom_idx __section(".data");
static char max_rtt_nom_idx __section(".data");
static char min_rodt_ctl __section(".data");
static char max_rodt_ctl __section(".data");
static int rl_dbg_loops __section(".data");
static unsigned char save_ddr2t __section(".data");
static int rl_samples __section(".data");
static char rl_compute __section(".data");
static char saved_ddr__ptune __section(".data");
static char saved_ddr__ntune __section(".data");
static char rl_comp_offs __section(".data");
static char saved_int_zqcs_dis __section(".data");
static int max_adj_rl_del_inc __section(".data");
static int print_nom_ohms __section(".data");
static int rl_print __section(".data");

#ifdef ENABLE_HARDCODED_RLEVEL
static char part_number[21] __section(".data");
#endif /* ENABLE_HARDCODED_RLEVEL */

struct perfect_counts {
	u16 count[9][32]; // 8+ECC by 64 values
	u32 mask[9];      // 8+ECC, bitmask of perfect delays
};

static struct perfect_counts rank_perf[4] __section(".data");
static struct perfect_counts rodt_perfect_counts __section(".data");
static int pbm_lowsum_limit __section(".data");
// FIXME: PBM skip for RODT 240 and 34
static u32 pbm_rodt_skip __section(".data");

// control rank majority processing
static int disable_rank_majority __section(".data");

// default to mask 11b ODDs for DDR4 (except 73xx), else DISABLE
// for DDR3
static int enable_rldelay_bump __section(".data");
static int rldelay_bump_incr __section(".data");
static int disable_rlv_bump_this_byte __section(".data");
static u64 value_mask __section(".data");

static struct rlevel_byte_data rl_byte[9] __section(".data");
static int sample_loops __section(".data");
static int max_samples __section(".data");
static int rl_rank_errors __section(".data");
static int rl_mask_err __section(".data");
static int rl_nonseq_err __section(".data");
static struct rlevel_bitmask rl_mask[9] __section(".data");
static int rl_best_rank_score __section(".data");

static int rodt_row_skip_mask __section(".data");

static void rodt_loop(struct ddr_priv *priv, int rankx, struct rl_score
		      rl_score[RTT_NOM_OHMS_COUNT][RODT_OHMS_COUNT][4])
{
	union cvmx_lmcx_comp_ctl2 cc2;
	const int rl_separate_ab = 1;
	int i;

	rl_best_rank_score = DEFAULT_BEST_RANK_SCORE;
	rl_rodt_err = 0;
	cc2.u64 = lmc_rd(priv, CVMX_LMCX_COMP_CTL2(if_num));
	cc2.cn78xx.rodt_ctl = rodt_ctl;
	lmc_wr(priv, CVMX_LMCX_COMP_CTL2(if_num), cc2.u64);
	cc2.u64 = lmc_rd(priv, CVMX_LMCX_COMP_CTL2(if_num));
	udelay(1); /* Give it a little time to take affect */
	if (rl_print > 1) {
		debug("Read ODT_CTL                                  : 0x%x (%d ohms)\n",
		      cc2.cn78xx.rodt_ctl,
		      imp_val->rodt_ohms[cc2.cn78xx.rodt_ctl]);
	}

	memset(rl_byte, 0, sizeof(rl_byte));
	memset(&rodt_perfect_counts, 0, sizeof(rodt_perfect_counts));

	// when iter RODT is the target RODT, take more samples...
	max_samples = rl_samples;
	if (rodt_ctl == default_rodt_ctl)
		max_samples += rl_samples + 1;

	for (sample_loops = 0; sample_loops < max_samples; sample_loops++) {
		int redoing_nonseq_errs = 0;

		rl_mask_err = 0;

		if (!(rl_separate_ab && spd_rdimm &&
		      ddr_type == DDR4_DRAM)) {
			/* Clear read-level delays */
			lmc_wr(priv, CVMX_LMCX_RLEVEL_RANKX(rankx, if_num), 0);

			/* read-leveling */
			oct3_ddr3_seq(priv, 1 << rankx, if_num, 1);

			do {
				rl_rank.u64 =
					lmc_rd(priv,
					       CVMX_LMCX_RLEVEL_RANKX(rankx,
								      if_num));
			} while (rl_rank.cn78xx.status != 3);
		}

		rl_rank.u64 =
			lmc_rd(priv, CVMX_LMCX_RLEVEL_RANKX(rankx, if_num));

		// start bitmask interpretation block

		memset(rl_mask, 0, sizeof(rl_mask));

		if (rl_separate_ab && spd_rdimm && ddr_type == DDR4_DRAM) {
			union cvmx_lmcx_rlevel_rankx rl_rank_aside;
			union cvmx_lmcx_modereg_params0 mp0;

			/* A-side */
			mp0.u64 =
				lmc_rd(priv, CVMX_LMCX_MODEREG_PARAMS0(if_num));
			mp0.s.mprloc = 0; /* MPR Page 0 Location 0 */
			lmc_wr(priv,
			       CVMX_LMCX_MODEREG_PARAMS0(if_num),
			       mp0.u64);

			/* Clear read-level delays */
			lmc_wr(priv, CVMX_LMCX_RLEVEL_RANKX(rankx, if_num), 0);

			/* read-leveling */
			oct3_ddr3_seq(priv, 1 << rankx, if_num, 1);

			do {
				rl_rank.u64 =
					lmc_rd(priv,
					       CVMX_LMCX_RLEVEL_RANKX(rankx,
								      if_num));
			} while (rl_rank.cn78xx.status != 3);

			rl_rank.u64 =
				lmc_rd(priv, CVMX_LMCX_RLEVEL_RANKX(rankx,
								    if_num));

			rl_rank_aside.u64 = rl_rank.u64;

			rl_mask[0].bm = lmc_ddr3_rl_dbg_read(priv, if_num, 0);
			rl_mask[1].bm = lmc_ddr3_rl_dbg_read(priv, if_num, 1);
			rl_mask[2].bm = lmc_ddr3_rl_dbg_read(priv, if_num, 2);
			rl_mask[3].bm = lmc_ddr3_rl_dbg_read(priv, if_num, 3);
			rl_mask[8].bm = lmc_ddr3_rl_dbg_read(priv, if_num, 8);
			/* A-side complete */

			/* B-side */
			mp0.u64 =
				lmc_rd(priv, CVMX_LMCX_MODEREG_PARAMS0(if_num));
			mp0.s.mprloc = 3; /* MPR Page 0 Location 3 */
			lmc_wr(priv, CVMX_LMCX_MODEREG_PARAMS0(if_num),
			       mp0.u64);

			/* Clear read-level delays */
			lmc_wr(priv, CVMX_LMCX_RLEVEL_RANKX(rankx, if_num), 0);

			/* read-leveling */
			oct3_ddr3_seq(priv, 1 << rankx, if_num, 1);

			do {
				rl_rank.u64 =
					lmc_rd(priv,
					       CVMX_LMCX_RLEVEL_RANKX(rankx,
								      if_num));
			} while (rl_rank.cn78xx.status != 3);

			rl_rank.u64 =
				lmc_rd(priv, CVMX_LMCX_RLEVEL_RANKX(rankx,
								    if_num));

			rl_mask[4].bm = lmc_ddr3_rl_dbg_read(priv, if_num, 4);
			rl_mask[5].bm = lmc_ddr3_rl_dbg_read(priv, if_num, 5);
			rl_mask[6].bm = lmc_ddr3_rl_dbg_read(priv, if_num, 6);
			rl_mask[7].bm = lmc_ddr3_rl_dbg_read(priv, if_num, 7);
			/* B-side complete */

			upd_rl_rank(&rl_rank, 0, rl_rank_aside.s.byte0);
			upd_rl_rank(&rl_rank, 1, rl_rank_aside.s.byte1);
			upd_rl_rank(&rl_rank, 2, rl_rank_aside.s.byte2);
			upd_rl_rank(&rl_rank, 3, rl_rank_aside.s.byte3);
			/* ECC A-side */
			upd_rl_rank(&rl_rank, 8, rl_rank_aside.s.byte8);

			mp0.u64 =
				lmc_rd(priv, CVMX_LMCX_MODEREG_PARAMS0(if_num));
			mp0.s.mprloc = 0; /* MPR Page 0 Location 0 */
			lmc_wr(priv, CVMX_LMCX_MODEREG_PARAMS0(if_num),
			       mp0.u64);
		}

		/*
		 * Evaluate the quality of the read-leveling delays from the
		 * bitmasks. Also save off a software computed read-leveling
		 * mask that may be used later to qualify the delay results
		 * from Octeon.
		 */
		for (i = 0; i < (8 + ecc_ena); ++i) {
			int bmerr;

			if (!(if_bytemask & (1 << i)))
				continue;
			if (!(rl_separate_ab && spd_rdimm &&
			      ddr_type == DDR4_DRAM)) {
				rl_mask[i].bm =
					lmc_ddr3_rl_dbg_read(priv, if_num, i);
			}
			bmerr = validate_ddr3_rlevel_bitmask(&rl_mask[i],
							     ddr_type);
			rl_mask[i].errs = bmerr;
			rl_mask_err += bmerr;
			// count only the "perfect" bitmasks
			if (ddr_type == DDR4_DRAM && !bmerr) {
				int delay;
				// FIXME: for now, simple filtering:
				// do NOT count PBMs for RODTs in skip mask
				if ((1U << rodt_ctl) & pbm_rodt_skip)
					continue;
				// FIXME: could optimize this a bit?
				delay = get_rl_rank(&rl_rank, i);
				rank_perf[rankx].count[i][delay] += 1;
				rank_perf[rankx].mask[i] |=
					(1ULL << delay);
				rodt_perfect_counts.count[i][delay] += 1;
				rodt_perfect_counts.mask[i] |= (1ULL << delay);
			}
		}

		/* Set delays for unused bytes to match byte 0. */
		for (i = 0; i < 9; ++i) {
			if (if_bytemask & (1 << i))
				continue;
			upd_rl_rank(&rl_rank, i, rl_rank.s.byte0);
		}

		/*
		 * Save a copy of the byte delays in physical
		 * order for sequential evaluation.
		 */
		unpack_rlevel_settings(if_bytemask, ecc_ena, rl_byte, rl_rank);

	redo_nonseq_errs:

		rl_nonseq_err  = 0;
		if (!disable_sequential_delay_check) {
			for (i = 0; i < 9; ++i)
				rl_byte[i].sqerrs = 0;

			if ((if_bytemask & 0xff) == 0xff) {
				/*
				 * Evaluate delay sequence across the whole
				 * range of bytes for standard dimms.
				 */
				/* 1=RDIMM, 5=Mini-RDIMM */
				if (spd_dimm_type == 1 || spd_dimm_type == 5) {
					int reg_adj_del = abs(rl_byte[4].delay -
							      rl_byte[5].delay);

					/*
					 * Registered dimm topology routes
					 * from the center.
					 */
					rl_nonseq_err +=
						nonseq_del(rl_byte, 0,
							   3 + ecc_ena,
							   max_adj_rl_del_inc);
					rl_nonseq_err +=
						nonseq_del(rl_byte, 5,
							   7 + ecc_ena,
							   max_adj_rl_del_inc);
					// byte 5 sqerrs never gets cleared
					// for RDIMMs
					rl_byte[5].sqerrs = 0;
					if (reg_adj_del > 1) {
						/*
						 * Assess proximity of bytes on
						 * opposite sides of register
						 */
						rl_nonseq_err += (reg_adj_del -
								  1) *
							RLEVEL_ADJACENT_DELAY_ERROR;
						// update byte 5 error
						rl_byte[5].sqerrs +=
							(reg_adj_del - 1) *
							RLEVEL_ADJACENT_DELAY_ERROR;
					}
				}

				/* 2=UDIMM, 6=Mini-UDIMM */
				if (spd_dimm_type == 2 || spd_dimm_type == 6) {
					/*
					 * Unbuffered dimm topology routes
					 * from end to end.
					 */
					rl_nonseq_err += nonseq_del(rl_byte, 0,
								    7 + ecc_ena,
								    max_adj_rl_del_inc);
				}
			} else {
				rl_nonseq_err += nonseq_del(rl_byte, 0,
							    3 + ecc_ena,
							    max_adj_rl_del_inc);
			}
		} /* if (! disable_sequential_delay_check) */

		rl_rank_errors = rl_mask_err + rl_nonseq_err;

		// print original sample here only if we are not really
		// averaging or picking best
		// also do not print if we were redoing the NONSEQ score
		// for using COMPUTED
		if (!redoing_nonseq_errs && rl_samples < 2) {
			if (rl_print > 1) {
				display_rl_bm(if_num, rankx, rl_mask, ecc_ena);
				display_rl_bm_scores(if_num, rankx, rl_mask,
						     ecc_ena);
				display_rl_seq_scores(if_num, rankx, rl_byte,
						      ecc_ena);
			}
			display_rl_with_score(if_num, rl_rank, rankx,
					      rl_rank_errors);
		}

		if (rl_compute) {
			if (!redoing_nonseq_errs) {
				/* Recompute the delays based on the bitmask */
				for (i = 0; i < (8 + ecc_ena); ++i) {
					if (!(if_bytemask & (1 << i)))
						continue;

					upd_rl_rank(&rl_rank, i,
						    compute_ddr3_rlevel_delay(
							    rl_mask[i].mstart,
							    rl_mask[i].width,
							    rl_ctl));
				}

				/*
				 * Override the copy of byte delays with the
				 * computed results.
				 */
				unpack_rlevel_settings(if_bytemask, ecc_ena,
						       rl_byte, rl_rank);

				redoing_nonseq_errs = 1;
				goto redo_nonseq_errs;

			} else {
				/*
				 * now print this if already printed the
				 * original sample
				 */
				if (rl_samples < 2 || rl_print) {
					display_rl_with_computed(if_num,
								 rl_rank, rankx,
								 rl_rank_errors);
				}
			}
		} /* if (rl_compute) */

		// end bitmask interpretation block

		// if it is a better (lower) score, then  keep it
		if (rl_rank_errors < rl_best_rank_score) {
			rl_best_rank_score = rl_rank_errors;

			// save the new best delays and best errors
			for (i = 0; i < (8 + ecc_ena); ++i) {
				rl_byte[i].best = rl_byte[i].delay;
				rl_byte[i].bestsq = rl_byte[i].sqerrs;
				// save bitmasks and their scores as well
				// xlate UNPACKED index to PACKED index to
				// get from rl_mask
				rl_byte[i].bm = rl_mask[XUP(i, !!ecc_ena)].bm;
				rl_byte[i].bmerrs =
					rl_mask[XUP(i, !!ecc_ena)].errs;
			}
		}

		rl_rodt_err += rl_rank_errors;
	}

	/* We recorded the best score across the averaging loops */
	rl_score[rtt_nom][rodt_ctl][rankx].score = rl_best_rank_score;

	/*
	 * Restore the delays from the best fields that go with the best
	 * score
	 */
	for (i = 0; i < 9; ++i) {
		rl_byte[i].delay = rl_byte[i].best;
		rl_byte[i].sqerrs = rl_byte[i].bestsq;
	}

	rl_rank.u64 = lmc_rd(priv, CVMX_LMCX_RLEVEL_RANKX(rankx, if_num));

	pack_rlevel_settings(if_bytemask, ecc_ena, rl_byte, &rl_rank);

	if (rl_samples > 1) {
		// restore the "best" bitmasks and their scores for printing
		for (i = 0; i < 9; ++i) {
			if ((if_bytemask & (1 << i)) == 0)
				continue;
			// xlate PACKED index to UNPACKED index to get from
			// rl_byte
			rl_mask[i].bm   = rl_byte[XPU(i, !!ecc_ena)].bm;
			rl_mask[i].errs = rl_byte[XPU(i, !!ecc_ena)].bmerrs;
		}

		// maybe print bitmasks/scores here
		if (rl_print > 1) {
			display_rl_bm(if_num, rankx, rl_mask, ecc_ena);
			display_rl_bm_scores(if_num, rankx, rl_mask, ecc_ena);
			display_rl_seq_scores(if_num, rankx, rl_byte, ecc_ena);

			display_rl_with_rodt(if_num, rl_rank, rankx,
					     rl_score[rtt_nom][rodt_ctl][rankx].score,
					     print_nom_ohms,
					     imp_val->rodt_ohms[rodt_ctl],
					     WITH_RODT_BESTSCORE);

			debug("-----------\n");
		}
	}

	rl_score[rtt_nom][rodt_ctl][rankx].setting = rl_rank.u64;

	// print out the PBMs for the current RODT
	if (ddr_type == DDR4_DRAM && rl_print > 1) { // verbosity?
		// FIXME: change verbosity level after debug complete...

		for (i = 0; i < 9; i++) {
			u64 temp_mask;
			int num_values;

			// FIXME: PBM skip for RODTs in mask
			if ((1U << rodt_ctl) & pbm_rodt_skip)
				continue;

			temp_mask = rodt_perfect_counts.mask[i];
			num_values = __builtin_popcountll(temp_mask);
			i = __builtin_ffsll(temp_mask) - 1;

			debug("N%d.LMC%d.R%d: PERFECT: RODT %3d: Byte %d: mask 0x%02llx (%d): ",
			      node, if_num, rankx,
			      imp_val->rodt_ohms[rodt_ctl],
			      i, temp_mask >> i, num_values);

			while (temp_mask != 0) {
				i = __builtin_ffsll(temp_mask) - 1;
				debug("%2d(%2d) ", i,
				      rodt_perfect_counts.count[i][i]);
				temp_mask &= ~(1UL << i);
			} /* while (temp_mask != 0) */
			debug("\n");
		}
	}
}

static void rank_major_loop(struct ddr_priv *priv, int rankx, struct rl_score
			    rl_score[RTT_NOM_OHMS_COUNT][RODT_OHMS_COUNT][4])
{
	/* Start with an arbitrarily high score */
	int best_rank_score = DEFAULT_BEST_RANK_SCORE;
	int best_rank_rtt_nom = 0;
	int best_rank_ctl = 0;
	int best_rank_ohms = 0;
	int best_rankx = 0;
	int dimm_rank_mask;
	int max_rank_score;
	union cvmx_lmcx_rlevel_rankx saved_rl_rank;
	int next_ohms;
	int orankx;
	int next_score = 0;
	int best_byte, new_byte, temp_byte, orig_best_byte;
	int rank_best_bytes[9];
	int byte_sh;
	int avg_byte;
	int avg_diff;
	int i;

	if (!(rank_mask & (1 << rankx)))
		return;

	// some of the rank-related loops below need to operate only on
	// the ranks of a single DIMM,
	// so create a mask for their use here
	if (num_ranks == 4) {
		dimm_rank_mask = rank_mask; // should be 1111
	} else {
		dimm_rank_mask = rank_mask & 3; // should be 01 or 11
		if (rankx >= 2) {
			// doing a rank on the second DIMM, should be
			// 0100 or 1100
			dimm_rank_mask <<= 2;
		}
	}
	debug("DIMM rank mask: 0x%x, rank mask: 0x%x, rankx: %d\n",
	      dimm_rank_mask, rank_mask, rankx);

	// this is the start of the BEST ROW SCORE LOOP

	for (rtt_idx = min_rtt_nom_idx; rtt_idx <= max_rtt_nom_idx; ++rtt_idx) {
		rtt_nom = imp_val->rtt_nom_table[rtt_idx];

		debug("N%d.LMC%d.R%d: starting RTT_NOM %d (%d)\n",
		      node, if_num, rankx, rtt_nom,
		      imp_val->rtt_nom_ohms[rtt_nom]);

		for (rodt_ctl = max_rodt_ctl; rodt_ctl >= min_rodt_ctl;
		     --rodt_ctl) {
			next_ohms = imp_val->rodt_ohms[rodt_ctl];

			// skip RODT rows in mask, but *NOT* rows with too
			// high a score;
			// we will not use the skipped ones for printing or
			// evaluating, but we need to allow all the
			// non-skipped ones to be candidates for "best"
			if (((1 << rodt_ctl) & rodt_row_skip_mask) != 0) {
				debug("N%d.LMC%d.R%d: SKIPPING rodt:%d (%d) with rank_score:%d\n",
				      node, if_num, rankx, rodt_ctl,
				      next_ohms, next_score);
				continue;
			}

			// this is ROFFIX-0528
			for (orankx = 0; orankx < dimm_count * 4; orankx++) {
				// stay on the same DIMM
				if (!(dimm_rank_mask & (1 << orankx)))
					continue;

				next_score = rl_score[rtt_nom][rodt_ctl][orankx].score;

				// always skip a higher score
				if (next_score > best_rank_score)
					continue;

				// if scores are equal
				if (next_score == best_rank_score) {
					// always skip lower ohms
					if (next_ohms < best_rank_ohms)
						continue;

					// if same ohms
					if (next_ohms == best_rank_ohms) {
						// always skip the other rank(s)
						if (orankx != rankx)
							continue;
					}
					// else next_ohms are greater,
					// always choose it
				}
				// else next_score is less than current best,
				// so always choose it
				debug("N%d.LMC%d.R%d: new best score: rank %d, rodt %d(%3d), new best %d, previous best %d(%d)\n",
				      node, if_num, rankx, orankx, rodt_ctl, next_ohms, next_score,
				      best_rank_score, best_rank_ohms);
				best_rank_score	    = next_score;
				best_rank_rtt_nom   = rtt_nom;
				//best_rank_nom_ohms  = rtt_nom_ohms;
				best_rank_ctl       = rodt_ctl;
				best_rank_ohms      = next_ohms;
				best_rankx          = orankx;
				rl_rank.u64 =
					rl_score[rtt_nom][rodt_ctl][orankx].setting;
			}
		}
	}

	// this is the end of the BEST ROW SCORE LOOP

	// DANGER, Will Robinson!! Abort now if we did not find a best
	// score at all...
	if (best_rank_score == DEFAULT_BEST_RANK_SCORE) {
		printf("N%d.LMC%d.R%d: WARNING: no best rank score found - resetting node...\n",
		       node, if_num, rankx);
		mdelay(500);
		do_reset(NULL, 0, 0, NULL);
	}

	// FIXME: relative now, but still arbitrary...
	max_rank_score = best_rank_score;
	if (ddr_type == DDR4_DRAM) {
		// halve the range if 2 DIMMs unless they are single rank...
		max_rank_score += (MAX_RANK_SCORE_LIMIT / ((num_ranks > 1) ?
							   dimm_count : 1));
	} else {
		// Since DDR3 typically has a wider score range,
		// keep more of them always
		max_rank_score += MAX_RANK_SCORE_LIMIT;
	}

	if (!ecc_ena) {
		/* ECC is not used */
		rl_rank.s.byte8 = rl_rank.s.byte0;
	}

	// at the end, write the best row settings to the current rank
	lmc_wr(priv, CVMX_LMCX_RLEVEL_RANKX(rankx, if_num), rl_rank.u64);
	rl_rank.u64 = lmc_rd(priv, CVMX_LMCX_RLEVEL_RANKX(rankx, if_num));

	saved_rl_rank.u64 = rl_rank.u64;

	// this is the start of the PRINT LOOP
	int pass;

	// for pass==0, print current rank, pass==1 print other rank(s)
	// this is done because we want to show each ranks RODT values
	// together, not interlaced
	// keep separates for ranks - pass=0 target rank, pass=1 other
	// rank on DIMM
	int mask_skipped[2] = {0, 0};
	int score_skipped[2] = {0, 0};
	int selected_rows[2] = {0, 0};
	int zero_scores[2] = {0, 0};
	for (pass = 0; pass < 2; pass++) {
		for (orankx = 0; orankx < dimm_count * 4; orankx++) {
			// stay on the same DIMM
			if (!(dimm_rank_mask & (1 << orankx)))
				continue;

			if ((pass == 0 && orankx != rankx) ||
			    (pass != 0 && orankx == rankx))
				continue;

			for (rtt_idx = min_rtt_nom_idx;
			     rtt_idx <= max_rtt_nom_idx; ++rtt_idx) {
				rtt_nom = imp_val->rtt_nom_table[rtt_idx];
				if (dyn_rtt_nom_mask == 0) {
					print_nom_ohms = -1;
				} else {
					print_nom_ohms =
						imp_val->rtt_nom_ohms[rtt_nom];
				}

				// cycle through all the RODT values...
				for (rodt_ctl = max_rodt_ctl;
				     rodt_ctl >= min_rodt_ctl; --rodt_ctl) {
					union cvmx_lmcx_rlevel_rankx
						temp_rl_rank;
					int temp_score =
						rl_score[rtt_nom][rodt_ctl][orankx].score;
					int skip_row;

					temp_rl_rank.u64 =
						rl_score[rtt_nom][rodt_ctl][orankx].setting;

					// skip RODT rows in mask, or rows
					// with too high a score;
					// we will not use them for printing
					// or evaluating...
					if ((1 << rodt_ctl) &
					    rodt_row_skip_mask) {
						skip_row = WITH_RODT_SKIPPING;
						++mask_skipped[pass];
					} else if (temp_score >
						   max_rank_score) {
						skip_row = WITH_RODT_SKIPPING;
						++score_skipped[pass];
					} else {
						skip_row = WITH_RODT_BLANK;
						++selected_rows[pass];
						if (temp_score == 0)
							++zero_scores[pass];
					}

					// identify and print the BEST ROW
					// when it comes up
					if (skip_row == WITH_RODT_BLANK &&
					    best_rankx == orankx &&
					    best_rank_rtt_nom == rtt_nom &&
					    best_rank_ctl == rodt_ctl)
						skip_row = WITH_RODT_BESTROW;

					if (rl_print) {
						display_rl_with_rodt(if_num,
								     temp_rl_rank, orankx, temp_score,
								     print_nom_ohms,
								     imp_val->rodt_ohms[rodt_ctl],
								     skip_row);
					}
				}
			}
		}
	}
	debug("N%d.LMC%d.R%d: RLROWS: selected %d+%d, zero_scores %d+%d, mask_skipped %d+%d, score_skipped %d+%d\n",
	      node, if_num, rankx, selected_rows[0], selected_rows[1],
	      zero_scores[0], zero_scores[1], mask_skipped[0], mask_skipped[1],
	      score_skipped[0], score_skipped[1]);
	// this is the end of the PRINT LOOP

	// now evaluate which bytes need adjusting
	// collect the new byte values; first init with current best for
	// neighbor use
	for (i = 0, byte_sh = 0; i < 8 + ecc_ena; i++, byte_sh += 6) {
		rank_best_bytes[i] = (int)(rl_rank.u64 >> byte_sh) &
			RLEVEL_BYTE_MSK;
	}

	// this is the start of the BEST BYTE LOOP

	for (i = 0, byte_sh = 0; i < 8 + ecc_ena; i++, byte_sh += 6) {
		int sum = 0, count = 0;
		int count_less = 0, count_same = 0, count_more = 0;
		int count_byte; // save the value we counted around
		// for rank majority use
		int rank_less = 0, rank_same = 0, rank_more = 0;
		int neighbor;
		int neigh_byte;

		best_byte = rank_best_bytes[i];
		orig_best_byte = rank_best_bytes[i];

		// this is the start of the BEST BYTE AVERAGING LOOP

		// validate the initial "best" byte by looking at the
		// average of the unskipped byte-column entries
		// we want to do this before we go further, so we can
		// try to start with a better initial value
		// this is the so-called "BESTBUY" patch set

		for (rtt_idx = min_rtt_nom_idx; rtt_idx <= max_rtt_nom_idx;
		     ++rtt_idx) {
			rtt_nom = imp_val->rtt_nom_table[rtt_idx];

			for (rodt_ctl = max_rodt_ctl; rodt_ctl >= min_rodt_ctl;
			     --rodt_ctl) {
				union cvmx_lmcx_rlevel_rankx temp_rl_rank;
				int temp_score;

				// average over all the ranks
				for (orankx = 0; orankx < dimm_count * 4;
				     orankx++) {
					// stay on the same DIMM
					if (!(dimm_rank_mask & (1 << orankx)))
						continue;

					temp_score =
						rl_score[rtt_nom][rodt_ctl][orankx].score;
					// skip RODT rows in mask, or rows with
					// too high a score;
					// we will not use them for printing or
					// evaluating...

					if (!((1 << rodt_ctl) &
					      rodt_row_skip_mask) &&
					    temp_score <= max_rank_score) {
						temp_rl_rank.u64 =
							rl_score[rtt_nom][rodt_ctl][orankx].setting;
						temp_byte =
							(int)(temp_rl_rank.u64 >> byte_sh) &
							RLEVEL_BYTE_MSK;
						sum += temp_byte;
						count++;
					}
				}
			}
		}

		// this is the end of the BEST BYTE AVERAGING LOOP

		// FIXME: validate count and sum??
		avg_byte = (int)divide_nint(sum, count);
		avg_diff = best_byte - avg_byte;
		new_byte = best_byte;
		if (avg_diff != 0) {
			// bump best up/dn by 1, not necessarily all the
			// way to avg
			new_byte = best_byte + ((avg_diff > 0) ? -1 : 1);
		}

		if (rl_print) {
			debug("N%d.LMC%d.R%d: START:   Byte %d: best %d is different by %d from average %d, using %d.\n",
			      node, if_num, rankx,
			      i, best_byte, avg_diff, avg_byte, new_byte);
		}
		best_byte = new_byte;
		count_byte = new_byte; // save the value we will count around

		// At this point best_byte is either:
		// 1. the original byte-column value from the best scoring
		//    RODT row, OR
		// 2. that value bumped toward the average of all the
		//    byte-column values
		//
		// best_byte will not change from here on...

		// this is the start of the BEST BYTE COUNTING LOOP

		// NOTE: we do this next loop separately from above, because
		// we count relative to "best_byte"
		// which may have been modified by the above averaging
		// operation...

		for (rtt_idx = min_rtt_nom_idx; rtt_idx <= max_rtt_nom_idx;
		     ++rtt_idx) {
			rtt_nom = imp_val->rtt_nom_table[rtt_idx];

			for (rodt_ctl = max_rodt_ctl; rodt_ctl >= min_rodt_ctl;
			     --rodt_ctl) {
				union cvmx_lmcx_rlevel_rankx temp_rl_rank;
				int temp_score;

				for (orankx = 0; orankx < dimm_count * 4;
				     orankx++) { // count over all the ranks
					// stay on the same DIMM
					if (!(dimm_rank_mask & (1 << orankx)))
						continue;

					temp_score =
						rl_score[rtt_nom][rodt_ctl][orankx].score;
					// skip RODT rows in mask, or rows
					// with too high a score;
					// we will not use them for printing
					// or evaluating...
					if (((1 << rodt_ctl) &
					     rodt_row_skip_mask) ||
					    temp_score > max_rank_score)
						continue;

					temp_rl_rank.u64 =
						rl_score[rtt_nom][rodt_ctl][orankx].setting;
					temp_byte = (temp_rl_rank.u64 >>
						     byte_sh) & RLEVEL_BYTE_MSK;

					if (temp_byte == 0)
						;  // do not count it if illegal
					else if (temp_byte == best_byte)
						count_same++;
					else if (temp_byte == best_byte - 1)
						count_less++;
					else if (temp_byte == best_byte + 1)
						count_more++;
					// else do not count anything more
					// than 1 away from the best

					// no rank counting if disabled
					if (disable_rank_majority)
						continue;

					// FIXME? count is relative to
					// best_byte; should it be rank-based?
					// rank counts only on main rank
					if (orankx != rankx)
						continue;
					else if (temp_byte == best_byte)
						rank_same++;
					else if (temp_byte == best_byte - 1)
						rank_less++;
					else if (temp_byte == best_byte + 1)
						rank_more++;
				}
			}
		}

		if (rl_print) {
			debug("N%d.LMC%d.R%d: COUNT:   Byte %d: orig %d now %d, more %d same %d less %d (%d/%d/%d)\n",
			      node, if_num, rankx,
			      i, orig_best_byte, best_byte,
			      count_more, count_same, count_less,
			      rank_more, rank_same, rank_less);
		}

		// this is the end of the BEST BYTE COUNTING LOOP

		// choose the new byte value
		// we need to check that there is no gap greater than 2
		// between adjacent bytes (adjacency depends on DIMM type)
		// use the neighbor value to help decide
		// initially, the rank_best_bytes[] will contain values from
		// the chosen lowest score rank
		new_byte = 0;

		// neighbor is index-1 unless we are index 0 or index 8 (ECC)
		neighbor = (i == 8) ? 3 : ((i == 0) ? 1 : i - 1);
		neigh_byte = rank_best_bytes[neighbor];

		// can go up or down or stay the same, so look at a numeric
		// average to help
		new_byte = (int)divide_nint(((count_more * (best_byte + 1)) +
					     (count_same * (best_byte + 0)) +
					     (count_less * (best_byte - 1))),
					    max(1, (count_more + count_same +
						    count_less)));

		// use neighbor to help choose with average
		if (i > 0 && (abs(neigh_byte - new_byte) > 2) &&
		    !disable_sequential_delay_check) {
			// but not for byte 0
			int avg_pick = new_byte;

			if ((new_byte - best_byte) != 0) {
				// back to best, average did not get better
				new_byte = best_byte;
			} else {
				// avg was the same, still too far, now move
				// it towards the neighbor
				new_byte += (neigh_byte > new_byte) ? 1 : -1;
			}

			if (rl_print) {
				debug("N%d.LMC%d.R%d: AVERAGE: Byte %d: neighbor %d too different %d from average %d, picking %d.\n",
				      node, if_num, rankx,
				      i, neighbor, neigh_byte, avg_pick,
				      new_byte);
			}
		} else {
			// NOTE:
			// For now, we let the neighbor processing above trump
			// the new simple majority processing here.
			// This is mostly because we have seen no smoking gun
			// for a neighbor bad choice (yet?).
			// Also note that we will ALWAYS be using byte 0
			// majority, because of the if clause above.

			// majority is dependent on the counts, which are
			// relative to best_byte, so start there
			int maj_byte = best_byte;
			int rank_maj;
			int rank_sum;

			if (count_more > count_same &&
			    count_more > count_less) {
				maj_byte++;
			} else if (count_less > count_same &&
				   count_less > count_more) {
				maj_byte--;
			}

			if (maj_byte != new_byte) {
				// print only when majority choice is
				// different from average
				if (rl_print) {
					debug("N%d.LMC%d.R%d: MAJORTY: Byte %d: picking majority of %d over average %d.\n",
					      node, if_num, rankx, i, maj_byte,
					      new_byte);
				}
				new_byte = maj_byte;
			} else {
				if (rl_print) {
					debug("N%d.LMC%d.R%d: AVERAGE: Byte %d: picking average of %d.\n",
					      node, if_num, rankx, i, new_byte);
				}
			}

			if (!disable_rank_majority) {
				// rank majority is dependent on the rank
				// counts, which are relative to best_byte,
				// so start there, and adjust according to the
				// rank counts majority
				rank_maj = best_byte;
				if (rank_more > rank_same &&
				    rank_more > rank_less) {
					rank_maj++;
				} else if (rank_less > rank_same &&
					   rank_less > rank_more) {
					rank_maj--;
				}
				rank_sum = rank_more + rank_same + rank_less;

				// now, let rank majority possibly rule over
				// the current new_byte however we got it
				if (rank_maj != new_byte) { // only if different
					// Here is where we decide whether to
					// completely apply RANK_MAJORITY or not
					// ignore if less than
					if (rank_maj < new_byte) {
						if (rl_print) {
							debug("N%d.LMC%d.R%d: RANKMAJ: Byte %d: LESS: NOT using %d over %d.\n",
							      node, if_num,
							      rankx, i,
							      rank_maj,
							      new_byte);
						}
					} else {
						// For the moment, we do it
						// ONLY when running 2-slot
						// configs
						//  OR when rank_sum is big
						// enough
						if (dimm_count > 1 ||
						    rank_sum > 2) {
							// print only when rank
							// majority choice is
							// selected
							if (rl_print) {
								debug("N%d.LMC%d.R%d: RANKMAJ: Byte %d: picking %d over %d.\n",
								      node,
								      if_num,
								      rankx,
								      i,
								      rank_maj,
								      new_byte);
							}
							new_byte = rank_maj;
						} else {
							// FIXME: print some
							// info when we could
							// have chosen RANKMAJ
							// but did not
							if (rl_print) {
								debug("N%d.LMC%d.R%d: RANKMAJ: Byte %d: NOT using %d over %d (best=%d,sum=%d).\n",
								      node,
								      if_num,
								      rankx,
								      i,
								      rank_maj,
								      new_byte,
								      best_byte,
								      rank_sum);
							}
						}
					}
				}
			} /* if (!disable_rank_majority) */
		}
		// one last check:
		// if new_byte is still count_byte, BUT there was no count
		// for that value, DO SOMETHING!!!
		// FIXME: go back to original best byte from the best row
		if (new_byte == count_byte && count_same == 0) {
			new_byte = orig_best_byte;
			if (rl_print) {
				debug("N%d.LMC%d.R%d: FAILSAF: Byte %d: going back to original %d.\n",
				      node, if_num, rankx, i, new_byte);
			}
		}
		// Look at counts for "perfect" bitmasks (PBMs) if we had
		// any for this byte-lane.
		// Remember, we only counted for DDR4, so zero means none
		// or DDR3, and we bypass this...
		value_mask = rank_perf[rankx].mask[i];
		disable_rlv_bump_this_byte = 0;

		if (value_mask != 0 && rl_ctl.cn78xx.offset == 1) {
			int i, delay_count, delay_max = 0, del_val = 0;
			int num_values = __builtin_popcountll(value_mask);
			int sum_counts = 0;
			u64 temp_mask = value_mask;

			disable_rlv_bump_this_byte = 1;
			i = __builtin_ffsll(temp_mask) - 1;
			if (rl_print)
				debug("N%d.LMC%d.R%d: PERFECT: Byte %d: OFF1: mask 0x%02llx (%d): ",
				      node, if_num, rankx, i, value_mask >> i,
				      num_values);

			while (temp_mask != 0) {
				i = __builtin_ffsll(temp_mask) - 1;
				delay_count = rank_perf[rankx].count[i][i];
				sum_counts += delay_count;
				if (rl_print)
					debug("%2d(%2d) ", i, delay_count);
				if (delay_count >= delay_max) {
					delay_max = delay_count;
					del_val = i;
				}
				temp_mask &= ~(1UL << i);
			} /* while (temp_mask != 0) */

			// if sum_counts is small, just use NEW_BYTE
			if (sum_counts < pbm_lowsum_limit) {
				if (rl_print)
					debug(": LOWSUM (%2d), choose ORIG ",
					      sum_counts);
				del_val = new_byte;
				delay_max = rank_perf[rankx].count[i][del_val];
			}

			// finish printing here...
			if (rl_print) {
				debug(": USING %2d (%2d) D%d\n", del_val,
				      delay_max, disable_rlv_bump_this_byte);
			}

			new_byte = del_val; // override with best PBM choice

		} else if ((value_mask != 0) && (rl_ctl.cn78xx.offset == 2)) {
			//                        if (value_mask != 0) {
			int i, delay_count, del_val;
			int num_values = __builtin_popcountll(value_mask);
			int sum_counts = 0;
			u64 temp_mask = value_mask;

			i = __builtin_ffsll(temp_mask) - 1;
			if (rl_print)
				debug("N%d.LMC%d.R%d: PERFECT: Byte %d: mask 0x%02llx (%d): ",
				      node, if_num, rankx, i, value_mask >> i,
				      num_values);
			while (temp_mask != 0) {
				i = __builtin_ffsll(temp_mask) - 1;
				delay_count = rank_perf[rankx].count[i][i];
				sum_counts += delay_count;
				if (rl_print)
					debug("%2d(%2d) ", i, delay_count);
				temp_mask &= ~(1UL << i);
			} /* while (temp_mask != 0) */

			del_val = __builtin_ffsll(value_mask) - 1;
			delay_count =
				rank_perf[rankx].count[i][del_val];

			// overkill, normally only 1-4 bits
			i = (value_mask >> del_val) & 0x1F;

			// if sum_counts is small, treat as special and use
			// NEW_BYTE
			if (sum_counts < pbm_lowsum_limit) {
				if (rl_print)
					debug(": LOWSUM (%2d), choose ORIG",
					      sum_counts);
				i = 99; // SPECIAL case...
			}

			switch (i) {
			case 0x01 /* 00001b */:
				// allow BUMP
				break;

			case 0x13 /* 10011b */:
			case 0x0B /* 01011b */:
			case 0x03 /* 00011b */:
				del_val += 1; // take the second
				disable_rlv_bump_this_byte = 1; // allow no BUMP
				break;

			case 0x0D /* 01101b */:
			case 0x05 /* 00101b */:
				// test count of lowest and all
				if (delay_count >= 5 || sum_counts <= 5)
					del_val += 1; // take the hole
				else
					del_val += 2; // take the next set
				disable_rlv_bump_this_byte = 1; // allow no BUMP
				break;

			case 0x0F /* 01111b */:
			case 0x17 /* 10111b */:
			case 0x07 /* 00111b */:
				del_val += 1; // take the second
				if (delay_count < 5) { // lowest count is small
					int second =
						rank_perf[rankx].count[i][del_val];
					int third =
						rank_perf[rankx].count[i][del_val + 1];
					// test if middle is more than 1 OR
					// top is more than 1;
					// this means if they are BOTH 1,
					// then we keep the second...
					if (second > 1 || third > 1) {
						// if middle is small OR top
						// is large
						if (second < 5 ||
						    third > 1) {
							// take the top
							del_val += 1;
							if (rl_print)
								debug(": TOP7 ");
						}
					}
				}
				disable_rlv_bump_this_byte = 1; // allow no BUMP
				break;

			default: // all others...
				if (rl_print)
					debug(": ABNORMAL, choose ORIG");

			case 99: // special
				 // FIXME: choose original choice?
				del_val = new_byte;
				disable_rlv_bump_this_byte = 1; // allow no BUMP
				break;
			}
			delay_count =
				rank_perf[rankx].count[i][del_val];

			// finish printing here...
			if (rl_print)
				debug(": USING %2d (%2d) D%d\n", del_val,
				      delay_count, disable_rlv_bump_this_byte);
			new_byte = del_val; // override with best PBM choice
		} else {
			if (ddr_type == DDR4_DRAM) { // only report when DDR4
				// FIXME: remove or increase VBL for this
				// output...
				if (rl_print)
					debug("N%d.LMC%d.R%d: PERFECT: Byte %d: ZERO PBMs, USING %d\n",
					      node, if_num, rankx, i,
					      new_byte);
				// prevent ODD bump, rely on original
				disable_rlv_bump_this_byte = 1;
			}
		} /* if (value_mask != 0) */

		// optionally bump the delay value
		if (enable_rldelay_bump && !disable_rlv_bump_this_byte) {
			if ((new_byte & enable_rldelay_bump) ==
			    enable_rldelay_bump) {
				int bump_value = new_byte + rldelay_bump_incr;

				if (rl_print) {
					debug("N%d.LMC%d.R%d: RLVBUMP: Byte %d: CHANGING %d to %d (%s)\n",
					      node, if_num, rankx, i,
					      new_byte, bump_value,
					      (value_mask &
					       (1 << bump_value)) ?
					      "PBM" : "NOPBM");
				}
				new_byte = bump_value;
			}
		}

		// last checks for count-related purposes
		if (new_byte == best_byte && count_more > 0 &&
		    count_less == 0) {
			// we really should take best_byte + 1
			if (rl_print) {
				debug("N%d.LMC%d.R%d: CADJMOR: Byte %d: CHANGING %d to %d\n",
				      node, if_num, rankx, i,
				      new_byte, best_byte + 1);
				new_byte = best_byte + 1;
			}
		} else if ((new_byte < best_byte) && (count_same > 0)) {
			// we really should take best_byte
			if (rl_print) {
				debug("N%d.LMC%d.R%d: CADJSAM: Byte %d: CHANGING %d to %d\n",
				      node, if_num, rankx, i,
				      new_byte, best_byte);
				new_byte = best_byte;
			}
		} else if (new_byte > best_byte) {
			if ((new_byte == (best_byte + 1)) &&
			    count_more == 0 && count_less > 0) {
				// we really should take best_byte
				if (rl_print) {
					debug("N%d.LMC%d.R%d: CADJLE1: Byte %d: CHANGING %d to %d\n",
					      node, if_num, rankx, i,
					      new_byte, best_byte);
					new_byte = best_byte;
				}
			} else if ((new_byte >= (best_byte + 2)) &&
				   ((count_more > 0) || (count_same > 0))) {
				if (rl_print) {
					debug("N%d.LMC%d.R%d: CADJLE2: Byte %d: CHANGING %d to %d\n",
					      node, if_num, rankx, i,
					      new_byte, best_byte + 1);
					new_byte = best_byte + 1;
				}
			}
		}

		if (rl_print) {
			debug("N%d.LMC%d.R%d: SUMMARY: Byte %d: orig %d now %d, more %d same %d less %d, using %d\n",
			      node, if_num, rankx, i, orig_best_byte,
			      best_byte, count_more, count_same, count_less,
			      new_byte);
		}

		// update the byte with the new value (NOTE: orig value in
		// the CSR may not be current "best")
		upd_rl_rank(&rl_rank, i, new_byte);

		// save new best for neighbor use
		rank_best_bytes[i] = new_byte;
	} /* for (i = 0; i < 8+ecc_ena; i++) */

	////////////////// this is the end of the BEST BYTE LOOP

	if (saved_rl_rank.u64 != rl_rank.u64) {
		lmc_wr(priv, CVMX_LMCX_RLEVEL_RANKX(rankx, if_num),
		       rl_rank.u64);
		rl_rank.u64 = lmc_rd(priv,
				     CVMX_LMCX_RLEVEL_RANKX(rankx, if_num));
		debug("Adjusting Read-Leveling per-RANK settings.\n");
	} else {
		debug("Not Adjusting Read-Leveling per-RANK settings.\n");
	}
	display_rl_with_final(if_num, rl_rank, rankx);

	// FIXME: does this help make the output a little easier to focus?
	if (rl_print > 0)
		debug("-----------\n");

#define RLEVEL_RANKX_EXTRAS_INCR  0
	// if there are unused entries to be filled
	if ((rank_mask & 0x0f) != 0x0f) {
		// copy the current rank
		union cvmx_lmcx_rlevel_rankx temp_rl_rank = rl_rank;

		if (rankx < 3) {
#if RLEVEL_RANKX_EXTRAS_INCR > 0
			int byte, delay;

			// modify the copy in prep for writing to empty slot(s)
			for (byte = 0; byte < 9; byte++) {
				delay = get_rl_rank(&temp_rl_rank, byte) +
					RLEVEL_RANKX_EXTRAS_INCR;
				if (delay > RLEVEL_BYTE_MSK)
					delay = RLEVEL_BYTE_MSK;
				upd_rl_rank(&temp_rl_rank, byte, delay);
			}
#endif

			// if rank 0, write rank 1 and rank 2 here if empty
			if (rankx == 0) {
				// check that rank 1 is empty
				if (!(rank_mask & (1 << 1))) {
					debug("N%d.LMC%d.R%d: writing RLEVEL_RANK unused entry R%d.\n",
					      node, if_num, rankx, 1);
					lmc_wr(priv,
					       CVMX_LMCX_RLEVEL_RANKX(1,
								      if_num),
					       temp_rl_rank.u64);
				}

				// check that rank 2 is empty
				if (!(rank_mask & (1 << 2))) {
					debug("N%d.LMC%d.R%d: writing RLEVEL_RANK unused entry R%d.\n",
					      node, if_num, rankx, 2);
					lmc_wr(priv,
					       CVMX_LMCX_RLEVEL_RANKX(2,
								      if_num),
					       temp_rl_rank.u64);
				}
			}

			// if ranks 0, 1 or 2, write rank 3 here if empty
			// check that rank 3 is empty
			if (!(rank_mask & (1 << 3))) {
				debug("N%d.LMC%d.R%d: writing RLEVEL_RANK unused entry R%d.\n",
				      node, if_num, rankx, 3);
				lmc_wr(priv, CVMX_LMCX_RLEVEL_RANKX(3, if_num),
				       temp_rl_rank.u64);
			}
		}
	}
}

static void lmc_read_leveling(struct ddr_priv *priv)
{
	struct rl_score rl_score[RTT_NOM_OHMS_COUNT][RODT_OHMS_COUNT][4];
	union cvmx_lmcx_control ctl;
	union cvmx_lmcx_config cfg;
	int rankx;
	char *s;
	int i;

	/*
	 * 4.8.10 LMC Read Leveling
	 *
	 * LMC supports an automatic read-leveling separately per byte-lane
	 * using the DDR3 multipurpose register predefined pattern for system
	 * calibration defined in the JEDEC DDR3 specifications.
	 *
	 * All of DDR PLL, LMC CK, and LMC DRESET, and early LMC initializations
	 * must be completed prior to starting this LMC read-leveling sequence.
	 *
	 * Software could simply write the desired read-leveling values into
	 * LMC(0)_RLEVEL_RANK(0..3). This section describes a sequence that uses
	 * LMC's autoread-leveling capabilities.
	 *
	 * When LMC does the read-leveling sequence for a rank, it first enables
	 * the DDR3 multipurpose register predefined pattern for system
	 * calibration on the selected DRAM rank via a DDR3 MR3 write, then
	 * executes 64 RD operations at different internal delay settings, then
	 * disables the predefined pattern via another DDR3 MR3 write
	 * operation. LMC determines the pass or fail of each of the 64 settings
	 * independently for each byte lane, then writes appropriate
	 * LMC(0)_RLEVEL_RANK(0..3)[BYTE*] values for the rank.
	 *
	 * After read-leveling for a rank, software can read the 64 pass/fail
	 * indications for one byte lane via LMC(0)_RLEVEL_DBG[BITMASK].
	 * Software can observe all pass/fail results for all byte lanes in a
	 * rank via separate read-leveling sequences on the rank with different
	 * LMC(0)_RLEVEL_CTL[BYTE] values.
	 *
	 * The 64 pass/fail results will typically have failures for the low
	 * delays, followed by a run of some passing settings, followed by more
	 * failures in the remaining high delays.  LMC sets
	 * LMC(0)_RLEVEL_RANK(0..3)[BYTE*] to one of the passing settings.
	 * First, LMC selects the longest run of successes in the 64 results.
	 * (In the unlikely event that there is more than one longest run, LMC
	 * selects the first one.) Then if LMC(0)_RLEVEL_CTL[OFFSET_EN] = 1 and
	 * the selected run has more than LMC(0)_RLEVEL_CTL[OFFSET] successes,
	 * LMC selects the last passing setting in the run minus
	 * LMC(0)_RLEVEL_CTL[OFFSET]. Otherwise LMC selects the middle setting
	 * in the run (rounding earlier when necessary). We expect the
	 * read-leveling sequence to produce good results with the reset values
	 * LMC(0)_RLEVEL_CTL [OFFSET_EN]=1, LMC(0)_RLEVEL_CTL[OFFSET] = 2.
	 *
	 * The read-leveling sequence has the following steps:
	 *
	 * 1. Select desired LMC(0)_RLEVEL_CTL[OFFSET_EN,OFFSET,BYTE] settings.
	 *    Do the remaining substeps 2-4 separately for each rank i with
	 *    attached DRAM.
	 *
	 * 2. Without changing any other fields in LMC(0)_CONFIG,
	 *
	 *    o write LMC(0)_SEQ_CTL[SEQ_SEL] to select read-leveling
	 *
	 *    o write LMC(0)_CONFIG[RANKMASK] = (1 << i)
	 *
	 *    o write LMC(0)_SEQ_CTL[INIT_START] = 1
	 *
	 *    This initiates the previously-described read-leveling.
	 *
	 * 3. Wait until LMC(0)_RLEVEL_RANKi[STATUS] != 2
	 *
	 *    LMC will have updated LMC(0)_RLEVEL_RANKi[BYTE*] for all byte
	 *    lanes at this point.
	 *
	 *    If ECC DRAM is not present (i.e. when DRAM is not attached to the
	 *    DDR_CBS_0_* and DDR_CB<7:0> chip signals, or the DDR_DQS_<4>_* and
	 *    DDR_DQ<35:32> chip signals), write LMC(0)_RLEVEL_RANK*[BYTE8] =
	 *    LMC(0)_RLEVEL_RANK*[BYTE0]. Write LMC(0)_RLEVEL_RANK*[BYTE4] =
	 *    LMC(0)_RLEVEL_RANK*[BYTE0].
	 *
	 * 4. If desired, consult LMC(0)_RLEVEL_DBG[BITMASK] and compare to
	 *    LMC(0)_RLEVEL_RANKi[BYTE*] for the lane selected by
	 *    LMC(0)_RLEVEL_CTL[BYTE]. If desired, modify
	 *    LMC(0)_RLEVEL_CTL[BYTE] to a new value and repeat so that all
	 *    BITMASKs can be observed.
	 *
	 * 5. Initialize LMC(0)_RLEVEL_RANK* values for all unused ranks.
	 *
	 *    Let rank i be a rank with attached DRAM.
	 *
	 *    For all ranks j that do not have attached DRAM, set
	 *    LMC(0)_RLEVEL_RANKj = LMC(0)_RLEVEL_RANKi.
	 *
	 * This read-leveling sequence can help select the proper CN70XX ODT
	 * resistance value (LMC(0)_COMP_CTL2[RODT_CTL]). A hardware-generated
	 * LMC(0)_RLEVEL_RANKi[BYTEj] value (for a used byte lane j) that is
	 * drastically different from a neighboring LMC(0)_RLEVEL_RANKi[BYTEk]
	 * (for a used byte lane k) can indicate that the CN70XX ODT value is
	 * bad. It is possible to simultaneously optimize both
	 * LMC(0)_COMP_CTL2[RODT_CTL] and LMC(0)_RLEVEL_RANKn[BYTE*] values by
	 * performing this read-leveling sequence for several
	 * LMC(0)_COMP_CTL2[RODT_CTL] values and selecting the one with the
	 * best LMC(0)_RLEVEL_RANKn[BYTE*] profile for the ranks.
	 */

	rl_rodt_err = 0;
	rl_dbg_loops = 1;
	saved_int_zqcs_dis = 0;
	max_adj_rl_del_inc = 0;
	rl_print = RLEVEL_PRINTALL_DEFAULT;

#ifdef ENABLE_HARDCODED_RLEVEL
	part_number[21] = {0};
#endif /* ENABLE_HARDCODED_RLEVEL */

	pbm_lowsum_limit = 5; // FIXME: is this a good default?
	// FIXME: PBM skip for RODT 240 and 34
	pbm_rodt_skip = (1U << ddr4_rodt_ctl_240_ohm) |
		(1U << ddr4_rodt_ctl_34_ohm);

	disable_rank_majority = 0; // control rank majority processing

	// default to mask 11b ODDs for DDR4 (except 73xx), else DISABLE
	// for DDR3
	rldelay_bump_incr = 0;
	disable_rlv_bump_this_byte = 0;

	enable_rldelay_bump = (ddr_type == DDR4_DRAM) ?
		((octeon_is_cpuid(OCTEON_CN73XX)) ? 1 : 3) : 0;

	s = lookup_env(priv, "ddr_disable_rank_majority");
	if (s)
		disable_rank_majority = !!simple_strtoul(s, NULL, 0);

	s = lookup_env(priv, "ddr_pbm_lowsum_limit");
	if (s)
		pbm_lowsum_limit = simple_strtoul(s, NULL, 0);

	s = lookup_env(priv, "ddr_pbm_rodt_skip");
	if (s)
		pbm_rodt_skip = simple_strtoul(s, NULL, 0);
	memset(rank_perf, 0, sizeof(rank_perf));

	ctl.u64 = lmc_rd(priv, CVMX_LMCX_CONTROL(if_num));
	save_ddr2t = ctl.cn78xx.ddr2t;

	cfg.u64 = lmc_rd(priv, CVMX_LMCX_CONFIG(if_num));
	ecc_ena = cfg.cn78xx.ecc_ena;

	s = lookup_env(priv, "ddr_rlevel_2t");
	if (s)
		ctl.cn78xx.ddr2t = simple_strtoul(s, NULL, 0);

	lmc_wr(priv, CVMX_LMCX_CONTROL(if_num), ctl.u64);

	debug("LMC%d: Performing Read-Leveling\n", if_num);

	rl_ctl.u64 = lmc_rd(priv, CVMX_LMCX_RLEVEL_CTL(if_num));

	rl_samples = c_cfg->rlevel_average_loops;
	if (rl_samples == 0) {
		rl_samples = RLEVEL_SAMPLES_DEFAULT;
		// up the samples for these cases
		if (dimm_count == 1 || num_ranks == 1)
			rl_samples = rl_samples * 2 + 1;
	}

	rl_compute = c_cfg->rlevel_compute;
	rl_ctl.cn78xx.offset_en = c_cfg->offset_en;
	rl_ctl.cn78xx.offset    = spd_rdimm
		? c_cfg->offset_rdimm
		: c_cfg->offset_udimm;

	int value = 1; // should ALWAYS be set

	s = lookup_env(priv, "ddr_rlevel_delay_unload");
	if (s)
		value = !!simple_strtoul(s, NULL, 0);
	rl_ctl.cn78xx.delay_unload_0 = value;
	rl_ctl.cn78xx.delay_unload_1 = value;
	rl_ctl.cn78xx.delay_unload_2 = value;
	rl_ctl.cn78xx.delay_unload_3 = value;

	// use OR_DIS=1 to try for better results
	rl_ctl.cn78xx.or_dis = 1;

	/*
	 * If we will be switching to 32bit mode level based on only
	 * four bits because there are only 4 ECC bits.
	 */
	rl_ctl.cn78xx.bitmask = (if_64b) ? 0xFF : 0x0F;

	// allow overrides
	s = lookup_env(priv, "ddr_rlevel_ctl_or_dis");
	if (s)
		rl_ctl.cn78xx.or_dis = simple_strtoul(s, NULL, 0);

	s = lookup_env(priv, "ddr_rlevel_ctl_bitmask");
	if (s)
		rl_ctl.cn78xx.bitmask = simple_strtoul(s, NULL, 0);

	rl_comp_offs = spd_rdimm
		? c_cfg->rlevel_comp_offset_rdimm
		: c_cfg->rlevel_comp_offset_udimm;
	s = lookup_env(priv, "ddr_rlevel_comp_offset");
	if (s)
		rl_comp_offs = strtoul(s, NULL, 0);

	s = lookup_env(priv, "ddr_rlevel_offset");
	if (s)
		rl_ctl.cn78xx.offset   = simple_strtoul(s, NULL, 0);

	s = lookup_env(priv, "ddr_rlevel_offset_en");
	if (s)
		rl_ctl.cn78xx.offset_en   = simple_strtoul(s, NULL, 0);

	s = lookup_env(priv, "ddr_rlevel_ctl");
	if (s)
		rl_ctl.u64   = simple_strtoul(s, NULL, 0);

	lmc_wr(priv,
	       CVMX_LMCX_RLEVEL_CTL(if_num),
	       rl_ctl.u64);

	// do this here so we can look at final RLEVEL_CTL[offset] setting...
	s = lookup_env(priv, "ddr_enable_rldelay_bump");
	if (s) {
		// also use as mask bits
		enable_rldelay_bump = strtoul(s, NULL, 0);
	}

	if (enable_rldelay_bump != 0)
		rldelay_bump_incr = (rl_ctl.cn78xx.offset == 1) ? -1 : 1;

	s = lookup_env(priv, "ddr%d_rlevel_debug_loops", if_num);
	if (s)
		rl_dbg_loops = simple_strtoul(s, NULL, 0);

	s = lookup_env(priv, "ddr_rtt_nom_auto");
	if (s)
		ddr_rtt_nom_auto = !!simple_strtoul(s, NULL, 0);

	s = lookup_env(priv, "ddr_rlevel_average");
	if (s)
		rl_samples = simple_strtoul(s, NULL, 0);

	s = lookup_env(priv, "ddr_rlevel_compute");
	if (s)
		rl_compute = simple_strtoul(s, NULL, 0);

	s = lookup_env(priv, "ddr_rlevel_printall");
	if (s)
		rl_print = simple_strtoul(s, NULL, 0);

	debug("RLEVEL_CTL                                    : 0x%016llx\n",
	      rl_ctl.u64);
	debug("RLEVEL_OFFSET                                 : %6d\n",
	      rl_ctl.cn78xx.offset);
	debug("RLEVEL_OFFSET_EN                              : %6d\n",
	      rl_ctl.cn78xx.offset_en);

	/*
	 * The purpose for the indexed table is to sort the settings
	 * by the ohm value to simplify the testing when incrementing
	 * through the settings.  (index => ohms) 1=120, 2=60, 3=40,
	 * 4=30, 5=20
	 */
	min_rtt_nom_idx = (c_cfg->min_rtt_nom_idx == 0) ?
		1 : c_cfg->min_rtt_nom_idx;
	max_rtt_nom_idx = (c_cfg->max_rtt_nom_idx == 0) ?
		5 : c_cfg->max_rtt_nom_idx;

	min_rodt_ctl = (c_cfg->min_rodt_ctl == 0) ? 1 : c_cfg->min_rodt_ctl;
	max_rodt_ctl = (c_cfg->max_rodt_ctl == 0) ? 5 : c_cfg->max_rodt_ctl;

	s = lookup_env(priv, "ddr_min_rodt_ctl");
	if (s)
		min_rodt_ctl = simple_strtoul(s, NULL, 0);

	s = lookup_env(priv, "ddr_max_rodt_ctl");
	if (s)
		max_rodt_ctl = simple_strtoul(s, NULL, 0);

	s = lookup_env(priv, "ddr_min_rtt_nom_idx");
	if (s)
		min_rtt_nom_idx = simple_strtoul(s, NULL, 0);

	s = lookup_env(priv, "ddr_max_rtt_nom_idx");
	if (s)
		max_rtt_nom_idx = simple_strtoul(s, NULL, 0);

#ifdef ENABLE_HARDCODED_RLEVEL
	if (c_cfg->rl_tbl) {
		/* Check for hard-coded read-leveling settings */
		get_dimm_part_number(part_number, &dimm_config_table[0],
				     0, ddr_type);
		for (rankx = 0; rankx < dimm_count * 4; rankx++) {
			if (!(rank_mask & (1 << rankx)))
				continue;

			rl_rank.u64 = lmc_rd(priv,
					     CVMX_LMCX_RLEVEL_RANKX(rankx,
								    if_num));

			i = 0;
			while (c_cfg->rl_tbl[i].part) {
				debug("DIMM part number:\"%s\", SPD: \"%s\"\n",
				      c_cfg->rl_tbl[i].part, part_number);
				if ((strcmp(part_number,
					    c_cfg->rl_tbl[i].part) == 0) &&
				    (abs(c_cfg->rl_tbl[i].speed -
					 2 * ddr_hertz / (1000 * 1000)) < 10)) {
					debug("Using hard-coded read leveling for DIMM part number: \"%s\"\n",
					      part_number);
					rl_rank.u64 =
						c_cfg->rl_tbl[i].rl_rank[if_num][rankx];
					lmc_wr(priv,
					       CVMX_LMCX_RLEVEL_RANKX(rankx,
								      if_num),
					       rl_rank.u64);
					rl_rank.u64 =
						lmc_rd(priv,
						       CVMX_LMCX_RLEVEL_RANKX(rankx,
									      if_num));
					display_rl(if_num, rl_rank, rankx);
					/* Disable h/w read-leveling */
					rl_dbg_loops = 0;
					break;
				}
				++i;
			}
		}
	}
#endif /* ENABLE_HARDCODED_RLEVEL */

	max_adj_rl_del_inc = c_cfg->maximum_adjacent_rlevel_delay_increment;
	s = lookup_env(priv, "ddr_maximum_adjacent_rlevel_delay_increment");
	if (s)
		max_adj_rl_del_inc = strtoul(s, NULL, 0);

	while (rl_dbg_loops--) {
		union cvmx_lmcx_modereg_params1 mp1;
		union cvmx_lmcx_comp_ctl2 cc2;

		/* Initialize the error scoreboard */
		memset(rl_score, 0, sizeof(rl_score));

		cc2.u64 = lmc_rd(priv, CVMX_LMCX_COMP_CTL2(if_num));
		saved_ddr__ptune = cc2.cn78xx.ddr__ptune;
		saved_ddr__ntune = cc2.cn78xx.ddr__ntune;

		/* Disable dynamic compensation settings */
		if (rl_comp_offs != 0) {
			cc2.cn78xx.ptune = saved_ddr__ptune;
			cc2.cn78xx.ntune = saved_ddr__ntune;

			/*
			 * Round up the ptune calculation to bias the odd
			 * cases toward ptune
			 */
			cc2.cn78xx.ptune += divide_roundup(rl_comp_offs, 2);
			cc2.cn78xx.ntune -= rl_comp_offs / 2;

			ctl.u64 = lmc_rd(priv, CVMX_LMCX_CONTROL(if_num));
			saved_int_zqcs_dis = ctl.s.int_zqcs_dis;
			/* Disable ZQCS while in bypass. */
			ctl.s.int_zqcs_dis = 1;
			lmc_wr(priv, CVMX_LMCX_CONTROL(if_num), ctl.u64);

			cc2.cn78xx.byp = 1; /* Enable bypass mode */
			lmc_wr(priv, CVMX_LMCX_COMP_CTL2(if_num), cc2.u64);
			lmc_rd(priv, CVMX_LMCX_COMP_CTL2(if_num));
			/* Read again */
			cc2.u64 = lmc_rd(priv, CVMX_LMCX_COMP_CTL2(if_num));
			debug("DDR__PTUNE/DDR__NTUNE                         : %d/%d\n",
			      cc2.cn78xx.ddr__ptune, cc2.cn78xx.ddr__ntune);
		}

		mp1.u64 = lmc_rd(priv, CVMX_LMCX_MODEREG_PARAMS1(if_num));

		for (rtt_idx = min_rtt_nom_idx; rtt_idx <= max_rtt_nom_idx;
		     ++rtt_idx) {
			rtt_nom = imp_val->rtt_nom_table[rtt_idx];

			/*
			 * When the read ODT mask is zero the dyn_rtt_nom_mask
			 * is zero than RTT_NOM will not be changing during
			 * read-leveling.  Since the value is fixed we only need
			 * to test it once.
			 */
			if (dyn_rtt_nom_mask == 0) {
				// flag not to print NOM ohms
				print_nom_ohms = -1;
			} else {
				if (dyn_rtt_nom_mask & 1)
					mp1.s.rtt_nom_00 = rtt_nom;
				if (dyn_rtt_nom_mask & 2)
					mp1.s.rtt_nom_01 = rtt_nom;
				if (dyn_rtt_nom_mask & 4)
					mp1.s.rtt_nom_10 = rtt_nom;
				if (dyn_rtt_nom_mask & 8)
					mp1.s.rtt_nom_11 = rtt_nom;
				// FIXME? rank 0 ohms always?
				print_nom_ohms =
					imp_val->rtt_nom_ohms[mp1.s.rtt_nom_00];
			}

			lmc_wr(priv, CVMX_LMCX_MODEREG_PARAMS1(if_num),
			       mp1.u64);

			if (print_nom_ohms >= 0 && rl_print > 1) {
				debug("\n");
				debug("RTT_NOM     %3d, %3d, %3d, %3d ohms           :  %x,%x,%x,%x\n",
				      imp_val->rtt_nom_ohms[mp1.s.rtt_nom_11],
				      imp_val->rtt_nom_ohms[mp1.s.rtt_nom_10],
				      imp_val->rtt_nom_ohms[mp1.s.rtt_nom_01],
				      imp_val->rtt_nom_ohms[mp1.s.rtt_nom_00],
				      mp1.s.rtt_nom_11,
				      mp1.s.rtt_nom_10,
				      mp1.s.rtt_nom_01,
				      mp1.s.rtt_nom_00);
			}

			ddr_init_seq(priv, rank_mask, if_num);

			// Try RANK outside RODT to rearrange the output...
			for (rankx = 0; rankx < dimm_count * 4; rankx++) {
				if (!(rank_mask & (1 << rankx)))
					continue;

				for (rodt_ctl = max_rodt_ctl;
				     rodt_ctl >= min_rodt_ctl; --rodt_ctl)
					rodt_loop(priv, rankx, rl_score);
			}
		}

		/* Re-enable dynamic compensation settings. */
		if (rl_comp_offs != 0) {
			cc2.u64 = lmc_rd(priv, CVMX_LMCX_COMP_CTL2(if_num));

			cc2.cn78xx.ptune = 0;
			cc2.cn78xx.ntune = 0;
			cc2.cn78xx.byp = 0; /* Disable bypass mode */
			lmc_wr(priv, CVMX_LMCX_COMP_CTL2(if_num), cc2.u64);
			/* Read once */
			lmc_rd(priv, CVMX_LMCX_COMP_CTL2(if_num));

			/* Read again */
			cc2.u64 = lmc_rd(priv, CVMX_LMCX_COMP_CTL2(if_num));
			debug("DDR__PTUNE/DDR__NTUNE                         : %d/%d\n",
			      cc2.cn78xx.ddr__ptune, cc2.cn78xx.ddr__ntune);

			ctl.u64 = lmc_rd(priv, CVMX_LMCX_CONTROL(if_num));
			/* Restore original setting */
			ctl.s.int_zqcs_dis = saved_int_zqcs_dis;
			lmc_wr(priv, CVMX_LMCX_CONTROL(if_num), ctl.u64);
		}

		int override_compensation = 0;

		s = lookup_env(priv, "ddr__ptune");
		if (s)
			saved_ddr__ptune = strtoul(s, NULL, 0);

		s = lookup_env(priv, "ddr__ntune");
		if (s) {
			saved_ddr__ntune = strtoul(s, NULL, 0);
			override_compensation = 1;
		}

		if (override_compensation) {
			cc2.cn78xx.ptune = saved_ddr__ptune;
			cc2.cn78xx.ntune = saved_ddr__ntune;

			ctl.u64 = lmc_rd(priv, CVMX_LMCX_CONTROL(if_num));
			saved_int_zqcs_dis = ctl.s.int_zqcs_dis;
			/* Disable ZQCS while in bypass. */
			ctl.s.int_zqcs_dis = 1;
			lmc_wr(priv, CVMX_LMCX_CONTROL(if_num), ctl.u64);

			cc2.cn78xx.byp = 1; /* Enable bypass mode */
			lmc_wr(priv, CVMX_LMCX_COMP_CTL2(if_num), cc2.u64);
			/* Read again */
			cc2.u64 = lmc_rd(priv, CVMX_LMCX_COMP_CTL2(if_num));

			debug("DDR__PTUNE/DDR__NTUNE                         : %d/%d\n",
			      cc2.cn78xx.ptune, cc2.cn78xx.ntune);
		}

		/* Evaluation block */
		/* Still at initial value? */
		int best_rodt_score = DEFAULT_BEST_RANK_SCORE;
		int auto_rodt_ctl = 0;
		int auto_rtt_nom  = 0;
		int rodt_score;

		rodt_row_skip_mask = 0;

		// just add specific RODT rows to the skip mask for DDR4
		// at this time...
		if (ddr_type == DDR4_DRAM) {
			// skip RODT row 34 ohms for all DDR4 types
			rodt_row_skip_mask |= (1 << ddr4_rodt_ctl_34_ohm);
			// skip RODT row 40 ohms for all DDR4 types
			rodt_row_skip_mask |= (1 << ddr4_rodt_ctl_40_ohm);
			// For now, do not skip RODT row 40 or 48 ohm when
			// ddr_hertz is above 1075 MHz
			if (ddr_hertz > 1075000000) {
				// noskip RODT row 40 ohms
				rodt_row_skip_mask &=
					~(1 << ddr4_rodt_ctl_40_ohm);
				// noskip RODT row 48 ohms
				rodt_row_skip_mask &=
					~(1 << ddr4_rodt_ctl_48_ohm);
			}
			// For now, do not skip RODT row 48 ohm for 2Rx4
			// stacked die DIMMs
			if (is_stacked_die && num_ranks == 2 &&
			    dram_width == 4) {
				// noskip RODT row 48 ohms
				rodt_row_skip_mask &=
					~(1 << ddr4_rodt_ctl_48_ohm);
			}
			// for now, leave all rows eligible when we have
			// mini-DIMMs...
			if (spd_dimm_type == 5 || spd_dimm_type == 6)
				rodt_row_skip_mask = 0;
			// for now, leave all rows eligible when we have
			// a 2-slot 1-rank config
			if (dimm_count == 2 && num_ranks == 1)
				rodt_row_skip_mask = 0;

			debug("Evaluating Read-Leveling Scoreboard for AUTO settings.\n");
			for (rtt_idx = min_rtt_nom_idx;
			     rtt_idx <= max_rtt_nom_idx; ++rtt_idx) {
				rtt_nom = imp_val->rtt_nom_table[rtt_idx];

				for (rodt_ctl = max_rodt_ctl;
				     rodt_ctl >= min_rodt_ctl; --rodt_ctl) {
					rodt_score = 0;
					for (rankx = 0; rankx < dimm_count * 4;
					     rankx++) {
						if (!(rank_mask & (1 << rankx)))
							continue;

						debug("rl_score[rtt_nom=%d][rodt_ctl=%d][rankx=%d].score:%d\n",
						      rtt_nom, rodt_ctl, rankx,
						      rl_score[rtt_nom][rodt_ctl][rankx].score);
						rodt_score +=
							rl_score[rtt_nom][rodt_ctl][rankx].score;
					}
					// FIXME: do we need to skip RODT rows
					// here, like we do below in the
					// by-RANK settings?

					/*
					 * When using automatic ODT settings use
					 * the ODT settings associated with the
					 * best score for all of the tested ODT
					 * combinations.
					 */

					if (rodt_score < best_rodt_score ||
					    (rodt_score == best_rodt_score &&
					     (imp_val->rodt_ohms[rodt_ctl] >
					      imp_val->rodt_ohms[auto_rodt_ctl]))) {
						debug("AUTO: new best score for rodt:%d (%d), new score:%d, previous score:%d\n",
						      rodt_ctl,
						      imp_val->rodt_ohms[rodt_ctl],
						      rodt_score,
						      best_rodt_score);
						best_rodt_score = rodt_score;
						auto_rodt_ctl   = rodt_ctl;
						auto_rtt_nom    = rtt_nom;
					}
				}
			}

			mp1.u64 = lmc_rd(priv,
					 CVMX_LMCX_MODEREG_PARAMS1(if_num));

			if (ddr_rtt_nom_auto) {
				/* Store the automatically set RTT_NOM value */
				if (dyn_rtt_nom_mask & 1)
					mp1.s.rtt_nom_00 = auto_rtt_nom;
				if (dyn_rtt_nom_mask & 2)
					mp1.s.rtt_nom_01 = auto_rtt_nom;
				if (dyn_rtt_nom_mask & 4)
					mp1.s.rtt_nom_10 = auto_rtt_nom;
				if (dyn_rtt_nom_mask & 8)
					mp1.s.rtt_nom_11 = auto_rtt_nom;
			} else {
				/*
				 * restore the manual settings to the register
				 */
				mp1.s.rtt_nom_00 = default_rtt_nom[0];
				mp1.s.rtt_nom_01 = default_rtt_nom[1];
				mp1.s.rtt_nom_10 = default_rtt_nom[2];
				mp1.s.rtt_nom_11 = default_rtt_nom[3];
			}

			lmc_wr(priv, CVMX_LMCX_MODEREG_PARAMS1(if_num),
			       mp1.u64);
			debug("RTT_NOM     %3d, %3d, %3d, %3d ohms           :  %x,%x,%x,%x\n",
			      imp_val->rtt_nom_ohms[mp1.s.rtt_nom_11],
			      imp_val->rtt_nom_ohms[mp1.s.rtt_nom_10],
			      imp_val->rtt_nom_ohms[mp1.s.rtt_nom_01],
			      imp_val->rtt_nom_ohms[mp1.s.rtt_nom_00],
			      mp1.s.rtt_nom_11,
			      mp1.s.rtt_nom_10,
			      mp1.s.rtt_nom_01,
			      mp1.s.rtt_nom_00);

			debug("RTT_WR      %3d, %3d, %3d, %3d ohms           :  %x,%x,%x,%x\n",
			      imp_val->rtt_wr_ohms[extr_wr(mp1.u64, 3)],
			      imp_val->rtt_wr_ohms[extr_wr(mp1.u64, 2)],
			      imp_val->rtt_wr_ohms[extr_wr(mp1.u64, 1)],
			      imp_val->rtt_wr_ohms[extr_wr(mp1.u64, 0)],
			      extr_wr(mp1.u64, 3),
			      extr_wr(mp1.u64, 2),
			      extr_wr(mp1.u64, 1),
			      extr_wr(mp1.u64, 0));

			debug("DIC         %3d, %3d, %3d, %3d ohms           :  %x,%x,%x,%x\n",
			      imp_val->dic_ohms[mp1.s.dic_11],
			      imp_val->dic_ohms[mp1.s.dic_10],
			      imp_val->dic_ohms[mp1.s.dic_01],
			      imp_val->dic_ohms[mp1.s.dic_00],
			      mp1.s.dic_11,
			      mp1.s.dic_10,
			      mp1.s.dic_01,
			      mp1.s.dic_00);

			if (ddr_type == DDR4_DRAM) {
				union cvmx_lmcx_modereg_params2 mp2;
				/*
				 * We must read the CSR, and not depend on
				 * odt_config[odt_idx].odt_mask2, since we could
				 * have overridden values with envvars.
				 * NOTE: this corrects the printout, since the
				 * CSR is not written with the old values...
				 */
				mp2.u64 = lmc_rd(priv,
						 CVMX_LMCX_MODEREG_PARAMS2(if_num));

				debug("RTT_PARK    %3d, %3d, %3d, %3d ohms           :  %x,%x,%x,%x\n",
				      imp_val->rtt_nom_ohms[mp2.s.rtt_park_11],
				      imp_val->rtt_nom_ohms[mp2.s.rtt_park_10],
				      imp_val->rtt_nom_ohms[mp2.s.rtt_park_01],
				      imp_val->rtt_nom_ohms[mp2.s.rtt_park_00],
				      mp2.s.rtt_park_11,
				      mp2.s.rtt_park_10,
				      mp2.s.rtt_park_01,
				      mp2.s.rtt_park_00);

				debug("%-45s :  0x%x,0x%x,0x%x,0x%x\n",
				      "VREF_RANGE",
				      mp2.s.vref_range_11,
				      mp2.s.vref_range_10,
				      mp2.s.vref_range_01,
				      mp2.s.vref_range_00);

				debug("%-45s :  0x%x,0x%x,0x%x,0x%x\n",
				      "VREF_VALUE",
				      mp2.s.vref_value_11,
				      mp2.s.vref_value_10,
				      mp2.s.vref_value_01,
				      mp2.s.vref_value_00);
			}

			cc2.u64 = lmc_rd(priv, CVMX_LMCX_COMP_CTL2(if_num));
			if (ddr_rodt_ctl_auto) {
				cc2.cn78xx.rodt_ctl = auto_rodt_ctl;
			} else {
				// back to the original setting
				cc2.cn78xx.rodt_ctl = default_rodt_ctl;
			}
			lmc_wr(priv, CVMX_LMCX_COMP_CTL2(if_num), cc2.u64);
			cc2.u64 = lmc_rd(priv, CVMX_LMCX_COMP_CTL2(if_num));
			debug("Read ODT_CTL                                  : 0x%x (%d ohms)\n",
			      cc2.cn78xx.rodt_ctl,
			      imp_val->rodt_ohms[cc2.cn78xx.rodt_ctl]);

			/*
			 * Use the delays associated with the best score for
			 * each individual rank
			 */
			debug("Evaluating Read-Leveling Scoreboard for per-RANK settings.\n");

			// this is the the RANK MAJOR LOOP
			for (rankx = 0; rankx < dimm_count * 4; rankx++)
				rank_major_loop(priv, rankx, rl_score);
		}  /* Evaluation block */
	} /* while(rl_dbg_loops--) */

	ctl.cn78xx.ddr2t = save_ddr2t;
	lmc_wr(priv, CVMX_LMCX_CONTROL(if_num), ctl.u64);
	ctl.u64 = lmc_rd(priv, CVMX_LMCX_CONTROL(if_num));
	/* Display final 2T value */
	debug("DDR2T                                         : %6d\n",
	      ctl.cn78xx.ddr2t);

	ddr_init_seq(priv, rank_mask, if_num);

	for (rankx = 0; rankx < dimm_count * 4; rankx++) {
		u64 value;
		int parameter_set = 0;

		if (!(rank_mask & (1 << rankx)))
			continue;

		rl_rank.u64 = lmc_rd(priv, CVMX_LMCX_RLEVEL_RANKX(rankx,
								  if_num));

		for (i = 0; i < 9; ++i) {
			s = lookup_env(priv, "ddr%d_rlevel_rank%d_byte%d",
				       if_num, rankx, i);
			if (s) {
				parameter_set |= 1;
				value = simple_strtoul(s, NULL, 0);

				upd_rl_rank(&rl_rank, i, value);
			}
		}

		s = lookup_env_ull(priv, "ddr%d_rlevel_rank%d", if_num, rankx);
		if (s) {
			parameter_set |= 1;
			value = simple_strtoull(s, NULL, 0);
			rl_rank.u64 = value;
		}

		if (parameter_set) {
			lmc_wr(priv,
			       CVMX_LMCX_RLEVEL_RANKX(rankx, if_num),
			       rl_rank.u64);
			rl_rank.u64 = lmc_rd(priv,
					     CVMX_LMCX_RLEVEL_RANKX(rankx,
								    if_num));
			display_rl(if_num, rl_rank, rankx);
		}
	}
}

int init_octeon3_ddr3_interface(struct ddr_priv *priv,
				struct ddr_conf *_ddr_conf, u32 _ddr_hertz,
				u32 cpu_hertz, u32 ddr_ref_hertz, int _if_num,
				u32 _if_mask)
{
	union cvmx_lmcx_control ctrl;
	int ret;
	char *s;
	int i;

	if_num = _if_num;
	ddr_hertz = _ddr_hertz;
	ddr_conf = _ddr_conf;
	if_mask = _if_mask;
	odt_1rank_config = ddr_conf->odt_1rank_config;
	odt_2rank_config = ddr_conf->odt_2rank_config;
	odt_4rank_config = ddr_conf->odt_4rank_config;
	dimm_config_table = ddr_conf->dimm_config_table;
	c_cfg = &ddr_conf->custom_lmc_config;

	/*
	 * Compute clock rates to the nearest picosecond.
	 */
	tclk_psecs = hertz_to_psecs(ddr_hertz);	/* Clock in psecs */
	eclk_psecs = hertz_to_psecs(cpu_hertz);	/* Clock in psecs */

	dimm_count = 0;
	/* Accumulate and report all the errors before giving up */
	fatal_error = 0;

	/* Flag that indicates safe DDR settings should be used */
	safe_ddr_flag = 0;
	if_64b = 1;		/* Octeon II Default: 64bit interface width */
	mem_size_mbytes = 0;
	bank_bits = 0;
	column_bits_start = 1;
	use_ecc = 1;
	min_cas_latency = 0, max_cas_latency = 0, override_cas_latency = 0;
	spd_package = 0;
	spd_rawcard = 0;
	spd_rawcard_aorb = 0;
	spd_rdimm_registers = 0;
	is_stacked_die = 0;
	is_3ds_dimm = 0;	// 3DS
	lranks_per_prank = 1;	// 3DS: logical ranks per package rank
	lranks_bits = 0;	// 3DS: logical ranks bits
	die_capacity = 0;	// in Mbits; only used for 3DS

	wl_mask_err = 0;
	dyn_rtt_nom_mask = 0;
	ddr_disable_chip_reset = 1;
	match_wl_rtt_nom = 0;

	internal_retries = 0;

	disable_deskew_training = 0;
	restart_if_dsk_incomplete = 0;
	last_lane = ((if_64b) ? 8 : 4) + use_ecc;

	disable_sequential_delay_check = 0;
	wl_print = WLEVEL_PRINTALL_DEFAULT;

	enable_by_rank_init = 1;	// FIXME: default by-rank ON
	saved_rank_mask = 0;

	node = 0;

	memset(hwl_alts, 0, sizeof(hwl_alts));

	/*
	 * Initialize these to shut up the compiler. They are configured
	 * and used only for DDR4
	 */
	ddr4_trrd_lmin = 6000;
	ddr4_tccd_lmin = 6000;

	debug("\nInitializing node %d DDR interface %d, DDR Clock %d, DDR Reference Clock %d, CPUID 0x%08x\n",
	      node, if_num, ddr_hertz, ddr_ref_hertz, read_c0_prid());

	if (dimm_config_table[0].spd_addrs[0] == 0 &&
	    !dimm_config_table[0].spd_ptrs[0]) {
		printf("ERROR: No dimms specified in the dimm_config_table.\n");
		return -1;
	}

	// allow some overrides to be done

	// this one controls several things related to DIMM geometry: HWL and RL
	disable_sequential_delay_check = c_cfg->disable_sequential_delay_check;
	s = lookup_env(priv, "ddr_disable_sequential_delay_check");
	if (s)
		disable_sequential_delay_check = strtoul(s, NULL, 0);

	// this one controls whether chip RESET is done, or LMC init restarted
	// from step 6.9.6
	s = lookup_env(priv, "ddr_disable_chip_reset");
	if (s)
		ddr_disable_chip_reset = !!strtoul(s, NULL, 0);

	// this one controls whether Deskew Training is performed
	s = lookup_env(priv, "ddr_disable_deskew_training");
	if (s)
		disable_deskew_training = !!strtoul(s, NULL, 0);

	if (ddr_verbose(priv)) {
		printf("DDR SPD Table:");
		for (didx = 0; didx < DDR_CFG_T_MAX_DIMMS; ++didx) {
			if (dimm_config_table[didx].spd_addrs[0] == 0)
				break;

			printf(" --ddr%dspd=0x%02x", if_num,
			       dimm_config_table[didx].spd_addrs[0]);
			if (dimm_config_table[didx].spd_addrs[1] != 0)
				printf(",0x%02x",
				       dimm_config_table[didx].spd_addrs[1]);
		}
		printf("\n");
	}

	/*
	 * Walk the DRAM Socket Configuration Table to see what is installed.
	 */
	for (didx = 0; didx < DDR_CFG_T_MAX_DIMMS; ++didx) {
		/* Check for lower DIMM socket populated */
		if (validate_dimm(priv, &dimm_config_table[didx], 0)) {
			if (ddr_verbose(priv))
				report_dimm(&dimm_config_table[didx], 0,
					    dimm_count, if_num);
			++dimm_count;
		} else {
			break;
		}		/* Finished when there is no lower DIMM */
	}

	initialize_ddr_clock(priv, ddr_conf, cpu_hertz, ddr_hertz,
			     ddr_ref_hertz, if_num, if_mask);

	if (!odt_1rank_config)
		odt_1rank_config = disable_odt_config;
	if (!odt_2rank_config)
		odt_2rank_config = disable_odt_config;
	if (!odt_4rank_config)
		odt_4rank_config = disable_odt_config;

	s = env_get("ddr_safe");
	if (s) {
		safe_ddr_flag = !!simple_strtoul(s, NULL, 0);
		printf("Parameter found in environment. ddr_safe = %d\n",
		       safe_ddr_flag);
	}

	if (dimm_count == 0) {
		printf("ERROR: DIMM 0 not detected.\n");
		return (-1);
	}

	if (c_cfg->mode32b)
		if_64b = 0;

	s = lookup_env(priv, "if_64b");
	if (s)
		if_64b = !!simple_strtoul(s, NULL, 0);

	if (if_64b == 1) {
		if (octeon_is_cpuid(OCTEON_CN70XX)) {
			printf("64-bit interface width is not supported for this Octeon model\n");
			++fatal_error;
		}
	}

	/* ddr_type only indicates DDR4 or DDR3 */
	ddr_type = (read_spd(&dimm_config_table[0], 0,
			     DDR4_SPD_KEY_BYTE_DEVICE_TYPE) == 0x0C) ? 4 : 3;
	debug("DRAM Device Type: DDR%d\n", ddr_type);

	if (ddr_type == DDR4_DRAM) {
		int spd_module_type;
		int asymmetric;
		const char *signal_load[4] = { "", "MLS", "3DS", "RSV" };

		imp_val = &ddr4_impedence_val;

		spd_addr =
		    read_spd(&dimm_config_table[0], 0,
			     DDR4_SPD_ADDRESSING_ROW_COL_BITS);
		spd_org =
		    read_spd(&dimm_config_table[0], 0,
			     DDR4_SPD_MODULE_ORGANIZATION);
		spd_banks =
		    0xFF & read_spd(&dimm_config_table[0], 0,
				    DDR4_SPD_DENSITY_BANKS);

		bank_bits =
		    (2 + ((spd_banks >> 4) & 0x3)) + ((spd_banks >> 6) & 0x3);
		/* Controller can only address 4 bits. */
		bank_bits = min((int)bank_bits, 4);

		spd_package =
		    0XFF & read_spd(&dimm_config_table[0], 0,
				    DDR4_SPD_PACKAGE_TYPE);
		if (spd_package & 0x80) {	// non-monolithic device
			is_stacked_die = ((spd_package & 0x73) == 0x11);
			debug("DDR4: Package Type 0x%02x (%s), %d die\n",
			      spd_package, signal_load[(spd_package & 3)],
			      ((spd_package >> 4) & 7) + 1);
			is_3ds_dimm = ((spd_package & 3) == 2);	// is it 3DS?
			if (is_3ds_dimm) {	// is it 3DS?
				lranks_per_prank = ((spd_package >> 4) & 7) + 1;
				// FIXME: should make sure it is only 2H or 4H
				// or 8H?
				lranks_bits = lranks_per_prank >> 1;
				if (lranks_bits == 4)
					lranks_bits = 3;
			}
		} else if (spd_package != 0) {
			// FIXME: print non-zero monolithic device definition
			debug("DDR4: Package Type MONOLITHIC: %d die, signal load %d\n",
			      ((spd_package >> 4) & 7) + 1, (spd_package & 3));
		}

		asymmetric = (spd_org >> 6) & 1;
		if (asymmetric) {
			int spd_secondary_pkg =
			    read_spd(&dimm_config_table[0], 0,
				     DDR4_SPD_SECONDARY_PACKAGE_TYPE);
			debug("DDR4: Module Organization: ASYMMETRICAL: Secondary Package Type 0x%02x\n",
			      spd_secondary_pkg);
		} else {
			u64 bus_width =
				8 << (0x07 &
				read_spd(&dimm_config_table[0], 0,
					 DDR4_SPD_MODULE_MEMORY_BUS_WIDTH));
			u64 ddr_width = 4 << ((spd_org >> 0) & 0x7);
			u64 module_cap;
			int shift = (spd_banks & 0x0F);

			die_capacity = (shift < 8) ? (256UL << shift) :
				((12UL << (shift & 1)) << 10);
			debug("DDR4: Module Organization: SYMMETRICAL: capacity per die %d %cbit\n",
			      (die_capacity > 512) ? (die_capacity >> 10) :
			      die_capacity, (die_capacity > 512) ? 'G' : 'M');
			module_cap = ((u64)die_capacity << 20) / 8UL *
				bus_width / ddr_width *
				(1UL + ((spd_org >> 3) & 0x7));

			// is it 3DS?
			if (is_3ds_dimm) {
				module_cap *= (u64)(((spd_package >> 4) & 7) +
						    1);
			}
			debug("DDR4: Module Organization: SYMMETRICAL: capacity per module %lld GB\n",
			      module_cap >> 30);
		}

		spd_rawcard =
		    0xFF & read_spd(&dimm_config_table[0], 0,
				    DDR4_SPD_REFERENCE_RAW_CARD);
		debug("DDR4: Reference Raw Card 0x%02x\n", spd_rawcard);

		spd_module_type =
		    read_spd(&dimm_config_table[0], 0,
			     DDR4_SPD_KEY_BYTE_MODULE_TYPE);
		if (spd_module_type & 0x80) {	// HYBRID module
			debug("DDR4: HYBRID module, type %s\n",
			      ((spd_module_type & 0x70) ==
			       0x10) ? "NVDIMM" : "UNKNOWN");
		}
		spd_thermal_sensor =
		    read_spd(&dimm_config_table[0], 0,
			     DDR4_SPD_MODULE_THERMAL_SENSOR);
		spd_dimm_type = spd_module_type & 0x0F;
		spd_rdimm = (spd_dimm_type == 1) || (spd_dimm_type == 5) ||
			(spd_dimm_type == 8);
		if (spd_rdimm) {
			u16 spd_mfgr_id, spd_register_rev, spd_mod_attr;
			static const u16 manu_ids[4] = {
				0xb380, 0x3286, 0x9780, 0xb304
			};
			static const char *manu_names[4] = {
				"XXX", "XXXXXXX", "XX", "XXXXX"
			};
			int mc;

			spd_mfgr_id =
			    (0xFFU &
			     read_spd(&dimm_config_table[0], 0,
				      DDR4_SPD_REGISTER_MANUFACTURER_ID_LSB)) |
			    ((0xFFU &
			      read_spd(&dimm_config_table[0], 0,
				       DDR4_SPD_REGISTER_MANUFACTURER_ID_MSB))
			     << 8);
			spd_register_rev =
			    0xFFU & read_spd(&dimm_config_table[0], 0,
					     DDR4_SPD_REGISTER_REVISION_NUMBER);
			for (mc = 0; mc < 4; mc++)
				if (manu_ids[mc] == spd_mfgr_id)
					break;

			debug("DDR4: RDIMM Register Manufacturer ID: %s, Revision: 0x%02x\n",
			      (mc >= 4) ? "UNKNOWN" : manu_names[mc],
			      spd_register_rev);

			// RAWCARD A or B must be bit 7=0 and bits 4-0
			// either 00000(A) or 00001(B)
			spd_rawcard_aorb = ((spd_rawcard & 0x9fUL) <= 1);
			// RDIMM Module Attributes
			spd_mod_attr =
			    0xFFU & read_spd(&dimm_config_table[0], 0,
					DDR4_SPD_UDIMM_ADDR_MAPPING_FROM_EDGE);
			spd_rdimm_registers = ((1 << (spd_mod_attr & 3)) >> 1);
			debug("DDR4: RDIMM Module Attributes (0x%02x): Register Type DDR4RCD%02d, DRAM rows %d, Registers %d\n",
			      spd_mod_attr, (spd_mod_attr >> 4) + 1,
			      ((1 << ((spd_mod_attr >> 2) & 3)) >> 1),
			      spd_rdimm_registers);
		}
		dimm_type_name = ddr4_dimm_types[spd_dimm_type];
	} else {		/* if (ddr_type == DDR4_DRAM) */
		const char *signal_load[4] = { "UNK", "MLS", "SLS", "RSV" };

		imp_val = &ddr3_impedence_val;

		spd_addr =
		    read_spd(&dimm_config_table[0], 0,
			     DDR3_SPD_ADDRESSING_ROW_COL_BITS);
		spd_org =
		    read_spd(&dimm_config_table[0], 0,
			     DDR3_SPD_MODULE_ORGANIZATION);
		spd_banks =
		    read_spd(&dimm_config_table[0], 0,
			     DDR3_SPD_DENSITY_BANKS) & 0xff;

		bank_bits = 3 + ((spd_banks >> 4) & 0x7);
		/* Controller can only address 3 bits. */
		bank_bits = min((int)bank_bits, 3);
		spd_dimm_type =
		    0x0f & read_spd(&dimm_config_table[0], 0,
				    DDR3_SPD_KEY_BYTE_MODULE_TYPE);
		spd_rdimm = (spd_dimm_type == 1) || (spd_dimm_type == 5) ||
			(spd_dimm_type == 9);

		spd_package =
		    0xFF & read_spd(&dimm_config_table[0], 0,
				    DDR3_SPD_SDRAM_DEVICE_TYPE);
		if (spd_package & 0x80) {	// non-standard device
			debug("DDR3: Device Type 0x%02x (%s), %d die\n",
			      spd_package, signal_load[(spd_package & 3)],
			      ((1 << ((spd_package >> 4) & 7)) >> 1));
		} else if (spd_package != 0) {
			// FIXME: print non-zero monolithic device definition
			debug("DDR3: Device Type MONOLITHIC: %d die, signal load %d\n",
			      ((1 << (spd_package >> 4) & 7) >> 1),
			      (spd_package & 3));
		}

		spd_rawcard =
		    0xFF & read_spd(&dimm_config_table[0], 0,
				    DDR3_SPD_REFERENCE_RAW_CARD);
		debug("DDR3: Reference Raw Card 0x%02x\n", spd_rawcard);
		spd_thermal_sensor =
		    read_spd(&dimm_config_table[0], 0,
			     DDR3_SPD_MODULE_THERMAL_SENSOR);

		if (spd_rdimm) {
			int spd_mfgr_id, spd_register_rev, spd_mod_attr;

			spd_mfgr_id =
			    (0xFFU &
			     read_spd(&dimm_config_table[0], 0,
				      DDR3_SPD_REGISTER_MANUFACTURER_ID_LSB)) |
			    ((0xFFU &
			      read_spd(&dimm_config_table[0], 0,
				       DDR3_SPD_REGISTER_MANUFACTURER_ID_MSB))
			     << 8);
			spd_register_rev =
			    0xFFU & read_spd(&dimm_config_table[0], 0,
					     DDR3_SPD_REGISTER_REVISION_NUMBER);
			debug("DDR3: RDIMM Register Manufacturer ID 0x%x Revision 0x%02x\n",
			      spd_mfgr_id, spd_register_rev);
			// Module Attributes
			spd_mod_attr =
			    0xFFU & read_spd(&dimm_config_table[0], 0,
					     DDR3_SPD_ADDRESS_MAPPING);
			spd_rdimm_registers = ((1 << (spd_mod_attr & 3)) >> 1);
			debug("DDR3: RDIMM Module Attributes (0x%02x): DRAM rows %d, Registers %d\n",
			      spd_mod_attr,
			      ((1 << ((spd_mod_attr >> 2) & 3)) >> 1),
			      spd_rdimm_registers);
		}
		dimm_type_name = ddr3_dimm_types[spd_dimm_type];
	}

	if (spd_thermal_sensor & 0x80) {
		debug("DDR%d: SPD: Thermal Sensor PRESENT\n",
		      (ddr_type == DDR4_DRAM) ? 4 : 3);
	}

	debug("spd_addr        : %#06x\n", spd_addr);
	debug("spd_org         : %#06x\n", spd_org);
	debug("spd_banks       : %#06x\n", spd_banks);

	row_bits = 12 + ((spd_addr >> 3) & 0x7);
	col_bits = 9 + ((spd_addr >> 0) & 0x7);

	num_ranks = 1 + ((spd_org >> 3) & 0x7);
	dram_width = 4 << ((spd_org >> 0) & 0x7);
	num_banks = 1 << bank_bits;

	s = lookup_env(priv, "ddr_num_ranks");
	if (s)
		num_ranks = simple_strtoul(s, NULL, 0);

	s = lookup_env(priv, "ddr_enable_by_rank_init");
	if (s)
		enable_by_rank_init = !!simple_strtoul(s, NULL, 0);

	// FIXME: for now, we can only handle a DDR4 2rank-1slot config
	// FIXME: also, by-rank init does not work correctly if 32-bit mode...
	if (enable_by_rank_init && (ddr_type != DDR4_DRAM ||
				    dimm_count != 1 || if_64b != 1 ||
				    num_ranks != 2))
		enable_by_rank_init = 0;

	if (enable_by_rank_init) {
		struct dimm_odt_config *odt_config;
		union cvmx_lmcx_modereg_params1 mp1;
		union cvmx_lmcx_modereg_params2 modereg_params2;
		int by_rank_rodt, by_rank_wr, by_rank_park;

		// Do ODT settings changes which work best for 2R-1S configs
		debug("DDR4: 2R-1S special BY-RANK init ODT settings updated\n");

		// setup for modifying config table values - 2 ranks and 1 DIMM
		odt_config =
		    (struct dimm_odt_config *)&ddr_conf->odt_2rank_config[0];

		// original was 80, first try was 60
		by_rank_rodt = ddr4_rodt_ctl_48_ohm;
		s = lookup_env(priv, "ddr_by_rank_rodt");
		if (s)
			by_rank_rodt = strtoul(s, NULL, 0);

		odt_config->qs_dic = /*RODT_CTL */ by_rank_rodt;

		// this is for MODEREG_PARAMS1 fields
		// fetch the original settings
		mp1.u64 = odt_config->modereg_params1.u64;

		by_rank_wr = ddr4_rttwr_80ohm;	// originals were 240
		s = lookup_env(priv, "ddr_by_rank_wr");
		if (s)
			by_rank_wr = simple_strtoul(s, NULL, 0);

		// change specific settings here...
		insrt_wr(&mp1.u64, /*rank */ 00, by_rank_wr);
		insrt_wr(&mp1.u64, /*rank */ 01, by_rank_wr);

		// save final settings
		odt_config->modereg_params1.u64 = mp1.u64;

		// this is for MODEREG_PARAMS2 fields
		// fetch the original settings
		modereg_params2.u64 = odt_config->modereg_params2.u64;

		by_rank_park = ddr4_rttpark_none;	// originals were 120
		s = lookup_env(priv, "ddr_by_rank_park");
		if (s)
			by_rank_park = simple_strtoul(s, NULL, 0);

		// change specific settings here...
		modereg_params2.s.rtt_park_00 = by_rank_park;
		modereg_params2.s.rtt_park_01 = by_rank_park;

		// save final settings
		odt_config->modereg_params2.u64 = modereg_params2.u64;
	}

	/*
	 * FIX
	 * Check that values are within some theoretical limits.
	 * col_bits(min) = row_lsb(min) - bank_bits(max) - bus_bits(max) =
	 *   14 - 3 - 4 = 7
	 * col_bits(max) = row_lsb(max) - bank_bits(min) - bus_bits(min) =
	 *   18 - 2 - 3 = 13
	 */
	if (col_bits > 13 || col_bits < 7) {
		printf("Unsupported number of Col Bits: %d\n", col_bits);
		++fatal_error;
	}

	/*
	 * FIX
	 * Check that values are within some theoretical limits.
	 * row_bits(min) = pbank_lsb(min) - row_lsb(max) - rank_bits =
	 *   26 - 18 - 1 = 7
	 * row_bits(max) = pbank_lsb(max) - row_lsb(min) - rank_bits =
	 *   33 - 14 - 1 = 18
	 */
	if (row_bits > 18 || row_bits < 7) {
		printf("Unsupported number of Row Bits: %d\n", row_bits);
		++fatal_error;
	}

	s = lookup_env(priv, "ddr_rdimm_ena");
	if (s)
		spd_rdimm = !!simple_strtoul(s, NULL, 0);

	wl_loops = WLEVEL_LOOPS_DEFAULT;
	// accept generic or interface-specific override
	s = lookup_env(priv, "ddr_wlevel_loops");
	if (!s)
		s = lookup_env(priv, "ddr%d_wlevel_loops", if_num);

	if (s)
		wl_loops = strtoul(s, NULL, 0);

	s = lookup_env(priv, "ddr_ranks");
	if (s)
		num_ranks = simple_strtoul(s, NULL, 0);

	bunk_enable = (num_ranks > 1);

	if (octeon_is_cpuid(OCTEON_CN7XXX))
		column_bits_start = 3;
	else
		printf("ERROR: Unsupported Octeon model: 0x%x\n",
		       read_c0_prid());

	row_lsb = column_bits_start + col_bits + bank_bits - (!if_64b);
	debug("row_lsb = column_bits_start + col_bits + bank_bits = %d\n",
	      row_lsb);

	pbank_lsb = row_lsb + row_bits + bunk_enable;
	debug("pbank_lsb = row_lsb + row_bits + bunk_enable = %d\n", pbank_lsb);

	if (lranks_per_prank > 1) {
		pbank_lsb = row_lsb + row_bits + lranks_bits + bunk_enable;
		debug("DDR4: 3DS: pbank_lsb = (%d row_lsb) + (%d row_bits) + (%d lranks_bits) + (%d bunk_enable) = %d\n",
		      row_lsb, row_bits, lranks_bits, bunk_enable, pbank_lsb);
	}

	mem_size_mbytes = dimm_count * ((1ull << pbank_lsb) >> 20);
	if (num_ranks == 4) {
		/*
		 * Quad rank dimm capacity is equivalent to two dual-rank
		 * dimms.
		 */
		mem_size_mbytes *= 2;
	}

	/*
	 * Mask with 1 bits set for for each active rank, allowing 2 bits
	 * per dimm. This makes later calculations simpler, as a variety
	 * of CSRs use this layout. This init needs to be updated for dual
	 * configs (ie non-identical DIMMs).
	 *
	 * Bit 0 = dimm0, rank 0
	 * Bit 1 = dimm0, rank 1
	 * Bit 2 = dimm1, rank 0
	 * Bit 3 = dimm1, rank 1
	 * ...
	 */
	rank_mask = 0x1;
	if (num_ranks > 1)
		rank_mask = 0x3;
	if (num_ranks > 2)
		rank_mask = 0xf;

	for (i = 1; i < dimm_count; i++)
		rank_mask |= ((rank_mask & 0x3) << (2 * i));

	/*
	 * If we are booting from RAM, the DRAM controller is
	 * already set up.  Just return the memory size
	 */
	if (priv->flags & FLAG_RAM_RESIDENT) {
		debug("Ram Boot: Skipping LMC config\n");
		return mem_size_mbytes;
	}

	if (ddr_type == DDR4_DRAM) {
		spd_ecc =
		    !!(read_spd
		       (&dimm_config_table[0], 0,
			DDR4_SPD_MODULE_MEMORY_BUS_WIDTH) & 8);
	} else {
		spd_ecc =
		    !!(read_spd
		       (&dimm_config_table[0], 0,
			DDR3_SPD_MEMORY_BUS_WIDTH) & 8);
	}

	char rank_spec[8];

	printable_rank_spec(rank_spec, num_ranks, dram_width, spd_package);
	debug("Summary: %d %s%s %s %s, row bits=%d, col bits=%d, bank bits=%d\n",
	      dimm_count, dimm_type_name, (dimm_count > 1) ? "s" : "",
	      rank_spec,
	      (spd_ecc) ? "ECC" : "non-ECC", row_bits, col_bits, bank_bits);

	if (ddr_type == DDR4_DRAM) {
		spd_cas_latency =
		    ((0xff &
		      read_spd(&dimm_config_table[0], 0,
			       DDR4_SPD_CAS_LATENCIES_BYTE0)) << 0);
		spd_cas_latency |=
		    ((0xff &
		      read_spd(&dimm_config_table[0], 0,
			       DDR4_SPD_CAS_LATENCIES_BYTE1)) << 8);
		spd_cas_latency |=
		    ((0xff &
		      read_spd(&dimm_config_table[0], 0,
			       DDR4_SPD_CAS_LATENCIES_BYTE2)) << 16);
		spd_cas_latency |=
		    ((0xff &
		      read_spd(&dimm_config_table[0], 0,
			       DDR4_SPD_CAS_LATENCIES_BYTE3)) << 24);
	} else {
		spd_cas_latency =
		    0xff & read_spd(&dimm_config_table[0], 0,
				    DDR3_SPD_CAS_LATENCIES_LSB);
		spd_cas_latency |=
		    ((0xff &
		      read_spd(&dimm_config_table[0], 0,
			       DDR3_SPD_CAS_LATENCIES_MSB)) << 8);
	}
	debug("spd_cas_latency : %#06x\n", spd_cas_latency);

	if (ddr_type == DDR4_DRAM) {
		/*
		 * No other values for DDR4 MTB and FTB are specified at the
		 * current time so don't bother reading them. Can't speculate
		 * how new values will be represented.
		 */
		int spdmtb = 125;
		int spdftb = 1;

		taamin = spdmtb * read_spd(&dimm_config_table[0], 0,
					   DDR4_SPD_MIN_CAS_LATENCY_TAAMIN) +
			 spdftb * (signed char)read_spd(&dimm_config_table[0],
			 0, DDR4_SPD_MIN_CAS_LATENCY_FINE_TAAMIN);

		ddr4_tckavgmin = spdmtb * read_spd(&dimm_config_table[0], 0,
			DDR4_SPD_MINIMUM_CYCLE_TIME_TCKAVGMIN) +
			spdftb * (signed char)read_spd(&dimm_config_table[0], 0,
			DDR4_SPD_MIN_CYCLE_TIME_FINE_TCKAVGMIN);

		ddr4_tckavgmax = spdmtb * read_spd(&dimm_config_table[0], 0,
			DDR4_SPD_MAXIMUM_CYCLE_TIME_TCKAVGMAX) +
			spdftb * (signed char)read_spd(&dimm_config_table[0], 0,
			DDR4_SPD_MAX_CYCLE_TIME_FINE_TCKAVGMAX);

		ddr4_trdcmin = spdmtb * read_spd(&dimm_config_table[0], 0,
			DDR4_SPD_MIN_RAS_CAS_DELAY_TRCDMIN) +
			spdftb * (signed char)read_spd(&dimm_config_table[0], 0,
			DDR4_SPD_MIN_RAS_TO_CAS_DELAY_FINE_TRCDMIN);

		ddr4_trpmin = spdmtb * read_spd(&dimm_config_table[0], 0,
			DDR4_SPD_MIN_ROW_PRECHARGE_DELAY_TRPMIN) +
			spdftb * (signed char)read_spd(&dimm_config_table[0], 0,
			DDR4_SPD_MIN_ROW_PRECHARGE_DELAY_FINE_TRPMIN);

		ddr4_trasmin = spdmtb *
			(((read_spd
			   (&dimm_config_table[0], 0,
			    DDR4_SPD_UPPER_NIBBLES_TRAS_TRC) & 0xf) << 8) +
			 (read_spd
			  (&dimm_config_table[0], 0,
			   DDR4_SPD_MIN_ACTIVE_PRECHARGE_LSB_TRASMIN) & 0xff));

		ddr4_trcmin = spdmtb *
			((((read_spd
			    (&dimm_config_table[0], 0,
			     DDR4_SPD_UPPER_NIBBLES_TRAS_TRC) >> 4) & 0xf) <<
			  8) + (read_spd
				(&dimm_config_table[0], 0,
				 DDR4_SPD_MIN_ACTIVE_REFRESH_LSB_TRCMIN) &
				0xff))
			+ spdftb * (signed char)read_spd(&dimm_config_table[0],
							 0,
			DDR4_SPD_MIN_ACT_TO_ACT_REFRESH_DELAY_FINE_TRCMIN);

		ddr4_trfc1min = spdmtb * (((read_spd(&dimm_config_table[0], 0,
			DDR4_SPD_MIN_REFRESH_RECOVERY_MSB_TRFC1MIN) & 0xff) <<
			8) + (read_spd(&dimm_config_table[0], 0,
			DDR4_SPD_MIN_REFRESH_RECOVERY_LSB_TRFC1MIN) & 0xff));

		ddr4_trfc2min = spdmtb * (((read_spd(&dimm_config_table[0], 0,
			DDR4_SPD_MIN_REFRESH_RECOVERY_MSB_TRFC2MIN) & 0xff) <<
			8) + (read_spd(&dimm_config_table[0], 0,
			DDR4_SPD_MIN_REFRESH_RECOVERY_LSB_TRFC2MIN) & 0xff));

		ddr4_trfc4min = spdmtb * (((read_spd(&dimm_config_table[0], 0,
			DDR4_SPD_MIN_REFRESH_RECOVERY_MSB_TRFC4MIN) & 0xff) <<
			8) + (read_spd(&dimm_config_table[0], 0,
			DDR4_SPD_MIN_REFRESH_RECOVERY_LSB_TRFC4MIN) & 0xff));

		ddr4_tfawmin = spdmtb * (((read_spd(&dimm_config_table[0], 0,
			DDR4_SPD_MIN_FOUR_ACTIVE_WINDOW_MSN_TFAWMIN) & 0xf) <<
			8) + (read_spd(&dimm_config_table[0], 0,
			DDR4_SPD_MIN_FOUR_ACTIVE_WINDOW_LSB_TFAWMIN) & 0xff));

		ddr4_trrd_smin = spdmtb * read_spd(&dimm_config_table[0], 0,
			DDR4_SPD_MIN_ROW_ACTIVE_DELAY_SAME_TRRD_SMIN) +
			spdftb * (signed char)read_spd(&dimm_config_table[0], 0,
			DDR4_SPD_MIN_ACT_TO_ACT_DELAY_DIFF_FINE_TRRD_SMIN);

		ddr4_trrd_lmin = spdmtb * read_spd(&dimm_config_table[0], 0,
			DDR4_SPD_MIN_ROW_ACTIVE_DELAY_DIFF_TRRD_LMIN) +
			spdftb * (signed char)read_spd(&dimm_config_table[0], 0,
			DDR4_SPD_MIN_ACT_TO_ACT_DELAY_SAME_FINE_TRRD_LMIN);

		ddr4_tccd_lmin = spdmtb * read_spd(&dimm_config_table[0], 0,
			DDR4_SPD_MIN_CAS_TO_CAS_DELAY_TCCD_LMIN) +
			spdftb * (signed char)read_spd(&dimm_config_table[0], 0,
			DDR4_SPD_MIN_CAS_TO_CAS_DELAY_FINE_TCCD_LMIN);

		debug("%-45s : %6d ps\n", "Medium Timebase (MTB)", spdmtb);
		debug("%-45s : %6d ps\n", "Fine Timebase   (FTB)", spdftb);

		debug("%-45s : %6d ps (%ld MT/s)\n",
		      "SDRAM Minimum Cycle Time (tCKAVGmin)", ddr4_tckavgmin,
		      pretty_psecs_to_mts(ddr4_tckavgmin));
		debug("%-45s : %6d ps\n",
		      "SDRAM Maximum Cycle Time (tCKAVGmax)", ddr4_tckavgmax);
		debug("%-45s : %6d ps\n", "Minimum CAS Latency Time (taamin)",
		      taamin);
		debug("%-45s : %6d ps\n",
		      "Minimum RAS to CAS Delay Time (tRCDmin)", ddr4_trdcmin);
		debug("%-45s : %6d ps\n",
		      "Minimum Row Precharge Delay Time (tRPmin)", ddr4_trpmin);
		debug("%-45s : %6d ps\n",
		      "Minimum Active to Precharge Delay (tRASmin)",
		      ddr4_trasmin);
		debug("%-45s : %6d ps\n",
		      "Minimum Active to Active/Refr. Delay (tRCmin)",
		      ddr4_trcmin);
		debug("%-45s : %6d ps\n",
		      "Minimum Refresh Recovery Delay (tRFC1min)",
		      ddr4_trfc1min);
		debug("%-45s : %6d ps\n",
		      "Minimum Refresh Recovery Delay (tRFC2min)",
		      ddr4_trfc2min);
		debug("%-45s : %6d ps\n",
		      "Minimum Refresh Recovery Delay (tRFC4min)",
		      ddr4_trfc4min);
		debug("%-45s : %6d ps\n",
		      "Minimum Four Activate Window Time (tFAWmin)",
		      ddr4_tfawmin);
		debug("%-45s : %6d ps\n",
		      "Minimum Act. to Act. Delay (tRRD_Smin)", ddr4_trrd_smin);
		debug("%-45s : %6d ps\n",
		      "Minimum Act. to Act. Delay (tRRD_Lmin)", ddr4_trrd_lmin);
		debug("%-45s : %6d ps\n",
		      "Minimum CAS to CAS Delay Time (tCCD_Lmin)",
		      ddr4_tccd_lmin);

#define DDR4_TWR 15000
#define DDR4_TWTR_S 2500

		tckmin = ddr4_tckavgmin;
		twr = DDR4_TWR;
		trcd = ddr4_trdcmin;
		trrd = ddr4_trrd_smin;
		trp = ddr4_trpmin;
		tras = ddr4_trasmin;
		trc = ddr4_trcmin;
		trfc = ddr4_trfc1min;
		twtr = DDR4_TWTR_S;
		tfaw = ddr4_tfawmin;

		if (spd_rdimm) {
			spd_addr_mirror = read_spd(&dimm_config_table[0], 0,
			DDR4_SPD_RDIMM_ADDR_MAPPING_FROM_REGISTER_TO_DRAM) &
			0x1;
		} else {
			spd_addr_mirror = read_spd(&dimm_config_table[0], 0,
				DDR4_SPD_UDIMM_ADDR_MAPPING_FROM_EDGE) & 0x1;
		}
		debug("spd_addr_mirror : %#06x\n", spd_addr_mirror);
	} else {
		spd_mtb_dividend =
		    0xff & read_spd(&dimm_config_table[0], 0,
				    DDR3_SPD_MEDIUM_TIMEBASE_DIVIDEND);
		spd_mtb_divisor =
		    0xff & read_spd(&dimm_config_table[0], 0,
				    DDR3_SPD_MEDIUM_TIMEBASE_DIVISOR);
		spd_tck_min =
		    0xff & read_spd(&dimm_config_table[0], 0,
				    DDR3_SPD_MINIMUM_CYCLE_TIME_TCKMIN);
		spd_taa_min =
		    0xff & read_spd(&dimm_config_table[0], 0,
				    DDR3_SPD_MIN_CAS_LATENCY_TAAMIN);

		spd_twr =
		    0xff & read_spd(&dimm_config_table[0], 0,
				    DDR3_SPD_MIN_WRITE_RECOVERY_TWRMIN);
		spd_trcd =
		    0xff & read_spd(&dimm_config_table[0], 0,
				    DDR3_SPD_MIN_RAS_CAS_DELAY_TRCDMIN);
		spd_trrd =
		    0xff & read_spd(&dimm_config_table[0], 0,
				    DDR3_SPD_MIN_ROW_ACTIVE_DELAY_TRRDMIN);
		spd_trp =
		    0xff & read_spd(&dimm_config_table[0], 0,
				    DDR3_SPD_MIN_ROW_PRECHARGE_DELAY_TRPMIN);
		spd_tras =
		    0xff & read_spd(&dimm_config_table[0], 0,
				    DDR3_SPD_MIN_ACTIVE_PRECHARGE_LSB_TRASMIN);
		spd_tras |=
		    ((0xff &
		      read_spd(&dimm_config_table[0], 0,
			       DDR3_SPD_UPPER_NIBBLES_TRAS_TRC) & 0xf) << 8);
		spd_trc =
		    0xff & read_spd(&dimm_config_table[0], 0,
				    DDR3_SPD_MIN_ACTIVE_REFRESH_LSB_TRCMIN);
		spd_trc |=
		    ((0xff &
		      read_spd(&dimm_config_table[0], 0,
			       DDR3_SPD_UPPER_NIBBLES_TRAS_TRC) & 0xf0) << 4);
		spd_trfc =
		    0xff & read_spd(&dimm_config_table[0], 0,
				    DDR3_SPD_MIN_REFRESH_RECOVERY_LSB_TRFCMIN);
		spd_trfc |=
		    ((0xff &
		      read_spd(&dimm_config_table[0], 0,
			       DDR3_SPD_MIN_REFRESH_RECOVERY_MSB_TRFCMIN)) <<
		     8);
		spd_twtr =
		    0xff & read_spd(&dimm_config_table[0], 0,
				DDR3_SPD_MIN_INTERNAL_WRITE_READ_CMD_TWTRMIN);
		spd_trtp =
		    0xff & read_spd(&dimm_config_table[0], 0,
			DDR3_SPD_MIN_INTERNAL_READ_PRECHARGE_CMD_TRTPMIN);
		spd_tfaw =
		    0xff & read_spd(&dimm_config_table[0], 0,
				    DDR3_SPD_MIN_FOUR_ACTIVE_WINDOW_TFAWMIN);
		spd_tfaw |=
		    ((0xff &
		      read_spd(&dimm_config_table[0], 0,
			       DDR3_SPD_UPPER_NIBBLE_TFAW) & 0xf) << 8);
		spd_addr_mirror =
		    0xff & read_spd(&dimm_config_table[0], 0,
				    DDR3_SPD_ADDRESS_MAPPING) & 0x1;
		/* Only address mirror unbuffered dimms.  */
		spd_addr_mirror = spd_addr_mirror && !spd_rdimm;
		ftb_dividend =
		    read_spd(&dimm_config_table[0], 0,
			     DDR3_SPD_FINE_TIMEBASE_DIVIDEND_DIVISOR) >> 4;
		ftb_divisor =
		    read_spd(&dimm_config_table[0], 0,
			     DDR3_SPD_FINE_TIMEBASE_DIVIDEND_DIVISOR) & 0xf;
		/* Make sure that it is not 0 */
		ftb_divisor = (ftb_divisor == 0) ? 1 : ftb_divisor;

		debug("spd_twr         : %#06x\n", spd_twr);
		debug("spd_trcd        : %#06x\n", spd_trcd);
		debug("spd_trrd        : %#06x\n", spd_trrd);
		debug("spd_trp         : %#06x\n", spd_trp);
		debug("spd_tras        : %#06x\n", spd_tras);
		debug("spd_trc         : %#06x\n", spd_trc);
		debug("spd_trfc        : %#06x\n", spd_trfc);
		debug("spd_twtr        : %#06x\n", spd_twtr);
		debug("spd_trtp        : %#06x\n", spd_trtp);
		debug("spd_tfaw        : %#06x\n", spd_tfaw);
		debug("spd_addr_mirror : %#06x\n", spd_addr_mirror);

		mtb_psec = spd_mtb_dividend * 1000 / spd_mtb_divisor;
		taamin = mtb_psec * spd_taa_min;
		taamin += ftb_dividend *
			(signed char)read_spd(&dimm_config_table[0],
				0, DDR3_SPD_MIN_CAS_LATENCY_FINE_TAAMIN) /
			ftb_divisor;
		tckmin = mtb_psec * spd_tck_min;
		tckmin += ftb_dividend *
			(signed char)read_spd(&dimm_config_table[0],
				0, DDR3_SPD_MINIMUM_CYCLE_TIME_FINE_TCKMIN) /
			ftb_divisor;

		twr = spd_twr * mtb_psec;
		trcd = spd_trcd * mtb_psec;
		trrd = spd_trrd * mtb_psec;
		trp = spd_trp * mtb_psec;
		tras = spd_tras * mtb_psec;
		trc = spd_trc * mtb_psec;
		trfc = spd_trfc * mtb_psec;
		if (octeon_is_cpuid(OCTEON_CN78XX_PASS2_X) && trfc < 260000) {
			// default to this - because it works...
			int new_trfc = 260000;

			s = env_get("ddr_trfc");
			if (s) {
				new_trfc = simple_strtoul(s, NULL, 0);
				printf("Parameter found in environment. ddr_trfc = %d\n",
				       new_trfc);
				if (new_trfc < 160000 || new_trfc > 260000) {
					// back to default if out of range
					new_trfc = 260000;
				}
			}
			debug("N%d.LMC%d: Adjusting tRFC from %d to %d, for CN78XX Pass 2.x\n",
			      node, if_num, trfc, new_trfc);
			trfc = new_trfc;
		}

		twtr = spd_twtr * mtb_psec;
		trtp = spd_trtp * mtb_psec;
		tfaw = spd_tfaw * mtb_psec;

		debug("Medium Timebase (MTB)                         : %6d ps\n",
		      mtb_psec);
		debug("Minimum Cycle Time (tckmin)                   : %6d ps (%ld MT/s)\n",
		      tckmin, pretty_psecs_to_mts(tckmin));
		debug("Minimum CAS Latency Time (taamin)             : %6d ps\n",
		      taamin);
		debug("Write Recovery Time (tWR)                     : %6d ps\n",
		      twr);
		debug("Minimum RAS to CAS delay (tRCD)               : %6d ps\n",
		      trcd);
		debug("Minimum Row Active to Row Active delay (tRRD) : %6d ps\n",
		      trrd);
		debug("Minimum Row Precharge Delay (tRP)             : %6d ps\n",
		      trp);
		debug("Minimum Active to Precharge (tRAS)            : %6d ps\n",
		      tras);
		debug("Minimum Active to Active/Refresh Delay (tRC)  : %6d ps\n",
		      trc);
		debug("Minimum Refresh Recovery Delay (tRFC)         : %6d ps\n",
		      trfc);
		debug("Internal write to read command delay (tWTR)   : %6d ps\n",
		      twtr);
		debug("Min Internal Rd to Precharge Cmd Delay (tRTP) : %6d ps\n",
		      trtp);
		debug("Minimum Four Activate Window Delay (tFAW)     : %6d ps\n",
		      tfaw);
	}

	/*
	 * When the cycle time is within 1 psec of the minimum accept it
	 * as a slight rounding error and adjust it to exactly the minimum
	 * cycle time. This avoids an unnecessary warning.
	 */
	if (abs(tclk_psecs - tckmin) < 2)
		tclk_psecs = tckmin;

	if (tclk_psecs < (u64)tckmin) {
		printf("WARNING!!!!: DDR Clock Rate (tCLK: %ld) exceeds DIMM specifications (tckmin: %ld)!!!!\n",
		       tclk_psecs, (ulong)tckmin);
	}

	debug("DDR Clock Rate (tCLK)                         : %6ld ps\n",
	      tclk_psecs);
	debug("Core Clock Rate (eCLK)                        : %6ld ps\n",
	      eclk_psecs);

	s = env_get("ddr_use_ecc");
	if (s) {
		use_ecc = !!simple_strtoul(s, NULL, 0);
		printf("Parameter found in environment. ddr_use_ecc = %d\n",
		       use_ecc);
	}
	use_ecc = use_ecc && spd_ecc;

	if_bytemask = if_64b ? (use_ecc ? 0x1ff : 0xff)
	    : (use_ecc ? 0x01f : 0x0f);

	debug("DRAM Interface width: %d bits %s bytemask 0x%03x\n",
	      if_64b ? 64 : 32, use_ecc ? "+ECC" : "", if_bytemask);

	debug("\n------ Board Custom Configuration Settings ------\n");
	debug("%-45s : %d\n", "MIN_RTT_NOM_IDX   ", c_cfg->min_rtt_nom_idx);
	debug("%-45s : %d\n", "MAX_RTT_NOM_IDX   ", c_cfg->max_rtt_nom_idx);
	debug("%-45s : %d\n", "MIN_RODT_CTL      ", c_cfg->min_rodt_ctl);
	debug("%-45s : %d\n", "MAX_RODT_CTL      ", c_cfg->max_rodt_ctl);
	debug("%-45s : %d\n", "MIN_CAS_LATENCY   ", c_cfg->min_cas_latency);
	debug("%-45s : %d\n", "OFFSET_EN         ", c_cfg->offset_en);
	debug("%-45s : %d\n", "OFFSET_UDIMM      ", c_cfg->offset_udimm);
	debug("%-45s : %d\n", "OFFSET_RDIMM      ", c_cfg->offset_rdimm);
	debug("%-45s : %d\n", "DDR_RTT_NOM_AUTO  ", c_cfg->ddr_rtt_nom_auto);
	debug("%-45s : %d\n", "DDR_RODT_CTL_AUTO ", c_cfg->ddr_rodt_ctl_auto);
	if (spd_rdimm)
		debug("%-45s : %d\n", "RLEVEL_COMP_OFFSET",
		      c_cfg->rlevel_comp_offset_rdimm);
	else
		debug("%-45s : %d\n", "RLEVEL_COMP_OFFSET",
		      c_cfg->rlevel_comp_offset_udimm);
	debug("%-45s : %d\n", "RLEVEL_COMPUTE    ", c_cfg->rlevel_compute);
	debug("%-45s : %d\n", "DDR2T_UDIMM       ", c_cfg->ddr2t_udimm);
	debug("%-45s : %d\n", "DDR2T_RDIMM       ", c_cfg->ddr2t_rdimm);
	debug("%-45s : %d\n", "FPRCH2            ", c_cfg->fprch2);
	debug("%-45s : %d\n", "PTUNE_OFFSET      ", c_cfg->ptune_offset);
	debug("%-45s : %d\n", "NTUNE_OFFSET      ", c_cfg->ntune_offset);
	debug("-------------------------------------------------\n");

	cl = divide_roundup(taamin, tclk_psecs);

	debug("Desired CAS Latency                           : %6d\n", cl);

	min_cas_latency = c_cfg->min_cas_latency;

	s = lookup_env(priv, "ddr_min_cas_latency");
	if (s)
		min_cas_latency = simple_strtoul(s, NULL, 0);

	debug("CAS Latencies supported in DIMM               :");
	base_cl = (ddr_type == DDR4_DRAM) ? 7 : 4;
	for (i = 0; i < 32; ++i) {
		if ((spd_cas_latency >> i) & 1) {
			debug(" %d", i + base_cl);
			max_cas_latency = i + base_cl;
			if (min_cas_latency == 0)
				min_cas_latency = i + base_cl;
		}
	}
	debug("\n");

	/*
	 * Use relaxed timing when running slower than the minimum
	 * supported speed.  Adjust timing to match the smallest supported
	 * CAS Latency.
	 */
	if (min_cas_latency > cl) {
		ulong adjusted_tclk = taamin / min_cas_latency;

		cl = min_cas_latency;
		debug("Slow clock speed. Adjusting timing: tClk = %ld, Adjusted tClk = %ld\n",
		      tclk_psecs, adjusted_tclk);
		tclk_psecs = adjusted_tclk;
	}

	s = env_get("ddr_cas_latency");
	if (s) {
		override_cas_latency = simple_strtoul(s, NULL, 0);
		printf("Parameter found in environment. ddr_cas_latency = %d\n",
		       override_cas_latency);
	}

	/* Make sure that the selected cas latency is legal */
	for (i = (cl - base_cl); i < 32; ++i) {
		if ((spd_cas_latency >> i) & 1) {
			cl = i + base_cl;
			break;
		}
	}

	if (max_cas_latency < cl)
		cl = max_cas_latency;

	if (override_cas_latency != 0)
		cl = override_cas_latency;

	debug("CAS Latency                                   : %6d\n", cl);

	if ((cl * tckmin) > 20000) {
		debug("(CLactual * tckmin) = %d exceeds 20 ns\n",
		      (cl * tckmin));
	}

	if (tclk_psecs < (ulong)tckmin) {
		printf("WARNING!!!!!!: DDR3 Clock Rate (tCLK: %ld) exceeds DIMM specifications (tckmin:%ld)!!!!!!!!\n",
		       tclk_psecs, (ulong)tckmin);
	}

	if (num_banks != 4 && num_banks != 8 && num_banks != 16) {
		printf("Unsupported number of banks %d. Must be 4 or 8.\n",
		       num_banks);
		++fatal_error;
	}

	if (num_ranks != 1 && num_ranks != 2 && num_ranks != 4) {
		printf("Unsupported number of ranks: %d\n", num_ranks);
		++fatal_error;
	}

	if (octeon_is_cpuid(OCTEON_CN78XX) ||
	    octeon_is_cpuid(OCTEON_CN73XX) ||
	    octeon_is_cpuid(OCTEON_CNF75XX)) {
		if (dram_width != 8 && dram_width != 16 && dram_width != 4) {
			printf("Unsupported SDRAM Width, %d.  Must be 4, 8 or 16.\n",
			       dram_width);
			++fatal_error;
		}
	} else if (dram_width != 8 && dram_width != 16) {
		printf("Unsupported SDRAM Width, %d.  Must be 8 or 16.\n",
		       dram_width);
		++fatal_error;
	}

	/*
	 ** Bail out here if things are not copasetic.
	 */
	if (fatal_error)
		return (-1);

	/*
	 * 4.8.4 LMC RESET Initialization
	 *
	 * The purpose of this step is to assert/deassert the RESET# pin at the
	 * DDR3/DDR4 parts.
	 *
	 * This LMC RESET step is done for all enabled LMCs.
	 */
	perform_lmc_reset(priv, node, if_num);

	// Make sure scrambling is disabled during init...
	ctrl.u64 = lmc_rd(priv, CVMX_LMCX_CONTROL(if_num));
	ctrl.s.scramble_ena = 0;
	lmc_wr(priv, CVMX_LMCX_CONTROL(if_num), ctrl.u64);

	lmc_wr(priv, CVMX_LMCX_SCRAMBLE_CFG0(if_num), 0);
	lmc_wr(priv, CVMX_LMCX_SCRAMBLE_CFG1(if_num), 0);
	if (!octeon_is_cpuid(OCTEON_CN78XX_PASS1_X))
		lmc_wr(priv, CVMX_LMCX_SCRAMBLE_CFG2(if_num), 0);

	odt_idx = min(dimm_count - 1, 3);

	switch (num_ranks) {
	case 1:
		odt_config = odt_1rank_config;
		break;
	case 2:
		odt_config = odt_2rank_config;
		break;
	case 4:
		odt_config = odt_4rank_config;
		break;
	default:
		odt_config = disable_odt_config;
		printf("Unsupported number of ranks: %d\n", num_ranks);
		++fatal_error;
	}

	/*
	 * 4.8.5 Early LMC Initialization
	 *
	 * All of DDR PLL, LMC CK, and LMC DRESET initializations must be
	 * completed prior to starting this LMC initialization sequence.
	 *
	 * Perform the following five substeps for early LMC initialization:
	 *
	 * 1. Software must ensure there are no pending DRAM transactions.
	 *
	 * 2. Write LMC(0)_CONFIG, LMC(0)_CONTROL, LMC(0)_TIMING_PARAMS0,
	 *    LMC(0)_TIMING_PARAMS1, LMC(0)_MODEREG_PARAMS0,
	 *    LMC(0)_MODEREG_PARAMS1, LMC(0)_DUAL_MEMCFG, LMC(0)_NXM,
	 *    LMC(0)_WODT_MASK, LMC(0)_RODT_MASK, LMC(0)_COMP_CTL2,
	 *    LMC(0)_PHY_CTL, LMC(0)_DIMM0/1_PARAMS, and LMC(0)_DIMM_CTL with
	 *    appropriate values. All sections in this chapter can be used to
	 *    derive proper register settings.
	 */

	/* LMC(0)_CONFIG */
	lmc_config(priv);

	/* LMC(0)_CONTROL */
	lmc_control(priv);

	/* LMC(0)_TIMING_PARAMS0 */
	lmc_timing_params0(priv);

	/* LMC(0)_TIMING_PARAMS1 */
	lmc_timing_params1(priv);

	/* LMC(0)_TIMING_PARAMS2 */
	lmc_timing_params2(priv);

	/* LMC(0)_MODEREG_PARAMS0 */
	lmc_modereg_params0(priv);

	/* LMC(0)_MODEREG_PARAMS1 */
	lmc_modereg_params1(priv);

	/* LMC(0)_MODEREG_PARAMS2 */
	lmc_modereg_params2(priv);

	/* LMC(0)_MODEREG_PARAMS3 */
	lmc_modereg_params3(priv);

	/* LMC(0)_NXM */
	lmc_nxm(priv);

	/* LMC(0)_WODT_MASK */
	lmc_wodt_mask(priv);

	/* LMC(0)_RODT_MASK */
	lmc_rodt_mask(priv);

	/* LMC(0)_COMP_CTL2 */
	lmc_comp_ctl2(priv);

	/* LMC(0)_PHY_CTL */
	lmc_phy_ctl(priv);

	/* LMC(0)_EXT_CONFIG */
	lmc_ext_config(priv);

	/* LMC(0)_EXT_CONFIG2 */
	lmc_ext_config2(priv);

	/* LMC(0)_DIMM0/1_PARAMS */
	lmc_dimm01_params(priv);

	ret = lmc_rank_init(priv);
	if (ret < 0)
		return 0;	/* 0 indicates problem */

	lmc_config_2(priv);

	lmc_write_leveling(priv);

	lmc_read_leveling(priv);

	lmc_workaround(priv);

	ret = lmc_sw_write_leveling(priv);
	if (ret < 0)
		return 0;	/* 0 indicates problem */

	// this sometimes causes stack overflow crashes..
	// display only for DDR4 RDIMMs.
	if (ddr_type == DDR4_DRAM && spd_rdimm) {
		int i;

		for (i = 0; i < 3; i += 2)	// just pages 0 and 2 for now..
			display_mpr_page(priv, rank_mask, if_num, i);
	}

	lmc_dll(priv);

	lmc_workaround_2(priv);

	lmc_final(priv);

	lmc_scrambling(priv);

	return mem_size_mbytes;
}

/////    HW-assist byte DLL offset tuning   //////

static int cvmx_dram_get_num_lmc(struct ddr_priv *priv)
{
	union cvmx_lmcx_dll_ctl2 lmcx_dll_ctl2;

	if (octeon_is_cpuid(OCTEON_CN70XX))
		return 1;

	if (octeon_is_cpuid(OCTEON_CN73XX) || octeon_is_cpuid(OCTEON_CNF75XX)) {
		// sample LMC1
		lmcx_dll_ctl2.u64 = lmc_rd(priv, CVMX_LMCX_DLL_CTL2(1));
		if (lmcx_dll_ctl2.cn78xx.intf_en)
			return 2;
		else
			return 1;
	}

	// for CN78XX, LMCs are always active in pairs, and always LMC0/1
	// so, we sample LMC2 to see if 2 and 3 are active
	lmcx_dll_ctl2.u64 = lmc_rd(priv, CVMX_LMCX_DLL_CTL2(2));
	if (lmcx_dll_ctl2.cn78xx.intf_en)
		return 4;
	else
		return 2;
}

// got to do these here, even though already defined in BDK

// all DDR3, and DDR4 x16 today, use only 3 bank bits;
// DDR4 x4 and x8 always have 4 bank bits
// NOTE: this will change in the future, when DDR4 x16 devices can
// come with 16 banks!! FIXME!!
static int cvmx_dram_get_num_bank_bits(struct ddr_priv *priv, int lmc)
{
	union cvmx_lmcx_dll_ctl2 lmcx_dll_ctl2;
	union cvmx_lmcx_config lmcx_config;
	union cvmx_lmcx_ddr_pll_ctl lmcx_ddr_pll_ctl;
	int bank_width;

	// can always read this
	lmcx_dll_ctl2.u64 = lmc_rd(priv, CVMX_LMCX_DLL_CTL2(lmc));

	if (lmcx_dll_ctl2.cn78xx.dreset)	// check LMCn
		return 0;

	lmcx_config.u64 = lmc_rd(priv, CVMX_LMCX_DLL_CTL2(lmc));
	lmcx_ddr_pll_ctl.u64 = lmc_rd(priv, CVMX_LMCX_DDR_PLL_CTL(lmc));

	bank_width = ((lmcx_ddr_pll_ctl.s.ddr4_mode != 0) &&
		      (lmcx_config.s.bg2_enable)) ? 4 : 3;

	return bank_width;
}

#define EXTRACT(v, lsb, width) (((v) >> (lsb)) & ((1ull << (width)) - 1))
#define ADDRESS_HOLE 0x10000000ULL

static void cvmx_dram_address_extract_info(struct ddr_priv *priv, u64 address,
					   int *node, int *lmc, int *dimm,
					   int *prank, int *lrank, int *bank,
					   int *row, int *col)
{
	int bank_lsb, xbits;
	union cvmx_l2c_ctl l2c_ctl;
	union cvmx_lmcx_config lmcx_config;
	union cvmx_lmcx_control lmcx_control;
	union cvmx_lmcx_ext_config ext_config;
	int bitno = (octeon_is_cpuid(OCTEON_CN7XXX)) ? 20 : 18;
	int bank_width;
	int dimm_lsb;
	int dimm_width;
	int prank_lsb, lrank_lsb;
	int prank_width, lrank_width;
	int row_lsb;
	int row_width;
	int col_hi_lsb;
	int col_hi_width;
	int col_hi;

	if (octeon_is_cpuid(OCTEON_CN73XX) || octeon_is_cpuid(OCTEON_CNF75XX))
		bitno = 18;

	*node = EXTRACT(address, 40, 2);	/* Address bits [41:40] */

	address &= (1ULL << 40) - 1;	// lop off any node bits or above
	if (address >= ADDRESS_HOLE)	// adjust down if at HOLE or above
		address -= ADDRESS_HOLE;

	/* Determine the LMC controllers */
	l2c_ctl.u64 = l2c_rd(priv, CVMX_L2C_CTL_REL);

	/* xbits depends on number of LMCs */
	xbits = cvmx_dram_get_num_lmc(priv) >> 1;	// 4->2, 2->1, 1->0
	bank_lsb = 7 + xbits;

	/* LMC number is probably aliased */
	if (l2c_ctl.s.disidxalias) {
		*lmc = EXTRACT(address, 7, xbits);
	}  else {
		*lmc = EXTRACT(address, 7, xbits) ^
			EXTRACT(address, bitno, xbits) ^
			EXTRACT(address, 12, xbits);
	}

	/* Figure out the bank field width */
	lmcx_config.u64 = lmc_rd(priv, CVMX_LMCX_CONFIG(*lmc));
	ext_config.u64 = lmc_rd(priv, CVMX_LMCX_EXT_CONFIG(*lmc));
	bank_width = cvmx_dram_get_num_bank_bits(priv, *lmc);

	/* Extract additional info from the LMC_CONFIG CSR */
	dimm_lsb = 28 + lmcx_config.s.pbank_lsb + xbits;
	dimm_width = 40 - dimm_lsb;
	prank_lsb = dimm_lsb - lmcx_config.s.rank_ena;
	prank_width = dimm_lsb - prank_lsb;
	lrank_lsb = prank_lsb - ext_config.s.dimm0_cid;
	lrank_width = prank_lsb - lrank_lsb;
	row_lsb = 14 + lmcx_config.s.row_lsb + xbits;
	row_width = lrank_lsb - row_lsb;
	col_hi_lsb = bank_lsb + bank_width;
	col_hi_width = row_lsb - col_hi_lsb;

	/* Extract the parts of the address */
	*dimm = EXTRACT(address, dimm_lsb, dimm_width);
	*prank = EXTRACT(address, prank_lsb, prank_width);
	*lrank = EXTRACT(address, lrank_lsb, lrank_width);
	*row = EXTRACT(address, row_lsb, row_width);

	/* bank calculation may be aliased... */
	lmcx_control.u64 = lmc_rd(priv, CVMX_LMCX_CONTROL(*lmc));
	if (lmcx_control.s.xor_bank) {
		*bank = EXTRACT(address, bank_lsb, bank_width) ^
			EXTRACT(address, 12 + xbits, bank_width);
	} else {
		*bank = EXTRACT(address, bank_lsb, bank_width);
	}

	/* LMC number already extracted */
	col_hi = EXTRACT(address, col_hi_lsb, col_hi_width);
	*col = EXTRACT(address, 3, 4) | (col_hi << 4);
	/* Bus byte is address bits [2:0]. Unused here */
}

// end of added workarounds

// NOTE: "mode" argument:
//         DBTRAIN_TEST: for testing using GP patterns, includes ECC
//         DBTRAIN_DBI:  for DBI deskew training behavior (uses GP patterns)
//         DBTRAIN_LFSR: for testing using LFSR patterns, includes ECC
// NOTE: trust the caller to specify the correct/supported mode
//
static int test_dram_byte_hw(struct ddr_priv *priv, int if_num, u64 p,
			     int mode, u64 *xor_data)
{
	u64 p1;
	u64 k;
	int errors = 0;

	u64 mpr_data0, mpr_data1;
	u64 bad_bits[2] = { 0, 0 };

	int node_address, lmc, dimm;
	int prank, lrank;
	int bank, row, col;
	int save_or_dis;
	int byte;
	int ba_loop, ba_bits;

	union cvmx_lmcx_rlevel_ctl rlevel_ctl;
	union cvmx_lmcx_dbtrain_ctl dbtrain_ctl;
	union cvmx_lmcx_phy_ctl phy_ctl;

	int biter_errs;

	// FIXME: K iterations set to 4 for now.
	// FIXME: decrement to increase interations.
	// FIXME: must be no less than 22 to stay above an LMC hash field.
	int kshift = 27;

	const char *s;
	int node = 0;

	// allow override default setting for kshift
	s = env_get("ddr_tune_set_kshift");
	if (s) {
		int temp = simple_strtoul(s, NULL, 0);

		if (temp < 22 || temp > 28) {
			debug("N%d.LMC%d: ILLEGAL override of kshift to %d, using default %d\n",
			      node, if_num, temp, kshift);
		} else {
			debug("N%d.LMC%d: overriding kshift (%d) to %d\n",
			      node, if_num, kshift, temp);
			kshift = temp;
		}
	}

	/*
	 * 1) Make sure that RLEVEL_CTL[OR_DIS] = 0.
	 */
	rlevel_ctl.u64 = lmc_rd(priv, CVMX_LMCX_RLEVEL_CTL(if_num));
	save_or_dis = rlevel_ctl.s.or_dis;
	/* or_dis must be disabled for this sequence */
	rlevel_ctl.s.or_dis = 0;
	lmc_wr(priv, CVMX_LMCX_RLEVEL_CTL(if_num), rlevel_ctl.u64);

	/*
	 * NOTE: this step done in the calling routine(s)...
	 * 3) Setup GENERAL_PURPOSE[0-2] registers with the data pattern
	 * of choice.
	 * a. GENERAL_PURPOSE0[DATA<63:0>] – sets the initial lower
	 * (rising edge) 64 bits of data.
	 * b. GENERAL_PURPOSE1[DATA<63:0>] – sets the initial upper
	 * (falling edge) 64 bits of data.
	 * c. GENERAL_PURPOSE2[DATA<15:0>] – sets the initial lower
	 * (rising edge <7:0>) and upper (falling edge <15:8>) ECC data.
	 */

	// final address must include LMC and node
	p |= (if_num << 7);	/* Map address into proper interface */
	p |= (u64)node << CVMX_NODE_MEM_SHIFT;	// map to node

	/*
	 * Add base offset to both test regions to not clobber u-boot stuff
	 * when running from L2 for NAND boot.
	 */
	p += 0x20000000;	// offset to 512MB, ie above THE HOLE!!!
	p |= 1ull << 63;	// needed for OCTEON

	errors = 0;

	cvmx_dram_address_extract_info(priv, p, &node_address, &lmc, &dimm,
				       &prank, &lrank, &bank, &row, &col);
	debug("%s: START at A:0x%012llx, N%d L%d D%d/%d R%d B%1x Row:%05x Col:%05x\n",
	      __func__, p, node_address, lmc, dimm, prank, lrank, bank,
	      row, col);

	// only check once per call, and ignore if no match...
	if ((int)node != node_address) {
		printf("ERROR: Node address mismatch\n");
		return 0;
	}
	if (lmc != if_num) {
		printf("ERROR: LMC address mismatch\n");
		return 0;
	}

	/*
	 * 7) Set PHY_CTL[PHY_RESET] = 1 (LMC automatically clears this as
	 * it’s a one-shot operation). This is to get into the habit of
	 * resetting PHY’s SILO to the original 0 location.
	 */
	phy_ctl.u64 = lmc_rd(priv, CVMX_LMCX_PHY_CTL(if_num));
	phy_ctl.s.phy_reset = 1;
	lmc_wr(priv, CVMX_LMCX_PHY_CTL(if_num), phy_ctl.u64);

	/*
	 * Walk through a range of addresses avoiding bits that alias
	 * interfaces on the CN88XX.
	 */

	// FIXME: want to try to keep the K increment from affecting the
	// LMC via hash, so keep it above bit 21 we also want to keep k
	// less than the base offset of bit 29 (512MB)

	for (k = 0; k < (1UL << 29); k += (1UL << kshift)) {
		// FIXME: the sequence will interate over 1/2 cacheline
		// FIXME: for each unit specified in "read_cmd_count",
		// FIXME: so, we setup each sequence to do the max cachelines
		// it can

		p1 = p + k;

		cvmx_dram_address_extract_info(priv, p1, &node_address, &lmc,
					       &dimm, &prank, &lrank, &bank,
					       &row, &col);

		/*
		 * 2) Setup the fields of the CSR DBTRAIN_CTL as follows:
		 * a. COL, ROW, BA, BG, PRANK points to the starting point
		 * of the address.
		 * You can just set them to all 0.
		 * b. RW_TRAIN – set this to 1.
		 * c. TCCD_L – set this to 0.
		 * d. READ_CMD_COUNT – instruct the sequence to the how many
		 * writes/reads.
		 * It is 5 bits field, so set to 31 of maximum # of r/w.
		 */
		dbtrain_ctl.u64 = lmc_rd(priv, CVMX_LMCX_DBTRAIN_CTL(if_num));
		dbtrain_ctl.s.column_a = col;
		dbtrain_ctl.s.row_a = row;
		dbtrain_ctl.s.bg = (bank >> 2) & 3;
		dbtrain_ctl.s.prank = (dimm * 2) + prank;	// FIXME?
		dbtrain_ctl.s.lrank = lrank;	// FIXME?
		dbtrain_ctl.s.activate = (mode == DBTRAIN_DBI);
		dbtrain_ctl.s.write_ena = 1;
		dbtrain_ctl.s.read_cmd_count = 31;	// max count pass 1.x
		if (octeon_is_cpuid(OCTEON_CN78XX_PASS2_X) ||
		    octeon_is_cpuid(OCTEON_CNF75XX)) {
			// max count on chips that support it
			dbtrain_ctl.s.cmd_count_ext = 3;
		} else {
			// max count pass 1.x
			dbtrain_ctl.s.cmd_count_ext = 0;
		}

		dbtrain_ctl.s.rw_train = 1;
		dbtrain_ctl.s.tccd_sel = (mode == DBTRAIN_DBI);
		// LFSR should only be on when chip supports it...
		dbtrain_ctl.s.lfsr_pattern_sel = (mode == DBTRAIN_LFSR) ? 1 : 0;

		biter_errs = 0;

		// for each address, iterate over the 4 "banks" in the BA
		for (ba_loop = 0, ba_bits = bank & 3;
		     ba_loop < 4; ba_loop++, ba_bits = (ba_bits + 1) & 3) {
			dbtrain_ctl.s.ba = ba_bits;
			lmc_wr(priv, CVMX_LMCX_DBTRAIN_CTL(if_num),
			       dbtrain_ctl.u64);

			/*
			 * We will use the RW_TRAINING sequence (14) for
			 * this task.
			 *
			 * 4) Kick off the sequence (SEQ_CTL[SEQ_SEL] = 14,
			 *    SEQ_CTL[INIT_START] = 1).
			 * 5) Poll on SEQ_CTL[SEQ_COMPLETE] for completion.
			 */
			oct3_ddr3_seq(priv, prank, if_num, 14);

			/*
			 * 6) Read MPR_DATA0 and MPR_DATA1 for results.
			 * a. MPR_DATA0[MPR_DATA<63:0>] – comparison results
			 *    for DQ63:DQ0. (1 means MATCH, 0 means FAIL).
			 * b. MPR_DATA1[MPR_DATA<7:0>] – comparison results
			 *    for ECC bit7:0.
			 */
			mpr_data0 = lmc_rd(priv, CVMX_LMCX_MPR_DATA0(if_num));
			mpr_data1 = lmc_rd(priv, CVMX_LMCX_MPR_DATA1(if_num));

			/*
			 * 7) Set PHY_CTL[PHY_RESET] = 1 (LMC automatically
			 * clears this as it’s a one-shot operation).
			 * This is to get into the habit of resetting PHY’s
			 * SILO to the original 0 location.
			 */
			phy_ctl.u64 = lmc_rd(priv, CVMX_LMCX_PHY_CTL(if_num));
			phy_ctl.s.phy_reset = 1;
			lmc_wr(priv, CVMX_LMCX_PHY_CTL(if_num), phy_ctl.u64);

			// bypass any error checking or updating when DBI mode
			if (mode == DBTRAIN_DBI)
				continue;

			// data bytes
			if (~mpr_data0) {
				for (byte = 0; byte < 8; byte++) {
					if ((~mpr_data0 >> (8 * byte)) & 0xffUL)
						biter_errs |= (1 << byte);
				}
				// accumulate bad bits
				bad_bits[0] |= ~mpr_data0;
			}

			// include ECC byte errors
			if (~mpr_data1 & 0xffUL) {
				biter_errs |= (1 << 8);
				bad_bits[1] |= ~mpr_data1 & 0xffUL;
			}
		}

		errors |= biter_errs;
	}			/* end for (k=...) */

	rlevel_ctl.s.or_dis = save_or_dis;
	lmc_wr(priv, CVMX_LMCX_RLEVEL_CTL(if_num), rlevel_ctl.u64);

	// send the bad bits back...
	if (mode != DBTRAIN_DBI && xor_data) {
		xor_data[0] = bad_bits[0];
		xor_data[1] = bad_bits[1];
	}

	return errors;
}

// setup default for byte test pattern array
// take these from the HRM section 6.9.13
static const u64 byte_pattern_0[] = {
	0xFFAAFFFFFF55FFFFULL,	// GP0
	0x55555555AAAAAAAAULL,	// GP1
	0xAA55AAAAULL,		// GP2
};

static const u64 byte_pattern_1[] = {
	0xFBF7EFDFBF7FFEFDULL,	// GP0
	0x0F1E3C78F0E1C387ULL,	// GP1
	0xF0E1BF7FULL,		// GP2
};

// this is from Andrew via LFSR with PRBS=0xFFFFAAAA
static const u64 byte_pattern_2[] = {
	0xEE55AADDEE55AADDULL,	// GP0
	0x55AADDEE55AADDEEULL,	// GP1
	0x55EEULL,		// GP2
};

// this is from Mike via LFSR with PRBS=0x4A519909
static const u64 byte_pattern_3[] = {
	0x0088CCEE0088CCEEULL,	// GP0
	0xBB552211BB552211ULL,	// GP1
	0xBB00ULL,		// GP2
};

static const u64 *byte_patterns[4] = {
	byte_pattern_0, byte_pattern_1, byte_pattern_2, byte_pattern_3
};

static const u32 lfsr_patterns[4] = {
	0xFFFFAAAAUL, 0x06000000UL, 0xAAAAFFFFUL, 0x4A519909UL
};

#define NUM_BYTE_PATTERNS 4

#define DEFAULT_BYTE_BURSTS 32	// compromise between time and rigor

static void setup_hw_pattern(struct ddr_priv *priv, int lmc,
			     const u64 *pattern_p)
{
	/*
	 * 3) Setup GENERAL_PURPOSE[0-2] registers with the data pattern
	 * of choice.
	 * a. GENERAL_PURPOSE0[DATA<63:0>] â sets the initial lower
	 *    (rising edge) 64 bits of data.
	 * b. GENERAL_PURPOSE1[DATA<63:0>] â sets the initial upper
	 *    (falling edge) 64 bits of data.
	 * c. GENERAL_PURPOSE2[DATA<15:0>] â sets the initial lower
	 *    (rising edge <7:0>) and upper
	 * (falling edge <15:8>) ECC data.
	 */
	lmc_wr(priv, CVMX_LMCX_GENERAL_PURPOSE0(lmc), pattern_p[0]);
	lmc_wr(priv, CVMX_LMCX_GENERAL_PURPOSE1(lmc), pattern_p[1]);
	lmc_wr(priv, CVMX_LMCX_GENERAL_PURPOSE2(lmc), pattern_p[2]);
}

static void setup_lfsr_pattern(struct ddr_priv *priv, int lmc, u32 data)
{
	union cvmx_lmcx_char_ctl char_ctl;
	u32 prbs;
	const char *s;

	s = env_get("ddr_lfsr_prbs");
	if (s)
		prbs = simple_strtoul(s, NULL, 0);
	else
		prbs = data;

	/*
	 * 2) DBTRAIN_CTL[LFSR_PATTERN_SEL] = 1
	 * here data comes from the LFSR generating a PRBS pattern
	 * CHAR_CTL.EN = 0
	 * CHAR_CTL.SEL = 0; // for PRBS
	 * CHAR_CTL.DR = 1;
	 * CHAR_CTL.PRBS = setup for whatever type of PRBS to send
	 * CHAR_CTL.SKEW_ON = 1;
	 */
	char_ctl.u64 = lmc_rd(priv, CVMX_LMCX_CHAR_CTL(lmc));
	char_ctl.s.en = 0;
	char_ctl.s.sel = 0;
	char_ctl.s.dr = 1;
	char_ctl.s.prbs = prbs;
	char_ctl.s.skew_on = 1;
	lmc_wr(priv, CVMX_LMCX_CHAR_CTL(lmc), char_ctl.u64);
}

static int choose_best_hw_patterns(int lmc, int mode)
{
	int new_mode = mode;
	const char *s;

	switch (mode) {
	case DBTRAIN_TEST:	// always choose LFSR if chip supports it
		if (octeon_is_cpuid(OCTEON_CN78XX_PASS2_X)) {
			int lfsr_enable = 1;

			s = env_get("ddr_allow_lfsr");
			if (s) {
				// override?
				lfsr_enable = !!strtoul(s, NULL, 0);
			}

			if (lfsr_enable)
				new_mode = DBTRAIN_LFSR;
		}
		break;

	case DBTRAIN_DBI:	// possibly can allow LFSR use?
		break;

	case DBTRAIN_LFSR:	// forced already
		if (!octeon_is_cpuid(OCTEON_CN78XX_PASS2_X)) {
			debug("ERROR: illegal HW assist mode %d\n", mode);
			new_mode = DBTRAIN_TEST;
		}
		break;

	default:
		debug("ERROR: unknown HW assist mode %d\n", mode);
	}

	if (new_mode != mode)
		debug("%s: changing mode %d to %d\n", __func__, mode, new_mode);

	return new_mode;
}

int run_best_hw_patterns(struct ddr_priv *priv, int lmc, u64 phys_addr,
			 int mode, u64 *xor_data)
{
	int pattern;
	const u64 *pattern_p;
	int errs, errors = 0;

	// FIXME? always choose LFSR if chip supports it???
	mode = choose_best_hw_patterns(lmc, mode);

	for (pattern = 0; pattern < NUM_BYTE_PATTERNS; pattern++) {
		if (mode == DBTRAIN_LFSR) {
			setup_lfsr_pattern(priv, lmc, lfsr_patterns[pattern]);
		} else {
			pattern_p = byte_patterns[pattern];
			setup_hw_pattern(priv, lmc, pattern_p);
		}
		errs = test_dram_byte_hw(priv, lmc, phys_addr, mode, xor_data);

		debug("%s: PATTERN %d at A:0x%012llx errors 0x%x\n",
		      __func__, pattern, phys_addr, errs);

		errors |= errs;
	}

	return errors;
}

static void hw_assist_test_dll_offset(struct ddr_priv *priv,
				      int dll_offset_mode, int lmc,
				      int bytelane,
				      int if_64b,
				      u64 dram_tune_rank_offset,
				      int dram_tune_byte_bursts)
{
	int byte_offset, new_best_offset[9];
	int rank_delay_start[4][9];
	int rank_delay_count[4][9];
	int rank_delay_best_start[4][9];
	int rank_delay_best_count[4][9];
	int errors[4], off_errors, tot_errors;
	int rank_mask, rankx, active_ranks;
	int pattern;
	const u64 *pattern_p;
	int byte;
	char *mode_str = (dll_offset_mode == 2) ? "Read" : "Write";
	int pat_best_offset[9];
	u64 phys_addr;
	int pat_beg, pat_end;
	int rank_beg, rank_end;
	int byte_lo, byte_hi;
	union cvmx_lmcx_config lmcx_config;
	u64 hw_rank_offset;
	int num_lmcs = cvmx_dram_get_num_lmc(priv);
	// FIXME? always choose LFSR if chip supports it???
	int mode = choose_best_hw_patterns(lmc, DBTRAIN_TEST);
	int node = 0;

	if (bytelane == 0x0A) {	// all bytelanes
		byte_lo = 0;
		byte_hi = 8;
	} else {		// just 1
		byte_lo = bytelane;
		byte_hi = bytelane;
	}

	lmcx_config.u64 = lmc_rd(priv, CVMX_LMCX_CONFIG(lmc));
	rank_mask = lmcx_config.s.init_status;

	// this should be correct for 1 or 2 ranks, 1 or 2 DIMMs
	hw_rank_offset =
	    1ull << (28 + lmcx_config.s.pbank_lsb - lmcx_config.s.rank_ena +
		     (num_lmcs / 2));

	debug("N%d: %s: starting LMC%d with rank offset 0x%016llx\n",
	      node, __func__, lmc, (unsigned long long)hw_rank_offset);

	// start of pattern loop
	// we do the set of tests for each pattern supplied...

	memset(new_best_offset, 0, sizeof(new_best_offset));
	for (pattern = 0; pattern < NUM_BYTE_PATTERNS; pattern++) {
		memset(pat_best_offset, 0, sizeof(pat_best_offset));

		if (mode == DBTRAIN_TEST) {
			pattern_p = byte_patterns[pattern];
			setup_hw_pattern(priv, lmc, pattern_p);
		} else {
			setup_lfsr_pattern(priv, lmc, lfsr_patterns[pattern]);
		}

		// now loop through all legal values for the DLL byte offset...

#define BYTE_OFFSET_INCR 3	// FIXME: make this tunable?

		tot_errors = 0;

		memset(rank_delay_count, 0, sizeof(rank_delay_count));
		memset(rank_delay_start, 0, sizeof(rank_delay_start));
		memset(rank_delay_best_count, 0, sizeof(rank_delay_best_count));
		memset(rank_delay_best_start, 0, sizeof(rank_delay_best_start));

		for (byte_offset = -63; byte_offset < 64;
		     byte_offset += BYTE_OFFSET_INCR) {
			// do the setup on the active LMC
			// set the bytelanes DLL offsets
			change_dll_offset_enable(priv, lmc, 0);
			// FIXME? bytelane?
			load_dll_offset(priv, lmc, dll_offset_mode,
					byte_offset, bytelane);
			change_dll_offset_enable(priv, lmc, 1);

			//bdk_watchdog_poke();

			// run the test on each rank
			// only 1 call per rank should be enough, let the
			// bursts, loops, etc, control the load...

			// errors for this byte_offset, all ranks
			off_errors = 0;

			active_ranks = 0;

			for (rankx = 0; rankx < 4; rankx++) {
				if (!(rank_mask & (1 << rankx)))
					continue;

				phys_addr = hw_rank_offset * active_ranks;
				// FIXME: now done by test_dram_byte_hw()
				//phys_addr |= (lmc << 7);
				//phys_addr |= (u64)node << CVMX_NODE_MEM_SHIFT;

				active_ranks++;

				// NOTE: return is a now a bitmask of the
				// erroring bytelanes.
				errors[rankx] =
				    test_dram_byte_hw(priv, lmc, phys_addr,
						      mode, NULL);

				// process any errors in the bytelane(s) that
				// are being tested
				for (byte = byte_lo; byte <= byte_hi; byte++) {
					// check errors
					// yes, an error in the byte lane in
					// this rank
					if (errors[rankx] & (1 << byte)) {
						off_errors |= (1 << byte);

						debug("N%d.LMC%d.R%d: Bytelane %d DLL %s Offset Test %3d: Address 0x%012llx errors\n",
						      node, lmc, rankx, byte,
						      mode_str, byte_offset,
						      phys_addr);

						// had started run
						if (rank_delay_count
						    [rankx][byte] > 0) {
							debug("N%d.LMC%d.R%d: Bytelane %d DLL %s Offset Test %3d: stopping a run here\n",
							      node, lmc, rankx,
							      byte, mode_str,
							      byte_offset);
							// stop now
							rank_delay_count
								[rankx][byte] =
								0;
						}
						// FIXME: else had not started
						// run - nothing else to do?
					} else {
						// no error in the byte lane
						// first success, set run start
						if (rank_delay_count[rankx]
						    [byte] == 0) {
							debug("N%d.LMC%d.R%d: Bytelane %d DLL %s Offset Test %3d: starting a run here\n",
							      node, lmc, rankx,
							      byte, mode_str,
							      byte_offset);
							rank_delay_start[rankx]
								[byte] =
								byte_offset;
						}
						// bump run length
						rank_delay_count[rankx][byte]
							+= BYTE_OFFSET_INCR;

						// is this now the biggest
						// window?
						if (rank_delay_count[rankx]
						    [byte] >
						    rank_delay_best_count[rankx]
						    [byte]) {
							rank_delay_best_count
							    [rankx][byte] =
							    rank_delay_count
							    [rankx][byte];
							rank_delay_best_start
							    [rankx][byte] =
							    rank_delay_start
							    [rankx][byte];
							debug("N%d.LMC%d.R%d: Bytelane %d DLL %s Offset Test %3d: updating best to %d/%d\n",
							      node, lmc, rankx,
							      byte, mode_str,
							      byte_offset,
							      rank_delay_best_start
							      [rankx][byte],
							      rank_delay_best_count
							      [rankx][byte]);
						}
					}
				}
			} /* for (rankx = 0; rankx < 4; rankx++) */

			tot_errors |= off_errors;
		}

		// set the bytelanes DLL offsets all back to 0
		change_dll_offset_enable(priv, lmc, 0);
		load_dll_offset(priv, lmc, dll_offset_mode, 0, bytelane);
		change_dll_offset_enable(priv, lmc, 1);

		// now choose the best byte_offsets for this pattern
		// according to the best windows of the tested ranks
		// calculate offset by constructing an average window
		// from the rank windows
		for (byte = byte_lo; byte <= byte_hi; byte++) {
			pat_beg = -999;
			pat_end = 999;

			for (rankx = 0; rankx < 4; rankx++) {
				if (!(rank_mask & (1 << rankx)))
					continue;

				rank_beg = rank_delay_best_start[rankx][byte];
				pat_beg = max(pat_beg, rank_beg);
				rank_end = rank_beg +
					rank_delay_best_count[rankx][byte] -
					BYTE_OFFSET_INCR;
				pat_end = min(pat_end, rank_end);

				debug("N%d.LMC%d.R%d: Bytelane %d DLL %s Offset Test:  Rank Window %3d:%3d\n",
				      node, lmc, rankx, byte, mode_str,
				      rank_beg, rank_end);

			}	/* for (rankx = 0; rankx < 4; rankx++) */

			pat_best_offset[byte] = (pat_end + pat_beg) / 2;

			// sum the pattern averages
			new_best_offset[byte] += pat_best_offset[byte];
		}

		// now print them on 1 line, descending order...
		debug("N%d.LMC%d: HW DLL %s Offset Pattern %d :",
		      node, lmc, mode_str, pattern);
		for (byte = byte_hi; byte >= byte_lo; --byte)
			debug(" %4d", pat_best_offset[byte]);
		debug("\n");
	}
	// end of pattern loop

	debug("N%d.LMC%d: HW DLL %s Offset Average  : ", node, lmc, mode_str);

	// print in decending byte index order
	for (byte = byte_hi; byte >= byte_lo; --byte) {
		// create the new average NINT
		new_best_offset[byte] = divide_nint(new_best_offset[byte],
						    NUM_BYTE_PATTERNS);

		// print the best offsets from all patterns

		// print just the offset of all the bytes
		if (bytelane == 0x0A)
			debug("%4d ", new_best_offset[byte]);
		else		// print the bytelanes also
			debug("(byte %d) %4d ", byte, new_best_offset[byte]);

		// done with testing, load up the best offsets we found...
		// disable offsets while we load...
		change_dll_offset_enable(priv, lmc, 0);
		load_dll_offset(priv, lmc, dll_offset_mode,
				new_best_offset[byte], byte);
		// re-enable the offsets now that we are done loading
		change_dll_offset_enable(priv, lmc, 1);
	}

	debug("\n");
}

/*
 * Automatically adjust the DLL offset for the selected bytelane using
 * hardware-assist
 */
static int perform_HW_dll_offset_tuning(struct ddr_priv *priv,
					int dll_offset_mode, int bytelane)
{
	int if_64b;
	int save_ecc_ena[4];
	union cvmx_lmcx_config lmc_config;
	int lmc, num_lmcs = cvmx_dram_get_num_lmc(priv);
	const char *s;
	int loops = 1, loop;
	int by;
	u64 dram_tune_rank_offset;
	int dram_tune_byte_bursts = DEFAULT_BYTE_BURSTS;
	int node = 0;

	// see if we want to do the tuning more than once per LMC...
	s = env_get("ddr_tune_ecc_loops");
	if (s)
		loops = strtoul(s, NULL, 0);

	// allow override of the test repeats (bursts)
	s = env_get("ddr_tune_byte_bursts");
	if (s)
		dram_tune_byte_bursts = strtoul(s, NULL, 10);

	// print current working values
	debug("N%d: H/W Tuning for bytelane %d will use %d loops, %d bursts, and %d patterns.\n",
	      node, bytelane, loops, dram_tune_byte_bursts, NUM_BYTE_PATTERNS);

	// FIXME? get flag from LMC0 only
	lmc_config.u64 = lmc_rd(priv, CVMX_LMCX_CONFIG(0));
	if_64b = !lmc_config.s.mode32b;

	// this should be correct for 1 or 2 ranks, 1 or 2 DIMMs
	dram_tune_rank_offset =
	    1ull << (28 + lmc_config.s.pbank_lsb - lmc_config.s.rank_ena +
		     (num_lmcs / 2));

	// do once for each active LMC

	for (lmc = 0; lmc < num_lmcs; lmc++) {
		debug("N%d: H/W Tuning: starting LMC%d bytelane %d tune.\n",
		      node, lmc, bytelane);

		/* Enable ECC for the HW tests */
		// NOTE: we do enable ECC, but the HW tests used will not
		// generate "visible" errors
		lmc_config.u64 = lmc_rd(priv, CVMX_LMCX_CONFIG(lmc));
		save_ecc_ena[lmc] = lmc_config.s.ecc_ena;
		lmc_config.s.ecc_ena = 1;
		lmc_wr(priv, CVMX_LMCX_CONFIG(lmc), lmc_config.u64);
		lmc_config.u64 = lmc_rd(priv, CVMX_LMCX_CONFIG(lmc));

		// testing is done on a single LMC at a time
		// FIXME: for now, loop here to show what happens multiple times
		for (loop = 0; loop < loops; loop++) {
			/* Perform DLL offset tuning */
			hw_assist_test_dll_offset(priv, 2 /* 2=read */, lmc,
						  bytelane,
						  if_64b, dram_tune_rank_offset,
						  dram_tune_byte_bursts);
		}

		// perform cleanup on active LMC
		debug("N%d: H/W Tuning: finishing LMC%d bytelane %d tune.\n",
		      node, lmc, bytelane);

		/* Restore ECC for DRAM tests */
		lmc_config.u64 = lmc_rd(priv, CVMX_LMCX_CONFIG(lmc));
		lmc_config.s.ecc_ena = save_ecc_ena[lmc];
		lmc_wr(priv, CVMX_LMCX_CONFIG(lmc), lmc_config.u64);
		lmc_config.u64 = lmc_rd(priv, CVMX_LMCX_CONFIG(lmc));

		// finally, see if there are any read offset overrides
		// after tuning
		for (by = 0; by < 9; by++) {
			s = lookup_env(priv, "ddr%d_tune_byte%d", lmc, by);
			if (s) {
				int dllro = strtoul(s, NULL, 10);

				change_dll_offset_enable(priv, lmc, 0);
				load_dll_offset(priv, lmc, 2, dllro, by);
				change_dll_offset_enable(priv, lmc, 1);
			}
		}

	}			/* for (lmc = 0; lmc < num_lmcs; lmc++) */

	// finish up...

	return 0;

}				/* perform_HW_dll_offset_tuning */

// this routine simply makes the calls to the tuning routine and returns
// any errors
static int cvmx_tune_node(struct ddr_priv *priv)
{
	int errs, tot_errs;
	int do_dllwo = 0;	// default to NO
	const char *str;
	int node = 0;

	// Automatically tune the data and ECC byte DLL read offsets
	debug("N%d: Starting DLL Read Offset Tuning for LMCs\n", node);
	errs = perform_HW_dll_offset_tuning(priv, 2, 0x0A /* all bytelanes */);
	debug("N%d: Finished DLL Read Offset Tuning for LMCs, %d errors\n",
	      node, errs);
	tot_errs = errs;

	// disabled by default for now, does not seem to be needed?
	// Automatically tune the data and ECC byte DLL write offsets
	// allow override of default setting
	str = env_get("ddr_tune_write_offsets");
	if (str)
		do_dllwo = !!strtoul(str, NULL, 0);
	if (do_dllwo) {
		debug("N%d: Starting DLL Write Offset Tuning for LMCs\n", node);
		errs =
		    perform_HW_dll_offset_tuning(priv, 1,
						 0x0A /* all bytelanes */);
		debug("N%d: Finished DLL Write Offset Tuning for LMCs, %d errors\n",
		      node, errs);
		tot_errs += errs;
	}

	return tot_errs;
}

// this routine makes the calls to the tuning routines when criteria are met
// intended to be called for automated tuning, to apply filtering...

#define IS_DDR4  1
#define IS_DDR3  0
#define IS_RDIMM 1
#define IS_UDIMM 0
#define IS_1SLOT 1
#define IS_2SLOT 0

// FIXME: DDR3 is not tuned
static const u32 ddr_speed_filter[2][2][2] = {
	[IS_DDR4] = {
		     [IS_RDIMM] = {
				   [IS_1SLOT] = 940,
				   [IS_2SLOT] = 800},
		     [IS_UDIMM] = {
				   [IS_1SLOT] = 1050,
				   [IS_2SLOT] = 940},
		      },
	[IS_DDR3] = {
		     [IS_RDIMM] = {
				   [IS_1SLOT] = 0,	// disabled
				   [IS_2SLOT] = 0	// disabled
				   },
		     [IS_UDIMM] = {
				   [IS_1SLOT] = 0,	// disabled
				   [IS_2SLOT] = 0	// disabled
				}
		}
};

void cvmx_maybe_tune_node(struct ddr_priv *priv, u32 ddr_speed)
{
	const char *s;
	union cvmx_lmcx_config lmc_config;
	union cvmx_lmcx_control lmc_control;
	union cvmx_lmcx_ddr_pll_ctl lmc_ddr_pll_ctl;
	int is_ddr4;
	int is_rdimm;
	int is_1slot;
	int do_tune = 0;
	u32 ddr_min_speed;
	int node = 0;

	// scale it down from Hz to MHz
	ddr_speed = divide_nint(ddr_speed, 1000000);

	// FIXME: allow an override here so that all configs can be tuned
	// or none
	// If the envvar is defined, always either force it or avoid it
	// accordingly
	s = env_get("ddr_tune_all_configs");
	if (s) {
		do_tune = !!strtoul(s, NULL, 0);
		printf("N%d: DRAM auto-tuning %s.\n", node,
		       (do_tune) ? "forced" : "disabled");
		if (do_tune)
			cvmx_tune_node(priv);

		return;
	}

	// filter the tuning calls here...
	// determine if we should/can run automatically for this configuration
	//
	// FIXME: tune only when the configuration indicates it will help:
	//    DDR type, RDIMM or UDIMM, 1-slot or 2-slot, and speed
	//
	lmc_config.u64 = lmc_rd(priv, CVMX_LMCX_CONFIG(0));	// sample LMC0
	lmc_control.u64 = lmc_rd(priv, CVMX_LMCX_CONTROL(0));	// sample LMC0
	// sample LMC0
	lmc_ddr_pll_ctl.u64 = lmc_rd(priv, CVMX_LMCX_DDR_PLL_CTL(0));

	is_ddr4 = (lmc_ddr_pll_ctl.s.ddr4_mode != 0);
	is_rdimm = (lmc_control.s.rdimm_ena != 0);
	// HACK, should do better
	is_1slot = (lmc_config.s.init_status < 4);

	ddr_min_speed = ddr_speed_filter[is_ddr4][is_rdimm][is_1slot];
	do_tune = ((ddr_min_speed != 0) && (ddr_speed > ddr_min_speed));

	debug("N%d: DDR%d %cDIMM %d-slot at %d MHz %s eligible for auto-tuning.\n",
	      node, (is_ddr4) ? 4 : 3, (is_rdimm) ? 'R' : 'U',
	      (is_1slot) ? 1 : 2, ddr_speed, (do_tune) ? "is" : "is not");

	// call the tuning routine, filtering is done...
	if (do_tune)
		cvmx_tune_node(priv);
}

/*
 * first pattern example:
 * GENERAL_PURPOSE0.DATA == 64'h00ff00ff00ff00ff;
 * GENERAL_PURPOSE1.DATA == 64'h00ff00ff00ff00ff;
 * GENERAL_PURPOSE0.DATA == 16'h0000;
 */

static const u64 dbi_pattern[3] = {
	0x00ff00ff00ff00ffULL, 0x00ff00ff00ff00ffULL, 0x0000ULL };

// Perform switchover to DBI
static void cvmx_dbi_switchover_interface(struct ddr_priv *priv, int lmc)
{
	union cvmx_lmcx_modereg_params0 modereg_params0;
	union cvmx_lmcx_modereg_params3 modereg_params3;
	union cvmx_lmcx_phy_ctl phy_ctl;
	union cvmx_lmcx_config lmcx_config;
	union cvmx_lmcx_ddr_pll_ctl ddr_pll_ctl;
	int rank_mask, rankx, active_ranks;
	u64 phys_addr, rank_offset;
	int num_lmcs, errors;
	int dbi_settings[9], byte, unlocked, retries;
	int ecc_ena;
	int rank_max = 1;	// FIXME: make this 4 to try all the ranks
	int node = 0;

	ddr_pll_ctl.u64 = lmc_rd(priv, CVMX_LMCX_DDR_PLL_CTL(0));

	lmcx_config.u64 = lmc_rd(priv, CVMX_LMCX_CONFIG(lmc));
	rank_mask = lmcx_config.s.init_status;
	ecc_ena = lmcx_config.s.ecc_ena;

	// FIXME: must filter out any non-supported configs
	//        ie, no DDR3, no x4 devices
	if (ddr_pll_ctl.s.ddr4_mode == 0 || lmcx_config.s.mode_x4dev == 1) {
		debug("N%d.LMC%d: DBI switchover: inappropriate device; EXITING...\n",
		      node, lmc);
		return;
	}

	// this should be correct for 1 or 2 ranks, 1 or 2 DIMMs
	num_lmcs = cvmx_dram_get_num_lmc(priv);
	rank_offset = 1ull << (28 + lmcx_config.s.pbank_lsb -
			       lmcx_config.s.rank_ena + (num_lmcs / 2));

	debug("N%d.LMC%d: DBI switchover: rank mask 0x%x, rank size 0x%016llx.\n",
	      node, lmc, rank_mask, (unsigned long long)rank_offset);

	/*
	 * 1. conduct the current init sequence as usual all the way
	 * after software write leveling.
	 */

	read_dac_dbi_settings(priv, lmc, /*DBI*/ 0, dbi_settings);

	display_dac_dbi_settings(lmc, /*DBI*/ 0, ecc_ena, dbi_settings,
				 " INIT");

	/*
	 * 2. set DBI related CSRs as below and issue MR write.
	 * MODEREG_PARAMS3.WR_DBI=1
	 * MODEREG_PARAMS3.RD_DBI=1
	 * PHY_CTL.DBI_MODE_ENA=1
	 */
	modereg_params0.u64 = lmc_rd(priv, CVMX_LMCX_MODEREG_PARAMS0(lmc));

	modereg_params3.u64 = lmc_rd(priv, CVMX_LMCX_MODEREG_PARAMS3(lmc));
	modereg_params3.s.wr_dbi = 1;
	modereg_params3.s.rd_dbi = 1;
	lmc_wr(priv, CVMX_LMCX_MODEREG_PARAMS3(lmc), modereg_params3.u64);

	phy_ctl.u64 = lmc_rd(priv, CVMX_LMCX_PHY_CTL(lmc));
	phy_ctl.s.dbi_mode_ena = 1;
	lmc_wr(priv, CVMX_LMCX_PHY_CTL(lmc), phy_ctl.u64);

	/*
	 * there are two options for data to send.  Lets start with (1)
	 * and could move to (2) in the future:
	 *
	 * 1) DBTRAIN_CTL[LFSR_PATTERN_SEL] = 0 (or for older chips where
	 * this does not exist) set data directly in these reigsters.
	 * this will yield a clk/2 pattern:
	 * GENERAL_PURPOSE0.DATA == 64'h00ff00ff00ff00ff;
	 * GENERAL_PURPOSE1.DATA == 64'h00ff00ff00ff00ff;
	 * GENERAL_PURPOSE0.DATA == 16'h0000;
	 * 2) DBTRAIN_CTL[LFSR_PATTERN_SEL] = 1
	 * here data comes from the LFSR generating a PRBS pattern
	 * CHAR_CTL.EN = 0
	 * CHAR_CTL.SEL = 0; // for PRBS
	 * CHAR_CTL.DR = 1;
	 * CHAR_CTL.PRBS = setup for whatever type of PRBS to send
	 * CHAR_CTL.SKEW_ON = 1;
	 */
	lmc_wr(priv, CVMX_LMCX_GENERAL_PURPOSE0(lmc), dbi_pattern[0]);
	lmc_wr(priv, CVMX_LMCX_GENERAL_PURPOSE1(lmc), dbi_pattern[1]);
	lmc_wr(priv, CVMX_LMCX_GENERAL_PURPOSE2(lmc), dbi_pattern[2]);

	/*
	 * 3. adjust cas_latency (only necessary if RD_DBI is set).
	 * here is my code for doing this:
	 *
	 * if (csr_model.MODEREG_PARAMS3.RD_DBI.value == 1) begin
	 * case (csr_model.MODEREG_PARAMS0.CL.value)
	 * 0,1,2,3,4: csr_model.MODEREG_PARAMS0.CL.value += 2;
	 * // CL 9-13 -> 11-15
	 * 5: begin
	 * // CL=14, CWL=10,12 gets +2, CLW=11,14 gets +3
	 * if((csr_model.MODEREG_PARAMS0.CWL.value==1 ||
	 * csr_model.MODEREG_PARAMS0.CWL.value==3))
	 * csr_model.MODEREG_PARAMS0.CL.value = 7; // 14->16
	 * else
	 * csr_model.MODEREG_PARAMS0.CL.value = 13; // 14->17
	 * end
	 * 6: csr_model.MODEREG_PARAMS0.CL.value = 8; // 15->18
	 * 7: csr_model.MODEREG_PARAMS0.CL.value = 14; // 16->19
	 * 8: csr_model.MODEREG_PARAMS0.CL.value = 15; // 18->21
	 * default:
	 * `cn_fatal(("Error mem_cfg (%s) CL (%d) with RD_DBI=1,
	 * I am not sure what to do.",
	 * mem_cfg, csr_model.MODEREG_PARAMS3.RD_DBI.value))
	 * endcase
	 * end
	 */

	if (modereg_params3.s.rd_dbi == 1) {
		int old_cl, new_cl, old_cwl;

		old_cl = modereg_params0.s.cl;
		old_cwl = modereg_params0.s.cwl;

		switch (old_cl) {
		case 0:
		case 1:
		case 2:
		case 3:
		case 4:
			new_cl = old_cl + 2;
			break;	// 9-13->11-15
			// CL=14, CWL=10,12 gets +2, CLW=11,14 gets +3
		case 5:
			new_cl = ((old_cwl == 1) || (old_cwl == 3)) ? 7 : 13;
			break;
		case 6:
			new_cl = 8;
			break;	// 15->18
		case 7:
			new_cl = 14;
			break;	// 16->19
		case 8:
			new_cl = 15;
			break;	// 18->21
		default:
			printf("ERROR: Bad CL value (%d) for DBI switchover.\n",
			       old_cl);
			// FIXME: need to error exit here...
			old_cl = -1;
			new_cl = -1;
			break;
		}
		debug("N%d.LMC%d: DBI switchover: CL ADJ: old_cl 0x%x, old_cwl 0x%x, new_cl 0x%x.\n",
		      node, lmc, old_cl, old_cwl, new_cl);
		modereg_params0.s.cl = new_cl;
		lmc_wr(priv, CVMX_LMCX_MODEREG_PARAMS0(lmc),
		       modereg_params0.u64);
	}

	/*
	 * 4. issue MRW to MR0 (CL) and MR5 (DBI), using LMC sequence
	 * SEQ_CTL[SEQ_SEL] = MRW.
	 */
	// Use the default values, from the CSRs fields
	// also, do B-sides for RDIMMs...

	for (rankx = 0; rankx < 4; rankx++) {
		if (!(rank_mask & (1 << rankx)))
			continue;

		// for RDIMMs, B-side writes should get done automatically
		// when the A-side is written
		ddr4_mrw(priv, lmc, rankx, -1 /* use_default */,
			 0 /*MRreg */, 0 /*A-side */);	/* MR0 */
		ddr4_mrw(priv, lmc, rankx, -1 /* use_default */,
			 5 /*MRreg */, 0 /*A-side */);	/* MR5 */
	}

	/*
	 * 5. conduct DBI bit deskew training via the General Purpose
	 * R/W sequence (dbtrain). may need to run this over and over to get
	 * a lock (I need up to 5 in simulation):
	 * SEQ_CTL[SEQ_SEL] = RW_TRAINING (15)
	 * DBTRAIN_CTL.CMD_COUNT_EXT = all 1's
	 * DBTRAIN_CTL.READ_CMD_COUNT = all 1's
	 * DBTRAIN_CTL.TCCD_SEL = set according to MODEREG_PARAMS3[TCCD_L]
	 * DBTRAIN_CTL.RW_TRAIN = 1
	 * DBTRAIN_CTL.READ_DQ_COUNT = dont care
	 * DBTRAIN_CTL.WRITE_ENA = 1;
	 * DBTRAIN_CTL.ACTIVATE = 1;
	 * DBTRAIN_CTL LRANK, PRANK, ROW_A, BG, BA, COLUMN_A = set to a
	 * valid address
	 */

	// NOW - do the training
	debug("N%d.LMC%d: DBI switchover: TRAINING begins...\n", node, lmc);

	active_ranks = 0;
	for (rankx = 0; rankx < rank_max; rankx++) {
		if (!(rank_mask & (1 << rankx)))
			continue;

		phys_addr = rank_offset * active_ranks;
		// FIXME: now done by test_dram_byte_hw()

		active_ranks++;

		retries = 0;

restart_training:

		// NOTE: return is a bitmask of the erroring bytelanes -
		// we only print it
		errors =
		    test_dram_byte_hw(priv, lmc, phys_addr, DBTRAIN_DBI, NULL);

		debug("N%d.LMC%d: DBI switchover: TEST: rank %d, phys_addr 0x%llx, errors 0x%x.\n",
		      node, lmc, rankx, (unsigned long long)phys_addr, errors);

		// NEXT - check for locking
		unlocked = 0;
		read_dac_dbi_settings(priv, lmc, /*DBI*/ 0, dbi_settings);

		for (byte = 0; byte < (8 + ecc_ena); byte++)
			unlocked += (dbi_settings[byte] & 1) ^ 1;

		// FIXME: print out the DBI settings array after each rank?
		if (rank_max > 1)	// only when doing more than 1 rank
			display_dac_dbi_settings(lmc, /*DBI*/ 0, ecc_ena,
						 dbi_settings, " RANK");

		if (unlocked > 0) {
			debug("N%d.LMC%d: DBI switchover: LOCK: %d still unlocked.\n",
			      node, lmc, unlocked);
			retries++;
			if (retries < 10) {
				goto restart_training;
			} else {
				debug("N%d.LMC%d: DBI switchover: LOCK: %d retries exhausted.\n",
				      node, lmc, retries);
			}
		}
	}			/* for (rankx = 0; rankx < 4; rankx++) */

	// print out the final DBI settings array
	display_dac_dbi_settings(lmc, /*DBI*/ 0, ecc_ena, dbi_settings,
				 "FINAL");
}

void cvmx_dbi_switchover(struct ddr_priv *priv)
{
	int lmc;
	int num_lmcs = cvmx_dram_get_num_lmc(priv);

	for (lmc = 0; lmc < num_lmcs; lmc++)
		cvmx_dbi_switchover_interface(priv, lmc);
}
