[ARM] pxa: separate GPIOs and their mode definitions to pxa2xx-gpio.h
[pandora-kernel.git] / sound / soc / pxa / pxa2xx-ac97.c
index 60e6f46..fe9c297 100644 (file)
@@ -15,9 +15,9 @@
 #include <linux/platform_device.h>
 #include <linux/interrupt.h>
 #include <linux/wait.h>
+#include <linux/clk.h>
 #include <linux/delay.h>
 
-#include <sound/driver.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/ac97_codec.h>
@@ -28,6 +28,7 @@
 #include <linux/mutex.h>
 #include <asm/hardware.h>
 #include <asm/arch/pxa-regs.h>
+#include <asm/arch/pxa2xx-gpio.h>
 #include <asm/arch/audio.h>
 
 #include "pxa2xx-pcm.h"
 static DEFINE_MUTEX(car_mutex);
 static DECLARE_WAIT_QUEUE_HEAD(gsr_wq);
 static volatile long gsr_bits;
+static struct clk *ac97_clk;
+#ifdef CONFIG_PXA27x
+static struct clk *ac97conf_clk;
+#endif
 
 /*
  * Beware PXA27x bugs:
@@ -160,9 +165,9 @@ static void pxa2xx_ac97_cold_reset(struct snd_ac97 *ac97)
        gsr_bits = 0;
 #ifdef CONFIG_PXA27x
        /* PXA27x Developers Manual section 13.5.2.2.1 */
-       pxa_set_cken(CKEN_AC97CONF, 1);
+       clk_enable(ac97conf_clk);
        udelay(5);
-       pxa_set_cken(CKEN_AC97CONF, 0);
+       clk_disable(ac97conf_clk);
        GCR = GCR_COLD_RST;
        udelay(50);
 #else
@@ -256,7 +261,7 @@ static int pxa2xx_ac97_suspend(struct platform_device *pdev,
        struct snd_soc_cpu_dai *dai)
 {
        GCR |= GCR_ACLINK_OFF;
-       pxa_set_cken(CKEN_AC97, 0);
+       clk_disable(ac97_clk);
        return 0;
 }
 
@@ -271,7 +276,7 @@ static int pxa2xx_ac97_resume(struct platform_device *pdev,
        /* Use GPIO 113 as AC97 Reset on Bulverde */
        pxa_gpio_mode(113 | GPIO_ALT_FN_2_OUT);
 #endif
-       pxa_set_cken(CKEN_AC97, 1);
+       clk_enable(ac97_clk);
        return 0;
 }
 
@@ -295,16 +300,32 @@ static int pxa2xx_ac97_probe(struct platform_device *pdev)
 #ifdef CONFIG_PXA27x
        /* Use GPIO 113 as AC97 Reset on Bulverde */
        pxa_gpio_mode(113 | GPIO_ALT_FN_2_OUT);
+
+       ac97conf_clk = clk_get(&pdev->dev, "AC97CONFCLK");
+       if (IS_ERR(ac97conf_clk)) {
+               ret = PTR_ERR(ac97conf_clk);
+               ac97conf_clk = NULL;
+               goto err_irq;
+       }
 #endif
-       pxa_set_cken(CKEN_AC97, 1);
+       ac97_clk = clk_get(&pdev->dev, "AC97CLK");
+       if (IS_ERR(ac97_clk)) {
+               ret = PTR_ERR(ac97_clk);
+               ac97_clk = NULL;
+               goto err_irq;
+       }
        return 0;
 
- err:
-       if (CKEN & (1 << CKEN_AC97)) {
-               GCR |= GCR_ACLINK_OFF;
-               free_irq(IRQ_AC97, NULL);
-               pxa_set_cken(CKEN_AC97, 0);
+ err_irq:
+       GCR |= GCR_ACLINK_OFF;
+#ifdef CONFIG_PXA27x
+       if (ac97conf_clk) {
+               clk_put(ac97conf_clk);
+               ac97conf_clk = NULL;
        }
+#endif
+       free_irq(IRQ_AC97, NULL);
+ err:
        return ret;
 }
 
@@ -312,7 +333,13 @@ static void pxa2xx_ac97_remove(struct platform_device *pdev)
 {
        GCR |= GCR_ACLINK_OFF;
        free_irq(IRQ_AC97, NULL);
-       pxa_set_cken(CKEN_AC97, 0);
+#ifdef CONFIG_PXA27x
+       clk_put(ac97conf_clk);
+       ac97conf_clk = NULL;
+#endif
+       clk_disable(ac97_clk);
+       clk_put(ac97_clk);
+       ac97_clk = NULL;
 }
 
 static int pxa2xx_ac97_hw_params(struct snd_pcm_substream *substream,