diff -urN barebox-2014.03.0.orig/arch/arm/boards/Makefile barebox-2014.03.0.work/arch/arm/boards/Makefile
--- barebox-2014.03.0.orig/arch/arm/boards/Makefile	2014-03-07 07:42:24.000000000 +0100
+++ barebox-2014.03.0.work/arch/arm/boards/Makefile	2014-05-02 19:00:54.000000000 +0200
@@ -94,6 +94,7 @@
 obj-$(CONFIG_MACH_USB_A9260)			+= usb-a926x/
 obj-$(CONFIG_MACH_USB_A9263)			+= usb-a926x/
 obj-$(CONFIG_MACH_USB_A9G20)			+= usb-a926x/
+obj-$(CONFIG_MACH_VMX53)			+= vmx53/
 obj-$(CONFIG_MACH_VERSATILEPB)			+= versatile/
 obj-$(CONFIG_MACH_VEXPRESS)			+= vexpress/
 obj-$(CONFIG_MACH_ZEDBOARD)			+= avnet-zedboard/
diff -urN barebox-2014.03.0.orig/arch/arm/boards/vmx53/board.c barebox-2014.03.0.work/arch/arm/boards/vmx53/board.c
--- barebox-2014.03.0.orig/arch/arm/boards/vmx53/board.c	1970-01-01 01:00:00.000000000 +0100
+++ barebox-2014.03.0.work/arch/arm/boards/vmx53/board.c	2014-09-13 18:45:44.353953867 +0200
@@ -0,0 +1,237 @@
+/*
+ * Copyright (C) 2012 Sascha Hauer, Pengutronix
+ * (c) 2014 Voipac <support@voipac.com>
+ *
+ * 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.
+ *
+ */
+#include <common.h>
+#include <bootsource.h>
+#include <environment.h>
+#include <fcntl.h>
+#include <fec.h>
+#include <fs.h>
+#include <init.h>
+#include <nand.h>
+#include <net.h>
+#include <partition.h>
+#include <sizes.h>
+#include <gpio.h>
+
+#include <generated/mach-types.h>
+
+#include <mach/imx53-regs.h>
+#include <mach/iomux-mx53.h>
+#include <mach/devices-imx53.h>
+#include <mach/generic.h>
+#include <mach/imx-nand.h>
+#include <mach/iim.h>
+#include <mach/imx5.h>
+#include <mach/imx-flash-header.h>
+#include <mach/bbu.h>
+#include <mach/revision.h>
+
+#include <asm/armlinux.h>
+#include <io.h>
+#include <asm/mmu.h>
+
+#include "mach/imx-gpio.h"
+
+
+#define VMX53_RESET_OUT_GPIO	IMX_GPIO_NR(7, 12)
+#define VMX53_SD1_SEL_GPIO      IMX_GPIO_NR(4,  0)
+
+static iomux_v3_cfg_t vmx53_sys_pads[] = {
+	MX53_PAD_GPIO_17__GPIO7_12,	// RESET_OUT
+	MX53_PAD_GPIO_10__GPIO4_0,      // SD1_SEL
+};
+
+#define IMX_ESD_BASE    	0x63fd9000
+
+static int vmx53_mem_init(void)
+{
+	uchar   rows, cols, dsiz, banks;
+	uint32_t size, esdctl, esdmsc;
+
+	esdctl = readl(IMX_ESD_BASE);
+	esdmsc = readl(IMX_ESD_BASE+0x18);
+
+	rows = ((esdctl >> 24) & 7);
+	cols = (((esdctl >> 20)+1) & 3);
+	dsiz = ((esdctl >> 16) & 1);     // 0=16bit,  1=32bit
+	banks = (~(esdmsc >> 5) & 1);    // 0=4banks, 1=8banks
+	size = (esdctl)? 1 << (rows + cols + banks + dsiz + 22) : 0;
+
+	if(size)
+	{
+		if( esdctl & 0x80000000) {
+			arm_add_mem_device("ram0", MX53_CSD0_BASE_ADDR, size);
+
+			printk("SDRAM at 0x%08x: %dMB (DDR3 2x%dMb, %d ROWs, %d COLs, %d BANKs)\n",
+			 MX53_CSD0_BASE_ADDR, size >> 20, size >> 18,  rows + 11, cols + 8, 4 << banks);
+		}
+		if( esdctl & 0x40000000) {
+			arm_add_mem_device("ram1", MX53_CSD1_BASE_ADDR, size);
+
+			printk("SDRAM at 0x%08x: %dMB (DDR3 2x%dMb, %d ROWs, %d COLs, %d BANKs)\n",
+			 MX53_CSD1_BASE_ADDR, size >> 20, size >> 18,  rows + 11, cols + 8, 4 << banks);
+		}
+	}
+
+	return 0;
+}
+mem_initcall(vmx53_mem_init);
+
+#ifdef CONFIG_DRIVER_NET_FEC_IMX
+#define VMX53_FEC_CLK_GPIO		IMX_GPIO_NR(4, 1)
+#define VMX53_FEC_RST_GPIO		IMX_GPIO_NR(4, 2)
+
+static struct vmx53_fec_gpio_setup {
+        iomux_v3_cfg_t pad;
+        unsigned gpio:9,
+                dir:1,
+                level:1;
+} vmx53_fec_gpios[] = {
+        { MX53_PAD_GPIO_12__GPIO4_2,      VMX53_FEC_RST_GPIO, 1, 0, }, /* PHY reset */
+        { MX53_PAD_GPIO_11__GPIO4_1,      VMX53_FEC_CLK_GPIO, 1, 1, }, /* PHY CLK enable */
+        { MX53_PAD_FEC_REF_CLK__GPIO1_23, IMX_GPIO_NR(1, 23), 0, 0, }, /* ENET_CLK */
+        { MX53_PAD_FEC_MDC__GPIO1_31,     IMX_GPIO_NR(1, 31), 1, 0, }, /* MDC */
+        { MX53_PAD_FEC_MDIO__GPIO1_22,    IMX_GPIO_NR(1, 22), 1, 0, }, /* MDIO */
+        { MX53_PAD_FEC_RXD0__GPIO1_27,    IMX_GPIO_NR(1, 27), 1, 1, }, /* Mode0/RXD0 */
+        { MX53_PAD_FEC_RXD1__GPIO1_26,    IMX_GPIO_NR(1, 26), 1, 1, }, /* Mode1/RXD1 */
+        { MX53_PAD_FEC_RX_ER__GPIO1_24,   IMX_GPIO_NR(1, 24), 0, 0, }, /* RX_ER */
+        { MX53_PAD_FEC_TX_EN__GPIO1_28,   IMX_GPIO_NR(1, 28), 1, 0, }, /* TX_EN */
+        { MX53_PAD_FEC_TXD0__GPIO1_30,    IMX_GPIO_NR(1, 30), 1, 0, }, /* TXD0 */
+        { MX53_PAD_FEC_TXD1__GPIO1_29,    IMX_GPIO_NR(1, 29), 1, 0, }, /* TXD1 */
+        { MX53_PAD_FEC_CRS_DV__GPIO1_25,  IMX_GPIO_NR(1, 25), 1, 1, }, /* Mode2/CRS_DV */
+};
+
+static iomux_v3_cfg_t vmx53_fec_pads[] = {
+        MX53_PAD_FEC_REF_CLK__FEC_TX_CLK,
+        MX53_PAD_FEC_MDC__FEC_MDC,
+        MX53_PAD_FEC_MDIO__FEC_MDIO,
+        MX53_PAD_FEC_RXD0__FEC_RDATA_0,
+        MX53_PAD_FEC_RXD1__FEC_RDATA_1,
+        MX53_PAD_FEC_RX_ER__FEC_RX_ER,
+        MX53_PAD_FEC_TX_EN__FEC_TX_EN,
+        MX53_PAD_FEC_TXD0__FEC_TDATA_0,
+        MX53_PAD_FEC_TXD1__FEC_TDATA_1,
+        MX53_PAD_FEC_CRS_DV__FEC_RX_DV,
+};
+
+static inline void vmx53_fec_activate(void)
+{
+	int i;
+
+	/* Configure LAN8700 pads as GPIO and set up
+	 * necessary strap options for PHY
+	 */
+	for (i = 0; i < ARRAY_SIZE(vmx53_fec_gpios); i++) {
+		struct vmx53_fec_gpio_setup *gs = &vmx53_fec_gpios[i];
+
+		if (gs->dir) {
+			gpio_direction_output(gs->gpio, gs->level);
+		} else {
+			gpio_direction_input(gs->gpio);
+		}
+
+		mxc_iomux_v3_setup_pad(gs->pad);
+	}
+
+	/*
+	 *Turn on phy clk, leave in reset state
+	 */
+	gpio_set_value(VMX53_FEC_CLK_GPIO, 1);
+
+	/*
+	 * Wait some time to let the phy clock stabilise
+	 */
+	mdelay(1);
+
+	/*
+	 * Deassert reset, phy latches the rest of bootstrap pins
+	 */
+	gpio_set_value(VMX53_FEC_RST_GPIO, 1);
+
+	/* LAN7800 has an internal Power On Reset (POR) signal (OR'ed with
+	 * the external RESET signal) which is deactivated 21ms after
+	 * power on and latches the strap options.
+	 * Delay for 22ms to ensure, that the internal POR is inactive
+	 * before reconfiguring the strap pins.
+	 */
+	mdelay(22);
+
+	/*
+	 * The phy is ready, now configure imx53 pads for fec operation
+	 */
+	mxc_iomux_v3_setup_multiple_pads(vmx53_fec_pads,
+			ARRAY_SIZE(vmx53_fec_pads));
+}
+#else
+#define vmx53_fec_activate()	((void)0)
+#endif
+
+static inline u64 imx53_uid(void)
+{
+        int ret;
+        u64 uid;
+
+        ret = imx_iim_read(0, 7, &uid, sizeof(uid));
+        if (ret != sizeof(uid)) {
+		uid = 0;
+	}
+
+        return uid;
+}
+
+static int vmx53_module_init(void)
+{
+	if (!of_machine_is_compatible("voipac,imx53-vmx53")) {
+		return 0;
+	}
+
+	barebox_set_hostname("vmx53");
+	armlinux_set_architecture(MACH_TYPE_VMX53);
+	armlinux_set_serial(imx53_uid() & 0x7fffffffffffffffull);
+	armlinux_set_revision(0x53000 | imx_silicon_revision());
+
+	return 0;
+}
+fs_initcall(vmx53_module_init);
+
+static int vmx53_console_init(void)
+{
+	if (!of_machine_is_compatible("voipac,imx53-vmx53")) {
+		return 0;
+	}
+
+	mxc_iomux_v3_setup_multiple_pads(vmx53_sys_pads, 
+		ARRAY_SIZE(vmx53_sys_pads));
+
+	/* assert RESET_OUT_B */
+	gpio_direction_output(VMX53_RESET_OUT_GPIO, 0);
+
+	mdelay(10);
+
+	imx53_init_lowlevel(800);
+//	imx53_init_lowlevel(1200);
+
+	vmx53_fec_activate();
+
+	/* SDHC 0 = module, 1 = baseboard */
+	gpio_direction_output(VMX53_SD1_SEL_GPIO, 1);
+
+	/* deassert RESET_OUT_B */
+	gpio_set_value(VMX53_RESET_OUT_GPIO, 1);
+
+	return 0;
+}
+console_initcall(vmx53_console_init);
diff -urN barebox-2014.03.0.orig/arch/arm/boards/vmx53/env/bin/update barebox-2014.03.0.work/arch/arm/boards/vmx53/env/bin/update
--- barebox-2014.03.0.orig/arch/arm/boards/vmx53/env/bin/update	1970-01-01 01:00:00.000000000 +0100
+++ barebox-2014.03.0.work/arch/arm/boards/vmx53/env/bin/update	2014-07-28 15:46:54.092477462 +0200
@@ -0,0 +1,67 @@
+#!/bin/sh
+
+updatedir=vmx53
+barebox=$updatedir/barebox.img
+zimage=$updatedir/zImage
+rootfs=$updatedir/rootfs.bin
+
+. /env/config
+
+if [ x$1 = xbarebox ]; then
+	image=$barebox
+	part=/dev/nand0.barebox.bb
+fi
+
+if [ x$1 = xkernel ]; then
+	image=$zimage
+	part=/dev/nand0.kernel.bb
+fi
+
+if [ x$1 = xrootfs ]; then
+	image=$rootfs
+	part=/dev/nand0.rootfs
+fi
+
+if [ -z "$part" -o -z "$image" ]; then
+	echo "update barebox|kernel|rootfs [<imagename>]"
+	exit 1
+fi
+
+if [ ! -e "$part" ]; then
+	echo "Partition $part does not exist"
+	exit 1
+fi
+
+if [ $# = 2 ]; then
+	image=$2
+fi
+
+if [ -f /env/network/eth0 ]; then
+	ifup eth0
+fi
+
+ping $eth0.serverip
+if [ $? -ne 0 ] ; then
+	echo "Update aborted"
+	exit 1
+fi
+
+unprotect $part
+
+echo
+echo "Erasing partition $part"
+erase $part
+
+if [ x$1 = xrootfs ]; then
+	echo
+	echo "Attaching UBI to $part"
+	ubiattach $part
+	ubimkvol /dev/ubi0 rootfs 0
+
+	part=/dev/ubi0.rootfs
+fi
+
+echo
+echo "Flashing $image to $part"
+echo
+tftp $image $part
diff -urN barebox-2014.03.0.orig/arch/arm/boards/vmx53/env/boot/nand-dtb-ubi barebox-2014.03.0.work/arch/arm/boards/vmx53/env/boot/nand-dtb-ubi
--- barebox-2014.03.0.orig/arch/arm/boards/vmx53/env/boot/nand-dtb-ubi	1970-01-01 01:00:00.000000000 +0100
+++ barebox-2014.03.0.work/arch/arm/boards/vmx53/env/boot/nand-dtb-ubi	2014-07-28 15:59:19.429352259 +0200
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+if [ "$1" = menu ]; then
+	boot-menu-add-entry "$0" "nand dtb (UBI)"
+	exit
+fi
+
+global.bootm.image="/dev/nand0.kernel.bb"
+global.linux.bootargs.dyn.root="root=ubi0:rootfs ubi.mtd=nand0.rootfs rootfstype=ubifs"
diff -urN barebox-2014.03.0.orig/arch/arm/boards/vmx53/env/boot/nand-legacy-ubi barebox-2014.03.0.work/arch/arm/boards/vmx53/env/boot/nand-legacy-ubi
--- barebox-2014.03.0.orig/arch/arm/boards/vmx53/env/boot/nand-legacy-ubi	1970-01-01 01:00:00.000000000 +0100
+++ barebox-2014.03.0.work/arch/arm/boards/vmx53/env/boot/nand-legacy-ubi	2014-04-24 08:17:08.252149000 +0200
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+if [ "$1" = menu ]; then
+	boot-menu-add-entry "$0" "nand legacy (UBI)"
+	exit
+fi
+
+oftree -f
+global.bootm.image="/dev/nand0.kernel.bb"
+global.linux.bootargs.dyn.root="root=ubi0:rootfs ubi.mtd=nand0.rootfs rootfstype=ubifs"
diff -urN barebox-2014.03.0.orig/arch/arm/boards/vmx53/env/boot/net-dtb barebox-2014.03.0.work/arch/arm/boards/vmx53/env/boot/net-dtb
--- barebox-2014.03.0.orig/arch/arm/boards/vmx53/env/boot/net-dtb	1970-01-01 01:00:00.000000000 +0100
+++ barebox-2014.03.0.work/arch/arm/boards/vmx53/env/boot/net-dtb	2014-07-28 16:16:49.788161228 +0200
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+if [ "$1" = menu ]; then
+        boot-menu-add-entry "$0" "network dtb (tftp, nfs)"
+        exit
+fi
+
+. /env/config
+
+#Settings
+dtb=imx53-vmx53-${global.vmxmodel}.dtb
+kernel=zImage-3.12.13_vmx53_dev
+
+dhcp
+eth0.serverip=192.168.0.1
+
+tftp vmx53/${kernel}
+tftp vmx53/${dtb}
+
+global.bootm.image=${kernel}
+if [ -e "${dtb}" ]; then
+	oftree -f
+        oftree -l "${dtb}"
+fi
+
+nfsroot="${eth0.serverip}:/srv/nfs/rootfs-bb-1-22-vmx53,nolock"
+
+bootargs-ip
+global.linux.bootargs.dyn.root="root=/dev/nfs nfsroot=$nfsroot,v3,tcp"
diff -urN barebox-2014.03.0.orig/arch/arm/boards/vmx53/env/boot/net-legacy barebox-2014.03.0.work/arch/arm/boards/vmx53/env/boot/net-legacy
--- barebox-2014.03.0.orig/arch/arm/boards/vmx53/env/boot/net-legacy	1970-01-01 01:00:00.000000000 +0100
+++ barebox-2014.03.0.work/arch/arm/boards/vmx53/env/boot/net-legacy	2014-07-12 20:15:47.987051851 +0200
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+if [ "$1" = menu ]; then
+        boot-menu-add-entry "$0" "network legacy (tftp, nfs)"
+        exit
+fi
+
+#Settings
+kernel=zImage-3.12.13_vmx53_dev
+
+dhcp
+eth0.serverip=192.168.0.1
+
+tftp vmx53/${kernel}
+global.bootm.image=${kernel}
+
+oftree -f
+nfsroot="${eth0.serverip}:/srv/nfs/rootfs-bb-1-22-vmx53,nolock"
+
+bootargs-ip
+global.linux.bootargs.dyn.root="root=/dev/nfs nfsroot=$nfsroot,v3,tcp"
diff -urN barebox-2014.03.0.orig/arch/arm/boards/vmx53/env/config-board barebox-2014.03.0.work/arch/arm/boards/vmx53/env/config-board
--- barebox-2014.03.0.orig/arch/arm/boards/vmx53/env/config-board	1970-01-01 01:00:00.000000000 +0100
+++ barebox-2014.03.0.work/arch/arm/boards/vmx53/env/config-board	2014-07-28 12:49:15.051792000 +0200
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+# board defaults, do not change in running system. Change /env/config
+# instead
+
+global vmxmodel
+global vmxkernel
+
+global.vmxmodel=557
+global.vmxkernel=3.12
+global.hostname=vmx53
+global.linux.bootargs.base="console=ttymxc0,115200"
+global.boot.default=nand-dtb-ubi
diff -urN barebox-2014.03.0.orig/arch/arm/boards/vmx53/env/dtb/3.12/dtb.txt barebox-2014.03.0.work/arch/arm/boards/vmx53/env/dtb/3.12/dtb.txt
--- barebox-2014.03.0.orig/arch/arm/boards/vmx53/env/dtb/3.12/dtb.txt	1970-01-01 01:00:00.000000000 +0100
+++ barebox-2014.03.0.work/arch/arm/boards/vmx53/env/dtb/3.12/dtb.txt	2014-09-06 16:27:30.031370048 +0200
@@ -0,0 +1,20 @@
+# Device Tree Blob (.dtb) files can be placed into this directory
+#
+# The file name and path is affected by two global env variables. 
+# global.vmxmodel
+# global.vmxkernel
+
+# Example:
+# 1. Configuration
+barebox@Voipac VMX53:/ cat /env/config
+#!/bin/sh
+...
+
+global.vmxmodel=557
+global.vmxkernel=3.12
+
+...
+
+# 2. DTB File name and location
+/env/dtb/3.12/imx53-vmx53-557.dtb
+
Binary files barebox-2014.03.0.orig/arch/arm/boards/vmx53/env/dtb/3.12/imx53-vmx53-557.dtb and barebox-2014.03.0.work/arch/arm/boards/vmx53/env/dtb/3.12/imx53-vmx53-557.dtb differ
Binary files barebox-2014.03.0.orig/arch/arm/boards/vmx53/env/dtb/3.12/imx53-vmx53-668.dtb and barebox-2014.03.0.work/arch/arm/boards/vmx53/env/dtb/3.12/imx53-vmx53-668.dtb differ
Binary files barebox-2014.03.0.orig/arch/arm/boards/vmx53/env/dtb/3.12/imx53-vmx53-779.dtb and barebox-2014.03.0.work/arch/arm/boards/vmx53/env/dtb/3.12/imx53-vmx53-779.dtb differ
diff -urN barebox-2014.03.0.orig/arch/arm/boards/vmx53/env/init/dtb barebox-2014.03.0.work/arch/arm/boards/vmx53/env/init/dtb
--- barebox-2014.03.0.orig/arch/arm/boards/vmx53/env/init/dtb	1970-01-01 01:00:00.000000000 +0100
+++ barebox-2014.03.0.work/arch/arm/boards/vmx53/env/init/dtb	2014-07-28 16:00:17.993731284 +0200
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+# Load correct dtb file
+
+if [ -e /env/config ]; then
+	/env/config
+fi
+
+#Settings
+dtb=imx53-vmx53-${global.vmxmodel}.dtb
+
+if [ -e /env/dtb/${global.vmxkernel}/${dtb} ]; then
+	oftree -f
+        oftree -l /env/dtb/${global.vmxkernel}/${dtb}
+	echo "DTB: ${dtb}"
+fi
diff -urN barebox-2014.03.0.orig/arch/arm/boards/vmx53/env/init/eth0-mac barebox-2014.03.0.work/arch/arm/boards/vmx53/env/init/eth0-mac
--- barebox-2014.03.0.orig/arch/arm/boards/vmx53/env/init/eth0-mac	1970-01-01 01:00:00.000000000 +0100
+++ barebox-2014.03.0.work/arch/arm/boards/vmx53/env/init/eth0-mac	2014-07-14 21:18:31.562952005 +0200
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+#interface=eth0
+#
+#. /env/network/${interface}
+
+#if [ -z $ethaddr ]; then
+#	while [ -z $ethaddr ]; do
+#		readline "No MAC address set for eth0. Please enter the one found on your module: " ethaddr
+#	done
+#	echo -a /env/network/${interface} "ethaddr=$ethaddr"
+#	saveenv
+#fi
+
+#${interface}.ethaddr=$ethaddr
diff -urN barebox-2014.03.0.orig/arch/arm/boards/vmx53/env/init/mtdparts-nand barebox-2014.03.0.work/arch/arm/boards/vmx53/env/init/mtdparts-nand
--- barebox-2014.03.0.orig/arch/arm/boards/vmx53/env/init/mtdparts-nand	1970-01-01 01:00:00.000000000 +0100
+++ barebox-2014.03.0.work/arch/arm/boards/vmx53/env/init/mtdparts-nand	2014-09-07 16:19:49.822337841 +0200
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+if [ "$1" = menu ]; then
+	init-menu-add-entry "$0" "NAND partitions"
+	exit
+fi
+
+mtdnames="barebox environment kernel rootfs"
+mtdparts="1M(nand0.barebox),1M(nand0.environment),4M(nand0.kernel),-(nand0.rootfs)"
+
+for partition in ${mtdnames}
+do
+	if [ -e /dev/nand0.${partition}.bb ]; then
+		nand -d /dev/nand0.${partition}.bb
+	fi
+
+	if [ -e /dev/nand0.${partition} ]; then
+		delpart /dev/nand0.${partition}
+	fi
+done
+
+addpart -n /dev/nand0 "${mtdparts}"
+
+for partition in ${mtdnames}
+do
+	if [ ! -e /dev/nand0.${partition}.bb ]; then
+		nand -a /dev/nand0.${partition}
+	fi
+done
+
+global linux.mtdparts.nand0
+global.linux.mtdparts.nand0="mxc_nand:${mtdparts}"
+
diff -urN barebox-2014.03.0.orig/arch/arm/boards/vmx53/flash_header.c barebox-2014.03.0.work/arch/arm/boards/vmx53/flash_header.c
--- barebox-2014.03.0.orig/arch/arm/boards/vmx53/flash_header.c	1970-01-01 01:00:00.000000000 +0100
+++ barebox-2014.03.0.work/arch/arm/boards/vmx53/flash_header.c	2014-09-13 10:29:47.718281859 +0200
@@ -0,0 +1,107 @@
+/*
+ * Copyright (C) 2011 Marc Kleine-Budde <mkl@pengutronix.de>
+ * (c) 2014 Voipac <support@voipac.com>
+ *
+ * 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.
+ *
+ */
+#include <common.h>
+#include <asm/byteorder.h>
+#include <mach/imx-flash-header.h>
+#include <asm/barebox-arm-head.h>
+
+#define KiB(a)	((a) * 1024)
+
+void __naked __flash_header_start go(void)
+{
+	barebox_arm_imx_fcb_head();
+}
+
+struct imx_dcd_v2_entry __dcd_entry_section dcd_entry[] = {
+	{ .addr = cpu_to_be32(0x53fa8554), .val = cpu_to_be32(0x00300000), },
+	{ .addr = cpu_to_be32(0x53fa8558), .val = cpu_to_be32(0x00300040), },
+	{ .addr = cpu_to_be32(0x53fa8560), .val = cpu_to_be32(0x00300000), },
+	{ .addr = cpu_to_be32(0x53fa8564), .val = cpu_to_be32(0x00300040), },
+	{ .addr = cpu_to_be32(0x53fa8568), .val = cpu_to_be32(0x00300040), },
+	{ .addr = cpu_to_be32(0x53fa8570), .val = cpu_to_be32(0x00300000), },
+	{ .addr = cpu_to_be32(0x53fa8574), .val = cpu_to_be32(0x00300000), },
+	{ .addr = cpu_to_be32(0x53fa8578), .val = cpu_to_be32(0x00300000), },
+	{ .addr = cpu_to_be32(0x53fa857c), .val = cpu_to_be32(0x00300040), },
+	{ .addr = cpu_to_be32(0x53fa8580), .val = cpu_to_be32(0x00300040), },
+	{ .addr = cpu_to_be32(0x53fa8584), .val = cpu_to_be32(0x00300000), },
+	{ .addr = cpu_to_be32(0x53fa8588), .val = cpu_to_be32(0x00300000), },
+	{ .addr = cpu_to_be32(0x53fa8590), .val = cpu_to_be32(0x00300040), },
+	{ .addr = cpu_to_be32(0x53fa8594), .val = cpu_to_be32(0x00300000), },
+	{ .addr = cpu_to_be32(0x53fa86f0), .val = cpu_to_be32(0x00300000), },
+	{ .addr = cpu_to_be32(0x53fa86f4), .val = cpu_to_be32(0x00000000), },
+	{ .addr = cpu_to_be32(0x53fa86fc), .val = cpu_to_be32(0x00000000), },
+	{ .addr = cpu_to_be32(0x53fa8714), .val = cpu_to_be32(0x00000000), },
+	{ .addr = cpu_to_be32(0x53fa8718), .val = cpu_to_be32(0x00300000), },
+	{ .addr = cpu_to_be32(0x53fa871c), .val = cpu_to_be32(0x00300000), },
+	{ .addr = cpu_to_be32(0x53fa8720), .val = cpu_to_be32(0x00300000), },
+	{ .addr = cpu_to_be32(0x53fa8724), .val = cpu_to_be32(0x04000000), },
+	{ .addr = cpu_to_be32(0x53fa8728), .val = cpu_to_be32(0x00300000), },
+	{ .addr = cpu_to_be32(0x53fa872c), .val = cpu_to_be32(0x00300000), },
+	{ .addr = cpu_to_be32(0x63fd9088), .val = cpu_to_be32(0x35343535), },
+	{ .addr = cpu_to_be32(0x63fd9090), .val = cpu_to_be32(0x4d444c44), },
+	{ .addr = cpu_to_be32(0x63fd907c), .val = cpu_to_be32(0x01370138), },
+	{ .addr = cpu_to_be32(0x63fd9080), .val = cpu_to_be32(0x013b013c), },
+	{ .addr = cpu_to_be32(0x63fd9018), .val = cpu_to_be32(0x00011740), },
+//	{ .addr = cpu_to_be32(0x63fd9000), .val = cpu_to_be32(0xc2190000), },
+//	{ .addr = cpu_to_be32(0x63fd9000), .val = cpu_to_be32(0xc3190000), },
+	{ .addr = cpu_to_be32(0x63fd9000), .val = cpu_to_be32(0xc4190000), },
+	{ .addr = cpu_to_be32(0x63fd900c), .val = cpu_to_be32(0x9f5152e3), },
+	{ .addr = cpu_to_be32(0x63fd9010), .val = cpu_to_be32(0xb68e8a63), },
+	{ .addr = cpu_to_be32(0x63fd9014), .val = cpu_to_be32(0x01ff00db), },
+	{ .addr = cpu_to_be32(0x63fd902c), .val = cpu_to_be32(0x000026d2), },
+	{ .addr = cpu_to_be32(0x63fd9030), .val = cpu_to_be32(0x009f0e21), },
+	{ .addr = cpu_to_be32(0x63fd9008), .val = cpu_to_be32(0x12273030), },
+	{ .addr = cpu_to_be32(0x63fd9004), .val = cpu_to_be32(0x0002002d), },
+	{ .addr = cpu_to_be32(0x63fd901c), .val = cpu_to_be32(0x00008032), },
+	{ .addr = cpu_to_be32(0x63fd901c), .val = cpu_to_be32(0x00008033), },
+	{ .addr = cpu_to_be32(0x63fd901c), .val = cpu_to_be32(0x00028031), },
+	{ .addr = cpu_to_be32(0x63fd901c), .val = cpu_to_be32(0x052080b0), },
+	{ .addr = cpu_to_be32(0x63fd901c), .val = cpu_to_be32(0x04008040), },
+	{ .addr = cpu_to_be32(0x63fd901c), .val = cpu_to_be32(0x0000803a), },
+	{ .addr = cpu_to_be32(0x63fd901c), .val = cpu_to_be32(0x0000803b), },
+	{ .addr = cpu_to_be32(0x63fd901c), .val = cpu_to_be32(0x00028039), },
+	{ .addr = cpu_to_be32(0x63fd901c), .val = cpu_to_be32(0x05208138), },
+	{ .addr = cpu_to_be32(0x63fd901c), .val = cpu_to_be32(0x04008048), },
+	{ .addr = cpu_to_be32(0x63fd9020), .val = cpu_to_be32(0x00005800), },
+	{ .addr = cpu_to_be32(0x63fd9040), .val = cpu_to_be32(0x04b80003), },
+	{ .addr = cpu_to_be32(0x63fd9058), .val = cpu_to_be32(0x00022227), },
+	{ .addr = cpu_to_be32(0x63fd901c), .val = cpu_to_be32(0x00000000), },
+};
+
+#define APP_DEST	0x70000000
+
+struct imx_flash_header_v2 __flash_header_section flash_header = {
+	.header.tag		= IVT_HEADER_TAG,
+	.header.length		= cpu_to_be16(32),
+	.header.version		= IVT_VERSION,
+
+	.entry			= APP_DEST + 0x2000,
+	.dcd_ptr		= APP_DEST + 0x400 + offsetof(struct imx_flash_header_v2, dcd),
+	.boot_data_ptr		= APP_DEST + 0x400 + offsetof(struct imx_flash_header_v2, boot_data),
+	.self			= APP_DEST + 0x400,
+
+	.boot_data.start	= APP_DEST,
+	.boot_data.size		= KiB(512),
+
+	.dcd.header.tag		= DCD_HEADER_TAG,
+	.dcd.header.length	= cpu_to_be16(sizeof(struct imx_dcd) + sizeof(dcd_entry)),
+	.dcd.header.version	= DCD_VERSION,
+
+	.dcd.command.tag	= DCD_COMMAND_WRITE_TAG,
+	.dcd.command.length	= cpu_to_be16(sizeof(struct imx_dcd_command) + sizeof(dcd_entry)),
+	.dcd.command.param	= DCD_COMMAND_WRITE_PARAM,
+};
+
diff -urN barebox-2014.03.0.orig/arch/arm/boards/vmx53/flash-header-imx53-vmx53.imxcfg barebox-2014.03.0.work/arch/arm/boards/vmx53/flash-header-imx53-vmx53.imxcfg
--- barebox-2014.03.0.orig/arch/arm/boards/vmx53/flash-header-imx53-vmx53.imxcfg	1970-01-01 01:00:00.000000000 +0100
+++ barebox-2014.03.0.work/arch/arm/boards/vmx53/flash-header-imx53-vmx53.imxcfg	2014-07-06 19:17:03.135108882 +0200
@@ -0,0 +1,54 @@
+loadaddr 0x70000000
+soc imx53
+dcdofs 0x400
+wm 32 0x53fa8554 0x00300000
+wm 32 0x53fa8558 0x00300040
+wm 32 0x53fa8560 0x00300000
+wm 32 0x53fa8564 0x00300040
+wm 32 0x53fa8568 0x00300040
+wm 32 0x53fa8570 0x00300000
+wm 32 0x53fa8574 0x00300000
+wm 32 0x53fa8578 0x00300000
+wm 32 0x53fa857c 0x00300040
+wm 32 0x53fa8580 0x00300040
+wm 32 0x53fa8584 0x00300000
+wm 32 0x53fa8588 0x00300000
+wm 32 0x53fa8590 0x00300040
+wm 32 0x53fa8594 0x00300000
+wm 32 0x53fa86f0 0x00300000
+wm 32 0x53fa86f4 0x00000000
+wm 32 0x53fa86fc 0x00000000
+wm 32 0x53fa8714 0x00000000
+wm 32 0x53fa8718 0x00300000
+wm 32 0x53fa871c 0x00300000
+wm 32 0x53fa8720 0x00300000
+wm 32 0x53fa8724 0x04000000
+wm 32 0x53fa8728 0x00300000
+wm 32 0x53fa872c 0x00300000
+wm 32 0x63fd9088 0x35343535
+wm 32 0x63fd9090 0x4d444c44
+wm 32 0x63fd907c 0x01370138
+wm 32 0x63fd9080 0x013b013c
+wm 32 0x63fd9018 0x00011740
+wm 32 0x63fd9000 0xc4190000
+wm 32 0x63fd900c 0x9f5152e3
+wm 32 0x63fd9010 0xb68e8a63
+wm 32 0x63fd9014 0x01ff00db
+wm 32 0x63fd902c 0x000026d2
+wm 32 0x63fd9030 0x009f0e21
+wm 32 0x63fd9008 0x12273030
+wm 32 0x63fd9004 0x0002002d
+wm 32 0x63fd901c 0x00008032
+wm 32 0x63fd901c 0x00008033
+wm 32 0x63fd901c 0x00028031
+wm 32 0x63fd901c 0x052080b0
+wm 32 0x63fd901c 0x04008040
+wm 32 0x63fd901c 0x0000803a
+wm 32 0x63fd901c 0x0000803b
+wm 32 0x63fd901c 0x00028039
+wm 32 0x63fd901c 0x05208138
+wm 32 0x63fd901c 0x04008048
+wm 32 0x63fd9020 0x00005800
+wm 32 0x63fd9040 0x04b80003
+wm 32 0x63fd9058 0x00022227
+wm 32 0x63fd901c 0x00000000
diff -urN barebox-2014.03.0.orig/arch/arm/boards/vmx53/lowlevel.c barebox-2014.03.0.work/arch/arm/boards/vmx53/lowlevel.c
--- barebox-2014.03.0.orig/arch/arm/boards/vmx53/lowlevel.c	1970-01-01 01:00:00.000000000 +0100
+++ barebox-2014.03.0.work/arch/arm/boards/vmx53/lowlevel.c	2014-08-17 14:30:28.227403622 +0200
@@ -0,0 +1,32 @@
+/*
+ * (c) 2014 Voipac <support@voipac.com>
+ *
+ * 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.
+ *
+ */
+
+#include <common.h>
+#include <mach/esdctl.h>
+#include <asm/barebox-arm-head.h>
+#include <asm/barebox-arm.h>
+
+extern char __dtb_imx53_vmx53_start[];
+
+void __naked barebox_arm_reset_vector(void)
+{
+	uint32_t fdt;
+
+	arm_cpu_lowlevel_init();
+
+	fdt = (uint32_t)__dtb_imx53_vmx53_start - get_runtime_offset();
+
+	imx53_barebox_entry(fdt);
+}
diff -urN barebox-2014.03.0.orig/arch/arm/boards/vmx53/Makefile barebox-2014.03.0.work/arch/arm/boards/vmx53/Makefile
--- barebox-2014.03.0.orig/arch/arm/boards/vmx53/Makefile	1970-01-01 01:00:00.000000000 +0100
+++ barebox-2014.03.0.work/arch/arm/boards/vmx53/Makefile	2014-07-08 19:26:34.683202633 +0200
@@ -0,0 +1,3 @@
+obj-y += board.o
+lwl-y += flash_header.o
+lwl-y += lowlevel.o
diff -urN barebox-2014.03.0.orig/arch/arm/dts/imx53-vmx53.dts barebox-2014.03.0.work/arch/arm/dts/imx53-vmx53.dts
--- barebox-2014.03.0.orig/arch/arm/dts/imx53-vmx53.dts	1970-01-01 01:00:00.000000000 +0100
+++ barebox-2014.03.0.work/arch/arm/dts/imx53-vmx53.dts	2014-09-09 20:07:55.850424375 +0200
@@ -0,0 +1,147 @@
+/*
+ * Copyright 2011 Freescale Semiconductor, Inc.
+ * Copyright 2011 Linaro Ltd.
+ * Copyright 2014 Voipac <support@voipac.com>
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+/dts-v1/;
+#include "imx53.dtsi"
+
+/ {
+	model = "Voipac VMX53";
+	compatible = "voipac,imx53-vmx53", "fsl,imx53";
+
+	chosen {
+		linux,stdout-path = &uart1;
+
+		environment@0 {
+			compatible = "barebox,environment";
+			device-path = &nfc, "partname:environment";
+		};
+	};
+
+	leds {
+		compatible = "gpio-leds";
+		pinctrl-names = "default";
+		pinctrl-0 = <&pinctrl_led>;
+
+		red {
+			label = "led-red";
+			gpios = <&gpio3 29 0>;
+			linux,default-trigger = "heartbeat";
+		};
+
+		orange {
+			label = "led-orange";
+			gpios = <&gpio2 31 0>;
+			linux,default-trigger = "panic";
+		};
+	};
+};
+
+&iomuxc {
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_hog>;
+
+	imx53-vmx53 {
+		pinctrl_hog: hoggrp {
+			fsl,pins = <
+				MX53_PAD_GPIO_17__GPIO7_12	0x80000000 // RESET_OUT
+				MX53_PAD_GPIO_10__GPIO4_0	0x80000000 // SD1_SEL
+				MX53_PAD_EIM_D24__GPIO3_24	0x80000000 // SD1_CD
+				MX53_PAD_EIM_D25__GPIO3_25	0x80000000 // SD2_CD
+				MX53_PAD_EIM_A19__GPIO2_19	0x80000000 // SD2_WP
+			>;
+		};
+	};
+
+	pinctrl_led: ledgrp {
+		fsl,pins = <
+			MX53_PAD_EIM_D29__GPIO3_29		0xC0
+			MX53_PAD_EIM_EB3__GPIO2_31		0xC0
+		>;
+	};
+};
+
+&uart1 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_uart1_2>;
+	status = "okay";
+};
+
+&iim {
+	barebox,provide-mac-address = <&fec 1 9>;
+};
+
+&fec {
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_fec_1>;
+	phy-mode = "rmii";
+	status = "okay";
+};
+
+&nfc {
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_nand_1>;
+	#address-cells = <1>;
+	#size-cells = <1>;
+	nand-on-flash-bbt;
+	nand-ecc-mode = "hw";
+	nand-bus-width = <8>;
+	status = "okay";
+
+	partition@0 {
+		label = "barebox";
+		reg = <0x0 0x100000>;
+	};
+
+	partition@1 {
+		label = "environment";
+		reg = <0x100000 0x100000>;
+	};
+
+	partition@2 {
+		label = "kernel";
+		reg = <0x200000 0x400000>;
+	};
+
+	partition@3 {
+		label = "rootfs";
+		reg = <0x600000 0x07B00000>;
+	};
+};
+
+&esdhc1 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_esdhc1_1>;
+	cd-gpios = <&gpio3 24 1>;
+	fsl,wp-controller;
+	status = "okay";
+};
+
+&esdhc2 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_esdhc2_1>;
+	cd-gpios = <&gpio3 25 1>;
+	fsl,wp-controller;
+	status = "okay";
+};
+
+&i2c1 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_i2c1_2>;
+	status = "okay";
+};
+
+&i2c3 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_i2c3_2>;
+	status = "okay";
+};
diff -urN barebox-2014.03.0.orig/arch/arm/dts/Makefile barebox-2014.03.0.work/arch/arm/dts/Makefile
--- barebox-2014.03.0.orig/arch/arm/dts/Makefile	2014-03-07 07:42:24.000000000 +0100
+++ barebox-2014.03.0.work/arch/arm/dts/Makefile	2014-07-07 19:35:14.376481697 +0200
@@ -10,7 +10,8 @@
 dtb-$(CONFIG_ARCH_IMX53) += imx53-mba53.dtb \
 	imx53-qsb.dtb \
 	imx53-qsrb.dtb \
-	imx53-voipac-bsb.dtb
+	imx53-voipac-bsb.dtb \
+	imx53-vmx53.dtb
 dtb-$(CONFIG_ARCH_IMX6) += imx6q-gk802.dtb \
 	imx6dl-dfi-fs700-m60-6s.dtb \
 	imx6q-dfi-fs700-m60-6q.dtb \
@@ -50,6 +51,7 @@
 pbl-$(CONFIG_MACH_TQMA53) += imx53-mba53.dtb.o
 pbl-$(CONFIG_MACH_TQMA6X) += imx6dl-mba6x.dtb.o imx6q-mba6x.dtb.o
 pbl-$(CONFIG_MACH_TX25) += imx25-karo-tx25.dtb.o
+pbl-$(CONFIG_MACH_VMX53) += imx53-vmx53.dtb.o
 pbl-$(CONFIG_MACH_SOCFPGA_EBV_SOCRATES) += socfpga_cyclone5_socrates.dtb.o
 pbl-$(CONFIG_MACH_SOCFPGA_TERASIC_SOCKIT) += socfpga_cyclone5_sockit.dtb.o
 pbl-$(CONFIG_MACH_SOLIDRUN_HUMMINGBOARD) += imx6dl-hummingboard.dtb.o
diff -urN barebox-2014.03.0.orig/arch/arm/mach-imx/esdctl.c barebox-2014.03.0.work/arch/arm/mach-imx/esdctl.c
--- barebox-2014.03.0.orig/arch/arm/mach-imx/esdctl.c	2014-03-07 07:42:24.000000000 +0100
+++ barebox-2014.03.0.work/arch/arm/mach-imx/esdctl.c	2014-09-13 18:59:18.946779433 +0200
@@ -462,6 +462,27 @@
 	barebox_arm_entry(base, size, boarddata);
 }
 
+#define IMX_ESD_BASE    	0x63fd9000
+#define IMX_ESD_ESDCTL		(IMX_ESD_BASE)
+#define IMX_ESD_ESDCTL_ROW_MASK	(7ul<<24)
+#define IMX_ESD_ESDCTL_ROW15	(4ul<<24)
+#define IMX_ESD_ESDCTL_ROW14	(3ul<<24)
+#define IMX_ESD_ESDCTL_ROW13	(2ul<<24)
+
+static inline void imx53_autoset_ddr3_rows(unsigned long base)
+{
+	unsigned long esdctl;
+
+	writel(IMX_ESD_ESDCTL_ROW15, base);
+	writel(IMX_ESD_ESDCTL_ROW14, base + 0x20000000);
+	writel(IMX_ESD_ESDCTL_ROW13, base + 0x10000000);
+
+	esdctl = (readl(IMX_ESD_ESDCTL) & ~IMX_ESD_ESDCTL_ROW_MASK);
+	esdctl |= readl(base);
+
+	writel(esdctl, IMX_ESD_ESDCTL);
+}
+
 void __naked __noreturn imx53_barebox_entry(uint32_t boarddata)
 {
 	unsigned long base;
@@ -469,6 +490,8 @@
 
 	base = MX53_CSD0_BASE_ADDR;
 
+	imx53_autoset_ddr3_rows(base);
+
 	size = imx_v4_sdram_size((void *)MX53_ESDCTL_BASE_ADDR, 0);
 	if (size == SZ_1G)
 		size += imx_v4_sdram_size((void *)MX53_ESDCTL_BASE_ADDR, 1);
diff -urN barebox-2014.03.0.orig/arch/arm/mach-imx/iim.c barebox-2014.03.0.work/arch/arm/mach-imx/iim.c
--- barebox-2014.03.0.orig/arch/arm/mach-imx/iim.c	2014-03-07 07:42:24.000000000 +0100
+++ barebox-2014.03.0.work/arch/arm/mach-imx/iim.c	2014-09-11 18:33:53.247767287 +0200
@@ -31,7 +31,7 @@
 
 #define DRIVERNAME	"imx_iim"
 
-static int iim_write_enable;
+static int iim_write_enable = 1;
 static int iim_sense_enable;
 
 struct iim_priv {
diff -urN barebox-2014.03.0.orig/arch/arm/mach-imx/Kconfig barebox-2014.03.0.work/arch/arm/mach-imx/Kconfig
--- barebox-2014.03.0.orig/arch/arm/mach-imx/Kconfig	2014-03-07 07:42:24.000000000 +0100
+++ barebox-2014.03.0.work/arch/arm/mach-imx/Kconfig	2014-07-08 19:22:53.078832088 +0200
@@ -11,6 +11,7 @@
 	default 0x83f00000 if MACH_FREESCALE_MX25_3STACK && FREESCALE_MX25_3STACK_SDRAM_64MB_DDR2
 	default 0x87f00000 if MACH_FREESCALE_MX25_3STACK && FREESCALE_MX25_3STACK_SDRAM_128MB_MDDR
 	default 0x87f00000 if MACH_FREESCALE_MX35_3STACK
+	default 0x7ff00000 if MACH_VMX53
 	default 0xa7f00000 if MACH_PCA100
 	default 0xa0000000 if MACH_PCM038
 	default 0x87f00000 if MACH_PCM037
@@ -446,6 +447,16 @@
 	select ARCH_IMX53
 	select HAVE_DEFAULT_ENVIRONMENT_NEW
 
+config MACH_VMX53
+	bool "Voipac VMX53"
+	select ARCH_IMX53
+	select HAVE_DEFAULT_ENVIRONMENT_NEW
+	select ARCH_IMX_INTERNAL_BOOT
+	select ARCH_IMX_INTERNAL_BOOT_NAND
+	help
+	  Say Y here if you are using the Voipac Technologies VMX53 module
+	  equipped with a Freescale i.MX53 Processor
+
 comment "i.MX6 Boards"
 
 config MACH_MX6Q_ARM2
diff -urN barebox-2014.03.0.orig/commands/nandtest.c barebox-2014.03.0.work/commands/nandtest.c
--- barebox-2014.03.0.orig/commands/nandtest.c	2014-03-07 07:42:24.000000000 +0100
+++ barebox-2014.03.0.work/commands/nandtest.c	2014-06-16 19:08:16.000000000 +0200
@@ -277,7 +277,7 @@
 	}
 	if (length + flash_offset > meminfo.size) {
 		printf("Length 0x%08llx + offset 0x%08llx exceeds "
-				"device size 0x%08x\n", length,
+				"device size 0x%08llx\n", length,
 				flash_offset, meminfo.size);
 		goto err;
 	}
diff -urN barebox-2014.03.0.orig/commands/partition.c barebox-2014.03.0.work/commands/partition.c
--- barebox-2014.03.0.orig/commands/partition.c	2014-03-07 07:42:24.000000000 +0100
+++ barebox-2014.03.0.work/commands/partition.c	2014-06-16 19:11:42.000000000 +0200
@@ -42,10 +42,11 @@
 #define PART_ADD_DEVNAME (1 << 0)
 
 static int mtd_part_do_parse_one(char *devname, const char *partstr,
-				 char **endp, unsigned long *offset,
-				 off_t devsize, size_t *retsize, unsigned int pflags)
+				 char **endp, loff_t *offset,
+				 loff_t devsize, size_t *retsize,
+				 unsigned int pflags)
 {
-	ulong size;
+	loff_t size;
 	char *end;
 	char buf[PATH_MAX] = {};
 	unsigned long flags = 0;
@@ -58,11 +59,11 @@
 		size = SIZE_REMAINING;
 		end = (char *)partstr + 1;
 	} else {
-		size = strtoul_suffix(partstr, &end, 0);
+		size = strtoull_suffix(partstr, &end, 0);
 	}
 
 	if (*end == '@')
-		*offset = strtoul_suffix(end+1, &end, 0);
+		*offset = strtoull_suffix(end+1, &end, 0);
 
 	if (size == SIZE_REMAINING)
 		size = devsize - *offset;
@@ -114,8 +115,8 @@
 {
 	char *devname;
 	char *endp;
-	unsigned long offset = 0;
-	off_t devsize;
+	loff_t offset = 0;
+	loff_t devsize;
 	struct stat s;
 	int opt;
 	unsigned int flags = PART_ADD_DEVNAME;
diff -urN barebox-2014.03.0.orig/commands/ubi.c barebox-2014.03.0.work/commands/ubi.c
--- barebox-2014.03.0.orig/commands/ubi.c	2014-03-07 07:42:24.000000000 +0100
+++ barebox-2014.03.0.work/commands/ubi.c	2014-05-31 17:38:21.000000000 +0200
@@ -15,12 +15,12 @@
 {
 	struct ubi_mkvol_req req;
 	int fd, ret;
-	size_t size;
+	uint64_t size;
 
 	if (argc != 4)
 		return COMMAND_ERROR_USAGE;
 
-	size = strtoul_suffix(argv[3], NULL, 0);
+	size = strtoull_suffix(argv[3], NULL, 0);
 	req.name_len = min_t(int, strlen(argv[2]), UBI_VOL_NAME_MAX);
 	strncpy(req.name, argv[2], req.name_len);
 	req.name[req.name_len] = 0;
diff -urN barebox-2014.03.0.orig/drivers/mtd/core.c barebox-2014.03.0.work/drivers/mtd/core.c
--- barebox-2014.03.0.orig/drivers/mtd/core.c	2014-03-07 07:42:24.000000000 +0100
+++ barebox-2014.03.0.work/drivers/mtd/core.c	2014-05-31 17:48:22.000000000 +0200
@@ -397,7 +397,7 @@
 	mtd->cdev.mtd = mtd;
 
 	if (IS_ENABLED(CONFIG_PARAMETER)) {
-		dev_add_param_int_ro(&mtd->class_dev, "size", mtd->size, "%u");
+		dev_add_param_int_ro(&mtd->class_dev, "size", mtd->size, "%llu");
 		dev_add_param_int_ro(&mtd->class_dev, "erasesize", mtd->erasesize, "%u");
 		dev_add_param_int_ro(&mtd->class_dev, "writesize", mtd->oobsize, "%u");
 		dev_add_param_int_ro(&mtd->class_dev, "oobsize", mtd->oobsize, "%u");
diff -urN barebox-2014.03.0.orig/drivers/mtd/devices/m25p80.c barebox-2014.03.0.work/drivers/mtd/devices/m25p80.c
--- barebox-2014.03.0.orig/drivers/mtd/devices/m25p80.c	2014-03-07 07:42:24.000000000 +0100
+++ barebox-2014.03.0.work/drivers/mtd/devices/m25p80.c	2015-11-29 18:15:56.439232987 +0100
@@ -273,8 +273,9 @@
 static int m25p80_erase(struct mtd_info *mtd, struct erase_info *instr)
 {
 	struct m25p *flash = mtd_to_m25p(mtd);
-	u32 addr, len;
+	u32 addr;
 	uint32_t rem;
+	uint64_t len;
 
 	dev_dbg(&flash->spi->dev, "%s at 0x%llx, len %lld\n",
 			__func__, (long long)instr->addr,
@@ -696,6 +697,7 @@
 	{ "sst25wf010",  INFO(0xbf2502, 0, 64 * 1024,  2, SECT_4K) },
 	{ "sst25wf020",  INFO(0xbf2503, 0, 64 * 1024,  4, SECT_4K) },
 	{ "sst25wf040",  INFO(0xbf2504, 0, 64 * 1024,  8, SECT_4K) },
+	{ "sst26vf032b", INFO(0xbf2642, 0, 64 * 1024, 64, SECT_4K) },
 
 	/* ST Microelectronics -- newer production may have feature updates */
 	{ "m25p05",  INFO(0x202010,  0,  32 * 1024,   2, 0) },
@@ -896,7 +898,7 @@
 	flash->mtd.type = MTD_NORFLASH;
 	flash->mtd.writesize = 1;
 	flash->mtd.flags = MTD_CAP_NORFLASH;
-	flash->mtd.size = info->sector_size * info->n_sectors;
+	flash->mtd.size = (uint64_t)info->sector_size * info->n_sectors;
 	flash->mtd.erase = m25p80_erase;
 	flash->mtd.read = m25p80_read;
 
diff -urN barebox-2014.03.0.orig/drivers/mtd/devices/mtd_dataflash.c barebox-2014.03.0.work/drivers/mtd/devices/mtd_dataflash.c
--- barebox-2014.03.0.orig/drivers/mtd/devices/mtd_dataflash.c	2014-03-07 07:42:24.000000000 +0100
+++ barebox-2014.03.0.work/drivers/mtd/devices/mtd_dataflash.c	2014-06-16 19:09:04.000000000 +0200
@@ -625,7 +625,7 @@
 
 	device = &priv->mtd;
 	device->name = (pdata && pdata->name) ? pdata->name : "dataflash";
-	device->size = nr_pages * pagesize;
+	device->size = nr_pages * (uint64_t)pagesize;
 	device->erasesize = pagesize;
 	device->writesize = pagesize;
 	device->type = MTD_DATAFLASH;
diff -urN barebox-2014.03.0.orig/drivers/mtd/mtdoob.c barebox-2014.03.0.work/drivers/mtd/mtdoob.c
--- barebox-2014.03.0.orig/drivers/mtd/mtdoob.c	2014-03-07 07:42:24.000000000 +0100
+++ barebox-2014.03.0.work/drivers/mtd/mtdoob.c	2014-06-16 19:09:32.000000000 +0200
@@ -78,7 +78,7 @@
 
 	mtdoob = xzalloc(sizeof(*mtdoob));
 	mtdoob->cdev.ops = &mtd_ops_oob;
-	mtdoob->cdev.size = (mtd->size / mtd->writesize) * mtd->oobsize;
+	mtdoob->cdev.size = mtd_div_by_wb(mtd->size, mtd) * mtd->oobsize;
 	mtdoob->cdev.name = asprintf("%s_oob%d", devname, mtd->class_dev.id);
 	mtdoob->cdev.priv = mtdoob;
 	mtdoob->cdev.dev = &mtd->class_dev;
diff -urN barebox-2014.03.0.orig/drivers/mtd/mtdraw.c barebox-2014.03.0.work/drivers/mtd/mtdraw.c
--- barebox-2014.03.0.orig/drivers/mtd/mtdraw.c	2014-03-07 07:42:24.000000000 +0100
+++ barebox-2014.03.0.work/drivers/mtd/mtdraw.c	2014-05-31 17:53:03.000000000 +0200
@@ -290,7 +290,7 @@
 	mtdraw->mtd = mtd;
 
 	mtdraw->cdev.ops = (struct file_operations *)&mtd_raw_fops;
-	mtdraw->cdev.size = mtd->size / mtd->writesize *
+	mtdraw->cdev.size = mtd_div_by_wb(mtd->size, mtd) *
 		(mtd->writesize + mtd->oobsize);
 	mtdraw->cdev.name = asprintf("%s.raw", mtd->cdev.name);
 	mtdraw->cdev.priv = mtdraw;
diff -urN barebox-2014.03.0.orig/drivers/mtd/nand/nand_ids.c barebox-2014.03.0.work/drivers/mtd/nand/nand_ids.c
--- barebox-2014.03.0.orig/drivers/mtd/nand/nand_ids.c	2014-03-07 07:42:24.000000000 +0100
+++ barebox-2014.03.0.work/drivers/mtd/nand/nand_ids.c	2014-09-09 20:42:39.826287686 +0200
@@ -49,6 +49,14 @@
 	{__STR("TC58NVG6D2 64G 3.3V 8-bit"),
 		{ .id = {0x98, 0xde, 0x94, 0x82, 0x76, 0x56, 0x04, 0x20} },
 		  SZ_8K, SZ_8K, SZ_2M, 0, 8, 640},
+	{__STR("MT29F8G08 OOB 128 8G 3.3V 8-bit"),
+		{ .id = {0x2c, 0x38, 0x00, 0x26, 0x85, 0x00, 0x00, 0x00} },
+		  SZ_4K, SZ_1K, SZ_512K, LP_OPTIONS, 5, 128},
+	{__STR("MT29F32G08 OOB 128 32G 3.3V 8-bit"),
+		{ .id = {0x2c, 0x68, 0x04, 0x46, 0x89, 0x00, 0x00, 0x00} },
+		  SZ_4K, SZ_4K, SZ_1M, LP_OPTIONS, 5, 128},
+
+
 
 	LEGACY_ID_NAND(__STR("NAND 4MiB 5V 8-bit"),   0x6B, 4, SZ_8K, SP_OPTIONS),
 	LEGACY_ID_NAND(__STR("NAND 4MiB 3,3V 8-bit"), 0xE3, 4, SZ_8K, SP_OPTIONS),
diff -urN barebox-2014.03.0.orig/drivers/mtd/nand/nand_imx_bbm.c barebox-2014.03.0.work/drivers/mtd/nand/nand_imx_bbm.c
--- barebox-2014.03.0.orig/drivers/mtd/nand/nand_imx_bbm.c	2014-03-07 07:42:24.000000000 +0100
+++ barebox-2014.03.0.work/drivers/mtd/nand/nand_imx_bbm.c	2014-08-16 08:34:32.874299099 +0200
@@ -51,8 +51,22 @@
  * From this point on we can forget about the BBMs and rely completely
  * on the flash BBT.
  *
+ * 4096 byte data + 218(224) OOB, but instead:
+ *
+ * 512b data + 26b OOB +
+ * 512b data + 26b OOB +
+ * 512b data + 26b OOB +
+ * 512b data + 26b OOB +
+ * 512b data + 26b OOB +
+ * 512b data + 26b OOB +
+ * 512b data + 26b OOB +
+ * 512b data + 36b OOB
+ *
+ * This means that the factory provided bad block marker ends up
+ * in the page data at offset 3914 instead of in the OOB data.
+ *
  */
-static int checkbad(struct mtd_info *mtd, loff_t ofs, void *__buf)
+static int checkbad(struct mtd_info *mtd, loff_t ofs, void *__buf, uint32_t bbtbyteoffset)
 {
 	int ret, retlen;
 	uint8_t *buf = __buf;
@@ -61,13 +75,14 @@
 	if (ret < 0)
 		return ret;
 
-	if (buf[2000] != 0xff)
+	if (buf[bbtbyteoffset] != 0xff) {
 		return 1;
+	}
 
 	return 0;
 }
 
-static void *create_bbt(struct mtd_info *mtd)
+static void *create_bbt(struct mtd_info *mtd, uint32_t bbtbyteoffset)
 {
 	struct nand_chip *chip = mtd->priv;
 	int len, i, numblocks, ret;
@@ -97,9 +112,9 @@
 	numblocks = mtd->size >> (chip->bbt_erase_shift - 1);
 
 	for (i = 0; i < numblocks;) {
-		ret = checkbad(mtd, from, buf);
-		if (ret < 0)
-			goto out1;
+		ret = checkbad(mtd, from, buf, bbtbyteoffset);
+//		if (ret < 0)
+//			goto out1;
 
 		if (ret) {
 			bbt[i >> 3] |= 0x03 << (i & 0x6);
@@ -113,8 +128,8 @@
 
 	return bbt;
 
-out1:
-	free(buf);
+//out1:
+//	free(buf);
 out2:
 	free(bbt);
 
@@ -140,6 +155,7 @@
 	struct mtd_info *mtd;
 	int yes = 0;
 	void *bbt;
+	uint32_t bbtbyteoffset;
 
 	while ((opt = getopt(argc, argv, "y")) > 0) {
 		switch (opt) {
@@ -171,6 +187,10 @@
 		ret = 1;
 		goto out;
 	case 2048:
+		bbtbyteoffset = 2000; 
+		break;
+	case 4096:
+		bbtbyteoffset = 3914;
 		break;
 	default:
 		printf("not implemented for writesize %d\n", mtd->writesize);
@@ -178,7 +198,7 @@
 		goto out;
 	}
 
-	bbt = create_bbt(mtd);
+	bbt = create_bbt(mtd, bbtbyteoffset);
 	if (IS_ERR(bbt)) {
 		ret = 1;
 		goto out;
diff -urN barebox-2014.03.0.orig/drivers/mtd/partition.c barebox-2014.03.0.work/drivers/mtd/partition.c
--- barebox-2014.03.0.orig/drivers/mtd/partition.c	2014-03-07 07:42:24.000000000 +0100
+++ barebox-2014.03.0.work/drivers/mtd/partition.c	2014-08-04 22:17:36.995277044 +0200
@@ -90,8 +90,8 @@
 	return res;
 }
 
-struct mtd_info *mtd_add_partition(struct mtd_info *mtd, off_t offset, size_t size,
-		unsigned long flags, const char *name)
+struct mtd_info *mtd_add_partition(struct mtd_info *mtd, off_t offset,
+		uint64_t size, unsigned long flags, const char *name)
 {
 	struct mtd_part *slave;
 	struct mtd_info *slave_mtd;
diff -urN barebox-2014.03.0.orig/drivers/mtd/ubi/cdev.c barebox-2014.03.0.work/drivers/mtd/ubi/cdev.c
--- barebox-2014.03.0.orig/drivers/mtd/ubi/cdev.c	2014-03-07 07:42:24.000000000 +0100
+++ barebox-2014.03.0.work/drivers/mtd/ubi/cdev.c	2014-06-16 19:08:52.000000000 +0200
@@ -220,7 +220,7 @@
 		break;
 	case UBI_IOCMKVOL:
 		if (!req->bytes)
-			req->bytes = ubi->avail_pebs * ubi->leb_size;
+			req->bytes = (__s64)ubi->avail_pebs * ubi->leb_size;
 		return ubi_create_volume(ubi, req);
 	};
 
diff -urN barebox-2014.03.0.orig/images/Makefile.imx barebox-2014.03.0.work/images/Makefile.imx
--- barebox-2014.03.0.orig/images/Makefile.imx	2014-03-07 07:42:24.000000000 +0100
+++ barebox-2014.03.0.work/images/Makefile.imx	2014-07-06 19:27:17.860509941 +0200
@@ -41,6 +41,11 @@
 FILE_barebox-freescale-imx53-vmx53.img = start_imx53_vmx53.pblx.imximg
 image-$(CONFIG_MACH_FREESCALE_MX53_VMX53) += barebox-freescale-imx53-vmx53.img
 
+pblx-$(CONFIG_MACH_VMX53) += start_imx53_vmx53
+CFG_start_imx53_vmx53.pblx.imximg = $(board)/vmx53/flash-header-imx53-vmx53.imxcfg
+FILE_barebox-imx53-vmx53.img = start_imx53_vmx53.pblx.imximg
+image-$(CONFIG_MACH_VMX53) += barebox-imx53-vmx53.img
+
 pblx-$(CONFIG_MACH_TQMA53) += start_imx53_mba53_512mib
 CFG_start_imx53_mba53_512mib.pblx.imximg = $(board)/tqma53/flash-header-tq-tqma53-512mib.imxcfg
 FILE_barebox-tq-mba53-512mib.img = start_imx53_mba53_512mib.pblx.imximg
diff -urN barebox-2014.03.0.orig/include/linux/mtd/mtd-abi.h barebox-2014.03.0.work/include/linux/mtd/mtd-abi.h
--- barebox-2014.03.0.orig/include/linux/mtd/mtd-abi.h	2014-03-07 07:42:24.000000000 +0100
+++ barebox-2014.03.0.work/include/linux/mtd/mtd-abi.h	2014-05-31 17:54:52.000000000 +0200
@@ -9,6 +9,8 @@
 
 #ifndef DOXYGEN_SHOULD_SKIP_THIS
 
+#include <asm-generic/div64.h>
+
 struct erase_info_user {
 	uint32_t start;
 	uint32_t length;
@@ -73,7 +75,7 @@
 struct mtd_info_user {
 	uint8_t type;
 	uint32_t flags;
-	uint32_t size;	 // Total size of the MTD
+	uint64_t size;	 // Total size of the MTD
 	uint32_t erasesize;
 	uint32_t writesize;
 	uint32_t oobsize;   // Amount of OOB data per block (e.g. 16)
@@ -173,6 +175,13 @@
 	MTD_MODE_RAW,
 };
 
+static inline uint32_t mtd_user_div_by_eb(uint64_t sz,
+	struct mtd_info_user *mtd_user)
+{
+	do_div(sz, mtd_user->erasesize);
+	return sz;
+}
+
 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
 
 #endif /* __MTD_ABI_H__ */
diff -urN barebox-2014.03.0.orig/include/linux/mtd/mtd.h barebox-2014.03.0.work/include/linux/mtd/mtd.h
--- barebox-2014.03.0.orig/include/linux/mtd/mtd.h	2014-03-07 07:42:24.000000000 +0100
+++ barebox-2014.03.0.work/include/linux/mtd/mtd.h	2014-08-04 22:05:42.448420933 +0200
@@ -86,7 +86,7 @@
 struct mtd_info {
 	u_char type;
 	u_int32_t flags;
-	u_int32_t size;	 // Total size of the MTD
+	u_int64_t size;	 // Total size of the MTD
 
 	/* "Major" erase size for the device. Naïve users may take this
 	 * to be the only erase size available, or may use the more detailed
@@ -253,6 +253,12 @@
 {
 	return do_div(sz, mtd->erasesize);
 }
+
+static inline uint32_t mtd_div_by_wb(uint64_t sz, struct mtd_info *mtd)
+{
+	do_div(sz, mtd->writesize);
+	return sz;
+}
 	/* Kernel-side ioctl definitions */
 
 extern int add_mtd_device(struct mtd_info *mtd, char *devname, int device_id);
@@ -270,8 +276,8 @@
 	struct list_head list;
 };
 
-struct mtd_info *mtd_add_partition(struct mtd_info *mtd, off_t offset, size_t size,
-		unsigned long flags, const char *name);
+struct mtd_info *mtd_add_partition(struct mtd_info *mtd, off_t offset,
+		uint64_t size, unsigned long flags, const char *name);
 void mtd_del_partition(struct mtd_info *mtd);
 
 extern void register_mtd_user (struct mtd_notifier *new);
diff -urN barebox-2014.03.0.orig/lib/libmtd.c barebox-2014.03.0.work/lib/libmtd.c
--- barebox-2014.03.0.orig/lib/libmtd.c	2014-03-07 07:42:24.000000000 +0100
+++ barebox-2014.03.0.work/lib/libmtd.c	2014-05-31 17:59:26.000000000 +0200
@@ -195,7 +195,7 @@
 	     void *buf, int len)
 {
 	int ret, rd = 0;
-	off_t seek;
+	loff_t seek;
 
 	ret = mtd_valid_erase_block(mtd, eb);
 	if (ret)
@@ -209,7 +209,7 @@
 	}
 
 	/* Seek to the beginning of the eraseblock */
-	seek = (off_t)eb * mtd->eb_size + offs;
+	seek = (loff_t)eb * mtd->eb_size + offs;
 	if (lseek(fd, seek, SEEK_SET) != seek)
 		return sys_errmsg("cannot seek %s to offset %llu",
 				  mtd->node, (unsigned long long)seek);
@@ -229,7 +229,7 @@
 	      void *buf, int len)
 {
 	int ret;
-	off_t seek;
+	loff_t seek;
 
 	ret = mtd_valid_erase_block(mtd, eb);
 	if (ret)
@@ -255,7 +255,7 @@
 	}
 
 	/* Seek to the beginning of the eraseblock */
-	seek = (off_t)eb * mtd->eb_size + offs;
+	seek = (loff_t)eb * mtd->eb_size + offs;
 	if (lseek(fd, seek, SEEK_SET) != seek)
 		return sys_errmsg("cannot seek %s to offset %llu",
 				  mtd->node, (unsigned long long)seek);
@@ -326,7 +326,7 @@
 		goto out_close;
 	}
 
-	mtd->eb_cnt = ui.size / ui.erasesize;
+	mtd->eb_cnt = mtd_user_div_by_eb(ui.size, &ui);
 
 	switch(mtd->type) {
 	case MTD_ABSENT:
