Commit ac70f4d8 authored by Arnd Bergmann's avatar Arnd Bergmann

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: default avatarMark Brown <broonie@kernel.org>
Acked-by: default avatarRobert Jarzmik <robert.jarzmik@free.fr>
Cc: alsa-devel@alsa-project.org
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
parent 813c2aee
...@@ -39,11 +39,13 @@ ...@@ -39,11 +39,13 @@
#include <asm/mach/irq.h> #include <asm/mach/irq.h>
#include "pxa25x.h" #include "pxa25x.h"
#include <linux/platform_data/mmc-pxamci.h>
#include "udc.h" #include "udc.h"
#include "poodle.h"
#include <linux/platform_data/mmc-pxamci.h>
#include <linux/platform_data/irda-pxaficp.h> #include <linux/platform_data/irda-pxaficp.h>
#include <mach/poodle.h>
#include <linux/platform_data/video-pxafb.h> #include <linux/platform_data/video-pxafb.h>
#include <linux/platform_data/asoc-poodle.h>
#include <asm/hardware/scoop.h> #include <asm/hardware/scoop.h>
#include <asm/hardware/locomo.h> #include <asm/hardware/locomo.h>
...@@ -155,12 +157,6 @@ static struct scoop_pcmcia_config poodle_pcmcia_config = { ...@@ -155,12 +157,6 @@ static struct scoop_pcmcia_config poodle_pcmcia_config = {
EXPORT_SYMBOL(poodle_scoop_device); EXPORT_SYMBOL(poodle_scoop_device);
static struct platform_device poodle_audio_device = {
.name = "poodle-audio",
.id = -1,
};
/* LoCoMo device */ /* LoCoMo device */
static struct resource locomo_resources[] = { static struct resource locomo_resources[] = {
[0] = { [0] = {
...@@ -179,7 +175,7 @@ static struct locomo_platform_data locomo_info = { ...@@ -179,7 +175,7 @@ static struct locomo_platform_data locomo_info = {
.irq_base = IRQ_BOARD_START, .irq_base = IRQ_BOARD_START,
}; };
struct platform_device poodle_locomo_device = { static struct platform_device poodle_locomo_device = {
.name = "locomo", .name = "locomo",
.id = 0, .id = 0,
.num_resources = ARRAY_SIZE(locomo_resources), .num_resources = ARRAY_SIZE(locomo_resources),
...@@ -189,7 +185,21 @@ struct platform_device poodle_locomo_device = { ...@@ -189,7 +185,21 @@ struct platform_device poodle_locomo_device = {
}, },
}; };
EXPORT_SYMBOL(poodle_locomo_device); static struct poodle_audio_platform_data poodle_audio_pdata = {
.locomo_dev = &poodle_locomo_device.dev,
.gpio_amp_on = POODLE_LOCOMO_GPIO_AMP_ON,
.gpio_mute_l = POODLE_LOCOMO_GPIO_MUTE_L,
.gpio_mute_r = POODLE_LOCOMO_GPIO_MUTE_R,
.gpio_232vcc_on = POODLE_LOCOMO_GPIO_232VCC_ON,
.gpio_jk_b = POODLE_LOCOMO_GPIO_JK_B,
};
static struct platform_device poodle_audio_device = {
.name = "poodle-audio",
.id = -1,
.dev.platform_data = &poodle_audio_pdata,
};
#if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE) #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
static struct pxa2xx_spi_controller poodle_spi_info = { static struct pxa2xx_spi_controller poodle_spi_info = {
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#ifndef __ASM_ARCH_POODLE_H #ifndef __ASM_ARCH_POODLE_H
#define __ASM_ARCH_POODLE_H 1 #define __ASM_ARCH_POODLE_H 1
#include "irqs.h" /* PXA_GPIO_TO_IRQ */ #include <mach/irqs.h> /* PXA_GPIO_TO_IRQ */
/* /*
* GPIOs * GPIOs
...@@ -89,6 +89,4 @@ ...@@ -89,6 +89,4 @@
#define POODLE_NR_IRQS (IRQ_BOARD_START + 4) /* 4 for LoCoMo */ #define POODLE_NR_IRQS (IRQ_BOARD_START + 4) /* 4 for LoCoMo */
extern struct platform_device poodle_locomo_device;
#endif /* __ASM_ARCH_POODLE_H */ #endif /* __ASM_ARCH_POODLE_H */
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __LINUX_PLATFORM_DATA_POODLE_AUDIO
#define __LINUX_PLATFORM_DATA_POODLE_AUDIO
/* locomo is not a proper gpio driver, and uses its own api */
struct poodle_audio_platform_data {
struct device *locomo_dev;
int gpio_amp_on;
int gpio_mute_l;
int gpio_mute_r;
int gpio_232vcc_on;
int gpio_jk_b;
};
#endif
...@@ -21,8 +21,8 @@ ...@@ -21,8 +21,8 @@
#include <asm/mach-types.h> #include <asm/mach-types.h>
#include <asm/hardware/locomo.h> #include <asm/hardware/locomo.h>
#include <mach/poodle.h>
#include <linux/platform_data/asoc-pxa.h> #include <linux/platform_data/asoc-pxa.h>
#include <linux/platform_data/asoc-poodle.h>
#include "../codecs/wm8731.h" #include "../codecs/wm8731.h"
#include "pxa2xx-i2s.h" #include "pxa2xx-i2s.h"
...@@ -38,21 +38,23 @@ ...@@ -38,21 +38,23 @@
static int poodle_jack_func; static int poodle_jack_func;
static int poodle_spk_func; static int poodle_spk_func;
static struct poodle_audio_platform_data *poodle_pdata;
static void poodle_ext_control(struct snd_soc_dapm_context *dapm) static void poodle_ext_control(struct snd_soc_dapm_context *dapm)
{ {
/* set up jack connection */ /* set up jack connection */
if (poodle_jack_func == POODLE_HP) { if (poodle_jack_func == POODLE_HP) {
/* set = unmute headphone */ /* set = unmute headphone */
locomo_gpio_write(&poodle_locomo_device.dev, locomo_gpio_write(poodle_pdata->locomo_dev,
POODLE_LOCOMO_GPIO_MUTE_L, 1); poodle_pdata->gpio_mute_l, 1);
locomo_gpio_write(&poodle_locomo_device.dev, locomo_gpio_write(poodle_pdata->locomo_dev,
POODLE_LOCOMO_GPIO_MUTE_R, 1); poodle_pdata->gpio_mute_r, 1);
snd_soc_dapm_enable_pin(dapm, "Headphone Jack"); snd_soc_dapm_enable_pin(dapm, "Headphone Jack");
} else { } else {
locomo_gpio_write(&poodle_locomo_device.dev, locomo_gpio_write(poodle_pdata->locomo_dev,
POODLE_LOCOMO_GPIO_MUTE_L, 0); poodle_pdata->gpio_mute_l, 0);
locomo_gpio_write(&poodle_locomo_device.dev, locomo_gpio_write(poodle_pdata->locomo_dev,
POODLE_LOCOMO_GPIO_MUTE_R, 0); poodle_pdata->gpio_mute_r, 0);
snd_soc_dapm_disable_pin(dapm, "Headphone Jack"); snd_soc_dapm_disable_pin(dapm, "Headphone Jack");
} }
...@@ -80,10 +82,10 @@ static int poodle_startup(struct snd_pcm_substream *substream) ...@@ -80,10 +82,10 @@ static int poodle_startup(struct snd_pcm_substream *substream)
static void poodle_shutdown(struct snd_pcm_substream *substream) static void poodle_shutdown(struct snd_pcm_substream *substream)
{ {
/* set = unmute headphone */ /* set = unmute headphone */
locomo_gpio_write(&poodle_locomo_device.dev, locomo_gpio_write(poodle_pdata->locomo_dev,
POODLE_LOCOMO_GPIO_MUTE_L, 1); poodle_pdata->gpio_mute_l, 1);
locomo_gpio_write(&poodle_locomo_device.dev, locomo_gpio_write(poodle_pdata->locomo_dev,
POODLE_LOCOMO_GPIO_MUTE_R, 1); poodle_pdata->gpio_mute_r, 1);
} }
static int poodle_hw_params(struct snd_pcm_substream *substream, static int poodle_hw_params(struct snd_pcm_substream *substream,
...@@ -174,11 +176,11 @@ static int poodle_amp_event(struct snd_soc_dapm_widget *w, ...@@ -174,11 +176,11 @@ static int poodle_amp_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *k, int event) struct snd_kcontrol *k, int event)
{ {
if (SND_SOC_DAPM_EVENT_ON(event)) if (SND_SOC_DAPM_EVENT_ON(event))
locomo_gpio_write(&poodle_locomo_device.dev, locomo_gpio_write(poodle_pdata->locomo_dev,
POODLE_LOCOMO_GPIO_AMP_ON, 0); poodle_pdata->gpio_amp_on, 0);
else else
locomo_gpio_write(&poodle_locomo_device.dev, locomo_gpio_write(poodle_pdata->locomo_dev,
POODLE_LOCOMO_GPIO_AMP_ON, 1); poodle_pdata->gpio_amp_on, 1);
return 0; return 0;
} }
...@@ -254,13 +256,14 @@ static int poodle_probe(struct platform_device *pdev) ...@@ -254,13 +256,14 @@ static int poodle_probe(struct platform_device *pdev)
struct snd_soc_card *card = &poodle; struct snd_soc_card *card = &poodle;
int ret; int ret;
locomo_gpio_set_dir(&poodle_locomo_device.dev, poodle_pdata = pdev->dev.platform_data;
POODLE_LOCOMO_GPIO_AMP_ON, 0); locomo_gpio_set_dir(poodle_pdata->locomo_dev,
poodle_pdata->gpio_amp_on, 0);
/* should we mute HP at startup - burning power ?*/ /* should we mute HP at startup - burning power ?*/
locomo_gpio_set_dir(&poodle_locomo_device.dev, locomo_gpio_set_dir(poodle_pdata->locomo_dev,
POODLE_LOCOMO_GPIO_MUTE_L, 0); poodle_pdata->gpio_mute_l, 0);
locomo_gpio_set_dir(&poodle_locomo_device.dev, locomo_gpio_set_dir(poodle_pdata->locomo_dev,
POODLE_LOCOMO_GPIO_MUTE_R, 0); poodle_pdata->gpio_mute_r, 0);
card->dev = &pdev->dev; card->dev = &pdev->dev;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment