[U-Boot] [PATCH v3 0/7] overo: add SPL support

V1 -> V2 * cleanups: replace printf with one argument by puts [1-2] * cleanups: remove unused macros and macro values / tabbing / remove FSF address [3] * i2c: move all local variables to SRAM [4] * OMAP SPL: call timer_init in s_init to make udelay work earlier [5] * hint CONFIG_SYS_TEXT_BASE changed in commit message [6] * remove log 'Texas Instruments Revision detection unimplemented' for overo [6] * remove unintended whitespaces [6] * send 'shut up' to TWL4030 to avoid corruption when reading board revision [6] * use macros for overo revisions [6] * don't separate SPL specific configurations [6]
V2 -> V3 * modify omap_rev_string [6] * CONFIG_SYS_TEXT_BASE back to 0x80008000 [7] * modify CONFIG_SYS_SPL_MALLOC_START / CONFIG_SYS_SPL_MALLOC_SIZE / CONFIG_SPL_BSS_START_ADDR to avoid conflicts with CONFIG_SYS_TEXT_BASE [7]
Andreas Müller (7): drivers/i2c/omap24xx_i2c.c: replace printf with one argument by puts board/overo/overo.c: replace printf with one argument by puts include/configs/omap3_overo.h: several cleanups drivers/i2c/omap24xx_i2c.c: move all local variables to SRAM OMAP SPL: call timer_init in s_init to make udelay work earlier omap_rev_string: output to stdout overo: add SPL support
arch/arm/cpu/armv7/omap-common/hwinit-common.c | 10 +- arch/arm/cpu/armv7/omap-common/spl.c | 12 +-- arch/arm/cpu/armv7/omap3/board.c | 2 + arch/arm/include/asm/arch-omap3/mem.h | 26 +++++ arch/arm/include/asm/arch-omap4/sys_proto.h | 2 +- arch/arm/include/asm/arch-omap5/sys_proto.h | 2 +- arch/arm/include/asm/omap_common.h | 2 +- board/overo/config.mk | 28 ------ board/overo/overo.c | 79 ++++++++++++++-- board/overo/overo.h | 9 ++ drivers/i2c/omap24xx_i2c.c | 25 +++-- include/configs/omap3_overo.h | 121 ++++++++++++++++-------- 12 files changed, 217 insertions(+), 101 deletions(-) delete mode 100644 board/overo/config.mk

Signed-off-by: Andreas Müller schnitzeltony@gmx.de --- drivers/i2c/omap24xx_i2c.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/i2c/omap24xx_i2c.c b/drivers/i2c/omap24xx_i2c.c index 4ae237a..271ed60 100644 --- a/drivers/i2c/omap24xx_i2c.c +++ b/drivers/i2c/omap24xx_i2c.c @@ -73,7 +73,7 @@ void i2c_init(int speed, int slaveadd) fssclh -= I2C_HIGHSPEED_PHASE_ONE_SCLH_TRIM; if (((fsscll < 0) || (fssclh < 0)) || ((fsscll > 255) || (fssclh > 255))) { - printf("Error : I2C initializing first phase clock\n"); + puts("Error : I2C initializing first phase clock\n"); return; }
@@ -84,7 +84,7 @@ void i2c_init(int speed, int slaveadd) hssclh -= I2C_HIGHSPEED_PHASE_TWO_SCLH_TRIM; if (((fsscll < 0) || (fssclh < 0)) || ((fsscll > 255) || (fssclh > 255))) { - printf("Error : I2C initializing second phase clock\n"); + puts("Error : I2C initializing second phase clock\n"); return; }
@@ -99,7 +99,7 @@ void i2c_init(int speed, int slaveadd) fssclh -= I2C_FASTSPEED_SCLH_TRIM; if (((fsscll < 0) || (fssclh < 0)) || ((fsscll > 255) || (fssclh > 255))) { - printf("Error : I2C initializing clock\n"); + puts("Error : I2C initializing clock\n"); return; }
@@ -118,7 +118,7 @@ void i2c_init(int speed, int slaveadd) writew(I2C_CON_EN, &i2c_base->con); while (!(readw(&i2c_base->syss) & I2C_SYSS_RDONE) && timeout--) { if (timeout <= 0) { - printf("ERROR: Timeout in soft-reset\n"); + puts("ERROR: Timeout in soft-reset\n"); return; } udelay(1000); @@ -284,13 +284,13 @@ int i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len) }
if (addr + len > 256) { - printf("I2C read: address out of range\n"); + puts("I2C read: address out of range\n"); return 1; }
for (i = 0; i < len; i++) { if (i2c_read_byte(chip, addr + i, &buffer[i])) { - printf("I2C read: I/O error\n"); + puts("I2C read: I/O error\n"); i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE); return 1; }

Hello Andreas,
Andreas Müller wrote:
Signed-off-by: Andreas Müller schnitzeltony@gmx.de
drivers/i2c/omap24xx_i2c.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-)
Acked-by: Heiko Schocher hs@denx.de
bye, Heiko

