summaryrefslogtreecommitdiff
path: root/sound/soc/mxs
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/mxs')
-rw-r--r--sound/soc/mxs/Kconfig6
-rw-r--r--sound/soc/mxs/mxs-devb-spdif.c90
-rw-r--r--sound/soc/mxs/mxs-pcm.c2
-rw-r--r--sound/soc/mxs/mxs-spdif-dai.c202
-rw-r--r--sound/soc/mxs/mxs-spdif-dai.h21
5 files changed, 318 insertions, 3 deletions
diff --git a/sound/soc/mxs/Kconfig b/sound/soc/mxs/Kconfig
index 0e5bc1b052bb..12e95ab6dce4 100644
--- a/sound/soc/mxs/Kconfig
+++ b/sound/soc/mxs/Kconfig
@@ -15,7 +15,7 @@ config SND_MXS_SOC_EVK_DEVB
depends on SND_MXS_SOC && ARCH_MX28
select SND_SOC_SGTL5000
help
- Say Y if you want to add support for SoC audio on mx28 EVK development
+ Say Y if you want to add support for SoC audio on MXS EVK development
board with the sgtl5000 codec.
config SND_MXS_SOC_DAI
@@ -40,10 +40,10 @@ config SND_MXS_SOC_SAIF1_SELECT
config SND_MXS_SOC_EVK_DEVB_SPDIF
- tristate "SoC SPDIF support for MX28 EVK Development Board"
+ tristate "SoC SPDIF support for MXS EVK Development Board"
depends on SND_MXS_SOC && ARCH_MX28
select SND_MXS_SOC_SPDIF_DAI
select SND_SOC_MXS_SPDIF
help
- Say Y if you want to add support for SoC audio on mx28 EVK development
+ Say Y if you want to add support for SoC audio on MXS EVK development
board with the SPDIF transmitter.
diff --git a/sound/soc/mxs/mxs-devb-spdif.c b/sound/soc/mxs/mxs-devb-spdif.c
new file mode 100644
index 000000000000..9ed62110dff7
--- /dev/null
+++ b/sound/soc/mxs/mxs-devb-spdif.c
@@ -0,0 +1,90 @@
+/*
+ * ASoC driver for MXS Evk development board
+ *
+ * Copyright (C) 2008-2010 Freescale Semiconductor, Inc.
+ *
+ * based on stmp3780_devb_spdif.c
+ *
+ * Vladimir Barinov <vbarinov@embeddedalley.com>
+ *
+ * Copyright 2008 SigmaTel, Inc
+ * Copyright 2008 Embedded Alley Solutions, Inc
+ *
+ * This file is licensed under the terms of the GNU General Public License
+ * version 2. This program is licensed "as is" without any warranty of any
+ * kind, whether express or implied.
+ */
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/timer.h>
+#include <linux/interrupt.h>
+#include <linux/platform_device.h>
+#include <sound/core.h>
+#include <sound/pcm.h>
+#include <sound/soc.h>
+#include <sound/soc-dapm.h>
+
+#include <asm/mach-types.h>
+#include <asm/dma.h>
+#include <mach/hardware.h>
+
+#include "mxs-spdif-dai.h"
+#include "../codecs/mxs_spdif.h"
+#include "mxs-pcm.h"
+
+/* mxs devb digital audio interface glue - connects codec <--> CPU */
+static struct snd_soc_dai_link mxs_devb_dai = {
+ .name = "MXS SPDIF",
+ .stream_name = "MXS SPDIF",
+ .cpu_dai = &mxs_spdif_dai,
+ .codec_dai = &mxs_spdif_codec_dai,
+};
+
+/* mxs devb audio machine driver */
+static struct snd_soc_card snd_soc_machine_mxs_devb = {
+ .name = "mxs-evk",
+ .platform = &mxs_soc_platform,
+ .dai_link = &mxs_devb_dai,
+ .num_links = 1,
+};
+
+/* mxs devb audio subsystem */
+static struct snd_soc_device mxs_devb_snd_devdata = {
+ .card = &snd_soc_machine_mxs_devb,
+ .codec_dev = &soc_spdif_codec_dev_mxs,
+};
+
+static struct platform_device *mxs_devb_snd_device;
+
+static int __init mxs_devb_init(void)
+{
+ int ret = 0;
+
+ mxs_devb_snd_device = platform_device_alloc("soc-audio", 2);
+ if (!mxs_devb_snd_device)
+ return -ENOMEM;
+
+ platform_set_drvdata(mxs_devb_snd_device,
+ &mxs_devb_snd_devdata);
+ mxs_devb_snd_devdata.dev = &mxs_devb_snd_device->dev;
+ mxs_devb_snd_device->dev.platform_data =
+ &mxs_devb_snd_devdata;
+
+ ret = platform_device_add(mxs_devb_snd_device);
+ if (ret)
+ platform_device_put(mxs_devb_snd_device);
+
+ return ret;
+}
+
+static void __exit mxs_devb_exit(void)
+{
+ platform_device_unregister(mxs_devb_snd_device);
+}
+
+module_init(mxs_devb_init);
+module_exit(mxs_devb_exit);
+
+MODULE_AUTHOR("Vladimir Barinov");
+MODULE_DESCRIPTION("MXS EVK development board ASoC driver");
+MODULE_LICENSE("GPL");
diff --git a/sound/soc/mxs/mxs-pcm.c b/sound/soc/mxs/mxs-pcm.c
index 2bb58b5ba586..6bac0eeac767 100644
--- a/sound/soc/mxs/mxs-pcm.c
+++ b/sound/soc/mxs/mxs-pcm.c
@@ -40,6 +40,8 @@ static const struct snd_pcm_hardware mxs_pcm_hardware = {
SNDRV_PCM_INFO_RESUME |
SNDRV_PCM_INFO_INTERLEAVED,
.formats = SNDRV_PCM_FMTBIT_S16_LE |
+ SNDRV_PCM_FMTBIT_S20_3LE |
+ SNDRV_PCM_FMTBIT_S24_LE |
SNDRV_PCM_FMTBIT_S32_LE,
.channels_min = 2,
.channels_max = 2,
diff --git a/sound/soc/mxs/mxs-spdif-dai.c b/sound/soc/mxs/mxs-spdif-dai.c
new file mode 100644
index 000000000000..5c9f93d73801
--- /dev/null
+++ b/sound/soc/mxs/mxs-spdif-dai.c
@@ -0,0 +1,202 @@
+/*
+ * ALSA SoC SPDIF Audio Layer for MXS
+ *
+ * Copyright (C) 2008-2010 Freescale Semiconductor, Inc.
+ *
+ * Based on stmp3xxx_spdif_dai.c
+ * Vladimir Barinov <vbarinov@embeddedalley.com>
+ * Copyright 2008 SigmaTel, Inc
+ * Copyright 2008 Embedded Alley Solutions, Inc
+ *
+ * This file is licensed under the terms of the GNU General Public License
+ * version 2. This program is licensed "as is" without any warranty of any
+ * kind, whether express or implied.
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/dma-mapping.h>
+#include <linux/clk.h>
+#include <linux/delay.h>
+#include <sound/core.h>
+#include <sound/pcm.h>
+#include <sound/soc.h>
+#include <mach/dma.h>
+
+#include "../codecs/mxs_spdif.h"
+#include "mxs-pcm.h"
+
+#define REGS_SPDIF_BASE IO_ADDRESS(SPDIF_PHYS_ADDR)
+
+struct mxs_pcm_dma_params mxs_spdif = {
+ .name = "mxs spdif",
+ .dma_ch = MXS_DMA_CHANNEL_AHB_APBX_SPDIF,
+ .irq = IRQ_SPDIF_DMA,
+};
+
+static irqreturn_t mxs_err_irq(int irq, void *dev_id)
+{
+ struct snd_pcm_substream *substream = dev_id;
+ int playback = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 1 : 0;
+ u32 ctrl_reg = 0;
+ u32 overflow_mask;
+ u32 underflow_mask;
+
+ if (playback) {
+ ctrl_reg = __raw_readl(REGS_SPDIF_BASE + HW_SPDIF_CTRL);
+ underflow_mask = BM_SPDIF_CTRL_FIFO_UNDERFLOW_IRQ;
+ overflow_mask = BM_SPDIF_CTRL_FIFO_OVERFLOW_IRQ;
+ }
+
+ if (ctrl_reg & underflow_mask) {
+ printk(KERN_DEBUG "underflow detected SPDIF\n");
+
+ if (playback)
+ __raw_writel(BM_SPDIF_CTRL_FIFO_UNDERFLOW_IRQ,
+ REGS_SPDIF_BASE + HW_SPDIF_CTRL_CLR);
+ } else if (ctrl_reg & overflow_mask) {
+ printk(KERN_DEBUG "overflow detected SPDIF\n");
+
+ if (playback)
+ __raw_writel(BM_SPDIF_CTRL_FIFO_OVERFLOW_IRQ,
+ REGS_SPDIF_BASE + HW_SPDIF_CTRL_CLR);
+ } else
+ printk(KERN_WARNING "Unknown SPDIF error interrupt\n");
+
+ return IRQ_HANDLED;
+}
+
+static int mxs_spdif_trigger(struct snd_pcm_substream *substream, int cmd,
+ struct snd_soc_dai *dai)
+{
+ int playback = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 1 : 0;
+ int ret = 0;
+
+ switch (cmd) {
+ case SNDRV_PCM_TRIGGER_START:
+ if (playback)
+ __raw_writel(BM_SPDIF_CTRL_RUN,
+ REGS_SPDIF_BASE + HW_SPDIF_CTRL_SET);
+ break;
+ case SNDRV_PCM_TRIGGER_STOP:
+ if (playback)
+ __raw_writel(BM_SPDIF_CTRL_RUN,
+ REGS_SPDIF_BASE + HW_SPDIF_CTRL_CLR);
+ break;
+ case SNDRV_PCM_TRIGGER_RESUME:
+ case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
+ case SNDRV_PCM_TRIGGER_SUSPEND:
+ case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
+
+ default:
+ ret = -EINVAL;
+ }
+
+ return ret;
+}
+
+static int mxs_spdif_startup(struct snd_pcm_substream *substream,
+ struct snd_soc_dai *dai)
+{
+ struct snd_soc_pcm_runtime *rtd = substream->private_data;
+ struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
+ int playback = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 1 : 0;
+ int irq;
+ int ret;
+
+ if (playback) {
+ irq = IRQ_SPDIF_ERROR;
+ cpu_dai->dma_data = &mxs_spdif;
+ }
+
+ ret = request_irq(irq, mxs_err_irq, 0, "Mxs SPDIF Error",
+ substream);
+ if (ret) {
+ printk(KERN_ERR "%s: Unable to request SPDIF error irq %d\n",
+ __func__, IRQ_SPDIF_ERROR);
+ return ret;
+ }
+
+ /* Enable error interrupt */
+ if (playback) {
+ __raw_writel(BM_SPDIF_CTRL_FIFO_OVERFLOW_IRQ,
+ REGS_SPDIF_BASE + HW_SPDIF_CTRL_CLR);
+ __raw_writel(BM_SPDIF_CTRL_FIFO_UNDERFLOW_IRQ,
+ REGS_SPDIF_BASE + HW_SPDIF_CTRL_CLR);
+ __raw_writel(BM_SPDIF_CTRL_FIFO_ERROR_IRQ_EN,
+ REGS_SPDIF_BASE + HW_SPDIF_CTRL_SET);
+ }
+
+ return 0;
+}
+
+static void mxs_spdif_shutdown(struct snd_pcm_substream *substream,
+ struct snd_soc_dai *dai)
+{
+ int playback = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? 1 : 0;
+
+ /* Disable error interrupt */
+ if (playback) {
+ __raw_writel(BM_SPDIF_CTRL_FIFO_ERROR_IRQ_EN,
+ REGS_SPDIF_BASE + HW_SPDIF_CTRL_CLR);
+ free_irq(IRQ_SPDIF_ERROR, substream);
+ }
+}
+
+#ifdef CONFIG_PM
+static int mxs_spdif_suspend(struct snd_soc_dai *cpu_dai)
+{
+ return 0;
+}
+
+static int mxs_spdif_resume(struct snd_soc_dai *cpu_dai)
+{
+ return 0;
+}
+#else
+#define mxs_spdif_suspend NULL
+#define mxs_spdif_resume NULL
+#endif /* CONFIG_PM */
+
+struct snd_soc_dai_ops mxs_spdif_dai_ops = {
+ .startup = mxs_spdif_startup,
+ .shutdown = mxs_spdif_shutdown,
+ .trigger = mxs_spdif_trigger,
+};
+
+struct snd_soc_dai mxs_spdif_dai = {
+ .name = "mxs-spdif",
+ .id = 0,
+ .suspend = mxs_spdif_suspend,
+ .resume = mxs_spdif_resume,
+ .playback = {
+ .channels_min = 2,
+ .channels_max = 2,
+ .rates = MXS_SPDIF_RATES,
+ .formats = MXS_SPDIF_FORMATS,
+ },
+ .capture = {
+ .channels_min = 2,
+ .channels_max = 2,
+ .rates = MXS_SPDIF_RATES,
+ .formats = MXS_SPDIF_FORMATS,
+ },
+ .ops = &mxs_spdif_dai_ops,
+};
+EXPORT_SYMBOL_GPL(mxs_spdif_dai);
+
+static int __init mxs_spdif_dai_init(void)
+{
+ return snd_soc_register_dai(&mxs_spdif_dai);
+}
+
+static void __exit mxs_spdif_dai_exit(void)
+{
+ snd_soc_unregister_dai(&mxs_spdif_dai);
+}
+module_init(mxs_spdif_dai_init);
+module_exit(mxs_spdif_dai_exit);
+
+MODULE_AUTHOR("Vladimir Barinov");
+MODULE_DESCRIPTION("MXS SPDIF DAI");
+MODULE_LICENSE("GPL");
diff --git a/sound/soc/mxs/mxs-spdif-dai.h b/sound/soc/mxs/mxs-spdif-dai.h
new file mode 100644
index 000000000000..035369af9676
--- /dev/null
+++ b/sound/soc/mxs/mxs-spdif-dai.h
@@ -0,0 +1,21 @@
+/*
+ * ASoC Audio Layer for Freescale STMP3XXX SPDIF transmitter
+ *
+ * Author: Vladimir Barinov <vbarinov@embeddedalley.com>
+ *
+ * Copyright 2008-2010 Freescale Semiconductor, Inc.
+ * Copyright 2008 Embedded Alley Solutions, Inc All Rights Reserved.
+ */
+
+/*
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+#ifndef _STMP3XXX_SPDIF_H
+#define _STMP3XXX_SPDIF_H
+extern struct snd_soc_dai mxs_spdif_dai;
+#endif