/*
 * Copyright (C) 2013, Intel Corporation
 * Copyright (C) 2015, Bin Meng <bmeng.cn@gmail.com>
 *
 * Ported from Intel released Quark UEFI BIOS
 * QuarkSocPkg/QuarkNorthCluster/MemoryInit/Pei
 *
 * SPDX-License-Identifier:	Intel
 */

#include <common.h>
#include <pci.h>
#include <asm/arch/device.h>
#include <asm/arch/mrc.h>
#include <asm/arch/msg_port.h>
#include "mrc_util.h"
#include "hte.h"
#include "smc.h"

/* t_ck clock period in picoseconds per speed index 800, 1066, 1333 */
static const uint32_t t_ck[3] = {
	2500,
	1875,
	1500
};

/* Global variables */
static const uint16_t ddr_wclk[] = {193, 158};
#ifdef BACKUP_WCTL
static const uint16_t ddr_wctl[] = {1, 217};
#endif
#ifdef BACKUP_WCMD
static const uint16_t ddr_wcmd[] = {1, 220};
#endif

#ifdef BACKUP_RCVN
static const uint16_t ddr_rcvn[] = {129, 498};
#endif

#ifdef BACKUP_WDQS
static const uint16_t ddr_wdqs[] = {65, 289};
#endif

#ifdef BACKUP_RDQS
static const uint8_t ddr_rdqs[] = {32, 24};
#endif

#ifdef BACKUP_WDQ
static const uint16_t ddr_wdq[] = {32, 257};
#endif

/* Stop self refresh driven by MCU */
void clear_self_refresh(struct mrc_params *mrc_params)
{
	ENTERFN();

	/* clear the PMSTS Channel Self Refresh bits */
	mrc_write_mask(MEM_CTLR, PMSTS, PMSTS_DISR, PMSTS_DISR);

	LEAVEFN();
}

/* It will initialize timing registers in the MCU (DTR0..DTR4) */
void prog_ddr_timing_control(struct mrc_params *mrc_params)
{
	uint8_t tcl, wl;
	uint8_t trp, trcd, tras, twr, twtr, trrd, trtp, tfaw;
	uint32_t tck;
	u32 dtr0, dtr1, dtr2, dtr3, dtr4;
	u32 tmp1, tmp2;

	ENTERFN();

	/* mcu_init starts */
	mrc_post_code(0x02, 0x00);

	dtr0 = msg_port_read(MEM_CTLR, DTR0);
	dtr1 = msg_port_read(MEM_CTLR, DTR1);
	dtr2 = msg_port_read(MEM_CTLR, DTR2);
	dtr3 = msg_port_read(MEM_CTLR, DTR3);
	dtr4 = msg_port_read(MEM_CTLR, DTR4);

	tck = t_ck[mrc_params->ddr_speed];	/* Clock in picoseconds */
	tcl = mrc_params->params.cl;		/* CAS latency in clocks */
	trp = tcl;	/* Per CAT MRC */
	trcd = tcl;	/* Per CAT MRC */
	tras = MCEIL(mrc_params->params.ras, tck);

	/* Per JEDEC: tWR=15000ps DDR2/3 from 800-1600 */
	twr = MCEIL(15000, tck);

	twtr = MCEIL(mrc_params->params.wtr, tck);
	trrd = MCEIL(mrc_params->params.rrd, tck);
	trtp = 4;	/* Valid for 800 and 1066, use 5 for 1333 */
	tfaw = MCEIL(mrc_params->params.faw, tck);

	wl = 5 + mrc_params->ddr_speed;

	dtr0 &= ~DTR0_DFREQ_MASK;
	dtr0 |= mrc_params->ddr_speed;
	dtr0 &= ~DTR0_TCL_MASK;
	tmp1 = tcl - 5;
	dtr0 |= ((tcl - 5) << 12);
	dtr0 &= ~DTR0_TRP_MASK;
	dtr0 |= ((trp - 5) << 4);	/* 5 bit DRAM Clock */
	dtr0 &= ~DTR0_TRCD_MASK;
	dtr0 |= ((trcd - 5) << 8);	/* 5 bit DRAM Clock */

	dtr1 &= ~DTR1_TWCL_MASK;
	tmp2 = wl - 3;
	dtr1 |= (wl - 3);
	dtr1 &= ~DTR1_TWTP_MASK;
	dtr1 |= ((wl + 4 + twr - 14) << 8);	/* Change to tWTP */
	dtr1 &= ~DTR1_TRTP_MASK;
	dtr1 |= ((MMAX(trtp, 4) - 3) << 28);	/* 4 bit DRAM Clock */
	dtr1 &= ~DTR1_TRRD_MASK;
	dtr1 |= ((trrd - 4) << 24);		/* 4 bit DRAM Clock */
	dtr1 &= ~DTR1_TCMD_MASK;
	dtr1 |= (1 << 4);
	dtr1 &= ~DTR1_TRAS_MASK;
	dtr1 |= ((tras - 14) << 20);		/* 6 bit DRAM Clock */
	dtr1 &= ~DTR1_TFAW_MASK;
	dtr1 |= ((((tfaw + 1) >> 1) - 5) << 16);/* 4 bit DRAM Clock */
	/* Set 4 Clock CAS to CAS delay (multi-burst) */
	dtr1 &= ~DTR1_TCCD_MASK;

	dtr2 &= ~DTR2_TRRDR_MASK;
	dtr2 |= 1;
	dtr2 &= ~DTR2_TWWDR_MASK;
	dtr2 |= (2 << 8);
	dtr2 &= ~DTR2_TRWDR_MASK;
	dtr2 |= (2 << 16);

	dtr3 &= ~DTR3_TWRDR_MASK;
	dtr3 |= 2;
	dtr3 &= ~DTR3_TXXXX_MASK;
	dtr3 |= (2 << 4);

	dtr3 &= ~DTR3_TRWSR_MASK;
	if (mrc_params->ddr_speed == DDRFREQ_800) {
		/* Extended RW delay (+1) */
		dtr3 |= ((tcl - 5 + 1) << 8);
	} else if (mrc_params->ddr_speed == DDRFREQ_1066) {
		/* Extended RW delay (+1) */
		dtr3 |= ((tcl - 5 + 1) << 8);
	}

	dtr3 &= ~DTR3_TWRSR_MASK;
	dtr3 |= ((4 + wl + twtr - 11) << 13);

	dtr3 &= ~DTR3_TXP_MASK;
	if (mrc_params->ddr_speed == DDRFREQ_800)
		dtr3 |= ((MMAX(0, 1 - 1)) << 22);
	else
		dtr3 |= ((MMAX(0, 2 - 1)) << 22);

	dtr4 &= ~DTR4_WRODTSTRT_MASK;
	dtr4 |= 1;
	dtr4 &= ~DTR4_WRODTSTOP_MASK;
	dtr4 |= (1 << 4);
	dtr4 &= ~DTR4_XXXX1_MASK;
	dtr4 |= ((1 + tmp1 - tmp2 + 2) << 8);
	dtr4 &= ~DTR4_XXXX2_MASK;
	dtr4 |= ((1 + tmp1 - tmp2 + 2) << 12);
	dtr4 &= ~(DTR4_ODTDIS | DTR4_TRGSTRDIS);

	msg_port_write(MEM_CTLR, DTR0, dtr0);
	msg_port_write(MEM_CTLR, DTR1, dtr1);
	msg_port_write(MEM_CTLR, DTR2, dtr2);
	msg_port_write(MEM_CTLR, DTR3, dtr3);
	msg_port_write(MEM_CTLR, DTR4, dtr4);

	LEAVEFN();
}

/* Configure MCU before jedec init sequence */
void prog_decode_before_jedec(struct mrc_params *mrc_params)
{
	u32 drp;
	u32 drfc;
	u32 dcal;
	u32 dsch;
	u32 dpmc0;

	ENTERFN();

	/* Disable power saving features */
	dpmc0 = msg_port_read(MEM_CTLR, DPMC0);
	dpmc0 |= (DPMC0_CLKGTDIS | DPMC0_DISPWRDN);
	dpmc0 &= ~DPMC0_PCLSTO_MASK;
	dpmc0 &= ~DPMC0_DYNSREN;
	msg_port_write(MEM_CTLR, DPMC0, dpmc0);

	/* Disable out of order transactions */
	dsch = msg_port_read(MEM_CTLR, DSCH);
	dsch |= (DSCH_OOODIS | DSCH_NEWBYPDIS);
	msg_port_write(MEM_CTLR, DSCH, dsch);

	/* Disable issuing the REF command */
	drfc = msg_port_read(MEM_CTLR, DRFC);
	drfc &= ~DRFC_TREFI_MASK;
	msg_port_write(MEM_CTLR, DRFC, drfc);

	/* Disable ZQ calibration short */
	dcal = msg_port_read(MEM_CTLR, DCAL);
	dcal &= ~DCAL_ZQCINT_MASK;
	dcal &= ~DCAL_SRXZQCL_MASK;
	msg_port_write(MEM_CTLR, DCAL, dcal);

	/*
	 * Training performed in address mode 0, rank population has limited
	 * impact, however simulator complains if enabled non-existing rank.
	 */
	drp = 0;
	if (mrc_params->rank_enables & 1)
		drp |= DRP_RKEN0;
	if (mrc_params->rank_enables & 2)
		drp |= DRP_RKEN1;
	msg_port_write(MEM_CTLR, DRP, drp);

	LEAVEFN();
}

/*
 * After Cold Reset, BIOS should set COLDWAKE bit to 1 before
 * sending the WAKE message to the Dunit.
 *
 * For Standby Exit, or any other mode in which the DRAM is in
 * SR, this bit must be set to 0.
 */
void perform_ddr_reset(struct mrc_params *mrc_params)
{
	ENTERFN();

	/* Set COLDWAKE bit before sending the WAKE message */
	mrc_write_mask(MEM_CTLR, DRMC, DRMC_COLDWAKE, DRMC_COLDWAKE);

	/* Send wake command to DUNIT (MUST be done before JEDEC) */
	dram_wake_command();

	/* Set default value */
	msg_port_write(MEM_CTLR, DRMC,
		       mrc_params->rd_odt_value == 0 ? DRMC_ODTMODE : 0);

	LEAVEFN();
}


/*
 * This function performs some initialization on the DDRIO unit.
 * This function is dependent on BOARD_ID, DDR_SPEED, and CHANNEL_ENABLES.
 */
