]> git.sur5r.net Git - u-boot/commitdiff
ARM: keystone: aemif: move aemif driver to drivers/memory/ti-aemif.c
authorKhoronzhuk, Ivan <ivan.khoronzhuk@ti.com>
Sat, 7 Jun 2014 02:10:49 +0000 (05:10 +0300)
committerTom Rini <trini@ti.com>
Thu, 19 Jun 2014 21:53:58 +0000 (17:53 -0400)
Move AEMIF driver to drivers/memory/ti-aemif.c along with AEMIF
definitions collected in arch/arm/include/asm/ti-common/ti-aemif.h

Acked-by: Vitaly Andrianov <vitalya@ti.com>
Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@ti.com>
arch/arm/cpu/armv7/keystone/Makefile
arch/arm/cpu/armv7/keystone/aemif.c [deleted file]
arch/arm/include/asm/arch-keystone/hardware-k2hk.h
arch/arm/include/asm/arch-keystone/hardware.h
arch/arm/include/asm/ti-common/ti-aemif.h [new file with mode: 0644]
board/ti/k2hk_evm/board.c
drivers/Makefile
drivers/memory/Makefile [new file with mode: 0644]
drivers/memory/ti-aemif.c [new file with mode: 0644]
include/configs/k2hk_evm.h

index b1bd0224eae39d29f11ed5e7de0d8e0577e0228f..c4af25211027a56f1adb332e3b71dc999b1c1c60 100644 (file)
@@ -5,7 +5,6 @@
 # SPDX-License-Identifier:     GPL-2.0+
 #
 
-obj-y  += aemif.o
 obj-y  += init.o
 obj-y  += psc.o
 obj-y  += clock.o
diff --git a/arch/arm/cpu/armv7/keystone/aemif.c b/arch/arm/cpu/armv7/keystone/aemif.c
deleted file mode 100644 (file)
index bcbb95a..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Keystone2: Asynchronous EMIF Configuration
- *
- * (C) Copyright 2012-2014
- *     Texas Instruments Incorporated, <www.ti.com>
- *
- * SPDX-License-Identifier:     GPL-2.0+
- */
-
-#include <common.h>
-#include <asm/io.h>
-#include <asm/arch/clock.h>
-#include <asm/ti-common/davinci_nand.h>
-
-#define AEMIF_CFG_SELECT_STROBE(v)     ((v) ? 1 << 31 : 0)
-#define AEMIF_CFG_EXTEND_WAIT(v)       ((v) ? 1 << 30 : 0)
-#define AEMIF_CFG_WR_SETUP(v)          (((v) & 0x0f) << 26)
-#define AEMIF_CFG_WR_STROBE(v)         (((v) & 0x3f) << 20)
-#define AEMIF_CFG_WR_HOLD(v)           (((v) & 0x07) << 17)
-#define AEMIF_CFG_RD_SETUP(v)          (((v) & 0x0f) << 13)
-#define AEMIF_CFG_RD_STROBE(v)         (((v) & 0x3f) << 7)
-#define AEMIF_CFG_RD_HOLD(v)           (((v) & 0x07) << 4)
-#define AEMIF_CFG_TURN_AROUND(v)       (((v) & 0x03) << 2)
-#define AEMIF_CFG_WIDTH(v)             (((v) & 0x03) << 0)
-
-#define set_config_field(reg, field, val)                      \
-       do {                                                    \
-               if (val != -1) {                                \
-                       reg &= ~AEMIF_CFG_##field(0xffffffff);  \
-                       reg |=  AEMIF_CFG_##field(val);         \
-               }                                               \
-       } while (0)
-
-void configure_async_emif(int cs, struct async_emif_config *cfg)
-{
-       unsigned long tmp;
-
-       if (cfg->mode == ASYNC_EMIF_MODE_NAND) {
-               tmp = __raw_readl(&davinci_emif_regs->nandfcr);
-               tmp |= (1 << cs);
-               __raw_writel(tmp, &davinci_emif_regs->nandfcr);
-
-       } else if (cfg->mode == ASYNC_EMIF_MODE_ONENAND) {
-               tmp = __raw_readl(&davinci_emif_regs->one_nand_cr);
-               tmp |= (1 << cs);
-               __raw_writel(tmp, &davinci_emif_regs->one_nand_cr);
-       }
-
-       tmp = __raw_readl(&davinci_emif_regs->abncr[cs]);
-
-       set_config_field(tmp, SELECT_STROBE,    cfg->select_strobe);
-       set_config_field(tmp, EXTEND_WAIT,      cfg->extend_wait);
-       set_config_field(tmp, WR_SETUP,         cfg->wr_setup);
-       set_config_field(tmp, WR_STROBE,        cfg->wr_strobe);
-       set_config_field(tmp, WR_HOLD,          cfg->wr_hold);
-       set_config_field(tmp, RD_SETUP,         cfg->rd_setup);
-       set_config_field(tmp, RD_STROBE,        cfg->rd_strobe);
-       set_config_field(tmp, RD_HOLD,          cfg->rd_hold);
-       set_config_field(tmp, TURN_AROUND,      cfg->turn_around);
-       set_config_field(tmp, WIDTH,            cfg->width);
-
-       __raw_writel(tmp, &davinci_emif_regs->abncr[cs]);
-}
-
-void init_async_emif(int num_cs, struct async_emif_config *config)
-{
-       int cs;
-
-       for (cs = 0; cs < num_cs; cs++)
-               configure_async_emif(cs, config + cs);
-}
index 7ac2662f1fb258fca83e873ef336d64d9e10a47b..50ce649d4c006b8b1c58d0831c4bb625f089883c 100644 (file)
@@ -9,13 +9,6 @@
 #ifndef __ASM_ARCH_HARDWARE_K2HK_H
 #define __ASM_ARCH_HARDWARE_K2HK_H
 
