public inbox for alsa-devel@alsa-project.org
 help / color / mirror / Atom feed
* [PATCH] Allow passing platform_data to devices attached to AC97 bus
@ 2009-07-21 14:33 Marek Vasut
  2009-07-21 14:50 ` Takashi Iwai
  2009-07-21 15:11 ` Robert Jarzmik
  0 siblings, 2 replies; 52+ messages in thread
From: Marek Vasut @ 2009-07-21 14:33 UTC (permalink / raw)
  To: alsa-devel; +Cc: Takashi Iwai, Mark Brown

[-- Attachment #1: Type: text/plain, Size: 188 bytes --]

Hi,

I managed to put together this patch with huge help from Mark. It allows 
passing platform_data to devices on ac97 bus and implements this for pxa2xx-
ac97. Please consider applying.

[-- Attachment #2: 0001-Allow-passing-platform_data-to-devices-attached-to-A.patch --]
[-- Type: text/x-patch, Size: 5195 bytes --]

From dc427c54f0fede86acb6e21b09908597b066f021 Mon Sep 17 00:00:00 2001
From: Marek Vasut <marek.vasut@gmail.com>
Date: Tue, 21 Jul 2009 16:22:29 +0200
Subject: [PATCH] Allow passing platform_data to devices attached to AC97 bus

This patch allows passing platform_data to devices attached to AC97 bus
(like touchscreens, battery measurement chips ...). This patch also adds
this support into PXA2xx-AC97 driver as a reference implementation.

Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
---
 arch/arm/mach-pxa/include/mach/audio.h |    1 +
 include/sound/ac97_codec.h             |    3 +++
 include/sound/soc-dai.h                |    1 +
 sound/arm/pxa2xx-ac97.c                |    3 +++
 sound/pci/ac97/ac97_codec.c            |    7 +++++++
 sound/soc/pxa/pxa2xx-ac97.c            |    7 ++++++-
 sound/soc/soc-core.c                   |    5 ++++-
 7 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-pxa/include/mach/audio.h b/arch/arm/mach-pxa/include/mach/audio.h
index 16eb025..8825b18 100644
--- a/arch/arm/mach-pxa/include/mach/audio.h
+++ b/arch/arm/mach-pxa/include/mach/audio.h
@@ -20,6 +20,7 @@ typedef struct {
 	void (*resume)(void *);
 	void *priv;
 	int reset_gpio;
+	void *codec_pdata[4];
 } pxa2xx_audio_ops_t;
 
 extern void pxa_set_ac97_info(pxa2xx_audio_ops_t *ops);
diff --git a/include/sound/ac97_codec.h b/include/sound/ac97_codec.h
index 251fc1c..c6b24e2 100644
--- a/include/sound/ac97_codec.h
+++ b/include/sound/ac97_codec.h
@@ -642,4 +642,7 @@ int snd_ac97_pcm_double_rate_rules(struct snd_pcm_runtime *runtime);
 /* ad hoc AC97 device driver access */
 extern struct bus_type ac97_bus_type;
 
+/* AC97 platform_data adding function */
+void snd_ac97_dev_add_pdata(struct snd_ac97 *ac97, void *data);
+
 #endif /* __SOUND_AC97_CODEC_H */
diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index 352d7ee..0d65a03 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -179,6 +179,7 @@ struct snd_soc_dai {
 	int ac97_control;
 
 	struct device *dev;
+	void *ac97_pdata;	/* platform_data for the ac97 codec */
 
 	/* DAI callbacks */
 	int (*probe)(struct platform_device *pdev,
diff --git a/sound/arm/pxa2xx-ac97.c b/sound/arm/pxa2xx-ac97.c
index c570ebd..cfab74e 100644
--- a/sound/arm/pxa2xx-ac97.c
+++ b/sound/arm/pxa2xx-ac97.c
@@ -170,6 +170,8 @@ static int __devinit pxa2xx_ac97_probe(struct platform_device *dev)
 	struct snd_ac97_bus *ac97_bus;
 	struct snd_ac97_template ac97_template;
 	int ret;
+	pxa2xx_audio_ops_t *pdata = dev->dev.platform_data;
+	int id = dev->id < 0 ? 0 : dev->id;
 
 	ret = snd_card_create(SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
 			      THIS_MODULE, 0, &card);
@@ -200,6 +202,7 @@ static int __devinit pxa2xx_ac97_probe(struct platform_device *dev)
 	snprintf(card->longname, sizeof(card->longname),
 		 "%s (%s)", dev->dev.driver->name, card->mixername);
 
+	snd_ac97_dev_add_pdata(ac97_bus->codec[id], pdata->codec_pdata[id]);
 	snd_card_set_dev(card, &dev->dev);
 	ret = snd_card_register(card);
 	if (ret == 0) {
diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c
index 78288db..476853a 100644
--- a/sound/pci/ac97/ac97_codec.c
+++ b/sound/pci/ac97/ac97_codec.c
@@ -1922,6 +1922,13 @@ static void ac97_device_release(struct device * dev)
 {
 }
 
+/* add platform_data to the ac97 device */
+void snd_ac97_dev_add_pdata(struct snd_ac97 *ac97, void *data)
+{
+	ac97->dev.platform_data = data;
+}
+EXPORT_SYMBOL_GPL(snd_ac97_dev_add_pdata);
+
 /* register ac97 codec to bus */
 static int snd_ac97_dev_register(struct snd_device *device)
 {
diff --git a/sound/soc/pxa/pxa2xx-ac97.c b/sound/soc/pxa/pxa2xx-ac97.c
index d9c94d7..dea18ee 100644
--- a/sound/soc/pxa/pxa2xx-ac97.c
+++ b/sound/soc/pxa/pxa2xx-ac97.c
@@ -22,6 +22,7 @@
 #include <mach/hardware.h>
 #include <mach/regs-ac97.h>
 #include <mach/dma.h>
+#include <mach/audio.h>
 
 #include "pxa2xx-pcm.h"
 #include "pxa2xx-ac97.h"
@@ -241,9 +242,13 @@ EXPORT_SYMBOL_GPL(soc_ac97_ops);
 static int __devinit pxa2xx_ac97_dev_probe(struct platform_device *pdev)
 {
 	int i;
+	pxa2xx_audio_ops_t *pdata = pdev->dev.platform_data;
 
-	for (i = 0; i < ARRAY_SIZE(pxa_ac97_dai); i++)
+	for (i = 0; i < ARRAY_SIZE(pxa_ac97_dai); i++) {
 		pxa_ac97_dai[i].dev = &pdev->dev;
+		pxa_ac97_dai[i].ac97_pdata = pdata->codec_pdata
+					[pdev->id < 0 ? 0 : pdev->id];
+	}
 
 	/* 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
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 1d70829..0b12fe5 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1381,8 +1381,11 @@ int snd_soc_init_card(struct snd_soc_device *socdev)
 				continue;
 			}
 		}
-		if (card->dai_link[i].codec_dai->ac97_control)
+		if (card->dai_link[i].codec_dai->ac97_control) {
 			ac97 = 1;
+			codec->ac97->dev.platform_data =
+				card->dai_link[i].cpu_dai->ac97_pdata;
+		}
 	}
 	snprintf(codec->card->shortname, sizeof(codec->card->shortname),
 		 "%s",  card->name);
-- 
1.6.3.3


[-- Attachment #3: Type: text/plain, Size: 160 bytes --]

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* Re: [PATCH] Allow passing platform_data to devices attached to AC97 bus
  2009-07-21 14:33 [PATCH] Allow passing platform_data to devices attached to AC97 bus Marek Vasut
@ 2009-07-21 14:50 ` Takashi Iwai
  2009-07-21 14:53   ` Mark Brown
  2009-07-21 15:11 ` Robert Jarzmik
  1 sibling, 1 reply; 52+ messages in thread
From: Takashi Iwai @ 2009-07-21 14:50 UTC (permalink / raw)
  To: Marek Vasut; +Cc: alsa-devel, Mark Brown

At Tue, 21 Jul 2009 16:33:14 +0200,
Marek Vasut wrote:
> 
> diff --git a/include/sound/ac97_codec.h b/include/sound/ac97_codec.h
> index 251fc1c..c6b24e2 100644
> --- a/include/sound/ac97_codec.h
> +++ b/include/sound/ac97_codec.h
> @@ -642,4 +642,7 @@ int snd_ac97_pcm_double_rate_rules(struct snd_pcm_runtime *runtime);
>  /* ad hoc AC97 device driver access */
>  extern struct bus_type ac97_bus_type;
>  
> +/* AC97 platform_data adding function */
> +void snd_ac97_dev_add_pdata(struct snd_ac97 *ac97, void *data);

The get/set accessors would be more consistent, I think.
Also, such a small one can be inline function.  We don't always need
to grow exported symbols.

> diff --git a/sound/arm/pxa2xx-ac97.c b/sound/arm/pxa2xx-ac97.c
> index c570ebd..cfab74e 100644
> --- a/sound/arm/pxa2xx-ac97.c
> +++ b/sound/arm/pxa2xx-ac97.c
> @@ -170,6 +170,8 @@ static int __devinit pxa2xx_ac97_probe(struct platform_device *dev)
>  	struct snd_ac97_bus *ac97_bus;
>  	struct snd_ac97_template ac97_template;
>  	int ret;
> +	pxa2xx_audio_ops_t *pdata = dev->dev.platform_data;

Use the get function.

>  /* register ac97 codec to bus */
>  static int snd_ac97_dev_register(struct snd_device *device)
>  {
> diff --git a/sound/soc/pxa/pxa2xx-ac97.c b/sound/soc/pxa/pxa2xx-ac97.c
> index d9c94d7..dea18ee 100644
> --- a/sound/soc/pxa/pxa2xx-ac97.c
> +++ b/sound/soc/pxa/pxa2xx-ac97.c
> @@ -22,6 +22,7 @@
>  #include <mach/hardware.h>
>  #include <mach/regs-ac97.h>
>  #include <mach/dma.h>
> +#include <mach/audio.h>
>  
>  #include "pxa2xx-pcm.h"
>  #include "pxa2xx-ac97.h"
> @@ -241,9 +242,13 @@ EXPORT_SYMBOL_GPL(soc_ac97_ops);
>  static int __devinit pxa2xx_ac97_dev_probe(struct platform_device *pdev)
>  {
>  	int i;
> +	pxa2xx_audio_ops_t *pdata = pdev->dev.platform_data;

Use the get function.

> diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
> index 1d70829..0b12fe5 100644
> --- a/sound/soc/soc-core.c
> +++ b/sound/soc/soc-core.c
> @@ -1381,8 +1381,11 @@ int snd_soc_init_card(struct snd_soc_device *socdev)
>  				continue;
>  			}
>  		}
> -		if (card->dai_link[i].codec_dai->ac97_control)
> +		if (card->dai_link[i].codec_dai->ac97_control) {
>  			ac97 = 1;
> +			codec->ac97->dev.platform_data =
> +				card->dai_link[i].cpu_dai->ac97_pdata;

Use the set function.

Also, at the next time, add Russell or linux-arm to Cc so that he
knows at least that a file in arch/arm will be changed.


thanks,

Takashi

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH] Allow passing platform_data to devices attached to AC97 bus
  2009-07-21 14:50 ` Takashi Iwai
@ 2009-07-21 14:53   ` Mark Brown
  2009-07-21 15:16     ` Takashi Iwai
  0 siblings, 1 reply; 52+ messages in thread
From: Mark Brown @ 2009-07-21 14:53 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Marek Vasut, alsa-devel

On Tue, Jul 21, 2009 at 04:50:26PM +0200, Takashi Iwai wrote:
> Marek Vasut wrote:

> >  	int ret;
> > +	pxa2xx_audio_ops_t *pdata = dev->dev.platform_data;

> Use the get function.

There's no such function in mainline right now.  However, apropos of
something else I submitted a patch adding that to the driver core - it's
been merged for 2.6.32 but won't be available in ALSA until after the
next merge window.  The function is dev_get_platdata().

> Also, at the next time, add Russell or linux-arm to Cc so that he
> knows at least that a file in arch/arm will be changed.

Ideally split things into two separate patches.

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH] Allow passing platform_data to devices attached to AC97 bus
  2009-07-21 14:33 [PATCH] Allow passing platform_data to devices attached to AC97 bus Marek Vasut
  2009-07-21 14:50 ` Takashi Iwai
@ 2009-07-21 15:11 ` Robert Jarzmik
  2009-07-21 15:17   ` Takashi Iwai
  2009-07-25 20:56   ` Robert Jarzmik
  1 sibling, 2 replies; 52+ messages in thread
From: Robert Jarzmik @ 2009-07-21 15:11 UTC (permalink / raw)
  To: Marek Vasut; +Cc: Takashi Iwai, alsa-devel, Mark Brown

Marek Vasut <marek.vasut@gmail.com> writes:

> diff --git a/arch/arm/mach-pxa/include/mach/audio.h b/arch/arm/mach-pxa/include/mach/audio.h
> index 16eb025..8825b18 100644
> --- a/arch/arm/mach-pxa/include/mach/audio.h
> +++ b/arch/arm/mach-pxa/include/mach/audio.h
> @@ -20,6 +20,7 @@ typedef struct {
>  	void (*resume)(void *);
>  	void *priv;
>  	int reset_gpio;
> +	void *codec_pdata[4];
I don't understand where that '4' comes from. Would you explain ?

> diff --git a/sound/arm/pxa2xx-ac97.c b/sound/arm/pxa2xx-ac97.c
> index c570ebd..cfab74e 100644
> --- a/sound/arm/pxa2xx-ac97.c
> +++ b/sound/arm/pxa2xx-ac97.c
> @@ -170,6 +170,8 @@ static int __devinit pxa2xx_ac97_probe(struct platform_device *dev)
>  	struct snd_ac97_bus *ac97_bus;
>  	struct snd_ac97_template ac97_template;
>  	int ret;
> +	pxa2xx_audio_ops_t *pdata = dev->dev.platform_data;
> +	int id = dev->id < 0 ? 0 : dev->id;
>  
>  	ret = snd_card_create(SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
>  			      THIS_MODULE, 0, &card);
> @@ -200,6 +202,7 @@ static int __devinit pxa2xx_ac97_probe(struct platform_device *dev)
>  	snprintf(card->longname, sizeof(card->longname),
>  		 "%s (%s)", dev->dev.driver->name, card->mixername);
>  
> +	snd_ac97_dev_add_pdata(ac97_bus->codec[id], pdata->codec_pdata[id]);
Is there something that grants that dev->id is lesser than 4 ?

Cheers.

-- 
Robert

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH] Allow passing platform_data to devices attached to AC97 bus
  2009-07-21 14:53   ` Mark Brown
@ 2009-07-21 15:16     ` Takashi Iwai
  2009-07-21 15:40       ` Marek Vasut
                         ` (4 more replies)
  0 siblings, 5 replies; 52+ messages in thread
From: Takashi Iwai @ 2009-07-21 15:16 UTC (permalink / raw)
  To: Mark Brown; +Cc: Marek Vasut, alsa-devel

At Tue, 21 Jul 2009 15:53:23 +0100,
Mark Brown wrote:
> 
> On Tue, Jul 21, 2009 at 04:50:26PM +0200, Takashi Iwai wrote:
> > Marek Vasut wrote:
> 
> > >  	int ret;
> > > +	pxa2xx_audio_ops_t *pdata = dev->dev.platform_data;
> 
> > Use the get function.
> 
> There's no such function in mainline right now.  However, apropos of
> something else I submitted a patch adding that to the driver core - it's
> been merged for 2.6.32 but won't be available in ALSA until after the
> next merge window.  The function is dev_get_platdata().

Ah, right.  This can be fixed later, then.

> > Also, at the next time, add Russell or linux-arm to Cc so that he
> > knows at least that a file in arch/arm will be changed.
> 
> Ideally split things into two separate patches.

Agreed.


Takashi

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH] Allow passing platform_data to devices attached to AC97 bus
  2009-07-21 15:11 ` Robert Jarzmik
@ 2009-07-21 15:17   ` Takashi Iwai
  2009-07-25 20:56   ` Robert Jarzmik
  1 sibling, 0 replies; 52+ messages in thread
From: Takashi Iwai @ 2009-07-21 15:17 UTC (permalink / raw)
  To: Robert Jarzmik; +Cc: Marek Vasut, alsa-devel, Mark Brown

At Tue, 21 Jul 2009 17:11:03 +0200,
Robert Jarzmik wrote:
> 
> Marek Vasut <marek.vasut@gmail.com> writes:
> 
> > diff --git a/arch/arm/mach-pxa/include/mach/audio.h b/arch/arm/mach-pxa/include/mach/audio.h
> > index 16eb025..8825b18 100644
> > --- a/arch/arm/mach-pxa/include/mach/audio.h
> > +++ b/arch/arm/mach-pxa/include/mach/audio.h
> > @@ -20,6 +20,7 @@ typedef struct {
> >  	void (*resume)(void *);
> >  	void *priv;
> >  	int reset_gpio;
> > +	void *codec_pdata[4];
> I don't understand where that '4' comes from. Would you explain ?

It's defacto-standard max of AC97 slots.  But, yes, a magic number
should be defined explicitly.


Takashi

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH] Allow passing platform_data to devices attached to AC97 bus
  2009-07-21 15:16     ` Takashi Iwai
@ 2009-07-21 15:40       ` Marek Vasut
  2009-07-21 18:30         ` Mark Brown
  2009-07-21 15:41       ` Marek Vasut
                         ` (3 subsequent siblings)
  4 siblings, 1 reply; 52+ messages in thread
From: Marek Vasut @ 2009-07-21 15:40 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: Eric Miao, alsa-devel, Mark Brown, Russell King - ARM Linux,
	linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 982 bytes --]

Dne Út 21. července 2009 17:16:07 Takashi Iwai napsal(a):
> At Tue, 21 Jul 2009 15:53:23 +0100,
>
> Mark Brown wrote:
> > On Tue, Jul 21, 2009 at 04:50:26PM +0200, Takashi Iwai wrote:
> > > Marek Vasut wrote:
> > > >  	int ret;
> > > > +	pxa2xx_audio_ops_t *pdata = dev->dev.platform_data;
> > >
> > > Use the get function.
> >
> > There's no such function in mainline right now.  However, apropos of
> > something else I submitted a patch adding that to the driver core - it's
> > been merged for 2.6.32 but won't be available in ALSA until after the
> > next merge window.  The function is dev_get_platdata().
>
> Ah, right.  This can be fixed later, then.
>
> > > Also, at the next time, add Russell or linux-arm to Cc so that he
> > > knows at least that a file in arch/arm will be changed.
> >
> > Ideally split things into two separate patches.
>
> Agreed.
>
>
> Takashi

Ok, I split it in two, here's the one that adds necessary stuff to alsa.

[-- Attachment #2: 0001-Allow-passing-platform_data-to-devices-attached-to-A.patch --]
[-- Type: text/x-patch, Size: 2618 bytes --]

From bb1d5481f2786a30133a8392c4e46170a1b8b615 Mon Sep 17 00:00:00 2001
From: Marek Vasut <marek.vasut@gmail.com>
Date: Tue, 21 Jul 2009 16:22:29 +0200
Subject: [PATCH 1/2] Allow passing platform_data to devices attached to AC97 bus

This patch allows passing platform_data to devices attached to AC97 bus
(like touchscreens, battery measurement chips ...).

Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
---
 include/sound/ac97_codec.h  |    3 +++
 include/sound/soc-dai.h     |    1 +
 sound/pci/ac97/ac97_codec.c |    6 ++++++
 sound/soc/soc-core.c        |    5 ++++-
 4 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/include/sound/ac97_codec.h b/include/sound/ac97_codec.h
index 251fc1c..aeaa40c 100644
--- a/include/sound/ac97_codec.h
+++ b/include/sound/ac97_codec.h
@@ -642,4 +642,7 @@ int snd_ac97_pcm_double_rate_rules(struct snd_pcm_runtime *runtime);
 /* ad hoc AC97 device driver access */
 extern struct bus_type ac97_bus_type;
 
+/* AC97 platform_data adding function */
+inline void snd_ac97_dev_add_pdata(struct snd_ac97 *ac97, void *data);
+
 #endif /* __SOUND_AC97_CODEC_H */
diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index 352d7ee..0d65a03 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -179,6 +179,7 @@ struct snd_soc_dai {
 	int ac97_control;
 
 	struct device *dev;
+	void *ac97_pdata;	/* platform_data for the ac97 codec */
 
 	/* DAI callbacks */
 	int (*probe)(struct platform_device *pdev,
diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c
index 78288db..e6f23ee 100644
--- a/sound/pci/ac97/ac97_codec.c
+++ b/sound/pci/ac97/ac97_codec.c
@@ -1922,6 +1922,12 @@ static void ac97_device_release(struct device * dev)
 {
 }
 
+/* add platform_data to the ac97 device */
+inline void snd_ac97_dev_add_pdata(struct snd_ac97 *ac97, void *data)
+{
+	ac97->dev.platform_data = data;
+}
+
 /* register ac97 codec to bus */
 static int snd_ac97_dev_register(struct snd_device *device)
 {
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 1d70829..0b12fe5 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1381,8 +1381,11 @@ int snd_soc_init_card(struct snd_soc_device *socdev)
 				continue;
 			}
 		}
-		if (card->dai_link[i].codec_dai->ac97_control)
+		if (card->dai_link[i].codec_dai->ac97_control) {
 			ac97 = 1;
+			codec->ac97->dev.platform_data =
+				card->dai_link[i].cpu_dai->ac97_pdata;
+		}
 	}
 	snprintf(codec->card->shortname, sizeof(codec->card->shortname),
 		 "%s",  card->name);
-- 
1.6.3.3


[-- Attachment #3: Type: text/plain, Size: 160 bytes --]

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* Re: [PATCH] Allow passing platform_data to devices attached to AC97 bus
  2009-07-21 15:16     ` Takashi Iwai
  2009-07-21 15:40       ` Marek Vasut
@ 2009-07-21 15:41       ` Marek Vasut
  2009-07-21 17:40       ` Marek Vasut
                         ` (2 subsequent siblings)
  4 siblings, 0 replies; 52+ messages in thread
From: Marek Vasut @ 2009-07-21 15:41 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: Eric Miao, alsa-devel, Mark Brown, Russell King - ARM Linux,
	linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 987 bytes --]

Dne Út 21. července 2009 17:16:07 Takashi Iwai napsal(a):
> At Tue, 21 Jul 2009 15:53:23 +0100,
>
> Mark Brown wrote:
> > On Tue, Jul 21, 2009 at 04:50:26PM +0200, Takashi Iwai wrote:
> > > Marek Vasut wrote:
> > > >  	int ret;
> > > > +	pxa2xx_audio_ops_t *pdata = dev->dev.platform_data;
> > >
> > > Use the get function.
> >
> > There's no such function in mainline right now.  However, apropos of
> > something else I submitted a patch adding that to the driver core - it's
> > been merged for 2.6.32 but won't be available in ALSA until after the
> > next merge window.  The function is dev_get_platdata().
>
> Ah, right.  This can be fixed later, then.
>
> > > Also, at the next time, add Russell or linux-arm to Cc so that he
> > > knows at least that a file in arch/arm will be changed.
> >
> > Ideally split things into two separate patches.
>
> Agreed.
>
>
> Takashi

And this patch adds changes to pxa2xx-ac97. Also, I fixed the magic constant.

[-- Attachment #2: 0002-Allow-passing-platform_data-for-pxa2xx-ac97.patch --]
[-- Type: text/x-patch, Size: 3731 bytes --]

From 97c0a179284cc8ea1419e1cd1857159bb9bc194b Mon Sep 17 00:00:00 2001
From: Marek Vasut <marek.vasut@gmail.com>
Date: Tue, 21 Jul 2009 16:22:29 +0200
Subject: [PATCH 2/2] 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>
---
 arch/arm/mach-pxa/include/mach/audio.h |    3 +++
 include/sound/ac97_codec.h             |    3 +++
 sound/arm/pxa2xx-ac97.c                |    3 +++
 sound/soc/pxa/pxa2xx-ac97.c            |    7 ++++++-
 4 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-pxa/include/mach/audio.h b/arch/arm/mach-pxa/include/mach/audio.h
index 16eb025..a3449e3 100644
--- a/arch/arm/mach-pxa/include/mach/audio.h
+++ b/arch/arm/mach-pxa/include/mach/audio.h
@@ -3,10 +3,12 @@
 
 #include <sound/core.h>
 #include <sound/pcm.h>
+#include <sound/ac97_codec.h>
 
 /*
  * @reset_gpio: AC97 reset gpio (normally gpio113 or gpio95)
  *              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
  * bug prevents correct operation of the reset line. If not specified,
@@ -20,6 +22,7 @@ typedef struct {
 	void (*resume)(void *);
 	void *priv;
 	int reset_gpio;
+	void *codec_pdata[AC97_BUS_MAX_DEVICES];
 } pxa2xx_audio_ops_t;
 
 extern void pxa_set_ac97_info(pxa2xx_audio_ops_t *ops);
diff --git a/include/sound/ac97_codec.h b/include/sound/ac97_codec.h
index aeaa40c..e5c36c9 100644
--- a/include/sound/ac97_codec.h
+++ b/include/sound/ac97_codec.h
@@ -32,6 +32,9 @@
 #include "control.h"
 #include "info.h"
 
+/* maximum number of devices on the AC97 bus */
+#define	AC97_BUS_MAX_DEVICES	4
+
 /*
  *  AC'97 codec registers
  */
diff --git a/sound/arm/pxa2xx-ac97.c b/sound/arm/pxa2xx-ac97.c
index c570ebd..cfab74e 100644
--- a/sound/arm/pxa2xx-ac97.c
+++ b/sound/arm/pxa2xx-ac97.c
@@ -170,6 +170,8 @@ static int __devinit pxa2xx_ac97_probe(struct platform_device *dev)
 	struct snd_ac97_bus *ac97_bus;
 	struct snd_ac97_template ac97_template;
 	int ret;
+	pxa2xx_audio_ops_t *pdata = dev->dev.platform_data;
+	int id = dev->id < 0 ? 0 : dev->id;
 
 	ret = snd_card_create(SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
 			      THIS_MODULE, 0, &card);
@@ -200,6 +202,7 @@ static int __devinit pxa2xx_ac97_probe(struct platform_device *dev)
 	snprintf(card->longname, sizeof(card->longname),
 		 "%s (%s)", dev->dev.driver->name, card->mixername);
 
+	snd_ac97_dev_add_pdata(ac97_bus->codec[id], pdata->codec_pdata[id]);
 	snd_card_set_dev(card, &dev->dev);
 	ret = snd_card_register(card);
 	if (ret == 0) {
diff --git a/sound/soc/pxa/pxa2xx-ac97.c b/sound/soc/pxa/pxa2xx-ac97.c
index d9c94d7..dea18ee 100644
--- a/sound/soc/pxa/pxa2xx-ac97.c
+++ b/sound/soc/pxa/pxa2xx-ac97.c
@@ -22,6 +22,7 @@
 #include <mach/hardware.h>
 #include <mach/regs-ac97.h>
 #include <mach/dma.h>
+#include <mach/audio.h>
 
 #include "pxa2xx-pcm.h"
 #include "pxa2xx-ac97.h"
@@ -241,9 +242,13 @@ EXPORT_SYMBOL_GPL(soc_ac97_ops);
 static int __devinit pxa2xx_ac97_dev_probe(struct platform_device *pdev)
 {
 	int i;
+	pxa2xx_audio_ops_t *pdata = pdev->dev.platform_data;
 
-	for (i = 0; i < ARRAY_SIZE(pxa_ac97_dai); i++)
+	for (i = 0; i < ARRAY_SIZE(pxa_ac97_dai); i++) {
 		pxa_ac97_dai[i].dev = &pdev->dev;
+		pxa_ac97_dai[i].ac97_pdata = pdata->codec_pdata
+					[pdev->id < 0 ? 0 : pdev->id];
+	}
 
 	/* 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
-- 
1.6.3.3


[-- Attachment #3: Type: text/plain, Size: 160 bytes --]

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* Re: [PATCH] Allow passing platform_data to devices attached to AC97 bus
  2009-07-21 15:16     ` Takashi Iwai
  2009-07-21 15:40       ` Marek Vasut
  2009-07-21 15:41       ` Marek Vasut
@ 2009-07-21 17:40       ` Marek Vasut
  2009-07-21 18:27         ` Mark Brown
  2009-07-21 17:42       ` Marek Vasut
  2009-07-21 18:18       ` Marek Vasut
  4 siblings, 1 reply; 52+ messages in thread
From: Marek Vasut @ 2009-07-21 17:40 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: alsa-devel, Mark Brown

[-- Attachment #1: Type: text/plain, Size: 1126 bytes --]

Dne Út 21. července 2009 17:16:07 Takashi Iwai napsal(a):
> At Tue, 21 Jul 2009 15:53:23 +0100,
>
> Mark Brown wrote:
> > On Tue, Jul 21, 2009 at 04:50:26PM +0200, Takashi Iwai wrote:
> > > Marek Vasut wrote:
> > > >  	int ret;
> > > > +	pxa2xx_audio_ops_t *pdata = dev->dev.platform_data;
> > >
> > > Use the get function.
> >
> > There's no such function in mainline right now.  However, apropos of
> > something else I submitted a patch adding that to the driver core - it's
> > been merged for 2.6.32 but won't be available in ALSA until after the
> > next merge window.  The function is dev_get_platdata().
>
> Ah, right.  This can be fixed later, then.
>
> > > Also, at the next time, add Russell or linux-arm to Cc so that he
> > > knows at least that a file in arch/arm will be changed.
> >
> > Ideally split things into two separate patches.
>
> Agreed.
>
>
> Takashi

Also, another patch (depends on previous two). This one converts wm97xx driver 
to use supplied platform_data. This will have a follow-up patch that converts 
all the platforms to supply the platform_data properly.

[-- Attachment #2: 0001-Convert-WM97xx-driver-to-use-platform_data.patch --]
[-- Type: text/x-patch, Size: 5046 bytes --]

From 833cb3050e05bc1a2ed3445533d5fe44188364e7 Mon Sep 17 00:00:00 2001
From: Marek Vasut <marek.vasut@gmail.com>
Date: Tue, 21 Jul 2009 18:52:28 +0200
Subject: [PATCH 1/2] Convert WM97xx driver to use platform_data

This patch converts the wm97xx driver to use platform_data supplied by
ac97 bus. Also, this fixes the related wm97xx-battery driver to use
it's platform_data and prepares a structure for touchscreen driver.

Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
---
 drivers/input/touchscreen/wm97xx-core.c |    3 +++
 drivers/power/wm97xx_battery.c          |   13 ++++---------
 include/linux/wm97xx.h                  |   30 ++++++++++++++++++++++++++++++
 include/linux/wm97xx_batt.h             |   26 --------------------------
 4 files changed, 37 insertions(+), 35 deletions(-)
 delete mode 100644 include/linux/wm97xx_batt.h

diff --git a/drivers/input/touchscreen/wm97xx-core.c b/drivers/input/touchscreen/wm97xx-core.c
index 252eb11..e379479 100644
--- a/drivers/input/touchscreen/wm97xx-core.c
+++ b/drivers/input/touchscreen/wm97xx-core.c
@@ -561,6 +561,7 @@ static void wm97xx_ts_input_close(struct input_dev *idev)
 static int wm97xx_probe(struct device *dev)
 {
 	struct wm97xx *wm;
+	struct wm97xx_pdata *pdata = dev->platform_data;
 	int ret = 0, id = 0;
 
 	wm = kzalloc(sizeof(struct wm97xx), GFP_KERNEL);
@@ -658,6 +659,7 @@ static int wm97xx_probe(struct device *dev)
 	}
 	platform_set_drvdata(wm->battery_dev, wm);
 	wm->battery_dev->dev.parent = dev;
+	wm->battery_dev->dev.platform_data = pdata->batt_pdata;
 	ret = platform_device_add(wm->battery_dev);
 	if (ret < 0)
 		goto batt_reg_err;
@@ -671,6 +673,7 @@ static int wm97xx_probe(struct device *dev)
 	}
 	platform_set_drvdata(wm->touch_dev, wm);
 	wm->touch_dev->dev.parent = dev;
+	wm->touch_dev->dev.platform_data = pdata->touch_pdata;
 	ret = platform_device_add(wm->touch_dev);
 	if (ret < 0)
 		goto touch_reg_err;
diff --git a/drivers/power/wm97xx_battery.c b/drivers/power/wm97xx_battery.c
index 8bde921..66af868 100644
--- a/drivers/power/wm97xx_battery.c
+++ b/drivers/power/wm97xx_battery.c
@@ -22,13 +22,12 @@
 #include <linux/spinlock.h>
 #include <linux/interrupt.h>
 #include <linux/gpio.h>
-#include <linux/wm97xx_batt.h>
 
 static DEFINE_MUTEX(bat_lock);
 static struct work_struct bat_work;
 struct mutex work_lock;
 static int bat_status = POWER_SUPPLY_STATUS_UNKNOWN;
-static struct wm97xx_batt_info *pdata;
+static struct wm97xx_batt_pdata *pdata;
 static enum power_supply_property *prop;
 
 static unsigned long wm97xx_read_bat(struct power_supply *bat_ps)
@@ -150,13 +149,15 @@ static int __devinit wm97xx_bat_probe(struct platform_device *dev)
 	int props = 1;	/* POWER_SUPPLY_PROP_PRESENT */
 	int i = 0;
 
+	pdata = dev->dev.platform_data;
+
 	if (dev->id != -1)
 		return -EINVAL;
 
 	mutex_init(&work_lock);
 
 	if (!pdata) {
-		dev_err(&dev->dev, "Please use wm97xx_bat_set_pdata\n");
+		dev_err(&dev->dev, "No platform_data supplied\n");
 		return -EINVAL;
 	}
 
@@ -258,12 +259,6 @@ static void __exit wm97xx_bat_exit(void)
 	platform_driver_unregister(&wm97xx_bat_driver);
 }
 
-void __init wm97xx_bat_set_pdata(struct wm97xx_batt_info *data)
-{
-	pdata = data;
-}
-EXPORT_SYMBOL_GPL(wm97xx_bat_set_pdata);
-
 module_init(wm97xx_bat_init);
 module_exit(wm97xx_bat_exit);
 
diff --git a/include/linux/wm97xx.h b/include/linux/wm97xx.h
index 0c98781..746edfa 100644
--- a/include/linux/wm97xx.h
+++ b/include/linux/wm97xx.h
@@ -293,6 +293,36 @@ struct wm97xx {
 	u16 suspend_mode;               /* PRP in suspend mode */
 };
 
+struct wm97xx_batt_pdata {
+	int	batt_aux;
+	int	temp_aux;
+	int	charge_gpio;
+	int	min_voltage;
+	int	max_voltage;
+	int	batt_div;
+	int	batt_mult;
+	int	temp_div;
+	int	temp_mult;
+	int	batt_tech;
+	char	*batt_name;
+};
+
+struct wm97xx_touch_pdata {
+	int	irq;
+	bool	irq_inverted;
+
+	int	cont_rate;
+	int	pen_int;
+	int	pressure;
+	int	ac97_touch_slot;
+
+};
+
+struct wm97xx_pdata {
+	struct wm97xx_batt_pdata	*batt_pdata;	/* battery data */
+	struct wm97xx_touch_pdata	*touch_pdata;
+};
+
 /*
  * Codec GPIO access (not supported on WM9705)
  * This can be used to set/get codec GPIO and Virtual GPIO status.
diff --git a/include/linux/wm97xx_batt.h b/include/linux/wm97xx_batt.h
deleted file mode 100644
index 9681d1a..0000000
--- a/include/linux/wm97xx_batt.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#ifndef _LINUX_WM97XX_BAT_H
-#define _LINUX_WM97XX_BAT_H
-
-#include <linux/wm97xx.h>
-
-struct wm97xx_batt_info {
-	int	batt_aux;
-	int	temp_aux;
-	int	charge_gpio;
-	int	min_voltage;
-	int	max_voltage;
-	int	batt_div;
-	int	batt_mult;
-	int	temp_div;
-	int	temp_mult;
-	int	batt_tech;
-	char	*batt_name;
-};
-
-#ifdef CONFIG_BATTERY_WM97XX
-void __init wm97xx_bat_set_pdata(struct wm97xx_batt_info *data);
-#else
-static inline void wm97xx_bat_set_pdata(struct wm97xx_batt_info *data) {}
-#endif
-
-#endif
-- 
1.6.3.3


[-- Attachment #3: Type: text/plain, Size: 160 bytes --]

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* Re: [PATCH] Allow passing platform_data to devices attached to AC97 bus
  2009-07-21 15:16     ` Takashi Iwai
                         ` (2 preceding siblings ...)
  2009-07-21 17:40       ` Marek Vasut
@ 2009-07-21 17:42       ` Marek Vasut
  2009-07-21 18:18       ` Marek Vasut
  4 siblings, 0 replies; 52+ messages in thread
From: Marek Vasut @ 2009-07-21 17:42 UTC (permalink / raw)
  To: Takashi Iwai, Robert Jarzmik
  Cc: Eric Miao, alsa-devel, Mark Brown, Russell King - ARM Linux,
	linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 1049 bytes --]

Dne Út 21. července 2009 17:16:07 Takashi Iwai napsal(a):
> At Tue, 21 Jul 2009 15:53:23 +0100,
>
> Mark Brown wrote:
> > On Tue, Jul 21, 2009 at 04:50:26PM +0200, Takashi Iwai wrote:
> > > Marek Vasut wrote:
> > > >  	int ret;
> > > > +	pxa2xx_audio_ops_t *pdata = dev->dev.platform_data;
> > >
> > > Use the get function.
> >
> > There's no such function in mainline right now.  However, apropos of
> > something else I submitted a patch adding that to the driver core - it's
> > been merged for 2.6.32 but won't be available in ALSA until after the
> > next merge window.  The function is dev_get_platdata().
>
> Ah, right.  This can be fixed later, then.
>
> > > Also, at the next time, add Russell or linux-arm to Cc so that he
> > > knows at least that a file in arch/arm will be changed.
> >
> > Ideally split things into two separate patches.
>
> Agreed.
>
>
> Takashi

This is the follow-up patch. This will need ack from maintainers (me as I 
maintain most of the palm devices) and Robert (because of mio).

[-- Attachment #2: 0002-Convert-all-platforms-to-pass-platform_data-to-wm97x.patch --]
[-- Type: text/x-patch, Size: 11915 bytes --]

From 1f94c536e04743b090eb17b8d7298cae55c716a2 Mon Sep 17 00:00:00 2001
From: Marek Vasut <marek.vasut@gmail.com>
Date: Tue, 21 Jul 2009 19:22:13 +0200
Subject: [PATCH 2/2] Convert all platforms to pass platform_data to wm97xx battery

Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
---
 arch/arm/mach-pxa/mioa701.c |    7 ++++++-
 arch/arm/mach-pxa/palmld.c  |   19 ++++++++++---------
 arch/arm/mach-pxa/palmt5.c  |   19 ++++++++++---------
 arch/arm/mach-pxa/palmte2.c |   20 ++++++++++++--------
 arch/arm/mach-pxa/palmtx.c  |   19 ++++++++++---------
 arch/arm/mach-pxa/palmz72.c |   20 ++++++++++++--------
 arch/arm/mach-pxa/treo680.c |    1 -
 7 files changed, 60 insertions(+), 45 deletions(-)

diff --git a/arch/arm/mach-pxa/mioa701.c b/arch/arm/mach-pxa/mioa701.c
index 3cab452..803917d 100644
--- a/arch/arm/mach-pxa/mioa701.c
+++ b/arch/arm/mach-pxa/mioa701.c
@@ -34,7 +34,7 @@
 #include <linux/irq.h>
 #include <linux/pda_power.h>
 #include <linux/power_supply.h>
-#include <linux/wm97xx_batt.h>
+#include <linux/wm97xx.h>
 #include <linux/mtd/physmap.h>
 #include <linux/usb/gpio_vbus.h>
 #include <linux/regulator/max1586.h>
@@ -660,6 +660,10 @@ static struct wm97xx_batt_info mioa701_battery_data = {
 	.batt_name	= "mioa701_battery",
 };
 
+static struct wm97xx_pdata mioa701_wm97xx_pdata = {
+	.batt_pdata	= &mioa701_battery_data,
+};
+
 /*
  * Voltage regulation
  */
@@ -728,6 +732,7 @@ struct i2c_pxa_platform_data i2c_pdata = {
 
 static pxa2xx_audio_ops_t mioa701_ac97_info = {
 	.reset_gpio = 95,
+	.codec_pdata = { &mioa701_wm97xx_pdata, },
 };
 
 /*
diff --git a/arch/arm/mach-pxa/palmld.c b/arch/arm/mach-pxa/palmld.c
index 1ad029d..bcf5b46 100644
--- a/arch/arm/mach-pxa/palmld.c
+++ b/arch/arm/mach-pxa/palmld.c
@@ -22,7 +22,7 @@
 #include <linux/pda_power.h>
 #include <linux/pwm_backlight.h>
 #include <linux/gpio.h>
-#include <linux/wm97xx_batt.h>
+#include <linux/wm97xx.h>
 #include <linux/power_supply.h>
 #include <linux/sysdev.h>
 #include <linux/mtd/mtd.h>
@@ -406,9 +406,9 @@ static struct platform_device power_supply = {
 };
 
 /******************************************************************************
- * WM97xx battery
+ * WM97xx audio, battery
  ******************************************************************************/
-static struct wm97xx_batt_info wm97xx_batt_pdata = {
+static struct wm97xx_batt_pdata palmld_batt_pdata = {
 	.batt_aux	= WM97XX_AUX_ID3,
 	.temp_aux	= WM97XX_AUX_ID2,
 	.charge_gpio	= -1,
@@ -422,15 +422,17 @@ static struct wm97xx_batt_info wm97xx_batt_pdata = {
 	.batt_name	= "main-batt",
 };
 
-/******************************************************************************
- * aSoC audio
- ******************************************************************************/
-static struct palm27x_asoc_info palmld_asoc_pdata = {
-	.jack_gpio	= GPIO_NR_PALMLD_EARPHONE_DETECT,
+static struct wm97xx_pdata palmld_wm97xx_pdata = {
+	.batt_pdata	= &palmld_batt_pdata,
 };
 
 static pxa2xx_audio_ops_t palmld_ac97_pdata = {
 	.reset_gpio	= 95,
+	.codec_pdata	= { &palmld_wm97xx_pdata, },
+};
+
+static struct palm27x_asoc_info palmld_asoc_pdata = {
+	.jack_gpio	= GPIO_NR_PALMLD_EARPHONE_DETECT,
 };
 
 static struct platform_device palmld_asoc = {
@@ -536,7 +538,6 @@ static void __init palmld_init(void)
 	pxa_set_ac97_info(&palmld_ac97_pdata);
 	pxa_set_ficp_info(&palmld_ficp_platform_data);
 	pxa_set_keypad_info(&palmld_keypad_platform_data);
-	wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
 
 	platform_add_devices(devices, ARRAY_SIZE(devices));
 }
diff --git a/arch/arm/mach-pxa/palmt5.c b/arch/arm/mach-pxa/palmt5.c
index 2dd7ce2..3e8b21d 100644
--- a/arch/arm/mach-pxa/palmt5.c
+++ b/arch/arm/mach-pxa/palmt5.c
@@ -24,7 +24,7 @@
 #include <linux/pda_power.h>
 #include <linux/pwm_backlight.h>
 #include <linux/gpio.h>
-#include <linux/wm97xx_batt.h>
+#include <linux/wm97xx.h>
 #include <linux/power_supply.h>
 #include <linux/usb/gpio_vbus.h>
 
@@ -317,9 +317,9 @@ static struct platform_device power_supply = {
 };
 
 /******************************************************************************
- * WM97xx battery
+ * WM97xx audio, battery
  ******************************************************************************/
-static struct wm97xx_batt_info wm97xx_batt_pdata = {
+static struct wm97xx_batt_pdata palmt5_batt_pdata = {
 	.batt_aux	= WM97XX_AUX_ID3,
 	.temp_aux	= WM97XX_AUX_ID2,
 	.charge_gpio	= -1,
@@ -333,15 +333,17 @@ static struct wm97xx_batt_info wm97xx_batt_pdata = {
 	.batt_name	= "main-batt",
 };
 
-/******************************************************************************
- * aSoC audio
- ******************************************************************************/
-static struct palm27x_asoc_info palmt5_asoc_pdata = {
-	.jack_gpio	= GPIO_NR_PALMT5_EARPHONE_DETECT,
+static struct wm97xx_pdata palmt5_wm97xx_pdata = {
+	.batt_pdata	= &palmt5_batt_pdata,
 };
 
 static pxa2xx_audio_ops_t palmt5_ac97_pdata = {
 	.reset_gpio	= 95,
+	.codec_pdata	= { &palmt5_wm97xx_pdata, },
+};
+
+static struct palm27x_asoc_info palmt5_asoc_pdata = {
+	.jack_gpio	= GPIO_NR_PALMT5_EARPHONE_DETECT,
 };
 
 static struct platform_device palmt5_asoc = {
@@ -426,7 +428,6 @@ static void __init palmt5_init(void)
 	pxa_set_ac97_info(&palmt5_ac97_pdata);
 	pxa_set_ficp_info(&palmt5_ficp_platform_data);
 	pxa_set_keypad_info(&palmt5_keypad_platform_data);
-	wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
 
 	platform_add_devices(devices, ARRAY_SIZE(devices));
 }
diff --git a/arch/arm/mach-pxa/palmte2.c b/arch/arm/mach-pxa/palmte2.c
index 277c406..21c241b 100644
--- a/arch/arm/mach-pxa/palmte2.c
+++ b/arch/arm/mach-pxa/palmte2.c
@@ -23,7 +23,7 @@
 #include <linux/pda_power.h>
 #include <linux/pwm_backlight.h>
 #include <linux/gpio.h>
-#include <linux/wm97xx_batt.h>
+#include <linux/wm97xx.h>
 #include <linux/power_supply.h>
 #include <linux/usb/gpio_vbus.h>
 
@@ -290,9 +290,9 @@ static struct platform_device power_supply = {
 };
 
 /******************************************************************************
- * WM97xx battery
+ * WM97xx audio, battery
  ******************************************************************************/
-static struct wm97xx_batt_info wm97xx_batt_pdata = {
+static struct wm97xx_batt_info palmte2_batt_pdata = {
 	.batt_aux	= WM97XX_AUX_ID3,
 	.temp_aux	= WM97XX_AUX_ID2,
 	.charge_gpio	= -1,
@@ -306,9 +306,14 @@ static struct wm97xx_batt_info wm97xx_batt_pdata = {
 	.batt_name	= "main-batt",
 };
 
-/******************************************************************************
- * aSoC audio
- ******************************************************************************/
+static struct wm97xx_pdata palmte2_wm97xx_pdata = {
+	.batt_pdata	= &palmte2_batt_pdata,
+};
+
+static pxa2xx_audio_ops_t palmte2_ac97_pdata = {
+	.codec_pdata	= { &palmte2_wm97xx_pdata, },
+};
+
 static struct palm27x_asoc_info palmte2_asoc_pdata = {
 	.jack_gpio	= GPIO_NR_PALMTE2_EARPHONE_DETECT,
 };
@@ -376,9 +381,8 @@ static void __init palmte2_init(void)
 	set_pxa_fb_info(&palmte2_lcd_screen);
 	pxa_set_mci_info(&palmte2_mci_platform_data);
 	palmte2_udc_init();
-	pxa_set_ac97_info(NULL);
+	pxa_set_ac97_info(&palmte2_ac97_pdata);
 	pxa_set_ficp_info(&palmte2_ficp_platform_data);
-	wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
 
 	platform_add_devices(devices, ARRAY_SIZE(devices));
 }
diff --git a/arch/arm/mach-pxa/palmtx.c b/arch/arm/mach-pxa/palmtx.c
index f1e248c..554b3da 100644
--- a/arch/arm/mach-pxa/palmtx.c
+++ b/arch/arm/mach-pxa/palmtx.c
@@ -25,7 +25,7 @@
 #include <linux/pda_power.h>
 #include <linux/pwm_backlight.h>
 #include <linux/gpio.h>
-#include <linux/wm97xx_batt.h>
+#include <linux/wm97xx.h>
 #include <linux/power_supply.h>
 #include <linux/usb/gpio_vbus.h>
 #include <linux/mtd/nand.h>
@@ -340,9 +340,9 @@ static struct platform_device power_supply = {
 };
 
 /******************************************************************************
- * WM97xx battery
+ * WM97xx audio, battery
  ******************************************************************************/
-static struct wm97xx_batt_info wm97xx_batt_pdata = {
+static struct wm97xx_batt_pdata palmtx_batt_pdata = {
 	.batt_aux	= WM97XX_AUX_ID3,
 	.temp_aux	= WM97XX_AUX_ID2,
 	.charge_gpio	= -1,
@@ -356,15 +356,17 @@ static struct wm97xx_batt_info wm97xx_batt_pdata = {
 	.batt_name	= "main-batt",
 };
 
-/******************************************************************************
- * aSoC audio
- ******************************************************************************/
-static struct palm27x_asoc_info palmtx_asoc_pdata = {
-	.jack_gpio	= GPIO_NR_PALMTX_EARPHONE_DETECT,
+static struct wm97xx_pdata palmtx_wm97xx_pdata = {
+	.batt_pdata	= &palmtx_batt_pdata,
 };
 
 static pxa2xx_audio_ops_t palmtx_ac97_pdata = {
 	.reset_gpio	= 95,
+	.codec_pdata	= { &palmtx_wm97xx_pdata, },
+};
+
+static struct palm27x_asoc_info palmtx_asoc_pdata = {
+	.jack_gpio	= GPIO_NR_PALMTX_EARPHONE_DETECT,
 };
 
 static struct platform_device palmtx_asoc = {
@@ -538,7 +540,6 @@ static void __init palmtx_init(void)
 	pxa_set_ac97_info(&palmtx_ac97_pdata);
 	pxa_set_ficp_info(&palmtx_ficp_platform_data);
 	pxa_set_keypad_info(&palmtx_keypad_platform_data);
-	wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
 
 	platform_add_devices(devices, ARRAY_SIZE(devices));
 }
diff --git a/arch/arm/mach-pxa/palmz72.c b/arch/arm/mach-pxa/palmz72.c
index c2bf493..b769447 100644
--- a/arch/arm/mach-pxa/palmz72.c
+++ b/arch/arm/mach-pxa/palmz72.c
@@ -27,7 +27,7 @@
 #include <linux/pda_power.h>
 #include <linux/pwm_backlight.h>
 #include <linux/gpio.h>
-#include <linux/wm97xx_batt.h>
+#include <linux/wm97xx.h>
 #include <linux/power_supply.h>
 #include <linux/usb/gpio_vbus.h>
 
@@ -343,9 +343,9 @@ static struct platform_device power_supply = {
 };
 
 /******************************************************************************
- * WM97xx battery
+ * WM97xx audio, battery
  ******************************************************************************/
-static struct wm97xx_batt_info wm97xx_batt_pdata = {
+static struct wm97xx_batt_info palmz72_batt_pdata = {
 	.batt_aux	= WM97XX_AUX_ID3,
 	.temp_aux	= WM97XX_AUX_ID2,
 	.charge_gpio	= -1,
@@ -359,9 +359,14 @@ static struct wm97xx_batt_info wm97xx_batt_pdata = {
 	.batt_name	= "main-batt",
 };
 
-/******************************************************************************
- * aSoC audio
- ******************************************************************************/
+static struct wm97xx_pdata palmz72_wm97xx_pdata = {
+	.batt_pdata	= &palmz72_batt_pdata,
+};
+
+static pxa2xx_audio_ops_t palmz72_ac97_pdata = {
+	.codec_pdata	= { &palmz72_wm97xx_pdata, },
+};
+
 static struct platform_device palmz72_asoc = {
 	.name = "palm27x-asoc",
 	.id   = -1,
@@ -494,10 +499,9 @@ static void __init palmz72_init(void)
 	set_pxa_fb_info(&palmz72_lcd_screen);
 	pxa_set_mci_info(&palmz72_mci_platform_data);
 	palmz72_udc_init();
-	pxa_set_ac97_info(NULL);
+	pxa_set_ac97_info(&palmz72_ac97_pdata);
 	pxa_set_ficp_info(&palmz72_ficp_platform_data);
 	pxa_set_keypad_info(&palmz72_keypad_platform_data);
-	wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
 
 	platform_add_devices(devices, ARRAY_SIZE(devices));
 }
diff --git a/arch/arm/mach-pxa/treo680.c b/arch/arm/mach-pxa/treo680.c
index f537265..f9acb12 100644
--- a/arch/arm/mach-pxa/treo680.c
+++ b/arch/arm/mach-pxa/treo680.c
@@ -19,7 +19,6 @@
 #include <linux/pda_power.h>
 #include <linux/pwm_backlight.h>
 #include <linux/gpio.h>
-#include <linux/wm97xx_batt.h>
 #include <linux/power_supply.h>
 #include <linux/sysdev.h>
 #include <linux/w1-gpio.h>
-- 
1.6.3.3


[-- Attachment #3: Type: text/plain, Size: 160 bytes --]

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* Re: [PATCH] Allow passing platform_data to devices attached to AC97 bus
  2009-07-21 15:16     ` Takashi Iwai
                         ` (3 preceding siblings ...)
  2009-07-21 17:42       ` Marek Vasut
@ 2009-07-21 18:18       ` Marek Vasut
  4 siblings, 0 replies; 52+ messages in thread
From: Marek Vasut @ 2009-07-21 18:18 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: alsa-devel, Mark Brown

[-- Attachment #1: Type: text/plain, Size: 1002 bytes --]

Dne Út 21. července 2009 17:16:07 Takashi Iwai napsal(a):
> At Tue, 21 Jul 2009 15:53:23 +0100,
>
> Mark Brown wrote:
> > On Tue, Jul 21, 2009 at 04:50:26PM +0200, Takashi Iwai wrote:
> > > Marek Vasut wrote:
> > > >  	int ret;
> > > > +	pxa2xx_audio_ops_t *pdata = dev->dev.platform_data;
> > >
> > > Use the get function.
> >
> > There's no such function in mainline right now.  However, apropos of
> > something else I submitted a patch adding that to the driver core - it's
> > been merged for 2.6.32 but won't be available in ALSA until after the
> > next merge window.  The function is dev_get_platdata().
>
> Ah, right.  This can be fixed later, then.
>
> > > Also, at the next time, add Russell or linux-arm to Cc so that he
> > > knows at least that a file in arch/arm will be changed.
> >
> > Ideally split things into two separate patches.
>
> Agreed.
>
>
> Takashi

And one more patch to convert the mainstone accelerated touch driver to use 
platform_data.

[-- Attachment #2: 0001-Convert-the-mainstone-accelerated-touch-driver-to-us.patch --]
[-- Type: text/x-patch, Size: 6737 bytes --]

From c75defb486f199d4bc9ead3245032ca2c0d298c9 Mon Sep 17 00:00:00 2001
From: Marek Vasut <marek.vasut@gmail.com>
Date: Tue, 21 Jul 2009 20:12:23 +0200
Subject: [PATCH] Convert the mainstone accelerated touch driver to use platform_data

Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
---
 arch/arm/mach-pxa/mainstone.c                |   10 ++++++++++
 arch/arm/mach-pxa/palmld.c                   |    9 ++++++++-
 arch/arm/mach-pxa/palmt5.c                   |    9 ++++++++-
 arch/arm/mach-pxa/palmtx.c                   |    9 ++++++++-
 drivers/input/touchscreen/mainstone-wm97xx.c |   26 ++++++++++++++++----------
 include/linux/wm97xx.h                       |    3 ++-
 6 files changed, 52 insertions(+), 14 deletions(-)

diff --git a/arch/arm/mach-pxa/mainstone.c b/arch/arm/mach-pxa/mainstone.c
index a4eeae3..b116927 100644
--- a/arch/arm/mach-pxa/mainstone.c
+++ b/arch/arm/mach-pxa/mainstone.c
@@ -27,6 +27,7 @@
 #include <linux/gpio_keys.h>
 #include <linux/pwm_backlight.h>
 #include <linux/smc91x.h>
+#include <linux/wm97xx.h>
 
 #include <asm/types.h>
 #include <asm/setup.h>
@@ -284,11 +285,20 @@ static void mst_audio_resume(void *priv)
 	MST_MSCWR2 &= mst_audio_suspend_mask | ~MST_MSCWR2_AC97_SPKROFF;
 }
 
+static struct wm97xx_touch_pdata mainstone_touch_pdata = {
+	.irq_gpio	= 4,
+};
+
+static struct wm97xx_pdata mainstone_wm97xx_pdata = {
+	.touch_pdata	= &palmtx_touch_pdata,
+};
+
 static pxa2xx_audio_ops_t mst_audio_ops = {
 	.startup	= mst_audio_startup,
 	.shutdown	= mst_audio_shutdown,
 	.suspend	= mst_audio_suspend,
 	.resume		= mst_audio_resume,
+	.codec_pdata	= { &mainstone_wm97xx_pdata, },
 };
 
 static struct resource flash_resources[] = {
diff --git a/arch/arm/mach-pxa/palmld.c b/arch/arm/mach-pxa/palmld.c
index bcf5b46..e7af187 100644
--- a/arch/arm/mach-pxa/palmld.c
+++ b/arch/arm/mach-pxa/palmld.c
@@ -406,7 +406,7 @@ static struct platform_device power_supply = {
 };
 
 /******************************************************************************
- * WM97xx audio, battery
+ * WM97xx audio, touchscreen, battery
  ******************************************************************************/
 static struct wm97xx_batt_pdata palmld_batt_pdata = {
 	.batt_aux	= WM97XX_AUX_ID3,
@@ -422,8 +422,15 @@ static struct wm97xx_batt_pdata palmld_batt_pdata = {
 	.batt_name	= "main-batt",
 };
 
+static struct wm97xx_touch_pdata palmld_touch_pdata = {
+	.irq_gpio	= GPIO_NR_PALMLD_WM9712_IRQ,
+	.pen_int	= 1,
+	.variant	= WM97xx_WM1613,
+};
+
 static struct wm97xx_pdata palmld_wm97xx_pdata = {
 	.batt_pdata	= &palmld_batt_pdata,
+	.touch_pdata	= &palmld_touch_pdata,
 };
 
 static pxa2xx_audio_ops_t palmld_ac97_pdata = {
diff --git a/arch/arm/mach-pxa/palmt5.c b/arch/arm/mach-pxa/palmt5.c
index 3e8b21d..3863cb9 100644
--- a/arch/arm/mach-pxa/palmt5.c
+++ b/arch/arm/mach-pxa/palmt5.c
@@ -317,7 +317,7 @@ static struct platform_device power_supply = {
 };
 
 /******************************************************************************
- * WM97xx audio, battery
+ * WM97xx audio, touchscreen, battery
  ******************************************************************************/
 static struct wm97xx_batt_pdata palmt5_batt_pdata = {
 	.batt_aux	= WM97XX_AUX_ID3,
@@ -333,8 +333,15 @@ static struct wm97xx_batt_pdata palmt5_batt_pdata = {
 	.batt_name	= "main-batt",
 };
 
+static struct wm97xx_touch_pdata palmt5_touch_pdata = {
+	.irq_gpio	= GPIO_NR_PALMT5_WM9712_IRQ,
+	.pen_int	= 1,
+	.variant	= WM97xx_WM1613,
+};
+
 static struct wm97xx_pdata palmt5_wm97xx_pdata = {
 	.batt_pdata	= &palmt5_batt_pdata,
+	.touch_pdata	= &palmt5_touch_pdata,
 };
 
 static pxa2xx_audio_ops_t palmt5_ac97_pdata = {
diff --git a/arch/arm/mach-pxa/palmtx.c b/arch/arm/mach-pxa/palmtx.c
index 554b3da..9009bd6 100644
--- a/arch/arm/mach-pxa/palmtx.c
+++ b/arch/arm/mach-pxa/palmtx.c
@@ -340,7 +340,7 @@ static struct platform_device power_supply = {
 };
 
 /******************************************************************************
- * WM97xx audio, battery
+ * WM97xx audio, touchscreen, battery
  ******************************************************************************/
 static struct wm97xx_batt_pdata palmtx_batt_pdata = {
 	.batt_aux	= WM97XX_AUX_ID3,
@@ -356,8 +356,15 @@ static struct wm97xx_batt_pdata palmtx_batt_pdata = {
 	.batt_name	= "main-batt",
 };
 
+static struct wm97xx_touch_pdata palmtx_touch_pdata = {
+	.irq_gpio	= GPIO_NR_PALMTX_WM9712_IRQ,
+	.pen_int	= 1,
+	.variant	= WM97xx_WM1613,
+};
+
 static struct wm97xx_pdata palmtx_wm97xx_pdata = {
 	.batt_pdata	= &palmtx_batt_pdata,
+	.touch_pdata	= &palmtx_touch_pdata,
 };
 
 static pxa2xx_audio_ops_t palmtx_ac97_pdata = {
diff --git a/drivers/input/touchscreen/mainstone-wm97xx.c b/drivers/input/touchscreen/mainstone-wm97xx.c
index e000ab3..96bedd3 100644
--- a/drivers/input/touchscreen/mainstone-wm97xx.c
+++ b/drivers/input/touchscreen/mainstone-wm97xx.c
@@ -194,16 +194,6 @@ static int wm97xx_acc_startup(struct wm97xx *wm)
 		 "mainstone accelerated touchscreen driver, %d samples/sec\n",
 		 cinfo[sp_idx].speed);
 
-	/* IRQ driven touchscreen is used on Palm hardware */
-	if (machine_is_palmt5() || machine_is_palmtx() || machine_is_palmld()) {
-		pen_int = 1;
-		irq = 27;
-		/* There is some obscure mutant of WM9712 interbred with WM9713
-		 * used on Palm HW */
-		wm->variant = WM97xx_WM1613;
-	} else if (machine_is_mainstone() && pen_int)
-		irq = 4;
-
 	if (irq) {
 		ret = gpio_request(irq, "Touchscreen IRQ");
 		if (ret)
@@ -280,6 +270,22 @@ static struct wm97xx_mach_ops mainstone_mach_ops = {
 static int mainstone_wm97xx_probe(struct platform_device *pdev)
 {
 	struct wm97xx *wm = platform_get_drvdata(pdev);
+	struct wm97xx_touch_pdata *pdata = pdev->dev.platform_data;
+
+	if (pdata) {
+		if (pdata->irq_gpio)
+			irq = pdata->irq_gpio;
+		if (pdata->cont_rate)
+			cont_rate = pdata->cont_rate;
+		if (pdata->pen_int)
+			pen_int = pdata->pen_int;
+		if (pdata->pressure)
+			pressure = pdata->pressure;
+		if (pdata->ac97_touch_slot)
+			ac97_touch_slot = pdata->ac97_touch_slot;
+		if (pdata->variant)
+			wm->variant = pdata->variant;
+	}
 
 	return wm97xx_register_mach_ops(wm, &mainstone_mach_ops);
 }
diff --git a/include/linux/wm97xx.h b/include/linux/wm97xx.h
index 746edfa..0c71c63 100644
--- a/include/linux/wm97xx.h
+++ b/include/linux/wm97xx.h
@@ -309,7 +309,8 @@ struct wm97xx_batt_pdata {
 
 struct wm97xx_touch_pdata {
 	int	irq;
-	bool	irq_inverted;
+	int	irq_gpio;	/* this is for mainstone and palm */
+	int	variant;
 
 	int	cont_rate;
 	int	pen_int;
-- 
1.6.3.3


[-- Attachment #3: Type: text/plain, Size: 160 bytes --]

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* Re: [PATCH] Allow passing platform_data to devices attached to AC97 bus
  2009-07-21 17:40       ` Marek Vasut
@ 2009-07-21 18:27         ` Mark Brown
  2009-07-21 18:38           ` Mark Brown
  0 siblings, 1 reply; 52+ messages in thread
From: Mark Brown @ 2009-07-21 18:27 UTC (permalink / raw)
  To: Marek Vasut; +Cc: Takashi Iwai, alsa-devel

On Tue, Jul 21, 2009 at 07:40:21PM +0200, Marek Vasut wrote:
> Dne ??t 21. ??ervence 2009 17:16:07 Takashi Iwai napsal(a):

> +struct wm97xx_touch_pdata {
> +	int	irq;
> +	bool	irq_inverted;

The IRQ is not touch-specific, it should be part of the main platform
data.  I can't see anything in the patch actually using this or any
other part of the touch platform data, though...

> +	int	cont_rate;
> +	int	pen_int;
> +	int	pressure;
> +	int	ac97_touch_slot;
> +
> +};

As I said previously this should be able to completely replace the
existing touch configuration.  That means the entire mach_ops structure,
plus all the stuff that can be configured via module options (including
the new option for the WM1616).

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH] Allow passing platform_data to devices attached to AC97 bus
  2009-07-21 15:40       ` Marek Vasut
@ 2009-07-21 18:30         ` Mark Brown
  2009-07-21 19:51           ` Marek Vasut
                             ` (2 more replies)
  0 siblings, 3 replies; 52+ messages in thread
From: Mark Brown @ 2009-07-21 18:30 UTC (permalink / raw)
  To: Marek Vasut
  Cc: Takashi Iwai, Russell King - ARM Linux, alsa-devel, Eric Miao,
	linux-arm-kernel

On Tue, Jul 21, 2009 at 05:40:01PM +0200, Marek Vasut wrote:
> Dne ??t 21. ??ervence 2009 17:16:07 Takashi Iwai napsal(a):

> +/* AC97 platform_data adding function */
> +inline void snd_ac97_dev_add_pdata(struct snd_ac97 *ac97, void *data);
> +

I think Takashi asked for this to be done as an inline?  I tend to agree
with him.

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH] Allow passing platform_data to devices attached to AC97 bus
  2009-07-21 18:27         ` Mark Brown
@ 2009-07-21 18:38           ` Mark Brown
  0 siblings, 0 replies; 52+ messages in thread
From: Mark Brown @ 2009-07-21 18:38 UTC (permalink / raw)
  To: Marek Vasut; +Cc: Takashi Iwai, alsa-devel

On Tue, Jul 21, 2009 at 07:27:54PM +0100, Mark Brown wrote:
> On Tue, Jul 21, 2009 at 07:40:21PM +0200, Marek Vasut wrote:
> > Dne ??t 21. ??ervence 2009 17:16:07 Takashi Iwai napsal(a):

> > +struct wm97xx_touch_pdata {
> > +	int	irq;
> > +	bool	irq_inverted;

> The IRQ is not touch-specific, it should be part of the main platform
> data.  I can't see anything in the patch actually using this or any
> other part of the touch platform data, though...

Also, please do try to remember to post patches to the appropriate
subsystems - this is a patch to the input and power subsystems so you
need to run the patch past their maintainers.

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH] Allow passing platform_data to devices attached to AC97 bus
  2009-07-21 18:30         ` Mark Brown
@ 2009-07-21 19:51           ` Marek Vasut
  2009-07-22 10:40             ` Mark Brown
  2009-07-21 20:24           ` [PATCH] " Marek Vasut
  2009-07-21 20:25           ` [PATCH] Allow passing platform_data to devices attached to AC97 bus Marek Vasut
  2 siblings, 1 reply; 52+ messages in thread
From: Marek Vasut @ 2009-07-21 19:51 UTC (permalink / raw)
  To: Mark Brown
  Cc: Takashi Iwai, Russell King - ARM Linux, alsa-devel, Eric Miao,
	linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 487 bytes --]

Dne Út 21. července 2009 20:30:56 Mark Brown napsal(a):
> On Tue, Jul 21, 2009 at 05:40:01PM +0200, Marek Vasut wrote:
> > Dne ??t 21. ??ervence 2009 17:16:07 Takashi Iwai napsal(a):
> >
> > +/* AC97 platform_data adding function */
> > +inline void snd_ac97_dev_add_pdata(struct snd_ac97 *ac97, void *data);
> > +
>
> I think Takashi asked for this to be done as an inline?  I tend to agree
> with him.

Ok, this one should be better then? Mark, thanks for guiding me :-)

[-- Attachment #2: 0001-Allow-passing-platform_data-to-devices-attached-to-A.patch --]
[-- Type: text/x-patch, Size: 2088 bytes --]

From 082f09b9f3c1bbf3240610dc89baba33d47787b7 Mon Sep 17 00:00:00 2001
From: Marek Vasut <marek.vasut@gmail.com>
Date: Tue, 21 Jul 2009 16:22:29 +0200
Subject: [PATCH] Allow passing platform_data to devices attached to AC97 bus

This patch allows passing platform_data to devices attached to AC97 bus
(like touchscreens, battery measurement chips ...).

Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
---
 include/sound/ac97_codec.h |    6 ++++++
 include/sound/soc-dai.h    |    1 +
 sound/soc/soc-core.c       |    5 ++++-
 3 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/include/sound/ac97_codec.h b/include/sound/ac97_codec.h
index 251fc1c..702f90d 100644
--- a/include/sound/ac97_codec.h
+++ b/include/sound/ac97_codec.h
@@ -642,4 +642,10 @@ int snd_ac97_pcm_double_rate_rules(struct snd_pcm_runtime *runtime);
 /* ad hoc AC97 device driver access */
 extern struct bus_type ac97_bus_type;
 
+/* AC97 platform_data adding function */
+inline void snd_ac97_dev_add_pdata(struct snd_ac97 *ac97, void *data)
+{
+	ac97->dev.platform_data = data;
+}
+
 #endif /* __SOUND_AC97_CODEC_H */
diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index 352d7ee..0d65a03 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -179,6 +179,7 @@ struct snd_soc_dai {
 	int ac97_control;
 
 	struct device *dev;
+	void *ac97_pdata;	/* platform_data for the ac97 codec */
 
 	/* DAI callbacks */
 	int (*probe)(struct platform_device *pdev,
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 1d70829..0b12fe5 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1381,8 +1381,11 @@ int snd_soc_init_card(struct snd_soc_device *socdev)
 				continue;
 			}
 		}
-		if (card->dai_link[i].codec_dai->ac97_control)
+		if (card->dai_link[i].codec_dai->ac97_control) {
 			ac97 = 1;
+			codec->ac97->dev.platform_data =
+				card->dai_link[i].cpu_dai->ac97_pdata;
+		}
 	}
 	snprintf(codec->card->shortname, sizeof(codec->card->shortname),
 		 "%s",  card->name);
-- 
1.6.3.3


[-- Attachment #3: Type: text/plain, Size: 160 bytes --]

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* Re: [PATCH] Allow passing platform_data to devices attached to AC97 bus
  2009-07-21 18:30         ` Mark Brown
  2009-07-21 19:51           ` Marek Vasut
@ 2009-07-21 20:24           ` Marek Vasut
  2009-07-21 20:59             ` Takashi Iwai
  2009-07-21 20:25           ` [PATCH] Allow passing platform_data to devices attached to AC97 bus Marek Vasut
  2 siblings, 1 reply; 52+ messages in thread
From: Marek Vasut @ 2009-07-21 20:24 UTC (permalink / raw)
  To: Mark Brown
  Cc: Takashi Iwai, Russell King - ARM Linux, alsa-devel, Eric Miao,
	linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 498 bytes --]

Dne Út 21. července 2009 20:30:56 Mark Brown napsal(a):
> On Tue, Jul 21, 2009 at 05:40:01PM +0200, Marek Vasut wrote:
> > Dne ??t 21. ??ervence 2009 17:16:07 Takashi Iwai napsal(a):
> >
> > +/* AC97 platform_data adding function */
> > +inline void snd_ac97_dev_add_pdata(struct snd_ac97 *ac97, void *data);
> > +
>
> I think Takashi asked for this to be done as an inline?  I tend to agree
> with him.
Ok, this one fixes one more issue. Should be fine now. Please consider applying.

[-- Attachment #2: 0001-Allow-passing-platform_data-to-devices-attached-to-A.patch --]
[-- Type: text/x-patch, Size: 2099 bytes --]

From 082f09b9f3c1bbf3240610dc89baba33d47787b7 Mon Sep 17 00:00:00 2001
From: Marek Vasut <marek.vasut@gmail.com>
Date: Tue, 21 Jul 2009 16:22:29 +0200
Subject: [PATCH 1/5] Allow passing platform_data to devices attached to AC97 bus

This patch allows passing platform_data to devices attached to AC97 bus
(like touchscreens, battery measurement chips ...).

Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
---
 include/sound/ac97_codec.h |    6 ++++++
 include/sound/soc-dai.h    |    1 +
 sound/soc/soc-core.c       |    5 ++++-
 3 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/include/sound/ac97_codec.h b/include/sound/ac97_codec.h
index 251fc1c..702f90d 100644
--- a/include/sound/ac97_codec.h
+++ b/include/sound/ac97_codec.h
@@ -642,4 +642,10 @@ int snd_ac97_pcm_double_rate_rules(struct snd_pcm_runtime *runtime);
 /* ad hoc AC97 device driver access */
 extern struct bus_type ac97_bus_type;
 
+/* AC97 platform_data adding function */
+static inline void snd_ac97_dev_add_pdata(struct snd_ac97 *ac97, void *data)
+{
+	ac97->dev.platform_data = data;
+}
+
 #endif /* __SOUND_AC97_CODEC_H */
diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index 352d7ee..0d65a03 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -179,6 +179,7 @@ struct snd_soc_dai {
 	int ac97_control;
 
 	struct device *dev;
+	void *ac97_pdata;	/* platform_data for the ac97 codec */
 
 	/* DAI callbacks */
 	int (*probe)(struct platform_device *pdev,
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 1d70829..0b12fe5 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1381,8 +1381,11 @@ int snd_soc_init_card(struct snd_soc_device *socdev)
 				continue;
 			}
 		}
-		if (card->dai_link[i].codec_dai->ac97_control)
+		if (card->dai_link[i].codec_dai->ac97_control) {
 			ac97 = 1;
+			codec->ac97->dev.platform_data =
+				card->dai_link[i].cpu_dai->ac97_pdata;
+		}
 	}
 	snprintf(codec->card->shortname, sizeof(codec->card->shortname),
 		 "%s",  card->name);
-- 
1.6.3.3


[-- Attachment #3: Type: text/plain, Size: 160 bytes --]

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* Re: [PATCH] Allow passing platform_data to devices attached to AC97 bus
  2009-07-21 18:30         ` Mark Brown
  2009-07-21 19:51           ` Marek Vasut
  2009-07-21 20:24           ` [PATCH] " Marek Vasut
@ 2009-07-21 20:25           ` Marek Vasut
  2 siblings, 0 replies; 52+ messages in thread
From: Marek Vasut @ 2009-07-21 20:25 UTC (permalink / raw)
  To: Mark Brown
  Cc: Takashi Iwai, Russell King - ARM Linux, alsa-devel, Eric Miao,
	linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 472 bytes --]

Dne Út 21. července 2009 20:30:56 Mark Brown napsal(a):
> On Tue, Jul 21, 2009 at 05:40:01PM +0200, Marek Vasut wrote:
> > Dne ??t 21. ??ervence 2009 17:16:07 Takashi Iwai napsal(a):
> >
> > +/* AC97 platform_data adding function */
> > +inline void snd_ac97_dev_add_pdata(struct snd_ac97 *ac97, void *data);
> > +
>
> I think Takashi asked for this to be done as an inline?  I tend to agree
> with him.
And here's that pxa-ac97 patch, just for completeness.

[-- Attachment #2: 0002-Allow-passing-platform_data-for-pxa2xx-ac97.patch --]
[-- Type: text/x-patch, Size: 3731 bytes --]

From 8f022739a263ffa47623385cc176355b93b660e8 Mon Sep 17 00:00:00 2001
From: Marek Vasut <marek.vasut@gmail.com>
Date: Tue, 21 Jul 2009 16:22:29 +0200
Subject: [PATCH 2/5] 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>
---
 arch/arm/mach-pxa/include/mach/audio.h |    3 +++
 include/sound/ac97_codec.h             |    3 +++
 sound/arm/pxa2xx-ac97.c                |    3 +++
 sound/soc/pxa/pxa2xx-ac97.c            |    7 ++++++-
 4 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-pxa/include/mach/audio.h b/arch/arm/mach-pxa/include/mach/audio.h
index 16eb025..a3449e3 100644
--- a/arch/arm/mach-pxa/include/mach/audio.h
+++ b/arch/arm/mach-pxa/include/mach/audio.h
@@ -3,10 +3,12 @@
 
 #include <sound/core.h>
 #include <sound/pcm.h>
+#include <sound/ac97_codec.h>
 
 /*
  * @reset_gpio: AC97 reset gpio (normally gpio113 or gpio95)
  *              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
  * bug prevents correct operation of the reset line. If not specified,
@@ -20,6 +22,7 @@ typedef struct {
 	void (*resume)(void *);
 	void *priv;
 	int reset_gpio;
+	void *codec_pdata[AC97_BUS_MAX_DEVICES];
 } pxa2xx_audio_ops_t;
 
 extern void pxa_set_ac97_info(pxa2xx_audio_ops_t *ops);
diff --git a/include/sound/ac97_codec.h b/include/sound/ac97_codec.h
index 702f90d..52fc1f9 100644
--- a/include/sound/ac97_codec.h
+++ b/include/sound/ac97_codec.h
@@ -32,6 +32,9 @@
 #include "control.h"
 #include "info.h"
 
+/* maximum number of devices on the AC97 bus */
+#define	AC97_BUS_MAX_DEVICES	4
+
 /*
  *  AC'97 codec registers
  */
diff --git a/sound/arm/pxa2xx-ac97.c b/sound/arm/pxa2xx-ac97.c
index c570ebd..cfab74e 100644
--- a/sound/arm/pxa2xx-ac97.c
+++ b/sound/arm/pxa2xx-ac97.c
@@ -170,6 +170,8 @@ static int __devinit pxa2xx_ac97_probe(struct platform_device *dev)
 	struct snd_ac97_bus *ac97_bus;
 	struct snd_ac97_template ac97_template;
 	int ret;
+	pxa2xx_audio_ops_t *pdata = dev->dev.platform_data;
+	int id = dev->id < 0 ? 0 : dev->id;
 
 	ret = snd_card_create(SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
 			      THIS_MODULE, 0, &card);
@@ -200,6 +202,7 @@ static int __devinit pxa2xx_ac97_probe(struct platform_device *dev)
 	snprintf(card->longname, sizeof(card->longname),
 		 "%s (%s)", dev->dev.driver->name, card->mixername);
 
+	snd_ac97_dev_add_pdata(ac97_bus->codec[id], pdata->codec_pdata[id]);
 	snd_card_set_dev(card, &dev->dev);
 	ret = snd_card_register(card);
 	if (ret == 0) {
diff --git a/sound/soc/pxa/pxa2xx-ac97.c b/sound/soc/pxa/pxa2xx-ac97.c
index d9c94d7..dea18ee 100644
--- a/sound/soc/pxa/pxa2xx-ac97.c
+++ b/sound/soc/pxa/pxa2xx-ac97.c
@@ -22,6 +22,7 @@
 #include <mach/hardware.h>
 #include <mach/regs-ac97.h>
 #include <mach/dma.h>
+#include <mach/audio.h>
 
 #include "pxa2xx-pcm.h"
 #include "pxa2xx-ac97.h"
@@ -241,9 +242,13 @@ EXPORT_SYMBOL_GPL(soc_ac97_ops);
 static int __devinit pxa2xx_ac97_dev_probe(struct platform_device *pdev)
 {
 	int i;
+	pxa2xx_audio_ops_t *pdata = pdev->dev.platform_data;
 
-	for (i = 0; i < ARRAY_SIZE(pxa_ac97_dai); i++)
+	for (i = 0; i < ARRAY_SIZE(pxa_ac97_dai); i++) {
 		pxa_ac97_dai[i].dev = &pdev->dev;
+		pxa_ac97_dai[i].ac97_pdata = pdata->codec_pdata
+					[pdev->id < 0 ? 0 : pdev->id];
+	}
 
 	/* 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
-- 
1.6.3.3


[-- Attachment #3: Type: text/plain, Size: 160 bytes --]

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* Re: [PATCH] Allow passing platform_data to devices attached to AC97 bus
  2009-07-21 20:24           ` [PATCH] " Marek Vasut
@ 2009-07-21 20:59             ` Takashi Iwai
  2009-07-21 21:53               ` Marek Vasut
  0 siblings, 1 reply; 52+ messages in thread
From: Takashi Iwai @ 2009-07-21 20:59 UTC (permalink / raw)
  To: Marek Vasut
  Cc: Russell King - ARM Linux, alsa-devel, Mark Brown, Eric Miao,
	linux-arm-kernel

At Tue, 21 Jul 2009 22:24:21 +0200,
Marek Vasut wrote:
> 
> From 082f09b9f3c1bbf3240610dc89baba33d47787b7 Mon Sep 17 00:00:00 2001
> From: Marek Vasut <marek.vasut@gmail.com>
> Date: Tue, 21 Jul 2009 16:22:29 +0200
> Subject: [PATCH 1/5] Allow passing platform_data to devices attached to AC97 bus
> 
> This patch allows passing platform_data to devices attached to AC97 bus
> (like touchscreens, battery measurement chips ...).
> 
> Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
> ---
>  include/sound/ac97_codec.h |    6 ++++++
>  include/sound/soc-dai.h    |    1 +
>  sound/soc/soc-core.c       |    5 ++++-
>  3 files changed, 11 insertions(+), 1 deletions(-)
> 
> diff --git a/include/sound/ac97_codec.h b/include/sound/ac97_codec.h
> index 251fc1c..702f90d 100644
> --- a/include/sound/ac97_codec.h
> +++ b/include/sound/ac97_codec.h
> @@ -642,4 +642,10 @@ int snd_ac97_pcm_double_rate_rules(struct snd_pcm_runtime *runtime);
>  /* ad hoc AC97 device driver access */
>  extern struct bus_type ac97_bus_type;
>  
> +/* AC97 platform_data adding function */
> +static inline void snd_ac97_dev_add_pdata(struct snd_ac97 *ac97, void *data)
> +{
> +	ac97->dev.platform_data = data;
> +}
> +
>  #endif /* __SOUND_AC97_CODEC_H */
> diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
> index 352d7ee..0d65a03 100644
> --- a/include/sound/soc-dai.h
> +++ b/include/sound/soc-dai.h
> @@ -179,6 +179,7 @@ struct snd_soc_dai {
>  	int ac97_control;
>  
>  	struct device *dev;
> +	void *ac97_pdata;	/* platform_data for the ac97 codec */
>  
>  	/* DAI callbacks */
>  	int (*probe)(struct platform_device *pdev,
> diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
> index 1d70829..0b12fe5 100644
> --- a/sound/soc/soc-core.c
> +++ b/sound/soc/soc-core.c
> @@ -1381,8 +1381,11 @@ int snd_soc_init_card(struct snd_soc_device *socdev)
>  				continue;
>  			}
>  		}
> -		if (card->dai_link[i].codec_dai->ac97_control)
> +		if (card->dai_link[i].codec_dai->ac97_control) {
>  			ac97 = 1;
> +			codec->ac97->dev.platform_data =
> +				card->dai_link[i].cpu_dai->ac97_pdata;

Any reason not to use the newly added snd_ac97_dev_add_pdata()?


thanks,

Takashi

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH] Allow passing platform_data to devices attached to AC97 bus
  2009-07-21 20:59             ` Takashi Iwai
@ 2009-07-21 21:53               ` Marek Vasut
  2009-07-21 22:13                 ` Marek Vasut
  0 siblings, 1 reply; 52+ messages in thread
From: Marek Vasut @ 2009-07-21 21:53 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: Russell King - ARM Linux, alsa-devel, Mark Brown, Eric Miao,
	linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 2462 bytes --]

Dne Út 21. července 2009 22:59:35 Takashi Iwai napsal(a):
> At Tue, 21 Jul 2009 22:24:21 +0200,
>
> Marek Vasut wrote:
> > From 082f09b9f3c1bbf3240610dc89baba33d47787b7 Mon Sep 17 00:00:00 2001
> > From: Marek Vasut <marek.vasut@gmail.com>
> > Date: Tue, 21 Jul 2009 16:22:29 +0200
> > Subject: [PATCH 1/5] Allow passing platform_data to devices attached to
> > AC97 bus
> >
> > This patch allows passing platform_data to devices attached to AC97 bus
> > (like touchscreens, battery measurement chips ...).
> >
> > Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
> > ---
> >  include/sound/ac97_codec.h |    6 ++++++
> >  include/sound/soc-dai.h    |    1 +
> >  sound/soc/soc-core.c       |    5 ++++-
> >  3 files changed, 11 insertions(+), 1 deletions(-)
> >
> > diff --git a/include/sound/ac97_codec.h b/include/sound/ac97_codec.h
> > index 251fc1c..702f90d 100644
> > --- a/include/sound/ac97_codec.h
> > +++ b/include/sound/ac97_codec.h
> > @@ -642,4 +642,10 @@ int snd_ac97_pcm_double_rate_rules(struct
> > snd_pcm_runtime *runtime); /* ad hoc AC97 device driver access */
> >  extern struct bus_type ac97_bus_type;
> >
> > +/* AC97 platform_data adding function */
> > +static inline void snd_ac97_dev_add_pdata(struct snd_ac97 *ac97, void
> > *data) +{
> > +	ac97->dev.platform_data = data;
> > +}
> > +
> >  #endif /* __SOUND_AC97_CODEC_H */
> > diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
> > index 352d7ee..0d65a03 100644
> > --- a/include/sound/soc-dai.h
> > +++ b/include/sound/soc-dai.h
> > @@ -179,6 +179,7 @@ struct snd_soc_dai {
> >  	int ac97_control;
> >
> >  	struct device *dev;
> > +	void *ac97_pdata;	/* platform_data for the ac97 codec */
> >
> >  	/* DAI callbacks */
> >  	int (*probe)(struct platform_device *pdev,
> > diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
> > index 1d70829..0b12fe5 100644
> > --- a/sound/soc/soc-core.c
> > +++ b/sound/soc/soc-core.c
> > @@ -1381,8 +1381,11 @@ int snd_soc_init_card(struct snd_soc_device
> > *socdev) continue;
> >  			}
> >  		}
> > -		if (card->dai_link[i].codec_dai->ac97_control)
> > +		if (card->dai_link[i].codec_dai->ac97_control) {
> >  			ac97 = 1;
> > +			codec->ac97->dev.platform_data =
> > +				card->dai_link[i].cpu_dai->ac97_pdata;
>
> Any reason not to use the newly added snd_ac97_dev_add_pdata()?

hm, that's true, one more iteration then.
>
>
> thanks,
>
> Takashi


[-- Attachment #2: 0001-Allow-passing-platform_data-to-devices-attached-to-A.patch --]
[-- Type: text/x-patch, Size: 2332 bytes --]

From 776233642ae196ee1998791ec69bd20d7725ecca Mon Sep 17 00:00:00 2001
From: Marek Vasut <marek.vasut@gmail.com>
Date: Tue, 21 Jul 2009 16:22:29 +0200
Subject: [PATCH 1/4] Allow passing platform_data to devices attached to AC97 bus

This patch allows passing platform_data to devices attached to AC97 bus
(like touchscreens, battery measurement chips ...).

Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
---
 include/sound/ac97_codec.h |    6 ++++++
 include/sound/soc-dai.h    |    1 +
 sound/soc/soc-core.c       |    6 +++++-
 3 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/include/sound/ac97_codec.h b/include/sound/ac97_codec.h
index 251fc1c..9b1c098 100644
--- a/include/sound/ac97_codec.h
+++ b/include/sound/ac97_codec.h
@@ -642,4 +642,10 @@ int snd_ac97_pcm_double_rate_rules(struct snd_pcm_runtime *runtime);
 /* ad hoc AC97 device driver access */
 extern struct bus_type ac97_bus_type;
 
+/* AC97 platform_data adding function */
+static inline void snd_ac97_dev_add_pdata(struct snd_ac97 *ac97, void *data)
+{
+	ac97->dev.platform_data = data;
+}
+
 #endif /* __SOUND_AC97_CODEC_H */
diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index 352d7ee..0d65a03 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -179,6 +179,7 @@ struct snd_soc_dai {
 	int ac97_control;
 
 	struct device *dev;
+	void *ac97_pdata;	/* platform_data for the ac97 codec */
 
 	/* DAI callbacks */
 	int (*probe)(struct platform_device *pdev,
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 1d70829..7cb0917 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -28,6 +28,7 @@
 #include <linux/bitops.h>
 #include <linux/debugfs.h>
 #include <linux/platform_device.h>
+#include <sound/ac97_codec.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
@@ -1381,8 +1382,11 @@ int snd_soc_init_card(struct snd_soc_device *socdev)
 				continue;
 			}
 		}
-		if (card->dai_link[i].codec_dai->ac97_control)
+		if (card->dai_link[i].codec_dai->ac97_control) {
 			ac97 = 1;
+			snd_ac97_dev_add_pdata(codec->ac97,
+				card->dai_link[i].cpu_dai->ac97_pdata);
+		}
 	}
 	snprintf(codec->card->shortname, sizeof(codec->card->shortname),
 		 "%s",  card->name);
-- 
1.6.3.3


[-- Attachment #3: Type: text/plain, Size: 160 bytes --]

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* Re: [PATCH] Allow passing platform_data to devices attached to AC97 bus
  2009-07-21 21:53               ` Marek Vasut
@ 2009-07-21 22:13                 ` Marek Vasut
  2009-07-21 22:33                   ` Russell King - ARM Linux
  2009-07-21 22:34                   ` Anton Vorontsov
  0 siblings, 2 replies; 52+ messages in thread
From: Marek Vasut @ 2009-07-21 22:13 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: alsa-devel, Russell King - ARM Linux, Mark Brown, cbou, Eric Miao,
	dwmw2, linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 89 bytes --]

Btw. I also reworked the wm97xx-battery a little more. Also, CCing power-
supply people.

[-- Attachment #2: 0003-Convert-WM97xx-driver-to-use-platform_data.patch --]
[-- Type: text/x-patch, Size: 8481 bytes --]

From 0c04c7f9cac26de8b4e401c17e65051c7f44ec3e Mon Sep 17 00:00:00 2001
From: Marek Vasut <marek.vasut@gmail.com>
Date: Tue, 21 Jul 2009 18:52:28 +0200
Subject: [PATCH 3/4] Convert WM97xx driver to use platform_data

This patch converts the wm97xx driver to use platform_data supplied by
ac97 bus. Also, this fixes the related wm97xx-battery driver to use
it's platform_data and prepares a structure for touchscreen driver.

Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
---
 drivers/input/touchscreen/wm97xx-core.c |    3 ++
 drivers/power/wm97xx_battery.c          |   59 +++++++++++++++++++++++--------
 include/linux/wm97xx.h                  |   18 +++++++++
 include/linux/wm97xx_batt.h             |   26 -------------
 4 files changed, 65 insertions(+), 41 deletions(-)
 delete mode 100644 include/linux/wm97xx_batt.h

diff --git a/drivers/input/touchscreen/wm97xx-core.c b/drivers/input/touchscreen/wm97xx-core.c
index 252eb11..f944918 100644
--- a/drivers/input/touchscreen/wm97xx-core.c
+++ b/drivers/input/touchscreen/wm97xx-core.c
@@ -561,6 +561,7 @@ static void wm97xx_ts_input_close(struct input_dev *idev)
 static int wm97xx_probe(struct device *dev)
 {
 	struct wm97xx *wm;
+	struct wm97xx_pdata *pdata = dev->platform_data;
 	int ret = 0, id = 0;
 
 	wm = kzalloc(sizeof(struct wm97xx), GFP_KERNEL);
@@ -658,6 +659,7 @@ static int wm97xx_probe(struct device *dev)
 	}
 	platform_set_drvdata(wm->battery_dev, wm);
 	wm->battery_dev->dev.parent = dev;
+	wm->battery_dev->dev.platform_data = pdata;
 	ret = platform_device_add(wm->battery_dev);
 	if (ret < 0)
 		goto batt_reg_err;
@@ -671,6 +673,7 @@ static int wm97xx_probe(struct device *dev)
 	}
 	platform_set_drvdata(wm->touch_dev, wm);
 	wm->touch_dev->dev.parent = dev;
+	wm->touch_dev->dev.platform_data = pdata;
 	ret = platform_device_add(wm->touch_dev);
 	if (ret < 0)
 		goto touch_reg_err;
diff --git a/drivers/power/wm97xx_battery.c b/drivers/power/wm97xx_battery.c
index 8bde921..05762d7 100644
--- a/drivers/power/wm97xx_battery.c
+++ b/drivers/power/wm97xx_battery.c
@@ -22,17 +22,19 @@
 #include <linux/spinlock.h>
 #include <linux/interrupt.h>
 #include <linux/gpio.h>
-#include <linux/wm97xx_batt.h>
+#include <linux/irq.h>
 
 static DEFINE_MUTEX(bat_lock);
 static struct work_struct bat_work;
 struct mutex work_lock;
 static int bat_status = POWER_SUPPLY_STATUS_UNKNOWN;
-static struct wm97xx_batt_info *pdata;
 static enum power_supply_property *prop;
 
 static unsigned long wm97xx_read_bat(struct power_supply *bat_ps)
 {
+	struct wm97xx_pdata *wmdata = bat_ps->dev->parent->platform_data;
+	struct wm97xx_batt_pdata *pdata = wmdata->batt_pdata;
+
 	return wm97xx_read_aux_adc(bat_ps->dev->parent->driver_data,
 					pdata->batt_aux) * pdata->batt_mult /
 					pdata->batt_div;
@@ -40,6 +42,9 @@ static unsigned long wm97xx_read_bat(struct power_supply *bat_ps)
 
 static unsigned long wm97xx_read_temp(struct power_supply *bat_ps)
 {
+	struct wm97xx_pdata *wmdata = bat_ps->dev->parent->platform_data;
+	struct wm97xx_batt_pdata *pdata = wmdata->batt_pdata;
+
 	return wm97xx_read_aux_adc(bat_ps->dev->parent->driver_data,
 					pdata->temp_aux) * pdata->temp_mult /
 					pdata->temp_div;
@@ -49,6 +54,9 @@ static int wm97xx_bat_get_property(struct power_supply *bat_ps,
 			    enum power_supply_property psp,
 			    union power_supply_propval *val)
 {
+	struct wm97xx_pdata *wmdata = bat_ps->dev->parent->platform_data;
+	struct wm97xx_batt_pdata *pdata = wmdata->batt_pdata;
+
 	switch (psp) {
 	case POWER_SUPPLY_PROP_STATUS:
 		val->intval = bat_status;
@@ -97,6 +105,7 @@ static void wm97xx_bat_external_power_changed(struct power_supply *bat_ps)
 static void wm97xx_bat_update(struct power_supply *bat_ps)
 {
 	int old_status = bat_status;
+	struct wm97xx_batt_pdata *pdata = dev_get_drvdata(bat_ps->dev->parent);
 
 	mutex_lock(&work_lock);
 
@@ -127,6 +136,12 @@ static void wm97xx_bat_work(struct work_struct *work)
 	wm97xx_bat_update(&bat_ps);
 }
 
+static irqreturn_t wm97xx_chrg_irq(int irq, void *data)
+{
+	schedule_work(&bat_work);
+	return IRQ_HANDLED;
+}
+
 #ifdef CONFIG_PM
 static int wm97xx_bat_suspend(struct platform_device *dev, pm_message_t state)
 {
@@ -149,6 +164,8 @@ static int __devinit wm97xx_bat_probe(struct platform_device *dev)
 	int ret = 0;
 	int props = 1;	/* POWER_SUPPLY_PROP_PRESENT */
 	int i = 0;
+	struct wm97xx_pdata *wmdata = dev->dev.platform_data;
+	struct wm97xx_batt_pdata *pdata = wmdata->batt_pdata;
 
 	if (dev->id != -1)
 		return -EINVAL;
@@ -156,17 +173,26 @@ static int __devinit wm97xx_bat_probe(struct platform_device *dev)
 	mutex_init(&work_lock);
 
 	if (!pdata) {
-		dev_err(&dev->dev, "Please use wm97xx_bat_set_pdata\n");
+		dev_err(&dev->dev, "No platform_data supplied\n");
 		return -EINVAL;
 	}
 
-	if (pdata->charge_gpio >= 0 && gpio_is_valid(pdata->charge_gpio)) {
+	if (gpio_is_valid(pdata->charge_gpio)) {
 		ret = gpio_request(pdata->charge_gpio, "BATT CHRG");
 		if (ret)
 			goto err;
 		ret = gpio_direction_input(pdata->charge_gpio);
 		if (ret)
 			goto err2;
+		ret = set_irq_type(gpio_to_irq(pdata->charge_gpio),
+				IRQ_TYPE_EDGE_BOTH);
+		if (ret)
+			goto err2;
+		ret = request_irq(gpio_to_irq(pdata->charge_gpio),
+				wm97xx_chrg_irq, IRQF_DISABLED,
+				"AC Detect", 0);
+		if (ret)
+			goto err3;
 		props++;	/* POWER_SUPPLY_PROP_STATUS */
 	}
 
@@ -183,7 +209,7 @@ static int __devinit wm97xx_bat_probe(struct platform_device *dev)
 
 	prop = kzalloc(props * sizeof(*prop), GFP_KERNEL);
 	if (!prop)
-		goto err2;
+		goto err3;
 
 	prop[i++] = POWER_SUPPLY_PROP_PRESENT;
 	if (pdata->charge_gpio >= 0)
@@ -216,21 +242,30 @@ static int __devinit wm97xx_bat_probe(struct platform_device *dev)
 	if (!ret)
 		schedule_work(&bat_work);
 	else
-		goto err3;
+		goto err4;
 
 	return 0;
-err3:
+err4:
 	kfree(prop);
+err3:
+	if (gpio_is_valid(pdata->charge_gpio))
+		free_irq(gpio_to_irq(pdata->charge_gpio), dev);
 err2:
-	gpio_free(pdata->charge_gpio);
+	if (gpio_is_valid(pdata->charge_gpio))
+		gpio_free(pdata->charge_gpio);
 err:
 	return ret;
 }
 
 static int __devexit wm97xx_bat_remove(struct platform_device *dev)
 {
-	if (pdata && pdata->charge_gpio && pdata->charge_gpio >= 0)
+	struct wm97xx_pdata *wmdata = dev->dev.platform_data;
+	struct wm97xx_batt_pdata *pdata = wmdata->batt_pdata;
+
+	if (pdata && gpio_is_valid(pdata->charge_gpio)) {
+		free_irq(gpio_to_irq(pdata->charge_gpio), dev);
 		gpio_free(pdata->charge_gpio);
+	}
 	flush_scheduled_work();
 	power_supply_unregister(&bat_ps);
 	kfree(prop);
@@ -258,12 +293,6 @@ static void __exit wm97xx_bat_exit(void)
 	platform_driver_unregister(&wm97xx_bat_driver);
 }
 
-void __init wm97xx_bat_set_pdata(struct wm97xx_batt_info *data)
-{
-	pdata = data;
-}
-EXPORT_SYMBOL_GPL(wm97xx_bat_set_pdata);
-
 module_init(wm97xx_bat_init);
 module_exit(wm97xx_bat_exit);
 
diff --git a/include/linux/wm97xx.h b/include/linux/wm97xx.h
index 0c98781..38e8c4d 100644
--- a/include/linux/wm97xx.h
+++ b/include/linux/wm97xx.h
@@ -293,6 +293,24 @@ struct wm97xx {
 	u16 suspend_mode;               /* PRP in suspend mode */
 };
 
+struct wm97xx_batt_pdata {
+	int	batt_aux;
+	int	temp_aux;
+	int	charge_gpio;
+	int	min_voltage;
+	int	max_voltage;
+	int	batt_div;
+	int	batt_mult;
+	int	temp_div;
+	int	temp_mult;
+	int	batt_tech;
+	char	*batt_name;
+};
+
+struct wm97xx_pdata {
+	struct wm97xx_batt_pdata	*batt_pdata;	/* battery data */
+};
+
 /*
  * Codec GPIO access (not supported on WM9705)
  * This can be used to set/get codec GPIO and Virtual GPIO status.
diff --git a/include/linux/wm97xx_batt.h b/include/linux/wm97xx_batt.h
deleted file mode 100644
index 9681d1a..0000000
--- a/include/linux/wm97xx_batt.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#ifndef _LINUX_WM97XX_BAT_H
-#define _LINUX_WM97XX_BAT_H
-
-#include <linux/wm97xx.h>
-
-struct wm97xx_batt_info {
-	int	batt_aux;
-	int	temp_aux;
-	int	charge_gpio;
-	int	min_voltage;
-	int	max_voltage;
-	int	batt_div;
-	int	batt_mult;
-	int	temp_div;
-	int	temp_mult;
-	int	batt_tech;
-	char	*batt_name;
-};
-
-#ifdef CONFIG_BATTERY_WM97XX
-void __init wm97xx_bat_set_pdata(struct wm97xx_batt_info *data);
-#else
-static inline void wm97xx_bat_set_pdata(struct wm97xx_batt_info *data) {}
-#endif
-
-#endif
-- 
1.6.3.3


[-- Attachment #3: Type: text/plain, Size: 160 bytes --]

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* Re: [PATCH] Allow passing platform_data to devices attached to AC97 bus
  2009-07-21 22:13                 ` Marek Vasut
@ 2009-07-21 22:33                   ` Russell King - ARM Linux
  2009-07-21 22:39                     ` Marek Vasut
  2009-07-21 22:34                   ` Anton Vorontsov
  1 sibling, 1 reply; 52+ messages in thread
From: Russell King - ARM Linux @ 2009-07-21 22:33 UTC (permalink / raw)
  To: Marek Vasut
  Cc: alsa-devel, Eric Miao, Takashi Iwai, Mark Brown, cbou, dwmw2,
	linux-arm-kernel

On Wed, Jul 22, 2009 at 12:13:12AM +0200, Marek Vasut wrote:
> +		ret = set_irq_type(gpio_to_irq(pdata->charge_gpio),
> +				IRQ_TYPE_EDGE_BOTH);
> +		if (ret)
> +			goto err2;
> +		ret = request_irq(gpio_to_irq(pdata->charge_gpio),
> +				wm97xx_chrg_irq, IRQF_DISABLED,
> +				"AC Detect", 0);

This should be done as one call to request_irq().

Why?

If the IRQ is already in use by something else, calling set_irq_type()
will stamp on that other user, enforcing the change of configuration.
request_irq() will then fail, leaving the IRQ configuration buggered.

Combining the two allows request_irq() to fail if the IRQ line is busy.
If it isn't busy, it will configure the IRQ line prior to enabling the
IRQ.  If the IRQ is shared and sharing is permitted, it will fail if
the configuration is not compatible with the existing IRQ configuration.

set_irq_type() should only be used very sparingly and when there's no
other option.

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH] Allow passing platform_data to devices attached to AC97 bus
  2009-07-21 22:13                 ` Marek Vasut
  2009-07-21 22:33                   ` Russell King - ARM Linux
@ 2009-07-21 22:34                   ` Anton Vorontsov
  2009-07-21 22:43                     ` Marek Vasut
  2009-07-22 11:01                     ` [PATCH 1/4] " Marek Vasut
  1 sibling, 2 replies; 52+ messages in thread
From: Anton Vorontsov @ 2009-07-21 22:34 UTC (permalink / raw)
  To: Marek Vasut
  Cc: alsa-devel, Russell King - ARM Linux, Takashi Iwai, Mark Brown,
	cbou, Eric Miao, dwmw2, linux-arm-kernel

On Wed, Jul 22, 2009 at 12:13:12AM +0200, Marek Vasut wrote:
> Btw. I also reworked the wm97xx-battery a little more. Also, CCing power-
> supply people.

> From 0c04c7f9cac26de8b4e401c17e65051c7f44ec3e Mon Sep 17 00:00:00 2001
> From: Marek Vasut <marek.vasut@gmail.com>
> Date: Tue, 21 Jul 2009 18:52:28 +0200
> Subject: [PATCH 3/4] Convert WM97xx driver to use platform_data
> 
> This patch converts the wm97xx driver to use platform_data supplied by
> ac97 bus. Also, this fixes the related wm97xx-battery driver to use
> it's platform_data and prepares a structure for touchscreen driver.
> 
> Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
> ---

Acked-by: Anton Vorontsov <cbouatmailru@gmail.com>

> +		ret = set_irq_type(gpio_to_irq(pdata->charge_gpio),
> +				IRQ_TYPE_EDGE_BOTH);
> +		if (ret)
> +			goto err2;

I always thought that request_irq() would set trigger type
as necessary if you pass IRQF_TRIGGER_* flags, so there is
no need for explicit set_irq_type() call?

This code in kernel/irq/manage.c:__setup_irq():

                /* Setup the type (level, edge polarity) if configured: */
                if (new->flags & IRQF_TRIGGER_MASK) {
                        ret = __irq_set_trigger(desc, irq,
                                        new->flags & IRQF_TRIGGER_MASK);


> +		ret = request_irq(gpio_to_irq(pdata->charge_gpio),
> +				wm97xx_chrg_irq, IRQF_DISABLED,
> +				"AC Detect", 0);
> +		if (ret)
> +			goto err3;

-- 
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH] Allow passing platform_data to devices attached to AC97 bus
  2009-07-21 22:33                   ` Russell King - ARM Linux
@ 2009-07-21 22:39                     ` Marek Vasut
  2009-07-21 22:40                       ` Marek Vasut
  0 siblings, 1 reply; 52+ messages in thread
From: Marek Vasut @ 2009-07-21 22:39 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: alsa-devel, Eric Miao, Takashi Iwai, Mark Brown, cbou, dwmw2,
	linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 1126 bytes --]

Dne St 22. července 2009 00:33:34 Russell King - ARM Linux napsal(a):
> On Wed, Jul 22, 2009 at 12:13:12AM +0200, Marek Vasut wrote:
> > +		ret = set_irq_type(gpio_to_irq(pdata->charge_gpio),
> > +				IRQ_TYPE_EDGE_BOTH);
> > +		if (ret)
> > +			goto err2;
> > +		ret = request_irq(gpio_to_irq(pdata->charge_gpio),
> > +				wm97xx_chrg_irq, IRQF_DISABLED,
> > +				"AC Detect", 0);
>
> This should be done as one call to request_irq().
>
> Why?
>
> If the IRQ is already in use by something else, calling set_irq_type()
> will stamp on that other user, enforcing the change of configuration.
> request_irq() will then fail, leaving the IRQ configuration buggered.
>
> Combining the two allows request_irq() to fail if the IRQ line is busy.
> If it isn't busy, it will configure the IRQ line prior to enabling the
> IRQ.  If the IRQ is shared and sharing is permitted, it will fail if
> the configuration is not compatible with the existing IRQ configuration.
>
> set_irq_type() should only be used very sparingly and when there's no
> other option.

Sorry, I removed that, this patch should be OK.

[-- Attachment #2: 0003-Convert-WM97xx-driver-to-use-platform_data.patch --]
[-- Type: text/x-patch, Size: 8370 bytes --]

From 54febe82847aeef3fcc02a074fd9d21def97f174 Mon Sep 17 00:00:00 2001
From: Marek Vasut <marek.vasut@gmail.com>
Date: Tue, 21 Jul 2009 18:52:28 +0200
Subject: [PATCH 3/4] Convert WM97xx driver to use platform_data

This patch converts the wm97xx driver to use platform_data supplied by
ac97 bus. Also, this fixes the related wm97xx-battery driver to use
it's platform_data and prepares a structure for touchscreen driver.

Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
---
 drivers/input/touchscreen/wm97xx-core.c |    3 ++
 drivers/power/wm97xx_battery.c          |   55 ++++++++++++++++++++++--------
 include/linux/wm97xx.h                  |   18 ++++++++++
 include/linux/wm97xx_batt.h             |   26 --------------
 4 files changed, 61 insertions(+), 41 deletions(-)
 delete mode 100644 include/linux/wm97xx_batt.h

diff --git a/drivers/input/touchscreen/wm97xx-core.c b/drivers/input/touchscreen/wm97xx-core.c
index 252eb11..f944918 100644
--- a/drivers/input/touchscreen/wm97xx-core.c
+++ b/drivers/input/touchscreen/wm97xx-core.c
@@ -561,6 +561,7 @@ static void wm97xx_ts_input_close(struct input_dev *idev)
 static int wm97xx_probe(struct device *dev)
 {
 	struct wm97xx *wm;
+	struct wm97xx_pdata *pdata = dev->platform_data;
 	int ret = 0, id = 0;
 
 	wm = kzalloc(sizeof(struct wm97xx), GFP_KERNEL);
@@ -658,6 +659,7 @@ static int wm97xx_probe(struct device *dev)
 	}
 	platform_set_drvdata(wm->battery_dev, wm);
 	wm->battery_dev->dev.parent = dev;
+	wm->battery_dev->dev.platform_data = pdata;
 	ret = platform_device_add(wm->battery_dev);
 	if (ret < 0)
 		goto batt_reg_err;
@@ -671,6 +673,7 @@ static int wm97xx_probe(struct device *dev)
 	}
 	platform_set_drvdata(wm->touch_dev, wm);
 	wm->touch_dev->dev.parent = dev;
+	wm->touch_dev->dev.platform_data = pdata;
 	ret = platform_device_add(wm->touch_dev);
 	if (ret < 0)
 		goto touch_reg_err;
diff --git a/drivers/power/wm97xx_battery.c b/drivers/power/wm97xx_battery.c
index 8bde921..f31cad9 100644
--- a/drivers/power/wm97xx_battery.c
+++ b/drivers/power/wm97xx_battery.c
@@ -22,17 +22,19 @@
 #include <linux/spinlock.h>
 #include <linux/interrupt.h>
 #include <linux/gpio.h>
-#include <linux/wm97xx_batt.h>
+#include <linux/irq.h>
 
 static DEFINE_MUTEX(bat_lock);
 static struct work_struct bat_work;
 struct mutex work_lock;
 static int bat_status = POWER_SUPPLY_STATUS_UNKNOWN;
-static struct wm97xx_batt_info *pdata;
 static enum power_supply_property *prop;
 
 static unsigned long wm97xx_read_bat(struct power_supply *bat_ps)
 {
+	struct wm97xx_pdata *wmdata = bat_ps->dev->parent->platform_data;
+	struct wm97xx_batt_pdata *pdata = wmdata->batt_pdata;
+
 	return wm97xx_read_aux_adc(bat_ps->dev->parent->driver_data,
 					pdata->batt_aux) * pdata->batt_mult /
 					pdata->batt_div;
@@ -40,6 +42,9 @@ static unsigned long wm97xx_read_bat(struct power_supply *bat_ps)
 
 static unsigned long wm97xx_read_temp(struct power_supply *bat_ps)
 {
+	struct wm97xx_pdata *wmdata = bat_ps->dev->parent->platform_data;
+	struct wm97xx_batt_pdata *pdata = wmdata->batt_pdata;
+
 	return wm97xx_read_aux_adc(bat_ps->dev->parent->driver_data,
 					pdata->temp_aux) * pdata->temp_mult /
 					pdata->temp_div;
@@ -49,6 +54,9 @@ static int wm97xx_bat_get_property(struct power_supply *bat_ps,
 			    enum power_supply_property psp,
 			    union power_supply_propval *val)
 {
+	struct wm97xx_pdata *wmdata = bat_ps->dev->parent->platform_data;
+	struct wm97xx_batt_pdata *pdata = wmdata->batt_pdata;
+
 	switch (psp) {
 	case POWER_SUPPLY_PROP_STATUS:
 		val->intval = bat_status;
@@ -97,6 +105,7 @@ static void wm97xx_bat_external_power_changed(struct power_supply *bat_ps)
 static void wm97xx_bat_update(struct power_supply *bat_ps)
 {
 	int old_status = bat_status;
+	struct wm97xx_batt_pdata *pdata = dev_get_drvdata(bat_ps->dev->parent);
 
 	mutex_lock(&work_lock);
 
@@ -127,6 +136,12 @@ static void wm97xx_bat_work(struct work_struct *work)
 	wm97xx_bat_update(&bat_ps);
 }
 
+static irqreturn_t wm97xx_chrg_irq(int irq, void *data)
+{
+	schedule_work(&bat_work);
+	return IRQ_HANDLED;
+}
+
 #ifdef CONFIG_PM
 static int wm97xx_bat_suspend(struct platform_device *dev, pm_message_t state)
 {
@@ -149,6 +164,8 @@ static int __devinit wm97xx_bat_probe(struct platform_device *dev)
 	int ret = 0;
 	int props = 1;	/* POWER_SUPPLY_PROP_PRESENT */
 	int i = 0;
+	struct wm97xx_pdata *wmdata = dev->dev.platform_data;
+	struct wm97xx_batt_pdata *pdata = wmdata->batt_pdata;
 
 	if (dev->id != -1)
 		return -EINVAL;
@@ -156,17 +173,22 @@ static int __devinit wm97xx_bat_probe(struct platform_device *dev)
 	mutex_init(&work_lock);
 
 	if (!pdata) {
-		dev_err(&dev->dev, "Please use wm97xx_bat_set_pdata\n");
+		dev_err(&dev->dev, "No platform_data supplied\n");
 		return -EINVAL;
 	}
 
-	if (pdata->charge_gpio >= 0 && gpio_is_valid(pdata->charge_gpio)) {
+	if (gpio_is_valid(pdata->charge_gpio)) {
 		ret = gpio_request(pdata->charge_gpio, "BATT CHRG");
 		if (ret)
 			goto err;
 		ret = gpio_direction_input(pdata->charge_gpio);
 		if (ret)
 			goto err2;
+		ret = request_irq(gpio_to_irq(pdata->charge_gpio),
+				wm97xx_chrg_irq, IRQF_DISABLED,
+				"AC Detect", 0);
+		if (ret)
+			goto err3;
 		props++;	/* POWER_SUPPLY_PROP_STATUS */
 	}
 
@@ -183,7 +205,7 @@ static int __devinit wm97xx_bat_probe(struct platform_device *dev)
 
 	prop = kzalloc(props * sizeof(*prop), GFP_KERNEL);
 	if (!prop)
-		goto err2;
+		goto err3;
 
 	prop[i++] = POWER_SUPPLY_PROP_PRESENT;
 	if (pdata->charge_gpio >= 0)
@@ -216,21 +238,30 @@ static int __devinit wm97xx_bat_probe(struct platform_device *dev)
 	if (!ret)
 		schedule_work(&bat_work);
 	else
-		goto err3;
+		goto err4;
 
 	return 0;
-err3:
+err4:
 	kfree(prop);
+err3:
+	if (gpio_is_valid(pdata->charge_gpio))
+		free_irq(gpio_to_irq(pdata->charge_gpio), dev);
 err2:
-	gpio_free(pdata->charge_gpio);
+	if (gpio_is_valid(pdata->charge_gpio))
+		gpio_free(pdata->charge_gpio);
 err:
 	return ret;
 }
 
 static int __devexit wm97xx_bat_remove(struct platform_device *dev)
 {
-	if (pdata && pdata->charge_gpio && pdata->charge_gpio >= 0)
+	struct wm97xx_pdata *wmdata = dev->dev.platform_data;
+	struct wm97xx_batt_pdata *pdata = wmdata->batt_pdata;
+
+	if (pdata && gpio_is_valid(pdata->charge_gpio)) {
+		free_irq(gpio_to_irq(pdata->charge_gpio), dev);
 		gpio_free(pdata->charge_gpio);
+	}
 	flush_scheduled_work();
 	power_supply_unregister(&bat_ps);
 	kfree(prop);
@@ -258,12 +289,6 @@ static void __exit wm97xx_bat_exit(void)
 	platform_driver_unregister(&wm97xx_bat_driver);
 }
 
-void __init wm97xx_bat_set_pdata(struct wm97xx_batt_info *data)
-{
-	pdata = data;
-}
-EXPORT_SYMBOL_GPL(wm97xx_bat_set_pdata);
-
 module_init(wm97xx_bat_init);
 module_exit(wm97xx_bat_exit);
 
diff --git a/include/linux/wm97xx.h b/include/linux/wm97xx.h
index 0c98781..38e8c4d 100644
--- a/include/linux/wm97xx.h
+++ b/include/linux/wm97xx.h
@@ -293,6 +293,24 @@ struct wm97xx {
 	u16 suspend_mode;               /* PRP in suspend mode */
 };
 
+struct wm97xx_batt_pdata {
+	int	batt_aux;
+	int	temp_aux;
+	int	charge_gpio;
+	int	min_voltage;
+	int	max_voltage;
+	int	batt_div;
+	int	batt_mult;
+	int	temp_div;
+	int	temp_mult;
+	int	batt_tech;
+	char	*batt_name;
+};
+
+struct wm97xx_pdata {
+	struct wm97xx_batt_pdata	*batt_pdata;	/* battery data */
+};
+
 /*
  * Codec GPIO access (not supported on WM9705)
  * This can be used to set/get codec GPIO and Virtual GPIO status.
diff --git a/include/linux/wm97xx_batt.h b/include/linux/wm97xx_batt.h
deleted file mode 100644
index 9681d1a..0000000
--- a/include/linux/wm97xx_batt.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#ifndef _LINUX_WM97XX_BAT_H
-#define _LINUX_WM97XX_BAT_H
-
-#include <linux/wm97xx.h>
-
-struct wm97xx_batt_info {
-	int	batt_aux;
-	int	temp_aux;
-	int	charge_gpio;
-	int	min_voltage;
-	int	max_voltage;
-	int	batt_div;
-	int	batt_mult;
-	int	temp_div;
-	int	temp_mult;
-	int	batt_tech;
-	char	*batt_name;
-};
-
-#ifdef CONFIG_BATTERY_WM97XX
-void __init wm97xx_bat_set_pdata(struct wm97xx_batt_info *data);
-#else
-static inline void wm97xx_bat_set_pdata(struct wm97xx_batt_info *data) {}
-#endif
-
-#endif
-- 
1.6.3.3


[-- Attachment #3: Type: text/plain, Size: 160 bytes --]

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* Re: [PATCH] Allow passing platform_data to devices attached to AC97 bus
  2009-07-21 22:39                     ` Marek Vasut
@ 2009-07-21 22:40                       ` Marek Vasut
  0 siblings, 0 replies; 52+ messages in thread
From: Marek Vasut @ 2009-07-21 22:40 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: alsa-devel, Eric Miao, Takashi Iwai, Mark Brown, cbou, dwmw2,
	linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 1279 bytes --]

Dne St 22. července 2009 00:39:00 Marek Vasut napsal(a):
> Dne St 22. července 2009 00:33:34 Russell King - ARM Linux napsal(a):
> > On Wed, Jul 22, 2009 at 12:13:12AM +0200, Marek Vasut wrote:
> > > +		ret = set_irq_type(gpio_to_irq(pdata->charge_gpio),
> > > +				IRQ_TYPE_EDGE_BOTH);
> > > +		if (ret)
> > > +			goto err2;
> > > +		ret = request_irq(gpio_to_irq(pdata->charge_gpio),
> > > +				wm97xx_chrg_irq, IRQF_DISABLED,
> > > +				"AC Detect", 0);
> >
> > This should be done as one call to request_irq().
> >
> > Why?
> >
> > If the IRQ is already in use by something else, calling set_irq_type()
> > will stamp on that other user, enforcing the change of configuration.
> > request_irq() will then fail, leaving the IRQ configuration buggered.
> >
> > Combining the two allows request_irq() to fail if the IRQ line is busy.
> > If it isn't busy, it will configure the IRQ line prior to enabling the
> > IRQ.  If the IRQ is shared and sharing is permitted, it will fail if
> > the configuration is not compatible with the existing IRQ configuration.
> >
> > set_irq_type() should only be used very sparingly and when there's no
> > other option.
>
> Sorry, I removed that, this patch should be OK.

Argh, I forget to fix the goto label.

[-- Attachment #2: 0003-Convert-WM97xx-driver-to-use-platform_data.patch --]
[-- Type: text/x-patch, Size: 8370 bytes --]

From 54febe82847aeef3fcc02a074fd9d21def97f174 Mon Sep 17 00:00:00 2001
From: Marek Vasut <marek.vasut@gmail.com>
Date: Tue, 21 Jul 2009 18:52:28 +0200
Subject: [PATCH 3/4] Convert WM97xx driver to use platform_data

This patch converts the wm97xx driver to use platform_data supplied by
ac97 bus. Also, this fixes the related wm97xx-battery driver to use
it's platform_data and prepares a structure for touchscreen driver.

Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
---
 drivers/input/touchscreen/wm97xx-core.c |    3 ++
 drivers/power/wm97xx_battery.c          |   55 ++++++++++++++++++++++--------
 include/linux/wm97xx.h                  |   18 ++++++++++
 include/linux/wm97xx_batt.h             |   26 --------------
 4 files changed, 61 insertions(+), 41 deletions(-)
 delete mode 100644 include/linux/wm97xx_batt.h

diff --git a/drivers/input/touchscreen/wm97xx-core.c b/drivers/input/touchscreen/wm97xx-core.c
index 252eb11..f944918 100644
--- a/drivers/input/touchscreen/wm97xx-core.c
+++ b/drivers/input/touchscreen/wm97xx-core.c
@@ -561,6 +561,7 @@ static void wm97xx_ts_input_close(struct input_dev *idev)
 static int wm97xx_probe(struct device *dev)
 {
 	struct wm97xx *wm;
+	struct wm97xx_pdata *pdata = dev->platform_data;
 	int ret = 0, id = 0;
 
 	wm = kzalloc(sizeof(struct wm97xx), GFP_KERNEL);
@@ -658,6 +659,7 @@ static int wm97xx_probe(struct device *dev)
 	}
 	platform_set_drvdata(wm->battery_dev, wm);
 	wm->battery_dev->dev.parent = dev;
+	wm->battery_dev->dev.platform_data = pdata;
 	ret = platform_device_add(wm->battery_dev);
 	if (ret < 0)
 		goto batt_reg_err;
@@ -671,6 +673,7 @@ static int wm97xx_probe(struct device *dev)
 	}
 	platform_set_drvdata(wm->touch_dev, wm);
 	wm->touch_dev->dev.parent = dev;
+	wm->touch_dev->dev.platform_data = pdata;
 	ret = platform_device_add(wm->touch_dev);
 	if (ret < 0)
 		goto touch_reg_err;
diff --git a/drivers/power/wm97xx_battery.c b/drivers/power/wm97xx_battery.c
index 8bde921..f31cad9 100644
--- a/drivers/power/wm97xx_battery.c
+++ b/drivers/power/wm97xx_battery.c
@@ -22,17 +22,19 @@
 #include <linux/spinlock.h>
 #include <linux/interrupt.h>
 #include <linux/gpio.h>
-#include <linux/wm97xx_batt.h>
+#include <linux/irq.h>
 
 static DEFINE_MUTEX(bat_lock);
 static struct work_struct bat_work;
 struct mutex work_lock;
 static int bat_status = POWER_SUPPLY_STATUS_UNKNOWN;
-static struct wm97xx_batt_info *pdata;
 static enum power_supply_property *prop;
 
 static unsigned long wm97xx_read_bat(struct power_supply *bat_ps)
 {
+	struct wm97xx_pdata *wmdata = bat_ps->dev->parent->platform_data;
+	struct wm97xx_batt_pdata *pdata = wmdata->batt_pdata;
+
 	return wm97xx_read_aux_adc(bat_ps->dev->parent->driver_data,
 					pdata->batt_aux) * pdata->batt_mult /
 					pdata->batt_div;
@@ -40,6 +42,9 @@ static unsigned long wm97xx_read_bat(struct power_supply *bat_ps)
 
 static unsigned long wm97xx_read_temp(struct power_supply *bat_ps)
 {
+	struct wm97xx_pdata *wmdata = bat_ps->dev->parent->platform_data;
+	struct wm97xx_batt_pdata *pdata = wmdata->batt_pdata;
+
 	return wm97xx_read_aux_adc(bat_ps->dev->parent->driver_data,
 					pdata->temp_aux) * pdata->temp_mult /
 					pdata->temp_div;
@@ -49,6 +54,9 @@ static int wm97xx_bat_get_property(struct power_supply *bat_ps,
 			    enum power_supply_property psp,
 			    union power_supply_propval *val)
 {
+	struct wm97xx_pdata *wmdata = bat_ps->dev->parent->platform_data;
+	struct wm97xx_batt_pdata *pdata = wmdata->batt_pdata;
+
 	switch (psp) {
 	case POWER_SUPPLY_PROP_STATUS:
 		val->intval = bat_status;
@@ -97,6 +105,7 @@ static void wm97xx_bat_external_power_changed(struct power_supply *bat_ps)
 static void wm97xx_bat_update(struct power_supply *bat_ps)
 {
 	int old_status = bat_status;
+	struct wm97xx_batt_pdata *pdata = dev_get_drvdata(bat_ps->dev->parent);
 
 	mutex_lock(&work_lock);
 
@@ -127,6 +136,12 @@ static void wm97xx_bat_work(struct work_struct *work)
 	wm97xx_bat_update(&bat_ps);
 }
 
+static irqreturn_t wm97xx_chrg_irq(int irq, void *data)
+{
+	schedule_work(&bat_work);
+	return IRQ_HANDLED;
+}
+
 #ifdef CONFIG_PM
 static int wm97xx_bat_suspend(struct platform_device *dev, pm_message_t state)
 {
@@ -149,6 +164,8 @@ static int __devinit wm97xx_bat_probe(struct platform_device *dev)
 	int ret = 0;
 	int props = 1;	/* POWER_SUPPLY_PROP_PRESENT */
 	int i = 0;
+	struct wm97xx_pdata *wmdata = dev->dev.platform_data;
+	struct wm97xx_batt_pdata *pdata = wmdata->batt_pdata;
 
 	if (dev->id != -1)
 		return -EINVAL;
@@ -156,17 +173,22 @@ static int __devinit wm97xx_bat_probe(struct platform_device *dev)
 	mutex_init(&work_lock);
 
 	if (!pdata) {
-		dev_err(&dev->dev, "Please use wm97xx_bat_set_pdata\n");
+		dev_err(&dev->dev, "No platform_data supplied\n");
 		return -EINVAL;
 	}
 
-	if (pdata->charge_gpio >= 0 && gpio_is_valid(pdata->charge_gpio)) {
+	if (gpio_is_valid(pdata->charge_gpio)) {
 		ret = gpio_request(pdata->charge_gpio, "BATT CHRG");
 		if (ret)
 			goto err;
 		ret = gpio_direction_input(pdata->charge_gpio);
 		if (ret)
 			goto err2;
+		ret = request_irq(gpio_to_irq(pdata->charge_gpio),
+				wm97xx_chrg_irq, IRQF_DISABLED,
+				"AC Detect", 0);
+		if (ret)
+			goto err2;
 		props++;	/* POWER_SUPPLY_PROP_STATUS */
 	}
 
@@ -183,7 +205,7 @@ static int __devinit wm97xx_bat_probe(struct platform_device *dev)
 
 	prop = kzalloc(props * sizeof(*prop), GFP_KERNEL);
 	if (!prop)
-		goto err2;
+		goto err3;
 
 	prop[i++] = POWER_SUPPLY_PROP_PRESENT;
 	if (pdata->charge_gpio >= 0)
@@ -216,21 +238,30 @@ static int __devinit wm97xx_bat_probe(struct platform_device *dev)
 	if (!ret)
 		schedule_work(&bat_work);
 	else
-		goto err3;
+		goto err4;
 
 	return 0;
-err3:
+err4:
 	kfree(prop);
+err3:
+	if (gpio_is_valid(pdata->charge_gpio))
+		free_irq(gpio_to_irq(pdata->charge_gpio), dev);
 err2:
-	gpio_free(pdata->charge_gpio);
+	if (gpio_is_valid(pdata->charge_gpio))
+		gpio_free(pdata->charge_gpio);
 err:
 	return ret;
 }
 
 static int __devexit wm97xx_bat_remove(struct platform_device *dev)
 {
-	if (pdata && pdata->charge_gpio && pdata->charge_gpio >= 0)
+	struct wm97xx_pdata *wmdata = dev->dev.platform_data;
+	struct wm97xx_batt_pdata *pdata = wmdata->batt_pdata;
+
+	if (pdata && gpio_is_valid(pdata->charge_gpio)) {
+		free_irq(gpio_to_irq(pdata->charge_gpio), dev);
 		gpio_free(pdata->charge_gpio);
+	}
 	flush_scheduled_work();
 	power_supply_unregister(&bat_ps);
 	kfree(prop);
@@ -258,12 +289,6 @@ static void __exit wm97xx_bat_exit(void)
 	platform_driver_unregister(&wm97xx_bat_driver);
 }
 
-void __init wm97xx_bat_set_pdata(struct wm97xx_batt_info *data)
-{
-	pdata = data;
-}
-EXPORT_SYMBOL_GPL(wm97xx_bat_set_pdata);
-
 module_init(wm97xx_bat_init);
 module_exit(wm97xx_bat_exit);
 
diff --git a/include/linux/wm97xx.h b/include/linux/wm97xx.h
index 0c98781..38e8c4d 100644
--- a/include/linux/wm97xx.h
+++ b/include/linux/wm97xx.h
@@ -293,6 +293,24 @@ struct wm97xx {
 	u16 suspend_mode;               /* PRP in suspend mode */
 };
 
+struct wm97xx_batt_pdata {
+	int	batt_aux;
+	int	temp_aux;
+	int	charge_gpio;
+	int	min_voltage;
+	int	max_voltage;
+	int	batt_div;
+	int	batt_mult;
+	int	temp_div;
+	int	temp_mult;
+	int	batt_tech;
+	char	*batt_name;
+};
+
+struct wm97xx_pdata {
+	struct wm97xx_batt_pdata	*batt_pdata;	/* battery data */
+};
+
 /*
  * Codec GPIO access (not supported on WM9705)
  * This can be used to set/get codec GPIO and Virtual GPIO status.
diff --git a/include/linux/wm97xx_batt.h b/include/linux/wm97xx_batt.h
deleted file mode 100644
index 9681d1a..0000000
--- a/include/linux/wm97xx_batt.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#ifndef _LINUX_WM97XX_BAT_H
-#define _LINUX_WM97XX_BAT_H
-
-#include <linux/wm97xx.h>
-
-struct wm97xx_batt_info {
-	int	batt_aux;
-	int	temp_aux;
-	int	charge_gpio;
-	int	min_voltage;
-	int	max_voltage;
-	int	batt_div;
-	int	batt_mult;
-	int	temp_div;
-	int	temp_mult;
-	int	batt_tech;
-	char	*batt_name;
-};
-
-#ifdef CONFIG_BATTERY_WM97XX
-void __init wm97xx_bat_set_pdata(struct wm97xx_batt_info *data);
-#else
-static inline void wm97xx_bat_set_pdata(struct wm97xx_batt_info *data) {}
-#endif
-
-#endif
-- 
1.6.3.3


[-- Attachment #3: Type: text/plain, Size: 160 bytes --]

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* Re: [PATCH] Allow passing platform_data to devices attached to AC97 bus
  2009-07-21 22:34                   ` Anton Vorontsov
@ 2009-07-21 22:43                     ` Marek Vasut
  2009-07-22 11:01                     ` [PATCH 1/4] " Marek Vasut
  1 sibling, 0 replies; 52+ messages in thread
From: Marek Vasut @ 2009-07-21 22:43 UTC (permalink / raw)
  To: avorontsov
  Cc: alsa-devel, Russell King - ARM Linux, Takashi Iwai,
	Robert Jarzmik, Mark Brown, cbou, Eric Miao, dwmw2,
	linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 1759 bytes --]

Dne St 22. července 2009 00:34:24 Anton Vorontsov napsal(a):
> On Wed, Jul 22, 2009 at 12:13:12AM +0200, Marek Vasut wrote:
> > Btw. I also reworked the wm97xx-battery a little more. Also, CCing power-
> > supply people.
> >
> > From 0c04c7f9cac26de8b4e401c17e65051c7f44ec3e Mon Sep 17 00:00:00 2001
> > From: Marek Vasut <marek.vasut@gmail.com>
> > Date: Tue, 21 Jul 2009 18:52:28 +0200
> > Subject: [PATCH 3/4] Convert WM97xx driver to use platform_data
> >
> > This patch converts the wm97xx driver to use platform_data supplied by
> > ac97 bus. Also, this fixes the related wm97xx-battery driver to use
> > it's platform_data and prepares a structure for touchscreen driver.
> >
> > Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
> > ---
>
> Acked-by: Anton Vorontsov <cbouatmailru@gmail.com>
>
> > +		ret = set_irq_type(gpio_to_irq(pdata->charge_gpio),
> > +				IRQ_TYPE_EDGE_BOTH);
> > +		if (ret)
> > +			goto err2;
>
> I always thought that request_irq() would set trigger type
> as necessary if you pass IRQF_TRIGGER_* flags, so there is
> no need for explicit set_irq_type() call?
>
> This code in kernel/irq/manage.c:__setup_irq():
>
>                 /* Setup the type (level, edge polarity) if configured: */
>                 if (new->flags & IRQF_TRIGGER_MASK) {
>                         ret = __irq_set_trigger(desc, irq,
>                                         new->flags & IRQF_TRIGGER_MASK);
>
> > +		ret = request_irq(gpio_to_irq(pdata->charge_gpio),
> > +				wm97xx_chrg_irq, IRQF_DISABLED,
> > +				"AC Detect", 0);
> > +		if (ret)
> > +			goto err3;

Yes, sorry, I fixed this one. Btw. we can safely apply the attached patch then. 
This will need Robert's ack though (mioa701 change).

[-- Attachment #2: 0004-Convert-all-platforms-to-pass-platform_data-to-wm97x.patch --]
[-- Type: text/x-patch, Size: 11915 bytes --]

From 0ccf06e47672e0cc1795c18c701b6db79bdc2eea Mon Sep 17 00:00:00 2001
From: Marek Vasut <marek.vasut@gmail.com>
Date: Tue, 21 Jul 2009 19:22:13 +0200
Subject: [PATCH 4/4] Convert all platforms to pass platform_data to wm97xx battery

Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
---
 arch/arm/mach-pxa/mioa701.c |    7 ++++++-
 arch/arm/mach-pxa/palmld.c  |   19 ++++++++++---------
 arch/arm/mach-pxa/palmt5.c  |   19 ++++++++++---------
 arch/arm/mach-pxa/palmte2.c |   20 ++++++++++++--------
 arch/arm/mach-pxa/palmtx.c  |   19 ++++++++++---------
 arch/arm/mach-pxa/palmz72.c |   20 ++++++++++++--------
 arch/arm/mach-pxa/treo680.c |    1 -
 7 files changed, 60 insertions(+), 45 deletions(-)

diff --git a/arch/arm/mach-pxa/mioa701.c b/arch/arm/mach-pxa/mioa701.c
index 3cab452..803917d 100644
--- a/arch/arm/mach-pxa/mioa701.c
+++ b/arch/arm/mach-pxa/mioa701.c
@@ -34,7 +34,7 @@
 #include <linux/irq.h>
 #include <linux/pda_power.h>
 #include <linux/power_supply.h>
-#include <linux/wm97xx_batt.h>
+#include <linux/wm97xx.h>
 #include <linux/mtd/physmap.h>
 #include <linux/usb/gpio_vbus.h>
 #include <linux/regulator/max1586.h>
@@ -660,6 +660,10 @@ static struct wm97xx_batt_info mioa701_battery_data = {
 	.batt_name	= "mioa701_battery",
 };
 
+static struct wm97xx_pdata mioa701_wm97xx_pdata = {
+	.batt_pdata	= &mioa701_battery_data,
+};
+
 /*
  * Voltage regulation
  */
@@ -728,6 +732,7 @@ struct i2c_pxa_platform_data i2c_pdata = {
 
 static pxa2xx_audio_ops_t mioa701_ac97_info = {
 	.reset_gpio = 95,
+	.codec_pdata = { &mioa701_wm97xx_pdata, },
 };
 
 /*
diff --git a/arch/arm/mach-pxa/palmld.c b/arch/arm/mach-pxa/palmld.c
index 1ad029d..bcf5b46 100644
--- a/arch/arm/mach-pxa/palmld.c
+++ b/arch/arm/mach-pxa/palmld.c
@@ -22,7 +22,7 @@
 #include <linux/pda_power.h>
 #include <linux/pwm_backlight.h>
 #include <linux/gpio.h>
-#include <linux/wm97xx_batt.h>
+#include <linux/wm97xx.h>
 #include <linux/power_supply.h>
 #include <linux/sysdev.h>
 #include <linux/mtd/mtd.h>
@@ -406,9 +406,9 @@ static struct platform_device power_supply = {
 };
 
 /******************************************************************************
- * WM97xx battery
+ * WM97xx audio, battery
  ******************************************************************************/
-static struct wm97xx_batt_info wm97xx_batt_pdata = {
+static struct wm97xx_batt_pdata palmld_batt_pdata = {
 	.batt_aux	= WM97XX_AUX_ID3,
 	.temp_aux	= WM97XX_AUX_ID2,
 	.charge_gpio	= -1,
@@ -422,15 +422,17 @@ static struct wm97xx_batt_info wm97xx_batt_pdata = {
 	.batt_name	= "main-batt",
 };
 
-/******************************************************************************
- * aSoC audio
- ******************************************************************************/
-static struct palm27x_asoc_info palmld_asoc_pdata = {
-	.jack_gpio	= GPIO_NR_PALMLD_EARPHONE_DETECT,
+static struct wm97xx_pdata palmld_wm97xx_pdata = {
+	.batt_pdata	= &palmld_batt_pdata,
 };
 
 static pxa2xx_audio_ops_t palmld_ac97_pdata = {
 	.reset_gpio	= 95,
+	.codec_pdata	= { &palmld_wm97xx_pdata, },
+};
+
+static struct palm27x_asoc_info palmld_asoc_pdata = {
+	.jack_gpio	= GPIO_NR_PALMLD_EARPHONE_DETECT,
 };
 
 static struct platform_device palmld_asoc = {
@@ -536,7 +538,6 @@ static void __init palmld_init(void)
 	pxa_set_ac97_info(&palmld_ac97_pdata);
 	pxa_set_ficp_info(&palmld_ficp_platform_data);
 	pxa_set_keypad_info(&palmld_keypad_platform_data);
-	wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
 
 	platform_add_devices(devices, ARRAY_SIZE(devices));
 }
diff --git a/arch/arm/mach-pxa/palmt5.c b/arch/arm/mach-pxa/palmt5.c
index 2dd7ce2..3e8b21d 100644
--- a/arch/arm/mach-pxa/palmt5.c
+++ b/arch/arm/mach-pxa/palmt5.c
@@ -24,7 +24,7 @@
 #include <linux/pda_power.h>
 #include <linux/pwm_backlight.h>
 #include <linux/gpio.h>
-#include <linux/wm97xx_batt.h>
+#include <linux/wm97xx.h>
 #include <linux/power_supply.h>
 #include <linux/usb/gpio_vbus.h>
 
@@ -317,9 +317,9 @@ static struct platform_device power_supply = {
 };
 
 /******************************************************************************
- * WM97xx battery
+ * WM97xx audio, battery
  ******************************************************************************/
-static struct wm97xx_batt_info wm97xx_batt_pdata = {
+static struct wm97xx_batt_pdata palmt5_batt_pdata = {
 	.batt_aux	= WM97XX_AUX_ID3,
 	.temp_aux	= WM97XX_AUX_ID2,
 	.charge_gpio	= -1,
@@ -333,15 +333,17 @@ static struct wm97xx_batt_info wm97xx_batt_pdata = {
 	.batt_name	= "main-batt",
 };
 
-/******************************************************************************
- * aSoC audio
- ******************************************************************************/
-static struct palm27x_asoc_info palmt5_asoc_pdata = {
-	.jack_gpio	= GPIO_NR_PALMT5_EARPHONE_DETECT,
+static struct wm97xx_pdata palmt5_wm97xx_pdata = {
+	.batt_pdata	= &palmt5_batt_pdata,
 };
 
 static pxa2xx_audio_ops_t palmt5_ac97_pdata = {
 	.reset_gpio	= 95,
+	.codec_pdata	= { &palmt5_wm97xx_pdata, },
+};
+
+static struct palm27x_asoc_info palmt5_asoc_pdata = {
+	.jack_gpio	= GPIO_NR_PALMT5_EARPHONE_DETECT,
 };
 
 static struct platform_device palmt5_asoc = {
@@ -426,7 +428,6 @@ static void __init palmt5_init(void)
 	pxa_set_ac97_info(&palmt5_ac97_pdata);
 	pxa_set_ficp_info(&palmt5_ficp_platform_data);
 	pxa_set_keypad_info(&palmt5_keypad_platform_data);
-	wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
 
 	platform_add_devices(devices, ARRAY_SIZE(devices));
 }
diff --git a/arch/arm/mach-pxa/palmte2.c b/arch/arm/mach-pxa/palmte2.c
index 277c406..21c241b 100644
--- a/arch/arm/mach-pxa/palmte2.c
+++ b/arch/arm/mach-pxa/palmte2.c
@@ -23,7 +23,7 @@
 #include <linux/pda_power.h>
 #include <linux/pwm_backlight.h>
 #include <linux/gpio.h>
-#include <linux/wm97xx_batt.h>
+#include <linux/wm97xx.h>
 #include <linux/power_supply.h>
 #include <linux/usb/gpio_vbus.h>
 
@@ -290,9 +290,9 @@ static struct platform_device power_supply = {
 };
 
 /******************************************************************************
- * WM97xx battery
+ * WM97xx audio, battery
  ******************************************************************************/
-static struct wm97xx_batt_info wm97xx_batt_pdata = {
+static struct wm97xx_batt_info palmte2_batt_pdata = {
 	.batt_aux	= WM97XX_AUX_ID3,
 	.temp_aux	= WM97XX_AUX_ID2,
 	.charge_gpio	= -1,
@@ -306,9 +306,14 @@ static struct wm97xx_batt_info wm97xx_batt_pdata = {
 	.batt_name	= "main-batt",
 };
 
-/******************************************************************************
- * aSoC audio
- ******************************************************************************/
+static struct wm97xx_pdata palmte2_wm97xx_pdata = {
+	.batt_pdata	= &palmte2_batt_pdata,
+};
+
+static pxa2xx_audio_ops_t palmte2_ac97_pdata = {
+	.codec_pdata	= { &palmte2_wm97xx_pdata, },
+};
+
 static struct palm27x_asoc_info palmte2_asoc_pdata = {
 	.jack_gpio	= GPIO_NR_PALMTE2_EARPHONE_DETECT,
 };
@@ -376,9 +381,8 @@ static void __init palmte2_init(void)
 	set_pxa_fb_info(&palmte2_lcd_screen);
 	pxa_set_mci_info(&palmte2_mci_platform_data);
 	palmte2_udc_init();
-	pxa_set_ac97_info(NULL);
+	pxa_set_ac97_info(&palmte2_ac97_pdata);
 	pxa_set_ficp_info(&palmte2_ficp_platform_data);
-	wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
 
 	platform_add_devices(devices, ARRAY_SIZE(devices));
 }
diff --git a/arch/arm/mach-pxa/palmtx.c b/arch/arm/mach-pxa/palmtx.c
index f1e248c..554b3da 100644
--- a/arch/arm/mach-pxa/palmtx.c
+++ b/arch/arm/mach-pxa/palmtx.c
@@ -25,7 +25,7 @@
 #include <linux/pda_power.h>
 #include <linux/pwm_backlight.h>
 #include <linux/gpio.h>
-#include <linux/wm97xx_batt.h>
+#include <linux/wm97xx.h>
 #include <linux/power_supply.h>
 #include <linux/usb/gpio_vbus.h>
 #include <linux/mtd/nand.h>
@@ -340,9 +340,9 @@ static struct platform_device power_supply = {
 };
 
 /******************************************************************************
- * WM97xx battery
+ * WM97xx audio, battery
  ******************************************************************************/
-static struct wm97xx_batt_info wm97xx_batt_pdata = {
+static struct wm97xx_batt_pdata palmtx_batt_pdata = {
 	.batt_aux	= WM97XX_AUX_ID3,
 	.temp_aux	= WM97XX_AUX_ID2,
 	.charge_gpio	= -1,
@@ -356,15 +356,17 @@ static struct wm97xx_batt_info wm97xx_batt_pdata = {
 	.batt_name	= "main-batt",
 };
 
-/******************************************************************************
- * aSoC audio
- ******************************************************************************/
-static struct palm27x_asoc_info palmtx_asoc_pdata = {
-	.jack_gpio	= GPIO_NR_PALMTX_EARPHONE_DETECT,
+static struct wm97xx_pdata palmtx_wm97xx_pdata = {
+	.batt_pdata	= &palmtx_batt_pdata,
 };
 
 static pxa2xx_audio_ops_t palmtx_ac97_pdata = {
 	.reset_gpio	= 95,
+	.codec_pdata	= { &palmtx_wm97xx_pdata, },
+};
+
+static struct palm27x_asoc_info palmtx_asoc_pdata = {
+	.jack_gpio	= GPIO_NR_PALMTX_EARPHONE_DETECT,
 };
 
 static struct platform_device palmtx_asoc = {
@@ -538,7 +540,6 @@ static void __init palmtx_init(void)
 	pxa_set_ac97_info(&palmtx_ac97_pdata);
 	pxa_set_ficp_info(&palmtx_ficp_platform_data);
 	pxa_set_keypad_info(&palmtx_keypad_platform_data);
-	wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
 
 	platform_add_devices(devices, ARRAY_SIZE(devices));
 }
diff --git a/arch/arm/mach-pxa/palmz72.c b/arch/arm/mach-pxa/palmz72.c
index c2bf493..b769447 100644
--- a/arch/arm/mach-pxa/palmz72.c
+++ b/arch/arm/mach-pxa/palmz72.c
@@ -27,7 +27,7 @@
 #include <linux/pda_power.h>
 #include <linux/pwm_backlight.h>
 #include <linux/gpio.h>
-#include <linux/wm97xx_batt.h>
+#include <linux/wm97xx.h>
 #include <linux/power_supply.h>
 #include <linux/usb/gpio_vbus.h>
 
@@ -343,9 +343,9 @@ static struct platform_device power_supply = {
 };
 
 /******************************************************************************
- * WM97xx battery
+ * WM97xx audio, battery
  ******************************************************************************/
-static struct wm97xx_batt_info wm97xx_batt_pdata = {
+static struct wm97xx_batt_info palmz72_batt_pdata = {
 	.batt_aux	= WM97XX_AUX_ID3,
 	.temp_aux	= WM97XX_AUX_ID2,
 	.charge_gpio	= -1,
@@ -359,9 +359,14 @@ static struct wm97xx_batt_info wm97xx_batt_pdata = {
 	.batt_name	= "main-batt",
 };
 
-/******************************************************************************
- * aSoC audio
- ******************************************************************************/
+static struct wm97xx_pdata palmz72_wm97xx_pdata = {
+	.batt_pdata	= &palmz72_batt_pdata,
+};
+
+static pxa2xx_audio_ops_t palmz72_ac97_pdata = {
+	.codec_pdata	= { &palmz72_wm97xx_pdata, },
+};
+
 static struct platform_device palmz72_asoc = {
 	.name = "palm27x-asoc",
 	.id   = -1,
@@ -494,10 +499,9 @@ static void __init palmz72_init(void)
 	set_pxa_fb_info(&palmz72_lcd_screen);
 	pxa_set_mci_info(&palmz72_mci_platform_data);
 	palmz72_udc_init();
-	pxa_set_ac97_info(NULL);
+	pxa_set_ac97_info(&palmz72_ac97_pdata);
 	pxa_set_ficp_info(&palmz72_ficp_platform_data);
 	pxa_set_keypad_info(&palmz72_keypad_platform_data);
-	wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
 
 	platform_add_devices(devices, ARRAY_SIZE(devices));
 }
diff --git a/arch/arm/mach-pxa/treo680.c b/arch/arm/mach-pxa/treo680.c
index f537265..f9acb12 100644
--- a/arch/arm/mach-pxa/treo680.c
+++ b/arch/arm/mach-pxa/treo680.c
@@ -19,7 +19,6 @@
 #include <linux/pda_power.h>
 #include <linux/pwm_backlight.h>
 #include <linux/gpio.h>
-#include <linux/wm97xx_batt.h>
 #include <linux/power_supply.h>
 #include <linux/sysdev.h>
 #include <linux/w1-gpio.h>
-- 
1.6.3.3


[-- Attachment #3: Type: text/plain, Size: 160 bytes --]

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* Re: [PATCH] Allow passing platform_data to devices attached to AC97 bus
  2009-07-21 19:51           ` Marek Vasut
@ 2009-07-22 10:40             ` Mark Brown
  2009-07-22 10:59               ` [PATCH 1/4] " Marek Vasut
  0 siblings, 1 reply; 52+ messages in thread
From: Mark Brown @ 2009-07-22 10:40 UTC (permalink / raw)
  To: Marek Vasut
  Cc: Takashi Iwai, Russell King - ARM Linux, alsa-devel, Eric Miao,
	linux-arm-kernel

On Tue, Jul 21, 2009 at 09:51:05PM +0200, Marek Vasut wrote:

> Ok, this one should be better then? Mark, thanks for guiding me :-)

There's so many patches flying around here that I've completely lost
track of what the current state of play is.  Could you please repost as
a new patch series, ideally as a normal submission with meaningful per
patch subject headers.

^ permalink raw reply	[flat|nested] 52+ messages in thread

* [PATCH 1/4] Allow passing platform_data to devices attached to AC97 bus
  2009-07-22 10:40             ` Mark Brown
@ 2009-07-22 10:59               ` Marek Vasut
  2009-07-23 10:16                 ` Mark Brown
  0 siblings, 1 reply; 52+ messages in thread
From: Marek Vasut @ 2009-07-22 10:59 UTC (permalink / raw)
  To: Mark Brown
  Cc: Takashi Iwai, Russell King - ARM Linux, alsa-devel, Eric Miao,
	linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 447 bytes --]

Dne St 22. července 2009 12:40:29 Mark Brown napsal(a):
> On Tue, Jul 21, 2009 at 09:51:05PM +0200, Marek Vasut wrote:
> > Ok, this one should be better then? Mark, thanks for guiding me :-)
>
> There's so many patches flying around here that I've completely lost
> track of what the current state of play is.  Could you please repost as
> a new patch series, ideally as a normal submission with meaningful per
> patch subject headers.


[-- Attachment #2: 0001-Allow-passing-platform_data-to-devices-attached-to-A.patch --]
[-- Type: text/x-patch, Size: 2332 bytes --]

From 5ed7859b282c23c2f98167ef3f821625ee8907aa Mon Sep 17 00:00:00 2001
From: Marek Vasut <marek.vasut@gmail.com>
Date: Tue, 21 Jul 2009 16:22:29 +0200
Subject: [PATCH 1/4] Allow passing platform_data to devices attached to AC97 bus

This patch allows passing platform_data to devices attached to AC97 bus
(like touchscreens, battery measurement chips ...).

Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
---
 include/sound/ac97_codec.h |    6 ++++++
 include/sound/soc-dai.h    |    1 +
 sound/soc/soc-core.c       |    6 +++++-
 3 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/include/sound/ac97_codec.h b/include/sound/ac97_codec.h
index 251fc1c..9b1c098 100644
--- a/include/sound/ac97_codec.h
+++ b/include/sound/ac97_codec.h
@@ -642,4 +642,10 @@ int snd_ac97_pcm_double_rate_rules(struct snd_pcm_runtime *runtime);
 /* ad hoc AC97 device driver access */
 extern struct bus_type ac97_bus_type;
 
+/* AC97 platform_data adding function */
+static inline void snd_ac97_dev_add_pdata(struct snd_ac97 *ac97, void *data)
+{
+	ac97->dev.platform_data = data;
+}
+
 #endif /* __SOUND_AC97_CODEC_H */
diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index 352d7ee..0d65a03 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -179,6 +179,7 @@ struct snd_soc_dai {
 	int ac97_control;
 
 	struct device *dev;
+	void *ac97_pdata;	/* platform_data for the ac97 codec */
 
 	/* DAI callbacks */
 	int (*probe)(struct platform_device *pdev,
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 1d70829..7cb0917 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -28,6 +28,7 @@
 #include <linux/bitops.h>
 #include <linux/debugfs.h>
 #include <linux/platform_device.h>
+#include <sound/ac97_codec.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
@@ -1381,8 +1382,11 @@ int snd_soc_init_card(struct snd_soc_device *socdev)
 				continue;
 			}
 		}
-		if (card->dai_link[i].codec_dai->ac97_control)
+		if (card->dai_link[i].codec_dai->ac97_control) {
 			ac97 = 1;
+			snd_ac97_dev_add_pdata(codec->ac97,
+				card->dai_link[i].cpu_dai->ac97_pdata);
+		}
 	}
 	snprintf(codec->card->shortname, sizeof(codec->card->shortname),
 		 "%s",  card->name);
-- 
1.6.3.3


[-- Attachment #3: Type: text/plain, Size: 160 bytes --]

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH 1/4] Allow passing platform_data to devices attached to AC97 bus
  2009-07-21 22:34                   ` Anton Vorontsov
  2009-07-21 22:43                     ` Marek Vasut
@ 2009-07-22 11:01                     ` Marek Vasut
  2009-07-22 11:02                       ` [PATCH 2/4] Allow passing platform_data for pxa2xx-ac97 Marek Vasut
                                         ` (2 more replies)
  1 sibling, 3 replies; 52+ messages in thread
From: Marek Vasut @ 2009-07-22 11:01 UTC (permalink / raw)
  To: avorontsov
  Cc: alsa-devel, Russell King - ARM Linux, Takashi Iwai,
	Robert Jarzmik, Mark Brown, cbou, Eric Miao, dwmw2,
	linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 30 bytes --]

Ok,
Im sending the set again.

[-- Attachment #2: 0001-Allow-passing-platform_data-to-devices-attached-to-A.patch --]
[-- Type: text/x-patch, Size: 2332 bytes --]

From 5ed7859b282c23c2f98167ef3f821625ee8907aa Mon Sep 17 00:00:00 2001
From: Marek Vasut <marek.vasut@gmail.com>
Date: Tue, 21 Jul 2009 16:22:29 +0200
Subject: [PATCH 1/4] Allow passing platform_data to devices attached to AC97 bus

This patch allows passing platform_data to devices attached to AC97 bus
(like touchscreens, battery measurement chips ...).

Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
---
 include/sound/ac97_codec.h |    6 ++++++
 include/sound/soc-dai.h    |    1 +
 sound/soc/soc-core.c       |    6 +++++-
 3 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/include/sound/ac97_codec.h b/include/sound/ac97_codec.h
index 251fc1c..9b1c098 100644
--- a/include/sound/ac97_codec.h
+++ b/include/sound/ac97_codec.h
@@ -642,4 +642,10 @@ int snd_ac97_pcm_double_rate_rules(struct snd_pcm_runtime *runtime);
 /* ad hoc AC97 device driver access */
 extern struct bus_type ac97_bus_type;
 
+/* AC97 platform_data adding function */
+static inline void snd_ac97_dev_add_pdata(struct snd_ac97 *ac97, void *data)
+{
+	ac97->dev.platform_data = data;
+}
+
 #endif /* __SOUND_AC97_CODEC_H */
diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index 352d7ee..0d65a03 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -179,6 +179,7 @@ struct snd_soc_dai {
 	int ac97_control;
 
 	struct device *dev;
+	void *ac97_pdata;	/* platform_data for the ac97 codec */
 
 	/* DAI callbacks */
 	int (*probe)(struct platform_device *pdev,
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 1d70829..7cb0917 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -28,6 +28,7 @@
 #include <linux/bitops.h>
 #include <linux/debugfs.h>
 #include <linux/platform_device.h>
+#include <sound/ac97_codec.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
@@ -1381,8 +1382,11 @@ int snd_soc_init_card(struct snd_soc_device *socdev)
 				continue;
 			}
 		}
-		if (card->dai_link[i].codec_dai->ac97_control)
+		if (card->dai_link[i].codec_dai->ac97_control) {
 			ac97 = 1;
+			snd_ac97_dev_add_pdata(codec->ac97,
+				card->dai_link[i].cpu_dai->ac97_pdata);
+		}
 	}
 	snprintf(codec->card->shortname, sizeof(codec->card->shortname),
 		 "%s",  card->name);
-- 
1.6.3.3


[-- Attachment #3: Type: text/plain, Size: 160 bytes --]

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH 2/4] Allow passing platform_data for pxa2xx-ac97
  2009-07-22 11:01                     ` [PATCH 1/4] " Marek Vasut
@ 2009-07-22 11:02                       ` Marek Vasut
  2009-07-23 10:27                         ` Mark Brown
  2009-07-22 11:04                       ` [PATCH 3/4] Convert WM97xx driver to use platform_data Marek Vasut
  2009-07-22 11:05                       ` [PATCH 4/4] Convert all platforms to pass platform_data to wm97xx battery Marek Vasut
  2 siblings, 1 reply; 52+ messages in thread
From: Marek Vasut @ 2009-07-22 11:02 UTC (permalink / raw)
  To: avorontsov
  Cc: alsa-devel, Russell King - ARM Linux, Takashi Iwai,
	Robert Jarzmik, Mark Brown, cbou, Eric Miao, dwmw2,
	linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 95 bytes --]

Dne St 22. července 2009 13:01:03 Marek Vasut napsal(a):
> Ok,
> Im sending the set again.

[-- Attachment #2: 0002-Allow-passing-platform_data-for-pxa2xx-ac97.patch --]
[-- Type: text/x-patch, Size: 3731 bytes --]

From 76c511499fa6115cdd7dd4c2fbf436b38cb7b8a1 Mon Sep 17 00:00:00 2001
From: Marek Vasut <marek.vasut@gmail.com>
Date: Tue, 21 Jul 2009 16:22:29 +0200
Subject: [PATCH 2/4] 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>
---
 arch/arm/mach-pxa/include/mach/audio.h |    3 +++
 include/sound/ac97_codec.h             |    3 +++
 sound/arm/pxa2xx-ac97.c                |    3 +++
 sound/soc/pxa/pxa2xx-ac97.c            |    7 ++++++-
 4 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-pxa/include/mach/audio.h b/arch/arm/mach-pxa/include/mach/audio.h
index 16eb025..a3449e3 100644
--- a/arch/arm/mach-pxa/include/mach/audio.h
+++ b/arch/arm/mach-pxa/include/mach/audio.h
@@ -3,10 +3,12 @@
 
 #include <sound/core.h>
 #include <sound/pcm.h>
+#include <sound/ac97_codec.h>
 
 /*
  * @reset_gpio: AC97 reset gpio (normally gpio113 or gpio95)
  *              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
  * bug prevents correct operation of the reset line. If not specified,
@@ -20,6 +22,7 @@ typedef struct {
 	void (*resume)(void *);
 	void *priv;
 	int reset_gpio;
+	void *codec_pdata[AC97_BUS_MAX_DEVICES];
 } pxa2xx_audio_ops_t;
 
 extern void pxa_set_ac97_info(pxa2xx_audio_ops_t *ops);
diff --git a/include/sound/ac97_codec.h b/include/sound/ac97_codec.h
index 9b1c098..3dae3f7 100644
--- a/include/sound/ac97_codec.h
+++ b/include/sound/ac97_codec.h
@@ -32,6 +32,9 @@
 #include "control.h"
 #include "info.h"
 
+/* maximum number of devices on the AC97 bus */
+#define	AC97_BUS_MAX_DEVICES	4
+
 /*
  *  AC'97 codec registers
  */
diff --git a/sound/arm/pxa2xx-ac97.c b/sound/arm/pxa2xx-ac97.c
index c570ebd..cfab74e 100644
--- a/sound/arm/pxa2xx-ac97.c
+++ b/sound/arm/pxa2xx-ac97.c
@@ -170,6 +170,8 @@ static int __devinit pxa2xx_ac97_probe(struct platform_device *dev)
 	struct snd_ac97_bus *ac97_bus;
 	struct snd_ac97_template ac97_template;
 	int ret;
+	pxa2xx_audio_ops_t *pdata = dev->dev.platform_data;
+	int id = dev->id < 0 ? 0 : dev->id;
 
 	ret = snd_card_create(SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
 			      THIS_MODULE, 0, &card);
@@ -200,6 +202,7 @@ static int __devinit pxa2xx_ac97_probe(struct platform_device *dev)
 	snprintf(card->longname, sizeof(card->longname),
 		 "%s (%s)", dev->dev.driver->name, card->mixername);
 
+	snd_ac97_dev_add_pdata(ac97_bus->codec[id], pdata->codec_pdata[id]);
 	snd_card_set_dev(card, &dev->dev);
 	ret = snd_card_register(card);
 	if (ret == 0) {
diff --git a/sound/soc/pxa/pxa2xx-ac97.c b/sound/soc/pxa/pxa2xx-ac97.c
index d9c94d7..dea18ee 100644
--- a/sound/soc/pxa/pxa2xx-ac97.c
+++ b/sound/soc/pxa/pxa2xx-ac97.c
@@ -22,6 +22,7 @@
 #include <mach/hardware.h>
 #include <mach/regs-ac97.h>
 #include <mach/dma.h>
+#include <mach/audio.h>
 
 #include "pxa2xx-pcm.h"
 #include "pxa2xx-ac97.h"
@@ -241,9 +242,13 @@ EXPORT_SYMBOL_GPL(soc_ac97_ops);
 static int __devinit pxa2xx_ac97_dev_probe(struct platform_device *pdev)
 {
 	int i;
+	pxa2xx_audio_ops_t *pdata = pdev->dev.platform_data;
 
-	for (i = 0; i < ARRAY_SIZE(pxa_ac97_dai); i++)
+	for (i = 0; i < ARRAY_SIZE(pxa_ac97_dai); i++) {
 		pxa_ac97_dai[i].dev = &pdev->dev;
+		pxa_ac97_dai[i].ac97_pdata = pdata->codec_pdata
+					[pdev->id < 0 ? 0 : pdev->id];
+	}
 
 	/* 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
-- 
1.6.3.3


[-- Attachment #3: Type: text/plain, Size: 160 bytes --]

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH 3/4] Convert WM97xx driver to use platform_data
  2009-07-22 11:01                     ` [PATCH 1/4] " Marek Vasut
  2009-07-22 11:02                       ` [PATCH 2/4] Allow passing platform_data for pxa2xx-ac97 Marek Vasut
@ 2009-07-22 11:04                       ` Marek Vasut
  2009-07-23 11:49                         ` Mark Brown
  2009-07-24 19:44                         ` Robert Jarzmik
  2009-07-22 11:05                       ` [PATCH 4/4] Convert all platforms to pass platform_data to wm97xx battery Marek Vasut
  2 siblings, 2 replies; 52+ messages in thread
From: Marek Vasut @ 2009-07-22 11:04 UTC (permalink / raw)
  To: avorontsov
  Cc: alsa-devel, Russell King - ARM Linux, Takashi Iwai,
	Robert Jarzmik, Mark Brown, cbou, Eric Miao, dwmw2,
	linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 141 bytes --]

Dne St 22. července 2009 13:01:03 Marek Vasut napsal(a):
> Ok,
> Im sending the set again.

This one should be acked by Anton already.

[-- Attachment #2: 0003-Convert-WM97xx-driver-to-use-platform_data.patch --]
[-- Type: text/x-patch, Size: 8370 bytes --]

From 54febe82847aeef3fcc02a074fd9d21def97f174 Mon Sep 17 00:00:00 2001
From: Marek Vasut <marek.vasut@gmail.com>
Date: Tue, 21 Jul 2009 18:52:28 +0200
Subject: [PATCH 3/4] Convert WM97xx driver to use platform_data

This patch converts the wm97xx driver to use platform_data supplied by
ac97 bus. Also, this fixes the related wm97xx-battery driver to use
it's platform_data and prepares a structure for touchscreen driver.

Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
---
 drivers/input/touchscreen/wm97xx-core.c |    3 ++
 drivers/power/wm97xx_battery.c          |   55 ++++++++++++++++++++++--------
 include/linux/wm97xx.h                  |   18 ++++++++++
 include/linux/wm97xx_batt.h             |   26 --------------
 4 files changed, 61 insertions(+), 41 deletions(-)
 delete mode 100644 include/linux/wm97xx_batt.h

diff --git a/drivers/input/touchscreen/wm97xx-core.c b/drivers/input/touchscreen/wm97xx-core.c
index 252eb11..f944918 100644
--- a/drivers/input/touchscreen/wm97xx-core.c
+++ b/drivers/input/touchscreen/wm97xx-core.c
@@ -561,6 +561,7 @@ static void wm97xx_ts_input_close(struct input_dev *idev)
 static int wm97xx_probe(struct device *dev)
 {
 	struct wm97xx *wm;
+	struct wm97xx_pdata *pdata = dev->platform_data;
 	int ret = 0, id = 0;
 
 	wm = kzalloc(sizeof(struct wm97xx), GFP_KERNEL);
@@ -658,6 +659,7 @@ static int wm97xx_probe(struct device *dev)
 	}
 	platform_set_drvdata(wm->battery_dev, wm);
 	wm->battery_dev->dev.parent = dev;
+	wm->battery_dev->dev.platform_data = pdata;
 	ret = platform_device_add(wm->battery_dev);
 	if (ret < 0)
 		goto batt_reg_err;
@@ -671,6 +673,7 @@ static int wm97xx_probe(struct device *dev)
 	}
 	platform_set_drvdata(wm->touch_dev, wm);
 	wm->touch_dev->dev.parent = dev;
+	wm->touch_dev->dev.platform_data = pdata;
 	ret = platform_device_add(wm->touch_dev);
 	if (ret < 0)
 		goto touch_reg_err;
diff --git a/drivers/power/wm97xx_battery.c b/drivers/power/wm97xx_battery.c
index 8bde921..f31cad9 100644
--- a/drivers/power/wm97xx_battery.c
+++ b/drivers/power/wm97xx_battery.c
@@ -22,17 +22,19 @@
 #include <linux/spinlock.h>
 #include <linux/interrupt.h>
 #include <linux/gpio.h>
-#include <linux/wm97xx_batt.h>
+#include <linux/irq.h>
 
 static DEFINE_MUTEX(bat_lock);
 static struct work_struct bat_work;
 struct mutex work_lock;
 static int bat_status = POWER_SUPPLY_STATUS_UNKNOWN;
-static struct wm97xx_batt_info *pdata;
 static enum power_supply_property *prop;
 
 static unsigned long wm97xx_read_bat(struct power_supply *bat_ps)
 {
+	struct wm97xx_pdata *wmdata = bat_ps->dev->parent->platform_data;
+	struct wm97xx_batt_pdata *pdata = wmdata->batt_pdata;
+
 	return wm97xx_read_aux_adc(bat_ps->dev->parent->driver_data,
 					pdata->batt_aux) * pdata->batt_mult /
 					pdata->batt_div;
@@ -40,6 +42,9 @@ static unsigned long wm97xx_read_bat(struct power_supply *bat_ps)
 
 static unsigned long wm97xx_read_temp(struct power_supply *bat_ps)
 {
+	struct wm97xx_pdata *wmdata = bat_ps->dev->parent->platform_data;
+	struct wm97xx_batt_pdata *pdata = wmdata->batt_pdata;
+
 	return wm97xx_read_aux_adc(bat_ps->dev->parent->driver_data,
 					pdata->temp_aux) * pdata->temp_mult /
 					pdata->temp_div;
@@ -49,6 +54,9 @@ static int wm97xx_bat_get_property(struct power_supply *bat_ps,
 			    enum power_supply_property psp,
 			    union power_supply_propval *val)
 {
+	struct wm97xx_pdata *wmdata = bat_ps->dev->parent->platform_data;
+	struct wm97xx_batt_pdata *pdata = wmdata->batt_pdata;
+
 	switch (psp) {
 	case POWER_SUPPLY_PROP_STATUS:
 		val->intval = bat_status;
@@ -97,6 +105,7 @@ static void wm97xx_bat_external_power_changed(struct power_supply *bat_ps)
 static void wm97xx_bat_update(struct power_supply *bat_ps)
 {
 	int old_status = bat_status;
+	struct wm97xx_batt_pdata *pdata = dev_get_drvdata(bat_ps->dev->parent);
 
 	mutex_lock(&work_lock);
 
@@ -127,6 +136,12 @@ static void wm97xx_bat_work(struct work_struct *work)
 	wm97xx_bat_update(&bat_ps);
 }
 
+static irqreturn_t wm97xx_chrg_irq(int irq, void *data)
+{
+	schedule_work(&bat_work);
+	return IRQ_HANDLED;
+}
+
 #ifdef CONFIG_PM
 static int wm97xx_bat_suspend(struct platform_device *dev, pm_message_t state)
 {
@@ -149,6 +164,8 @@ static int __devinit wm97xx_bat_probe(struct platform_device *dev)
 	int ret = 0;
 	int props = 1;	/* POWER_SUPPLY_PROP_PRESENT */
 	int i = 0;
+	struct wm97xx_pdata *wmdata = dev->dev.platform_data;
+	struct wm97xx_batt_pdata *pdata = wmdata->batt_pdata;
 
 	if (dev->id != -1)
 		return -EINVAL;
@@ -156,17 +173,22 @@ static int __devinit wm97xx_bat_probe(struct platform_device *dev)
 	mutex_init(&work_lock);
 
 	if (!pdata) {
-		dev_err(&dev->dev, "Please use wm97xx_bat_set_pdata\n");
+		dev_err(&dev->dev, "No platform_data supplied\n");
 		return -EINVAL;
 	}
 
-	if (pdata->charge_gpio >= 0 && gpio_is_valid(pdata->charge_gpio)) {
+	if (gpio_is_valid(pdata->charge_gpio)) {
 		ret = gpio_request(pdata->charge_gpio, "BATT CHRG");
 		if (ret)
 			goto err;
 		ret = gpio_direction_input(pdata->charge_gpio);
 		if (ret)
 			goto err2;
+		ret = request_irq(gpio_to_irq(pdata->charge_gpio),
+				wm97xx_chrg_irq, IRQF_DISABLED,
+				"AC Detect", 0);
+		if (ret)
+			goto err2;
 		props++;	/* POWER_SUPPLY_PROP_STATUS */
 	}
 
@@ -183,7 +205,7 @@ static int __devinit wm97xx_bat_probe(struct platform_device *dev)
 
 	prop = kzalloc(props * sizeof(*prop), GFP_KERNEL);
 	if (!prop)
-		goto err2;
+		goto err3;
 
 	prop[i++] = POWER_SUPPLY_PROP_PRESENT;
 	if (pdata->charge_gpio >= 0)
@@ -216,21 +238,30 @@ static int __devinit wm97xx_bat_probe(struct platform_device *dev)
 	if (!ret)
 		schedule_work(&bat_work);
 	else
-		goto err3;
+		goto err4;
 
 	return 0;
-err3:
+err4:
 	kfree(prop);
+err3:
+	if (gpio_is_valid(pdata->charge_gpio))
+		free_irq(gpio_to_irq(pdata->charge_gpio), dev);
 err2:
-	gpio_free(pdata->charge_gpio);
+	if (gpio_is_valid(pdata->charge_gpio))
+		gpio_free(pdata->charge_gpio);
 err:
 	return ret;
 }
 
 static int __devexit wm97xx_bat_remove(struct platform_device *dev)
 {
-	if (pdata && pdata->charge_gpio && pdata->charge_gpio >= 0)
+	struct wm97xx_pdata *wmdata = dev->dev.platform_data;
+	struct wm97xx_batt_pdata *pdata = wmdata->batt_pdata;
+
+	if (pdata && gpio_is_valid(pdata->charge_gpio)) {
+		free_irq(gpio_to_irq(pdata->charge_gpio), dev);
 		gpio_free(pdata->charge_gpio);
+	}
 	flush_scheduled_work();
 	power_supply_unregister(&bat_ps);
 	kfree(prop);
@@ -258,12 +289,6 @@ static void __exit wm97xx_bat_exit(void)
 	platform_driver_unregister(&wm97xx_bat_driver);
 }
 
-void __init wm97xx_bat_set_pdata(struct wm97xx_batt_info *data)
-{
-	pdata = data;
-}
-EXPORT_SYMBOL_GPL(wm97xx_bat_set_pdata);
-
 module_init(wm97xx_bat_init);
 module_exit(wm97xx_bat_exit);
 
diff --git a/include/linux/wm97xx.h b/include/linux/wm97xx.h
index 0c98781..38e8c4d 100644
--- a/include/linux/wm97xx.h
+++ b/include/linux/wm97xx.h
@@ -293,6 +293,24 @@ struct wm97xx {
 	u16 suspend_mode;               /* PRP in suspend mode */
 };
 
+struct wm97xx_batt_pdata {
+	int	batt_aux;
+	int	temp_aux;
+	int	charge_gpio;
+	int	min_voltage;
+	int	max_voltage;
+	int	batt_div;
+	int	batt_mult;
+	int	temp_div;
+	int	temp_mult;
+	int	batt_tech;
+	char	*batt_name;
+};
+
+struct wm97xx_pdata {
+	struct wm97xx_batt_pdata	*batt_pdata;	/* battery data */
+};
+
 /*
  * Codec GPIO access (not supported on WM9705)
  * This can be used to set/get codec GPIO and Virtual GPIO status.
diff --git a/include/linux/wm97xx_batt.h b/include/linux/wm97xx_batt.h
deleted file mode 100644
index 9681d1a..0000000
--- a/include/linux/wm97xx_batt.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#ifndef _LINUX_WM97XX_BAT_H
-#define _LINUX_WM97XX_BAT_H
-
-#include <linux/wm97xx.h>
-
-struct wm97xx_batt_info {
-	int	batt_aux;
-	int	temp_aux;
-	int	charge_gpio;
-	int	min_voltage;
-	int	max_voltage;
-	int	batt_div;
-	int	batt_mult;
-	int	temp_div;
-	int	temp_mult;
-	int	batt_tech;
-	char	*batt_name;
-};
-
-#ifdef CONFIG_BATTERY_WM97XX
-void __init wm97xx_bat_set_pdata(struct wm97xx_batt_info *data);
-#else
-static inline void wm97xx_bat_set_pdata(struct wm97xx_batt_info *data) {}
-#endif
-
-#endif
-- 
1.6.3.3


[-- Attachment #3: Type: text/plain, Size: 160 bytes --]

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* [PATCH 4/4] Convert all platforms to pass platform_data to wm97xx battery
  2009-07-22 11:01                     ` [PATCH 1/4] " Marek Vasut
  2009-07-22 11:02                       ` [PATCH 2/4] Allow passing platform_data for pxa2xx-ac97 Marek Vasut
  2009-07-22 11:04                       ` [PATCH 3/4] Convert WM97xx driver to use platform_data Marek Vasut
@ 2009-07-22 11:05                       ` Marek Vasut
  2009-07-22 18:09                         ` Robert Jarzmik
  2 siblings, 1 reply; 52+ messages in thread
From: Marek Vasut @ 2009-07-22 11:05 UTC (permalink / raw)
  To: avorontsov
  Cc: alsa-devel, Russell King - ARM Linux, Takashi Iwai,
	Robert Jarzmik, Mark Brown, cbou, Eric Miao, dwmw2,
	linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 247 bytes --]

Dne St 22. července 2009 13:01:03 Marek Vasut napsal(a):
> Ok,
> Im sending the set again.
And this does the platform conversion. Depends on 3/4 and should be Acked by 
Robert. So please.

Thanks for your patience (especially yours, Mark)

[-- Attachment #2: 0004-Convert-all-platforms-to-pass-platform_data-to-wm97x.patch --]
[-- Type: text/x-patch, Size: 11915 bytes --]

From 0ccf06e47672e0cc1795c18c701b6db79bdc2eea Mon Sep 17 00:00:00 2001
From: Marek Vasut <marek.vasut@gmail.com>
Date: Tue, 21 Jul 2009 19:22:13 +0200
Subject: [PATCH 4/4] Convert all platforms to pass platform_data to wm97xx battery

Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
---
 arch/arm/mach-pxa/mioa701.c |    7 ++++++-
 arch/arm/mach-pxa/palmld.c  |   19 ++++++++++---------
 arch/arm/mach-pxa/palmt5.c  |   19 ++++++++++---------
 arch/arm/mach-pxa/palmte2.c |   20 ++++++++++++--------
 arch/arm/mach-pxa/palmtx.c  |   19 ++++++++++---------
 arch/arm/mach-pxa/palmz72.c |   20 ++++++++++++--------
 arch/arm/mach-pxa/treo680.c |    1 -
 7 files changed, 60 insertions(+), 45 deletions(-)

diff --git a/arch/arm/mach-pxa/mioa701.c b/arch/arm/mach-pxa/mioa701.c
index 3cab452..803917d 100644
--- a/arch/arm/mach-pxa/mioa701.c
+++ b/arch/arm/mach-pxa/mioa701.c
@@ -34,7 +34,7 @@
 #include <linux/irq.h>
 #include <linux/pda_power.h>
 #include <linux/power_supply.h>
-#include <linux/wm97xx_batt.h>
+#include <linux/wm97xx.h>
 #include <linux/mtd/physmap.h>
 #include <linux/usb/gpio_vbus.h>
 #include <linux/regulator/max1586.h>
@@ -660,6 +660,10 @@ static struct wm97xx_batt_info mioa701_battery_data = {
 	.batt_name	= "mioa701_battery",
 };
 
+static struct wm97xx_pdata mioa701_wm97xx_pdata = {
+	.batt_pdata	= &mioa701_battery_data,
+};
+
 /*
  * Voltage regulation
  */
@@ -728,6 +732,7 @@ struct i2c_pxa_platform_data i2c_pdata = {
 
 static pxa2xx_audio_ops_t mioa701_ac97_info = {
 	.reset_gpio = 95,
+	.codec_pdata = { &mioa701_wm97xx_pdata, },
 };
 
 /*
diff --git a/arch/arm/mach-pxa/palmld.c b/arch/arm/mach-pxa/palmld.c
index 1ad029d..bcf5b46 100644
--- a/arch/arm/mach-pxa/palmld.c
+++ b/arch/arm/mach-pxa/palmld.c
@@ -22,7 +22,7 @@
 #include <linux/pda_power.h>
 #include <linux/pwm_backlight.h>
 #include <linux/gpio.h>
-#include <linux/wm97xx_batt.h>
+#include <linux/wm97xx.h>
 #include <linux/power_supply.h>
 #include <linux/sysdev.h>
 #include <linux/mtd/mtd.h>
@@ -406,9 +406,9 @@ static struct platform_device power_supply = {
 };
 
 /******************************************************************************
- * WM97xx battery
+ * WM97xx audio, battery
  ******************************************************************************/
-static struct wm97xx_batt_info wm97xx_batt_pdata = {
+static struct wm97xx_batt_pdata palmld_batt_pdata = {
 	.batt_aux	= WM97XX_AUX_ID3,
 	.temp_aux	= WM97XX_AUX_ID2,
 	.charge_gpio	= -1,
@@ -422,15 +422,17 @@ static struct wm97xx_batt_info wm97xx_batt_pdata = {
 	.batt_name	= "main-batt",
 };
 
-/******************************************************************************
- * aSoC audio
- ******************************************************************************/
-static struct palm27x_asoc_info palmld_asoc_pdata = {
-	.jack_gpio	= GPIO_NR_PALMLD_EARPHONE_DETECT,
+static struct wm97xx_pdata palmld_wm97xx_pdata = {
+	.batt_pdata	= &palmld_batt_pdata,
 };
 
 static pxa2xx_audio_ops_t palmld_ac97_pdata = {
 	.reset_gpio	= 95,
+	.codec_pdata	= { &palmld_wm97xx_pdata, },
+};
+
+static struct palm27x_asoc_info palmld_asoc_pdata = {
+	.jack_gpio	= GPIO_NR_PALMLD_EARPHONE_DETECT,
 };
 
 static struct platform_device palmld_asoc = {
@@ -536,7 +538,6 @@ static void __init palmld_init(void)
 	pxa_set_ac97_info(&palmld_ac97_pdata);
 	pxa_set_ficp_info(&palmld_ficp_platform_data);
 	pxa_set_keypad_info(&palmld_keypad_platform_data);
-	wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
 
 	platform_add_devices(devices, ARRAY_SIZE(devices));
 }
diff --git a/arch/arm/mach-pxa/palmt5.c b/arch/arm/mach-pxa/palmt5.c
index 2dd7ce2..3e8b21d 100644
--- a/arch/arm/mach-pxa/palmt5.c
+++ b/arch/arm/mach-pxa/palmt5.c
@@ -24,7 +24,7 @@
 #include <linux/pda_power.h>
 #include <linux/pwm_backlight.h>
 #include <linux/gpio.h>
-#include <linux/wm97xx_batt.h>
+#include <linux/wm97xx.h>
 #include <linux/power_supply.h>
 #include <linux/usb/gpio_vbus.h>
 
@@ -317,9 +317,9 @@ static struct platform_device power_supply = {
 };
 
 /******************************************************************************
- * WM97xx battery
+ * WM97xx audio, battery
  ******************************************************************************/
-static struct wm97xx_batt_info wm97xx_batt_pdata = {
+static struct wm97xx_batt_pdata palmt5_batt_pdata = {
 	.batt_aux	= WM97XX_AUX_ID3,
 	.temp_aux	= WM97XX_AUX_ID2,
 	.charge_gpio	= -1,
@@ -333,15 +333,17 @@ static struct wm97xx_batt_info wm97xx_batt_pdata = {
 	.batt_name	= "main-batt",
 };
 
-/******************************************************************************
- * aSoC audio
- ******************************************************************************/
-static struct palm27x_asoc_info palmt5_asoc_pdata = {
-	.jack_gpio	= GPIO_NR_PALMT5_EARPHONE_DETECT,
+static struct wm97xx_pdata palmt5_wm97xx_pdata = {
+	.batt_pdata	= &palmt5_batt_pdata,
 };
 
 static pxa2xx_audio_ops_t palmt5_ac97_pdata = {
 	.reset_gpio	= 95,
+	.codec_pdata	= { &palmt5_wm97xx_pdata, },
+};
+
+static struct palm27x_asoc_info palmt5_asoc_pdata = {
+	.jack_gpio	= GPIO_NR_PALMT5_EARPHONE_DETECT,
 };
 
 static struct platform_device palmt5_asoc = {
@@ -426,7 +428,6 @@ static void __init palmt5_init(void)
 	pxa_set_ac97_info(&palmt5_ac97_pdata);
 	pxa_set_ficp_info(&palmt5_ficp_platform_data);
 	pxa_set_keypad_info(&palmt5_keypad_platform_data);
-	wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
 
 	platform_add_devices(devices, ARRAY_SIZE(devices));
 }
diff --git a/arch/arm/mach-pxa/palmte2.c b/arch/arm/mach-pxa/palmte2.c
index 277c406..21c241b 100644
--- a/arch/arm/mach-pxa/palmte2.c
+++ b/arch/arm/mach-pxa/palmte2.c
@@ -23,7 +23,7 @@
 #include <linux/pda_power.h>
 #include <linux/pwm_backlight.h>
 #include <linux/gpio.h>
-#include <linux/wm97xx_batt.h>
+#include <linux/wm97xx.h>
 #include <linux/power_supply.h>
 #include <linux/usb/gpio_vbus.h>
 
@@ -290,9 +290,9 @@ static struct platform_device power_supply = {
 };
 
 /******************************************************************************
- * WM97xx battery
+ * WM97xx audio, battery
  ******************************************************************************/
-static struct wm97xx_batt_info wm97xx_batt_pdata = {
+static struct wm97xx_batt_info palmte2_batt_pdata = {
 	.batt_aux	= WM97XX_AUX_ID3,
 	.temp_aux	= WM97XX_AUX_ID2,
 	.charge_gpio	= -1,
@@ -306,9 +306,14 @@ static struct wm97xx_batt_info wm97xx_batt_pdata = {
 	.batt_name	= "main-batt",
 };
 
-/******************************************************************************
- * aSoC audio
- ******************************************************************************/
+static struct wm97xx_pdata palmte2_wm97xx_pdata = {
+	.batt_pdata	= &palmte2_batt_pdata,
+};
+
+static pxa2xx_audio_ops_t palmte2_ac97_pdata = {
+	.codec_pdata	= { &palmte2_wm97xx_pdata, },
+};
+
 static struct palm27x_asoc_info palmte2_asoc_pdata = {
 	.jack_gpio	= GPIO_NR_PALMTE2_EARPHONE_DETECT,
 };
@@ -376,9 +381,8 @@ static void __init palmte2_init(void)
 	set_pxa_fb_info(&palmte2_lcd_screen);
 	pxa_set_mci_info(&palmte2_mci_platform_data);
 	palmte2_udc_init();
-	pxa_set_ac97_info(NULL);
+	pxa_set_ac97_info(&palmte2_ac97_pdata);
 	pxa_set_ficp_info(&palmte2_ficp_platform_data);
-	wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
 
 	platform_add_devices(devices, ARRAY_SIZE(devices));
 }
diff --git a/arch/arm/mach-pxa/palmtx.c b/arch/arm/mach-pxa/palmtx.c
index f1e248c..554b3da 100644
--- a/arch/arm/mach-pxa/palmtx.c
+++ b/arch/arm/mach-pxa/palmtx.c
@@ -25,7 +25,7 @@
 #include <linux/pda_power.h>
 #include <linux/pwm_backlight.h>
 #include <linux/gpio.h>
-#include <linux/wm97xx_batt.h>
+#include <linux/wm97xx.h>
 #include <linux/power_supply.h>
 #include <linux/usb/gpio_vbus.h>
 #include <linux/mtd/nand.h>
@@ -340,9 +340,9 @@ static struct platform_device power_supply = {
 };
 
 /******************************************************************************
- * WM97xx battery
+ * WM97xx audio, battery
  ******************************************************************************/
-static struct wm97xx_batt_info wm97xx_batt_pdata = {
+static struct wm97xx_batt_pdata palmtx_batt_pdata = {
 	.batt_aux	= WM97XX_AUX_ID3,
 	.temp_aux	= WM97XX_AUX_ID2,
 	.charge_gpio	= -1,
@@ -356,15 +356,17 @@ static struct wm97xx_batt_info wm97xx_batt_pdata = {
 	.batt_name	= "main-batt",
 };
 
-/******************************************************************************
- * aSoC audio
- ******************************************************************************/
-static struct palm27x_asoc_info palmtx_asoc_pdata = {
-	.jack_gpio	= GPIO_NR_PALMTX_EARPHONE_DETECT,
+static struct wm97xx_pdata palmtx_wm97xx_pdata = {
+	.batt_pdata	= &palmtx_batt_pdata,
 };
 
 static pxa2xx_audio_ops_t palmtx_ac97_pdata = {
 	.reset_gpio	= 95,
+	.codec_pdata	= { &palmtx_wm97xx_pdata, },
+};
+
+static struct palm27x_asoc_info palmtx_asoc_pdata = {
+	.jack_gpio	= GPIO_NR_PALMTX_EARPHONE_DETECT,
 };
 
 static struct platform_device palmtx_asoc = {
@@ -538,7 +540,6 @@ static void __init palmtx_init(void)
 	pxa_set_ac97_info(&palmtx_ac97_pdata);
 	pxa_set_ficp_info(&palmtx_ficp_platform_data);
 	pxa_set_keypad_info(&palmtx_keypad_platform_data);
-	wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
 
 	platform_add_devices(devices, ARRAY_SIZE(devices));
 }
diff --git a/arch/arm/mach-pxa/palmz72.c b/arch/arm/mach-pxa/palmz72.c
index c2bf493..b769447 100644
--- a/arch/arm/mach-pxa/palmz72.c
+++ b/arch/arm/mach-pxa/palmz72.c
@@ -27,7 +27,7 @@
 #include <linux/pda_power.h>
 #include <linux/pwm_backlight.h>
 #include <linux/gpio.h>
-#include <linux/wm97xx_batt.h>
+#include <linux/wm97xx.h>
 #include <linux/power_supply.h>
 #include <linux/usb/gpio_vbus.h>
 
@@ -343,9 +343,9 @@ static struct platform_device power_supply = {
 };
 
 /******************************************************************************
- * WM97xx battery
+ * WM97xx audio, battery
  ******************************************************************************/
-static struct wm97xx_batt_info wm97xx_batt_pdata = {
+static struct wm97xx_batt_info palmz72_batt_pdata = {
 	.batt_aux	= WM97XX_AUX_ID3,
 	.temp_aux	= WM97XX_AUX_ID2,
 	.charge_gpio	= -1,
@@ -359,9 +359,14 @@ static struct wm97xx_batt_info wm97xx_batt_pdata = {
 	.batt_name	= "main-batt",
 };
 
-/******************************************************************************
- * aSoC audio
- ******************************************************************************/
+static struct wm97xx_pdata palmz72_wm97xx_pdata = {
+	.batt_pdata	= &palmz72_batt_pdata,
+};
+
+static pxa2xx_audio_ops_t palmz72_ac97_pdata = {
+	.codec_pdata	= { &palmz72_wm97xx_pdata, },
+};
+
 static struct platform_device palmz72_asoc = {
 	.name = "palm27x-asoc",
 	.id   = -1,
@@ -494,10 +499,9 @@ static void __init palmz72_init(void)
 	set_pxa_fb_info(&palmz72_lcd_screen);
 	pxa_set_mci_info(&palmz72_mci_platform_data);
 	palmz72_udc_init();
-	pxa_set_ac97_info(NULL);
+	pxa_set_ac97_info(&palmz72_ac97_pdata);
 	pxa_set_ficp_info(&palmz72_ficp_platform_data);
 	pxa_set_keypad_info(&palmz72_keypad_platform_data);
-	wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
 
 	platform_add_devices(devices, ARRAY_SIZE(devices));
 }
diff --git a/arch/arm/mach-pxa/treo680.c b/arch/arm/mach-pxa/treo680.c
index f537265..f9acb12 100644
--- a/arch/arm/mach-pxa/treo680.c
+++ b/arch/arm/mach-pxa/treo680.c
@@ -19,7 +19,6 @@
 #include <linux/pda_power.h>
 #include <linux/pwm_backlight.h>
 #include <linux/gpio.h>
-#include <linux/wm97xx_batt.h>
 #include <linux/power_supply.h>
 #include <linux/sysdev.h>
 #include <linux/w1-gpio.h>
-- 
1.6.3.3


[-- Attachment #3: Type: text/plain, Size: 160 bytes --]

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* Re: [PATCH 4/4] Convert all platforms to pass platform_data to wm97xx battery
  2009-07-22 11:05                       ` [PATCH 4/4] Convert all platforms to pass platform_data to wm97xx battery Marek Vasut
@ 2009-07-22 18:09                         ` Robert Jarzmik
  2009-07-22 18:30                           ` Marek Vasut
  0 siblings, 1 reply; 52+ messages in thread
From: Robert Jarzmik @ 2009-07-22 18:09 UTC (permalink / raw)
  To: Marek Vasut
  Cc: alsa-devel, Russell King - ARM Linux, Takashi Iwai, Mark Brown,
	cbou, Eric Miao, avorontsov, dwmw2, linux-arm-kernel

Marek Vasut <marek.vasut@gmail.com> writes:

> Dne St 22. července 2009 13:01:03 Marek Vasut napsal(a):
>> Ok,
>> Im sending the set again.
> And this does the platform conversion. Depends on 3/4 and should be Acked by 
> Robert. So please.
Well, there are 2 things wrong with the mioa701 part.

> diff --git a/arch/arm/mach-pxa/mioa701.c b/arch/arm/mach-pxa/mioa701.c
> index 3cab452..803917d 100644
> --- a/arch/arm/mach-pxa/mioa701.c
> +++ b/arch/arm/mach-pxa/mioa701.c
> @@ -34,7 +34,7 @@
>  #include <linux/irq.h>
>  #include <linux/pda_power.h>
>  #include <linux/power_supply.h>
> -#include <linux/wm97xx_batt.h>
> +#include <linux/wm97xx.h>
>  #include <linux/mtd/physmap.h>
>  #include <linux/usb/gpio_vbus.h>
>  #include <linux/regulator/max1586.h>
> @@ -660,6 +660,10 @@ static struct wm97xx_batt_info mioa701_battery_data = {
(1)                                    \-> should be wm97xx_batt_pdata

(2) remove wm97xx_bat_set_pdata(&mioa701_battery_data) call in
mioa701_machine_init().

I'll try to test this evening, and report.

Cheers.

--
Robert
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 4/4] Convert all platforms to pass platform_data to wm97xx battery
  2009-07-22 18:09                         ` Robert Jarzmik
@ 2009-07-22 18:30                           ` Marek Vasut
  2009-07-25 20:55                             ` Robert Jarzmik
  2009-07-27  0:06                             ` Marek Vasut
  0 siblings, 2 replies; 52+ messages in thread
From: Marek Vasut @ 2009-07-22 18:30 UTC (permalink / raw)
  To: Robert Jarzmik
  Cc: alsa-devel, Russell King - ARM Linux, Takashi Iwai, Mark Brown,
	cbou, Eric Miao, avorontsov, dwmw2, linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 1265 bytes --]

Dne St 22. července 2009 20:09:09 Robert Jarzmik napsal(a):
> Marek Vasut <marek.vasut@gmail.com> writes:
> > Dne St 22. července 2009 13:01:03 Marek Vasut napsal(a):
> >> Ok,
> >> Im sending the set again.
> >
> > And this does the platform conversion. Depends on 3/4 and should be Acked
> > by Robert. So please.
>
> Well, there are 2 things wrong with the mioa701 part.
>
> > diff --git a/arch/arm/mach-pxa/mioa701.c b/arch/arm/mach-pxa/mioa701.c
> > index 3cab452..803917d 100644
> > --- a/arch/arm/mach-pxa/mioa701.c
> > +++ b/arch/arm/mach-pxa/mioa701.c
> > @@ -34,7 +34,7 @@
> >  #include <linux/irq.h>
> >  #include <linux/pda_power.h>
> >  #include <linux/power_supply.h>
> > -#include <linux/wm97xx_batt.h>
> > +#include <linux/wm97xx.h>
> >  #include <linux/mtd/physmap.h>
> >  #include <linux/usb/gpio_vbus.h>
> >  #include <linux/regulator/max1586.h>
> > @@ -660,6 +660,10 @@ static struct wm97xx_batt_info mioa701_battery_data
> > = {
>
> (1)                                    \-> should be wm97xx_batt_pdata
>
> (2) remove wm97xx_bat_set_pdata(&mioa701_battery_data) call in
> mioa701_machine_init().
>
> I'll try to test this evening, and report.
>
> Cheers.
>
> --
> Robert

Thanks! Here's a fixed patch.

[-- Attachment #2: 0004-Convert-all-platforms-to-pass-platform_data-to-wm97x.patch --]
[-- Type: text/x-patch, Size: 12563 bytes --]

From 3f6fa6d7fb1ac1959b612580151248c222d63a68 Mon Sep 17 00:00:00 2001
From: Marek Vasut <marek.vasut@gmail.com>
Date: Tue, 21 Jul 2009 19:22:13 +0200
Subject: [PATCH 4/4] Convert all platforms to pass platform_data to wm97xx battery

Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
---
 arch/arm/mach-pxa/mioa701.c |   10 +++++++---
 arch/arm/mach-pxa/palmld.c  |   19 ++++++++++---------
 arch/arm/mach-pxa/palmt5.c  |   19 ++++++++++---------
 arch/arm/mach-pxa/palmte2.c |   20 ++++++++++++--------
 arch/arm/mach-pxa/palmtx.c  |   19 ++++++++++---------
 arch/arm/mach-pxa/palmz72.c |   20 ++++++++++++--------
 arch/arm/mach-pxa/treo680.c |    1 -
 7 files changed, 61 insertions(+), 47 deletions(-)

diff --git a/arch/arm/mach-pxa/mioa701.c b/arch/arm/mach-pxa/mioa701.c
index 3cab452..2057ede 100644
--- a/arch/arm/mach-pxa/mioa701.c
+++ b/arch/arm/mach-pxa/mioa701.c
@@ -34,7 +34,7 @@
 #include <linux/irq.h>
 #include <linux/pda_power.h>
 #include <linux/power_supply.h>
-#include <linux/wm97xx_batt.h>
+#include <linux/wm97xx.h>
 #include <linux/mtd/physmap.h>
 #include <linux/usb/gpio_vbus.h>
 #include <linux/regulator/max1586.h>
@@ -648,7 +648,7 @@ static struct platform_device power_dev = {
 	},
 };
 
-static struct wm97xx_batt_info mioa701_battery_data = {
+static struct wm97xx_batt_pdata mioa701_battery_data = {
 	.batt_aux	= WM97XX_AUX_ID1,
 	.temp_aux	= -1,
 	.charge_gpio	= -1,
@@ -660,6 +660,10 @@ static struct wm97xx_batt_info mioa701_battery_data = {
 	.batt_name	= "mioa701_battery",
 };
 
+static struct wm97xx_pdata mioa701_wm97xx_pdata = {
+	.batt_pdata	= &mioa701_battery_data,
+};
+
 /*
  * Voltage regulation
  */
@@ -728,6 +732,7 @@ struct i2c_pxa_platform_data i2c_pdata = {
 
 static pxa2xx_audio_ops_t mioa701_ac97_info = {
 	.reset_gpio = 95,
+	.codec_pdata = { &mioa701_wm97xx_pdata, },
 };
 
 /*
@@ -804,7 +809,6 @@ static void __init mioa701_machine_init(void)
 	mioa701_mci_info.detect_delay = msecs_to_jiffies(250);
 	pxa_set_mci_info(&mioa701_mci_info);
 	pxa_set_keypad_info(&mioa701_keypad_info);
-	wm97xx_bat_set_pdata(&mioa701_battery_data);
 	pxa_set_udc_info(&mioa701_udc_info);
 	pxa_set_ac97_info(&mioa701_ac97_info);
 	pm_power_off = mioa701_poweroff;
diff --git a/arch/arm/mach-pxa/palmld.c b/arch/arm/mach-pxa/palmld.c
index 1ad029d..bcf5b46 100644
--- a/arch/arm/mach-pxa/palmld.c
+++ b/arch/arm/mach-pxa/palmld.c
@@ -22,7 +22,7 @@
 #include <linux/pda_power.h>
 #include <linux/pwm_backlight.h>
 #include <linux/gpio.h>
-#include <linux/wm97xx_batt.h>
+#include <linux/wm97xx.h>
 #include <linux/power_supply.h>
 #include <linux/sysdev.h>
 #include <linux/mtd/mtd.h>
@@ -406,9 +406,9 @@ static struct platform_device power_supply = {
 };
 
 /******************************************************************************
- * WM97xx battery
+ * WM97xx audio, battery
  ******************************************************************************/
-static struct wm97xx_batt_info wm97xx_batt_pdata = {
+static struct wm97xx_batt_pdata palmld_batt_pdata = {
 	.batt_aux	= WM97XX_AUX_ID3,
 	.temp_aux	= WM97XX_AUX_ID2,
 	.charge_gpio	= -1,
@@ -422,15 +422,17 @@ static struct wm97xx_batt_info wm97xx_batt_pdata = {
 	.batt_name	= "main-batt",
 };
 
-/******************************************************************************
- * aSoC audio
- ******************************************************************************/
-static struct palm27x_asoc_info palmld_asoc_pdata = {
-	.jack_gpio	= GPIO_NR_PALMLD_EARPHONE_DETECT,
+static struct wm97xx_pdata palmld_wm97xx_pdata = {
+	.batt_pdata	= &palmld_batt_pdata,
 };
 
 static pxa2xx_audio_ops_t palmld_ac97_pdata = {
 	.reset_gpio	= 95,
+	.codec_pdata	= { &palmld_wm97xx_pdata, },
+};
+
+static struct palm27x_asoc_info palmld_asoc_pdata = {
+	.jack_gpio	= GPIO_NR_PALMLD_EARPHONE_DETECT,
 };
 
 static struct platform_device palmld_asoc = {
@@ -536,7 +538,6 @@ static void __init palmld_init(void)
 	pxa_set_ac97_info(&palmld_ac97_pdata);
 	pxa_set_ficp_info(&palmld_ficp_platform_data);
 	pxa_set_keypad_info(&palmld_keypad_platform_data);
-	wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
 
 	platform_add_devices(devices, ARRAY_SIZE(devices));
 }
diff --git a/arch/arm/mach-pxa/palmt5.c b/arch/arm/mach-pxa/palmt5.c
index 2dd7ce2..3e8b21d 100644
--- a/arch/arm/mach-pxa/palmt5.c
+++ b/arch/arm/mach-pxa/palmt5.c
@@ -24,7 +24,7 @@
 #include <linux/pda_power.h>
 #include <linux/pwm_backlight.h>
 #include <linux/gpio.h>
-#include <linux/wm97xx_batt.h>
+#include <linux/wm97xx.h>
 #include <linux/power_supply.h>
 #include <linux/usb/gpio_vbus.h>
 
@@ -317,9 +317,9 @@ static struct platform_device power_supply = {
 };
 
 /******************************************************************************
- * WM97xx battery
+ * WM97xx audio, battery
  ******************************************************************************/
-static struct wm97xx_batt_info wm97xx_batt_pdata = {
+static struct wm97xx_batt_pdata palmt5_batt_pdata = {
 	.batt_aux	= WM97XX_AUX_ID3,
 	.temp_aux	= WM97XX_AUX_ID2,
 	.charge_gpio	= -1,
@@ -333,15 +333,17 @@ static struct wm97xx_batt_info wm97xx_batt_pdata = {
 	.batt_name	= "main-batt",
 };
 
-/******************************************************************************
- * aSoC audio
- ******************************************************************************/
-static struct palm27x_asoc_info palmt5_asoc_pdata = {
-	.jack_gpio	= GPIO_NR_PALMT5_EARPHONE_DETECT,
+static struct wm97xx_pdata palmt5_wm97xx_pdata = {
+	.batt_pdata	= &palmt5_batt_pdata,
 };
 
 static pxa2xx_audio_ops_t palmt5_ac97_pdata = {
 	.reset_gpio	= 95,
+	.codec_pdata	= { &palmt5_wm97xx_pdata, },
+};
+
+static struct palm27x_asoc_info palmt5_asoc_pdata = {
+	.jack_gpio	= GPIO_NR_PALMT5_EARPHONE_DETECT,
 };
 
 static struct platform_device palmt5_asoc = {
@@ -426,7 +428,6 @@ static void __init palmt5_init(void)
 	pxa_set_ac97_info(&palmt5_ac97_pdata);
 	pxa_set_ficp_info(&palmt5_ficp_platform_data);
 	pxa_set_keypad_info(&palmt5_keypad_platform_data);
-	wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
 
 	platform_add_devices(devices, ARRAY_SIZE(devices));
 }
diff --git a/arch/arm/mach-pxa/palmte2.c b/arch/arm/mach-pxa/palmte2.c
index 277c406..21c241b 100644
--- a/arch/arm/mach-pxa/palmte2.c
+++ b/arch/arm/mach-pxa/palmte2.c
@@ -23,7 +23,7 @@
 #include <linux/pda_power.h>
 #include <linux/pwm_backlight.h>
 #include <linux/gpio.h>
-#include <linux/wm97xx_batt.h>
+#include <linux/wm97xx.h>
 #include <linux/power_supply.h>
 #include <linux/usb/gpio_vbus.h>
 
@@ -290,9 +290,9 @@ static struct platform_device power_supply = {
 };
 
 /******************************************************************************
- * WM97xx battery
+ * WM97xx audio, battery
  ******************************************************************************/
-static struct wm97xx_batt_info wm97xx_batt_pdata = {
+static struct wm97xx_batt_info palmte2_batt_pdata = {
 	.batt_aux	= WM97XX_AUX_ID3,
 	.temp_aux	= WM97XX_AUX_ID2,
 	.charge_gpio	= -1,
@@ -306,9 +306,14 @@ static struct wm97xx_batt_info wm97xx_batt_pdata = {
 	.batt_name	= "main-batt",
 };
 
-/******************************************************************************
- * aSoC audio
- ******************************************************************************/
+static struct wm97xx_pdata palmte2_wm97xx_pdata = {
+	.batt_pdata	= &palmte2_batt_pdata,
+};
+
+static pxa2xx_audio_ops_t palmte2_ac97_pdata = {
+	.codec_pdata	= { &palmte2_wm97xx_pdata, },
+};
+
 static struct palm27x_asoc_info palmte2_asoc_pdata = {
 	.jack_gpio	= GPIO_NR_PALMTE2_EARPHONE_DETECT,
 };
@@ -376,9 +381,8 @@ static void __init palmte2_init(void)
 	set_pxa_fb_info(&palmte2_lcd_screen);
 	pxa_set_mci_info(&palmte2_mci_platform_data);
 	palmte2_udc_init();
-	pxa_set_ac97_info(NULL);
+	pxa_set_ac97_info(&palmte2_ac97_pdata);
 	pxa_set_ficp_info(&palmte2_ficp_platform_data);
-	wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
 
 	platform_add_devices(devices, ARRAY_SIZE(devices));
 }
diff --git a/arch/arm/mach-pxa/palmtx.c b/arch/arm/mach-pxa/palmtx.c
index f1e248c..554b3da 100644
--- a/arch/arm/mach-pxa/palmtx.c
+++ b/arch/arm/mach-pxa/palmtx.c
@@ -25,7 +25,7 @@
 #include <linux/pda_power.h>
 #include <linux/pwm_backlight.h>
 #include <linux/gpio.h>
-#include <linux/wm97xx_batt.h>
+#include <linux/wm97xx.h>
 #include <linux/power_supply.h>
 #include <linux/usb/gpio_vbus.h>
 #include <linux/mtd/nand.h>
@@ -340,9 +340,9 @@ static struct platform_device power_supply = {
 };
 
 /******************************************************************************
- * WM97xx battery
+ * WM97xx audio, battery
  ******************************************************************************/
-static struct wm97xx_batt_info wm97xx_batt_pdata = {
+static struct wm97xx_batt_pdata palmtx_batt_pdata = {
 	.batt_aux	= WM97XX_AUX_ID3,
 	.temp_aux	= WM97XX_AUX_ID2,
 	.charge_gpio	= -1,
@@ -356,15 +356,17 @@ static struct wm97xx_batt_info wm97xx_batt_pdata = {
 	.batt_name	= "main-batt",
 };
 
-/******************************************************************************
- * aSoC audio
- ******************************************************************************/
-static struct palm27x_asoc_info palmtx_asoc_pdata = {
-	.jack_gpio	= GPIO_NR_PALMTX_EARPHONE_DETECT,
+static struct wm97xx_pdata palmtx_wm97xx_pdata = {
+	.batt_pdata	= &palmtx_batt_pdata,
 };
 
 static pxa2xx_audio_ops_t palmtx_ac97_pdata = {
 	.reset_gpio	= 95,
+	.codec_pdata	= { &palmtx_wm97xx_pdata, },
+};
+
+static struct palm27x_asoc_info palmtx_asoc_pdata = {
+	.jack_gpio	= GPIO_NR_PALMTX_EARPHONE_DETECT,
 };
 
 static struct platform_device palmtx_asoc = {
@@ -538,7 +540,6 @@ static void __init palmtx_init(void)
 	pxa_set_ac97_info(&palmtx_ac97_pdata);
 	pxa_set_ficp_info(&palmtx_ficp_platform_data);
 	pxa_set_keypad_info(&palmtx_keypad_platform_data);
-	wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
 
 	platform_add_devices(devices, ARRAY_SIZE(devices));
 }
diff --git a/arch/arm/mach-pxa/palmz72.c b/arch/arm/mach-pxa/palmz72.c
index c2bf493..b769447 100644
--- a/arch/arm/mach-pxa/palmz72.c
+++ b/arch/arm/mach-pxa/palmz72.c
@@ -27,7 +27,7 @@
 #include <linux/pda_power.h>
 #include <linux/pwm_backlight.h>
 #include <linux/gpio.h>
-#include <linux/wm97xx_batt.h>
+#include <linux/wm97xx.h>
 #include <linux/power_supply.h>
 #include <linux/usb/gpio_vbus.h>
 
@@ -343,9 +343,9 @@ static struct platform_device power_supply = {
 };
 
 /******************************************************************************
- * WM97xx battery
+ * WM97xx audio, battery
  ******************************************************************************/
-static struct wm97xx_batt_info wm97xx_batt_pdata = {
+static struct wm97xx_batt_info palmz72_batt_pdata = {
 	.batt_aux	= WM97XX_AUX_ID3,
 	.temp_aux	= WM97XX_AUX_ID2,
 	.charge_gpio	= -1,
@@ -359,9 +359,14 @@ static struct wm97xx_batt_info wm97xx_batt_pdata = {
 	.batt_name	= "main-batt",
 };
 
-/******************************************************************************
- * aSoC audio
- ******************************************************************************/
+static struct wm97xx_pdata palmz72_wm97xx_pdata = {
+	.batt_pdata	= &palmz72_batt_pdata,
+};
+
+static pxa2xx_audio_ops_t palmz72_ac97_pdata = {
+	.codec_pdata	= { &palmz72_wm97xx_pdata, },
+};
+
 static struct platform_device palmz72_asoc = {
 	.name = "palm27x-asoc",
 	.id   = -1,
@@ -494,10 +499,9 @@ static void __init palmz72_init(void)
 	set_pxa_fb_info(&palmz72_lcd_screen);
 	pxa_set_mci_info(&palmz72_mci_platform_data);
 	palmz72_udc_init();
-	pxa_set_ac97_info(NULL);
+	pxa_set_ac97_info(&palmz72_ac97_pdata);
 	pxa_set_ficp_info(&palmz72_ficp_platform_data);
 	pxa_set_keypad_info(&palmz72_keypad_platform_data);
-	wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
 
 	platform_add_devices(devices, ARRAY_SIZE(devices));
 }
diff --git a/arch/arm/mach-pxa/treo680.c b/arch/arm/mach-pxa/treo680.c
index f537265..f9acb12 100644
--- a/arch/arm/mach-pxa/treo680.c
+++ b/arch/arm/mach-pxa/treo680.c
@@ -19,7 +19,6 @@
 #include <linux/pda_power.h>
 #include <linux/pwm_backlight.h>
 #include <linux/gpio.h>
-#include <linux/wm97xx_batt.h>
 #include <linux/power_supply.h>
 #include <linux/sysdev.h>
 #include <linux/w1-gpio.h>
-- 
1.6.3.3


[-- Attachment #3: Type: text/plain, Size: 160 bytes --]

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* Re: [PATCH 1/4] Allow passing platform_data to devices attached to AC97 bus
  2009-07-22 10:59               ` [PATCH 1/4] " Marek Vasut
@ 2009-07-23 10:16                 ` Mark Brown
  2009-07-23 10:28                   ` Takashi Iwai
  0 siblings, 1 reply; 52+ messages in thread
From: Mark Brown @ 2009-07-23 10:16 UTC (permalink / raw)
  To: Marek Vasut
  Cc: Takashi Iwai, Russell King - ARM Linux, alsa-devel, Eric Miao,
	linux-arm-kernel

On Wed, Jul 22, 2009 at 12:59:13PM +0200, Marek Vasut wrote:

> This patch allows passing platform_data to devices attached to AC97 bus
> (like touchscreens, battery measurement chips ...).
> 
> Signed-off-by: Marek Vasut <marek.vasut@gmail.com>

Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

Takashi, should I apply this to ASoC or do you want to merge it given
that it touches ALSA core stuff?

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 2/4] Allow passing platform_data for pxa2xx-ac97
  2009-07-22 11:02                       ` [PATCH 2/4] Allow passing platform_data for pxa2xx-ac97 Marek Vasut
@ 2009-07-23 10:27                         ` Mark Brown
  2009-07-23 14:16                           ` Marek Vasut
  0 siblings, 1 reply; 52+ messages in thread
From: Mark Brown @ 2009-07-23 10:27 UTC (permalink / raw)
  To: Marek Vasut
  Cc: alsa-devel, Russell King - ARM Linux, Takashi Iwai,
	Robert Jarzmik, cbou, Eric Miao, avorontsov, dwmw2,
	linux-arm-kernel

On Wed, Jul 22, 2009 at 01:02:40PM +0200, Marek Vasut wrote:

>  	struct snd_ac97_bus *ac97_bus;
>  	struct snd_ac97_template ac97_template;
>  	int ret;
> +	pxa2xx_audio_ops_t *pdata = dev->dev.platform_data;
> +	int id = dev->id < 0 ? 0 : dev->id;
>  

dev here is the AC97 controller device - if there's more than one AC97
controller in the system they can each have the four child devices.  On
the other hand, I don't think any of the PXA processors have more than
one AC97 controller so it'll never actually have any impact.

I think the best thing for now is to either warn if anything except the
primary codec has platform data or change the platform data to have a
variable something like primary_audio_pdata.  The driver doesn't appear
to support secondary codecs anyway.

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 1/4] Allow passing platform_data to devices attached to AC97 bus
  2009-07-23 10:16                 ` Mark Brown
@ 2009-07-23 10:28                   ` Takashi Iwai
  2009-07-23 10:31                     ` Mark Brown
  0 siblings, 1 reply; 52+ messages in thread
From: Takashi Iwai @ 2009-07-23 10:28 UTC (permalink / raw)
  To: Mark Brown
  Cc: Marek Vasut, alsa-devel, Eric Miao, linux-arm-kernel,
	Russell King - ARM Linux

At Thu, 23 Jul 2009 11:16:55 +0100,
Mark Brown wrote:
> 
> On Wed, Jul 22, 2009 at 12:59:13PM +0200, Marek Vasut wrote:
> 
> > This patch allows passing platform_data to devices attached to AC97 bus
> > (like touchscreens, battery measurement chips ...).
> > 
> > Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
> 
> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
> 
> Takashi, should I apply this to ASoC or do you want to merge it given
> that it touches ALSA core stuff?

Feel free to take it into your tree.  The core (ac97) change is used
only by ASoC as now, and above all, it doesn't break anything else.


thanks,

Takashi

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 1/4] Allow passing platform_data to devices attached to AC97 bus
  2009-07-23 10:28                   ` Takashi Iwai
@ 2009-07-23 10:31                     ` Mark Brown
  0 siblings, 0 replies; 52+ messages in thread
From: Mark Brown @ 2009-07-23 10:31 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: Marek Vasut, alsa-devel, Eric Miao, linux-arm-kernel,
	Russell King - ARM Linux

On Thu, Jul 23, 2009 at 12:28:41PM +0200, Takashi Iwai wrote:

> Feel free to take it into your tree.  The core (ac97) change is used
> only by ASoC as now, and above all, it doesn't break anything else.

OK, applied now.

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 3/4] Convert WM97xx driver to use platform_data
  2009-07-22 11:04                       ` [PATCH 3/4] Convert WM97xx driver to use platform_data Marek Vasut
@ 2009-07-23 11:49                         ` Mark Brown
  2009-07-24 19:44                         ` Robert Jarzmik
  1 sibling, 0 replies; 52+ messages in thread
From: Mark Brown @ 2009-07-23 11:49 UTC (permalink / raw)
  To: Marek Vasut
  Cc: alsa-devel, Russell King - ARM Linux, Takashi Iwai,
	Robert Jarzmik, cbou, Eric Miao, avorontsov, dwmw2,
	linux-arm-kernel

On Wed, Jul 22, 2009 at 01:04:16PM +0200, Marek Vasut wrote:

> diff --git a/drivers/input/touchscreen/wm97xx-core.c b/drivers/input/touchscreen/wm97xx-core.c
> index 252eb11..f944918 100644
> --- a/drivers/input/touchscreen/wm97xx-core.c
> +++ b/drivers/input/touchscreen/wm97xx-core.c
> @@ -561,6 +561,7 @@ static void wm97xx_ts_input_close(struct input_dev *idev)
>  static int wm97xx_probe(struct device *dev)
>  {
>  	struct wm97xx *wm;
> +	struct wm97xx_pdata *pdata = dev->platform_data;
>  	int ret = 0, id = 0;
>  
>  	wm = kzalloc(sizeof(struct wm97xx), GFP_KERNEL);

> +++ b/drivers/power/wm97xx_battery.c
> @@ -22,17 +22,19 @@
>  #include <linux/spinlock.h>
>  #include <linux/interrupt.h>
>  #include <linux/gpio.h>
> -#include <linux/wm97xx_batt.h>
> +#include <linux/irq.h>

...

> +static irqreturn_t wm97xx_chrg_irq(int irq, void *data)
> +{
> +	schedule_work(&bat_work);
> +	return IRQ_HANDLED;
> +}
> +

> -	if (pdata->charge_gpio >= 0 && gpio_is_valid(pdata->charge_gpio)) {
> +	if (gpio_is_valid(pdata->charge_gpio)) {
>  		ret = gpio_request(pdata->charge_gpio, "BATT CHRG");
>  		if (ret)
>  			goto err;
>  		ret = gpio_direction_input(pdata->charge_gpio);
>  		if (ret)
>  			goto err2;
> +		ret = request_irq(gpio_to_irq(pdata->charge_gpio),
> +				wm97xx_chrg_irq, IRQF_DISABLED,
> +				"AC Detect", 0);
> +		if (ret)
> +			goto err2;
>  		props++;	/* POWER_SUPPLY_PROP_STATUS */

None of these hunks appear to be related to the change in where the
platform data is coming from and should be split out, as should all the
error handling code which follows.

> -void __init wm97xx_bat_set_pdata(struct wm97xx_batt_info *data)
> -{
> -	pdata = data;
> -}
> -EXPORT_SYMBOL_GPL(wm97xx_bat_set_pdata);
> -

This change and the removal of the old structure should ideally be
included in the commit which converts all the users to avoid build
errors during bisection.  I'd say it's OK to have the driver just print
a warning or something if someone boots the affected kernel during the
transition period.

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 2/4] Allow passing platform_data for pxa2xx-ac97
  2009-07-23 10:27                         ` Mark Brown
@ 2009-07-23 14:16                           ` Marek Vasut
  2009-07-23 15:14                             ` Mark Brown
  2009-07-23 18:39                             ` Marek Vasut
  0 siblings, 2 replies; 52+ messages in thread
From: Marek Vasut @ 2009-07-23 14:16 UTC (permalink / raw)
  To: Mark Brown
  Cc: alsa-devel, Russell King - ARM Linux, Takashi Iwai,
	Robert Jarzmik, cbou, Eric Miao, avorontsov, dwmw2,
	linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 910 bytes --]

Dne Čt 23. července 2009 12:27:41 Mark Brown napsal(a):
> On Wed, Jul 22, 2009 at 01:02:40PM +0200, Marek Vasut wrote:
> >  	struct snd_ac97_bus *ac97_bus;
> >  	struct snd_ac97_template ac97_template;
> >  	int ret;
> > +	pxa2xx_audio_ops_t *pdata = dev->dev.platform_data;
> > +	int id = dev->id < 0 ? 0 : dev->id;
>
> dev here is the AC97 controller device - if there's more than one AC97
> controller in the system they can each have the four child devices.  On
> the other hand, I don't think any of the PXA processors have more than
> one AC97 controller so it'll never actually have any impact.
>
> I think the best thing for now is to either warn if anything except the
> primary codec has platform data or change the platform data to have a
> variable something like primary_audio_pdata.  The driver doesn't appear
> to support secondary codecs anyway.

Ok, here's a fixed patch.

[-- Attachment #2: 0001-Allow-passing-platform_data-for-pxa2xx-ac97.patch --]
[-- Type: text/x-patch, Size: 4016 bytes --]

From 645d82cc2621b992ceb1e164e7fca182a2c321d4 Mon Sep 17 00:00:00 2001
From: Marek Vasut <marek.vasut@gmail.com>
Date: Tue, 21 Jul 2009 16:22:29 +0200
Subject: [PATCH 1/4] 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>
---
 arch/arm/mach-pxa/include/mach/audio.h |    3 +++
 include/sound/ac97_codec.h             |    3 +++
 sound/arm/pxa2xx-ac97.c                |    9 +++++++++
 sound/soc/pxa/pxa2xx-ac97.c            |   11 ++++++++++-
 4 files changed, 25 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-pxa/include/mach/audio.h b/arch/arm/mach-pxa/include/mach/audio.h
index 16eb025..a3449e3 100644
--- a/arch/arm/mach-pxa/include/mach/audio.h
+++ b/arch/arm/mach-pxa/include/mach/audio.h
@@ -3,10 +3,12 @@
 
 #include <sound/core.h>
 #include <sound/pcm.h>
+#include <sound/ac97_codec.h>
 
 /*
  * @reset_gpio: AC97 reset gpio (normally gpio113 or gpio95)
  *              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
  * bug prevents correct operation of the reset line. If not specified,
@@ -20,6 +22,7 @@ typedef struct {
 	void (*resume)(void *);
 	void *priv;
 	int reset_gpio;
+	void *codec_pdata[AC97_BUS_MAX_DEVICES];
 } pxa2xx_audio_ops_t;
 
 extern void pxa_set_ac97_info(pxa2xx_audio_ops_t *ops);
diff --git a/include/sound/ac97_codec.h b/include/sound/ac97_codec.h
index 9b1c098..3dae3f7 100644
--- a/include/sound/ac97_codec.h
+++ b/include/sound/ac97_codec.h
@@ -32,6 +32,9 @@
 #include "control.h"
 #include "info.h"
 
+/* maximum number of devices on the AC97 bus */
+#define	AC97_BUS_MAX_DEVICES	4
+
 /*
  *  AC'97 codec registers
  */
diff --git a/sound/arm/pxa2xx-ac97.c b/sound/arm/pxa2xx-ac97.c
index c570ebd..22d4f83 100644
--- a/sound/arm/pxa2xx-ac97.c
+++ b/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_template ac97_template;
 	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,
 			      THIS_MODULE, 0, &card);
@@ -200,6 +207,7 @@ static int __devinit pxa2xx_ac97_probe(struct platform_device *dev)
 	snprintf(card->longname, sizeof(card->longname),
 		 "%s (%s)", dev->dev.driver->name, card->mixername);
 
+	snd_ac97_dev_add_pdata(ac97_bus->codec[0], pdata->codec_pdata[0]);
 	snd_card_set_dev(card, &dev->dev);
 	ret = snd_card_register(card);
 	if (ret == 0) {
@@ -212,6 +220,7 @@ err_remove:
 err:
 	if (card)
 		snd_card_free(card);
+err_dev:
 	return ret;
 }
 
diff --git a/sound/soc/pxa/pxa2xx-ac97.c b/sound/soc/pxa/pxa2xx-ac97.c
index d9c94d7..b19451d 100644
--- a/sound/soc/pxa/pxa2xx-ac97.c
+++ b/sound/soc/pxa/pxa2xx-ac97.c
@@ -22,6 +22,7 @@
 #include <mach/hardware.h>
 #include <mach/regs-ac97.h>
 #include <mach/dma.h>
+#include <mach/audio.h>
 
 #include "pxa2xx-pcm.h"
 #include "pxa2xx-ac97.h"
@@ -241,9 +242,17 @@ EXPORT_SYMBOL_GPL(soc_ac97_ops);
 static int __devinit pxa2xx_ac97_dev_probe(struct platform_device *pdev)
 {
 	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(&dev->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].ac97_pdata = pdata->codec_pdata[0];
+	}
 
 	/* 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
-- 
1.6.3.3


[-- Attachment #3: Type: text/plain, Size: 160 bytes --]

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* Re: [PATCH 2/4] Allow passing platform_data for pxa2xx-ac97
  2009-07-23 14:16                           ` Marek Vasut
@ 2009-07-23 15:14                             ` Mark Brown
  2009-07-23 18:39                             ` Marek Vasut
  1 sibling, 0 replies; 52+ messages in thread
From: Mark Brown @ 2009-07-23 15:14 UTC (permalink / raw)
  To: Marek Vasut
  Cc: alsa-devel, Russell King - ARM Linux, Takashi Iwai,
	Robert Jarzmik, cbou, Eric Miao, avorontsov, dwmw2,
	linux-arm-kernel

On Thu, Jul 23, 2009 at 04:16:12PM +0200, Marek Vasut wrote:

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

I'm OK with this.  Eric any issues?

> 
> Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
> ---
>  arch/arm/mach-pxa/include/mach/audio.h |    3 +++
>  include/sound/ac97_codec.h             |    3 +++
>  sound/arm/pxa2xx-ac97.c                |    9 +++++++++
>  sound/soc/pxa/pxa2xx-ac97.c            |   11 ++++++++++-
>  4 files changed, 25 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/arm/mach-pxa/include/mach/audio.h b/arch/arm/mach-pxa/include/mach/audio.h
> index 16eb025..a3449e3 100644
> --- a/arch/arm/mach-pxa/include/mach/audio.h
> +++ b/arch/arm/mach-pxa/include/mach/audio.h
> @@ -3,10 +3,12 @@
>  
>  #include <sound/core.h>
>  #include <sound/pcm.h>
> +#include <sound/ac97_codec.h>
>  
>  /*
>   * @reset_gpio: AC97 reset gpio (normally gpio113 or gpio95)
>   *              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
>   * bug prevents correct operation of the reset line. If not specified,
> @@ -20,6 +22,7 @@ typedef struct {
>  	void (*resume)(void *);
>  	void *priv;
>  	int reset_gpio;
> +	void *codec_pdata[AC97_BUS_MAX_DEVICES];
>  } pxa2xx_audio_ops_t;
>  
>  extern void pxa_set_ac97_info(pxa2xx_audio_ops_t *ops);
> diff --git a/include/sound/ac97_codec.h b/include/sound/ac97_codec.h
> index 9b1c098..3dae3f7 100644
> --- a/include/sound/ac97_codec.h
> +++ b/include/sound/ac97_codec.h
> @@ -32,6 +32,9 @@
>  #include "control.h"
>  #include "info.h"
>  
> +/* maximum number of devices on the AC97 bus */
> +#define	AC97_BUS_MAX_DEVICES	4
> +
>  /*
>   *  AC'97 codec registers
>   */
> diff --git a/sound/arm/pxa2xx-ac97.c b/sound/arm/pxa2xx-ac97.c
> index c570ebd..22d4f83 100644
> --- a/sound/arm/pxa2xx-ac97.c
> +++ b/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_template ac97_template;
>  	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,
>  			      THIS_MODULE, 0, &card);
> @@ -200,6 +207,7 @@ static int __devinit pxa2xx_ac97_probe(struct platform_device *dev)
>  	snprintf(card->longname, sizeof(card->longname),
>  		 "%s (%s)", dev->dev.driver->name, card->mixername);
>  
> +	snd_ac97_dev_add_pdata(ac97_bus->codec[0], pdata->codec_pdata[0]);
>  	snd_card_set_dev(card, &dev->dev);
>  	ret = snd_card_register(card);
>  	if (ret == 0) {
> @@ -212,6 +220,7 @@ err_remove:
>  err:
>  	if (card)
>  		snd_card_free(card);
> +err_dev:
>  	return ret;
>  }
>  
> diff --git a/sound/soc/pxa/pxa2xx-ac97.c b/sound/soc/pxa/pxa2xx-ac97.c
> index d9c94d7..b19451d 100644
> --- a/sound/soc/pxa/pxa2xx-ac97.c
> +++ b/sound/soc/pxa/pxa2xx-ac97.c
> @@ -22,6 +22,7 @@
>  #include <mach/hardware.h>
>  #include <mach/regs-ac97.h>
>  #include <mach/dma.h>
> +#include <mach/audio.h>
>  
>  #include "pxa2xx-pcm.h"
>  #include "pxa2xx-ac97.h"
> @@ -241,9 +242,17 @@ EXPORT_SYMBOL_GPL(soc_ac97_ops);
>  static int __devinit pxa2xx_ac97_dev_probe(struct platform_device *pdev)
>  {
>  	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(&dev->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].ac97_pdata = pdata->codec_pdata[0];
> +	}
>  
>  	/* 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
> -- 
> 1.6.3.3
> 

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 2/4] Allow passing platform_data for pxa2xx-ac97
  2009-07-23 14:16                           ` Marek Vasut
  2009-07-23 15:14                             ` Mark Brown
@ 2009-07-23 18:39                             ` Marek Vasut
  2009-07-28  5:28                               ` Marek Vasut
  1 sibling, 1 reply; 52+ messages in thread
From: Marek Vasut @ 2009-07-23 18:39 UTC (permalink / raw)
  To: Mark Brown
  Cc: alsa-devel, Russell King - ARM Linux, Takashi Iwai,
	Robert Jarzmik, cbou, Eric Miao, avorontsov, dwmw2,
	linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 1088 bytes --]

Dne Čt 23. července 2009 16:16:12 Marek Vasut napsal(a):
> Dne Čt 23. července 2009 12:27:41 Mark Brown napsal(a):
> > On Wed, Jul 22, 2009 at 01:02:40PM +0200, Marek Vasut wrote:
> > >  	struct snd_ac97_bus *ac97_bus;
> > >  	struct snd_ac97_template ac97_template;
> > >  	int ret;
> > > +	pxa2xx_audio_ops_t *pdata = dev->dev.platform_data;
> > > +	int id = dev->id < 0 ? 0 : dev->id;
> >
> > dev here is the AC97 controller device - if there's more than one AC97
> > controller in the system they can each have the four child devices.  On
> > the other hand, I don't think any of the PXA processors have more than
> > one AC97 controller so it'll never actually have any impact.
> >
> > I think the best thing for now is to either warn if anything except the
> > primary codec has platform data or change the platform data to have a
> > variable something like primary_audio_pdata.  The driver doesn't appear
> > to support secondary codecs anyway.
>
> Ok, here's a fixed patch.

Argh, one more iteration here. There was a typo in the previous patch. Sorry.

[-- Attachment #2: 0001-Allow-passing-platform_data-for-pxa2xx-ac97.patch --]
[-- Type: text/x-patch, Size: 4017 bytes --]

From 645d82cc2621b992ceb1e164e7fca182a2c321d4 Mon Sep 17 00:00:00 2001
From: Marek Vasut <marek.vasut@gmail.com>
Date: Tue, 21 Jul 2009 16:22:29 +0200
Subject: [PATCH 1/4] 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>
---
 arch/arm/mach-pxa/include/mach/audio.h |    3 +++
 include/sound/ac97_codec.h             |    3 +++
 sound/arm/pxa2xx-ac97.c                |    9 +++++++++
 sound/soc/pxa/pxa2xx-ac97.c            |   11 ++++++++++-
 4 files changed, 25 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-pxa/include/mach/audio.h b/arch/arm/mach-pxa/include/mach/audio.h
index 16eb025..a3449e3 100644
--- a/arch/arm/mach-pxa/include/mach/audio.h
+++ b/arch/arm/mach-pxa/include/mach/audio.h
@@ -3,10 +3,12 @@
 
 #include <sound/core.h>
 #include <sound/pcm.h>
+#include <sound/ac97_codec.h>
 
 /*
  * @reset_gpio: AC97 reset gpio (normally gpio113 or gpio95)
  *              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
  * bug prevents correct operation of the reset line. If not specified,
@@ -20,6 +22,7 @@ typedef struct {
 	void (*resume)(void *);
 	void *priv;
 	int reset_gpio;
+	void *codec_pdata[AC97_BUS_MAX_DEVICES];
 } pxa2xx_audio_ops_t;
 
 extern void pxa_set_ac97_info(pxa2xx_audio_ops_t *ops);
diff --git a/include/sound/ac97_codec.h b/include/sound/ac97_codec.h
index 9b1c098..3dae3f7 100644
--- a/include/sound/ac97_codec.h
+++ b/include/sound/ac97_codec.h
@@ -32,6 +32,9 @@
 #include "control.h"
 #include "info.h"
 
+/* maximum number of devices on the AC97 bus */
+#define	AC97_BUS_MAX_DEVICES	4
+
 /*
  *  AC'97 codec registers
  */
diff --git a/sound/arm/pxa2xx-ac97.c b/sound/arm/pxa2xx-ac97.c
index c570ebd..22d4f83 100644
--- a/sound/arm/pxa2xx-ac97.c
+++ b/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_template ac97_template;
 	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,
 			      THIS_MODULE, 0, &card);
@@ -200,6 +207,7 @@ static int __devinit pxa2xx_ac97_probe(struct platform_device *dev)
 	snprintf(card->longname, sizeof(card->longname),
 		 "%s (%s)", dev->dev.driver->name, card->mixername);
 
+	snd_ac97_dev_add_pdata(ac97_bus->codec[0], pdata->codec_pdata[0]);
 	snd_card_set_dev(card, &dev->dev);
 	ret = snd_card_register(card);
 	if (ret == 0) {
@@ -212,6 +220,7 @@ err_remove:
 err:
 	if (card)
 		snd_card_free(card);
+err_dev:
 	return ret;
 }
 
diff --git a/sound/soc/pxa/pxa2xx-ac97.c b/sound/soc/pxa/pxa2xx-ac97.c
index d9c94d7..b19451d 100644
--- a/sound/soc/pxa/pxa2xx-ac97.c
+++ b/sound/soc/pxa/pxa2xx-ac97.c
@@ -22,6 +22,7 @@
 #include <mach/hardware.h>
 #include <mach/regs-ac97.h>
 #include <mach/dma.h>
+#include <mach/audio.h>
 
 #include "pxa2xx-pcm.h"
 #include "pxa2xx-ac97.h"
@@ -241,9 +242,17 @@ EXPORT_SYMBOL_GPL(soc_ac97_ops);
 static int __devinit pxa2xx_ac97_dev_probe(struct platform_device *pdev)
 {
 	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].ac97_pdata = pdata->codec_pdata[0];
+	}
 
 	/* 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
-- 
1.6.3.3


[-- Attachment #3: Type: text/plain, Size: 160 bytes --]

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* Re: [PATCH 3/4] Convert WM97xx driver to use platform_data
  2009-07-22 11:04                       ` [PATCH 3/4] Convert WM97xx driver to use platform_data Marek Vasut
  2009-07-23 11:49                         ` Mark Brown
@ 2009-07-24 19:44                         ` Robert Jarzmik
  2009-07-24 21:03                           ` Marek Vasut
  1 sibling, 1 reply; 52+ messages in thread
From: Robert Jarzmik @ 2009-07-24 19:44 UTC (permalink / raw)
  To: Marek Vasut
  Cc: alsa-devel, Russell King - ARM Linux, Takashi Iwai, Mark Brown,
	cbou, Eric Miao, avorontsov, dwmw2, linux-arm-kernel

Marek Vasut <marek.vasut@gmail.com> writes:

> Dne St 22. července 2009 13:01:03 Marek Vasut napsal(a):
>> Ok,
>> Im sending the set again.
>
> This one should be acked by Anton already.
>
> From 54febe82847aeef3fcc02a074fd9d21def97f174 Mon Sep 17 00:00:00 2001
> From: Marek Vasut <marek.vasut@gmail.com>
> Date: Tue, 21 Jul 2009 18:52:28 +0200
> Subject: [PATCH 3/4] Convert WM97xx driver to use platform_data
>
> This patch converts the wm97xx driver to use platform_data supplied by
> ac97 bus. Also, this fixes the related wm97xx-battery driver to use
> it's platform_data and prepares a structure for touchscreen driver.
>
> Signed-off-by: Marek Vasut <marek.vasut@gmail.com>

> @@ -97,6 +105,7 @@ static void wm97xx_bat_external_power_changed(struct power_supply *bat_ps)
>  static void wm97xx_bat_update(struct power_supply *bat_ps)
>  {
>  	int old_status = bat_status;
> +	struct wm97xx_batt_pdata *pdata = dev_get_drvdata(bat_ps->dev->parent);
Are you sure of this line ?
Because when I add this line next to it :
	printk(KERN_INFO "RJK: charge_gpio = %d\n", pdata->charge_gpio);
I get :
[  160.079239] power_supply mioa701_battery: prop VOLTAGE_NOW=4012
[  160.089767] power_supply mioa701_battery: prop VOLTAGE_MAX=4032
[  160.099772] power_supply mioa701_battery: prop VOLTAGE_MIN=3072
[  160.111776] RJK: charge_gpio = 260440062

Needless to say that my kernel doesn't boot in that case (because of the
following gpio_get_value()). I was expecting to have "-1" in my printk.

Cheers.

--
Robert
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 3/4] Convert WM97xx driver to use platform_data
  2009-07-24 19:44                         ` Robert Jarzmik
@ 2009-07-24 21:03                           ` Marek Vasut
  0 siblings, 0 replies; 52+ messages in thread
From: Marek Vasut @ 2009-07-24 21:03 UTC (permalink / raw)
  To: Robert Jarzmik
  Cc: alsa-devel, Russell King - ARM Linux, Takashi Iwai, Mark Brown,
	cbou, Eric Miao, avorontsov, dwmw2, linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 1744 bytes --]

Dne Pá 24. července 2009 21:44:01 Robert Jarzmik napsal(a):
> Marek Vasut <marek.vasut@gmail.com> writes:
> > Dne St 22. července 2009 13:01:03 Marek Vasut napsal(a):
> >> Ok,
> >> Im sending the set again.
> >
> > This one should be acked by Anton already.
> >
> > From 54febe82847aeef3fcc02a074fd9d21def97f174 Mon Sep 17 00:00:00 2001
> > From: Marek Vasut <marek.vasut@gmail.com>
> > Date: Tue, 21 Jul 2009 18:52:28 +0200
> > Subject: [PATCH 3/4] Convert WM97xx driver to use platform_data
> >
> > This patch converts the wm97xx driver to use platform_data supplied by
> > ac97 bus. Also, this fixes the related wm97xx-battery driver to use
> > it's platform_data and prepares a structure for touchscreen driver.
> >
> > Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
> >
> > @@ -97,6 +105,7 @@ static void wm97xx_bat_external_power_changed(struct
> > power_supply *bat_ps) static void wm97xx_bat_update(struct power_supply
> > *bat_ps)
> >  {
> >  	int old_status = bat_status;
> > +	struct wm97xx_batt_pdata *pdata = dev_get_drvdata(bat_ps->dev->parent);
>
> Are you sure of this line ?
> Because when I add this line next to it :
> 	printk(KERN_INFO "RJK: charge_gpio = %d\n", pdata->charge_gpio);
> I get :
> [  160.079239] power_supply mioa701_battery: prop VOLTAGE_NOW=4012
> [  160.089767] power_supply mioa701_battery: prop VOLTAGE_MAX=4032
> [  160.099772] power_supply mioa701_battery: prop VOLTAGE_MIN=3072
> [  160.111776] RJK: charge_gpio = 260440062
>
> Needless to say that my kernel doesn't boot in that case (because of the
> following gpio_get_value()). I was expecting to have "-1" in my printk.

Argh ... right. Thanks, try attached patch.
>
> Cheers.
>
> --
> Robert


[-- Attachment #2: 0003-Convert-WM97xx-battery-to-use-platform_data.patch --]
[-- Type: text/x-patch, Size: 5457 bytes --]

From 532c7e0d33c2366e658d13fcb57b68786307b74a Mon Sep 17 00:00:00 2001
From: Marek Vasut <marek.vasut@gmail.com>
Date: Thu, 23 Jul 2009 15:52:08 +0200
Subject: [PATCH 3/7] Convert WM97xx battery to use platform_data

This patch converts the wm97xx-battery driver to use platform_data
supplied by ac97 bus.

Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
---
 drivers/power/wm97xx_battery.c |   26 +++++++++++++++++---------
 include/linux/wm97xx.h         |   18 ++++++++++++++++++
 include/linux/wm97xx_batt.h    |   26 --------------------------
 3 files changed, 35 insertions(+), 35 deletions(-)
 delete mode 100644 include/linux/wm97xx_batt.h

diff --git a/drivers/power/wm97xx_battery.c b/drivers/power/wm97xx_battery.c
index 8bde921..1e33366 100644
--- a/drivers/power/wm97xx_battery.c
+++ b/drivers/power/wm97xx_battery.c
@@ -22,17 +22,18 @@
 #include <linux/spinlock.h>
 #include <linux/interrupt.h>
 #include <linux/gpio.h>
-#include <linux/wm97xx_batt.h>
 
 static DEFINE_MUTEX(bat_lock);
 static struct work_struct bat_work;
 struct mutex work_lock;
 static int bat_status = POWER_SUPPLY_STATUS_UNKNOWN;
-static struct wm97xx_batt_info *pdata;
 static enum power_supply_property *prop;
 
 static unsigned long wm97xx_read_bat(struct power_supply *bat_ps)
 {
+	struct wm97xx_pdata *wmdata = bat_ps->dev->parent->platform_data;
+	struct wm97xx_batt_pdata *pdata = wmdata->batt_pdata;
+
 	return wm97xx_read_aux_adc(bat_ps->dev->parent->driver_data,
 					pdata->batt_aux) * pdata->batt_mult /
 					pdata->batt_div;
@@ -40,6 +41,9 @@ static unsigned long wm97xx_read_bat(struct power_supply *bat_ps)
 
 static unsigned long wm97xx_read_temp(struct power_supply *bat_ps)
 {
+	struct wm97xx_pdata *wmdata = bat_ps->dev->parent->platform_data;
+	struct wm97xx_batt_pdata *pdata = wmdata->batt_pdata;
+
 	return wm97xx_read_aux_adc(bat_ps->dev->parent->driver_data,
 					pdata->temp_aux) * pdata->temp_mult /
 					pdata->temp_div;
@@ -49,6 +53,9 @@ static int wm97xx_bat_get_property(struct power_supply *bat_ps,
 			    enum power_supply_property psp,
 			    union power_supply_propval *val)
 {
+	struct wm97xx_pdata *wmdata = bat_ps->dev->parent->platform_data;
+	struct wm97xx_batt_pdata *pdata = wmdata->batt_pdata;
+
 	switch (psp) {
 	case POWER_SUPPLY_PROP_STATUS:
 		val->intval = bat_status;
@@ -97,6 +104,8 @@ static void wm97xx_bat_external_power_changed(struct power_supply *bat_ps)
 static void wm97xx_bat_update(struct power_supply *bat_ps)
 {
 	int old_status = bat_status;
+	struct wm97xx_pdata *wmdata = bat_ps->dev->parent->platform_data;
+	struct wm97xx_batt_pdata *pdata = wmdata->batt_pdata;
 
 	mutex_lock(&work_lock);
 
@@ -149,6 +158,8 @@ static int __devinit wm97xx_bat_probe(struct platform_device *dev)
 	int ret = 0;
 	int props = 1;	/* POWER_SUPPLY_PROP_PRESENT */
 	int i = 0;
+	struct wm97xx_pdata *wmdata = dev->dev.platform_data;
+	struct wm97xx_batt_pdata *pdata = wmdata->batt_pdata;
 
 	if (dev->id != -1)
 		return -EINVAL;
@@ -156,7 +167,7 @@ static int __devinit wm97xx_bat_probe(struct platform_device *dev)
 	mutex_init(&work_lock);
 
 	if (!pdata) {
-		dev_err(&dev->dev, "Please use wm97xx_bat_set_pdata\n");
+		dev_err(&dev->dev, "No platform_data supplied\n");
 		return -EINVAL;
 	}
 
@@ -229,6 +240,9 @@ err:
 
 static int __devexit wm97xx_bat_remove(struct platform_device *dev)
 {
+	struct wm97xx_pdata *wmdata = dev->dev.platform_data;
+	struct wm97xx_batt_pdata *pdata = wmdata->batt_pdata;
+
 	if (pdata && pdata->charge_gpio && pdata->charge_gpio >= 0)
 		gpio_free(pdata->charge_gpio);
 	flush_scheduled_work();
@@ -258,12 +272,6 @@ static void __exit wm97xx_bat_exit(void)
 	platform_driver_unregister(&wm97xx_bat_driver);
 }
 
-void __init wm97xx_bat_set_pdata(struct wm97xx_batt_info *data)
-{
-	pdata = data;
-}
-EXPORT_SYMBOL_GPL(wm97xx_bat_set_pdata);
-
 module_init(wm97xx_bat_init);
 module_exit(wm97xx_bat_exit);
 
diff --git a/include/linux/wm97xx.h b/include/linux/wm97xx.h
index 0c98781..38e8c4d 100644
--- a/include/linux/wm97xx.h
+++ b/include/linux/wm97xx.h
@@ -293,6 +293,24 @@ struct wm97xx {
 	u16 suspend_mode;               /* PRP in suspend mode */
 };
 
+struct wm97xx_batt_pdata {
+	int	batt_aux;
+	int	temp_aux;
+	int	charge_gpio;
+	int	min_voltage;
+	int	max_voltage;
+	int	batt_div;
+	int	batt_mult;
+	int	temp_div;
+	int	temp_mult;
+	int	batt_tech;
+	char	*batt_name;
+};
+
+struct wm97xx_pdata {
+	struct wm97xx_batt_pdata	*batt_pdata;	/* battery data */
+};
+
 /*
  * Codec GPIO access (not supported on WM9705)
  * This can be used to set/get codec GPIO and Virtual GPIO status.
diff --git a/include/linux/wm97xx_batt.h b/include/linux/wm97xx_batt.h
deleted file mode 100644
index 9681d1a..0000000
--- a/include/linux/wm97xx_batt.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#ifndef _LINUX_WM97XX_BAT_H
-#define _LINUX_WM97XX_BAT_H
-
-#include <linux/wm97xx.h>
-
-struct wm97xx_batt_info {
-	int	batt_aux;
-	int	temp_aux;
-	int	charge_gpio;
-	int	min_voltage;
-	int	max_voltage;
-	int	batt_div;
-	int	batt_mult;
-	int	temp_div;
-	int	temp_mult;
-	int	batt_tech;
-	char	*batt_name;
-};
-
-#ifdef CONFIG_BATTERY_WM97XX
-void __init wm97xx_bat_set_pdata(struct wm97xx_batt_info *data);
-#else
-static inline void wm97xx_bat_set_pdata(struct wm97xx_batt_info *data) {}
-#endif
-
-#endif
-- 
1.6.3.3


[-- Attachment #3: Type: text/plain, Size: 160 bytes --]

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* Re: [PATCH 4/4] Convert all platforms to pass platform_data to wm97xx battery
  2009-07-22 18:30                           ` Marek Vasut
@ 2009-07-25 20:55                             ` Robert Jarzmik
  2009-07-27  0:06                             ` Marek Vasut
  1 sibling, 0 replies; 52+ messages in thread
From: Robert Jarzmik @ 2009-07-25 20:55 UTC (permalink / raw)
  To: Marek Vasut
  Cc: alsa-devel, Russell King - ARM Linux, Takashi Iwai, Mark Brown,
	cbou, Eric Miao, avorontsov, dwmw2, linux-arm-kernel

Marek Vasut <marek.vasut@gmail.com> writes:
>
> Thanks! Here's a fixed patch.
>
For the mioa701 part :
Acked-by: Robert Jarzmik <robert.jarzmik@free.fr>

Cheers.

-- 
Robert

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH] Allow passing platform_data to devices attached to AC97 bus
  2009-07-21 15:11 ` Robert Jarzmik
  2009-07-21 15:17   ` Takashi Iwai
@ 2009-07-25 20:56   ` Robert Jarzmik
  1 sibling, 0 replies; 52+ messages in thread
From: Robert Jarzmik @ 2009-07-25 20:56 UTC (permalink / raw)
  To: Marek Vasut; +Cc: Takashi Iwai, alsa-devel, Mark Brown

You can add, for the whole serie, my :
Tested-by: Robert Jarzmik <robert.jarzmik@free.fr>

--
Robert

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 4/4] Convert all platforms to pass platform_data to wm97xx battery
  2009-07-22 18:30                           ` Marek Vasut
  2009-07-25 20:55                             ` Robert Jarzmik
@ 2009-07-27  0:06                             ` Marek Vasut
  1 sibling, 0 replies; 52+ messages in thread
From: Marek Vasut @ 2009-07-27  0:06 UTC (permalink / raw)
  To: Robert Jarzmik
  Cc: alsa-devel, Russell King - ARM Linux, Takashi Iwai, Mark Brown,
	cbou, Eric Miao, avorontsov, dwmw2, linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 1564 bytes --]

Dne St 22. července 2009 20:30:42 Marek Vasut napsal(a):
> Dne St 22. července 2009 20:09:09 Robert Jarzmik napsal(a):
> > Marek Vasut <marek.vasut@gmail.com> writes:
> > > Dne St 22. července 2009 13:01:03 Marek Vasut napsal(a):
> > >> Ok,
> > >> Im sending the set again.
> > >
> > > And this does the platform conversion. Depends on 3/4 and should be
> > > Acked by Robert. So please.
> >
> > Well, there are 2 things wrong with the mioa701 part.
> >
> > > diff --git a/arch/arm/mach-pxa/mioa701.c b/arch/arm/mach-pxa/mioa701.c
> > > index 3cab452..803917d 100644
> > > --- a/arch/arm/mach-pxa/mioa701.c
> > > +++ b/arch/arm/mach-pxa/mioa701.c
> > > @@ -34,7 +34,7 @@
> > >  #include <linux/irq.h>
> > >  #include <linux/pda_power.h>
> > >  #include <linux/power_supply.h>
> > > -#include <linux/wm97xx_batt.h>
> > > +#include <linux/wm97xx.h>
> > >  #include <linux/mtd/physmap.h>
> > >  #include <linux/usb/gpio_vbus.h>
> > >  #include <linux/regulator/max1586.h>
> > > @@ -660,6 +660,10 @@ static struct wm97xx_batt_info
> > > mioa701_battery_data = {
> >
> > (1)                                    \-> should be wm97xx_batt_pdata
> >
> > (2) remove wm97xx_bat_set_pdata(&mioa701_battery_data) call in
> > mioa701_machine_init().
> >
> > I'll try to test this evening, and report.
> >
> > Cheers.
> >
> > --
> > Robert
>
> Thanks! Here's a fixed patch.

Looks like this isnt only a problem with mio. I missed the change to pdata in 
palmte2 and z72 too, sorry. I compile-tested it now so this one should be OK.

[-- Attachment #2: 0004-Convert-all-platforms-to-pass-platform_data-to-wm97x.patch --]
[-- Type: text/x-patch, Size: 12565 bytes --]

From 3f6fa6d7fb1ac1959b612580151248c222d63a68 Mon Sep 17 00:00:00 2001
From: Marek Vasut <marek.vasut@gmail.com>
Date: Tue, 21 Jul 2009 19:22:13 +0200
Subject: [PATCH 4/4] Convert all platforms to pass platform_data to wm97xx battery

Signed-off-by: Marek Vasut <marek.vasut@gmail.com>
---
 arch/arm/mach-pxa/mioa701.c |   10 +++++++---
 arch/arm/mach-pxa/palmld.c  |   19 ++++++++++---------
 arch/arm/mach-pxa/palmt5.c  |   19 ++++++++++---------
 arch/arm/mach-pxa/palmte2.c |   20 ++++++++++++--------
 arch/arm/mach-pxa/palmtx.c  |   19 ++++++++++---------
 arch/arm/mach-pxa/palmz72.c |   20 ++++++++++++--------
 arch/arm/mach-pxa/treo680.c |    1 -
 7 files changed, 61 insertions(+), 47 deletions(-)

diff --git a/arch/arm/mach-pxa/mioa701.c b/arch/arm/mach-pxa/mioa701.c
index 3cab452..2057ede 100644
--- a/arch/arm/mach-pxa/mioa701.c
+++ b/arch/arm/mach-pxa/mioa701.c
@@ -34,7 +34,7 @@
 #include <linux/irq.h>
 #include <linux/pda_power.h>
 #include <linux/power_supply.h>
-#include <linux/wm97xx_batt.h>
+#include <linux/wm97xx.h>
 #include <linux/mtd/physmap.h>
 #include <linux/usb/gpio_vbus.h>
 #include <linux/regulator/max1586.h>
@@ -648,7 +648,7 @@ static struct platform_device power_dev = {
 	},
 };
 
-static struct wm97xx_batt_info mioa701_battery_data = {
+static struct wm97xx_batt_pdata mioa701_battery_data = {
 	.batt_aux	= WM97XX_AUX_ID1,
 	.temp_aux	= -1,
 	.charge_gpio	= -1,
@@ -660,6 +660,10 @@ static struct wm97xx_batt_info mioa701_battery_data = {
 	.batt_name	= "mioa701_battery",
 };
 
+static struct wm97xx_pdata mioa701_wm97xx_pdata = {
+	.batt_pdata	= &mioa701_battery_data,
+};
+
 /*
  * Voltage regulation
  */
@@ -728,6 +732,7 @@ struct i2c_pxa_platform_data i2c_pdata = {
 
 static pxa2xx_audio_ops_t mioa701_ac97_info = {
 	.reset_gpio = 95,
+	.codec_pdata = { &mioa701_wm97xx_pdata, },
 };
 
 /*
@@ -804,7 +809,6 @@ static void __init mioa701_machine_init(void)
 	mioa701_mci_info.detect_delay = msecs_to_jiffies(250);
 	pxa_set_mci_info(&mioa701_mci_info);
 	pxa_set_keypad_info(&mioa701_keypad_info);
-	wm97xx_bat_set_pdata(&mioa701_battery_data);
 	pxa_set_udc_info(&mioa701_udc_info);
 	pxa_set_ac97_info(&mioa701_ac97_info);
 	pm_power_off = mioa701_poweroff;
diff --git a/arch/arm/mach-pxa/palmld.c b/arch/arm/mach-pxa/palmld.c
index 1ad029d..bcf5b46 100644
--- a/arch/arm/mach-pxa/palmld.c
+++ b/arch/arm/mach-pxa/palmld.c
@@ -22,7 +22,7 @@
 #include <linux/pda_power.h>
 #include <linux/pwm_backlight.h>
 #include <linux/gpio.h>
-#include <linux/wm97xx_batt.h>
+#include <linux/wm97xx.h>
 #include <linux/power_supply.h>
 #include <linux/sysdev.h>
 #include <linux/mtd/mtd.h>
@@ -406,9 +406,9 @@ static struct platform_device power_supply = {
 };
 
 /******************************************************************************
- * WM97xx battery
+ * WM97xx audio, battery
  ******************************************************************************/
-static struct wm97xx_batt_info wm97xx_batt_pdata = {
+static struct wm97xx_batt_pdata palmld_batt_pdata = {
 	.batt_aux	= WM97XX_AUX_ID3,
 	.temp_aux	= WM97XX_AUX_ID2,
 	.charge_gpio	= -1,
@@ -422,15 +422,17 @@ static struct wm97xx_batt_info wm97xx_batt_pdata = {
 	.batt_name	= "main-batt",
 };
 
-/******************************************************************************
- * aSoC audio
- ******************************************************************************/
-static struct palm27x_asoc_info palmld_asoc_pdata = {
-	.jack_gpio	= GPIO_NR_PALMLD_EARPHONE_DETECT,
+static struct wm97xx_pdata palmld_wm97xx_pdata = {
+	.batt_pdata	= &palmld_batt_pdata,
 };
 
 static pxa2xx_audio_ops_t palmld_ac97_pdata = {
 	.reset_gpio	= 95,
+	.codec_pdata	= { &palmld_wm97xx_pdata, },
+};
+
+static struct palm27x_asoc_info palmld_asoc_pdata = {
+	.jack_gpio	= GPIO_NR_PALMLD_EARPHONE_DETECT,
 };
 
 static struct platform_device palmld_asoc = {
@@ -536,7 +538,6 @@ static void __init palmld_init(void)
 	pxa_set_ac97_info(&palmld_ac97_pdata);
 	pxa_set_ficp_info(&palmld_ficp_platform_data);
 	pxa_set_keypad_info(&palmld_keypad_platform_data);
-	wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
 
 	platform_add_devices(devices, ARRAY_SIZE(devices));
 }
diff --git a/arch/arm/mach-pxa/palmt5.c b/arch/arm/mach-pxa/palmt5.c
index 2dd7ce2..3e8b21d 100644
--- a/arch/arm/mach-pxa/palmt5.c
+++ b/arch/arm/mach-pxa/palmt5.c
@@ -24,7 +24,7 @@
 #include <linux/pda_power.h>
 #include <linux/pwm_backlight.h>
 #include <linux/gpio.h>
-#include <linux/wm97xx_batt.h>
+#include <linux/wm97xx.h>
 #include <linux/power_supply.h>
 #include <linux/usb/gpio_vbus.h>
 
@@ -317,9 +317,9 @@ static struct platform_device power_supply = {
 };
 
 /******************************************************************************
- * WM97xx battery
+ * WM97xx audio, battery
  ******************************************************************************/
-static struct wm97xx_batt_info wm97xx_batt_pdata = {
+static struct wm97xx_batt_pdata palmt5_batt_pdata = {
 	.batt_aux	= WM97XX_AUX_ID3,
 	.temp_aux	= WM97XX_AUX_ID2,
 	.charge_gpio	= -1,
@@ -333,15 +333,17 @@ static struct wm97xx_batt_info wm97xx_batt_pdata = {
 	.batt_name	= "main-batt",
 };
 
-/******************************************************************************
- * aSoC audio
- ******************************************************************************/
-static struct palm27x_asoc_info palmt5_asoc_pdata = {
-	.jack_gpio	= GPIO_NR_PALMT5_EARPHONE_DETECT,
+static struct wm97xx_pdata palmt5_wm97xx_pdata = {
+	.batt_pdata	= &palmt5_batt_pdata,
 };
 
 static pxa2xx_audio_ops_t palmt5_ac97_pdata = {
 	.reset_gpio	= 95,
+	.codec_pdata	= { &palmt5_wm97xx_pdata, },
+};
+
+static struct palm27x_asoc_info palmt5_asoc_pdata = {
+	.jack_gpio	= GPIO_NR_PALMT5_EARPHONE_DETECT,
 };
 
 static struct platform_device palmt5_asoc = {
@@ -426,7 +428,6 @@ static void __init palmt5_init(void)
 	pxa_set_ac97_info(&palmt5_ac97_pdata);
 	pxa_set_ficp_info(&palmt5_ficp_platform_data);
 	pxa_set_keypad_info(&palmt5_keypad_platform_data);
-	wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
 
 	platform_add_devices(devices, ARRAY_SIZE(devices));
 }
diff --git a/arch/arm/mach-pxa/palmte2.c b/arch/arm/mach-pxa/palmte2.c
index 277c406..21c241b 100644
--- a/arch/arm/mach-pxa/palmte2.c
+++ b/arch/arm/mach-pxa/palmte2.c
@@ -23,7 +23,7 @@
 #include <linux/pda_power.h>
 #include <linux/pwm_backlight.h>
 #include <linux/gpio.h>
-#include <linux/wm97xx_batt.h>
+#include <linux/wm97xx.h>
 #include <linux/power_supply.h>
 #include <linux/usb/gpio_vbus.h>
 
@@ -290,9 +290,9 @@ static struct platform_device power_supply = {
 };
 
 /******************************************************************************
- * WM97xx battery
+ * WM97xx audio, battery
  ******************************************************************************/
-static struct wm97xx_batt_info wm97xx_batt_pdata = {
+static struct wm97xx_batt_pdata palmte2_batt_pdata = {
 	.batt_aux	= WM97XX_AUX_ID3,
 	.temp_aux	= WM97XX_AUX_ID2,
 	.charge_gpio	= -1,
@@ -306,9 +306,14 @@ static struct wm97xx_batt_info wm97xx_batt_pdata = {
 	.batt_name	= "main-batt",
 };
 
-/******************************************************************************
- * aSoC audio
- ******************************************************************************/
+static struct wm97xx_pdata palmte2_wm97xx_pdata = {
+	.batt_pdata	= &palmte2_batt_pdata,
+};
+
+static pxa2xx_audio_ops_t palmte2_ac97_pdata = {
+	.codec_pdata	= { &palmte2_wm97xx_pdata, },
+};
+
 static struct palm27x_asoc_info palmte2_asoc_pdata = {
 	.jack_gpio	= GPIO_NR_PALMTE2_EARPHONE_DETECT,
 };
@@ -376,9 +381,8 @@ static void __init palmte2_init(void)
 	set_pxa_fb_info(&palmte2_lcd_screen);
 	pxa_set_mci_info(&palmte2_mci_platform_data);
 	palmte2_udc_init();
-	pxa_set_ac97_info(NULL);
+	pxa_set_ac97_info(&palmte2_ac97_pdata);
 	pxa_set_ficp_info(&palmte2_ficp_platform_data);
-	wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
 
 	platform_add_devices(devices, ARRAY_SIZE(devices));
 }
diff --git a/arch/arm/mach-pxa/palmtx.c b/arch/arm/mach-pxa/palmtx.c
index f1e248c..554b3da 100644
--- a/arch/arm/mach-pxa/palmtx.c
+++ b/arch/arm/mach-pxa/palmtx.c
@@ -25,7 +25,7 @@
 #include <linux/pda_power.h>
 #include <linux/pwm_backlight.h>
 #include <linux/gpio.h>
-#include <linux/wm97xx_batt.h>
+#include <linux/wm97xx.h>
 #include <linux/power_supply.h>
 #include <linux/usb/gpio_vbus.h>
 #include <linux/mtd/nand.h>
@@ -340,9 +340,9 @@ static struct platform_device power_supply = {
 };
 
 /******************************************************************************
- * WM97xx battery
+ * WM97xx audio, battery
  ******************************************************************************/
-static struct wm97xx_batt_info wm97xx_batt_pdata = {
+static struct wm97xx_batt_pdata palmtx_batt_pdata = {
 	.batt_aux	= WM97XX_AUX_ID3,
 	.temp_aux	= WM97XX_AUX_ID2,
 	.charge_gpio	= -1,
@@ -356,15 +356,17 @@ static struct wm97xx_batt_info wm97xx_batt_pdata = {
 	.batt_name	= "main-batt",
 };
 
-/******************************************************************************
- * aSoC audio
- ******************************************************************************/
-static struct palm27x_asoc_info palmtx_asoc_pdata = {
-	.jack_gpio	= GPIO_NR_PALMTX_EARPHONE_DETECT,
+static struct wm97xx_pdata palmtx_wm97xx_pdata = {
+	.batt_pdata	= &palmtx_batt_pdata,
 };
 
 static pxa2xx_audio_ops_t palmtx_ac97_pdata = {
 	.reset_gpio	= 95,
+	.codec_pdata	= { &palmtx_wm97xx_pdata, },
+};
+
+static struct palm27x_asoc_info palmtx_asoc_pdata = {
+	.jack_gpio	= GPIO_NR_PALMTX_EARPHONE_DETECT,
 };
 
 static struct platform_device palmtx_asoc = {
@@ -538,7 +540,6 @@ static void __init palmtx_init(void)
 	pxa_set_ac97_info(&palmtx_ac97_pdata);
 	pxa_set_ficp_info(&palmtx_ficp_platform_data);
 	pxa_set_keypad_info(&palmtx_keypad_platform_data);
-	wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
 
 	platform_add_devices(devices, ARRAY_SIZE(devices));
 }
diff --git a/arch/arm/mach-pxa/palmz72.c b/arch/arm/mach-pxa/palmz72.c
index c2bf493..b769447 100644
--- a/arch/arm/mach-pxa/palmz72.c
+++ b/arch/arm/mach-pxa/palmz72.c
@@ -27,7 +27,7 @@
 #include <linux/pda_power.h>
 #include <linux/pwm_backlight.h>
 #include <linux/gpio.h>
-#include <linux/wm97xx_batt.h>
+#include <linux/wm97xx.h>
 #include <linux/power_supply.h>
 #include <linux/usb/gpio_vbus.h>
 
@@ -343,9 +343,9 @@ static struct platform_device power_supply = {
 };
 
 /******************************************************************************
- * WM97xx battery
+ * WM97xx audio, battery
  ******************************************************************************/
-static struct wm97xx_batt_info wm97xx_batt_pdata = {
+static struct wm97xx_batt_pdata palmz72_batt_pdata = {
 	.batt_aux	= WM97XX_AUX_ID3,
 	.temp_aux	= WM97XX_AUX_ID2,
 	.charge_gpio	= -1,
@@ -359,9 +359,14 @@ static struct wm97xx_batt_info wm97xx_batt_pdata = {
 	.batt_name	= "main-batt",
 };
 
-/******************************************************************************
- * aSoC audio
- ******************************************************************************/
+static struct wm97xx_pdata palmz72_wm97xx_pdata = {
+	.batt_pdata	= &palmz72_batt_pdata,
+};
+
+static pxa2xx_audio_ops_t palmz72_ac97_pdata = {
+	.codec_pdata	= { &palmz72_wm97xx_pdata, },
+};
+
 static struct platform_device palmz72_asoc = {
 	.name = "palm27x-asoc",
 	.id   = -1,
@@ -494,10 +499,9 @@ static void __init palmz72_init(void)
 	set_pxa_fb_info(&palmz72_lcd_screen);
 	pxa_set_mci_info(&palmz72_mci_platform_data);
 	palmz72_udc_init();
-	pxa_set_ac97_info(NULL);
+	pxa_set_ac97_info(&palmz72_ac97_pdata);
 	pxa_set_ficp_info(&palmz72_ficp_platform_data);
 	pxa_set_keypad_info(&palmz72_keypad_platform_data);
-	wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
 
 	platform_add_devices(devices, ARRAY_SIZE(devices));
 }
diff --git a/arch/arm/mach-pxa/treo680.c b/arch/arm/mach-pxa/treo680.c
index f537265..f9acb12 100644
--- a/arch/arm/mach-pxa/treo680.c
+++ b/arch/arm/mach-pxa/treo680.c
@@ -19,7 +19,6 @@
 #include <linux/pda_power.h>
 #include <linux/pwm_backlight.h>
 #include <linux/gpio.h>
-#include <linux/wm97xx_batt.h>
 #include <linux/power_supply.h>
 #include <linux/sysdev.h>
 #include <linux/w1-gpio.h>
-- 
1.6.3.3


[-- Attachment #3: Type: text/plain, Size: 160 bytes --]

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* Re: [PATCH 2/4] Allow passing platform_data for pxa2xx-ac97
  2009-07-23 18:39                             ` Marek Vasut
@ 2009-07-28  5:28                               ` Marek Vasut
  2009-07-30  0:55                                 ` Marek Vasut
  0 siblings, 1 reply; 52+ messages in thread
From: Marek Vasut @ 2009-07-28  5:28 UTC (permalink / raw)
  To: Mark Brown
  Cc: alsa-devel, Russell King - ARM Linux, Takashi Iwai,
	Robert Jarzmik, cbou, Eric Miao, avorontsov, dwmw2,
	linux-arm-kernel

Dne Čt 23. července 2009 20:39:37 Marek Vasut napsal(a):
> Dne Čt 23. července 2009 16:16:12 Marek Vasut napsal(a):
> > Dne Čt 23. července 2009 12:27:41 Mark Brown napsal(a):
> > > On Wed, Jul 22, 2009 at 01:02:40PM +0200, Marek Vasut wrote:
> > > >  	struct snd_ac97_bus *ac97_bus;
> > > >  	struct snd_ac97_template ac97_template;
> > > >  	int ret;
> > > > +	pxa2xx_audio_ops_t *pdata = dev->dev.platform_data;
> > > > +	int id = dev->id < 0 ? 0 : dev->id;
> > >
> > > dev here is the AC97 controller device - if there's more than one AC97
> > > controller in the system they can each have the four child devices.  On
> > > the other hand, I don't think any of the PXA processors have more than
> > > one AC97 controller so it'll never actually have any impact.
> > >
> > > I think the best thing for now is to either warn if anything except the
> > > primary codec has platform data or change the platform data to have a
> > > variable something like primary_audio_pdata.  The driver doesn't appear
> > > to support secondary codecs anyway.
> >
> > Ok, here's a fixed patch.
>
> Argh, one more iteration here. There was a typo in the previous patch.
> Sorry.

Hi, well ... any updates ? Eric, is this patch ok with you ?
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 2/4] Allow passing platform_data for pxa2xx-ac97
  2009-07-28  5:28                               ` Marek Vasut
@ 2009-07-30  0:55                                 ` Marek Vasut
  2009-08-13 20:40                                   ` Mark Brown
  0 siblings, 1 reply; 52+ messages in thread
From: Marek Vasut @ 2009-07-30  0:55 UTC (permalink / raw)
  To: Mark Brown
  Cc: alsa-devel, Russell King - ARM Linux, Takashi Iwai,
	Robert Jarzmik, cbou, Eric Miao, avorontsov, dwmw2,
	linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 1489 bytes --]

Dne Út 28. července 2009 07:28:20 Marek Vasut napsal(a):
> Dne Čt 23. července 2009 20:39:37 Marek Vasut napsal(a):
> > Dne Čt 23. července 2009 16:16:12 Marek Vasut napsal(a):
> > > Dne Čt 23. července 2009 12:27:41 Mark Brown napsal(a):
> > > > On Wed, Jul 22, 2009 at 01:02:40PM +0200, Marek Vasut wrote:
> > > > >  	struct snd_ac97_bus *ac97_bus;
> > > > >  	struct snd_ac97_template ac97_template;
> > > > >  	int ret;
> > > > > +	pxa2xx_audio_ops_t *pdata = dev->dev.platform_data;
> > > > > +	int id = dev->id < 0 ? 0 : dev->id;
> > > >
> > > > dev here is the AC97 controller device - if there's more than one
> > > > AC97 controller in the system they can each have the four child
> > > > devices.  On the other hand, I don't think any of the PXA processors
> > > > have more than one AC97 controller so it'll never actually have any
> > > > impact.
> > > >
> > > > I think the best thing for now is to either warn if anything except
> > > > the primary codec has platform data or change the platform data to
> > > > have a variable something like primary_audio_pdata.  The driver
> > > > doesn't appear to support secondary codecs anyway.
> > >
> > > Ok, here's a fixed patch.
> >
> > Argh, one more iteration here. There was a typo in the previous patch.
> > Sorry.
>
> Hi, well ... any updates ? Eric, is this patch ok with you ?

I made one more revision here as in case the platform_data aren't supplied, 
the kernel obviously crashes.

[-- Attachment #2: 0001-Allow-passing-platform_data-for-pxa2xx-ac97.patch --]
[-- Type: text/x-patch, Size: 4083 bytes --]

From 207d54244768e94ce0144cba55acf4ae065e6ce0 Mon Sep 17 00:00:00 2001
From: Marek Vasut <marek.vasut@gmail.com>
Date: Tue, 21 Jul 2009 16:22:29 +0200
Subject: [PATCH] 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>
---
 arch/arm/mach-pxa/include/mach/audio.h |    3 +++
 include/sound/ac97_codec.h             |    3 +++
 sound/arm/pxa2xx-ac97.c                |   10 ++++++++++
 sound/soc/pxa/pxa2xx-ac97.c            |   12 +++++++++++-
 4 files changed, 27 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-pxa/include/mach/audio.h b/arch/arm/mach-pxa/include/mach/audio.h
index 16eb025..a3449e3 100644
--- a/arch/arm/mach-pxa/include/mach/audio.h
+++ b/arch/arm/mach-pxa/include/mach/audio.h
@@ -3,10 +3,12 @@
 
 #include <sound/core.h>
 #include <sound/pcm.h>
+#include <sound/ac97_codec.h>
 
 /*
  * @reset_gpio: AC97 reset gpio (normally gpio113 or gpio95)
  *              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
  * bug prevents correct operation of the reset line. If not specified,
@@ -20,6 +22,7 @@ typedef struct {
 	void (*resume)(void *);
 	void *priv;
 	int reset_gpio;
+	void *codec_pdata[AC97_BUS_MAX_DEVICES];
 } pxa2xx_audio_ops_t;
 
 extern void pxa_set_ac97_info(pxa2xx_audio_ops_t *ops);
diff --git a/include/sound/ac97_codec.h b/include/sound/ac97_codec.h
index 9b1c098..3dae3f7 100644
--- a/include/sound/ac97_codec.h
+++ b/include/sound/ac97_codec.h
@@ -32,6 +32,9 @@
 #include "control.h"
 #include "info.h"
 
+/* maximum number of devices on the AC97 bus */
+#define	AC97_BUS_MAX_DEVICES	4
+
 /*
  *  AC'97 codec registers
  */
diff --git a/sound/arm/pxa2xx-ac97.c b/sound/arm/pxa2xx-ac97.c
index c570ebd..6c00ea4 100644
--- a/sound/arm/pxa2xx-ac97.c
+++ b/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_template ac97_template;
 	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,
 			      THIS_MODULE, 0, &card);
@@ -200,6 +207,8 @@ static int __devinit pxa2xx_ac97_probe(struct platform_device *dev)
 	snprintf(card->longname, sizeof(card->longname),
 		 "%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);
 	ret = snd_card_register(card);
 	if (ret == 0) {
@@ -212,6 +221,7 @@ err_remove:
 err:
 	if (card)
 		snd_card_free(card);
+err_dev:
 	return ret;
 }
 
diff --git a/sound/soc/pxa/pxa2xx-ac97.c b/sound/soc/pxa/pxa2xx-ac97.c
index d9c94d7..7330e5c 100644
--- a/sound/soc/pxa/pxa2xx-ac97.c
+++ b/sound/soc/pxa/pxa2xx-ac97.c
@@ -22,6 +22,7 @@
 #include <mach/hardware.h>
 #include <mach/regs-ac97.h>
 #include <mach/dma.h>
+#include <mach/audio.h>
 
 #include "pxa2xx-pcm.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)
 {
 	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;
+		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
 	 * driver to do interesting things with the clocking to get us up
-- 
1.6.3.3


[-- Attachment #3: Type: text/plain, Size: 160 bytes --]

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 52+ messages in thread

* Re: [PATCH 2/4] Allow passing platform_data for pxa2xx-ac97
  2009-07-30  0:55                                 ` Marek Vasut
@ 2009-08-13 20:40                                   ` Mark Brown
  2009-08-13 23:34                                     ` Marek Vasut
  0 siblings, 1 reply; 52+ messages in thread
From: Mark Brown @ 2009-08-13 20:40 UTC (permalink / raw)
  To: Marek Vasut
  Cc: alsa-devel, Russell King - ARM Linux, Takashi Iwai, dwmw2, cbou,
	Eric Miao, avorontsov, Robert Jarzmik, linux-arm-kernel

On Thu, Jul 30, 2009 at 02:55:01AM +0200, Marek Vasut wrote:

> From 207d54244768e94ce0144cba55acf4ae065e6ce0 Mon Sep 17 00:00:00 2001
> From: Marek Vasut <marek.vasut@gmail.com>
> Date: Tue, 21 Jul 2009 16:22:29 +0200
> Subject: [PATCH] Allow passing platform_data for pxa2xx-ac97
> 
> This patch adds support for passing platform data to ac97 bus devices
> from PXA2xx-AC97 driver..

I've applied this one too since it's ALSA only and it'll ease merge
issues next merge window - we can revisit if any of the other patches
get applied before.

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 2/4] Allow passing platform_data for pxa2xx-ac97
  2009-08-13 20:40                                   ` Mark Brown
@ 2009-08-13 23:34                                     ` Marek Vasut
  2009-08-13 23:42                                       ` Anton Vorontsov
  2009-08-14  8:57                                       ` Mark Brown
  0 siblings, 2 replies; 52+ messages in thread
From: Marek Vasut @ 2009-08-13 23:34 UTC (permalink / raw)
  To: Mark Brown, linux-arm-kernel
  Cc: alsa-devel, Russell King - ARM Linux, Takashi Iwai, dwmw2, cbou,
	Eric Miao, avorontsov, Robert Jarzmik

Dne Čt 13. srpna 2009 22:40:34 Mark Brown napsal(a):
> On Thu, Jul 30, 2009 at 02:55:01AM +0200, Marek Vasut wrote:
> > From 207d54244768e94ce0144cba55acf4ae065e6ce0 Mon Sep 17 00:00:00 2001
> > From: Marek Vasut <marek.vasut@gmail.com>
> > Date: Tue, 21 Jul 2009 16:22:29 +0200
> > Subject: [PATCH] Allow passing platform_data for pxa2xx-ac97
> >
> > This patch adds support for passing platform data to ac97 bus devices
> > from PXA2xx-AC97 driver..
>
> I've applied this one too since it's ALSA only and it'll ease merge
> issues next merge window - we can revisit if any of the other patches
> get applied before.

Hi,

thanks, I think you can apply the 3/4 and 4/4 as well. But you should probably 
talk to Anton about the 3/4 if he wants to merge it through your tree or his 
or whatever. He acked it previously, it's in that huge thread from july. The 
mail's subject is "[PATCH 2/4] Allow passing platform_data for pxa2xx-ac97" 
and it's from 22/07/2009.

Cheers!
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 2/4] Allow passing platform_data for pxa2xx-ac97
  2009-08-13 23:34                                     ` Marek Vasut
@ 2009-08-13 23:42                                       ` Anton Vorontsov
  2009-08-14  8:57                                       ` Mark Brown
  1 sibling, 0 replies; 52+ messages in thread
From: Anton Vorontsov @ 2009-08-13 23:42 UTC (permalink / raw)
  To: Marek Vasut
  Cc: alsa-devel, Russell King - ARM Linux, Takashi Iwai, dwmw2,
	Mark Brown, cbou, Eric Miao, Robert Jarzmik, linux-arm-kernel

On Fri, Aug 14, 2009 at 01:34:22AM +0200, Marek Vasut wrote:
> Dne Čt 13. srpna 2009 22:40:34 Mark Brown napsal(a):
> > On Thu, Jul 30, 2009 at 02:55:01AM +0200, Marek Vasut wrote:
> > > From 207d54244768e94ce0144cba55acf4ae065e6ce0 Mon Sep 17 00:00:00 2001
> > > From: Marek Vasut <marek.vasut@gmail.com>
> > > Date: Tue, 21 Jul 2009 16:22:29 +0200
> > > Subject: [PATCH] Allow passing platform_data for pxa2xx-ac97
> > >
> > > This patch adds support for passing platform data to ac97 bus devices
> > > from PXA2xx-AC97 driver..
> >
> > I've applied this one too since it's ALSA only and it'll ease merge
> > issues next merge window - we can revisit if any of the other patches
> > get applied before.
> 
> Hi,
> 
> thanks, I think you can apply the 3/4 and 4/4 as well. But you should probably 
> talk to Anton about the 3/4 if he wants to merge it through your tree or his 
> or whatever. He acked it previously, it's in that huge thread from july. The 
> mail's subject is "[PATCH 2/4] Allow passing platform_data for pxa2xx-ac97" 
> and it's from 22/07/2009.

I'm fine with it going through Mark's tree. Thanks!

-- 
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 52+ messages in thread

* Re: [PATCH 2/4] Allow passing platform_data for pxa2xx-ac97
  2009-08-13 23:34                                     ` Marek Vasut
  2009-08-13 23:42                                       ` Anton Vorontsov
@ 2009-08-14  8:57                                       ` Mark Brown
  1 sibling, 0 replies; 52+ messages in thread
From: Mark Brown @ 2009-08-14  8:57 UTC (permalink / raw)
  To: Marek Vasut
  Cc: alsa-devel, Russell King - ARM Linux, Takashi Iwai, dwmw2, cbou,
	Eric Miao, avorontsov, Robert Jarzmik, linux-arm-kernel

On Fri, Aug 14, 2009 at 01:34:22AM +0200, Marek Vasut wrote:
> Dne Čt 13. srpna 2009 22:40:34 Mark Brown napsal(a):

> > I've applied this one too since it's ALSA only and it'll ease merge
> > issues next merge window - we can revisit if any of the other patches
> > get applied before.

> thanks, I think you can apply the 3/4 and 4/4 as well. But you should probably 
> talk to Anton about the 3/4 if he wants to merge it through your tree or his 
> or whatever. He acked it previously, it's in that huge thread from july. The 
> mail's subject is "[PATCH 2/4] Allow passing platform_data for pxa2xx-ac97" 
> and it's from 22/07/2009.

Will those be OK for the Palm platforms without the arch/arm changes?
AFAIR (and I may be remembering an old version) these patches would
break the Palms unless the arch/arm stuff goes in in the same merge
window.
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 52+ messages in thread

end of thread, other threads:[~2009-08-14  8:57 UTC | newest]

Thread overview: 52+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-21 14:33 [PATCH] Allow passing platform_data to devices attached to AC97 bus Marek Vasut
2009-07-21 14:50 ` Takashi Iwai
2009-07-21 14:53   ` Mark Brown
2009-07-21 15:16     ` Takashi Iwai
2009-07-21 15:40       ` Marek Vasut
2009-07-21 18:30         ` Mark Brown
2009-07-21 19:51           ` Marek Vasut
2009-07-22 10:40             ` Mark Brown
2009-07-22 10:59               ` [PATCH 1/4] " Marek Vasut
2009-07-23 10:16                 ` Mark Brown
2009-07-23 10:28                   ` Takashi Iwai
2009-07-23 10:31                     ` Mark Brown
2009-07-21 20:24           ` [PATCH] " Marek Vasut
2009-07-21 20:59             ` Takashi Iwai
2009-07-21 21:53               ` Marek Vasut
2009-07-21 22:13                 ` Marek Vasut
2009-07-21 22:33                   ` Russell King - ARM Linux
2009-07-21 22:39                     ` Marek Vasut
2009-07-21 22:40                       ` Marek Vasut
2009-07-21 22:34                   ` Anton Vorontsov
2009-07-21 22:43                     ` Marek Vasut
2009-07-22 11:01                     ` [PATCH 1/4] " Marek Vasut
2009-07-22 11:02                       ` [PATCH 2/4] Allow passing platform_data for pxa2xx-ac97 Marek Vasut
2009-07-23 10:27                         ` Mark Brown
2009-07-23 14:16                           ` Marek Vasut
2009-07-23 15:14                             ` Mark Brown
2009-07-23 18:39                             ` Marek Vasut
2009-07-28  5:28                               ` Marek Vasut
2009-07-30  0:55                                 ` Marek Vasut
2009-08-13 20:40                                   ` Mark Brown
2009-08-13 23:34                                     ` Marek Vasut
2009-08-13 23:42                                       ` Anton Vorontsov
2009-08-14  8:57                                       ` Mark Brown
2009-07-22 11:04                       ` [PATCH 3/4] Convert WM97xx driver to use platform_data Marek Vasut
2009-07-23 11:49                         ` Mark Brown
2009-07-24 19:44                         ` Robert Jarzmik
2009-07-24 21:03                           ` Marek Vasut
2009-07-22 11:05                       ` [PATCH 4/4] Convert all platforms to pass platform_data to wm97xx battery Marek Vasut
2009-07-22 18:09                         ` Robert Jarzmik
2009-07-22 18:30                           ` Marek Vasut
2009-07-25 20:55                             ` Robert Jarzmik
2009-07-27  0:06                             ` Marek Vasut
2009-07-21 20:25           ` [PATCH] Allow passing platform_data to devices attached to AC97 bus Marek Vasut
2009-07-21 15:41       ` Marek Vasut
2009-07-21 17:40       ` Marek Vasut
2009-07-21 18:27         ` Mark Brown
2009-07-21 18:38           ` Mark Brown
2009-07-21 17:42       ` Marek Vasut
2009-07-21 18:18       ` Marek Vasut
2009-07-21 15:11 ` Robert Jarzmik
2009-07-21 15:17   ` Takashi Iwai
2009-07-25 20:56   ` Robert Jarzmik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox