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

ARM: pxa: poodle: use platform data for poodle asoc driver

The poodle audio driver shows its age by using a custom
gpio api for the "locomo" support chip.

In a perfect world, this would get converted to use gpiolib
and a gpio lookup table.

As the world is not perfect, just pass all the required data
in a custom platform_data structure. to avoid the globally
visible mach/poodle.h header.

Acked-by: Mark Brown <broonie@kernel.org>
Acked-by: Robert Jarzmik <robert.jarzmik@free.fr>
Cc: alsa-devel@alsa-project.org
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

+63 -36
+1 -3
arch/arm/mach-pxa/include/mach/poodle.h arch/arm/mach-pxa/poodle.h
··· 15 15 #ifndef __ASM_ARCH_POODLE_H 16 16 #define __ASM_ARCH_POODLE_H 1 17 17 18 - #include "irqs.h" /* PXA_GPIO_TO_IRQ */ 18 + #include <mach/irqs.h> /* PXA_GPIO_TO_IRQ */ 19 19 20 20 /* 21 21 * GPIOs ··· 88 88 #define POODLE_LOCOMO_GPIO_JK_B LOCOMO_GPIO(13) 89 89 90 90 #define POODLE_NR_IRQS (IRQ_BOARD_START + 4) /* 4 for LoCoMo */ 91 - 92 - extern struct platform_device poodle_locomo_device; 93 91 94 92 #endif /* __ASM_ARCH_POODLE_H */
+20 -10
arch/arm/mach-pxa/poodle.c
··· 39 39 #include <asm/mach/irq.h> 40 40 41 41 #include "pxa25x.h" 42 - #include <linux/platform_data/mmc-pxamci.h> 43 42 #include "udc.h" 43 + #include "poodle.h" 44 + 45 + #include <linux/platform_data/mmc-pxamci.h> 44 46 #include <linux/platform_data/irda-pxaficp.h> 45 - #include <mach/poodle.h> 46 47 #include <linux/platform_data/video-pxafb.h> 48 + #include <linux/platform_data/asoc-poodle.h> 47 49 48 50 #include <asm/hardware/scoop.h> 49 51 #include <asm/hardware/locomo.h> ··· 157 155 158 156 EXPORT_SYMBOL(poodle_scoop_device); 159 157 160 - 161 - static struct platform_device poodle_audio_device = { 162 - .name = "poodle-audio", 163 - .id = -1, 164 - }; 165 - 166 158 /* LoCoMo device */ 167 159 static struct resource locomo_resources[] = { 168 160 [0] = { ··· 175 179 .irq_base = IRQ_BOARD_START, 176 180 }; 177 181 178 - struct platform_device poodle_locomo_device = { 182 + static struct platform_device poodle_locomo_device = { 179 183 .name = "locomo", 180 184 .id = 0, 181 185 .num_resources = ARRAY_SIZE(locomo_resources), ··· 185 189 }, 186 190 }; 187 191 188 - EXPORT_SYMBOL(poodle_locomo_device); 192 + static struct poodle_audio_platform_data poodle_audio_pdata = { 193 + .locomo_dev = &poodle_locomo_device.dev, 194 + 195 + .gpio_amp_on = POODLE_LOCOMO_GPIO_AMP_ON, 196 + .gpio_mute_l = POODLE_LOCOMO_GPIO_MUTE_L, 197 + .gpio_mute_r = POODLE_LOCOMO_GPIO_MUTE_R, 198 + .gpio_232vcc_on = POODLE_LOCOMO_GPIO_232VCC_ON, 199 + .gpio_jk_b = POODLE_LOCOMO_GPIO_JK_B, 200 + }; 201 + 202 + static struct platform_device poodle_audio_device = { 203 + .name = "poodle-audio", 204 + .id = -1, 205 + .dev.platform_data = &poodle_audio_pdata, 206 + }; 189 207 190 208 #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE) 191 209 static struct pxa2xx_spi_controller poodle_spi_info = {
+16
include/linux/platform_data/asoc-poodle.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + #ifndef __LINUX_PLATFORM_DATA_POODLE_AUDIO 3 + #define __LINUX_PLATFORM_DATA_POODLE_AUDIO 4 + 5 + /* locomo is not a proper gpio driver, and uses its own api */ 6 + struct poodle_audio_platform_data { 7 + struct device *locomo_dev; 8 + 9 + int gpio_amp_on; 10 + int gpio_mute_l; 11 + int gpio_mute_r; 12 + int gpio_232vcc_on; 13 + int gpio_jk_b; 14 + }; 15 + 16 + #endif
+26 -23
sound/soc/pxa/poodle.c
··· 21 21 22 22 #include <asm/mach-types.h> 23 23 #include <asm/hardware/locomo.h> 24 - #include <mach/poodle.h> 25 24 #include <linux/platform_data/asoc-pxa.h> 25 + #include <linux/platform_data/asoc-poodle.h> 26 26 27 27 #include "../codecs/wm8731.h" 28 28 #include "pxa2xx-i2s.h" ··· 38 38 static int poodle_jack_func; 39 39 static int poodle_spk_func; 40 40 41 + static struct poodle_audio_platform_data *poodle_pdata; 42 + 41 43 static void poodle_ext_control(struct snd_soc_dapm_context *dapm) 42 44 { 43 45 /* set up jack connection */ 44 46 if (poodle_jack_func == POODLE_HP) { 45 47 /* set = unmute headphone */ 46 - locomo_gpio_write(&poodle_locomo_device.dev, 47 - POODLE_LOCOMO_GPIO_MUTE_L, 1); 48 - locomo_gpio_write(&poodle_locomo_device.dev, 49 - POODLE_LOCOMO_GPIO_MUTE_R, 1); 48 + locomo_gpio_write(poodle_pdata->locomo_dev, 49 + poodle_pdata->gpio_mute_l, 1); 50 + locomo_gpio_write(poodle_pdata->locomo_dev, 51 + poodle_pdata->gpio_mute_r, 1); 50 52 snd_soc_dapm_enable_pin(dapm, "Headphone Jack"); 51 53 } else { 52 - locomo_gpio_write(&poodle_locomo_device.dev, 53 - POODLE_LOCOMO_GPIO_MUTE_L, 0); 54 - locomo_gpio_write(&poodle_locomo_device.dev, 55 - POODLE_LOCOMO_GPIO_MUTE_R, 0); 54 + locomo_gpio_write(poodle_pdata->locomo_dev, 55 + poodle_pdata->gpio_mute_l, 0); 56 + locomo_gpio_write(poodle_pdata->locomo_dev, 57 + poodle_pdata->gpio_mute_r, 0); 56 58 snd_soc_dapm_disable_pin(dapm, "Headphone Jack"); 57 59 } 58 60 ··· 82 80 static void poodle_shutdown(struct snd_pcm_substream *substream) 83 81 { 84 82 /* set = unmute headphone */ 85 - locomo_gpio_write(&poodle_locomo_device.dev, 86 - POODLE_LOCOMO_GPIO_MUTE_L, 1); 87 - locomo_gpio_write(&poodle_locomo_device.dev, 88 - POODLE_LOCOMO_GPIO_MUTE_R, 1); 83 + locomo_gpio_write(poodle_pdata->locomo_dev, 84 + poodle_pdata->gpio_mute_l, 1); 85 + locomo_gpio_write(poodle_pdata->locomo_dev, 86 + poodle_pdata->gpio_mute_r, 1); 89 87 } 90 88 91 89 static int poodle_hw_params(struct snd_pcm_substream *substream, ··· 176 174 struct snd_kcontrol *k, int event) 177 175 { 178 176 if (SND_SOC_DAPM_EVENT_ON(event)) 179 - locomo_gpio_write(&poodle_locomo_device.dev, 180 - POODLE_LOCOMO_GPIO_AMP_ON, 0); 177 + locomo_gpio_write(poodle_pdata->locomo_dev, 178 + poodle_pdata->gpio_amp_on, 0); 181 179 else 182 - locomo_gpio_write(&poodle_locomo_device.dev, 183 - POODLE_LOCOMO_GPIO_AMP_ON, 1); 180 + locomo_gpio_write(poodle_pdata->locomo_dev, 181 + poodle_pdata->gpio_amp_on, 1); 184 182 185 183 return 0; 186 184 } ··· 256 254 struct snd_soc_card *card = &poodle; 257 255 int ret; 258 256 259 - locomo_gpio_set_dir(&poodle_locomo_device.dev, 260 - POODLE_LOCOMO_GPIO_AMP_ON, 0); 257 + poodle_pdata = pdev->dev.platform_data; 258 + locomo_gpio_set_dir(poodle_pdata->locomo_dev, 259 + poodle_pdata->gpio_amp_on, 0); 261 260 /* should we mute HP at startup - burning power ?*/ 262 - locomo_gpio_set_dir(&poodle_locomo_device.dev, 263 - POODLE_LOCOMO_GPIO_MUTE_L, 0); 264 - locomo_gpio_set_dir(&poodle_locomo_device.dev, 265 - POODLE_LOCOMO_GPIO_MUTE_R, 0); 261 + locomo_gpio_set_dir(poodle_pdata->locomo_dev, 262 + poodle_pdata->gpio_mute_l, 0); 263 + locomo_gpio_set_dir(poodle_pdata->locomo_dev, 264 + poodle_pdata->gpio_mute_r, 0); 266 265 267 266 card->dev = &pdev->dev; 268 267