void ddrphy_init(struct mrc_params *mrc_params)
{
	uint32_t temp;
	uint8_t ch;	/* channel counter */
	uint8_t rk;	/* rank counter */
	uint8_t bl_grp;	/*  byte lane group counter (2 BLs per module) */
	uint8_t bl_divisor = 1;	/* byte lane divisor */
	/* For DDR3 --> 0 == 800, 1 == 1066, 2 == 1333 */
	uint8_t speed = mrc_params->ddr_speed & 3;
	uint8_t cas;
	uint8_t cwl;

	ENTERFN();

	cas = mrc_params->params.cl;
	cwl = 5 + mrc_params->ddr_speed;

	/* ddrphy_init starts */
	mrc_post_code(0x03, 0x00);

	/*
	 * HSD#231531
	 * Make sure IOBUFACT is deasserted before initializing the DDR PHY
	 *
	 * HSD#234845
	 * Make sure WRPTRENABLE is deasserted before initializing the DDR PHY
	 */
	for (ch = 0; ch < NUM_CHANNELS; ch++) {
		if (mrc_params->channel_enables & (1 << ch)) {
			/* Deassert DDRPHY Initialization Complete */
			mrc_alt_write_mask(DDRPHY,
				CMDPMCONFIG0 + ch * DDRIOCCC_CH_OFFSET,
				~(1 << 20), 1 << 20);	/* SPID_INIT_COMPLETE=0 */
			/* Deassert IOBUFACT */
			mrc_alt_write_mask(DDRPHY,
				CMDCFGREG0 + ch * DDRIOCCC_CH_OFFSET,
				~(1 << 2), 1 << 2);	/* IOBUFACTRST_N=0 */
			/* Disable WRPTR */
			mrc_alt_write_mask(DDRPHY,
				CMDPTRREG + ch * DDRIOCCC_CH_OFFSET,
				~(1 << 0), 1 << 0);	/* WRPTRENABLE=0 */
		}
	}

	/* Put PHY in reset */
	mrc_alt_write_mask(DDRPHY, MASTERRSTN, 0, 1);

	/* Initialize DQ01, DQ23, CMD, CLK-CTL, COMP modules */

	/* STEP0 */
	mrc_post_code(0x03, 0x10);
	for (ch = 0; ch < NUM_CHANNELS; ch++) {
		if (mrc_params->channel_enables & (1 << ch)) {
			/* DQ01-DQ23 */
			for (bl_grp = 0;
			     bl_grp < (NUM_BYTE_LANES / bl_divisor) / 2;
			     bl_grp++) {
				/* Analog MUX select - IO2xCLKSEL */
				mrc_alt_write_mask(DDRPHY,
					DQOBSCKEBBCTL +
					bl_grp * DDRIODQ_BL_OFFSET +
					ch * DDRIODQ_CH_OFFSET,
					bl_grp ? 0 : (1 << 22), 1 << 22);

				/* ODT Strength */
				switch (mrc_params->rd_odt_value) {
				case 1:
					temp = 0x3;
					break;	/* 60 ohm */
				case 2:
					temp = 0x3;
					break;	/* 120 ohm */
				case 3:
					temp = 0x3;
					break;	/* 180 ohm */
				default:
					temp = 0x3;
					break;	/* 120 ohm */
				}

				/* ODT strength */
				mrc_alt_write_mask(DDRPHY,
					B0RXIOBUFCTL +
					bl_grp * DDRIODQ_BL_OFFSET +
					ch * DDRIODQ_CH_OFFSET,
					temp << 5, 0x60);
				/* ODT strength */
				mrc_alt_write_mask(DDRPHY,
					B1RXIOBUFCTL +
					bl_grp * DDRIODQ_BL_OFFSET +
					ch * DDRIODQ_CH_OFFSET,
					temp << 5, 0x60);

				/* Dynamic ODT/DIFFAMP */
				temp = (cas << 24) | (cas << 16) |
					(cas << 8) | (cas << 0);
				switch (speed) {
				case 0:
					temp -= 0x01010101;
					break;	/* 800 */
				case 1:
					temp -= 0x02020202;
					break;	/* 1066 */
				case 2:
					temp -= 0x03030303;
					break;	/* 1333 */
				case 3:
					temp -= 0x04040404;
					break;	/* 1600 */
				}

				/* Launch Time: ODT, DIFFAMP, ODT, DIFFAMP */
				mrc_alt_write_mask(DDRPHY,
					B01LATCTL1 +
					bl_grp * DDRIODQ_BL_OFFSET +
					ch * DDRIODQ_CH_OFFSET,
					temp, 0x1f1f1f1f);
				switch (speed) {
				/* HSD#234715 */
				case 0:
					temp = (0x06 << 16) | (0x07 << 8);
					break;	/* 800 */
				case 1:
					temp = (0x07 << 16) | (0x08 << 8);
					break;	/* 1066 */
				case 2:
					temp = (0x09 << 16) | (0x0a << 8);
					break;	/* 1333 */
				case 3:
					temp = (0x0a << 16) | (0x0b << 8);
					break;	/* 1600 */
				}

				/* On Duration: ODT, DIFFAMP */
				mrc_alt_write_mask(DDRPHY,
					B0ONDURCTL +
					bl_grp * DDRIODQ_BL_OFFSET +
					ch * DDRIODQ_CH_OFFSET,
					temp, 0x003f3f00);
				/* On Duration: ODT, DIFFAMP */
				mrc_alt_write_mask(DDRPHY,
					B1ONDURCTL +
					bl_grp * DDRIODQ_BL_OFFSET +
					ch * DDRIODQ_CH_OFFSET,
					temp, 0x003f3f00);

				switch (mrc_params->rd_odt_value) {
				case 0:
					/* override DIFFAMP=on, ODT=off */
					temp = (0x3f << 16) | (0x3f << 10);
					break;
				default:
					/* override DIFFAMP=on, ODT=on */
					temp = (0x3f << 16) | (0x2a << 10);
					break;
				}

				/* Override: DIFFAMP, ODT */
				mrc_alt_write_mask(DDRPHY,
					B0OVRCTL +
					bl_grp * DDRIODQ_BL_OFFSET +
					ch * DDRIODQ_CH_OFFSET,
					temp, 0x003ffc00);
				/* Override: DIFFAMP, ODT */
				mrc_alt_write_mask(DDRPHY,
					B1OVRCTL +
					bl_grp * DDRIODQ_BL_OFFSET +
					ch * DDRIODQ_CH_OFFSET,
					temp, 0x003ffc00);

				/* DLL Setup */

				/* 1xCLK Domain Timings: tEDP,RCVEN,WDQS (PO) */
				mrc_alt_write_mask(DDRPHY,
					B0LATCTL0 +
					bl_grp * DDRIODQ_BL_OFFSET +
					ch * DDRIODQ_CH_OFFSET,
					((cas + 7) << 16) | ((cas - 4) << 8) |
					((cwl - 2) << 0), 0x003f1f1f);
				mrc_alt_write_mask(DDRPHY,
					B1LATCTL0 +
					bl_grp * DDRIODQ_BL_OFFSET +
					ch * DDRIODQ_CH_OFFSET,
					((cas + 7) << 16) | ((cas - 4) << 8) |
					((cwl - 2) << 0), 0x003f1f1f);

				/* RCVEN Bypass (PO) */
				mrc_alt_write_mask(DDRPHY,
					B0RXIOBUFCTL +
					bl_grp * DDRIODQ_BL_OFFSET +
					ch * DDRIODQ_CH_OFFSET,
					0, 0x81);
				mrc_alt_write_mask(DDRPHY,
					B1RXIOBUFCTL +
					bl_grp * DDRIODQ_BL_OFFSET +
					ch * DDRIODQ_CH_OFFSET,
					0, 0x81);

				/* TX */
				mrc_alt_write_mask(DDRPHY,
					DQCTL +
					bl_grp * DDRIODQ_BL_OFFSET +
					ch * DDRIODQ_CH_OFFSET,
					1 << 16, 1 << 16);
				mrc_alt_write_mask(DDRPHY,
					B01PTRCTL1 +
					bl_grp * DDRIODQ_BL_OFFSET +
					ch * DDRIODQ_CH_OFFSET,
					1 << 8, 1 << 8);

				/* RX (PO) */
				/* Internal Vref Code, Enable#, Ext_or_Int (1=Ext) */
				mrc_alt_write_mask(DDRPHY,
					B0VREFCTL +
					bl_grp * DDRIODQ_BL_OFFSET +
					ch * DDRIODQ_CH_OFFSET,
					(0x03 << 2) | (0x0 << 1) | (0x0 << 0),
					0xff);
				/* Internal Vref Code, Enable#, Ext_or_Int (1=Ext) */
				mrc_alt_write_mask(DDRPHY,
					B1VREFCTL +
					bl_grp * DDRIODQ_BL_OFFSET +
					ch * DDRIODQ_CH_OFFSET,
					(0x03 << 2) | (0x0 << 1) | (0x0 << 0),
					0xff);
				/* Per-Bit De-Skew Enable */
				mrc_alt_write_mask(DDRPHY,
					B0RXIOBUFCTL +
					bl_grp * DDRIODQ_BL_OFFSET +
					ch * DDRIODQ_CH_OFFSET,
					0, 0x10);
				/* Per-Bit De-Skew Enable */
				mrc_alt_write_mask(DDRPHY,
					B1RXIOBUFCTL +
					bl_grp * DDRIODQ_BL_OFFSET +
					ch * DDRIODQ_CH_OFFSET,
					0, 0x10);
			}

			/* CLKEBB */
			mrc_alt_write_mask(DDRPHY,
				CMDOBSCKEBBCTL + ch * DDRIOCCC_CH_OFFSET,
				0, 1 << 23);

			/* Enable tristate control of cmd/address bus */
			mrc_alt_write_mask(DDRPHY,
				CMDCFGREG0 + ch * DDRIOCCC_CH_OFFSET,
				0, 0x03);

			/* ODT RCOMP */
			mrc_alt_write_mask(DDRPHY,
				CMDRCOMPODT + ch * DDRIOCCC_CH_OFFSET,
				(0x03 << 5) | (0x03 << 0), 0x3ff);

			/* CMDPM* registers must be programmed in this order */

			/* Turn On Delays: SFR (regulator), MPLL */
			mrc_alt_write_mask(DDRPHY,
				CMDPMDLYREG4 + ch * DDRIOCCC_CH_OFFSET,
				0xffffffff, 0xffffffff);
			/*
			 * Delays: ASSERT_IOBUFACT_to_ALLON0_for_PM_MSG_3,
			 * VREG (MDLL) Turn On, ALLON0_to_DEASSERT_IOBUFACT
			 * for_PM_MSG_gt0, MDLL Turn On
			 */
			mrc_alt_write_mask(DDRPHY,
				CMDPMDLYREG3 + ch * DDRIOCCC_CH_OFFSET,
				0xfffff616, 0xffffffff);
			/* MPLL Divider Reset Delays */
			mrc_alt_write_mask(DDRPHY,
				CMDPMDLYREG2 + ch * DDRIOCCC_CH_OFFSET,
				0xffffffff, 0xffffffff);
			/* Turn Off Delays: VREG, Staggered MDLL, MDLL, PI */
			mrc_alt_write_mask(DDRPHY,
				CMDPMDLYREG1 + ch * DDRIOCCC_CH_OFFSET,
				0xffffffff, 0xffffffff);
			/* Turn On Delays: MPLL, Staggered MDLL, PI, IOBUFACT */
			mrc_alt_write_mask(DDRPHY,
				CMDPMDLYREG0 + ch * DDRIOCCC_CH_OFFSET,
				0xffffffff, 0xffffffff);
			/* Allow PUnit signals */
			mrc_alt_write_mask(DDRPHY,
				CMDPMCONFIG0 + ch * DDRIOCCC_CH_OFFSET,
				(0x6 << 8) | (0x1 << 6) | (0x4 << 0),
				0xffe00f4f);
			/* DLL_VREG Bias Trim, VREF Tuning for DLL_VREG */
			mrc_alt_write_mask(DDRPHY,
				CMDMDLLCTL + ch * DDRIOCCC_CH_OFFSET,
				(0x3 << 4) | (0x7 << 0), 0x7f);

			/* CLK-CTL */
			mrc_alt_write_mask(DDRPHY,
				CCOBSCKEBBCTL + ch * DDRIOCCC_CH_OFFSET,
				0, 1 << 24);	/* CLKEBB */
			/* Buffer Enable: CS,CKE,ODT,CLK */
			mrc_alt_write_mask(DDRPHY,
				CCCFGREG0 + ch * DDRIOCCC_CH_OFFSET,
				0x1f, 0x000ffff1);
			/* ODT RCOMP */
			mrc_alt_write_mask(DDRPHY,
				CCRCOMPODT + ch * DDRIOCCC_CH_OFFSET,
				(0x03 << 8) | (0x03 << 0), 0x00001f1f);
			/* DLL_VREG Bias Trim, VREF Tuning for DLL_VREG */
			mrc_alt_write_mask(DDRPHY,
				CCMDLLCTL + ch * DDRIOCCC_CH_OFFSET,
				(0x3 << 4) | (0x7 << 0), 0x7f);

			/*
			 * COMP (RON channel specific)
			 * - DQ/DQS/DM RON: 32 Ohm
			 * - CTRL/CMD RON: 27 Ohm
			 * - CLK RON: 26 Ohm
			 */
			/* RCOMP Vref PU/PD */
			mrc_alt_write_mask(DDRPHY,
				DQVREFCH0 +  ch * DDRCOMP_CH_OFFSET,
				(0x08 << 24) | (0x03 << 16), 0x3f3f0000);
			/* RCOMP Vref PU/PD */
			mrc_alt_write_mask(DDRPHY,
				CMDVREFCH0 + ch * DDRCOMP_CH_OFFSET,
				(0x0C << 24) | (0x03 << 16), 0x3f3f0000);
			/* RCOMP Vref PU/PD */
			mrc_alt_write_mask(DDRPHY,
				CLKVREFCH0 + ch * DDRCOMP_CH_OFFSET,
				(0x0F << 24) | (0x03 << 16), 0x3f3f0000);
			/* RCOMP Vref PU/PD */
			mrc_alt_write_mask(DDRPHY,
				DQSVREFCH0 + ch * DDRCOMP_CH_OFFSET,
				(0x08 << 24) | (0x03 << 16), 0x3f3f0000);
			/* RCOMP Vref PU/PD */
			mrc_alt_write_mask(DDRPHY,
				CTLVREFCH0 + ch * DDRCOMP_CH_OFFSET,
				(0x0C << 24) | (0x03 << 16), 0x3f3f0000);

			/* DQS Swapped Input Enable */
			mrc_alt_write_mask(DDRPHY,
				COMPEN1CH0 + ch * DDRCOMP_CH_OFFSET,
				(1 << 19) | (1 << 17), 0xc00ac000);

			/* ODT VREF = 1.5 x 274/360+274 = 0.65V (code of ~50) */
			/* ODT Vref PU/PD */
			mrc_alt_write_mask(DDRPHY,
				DQVREFCH0 + ch * DDRCOMP_CH_OFFSET,
				(0x32 << 8) | (0x03 << 0), 0x00003f3f);
			/* ODT Vref PU/PD */
			mrc_alt_write_mask(DDRPHY,
				DQSVREFCH0 + ch * DDRCOMP_CH_OFFSET,
				(0x32 << 8) | (0x03 << 0), 0x00003f3f);
			/* ODT Vref PU/PD */
			mrc_alt_write_mask(DDRPHY,
				CLKVREFCH0 + ch * DDRCOMP_CH_OFFSET,
				(0x0E << 8) | (0x05 << 0), 0x00003f3f);

			/*
			 * Slew rate settings are frequency specific,
			 * numbers below are for 800Mhz (speed == 0)
			 * - DQ/DQS/DM/CLK SR: 4V/ns,
			 * - CTRL/CMD SR: 1.5V/ns
			 */
			temp = (0x0e << 16) | (0x0e << 12) | (0x08 << 8) |
				(0x0b << 4) | (0x0b << 0);
			/* DCOMP Delay Select: CTL,CMD,CLK,DQS,DQ */
			mrc_alt_write_mask(DDRPHY,
				DLYSELCH0 + ch * DDRCOMP_CH_OFFSET,
				temp, 0x000fffff);
			/* TCO Vref CLK,DQS,DQ */
			mrc_alt_write_mask(DDRPHY,
				TCOVREFCH0 + ch * DDRCOMP_CH_OFFSET,
				(0x05 << 16) | (0x05 << 8) | (0x05 << 0),
				0x003f3f3f);
			/* ODTCOMP CMD/CTL PU/PD */
			mrc_alt_write_mask(DDRPHY,
				CCBUFODTCH0 + ch * DDRCOMP_CH_OFFSET,
				(0x03 << 8) | (0x03 << 0),
				0x00001f1f);
			/* COMP */
			mrc_alt_write_mask(DDRPHY,
				COMPEN0CH0 + ch * DDRCOMP_CH_OFFSET,
				0, 0xc0000100);

#ifdef BACKUP_COMPS
			/* DQ COMP Overrides */
			/* RCOMP PU */
			mrc_alt_write_mask(DDRPHY,
				DQDRVPUCTLCH0 + ch * DDRCOMP_CH_OFFSET,
				(1 << 31) | (0x0a << 16),
				0x801f0000);
			/* RCOMP PD */
			mrc_alt_write_mask(DDRPHY,
				DQDRVPDCTLCH0 + ch * DDRCOMP_CH_OFFSET,
				(1 << 31) | (0x0a << 16),
				0x801f0000);
			/* DCOMP PU */
			mrc_alt_write_mask(DDRPHY,
				DQDLYPUCTLCH0 + ch * DDRCOMP_CH_OFFSET,
				(1 << 31) | (0x10 << 16),
				0x801f0000);
			/* DCOMP PD */
			mrc_alt_write_mask(DDRPHY,
				DQDLYPDCTLCH0 + ch * DDRCOMP_CH_OFFSET,
				(1 << 31) | (0x10 << 16),
				0x801f0000);
			/* ODTCOMP PU */
			mrc_alt_write_mask(DDRPHY,
				DQODTPUCTLCH0 + ch * DDRCOMP_CH_OFFSET,
				(1 << 31) | (0x0b << 16),
				0x801f0000);
			/* ODTCOMP PD */
			mrc_alt_write_mask(DDRPHY,
				DQODTPDCTLCH0 + ch * DDRCOMP_CH_OFFSET,
				(1 << 31) | (0x0b << 16),
				0x801f0000);
			/* TCOCOMP PU */
			mrc_alt_write_mask(DDRPHY,
				DQTCOPUCTLCH0 + ch * DDRCOMP_CH_OFFSET,
				1 << 31, 1 << 31);
			/* TCOCOMP PD */
			mrc_alt_write_mask(DDRPHY,
				DQTCOPDCTLCH0 + ch * DDRCOMP_CH_OFFSET,
				1 << 31, 1 << 31);

			/* DQS COMP Overrides */
			/* RCOMP PU */
			mrc_alt_write_mask(DDRPHY,
				DQSDRVPUCTLCH0 + ch * DDRCOMP_CH_OFFSET,
				(1 << 31) | (0x0a << 16),
				0x801f0000);
			/* RCOMP PD */
			mrc_alt_write_mask(DDRPHY,
				DQSDRVPDCTLCH0 + ch * DDRCOMP_CH_OFFSET,
				(1 << 31) | (0x0a << 16),
				0x801f0000);
			/* DCOMP PU */
			mrc_alt_write_mask(DDRPHY,
				DQSDLYPUCTLCH0 + ch * DDRCOMP_CH_OFFSET,
				(1 << 31) | (0x10 << 16),
				0x801f0000);
			/* DCOMP PD */
			mrc_alt_write_mask(DDRPHY,
				DQSDLYPDCTLCH0 + ch * DDRCOMP_CH_OFFSET,
				(1 << 31) | (0x10 << 16),
				0x801f0000);
			/* ODTCOMP PU */
			mrc_alt_write_mask(DDRPHY,
				DQSODTPUCTLCH0 + ch * DDRCOMP_CH_OFFSET,
				(1 << 31) | (0x0b << 16),
				0x801f0000);
			/* ODTCOMP PD */
			mrc_alt_write_mask(DDRPHY,
				DQSODTPDCTLCH0 + ch * DDRCOMP_CH_OFFSET,
				(1 << 31) | (0x0b << 16),
				0x801f0000);
			/* TCOCOMP PU */
			mrc_alt_write_mask(DDRPHY,
				DQSTCOPUCTLCH0 + ch * DDRCOMP_CH_OFFSET,
				1 << 31, 1 << 31);
			/* TCOCOMP PD */
			mrc_alt_write_mask(DDRPHY,
				DQSTCOPDCTLCH0 + ch * DDRCOMP_CH_OFFSET,
				1 << 31, 1 << 31);

			/* CLK COMP Overrides */
			/* RCOMP PU */
			mrc_alt_write_mask(DDRPHY,
				CLKDRVPUCTLCH0 + ch * DDRCOMP_CH_OFFSET,
				(1 << 31) | (0x0c << 16),
				0x801f0000);
			/* RCOMP PD */
			mrc_alt_write_mask(DDRPHY,
				CLKDRVPDCTLCH0 + ch * DDRCOMP_CH_OFFSET,
				(1 << 31) | (0x0c << 16),
				0x801f0000);
			/* DCOMP PU */
			mrc_alt_write_mask(DDRPHY,
				CLKDLYPUCTLCH0 + ch * DDRCOMP_CH_OFFSET,
				(1 << 31) | (0x07 << 16),
				0x801f0000);
			/* DCOMP PD */
			mrc_alt_write_mask(DDRPHY,
				CLKDLYPDCTLCH0 + ch * DDRCOMP_CH_OFFSET,
				(1 << 31) | (0x07 << 16),
				0x801f0000);
			/* ODTCOMP PU */
			mrc_alt_write_mask(DDRPHY,
				CLKODTPUCTLCH0 + ch * DDRCOMP_CH_OFFSET,
				(1 << 31) | (0x0b << 16),
				0x801f0000);
			/* ODTCOMP PD */
			mrc_alt_write_mask(DDRPHY,
				CLKODTPDCTLCH0 + ch * DDRCOMP_CH_OFFSET,
				(1 << 31) | (0x0b << 16),
				0x801f0000);
			/* TCOCOMP PU */
			mrc_alt_write_mask(DDRPHY,
				CLKTCOPUCTLCH0 + ch * DDRCOMP_CH_OFFSET,
				1 << 31, 1 << 31);
			/* TCOCOMP PD */
			mrc_alt_write_mask(DDRPHY,
				CLKTCOPDCTLCH0 + ch * DDRCOMP_CH_OFFSET,
				1 << 31, 1 << 31);

			/* CMD COMP Overrides */
			/* RCOMP PU */
			mrc_alt_write_mask(DDRPHY,
				CMDDRVPUCTLCH0 + ch * DDRCOMP_CH_OFFSET,
				(1 << 31) | (0x0d << 16),
				0x803f0000);
			/* RCOMP PD */
			mrc_alt_write_mask(DDRPHY,
				CMDDRVPDCTLCH0 + ch * DDRCOMP_CH_OFFSET,
				(1 << 31) | (0x0d << 16),
				0x803f0000);
			/* DCOMP PU */
			mrc_alt_write_mask(DDRPHY,
				CMDDLYPUCTLCH0 + ch * DDRCOMP_CH_OFFSET,
				(1 << 31) | (0x0a << 16),
				0x801f0000);
			/* DCOMP PD */
			mrc_alt_write_mask(DDRPHY,
				CMDDLYPDCTLCH0 + ch * DDRCOMP_CH_OFFSET,
				(1 << 31) | (0x0a << 16),
				0x801f0000);

			/* CTL COMP Overrides */
			/* RCOMP PU */
			mrc_alt_write_mask(DDRPHY,
				CTLDRVPUCTLCH0 + ch * DDRCOMP_CH_OFFSET,
				(1 << 31) | (0x0d << 16),
				0x803f0000);
			/* RCOMP PD */
			mrc_alt_write_mask(DDRPHY,
				CTLDRVPDCTLCH0 + ch * DDRCOMP_CH_OFFSET,
				(1 << 31) | (0x0d << 16),
				0x803f0000);
			/* DCOMP PU */
			mrc_alt_write_mask(DDRPHY,
				CTLDLYPUCTLCH0 + ch * DDRCOMP_CH_OFFSET,
				(1 << 31) | (0x0a << 16),
				0x801f0000);
			/* DCOMP PD */
			mrc_alt_write_mask(DDRPHY,
				CTLDLYPDCTLCH0 + ch * DDRCOMP_CH_OFFSET,
				(1 << 31) | (0x0a << 16),
				0x801f0000);
#else
			/* DQ TCOCOMP Overrides */
			/* TCOCOMP PU */
			mrc_alt_write_mask(DDRPHY,
				DQTCOPUCTLCH0 + ch * DDRCOMP_CH_OFFSET,
				(1 << 31) | (0x1f << 16),
				0x801f0000);
			/* TCOCOMP PD */
			mrc_alt_write_mask(DDRPHY,
				DQTCOPDCTLCH0 + ch * DDRCOMP_CH_OFFSET,
				(1 << 31) | (0x1f << 16),
				0x801f0000);

			/* DQS TCOCOMP Overrides */
			/* TCOCOMP PU */
			mrc_alt_write_mask(DDRPHY,
				DQSTCOPUCTLCH0 + ch * DDRCOMP_CH_OFFSET,
				(1 << 31) | (0x1f << 16),
				0x801f0000);
			/* TCOCOMP PD */
			mrc_alt_write_mask(DDRPHY,
				DQSTCOPDCTLCH0 + ch * DDRCOMP_CH_OFFSET,
				(1 << 31) | (0x1f << 16),
				0x801f0000);

			/* CLK TCOCOMP Overrides */
			/* TCOCOMP PU */
			mrc_alt_write_mask(DDRPHY,
				CLKTCOPUCTLCH0 + ch * DDRCOMP_CH_OFFSET,
				(1 << 31) | (0x1f << 16),
				0x801f0000);
			/* TCOCOMP PD */
			mrc_alt_write_mask(DDRPHY,
				CLKTCOPDCTLCH0 + ch * DDRCOMP_CH_OFFSET,
				(1 << 31) | (0x1f << 16),
				0x801f0000);
#endif

			/* program STATIC delays */
#ifdef BACKUP_WCMD
			set_wcmd(ch, ddr_wcmd[PLATFORM_ID]);
#else
			set_wcmd(ch, ddr_wclk[PLATFORM_ID] + HALF_CLK);
#endif

			for (rk = 0; rk < NUM_RANKS; rk++) {
				if (mrc_params->rank_enables & (1 << rk)) {
					set_wclk(ch, rk, ddr_wclk[PLATFORM_ID]);
#ifdef BACKUP_WCTL
					set_wctl(ch, rk, ddr_wctl[PLATFORM_ID]);
#else
					set_wctl(ch, rk, ddr_wclk[PLATFORM_ID] + HALF_CLK);
#endif
				}
			}
		}
	}

	/* COMP (non channel specific) */
	/* RCOMP: Dither PU Enable */
	mrc_alt_write_mask(DDRPHY, DQANADRVPUCTL, 1 << 30, 1 << 30);
	/* RCOMP: Dither PD Enable */
	mrc_alt_write_mask(DDRPHY, DQANADRVPDCTL, 1 << 30, 1 << 30);
	/* RCOMP: Dither PU Enable */
	mrc_alt_write_mask(DDRPHY, CMDANADRVPUCTL, 1 << 30, 1 << 30);
	/* RCOMP: Dither PD Enable */
	mrc_alt_write_mask(DDRPHY, CMDANADRVPDCTL, 1 << 30, 1 << 30);
	/* RCOMP: Dither PU Enable */
	mrc_alt_write_mask(DDRPHY, CLKANADRVPUCTL, 1 << 30, 1 << 30);
	/* RCOMP: Dither PD Enable */
	mrc_alt_write_mask(DDRPHY, CLKANADRVPDCTL, 1 << 30, 1 << 30);
	/* RCOMP: Dither PU Enable */
	mrc_alt_write_mask(DDRPHY, DQSANADRVPUCTL, 1 << 30, 1 << 30);
	/* RCOMP: Dither PD Enable */
	mrc_alt_write_mask(DDRPHY, DQSANADRVPDCTL, 1 << 30, 1 << 30);
	/* RCOMP: Dither PU Enable */
	mrc_alt_write_mask(DDRPHY, CTLANADRVPUCTL, 1 << 30, 1 << 30);
	/* RCOMP: Dither PD Enable */
	mrc_alt_write_mask(DDRPHY, CTLANADRVPDCTL, 1 << 30, 1 << 30);
	/* ODT: Dither PU Enable */
	mrc_alt_write_mask(DDRPHY, DQANAODTPUCTL, 1 << 30, 1 << 30);
	/* ODT: Dither PD Enable */
	mrc_alt_write_mask(DDRPHY, DQANAODTPDCTL, 1 << 30, 1 << 30);
	/* ODT: Dither PU Enable */
	mrc_alt_write_mask(DDRPHY, CLKANAODTPUCTL, 1 << 30, 1 << 30);
	/* ODT: Dither PD Enable */
	mrc_alt_write_mask(DDRPHY, CLKANAODTPDCTL, 1 << 30, 1 << 30);
	/* ODT: Dither PU Enable */
	mrc_alt_write_mask(DDRPHY, DQSANAODTPUCTL, 1 << 30, 1 << 30);
	/* ODT: Dither PD Enable */
	mrc_alt_write_mask(DDRPHY, DQSANAODTPDCTL, 1 << 30, 1 << 30);
	/* DCOMP: Dither PU Enable */
	mrc_alt_write_mask(DDRPHY, DQANADLYPUCTL, 1 << 30, 1 << 30);
	/* DCOMP: Dither PD Enable */
	mrc_alt_write_mask(DDRPHY, DQANADLYPDCTL, 1 << 30, 1 << 30);
	/* DCOMP: Dither PU Enable */
	mrc_alt_write_mask(DDRPHY, CMDANADLYPUCTL, 1 << 30, 1 << 30);
	/* DCOMP: Dither PD Enable */
	mrc_alt_write_mask(DDRPHY, CMDANADLYPDCTL, 1 << 30, 1 << 30);
	/* DCOMP: Dither PU Enable */
	mrc_alt_write_mask(DDRPHY, CLKANADLYPUCTL, 1 << 30, 1 << 30);
	/* DCOMP: Dither PD Enable */
	mrc_alt_write_mask(DDRPHY, CLKANADLYPDCTL, 1 << 30, 1 << 30);
	/* DCOMP: Dither PU Enable */
	mrc_alt_write_mask(DDRPHY, DQSANADLYPUCTL, 1 << 30, 1 << 30);
	/* DCOMP: Dither PD Enable */
	mrc_alt_write_mask(DDRPHY, DQSANADLYPDCTL, 1 << 30, 1 << 30);
	/* DCOMP: Dither PU Enable */
	mrc_alt_write_mask(DDRPHY, CTLANADLYPUCTL, 1 << 30, 1 << 30);
	/* DCOMP: Dither PD Enable */
	mrc_alt_write_mask(DDRPHY, CTLANADLYPDCTL, 1 << 30, 1 << 30);
	/* TCO: Dither PU Enable */
	mrc_alt_write_mask(DDRPHY, DQANATCOPUCTL, 1 << 30, 1 << 30);
	/* TCO: Dither PD Enable */
	mrc_alt_write_mask(DDRPHY, DQANATCOPDCTL, 1 << 30, 1 << 30);
	/* TCO: Dither PU Enable */
	mrc_alt_write_mask(DDRPHY, CLKANATCOPUCTL, 1 << 30, 1 << 30);
	/* TCO: Dither PD Enable */
	mrc_alt_write_mask(DDRPHY, CLKANATCOPDCTL, 1 << 30, 1 << 30);
	/* TCO: Dither PU Enable */
	mrc_alt_write_mask(DDRPHY, DQSANATCOPUCTL, 1 << 30, 1 << 30);
	/* TCO: Dither PD Enable */
	mrc_alt_write_mask(DDRPHY, DQSANATCOPDCTL, 1 << 30, 1 << 30);
	/* TCOCOMP: Pulse Count */
	mrc_alt_write_mask(DDRPHY, TCOCNTCTRL, 1, 3);
	/* ODT: CMD/CTL PD/PU */
	mrc_alt_write_mask(DDRPHY, CHNLBUFSTATIC,
		(0x03 << 24) | (0x03 << 16), 0x1f1f0000);
	/* Set 1us counter */
	mrc_alt_write_mask(DDRPHY, MSCNTR, 0x64, 0xff);
	mrc_alt_write_mask(DDRPHY, LATCH1CTL, 0x1 << 28, 0x70000000);

	/* Release PHY from reset */
	mrc_alt_write_mask(DDRPHY, MASTERRSTN, 1, 1);

	/* STEP1 */
	mrc_post_code(0x03, 0x11);

	for (ch = 0; ch < NUM_CHANNELS; ch++) {
		if (mrc_params->channel_enables & (1 << ch)) {
			/* DQ01-DQ23 */
			for (bl_grp = 0;
			     bl_grp < (NUM_BYTE_LANES / bl_divisor) / 2;
			     bl_grp++) {
				mrc_alt_write_mask(DDRPHY,
					DQMDLLCTL +
					bl_grp * DDRIODQ_BL_OFFSET +
					ch * DDRIODQ_CH_OFFSET,
					1 << 13,
					1 << 13);	/* Enable VREG */
				delay_n(3);
			}

			/* ECC */
			mrc_alt_write_mask(DDRPHY, ECCMDLLCTL,
				1 << 13, 1 << 13);	/* Enable VREG */
			delay_n(3);
			/* CMD */
			mrc_alt_write_mask(DDRPHY,
				CMDMDLLCTL + ch * DDRIOCCC_CH_OFFSET,
				1 << 13, 1 << 13);	/* Enable VREG */
			delay_n(3);
			/* CLK-CTL */
			mrc_alt_write_mask(DDRPHY,
				CCMDLLCTL + ch * DDRIOCCC_CH_OFFSET,
				1 << 13, 1 << 13);	/* Enable VREG */
			delay_n(3);
		}
	}

	/* STEP2 */
	mrc_post_code(0x03, 0x12);
	delay_n(200);

	for (ch = 0; ch < NUM_CHANNELS; ch++) {
		if (mrc_params->channel_enables & (1 << ch)) {
			/* DQ01-DQ23 */
			for (bl_grp = 0;
			     bl_grp < (NUM_BYTE_LANES / bl_divisor) / 2;
			     bl_grp++) {
				mrc_alt_write_mask(DDRPHY,
					DQMDLLCTL +
					bl_grp * DDRIODQ_BL_OFFSET +
					ch * DDRIODQ_CH_OFFSET,
					1 << 17,
					1 << 17);	/* Enable MCDLL */
				delay_n(50);
			}

		/* ECC */
		mrc_alt_write_mask(DDRPHY, ECCMDLLCTL,
			1 << 17, 1 << 17);	/* Enable MCDLL */
		delay_n(50);
		/* CMD */
		mrc_alt_write_mask(DDRPHY,
			CMDMDLLCTL + ch * DDRIOCCC_CH_OFFSET,
			1 << 18, 1 << 18);	/* Enable MCDLL */
		delay_n(50);
		/* CLK-CTL */
		mrc_alt_write_mask(DDRPHY,
			CCMDLLCTL + ch * DDRIOCCC_CH_OFFSET,
			1 << 18, 1 << 18);	/* Enable MCDLL */
		delay_n(50);
		}
	}

	/* STEP3: */
	mrc_post_code(0x03, 0x13);
	delay_n(100);

	for (ch = 0; ch < NUM_CHANNELS; ch++) {
		if (mrc_params->channel_enables & (1 << ch)) {
			/* DQ01-DQ23 */
			for (bl_grp = 0;
			     bl_grp < (NUM_BYTE_LANES / bl_divisor) / 2;
			     bl_grp++) {
#ifdef FORCE_16BIT_DDRIO
				temp = (bl_grp &&
					(mrc_params->channel_width == X16)) ?
					0x11ff : 0xffff;
#else
				temp = 0xffff;
#endif
				/* Enable TXDLL */
				mrc_alt_write_mask(DDRPHY,
					DQDLLTXCTL +
					bl_grp * DDRIODQ_BL_OFFSET +
					ch * DDRIODQ_CH_OFFSET,
					temp, 0xffff);
				delay_n(3);
				/* Enable RXDLL */
				mrc_alt_write_mask(DDRPHY,
					DQDLLRXCTL +
					bl_grp * DDRIODQ_BL_OFFSET +
					ch * DDRIODQ_CH_OFFSET,
					0xf, 0xf);
				delay_n(3);
				/* Enable RXDLL Overrides BL0 */
				mrc_alt_write_mask(DDRPHY,
					B0OVRCTL +
					bl_grp * DDRIODQ_BL_OFFSET +
					ch * DDRIODQ_CH_OFFSET,
					0xf, 0xf);
			}

			/* ECC */
			temp = 0xffff;
			mrc_alt_write_mask(DDRPHY, ECCDLLTXCTL,
				temp, 0xffff);
			delay_n(3);

			/* CMD (PO) */
			mrc_alt_write_mask(DDRPHY,
				CMDDLLTXCTL + ch * DDRIOCCC_CH_OFFSET,
				temp, 0xffff);
			delay_n(3);
		}
	}

	/* STEP4 */
	mrc_post_code(0x03, 0x14);

	for (ch = 0; ch < NUM_CHANNELS; ch++) {
		if (mrc_params->channel_enables & (1 << ch)) {
			/* Host To Memory Clock Alignment (HMC) for 800/1066 */
			for (bl_grp = 0;
			     bl_grp < (NUM_BYTE_LANES / bl_divisor) / 2;
			     bl_grp++) {
				/* CLK_ALIGN_MOD_ID */
				mrc_alt_write_mask(DDRPHY,
					DQCLKALIGNREG2 +
					bl_grp * DDRIODQ_BL_OFFSET +
					ch * DDRIODQ_CH_OFFSET,
					bl_grp ? 3 : 1,
					0xf);
			}

			mrc_alt_write_mask(DDRPHY,
				ECCCLKALIGNREG2 + ch * DDRIODQ_CH_OFFSET,
				0x2, 0xf);
			mrc_alt_write_mask(DDRPHY,
				CMDCLKALIGNREG2 + ch * DDRIODQ_CH_OFFSET,
				0x0, 0xf);
			mrc_alt_write_mask(DDRPHY,
				CCCLKALIGNREG2 + ch * DDRIODQ_CH_OFFSET,
				0x2, 0xf);
			mrc_alt_write_mask(DDRPHY,
				CMDCLKALIGNREG0 + ch * DDRIOCCC_CH_OFFSET,
				0x20, 0x30);
			/*
			 * NUM_SAMPLES, MAX_SAMPLES,
			 * MACRO_PI_STEP, MICRO_PI_STEP
			 */
			mrc_alt_write_mask(DDRPHY,
				CMDCLKALIGNREG1 + ch * DDRIOCCC_CH_OFFSET,
				(0x18 << 16) | (0x10 << 8) |
				(0x8 << 2) | (0x1 << 0),
				0x007f7fff);
			/* TOTAL_NUM_MODULES, FIRST_U_PARTITION */
			mrc_alt_write_mask(DDRPHY,
				CMDCLKALIGNREG2 + ch * DDRIOCCC_CH_OFFSET,
				(0x10 << 16) | (0x4 << 8) | (0x2 << 4),
				0x001f0ff0);
#ifdef HMC_TEST
			/* START_CLK_ALIGN=1 */
			mrc_alt_write_mask(DDRPHY,
				CMDCLKALIGNREG0 + ch * DDRIOCCC_CH_OFFSET,
				1 << 24, 1 << 24);
			while (msg_port_alt_read(DDRPHY,
				CMDCLKALIGNREG0 + ch * DDRIOCCC_CH_OFFSET) &
				(1 << 24))
				;	/* wait for START_CLK_ALIGN=0 */
#endif

			/* Set RD/WR Pointer Seperation & COUNTEN & FIFOPTREN */
			mrc_alt_write_mask(DDRPHY,
				CMDPTRREG + ch * DDRIOCCC_CH_OFFSET,
				1, 1);	/* WRPTRENABLE=1 */

			/* COMP initial */
			/* enable bypass for CLK buffer (PO) */
			mrc_alt_write_mask(DDRPHY,
				COMPEN0CH0 + ch * DDRCOMP_CH_OFFSET,
				1 << 5, 1 << 5);
			/* Initial COMP Enable */
			mrc_alt_write_mask(DDRPHY, CMPCTRL, 1, 1);
			/* wait for Initial COMP Enable = 0 */
			while (msg_port_alt_read(DDRPHY, CMPCTRL) & 1)
				;
			/* disable bypass for CLK buffer (PO) */
			mrc_alt_write_mask(DDRPHY,
				COMPEN0CH0 + ch * DDRCOMP_CH_OFFSET,
				~(1 << 5), 1 << 5);

			/* IOBUFACT */

			/* STEP4a */
			mrc_alt_write_mask(DDRPHY,
				CMDCFGREG0 + ch * DDRIOCCC_CH_OFFSET,
				1 << 2, 1 << 2);	/* IOBUFACTRST_N=1 */

			/* DDRPHY initialization complete */
			mrc_alt_write_mask(DDRPHY,
				CMDPMCONFIG0 + ch * DDRIOCCC_CH_OFFSET,
				1 << 20, 1 << 20);	/* SPID_INIT_COMPLETE=1 */
		}
	}

	LEAVEFN();
}

