[U-Boot] [PATCH v1 14/25] arm: kirkwood: Change naming of dram functions from km_foo() to mvebu_foo()

Stefan Roese
2014-06-27T09:55:00Z

Additionally the SDRAM address decoding register address is not hard coded
in the C code any more. A define is introduced for this base address.

This makes is possible to use those gpio functions from other MVEBU SoC's
as well.

Signed-off-by: Stefan Roese <sr@denx.de>
---

arch/arm/include/asm/arch-kirkwood/cpu.h | 6 +--
arch/arm/include/asm/arch-kirkwood/soc.h | 1 +
arch/arm/mvebu-common/dram.c | 53 +++++++++++++------------
board/LaCie/net2big_v2/net2big_v2.c | 2 +-
board/LaCie/netspace_v2/netspace_v2.c | 2 +-
board/LaCie/wireless_space/wireless_space.c | 2 +-
board/Marvell/dreamplug/dreamplug.c | 2 +-
board/Marvell/guruplug/guruplug.c | 2 +-
board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c | 2 +-
board/Marvell/openrd/openrd.c | 2 +-
board/Marvell/rd6281a/rd6281a.c | 2 +-
board/Marvell/sheevaplug/sheevaplug.c | 2 +-
board/Seagate/dockstar/dockstar.c | 2 +-
board/Seagate/goflexhome/goflexhome.c | 2 +-
board/buffalo/lsxl/lsxl.c | 2 +-
board/cloudengines/pogo_e02/pogo_e02.c | 2 +-
board/d-link/dns325/dns325.c | 2 +-
board/iomega/iconnect/iconnect.c | 2 +-
board/karo/tk71/tk71.c | 2 +-
board/keymile/km_arm/km_arm.c | 4 +-
board/raidsonic/ib62x0/ib62x0.c | 2 +-
21 files changed, 50 insertions(+), 48 deletions(-)

