/* Return: 0 when the domain is free. Returns -1 if a timeout occurred waiting for the completion.  */
int psc_wait(u32 domain_num)
/* Return: 0 when the domain is free. Returns -1 if a timeout occurred waiting for the completion.  */
int psc_wait(u32 domain_num)
{
	u32 retry;
	u32 ptstat;
	retry = 0;
	do {
		ptstat = __raw_readl(KS2_PSC_BASE + PSC_REG_PSTAT);
		ptstat = ptstat & (1 << domain_num);
	} while ((ptstat != 0) && ((retry += psc_delay()) <
		 PSC_PTSTAT_TIMEOUT_LIMIT));
	if (retry >= PSC_PTSTAT_TIMEOUT_LIMIT)
		return -1;
	return 0;
}