Merge git://git.denx.de/u-boot-uniphier

- fix sparse warnings
- sync DT with Linux
- add new board support (LD11/LD20 global)
diff --git a/MAINTAINERS b/MAINTAINERS
index 37cefdb..957e27c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -133,6 +133,7 @@
 
 ARM ROCKCHIP
 M:	Simon Glass <sjg@chromium.org>
+M:	Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
 S:	Maintained
 T:	git git://git.denx.de/u-boot-rockchip.git
 F:	arch/arm/mach-rockchip/
diff --git a/api/api_storage.c b/api/api_storage.c
index f858f09..8bed2f3 100644
--- a/api/api_storage.c
+++ b/api/api_storage.c
@@ -43,6 +43,9 @@
 
 static struct stor_spec specs[ENUM_MAX] = { { 0, 0, 0, 0, NULL }, };
 
+#ifndef CONFIG_SYS_MMC_MAX_DEVICE
+#define CONFIG_SYS_MMC_MAX_DEVICE	1
+#endif
 
 void dev_stor_init(void)
 {
diff --git a/arch/arm/dts/am437x-gp-evm-u-boot.dtsi b/arch/arm/dts/am437x-gp-evm-u-boot.dtsi
index 885a9a9..530f549 100644
--- a/arch/arm/dts/am437x-gp-evm-u-boot.dtsi
+++ b/arch/arm/dts/am437x-gp-evm-u-boot.dtsi
@@ -9,30 +9,30 @@
 
 /{
 	ocp {
-		u-boot,dm-pre-reloc;
+		u-boot,dm-spl;
 	};
 };
 
 &uart0 {
-	u-boot,dm-pre-reloc;
+	u-boot,dm-spl;
 };
 
 &mmc1 {
-	u-boot,dm-pre-reloc;
+	u-boot,dm-spl;
 };
 
 &mac {
-	u-boot,dm-pre-reloc;
+	u-boot,dm-spl;
 };
 
 &davinci_mdio {
-	u-boot,dm-pre-reloc;
+	u-boot,dm-spl;
 };
 
 &cpsw_emac0 {
-	u-boot,dm-pre-reloc;
+	u-boot,dm-spl;
 };
 
 &phy_sel {
-	u-boot,dm-pre-reloc;
+	u-boot,dm-spl;
 };
diff --git a/arch/arm/dts/at91sam9g45-corvus.dts b/arch/arm/dts/at91sam9g45-corvus.dts
index c207c02..6367996 100644
--- a/arch/arm/dts/at91sam9g45-corvus.dts
+++ b/arch/arm/dts/at91sam9g45-corvus.dts
@@ -18,6 +18,7 @@
 	compatible = "atmel,at91sam9m10g45ek", "atmel,at91sam9g45", "atmel,at91sam9";
 
 	chosen {
+		u-boot,dm-pre-reloc;
 		stdout-path = &dbgu;
 	};
 
@@ -38,6 +39,7 @@
 	ahb {
 		apb {
 			dbgu: serial@ffffee00 {
+				u-boot,dm-pre-reloc;
 				status = "okay";
 			};
 
diff --git a/arch/arm/dts/omap5-u-boot.dtsi b/arch/arm/dts/omap5-u-boot.dtsi
index 9247314..9f9b4d1 100644
--- a/arch/arm/dts/omap5-u-boot.dtsi
+++ b/arch/arm/dts/omap5-u-boot.dtsi
@@ -9,7 +9,7 @@
 
 /{
 	ocp {
-		u-boot,dm-pre-reloc;
+		u-boot,dm-spl;
 
 		ocp2scp@4a090000 {
 			compatible = "ti,omap-ocp2scp", "simple-bus";
@@ -18,37 +18,37 @@
 };
 
 &uart1 {
-	u-boot,dm-pre-reloc;
+	u-boot,dm-spl;
 };
 
 &uart3 {
-	u-boot,dm-pre-reloc;
+	u-boot,dm-spl;
 };
 
 &mmc1 {
-	u-boot,dm-pre-reloc;
+	u-boot,dm-spl;
 };
 
 &mmc2 {
-	u-boot,dm-pre-reloc;
+	u-boot,dm-spl;
 };
 
 &l4_cfg {
-	u-boot,dm-pre-reloc;
+	u-boot,dm-spl;
 };
 
 &scm {
-	u-boot,dm-pre-reloc;
+	u-boot,dm-spl;
 };
 
 &scm_conf {
-	u-boot,dm-pre-reloc;
+	u-boot,dm-spl;
 };
 
 &qspi {
-	u-boot,dm-pre-reloc;
+	u-boot,dm-spl;
 
 	m25p80@0 {
-		u-boot,dm-pre-reloc;
+		u-boot,dm-spl;
 	};
 };
diff --git a/arch/arm/mach-omap2/boot-common.c b/arch/arm/mach-omap2/boot-common.c
index 29c8f23..b77506d 100644
--- a/arch/arm/mach-omap2/boot-common.c
+++ b/arch/arm/mach-omap2/boot-common.c
@@ -65,6 +65,23 @@
 	if (boot_device == BOOT_DEVICE_QSPI_4)
 		boot_device = BOOT_DEVICE_SPI;
 #endif
+#ifdef CONFIG_TI816X
+	/*
+	 * On PG2.0 and later TI816x the values we get when booting are not the
+	 * same as on PG1.0, which is what the defines are based on.  Update
+	 * them as needed.
+	 */
+	if (get_cpu_rev() != 1) {
+		if (boot_device == 0x05) {
+			omap_boot_params->boot_device = BOOT_DEVICE_NAND;
+			boot_device = BOOT_DEVICE_NAND;
+		}
+		if (boot_device == 0x08) {
+			omap_boot_params->boot_device = BOOT_DEVICE_MMC1;
+			boot_device = BOOT_DEVICE_MMC1;
+		}
+	}
+#endif
 	/*
 	 * When booting from peripheral booting, the boot device is not usable
 	 * as-is (unless there is support for it), so the boot device is instead
diff --git a/board/gdsys/p1022/controlcenterd-id.c b/board/gdsys/p1022/controlcenterd-id.c
index db8a917..95f11fb 100644
--- a/board/gdsys/p1022/controlcenterd-id.c
+++ b/board/gdsys/p1022/controlcenterd-id.c
@@ -142,20 +142,6 @@
 #define IS_VAR_HREG(spec) (((spec) & 0x38) == 0x10)
 #define HREG_IDX(spec) ((spec) & (IS_PCR_HREG(spec) ? 0x1f : 0x7))
 
-
-static const uint8_t prg_stage1_prepare[] = {
-	0x00, 0x20, 0x00, 0x00, /* opcode: SYNC f0 */
-	0x00, 0x24, 0x00, 0x00, /* opcode: SYNC f1 */
-	0x01, 0x80, 0x00, 0x00, /* opcode: CHECK0 PCR0 */
-	0x81, 0x22, 0x00, 0x00, /* opcode: LOAD PCR0, f0 */
-	0x01, 0x84, 0x00, 0x00, /* opcode: CHECK0 PCR1 */
-	0x81, 0x26, 0x10, 0x00, /* opcode: LOAD PCR1, f1 */
-	0x01, 0x88, 0x00, 0x00, /* opcode: CHECK0 PCR2 */
-	0x81, 0x2a, 0x20, 0x00, /* opcode: LOAD PCR2, f2 */
-	0x01, 0x8c, 0x00, 0x00, /* opcode: CHECK0 PCR3 */
-	0x81, 0x2e, 0x30, 0x00, /* opcode: LOAD PCR3, f3 */
-};
-
 static const uint8_t vendor[] = "Guntermann & Drunck";
 
 /**
@@ -931,6 +917,19 @@
 #endif
 
 #if defined(CCDM_FIRST_STAGE) || (defined CCDM_AUTO_FIRST_STAGE)
+static const uint8_t prg_stage1_prepare[] = {
+	0x00, 0x20, 0x00, 0x00, /* opcode: SYNC f0 */
+	0x00, 0x24, 0x00, 0x00, /* opcode: SYNC f1 */
+	0x01, 0x80, 0x00, 0x00, /* opcode: CHECK0 PCR0 */
+	0x81, 0x22, 0x00, 0x00, /* opcode: LOAD PCR0, f0 */
+	0x01, 0x84, 0x00, 0x00, /* opcode: CHECK0 PCR1 */
+	0x81, 0x26, 0x10, 0x00, /* opcode: LOAD PCR1, f1 */
+	0x01, 0x88, 0x00, 0x00, /* opcode: CHECK0 PCR2 */
+	0x81, 0x2a, 0x20, 0x00, /* opcode: LOAD PCR2, f2 */
+	0x01, 0x8c, 0x00, 0x00, /* opcode: CHECK0 PCR3 */
+	0x81, 0x2e, 0x30, 0x00, /* opcode: LOAD PCR3, f3 */
+};
+
 static int first_stage_actions(void)
 {
 	int result = 0;
diff --git a/board/qualcomm/dragonboard410c/u-boot.lds b/board/qualcomm/dragonboard410c/u-boot.lds
index 6e1c5a8..62ac4d7 100644
--- a/board/qualcomm/dragonboard410c/u-boot.lds
+++ b/board/qualcomm/dragonboard410c/u-boot.lds
@@ -43,6 +43,22 @@
 
 	. = ALIGN(8);
 
+	.efi_runtime : {
+                __efi_runtime_start = .;
+		*(efi_runtime_text)
+		*(efi_runtime_data)
+                __efi_runtime_stop = .;
+	}
+
+	.efi_runtime_rel : {
+                __efi_runtime_rel_start = .;
+		*(.relaefi_runtime_text)
+		*(.relaefi_runtime_data)
+                __efi_runtime_rel_stop = .;
+	}
+
+	. = ALIGN(8);
+
 	.image_copy_end :
 	{
 		*(.__image_copy_end)
diff --git a/cmd/bdinfo.c b/cmd/bdinfo.c
index 48dba20..45baa2e 100644
--- a/cmd/bdinfo.c
+++ b/cmd/bdinfo.c
@@ -375,6 +375,8 @@
 	printf("Early malloc usage: %lx / %x\n", gd->malloc_ptr,
 	       CONFIG_SYS_MALLOC_F_LEN);
 #endif
+	if (gd->fdt_blob)
+		printf("fdt_blob = %p\n", gd->fdt_blob);
 
 	return 0;
 }
diff --git a/configs/corvus_defconfig b/configs/corvus_defconfig
index 36e6608..ac5eefd 100644
--- a/configs/corvus_defconfig
+++ b/configs/corvus_defconfig
@@ -6,6 +6,7 @@
 CONFIG_SPL_GPIO_SUPPORT=y
 CONFIG_SPL_LIBCOMMON_SUPPORT=y
 CONFIG_SPL_LIBGENERIC_SUPPORT=y
+CONFIG_SYS_MALLOC_F_LEN=0x800
 CONFIG_SPL_SERIAL_SUPPORT=y
 CONFIG_SPL_NAND_SUPPORT=y
 CONFIG_DEFAULT_DEVICE_TREE="at91sam9g45-corvus"
@@ -31,8 +32,13 @@
 CONFIG_CMD_PING=y
 CONFIG_OF_CONTROL=y
 CONFIG_OF_EMBED=y
+CONFIG_CLK=y
+CONFIG_CLK_AT91=y
+CONFIG_AT91_UTMI=y
 CONFIG_DFU_NAND=y
 # CONFIG_MMC is not set
+# CONFIG_SPL_DM_SERIAL is not set
+CONFIG_ATMEL_USART=y
 CONFIG_USB=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_STORAGE=y
diff --git a/doc/git-mailrc b/doc/git-mailrc
index 33317d1..04c6c8d 100644
--- a/doc/git-mailrc
+++ b/doc/git-mailrc
@@ -40,6 +40,7 @@
 alias monstr         Michal Simek <monstr@monstr.eu>
 alias prafulla       Prafulla Wadaskar <prafulla@marvell.com>
 alias prom           Minkyu Kang <mk7.kang@samsung.com>
+alias ptomsich       Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
 alias rbohmer        Remy Bohmer <linux@bohmer.net>
 alias reinhardm      Reinhard Meyer <u-boot@emk-elektronik.de>
 alias sbabic         Stefano Babic <sbabic@denx.de>
@@ -77,7 +78,7 @@
 alias ti             uboot, trini
 alias uniphier       uboot, masahiro
 alias zynq           uboot, monstr
-alias rockchip       uboot, sjg, Kever Yang <kever.yang@rock-chips.com>
+alias rockchip       uboot, sjg, Kever Yang <kever.yang@rock-chips.com>, ptomsich
 alias avr32          uboot, abiessmann
 
 alias bfin           uboot, vapier, sonic
diff --git a/drivers/clk/rockchip/clk_rk3036.c b/drivers/clk/rockchip/clk_rk3036.c
index 28652df..5ecf512 100644
--- a/drivers/clk/rockchip/clk_rk3036.c
+++ b/drivers/clk/rockchip/clk_rk3036.c
@@ -40,7 +40,7 @@
 			 #hz "Hz cannot be hit with PLL "\
 			 "divisors on line " __stringify(__LINE__));
 
-/* use interge mode*/
+/* use integer mode*/
 static const struct pll_div apll_init_cfg = PLL_DIVISORS(APLL_HZ, 1, 3, 1);
 static const struct pll_div gpll_init_cfg = PLL_DIVISORS(GPLL_HZ, 2, 2, 1);
 
@@ -61,8 +61,8 @@
 	assert(vco_hz >= VCO_MIN_HZ && vco_hz <= VCO_MAX_HZ &&
 	       output_hz >= OUTPUT_MIN_HZ && output_hz <= OUTPUT_MAX_HZ);
 
-	/* use interger mode */
-	rk_clrreg(&pll->con1, 1 << PLL_DSMPD_SHIFT);
+	/* use integer mode */
+	rk_setreg(&pll->con1, 1 << PLL_DSMPD_SHIFT);
 
 	rk_clrsetreg(&pll->con0,
 		     PLL_POSTDIV1_MASK | PLL_FBDIV_MASK,
diff --git a/drivers/clk/rockchip/clk_rv1108.c b/drivers/clk/rockchip/clk_rv1108.c
index 0a3ba3b..818293d 100644
--- a/drivers/clk/rockchip/clk_rv1108.c
+++ b/drivers/clk/rockchip/clk_rv1108.c
@@ -40,9 +40,6 @@
 			 "divisors on line " __stringify(__LINE__));
 
 /* use interge mode*/
-static const struct pll_div apll_init_cfg = PLL_DIVISORS(APLL_HZ, 1, 3, 1);
-static const struct pll_div gpll_init_cfg = PLL_DIVISORS(GPLL_HZ, 2, 2, 1);
-
 static inline int rv1108_pll_id(enum rk_clk_id clk_id)
 {
 	int id = 0;
diff --git a/drivers/mtd/onenand/onenand_base.c b/drivers/mtd/onenand/onenand_base.c
index 2e3d0e5..8282f68 100644
--- a/drivers/mtd/onenand/onenand_base.c
+++ b/drivers/mtd/onenand/onenand_base.c
@@ -1919,6 +1919,7 @@
  */
 int onenand_block_markbad(struct mtd_info *mtd, loff_t ofs)
 {
+	struct onenand_chip *this = mtd->priv;
 	int ret;
 
 	ret = onenand_block_isbad(mtd, ofs);
@@ -1929,7 +1930,10 @@
 		return ret;
 	}
 
-	ret = mtd_block_markbad(mtd, ofs);
+	onenand_get_device(mtd, FL_WRITING);
+	ret = this->block_markbad(mtd, ofs);
+	onenand_release_device(mtd);
+
 	return ret;
 }
 
diff --git a/drivers/mtd/onenand/onenand_spl.c b/drivers/mtd/onenand/onenand_spl.c
index 1925f41..0b78067 100644
--- a/drivers/mtd/onenand/onenand_spl.c
+++ b/drivers/mtd/onenand/onenand_spl.c
@@ -23,11 +23,29 @@
 	PAGE_4K = 4096,
 };
 
+static unsigned int density_mask;
+
 #define ONENAND_PAGES_PER_BLOCK			64
-#define onenand_block_address(block)		(block)
 #define onenand_sector_address(page)		(page << 2)
 #define onenand_buffer_address()		((1 << 3) << 8)
-#define onenand_bufferram_address(block)	(0)
+
+static inline int onenand_block_address(int block)
+{
+	/* Device Flash Core select, NAND Flash Block Address */
+	if (block & density_mask)
+		return ONENAND_DDP_CHIP1 | (block ^ density_mask);
+
+	return block;
+}
+
+static inline int onenand_bufferram_address(int block)
+{
+	/* Device BufferRAM Select */
+	if (block & density_mask)
+		return ONENAND_DDP_CHIP1;
+
+	return ONENAND_DDP_CHIP0;
+}
 
 static inline uint16_t onenand_readw(uint32_t addr)
 {
@@ -41,7 +59,7 @@
 
 static enum onenand_spl_pagesize onenand_spl_get_geometry(void)
 {
-	uint32_t dev_id, density;
+	unsigned int dev_id, density, size;
 
 	if (!onenand_readw(ONENAND_REG_TECHNOLOGY)) {
 		dev_id = onenand_readw(ONENAND_REG_DEVICE_ID);
@@ -51,8 +69,11 @@
 		if (density < ONENAND_DEVICE_DENSITY_4Gb)
 			return PAGE_2K;
 
-		if (dev_id & ONENAND_DEVICE_IS_DDP)
+		if (dev_id & ONENAND_DEVICE_IS_DDP) {
+			size = onenand_readw(ONENAND_REG_DATA_BUFFER_SIZE);
+			density_mask = 1 << (18 + density - ffs(size));
 			return PAGE_2K;
+		}
 	}
 
 	return PAGE_4K;
@@ -110,9 +131,12 @@
  */
 int onenand_spl_read_block(int block, int offset, int len, void *dst)
 {
-	int page, read, psize;
+	int page, read;
+	static int psize;
+
+	if (!psize)
+		psize = onenand_spl_get_geometry();
 
-	psize = onenand_spl_get_geometry();
 	/* Calculate the page number */
 	page = offset / psize;
 	/* Offset to the start of a flash page */
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 58fc7cd..c64f4a6 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -65,7 +65,7 @@
 	  defined in include/serial.h.
 
 config SPL_DM_SERIAL
-	bool "Enable Driver Model for serial drivers"
+	bool "Enable Driver Model for serial drivers in SPL"
 	depends on DM_SERIAL
 	default y if SPL && DM_SERIAL
 	help
@@ -75,7 +75,7 @@
 	  defined in include/serial.h.
 
 config TPL_DM_SERIAL
-	bool "Enable Driver Model for serial drivers"
+	bool "Enable Driver Model for serial drivers in TPL"
 	depends on DM_SERIAL
 	default y if TPL && DM_SERIAL
 	help
diff --git a/include/configs/corvus.h b/include/configs/corvus.h
index 3847a19..8b8b122 100644
--- a/include/configs/corvus.h
+++ b/include/configs/corvus.h
@@ -43,7 +43,6 @@
 #define CONFIG_AT91_GPIO_PULLUP	1	/* keep pullups on peripheral pins */
 
 /* serial console */
-#define CONFIG_ATMEL_USART
 #define CONFIG_USART_BASE		ATMEL_BASE_DBGU
 #define CONFIG_USART_ID			ATMEL_ID_SYS
 
@@ -72,7 +71,7 @@
 #define CONFIG_SYS_SDRAM_SIZE		0x08000000
 
 #define CONFIG_SYS_INIT_SP_ADDR \
-	(CONFIG_SYS_SDRAM_BASE + SZ_4K - GENERATED_GBL_DATA_SIZE)
+	(CONFIG_SYS_SDRAM_BASE + SZ_32K - GENERATED_GBL_DATA_SIZE)
 
 /* NAND flash */
 #ifdef CONFIG_CMD_NAND
diff --git a/include/configs/rk3399_common.h b/include/configs/rk3399_common.h
index 7a8a442..44dad57 100644
--- a/include/configs/rk3399_common.h
+++ b/include/configs/rk3399_common.h
@@ -31,7 +31,7 @@
 #define CONFIG_SYS_LOAD_ADDR		0x00800800
 #define CONFIG_SPL_STACK		0xff8effff
 #define CONFIG_SPL_TEXT_BASE		0xff8c2000
-#define CONFIG_SPL_MAX_SIZE		0x30000
+#define CONFIG_SPL_MAX_SIZE		0x30000 - 0x2000
 /*  BSS setup */
 #define CONFIG_SPL_BSS_START_ADDR       0xff8e0000
 #define CONFIG_SPL_BSS_MAX_SIZE         0x10000
diff --git a/include/configs/ti_omap5_common.h b/include/configs/ti_omap5_common.h
index d45baab..4c3a276 100644
--- a/include/configs/ti_omap5_common.h
+++ b/include/configs/ti_omap5_common.h
@@ -50,14 +50,12 @@
 /*
  * Environment setup
  */
-#ifndef PARTS_DEFAULT
-#define PARTS_DEFAULT
-#endif
 
 #ifndef DFUARGS
 #define DFUARGS
 #endif
 
+#include <environment/ti/boot.h>
 #include <environment/ti/mmc.h>
 
 #define CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
@@ -65,63 +63,11 @@
 	DEFAULT_LINUX_BOOT_ENV \
 	DEFAULT_MMC_TI_ARGS \
 	DEFAULT_FIT_TI_ARGS \
-	"console=" CONSOLEDEV ",115200n8\0" \
-	"fdtfile=undefined\0" \
-	"bootpart=0:2\0" \
-	"bootdir=/boot\0" \
-	"bootfile=zImage\0" \
-	"usbtty=cdc_acm\0" \
-	"vram=16M\0" \
-	"partitions=" PARTS_DEFAULT "\0" \
-	"optargs=\0" \
-	"dofastboot=0\0" \
-	"findfdt="\
-		"if test $board_name = omap5_uevm; then " \
-			"setenv fdtfile omap5-uevm.dtb; fi; " \
-		"if test $board_name = dra7xx; then " \
-			"setenv fdtfile dra7-evm.dtb; fi;" \
-		"if test $board_name = dra72x-revc; then " \
-			"setenv fdtfile dra72-evm-revc.dtb; fi;" \
-		"if test $board_name = dra72x; then " \
-			"setenv fdtfile dra72-evm.dtb; fi;" \
-		"if test $board_name = dra71x; then " \
-			"setenv fdtfile dra71-evm.dtb; fi;" \
-		"if test $board_name = beagle_x15; then " \
-			"setenv fdtfile am57xx-beagle-x15.dtb; fi;" \
-		"if test $board_name = beagle_x15_revb1; then " \
-			"setenv fdtfile am57xx-beagle-x15-revb1.dtb; fi;" \
-		"if test $board_name = am572x_idk; then " \
-			"setenv fdtfile am572x-idk.dtb; fi;" \
-		"if test $board_name = am57xx_evm; then " \
-			"setenv fdtfile am57xx-beagle-x15.dtb; fi;" \
-		"if test $board_name = am57xx_evm_reva3; then " \
-			"setenv fdtfile am57xx-beagle-x15.dtb; fi;" \
-		"if test $board_name = am571x_idk; then " \
-			"setenv fdtfile am571x-idk.dtb; fi;" \
-		"if test $fdtfile = undefined; then " \
-			"echo WARNING: Could not determine device tree to use; fi; \0" \
+	DEFAULT_COMMON_BOOT_TI_ARGS \
+	DEFAULT_FDT_TI_ARGS \
 	DFUARGS \
 	NETARGS \
 
-#define CONFIG_BOOTCOMMAND \
-	"if test ${dofastboot} -eq 1; then " \
-		"echo Boot fastboot requested, resetting dofastboot ...;" \
-		"setenv dofastboot 0; saveenv;" \
-		"echo Booting into fastboot ...; " \
-		"fastboot " __stringify(CONFIG_FASTBOOT_USB_DEV) "; " \
-	"fi;" \
-	"if test ${boot_fit} -eq 1; then "	\
-		"run update_to_fit;"	\
-	"fi;"	\
-	"run findfdt; " \
-	"run envboot; " \
-	"run mmcboot;" \
-	"setenv mmcdev 1; " \
-	"setenv bootpart 1:2; " \
-	"setenv mmcroot /dev/mmcblk0p2 rw; " \
-	"run mmcboot;" \
-	""
-
 /*
  * SPL related defines.  The Public RAM memory map the ROM defines the
  * area between 0x40300000 and 0x4031E000 as a download area for OMAP5.
diff --git a/include/environment/ti/boot.h b/include/environment/ti/boot.h
new file mode 100644
index 0000000..1c3ae40
--- /dev/null
+++ b/include/environment/ti/boot.h
@@ -0,0 +1,83 @@
+/*
+ * Boot related environment variable definitions on TI boards.
+ *
+ * (C) Copyright 2017 Linaro Ltd.
+ * Sam Protsenko <semen.protsenko@linaro.org>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef __TI_BOOT_H
+#define __TI_BOOT_H
+
+#ifndef CONSOLEDEV
+#define CONSOLEDEV "ttyO2"
+#endif
+
+#ifndef PARTS_DEFAULT
+#define PARTS_DEFAULT
+#endif
+
+#define DEFAULT_COMMON_BOOT_TI_ARGS \
+	"console=" CONSOLEDEV ",115200n8\0" \
+	"fdtfile=undefined\0" \
+	"bootpart=0:2\0" \
+	"bootdir=/boot\0" \
+	"bootfile=zImage\0" \
+	"usbtty=cdc_acm\0" \
+	"vram=16M\0" \
+	"partitions=" PARTS_DEFAULT "\0" \
+	"optargs=\0" \
+	"dofastboot=0\0"
+
+#ifdef CONFIG_OMAP54XX
+
+#define DEFAULT_FDT_TI_ARGS \
+	"findfdt="\
+		"if test $board_name = omap5_uevm; then " \
+			"setenv fdtfile omap5-uevm.dtb; fi; " \
+		"if test $board_name = dra7xx; then " \
+			"setenv fdtfile dra7-evm.dtb; fi;" \
+		"if test $board_name = dra72x-revc; then " \
+			"setenv fdtfile dra72-evm-revc.dtb; fi;" \
+		"if test $board_name = dra72x; then " \
+			"setenv fdtfile dra72-evm.dtb; fi;" \
+		"if test $board_name = dra71x; then " \
+			"setenv fdtfile dra71-evm.dtb; fi;" \
+		"if test $board_name = beagle_x15; then " \
+			"setenv fdtfile am57xx-beagle-x15.dtb; fi;" \
+		"if test $board_name = beagle_x15_revb1; then " \
+			"setenv fdtfile am57xx-beagle-x15-revb1.dtb; fi;" \
+		"if test $board_name = am572x_idk; then " \
+			"setenv fdtfile am572x-idk.dtb; fi;" \
+		"if test $board_name = am57xx_evm; then " \
+			"setenv fdtfile am57xx-beagle-x15.dtb; fi;" \
+		"if test $board_name = am57xx_evm_reva3; then " \
+			"setenv fdtfile am57xx-beagle-x15.dtb; fi;" \
+		"if test $board_name = am571x_idk; then " \
+			"setenv fdtfile am571x-idk.dtb; fi;" \
+		"if test $fdtfile = undefined; then " \
+			"echo WARNING: Could not determine device tree to use; fi; \0"
+
+#define CONFIG_BOOTCOMMAND \
+	"if test ${dofastboot} -eq 1; then " \
+		"echo Boot fastboot requested, resetting dofastboot ...;" \
+		"setenv dofastboot 0; saveenv;" \
+		"echo Booting into fastboot ...; " \
+		"fastboot " __stringify(CONFIG_FASTBOOT_USB_DEV) "; " \
+	"fi;" \
+	"if test ${boot_fit} -eq 1; then "	\
+		"run update_to_fit;"	\
+	"fi;"	\
+	"run findfdt; " \
+	"run envboot; " \
+	"run mmcboot;" \
+	"setenv mmcdev 1; " \
+	"setenv bootpart 1:2; " \
+	"setenv mmcroot /dev/mmcblk0p2 rw; " \
+	"run mmcboot;" \
+	""
+
+#endif /* CONFIG_OMAP54XX */
+
+#endif /* __TI_BOOT_H */
diff --git a/post/cpu/ppc4xx/denali_ecc.c b/post/cpu/ppc4xx/denali_ecc.c
index 1190739..ad5e64f 100644
--- a/post/cpu/ppc4xx/denali_ecc.c
+++ b/post/cpu/ppc4xx/denali_ecc.c
@@ -33,6 +33,7 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#if defined(DEBUG)
 const static uint8_t syndrome_codes[] = {
 	0xF4, 0XF1, 0XEC, 0XEA, 0XE9, 0XE6, 0XE5, 0XE3,
 	0XDC, 0XDA, 0XD9, 0XD6, 0XD5, 0XD3, 0XCE, 0XCB,
@@ -44,6 +45,7 @@
 	0X1C, 0X1A, 0X19, 0X16, 0X15, 0X13, 0X0E, 0X0B,
 	0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01
 };
+#endif
 
 #define ECC_START_ADDR		0x10
 #define ECC_STOP_ADDR		0x2000
diff --git a/tools/rkcommon.c b/tools/rkcommon.c
index a583c0c..1056ffa 100644
--- a/tools/rkcommon.c
+++ b/tools/rkcommon.c
@@ -76,7 +76,7 @@
 	{ "rk3188", "RK31", 0x8000 - 0x800, true, false },
 	{ "rk3288", "RK32", 0x8000, false, false },
 	{ "rk3328", "RK32", 0x8000 - 0x1000, false, false },
-	{ "rk3399", "RK33", 0x20000, false, true },
+	{ "rk3399", "RK33", 0x30000 - 0x2000, false, true },
 	{ "rv1108", "RK11", 0x1800, false, false},
 };
 
@@ -226,11 +226,6 @@
 	return ((offset & ~0x7ff) << 1) + (offset & 0x7ff);
 }
 
-static inline unsigned rkcommon_spi_to_offset(unsigned offset)
-{
-	return ((offset & ~0x7ff) >> 1) + (offset & 0x7ff);
-}
-
 static int rkcommon_parse_header(const void *buf, struct header0_info *header0,
 				 struct spl_info **spl_info)
 {