/* This function performs JEDEC initialization on all enabled channels */
void perform_jedec_init(struct mrc_params *mrc_params)
{
	uint8_t twr, wl, rank;
	uint32_t tck;
	u32 dtr0;
	u32 drp;
	u32 drmc;
	u32 mrs0_cmd = 0;
	u32 emrs1_cmd = 0;
	u32 emrs2_cmd = 0;
	u32 emrs3_cmd = 0;

	ENTERFN();

	/* jedec_init starts */
	mrc_post_code(0x04, 0x00);

	/* DDR3_RESET_SET=0, DDR3_RESET_RESET=1 */
	mrc_alt_write_mask(DDRPHY, CCDDR3RESETCTL, 2, 0x102);

	/* Assert RESET# for 200us */
	delay_u(200);

	/* DDR3_RESET_SET=1, DDR3_RESET_RESET=0 */
	mrc_alt_write_mask(DDRPHY, CCDDR3RESETCTL, 0x100, 0x102);

	dtr0 = msg_port_read(MEM_CTLR, DTR0);

	/*
	 * Set CKEVAL for populated ranks
	 * then send NOP to each rank (#4550197)
	 */

	drp = msg_port_read(MEM_CTLR, DRP);
	drp &= 0x3;

	drmc = msg_port_read(MEM_CTLR, DRMC);
	drmc &= 0xfffffffc;
	drmc |= (DRMC_CKEMODE | drp);

	msg_port_write(MEM_CTLR, DRMC, drmc);

	for (rank = 0; rank < NUM_RANKS; rank++) {
		/* Skip to next populated rank */
		if ((mrc_params->rank_enables & (1 << rank)) == 0)
			continue;

		dram_init_command(DCMD_NOP(rank));
	}

	msg_port_write(MEM_CTLR, DRMC,
		(mrc_params->rd_odt_value == 0 ? DRMC_ODTMODE : 0));

	/*
	 * setup for emrs 2
	 * BIT[15:11] --> Always "0"
	 * BIT[10:09] --> Rtt_WR: want "Dynamic ODT Off" (0)
	 * BIT[08]    --> Always "0"
	 * BIT[07]    --> SRT: use sr_temp_range
	 * BIT[06]    --> ASR: want "Manual SR Reference" (0)
	 * BIT[05:03] --> CWL: use oem_tCWL
	 * BIT[02:00] --> PASR: want "Full Array" (0)
	 */
	emrs2_cmd |= (2 << 3);
	wl = 5 + mrc_params->ddr_speed;
	emrs2_cmd |= ((wl - 5) << 9);
	emrs2_cmd |= (mrc_params->sr_temp_range << 13);

	/*
	 * setup for emrs 3
	 * BIT[15:03] --> Always "0"
	 * BIT[02]    --> MPR: want "Normal Operation" (0)
	 * BIT[01:00] --> MPR_Loc: want "Predefined Pattern" (0)
	 */
	emrs3_cmd |= (3 << 3);

	/*
	 * setup for emrs 1
	 * BIT[15:13]     --> Always "0"
	 * BIT[12:12]     --> Qoff: want "Output Buffer Enabled" (0)
	 * BIT[11:11]     --> TDQS: want "Disabled" (0)
	 * BIT[10:10]     --> Always "0"
	 * BIT[09,06,02]  --> Rtt_nom: use rtt_nom_value
	 * BIT[08]        --> Always "0"
	 * BIT[07]        --> WR_LVL: want "Disabled" (0)
	 * BIT[05,01]     --> DIC: use ron_value
	 * BIT[04:03]     --> AL: additive latency want "0" (0)
	 * BIT[00]        --> DLL: want "Enable" (0)
	 *
	 * (BIT5|BIT1) set Ron value
	 * 00 --> RZQ/6 (40ohm)
	 * 01 --> RZQ/7 (34ohm)
	 * 1* --> RESERVED
	 *
	 * (BIT9|BIT6|BIT2) set Rtt_nom value
	 * 000 --> Disabled
	 * 001 --> RZQ/4 ( 60ohm)
	 * 010 --> RZQ/2 (120ohm)
	 * 011 --> RZQ/6 ( 40ohm)
	 * 1** --> RESERVED
	 */
	emrs1_cmd |= (1 << 3);
	emrs1_cmd &= ~(1 << 6);

	if (mrc_params->ron_value == 0)
		emrs1_cmd |= (1 << 7);
	else
		emrs1_cmd &= ~(1 << 7);

	if (mrc_params->rtt_nom_value == 0)
		emrs1_cmd |= (DDR3_EMRS1_RTTNOM_40 << 6);
	else if (mrc_params->rtt_nom_value == 1)
		emrs1_cmd |= (DDR3_EMRS1_RTTNOM_60 << 6);
	else if (mrc_params->rtt_nom_value == 2)
		emrs1_cmd |= (DDR3_EMRS1_RTTNOM_120 << 6);

	/* save MRS1 value (excluding control fields) */
	mrc_params->mrs1 = emrs1_cmd >> 6;

	/*
	 * setup for mrs 0
	 * BIT[15:13]     --> Always "0"
	 * BIT[12]        --> PPD: for Quark (1)
	 * BIT[11:09]     --> WR: use oem_tWR
	 * BIT[08]        --> DLL: want "Reset" (1, self clearing)
	 * BIT[07]        --> MODE: want "Normal" (0)
	 * BIT[06:04,02]  --> CL: use oem_tCAS
	 * BIT[03]        --> RD_BURST_TYPE: want "Interleave" (1)
	 * BIT[01:00]     --> BL: want "8 Fixed" (0)
	 * WR:
	 * 0 --> 16
	 * 1 --> 5
	 * 2 --> 6
	 * 3 --> 7
	 * 4 --> 8
	 * 5 --> 10
	 * 6 --> 12
	 * 7 --> 14
	 * CL:
	 * BIT[02:02] "0" if oem_tCAS <= 11 (1866?)
	 * BIT[06:04] use oem_tCAS-4
	 */
	mrs0_cmd |= (1 << 14);
	mrs0_cmd |= (1 << 18);
	mrs0_cmd |= ((((dtr0 >> 12) & 7) + 1) << 10);

	tck = t_ck[mrc_params->ddr_speed];
	/* Per JEDEC: tWR=15000ps DDR2/3 from 800-1600 */
	twr = MCEIL(15000, tck);
	mrs0_cmd |= ((twr - 4) << 15);

	for (rank = 0; rank < NUM_RANKS; rank++) {
		/* Skip to next populated rank */
		if ((mrc_params->rank_enables & (1 << rank)) == 0)
			continue;

		emrs2_cmd |= (rank << 22);
		dram_init_command(emrs2_cmd);

		emrs3_cmd |= (rank << 22);
		dram_init_command(emrs3_cmd);

		emrs1_cmd |= (rank << 22);
		dram_init_command(emrs1_cmd);

		mrs0_cmd |= (rank << 22);
		dram_init_command(mrs0_cmd);

		dram_init_command(DCMD_ZQCL(rank));
	}

	LEAVEFN();
}

