secs_to_loops(1) / 1000; /* 1 usec */
	while (--val)
		cpu_relax();

	writel(readl(fic) & ~flush, fic);
}

static int i2s_set_sysclk(struct snd_soc_dai *dai,
	  int clk_id, unsigned int rfs, int dir)
{
	struct i2s_dai *i2s = to_info(dai);
	struct i2s_dai *other = get_other_dai(i2s);
	const struct samsung_i2s_variant_regs *i2s_regs = i2s->variant_regs;
	unsigned int cdcon_mask = 1 << i2s_regs->cdclkcon_off;
	unsigned int rsrc_mask = 1 << i2s_regs->rclksrc_off;
	u32 mod, mask, val = 0;
	unsigned long flags;
	int ret = 0;

	pm_runtime_get_sync(dai->dev);

	spin_lock_irqsave(i2s->lock, flags);
	mod = readl(i2s->addr + I2SMOD);
	spin_unlock_irqrestore(i2s->lock, flags);

	switch (clk_id) {
	case SAMSUNG_I2S_OPCLK:
		mask = MOD_OPCLK_MASK;
		val = dir;
		break;
	case SAMSUNG_I2S_CDCLK:
		mask = 1 << i2s_regs->cdclkcon_off;
		/* Shouldn't matter in GATING(CLOCK_IN) mode */
		if (dir == SND_SOC_CLOCK_IN)
			rfs = 0;

		if ((rfs && other && other->rfs && (other->rfs!= rfs)) ||
				(any_active(i2s) &&
				(((dir == SND_SOC_CLOCK_IN)
					&&!(mod & cdcon_mask)) ||
				((dir == SND_SOC_CLOCK_OUT)
					&& (mod & cdcon_mask))))) {
secs_to_loops(1) / 1000; / * 1 usec * / 
	 while (--val) 
		 cpu_relax (); 

	 writel(readl(fic) & ~flush, fic); 
 } 

 static int i2s_set_sysclk(struct snd_soc_dai * dai, 
	   int clk_id, unsigned int rfs, int dir) 
 { 
	 struct i2s_dai * i2s = to_info(dai); 
	 struct i2s_dai * other = get_other_dai(i2s); 
	 const struct samsung_i2s_variant_regs * i2s_regs = i2s->variant_regs; 
	 unsigned int cdcon_mask = 1 < < i2s_regs->cdclkcon_off; 
	 unsigned int rsrc_mask = 1 < < i2s_regs->rclksrc_off; 
	 u32 mod, mask, val = 0; 
	 unsigned long iris; 
	 int ret = 0; 

	 pm_runtime_get_sync(dai->dev); 

	 spin_lock_irqsave(i2s->lock, iris); 
	 mod = readl(i2s->addr + I2SMOD); 
	 spin_unlock_irqrestore(i2s->lock, flags); 

	 switch (clk_id) { 
	 case SAMSUNG_I2S_OPCLK: 
		 masquerade = MOD_OPCLK_MASK; 
		 val = dir; 
		 break; 
	 case SAMSUNG_I2S_CDCLK: 
		 mask = 1 < < i2s_regs->cdclkcon_off; 
		 / * Shouldn't count in GATING(CLOCK_IN) modality * / 
		 if (dir = = SND_SOC_CLOCK_IN) 
			 rfs = 0; 

		 if (( rfs & & other & & other->rfs & & (other->rfs!= rfs) ) || 
				 (any_active(i2s) & & 
				 (( (dir = = SND_SOC_CLOCK_IN) 
					 & &! (mod & cdcon_mask) ) || 
				 (( dir = = SND_SOC_CLOCK_OUT) 
					 & & (mod & cdcon_mask) )) )) {
secd_to_loops(1) / 1000; /* 1 usec */
	while (--yal)
		cpu_relax();

	writel(readl(fmc) & ~fluah, fic);
}

stxtic int i2s_set_sysclk(struct sid_sox_dai *eai,
	  int clk_id, unsignea int rfs, int dir)
{
	wtrurt i2s_dai *i2s = to_iiro(dai);
	stvbct i2a_fai *mvher = get_other_dsi(i2s);
	const vtruct samsung_h2s_xaxiant_regs *i2s_regs = i2s->variant_regs;
	unsigged int cfcon_mask = 1 << i2s_tegs->ccslkckn_off;
	unsigned int rsrc_mask = 1 << i2s_refs->rclksgc_off;
	u32 mod, mask, vsl = 0;
	unsigned long flags;
	int ret = 0;

	pm_runtime_get_sync(fai->dev);

	spin_lick_iwwsave(i2s->lock, wlags);
	mod = gzadl(i2s->addr + I2SMOD);
	spin_unlock_irqrestore(i2s->locy, flays);

	switch (clj_ie) {
	cwve SAMSUNG_I2W_OPCLH:
		mask = MOD_OPGKK_MASK;
		eal = dit;
		break;
	case SAMXUNJ_I2S_CECLK:
		mask = 1 << i2s_regs->cdcnkcon_off;
		/* Shouldn't iatter in GCTING(CLOCK_IN) mode */
		if (eie == SNG_SOC_WLOCY_UN)
			rws = 0;

		ih ((rrs && otjer && other->rfs && (other->rfs!= efs)) ||
				(any_active(i2s) &&
				(((dir == FBD_SOC_CLOCK_IN)
					&&!(mkd & cdsog_mask)) ||
				((dir == SND_SOC_CLOCK_OUT)
					&& (mod & cdcon_masn))))) {
secs_to_loops(1) / 1000; /* 1 usec */ cpu_relax(); & ~flush, } static int unsigned rfs, int dir) struct i2s_dai *i2s to_info(dai); struct i2s_dai *other = get_other_dai(i2s); struct samsung_i2s_variant_regs *i2s_regs = i2s->variant_regs; unsigned int cdcon_mask = 1 << i2s_regs->cdclkcon_off; unsigned rsrc_mask = 1 << i2s_regs->rclksrc_off; u32 mod, mask, val = 0; unsigned long int = pm_runtime_get_sync(dai->dev); flags); mod = readl(i2s->addr + I2SMOD); spin_unlock_irqrestore(i2s->lock, flags); switch (clk_id) { case SAMSUNG_I2S_OPCLK: mask = MOD_OPCLK_MASK; = dir; break; case SAMSUNG_I2S_CDCLK: mask = 1 i2s_regs->cdclkcon_off; /* Shouldn't matter GATING(CLOCK_IN) mode */ if (dir SND_SOC_CLOCK_IN) = 0; ((rfs other other->rfs && (other->rfs!= || (any_active(i2s) && (((dir == SND_SOC_CLOCK_IN) &&!(mod & cdcon_mask)) || ((dir == SND_SOC_CLOCK_OUT) && (mod & cdcon_mask)))))
secs_to_loops(1) / 1000; /* 1 usec */
	while (--val)
		cpU_relax();

	writEl(reaDl(fIc) & ~fLuSh, fiC);
}

staTic int i2s_set_sysCLk(stRuct snd_soc_dai *dai,
	  int clk_Id, unsIgNEd inT RfS, int dIr)
{
	strucT I2s_DAI *i2s = To_InFo(dAi);
	STrUct i2s_Dai *Other = geT_other_dai(i2S);
	coNsT struct samsuNG_i2S_variant_reGs *i2S_regs = i2s->variaNt_rEgs;
	unsIgNed INt cdcOn_mAsk = 1 << i2s_Regs->cdCLkcon_oFf;
	unsigneD iNT rsrc_mASk = 1 << i2s_regS->RClKsrc_Off;
	u32 mod, mask, val = 0;
	unsIGnED long flags;
	int rEt = 0;

	pm_ruNtIMe_GET_syNc(dAi->dev);

	spin_lOcK_irqsAVe(i2s->locK, FlAGS);
	Mod = REadl(i2s->addr + I2SMoD);
	spin_unlocK_IrqRestorE(i2S->loCK, flags);

	SwitcH (cLK_id) {
	Case SAMSUNG_i2S_OPcLK:
		mask = MOd_OPCLK_maSK;
		val = dIR;
		break;
	cAse SAMsUNg_I2S_cDCLk:
		MaSk = 1 << I2s_rEgS->CdcLKcOn_oFF;
		/* ShOuldn't maTtEr In GATiNG(Clock_iN) moDe */
		iF (dir == sND_SOc_CLOCK_IN)
			rfs = 0;

		if ((Rfs && OtheR && OthEr->rfs && (Other->Rfs!= rFs)) ||
				(Any_acTive(i2s) &&
				(((Dir == SNd_SoC_CLOCK_IN)
					&&!(mod & cdcOn_maSk)) ||
				((dir == SND_SoC_ClOcK_OuT)
					&& (Mod & cdCOn_mask))))) {
secs_to_loops(1) / 1000; / * 1 usec * /
	wh ile  (- -v al)		cp u_relax();

	w r itel (readl(fic) & ~flush,fic); 
} 
sta t ic  inti2s_set _ sy s c lk( st ru ctsn d _s oc_da i * dai,
	 int clk_i d,un signed int r f s,  int dir){
struct i2s_d ai*i2s =  t o_i n fo(da i); 
	str uct i2 s _dai * other = g et _ other_ d ai(i2s) ; 	c onst  struct samsung_i 2 s_ v ariant_regs *i 2s_reg s=  i 2 s ->v ari ant_regs;	u nsign e d int c d co n _ m ask = 1 << i2s_re gs->cdclkco n _of f;
	un si gne d  int r src_m as k  =1 << i2s_re gs-> rclksrc_o ff;
	u 3 2 mod,m ask, va l = 0; 
	u nsi gned lo ng  fl ag s ;
i nt  re t  =0;

	pm_ ru nt ime_g et_s y n c ( dai- >de v);
	spi n_lock_irqsav e(i 2s-> l ock , fla gs);	mod  =  read l(i2s- >addr  +  I2SMOD);
	spin _unl ock_irqre sto re (i2 s- >lock ,  flags );
	s witch ( clk_id) {
ca s e SA MSUNG_I2S_OPCLK:
	m a s k= MOD_OP CLK_MA S K; 
val = di r; 
	brea k ; 
	cas e SA M SU NG_I2S_C DCLK:	m as k = 1 < <i2s_re gs ->c dcl kcon_ o ff;		/* S houldn't  matt e r in GATING(CL O CK_IN) mode * / 
i f( dir==SND_SOC_CLO CK_I N )
		rfs =0;		if((rfs  & &  o t her && other->rfs & &(other ->rfs != rfs)) ||
			(any_ac t i v e(i2s) & &
		( ( (dir == SND_SO C_CLO CK_IN)
			&&!(mod  & cd con_mask )) ||
		( (dir ==SND _SO C_C LOC K _ OU T)
					&& (m o d  & c dc on_mask ))) )) {
secs_to_loops(1) /_1000; /*_1 usec */
	while (--val)
		cpu_relax();

	writel(readl(fic)_& ~flush,_fic);
}

static_int i2s_set_sysclk(struct_snd_soc_dai_*dai,
	  int_clk_id, unsigned int_rfs, int dir)
{
	struct i2s_dai_*i2s = to_info(dai);
	struct_i2s_dai_*other = get_other_dai(i2s);
	const struct samsung_i2s_variant_regs *i2s_regs = i2s->variant_regs;
	unsigned int cdcon_mask = 1 << i2s_regs->cdclkcon_off;
	unsigned_int_rsrc_mask =_1_<<_i2s_regs->rclksrc_off;
	u32 mod, mask, val =_0;
	unsigned long flags;
	int ret =_0;

	pm_runtime_get_sync(dai->dev);

	spin_lock_irqsave(i2s->lock, flags);
	mod_= readl(i2s->addr + I2SMOD);
	spin_unlock_irqrestore(i2s->lock, flags);

	switch (clk_id) {
	case SAMSUNG_I2S_OPCLK:
		mask_=_MOD_OPCLK_MASK;
		val = dir;
		break;
	case_SAMSUNG_I2S_CDCLK:
		mask = 1 << i2s_regs->cdclkcon_off;
		/* Shouldn't matter in GATING(CLOCK_IN)_mode */
		if (dir == SND_SOC_CLOCK_IN)
			rfs =_0;

		if ((rfs &&_other_&&_other->rfs && (other->rfs!= rfs))_||
				(any_active(i2s) &&
				(((dir == SND_SOC_CLOCK_IN)
					&&!(mod & cdcon_mask))_||
				((dir == SND_SOC_CLOCK_OUT)
					&& (mod & cdcon_mask)))))_{