Signed-off-by: Andreas Müller schnitzeltony@gmx.de --- board/overo/overo.c | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/board/overo/overo.c b/board/overo/overo.c index 3c60b06..4a20c7f 100644 --- a/board/overo/overo.c +++ b/board/overo/overo.c @@ -119,7 +119,7 @@ int get_board_revision(void) gpio_get_value(113) << 1 | gpio_get_value(112); } else { - printf("Error: unable to acquire board revision GPIOs\n"); + puts("Error: unable to acquire board revision GPIOs\n"); revision = -1; }
@@ -151,7 +151,7 @@ int get_sdio2_config(void)
gpio_direction_input(130); } else { - printf("Error: unable to acquire sdio2 clk GPIOs\n"); + puts("Error: unable to acquire sdio2 clk GPIOs\n"); sdio_direct = -1; }
@@ -200,15 +200,15 @@ int misc_init_r(void)
switch (get_sdio2_config()) { case 0: - printf("Tranceiver detected on mmc2\n"); + puts("Tranceiver detected on mmc2\n"); MUX_OVERO_SDIO2_TRANSCEIVER(); break; case 1: - printf("Direct connection on mmc2\n"); + puts("Direct connection on mmc2\n"); MUX_OVERO_SDIO2_DIRECT(); break; default: - printf("Unable to detect mmc2 connection type\n"); + puts("Unable to detect mmc2 connection type\n"); }
switch (get_expansion_id()) { @@ -269,10 +269,10 @@ int misc_init_r(void) setenv("defaultdisplay", "dvi"); break; case GUMSTIX_NO_EEPROM: - printf("No EEPROM on expansion board\n"); + puts("No EEPROM on expansion board\n"); break; default: - printf("Unrecognized expansion board\n"); + puts("Unrecognized expansion board\n"); }
if (expansion_config.content == 1)

* remove unused macros * remove unused macro values * align tabs * remove Free Software Foundation address
Signed-off-by: Andreas Müller schnitzeltony@gmx.de --- include/configs/omap3_overo.h | 69 ++++++++++++++++++---------------------- 1 files changed, 31 insertions(+), 38 deletions(-)
diff --git a/include/configs/omap3_overo.h b/include/configs/omap3_overo.h index 79eb466..8f2e69d 100644 --- a/include/configs/omap3_overo.h +++ b/include/configs/omap3_overo.h @@ -13,8 +13,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA + * Foundation, Inc. */
#ifndef __CONFIG_H @@ -23,41 +22,41 @@ /* * High Level Configuration Options */ -#define CONFIG_OMAP 1 /* in a TI OMAP core */ -#define CONFIG_OMAP34XX 1 /* which is a 34XX */ -#define CONFIG_OMAP3_OVERO 1 /* working with overo */ +#define CONFIG_OMAP /* in a TI OMAP core */ +#define CONFIG_OMAP34XX /* which is a 34XX */ +#define CONFIG_OMAP3_OVERO /* working with overo */
-#define CONFIG_SDRC /* The chip has SDRC controller */ +#define CONFIG_SDRC /* The chip has SDRC controller */
-#include <asm/arch/cpu.h> /* get chip and board defs */ +#include <asm/arch/cpu.h> /* get chip and board defs */ #include <asm/arch/omap3.h>
/* * Display CPU and Board information */ -#define CONFIG_DISPLAY_CPUINFO 1 -#define CONFIG_DISPLAY_BOARDINFO 1 +#define CONFIG_DISPLAY_CPUINFO +#define CONFIG_DISPLAY_BOARDINFO
/* Clock Defines */ #define V_OSCK 26000000 /* Clock output from T2 */ #define V_SCLK (V_OSCK >> 1)
-#undef CONFIG_USE_IRQ /* no support for IRQs */ +#undef CONFIG_USE_IRQ /* no support for IRQs */ #define CONFIG_MISC_INIT_R
-#define CONFIG_CMDLINE_TAG 1 /* enable passing of ATAGs */ -#define CONFIG_SETUP_MEMORY_TAGS 1 -#define CONFIG_INITRD_TAG 1 -#define CONFIG_REVISION_TAG 1 +#define CONFIG_CMDLINE_TAG /* enable passing of ATAGs */ +#define CONFIG_SETUP_MEMORY_TAGS +#define CONFIG_INITRD_TAG +#define CONFIG_REVISION_TAG
-#define CONFIG_OF_LIBFDT 1 +#define CONFIG_OF_LIBFDT
/* * Size of malloc() pool */ -#define CONFIG_ENV_SIZE (128 << 10) /* 128 KiB */ +#define CONFIG_ENV_SIZE (128 << 10) /* 128 KiB */ /* Sector */ -#define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SIZE + (128 << 10)) +#define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SIZE + (128 << 10))
/* * Hardware drivers @@ -66,7 +65,7 @@ /* * NS16550 Configuration */ -#define V_NS16550_CLK 48000000 /* 48MHz (APLL96/2) */ +#define V_NS16550_CLK 48000000 /* 48MHz (APLL96/2) */
#define CONFIG_SYS_NS16550 #define CONFIG_SYS_NS16550_SERIAL @@ -85,13 +84,10 @@ #define CONFIG_BAUDRATE 115200 #define CONFIG_SYS_BAUDRATE_TABLE {4800, 9600, 19200, 38400, 57600, \ 115200} -#define CONFIG_GENERIC_MMC 1 -#define CONFIG_MMC 1 -#define CONFIG_OMAP_HSMMC 1 -#define CONFIG_DOS_PARTITION 1 - -/* DDR - I use Micron DDR */ -#define CONFIG_OMAP3_MICRON_DDR 1 +#define CONFIG_GENERIC_MMC +#define CONFIG_MMC +#define CONFIG_OMAP_HSMMC +#define CONFIG_DOS_PARTITION
/* commands to include */ #include <config_cmd_default.h> @@ -113,31 +109,29 @@ #define CONFIG_CMD_NET /* bootp, tftpboot, rarpboot */
#define CONFIG_SYS_NO_FLASH -#define CONFIG_HARD_I2C 1 +#define CONFIG_HARD_I2C #define CONFIG_SYS_I2C_SPEED 100000 #define CONFIG_SYS_I2C_SLAVE 1 -#define CONFIG_SYS_I2C_BUS 0 -#define CONFIG_SYS_I2C_BUS_SELECT 1 -#define CONFIG_I2C_MULTI_BUS 1 -#define CONFIG_DRIVER_OMAP34XX_I2C 1 +#define CONFIG_I2C_MULTI_BUS +#define CONFIG_DRIVER_OMAP34XX_I2C
/* * TWL4030 */ -#define CONFIG_TWL4030_POWER 1 -#define CONFIG_TWL4030_LED 1 +#define CONFIG_TWL4030_POWER +#define CONFIG_TWL4030_LED
/* * Board NAND Info. */ -#define CONFIG_SYS_NAND_QUIET_TEST 1 +#define CONFIG_SYS_NAND_QUIET_TEST #define CONFIG_NAND_OMAP_GPMC #define CONFIG_SYS_NAND_ADDR NAND_BASE /* physical address */ /* to access nand */ #define CONFIG_SYS_NAND_BASE NAND_BASE /* physical address */ /* to access nand */ /* at CS0 */ -#define GPMC_NAND_ECC_LP_x16_LAYOUT 1 +#define GPMC_NAND_ECC_LP_x16_LAYOUT
#define CONFIG_SYS_MAX_NAND_DEVICE 1 /* Max number of NAND */ /* devices */ @@ -249,7 +243,6 @@ */ #define CONFIG_NR_DRAM_BANKS 2 /* CS1 may or may not be populated */ #define PHYS_SDRAM_1 OMAP34XX_SDRC_CS0 -#define PHYS_SDRAM_1_SIZE (32 << 20) /* at least 32 MiB */ #define PHYS_SDRAM_2 OMAP34XX_SDRC_CS1
/*----------------------------------------------------------------------- @@ -272,7 +265,7 @@ #define CONFIG_SYS_MONITOR_BASE CONFIG_SYS_FLASH_BASE #define CONFIG_SYS_ONENAND_BASE ONENAND_MAP
-#define CONFIG_ENV_IS_IN_NAND 1 +#define CONFIG_ENV_IS_IN_NAND #define ONENAND_ENV_OFFSET 0x240000 /* environment starts here */ #define SMNAND_ENV_OFFSET 0x240000 /* environment starts here */
@@ -286,9 +279,9 @@ *---------------------------------------------------------------------------- */
-#define CONFIG_SMC911X 1 +#define CONFIG_SMC911X #define CONFIG_SMC911X_32_BIT -#define CONFIG_SMC911X_BASE 0x2C000000 +#define CONFIG_SMC911X_BASE 0x2C000000
#endif /* (CONFIG_CMD_NET) */

