]> git.sur5r.net Git - u-boot/commitdiff
arm: at91: mpddr: allow multiple DDR controllers
authorErik van Luijk <evanluijk@interact.nl>
Thu, 13 Aug 2015 13:43:18 +0000 (15:43 +0200)
committerAndreas Bießmann <andreas.devel@googlemail.com>
Fri, 21 Aug 2015 13:47:02 +0000 (15:47 +0200)
The mpddr.c depends on ATMEL_BASE_MPDDRC for the base address to configure the controller.
This cannot be used when there is more than one controller (i.e. AT91SAM9G45, AT91SAM9M10).

Signed-off-by: Erik van Luijk <evanluijk@interact.nl>
[remove 'new blank line at EOF']
Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com>
14 files changed:
arch/arm/mach-at91/include/mach/atmel_mpddrc.h
arch/arm/mach-at91/mpddrc.c
board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c
board/atmel/at91sam9n12ek/at91sam9n12ek.c
board/atmel/at91sam9x5ek/at91sam9x5ek.c
board/atmel/sama5d3_xplained/sama5d3_xplained.c
board/atmel/sama5d3xek/sama5d3xek.c
board/atmel/sama5d4_xplained/sama5d4_xplained.c
board/atmel/sama5d4ek/sama5d4ek.c
board/siemens/corvus/board.c
include/configs/at91sam9m10g45ek.h
include/configs/at91sam9n12ek.h
include/configs/at91sam9x5ek.h
include/configs/corvus.h

index 130a85abeea581eecb60f71defc8cc6fcd4ce494..c6c8dda803e9ac1499f86e7a11894ec449351147 100644 (file)
@@ -23,8 +23,10 @@ struct atmel_mpddr {
        u32 md;
 };
 
-int ddr2_init(const unsigned int ram_address,
-              const struct atmel_mpddr *mpddr);
+
+int ddr2_init(const unsigned int base,
+             const unsigned int ram_address,
+             const struct atmel_mpddr *mpddr);
 
 /* Bit field in mode register */
 #define ATMEL_MPDDRC_MR_MODE_NORMAL_CMD                0x0
index e2b6a49eb92f1d7996f9c691ca7af22ed403a139..47e6e5a3cdc4290265b020fdcebab73d06aae9a7 100644 (file)
@@ -9,10 +9,10 @@
 #include <asm/io.h>
 #include <asm/arch/atmel_mpddrc.h>
 
-static inline void atmel_mpddr_op(int mode, u32 ram_address)
+static inline void atmel_mpddr_op(const struct atmel_mpddr *mpddr,
+             int mode,
+             u32 ram_address)
 {
-       struct atmel_mpddr *mpddr = (struct atmel_mpddr *)ATMEL_BASE_MPDDRC;
-
        writel(mode, &mpddr->mr);
        writel(0, ram_address);
 }
@@ -27,10 +27,13 @@ static int ddr2_decodtype_is_seq(u32 cr)
        return 1;
 }
 
