--- /dev/null
+From ee16ee20205ea374613c3ac7f50209451eb29068 Mon Sep 17 00:00:00 2001
+From: Josua Mayer <josua.mayer97@gmail.com>
+Date: Sun, 23 Apr 2017 18:02:40 +0200
+Subject: [PATCH 1/4] clearfog: generate random MAC address
+
+The Clearfog does not come with predetermined MACs.
+Falling back to random ones ensures ethernet can still operate anyway.
+
+Signed-off-by: Josua Mayer >josua.mayer97@gmail.com>
+---
+ configs/clearfog_defconfig | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/configs/clearfog_defconfig b/configs/clearfog_defconfig
+index 1264871e83..41e94e6daf 100644
+--- a/configs/clearfog_defconfig
++++ b/configs/clearfog_defconfig
+@@ -47,6 +47,7 @@ CONFIG_DEBUG_UART=y
+ CONFIG_DEBUG_UART_BASE=0xd0012000
+ CONFIG_DEBUG_UART_CLOCK=250000000
+ CONFIG_DEBUG_UART_SHIFT=2
++CONFIG_NET_RANDOM_ETHADDR=y
+ CONFIG_SYS_NS16550=y
+ CONFIG_USB=y
+ CONFIG_DM_USB=y
+--
+2.12.2
+
--- /dev/null
+From 98848106b9558244ae36a85229caabcdb57d0f7b Mon Sep 17 00:00:00 2001
+From: Jonas Gorski <jonas.gorski@gmail.com>
+Date: Fri, 23 Sep 2016 13:58:14 +0200
+Subject: [PATCH 2/4] clearfog: reset usom onboard 1512 phy
+
+Use GPIO19 which is wired to the uSOM phy reset signal in order to reset
+the uSOM's 88E81512 gigabit Ethernet phy.
+
+This GPIO is valid on ClearFog rev 2.1 and newer.
+
+Signed-off-by: Rabeeh Khoury <rabeeh@solid-run.com>
+[jonas.gorski: adapted to upstream u-boot code]
+Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
+---
+ board/solidrun/clearfog/clearfog.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/board/solidrun/clearfog/clearfog.c b/board/solidrun/clearfog/clearfog.c
+index 2773f5957e..3a8257cac3 100644
+--- a/board/solidrun/clearfog/clearfog.c
++++ b/board/solidrun/clearfog/clearfog.c
+@@ -131,8 +131,12 @@ int board_init(void)
+ /* Toggle GPIO41 to reset onboard switch and phy */
+ clrbits_le32(MVEBU_GPIO1_BASE + 0x0, BIT(9));
+ clrbits_le32(MVEBU_GPIO1_BASE + 0x4, BIT(9));
++ /* GPIO 19 on ClearFog rev 2.1 controls the uSOM onboard phy reset */
++ clrbits_le32(MVEBU_GPIO0_BASE + 0x0, BIT(19));
++ clrbits_le32(MVEBU_GPIO0_BASE + 0x4, BIT(19));
+ mdelay(1);
+ setbits_le32(MVEBU_GPIO1_BASE + 0x0, BIT(9));
++ setbits_le32(MVEBU_GPIO0_BASE + 0x0, BIT(19));
+ mdelay(10);
+
+ /* Init I2C IO expanders */
+--
+2.12.2
+
--- /dev/null
+From 9653921eadd5d5268afbee6c928708158fc4e844 Mon Sep 17 00:00:00 2001
+From: Josua Mayer <josua.mayer97@gmail.com>
+Date: Tue, 22 Nov 2016 16:33:23 +0100
+Subject: [PATCH 3/4] clearfog: enable distro boot code
+
+load addresses start at 0x02000000, leaving enough space for fdt,
+boot scripts and ramdisk at the end.
+Only boot from mmc, the other options are not in working order.
+Removed *_high variables in good faith. They can be re-added with sane
+values when, and if required.
+
+Signed-off-by: Josua Mayer <josua.mayer97@gmail.com>
+---
+ Kconfig | 1 +
+ include/configs/clearfog.h | 47 +++++++++++++++++++++++++++++++++++++++++-----
+ 2 files changed, 43 insertions(+), 5 deletions(-)
+
+diff --git a/Kconfig b/Kconfig
+index 81b4226463..f7aec2255b 100644
+--- a/Kconfig
++++ b/Kconfig
+@@ -59,6 +59,7 @@ config DISTRO_DEFAULTS
+ default y if ARCH_LS2080A
+ default y if ARCH_MESON
+ default y if ARCH_ROCKCHIP
++ default y if TARGET_CLEARFOG
+ default n
+ select CMD_BOOTZ if ARM && !ARM64
+ select CMD_BOOTI if ARM64
+diff --git a/include/configs/clearfog.h b/include/configs/clearfog.h
+index 0c51d2a288..890dd84b5d 100644
+--- a/include/configs/clearfog.h
++++ b/include/configs/clearfog.h
+@@ -79,11 +79,6 @@
+
+ #define CONFIG_SYS_ALT_MEMTEST
+
+-/* Keep device tree and initrd in lower memory so the kernel can access them */
+-#define CONFIG_EXTRA_ENV_SETTINGS \
+- "fdt_high=0x10000000\0" \
+- "initrd_high=0x10000000\0"
+-
+ /* SPL */
+ /*
+ * Select the boot device here
+@@ -128,6 +123,48 @@
+ #endif
+ #endif
+
++#ifndef CONFIG_SPL_BUILD
++/*
++ * Add standard bootenv from distro boot code:
++ * Keep device tree and initrd in lower memory so the kernel can access them
++ * Set default load addresses:
++ * - 63MiB space for kernel
++ * - 1MiB space for fdt
++ * - 1MiB space for extlinux file, or boot script
++ * - remainder for ramdisk
++ * Keep device tree and initrd in lower memory so the kernel can access them
++ * Set name of fdt file (default to Clearfog Pro)
++ * specify console device
++ */
++#define CONFIG_EXTRA_ENV_SETTINGS \
++ "kernel_addr_r=0x02000000\0" \
++ "fdt_addr_r=0x05f00000\0" \
++ "pxefile_addr_r=0x06000000\0" \
++ "scriptaddr=0x06000000\0" \
++ "ramdisk_addr_r=0x06100000\0" \
++ "fdt_high=0x10000000\0" \
++ "initrd_high=0x10000000\0" \
++ "fdtfile=armada-388-clearfog-pro.dtb\0" \
++ "console=ttyS0," __stringify(CONFIG_BAUDRATE) "\0" \
++ BOOTENV
++
++/* include distro boot code defaults */
++#include <config_distro_defaults.h>
++
++/*
++ * specify boot order
++ * sdcard or emmc -> usb -> network
++ */
++#define BOOT_TARGET_DEVICES(func) \
++ func(MMC, mmc, 0) \
++ func(USB, usb, 0) \
++ func(PXE, pxe, na) \
++ func(DHCP, dhcp, na)
++
++/* include the actual distro boot code */
++#include <config_distro_bootcmd.h>
++#endif
++
+ /*
+ * mv-common.h should be defined after CMD configs since it used them
+ * to enable certain macros
+--
+2.12.2
+
+++ /dev/null
-diff --git a/configs/clearfog_defconfig b/configs/clearfog_defconfig
-index 1264871e83..41e94e6daf 100644
---- a/configs/clearfog_defconfig
-+++ b/configs/clearfog_defconfig
-@@ -47,6 +47,7 @@ CONFIG_DEBUG_UART=y
- CONFIG_DEBUG_UART_BASE=0xd0012000
- CONFIG_DEBUG_UART_CLOCK=250000000
- CONFIG_DEBUG_UART_SHIFT=2
-+CONFIG_NET_RANDOM_ETHADDR=y
- CONFIG_SYS_NS16550=y
- CONFIG_USB=y
- CONFIG_DM_USB=y
+++ /dev/null
-diff --git a/configs/clearfog_defconfig b/configs/clearfog_defconfig
-index 41e94e6daf..f23e65e345 100644
---- a/configs/clearfog_defconfig
-+++ b/configs/clearfog_defconfig
-@@ -11,6 +11,7 @@ CONFIG_DEFAULT_DEVICE_TREE="armada-388-clearfog"
- CONFIG_BOOTDELAY=3
- CONFIG_SYS_CONSOLE_INFO_QUIET=y
- # CONFIG_DISPLAY_BOARDINFO is not set
-+CONFIG_HUSH_PARSER=y
- CONFIG_SPL=y
- CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x141
- CONFIG_SPL_I2C_SUPPORT=y
-diff --git a/include/configs/clearfog.h b/include/configs/clearfog.h
-index 0c51d2a288..e52ba8145f 100644
---- a/include/configs/clearfog.h
-+++ b/include/configs/clearfog.h
-@@ -82,7 +82,18 @@
- /* Keep device tree and initrd in lower memory so the kernel can access them */
- #define CONFIG_EXTRA_ENV_SETTINGS \
- "fdt_high=0x10000000\0" \
-- "initrd_high=0x10000000\0"
-+ "initrd_high=0x10000000\0" \
-+ "script=boot.scr\0" \
-+ "loadaddr=0x01000000\0" \
-+ "mmcdev=0\0" \
-+ "mmcpart=1\0" \
-+ "loadbootscript=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${script};\0" \
-+ "bootscript=echo Running bootscript from mmc ...; source ${loadaddr}\0"
-+
-+#define CONFIG_BOOTCOMMAND \
-+ "if run loadbootscript; then " \
-+ "run bootscript; " \
-+ "fi"
-
- /* SPL */
- /*
+++ /dev/null
-From 98848106b9558244ae36a85229caabcdb57d0f7b Mon Sep 17 00:00:00 2001
-From: Jonas Gorski <jonas.gorski@gmail.com>
-Date: Fri, 23 Sep 2016 13:58:14 +0200
-Subject: [PATCH] clearfog: reset usom onboard 1512 phy
-
-Use GPIO19 which is wired to the uSOM phy reset signal in order to reset
-the uSOM's 88E81512 gigabit Ethernet phy.
-
-This GPIO is valid on ClearFog rev 2.1 and newer.
-
-Signed-off-by: Rabeeh Khoury <rabeeh@solid-run.com>
-[jonas.gorski: adapted to upstream u-boot code]
-Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
----
- board/solidrun/clearfog/clearfog.c | 4 ++++
- 1 file changed, 4 insertions(+)
-
-diff --git a/board/solidrun/clearfog/clearfog.c b/board/solidrun/clearfog/clearfog.c
-index 2773f5957e..3a8257cac3 100644
---- a/board/solidrun/clearfog/clearfog.c
-+++ b/board/solidrun/clearfog/clearfog.c
-@@ -131,8 +131,12 @@ int board_init(void)
- /* Toggle GPIO41 to reset onboard switch and phy */
- clrbits_le32(MVEBU_GPIO1_BASE + 0x0, BIT(9));
- clrbits_le32(MVEBU_GPIO1_BASE + 0x4, BIT(9));
-+ /* GPIO 19 on ClearFog rev 2.1 controls the uSOM onboard phy reset */
-+ clrbits_le32(MVEBU_GPIO0_BASE + 0x0, BIT(19));
-+ clrbits_le32(MVEBU_GPIO0_BASE + 0x4, BIT(19));
- mdelay(1);
- setbits_le32(MVEBU_GPIO1_BASE + 0x0, BIT(9));
-+ setbits_le32(MVEBU_GPIO0_BASE + 0x0, BIT(19));
- mdelay(10);
-
- /* Init I2C IO expanders */
---
-2.12.2
-