diff --git a/arch/arm/include/asm/arch-kirkwood/cpu.h b/arch/arm/include/asm/arch-kirkwood/cpu.h
index 5900a15..926d347 100644
--- a/arch/arm/include/asm/arch-kirkwood/cpu.h
+++ b/arch/arm/include/asm/arch-kirkwood/cpu.h
@@ -140,9 +140,9 @@ struct kwgpio_registers {
* functions
*/
unsigned char get_random_hex(void);
-unsigned int kw_sdram_bar(enum memory_bank bank);
-unsigned int kw_sdram_bs(enum memory_bank bank);
-void kw_sdram_size_adjust(enum memory_bank bank);
+unsigned int mvebu_sdram_bar(enum memory_bank bank);
+unsigned int mvebu_sdram_bs(enum memory_bank bank);
+void mvebu_sdram_size_adjust(enum memory_bank bank);
int kw_config_adr_windows(void);
void mvebu_config_gpio(unsigned int gpp0_oe_val, unsigned int gpp1_oe_val,
unsigned int gpp0_oe, unsigned int gpp1_oe);
diff --git a/arch/arm/include/asm/arch-kirkwood/soc.h b/arch/arm/include/asm/arch-kirkwood/soc.h
index 379ce13..75120b1 100644
--- a/arch/arm/include/asm/arch-kirkwood/soc.h
+++ b/arch/arm/include/asm/arch-kirkwood/soc.h
@@ -22,6 +22,7 @@
#define KW_REG_UNDOC_0x1470 (KW_REGISTER(0x1470))
#define KW_REG_UNDOC_0x1478 (KW_REGISTER(0x1478))

+#define MVEBU_SDRAM_BASE (KW_REGISTER(0x1500))
#define KW_TWSI_BASE (KW_REGISTER(0x11000))
#define KW_UART0_BASE (KW_REGISTER(0x12000))
#define KW_UART1_BASE (KW_REGISTER(0x12100))
diff --git a/arch/arm/mvebu-common/dram.c b/arch/arm/mvebu-common/dram.c
index e468136..db18791 100644
--- a/arch/arm/mvebu-common/dram.c
+++ b/arch/arm/mvebu-common/dram.c
@@ -14,27 +14,27 @@

DECLARE_GLOBAL_DATA_PTR;

-struct kw_sdram_bank {
+struct sdram_bank {
u32 win_bar;
u32 win_sz;
};

-struct kw_sdram_addr_dec {
- struct kw_sdram_bank sdram_bank[4];
+struct sdram_addr_dec {
+ struct sdram_bank sdram_bank[4];
};

-#define KW_REG_CPUCS_WIN_ENABLE (1 << 0)
-#define KW_REG_CPUCS_WIN_WR_PROTECT (1 << 1)
-#define KW_REG_CPUCS_WIN_WIN0_CS(x) (((x) & 0x3) << 2)
-#define KW_REG_CPUCS_WIN_SIZE(x) (((x) & 0xff) << 24)
+#define REG_CPUCS_WIN_ENABLE (1 << 0)
+#define REG_CPUCS_WIN_WR_PROTECT (1 << 1)
+#define REG_CPUCS_WIN_WIN0_CS(x) (((x) & 0x3) << 2)
+#define REG_CPUCS_WIN_SIZE(x) (((x) & 0xff) << 24)

/*
- * kw_sdram_bar - reads SDRAM Base Address Register
+ * mvebu_sdram_bar - reads SDRAM Base Address Register
*/
-u32 kw_sdram_bar(enum memory_bank bank)
+u32 mvebu_sdram_bar(enum memory_bank bank)
{
- struct kw_sdram_addr_dec *base =
- (struct kw_sdram_addr_dec *)KW_REGISTER(0x1500);
+ struct sdram_addr_dec *base =
+ (struct sdram_addr_dec *)MVEBU_SDRAM_BASE;
u32 result = 0;
u32 enable = 0x01 & readl(&base->sdram_bank[bank].win_sz);

@@ -46,31 +46,31 @@ u32 kw_sdram_bar(enum memory_bank bank)
}

/*
- * kw_sdram_bs_set - writes SDRAM Bank size
+ * mvebu_sdram_bs_set - writes SDRAM Bank size
*/
-static void kw_sdram_bs_set(enum memory_bank bank, u32 size)
+static void mvebu_sdram_bs_set(enum memory_bank bank, u32 size)
{
- struct kw_sdram_addr_dec *base =
- (struct kw_sdram_addr_dec *)KW_REGISTER(0x1500);
+ struct sdram_addr_dec *base =
+ (struct sdram_addr_dec *)MVEBU_SDRAM_BASE;
/* Read current register value */
u32 reg = readl(&base->sdram_bank[bank].win_sz);

/* Clear window size */
- reg &= ~KW_REG_CPUCS_WIN_SIZE(0xFF);
+ reg &= ~REG_CPUCS_WIN_SIZE(0xFF);

/* Set new window size */
- reg |= KW_REG_CPUCS_WIN_SIZE((size - 1) >> 24);
+ reg |= REG_CPUCS_WIN_SIZE((size - 1) >> 24);

writel(reg, &base->sdram_bank[bank].win_sz);
}

/*
- * kw_sdram_bs - reads SDRAM Bank size
+ * mvebu_sdram_bs - reads SDRAM Bank size
*/
-u32 kw_sdram_bs(enum memory_bank bank)
+u32 mvebu_sdram_bs(enum memory_bank bank)
{
- struct kw_sdram_addr_dec *base =
- (struct kw_sdram_addr_dec *)KW_REGISTER(0x1500);
+ struct sdram_addr_dec *base =
+ (struct sdram_addr_dec *)MVEBU_SDRAM_BASE;
u32 result = 0;
u32 enable = 0x01 & readl(&base->sdram_bank[bank].win_sz);

@@ -81,15 +81,16 @@ u32 kw_sdram_bs(enum memory_bank bank)
return result;
}

-void kw_sdram_size_adjust(enum memory_bank bank)
+void mvebu_sdram_size_adjust(enum memory_bank bank)
{
u32 size;

/* probe currently equipped RAM size */
- size = get_ram_size((void *)kw_sdram_bar(bank), kw_sdram_bs(bank));
+ size = get_ram_size((void *)mvebu_sdram_bar(bank),
+ mvebu_sdram_bs(bank));

/* adjust SDRAM window size accordingly */
- kw_sdram_bs_set(bank, size);
+ mvebu_sdram_bs_set(bank, size);
}

#ifndef CONFIG_SYS_BOARD_DRAM_INIT
@@ -99,8 +100,8 @@ int dram_init(void)

gd->ram_size = 0;
for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
- gd->bd->bi_dram[i].start = kw_sdram_bar(i);
- gd->bd->bi_dram[i].size = kw_sdram_bs(i);
+ gd->bd->bi_dram[i].start = mvebu_sdram_bar(i);
+ gd->bd->bi_dram[i].size = mvebu_sdram_bs(i);
/*
* It is assumed that all memory banks are consecutive
* and without gaps.
diff --git a/board/LaCie/net2big_v2/net2big_v2.c b/board/LaCie/net2big_v2/net2big_v2.c
index 12a516e..263bb54 100644
--- a/board/LaCie/net2big_v2/net2big_v2.c
+++ b/board/LaCie/net2big_v2/net2big_v2.c
@@ -77,7 +77,7 @@ int board_init(void)
gd->bd->bi_arch_number = MACH_TYPE_NET2BIG_V2;

/* Boot parameters address */
- gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+ gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;

return 0;
}
diff --git a/board/LaCie/netspace_v2/netspace_v2.c b/board/LaCie/netspace_v2/netspace_v2.c
index 323e34a..17e6296 100644
--- a/board/LaCie/netspace_v2/netspace_v2.c
+++ b/board/LaCie/netspace_v2/netspace_v2.c
@@ -73,7 +73,7 @@ int board_init(void)
gd->bd->bi_arch_number = CONFIG_MACH_TYPE;

/* Boot parameters address */
- gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+ gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;

return 0;
}
diff --git a/board/LaCie/wireless_space/wireless_space.c b/board/LaCie/wireless_space/wireless_space.c
index 15b34a3..8620e4b 100644
--- a/board/LaCie/wireless_space/wireless_space.c
+++ b/board/LaCie/wireless_space/wireless_space.c
@@ -112,7 +112,7 @@ int board_init(void)
gd->bd->bi_arch_number = CONFIG_MACH_TYPE;

/* Boot parameters address */
- gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+ gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;

return 0;
}
diff --git a/board/Marvell/dreamplug/dreamplug.c b/board/Marvell/dreamplug/dreamplug.c
index 07b7496..0887d92 100644
--- a/board/Marvell/dreamplug/dreamplug.c
+++ b/board/Marvell/dreamplug/dreamplug.c
@@ -90,7 +90,7 @@ int board_early_init_f(void)
int board_init(void)
{
/* adress of boot parameters */
- gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+ gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;

return 0;
}
diff --git a/board/Marvell/guruplug/guruplug.c b/board/Marvell/guruplug/guruplug.c
index b18a306..b0d5f1e 100644
--- a/board/Marvell/guruplug/guruplug.c
+++ b/board/Marvell/guruplug/guruplug.c
@@ -92,7 +92,7 @@ int board_init(void)
gd->bd->bi_arch_number = MACH_TYPE_GURUPLUG;

