kirkwood: implement kw_sdram_bs_set()
PATCH 1/2 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(), to be called for instance within board_early_init_f().
--- arch/arm/cpu/arm926ejs/kirkwood/dram.c | 23 +++++++++++++++++++++++ arch/arm/include/asm/arch-kirkwood/cpu.h | 2 ++ 2 files changed, 25 insertions(+), 0 deletions(-)
arch/arm/cpu/arm926ejs/kirkwood/dram.c +23 -0
@@ -32,6 +32,12 @@ 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)) + +#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 */
@@ -62,6 +68,23 @@ u32 kw_sdram_bs(enum memory_bank bank)return result; } +/* +* kw_sdram_bs_set - writes SDRAM Bank size +*/ +void kw_sdram_bs_set (enum memory_bank bank,u32 size) +{ +/* Read current register value */ +u32 reg =readl (KW_REG_CPUCS_WIN_SZ (bank)); + +/* 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,KW_REG_CPUCS_WIN_SZ (bank)); +} +#ifndef CONFIG_SYS_BOARD_DRAM_INIT int dram_init (void ) {
arch/arm/include/asm/arch-kirkwood/cpu.h +2 -0
@@ -159,6 +159,8 @@ 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_bs_set (enum memory_bank bank,u32 size); +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);
Signature · 1 line
1.7.1
PATCH 2/2 km_arm: enable SDRAM window size fixup
Size of the SDRAM chips might differ between any two (otherwise identical) instances of the same board.
So change board_early_init_f() to use km_sdram_bs_set(), in order to fixup the window size register at runtime, according to the detected SDRAM size.
--- board/keymile/km_arm/km_arm.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-)
board/keymile/km_arm/km_arm.c +12 -0
@@ -241,10 +241,22 @@ int misc_init_r(void)return 0 ; } +static void dram_size_fixup (void ) +{ +u32 size; + +/* probe currently equipped RAM size */ + size =get_ram_size ((void *)kw_sdram_bar (0 ),kw_sdram_bs (0 )); + +/* fixup SDRAM window size accordingly */ +kw_sdram_bs_set (0 , size); +} +int board_early_init_f (void ) {u32 tmp; +dram_size_fixup ();kirkwood_mpp_conf (kwmpp_config,NULL );/*
Signature · 1 line
1.7.1
PATCH 1/2 kirkwood: implement kw_sdram_bs_set()
In reply to Gerlando FalautoDear Gerlando Falauto,
Quoted 8 lines
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(), to be called for instance withinboard_early_init_f().
[..]
arch/arm/cpu/arm926ejs/kirkwood/dram.c u32 kw_sdram_bs(enum memory_bank bank) · line 74
Quoted 4 lines
arch/arm/cpu/arm926ejs/kirkwood/dram.c +4
-0+/* +* kw_sdram_bs_set - writes SDRAM Bank size +*/ +void kw_sdram_bs_set (enum memory_bank bank,u32 size)
The enum is declared somewhere, right ?
[...]
Best regards,
Marek Vasut
PATCH 1/2 kirkwood: implement kw_sdram_bs_set()
Quoted 10 lines · Marek Vasut
Dear Gerlando Falauto,
Quoted 8 lines
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(), to be called for instance withinboard_early_init_f().
Quoted 8 lines
[..]
arch/arm/cpu/arm926ejs/kirkwood/dram.c u32 kw_sdram_bs(enum memory_bank bank) · line 74
Quoted 4 lines
arch/arm/cpu/arm926ejs/kirkwood/dram.c +4
-0+/* +* kw_sdram_bs_set - writes SDRAM Bank size +*/ +void kw_sdram_bs_set (enum memory_bank bank,u32 size)The enum is declared somewhere, right ?
Yes, in arch/arm/include/asm/arch-kirkwood/cpu.h.
It's the same enum also used by other functions {declared, defined} within the same {header, source} file, like:
u32 kw_sdram_bs(enum memory_bank bank)
Best regards,
Gerlando
PATCH 1/2 kirkwood: implement kw_sdram_bs_set()
Dear Gerlando Falauto,
Quoted 20 lines · Marek Vasut
Quoted 10 lines
Dear Gerlando Falauto,
Quoted 7 lines
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(), to be called for instance withinboard_early_init_f().Quoted 8 lines
[..]
arch/arm/cpu/arm926ejs/kirkwood/dram.c u32 kw_sdram_bs(enum memory_bank bank) · line 74
Quoted 4 lines
arch/arm/cpu/arm926ejs/kirkwood/dram.c +4
-0+/* +* kw_sdram_bs_set - writes SDRAM Bank size +*/ +void kw_sdram_bs_set (enum memory_bank bank,u32 size)The enum is declared somewhere, right ?
Quoted 6 lines
Yes, in
arch/arm/include/asm/arch-kirkwood/cpu.h.It's the same enum also used by other functions {declared, defined} within the same {header, source} file, like:
u32
kw_sdram_bs(enum memory_bank bank)
Good, add my
Quoted 3 lines
Best regards,
Gerlando
Best regards,
Marek Vasut
PATCH v2 1/2 kirkwood: implement kw_sdram_bs_set()
In reply to Gerlando FalautoSome 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(), to be called for instance within board_early_init_f().
---
changes for v2:
added Reviewed-by: Marek Vasut <[email protected]>
arch/arm/cpu/arm926ejs/kirkwood/dram.c | 23 +++++++++++++++++++++++ arch/arm/include/asm/arch-kirkwood/cpu.h | 2 ++ 2 files changed, 25 insertions(+), 0 deletions(-)
arch/arm/cpu/arm926ejs/kirkwood/dram.c +23 -0
@@ -32,6 +32,12 @@ 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)) + +#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 */
@@ -62,6 +68,23 @@ u32 kw_sdram_bs(enum memory_bank bank)return result; } +/* +* kw_sdram_bs_set - writes SDRAM Bank size +*/ +void kw_sdram_bs_set (enum memory_bank bank,u32 size) +{ +/* Read current register value */ +u32 reg =readl (KW_REG_CPUCS_WIN_SZ (bank)); + +/* 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,KW_REG_CPUCS_WIN_SZ (bank)); +} +#ifndef CONFIG_SYS_BOARD_DRAM_INIT int dram_init (void ) {
arch/arm/include/asm/arch-kirkwood/cpu.h +2 -0
@@ -159,6 +159,8 @@ 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_bs_set (enum memory_bank bank,u32 size); +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);
Signature · 1 line
1.7.1
PATCH v2 1/2 kirkwood: implement kw_sdram_bs_set()
Dear Gerlando Falauto,
Quoted 14 lines
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(), to be called for instance withinboard_early_init_f().Signed-off-by Gerlando Falauto <[email protected]>Reviewed-by Marek Vasut <[email protected]>Cc Prafulla Wadaskar <[email protected]>Cc Wolfgang Denk <[email protected]>Cc Valentin Longchamp <[email protected]>Cc Holger Brunck <[email protected]>
Quoted 3 lines
---
changes for v2:
added Reviewed-by: Marek Vasut <[email protected]>
[...]
You don't have to resend it, patchwork does this additions for us :)
Best regards,
Marek Vasut
PATCH v2 1/2 kirkwood: implement kw_sdram_bs_set()
In reply to Gerlando FalautoQuoted 41 lines
-----Original Message-----
From: Gerlando Falauto [mailto:gerlando.falauto at keymile.com]
Sent: 06 July 2012 17:20
To: u-boot at lists.denx.de
Cc: Gerlando Falauto; Prafulla Wadaskar; Wolfgang Denk; Valentin Longchamp; Holger Brunck
Subject: [PATCH v2 1/2] kirkwood: implementkw_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(), to be called for instance withinboard_early_init_f().Signed-off-by Gerlando Falauto <[email protected]>Reviewed-by Marek Vasut <[email protected]>Cc Prafulla Wadaskar <[email protected]>Cc Wolfgang Denk <[email protected]>Cc Valentin Longchamp <[email protected]>Cc Holger Brunck <[email protected]>---
changes for v2:
added Reviewed-by: Marek Vasut <[email protected]>arch/arm/cpu/arm926ejs/kirkwood/dram.c | 23 +++++++++++++++++++++++ arch/arm/include/asm/arch-kirkwood/cpu.h | 2 ++ 2 files changed, 25 insertions(+), 0 deletions(-)arch/arm/cpu/arm926ejs/kirkwood/dram.c +0
-0
arch/arm/cpu/arm926ejs/kirkwood/dram.c DECLARE_GLOBAL_DATA_PTR; · line 36
Quoted 5 lines
arch/arm/cpu/arm926ejs/kirkwood/dram.c +0
-0@@ -32,6 +32,12 @@ 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))
Hi Gerlando
I have a full ack for this patch.
But I would like to ask you-
Since dram.c is going through this change and macros are being used in stead of c-struct for DRAM register variables. This is being one of the todo item pending from long time.
Would you like to convert macros to c-struct definition in this file?
Quoted 39 lines
arch/arm/cpu/arm926ejs/kirkwood/dram.c +6
-0+ +#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 */arch/arm/cpu/arm926ejs/kirkwood/dram.c +17
-0@@ -62,6 +68,23 @@ u32 kw_sdram_bs(enum memory_bank bank)return result; } +/* +* kw_sdram_bs_set - writes SDRAM Bank size +*/ +void kw_sdram_bs_set (enum memory_bank bank,u32 size) +{ +/* Read current register value */ +u32 reg =readl (KW_REG_CPUCS_WIN_SZ (bank)); + +/* 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,KW_REG_CPUCS_WIN_SZ (bank)); +} +#ifndef CONFIG_SYS_BOARD_DRAM_INIT int dram_init (void ) {arch/arm/include/asm/arch-kirkwood/cpu.h +0
-0
arch/arm/include/asm/arch-kirkwood/cpu.h void reset_cpu(unsigned long ignored); · line 163
Quoted 5 lines
arch/arm/include/asm/arch-kirkwood/cpu.h +2
-0@@ -159,6 +159,8 @@ 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_bs_set (enum memory_bank bank,u32 size); +
Please remove this additional line
Quoted 5 lines
arch/arm/include/asm/arch-kirkwood/cpu.h +0
-0int kw_config_adr_windows (void ); void kw_config_gpio(unsigned int gpp0_oe_val, unsigned int gpp1_oe_val,unsigned int
gpp0_oe, unsigned intgpp1_oe);
--
Regards...
Prafulla . . .
Quoted 1 line
1.7.1
PATCH v2 1/2 kirkwood: implement kw_sdram_bs_set()
Dear Prafulla Wadaskar,
[...]
Quoted 22 lines
Quoted 13 lines
arch/arm/cpu/arm926ejs/kirkwood/dram.c +0
-0@@ -32,6 +32,12 @@ 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 *Quoted 1 line
0x08))Hi Gerlando
I have a full ack for this patch.
But I would like to ask you-
Sincedram.cis going through this change and macros are being used in stead of c-struct for DRAM register variables. This is being one of the todo item pending from long time.
Quoted 1 line
Would you like to convert macros to c-struct definition in this file?
Certainly, but let's get this applied first.
[...]
Quoted 7 lines
Quoted 7 lines
arch/arm/include/asm/arch-kirkwood/cpu.h +0
-0@@ -159,6 +159,8 @@ void reset_cpu(unsigned long ignored);
Quoted 8 lines
arch/arm/include/asm/arch-kirkwood/cpu.h void reset_cpu(unsigned long ignored); · line 163
Quoted 6 lines
arch/arm/include/asm/arch-kirkwood/cpu.h +2
-0unsigned 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_bs_set (enum memory_bank bank,u32 size); +Please remove this additional line
Well, maybe you can remove it in the application process since it's really one small thing?
Quoted 13 lines
Quoted 8 lines
arch/arm/include/asm/arch-kirkwood/cpu.h +0
-0int kw_config_adr_windows (void );void kw_config_gpio(unsigned int
gpp0_oe_val, unsigned int
gpp1_oe_val,unsigned int
gpp0_oe, unsigned intgpp1_oe);--
Regards...
Prafulla . . .Quoted 1 line
1.7.1
Best regards,
Marek Vasut
PATCH v2 1/2 kirkwood: implement kw_sdram_bs_set()
Hi Marek, hi Prafulla,
Quoted 26 lines · Marek Vasut
Dear Prafulla Wadaskar,
[...]
Quoted 22 lines
Quoted 13 lines
arch/arm/cpu/arm926ejs/kirkwood/dram.c +0
-0@@ -32,6 +32,12 @@ 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 *Quoted 1 line
0x08))Hi Gerlando
I have a full ack for this patch.
But I would like to ask you-
Sincedram.cis going through this change and macros are being used in stead of c-struct for DRAM register variables. This is being one of the todo item pending from long time.
Quoted 6 lines
Quoted 1 line
Would you like to convert macros to c-struct definition in this file?
Certainly, but let's get this applied first.
[...]
I have done a v3 version of this patchserie with Prafullas inputs. Gerlando is not in these days.
I'll send the updates soon... I have already tested them on km_kirkwood.
Regards
Holger
PATCH v2 2/2 km_arm: enable SDRAM window size fixup
In reply to Gerlando FalautoSize of the SDRAM chips might differ between any two (otherwise identical) instances of the same board.
So change board_early_init_f() to use km_sdram_bs_set(), in order to fixup the window size register at runtime, according to the detected SDRAM size.
---
changes for v2:
- rebase to current u-boot-marvell.git master branch
board/keymile/km_arm/km_arm.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-)
board/keymile/km_arm/km_arm.c +12 -0
@@ -241,6 +241,17 @@ int misc_init_r(void)return 0 ; } +static void dram_size_fixup (void ) +{ +u32 size; + +/* probe currently equipped RAM size */ + size =get_ram_size ((void *)kw_sdram_bar (0 ),kw_sdram_bs (0 )); + +/* fixup SDRAM window size accordingly */ +kw_sdram_bs_set (0 , size); +} +int board_early_init_f (void ) {#if defined(CONFIG_SOFT_I2C )
@@ -251,6 +262,7 @@ int board_early_init_f(void)writel (tmp & (~KM_KIRKWOOD_SOFT_I2C_GPIOS ) ,KW_GPIO0_BASE +4 );#endif +dram_size_fixup ();kirkwood_mpp_conf (kwmpp_config,NULL );return 0 ; }
Signature · 1 line
1.7.1
PATCH v2 2/2 km_arm: enable SDRAM window size fixup
Quoted 34 lines
-----Original Message-----
From: u-boot-bounces at lists.denx.de [mailto:u-boot- bounces at lists.denx.de] On Behalf Of Gerlando Falauto
Sent: 06 July 2012 17:20
To: u-boot at lists.denx.de
Cc: Valentin Longchamp; Holger Brunck; Gerlando Falauto
Subject: [U-Boot] [PATCH v2 2/2]km_arm: enable SDRAM window size fixupSize of the SDRAM chips might differ between any two (otherwise identical) instances of the same board.
So change
board_early_init_f()to usekm_sdram_bs_set(), in order to fixup the window size register at runtime, according to the detected SDRAM size.Signed-off-by Gerlando Falauto <[email protected]>Cc Valentin Longchamp <[email protected]>Cc Holger Brunck <[email protected]>---
changes for v2:
- rebase to current u-boot-marvell.git master branchboard/keymile/km_arm/km_arm.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-)board/keymile/km_arm/km_arm.c +0
-0
board/keymile/km_arm/km_arm.c int misc_init_r(void) · line 244
Quoted 4 lines
board/keymile/km_arm/km_arm.c +1
-0@@ -241,6 +241,17 @@ int misc_init_r(void)return 0 ; } +static void dram_size_fixup (void )
The name "fixup" doesn't sound good.
board/keymile/km_arm/km_arm.c int misc_init_r(void) · line 254
Quoted 10 lines
board/keymile/km_arm/km_arm.c +10
-0+{ +u32 size; + +/* probe currently equipped RAM size */ + size =get_ram_size ((void *)kw_sdram_bar (0 ),kw_sdram_bs (0 )); + +/* fixup SDRAM window size accordingly */ +kw_sdram_bs_set (0 , size); +} +
This is useful API for other boards too.
I would like to suggest to add this change in dram_init(), the window size can be corrected right after sdram size detection. And that will be applicable for all supported bank.
So may you please push in to dram.c?
Regards...
Prafulla . . .