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

ASoC: mx27vis: retrieve gpio numbers from platform_data

Rather than including mach/iomux-mx27.h to define gpio numbers and set
up the pins, the patch moves all these into machine code and has the
gpio numbers passed to driver via platform_data. As the result, we
can remove the mach/iomux-mx27.h inclusion from driver.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Acked-by: Javier Martin <javier.martin@vista-silicon.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

authored by

Shawn Guo and committed by
Mark Brown
d41789b2 7f22fd9c

+72 -23
+41 -1
arch/arm/mach-imx/mach-imx27_visstrim_m10.c
··· 33 33 #include <linux/dma-mapping.h> 34 34 #include <linux/leds.h> 35 35 #include <linux/memblock.h> 36 + #include <linux/platform_data/asoc-mx27vis.h> 36 37 #include <media/soc_camera.h> 37 38 #include <sound/tlv320aic32x4.h> 38 39 #include <asm/mach-types.h> ··· 58 57 #define EXPBOARD_BIT2 (GPIO_PORTD + 25) 59 58 #define EXPBOARD_BIT1 (GPIO_PORTD + 27) 60 59 #define EXPBOARD_BIT0 (GPIO_PORTD + 28) 60 + 61 + #define AMP_GAIN_0 (GPIO_PORTF + 9) 62 + #define AMP_GAIN_1 (GPIO_PORTF + 8) 63 + #define AMP_MUTE_SDL (GPIO_PORTE + 5) 64 + #define AMP_MUTE_SDR (GPIO_PORTF + 7) 61 65 62 66 static const int visstrim_m10_pins[] __initconst = { 63 67 /* UART1 (console) */ ··· 145 139 EXPBOARD_BIT2 | GPIO_GPIO | GPIO_IN | GPIO_PUEN, 146 140 EXPBOARD_BIT1 | GPIO_GPIO | GPIO_IN | GPIO_PUEN, 147 141 EXPBOARD_BIT0 | GPIO_GPIO | GPIO_IN | GPIO_PUEN, 142 + /* Audio AMP control */ 143 + AMP_GAIN_0 | GPIO_GPIO | GPIO_OUT, 144 + AMP_GAIN_1 | GPIO_GPIO | GPIO_OUT, 145 + AMP_MUTE_SDL | GPIO_GPIO | GPIO_OUT, 146 + AMP_MUTE_SDR | GPIO_GPIO | GPIO_OUT, 148 147 }; 149 148 150 149 static struct gpio visstrim_m10_version_gpios[] = { ··· 176 165 .gpio = OTG_PHY_CS_GPIO, 177 166 .flags = GPIOF_DIR_OUT | GPIOF_INIT_LOW, 178 167 .label = "usbotg_cs", 168 + }, 169 + { 170 + .gpio = AMP_GAIN_0, 171 + .flags = GPIOF_DIR_OUT, 172 + .label = "amp-gain-0", 173 + }, 174 + { 175 + .gpio = AMP_GAIN_1, 176 + .flags = GPIOF_DIR_OUT, 177 + .label = "amp-gain-1", 178 + }, 179 + { 180 + .gpio = AMP_MUTE_SDL, 181 + .flags = GPIOF_DIR_OUT, 182 + .label = "amp-mute-sdl", 183 + }, 184 + { 185 + .gpio = AMP_MUTE_SDR, 186 + .flags = GPIOF_DIR_OUT, 187 + .label = "amp-mute-sdr", 179 188 }, 180 189 }; 181 190 ··· 436 405 .flags = IMX_SSI_DMA | IMX_SSI_SYN, 437 406 }; 438 407 408 + /* Audio */ 409 + static const struct snd_mx27vis_platform_data snd_mx27vis_pdata __initconst = { 410 + .amp_gain0_gpio = AMP_GAIN_0, 411 + .amp_gain1_gpio = AMP_GAIN_1, 412 + .amp_mutel_gpio = AMP_MUTE_SDL, 413 + .amp_muter_gpio = AMP_MUTE_SDR, 414 + }; 415 + 439 416 static void __init visstrim_m10_revision(void) 440 417 { 441 418 int exp_version = 0; ··· 502 463 imx27_add_fec(NULL); 503 464 imx_add_gpio_keys(&visstrim_gpio_keys_platform_data); 504 465 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices)); 505 - imx_add_platform_device("mx27vis", 0, NULL, 0, NULL, 0); 466 + imx_add_platform_device("mx27vis", 0, NULL, 0, &snd_mx27vis_pdata, 467 + sizeof(snd_mx27vis_pdata)); 506 468 platform_device_register_resndata(NULL, "soc-camera-pdrv", 0, NULL, 0, 507 469 &iclink_tvp5150, sizeof(iclink_tvp5150)); 508 470 gpio_led_register_device(0, &visstrim_m10_led_data);
+11
include/linux/platform_data/asoc-mx27vis.h
··· 1 + #ifndef __PLATFORM_DATA_ASOC_MX27VIS_H 2 + #define __PLATFORM_DATA_ASOC_MX27VIS_H 3 + 4 + struct snd_mx27vis_platform_data { 5 + int amp_gain0_gpio; 6 + int amp_gain1_gpio; 7 + int amp_mutel_gpio; 8 + int amp_muter_gpio; 9 + }; 10 + 11 + #endif /* __PLATFORM_DATA_ASOC_MX27VIS_H */
+20 -22
sound/soc/fsl/mx27vis-aic32x4.c
··· 26 26 #include <linux/device.h> 27 27 #include <linux/i2c.h> 28 28 #include <linux/gpio.h> 29 + #include <linux/platform_data/asoc-mx27vis.h> 29 30 #include <sound/core.h> 30 31 #include <sound/pcm.h> 31 32 #include <sound/soc.h> 32 33 #include <sound/soc-dapm.h> 33 34 #include <sound/tlv.h> 34 35 #include <asm/mach-types.h> 35 - #include <mach/iomux-mx27.h> 36 36 37 37 #include "../codecs/tlv320aic32x4.h" 38 38 #include "imx-ssi.h" ··· 41 41 #define MX27VIS_AMP_GAIN 0 42 42 #define MX27VIS_AMP_MUTE 1 43 43 44 - #define MX27VIS_PIN_G0 (GPIO_PORTF + 9) 45 - #define MX27VIS_PIN_G1 (GPIO_PORTF + 8) 46 - #define MX27VIS_PIN_SDL (GPIO_PORTE + 5) 47 - #define MX27VIS_PIN_SDR (GPIO_PORTF + 7) 48 - 49 44 static int mx27vis_amp_gain; 50 45 static int mx27vis_amp_mute; 51 - 52 - static const int mx27vis_amp_pins[] = { 53 - MX27VIS_PIN_G0 | GPIO_GPIO | GPIO_OUT, 54 - MX27VIS_PIN_G1 | GPIO_GPIO | GPIO_OUT, 55 - MX27VIS_PIN_SDL | GPIO_GPIO | GPIO_OUT, 56 - MX27VIS_PIN_SDR | GPIO_GPIO | GPIO_OUT, 57 - }; 46 + static int mx27vis_amp_gain0_gpio; 47 + static int mx27vis_amp_gain1_gpio; 48 + static int mx27vis_amp_mutel_gpio; 49 + static int mx27vis_amp_muter_gpio; 58 50 59 51 static int mx27vis_aic32x4_hw_params(struct snd_pcm_substream *substream, 60 52 struct snd_pcm_hw_params *params) ··· 101 109 102 110 switch (reg) { 103 111 case MX27VIS_AMP_GAIN: 104 - gpio_set_value(MX27VIS_PIN_G0, value & 1); 105 - gpio_set_value(MX27VIS_PIN_G1, value >> 1); 112 + gpio_set_value(mx27vis_amp_gain0_gpio, value & 1); 113 + gpio_set_value(mx27vis_amp_gain1_gpio, value >> 1); 106 114 mx27vis_amp_gain = value; 107 115 break; 108 116 case MX27VIS_AMP_MUTE: 109 - gpio_set_value(MX27VIS_PIN_SDL, value & 1); 110 - gpio_set_value(MX27VIS_PIN_SDR, value >> 1); 117 + gpio_set_value(mx27vis_amp_mutel_gpio, value & 1); 118 + gpio_set_value(mx27vis_amp_muter_gpio, value >> 1); 111 119 mx27vis_amp_mute = value; 112 120 break; 113 121 } ··· 182 190 183 191 static int __devinit mx27vis_aic32x4_probe(struct platform_device *pdev) 184 192 { 193 + struct snd_mx27vis_platform_data *pdata = pdev->dev.platform_data; 185 194 int ret; 195 + 196 + if (!pdata) { 197 + dev_err(&pdev->dev, "No platform data supplied\n"); 198 + return -EINVAL; 199 + } 200 + 201 + mx27vis_amp_gain0_gpio = pdata->amp_gain0_gpio; 202 + mx27vis_amp_gain1_gpio = pdata->amp_gain1_gpio; 203 + mx27vis_amp_mutel_gpio = pdata->amp_mutel_gpio; 204 + mx27vis_amp_muter_gpio = pdata->amp_muter_gpio; 186 205 187 206 mx27vis_aic32x4.dev = &pdev->dev; 188 207 ret = snd_soc_register_card(&mx27vis_aic32x4); ··· 215 212 IMX_AUDMUX_V1_PCR_SYN | 216 213 IMX_AUDMUX_V1_PCR_RXDSEL(MX27_AUDMUX_HPCR1_SSI0) 217 214 ); 218 - 219 - ret = mxc_gpio_setup_multiple_pins(mx27vis_amp_pins, 220 - ARRAY_SIZE(mx27vis_amp_pins), "MX27VIS_AMP"); 221 - if (ret) 222 - printk(KERN_ERR "ASoC: unable to setup gpios\n"); 223 215 224 216 return ret; 225 217 }