Merge branch 'timers/for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[cascardo/linux.git] / sound / soc / pxa / pxa2xx-ac97.c
index e173799..059af81 100644 (file)
@@ -61,7 +61,7 @@ static unsigned short pxa2xx_ac97_read(struct snd_ac97 *ac97,
        mutex_lock(&car_mutex);
 
        /* set up primary or secondary codec/modem space */
-#ifdef CONFIG_PXA27x
+#if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
        reg_addr = ac97->num ? &SAC_REG_BASE : &PAC_REG_BASE;
 #else
        if (reg == AC97_GPIO_STATUS)
@@ -87,7 +87,7 @@ static unsigned short pxa2xx_ac97_read(struct snd_ac97 *ac97,
        wait_event_timeout(gsr_wq, (GSR | gsr_bits) & GSR_SDONE, 1);
        if (!((GSR | gsr_bits) & GSR_SDONE)) {
                printk(KERN_ERR "%s: read error (ac97_reg=%x GSR=%#lx)\n",
-                               __FUNCTION__, reg, GSR | gsr_bits);
+                               __func__, reg, GSR | gsr_bits);
                val = -1;
                goto out;
        }
@@ -111,7 +111,7 @@ static void pxa2xx_ac97_write(struct snd_ac97 *ac97, unsigned short reg,
        mutex_lock(&car_mutex);
 
        /* set up primary or secondary codec/modem space */
-#ifdef CONFIG_PXA27x
+#if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
        reg_addr = ac97->num ? &SAC_REG_BASE : &PAC_REG_BASE;
 #else
        if (reg == AC97_GPIO_STATUS)
@@ -127,13 +127,16 @@ static void pxa2xx_ac97_write(struct snd_ac97 *ac97, unsigned short reg,
        wait_event_timeout(gsr_wq, (GSR | gsr_bits) & GSR_CDONE, 1);
        if (!((GSR | gsr_bits) & GSR_CDONE))
                printk(KERN_ERR "%s: write error (ac97_reg=%x GSR=%#lx)\n",
-                               __FUNCTION__, reg, GSR | gsr_bits);
+                               __func__, reg, GSR | gsr_bits);
 
        mutex_unlock(&car_mutex);
 }
 
 static void pxa2xx_ac97_warm_reset(struct snd_ac97 *ac97)
 {
+#ifdef CONFIG_PXA3xx
+       int timeout = 100;
+#endif
        gsr_bits = 0;
 
 #ifdef CONFIG_PXA27x
@@ -144,6 +147,11 @@ static void pxa2xx_ac97_warm_reset(struct snd_ac97 *ac97)
        GCR |= GCR_WARM_RST;
        pxa_gpio_mode(113 | GPIO_ALT_FN_2_OUT);
        udelay(500);
+#elif defined(CONFIG_PXA3xx)
+       /* Can't use interrupts */
+       GCR |= GCR_WARM_RST;
+       while (!((GSR | gsr_bits) & (GSR_PCR | GSR_SCR)) && timeout--)
+               mdelay(1);
 #else
        GCR |= GCR_WARM_RST | GCR_PRIRDY_IEN | GCR_SECRDY_IEN;
        wait_event_timeout(gsr_wq, gsr_bits & (GSR_PCR | GSR_SCR), 1);
@@ -151,7 +159,7 @@ static void pxa2xx_ac97_warm_reset(struct snd_ac97 *ac97)
 
        if (!((GSR | gsr_bits) & (GSR_PCR | GSR_SCR)))
                printk(KERN_INFO "%s: warm reset timeout (GSR=%#lx)\n",
-                                __FUNCTION__, gsr_bits);
+                                __func__, gsr_bits);
 
        GCR &= ~(GCR_PRIRDY_IEN|GCR_SECRDY_IEN);
        GCR |= GCR_SDONE_IE|GCR_CDONE_IE;
@@ -159,6 +167,16 @@ static void pxa2xx_ac97_warm_reset(struct snd_ac97 *ac97)
 
 static void pxa2xx_ac97_cold_reset(struct snd_ac97 *ac97)
 {
+#ifdef CONFIG_PXA3xx
+       int timeout = 1000;
+
+       /* Hold CLKBPB for 100us */
+       GCR = 0;
+       GCR = GCR_CLKBPB;
+       udelay(100);
+       GCR = 0;
+#endif
+
        GCR &=  GCR_COLD_RST;  /* clear everything but nCRST */
        GCR &= ~GCR_COLD_RST;  /* then assert nCRST */
 
@@ -170,6 +188,13 @@ static void pxa2xx_ac97_cold_reset(struct snd_ac97 *ac97)
        clk_disable(ac97conf_clk);
        GCR = GCR_COLD_RST;
        udelay(50);
+#elif defined(CONFIG_PXA3xx)
+       /* Can't use interrupts on PXA3xx */
+       GCR &= ~(GCR_PRIRDY_IEN|GCR_SECRDY_IEN);
+
+       GCR = GCR_WARM_RST | GCR_COLD_RST;
+       while (!(GSR & (GSR_PCR | GSR_SCR)) && timeout--)
+               mdelay(10);
 #else
        GCR = GCR_COLD_RST;
        GCR |= GCR_CDONE_IE|GCR_SDONE_IE;
@@ -178,7 +203,7 @@ static void pxa2xx_ac97_cold_reset(struct snd_ac97 *ac97)
 
        if (!((GSR | gsr_bits) & (GSR_PCR | GSR_SCR)))
                printk(KERN_INFO "%s: cold reset timeout (GSR=%#lx)\n",
-                                __FUNCTION__, gsr_bits);
+                                __func__, gsr_bits);
 
        GCR &= ~(GCR_PRIRDY_IEN|GCR_SECRDY_IEN);
        GCR |= GCR_SDONE_IE|GCR_CDONE_IE;
@@ -258,7 +283,7 @@ static struct pxa2xx_pcm_dma_params pxa2xx_ac97_pcm_mic_mono_in = {
 
 #ifdef CONFIG_PM
 static int pxa2xx_ac97_suspend(struct platform_device *pdev,
-       struct snd_soc_cpu_dai *dai)
+       struct snd_soc_dai *dai)
 {
        GCR |= GCR_ACLINK_OFF;
        clk_disable(ac97_clk);
@@ -266,7 +291,7 @@ static int pxa2xx_ac97_suspend(struct platform_device *pdev,
 }
 
 static int pxa2xx_ac97_resume(struct platform_device *pdev,
-       struct snd_soc_cpu_dai *dai)
+       struct snd_soc_dai *dai)
 {
        pxa_gpio_mode(GPIO31_SYNC_AC97_MD);
        pxa_gpio_mode(GPIO30_SDATA_OUT_AC97_MD);
@@ -285,7 +310,8 @@ static int pxa2xx_ac97_resume(struct platform_device *pdev,
 #define pxa2xx_ac97_resume     NULL
 #endif
 
-static int pxa2xx_ac97_probe(struct platform_device *pdev)
+static int pxa2xx_ac97_probe(struct platform_device *pdev,
+                            struct snd_soc_dai *dai)
 {
        int ret;
 
@@ -330,7 +356,8 @@ static int pxa2xx_ac97_probe(struct platform_device *pdev)
        return ret;
 }
 
-static void pxa2xx_ac97_remove(struct platform_device *pdev)
+static void pxa2xx_ac97_remove(struct platform_device *pdev,
+                              struct snd_soc_dai *dai)
 {
        GCR |= GCR_ACLINK_OFF;
        free_irq(IRQ_AC97, NULL);
@@ -347,7 +374,7 @@ static int pxa2xx_ac97_hw_params(struct snd_pcm_substream *substream,
                                struct snd_pcm_hw_params *params)
 {
        struct snd_soc_pcm_runtime *rtd = substream->private_data;
-       struct snd_soc_cpu_dai *cpu_dai = rtd->dai->cpu_dai;
+       struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
 
        if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
                cpu_dai->dma_data = &pxa2xx_ac97_pcm_stereo_out;
@@ -361,7 +388,7 @@ static int pxa2xx_ac97_hw_aux_params(struct snd_pcm_substream *substream,
        struct snd_pcm_hw_params *params)
 {
        struct snd_soc_pcm_runtime *rtd = substream->private_data;
-       struct snd_soc_cpu_dai *cpu_dai = rtd->dai->cpu_dai;
+       struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
 
        if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
                cpu_dai->dma_data = &pxa2xx_ac97_pcm_aux_mono_out;
@@ -375,7 +402,7 @@ static int pxa2xx_ac97_hw_mic_params(struct snd_pcm_substream *substream,
        struct snd_pcm_hw_params *params)
 {
        struct snd_soc_pcm_runtime *rtd = substream->private_data;
-       struct snd_soc_cpu_dai *cpu_dai = rtd->dai->cpu_dai;
+       struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
 
        if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
                return -ENODEV;
@@ -393,7 +420,7 @@ static int pxa2xx_ac97_hw_mic_params(struct snd_pcm_substream *substream,
  * There is only 1 physical AC97 interface for pxa2xx, but it
  * has extra fifo's that can be used for aux DACs and ADCs.
  */
-struct snd_soc_cpu_dai pxa_ac97_dai[] = {
+struct snd_soc_dai pxa_ac97_dai[] = {
 {
        .name = "pxa2xx-ac97",
        .id = 0,