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

ARM: pxa: spitz: 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
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

+57 -38
+1 -1
arch/arm/mach-pxa/include/mach/spitz.h arch/arm/mach-pxa/spitz.h
··· 11 11 #define __ASM_ARCH_SPITZ_H 1 12 12 #endif 13 13 14 - #include "irqs.h" /* PXA_NR_BUILTIN_GPIO, PXA_GPIO_TO_IRQ */ 14 + #include <mach/irqs.h> /* PXA_NR_BUILTIN_GPIO, PXA_GPIO_TO_IRQ */ 15 15 #include <linux/fb.h> 16 16 17 17 /* Spitz/Akita GPIOs */
+32 -1
arch/arm/mach-pxa/spitz.c
··· 44 44 #include <linux/platform_data/mmc-pxamci.h> 45 45 #include <linux/platform_data/usb-ohci-pxa27x.h> 46 46 #include <linux/platform_data/video-pxafb.h> 47 - #include <mach/spitz.h> 47 + #include "spitz.h" 48 48 #include "sharpsl_pm.h" 49 49 #include <mach/smemc.h> 50 50 ··· 962 962 static inline void spitz_i2c_init(void) {} 963 963 #endif 964 964 965 + static struct gpiod_lookup_table spitz_audio_gpio_table = { 966 + .dev_id = "spitz-audio", 967 + .table = { 968 + GPIO_LOOKUP("sharp-scoop.0", SPITZ_GPIO_MUTE_L - SPITZ_SCP_GPIO_BASE, 969 + "mute-l", GPIO_ACTIVE_HIGH), 970 + GPIO_LOOKUP("sharp-scoop.0", SPITZ_GPIO_MUTE_R - SPITZ_SCP_GPIO_BASE, 971 + "mute-r", GPIO_ACTIVE_HIGH), 972 + GPIO_LOOKUP("sharp-scoop.1", SPITZ_GPIO_MIC_BIAS - SPITZ_SCP2_GPIO_BASE, 973 + "mic", GPIO_ACTIVE_HIGH), 974 + { }, 975 + }, 976 + }; 977 + 978 + static struct gpiod_lookup_table akita_audio_gpio_table = { 979 + .dev_id = "spitz-audio", 980 + .table = { 981 + GPIO_LOOKUP("sharp-scoop.0", SPITZ_GPIO_MUTE_L - SPITZ_SCP_GPIO_BASE, 982 + "mute-l", GPIO_ACTIVE_HIGH), 983 + GPIO_LOOKUP("sharp-scoop.0", SPITZ_GPIO_MUTE_R - SPITZ_SCP_GPIO_BASE, 984 + "mute-r", GPIO_ACTIVE_HIGH), 985 + GPIO_LOOKUP("i2c-max7310", AKITA_GPIO_MIC_BIAS - AKITA_IOEXP_GPIO_BASE, 986 + "mic", GPIO_ACTIVE_HIGH), 987 + { }, 988 + }, 989 + }; 990 + 965 991 /****************************************************************************** 966 992 * Audio devices 967 993 ******************************************************************************/ 968 994 static inline void spitz_audio_init(void) 969 995 { 996 + if (machine_is_akita()) 997 + gpiod_add_lookup_table(&akita_audio_gpio_table); 998 + else 999 + gpiod_add_lookup_table(&spitz_audio_gpio_table); 1000 + 970 1001 platform_device_register_simple("spitz-audio", -1, NULL, 0); 971 1002 } 972 1003
+1 -1
arch/arm/mach-pxa/spitz_pm.c
··· 19 19 #include <asm/irq.h> 20 20 #include <asm/mach-types.h> 21 21 22 - #include <mach/spitz.h> 22 + #include "spitz.h" 23 23 #include "pxa27x.h" 24 24 #include "sharpsl_pm.h" 25 25
+23 -35
sound/soc/pxa/spitz.c
··· 14 14 #include <linux/timer.h> 15 15 #include <linux/interrupt.h> 16 16 #include <linux/platform_device.h> 17 - #include <linux/gpio.h> 17 + #include <linux/gpio/consumer.h> 18 18 #include <sound/core.h> 19 19 #include <sound/pcm.h> 20 20 #include <sound/soc.h> 21 21 22 22 #include <asm/mach-types.h> 23 - #include <mach/spitz.h> 24 23 #include "../codecs/wm8750.h" 25 24 #include "pxa2xx-i2s.h" 26 25 ··· 36 37 37 38 static int spitz_jack_func; 38 39 static int spitz_spk_func; 39 - static int spitz_mic_gpio; 40 + static struct gpio_desc *gpiod_mic, *gpiod_mute_l, *gpiod_mute_r; 40 41 41 42 static void spitz_ext_control(struct snd_soc_dapm_context *dapm) 42 43 { ··· 55 56 snd_soc_dapm_disable_pin_unlocked(dapm, "Mic Jack"); 56 57 snd_soc_dapm_disable_pin_unlocked(dapm, "Line Jack"); 57 58 snd_soc_dapm_enable_pin_unlocked(dapm, "Headphone Jack"); 58 - gpio_set_value(SPITZ_GPIO_MUTE_L, 1); 59 - gpio_set_value(SPITZ_GPIO_MUTE_R, 1); 59 + gpiod_set_value(gpiod_mute_l, 1); 60 + gpiod_set_value(gpiod_mute_r, 1); 60 61 break; 61 62 case SPITZ_MIC: 62 63 /* enable mic jack and bias, mute hp */ ··· 64 65 snd_soc_dapm_disable_pin_unlocked(dapm, "Headset Jack"); 65 66 snd_soc_dapm_disable_pin_unlocked(dapm, "Line Jack"); 66 67 snd_soc_dapm_enable_pin_unlocked(dapm, "Mic Jack"); 67 - gpio_set_value(SPITZ_GPIO_MUTE_L, 0); 68 - gpio_set_value(SPITZ_GPIO_MUTE_R, 0); 68 + gpiod_set_value(gpiod_mute_l, 0); 69 + gpiod_set_value(gpiod_mute_r, 0); 69 70 break; 70 71 case SPITZ_LINE: 71 72 /* enable line jack, disable mic bias and mute hp */ ··· 73 74 snd_soc_dapm_disable_pin_unlocked(dapm, "Headset Jack"); 74 75 snd_soc_dapm_disable_pin_unlocked(dapm, "Mic Jack"); 75 76 snd_soc_dapm_enable_pin_unlocked(dapm, "Line Jack"); 76 - gpio_set_value(SPITZ_GPIO_MUTE_L, 0); 77 - gpio_set_value(SPITZ_GPIO_MUTE_R, 0); 77 + gpiod_set_value(gpiod_mute_l, 0); 78 + gpiod_set_value(gpiod_mute_r, 0); 78 79 break; 79 80 case SPITZ_HEADSET: 80 81 /* enable and unmute headset jack enable mic bias, mute L hp */ ··· 82 83 snd_soc_dapm_enable_pin_unlocked(dapm, "Mic Jack"); 83 84 snd_soc_dapm_disable_pin_unlocked(dapm, "Line Jack"); 84 85 snd_soc_dapm_enable_pin_unlocked(dapm, "Headset Jack"); 85 - gpio_set_value(SPITZ_GPIO_MUTE_L, 0); 86 - gpio_set_value(SPITZ_GPIO_MUTE_R, 1); 86 + gpiod_set_value(gpiod_mute_l, 0); 87 + gpiod_set_value(gpiod_mute_r, 1); 87 88 break; 88 89 case SPITZ_HP_OFF: 89 90 ··· 92 93 snd_soc_dapm_disable_pin_unlocked(dapm, "Headset Jack"); 93 94 snd_soc_dapm_disable_pin_unlocked(dapm, "Mic Jack"); 94 95 snd_soc_dapm_disable_pin_unlocked(dapm, "Line Jack"); 95 - gpio_set_value(SPITZ_GPIO_MUTE_L, 0); 96 - gpio_set_value(SPITZ_GPIO_MUTE_R, 0); 96 + gpiod_set_value(gpiod_mute_l, 0); 97 + gpiod_set_value(gpiod_mute_r, 0); 97 98 break; 98 99 } 99 100 ··· 198 199 static int spitz_mic_bias(struct snd_soc_dapm_widget *w, 199 200 struct snd_kcontrol *k, int event) 200 201 { 201 - gpio_set_value_cansleep(spitz_mic_gpio, SND_SOC_DAPM_EVENT_ON(event)); 202 + gpiod_set_value_cansleep(gpiod_mic, SND_SOC_DAPM_EVENT_ON(event)); 202 203 return 0; 203 204 } 204 205 ··· 286 287 struct snd_soc_card *card = &snd_soc_spitz; 287 288 int ret; 288 289 289 - if (machine_is_akita()) 290 - spitz_mic_gpio = AKITA_GPIO_MIC_BIAS; 291 - else 292 - spitz_mic_gpio = SPITZ_GPIO_MIC_BIAS; 293 - 294 - ret = gpio_request(spitz_mic_gpio, "MIC GPIO"); 295 - if (ret) 296 - goto err1; 297 - 298 - ret = gpio_direction_output(spitz_mic_gpio, 0); 299 - if (ret) 300 - goto err2; 290 + gpiod_mic = devm_gpiod_get(&pdev->dev, "mic", GPIOD_OUT_LOW); 291 + if (IS_ERR(gpiod_mic)) 292 + return PTR_ERR(gpiod_mic); 293 + gpiod_mute_l = devm_gpiod_get(&pdev->dev, "mute-l", GPIOD_OUT_LOW); 294 + if (IS_ERR(gpiod_mute_l)) 295 + return PTR_ERR(gpiod_mute_l); 296 + gpiod_mute_r = devm_gpiod_get(&pdev->dev, "mute-r", GPIOD_OUT_LOW); 297 + if (IS_ERR(gpiod_mute_r)) 298 + return PTR_ERR(gpiod_mute_r); 301 299 302 300 card->dev = &pdev->dev; 303 301 304 302 ret = devm_snd_soc_register_card(&pdev->dev, card); 305 - if (ret) { 303 + if (ret) 306 304 dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", 307 305 ret); 308 - goto err2; 309 - } 310 306 311 - return 0; 312 - 313 - err2: 314 - gpio_free(spitz_mic_gpio); 315 - err1: 316 307 return ret; 317 308 } 318 309 319 310 static int spitz_remove(struct platform_device *pdev) 320 311 { 321 - gpio_free(spitz_mic_gpio); 322 312 return 0; 323 313 } 324 314