From patchwork Sat Mar 16 08:46:34 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inderpal Singh X-Patchwork-Id: 15388 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id AA70923E39 for ; Sat, 16 Mar 2013 08:46:45 +0000 (UTC) Received: from mail-vc0-f169.google.com (mail-vc0-f169.google.com [209.85.220.169]) by fiordland.canonical.com (Postfix) with ESMTP id 17F15A182C9 for ; Sat, 16 Mar 2013 08:46:45 +0000 (UTC) Received: by mail-vc0-f169.google.com with SMTP id kw10so1806024vcb.14 for ; Sat, 16 Mar 2013 01:46:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=2NzYQa3NKjX7NQFm0cKd/CMqp2hT8thX8txsLs/Zeuc=; b=DO/HyqSmD6u3dnqajvp0yk6XWgAsL8qRvAIJsC2bZcaJhVwWelksvVWBWwjN+suPGw 6w2Ydj5qS2WKGQfbY4GOXkiK2CntQGlFRScyn/vP1YaQeg5TpQgbk/fyN+zrYJmb8SeP u+YFCcewoQwYYsXXPpZuA/a7RtGYHK2ftNfw7tmnKEXePZ49ATcNHk4mgnEKxoSUnVaK SekRBgILXL9YTepEULNBSfr7klDYZ2FMAZKoNvwA6UczSdPQp08VEY4I5G1VWngLEl/+ SBXfPesLgnCrE/gcGTsRgWks6Uq2mKglAsm13dgKPpEBO4Ndf1ZXQI9e6+U7kJ2OydjX QQHw== X-Received: by 10.52.88.237 with SMTP id bj13mr9339846vdb.75.1363423604480; Sat, 16 Mar 2013 01:46:44 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.58.127.98 with SMTP id nf2csp154388veb; Sat, 16 Mar 2013 01:46:43 -0700 (PDT) X-Received: by 10.68.65.226 with SMTP id a2mr23353749pbt.92.1363423603075; Sat, 16 Mar 2013 01:46:43 -0700 (PDT) Received: from mail-pb0-f52.google.com (mail-pb0-f52.google.com [209.85.160.52]) by mx.google.com with ESMTPS id cg2si10358496pbc.64.2013.03.16.01.46.42 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 16 Mar 2013 01:46:42 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.52 is neither permitted nor denied by best guess record for domain of inderpal.singh@linaro.org) client-ip=209.85.160.52; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.52 is neither permitted nor denied by best guess record for domain of inderpal.singh@linaro.org) smtp.mail=inderpal.singh@linaro.org Received: by mail-pb0-f52.google.com with SMTP id ma3so4830079pbc.11 for ; Sat, 16 Mar 2013 01:46:42 -0700 (PDT) X-Received: by 10.68.241.102 with SMTP id wh6mr23684069pbc.150.1363423602059; Sat, 16 Mar 2013 01:46:42 -0700 (PDT) Received: from inder-ubuntu.sisodomain.com ([115.113.119.130]) by mx.google.com with ESMTPS id ve7sm287385pab.11.2013.03.16.01.46.39 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 16 Mar 2013 01:46:41 -0700 (PDT) From: Inderpal Singh To: u-boot@lists.denx.de Cc: promsoft@gmail.com, patches@linaro.org Subject: [PATCH] spl: exynos: make spl_boot common for all exynos based platforms Date: Sat, 16 Mar 2013 14:16:34 +0530 Message-Id: <1363423594-15077-1-git-send-email-inderpal.singh@linaro.org> X-Mailer: git-send-email 1.7.9.5 X-Gm-Message-State: ALoCoQmawajLhoyr2iHu/kUEVnaEN7fNrPf1LqTWirk+ShrmuFK8TOZZT7Hy1tpw0z81iya0GR+V 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 --- 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 #include +#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 -#include - -/* -* 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 -#include - -/* -* 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