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

Inderpal Singh inderpal.singh at linaro.org
Fri Jun 7 08:14:18 CEST 2013


Dear Minkyu Kang,

Thanks for the review.


On 4 June 2013 12:56, Minkyu Kang <mk7.kang at samsung.com> wrote:

> Dear Inderpal Singh,
>
> On 27/03/13 17:48, Inderpal Singh wrote:
> > 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
>
> Since this patch had wait too long on queue, need to rebase.
> I'm sorry to late review.
>
> >>
> >> 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
>
> Is this ifdef needs?
>

I introduced this ifdef because only exynos5250 has
EXYNOS_COPY_SPI_FNPTR_ADDR defined.
If i don't use this ifdef, It won't compile for origen, smdkv310 etc.


> >>         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())
>
> According to your comment, you should check cpu_ids.
>

The s5p_cpu_rev is being set to zero only for Exynos4210 EVT0, hence I
thought only revision check is sufficient.
That's, perhaps, not very clear. I will change it to check both cpuid as
well as 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
>
> I think this ifdef is unnecessary.
> You already know that we will use spi booting on this board.
>

As this is consolidation patch, I introduced this to solve the compilation
issue for other boards as mentioned above.

Now, the USB download boot mode is also supported on exynos5250 and it has
one more EXYNOS_COPY_USB_FNPTR_ADDR. The other boards won't have this as
well.

Let me know your thinking about handling this issue for spl_boot.c
consolidation.

With Regards,
Inder


>
> >>  #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
> >>
> >
>
> This patch needs to test.
> Please help to test this patch and let me know.
>
> Thanks,
> Minkyu Kang.
>


More information about the U-Boot mailing list