提交 2f361e94 编写于 作者: A Arnd Bergmann

ARM: pxa: corgi: use gpio descriptors for audio

The audio driver should not use a hardwired gpio number
from the header. Change it to use a lookup table.
Acked-by: NMark Brown <broonie@kernel.org>
Cc: alsa-devel@alsa-project.org
Acked-by: NRobert Jarzmik <robert.jarzmik@free.fr>
Reviewed-by: NLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: NArnd Bergmann <arnd@arndb.de>
上级 ac70f4d8
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
#include <linux/platform_data/irda-pxaficp.h> #include <linux/platform_data/irda-pxaficp.h>
#include <linux/platform_data/mmc-pxamci.h> #include <linux/platform_data/mmc-pxamci.h>
#include "udc.h" #include "udc.h"
#include <mach/corgi.h> #include "corgi.h"
#include "sharpsl_pm.h" #include "sharpsl_pm.h"
#include <asm/mach/sharpsl_param.h> #include <asm/mach/sharpsl_param.h>
...@@ -472,6 +472,25 @@ static struct platform_device corgiled_device = { ...@@ -472,6 +472,25 @@ static struct platform_device corgiled_device = {
}, },
}; };
static struct gpiod_lookup_table corgi_audio_gpio_table = {
.dev_id = "corgi-audio",
.table = {
GPIO_LOOKUP("sharp-scoop",
CORGI_GPIO_MUTE_L - CORGI_SCOOP_GPIO_BASE,
"mute-l", GPIO_ACTIVE_HIGH),
GPIO_LOOKUP("sharp-scoop",
CORGI_GPIO_MUTE_R - CORGI_SCOOP_GPIO_BASE,
"mute-r", GPIO_ACTIVE_HIGH),
GPIO_LOOKUP("sharp-scoop",
CORGI_GPIO_APM_ON - CORGI_SCOOP_GPIO_BASE,
"apm-on", GPIO_ACTIVE_HIGH),
GPIO_LOOKUP("sharp-scoop",
CORGI_GPIO_MIC_BIAS - CORGI_SCOOP_GPIO_BASE,
"mic-bias", GPIO_ACTIVE_HIGH),
{ },
},
};
/* /*
* Corgi Audio * Corgi Audio
*/ */
...@@ -744,6 +763,7 @@ static void __init corgi_init(void) ...@@ -744,6 +763,7 @@ static void __init corgi_init(void)
pxa_set_udc_info(&udc_info); pxa_set_udc_info(&udc_info);
gpiod_add_lookup_table(&corgi_mci_gpio_table); gpiod_add_lookup_table(&corgi_mci_gpio_table);
gpiod_add_lookup_table(&corgi_audio_gpio_table);
pxa_set_mci_info(&corgi_mci_platform_data); pxa_set_mci_info(&corgi_mci_platform_data);
pxa_set_ficp_info(&corgi_ficp_platform_data); pxa_set_ficp_info(&corgi_ficp_platform_data);
pxa_set_i2c_info(NULL); pxa_set_i2c_info(NULL);
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#ifndef __ASM_ARCH_CORGI_H #ifndef __ASM_ARCH_CORGI_H
#define __ASM_ARCH_CORGI_H 1 #define __ASM_ARCH_CORGI_H 1
#include "irqs.h" /* PXA_NR_BUILTIN_GPIO */ #include <mach/irqs.h> /* PXA_NR_BUILTIN_GPIO */
/* /*
* Corgi (Non Standard) GPIO Definitions * Corgi (Non Standard) GPIO Definitions
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include <asm/irq.h> #include <asm/irq.h>
#include <asm/mach-types.h> #include <asm/mach-types.h>
#include <mach/corgi.h> #include "corgi.h"
#include <mach/pxa2xx-regs.h> #include <mach/pxa2xx-regs.h>
#include "sharpsl_pm.h" #include "sharpsl_pm.h"
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include <sound/soc.h> #include <sound/soc.h>
#include <asm/mach-types.h> #include <asm/mach-types.h>
#include <mach/corgi.h>
#include <linux/platform_data/asoc-pxa.h> #include <linux/platform_data/asoc-pxa.h>
#include "../codecs/wm8731.h" #include "../codecs/wm8731.h"
...@@ -41,6 +40,9 @@ ...@@ -41,6 +40,9 @@
static int corgi_jack_func; static int corgi_jack_func;
static int corgi_spk_func; static int corgi_spk_func;
static struct gpio_desc *gpiod_mute_l, *gpiod_mute_r,
*gpiod_apm_on, *gpiod_mic_bias;
static void corgi_ext_control(struct snd_soc_dapm_context *dapm) static void corgi_ext_control(struct snd_soc_dapm_context *dapm)
{ {
snd_soc_dapm_mutex_lock(dapm); snd_soc_dapm_mutex_lock(dapm);
...@@ -49,8 +51,8 @@ static void corgi_ext_control(struct snd_soc_dapm_context *dapm) ...@@ -49,8 +51,8 @@ static void corgi_ext_control(struct snd_soc_dapm_context *dapm)
switch (corgi_jack_func) { switch (corgi_jack_func) {
case CORGI_HP: case CORGI_HP:
/* set = unmute headphone */ /* set = unmute headphone */
gpio_set_value(CORGI_GPIO_MUTE_L, 1); gpiod_set_value(gpiod_mute_l, 1);
gpio_set_value(CORGI_GPIO_MUTE_R, 1); gpiod_set_value(gpiod_mute_r, 1);
snd_soc_dapm_disable_pin_unlocked(dapm, "Mic Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Mic Jack");
snd_soc_dapm_disable_pin_unlocked(dapm, "Line Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Line Jack");
snd_soc_dapm_enable_pin_unlocked(dapm, "Headphone Jack"); snd_soc_dapm_enable_pin_unlocked(dapm, "Headphone Jack");
...@@ -58,24 +60,24 @@ static void corgi_ext_control(struct snd_soc_dapm_context *dapm) ...@@ -58,24 +60,24 @@ static void corgi_ext_control(struct snd_soc_dapm_context *dapm)
break; break;
case CORGI_MIC: case CORGI_MIC:
/* reset = mute headphone */ /* reset = mute headphone */
gpio_set_value(CORGI_GPIO_MUTE_L, 0); gpiod_set_value(gpiod_mute_l, 0);
gpio_set_value(CORGI_GPIO_MUTE_R, 0); gpiod_set_value(gpiod_mute_r, 0);
snd_soc_dapm_enable_pin_unlocked(dapm, "Mic Jack"); snd_soc_dapm_enable_pin_unlocked(dapm, "Mic Jack");
snd_soc_dapm_disable_pin_unlocked(dapm, "Line Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Line Jack");
snd_soc_dapm_disable_pin_unlocked(dapm, "Headphone Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Headphone Jack");
snd_soc_dapm_disable_pin_unlocked(dapm, "Headset Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Headset Jack");
break; break;
case CORGI_LINE: case CORGI_LINE:
gpio_set_value(CORGI_GPIO_MUTE_L, 0); gpiod_set_value(gpiod_mute_l, 0);
gpio_set_value(CORGI_GPIO_MUTE_R, 0); gpiod_set_value(gpiod_mute_r, 0);
snd_soc_dapm_disable_pin_unlocked(dapm, "Mic Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Mic Jack");
snd_soc_dapm_enable_pin_unlocked(dapm, "Line Jack"); snd_soc_dapm_enable_pin_unlocked(dapm, "Line Jack");
snd_soc_dapm_disable_pin_unlocked(dapm, "Headphone Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Headphone Jack");
snd_soc_dapm_disable_pin_unlocked(dapm, "Headset Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Headset Jack");
break; break;
case CORGI_HEADSET: case CORGI_HEADSET:
gpio_set_value(CORGI_GPIO_MUTE_L, 0); gpiod_set_value(gpiod_mute_l, 0);
gpio_set_value(CORGI_GPIO_MUTE_R, 1); gpiod_set_value(gpiod_mute_r, 1);
snd_soc_dapm_enable_pin_unlocked(dapm, "Mic Jack"); snd_soc_dapm_enable_pin_unlocked(dapm, "Mic Jack");
snd_soc_dapm_disable_pin_unlocked(dapm, "Line Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Line Jack");
snd_soc_dapm_disable_pin_unlocked(dapm, "Headphone Jack"); snd_soc_dapm_disable_pin_unlocked(dapm, "Headphone Jack");
...@@ -108,8 +110,8 @@ static int corgi_startup(struct snd_pcm_substream *substream) ...@@ -108,8 +110,8 @@ static int corgi_startup(struct snd_pcm_substream *substream)
static void corgi_shutdown(struct snd_pcm_substream *substream) static void corgi_shutdown(struct snd_pcm_substream *substream)
{ {
/* set = unmute headphone */ /* set = unmute headphone */
gpio_set_value(CORGI_GPIO_MUTE_L, 1); gpiod_set_value(gpiod_mute_l, 1);
gpio_set_value(CORGI_GPIO_MUTE_R, 1); gpiod_set_value(gpiod_mute_r, 1);
} }
static int corgi_hw_params(struct snd_pcm_substream *substream, static int corgi_hw_params(struct snd_pcm_substream *substream,
...@@ -199,14 +201,14 @@ static int corgi_set_spk(struct snd_kcontrol *kcontrol, ...@@ -199,14 +201,14 @@ static int corgi_set_spk(struct snd_kcontrol *kcontrol,
static int corgi_amp_event(struct snd_soc_dapm_widget *w, static int corgi_amp_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *k, int event) struct snd_kcontrol *k, int event)
{ {
gpio_set_value(CORGI_GPIO_APM_ON, SND_SOC_DAPM_EVENT_ON(event)); gpiod_set_value(gpiod_apm_on, SND_SOC_DAPM_EVENT_ON(event));
return 0; return 0;
} }
static int corgi_mic_event(struct snd_soc_dapm_widget *w, static int corgi_mic_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *k, int event) struct snd_kcontrol *k, int event)
{ {
gpio_set_value(CORGI_GPIO_MIC_BIAS, SND_SOC_DAPM_EVENT_ON(event)); gpiod_set_value(gpiod_mic_bias, SND_SOC_DAPM_EVENT_ON(event));
return 0; return 0;
} }
...@@ -293,6 +295,19 @@ static int corgi_probe(struct platform_device *pdev) ...@@ -293,6 +295,19 @@ static int corgi_probe(struct platform_device *pdev)
card->dev = &pdev->dev; card->dev = &pdev->dev;
gpiod_mute_l = devm_gpiod_get(&pdev->dev, "mute-l", GPIOD_OUT_HIGH);
if (IS_ERR(gpiod_mute_l))
return PTR_ERR(gpiod_mute_l);
gpiod_mute_r = devm_gpiod_get(&pdev->dev, "mute-r", GPIOD_OUT_HIGH);
if (IS_ERR(gpiod_mute_r))
return PTR_ERR(gpiod_mute_r);
gpiod_apm_on = devm_gpiod_get(&pdev->dev, "apm-on", GPIOD_OUT_LOW);
if (IS_ERR(gpiod_apm_on))
return PTR_ERR(gpiod_apm_on);
gpiod_mic_bias = devm_gpiod_get(&pdev->dev, "mic-bias", GPIOD_OUT_LOW);
if (IS_ERR(gpiod_mic_bias))
return PTR_ERR(gpiod_mic_bias);
ret = devm_snd_soc_register_card(&pdev->dev, card); ret = devm_snd_soc_register_card(&pdev->dev, card);
if (ret) if (ret)
dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册