]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
memory: ti-aemif: Wrap the CS configuration into a function
authorBastien Curutchet <bastien.curutchet@bootlin.com>
Mon, 21 Oct 2024 15:13:28 +0000 (17:13 +0200)
committerTom Rini <trini@konsulko.com>
Wed, 30 Oct 2024 00:45:22 +0000 (18:45 -0600)
Wrap the CS configuration into a aemif_configure_cs() to ease its
migration to another driver when adding DM support.

Signed-off-by: Bastien Curutchet <bastien.curutchet@bootlin.com>
drivers/memory/ti-aemif.c

index 82a9c8cf7b981e57fa5c81574f59bc86e530a08b..5e9514713f22e21dcd3ca01f24418a5515c3263e 100644 (file)
                }                                               \
        } while (0)
 
-static void aemif_configure(int cs, struct aemif_config *cfg)
+static void aemif_cs_configure(int cs, struct aemif_config *cfg)
 {
        unsigned long tmp;
 
-       if (cfg->mode == AEMIF_MODE_NAND) {
-               tmp = __raw_readl(cfg->base + AEMIF_NAND_CONTROL);
-               tmp |= (1 << cs);
-               __raw_writel(tmp, cfg->base + AEMIF_NAND_CONTROL);
-
-       } else if (cfg->mode == AEMIF_MODE_ONENAND) {
-               tmp = __raw_readl(cfg->base + AEMIF_ONENAND_CONTROL);
-               tmp |= (1 << cs);
-               __raw_writel(tmp, cfg->base + AEMIF_ONENAND_CONTROL);
-       }
-
        tmp = __raw_readl(cfg->base + AEMIF_CONFIG(cs));
 
        set_config_field(tmp, SELECT_STROBE,    cfg->select_strobe);
@@ -65,6 +54,24 @@ static void aemif_configure(int cs, struct aemif_config *cfg)
        __raw_writel(tmp, cfg->base + AEMIF_CONFIG(cs));
 }
 
+static void aemif_configure(int cs, struct aemif_config *cfg)
+{
+       unsigned long tmp;
+
+       if (cfg->mode == AEMIF_MODE_NAND) {
+               tmp = __raw_readl(cfg->base + AEMIF_NAND_CONTROL);
+               tmp |= (1 << cs);
+               __raw_writel(tmp, cfg->base + AEMIF_NAND_CONTROL);
+
+       } else if (cfg->mode == AEMIF_MODE_ONENAND) {
+               tmp = __raw_readl(cfg->base + AEMIF_ONENAND_CONTROL);
+               tmp |= (1 << cs);
+               __raw_writel(tmp, cfg->base + AEMIF_ONENAND_CONTROL);
+       }
+
+       aemif_cs_configure(cs, cfg);
+}
+
 void aemif_init(int num_cs, struct aemif_config *config)
 {
        int cs;