At old overo boards TWL4030 RTC irq is connected to gpio112. Unfortunately this pin is also used for revision detection. Therefore we need to send shut-up to TWL4030 to avoid reading wrong revision. In SPL this must be done before SDRAM is set up because the type of SDRAM is revision dependent. By this patch it is ensured that all variables used by omap24xx_i2c.c are located in SRAM.
Signed-off-by: Andreas Müller schnitzeltony@gmx.de --- drivers/i2c/omap24xx_i2c.c | 13 +++++++++---- 1 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/drivers/i2c/omap24xx_i2c.c b/drivers/i2c/omap24xx_i2c.c index 271ed60..44290b4 100644 --- a/drivers/i2c/omap24xx_i2c.c +++ b/drivers/i2c/omap24xx_i2c.c @@ -35,10 +35,15 @@ static void wait_for_bb(void); static u16 wait_for_pin(void); static void flush_fifo(void);
-static struct i2c *i2c_base = (struct i2c *)I2C_DEFAULT_BASE; - -static unsigned int bus_initialized[I2C_BUS_MAX]; -static unsigned int current_bus; +/* + * For SPL boot some boards need i2c before SDRAM is initialised so force + * variables to live in SRAM + */ +static struct i2c __attribute__ ((section (".data"))) *i2c_base = + (struct i2c *)I2C_DEFAULT_BASE; +static unsigned int __attribute__ ((section (".data"))) bus_initialized[I2C_BUS_MAX] = + { [0 ... (I2C_BUS_MAX-1)] = 0 }; +static unsigned int __attribute__ ((section (".data"))) current_bus = 0;
void i2c_init(int speed, int slaveadd) {

Hello Andreas,
Andreas Müller wrote:
At old overo boards TWL4030 RTC irq is connected to gpio112. Unfortunately this pin is also used for revision detection. Therefore we need to send shut-up to TWL4030 to avoid reading wrong revision. In SPL this must be done before SDRAM is set up because the type of SDRAM is revision dependent. By this patch it is ensured that all variables used by omap24xx_i2c.c are located in SRAM.
Signed-off-by: Andreas Müller schnitzeltony@gmx.de
drivers/i2c/omap24xx_i2c.c | 13 +++++++++---- 1 files changed, 9 insertions(+), 4 deletions(-)
Acked-by: Heiko Schocher hs@denx.de
Thanks!
bye, Heiko

On Wed, Jan 4, 2012 at 6:26 PM, Andreas Müller schnitzeltony@gmx.de wrote:
At old overo boards TWL4030 RTC irq is connected to gpio112. Unfortunately this pin is also used for revision detection. Therefore we need to send shut-up to TWL4030 to avoid reading wrong revision. In SPL this must be done before SDRAM is set up because the type of SDRAM is revision dependent. By this patch it is ensured that all variables used by omap24xx_i2c.c are located in SRAM.
Signed-off-by: Andreas Müller schnitzeltony@gmx.de
drivers/i2c/omap24xx_i2c.c | 13 +++++++++---- 1 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/drivers/i2c/omap24xx_i2c.c b/drivers/i2c/omap24xx_i2c.c index 271ed60..44290b4 100644 --- a/drivers/i2c/omap24xx_i2c.c +++ b/drivers/i2c/omap24xx_i2c.c @@ -35,10 +35,15 @@ static void wait_for_bb(void); static u16 wait_for_pin(void); static void flush_fifo(void);
-static struct i2c *i2c_base = (struct i2c *)I2C_DEFAULT_BASE;
-static unsigned int bus_initialized[I2C_BUS_MAX]; -static unsigned int current_bus; +/*
- For SPL boot some boards need i2c before SDRAM is initialised so force
- variables to live in SRAM
- */
+static struct i2c __attribute__ ((section (".data"))) *i2c_base =
- (struct i2c *)I2C_DEFAULT_BASE;
__attribute__ ((...)) is a checkpatch warning, so I've changed this to __attribute__((..)) in my commit.

Signed-off-by: Andreas Müller schnitzeltony@gmx.de --- arch/arm/cpu/armv7/omap-common/spl.c | 2 -- arch/arm/cpu/armv7/omap3/board.c | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/arm/cpu/armv7/omap-common/spl.c b/arch/arm/cpu/armv7/omap-common/spl.c index 9c35a09..74fea4f 100644 --- a/arch/arm/cpu/armv7/omap-common/spl.c +++ b/arch/arm/cpu/armv7/omap-common/spl.c @@ -115,8 +115,6 @@ void board_init_r(gd_t *id, ulong dummy) mem_malloc_init(CONFIG_SYS_SPL_MALLOC_START, CONFIG_SYS_SPL_MALLOC_SIZE);
- timer_init(); - #ifdef CONFIG_SPL_BOARD_INIT spl_board_init(); #endif diff --git a/arch/arm/cpu/armv7/omap3/board.c b/arch/arm/cpu/armv7/omap3/board.c index 1f33c63..871aa37 100644 --- a/arch/arm/cpu/armv7/omap3/board.c +++ b/arch/arm/cpu/armv7/omap3/board.c @@ -230,6 +230,8 @@ void s_init(void)
#ifdef CONFIG_SPL_BUILD preloader_console_init(); + + timer_init(); #endif
if (!in_sdram)

* avoid potential buffer overflows * allow SPL-build not to output "Texas Instruments Revision detection unimplemented"
Signed-off-by: Andreas Müller schnitzeltony@gmx.de --- arch/arm/cpu/armv7/omap-common/hwinit-common.c | 10 ++++------ arch/arm/cpu/armv7/omap-common/spl.c | 10 ++++------ arch/arm/include/asm/arch-omap4/sys_proto.h | 2 +- arch/arm/include/asm/arch-omap5/sys_proto.h | 2 +- arch/arm/include/asm/omap_common.h | 2 +- 5 files changed, 11 insertions(+), 15 deletions(-)
diff --git a/arch/arm/cpu/armv7/omap-common/hwinit-common.c b/arch/arm/cpu/armv7/omap-common/hwinit-common.c index f65705d..90ec44d 100644 --- a/arch/arm/cpu/armv7/omap-common/hwinit-common.c +++ b/arch/arm/cpu/armv7/omap-common/hwinit-common.c @@ -104,14 +104,14 @@ u32 cortex_rev(void) return rev; }
-void omap_rev_string(char *omap_rev_string) +void omap_rev_string() { u32 omap_rev = omap_revision(); u32 omap_variant = (omap_rev & 0xFFFF0000) >> 16; u32 major_rev = (omap_rev & 0x00000F00) >> 8; u32 minor_rev = (omap_rev & 0x000000F0) >> 4;
- sprintf(omap_rev_string, "OMAP%x ES%x.%x", omap_variant, major_rev, + printf("OMAP%x ES%x.%x\n", omap_variant, major_rev, minor_rev); }
@@ -251,10 +251,8 @@ u32 get_device_type(void) */ int print_cpuinfo(void) { - char rev_string_buffer[50]; - - omap_rev_string(rev_string_buffer); - printf("CPU : %s\n", rev_string_buffer); + puts("CPU : "); + omap_rev_string();
return 0; } diff --git a/arch/arm/cpu/armv7/omap-common/spl.c b/arch/arm/cpu/armv7/omap-common/spl.c index 74fea4f..fdce2dc 100644 --- a/arch/arm/cpu/armv7/omap-common/spl.c +++ b/arch/arm/cpu/armv7/omap-common/spl.c @@ -154,7 +154,6 @@ void board_init_r(gd_t *id, ulong dummy) void preloader_console_init(void) { const char *u_boot_rev = U_BOOT_VERSION; - char rev_string_buffer[50];
gd = &gdata; gd->bd = &bdata; @@ -170,14 +169,13 @@ void preloader_console_init(void)
printf("\nU-Boot SPL %s (%s - %s)\n", u_boot_rev, U_BOOT_DATE, U_BOOT_TIME); - omap_rev_string(rev_string_buffer); - printf("Texas Instruments %s\n", rev_string_buffer); + omap_rev_string(); }
-void __omap_rev_string(char *str) +void __omap_rev_string() { - sprintf(str, "Revision detection unimplemented"); + printf("Texas Instruments Revision detection unimplemented\n"); }
-void omap_rev_string(char *str) +void omap_rev_string() __attribute__((weak, alias("__omap_rev_string"))); diff --git a/arch/arm/include/asm/arch-omap4/sys_proto.h b/arch/arm/include/asm/arch-omap4/sys_proto.h index 4146e21..7386adf 100644 --- a/arch/arm/include/asm/arch-omap4/sys_proto.h +++ b/arch/arm/include/asm/arch-omap4/sys_proto.h @@ -42,7 +42,7 @@ void sr32(void *, u32, u32, u32); u32 wait_on_value(u32, u32, void *, u32); void sdelay(unsigned long); void set_pl310_ctrl_reg(u32 val); -void omap_rev_string(char *omap_rev_string); +void omap_rev_string(); void setup_clocks_for_console(void); void prcm_init(void); void bypass_dpll(u32 *const base); diff --git a/arch/arm/include/asm/arch-omap5/sys_proto.h b/arch/arm/include/asm/arch-omap5/sys_proto.h index c31e18c..fd1ba39 100644 --- a/arch/arm/include/asm/arch-omap5/sys_proto.h +++ b/arch/arm/include/asm/arch-omap5/sys_proto.h @@ -42,7 +42,7 @@ void set_muxconf_regs_non_essential(void); void sr32(void *, u32, u32, u32); u32 wait_on_value(u32, u32, void *, u32); void sdelay(unsigned long); -void omap_rev_string(char *omap_rev_string); +void omap_rev_string(); void setup_clocks_for_console(void); void prcm_init(void); void bypass_dpll(u32 *const base); diff --git a/arch/arm/include/asm/omap_common.h b/arch/arm/include/asm/omap_common.h index 1ec651b..7e92ef2 100644 --- a/arch/arm/include/asm/omap_common.h +++ b/arch/arm/include/asm/omap_common.h @@ -86,7 +86,7 @@ u32 omap_boot_mode(void);
/* SPL common function s*/ void spl_parse_image_header(const struct image_header *header); -void omap_rev_string(char *omap_rev_string); +void omap_rev_string();
/* NAND SPL functions */ void spl_nand_load_image(void);

On Wed, Jan 4, 2012 at 6:26 PM, Andreas Müller schnitzeltony@gmx.de wrote:
- avoid potential buffer overflows
- allow SPL-build not to output "Texas Instruments Revision detection unimplemented"
Signed-off-by: Andreas Müller schnitzeltony@gmx.de
arch/arm/cpu/armv7/omap-common/hwinit-common.c | 10 ++++------ arch/arm/cpu/armv7/omap-common/spl.c | 10 ++++------ arch/arm/include/asm/arch-omap4/sys_proto.h | 2 +- arch/arm/include/asm/arch-omap5/sys_proto.h | 2 +- arch/arm/include/asm/omap_common.h | 2 +- 5 files changed, 11 insertions(+), 15 deletions(-)
diff --git a/arch/arm/cpu/armv7/omap-common/hwinit-common.c b/arch/arm/cpu/armv7/omap-common/hwinit-common.c index f65705d..90ec44d 100644 --- a/arch/arm/cpu/armv7/omap-common/hwinit-common.c +++ b/arch/arm/cpu/armv7/omap-common/hwinit-common.c @@ -104,14 +104,14 @@ u32 cortex_rev(void) return rev; }
-void omap_rev_string(char *omap_rev_string) +void omap_rev_string()
I'm going to apply this, but globally fix this change, it should read 'void omap_rev_string(void)'

