[U-Boot] [PATCH 0/3] ARM: AMx3xx: Minor cleanup in early init code

This series does a minor cleanup for early initialization code on AM33xx and AM43xx based platforms.
Logs: AM437x-GP EVM: http://pastebin.ubuntu.com/23321700/ BBB: http://pastebin.ubuntu.com/23321698/
Lokesh Vutla (3): ARM: AMx3xx: Allow arch specific code to use early DM ARM: AMx3xx: Centralize early clock initialization board: ti: amx3xx: Remove multiple EEPROM reads
arch/arm/cpu/armv7/am33xx/board.c | 31 +++++++++++++++++++++------ arch/arm/cpu/armv7/am33xx/clock.c | 9 ++++++-- arch/arm/include/asm/arch-am33xx/sys_proto.h | 2 ++ board/ti/am335x/board.c | 32 +++++++--------------------- board/ti/am43xx/board.c | 15 +++++-------- 5 files changed, 46 insertions(+), 43 deletions(-)

Early system initialization is being done before initf_dm is being called in U-Boot. Then system will fail to boot if any of the DM enabled driver is being called in this system initialization code. So, rearrange the code a bit so that DM enabled drivers can be called during early system initialization. This is inspired by commit e850ed82bce8 ("ARM: OMAP4+: Allow arch specific code to use early DM")
Signed-off-by: Lokesh Vutla lokeshvutla@ti.com --- arch/arm/cpu/armv7/am33xx/board.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-)
diff --git a/arch/arm/cpu/armv7/am33xx/board.c b/arch/arm/cpu/armv7/am33xx/board.c index 68baded..1ba4ec5 100644 --- a/arch/arm/cpu/armv7/am33xx/board.c +++ b/arch/arm/cpu/armv7/am33xx/board.c @@ -270,15 +270,11 @@ static void watchdog_disable(void) ; }
-#ifdef CONFIG_SPL_BUILD -void board_init_f(ulong dummy) +void s_init(void) { - board_early_init_f(); - sdram_init(); } -#endif
-void s_init(void) +void early_system_init(void) { /* * The ROM will only have set up sufficient pinmux to allow for the @@ -297,4 +293,22 @@ void s_init(void) rtc32k_enable(); #endif } + +#ifdef CONFIG_SPL_BUILD +void board_init_f(ulong dummy) +{ + early_system_init(); + board_early_init_f(); + sdram_init(); +} #endif + +#endif + +int arch_cpu_init_dm(void) +{ +#ifndef CONFIG_SKIP_LOWLEVEL_INIT + early_system_init(); +#endif + return 0; +}

On Fri, Oct 14, 2016 at 10:35:23AM +0530, Lokesh Vutla wrote:
Early system initialization is being done before initf_dm is being called in U-Boot. Then system will fail to boot if any of the DM enabled driver is being called in this system initialization code. So, rearrange the code a bit so that DM enabled drivers can be called during early system initialization. This is inspired by commit e850ed82bce8 ("ARM: OMAP4+: Allow arch specific code to use early DM")
Signed-off-by: Lokesh Vutla lokeshvutla@ti.com
Reviewed-by: Tom Rini trini@konsulko.com

On Fri, Oct 14, 2016 at 10:35:23AM +0530, Lokesh Vutla wrote:
Early system initialization is being done before initf_dm is being called in U-Boot. Then system will fail to boot if any of the DM enabled driver is being called in this system initialization code. So, rearrange the code a bit so that DM enabled drivers can be called during early system initialization. This is inspired by commit e850ed82bce8 ("ARM: OMAP4+: Allow arch specific code to use early DM")
Signed-off-by: Lokesh Vutla lokeshvutla@ti.com Reviewed-by: Tom Rini trini@konsulko.com
Applied to u-boot/master, thanks!

This is similar to Commit 93e6253d11030 ("ARM: OMAP4/5: Centralize early clock initialization") that was done for OMAP4+, reflecting the same for AM33xx and AM43xx SoCs to centralize clock initialization.
Signed-off-by: Lokesh Vutla lokeshvutla@ti.com --- arch/arm/cpu/armv7/am33xx/board.c | 2 +- arch/arm/cpu/armv7/am33xx/clock.c | 9 +++++++-- arch/arm/include/asm/arch-am33xx/sys_proto.h | 1 + 3 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/arch/arm/cpu/armv7/am33xx/board.c b/arch/arm/cpu/armv7/am33xx/board.c index 1ba4ec5..8340b54 100644 --- a/arch/arm/cpu/armv7/am33xx/board.c +++ b/arch/arm/cpu/armv7/am33xx/board.c @@ -286,7 +286,7 @@ void early_system_init(void) #endif watchdog_disable(); set_uart_mux_conf(); - setup_clocks_for_console(); + setup_early_clocks(); uart_soft_reset(); #if defined(CONFIG_SPL_AM33XX_ENABLE_RTC32K_OSC) /* Enable RTC32K clock */ diff --git a/arch/arm/cpu/armv7/am33xx/clock.c b/arch/arm/cpu/armv7/am33xx/clock.c index 9b9b78e..3d17698 100644 --- a/arch/arm/cpu/armv7/am33xx/clock.c +++ b/arch/arm/cpu/armv7/am33xx/clock.c @@ -232,10 +232,15 @@ __weak void scale_vcores(void) { }
-void prcm_init() +void setup_early_clocks(void) { + setup_clocks_for_console(); enable_basic_clocks(); + timer_init(); +} + +void prcm_init(void) +{ scale_vcores(); setup_dplls(); - timer_init(); } diff --git a/arch/arm/include/asm/arch-am33xx/sys_proto.h b/arch/arm/include/asm/arch-am33xx/sys_proto.h index ed1a46c..4e942ba 100644 --- a/arch/arm/include/asm/arch-am33xx/sys_proto.h +++ b/arch/arm/include/asm/arch-am33xx/sys_proto.h @@ -19,6 +19,7 @@ u32 get_sysboot_value(void); extern struct ctrl_stat *cstat; u32 get_device_type(void); void save_omap_boot_params(void); +void setup_early_clocks(void); void setup_clocks_for_console(void); void mpu_pll_config_val(int mpull_m); void ddr_pll_config(unsigned int ddrpll_M);

On Fri, Oct 14, 2016 at 10:35:24AM +0530, Lokesh Vutla wrote:
This is similar to Commit 93e6253d11030 ("ARM: OMAP4/5: Centralize early clock initialization") that was done for OMAP4+, reflecting the same for AM33xx and AM43xx SoCs to centralize clock initialization.
Signed-off-by: Lokesh Vutla lokeshvutla@ti.com
Reviewed-by: Tom Rini trini@konsulko.com

On Fri, Oct 14, 2016 at 10:35:24AM +0530, Lokesh Vutla wrote:
This is similar to Commit 93e6253d11030 ("ARM: OMAP4/5: Centralize early clock initialization") that was done for OMAP4+, reflecting the same for AM33xx and AM43xx SoCs to centralize clock initialization.
Signed-off-by: Lokesh Vutla lokeshvutla@ti.com Reviewed-by: Tom Rini trini@konsulko.com
After adding in:
diff --git a/arch/arm/cpu/armv7/am33xx/clock_ti814x.c b/arch/arm/cpu/armv7/am33xx/clock_ti814x.c index 9b5a47b01892..50bd631cf6b5 100644 --- a/arch/arm/cpu/armv7/am33xx/clock_ti814x.c +++ b/arch/arm/cpu/armv7/am33xx/clock_ti814x.c @@ -386,6 +386,12 @@ void setup_clocks_for_console(void) while (readl(&cmalwon->uart0clkctrl) != PRCM_MOD_EN) ; } + +void setup_early_clocks(void) +{ + setup_clocks_for_console(); +} + /* * Configure the PLL/PRCM for necessary peripherals */ diff --git a/arch/arm/cpu/armv7/am33xx/clock_ti816x.c b/arch/arm/cpu/armv7/am33xx/clock_ti816x.c index ace4a5afef09..079ddd7eb9fc 100644 --- a/arch/arm/cpu/armv7/am33xx/clock_ti816x.c +++ b/arch/arm/cpu/armv7/am33xx/clock_ti816x.c @@ -429,6 +429,11 @@ void setup_clocks_for_console(void) ; }
+void setup_early_clocks(void) +{ + setup_clocks_for_console(); +} + void prcm_init(void) { /* Enable the control */
Applied to u-boot/master, thanks!

Detect the board very early and avoid reading eeprom multiple times.
Signed-off-by: Lokesh Vutla lokeshvutla@ti.com --- arch/arm/cpu/armv7/am33xx/board.c | 3 +++ arch/arm/include/asm/arch-am33xx/sys_proto.h | 1 + board/ti/am335x/board.c | 32 +++++++--------------------- board/ti/am43xx/board.c | 15 +++++-------- 4 files changed, 17 insertions(+), 34 deletions(-)
diff --git a/arch/arm/cpu/armv7/am33xx/board.c b/arch/arm/cpu/armv7/am33xx/board.c index 8340b54..5ebeac0 100644 --- a/arch/arm/cpu/armv7/am33xx/board.c +++ b/arch/arm/cpu/armv7/am33xx/board.c @@ -288,6 +288,9 @@ void early_system_init(void) set_uart_mux_conf(); setup_early_clocks(); uart_soft_reset(); +#ifdef CONFIG_TI_I2C_BOARD_DETECT + do_board_detect(); +#endif #if defined(CONFIG_SPL_AM33XX_ENABLE_RTC32K_OSC) /* Enable RTC32K clock */ rtc32k_enable(); diff --git a/arch/arm/include/asm/arch-am33xx/sys_proto.h b/arch/arm/include/asm/arch-am33xx/sys_proto.h index 4e942ba..0c5792b 100644 --- a/arch/arm/include/asm/arch-am33xx/sys_proto.h +++ b/arch/arm/include/asm/arch-am33xx/sys_proto.h @@ -45,3 +45,4 @@ int am335x_get_tps65910_mpu_vdd(int sil_rev, int frequency);
void enable_usb_clocks(int index); void disable_usb_clocks(int index); +void do_board_detect(void); diff --git a/board/ti/am335x/board.c b/board/ti/am335x/board.c index fc1353a..da9eab4 100644 --- a/board/ti/am335x/board.c +++ b/board/ti/am335x/board.c @@ -64,10 +64,16 @@ static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE; /* * Read header information from EEPROM into global structure. */ -static inline int __maybe_unused read_eeprom(void) +#ifdef CONFIG_TI_I2C_BOARD_DETECT +void do_board_detect(void) { - return ti_i2c_eeprom_am_get(-1, CONFIG_SYS_I2C_EEPROM_ADDR); + enable_i2c0_pin_mux(); + i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, CONFIG_SYS_OMAP24_I2C_SLAVE); + + if (ti_i2c_eeprom_am_get(-1, CONFIG_SYS_I2C_EEPROM_ADDR)) + printf("ti_i2c_eeprom_init failed\n"); } +#endif
#ifndef CONFIG_DM_SERIAL struct serial_device *default_serial_console(void) @@ -248,9 +254,6 @@ void am33xx_spl_board_init(void) { int mpu_vdd;
- if (read_eeprom() < 0) - puts("Could not get board ID.\n"); - /* Get the frequency */ dpll_mpu_opp100.m = am335x_get_efuse_mpu_max_freq(cdev);
@@ -388,11 +391,6 @@ void am33xx_spl_board_init(void)
const struct dpll_params *get_dpll_ddr_params(void) { - enable_i2c0_pin_mux(); - i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, CONFIG_SYS_OMAP24_I2C_SLAVE); - if (read_eeprom() < 0) - puts("Could not get board ID.\n"); - if (board_is_evm_sk()) return &dpll_ddr_evm_sk; else if (board_is_bone_lt() || board_is_icev2()) @@ -422,9 +420,6 @@ void set_uart_mux_conf(void)
void set_mux_conf_regs(void) { - if (read_eeprom() < 0) - puts("Could not get board ID.\n"); - enable_board_pin_mux(); }
@@ -462,9 +457,6 @@ const struct ctrl_ioregs ioregs = {
void sdram_init(void) { - if (read_eeprom() < 0) - puts("Could not get board ID.\n"); - if (board_is_evm_sk()) { /* * EVM SK 1.2A and later use gpio0_7 to enable DDR3. @@ -642,13 +634,8 @@ int board_late_init(void) #endif
#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG - int rc; char *name = NULL;
- rc = read_eeprom(); - if (rc) - puts("Could not get board ID.\n"); - if (board_is_bbg1()) name = "BBG1"; set_board_info_env(name); @@ -779,9 +766,6 @@ int board_eth_init(bd_t *bis) (defined(CONFIG_SPL_ETH_SUPPORT) && defined(CONFIG_SPL_BUILD))
#ifdef CONFIG_DRIVER_TI_CPSW - if (read_eeprom() < 0) - puts("Could not get board ID.\n"); - if (board_is_bone() || board_is_bone_lt() || board_is_idk()) { writel(MII_MODE_ENABLE, &cdev->miisel); diff --git a/board/ti/am43xx/board.c b/board/ti/am43xx/board.c index f04a06e..ba6f88f 100644 --- a/board/ti/am43xx/board.c +++ b/board/ti/am43xx/board.c @@ -39,10 +39,13 @@ static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE; /* * Read header information from EEPROM into global structure. */ -static inline int __maybe_unused read_eeprom(void) +#ifdef CONFIG_TI_I2C_BOARD_DETECT +void do_board_detect(void) { - return ti_i2c_eeprom_am_get(-1, CONFIG_SYS_I2C_EEPROM_ADDR); + if (ti_i2c_eeprom_am_get(-1, CONFIG_SYS_I2C_EEPROM_ADDR)) + printf("ti_i2c_eeprom_init failed\n"); } +#endif
#ifndef CONFIG_SKIP_LOWLEVEL_INIT
@@ -337,9 +340,6 @@ const struct dpll_params *get_dpll_ddr_params(void) { int ind = get_sys_clk_index();
- if (read_eeprom() < 0) - return NULL; - if (board_is_eposevm()) return &epos_evm_dpll_ddr[ind]; else if (board_is_evm() || board_is_sk()) @@ -495,9 +495,6 @@ void scale_vcores(void) { const struct dpll_params *mpu_params;
- if (read_eeprom() < 0) - puts("Could not get board ID.\n"); - /* Ensure I2C is initialized for PMIC configuration */ gpi2c_init();
@@ -537,8 +534,6 @@ static void enable_vtt_regulator(void)
void sdram_init(void) { - if (read_eeprom() < 0) - return; /* * EPOS EVM has 1GB LPDDR2 connected to EMIF. * GP EMV has 1GB DDR3 connected to EMIF

On Fri, Oct 14, 2016 at 10:35:25AM +0530, Lokesh Vutla wrote:
Detect the board very early and avoid reading eeprom multiple times.
Signed-off-by: Lokesh Vutla lokeshvutla@ti.com
Reviewed-by: Tom Rini trini@konsulko.com

On Fri, Oct 14, 2016 at 10:35:25AM +0530, Lokesh Vutla wrote:
Detect the board very early and avoid reading eeprom multiple times.
Signed-off-by: Lokesh Vutla lokeshvutla@ti.com Reviewed-by: Tom Rini trini@konsulko.com
Applied to u-boot/master, thanks!
participants (2)
-
Lokesh Vutla
-
Tom Rini