[U-Boot] [PATCH] spl: exynos: make spl_boot common for all exynos based platforms

Inderpal Singh inderpal.singh at linaro.org
Wed Mar 27 09:48:45 CET 2013


Dear Minkyu,

Please let me know if you have any comments for this patch.

With Regards,
Inder

On 16 March 2013 14:16, Inderpal Singh <inderpal.singh at linaro.org> wrote:
> The spl_boot.c which copies the u-boot from the booting device to ram
> is made common for all the exynos based platforms. To do so:
>
> 1. Moved smdk5250/spl_boot.c to common armv7/exynos folder and updated
>    to make it common for exynos4 and exynos5
> 2. Introduced a CONFIG_SPL_BOOTING option as only exynos5250 supports
>    booting from SPI device
> 3. Renamed some config options to make them common between exynos5250,
>    origen and smdkv310.
>
> SD/MMC booting: tested on exynos4210 based origen, exynos5250 based Arndale
> and SMDK5250 boards.
> SPI booting: tested on SMDK5250 board
>
> Signed-off-by: Inderpal Singh <inderpal.singh at linaro.org>
> ---
> It depends on the patchset at [1] as it provides the infrastructure to
> detect the SOC type and revision in spl at runtime.
>
> [1] http://www.mail-archive.com/u-boot@lists.denx.de/msg108301.html
>
>  arch/arm/cpu/armv7/exynos/Makefile                 |    4 ++
>  .../arm/cpu/armv7/exynos}/spl_boot.c               |   33 +++++++----
>  board/samsung/origen/Makefile                      |    4 --
>  board/samsung/origen/mmc_boot.c                    |   58 -------------------
>  board/samsung/smdk5250/Makefile                    |    4 --
>  board/samsung/smdkv310/Makefile                    |    4 --
>  board/samsung/smdkv310/mmc_boot.c                  |   60 --------------------
>  include/configs/exynos5250-dt.h                    |   10 ++--
>  include/configs/origen.h                           |   21 +++----
>  include/configs/smdkv310.h                         |   21 +++----
>  10 files changed, 54 insertions(+), 165 deletions(-)
>  rename {board/samsung/smdk5250 => arch/arm/cpu/armv7/exynos}/spl_boot.c (73%)
>  delete mode 100644 board/samsung/origen/mmc_boot.c
>  delete mode 100644 board/samsung/smdkv310/mmc_boot.c
>
> diff --git a/arch/arm/cpu/armv7/exynos/Makefile b/arch/arm/cpu/armv7/exynos/Makefile
> index b9cf921..c507608 100644
> --- a/arch/arm/cpu/armv7/exynos/Makefile
> +++ b/arch/arm/cpu/armv7/exynos/Makefile
> @@ -24,6 +24,10 @@ LIB  = $(obj)lib$(SOC).o
>
>  COBJS  += clock.o power.o soc.o system.o pinmux.o tzpc_init.o
>
> +ifdef CONFIG_SPL_BUILD
> +COBJS  += spl_boot.o
> +endif
> +
>  SRCS   := $(SOBJS:.o=.S) $(COBJS:.o=.c)
>  OBJS   := $(addprefix $(obj),$(COBJS) $(SOBJS))
>
> diff --git a/board/samsung/smdk5250/spl_boot.c b/arch/arm/cpu/armv7/exynos/spl_boot.c
> similarity index 73%
> rename from board/samsung/smdk5250/spl_boot.c
> rename to arch/arm/cpu/armv7/exynos/spl_boot.c
> index d8f3c1e..e970ff6 100644
> --- a/board/samsung/smdk5250/spl_boot.c
> +++ b/arch/arm/cpu/armv7/exynos/spl_boot.c
> @@ -23,6 +23,8 @@
>  #include<common.h>
>  #include<config.h>
>
> +#define OM_STAT        (0x1f << 1)
> +
>  enum boot_mode {
>         BOOT_MODE_MMC = 4,
>         BOOT_MODE_SERIAL = 20,
> @@ -31,8 +33,6 @@ enum boot_mode {
>         BOOT_MODE_USB,  /* Boot using USB download */
>  };
>
> -       typedef u32 (*spi_copy_func_t)(u32 offset, u32 nblock, u32 dst);
> -
>  /*
>  * Copy U-boot from mmc to RAM:
>  * COPY_BL2_FNPTR_ADDR: Address in iRAM, which Contains
> @@ -40,26 +40,37 @@ enum boot_mode {
>  */
>  void copy_uboot_to_ram(void)
>  {
> -       spi_copy_func_t spi_copy;
>         enum boot_mode bootmode;
> -       u32 (*copy_bl2)(u32, u32, u32);
> +       u32 (*copy_bl2)(u32, u32, u32) = NULL;
> +       u32 offset = 0, size = 0;
>
> -       bootmode = readl(EXYNOS5_POWER_BASE) & OM_STAT;
> +       bootmode = readl(samsung_get_base_power()) & OM_STAT;
>
>         switch (bootmode) {
> +#ifdef CONFIG_SPI_BOOTING
>         case BOOT_MODE_SERIAL:
> -               spi_copy = *(spi_copy_func_t *)EXYNOS_COPY_SPI_FNPTR_ADDR;
> -               spi_copy(SPI_FLASH_UBOOT_POS, CONFIG_BL2_SIZE,
> -                                               CONFIG_SYS_TEXT_BASE);
> +               offset = CONFIG_BL2_OFFSET - CONFIG_RES_BLOCK_SIZE;
> +               size = CONFIG_BL2_SIZE;
> +               copy_bl2 = (void *) *(u32 *)EXYNOS_COPY_SPI_FNPTR_ADDR;
>                 break;
> +#endif
>         case BOOT_MODE_MMC:
> -               copy_bl2 = (void *) *(u32 *)COPY_BL2_FNPTR_ADDR;
> -               copy_bl2(BL2_START_OFFSET, BL2_SIZE_BLOC_COUNT,
> -                                               CONFIG_SYS_TEXT_BASE);
> +               offset = CONFIG_BL2_BLOCK_OFFSET;
> +               size = CONFIG_BL2_SIZE_BLOCK_COUNT;
> +
> +               /* Only SMDKv310 EVT0 directly jumps to BootROM copy function */
> +               if (s5p_get_cpu_rev())
> +                       copy_bl2 = (void *) *(u32 *)COPY_BL2_FNPTR_ADDR;
> +               else
> +                       copy_bl2 = (void *) COPY_BL2_FNPTR_ADDR;
> +
>                 break;
>         default:
>                 break;
>         }
> +
> +       if (copy_bl2)
> +               copy_bl2(offset, size, CONFIG_SYS_TEXT_BASE);
>  }
>
>  void board_init_f(unsigned long bootflag)
> diff --git a/board/samsung/origen/Makefile b/board/samsung/origen/Makefile
> index 3a885a5..6133b26 100644
> --- a/board/samsung/origen/Makefile
> +++ b/board/samsung/origen/Makefile
> @@ -31,10 +31,6 @@ ifndef CONFIG_SPL_BUILD
>  COBJS  += origen.o
>  endif
>
> -ifdef CONFIG_SPL_BUILD
> -COBJS  += mmc_boot.o
> -endif
> -
>  SRCS   := $(SOBJS:.o=.S) $(COBJS:.o=.c)
>  OBJS   := $(addprefix $(obj),$(COBJS) $(SOBJS))
>
> diff --git a/board/samsung/origen/mmc_boot.c b/board/samsung/origen/mmc_boot.c
> deleted file mode 100644
> index 072f161..0000000
> --- a/board/samsung/origen/mmc_boot.c
> +++ /dev/null
> @@ -1,58 +0,0 @@
> -/*
> - * Copyright (C) 2011 Samsung Electronics
> - *
> - * 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
> - */
> -
> -#include<common.h>
> -#include<config.h>
> -
> -/*
> -* Copy U-boot from mmc to RAM:
> -* COPY_BL2_FNPTR_ADDR: Address in iRAM, which Contains
> -* Pointer to API (Data transfer from mmc to ram)
> -*/
> -void copy_uboot_to_ram(void)
> -{
> -       u32 (*copy_bl2)(u32, u32, u32)  = (void *) *(u32 *)COPY_BL2_FNPTR_ADDR;
> -
> -       copy_bl2(BL2_START_OFFSET, BL2_SIZE_BLOC_COUNT, CONFIG_SYS_TEXT_BASE);
> -}
> -
> -void board_init_f(unsigned long bootflag)
> -{
> -       __attribute__((noreturn)) void (*uboot)(void);
> -       copy_uboot_to_ram();
> -
> -       /* Jump to U-Boot image */
> -       uboot = (void *)CONFIG_SYS_TEXT_BASE;
> -       (*uboot)();
> -       /* Never returns Here */
> -}
> -
> -/* Place Holders */
> -void board_init_r(gd_t *id, ulong dest_addr)
> -{
> -       /* Function attribute is no-return */
> -       /* This Function never executes */
> -       while (1)
> -               ;
> -}
> -
> -void save_boot_params(u32 r0, u32 r1, u32 r2, u32 r3) {}
> diff --git a/board/samsung/smdk5250/Makefile b/board/samsung/smdk5250/Makefile
> index f2c32ee..075b1a7 100644
> --- a/board/samsung/smdk5250/Makefile
> +++ b/board/samsung/smdk5250/Makefile
> @@ -38,10 +38,6 @@ COBJS        += smdk5250.o
>  endif
>  endif
>
> -ifdef CONFIG_SPL_BUILD
> -COBJS  += spl_boot.o
> -endif
> -
>  SRCS   := $(SOBJS:.o=.S) $(COBJS:.o=.c)
>  OBJS   := $(addprefix $(obj),$(COBJS) $(SOBJS))
>
> diff --git a/board/samsung/smdkv310/Makefile b/board/samsung/smdkv310/Makefile
> index 56e0c16..e79045d 100644
> --- a/board/samsung/smdkv310/Makefile
> +++ b/board/samsung/smdkv310/Makefile
> @@ -30,10 +30,6 @@ ifndef CONFIG_SPL_BUILD
>  COBJS  += smdkv310.o
>  endif
>
> -ifdef CONFIG_SPL_BUILD
> -COBJS  += mmc_boot.o
> -endif
> -
>  SRCS   := $(SOBJS:.o=.S) $(COBJS:.o=.c)
>  OBJS   := $(addprefix $(obj),$(COBJS) $(SOBJS))
>
> diff --git a/board/samsung/smdkv310/mmc_boot.c b/board/samsung/smdkv310/mmc_boot.c
> deleted file mode 100644
> index d3fc18d..0000000
> --- a/board/samsung/smdkv310/mmc_boot.c
> +++ /dev/null
> @@ -1,60 +0,0 @@
> -/*
> - * Copyright (C) 2011 Samsung Electronics
> - *
> - * 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
> - */
> -
> -#include<common.h>
> -#include<config.h>
> -
> -/*
> -* Copy U-boot from mmc to RAM:
> -* COPY_BL2_FNPTR_ADDR: Address in iRAM, which Contains
> -* API (Data transfer from mmc to ram)
> -*/
> -void copy_uboot_to_ram(void)
> -{
> -       u32 (*copy_bl2)(u32, u32, u32) = (void *)COPY_BL2_FNPTR_ADDR;
> -
> -       copy_bl2(BL2_START_OFFSET, BL2_SIZE_BLOC_COUNT, CONFIG_SYS_TEXT_BASE);
> -}
> -
> -void board_init_f(unsigned long bootflag)
> -{
> -       __attribute__((noreturn)) void (*uboot)(void);
> -       copy_uboot_to_ram();
> -
> -       /* Jump to U-Boot image */
> -       uboot = (void *)CONFIG_SYS_TEXT_BASE;
> -       (*uboot)();
> -       /* Never returns Here */
> -}
> -
> -/* Place Holders */
> -void board_init_r(gd_t *id, ulong dest_addr)
> -{
> -       /*Function attribute is no-return*/
> -       /*This Function never executes*/
> -       while (1)
> -               ;
> -}
> -
> -void save_boot_params(u32 r0, u32 r1, u32 r2, u32 r3)
> -{
> -}
> diff --git a/include/configs/exynos5250-dt.h b/include/configs/exynos5250-dt.h
> index 16d3ab1..7308522 100644
> --- a/include/configs/exynos5250-dt.h
> +++ b/include/configs/exynos5250-dt.h
> @@ -206,12 +206,14 @@
>  #define CONFIG_ENV_OFFSET      (CONFIG_BL2_OFFSET + CONFIG_BL2_SIZE)
>
>  /* U-boot copy size from boot Media to DRAM.*/
> -#define BL2_START_OFFSET       (CONFIG_BL2_OFFSET/512)
> -#define BL2_SIZE_BLOC_COUNT    (CONFIG_BL2_SIZE/512)
> +#define CONFIG_BL2_BLOCK_OFFSET                (CONFIG_BL2_OFFSET/512)
> +#define CONFIG_BL2_SIZE_BLOCK_COUNT    (CONFIG_BL2_SIZE/512)
>
> -#define OM_STAT                                (0x1f << 1)
> +#define CONFIG_SPI_BOOTING
> +
> +#ifdef CONFIG_SPI_BOOTING
>  #define EXYNOS_COPY_SPI_FNPTR_ADDR     0x02020058
> -#define SPI_FLASH_UBOOT_POS            (CONFIG_SEC_FW_SIZE + CONFIG_BL1_SIZE)
> +#endif
>
>  #define CONFIG_DOS_PARTITION
>
> diff --git a/include/configs/origen.h b/include/configs/origen.h
> index e179911..c4f2ec0 100644
> --- a/include/configs/origen.h
> +++ b/include/configs/origen.h
> @@ -139,20 +139,21 @@
>  /* MIU (Memory Interleaving Unit) */
>  #define CONFIG_MIU_2BIT_21_7_INTERLEAVED
>
> -#define CONFIG_ENV_IS_IN_MMC           1
> -#define CONFIG_SYS_MMC_ENV_DEV         0
> -#define CONFIG_ENV_SIZE                        (16 << 10)      /* 16 KB */
> -#define RESERVE_BLOCK_SIZE             (512)
> -#define BL1_SIZE                       (16 << 10) /*16 K reserved for BL1*/
> -#define CONFIG_ENV_OFFSET              (RESERVE_BLOCK_SIZE + BL1_SIZE)
> -#define CONFIG_DOS_PARTITION           1
> +#define CONFIG_ENV_IS_IN_MMC   1
> +#define CONFIG_SYS_MMC_ENV_DEV 0
> +#define CONFIG_ENV_SIZE                (16 << 10)      /* 16 KB */
> +#define CONFIG_RES_BLOCK_SIZE  (512)
> +#define CONFIG_BL1_SIZE                (16 << 10) /*16 K reserved for BL1*/
> +#define CONFIG_ENV_OFFSET      (CONFIG_RES_BLOCK_SIZE + CONFIG_BL1_SIZE)
> +#define CONFIG_BL2_OFFSET      (CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE)
> +#define CONFIG_DOS_PARTITION   1
>
>  #define CONFIG_SYS_INIT_SP_ADDR        (CONFIG_SYS_LOAD_ADDR - GENERATED_GBL_DATA_SIZE)
>
>  /* U-boot copy size from boot Media to DRAM.*/
> -#define COPY_BL2_SIZE          0x80000
> -#define BL2_START_OFFSET       ((CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE)/512)
> -#define BL2_SIZE_BLOC_COUNT    (COPY_BL2_SIZE/512)
> +#define CONFIG_BL2_SIZE                        0x80000
> +#define CONFIG_BL2_BLOCK_OFFSET                (CONFIG_BL2_OFFSET/512)
> +#define CONFIG_BL2_SIZE_BLOCK_COUNT    (CONFIG_BL2_SIZE/512)
>
>  /* Enable devicetree support */
>  #define CONFIG_OF_LIBFDT
> diff --git a/include/configs/smdkv310.h b/include/configs/smdkv310.h
> index 5e43066..8bb8de7 100644
> --- a/include/configs/smdkv310.h
> +++ b/include/configs/smdkv310.h
> @@ -138,20 +138,21 @@
>  /* MIU (Memory Interleaving Unit) */
>  #define CONFIG_MIU_2BIT_INTERLEAVED
>
> -#define CONFIG_ENV_IS_IN_MMC           1
> -#define CONFIG_SYS_MMC_ENV_DEV         0
> -#define CONFIG_ENV_SIZE                        (16 << 10)      /* 16 KB */
> -#define RESERVE_BLOCK_SIZE             (512)
> -#define BL1_SIZE                       (16 << 10) /*16 K reserved for BL1*/
> -#define CONFIG_ENV_OFFSET              (RESERVE_BLOCK_SIZE + BL1_SIZE)
> -#define CONFIG_DOS_PARTITION           1
> +#define CONFIG_ENV_IS_IN_MMC   1
> +#define CONFIG_SYS_MMC_ENV_DEV 0
> +#define CONFIG_ENV_SIZE                (16 << 10) /* 16 KB */
> +#define CONFIG_RES_BLOCK_SIZE  (512)
> +#define CONFIG_BL1_SIZE                (16 << 10) /*16 K reserved for BL1*/
> +#define CONFIG_ENV_OFFSET      (CONFIG_RES_BLOCK_SIZE + CONFIG_BL1_SIZE)
> +#define CONFIG_BL2_OFFSET      (CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE)
> +#define CONFIG_DOS_PARTITION   1
>
>  #define CONFIG_SYS_INIT_SP_ADDR        (CONFIG_SYS_LOAD_ADDR - GENERATED_GBL_DATA_SIZE)
>
>  /* U-boot copy size from boot Media to DRAM.*/
> -#define        COPY_BL2_SIZE           0x80000
> -#define BL2_START_OFFSET       ((CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE)/512)
> -#define BL2_SIZE_BLOC_COUNT    (COPY_BL2_SIZE/512)
> +#define        CONFIG_BL2_SIZE                 0x80000
> +#define CONFIG_BL2_BLOCK_OFFSET                (CONFIG_BL2_OFFSET/512)
> +#define CONFIG_BL2_SIZE_BLOCK_COUNT    (CONFIG_BL2_SIZE/512)
>
>  /* Ethernet Controllor Driver */
>  #ifdef CONFIG_CMD_NET
> --
> 1.7.9.5
>


More information about the U-Boot mailing list