diff options
author | Shawn Guo <shawn.guo@linaro.org> | 2012-09-17 01:34:31 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-09-17 07:35:08 -0400 |
commit | d41789b2660e5b18b8401bf83ebcd502916c2cb5 (patch) | |
tree | 847bc18e076d820d8956dce1f681a7e02c1c2ac1 | |
parent | 7f22fd9c03c0b67ee6aa138bd10ae91bb0d22151 (diff) |
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>
-rw-r--r-- | arch/arm/mach-imx/mach-imx27_visstrim_m10.c | 42 | ||||
-rw-r--r-- | include/linux/platform_data/asoc-mx27vis.h | 11 | ||||
-rw-r--r-- | sound/soc/fsl/mx27vis-aic32x4.c | 42 |
3 files changed, 72 insertions, 23 deletions
diff --git a/arch/arm/mach-imx/mach-imx27_visstrim_m10.c b/arch/arm/mach-imx/mach-imx27_visstrim_m10.c index f264ddddd47c..562722959666 100644 --- a/arch/arm/mach-imx/mach-imx27_visstrim_m10.c +++ b/arch/arm/mach-imx/mach-imx27_visstrim_m10.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/dma-mapping.h> | 33 | #include <linux/dma-mapping.h> |
34 | #include <linux/leds.h> | 34 | #include <linux/leds.h> |
35 | #include <linux/memblock.h> | 35 | #include <linux/memblock.h> |
36 | #include <linux/platform_data/asoc-mx27vis.h> | ||
36 | #include <media/soc_camera.h> | 37 | #include <media/soc_camera.h> |
37 | #include <sound/tlv320aic32x4.h> | 38 | #include <sound/tlv320aic32x4.h> |
38 | #include <asm/mach-types.h> | 39 | #include <asm/mach-types.h> |
@@ -58,6 +59,11 @@ | |||
58 | #define EXPBOARD_BIT1 (GPIO_PORTD + 27) | 59 | #define EXPBOARD_BIT1 (GPIO_PORTD + 27) |
59 | #define EXPBOARD_BIT0 (GPIO_PORTD + 28) | 60 | #define EXPBOARD_BIT0 (GPIO_PORTD + 28) |
60 | 61 | ||
62 | #define AMP_GAIN_0 (GPIO_PORTF + 9) | ||
63 | #define AMP_GAIN_1 (GPIO_PORTF + 8) | ||
64 | #define AMP_MUTE_SDL (GPIO_PORTE + 5) | ||
65 | #define AMP_MUTE_SDR (GPIO_PORTF + 7) | ||
66 | |||
61 | static const int visstrim_m10_pins[] __initconst = { | 67 | static const int visstrim_m10_pins[] __initconst = { |
62 | /* UART1 (console) */ | 68 | /* UART1 (console) */ |
63 | PE12_PF_UART1_TXD, | 69 | PE12_PF_UART1_TXD, |
@@ -139,6 +145,11 @@ static const int visstrim_m10_pins[] __initconst = { | |||
139 | EXPBOARD_BIT2 | GPIO_GPIO | GPIO_IN | GPIO_PUEN, | 145 | EXPBOARD_BIT2 | GPIO_GPIO | GPIO_IN | GPIO_PUEN, |
140 | EXPBOARD_BIT1 | GPIO_GPIO | GPIO_IN | GPIO_PUEN, | 146 | EXPBOARD_BIT1 | GPIO_GPIO | GPIO_IN | GPIO_PUEN, |
141 | EXPBOARD_BIT0 | GPIO_GPIO | GPIO_IN | GPIO_PUEN, | 147 | EXPBOARD_BIT0 | GPIO_GPIO | GPIO_IN | GPIO_PUEN, |
148 | /* Audio AMP control */ | ||
149 | AMP_GAIN_0 | GPIO_GPIO | GPIO_OUT, | ||
150 | AMP_GAIN_1 | GPIO_GPIO | GPIO_OUT, | ||
151 | AMP_MUTE_SDL | GPIO_GPIO | GPIO_OUT, | ||
152 | AMP_MUTE_SDR | GPIO_GPIO | GPIO_OUT, | ||
142 | }; | 153 | }; |
143 | 154 | ||
144 | static struct gpio visstrim_m10_version_gpios[] = { | 155 | static struct gpio visstrim_m10_version_gpios[] = { |
@@ -166,6 +177,26 @@ static const struct gpio visstrim_m10_gpios[] __initconst = { | |||
166 | .flags = GPIOF_DIR_OUT | GPIOF_INIT_LOW, | 177 | .flags = GPIOF_DIR_OUT | GPIOF_INIT_LOW, |
167 | .label = "usbotg_cs", | 178 | .label = "usbotg_cs", |
168 | }, | 179 | }, |
180 | { | ||
181 | .gpio = AMP_GAIN_0, | ||
182 | .flags = GPIOF_DIR_OUT, | ||
183 | .label = "amp-gain-0", | ||
184 | }, | ||
185 | { | ||
186 | .gpio = AMP_GAIN_1, | ||
187 | .flags = GPIOF_DIR_OUT, | ||
188 | .label = "amp-gain-1", | ||
189 | }, | ||
190 | { | ||
191 | .gpio = AMP_MUTE_SDL, | ||
192 | .flags = GPIOF_DIR_OUT, | ||
193 | .label = "amp-mute-sdl", | ||
194 | }, | ||
195 | { | ||
196 | .gpio = AMP_MUTE_SDR, | ||
197 | .flags = GPIOF_DIR_OUT, | ||
198 | .label = "amp-mute-sdr", | ||
199 | }, | ||
169 | }; | 200 | }; |
170 | 201 | ||
171 | /* Camera */ | 202 | /* Camera */ |
@@ -405,6 +436,14 @@ static const struct imx_ssi_platform_data visstrim_m10_ssi_pdata __initconst = { | |||
405 | .flags = IMX_SSI_DMA | IMX_SSI_SYN, | 436 | .flags = IMX_SSI_DMA | IMX_SSI_SYN, |
406 | }; | 437 | }; |
407 | 438 | ||
439 | /* Audio */ | ||
440 | static const struct snd_mx27vis_platform_data snd_mx27vis_pdata __initconst = { | ||
441 | .amp_gain0_gpio = AMP_GAIN_0, | ||
442 | .amp_gain1_gpio = AMP_GAIN_1, | ||
443 | .amp_mutel_gpio = AMP_MUTE_SDL, | ||
444 | .amp_muter_gpio = AMP_MUTE_SDR, | ||
445 | }; | ||
446 | |||
408 | static void __init visstrim_m10_revision(void) | 447 | static void __init visstrim_m10_revision(void) |
409 | { | 448 | { |
410 | int exp_version = 0; | 449 | int exp_version = 0; |
@@ -463,7 +502,8 @@ static void __init visstrim_m10_board_init(void) | |||
463 | imx27_add_fec(NULL); | 502 | imx27_add_fec(NULL); |
464 | imx_add_gpio_keys(&visstrim_gpio_keys_platform_data); | 503 | imx_add_gpio_keys(&visstrim_gpio_keys_platform_data); |
465 | platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices)); | 504 | platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices)); |
466 | imx_add_platform_device("mx27vis", 0, NULL, 0, NULL, 0); | 505 | imx_add_platform_device("mx27vis", 0, NULL, 0, &snd_mx27vis_pdata, |
506 | sizeof(snd_mx27vis_pdata)); | ||
467 | platform_device_register_resndata(NULL, "soc-camera-pdrv", 0, NULL, 0, | 507 | platform_device_register_resndata(NULL, "soc-camera-pdrv", 0, NULL, 0, |
468 | &iclink_tvp5150, sizeof(iclink_tvp5150)); | 508 | &iclink_tvp5150, sizeof(iclink_tvp5150)); |
469 | gpio_led_register_device(0, &visstrim_m10_led_data); | 509 | gpio_led_register_device(0, &visstrim_m10_led_data); |
diff --git a/include/linux/platform_data/asoc-mx27vis.h b/include/linux/platform_data/asoc-mx27vis.h new file mode 100644 index 000000000000..409adcd04d04 --- /dev/null +++ b/include/linux/platform_data/asoc-mx27vis.h | |||
@@ -0,0 +1,11 @@ | |||
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 */ | ||
diff --git a/sound/soc/fsl/mx27vis-aic32x4.c b/sound/soc/fsl/mx27vis-aic32x4.c index f6d04ad4bb39..2b76877b1789 100644 --- a/sound/soc/fsl/mx27vis-aic32x4.c +++ b/sound/soc/fsl/mx27vis-aic32x4.c | |||
@@ -26,13 +26,13 @@ | |||
26 | #include <linux/device.h> | 26 | #include <linux/device.h> |
27 | #include <linux/i2c.h> | 27 | #include <linux/i2c.h> |
28 | #include <linux/gpio.h> | 28 | #include <linux/gpio.h> |
29 | #include <linux/platform_data/asoc-mx27vis.h> | ||
29 | #include <sound/core.h> | 30 | #include <sound/core.h> |
30 | #include <sound/pcm.h> | 31 | #include <sound/pcm.h> |
31 | #include <sound/soc.h> | 32 | #include <sound/soc.h> |
32 | #include <sound/soc-dapm.h> | 33 | #include <sound/soc-dapm.h> |
33 | #include <sound/tlv.h> | 34 | #include <sound/tlv.h> |
34 | #include <asm/mach-types.h> | 35 | #include <asm/mach-types.h> |
35 | #include <mach/iomux-mx27.h> | ||
36 | 36 | ||
37 | #include "../codecs/tlv320aic32x4.h" | 37 | #include "../codecs/tlv320aic32x4.h" |
38 | #include "imx-ssi.h" | 38 | #include "imx-ssi.h" |
@@ -41,20 +41,12 @@ | |||
41 | #define MX27VIS_AMP_GAIN 0 | 41 | #define MX27VIS_AMP_GAIN 0 |
42 | #define MX27VIS_AMP_MUTE 1 | 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 | static int mx27vis_amp_gain; | 44 | static int mx27vis_amp_gain; |
50 | static int mx27vis_amp_mute; | 45 | static int mx27vis_amp_mute; |
51 | 46 | static int mx27vis_amp_gain0_gpio; | |
52 | static const int mx27vis_amp_pins[] = { | 47 | static int mx27vis_amp_gain1_gpio; |
53 | MX27VIS_PIN_G0 | GPIO_GPIO | GPIO_OUT, | 48 | static int mx27vis_amp_mutel_gpio; |
54 | MX27VIS_PIN_G1 | GPIO_GPIO | GPIO_OUT, | 49 | static int mx27vis_amp_muter_gpio; |
55 | MX27VIS_PIN_SDL | GPIO_GPIO | GPIO_OUT, | ||
56 | MX27VIS_PIN_SDR | GPIO_GPIO | GPIO_OUT, | ||
57 | }; | ||
58 | 50 | ||
59 | static int mx27vis_aic32x4_hw_params(struct snd_pcm_substream *substream, | 51 | static int mx27vis_aic32x4_hw_params(struct snd_pcm_substream *substream, |
60 | struct snd_pcm_hw_params *params) | 52 | struct snd_pcm_hw_params *params) |
@@ -109,13 +101,13 @@ static int mx27vis_amp_set(struct snd_kcontrol *kcontrol, | |||
109 | 101 | ||
110 | switch (reg) { | 102 | switch (reg) { |
111 | case MX27VIS_AMP_GAIN: | 103 | case MX27VIS_AMP_GAIN: |
112 | gpio_set_value(MX27VIS_PIN_G0, value & 1); | 104 | gpio_set_value(mx27vis_amp_gain0_gpio, value & 1); |
113 | gpio_set_value(MX27VIS_PIN_G1, value >> 1); | 105 | gpio_set_value(mx27vis_amp_gain1_gpio, value >> 1); |
114 | mx27vis_amp_gain = value; | 106 | mx27vis_amp_gain = value; |
115 | break; | 107 | break; |
116 | case MX27VIS_AMP_MUTE: | 108 | case MX27VIS_AMP_MUTE: |
117 | gpio_set_value(MX27VIS_PIN_SDL, value & 1); | 109 | gpio_set_value(mx27vis_amp_mutel_gpio, value & 1); |
118 | gpio_set_value(MX27VIS_PIN_SDR, value >> 1); | 110 | gpio_set_value(mx27vis_amp_muter_gpio, value >> 1); |
119 | mx27vis_amp_mute = value; | 111 | mx27vis_amp_mute = value; |
120 | break; | 112 | break; |
121 | } | 113 | } |
@@ -190,8 +182,19 @@ static struct snd_soc_card mx27vis_aic32x4 = { | |||
190 | 182 | ||
191 | static int __devinit mx27vis_aic32x4_probe(struct platform_device *pdev) | 183 | static int __devinit mx27vis_aic32x4_probe(struct platform_device *pdev) |
192 | { | 184 | { |
185 | struct snd_mx27vis_platform_data *pdata = pdev->dev.platform_data; | ||
193 | int ret; | 186 | int ret; |
194 | 187 | ||
188 | if (!pdata) { | ||
189 | dev_err(&pdev->dev, "No platform data supplied\n"); | ||
190 | return -EINVAL; | ||
191 | } | ||
192 | |||
193 | mx27vis_amp_gain0_gpio = pdata->amp_gain0_gpio; | ||
194 | mx27vis_amp_gain1_gpio = pdata->amp_gain1_gpio; | ||
195 | mx27vis_amp_mutel_gpio = pdata->amp_mutel_gpio; | ||
196 | mx27vis_amp_muter_gpio = pdata->amp_muter_gpio; | ||
197 | |||
195 | mx27vis_aic32x4.dev = &pdev->dev; | 198 | mx27vis_aic32x4.dev = &pdev->dev; |
196 | ret = snd_soc_register_card(&mx27vis_aic32x4); | 199 | ret = snd_soc_register_card(&mx27vis_aic32x4); |
197 | if (ret) { | 200 | if (ret) { |
@@ -213,11 +216,6 @@ static int __devinit mx27vis_aic32x4_probe(struct platform_device *pdev) | |||
213 | IMX_AUDMUX_V1_PCR_RXDSEL(MX27_AUDMUX_HPCR1_SSI0) | 216 | IMX_AUDMUX_V1_PCR_RXDSEL(MX27_AUDMUX_HPCR1_SSI0) |
214 | ); | 217 | ); |
215 | 218 | ||
216 | ret = mxc_gpio_setup_multiple_pins(mx27vis_amp_pins, | ||
217 | ARRAY_SIZE(mx27vis_amp_pins), "MX27VIS_AMP"); | ||
218 | if (ret) | ||
219 | printk(KERN_ERR "ASoC: unable to setup gpios\n"); | ||
220 | |||
221 | return ret; | 219 | return ret; |
222 | } | 220 | } |
223 | 221 | ||