-int ddr2_init(const unsigned int ram_address,
+
+int ddr2_init(const unsigned int base,
+             const unsigned int ram_address,
              const struct atmel_mpddr *mpddr_value)
 {
-       struct atmel_mpddr *mpddr = (struct atmel_mpddr *)ATMEL_BASE_MPDDRC;
+       const struct atmel_mpddr *mpddr = (struct atmel_mpddr *)base;
+
        u32 ba_off, cr;
 
        /* Compute bank offset according to NC in configuration register */
@@ -52,30 +55,30 @@ int ddr2_init(const unsigned int ram_address,
        writel(mpddr_value->tpr2, &mpddr->tpr2);
 
        /* Issue a NOP command */
-       atmel_mpddr_op(ATMEL_MPDDRC_MR_MODE_NOP_CMD, ram_address);
+       atmel_mpddr_op(mpddr, ATMEL_MPDDRC_MR_MODE_NOP_CMD, ram_address);
 
        /* A 200 us is provided to precede any signal toggle */
        udelay(200);
 
        /* Issue a NOP command */
-       atmel_mpddr_op(ATMEL_MPDDRC_MR_MODE_NOP_CMD, ram_address);
+       atmel_mpddr_op(mpddr, ATMEL_MPDDRC_MR_MODE_NOP_CMD, ram_address);
 
        /* Issue an all banks precharge command */
-       atmel_mpddr_op(ATMEL_MPDDRC_MR_MODE_PRCGALL_CMD, ram_address);
+       atmel_mpddr_op(mpddr, ATMEL_MPDDRC_MR_MODE_PRCGALL_CMD, ram_address);
 
        /* Issue an extended mode register set(EMRS2) to choose operation */
-       atmel_mpddr_op(ATMEL_MPDDRC_MR_MODE_EXT_LMR_CMD,
+       atmel_mpddr_op(mpddr, ATMEL_MPDDRC_MR_MODE_EXT_LMR_CMD,
                       ram_address + (0x2 << ba_off));
 
        /* Issue an extended mode register set(EMRS3) to set EMSR to 0 */
-       atmel_mpddr_op(ATMEL_MPDDRC_MR_MODE_EXT_LMR_CMD,
+       atmel_mpddr_op(mpddr, ATMEL_MPDDRC_MR_MODE_EXT_LMR_CMD,
                       ram_address + (0x3 << ba_off));
 
        /*
         * Issue an extended mode register set(EMRS1) to enable DLL and
         * program D.I.C (output driver impedance control)
         */
-       atmel_mpddr_op(ATMEL_MPDDRC_MR_MODE_EXT_LMR_CMD,
+       atmel_mpddr_op(mpddr, ATMEL_MPDDRC_MR_MODE_EXT_LMR_CMD,
                       ram_address + (0x1 << ba_off));
 
        /* Enable DLL reset */
@@ -83,21 +86,21 @@ int ddr2_init(const unsigned int ram_address,
        writel(cr | ATMEL_MPDDRC_CR_DLL_RESET_ENABLED, &mpddr->cr);
 
        /* A mode register set(MRS) cycle is issued to reset DLL */
-       atmel_mpddr_op(ATMEL_MPDDRC_MR_MODE_LMR_CMD, ram_address);
+       atmel_mpddr_op(mpddr, ATMEL_MPDDRC_MR_MODE_LMR_CMD, ram_address);
 
        /* Issue an all banks precharge command */
-       atmel_mpddr_op(ATMEL_MPDDRC_MR_MODE_PRCGALL_CMD, ram_address);
+       atmel_mpddr_op(mpddr, ATMEL_MPDDRC_MR_MODE_PRCGALL_CMD, ram_address);
 
        /* Two auto-refresh (CBR) cycles are provided */
-       atmel_mpddr_op(ATMEL_MPDDRC_MR_MODE_RFSH_CMD, ram_address);
-       atmel_mpddr_op(ATMEL_MPDDRC_MR_MODE_RFSH_CMD, ram_address);
+       atmel_mpddr_op(mpddr, ATMEL_MPDDRC_MR_MODE_RFSH_CMD, ram_address);
+       atmel_mpddr_op(mpddr, ATMEL_MPDDRC_MR_MODE_RFSH_CMD, ram_address);
 
        /* Disable DLL reset */
        cr = readl(&mpddr->cr);
        writel(cr & (~ATMEL_MPDDRC_CR_DLL_RESET_ENABLED), &mpddr->cr);
 
        /* A mode register set (MRS) cycle is issued to disable DLL reset */
-       atmel_mpddr_op(ATMEL_MPDDRC_MR_MODE_LMR_CMD, ram_address);
+       atmel_mpddr_op(mpddr, ATMEL_MPDDRC_MR_MODE_LMR_CMD, ram_address);
 
        /* Set OCD calibration in default state */
        cr = readl(&mpddr->cr);
@@ -107,7 +110,7 @@ int ddr2_init(const unsigned int ram_address,
         * An extended mode register set (EMRS1) cycle is issued
         * to OCD default value
         */
-       atmel_mpddr_op(ATMEL_MPDDRC_MR_MODE_EXT_LMR_CMD,
+       atmel_mpddr_op(mpddr, ATMEL_MPDDRC_MR_MODE_EXT_LMR_CMD,
                       ram_address + (0x1 << ba_off));
 
         /* OCD calibration mode exit */
@@ -118,11 +121,11 @@ int ddr2_init(const unsigned int ram_address,
         * An extended mode register set (EMRS1) cycle is issued
         * to enable OCD exit
         */
-       atmel_mpddr_op(ATMEL_MPDDRC_MR_MODE_EXT_LMR_CMD,
+       atmel_mpddr_op(mpddr, ATMEL_MPDDRC_MR_MODE_EXT_LMR_CMD,
                       ram_address + (0x1 << ba_off));
 
        /* A nornal mode command is provided */
-       atmel_mpddr_op(ATMEL_MPDDRC_MR_MODE_NORMAL_CMD, ram_address);
+       atmel_mpddr_op(mpddr, ATMEL_MPDDRC_MR_MODE_NORMAL_CMD, ram_address);
 
        /* Perform a write access to any DDR2-SDRAM address */
        writel(0, ram_address);
index 4289179ee667c4a1aedbf9756de182dacaf88afd..3e65d711c0cc30dcd04b15b055cec67f70fb8810 100644 (file)
@@ -147,7 +147,7 @@ void mem_init(void)
        writel(csa, &mat->ebicsa);
 
        /* DDRAM2 Controller initialize */
-       ddr2_init(ATMEL_BASE_CS6, &ddr2);
+       ddr2_init(ATMEL_BASE_DDRSDRC0, ATMEL_BASE_CS6, &ddr2);
 }
 #endif
 
index 4f46a0353338be729a01b6d2d71994449bf0214c..8437f37d33e3b6d4d2d206c3b1f0f7f76b903256 100644 (file)
@@ -327,6 +327,6 @@ void mem_init(void)
        writel(csa, &matrix->ebicsa);
 
        /* DDRAM2 Controller initialize */
-       ddr2_init(ATMEL_BASE_CS1, &ddr2);
+       ddr2_init(ATMEL_BASE_DDRSDRC, ATMEL_BASE_CS1, &ddr2);
 }
 #endif
index 114ac5c85abafc6429e86267ca792767e701a45f..0455e2cb3078c0d3c4d7cc8a6b6e73507583bfe8 100644 (file)
@@ -364,6 +364,6 @@ void mem_init(void)
        writel(csa, &matrix->ebicsa);
 
        /* DDRAM2 Controller initialize */
-       ddr2_init(ATMEL_BASE_CS1, &ddr2);
+       ddr2_init(ATMEL_BASE_DDRSDRC, ATMEL_BASE_CS1, &ddr2);
 }
 #endif
index 92ed4e81d3902ea5b8c53107e6ac833b5693c967..0793e4aaba5295029e9a9b63f45a22d36722def3 100644 (file)
@@ -194,7 +194,7 @@ void mem_init(void)
        writel(0x4, &pmc->scer);
 
        /* DDRAM2 Controller initialize */
-       ddr2_init(ATMEL_BASE_DDRCS, &ddr2);
+       ddr2_init(ATMEL_BASE_MPDDRC, ATMEL_BASE_DDRCS, &ddr2);
 }
 
 void at91_pmc_init(void)
index cf6ed8b94c303d203ad53667ab6716496a481e8b..d6e7e163bdffc0b1a75c9c6de332381869b9c974 100644 (file)
@@ -433,7 +433,7 @@ void mem_init(void)
        writel(0x4, &pmc->scer);
 
        /* DDRAM2 Controller initialize */
-       ddr2_init(ATMEL_BASE_DDRCS, &ddr2);
+       ddr2_init(ATMEL_BASE_MPDDRC, ATMEL_BASE_DDRCS, &ddr2);
 }
 
 void at91_pmc_init(void)
index 7d447fe76b241b7a621fe1b985b67f0e1387d189..71ec4b7471db4237167f9c7479e79a17889a0cf0 100644 (file)
@@ -393,7 +393,7 @@ void mem_init(void)
        writel(0x4, &pmc->scer);
 
        /* DDRAM2 Controller initialize */
-       ddr2_init(ATMEL_BASE_DDRCS, &ddr2);
+       ddr2_init(ATMEL_BASE_MPDDRC, ATMEL_BASE_DDRCS, &ddr2);
 }
 
 void at91_pmc_init(void)
index e9bbb4b1c81521d13945997ded556535838bdb04..de4291f94a78a1aaf2d1bfed70d281cdebae3bd7 100644 (file)
@@ -389,7 +389,7 @@ void mem_init(void)
        writel(0x4, &pmc->scer);
 
        /* DDRAM2 Controller initialize */
-       ddr2_init(ATMEL_BASE_DDRCS, &ddr2);
+       ddr2_init(ATMEL_BASE_MPDDRC, ATMEL_BASE_DDRCS, &ddr2);
 }
 
 void at91_pmc_init(void)
index f3f6dae459af3ba6a74bfa49e544a73106db6b3f..9001fcbcf50ef0fea76fabbf6cab30c15ed6b8cc 100644 (file)
@@ -160,7 +160,7 @@ void mem_init(void)
        writel(csa, &mat->ebicsa);
 
        /* DDRAM2 Controller initialize */
-       ddr2_init(ATMEL_BASE_CS6, &ddr2);
+       ddr2_init(ATMEL_BASE_DDRSDRC0, ATMEL_BASE_CS6, &ddr2);
 }
 #endif
 
index 4d9020975ef9f819f5c39f6a40b7b2ec58a9688d..2f6a3a57b49bb5b24a2806c45a99e960c4db53a5 100644 (file)
 #define CONFIG_SYS_MCKR                        0x1301
 #define CONFIG_SYS_MCKR_CSS            0x1302
 
-#define ATMEL_BASE_MPDDRC              ATMEL_BASE_DDRSDRC0
 #endif
index ea0a94bcde32b3d61c9ef01fd17410ef8753aecf..acdd63e758f7df743d9905fac0e927ebc1da8157 100644 (file)
 #define CONFIG_SYS_MCKR                        0x1301
 #define CONFIG_SYS_MCKR_CSS            0x1302
 
-#define ATMEL_BASE_MPDDRC              ATMEL_BASE_DDRSDRC
-
 #ifdef CONFIG_SYS_USE_MMC
 #define CONFIG_SPL_LDSCRIPT            arch/arm/mach-at91/arm926ejs/u-boot-spl.lds
 #define CONFIG_SPL_MMC_SUPPORT
index 9f767862021dad2bd82b77c24d87de623df6cab6..fbb584d9bf3c047dbfc566cd0cc734902257dc4d 100644 (file)
 #define CONFIG_SYS_MCKR                        0x1301
 #define CONFIG_SYS_MCKR_CSS            0x1302
 
-#define ATMEL_BASE_MPDDRC              ATMEL_BASE_DDRSDRC
-
 #ifdef CONFIG_SYS_USE_MMC
 #define CONFIG_SPL_LDSCRIPT            arch/arm/mach-at91/arm926ejs/u-boot-spl.lds
 #define CONFIG_SPL_MMC_SUPPORT
index 2d2f3c11aafd7337cc244bd8f49c4bca0c0cce47..c91e289da8d9b2893bfc7e4ce238e7a100413f33 100644 (file)
 #define CONFIG_SYS_MCKR                        0x1301
 #define CONFIG_SYS_MCKR_CSS            0x1302
 
-#define ATMEL_BASE_MPDDRC              ATMEL_BASE_DDRSDRC0
-
 #endif