[ALSA] ASoC: Convert N810 machine driver to use gpiolib
[cascardo/linux.git] / sound / soc / omap / n810.c
index 6533563..c32487b 100644 (file)
 
 #include <asm/mach-types.h>
 #include <asm/arch/hardware.h>
-#include <asm/arch/gpio.h>
+#include <linux/gpio.h>
 #include <asm/arch/mcbsp.h>
 
 #include "omap-mcbsp.h"
 #include "omap-pcm.h"
 #include "../codecs/tlv320aic3x.h"
 
-#define RX44_HEADSET_AMP_GPIO  10
-#define RX44_SPEAKER_AMP_GPIO  101
+#define N810_HEADSET_AMP_GPIO  10
+#define N810_SPEAKER_AMP_GPIO  101
 
 static struct clk *sys_clkout2;
 static struct clk *sys_clkout2_src;
@@ -154,9 +154,9 @@ static int n810_spk_event(struct snd_soc_dapm_widget *w,
                          struct snd_kcontrol *k, int event)
 {
        if (SND_SOC_DAPM_EVENT_ON(event))
-               omap_set_gpio_dataout(RX44_SPEAKER_AMP_GPIO, 1);
+               gpio_set_value(N810_SPEAKER_AMP_GPIO, 1);
        else
-               omap_set_gpio_dataout(RX44_SPEAKER_AMP_GPIO, 0);
+               gpio_set_value(N810_SPEAKER_AMP_GPIO, 0);
 
        return 0;
 }
@@ -165,9 +165,9 @@ static int n810_jack_event(struct snd_soc_dapm_widget *w,
                           struct snd_kcontrol *k, int event)
 {
        if (SND_SOC_DAPM_EVENT_ON(event))
-               omap_set_gpio_dataout(RX44_HEADSET_AMP_GPIO, 1);
+               gpio_set_value(N810_HEADSET_AMP_GPIO, 1);
        else
-               omap_set_gpio_dataout(RX44_HEADSET_AMP_GPIO, 0);
+               gpio_set_value(N810_HEADSET_AMP_GPIO, 0);
 
        return 0;
 }
@@ -177,7 +177,7 @@ static const struct snd_soc_dapm_widget aic33_dapm_widgets[] = {
        SND_SOC_DAPM_HP("Headphone Jack", n810_jack_event),
 };
 
-static const char *audio_map[][3] = {
+static const struct snd_soc_dapm_route audio_map[] = {
        {"Headphone Jack", NULL, "HPLOUT"},
        {"Headphone Jack", NULL, "HPROUT"},
 
@@ -217,13 +217,11 @@ static int n810_aic33_init(struct snd_soc_codec *codec)
        }
 
        /* Add N810 specific widgets */
-       for (i = 0; i < ARRAY_SIZE(aic33_dapm_widgets); i++)
-               snd_soc_dapm_new_control(codec, &aic33_dapm_widgets[i]);
+       snd_soc_dapm_new_controls(codec, aic33_dapm_widgets,
+                                 ARRAY_SIZE(aic33_dapm_widgets));
 
        /* Set up N810 specific audio path audio_map */
-       for (i = 0; i < ARRAY_SIZE(audio_map); i++)
-               snd_soc_dapm_connect_input(codec, audio_map[i][0],
-                       audio_map[i][1], audio_map[i][2]);
+       snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map));
 
        snd_soc_dapm_sync_endpoints(codec);
 
@@ -305,12 +303,12 @@ static int __init n810_soc_init(void)
        clk_set_parent(sys_clkout2_src, func96m_clk);
        clk_set_rate(sys_clkout2, 12000000);
 
-       if (omap_request_gpio(RX44_HEADSET_AMP_GPIO) < 0)
+       if (gpio_request(N810_HEADSET_AMP_GPIO, "hs_amp") < 0)
                BUG();
-       if (omap_request_gpio(RX44_SPEAKER_AMP_GPIO) < 0)
+       if (gpio_request(N810_SPEAKER_AMP_GPIO, "spk_amp") < 0)
                BUG();
-       omap_set_gpio_direction(RX44_HEADSET_AMP_GPIO, 0);
-       omap_set_gpio_direction(RX44_SPEAKER_AMP_GPIO, 0);
+       gpio_direction_output(N810_HEADSET_AMP_GPIO, 0);
+       gpio_direction_output(N810_SPEAKER_AMP_GPIO, 0);
 
        return 0;
 err2:
@@ -325,6 +323,9 @@ err1:
 
 static void __exit n810_soc_exit(void)
 {
+       gpio_free(N810_SPEAKER_AMP_GPIO);
+       gpio_free(N810_HEADSET_AMP_GPIO);
+
        platform_device_unregister(n810_snd_device);
 }