ARM: imx: fix/define clocks and create devices for imx dma
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Fri, 8 Oct 2010 14:00:11 +0000 (16:00 +0200)
committerSascha Hauer <s.hauer@pengutronix.de>
Mon, 11 Oct 2010 13:30:31 +0000 (15:30 +0200)
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
arch/arm/mach-mx3/clock-imx31.c
arch/arm/mach-mx3/clock-imx35.c
arch/arm/mach-mx5/clock-mx51.c
arch/arm/plat-mxc/devices/Makefile
arch/arm/plat-mxc/devices/platform-imx-dma.c [new file with mode: 0644]
arch/arm/plat-mxc/include/mach/mx51.h

index 18e98f1d4de0504bb20fa92e06bd58541fc9bb5b..109e98f323e0568a299d46f1481ee3a31116476e 100644 (file)
@@ -477,7 +477,7 @@ DEFINE_CLOCK(epit1_clk,   0, MXC_CCM_CGR0,  6, NULL, NULL, &perclk_clk);
 DEFINE_CLOCK(epit2_clk,   1, MXC_CCM_CGR0,  8, NULL, NULL, &perclk_clk);
 DEFINE_CLOCK(iim_clk,     0, MXC_CCM_CGR0, 10, NULL, NULL, &ipg_clk);
 DEFINE_CLOCK(ata_clk,     0, MXC_CCM_CGR0, 12, NULL, NULL, &ipg_clk);
-DEFINE_CLOCK(sdma_clk1,   0, MXC_CCM_CGR0, 14, NULL, &sdma_clk1, &ahb_clk);
+DEFINE_CLOCK(sdma_clk1,   0, MXC_CCM_CGR0, 14, NULL, NULL, &ahb_clk);
 DEFINE_CLOCK(cspi3_clk,   2, MXC_CCM_CGR0, 16, NULL, NULL, &ipg_clk);
 DEFINE_CLOCK(rng_clk,     0, MXC_CCM_CGR0, 18, NULL, NULL, &ipg_clk);
 DEFINE_CLOCK(uart1_clk,   0, MXC_CCM_CGR0, 20, NULL, NULL, &perclk_clk);