/* adress of boot parameters */
- gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+ gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;

return 0;
}
diff --git a/board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c b/board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c
index 97fb61b..ef08ad8 100644
--- a/board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c
+++ b/board/Marvell/mv88f6281gtw_ge/mv88f6281gtw_ge.c
@@ -94,7 +94,7 @@ int board_init(void)
gd->bd->bi_arch_number = MACH_TYPE_MV88F6281GTW_GE;

/* adress of boot parameters */
- gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+ gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;

return 0;
}
diff --git a/board/Marvell/openrd/openrd.c b/board/Marvell/openrd/openrd.c
index 52dd083..55cf525 100644
--- a/board/Marvell/openrd/openrd.c
+++ b/board/Marvell/openrd/openrd.c
@@ -104,7 +104,7 @@ int board_init(void)
#endif

/* adress of boot parameters */
- gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+ gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
return 0;
}

diff --git a/board/Marvell/rd6281a/rd6281a.c b/board/Marvell/rd6281a/rd6281a.c
index df5fbea..b0020c9 100644
--- a/board/Marvell/rd6281a/rd6281a.c
+++ b/board/Marvell/rd6281a/rd6281a.c
@@ -93,7 +93,7 @@ int board_init(void)
gd->bd->bi_arch_number = MACH_TYPE_RD88F6281;

/* adress of boot parameters */
- gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+ gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;

return 0;
}
diff --git a/board/Marvell/sheevaplug/sheevaplug.c b/board/Marvell/sheevaplug/sheevaplug.c
index 18eeb4c..8907fb5 100644
--- a/board/Marvell/sheevaplug/sheevaplug.c
+++ b/board/Marvell/sheevaplug/sheevaplug.c
@@ -92,7 +92,7 @@ int board_init(void)
gd->bd->bi_arch_number = MACH_TYPE_SHEEVAPLUG;

/* adress of boot parameters */
- gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+ gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;