/*
 * Dunit Initialization Complete
 *
 * Indicates that initialization of the Dunit has completed.
 *
 * Memory accesses are permitted and maintenance operation begins.
 * Until this bit is set to a 1, the memory controller will not accept
 * DRAM requests from the MEMORY_MANAGER or HTE.
 */
void set_ddr_init_complete(struct mrc_params *mrc_params)
{
	u32 dco;

	ENTERFN();

	dco = msg_port_read(MEM_CTLR, DCO);
	dco &= ~DCO_PMICTL;
	dco |= DCO_IC;
	msg_port_write(MEM_CTLR, DCO, dco);

	LEAVEFN();
}

/*
 * This function will retrieve relevant timing data
 *
 * This data will be used on subsequent boots to speed up boot times
 * and is required for Suspend To RAM capabilities.
 */
void restore_timings(struct mrc_params *mrc_params)
{
	uint8_t ch, rk, bl;
	const struct mrc_timings *mt = &mrc_params->timings;

	for (ch = 0; ch < NUM_CHANNELS; ch++) {
		for (rk = 0; rk < NUM_RANKS; rk++) {
			for (bl = 0; bl < NUM_BYTE_LANES; bl++) {
				set_rcvn(ch, rk, bl, mt->rcvn[ch][rk][bl]);
				set_rdqs(ch, rk, bl, mt->rdqs[ch][rk][bl]);
				set_wdqs(ch, rk, bl, mt->wdqs[ch][rk][bl]);
				set_wdq(ch, rk, bl, mt->wdq[ch][rk][bl]);
				if (rk == 0) {
					/* VREF (RANK0 only) */
					set_vref(ch, bl, mt->vref[ch][bl]);
				}
			}
			set_wctl(ch, rk, mt->wctl[ch][rk]);
		}
		set_wcmd(ch, mt->wcmd[ch]);
	}
}

