]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
memory: ti-aemif: Make AEMIF driver architecture agnostic
authorBastien Curutchet <bastien.curutchet@bootlin.com>
Mon, 21 Oct 2024 15:13:26 +0000 (17:13 +0200)
committerTom Rini <trini@konsulko.com>
Wed, 30 Oct 2024 00:45:22 +0000 (18:45 -0600)
AEMIF controller is present on other SoCs than the Keystone ones.

Remove Keystone specificities from the driver to be able to use it from
other architectures.
Adapt the ks2_evm/board.c to fit the new driver.

Signed-off-by: Bastien Curutchet <bastien.curutchet@bootlin.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
arch/arm/include/asm/ti-common/ti-aemif.h
board/ti/ks2_evm/board.c
drivers/memory/ti-aemif.c

index a77538673f6377695a7874d8847ff1555674fb98..11a7384cec97e85a6e422ef7ef5d44cbcf921f22 100644 (file)
@@ -16,6 +16,7 @@
 #define AEMIF_PRESERVE             -1
 
 struct aemif_config {
+       void *base;
        unsigned mode;
        unsigned select_strobe;
        unsigned extend_wait;
index c6735d37dda7a0080be133eaaaa2ee9a08dc9275..b2f0dced677bc859220def90f329c0dfaa4821d7 100644 (file)
@@ -49,8 +49,10 @@ int dram_init(void)
        gd->ram_size = get_ram_size((long *)CFG_SYS_SDRAM_BASE,
                                    CFG_MAX_RAM_BANK_SIZE);
 #if defined(CONFIG_TI_AEMIF)
-       if (!(board_is_k2g_ice() || board_is_k2g_i1()))
+       if (!(board_is_k2g_ice() || board_is_k2g_i1())) {
+               aemif_configs->base = (void *)KS2_AEMIF_CNTRL_BASE;
                aemif_init(ARRAY_SIZE(aemif_configs), aemif_configs);
+       }
 #endif
 
        if (!(board_is_k2g_ice() || board_is_k2g_i1())) {
index 127a262894a3902ae54a3caccf6dac4aca4b5f25..8e7ddde970bd3ceb276ce711aa8b2409021c3caa 100644 (file)
@@ -9,10 +9,10 @@
 #include <asm/arch/hardware.h>
 #include <asm/ti-common/ti-aemif.h>
 
-#define AEMIF_WAITCYCLE_CONFIG         (KS2_AEMIF_CNTRL_BASE + 0x4)
-#define AEMIF_NAND_CONTROL             (KS2_AEMIF_CNTRL_BASE + 0x60)
-#define AEMIF_ONENAND_CONTROL          (KS2_AEMIF_CNTRL_BASE + 0x5c)
-#define AEMIF_CONFIG(cs)               (KS2_AEMIF_CNTRL_BASE + 0x10 + ((cs) * 4))
+#define AEMIF_WAITCYCLE_CONFIG         (0x4)
+#define AEMIF_NAND_CONTROL             (0x60)
+#define AEMIF_ONENAND_CONTROL          (0x5c)
+#define AEMIF_CONFIG(cs)               (0x10 + ((cs) * 4))
 
 #define AEMIF_CFG_SELECT_STROBE(v)     ((v) ? 1 << 31 : 0)
 #define AEMIF_CFG_EXTEND_WAIT(v)       ((v) ? 1 << 30 : 0)
@@ -38,17 +38,17 @@ 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 = __raw_readl(cfg->base + AEMIF_NAND_CONTROL);
                tmp |= (1 << cs);
-               __raw_writel(tmp, AEMIF_NAND_CONTROL);
+               __raw_writel(tmp, cfg->base + AEMIF_NAND_CONTROL);
 
        } else if (cfg->mode == AEMIF_MODE_ONENAND) {
-               tmp = __raw_readl(AEMIF_ONENAND_CONTROL);
+               tmp = __raw_readl(cfg->base + AEMIF_ONENAND_CONTROL);
                tmp |= (1 << cs);
-               __raw_writel(tmp, AEMIF_ONENAND_CONTROL);
+               __raw_writel(tmp, cfg->base + AEMIF_ONENAND_CONTROL);
        }
 
-       tmp = __raw_readl(AEMIF_CONFIG(cs));
+       tmp = __raw_readl(cfg->base + AEMIF_CONFIG(cs));
 
        set_config_field(tmp, SELECT_STROBE,    cfg->select_strobe);
        set_config_field(tmp, EXTEND_WAIT,      cfg->extend_wait);
@@ -61,7 +61,7 @@ static void aemif_configure(int cs, struct aemif_config *cfg)
        set_config_field(tmp, TURN_AROUND,      cfg->turn_around);
        set_config_field(tmp, WIDTH,            cfg->width);
 
-       __raw_writel(tmp, AEMIF_CONFIG(cs));
+       __raw_writel(tmp, cfg->base + AEMIF_CONFIG(cs));
 }
 
 void aemif_init(int num_cs, struct aemif_config *config)