-#define K2HK_ASYNC_EMIF_CNTRL_BASE      0x21000a00
-#define DAVINCI_ASYNC_EMIF_CNTRL_BASE   K2HK_ASYNC_EMIF_CNTRL_BASE
-#define K2HK_ASYNC_EMIF_DATA_CE0_BASE   0x30000000
-#define K2HK_ASYNC_EMIF_DATA_CE1_BASE   0x34000000
-#define K2HK_ASYNC_EMIF_DATA_CE2_BASE   0x38000000
-#define K2HK_ASYNC_EMIF_DATA_CE3_BASE   0x3c000000
-
 #define K2HK_PLL_CNTRL_BASE             0x02310000
 #define CLOCK_BASE                      K2HK_PLL_CNTRL_BASE
 #define KS2_RSTCTRL                     (K2HK_PLL_CNTRL_BASE + 0xe8)
index 6c532ca8700bfffad852e90ea1eaf7064ffb1165..ffdecbfcd6d1cea690fd7e14af8521dcc093e283 100644 (file)
 typedef volatile unsigned int   dv_reg;
 typedef volatile unsigned int   *dv_reg_p;
 
-#define ASYNC_EMIF_NUM_CS               4
-#define ASYNC_EMIF_MODE_NOR             0
-#define ASYNC_EMIF_MODE_NAND            1
-#define ASYNC_EMIF_MODE_ONENAND         2
-#define ASYNC_EMIF_PRESERVE             -1
-
-struct async_emif_config {
-       unsigned mode;
-       unsigned select_strobe;
-       unsigned extend_wait;
-       unsigned wr_setup;
-       unsigned wr_strobe;
-       unsigned wr_hold;
-       unsigned rd_setup;
-       unsigned rd_strobe;
-       unsigned rd_hold;
-       unsigned turn_around;
-       enum {
-               ASYNC_EMIF_8    = 0,
-               ASYNC_EMIF_16   = 1,
-               ASYNC_EMIF_32   = 2,
-       } width;
-};
-
-void init_async_emif(int num_cs, struct async_emif_config *config);
-
 struct ddr3_phy_config {
        unsigned int pllcr;
        unsigned int pgcr1_mask;
@@ -145,6 +119,10 @@ struct ddr3_emif_config {
 #define KS2_UART0_BASE                 0x02530c00
 #define KS2_UART1_BASE                 0x02531000
 
+/* AEMIF */
+#define KS2_AEMIF_CNTRL_BASE           0x21000a00
+#define DAVINCI_ASYNC_EMIF_CNTRL_BASE   KS2_AEMIF_CNTRL_BASE
+
 #ifdef CONFIG_SOC_K2HK
 #include <asm/arch/hardware-k2hk.h>
 #endif
diff --git a/arch/arm/include/asm/ti-common/ti-aemif.h b/arch/arm/include/asm/ti-common/ti-aemif.h
new file mode 100644 (file)
index 0000000..4a311d4
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * AEMIF definitions
+ *
+ * (C) Copyright 2012-2014
+ *     Texas Instruments Incorporated, <www.ti.com>
+ *
+ * SPDX-License-Identifier:     GPL-2.0+
+ */
+
+#ifndef _AEMIF_H_
+#define _AEMIF_H_
+
+#define AEMIF_NUM_CS               4
+#define AEMIF_MODE_NOR             0
+#define AEMIF_MODE_NAND            1
+#define AEMIF_MODE_ONENAND         2
+#define AEMIF_PRESERVE             -1
+
+struct aemif_config {
+       unsigned mode;
+       unsigned select_strobe;
+       unsigned extend_wait;
+       unsigned wr_setup;
+       unsigned wr_strobe;
+       unsigned wr_hold;
+       unsigned rd_setup;
+       unsigned rd_strobe;
+       unsigned rd_hold;
+       unsigned turn_around;
+       enum {
+               AEMIF_WIDTH_8   = 0,
+               AEMIF_WIDTH_16  = 1,
+               AEMIF_WIDTH_32  = 2,
+       } width;
+};
+
+void aemif_init(int num_cs, struct aemif_config *config);
+
+#endif
index 53f26b2ef33328634716c01dcb787ce9eb267c66..ef90f9d821396c17c7702b39822646e58d9046fb 100644 (file)
@@ -18,6 +18,7 @@
 #include <asm/mach-types.h>
 #include <asm/arch/emac_defs.h>
 #include <asm/arch/psc_defs.h>
+#include <asm/ti-common/ti-aemif.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -39,9 +40,9 @@ unsigned int external_clk[ext_clk_count] = {
                                                what is that */
 };
 
-static struct async_emif_config async_emif_config[ASYNC_EMIF_NUM_CS] = {
+static struct aemif_config aemif_configs[] = {
        {                       /* CS0 */
-               .mode           = ASYNC_EMIF_MODE_NAND,
+               .mode           = AEMIF_MODE_NAND,
                .wr_setup       = 0xf,
                .wr_strobe      = 0x3f,
                .wr_hold        = 7,
@@ -49,7 +50,7 @@ static struct async_emif_config async_emif_config[ASYNC_EMIF_NUM_CS] = {
                .rd_strobe      = 0x3f,
                .rd_hold        = 7,
                .turn_around    = 3,
-               .width          = ASYNC_EMIF_8,
+               .width          = AEMIF_WIDTH_8,
        },
 
 };
@@ -66,7 +67,7 @@ int dram_init(void)
 
        gd->ram_size = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE,
                                    CONFIG_MAX_RAM_BANK_SIZE);
-       init_async_emif(ARRAY_SIZE(async_emif_config), async_emif_config);
+       aemif_init(ARRAY_SIZE(aemif_configs), aemif_configs);
        return 0;
 }
 
index 5d03f37a187b8fb5f112578ff69043ea2d0135ce..b23076f614a0fdac02c17cb19c3dcb45bcd90a68 100644 (file)
@@ -14,3 +14,4 @@ obj-y += twserial/
 obj-y += video/
 obj-y += watchdog/
 obj-$(CONFIG_QE) += qe/
+obj-y += memory/
diff --git a/drivers/memory/Makefile b/drivers/memory/Makefile
new file mode 100644 (file)
index 0000000..9bfb9c7
--- /dev/null
@@ -0,0 +1 @@
+obj-$(CONFIG_TI_AEMIF) += ti-aemif.o
diff --git a/drivers/memory/ti-aemif.c b/drivers/memory/ti-aemif.c
new file mode 100644 (file)
index 0000000..f821dae
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * Keystone2: Asynchronous EMIF Configuration
+ *
+ * (C) Copyright 2012-2014
+ *     Texas Instruments Incorporated, <www.ti.com>
+ *
+ * SPDX-License-Identifier:     GPL-2.0+
+ */
+
+#include <common.h>
+#include <asm/ti-common/ti-aemif.h>
+
+#define AEMIF_WAITCYCLE_CONFIG         (CONFIG_AEMIF_CNTRL_BASE + 0x4)
+#define AEMIF_NAND_CONTROL             (CONFIG_AEMIF_CNTRL_BASE + 0x60)
+#define AEMIF_ONENAND_CONTROL          (CONFIG_AEMIF_CNTRL_BASE + 0x5c)
+#define AEMIF_CONFIG(cs)               (CONFIG_AEMIF_CNTRL_BASE + 0x10 \
+                                        + (cs * 4))
+
+#define AEMIF_CFG_SELECT_STROBE(v)     ((v) ? 1 << 31 : 0)
+#define AEMIF_CFG_EXTEND_WAIT(v)       ((v) ? 1 << 30 : 0)
+#define AEMIF_CFG_WR_SETUP(v)          (((v) & 0x0f) << 26)
+#define AEMIF_CFG_WR_STROBE(v)         (((v) & 0x3f) << 20)
+#define AEMIF_CFG_WR_HOLD(v)           (((v) & 0x07) << 17)
+#define AEMIF_CFG_RD_SETUP(v)          (((v) & 0x0f) << 13)
+#define AEMIF_CFG_RD_STROBE(v)         (((v) & 0x3f) << 7)
+#define AEMIF_CFG_RD_HOLD(v)           (((v) & 0x07) << 4)
+#define AEMIF_CFG_TURN_AROUND(v)       (((v) & 0x03) << 2)
+#define AEMIF_CFG_WIDTH(v)             (((v) & 0x03) << 0)
+
+#define set_config_field(reg, field, val)                      \
+       do {                                                    \
+               if (val != -1) {                                \
+                       reg &= ~AEMIF_CFG_##field(0xffffffff);  \
+                       reg |=  AEMIF_CFG_##field(val);         \
+               }                                               \
+       } while (0)
+
+static void aemif_configure(int cs, struct aemif_config *cfg)
+{
+       unsigned long tmp;
+
+       if (cfg->mode == AEMIF_MODE_NAND) {
+               tmp = __raw_readl(AEMIF_NAND_CONTROL);
+               tmp |= (1 << cs);
+               __raw_writel(tmp, AEMIF_NAND_CONTROL);
+
+       } else if (cfg->mode == AEMIF_MODE_ONENAND) {
+               tmp = __raw_readl(AEMIF_ONENAND_CONTROL);
+               tmp |= (1 << cs);
+               __raw_writel(tmp, AEMIF_ONENAND_CONTROL);
+       }
+
+       tmp = __raw_readl(AEMIF_CONFIG(cs));
+
+       set_config_field(tmp, SELECT_STROBE,    cfg->select_strobe);
+       set_config_field(tmp, EXTEND_WAIT,      cfg->extend_wait);
+       set_config_field(tmp, WR_SETUP,         cfg->wr_setup);
+       set_config_field(tmp, WR_STROBE,        cfg->wr_strobe);
+       set_config_field(tmp, WR_HOLD,          cfg->wr_hold);
+       set_config_field(tmp, RD_SETUP,         cfg->rd_setup);
+       set_config_field(tmp, RD_STROBE,        cfg->rd_strobe);
+       set_config_field(tmp, RD_HOLD,          cfg->rd_hold);
+       set_config_field(tmp, TURN_AROUND,      cfg->turn_around);
+       set_config_field(tmp, WIDTH,            cfg->width);
+
+       __raw_writel(tmp, AEMIF_CONFIG(cs));
+}
+
+void aemif_init(int num_cs, struct aemif_config *config)
+{
+       int cs;
+
+       if (num_cs > AEMIF_NUM_CS) {
+               num_cs = AEMIF_NUM_CS;
+               printf("AEMIF: csnum has to be <= 5");
+       }
+
+       for (cs = 0; cs < num_cs; cs++)
+               aemif_configure(cs, config + cs);
+}
index fcfbca92d18ae89c82906dee82f8e93df0c8dc06..858329f9586ceb62d9df23864642060baa6fa801 100644 (file)
 #define CONFIG_SYS_SGMII_LINERATE_MHZ          1250
 #define CONFIG_SYS_SGMII_RATESCALE             2
 
+/* AEMIF */
+#define CONFIG_TI_AEMIF
+#define CONFIG_AEMIF_CNTRL_BASE                       KS2_AEMIF_CNTRL_BASE
+
 /* NAND Configuration */
 #define CONFIG_NAND_DAVINCI
 #define CONFIG_CMD_NAND_ECCLAYOUT