/*
 * Configure default settings normally set as part of read training
 *
 * Some defaults have to be set earlier as they may affect earlier
 * training steps.
 */
void default_timings(struct mrc_params *mrc_params)
{
	uint8_t ch, rk, bl;

	for (ch = 0; ch < NUM_CHANNELS; ch++) {
		for (rk = 0; rk < NUM_RANKS; rk++) {
			for (bl = 0; bl < NUM_BYTE_LANES; bl++) {
				set_rdqs(ch, rk, bl, 24);
				if (rk == 0) {
					/* VREF (RANK0 only) */
					set_vref(ch, bl, 32);
				}
			}
		}
	}
}

/*
 * This function will perform our RCVEN Calibration Algorithm.
 * We will only use the 2xCLK domain timings to perform RCVEN Calibration.
 * All byte lanes will be calibrated "simultaneously" per channel per rank.
 */
void rcvn_cal(struct mrc_params *mrc_params)
{
	uint8_t ch;	/* channel counter */
	uint8_t rk;	/* rank counter */
	uint8_t bl;	/* byte lane counter */
	uint8_t bl_divisor = (mrc_params->channel_width == X16) ? 2 : 1;

#ifdef R2R_SHARING
	/* used to find placement for rank2rank sharing configs */
	uint32_t final_delay[NUM_CHANNELS][NUM_BYTE_LANES];
#ifndef BACKUP_RCVN
	/* used to find placement for rank2rank sharing configs */
	uint32_t num_ranks_enabled = 0;
#endif
#endif

#ifdef BACKUP_RCVN
#else
	uint32_t temp;
	/* absolute PI value to be programmed on the byte lane */
	uint32_t delay[NUM_BYTE_LANES];
	u32 dtr1, dtr1_save;
#endif

	ENTERFN();

	/* rcvn_cal starts */
	mrc_post_code(0x05, 0x00);

#ifndef BACKUP_RCVN
	/* need separate burst to sample DQS preamble */
	dtr1 = msg_port_read(MEM_CTLR, DTR1);
	dtr1_save = dtr1;
	dtr1 |= DTR1_TCCD_12CLK;
	msg_port_write(MEM_CTLR, DTR1, dtr1);
#endif

#ifdef R2R_SHARING
	/* need to set "final_delay[][]" elements to "0" */
	memset((void *)(final_delay), 0x00, (size_t)sizeof(final_delay));
#endif

	/* loop through each enabled channel */
	for (ch = 0; ch < NUM_CHANNELS; ch++) {
		if (mrc_params->channel_enables & (1 << ch)) {
			/* perform RCVEN Calibration on a per rank basis */
			for (rk = 0; rk < NUM_RANKS; rk++) {
				if (mrc_params->rank_enables & (1 << rk)) {
					/*
					 * POST_CODE here indicates the current
					 * channel and rank being calibrated
					 */
					mrc_post_code(0x05, 0x10 + ((ch << 4) | rk));

#ifdef BACKUP_RCVN
					/* et hard-coded timing values */
					for (bl = 0; bl < (NUM_BYTE_LANES / bl_divisor); bl++)
						set_rcvn(ch, rk, bl, ddr_rcvn[PLATFORM_ID]);
#else
					/* enable FIFORST */
					for (bl = 0; bl < (NUM_BYTE_LANES / bl_divisor); bl += 2) {
						mrc_alt_write_mask(DDRPHY,
							B01PTRCTL1 +
							(bl >> 1) * DDRIODQ_BL_OFFSET +
							ch * DDRIODQ_CH_OFFSET,
							0, 1 << 8);
					}
					/* initialize the starting delay to 128 PI (cas +1 CLK) */
					for (bl = 0; bl < (NUM_BYTE_LANES / bl_divisor); bl++) {
						/* 1x CLK domain timing is cas-4 */
						delay[bl] = (4 + 1) * FULL_CLK;

						set_rcvn(ch, rk, bl, delay[bl]);
					}

					/* now find the rising edge */
					find_rising_edge(mrc_params, delay, ch, rk, true);

					/* Now increase delay by 32 PI (1/4 CLK) to place in center of high pulse */
					for (bl = 0; bl < (NUM_BYTE_LANES / bl_divisor); bl++) {
						delay[bl] += QRTR_CLK;
						set_rcvn(ch, rk, bl, delay[bl]);
					}
					/* Now decrement delay by 128 PI (1 CLK) until we sample a "0" */
					do {
						temp = sample_dqs(mrc_params, ch, rk, true);
						for (bl = 0; bl < (NUM_BYTE_LANES / bl_divisor); bl++) {
							if (temp & (1 << bl)) {
								if (delay[bl] >= FULL_CLK) {
									delay[bl] -= FULL_CLK;
									set_rcvn(ch, rk, bl, delay[bl]);
								} else {
									/* not enough delay */
									training_message(ch, rk, bl);
									mrc_post_code(0xee, 0x50);
								}
							}
						}
					} while (temp & 0xff);

#ifdef R2R_SHARING
					/* increment "num_ranks_enabled" */
					num_ranks_enabled++;
					/* Finally increment delay by 32 PI (1/4 CLK) to place in center of preamble */
					for (bl = 0; bl < (NUM_BYTE_LANES / bl_divisor); bl++) {
						delay[bl] += QRTR_CLK;
						/* add "delay[]" values to "final_delay[][]" for rolling average */
						final_delay[ch][bl] += delay[bl];
						/* set timing based on rolling average values */
						set_rcvn(ch, rk, bl, final_delay[ch][bl] / num_ranks_enabled);
					}
#else
					/* Finally increment delay by 32 PI (1/4 CLK) to place in center of preamble */
					for (bl = 0; bl < (NUM_BYTE_LANES / bl_divisor); bl++) {
						delay[bl] += QRTR_CLK;
						set_rcvn(ch, rk, bl, delay[bl]);
					}
#endif

					/* disable FIFORST */
					for (bl = 0; bl < (NUM_BYTE_LANES / bl_divisor); bl += 2) {
						mrc_alt_write_mask(DDRPHY,
							B01PTRCTL1 +
							(bl >> 1) * DDRIODQ_BL_OFFSET +
							ch * DDRIODQ_CH_OFFSET,
							1 << 8, 1 << 8);
					}
#endif
				}
			}
		}
	}

#ifndef BACKUP_RCVN
	/* restore original */
	msg_port_write(MEM_CTLR, DTR1, dtr1_save);
#endif

	LEAVEFN();
}

/*
 * This function will perform the Write Levelling algorithm
 * (align WCLK and WDQS).
 *
 * This algorithm will act on each rank in each channel separately.
 */
void wr_level(struct mrc_params *mrc_params)
{
	uint8_t ch;	/* channel counter */
	uint8_t rk;	/* rank counter */
	uint8_t bl;	/* byte lane counter */
	uint8_t bl_divisor = (mrc_params->channel_width == X16) ? 2 : 1;

#ifdef R2R_SHARING
	/* used to find placement for rank2rank sharing configs */
	uint32_t final_delay[NUM_CHANNELS][NUM_BYTE_LANES];
#ifndef BACKUP_WDQS
	/* used to find placement for rank2rank sharing configs */
	uint32_t num_ranks_enabled = 0;
#endif
#endif

#ifdef BACKUP_WDQS
#else
	/* determines stop condition for CRS_WR_LVL */
	bool all_edges_found;
	/* absolute PI value to be programmed on the byte lane */
	uint32_t delay[NUM_BYTE_LANES];
	/*
	 * static makes it so the data is loaded in the heap once by shadow(),
	 * where non-static copies the data onto the stack every time this
	 * function is called
	 */
	uint32_t address;	/* address to be checked during COARSE_WR_LVL */
	u32 dtr4, dtr4_save;
#endif

	ENTERFN();

	/* wr_level starts */
	mrc_post_code(0x06, 0x00);

#ifdef R2R_SHARING
	/* need to set "final_delay[][]" elements to "0" */
	memset((void *)(final_delay), 0x00, (size_t)sizeof(final_delay));
#endif

	/* loop through each enabled channel */
	for (ch = 0; ch < NUM_CHANNELS; ch++) {
		if (mrc_params->channel_enables & (1 << ch)) {
			/* perform WRITE LEVELING algorithm on a per rank basis */
			for (rk = 0; rk < NUM_RANKS; rk++) {
				if (mrc_params->rank_enables & (1 << rk)) {
					/*
					 * POST_CODE here indicates the current
					 * rank and channel being calibrated
					 */
					mrc_post_code(0x06, 0x10 + ((ch << 4) | rk));

#ifdef BACKUP_WDQS
					for (bl = 0; bl < (NUM_BYTE_LANES / bl_divisor); bl++) {
						set_wdqs(ch, rk, bl, ddr_wdqs[PLATFORM_ID]);
						set_wdq(ch, rk, bl, ddr_wdqs[PLATFORM_ID] - QRTR_CLK);
					}
#else
					/*
					 * perform a single PRECHARGE_ALL command to
					 * make DRAM state machine go to IDLE state
					 */
					dram_init_command(DCMD_PREA(rk));

					/*
					 * enable Write Levelling Mode
					 * (EMRS1 w/ Write Levelling Mode Enable)
					 */
					dram_init_command(DCMD_MRS1(rk, 0x82));

					/*
					 * set ODT DRAM Full Time Termination
					 * disable in MCU
					 */

					dtr4 = msg_port_read(MEM_CTLR, DTR4);
					dtr4_save = dtr4;
					dtr4 |= DTR4_ODTDIS;
					msg_port_write(MEM_CTLR, DTR4, dtr4);

					for (bl = 0; bl < (NUM_BYTE_LANES / bl_divisor) / 2; bl++) {
						/*
						 * Enable Sandy Bridge Mode (WDQ Tri-State) &
						 * Ensure 5 WDQS pulses during Write Leveling
						 */
						mrc_alt_write_mask(DDRPHY,
							DQCTL + DDRIODQ_BL_OFFSET * bl + DDRIODQ_CH_OFFSET * ch,
							0x10000154,
							0x100003fc);
					}

					/* Write Leveling Mode enabled in IO */
					mrc_alt_write_mask(DDRPHY,
						CCDDR3RESETCTL + DDRIOCCC_CH_OFFSET * ch,
						1 << 16, 1 << 16);

					/* Initialize the starting delay to WCLK */
					for (bl = 0; bl < (NUM_BYTE_LANES / bl_divisor); bl++) {
						/*
						 * CLK0 --> RK0
						 * CLK1 --> RK1
						 */
						delay[bl] = get_wclk(ch, rk);

						set_wdqs(ch, rk, bl, delay[bl]);
					}

					/* now find the rising edge */
					find_rising_edge(mrc_params, delay, ch, rk, false);

					/* disable Write Levelling Mode */
					mrc_alt_write_mask(DDRPHY,
						CCDDR3RESETCTL + DDRIOCCC_CH_OFFSET * ch,
						0, 1 << 16);

					for (bl = 0; bl < (NUM_BYTE_LANES / bl_divisor) / 2; bl++) {
						/* Disable Sandy Bridge Mode & Ensure 4 WDQS pulses during normal operation */
						mrc_alt_write_mask(DDRPHY,
							DQCTL + DDRIODQ_BL_OFFSET * bl + DDRIODQ_CH_OFFSET * ch,
							0x00000154,
							0x100003fc);
					}

					/* restore original DTR4 */
					msg_port_write(MEM_CTLR, DTR4, dtr4_save);

					/*
					 * restore original value
					 * (Write Levelling Mode Disable)
					 */
					dram_init_command(DCMD_MRS1(rk, mrc_params->mrs1));

					/*
					 * perform a single PRECHARGE_ALL command to
					 * make DRAM state machine go to IDLE state
					 */
					dram_init_command(DCMD_PREA(rk));

					mrc_post_code(0x06, 0x30 + ((ch << 4) | rk));

					/*
					 * COARSE WRITE LEVEL:
					 * check that we're on the correct clock edge
					 */

					/* hte reconfiguration request */
					mrc_params->hte_setup = 1;

					/* start CRS_WR_LVL with WDQS = WDQS + 128 PI */
					for (bl = 0; bl < (NUM_BYTE_LANES / bl_divisor); bl++) {
						delay[bl] = get_wdqs(ch, rk, bl) + FULL_CLK;
						set_wdqs(ch, rk, bl, delay[bl]);
						/*
						 * program WDQ timings based on WDQS
						 * (WDQ = WDQS - 32 PI)
						 */
						set_wdq(ch, rk, bl, (delay[bl] - QRTR_CLK));
					}

					/* get an address in the targeted channel/rank */
					address = get_addr(ch, rk);
					do {
						uint32_t coarse_result = 0x00;
						uint32_t coarse_result_mask = byte_lane_mask(mrc_params);
						/* assume pass */
						all_edges_found = true;

						mrc_params->hte_setup = 1;
						coarse_result = check_rw_coarse(mrc_params, address);

						/* check for failures and margin the byte lane back 128 PI (1 CLK) */
						for (bl = 0; bl < NUM_BYTE_LANES / bl_divisor; bl++) {
							if (coarse_result & (coarse_result_mask << bl)) {
								all_edges_found = false;
								delay[bl] -= FULL_CLK;
								set_wdqs(ch, rk, bl, delay[bl]);
								/* program WDQ timings based on WDQS (WDQ = WDQS - 32 PI) */
								set_wdq(ch, rk, bl, delay[bl] - QRTR_CLK);
							}
						}
					} while (!all_edges_found);

#ifdef R2R_SHARING
					/* increment "num_ranks_enabled" */
					 num_ranks_enabled++;
					/* accumulate "final_delay[][]" values from "delay[]" values for rolling average */
					for (bl = 0; bl < NUM_BYTE_LANES / bl_divisor; bl++) {
						final_delay[ch][bl] += delay[bl];
						set_wdqs(ch, rk, bl, final_delay[ch][bl] / num_ranks_enabled);
						/* program WDQ timings based on WDQS (WDQ = WDQS - 32 PI) */
						set_wdq(ch, rk, bl, final_delay[ch][bl] / num_ranks_enabled - QRTR_CLK);
					}
#endif
#endif
				}
			}
		}
	}

	LEAVEFN();
}

void prog_page_ctrl(struct mrc_params *mrc_params)
{
	u32 dpmc0;

	ENTERFN();

	dpmc0 = msg_port_read(MEM_CTLR, DPMC0);
	dpmc0 &= ~DPMC0_PCLSTO_MASK;
	dpmc0 |= (4 << 16);
	dpmc0 |= DPMC0_PREAPWDEN;
	msg_port_write(MEM_CTLR, DPMC0, dpmc0);
}

/*
 * This function will perform the READ TRAINING Algorithm on all
 * channels/ranks/byte_lanes simultaneously to minimize execution time.
 *
 * The idea here is to train the VREF and RDQS (and eventually RDQ) values
 * to achieve maximum READ margins. The algorithm will first determine the
 * X coordinate (RDQS setting). This is done by collapsing the VREF eye
 * until we find a minimum required RDQS eye for VREF_MIN and VREF_MAX.
 * Then we take the averages of the RDQS eye at VREF_MIN and VREF_MAX,
 * then average those; this will be the final X coordinate. The algorithm
 * will then determine the Y coordinate (VREF setting). This is done by
 * collapsing the RDQS eye until we find a minimum required VREF eye for
 * RDQS_MIN and RDQS_MAX. Then we take the averages of the VREF eye at
 * RDQS_MIN and RDQS_MAX, then average those; this will be the final Y
 * coordinate.
 *
 * NOTE: this algorithm assumes the eye curves have a one-to-one relationship,
 * meaning for each X the curve has only one Y and vice-a-versa.
 */
