[U-Boot] [PATCH 12/12] imx: ventana: switch to SPL

Tim Harvey tharvey at gateworks.com
Tue May 6 20:18:42 CEST 2014


On Mon, Apr 28, 2014 at 1:17 PM, Tim Harvey <tharvey at gateworks.com> wrote:
>
> Switch to an SPL image. The SPL for Ventana does the following:
>  - setup i2c and read the factory programmed EEPROM to obtain DRAM config
>    and model for board-specific calibration data
>  - configure DRAM per CPU/size/layout/devices/calibration
>  - load u-boot.img from NAND or MTD depending on boot device  and jump to it
>
> This allows for a single SPL+u-boot.img to replace the previous multiple board
> configurations.
>
<snip>
> +
> +static void i2c_setup_iomux(void)
> +{
> +       if (is_cpu_type(MXC_CPU_MX6Q))
> +               setup_i2c(0, CONFIG_SYS_I2C_SPEED, 0x7f, &mx6q_i2c_pad_info0);
> +       else
> +               setup_i2c(0, CONFIG_SYS_I2C_SPEED, 0x7f, &mx6dl_i2c_pad_info0);
> +}
> +
<snip>
> +
> +/*
> + * called from C runtime startup code (arch/arm/lib/crt0.S:_main)
> + * - we have a stack and a place to store GD, both in SRAM
> + * - no variable global data is available
> + */
> +void board_init_f(ulong dummy)
> +{
> +       struct ventana_board_info ventana_info;
> +       int board_model;
> +
> +       /* iomux and setup of i2c */
> +       i2c_setup_iomux();
> +       timer_init();
> +       board_model = read_eeprom(I2C_GSC, &ventana_info);
> +
> +       /* provide some some default: 32bit 128MB */
> +       if (GW_UNKNOWN == board_model) {
> +               ventana_info.sdram_width = 2;
> +               ventana_info.sdram_size = 3;
> +       }
> +       spl_dram_init(8 << ventana_info.sdram_width,
> +                     16 << ventana_info.sdram_size,
> +                     board_model);
> +
> +       arch_cpu_init();
> +
> +       /* Clear the BSS. */
> +       memset(__bss_start, 0, __bss_end - __bss_start);
> +
> +       /* Set global data pointer. */
> +       gd = &gdata;
> +
> +       board_early_init_f();
> +
> +       preloader_console_init();
> +
> +       board_init_r(NULL, 0);
> +}

Stefano / York,

While preparing for a v3 patch series of my IMX6 SPL bootloader, I
find that commit dec1861be90c948ea9fb771927d3d26a994d2e20 [1] breaks
the above code because gd is now needed within setup_i2c.

I've always been a bit fuzzy on the order of the above calls so I dug
through the code and I think I understand things better. Please
correct any wrong assumptions I'm making below:
 - assignment to gd should 'always' be first (before anything needs
it, so why not do it first)
 - arch_cpu_init() should go next as this sets up very low level
CPU/SoC resources (in this case AIPS config and watchdog disable)
 - board_early_init_f() should be next as that sets up any board-specific iomux
 - any additional iomux necessary for SPL should go next (I take care
of i2c iomux and setup here)
 - timer_init() next as you need a timer for UART and mxc i2c (for
delays and busy checks)
 - preloader_console_init() next as we are now able to send something
over the UART (this gives me early debug for sdram config now too!)
 - sdram setup goes next
 - after sdram is setup, the bss can be cleared
 - board_init_r - pass over to generic SPL code which will load/call
an image based on boot device

So, if the above is correct, I should rework the above function as follows:

void board_init_f(ulong dummy)
{
        struct ventana_board_info ventana_info;
        int board_model;

        /* Set global data pointer. */
        gd = &gdata;

        /* setup AIPS and disable watchdog */
        arch_cpu_init();

        /* iomux and setup of i2c */
        board_early_init_f();
        i2c_setup_iomux();

        /* setup GP timer */
        timer_init();

        /* UART clocks enabled and gd valid - init serial console */
        preloader_console_init();

        /* read/validate EEPROM info to determine board model and SDRAM cfg */
        board_model = read_eeprom(I2C_GSC, &ventana_info);

        /* provide some some default: 32bit 128MB */
        if (GW_UNKNOWN == board_model) {
                ventana_info.sdram_width = 2;
                ventana_info.sdram_size = 3;
        }

        /* configure MMDC for SDRAM width/size and per-model calibration */
        spl_dram_init(8 << ventana_info.sdram_width,
                      16 << ventana_info.sdram_size,
                      board_model);

        /* Clear the BSS. */
        memset(__bss_start, 0, __bss_end - __bss_start);

        /* load/boot image from boot device */
        board_init_r(NULL, 0);
}

Does this make sense?

Thanks,

Tim

