Commit ac70f4d8 authored by Arnd Bergmann's avatar Arnd Bergmann
Browse files

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
Loading
Loading
Loading
Loading
+20 −10
Original line number Diff line number Diff line
@@ -39,11 +39,13 @@
#include <asm/mach/irq.h>

#include "pxa25x.h"
#include <linux/platform_data/mmc-pxamci.h>
#include "udc.h"
#include "poodle.h"

#include <linux/platform_data/mmc-pxamci.h>
#include <linux/platform_data/irda-pxaficp.h>
#include <mach/poodle.h>
#include <linux/platform_data/video-pxafb.h>
#include <linux/platform_data/asoc-poodle.h>

#include <asm/hardware/scoop.h>
#include <asm/hardware/locomo.h>
@@ -155,12 +157,6 @@ static struct scoop_pcmcia_config poodle_pcmcia_config = {

EXPORT_SYMBOL(poodle_scoop_device);


static struct platform_device poodle_audio_device = {
	.name	= "poodle-audio",
	.id	= -1,
};

/* LoCoMo device */
static struct resource locomo_resources[] = {
	[0] = {
@@ -179,7 +175,7 @@ static struct locomo_platform_data locomo_info = {
	.irq_base	= IRQ_BOARD_START,
};

struct platform_device poodle_locomo_device = {
static struct platform_device poodle_locomo_device = {
	.name		= "locomo",
	.id		= 0,
	.num_resources	= ARRAY_SIZE(locomo_resources),
@@ -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)
static struct pxa2xx_spi_controller poodle_spi_info = {
+1 −3
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@
#ifndef __ASM_ARCH_POODLE_H
#define __ASM_ARCH_POODLE_H  1

#include "irqs.h" /* PXA_GPIO_TO_IRQ */
#include <mach/irqs.h> /* PXA_GPIO_TO_IRQ */

/*
 * GPIOs
@@ -89,6 +89,4 @@

#define POODLE_NR_IRQS		(IRQ_BOARD_START + 4)	/* 4 for LoCoMo */

extern struct platform_device poodle_locomo_device;

#endif /* __ASM_ARCH_POODLE_H  */
+16 −0
Original line number Diff line number Diff line
/* 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
+26 −23
Original line number Diff line number Diff line
@@ -21,8 +21,8 @@

#include <asm/mach-types.h>
#include <asm/hardware/locomo.h>
#include <mach/poodle.h>
#include <linux/platform_data/asoc-pxa.h>
#include <linux/platform_data/asoc-poodle.h>

#include "../codecs/wm8731.h"
#include "pxa2xx-i2s.h"
@@ -38,21 +38,23 @@
static int poodle_jack_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)
{
	/* set up jack connection */
	if (poodle_jack_func == POODLE_HP) {
		/* set = unmute headphone */
		locomo_gpio_write(&poodle_locomo_device.dev,
			POODLE_LOCOMO_GPIO_MUTE_L, 1);
		locomo_gpio_write(&poodle_locomo_device.dev,
			POODLE_LOCOMO_GPIO_MUTE_R, 1);
		locomo_gpio_write(poodle_pdata->locomo_dev,
			poodle_pdata->gpio_mute_l, 1);
		locomo_gpio_write(poodle_pdata->locomo_dev,
			poodle_pdata->gpio_mute_r, 1);
		snd_soc_dapm_enable_pin(dapm, "Headphone Jack");
	} else {
		locomo_gpio_write(&poodle_locomo_device.dev,
			POODLE_LOCOMO_GPIO_MUTE_L, 0);
		locomo_gpio_write(&poodle_locomo_device.dev,
			POODLE_LOCOMO_GPIO_MUTE_R, 0);
		locomo_gpio_write(poodle_pdata->locomo_dev,
			poodle_pdata->gpio_mute_l, 0);
		locomo_gpio_write(poodle_pdata->locomo_dev,
			poodle_pdata->gpio_mute_r, 0);
		snd_soc_dapm_disable_pin(dapm, "Headphone Jack");
	}

@@ -80,10 +82,10 @@ static int poodle_startup(struct snd_pcm_substream *substream)
static void poodle_shutdown(struct snd_pcm_substream *substream)
{
	/* set = unmute headphone */
	locomo_gpio_write(&poodle_locomo_device.dev,
		POODLE_LOCOMO_GPIO_MUTE_L, 1);
	locomo_gpio_write(&poodle_locomo_device.dev,
		POODLE_LOCOMO_GPIO_MUTE_R, 1);
	locomo_gpio_write(poodle_pdata->locomo_dev,
		poodle_pdata->gpio_mute_l, 1);
	locomo_gpio_write(poodle_pdata->locomo_dev,
		poodle_pdata->gpio_mute_r, 1);
}

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,
	struct snd_kcontrol *k, int event)
{
	if (SND_SOC_DAPM_EVENT_ON(event))
		locomo_gpio_write(&poodle_locomo_device.dev,
			POODLE_LOCOMO_GPIO_AMP_ON, 0);
		locomo_gpio_write(poodle_pdata->locomo_dev,
			poodle_pdata->gpio_amp_on, 0);
	else
		locomo_gpio_write(&poodle_locomo_device.dev,
			POODLE_LOCOMO_GPIO_AMP_ON, 1);
		locomo_gpio_write(poodle_pdata->locomo_dev,
			poodle_pdata->gpio_amp_on, 1);

	return 0;
}
@@ -254,13 +256,14 @@ static int poodle_probe(struct platform_device *pdev)
	struct snd_soc_card *card = &poodle;
	int ret;

	locomo_gpio_set_dir(&poodle_locomo_device.dev,
		POODLE_LOCOMO_GPIO_AMP_ON, 0);
	poodle_pdata = pdev->dev.platform_data;
	locomo_gpio_set_dir(poodle_pdata->locomo_dev,
		poodle_pdata->gpio_amp_on, 0);
	/* should we mute HP at startup - burning power ?*/
	locomo_gpio_set_dir(&poodle_locomo_device.dev,
		POODLE_LOCOMO_GPIO_MUTE_L, 0);
	locomo_gpio_set_dir(&poodle_locomo_device.dev,
		POODLE_LOCOMO_GPIO_MUTE_R, 0);
	locomo_gpio_set_dir(poodle_pdata->locomo_dev,
		poodle_pdata->gpio_mute_l, 0);
	locomo_gpio_set_dir(poodle_pdata->locomo_dev,
		poodle_pdata->gpio_mute_r, 0);

	card->dev = &pdev->dev;