void rd_train(struct mrc_params *mrc_params)
{
	uint8_t ch;	/* channel counter */
	uint8_t rk;	/* rank counter */
	uint8_t bl;	/* byte lane counter */
	uint8_t bl_divisor = (mrc_params->channel_width == X16) ? 2 : 1;
#ifdef BACKUP_RDQS
#else
	uint8_t side_x;	/* tracks LEFT/RIGHT approach vectors */
	uint8_t side_y;	/* tracks BOTTOM/TOP approach vectors */
	/* X coordinate data (passing RDQS values) for approach vectors */
	uint8_t x_coordinate[2][2][NUM_CHANNELS][NUM_RANKS][NUM_BYTE_LANES];
	/* Y coordinate data (passing VREF values) for approach vectors */
	uint8_t y_coordinate[2][2][NUM_CHANNELS][NUM_BYTE_LANES];
	/* centered X (RDQS) */
	uint8_t x_center[NUM_CHANNELS][NUM_RANKS][NUM_BYTE_LANES];
	/* centered Y (VREF) */
	uint8_t y_center[NUM_CHANNELS][NUM_BYTE_LANES];
	uint32_t address;	/* target address for check_bls_ex() */
	uint32_t result;	/* result of check_bls_ex() */
	uint32_t bl_mask;	/* byte lane mask for result checking */
#ifdef R2R_SHARING
	/* used to find placement for rank2rank sharing configs */
	uint32_t final_delay[NUM_CHANNELS][NUM_BYTE_LANES];
	/* used to find placement for rank2rank sharing configs */
	uint32_t num_ranks_enabled = 0;
#endif
#endif

	/* rd_train starts */
	mrc_post_code(0x07, 0x00);

	ENTERFN();

#ifdef BACKUP_RDQS
	for (ch = 0; ch < NUM_CHANNELS; ch++) {
		if (mrc_params->channel_enables & (1 << ch)) {
			for (rk = 0; rk < NUM_RANKS; rk++) {
				if (mrc_params->rank_enables & (1 << rk)) {
					for (bl = 0;
					     bl < NUM_BYTE_LANES / bl_divisor;
					     bl++) {
						set_rdqs(ch, rk, bl, ddr_rdqs[PLATFORM_ID]);
					}
				}
			}
		}
	}
#else
	/* initialize x/y_coordinate arrays */
	for (ch = 0; ch < NUM_CHANNELS; ch++) {
		if (mrc_params->channel_enables & (1 << ch)) {
			for (rk = 0; rk < NUM_RANKS; rk++) {
				if (mrc_params->rank_enables & (1 << rk)) {
					for (bl = 0;
					     bl < NUM_BYTE_LANES / bl_divisor;
					     bl++) {
						/* x_coordinate */
						x_coordinate[L][B][ch][rk][bl] = RDQS_MIN;
						x_coordinate[R][B][ch][rk][bl] = RDQS_MAX;
						x_coordinate[L][T][ch][rk][bl] = RDQS_MIN;
						x_coordinate[R][T][ch][rk][bl] = RDQS_MAX;
						/* y_coordinate */
						y_coordinate[L][B][ch][bl] = VREF_MIN;
						y_coordinate[R][B][ch][bl] = VREF_MIN;
						y_coordinate[L][T][ch][bl] = VREF_MAX;
						y_coordinate[R][T][ch][bl] = VREF_MAX;
					}
				}
			}
		}
	}

	/* initialize other variables */
	bl_mask = byte_lane_mask(mrc_params);
	address = get_addr(0, 0);

#ifdef R2R_SHARING
	/* need to set "final_delay[][]" elements to "0" */
	memset((void *)(final_delay), 0x00, (size_t)sizeof(final_delay));
#endif

	/* look for passing coordinates */
	for (side_y = B; side_y <= T; side_y++) {
		for (side_x = L; side_x <= R; side_x++) {
			mrc_post_code(0x07, 0x10 + side_y * 2 + side_x);

			/* find passing values */
			for (ch = 0; ch < NUM_CHANNELS; ch++) {
				if (mrc_params->channel_enables & (0x1 << ch)) {
					for (rk = 0; rk < NUM_RANKS; rk++) {
						if (mrc_params->rank_enables &
							(0x1 << rk)) {
							/* set x/y_coordinate search starting settings */
							for (bl = 0;
							     bl < NUM_BYTE_LANES / bl_divisor;
							     bl++) {
								set_rdqs(ch, rk, bl,
									 x_coordinate[side_x][side_y][ch][rk][bl]);
								set_vref(ch, bl,
									 y_coordinate[side_x][side_y][ch][bl]);
							}

							/* get an address in the target channel/rank */
							address = get_addr(ch, rk);

							/* request HTE reconfiguration */
							mrc_params->hte_setup = 1;

							/* test the settings */
							do {
								/* result[07:00] == failing byte lane (MAX 8) */
								result = check_bls_ex(mrc_params, address);

								/* check for failures */
								if (result & 0xff) {
									/* at least 1 byte lane failed */
									for (bl = 0; bl < NUM_BYTE_LANES / bl_divisor; bl++) {
										if (result &
											(bl_mask << bl)) {
											/* adjust the RDQS values accordingly */
											if (side_x == L)
												x_coordinate[L][side_y][ch][rk][bl] += RDQS_STEP;
											else
												x_coordinate[R][side_y][ch][rk][bl] -= RDQS_STEP;

											/* check that we haven't closed the RDQS_EYE too much */
											if ((x_coordinate[L][side_y][ch][rk][bl] > (RDQS_MAX - MIN_RDQS_EYE)) ||
												(x_coordinate[R][side_y][ch][rk][bl] < (RDQS_MIN + MIN_RDQS_EYE)) ||
												(x_coordinate[L][side_y][ch][rk][bl] ==
												x_coordinate[R][side_y][ch][rk][bl])) {
												/*
												 * not enough RDQS margin available at this VREF
												 * update VREF values accordingly
												 */
												if (side_y == B)
													y_coordinate[side_x][B][ch][bl] += VREF_STEP;
												else
													y_coordinate[side_x][T][ch][bl] -= VREF_STEP;

												/* check that we haven't closed the VREF_EYE too much */
												if ((y_coordinate[side_x][B][ch][bl] > (VREF_MAX - MIN_VREF_EYE)) ||
													(y_coordinate[side_x][T][ch][bl] < (VREF_MIN + MIN_VREF_EYE)) ||
													(y_coordinate[side_x][B][ch][bl] == y_coordinate[side_x][T][ch][bl])) {
													/* VREF_EYE collapsed below MIN_VREF_EYE */
													training_message(ch, rk, bl);
													mrc_post_code(0xEE, 0x70 + side_y * 2 + side_x);
												} else {
													/* update the VREF setting */
													set_vref(ch, bl, y_coordinate[side_x][side_y][ch][bl]);
													/* reset the X coordinate to begin the search at the new VREF */
													x_coordinate[side_x][side_y][ch][rk][bl] =
														(side_x == L) ? RDQS_MIN : RDQS_MAX;
												}
											}

											/* update the RDQS setting */
											set_rdqs(ch, rk, bl, x_coordinate[side_x][side_y][ch][rk][bl]);
										}
									}
								}
							} while (result & 0xff);
						}
					}
				}
			}
		}
	}

	mrc_post_code(0x07, 0x20);

	/* find final RDQS (X coordinate) & final VREF (Y coordinate) */
	for (ch = 0; ch < NUM_CHANNELS; ch++) {
		if (mrc_params->channel_enables & (1 << ch)) {
			for (rk = 0; rk < NUM_RANKS; rk++) {
				if (mrc_params->rank_enables & (1 << rk)) {
					for (bl = 0; bl < (NUM_BYTE_LANES / bl_divisor); bl++) {
						uint32_t temp1;
						uint32_t temp2;

						/* x_coordinate */
						DPF(D_INFO,
						    "RDQS T/B eye rank%d lane%d : %d-%d %d-%d\n",
						    rk, bl,
						    x_coordinate[L][T][ch][rk][bl],
						    x_coordinate[R][T][ch][rk][bl],
						    x_coordinate[L][B][ch][rk][bl],
						    x_coordinate[R][B][ch][rk][bl]);

						/* average the TOP side LEFT & RIGHT values */
						temp1 = (x_coordinate[R][T][ch][rk][bl] + x_coordinate[L][T][ch][rk][bl]) / 2;
						/* average the BOTTOM side LEFT & RIGHT values */
						temp2 = (x_coordinate[R][B][ch][rk][bl] + x_coordinate[L][B][ch][rk][bl]) / 2;
						/* average the above averages */
						x_center[ch][rk][bl] = (uint8_t) ((temp1 + temp2) / 2);

						/* y_coordinate */
						DPF(D_INFO,
						    "VREF R/L eye lane%d : %d-%d %d-%d\n",
						    bl,
						    y_coordinate[R][B][ch][bl],
						    y_coordinate[R][T][ch][bl],
						    y_coordinate[L][B][ch][bl],
						    y_coordinate[L][T][ch][bl]);

						/* average the RIGHT side TOP & BOTTOM values */
						temp1 = (y_coordinate[R][T][ch][bl] + y_coordinate[R][B][ch][bl]) / 2;
						/* average the LEFT side TOP & BOTTOM values */
						temp2 = (y_coordinate[L][T][ch][bl] + y_coordinate[L][B][ch][bl]) / 2;
						/* average the above averages */
						y_center[ch][bl] = (uint8_t) ((temp1 + temp2) / 2);
					}
				}
			}
		}
	}

#ifdef RX_EYE_CHECK
	/* perform an eye check */
	for (side_y = B; side_y <= T; side_y++) {
		for (side_x = L; side_x <= R; side_x++) {
			mrc_post_code(0x07, 0x30 + side_y * 2 + side_x);

			/* update the settings for the eye check */
			for (ch = 0; ch < NUM_CHANNELS; ch++) {
				if (mrc_params->channel_enables & (1 << ch)) {
					for (rk = 0; rk < NUM_RANKS; rk++) {
						if (mrc_params->rank_enables & (1 << rk)) {
							for (bl = 0; bl < NUM_BYTE_LANES / bl_divisor; bl++) {
								if (side_x == L)
									set_rdqs(ch, rk, bl, x_center[ch][rk][bl] - (MIN_RDQS_EYE / 2));
								else
									set_rdqs(ch, rk, bl, x_center[ch][rk][bl] + (MIN_RDQS_EYE / 2));

								if (side_y == B)
									set_vref(ch, bl, y_center[ch][bl] - (MIN_VREF_EYE / 2));
								else
									set_vref(ch, bl, y_center[ch][bl] + (MIN_VREF_EYE / 2));
							}
						}
					}
				}
			}

			/* request HTE reconfiguration */
			mrc_params->hte_setup = 1;

			/* check the eye */
			if (check_bls_ex(mrc_params, address) & 0xff) {
				/* one or more byte lanes failed */
				mrc_post_code(0xee, 0x74 + side_x * 2 + side_y);
			}
		}
	}
#endif

	mrc_post_code(0x07, 0x40);

	/* set final placements */
	for (ch = 0; ch < NUM_CHANNELS; ch++) {
		if (mrc_params->channel_enables & (1 << ch)) {
			for (rk = 0; rk < NUM_RANKS; rk++) {
				if (mrc_params->rank_enables & (1 << rk)) {
#ifdef R2R_SHARING
					/* increment "num_ranks_enabled" */
					num_ranks_enabled++;
#endif
					for (bl = 0; bl < (NUM_BYTE_LANES / bl_divisor); bl++) {
						/* x_coordinate */
#ifdef R2R_SHARING
						final_delay[ch][bl] += x_center[ch][rk][bl];
						set_rdqs(ch, rk, bl, final_delay[ch][bl] / num_ranks_enabled);
#else
						set_rdqs(ch, rk, bl, x_center[ch][rk][bl]);
#endif
						/* y_coordinate */
						set_vref(ch, bl, y_center[ch][bl]);
					}
				}
			}
		}
	}
#endif

	LEAVEFN();
}

/*
 * This function will perform the WRITE TRAINING Algorithm on all
 * channels/ranks/byte_lanes simultaneously to minimize execution time.
 *
 * The idea here is to train the WDQ timings to achieve maximum WRITE margins.
 * The algorithm will start with WDQ at the current WDQ setting (tracks WDQS
 * in WR_LVL) +/- 32 PIs (+/- 1/4 CLK) and collapse the eye until all data
 * patterns pass. This is because WDQS will be aligned to WCLK by the
 * Write Leveling algorithm and WDQ will only ever have a 1/2 CLK window
 * of validity.
 */
void wr_train(struct mrc_params *mrc_params)
{
	uint8_t ch;	/* channel counter */
	uint8_t rk;	/* rank counter */
	uint8_t bl;	/* byte lane counter */
	uint8_t bl_divisor = (mrc_params->channel_width == X16) ? 2 : 1;
#ifdef BACKUP_WDQ
#else
	uint8_t side;		/* LEFT/RIGHT side indicator (0=L, 1=R) */
	uint32_t temp;		/* temporary DWORD */
	/* 2 arrays, for L & R side passing delays */
	uint32_t delay[2][NUM_CHANNELS][NUM_RANKS][NUM_BYTE_LANES];
	uint32_t address;	/* target address for check_bls_ex() */
	uint32_t result;	/* result of check_bls_ex() */
	uint32_t bl_mask;	/* byte lane mask for result checking */
#ifdef R2R_SHARING
	/* used to find placement for rank2rank sharing configs */
	uint32_t final_delay[NUM_CHANNELS][NUM_BYTE_LANES];
	/* used to find placement for rank2rank sharing configs */
	uint32_t num_ranks_enabled = 0;
#endif
#endif

	/* wr_train starts */
	mrc_post_code(0x08, 0x00);

	ENTERFN();

#ifdef BACKUP_WDQ
	for (ch = 0; ch < NUM_CHANNELS; ch++) {
		if (mrc_params->channel_enables & (1 << ch)) {
			for (rk = 0; rk < NUM_RANKS; rk++) {
				if (mrc_params->rank_enables & (1 << rk)) {
					for (bl = 0;
					     bl < NUM_BYTE_LANES / bl_divisor;
					     bl++) {
						set_wdq(ch, rk, bl, ddr_wdq[PLATFORM_ID]);
					}
				}
			}
		}
	}
#else
	/* initialize "delay" */
	for (ch = 0; ch < NUM_CHANNELS; ch++) {
		if (mrc_params->channel_enables & (1 << ch)) {
			for (rk = 0; rk < NUM_RANKS; rk++) {
				if (mrc_params->rank_enables & (1 << rk)) {
					for (bl = 0;
					     bl < NUM_BYTE_LANES / bl_divisor;
					     bl++) {
						/*
						 * want to start with
						 * WDQ = (WDQS - QRTR_CLK)
						 * +/- QRTR_CLK
						 */
						temp = get_wdqs(ch, rk, bl) - QRTR_CLK;
						delay[L][ch][rk][bl] = temp - QRTR_CLK;
						delay[R][ch][rk][bl] = temp + QRTR_CLK;
					}
				}
			}
		}
	}

	/* initialize other variables */
	bl_mask = byte_lane_mask(mrc_params);
	address = get_addr(0, 0);

#ifdef R2R_SHARING
	/* need to set "final_delay[][]" elements to "0" */
	memset((void *)(final_delay), 0x00, (size_t)sizeof(final_delay));
#endif

	/*
	 * start algorithm on the LEFT side and train each channel/bl
	 * until no failures are observed, then repeat for the RIGHT side.
	 */
	for (side = L; side <= R; side++) {
		mrc_post_code(0x08, 0x10 + side);

		/* set starting values */
		for (ch = 0; ch < NUM_CHANNELS; ch++) {
			if (mrc_params->channel_enables & (1 << ch)) {
				for (rk = 0; rk < NUM_RANKS; rk++) {
					if (mrc_params->rank_enables &
						(1 << rk)) {
						for (bl = 0;
						     bl < NUM_BYTE_LANES / bl_divisor;
						     bl++) {
							set_wdq(ch, rk, bl, delay[side][ch][rk][bl]);
						}
					}
				}
			}
		}

		/* find passing values */
		for (ch = 0; ch < NUM_CHANNELS; ch++) {
			if (mrc_params->channel_enables & (1 << ch)) {
				for (rk = 0; rk < NUM_RANKS; rk++) {
					if (mrc_params->rank_enables &
						(1 << rk)) {
						/* get an address in the target channel/rank */
						address = get_addr(ch, rk);

						/* request HTE reconfiguration */
						mrc_params->hte_setup = 1;

						/* check the settings */
						do {
							/* result[07:00] == failing byte lane (MAX 8) */
							result = check_bls_ex(mrc_params, address);
							/* check for failures */
							if (result & 0xff) {
								/* at least 1 byte lane failed */
								for (bl = 0; bl < NUM_BYTE_LANES / bl_divisor; bl++) {
									if (result &
										(bl_mask << bl)) {
										if (side == L)
											delay[L][ch][rk][bl] += WDQ_STEP;
										else
											delay[R][ch][rk][bl] -= WDQ_STEP;

										/* check for algorithm failure */
										if (delay[L][ch][rk][bl] != delay[R][ch][rk][bl]) {
											/*
											 * margin available
											 * update delay setting
											 */
											set_wdq(ch, rk, bl,
												delay[side][ch][rk][bl]);
										} else {
											/*
											 * no margin available
											 * notify the user and halt
											 */
											training_message(ch, rk, bl);
											mrc_post_code(0xee, 0x80 + side);
										}
									}
								}
							}
						/* stop when all byte lanes pass */
						} while (result & 0xff);
					}
				}
			}
		}
	}

	/* program WDQ to the middle of passing window */
	for (ch = 0; ch < NUM_CHANNELS; ch++) {
		if (mrc_params->channel_enables & (1 << ch)) {
			for (rk = 0; rk < NUM_RANKS; rk++) {
				if (mrc_params->rank_enables & (1 << rk)) {
#ifdef R2R_SHARING
					/* increment "num_ranks_enabled" */
					num_ranks_enabled++;
#endif
					for (bl = 0; bl < NUM_BYTE_LANES / bl_divisor; bl++) {
						DPF(D_INFO,
						    "WDQ eye rank%d lane%d : %d-%d\n",
						    rk, bl,
						    delay[L][ch][rk][bl],
						    delay[R][ch][rk][bl]);

						temp = (delay[R][ch][rk][bl] + delay[L][ch][rk][bl]) / 2;

#ifdef R2R_SHARING
						final_delay[ch][bl] += temp;
						set_wdq(ch, rk, bl,
							final_delay[ch][bl] / num_ranks_enabled);
#else
						set_wdq(ch, rk, bl, temp);
#endif
					}
				}
			}
		}
	}
#endif

	LEAVEFN();
}

