* [PATCH v3 0/3] ALSA SoC: MPC5200 audio driver
@ 2008-07-22 6:58 Grant Likely
2008-07-22 9:26 ` [alsa-devel] " Mark Brown
2008-07-22 11:52 ` Mark Brown
0 siblings, 2 replies; 15+ messages in thread
From: Grant Likely @ 2008-07-22 6:58 UTC (permalink / raw)
To: linuxppc-dev, alsa-devel, liam.girdwood; +Cc: broonie, timur
Hi all,
Here is the latest series for adding MPC5200 I2S and TI AIC26 codec
support to ALSA SoC. I believe all the comments are addressed and I
hope that this series is now ready to be merged. I would really like
to see these ones land in 2.6.27.
Thanks,
g.
include/sound/soc-of-simple.h | 21 +
sound/soc/codecs/Kconfig | 4 +
sound/soc/codecs/Makefile | 2 +
sound/soc/codecs/tlv320aic26.c | 519 +++++++++++++++++++++++
sound/soc/codecs/tlv320aic26.h | 93 ++++
sound/soc/fsl/Kconfig | 10 +
sound/soc/fsl/Makefile | 5 +
sound/soc/fsl/mpc5200_psc_i2s.c | 884 +++++++++++++++++++++++++++++++++++++++
sound/soc/fsl/soc-of-simple.c | 171 ++++++++
9 files changed, 1709 insertions(+), 0 deletions(-)
Cheers,
g.
On Tue, Jul 22, 2008 at 12:53 AM, Grant Likely
<grant.likely@secretlab.ca> wrote:
> From: Grant Likely <grant.likely@secretlab.ca>
>
> Simple utility layer for creating ASoC machine instances based on data
> in the OpenFirmware device tree. OF aware platform drivers and codec
> drivers register themselves with this framework and the framework
> automatically instantiates a machine driver. At the moment, the driver
> is not very capable and it is expected to be extended as more features
> are needed for specifying the configuration in the device tree.
>
> This is most likely temporary glue code to work around limitations in
> the ASoC v1 framework. When v2 is merged, most of this driver will
> need to be reworked.
>
> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
> ---
>
> include/sound/soc-of-simple.h | 21 +++++
> sound/soc/fsl/Kconfig | 3 +
> sound/soc/fsl/Makefile | 3 +
> sound/soc/fsl/soc-of-simple.c | 171 +++++++++++++++++++++++++++++++++++++++++
> 4 files changed, 198 insertions(+), 0 deletions(-)
>
> diff --git a/include/sound/soc-of-simple.h b/include/sound/soc-of-simple.h
> new file mode 100644
> index 0000000..696fc51
> --- /dev/null
> +++ b/include/sound/soc-of-simple.h
> @@ -0,0 +1,21 @@
> +/*
> + * OF helpers for ALSA SoC
> + *
> + * Copyright (C) 2008, Secret Lab Technologies Ltd.
> + */
> +
> +#ifndef _INCLUDE_SOC_OF_H_
> +#define _INCLUDE_SOC_OF_H_
> +
> +#include <linux/of.h>
> +#include <sound/soc.h>
> +
> +int of_snd_soc_register_codec(struct snd_soc_codec_device *codec_dev,
> + void *codec_data, struct snd_soc_dai *dai,
> + struct device_node *node);
> +
> +int of_snd_soc_register_platform(struct snd_soc_platform *platform,
> + struct device_node *node,
> + struct snd_soc_dai *cpu_dai);
> +
> +#endif /* _INCLUDE_SOC_OF_H_ */
> diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig
> index 3368ace..398f002 100644
> --- a/sound/soc/fsl/Kconfig
> +++ b/sound/soc/fsl/Kconfig
> @@ -1,3 +1,6 @@
> +config SND_SOC_OF_SIMPLE
> + tristate
> +
> config SND_SOC_MPC8610
> bool "ALSA SoC support for the MPC8610 SOC"
> depends on MPC8610_HPCD
> diff --git a/sound/soc/fsl/Makefile b/sound/soc/fsl/Makefile
> index 62f680a..aa2100b 100644
> --- a/sound/soc/fsl/Makefile
> +++ b/sound/soc/fsl/Makefile
> @@ -1,3 +1,6 @@
> +# Simple machine driver that extracts configuration from the OF device tree
> +obj-$(CONFIG_SND_SOC_OF_SIMPLE) += soc-of-simple.o
> +
> # MPC8610 HPCD Machine Support
> obj-$(CONFIG_SND_SOC_MPC8610_HPCD) += mpc8610_hpcd.o
>
> diff --git a/sound/soc/fsl/soc-of-simple.c b/sound/soc/fsl/soc-of-simple.c
> new file mode 100644
> index 0000000..0382fda
> --- /dev/null
> +++ b/sound/soc/fsl/soc-of-simple.c
> @@ -0,0 +1,171 @@
> +/*
> + * OF helpers for ALSA SoC Layer
> + *
> + * Copyright (C) 2008, Secret Lab Technologies Ltd.
> + */
> +
> +#include <linux/module.h>
> +#include <linux/moduleparam.h>
> +#include <linux/init.h>
> +#include <linux/delay.h>
> +#include <linux/pm.h>
> +#include <linux/bitops.h>
> +#include <linux/platform_device.h>
> +#include <linux/of.h>
> +#include <sound/core.h>
> +#include <sound/pcm.h>
> +#include <sound/pcm_params.h>
> +#include <sound/soc.h>
> +#include <sound/soc-of-simple.h>
> +#include <sound/initval.h>
> +
> +MODULE_AUTHOR("Grant Likely <grant.likely@secretlab.ca>");
> +MODULE_LICENSE("GPL");
> +MODULE_DESCRIPTION("ALSA SoC OpenFirmware bindings");
> +
> +static DEFINE_MUTEX(of_snd_soc_mutex);
> +static LIST_HEAD(of_snd_soc_device_list);
> +static int of_snd_soc_next_index;
> +
> +struct of_snd_soc_device {
> + int id;
> + struct list_head list;
> + struct snd_soc_device device;
> + struct snd_soc_machine machine;
> + struct snd_soc_dai_link dai_link;
> + struct platform_device *pdev;
> + struct device_node *platform_node;
> + struct device_node *codec_node;
> +};
> +
> +static struct snd_soc_ops of_snd_soc_ops = {
> +};
> +
> +static struct of_snd_soc_device *
> +of_snd_soc_get_device(struct device_node *codec_node)
> +{
> + struct of_snd_soc_device *of_soc;
> +
> + list_for_each_entry(of_soc, &of_snd_soc_device_list, list) {
> + if (of_soc->codec_node == codec_node)
> + return of_soc;
> + }
> +
> + of_soc = kzalloc(sizeof(struct of_snd_soc_device), GFP_KERNEL);
> + if (!of_soc)
> + return NULL;
> +
> + /* Initialize the structure and add it to the global list */
> + of_soc->codec_node = codec_node;
> + of_soc->id = of_snd_soc_next_index++;
> + of_soc->machine.dai_link = &of_soc->dai_link;
> + of_soc->machine.num_links = 1;
> + of_soc->device.machine = &of_soc->machine;
> + of_soc->dai_link.ops = &of_snd_soc_ops;
> + list_add(&of_soc->list, &of_snd_soc_device_list);
> +
> + return of_soc;
> +}
> +
> +static void of_snd_soc_register_device(struct of_snd_soc_device *of_soc)
> +{
> + struct platform_device *pdev;
> + int rc;
> +
> + /* Only register the device if both the codec and platform have
> + * been registered */
> + if ((!of_soc->device.codec_data) || (!of_soc->platform_node))
> + return;
> +
> + pr_info("platform<-->codec match achieved; registering machine\n");
> +
> + pdev = platform_device_alloc("soc-audio", of_soc->id);
> + if (!pdev) {
> + pr_err("of_soc: platform_device_alloc() failed\n");
> + return;
> + }
> +
> + pdev->dev.platform_data = of_soc;
> + platform_set_drvdata(pdev, &of_soc->device);
> + of_soc->device.dev = &pdev->dev;
> +
> + /* The ASoC device is complete; register it */
> + rc = platform_device_add(pdev);
> + if (rc) {
> + pr_err("of_soc: platform_device_add() failed\n");
> + return;
> + }
> +
> +}
> +
> +int of_snd_soc_register_codec(struct snd_soc_codec_device *codec_dev,
> + void *codec_data, struct snd_soc_dai *dai,
> + struct device_node *node)
> +{
> + struct of_snd_soc_device *of_soc;
> + int rc = 0;
> +
> + pr_info("registering ASoC codec driver: %s\n", node->full_name);
> +
> + mutex_lock(&of_snd_soc_mutex);
> + of_soc = of_snd_soc_get_device(node);
> + if (!of_soc) {
> + rc = -ENOMEM;
> + goto out;
> + }
> +
> + /* Store the codec data */
> + of_soc->device.codec_data = codec_data;
> + of_soc->device.codec_dev = codec_dev;
> + of_soc->dai_link.name = (char *)node->name;
> + of_soc->dai_link.stream_name = (char *)node->name;
> + of_soc->dai_link.codec_dai = dai;
> +
> + /* Now try to register the SoC device */
> + of_snd_soc_register_device(of_soc);
> +
> + out:
> + mutex_unlock(&of_snd_soc_mutex);
> + return rc;
> +}
> +EXPORT_SYMBOL_GPL(of_snd_soc_register_codec);
> +
> +int of_snd_soc_register_platform(struct snd_soc_platform *platform,
> + struct device_node *node,
> + struct snd_soc_dai *cpu_dai)
> +{
> + struct of_snd_soc_device *of_soc;
> + struct device_node *codec_node;
> + const phandle *handle;
> + int len, rc = 0;
> +
> + pr_info("registering ASoC platform driver: %s\n", node->full_name);
> +
> + handle = of_get_property(node, "codec-handle", &len);
> + if (!handle || len < sizeof(handle))
> + return -ENODEV;
> + codec_node = of_find_node_by_phandle(*handle);
> + if (!codec_node)
> + return -ENODEV;
> + pr_info("looking for codec: %s\n", codec_node->full_name);
> +
> + mutex_lock(&of_snd_soc_mutex);
> + of_soc = of_snd_soc_get_device(codec_node);
> + if (!of_soc) {
> + rc = -ENOMEM;
> + goto out;
> + }
> +
> + of_soc->platform_node = node;
> + of_soc->dai_link.cpu_dai = cpu_dai;
> + of_soc->device.platform = platform;
> + of_soc->machine.name = of_soc->dai_link.cpu_dai->name;
> +
> + /* Now try to register the SoC device */
> + of_snd_soc_register_device(of_soc);
> +
> + out:
> + mutex_unlock(&of_snd_soc_mutex);
> + return rc;
> +}
> +EXPORT_SYMBOL_GPL(of_snd_soc_register_platform);
>
>
--
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [alsa-devel] [PATCH v3 0/3] ALSA SoC: MPC5200 audio driver
2008-07-22 6:58 [PATCH v3 0/3] ALSA SoC: MPC5200 audio driver Grant Likely
@ 2008-07-22 9:26 ` Mark Brown
2008-07-22 13:38 ` Jon Smirl
2008-07-22 21:26 ` Grant Likely
2008-07-22 11:52 ` Mark Brown
1 sibling, 2 replies; 15+ messages in thread
From: Mark Brown @ 2008-07-22 9:26 UTC (permalink / raw)
To: Grant Likely; +Cc: linuxppc-dev, alsa-devel, timur, liam.girdwood
On Tue, Jul 22, 2008 at 12:58:09AM -0600, Grant Likely wrote:
> Here is the latest series for adding MPC5200 I2S and TI AIC26 codec
> support to ALSA SoC. I believe all the comments are addressed and I
> hope that this series is now ready to be merged. I would really like
> to see these ones land in 2.6.27.
That might be a bit of a push given how far into the merge window we
are and Takashi's holiday this week, though as they are new drivers
things could be a bit more relaxed.
Takashi, I'll queue these (and other ASoC patches) for submission in
bulk once you return.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v3 0/3] ALSA SoC: MPC5200 audio driver
2008-07-22 6:58 [PATCH v3 0/3] ALSA SoC: MPC5200 audio driver Grant Likely
2008-07-22 9:26 ` [alsa-devel] " Mark Brown
@ 2008-07-22 11:52 ` Mark Brown
2008-07-22 11:53 ` [PATCH 1/3] ASoC: Make OpenFirmware helper include file conditional Mark Brown
1 sibling, 1 reply; 15+ messages in thread
From: Mark Brown @ 2008-07-22 11:52 UTC (permalink / raw)
To: Grant Likely; +Cc: linuxppc-dev, alsa-devel, timur, liam.girdwood
On Tue, Jul 22, 2008 at 12:58:09AM -0600, Grant Likely wrote:
> Here is the latest series for adding MPC5200 I2S and TI AIC26 codec
> support to ALSA SoC. I believe all the comments are addressed and I
> hope that this series is now ready to be merged. I would really like
> to see these ones land in 2.6.27.
I added the changes in the following fairly trivial patch series to
these to allow tlv320aic26 build cleanly on my ARM platforms.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 1/3] ASoC: Make OpenFirmware helper include file conditional
2008-07-22 11:52 ` Mark Brown
@ 2008-07-22 11:53 ` Mark Brown
2008-07-22 11:53 ` [PATCH 2/3] ASoC: Export DAI and codec for TLV320AIC26 Mark Brown
2008-07-22 21:24 ` [PATCH 1/3] ASoC: Make OpenFirmware helper include file conditional Grant Likely
0 siblings, 2 replies; 15+ messages in thread
From: Mark Brown @ 2008-07-22 11:53 UTC (permalink / raw)
To: Grant Likely
Cc: alsa-project.org, linuxppc-dev, Mark Brown, timur, liam.girdwood
The OpenFirmware API headers don't build on all platforms so ensure
that they are not included unless they are being used.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
include/sound/soc-of-simple.h | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/include/sound/soc-of-simple.h b/include/sound/soc-of-simple.h
index 696fc51..a064e19 100644
--- a/include/sound/soc-of-simple.h
+++ b/include/sound/soc-of-simple.h
@@ -7,6 +7,8 @@
#ifndef _INCLUDE_SOC_OF_H_
#define _INCLUDE_SOC_OF_H_
+#if defined(CONFIG_SND_SOC_OF_SIMPLE) || defined(CONFIG_SND_SOC_OF_SIMPLE_MODULE)
+
#include <linux/of.h>
#include <sound/soc.h>
@@ -18,4 +20,6 @@ int of_snd_soc_register_platform(struct snd_soc_platform *platform,
struct device_node *node,
struct snd_soc_dai *cpu_dai);
+#endif
+
#endif /* _INCLUDE_SOC_OF_H_ */
--
1.5.6.3
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 2/3] ASoC: Export DAI and codec for TLV320AIC26
2008-07-22 11:53 ` [PATCH 1/3] ASoC: Make OpenFirmware helper include file conditional Mark Brown
@ 2008-07-22 11:53 ` Mark Brown
2008-07-22 11:53 ` [PATCH 3/3] ASoC: Staticise keyclick dev_attr in tlv320aic26 Mark Brown
2008-07-22 21:25 ` [PATCH 2/3] ASoC: Export DAI and codec for TLV320AIC26 Grant Likely
2008-07-22 21:24 ` [PATCH 1/3] ASoC: Make OpenFirmware helper include file conditional Grant Likely
1 sibling, 2 replies; 15+ messages in thread
From: Mark Brown @ 2008-07-22 11:53 UTC (permalink / raw)
To: Grant Likely
Cc: alsa-project.org, linuxppc-dev, Mark Brown, timur, liam.girdwood
This fixes sparse warnings and allows non-OpenFirmware systems to attempt
to bind to the device.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
sound/soc/codecs/tlv320aic26.c | 1 +
sound/soc/codecs/tlv320aic26.h | 3 +++
2 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/sound/soc/codecs/tlv320aic26.c b/sound/soc/codecs/tlv320aic26.c
index 4621fda..73b7027 100644
--- a/sound/soc/codecs/tlv320aic26.c
+++ b/sound/soc/codecs/tlv320aic26.c
@@ -383,6 +383,7 @@ struct snd_soc_codec_device aic26_soc_codec_dev = {
.probe = aic26_probe,
.remove = aic26_remove,
};
+EXPORT_SYMBOL_GPL(aic26_soc_codec_dev);
/* ---------------------------------------------------------------------
* SPI device portion of driver: sysfs files for debugging
diff --git a/sound/soc/codecs/tlv320aic26.h b/sound/soc/codecs/tlv320aic26.h
index 62b1f22..786ba16 100644
--- a/sound/soc/codecs/tlv320aic26.h
+++ b/sound/soc/codecs/tlv320aic26.h
@@ -90,4 +90,7 @@ enum aic26_wlen {
AIC26_WLEN_32 = 3 << 10,
};
+extern struct snd_soc_dai aic26_dai;
+extern struct snd_soc_codec_device aic26_soc_codec_dev;
+
#endif /* _TLV320AIC16_H_ */
--
1.5.6.3
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 3/3] ASoC: Staticise keyclick dev_attr in tlv320aic26
2008-07-22 11:53 ` [PATCH 2/3] ASoC: Export DAI and codec for TLV320AIC26 Mark Brown
@ 2008-07-22 11:53 ` Mark Brown
2008-07-22 21:26 ` Grant Likely
2008-07-22 21:25 ` [PATCH 2/3] ASoC: Export DAI and codec for TLV320AIC26 Grant Likely
1 sibling, 1 reply; 15+ messages in thread
From: Mark Brown @ 2008-07-22 11:53 UTC (permalink / raw)
To: Grant Likely
Cc: alsa-project.org, linuxppc-dev, Mark Brown, timur, liam.girdwood
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
sound/soc/codecs/tlv320aic26.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/sound/soc/codecs/tlv320aic26.c b/sound/soc/codecs/tlv320aic26.c
index 73b7027..bed8a9e 100644
--- a/sound/soc/codecs/tlv320aic26.c
+++ b/sound/soc/codecs/tlv320aic26.c
@@ -418,7 +418,7 @@ static ssize_t aic26_keyclick_set(struct device *dev,
return count;
}
-DEVICE_ATTR(keyclick, 0644, aic26_keyclick_show, aic26_keyclick_set);
+static DEVICE_ATTR(keyclick, 0644, aic26_keyclick_show, aic26_keyclick_set);
/* ---------------------------------------------------------------------
* SPI device portion of driver: probe and release routines and SPI
--
1.5.6.3
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [alsa-devel] [PATCH v3 0/3] ALSA SoC: MPC5200 audio driver
2008-07-22 9:26 ` [alsa-devel] " Mark Brown
@ 2008-07-22 13:38 ` Jon Smirl
2008-07-22 14:10 ` Mark Brown
2008-07-22 21:26 ` Grant Likely
1 sibling, 1 reply; 15+ messages in thread
From: Jon Smirl @ 2008-07-22 13:38 UTC (permalink / raw)
To: Grant Likely, linuxppc-dev, alsa-devel, liam.girdwood, timur
On 7/22/08, Mark Brown <broonie@opensource.wolfsonmicro.com> wrote:
> On Tue, Jul 22, 2008 at 12:58:09AM -0600, Grant Likely wrote:
>
> > Here is the latest series for adding MPC5200 I2S and TI AIC26 codec
> > support to ALSA SoC. I believe all the comments are addressed and I
> > hope that this series is now ready to be merged. I would really like
> > to see these ones land in 2.6.27.
>
>
> That might be a bit of a push given how far into the merge window we
> are and Takashi's holiday this week, though as they are new drivers
> things could be a bit more relaxed.
These drivers are going to get hit with immediate patches. The DMA is
not broken out so that AC97 support can be fixed for the Efika.
I haven't touched these up for the driver that was just posted.
From: Jon Smirl <jonsmirl@gmail.com>
---
include/sound/soc-of.h | 2 +
sound/soc/fsl/mpc5200_psc_i2s.c | 93 ++++++++++++++++++++++++++++++++-------
sound/soc/fsl/mpc5200_psc_i2s.h | 13 +++++
sound/soc/soc-of.c | 26 +++++++++--
4 files changed, 112 insertions(+), 22 deletions(-)
create mode 100644 sound/soc/fsl/mpc5200_psc_i2s.h
diff --git a/include/sound/soc-of.h b/include/sound/soc-of.h
index a963032..15f0b8d 100644
--- a/include/sound/soc-of.h
+++ b/include/sound/soc-of.h
@@ -17,5 +17,7 @@ int of_snd_soc_register_codec(struct
snd_soc_codec_device *codec_dev,
int of_snd_soc_register_platform(struct snd_soc_platform *platform,
struct device_node *node,
struct snd_soc_cpu_dai *cpu_dai);
+
+void of_snd_soc_register_machine(char *name, struct snd_soc_ops *ops);
#endif /* _INCLUDE_SOC_OF_H_ */
diff --git a/sound/soc/fsl/mpc5200_psc_i2s.c b/sound/soc/fsl/mpc5200_psc_i2s.c
index 81d0933..a34961a 100644
--- a/sound/soc/fsl/mpc5200_psc_i2s.c
+++ b/sound/soc/fsl/mpc5200_psc_i2s.c
@@ -5,6 +5,8 @@
* Copyright (C) 2008 Secret Lab Technologies Ltd.
*/
+#define DEBUG
+
#include <linux/init.h>
#include <linux/module.h>
#include <linux/interrupt.h>
@@ -23,8 +25,12 @@
#include <sysdev/bestcomm/bestcomm.h>
#include <sysdev/bestcomm/gen_bd.h>
+#include <asm/time.h>
+#include <asm/mpc52xx.h>
#include <asm/mpc52xx_psc.h>
+#include "mpc5200_psc_i2s.h"
+
MODULE_AUTHOR("Grant Likely <grant.likely@secretlab.ca>");
MODULE_DESCRIPTION("Freescale MPC5200 PSC in I2S mode ASoC Driver");
MODULE_LICENSE("GPL");
@@ -90,8 +96,10 @@ struct psc_i2s {
struct mpc52xx_psc_fifo __iomem *fifo_regs;
unsigned int irq;
struct device *dev;
+ u32 sicr;
struct snd_soc_cpu_dai dai;
spinlock_t lock;
+ uint sysclk;
/* per-stream data */
struct psc_i2s_stream playback_stream;
@@ -210,9 +218,7 @@ static int psc_i2s_startup(struct
snd_pcm_substream *substream)
out_8(®s->command, 4 << 4); /* reset error */
/* Default to CODEC8 mode */
- out_be32(®s->sicr,
- MPC52xx_PSC_SICR_DTS1 | MPC52xx_PSC_SICR_I2S |
- MPC52xx_PSC_SICR_CLKPOL | MPC52xx_PSC_SICR_SIM_CODEC_8);
+ out_be32(®s->sicr, psc_i2s->sicr | MPC52xx_PSC_SICR_SIM_CODEC_8);
/* First write: RxRdy (FIFO Alarm) generates receive FIFO interrupt */
/* Second write to mode: register Normal mode for non loopback */
@@ -249,7 +255,7 @@ static int psc_i2s_hw_params(struct
snd_pcm_substream *substream,
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct psc_i2s *psc_i2s = rtd->dai->cpu_dai->private_data;
- u32 sicr;
+ u32 sicr, bits, framesync, bitclk, value;
dev_dbg(psc_i2s->dev, "%s(substream=%p) p_size=%i p_bytes=%i"
" periods=%i buffer_size=%i buffer_bytes=%i\n",
@@ -257,26 +263,46 @@ static int psc_i2s_hw_params(struct
snd_pcm_substream *substream,
params_period_bytes(params), params_periods(params),
params_buffer_size(params), params_buffer_bytes(params));
- sicr = MPC52xx_PSC_SICR_DTS1 |
- MPC52xx_PSC_SICR_I2S | MPC52xx_PSC_SICR_CLKPOL;
+ sicr = psc_i2s->sicr;
switch (params_format(params)) {
case SNDRV_PCM_FORMAT_S8:
sicr |= MPC52xx_PSC_SICR_SIM_CODEC_8;
+ bits = 8;
break;
case SNDRV_PCM_FORMAT_S16_BE:
sicr |= MPC52xx_PSC_SICR_SIM_CODEC_16;
+ bits = 16;
break;
case SNDRV_PCM_FORMAT_S24_BE:
sicr |= MPC52xx_PSC_SICR_SIM_CODEC_24;
+ bits = 24;
break;
case SNDRV_PCM_FORMAT_S32_BE:
sicr |= MPC52xx_PSC_SICR_SIM_CODEC_32;
+ bits = 32;
break;
default:
dev_dbg(psc_i2s->dev, "invalid format\n");
return -EINVAL;
}
out_be32(&psc_i2s->psc_regs->sicr, sicr);
+
+ if (psc_i2s->sysclk) {
+ framesync = bits * 2;
+ bitclk = (psc_i2s->sysclk) / (params_rate(params) * framesync);
+
+ /* bitclk field is byte swapped due to mpc5200/b compatibility */
+ value = ((framesync - 1) << 24) |
+ (((bitclk - 1) & 0xFF) << 16) | ((bitclk - 1) & 0xFF00);
+
+ dev_dbg(psc_i2s->dev, "%s(substream=%p) rate=%i sysclk=%i"
+ " framesync=%i bitclk=%i reg=%X\n",
+ __FUNCTION__, substream, params_rate(params), psc_i2s->sysclk,
+ framesync, bitclk, value);
+
+ out_be32(&psc_i2s->psc_regs->ccr, value);
+ out_8(&psc_i2s->psc_regs->ctur, bits - 1);
+ }
//rc = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params));
//if (rc) {
@@ -463,9 +489,29 @@ static int psc_i2s_set_sysclk(struct
snd_soc_cpu_dai *cpu_dai,
int clk_id, unsigned int freq, int dir)
{
struct psc_i2s *psc_i2s = cpu_dai->private_data;
- dev_dbg(psc_i2s->dev, "psc_i2s_set_sysclk(cpu_dai=%p, dir=%i)\n",
- cpu_dai, dir);
- return (dir == SND_SOC_CLOCK_IN) ? 0 : -EINVAL;
+ int clkdiv, err;
+ dev_dbg(psc_i2s->dev, "psc_i2s_set_sysclk(cpu_dai=%p, freq=%u, dir=%i)\n",
+ cpu_dai, freq, dir);
+ if (dir == SND_SOC_CLOCK_OUT) {
+ psc_i2s->sysclk = freq;
+ if (clk_id == MPC52xx_CLK_CELLSLAVE) {
+ psc_i2s->sicr |= MPC52xx_PSC_SICR_CELLSLAVE | MPC52xx_PSC_SICR_GENCLK;
+ } else { /* MPC52xx_CLK_INTERNAL */
+ psc_i2s->sicr &= ~MPC52xx_PSC_SICR_CELLSLAVE;
+ psc_i2s->sicr |= MPC52xx_PSC_SICR_GENCLK;
+
+ clkdiv = ppc_proc_freq / freq;
+ err = ppc_proc_freq % freq;
+ if (err > freq / 2)
+ clkdiv++;
+
+ dev_dbg(psc_i2s->dev, "psc_i2s_set_sysclk(clkdiv %d freq error=%ldHz)\n",
+ clkdiv, (ppc_proc_freq / clkdiv - freq));
+
+ return mpc52xx_set_psc_clkdiv(psc_i2s->dai.id + 1, clkdiv);
+ }
+ }
+ return 0;
}
/**
@@ -660,14 +706,15 @@ static int psc_i2s_pcm_new(struct snd_card
*card, struct snd_soc_codec_dai *dai,
return -ENOMEM;
}
- rc = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, pcm->dev, size,
- &pcm->streams[1].substream->dma_buffer);
- if (rc) {
- snd_dma_free_pages(&pcm->streams[0].substream->dma_buffer);
- dev_err(card->dev, "Can't allocate capture DMA buffer\n");
- return -ENOMEM;
+ if (pcm->streams[1].substream != NULL) { /* only allocate if the is
a capture stream */
+ rc = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, pcm->dev, size,
+ &pcm->streams[1].substream->dma_buffer);
+ if (rc) {
+ snd_dma_free_pages(&pcm->streams[0].substream->dma_buffer);
+ dev_err(card->dev, "Can't allocate capture DMA buffer\n");
+ return -ENOMEM;
+ }
}
-
return 0;
}
@@ -829,6 +876,18 @@ static int __devinit psc_i2s_of_probe(struct of_device *op,
return -ENODEV;
}
+ /* Disable all interrupts and reset the PSC */
+ out_be16(&psc_i2s->psc_regs->mpc52xx_psc_imr, 0);
+ out_8(&psc_i2s->psc_regs->command, 3 << 4); /* reset transmitter */
+ out_8(&psc_i2s->psc_regs->command, 2 << 4); /* reset receiver */
+ out_8(&psc_i2s->psc_regs->command, 1 << 4); /* reset mode */
+ out_8(&psc_i2s->psc_regs->command, 4 << 4); /* reset error */
+
+ /* Default to CODEC8 mode */
+ psc_i2s->sicr = MPC52xx_PSC_SICR_DTS1 | MPC52xx_PSC_SICR_I2S |
+ MPC52xx_PSC_SICR_CLKPOL;
+ out_be32(&psc_i2s->psc_regs->sicr, psc_i2s->sicr |
MPC52xx_PSC_SICR_SIM_CODEC_8);
+
/* Save what we've done so it can be found again later */
dev_set_drvdata(&op->dev, psc_i2s);
@@ -865,7 +924,7 @@ static int __devexit psc_i2s_of_remove(struct of_device *op)
/* Match table for of_platform binding */
static struct of_device_id psc_i2s_match[] __devinitdata = {
- { .compatible = "fsl,mpc5200-psc-i2s", },
+ { .compatible = "fsl,mpc5200b-psc-i2s", },
{}
};
MODULE_DEVICE_TABLE(of, psc_i2s_match);
diff --git a/sound/soc/fsl/mpc5200_psc_i2s.h b/sound/soc/fsl/mpc5200_psc_i2s.h
new file mode 100644
index 0000000..0e0a84e
--- /dev/null
+++ b/sound/soc/fsl/mpc5200_psc_i2s.h
@@ -0,0 +1,13 @@
+/*
+ * Freescale MPC5200 PSC in I2S mode
+ * ALSA SoC Digital Audio Interface (DAI) driver
+ *
+ */
+
+#ifndef __SOUND_SOC_FSL_MPC52xx_PSC_I2S_H__
+#define __SOUND_SOC_FSL_MPC52xx_PSC_I2S_H__
+
+#define MPC52xx_CLK_INTERNAL 0
+#define MPC52xx_CLK_CELLSLAVE 1
+
+#endif /* __SOUND_SOC_FSL_MPC52xx_PSC_I2S_H__ */
diff --git a/sound/soc/soc-of.c b/sound/soc/soc-of.c
index 9694979..3d21ed0 100644
--- a/sound/soc/soc-of.c
+++ b/sound/soc/soc-of.c
@@ -38,8 +38,8 @@ struct of_snd_soc_device {
struct device_node *codec_node;
};
-static struct snd_soc_ops of_snd_soc_ops = {
-};
+static struct snd_soc_ops *machine_ops = NULL;
+static char *machine_name = NULL;
static struct of_snd_soc_device *
of_snd_soc_get_device(struct device_node *codec_node)
@@ -61,7 +61,7 @@ of_snd_soc_get_device(struct device_node *codec_node)
of_soc->machine.dai_link = &of_soc->dai_link;
of_soc->machine.num_links = 1;
of_soc->device.machine = &of_soc->machine;
- of_soc->dai_link.ops = &of_snd_soc_ops;
+ of_soc->dai_link.ops = machine_ops;
list_add(&of_soc->list, &of_snd_soc_device_list);
return of_soc;
@@ -74,7 +74,7 @@ static void of_snd_soc_register_device(struct
of_snd_soc_device *of_soc)
/* Only register the device if both the codec and platform have
* been registered */
- if ((!of_soc->device.codec_data) || (!of_soc->platform_node))
+ if ((!of_soc->device.codec_data) || (!of_soc->platform_node) || !machine_name)
return;
pr_info("platform<-->codec match achieved; registering machine\n");
@@ -159,7 +159,7 @@ int of_snd_soc_register_platform(struct
snd_soc_platform *platform,
of_soc->platform_node = node;
of_soc->dai_link.cpu_dai = cpu_dai;
of_soc->device.platform = platform;
- of_soc->machine.name = of_soc->dai_link.cpu_dai->name;
+ of_soc->machine.name = machine_name;
/* Now try to register the SoC device */
of_snd_soc_register_device(of_soc);
@@ -169,3 +169,19 @@ int of_snd_soc_register_platform(struct
snd_soc_platform *platform,
return rc;
}
EXPORT_SYMBOL_GPL(of_snd_soc_register_platform);
+
+void of_snd_soc_register_machine(char *name, struct snd_soc_ops *ops)
+{
+ struct of_snd_soc_device *of_soc;
+
+ machine_name = name;
+ machine_ops = ops;
+
+ list_for_each_entry(of_soc, &of_snd_soc_device_list, list) {
+ of_soc->dai_link.ops = machine_ops;
+ of_soc->machine.name = machine_name;
+ of_snd_soc_register_device(of_soc);
+ }
+
+}
+EXPORT_SYMBOL_GPL(of_snd_soc_register_machine);
>
> Takashi, I'll queue these (and other ASoC patches) for submission in
> bulk once you return.
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
>
--
Jon Smirl
jonsmirl@gmail.com
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [alsa-devel] [PATCH v3 0/3] ALSA SoC: MPC5200 audio driver
2008-07-22 13:38 ` Jon Smirl
@ 2008-07-22 14:10 ` Mark Brown
2008-07-22 14:52 ` Jon Smirl
0 siblings, 1 reply; 15+ messages in thread
From: Mark Brown @ 2008-07-22 14:10 UTC (permalink / raw)
To: Jon Smirl; +Cc: linuxppc-dev, alsa-devel, timur, liam.girdwood
On Tue, Jul 22, 2008 at 09:38:11AM -0400, Jon Smirl wrote:
> These drivers are going to get hit with immediate patches. The DMA is
> not broken out so that AC97 support can be fixed for the Efika.
Further updates shouldn't present a problem - if anything, it should be
easier easier to review incremental patches.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [alsa-devel] [PATCH v3 0/3] ALSA SoC: MPC5200 audio driver
2008-07-22 14:10 ` Mark Brown
@ 2008-07-22 14:52 ` Jon Smirl
2008-07-22 15:14 ` Timur Tabi
2008-07-22 18:39 ` Mark Brown
0 siblings, 2 replies; 15+ messages in thread
From: Jon Smirl @ 2008-07-22 14:52 UTC (permalink / raw)
To: Grant Likely, linuxppc-dev, alsa-devel, liam.girdwood, timur,
Mark Brown
On 7/22/08, Mark Brown <broonie@opensource.wolfsonmicro.com> wrote:
> On Tue, Jul 22, 2008 at 09:38:11AM -0400, Jon Smirl wrote:
>
> > These drivers are going to get hit with immediate patches. The DMA is
> > not broken out so that AC97 support can be fixed for the Efika.
>
> Further updates shouldn't present a problem - if anything, it should be
> easier easier to review incremental patches.
I'm just going to ignore 2.6.27 and wait for 2.6.28. This driver only
partially implement i2s support and assumes external clocking. There's
no way to add a ASOC machine driver. It's not a general purpose
driver. Adding the rest of the features probably means device tree
changes.
--
Jon Smirl
jonsmirl@gmail.com
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [alsa-devel] [PATCH v3 0/3] ALSA SoC: MPC5200 audio driver
2008-07-22 14:52 ` Jon Smirl
@ 2008-07-22 15:14 ` Timur Tabi
2008-07-22 18:39 ` Mark Brown
1 sibling, 0 replies; 15+ messages in thread
From: Timur Tabi @ 2008-07-22 15:14 UTC (permalink / raw)
To: Jon Smirl; +Cc: linuxppc-dev, alsa-devel, Mark Brown, liam.girdwood
Jon Smirl wrote:
> I'm just going to ignore 2.6.27 and wait for 2.6.28.
2.6.28 might have ASoC V2, or at least portions of it. You might want to just
port your driver to ASoC V2 like I did and not worry about it.
--
Timur Tabi
Linux kernel developer at Freescale
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [alsa-devel] [PATCH v3 0/3] ALSA SoC: MPC5200 audio driver
2008-07-22 14:52 ` Jon Smirl
2008-07-22 15:14 ` Timur Tabi
@ 2008-07-22 18:39 ` Mark Brown
1 sibling, 0 replies; 15+ messages in thread
From: Mark Brown @ 2008-07-22 18:39 UTC (permalink / raw)
To: Jon Smirl; +Cc: linuxppc-dev, alsa-devel, timur, liam.girdwood
On Tue, Jul 22, 2008 at 10:52:20AM -0400, Jon Smirl wrote:
> I'm just going to ignore 2.6.27 and wait for 2.6.28. This driver only
If you want to get changes in for 2.6.28 it's probably best to be
working on them now - it's not clear if this driver will be merged for
2.6.27 at all and the sooner the stuff gets in the safer it is for
2.6.28 and the closer the code base will be to 2.6.26. It's up to you
obviously but I think it may work best.
> partially implement i2s support and assumes external clocking. There's
> no way to add a ASOC machine driver. It's not a general purpose
> driver. Adding the rest of the features probably means device tree
> changes.
of-soc is a machine driver - other machine drivers should be able to
bind to the driver as normal (though I'd expect that users would want to
add more configurablilty to the driver prior to using it). Or at least
that was the usage I was expecting, anyway.
Implementing only partial support for devices is pretty much normal when
the driver isn't contributed by the vendor - people tend to only work on
the features they're using.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/3] ASoC: Make OpenFirmware helper include file conditional
2008-07-22 11:53 ` [PATCH 1/3] ASoC: Make OpenFirmware helper include file conditional Mark Brown
2008-07-22 11:53 ` [PATCH 2/3] ASoC: Export DAI and codec for TLV320AIC26 Mark Brown
@ 2008-07-22 21:24 ` Grant Likely
1 sibling, 0 replies; 15+ messages in thread
From: Grant Likely @ 2008-07-22 21:24 UTC (permalink / raw)
To: Mark Brown; +Cc: alsa-project.org, linuxppc-dev, timur, liam.girdwood
On Tue, Jul 22, 2008 at 12:53:07PM +0100, Mark Brown wrote:
> The OpenFirmware API headers don't build on all platforms so ensure
> that they are not included unless they are being used.
>
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Grant Likely <grant.likely@secretlab.ca>
I actually fixed this in my tree, but I forgot to roll it into the patch
before I emailed it. Thanks.
g.
> ---
> include/sound/soc-of-simple.h | 4 ++++
> 1 files changed, 4 insertions(+), 0 deletions(-)
>
> diff --git a/include/sound/soc-of-simple.h b/include/sound/soc-of-simple.h
> index 696fc51..a064e19 100644
> --- a/include/sound/soc-of-simple.h
> +++ b/include/sound/soc-of-simple.h
> @@ -7,6 +7,8 @@
> #ifndef _INCLUDE_SOC_OF_H_
> #define _INCLUDE_SOC_OF_H_
>
> +#if defined(CONFIG_SND_SOC_OF_SIMPLE) || defined(CONFIG_SND_SOC_OF_SIMPLE_MODULE)
> +
> #include <linux/of.h>
> #include <sound/soc.h>
>
> @@ -18,4 +20,6 @@ int of_snd_soc_register_platform(struct snd_soc_platform *platform,
> struct device_node *node,
> struct snd_soc_dai *cpu_dai);
>
> +#endif
> +
> #endif /* _INCLUDE_SOC_OF_H_ */
> --
> 1.5.6.3
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 2/3] ASoC: Export DAI and codec for TLV320AIC26
2008-07-22 11:53 ` [PATCH 2/3] ASoC: Export DAI and codec for TLV320AIC26 Mark Brown
2008-07-22 11:53 ` [PATCH 3/3] ASoC: Staticise keyclick dev_attr in tlv320aic26 Mark Brown
@ 2008-07-22 21:25 ` Grant Likely
1 sibling, 0 replies; 15+ messages in thread
From: Grant Likely @ 2008-07-22 21:25 UTC (permalink / raw)
To: Mark Brown; +Cc: alsa-project.org, linuxppc-dev, timur, liam.girdwood
On Tue, Jul 22, 2008 at 12:53:08PM +0100, Mark Brown wrote:
> This fixes sparse warnings and allows non-OpenFirmware systems to attempt
> to bind to the device.
>
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Grant Likely <grant.likely@secretlab.ca>
> ---
> sound/soc/codecs/tlv320aic26.c | 1 +
> sound/soc/codecs/tlv320aic26.h | 3 +++
> 2 files changed, 4 insertions(+), 0 deletions(-)
>
> diff --git a/sound/soc/codecs/tlv320aic26.c b/sound/soc/codecs/tlv320aic26.c
> index 4621fda..73b7027 100644
> --- a/sound/soc/codecs/tlv320aic26.c
> +++ b/sound/soc/codecs/tlv320aic26.c
> @@ -383,6 +383,7 @@ struct snd_soc_codec_device aic26_soc_codec_dev = {
> .probe = aic26_probe,
> .remove = aic26_remove,
> };
> +EXPORT_SYMBOL_GPL(aic26_soc_codec_dev);
>
> /* ---------------------------------------------------------------------
> * SPI device portion of driver: sysfs files for debugging
> diff --git a/sound/soc/codecs/tlv320aic26.h b/sound/soc/codecs/tlv320aic26.h
> index 62b1f22..786ba16 100644
> --- a/sound/soc/codecs/tlv320aic26.h
> +++ b/sound/soc/codecs/tlv320aic26.h
> @@ -90,4 +90,7 @@ enum aic26_wlen {
> AIC26_WLEN_32 = 3 << 10,
> };
>
> +extern struct snd_soc_dai aic26_dai;
> +extern struct snd_soc_codec_device aic26_soc_codec_dev;
> +
> #endif /* _TLV320AIC16_H_ */
> --
> 1.5.6.3
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 3/3] ASoC: Staticise keyclick dev_attr in tlv320aic26
2008-07-22 11:53 ` [PATCH 3/3] ASoC: Staticise keyclick dev_attr in tlv320aic26 Mark Brown
@ 2008-07-22 21:26 ` Grant Likely
0 siblings, 0 replies; 15+ messages in thread
From: Grant Likely @ 2008-07-22 21:26 UTC (permalink / raw)
To: Mark Brown; +Cc: alsa-project.org, linuxppc-dev, timur, liam.girdwood
On Tue, Jul 22, 2008 at 12:53:09PM +0100, Mark Brown wrote:
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Grant Likely <grant.likely@secretlab.ca>
> ---
> sound/soc/codecs/tlv320aic26.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/sound/soc/codecs/tlv320aic26.c b/sound/soc/codecs/tlv320aic26.c
> index 73b7027..bed8a9e 100644
> --- a/sound/soc/codecs/tlv320aic26.c
> +++ b/sound/soc/codecs/tlv320aic26.c
> @@ -418,7 +418,7 @@ static ssize_t aic26_keyclick_set(struct device *dev,
> return count;
> }
>
> -DEVICE_ATTR(keyclick, 0644, aic26_keyclick_show, aic26_keyclick_set);
> +static DEVICE_ATTR(keyclick, 0644, aic26_keyclick_show, aic26_keyclick_set);
>
> /* ---------------------------------------------------------------------
> * SPI device portion of driver: probe and release routines and SPI
> --
> 1.5.6.3
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [alsa-devel] [PATCH v3 0/3] ALSA SoC: MPC5200 audio driver
2008-07-22 9:26 ` [alsa-devel] " Mark Brown
2008-07-22 13:38 ` Jon Smirl
@ 2008-07-22 21:26 ` Grant Likely
1 sibling, 0 replies; 15+ messages in thread
From: Grant Likely @ 2008-07-22 21:26 UTC (permalink / raw)
To: linuxppc-dev, alsa-devel, liam.girdwood, timur
On Tue, Jul 22, 2008 at 10:26:47AM +0100, Mark Brown wrote:
> On Tue, Jul 22, 2008 at 12:58:09AM -0600, Grant Likely wrote:
>
> > Here is the latest series for adding MPC5200 I2S and TI AIC26 codec
> > support to ALSA SoC. I believe all the comments are addressed and I
> > hope that this series is now ready to be merged. I would really like
> > to see these ones land in 2.6.27.
>
> That might be a bit of a push given how far into the merge window we
> are and Takashi's holiday this week, though as they are new drivers
> things could be a bit more relaxed.
>
> Takashi, I'll queue these (and other ASoC patches) for submission in
> bulk once you return.
Thanks Mark, I owe you a beer.
g.
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2008-07-22 21:27 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-22 6:58 [PATCH v3 0/3] ALSA SoC: MPC5200 audio driver Grant Likely
2008-07-22 9:26 ` [alsa-devel] " Mark Brown
2008-07-22 13:38 ` Jon Smirl
2008-07-22 14:10 ` Mark Brown
2008-07-22 14:52 ` Jon Smirl
2008-07-22 15:14 ` Timur Tabi
2008-07-22 18:39 ` Mark Brown
2008-07-22 21:26 ` Grant Likely
2008-07-22 11:52 ` Mark Brown
2008-07-22 11:53 ` [PATCH 1/3] ASoC: Make OpenFirmware helper include file conditional Mark Brown
2008-07-22 11:53 ` [PATCH 2/3] ASoC: Export DAI and codec for TLV320AIC26 Mark Brown
2008-07-22 11:53 ` [PATCH 3/3] ASoC: Staticise keyclick dev_attr in tlv320aic26 Mark Brown
2008-07-22 21:26 ` Grant Likely
2008-07-22 21:25 ` [PATCH 2/3] ASoC: Export DAI and codec for TLV320AIC26 Grant Likely
2008-07-22 21:24 ` [PATCH 1/3] ASoC: Make OpenFirmware helper include file conditional Grant Likely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).