Просмотр исходного кода

ALSA: Allow passing platform_data for pxa2xx-ac97

This patch adds support for passing platform data to ac97 bus devices
from PXA2xx-AC97 driver..

Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Marek Vasut 16 лет назад
Родитель
Сommit
4ac0478f2a
4 измененных файлов с 27 добавлено и 1 удалено
  1. 3 0
      arch/arm/mach-pxa/include/mach/audio.h
  2. 3 0
      include/sound/ac97_codec.h
  3. 10 0
      sound/arm/pxa2xx-ac97.c
  4. 11 1
      sound/soc/pxa/pxa2xx-ac97.c

+ 3 - 0
arch/arm/mach-pxa/include/mach/audio.h

@@ -3,10 +3,12 @@
 
 
 #include <sound/core.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm.h>
+#include <sound/ac97_codec.h>
 
 
 /*
 /*
  * @reset_gpio: AC97 reset gpio (normally gpio113 or gpio95)
  * @reset_gpio: AC97 reset gpio (normally gpio113 or gpio95)
  *              a -1 value means no gpio will be used for reset
  *              a -1 value means no gpio will be used for reset
+ * @codec_pdata: AC97 codec platform_data
 
 
  * reset_gpio should only be specified for pxa27x CPUs where a silicon
  * reset_gpio should only be specified for pxa27x CPUs where a silicon
  * bug prevents correct operation of the reset line. If not specified,
  * bug prevents correct operation of the reset line. If not specified,
@@ -20,6 +22,7 @@ typedef struct {
 	void (*resume)(void *);
 	void (*resume)(void *);
 	void *priv;
 	void *priv;
 	int reset_gpio;
 	int reset_gpio;
+	void *codec_pdata[AC97_BUS_MAX_DEVICES];
 } pxa2xx_audio_ops_t;
 } pxa2xx_audio_ops_t;
 
 
 extern void pxa_set_ac97_info(pxa2xx_audio_ops_t *ops);
 extern void pxa_set_ac97_info(pxa2xx_audio_ops_t *ops);

+ 3 - 0
include/sound/ac97_codec.h

@@ -32,6 +32,9 @@
 #include "control.h"
 #include "control.h"
 #include "info.h"
 #include "info.h"
 
 
+/* maximum number of devices on the AC97 bus */
+#define	AC97_BUS_MAX_DEVICES	4
+
 /*
 /*
  *  AC'97 codec registers
  *  AC'97 codec registers
  */
  */

+ 10 - 0
sound/arm/pxa2xx-ac97.c

@@ -170,6 +170,13 @@ static int __devinit pxa2xx_ac97_probe(struct platform_device *dev)
 	struct snd_ac97_bus *ac97_bus;
 	struct snd_ac97_bus *ac97_bus;
 	struct snd_ac97_template ac97_template;
 	struct snd_ac97_template ac97_template;
 	int ret;
 	int ret;
+	pxa2xx_audio_ops_t *pdata = dev->dev.platform_data;
+
+	if (dev->id >= 0) {
+		dev_err(&dev->dev, "PXA2xx has only one AC97 port.\n");
+		ret = -ENXIO;
+		goto err_dev;
+	}
 
 
 	ret = snd_card_create(SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
 	ret = snd_card_create(SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
 			      THIS_MODULE, 0, &card);
 			      THIS_MODULE, 0, &card);
@@ -200,6 +207,8 @@ static int __devinit pxa2xx_ac97_probe(struct platform_device *dev)
 	snprintf(card->longname, sizeof(card->longname),
 	snprintf(card->longname, sizeof(card->longname),
 		 "%s (%s)", dev->dev.driver->name, card->mixername);
 		 "%s (%s)", dev->dev.driver->name, card->mixername);
 
 
+	if (pdata && pdata->codec_data)
+		snd_ac97_dev_add_pdata(ac97_bus->codec[0], pdata->codec_pdata);
 	snd_card_set_dev(card, &dev->dev);
 	snd_card_set_dev(card, &dev->dev);
 	ret = snd_card_register(card);
 	ret = snd_card_register(card);
 	if (ret == 0) {
 	if (ret == 0) {
@@ -212,6 +221,7 @@ err_remove:
 err:
 err:
 	if (card)
 	if (card)
 		snd_card_free(card);
 		snd_card_free(card);
+err_dev:
 	return ret;
 	return ret;
 }
 }
 
 

+ 11 - 1
sound/soc/pxa/pxa2xx-ac97.c

@@ -22,6 +22,7 @@
 #include <mach/hardware.h>
 #include <mach/hardware.h>
 #include <mach/regs-ac97.h>
 #include <mach/regs-ac97.h>
 #include <mach/dma.h>
 #include <mach/dma.h>
+#include <mach/audio.h>
 
 
 #include "pxa2xx-pcm.h"
 #include "pxa2xx-pcm.h"
 #include "pxa2xx-ac97.h"
 #include "pxa2xx-ac97.h"
@@ -241,9 +242,18 @@ EXPORT_SYMBOL_GPL(soc_ac97_ops);
 static int __devinit pxa2xx_ac97_dev_probe(struct platform_device *pdev)
 static int __devinit pxa2xx_ac97_dev_probe(struct platform_device *pdev)
 {
 {
 	int i;
 	int i;
+	pxa2xx_audio_ops_t *pdata = pdev->dev.platform_data;
 
 
-	for (i = 0; i < ARRAY_SIZE(pxa_ac97_dai); i++)
+	if (pdev->id >= 0) {
+		dev_err(&pdev->dev, "PXA2xx has only one AC97 port.\n");
+		return -ENXIO;
+	}
+
+	for (i = 0; i < ARRAY_SIZE(pxa_ac97_dai); i++) {
 		pxa_ac97_dai[i].dev = &pdev->dev;
 		pxa_ac97_dai[i].dev = &pdev->dev;
+		if (pdata && pdata->codec_pdata)
+			pxa_ac97_dai[i].ac97_pdata = pdata->codec_pdata;
+	}
 
 
 	/* Punt most of the init to the SoC probe; we may need the machine
 	/* Punt most of the init to the SoC probe; we may need the machine
 	 * driver to do interesting things with the clocking to get us up
 	 * driver to do interesting things with the clocking to get us up