/*
 * This function will store relevant timing data
 *
 * This data will be used on subsequent boots to speed up boot times
 * and is required for Suspend To RAM capabilities.
 */
void store_timings(struct mrc_params *mrc_params)
{
	uint8_t ch, rk, bl;
	struct mrc_timings *mt = &mrc_params->timings;

	for (ch = 0; ch < NUM_CHANNELS; ch++) {
		for (rk = 0; rk < NUM_RANKS; rk++) {
			for (bl = 0; bl < NUM_BYTE_LANES; bl++) {
				mt->rcvn[ch][rk][bl] = get_rcvn(ch, rk, bl);
				mt->rdqs[ch][rk][bl] = get_rdqs(ch, rk, bl);
				mt->wdqs[ch][rk][bl] = get_wdqs(ch, rk, bl);
				mt->wdq[ch][rk][bl] = get_wdq(ch, rk, bl);

				if (rk == 0)
					mt->vref[ch][bl] = get_vref(ch, bl);
			}

			mt->wctl[ch][rk] = get_wctl(ch, rk);
		}

		mt->wcmd[ch] = get_wcmd(ch);
	}

	/* need to save for a case of changing frequency after warm reset */
	mt->ddr_speed = mrc_params->ddr_speed;
}

/*
 * The purpose of this function is to ensure the SEC comes out of reset
 * and IA initiates the SEC enabling Memory Scrambling.
 */
void enable_scrambling(struct mrc_params *mrc_params)
{
	uint32_t lfsr = 0;
	uint8_t i;

	if (mrc_params->scrambling_enables == 0)
		return;

	ENTERFN();

	/* 32 bit seed is always stored in BIOS NVM */
	lfsr = mrc_params->timings.scrambler_seed;

	if (mrc_params->boot_mode == BM_COLD) {
		/*
		 * factory value is 0 and in first boot,
		 * a clock based seed is loaded.
		 */
		if (lfsr == 0) {
			/*
			 * get seed from system clock
			 * and make sure it is not all 1's
			 */
			lfsr = rdtsc() & 0x0fffffff;
		} else {
			/*
			 * Need to replace scrambler
			 *
			 * get next 32bit LFSR 16 times which is the last
			 * part of the previous scrambler vector
			 */
			for (i = 0; i < 16; i++)
				lfsr32(&lfsr);
		}

		/* save new seed */
		mrc_params->timings.scrambler_seed = lfsr;
	}

	/*
	 * In warm boot or S3 exit, we have the previous seed.
	 * In cold boot, we have the last 32bit LFSR which is the new seed.
	 */
	lfsr32(&lfsr);	/* shift to next value */
	msg_port_write(MEM_CTLR, SCRMSEED, (lfsr & 0x0003ffff));

	for (i = 0; i < 2; i++)
		msg_port_write(MEM_CTLR, SCRMLO + i, (lfsr & 0xaaaaaaaa));

	LEAVEFN();
}

/*
 * Configure MCU Power Management Control Register
 * and Scheduler Control Register
 */
void prog_ddr_control(struct mrc_params *mrc_params)
{
	u32 dsch;
	u32 dpmc0;

	ENTERFN();

	dsch = msg_port_read(MEM_CTLR, DSCH);
	dsch &= ~(DSCH_OOODIS | DSCH_OOOST3DIS | DSCH_NEWBYPDIS);
	msg_port_write(MEM_CTLR, DSCH, dsch);

	dpmc0 = msg_port_read(MEM_CTLR, DPMC0);
	dpmc0 &= ~DPMC0_DISPWRDN;
	dpmc0 |= (mrc_params->power_down_disable << 25);
	dpmc0 &= ~DPMC0_CLKGTDIS;
	dpmc0 &= ~DPMC0_PCLSTO_MASK;
	dpmc0 |= (4 << 16);
	dpmc0 |= DPMC0_PREAPWDEN;
	msg_port_write(MEM_CTLR, DPMC0, dpmc0);

	/* CMDTRIST = 2h - CMD/ADDR are tristated when no valid command */
	mrc_write_mask(MEM_CTLR, DPMC1, 0x20, 0x30);

	LEAVEFN();
}

/*
 * After training complete configure MCU Rank Population Register
 * specifying: ranks enabled, device width, density, address mode
 */
void prog_dra_drb(struct mrc_params *mrc_params)
{
	u32 drp;
	u32 dco;
	u8 density = mrc_params->params.density;

	ENTERFN();

	dco = msg_port_read(MEM_CTLR, DCO);
	dco &= ~DCO_IC;
	msg_port_write(MEM_CTLR, DCO, dco);

	drp = 0;
	if (mrc_params->rank_enables & 1)
		drp |= DRP_RKEN0;
	if (mrc_params->rank_enables & 2)
		drp |= DRP_RKEN1;
	if (mrc_params->dram_width == X16) {
		drp |= (1 << 4);
		drp |= (1 << 9);
	}

	/*
	 * Density encoding in struct dram_params: 0=512Mb, 1=Gb, 2=2Gb, 3=4Gb
	 * has to be mapped RANKDENSx encoding (0=1Gb)
	 */
	if (density == 0)
		density = 4;

	drp |= ((density - 1) << 6);
	drp |= ((density - 1) << 11);

	/* Address mode can be overwritten if ECC enabled */
	drp |= (mrc_params->address_mode << 14);

	msg_port_write(MEM_CTLR, DRP, drp);

	dco &= ~DCO_PMICTL;
	dco |= DCO_IC;
	msg_port_write(MEM_CTLR, DCO, dco);

	LEAVEFN();
}

/* Send DRAM wake command */
void perform_wake(struct mrc_params *mrc_params)
{
	ENTERFN();

	dram_wake_command();

	LEAVEFN();
}

/*
 * Configure refresh rate and short ZQ calibration interval
 * Activate dynamic self refresh
 */
void change_refresh_period(struct mrc_params *mrc_params)
{
	u32 drfc;
	u32 dcal;
	u32 dpmc0;

	ENTERFN();

	drfc = msg_port_read(MEM_CTLR, DRFC);
	drfc &= ~DRFC_TREFI_MASK;
	drfc |= (mrc_params->refresh_rate << 12);
	drfc |= DRFC_REFDBTCLR;
	msg_port_write(MEM_CTLR, DRFC, drfc);

	dcal = msg_port_read(MEM_CTLR, DCAL);
	dcal &= ~DCAL_ZQCINT_MASK;
	dcal |= (3 << 8);	/* 63ms */
	msg_port_write(MEM_CTLR, DCAL, dcal);

	dpmc0 = msg_port_read(MEM_CTLR, DPMC0);
	dpmc0 |= (DPMC0_DYNSREN | DPMC0_ENPHYCLKGATE);
	msg_port_write(MEM_CTLR, DPMC0, dpmc0);

	LEAVEFN();
}

/*
 * Configure DDRPHY for Auto-Refresh, Periodic Compensations,
 * Dynamic Diff-Amp, ZQSPERIOD, Auto-Precharge, CKE Power-Down
 */
void set_auto_refresh(struct mrc_params *mrc_params)
{
	uint32_t channel;
	uint32_t rank;
	uint32_t bl;
	uint32_t bl_divisor = 1;
	uint32_t temp;

	ENTERFN();

	/*
	 * Enable Auto-Refresh, Periodic Compensations, Dynamic Diff-Amp,
	 * ZQSPERIOD, Auto-Precharge, CKE Power-Down
	 */
	for (channel = 0; channel < NUM_CHANNELS; channel++) {
		if (mrc_params->channel_enables & (1 << channel)) {
			/* Enable Periodic RCOMPS */
			mrc_alt_write_mask(DDRPHY, CMPCTRL, 2, 2);

			/* Enable Dynamic DiffAmp & Set Read ODT Value */
			switch (mrc_params->rd_odt_value) {
			case 0:
				temp = 0x3f;	/* OFF */
				break;
			default:
				temp = 0x00;	/* Auto */
				break;
			}

			for (bl = 0; bl < (NUM_BYTE_LANES / bl_divisor) / 2; bl++) {
				/* Override: DIFFAMP, ODT */
				mrc_alt_write_mask(DDRPHY,
					B0OVRCTL + bl * DDRIODQ_BL_OFFSET +
					channel * DDRIODQ_CH_OFFSET,
					temp << 10,
					0x003ffc00);

				/* Override: DIFFAMP, ODT */
				mrc_alt_write_mask(DDRPHY,
					B1OVRCTL + bl * DDRIODQ_BL_OFFSET +
					channel * DDRIODQ_CH_OFFSET,
					temp << 10,
					0x003ffc00);
			}

			/* Issue ZQCS command */
			for (rank = 0; rank < NUM_RANKS; rank++) {
				if (mrc_params->rank_enables & (1 << rank))
					dram_init_command(DCMD_ZQCS(rank));
			}
		}
	}

	clear_pointers();

	LEAVEFN();
}

/*
 * Depending on configuration enables ECC support
 *
 * Available memory size is decreased, and updated with 0s
 * in order to clear error status. Address mode 2 forced.
 */
void ecc_enable(struct mrc_params *mrc_params)
{
	u32 drp;
	u32 dsch;
	u32 ecc_ctrl;

	if (mrc_params->ecc_enables == 0)
		return;

	ENTERFN();

	/* Configuration required in ECC mode */
	drp = msg_port_read(MEM_CTLR, DRP);
	drp &= ~DRP_ADDRMAP_MASK;
	drp |= DRP_ADDRMAP_MAP1;
	drp |= DRP_PRI64BSPLITEN;
	msg_port_write(MEM_CTLR, DRP, drp);

	/* Disable new request bypass */
	dsch = msg_port_read(MEM_CTLR, DSCH);
	dsch |= DSCH_NEWBYPDIS;
	msg_port_write(MEM_CTLR, DSCH, dsch);

	/* Enable ECC */
	ecc_ctrl = (DECCCTRL_SBEEN | DECCCTRL_DBEEN | DECCCTRL_ENCBGEN);
	msg_port_write(MEM_CTLR, DECCCTRL, ecc_ctrl);

	/* Assume 8 bank memory, one bank is gone for ECC */
	mrc_params->mem_size -= mrc_params->mem_size / 8;

	/* For S3 resume memory content has to be preserved */
	if (mrc_params->boot_mode != BM_S3) {
		select_hte();
		hte_mem_init(mrc_params, MRC_MEM_INIT);
		select_mem_mgr();
	}

	LEAVEFN();
}

/*
 * Execute memory test
 * if error detected it is indicated in mrc_params->status
 */
void memory_test(struct mrc_params *mrc_params)
{
	uint32_t result = 0;

	ENTERFN();

	select_hte();
	result = hte_mem_init(mrc_params, MRC_MEM_TEST);
	select_mem_mgr();

	DPF(D_INFO, "Memory test result %x\n", result);
	mrc_params->status = ((result == 0) ? MRC_SUCCESS : MRC_E_MEMTEST);
	LEAVEFN();
}

/* Lock MCU registers at the end of initialization sequence */
void lock_registers(struct mrc_params *mrc_params)
{
	u32 dco;

	ENTERFN();

	dco = msg_port_read(MEM_CTLR, DCO);
	dco &= ~(DCO_PMICTL | DCO_PMIDIS);
	dco |= (DCO_DRPLOCK | DCO_CPGCLOCK);
	msg_port_write(MEM_CTLR, DCO, dco);

	LEAVEFN();
}
