/* After detecting the DDR type this function will pause until the initialization is complete. Each DDR type has mask of multiple bits. The size of the field depends on the DDR Type. If the initialization does not complete and error will be returned and will cause the boot to halt.  */
static int am654_ddrss_dram_wait_for_init_complt(struct am654_ddrss_desc *ddrss)
/* After detecting the DDR type this function will pause until the initialization is complete. Each DDR type has mask of multiple bits. The size of the field depends on the DDR Type. If the initialization does not complete and error will be returned and will cause the boot to halt.  */
static int am654_ddrss_dram_wait_for_init_complt(struct am654_ddrss_desc *ddrss)
{
	u32 val, mask;
	val = am654_ddrss_get_type(ddrss);
	switch (val) {
	case DDR_TYPE_LPDDR4:
	case DDR_TYPE_DDR4:
		mask = DDR4_STAT_MODE_MASK;
		break;
	case DDR_TYPE_DDR3:
		mask = DDR3_STAT_MODE_MASK;
		break;
	default:
		printf("Unsupported DDR type 0x%x\n", val);
		return -EINVAL;
	}
	if (!wait_on_value(mask, DDR_MODE_NORMAL,
			   ddrss->ddrss_ctl_cfg + DDRSS_DDRCTL_STAT, LDELAY))
		return -ETIMEDOUT;
	return 0;
}