aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Tull <alan.tull@freescale.com>2011-10-16 14:53:12 +0800
committerEric Miao <eric.miao@linaro.org>2011-10-18 17:13:03 +0800
commitf454b41a1b7f139a9da69144880a4d3daed68776 (patch)
treef7a53982035b06aa710ec12217f910e30aade2fb
parentb34869b372bf1d9b86749061dc78db4e4b574bb9 (diff)
downloadlinux-linaro-f454b41a1b7f139a9da69144880a4d3daed68776.tar.gz
SAUCE: ENGR00139461-1 mxc alsa soc spdif driver
BugLink: http://bugs.launchpad.net/bugs/837155 S/PDIF tx and rx using ASoC layer. Signed-off-by: Alan Tull <alan.tull@freescale.com> Signed-off-by: Eric Miao <eric.miao@linaro.org>
-rw-r--r--arch/arm/mach-mx5/Kconfig2
-rw-r--r--arch/arm/mach-mx5/board-mx53_loco.c19
-rw-r--r--arch/arm/mach-mx5/clock.c4
-rw-r--r--arch/arm/mach-mx5/devices-imx51.h8
-rw-r--r--arch/arm/mach-mx5/devices-imx53.h8
-rw-r--r--arch/arm/plat-mxc/devices/Kconfig3
-rw-r--r--arch/arm/plat-mxc/devices/Makefile3
-rw-r--r--arch/arm/plat-mxc/devices/platform-imx-spdif-audio.c29
-rw-r--r--arch/arm/plat-mxc/devices/platform-imx-spdif-dai.c65
-rw-r--r--arch/arm/plat-mxc/devices/platform-imx-spdif.c64
-rw-r--r--arch/arm/plat-mxc/include/mach/devices-common.h18
-rw-r--r--arch/arm/plat-mxc/include/mach/dma.h7
12 files changed, 228 insertions, 2 deletions
diff --git a/arch/arm/mach-mx5/Kconfig b/arch/arm/mach-mx5/Kconfig
index 91063b9b4e7..0c0b941711b 100644
--- a/arch/arm/mach-mx5/Kconfig
+++ b/arch/arm/mach-mx5/Kconfig
@@ -21,6 +21,7 @@ config SOC_IMX51
select IMX_HAVE_PLATFORM_IMX_IPUV3
select IMX_HAVE_PLATFORM_IMX_TVE
select IMX_HAVE_PLATFORM_IMX_VPU
+ select IMX_HAVE_PLATFORM_IMX_SPDIF
config SOC_IMX53
bool
@@ -35,6 +36,7 @@ config SOC_IMX53
select IMX_HAVE_PLATFORM_IMX_TVE
select IMX_HAVE_PLATFORM_LDB
select IMX_HAVE_PLATFORM_IMX_VPU
+ select IMX_HAVE_PLATFORM_IMX_SPDIF
comment "i.MX50 machines:"
diff --git a/arch/arm/mach-mx5/board-mx53_loco.c b/arch/arm/mach-mx5/board-mx53_loco.c
index f32d3353f09..fe3199b6641 100644
--- a/arch/arm/mach-mx5/board-mx53_loco.c
+++ b/arch/arm/mach-mx5/board-mx53_loco.c
@@ -481,6 +481,18 @@ static void __init mx53_loco_io_init(void)
gpio_direction_output(LOCO_DISP0_PWR, 1);
}
+static struct mxc_spdif_platform_data mxc_spdif_data = {
+ .spdif_tx = 1,
+ .spdif_rx = 0,
+ .spdif_clk_44100 = -1, /* No source for 44.1K */
+ /* Source from CCM spdif_clk (24M) for 48k and 32k
+ * It's not accurate: for 48Khz it is actually 46875Hz (2.3% off)
+ */
+ .spdif_clk_48000 = 1,
+ .spdif_clkid = 0,
+ .spdif_clk = NULL, /* spdif bus clk */
+};
+
static void __init mx53_loco_board_init(void)
{
int i, ret;
@@ -527,6 +539,13 @@ static void __init mx53_loco_board_init(void)
imx53_add_mxc_pwm(1);
imx53_add_mxc_pwm_backlight(0, &loco_pwm_backlight_data);
+ mxc_spdif_data.spdif_core_clk = clk_get(NULL, "spdif_xtal_clk");
+ clk_put(mxc_spdif_data.spdif_core_clk);
+
+ imx53_add_spdif(&mxc_spdif_data);
+ imx53_add_spdif_dai();
+ imx53_add_spdif_audio_device();
+
/*GPU*/
if (mx53_revision() >= IMX_CHIP_REVISION_2_0)
gpu_data.z160_revision = 1;
diff --git a/arch/arm/mach-mx5/clock.c b/arch/arm/mach-mx5/clock.c
index 2789b06c901..071ea052963 100644
--- a/arch/arm/mach-mx5/clock.c
+++ b/arch/arm/mach-mx5/clock.c
@@ -4479,7 +4479,7 @@ static struct clk_lookup lookups[] = {
_REGISTER_CLOCK(NULL, "emi_intr_clk.0", emi_intr_clk[0]),
_REGISTER_CLOCK(NULL, "emi_intr_clk.1", emi_intr_clk[1]),
_REGISTER_CLOCK(NULL, "spdif_xtal_clk", spdif_xtal_clk),
- _REGISTER_CLOCK("mxc_alsa_spdif.0", NULL, spdif0_clk[0]),
+ _REGISTER_CLOCK("mxc_spdif.0", NULL, spdif0_clk[0]),
_REGISTER_CLOCK("mxc_vpu.0", NULL, vpu_clk[0]),
_REGISTER_CLOCK(NULL, "lpsr_clk", lpsr_clk),
_REGISTER_CLOCK("mxc_rtc.0", NULL, rtc_clk),
@@ -4498,7 +4498,7 @@ static struct clk_lookup lookups[] = {
static struct clk_lookup mx51_lookups[] = {
_REGISTER_CLOCK("mxc_i2c_hs.3", NULL, hsi2c_serial_clk),
_REGISTER_CLOCK("mxc_sim.0", NULL, sim_clk[0]),
- _REGISTER_CLOCK("mxc_alsa_spdif.0", NULL, spdif1_clk[0]),
+ _REGISTER_CLOCK("mxc_spdif.0", NULL, spdif1_clk[0]),
_REGISTER_CLOCK(NULL, "mipi_hsp_clk", mipi_hsp_clk),
_REGISTER_CLOCK(NULL, "ddr_hf_clk", ddr_hf_clk),
_REGISTER_CLOCK("imx51-ecspi.0", NULL, cspi1_clk[0]),
diff --git a/arch/arm/mach-mx5/devices-imx51.h b/arch/arm/mach-mx5/devices-imx51.h
index c58255c0920..2c6c865c411 100644
--- a/arch/arm/mach-mx5/devices-imx51.h
+++ b/arch/arm/mach-mx5/devices-imx51.h
@@ -64,3 +64,11 @@ extern const struct imx_tve_data imx51_tve_data __initconst;
#define imx51_add_v4l2_output(id) \
platform_device_register_resndata(NULL, "mxc_v4l2_output",\
id, NULL, 0, NULL, 0);
+
+extern const struct imx_spdif_data imx51_imx_spdif_data __initconst;
+#define imx51_add_spdif(pdata) imx_add_spdif(&imx51_imx_spdif_data, pdata)
+
+extern const struct imx_spdif_dai_data imx51_spdif_dai_data __initconst;
+#define imx51_add_spdif_dai() imx_add_spdif_dai(&imx51_spdif_dai_data)
+
+#define imx51_add_spdif_audio_device(pdata) imx_add_spdif_audio_device()
diff --git a/arch/arm/mach-mx5/devices-imx53.h b/arch/arm/mach-mx5/devices-imx53.h
index 192552f6838..a041d436800 100644
--- a/arch/arm/mach-mx5/devices-imx53.h
+++ b/arch/arm/mach-mx5/devices-imx53.h
@@ -41,6 +41,14 @@ extern const struct imx_imx_ssi_data imx53_imx_ssi_data[];
#define imx53_add_imx_ssi(id, pdata) \
imx_add_imx_ssi(&imx53_imx_ssi_data[id], pdata)
+extern const struct imx_spdif_data imx53_imx_spdif_data __initconst;
+#define imx53_add_spdif(pdata) imx_add_spdif(&imx53_imx_spdif_data, pdata)
+
+extern const struct imx_spdif_dai_data imx53_spdif_dai_data __initconst;
+#define imx53_add_spdif_dai() imx_add_spdif_dai(&imx53_spdif_dai_data)
+
+#define imx53_add_spdif_audio_device(pdata) imx_add_spdif_audio_device()
+
extern const struct imx_imx_keypad_data imx53_imx_keypad_data;
#define imx53_add_imx_keypad(pdata) \
imx_add_imx_keypad(&imx53_imx_keypad_data, pdata)
diff --git a/arch/arm/plat-mxc/devices/Kconfig b/arch/arm/plat-mxc/devices/Kconfig
index 76e4d4c6b9d..b591e3851a2 100644
--- a/arch/arm/plat-mxc/devices/Kconfig
+++ b/arch/arm/plat-mxc/devices/Kconfig
@@ -101,3 +101,6 @@ config IMX_HAVE_PLATFORM_AHCI
config IMX_HAVE_PLATFORM_IMX_VPU
bool
+
+config IMX_HAVE_PLATFORM_IMX_SPDIF
+ bool
diff --git a/arch/arm/plat-mxc/devices/Makefile b/arch/arm/plat-mxc/devices/Makefile
index 8d2da47fa76..6b9b6b200da 100644
--- a/arch/arm/plat-mxc/devices/Makefile
+++ b/arch/arm/plat-mxc/devices/Makefile
@@ -33,3 +33,6 @@ obj-$(CONFIG_IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX) += platform-sdhci-esdhc-imx.o
obj-$(CONFIG_IMX_HAVE_PLATFORM_SPI_IMX) += platform-spi_imx.o
obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_IIM) += platform-imx-iim.o
obj-$(CONFIG_IMX_HAVE_PLATFORM_AHCI) += platform-ahci-imx.o
+obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_SPDIF) += platform-imx-spdif.o
+obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_SPDIF) += platform-imx-spdif-dai.o
+obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_SPDIF) += platform-imx-spdif-audio.o
diff --git a/arch/arm/plat-mxc/devices/platform-imx-spdif-audio.c b/arch/arm/plat-mxc/devices/platform-imx-spdif-audio.c
new file mode 100644
index 00000000000..4a0cb7bf9a1
--- /dev/null
+++ b/arch/arm/plat-mxc/devices/platform-imx-spdif-audio.c
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2011 Freescale Semiconductor, Inc. All Rights Reserved.
+ */
+
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <mach/hardware.h>
+#include <mach/devices-common.h>
+
+struct platform_device *__init imx_add_spdif_audio_device(void)
+{
+ return imx_add_platform_device("imx-spdif-audio-device", 0,
+ NULL, 0, NULL, 0);
+}
+
diff --git a/arch/arm/plat-mxc/devices/platform-imx-spdif-dai.c b/arch/arm/plat-mxc/devices/platform-imx-spdif-dai.c
new file mode 100644
index 00000000000..516ebc52467
--- /dev/null
+++ b/arch/arm/plat-mxc/devices/platform-imx-spdif-dai.c
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2010 Pengutronix
+ * Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>
+ *
+ * Copyright (C) 2011 Freescale Semiconductor, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License version 2 as published by the
+ * Free Software Foundation.
+ */
+#include <mach/hardware.h>
+#include <mach/devices-common.h>
+
+#define MXC_SPDIF_TX_REG 0x2C
+#define MXC_SPDIF_RX_REG 0x14
+
+#define imx_spdif_dai_data_entry(soc) \
+ { \
+ .iobase = soc ## _SPDIF_BASE_ADDR, \
+ .dmatx = soc ## _DMA_REQ_SPDIF_TX, \
+ .dmarx = soc ## _DMA_REQ_SPDIF_RX, \
+ }
+
+#ifdef CONFIG_SOC_IMX51
+const struct imx_spdif_dai_data imx51_spdif_dai_data __initconst = {
+ .iobase = MX51_SPDIF_BASE_ADDR,
+ .dmatx = MX51_DMA_REQ_SPDIF,
+ };
+#endif /* ifdef CONFIG_SOC_IMX51 */
+
+#ifdef CONFIG_SOC_IMX53
+const struct imx_spdif_dai_data imx53_spdif_dai_data __initconst =
+ imx_spdif_dai_data_entry(MX53);
+#endif /* ifdef CONFIG_SOC_IMX53 */
+
+struct platform_device *__init imx_add_spdif_dai(
+ const struct imx_spdif_dai_data *data)
+{
+ struct resource res[] = {
+ {
+ .name = "tx_reg",
+ .start = data->iobase + MXC_SPDIF_TX_REG,
+ .end = data->iobase + MXC_SPDIF_TX_REG,
+ .flags = IORESOURCE_DMA,
+ }, {
+ .name = "rx_reg",
+ .start = data->iobase + MXC_SPDIF_RX_REG,
+ .end = data->iobase + MXC_SPDIF_RX_REG,
+ .flags = IORESOURCE_DMA,
+ }, {
+ .name = "tx",
+ .start = data->dmatx,
+ .end = data->dmatx,
+ .flags = IORESOURCE_DMA,
+ }, {
+ .name = "rx",
+ .start = data->dmarx,
+ .end = data->dmarx,
+ .flags = IORESOURCE_DMA,
+ },
+ };
+
+ return imx_add_platform_device("imx-spdif-dai", 0,
+ res, ARRAY_SIZE(res), NULL, 0);
+}
diff --git a/arch/arm/plat-mxc/devices/platform-imx-spdif.c b/arch/arm/plat-mxc/devices/platform-imx-spdif.c
new file mode 100644
index 00000000000..80a5e782067
--- /dev/null
+++ b/arch/arm/plat-mxc/devices/platform-imx-spdif.c
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2011 Freescale Semiconductor, Inc. All Rights Reserved.
+ */
+
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <mach/hardware.h>
+#include <mach/devices-common.h>
+
+#define imx5_spdif_data_entry_single(soc) \
+ { \
+ .iobase = soc ## _SPDIF_BASE_ADDR, \
+ .irq = soc ## _INT_SPDIF, \
+ }
+
+#ifdef CONFIG_SOC_IMX50
+const struct imx_spdif_data imx50_imx_spdif_data __initconst =
+ imx5_spdif_data_entry_single(MX53);
+#endif /* ifdef CONFIG_SOC_IMX50 */
+
+#ifdef CONFIG_SOC_IMX51
+const struct imx_spdif_data imx51_imx_spdif_data __initconst =
+ imx5_spdif_data_entry_single(MX51);
+#endif /* ifdef CONFIG_SOC_IMX51 */
+
+#ifdef CONFIG_SOC_IMX53
+const struct imx_spdif_data imx53_imx_spdif_data __initconst =
+ imx5_spdif_data_entry_single(MX53);
+#endif /* ifdef CONFIG_SOC_IMX53 */
+
+struct platform_device *__init imx_add_spdif(
+ const struct imx_spdif_data *data,
+ const struct mxc_spdif_platform_data *pdata)
+{
+ struct resource res[] = {
+ {
+ .start = data->iobase,
+ .end = data->iobase + 0x50,
+ .flags = IORESOURCE_MEM,
+ }, {
+ .start = data->irq,
+ .end = data->irq,
+ .flags = IORESOURCE_IRQ,
+ },
+ };
+
+ return imx_add_platform_device("mxc_spdif", 0,
+ res, ARRAY_SIZE(res), pdata, sizeof(*pdata));
+}
+
diff --git a/arch/arm/plat-mxc/include/mach/devices-common.h b/arch/arm/plat-mxc/include/mach/devices-common.h
index 7207263f470..d47616caff1 100644
--- a/arch/arm/plat-mxc/include/mach/devices-common.h
+++ b/arch/arm/plat-mxc/include/mach/devices-common.h
@@ -132,6 +132,24 @@ struct platform_device *__init imx_add_imx_ssi(
const struct imx_imx_ssi_data *data,
const struct imx_ssi_platform_data *pdata);
+struct imx_spdif_data {
+ resource_size_t iobase;
+ resource_size_t irq;
+};
+struct platform_device *__init imx_add_spdif(
+ const struct imx_spdif_data *data,
+ const struct mxc_spdif_platform_data *pdata);
+
+struct imx_spdif_dai_data {
+ resource_size_t iobase;
+ resource_size_t dmatx;
+ resource_size_t dmarx;
+};
+struct platform_device *__init imx_add_spdif_dai(
+ const struct imx_spdif_dai_data *data);
+
+struct platform_device *__init imx_add_spdif_audio_device(void);
+
#include <mach/imx-uart.h>
struct imx_imx_uart_3irq_data {
int id;
diff --git a/arch/arm/plat-mxc/include/mach/dma.h b/arch/arm/plat-mxc/include/mach/dma.h
index 233d0a5e2d6..dd41a6475be 100644
--- a/arch/arm/plat-mxc/include/mach/dma.h
+++ b/arch/arm/plat-mxc/include/mach/dma.h
@@ -53,6 +53,13 @@ struct imx_dma_data {
int priority;
};
+struct imx_pcm_dma_params {
+ enum sdma_peripheral_type peripheral_type;
+ int dma;
+ unsigned long dma_addr;
+ int burstsize;
+};
+
static inline int imx_dma_is_ipu(struct dma_chan *chan)
{
return !strcmp(dev_name(chan->device->dev), "ipu-core");