Re: [U-Boot] [PATCH v5 16/23] Adjust board_f.c for ppc
On 02/12/2013 04:41:15 PM, Simon Glass wrote: Hi Scott, On Tue, Feb 12, 2013 at 2:32 PM, Scott Wood wrote: > On 02/08/2013 09:12:12 AM, Simon Glass wrote: >> >> #ifndef CONFIG_SPL_BUILD >> static int reserve_stacks(void) >> { >> +#ifdef CONFIG_PPC >> + ulong *s; >> +#endif >> + >> /* setup stack pointer for exceptions */ >> gd->dest_addr_sp -= 16; >> gd->dest_addr_sp &= ~0xf; >> @@ -398,6 +532,14 @@ static int reserve_stacks(void) >> /* leave 3 words for abort-stack, plus 1 for alignment */ >> gd->dest_addr_sp -= 16; >> >> +#ifdef CONFIG_PPC >> + /* Clear initial stack frame */ >> + s = (ulong *) gd->dest_addr_sp; >> + *s = 0; /* Terminate back chain */ >> + *++s = 0; /* NULL return address */ >> + gd->dest_addr_sp = (ulong) s; >> +#endif >> + > > > PPC ABI requires 16-byte stack alignment, which would be broken by the > CONFIG_USE_IRQ section (which even still has an "ARM ABI" comment). > > I think this entire function should be kept in arch code. Stack layout is > inherently architecture/ABI specific. Some architectures even have a stack > that grows upward (not sure if any such are supported by U-Boot). Thanks for reviewing all this. While I am working to avoid it, one option is to create a weak function which archs can override. The reason I am keen to avoid it, at least for a first implementation, is that it obscures the similarities. That's fine for most of the file, but I think there's not much that's truly generic when it comes to setting up the stack. It's not as if this is a huge function (at least before it grows a bunch of ifdefs). In this case we could just just force 16-byte alignment, and make the PPC code unconditional. It shouldn't hurt anything. The CONFIG_USE_IRQ section also has references to FIQs... if it's meant to be an ARM-specific CONFIG, perhaps it should be renamed (and definitely it should be documented). -Scott ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v5 16/23] Adjust board_f.c for ppc
Hi Scott, On Tue, Feb 12, 2013 at 2:32 PM, Scott Wood wrote: > On 02/08/2013 09:12:12 AM, Simon Glass wrote: >> >> #ifndef CONFIG_SPL_BUILD >> static int reserve_stacks(void) >> { >> +#ifdef CONFIG_PPC >> + ulong *s; >> +#endif >> + >> /* setup stack pointer for exceptions */ >> gd->dest_addr_sp -= 16; >> gd->dest_addr_sp &= ~0xf; >> @@ -398,6 +532,14 @@ static int reserve_stacks(void) >> /* leave 3 words for abort-stack, plus 1 for alignment */ >> gd->dest_addr_sp -= 16; >> >> +#ifdef CONFIG_PPC >> + /* Clear initial stack frame */ >> + s = (ulong *) gd->dest_addr_sp; >> + *s = 0; /* Terminate back chain */ >> + *++s = 0; /* NULL return address */ >> + gd->dest_addr_sp = (ulong) s; >> +#endif >> + > > > PPC ABI requires 16-byte stack alignment, which would be broken by the > CONFIG_USE_IRQ section (which even still has an "ARM ABI" comment). > > I think this entire function should be kept in arch code. Stack layout is > inherently architecture/ABI specific. Some architectures even have a stack > that grows upward (not sure if any such are supported by U-Boot). Thanks for reviewing all this. While I am working to avoid it, one option is to create a weak function which archs can override. The reason I am keen to avoid it, at least for a first implementation, is that it obscures the similarities. In this case we could just just force 16-byte alignment, and make the PPC code unconditional. It shouldn't hurt anything. Regards, Simon > > -Scott ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v5 16/23] Adjust board_f.c for ppc
On 02/08/2013 09:12:12 AM, Simon Glass wrote: #ifndef CONFIG_SPL_BUILD static int reserve_stacks(void) { +#ifdef CONFIG_PPC + ulong *s; +#endif + /* setup stack pointer for exceptions */ gd->dest_addr_sp -= 16; gd->dest_addr_sp &= ~0xf; @@ -398,6 +532,14 @@ static int reserve_stacks(void) /* leave 3 words for abort-stack, plus 1 for alignment */ gd->dest_addr_sp -= 16; +#ifdef CONFIG_PPC + /* Clear initial stack frame */ + s = (ulong *) gd->dest_addr_sp; + *s = 0; /* Terminate back chain */ + *++s = 0; /* NULL return address */ + gd->dest_addr_sp = (ulong) s; +#endif + PPC ABI requires 16-byte stack alignment, which would be broken by the CONFIG_USE_IRQ section (which even still has an "ARM ABI" comment). I think this entire function should be kept in arch code. Stack layout is inherently architecture/ABI specific. Some architectures even have a stack that grows upward (not sure if any such are supported by U-Boot). -Scott ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v5 16/23] Adjust board_f.c for ppc
This adds ppc features to the generic pre-relocation board init. This is a separate commit so that these features are clearly shown. Signed-off-by: Simon Glass --- Changes in v5: - Use watchdog.h for watchdog functions - Add define to work around __bss_end / __bss_end__ confusion Changes in v4: - Updates to sit on top of earlier patches Changes in v3: None Changes in v2: None common/board_f.c | 347 ++- 1 file changed, 345 insertions(+), 2 deletions(-) diff --git a/common/board_f.c b/common/board_f.c index db3ef0a..4dfac6e 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -31,10 +31,31 @@ #include #include #include +#if defined(CONFIG_CMD_IDE) +#include +#endif +#include #include #include + +/* TODO: Can we move these into arch/ headers? */ +#ifdef CONFIG_8xx +#include +#endif +#ifdef CONFIG_5xx +#include +#endif +#ifdef CONFIG_MPC5xxx +#include +#endif + #include +#include +#include #include +#ifdef CONFIG_MP +#include +#endif #include #include @@ -97,6 +118,31 @@ void blue_led_off(void) __attribute__((weak, alias("__blue_led_off"))); * Could the CONFIG_SPL_BUILD infection become a flag in gd? */ +#if defined(CONFIG_WATCHDOG) +static int init_func_watchdog_init(void) +{ + puts(" Watchdog enabled\n"); + WATCHDOG_RESET(); + + return 0; +} + +int init_func_watchdog_reset(void) +{ + WATCHDOG_RESET(); + + return 0; +} +#endif /* CONFIG_WATCHDOG */ + +void __board_add_ram_info(int use_default) +{ + /* please define platform specific board_add_ram_info() */ +} + +void board_add_ram_info(int) + __attribute__ ((weak, alias("__board_add_ram_info"))); + static int init_baud_rate(void) { gd->baudrate = getenv_ulong("baudrate", 10, CONFIG_BAUDRATE); @@ -134,6 +180,25 @@ static int announce_dram_init(void) return 0; } +#ifdef CONFIG_PPC +static int init_func_ram(void) +{ +#ifdef CONFIG_BOARD_TYPES + int board_type = gd->board_type; +#else + int board_type = 0; /* use dummy arg */ +#endif + + gd->ram_size = initdram(board_type); + + if (gd->ram_size > 0) + return 0; + + puts("*** failed ***\n"); + return 1; +} +#endif + static int show_dram_config(void) { ulong size; @@ -154,11 +219,24 @@ static int show_dram_config(void) size = gd->ram_size; #endif - print_size(size, "\n"); + print_size(size, ""); + board_add_ram_info(0); + putc('\n'); return 0; } +ulong get_effective_memsize(void) +{ +#ifndefCONFIG_VERY_BIG_RAM + return gd->ram_size; +#else + /* limit stack to what we can reasonable map */ + return ((gd->ram_size > CONFIG_MAX_MEM_MAPPED) ? + CONFIG_MAX_MEM_MAPPED : gd->ram_size); +#endif +} + void __dram_init_banksize(void) { #if defined(CONFIG_NR_DRAM_BANKS) && defined(CONFIG_SYS_SDRAM_BASE) @@ -170,6 +248,27 @@ void __dram_init_banksize(void) void dram_init_banksize(void) __attribute__((weak, alias("__dram_init_banksize"))); +#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C) +static int init_func_i2c(void) +{ + puts("I2C: "); + i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE); + puts("ready\n"); + return 0; +} +#endif + +#if defined(CONFIG_HARD_SPI) +static int init_func_spi(void) +{ + puts("SPI: "); + spi_init(); + puts("ready\n"); + return 0; +} +#endif + +__maybe_unused static int zero_global_data(void) { memset((void *)gd, '\0', sizeof(gd_t)); @@ -182,7 +281,8 @@ static int setup_mon_len(void) #ifdef CONFIG_SYS_SYM_OFFSETS gd->mon_len = _bss_end_ofs; #else - gd->mon_len = (ulong)&__bss_end - (ulong)&__text_start; + /* TODO: use (ulong)&__bss_end - (ulong)&__text_start; ? */ + gd->mon_len = (ulong)&__bss_end - CONFIG_SYS_MONITOR_BASE; #endif return 0; } @@ -237,9 +337,23 @@ static int setup_dest_addr(void) */ gd->ram_size -= CONFIG_SYS_MEM_TOP_HIDE; #endif +#ifdef CONFIG_NR_DRAM_BANKS gd->ram_top = gd->bd->bi_dram[0].start + gd->bd->bi_dram[0].size; +#else + gd->ram_top = CONFIG_SYS_SDRAM_BASE + get_effective_memsize(); +#endif gd->ram_top = board_get_usable_ram_top(gd->mon_len); gd->dest_addr = gd->ram_top; +#if defined(CONFIG_MP) && (defined(CONFIG_MPC86xx) || defined(CONFIG_E500)) + /* +* We need to make sure the location we intend to put secondary core +* boot code is reserved and not used by any part of u-boot +*/ + if (gd->dest_addr > determine_mp_bootpg(NULL)) { + gd->dest_addr = determine_mp_bootpg(NULL); + debug("Reserving MP boot page to %08lx\n", gd->dest_addr); + } +#endif gd->dest_addr_sp = gd->dest_addr; return 0; } @@ -308,6 +422,18 @@ static int reserve_lcd(void) } #endif /* CONFIG_LCD */ +#if defined(CONFIG_VIDEO) && (!de