[1] - http://git.denx.de/?p=u-boot.git;a=commitdiff;h=dec1861be90c948ea9fb771927d3d26a994d2e20

> +
> +void reset_cpu(ulong addr)
> +{
> +}
> diff --git a/boards.cfg b/boards.cfg
> index c83aff3..9119e24 100644
> --- a/boards.cfg
> +++ b/boards.cfg
> @@ -322,11 +322,7 @@ Active  arm         armv7          mx6         freescale       mx6qsabreauto
>  Active  arm         armv7          mx6         freescale       mx6sabresd          mx6dlsabresd                         mx6sabresd:IMX_CONFIG=board/boundary/nitrogen6x/nitrogen6dl.cfg,MX6DL                                                             Fabio Estevam <fabio.estevam at freescale.com>
>  Active  arm         armv7          mx6         freescale       mx6sabresd          mx6qsabresd                          mx6sabresd:IMX_CONFIG=board/freescale/imx/ddr/mx6q_4x_mt41j128.cfg,MX6Q                                                           Fabio Estevam <fabio.estevam at freescale.com>
>  Active  arm         armv7          mx6         freescale       mx6slevk            mx6slevk                             mx6slevk:IMX_CONFIG=board/freescale/mx6slevk/imximage.cfg,MX6SL                                                                   Fabio Estevam <fabio.estevam at freescale.com>
> -Active  arm         armv7          mx6         gateworks       gw_ventana          gwventanadl                          gw_ventana:IMX_CONFIG=board/gateworks/gw_ventana/gw_ventana.cfg,MX6DL,DDR_MB=512                                                  Tim Harvey <tharvey at gateworks.com>
> -Active  arm         armv7          mx6         gateworks       gw_ventana          gwventanadl1g                        gw_ventana:IMX_CONFIG=board/gateworks/gw_ventana/gw_ventana.cfg,MX6DL,DDR_MB=1024                                                 Tim Harvey <tharvey at gateworks.com>
> -Active  arm         armv7          mx6         gateworks       gw_ventana          gwventanaq                           gw_ventana:IMX_CONFIG=board/gateworks/gw_ventana/gw_ventana.cfg,MX6Q,DDR_MB=512                                                   Tim Harvey <tharvey at gateworks.com>
> -Active  arm         armv7          mx6         gateworks       gw_ventana          gwventanaq1g                         gw_ventana:IMX_CONFIG=board/gateworks/gw_ventana/gw_ventana.cfg,MX6Q,DDR_MB=1024                                                  Tim Harvey <tharvey at gateworks.com>
> -Active  arm         armv7          mx6         gateworks       gw_ventana          gwventanaq1gspi                      gw_ventana:IMX_CONFIG=board/gateworks/gw_ventana/gw_ventana.cfg,MX6Q,DDR_MB=1024,SPI_FLASH                                        Tim Harvey <tharvey at gateworks.com>
> +Active  arm         armv7          mx6         gateworks       gw_ventana          gwventana                            gw_ventana:IMX_CONFIG=board/gateworks/gw_ventana/gw_ventana.cfg,MX6QDL,SPL                                                  Tim Harvey <tharvey at gateworks.com>
>  Active  arm         armv7          mx6         solidrun        hummingboard        hummingboard_solo                    hummingboard:IMX_CONFIG=board/solidrun/hummingboard/solo.cfg,MX6S,DDR_MB=512                                                      Jon Nettleton <jon.nettleton at gmail.com>
>  Active  arm         armv7          omap3       -               overo               omap3_overo                          -                                                                                                                                 Steve Sakoman <sakoman at gmail.com>
>  Active  arm         armv7          omap3       -               pandora             omap3_pandora                        -                                                                                                                                 Grazvydas Ignotas <notasas at gmail.com>
> diff --git a/include/configs/gw_ventana.h b/include/configs/gw_ventana.h
> index 3398390..cd53737 100644
> --- a/include/configs/gw_ventana.h
> +++ b/include/configs/gw_ventana.h
> @@ -7,6 +7,17 @@
>  #ifndef __CONFIG_H
>  #define __CONFIG_H
>
> +/* SPL */
> +#define CONFIG_SPL_NAND_SUPPORT
> +#define CONFIG_SPL_MMC_SUPPORT
> +#define CONFIG_SPL_FAT_SUPPORT
> +/*
> +#define CONFIG_SPL_SATA_SUPPORT
> +*/
> +/* Location in NAND to read U-Boot from */
> +#define CONFIG_SYS_NAND_U_BOOT_OFFS     (14 * 1024 * 1024)
> +
> +#include "imx6_spl.h"                  /* common IMX6 SPL configuration */
>  #include "mx6_common.h"
>  #define CONFIG_MX6
>  #define CONFIG_DISPLAY_CPUINFO         /* display cpu info */
> --
> 1.8.3.2
>


More information about the U-Boot mailing list