* [PATCH 1/3] ARM i.MX: Add driver to get sdram base and size
2012-11-27 20:48 [PATCH] i.MX sdram controller driver support Sascha Hauer
@ 2012-11-27 20:48 ` Sascha Hauer
2012-11-27 20:48 ` [PATCH 2/3] ARM i.MX: register esdctl controller device Sascha Hauer
2012-11-27 20:48 ` [PATCH 3/3] ARM i.MX boards: use esdctl code to detect sdram size Sascha Hauer
2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2012-11-27 20:48 UTC (permalink / raw)
To: barebox
The code initializing the SDRAM controller is not at the same
place where SDRAM is registered with barebox. To reduce the
risk of registering wrong SDRAM sizes this patch adds a
driver for the ESDCTL which reads back the configured SDRAM
size and registers the memory found with barebox.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
arch/arm/mach-imx/Makefile | 3 +-
arch/arm/mach-imx/esdctl.c | 348 ++++++++++++++++++++++++++++
arch/arm/mach-imx/imx1.c | 2 +
arch/arm/mach-imx/include/mach/esdctl.h | 1 +
arch/arm/mach-imx/include/mach/imx1-regs.h | 3 +
5 files changed, 356 insertions(+), 1 deletion(-)
create mode 100644 arch/arm/mach-imx/esdctl.c
diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
index 259733e..6bc2b79 100644
--- a/arch/arm/mach-imx/Makefile
+++ b/arch/arm/mach-imx/Makefile
@@ -14,6 +14,7 @@ obj-$(CONFIG_NAND_IMX) += nand.o
obj-$(CONFIG_ARCH_IMX_EXTERNAL_BOOT_NAND) += external-nand-boot.o
pbl-$(CONFIG_ARCH_IMX_EXTERNAL_BOOT_NAND) += external-nand-boot.o
obj-$(CONFIG_COMMON_CLK) += clk-pllv1.o clk-pllv2.o clk-pllv3.o clk-pfd.o
-obj-y += devices.o imx.o
+obj-y += devices.o imx.o esdctl.o
obj-y += boot.o
obj-$(CONFIG_BAREBOX_UPDATE) += imx-bbu-internal.o
+pbl-y += esdctl.o
diff --git a/arch/arm/mach-imx/esdctl.c b/arch/arm/mach-imx/esdctl.c
new file mode 100644
index 0000000..99b7f80
--- /dev/null
+++ b/arch/arm/mach-imx/esdctl.c
@@ -0,0 +1,348 @@
+/*
+ * esdctl.c - i.MX sdram controller functions
+ *
+ * Copyright (c) 2012 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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.
+ *
+ * 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.
+ */
+
+#include <common.h>
+#include <io.h>
+#include <sizes.h>
+#include <init.h>
+#include <asm/barebox-arm.h>
+#include <asm/memory.h>
+#include <mach/esdctl.h>
+#include <mach/imx1-regs.h>
+#include <mach/imx21-regs.h>
+#include <mach/imx25-regs.h>
+#include <mach/imx27-regs.h>
+#include <mach/imx31-regs.h>
+#include <mach/imx35-regs.h>
+#include <mach/imx51-regs.h>
+#include <mach/imx53-regs.h>
+
+struct imx_esdctl_data {
+ unsigned long base0;
+ unsigned long base1;
+ void (*add_mem)(void *esdctlbase, struct imx_esdctl_data *);
+};
+
+/*
+ * v1 - found on i.MX1
+ */
+static inline unsigned long imx_v1_sdram_size(void __iomem *esdctlbase, int num)
+{
+ void __iomem *esdctl = esdctlbase + (num ? 4 : 0);
+ u32 ctlval = readl(esdctl);
+ unsigned long size;
+ int rows, cols, width = 2, banks = 4;
+
+ if (!(ctlval & ESDCTL0_SDE))
+ /* SDRAM controller disabled, so no RAM here */
+ return 0;
+
+ rows = ((ctlval >> 24) & 0x3) + 11;
+ cols = ((ctlval >> 20) & 0x3) + 8;
+
+ if (ctlval & (1 << 17))
+ width = 4;
+
+ size = (1 << cols) * (1 << rows) * banks * width;
+
+ if (size > SZ_64M)
+ size = SZ_64M;
+
+ return size;
+}
+
+/*
+ * v2 - found on i.MX25, i.MX27, i.MX31 and i.MX35
+ */
+static inline unsigned long imx_v2_sdram_size(void __iomem *esdctlbase, int num)
+{
+ void __iomem *esdctl = esdctlbase + (num ? IMX_ESDCTL1 : IMX_ESDCTL0);
+ u32 ctlval = readl(esdctl);
+ unsigned long size;
+ int rows, cols, width = 2, banks = 4;
+
+ if (!(ctlval & ESDCTL0_SDE))
+ /* SDRAM controller disabled, so no RAM here */
+ return 0;
+
+ rows = ((ctlval >> 24) & 0x7) + 11;
+ cols = ((ctlval >> 20) & 0x3) + 8;
+
+ if ((ctlval & ESDCTL0_DSIZ_MASK) == ESDCTL0_DSIZ_31_0)
+ width = 4;
+
+ size = (1 << cols) * (1 << rows) * banks * width;
+
+ if (size > SZ_256M)
+ size = SZ_256M;
+
+ return size;
+}
+
+/*
+ * v3 - found on i.MX51
+ */
+static inline unsigned long imx_v3_sdram_size(void __iomem *esdctlbase, int num)
+{
+ unsigned long size;
+
+ size = imx_v2_sdram_size(esdctlbase, num);
+
+ if (readl(esdctlbase + IMX_ESDMISC) & (1 << 6))
+ size *= 2;
+
+ if (size > SZ_256M)
+ size = SZ_256M;
+
+ return size;
+}
+
+#define IMX_ESDCTL_V4_ESDCTL 0x0
+#define IMX_ESDCTL_V4_ESDMISC 0x18
+
+#define ESDCTL_V4_ESDCTL_DSIZ (1 << 16)
+#define ESDCTL_V4_ESDMISC_DDR_4_BANK (1 << 5)
+#define ESDCTL_V4_ESDMISC_ONECS (1 << 20)
+
+#define ESDCTL_V4_ESDCTL_SDE_0 (1 << 31)
+#define ESDCTL_V4_ESDCTL_SDE_1 (1 << 30)
+#define ESDCTL_V4_ESDMISC_BI (1 << 12)
+
+/*
+ * v4 - found on i.MX53
+ */
+static inline unsigned long imx_v4_sdram_size(void __iomem *esdctlbase, int cs)
+{
+ u32 ctlval = readl(esdctlbase + IMX_ESDCTL_V4_ESDCTL);
+ u32 esdmisc = readl(esdctlbase + IMX_ESDCTL_V4_ESDMISC);
+ unsigned long size;
+ int rows, cols, width = 2, banks = 8;
+
+ if (cs == 0 && !(ctlval & ESDCTL_V4_ESDCTL_SDE_0))
+ return 0;
+ if (cs == 1 && !(ctlval & ESDCTL_V4_ESDCTL_SDE_1))
+ return 0;
+
+ /* one 2GiB cs, memory is returned for cs0 only */
+ if (cs == 1 && (esdmisc & ESDCTL_V4_ESDMISC_ONECS))
+ return 9;
+
+ rows = ((ctlval >> 24) & 0x7) + 11;
+ switch ((ctlval >> 20) & 0x7) {
+ case 0:
+ cols = 9;
+ break;
+ case 1:
+ cols = 10;
+ break;
+ case 2:
+ cols = 11;
+ break;
+ case 3:
+ cols = 8;
+ break;
+ case 4:
+ cols = 12;
+ break;
+ default:
+ cols = 0;
+ break;
+ }
+
+ if (ctlval & ESDCTL_V4_ESDCTL_DSIZ)
+ width = 4;
+
+ if (esdmisc & ESDCTL_V4_ESDMISC_DDR_4_BANK)
+ banks = 4;
+
+ size = (1 << cols) * (1 << rows) * banks * width;
+
+ /* bank interleaved, double size */
+ if (esdmisc & ESDCTL_V4_ESDMISC_BI)
+ return size * 2;
+
+ return size;
+}
+
+static void add_mem(unsigned long base0, unsigned long size0,
+ unsigned long base1, unsigned long size1)
+{
+ debug("%s: cs0 base: 0x%08x cs0 size: 0x%08x\n", __func__, base0, size0);
+ debug("%s: cs1 base: 0x%08x cs1 size: 0x%08x\n", __func__, base1, size1);
+
+ if (base0 + size0 == base1 && size1 > 0) {
+ /*
+ * concatenate both chip selects to a single bank
+ */
+ arm_add_mem_device("ram0", base0, size0 + size1);
+
+ return;
+ }
+
+ if (size0)
+ arm_add_mem_device("ram0", base0, size0);
+
+ if (size1)
+ arm_add_mem_device(size0 ? "ram1" : "ram0", base1, size1);
+}
+
+static void imx_esdctl_v1_add_mem(void *esdctlbase, struct imx_esdctl_data *data)
+{
+ add_mem(data->base0, imx_v1_sdram_size(esdctlbase, 0),
+ data->base1, imx_v1_sdram_size(esdctlbase, 1));
+}
+
+static void imx_esdctl_v2_add_mem(void *esdctlbase, struct imx_esdctl_data *data)
+{
+ add_mem(data->base0, imx_v2_sdram_size(esdctlbase, 0),
+ data->base1, imx_v2_sdram_size(esdctlbase, 1));
+}
+
+static void imx_esdctl_v3_add_mem(void *esdctlbase, struct imx_esdctl_data *data)
+{
+ add_mem(data->base0, imx_v3_sdram_size(esdctlbase, 0),
+ data->base1, imx_v3_sdram_size(esdctlbase, 1));
+}
+
+static void imx_esdctl_v4_add_mem(void *esdctlbase, struct imx_esdctl_data *data)
+{
+ add_mem(data->base0, imx_v4_sdram_size(esdctlbase, 0),
+ data->base1, imx_v4_sdram_size(esdctlbase, 1));
+}
+
+static __maybe_unused struct imx_esdctl_data imx1_data = {
+ .base0 = MX1_CSD0_BASE_ADDR,
+ .base1 = MX1_CSD1_BASE_ADDR,
+ .add_mem = imx_esdctl_v1_add_mem,
+};
+
+static int imx_esdctl_probe(struct device_d *dev)
+{
+ struct imx_esdctl_data *data;
+ int ret;
+ void *base;
+
+ ret = dev_get_drvdata(dev, (unsigned long *)&data);
+ if (ret)
+ return ret;
+
+ base = dev_request_mem_region(dev, 0);
+ if (!base)
+ return -ENOMEM;
+
+ data->add_mem(base, data);
+
+ return 0;
+}
+
+static __maybe_unused struct imx_esdctl_data imx25_data = {
+ .base0 = MX25_CSD0_BASE_ADDR,
+ .base1 = MX25_CSD1_BASE_ADDR,
+ .add_mem = imx_esdctl_v2_add_mem,
+};
+
+static __maybe_unused struct imx_esdctl_data imx27_data = {
+ .base0 = MX27_CSD0_BASE_ADDR,
+ .base1 = MX27_CSD1_BASE_ADDR,
+ .add_mem = imx_esdctl_v2_add_mem,
+};
+
+static __maybe_unused struct imx_esdctl_data imx31_data = {
+ .base0 = MX31_CSD0_BASE_ADDR,
+ .base1 = MX31_CSD1_BASE_ADDR,
+ .add_mem = imx_esdctl_v2_add_mem,
+};
+
+static __maybe_unused struct imx_esdctl_data imx35_data = {
+ .base0 = MX35_CSD0_BASE_ADDR,
+ .base1 = MX35_CSD1_BASE_ADDR,
+ .add_mem = imx_esdctl_v2_add_mem,
+};
+
+static __maybe_unused struct imx_esdctl_data imx51_data = {
+ .base0 = MX51_CSD0_BASE_ADDR,
+ .base1 = MX51_CSD1_BASE_ADDR,
+ .add_mem = imx_esdctl_v3_add_mem,
+};
+
+static __maybe_unused struct imx_esdctl_data imx53_data = {
+ .base0 = MX53_CSD0_BASE_ADDR,
+ .base1 = MX53_CSD1_BASE_ADDR,
+ .add_mem = imx_esdctl_v4_add_mem,
+};
+
+static struct platform_device_id imx_esdctl_ids[] = {
+#ifdef CONFIG_ARCH_IMX1
+ {
+ .name = "imx1-sdramc",
+ .driver_data = (unsigned long)&imx1_data,
+ },
+#endif
+#ifdef CONFIG_ARCH_IMX25
+ {
+ .name = "imx25-esdctl",
+ .driver_data = (unsigned long)&imx25_data,
+ },
+#endif
+#ifdef CONFIG_ARCH_IMX27
+ {
+ .name = "imx27-esdctl",
+ .driver_data = (unsigned long)&imx27_data,
+ },
+#endif
+#ifdef CONFIG_ARCH_IMX31
+ {
+ .name = "imx31-esdctl",
+ .driver_data = (unsigned long)&imx31_data,
+ },
+#endif
+#ifdef CONFIG_ARCH_IMX35
+ {
+ .name = "imx35-esdctl",
+ .driver_data = (unsigned long)&imx35_data,
+ },
+#endif
+#ifdef CONFIG_ARCH_IMX51
+ {
+ .name = "imx51-esdctl",
+ .driver_data = (unsigned long)&imx51_data,
+ },
+#endif
+#ifdef CONFIG_ARCH_IMX53
+ {
+ .name = "imx53-esdctl",
+ .driver_data = (unsigned long)&imx53_data,
+ },
+#endif
+ {
+ /* sentinel */
+ },
+};
+
+static struct driver_d imx_serial_driver = {
+ .name = "imx-esdctl",
+ .probe = imx_esdctl_probe,
+ .id_table = imx_esdctl_ids,
+};
+
+static int imx_esdctl_init(void)
+{
+ return platform_driver_register(&imx_serial_driver);
+}
+
+mem_initcall(imx_esdctl_init);
diff --git a/arch/arm/mach-imx/imx1.c b/arch/arm/mach-imx/imx1.c
index 18901ea..59cff28 100644
--- a/arch/arm/mach-imx/imx1.c
+++ b/arch/arm/mach-imx/imx1.c
@@ -49,6 +49,8 @@ void imx1_setup_eimcs(size_t cs, unsigned upper, unsigned lower)
writel(lower, MX1_EIM_BASE_ADDR + 4 + cs * 8);
}
+#include <mach/esdctl.h>
+
static int imx1_init(void)
{
imx_iomuxv1_init((void *)MX1_GPIO1_BASE_ADDR);
diff --git a/arch/arm/mach-imx/include/mach/esdctl.h b/arch/arm/mach-imx/include/mach/esdctl.h
index 8124c87..1aec2a8 100644
--- a/arch/arm/mach-imx/include/mach/esdctl.h
+++ b/arch/arm/mach-imx/include/mach/esdctl.h
@@ -26,6 +26,7 @@
#define ESDCTL0_DSIZ_31_16 (0 << 16)
#define ESDCTL0_DSIZ_15_0 (1 << 16)
#define ESDCTL0_DSIZ_31_0 (2 << 16)
+#define ESDCTL0_DSIZ_MASK (3 << 16)
#define ESDCTL0_REF1 (1 << 13)
#define ESDCTL0_REF2 (2 << 13)
#define ESDCTL0_REF4 (3 << 13)
diff --git a/arch/arm/mach-imx/include/mach/imx1-regs.h b/arch/arm/mach-imx/include/mach/imx1-regs.h
index df6ede5..69e57e3 100644
--- a/arch/arm/mach-imx/include/mach/imx1-regs.h
+++ b/arch/arm/mach-imx/include/mach/imx1-regs.h
@@ -4,6 +4,9 @@
#define MX1_IO_BASE_ADDR 0x00200000
#define MX1_IO_SIZE SZ_1M
+#define MX1_CSD0_BASE_ADDR 0x08000000
+#define MX1_CSD1_BASE_ADDR 0x0c000000
+
#define MX1_CS0_PHYS 0x10000000
#define MX1_CS0_SIZE 0x02000000
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/3] ARM i.MX: register esdctl controller device
2012-11-27 20:48 [PATCH] i.MX sdram controller driver support Sascha Hauer
2012-11-27 20:48 ` [PATCH 1/3] ARM i.MX: Add driver to get sdram base and size Sascha Hauer
@ 2012-11-27 20:48 ` Sascha Hauer
2012-11-27 20:48 ` [PATCH 3/3] ARM i.MX boards: use esdctl code to detect sdram size Sascha Hauer
2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2012-11-27 20:48 UTC (permalink / raw)
To: barebox
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
arch/arm/mach-imx/imx1.c | 1 +
arch/arm/mach-imx/imx25.c | 1 +
arch/arm/mach-imx/imx27.c | 1 +
arch/arm/mach-imx/imx31.c | 1 +
arch/arm/mach-imx/imx35.c | 1 +
arch/arm/mach-imx/imx51.c | 1 +
arch/arm/mach-imx/imx53.c | 1 +
7 files changed, 7 insertions(+)
diff --git a/arch/arm/mach-imx/imx1.c b/arch/arm/mach-imx/imx1.c
index 59cff28..588ac02 100644
--- a/arch/arm/mach-imx/imx1.c
+++ b/arch/arm/mach-imx/imx1.c
@@ -63,6 +63,7 @@ static int imx1_init(void)
add_generic_device("imx1-gpio", 2, NULL, MX1_GPIO3_BASE_ADDR, 0x100, IORESOURCE_MEM, NULL);
add_generic_device("imx1-gpio", 3, NULL, MX1_GPIO4_BASE_ADDR, 0x100, IORESOURCE_MEM, NULL);
add_generic_device("imx1-wdt", 0, NULL, MX1_WDT_BASE_ADDR, 0x100, IORESOURCE_MEM, NULL);
+ add_generic_device("imx1-sdramc", 0, NULL, MX1_SDRAMC_BASE_ADDR, 0x100, IORESOURCE_MEM, NULL);
return 0;
}
diff --git a/arch/arm/mach-imx/imx25.c b/arch/arm/mach-imx/imx25.c
index 3bd95c1..e2ef374 100644
--- a/arch/arm/mach-imx/imx25.c
+++ b/arch/arm/mach-imx/imx25.c
@@ -75,6 +75,7 @@ static int imx25_init(void)
add_generic_device("imx31-gpio", 2, NULL, MX25_GPIO3_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
add_generic_device("imx31-gpio", 3, NULL, MX25_GPIO4_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
add_generic_device("imx21-wdt", 0, NULL, MX25_WDOG_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
+ add_generic_device("imx25-esdctl", 0, NULL, MX25_ESDCTL_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
return 0;
}
diff --git a/arch/arm/mach-imx/imx27.c b/arch/arm/mach-imx/imx27.c
index a0a510f..31117f4 100644
--- a/arch/arm/mach-imx/imx27.c
+++ b/arch/arm/mach-imx/imx27.c
@@ -117,6 +117,7 @@ static int imx27_init(void)
add_generic_device("imx1-gpio", 4, NULL, MX27_GPIO5_BASE_ADDR, 0x100, IORESOURCE_MEM, NULL);
add_generic_device("imx1-gpio", 5, NULL, MX27_GPIO6_BASE_ADDR, 0x100, IORESOURCE_MEM, NULL);
add_generic_device("imx21-wdt", 0, NULL, MX27_WDOG_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
+ add_generic_device("imx27-esdctl", 0, NULL, MX27_ESDCTL_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
return 0;
}
diff --git a/arch/arm/mach-imx/imx31.c b/arch/arm/mach-imx/imx31.c
index b2f0724..52be541 100644
--- a/arch/arm/mach-imx/imx31.c
+++ b/arch/arm/mach-imx/imx31.c
@@ -38,6 +38,7 @@ static int imx31_init(void)
add_generic_device("imx-gpio", 1, NULL, MX31_GPIO2_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
add_generic_device("imx-gpio", 2, NULL, MX31_GPIO3_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
add_generic_device("imx21-wdt", 0, NULL, MX31_WDOG_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
+ add_generic_device("imx31-esdctl", 0, NULL, MX31_ESDCTL_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
return 0;
}
diff --git a/arch/arm/mach-imx/imx35.c b/arch/arm/mach-imx/imx35.c
index 737eb3a..21c7e90 100644
--- a/arch/arm/mach-imx/imx35.c
+++ b/arch/arm/mach-imx/imx35.c
@@ -77,6 +77,7 @@ static int imx35_init(void)
add_generic_device("imx-gpio", 1, NULL, MX35_GPIO2_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
add_generic_device("imx-gpio", 2, NULL, MX35_GPIO3_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
add_generic_device("imx21-wdt", 0, NULL, MX35_WDOG_BASE_ADDR, 0x4000, IORESOURCE_MEM, NULL);
+ add_generic_device("imx35-esdctl", 0, NULL, MX35_ESDCTL_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
return 0;
}
diff --git a/arch/arm/mach-imx/imx51.c b/arch/arm/mach-imx/imx51.c
index 4b0786b..3d0520a 100644
--- a/arch/arm/mach-imx/imx51.c
+++ b/arch/arm/mach-imx/imx51.c
@@ -69,6 +69,7 @@ static int imx51_init(void)
add_generic_device("imx31-gpio", 2, NULL, MX51_GPIO3_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
add_generic_device("imx31-gpio", 3, NULL, MX51_GPIO4_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
add_generic_device("imx21-wdt", 0, NULL, MX51_WDOG_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
+ add_generic_device("imx51-esdctl", 0, NULL, MX51_ESDCTL_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
return 0;
}
diff --git a/arch/arm/mach-imx/imx53.c b/arch/arm/mach-imx/imx53.c
index e424e7d..2d6557f 100644
--- a/arch/arm/mach-imx/imx53.c
+++ b/arch/arm/mach-imx/imx53.c
@@ -69,6 +69,7 @@ static int imx53_init(void)
add_generic_device("imx31-gpio", 5, NULL, MX53_GPIO6_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
add_generic_device("imx31-gpio", 6, NULL, MX53_GPIO7_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
add_generic_device("imx21-wdt", 0, NULL, MX53_WDOG1_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
+ add_generic_device("imx53-esdctl", 0, NULL, MX53_ESDCTL_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
return 0;
}
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 3/3] ARM i.MX boards: use esdctl code to detect sdram size
2012-11-27 20:48 [PATCH] i.MX sdram controller driver support Sascha Hauer
2012-11-27 20:48 ` [PATCH 1/3] ARM i.MX: Add driver to get sdram base and size Sascha Hauer
2012-11-27 20:48 ` [PATCH 2/3] ARM i.MX: register esdctl controller device Sascha Hauer
@ 2012-11-27 20:48 ` Sascha Hauer
2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2012-11-27 20:48 UTC (permalink / raw)
To: barebox
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
arch/arm/boards/ccxmx51/ccxmx51.c | 9 ---------
arch/arm/boards/eukrea_cpuimx25/eukrea_cpuimx25.c | 8 --------
arch/arm/boards/eukrea_cpuimx27/eukrea_cpuimx27.c | 14 --------------
arch/arm/boards/eukrea_cpuimx35/eukrea_cpuimx35.c | 8 --------
arch/arm/boards/eukrea_cpuimx51/eukrea_cpuimx51.c | 8 --------
arch/arm/boards/freescale-mx25-3-stack/3stack.c | 18 ++----------------
arch/arm/boards/freescale-mx35-3-stack/3stack.c | 9 ---------
arch/arm/boards/freescale-mx51-pdk/board.c | 8 --------
arch/arm/boards/freescale-mx53-loco/board.c | 9 ---------
arch/arm/boards/freescale-mx53-smd/board.c | 9 ---------
arch/arm/boards/guf-cupid/board.c | 8 --------
arch/arm/boards/guf-neso/board.c | 8 --------
arch/arm/boards/imx27ads/imx27ads.c | 8 --------
arch/arm/boards/karo-tx25/board.c | 14 +++-----------
arch/arm/boards/karo-tx51/tx51.c | 8 --------
arch/arm/boards/karo-tx53/board.c | 11 -----------
arch/arm/boards/pcm037/pcm037.c | 11 -----------
arch/arm/boards/pcm038/pcm038.c | 14 ++++----------
arch/arm/boards/pcm043/pcm043.c | 8 --------
arch/arm/boards/phycard-i.MX27/pca100.c | 8 --------
arch/arm/boards/scb9328/scb9328.c | 8 --------
arch/arm/boards/tqma53/board.c | 11 -----------
22 files changed, 9 insertions(+), 208 deletions(-)
diff --git a/arch/arm/boards/ccxmx51/ccxmx51.c b/arch/arm/boards/ccxmx51/ccxmx51.c
index a8d172c..b3173a4 100644
--- a/arch/arm/boards/ccxmx51/ccxmx51.c
+++ b/arch/arm/boards/ccxmx51/ccxmx51.c
@@ -197,15 +197,6 @@ static const struct spi_board_info ccxmx51_spi_board_info[] = {
},
};
-static int ccxmx51_mem_init(void)
-{
- /* Add minimal SDRAM first */
- arm_add_mem_device("ram0", MX51_CSD0_BASE_ADDR, SZ_128M);
-
- return 0;
-}
-mem_initcall(ccxmx51_mem_init);
-
static void ccxmx51_otghost_init(void)
{
#define MX51_USBOTHER_REGS_OFFSET 0x800
diff --git a/arch/arm/boards/eukrea_cpuimx25/eukrea_cpuimx25.c b/arch/arm/boards/eukrea_cpuimx25/eukrea_cpuimx25.c
index 92e8df2..ae2363a 100644
--- a/arch/arm/boards/eukrea_cpuimx25/eukrea_cpuimx25.c
+++ b/arch/arm/boards/eukrea_cpuimx25/eukrea_cpuimx25.c
@@ -117,14 +117,6 @@ static struct fsl_usb2_platform_data usb_pdata = {
.phy_mode = FSL_USB2_PHY_UTMI,
};
-static int eukrea_cpuimx25_mem_init(void)
-{
- arm_add_mem_device("ram0", MX25_CSD0_BASE_ADDR, 64 * 1024 * 1024);
-
- return 0;
-}
-mem_initcall(eukrea_cpuimx25_mem_init);
-
static iomux_v3_cfg_t eukrea_cpuimx25_pads[] = {
MX25_PAD_FEC_MDC__FEC_MDC,
MX25_PAD_FEC_MDIO__FEC_MDIO,
diff --git a/arch/arm/boards/eukrea_cpuimx27/eukrea_cpuimx27.c b/arch/arm/boards/eukrea_cpuimx27/eukrea_cpuimx27.c
index c89ce8a..498e9b4 100644
--- a/arch/arm/boards/eukrea_cpuimx27/eukrea_cpuimx27.c
+++ b/arch/arm/boards/eukrea_cpuimx27/eukrea_cpuimx27.c
@@ -46,12 +46,6 @@
#include <mach/iomux-mx27.h>
#include <mach/devices-imx27.h>
-#if defined CONFIG_EUKREA_CPUIMX27_SDRAM_256MB
-#define SDRAM0 256
-#elif defined CONFIG_EUKREA_CPUIMX27_SDRAM_128MB
-#define SDRAM0 128
-#endif
-
static struct fec_platform_data fec_info = {
.xcv_type = MII100,
.phy_addr = 1,
@@ -86,14 +80,6 @@ static struct i2c_board_info i2c_devices[] = {
},
};
-static int eukrea_cpuimx27_mem_init(void)
-{
- arm_add_mem_device("ram0", 0xa0000000, SDRAM0 * 1024 * 1024);
-
- return 0;
-}
-mem_initcall(eukrea_cpuimx27_mem_init);
-
#ifdef CONFIG_DRIVER_VIDEO_IMX
static struct imx_fb_videomode imxfb_mode = {
.mode = {
diff --git a/arch/arm/boards/eukrea_cpuimx35/eukrea_cpuimx35.c b/arch/arm/boards/eukrea_cpuimx35/eukrea_cpuimx35.c
index fdbc26a..2c96007 100644
--- a/arch/arm/boards/eukrea_cpuimx35/eukrea_cpuimx35.c
+++ b/arch/arm/boards/eukrea_cpuimx35/eukrea_cpuimx35.c
@@ -122,14 +122,6 @@ static struct fsl_usb2_platform_data usb_pdata = {
};
#endif
-static int eukrea_cpuimx35_mem_init(void)
-{
- arm_add_mem_device("ram0", MX35_CSD0_BASE_ADDR, 128 * 1024 * 1024);
-
- return 0;
-}
-mem_initcall(eukrea_cpuimx35_mem_init);
-
static int eukrea_cpuimx35_mmu_init(void)
{
l2x0_init((void __iomem *)0x30000000, 0x00030024, 0x00000000);
diff --git a/arch/arm/boards/eukrea_cpuimx51/eukrea_cpuimx51.c b/arch/arm/boards/eukrea_cpuimx51/eukrea_cpuimx51.c
index ab0ff81..fdbd051 100644
--- a/arch/arm/boards/eukrea_cpuimx51/eukrea_cpuimx51.c
+++ b/arch/arm/boards/eukrea_cpuimx51/eukrea_cpuimx51.c
@@ -103,14 +103,6 @@ static iomux_v3_cfg_t eukrea_cpuimx51_pads[] = {
#define GPIO_LAN8700_RESET (1 * 32 + 31)
#define GPIO_LCD_BL (2 * 32 + 4)
-static int eukrea_cpuimx51_mem_init(void)
-{
- arm_add_mem_device("ram0", 0x90000000, 256 * 1024 * 1024);
-
- return 0;
-}
-mem_initcall(eukrea_cpuimx51_mem_init);
-
static int eukrea_cpuimx51_devices_init(void)
{
imx51_add_fec(&fec_info);
diff --git a/arch/arm/boards/freescale-mx25-3-stack/3stack.c b/arch/arm/boards/freescale-mx25-3-stack/3stack.c
index 5ce2f8e..1271ad9 100644
--- a/arch/arm/boards/freescale-mx25-3-stack/3stack.c
+++ b/arch/arm/boards/freescale-mx25-3-stack/3stack.c
@@ -186,22 +186,6 @@ static int imx25_3ds_fec_init(void)
}
late_initcall(imx25_3ds_fec_init);
-static int imx25_mem_init(void)
-{
-#if defined CONFIG_FREESCALE_MX25_3STACK_SDRAM_64MB_DDR2
-#define SDRAM_SIZE 64 * 1024 * 1024
-#elif defined CONFIG_FREESCALE_MX25_3STACK_SDRAM_128MB_MDDR
-#define SDRAM_SIZE 128 * 1024 * 1024
-#else
-#error "Unsupported SDRAM type"
-#endif
- arm_add_mem_device("ram0", MX25_CSD0_BASE_ADDR, SDRAM_SIZE);
- add_mem_device("sram0", 0x78000000, 128 * 1024, IORESOURCE_MEM_WRITEABLE);
-
- return 0;
-}
-mem_initcall(imx25_mem_init);
-
static int imx25_devices_init(void)
{
#ifdef CONFIG_USB
@@ -215,6 +199,8 @@ static int imx25_devices_init(void)
imx25_iim_register_fec_ethaddr();
imx25_add_fec(&fec_info);
+ add_mem_device("sram0", 0x78000000, 128 * 1024, IORESOURCE_MEM_WRITEABLE);
+
if (readl(MX25_CCM_BASE_ADDR + MX25_CCM_RCSR) & (1 << 14))
nand_info.width = 2;
diff --git a/arch/arm/boards/freescale-mx35-3-stack/3stack.c b/arch/arm/boards/freescale-mx35-3-stack/3stack.c
index 7da031a..3128d4f 100644
--- a/arch/arm/boards/freescale-mx35-3-stack/3stack.c
+++ b/arch/arm/boards/freescale-mx35-3-stack/3stack.c
@@ -128,15 +128,6 @@ static void set_board_rev(int rev)
imx35_3ds_system_rev = (imx35_3ds_system_rev & ~(0xF << 8)) | (rev & 0xF) << 8;
}
-static int f3s_mem_init(void)
-{
- arm_add_mem_device("ram0", MX35_CSD0_BASE_ADDR, 128 * 1024 * 1024);
- arm_add_mem_device("ram1", MX35_CSD1_BASE_ADDR, 128 * 1024 * 1024);
-
- return 0;
-}
-mem_initcall(f3s_mem_init);
-
static int f3s_devices_init(void)
{
uint32_t reg;
diff --git a/arch/arm/boards/freescale-mx51-pdk/board.c b/arch/arm/boards/freescale-mx51-pdk/board.c
index 9db0ed9..cb190ef 100644
--- a/arch/arm/boards/freescale-mx51-pdk/board.c
+++ b/arch/arm/boards/freescale-mx51-pdk/board.c
@@ -97,14 +97,6 @@ static iomux_v3_cfg_t f3s_pads[] = {
MX51_PAD_GPIO1_5__GPIO1_5,
};
-static int babbage_mem_init(void)
-{
- arm_add_mem_device("ram0", 0x90000000, 512 * 1024 * 1024);
-
- return 0;
-}
-mem_initcall(babbage_mem_init);
-
#define BABBAGE_ECSPI1_CS0 (3 * 32 + 24)
static int spi_0_cs[] = {BABBAGE_ECSPI1_CS0};
diff --git a/arch/arm/boards/freescale-mx53-loco/board.c b/arch/arm/boards/freescale-mx53-loco/board.c
index 216d26a..38ece23 100644
--- a/arch/arm/boards/freescale-mx53-loco/board.c
+++ b/arch/arm/boards/freescale-mx53-loco/board.c
@@ -133,15 +133,6 @@ static void set_board_rev(int rev)
loco_system_rev = (loco_system_rev & ~(0xF << 8)) | (rev & 0xF) << 8;
}
-static int loco_mem_init(void)
-{
- arm_add_mem_device("ram0", 0x70000000, SZ_512M);
- arm_add_mem_device("ram1", 0xb0000000, SZ_512M);
-
- return 0;
-}
-mem_initcall(loco_mem_init);
-
#define LOCO_FEC_PHY_RST IMX_GPIO_NR(7, 6)
static void loco_fec_reset(void)
diff --git a/arch/arm/boards/freescale-mx53-smd/board.c b/arch/arm/boards/freescale-mx53-smd/board.c
index a5ad009..64ba7f2 100644
--- a/arch/arm/boards/freescale-mx53-smd/board.c
+++ b/arch/arm/boards/freescale-mx53-smd/board.c
@@ -98,15 +98,6 @@ static iomux_v3_cfg_t smd_pads[] = {
MX53_PAD_PATA_RESET_B__ESDHC3_CMD,
};
-static int smd_mem_init(void)
-{
- arm_add_mem_device("ram0", 0x70000000, SZ_512M);
- arm_add_mem_device("ram1", 0xb0000000, SZ_512M);
-
- return 0;
-}
-mem_initcall(smd_mem_init);
-
#define SMD_FEC_PHY_RST IMX_GPIO_NR(7, 6)
static void smd_fec_reset(void)
diff --git a/arch/arm/boards/guf-cupid/board.c b/arch/arm/boards/guf-cupid/board.c
index 5b17326..839b415 100644
--- a/arch/arm/boards/guf-cupid/board.c
+++ b/arch/arm/boards/guf-cupid/board.c
@@ -94,14 +94,6 @@ static struct imx_ipu_fb_platform_data ipu_fb_data = {
.enable = cupid_fb_enable,
};
-static int cupid_mem_init(void)
-{
- arm_add_mem_device("ram0", MX35_CSD0_BASE_ADDR, 128 * 1024 * 1024);
-
- return 0;
-}
-mem_initcall(cupid_mem_init);
-
static int cupid_mmu_init(void)
{
l2x0_init((void __iomem *)0x30000000, 0x00030024, 0x00000000);
diff --git a/arch/arm/boards/guf-neso/board.c b/arch/arm/boards/guf-neso/board.c
index 200a2ef..086d96b 100644
--- a/arch/arm/boards/guf-neso/board.c
+++ b/arch/arm/boards/guf-neso/board.c
@@ -133,14 +133,6 @@ static void neso_usbh_init(void)
}
#endif
-static int neso_mem_init(void)
-{
- arm_add_mem_device("ram0", 0xa0000000, 128 * 1024 * 1024);
-
- return 0;
-}
-mem_initcall(neso_mem_init);
-
static int neso_devices_init(void)
{
int i;
diff --git a/arch/arm/boards/imx27ads/imx27ads.c b/arch/arm/boards/imx27ads/imx27ads.c
index f41b155..d07d553 100644
--- a/arch/arm/boards/imx27ads/imx27ads.c
+++ b/arch/arm/boards/imx27ads/imx27ads.c
@@ -65,14 +65,6 @@ static int imx27ads_timing_init(void)
core_initcall(imx27ads_timing_init);
-static int mx27ads_mem_init(void)
-{
- arm_add_mem_device("ram0", 0xa0000000, 128 * 1024 * 1024);
-
- return 0;
-}
-mem_initcall(mx27ads_mem_init);
-
static int mx27ads_devices_init(void)
{
int i;
diff --git a/arch/arm/boards/karo-tx25/board.c b/arch/arm/boards/karo-tx25/board.c
index 1ffd890..98140b3 100644
--- a/arch/arm/boards/karo-tx25/board.c
+++ b/arch/arm/boards/karo-tx25/board.c
@@ -50,17 +50,6 @@ struct imx_nand_platform_data nand_info = {
.flash_bbt = 1,
};
-static int tx25_mem_init(void)
-{
- arm_add_mem_device("ram0", MX25_CSD0_BASE_ADDR, 32 * 1024 * 1024);
- arm_add_mem_device("ram0", MX25_CSD1_BASE_ADDR, 32 * 1024 * 1024);
- add_mem_device("ram0", 0x78000000, 128 * 1024,
- IORESOURCE_MEM_WRITEABLE);
-
- return 0;
-}
-mem_initcall(tx25_mem_init);
-
static iomux_v3_cfg_t karo_tx25_padsd_fec[] = {
MX25_PAD_D11__GPIO_4_9, /* FEC PHY power on pin */
MX25_PAD_D13__GPIO_4_7, /* FEC reset */
@@ -119,6 +108,9 @@ static int tx25_devices_init(void)
devfs_add_partition("nand0", 0x40000, 0x80000, DEVFS_PARTITION_FIXED, "env_raw");
dev_add_bb_dev("env_raw", "env0");
+ add_mem_device("sram0", 0x78000000, 128 * 1024,
+ IORESOURCE_MEM_WRITEABLE);
+
armlinux_set_bootparams((void *)0x80000100);
armlinux_set_architecture(MACH_TYPE_TX25);
armlinux_set_serial(imx_uid());
diff --git a/arch/arm/boards/karo-tx51/tx51.c b/arch/arm/boards/karo-tx51/tx51.c
index dd377c1..6c2b14b 100644
--- a/arch/arm/boards/karo-tx51/tx51.c
+++ b/arch/arm/boards/karo-tx51/tx51.c
@@ -112,14 +112,6 @@ static iomux_v3_cfg_t tx51_pads[] = {
MX51_PAD_GPIO1_0__GPIO1_0,
};
-static int tx51_mem_init(void)
-{
- arm_add_mem_device("ram0", MX51_CSD0_BASE_ADDR, 128 * 1024 * 1024);
-
- return 0;
-}
-mem_initcall(tx51_mem_init);
-
static int spi_0_cs[] = {
IMX_GPIO_NR(4, 24),
IMX_GPIO_NR(4, 25),
diff --git a/arch/arm/boards/karo-tx53/board.c b/arch/arm/boards/karo-tx53/board.c
index 8f87c9c..581b6fa 100644
--- a/arch/arm/boards/karo-tx53/board.c
+++ b/arch/arm/boards/karo-tx53/board.c
@@ -99,17 +99,6 @@ static iomux_v3_cfg_t tx53_pads[] = {
MX53_PAD_CSI0_PIXCLK__IPU_CSI0_PIXCLK,
};
-static int tx53_mem_init(void)
-{
- if (IS_ENABLED(CONFIG_TX53_REV_1011))
- arm_add_mem_device("ram0", 0x70000000, SZ_1G);
- else
- arm_add_mem_device("ram0", 0x70000000, SZ_512M);
-
- return 0;
-}
-mem_initcall(tx53_mem_init);
-
#define TX53_SD1_CD IMX_GPIO_NR(3, 24)
static struct esdhc_platform_data tx53_sd1_data = {
diff --git a/arch/arm/boards/pcm037/pcm037.c b/arch/arm/boards/pcm037/pcm037.c
index ff4089a..ff32e35 100644
--- a/arch/arm/boards/pcm037/pcm037.c
+++ b/arch/arm/boards/pcm037/pcm037.c
@@ -145,17 +145,6 @@ static void pcm037_usb_init(void)
}
#endif
-static int pcm037_mem_init(void)
-{
- arm_add_mem_device("ram0", MX31_CSD0_BASE_ADDR, SDRAM0 * 1024 * 1024);
-#ifndef CONFIG_PCM037_SDRAM_BANK1_NONE
- arm_add_mem_device("ram1", MX31_CSD1_BASE_ADDR, SDRAM1 * 1024 * 1024);
-#endif
-
- return 0;
-}
-mem_initcall(pcm037_mem_init);
-
static int pcm037_mmu_init(void)
{
l2x0_init((void __iomem *)0x30000000, 0x00030024, 0x00000000);
diff --git a/arch/arm/boards/pcm038/pcm038.c b/arch/arm/boards/pcm038/pcm038.c
index 715d604..ea50a78 100644
--- a/arch/arm/boards/pcm038/pcm038.c
+++ b/arch/arm/boards/pcm038/pcm038.c
@@ -180,16 +180,6 @@ static int pcm038_power_init(void)
return 0;
}
-static int pcm038_mem_init(void)
-{
- arm_add_mem_device("ram0", 0xa0000000, 128 * 1024 * 1024);
-
- add_mem_device("ram1", 0xc8000000, 512 * 1024, /* Can be up to 2MiB */
- IORESOURCE_MEM_WRITEABLE);
- return 0;
-}
-mem_initcall(pcm038_mem_init);
-
static int pcm038_devices_init(void)
{
int i;
@@ -279,6 +269,10 @@ static int pcm038_devices_init(void)
/* configure SRAM on cs1 */
imx27_setup_weimcs(1, 0x0000d843, 0x22252521, 0x22220a00);
+ /* Can be up to 2MiB */
+ add_mem_device("ram1", 0xc8000000, 512 * 1024,
+ IORESOURCE_MEM_WRITEABLE);
+
/* initizalize gpios */
for (i = 0; i < ARRAY_SIZE(mode); i++)
imx_gpio_mode(mode[i]);
diff --git a/arch/arm/boards/pcm043/pcm043.c b/arch/arm/boards/pcm043/pcm043.c
index abfeaf1..95da8f0 100644
--- a/arch/arm/boards/pcm043/pcm043.c
+++ b/arch/arm/boards/pcm043/pcm043.c
@@ -98,14 +98,6 @@ static struct imx_ipu_fb_platform_data ipu_fb_data = {
.bpp = 16,
};
-static int pcm043_mem_init(void)
-{
- arm_add_mem_device("ram0", MX35_CSD0_BASE_ADDR, SZ_128M);
-
- return 0;
-}
-mem_initcall(pcm043_mem_init);
-
static int pcm043_mmu_init(void)
{
l2x0_init((void __iomem *)0x30000000, 0x00030024, 0x00000000);
diff --git a/arch/arm/boards/phycard-i.MX27/pca100.c b/arch/arm/boards/phycard-i.MX27/pca100.c
index 0b66b04..1a21c8a 100644
--- a/arch/arm/boards/phycard-i.MX27/pca100.c
+++ b/arch/arm/boards/phycard-i.MX27/pca100.c
@@ -143,14 +143,6 @@ static void pca100_usb_register(void)
}
#endif
-static int pca100_mem_init(void)
-{
- arm_add_mem_device("ram0", 0xa0000000, 128 * 1024 * 1024);
-
- return 0;
-}
-mem_initcall(pca100_mem_init);
-
static void pca100_usb_init(void)
{
u32 reg;
diff --git a/arch/arm/boards/scb9328/scb9328.c b/arch/arm/boards/scb9328/scb9328.c
index c70852c..d91b21d 100644
--- a/arch/arm/boards/scb9328/scb9328.c
+++ b/arch/arm/boards/scb9328/scb9328.c
@@ -48,14 +48,6 @@ struct gpio_led leds[] = {
},
};
-static int scb9328_mem_init(void)
-{
- arm_add_mem_device("ram0", 0x08000000, 16 * 1024 * 1024);
-
- return 0;
-}
-mem_initcall(scb9328_mem_init);
-
static int scb9328_devices_init(void)
{
int i;
diff --git a/arch/arm/boards/tqma53/board.c b/arch/arm/boards/tqma53/board.c
index 77535b5..03cb8ea 100644
--- a/arch/arm/boards/tqma53/board.c
+++ b/arch/arm/boards/tqma53/board.c
@@ -207,17 +207,6 @@ static iomux_v3_cfg_t tqma53_pads[] = {
#define GPIO_FEC_NRESET IMX_GPIO_NR(7, 6)
-static int tqma53_mem_init(void)
-{
- arm_add_mem_device("ram0", 0x70000000, SZ_512M);
-#ifdef CONFIG_MACH_TQMA53_1GB_RAM
- arm_add_mem_device("ram1", 0xb0000000, SZ_512M);
-#endif
-
- return 0;
-}
-mem_initcall(tqma53_mem_init);
-
#define GPIO_SD2_CD IMX_GPIO_NR(1, 4)
#define GPIO_SD2_WP IMX_GPIO_NR(1, 2)
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 4+ messages in thread