]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - sound/soc/au1x/psc-ac97.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc
[karo-tx-linux.git] / sound / soc / au1x / psc-ac97.c
index 986dcec79fa02e1552fb631456878cb9dbe5f940..84f31e1f9d249c5700b6c00b01ed370a81cbcefd 100644 (file)
@@ -79,28 +79,28 @@ static unsigned short au1xpsc_ac97_read(struct snd_ac97 *ac97,
        unsigned short retry, tmo;
        unsigned long data;
 
-       au_writel(PSC_AC97EVNT_CD, AC97_EVNT(pscdata));
-       au_sync();
+       __raw_writel(PSC_AC97EVNT_CD, AC97_EVNT(pscdata));
+       wmb(); /* drain writebuffer */
 
        retry = AC97_RW_RETRIES;
        do {
                mutex_lock(&pscdata->lock);
 
-               au_writel(PSC_AC97CDC_RD | PSC_AC97CDC_INDX(reg),
+               __raw_writel(PSC_AC97CDC_RD | PSC_AC97CDC_INDX(reg),
                          AC97_CDC(pscdata));
-               au_sync();
+               wmb(); /* drain writebuffer */
 
                tmo = 20;
                do {
                        udelay(21);
-                       if (au_readl(AC97_EVNT(pscdata)) & PSC_AC97EVNT_CD)
+                       if (__raw_readl(AC97_EVNT(pscdata)) & PSC_AC97EVNT_CD)
                                break;
                } while (--tmo);
 
-               data = au_readl(AC97_CDC(pscdata));
+               data = __raw_readl(AC97_CDC(pscdata));
 
-               au_writel(PSC_AC97EVNT_CD, AC97_EVNT(pscdata));
-               au_sync();
+               __raw_writel(PSC_AC97EVNT_CD, AC97_EVNT(pscdata));
+               wmb(); /* drain writebuffer */
 
                mutex_unlock(&pscdata->lock);
 
@@ -119,26 +119,26 @@ static void au1xpsc_ac97_write(struct snd_ac97 *ac97, unsigned short reg,
        struct au1xpsc_audio_data *pscdata = ac97_to_pscdata(ac97);
        unsigned int tmo, retry;
 
-       au_writel(PSC_AC97EVNT_CD, AC97_EVNT(pscdata));
-       au_sync();
+       __raw_writel(PSC_AC97EVNT_CD, AC97_EVNT(pscdata));
+       wmb(); /* drain writebuffer */
 
        retry = AC97_RW_RETRIES;
        do {
                mutex_lock(&pscdata->lock);
 
-               au_writel(PSC_AC97CDC_INDX(reg) | (val & 0xffff),
+               __raw_writel(PSC_AC97CDC_INDX(reg) | (val & 0xffff),
                          AC97_CDC(pscdata));
-               au_sync();
+               wmb(); /* drain writebuffer */
 
                tmo = 20;
                do {
                        udelay(21);
-                       if (au_readl(AC97_EVNT(pscdata)) & PSC_AC97EVNT_CD)
+                       if (__raw_readl(AC97_EVNT(pscdata)) & PSC_AC97EVNT_CD)
                                break;
                } while (--tmo);
 
-               au_writel(PSC_AC97EVNT_CD, AC97_EVNT(pscdata));
-               au_sync();
+               __raw_writel(PSC_AC97EVNT_CD, AC97_EVNT(pscdata));
+               wmb(); /* drain writebuffer */
 
                mutex_unlock(&pscdata->lock);
        } while (--retry && !tmo);
@@ -149,11 +149,11 @@ static void au1xpsc_ac97_warm_reset(struct snd_ac97 *ac97)
 {
        struct au1xpsc_audio_data *pscdata = ac97_to_pscdata(ac97);
 
-       au_writel(PSC_AC97RST_SNC, AC97_RST(pscdata));
-       au_sync();
+       __raw_writel(PSC_AC97RST_SNC, AC97_RST(pscdata));
+       wmb(); /* drain writebuffer */
        msleep(10);
-       au_writel(0, AC97_RST(pscdata));
-       au_sync();
+       __raw_writel(0, AC97_RST(pscdata));
+       wmb(); /* drain writebuffer */
 }
 
 static void au1xpsc_ac97_cold_reset(struct snd_ac97 *ac97)
@@ -162,25 +162,25 @@ static void au1xpsc_ac97_cold_reset(struct snd_ac97 *ac97)
        int i;
 
        /* disable PSC during cold reset */
-       au_writel(0, AC97_CFG(au1xpsc_ac97_workdata));
-       au_sync();
-       au_writel(PSC_CTRL_DISABLE, PSC_CTRL(pscdata));
-       au_sync();
+       __raw_writel(0, AC97_CFG(au1xpsc_ac97_workdata));
+       wmb(); /* drain writebuffer */
+       __raw_writel(PSC_CTRL_DISABLE, PSC_CTRL(pscdata));
+       wmb(); /* drain writebuffer */
 
        /* issue cold reset */
-       au_writel(PSC_AC97RST_RST, AC97_RST(pscdata));
-       au_sync();
+       __raw_writel(PSC_AC97RST_RST, AC97_RST(pscdata));
+       wmb(); /* drain writebuffer */
        msleep(500);
-       au_writel(0, AC97_RST(pscdata));
-       au_sync();
+       __raw_writel(0, AC97_RST(pscdata));
+       wmb(); /* drain writebuffer */
 
        /* enable PSC */
-       au_writel(PSC_CTRL_ENABLE, PSC_CTRL(pscdata));
-       au_sync();
+       __raw_writel(PSC_CTRL_ENABLE, PSC_CTRL(pscdata));
+       wmb(); /* drain writebuffer */
 
        /* wait for PSC to indicate it's ready */
        i = 1000;
-       while (!((au_readl(AC97_STAT(pscdata)) & PSC_AC97STAT_SR)) && (--i))
+       while (!((__raw_readl(AC97_STAT(pscdata)) & PSC_AC97STAT_SR)) && (--i))
                msleep(1);
 
        if (i == 0) {
@@ -189,12 +189,12 @@ static void au1xpsc_ac97_cold_reset(struct snd_ac97 *ac97)
        }
 
        /* enable the ac97 function */
-       au_writel(pscdata->cfg | PSC_AC97CFG_DE_ENABLE, AC97_CFG(pscdata));
-       au_sync();
+       __raw_writel(pscdata->cfg | PSC_AC97CFG_DE_ENABLE, AC97_CFG(pscdata));
+       wmb(); /* drain writebuffer */
 
        /* wait for AC97 core to become ready */
        i = 1000;
-       while (!((au_readl(AC97_STAT(pscdata)) & PSC_AC97STAT_DR)) && (--i))
+       while (!((__raw_readl(AC97_STAT(pscdata)) & PSC_AC97STAT_DR)) && (--i))
                msleep(1);
        if (i == 0)
                printk(KERN_ERR "au1xpsc-ac97: AC97 ctrl not ready\n");
@@ -218,8 +218,8 @@ static int au1xpsc_ac97_hw_params(struct snd_pcm_substream *substream,
 
        chans = params_channels(params);
 
-       r = ro = au_readl(AC97_CFG(pscdata));
-       stat = au_readl(AC97_STAT(pscdata));
+       r = ro = __raw_readl(AC97_CFG(pscdata));
+       stat = __raw_readl(AC97_STAT(pscdata));
 
        /* already active? */
        if (stat & (PSC_AC97STAT_TB | PSC_AC97STAT_RB)) {
@@ -252,28 +252,28 @@ static int au1xpsc_ac97_hw_params(struct snd_pcm_substream *substream,
                mutex_lock(&pscdata->lock);
 
                /* disable AC97 device controller first... */
-               au_writel(r & ~PSC_AC97CFG_DE_ENABLE, AC97_CFG(pscdata));
-               au_sync();
+               __raw_writel(r & ~PSC_AC97CFG_DE_ENABLE, AC97_CFG(pscdata));
+               wmb(); /* drain writebuffer */
 
                /* ...wait for it... */
                t = 100;
-               while ((au_readl(AC97_STAT(pscdata)) & PSC_AC97STAT_DR) && --t)
+               while ((__raw_readl(AC97_STAT(pscdata)) & PSC_AC97STAT_DR) && --t)
                        msleep(1);
 
                if (!t)
                        printk(KERN_ERR "PSC-AC97: can't disable!\n");
 
                /* ...write config... */
-               au_writel(r, AC97_CFG(pscdata));
-               au_sync();
+               __raw_writel(r, AC97_CFG(pscdata));
+               wmb(); /* drain writebuffer */
 
                /* ...enable the AC97 controller again... */
-               au_writel(r | PSC_AC97CFG_DE_ENABLE, AC97_CFG(pscdata));
-               au_sync();
+               __raw_writel(r | PSC_AC97CFG_DE_ENABLE, AC97_CFG(pscdata));
+               wmb(); /* drain writebuffer */
 
                /* ...and wait for ready bit */
                t = 100;
-               while ((!(au_readl(AC97_STAT(pscdata)) & PSC_AC97STAT_DR)) && --t)
+               while ((!(__raw_readl(AC97_STAT(pscdata)) & PSC_AC97STAT_DR)) && --t)
                        msleep(1);
 
                if (!t)
@@ -300,21 +300,21 @@ static int au1xpsc_ac97_trigger(struct snd_pcm_substream *substream,
        switch (cmd) {
        case SNDRV_PCM_TRIGGER_START:
        case SNDRV_PCM_TRIGGER_RESUME:
-               au_writel(AC97PCR_CLRFIFO(stype), AC97_PCR(pscdata));
-               au_sync();
-               au_writel(AC97PCR_START(stype), AC97_PCR(pscdata));
-               au_sync();
+               __raw_writel(AC97PCR_CLRFIFO(stype), AC97_PCR(pscdata));
+               wmb(); /* drain writebuffer */
+               __raw_writel(AC97PCR_START(stype), AC97_PCR(pscdata));
+               wmb(); /* drain writebuffer */
                break;
        case SNDRV_PCM_TRIGGER_STOP:
        case SNDRV_PCM_TRIGGER_SUSPEND:
-               au_writel(AC97PCR_STOP(stype), AC97_PCR(pscdata));
-               au_sync();
+               __raw_writel(AC97PCR_STOP(stype), AC97_PCR(pscdata));
+               wmb(); /* drain writebuffer */
 
-               while (au_readl(AC97_STAT(pscdata)) & AC97STAT_BUSY(stype))
+               while (__raw_readl(AC97_STAT(pscdata)) & AC97STAT_BUSY(stype))
                        asm volatile ("nop");
 
-               au_writel(AC97PCR_CLRFIFO(stype), AC97_PCR(pscdata));
-               au_sync();
+               __raw_writel(AC97PCR_CLRFIFO(stype), AC97_PCR(pscdata));
+               wmb(); /* drain writebuffer */
 
                break;
        default:
@@ -398,13 +398,13 @@ static int au1xpsc_ac97_drvprobe(struct platform_device *pdev)
                  PSC_AC97CFG_DE_ENABLE;
 
        /* preserve PSC clock source set up by platform  */
-       sel = au_readl(PSC_SEL(wd)) & PSC_SEL_CLK_MASK;
-       au_writel(PSC_CTRL_DISABLE, PSC_CTRL(wd));
-       au_sync();
-       au_writel(0, PSC_SEL(wd));
-       au_sync();
-       au_writel(PSC_SEL_PS_AC97MODE | sel, PSC_SEL(wd));
-       au_sync();
+       sel = __raw_readl(PSC_SEL(wd)) & PSC_SEL_CLK_MASK;
+       __raw_writel(PSC_CTRL_DISABLE, PSC_CTRL(wd));
+       wmb(); /* drain writebuffer */
+       __raw_writel(0, PSC_SEL(wd));
+       wmb(); /* drain writebuffer */
+       __raw_writel(PSC_SEL_PS_AC97MODE | sel, PSC_SEL(wd));
+       wmb(); /* drain writebuffer */
 
        /* name the DAI like this device instance ("au1xpsc-ac97.PSCINDEX") */
        memcpy(&wd->dai_drv, &au1xpsc_ac97_dai_template,
@@ -433,10 +433,10 @@ static int au1xpsc_ac97_drvremove(struct platform_device *pdev)
        snd_soc_unregister_component(&pdev->dev);
 
        /* disable PSC completely */
-       au_writel(0, AC97_CFG(wd));
-       au_sync();
-       au_writel(PSC_CTRL_DISABLE, PSC_CTRL(wd));
-       au_sync();
+       __raw_writel(0, AC97_CFG(wd));
+       wmb(); /* drain writebuffer */
+       __raw_writel(PSC_CTRL_DISABLE, PSC_CTRL(wd));
+       wmb(); /* drain writebuffer */
 
        au1xpsc_ac97_workdata = NULL;   /* MDEV */
 
@@ -449,12 +449,12 @@ static int au1xpsc_ac97_drvsuspend(struct device *dev)
        struct au1xpsc_audio_data *wd = dev_get_drvdata(dev);
 
        /* save interesting registers and disable PSC */
-       wd->pm[0] = au_readl(PSC_SEL(wd));
+       wd->pm[0] = __raw_readl(PSC_SEL(wd));
 
-       au_writel(0, AC97_CFG(wd));
-       au_sync();
-       au_writel(PSC_CTRL_DISABLE, PSC_CTRL(wd));
-       au_sync();
+       __raw_writel(0, AC97_CFG(wd));
+       wmb(); /* drain writebuffer */
+       __raw_writel(PSC_CTRL_DISABLE, PSC_CTRL(wd));
+       wmb(); /* drain writebuffer */
 
        return 0;
 }
@@ -464,8 +464,8 @@ static int au1xpsc_ac97_drvresume(struct device *dev)
        struct au1xpsc_audio_data *wd = dev_get_drvdata(dev);
 
        /* restore PSC clock config */
-       au_writel(wd->pm[0] | PSC_SEL_PS_AC97MODE, PSC_SEL(wd));
-       au_sync();
+       __raw_writel(wd->pm[0] | PSC_SEL_PS_AC97MODE, PSC_SEL(wd));
+       wmb(); /* drain writebuffer */
 
        /* after this point the ac97 core will cold-reset the codec.
         * During cold-reset the PSC is reinitialized and the last