/* This function does the actual uploading of an Fman microcode to an Fman.  */
static void fm_upload_ucode(int fm_idx, struct fm_imem *imem, u32 *ucode, unsigned int size)
/* This function does the actual uploading of an Fman microcode to an Fman.  */
static void fm_upload_ucode(int fm_idx, struct fm_imem *imem, u32 *ucode, unsigned int size)
{
	unsigned int i;
	unsigned int timeout = 1000000;
	out_be32(&imem->iadd, IRAM_IADD_AIE);
	for (i = 0; i < size / 4; i++)
		out_be32(&imem->idata, (be32_to_cpu(ucode[i])));
	out_be32(&imem->iadd, 0);
	while ((in_be32(&imem->idata) != be32_to_cpu(ucode[0])) && --timeout)
		;
	if (!timeout)
		printf("Fman%u: microcode upload timeout\n", fm_idx + 1);
	out_be32(&imem->iready, IRAM_READY);
}