Message ID | 1340969874-12869-1-git-send-email-gerlando.falauto@keymile.com |
---|---|
State | Superseded |
Delegated to: | Prafulla Wadaskar |
Headers | show |
Hi Gerlando, On Fri, 29 Jun 2012 13:37:54 +0200, Gerlando Falauto <gerlando.falauto@keymile.com> wrote: > 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(). > > Signed-off-by: Gerlando Falauto <gerlando.falauto@keymile.com> > Cc: Marek Vasut <marex@denx.de> > Cc: Prafulla Wadaskar <prafulla@marvell.com> > Cc: Wolfgang Denk <wd@denx.de> > Cc: Valentin Longchamp <valentin.longchamp@keymile.com> > Cc: Holger Brunck <holger.brunck@keymile.com> > --- > arch/arm/cpu/arm926ejs/kirkwood/dram.c | 28 > ++++++++++++++++++++++++++-- arch/arm/include/asm/arch-kirkwood/cpu.h > | 2 ++ 2 files changed, 28 insertions(+), 2 deletions(-) > > diff --git a/arch/arm/cpu/arm926ejs/kirkwood/dram.c > b/arch/arm/cpu/arm926ejs/kirkwood/dram.c index 2441554..e5409f1 100644 > --- a/arch/arm/cpu/arm926ejs/kirkwood/dram.c > +++ b/arch/arm/cpu/arm926ejs/kirkwood/dram.c > @@ -28,8 +28,15 @@ > > 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)) +/* Kirkwood memory registers */ > +#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 > */ > @@ -60,6 +67,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) > { > diff --git a/arch/arm/include/asm/arch-kirkwood/cpu.h > b/arch/arm/include/asm/arch-kirkwood/cpu.h index d28c51a..807154e > 100644 --- a/arch/arm/include/asm/arch-kirkwood/cpu.h > +++ b/arch/arm/include/asm/arch-kirkwood/cpu.h > @@ -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); I don't like isolated patches that seem to create dead code. I know here it is not the goal, of course; so why not submit a two-patch series, providing both the new code *and* a use for it? Amicalement,
Hi Albert, On 07/05/2012 12:39 PM, Albert ARIBAUD wrote: > Hi Gerlando, > > On Fri, 29 Jun 2012 13:37:54 +0200, Gerlando Falauto > <gerlando.falauto@keymile.com> wrote: >> 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(). >> [...] > > I don't like isolated patches that seem to create dead code. I know > here it is not the goal, of course; so why not submit a two-patch > series, providing both the new code *and* a use for it? > You're absolutely right. But mine was more of an interruption/suggestion throughout the discussion between Marek and Prafulla... I just didn't want to take credit for someone else's code, or create any conflicts with it. I figured it might be quicker (and more fair) that way, perhaps with Marek resubmitting it within his own series, or SoB-ing it, because in fact mine is just a refactoring of his idea... I can of course submit the two-patch series for our boards, if that's OK with Marek. Thanks, Gerlando
Hi Gerlando, On Thu, 05 Jul 2012 12:57:44 +0200, Gerlando Falauto <gerlando.falauto@keymile.com> wrote: > Hi Albert, > > On 07/05/2012 12:39 PM, Albert ARIBAUD wrote: > > Hi Gerlando, > > > > On Fri, 29 Jun 2012 13:37:54 +0200, Gerlando Falauto > > <gerlando.falauto@keymile.com> wrote: > >> 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(). > >> > [...] > > > > I don't like isolated patches that seem to create dead code. I know > > here it is not the goal, of course; so why not submit a two-patch > > series, providing both the new code *and* a use for it? > > You're absolutely right. > But mine was more of an interruption/suggestion throughout the > discussion between Marek and Prafulla... I just didn't want to take > credit for someone else's code, or create any conflicts with it. Understood. Next time, please just add [RFC] in the subject, so that the patch is not considered for inclusion. > I figured it might be quicker (and more fair) that way, perhaps with > Marek resubmitting it within his own series, or SoB-ing it, because > in fact mine is just a refactoring of his idea... > I can of course submit the two-patch series for our boards, if that's > OK with Marek. That's to be sorted between Marek and you. :) > Thanks, > Gerlando Amicalement,
> -----Original Message----- > From: Albert ARIBAUD [mailto:albert.u.boot@aribaud.net] > Sent: 05 July 2012 16:32 > To: Gerlando Falauto > Cc: u-boot@lists.denx.de; Marek Vasut; Longchamp, Valentin; Brunck, > Holger; Prafulla Wadaskar > Subject: Re: [U-Boot] [PATCH] kirkwood: implement kw_sdram_bs_set() > > Hi Gerlando, > > On Thu, 05 Jul 2012 12:57:44 +0200, Gerlando Falauto > <gerlando.falauto@keymile.com> wrote: > > Hi Albert, > > > > On 07/05/2012 12:39 PM, Albert ARIBAUD wrote: > > > Hi Gerlando, > > > > > > On Fri, 29 Jun 2012 13:37:54 +0200, Gerlando Falauto > > > <gerlando.falauto@keymile.com> wrote: > > >> 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(). > > >> > > [...] > > > > > > I don't like isolated patches that seem to create dead code. I > know > > > here it is not the goal, of course; so why not submit a two-patch > > > series, providing both the new code *and* a use for it? > > > > You're absolutely right. > > But mine was more of an interruption/suggestion throughout the > > discussion between Marek and Prafulla... I just didn't want to take > > credit for someone else's code, or create any conflicts with it. > > Understood. Next time, please just add [RFC] in the subject, so that > the patch is not considered for inclusion. > > > I figured it might be quicker (and more fair) that way, perhaps with > > Marek resubmitting it within his own series, or SoB-ing it, because > > in fact mine is just a refactoring of his idea... > > I can of course submit the two-patch series for our boards, if > that's > > OK with Marek. > > That's to be sorted between Marek and you. :) Hi Gerlando Marek's board support for TK71 is pulled in, may be this patch will be useful for his next board support (if any). BTW: you can always submit it as a part of patch series for your boards. Regards... Prafulla . . .
diff --git a/arch/arm/cpu/arm926ejs/kirkwood/dram.c b/arch/arm/cpu/arm926ejs/kirkwood/dram.c index 2441554..e5409f1 100644 --- a/arch/arm/cpu/arm926ejs/kirkwood/dram.c +++ b/arch/arm/cpu/arm926ejs/kirkwood/dram.c @@ -28,8 +28,15 @@ 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)) +/* Kirkwood memory registers */ +#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 */ @@ -60,6 +67,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) { diff --git a/arch/arm/include/asm/arch-kirkwood/cpu.h b/arch/arm/include/asm/arch-kirkwood/cpu.h index d28c51a..807154e 100644 --- a/arch/arm/include/asm/arch-kirkwood/cpu.h +++ b/arch/arm/include/asm/arch-kirkwood/cpu.h @@ -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);
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(). Signed-off-by: Gerlando Falauto <gerlando.falauto@keymile.com> Cc: Marek Vasut <marex@denx.de> Cc: Prafulla Wadaskar <prafulla@marvell.com> Cc: Wolfgang Denk <wd@denx.de> Cc: Valentin Longchamp <valentin.longchamp@keymile.com> Cc: Holger Brunck <holger.brunck@keymile.com> --- arch/arm/cpu/arm926ejs/kirkwood/dram.c | 28 ++++++++++++++++++++++++++-- arch/arm/include/asm/arch-kirkwood/cpu.h | 2 ++ 2 files changed, 28 insertions(+), 2 deletions(-)