From 6d4ebd159eb0b28e0dcbf0d8cbc8585274af7044 Mon Sep 17 00:00:00 2001 From: Luka Perkov Date: Wed, 5 Sep 2012 08:08:16 +0000 Subject: kirkwood: fix mpp.h coding style Signed-off-by: Luka Perkov --- arch/arm/include/asm/arch-kirkwood/mpp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'arch/arm') diff --git a/arch/arm/include/asm/arch-kirkwood/mpp.h b/arch/arm/include/asm/arch-kirkwood/mpp.h index 8e50ee7..8ceea7b 100644 --- a/arch/arm/include/asm/arch-kirkwood/mpp.h +++ b/arch/arm/include/asm/arch-kirkwood/mpp.h @@ -85,7 +85,7 @@ #define MPP7_SPI_SCn MPP( 7, 0x2, 0, 1, 1, 1, 1, 1 ) #define MPP7_PTP_TRIG_GEN MPP( 7, 0x3, 0, 1, 1, 1, 1, 1 ) -#define MPP8_GPIO MPP( 8, 0x0, 1, 1, 1, 1, 1, 1 ) +#define MPP8_GPIO MPP( 8, 0x0, 1, 1, 1, 1, 1, 1 ) #define MPP8_TW_SDA MPP( 8, 0x1, 1, 1, 1, 1, 1, 1 ) #define MPP8_UART0_RTS MPP( 8, 0x2, 0, 1, 1, 1, 1, 1 ) #define MPP8_UART1_RTS MPP( 8, 0x3, 0, 1, 1, 1, 1, 1 ) -- cgit v1.1 From cf37c5d98bb2e23fbcbca8a0328ca7dd43d6af8c Mon Sep 17 00:00:00 2001 From: Holger Brunck Date: Fri, 20 Jul 2012 02:34:24 +0000 Subject: kirkwood: use c-struct for access to SDRAM addr decode registers Remove the defines and do this with a C-struct. Signed-off-by: Holger Brunck cc: Prafulla Wadaskar cc: Valentin Longchamp cc: Gerlando Falauto cc: Marek Vasut Acked-By: Prafulla Wadaskar --- arch/arm/cpu/arm926ejs/kirkwood/dram.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'arch/arm') diff --git a/arch/arm/cpu/arm926ejs/kirkwood/dram.c b/arch/arm/cpu/arm926ejs/kirkwood/dram.c index 181b3e7..1c5faab 100644 --- a/arch/arm/cpu/arm926ejs/kirkwood/dram.c +++ b/arch/arm/cpu/arm926ejs/kirkwood/dram.c @@ -30,20 +30,29 @@ DECLARE_GLOBAL_DATA_PTR; -#define KW_REG_CPUCS_WIN_BAR(x) (KW_REGISTER(0x1500) + (x * 0x08)) -#define KW_REG_CPUCS_WIN_SZ(x) (KW_REGISTER(0x1504) + (x * 0x08)) +struct kw_sdram_bank { + u32 win_bar; + u32 win_sz; +}; + +struct kw_sdram_addr_dec { + struct kw_sdram_bank sdram_bank[4]; +}; + /* * kw_sdram_bar - reads SDRAM Base Address Register */ u32 kw_sdram_bar(enum memory_bank bank) { + struct kw_sdram_addr_dec *base = + (struct kw_sdram_addr_dec *)KW_REGISTER(0x1500); u32 result = 0; - u32 enable = 0x01 & readl(KW_REG_CPUCS_WIN_SZ(bank)); + u32 enable = 0x01 & readl(&base->sdram_bank[bank].win_sz); if ((!enable) || (bank > BANK3)) return 0; - result = readl(KW_REG_CPUCS_WIN_BAR(bank)); + result = readl(&base->sdram_bank[bank].win_bar); return result; } @@ -52,12 +61,14 @@ u32 kw_sdram_bar(enum memory_bank bank) */ u32 kw_sdram_bs(enum memory_bank bank) { + struct kw_sdram_addr_dec *base = + (struct kw_sdram_addr_dec *)KW_REGISTER(0x1500); u32 result = 0; - u32 enable = 0x01 & readl(KW_REG_CPUCS_WIN_SZ(bank)); + u32 enable = 0x01 & readl(&base->sdram_bank[bank].win_sz); if ((!enable) || (bank > BANK3)) return 0; - result = 0xff000000 & readl(KW_REG_CPUCS_WIN_SZ(bank)); + result = 0xff000000 & readl(&base->sdram_bank[bank].win_sz); result += 0x01000000; return result; } -- cgit v1.1 From 455151652524570d7c5b320718c7004e63e01656 Mon Sep 17 00:00:00 2001 From: Gerlando Falauto Date: Fri, 20 Jul 2012 02:34:25 +0000 Subject: kirkwood: implement kw_sdram_bs_set() Some boards might be equipped with different SDRAM configurations. When that is the case, CPU CS Window Size Register (CS[0]n Size) should be set to the biggest value through board.cfg file; then its value can be fixed at runtime according to the detected SDRAM size. Therefore, implement kw_sdram_bs_set(). Signed-off-by: Gerlando Falauto Signed-off-by: Holger Brunck cc: Prafulla Wadaskar cc: Valentin Longchamp cc: Marek Vasut Acked-by: Prafulla Wadaskar --- arch/arm/cpu/arm926ejs/kirkwood/dram.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'arch/arm') diff --git a/arch/arm/cpu/arm926ejs/kirkwood/dram.c b/arch/arm/cpu/arm926ejs/kirkwood/dram.c index 1c5faab..5e2f9d8 100644 --- a/arch/arm/cpu/arm926ejs/kirkwood/dram.c +++ b/arch/arm/cpu/arm926ejs/kirkwood/dram.c @@ -39,6 +39,11 @@ struct kw_sdram_addr_dec { struct kw_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) + /* * kw_sdram_bar - reads SDRAM Base Address Register */ @@ -57,6 +62,25 @@ u32 kw_sdram_bar(enum memory_bank bank) } /* + * kw_sdram_bs_set - writes SDRAM Bank size + */ +static void kw_sdram_bs_set(enum memory_bank bank, u32 size) +{ + struct kw_sdram_addr_dec *base = + (struct kw_sdram_addr_dec *)KW_REGISTER(0x1500); + /* Read current register value */ + u32 reg = readl(&base->sdram_bank[bank].win_sz); + + /* Clear window size */ + reg &= ~KW_REG_CPUCS_WIN_SIZE(0xFF); + + /* Set new window size */ + reg |= KW_REG_CPUCS_WIN_SIZE((size - 1) >> 24); + + writel(reg, &base->sdram_bank[bank].win_sz); +} + +/* * kw_sdram_bs - reads SDRAM Bank size */ u32 kw_sdram_bs(enum memory_bank bank) -- cgit v1.1 From b3168f4be86ef02905281ff7531960112e10cc7e Mon Sep 17 00:00:00 2001 From: Gerlando Falauto Date: Wed, 25 Jul 2012 06:23:48 +0000 Subject: kirkwood: implement kw_sdram_size_adjust Size of the SDRAM chips might differ between any two (otherwise identical) instances of the same board. So add a function kw_sdram_size_adjust() which reads out the current ram size for a given bank, and adjusts the Kirkwood's SDRAM window size register accordingly. Signed-off-by: Gerlando Falauto Signed-off-by: Holger Brunck cc: Prafulla Wadaskar cc: Valentin Longchamp --- arch/arm/cpu/arm926ejs/kirkwood/dram.c | 11 +++++++++++ arch/arm/include/asm/arch-kirkwood/cpu.h | 1 + 2 files changed, 12 insertions(+) (limited to 'arch/arm') diff --git a/arch/arm/cpu/arm926ejs/kirkwood/dram.c b/arch/arm/cpu/arm926ejs/kirkwood/dram.c index 5e2f9d8..807894f 100644 --- a/arch/arm/cpu/arm926ejs/kirkwood/dram.c +++ b/arch/arm/cpu/arm926ejs/kirkwood/dram.c @@ -97,6 +97,17 @@ u32 kw_sdram_bs(enum memory_bank bank) return result; } +void kw_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)); + + /* adjust SDRAM window size accordingly */ + kw_sdram_bs_set(bank, size); +} + #ifndef CONFIG_SYS_BOARD_DRAM_INIT int dram_init(void) { diff --git a/arch/arm/include/asm/arch-kirkwood/cpu.h b/arch/arm/include/asm/arch-kirkwood/cpu.h index d28c51a..23783d5 100644 --- a/arch/arm/include/asm/arch-kirkwood/cpu.h +++ b/arch/arm/include/asm/arch-kirkwood/cpu.h @@ -159,6 +159,7 @@ void reset_cpu(unsigned long ignored); 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); int kw_config_adr_windows(void); void kw_config_gpio(unsigned int gpp0_oe_val, unsigned int gpp1_oe_val, unsigned int gpp0_oe, unsigned int gpp1_oe); -- cgit v1.1 From 7029394d822a7d9e8ccb12d9679030b462e1052f Mon Sep 17 00:00:00 2001 From: Dinh Nguyen Date: Fri, 14 Sep 2012 11:08:28 +0000 Subject: ARM: kirkwood/orion5x: Use reset_cpu definition in include/common.h include/common.h has the reset_cpu defined already. No need to re-define here. Signed-off-by: Dinh Nguyen Signed-off-by: Pavel Machek Acked-By: Prafulla Wadaskar --- arch/arm/include/asm/arch-kirkwood/cpu.h | 1 - arch/arm/include/asm/arch-orion5x/cpu.h | 1 - 2 files changed, 2 deletions(-) (limited to 'arch/arm') diff --git a/arch/arm/include/asm/arch-kirkwood/cpu.h b/arch/arm/include/asm/arch-kirkwood/cpu.h index 23783d5..57bfe8e 100644 --- a/arch/arm/include/asm/arch-kirkwood/cpu.h +++ b/arch/arm/include/asm/arch-kirkwood/cpu.h @@ -155,7 +155,6 @@ struct kwgpio_registers { /* * functions */ -void reset_cpu(unsigned long ignored); unsigned char get_random_hex(void); unsigned int kw_sdram_bar(enum memory_bank bank); unsigned int kw_sdram_bs(enum memory_bank bank); diff --git a/arch/arm/include/asm/arch-orion5x/cpu.h b/arch/arm/include/asm/arch-orion5x/cpu.h index 2f52ca8..17b9b69 100644 --- a/arch/arm/include/asm/arch-orion5x/cpu.h +++ b/arch/arm/include/asm/arch-orion5x/cpu.h @@ -251,7 +251,6 @@ struct orion5x_ddr_addr_decode_registers { /* * functions */ -void reset_cpu(unsigned long ignored); u32 orion5x_device_id(void); u32 orion5x_device_rev(void); unsigned int orion5x_winctrl_calcsize(unsigned int sizeval); -- cgit v1.1