Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Mark Brown <broonie@kernel.org>
Cc: alsa-devel@alsa-project.org
Acked-by: Robert Jarzmik <robert.jarzmik@free.fr>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

+51 -16
+21 -1
arch/arm/mach-pxa/corgi.c
··· 49 49 #include <linux/platform_data/irda-pxaficp.h> 50 50 #include <linux/platform_data/mmc-pxamci.h> 51 51 #include "udc.h" 52 - #include <mach/corgi.h> 52 + #include "corgi.h" 53 53 #include "sharpsl_pm.h" 54 54 55 55 #include <asm/mach/sharpsl_param.h> ··· 472 472 }, 473 473 }; 474 474 475 + static struct gpiod_lookup_table corgi_audio_gpio_table = { 476 + .dev_id = "corgi-audio", 477 + .table = { 478 + GPIO_LOOKUP("sharp-scoop", 479 + CORGI_GPIO_MUTE_L - CORGI_SCOOP_GPIO_BASE, 480 + "mute-l", GPIO_ACTIVE_HIGH), 481 + GPIO_LOOKUP("sharp-scoop", 482 + CORGI_GPIO_MUTE_R - CORGI_SCOOP_GPIO_BASE, 483 + "mute-r", GPIO_ACTIVE_HIGH), 484 + GPIO_LOOKUP("sharp-scoop", 485 + CORGI_GPIO_APM_ON - CORGI_SCOOP_GPIO_BASE, 486 + "apm-on", GPIO_ACTIVE_HIGH), 487 + GPIO_LOOKUP("sharp-scoop", 488 + CORGI_GPIO_MIC_BIAS - CORGI_SCOOP_GPIO_BASE, 489 + "mic-bias", GPIO_ACTIVE_HIGH), 490 + { }, 491 + }, 492 + }; 493 + 475 494 /* 476 495 * Corgi Audio 477 496 */ ··· 763 744 764 745 pxa_set_udc_info(&udc_info); 765 746 gpiod_add_lookup_table(&corgi_mci_gpio_table); 747 + gpiod_add_lookup_table(&corgi_audio_gpio_table); 766 748 pxa_set_mci_info(&corgi_mci_platform_data); 767 749 pxa_set_ficp_info(&corgi_ficp_platform_data); 768 750 pxa_set_i2c_info(NULL);
+1 -1
arch/arm/mach-pxa/corgi_pm.c
··· 20 20 #include <asm/irq.h> 21 21 #include <asm/mach-types.h> 22 22 23 - #include <mach/corgi.h> 23 + #include "corgi.h" 24 24 #include <mach/pxa2xx-regs.h> 25 25 #include "sharpsl_pm.h" 26 26
+1 -1
arch/arm/mach-pxa/include/mach/corgi.h arch/arm/mach-pxa/corgi.h
··· 9 9 #ifndef __ASM_ARCH_CORGI_H 10 10 #define __ASM_ARCH_CORGI_H 1 11 11 12 - #include "irqs.h" /* PXA_NR_BUILTIN_GPIO */ 12 + #include <mach/irqs.h> /* PXA_NR_BUILTIN_GPIO */ 13 13 14 14 /* 15 15 * Corgi (Non Standard) GPIO Definitions
+28 -13
sound/soc/pxa/corgi.c
··· 21 21 #include <sound/soc.h> 22 22 23 23 #include <asm/mach-types.h> 24 - #include <mach/corgi.h> 25 24 #include <linux/platform_data/asoc-pxa.h> 26 25 27 26 #include "../codecs/wm8731.h" ··· 40 41 static int corgi_jack_func; 41 42 static int corgi_spk_func; 42 43 44 + static struct gpio_desc *gpiod_mute_l, *gpiod_mute_r, 45 + *gpiod_apm_on, *gpiod_mic_bias; 46 + 43 47 static void corgi_ext_control(struct snd_soc_dapm_context *dapm) 44 48 { 45 49 snd_soc_dapm_mutex_lock(dapm); ··· 51 49 switch (corgi_jack_func) { 52 50 case CORGI_HP: 53 51 /* set = unmute headphone */ 54 - gpio_set_value(CORGI_GPIO_MUTE_L, 1); 55 - gpio_set_value(CORGI_GPIO_MUTE_R, 1); 52 + gpiod_set_value(gpiod_mute_l, 1); 53 + gpiod_set_value(gpiod_mute_r, 1); 56 54 snd_soc_dapm_disable_pin_unlocked(dapm, "Mic Jack"); 57 55 snd_soc_dapm_disable_pin_unlocked(dapm, "Line Jack"); 58 56 snd_soc_dapm_enable_pin_unlocked(dapm, "Headphone Jack"); ··· 60 58 break; 61 59 case CORGI_MIC: 62 60 /* reset = mute headphone */ 63 - gpio_set_value(CORGI_GPIO_MUTE_L, 0); 64 - gpio_set_value(CORGI_GPIO_MUTE_R, 0); 61 + gpiod_set_value(gpiod_mute_l, 0); 62 + gpiod_set_value(gpiod_mute_r, 0); 65 63 snd_soc_dapm_enable_pin_unlocked(dapm, "Mic Jack"); 66 64 snd_soc_dapm_disable_pin_unlocked(dapm, "Line Jack"); 67 65 snd_soc_dapm_disable_pin_unlocked(dapm, "Headphone Jack"); 68 66 snd_soc_dapm_disable_pin_unlocked(dapm, "Headset Jack"); 69 67 break; 70 68 case CORGI_LINE: 71 - gpio_set_value(CORGI_GPIO_MUTE_L, 0); 72 - gpio_set_value(CORGI_GPIO_MUTE_R, 0); 69 + gpiod_set_value(gpiod_mute_l, 0); 70 + gpiod_set_value(gpiod_mute_r, 0); 73 71 snd_soc_dapm_disable_pin_unlocked(dapm, "Mic Jack"); 74 72 snd_soc_dapm_enable_pin_unlocked(dapm, "Line Jack"); 75 73 snd_soc_dapm_disable_pin_unlocked(dapm, "Headphone Jack"); 76 74 snd_soc_dapm_disable_pin_unlocked(dapm, "Headset Jack"); 77 75 break; 78 76 case CORGI_HEADSET: 79 - gpio_set_value(CORGI_GPIO_MUTE_L, 0); 80 - gpio_set_value(CORGI_GPIO_MUTE_R, 1); 77 + gpiod_set_value(gpiod_mute_l, 0); 78 + gpiod_set_value(gpiod_mute_r, 1); 81 79 snd_soc_dapm_enable_pin_unlocked(dapm, "Mic Jack"); 82 80 snd_soc_dapm_disable_pin_unlocked(dapm, "Line Jack"); 83 81 snd_soc_dapm_disable_pin_unlocked(dapm, "Headphone Jack"); ··· 110 108 static void corgi_shutdown(struct snd_pcm_substream *substream) 111 109 { 112 110 /* set = unmute headphone */ 113 - gpio_set_value(CORGI_GPIO_MUTE_L, 1); 114 - gpio_set_value(CORGI_GPIO_MUTE_R, 1); 111 + gpiod_set_value(gpiod_mute_l, 1); 112 + gpiod_set_value(gpiod_mute_r, 1); 115 113 } 116 114 117 115 static int corgi_hw_params(struct snd_pcm_substream *substream, ··· 201 199 static int corgi_amp_event(struct snd_soc_dapm_widget *w, 202 200 struct snd_kcontrol *k, int event) 203 201 { 204 - gpio_set_value(CORGI_GPIO_APM_ON, SND_SOC_DAPM_EVENT_ON(event)); 202 + gpiod_set_value(gpiod_apm_on, SND_SOC_DAPM_EVENT_ON(event)); 205 203 return 0; 206 204 } 207 205 208 206 static int corgi_mic_event(struct snd_soc_dapm_widget *w, 209 207 struct snd_kcontrol *k, int event) 210 208 { 211 - gpio_set_value(CORGI_GPIO_MIC_BIAS, SND_SOC_DAPM_EVENT_ON(event)); 209 + gpiod_set_value(gpiod_mic_bias, SND_SOC_DAPM_EVENT_ON(event)); 212 210 return 0; 213 211 } 214 212 ··· 294 292 int ret; 295 293 296 294 card->dev = &pdev->dev; 295 + 296 + gpiod_mute_l = devm_gpiod_get(&pdev->dev, "mute-l", GPIOD_OUT_HIGH); 297 + if (IS_ERR(gpiod_mute_l)) 298 + return PTR_ERR(gpiod_mute_l); 299 + gpiod_mute_r = devm_gpiod_get(&pdev->dev, "mute-r", GPIOD_OUT_HIGH); 300 + if (IS_ERR(gpiod_mute_r)) 301 + return PTR_ERR(gpiod_mute_r); 302 + gpiod_apm_on = devm_gpiod_get(&pdev->dev, "apm-on", GPIOD_OUT_LOW); 303 + if (IS_ERR(gpiod_apm_on)) 304 + return PTR_ERR(gpiod_apm_on); 305 + gpiod_mic_bias = devm_gpiod_get(&pdev->dev, "mic-bias", GPIOD_OUT_LOW); 306 + if (IS_ERR(gpiod_mic_bias)) 307 + return PTR_ERR(gpiod_mic_bias); 297 308 298 309 ret = devm_snd_soc_register_card(&pdev->dev, card); 299 310 if (ret)