@@ -564,7 +564,7 @@ static struct clk_lookup lookups[] = {
        _REGISTER_CLOCK(NULL, "ata", ata_clk)
        _REGISTER_CLOCK(NULL, "rtic", rtic_clk)
        _REGISTER_CLOCK(NULL, "rng", rng_clk)
-       _REGISTER_CLOCK(NULL, "sdma_ahb", sdma_clk1)
+       _REGISTER_CLOCK("imx-sdma", NULL, sdma_clk1)
        _REGISTER_CLOCK(NULL, "sdma_ipg", sdma_clk2)
        _REGISTER_CLOCK(NULL, "mstick", mstick1_clk)
        _REGISTER_CLOCK(NULL, "mstick", mstick2_clk)
index 9a10098841645b375a79fd1b8e2fb14b741f963e..61e4a318980a2bc9fe4fa25c7de02a08a7b89bb8 100644 (file)
@@ -482,7 +482,7 @@ static struct clk_lookup lookups[] = {
        _REGISTER_CLOCK(NULL, "rtc", rtc_clk)
        _REGISTER_CLOCK(NULL, "rtic", rtic_clk)
        _REGISTER_CLOCK(NULL, "scc", scc_clk)
-       _REGISTER_CLOCK(NULL, "sdma", sdma_clk)
+       _REGISTER_CLOCK("imx-sdma", NULL, sdma_clk)
        _REGISTER_CLOCK(NULL, "spba", spba_clk)
        _REGISTER_CLOCK(NULL, "spdif", spdif_clk)
        _REGISTER_CLOCK("imx-ssi.0", NULL, ssi1_clk)
index e6c17d78189c7b28d18e615f245aca545eb781e6..21cecc0401727dad6f108071180391d71452382f 100644 (file)
@@ -977,6 +977,10 @@ DEFINE_CLOCK(cspi_ipg_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG9_OFFSET,
 DEFINE_CLOCK(cspi_clk, 0, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG13_OFFSET,
                NULL, NULL, &ipg_clk, &cspi_ipg_clk);
 
+/* SDMA */
+DEFINE_CLOCK(sdma_clk, 1, MXC_CCM_CCGR4, MXC_CCM_CCGRx_CG15_OFFSET,
+               NULL, NULL, &ahb_clk, NULL);
+
 #define _REGISTER_CLOCK(d, n, c) \
        { \
                .dev_id = d, \
@@ -1003,6 +1007,7 @@ static struct clk_lookup lookups[] = {
        _REGISTER_CLOCK("mxc_nand", NULL, nfc_clk)
        _REGISTER_CLOCK("imx-ssi.0", NULL, ssi1_clk)
        _REGISTER_CLOCK("imx-ssi.1", NULL, ssi2_clk)
+       _REGISTER_CLOCK("imx-sdma", NULL, sdma_clk)
        _REGISTER_CLOCK(NULL, "ckih", ckih_clk)
        _REGISTER_CLOCK(NULL, "ckih2", ckih2_clk)
        _REGISTER_CLOCK(NULL, "gpt_32k", gpt_32k_clk)
index da9676e80e8df6cf06ad811555ec164470b93fd2..cd0bf756c3f803ff4537352359fb226fa2a080b3 100644 (file)
@@ -1,5 +1,6 @@
 obj-$(CONFIG_IMX_HAVE_PLATFORM_ESDHC) += platform-esdhc.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_FLEXCAN) += platform-flexcan.o
+obj-y += platform-imx-dma.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_I2C) += platform-imx-i2c.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_SSI) += platform-imx-ssi.o
 obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_UART) += platform-imx-uart.o
diff --git a/arch/arm/plat-mxc/devices/platform-imx-dma.c b/arch/arm/plat-mxc/devices/platform-imx-dma.c
new file mode 100644 (file)
index 0000000..02d9890
--- /dev/null
@@ -0,0 +1,129 @@
+/*
+ * Copyright (C) 2010 Pengutronix
+ * Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>
+ *
+ * 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 <linux/compiler.h>
+#include <linux/err.h>
+#include <linux/init.h>
+
+#include <mach/hardware.h>
+#include <mach/devices-common.h>
+#ifdef SDMA_IS_MERGED
+#include <mach/sdma.h>
+#else
+struct sdma_platform_data {
+       int sdma_version;
+       char *cpu_name;
+       int to_version;
+};
+#endif
+
+struct imx_imx_sdma_data {
+       resource_size_t iobase;
+       resource_size_t irq;
+       struct sdma_platform_data pdata;
+};
+
+#define imx_imx_sdma_data_entry_single(soc, _sdma_version, _cpu_name, _to_version)\
+       {                                                               \
+               .iobase = soc ## _SDMA ## _BASE_ADDR,                   \
+               .irq = soc ## _INT_SDMA,                                \
+               .pdata = {                                              \
+                       .sdma_version = _sdma_version,                  \
+                       .cpu_name = _cpu_name,                          \
+                       .to_version = _to_version,                      \
+               },                                                      \
+       }
+
+#ifdef CONFIG_ARCH_MX25
+const struct imx_imx_sdma_data imx25_imx_sdma_data __initconst =
+       imx_imx_sdma_data_entry_single(MX25, 1, "imx25", 0);
+#endif /* ifdef CONFIG_ARCH_MX25 */
+
+#ifdef CONFIG_ARCH_MX31
+struct imx_imx_sdma_data imx31_imx_sdma_data __initdata =
+       imx_imx_sdma_data_entry_single(MX31, 1, "imx31", 0);
+#endif /* ifdef CONFIG_ARCH_MX31 */
+
+#ifdef CONFIG_ARCH_MX35
+struct imx_imx_sdma_data imx35_imx_sdma_data __initdata =
+       imx_imx_sdma_data_entry_single(MX35, 2, "imx35", 0);
+#endif /* ifdef CONFIG_ARCH_MX35 */
+
+#ifdef CONFIG_ARCH_MX51
+const struct imx_imx_sdma_data imx51_imx_sdma_data __initconst =
+       imx_imx_sdma_data_entry_single(MX51, 2, "imx51", 0);
+#endif /* ifdef CONFIG_ARCH_MX51 */
+
+static struct platform_device __init __maybe_unused *imx_add_imx_sdma(
+               const struct imx_imx_sdma_data *data)
+{
+       struct resource res[] = {
+               {
+                       .start = data->iobase,
+                       .end = data->iobase + SZ_4K - 1,
+                       .flags = IORESOURCE_MEM,
+               }, {
+                       .start = data->irq,
+                       .end = data->irq,
+                       .flags = IORESOURCE_IRQ,
+               },
+       };
+
+       return imx_add_platform_device("imx-sdma", -1,
+                       res, ARRAY_SIZE(res),
+                       &data->pdata, sizeof(data->pdata));
+}
+
+static struct platform_device __init __maybe_unused *imx_add_imx_dma(void)
+{
+       return imx_add_platform_device("imx-dma", -1, NULL, 0, NULL, 0);
+}
+
+static int __init imxXX_add_imx_dma(void)
+{
+       struct platform_device *ret;
+
+#if defined(CONFIG_SOC_IMX21) || defined(CONFIG_SOC_IMX27)
+       if (cpu_is_mx21() || cpu_is_mx27())
+               ret = imx_add_imx_dma();
+       else
+#endif
+
+#if defined(CONFIG_ARCH_MX25)
+       if (cpu_is_mx25())
+               ret = imx_add_imx_sdma(&imx25_imx_sdma_data);
+       else
+#endif
+
+#if defined(CONFIG_ARCH_MX31)
+       if (cpu_is_mx31()) {
+               imx31_imx_sdma_data.pdata.to_version = mx31_revision() >> 4;
+               ret = imx_add_imx_sdma(&imx31_imx_sdma_data);
+       } else
+#endif
+
+#if defined(CONFIG_ARCH_MX35)
+       if (cpu_is_mx35()) {
+               imx35_imx_sdma_data.pdata.to_version = mx35_revision() >> 4;
+               ret = imx_add_imx_sdma(&imx35_imx_sdma_data);
+       } else
+#endif
+
+#if defined(CONFIG_ARCH_MX51)
+       if (cpu_is_mx51())
+               ret = imx_add_imx_sdma(&imx51_imx_sdma_data);
+       else
+#endif
+               ret = ERR_PTR(-ENODEV);
+
+       if (IS_ERR(ret))
+               return PTR_ERR(ret);
+
+       return 0;
+}
+arch_initcall(imxXX_add_imx_dma);
index c99eeab6fe09ad29cb2d577eb04ae3d6f39e0af3..1906ee5a5497984a16c6312d0d66e96534c84d63 100644 (file)
 #define MX51_MXC_INT_MMC_SDHC3         3
 #define MX51_MXC_INT_MMC_SDHC4         4
 #define MX51_MXC_INT_RESV5             5
-#define MX51_MXC_INT_SDMA              6
+#define MX51_INT_SDMA                  6
 #define MX51_MXC_INT_IOMUX             7
 #define MX51_INT_NFC                   8
 #define MX51_MXC_INT_VPU               9