On Fri, Jan 13, 2012 at 9:31 AM, Tom Rini tom.rini@gmail.com wrote:
On Wed, Jan 4, 2012 at 6:26 PM, Andreas Müller schnitzeltony@gmx.de wrote:
- avoid potential buffer overflows
- allow SPL-build not to output "Texas Instruments Revision detection unimplemented"
Signed-off-by: Andreas Müller schnitzeltony@gmx.de
arch/arm/cpu/armv7/omap-common/hwinit-common.c | 10 ++++------ arch/arm/cpu/armv7/omap-common/spl.c | 10 ++++------ arch/arm/include/asm/arch-omap4/sys_proto.h | 2 +- arch/arm/include/asm/arch-omap5/sys_proto.h | 2 +- arch/arm/include/asm/omap_common.h | 2 +- 5 files changed, 11 insertions(+), 15 deletions(-)
diff --git a/arch/arm/cpu/armv7/omap-common/hwinit-common.c b/arch/arm/cpu/armv7/omap-common/hwinit-common.c index f65705d..90ec44d 100644 --- a/arch/arm/cpu/armv7/omap-common/hwinit-common.c +++ b/arch/arm/cpu/armv7/omap-common/hwinit-common.c @@ -104,14 +104,14 @@ u32 cortex_rev(void) return rev; }
-void omap_rev_string(char *omap_rev_string) +void omap_rev_string()
I'm going to apply this, but globally fix this change, it should read 'void omap_rev_string(void)'
For clarity, I'm doing:
diff --git a/arch/arm/cpu/armv7/omap-common/hwinit-common.c b/arch/arm/cpu/armv7/omap-common/hwinit-common.c index d23ea1f..49cdc39 100644 --- a/arch/arm/cpu/armv7/omap-common/hwinit-common.c +++ b/arch/arm/cpu/armv7/omap-common/hwinit-common.c @@ -76,7 +76,7 @@ u32 cortex_rev(void) return rev; }
-void omap_rev_string() +void omap_rev_string(void) { u32 omap_rev = omap_revision(); u32 omap_variant = (omap_rev & 0xFFFF0000) >> 16; diff --git a/arch/arm/cpu/armv7/omap-common/spl.c b/arch/arm/cpu/armv7/omap-common/spl.c index fdce2dc..c9f85fe 100644 --- a/arch/arm/cpu/armv7/omap-common/spl.c +++ b/arch/arm/cpu/armv7/omap-common/spl.c @@ -172,10 +172,7 @@ void preloader_console_init(void) omap_rev_string(); }
-void __omap_rev_string() +void __weak omap_rev_string() { printf("Texas Instruments Revision detection unimplemented\n"); } - -void omap_rev_string() - __attribute__((weak, alias("__omap_rev_string"))); diff --git a/arch/arm/include/asm/arch-omap4/sys_proto.h b/arch/arm/include/asm/arch-omap4/sys_proto.h index 7386adf..b8dbc2c 100644 --- a/arch/arm/include/asm/arch-omap4/sys_proto.h +++ b/arch/arm/include/asm/arch-omap4/sys_proto.h @@ -42,7 +42,7 @@ void sr32(void *, u32, u32, u32); u32 wait_on_value(u32, u32, void *, u32); void sdelay(unsigned long); void set_pl310_ctrl_reg(u32 val); -void omap_rev_string(); +void omap_rev_string(void); void setup_clocks_for_console(void); void prcm_init(void); void bypass_dpll(u32 *const base); diff --git a/arch/arm/include/asm/arch-omap5/sys_proto.h b/arch/arm/include/asm/arch-omap5/sys_proto.h index fd1ba39..40a7c57 100644 --- a/arch/arm/include/asm/arch-omap5/sys_proto.h +++ b/arch/arm/include/asm/arch-omap5/sys_proto.h @@ -42,7 +42,7 @@ void set_muxconf_regs_non_essential(void); void sr32(void *, u32, u32, u32); u32 wait_on_value(u32, u32, void *, u32); void sdelay(unsigned long); -void omap_rev_string(); +void omap_rev_string(void); void setup_clocks_for_console(void); void prcm_init(void); void bypass_dpll(u32 *const base); diff --git a/arch/arm/include/asm/omap_common.h b/arch/arm/include/asm/omap_common.h index d2b7cba..34bec45 100644 --- a/arch/arm/include/asm/omap_common.h +++ b/arch/arm/include/asm/omap_common.h @@ -91,7 +91,7 @@ u32 omap_boot_mode(void);
/* SPL common function s*/ void spl_parse_image_header(const struct image_header *header); -void omap_rev_string(); +void omap_rev_string(void);
/* NAND SPL functions */ void spl_nand_load_image(void);