return 0;
}
diff --git a/board/Seagate/dockstar/dockstar.c b/board/Seagate/dockstar/dockstar.c
index 838f578..83ab1bc 100644
--- a/board/Seagate/dockstar/dockstar.c
+++ b/board/Seagate/dockstar/dockstar.c
@@ -96,7 +96,7 @@ int board_init(void)
gd->bd->bi_arch_number = MACH_TYPE_DOCKSTAR;

/* address of boot parameters */
- gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+ gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;

return 0;
}
diff --git a/board/Seagate/goflexhome/goflexhome.c b/board/Seagate/goflexhome/goflexhome.c
index c3f4cbf..1f4fb92 100644
--- a/board/Seagate/goflexhome/goflexhome.c
+++ b/board/Seagate/goflexhome/goflexhome.c
@@ -98,7 +98,7 @@ int board_init(void)
gd->bd->bi_arch_number = MACH_TYPE_GOFLEXHOME;

/* address of boot parameters */
- gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+ gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;

return 0;
}
diff --git a/board/buffalo/lsxl/lsxl.c b/board/buffalo/lsxl/lsxl.c
index 042132e..92292ae 100644
--- a/board/buffalo/lsxl/lsxl.c
+++ b/board/buffalo/lsxl/lsxl.c
@@ -167,7 +167,7 @@ static void set_led(int state)
int board_init(void)
{
/* address of boot parameters */
- gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+ gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;

set_led(LED_POWER_BLINKING);

diff --git a/board/cloudengines/pogo_e02/pogo_e02.c b/board/cloudengines/pogo_e02/pogo_e02.c
index 314834f..8309d06 100644
--- a/board/cloudengines/pogo_e02/pogo_e02.c
+++ b/board/cloudengines/pogo_e02/pogo_e02.c
@@ -64,7 +64,7 @@ int board_early_init_f(void)
int board_init(void)
{
/* Boot parameters address */
- gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+ gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;

return 0;
}
diff --git a/board/d-link/dns325/dns325.c b/board/d-link/dns325/dns325.c
index fd23696..a022daf 100644
--- a/board/d-link/dns325/dns325.c
+++ b/board/d-link/dns325/dns325.c
@@ -92,7 +92,7 @@ int board_early_init_f(void)
int board_init(void)
{
/* Boot parameters address */
- gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+ gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;

return 0;
}
diff --git a/board/iomega/iconnect/iconnect.c b/board/iomega/iconnect/iconnect.c
index 76c945a..086a473 100644
--- a/board/iomega/iconnect/iconnect.c
+++ b/board/iomega/iconnect/iconnect.c
@@ -87,7 +87,7 @@ int board_early_init_f(void)
int board_init(void)
{
/* adress of boot parameters */
- gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+ gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;

return 0;
}
diff --git a/board/karo/tk71/tk71.c b/board/karo/tk71/tk71.c
index 7aec5f9..35546d2 100644
--- a/board/karo/tk71/tk71.c
+++ b/board/karo/tk71/tk71.c
@@ -97,7 +97,7 @@ int board_init(void)
gd->bd->bi_arch_number = CONFIG_MACH_TYPE;

/* adress of boot parameters */
- gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+ gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;

return 0;
}
diff --git a/board/keymile/km_arm/km_arm.c b/board/keymile/km_arm/km_arm.c
index 6621464..1c7c108 100644
--- a/board/keymile/km_arm/km_arm.c
+++ b/board/keymile/km_arm/km_arm.c
@@ -226,7 +226,7 @@ int board_early_init_f(void)
writel(tmp & (~KM_KIRKWOOD_SOFT_I2C_GPIOS) , MVEBU_GPIO0_BASE + 4);
#endif
/* adjust SDRAM size for bank 0 */
- kw_sdram_size_adjust(0);
+ mvebu_sdram_size_adjust(0);
kirkwood_mpp_conf(kwmpp_config, NULL);
return 0;
}
@@ -234,7 +234,7 @@ int board_early_init_f(void)
int board_init(void)
{
/* address of boot parameters */
- gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+ gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;

/*
* The KM_FLASH_GPIO_PIN switches between using a
diff --git a/board/raidsonic/ib62x0/ib62x0.c b/board/raidsonic/ib62x0/ib62x0.c
index dbcfb43..f01fb1c 100644
--- a/board/raidsonic/ib62x0/ib62x0.c
+++ b/board/raidsonic/ib62x0/ib62x0.c
@@ -62,7 +62,7 @@ int board_early_init_f(void)
int board_init(void)
{
/* adress of boot parameters */
- gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
+ gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;

return 0;
}
--
2.0.1