/* This function will return the amout of WCLK delay on the given channel, rank as an absolute PI count.  */
uint32_t get_wclk(uint8_t channel, uint8_t rank)
/* This function will return the amout of WCLK delay on the given channel, rank as an absolute PI count.  */
uint32_t get_wclk(uint8_t channel, uint8_t rank)
{
	uint32_t reg;
	uint32_t temp;
	uint32_t pi_count;
	ENTERFN();
	reg = CCPTRREG + channel * DDRIOCCC_CH_OFFSET;
	temp = msg_port_alt_read(DDRPHY, reg);
	temp >>= rank ? 12 : 8;
	temp &= 0xf;
	pi_count = temp * HALF_CLK;
	reg = rank ? ECCB1DLLPICODER0 : ECCB1DLLPICODER0;
	reg += (channel * DDRIOCCC_CH_OFFSET);
	temp = msg_port_alt_read(DDRPHY, reg);
	temp >>= rank ? 16 : 8;
	temp &= 0x3f;
	pi_count += temp;
	LEAVEFN();
	return pi_count;
}