* implementation based on ti beagleboard/omap3evm * timing data and i2c workaround for revision 0 boards taken from x-loader * run-tested with overo revision 0 and 1 / boot from NAND and SDcard * run-tested with x-loader
Signed-off-by: Andreas Müller schnitzeltony@gmx.de --- arch/arm/include/asm/arch-omap3/mem.h | 26 +++++++++++++ board/overo/config.mk | 28 -------------- board/overo/overo.c | 65 ++++++++++++++++++++++++++++++++- board/overo/overo.h | 9 +++++ include/configs/omap3_overo.h | 52 ++++++++++++++++++++++++++ 5 files changed, 151 insertions(+), 29 deletions(-) delete mode 100644 board/overo/config.mk
diff --git a/arch/arm/include/asm/arch-omap3/mem.h b/arch/arm/include/asm/arch-omap3/mem.h index 5fd02d4..4ca929e 100644 --- a/arch/arm/include/asm/arch-omap3/mem.h +++ b/arch/arm/include/asm/arch-omap3/mem.h @@ -123,6 +123,32 @@ enum { V_MCFG_BANKALLOCATION_RBC | \ V_MCFG_B32NOT16_32 | V_MCFG_DEEPPD_EN | V_MCFG_RAMTYPE_DDR
+/* Hynix part of Overo (165MHz optimized) 6.06ns */ +#define HYNIX_TDAL_165 6 +#define HYNIX_TDPL_165 3 +#define HYNIX_TRRD_165 2 +#define HYNIX_TRCD_165 3 +#define HYNIX_TRP_165 3 +#define HYNIX_TRAS_165 7 +#define HYNIX_TRC_165 10 +#define HYNIX_TRFC_165 21 +#define HYNIX_V_ACTIMA_165 \ + ACTIM_CTRLA(HYNIX_TRFC_165, HYNIX_TRC_165, \ + HYNIX_TRAS_165, HYNIX_TRP_165, \ + HYNIX_TRCD_165, HYNIX_TRRD_165, \ + HYNIX_TDPL_165, HYNIX_TDAL_165) + +#define HYNIX_TWTR_165 1 +#define HYNIX_TCKE_165 1 +#define HYNIX_TXP_165 2 +#define HYNIX_XSR_165 24 +#define HYNIX_V_ACTIMB_165 \ + ACTIM_CTRLB(HYNIX_TWTR_165, HYNIX_TCKE_165, \ + HYNIX_TXP_165, HYNIX_XSR_165) + +#define HYNIX_RASWIDTH_165 0x2 +#define HYNIX_V_MCFG_165(size) MCFG((size), HYNIX_RASWIDTH_165) + /* Hynix part of AM/DM37xEVM (200MHz optimized) */ #define HYNIX_TDAL_200 6 #define HYNIX_TDPL_200 3 diff --git a/board/overo/config.mk b/board/overo/config.mk deleted file mode 100644 index e7c471c..0000000 --- a/board/overo/config.mk +++ /dev/null @@ -1,28 +0,0 @@ -# -# Overo uses OMAP3 (ARM-CortexA8) cpu -# -# See file CREDITS for list of people who contributed to this -# project. -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of -# the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, -# MA 02111-1307 USA -# -# Physical Address: -# 8000'0000 (bank0) -# A000/0000 (bank1) -# Linux-Kernel is expected to be at 8000'8000, entry 8000'8000 -# (mem base + reserved) - -CONFIG_SYS_TEXT_BASE = 0x80008000 diff --git a/board/overo/overo.c b/board/overo/overo.c index 4a20c7f..2534e47 100644 --- a/board/overo/overo.c +++ b/board/overo/overo.c @@ -31,6 +31,7 @@ #include <common.h> #include <netdev.h> #include <twl4030.h> +#include <linux/mtd/nand.h> #include <asm/io.h> #include <asm/arch/mmc_host_def.h> #include <asm/arch/mux.h> @@ -100,6 +101,16 @@ int board_init(void) }
/* + * Routine: omap_rev_string + * Description: For SPL builds output board rev + */ +#ifdef CONFIG_SPL_BUILD +void omap_rev_string() +{ +} +#endif + +/* * Routine: get_board_revision * Description: Returns the board revision */ @@ -107,6 +118,20 @@ int get_board_revision(void) { int revision;
+#ifdef CONFIG_DRIVER_OMAP34XX_I2C + unsigned char data; + + /* board revisions <= R2410 connect 4030 irq_1 to gpio112 */ + /* these boards should return a revision number of 0 */ + /* the code below forces a 4030 RTC irq to ensure that gpio112 is low */ + i2c_set_bus_num(TWL4030_I2C_BUS); + data = 0x01; + i2c_write(0x4B, 0x29, 1, &data, 1); + data = 0x0c; + i2c_write(0x4B, 0x2b, 1, &data, 1); + i2c_read(0x4B, 0x2a, 1, &data, 1); +#endif + if (!gpio_request(112, "") && !gpio_request(113, "") && !gpio_request(115, "")) { @@ -126,6 +151,44 @@ int get_board_revision(void) return revision; }
+#ifdef CONFIG_SPL_BUILD +/* + * Routine: get_board_mem_timings + * Description: If we use SPL then there is no x-loader nor config header + * so we have to setup the DDR timings ourself on both banks. + */ +void get_board_mem_timings(u32 *mcfg, u32 *ctrla, u32 *ctrlb, u32 *rfr_ctrl, + u32 *mr) +{ + *mr = MICRON_V_MR_165; + switch (get_board_revision()) { + case REVISION_0: /* Micron 1286MB/256MB, 1/2 banks of 128MB */ + *mcfg = MICRON_V_MCFG_165(128 << 20); + *ctrla = MICRON_V_ACTIMA_165; + *ctrlb = MICRON_V_ACTIMB_165; + *rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz; + break; + case REVISION_1: /* Micron 256MB/512MB, 1/2 banks of 256MB */ + *mcfg = MICRON_V_MCFG_165(256 << 20); + *ctrla = MICRON_V_ACTIMA_165; + *ctrlb = MICRON_V_ACTIMB_165; + *rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz; + break; + case REVISION_2: /* Hynix 256MB/512MB, 1/2 banks of 256MB */ + *mcfg = HYNIX_V_MCFG_165(256 << 20); + *ctrla = HYNIX_V_ACTIMA_165; + *ctrlb = HYNIX_V_ACTIMB_165; + *rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz; + break; + default: + *mcfg = MICRON_V_MCFG_165(128 << 20); + *ctrla = MICRON_V_ACTIMA_165; + *ctrlb = MICRON_V_ACTIMB_165; + *rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz; + } +} +#endif + /* * Routine: get_sdio2_config * Description: Return information about the wifi module connection @@ -337,7 +400,7 @@ int board_eth_init(bd_t *bis) return rc; }
-#ifdef CONFIG_GENERIC_MMC +#if defined(CONFIG_GENERIC_MMC) && !defined(CONFIG_SPL_BUILD) int board_mmc_init(bd_t *bis) { omap_mmc_init(0); diff --git a/board/overo/overo.h b/board/overo/overo.h index 915f15b..60d696e 100644 --- a/board/overo/overo.h +++ b/board/overo/overo.h @@ -33,6 +33,15 @@ const omap3_sysinfo sysinfo = { #endif };
+#ifdef CONFIG_SPL_BUILD +void omap_rev_string(); +#endif + +/* overo revisions */ +#define REVISION_0 0x0 +#define REVISION_1 0x1 +#define REVISION_2 0x2 + /* * IEN - Input Enable * IDIS - Input Disable diff --git a/include/configs/omap3_overo.h b/include/configs/omap3_overo.h index 8f2e69d..5f29839 100644 --- a/include/configs/omap3_overo.h +++ b/include/configs/omap3_overo.h @@ -285,6 +285,11 @@
#endif /* (CONFIG_CMD_NET) */
+/* + * Leave it at 0x80008000 to allow booting new u-boot.bin with X-loader + * and older u-boot.bin with the new U-Boot SPL. + */ +#define CONFIG_SYS_TEXT_BASE 0x80008000 #define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM_1 #define CONFIG_SYS_INIT_RAM_ADDR 0x4020f800 #define CONFIG_SYS_INIT_RAM_SIZE 0x800 @@ -294,4 +299,51 @@
#define CONFIG_SYS_CACHELINE_SIZE 64
+/* Defines for SPL */ +#define CONFIG_SPL +#define CONFIG_SPL_NAND_SIMPLE +#define CONFIG_SPL_TEXT_BASE 0x40200800 +#define CONFIG_SPL_MAX_SIZE (45 * 1024) +#define CONFIG_SPL_STACK LOW_LEVEL_SRAM_STACK + +/* move malloc and bss high to prevent clashing with the main image */ +#define CONFIG_SYS_SPL_MALLOC_START 0x87000000 +#define CONFIG_SYS_SPL_MALLOC_SIZE 0x80000 +#define CONFIG_SPL_BSS_START_ADDR 0x87080000 /* end of minimum RAM */ +#define CONFIG_SPL_BSS_MAX_SIZE 0x80000 /* 512 KB */ + +#define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR 0x300 /* address 0x60000 */ +#define CONFIG_SYS_U_BOOT_MAX_SIZE_SECTORS 0x200 /* 256 KB */ +#define CONFIG_SYS_MMC_SD_FAT_BOOT_PARTITION 1 +#define CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME "u-boot.img" + +#define CONFIG_SPL_LIBCOMMON_SUPPORT +#define CONFIG_SPL_LIBDISK_SUPPORT +#define CONFIG_SPL_I2C_SUPPORT +#define CONFIG_SPL_LIBGENERIC_SUPPORT +#define CONFIG_SPL_MMC_SUPPORT +#define CONFIG_SPL_FAT_SUPPORT +#define CONFIG_SPL_SERIAL_SUPPORT +#define CONFIG_SPL_NAND_SUPPORT +#define CONFIG_SPL_POWER_SUPPORT +#define CONFIG_SPL_LDSCRIPT "$(CPUDIR)/omap-common/u-boot-spl.lds" + +/* NAND boot config */ +#define CONFIG_SYS_NAND_5_ADDR_CYCLE +#define CONFIG_SYS_NAND_PAGE_COUNT 64 +#define CONFIG_SYS_NAND_PAGE_SIZE 2048 +#define CONFIG_SYS_NAND_OOBSIZE 64 +#define CONFIG_SYS_NAND_BLOCK_SIZE (128*1024) +#define CONFIG_SYS_NAND_BAD_BLOCK_POS NAND_LARGE_BADBLOCK_POS +#define CONFIG_SYS_NAND_ECCPOS {2, 3, 4, 5, 6, 7, 8, 9,\ + 10, 11, 12, 13} +#define CONFIG_SYS_NAND_ECCSIZE 512 +#define CONFIG_SYS_NAND_ECCBYTES 3 +#define CONFIG_SYS_NAND_ECCSTEPS (CONFIG_SYS_NAND_PAGE_SIZE / \ + CONFIG_SYS_NAND_ECCSIZE) +#define CONFIG_SYS_NAND_ECCTOTAL (CONFIG_SYS_NAND_ECCBYTES * \ + CONFIG_SYS_NAND_ECCSTEPS) +#define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE +#define CONFIG_SYS_NAND_U_BOOT_OFFS 0x80000 + #endif /* __CONFIG_H */

On Wed, Jan 4, 2012 at 6:26 PM, Andreas Müller schnitzeltony@gmx.de wrote:
- implementation based on ti beagleboard/omap3evm
- timing data and i2c workaround for revision 0 boards taken from x-loader
- run-tested with overo revision 0 and 1 / boot from NAND and SDcard
- run-tested with x-loader
Signed-off-by: Andreas Müller schnitzeltony@gmx.de
I've applied this with the following changes:
diff --git a/board/overo/overo.c b/board/overo/overo.c index 2534e47..7b4064c 100644 --- a/board/overo/overo.c +++ b/board/overo/overo.c @@ -105,7 +105,7 @@ int board_init(void) * Description: For SPL builds output board rev */ #ifdef CONFIG_SPL_BUILD -void omap_rev_string() +void omap_rev_string(void) { } #endif diff --git a/board/overo/overo.h b/board/overo/overo.h index 60d696e..b41b628 100644 --- a/board/overo/overo.h +++ b/board/overo/overo.h @@ -33,10 +33,6 @@ const omap3_sysinfo sysinfo = { #endif };
-#ifdef CONFIG_SPL_BUILD -void omap_rev_string(); -#endif - /* overo revisions */ #define REVISION_0 0x0 #define REVISION_1 0x1
To fix some warnings. In the future please make sure you don't add any new warnings with your changes. Thanks!

On Wed, Jan 4, 2012 at 6:26 PM, Andreas Müller schnitzeltony@gmx.de wrote:
V1 -> V2
- cleanups: replace printf with one argument by puts [1-2]
- cleanups: remove unused macros and macro values / tabbing / remove FSF address [3]
- i2c: move all local variables to SRAM [4]
- OMAP SPL: call timer_init in s_init to make udelay work earlier [5]
- hint CONFIG_SYS_TEXT_BASE changed in commit message [6]
- remove log 'Texas Instruments Revision detection unimplemented' for overo [6]
- remove unintended whitespaces [6]
- send 'shut up' to TWL4030 to avoid corruption when reading board revision [6]
- use macros for overo revisions [6]
- don't separate SPL specific configurations [6]
V2 -> V3
- modify omap_rev_string [6]
- CONFIG_SYS_TEXT_BASE back to 0x80008000 [7]
- modify CONFIG_SYS_SPL_MALLOC_START / CONFIG_SYS_SPL_MALLOC_SIZE /
CONFIG_SPL_BSS_START_ADDR to avoid conflicts with CONFIG_SYS_TEXT_BASE [7]
Andreas Müller (7): drivers/i2c/omap24xx_i2c.c: replace printf with one argument by puts board/overo/overo.c: replace printf with one argument by puts include/configs/omap3_overo.h: several cleanups drivers/i2c/omap24xx_i2c.c: move all local variables to SRAM OMAP SPL: call timer_init in s_init to make udelay work earlier omap_rev_string: output to stdout overo: add SPL support
arch/arm/cpu/armv7/omap-common/hwinit-common.c | 10 +- arch/arm/cpu/armv7/omap-common/spl.c | 12 +-- arch/arm/cpu/armv7/omap3/board.c | 2 + arch/arm/include/asm/arch-omap3/mem.h | 26 +++++ arch/arm/include/asm/arch-omap4/sys_proto.h | 2 +- arch/arm/include/asm/arch-omap5/sys_proto.h | 2 +- arch/arm/include/asm/omap_common.h | 2 +- board/overo/config.mk | 28 ------ board/overo/overo.c | 79 ++++++++++++++-- board/overo/overo.h | 9 ++ drivers/i2c/omap24xx_i2c.c | 25 +++-- include/configs/omap3_overo.h | 121 ++++++++++++++++-------- 12 files changed, 217 insertions(+), 101 deletions(-) delete mode 100644 board/overo/config.mk
With the changes posted in reply to 6/7, applied to u-boot-ti/master, thanks!
participants (3)
-
Andreas Müller
-
Heiko Schocher
-
Tom Rini