Merge git://git.denx.de/u-boot-tegra
diff --git a/Kconfig b/Kconfig
index 14740b4..c48f00e 100644
--- a/Kconfig
+++ b/Kconfig
@@ -380,6 +380,8 @@
 
 source "dts/Kconfig"
 
+source "env/Kconfig"
+
 source "net/Kconfig"
 
 source "drivers/Kconfig"
diff --git a/Makefile b/Makefile
index 3d636c5..2fc4616 100644
--- a/Makefile
+++ b/Makefile
@@ -690,6 +690,7 @@
 libs-y += drivers/usb/ulpi/
 libs-y += cmd/
 libs-y += common/
+libs-y += env/
 libs-$(CONFIG_API) += api/
 libs-$(CONFIG_HAS_POST) += post/
 libs-y += test/
@@ -1464,14 +1465,14 @@
 		false; \
 	fi
 
-env: scripts_basic
+environ: scripts_basic
 	$(Q)$(MAKE) $(build)=tools/$@
 
 tools-only: scripts_basic $(version_h) $(timestamp_h)
 	$(Q)$(MAKE) $(build)=tools
 
 tools-all: export HOST_TOOLS_ALL=y
-tools-all: env tools ;
+tools-all: environ tools ;
 
 cross_tools: export CROSS_BUILD_TOOLS=y
 cross_tools: tools ;
diff --git a/README b/README
index 3fdb89c..1a7a788 100644
--- a/README
+++ b/README
@@ -3286,7 +3286,7 @@
 
 Please note that the environment is read-only until the monitor
 has been relocated to RAM and a RAM copy of the environment has been
-created; also, when using EEPROM you will have to use getenv_f()
+created; also, when using EEPROM you will have to use env_get_f()
 until then to read environment variables.
 
 The environment is protected by a CRC32 checksum. Before the monitor
diff --git a/api/api.c b/api/api.c
index 4fae95d..7eee2fc 100644
--- a/api/api.c
+++ b/api/api.c
@@ -458,7 +458,7 @@
 	if ((value = (char **)va_arg(ap, uintptr_t)) == NULL)
 		return API_EINVAL;
 
-	*value = getenv(name);
+	*value = env_get(name);
 
 	return 0;
 }
@@ -481,7 +481,7 @@
 	if ((value = (char *)va_arg(ap, uintptr_t)) == NULL)
 		return API_EINVAL;
 
-	setenv(name, value);
+	env_set(name, value);
 
 	return 0;
 }
@@ -663,7 +663,7 @@
 		return;
 	}
 
-	setenv_hex("api_address", (unsigned long)sig);
+	env_set_hex("api_address", (unsigned long)sig);
 	debugf("API sig @ 0x%lX\n", (unsigned long)sig);
 	memcpy(sig->magic, API_SIG_MAGIC, 8);
 	sig->version = API_SIG_VERSION;
diff --git a/arch/arc/lib/bootm.c b/arch/arc/lib/bootm.c
index 5798149..a498ce5 100644
--- a/arch/arc/lib/bootm.c
+++ b/arch/arc/lib/bootm.c
@@ -85,7 +85,7 @@
 		r2 = (unsigned int)images->ft_addr;
 	} else {
 		r0 = 1;
-		r2 = (unsigned int)getenv("bootargs");
+		r2 = (unsigned int)env_get("bootargs");
 	}
 
 	smp_set_core_boot_addr((unsigned long)kernel_entry, -1);
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 39b001f..da9324b 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -97,6 +97,9 @@
 config ARM_ERRATA_833471
 	bool
 
+config ARM_ERRATA_845369
+       bool
+
 config ARM_ERRATA_852421
 	bool
 
@@ -493,7 +496,6 @@
 	select DM_GPIO
 	select OF_CONTROL
 	imply FAT_WRITE
-	imply ENV_IS_IN_FAT
 
 config TARGET_VEXPRESS_CA15_TC2
 	bool "Support vexpress_ca15_tc2"
@@ -1039,7 +1041,6 @@
 	select SPL_PINCTRL if SPL
 	select SUPPORT_SPL
 	imply FAT_WRITE
-	imply ENV_IS_IN_MMC
 	help
 	  Support for UniPhier SoC family developed by Socionext Inc.
 	  (formerly, System LSI Business Division of Panasonic Corporation)
diff --git a/arch/arm/cpu/armv7/start.S b/arch/arm/cpu/armv7/start.S
index f06fd28..7b84a7a 100644
--- a/arch/arm/cpu/armv7/start.S
+++ b/arch/arm/cpu/armv7/start.S
@@ -187,6 +187,12 @@
 	mcr	p15, 0, r0, c15, c0, 1	@ write diagnostic register
 #endif
 
+#ifdef CONFIG_ARM_ERRATA_845369
+	mrc     p15, 0, r0, c15, c0, 1	@ read diagnostic register
+	orr     r0, r0, #1 << 22	@ set bit #22
+	mcr     p15, 0, r0, c15, c0, 1	@ write diagnostic register
+#endif
+
 	mov	r5, lr			@ Store my Caller
 	mrc	p15, 0, r1, c0, c0, 0	@ r1 has Read Main ID Register (MIDR)
 	mov	r3, r1, lsr #20		@ get variant field
diff --git a/arch/arm/cpu/armv7/vf610/generic.c b/arch/arm/cpu/armv7/vf610/generic.c
index ac2d8d1..88f3f4d 100644
--- a/arch/arm/cpu/armv7/vf610/generic.c
+++ b/arch/arm/cpu/armv7/vf610/generic.c
@@ -329,7 +329,7 @@
 
 	strcpy(soc, "vf");
 	strcat(soc, soc_type);
-	setenv("soc", soc);
+	env_set("soc", soc);
 
 	return 0;
 }
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/soc.c b/arch/arm/cpu/armv8/fsl-layerscape/soc.c
index aee1ffa..639e9d2 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/soc.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/soc.c
@@ -95,7 +95,7 @@
 
 static unsigned long get_internval_val_mhz(void)
 {
-	char *interval = getenv(PLATFORM_CYCLE_ENV_VAR);
+	char *interval = env_get(PLATFORM_CYCLE_ENV_VAR);
 	/*
 	 *  interval is the number of platform cycles(MHz) between
 	 *  wake up events generated by EPU.
diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 2cbdb17..f94c247 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -336,6 +336,8 @@
 	sun50i-h5-orangepi-zero-plus2.dtb
 dtb-$(CONFIG_MACH_SUN50I) += \
 	sun50i-a64-bananapi-m64.dtb \
+	sun50i-a64-nanopi-a64.dtb \
+	sun50i-a64-olinuxino.dtb \
 	sun50i-a64-orangepi-win.dtb \
 	sun50i-a64-pine64-plus.dtb \
 	sun50i-a64-pine64.dtb
diff --git a/arch/arm/dts/sun50i-a64-nanopi-a64.dts b/arch/arm/dts/sun50i-a64-nanopi-a64.dts
new file mode 100644
index 0000000..778636c
--- /dev/null
+++ b/arch/arm/dts/sun50i-a64-nanopi-a64.dts
@@ -0,0 +1,115 @@
+/*
+ * Copyright (C) 2017 Jagan Teki <jteki@openedev.com>
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This library 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 library 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.
+ *
+ * Or, alternatively,
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ *     obtaining a copy of this software and associated documentation
+ *     files (the "Software"), to deal in the Software without
+ *     restriction, including without limitation the rights to use,
+ *     copy, modify, merge, publish, distribute, sublicense, and/or
+ *     sell copies of the Software, and to permit persons to whom the
+ *     Software is furnished to do so, subject to the following
+ *     conditions:
+ *
+ *     The above copyright notice and this permission notice shall be
+ *     included in all copies or substantial portions of the Software.
+ *
+ *     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ *     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ *     HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ *     WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ *     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ *     OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/dts-v1/;
+
+#include "sun50i-a64.dtsi"
+
+#include <dt-bindings/gpio/gpio.h>
+
+/ {
+	model = "FriendlyARM NanoPi A64";
+	compatible = "friendlyarm,nanopi-a64", "allwinner,sun50i-a64";
+
+	aliases {
+		serial0 = &uart0;
+	};
+
+	chosen {
+		stdout-path = "serial0:115200n8";
+	};
+
+	reg_vcc3v3: vcc3v3 {
+		compatible = "regulator-fixed";
+		regulator-name = "vcc3v3";
+		regulator-min-microvolt = <3300000>;
+		regulator-max-microvolt = <3300000>;
+	};
+};
+
+&ehci0 {
+	status = "okay";
+};
+
+&ehci1 {
+	status = "okay";
+};
+
+/* i2c1 connected with gpio headers like pine64, bananapi */
+&i2c1 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&i2c1_pins>;
+	status = "disabled";
+};
+
+&i2c1_pins {
+	bias-pull-up;
+};
+
+&mmc0 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&mmc0_pins>;
+	vmmc-supply = <&reg_vcc3v3>;
+	cd-gpios = <&pio 5 6 GPIO_ACTIVE_HIGH>;
+	cd-inverted;
+	disable-wp;
+	bus-width = <4>;
+	status = "okay";
+};
+
+&ohci0 {
+	status = "okay";
+};
+
+&ohci1 {
+	status = "okay";
+};
+
+&uart0 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&uart0_pins_a>;
+	status = "okay";
+};
+
+&usbphy {
+	status = "okay";
+};
diff --git a/arch/arm/dts/sun50i-a64-olinuxino.dts b/arch/arm/dts/sun50i-a64-olinuxino.dts
new file mode 100644
index 0000000..7bd4730
--- /dev/null
+++ b/arch/arm/dts/sun50i-a64-olinuxino.dts
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2017 Jagan Teki <jteki@openedev.com>
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This library 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 library 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.
+ *
+ * Or, alternatively,
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ *     obtaining a copy of this software and associated documentation
+ *     files (the "Software"), to deal in the Software without
+ *     restriction, including without limitation the rights to use,
+ *     copy, modify, merge, publish, distribute, sublicense, and/or
+ *     sell copies of the Software, and to permit persons to whom the
+ *     Software is furnished to do so, subject to the following
+ *     conditions:
+ *
+ *     The above copyright notice and this permission notice shall be
+ *     included in all copies or substantial portions of the Software.
+ *
+ *     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ *     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ *     HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ *     WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ *     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ *     OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/dts-v1/;
+
+#include "sun50i-a64.dtsi"
+
+#include <dt-bindings/gpio/gpio.h>
+
+/ {
+	model = "Olimex A64-Olinuxino";
+	compatible = "olimex,a64-olinuxino", "allwinner,sun50i-a64";
+
+	aliases {
+		serial0 = &uart0;
+	};
+
+	chosen {
+		stdout-path = "serial0:115200n8";
+	};
+
+	reg_vcc3v3: vcc3v3 {
+		compatible = "regulator-fixed";
+		regulator-name = "vcc3v3";
+		regulator-min-microvolt = <3300000>;
+		regulator-max-microvolt = <3300000>;
+	};
+};
+
+&mmc0 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&mmc0_pins>;
+	vmmc-supply = <&reg_vcc3v3>;
+	cd-gpios = <&pio 5 6 GPIO_ACTIVE_HIGH>;
+	cd-inverted;
+	disable-wp;
+	bus-width = <4>;
+	status = "okay";
+};
+
+&uart0 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&uart0_pins_a>;
+	status = "okay";
+};
diff --git a/arch/arm/dts/sun50i-a64.dtsi b/arch/arm/dts/sun50i-a64.dtsi
index c7f669f..65a344d 100644
--- a/arch/arm/dts/sun50i-a64.dtsi
+++ b/arch/arm/dts/sun50i-a64.dtsi
@@ -204,6 +204,28 @@
 			#phy-cells = <1>;
 		};
 
+		ehci0: usb@01c1a000 {
+			compatible = "allwinner,sun50i-a64-ehci", "generic-ehci";
+			reg = <0x01c1a000 0x100>;
+			interrupts = <GIC_SPI 72 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&ccu CLK_BUS_OHCI0>,
+				 <&ccu CLK_BUS_EHCI0>,
+				 <&ccu CLK_USB_OHCI0>;
+			resets = <&ccu RST_BUS_OHCI0>,
+				 <&ccu RST_BUS_EHCI0>;
+			status = "disabled";
+		};
+
+		ohci0: usb@01c1a400 {
+			compatible = "allwinner,sun50i-a64-ohci", "generic-ohci";
+			reg = <0x01c1a400 0x100>;
+			interrupts = <GIC_SPI 73 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&ccu CLK_BUS_OHCI0>,
+				 <&ccu CLK_USB_OHCI0>;
+			resets = <&ccu RST_BUS_OHCI0>;
+			status = "disabled";
+		};
+
 		ehci1: usb@01c1b000 {
 			compatible = "allwinner,sun50i-a64-ehci", "generic-ehci";
 			reg = <0x01c1b000 0x100>;
diff --git a/arch/arm/dts/sun7i-a20-olinuxino-lime2-emmc.dts b/arch/arm/dts/sun7i-a20-olinuxino-lime2-emmc.dts
index 5ea4915..10d3074 100644
--- a/arch/arm/dts/sun7i-a20-olinuxino-lime2-emmc.dts
+++ b/arch/arm/dts/sun7i-a20-olinuxino-lime2-emmc.dts
@@ -56,7 +56,7 @@
 };
 
 &pio {
-	mmc2_pins_nrst: mmc2@0 {
+	mmc2_pins_nrst: mmc2-rst-pin {
 		allwinner,pins = "PC16";
 		allwinner,function = "gpio_out";
 		allwinner,drive = <SUN4I_PINCTRL_10_MA>;
diff --git a/arch/arm/include/asm/arch-mx6/mx6q_pins.h b/arch/arm/include/asm/arch-mx6/mx6q_pins.h
index a8456a2..41f7240 100644
--- a/arch/arm/include/asm/arch-mx6/mx6q_pins.h
+++ b/arch/arm/include/asm/arch-mx6/mx6q_pins.h
@@ -863,7 +863,7 @@
 MX6_PAD_DECL(SD3_DAT4__UART2_TX_DATA,	0x069C, 0x02B4, 1, 0x0000, 0, 0)
 MX6_PAD_DECL(SD3_DAT4__UART2_RX_DATA,	0x069C, 0x02B4, 1, 0x0928, 5, 0)
 MX6_PAD_DECL(SD3_DAT4__GPIO7_IO01,	0x069C, 0x02B4, 5, 0x0000, 0, 0)
-MX6_PAD_DECL(SD3_CMD__SD3_CMD,	0x06A0, 0x02B8, 16, 0x0000, 0, 0)
+MX6_PAD_DECL(SD3_CMD__SD3_CMD,		0x06A0, 0x02B8, 0 | IOMUX_CONFIG_SION, 0x0000, 0, 0)
 MX6_PAD_DECL(SD3_CMD__UART2_CTS_B,	0x06A0, 0x02B8, 1, 0x0000, 0, 0)
 MX6_PAD_DECL(SD3_CMD__UART2_RTS_B,	0x06A0, 0x02B8, 1, 0x0924, 2, 0)
 MX6_PAD_DECL(SD3_CMD__FLEXCAN1_TX,	0x06A0, 0x02B8, 2, 0x0000, 0, 0)
@@ -924,7 +924,7 @@
 MX6_PAD_DECL(NANDF_CS3__EIM_ADDR26,	0x06D8, 0x02F0, 3, 0x0000, 0, 0)
 MX6_PAD_DECL(NANDF_CS3__GPIO6_IO16,	0x06D8, 0x02F0, 5, 0x0000, 0, 0)
 MX6_PAD_DECL(NANDF_CS3__IPU2_SISG1,	0x06D8, 0x02F0, 6, 0x0000, 0, 0)
-MX6_PAD_DECL(SD4_CMD__SD4_CMD,	0x06DC, 0x02F4, 16, 0x0000, 0, 0)
+MX6_PAD_DECL(SD4_CMD__SD4_CMD,		0x06DC, 0x02F4, 0 | IOMUX_CONFIG_SION, 0x0000, 0, 0)
 MX6_PAD_DECL(SD4_CMD__NAND_RE_B,	0x06DC, 0x02F4, 1, 0x0000, 0, 0)
 MX6_PAD_DECL(SD4_CMD__UART3_TX_DATA,	0x06DC, 0x02F4, 2, 0x0000, 0, 0)
 MX6_PAD_DECL(SD4_CMD__UART3_RX_DATA,	0x06DC, 0x02F4, 2, 0x0930, 2, 0)
@@ -1001,7 +1001,7 @@
 MX6_PAD_DECL(SD1_DAT3__WDOG2_B,	0x072C, 0x0344, 4, 0x0000, 0, 0)
 MX6_PAD_DECL(SD1_DAT3__GPIO1_IO21,	0x072C, 0x0344, 5, 0x0000, 0, 0)
 MX6_PAD_DECL(SD1_DAT3__WDOG2_RESET_B_DEB,	0x072C, 0x0344, 6, 0x0000, 0, 0)
-MX6_PAD_DECL(SD1_CMD__SD1_CMD,	0x0730, 0x0348, 16, 0x0000, 0, 0)
+MX6_PAD_DECL(SD1_CMD__SD1_CMD,		0x0730, 0x0348, 0 | IOMUX_CONFIG_SION, 0x0000, 0, 0)
 MX6_PAD_DECL(SD1_CMD__ECSPI5_MOSI,	0x0730, 0x0348, 1, 0x0830, 0, 0)
 MX6_PAD_DECL(SD1_CMD__PWM4_OUT,	0x0730, 0x0348, 2, 0x0000, 0, 0)
 MX6_PAD_DECL(SD1_CMD__GPT_COMPARE1,	0x0730, 0x0348, 3, 0x0000, 0, 0)
@@ -1022,7 +1022,7 @@
 MX6_PAD_DECL(SD2_CLK__KEY_COL5,	0x073C, 0x0354, 2, 0x08E8, 3, 0)
 MX6_PAD_DECL(SD2_CLK__AUD4_RXFS,	0x073C, 0x0354, 3, 0x07C0, 1, 0)
 MX6_PAD_DECL(SD2_CLK__GPIO1_IO10,	0x073C, 0x0354, 5, 0x0000, 0, 0)
-MX6_PAD_DECL(SD2_CMD__SD2_CMD,	0x0740, 0x0358, 16, 0x0000, 0, 0)
+MX6_PAD_DECL(SD2_CMD__SD2_CMD,		0x0740, 0x0358, 0 | IOMUX_CONFIG_SION, 0x0000, 0, 0)
 MX6_PAD_DECL(SD2_CMD__ECSPI5_MOSI,	0x0740, 0x0358, 1, 0x0830, 1, 0)
 MX6_PAD_DECL(SD2_CMD__KEY_ROW5,	0x0740, 0x0358, 2, 0x08F4, 2, 0)
 MX6_PAD_DECL(SD2_CMD__AUD4_RXC,	0x0740, 0x0358, 3, 0x07BC, 1, 0)
diff --git a/arch/arm/include/asm/arch-sunxi/prcm.h b/arch/arm/include/asm/arch-sunxi/prcm.h
index ae3880b..ba4427c 100644
--- a/arch/arm/include/asm/arch-sunxi/prcm.h
+++ b/arch/arm/include/asm/arch-sunxi/prcm.h
@@ -196,6 +196,10 @@
 #define PRCM_CPU3_PWR_CLAMP(n) (((n) & 0xff) << 0)
 #define PRCM_CPU3_PWR_CLAMP_MASK PRCM_CPU3_PWR_CLAMP(0xff)
 
+#define PRCM_SEC_SWITCH_APB0_CLK_NONSEC (0x1 << 0)
+#define PRCM_SEC_SWITCH_PLL_CFG_NONSEC (0x1 << 1)
+#define PRCM_SEC_SWITCH_PWR_GATE_NONSEC (0x1 << 2)
+
 #ifndef __ASSEMBLY__
 #include <linux/compiler.h>
 
@@ -233,6 +237,8 @@
 	u32 dram_pwr;		/* 0x180 */
 	u8 res12[0xc];		/* 0x184 */
 	u32 dram_tst;		/* 0x190 */
+	u8 res13[0x3c];		/* 0x194 */
+	u32 prcm_sec_switch;	/* 0x1d0 */
 };
 
 void prcm_apb0_enable(u32 flags);
diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c
index 704849b..5c62d9c 100644
--- a/arch/arm/lib/bootm.c
+++ b/arch/arm/lib/bootm.c
@@ -216,7 +216,7 @@
 /* Subcommand: PREP */
 static void boot_prep_linux(bootm_headers_t *images)
 {
-	char *commandline = getenv("bootargs");
+	char *commandline = env_get("bootargs");
 
 	if (IMAGE_ENABLE_OF_LIBFDT && images->ft_len) {
 #ifdef CONFIG_OF_LIBFDT
@@ -273,7 +273,7 @@
 #ifdef CONFIG_ARMV7_NONSEC
 bool armv7_boot_nonsec(void)
 {
-	char *s = getenv("bootm_boot_mode");
+	char *s = env_get("bootm_boot_mode");
 	bool nonsec = armv7_boot_nonsec_default();
 
 	if (s && !strcmp(s, "sec"))
@@ -361,7 +361,7 @@
 	ulong addr = (ulong)kernel_entry | 1;
 	kernel_entry = (void *)addr;
 #endif
-	s = getenv("machid");
+	s = env_get("machid");
 	if (s) {
 		if (strict_strtoul(s, 16, &machid) < 0) {
 			debug("strict_strtoul failed!\n");
diff --git a/arch/arm/lib/semihosting.c b/arch/arm/lib/semihosting.c
index 415ac89..bcd16ee 100644
--- a/arch/arm/lib/semihosting.c
+++ b/arch/arm/lib/semihosting.c
@@ -200,7 +200,7 @@
 		/* Optionally save returned end to the environment */
 		if (argc == 4) {
 			sprintf(end_str, "0x%08lx", end_addr);
-			setenv(argv[3], end_str);
+			env_set(argv[3], end_str);
 		}
 	} else {
 		return CMD_RET_USAGE;
diff --git a/arch/arm/mach-davinci/misc.c b/arch/arm/mach-davinci/misc.c
index ec331ba..461ff77 100644
--- a/arch/arm/mach-davinci/misc.c
+++ b/arch/arm/mach-davinci/misc.c
@@ -90,7 +90,7 @@
 	uint8_t env_enetaddr[6];
 	int ret;
 
-	ret = eth_getenv_enetaddr_by_index("eth", 0, env_enetaddr);
+	ret = eth_env_get_enetaddr_by_index("eth", 0, env_enetaddr);
 	if (!ret) {
 		/*
 		 * There is no MAC address in the environment, so we
@@ -99,7 +99,7 @@
 		debug("### Setting environment from EEPROM MAC address = "
 			"\"%pM\"\n",
 			env_enetaddr);
-		ret = !eth_setenv_enetaddr("ethaddr", rom_enetaddr);
+		ret = !eth_env_set_enetaddr("ethaddr", rom_enetaddr);
 	}
 	if (!ret)
 		printf("Failed to set mac address from EEPROM: %d\n", ret);
diff --git a/arch/arm/mach-exynos/Kconfig b/arch/arm/mach-exynos/Kconfig
index 8b1389f..2fb84f9 100644
--- a/arch/arm/mach-exynos/Kconfig
+++ b/arch/arm/mach-exynos/Kconfig
@@ -8,7 +8,6 @@
 	bool "Exynos4 SoC family"
 	select CPU_V7
 	select BOARD_EARLY_INIT_F
-	imply ENV_IS_IN_MMC
 	help
 	  Samsung Exynos4 SoC family are based on ARM Cortex-A9 CPU. There
 	  are multiple SoCs in this family including Exynos4210, Exynos4412,
diff --git a/arch/arm/mach-imx/mx6/Kconfig b/arch/arm/mach-imx/mx6/Kconfig
index 9bae748..a1aa36b 100644
--- a/arch/arm/mach-imx/mx6/Kconfig
+++ b/arch/arm/mach-imx/mx6/Kconfig
@@ -1,24 +1,32 @@
 if ARCH_MX6
 
+config MX6_SMP
+	select ARM_ERRATA_751472
+	select ARM_ERRATA_761320
+	select ARM_ERRATA_794072
+	select ARM_ERRATA_845369
+	bool
+
 config MX6
+	select ARM_ERRATA_743622 if !MX6UL
 	bool
 	default y
-	select ARM_ERRATA_743622 if !MX6UL
-	select ARM_ERRATA_751472 if !MX6UL
-	select ARM_ERRATA_761320 if !MX6UL
-	select ARM_ERRATA_794072 if !MX6UL
 	imply CMD_FUSE
 
 config MX6D
+	select MX6_SMP
 	bool
 
 config MX6DL
+	select MX6_SMP
 	bool
 
 config MX6Q
+	select MX6_SMP
 	bool
 
 config MX6QDL
+	select MX6_SMP
 	bool
 
 config MX6S
@@ -30,7 +38,6 @@
 config MX6SX
 	select ROM_UNIFIED_SECTIONS
 	bool
-	imply ENV_IS_IN_MMC
 
 config MX6SLL
 	select ROM_UNIFIED_SECTIONS
@@ -332,6 +339,11 @@
 	select BOARD_LATE_INIT
 	select SUPPORT_SPL
 
+config TARGET_PFLA02
+	bool "Phytec PFLA02 (PhyFlex) i.MX6 Quad"
+	select BOARD_LATE_INIT
+	select SUPPORT_SPL
+
 config TARGET_SECOMX6
 	bool "secomx6 boards"
 
@@ -429,6 +441,7 @@
 source "board/freescale/mx6ullevk/Kconfig"
 source "board/grinn/liteboard/Kconfig"
 source "board/phytec/pcm058/Kconfig"
+source "board/phytec/pfla02/Kconfig"
 source "board/gateworks/gw_ventana/Kconfig"
 source "board/kosagi/novena/Kconfig"
 source "board/samtec/vining_2000/Kconfig"
diff --git a/arch/arm/mach-imx/mx6/clock.c b/arch/arm/mach-imx/mx6/clock.c
index 1f2739e..0e019c4 100644
--- a/arch/arm/mach-imx/mx6/clock.c
+++ b/arch/arm/mach-imx/mx6/clock.c
@@ -19,7 +19,7 @@
 	PLL_USBOTG,	/* OTG USB PLL */
 	PLL_ENET,	/* ENET PLL */
 	PLL_AUDIO,	/* AUDIO PLL */
-	PLL_VIDEO,	/* AUDIO PLL */
+	PLL_VIDEO,	/* VIDEO PLL */
 };
 
 struct mxc_ccm_reg *imx_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
diff --git a/arch/arm/mach-imx/mx6/opos6ul.c b/arch/arm/mach-imx/mx6/opos6ul.c
index 22b2440..f8d7e8e 100644
--- a/arch/arm/mach-imx/mx6/opos6ul.c
+++ b/arch/arm/mach-imx/mx6/opos6ul.c
@@ -132,7 +132,7 @@
 	/* In bootstrap don't use the env vars */
 	if (((reg & 0x3000000) >> 24) == 0x1) {
 		set_default_env(NULL);
-		setenv("preboot", "");
+		env_set("preboot", "");
 	}
 
 	return opos6ul_board_late_init();
diff --git a/arch/arm/mach-imx/mx6/soc.c b/arch/arm/mach-imx/mx6/soc.c
index af31673..9ede1f5 100644
--- a/arch/arm/mach-imx/mx6/soc.c
+++ b/arch/arm/mach-imx/mx6/soc.c
@@ -114,6 +114,12 @@
 #define OCOTP_CFG3_SPEED_528MHZ 1
 #define OCOTP_CFG3_SPEED_696MHZ 2
 
+/*
+ * For i.MX6ULL
+ */
+#define OCOTP_CFG3_SPEED_792MHZ 2
+#define OCOTP_CFG3_SPEED_900MHZ 3
+
 u32 get_cpu_speed_grade_hz(void)
 {
 	struct ocotp_regs *ocotp = (struct ocotp_regs *)OCOTP_BASE_ADDR;
@@ -126,11 +132,22 @@
 	val >>= OCOTP_CFG3_SPEED_SHIFT;
 	val &= 0x3;
 
-	if (is_mx6ul() || is_mx6ull()) {
+	if (is_mx6ul()) {
 		if (val == OCOTP_CFG3_SPEED_528MHZ)
 			return 528000000;
 		else if (val == OCOTP_CFG3_SPEED_696MHZ)
-			return 69600000;
+			return 696000000;
+		else
+			return 0;
+	}
+
+	if (is_mx6ull()) {
+		if (val == OCOTP_CFG3_SPEED_528MHZ)
+			return 528000000;
+		else if (val == OCOTP_CFG3_SPEED_792MHZ)
+			return 792000000;
+		else if (val == OCOTP_CFG3_SPEED_900MHZ)
+			return 900000000;
 		else
 			return 0;
 	}
@@ -234,6 +251,10 @@
 	u32 val, step, old, reg = readl(&anatop->reg_core);
 	u8 shift;
 
+	/* No LDO_SOC/PU/ARM */
+	if (is_mx6sll())
+		return 0;
+
 	if (mv < 725)
 		val = 0x00;	/* Power gated off */
 	else if (mv > 1450)
@@ -293,7 +314,7 @@
 	reg = readl(&mxc_ccm->ccdr);
 
 	/* Clear MMDC channel mask */
-	if (is_mx6sx() || is_mx6ul() || is_mx6ull() || is_mx6sl())
+	if (is_mx6sx() || is_mx6ul() || is_mx6ull() || is_mx6sl() || is_mx6sll())
 		reg &= ~(MXC_CCM_CCDR_MMDC_CH1_HS_MASK);
 	else
 		reg &= ~(MXC_CCM_CCDR_MMDC_CH1_HS_MASK | MXC_CCM_CCDR_MMDC_CH0_HS_MASK);
@@ -344,20 +365,10 @@
 	}
 }
 
-#ifdef CONFIG_MX6SL
-static void set_preclk_from_osc(void)
-{
-	struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
-	u32 reg;
-
-	reg = readl(&mxc_ccm->cscmr1);
-	reg |= MXC_CCM_CSCMR1_PER_CLK_SEL_MASK;
-	writel(reg, &mxc_ccm->cscmr1);
-}
-#endif
-
 int arch_cpu_init(void)
 {
+	struct mxc_ccm_reg *ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
+
 	init_aips();
 
 	/* Need to clear MMDC_CHx_MASK to make warm reset work. */
@@ -421,12 +432,14 @@
 	}
 
 	/* Set perclk to source from OSC 24MHz */
-#if defined(CONFIG_MX6SL)
-	set_preclk_from_osc();
-#endif
+	if (is_mx6sl())
+		setbits_le32(&ccm->cscmr1, MXC_CCM_CSCMR1_PER_CLK_SEL_MASK);
 
 	imx_set_wdog_powerdown(false); /* Disable PDE bit of WMCR register */
 
+	if (is_mx6sx())
+		setbits_le32(&ccm->cscdr1, MXC_CCM_CSCDR1_UART_CLK_SEL);
+
 	init_src();
 
 	return 0;
@@ -495,6 +508,10 @@
 
 int board_postclk_init(void)
 {
+	/* NO LDO SOC on i.MX6SLL */
+	if (is_mx6sll())
+		return 0;
+
 	set_ldo_voltage(LDO_SOC, 1175);	/* Set VDDSOC to 1.175V */
 
 	return 0;
@@ -576,7 +593,7 @@
 	u32 mask528;
 	u32 reg, periph1, periph2;
 
-	if (is_mx6sx() || is_mx6ul() || is_mx6ull())
+	if (is_mx6sx() || is_mx6ul() || is_mx6ull() || is_mx6sll())
 		return;
 
 	/* Due to hardware limitation, on MX6Q we need to gate/ungate all PFDs
diff --git a/arch/arm/mach-imx/mx7/Kconfig b/arch/arm/mach-imx/mx7/Kconfig
index 7053697f..aea8526 100644
--- a/arch/arm/mach-imx/mx7/Kconfig
+++ b/arch/arm/mach-imx/mx7/Kconfig
@@ -13,7 +13,6 @@
 	select ROM_UNIFIED_SECTIONS
 	imply CMD_FUSE
 	bool
-	imply ENV_IS_IN_MMC
 
 choice
 	prompt "MX7 board select"
diff --git a/arch/arm/mach-imx/mx7/soc.c b/arch/arm/mach-imx/mx7/soc.c
index 4cf977e..87bf105 100644
--- a/arch/arm/mach-imx/mx7/soc.c
+++ b/arch/arm/mach-imx/mx7/soc.c
@@ -31,7 +31,7 @@
 };
 #endif
 
-#ifdef CONFIG_IMX_RDC
+#if CONFIG_IS_ENABLED(IMX_RDC)
 /*
  * In current design, if any peripheral was assigned to both A7 and M4,
  * it will receive ipg_stop or ipg_wait when any of the 2 platforms enter
@@ -245,8 +245,9 @@
 	mxs_dma_init();
 #endif
 
-	if (IS_ENABLED(CONFIG_IMX_RDC))
-		isolate_resource();
+#if CONFIG_IS_ENABLED(IMX_RDC)
+	isolate_resource();
+#endif
 
 	return 0;
 }
@@ -256,9 +257,9 @@
 {
 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
 	if (is_mx7d())
-		setenv("soc", "imx7d");
+		env_set("soc", "imx7d");
 	else
-		setenv("soc", "imx7s");
+		env_set("soc", "imx7s");
 #endif
 
 	return 0;
diff --git a/arch/arm/mach-imx/video.c b/arch/arm/mach-imx/video.c
index 55242f0..c670c5d 100644
--- a/arch/arm/mach-imx/video.c
+++ b/arch/arm/mach-imx/video.c
@@ -10,7 +10,7 @@
 {
 	int i;
 	int ret;
-	char const *panel = getenv("panel");
+	char const *panel = env_get("panel");
 
 	if (!panel) {
 		for (i = 0; i < display_count; i++) {
diff --git a/arch/arm/mach-integrator/Kconfig b/arch/arm/mach-integrator/Kconfig
index 5146e51..d506ee5 100644
--- a/arch/arm/mach-integrator/Kconfig
+++ b/arch/arm/mach-integrator/Kconfig
@@ -11,13 +11,11 @@
 config ARCH_INTEGRATOR_CP
 	bool "Support Integrator/CP platform"
 	select ARCH_CINTEGRATOR
-	imply ENV_IS_IN_FLASH
 
 endchoice
 
 config ARCH_CINTEGRATOR
 	bool
-	imply ENV_IS_IN_FLASH
 
 choice
 	prompt "Integrator core module select"
diff --git a/arch/arm/mach-keystone/ddr3.c b/arch/arm/mach-keystone/ddr3.c
index 4cad6a2..b2f5414 100644
--- a/arch/arm/mach-keystone/ddr3.c
+++ b/arch/arm/mach-keystone/ddr3.c
@@ -331,7 +331,7 @@
 	int ecc_test = 0;
 	u32 value = __raw_readl(base + KS2_DDR3_ECC_INT_STATUS_OFFSET);
 
-	env = getenv("ecc_test");
+	env = env_get("ecc_test");
 	if (env)
 		ecc_test = simple_strtol(env, NULL, 0);
 
diff --git a/arch/arm/mach-keystone/keystone.c b/arch/arm/mach-keystone/keystone.c
index beb8a76..fcabfbd 100644
--- a/arch/arm/mach-keystone/keystone.c
+++ b/arch/arm/mach-keystone/keystone.c
@@ -46,7 +46,7 @@
 	char *env;
 	long ks2_debug = 0;
 
-	env = getenv("ks2_debug");
+	env = env_get("ks2_debug");
 
 	if (env)
 		ks2_debug = simple_strtol(env, NULL, 0);
diff --git a/arch/arm/mach-kirkwood/cpu.c b/arch/arm/mach-kirkwood/cpu.c
index 4c9d3fd..db2ff03 100644
--- a/arch/arm/mach-kirkwood/cpu.c
+++ b/arch/arm/mach-kirkwood/cpu.c
@@ -129,7 +129,7 @@
 static void kw_sysrst_action(void)
 {
 	int ret;
-	char *s = getenv("sysrstcmd");
+	char *s = env_get("sysrstcmd");
 
 	if (!s) {
 		debug("Error.. %s failed, check sysrstcmd\n",
@@ -153,7 +153,7 @@
 	/*
 	 * no action if sysrstdelay environment variable is not defined
 	 */
-	s = getenv("sysrstdelay");
+	s = env_get("sysrstdelay");
 	if (s == NULL)
 		return;
 
diff --git a/arch/arm/mach-mvebu/Kconfig b/arch/arm/mach-mvebu/Kconfig
index 1b12b33..01d700b 100644
--- a/arch/arm/mach-mvebu/Kconfig
+++ b/arch/arm/mach-mvebu/Kconfig
@@ -32,7 +32,6 @@
 config ARMADA_XP
 	bool
 	select ARMADA_32BIT
-	imply ENV_IS_IN_SPI_FLASH
 
 # ARMv8 SoCs...
 config ARMADA_3700
diff --git a/arch/arm/mach-omap2/boot-common.c b/arch/arm/mach-omap2/boot-common.c
index 700e6c2..26245aa 100644
--- a/arch/arm/mach-omap2/boot-common.c
+++ b/arch/arm/mach-omap2/boot-common.c
@@ -10,6 +10,7 @@
 
 #include <common.h>
 #include <ahci.h>
+#include <environment.h>
 #include <spl.h>
 #include <asm/omap_common.h>
 #include <asm/arch/omap.h>
@@ -240,8 +241,8 @@
 int fb_set_reboot_flag(void)
 {
 	printf("Setting reboot to fastboot flag ...\n");
-	setenv("dofastboot", "1");
-	saveenv();
+	env_set("dofastboot", "1");
+	env_save();
 	return 0;
 }
 #endif
diff --git a/arch/arm/mach-omap2/utils.c b/arch/arm/mach-omap2/utils.c
index 1946641..0b0bf18 100644
--- a/arch/arm/mach-omap2/utils.c
+++ b/arch/arm/mach-omap2/utils.c
@@ -40,7 +40,7 @@
 		printf("Warning: fastboot.cpu: unknown CPU rev: %u\n", cpu_rev);
 	}
 
-	setenv("fastboot.cpu", cpu);
+	env_set("fastboot.cpu", cpu);
 }
 
 static void omap_set_fastboot_secure(void)
@@ -63,18 +63,18 @@
 		printf("Warning: fastboot.secure: unknown CPU sec: %u\n", dev);
 	}
 
-	setenv("fastboot.secure", secure);
+	env_set("fastboot.secure", secure);
 }
 
 static void omap_set_fastboot_board_rev(void)
 {
 	const char *board_rev;
 
-	board_rev = getenv("board_rev");
+	board_rev = env_get("board_rev");
 	if (board_rev == NULL)
 		printf("Warning: fastboot.board_rev: unknown board revision\n");
 
-	setenv("fastboot.board_rev", board_rev);
+	env_set("fastboot.board_rev", board_rev);
 }
 
 #ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV
@@ -118,7 +118,7 @@
 		sprintf(buf, "%u", sz_kb);
 	}
 
-	setenv("fastboot.userdata_size", buf);
+	env_set("fastboot.userdata_size", buf);
 }
 #else
 static inline void omap_set_fastboot_userdata_size(void)
@@ -169,11 +169,11 @@
 
 	omap_die_id((unsigned int *)&die_id);
 
-	if (!getenv("serial#")) {
+	if (!env_get("serial#")) {
 		snprintf(serial_string, sizeof(serial_string),
 			"%08x%08x", die_id[0], die_id[3]);
 
-		setenv("serial#", serial_string);
+		env_set("serial#", serial_string);
 	}
 }
 
@@ -182,7 +182,7 @@
 	char *serial_string;
 	unsigned long long serial;
 
-	serial_string = getenv("serial#");
+	serial_string = env_get("serial#");
 
 	if (serial_string) {
 		serial = simple_strtoull(serial_string, NULL, 16);
@@ -202,7 +202,7 @@
 
 	omap_die_id((unsigned int *)&die_id);
 
-	if (!getenv("usbethaddr")) {
+	if (!env_get("usbethaddr")) {
 		/*
 		 * Create a fake MAC address from the processor ID code.
 		 * First byte is 0x02 to signify locally administered.
@@ -214,7 +214,7 @@
 		mac[4] = die_id[0] & 0xff;
 		mac[5] = (die_id[0] >> 8) & 0xff;
 
-		eth_setenv_enetaddr("usbethaddr", mac);
+		eth_env_set_enetaddr("usbethaddr", mac);
 	}
 }
 
diff --git a/arch/arm/mach-rockchip/rk3036-board.c b/arch/arm/mach-rockchip/rk3036-board.c
index 26ea23b..a3457f3 100644
--- a/arch/arm/mach-rockchip/rk3036-board.c
+++ b/arch/arm/mach-rockchip/rk3036-board.c
@@ -34,11 +34,11 @@
 	switch (boot_mode) {
 	case BOOT_FASTBOOT:
 		printf("enter fastboot!\n");
-		setenv("preboot", "setenv preboot; fastboot usb0");
+		env_set("preboot", "setenv preboot; fastboot usb0");
 		break;
 	case BOOT_UMS:
 		printf("enter UMS!\n");
-		setenv("preboot", "setenv preboot; ums mmc 0");
+		env_set("preboot", "setenv preboot; ums mmc 0");
 		break;
 	}
 }
diff --git a/arch/arm/mach-rockchip/rk322x-board.c b/arch/arm/mach-rockchip/rk322x-board.c
index b6543a5..1e79c19 100644
--- a/arch/arm/mach-rockchip/rk322x-board.c
+++ b/arch/arm/mach-rockchip/rk322x-board.c
@@ -30,11 +30,11 @@
 	switch (boot_mode) {
 	case BOOT_FASTBOOT:
 		printf("enter fastboot!\n");
-		setenv("preboot", "setenv preboot; fastboot usb0");
+		env_set("preboot", "setenv preboot; fastboot usb0");
 		break;
 	case BOOT_UMS:
 		printf("enter UMS!\n");
-		setenv("preboot", "setenv preboot; ums mmc 0");
+		env_set("preboot", "setenv preboot; ums mmc 0");
 		break;
 	}
 }
diff --git a/arch/arm/mach-rockchip/rk3288-board.c b/arch/arm/mach-rockchip/rk3288-board.c
index d5f568c..74c6cc1 100644
--- a/arch/arm/mach-rockchip/rk3288-board.c
+++ b/arch/arm/mach-rockchip/rk3288-board.c
@@ -37,11 +37,11 @@
 	switch (boot_mode) {
 	case BOOT_FASTBOOT:
 		printf("enter fastboot!\n");
-		setenv("preboot", "setenv preboot; fastboot usb0");
+		env_set("preboot", "setenv preboot; fastboot usb0");
 		break;
 	case BOOT_UMS:
 		printf("enter UMS!\n");
-		setenv("preboot", "setenv preboot; if mmc dev 0;"
+		env_set("preboot", "setenv preboot; if mmc dev 0;"
 		       "then ums mmc 0; else ums mmc 1;fi");
 		break;
 	}
diff --git a/arch/arm/mach-socfpga/misc_gen5.c b/arch/arm/mach-socfpga/misc_gen5.c
index 49b26b3..2f1da74 100644
--- a/arch/arm/mach-socfpga/misc_gen5.c
+++ b/arch/arm/mach-socfpga/misc_gen5.c
@@ -219,9 +219,9 @@
 {
 	const u32 bsel = readl(&sysmgr_regs->bootinfo) & 0x7;
 	const int fpga_id = socfpga_fpga_id(0);
-	setenv("bootmode", bsel_str[bsel].mode);
+	env_set("bootmode", bsel_str[bsel].mode);
 	if (fpga_id >= 0)
-		setenv("fpgatype", socfpga_fpga_model[fpga_id].var);
+		env_set("fpgatype", socfpga_fpga_model[fpga_id].var);
 	return socfpga_eth_reset();
 }
 #endif
diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig
index 386befb..2cd7bae 100644
--- a/arch/arm/mach-sunxi/Kconfig
+++ b/arch/arm/mach-sunxi/Kconfig
@@ -62,7 +62,6 @@
 	select SUNXI_DRAM_DW_32BIT
 	select SUNXI_GEN_SUN6I
 	select SUPPORT_SPL
-	imply ENV_IS_IN_MMC
 
 choice
 	prompt "Sunxi SoC Variant"
@@ -74,7 +73,6 @@
 	select ARM_CORTEX_CPU_IS_UP
 	select SUNXI_GEN_SUN4I
 	select SUPPORT_SPL
-	imply ENV_IS_IN_MMC
 
 config MACH_SUN5I
 	bool "sun5i (Allwinner A13)"
@@ -92,7 +90,6 @@
 	select SUNXI_GEN_SUN6I
 	select SUPPORT_SPL
 	select ARMV7_BOOT_SEC_DEFAULT if OLD_SUNXI_KERNEL_COMPAT
-	imply ENV_IS_IN_MMC
 
 config MACH_SUN7I
 	bool "sun7i (Allwinner A20)"
@@ -103,7 +100,6 @@
 	select SUNXI_GEN_SUN4I
 	select SUPPORT_SPL
 	select ARMV7_BOOT_SEC_DEFAULT if OLD_SUNXI_KERNEL_COMPAT
-	imply ENV_IS_IN_MMC
 
 config MACH_SUN8I_A23
 	bool "sun8i (Allwinner A23)"
@@ -114,7 +110,6 @@
 	select SUNXI_GEN_SUN6I
 	select SUPPORT_SPL
 	select ARMV7_BOOT_SEC_DEFAULT if OLD_SUNXI_KERNEL_COMPAT
-	imply ENV_IS_IN_MMC
 
 config MACH_SUN8I_A33
 	bool "sun8i (Allwinner A33)"
@@ -140,7 +135,6 @@
 	select ARCH_SUPPORT_PSCI
 	select MACH_SUNXI_H3_H5
 	select ARMV7_BOOT_SEC_DEFAULT if OLD_SUNXI_KERNEL_COMPAT
-	imply ENV_IS_IN_MMC
 
 config MACH_SUN8I_R40
 	bool "sun8i (Allwinner R40)"
diff --git a/arch/arm/mach-sunxi/clock_sun6i.c b/arch/arm/mach-sunxi/clock_sun6i.c
index ec5b026..870ff5b 100644
--- a/arch/arm/mach-sunxi/clock_sun6i.c
+++ b/arch/arm/mach-sunxi/clock_sun6i.c
@@ -66,11 +66,17 @@
 #ifdef CONFIG_MACH_SUNXI_H3_H5
 	struct sunxi_ccm_reg * const ccm =
 		(struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
+	struct sunxi_prcm_reg * const prcm =
+		(struct sunxi_prcm_reg *)SUNXI_PRCM_BASE;
 
 	setbits_le32(&ccm->ccu_sec_switch,
 		     CCM_SEC_SWITCH_MBUS_NONSEC |
 		     CCM_SEC_SWITCH_BUS_NONSEC |
 		     CCM_SEC_SWITCH_PLL_NONSEC);
+	setbits_le32(&prcm->prcm_sec_switch,
+		     PRCM_SEC_SWITCH_APB0_CLK_NONSEC |
+		     PRCM_SEC_SWITCH_PLL_CFG_NONSEC |
+		     PRCM_SEC_SWITCH_PWR_GATE_NONSEC);
 #endif
 }
 
diff --git a/arch/arm/mach-tegra/Kconfig b/arch/arm/mach-tegra/Kconfig
index 58085dc..51e5090 100644
--- a/arch/arm/mach-tegra/Kconfig
+++ b/arch/arm/mach-tegra/Kconfig
@@ -60,7 +60,6 @@
 	bool "Tegra 64-bit common options"
 	select ARM64
 	select TEGRA_COMMON
-	imply ENV_IS_IN_MMC
 
 choice
 	prompt "Tegra SoC select"
@@ -78,7 +77,6 @@
 	select ARM_ERRATA_743622
 	select ARM_ERRATA_751472
 	select TEGRA_ARMV7_COMMON
-	imply ENV_IS_IN_MMC
 
 config TEGRA114
 	bool "Tegra114 family"
@@ -87,7 +85,6 @@
 config TEGRA124
 	bool "Tegra124 family"
 	select TEGRA_ARMV7_COMMON
-	imply ENV_IS_IN_MMC
 	imply REGMAP
 	imply SYSCON
 
diff --git a/arch/arm/mach-tegra/board2.c b/arch/arm/mach-tegra/board2.c
index bd13796..0426b7a 100644
--- a/arch/arm/mach-tegra/board2.c
+++ b/arch/arm/mach-tegra/board2.c
@@ -214,9 +214,9 @@
 #if defined(CONFIG_TEGRA_SUPPORT_NON_SECURE)
 	if (tegra_cpu_is_non_secure()) {
 		printf("CPU is in NS mode\n");
-		setenv("cpu_ns_mode", "1");
+		env_set("cpu_ns_mode", "1");
 	} else {
-		setenv("cpu_ns_mode", "");
+		env_set("cpu_ns_mode", "");
 	}
 #endif
 	start_cpu_fan();
diff --git a/arch/arm/mach-tegra/tegra186/nvtboot_board.c b/arch/arm/mach-tegra/tegra186/nvtboot_board.c
index feb935f..b94eb42 100644
--- a/arch/arm/mach-tegra/tegra186/nvtboot_board.c
+++ b/arch/arm/mach-tegra/tegra186/nvtboot_board.c
@@ -15,7 +15,7 @@
 {
 	int ret;
 
-	ret = setenv_hex("fdt_addr", nvtboot_boot_x0);
+	ret = env_set_hex("fdt_addr", nvtboot_boot_x0);
 	if (ret) {
 		printf("Failed to set fdt_addr to point at DTB: %d\n", ret);
 		return ret;
@@ -35,7 +35,7 @@
 	const u32 *prop;
 
 	/* Already a valid address in the environment? If so, keep it */
-	if (getenv("ethaddr"))
+	if (env_get("ethaddr"))
 		return 0;
 
 	node = fdt_path_offset(nvtboot_blob, "/chosen");
@@ -49,7 +49,7 @@
 		return -ENOENT;
 	}
 
-	ret = setenv("ethaddr", (void *)prop);
+	ret = env_set("ethaddr", (void *)prop);
 	if (ret) {
 		printf("Failed to set ethaddr from nvtboot DTB: %d\n", ret);
 		return ret;
diff --git a/arch/arm/mach-uniphier/board_late_init.c b/arch/arm/mach-uniphier/board_late_init.c
index 4bfa10b..b9a2cbe 100644
--- a/arch/arm/mach-uniphier/board_late_init.c
+++ b/arch/arm/mach-uniphier/board_late_init.c
@@ -37,7 +37,7 @@
 	char dtb_name[256];
 	int buf_len = sizeof(dtb_name);
 
-	if (getenv("fdt_file"))
+	if (env_get("fdt_file"))
 		return 0;	/* do nothing if it is already set */
 
 	compat = fdt_stringlist_get(gd->fdt_blob, 0, "compatible", 0, NULL);
@@ -55,7 +55,7 @@
 
 	strncat(dtb_name, ".dtb", buf_len);
 
-	return setenv("fdt_file", dtb_name);
+	return env_set("fdt_file", dtb_name);
 }
 
 int board_late_init(void)
@@ -65,20 +65,20 @@
 	switch (uniphier_boot_device_raw()) {
 	case BOOT_DEVICE_MMC1:
 		printf("eMMC Boot");
-		setenv("bootmode", "emmcboot");
+		env_set("bootmode", "emmcboot");
 		break;
 	case BOOT_DEVICE_NAND:
 		printf("NAND Boot");
-		setenv("bootmode", "nandboot");
+		env_set("bootmode", "nandboot");
 		nand_denali_wp_disable();
 		break;
 	case BOOT_DEVICE_NOR:
 		printf("NOR Boot");
-		setenv("bootmode", "norboot");
+		env_set("bootmode", "norboot");
 		break;
 	case BOOT_DEVICE_USB:
 		printf("USB Boot");
-		setenv("bootmode", "usbboot");
+		env_set("bootmode", "usbboot");
 		break;
 	default:
 		printf("Unknown");
diff --git a/arch/arm/mach-uniphier/mmc-first-dev.c b/arch/arm/mach-uniphier/mmc-first-dev.c
index 8c45229..acc859a 100644
--- a/arch/arm/mach-uniphier/mmc-first-dev.c
+++ b/arch/arm/mach-uniphier/mmc-first-dev.c
@@ -35,7 +35,7 @@
 	if (dev < 0)
 		return CMD_RET_FAILURE;
 
-	setenv_ulong("mmc_first_dev", dev);
+	env_set_ulong("mmc_first_dev", dev);
 	return CMD_RET_SUCCESS;
 }
 
diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
index 88e7d6a..26509b7 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -10,7 +10,6 @@
 
 config MCF52x2
 	bool
-	imply ENV_IS_IN_FLASH
 
 config MCF523x
 	bool
@@ -23,7 +22,6 @@
 
 config MCF532x
 	bool
-	imply ENV_IS_IN_FLASH
 
 config MCF537x
 	bool
@@ -39,7 +37,6 @@
 
 config MCF547x_8x
 	bool
-	imply ENV_IS_IN_FLASH
 
 # processor type
 config M5208
@@ -73,7 +70,6 @@
 config M5282
 	bool
 	select MCF52x2
-	imply ENV_IS_IN_FLASH
 
 config M5307
 	bool
@@ -111,12 +107,10 @@
 config M547x
 	bool
 	select MCF547x_8x
-	imply ENV_IS_IN_FLASH
 
 config M548x
 	bool
 	select MCF547x_8x
-	imply ENV_IS_IN_FLASH
 
 choice
 	prompt "Target select"
@@ -197,12 +191,10 @@
 config TARGET_M5475EVB
 	bool "Support M5475EVB"
 	select M547x
-	imply ENV_IS_IN_FLASH
 
 config TARGET_M5485EVB
 	bool "Support M5485EVB"
 	select M548x
-	imply ENV_IS_IN_FLASH
 
 config TARGET_AMCORE
 	bool "Support AMCORE"
diff --git a/arch/m68k/lib/bootm.c b/arch/m68k/lib/bootm.c
index fa9c493..c976904 100644
--- a/arch/m68k/lib/bootm.c
+++ b/arch/m68k/lib/bootm.c
@@ -113,7 +113,8 @@
 {
 	char *s;
 
-	if ((s = getenv("clocks_in_mhz")) != NULL) {
+	s = env_get("clocks_in_mhz");
+	if (s) {
 		/* convert all clock information to MHz */
 		kbd->bi_intfreq /= 1000000L;
 		kbd->bi_busfreq /= 1000000L;
diff --git a/arch/microblaze/lib/bootm.c b/arch/microblaze/lib/bootm.c
index 2732203..0a286e8 100644
--- a/arch/microblaze/lib/bootm.c
+++ b/arch/microblaze/lib/bootm.c
@@ -27,7 +27,7 @@
 {
 	/* First parameter is mapped to $r5 for kernel boot args */
 	void	(*thekernel) (char *, ulong, ulong);
-	char	*commandline = getenv("bootargs");
+	char	*commandline = env_get("bootargs");
 	ulong	rd_data_start, rd_data_end;
 
 	/*
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index b53206b..d07b92d 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -21,7 +21,6 @@
 	select SUPPORTS_CPU_MIPS64_R1
 	select SUPPORTS_CPU_MIPS64_R2
 	select ROM_EXCEPTION_VECTORS
-	imply ENV_IS_IN_FLASH
 
 config TARGET_MALTA
 	bool "Support malta"
@@ -43,7 +42,6 @@
 	select SWAP_IO_SPACE
 	select MIPS_L1_CACHE_SHIFT_6
 	select ROM_EXCEPTION_VECTORS
-	imply ENV_IS_IN_FLASH
 
 config TARGET_VCT
 	bool "Support vct"
@@ -85,7 +83,6 @@
 	select CPU
 	select RAM
 	select SYSRESET
-	imply ENV_IS_NOWHERE
 
 config MACH_PIC32
 	bool "Support Microchip PIC32"
@@ -110,7 +107,6 @@
 	select SUPPORTS_CPU_MIPS64_R2
 	select SUPPORTS_CPU_MIPS64_R6
 	select ROM_EXCEPTION_VECTORS
-	imply ENV_IS_IN_FLASH
 
 config TARGET_XILFPGA
 	bool "Support Imagination Xilfpga"
@@ -200,7 +196,6 @@
 	bool "MIPS64 Release 2"
 	depends on SUPPORTS_CPU_MIPS64_R2
 	select 64BIT
-	imply ENV_IS_IN_FLASH
 	help
 	  Choose this option to build a kernel for release 2 through 5 of the
 	  MIPS64 architecture.
diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c
index 2b67905..5a9a281 100644
--- a/arch/mips/lib/bootm.c
+++ b/arch/mips/lib/bootm.c
@@ -80,7 +80,7 @@
 
 	linux_cmdline_init();
 
-	bootargs = getenv("bootargs");
+	bootargs = env_get("bootargs");
 	if (!bootargs)
 		return;
 
@@ -202,11 +202,11 @@
 	sprintf(env_buf, "0x%X", (uint) (gd->bd->bi_flashsize));
 	linux_env_set("flash_size", env_buf);
 
-	cp = getenv("ethaddr");
+	cp = env_get("ethaddr");
 	if (cp)
 		linux_env_set("ethaddr", cp);
 
-	cp = getenv("eth1addr");
+	cp = env_get("eth1addr");
 	if (cp)
 		linux_env_set("eth1addr", cp);
 
diff --git a/arch/nds32/lib/bootm.c b/arch/nds32/lib/bootm.c
index 21aadf2..e834329 100644
--- a/arch/nds32/lib/bootm.c
+++ b/arch/nds32/lib/bootm.c
@@ -50,7 +50,7 @@
 	void	(*theKernel)(int zero, int arch, uint params);
 
 #ifdef CONFIG_CMDLINE_TAG
-	char *commandline = getenv("bootargs");
+	char *commandline = env_get("bootargs");
 #endif
 
 	/*
@@ -64,7 +64,7 @@
 
 	theKernel = (void (*)(int, int, uint))images->ep;
 
-	s = getenv("machid");
+	s = env_get("machid");
 	if (s) {
 		machid = simple_strtoul(s, NULL, 16);
 		printf("Using machid 0x%x from environment\n", machid);
diff --git a/arch/nios2/lib/bootm.c b/arch/nios2/lib/bootm.c
index 4e5c269..00ade2c 100644
--- a/arch/nios2/lib/bootm.c
+++ b/arch/nios2/lib/bootm.c
@@ -12,7 +12,7 @@
 int do_bootm_linux(int flag, int argc, char * const argv[], bootm_headers_t *images)
 {
 	void (*kernel)(int, int, int, char *) = (void *)images->ep;
-	char *commandline = getenv("bootargs");
+	char *commandline = env_get("bootargs");
 	ulong initrd_start = images->rd_start;
 	ulong initrd_end = images->rd_end;
 	char *of_flat_tree = NULL;
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 7ac5cbf..e4b3043 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -28,7 +28,6 @@
 	bool "MPC86xx"
 	select SYS_FSL_DDR
 	select SYS_FSL_DDR_BE
-	imply ENV_IS_IN_FLASH
 	imply CMD_REGINFO
 
 config 8xx
diff --git a/arch/powerpc/cpu/mpc83xx/Kconfig b/arch/powerpc/cpu/mpc83xx/Kconfig
index c66d661..a377973 100644
--- a/arch/powerpc/cpu/mpc83xx/Kconfig
+++ b/arch/powerpc/cpu/mpc83xx/Kconfig
@@ -13,7 +13,6 @@
 
 config TARGET_SBC8349
 	bool "Support sbc8349"
-	imply ENV_IS_IN_FLASH
 
 config TARGET_VE8313
 	bool "Support ve8313"
@@ -40,7 +39,6 @@
 config TARGET_MPC832XEMDS
 	bool "Support MPC832XEMDS"
 	select BOARD_EARLY_INIT_F
-	imply ENV_IS_IN_FLASH
 
 config TARGET_MPC8349EMDS
 	bool "Support MPC8349EMDS"
@@ -52,7 +50,6 @@
 config TARGET_MPC8349ITX
 	bool "Support MPC8349ITX"
 	imply CMD_IRQ
-	imply ENV_IS_IN_FLASH
 
 config TARGET_MPC837XEMDS
 	bool "Support MPC837XEMDS"
@@ -77,13 +74,11 @@
 	bool "Support suvd3"
 	imply CMD_CRAMFS
 	imply FS_CRAMFS
-	imply ENV_IS_IN_FLASH
 
 config TARGET_TUXX1
 	bool "Support tuxx1"
 	imply CMD_CRAMFS
 	imply FS_CRAMFS
-	imply ENV_IS_IN_FLASH
 
 config TARGET_TQM834X
 	bool "Support TQM834x"
@@ -95,7 +90,6 @@
 config TARGET_STRIDER
 	bool "Support strider"
 	select SYS_FSL_ERRATUM_ESDHC111
-	imply ENV_IS_IN_FLASH
 	imply CMD_PCA953X
 
 endchoice
diff --git a/arch/powerpc/cpu/mpc85xx/Kconfig b/arch/powerpc/cpu/mpc85xx/Kconfig
index ccdf103..92187d3 100644
--- a/arch/powerpc/cpu/mpc85xx/Kconfig
+++ b/arch/powerpc/cpu/mpc85xx/Kconfig
@@ -19,7 +19,6 @@
 config TARGET_SBC8548
 	bool "Support sbc8548"
 	select ARCH_MPC8548
-	imply ENV_IS_IN_FLASH
 
 config TARGET_SOCRATES
 	bool "Support socrates"
@@ -105,7 +104,6 @@
 config TARGET_MPC8548CDS
 	bool "Support MPC8548CDS"
 	select ARCH_MPC8548
-	imply ENV_IS_IN_FLASH
 
 config TARGET_MPC8555CDS
 	bool "Support MPC8555CDS"
@@ -565,7 +563,6 @@
 	select SYS_FSL_SEC_BE
 	select SYS_FSL_SEC_COMPAT_2
 	select SYS_PPC_E500_USE_DEBUG_TLB
-	imply ENV_IS_IN_FLASH
 	imply CMD_REGINFO
 
 config ARCH_MPC8555
@@ -616,7 +613,6 @@
 	select SYS_PPC_E500_USE_DEBUG_TLB
 	select FSL_ELBC
 	imply CMD_NAND
-	imply ENV_IS_IN_FLASH
 
 config ARCH_P1010
 	bool
diff --git a/arch/powerpc/cpu/mpc85xx/cpu_init.c b/arch/powerpc/cpu/mpc85xx/cpu_init.c
index a3076d8..ea46e49 100644
--- a/arch/powerpc/cpu/mpc85xx/cpu_init.c
+++ b/arch/powerpc/cpu/mpc85xx/cpu_init.c
@@ -256,7 +256,7 @@
 	 * is not setup properly yet. Search for tdm entry in
 	 * hwconfig.
 	 */
-	ret = getenv_f("hwconfig", buffer, sizeof(buffer));
+	ret = env_get_f("hwconfig", buffer, sizeof(buffer));
 	if (ret > 0) {
 		tdm_hwconfig_enabled = hwconfig_f("tdm", buffer);
 		/* If tdm is defined in hwconfig, set law for tdm workaround */
@@ -280,7 +280,7 @@
 	cpc_corenet_t *cpc = (cpc_corenet_t *)CONFIG_SYS_FSL_CPC_ADDR;
 
 	/* Extract hwconfig from environment */
-	ret = getenv_f("hwconfig", buffer, sizeof(buffer));
+	ret = env_get_f("hwconfig", buffer, sizeof(buffer));
 	if (ret > 0) {
 		/*
 		 * If "en_cpc" is not defined in hwconfig then by default all
@@ -754,7 +754,7 @@
 	char *buf = NULL;
 	int n, res;
 
-	n = getenv_f("hwconfig", buffer, sizeof(buffer));
+	n = env_get_f("hwconfig", buffer, sizeof(buffer));
 	if (n > 0)
 		buf = buffer;
 
@@ -794,7 +794,7 @@
 #endif
 
 #if defined(CONFIG_PPC_SPINTABLE_COMPATIBLE) && defined(CONFIG_MP)
-	spin = getenv("spin_table_compat");
+	spin = env_get("spin_table_compat");
 	if (spin && (*spin == 'n'))
 		spin_table_compat = 0;
 	else
@@ -845,7 +845,7 @@
 #ifdef CONFIG_SYS_SRIO
 	srio_init();
 #ifdef CONFIG_SRIO_PCIE_BOOT_MASTER
-	char *s = getenv("bootmaster");
+	char *s = env_get("bootmaster");
 	if (s) {
 		if (!strcmp(s, "SRIO1")) {
 			srio_boot_master(1);
diff --git a/arch/powerpc/cpu/mpc85xx/fdt.c b/arch/powerpc/cpu/mpc85xx/fdt.c
index caa0bf9..297dc4a 100644
--- a/arch/powerpc/cpu/mpc85xx/fdt.c
+++ b/arch/powerpc/cpu/mpc85xx/fdt.c
@@ -92,7 +92,7 @@
 	 * Extract hwconfig from environment.
 	 * Search for tdm entry in hwconfig.
 	 */
-	ret = getenv_f("hwconfig", buffer, sizeof(buffer));
+	ret = env_get_f("hwconfig", buffer, sizeof(buffer));
 	if (ret > 0)
 		tdm_hwconfig_enabled = hwconfig_f("tdm", buffer);
 
@@ -580,7 +580,7 @@
 		return;
 
 	/* Get MAC address for the l2switch from "l2switchaddr"*/
-	if (!eth_getenv_enetaddr("l2switchaddr", l2swaddr)) {
+	if (!eth_env_get_enetaddr("l2switchaddr", l2swaddr)) {
 		printf("Warning: MAC address for l2switch not found\n");
 		memset(l2swaddr, 0, sizeof(l2swaddr));
 	}
diff --git a/arch/powerpc/cpu/mpc85xx/fsl_corenet_serdes.c b/arch/powerpc/cpu/mpc85xx/fsl_corenet_serdes.c
index 1bc0c64..79d6544 100644
--- a/arch/powerpc/cpu/mpc85xx/fsl_corenet_serdes.c
+++ b/arch/powerpc/cpu/mpc85xx/fsl_corenet_serdes.c
@@ -514,7 +514,7 @@
 	 * Extract hwconfig from environment since we have not properly setup
 	 * the environment but need it for ddr config params
 	 */
-	if (getenv_f("hwconfig", buffer, sizeof(buffer)) > 0)
+	if (env_get_f("hwconfig", buffer, sizeof(buffer)) > 0)
 		buf = buffer;
 #endif
 	if (serdes_prtcl_map & (1 << NONE))
diff --git a/arch/powerpc/cpu/mpc85xx/mp.c b/arch/powerpc/cpu/mpc85xx/mp.c
index 0addf84..2ea9f5c 100644
--- a/arch/powerpc/cpu/mpc85xx/mp.c
+++ b/arch/powerpc/cpu/mpc85xx/mp.c
@@ -31,7 +31,7 @@
 int hold_cores_in_reset(int verbose)
 {
 	/* Default to no, overridden by 'y', 'yes', 'Y', 'Yes', or '1' */
-	if (getenv_yesno("mp_holdoff") == 1) {
+	if (env_get_yesno("mp_holdoff") == 1) {
 		if (verbose) {
 			puts("Secondary cores are being held in reset.\n");
 			puts("See 'mp_holdoff' environment variable\n");
diff --git a/arch/powerpc/cpu/mpc86xx/Kconfig b/arch/powerpc/cpu/mpc86xx/Kconfig
index fe56efd..2cc180d 100644
--- a/arch/powerpc/cpu/mpc86xx/Kconfig
+++ b/arch/powerpc/cpu/mpc86xx/Kconfig
@@ -40,7 +40,6 @@
 	select FSL_LAW
 	select SYS_FSL_HAS_DDR1
 	select SYS_FSL_HAS_DDR2
-	imply ENV_IS_IN_FLASH
 
 config FSL_LAW
 	bool
diff --git a/arch/powerpc/lib/bootm.c b/arch/powerpc/lib/bootm.c
index 0e20402..b9ae24d 100644
--- a/arch/powerpc/lib/bootm.c
+++ b/arch/powerpc/lib/bootm.c
@@ -86,7 +86,7 @@
 		debug ("   Booting using OF flat tree...\n");
 		WATCHDOG_RESET ();
 		(*kernel) ((bd_t *)of_flat_tree, 0, 0, EPAPR_MAGIC,
-			   getenv_bootm_mapsize(), 0, 0);
+			   env_get_bootm_mapsize(), 0, 0);
 		/* does not return */
 	} else
 #endif
@@ -121,8 +121,8 @@
 	phys_size_t bootm_size;
 	ulong size, sp, bootmap_base;
 
-	bootmap_base = getenv_bootm_low();
-	bootm_size = getenv_bootm_size();
+	bootmap_base = env_get_bootm_low();
+	bootm_size = env_get_bootm_size();
 
 #ifdef DEBUG
 	if (((u64)bootmap_base + bootm_size) >
@@ -275,7 +275,8 @@
 {
 	char	*s;
 
-	if ((s = getenv ("clocks_in_mhz")) != NULL) {
+	s = env_get("clocks_in_mhz");
+	if (s) {
 		/* convert all clock information to MHz */
 		kbd->bi_intfreq /= 1000000L;
 		kbd->bi_busfreq /= 1000000L;
@@ -339,6 +340,6 @@
 
 	((void (*)(void *, ulong, ulong, ulong,
 		ulong, ulong, ulong))images->ep)(images->ft_addr,
-		0, 0, EPAPR_MAGIC, getenv_bootm_mapsize(), 0, 0);
+		0, 0, EPAPR_MAGIC, env_get_bootm_mapsize(), 0, 0);
 }
 #endif
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index fa32df0..d20761e 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -3,16 +3,13 @@
 
 config CPU_SH2
 	bool
-	imply ENV_IS_IN_FLASH
 
 config CPU_SH2A
 	bool
 	select CPU_SH2
-	imply ENV_IS_IN_FLASH
 
 config CPU_SH3
 	bool
-	imply ENV_IS_IN_FLASH
 
 config CPU_SH4
 	bool
diff --git a/arch/sh/cpu/u-boot.lds b/arch/sh/cpu/u-boot.lds
index bbf9ff4..7fc91bc 100644
--- a/arch/sh/cpu/u-boot.lds
+++ b/arch/sh/cpu/u-boot.lds
@@ -33,9 +33,9 @@
 		KEEP(CONFIG_BOARDDIR/lowlevel_init.o	(.text .spiboot1.text))
 		KEEP(*(.spiboot2.text))
 		. = ALIGN(8192);
-		common/env_embedded.o	(.ppcenv)
+		env/embedded.o	(.ppcenv)
 		. = ALIGN(8192);
-		common/env_embedded.o	(.ppcenvr)
+		env/embedded.o	(.ppcenvr)
 		. = ALIGN(8192);
 		*(.text)
 		. = ALIGN(4);
diff --git a/arch/sh/lib/bootm.c b/arch/sh/lib/bootm.c
index 8a0010b..09fbd5e 100644
--- a/arch/sh/lib/bootm.c
+++ b/arch/sh/lib/bootm.c
@@ -61,7 +61,7 @@
 	char *cmdline = (char *)param + COMMAND_LINE;
 	/* PAGE_SIZE */
 	unsigned long size = images->ep - (unsigned long)param;
-	char *bootargs = getenv("bootargs");
+	char *bootargs = env_get("bootargs");
 
 	/*
 	 * allow the PREP bootm subcommand, it is required for bootm to work
diff --git a/arch/sh/lib/zimageboot.c b/arch/sh/lib/zimageboot.c
index 3fea5f5..cd4abba 100644
--- a/arch/sh/lib/zimageboot.c
+++ b/arch/sh/lib/zimageboot.c
@@ -42,7 +42,7 @@
 
 	/* Linux kernel command line */
 	cmdline = (char *)param + COMMAND_LINE;
-	bootargs = getenv("bootargs");
+	bootargs = env_get("bootargs");
 
 	/* Clear zero page */
 	/* cppcheck-suppress nullPointer */
diff --git a/arch/x86/cpu/baytrail/Kconfig b/arch/x86/cpu/baytrail/Kconfig
index 9374c12..75dbbc2 100644
--- a/arch/x86/cpu/baytrail/Kconfig
+++ b/arch/x86/cpu/baytrail/Kconfig
@@ -10,7 +10,6 @@
 	select ARCH_MISC_INIT if !EFI
 	imply HAVE_INTEL_ME if !EFI
 	imply ENABLE_MRC_CACHE
-	imply ENV_IS_IN_SPI_FLASH
 	imply AHCI_PCI
 	imply ICH_SPI
 	imply INTEL_ICH6_GPIO
diff --git a/arch/x86/cpu/broadwell/Kconfig b/arch/x86/cpu/broadwell/Kconfig
index b421f18..bc2dba2 100644
--- a/arch/x86/cpu/broadwell/Kconfig
+++ b/arch/x86/cpu/broadwell/Kconfig
@@ -9,7 +9,6 @@
 	select ARCH_EARLY_INIT_R
 	imply HAVE_INTEL_ME
 	imply ENABLE_MRC_CACHE
-	imply ENV_IS_IN_SPI_FLASH
 	imply AHCI_PCI
 	imply ICH_SPI
 	imply INTEL_BROADWELL_GPIO
diff --git a/arch/x86/cpu/coreboot/Kconfig b/arch/x86/cpu/coreboot/Kconfig
index d4e0587..60eb45f 100644
--- a/arch/x86/cpu/coreboot/Kconfig
+++ b/arch/x86/cpu/coreboot/Kconfig
@@ -3,7 +3,6 @@
 config SYS_COREBOOT
 	bool
 	default y
-	imply ENV_IS_NOWHERE
 	imply AHCI_PCI
 	imply E1000
 	imply ICH_SPI
diff --git a/arch/x86/cpu/ivybridge/Kconfig b/arch/x86/cpu/ivybridge/Kconfig
index 00f99d6..c214ea0 100644
--- a/arch/x86/cpu/ivybridge/Kconfig
+++ b/arch/x86/cpu/ivybridge/Kconfig
@@ -10,7 +10,6 @@
 	select CACHE_MRC_BIN if HAVE_MRC
 	imply HAVE_INTEL_ME
 	imply ENABLE_MRC_CACHE
-	imply ENV_IS_IN_SPI_FLASH
 	imply AHCI_PCI
 	imply ICH_SPI
 	imply INTEL_ICH6_GPIO
diff --git a/arch/x86/cpu/qemu/Kconfig b/arch/x86/cpu/qemu/Kconfig
index fdf5ae3..da37812 100644
--- a/arch/x86/cpu/qemu/Kconfig
+++ b/arch/x86/cpu/qemu/Kconfig
@@ -7,7 +7,6 @@
 config QEMU
 	bool
 	select ARCH_EARLY_INIT_R
-	imply ENV_IS_NOWHERE
 	imply AHCI_PCI
 	imply E1000
 	imply SYS_NS16550
diff --git a/arch/x86/cpu/quark/Kconfig b/arch/x86/cpu/quark/Kconfig
index 7ec46e9..0ed7248 100644
--- a/arch/x86/cpu/quark/Kconfig
+++ b/arch/x86/cpu/quark/Kconfig
@@ -10,7 +10,6 @@
 	select ARCH_EARLY_INIT_R
 	select ARCH_MISC_INIT
 	imply ENABLE_MRC_CACHE
-	imply ENV_IS_IN_SPI_FLASH
 	imply ETH_DESIGNWARE
 	imply ICH_SPI
 	imply INTEL_ICH6_GPIO
diff --git a/arch/x86/cpu/queensbay/Kconfig b/arch/x86/cpu/queensbay/Kconfig
index d1b04c9..835de85 100644
--- a/arch/x86/cpu/queensbay/Kconfig
+++ b/arch/x86/cpu/queensbay/Kconfig
@@ -9,7 +9,6 @@
 	select HAVE_FSP
 	select HAVE_CMC
 	select ARCH_EARLY_INIT_R
-	imply ENV_IS_IN_SPI_FLASH
 	imply AHCI_PCI
 	imply ICH_SPI
 	imply INTEL_ICH6_GPIO
diff --git a/arch/x86/lib/zimage.c b/arch/x86/lib/zimage.c
index aafbeb0..00172dc 100644
--- a/arch/x86/lib/zimage.c
+++ b/arch/x86/lib/zimage.c
@@ -48,15 +48,15 @@
 
 	command_line[0] = '\0';
 
-	env_command_line =  getenv("bootargs");
+	env_command_line =  env_get("bootargs");
 
 	/* set console= argument if we use a serial console */
 	if (!strstr(env_command_line, "console=")) {
-		if (!strcmp(getenv("stdout"), "serial")) {
+		if (!strcmp(env_get("stdout"), "serial")) {
 
 			/* We seem to use serial console */
 			sprintf(command_line, "console=ttyS0,%s ",
-				getenv("baudrate"));
+				env_get("baudrate"));
 		}
 	}
 
@@ -285,7 +285,7 @@
 		/* argv[1] holds the address of the bzImage */
 		s = argv[1];
 	} else {
-		s = getenv("fileaddr");
+		s = env_get("fileaddr");
 	}
 
 	if (s)
diff --git a/arch/xtensa/lib/bootm.c b/arch/xtensa/lib/bootm.c
index 1604bb9..16961ac 100644
--- a/arch/xtensa/lib/bootm.c
+++ b/arch/xtensa/lib/bootm.c
@@ -136,7 +136,7 @@
 {
 	struct bp_tag *params, *params_start;
 	ulong initrd_start, initrd_end;
-	char *commandline = getenv("bootargs");
+	char *commandline = env_get("bootargs");
 
 	if (!(flag & (BOOTM_STATE_OS_GO | BOOTM_STATE_OS_FAKE_GO)))
 		return 0;
diff --git a/board/Arcturus/ucp1020/cmd_arc.c b/board/Arcturus/ucp1020/cmd_arc.c
index fa6b485..0d3ac88 100644
--- a/board/Arcturus/ucp1020/cmd_arc.c
+++ b/board/Arcturus/ucp1020/cmd_arc.c
@@ -138,7 +138,7 @@
 			printf("\t<not found>\n");
 		} else {
 			printf("\t%s\n", smac[3]);
-			setenv("SERIAL", smac[3]);
+			env_set("SERIAL", smac[3]);
 		}
 	}
 
@@ -149,10 +149,10 @@
 	if (smac[2][0] == 0xFF) {
 		printf("\t<not found>\n");
 	} else {
-		char *ret = getenv("ethaddr");
+		char *ret = env_get("ethaddr");
 
 		if (strcmp(ret, __stringify(CONFIG_ETHADDR)) == 0) {
-			setenv("ethaddr", smac[2]);
+			env_set("ethaddr", smac[2]);
 			printf("\t%s (factory)\n", smac[2]);
 		} else {
 			printf("\t%s\n", ret);
@@ -160,8 +160,8 @@
 	}
 
 	if (strcmp(smac[1], "00:00:00:00:00:00") == 0) {
-		setenv("eth1addr", smac[2]);
-		setenv("eth2addr", smac[2]);
+		env_set("eth1addr", smac[2]);
+		env_set("eth2addr", smac[2]);
 		return 0;
 	}
 
@@ -169,10 +169,10 @@
 	if (smac[1][0] == 0xFF) {
 		printf("\t<not found>\n");
 	} else {
-		char *ret = getenv("eth1addr");
+		char *ret = env_get("eth1addr");
 
 		if (strcmp(ret, __stringify(CONFIG_ETH1ADDR)) == 0) {
-			setenv("eth1addr", smac[1]);
+			env_set("eth1addr", smac[1]);
 			printf("\t%s (factory)\n", smac[1]);
 		} else {
 			printf("\t%s\n", ret);
@@ -180,7 +180,7 @@
 	}
 
 	if (strcmp(smac[0], "00:00:00:00:00:00") == 0) {
-		setenv("eth2addr", smac[1]);
+		env_set("eth2addr", smac[1]);
 		return 0;
 	}
 
@@ -188,10 +188,10 @@
 	if (smac[0][0] == 0xFF) {
 		printf("\t<not found>\n");
 	} else {
-		char *ret = getenv("eth2addr");
+		char *ret = env_get("eth2addr");
 
 		if (strcmp(ret, __stringify(CONFIG_ETH2ADDR)) == 0) {
-			setenv("eth2addr", smac[0]);
+			env_set("eth2addr", smac[0]);
 			printf("\t%s (factory)\n", smac[0]);
 		} else {
 			printf("\t%s\n", ret);
diff --git a/board/Arcturus/ucp1020/spl.c b/board/Arcturus/ucp1020/spl.c
index cd484fc..b5e7a5d 100644
--- a/board/Arcturus/ucp1020/spl.c
+++ b/board/Arcturus/ucp1020/spl.c
@@ -10,6 +10,7 @@
 
 #include <common.h>
 #include <console.h>
+#include <environment.h>
 #include <ns16550.h>
 #include <malloc.h>
 #include <mmc.h>
@@ -99,7 +100,7 @@
 	nand_spl_load_image(CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE,
 			    (uchar *)CONFIG_ENV_ADDR);
 	gd->env_addr = (ulong)(CONFIG_ENV_ADDR);
-	gd->env_valid = 1;
+	gd->env_valid = ENV_VALID;
 #else
 	env_relocate();
 #endif
diff --git a/board/Arcturus/ucp1020/ucp1020.c b/board/Arcturus/ucp1020/ucp1020.c
index 0d086e8..3f786a2 100644
--- a/board/Arcturus/ucp1020/ucp1020.c
+++ b/board/Arcturus/ucp1020/ucp1020.c
@@ -64,7 +64,7 @@
 
 	for (i = 0; i < GPIO_MAX_NUM; i++) {
 		sprintf(envname, "GPIO%d", i);
-		val = getenv(envname);
+		val = env_get(envname);
 		if (val) {
 			char direction = toupper(val[0]);
 			char level = toupper(val[1]);
@@ -82,7 +82,7 @@
 		}
 	}
 
-	val = getenv("PCIE_OFF");
+	val = env_get("PCIE_OFF");
 	if (val) {
 		gpio_direction_input(GPIO_PCIE1_EN);
 		gpio_direction_input(GPIO_PCIE2_EN);
@@ -91,7 +91,7 @@
 		gpio_direction_output(GPIO_PCIE2_EN, 1);
 	}
 
-	val = getenv("SDHC_CDWP_OFF");
+	val = env_get("SDHC_CDWP_OFF");
 	if (!val) {
 		ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
 
@@ -214,7 +214,7 @@
 	else
 		printf("NCT72(0x%x): ready\n", id2);
 
-	kval = getenv("kernelargs");
+	kval = env_get("kernelargs");
 
 	mmc = find_mmc_device(0);
 	if (mmc)
@@ -230,21 +230,21 @@
 				strcat(newkernelargs, mmckargs);
 				strcat(newkernelargs, " ");
 				strcat(newkernelargs, &tmp[n]);
-				setenv("kernelargs", newkernelargs);
+				env_set("kernelargs", newkernelargs);
 			} else {
-				setenv("kernelargs", mmckargs);
+				env_set("kernelargs", mmckargs);
 			}
 		}
 	get_arc_info();
 
 	if (kval) {
-		sval = getenv("SERIAL");
+		sval = env_get("SERIAL");
 		if (sval) {
 			strcpy(newkernelargs, "SN=");
 			strcat(newkernelargs, sval);
 			strcat(newkernelargs, " ");
 			strcat(newkernelargs, kval);
-			setenv("kernelargs", newkernelargs);
+			env_set("kernelargs", newkernelargs);
 		}
 	} else {
 		printf("Error reading kernelargs env variable!\n");
@@ -307,8 +307,8 @@
 
 	ft_cpu_setup(blob, bd);
 
-	base = getenv_bootm_low();
-	size = getenv_bootm_size();
+	base = env_get_bootm_low();
+	size = env_get_bootm_size();
 
 	fdt_fixup_memory(blob, (u64)base, (u64)size);
 
diff --git a/board/Barix/ipam390/ipam390.c b/board/Barix/ipam390/ipam390.c
index 3a58402..d203429 100644
--- a/board/Barix/ipam390/ipam390.c
+++ b/board/Barix/ipam390/ipam390.c
@@ -157,7 +157,7 @@
 	u32 maxcpuclk = CONFIG_DA850_EVM_MAX_CPU_CLK;
 	u32 rev = 0;
 
-	s = getenv("maxcpuclk");
+	s = env_get("maxcpuclk");
 	if (s)
 		maxcpuclk = simple_strtoul(s, NULL, 10);
 
diff --git a/board/BuR/brppt1/board.c b/board/BuR/brppt1/board.c
index a227221..6083479 100644
--- a/board/BuR/brppt1/board.c
+++ b/board/BuR/brppt1/board.c
@@ -167,7 +167,7 @@
 		lcd_position_cursor(1, 8);
 		lcd_puts(
 		"switching to network-console ...       ");
-		setenv("bootcmd", "run netconsole");
+		env_set("bootcmd", "run netconsole");
 	}
 	return 0;
 }
diff --git a/board/BuR/brxre1/board.c b/board/BuR/brxre1/board.c
index f4bfa41..ca08f3c 100644
--- a/board/BuR/brxre1/board.c
+++ b/board/BuR/brxre1/board.c
@@ -203,7 +203,7 @@
 				lcd_position_cursor(1, 8);
 				lcd_puts(
 				"switching to network-console ...       ");
-				setenv("bootcmd", "run netconsole");
+				env_set("bootcmd", "run netconsole");
 				cnt = 4;
 				break;
 			} else if (!gpio_get_value(ESC_KEY) &&
@@ -211,7 +211,7 @@
 				lcd_position_cursor(1, 8);
 				lcd_puts(
 				"starting u-boot script from USB ...    ");
-				setenv("bootcmd", "run usbscript");
+				env_set("bootcmd", "run usbscript");
 				cnt = 4;
 				break;
 			} else if ((!gpio_get_value(ESC_KEY) &&
@@ -221,7 +221,7 @@
 				lcd_position_cursor(1, 8);
 				lcd_puts(
 				"starting script from network ...      ");
-				setenv("bootcmd", "run netscript");
+				env_set("bootcmd", "run netscript");
 				cnt = 4;
 				break;
 			} else if (!gpio_get_value(ESC_KEY)) {
@@ -232,19 +232,19 @@
 		lcd_position_cursor(1, 8);
 		lcd_puts(
 		"starting vxworks from network ...      ");
-		setenv("bootcmd", "run netboot");
+		env_set("bootcmd", "run netboot");
 		cnt = 4;
 	} else if (scratchreg == 0xCD) {
 		lcd_position_cursor(1, 8);
 		lcd_puts(
 		"starting script from network ...      ");
-		setenv("bootcmd", "run netscript");
+		env_set("bootcmd", "run netscript");
 		cnt = 4;
 	} else if (scratchreg == 0xCE) {
 		lcd_position_cursor(1, 8);
 		lcd_puts(
 		"starting AR from eMMC ...             ");
-		setenv("bootcmd", "run mmcboot");
+		env_set("bootcmd", "run mmcboot");
 		cnt = 4;
 	}
 
@@ -252,7 +252,7 @@
 	switch (cnt) {
 	case 0:
 		lcd_puts("entering BOOT-mode.                    ");
-		setenv("bootcmd", "run defaultAR");
+		env_set("bootcmd", "run defaultAR");
 		buf = 0x0000;
 		break;
 	case 1:
@@ -282,10 +282,10 @@
 	snprintf(othbootargs, sizeof(othbootargs),
 		 "u=vxWorksFTP pw=vxWorks o=0x%08x;0x%08x;0x%08x;0x%08x",
 		 (unsigned int) gd->fb_base-0x20,
-		 (u32)getenv_ulong("vx_memtop", 16, gd->fb_base-0x20),
-		 (u32)getenv_ulong("vx_romfsbase", 16, 0),
-		 (u32)getenv_ulong("vx_romfssize", 16, 0));
-	setenv("othbootargs", othbootargs);
+		 (u32)env_get_ulong("vx_memtop", 16, gd->fb_base-0x20),
+		 (u32)env_get_ulong("vx_romfsbase", 16, 0),
+		 (u32)env_get_ulong("vx_romfssize", 16, 0));
+	env_set("othbootargs", othbootargs);
 	/*
 	 * reset VBAR registers to its reset location, VxWorks 6.9.3.2 does
 	 * expect that vectors are there, original u-boot moves them to _start
diff --git a/board/BuR/common/common.c b/board/BuR/common/common.c
index c3a56db..c1cd010 100644
--- a/board/BuR/common/common.c
+++ b/board/BuR/common/common.c
@@ -58,9 +58,9 @@
 	unsigned int bright = FDTPROP(PATHINF, "brightdef");
 	unsigned int pwmfrq = FDTPROP(PATHINF, "brightfdim");
 #else
-	unsigned int driver = getenv_ulong("ds1_bright_drv", 16, 0UL);
-	unsigned int bright = getenv_ulong("ds1_bright_def", 10, 50);
-	unsigned int pwmfrq = getenv_ulong("ds1_pwmfreq", 10, ~0UL);
+	unsigned int driver = env_get_ulong("ds1_bright_drv", 16, 0UL);
+	unsigned int bright = env_get_ulong("ds1_bright_def", 10, 50);
+	unsigned int pwmfrq = env_get_ulong("ds1_pwmfreq", 10, ~0UL);
 #endif
 	unsigned int tmp;
 	struct gptimer *timerhw;
@@ -184,22 +184,22 @@
 		puts("no 'factory-settings / rotation' in dtb!\n");
 	}
 	snprintf(buf, sizeof(buf), "fbcon=rotate:%d", panel_info.vl_rot);
-	setenv("optargs_rot", buf);
+	env_set("optargs_rot", buf);
 #else
-	pnltmp.hactive = getenv_ulong("ds1_hactive", 10, ~0UL);
-	pnltmp.vactive = getenv_ulong("ds1_vactive", 10, ~0UL);
-	pnltmp.bpp = getenv_ulong("ds1_bpp", 10, ~0UL);
-	pnltmp.hfp = getenv_ulong("ds1_hfp", 10, ~0UL);
-	pnltmp.hbp = getenv_ulong("ds1_hbp", 10, ~0UL);
-	pnltmp.hsw = getenv_ulong("ds1_hsw", 10, ~0UL);
-	pnltmp.vfp = getenv_ulong("ds1_vfp", 10, ~0UL);
-	pnltmp.vbp = getenv_ulong("ds1_vbp", 10, ~0UL);
-	pnltmp.vsw = getenv_ulong("ds1_vsw", 10, ~0UL);
-	pnltmp.pxl_clk_div = getenv_ulong("ds1_pxlclkdiv", 10, ~0UL);
-	pnltmp.pol = getenv_ulong("ds1_pol", 16, ~0UL);
-	pnltmp.pup_delay = getenv_ulong("ds1_pupdelay", 10, ~0UL);
-	pnltmp.pon_delay = getenv_ulong("ds1_tondelay", 10, ~0UL);
-	panel_info.vl_rot = getenv_ulong("ds1_rotation", 10, 0);
+	pnltmp.hactive = env_get_ulong("ds1_hactive", 10, ~0UL);
+	pnltmp.vactive = env_get_ulong("ds1_vactive", 10, ~0UL);
+	pnltmp.bpp = env_get_ulong("ds1_bpp", 10, ~0UL);
+	pnltmp.hfp = env_get_ulong("ds1_hfp", 10, ~0UL);
+	pnltmp.hbp = env_get_ulong("ds1_hbp", 10, ~0UL);
+	pnltmp.hsw = env_get_ulong("ds1_hsw", 10, ~0UL);
+	pnltmp.vfp = env_get_ulong("ds1_vfp", 10, ~0UL);
+	pnltmp.vbp = env_get_ulong("ds1_vbp", 10, ~0UL);
+	pnltmp.vsw = env_get_ulong("ds1_vsw", 10, ~0UL);
+	pnltmp.pxl_clk_div = env_get_ulong("ds1_pxlclkdiv", 10, ~0UL);
+	pnltmp.pol = env_get_ulong("ds1_pol", 16, ~0UL);
+	pnltmp.pup_delay = env_get_ulong("ds1_pupdelay", 10, ~0UL);
+	pnltmp.pon_delay = env_get_ulong("ds1_tondelay", 10, ~0UL);
+	panel_info.vl_rot = env_get_ulong("ds1_rotation", 10, 0);
 #endif
 	if (
 	   ~0UL == (pnltmp.hactive) ||
@@ -251,7 +251,7 @@
 {
 	int rc;
 	loff_t dtbsize;
-	u32 dtbaddr = getenv_ulong("dtbaddr", 16, 0UL);
+	u32 dtbaddr = env_get_ulong("dtbaddr", 16, 0UL);
 
 	if (dtbaddr == 0) {
 		printf("%s: don't have a valid <dtbaddr> in env!\n", __func__);
@@ -263,9 +263,9 @@
 				(size_t *)&dtbsize,
 				NULL, 0x20000, (u_char *)dtbaddr);
 #else
-	char *dtbname = getenv("dtb");
-	char *dtbdev = getenv("dtbdev");
-	char *dtbpart = getenv("dtbpart");
+	char *dtbname = env_get("dtb");
+	char *dtbdev = env_get("dtbdev");
+	char *dtbpart = env_get("dtbpart");
 	if (!dtbdev || !dtbpart || !dtbname) {
 		printf("%s: <dtbdev>/<dtbpart>/<dtb> missing.\n", __func__);
 		return -1;
@@ -375,7 +375,7 @@
 	 * if no simplefb is requested through environment, we don't set up
 	 * one, instead we turn off backlight.
 	 */
-	if (getenv_ulong("simplefb", 10, 0) == 0) {
+	if (env_get_ulong("simplefb", 10, 0) == 0) {
 		lcdbacklight(0);
 		return 0;
 	}
@@ -405,11 +405,11 @@
 				       char *name, char *altname,
 				       char *suffix)
 {
-	char *envval = getenv(name);
+	char *envval = env_get(name);
 	if (0 != envval) {
 		lcd_printf("%s %s %s", prefix, envval, suffix);
 	} else if (0 != altname) {
-		envval = getenv(altname);
+		envval = env_get(altname);
 		if (0 != envval)
 			lcd_printf("%s %s %s", prefix, envval, suffix);
 	} else {
@@ -447,7 +447,7 @@
 	}
 	pin = FDTPROP(PATHINF, "pwrpin");
 #else
-	pin = getenv_ulong("ds1_pwr", 16, ~0UL);
+	pin = env_get_ulong("ds1_pwr", 16, ~0UL);
 #endif
 	if (pin == ~0UL) {
 		puts("no pwrpin in dtb/env, cannot powerup display!\n");
@@ -657,7 +657,7 @@
 	mac_addr[4] = mac_lo & 0xFF;
 	mac_addr[5] = (mac_lo & 0xFF00) >> 8;
 
-	if (!getenv("ethaddr")) {
+	if (!env_get("ethaddr")) {
 		#if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_USE_FDT)
 		printf("<ethaddr> not set. trying DTB ... ");
 		mac = dtbmacaddr(0);
@@ -670,7 +670,7 @@
 
 		if (mac) {
 			printf("using: %pM on ", mac);
-			eth_setenv_enetaddr("ethaddr", (const u8 *)mac);
+			eth_env_set_enetaddr("ethaddr", (const u8 *)mac);
 		}
 	}
 	writel(MII_MODE_ENABLE, &cdev->miisel);
diff --git a/board/BuS/eb_cpu5282/eb_cpu5282.c b/board/BuS/eb_cpu5282/eb_cpu5282.c
index a00a83a..d23b9f3 100644
--- a/board/BuS/eb_cpu5282/eb_cpu5282.c
+++ b/board/BuS/eb_cpu5282/eb_cpu5282.c
@@ -139,7 +139,7 @@
 	int enable;
 
 	enable = 1;
-	s = getenv("watchdog");
+	s = env_get("watchdog");
 	if (s != NULL)
 		if ((strncmp(s, "off", 3) == 0) || (strncmp(s, "0", 1) == 0))
 			enable = 0;
@@ -191,13 +191,13 @@
 	unsigned long splash;
 #endif
 	printf("Init Video as ");
-	s = getenv("displaywidth");
+	s = env_get("displaywidth");
 	if (s != NULL)
 		display_width = simple_strtoul(s, NULL, 10);
 	else
 		display_width = 256;
 
-	s = getenv("displayheight");
+	s = env_get("displayheight");
 	if (s != NULL)
 		display_height = simple_strtoul(s, NULL, 10);
 	else
@@ -211,7 +211,7 @@
 	vcxk_init(display_width, display_height);
 
 #ifdef CONFIG_SPLASH_SCREEN
-	s = getenv("splashimage");
+	s = env_get("splashimage");
 	if (s != NULL) {
 		splash = simple_strtoul(s, NULL, 16);
 		vcxk_acknowledge_wait();
diff --git a/board/CZ.NIC/turris_omnia/turris_omnia.c b/board/CZ.NIC/turris_omnia/turris_omnia.c
index a427509..af66837 100644
--- a/board/CZ.NIC/turris_omnia/turris_omnia.c
+++ b/board/CZ.NIC/turris_omnia/turris_omnia.c
@@ -285,7 +285,7 @@
 		puts("EEPROM regdomain read failed.\n");
 
 	printf("Regdomain set to %s\n", rd);
-	return setenv("regdomain", rd);
+	return env_set("regdomain", rd);
 }
 #endif
 
@@ -515,17 +515,17 @@
 	mac[5] = mac1[3];
 
 	if (is_valid_ethaddr(mac))
-		eth_setenv_enetaddr("ethaddr", mac);
+		eth_env_set_enetaddr("ethaddr", mac);
 
 	increment_mac(mac);
 
 	if (is_valid_ethaddr(mac))
-		eth_setenv_enetaddr("eth1addr", mac);
+		eth_env_set_enetaddr("eth1addr", mac);
 
 	increment_mac(mac);
 
 	if (is_valid_ethaddr(mac))
-		eth_setenv_enetaddr("eth2addr", mac);
+		eth_env_set_enetaddr("eth2addr", mac);
 
 out:
 #endif
diff --git a/board/CarMediaLab/flea3/flea3.c b/board/CarMediaLab/flea3/flea3.c
index 3cd4dc9..5e75eb0 100644
--- a/board/CarMediaLab/flea3/flea3.c
+++ b/board/CarMediaLab/flea3/flea3.c
@@ -211,7 +211,7 @@
 		{ "mxc_nand", MTD_DEV_TYPE_NAND, }, /* NAND flash */
 	};
 
-	if (getenv("fdt_noauto")) {
+	if (env_get("fdt_noauto")) {
 		puts("   Skiping ft_board_setup (fdt_noauto defined)\n");
 		return 0;
 	}
diff --git a/board/LaCie/net2big_v2/net2big_v2.c b/board/LaCie/net2big_v2/net2big_v2.c
index 2e6e9ef..f639a37 100644
--- a/board/LaCie/net2big_v2/net2big_v2.c
+++ b/board/LaCie/net2big_v2/net2big_v2.c
@@ -221,10 +221,10 @@
 {
 	init_fan();
 #if defined(CONFIG_CMD_I2C) && defined(CONFIG_SYS_I2C_EEPROM_ADDR)
-	if (!getenv("ethaddr")) {
+	if (!env_get("ethaddr")) {
 		uchar mac[6];
 		if (lacie_read_mac_address(mac) == 0)
-			eth_setenv_enetaddr("ethaddr", mac);
+			eth_env_set_enetaddr("ethaddr", mac);
 	}
 #endif
 	init_leds();
diff --git a/board/LaCie/netspace_v2/netspace_v2.c b/board/LaCie/netspace_v2/netspace_v2.c
index 16d6947..52f3664 100644
--- a/board/LaCie/netspace_v2/netspace_v2.c
+++ b/board/LaCie/netspace_v2/netspace_v2.c
@@ -83,10 +83,10 @@
 int misc_init_r(void)
 {
 #if defined(CONFIG_CMD_I2C) && defined(CONFIG_SYS_I2C_EEPROM_ADDR)
-	if (!getenv("ethaddr")) {
+	if (!env_get("ethaddr")) {
 		uchar mac[6];
 		if (lacie_read_mac_address(mac) == 0)
-			eth_setenv_enetaddr("ethaddr", mac);
+			eth_env_set_enetaddr("ethaddr", mac);
 	}
 #endif
 	return 0;
diff --git a/board/Synology/ds414/cmd_syno.c b/board/Synology/ds414/cmd_syno.c
index 20544e2..6313882 100644
--- a/board/Synology/ds414/cmd_syno.c
+++ b/board/Synology/ds414/cmd_syno.c
@@ -81,7 +81,7 @@
 		         ethaddr[0], ethaddr[1], ethaddr[2],
 			 ethaddr[3], ethaddr[4], ethaddr[5]);
 		printf("parsed %s = %s\n", var, val);
-		setenv(var, val);
+		env_set(var, val);
 	}
 	if (!strncmp(buf + 32, SYNO_SN_TAG, strlen(SYNO_SN_TAG))) {
 		char *snp, *csump;
@@ -111,7 +111,7 @@
 			goto out_unmap;
 		}
 		printf("parsed SN = %s\n", snp);
-		setenv("SN", snp);
+		env_set("SN", snp);
 	} else {	/* old style format */
 		unsigned char csum = 0;
 
@@ -125,7 +125,7 @@
 		}
 		bufp[n] = '\0';
 		printf("parsed SN = %s\n", buf + 32);
-		setenv("SN", buf + 32);
+		env_set("SN", buf + 32);
 	}
 out_unmap:
 	unmap_physmem(buf, len);
diff --git a/board/amazon/kc1/kc1.c b/board/amazon/kc1/kc1.c
index 13a9c6a..eead98b 100644
--- a/board/amazon/kc1/kc1.c
+++ b/board/amazon/kc1/kc1.c
@@ -118,8 +118,8 @@
 	}
 
 	if (reboot_mode[0] > 0 && isascii(reboot_mode[0])) {
-		if (!getenv("reboot-mode"))
-			setenv("reboot-mode", (char *)reboot_mode);
+		if (!env_get("reboot-mode"))
+			env_set("reboot-mode", (char *)reboot_mode);
 	}
 
 	omap_reboot_mode_clear();
diff --git a/board/amlogic/odroid-c2/odroid-c2.c b/board/amlogic/odroid-c2/odroid-c2.c
index b29f56d..eac04d8 100644
--- a/board/amlogic/odroid-c2/odroid-c2.c
+++ b/board/amlogic/odroid-c2/odroid-c2.c
@@ -44,18 +44,18 @@
 	mdelay(10);
 	setbits_le32(GXBB_GPIO_OUT(3), BIT(14));
 
-	if (!eth_getenv_enetaddr("ethaddr", mac_addr)) {
+	if (!eth_env_get_enetaddr("ethaddr", mac_addr)) {
 		len = meson_sm_read_efuse(EFUSE_MAC_OFFSET,
 					  mac_addr, EFUSE_MAC_SIZE);
 		if (len == EFUSE_MAC_SIZE && is_valid_ethaddr(mac_addr))
-			eth_setenv_enetaddr("ethaddr", mac_addr);
+			eth_env_set_enetaddr("ethaddr", mac_addr);
 	}
 
-	if (!getenv("serial#")) {
+	if (!env_get("serial#")) {
 		len = meson_sm_read_efuse(EFUSE_SN_OFFSET, serial,
 			EFUSE_SN_SIZE);
 		if (len == EFUSE_SN_SIZE) 
-			setenv("serial#", serial);
+			env_set("serial#", serial);
 	}
 
 	return 0;
diff --git a/board/aries/ma5d4evk/ma5d4evk.c b/board/aries/ma5d4evk/ma5d4evk.c
index b9294fc..956c297 100644
--- a/board/aries/ma5d4evk/ma5d4evk.c
+++ b/board/aries/ma5d4evk/ma5d4evk.c
@@ -325,7 +325,7 @@
 
 int board_late_init(void)
 {
-	setenv("bootmode", boot_mode_sf ? "sf" : "emmc");
+	env_set("bootmode", boot_mode_sf ? "sf" : "emmc");
 	return 0;
 }
 
diff --git a/board/aristainetos/aristainetos-v2.c b/board/aristainetos/aristainetos-v2.c
index 6abc215..698715ca 100644
--- a/board/aristainetos/aristainetos-v2.c
+++ b/board/aristainetos/aristainetos-v2.c
@@ -651,7 +651,7 @@
 {
 	char *my_bootdelay;
 	char bootmode = 0;
-	char const *panel = getenv("panel");
+	char const *panel = env_get("panel");
 
 	/*
 	 * Check the boot-source. If booting from NOR Flash,
@@ -668,11 +668,11 @@
 	bootmode |= (gpio_get_value(IMX_GPIO_NR(7, 1)) ? 1 : 0) << 2;
 
 	if (bootmode == 7) {
-		my_bootdelay = getenv("nor_bootdelay");
+		my_bootdelay = env_get("nor_bootdelay");
 		if (my_bootdelay != NULL)
-			setenv("bootdelay", my_bootdelay);
+			env_set("bootdelay", my_bootdelay);
 		else
-			setenv("bootdelay", "-2");
+			env_set("bootdelay", "-2");
 	}
 
 	/* if we have the lg panel, we can initialze it now */
diff --git a/board/armltd/integrator/integrator.c b/board/armltd/integrator/integrator.c
index c3bafd4..858f74e 100644
--- a/board/armltd/integrator/integrator.c
+++ b/board/armltd/integrator/integrator.c
@@ -116,7 +116,7 @@
 
 int misc_init_r (void)
 {
-	setenv("verify", "n");
+	env_set("verify", "n");
 	return (0);
 }
 
diff --git a/board/atmel/sama5d2_xplained/sama5d2_xplained.c b/board/atmel/sama5d2_xplained/sama5d2_xplained.c
index 48f45b3..3f0860c 100644
--- a/board/atmel/sama5d2_xplained/sama5d2_xplained.c
+++ b/board/atmel/sama5d2_xplained/sama5d2_xplained.c
@@ -169,7 +169,7 @@
 	const char *ETHADDR_NAME = "ethaddr";
 	struct udevice *bus, *dev;
 
-	if (getenv(ETHADDR_NAME))
+	if (env_get(ETHADDR_NAME))
 		return 0;
 
 	if (uclass_get_device_by_seq(UCLASS_I2C, 1, &bus)) {
@@ -192,7 +192,7 @@
 		return -1;
 	}
 
-	return eth_setenv_enetaddr(ETHADDR_NAME, ethaddr);
+	return eth_env_set_enetaddr(ETHADDR_NAME, ethaddr);
 }
 #else
 static int set_ethaddr_from_eeprom(void)
diff --git a/board/atmel/sama5d3xek/sama5d3xek.c b/board/atmel/sama5d3xek/sama5d3xek.c
index c1f2769..88bcd87 100644
--- a/board/atmel/sama5d3xek/sama5d3xek.c
+++ b/board/atmel/sama5d3xek/sama5d3xek.c
@@ -267,7 +267,7 @@
 		*p = tolower(*p);
 
 	strcat(name, "ek.dtb");
-	setenv("dtb_name", name);
+	env_set("dtb_name", name);
 #endif
 	return 0;
 }
diff --git a/board/bachmann/ot1200/ot1200.c b/board/bachmann/ot1200/ot1200.c
index 1ad4ef9..df10d6a 100644
--- a/board/bachmann/ot1200/ot1200.c
+++ b/board/bachmann/ot1200/ot1200.c
@@ -312,9 +312,9 @@
 
 	/* depending on the phy address we can detect our board version */
 	if (phydev->addr == 0)
-		setenv("boardver", "");
+		env_set("boardver", "");
 	else
-		setenv("boardver", "mr");
+		env_set("boardver", "mr");
 
 	printf("using phy at %d\n", phydev->addr);
 	ret = fec_probe(bis, -1, base, bus, phydev);
diff --git a/board/birdland/bav335x/board.c b/board/birdland/bav335x/board.c
index 67aca3c..f284568 100644
--- a/board/birdland/bav335x/board.c
+++ b/board/birdland/bav335x/board.c
@@ -162,8 +162,8 @@
 
 #ifdef CONFIG_SPL_ENV_SUPPORT
 	env_init();
-	env_relocate_spec();
-	if (getenv_yesno("boot_os") != 1)
+	env_load();
+	if (env_get_yesno("boot_os") != 1)
 		return 1;
 #endif
 
@@ -301,8 +301,8 @@
 int board_late_init(void)
 {
 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
-	setenv("board_name", "BAV335xB");
-	setenv("board_rev", "B"); /* Fix me, but why bother.. */
+	env_set("board_name", "BAV335xB");
+	env_set("board_rev", "B"); /* Fix me, but why bother.. */
 #endif
 	return 0;
 }
@@ -392,11 +392,11 @@
 #if (defined(CONFIG_DRIVER_TI_CPSW) && !defined(CONFIG_SPL_BUILD)) || \
 	(defined(CONFIG_SPL_ETH_SUPPORT) && defined(CONFIG_SPL_BUILD))
 
-	if (!getenv("ethaddr")) {
+	if (!env_get("ethaddr")) {
 		printf("<ethaddr> not set. Validating first E-fuse MAC\n");
 
 		if (is_valid_ethaddr(mac_addr))
-			eth_setenv_enetaddr("ethaddr", mac_addr);
+			eth_env_set_enetaddr("ethaddr", mac_addr);
 	}
 
 #ifdef CONFIG_DRIVER_TI_CPSW
diff --git a/board/bluegiga/apx4devkit/apx4devkit.c b/board/bluegiga/apx4devkit/apx4devkit.c
index 2215c29..25e5c3d 100644
--- a/board/bluegiga/apx4devkit/apx4devkit.c
+++ b/board/bluegiga/apx4devkit/apx4devkit.c
@@ -133,8 +133,8 @@
 #ifdef CONFIG_REVISION_TAG
 u32 get_board_rev(void)
 {
-	if (getenv("revision#") != NULL)
-		return simple_strtoul(getenv("revision#"), NULL, 10);
+	if (env_get("revision#") != NULL)
+		return simple_strtoul(env_get("revision#"), NULL, 10);
 	return 0;
 }
 #endif
diff --git a/board/bluewater/gurnard/gurnard.c b/board/bluewater/gurnard/gurnard.c
index e82c691..8733a9a 100644
--- a/board/bluewater/gurnard/gurnard.c
+++ b/board/bluewater/gurnard/gurnard.c
@@ -341,7 +341,7 @@
 	at91_set_A_periph(AT91_PIN_PE6, 1);	/* power up */
 
 	/* Select the second timing index for board rev 2 */
-	rev_str = getenv("board_rev");
+	rev_str = env_get("board_rev");
 	if (rev_str && !strncmp(rev_str, "2", 1)) {
 		struct udevice *dev;
 
@@ -368,7 +368,7 @@
 	 * Set MAC address so we do not need to init Ethernet before Linux
 	 * boot
 	 */
-	env_str = getenv("ethaddr");
+	env_str = env_get("ethaddr");
 	if (env_str) {
 		struct at91_emac *emac = (struct at91_emac *)ATMEL_BASE_EMAC;
 		/* Parse MAC address */
@@ -385,7 +385,7 @@
 		       &emac->sa2l);
 		writel((env_enetaddr[4] | env_enetaddr[5] << 8), &emac->sa2h);
 
-		printf("MAC:   %s\n", getenv("ethaddr"));
+		printf("MAC:   %s\n", env_get("ethaddr"));
 	} else {
 		/* Not set in environment */
 		printf("MAC:   not set\n");
diff --git a/board/bosch/shc/board.c b/board/bosch/shc/board.c
index 38577f3..999ed95 100644
--- a/board/bosch/shc/board.c
+++ b/board/bosch/shc/board.c
@@ -251,7 +251,7 @@
 
 	if (value == 0) {
 		printf("front button activated !\n");
-		setenv("harakiri", "1");
+		env_set("harakiri", "1");
 	}
 }
 
@@ -460,7 +460,7 @@
 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
 	if (shc_eeprom_valid)
 		if (is_valid_ethaddr(header.mac_addr))
-			eth_setenv_enetaddr("ethaddr", header.mac_addr);
+			eth_env_set_enetaddr("ethaddr", header.mac_addr);
 #endif
 
 	return 0;
@@ -545,11 +545,11 @@
 
 #if (defined(CONFIG_DRIVER_TI_CPSW) && !defined(CONFIG_SPL_BUILD)) || \
 	(defined(CONFIG_SPL_ETH_SUPPORT) && defined(CONFIG_SPL_BUILD))
-	if (!getenv("ethaddr")) {
+	if (!env_get("ethaddr")) {
 		printf("<ethaddr> not set. Validating first E-fuse MAC\n");
 
 		if (is_valid_ethaddr(mac_addr))
-			eth_setenv_enetaddr("ethaddr", mac_addr);
+			eth_env_set_enetaddr("ethaddr", mac_addr);
 	}
 
 	writel(MII_MODE_ENABLE, &cdev->miisel);
@@ -565,7 +565,7 @@
 #if defined(CONFIG_USB_ETHER) && \
 	(!defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_USBETH_SUPPORT))
 	if (is_valid_ethaddr(mac_addr))
-		eth_setenv_enetaddr("usbnet_devaddr", mac_addr);
+		eth_env_set_enetaddr("usbnet_devaddr", mac_addr);
 
 	rv = usb_eth_initialize(bis);
 	if (rv < 0)
diff --git a/board/boundary/nitrogen6x/nitrogen6x.c b/board/boundary/nitrogen6x/nitrogen6x.c
index 17fd6f5..3b92b64 100644
--- a/board/boundary/nitrogen6x/nitrogen6x.c
+++ b/board/boundary/nitrogen6x/nitrogen6x.c
@@ -749,7 +749,7 @@
 
 int board_cfb_skip(void)
 {
-	return NULL != getenv("novideo");
+	return NULL != env_get("novideo");
 }
 
 static void setup_display(void)
@@ -954,7 +954,7 @@
 {
 	char envvalue[ARRAY_SIZE(buttons)+1];
 	int numpressed = read_keys(envvalue);
-	setenv("keybd", envvalue);
+	env_set("keybd", envvalue);
 	return numpressed == 0;
 }
 
@@ -974,7 +974,7 @@
 	char keypress[ARRAY_SIZE(buttons)+1];
 	numpressed = read_keys(keypress);
 	if (numpressed) {
-		char *kbd_magic_keys = getenv("magic_keys");
+		char *kbd_magic_keys = env_get("magic_keys");
 		char *suffix;
 		/*
 		 * loop over all magic keys
@@ -983,7 +983,7 @@
 			char *keys;
 			char magic[sizeof(kbd_magic_prefix) + 1];
 			sprintf(magic, "%s%c", kbd_magic_prefix, *suffix);
-			keys = getenv(magic);
+			keys = env_get(magic);
 			if (keys) {
 				if (!strcmp(keys, keypress))
 					break;
@@ -993,9 +993,9 @@
 			char cmd_name[sizeof(kbd_command_prefix) + 1];
 			char *cmd;
 			sprintf(cmd_name, "%s%c", kbd_command_prefix, *suffix);
-			cmd = getenv(cmd_name);
+			cmd = env_get(cmd_name);
 			if (cmd) {
-				setenv("preboot", cmd);
+				env_set("preboot", cmd);
 				return;
 			}
 		}
@@ -1021,6 +1021,6 @@
 #ifdef CONFIG_CMD_BMODE
 	add_board_boot_modes(board_boot_modes);
 #endif
-	setenv_hex("reset_cause", get_imx_reset_cause());
+	env_set_hex("reset_cause", get_imx_reset_cause());
 	return 0;
 }
diff --git a/board/broadcom/bcm23550_w1d/bcm23550_w1d.c b/board/broadcom/bcm23550_w1d/bcm23550_w1d.c
index 5f4c634..0267582 100644
--- a/board/broadcom/bcm23550_w1d/bcm23550_w1d.c
+++ b/board/broadcom/bcm23550_w1d/bcm23550_w1d.c
@@ -103,7 +103,7 @@
 int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
 {
 	debug("%s\n", __func__);
-	if (!getenv("serial#"))
+	if (!env_get("serial#"))
 		g_dnl_set_serialnumber(CONFIG_USB_SERIALNO);
 	return 0;
 }
diff --git a/board/broadcom/bcm28155_ap/bcm28155_ap.c b/board/broadcom/bcm28155_ap/bcm28155_ap.c
index f5b94f6..8f48ccb 100644
--- a/board/broadcom/bcm28155_ap/bcm28155_ap.c
+++ b/board/broadcom/bcm28155_ap/bcm28155_ap.c
@@ -110,7 +110,7 @@
 int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
 {
 	debug("%s\n", __func__);
-	if (!getenv("serial#"))
+	if (!env_get("serial#"))
 		g_dnl_set_serialnumber(CONFIG_USB_SERIALNO);
 	return 0;
 }
diff --git a/board/buffalo/lsxl/lsxl.c b/board/buffalo/lsxl/lsxl.c
index 0f37345..2d01ac2 100644
--- a/board/buffalo/lsxl/lsxl.c
+++ b/board/buffalo/lsxl/lsxl.c
@@ -203,7 +203,7 @@
 {
 	uchar enetaddr[6];
 
-	if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
+	if (!eth_env_get_enetaddr("ethaddr", enetaddr)) {
 		/* signal unset/invalid ethaddr to user */
 		set_led(LED_INFO_BLINKING);
 	}
@@ -228,7 +228,7 @@
 static void rescue_mode(void)
 {
 	printf("Entering rescue mode..\n");
-	setenv("bootsource", "rescue");
+	env_set("bootsource", "rescue");
 }
 
 static void check_push_button(void)
diff --git a/board/cadence/xtfpga/xtfpga.c b/board/cadence/xtfpga/xtfpga.c
index 0265e9b..f81fa95 100644
--- a/board/cadence/xtfpga/xtfpga.c
+++ b/board/cadence/xtfpga/xtfpga.c
@@ -86,14 +86,14 @@
 	 * Default MAC address comes from CONFIG_ETHADDR + DIP switches 1-6.
 	 */
 
-	char *s = getenv("ethaddr");
+	char *s = env_get("ethaddr");
 	if (s == 0) {
 		unsigned int x;
 		char s[] = __stringify(CONFIG_ETHBASE);
 		x = (*(volatile u32 *)CONFIG_SYS_FPGAREG_DIPSW)
 			& FPGAREG_MAC_MASK;
 		sprintf(&s[15], "%02x", x);
-		setenv("ethaddr", s);
+		env_set("ethaddr", s);
 	}
 #endif /* CONFIG_CMD_NET */
 
diff --git a/board/ccv/xpress/xpress.c b/board/ccv/xpress/xpress.c
index 542e534..b656465 100644
--- a/board/ccv/xpress/xpress.c
+++ b/board/ccv/xpress/xpress.c
@@ -318,7 +318,7 @@
 int board_late_init(void)
 {
 	add_board_boot_modes(board_boot_modes);
-	setenv("board_name", "xpress");
+	env_set("board_name", "xpress");
 
 	return 0;
 }
diff --git a/board/compulab/cl-som-am57x/eth.c b/board/compulab/cl-som-am57x/eth.c
index 0c4bf91..b615fb9 100644
--- a/board/compulab/cl-som-am57x/eth.c
+++ b/board/compulab/cl-som-am57x/eth.c
@@ -95,7 +95,7 @@
 	int ret;
 	uint8_t enetaddr[6];
 
-	ret = eth_getenv_enetaddr(env_name, enetaddr);
+	ret = eth_env_get_enetaddr(env_name, enetaddr);
 	if (ret)
 		return 0;
 
@@ -107,7 +107,7 @@
 	if (!is_valid_ethaddr(enetaddr))
 		return -1;
 
-	ret = eth_setenv_enetaddr(env_name, enetaddr);
+	ret = eth_env_set_enetaddr(env_name, enetaddr);
 	if (ret)
 		printf("cl-som-am57x: Failed to set Eth port %d MAC address\n",
 		       port_num);
@@ -181,7 +181,7 @@
 	gpio_set_value(CL_SOM_AM57X_GPIO_PHY1_RST, 1);
 	mdelay(20);
 
-	cpsw_phy_envval = getenv("cpsw_phy");
+	cpsw_phy_envval = env_get("cpsw_phy");
 	if (cpsw_phy_envval != NULL)
 		cpsw_act_phy = simple_strtoul(cpsw_phy_envval, NULL, 0);
 
diff --git a/board/compulab/cm_fx6/cm_fx6.c b/board/compulab/cm_fx6/cm_fx6.c
index c59884a..a1da278 100644
--- a/board/compulab/cm_fx6/cm_fx6.c
+++ b/board/compulab/cm_fx6/cm_fx6.c
@@ -114,10 +114,10 @@
 {
 	int ret;
 	struct display_info_t *preset;
-	char const *panel = getenv("displaytype");
+	char const *panel = env_get("displaytype");
 
 	if (!panel) /* Also accept panel for backward compatibility */
-		panel = getenv("panel");
+		panel = env_get("panel");
 
 	if (!panel)
 		return -ENOENT;
@@ -470,7 +470,7 @@
 	unsigned char enetaddr[6];
 	int rc;
 
-	rc = eth_getenv_enetaddr(env_var, enetaddr);
+	rc = eth_env_get_enetaddr(env_var, enetaddr);
 	if (rc)
 		return 0;
 
@@ -481,7 +481,7 @@
 	if (!is_valid_ethaddr(enetaddr))
 		return -1;
 
-	return eth_setenv_enetaddr(env_var, enetaddr);
+	return eth_env_set_enetaddr(env_var, enetaddr);
 }
 
 #define SB_FX6_I2C_EEPROM_BUS	0
@@ -605,13 +605,13 @@
 	fdt_shrink_to_minimum(blob, 0); /* Make room for new properties */
 
 	/* MAC addr */
-	if (eth_getenv_enetaddr("ethaddr", enetaddr)) {
+	if (eth_env_get_enetaddr("ethaddr", enetaddr)) {
 		fdt_find_and_setprop(blob,
 				     "/soc/aips-bus@02100000/ethernet@02188000",
 				     "local-mac-address", enetaddr, 6, 1);
 	}
 
-	if (eth_getenv_enetaddr("eth1addr", enetaddr)) {
+	if (eth_env_get_enetaddr("eth1addr", enetaddr)) {
 		fdt_find_and_setprop(blob, "/eth@pcie", "local-mac-address",
 				     enetaddr, 6, 1);
 	}
diff --git a/board/compulab/cm_t335/cm_t335.c b/board/compulab/cm_t335/cm_t335.c
index c4506b9..6f6ba49 100644
--- a/board/compulab/cm_t335/cm_t335.c
+++ b/board/compulab/cm_t335/cm_t335.c
@@ -106,7 +106,7 @@
 	uchar enetaddr[6];
 	int rv;
 
-	rv = eth_getenv_enetaddr("ethaddr", enetaddr);
+	rv = eth_env_get_enetaddr("ethaddr", enetaddr);
 	if (rv)
 		return 0;
 
@@ -117,7 +117,7 @@
 	if (!is_valid_ethaddr(enetaddr))
 		return -1;
 
-	return eth_setenv_enetaddr("ethaddr", enetaddr);
+	return eth_env_set_enetaddr("ethaddr", enetaddr);
 }
 
 #define AR8051_PHY_DEBUG_ADDR_REG	0x1d
diff --git a/board/compulab/cm_t35/cm_t35.c b/board/compulab/cm_t35/cm_t35.c
index da67098..be938eb 100644
--- a/board/compulab/cm_t35/cm_t35.c
+++ b/board/compulab/cm_t35/cm_t35.c
@@ -434,7 +434,7 @@
 	unsigned char enetaddr[6];
 	int rc;
 
-	rc = eth_getenv_enetaddr("ethaddr", enetaddr);
+	rc = eth_env_get_enetaddr("ethaddr", enetaddr);
 	if (rc)
 		return 0;
 
@@ -445,7 +445,7 @@
 	if (!is_valid_ethaddr(enetaddr))
 		return -1;
 
-	return eth_setenv_enetaddr("ethaddr", enetaddr);
+	return eth_env_set_enetaddr("ethaddr", enetaddr);
 }
 
 /*
diff --git a/board/compulab/cm_t3517/cm_t3517.c b/board/compulab/cm_t3517/cm_t3517.c
index 38eb641..0ff49dc 100644
--- a/board/compulab/cm_t3517/cm_t3517.c
+++ b/board/compulab/cm_t3517/cm_t3517.c
@@ -168,7 +168,7 @@
 	unsigned char enetaddr[6];
 	int ret;
 
-	ret = eth_getenv_enetaddr("ethaddr", enetaddr);
+	ret = eth_env_get_enetaddr("ethaddr", enetaddr);
 	if (ret)
 		return 0;
 
@@ -182,7 +182,7 @@
 	if (!is_valid_ethaddr(enetaddr))
 		return -1;
 
-	return eth_setenv_enetaddr("ethaddr", enetaddr);
+	return eth_env_set_enetaddr("ethaddr", enetaddr);
 }
 
 #define SB_T35_ETH_RST_GPIO 164
diff --git a/board/compulab/cm_t54/cm_t54.c b/board/compulab/cm_t54/cm_t54.c
index 6437718..31730a4 100644
--- a/board/compulab/cm_t54/cm_t54.c
+++ b/board/compulab/cm_t54/cm_t54.c
@@ -126,7 +126,7 @@
 	uint8_t enetaddr[6];
 
 	/* MAC addr */
-	if (eth_getenv_enetaddr("usbethaddr", enetaddr)) {
+	if (eth_env_get_enetaddr("usbethaddr", enetaddr)) {
 		fdt_find_and_setprop(blob, "/smsc95xx@0", "mac-address",
 				     enetaddr, 6, 1);
 	}
@@ -161,7 +161,7 @@
 	uint8_t enetaddr[6];
 	int ret;
 
-	ret = eth_getenv_enetaddr("usbethaddr", enetaddr);
+	ret = eth_env_get_enetaddr("usbethaddr", enetaddr);
 	if (ret)
 		return 0;
 
@@ -172,7 +172,7 @@
 	if (!is_valid_ethaddr(enetaddr))
 		return -1;
 
-	return eth_setenv_enetaddr("usbethaddr", enetaddr);
+	return eth_env_set_enetaddr("usbethaddr", enetaddr);
 }
 
 int board_eth_init(bd_t *bis)
diff --git a/board/compulab/common/omap3_display.c b/board/compulab/common/omap3_display.c
index 61707f5..ed2077e 100644
--- a/board/compulab/common/omap3_display.c
+++ b/board/compulab/common/omap3_display.c
@@ -400,7 +400,7 @@
 {
 	struct prcm *prcm = (struct prcm *)PRCM_BASE;
 	char *custom_lcd;
-	char *displaytype = getenv("displaytype");
+	char *displaytype = env_get("displaytype");
 
 	if (displaytype == NULL)
 		return;
@@ -408,7 +408,7 @@
 	lcd_def = env_parse_displaytype(displaytype);
 	/* If we did not recognize the preset, check if it's an env variable */
 	if (lcd_def == NONE) {
-		custom_lcd = getenv(displaytype);
+		custom_lcd = env_get(displaytype);
 		if (custom_lcd == NULL || parse_customlcd(custom_lcd) < 0)
 			return;
 	}
diff --git a/board/congatec/cgtqmx6eval/cgtqmx6eval.c b/board/congatec/cgtqmx6eval/cgtqmx6eval.c
index 5cb97b4..8cd0090 100644
--- a/board/congatec/cgtqmx6eval/cgtqmx6eval.c
+++ b/board/congatec/cgtqmx6eval/cgtqmx6eval.c
@@ -235,7 +235,7 @@
 		return 0;
 
 	/* set level of MIPI if specified */
-	lv_mipi = getenv("lv_mipi");
+	lv_mipi = env_get("lv_mipi");
 	if (lv_mipi)
 		return 0;
 
@@ -583,7 +583,7 @@
 {
 	int i;
 	int ret;
-	char const *panel = getenv("panel");
+	char const *panel = env_get("panel");
 	if (!panel) {
 		for (i = 0; i < ARRAY_SIZE(displays); i++) {
 			struct display_info_t const *dev = displays + i;
@@ -755,9 +755,9 @@
 {
 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
 	if (is_mx6dq())
-		setenv("board_rev", "MX6Q");
+		env_set("board_rev", "MX6Q");
 	else
-		setenv("board_rev", "MX6DL");
+		env_set("board_rev", "MX6DL");
 #endif
 
 	return 0;
diff --git a/board/cssi/MCR3000/MCR3000.c b/board/cssi/MCR3000/MCR3000.c
index 43c4cb7..c928881 100644
--- a/board/cssi/MCR3000/MCR3000.c
+++ b/board/cssi/MCR3000/MCR3000.c
@@ -123,7 +123,7 @@
 
 	/* if BTN_ACQ_AL is pressed then bootdelay is changed to 60 second */
 	if ((in_be16(&iop->iop_pcdat) & 0x0004) == 0)
-		setenv("bootdelay", "60");
+		env_set("bootdelay", "60");
 
 	return 0;
 }
diff --git a/board/davinci/da8xxevm/da850evm.c b/board/davinci/da8xxevm/da850evm.c
index 11ea52f..c2d2e8e8 100644
--- a/board/davinci/da8xxevm/da850evm.c
+++ b/board/davinci/da8xxevm/da850evm.c
@@ -131,7 +131,7 @@
 	uchar env_enetaddr[6];
 	int enetaddr_found;
 
-	enetaddr_found = eth_getenv_enetaddr("ethaddr", env_enetaddr);
+	enetaddr_found = eth_env_get_enetaddr("ethaddr", env_enetaddr);
 
 #ifdef CONFIG_MAC_ADDR_IN_SPIFLASH
 	int spi_mac_read;
@@ -147,7 +147,7 @@
 	if (!enetaddr_found) {
 		if (!spi_mac_read) {
 			if (is_valid_ethaddr(buff)) {
-				if (eth_setenv_enetaddr("ethaddr", buff)) {
+				if (eth_env_set_enetaddr("ethaddr", buff)) {
 					printf("Warning: Failed to "
 					"set MAC address from SPI flash\n");
 				}
@@ -292,7 +292,7 @@
 	u32 maxcpuclk = CONFIG_DA850_EVM_MAX_CPU_CLK;
 	u32 rev = 0;
 
-	s = getenv("maxcpuclk");
+	s = env_get("maxcpuclk");
 	if (s)
 		maxcpuclk = simple_strtoul(s, NULL, 10);
 
diff --git a/board/davinci/da8xxevm/omapl138_lcdk.c b/board/davinci/da8xxevm/omapl138_lcdk.c
index 52bb736..5650207 100644
--- a/board/davinci/da8xxevm/omapl138_lcdk.c
+++ b/board/davinci/da8xxevm/omapl138_lcdk.c
@@ -293,7 +293,7 @@
 	if ((REG(CHIP_REV_ID_REG) & 0x3f) == 0x10)
 		return;
 
-	if (!strcmp(getenv("dspwake"), "no"))
+	if (!strcmp(env_get("dspwake"), "no"))
 		return;
 
 	*resetvect++ = 0x1E000; /* DSP Idle */
@@ -323,7 +323,7 @@
 	uint8_t tmp[20], addr[10];
 
 
-	if (getenv("ethaddr") == NULL) {
+	if (env_get("ethaddr") == NULL) {
 		/* Read Ethernet MAC address from EEPROM */
 		if (dvevm_read_mac_address(addr)) {
 			/* Set Ethernet MAC address from EEPROM */
@@ -337,7 +337,7 @@
 				addr[0], addr[1], addr[2], addr[3], addr[4],
 				addr[5]);
 
-			setenv("ethaddr", (char *)tmp);
+			env_set("ethaddr", (char *)tmp);
 		} else {
 			printf("Invalid MAC address read.\n");
 		}
diff --git a/board/el/el6x/el6x.c b/board/el/el6x/el6x.c
index cbe355a..6b98b5c 100644
--- a/board/el/el6x/el6x.c
+++ b/board/el/el6x/el6x.c
@@ -466,7 +466,7 @@
 	add_board_boot_modes(board_boot_modes);
 #endif
 
-	setenv("board_name", BOARD_NAME);
+	env_set("board_name", BOARD_NAME);
 	return 0;
 }
 
diff --git a/board/engicam/common/board.c b/board/engicam/common/board.c
index e3bb569..c7ec55f 100644
--- a/board/engicam/common/board.c
+++ b/board/engicam/common/board.c
@@ -21,11 +21,11 @@
 	char mmcblk[32];
 	u32 dev_no = mmc_get_env_dev();
 
-	setenv_ulong("mmcdev", dev_no);
+	env_set_ulong("mmcdev", dev_no);
 
 	/* Set mmcblk env */
 	sprintf(mmcblk, "/dev/mmcblk%dp2 rootwait rw", dev_no);
-	setenv("mmcroot", mmcblk);
+	env_set("mmcroot", mmcblk);
 
 	sprintf(cmd, "mmc dev %d", dev_no);
 	run_command(cmd, 0);
@@ -43,20 +43,20 @@
 #ifdef CONFIG_ENV_IS_IN_MMC
 		mmc_late_init();
 #endif
-		setenv("modeboot", "mmcboot");
+		env_set("modeboot", "mmcboot");
 		break;
 	case IMX6_BMODE_NAND:
-		setenv("modeboot", "nandboot");
+		env_set("modeboot", "nandboot");
 		break;
 	default:
-		setenv("modeboot", "");
+		env_set("modeboot", "");
 		break;
 	}
 
 	if (is_mx6ul())
-		setenv("console", "ttymxc0");
+		env_set("console", "ttymxc0");
 	else
-		setenv("console", "ttymxc3");
+		env_set("console", "ttymxc3");
 
 	setenv_fdt_file();
 
diff --git a/board/engicam/geam6ul/geam6ul.c b/board/engicam/geam6ul/geam6ul.c
index bc36fc7..ffd383a 100644
--- a/board/engicam/geam6ul/geam6ul.c
+++ b/board/engicam/geam6ul/geam6ul.c
@@ -93,7 +93,7 @@
 void setenv_fdt_file(void)
 {
 	if (is_mx6ul())
-		setenv("fdt_file", "imx6ul-geam-kit.dtb");
+		env_set("fdt_file", "imx6ul-geam-kit.dtb");
 }
 
 #ifdef CONFIG_SPL_BUILD
diff --git a/board/engicam/icorem6/icorem6.c b/board/engicam/icorem6/icorem6.c
index 5b2ed06..3d4f713 100644
--- a/board/engicam/icorem6/icorem6.c
+++ b/board/engicam/icorem6/icorem6.c
@@ -195,9 +195,9 @@
 void setenv_fdt_file(void)
 {
 	if (is_mx6dq())
-		setenv("fdt_file", "imx6q-icore.dtb");
+		env_set("fdt_file", "imx6q-icore.dtb");
 	else if(is_mx6dl() || is_mx6solo())
-		setenv("fdt_file", "imx6dl-icore.dtb");
+		env_set("fdt_file", "imx6dl-icore.dtb");
 }
 
 #ifdef CONFIG_SPL_BUILD
diff --git a/board/engicam/icorem6_rqs/icorem6_rqs.c b/board/engicam/icorem6_rqs/icorem6_rqs.c
index 10a9471..2a321dc 100644
--- a/board/engicam/icorem6_rqs/icorem6_rqs.c
+++ b/board/engicam/icorem6_rqs/icorem6_rqs.c
@@ -35,9 +35,9 @@
 void setenv_fdt_file(void)
 {
 	if (is_mx6dq())
-		setenv("fdt_file", "imx6q-icore-rqs.dtb");
+		env_set("fdt_file", "imx6q-icore-rqs.dtb");
 	else if(is_mx6dl() || is_mx6solo())
-		setenv("fdt_file", "imx6dl-icore-rqs.dtb");
+		env_set("fdt_file", "imx6dl-icore-rqs.dtb");
 }
 
 #ifdef CONFIG_SPL_BUILD
diff --git a/board/engicam/isiotmx6ul/isiotmx6ul.c b/board/engicam/isiotmx6ul/isiotmx6ul.c
index 4dcc9ea..fbf1724 100644
--- a/board/engicam/isiotmx6ul/isiotmx6ul.c
+++ b/board/engicam/isiotmx6ul/isiotmx6ul.c
@@ -102,9 +102,9 @@
 {
 	if (is_mx6ul()) {
 #ifdef CONFIG_ENV_IS_IN_MMC
-		setenv("fdt_file", "imx6ul-isiot-emmc.dtb");
+		env_set("fdt_file", "imx6ul-isiot-emmc.dtb");
 #else
-		setenv("fdt_file", "imx6ul-isiot-nand.dtb");
+		env_set("fdt_file", "imx6ul-isiot-nand.dtb");
 #endif
 	}
 }
diff --git a/board/esd/meesc/meesc.c b/board/esd/meesc/meesc.c
index 93a02ab..0c5900a 100644
--- a/board/esd/meesc/meesc.c
+++ b/board/esd/meesc/meesc.c
@@ -181,7 +181,7 @@
 		puts("Board: EtherCAN/2 Gateway");
 		break;
 	}
-	if (getenv_f("serial#", str, sizeof(str)) > 0) {
+	if (env_get_f("serial#", str, sizeof(str)) > 0) {
 		puts(", serial# ");
 		puts(str);
 	}
@@ -198,7 +198,7 @@
 {
 	char *str;
 
-	char *serial = getenv("serial#");
+	char *serial = env_get("serial#");
 	if (serial) {
 		str = strchr(serial, '_');
 		if (str && (strlen(str) >= 4)) {
@@ -231,7 +231,8 @@
 	 * In some cases this this needs to be set to 4.
 	 * Check the user has set environment mdiv to 4 to change the divisor.
 	 */
-	if ((str = getenv("mdiv")) && (strcmp(str, "4") == 0)) {
+	str = env_get("mdiv");
+	if (str && (strcmp(str, "4") == 0)) {
 		writel((readl(&pmc->mckr) & ~AT91_PMC_MDIV) |
 			AT91SAM9_PMC_MDIV_4, &pmc->mckr);
 		at91_clock_init(CONFIG_SYS_AT91_MAIN_CLOCK);
diff --git a/board/freescale/b4860qds/b4860qds.c b/board/freescale/b4860qds/b4860qds.c
index 83a7015..5d872fd 100644
--- a/board/freescale/b4860qds/b4860qds.c
+++ b/board/freescale/b4860qds/b4860qds.c
@@ -195,7 +195,7 @@
 	      vid, vdd_target/10);
 
 	/* check override variable for overriding VDD */
-	vdd_string = getenv("b4qds_vdd_mv");
+	vdd_string = env_get("b4qds_vdd_mv");
 	if (vdd_override == 0 && vdd_string &&
 	    !strict_strtoul(vdd_string, 10, &vdd_string_override))
 		vdd_override = vdd_string_override;
@@ -542,7 +542,7 @@
 			 * Extract hwconfig from environment since environment
 			 * is not setup properly yet
 			 */
-			getenv_f("hwconfig", buffer, sizeof(buffer));
+			env_get_f("hwconfig", buffer, sizeof(buffer));
 			buf = buffer;
 
 			if (hwconfig_subarg_cmp_f("fsl_b4860_serdes2",
@@ -1197,8 +1197,8 @@
 
 	ft_cpu_setup(blob, bd);
 
-	base = getenv_bootm_low();
-	size = getenv_bootm_size();
+	base = env_get_bootm_low();
+	size = env_get_bootm_size();
 
 	fdt_fixup_memory(blob, (u64)base, (u64)size);
 
diff --git a/board/freescale/b4860qds/spl.c b/board/freescale/b4860qds/spl.c
index 60d7f0d..b1824b0 100644
--- a/board/freescale/b4860qds/spl.c
+++ b/board/freescale/b4860qds/spl.c
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <console.h>
+#include <environment.h>
 #include <asm/spl.h>
 #include <malloc.h>
 #include <ns16550.h>
@@ -101,7 +102,7 @@
 	nand_spl_load_image(CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE,
 			    (uchar *)CONFIG_ENV_ADDR);
 	gd->env_addr  = (ulong)(CONFIG_ENV_ADDR);
-	gd->env_valid = 1;
+	gd->env_valid = ENV_VALID;
 #endif
 
 	i2c_init_all();
diff --git a/board/freescale/bsc9131rdb/bsc9131rdb.c b/board/freescale/bsc9131rdb/bsc9131rdb.c
index fb8bb39..c642e88 100644
--- a/board/freescale/bsc9131rdb/bsc9131rdb.c
+++ b/board/freescale/bsc9131rdb/bsc9131rdb.c
@@ -65,8 +65,8 @@
 
 	ft_cpu_setup(blob, bd);
 
-	base = getenv_bootm_low();
-	size = getenv_bootm_size();
+	base = env_get_bootm_low();
+	size = env_get_bootm_size();
 
 	fdt_fixup_memory(blob, (u64)base, (u64)size);
 #ifdef CONFIG_FDT_FIXUP_PARTITIONS
diff --git a/board/freescale/bsc9132qds/bsc9132qds.c b/board/freescale/bsc9132qds/bsc9132qds.c
index a7772c4..ed0b453 100644
--- a/board/freescale/bsc9132qds/bsc9132qds.c
+++ b/board/freescale/bsc9132qds/bsc9132qds.c
@@ -370,8 +370,8 @@
 
 	ft_cpu_setup(blob, bd);
 
-	base = getenv_bootm_low();
-	size = getenv_bootm_size();
+	base = env_get_bootm_low();
+	size = env_get_bootm_size();
 
 	#if defined(CONFIG_PCI)
 	FT_FSL_PCI_SETUP;
diff --git a/board/freescale/c29xpcie/c29xpcie.c b/board/freescale/c29xpcie/c29xpcie.c
index 45f463f..23901a4 100644
--- a/board/freescale/c29xpcie/c29xpcie.c
+++ b/board/freescale/c29xpcie/c29xpcie.c
@@ -138,8 +138,8 @@
 
 	ft_cpu_setup(blob, bd);
 
-	base = getenv_bootm_low();
-	size = getenv_bootm_size();
+	base = env_get_bootm_low();
+	size = env_get_bootm_size();
 
 #if defined(CONFIG_PCI)
 	FT_FSL_PCI_SETUP;
diff --git a/board/freescale/c29xpcie/spl.c b/board/freescale/c29xpcie/spl.c
index 94093f1..28541a7 100644
--- a/board/freescale/c29xpcie/spl.c
+++ b/board/freescale/c29xpcie/spl.c
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <console.h>
+#include <environment.h>
 #include <ns16550.h>
 #include <malloc.h>
 #include <mmc.h>
@@ -63,7 +64,7 @@
 	nand_spl_load_image(CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE,
 			    (uchar *)CONFIG_ENV_ADDR);
 	gd->env_addr  = (ulong)(CONFIG_ENV_ADDR);
-	gd->env_valid = 1;
+	gd->env_valid = ENV_VALID;
 
 	i2c_init_all();
 
diff --git a/board/freescale/common/cmd_esbc_validate.c b/board/freescale/common/cmd_esbc_validate.c
index cefe3cc..b3e5f01 100644
--- a/board/freescale/common/cmd_esbc_validate.c
+++ b/board/freescale/common/cmd_esbc_validate.c
@@ -52,7 +52,7 @@
 	 * to continue U-Boot
 	 */
 	sprintf(buf, "%lx", img_addr);
-	setenv("img_addr", buf);
+	env_set("img_addr", buf);
 
 	if (ret)
 		return 1;
diff --git a/board/freescale/common/fsl_chain_of_trust.c b/board/freescale/common/fsl_chain_of_trust.c
index dfe5d20..6e750b0 100644
--- a/board/freescale/common/fsl_chain_of_trust.c
+++ b/board/freescale/common/fsl_chain_of_trust.c
@@ -80,12 +80,12 @@
 	 * bootdelay = 0 (To disable Boot Prompt)
 	 * bootcmd = CONFIG_CHAIN_BOOT_CMD (Validate and execute Boot script)
 	 */
-	setenv("bootdelay", "0");
+	env_set("bootdelay", "0");
 
 #ifdef CONFIG_ARM
-	setenv("secureboot", "y");
+	env_set("secureboot", "y");
 #else
-	setenv("bootcmd", CONFIG_CHAIN_BOOT_CMD);
+	env_set("bootcmd", CONFIG_CHAIN_BOOT_CMD);
 #endif
 
 	return 0;
diff --git a/board/freescale/common/sys_eeprom.c b/board/freescale/common/sys_eeprom.c
index 29aa778..152ad84 100644
--- a/board/freescale/common/sys_eeprom.c
+++ b/board/freescale/common/sys_eeprom.c
@@ -478,8 +478,8 @@
 			/* Only initialize environment variables that are blank
 			 * (i.e. have not yet been set)
 			 */
-			if (!getenv(enetvar))
-				setenv(enetvar, ethaddr);
+			if (!env_get(enetvar))
+				env_set(enetvar, ethaddr);
 		}
 	}
 
diff --git a/board/freescale/common/vid.c b/board/freescale/common/vid.c
index 9b65c13..d6d1bfc 100644
--- a/board/freescale/common/vid.c
+++ b/board/freescale/common/vid.c
@@ -376,7 +376,7 @@
 	vdd_target = vdd[vid];
 
 	/* check override variable for overriding VDD */
-	vdd_string = getenv(CONFIG_VID_FLS_ENV);
+	vdd_string = env_get(CONFIG_VID_FLS_ENV);
 	if (vdd_override == 0 && vdd_string &&
 	    !strict_strtoul(vdd_string, 10, &vdd_string_override))
 		vdd_override = vdd_string_override;
@@ -560,7 +560,7 @@
 	vdd_target = vdd[vid];
 
 	/* check override variable for overriding VDD */
-	vdd_string = getenv(CONFIG_VID_FLS_ENV);
+	vdd_string = env_get(CONFIG_VID_FLS_ENV);
 	if (vdd_override == 0 && vdd_string &&
 	    !strict_strtoul(vdd_string, 10, &vdd_string_override))
 		vdd_override = vdd_string_override;
diff --git a/board/freescale/corenet_ds/corenet_ds.c b/board/freescale/corenet_ds/corenet_ds.c
index 93e1258..132650c 100644
--- a/board/freescale/corenet_ds/corenet_ds.c
+++ b/board/freescale/corenet_ds/corenet_ds.c
@@ -191,8 +191,8 @@
 
 	ft_cpu_setup(blob, bd);
 
-	base = getenv_bootm_low();
-	size = getenv_bootm_size();
+	base = env_get_bootm_low();
+	size = env_get_bootm_size();
 
 	fdt_fixup_memory(blob, (u64)base, (u64)size);
 
diff --git a/board/freescale/ls2080aqds/eth.c b/board/freescale/ls2080aqds/eth.c
index defcac5..aca29bc 100644
--- a/board/freescale/ls2080aqds/eth.c
+++ b/board/freescale/ls2080aqds/eth.c
@@ -449,7 +449,7 @@
 		>> FSL_CHASSIS3_RCWSR28_SRDS2_PRTCL_SHIFT;
 
 	char *env_hwconfig;
-	env_hwconfig = getenv("hwconfig");
+	env_hwconfig = env_get("hwconfig");
 
 	switch (serdes1_prtcl) {
 	case 0x07:
@@ -603,7 +603,7 @@
 		>> FSL_CHASSIS3_RCWSR28_SRDS2_PRTCL_SHIFT;
 
 	int *riser_phy_addr;
-	char *env_hwconfig = getenv("hwconfig");
+	char *env_hwconfig = env_get("hwconfig");
 
 	if (hwconfig_f("xqsgmii", env_hwconfig))
 		riser_phy_addr = &xqsgii_riser_phy_addr[0];
@@ -849,7 +849,7 @@
 	unsigned int i;
 	char *env_hwconfig;
 
-	env_hwconfig = getenv("hwconfig");
+	env_hwconfig = env_get("hwconfig");
 
 	initialize_dpmac_to_slot();
 
diff --git a/board/freescale/ls2080aqds/ls2080aqds.c b/board/freescale/ls2080aqds/ls2080aqds.c
index f36fb98..83773d0 100644
--- a/board/freescale/ls2080aqds/ls2080aqds.c
+++ b/board/freescale/ls2080aqds/ls2080aqds.c
@@ -204,7 +204,7 @@
 
 	val = in_le32(dcfg_ccsr + DCFG_RCWSR13 / 4);
 
-	env_hwconfig = getenv("hwconfig");
+	env_hwconfig = env_get("hwconfig");
 
 	if (hwconfig_f("dspi", env_hwconfig) &&
 	    DCFG_RCWSR13_DSPI == (val & (u32)(0xf << 8)))
diff --git a/board/freescale/ls2080ardb/ls2080ardb.c b/board/freescale/ls2080ardb/ls2080ardb.c
index d7122b3..07ba026 100644
--- a/board/freescale/ls2080ardb/ls2080ardb.c
+++ b/board/freescale/ls2080ardb/ls2080ardb.c
@@ -250,7 +250,7 @@
 
 	val = in_le32(dcfg_ccsr + DCFG_RCWSR13 / 4);
 
-	env_hwconfig = getenv("hwconfig");
+	env_hwconfig = env_get("hwconfig");
 
 	if (hwconfig_f("dspi", env_hwconfig) &&
 	    DCFG_RCWSR13_DSPI == (val & (u32)(0xf << 8)))
diff --git a/board/freescale/mpc8323erdb/mpc8323erdb.c b/board/freescale/mpc8323erdb/mpc8323erdb.c
index f30a151..b715d83 100644
--- a/board/freescale/mpc8323erdb/mpc8323erdb.c
+++ b/board/freescale/mpc8323erdb/mpc8323erdb.c
@@ -216,7 +216,7 @@
 						buf[i * 6 + 4], buf[i * 6 + 5]);
 					sprintf((char *)enetvar,
 						i ? "eth%daddr" : "ethaddr", i);
-					setenv((char *)enetvar, str);
+					env_set((char *)enetvar, str);
 				}
 			}
 		}
diff --git a/board/freescale/mpc837xemds/pci.c b/board/freescale/mpc837xemds/pci.c
index 39c40e5..e5d3dfd 100644
--- a/board/freescale/mpc837xemds/pci.c
+++ b/board/freescale/mpc837xemds/pci.c
@@ -67,7 +67,7 @@
 
 static int is_pex_x2(void)
 {
-	const char *pex_x2 = getenv("pex_x2");
+	const char *pex_x2 = env_get("pex_x2");
 
 	if (pex_x2 && !strcmp(pex_x2, "yes"))
 		return 1;
diff --git a/board/freescale/mpc837xerdb/mpc837xerdb.c b/board/freescale/mpc837xerdb/mpc837xerdb.c
index 319f047..9a0ab7f 100644
--- a/board/freescale/mpc837xerdb/mpc837xerdb.c
+++ b/board/freescale/mpc837xerdb/mpc837xerdb.c
@@ -173,7 +173,7 @@
 	char buffer[HWCONFIG_BUFFER_SIZE] = {0};
 	int esdhc_hwconfig_enabled = 0;
 
-	if (getenv_f("hwconfig", buffer, sizeof(buffer)) > 0)
+	if (env_get_f("hwconfig", buffer, sizeof(buffer)) > 0)
 		esdhc_hwconfig_enabled = hwconfig_f("esdhc", buffer);
 
 	if (esdhc_hwconfig_enabled == 0)
diff --git a/board/freescale/mpc8572ds/mpc8572ds.c b/board/freescale/mpc8572ds/mpc8572ds.c
index ed6836a..93d54f5 100644
--- a/board/freescale/mpc8572ds/mpc8572ds.c
+++ b/board/freescale/mpc8572ds/mpc8572ds.c
@@ -239,8 +239,8 @@
 
 	ft_cpu_setup(blob, bd);
 
-	base = getenv_bootm_low();
-	size = getenv_bootm_size();
+	base = env_get_bootm_low();
+	size = env_get_bootm_size();
 
 	fdt_fixup_memory(blob, (u64)base, (u64)size);
 
diff --git a/board/freescale/mx31ads/u-boot.lds b/board/freescale/mx31ads/u-boot.lds
index 8a4a8a2..71a63f1 100644
--- a/board/freescale/mx31ads/u-boot.lds
+++ b/board/freescale/mx31ads/u-boot.lds
@@ -30,7 +30,7 @@
 	  drivers/mtd/built-in.o		(.text*)
 
 	  . = DEFINED(env_offset) ? env_offset : .;
-	  common/env_embedded.o(.text*)
+	  env/embedded.o(.text*)
 
 	  *(.text*)
 	}
diff --git a/board/freescale/mx51evk/mx51evk_video.c b/board/freescale/mx51evk/mx51evk_video.c
index 86ec750..cc2c855 100644
--- a/board/freescale/mx51evk/mx51evk_video.c
+++ b/board/freescale/mx51evk/mx51evk_video.c
@@ -76,7 +76,7 @@
 int board_video_skip(void)
 {
 	int ret;
-	char const *e = getenv("panel");
+	char const *e = env_get("panel");
 
 	if (e) {
 		if (strcmp(e, "claa") == 0) {
diff --git a/board/freescale/mx53loco/mx53loco.c b/board/freescale/mx53loco/mx53loco.c
index 27d606f..ea36603 100644
--- a/board/freescale/mx53loco/mx53loco.c
+++ b/board/freescale/mx53loco/mx53loco.c
@@ -246,7 +246,7 @@
 		if (!p)
 			return -ENODEV;
 
-		setenv("fdt_file", "imx53-qsb.dtb");
+		env_set("fdt_file", "imx53-qsb.dtb");
 
 		/* Set VDDA to 1.25V */
 		val = DA9052_BUCKCORE_BCOREEN | DA_BUCKCORE_VBCORE_1_250V;
@@ -289,7 +289,7 @@
 		if (!p)
 			return -ENODEV;
 
-		setenv("fdt_file", "imx53-qsrb.dtb");
+		env_set("fdt_file", "imx53-qsrb.dtb");
 
 		/* Set VDDGP to 1.25V for 1GHz on SW1 */
 		pmic_reg_read(p, REG_SW_0, &val);
diff --git a/board/freescale/mx53loco/mx53loco_video.c b/board/freescale/mx53loco/mx53loco_video.c
index bc5e8a9..5fb0f04 100644
--- a/board/freescale/mx53loco/mx53loco_video.c
+++ b/board/freescale/mx53loco/mx53loco_video.c
@@ -92,7 +92,7 @@
 int board_video_skip(void)
 {
 	int ret;
-	char const *e = getenv("panel");
+	char const *e = env_get("panel");
 
 	if (e) {
 		if (strcmp(e, "seiko") == 0) {
diff --git a/board/freescale/mx6sabreauto/mx6sabreauto.c b/board/freescale/mx6sabreauto/mx6sabreauto.c
index a5703a3..f8f77f6 100644
--- a/board/freescale/mx6sabreauto/mx6sabreauto.c
+++ b/board/freescale/mx6sabreauto/mx6sabreauto.c
@@ -687,14 +687,14 @@
 #endif
 
 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
-	setenv("board_name", "SABREAUTO");
+	env_set("board_name", "SABREAUTO");
 
 	if (is_mx6dqp())
-		setenv("board_rev", "MX6QP");
+		env_set("board_rev", "MX6QP");
 	else if (is_mx6dq())
-		setenv("board_rev", "MX6Q");
+		env_set("board_rev", "MX6Q");
 	else if (is_mx6sdl())
-		setenv("board_rev", "MX6DL");
+		env_set("board_rev", "MX6DL");
 #endif
 
 	return 0;
@@ -806,8 +806,8 @@
 	writel(0xF00000CF, &iomux->gpr[4]);
 	if (is_mx6dqp()) {
 		/* set IPU AXI-id1 Qos=0x1 AXI-id0/2/3 Qos=0x7 */
-		writel(0x007F007F, &iomux->gpr[6]);
-		writel(0x007F007F, &iomux->gpr[7]);
+		writel(0x77177717, &iomux->gpr[6]);
+		writel(0x77177717, &iomux->gpr[7]);
 	} else {
 		/* set IPU AXI-id0 Qos=0xf(bypass) AXI-id1 Qos=0x7 */
 		writel(0x007F007F, &iomux->gpr[6]);
diff --git a/board/freescale/mx6sabresd/mx6sabresd.c b/board/freescale/mx6sabresd/mx6sabresd.c
index e416042..9a562b3 100644
--- a/board/freescale/mx6sabresd/mx6sabresd.c
+++ b/board/freescale/mx6sabresd/mx6sabresd.c
@@ -700,14 +700,14 @@
 #endif
 
 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
-	setenv("board_name", "SABRESD");
+	env_set("board_name", "SABRESD");
 
 	if (is_mx6dqp())
-		setenv("board_rev", "MX6QP");
+		env_set("board_rev", "MX6QP");
 	else if (is_mx6dq())
-		setenv("board_rev", "MX6Q");
+		env_set("board_rev", "MX6Q");
 	else if (is_mx6sdl())
-		setenv("board_rev", "MX6DL");
+		env_set("board_rev", "MX6DL");
 #endif
 
 	return 0;
@@ -755,8 +755,8 @@
 	writel(0xF00000CF, &iomux->gpr[4]);
 	if (is_mx6dqp()) {
 		/* set IPU AXI-id1 Qos=0x1 AXI-id0/2/3 Qos=0x7 */
-		writel(0x007F007F, &iomux->gpr[6]);
-		writel(0x007F007F, &iomux->gpr[7]);
+		writel(0x77177717, &iomux->gpr[6]);
+		writel(0x77177717, &iomux->gpr[7]);
 	} else {
 		/* set IPU AXI-id0 Qos=0xf(bypass) AXI-id1 Qos=0x7 */
 		writel(0x007F007F, &iomux->gpr[6]);
diff --git a/board/freescale/mx6ul_14x14_evk/mx6ul_14x14_evk.c b/board/freescale/mx6ul_14x14_evk/mx6ul_14x14_evk.c
index a30c379..cf7a069 100644
--- a/board/freescale/mx6ul_14x14_evk/mx6ul_14x14_evk.c
+++ b/board/freescale/mx6ul_14x14_evk/mx6ul_14x14_evk.c
@@ -674,12 +674,12 @@
 #endif
 
 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
-	setenv("board_name", "EVK");
+	env_set("board_name", "EVK");
 
 	if (is_mx6ul_9x9_evk())
-		setenv("board_rev", "9X9");
+		env_set("board_rev", "9X9");
 	else
-		setenv("board_rev", "14X14");
+		env_set("board_rev", "14X14");
 #endif
 
 	return 0;
diff --git a/board/freescale/mx6ullevk/mx6ullevk.c b/board/freescale/mx6ullevk/mx6ullevk.c
index 66b08f8..cebcec7 100644
--- a/board/freescale/mx6ullevk/mx6ullevk.c
+++ b/board/freescale/mx6ullevk/mx6ullevk.c
@@ -84,8 +84,8 @@
 #endif
 
 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
-	setenv("board_name", "EVK");
-	setenv("board_rev", "14X14");
+	env_set("board_name", "EVK");
+	env_set("board_rev", "14X14");
 #endif
 
 	return 0;
diff --git a/board/freescale/p1010rdb/p1010rdb.c b/board/freescale/p1010rdb/p1010rdb.c
index 65bb575..aa04e99 100644
--- a/board/freescale/p1010rdb/p1010rdb.c
+++ b/board/freescale/p1010rdb/p1010rdb.c
@@ -453,8 +453,8 @@
 
 	ft_cpu_setup(blob, bd);
 
-	base = getenv_bootm_low();
-	size = getenv_bootm_size();
+	base = env_get_bootm_low();
+	size = env_get_bootm_size();
 
 #if defined(CONFIG_PCI)
 	FT_FSL_PCI_SETUP;
diff --git a/board/freescale/p1010rdb/spl.c b/board/freescale/p1010rdb/spl.c
index 2cebc2c..0013088 100644
--- a/board/freescale/p1010rdb/spl.c
+++ b/board/freescale/p1010rdb/spl.c
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <console.h>
+#include <environment.h>
 #include <ns16550.h>
 #include <malloc.h>
 #include <mmc.h>
@@ -87,7 +88,7 @@
 	nand_spl_load_image(CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE,
 			    (uchar *)CONFIG_ENV_ADDR);
 			    gd->env_addr  = (ulong)(CONFIG_ENV_ADDR);
-	gd->env_valid = 1;
+	gd->env_valid = ENV_VALID;
 #else
 	env_relocate();
 #endif
diff --git a/board/freescale/p1022ds/p1022ds.c b/board/freescale/p1022ds/p1022ds.c
index 345feac..bf49326 100644
--- a/board/freescale/p1022ds/p1022ds.c
+++ b/board/freescale/p1022ds/p1022ds.c
@@ -339,8 +339,8 @@
 
 	ft_cpu_setup(blob, bd);
 
-	base = getenv_bootm_low();
-	size = getenv_bootm_size();
+	base = env_get_bootm_low();
+	size = env_get_bootm_size();
 
 	fdt_fixup_memory(blob, (u64)base, (u64)size);
 
diff --git a/board/freescale/p1022ds/spl.c b/board/freescale/p1022ds/spl.c
index a117dc3..94b357d 100644
--- a/board/freescale/p1022ds/spl.c
+++ b/board/freescale/p1022ds/spl.c
@@ -6,6 +6,7 @@
 
 #include <common.h>
 #include <console.h>
+#include <environment.h>
 #include <ns16550.h>
 #include <malloc.h>
 #include <mmc.h>
@@ -100,7 +101,7 @@
 			    (uchar *)CONFIG_ENV_ADDR);
 
 	gd->env_addr  = (ulong)(CONFIG_ENV_ADDR);
-	gd->env_valid = 1;
+	gd->env_valid = ENV_VALID;
 #else
 	env_relocate();
 #endif
diff --git a/board/freescale/p1023rdb/p1023rdb.c b/board/freescale/p1023rdb/p1023rdb.c
index 0451722..ccda824 100644
--- a/board/freescale/p1023rdb/p1023rdb.c
+++ b/board/freescale/p1023rdb/p1023rdb.c
@@ -137,8 +137,8 @@
 
 	ft_cpu_setup(blob, bd);
 
-	base = getenv_bootm_low();
-	size = getenv_bootm_size();
+	base = env_get_bootm_low();
+	size = env_get_bootm_size();
 
 	fdt_fixup_memory(blob, (u64)base, (u64)size);
 
diff --git a/board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c b/board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c
index 51217c5..31c8ed9 100644
--- a/board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c
+++ b/board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c
@@ -350,7 +350,8 @@
 
 #ifdef CONFIG_VSC7385_ENET
 	/* If a VSC7385 microcode image is present, then upload it. */
-	if ((tmp = getenv("vscfw_addr")) != NULL) {
+	tmp = env_get("vscfw_addr");
+	if (tmp) {
 		vscfw_addr = simple_strtoul(tmp, NULL, 16);
 		printf("uploading VSC7385 microcode from %x\n", vscfw_addr);
 		if (vsc7385_upload_firmware((void *) vscfw_addr,
@@ -438,8 +439,8 @@
 
 	ft_cpu_setup(blob, bd);
 
-	base = getenv_bootm_low();
-	size = getenv_bootm_size();
+	base = env_get_bootm_low();
+	size = env_get_bootm_size();
 
 	fdt_fixup_memory(blob, (u64)base, (u64)size);
 
diff --git a/board/freescale/p1_p2_rdb_pc/spl.c b/board/freescale/p1_p2_rdb_pc/spl.c
index ca7ba57..c1d4c36 100644
--- a/board/freescale/p1_p2_rdb_pc/spl.c
+++ b/board/freescale/p1_p2_rdb_pc/spl.c
@@ -6,6 +6,7 @@
 
 #include <common.h>
 #include <console.h>
+#include <environment.h>
 #include <ns16550.h>
 #include <malloc.h>
 #include <mmc.h>
@@ -92,7 +93,7 @@
 	nand_spl_load_image(CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE,
 			    (uchar *)CONFIG_ENV_ADDR);
 	gd->env_addr  = (ulong)(CONFIG_ENV_ADDR);
-	gd->env_valid = 1;
+	gd->env_valid = ENV_VALID;
 #else
 	env_relocate();
 #endif
diff --git a/board/freescale/p1_twr/p1_twr.c b/board/freescale/p1_twr/p1_twr.c
index f54a6ff..02c8999 100644
--- a/board/freescale/p1_twr/p1_twr.c
+++ b/board/freescale/p1_twr/p1_twr.c
@@ -268,8 +268,8 @@
 
 	ft_cpu_setup(blob, bd);
 
-	base = getenv_bootm_low();
-	size = getenv_bootm_size();
+	base = env_get_bootm_low();
+	size = env_get_bootm_size();
 
 	fdt_fixup_memory(blob, (u64)base, (u64)size);
 
diff --git a/board/freescale/p2041rdb/p2041rdb.c b/board/freescale/p2041rdb/p2041rdb.c
index 21fb66f..78ee747 100644
--- a/board/freescale/p2041rdb/p2041rdb.c
+++ b/board/freescale/p2041rdb/p2041rdb.c
@@ -219,8 +219,8 @@
 
 	ft_cpu_setup(blob, bd);
 
-	base = getenv_bootm_low();
-	size = getenv_bootm_size();
+	base = env_get_bootm_low();
+	size = env_get_bootm_size();
 
 	fdt_fixup_memory(blob, (u64)base, (u64)size);
 
diff --git a/board/freescale/qemu-ppce500/qemu-ppce500.c b/board/freescale/qemu-ppce500/qemu-ppce500.c
index 0c65ec7..cf5023c 100644
--- a/board/freescale/qemu-ppce500/qemu-ppce500.c
+++ b/board/freescale/qemu-ppce500/qemu-ppce500.c
@@ -211,10 +211,10 @@
 	/* -kernel boot */
 	prop = fdt_getprop(fdt, chosen, "qemu,boot-kernel", &len);
 	if (prop && (len >= 8))
-		setenv_hex("qemu_kernel_addr", *prop);
+		env_set_hex("qemu_kernel_addr", *prop);
 
 	/* Give the user a variable for the host fdt */
-	setenv_hex("fdt_addr_r", (ulong)fdt);
+	env_set_hex("fdt_addr_r", (ulong)fdt);
 
 	return 0;
 }
diff --git a/board/freescale/t102xqds/spl.c b/board/freescale/t102xqds/spl.c
index b987ece..3aa19e6 100644
--- a/board/freescale/t102xqds/spl.c
+++ b/board/freescale/t102xqds/spl.c
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <console.h>
+#include <environment.h>
 #include <malloc.h>
 #include <ns16550.h>
 #include <nand.h>
@@ -138,7 +139,7 @@
 #endif
 
 	gd->env_addr  = (ulong)(CONFIG_ENV_ADDR);
-	gd->env_valid = 1;
+	gd->env_valid = ENV_VALID;
 
 	i2c_init_all();
 
diff --git a/board/freescale/t102xqds/t102xqds.c b/board/freescale/t102xqds/t102xqds.c
index 1b2f6b2..20374ba 100644
--- a/board/freescale/t102xqds/t102xqds.c
+++ b/board/freescale/t102xqds/t102xqds.c
@@ -363,8 +363,8 @@
 
 	ft_cpu_setup(blob, bd);
 
-	base = getenv_bootm_low();
-	size = getenv_bootm_size();
+	base = env_get_bootm_low();
+	size = env_get_bootm_size();
 
 	fdt_fixup_memory(blob, (u64)base, (u64)size);
 
diff --git a/board/freescale/t102xrdb/spl.c b/board/freescale/t102xrdb/spl.c
index dc6d9ee..ca1e49f 100644
--- a/board/freescale/t102xrdb/spl.c
+++ b/board/freescale/t102xrdb/spl.c
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <console.h>
+#include <environment.h>
 #include <malloc.h>
 #include <ns16550.h>
 #include <nand.h>
@@ -125,7 +126,7 @@
 #endif
 
 	gd->env_addr  = (ulong)(CONFIG_ENV_ADDR);
-	gd->env_valid = 1;
+	gd->env_valid = ENV_VALID;
 
 	i2c_init_all();
 
diff --git a/board/freescale/t102xrdb/t102xrdb.c b/board/freescale/t102xrdb/t102xrdb.c
index f370f72..8885a54 100644
--- a/board/freescale/t102xrdb/t102xrdb.c
+++ b/board/freescale/t102xrdb/t102xrdb.c
@@ -186,8 +186,8 @@
 
 	ft_cpu_setup(blob, bd);
 
-	base = getenv_bootm_low();
-	size = getenv_bootm_size();
+	base = env_get_bootm_low();
+	size = env_get_bootm_size();
 
 	fdt_fixup_memory(blob, (u64)base, (u64)size);
 
diff --git a/board/freescale/t1040qds/t1040qds.c b/board/freescale/t1040qds/t1040qds.c
index 5466fbf..a36997b 100644
--- a/board/freescale/t1040qds/t1040qds.c
+++ b/board/freescale/t1040qds/t1040qds.c
@@ -245,8 +245,8 @@
 
 	ft_cpu_setup(blob, bd);
 
-	base = getenv_bootm_low();
-	size = getenv_bootm_size();
+	base = env_get_bootm_low();
+	size = env_get_bootm_size();
 
 	fdt_fixup_memory(blob, (u64)base, (u64)size);
 
diff --git a/board/freescale/t104xrdb/spl.c b/board/freescale/t104xrdb/spl.c
index 2e43307..4fb9323 100644
--- a/board/freescale/t104xrdb/spl.c
+++ b/board/freescale/t104xrdb/spl.c
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <console.h>
+#include <environment.h>
 #include <malloc.h>
 #include <ns16550.h>
 #include <nand.h>
@@ -119,7 +120,7 @@
 			       (uchar *)CONFIG_ENV_ADDR);
 #endif
 	gd->env_addr  = (ulong)(CONFIG_ENV_ADDR);
-	gd->env_valid = 1;
+	gd->env_valid = ENV_VALID;
 
 	i2c_init_all();
 
diff --git a/board/freescale/t104xrdb/t104xrdb.c b/board/freescale/t104xrdb/t104xrdb.c
index d4c3d4d..2818cdf 100644
--- a/board/freescale/t104xrdb/t104xrdb.c
+++ b/board/freescale/t104xrdb/t104xrdb.c
@@ -132,8 +132,8 @@
 
 	ft_cpu_setup(blob, bd);
 
-	base = getenv_bootm_low();
-	size = getenv_bootm_size();
+	base = env_get_bootm_low();
+	size = env_get_bootm_size();
 
 	fdt_fixup_memory(blob, (u64)base, (u64)size);
 
diff --git a/board/freescale/t208xqds/spl.c b/board/freescale/t208xqds/spl.c
index d7d716b..36961dc 100644
--- a/board/freescale/t208xqds/spl.c
+++ b/board/freescale/t208xqds/spl.c
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <console.h>
+#include <environment.h>
 #include <malloc.h>
 #include <ns16550.h>
 #include <nand.h>
@@ -124,7 +125,7 @@
 #endif
 
 	gd->env_addr  = (ulong)(CONFIG_ENV_ADDR);
-	gd->env_valid = 1;
+	gd->env_valid = ENV_VALID;
 
 	i2c_init_all();
 
diff --git a/board/freescale/t208xqds/t208xqds.c b/board/freescale/t208xqds/t208xqds.c
index 26093ea..ed3d3f4 100644
--- a/board/freescale/t208xqds/t208xqds.c
+++ b/board/freescale/t208xqds/t208xqds.c
@@ -451,8 +451,8 @@
 
 	ft_cpu_setup(blob, bd);
 
-	base = getenv_bootm_low();
-	size = getenv_bootm_size();
+	base = env_get_bootm_low();
+	size = env_get_bootm_size();
 
 	fdt_fixup_memory(blob, (u64)base, (u64)size);
 
diff --git a/board/freescale/t208xrdb/spl.c b/board/freescale/t208xrdb/spl.c
index b431401..f0cc34d 100644
--- a/board/freescale/t208xrdb/spl.c
+++ b/board/freescale/t208xrdb/spl.c
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <console.h>
+#include <environment.h>
 #include <malloc.h>
 #include <ns16550.h>
 #include <nand.h>
@@ -94,7 +95,7 @@
 #endif
 
 	gd->env_addr  = (ulong)(CONFIG_ENV_ADDR);
-	gd->env_valid = 1;
+	gd->env_valid = ENV_VALID;
 
 	i2c_init_all();
 
diff --git a/board/freescale/t208xrdb/t208xrdb.c b/board/freescale/t208xrdb/t208xrdb.c
index 1ab05ec..619495e 100644
--- a/board/freescale/t208xrdb/t208xrdb.c
+++ b/board/freescale/t208xrdb/t208xrdb.c
@@ -118,8 +118,8 @@
 
 	ft_cpu_setup(blob, bd);
 
-	base = getenv_bootm_low();
-	size = getenv_bootm_size();
+	base = env_get_bootm_low();
+	size = env_get_bootm_size();
 
 	fdt_fixup_memory(blob, (u64)base, (u64)size);
 
diff --git a/board/freescale/t4qds/spl.c b/board/freescale/t4qds/spl.c
index 9ecdaed..750f155 100644
--- a/board/freescale/t4qds/spl.c
+++ b/board/freescale/t4qds/spl.c
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <console.h>
+#include <environment.h>
 #include <asm/spl.h>
 #include <malloc.h>
 #include <ns16550.h>
@@ -129,7 +130,7 @@
 #endif
 
 	gd->env_addr  = (ulong)(CONFIG_ENV_ADDR);
-	gd->env_valid = 1;
+	gd->env_valid = ENV_VALID;
 
 	i2c_init_all();
 
diff --git a/board/freescale/t4qds/t4240emu.c b/board/freescale/t4qds/t4240emu.c
index 35ad19e..7136aca 100644
--- a/board/freescale/t4qds/t4240emu.c
+++ b/board/freescale/t4qds/t4240emu.c
@@ -70,8 +70,8 @@
 
 	ft_cpu_setup(blob, bd);
 
-	base = getenv_bootm_low();
-	size = getenv_bootm_size();
+	base = env_get_bootm_low();
+	size = env_get_bootm_size();
 
 	fdt_fixup_memory(blob, (u64)base, (u64)size);
 
diff --git a/board/freescale/t4qds/t4240qds.c b/board/freescale/t4qds/t4240qds.c
index 8f9e7e8..7b71b54 100644
--- a/board/freescale/t4qds/t4240qds.c
+++ b/board/freescale/t4qds/t4240qds.c
@@ -265,7 +265,7 @@
 	vdd_target = vdd[vid];
 
 	/* check override variable for overriding VDD */
-	vdd_string = getenv("t4240qds_vdd_mv");
+	vdd_string = env_get("t4240qds_vdd_mv");
 	if (vdd_override == 0 && vdd_string &&
 	    !strict_strtoul(vdd_string, 10, &vdd_string_override))
 		vdd_override = vdd_string_override;
@@ -684,8 +684,8 @@
 
 	ft_cpu_setup(blob, bd);
 
-	base = getenv_bootm_low();
-	size = getenv_bootm_size();
+	base = env_get_bootm_low();
+	size = env_get_bootm_size();
 
 	fdt_fixup_memory(blob, (u64)base, (u64)size);
 
diff --git a/board/freescale/t4rdb/spl.c b/board/freescale/t4rdb/spl.c
index 5feab1c..932954e 100644
--- a/board/freescale/t4rdb/spl.c
+++ b/board/freescale/t4rdb/spl.c
@@ -8,6 +8,7 @@
 
 #include <common.h>
 #include <console.h>
+#include <environment.h>
 #include <asm/spl.h>
 #include <malloc.h>
 #include <ns16550.h>
@@ -87,7 +88,7 @@
 			   (uchar *)CONFIG_ENV_ADDR);
 
 	gd->env_addr  = (ulong)(CONFIG_ENV_ADDR);
-	gd->env_valid = 1;
+	gd->env_valid = ENV_VALID;
 
 	i2c_init_all();
 
diff --git a/board/freescale/t4rdb/t4240rdb.c b/board/freescale/t4rdb/t4240rdb.c
index bdd6f4e..f511706 100644
--- a/board/freescale/t4rdb/t4240rdb.c
+++ b/board/freescale/t4rdb/t4240rdb.c
@@ -97,8 +97,8 @@
 
 	ft_cpu_setup(blob, bd);
 
-	base = getenv_bootm_low();
-	size = getenv_bootm_size();
+	base = env_get_bootm_low();
+	size = env_get_bootm_size();
 
 	fdt_fixup_memory(blob, (u64)base, (u64)size);
 
diff --git a/board/gateworks/gw_ventana/common.c b/board/gateworks/gw_ventana/common.c
index 46404b4..e9865b4 100644
--- a/board/gateworks/gw_ventana/common.c
+++ b/board/gateworks/gw_ventana/common.c
@@ -1160,7 +1160,7 @@
 	char arg[10];
 	size_t len;
 	int i;
-	int quiet = simple_strtol(getenv("quiet"), NULL, 10);
+	int quiet = simple_strtol(env_get("quiet"), NULL, 10);
 
 	if (board >= GW_UNKNOWN)
 		return;
diff --git a/board/gateworks/gw_ventana/gw_ventana.c b/board/gateworks/gw_ventana/gw_ventana.c
index 89848c8..4ddc7e1 100644
--- a/board/gateworks/gw_ventana/gw_ventana.c
+++ b/board/gateworks/gw_ventana/gw_ventana.c
@@ -298,11 +298,11 @@
 #endif
 
 	/* default to the first detected enet dev */
-	if (!getenv("ethprime")) {
+	if (!env_get("ethprime")) {
 		struct eth_device *dev = eth_get_dev_by_index(0);
 		if (dev) {
-			setenv("ethprime", dev->name);
-			printf("set ethprime to %s\n", getenv("ethprime"));
+			env_set("ethprime", dev->name);
+			printf("set ethprime to %s\n", env_get("ethprime"));
 		}
 	}
 
@@ -579,7 +579,7 @@
  */
 void get_board_serial(struct tag_serialnr *serialnr)
 {
-	char *serial = getenv("serial#");
+	char *serial = env_get("serial#");
 
 	if (serial) {
 		serialnr->high = 0;
@@ -658,11 +658,11 @@
 	int quiet; /* Quiet or minimal output mode */
 
 	quiet = 0;
-	p = getenv("quiet");
+	p = env_get("quiet");
 	if (p)
 		quiet = simple_strtol(p, NULL, 10);
 	else
-		setenv("quiet", "0");
+		env_set("quiet", "0");
 
 	puts("\nGateworks Corporation Copyright 2014\n");
 	if (info->model[0]) {
@@ -737,26 +737,26 @@
 		else if (is_cpu_type(MXC_CPU_MX6DL) ||
 			 is_cpu_type(MXC_CPU_MX6SOLO))
 			cputype = "imx6dl";
-		setenv("soctype", cputype);
+		env_set("soctype", cputype);
 		if (8 << (ventana_info.nand_flash_size-1) >= 2048)
-			setenv("flash_layout", "large");
+			env_set("flash_layout", "large");
 		else
-			setenv("flash_layout", "normal");
+			env_set("flash_layout", "normal");
 		memset(str, 0, sizeof(str));
 		for (i = 0; i < (sizeof(str)-1) && info->model[i]; i++)
 			str[i] = tolower(info->model[i]);
-		setenv("model", str);
-		if (!getenv("fdt_file")) {
+		env_set("model", str);
+		if (!env_get("fdt_file")) {
 			sprintf(fdt, "%s-%s.dtb", cputype, str);
-			setenv("fdt_file", fdt);
+			env_set("fdt_file", fdt);
 		}
 		p = strchr(str, '-');
 		if (p) {
 			*p++ = 0;
 
-			setenv("model_base", str);
+			env_set("model_base", str);
 			sprintf(fdt, "%s-%s.dtb", cputype, str);
-			setenv("fdt_file1", fdt);
+			env_set("fdt_file1", fdt);
 			if (board_type != GW551x &&
 			    board_type != GW552x &&
 			    board_type != GW553x &&
@@ -765,30 +765,30 @@
 			str[5] = 'x';
 			str[6] = 0;
 			sprintf(fdt, "%s-%s.dtb", cputype, str);
-			setenv("fdt_file2", fdt);
+			env_set("fdt_file2", fdt);
 		}
 
 		/* initialize env from EEPROM */
 		if (test_bit(EECONFIG_ETH0, info->config) &&
-		    !getenv("ethaddr")) {
-			eth_setenv_enetaddr("ethaddr", info->mac0);
+		    !env_get("ethaddr")) {
+			eth_env_set_enetaddr("ethaddr", info->mac0);
 		}
 		if (test_bit(EECONFIG_ETH1, info->config) &&
-		    !getenv("eth1addr")) {
-			eth_setenv_enetaddr("eth1addr", info->mac1);
+		    !env_get("eth1addr")) {
+			eth_env_set_enetaddr("eth1addr", info->mac1);
 		}
 
 		/* board serial-number */
 		sprintf(str, "%6d", info->serial);
-		setenv("serial#", str);
+		env_set("serial#", str);
 
 		/* memory MB */
 		sprintf(str, "%d", (int) (gd->ram_size >> 20));
-		setenv("mem_mb", str);
+		env_set("mem_mb", str);
 	}
 
 	/* Set a non-initialized hwconfig based on board configuration */
-	if (!strcmp(getenv("hwconfig"), "_UNKNOWN_")) {
+	if (!strcmp(env_get("hwconfig"), "_UNKNOWN_")) {
 		buf[0] = 0;
 		if (gpio_cfg[board_type].rs232_en)
 			strcat(buf, "rs232;");
@@ -798,7 +798,7 @@
 			if (strlen(buf) + strlen(buf1) < sizeof(buf))
 				strcat(buf, buf1);
 		}
-		setenv("hwconfig", buf);
+		env_set("hwconfig", buf);
 	}
 
 	/* setup baseboard specific GPIO based on board and env */
@@ -1035,7 +1035,7 @@
 	int j;
 
 	sprintf(mac, "eth1addr");
-	tmp = getenv(mac);
+	tmp = env_get(mac);
 	if (tmp) {
 		for (j = 0; j < 6; j++) {
 			mac_addr[j] = tmp ?
@@ -1118,8 +1118,8 @@
 		{ "sst,w25q256",          MTD_DEV_TYPE_NOR, },  /* SPI flash */
 		{ "fsl,imx6q-gpmi-nand",  MTD_DEV_TYPE_NAND, }, /* NAND flash */
 	};
-	const char *model = getenv("model");
-	const char *display = getenv("display");
+	const char *model = env_get("model");
+	const char *display = env_get("display");
 	int i;
 	char rev = 0;
 
@@ -1131,7 +1131,7 @@
 		}
 	}
 
-	if (getenv("fdt_noauto")) {
+	if (env_get("fdt_noauto")) {
 		puts("   Skiping ft_board_setup (fdt_noauto defined)\n");
 		return 0;
 	}
@@ -1152,15 +1152,15 @@
 	printf("   Adjusting FDT per EEPROM for %s...\n", model);
 
 	/* board serial number */
-	fdt_setprop(blob, 0, "system-serial", getenv("serial#"),
-		    strlen(getenv("serial#")) + 1);
+	fdt_setprop(blob, 0, "system-serial", env_get("serial#"),
+		    strlen(env_get("serial#")) + 1);
 
 	/* board (model contains model from device-tree) */
 	fdt_setprop(blob, 0, "board", info->model,
 		    strlen((const char *)info->model) + 1);
 
 	/* set desired digital video capture format */
-	ft_sethdmiinfmt(blob, getenv("hdmiinfmt"));
+	ft_sethdmiinfmt(blob, env_get("hdmiinfmt"));
 
 	/*
 	 * Board model specific fixups
@@ -1315,7 +1315,7 @@
 	}
 
 #if defined(CONFIG_CMD_PCI)
-	if (!getenv("nopcifixup"))
+	if (!env_get("nopcifixup"))
 		ft_board_pci_fixup(blob, bd);
 #endif
 
@@ -1324,7 +1324,7 @@
 	 *  remove nodes by alias path if EEPROM config tells us the
 	 *  peripheral is not loaded on the board.
 	 */
-	if (getenv("fdt_noconfig")) {
+	if (env_get("fdt_noconfig")) {
 		puts("   Skiping periperhal config (fdt_noconfig defined)\n");
 		return 0;
 	}
diff --git a/board/gateworks/gw_ventana/gw_ventana_spl.c b/board/gateworks/gw_ventana/gw_ventana_spl.c
index 69a638d..9524da7 100644
--- a/board/gateworks/gw_ventana/gw_ventana_spl.c
+++ b/board/gateworks/gw_ventana/gw_ventana_spl.c
@@ -690,9 +690,9 @@
 	debug("%s\n", __func__);
 #ifdef CONFIG_SPL_ENV_SUPPORT
 	env_init();
-	env_relocate_spec();
-	debug("boot_os=%s\n", getenv("boot_os"));
-	if (getenv_yesno("boot_os") == 1)
+	env_load();
+	debug("boot_os=%s\n", env_get("boot_os"));
+	if (env_get_yesno("boot_os") == 1)
 		ret = 0;
 #else
 	/* use i2c-0:0x50:0x00 for falcon boot mode (0=linux, else uboot) */
diff --git a/board/gdsys/a38x/keyprogram.c b/board/gdsys/a38x/keyprogram.c
index a4a6f1c..d75e08b 100644
--- a/board/gdsys/a38x/keyprogram.c
+++ b/board/gdsys/a38x/keyprogram.c
@@ -129,12 +129,12 @@
 	char *hexprog;
 	struct key_program *prog;
 
-	cmd = getenv("loadkeyprogram");
+	cmd = env_get("loadkeyprogram");
 
 	if (!cmd || run_command(cmd, 0))
 		return 1;
 
-	hexprog = getenv("keyprogram");
+	hexprog = env_get("keyprogram");
 
 	if (decode_hexstr(hexprog, &binprog))
 		return 1;
diff --git a/board/gdsys/mpc8308/hrcon.c b/board/gdsys/mpc8308/hrcon.c
index c6566e9..7e48507 100644
--- a/board/gdsys/mpc8308/hrcon.c
+++ b/board/gdsys/mpc8308/hrcon.c
@@ -103,7 +103,7 @@
 
 int checkboard(void)
 {
-	char *s = getenv("serial#");
+	char *s = env_get("serial#");
 	bool hw_type_cat = pca9698_get_value(0x20, 20);
 
 	puts("Board: ");
diff --git a/board/gdsys/mpc8308/strider.c b/board/gdsys/mpc8308/strider.c
index 34e9d19..fec6915 100644
--- a/board/gdsys/mpc8308/strider.c
+++ b/board/gdsys/mpc8308/strider.c
@@ -106,7 +106,7 @@
 
 int checkboard(void)
 {
-	char *s = getenv("serial#");
+	char *s = env_get("serial#");
 	bool hw_type_cat = pca9698_get_value(0x20, 18);
 
 	puts("Board: ");
diff --git a/board/gdsys/p1022/controlcenterd-id.c b/board/gdsys/p1022/controlcenterd-id.c
index 95f11fb..1813a58 100644
--- a/board/gdsys/p1022/controlcenterd-id.c
+++ b/board/gdsys/p1022/controlcenterd-id.c
@@ -217,7 +217,7 @@
 {
 	ulong addr;
 #ifdef CCDM_SECOND_STAGE
-	addr = getenv_ulong("loadaddr", 16, CONFIG_LOADADDR);
+	addr = env_get_ulong("loadaddr", 16, CONFIG_LOADADDR);
 #else
 	addr = target_addr;
 #endif
@@ -235,7 +235,7 @@
 {
 	ulong addr;
 	/* TODO use other area? */
-	addr = getenv_ulong("loadaddr", 16, CONFIG_LOADADDR);
+	addr = env_get_ulong("loadaddr", 16, CONFIG_LOADADDR);
 	return (u8 *)(addr);
 }
 #endif
@@ -1043,13 +1043,13 @@
 		goto failure;
 
 	/* run "prepboot" from env to get "mmcdev" set */
-	cptr = getenv("prepboot");
+	cptr = env_get("prepboot");
 	if (cptr && !run_command(cptr, 0))
-		mmcdev = getenv("mmcdev");
+		mmcdev = env_get("mmcdev");
 	if (!mmcdev)
 		goto failure;
 
-	cptr = getenv("ramdiskimage");
+	cptr = env_get("ramdiskimage");
 	if (cptr)
 		image_path = cptr;
 
diff --git a/board/gdsys/p1022/controlcenterd.c b/board/gdsys/p1022/controlcenterd.c
index 01064dc..9fb814d 100644
--- a/board/gdsys/p1022/controlcenterd.c
+++ b/board/gdsys/p1022/controlcenterd.c
@@ -223,7 +223,7 @@
 #ifdef CONFIG_TRAILBLAZER
 int do_bootd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
-	return run_command(getenv("bootcmd"), flag);
+	return run_command(env_get("bootcmd"), flag);
 }
 
 int board_early_init_r(void)
@@ -335,8 +335,8 @@
 
 	ft_cpu_setup(blob, bd);
 
-	base = getenv_bootm_low();
-	size = getenv_bootm_size();
+	base = env_get_bootm_low();
+	size = env_get_bootm_size();
 
 	fdt_fixup_memory(blob, (u64)base, (u64)size);
 
diff --git a/board/grinn/chiliboard/board.c b/board/grinn/chiliboard/board.c
index e3f82b0..2f5974a 100644
--- a/board/grinn/chiliboard/board.c
+++ b/board/grinn/chiliboard/board.c
@@ -126,11 +126,11 @@
 	mac_addr[4] = mac_lo & 0xFF;
 	mac_addr[5] = (mac_lo & 0xFF00) >> 8;
 
-	if (!getenv("ethaddr")) {
+	if (!env_get("ethaddr")) {
 		printf("<ethaddr> not set. Validating first E-fuse MAC\n");
 
 		if (is_valid_ethaddr(mac_addr))
-			eth_setenv_enetaddr("ethaddr", mac_addr);
+			eth_env_set_enetaddr("ethaddr", mac_addr);
 	}
 
 	mac_lo = readl(&cdev->macid1l);
@@ -142,9 +142,9 @@
 	mac_addr[4] = mac_lo & 0xFF;
 	mac_addr[5] = (mac_lo & 0xFF00) >> 8;
 
-	if (!getenv("eth1addr")) {
+	if (!env_get("eth1addr")) {
 		if (is_valid_ethaddr(mac_addr))
-			eth_setenv_enetaddr("eth1addr", mac_addr);
+			eth_env_set_enetaddr("eth1addr", mac_addr);
 	}
 #endif
 
diff --git a/board/grinn/liteboard/board.c b/board/grinn/liteboard/board.c
index 817e22f..941e7ea 100644
--- a/board/grinn/liteboard/board.c
+++ b/board/grinn/liteboard/board.c
@@ -149,7 +149,7 @@
 
 static int check_mmc_autodetect(void)
 {
-	char *autodetect_str = getenv("mmcautodetect");
+	char *autodetect_str = env_get("mmcautodetect");
 
 	if ((autodetect_str != NULL) &&
 	    (strcmp(autodetect_str, "yes") == 0)) {
@@ -168,12 +168,12 @@
 	if (!check_mmc_autodetect())
 		return;
 
-	setenv_ulong("mmcdev", dev_no);
+	env_set_ulong("mmcdev", dev_no);
 
 	/* Set mmcblk env */
 	sprintf(mmcblk, "/dev/mmcblk%dp2 rootwait rw",
 		dev_no);
-	setenv("mmcroot", mmcblk);
+	env_set("mmcroot", mmcblk);
 
 	sprintf(cmd, "mmc dev %d", dev_no);
 	run_command(cmd, 0);
diff --git a/board/gumstix/pepper/board.c b/board/gumstix/pepper/board.c
index d76c28b..bfc5fd1 100644
--- a/board/gumstix/pepper/board.c
+++ b/board/gumstix/pepper/board.c
@@ -239,7 +239,7 @@
 	uint32_t mac_hi, mac_lo;
 	const char *devname;
 
-	if (!eth_getenv_enetaddr("ethaddr", mac_addr)) {
+	if (!eth_env_get_enetaddr("ethaddr", mac_addr)) {
 		/* try reading mac address from efuse */
 		mac_lo = readl(&cdev->macid0l);
 		mac_hi = readl(&cdev->macid0h);
@@ -250,7 +250,7 @@
 		mac_addr[4] = mac_lo & 0xFF;
 		mac_addr[5] = (mac_lo & 0xFF00) >> 8;
 		if (is_valid_ethaddr(mac_addr))
-			eth_setenv_enetaddr("ethaddr", mac_addr);
+			eth_env_set_enetaddr("ethaddr", mac_addr);
 	}
 
 	writel((RGMII_MODE_ENABLE | RGMII_INT_DELAY), &cdev->miisel);
diff --git a/board/highbank/highbank.c b/board/highbank/highbank.c
index 1af2207..f7c05ab 100644
--- a/board/highbank/highbank.c
+++ b/board/highbank/highbank.c
@@ -80,11 +80,11 @@
 
 	boot_choice = readl(HB_SREG_A9_BOOT_SRC_STAT) & 0xff;
 	sprintf(envbuffer, "bootcmd%d", boot_choice);
-	if (getenv(envbuffer)) {
+	if (env_get(envbuffer)) {
 		sprintf(envbuffer, "run bootcmd%d", boot_choice);
-		setenv("bootcmd", envbuffer);
+		env_set("bootcmd", envbuffer);
 	} else
-		setenv("bootcmd", "");
+		env_set("bootcmd", "");
 
 	return 0;
 }
diff --git a/board/htkw/mcx/mcx.c b/board/htkw/mcx/mcx.c
index 1deb2bd..0a02e44 100644
--- a/board/htkw/mcx/mcx.c
+++ b/board/htkw/mcx/mcx.c
@@ -83,7 +83,7 @@
 	if (gpio_get_value(HOT_WATER_BUTTON))
 		return 0;
 
-	setenv("bootcmd", "run swupdate");
+	env_set("bootcmd", "run swupdate");
 
 	return 0;
 }
diff --git a/board/intel/edison/edison.c b/board/intel/edison/edison.c
index a1a7d4d..4b1e6d0 100644
--- a/board/intel/edison/edison.c
+++ b/board/intel/edison/edison.c
@@ -5,6 +5,7 @@
  */
 #include <common.h>
 #include <dwc3-uboot.h>
+#include <environment.h>
 #include <mmc.h>
 #include <u-boot/md5.h>
 #include <usb.h>
@@ -63,14 +64,14 @@
 
 	snprintf(usb0addr, sizeof(usb0addr), "02:00:86:%02x:%02x:%02x",
 		 ssn[13], ssn[14], ssn[15]);
-	setenv("usb0addr", usb0addr);
+	env_set("usb0addr", usb0addr);
 
 	for (i = 0; i < 16; i++)
 		snprintf(&serial[2 * i], 3, "%02x", ssn[i]);
-	setenv("serial#", serial);
+	env_set("serial#", serial);
 
 #if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE)
-	saveenv();
+	env_save();
 #endif
 }
 
@@ -85,19 +86,19 @@
 		printf("Can't retrieve hardware revision\n");
 
 	snprintf(hardware_id, sizeof(hardware_id), "%02X", v.hardware_id);
-	setenv("hardware_id", hardware_id);
+	env_set("hardware_id", hardware_id);
 
 #if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE)
-	saveenv();
+	env_save();
 #endif
 }
 
 int board_late_init(void)
 {
-	if (!getenv("serial#"))
+	if (!env_get("serial#"))
 		assign_serial();
 
-	if (!getenv("hardware_id"))
+	if (!env_get("hardware_id"))
 		assign_hardware_id();
 
 	return 0;
diff --git a/board/isee/igep003x/board.c b/board/isee/igep003x/board.c
index e33170d..d33dc96 100644
--- a/board/isee/igep003x/board.c
+++ b/board/isee/igep003x/board.c
@@ -194,13 +194,13 @@
 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
 	switch (get_board_revision()) {
 		case 0:
-			setenv("board_name", "igep0034-lite");
+			env_set("board_name", "igep0034-lite");
 			break;
 		case 1:
-			setenv("board_name", "igep0034");
+			env_set("board_name", "igep0034");
 			break;
 		default:
-			setenv("board_name", "igep0033");
+			env_set("board_name", "igep0033");
 			break;
 	}
 #endif
@@ -264,7 +264,7 @@
 	uint8_t mac_addr[6];
 	uint32_t mac_hi, mac_lo;
 
-	if (!eth_getenv_enetaddr("ethaddr", mac_addr)) {
+	if (!eth_env_get_enetaddr("ethaddr", mac_addr)) {
 		/* try reading mac address from efuse */
 		mac_lo = readl(&cdev->macid0l);
 		mac_hi = readl(&cdev->macid0h);
@@ -275,7 +275,7 @@
 		mac_addr[4] = mac_lo & 0xFF;
 		mac_addr[5] = (mac_lo & 0xFF00) >> 8;
 		if (is_valid_ethaddr(mac_addr))
-			eth_setenv_enetaddr("ethaddr", mac_addr);
+			eth_env_set_enetaddr("ethaddr", mac_addr);
 	}
 
 	writel((GMII1_SEL_RMII | RMII1_IO_CLK_EN),
diff --git a/board/isee/igep00x0/igep00x0.c b/board/isee/igep00x0/igep00x0.c
index 843d35e..a7a7560 100644
--- a/board/isee/igep00x0/igep00x0.c
+++ b/board/isee/igep00x0/igep00x0.c
@@ -251,10 +251,10 @@
 {
 	switch (gd->bd->bi_arch_number) {
 	case MACH_TYPE_IGEP0020:
-		setenv("fdtfile", "omap3-igep0020.dtb");
+		env_set("fdtfile", "omap3-igep0020.dtb");
 		break;
 	case MACH_TYPE_IGEP0030:
-		setenv("fdtfile", "omap3-igep0030.dtb");
+		env_set("fdtfile", "omap3-igep0030.dtb");
 		break;
 	}
 }
diff --git a/board/keymile/common/common.c b/board/keymile/common/common.c
index 408079c..6cd2812 100644
--- a/board/keymile/common/common.c
+++ b/board/keymile/common/common.c
@@ -51,24 +51,24 @@
 	pnvramaddr = gd->ram_size - CONFIG_KM_RESERVED_PRAM - CONFIG_KM_PHRAM
 			- CONFIG_KM_PNVRAM;
 	sprintf((char *)buf, "0x%x", pnvramaddr);
-	setenv("pnvramaddr", (char *)buf);
+	env_set("pnvramaddr", (char *)buf);
 
 	/* try to read rootfssize (ram image) from environment */
-	p = getenv("rootfssize");
+	p = env_get("rootfssize");
 	if (p != NULL)
 		strict_strtoul(p, 16, &rootfssize);
 	pram = (rootfssize + CONFIG_KM_RESERVED_PRAM + CONFIG_KM_PHRAM +
 		CONFIG_KM_PNVRAM) / 0x400;
 	sprintf((char *)buf, "0x%x", pram);
-	setenv("pram", (char *)buf);
+	env_set("pram", (char *)buf);
 
 	varaddr = gd->ram_size - CONFIG_KM_RESERVED_PRAM - CONFIG_KM_PHRAM;
 	sprintf((char *)buf, "0x%x", varaddr);
-	setenv("varaddr", (char *)buf);
+	env_set("varaddr", (char *)buf);
 
 	kernelmem = gd->ram_size - 0x400 * pram;
 	sprintf((char *)buf, "0x%x", kernelmem);
-	setenv("kernelmem", (char *)buf);
+	env_set("kernelmem", (char *)buf);
 
 	return 0;
 }
@@ -169,7 +169,7 @@
 		return 1;
 	}
 	strcpy((char *)buf, p);
-	setenv("boardid", (char *)buf);
+	env_set("boardid", (char *)buf);
 	printf("set boardid=%s\n", buf);
 
 	p = get_local_var("IVM_HWKey");
@@ -178,7 +178,7 @@
 		return 1;
 	}
 	strcpy((char *)buf, p);
-	setenv("hwkey", (char *)buf);
+	env_set("hwkey", (char *)buf);
 	printf("set hwkey=%s\n", buf);
 	printf("Execute manually saveenv for persistent storage.\n");
 
@@ -236,10 +236,10 @@
 	}
 
 	/* now try to read values from environment if available */
-	p = getenv("boardid");
+	p = env_get("boardid");
 	if (p != NULL)
 		rc = strict_strtoul(p, 16, &envbid);
-	p = getenv("hwkey");
+	p = env_get("hwkey");
 	if (p != NULL)
 		rc = strict_strtoul(p, 16, &envhwkey);
 
@@ -253,7 +253,7 @@
 		 * BoardId/HWkey not available in the environment, so try the
 		 * environment variable for BoardId/HWkey list
 		 */
-		char *bidhwklist = getenv("boardIdListHex");
+		char *bidhwklist = env_get("boardIdListHex");
 
 		if (bidhwklist) {
 			int found = 0;
@@ -311,9 +311,9 @@
 					envbid   = bid;
 					envhwkey = hwkey;
 					sprintf(buf, "%lx", bid);
-					setenv("boardid", buf);
+					env_set("boardid", buf);
 					sprintf(buf, "%lx", hwkey);
-					setenv("hwkey", buf);
+					env_set("hwkey", buf);
 				}
 			} /* end while( ! found ) */
 		}
@@ -355,7 +355,7 @@
 #if defined(CONFIG_POST)
 	testpin = post_hotkeys_pressed();
 #endif
-	s = getenv("test_bank");
+	s = env_get("test_bank");
 	/* when test_bank is not set, act as if testpin is not asserted */
 	testboot = (testpin != 0) && (s);
 	if (verbose) {
diff --git a/board/keymile/common/ivm.c b/board/keymile/common/ivm.c
index e9e518c..f1321d9 100644
--- a/board/keymile/common/ivm.c
+++ b/board/keymile/common/ivm.c
@@ -261,7 +261,7 @@
 
 	GET_STRING("IVM_Symbol", IVM_POS_SYMBOL_ONLY, 8)
 	GET_STRING("IVM_DeviceName", IVM_POS_SHORT_TEXT, 64)
-	tmp = (unsigned char *) getenv("IVM_DeviceName");
+	tmp = (unsigned char *)env_get("IVM_DeviceName");
 	if (tmp) {
 		int	len = strlen((char *)tmp);
 		int	i = 0;
@@ -310,11 +310,11 @@
 #ifndef CONFIG_KMTEGR1
 	/* if an offset is defined, add it */
 	process_mac(valbuf, page2, CONFIG_PIGGY_MAC_ADRESS_OFFSET, true);
-	setenv((char *)"ethaddr", (char *)valbuf);
+	env_set((char *)"ethaddr", (char *)valbuf);
 #ifdef CONFIG_KMVECT1
 /* KMVECT1 has two ethernet interfaces */
 	process_mac(valbuf, page2, 1, true);
-	setenv((char *)"eth1addr", (char *)valbuf);
+	env_set((char *)"eth1addr", (char *)valbuf);
 #endif
 #else
 /* KMTEGR1 has a special setup. eth0 has no connection to the outside and
@@ -322,9 +322,9 @@
  * gets the official MAC address from the IVM
  */
 	process_mac(valbuf, page2, CONFIG_PIGGY_MAC_ADRESS_OFFSET, false);
-	setenv((char *)"ethaddr", (char *)valbuf);
+	env_set((char *)"ethaddr", (char *)valbuf);
 	process_mac(valbuf, page2, CONFIG_PIGGY_MAC_ADRESS_OFFSET, true);
-	setenv((char *)"eth1addr", (char *)valbuf);
+	env_set((char *)"eth1addr", (char *)valbuf);
 #endif
 
 	return 0;
diff --git a/board/keymile/km83xx/km83xx.c b/board/keymile/km83xx/km83xx.c
index 8020c37..5e07faa 100644
--- a/board/keymile/km83xx/km83xx.c
+++ b/board/keymile/km83xx/km83xx.c
@@ -263,11 +263,11 @@
 	mv88e_sw_reset(name, CONFIG_KM_MVEXTSW_ADDR);
 
 	if (piggy_present()) {
-		setenv("ethact", "UEC2");
-		setenv("netdev", "eth1");
+		env_set("ethact", "UEC2");
+		env_set("netdev", "eth1");
 		puts("using PIGGY for network boot\n");
 	} else {
-		setenv("netdev", "eth0");
+		env_set("netdev", "eth0");
 		puts("using frontport for network boot\n");
 	}
 #endif
@@ -280,7 +280,7 @@
 	if (dip_switch != 0) {
 		/* start bootloader */
 		puts("DIP:   Enabled\n");
-		setenv("actual_bank", "0");
+		env_set("actual_bank", "0");
 	}
 #endif
 	set_km_env();
diff --git a/board/keymile/km_arm/km_arm.c b/board/keymile/km_arm/km_arm.c
index 85785ff..af1ebc4 100644
--- a/board/keymile/km_arm/km_arm.c
+++ b/board/keymile/km_arm/km_arm.c
@@ -193,7 +193,7 @@
 	unsigned int bootcountaddr;
 	bootcountaddr = gd->ram_size - BOOTCOUNT_ADDR;
 	sprintf((char *)buf, "0x%x", bootcountaddr);
-	setenv("bootcountaddr", (char *)buf);
+	env_set("bootcountaddr", (char *)buf);
 }
 
 int misc_init_r(void)
@@ -201,7 +201,7 @@
 #if defined(CONFIG_KM_MGCOGE3UN)
 	char *wait_for_ne;
 	u8 dip_switch = kw_gpio_get_value(KM_FLASH_ERASE_ENABLE);
-	wait_for_ne = getenv("waitforne");
+	wait_for_ne = env_get("waitforne");
 
 	if ((wait_for_ne != NULL) && (dip_switch == 0)) {
 		if (strcmp(wait_for_ne, "true") == 0) {
@@ -299,7 +299,7 @@
 	if (dip_switch != 0) {
 		/* start bootloader */
 		puts("DIP:   Enabled\n");
-		setenv("actual_bank", "0");
+		env_set("actual_bank", "0");
 	}
 #endif
 
diff --git a/board/keymile/kmp204x/kmp204x.c b/board/keymile/kmp204x/kmp204x.c
index abb2019..8c9d6b1 100644
--- a/board/keymile/kmp204x/kmp204x.c
+++ b/board/keymile/kmp204x/kmp204x.c
@@ -222,7 +222,7 @@
 	if (dip_switch != 0) {
 		/* start bootloader */
 		puts("DIP:   Enabled\n");
-		setenv("actual_bank", "0");
+		env_set("actual_bank", "0");
 	}
 #endif
 	set_km_env();
@@ -239,7 +239,7 @@
 	unsigned char mac_addr[6];
 
 	/* get the mac addr from env */
-	tmp = getenv("ethaddr");
+	tmp = env_get("ethaddr");
 	if (!tmp) {
 		printf("ethaddr env variable not defined\n");
 		return;
@@ -271,8 +271,8 @@
 
 	ft_cpu_setup(blob, bd);
 
-	base = getenv_bootm_low();
-	size = getenv_bootm_size();
+	base = env_get_bootm_low();
+	size = env_get_bootm_size();
 
 	fdt_fixup_memory(blob, (u64)base, (u64)size);
 
diff --git a/board/kosagi/novena/novena.c b/board/kosagi/novena/novena.c
index 980cd62..f0ace03 100644
--- a/board/kosagi/novena/novena.c
+++ b/board/kosagi/novena/novena.c
@@ -240,7 +240,7 @@
 	int ret;
 
 	/* If 'ethaddr' is already set, do nothing. */
-	if (getenv("ethaddr"))
+	if (env_get("ethaddr"))
 		return 0;
 
 	/* EEPROM is at bus 2. */
@@ -264,7 +264,7 @@
 	}
 
 	/* Set ethernet address from EEPROM. */
-	eth_setenv_enetaddr("ethaddr", data.mac);
+	eth_env_set_enetaddr("ethaddr", data.mac);
 
 	return ret;
 }
diff --git a/board/lg/sniper/sniper.c b/board/lg/sniper/sniper.c
index f924645..a299f76 100644
--- a/board/lg/sniper/sniper.c
+++ b/board/lg/sniper/sniper.c
@@ -133,8 +133,8 @@
 	}
 
 	if (reboot_mode[0] > 0 && isascii(reboot_mode[0])) {
-		if (!getenv("reboot-mode"))
-			setenv("reboot-mode", (char *)reboot_mode);
+		if (!env_get("reboot-mode"))
+			env_set("reboot-mode", (char *)reboot_mode);
 	}
 
 	omap_reboot_mode_clear();
diff --git a/board/liebherr/mccmon6/mccmon6.c b/board/liebherr/mccmon6/mccmon6.c
index e265e2a..4f7e018 100644
--- a/board/liebherr/mccmon6/mccmon6.c
+++ b/board/liebherr/mccmon6/mccmon6.c
@@ -367,7 +367,7 @@
 
 int board_late_init(void)
 {
-	setenv("board_name", "mccmon6");
+	env_set("board_name", "mccmon6");
 
 	return 0;
 }
@@ -467,7 +467,7 @@
 		return 1;
 
 	env_init();
-	ret = getenv_f("boot_os", s, sizeof(s));
+	ret = env_get_f("boot_os", s, sizeof(s));
 	if ((ret != -1) && (strcmp(s, "no") == 0))
 		return 1;
 
@@ -481,7 +481,7 @@
 	 * recovery_status = <any value> -> start SWUpdate
 	 *
 	 */
-	ret = getenv_f("recovery_status", s, sizeof(s));
+	ret = env_get_f("recovery_status", s, sizeof(s));
 	if (ret != -1)
 		return 1;
 
diff --git a/board/logicpd/imx6/imx6logic.c b/board/logicpd/imx6/imx6logic.c
index 0a7d412..78fc546 100644
--- a/board/logicpd/imx6/imx6logic.c
+++ b/board/logicpd/imx6/imx6logic.c
@@ -173,11 +173,11 @@
 
 int board_late_init(void)
 {
-	setenv("board_name", "imx6logic");
+	env_set("board_name", "imx6logic");
 
 	if (is_mx6dq()) {
-		setenv("board_rev", "MX6DQ");
-		setenv("fdt_file", "imx6q-logicpd.dtb");
+		env_set("board_rev", "MX6DQ");
+		env_set("fdt_file", "imx6q-logicpd.dtb");
 	}
 
 	return 0;
diff --git a/board/logicpd/omap3som/omap3logic.c b/board/logicpd/omap3som/omap3logic.c
index f8b9f68..fe3f9e6 100644
--- a/board/logicpd/omap3som/omap3logic.c
+++ b/board/logicpd/omap3som/omap3logic.c
@@ -219,8 +219,8 @@
 			gd->bd->bi_arch_number = board->machine_id;
 
 		/* If the user has not set fdtimage, set the default */
-		if (!getenv("fdtimage"))
-			setenv("fdtimage", board->fdtfile);
+		if (!env_get("fdtimage"))
+			env_set("fdtimage", board->fdtfile);
 	}
 
 	/* restore hsusb0_data5 pin as hsusb0_data5 */
diff --git a/board/logicpd/zoom1/zoom1.c b/board/logicpd/zoom1/zoom1.c
index e91f874..e6c2526 100644
--- a/board/logicpd/zoom1/zoom1.c
+++ b/board/logicpd/zoom1/zoom1.c
@@ -130,10 +130,10 @@
 	uchar eth_addr[6];
 
 	rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);
-	if (!eth_getenv_enetaddr(STR_ENV_ETHADDR, eth_addr)) {
+	if (!eth_env_get_enetaddr(STR_ENV_ETHADDR, eth_addr)) {
 		dev = eth_get_dev_by_index(0);
 		if (dev) {
-			eth_setenv_enetaddr(STR_ENV_ETHADDR, dev->enetaddr);
+			eth_env_set_enetaddr(STR_ENV_ETHADDR, dev->enetaddr);
 		} else {
 			printf("zoom1: Couldn't get eth device\n");
 			rc = -1;
diff --git a/board/micronas/vct/vct.c b/board/micronas/vct/vct.c
index 8bf8d5f..510746d 100644
--- a/board/micronas/vct/vct.c
+++ b/board/micronas/vct/vct.c
@@ -72,7 +72,7 @@
 int checkboard(void)
 {
 	char buf[64];
-	int i = getenv_f("serial#", buf, sizeof(buf));
+	int i = env_get_f("serial#", buf, sizeof(buf));
 	u32 config0 = read_c0_prid();
 
 	if ((config0 & 0xff0000) == PRID_COMP_LEGACY
diff --git a/board/nokia/rx51/rx51.c b/board/nokia/rx51/rx51.c
index 6a4427a..7764288 100644
--- a/board/nokia/rx51/rx51.c
+++ b/board/nokia/rx51/rx51.c
@@ -234,18 +234,18 @@
 	params->u.core.rootdev = 0x0;
 
 	/* append omap atag only if env setup_omap_atag is set to 1 */
-	str = getenv("setup_omap_atag");
+	str = env_get("setup_omap_atag");
 	if (!str || str[0] != '1')
 		return;
 
-	str = getenv("setup_console_atag");
+	str = env_get("setup_console_atag");
 	if (str && str[0] == '1')
 		setup_console_atag = 1;
 	else
 		setup_console_atag = 0;
 
-	setup_boot_reason_atag = getenv("setup_boot_reason_atag");
-	setup_boot_mode_atag = getenv("setup_boot_mode_atag");
+	setup_boot_reason_atag = env_get("setup_boot_reason_atag");
+	setup_boot_mode_atag = env_get("setup_boot_mode_atag");
 
 	params = *in_params;
 	t = (struct tag_omap *)&params->u;
@@ -413,7 +413,7 @@
 
 	/* set env variable attkernaddr for relocated kernel */
 	sprintf(buf, "%#x", KERNEL_ADDRESS);
-	setenv("attkernaddr", buf);
+	env_set("attkernaddr", buf);
 
 	/* initialize omap tags */
 	init_omap_tags();
diff --git a/board/overo/overo.c b/board/overo/overo.c
index adf33cf..140e34d 100644
--- a/board/overo/overo.c
+++ b/board/overo/overo.c
@@ -172,47 +172,47 @@
 			expansion_config.revision,
 			expansion_config.fab_revision);
 		MUX_GUMSTIX();
-		setenv("defaultdisplay", "dvi");
-		setenv("expansionname", "summit");
+		env_set("defaultdisplay", "dvi");
+		env_set("expansionname", "summit");
 		break;
 	case GUMSTIX_TOBI:
 		printf("Recognized Tobi expansion board (rev %d %s)\n",
 			expansion_config.revision,
 			expansion_config.fab_revision);
 		MUX_GUMSTIX();
-		setenv("defaultdisplay", "dvi");
-		setenv("expansionname", "tobi");
+		env_set("defaultdisplay", "dvi");
+		env_set("expansionname", "tobi");
 		break;
 	case GUMSTIX_TOBI_DUO:
 		printf("Recognized Tobi Duo expansion board (rev %d %s)\n",
 			expansion_config.revision,
 			expansion_config.fab_revision);
 		MUX_GUMSTIX();
-		setenv("expansionname", "tobiduo");
+		env_set("expansionname", "tobiduo");
 		break;
 	case GUMSTIX_PALO35:
 		printf("Recognized Palo35 expansion board (rev %d %s)\n",
 			expansion_config.revision,
 			expansion_config.fab_revision);
 		MUX_GUMSTIX();
-		setenv("defaultdisplay", "lcd35");
-		setenv("expansionname", "palo35");
+		env_set("defaultdisplay", "lcd35");
+		env_set("expansionname", "palo35");
 		break;
 	case GUMSTIX_PALO43:
 		printf("Recognized Palo43 expansion board (rev %d %s)\n",
 			expansion_config.revision,
 			expansion_config.fab_revision);
 		MUX_GUMSTIX();
-		setenv("defaultdisplay", "lcd43");
-		setenv("expansionname", "palo43");
+		env_set("defaultdisplay", "lcd43");
+		env_set("expansionname", "palo43");
 		break;
 	case GUMSTIX_CHESTNUT43:
 		printf("Recognized Chestnut43 expansion board (rev %d %s)\n",
 			expansion_config.revision,
 			expansion_config.fab_revision);
 		MUX_GUMSTIX();
-		setenv("defaultdisplay", "lcd43");
-		setenv("expansionname", "chestnut43");
+		env_set("defaultdisplay", "lcd43");
+		env_set("expansionname", "chestnut43");
 		break;
 	case GUMSTIX_PINTO:
 		printf("Recognized Pinto expansion board (rev %d %s)\n",
@@ -225,8 +225,8 @@
 			expansion_config.revision,
 			expansion_config.fab_revision);
 		MUX_GUMSTIX();
-		setenv("defaultdisplay", "lcd43");
-		setenv("expansionname", "gallop43");
+		env_set("defaultdisplay", "lcd43");
+		env_set("expansionname", "gallop43");
 		break;
 	case GUMSTIX_ALTO35:
 		printf("Recognized Alto35 expansion board (rev %d %s)\n",
@@ -234,8 +234,8 @@
 			expansion_config.fab_revision);
 		MUX_GUMSTIX();
 		MUX_ALTO35();
-		setenv("defaultdisplay", "lcd35");
-		setenv("expansionname", "alto35");
+		env_set("defaultdisplay", "lcd35");
+		env_set("expansionname", "alto35");
 		break;
 	case GUMSTIX_STAGECOACH:
 		printf("Recognized Stagecoach expansion board (rev %d %s)\n",
@@ -261,8 +261,8 @@
 			expansion_config.fab_revision);
 		MUX_GUMSTIX();
 		MUX_ARBOR43C();
-		setenv("defaultdisplay", "lcd43");
-		setenv("expansionname", "arbor43c");
+		env_set("defaultdisplay", "lcd43");
+		env_set("expansionname", "arbor43c");
 		break;
 	case ETTUS_USRP_E:
 		printf("Recognized Ettus Research USRP-E (rev %d %s)\n",
@@ -270,13 +270,13 @@
 			expansion_config.fab_revision);
 		MUX_GUMSTIX();
 		MUX_USRP_E();
-		setenv("defaultdisplay", "dvi");
+		env_set("defaultdisplay", "dvi");
 		break;
 	case GUMSTIX_NO_EEPROM:
 	case GUMSTIX_EMPTY_EEPROM:
 		puts("No or empty EEPROM on expansion board\n");
 		MUX_GUMSTIX();
-		setenv("expansionname", "tobi");
+		env_set("expansionname", "tobi");
 		break;
 	default:
 		printf("Unrecognized expansion board 0x%08x\n", expansion_id);
@@ -284,14 +284,14 @@
 	}
 
 	if (expansion_config.content == 1)
-		setenv(expansion_config.env_var, expansion_config.env_setting);
+		env_set(expansion_config.env_var, expansion_config.env_setting);
 
 	omap_die_id_display();
 
 	if (get_cpu_family() == CPU_OMAP34XX)
-		setenv("boardname", "overo");
+		env_set("boardname", "overo");
 	else
-		setenv("boardname", "overo-storm");
+		env_set("boardname", "overo-storm");
 
 	return 0;
 }
diff --git a/board/phytec/pcm051/board.c b/board/phytec/pcm051/board.c
index 4f3853a..52ad5b6 100644
--- a/board/phytec/pcm051/board.c
+++ b/board/phytec/pcm051/board.c
@@ -216,7 +216,7 @@
 	uint8_t mac_addr[6];
 	uint32_t mac_hi, mac_lo;
 
-	if (!eth_getenv_enetaddr("ethaddr", mac_addr)) {
+	if (!eth_env_get_enetaddr("ethaddr", mac_addr)) {
 		printf("<ethaddr> not set. Reading from E-fuse\n");
 		/* try reading mac address from efuse */
 		mac_lo = readl(&cdev->macid0l);
@@ -229,7 +229,7 @@
 		mac_addr[5] = (mac_lo & 0xFF00) >> 8;
 
 		if (is_valid_ethaddr(mac_addr))
-			eth_setenv_enetaddr("ethaddr", mac_addr);
+			eth_env_set_enetaddr("ethaddr", mac_addr);
 		else
 			goto try_usbether;
 	}
diff --git a/board/phytec/pfla02/Kconfig b/board/phytec/pfla02/Kconfig
new file mode 100644
index 0000000..142a122
--- /dev/null
+++ b/board/phytec/pfla02/Kconfig
@@ -0,0 +1,12 @@
+if TARGET_PFLA02
+
+config SYS_BOARD
+	default "pfla02"
+
+config SYS_VENDOR
+	default "phytec"
+
+config SYS_CONFIG_NAME
+	default "pfla02"
+
+endif
diff --git a/board/phytec/pfla02/MAINTAINERS b/board/phytec/pfla02/MAINTAINERS
new file mode 100644
index 0000000..4b069a9
--- /dev/null
+++ b/board/phytec/pfla02/MAINTAINERS
@@ -0,0 +1,6 @@
+PHYTEC PHYFLEX
+M:	Stefano Babic <sbabic@denx.de>
+S:	Maintained
+F:	board/phytec/pfla02/
+F:	include/configs/pfla02.h
+F:	configs/pfla02_defconfig
diff --git a/board/phytec/pfla02/Makefile b/board/phytec/pfla02/Makefile
new file mode 100644
index 0000000..25af9a0
--- /dev/null
+++ b/board/phytec/pfla02/Makefile
@@ -0,0 +1,9 @@
+#
+# Copyright (C) 2007, Guennadi Liakhovetski <lg@denx.de>
+#
+# (C) Copyright 2011 Freescale Semiconductor, Inc.
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+
+obj-y  := pfla02.o
diff --git a/board/phytec/pfla02/README b/board/phytec/pfla02/README
new file mode 100644
index 0000000..0f46ab8
--- /dev/null
+++ b/board/phytec/pfla02/README
@@ -0,0 +1,24 @@
+Board information
+-----------------
+
+The evaluation board "pbab01" is thought to be used
+together with the SOM.
+
+More information on the board can be found on manufacturer's
+website:
+
+http://www.phytec.de/produkt/system-on-modules/phyflex-imx-6/
+
+Building U-Boot
+-------------------------------
+
+$ make pfla02_defconfig
+$ make
+
+This generates the artifacts SPL and u-boot.img.
+The SOM can boot from NAND or from SD-Card, having the SPI-NOR
+as second option.
+The dip switch "SW3" on the board let choose the boot device.
+
+SW3_1(on), SW3_2(on), SW3_3(off):	Boot first from SD, then try SPI
+SW3_1(off), SW3_2(on), SW3_3(off):	Boot from SPI
diff --git a/board/phytec/pfla02/pfla02.c b/board/phytec/pfla02/pfla02.c
new file mode 100644
index 0000000..8d2ce63
--- /dev/null
+++ b/board/phytec/pfla02/pfla02.c
@@ -0,0 +1,698 @@
+/*
+ * Copyright (C) 2017 Stefano Babic <sbabic@denx.de>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/arch/clock.h>
+#include <asm/arch/imx-regs.h>
+#include <asm/arch/iomux.h>
+#include <asm/arch/crm_regs.h>
+#include <asm/arch/iomux.h>
+#include <asm/arch/mx6-pins.h>
+#include <asm/mach-imx/iomux-v3.h>
+#include <asm/mach-imx/boot_mode.h>
+#include <asm/mach-imx/mxc_i2c.h>
+#include <asm/mach-imx/spi.h>
+#include <linux/errno.h>
+#include <asm/gpio.h>
+#include <mmc.h>
+#include <i2c.h>
+#include <fsl_esdhc.h>
+#include <nand.h>
+#include <miiphy.h>
+#include <netdev.h>
+#include <asm/arch/sys_proto.h>
+#include <asm/sections.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#define UART_PAD_CTRL  (PAD_CTL_PUS_100K_UP |			\
+	PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm |			\
+	PAD_CTL_SRE_FAST  | PAD_CTL_HYS)
+
+#define USDHC_PAD_CTRL (PAD_CTL_PUS_47K_UP |			\
+	PAD_CTL_SPEED_LOW | PAD_CTL_DSE_80ohm |			\
+	PAD_CTL_SRE_FAST  | PAD_CTL_HYS)
+
+#define ENET_PAD_CTRL  (PAD_CTL_PUS_100K_UP |			\
+	PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | PAD_CTL_HYS)
+
+#define SPI_PAD_CTRL (PAD_CTL_HYS | PAD_CTL_SPEED_MED | \
+		      PAD_CTL_DSE_40ohm | PAD_CTL_SRE_FAST)
+
+#define I2C_PAD_CTRL  (PAD_CTL_PUS_100K_UP |			\
+	PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | PAD_CTL_HYS |	\
+	PAD_CTL_ODE | PAD_CTL_SRE_FAST)
+
+#define I2C_PAD MUX_PAD_CTRL(I2C_PAD_CTRL)
+
+#define ASRC_PAD_CTRL (PAD_CTL_HYS | PAD_CTL_PUS_100K_UP  |	\
+		      PAD_CTL_DSE_40ohm | PAD_CTL_SRE_FAST)
+
+#define NAND_PAD_CTRL (PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED | \
+	       PAD_CTL_DSE_40ohm | PAD_CTL_SRE_FAST)
+
+#define ENET_PHY_RESET_GPIO IMX_GPIO_NR(1, 14)
+#define USDHC2_CD_GPIO	IMX_GPIO_NR(1, 4)
+#define GREEN_LED	IMX_GPIO_NR(2, 31)
+#define RED_LED		IMX_GPIO_NR(1, 30)
+#define IMX6Q_DRIVE_STRENGTH	0x30
+
+int dram_init(void)
+{
+	gd->ram_size = imx_ddr_size();
+	return 0;
+}
+
+static iomux_v3_cfg_t const uart4_pads[] = {
+	IOMUX_PADS(PAD_KEY_COL0__UART4_TX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL)),
+	IOMUX_PADS(PAD_KEY_ROW0__UART4_RX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL)),
+};
+
+static iomux_v3_cfg_t const enet_pads[] = {
+	IOMUX_PADS(PAD_ENET_MDIO__ENET_MDIO	| MUX_PAD_CTRL(ENET_PAD_CTRL)),
+	IOMUX_PADS(PAD_ENET_MDC__ENET_MDC	| MUX_PAD_CTRL(ENET_PAD_CTRL)),
+	IOMUX_PADS(PAD_RGMII_TXC__RGMII_TXC	| MUX_PAD_CTRL(ENET_PAD_CTRL)),
+	IOMUX_PADS(PAD_RGMII_TD0__RGMII_TD0	| MUX_PAD_CTRL(ENET_PAD_CTRL)),
+	IOMUX_PADS(PAD_RGMII_TD1__RGMII_TD1	| MUX_PAD_CTRL(ENET_PAD_CTRL)),
+	IOMUX_PADS(PAD_RGMII_TD2__RGMII_TD2	| MUX_PAD_CTRL(ENET_PAD_CTRL)),
+	IOMUX_PADS(PAD_RGMII_TD3__RGMII_TD3	| MUX_PAD_CTRL(ENET_PAD_CTRL)),
+	IOMUX_PADS(PAD_RGMII_TX_CTL__RGMII_TX_CTL |
+			MUX_PAD_CTRL(ENET_PAD_CTRL)),
+	IOMUX_PADS(PAD_ENET_REF_CLK__ENET_TX_CLK |
+			MUX_PAD_CTRL(ENET_PAD_CTRL)),
+	IOMUX_PADS(PAD_RGMII_RXC__RGMII_RXC	| MUX_PAD_CTRL(ENET_PAD_CTRL)),
+	IOMUX_PADS(PAD_RGMII_RD0__RGMII_RD0	| MUX_PAD_CTRL(ENET_PAD_CTRL)),
+	IOMUX_PADS(PAD_RGMII_RD1__RGMII_RD1	| MUX_PAD_CTRL(ENET_PAD_CTRL)),
+	IOMUX_PADS(PAD_RGMII_RD2__RGMII_RD2	| MUX_PAD_CTRL(ENET_PAD_CTRL)),
+	IOMUX_PADS(PAD_RGMII_RD3__RGMII_RD3	| MUX_PAD_CTRL(ENET_PAD_CTRL)),
+	IOMUX_PADS(PAD_RGMII_RX_CTL__RGMII_RX_CTL |
+			MUX_PAD_CTRL(ENET_PAD_CTRL)),
+	IOMUX_PADS(PAD_SD2_DAT1__GPIO1_IO14	| MUX_PAD_CTRL(NO_PAD_CTRL)),
+};
+
+static iomux_v3_cfg_t const ecspi3_pads[] = {
+	IOMUX_PADS(PAD_DISP0_DAT0__ECSPI3_SCLK | MUX_PAD_CTRL(SPI_PAD_CTRL)),
+	IOMUX_PADS(PAD_DISP0_DAT1__ECSPI3_MOSI | MUX_PAD_CTRL(SPI_PAD_CTRL)),
+	IOMUX_PADS(PAD_DISP0_DAT2__ECSPI3_MISO | MUX_PAD_CTRL(SPI_PAD_CTRL)),
+	IOMUX_PADS(PAD_DISP0_DAT3__GPIO4_IO24  | MUX_PAD_CTRL(NO_PAD_CTRL)),
+};
+
+static iomux_v3_cfg_t const gpios_pads[] = {
+	IOMUX_PADS(PAD_SD4_DAT3__GPIO2_IO11 | MUX_PAD_CTRL(NO_PAD_CTRL)),
+	IOMUX_PADS(PAD_SD4_DAT4__GPIO2_IO12 | MUX_PAD_CTRL(NO_PAD_CTRL)),
+	IOMUX_PADS(PAD_SD4_DAT5__GPIO2_IO13 | MUX_PAD_CTRL(NO_PAD_CTRL)),
+	IOMUX_PADS(PAD_SD4_DAT6__GPIO2_IO14 | MUX_PAD_CTRL(NO_PAD_CTRL)),
+	IOMUX_PADS(PAD_SD4_DAT7__GPIO2_IO15 | MUX_PAD_CTRL(NO_PAD_CTRL)),
+	IOMUX_PADS(PAD_EIM_EB3__GPIO2_IO31 | MUX_PAD_CTRL(NO_PAD_CTRL)),
+	IOMUX_PADS(PAD_ENET_TXD0__GPIO1_IO30 | MUX_PAD_CTRL(NO_PAD_CTRL)),
+	IOMUX_PADS(PAD_SD4_DAT3__GPIO2_IO11 | MUX_PAD_CTRL(NO_PAD_CTRL)),
+};
+
+#ifdef CONFIG_CMD_NAND
+/* NAND */
+static iomux_v3_cfg_t const nfc_pads[] = {
+	IOMUX_PADS(PAD_NANDF_CLE__NAND_CLE	| MUX_PAD_CTRL(NAND_PAD_CTRL)),
+	IOMUX_PADS(PAD_NANDF_ALE__NAND_ALE	| MUX_PAD_CTRL(NAND_PAD_CTRL)),
+	IOMUX_PADS(PAD_NANDF_WP_B__NAND_WP_B	| MUX_PAD_CTRL(NAND_PAD_CTRL)),
+	IOMUX_PADS(PAD_NANDF_RB0__NAND_READY_B	| MUX_PAD_CTRL(NAND_PAD_CTRL)),
+	IOMUX_PADS(PAD_NANDF_CS0__NAND_CE0_B	| MUX_PAD_CTRL(NAND_PAD_CTRL)),
+	IOMUX_PADS(PAD_NANDF_CS1__NAND_CE1_B	| MUX_PAD_CTRL(NAND_PAD_CTRL)),
+	IOMUX_PADS(PAD_NANDF_CS2__NAND_CE2_B	| MUX_PAD_CTRL(NAND_PAD_CTRL)),
+	IOMUX_PADS(PAD_NANDF_CS3__NAND_CE3_B	| MUX_PAD_CTRL(NAND_PAD_CTRL)),
+	IOMUX_PADS(PAD_SD4_CMD__NAND_RE_B	| MUX_PAD_CTRL(NAND_PAD_CTRL)),
+	IOMUX_PADS(PAD_SD4_CLK__NAND_WE_B	| MUX_PAD_CTRL(NAND_PAD_CTRL)),
+	IOMUX_PADS(PAD_NANDF_D0__NAND_DATA00	| MUX_PAD_CTRL(NAND_PAD_CTRL)),
+	IOMUX_PADS(PAD_NANDF_D1__NAND_DATA01	| MUX_PAD_CTRL(NAND_PAD_CTRL)),
+	IOMUX_PADS(PAD_NANDF_D2__NAND_DATA02	| MUX_PAD_CTRL(NAND_PAD_CTRL)),
+	IOMUX_PADS(PAD_NANDF_D3__NAND_DATA03	| MUX_PAD_CTRL(NAND_PAD_CTRL)),
+	IOMUX_PADS(PAD_NANDF_D4__NAND_DATA04	| MUX_PAD_CTRL(NAND_PAD_CTRL)),
+	IOMUX_PADS(PAD_NANDF_D5__NAND_DATA05	| MUX_PAD_CTRL(NAND_PAD_CTRL)),
+	IOMUX_PADS(PAD_NANDF_D6__NAND_DATA06	| MUX_PAD_CTRL(NAND_PAD_CTRL)),
+	IOMUX_PADS(PAD_NANDF_D7__NAND_DATA07	| MUX_PAD_CTRL(NAND_PAD_CTRL)),
+	IOMUX_PADS(PAD_SD4_DAT0__NAND_DQS	| MUX_PAD_CTRL(NAND_PAD_CTRL)),
+};
+#endif
+
+static struct i2c_pads_info i2c_pad_info = {
+	.scl = {
+		.i2c_mode = MX6Q_PAD_EIM_D21__I2C1_SCL | I2C_PAD,
+		.gpio_mode = MX6Q_PAD_EIM_D21__GPIO3_IO21 | I2C_PAD,
+		.gp = IMX_GPIO_NR(3, 21)
+	},
+	.sda = {
+		.i2c_mode = MX6Q_PAD_EIM_D28__I2C1_SDA | I2C_PAD,
+		.gpio_mode = MX6Q_PAD_EIM_D28__GPIO3_IO28 | I2C_PAD,
+		.gp = IMX_GPIO_NR(3, 28)
+	}
+};
+
+static struct fsl_esdhc_cfg usdhc_cfg[] = {
+	{USDHC3_BASE_ADDR,
+	.max_bus_width = 4},
+	{.esdhc_base = USDHC2_BASE_ADDR,
+	.max_bus_width = 4},
+};
+
+#if !defined(CONFIG_SPL_BUILD)
+static iomux_v3_cfg_t const usdhc2_pads[] = {
+	IOMUX_PADS(PAD_SD2_CLK__SD2_CLK	| MUX_PAD_CTRL(USDHC_PAD_CTRL)),
+	IOMUX_PADS(PAD_SD2_CMD__SD2_CMD	| MUX_PAD_CTRL(USDHC_PAD_CTRL)),
+	IOMUX_PADS(PAD_SD2_DAT0__SD2_DATA0	| MUX_PAD_CTRL(USDHC_PAD_CTRL)),
+	IOMUX_PADS(PAD_SD2_DAT1__SD2_DATA1	| MUX_PAD_CTRL(USDHC_PAD_CTRL)),
+	IOMUX_PADS(PAD_SD2_DAT2__SD2_DATA2	| MUX_PAD_CTRL(USDHC_PAD_CTRL)),
+	IOMUX_PADS(PAD_SD2_DAT3__SD2_DATA3	| MUX_PAD_CTRL(USDHC_PAD_CTRL)),
+	IOMUX_PADS(PAD_EIM_BCLK__GPIO6_IO31	| MUX_PAD_CTRL(NO_PAD_CTRL)),
+	IOMUX_PADS(PAD_GPIO_4__GPIO1_IO04	| MUX_PAD_CTRL(NO_PAD_CTRL)),
+};
+#endif
+
+static iomux_v3_cfg_t const usdhc3_pads[] = {
+	IOMUX_PADS(PAD_SD3_CLK__SD3_CLK	| MUX_PAD_CTRL(USDHC_PAD_CTRL)),
+	IOMUX_PADS(PAD_SD3_CMD__SD3_CMD	| MUX_PAD_CTRL(USDHC_PAD_CTRL)),
+	IOMUX_PADS(PAD_SD3_DAT0__SD3_DATA0	| MUX_PAD_CTRL(USDHC_PAD_CTRL)),
+	IOMUX_PADS(PAD_SD3_DAT1__SD3_DATA1	| MUX_PAD_CTRL(USDHC_PAD_CTRL)),
+	IOMUX_PADS(PAD_SD3_DAT2__SD3_DATA2	| MUX_PAD_CTRL(USDHC_PAD_CTRL)),
+	IOMUX_PADS(PAD_SD3_DAT3__SD3_DATA3	| MUX_PAD_CTRL(USDHC_PAD_CTRL)),
+	IOMUX_PADS(PAD_SD3_DAT4__SD3_DATA4	| MUX_PAD_CTRL(USDHC_PAD_CTRL)),
+	IOMUX_PADS(PAD_SD3_DAT5__SD3_DATA5	| MUX_PAD_CTRL(USDHC_PAD_CTRL)),
+	IOMUX_PADS(PAD_SD3_DAT6__SD3_DATA6	| MUX_PAD_CTRL(USDHC_PAD_CTRL)),
+	IOMUX_PADS(PAD_SD3_DAT7__SD3_DATA7	| MUX_PAD_CTRL(USDHC_PAD_CTRL)),
+};
+
+int board_mmc_get_env_dev(int devno)
+{
+	return devno - 1;
+}
+
+int board_mmc_getcd(struct mmc *mmc)
+{
+	struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv;
+	int ret = 0;
+
+	switch (cfg->esdhc_base) {
+	case USDHC2_BASE_ADDR:
+		ret = !gpio_get_value(USDHC2_CD_GPIO);
+		ret = 1;
+		break;
+	case USDHC3_BASE_ADDR:
+		ret = 1;
+		break;
+	}
+
+	return ret;
+}
+
+#ifndef CONFIG_SPL_BUILD
+int board_mmc_init(bd_t *bis)
+{
+	int ret;
+	int i;
+
+	for (i = 0; i < CONFIG_SYS_FSL_USDHC_NUM; i++) {
+		switch (i) {
+		case 0:
+			SETUP_IOMUX_PADS(usdhc3_pads);
+			usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC3_CLK);
+			break;
+		case 1:
+			SETUP_IOMUX_PADS(usdhc2_pads);
+			gpio_direction_input(USDHC2_CD_GPIO);
+			usdhc_cfg[1].sdhc_clk = mxc_get_clock(MXC_ESDHC2_CLK);
+			break;
+		default:
+			printf("Warning: you configured more USDHC controllers"
+			       "(%d) then supported by the board (%d)\n",
+			       i + 1, CONFIG_SYS_FSL_USDHC_NUM);
+			return -EINVAL;
+		}
+
+		ret = fsl_esdhc_initialize(bis, &usdhc_cfg[i]);
+		if (ret)
+			return ret;
+	}
+
+	return 0;
+}
+#endif
+
+static void setup_iomux_uart(void)
+{
+	SETUP_IOMUX_PADS(uart4_pads);
+}
+
+static void setup_iomux_enet(void)
+{
+	SETUP_IOMUX_PADS(enet_pads);
+
+	gpio_direction_output(ENET_PHY_RESET_GPIO, 0);
+	mdelay(10);
+	gpio_set_value(ENET_PHY_RESET_GPIO, 1);
+	mdelay(30);
+}
+
+static void setup_spi(void)
+{
+	gpio_request(IMX_GPIO_NR(4, 24), "spi_cs0");
+	gpio_direction_output(IMX_GPIO_NR(4, 24), 1);
+
+	SETUP_IOMUX_PADS(ecspi3_pads);
+
+	enable_spi_clk(true, 2);
+}
+
+static void setup_gpios(void)
+{
+	SETUP_IOMUX_PADS(gpios_pads);
+}
+
+#ifdef CONFIG_CMD_NAND
+static void setup_gpmi_nand(void)
+{
+	struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
+
+	/* config gpmi nand iomux */
+	SETUP_IOMUX_PADS(nfc_pads);
+
+	/* gate ENFC_CLK_ROOT clock first,before clk source switch */
+	clrbits_le32(&mxc_ccm->CCGR2, MXC_CCM_CCGR2_IOMUX_IPT_CLK_IO_MASK);
+
+	/* config gpmi and bch clock to 100 MHz */
+	clrsetbits_le32(&mxc_ccm->cs2cdr,
+			MXC_CCM_CS2CDR_ENFC_CLK_PODF_MASK |
+			MXC_CCM_CS2CDR_ENFC_CLK_PRED_MASK |
+			MXC_CCM_CS2CDR_ENFC_CLK_SEL_MASK,
+			MXC_CCM_CS2CDR_ENFC_CLK_PODF(0) |
+			MXC_CCM_CS2CDR_ENFC_CLK_PRED(3) |
+			MXC_CCM_CS2CDR_ENFC_CLK_SEL(3));
+
+	/* enable ENFC_CLK_ROOT clock */
+	setbits_le32(&mxc_ccm->CCGR2, MXC_CCM_CCGR2_IOMUX_IPT_CLK_IO_MASK);
+
+	/* enable gpmi and bch clock gating */
+	setbits_le32(&mxc_ccm->CCGR4,
+		     MXC_CCM_CCGR4_RAWNAND_U_BCH_INPUT_APB_MASK |
+		     MXC_CCM_CCGR4_RAWNAND_U_GPMI_BCH_INPUT_BCH_MASK |
+		     MXC_CCM_CCGR4_RAWNAND_U_GPMI_BCH_INPUT_GPMI_IO_MASK |
+		     MXC_CCM_CCGR4_RAWNAND_U_GPMI_INPUT_APB_MASK |
+		     MXC_CCM_CCGR4_PL301_MX6QPER1_BCH_OFFSET);
+
+	/* enable apbh clock gating */
+	setbits_le32(&mxc_ccm->CCGR0, MXC_CCM_CCGR0_APBHDMA_MASK);
+}
+#endif
+
+/*
+ * Board revision is coded in 4 GPIOs
+ */
+u32 get_board_rev(void)
+{
+	u32 rev;
+	int i;
+
+	for (i = 0, rev = 0; i < 4; i++)
+		rev |= (gpio_get_value(IMX_GPIO_NR(2, 12 + i)) << i);
+
+	return 16 - rev;
+}
+
+int board_spi_cs_gpio(unsigned bus, unsigned cs)
+{
+	if (bus != 2 || (cs != 0))
+		return -EINVAL;
+
+	return IMX_GPIO_NR(4, 24);
+}
+
+int board_eth_init(bd_t *bis)
+{
+	setup_iomux_enet();
+
+	return cpu_eth_init(bis);
+}
+
+int board_early_init_f(void)
+{
+	setup_iomux_uart();
+
+	return 0;
+}
+
+int board_init(void)
+{
+	/* address of boot parameters */
+	gd->bd->bi_boot_params = PHYS_SDRAM + 0x100;
+
+#ifdef CONFIG_SYS_I2C_MXC
+	setup_i2c(0, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info);
+#endif
+
+#ifdef CONFIG_MXC_SPI
+	setup_spi();
+#endif
+
+	setup_gpios();
+
+#ifdef CONFIG_CMD_NAND
+	setup_gpmi_nand();
+#endif
+	return 0;
+}
+
+
+#ifdef CONFIG_CMD_BMODE
+/*
+ * BOOT_CFG1, BOOT_CFG2, BOOT_CFG3, BOOT_CFG4
+ * see Table 8-11 and Table 5-9
+ *  BOOT_CFG1[7] = 1 (boot from NAND)
+ *  BOOT_CFG1[5] = 0 - raw NAND
+ *  BOOT_CFG1[4] = 0 - default pad settings
+ *  BOOT_CFG1[3:2] = 00 - devices = 1
+ *  BOOT_CFG1[1:0] = 00 - Row Address Cycles = 3
+ *  BOOT_CFG2[4:3] = 00 - Boot Search Count = 2
+ *  BOOT_CFG2[2:1] = 01 - Pages In Block = 64
+ *  BOOT_CFG2[0] = 0 - Reset time 12ms
+ */
+static const struct boot_mode board_boot_modes[] = {
+	/* NAND: 64pages per block, 3 row addr cycles, 2 copies of FCB/DBBT */
+	{"nand", MAKE_CFGVAL(0x80, 0x02, 0x00, 0x00)},
+	{"mmc0",  MAKE_CFGVAL(0x40, 0x20, 0x00, 0x00)},
+	{NULL, 0},
+};
+#endif
+
+int board_late_init(void)
+{
+	char buf[10];
+#ifdef CONFIG_CMD_BMODE
+	add_board_boot_modes(board_boot_modes);
+#endif
+
+	snprintf(buf, sizeof(buf), "%d", get_board_rev());
+	env_set("board_rev", buf);
+
+	return 0;
+}
+
+#ifdef CONFIG_SPL_BUILD
+#include <asm/arch/mx6-ddr.h>
+#include <spl.h>
+#include <libfdt.h>
+
+#define MX6_PHYFLEX_ERR006282	IMX_GPIO_NR(2, 11)
+static void phyflex_err006282_workaround(void)
+{
+	/*
+	 * Boards beginning with 1362.2 have the SD4_DAT3 pin connected
+	 * to the CMIC. If this pin isn't toggled within 10s the boards
+	 * reset. The pin is unconnected on older boards, so we do not
+	 * need a check for older boards before applying this fixup.
+	 */
+
+	gpio_direction_output(MX6_PHYFLEX_ERR006282, 0);
+	mdelay(2);
+	gpio_direction_output(MX6_PHYFLEX_ERR006282, 1);
+	mdelay(2);
+	gpio_set_value(MX6_PHYFLEX_ERR006282, 0);
+
+	gpio_direction_input(MX6_PHYFLEX_ERR006282);
+}
+
+static const struct mx6dq_iomux_ddr_regs mx6_ddr_ioregs = {
+	.dram_sdclk_0 = 0x00000030,
+	.dram_sdclk_1 = 0x00000030,
+	.dram_cas = 0x00000030,
+	.dram_ras = 0x00000030,
+	.dram_reset = 0x00000030,
+	.dram_sdcke0 = 0x00003000,
+	.dram_sdcke1 = 0x00003000,
+	.dram_sdba2 = 0x00000030,
+	.dram_sdodt0 = 0x00000030,
+	.dram_sdodt1 = 0x00000030,
+
+	.dram_sdqs0 = 0x00000028,
+	.dram_sdqs1 = 0x00000028,
+	.dram_sdqs2 = 0x00000028,
+	.dram_sdqs3 = 0x00000028,
+	.dram_sdqs4 = 0x00000028,
+	.dram_sdqs5 = 0x00000028,
+	.dram_sdqs6 = 0x00000028,
+	.dram_sdqs7 = 0x00000028,
+	.dram_dqm0 = 0x00000028,
+	.dram_dqm1 = 0x00000028,
+	.dram_dqm2 = 0x00000028,
+	.dram_dqm3 = 0x00000028,
+	.dram_dqm4 = 0x00000028,
+	.dram_dqm5 = 0x00000028,
+	.dram_dqm6 = 0x00000028,
+	.dram_dqm7 = 0x00000028,
+};
+
+static const struct mx6dq_iomux_grp_regs mx6_grp_ioregs = {
+	.grp_ddr_type =  0x000C0000,
+	.grp_ddrmode_ctl =  0x00020000,
+	.grp_ddrpke =  0x00000000,
+	.grp_addds = IMX6Q_DRIVE_STRENGTH,
+	.grp_ctlds = IMX6Q_DRIVE_STRENGTH,
+	.grp_ddrmode =  0x00020000,
+	.grp_b0ds = 0x00000028,
+	.grp_b1ds = 0x00000028,
+	.grp_b2ds = 0x00000028,
+	.grp_b3ds = 0x00000028,
+	.grp_b4ds = 0x00000028,
+	.grp_b5ds = 0x00000028,
+	.grp_b6ds = 0x00000028,
+	.grp_b7ds = 0x00000028,
+};
+
+static const struct mx6_mmdc_calibration mx6_mmcd_calib = {
+	.p0_mpwldectrl0 =  0x00110011,
+	.p0_mpwldectrl1 =  0x00240024,
+	.p1_mpwldectrl0 =  0x00260038,
+	.p1_mpwldectrl1 =  0x002C0038,
+	.p0_mpdgctrl0 =  0x03400350,
+	.p0_mpdgctrl1 =  0x03440340,
+	.p1_mpdgctrl0 =  0x034C0354,
+	.p1_mpdgctrl1 =  0x035C033C,
+	.p0_mprddlctl =  0x322A2A2A,
+	.p1_mprddlctl =  0x302C2834,
+	.p0_mpwrdlctl =  0x34303834,
+	.p1_mpwrdlctl =  0x422A3E36,
+};
+
+/* Index in RAM Chip array */
+enum {
+	RAM_1GB,
+	RAM_2GB,
+	RAM_4GB
+};
+
+static struct mx6_ddr3_cfg mt41k_xx[] = {
+/* MT41K64M16JT-125 (1Gb density) */
+	{
+	.mem_speed = 1600,
+	.density = 1,
+	.width = 16,
+	.banks = 8,
+	.rowaddr = 13,
+	.coladdr = 10,
+	.pagesz = 2,
+	.trcd = 1375,
+	.trcmin = 4875,
+	.trasmin = 3500,
+	.SRT       = 1,
+	},
+
+/* MT41K256M16JT-125 (2Gb density) */
+	{
+	.mem_speed = 1600,
+	.density = 2,
+	.width = 16,
+	.banks = 8,
+	.rowaddr = 14,
+	.coladdr = 10,
+	.pagesz = 2,
+	.trcd = 1375,
+	.trcmin = 4875,
+	.trasmin = 3500,
+	.SRT       = 1,
+	},
+
+/* MT41K256M16JT-125 (4Gb density) */
+	{
+	.mem_speed = 1600,
+	.density = 4,
+	.width = 16,
+	.banks = 8,
+	.rowaddr = 15,
+	.coladdr = 10,
+	.pagesz = 2,
+	.trcd = 1375,
+	.trcmin = 4875,
+	.trasmin = 3500,
+	.SRT       = 1,
+	}
+};
+
+static void ccgr_init(void)
+{
+	struct mxc_ccm_reg *ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
+
+	writel(0x00C03F3F, &ccm->CCGR0);
+	writel(0x0030FC03, &ccm->CCGR1);
+	writel(0x0FFFC000, &ccm->CCGR2);
+	writel(0x3FF00000, &ccm->CCGR3);
+	writel(0x00FFF300, &ccm->CCGR4);
+	writel(0x0F0000C3, &ccm->CCGR5);
+	writel(0x000003FF, &ccm->CCGR6);
+}
+
+static void gpr_init(void)
+{
+	struct iomuxc *iomux = (struct iomuxc *)IOMUXC_BASE_ADDR;
+
+	/* enable AXI cache for VDOA/VPU/IPU */
+	writel(0xF00000CF, &iomux->gpr[4]);
+	/* set IPU AXI-id0 Qos=0xf(bypass) AXI-id1 Qos=0x7 */
+	writel(0x007F007F, &iomux->gpr[6]);
+	writel(0x007F007F, &iomux->gpr[7]);
+}
+
+static void spl_dram_init(struct mx6_ddr3_cfg *mem_ddr)
+{
+	struct mx6_ddr_sysinfo sysinfo = {
+		/* width of data bus:0=16,1=32,2=64 */
+		.dsize = 2,
+		/* config for full 4GB range so that get_mem_size() works */
+		.cs_density = 32, /* 32Gb per CS */
+		/* single chip select */
+		.ncs = 2,
+		.cs1_mirror = 0,
+		.rtt_wr = 1 /*DDR3_RTT_60_OHM*/,	/* RTT_Wr = RZQ/4 */
+		.rtt_nom = 1 /*DDR3_RTT_60_OHM*/,	/* RTT_Nom = RZQ/4 */
+		.walat = 1,	/* Write additional latency */
+		.ralat = 5,	/* Read additional latency */
+		.mif3_mode = 3,	/* Command prediction working mode */
+		.bi_on = 1,	/* Bank interleaving enabled */
+		.sde_to_rst = 0x10,	/* 14 cycles, 200us (JEDEC default) */
+		.rst_to_cke = 0x23,	/* 33 cycles, 500us (JEDEC default) */
+		.ddr_type = DDR_TYPE_DDR3,
+		.refsel = 1,	/* Refresh cycles at 32KHz */
+		.refr = 7,	/* 8 refresh commands per refresh cycle */
+	};
+
+	mx6dq_dram_iocfg(64, &mx6_ddr_ioregs, &mx6_grp_ioregs);
+	mx6_dram_cfg(&sysinfo, &mx6_mmcd_calib, mem_ddr);
+}
+
+int board_mmc_init(bd_t *bis)
+{
+	if (spl_boot_device() == BOOT_DEVICE_SPI)
+		printf("MMC SEtup, Boot SPI");
+
+	SETUP_IOMUX_PADS(usdhc3_pads);
+	usdhc_cfg[0].esdhc_base = USDHC3_BASE_ADDR;
+	usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC3_CLK);
+	usdhc_cfg[0].max_bus_width = 4;
+	gd->arch.sdhc_clk = usdhc_cfg[0].sdhc_clk;
+
+	return fsl_esdhc_initialize(bis, &usdhc_cfg[0]);
+}
+
+
+void board_boot_order(u32 *spl_boot_list)
+{
+	spl_boot_list[0] = spl_boot_device();
+	printf("Boot device %x\n", spl_boot_list[0]);
+	switch (spl_boot_list[0]) {
+	case BOOT_DEVICE_SPI:
+		spl_boot_list[1] = BOOT_DEVICE_UART;
+		break;
+	case BOOT_DEVICE_MMC1:
+		spl_boot_list[1] = BOOT_DEVICE_SPI;
+		spl_boot_list[2] = BOOT_DEVICE_UART;
+		break;
+	default:
+		printf("Boot device %x\n", spl_boot_list[0]);
+	}
+}
+
+/*
+ * This is used because get_ram_size() does not
+ * take care of cache, resulting a wrong size
+ * pfla02 has just 1, 2 or 4 GB option
+ * Function checks for mirrors in the first CS
+ */
+#define RAM_TEST_PATTERN	0xaa5555aa
+static unsigned int pfla02_detect_ramsize(void)
+{
+	u32 *p, *p1;
+	unsigned int offset = 512 * 1024 * 1024;
+	int i;
+
+	for (i = 0; i < 2; i++) {
+		p = (u32 *)PHYS_SDRAM;
+		p1 = (u32 *)(PHYS_SDRAM + (i + 1) * offset);
+
+		*p1 = 0;
+		*p = RAM_TEST_PATTERN;
+
+		/*
+		 *  This is required to detect mirroring
+		 *  else we read back values from cache
+		 */
+		flush_dcache_all();
+
+		if (*p == *p1)
+			return i;
+	}
+	return RAM_4GB;
+}
+
+void board_init_f(ulong dummy)
+{
+	unsigned int ramchip;
+#ifdef CONFIG_CMD_NAND
+	/* Enable NAND */
+	setup_gpmi_nand();
+#endif
+
+	/* setup clock gating */
+	ccgr_init();
+
+	/* setup AIPS and disable watchdog */
+	arch_cpu_init();
+
+	/* setup AXI */
+	gpr_init();
+
+	board_early_init_f();
+
+	/* setup GP timer */
+	timer_init();
+
+	/* UART clocks enabled and gd valid - init serial console */
+	preloader_console_init();
+
+	setup_spi();
+
+	setup_gpios();
+
+	/* DDR initialization */
+	spl_dram_init(&mt41k_xx[RAM_4GB]);
+	ramchip = pfla02_detect_ramsize();
+	if (ramchip != RAM_4GB)
+		spl_dram_init(&mt41k_xx[ramchip]);
+
+	/* Clear the BSS. */
+	memset(__bss_start, 0, __bss_end - __bss_start);
+
+	phyflex_err006282_workaround();
+
+	/* load/boot image from boot device */
+	board_init_r(NULL, 0);
+}
+#endif
diff --git a/board/qualcomm/dragonboard410c/dragonboard410c.c b/board/qualcomm/dragonboard410c/dragonboard410c.c
index 37d0b85..848e278 100644
--- a/board/qualcomm/dragonboard410c/dragonboard410c.c
+++ b/board/qualcomm/dragonboard410c/dragonboard410c.c
@@ -128,7 +128,7 @@
 	}
 
 	if (dm_gpio_get_value(&resin)) {
-		setenv("bootdelay", "-1");
+		env_set("bootdelay", "-1");
 		printf("Power button pressed - dropping to console.\n");
 	}
 
diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
index d3c6ba5..530f149 100644
--- a/board/raspberrypi/rpi/rpi.c
+++ b/board/raspberrypi/rpi/rpi.c
@@ -247,11 +247,11 @@
 {
 	const char *fdtfile;
 
-	if (getenv("fdtfile"))
+	if (env_get("fdtfile"))
 		return;
 
 	fdtfile = model->fdtfile;
-	setenv("fdtfile", fdtfile);
+	env_set("fdtfile", fdtfile);
 }
 
 /*
@@ -260,13 +260,13 @@
  */
 static void set_fdt_addr(void)
 {
-	if (getenv("fdt_addr"))
+	if (env_get("fdt_addr"))
 		return;
 
 	if (fdt_magic(fw_dtb_pointer) != FDT_MAGIC)
 		return;
 
-	setenv_hex("fdt_addr", fw_dtb_pointer);
+	env_set_hex("fdt_addr", fw_dtb_pointer);
 }
 
 /*
@@ -287,7 +287,7 @@
 	if (!model->has_onboard_eth)
 		return;
 
-	if (getenv("usbethaddr"))
+	if (env_get("usbethaddr"))
 		return;
 
 	BCM2835_MBOX_INIT_HDR(msg);
@@ -300,10 +300,10 @@
 		return;
 	}
 
-	eth_setenv_enetaddr("usbethaddr", msg->get_mac_address.body.resp.mac);
+	eth_env_set_enetaddr("usbethaddr", msg->get_mac_address.body.resp.mac);
 
-	if (!getenv("ethaddr"))
-		setenv("ethaddr", getenv("usbethaddr"));
+	if (!env_get("ethaddr"))
+		env_set("ethaddr", env_get("usbethaddr"));
 
 	return;
 }
@@ -314,13 +314,13 @@
 	char s[11];
 
 	snprintf(s, sizeof(s), "0x%X", revision);
-	setenv("board_revision", s);
+	env_set("board_revision", s);
 	snprintf(s, sizeof(s), "%d", rev_scheme);
-	setenv("board_rev_scheme", s);
+	env_set("board_rev_scheme", s);
 	/* Can't rename this to board_rev_type since it's an ABI for scripts */
 	snprintf(s, sizeof(s), "0x%X", rev_type);
-	setenv("board_rev", s);
-	setenv("board_name", model->name);
+	env_set("board_rev", s);
+	env_set("board_name", model->name);
 }
 #endif /* CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG */
 
@@ -330,7 +330,7 @@
 	int ret;
 	char serial_string[17] = { 0 };
 
-	if (getenv("serial#"))
+	if (env_get("serial#"))
 		return;
 
 	BCM2835_MBOX_INIT_HDR(msg);
@@ -345,7 +345,7 @@
 
 	snprintf(serial_string, sizeof(serial_string), "%016" PRIx64,
 		 msg->get_board_serial.body.resp.serial);
-	setenv("serial#", serial_string);
+	env_set("serial#", serial_string);
 }
 
 int misc_init_r(void)
diff --git a/board/renesas/alt/alt.c b/board/renesas/alt/alt.c
index b35b6a3..0bf8160 100644
--- a/board/renesas/alt/alt.c
+++ b/board/renesas/alt/alt.c
@@ -143,7 +143,7 @@
 	unsigned char enetaddr[6];
 
 	ret = sh_eth_initialize(bis);
-	if (!eth_getenv_enetaddr("ethaddr", enetaddr))
+	if (!eth_env_get_enetaddr("ethaddr", enetaddr))
 		return ret;
 
 	/* Set Mac address */
diff --git a/board/renesas/blanche/blanche.c b/board/renesas/blanche/blanche.c
index 5156eaf..574dcda 100644
--- a/board/renesas/blanche/blanche.c
+++ b/board/renesas/blanche/blanche.c
@@ -418,10 +418,10 @@
 
 	rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);
 
-	if (!eth_getenv_enetaddr(STR_ENV_ETHADDR, eth_addr)) {
+	if (!eth_env_get_enetaddr(STR_ENV_ETHADDR, eth_addr)) {
 		dev = eth_get_dev_by_index(0);
 		if (dev) {
-			eth_setenv_enetaddr(STR_ENV_ETHADDR, dev->enetaddr);
+			eth_env_set_enetaddr(STR_ENV_ETHADDR, dev->enetaddr);
 		} else {
 			printf("blanche: Couldn't get eth device\n");
 			rc = -1;
diff --git a/board/renesas/ecovec/ecovec.c b/board/renesas/ecovec/ecovec.c
index 28b557a..e4bb440 100644
--- a/board/renesas/ecovec/ecovec.c
+++ b/board/renesas/ecovec/ecovec.c
@@ -55,7 +55,7 @@
 	/* Set MAC address */
 	sprintf(env_mac, "%02X:%02X:%02X:%02X:%02X:%02X",
 		mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
-	setenv("ethaddr", env_mac);
+	env_set("ethaddr", env_mac);
 
 	debug_led(0x0F);
 
diff --git a/board/renesas/gose/gose.c b/board/renesas/gose/gose.c
index 359f95e..54e1269 100644
--- a/board/renesas/gose/gose.c
+++ b/board/renesas/gose/gose.c
@@ -126,7 +126,7 @@
 
 #ifdef CONFIG_SH_ETHER
 	ret = sh_eth_initialize(bis);
-	if (!eth_getenv_enetaddr("ethaddr", enetaddr))
+	if (!eth_env_get_enetaddr("ethaddr", enetaddr))
 		return ret;
 
 	/* Set Mac address */
diff --git a/board/renesas/koelsch/koelsch.c b/board/renesas/koelsch/koelsch.c
index dd62145..8fa648e 100644
--- a/board/renesas/koelsch/koelsch.c
+++ b/board/renesas/koelsch/koelsch.c
@@ -131,7 +131,7 @@
 	unsigned char enetaddr[6];
 
 	ret = sh_eth_initialize(bis);
-	if (!eth_getenv_enetaddr("ethaddr", enetaddr))
+	if (!eth_env_get_enetaddr("ethaddr", enetaddr))
 		return ret;
 
 	/* Set Mac address */
diff --git a/board/renesas/lager/lager.c b/board/renesas/lager/lager.c
index 2ada816..562be04 100644
--- a/board/renesas/lager/lager.c
+++ b/board/renesas/lager/lager.c
@@ -136,7 +136,7 @@
 	unsigned char enetaddr[6];
 
 	ret = sh_eth_initialize(bis);
-	if (!eth_getenv_enetaddr("ethaddr", enetaddr))
+	if (!eth_env_get_enetaddr("ethaddr", enetaddr))
 		return ret;
 
 	/* Set Mac address */
diff --git a/board/renesas/porter/porter.c b/board/renesas/porter/porter.c
index 926a657..5b1a167 100644
--- a/board/renesas/porter/porter.c
+++ b/board/renesas/porter/porter.c
@@ -126,7 +126,7 @@
 	unsigned char enetaddr[6];
 
 	ret = sh_eth_initialize(bis);
-	if (!eth_getenv_enetaddr("ethaddr", enetaddr))
+	if (!eth_env_get_enetaddr("ethaddr", enetaddr))
 		return ret;
 
 	/* Set Mac address */
diff --git a/board/renesas/sh7752evb/sh7752evb.c b/board/renesas/sh7752evb/sh7752evb.c
index 525d979..4a76fb7 100644
--- a/board/renesas/sh7752evb/sh7752evb.c
+++ b/board/renesas/sh7752evb/sh7752evb.c
@@ -221,10 +221,10 @@
 	for (i = 0; i < SH7752EVB_ETHERNET_NUM_CH; i++) {
 		get_sh_eth_mac(i, mac_string, buf);
 		if (i == 0)
-			setenv("ethaddr", mac_string);
+			env_set("ethaddr", mac_string);
 		else {
 			sprintf(env_string, "eth%daddr", i);
-			setenv(env_string, mac_string);
+			env_set(env_string, mac_string);
 		}
 		set_mac_to_sh_giga_eth_register(i, mac_string);
 	}
diff --git a/board/renesas/sh7753evb/sh7753evb.c b/board/renesas/sh7753evb/sh7753evb.c
index 3d1eeda..ca9e144 100644
--- a/board/renesas/sh7753evb/sh7753evb.c
+++ b/board/renesas/sh7753evb/sh7753evb.c
@@ -237,10 +237,10 @@
 	for (i = 0; i < SH7753EVB_ETHERNET_NUM_CH; i++) {
 		get_sh_eth_mac(i, mac_string, buf);
 		if (i == 0)
-			setenv("ethaddr", mac_string);
+			env_set("ethaddr", mac_string);
 		else {
 			sprintf(env_string, "eth%daddr", i);
-			setenv(env_string, mac_string);
+			env_set(env_string, mac_string);
 		}
 		set_mac_to_sh_giga_eth_register(i, mac_string);
 	}
diff --git a/board/renesas/sh7757lcr/sh7757lcr.c b/board/renesas/sh7757lcr/sh7757lcr.c
index 0a04a9d..3f970fc 100644
--- a/board/renesas/sh7757lcr/sh7757lcr.c
+++ b/board/renesas/sh7757lcr/sh7757lcr.c
@@ -278,10 +278,10 @@
 	for (i = 0; i < SH7757LCR_ETHERNET_NUM_CH; i++) {
 		get_sh_eth_mac(i, mac_string, buf);
 		if (i == 0)
-			setenv("ethaddr", mac_string);
+			env_set("ethaddr", mac_string);
 		else {
 			sprintf(env_string, "eth%daddr", i);
-			setenv(env_string, mac_string);
+			env_set(env_string, mac_string);
 		}
 
 		set_mac_to_sh_eth_register(i, mac_string);
@@ -291,7 +291,7 @@
 	for (i = 0; i < SH7757LCR_GIGA_ETHERNET_NUM_CH; i++) {
 		get_sh_eth_mac(i + SH7757LCR_ETHERNET_NUM_CH, mac_string, buf);
 		sprintf(env_string, "eth%daddr", i + SH7757LCR_ETHERNET_NUM_CH);
-		setenv(env_string, mac_string);
+		env_set(env_string, mac_string);
 
 		set_mac_to_sh_giga_eth_register(i, mac_string);
 	}
diff --git a/board/renesas/silk/silk.c b/board/renesas/silk/silk.c
index e13a38f..a8de402 100644
--- a/board/renesas/silk/silk.c
+++ b/board/renesas/silk/silk.c
@@ -135,7 +135,7 @@
 	unsigned char enetaddr[6];
 
 	ret = sh_eth_initialize(bis);
-	if (!eth_getenv_enetaddr("ethaddr", enetaddr))
+	if (!eth_env_get_enetaddr("ethaddr", enetaddr))
 		return ret;
 
 	/* Set Mac address */
diff --git a/board/renesas/stout/stout.c b/board/renesas/stout/stout.c
index fe8dd3d..d681148 100644
--- a/board/renesas/stout/stout.c
+++ b/board/renesas/stout/stout.c
@@ -137,7 +137,7 @@
 	unsigned char enetaddr[6];
 
 	ret = sh_eth_initialize(bis);
-	if (!eth_getenv_enetaddr("ethaddr", enetaddr))
+	if (!eth_env_get_enetaddr("ethaddr", enetaddr))
 		return ret;
 
 	/* Set Mac address */
diff --git a/board/rockchip/kylin_rk3036/kylin_rk3036.c b/board/rockchip/kylin_rk3036/kylin_rk3036.c
index 7e2edf4..9134994 100644
--- a/board/rockchip/kylin_rk3036/kylin_rk3036.c
+++ b/board/rockchip/kylin_rk3036/kylin_rk3036.c
@@ -44,7 +44,7 @@
 {
 	if (fastboot_key_pressed()) {
 		printf("enter fastboot!\n");
-		setenv("preboot", "setenv preboot; fastboot usb0");
+		env_set("preboot", "setenv preboot; fastboot usb0");
 	}
 
 	return 0;
diff --git a/board/rockchip/tinker_rk3288/tinker-rk3288.c b/board/rockchip/tinker_rk3288/tinker-rk3288.c
index c2872e7..790a921 100644
--- a/board/rockchip/tinker_rk3288/tinker-rk3288.c
+++ b/board/rockchip/tinker_rk3288/tinker-rk3288.c
@@ -29,7 +29,7 @@
 		return 0;
 
 	if (is_valid_ethaddr(ethaddr))
-		eth_setenv_enetaddr("ethaddr", ethaddr);
+		eth_env_set_enetaddr("ethaddr", ethaddr);
 
 	return 0;
 }
diff --git a/board/samsung/common/exynos5-dt.c b/board/samsung/common/exynos5-dt.c
index 44f412d..ae2a6e6 100644
--- a/board/samsung/common/exynos5-dt.c
+++ b/board/samsung/common/exynos5-dt.c
@@ -179,7 +179,7 @@
 	if (board_is_odroidxu4())
 		return info;
 
-	return getenv("dfu_alt_system");
+	return env_get("dfu_alt_system");
 }
 
 char *get_dfu_alt_boot(char *interface, char *devstr)
diff --git a/board/samsung/common/misc.c b/board/samsung/common/misc.c
index b18eed2..4157349 100644
--- a/board/samsung/common/misc.c
+++ b/board/samsung/common/misc.c
@@ -51,7 +51,7 @@
 
 	alt_setting = get_dfu_alt_boot(interface, devstr);
 	if (alt_setting) {
-		setenv("dfu_alt_boot", alt_setting);
+		env_set("dfu_alt_boot", alt_setting);
 		offset = snprintf(buf, buf_size, "%s", alt_setting);
 	}
 
@@ -71,7 +71,7 @@
 		status = "done\n";
 	}
 
-	setenv("dfu_alt_info", alt_info);
+	env_set("dfu_alt_info", alt_info);
 	puts(status);
 }
 #endif
@@ -83,14 +83,14 @@
 
 	snprintf(info, ARRAY_SIZE(info), "%u.%u", (s5p_cpu_rev & 0xf0) >> 4,
 		 s5p_cpu_rev & 0xf);
-	setenv("soc_rev", info);
+	env_set("soc_rev", info);
 
 	snprintf(info, ARRAY_SIZE(info), "%x", s5p_cpu_id);
-	setenv("soc_id", info);
+	env_set("soc_id", info);
 
 #ifdef CONFIG_REVISION_TAG
 	snprintf(info, ARRAY_SIZE(info), "%x", get_board_rev());
-	setenv("board_rev", info);
+	env_set("board_rev", info);
 #endif
 #ifdef CONFIG_OF_LIBFDT
 	const char *bdtype = "";
@@ -102,11 +102,11 @@
 		bdtype = "";
 
 	sprintf(info, "%s%s", bdname, bdtype);
-	setenv("boardname", info);
+	env_set("boardname", info);
 #endif
 	snprintf(info, ARRAY_SIZE(info),  "%s%x-%s%s.dtb",
 		 CONFIG_SYS_SOC, s5p_cpu_id, bdname, bdtype);
-	setenv("fdtfile", info);
+	env_set("fdtfile", info);
 #endif
 }
 #endif /* CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG */
diff --git a/board/samsung/odroid/odroid.c b/board/samsung/odroid/odroid.c
index b4cb332..e40a2f6 100644
--- a/board/samsung/odroid/odroid.c
+++ b/board/samsung/odroid/odroid.c
@@ -66,7 +66,7 @@
 #ifdef CONFIG_SET_DFU_ALT_INFO
 char *get_dfu_alt_system(char *interface, char *devstr)
 {
-	return getenv("dfu_alt_system");
+	return env_get("dfu_alt_system");
 }
 
 char *get_dfu_alt_boot(char *interface, char *devstr)
diff --git a/board/samsung/trats/trats.c b/board/samsung/trats/trats.c
index 00059a1..f091338 100644
--- a/board/samsung/trats/trats.c
+++ b/board/samsung/trats/trats.c
@@ -469,7 +469,7 @@
 #endif
 #ifdef CONFIG_S6E8AX0
 	s6e8ax0_init();
-	setenv("lcdinfo", "lcd=s6e8ax0");
+	env_set("lcdinfo", "lcd=s6e8ax0");
 #endif
 }
 #endif
diff --git a/board/samsung/universal_c210/universal.c b/board/samsung/universal_c210/universal.c
index cc6eaf7..549ac8b 100644
--- a/board/samsung/universal_c210/universal.c
+++ b/board/samsung/universal_c210/universal.c
@@ -397,6 +397,6 @@
 	vid->pclk_name = 1;	/* MPLL */
 	vid->sclk_div = 1;
 
-	setenv("lcdinfo", "lcd=ld9040");
+	env_set("lcdinfo", "lcd=ld9040");
 }
 #endif
diff --git a/board/samtec/vining_2000/vining_2000.c b/board/samtec/vining_2000/vining_2000.c
index 5c8b436..af1a3e7 100644
--- a/board/samtec/vining_2000/vining_2000.c
+++ b/board/samtec/vining_2000/vining_2000.c
@@ -131,8 +131,8 @@
 
 	/* just to get secound mac address */
 	imx_get_mac_from_fuse(1, eth1addr);
-	if (!getenv("eth1addr") && is_valid_ethaddr(eth1addr))
-		eth_setenv_enetaddr("eth1addr", eth1addr);
+	if (!env_get("eth1addr") && is_valid_ethaddr(eth1addr))
+		eth_env_set_enetaddr("eth1addr", eth1addr);
 
 	imx_iomux_v3_setup_multiple_pads(fec1_pads, ARRAY_SIZE(fec1_pads));
 
@@ -413,11 +413,11 @@
 		return ret;
 
 	if (val >= VAL_UPPER)
-		setenv("pin_state", "connected");
+		env_set("pin_state", "connected");
 	else if (val < VAL_UPPER && val > VAL_LOWER)
-		setenv("pin_state", "open");
+		env_set("pin_state", "open");
 	else
-		setenv("pin_state", "button");
+		env_set("pin_state", "button");
 
 	return ret;
 }
diff --git a/board/samtec/vining_fpga/socfpga.c b/board/samtec/vining_fpga/socfpga.c
index f888ecb..229b12f 100644
--- a/board/samtec/vining_fpga/socfpga.c
+++ b/board/samtec/vining_fpga/socfpga.c
@@ -69,31 +69,31 @@
 	/* Check EEPROM signature. */
 	if (!(data[0] == 0xa5 && data[1] == 0x5a)) {
 		puts("Invalid I2C EEPROM signature.\n");
-		setenv("unit_serial", "invalid");
-		setenv("unit_ident", "VINing-xxxx-STD");
-		setenv("hostname", "vining-invalid");
+		env_set("unit_serial", "invalid");
+		env_set("unit_ident", "VINing-xxxx-STD");
+		env_set("hostname", "vining-invalid");
 		return 0;
 	}
 
 	/* If 'unit_serial' is already set, do nothing. */
-	if (!getenv("unit_serial")) {
+	if (!env_get("unit_serial")) {
 		/* This field is Big Endian ! */
 		serial = (data[0x54] << 24) | (data[0x55] << 16) |
 			 (data[0x56] << 8) | (data[0x57] << 0);
 		memset(str, 0, sizeof(str));
 		sprintf(str, "%07i", serial);
-		setenv("unit_serial", str);
+		env_set("unit_serial", str);
 	}
 
-	if (!getenv("unit_ident")) {
+	if (!env_get("unit_ident")) {
 		memset(str, 0, sizeof(str));
 		memcpy(str, &data[0x2e], 18);
-		setenv("unit_ident", str);
+		env_set("unit_ident", str);
 	}
 
 	/* Set ethernet address from EEPROM. */
-	if (!getenv("ethaddr") && is_valid_ethaddr(&data[0x62]))
-		eth_setenv_enetaddr("ethaddr", &data[0x62]);
+	if (!env_get("ethaddr") && is_valid_ethaddr(&data[0x62]))
+		eth_env_set_enetaddr("ethaddr", &data[0x62]);
 
 	return 0;
 }
diff --git a/board/siemens/common/board.c b/board/siemens/common/board.c
index b967227..65fa6af 100644
--- a/board/siemens/common/board.c
+++ b/board/siemens/common/board.c
@@ -121,7 +121,7 @@
 	char *ptr_env;
 
 	/* If button is not found we take default */
-	ptr_env = getenv(envname);
+	ptr_env = env_get(envname);
 	if (NULL == ptr_env) {
 		gpio = def;
 	} else {
@@ -199,7 +199,7 @@
 		strcat(str_tmp, num);
 
 		/* If env var is not found we stop */
-		ptr_env = getenv(str_tmp);
+		ptr_env = env_get(str_tmp);
 		if (NULL == ptr_env)
 			break;
 
diff --git a/board/siemens/common/factoryset.c b/board/siemens/common/factoryset.c
index 6c869ed..b4f027a 100644
--- a/board/siemens/common/factoryset.c
+++ b/board/siemens/common/factoryset.c
@@ -266,7 +266,7 @@
 
 static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE;
 
-static int factoryset_mac_setenv(void)
+static int factoryset_mac_env_set(void)
 {
 	uint8_t mac_addr[6];
 
@@ -292,15 +292,15 @@
 		}
 	}
 
-	eth_setenv_enetaddr("ethaddr", mac_addr);
+	eth_env_set_enetaddr("ethaddr", mac_addr);
 	return 0;
 }
 
-int factoryset_setenv(void)
+int factoryset_env_set(void)
 {
 	int ret = 0;
 
-	if (factoryset_mac_setenv() < 0)
+	if (factoryset_mac_env_set() < 0)
 		ret = -1;
 
 	return ret;
diff --git a/board/siemens/common/factoryset.h b/board/siemens/common/factoryset.h
index 3f23d5e..8602627 100644
--- a/board/siemens/common/factoryset.h
+++ b/board/siemens/common/factoryset.h
@@ -25,7 +25,7 @@
 };
 
 int factoryset_read_eeprom(int i2c_addr);
-int factoryset_setenv(void);
+int factoryset_env_set(void);
 extern struct factorysetcontainer factory_dat;
 
 #endif /* __FACTORYSET_H */
diff --git a/board/siemens/draco/board.c b/board/siemens/draco/board.c
index d8869a0..c705b5a 100644
--- a/board/siemens/draco/board.c
+++ b/board/siemens/draco/board.c
@@ -272,13 +272,13 @@
 #ifdef CONFIG_FACTORYSET
 	/* Set ASN in environment*/
 	if (factory_dat.asn[0] != 0) {
-		setenv("dtb_name", (char *)factory_dat.asn);
+		env_set("dtb_name", (char *)factory_dat.asn);
 	} else {
 		/* dtb suffix gets added in load script */
-		setenv("dtb_name", "am335x-draco");
+		env_set("dtb_name", "am335x-draco");
 	}
 #else
-	setenv("dtb_name", "am335x-draco");
+	env_set("dtb_name", "am335x-draco");
 #endif
 
 	return 0;
@@ -330,7 +330,7 @@
 	int n = 0;
 	int rv;
 
-	factoryset_setenv();
+	factoryset_env_set();
 
 	/* Set rgmii mode and enable rmii clock to be sourced from chip */
 	writel((RMII_MODE_ENABLE | RMII_CHIPCKL_ENABLE), &cdev->miisel);
diff --git a/board/siemens/pxm2/board.c b/board/siemens/pxm2/board.c
index 750f338..8bbb035 100644
--- a/board/siemens/pxm2/board.c
+++ b/board/siemens/pxm2/board.c
@@ -225,7 +225,7 @@
 	if (!is_valid_ethaddr(factory_dat.mac))
 		printf("Error: no valid mac address\n");
 	else
-		eth_setenv_enetaddr("ethaddr", factory_dat.mac);
+		eth_env_set_enetaddr("ethaddr", factory_dat.mac);
 #endif /* #ifdef CONFIG_FACTORYSET */
 
 	/* Set rgmii mode and enable rmii clock to be sourced from chip */
@@ -446,12 +446,12 @@
 			factory_dat.pxm50 = 0;
 		sprintf(tmp, "%s_%s", factory_dat.asn,
 			factory_dat.comp_version);
-		ret = setenv("boardid", tmp);
+		ret = env_set("boardid", tmp);
 		if (ret)
 			printf("error setting board id\n");
 	} else {
 		factory_dat.pxm50 = 1;
-		ret = setenv("boardid", "PXM50_1.0");
+		ret = env_set("boardid", "PXM50_1.0");
 		if (ret)
 			printf("error setting board id\n");
 	}
diff --git a/board/siemens/rut/board.c b/board/siemens/rut/board.c
index b3c666c..2a97414 100644
--- a/board/siemens/rut/board.c
+++ b/board/siemens/rut/board.c
@@ -182,7 +182,7 @@
 	int rv;
 
 #ifndef CONFIG_SPL_BUILD
-	factoryset_setenv();
+	factoryset_env_set();
 #endif
 
 	/* Set rgmii mode and enable rmii clock to be sourced from chip */
@@ -482,7 +482,7 @@
 	else
 		strcpy(tmp, "QMX7.E38_4.0");
 
-	ret = setenv("boardid", tmp);
+	ret = env_set("boardid", tmp);
 	if (ret)
 		printf("error setting board id\n");
 
diff --git a/board/siemens/taurus/taurus.c b/board/siemens/taurus/taurus.c
index 4aa8d64..8390bdd 100644
--- a/board/siemens/taurus/taurus.c
+++ b/board/siemens/taurus/taurus.c
@@ -15,6 +15,7 @@
 #include <command.h>
 #include <common.h>
 #include <dm.h>
+#include <environment.h>
 #include <asm/io.h>
 #include <asm/arch/at91sam9260_matrix.h>
 #include <asm/arch/at91sam9_smc.h>
@@ -376,36 +377,36 @@
 	char *kern_size;
 	char *kern_size_fb;
 
-	partitionset_active = getenv("partitionset_active");
+	partitionset_active = env_get("partitionset_active");
 	if (partitionset_active) {
 		if (partitionset_active[0] == 'A')
-			setenv("partitionset_active", "B");
+			env_set("partitionset_active", "B");
 		else
-			setenv("partitionset_active", "A");
+			env_set("partitionset_active", "A");
 	} else {
 		printf("partitionset_active missing.\n");
 		return -ENOENT;
 	}
 
-	rootfs = getenv("rootfs");
-	rootfs_fallback = getenv("rootfs_fallback");
-	setenv("rootfs", rootfs_fallback);
-	setenv("rootfs_fallback", rootfs);
+	rootfs = env_get("rootfs");
+	rootfs_fallback = env_get("rootfs_fallback");
+	env_set("rootfs", rootfs_fallback);
+	env_set("rootfs_fallback", rootfs);
 
-	kern_size = getenv("kernel_size");
-	kern_size_fb = getenv("kernel_size_fallback");
-	setenv("kernel_size", kern_size_fb);
-	setenv("kernel_size_fallback", kern_size);
+	kern_size = env_get("kernel_size");
+	kern_size_fb = env_get("kernel_size_fallback");
+	env_set("kernel_size", kern_size_fb);
+	env_set("kernel_size_fallback", kern_size);
 
-	kern_off = getenv("kernel_Off");
-	kern_off_fb = getenv("kernel_Off_fallback");
-	setenv("kernel_Off", kern_off_fb);
-	setenv("kernel_Off_fallback", kern_off);
+	kern_off = env_get("kernel_Off");
+	kern_off_fb = env_get("kernel_Off_fallback");
+	env_set("kernel_Off", kern_off_fb);
+	env_set("kernel_Off_fallback", kern_off);
 
-	setenv("bootargs", '\0');
-	setenv("upgrade_available", '\0');
-	setenv("boot_retries", '\0');
-	saveenv();
+	env_set("bootargs", '\0');
+	env_set("upgrade_available", '\0');
+	env_set("boot_retries", '\0');
+	env_save();
 
 	return 0;
 }
@@ -417,14 +418,14 @@
 	unsigned long boot_retry = 0;
 	char boot_buf[10];
 
-	upgrade_available = simple_strtoul(getenv("upgrade_available"), NULL,
+	upgrade_available = simple_strtoul(env_get("upgrade_available"), NULL,
 					   10);
 	if (upgrade_available) {
-		boot_retry = simple_strtoul(getenv("boot_retries"), NULL, 10);
+		boot_retry = simple_strtoul(env_get("boot_retries"), NULL, 10);
 		boot_retry++;
 		sprintf(boot_buf, "%lx", boot_retry);
-		setenv("boot_retries", boot_buf);
-		saveenv();
+		env_set("boot_retries", boot_buf);
+		env_save();
 
 		/*
 		 * Here the boot_retries count is checked, and if the
diff --git a/board/silica/pengwyn/board.c b/board/silica/pengwyn/board.c
index 1f5a586..0429e6f 100644
--- a/board/silica/pengwyn/board.c
+++ b/board/silica/pengwyn/board.c
@@ -171,7 +171,7 @@
 	uint8_t mac_addr[6];
 	uint32_t mac_hi, mac_lo;
 
-	if (!eth_getenv_enetaddr("ethaddr", mac_addr)) {
+	if (!eth_env_get_enetaddr("ethaddr", mac_addr)) {
 		printf("<ethaddr> not set. Reading from E-fuse\n");
 		/* try reading mac address from efuse */
 		mac_lo = readl(&cdev->macid0l);
@@ -184,7 +184,7 @@
 		mac_addr[5] = (mac_lo & 0xFF00) >> 8;
 
 		if (is_valid_ethaddr(mac_addr))
-			eth_setenv_enetaddr("ethaddr", mac_addr);
+			eth_env_set_enetaddr("ethaddr", mac_addr);
 		else
 			return n;
 	}
diff --git a/board/socrates/socrates.c b/board/socrates/socrates.c
index fb691c2..004f370 100644
--- a/board/socrates/socrates.c
+++ b/board/socrates/socrates.c
@@ -38,7 +38,7 @@
 	volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
 	char buf[64];
 	int f;
-	int i = getenv_f("serial#", buf, sizeof(buf));
+	int i = env_get_f("serial#", buf, sizeof(buf));
 #ifdef CONFIG_PCI
 	char *src;
 #endif
@@ -409,7 +409,7 @@
 		printf ("hwmon IC init failed\n");
 
 	if (flag) {
-		param = getenv("brightness");
+		param = env_get("brightness");
 		rc = param ? simple_strtol(param, NULL, 10) : -1;
 		if (rc < 0)
 			rc = DEFAULT_BRIGHTNESS;
diff --git a/board/solidrun/mx6cuboxi/mx6cuboxi.c b/board/solidrun/mx6cuboxi/mx6cuboxi.c
index 1ccdfa8..7e59fb2 100644
--- a/board/solidrun/mx6cuboxi/mx6cuboxi.c
+++ b/board/solidrun/mx6cuboxi/mx6cuboxi.c
@@ -376,14 +376,14 @@
 {
 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
 	if (is_hummingboard())
-		setenv("board_name", "HUMMINGBOARD");
+		env_set("board_name", "HUMMINGBOARD");
 	else
-		setenv("board_name", "CUBOXI");
+		env_set("board_name", "CUBOXI");
 
 	if (is_mx6dq())
-		setenv("board_rev", "MX6Q");
+		env_set("board_rev", "MX6Q");
 	else
-		setenv("board_rev", "MX6DL");
+		env_set("board_rev", "MX6DL");
 #endif
 
 	return 0;
diff --git a/board/spear/common/spr_misc.c b/board/spear/common/spr_misc.c
index d6a84db..a02304f 100644
--- a/board/spear/common/spr_misc.c
+++ b/board/spear/common/spr_misc.c
@@ -53,15 +53,15 @@
 #if defined(CONFIG_CMD_NET)
 	uchar mac_id[6];
 
-	if (!eth_getenv_enetaddr("ethaddr", mac_id) && !i2c_read_mac(mac_id))
-		eth_setenv_enetaddr("ethaddr", mac_id);
+	if (!eth_env_get_enetaddr("ethaddr", mac_id) && !i2c_read_mac(mac_id))
+		eth_env_set_enetaddr("ethaddr", mac_id);
 #endif
-	setenv("verify", "n");
+	env_set("verify", "n");
 
 #if defined(CONFIG_SPEAR_USBTTY)
-	setenv("stdin", "usbtty");
-	setenv("stdout", "usbtty");
-	setenv("stderr", "usbtty");
+	env_set("stdin", "usbtty");
+	env_set("stdout", "usbtty");
+	env_set("stderr", "usbtty");
 
 #ifndef CONFIG_SYS_NO_DCACHE
 	dcache_enable();
diff --git a/board/st/stm32f429-discovery/stm32f429-discovery.c b/board/st/stm32f429-discovery/stm32f429-discovery.c
index 8c8abf6..d6763c3 100644
--- a/board/st/stm32f429-discovery/stm32f429-discovery.c
+++ b/board/st/stm32f429-discovery/stm32f429-discovery.c
@@ -314,13 +314,13 @@
 	char serialno[25];
 	uint32_t u_id_low, u_id_mid, u_id_high;
 
-	if (!getenv("serial#")) {
+	if (!env_get("serial#")) {
 		u_id_low  = readl(&STM32_U_ID->u_id_low);
 		u_id_mid  = readl(&STM32_U_ID->u_id_mid);
 		u_id_high = readl(&STM32_U_ID->u_id_high);
 		sprintf(serialno, "%08x%08x%08x",
 			u_id_high, u_id_mid, u_id_low);
-		setenv("serial#", serialno);
+		env_set("serial#", serialno);
 	}
 
 	return 0;
diff --git a/board/sunxi/MAINTAINERS b/board/sunxi/MAINTAINERS
index e9f3e35..ff6eea2 100644
--- a/board/sunxi/MAINTAINERS
+++ b/board/sunxi/MAINTAINERS
@@ -88,11 +88,21 @@
 S:	Maintained
 F:	configs/A20-OLinuXino-Lime2_defconfig
 
+A20-OLINUXINO-LIME2-EMMC BOARD
+M:	Olliver Schinagl <oliver@schinagl.nl>
+S:	Maintained
+F:	configs/A20-OLinuXino-Lime2-eMMC_defconfig
+
 A33-OLINUXINO BOARD
 M:	Stefan Mavrodiev <stefan.mavrodiev@gmail.com>
 S:	Maintained
 F:	configs/A33-OLinuXino_defconfig
 
+A64-OLINUXINO BOARD
+M:	Jagan Teki <jagan@amarulasolutions.com>
+S:	Maintained
+F:	configs/a64-olinuxino_defconfig
+
 A80 OPTIMUS BOARD
 M:	Chen-Yu Tsai <wens@csie.org>
 S:	Maintained
@@ -267,6 +277,11 @@
 S:	Maintained
 F:	configs/nanopi_neo_air_defconfig
 
+NANOPI-A64 BOARD
+M:	Jagan Teki <jagan@amarulasolutions.com>
+S:	Maintained
+F:	configs/nanopi_a64_defconfig
+
 NINTENDO NES CLASSIC EDITION BOARD
 M:	FUKAUMI Naoki <naobsd@gmail.com>
 S:	Maintained
diff --git a/board/sunxi/board.c b/board/sunxi/board.c
index 800f412..70e0143 100644
--- a/board/sunxi/board.c
+++ b/board/sunxi/board.c
@@ -602,7 +602,7 @@
 	char *serial_string;
 	unsigned long long serial;
 
-	serial_string = getenv("serial#");
+	serial_string = env_get("serial#");
 
 	if (serial_string) {
 		serial = simple_strtoull(serial_string, NULL, 16);
@@ -646,7 +646,7 @@
 		return;
 	}
 	/* otherwise assume .scr format (mkimage-type script) */
-	setenv_hex("fel_scriptaddr", spl->fel_script_address);
+	env_set_hex("fel_scriptaddr", spl->fel_script_address);
 }
 
 /*
@@ -694,7 +694,7 @@
 			else
 				sprintf(ethaddr, "eth%daddr", i);
 
-			if (getenv(ethaddr))
+			if (env_get(ethaddr))
 				continue;
 
 			/* Non OUI / registered MAC address */
@@ -705,14 +705,14 @@
 			mac_addr[4] = (sid[3] >>  8) & 0xff;
 			mac_addr[5] = (sid[3] >>  0) & 0xff;
 
-			eth_setenv_enetaddr(ethaddr, mac_addr);
+			eth_env_set_enetaddr(ethaddr, mac_addr);
 		}
 
-		if (!getenv("serial#")) {
+		if (!env_get("serial#")) {
 			snprintf(serial_string, sizeof(serial_string),
 				"%08x%08x", sid[0], sid[3]);
 
-			setenv("serial#", serial_string);
+			env_set("serial#", serial_string);
 		}
 	}
 }
@@ -721,11 +721,11 @@
 {
 	__maybe_unused int ret;
 
-	setenv("fel_booted", NULL);
-	setenv("fel_scriptaddr", NULL);
+	env_set("fel_booted", NULL);
+	env_set("fel_scriptaddr", NULL);
 	/* determine if we are running in FEL mode */
 	if (!is_boot0_magic(SPL_ADDR + 4)) { /* eGON.BT0 */
-		setenv("fel_booted", "1");
+		env_set("fel_booted", "1");
 		parse_spl_header(SPL_ADDR);
 	}
 
diff --git a/board/syteco/zmx25/zmx25.c b/board/syteco/zmx25/zmx25.c
index bdbf02a..85fda13 100644
--- a/board/syteco/zmx25/zmx25.c
+++ b/board/syteco/zmx25/zmx25.c
@@ -146,7 +146,7 @@
 	udelay(5000);
 #endif
 
-	e = getenv("gs_base_board");
+	e = env_get("gs_base_board");
 	if (e != NULL) {
 		if (strcmp(e, "G283") == 0) {
 			int key = gpio_get_value(IMX_GPIO_NR(2, 29));
@@ -156,9 +156,9 @@
 				gpio_set_value(IMX_GPIO_NR(1, 29), 0);
 				gpio_set_value(IMX_GPIO_NR(4, 21), 0);
 
-				setenv("preboot", "run gs_slow_boot");
+				env_set("preboot", "run gs_slow_boot");
 			} else
-				setenv("preboot", "run gs_fast_boot");
+				env_set("preboot", "run gs_fast_boot");
 		}
 	}
 
diff --git a/board/tcl/sl50/board.c b/board/tcl/sl50/board.c
index e89ee35..f79bb9d 100644
--- a/board/tcl/sl50/board.c
+++ b/board/tcl/sl50/board.c
@@ -76,8 +76,8 @@
 
 #ifdef CONFIG_SPL_ENV_SUPPORT
 	env_init();
-	env_relocate_spec();
-	if (getenv_yesno("boot_os") != 1)
+	env_load();
+	if (env_get_yesno("boot_os") != 1)
 		return 1;
 #endif
 
@@ -322,11 +322,11 @@
 
 #if (defined(CONFIG_DRIVER_TI_CPSW) && !defined(CONFIG_SPL_BUILD)) || \
 	(defined(CONFIG_SPL_ETH_SUPPORT) && defined(CONFIG_SPL_BUILD))
-	if (!getenv("ethaddr")) {
+	if (!env_get("ethaddr")) {
 		printf("<ethaddr> not set. Validating first E-fuse MAC\n");
 
 		if (is_valid_ethaddr(mac_addr))
-			eth_setenv_enetaddr("ethaddr", mac_addr);
+			eth_env_set_enetaddr("ethaddr", mac_addr);
 	}
 
 #ifdef CONFIG_DRIVER_TI_CPSW
@@ -340,9 +340,9 @@
 	mac_addr[4] = mac_lo & 0xFF;
 	mac_addr[5] = (mac_lo & 0xFF00) >> 8;
 
-	if (!getenv("eth1addr")) {
+	if (!env_get("eth1addr")) {
 		if (is_valid_ethaddr(mac_addr))
-			eth_setenv_enetaddr("eth1addr", mac_addr);
+			eth_env_set_enetaddr("eth1addr", mac_addr);
 	}
 
 
@@ -373,7 +373,7 @@
 #if defined(CONFIG_USB_ETHER) && \
 	(!defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_USBETH_SUPPORT))
 	if (is_valid_ether_addr(mac_addr))
-		eth_setenv_enetaddr("usbnet_devaddr", mac_addr);
+		eth_env_set_enetaddr("usbnet_devaddr", mac_addr);
 
 	rv = usb_eth_initialize(bis);
 	if (rv < 0)
diff --git a/board/technexion/twister/twister.c b/board/technexion/twister/twister.c
index 25aeebc..8c38f14 100644
--- a/board/technexion/twister/twister.c
+++ b/board/technexion/twister/twister.c
@@ -94,7 +94,7 @@
 
 	omap_die_id_display();
 
-	eth_addr = getenv("ethaddr");
+	eth_addr = env_get("ethaddr");
 	if (eth_addr)
 		return 0;
 
diff --git a/board/technologic/ts4800/ts4800.c b/board/technologic/ts4800/ts4800.c
index 94251c6..8fe26a7 100644
--- a/board/technologic/ts4800/ts4800.c
+++ b/board/technologic/ts4800/ts4800.c
@@ -178,7 +178,7 @@
 		ethaddr[i] = (reg_mac[i / 4] >> ((i % 4) * 8)) & 0xFF;
 
 	if (is_valid_ethaddr(ethaddr)) {
-		eth_setenv_enetaddr("ethaddr", ethaddr);
+		eth_env_set_enetaddr("ethaddr", ethaddr);
 		return 0;
 	}
 
diff --git a/board/teejet/mt_ventoux/mt_ventoux.c b/board/teejet/mt_ventoux/mt_ventoux.c
index 6e73ae1..9eaae50 100644
--- a/board/teejet/mt_ventoux/mt_ventoux.c
+++ b/board/teejet/mt_ventoux/mt_ventoux.c
@@ -261,7 +261,7 @@
 
 	if (ret)
 		return 0;
-	eth_addr = getenv("ethaddr");
+	eth_addr = env_get("ethaddr");
 	if (!eth_addr)
 		TAM3517_READ_MAC_FROM_EEPROM(&info);
 
@@ -311,7 +311,7 @@
 
 	fb = (void *)0x88000000;
 
-	s = getenv("panel");
+	s = env_get("panel");
 	if (s) {
 		index = simple_strtoul(s, NULL, 10);
 		if (index < ARRAY_SIZE(lcd_cfg))
diff --git a/board/theobroma-systems/puma_rk3399/puma-rk3399.c b/board/theobroma-systems/puma_rk3399/puma-rk3399.c
index 9347329..c6f8eed 100644
--- a/board/theobroma-systems/puma_rk3399/puma-rk3399.c
+++ b/board/theobroma-systems/puma_rk3399/puma-rk3399.c
@@ -63,13 +63,13 @@
 {
 #if CONFIG_IS_ENABLED(CMD_NET)
 	int ret;
-	const char *cpuid = getenv("cpuid#");
+	const char *cpuid = env_get("cpuid#");
 	u8 hash[SHA256_SUM_LEN];
 	int size = sizeof(hash);
 	u8 mac_addr[6];
 
 	/* Only generate a MAC address, if none is set in the environment */
-	if (getenv("ethaddr"))
+	if (env_get("ethaddr"))
 		return;
 
 	if (!cpuid) {
@@ -89,7 +89,7 @@
 	/* Make this a valid MAC address and set it */
 	mac_addr[0] &= 0xfe;  /* clear multicast bit */
 	mac_addr[0] |= 0x02;  /* set local assignment bit (IEEE802) */
-	eth_setenv_enetaddr("ethaddr", mac_addr);
+	eth_env_set_enetaddr("ethaddr", mac_addr);
 #endif
 
 	return;
@@ -144,8 +144,8 @@
 	serialno |= (u64)crc32_no_comp(serialno, high, 8) << 32;
 	snprintf(serialno_str, sizeof(serialno_str), "%llx", serialno);
 
-	setenv("cpuid#", cpuid_str);
-	setenv("serial#", serialno_str);
+	env_set("cpuid#", cpuid_str);
+	env_set("serial#", serialno_str);
 #endif
 
 	return;
@@ -165,7 +165,7 @@
 	char *serial_string;
 	u64 serial = 0;
 
-	serial_string = getenv("serial#");
+	serial_string = env_get("serial#");
 
 	if (serial_string)
 		serial = simple_strtoull(serial_string, NULL, 16);
diff --git a/board/ti/am335x/board.c b/board/ti/am335x/board.c
index 0a16529..1a52bff 100644
--- a/board/ti/am335x/board.c
+++ b/board/ti/am335x/board.c
@@ -249,8 +249,8 @@
 
 #ifdef CONFIG_SPL_ENV_SUPPORT
 	env_init();
-	env_relocate_spec();
-	if (getenv_yesno("boot_os") != 1)
+	env_load();
+	if (env_get_yesno("boot_os") != 1)
 		return 1;
 #endif
 
@@ -731,7 +731,7 @@
 	 * on HS devices.
 	 */
 	if (get_device_type() == HS_DEVICE)
-		setenv("boot_fit", "1");
+		env_set("boot_fit", "1");
 #endif
 
 #if !defined(CONFIG_SPL_BUILD)
@@ -745,11 +745,11 @@
 	mac_addr[4] = mac_lo & 0xFF;
 	mac_addr[5] = (mac_lo & 0xFF00) >> 8;
 
-	if (!getenv("ethaddr")) {
+	if (!env_get("ethaddr")) {
 		printf("<ethaddr> not set. Validating first E-fuse MAC\n");
 
 		if (is_valid_ethaddr(mac_addr))
-			eth_setenv_enetaddr("ethaddr", mac_addr);
+			eth_env_set_enetaddr("ethaddr", mac_addr);
 	}
 
 	mac_lo = readl(&cdev->macid1l);
@@ -761,9 +761,9 @@
 	mac_addr[4] = mac_lo & 0xFF;
 	mac_addr[5] = (mac_lo & 0xFF00) >> 8;
 
-	if (!getenv("eth1addr")) {
+	if (!env_get("eth1addr")) {
 		if (is_valid_ethaddr(mac_addr))
-			eth_setenv_enetaddr("eth1addr", mac_addr);
+			eth_env_set_enetaddr("eth1addr", mac_addr);
 	}
 #endif
 
@@ -908,7 +908,7 @@
 #if defined(CONFIG_USB_ETHER) && \
 	(!defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_USBETH_SUPPORT))
 	if (is_valid_ethaddr(mac_addr))
-		eth_setenv_enetaddr("usbnet_devaddr", mac_addr);
+		eth_env_set_enetaddr("usbnet_devaddr", mac_addr);
 
 	rv = usb_eth_initialize(bis);
 	if (rv < 0)
diff --git a/board/ti/am43xx/board.c b/board/ti/am43xx/board.c
index 933596d..2c417e7 100644
--- a/board/ti/am43xx/board.c
+++ b/board/ti/am43xx/board.c
@@ -626,7 +626,7 @@
 	 * on HS devices.
 	 */
 	if (get_device_type() == HS_DEVICE)
-		setenv("boot_fit", "1");
+		env_set("boot_fit", "1");
 #endif
 	return 0;
 }
@@ -791,10 +791,10 @@
 	mac_addr[4] = mac_lo & 0xFF;
 	mac_addr[5] = (mac_lo & 0xFF00) >> 8;
 
-	if (!getenv("ethaddr")) {
+	if (!env_get("ethaddr")) {
 		puts("<ethaddr> not set. Validating first E-fuse MAC\n");
 		if (is_valid_ethaddr(mac_addr))
-			eth_setenv_enetaddr("ethaddr", mac_addr);
+			eth_env_set_enetaddr("ethaddr", mac_addr);
 	}
 
 	mac_lo = readl(&cdev->macid1l);
@@ -806,9 +806,9 @@
 	mac_addr[4] = mac_lo & 0xFF;
 	mac_addr[5] = (mac_lo & 0xFF00) >> 8;
 
-	if (!getenv("eth1addr")) {
+	if (!env_get("eth1addr")) {
 		if (is_valid_ethaddr(mac_addr))
-			eth_setenv_enetaddr("eth1addr", mac_addr);
+			eth_env_set_enetaddr("eth1addr", mac_addr);
 	}
 
 	if (board_is_eposevm()) {
diff --git a/board/ti/am57xx/board.c b/board/ti/am57xx/board.c
index 00a31a97..7e7056c 100644
--- a/board/ti/am57xx/board.c
+++ b/board/ti/am57xx/board.c
@@ -592,7 +592,7 @@
 		/* we will let default be "no lcd" */
 	}
 out:
-	setenv("idk_lcd", idk_lcd);
+	env_set("idk_lcd", idk_lcd);
 	return;
 }
 
@@ -612,7 +612,7 @@
 	 * on HS devices.
 	 */
 	if (get_device_type() == HS_DEVICE)
-		setenv("boot_fit", "1");
+		env_set("boot_fit", "1");
 
 	/*
 	 * Set the GPIO7 Pad to POWERHOLD. This has higher priority
@@ -742,8 +742,8 @@
 
 #ifdef CONFIG_SPL_ENV_SUPPORT
 	env_init();
-	env_relocate_spec();
-	if (getenv_yesno("boot_os") != 1)
+	env_load();
+	if (env_get_yesno("boot_os") != 1)
 		return 1;
 #endif
 
@@ -933,11 +933,11 @@
 	mac_addr[4] = (mac_lo & 0xFF00) >> 8;
 	mac_addr[5] = mac_lo & 0xFF;
 
-	if (!getenv("ethaddr")) {
+	if (!env_get("ethaddr")) {
 		printf("<ethaddr> not set. Validating first E-fuse MAC\n");
 
 		if (is_valid_ethaddr(mac_addr))
-			eth_setenv_enetaddr("ethaddr", mac_addr);
+			eth_env_set_enetaddr("ethaddr", mac_addr);
 	}
 
 	mac_lo = readl((*ctrl)->control_core_mac_id_1_lo);
@@ -949,9 +949,9 @@
 	mac_addr[4] = (mac_lo & 0xFF00) >> 8;
 	mac_addr[5] = mac_lo & 0xFF;
 
-	if (!getenv("eth1addr")) {
+	if (!env_get("eth1addr")) {
 		if (is_valid_ethaddr(mac_addr))
-			eth_setenv_enetaddr("eth1addr", mac_addr);
+			eth_env_set_enetaddr("eth1addr", mac_addr);
 	}
 
 	ctrl_val = readl((*ctrl)->control_core_control_io1) & (~0x33);
@@ -986,9 +986,9 @@
 			for (i = 0; i < num_macs; i++) {
 				u64_to_mac(mac1 + i, mac_addr);
 				if (is_valid_ethaddr(mac_addr)) {
-					eth_setenv_enetaddr_by_index("eth",
-								     i + 2,
-								     mac_addr);
+					eth_env_set_enetaddr_by_index("eth",
+								      i + 2,
+								      mac_addr);
 				}
 			}
 		}
diff --git a/board/ti/beagle/beagle.c b/board/ti/beagle/beagle.c
index 887b577..2f62fbe 100644
--- a/board/ti/beagle/beagle.c
+++ b/board/ti/beagle/beagle.c
@@ -341,16 +341,16 @@
 	switch (get_board_revision()) {
 	case REVISION_AXBX:
 		printf("Beagle Rev Ax/Bx\n");
-		setenv("beaglerev", "AxBx");
+		env_set("beaglerev", "AxBx");
 		break;
 	case REVISION_CX:
 		printf("Beagle Rev C1/C2/C3\n");
-		setenv("beaglerev", "Cx");
+		env_set("beaglerev", "Cx");
 		MUX_BEAGLE_C();
 		break;
 	case REVISION_C4:
 		printf("Beagle Rev C4\n");
-		setenv("beaglerev", "C4");
+		env_set("beaglerev", "C4");
 		MUX_BEAGLE_C();
 		/* Set VAUX2 to 1.8V for EHCI PHY */
 		twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
@@ -360,7 +360,7 @@
 		break;
 	case REVISION_XM_AB:
 		printf("Beagle xM Rev A/B\n");
-		setenv("beaglerev", "xMAB");
+		env_set("beaglerev", "xMAB");
 		MUX_BEAGLE_XM();
 		/* Set VAUX2 to 1.8V for EHCI PHY */
 		twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
@@ -371,7 +371,7 @@
 		break;
 	case REVISION_XM_C:
 		printf("Beagle xM Rev C\n");
-		setenv("beaglerev", "xMC");
+		env_set("beaglerev", "xMC");
 		MUX_BEAGLE_XM();
 		/* Set VAUX2 to 1.8V for EHCI PHY */
 		twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
@@ -397,14 +397,14 @@
 			expansion_config.revision,
 			expansion_config.fab_revision);
 		MUX_TINCANTOOLS_ZIPPY();
-		setenv("buddy", "zippy");
+		env_set("buddy", "zippy");
 		break;
 	case TINCANTOOLS_ZIPPY2:
 		printf("Recognized Tincantools Zippy2 board (rev %d %s)\n",
 			expansion_config.revision,
 			expansion_config.fab_revision);
 		MUX_TINCANTOOLS_ZIPPY();
-		setenv("buddy", "zippy2");
+		env_set("buddy", "zippy2");
 		break;
 	case TINCANTOOLS_TRAINER:
 		printf("Recognized Tincantools Trainer board (rev %d %s)\n",
@@ -412,37 +412,37 @@
 			expansion_config.fab_revision);
 		MUX_TINCANTOOLS_ZIPPY();
 		MUX_TINCANTOOLS_TRAINER();
-		setenv("buddy", "trainer");
+		env_set("buddy", "trainer");
 		break;
 	case TINCANTOOLS_SHOWDOG:
 		printf("Recognized Tincantools Showdow board (rev %d %s)\n",
 			expansion_config.revision,
 			expansion_config.fab_revision);
 		/* Place holder for DSS2 definition for showdog lcd */
-		setenv("defaultdisplay", "showdoglcd");
-		setenv("buddy", "showdog");
+		env_set("defaultdisplay", "showdoglcd");
+		env_set("buddy", "showdog");
 		break;
 	case KBADC_BEAGLEFPGA:
 		printf("Recognized KBADC Beagle FPGA board\n");
 		MUX_KBADC_BEAGLEFPGA();
-		setenv("buddy", "beaglefpga");
+		env_set("buddy", "beaglefpga");
 		break;
 	case LW_BEAGLETOUCH:
 		printf("Recognized Liquidware BeagleTouch board\n");
-		setenv("buddy", "beagletouch");
+		env_set("buddy", "beagletouch");
 		break;
 	case BRAINMUX_LCDOG:
 		printf("Recognized Brainmux LCDog board\n");
-		setenv("buddy", "lcdog");
+		env_set("buddy", "lcdog");
 		break;
 	case BRAINMUX_LCDOGTOUCH:
 		printf("Recognized Brainmux LCDog Touch board\n");
-		setenv("buddy", "lcdogtouch");
+		env_set("buddy", "lcdogtouch");
 		break;
 	case BBTOYS_WIFI:
 		printf("Recognized BeagleBoardToys WiFi board\n");
 		MUX_BBTOYS_WIFI()
-		setenv("buddy", "bbtoys-wifi");
+		env_set("buddy", "bbtoys-wifi");
 		break;
 	case BBTOYS_VGA:
 		printf("Recognized BeagleBoardToys VGA board\n");
@@ -459,20 +459,20 @@
 	case LSR_COM6L_ADPT:
 		printf("Recognized LSR COM6L Adapter Board\n");
 		MUX_BBTOYS_WIFI()
-		setenv("buddy", "lsr-com6l-adpt");
+		env_set("buddy", "lsr-com6l-adpt");
 		break;
 	case BEAGLE_NO_EEPROM:
 		printf("No EEPROM on expansion board\n");
-		setenv("buddy", "none");
+		env_set("buddy", "none");
 		break;
 	default:
 		printf("Unrecognized expansion board: %x\n",
 			expansion_config.device_vendor);
-		setenv("buddy", "unknown");
+		env_set("buddy", "unknown");
 	}
 
 	if (expansion_config.content == 1)
-		setenv(expansion_config.env_var, expansion_config.env_setting);
+		env_set(expansion_config.env_var, expansion_config.env_setting);
 
 	twl4030_power_init();
 	switch (get_board_revision()) {
diff --git a/board/ti/common/Kconfig b/board/ti/common/Kconfig
index c81baa1..c21eb8c 100644
--- a/board/ti/common/Kconfig
+++ b/board/ti/common/Kconfig
@@ -42,4 +42,3 @@
 	imply CMD_SPI
 	imply CMD_TIME
 	imply CMD_USB if USB
-	imply ENV_IS_IN_FAT if MMC_OMAP_HS
diff --git a/board/ti/common/board_detect.c b/board/ti/common/board_detect.c
index 1da5ace..6f07ec3 100644
--- a/board/ti/common/board_detect.c
+++ b/board/ti/common/board_detect.c
@@ -379,21 +379,21 @@
 	struct ti_common_eeprom *ep = TI_EEPROM_DATA;
 
 	if (name)
-		setenv("board_name", name);
+		env_set("board_name", name);
 	else if (ep->name)
-		setenv("board_name", ep->name);
+		env_set("board_name", ep->name);
 	else
-		setenv("board_name", unknown);
+		env_set("board_name", unknown);
 
 	if (ep->version)
-		setenv("board_rev", ep->version);
+		env_set("board_rev", ep->version);
 	else
-		setenv("board_rev", unknown);
+		env_set("board_rev", unknown);
 
 	if (ep->serial)
-		setenv("board_serial", ep->serial);
+		env_set("board_serial", ep->serial);
 	else
-		setenv("board_serial", unknown);
+		env_set("board_serial", unknown);
 }
 
 static u64 mac_to_u64(u8 mac[6])
@@ -451,8 +451,8 @@
 		for (i = 0; i < num_macs; i++) {
 			u64_to_mac(mac1 + i, mac_addr);
 			if (is_valid_ethaddr(mac_addr)) {
-				eth_setenv_enetaddr_by_index("eth", i + index,
-							     mac_addr);
+				eth_env_set_enetaddr_by_index("eth", i + index,
+							      mac_addr);
 			}
 		}
 	}
diff --git a/board/ti/dra7xx/evm.c b/board/ti/dra7xx/evm.c
index 7d36f03..93d3d0b 100644
--- a/board/ti/dra7xx/evm.c
+++ b/board/ti/dra7xx/evm.c
@@ -558,7 +558,7 @@
 	 * on HS devices.
 	 */
 	if (get_device_type() == HS_DEVICE)
-		setenv("boot_fit", "1");
+		env_set("boot_fit", "1");
 
 	omap_die_id_serial();
 	omap_set_fastboot_vars();
@@ -825,8 +825,8 @@
 
 #ifdef CONFIG_SPL_ENV_SUPPORT
 	env_init();
-	env_relocate_spec();
-	if (getenv_yesno("boot_os") != 1)
+	env_load();
+	if (env_get_yesno("boot_os") != 1)
 		return 1;
 #endif
 
@@ -893,11 +893,11 @@
 	mac_addr[4] = (mac_lo & 0xFF00) >> 8;
 	mac_addr[5] = mac_lo & 0xFF;
 
-	if (!getenv("ethaddr")) {
+	if (!env_get("ethaddr")) {
 		printf("<ethaddr> not set. Validating first E-fuse MAC\n");
 
 		if (is_valid_ethaddr(mac_addr))
-			eth_setenv_enetaddr("ethaddr", mac_addr);
+			eth_env_set_enetaddr("ethaddr", mac_addr);
 	}
 
 	mac_lo = readl((*ctrl)->control_core_mac_id_1_lo);
@@ -909,9 +909,9 @@
 	mac_addr[4] = (mac_lo & 0xFF00) >> 8;
 	mac_addr[5] = mac_lo & 0xFF;
 
-	if (!getenv("eth1addr")) {
+	if (!env_get("eth1addr")) {
 		if (is_valid_ethaddr(mac_addr))
-			eth_setenv_enetaddr("eth1addr", mac_addr);
+			eth_env_set_enetaddr("eth1addr", mac_addr);
 	}
 
 	ctrl_val = readl((*ctrl)->control_core_control_io1) & (~0x33);
diff --git a/board/ti/evm/evm.c b/board/ti/evm/evm.c
index 6f75bd1..6bf57f9 100644
--- a/board/ti/evm/evm.c
+++ b/board/ti/evm/evm.c
@@ -297,10 +297,10 @@
 
 	rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);
 
-	if (!eth_getenv_enetaddr(STR_ENV_ETHADDR, eth_addr)) {
+	if (!eth_env_get_enetaddr(STR_ENV_ETHADDR, eth_addr)) {
 		dev = eth_get_dev_by_index(0);
 		if (dev) {
-			eth_setenv_enetaddr(STR_ENV_ETHADDR, dev->enetaddr);
+			eth_env_set_enetaddr(STR_ENV_ETHADDR, dev->enetaddr);
 		} else {
 			printf("omap3evm: Couldn't get eth device\n");
 			rc = -1;
diff --git a/board/ti/ks2_evm/board.c b/board/ti/ks2_evm/board.c
index c61baee..ae86dfb 100644
--- a/board/ti/ks2_evm/board.c
+++ b/board/ti/ks2_evm/board.c
@@ -74,7 +74,7 @@
 	char *env;
 	int res = -1;
 
-	env = getenv(env_name);
+	env = env_get(env_name);
 	if (env)
 		res = simple_strtol(env, NULL, 0);
 
@@ -151,9 +151,9 @@
 	u32 ddr3a_size;
 	int unitrd_fixup = 0;
 
-	env = getenv("mem_lpae");
+	env = env_get("mem_lpae");
 	lpae = env && simple_strtol(env, NULL, 0);
-	env = getenv("uinitrd_fixup");
+	env = env_get("uinitrd_fixup");
 	unitrd_fixup = env && simple_strtol(env, NULL, 0);
 
 	ddr3a_size = 0;
@@ -180,13 +180,13 @@
 	}
 
 	/* reserve memory at start of bank */
-	env = getenv("mem_reserve_head");
+	env = env_get("mem_reserve_head");
 	if (env) {
 		start[0] += ustrtoul(env, &endp, 0);
 		size[0] -= ustrtoul(env, &endp, 0);
 	}
 
-	env = getenv("mem_reserve");
+	env = env_get("mem_reserve");
 	if (env)
 		size[0] -= ustrtoul(env, &endp, 0);
 
@@ -251,7 +251,7 @@
 	char *env;
 	u64 *reserve_start;
 
-	env = getenv("mem_lpae");
+	env = env_get("mem_lpae");
 	lpae = env && simple_strtol(env, NULL, 0);
 
 	if (lpae) {
diff --git a/board/ti/ks2_evm/board_k2g.c b/board/ti/ks2_evm/board_k2g.c
index 2160576..15f0f54 100644
--- a/board/ti/ks2_evm/board_k2g.c
+++ b/board/ti/ks2_evm/board_k2g.c
@@ -310,9 +310,9 @@
 
 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
 	if (board_is_k2g_gp())
-		setenv("board_name", "66AK2GGP\0");
+		env_set("board_name", "66AK2GGP\0");
 	else if (board_is_k2g_ice())
-		setenv("board_name", "66AK2GIC\0");
+		env_set("board_name", "66AK2GIC\0");
 #endif
 	return 0;
 }
diff --git a/board/ti/panda/panda.c b/board/ti/panda/panda.c
index 6ffb53c..c59e58a 100644
--- a/board/ti/panda/panda.c
+++ b/board/ti/panda/panda.c
@@ -103,7 +103,7 @@
 		board_id4 = gpio_get_value(PANDA_ES_BOARD_ID_4_GPIO);
 
 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
-		setenv("board_name", "panda-es");
+		env_set("board_name", "panda-es");
 #endif
 		board_id = ((board_id4 << 4) | (board_id3 << 3) |
 			(board_id2 << 2) | (board_id1 << 1) | (board_id0));
@@ -117,7 +117,7 @@
 
 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
 		if ((board_id >= 0x3) && (processor_rev == OMAP4430_ES2_3))
-			setenv("board_name", "panda-a4");
+			env_set("board_name", "panda-a4");
 #endif
 	}
 
diff --git a/board/ti/ti814x/evm.c b/board/ti/ti814x/evm.c
index 055a29d..cdde6a8 100644
--- a/board/ti/ti814x/evm.c
+++ b/board/ti/ti814x/evm.c
@@ -166,7 +166,7 @@
 	uint8_t mac_addr[6];
 	uint32_t mac_hi, mac_lo;
 
-	if (!eth_getenv_enetaddr("ethaddr", mac_addr)) {
+	if (!eth_env_get_enetaddr("ethaddr", mac_addr)) {
 		printf("<ethaddr> not set. Reading from E-fuse\n");
 		/* try reading mac address from efuse */
 		mac_lo = readl(&cdev->macid0l);
@@ -179,7 +179,7 @@
 		mac_addr[5] = (mac_lo & 0xFF00) >> 8;
 
 		if (is_valid_ethaddr(mac_addr))
-			eth_setenv_enetaddr("ethaddr", mac_addr);
+			eth_env_set_enetaddr("ethaddr", mac_addr);
 		else
 			printf("Unable to read MAC address. Set <ethaddr>\n");
 	}
diff --git a/board/ti/ti816x/evm.c b/board/ti/ti816x/evm.c
index 9d6c3d6..cb40cc5 100644
--- a/board/ti/ti816x/evm.c
+++ b/board/ti/ti816x/evm.c
@@ -38,7 +38,7 @@
 	uint32_t mac_hi, mac_lo;
 	struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE;
 
-	if (!eth_getenv_enetaddr("ethaddr", mac_addr)) {
+	if (!eth_env_get_enetaddr("ethaddr", mac_addr)) {
 		printf("<ethaddr> not set. Reading from E-fuse\n");
 		/* try reading mac address from efuse */
 		mac_lo = readl(&cdev->macid0l);
@@ -51,7 +51,7 @@
 		mac_addr[5] = (mac_lo & 0xFF00) >> 8;
 
 		if (is_valid_ethaddr(mac_addr))
-			eth_setenv_enetaddr("ethaddr", mac_addr);
+			eth_env_set_enetaddr("ethaddr", mac_addr);
 		else
 			printf("Unable to read MAC address. Set <ethaddr>\n");
 	}
diff --git a/board/timll/devkit8000/devkit8000.c b/board/timll/devkit8000/devkit8000.c
index d31eeb8..741b3ac 100644
--- a/board/timll/devkit8000/devkit8000.c
+++ b/board/timll/devkit8000/devkit8000.c
@@ -102,7 +102,7 @@
 			CONFIG_DM9000_BASE, GPMC_SIZE_16M);
 
 	/* Use OMAP DIE_ID as MAC address */
-	if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
+	if (!eth_env_get_enetaddr("ethaddr", enetaddr)) {
 		printf("ethaddr not set, using Die ID\n");
 		die_id_0 = readl(&id_base->die_id_0);
 		enetaddr[0] = 0x02; /* locally administered */
@@ -111,7 +111,7 @@
 		enetaddr[3] = (die_id_0 & 0x00ff0000) >> 16;
 		enetaddr[4] = (die_id_0 & 0x0000ff00) >> 8;
 		enetaddr[5] = (die_id_0 & 0x000000ff);
-		eth_setenv_enetaddr("ethaddr", enetaddr);
+		eth_env_set_enetaddr("ethaddr", enetaddr);
 	}
 #endif
 
diff --git a/board/toradex/apalis_imx6/apalis_imx6.c b/board/toradex/apalis_imx6/apalis_imx6.c
index 8e5613c..7a3e493 100644
--- a/board/toradex/apalis_imx6/apalis_imx6.c
+++ b/board/toradex/apalis_imx6/apalis_imx6.c
@@ -9,6 +9,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <environment.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/crm_regs.h>
 #include <asm/arch/mxc_hdmi.h>
@@ -803,7 +804,7 @@
 
 	rev = get_board_rev();
 	snprintf(env_str, ARRAY_SIZE(env_str), "%.4x", rev);
-	setenv("board_rev", env_str);
+	env_set("board_rev", env_str);
 
 #ifndef CONFIG_TDX_APALIS_IMX6_V1_0
 	if ((rev & 0xfff0) == 0x0100) {
@@ -813,12 +814,12 @@
 		setup_iomux_dce_uart();
 
 		/* if using the default device tree, use version for V1.0 HW */
-		fdt_env = getenv("fdt_file");
+		fdt_env = env_get("fdt_file");
 		if ((fdt_env != NULL) && (strcmp(FDT_FILE, fdt_env) == 0)) {
-			setenv("fdt_file", FDT_FILE_V1_0);
+			env_set("fdt_file", FDT_FILE_V1_0);
 			printf("patching fdt_file to " FDT_FILE_V1_0 "\n");
 #ifndef CONFIG_ENV_IS_NOWHERE
-			saveenv();
+			env_save();
 #endif
 		}
 	}
diff --git a/board/toradex/colibri_imx6/colibri_imx6.c b/board/toradex/colibri_imx6/colibri_imx6.c
index cbf7aa9..dbcd233 100644
--- a/board/toradex/colibri_imx6/colibri_imx6.c
+++ b/board/toradex/colibri_imx6/colibri_imx6.c
@@ -676,7 +676,7 @@
 
 	rev = get_board_rev();
 	snprintf(env_str, ARRAY_SIZE(env_str), "%.4x", rev);
-	setenv("board_rev", env_str);
+	env_set("board_rev", env_str);
 #endif
 
 	return 0;
diff --git a/board/toradex/colibri_vf/colibri_vf.c b/board/toradex/colibri_vf/colibri_vf.c
index 46dd15b..3858af9 100644
--- a/board/toradex/colibri_vf/colibri_vf.c
+++ b/board/toradex/colibri_vf/colibri_vf.c
@@ -535,7 +535,7 @@
 	if (((src->sbmr2 & SRC_SBMR2_BMOD_MASK) >> SRC_SBMR2_BMOD_SHIFT)
 			== SRC_SBMR2_BMOD_SERIAL) {
 		printf("Serial Downloader recovery mode, disable autoboot\n");
-		setenv("bootdelay", "-1");
+		env_set("bootdelay", "-1");
 	}
 
 	return 0;
diff --git a/board/toradex/common/tdx-cfg-block.c b/board/toradex/common/tdx-cfg-block.c
index 1bf8ca8..328c4c0 100644
--- a/board/toradex/common/tdx-cfg-block.c
+++ b/board/toradex/common/tdx-cfg-block.c
@@ -278,7 +278,7 @@
 	len = cli_readline(message);
 	it = console_buffer[0];
 
-	soc = getenv("soc");
+	soc = env_get("soc");
 	if (!strcmp("mx6", soc)) {
 #ifdef CONFIG_MACH_TYPE
 		if (it == 'y' || it == 'Y')
diff --git a/board/toradex/common/tdx-common.c b/board/toradex/common/tdx-common.c
index 0d26787..b4e4727 100644
--- a/board/toradex/common/tdx-common.c
+++ b/board/toradex/common/tdx-common.c
@@ -80,24 +80,24 @@
 		tdx_hw_tag.ver_minor,
 		(char)tdx_hw_tag.ver_assembly + 'A');
 
-	setenv("serial#", tdx_serial_str);
+	env_set("serial#", tdx_serial_str);
 
 	/*
 	 * Check if environment contains a valid MAC address,
 	 * set the one from config block if not
 	 */
-	if (!eth_getenv_enetaddr("ethaddr", ethaddr))
-		eth_setenv_enetaddr("ethaddr", (u8 *)&tdx_eth_addr);
+	if (!eth_env_get_enetaddr("ethaddr", ethaddr))
+		eth_env_set_enetaddr("ethaddr", (u8 *)&tdx_eth_addr);
 
 #ifdef CONFIG_TDX_CFG_BLOCK_2ND_ETHADDR
-	if (!eth_getenv_enetaddr("eth1addr", ethaddr)) {
+	if (!eth_env_get_enetaddr("eth1addr", ethaddr)) {
 		/*
 		 * Secondary MAC address is allocated from block
 		 * 0x100000 higher then the first MAC address
 		 */
 		memcpy(ethaddr, &tdx_eth_addr, 6);
 		ethaddr[3] += 0x10;
-		eth_setenv_enetaddr("eth1addr", ethaddr);
+		eth_env_set_enetaddr("eth1addr", ethaddr);
 	}
 #endif
 
diff --git a/board/tqc/tqma6/tqma6.c b/board/tqc/tqma6/tqma6.c
index fcdea34..14991fd 100644
--- a/board/tqc/tqma6/tqma6.c
+++ b/board/tqc/tqma6/tqma6.c
@@ -251,7 +251,7 @@
 
 int board_late_init(void)
 {
-	setenv("board_name", tqma6_get_boardname());
+	env_set("board_name", tqma6_get_boardname());
 
 	tqma6_bb_board_late_init();
 
diff --git a/board/udoo/neo/neo.c b/board/udoo/neo/neo.c
index 276c625..7fa1289 100644
--- a/board/udoo/neo/neo.c
+++ b/board/udoo/neo/neo.c
@@ -437,7 +437,7 @@
 int board_late_init(void)
 {
 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
-	setenv("board_name", board_string());
+	env_set("board_name", board_string());
 #endif
 
 	return 0;
diff --git a/board/udoo/udoo.c b/board/udoo/udoo.c
index 7534935..a359626 100644
--- a/board/udoo/udoo.c
+++ b/board/udoo/udoo.c
@@ -255,9 +255,9 @@
 {
 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
 	if (is_cpu_type(MXC_CPU_MX6Q))
-		setenv("board_rev", "MX6Q");
+		env_set("board_rev", "MX6Q");
 	else
-		setenv("board_rev", "MX6DL");
+		env_set("board_rev", "MX6DL");
 #endif
 	return 0;
 }
diff --git a/board/varisys/common/sys_eeprom.c b/board/varisys/common/sys_eeprom.c
index b55ab81..69f596a 100644
--- a/board/varisys/common/sys_eeprom.c
+++ b/board/varisys/common/sys_eeprom.c
@@ -401,7 +401,7 @@
 			mac[5]);
 
 		printf("MAC: %s\n", ethaddr);
-		setenv(envvar, ethaddr);
+		env_set(envvar, ethaddr);
 	}
 
 	return ret;
@@ -486,8 +486,8 @@
 			/* Only initialize environment variables that are blank
 			 * (i.e. have not yet been set)
 			 */
-			if (!getenv(enetvar))
-				setenv(enetvar, ethaddr);
+			if (!env_get(enetvar))
+				env_set(enetvar, ethaddr);
 		}
 	}
 
diff --git a/board/varisys/cyrus/cyrus.c b/board/varisys/cyrus/cyrus.c
index 74f4473..30f518a 100644
--- a/board/varisys/cyrus/cyrus.c
+++ b/board/varisys/cyrus/cyrus.c
@@ -87,8 +87,8 @@
 
 	ft_cpu_setup(blob, bd);
 
-	base = getenv_bootm_low();
-	size = getenv_bootm_size();
+	base = env_get_bootm_low();
+	size = env_get_bootm_size();
 
 	fdt_fixup_memory(blob, (u64)base, (u64)size);
 
diff --git a/board/vscom/baltos/board.c b/board/vscom/baltos/board.c
index d3b1f15..cb39190 100644
--- a/board/vscom/baltos/board.c
+++ b/board/vscom/baltos/board.c
@@ -68,7 +68,7 @@
 	printf("DIPs: 0x%1x\n", (~dips) & 0xf);
 
 	if ((dips & 0xf) == 0xe)
-		setenv("console", "ttyUSB0,115200n8");
+		env_set("console", "ttyUSB0,115200n8");
 
 	return 0;
 }
@@ -373,7 +373,7 @@
 		return -ENODEV;
 	}
 
-	setenv("board_name", model);
+	env_set("board_name", model);
 #endif
 
 	return 0;
@@ -453,11 +453,11 @@
 
 #if (defined(CONFIG_DRIVER_TI_CPSW) && !defined(CONFIG_SPL_BUILD)) || \
 	(defined(CONFIG_SPL_ETH_SUPPORT) && defined(CONFIG_SPL_BUILD))
-	if (!getenv("ethaddr")) {
+	if (!env_get("ethaddr")) {
 		printf("<ethaddr> not set. Validating first E-fuse MAC\n");
 
 		if (is_valid_ethaddr(mac_addr))
-			eth_setenv_enetaddr("ethaddr", mac_addr);
+			eth_env_set_enetaddr("ethaddr", mac_addr);
 	}
 
 #ifdef CONFIG_DRIVER_TI_CPSW
diff --git a/board/wandboard/wandboard.c b/board/wandboard/wandboard.c
index 1dbc966..adfcf48 100644
--- a/board/wandboard/wandboard.c
+++ b/board/wandboard/wandboard.c
@@ -425,14 +425,14 @@
 
 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
 	if (is_mx6dq())
-		setenv("board_rev", "MX6Q");
+		env_set("board_rev", "MX6Q");
 	else
-		setenv("board_rev", "MX6DL");
+		env_set("board_rev", "MX6DL");
 
 	if (is_revc1())
-		setenv("board_name", "C1");
+		env_set("board_name", "C1");
 	else
-		setenv("board_name", "B1");
+		env_set("board_name", "B1");
 #endif
 	return 0;
 }
diff --git a/board/work-microwave/work_92105/work_92105_display.c b/board/work-microwave/work_92105/work_92105_display.c
index 37a7363..c997cea 100644
--- a/board/work-microwave/work_92105/work_92105_display.c
+++ b/board/work-microwave/work_92105/work_92105_display.c
@@ -228,7 +228,7 @@
 	i2c_write(0x2c, 0x01, 1, &enable_backlight, 1);
 
 	/* set display contrast */
-	display_contrast_str = getenv("fwopt_dispcontrast");
+	display_contrast_str = env_get("fwopt_dispcontrast");
 	if (display_contrast_str)
 		display_contrast = simple_strtoul(display_contrast_str,
 			NULL, 10);
diff --git a/board/xes/common/board.c b/board/xes/common/board.c
index 4ed6f50..b76eb94 100644
--- a/board/xes/common/board.c
+++ b/board/xes/common/board.c
@@ -51,13 +51,13 @@
 
 	/* Display board specific information */
 	puts("       ");
-	i = getenv_f("board_rev", buf, sizeof(buf));
+	i = env_get_f("board_rev", buf, sizeof(buf));
 	if (i > 0)
 		printf("Rev %s, ", buf);
-	i = getenv_f("serial#", buf, sizeof(buf));
+	i = env_get_f("serial#", buf, sizeof(buf));
 	if (i > 0)
 		printf("Serial# %s, ", buf);
-	i = getenv_f("board_cfg", buf, sizeof(buf));
+	i = env_get_f("board_cfg", buf, sizeof(buf));
 	if (i > 0)
 		printf("Cfg %s", buf);
 	puts("\n");
diff --git a/board/xilinx/zynq/board.c b/board/xilinx/zynq/board.c
index b2fbecf..90ef542 100644
--- a/board/xilinx/zynq/board.c
+++ b/board/xilinx/zynq/board.c
@@ -86,22 +86,22 @@
 {
 	switch ((zynq_slcr_get_boot_mode()) & ZYNQ_BM_MASK) {
 	case ZYNQ_BM_QSPI:
-		setenv("modeboot", "qspiboot");
+		env_set("modeboot", "qspiboot");
 		break;
 	case ZYNQ_BM_NAND:
-		setenv("modeboot", "nandboot");
+		env_set("modeboot", "nandboot");
 		break;
 	case ZYNQ_BM_NOR:
-		setenv("modeboot", "norboot");
+		env_set("modeboot", "norboot");
 		break;
 	case ZYNQ_BM_SD:
-		setenv("modeboot", "sdboot");
+		env_set("modeboot", "sdboot");
 		break;
 	case ZYNQ_BM_JTAG:
-		setenv("modeboot", "jtagboot");
+		env_set("modeboot", "jtagboot");
 		break;
 	default:
-		setenv("modeboot", "");
+		env_set("modeboot", "");
 		break;
 	}
 
diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c
index aebd3df..d17868b 100644
--- a/board/xilinx/zynqmp/zynqmp.c
+++ b/board/xilinx/zynqmp/zynqmp.c
@@ -318,10 +318,10 @@
 	 * and default boot_targets
 	 */
 	new_targets = calloc(1, strlen(mode) +
-				strlen(getenv("boot_targets")) + 2);
+				strlen(env_get("boot_targets")) + 2);
 
-	sprintf(new_targets, "%s %s", mode, getenv("boot_targets"));
-	setenv("boot_targets", new_targets);
+	sprintf(new_targets, "%s %s", mode, env_get("boot_targets"));
+	env_set("boot_targets", new_targets);
 
 	return 0;
 }
diff --git a/cmd/bdinfo.c b/cmd/bdinfo.c
index 96d7b72..27ffcd5 100644
--- a/cmd/bdinfo.c
+++ b/cmd/bdinfo.c
@@ -28,7 +28,7 @@
 		sprintf(name, "eth%iaddr", idx);
 	else
 		strcpy(name, "ethaddr");
-	val = getenv(name);
+	val = env_get(name);
 	if (!val)
 		val = "(not set)";
 	printf("%-12s= %s\n", name, val);
@@ -51,7 +51,7 @@
 	} while (dev);
 
 	printf("current eth = %s\n", eth_get_name());
-	printf("ip_addr     = %s\n", getenv("ipaddr"));
+	printf("ip_addr     = %s\n", env_get("ipaddr"));
 }
 #endif
 
@@ -141,7 +141,7 @@
 #if defined(CONFIG_HAS_ETH5)
 	print_eth(5);
 #endif
-	printf("IP addr     = %s\n", getenv("ipaddr"));
+	printf("IP addr     = %s\n", env_get("ipaddr"));
 #endif
 }
 
diff --git a/cmd/bootm.c b/cmd/bootm.c
index daf15d9..df0bbe1 100644
--- a/cmd/bootm.c
+++ b/cmd/bootm.c
@@ -138,7 +138,7 @@
 
 int bootm_maybe_autostart(cmd_tbl_t *cmdtp, const char *cmd)
 {
-	const char *ep = getenv("autostart");
+	const char *ep = env_get("autostart");
 
 	if (ep && !strcmp(ep, "yes")) {
 		char *local_args[2];
@@ -202,7 +202,7 @@
 #if defined(CONFIG_CMD_BOOTD)
 int do_bootd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
-	return run_command(getenv("bootcmd"), flag);
+	return run_command(env_get("bootcmd"), flag);
 }
 
 U_BOOT_CMD(
diff --git a/cmd/bootmenu.c b/cmd/bootmenu.c
index 5879065..870db7c 100644
--- a/cmd/bootmenu.c
+++ b/cmd/bootmenu.c
@@ -53,7 +53,7 @@
 		return NULL;
 
 	sprintf(name, "bootmenu_%d", n);
-	return getenv(name);
+	return env_get(name);
 }
 
 static void bootmenu_print_entry(void *data)
@@ -483,7 +483,7 @@
 		delay_str = argv[1];
 
 	if (!delay_str)
-		delay_str = getenv("bootmenu_delay");
+		delay_str = env_get("bootmenu_delay");
 
 	if (delay_str)
 		delay = (int)simple_strtol(delay_str, NULL, 10);
diff --git a/cmd/cbfs.c b/cmd/cbfs.c
index 95a11a3..799ba01 100644
--- a/cmd/cbfs.c
+++ b/cmd/cbfs.c
@@ -80,7 +80,7 @@
 
 	printf("\n%ld bytes read\n", size);
 
-	setenv_hex("filesize", size);
+	env_set_hex("filesize", size);
 
 	return 0;
 }
diff --git a/cmd/cramfs.c b/cmd/cramfs.c
index 49ee36c..86f1bac 100644
--- a/cmd/cramfs.c
+++ b/cmd/cramfs.c
@@ -104,7 +104,7 @@
 	struct mtdids id;
 
 	ulong addr;
-	addr = simple_strtoul(getenv("cramfsaddr"), NULL, 16);
+	addr = simple_strtoul(env_get("cramfsaddr"), NULL, 16);
 
 	/* hack! */
 	/* cramfs_* only supports NOR flash chips */
@@ -117,9 +117,9 @@
 	part.offset = (u64)(uintptr_t) map_sysmem(addr - OFFSET_ADJUSTMENT, 0);
 
 	/* pre-set Boot file name */
-	if ((filename = getenv("bootfile")) == NULL) {
+	filename = env_get("bootfile");
+	if (!filename)
 		filename = "uImage";
-	}
 
 	if (argc == 2) {
 		filename = argv[1];
@@ -138,7 +138,7 @@
 	if (size > 0) {
 		printf("### CRAMFS load complete: %d bytes loaded to 0x%lx\n",
 			size, offset);
-		setenv_hex("filesize", size);
+		env_set_hex("filesize", size);
 	} else {
 		printf("### CRAMFS LOAD ERROR<%x> for %s!\n", size, filename);
 	}
@@ -169,7 +169,7 @@
 	struct mtdids id;
 
 	ulong addr;
-	addr = simple_strtoul(getenv("cramfsaddr"), NULL, 16);
+	addr = simple_strtoul(env_get("cramfsaddr"), NULL, 16);
 
 	/* hack! */
 	/* cramfs_* only supports NOR flash chips */
diff --git a/cmd/elf.c b/cmd/elf.c
index ed9625b..5745a38 100644
--- a/cmd/elf.c
+++ b/cmd/elf.c
@@ -148,7 +148,7 @@
 	unsigned long addr; /* Address of the ELF image */
 	unsigned long rc; /* Return value from user code */
 	char *sload = NULL;
-	const char *ep = getenv("autostart");
+	const char *ep = env_get("autostart");
 	int rcode = 0;
 
 	/* Consume 'bootelf' */
@@ -242,11 +242,11 @@
 	 */
 #if defined(CONFIG_WALNUT)
 	tmp = (char *)CONFIG_SYS_NVRAM_BASE_ADDR + 0x500;
-	eth_getenv_enetaddr("ethaddr", (uchar *)build_buf);
+	eth_env_get_enetaddr("ethaddr", (uchar *)build_buf);
 	memcpy(tmp, &build_buf[3], 3);
 #elif defined(CONFIG_SYS_VXWORKS_MAC_PTR)
 	tmp = (char *)CONFIG_SYS_VXWORKS_MAC_PTR;
-	eth_getenv_enetaddr("ethaddr", (uchar *)build_buf);
+	eth_env_get_enetaddr("ethaddr", (uchar *)build_buf);
 	memcpy(tmp, build_buf, 6);
 #else
 	puts("## Ethernet MAC address not copied to NV RAM\n");
@@ -258,7 +258,7 @@
 	 * (LOCAL_MEM_LOCAL_ADRS + BOOT_LINE_OFFSET) as defined by
 	 * VxWorks BSP. For example, on PowerPC it defaults to 0x4200.
 	 */
-	tmp = getenv("bootaddr");
+	tmp = env_get("bootaddr");
 	if (!tmp) {
 		printf("## VxWorks bootline address not specified\n");
 	} else {
@@ -269,21 +269,21 @@
 		 * parameter. If it is not defined, we may be able to
 		 * construct the info.
 		 */
-		bootline = getenv("bootargs");
+		bootline = env_get("bootargs");
 		if (bootline) {
 			memcpy((void *)bootaddr, bootline,
 			       max(strlen(bootline), (size_t)255));
 			flush_cache(bootaddr, max(strlen(bootline),
 						  (size_t)255));
 		} else {
-			tmp = getenv("bootdev");
+			tmp = env_get("bootdev");
 			if (tmp) {
 				strcpy(build_buf, tmp);
 				ptr = strlen(tmp);
 			} else
 				printf("## VxWorks boot device not specified\n");
 
-			tmp = getenv("bootfile");
+			tmp = env_get("bootfile");
 			if (tmp)
 				ptr += sprintf(build_buf + ptr,
 					       "host:%s ", tmp);
@@ -295,12 +295,12 @@
 			 * The following parameters are only needed if 'bootdev'
 			 * is an ethernet device, otherwise they are optional.
 			 */
-			tmp = getenv("ipaddr");
+			tmp = env_get("ipaddr");
 			if (tmp) {
 				ptr += sprintf(build_buf + ptr, "e=%s", tmp);
-				tmp = getenv("netmask");
+				tmp = env_get("netmask");
 				if (tmp) {
-					u32 mask = getenv_ip("netmask").s_addr;
+					u32 mask = env_get_ip("netmask").s_addr;
 					ptr += sprintf(build_buf + ptr,
 						       ":%08x ", ntohl(mask));
 				} else {
@@ -308,19 +308,19 @@
 				}
 			}
 
-			tmp = getenv("serverip");
+			tmp = env_get("serverip");
 			if (tmp)
 				ptr += sprintf(build_buf + ptr, "h=%s ", tmp);
 
-			tmp = getenv("gatewayip");
+			tmp = env_get("gatewayip");
 			if (tmp)
 				ptr += sprintf(build_buf + ptr, "g=%s ", tmp);
 
-			tmp = getenv("hostname");
+			tmp = env_get("hostname");
 			if (tmp)
 				ptr += sprintf(build_buf + ptr, "tn=%s ", tmp);
 
-			tmp = getenv("othbootargs");
+			tmp = env_get("othbootargs");
 			if (tmp) {
 				strcpy(build_buf + ptr, tmp);
 				ptr += strlen(tmp);
@@ -341,12 +341,12 @@
 	 * Since E820 information is critical to the kernel, if we don't
 	 * specify these in the environments, use a default one.
 	 */
-	tmp = getenv("e820data");
+	tmp = env_get("e820data");
 	if (tmp)
 		data = (struct e820entry *)simple_strtoul(tmp, NULL, 16);
 	else
 		data = (struct e820entry *)VXWORKS_E820_DATA_ADDR;
-	tmp = getenv("e820info");
+	tmp = env_get("e820info");
 	if (tmp)
 		info = (struct e820info *)simple_strtoul(tmp, NULL, 16);
 	else
diff --git a/cmd/fdt.c b/cmd/fdt.c
index 05e19f8..118613f 100644
--- a/cmd/fdt.c
+++ b/cmd/fdt.c
@@ -43,21 +43,21 @@
 
 	buf = map_sysmem(addr, 0);
 	working_fdt = buf;
-	setenv_hex("fdtaddr", addr);
+	env_set_hex("fdtaddr", addr);
 }
 
 /*
  * Get a value from the fdt and format it to be set in the environment
  */
-static int fdt_value_setenv(const void *nodep, int len, const char *var)
+static int fdt_value_env_set(const void *nodep, int len, const char *var)
 {
 	if (is_printable_string(nodep, len))
-		setenv(var, (void *)nodep);
+		env_set(var, (void *)nodep);
 	else if (len == 4) {
 		char buf[11];
 
 		sprintf(buf, "0x%08X", fdt32_to_cpu(*(fdt32_t *)nodep));
-		setenv(var, buf);
+		env_set(var, buf);
 	} else if (len%4 == 0 && len <= 20) {
 		/* Needed to print things like sha1 hashes. */
 		char buf[41];
@@ -66,7 +66,7 @@
 		for (i = 0; i < len; i += sizeof(unsigned int))
 			sprintf(buf + (i * 2), "%08x",
 				*(unsigned int *)(nodep + i));
-		setenv(var, buf);
+		env_set(var, buf);
 	} else {
 		printf("error: unprintable value\n");
 		return 1;
@@ -111,7 +111,7 @@
 				return 1;
 			printf("The address of the fdt is %#08lx\n",
 			       control ? (ulong)map_to_sysmem(blob) :
-					getenv_hex("fdtaddr", 0));
+					env_get_hex("fdtaddr", 0));
 			return 0;
 		}
 
@@ -358,10 +358,12 @@
 				if (curDepth == startDepth + 1)
 					curIndex++;
 				if (subcmd[0] == 'n' && curIndex == reqIndex) {
-					const char *nodeName = fdt_get_name(
-					    working_fdt, nextNodeOffset, NULL);
+					const char *node_name;
 
-					setenv(var, (char *)nodeName);
+					node_name = fdt_get_name(working_fdt,
+								 nextNodeOffset,
+								 NULL);
+					env_set(var, node_name);
 					return 0;
 				}
 				nextNodeOffset = fdt_next_node(
@@ -371,7 +373,7 @@
 			}
 			if (subcmd[0] == 's') {
 				/* get the num nodes at this level */
-				setenv_ulong(var, curIndex + 1);
+				env_set_ulong(var, curIndex + 1);
 			} else {
 				/* node index not found */
 				printf("libfdt node not found\n");
@@ -382,13 +384,14 @@
 				working_fdt, nodeoffset, prop, &len);
 			if (len == 0) {
 				/* no property value */
-				setenv(var, "");
+				env_set(var, "");
 				return 0;
 			} else if (nodep && len > 0) {
 				if (subcmd[0] == 'v') {
 					int ret;
 
-					ret = fdt_value_setenv(nodep, len, var);
+					ret = fdt_value_env_set(nodep, len,
+								var);
 					if (ret != 0)
 						return ret;
 				} else if (subcmd[0] == 'a') {
@@ -396,13 +399,13 @@
 					char buf[11];
 
 					sprintf(buf, "0x%p", nodep);
-					setenv(var, buf);
+					env_set(var, buf);
 				} else if (subcmd[0] == 's') {
 					/* Get size */
 					char buf[11];
 
 					sprintf(buf, "0x%08X", len);
-					setenv(var, buf);
+					env_set(var, buf);
 				} else
 					return CMD_RET_USAGE;
 				return 0;
diff --git a/cmd/fpga.c b/cmd/fpga.c
index 016349f..ac6f504 100644
--- a/cmd/fpga.c
+++ b/cmd/fpga.c
@@ -43,8 +43,8 @@
 	int op, dev = FPGA_INVALID_DEVICE;
 	size_t data_size = 0;
 	void *fpga_data = NULL;
-	char *devstr = getenv("fpga");
-	char *datastr = getenv("fpgadata");
+	char *devstr = env_get("fpga");
+	char *datastr = env_get("fpgadata");
 	int rc = FPGA_FAIL;
 	int wrong_parms = 0;
 #if defined(CONFIG_FIT)
diff --git a/cmd/gpt.c b/cmd/gpt.c
index 6f08f61..638aa19 100644
--- a/cmd/gpt.c
+++ b/cmd/gpt.c
@@ -55,14 +55,14 @@
 	memset(s + strlen(s) - 1, '\0', 1);
 	memmove(s, s + 2, strlen(s) - 1);
 
-	e = getenv(s);
+	e = env_get(s);
 	if (e == NULL) {
 #ifdef CONFIG_RANDOM_UUID
 		debug("%s unset. ", str);
 		gen_rand_uuid_str(uuid_str, UUID_STR_FORMAT_GUID);
-		setenv(s, uuid_str);
+		env_set(s, uuid_str);
 
-		e = getenv(s);
+		e = env_get(s);
 		if (e) {
 			debug("Set to random.\n");
 			ret = 0;
@@ -626,7 +626,7 @@
 		return CMD_RET_FAILURE;
 
 	if (namestr)
-		setenv(namestr, disk_guid);
+		env_set(namestr, disk_guid);
 	else
 		printf("%s\n", disk_guid);
 
diff --git a/cmd/ini.c b/cmd/ini.c
index 727fd1c..8656299 100644
--- a/cmd/ini.c
+++ b/cmd/ini.c
@@ -219,7 +219,7 @@
 		for (i = 0; i < strlen(value); i++)
 			value[i] = tolower(value[i]);
 #endif
-		setenv(name, value);
+		env_set(name, value);
 		printf("ini: Imported %s as %s\n", name, value);
 	}
 
@@ -238,9 +238,9 @@
 
 	section = argv[1];
 	file_address = (char *)simple_strtoul(
-		argc < 3 ? getenv("loadaddr") : argv[2], NULL, 16);
+		argc < 3 ? env_get("loadaddr") : argv[2], NULL, 16);
 	file_size = (size_t)simple_strtoul(
-		argc < 4 ? getenv("filesize") : argv[3], NULL, 16);
+		argc < 4 ? env_get("filesize") : argv[3], NULL, 16);
 
 	return ini_parse(file_address, file_size, ini_handler, (void *)section);
 }
diff --git a/cmd/itest.c b/cmd/itest.c
index e1896d9..70db04a 100644
--- a/cmd/itest.c
+++ b/cmd/itest.c
@@ -101,7 +101,7 @@
 			i++;
 		}
 		s[i] = 0;
-		return  getenv((const char *)&s[2]);
+		return  env_get((const char *)&s[2]);
 	} else {
 		return s;
 	}
diff --git a/cmd/jffs2.c b/cmd/jffs2.c
index dc94705..aee2f45 100644
--- a/cmd/jffs2.c
+++ b/cmd/jffs2.c
@@ -479,9 +479,9 @@
 	ulong offset = load_addr;
 
 	/* pre-set Boot file name */
-	if ((filename = getenv("bootfile")) == NULL) {
+	filename = env_get("bootfile");
+	if (!filename)
 		filename = "uImage";
-	}
 
 	if (argc == 2) {
 		filename = argv[1];
@@ -512,7 +512,7 @@
 		if (size > 0) {
 			printf("### %s load complete: %d bytes loaded to 0x%lx\n",
 				fsname, size, offset);
-			setenv_hex("filesize", size);
+			env_set_hex("filesize", size);
 		} else {
 			printf("### %s LOAD ERROR<%x> for %s!\n", fsname, size, filename);
 		}
diff --git a/cmd/load.c b/cmd/load.c
index 4597ec5..519c309 100644
--- a/cmd/load.c
+++ b/cmd/load.c
@@ -50,11 +50,11 @@
 	load_baudrate = current_baudrate = gd->baudrate;
 #endif
 
-	if (((env_echo = getenv("loads_echo")) != NULL) && (*env_echo == '1')) {
+	env_echo = env_get("loads_echo");
+	if (env_echo && *env_echo == '1')
 		do_echo = 1;
-	} else {
+	else
 		do_echo = 0;
-	}
 
 #ifdef	CONFIG_SYS_LOADS_BAUD_CHANGE
 	if (argc >= 2) {
@@ -182,7 +182,7 @@
 			    start_addr, end_addr, size, size
 		    );
 		    flush_cache(start_addr, size);
-		    setenv_hex("filesize", size);
+		    env_set_hex("filesize", size);
 		    return (addr);
 		case SREC_START:
 		    break;
@@ -427,9 +427,9 @@
 	offset = CONFIG_SYS_LOAD_ADDR;
 
 	/* pre-set offset from $loadaddr */
-	if ((s = getenv("loadaddr")) != NULL) {
+	s = env_get("loadaddr");
+	if (s)
 		offset = simple_strtoul(s, NULL, 16);
-	}
 
 	load_baudrate = current_baudrate = gd->baudrate;
 
@@ -529,7 +529,7 @@
 	flush_cache(offset, size);
 
 	printf("## Total Size      = 0x%08x = %d Bytes\n", size, size);
-	setenv_hex("filesize", size);
+	env_set_hex("filesize", size);
 
 	return offset;
 }
@@ -1000,7 +1000,7 @@
 	flush_cache(offset, ALIGN(size, ARCH_DMA_MINALIGN));
 
 	printf("## Total Size      = 0x%08x = %d Bytes\n", size, size);
-	setenv_hex("filesize", size);
+	env_set_hex("filesize", size);
 
 	return offset;
 }
diff --git a/cmd/log.c b/cmd/log.c
index 873ee40..7a3bd5c 100644
--- a/cmd/log.c
+++ b/cmd/log.c
@@ -71,7 +71,8 @@
 #endif
 
 	/* Set up log version */
-	if ((s = getenv ("logversion")) != NULL)
+	s = env_get("logversion");
+	if (s)
 		log_version = (int)simple_strtoul(s, NULL, 10);
 
 	if (log_version == 2)
@@ -94,7 +95,8 @@
 		log->v2.start = log->v2.con;
 
 	/* Initialize default loglevel if present */
-	if ((s = getenv ("loglevel")) != NULL)
+	s = env_get("loglevel");
+	if (s)
 		console_loglevel = (int)simple_strtoul(s, NULL, 10);
 
 	gd->flags |= GD_FLG_LOGINIT;
diff --git a/cmd/lzmadec.c b/cmd/lzmadec.c
index c78df82..1b482ed 100644
--- a/cmd/lzmadec.c
+++ b/cmd/lzmadec.c
@@ -42,7 +42,7 @@
 		return 1;
 	printf("Uncompressed size: %ld = %#lX\n", (ulong)src_len,
 	       (ulong)src_len);
-	setenv_hex("filesize", src_len);
+	env_set_hex("filesize", src_len);
 
 	return 0;
 }
diff --git a/cmd/md5sum.c b/cmd/md5sum.c
index 23bb81e..c737cb2 100644
--- a/cmd/md5sum.c
+++ b/cmd/md5sum.c
@@ -35,7 +35,7 @@
 			sprintf(str_ptr, "%02x", sum[i]);
 			str_ptr += 2;
 		}
-		setenv(dest, str_output);
+		env_set(dest, str_output);
 	}
 }
 
@@ -54,7 +54,7 @@
 		if (strlen(verify_str) == 32)
 			vsum_str = verify_str;
 		else {
-			vsum_str = getenv(verify_str);
+			vsum_str = env_get(verify_str);
 			if (vsum_str == NULL || strlen(vsum_str) != 32)
 				return 1;
 		}
diff --git a/cmd/mtdparts.c b/cmd/mtdparts.c
index 683c48b..615aa74 100644
--- a/cmd/mtdparts.c
+++ b/cmd/mtdparts.c
@@ -239,19 +239,19 @@
 			dev = list_entry(dentry, struct mtd_device, link);
 			if (dev == current_mtd_dev) {
 				mtddevnum += current_mtd_partnum;
-				setenv_ulong("mtddevnum", mtddevnum);
+				env_set_ulong("mtddevnum", mtddevnum);
 				break;
 			}
 			mtddevnum += dev->num_parts;
 		}
 
 		part = mtd_part_info(current_mtd_dev, current_mtd_partnum);
-		setenv("mtddevname", part->name);
+		env_set("mtddevname", part->name);
 
 		debug("=> mtddevnum %d,\n=> mtddevname %s\n", mtddevnum, part->name);
 	} else {
-		setenv("mtddevnum", NULL);
-		setenv("mtddevname", NULL);
+		env_set("mtddevnum", NULL);
+		env_set("mtddevname", NULL);
 
 		debug("=> mtddevnum NULL\n=> mtddevname NULL\n");
 	}
@@ -270,12 +270,12 @@
 		sprintf(buf, "%s%d,%d", MTD_DEV_TYPE(current_mtd_dev->id->type),
 					current_mtd_dev->id->num, current_mtd_partnum);
 
-		setenv("partition", buf);
+		env_set("partition", buf);
 		strncpy(last_partition, buf, 16);
 
 		debug("=> partition %s\n", buf);
 	} else {
-		setenv("partition", NULL);
+		env_set("partition", NULL);
 		last_partition[0] = '\0';
 
 		debug("=> partition NULL\n");
@@ -1213,9 +1213,9 @@
 	ret = generate_mtdparts(buf, buflen);
 
 	if ((buf[0] != '\0') && (ret == 0))
-		setenv("mtdparts", buf);
+		env_set("mtdparts", buf);
 	else
-		setenv("mtdparts", NULL);
+		env_set("mtdparts", NULL);
 
 	return ret;
 }
@@ -1533,11 +1533,11 @@
  * @param buf temporary buffer pointer MTDPARTS_MAXLEN long
  * @return mtdparts variable string, NULL if not found
  */
-static const char *getenv_mtdparts(char *buf)
+static const char *env_get_mtdparts(char *buf)
 {
 	if (gd->flags & GD_FLG_ENV_READY)
-		return getenv("mtdparts");
-	if (getenv_f("mtdparts", buf, MTDPARTS_MAXLEN) != -1)
+		return env_get("mtdparts");
+	if (env_get_f("mtdparts", buf, MTDPARTS_MAXLEN) != -1)
 		return buf;
 	return NULL;
 }
@@ -1565,7 +1565,7 @@
 	}
 
 	/* re-read 'mtdparts' variable, mtd_devices_init may be updating env */
-	p = getenv_mtdparts(tmp_parts);
+	p = env_get_mtdparts(tmp_parts);
 	if (!p)
 		p = mtdparts;
 
@@ -1741,9 +1741,9 @@
 	}
 
 	/* get variables */
-	ids = getenv("mtdids");
-	parts = getenv_mtdparts(tmp_parts);
-	current_partition = getenv("partition");
+	ids = env_get("mtdids");
+	parts = env_get_mtdparts(tmp_parts);
+	current_partition = env_get("partition");
 
 	/* save it for later parsing, cannot rely on current partition pointer
 	 * as 'partition' variable may be updated during init */
@@ -1764,7 +1764,7 @@
 		if (mtdids_default) {
 			debug("mtdids variable not defined, using default\n");
 			ids = mtdids_default;
-			setenv("mtdids", (char *)ids);
+			env_set("mtdids", (char *)ids);
 		} else {
 			printf("mtdids not defined, no default present\n");
 			return 1;
@@ -1780,7 +1780,7 @@
 	if (!parts) {
 		if (mtdparts_default && use_defaults) {
 			parts = mtdparts_default;
-			if (setenv("mtdparts", (char *)parts) == 0)
+			if (env_set("mtdparts", (char *)parts) == 0)
 				use_defaults = 0;
 		} else
 			printf("mtdparts variable not set, see 'help mtdparts'\n");
@@ -1850,7 +1850,7 @@
 			current_mtd_partnum = pnum;
 			current_save();
 		}
-	} else if (getenv("partition") == NULL) {
+	} else if (env_get("partition") == NULL) {
 		debug("no partition variable set, setting...\n");
 		current_save();
 	}
@@ -1956,9 +1956,9 @@
 {
 	if (argc == 2) {
 		if (strcmp(argv[1], "default") == 0) {
-			setenv("mtdids", NULL);
-			setenv("mtdparts", NULL);
-			setenv("partition", NULL);
+			env_set("mtdids", NULL);
+			env_set("mtdparts", NULL);
+			env_set("partition", NULL);
 			use_defaults = 1;
 
 			mtdparts_init();
@@ -1967,7 +1967,7 @@
 			/* this may be the first run, initialize lists if needed */
 			mtdparts_init();
 
-			setenv("mtdparts", NULL);
+			env_set("mtdparts", NULL);
 
 			/* mtd_devices_init() calls current_save() */
 			return mtd_devices_init();
diff --git a/cmd/mvebu/bubt.c b/cmd/mvebu/bubt.c
index ea46e7b..a1997ac 100644
--- a/cmd/mvebu/bubt.c
+++ b/cmd/mvebu/bubt.c
@@ -98,7 +98,7 @@
 	const char *addr_str;
 	unsigned long addr;
 
-	addr_str = getenv("loadaddr");
+	addr_str = env_get("loadaddr");
 	if (addr_str)
 		addr = simple_strtoul(addr_str, NULL, 16);
 	else
diff --git a/cmd/nand.c b/cmd/nand.c
index a2152ec..a22945d 100644
--- a/cmd/nand.c
+++ b/cmd/nand.c
@@ -305,9 +305,9 @@
 	printf("  bbt options 0x%08x\n", chip->bbt_options);
 
 	/* Set geometry info */
-	setenv_hex("nand_writesize", mtd->writesize);
-	setenv_hex("nand_oobsize", mtd->oobsize);
-	setenv_hex("nand_erasesize", mtd->erasesize);
+	env_set_hex("nand_writesize", mtd->writesize);
+	env_set_hex("nand_oobsize", mtd->oobsize);
+	env_set_hex("nand_erasesize", mtd->erasesize);
 }
 
 static int raw_access(struct mtd_info *mtd, ulong addr, loff_t off,
@@ -383,7 +383,7 @@
 #else
 	int quiet = 0;
 #endif
-	const char *quiet_str = getenv("quiet");
+	const char *quiet_str = env_get("quiet");
 	int dev = nand_curr_device;
 	int repeat = flag & CMD_FLAG_REPEAT;
 
@@ -966,11 +966,11 @@
 	switch (argc) {
 	case 1:
 		addr = CONFIG_SYS_LOAD_ADDR;
-		boot_device = getenv("bootdevice");
+		boot_device = env_get("bootdevice");
 		break;
 	case 2:
 		addr = simple_strtoul(argv[1], NULL, 16);
-		boot_device = getenv("bootdevice");
+		boot_device = env_get("bootdevice");
 		break;
 	case 3:
 		addr = simple_strtoul(argv[1], NULL, 16);
diff --git a/cmd/net.c b/cmd/net.c
index 5e91d3a..d7c776a 100644
--- a/cmd/net.c
+++ b/cmd/net.c
@@ -116,23 +116,23 @@
 
 	if (net_gateway.s_addr) {
 		ip_to_string(net_gateway, tmp);
-		setenv("gatewayip", tmp);
+		env_set("gatewayip", tmp);
 	}
 
 	if (net_netmask.s_addr) {
 		ip_to_string(net_netmask, tmp);
-		setenv("netmask", tmp);
+		env_set("netmask", tmp);
 	}
 
 	if (net_hostname[0])
-		setenv("hostname", net_hostname);
+		env_set("hostname", net_hostname);
 
 	if (net_root_path[0])
-		setenv("rootpath", net_root_path);
+		env_set("rootpath", net_root_path);
 
 	if (net_ip.s_addr) {
 		ip_to_string(net_ip, tmp);
-		setenv("ipaddr", tmp);
+		env_set("ipaddr", tmp);
 	}
 #if !defined(CONFIG_BOOTP_SERVERIP)
 	/*
@@ -141,32 +141,32 @@
 	 */
 	if (net_server_ip.s_addr) {
 		ip_to_string(net_server_ip, tmp);
-		setenv("serverip", tmp);
+		env_set("serverip", tmp);
 	}
 #endif
 	if (net_dns_server.s_addr) {
 		ip_to_string(net_dns_server, tmp);
-		setenv("dnsip", tmp);
+		env_set("dnsip", tmp);
 	}
 #if defined(CONFIG_BOOTP_DNS2)
 	if (net_dns_server2.s_addr) {
 		ip_to_string(net_dns_server2, tmp);
-		setenv("dnsip2", tmp);
+		env_set("dnsip2", tmp);
 	}
 #endif
 	if (net_nis_domain[0])
-		setenv("domain", net_nis_domain);
+		env_set("domain", net_nis_domain);
 
 #if defined(CONFIG_CMD_SNTP) && defined(CONFIG_BOOTP_TIMEOFFSET)
 	if (net_ntp_time_offset) {
 		sprintf(tmp, "%d", net_ntp_time_offset);
-		setenv("timeoffset", tmp);
+		env_set("timeoffset", tmp);
 	}
 #endif
 #if defined(CONFIG_CMD_SNTP) && defined(CONFIG_BOOTP_NTPSERVER)
 	if (net_ntp_server.s_addr) {
 		ip_to_string(net_ntp_server, tmp);
-		setenv("ntpserverip", tmp);
+		env_set("ntpserverip", tmp);
 	}
 #endif
 }
@@ -181,7 +181,7 @@
 	ulong addr;
 
 	/* pre-set load_addr */
-	s = getenv("loadaddr");
+	s = env_get("loadaddr");
 	if (s != NULL)
 		load_addr = simple_strtoul(s, NULL, 16);
 
@@ -291,14 +291,14 @@
 		printf("CDP offered appliance VLAN %d\n",
 		       ntohs(cdp_appliance_vlan));
 		vlan_to_string(cdp_appliance_vlan, tmp);
-		setenv("vlan", tmp);
+		env_set("vlan", tmp);
 		net_our_vlan = cdp_appliance_vlan;
 	}
 
 	if (cdp_native_vlan != htons(-1)) {
 		printf("CDP offered native VLAN %d\n", ntohs(cdp_native_vlan));
 		vlan_to_string(cdp_native_vlan, tmp);
-		setenv("nvlan", tmp);
+		env_set("nvlan", tmp);
 		net_native_vlan = cdp_native_vlan;
 	}
 }
@@ -331,7 +331,7 @@
 	char *toff;
 
 	if (argc < 2) {
-		net_ntp_server = getenv_ip("ntpserverip");
+		net_ntp_server = env_get_ip("ntpserverip");
 		if (net_ntp_server.s_addr == 0) {
 			printf("ntpserverip not set\n");
 			return CMD_RET_FAILURE;
@@ -344,7 +344,7 @@
 		}
 	}
 
-	toff = getenv("timeoffset");
+	toff = env_get("timeoffset");
 	if (toff == NULL)
 		net_ntp_time_offset = 0;
 	else
@@ -423,14 +423,14 @@
 
 	net_gateway.s_addr = 0;
 	ip_to_string(net_gateway, tmp);
-	setenv("gatewayip", tmp);
+	env_set("gatewayip", tmp);
 
 	ip_to_string(net_netmask, tmp);
-	setenv("netmask", tmp);
+	env_set("netmask", tmp);
 
 	ip_to_string(net_ip, tmp);
-	setenv("ipaddr", tmp);
-	setenv("llipaddr", tmp); /* store this for next time */
+	env_set("ipaddr", tmp);
+	env_set("llipaddr", tmp); /* store this for next time */
 
 	return CMD_RET_SUCCESS;
 }
diff --git a/cmd/nvedit.c b/cmd/nvedit.c
index cd17db6..4033d90 100644
--- a/cmd/nvedit.c
+++ b/cmd/nvedit.c
@@ -283,7 +283,7 @@
 	return 0;
 }
 
-int setenv(const char *varname, const char *varvalue)
+int env_set(const char *varname, const char *varvalue)
 {
 	const char * const argv[4] = { "setenv", varname, varvalue, NULL };
 
@@ -304,12 +304,12 @@
  * @param value		Value to set it to
  * @return 0 if ok, 1 on error
  */
-int setenv_ulong(const char *varname, ulong value)
+int env_set_ulong(const char *varname, ulong value)
 {
 	/* TODO: this should be unsigned */
 	char *str = simple_itoa(value);
 
-	return setenv(varname, str);
+	return env_set(varname, str);
 }
 
 /**
@@ -319,21 +319,21 @@
  * @param value		Value to set it to
  * @return 0 if ok, 1 on error
  */
-int setenv_hex(const char *varname, ulong value)
+int env_set_hex(const char *varname, ulong value)
 {
 	char str[17];
 
 	sprintf(str, "%lx", value);
-	return setenv(varname, str);
+	return env_set(varname, str);
 }
 
-ulong getenv_hex(const char *varname, ulong default_val)
+ulong env_get_hex(const char *varname, ulong default_val)
 {
 	const char *s;
 	ulong value;
 	char *endp;
 
-	s = getenv(varname);
+	s = env_get(varname);
 	if (s)
 		value = simple_strtoul(s, &endp, 16);
 	if (!s || endp == s)
@@ -594,7 +594,7 @@
 		return 1;
 
 	/* Set read buffer to initial value or empty sting */
-	init_val = getenv(argv[1]);
+	init_val = env_get(argv[1]);
 	if (init_val)
 		snprintf(buffer, CONFIG_SYS_CBSIZE, "%s", init_val);
 	else
@@ -622,7 +622,7 @@
  * return address of storage for that variable,
  * or NULL if not found
  */
-char *getenv(const char *name)
+char *env_get(const char *name)
 {
 	if (gd->flags & GD_FLG_ENV_READY) { /* after import into hashtable */
 		ENTRY e, *ep;
@@ -637,7 +637,7 @@
 	}
 
 	/* restricted capabilities before import */
-	if (getenv_f(name, (char *)(gd->env_buf), sizeof(gd->env_buf)) > 0)
+	if (env_get_f(name, (char *)(gd->env_buf), sizeof(gd->env_buf)) > 0)
 		return (char *)(gd->env_buf);
 
 	return NULL;
@@ -646,7 +646,7 @@
 /*
  * Look up variable from environment for restricted C runtime env.
  */
-int getenv_f(const char *name, char *buf, unsigned len)
+int env_get_f(const char *name, char *buf, unsigned len)
 {
 	int i, nxt;
 
@@ -690,13 +690,13 @@
  *			found
  * @return the decoded value, or default_val if not found
  */
-ulong getenv_ulong(const char *name, int base, ulong default_val)
+ulong env_get_ulong(const char *name, int base, ulong default_val)
 {
 	/*
-	 * We can use getenv() here, even before relocation, since the
+	 * We can use env_get() here, even before relocation, since the
 	 * environment variable value is an integer and thus short.
 	 */
-	const char *str = getenv(name);
+	const char *str = env_get(name);
 
 	return str ? simple_strtoul(str, NULL, base) : default_val;
 }
@@ -706,9 +706,11 @@
 static int do_env_save(cmd_tbl_t *cmdtp, int flag, int argc,
 		       char * const argv[])
 {
-	printf("Saving Environment to %s...\n", env_name_spec);
+	struct env_driver *env = env_driver_lookup_default();
 
-	return saveenv() ? 1 : 0;
+	printf("Saving Environment to %s...\n", env->name);
+
+	return env_save() ? 1 : 0;
 }
 
 U_BOOT_CMD(
@@ -929,7 +931,7 @@
 			return 1;
 		}
 		sprintf(buf, "%zX", (size_t)len);
-		setenv("filesize", buf);
+		env_set("filesize", buf);
 
 		return 0;
 	}
@@ -955,7 +957,7 @@
 		envp->flags = ACTIVE_FLAG;
 #endif
 	}
-	setenv_hex("filesize", len + offsetof(env_t, data));
+	env_set_hex("filesize", len + offsetof(env_t, data));
 
 	return 0;
 
diff --git a/cmd/part.c b/cmd/part.c
index 8ba0598..746bf40 100644
--- a/cmd/part.c
+++ b/cmd/part.c
@@ -38,7 +38,7 @@
 		return 1;
 
 	if (argc > 2)
-		setenv(argv[2], info.uuid);
+		env_set(argv[2], info.uuid);
 	else
 		printf("%s\n", info.uuid);
 
@@ -99,7 +99,7 @@
 			sprintf(t, "%s%x", str[0] ? " " : "", p);
 			strcat(str, t);
 		}
-		setenv(var, str);
+		env_set(var, str);
 		return 0;
 	}
 
@@ -135,7 +135,7 @@
 	snprintf(buf, sizeof(buf), LBAF, info.start);
 
 	if (argc > 3)
-		setenv(argv[3], buf);
+		env_set(argv[3], buf);
 	else
 		printf("%s\n", buf);
 
@@ -169,7 +169,7 @@
 	snprintf(buf, sizeof(buf), LBAF, info.size);
 
 	if (argc > 3)
-		setenv(argv[3], buf);
+		env_set(argv[3], buf);
 	else
 		printf("%s\n", buf);
 
diff --git a/cmd/pxe.c b/cmd/pxe.c
index 0a07f14..c5a770a 100644
--- a/cmd/pxe.c
+++ b/cmd/pxe.c
@@ -33,15 +33,15 @@
 static bool is_pxe;
 
 /*
- * Like getenv, but prints an error if envvar isn't defined in the
- * environment.  It always returns what getenv does, so it can be used in
- * place of getenv without changing error handling otherwise.
+ * Like env_get, but prints an error if envvar isn't defined in the
+ * environment.  It always returns what env_get does, so it can be used in
+ * place of env_get without changing error handling otherwise.
  */
 static char *from_env(const char *envvar)
 {
 	char *ret;
 
-	ret = getenv(envvar);
+	ret = env_get(envvar);
 
 	if (!ret)
 		printf("missing environment variable: %s\n", envvar);
@@ -70,8 +70,7 @@
 		return -EINVAL;
 	}
 
-	if (!eth_getenv_enetaddr_by_index("eth", eth_get_dev_index(),
-					  ethaddr))
+	if (!eth_env_get_enetaddr_by_index("eth", eth_get_dev_index(), ethaddr))
 		return -ENOENT;
 
 	sprintf(outbuf, "01-%02x-%02x-%02x-%02x-%02x-%02x",
@@ -591,7 +590,7 @@
 		char bootargs[CONFIG_SYS_CBSIZE];
 
 		cli_simple_process_macros(label->append, bootargs);
-		setenv("bootargs", bootargs);
+		env_set("bootargs", bootargs);
 	}
 
 	debug("running: %s\n", localcmd);
@@ -649,9 +648,9 @@
 		}
 
 		bootm_argv[2] = initrd_str;
-		strcpy(bootm_argv[2], getenv("ramdisk_addr_r"));
+		strcpy(bootm_argv[2], env_get("ramdisk_addr_r"));
 		strcat(bootm_argv[2], ":");
-		strcat(bootm_argv[2], getenv("filesize"));
+		strcat(bootm_argv[2], env_get("filesize"));
 	}
 
 	if (get_relfile_envaddr(cmdtp, label->kernel, "kernel_addr_r") < 0) {
@@ -662,8 +661,8 @@
 
 	if (label->ipappend & 0x1) {
 		sprintf(ip_str, " ip=%s:%s:%s:%s",
-			getenv("ipaddr"), getenv("serverip"),
-			getenv("gatewayip"), getenv("netmask"));
+			env_get("ipaddr"), env_get("serverip"),
+			env_get("gatewayip"), env_get("netmask"));
 	}
 
 #ifdef CONFIG_CMD_NET
@@ -695,11 +694,11 @@
 		strcat(bootargs, mac_str);
 
 		cli_simple_process_macros(bootargs, finalbootargs);
-		setenv("bootargs", finalbootargs);
+		env_set("bootargs", finalbootargs);
 		printf("append: %s\n", finalbootargs);
 	}
 
-	bootm_argv[1] = getenv("kernel_addr_r");
+	bootm_argv[1] = env_get("kernel_addr_r");
 
 	/*
 	 * fdt usage is optional:
@@ -714,7 +713,7 @@
 	 *
 	 * Scenario 3: fdt blob is not available.
 	 */
-	bootm_argv[3] = getenv("fdt_addr_r");
+	bootm_argv[3] = env_get("fdt_addr_r");
 
 	/* if fdt label is defined then get fdt from server */
 	if (bootm_argv[3]) {
@@ -726,7 +725,7 @@
 		} else if (label->fdtdir) {
 			char *f1, *f2, *f3, *f4, *slash;
 
-			f1 = getenv("fdtfile");
+			f1 = env_get("fdtfile");
 			if (f1) {
 				f2 = "";
 				f3 = "";
@@ -739,9 +738,9 @@
 				 * or the boot scripts should set $fdtfile
 				 * before invoking "pxe" or "sysboot".
 				 */
-				f1 = getenv("soc");
+				f1 = env_get("soc");
 				f2 = "-";
-				f3 = getenv("board");
+				f3 = env_get("board");
 				f4 = ".dtb";
 			}
 
@@ -781,7 +780,7 @@
 	}
 
 	if (!bootm_argv[3])
-		bootm_argv[3] = getenv("fdt_addr");
+		bootm_argv[3] = env_get("fdt_addr");
 
 	if (bootm_argv[3]) {
 		if (!bootm_argv[2])
@@ -1671,10 +1670,10 @@
 	}
 
 	if (argc < 6)
-		filename = getenv("bootfile");
+		filename = env_get("bootfile");
 	else {
 		filename = argv[5];
-		setenv("bootfile", filename);
+		env_set("bootfile", filename);
 	}
 
 	if (strstr(argv[3], "ext2"))
diff --git a/cmd/qfw.c b/cmd/qfw.c
index 12436ec..b38026b 100644
--- a/cmd/qfw.c
+++ b/cmd/qfw.c
@@ -55,7 +55,7 @@
 		 * when invoking qemu), do not update bootargs
 		 */
 		if (*data_addr != '\0') {
-			if (setenv("bootargs", data_addr) < 0)
+			if (env_set("bootargs", data_addr) < 0)
 				printf("warning: unable to change bootargs\n");
 		}
 	}
@@ -123,7 +123,7 @@
 	void *load_addr;
 	void *initrd_addr;
 
-	env = getenv("loadaddr");
+	env = env_get("loadaddr");
 	load_addr = env ?
 		(void *)simple_strtoul(env, NULL, 16) :
 #ifdef CONFIG_LOADADDR
@@ -132,7 +132,7 @@
 		NULL;
 #endif
 
-	env = getenv("ramdiskaddr");
+	env = env_get("ramdiskaddr");
 	initrd_addr = env ?
 		(void *)simple_strtoul(env, NULL, 16) :
 #ifdef CONFIG_RAMDISK_ADDR
diff --git a/cmd/reiser.c b/cmd/reiser.c
index 9c3e9e9..e10c7b9 100644
--- a/cmd/reiser.c
+++ b/cmd/reiser.c
@@ -88,18 +88,18 @@
 
 	switch (argc) {
 	case 3:
-		addr_str = getenv("loadaddr");
+		addr_str = env_get("loadaddr");
 		if (addr_str != NULL) {
 			addr = simple_strtoul (addr_str, NULL, 16);
 		} else {
 			addr = CONFIG_SYS_LOAD_ADDR;
 		}
-		filename = getenv ("bootfile");
+		filename = env_get("bootfile");
 		count = 0;
 		break;
 	case 4:
 		addr = simple_strtoul (argv[3], NULL, 16);
-		filename = getenv ("bootfile");
+		filename = env_get("bootfile");
 		count = 0;
 		break;
 	case 5:
@@ -157,7 +157,7 @@
 	load_addr = addr;
 
 	printf ("\n%ld bytes read\n", filelen);
-	setenv_hex("filesize", filelen);
+	env_set_hex("filesize", filelen);
 
 	return filelen;
 }
diff --git a/cmd/setexpr.c b/cmd/setexpr.c
index e7194fc..af21022 100644
--- a/cmd/setexpr.c
+++ b/cmd/setexpr.c
@@ -145,7 +145,7 @@
 	}
 
 	if (t == NULL) {
-		value = getenv(name);
+		value = env_get(name);
 
 		if (value == NULL) {
 			printf("## Error: variable \"%s\" not defined\n", name);
@@ -282,11 +282,11 @@
 		if (!global)
 			break;
 	}
-	debug("## FINAL (now setenv()) :  %s\n", data);
+	debug("## FINAL (now env_set()) :  %s\n", data);
 
 	printf("%s=%s\n", name, data);
 
-	return setenv(name, data);
+	return env_set(name, data);
 }
 #endif
 
@@ -314,7 +314,7 @@
 
 	/* plain assignment: "setexpr name value" */
 	if (argc == 3) {
-		setenv_hex(argv[1], a);
+		env_set_hex(argv[1], a);
 		return 0;
 	}
 
@@ -370,7 +370,7 @@
 		return 1;
 	}
 
-	setenv_hex(argv[1], value);
+	env_set_hex(argv[1], value);
 
 	return 0;
 }
diff --git a/cmd/source.c b/cmd/source.c
index 177f86b..a9831b6 100644
--- a/cmd/source.c
+++ b/cmd/source.c
@@ -40,7 +40,7 @@
 	size_t		fit_len;
 #endif
 
-	verify = getenv_yesno ("verify");
+	verify = env_get_yesno("verify");
 
 	buf = map_sysmem(addr, 0);
 	switch (genimg_get_format(buf)) {
diff --git a/cmd/tpm.c b/cmd/tpm.c
index 0c4bc73..d9b4335 100644
--- a/cmd/tpm.c
+++ b/cmd/tpm.c
@@ -231,7 +231,7 @@
 		default:
 			return -1;
 		}
-		if (setenv_ulong(*vars, value))
+		if (env_set_ulong(*vars, value))
 			return -1;
 	}
 
@@ -624,7 +624,7 @@
 				 &key_handle);
 	if (!err) {
 		printf("Key handle is 0x%x\n", key_handle);
-		setenv_hex("key_handle", key_handle);
+		env_set_hex("key_handle", key_handle);
 	}
 
 	return report_return_code(err);
diff --git a/cmd/trace.c b/cmd/trace.c
index 1a6d8c3..a0a7dd1 100644
--- a/cmd/trace.c
+++ b/cmd/trace.c
@@ -16,10 +16,10 @@
 	if (argc < 2)
 		return -1;
 	if (argc < 4) {
-		*buff_size = getenv_ulong("profsize", 16, 0);
-		*buff = map_sysmem(getenv_ulong("profbase", 16, 0),
+		*buff_size = env_get_ulong("profsize", 16, 0);
+		*buff = map_sysmem(env_get_ulong("profbase", 16, 0),
 				   *buff_size);
-		*buff_ptr = getenv_ulong("profoffset", 16, 0);
+		*buff_ptr = env_get_ulong("profoffset", 16, 0);
 	} else {
 		*buff_size = simple_strtoul(argv[3], NULL, 16);
 		*buff = map_sysmem(simple_strtoul(argv[2], NULL, 16),
@@ -46,9 +46,9 @@
 	used = min(avail, (size_t)needed);
 	printf("Function trace dumped to %08lx, size %#zx\n",
 	       (ulong)map_to_sysmem(buff + buff_ptr), used);
-	setenv_hex("profbase", map_to_sysmem(buff));
-	setenv_hex("profsize", buff_size);
-	setenv_hex("profoffset", buff_ptr + used);
+	env_set_hex("profbase", map_to_sysmem(buff));
+	env_set_hex("profsize", buff_size);
+	env_set_hex("profoffset", buff_ptr + used);
 
 	return 0;
 }
@@ -71,9 +71,9 @@
 	printf("Call list dumped to %08lx, size %#zx\n",
 	       (ulong)map_to_sysmem(buff + buff_ptr), used);
 
-	setenv_hex("profbase", map_to_sysmem(buff));
-	setenv_hex("profsize", buff_size);
-	setenv_hex("profoffset", buff_ptr + used);
+	env_set_hex("profbase", map_to_sysmem(buff));
+	env_set_hex("profsize", buff_size);
+	env_set_hex("profoffset", buff_ptr + used);
 
 	return 0;
 }
diff --git a/cmd/unzip.c b/cmd/unzip.c
index a8bcb1f..94f883f 100644
--- a/cmd/unzip.c
+++ b/cmd/unzip.c
@@ -29,7 +29,7 @@
 		return 1;
 
 	printf("Uncompressed size: %ld = 0x%lX\n", src_len, src_len);
-	setenv_hex("filesize", src_len);
+	env_set_hex("filesize", src_len);
 
 	return 0;
 }
diff --git a/cmd/ximg.c b/cmd/ximg.c
index d033c15..21b5c37 100644
--- a/cmd/ximg.c
+++ b/cmd/ximg.c
@@ -52,7 +52,7 @@
 #endif
 	uint8_t		comp;
 
-	verify = getenv_yesno("verify");
+	verify = env_get_yesno("verify");
 
 	if (argc > 1) {
 		addr = simple_strtoul(argv[1], NULL, 16);
@@ -251,8 +251,8 @@
 
 	flush_cache(dest, len);
 
-	setenv_hex("fileaddr", data);
-	setenv_hex("filesize", len);
+	env_set_hex("fileaddr", data);
+	env_set_hex("filesize", len);
 
 	return 0;
 }
diff --git a/cmd/zfs.c b/cmd/zfs.c
index 3ed9912..6913043 100644
--- a/cmd/zfs.c
+++ b/cmd/zfs.c
@@ -51,10 +51,10 @@
 
 	count = 0;
 	addr = simple_strtoul(argv[3], NULL, 16);
-	filename = getenv("bootfile");
+	filename = env_get("bootfile");
 	switch (argc) {
 	case 3:
-		addr_str = getenv("loadaddr");
+		addr_str = env_get("loadaddr");
 		if (addr_str != NULL)
 			addr = simple_strtoul(addr_str, NULL, 16);
 		else
@@ -115,7 +115,7 @@
 	load_addr = addr;
 
 	printf("%llu bytes read\n", zfile.size);
-	setenv_hex("filesize", zfile.size);
+	env_set_hex("filesize", zfile.size);
 
 	return 0;
 }
diff --git a/cmd/zip.c b/cmd/zip.c
index 7fcd9d5..dac7527 100644
--- a/cmd/zip.c
+++ b/cmd/zip.c
@@ -30,7 +30,7 @@
 		return 1;
 
 	printf("Compressed size: %ld = 0x%lX\n", dst_len, dst_len);
-	setenv_hex("filesize", dst_len);
+	env_set_hex("filesize", dst_len);
 
 	return 0;
 }
diff --git a/common/Kconfig b/common/Kconfig
index 3ef1ab0..4d8cae9 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -174,448 +174,6 @@
 
 endmenu
 
-menu "Environment"
-
-config ENV_IS_IN_DATAFLASH
-	bool "Environment in dataflash"
-	depends on !CHAIN_OF_TRUST
-	help
-	  Define this if you have a DataFlash memory device which you
-	  want to use for the environment.
-
-	  - CONFIG_ENV_OFFSET:
-	  - CONFIG_ENV_ADDR:
-	  - CONFIG_ENV_SIZE:
-
-	  These three #defines specify the offset and size of the
-	  environment area within the total memory of your DataFlash placed
-	  at the specified address.
-
-config ENV_IS_IN_EEPROM
-	bool "Environment in EEPROM"
-	depends on !CHAIN_OF_TRUST
-	help
-	  Use this if you have an EEPROM or similar serial access
-	  device and a driver for it.
-
-	  - CONFIG_ENV_OFFSET:
-	  - CONFIG_ENV_SIZE:
-
-	  These two #defines specify the offset and size of the
-	  environment area within the total memory of your EEPROM.
-
-	  - CONFIG_SYS_I2C_EEPROM_ADDR:
-	  If defined, specified the chip address of the EEPROM device.
-	  The default address is zero.
-
-	  - CONFIG_SYS_I2C_EEPROM_BUS:
-	  If defined, specified the i2c bus of the EEPROM device.
-
-	  - CONFIG_SYS_EEPROM_PAGE_WRITE_BITS:
-	  If defined, the number of bits used to address bytes in a
-	  single page in the EEPROM device.  A 64 byte page, for example
-	  would require six bits.
-
-	  - CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS:
-	  If defined, the number of milliseconds to delay between
-	  page writes.	The default is zero milliseconds.
-
-	  - CONFIG_SYS_I2C_EEPROM_ADDR_LEN:
-	  The length in bytes of the EEPROM memory array address.  Note
-	  that this is NOT the chip address length!
-
-	  - CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW:
-	  EEPROM chips that implement "address overflow" are ones
-	  like Catalyst 24WC04/08/16 which has 9/10/11 bits of
-	  address and the extra bits end up in the "chip address" bit
-	  slots. This makes a 24WC08 (1Kbyte) chip look like four 256
-	  byte chips.
-
-	  Note that we consider the length of the address field to
-	  still be one byte because the extra address bits are hidden
-	  in the chip address.
-
-	  - CONFIG_SYS_EEPROM_SIZE:
-	  The size in bytes of the EEPROM device.
-
-	  - CONFIG_ENV_EEPROM_IS_ON_I2C
-	  define this, if you have I2C and SPI activated, and your
-	  EEPROM, which holds the environment, is on the I2C bus.
-
-	  - CONFIG_I2C_ENV_EEPROM_BUS
-	  if you have an Environment on an EEPROM reached over
-	  I2C muxes, you can define here, how to reach this
-	  EEPROM. For example:
-
-	  #define CONFIG_I2C_ENV_EEPROM_BUS	  1
-
-	  EEPROM which holds the environment, is reached over
-	  a pca9547 i2c mux with address 0x70, channel 3.
-
-config ENV_IS_IN_FAT
-	bool "Environment is in a FAT filesystem"
-	depends on !CHAIN_OF_TRUST
-	select FAT_WRITE
-	help
-         Define this if you want to use the FAT file system for the environment.
-
-
-         - CONFIG_FAT_WRITE:
-         This must be enabled. Otherwise it cannot save the environment file.
-
-config ENV_IS_IN_FLASH
-	bool "Environment in flash memory"
-	depends on !CHAIN_OF_TRUST
-	help
-	  Define this if you have a flash device which you want to use for the
-	  environment.
-
-	  a) The environment occupies one whole flash sector, which is
-	   "embedded" in the text segment with the U-Boot code. This
-	   happens usually with "bottom boot sector" or "top boot
-	   sector" type flash chips, which have several smaller
-	   sectors at the start or the end. For instance, such a
-	   layout can have sector sizes of 8, 2x4, 16, Nx32 kB. In
-	   such a case you would place the environment in one of the
-	   4 kB sectors - with U-Boot code before and after it. With
-	   "top boot sector" type flash chips, you would put the
-	   environment in one of the last sectors, leaving a gap
-	   between U-Boot and the environment.
-
-	  CONFIG_ENV_OFFSET:
-
-	   Offset of environment data (variable area) to the
-	   beginning of flash memory; for instance, with bottom boot
-	   type flash chips the second sector can be used: the offset
-	   for this sector is given here.
-
-	   CONFIG_ENV_OFFSET is used relative to CONFIG_SYS_FLASH_BASE.
-
-	  CONFIG_ENV_ADDR:
-
-	   This is just another way to specify the start address of
-	   the flash sector containing the environment (instead of
-	   CONFIG_ENV_OFFSET).
-
-	  CONFIG_ENV_SECT_SIZE:
-
-	   Size of the sector containing the environment.
-
-
-	  b) Sometimes flash chips have few, equal sized, BIG sectors.
-	   In such a case you don't want to spend a whole sector for
-	   the environment.
-
-	  CONFIG_ENV_SIZE:
-
-	   If you use this in combination with CONFIG_ENV_IS_IN_FLASH
-	   and CONFIG_ENV_SECT_SIZE, you can specify to use only a part
-	   of this flash sector for the environment. This saves
-	   memory for the RAM copy of the environment.
-
-	   It may also save flash memory if you decide to use this
-	   when your environment is "embedded" within U-Boot code,
-	   since then the remainder of the flash sector could be used
-	   for U-Boot code. It should be pointed out that this is
-	   STRONGLY DISCOURAGED from a robustness point of view:
-	   updating the environment in flash makes it always
-	   necessary to erase the WHOLE sector. If something goes
-	   wrong before the contents has been restored from a copy in
-	   RAM, your target system will be dead.
-
-	  CONFIG_ENV_ADDR_REDUND
-	  CONFIG_ENV_SIZE_REDUND
-
-	   These settings describe a second storage area used to hold
-	   a redundant copy of the environment data, so that there is
-	   a valid backup copy in case there is a power failure during
-	   a "saveenv" operation.
-
-	  BE CAREFUL! Any changes to the flash layout, and some changes to the
-	  source code will make it necessary to adapt <board>/u-boot.lds*
-	  accordingly!
-
-config ENV_IS_IN_MMC
-	bool "Environment in an MMC device"
-	depends on !CHAIN_OF_TRUST
-	default y if ARCH_SUNXI
-	help
-	  Define this if you have an MMC device which you want to use for the
-	  environment.
-
-	  CONFIG_SYS_MMC_ENV_DEV:
-
-	  Specifies which MMC device the environment is stored in.
-
-	  CONFIG_SYS_MMC_ENV_PART (optional):
-
-	  Specifies which MMC partition the environment is stored in. If not
-	  set, defaults to partition 0, the user area. Common values might be
-	  1 (first MMC boot partition), 2 (second MMC boot partition).
-
-	  CONFIG_ENV_OFFSET:
-	  CONFIG_ENV_SIZE:
-
-	  These two #defines specify the offset and size of the environment
-	  area within the specified MMC device.
-
-	  If offset is positive (the usual case), it is treated as relative to
-	  the start of the MMC partition. If offset is negative, it is treated
-	  as relative to the end of the MMC partition. This can be useful if
-	  your board may be fitted with different MMC devices, which have
-	  different sizes for the MMC partitions, and you always want the
-	  environment placed at the very end of the partition, to leave the
-	  maximum possible space before it, to store other data.
-
-	  These two values are in units of bytes, but must be aligned to an
-	  MMC sector boundary.
-
-	  CONFIG_ENV_OFFSET_REDUND (optional):
-
-	  Specifies a second storage area, of CONFIG_ENV_SIZE size, used to
-	  hold a redundant copy of the environment data. This provides a
-	  valid backup copy in case the other copy is corrupted, e.g. due
-	  to a power failure during a "saveenv" operation.
-
-	  This value may also be positive or negative; this is handled in the
-	  same way as CONFIG_ENV_OFFSET.
-
-	  This value is also in units of bytes, but must also be aligned to
-	  an MMC sector boundary.
-
-	  CONFIG_ENV_SIZE_REDUND (optional):
-
-	  This value need not be set, even when CONFIG_ENV_OFFSET_REDUND is
-	  set. If this value is set, it must be set to the same value as
-	  CONFIG_ENV_SIZE.
-
-config ENV_IS_IN_NAND
-	bool "Environment in a NAND device"
-	depends on !CHAIN_OF_TRUST
-	help
-	  Define this if you have a NAND device which you want to use for the
-	  environment.
-
-	  - CONFIG_ENV_OFFSET:
-	  - CONFIG_ENV_SIZE:
-
-	  These two #defines specify the offset and size of the environment
-	  area within the first NAND device.  CONFIG_ENV_OFFSET must be
-	  aligned to an erase block boundary.
-
-	  - CONFIG_ENV_OFFSET_REDUND (optional):
-
-	  This setting describes a second storage area of CONFIG_ENV_SIZE
-	  size used to hold a redundant copy of the environment data, so
-	  that there is a valid backup copy in case there is a power failure
-	  during a "saveenv" operation.	 CONFIG_ENV_OFFSET_REDUND must be
-	  aligned to an erase block boundary.
-
-	  - CONFIG_ENV_RANGE (optional):
-
-	  Specifies the length of the region in which the environment
-	  can be written.  This should be a multiple of the NAND device's
-	  block size.  Specifying a range with more erase blocks than
-	  are needed to hold CONFIG_ENV_SIZE allows bad blocks within
-	  the range to be avoided.
-
-	  - CONFIG_ENV_OFFSET_OOB (optional):
-
-	  Enables support for dynamically retrieving the offset of the
-	  environment from block zero's out-of-band data.  The
-	  "nand env.oob" command can be used to record this offset.
-	  Currently, CONFIG_ENV_OFFSET_REDUND is not supported when
-	  using CONFIG_ENV_OFFSET_OOB.
-
-config ENV_IS_IN_NVRAM
-	bool "Environment in a non-volatile RAM"
-	depends on !CHAIN_OF_TRUST
-	help
-	  Define this if you have some non-volatile memory device
-	  (NVRAM, battery buffered SRAM) which you want to use for the
-	  environment.
-
-	  - CONFIG_ENV_ADDR:
-	  - CONFIG_ENV_SIZE:
-
-	  These two #defines are used to determine the memory area you
-	  want to use for environment. It is assumed that this memory
-	  can just be read and written to, without any special
-	  provision.
-
-config ENV_IS_IN_ONENAND
-	bool "Environment is in OneNAND"
-	depends on !CHAIN_OF_TRUST
-	help
-	  Define this if you want to put your local device's environment in
-	  OneNAND.
-
-	  - CONFIG_ENV_ADDR:
-	  - CONFIG_ENV_SIZE:
-
-	  These two #defines are used to determine the device range you
-	  want to use for environment. It is assumed that this memory
-	  can just be read and written to, without any special
-	  provision.
-
-config ENV_IS_IN_REMOTE
-	bool "Environment is in remove memory space"
-	depends on !CHAIN_OF_TRUST
-	help
-	  Define this if you have a remote memory space which you
-	  want to use for the local device's environment.
-
-	  - CONFIG_ENV_ADDR:
-	  - CONFIG_ENV_SIZE:
-
-	  These two #defines specify the address and size of the
-	  environment area within the remote memory space. The
-	  local device can get the environment from remote memory
-	  space by SRIO or PCIE links.
-
-config ENV_IS_IN_SPI_FLASH
-	bool "Environment is in SPI flash"
-	depends on !CHAIN_OF_TRUST
-	help
-	  Define this if you have a SPI Flash memory device which you
-	  want to use for the environment.
-
-	  - CONFIG_ENV_OFFSET:
-	  - CONFIG_ENV_SIZE:
-
-	  These two #defines specify the offset and size of the
-	  environment area within the SPI Flash. CONFIG_ENV_OFFSET must be
-	  aligned to an erase sector boundary.
-
-	  - CONFIG_ENV_SECT_SIZE:
-
-	  Define the SPI flash's sector size.
-
-	  - CONFIG_ENV_OFFSET_REDUND (optional):
-
-	  This setting describes a second storage area of CONFIG_ENV_SIZE
-	  size used to hold a redundant copy of the environment data, so
-	  that there is a valid backup copy in case there is a power failure
-	  during a "saveenv" operation. CONFIG_ENV_OFFSET_REDUND must be
-	  aligned to an erase sector boundary.
-
-	  - CONFIG_ENV_SPI_BUS (optional):
-	  - CONFIG_ENV_SPI_CS (optional):
-
-	  Define the SPI bus and chip select. If not defined they will be 0.
-
-	  - CONFIG_ENV_SPI_MAX_HZ (optional):
-
-	  Define the SPI max work clock. If not defined then use 1MHz.
-
-	  - CONFIG_ENV_SPI_MODE (optional):
-
-	  Define the SPI work mode. If not defined then use SPI_MODE_3.
-
-config ENV_IS_IN_UBI
-	bool "Environment in a UBI volume"
-	depends on !CHAIN_OF_TRUST
-	help
-	  Define this if you have an UBI volume that you want to use for the
-	  environment.  This has the benefit of wear-leveling the environment
-	  accesses, which is important on NAND.
-
-	  - CONFIG_ENV_UBI_PART:
-
-	  Define this to a string that is the mtd partition containing the UBI.
-
-	  - CONFIG_ENV_UBI_VOLUME:
-
-	  Define this to the name of the volume that you want to store the
-	  environment in.
-
-	  - CONFIG_ENV_UBI_VOLUME_REDUND:
-
-	  Define this to the name of another volume to store a second copy of
-	  the environment in.  This will enable redundant environments in UBI.
-	  It is assumed that both volumes are in the same MTD partition.
-
-	  - CONFIG_UBI_SILENCE_MSG
-	  - CONFIG_UBIFS_SILENCE_MSG
-
-	  You will probably want to define these to avoid a really noisy system
-	  when storing the env in UBI.
-
-config ENV_IS_NOWHERE
-	bool "Environment is not stored"
-	help
-	  Define this if you don't want to or can't have an environment stored
-	  on a storage medium
-
-config ENV_FAT_INTERFACE
-	string "Name of the block device for the environment"
-	depends on ENV_IS_IN_FAT
-	default "mmc" if TI_COMMON_CMD_OPTIONS || ARCH_ZYNQMP || ARCH_AT91
-	help
-	  Define this to a string that is the name of the block device.
-
-config ENV_FAT_DEVICE_AND_PART
-	string "Device and partition for where to store the environemt in FAT"
-	depends on ENV_IS_IN_FAT
-	default "0:1" if TI_COMMON_CMD_OPTIONS
-	default "0:auto" if ARCH_ZYNQMP
-	default "0" if ARCH_AT91
-	help
-	  Define this to a string to specify the partition of the device. It can
-	  be as following:
-
-	    "D:P", "D:0", "D", "D:" or "D:auto" (D, P are integers. And P >= 1)
-	       - "D:P": device D partition P. Error occurs if device D has no
-	                partition table.
-	       - "D:0": device D.
-	       - "D" or "D:": device D partition 1 if device D has partition
-	                      table, or the whole device D if has no partition
-	                      table.
-	       - "D:auto": first partition in device D with bootable flag set.
-	                   If none, first valid partition in device D. If no
-	                   partition table then means device D.
-
-config ENV_FAT_FILE
-	string "Name of the FAT file to use for the environemnt"
-	depends on ENV_IS_IN_FAT
-	default "uboot.env"
-	help
-	  It's a string of the FAT file name. This file use to store the
-	  environment.
-
-if ARCH_SUNXI
-
-config ENV_OFFSET
-	hex "Environment Offset"
-	depends on !ENV_IS_IN_UBI
-	depends on !ENV_IS_NOWHERE
-	default 0x88000 if ARCH_SUNXI
-	help
-	  Offset from the start of the device (or partition)
-
-config ENV_SIZE
-	hex "Environment Size"
-	depends on !ENV_IS_NOWHERE
-	default 0x20000 if ARCH_SUNXI
-	help
-	  Size of the environment storage area
-
-config ENV_UBI_PART
-	string "UBI partition name"
-	depends on ENV_IS_IN_UBI
-	help
-	  MTD partition containing the UBI device
-
-config ENV_UBI_VOLUME
-	string "UBI volume name"
-	depends on ENV_IS_IN_UBI
-	help
-	  Name of the volume that you want to store the environment in.
-
-endif
-
-endmenu
-
 config BOOTDELAY
 	int "delay in seconds before automatically booting"
 	default 2
diff --git a/common/Makefile b/common/Makefile
index 3ee7a6b..1b56cf9 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -19,7 +19,7 @@
 obj-y += bootretry.o
 endif
 
-# boards
+# # boards
 obj-y += board_f.o
 obj-y += board_r.o
 obj-$(CONFIG_DISPLAY_BOARDINFO) += board_info.o
@@ -29,29 +29,6 @@
 obj-$(CONFIG_CMD_BOOTZ) += bootm.o bootm_os.o
 obj-$(CONFIG_CMD_BOOTI) += bootm.o bootm_os.o
 
-# environment
-obj-y += env_attr.o
-obj-y += env_callback.o
-obj-y += env_flags.o
-obj-$(CONFIG_ENV_IS_IN_DATAFLASH) += env_dataflash.o
-obj-$(CONFIG_ENV_IS_IN_EEPROM) += env_eeprom.o
-extra-$(CONFIG_ENV_IS_EMBEDDED) += env_embedded.o
-obj-$(CONFIG_ENV_IS_IN_EEPROM) += env_embedded.o
-extra-$(CONFIG_ENV_IS_IN_FLASH) += env_embedded.o
-obj-$(CONFIG_ENV_IS_IN_NVRAM) += env_embedded.o
-obj-$(CONFIG_ENV_IS_IN_FLASH) += env_flash.o
-obj-$(CONFIG_ENV_IS_IN_MMC) += env_mmc.o
-obj-$(CONFIG_ENV_IS_IN_FAT) += env_fat.o
-obj-$(CONFIG_ENV_IS_IN_EXT4) += env_ext4.o
-obj-$(CONFIG_ENV_IS_IN_NAND) += env_nand.o
-obj-$(CONFIG_ENV_IS_IN_NVRAM) += env_nvram.o
-obj-$(CONFIG_ENV_IS_IN_ONENAND) += env_onenand.o
-obj-$(CONFIG_ENV_IS_IN_SATA) += env_sata.o
-obj-$(CONFIG_ENV_IS_IN_SPI_FLASH) += env_sf.o
-obj-$(CONFIG_ENV_IS_IN_REMOTE) += env_remote.o
-obj-$(CONFIG_ENV_IS_IN_UBI) += env_ubi.o
-obj-$(CONFIG_ENV_IS_NOWHERE) += env_nowhere.o
-
 obj-$(CONFIG_CMD_BEDBUG) += bedbug.o
 obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += fdt_support.o
 
@@ -92,7 +69,6 @@
 obj-$(CONFIG_SPL_DFU_SUPPORT) += dfu.o
 obj-$(CONFIG_SPL_DFU_SUPPORT) += cli_hush.o
 obj-$(CONFIG_SPL_HASH_SUPPORT) += hash.o
-obj-$(CONFIG_ENV_IS_IN_FLASH) += env_flash.o
 obj-$(CONFIG_SPL_YMODEM_SUPPORT) += xyzModem.o
 obj-$(CONFIG_SPL_LOAD_FIT) += common_fit.o
 obj-$(CONFIG_SPL_NET_SUPPORT) += miiphyutil.o
@@ -101,28 +77,7 @@
 obj-$(CONFIG_SPL_USB_SUPPORT) += usb.o usb_hub.o
 obj-$(CONFIG_USB_STORAGE) += usb_storage.o
 endif
-# environment
-ifdef CONFIG_TPL_BUILD
-obj-$(CONFIG_TPL_ENV_SUPPORT) += env_attr.o
-obj-$(CONFIG_TPL_ENV_SUPPORT) += env_flags.o
-obj-$(CONFIG_TPL_ENV_SUPPORT) += env_callback.o
-else
-obj-$(CONFIG_SPL_ENV_SUPPORT) += env_attr.o
-obj-$(CONFIG_SPL_ENV_SUPPORT) += env_flags.o
-obj-$(CONFIG_SPL_ENV_SUPPORT) += env_callback.o
 endif
-ifneq ($(CONFIG_TPL_ENV_SUPPORT)$(CONFIG_SPL_ENV_SUPPORT),)
-obj-$(CONFIG_ENV_IS_NOWHERE) += env_nowhere.o
-obj-$(CONFIG_ENV_IS_IN_MMC) += env_mmc.o
-obj-$(CONFIG_ENV_IS_IN_FAT) += env_fat.o
-obj-$(CONFIG_ENV_IS_IN_EXT4) += env_ext4.o
-obj-$(CONFIG_ENV_IS_IN_NAND) += env_nand.o
-obj-$(CONFIG_ENV_IS_IN_SPI_FLASH) += env_sf.o
-obj-$(CONFIG_ENV_IS_IN_FLASH) += env_flash.o
-endif
-endif
-#environment
-obj-y += env_common.o
 #others
 obj-$(CONFIG_DDR_SPD) += ddr_spd.o
 obj-$(CONFIG_SPD_EEPROM) += ddr_spd.o
@@ -175,5 +130,3 @@
 obj-y += command.o
 obj-y += s_record.o
 obj-y += xyzModem.o
-
-CFLAGS_env_embedded.o := -Wa,--no-warn -DENV_CRC=$(shell tools/envcrc 2>/dev/null)
diff --git a/common/autoboot.c b/common/autoboot.c
index c52bad8..a011865 100644
--- a/common/autoboot.c
+++ b/common/autoboot.c
@@ -50,7 +50,7 @@
 
 static int passwd_abort(uint64_t etime)
 {
-	const char *sha_env_str = getenv("bootstopkeysha256");
+	const char *sha_env_str = env_get("bootstopkeysha256");
 	u8 sha_env[SHA256_SUM_LEN];
 	u8 sha[SHA256_SUM_LEN];
 	char presskey[MAX_DELAY_STOP_STR];
@@ -109,8 +109,8 @@
 		int retry;
 	}
 	delaykey[] = {
-		{ .str = getenv("bootdelaykey"),  .retry = 1 },
-		{ .str = getenv("bootstopkey"),   .retry = 0 },
+		{ .str = env_get("bootdelaykey"),  .retry = 1 },
+		{ .str = env_get("bootstopkey"),   .retry = 0 },
 	};
 
 	char presskey[MAX_DELAY_STOP_STR];
@@ -278,12 +278,12 @@
 	/* Add an env variable to point to a kernel payload, if available */
 	addr = fdtdec_get_config_int(gd->fdt_blob, "kernel-offset", 0);
 	if (addr)
-		setenv_addr("kernaddr", (void *)(CONFIG_SYS_TEXT_BASE + addr));
+		env_set_addr("kernaddr", (void *)(CONFIG_SYS_TEXT_BASE + addr));
 
 	/* Add an env variable to point to a root disk, if available */
 	addr = fdtdec_get_config_int(gd->fdt_blob, "rootdisk-offset", 0);
 	if (addr)
-		setenv_addr("rootaddr", (void *)(CONFIG_SYS_TEXT_BASE + addr));
+		env_set_addr("rootaddr", (void *)(CONFIG_SYS_TEXT_BASE + addr));
 #endif /* CONFIG_OF_CONTROL && CONFIG_SYS_TEXT_BASE */
 }
 
@@ -300,11 +300,11 @@
 	bootcount = bootcount_load();
 	bootcount++;
 	bootcount_store(bootcount);
-	setenv_ulong("bootcount", bootcount);
-	bootlimit = getenv_ulong("bootlimit", 10, 0);
+	env_set_ulong("bootcount", bootcount);
+	bootlimit = env_get_ulong("bootlimit", 10, 0);
 #endif /* CONFIG_BOOTCOUNT_LIMIT */
 
-	s = getenv("bootdelay");
+	s = env_get("bootdelay");
 	bootdelay = s ? (int)simple_strtol(s, NULL, 10) : CONFIG_BOOTDELAY;
 
 #ifdef CONFIG_OF_CONTROL
@@ -321,17 +321,17 @@
 
 #ifdef CONFIG_POST
 	if (gd->flags & GD_FLG_POSTFAIL) {
-		s = getenv("failbootcmd");
+		s = env_get("failbootcmd");
 	} else
 #endif /* CONFIG_POST */
 #ifdef CONFIG_BOOTCOUNT_LIMIT
 	if (bootlimit && (bootcount > bootlimit)) {
 		printf("Warning: Bootlimit (%u) exceeded. Using altbootcmd.\n",
 		       (unsigned)bootlimit);
-		s = getenv("altbootcmd");
+		s = env_get("altbootcmd");
 	} else
 #endif /* CONFIG_BOOTCOUNT_LIMIT */
-		s = getenv("bootcmd");
+		s = env_get("bootcmd");
 
 	process_fdt_options(gd->fdt_blob);
 	stored_bootdelay = bootdelay;
@@ -357,7 +357,7 @@
 
 #ifdef CONFIG_MENUKEY
 	if (menukey == CONFIG_MENUKEY) {
-		s = getenv("menucmd");
+		s = env_get("menucmd");
 		if (s)
 			run_command_list(s, -1, 0);
 	}
diff --git a/common/board_f.c b/common/board_f.c
index 5915e50..de5f398 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -118,7 +118,7 @@
 
 static int init_baud_rate(void)
 {
-	gd->baudrate = getenv_ulong("baudrate", 10, CONFIG_BAUDRATE);
+	gd->baudrate = env_get_ulong("baudrate", 10, CONFIG_BAUDRATE);
 	return 0;
 }
 
@@ -324,7 +324,7 @@
 {
 	ulong reg;
 
-	reg = getenv_ulong("pram", 10, CONFIG_PRAM);
+	reg = env_get_ulong("pram", 10, CONFIG_PRAM);
 	gd->relocaddr -= (reg << 10);		/* size is in kB */
 	debug("Reserving %ldk for protected RAM at %08lx\n", reg,
 	      gd->relocaddr);
diff --git a/common/board_r.c b/common/board_r.c
index 985aa95..94697e7 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -372,7 +372,7 @@
 	*
 	* NOTE: Maybe we should add some WATCHDOG_RESET()? XXX
 	*/
-	if (getenv_yesno("flashchecksum") == 1) {
+	if (env_get_yesno("flashchecksum") == 1) {
 		printf("  CRC: %08X", crc32(0,
 			(const unsigned char *) CONFIG_SYS_FLASH_BASE,
 			flash_size));
@@ -486,11 +486,11 @@
 	else
 		set_default_env(NULL);
 #ifdef CONFIG_OF_CONTROL
-	setenv_addr("fdtcontroladdr", gd->fdt_blob);
+	env_set_addr("fdtcontroladdr", gd->fdt_blob);
 #endif
 
 	/* Initialize from environment */
-	load_addr = getenv_ulong("loadaddr", 16, load_addr);
+	load_addr = env_get_ulong("loadaddr", 16, load_addr);
 
 	return 0;
 }
@@ -537,21 +537,21 @@
 	bd_t *bd = gd->bd;
 
 	/* kept around for legacy kernels only ... ignore the next section */
-	eth_getenv_enetaddr("ethaddr", bd->bi_enetaddr);
+	eth_env_get_enetaddr("ethaddr", bd->bi_enetaddr);
 #ifdef CONFIG_HAS_ETH1
-	eth_getenv_enetaddr("eth1addr", bd->bi_enet1addr);
+	eth_env_get_enetaddr("eth1addr", bd->bi_enet1addr);
 #endif
 #ifdef CONFIG_HAS_ETH2
-	eth_getenv_enetaddr("eth2addr", bd->bi_enet2addr);
+	eth_env_get_enetaddr("eth2addr", bd->bi_enet2addr);
 #endif
 #ifdef CONFIG_HAS_ETH3
-	eth_getenv_enetaddr("eth3addr", bd->bi_enet3addr);
+	eth_env_get_enetaddr("eth3addr", bd->bi_enet3addr);
 #endif
 #ifdef CONFIG_HAS_ETH4
-	eth_getenv_enetaddr("eth4addr", bd->bi_enet4addr);
+	eth_env_get_enetaddr("eth4addr", bd->bi_enet4addr);
 #endif
 #ifdef CONFIG_HAS_ETH5
-	eth_getenv_enetaddr("eth5addr", bd->bi_enet5addr);
+	eth_env_get_enetaddr("eth5addr", bd->bi_enet5addr);
 #endif
 	return 0;
 }
@@ -651,14 +651,14 @@
 	char memsz[32];
 
 # ifdef CONFIG_PRAM
-	pram = getenv_ulong("pram", 10, CONFIG_PRAM);
+	pram = env_get_ulong("pram", 10, CONFIG_PRAM);
 # endif
 # if defined(CONFIG_LOGBUFFER) && !defined(CONFIG_ALT_LB_ADDR)
 	/* Also take the logbuffer into account (pram is in kB) */
 	pram += (LOGBUFF_LEN + LOGBUFF_OVERHEAD) / 1024;
 # endif
 	sprintf(memsz, "%ldk", (long int) ((gd->ram_size / 1024) - pram));
-	setenv("mem", memsz);
+	env_set("mem", memsz);
 
 	return 0;
 }
diff --git a/common/bootm.c b/common/bootm.c
index b2c0912..32b3ea8 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -55,8 +55,8 @@
 
 	lmb_init(&images->lmb);
 
-	mem_start = getenv_bootm_low();
-	mem_size = getenv_bootm_size();
+	mem_start = env_get_bootm_low();
+	mem_size = env_get_bootm_size();
 
 	lmb_add(&images->lmb, (phys_addr_t)mem_start, mem_size);
 
@@ -72,7 +72,7 @@
 		       char * const argv[])
 {
 	memset((void *)&images, 0, sizeof(images));
-	images.verify = getenv_yesno("verify");
+	images.verify = env_get_yesno("verify");
 
 	boot_start_lmb(&images);
 
@@ -524,7 +524,7 @@
 {
 	char *buf;
 	const char *env_val;
-	char *cmdline = getenv("bootargs");
+	char *cmdline = env_get("bootargs");
 	int want_silent;
 
 	/*
@@ -534,7 +534,7 @@
 	 *	yes - we always fixup
 	 *	unset - we rely on the console silent flag
 	 */
-	want_silent = getenv_yesno("silent_linux");
+	want_silent = env_get_yesno("silent_linux");
 	if (want_silent == 0)
 		return;
 	else if (want_silent == -1 && !(gd->flags & GD_FLG_SILENT))
@@ -569,7 +569,7 @@
 		env_val = CONSOLE_ARG;
 	}
 
-	setenv("bootargs", env_val);
+	env_set("bootargs", env_val);
 	debug("after silent fix-up: %s\n", env_val);
 	free(buf);
 }
@@ -645,8 +645,8 @@
 		ret = boot_ramdisk_high(&images->lmb, images->rd_start,
 			rd_len, &images->initrd_start, &images->initrd_end);
 		if (!ret) {
-			setenv_hex("initrd_start", images->initrd_start);
-			setenv_hex("initrd_end", images->initrd_end);
+			env_set_hex("initrd_start", images->initrd_start);
+			env_set_hex("initrd_end", images->initrd_end);
 		}
 	}
 #endif
@@ -691,7 +691,7 @@
 #ifdef CONFIG_TRACE
 	/* Pretend to run the OS, then run a user command */
 	if (!ret && (states & BOOTM_STATE_OS_FAKE_GO)) {
-		char *cmd_list = getenv("fakegocmd");
+		char *cmd_list = env_get("fakegocmd");
 
 		ret = boot_selected_os(argc, argv, BOOTM_STATE_OS_FAKE_GO,
 				images, boot_fn);
diff --git a/common/bootm_os.c b/common/bootm_os.c
index d9e6e93..1feea8a 100644
--- a/common/bootm_os.c
+++ b/common/bootm_os.c
@@ -21,9 +21,9 @@
 	int (*appl)(int, char *const[]);
 
 	/* Don't start if "autostart" is set to "no" */
-	s = getenv("autostart");
+	s = env_get("autostart");
 	if ((s != NULL) && !strcmp(s, "no")) {
-		setenv_hex("filesize", images->os.image_len);
+		env_set_hex("filesize", images->os.image_len);
 		return 0;
 	}
 	appl = (int (*)(int, char * const []))images->ep;
@@ -96,7 +96,7 @@
 		cmdline = malloc(len);
 		copy_args(cmdline, argc, argv, ' ');
 	} else {
-		cmdline = getenv("bootargs");
+		cmdline = env_get("bootargs");
 		if (cmdline == NULL)
 			cmdline = "";
 	}
@@ -227,14 +227,14 @@
 #endif
 
 	/* See README.plan9 */
-	s = getenv("confaddr");
+	s = env_get("confaddr");
 	if (s != NULL) {
 		char *confaddr = (char *)simple_strtoul(s, NULL, 16);
 
 		if (argc > 0) {
 			copy_args(confaddr, argc, argv, '\n');
 		} else {
-			s = getenv("bootargs");
+			s = env_get("bootargs");
 			if (s != NULL)
 				strcpy(confaddr, s);
 		}
@@ -278,7 +278,7 @@
 
 		ret = fdt_add_subnode(*of_flat_tree, 0, "chosen");
 		if ((ret >= 0 || ret == -FDT_ERR_EXISTS)) {
-			bootline = getenv("bootargs");
+			bootline = env_get("bootargs");
 			if (bootline) {
 				ret = fdt_find_and_setprop(*of_flat_tree,
 						"/chosen", "bootargs",
diff --git a/common/bootretry.c b/common/bootretry.c
index 2d82798..b3b8271 100644
--- a/common/bootretry.c
+++ b/common/bootretry.c
@@ -23,7 +23,7 @@
  */
 void bootretry_init_cmd_timeout(void)
 {
-	char *s = getenv("bootretry");
+	char *s = env_get("bootretry");
 
 	if (s != NULL)
 		retry_time = (int)simple_strtol(s, NULL, 10);
diff --git a/common/cli.c b/common/cli.c
index a433ef2..57874d8 100644
--- a/common/cli.c
+++ b/common/cli.c
@@ -129,7 +129,7 @@
 	for (i = 1; i < argc; ++i) {
 		char *arg;
 
-		arg = getenv(argv[i]);
+		arg = env_get(argv[i]);
 		if (arg == NULL) {
 			printf("## Error: \"%s\" not defined\n", argv[i]);
 			return 1;
diff --git a/common/cli_hush.c b/common/cli_hush.c
index 00861e2..07c048e 100644
--- a/common/cli_hush.c
+++ b/common/cli_hush.c
@@ -560,7 +560,7 @@
 {
 	char *newdir;
 	if (child->argv[1] == NULL)
-		newdir = getenv("HOME");
+		newdir = env_get("HOME");
 	else
 		newdir = child->argv[1];
 	if (chdir(newdir)) {
@@ -948,7 +948,7 @@
 #ifndef CONFIG_FEATURE_SH_FANCY_PROMPT
 	PS1 = NULL;
 #else
-	PS1 = getenv("PS1");
+	PS1 = env_get("PS1");
 	if(PS1==0)
 		PS1 = "\\w \\$ ";
 #endif
@@ -987,9 +987,9 @@
 
 #ifdef CONFIG_CMDLINE_PS_SUPPORT
 	if (i->promptmode == 1)
-		ps_prompt = getenv("PS1");
+		ps_prompt = env_get("PS1");
 	else
-		ps_prompt = getenv("PS2");
+		ps_prompt = env_get("PS2");
 	if (ps_prompt)
 		prompt = ps_prompt;
 #endif
@@ -2172,7 +2172,7 @@
 	name=strdup(s);
 
 #ifdef __U_BOOT__
-	if (getenv(name) != NULL) {
+	if (env_get(name) != NULL) {
 		printf ("ERROR: "
 				"There is a global environment variable with the same name.\n");
 		free(name);
@@ -2265,7 +2265,7 @@
 			} else {
 #ifndef __U_BOOT__
 				if(cur->flg_export)
-					unsetenv(cur->name);
+					unenv_set(cur->name);
 #endif
 				free(cur->name);
 				free(cur->value);
@@ -2793,7 +2793,7 @@
 		}
 	}
 
-	p = getenv(src);
+	p = env_get(src);
 	if (!p)
 		p = get_local_var(src);
 
@@ -3157,7 +3157,7 @@
 static void update_ifs_map(void)
 {
 	/* char *ifs and char map[256] are both globals. */
-	ifs = (uchar *)getenv("IFS");
+	ifs = (uchar *)env_get("IFS");
 	if (ifs == NULL) ifs=(uchar *)" \t\n";
 	/* Precompute a list of 'flow through' behavior so it can be treated
 	 * quickly up front.  Computation is necessary because of IFS.
diff --git a/common/cli_simple.c b/common/cli_simple.c
index bb96aae..cb642d2 100644
--- a/common/cli_simple.c
+++ b/common/cli_simple.c
@@ -131,7 +131,7 @@
 				envname[i] = 0;
 
 				/* Get its value */
-				envval = getenv(envname);
+				envval = env_get(envname);
 
 				/* Copy into the line if it exists */
 				if (envval != NULL)
@@ -168,7 +168,7 @@
  * WARNING:
  *
  * We must create a temporary copy of the command since the command we get
- * may be the result from getenv(), which returns a pointer directly to
+ * may be the result from env_get(), which returns a pointer directly to
  * the environment data, which may change magicly when the command we run
  * creates or modifies environment variables (like "bootp" does).
  */
diff --git a/common/console.c b/common/console.c
index ec4af3b..3167921 100644
--- a/common/console.c
+++ b/common/console.c
@@ -666,7 +666,7 @@
 static void console_update_silent(void)
 {
 #ifdef CONFIG_SILENT_CONSOLE
-	if (getenv("silent") != NULL)
+	if (env_get("silent") != NULL)
 		gd->flags |= GD_FLG_SILENT;
 	else
 		gd->flags &= ~GD_FLG_SILENT;
@@ -745,9 +745,9 @@
 
 	/* stdin stdout and stderr are in environment */
 	/* scan for it */
-	stdinname  = getenv("stdin");
-	stdoutname = getenv("stdout");
-	stderrname = getenv("stderr");
+	stdinname  = env_get("stdin");
+	stdoutname = env_get("stdout");
+	stderrname = env_get("stderr");
 
 	if (OVERWRITE_CONSOLE == 0) {	/* if not overwritten by config switch */
 		inputdev  = search_device(DEV_FLAGS_INPUT,  stdinname);
@@ -801,7 +801,7 @@
 #ifdef CONFIG_SYS_CONSOLE_ENV_OVERWRITE
 	/* set the environment variables (will overwrite previous env settings) */
 	for (i = 0; i < 3; i++) {
-		setenv(stdio_names[i], stdio_devices[i]->name);
+		env_set(stdio_names[i], stdio_devices[i]->name);
 	}
 #endif /* CONFIG_SYS_CONSOLE_ENV_OVERWRITE */
 
@@ -836,7 +836,7 @@
 	 * console to serial console in this case or suppress it if
 	 * "silent" mode was requested.
 	 */
-	if (getenv("splashimage") != NULL) {
+	if (env_get("splashimage") != NULL) {
 		if (!(gd->flags & GD_FLG_SILENT))
 			outputdev = search_device (DEV_FLAGS_OUTPUT, "serial");
 	}
@@ -880,7 +880,7 @@
 
 	/* Setting environment variables */
 	for (i = 0; i < 3; i++) {
-		setenv(stdio_names[i], stdio_devices[i]->name);
+		env_set(stdio_names[i], stdio_devices[i]->name);
 	}
 
 	gd->flags |= GD_FLG_DEVINIT;	/* device initialization completed */
diff --git a/common/env_nowhere.c b/common/env_nowhere.c
deleted file mode 100644
index bdc1ed5..0000000
--- a/common/env_nowhere.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * (C) Copyright 2000-2010
- * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
- *
- * (C) Copyright 2001 Sysgo Real-Time Solutions, GmbH <www.elinos.com>
- * Andreas Heppel <aheppel@sysgo.de>
-
- * SPDX-License-Identifier:	GPL-2.0+
- */
-
-#include <common.h>
-#include <command.h>
-#include <environment.h>
-#include <linux/stddef.h>
-
-DECLARE_GLOBAL_DATA_PTR;
-
-env_t *env_ptr;
-
-void env_relocate_spec(void)
-{
-}
-
-/*
- * Initialize Environment use
- *
- * We are still running from ROM, so data use is limited
- */
-int env_init(void)
-{
-	gd->env_addr	= (ulong)&default_environment[0];
-	gd->env_valid	= 0;
-
-	return 0;
-}
diff --git a/common/fb_mmc.c b/common/fb_mmc.c
index 2113b6c..5065ad5 100644
--- a/common/fb_mmc.c
+++ b/common/fb_mmc.c
@@ -49,7 +49,7 @@
 		/* check for alias */
 		strcpy(env_alias_name, "fastboot_partition_alias_");
 		strncat(env_alias_name, name, 32);
-		aliased_part_name = getenv(env_alias_name);
+		aliased_part_name = env_get(env_alias_name);
 		if (aliased_part_name != NULL)
 			ret = part_get_info_by_name(dev_desc,
 					aliased_part_name, info);
diff --git a/common/fdt_support.c b/common/fdt_support.c
index 7ccf8b1..916a448 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -197,7 +197,7 @@
 		return err;
 	}
 
-	serial = getenv("serial#");
+	serial = env_get("serial#");
 	if (serial) {
 		err = fdt_setprop(fdt, 0, "serial-number", serial,
 				  strlen(serial) + 1);
@@ -289,7 +289,7 @@
 	if (nodeoffset < 0)
 		return nodeoffset;
 
-	str = getenv("bootargs");
+	str = env_get("bootargs");
 	if (str) {
 		err = fdt_setprop(fdt, nodeoffset, "bootargs", str,
 				  strlen(str) + 1);
@@ -509,7 +509,7 @@
 			} else {
 				continue;
 			}
-			tmp = getenv(mac);
+			tmp = env_get(mac);
 			if (!tmp)
 				continue;
 
diff --git a/common/hash.c b/common/hash.c
index 771d8fa..dcf016d 100644
--- a/common/hash.c
+++ b/common/hash.c
@@ -302,7 +302,7 @@
 			str_ptr += 2;
 		}
 		*str_ptr = '\0';
-		setenv(dest, str_output);
+		env_set(dest, str_output);
 	} else {
 		ulong addr;
 		void *buf;
@@ -362,7 +362,7 @@
 		if (strlen(verify_str) == digits)
 			vsum_str = verify_str;
 		else {
-			vsum_str = getenv(verify_str);
+			vsum_str = env_get(verify_str);
 			if (vsum_str == NULL || strlen(vsum_str) != digits) {
 				printf("Expected %d hex digits in env var\n",
 				       digits);
diff --git a/common/hwconfig.c b/common/hwconfig.c
index 4ae042e..e5186d7 100644
--- a/common/hwconfig.c
+++ b/common/hwconfig.c
@@ -81,7 +81,7 @@
 					"and before environment is ready\n");
 			return NULL;
 		}
-		env_hwconfig = getenv("hwconfig");
+		env_hwconfig = env_get("hwconfig");
 	}
 
 	if (env_hwconfig) {
@@ -243,7 +243,7 @@
 	const char *ret;
 	size_t len;
 
-	setenv("hwconfig", "key1:subkey1=value1,subkey2=value2;key2:value3;;;;"
+	env_set("hwconfig", "key1:subkey1=value1,subkey2=value2;key2:value3;;;;"
 			   "key3;:,:=;key4", 1);
 
 	ret = hwconfig_arg("key1", &len);
@@ -274,7 +274,7 @@
 	assert(hwconfig_arg("key4", &len) == NULL);
 	assert(hwconfig_arg("bogus", &len) == NULL);
 
-	unsetenv("hwconfig");
+	unenv_set("hwconfig");
 
 	assert(hwconfig(NULL) == 0);
 	assert(hwconfig("") == 0);
diff --git a/common/image-android.c b/common/image-android.c
index c668407..e74d0aa 100644
--- a/common/image-android.c
+++ b/common/image-android.c
@@ -72,7 +72,7 @@
 		len += strlen(hdr->cmdline);
 	}
 
-	char *bootargs = getenv("bootargs");
+	char *bootargs = env_get("bootargs");
 	if (bootargs)
 		len += strlen(bootargs);
 
@@ -90,7 +90,7 @@
 	if (*hdr->cmdline)
 		strcat(newbootargs, hdr->cmdline);
 
-	setenv("bootargs", newbootargs);
+	env_set("bootargs", newbootargs);
 
 	if (os_data) {
 		*os_data = (ulong)hdr;
diff --git a/common/image-fdt.c b/common/image-fdt.c
index c6e8832..da4d007 100644
--- a/common/image-fdt.c
+++ b/common/image-fdt.c
@@ -132,7 +132,7 @@
 	of_len = *of_size + CONFIG_SYS_FDT_PAD;
 
 	/* If fdt_high is set use it to select the relocation address */
-	fdt_high = getenv("fdt_high");
+	fdt_high = env_get("fdt_high");
 	if (fdt_high) {
 		void *desired_addr = (void *)simple_strtoul(fdt_high, NULL, 16);
 
@@ -156,8 +156,8 @@
 	} else {
 		of_start =
 		    (void *)(ulong) lmb_alloc_base(lmb, of_len, 0x1000,
-						   getenv_bootm_mapsize()
-						   + getenv_bootm_low());
+						   env_get_bootm_mapsize()
+						   + env_get_bootm_low());
 	}
 
 	if (of_start == NULL) {
diff --git a/common/image.c b/common/image.c
index 0f88984..a058eb8 100644
--- a/common/image.c
+++ b/common/image.c
@@ -465,9 +465,9 @@
 }
 U_BOOT_ENV_CALLBACK(loadaddr, on_loadaddr);
 
-ulong getenv_bootm_low(void)
+ulong env_get_bootm_low(void)
 {
-	char *s = getenv("bootm_low");
+	char *s = env_get("bootm_low");
 	if (s) {
 		ulong tmp = simple_strtoul(s, NULL, 16);
 		return tmp;
@@ -482,11 +482,11 @@
 #endif
 }
 
-phys_size_t getenv_bootm_size(void)
+phys_size_t env_get_bootm_size(void)
 {
 	phys_size_t tmp, size;
 	phys_addr_t start;
-	char *s = getenv("bootm_size");
+	char *s = env_get("bootm_size");
 	if (s) {
 		tmp = (phys_size_t)simple_strtoull(s, NULL, 16);
 		return tmp;
@@ -500,7 +500,7 @@
 	size = gd->bd->bi_memsize;
 #endif
 
-	s = getenv("bootm_low");
+	s = env_get("bootm_low");
 	if (s)
 		tmp = (phys_size_t)simple_strtoull(s, NULL, 16);
 	else
@@ -509,10 +509,10 @@
 	return size - (tmp - start);
 }
 
-phys_size_t getenv_bootm_mapsize(void)
+phys_size_t env_get_bootm_mapsize(void)
 {
 	phys_size_t tmp;
-	char *s = getenv("bootm_mapsize");
+	char *s = env_get("bootm_mapsize");
 	if (s) {
 		tmp = (phys_size_t)simple_strtoull(s, NULL, 16);
 		return tmp;
@@ -521,7 +521,7 @@
 #if defined(CONFIG_SYS_BOOTMAPSZ)
 	return CONFIG_SYS_BOOTMAPSZ;
 #else
-	return getenv_bootm_size();
+	return env_get_bootm_size();
 #endif
 }
 
@@ -1224,7 +1224,8 @@
 	ulong	initrd_high;
 	int	initrd_copy_to_ram = 1;
 
-	if ((s = getenv("initrd_high")) != NULL) {
+	s = env_get("initrd_high");
+	if (s) {
 		/* a value of "no" or a similar string will act like 0,
 		 * turning the "load high" feature off. This is intentional.
 		 */
@@ -1232,7 +1233,7 @@
 		if (initrd_high == ~0)
 			initrd_copy_to_ram = 0;
 	} else {
-		initrd_high = getenv_bootm_mapsize() + getenv_bootm_low();
+		initrd_high = env_get_bootm_mapsize() + env_get_bootm_low();
 	}
 
 
@@ -1505,7 +1506,7 @@
  * @cmd_end: pointer to a ulong variable, will hold cmdline end
  *
  * boot_get_cmdline() allocates space for kernel command line below
- * BOOTMAPSZ + getenv_bootm_low() address. If "bootargs" U-Boot environemnt
+ * BOOTMAPSZ + env_get_bootm_low() address. If "bootargs" U-Boot environemnt
  * variable is present its contents is copied to allocated kernel
  * command line.
  *
@@ -1519,12 +1520,13 @@
 	char *s;
 
 	cmdline = (char *)(ulong)lmb_alloc_base(lmb, CONFIG_SYS_BARGSIZE, 0xf,
-				getenv_bootm_mapsize() + getenv_bootm_low());
+				env_get_bootm_mapsize() + env_get_bootm_low());
 
 	if (cmdline == NULL)
 		return -1;
 
-	if ((s = getenv("bootargs")) == NULL)
+	s = env_get("bootargs");
+	if (!s)
 		s = "";
 
 	strcpy(cmdline, s);
@@ -1545,7 +1547,7 @@
  * @kbd: double pointer to board info data
  *
  * boot_get_kbd() allocates space for kernel copy of board info data below
- * BOOTMAPSZ + getenv_bootm_low() address and kernel board info is initialized
+ * BOOTMAPSZ + env_get_bootm_low() address and kernel board info is initialized
  * with the current u-boot board info data.
  *
  * returns:
@@ -1555,7 +1557,7 @@
 int boot_get_kbd(struct lmb *lmb, bd_t **kbd)
 {
 	*kbd = (bd_t *)(ulong)lmb_alloc_base(lmb, sizeof(bd_t), 0xf,
-				getenv_bootm_mapsize() + getenv_bootm_low());
+				env_get_bootm_mapsize() + env_get_bootm_low());
 	if (*kbd == NULL)
 		return -1;
 
diff --git a/common/lcd.c b/common/lcd.c
index 7e399ce..c3ff959 100644
--- a/common/lcd.c
+++ b/common/lcd.c
@@ -223,7 +223,7 @@
 	/* Paint the logo and retrieve LCD base address */
 	debug("[LCD] Drawing the logo...\n");
 	if (do_splash) {
-		s = getenv("splashimage");
+		s = env_get("splashimage");
 		if (s) {
 			do_splash = 0;
 			addr = simple_strtoul(s, NULL, 16);
diff --git a/common/main.c b/common/main.c
index 2116a9e..6a11598 100644
--- a/common/main.c
+++ b/common/main.c
@@ -25,7 +25,7 @@
 #ifdef CONFIG_PREBOOT
 	char *p;
 
-	p = getenv("preboot");
+	p = env_get("preboot");
 	if (p != NULL) {
 # ifdef CONFIG_AUTOBOOT_KEYED
 		int prev = disable_ctrlc(1);	/* disable Control C checking */
@@ -48,7 +48,7 @@
 	bootstage_mark_name(BOOTSTAGE_ID_MAIN_LOOP, "main_loop");
 
 #ifdef CONFIG_VERSION_VARIABLE
-	setenv("ver", version_string);  /* set version variable */
+	env_set("ver", version_string);  /* set version variable */
 #endif /* CONFIG_VERSION_VARIABLE */
 
 	cli_init();
diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index 5176857..582b685 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -278,8 +278,8 @@
 	  needed in SPL as it has a much simpler task with less
 	  configuration. But some boards use this to support 'Falcon' boot
 	  on EXT2 and FAT, where SPL boots directly into Linux without
-	  starting U-Boot first. Enabling this option will make getenv()
-	  and setenv() available in SPL.
+	  starting U-Boot first. Enabling this option will make env_get()
+	  and env_set() available in SPL.
 
 config SPL_SAVEENV
 	bool "Support save environment"
diff --git a/common/spl/spl_dfu.c b/common/spl/spl_dfu.c
index e8d0ba1..2c97473 100644
--- a/common/spl/spl_dfu.c
+++ b/common/spl/spl_dfu.c
@@ -40,13 +40,13 @@
 
 	/* set default environment */
 	set_default_env(0);
-	str_env = getenv(dfu_alt_info);
+	str_env = env_get(dfu_alt_info);
 	if (!str_env) {
 		error("\"dfu_alt_info\" env variable not defined!\n");
 		return -EINVAL;
 	}
 
-	ret = setenv("dfu_alt_info", str_env);
+	ret = env_set("dfu_alt_info", str_env);
 	if (ret) {
 		error("unable to set env variable \"dfu_alt_info\"!\n");
 		return -EINVAL;
diff --git a/common/spl/spl_ext.c b/common/spl/spl_ext.c
index f17c6b9..559ba0b 100644
--- a/common/spl/spl_ext.c
+++ b/common/spl/spl_ext.c
@@ -89,7 +89,7 @@
 		return -1;
 	}
 #if defined(CONFIG_SPL_ENV_SUPPORT)
-	file = getenv("falcon_args_file");
+	file = env_get("falcon_args_file");
 	if (file) {
 		err = ext4fs_open(file, &filelen);
 		if (err < 0) {
@@ -102,7 +102,7 @@
 			       file, err);
 			goto defaults;
 		}
-		file = getenv("falcon_image_file");
+		file = env_get("falcon_image_file");
 		if (file) {
 			err = spl_load_image_ext(spl_image, block_dev,
 						 partition, file);
diff --git a/common/spl/spl_fat.c b/common/spl/spl_fat.c
index 5e31216..60b85f0 100644
--- a/common/spl/spl_fat.c
+++ b/common/spl/spl_fat.c
@@ -113,7 +113,7 @@
 		return err;
 
 #if defined(CONFIG_SPL_ENV_SUPPORT) && defined(CONFIG_SPL_OS_BOOT)
-	file = getenv("falcon_args_file");
+	file = env_get("falcon_args_file");
 	if (file) {
 		err = file_fat_read(file, (void *)CONFIG_SYS_SPL_ARGS_ADDR, 0);
 		if (err <= 0) {
@@ -121,7 +121,7 @@
 			       file, err);
 			goto defaults;
 		}
-		file = getenv("falcon_image_file");
+		file = env_get("falcon_image_file");
 		if (file) {
 			err = spl_load_image_fat(spl_image, block_dev,
 						 partition, file);
diff --git a/common/spl/spl_net.c b/common/spl/spl_net.c
index 85fe508..8883109 100644
--- a/common/spl/spl_net.c
+++ b/common/spl/spl_net.c
@@ -33,14 +33,14 @@
 
 	env_init();
 	env_relocate();
-	setenv("autoload", "yes");
+	env_set("autoload", "yes");
 	rv = eth_initialize();
 	if (rv == 0) {
 		printf("No Ethernet devices found\n");
 		return -ENODEV;
 	}
 	if (bootdev->boot_device_name)
-		setenv("ethact", bootdev->boot_device_name);
+		env_set("ethact", bootdev->boot_device_name);
 	rv = net_loop(BOOTP);
 	if (rv < 0) {
 		printf("Problem booting with BOOTP\n");
diff --git a/common/splash.c b/common/splash.c
index 89af437..d251b3b 100644
--- a/common/splash.c
+++ b/common/splash.c
@@ -60,7 +60,7 @@
 #ifdef CONFIG_SPLASH_SCREEN_ALIGN
 void splash_get_pos(int *x, int *y)
 {
-	char *s = getenv("splashpos");
+	char *s = env_get("splashpos");
 
 	if (!s)
 		return;
diff --git a/common/splash_source.c b/common/splash_source.c
index 867a798..8c0ac58 100644
--- a/common/splash_source.c
+++ b/common/splash_source.c
@@ -220,7 +220,7 @@
 	loff_t actread;
 	char *splash_file;
 
-	splash_file = getenv("splashfile");
+	splash_file = env_get("splashfile");
 	if (!splash_file)
 		splash_file = SPLASH_SOURCE_DEFAULT_FILE_NAME;
 
@@ -286,7 +286,7 @@
 	if (!locations || size == 0)
 		return NULL;
 
-	env_splashsource = getenv("splashsource");
+	env_splashsource = env_get("splashsource");
 	if (env_splashsource == NULL)
 		return &locations[0];
 
@@ -383,7 +383,7 @@
 	char *env_splashimage_value;
 	u32 bmp_load_addr;
 
-	env_splashimage_value = getenv("splashimage");
+	env_splashimage_value = env_get("splashimage");
 	if (env_splashimage_value == NULL)
 		return -ENOENT;
 
diff --git a/common/update.c b/common/update.c
index 0767fcb..974f465 100644
--- a/common/update.c
+++ b/common/update.c
@@ -59,7 +59,7 @@
 	/* save used globals and env variable */
 	saved_timeout_msecs = tftp_timeout_ms;
 	saved_timeout_count = tftp_timeout_count_max;
-	saved_netretry = strdup(getenv("netretry"));
+	saved_netretry = strdup(env_get("netretry"));
 	saved_bootfile = strdup(net_boot_file_name);
 
 	/* set timeouts for auto-update */
@@ -67,7 +67,7 @@
 	tftp_timeout_count_max = cnt_max;
 
 	/* we don't want to retry the connection if errors occur */
-	setenv("netretry", "no");
+	env_set("netretry", "no");
 
 	/* download the update file */
 	load_addr = addr;
@@ -83,7 +83,7 @@
 	tftp_timeout_ms = saved_timeout_msecs;
 	tftp_timeout_count_max = saved_timeout_count;
 
-	setenv("netretry", saved_netretry);
+	env_set("netretry", saved_netretry);
 	if (saved_netretry != NULL)
 		free(saved_netretry);
 
@@ -254,7 +254,7 @@
 	printf("Auto-update from TFTP: ");
 
 	/* get the file name of the update file */
-	filename = getenv(UPDATE_FILE_ENV);
+	filename = env_get(UPDATE_FILE_ENV);
 	if (filename == NULL) {
 		printf("failed, env. variable '%s' not found\n",
 							UPDATE_FILE_ENV);
@@ -264,7 +264,8 @@
 	printf("trying update file '%s'\n", filename);
 
 	/* get load address of downloaded update file */
-	if ((env_addr = getenv("loadaddr")) != NULL)
+	env_addr = env_get("loadaddr");
+	if (env_addr)
 		addr = simple_strtoul(env_addr, NULL, 16);
 	else
 		addr = CONFIG_UPDATE_LOAD_ADDR;
diff --git a/common/usb_hub.c b/common/usb_hub.c
index 70bc6e2..86a3477 100644
--- a/common/usb_hub.c
+++ b/common/usb_hub.c
@@ -189,7 +189,7 @@
 	 * but allow this time to be increased via env variable as some
 	 * devices break the spec and require longer warm-up times
 	 */
-	env = getenv("usb_pgood_delay");
+	env = env_get("usb_pgood_delay");
 	if (env)
 		pgood_delay = max(pgood_delay,
 			          (unsigned)simple_strtol(env, NULL, 0));
diff --git a/common/usb_kbd.c b/common/usb_kbd.c
index d2d29cc..8cbdba6 100644
--- a/common/usb_kbd.c
+++ b/common/usb_kbd.c
@@ -515,7 +515,7 @@
 	if (error)
 		return error;
 
-	stdinname = getenv("stdin");
+	stdinname = env_get("stdin");
 #if CONFIG_IS_ENABLED(CONSOLE_MUX)
 	error = iomux_doenv(stdin, stdinname);
 	if (error)
@@ -582,7 +582,7 @@
 		if (stdio_deregister_dev(dev, force) != 0)
 			return 1;
 #if CONFIG_IS_ENABLED(CONSOLE_MUX)
-		if (iomux_doenv(stdin, getenv("stdin")) != 0)
+		if (iomux_doenv(stdin, env_get("stdin")) != 0)
 			return 1;
 #endif
 #ifdef CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE
@@ -627,7 +627,7 @@
 		goto err;
 	}
 #if CONFIG_IS_ENABLED(CONSOLE_MUX)
-	if (iomux_doenv(stdin, getenv("stdin"))) {
+	if (iomux_doenv(stdin, env_get("stdin"))) {
 		ret = -ENOLINK;
 		goto err;
 	}
diff --git a/configs/A20-OLinuXino-Lime2-eMMC_defconfig b/configs/A20-OLinuXino-Lime2-eMMC_defconfig
new file mode 100644
index 0000000..1c58c54
--- /dev/null
+++ b/configs/A20-OLinuXino-Lime2-eMMC_defconfig
@@ -0,0 +1,37 @@
+CONFIG_ARM=y
+CONFIG_ARCH_SUNXI=y
+CONFIG_MACH_SUN7I=y
+CONFIG_DRAM_CLK=384
+CONFIG_MMC0_CD_PIN="PH1"
+CONFIG_MMC_SUNXI_SLOT_EXTRA=2
+CONFIG_USB0_VBUS_PIN="PC17"
+CONFIG_USB0_VBUS_DET="PH5"
+CONFIG_I2C1_ENABLE=y
+CONFIG_SATAPWR="PC3"
+CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-olinuxino-lime2-emmc"
+CONFIG_AHCI=y
+# CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
+CONFIG_SPL=y
+CONFIG_SPL_I2C_SUPPORT=y
+# CONFIG_CMD_IMLS is not set
+# CONFIG_CMD_FLASH is not set
+CONFIG_CMD_DFU=y
+CONFIG_CMD_USB_MASS_STORAGE=y
+# CONFIG_CMD_FPGA is not set
+# CONFIG_SPL_DOS_PARTITION is not set
+# CONFIG_SPL_ISO_PARTITION is not set
+# CONFIG_SPL_PARTITION_UUIDS is not set
+CONFIG_DFU_RAM=y
+CONFIG_ETH_DESIGNWARE=y
+CONFIG_RGMII=y
+CONFIG_SUN7I_GMAC=y
+CONFIG_AXP_ALDO3_VOLT=2800
+CONFIG_AXP_ALDO4_VOLT=2800
+CONFIG_SCSI=y
+CONFIG_USB_EHCI_HCD=y
+CONFIG_USB_MUSB_GADGET=y
+CONFIG_USB_GADGET=y
+CONFIG_USB_GADGET_DOWNLOAD=y
+CONFIG_G_DNL_MANUFACTURER="Allwinner Technology"
+CONFIG_G_DNL_VENDOR_NUM=0x1f3a
+CONFIG_G_DNL_PRODUCT_NUM=0x1010
diff --git a/configs/a64-olinuxino_defconfig b/configs/a64-olinuxino_defconfig
new file mode 100644
index 0000000..14f2c3d
--- /dev/null
+++ b/configs/a64-olinuxino_defconfig
@@ -0,0 +1,15 @@
+CONFIG_ARM=y
+CONFIG_ARCH_SUNXI=y
+CONFIG_MACH_SUN50I=y
+CONFIG_RESERVE_ALLWINNER_BOOT0_HEADER=y
+CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-olinuxino"
+# CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
+CONFIG_SPL=y
+# CONFIG_CMD_IMLS is not set
+# CONFIG_CMD_FLASH is not set
+# CONFIG_CMD_FPGA is not set
+# CONFIG_SPL_DOS_PARTITION is not set
+# CONFIG_SPL_ISO_PARTITION is not set
+# CONFIG_SPL_EFI_PARTITION is not set
+CONFIG_SUN8I_EMAC=y
+CONFIG_USB_EHCI_HCD=y
diff --git a/configs/boston32r2_defconfig b/configs/boston32r2_defconfig
index 3129249..48983f5 100644
--- a/configs/boston32r2_defconfig
+++ b/configs/boston32r2_defconfig
@@ -38,3 +38,4 @@
 CONFIG_PCI_XILINX=y
 CONFIG_SYS_NS16550=y
 CONFIG_LZ4=y
+CONFIG_ENV_IS_IN_FLASH=y
diff --git a/configs/boston32r2el_defconfig b/configs/boston32r2el_defconfig
index ee47e2c..0e1cf29 100644
--- a/configs/boston32r2el_defconfig
+++ b/configs/boston32r2el_defconfig
@@ -39,3 +39,4 @@
 CONFIG_PCI_XILINX=y
 CONFIG_SYS_NS16550=y
 CONFIG_LZ4=y
+CONFIG_ENV_IS_IN_FLASH=y
diff --git a/configs/boston64r2_defconfig b/configs/boston64r2_defconfig
index a98fe97..5010a0e 100644
--- a/configs/boston64r2_defconfig
+++ b/configs/boston64r2_defconfig
@@ -39,3 +39,4 @@
 CONFIG_PCI_XILINX=y
 CONFIG_SYS_NS16550=y
 CONFIG_LZ4=y
+CONFIG_ENV_IS_IN_FLASH=y
diff --git a/configs/boston64r2el_defconfig b/configs/boston64r2el_defconfig
index a361447..ae090bf 100644
--- a/configs/boston64r2el_defconfig
+++ b/configs/boston64r2el_defconfig
@@ -40,3 +40,4 @@
 CONFIG_PCI_XILINX=y
 CONFIG_SYS_NS16550=y
 CONFIG_LZ4=y
+CONFIG_ENV_IS_IN_FLASH=y
diff --git a/configs/edison_defconfig b/configs/edison_defconfig
index b55cc78..0aa7a45 100644
--- a/configs/edison_defconfig
+++ b/configs/edison_defconfig
@@ -24,6 +24,7 @@
 CONFIG_CMD_FAT=y
 CONFIG_CMD_FS_GENERIC=y
 CONFIG_OF_EMBED=y
+CONFIG_ENV_IS_IN_MMC=y
 CONFIG_CPU=y
 CONFIG_DFU_MMC=y
 CONFIG_DFU_RAM=y
diff --git a/configs/malta64_defconfig b/configs/malta64_defconfig
index c70c1cc..9a4ef27 100644
--- a/configs/malta64_defconfig
+++ b/configs/malta64_defconfig
@@ -21,3 +21,4 @@
 CONFIG_MTD_NOR_FLASH=y
 CONFIG_PCI=y
 CONFIG_SYS_NS16550=y
+CONFIG_ENV_IS_IN_FLASH=y
diff --git a/configs/malta64el_defconfig b/configs/malta64el_defconfig
index a05d76d..1d076d4 100644
--- a/configs/malta64el_defconfig
+++ b/configs/malta64el_defconfig
@@ -22,3 +22,4 @@
 CONFIG_MTD_NOR_FLASH=y
 CONFIG_PCI=y
 CONFIG_SYS_NS16550=y
+CONFIG_ENV_IS_IN_FLASH=y
diff --git a/configs/malta_defconfig b/configs/malta_defconfig
index f0a0f20..6c7034e 100644
--- a/configs/malta_defconfig
+++ b/configs/malta_defconfig
@@ -20,3 +20,4 @@
 CONFIG_MTD_NOR_FLASH=y
 CONFIG_PCI=y
 CONFIG_SYS_NS16550=y
+CONFIG_ENV_IS_IN_FLASH=y
diff --git a/configs/maltael_defconfig b/configs/maltael_defconfig
index dcbd5d0..c19f925 100644
--- a/configs/maltael_defconfig
+++ b/configs/maltael_defconfig
@@ -21,3 +21,4 @@
 CONFIG_MTD_NOR_FLASH=y
 CONFIG_PCI=y
 CONFIG_SYS_NS16550=y
+CONFIG_ENV_IS_IN_FLASH=y
diff --git a/configs/microblaze-generic_defconfig b/configs/microblaze-generic_defconfig
index 1036abe..953801e 100644
--- a/configs/microblaze-generic_defconfig
+++ b/configs/microblaze-generic_defconfig
@@ -37,6 +37,7 @@
 # CONFIG_CMD_UBIFS is not set
 CONFIG_SPL_OF_CONTROL=y
 CONFIG_OF_EMBED=y
+CONFIG_ENV_IS_IN_FLASH=y
 CONFIG_NETCONSOLE=y
 CONFIG_SPL_DM=y
 CONFIG_MTD_NOR_FLASH=y
diff --git a/configs/nanopi_a64_defconfig b/configs/nanopi_a64_defconfig
new file mode 100644
index 0000000..2f4ed11
--- /dev/null
+++ b/configs/nanopi_a64_defconfig
@@ -0,0 +1,15 @@
+CONFIG_ARM=y
+CONFIG_ARCH_SUNXI=y
+CONFIG_MACH_SUN50I=y
+CONFIG_RESERVE_ALLWINNER_BOOT0_HEADER=y
+CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-nanopi-a64"
+# CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
+CONFIG_SPL=y
+# CONFIG_CMD_IMLS is not set
+# CONFIG_CMD_FLASH is not set
+# CONFIG_CMD_FPGA is not set
+# CONFIG_SPL_DOS_PARTITION is not set
+# CONFIG_SPL_ISO_PARTITION is not set
+# CONFIG_SPL_EFI_PARTITION is not set
+CONFIG_SUN8I_EMAC=y
+CONFIG_USB_EHCI_HCD=y
diff --git a/configs/orangepi_pc2_defconfig b/configs/orangepi_pc2_defconfig
index 5a64ad3..b72514d 100644
--- a/configs/orangepi_pc2_defconfig
+++ b/configs/orangepi_pc2_defconfig
@@ -4,6 +4,7 @@
 CONFIG_MACH_SUN50I_H5=y
 CONFIG_DRAM_CLK=672
 CONFIG_DRAM_ZQ=3881977
+CONFIG_MACPWR="PD6"
 CONFIG_DEFAULT_DEVICE_TREE="sun50i-h5-orangepi-pc2"
 # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
 CONFIG_SPL=y
diff --git a/configs/orangepi_zero_defconfig b/configs/orangepi_zero_defconfig
index c650ce8..16a3929 100644
--- a/configs/orangepi_zero_defconfig
+++ b/configs/orangepi_zero_defconfig
@@ -2,7 +2,7 @@
 CONFIG_ARCH_SUNXI=y
 CONFIG_SPL_SPI_FLASH_SUPPORT=y
 CONFIG_MACH_SUN8I_H3=y
-CONFIG_DRAM_CLK=672
+CONFIG_DRAM_CLK=624
 CONFIG_DRAM_ZQ=3881979
 CONFIG_DRAM_ODT_EN=y
 # CONFIG_VIDEO_DE2 is not set
diff --git a/configs/pfla02_defconfig b/configs/pfla02_defconfig
new file mode 100644
index 0000000..bcd83ed
--- /dev/null
+++ b/configs/pfla02_defconfig
@@ -0,0 +1,55 @@
+CONFIG_ARM=y
+CONFIG_ARCH_MX6=y
+CONFIG_SPL_GPIO_SUPPORT=y
+CONFIG_SPL_LIBCOMMON_SUPPORT=y
+CONFIG_SPL_LIBGENERIC_SUPPORT=y
+CONFIG_TARGET_PFLA02=y
+CONFIG_SPL_MMC_SUPPORT=y
+CONFIG_SPL_SERIAL_SUPPORT=y
+CONFIG_SPL_LIBDISK_SUPPORT=y
+CONFIG_SPL_SPI_FLASH_SUPPORT=y
+CONFIG_SPL_SPI_SUPPORT=y
+CONFIG_SPL_WATCHDOG_SUPPORT=y
+CONFIG_CMD_HDMIDETECT=y
+CONFIG_FIT=y
+CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=arch/arm/mach-imx/spl_sd.cfg,MX6QDL"
+CONFIG_BOOTDELAY=3
+CONFIG_BOARD_EARLY_INIT_F=y
+CONFIG_SPL=y
+CONFIG_SPL_DMA_SUPPORT=y
+CONFIG_SPL_EXT_SUPPORT=y
+CONFIG_SPL_I2C_SUPPORT=y
+CONFIG_SPL_YMODEM_SUPPORT=y
+CONFIG_HUSH_PARSER=y
+CONFIG_CMD_BOOTZ=y
+# CONFIG_CMD_IMLS is not set
+# CONFIG_CMD_FLASH is not set
+CONFIG_CMD_GPIO=y
+CONFIG_CMD_I2C=y
+CONFIG_CMD_MMC=y
+CONFIG_CMD_SF=y
+CONFIG_CMD_DHCP=y
+CONFIG_CMD_MII=y
+CONFIG_CMD_PING=y
+CONFIG_CMD_CACHE=y
+CONFIG_CMD_EXT2=y
+CONFIG_CMD_EXT4=y
+CONFIG_CMD_EXT4_WRITE=y
+CONFIG_CMD_FAT=y
+CONFIG_CMD_FS_GENERIC=y
+CONFIG_CMD_UBI=y
+CONFIG_ISO_PARTITION=y
+CONFIG_EFI_PARTITION=y
+# CONFIG_PARTITION_UUIDS is not set
+# CONFIG_SPL_PARTITION_UUIDS is not set
+CONFIG_DM=y
+CONFIG_MTD=y
+CONFIG_SPI_FLASH=y
+CONFIG_SPI_FLASH_STMICRO=y
+CONFIG_PHYLIB=y
+CONFIG_PHY_MICREL=y
+CONFIG_PHY_MICREL_KSZ90X1=y
+CONFIG_NETDEVICES=y
+CONFIG_FEC_MXC=y
+CONFIG_DM_THERMAL=y
+CONFIG_OF_LIBFDT=y
diff --git a/configs/qemu_mips64_defconfig b/configs/qemu_mips64_defconfig
index 6835cf1..4262934 100644
--- a/configs/qemu_mips64_defconfig
+++ b/configs/qemu_mips64_defconfig
@@ -16,3 +16,4 @@
 CONFIG_MTD_NOR_FLASH=y
 CONFIG_SYS_NS16550=y
 CONFIG_LZMA=y
+CONFIG_ENV_IS_IN_FLASH=y
diff --git a/configs/qemu_mips64el_defconfig b/configs/qemu_mips64el_defconfig
index 60bd616..6027835 100644
--- a/configs/qemu_mips64el_defconfig
+++ b/configs/qemu_mips64el_defconfig
@@ -17,3 +17,4 @@
 CONFIG_MTD_NOR_FLASH=y
 CONFIG_SYS_NS16550=y
 CONFIG_LZMA=y
+CONFIG_ENV_IS_IN_FLASH=y
diff --git a/configs/qemu_mips_defconfig b/configs/qemu_mips_defconfig
index c6f08b4..cedb906 100644
--- a/configs/qemu_mips_defconfig
+++ b/configs/qemu_mips_defconfig
@@ -14,3 +14,4 @@
 CONFIG_MTD_NOR_FLASH=y
 CONFIG_SYS_NS16550=y
 CONFIG_LZMA=y
+CONFIG_ENV_IS_IN_FLASH=y
diff --git a/configs/qemu_mipsel_defconfig b/configs/qemu_mipsel_defconfig
index b8c2069..5bb84da 100644
--- a/configs/qemu_mipsel_defconfig
+++ b/configs/qemu_mipsel_defconfig
@@ -15,3 +15,4 @@
 CONFIG_MTD_NOR_FLASH=y
 CONFIG_SYS_NS16550=y
 CONFIG_LZMA=y
+CONFIG_ENV_IS_IN_FLASH=y
diff --git a/configs/r8a7795_ulcb_defconfig b/configs/r8a7795_ulcb_defconfig
index 6e967f5..8b6b03b 100644
--- a/configs/r8a7795_ulcb_defconfig
+++ b/configs/r8a7795_ulcb_defconfig
@@ -17,6 +17,7 @@
 CONFIG_CMD_MII=y
 CONFIG_CMD_PING=y
 CONFIG_OF_CONTROL=y
+CONFIG_ENV_IS_IN_MMC=y
 CONFIG_CLK=y
 CONFIG_CLK_RENESAS=y
 CONFIG_SH_SDHI=y
diff --git a/configs/r8a7796_ulcb_defconfig b/configs/r8a7796_ulcb_defconfig
index 62ec2a5..bc995de 100644
--- a/configs/r8a7796_ulcb_defconfig
+++ b/configs/r8a7796_ulcb_defconfig
@@ -18,6 +18,7 @@
 CONFIG_CMD_MII=y
 CONFIG_CMD_PING=y
 CONFIG_OF_CONTROL=y
+CONFIG_ENV_IS_IN_MMC=y
 CONFIG_CLK=y
 CONFIG_CLK_RENESAS=y
 CONFIG_SH_SDHI=y
diff --git a/disk/part.c b/disk/part.c
index d76aa90..c67fdac 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -455,7 +455,7 @@
 	/* If no dev_part_str, use bootdevice environment variable */
 	if (!dev_part_str || !strlen(dev_part_str) ||
 	    !strcmp(dev_part_str, "-"))
-		dev_part_str = getenv("bootdevice");
+		dev_part_str = env_get("bootdevice");
 
 	/* If still no dev_part_str, it's an error */
 	if (!dev_part_str) {
diff --git a/disk/part_amiga.c b/disk/part_amiga.c
index 25fe56c..f8dae00 100644
--- a/disk/part_amiga.c
+++ b/disk/part_amiga.c
@@ -132,7 +132,7 @@
     int limit;
     char *s;
 
-    s = getenv("amiga_scanlimit");
+    s = env_get("amiga_scanlimit");
     if (s)
 	limit = simple_strtoul(s, NULL, 10);
     else
@@ -172,7 +172,7 @@
     int limit;
     char *s;
 
-    s = getenv("amiga_scanlimit");
+    s = env_get("amiga_scanlimit");
     if (s)
 	limit = simple_strtoul(s, NULL, 10);
     else
diff --git a/doc/README.enetaddr b/doc/README.enetaddr
index 50e4899..f926485 100644
--- a/doc/README.enetaddr
+++ b/doc/README.enetaddr
@@ -84,7 +84,7 @@
 eth_parse_enetaddr(addr, enetaddr);
 /* enetaddr now equals { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 } */
 
-	* int eth_getenv_enetaddr(char *name, uchar *enetaddr);
+	* int eth_env_get_enetaddr(char *name, uchar *enetaddr);
 
 Look up an environment variable and convert the stored address.  If the address
 is valid, then the function returns 1.  Otherwise, the function returns 0.  In
@@ -92,18 +92,18 @@
 then it is set to all zeros.  The common function is_valid_ethaddr() is used
 to determine address validity.
 uchar enetaddr[6];
-if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
+if (!eth_env_get_enetaddr("ethaddr", enetaddr)) {
 	/* "ethaddr" is not set in the environment */
 	... try and setup "ethaddr" in the env ...
 }
 /* enetaddr is now set to the value stored in the ethaddr env var */
 
-	* int eth_setenv_enetaddr(char *name, const uchar *enetaddr);
+	* int eth_env_set_enetaddr(char *name, const uchar *enetaddr);
 
 Store the MAC address into the named environment variable.  The return value is
-the same as the setenv() function.
+the same as the env_set() function.
 uchar enetaddr[6] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 };
-eth_setenv_enetaddr("ethaddr", enetaddr);
+eth_env_set_enetaddr("ethaddr", enetaddr);
 /* the "ethaddr" env var should now be set to "00:11:22:33:44:55" */
 
 	* the %pM format modifier
diff --git a/drivers/bootcount/bootcount_env.c b/drivers/bootcount/bootcount_env.c
index 2d6e8db..c3618d3 100644
--- a/drivers/bootcount/bootcount_env.c
+++ b/drivers/bootcount/bootcount_env.c
@@ -6,24 +6,25 @@
  */
 
 #include <common.h>
+#include <environment.h>
 
 void bootcount_store(ulong a)
 {
-	int upgrade_available = getenv_ulong("upgrade_available", 10, 0);
+	int upgrade_available = env_get_ulong("upgrade_available", 10, 0);
 
 	if (upgrade_available) {
-		setenv_ulong("bootcount", a);
-		saveenv();
+		env_set_ulong("bootcount", a);
+		env_save();
 	}
 }
 
 ulong bootcount_load(void)
 {
-	int upgrade_available = getenv_ulong("upgrade_available", 10, 0);
+	int upgrade_available = env_get_ulong("upgrade_available", 10, 0);
 	ulong val = 0;
 
 	if (upgrade_available)
-		val = getenv_ulong("bootcount", 10, 0);
+		val = env_get_ulong("bootcount", 10, 0);
 
 	return val;
 }
diff --git a/drivers/ddr/fsl/fsl_ddr_gen4.c b/drivers/ddr/fsl/fsl_ddr_gen4.c
index 3349fc5..058c9b9 100644
--- a/drivers/ddr/fsl/fsl_ddr_gen4.c
+++ b/drivers/ddr/fsl/fsl_ddr_gen4.c
@@ -469,7 +469,7 @@
 #define CTLR_INTLV_MASK	0x20000000
 	/* Perform build-in test on memory. Three-way interleaving is not yet
 	 * supported by this code. */
-	if (getenv_f("ddr_bist", buffer, CONFIG_SYS_CBSIZE) >= 0) {
+	if (env_get_f("ddr_bist", buffer, CONFIG_SYS_CBSIZE) >= 0) {
 		puts("Running BIST test. This will take a while...");
 		cs0_config = ddr_in32(&ddr->cs0_config);
 		cs0_bnds = ddr_in32(&ddr->cs0_bnds);
diff --git a/drivers/ddr/fsl/interactive.c b/drivers/ddr/fsl/interactive.c
index 653bbab..c99bd2f 100644
--- a/drivers/ddr/fsl/interactive.c
+++ b/drivers/ddr/fsl/interactive.c
@@ -1861,7 +1861,7 @@
 {
 	char buffer[CONFIG_SYS_CBSIZE];
 
-	if (getenv_f("ddr_interactive", buffer, CONFIG_SYS_CBSIZE) >= 0)
+	if (env_get_f("ddr_interactive", buffer, CONFIG_SYS_CBSIZE) >= 0)
 		return 1;
 
 	return 0;
@@ -1891,11 +1891,11 @@
 	};
 
 	if (var_is_set) {
-		if (getenv_f("ddr_interactive", buffer2, CONFIG_SYS_CBSIZE) > 0) {
+		if (env_get_f("ddr_interactive", buffer2,
+			      CONFIG_SYS_CBSIZE) > 0)
 			p = buffer2;
-		} else {
+		else
 			var_is_set = 0;
-		}
 	}
 
 	/*
diff --git a/drivers/ddr/fsl/options.c b/drivers/ddr/fsl/options.c
index 20edd2d..a7eaed1 100644
--- a/drivers/ddr/fsl/options.c
+++ b/drivers/ddr/fsl/options.c
@@ -18,7 +18,7 @@
  * Use our own stack based buffer before relocation to allow accessing longer
  * hwconfig strings that might be in the environment before we've relocated.
  * This is pretty fragile on both the use of stack and if the buffer is big
- * enough. However we will get a warning from getenv_f for the later.
+ * enough. However we will get a warning from env_get_f() for the latter.
  */
 
 /* Board-specific functions defined in each board's ddr.c */
@@ -755,7 +755,7 @@
 	 * Extract hwconfig from environment since we have not properly setup
 	 * the environment but need it for ddr config params
 	 */
-	if (getenv_f("hwconfig", buffer, sizeof(buffer)) > 0)
+	if (env_get_f("hwconfig", buffer, sizeof(buffer)) > 0)
 		buf = buffer;
 
 #if defined(CONFIG_SYS_FSL_DDR3) || \
@@ -1399,7 +1399,7 @@
 	 * Extract hwconfig from environment since we have not properly setup
 	 * the environment but need it for ddr config params
 	 */
-	if (getenv_f("hwconfig", buffer, sizeof(buffer)) > 0)
+	if (env_get_f("hwconfig", buffer, sizeof(buffer)) > 0)
 		buf = buffer;
 
 	/* if hwconfig is not enabled, or "sdram" is not defined, use spd */
diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
index f6281f4..ff732ac 100644
--- a/drivers/dfu/dfu.c
+++ b/drivers/dfu/dfu.c
@@ -62,7 +62,7 @@
 #ifdef CONFIG_SET_DFU_ALT_INFO
 	set_dfu_alt_info(interface, devstr);
 #endif
-	str_env = getenv("dfu_alt_info");
+	str_env = env_get("dfu_alt_info");
 	if (!str_env) {
 		error("\"dfu_alt_info\" env variable not defined!\n");
 		return -EINVAL;
@@ -101,7 +101,7 @@
 	if (dfu_buf != NULL)
 		return dfu_buf;
 
-	s = getenv("dfu_bufsiz");
+	s = env_get("dfu_bufsiz");
 	if (s)
 		dfu_buf_size = (unsigned long)simple_strtol(s, NULL, 0);
 
@@ -123,7 +123,7 @@
 {
 	char *s;
 
-	s = getenv("dfu_hash_algo");
+	s = env_get("dfu_hash_algo");
 	if (!s)
 		return NULL;
 
diff --git a/drivers/dfu/dfu_mmc.c b/drivers/dfu/dfu_mmc.c
index bb23e7f..39e10b1 100644
--- a/drivers/dfu/dfu_mmc.c
+++ b/drivers/dfu/dfu_mmc.c
@@ -161,7 +161,7 @@
 	}
 
 	if (op != DFU_OP_WRITE) {
-		str_env = getenv("filesize");
+		str_env = env_get("filesize");
 		if (str_env == NULL) {
 			puts("dfu: Wrong file size!\n");
 			return -1;
diff --git a/drivers/input/i8042.c b/drivers/input/i8042.c
index 0fd25b1..18476e9 100644
--- a/drivers/input/i8042.c
+++ b/drivers/input/i8042.c
@@ -274,7 +274,7 @@
 
 	/* Init keyboard device (default US layout) */
 	keymap = KBD_US;
-	penv = getenv("keymap");
+	penv = env_get("keymap");
 	if (penv != NULL) {
 		if (strncmp(penv, "de", 3) == 0)
 			keymap = KBD_GER;
diff --git a/drivers/input/input.c b/drivers/input/input.c
index 011667f..26da3a9 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -652,7 +652,7 @@
 	error = stdio_register(dev);
 
 	/* check if this is the standard input device */
-	if (!error && strcmp(getenv("stdin"), dev->name) == 0) {
+	if (!error && strcmp(env_get("stdin"), dev->name) == 0) {
 		/* reassign the console */
 		if (OVERWRITE_CONSOLE ||
 				console_assign(stdin, dev->name))
diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index 048a517..42bc2ef 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -2353,7 +2353,7 @@
 #ifdef CONFIG_SYS_FLASH_PROTECTION
 	/* read environment from EEPROM */
 	char s[64];
-	getenv_f("unlock", s, sizeof(s));
+	env_get_f("unlock", s, sizeof(s));
 #endif
 
 #ifdef CONFIG_CFI_FLASH /* for driver model */
diff --git a/drivers/mtd/dataflash.c b/drivers/mtd/dataflash.c
index 2d2c318..e961f51 100644
--- a/drivers/mtd/dataflash.c
+++ b/drivers/mtd/dataflash.c
@@ -155,7 +155,7 @@
 	return found[0];
 }
 
-void AT91F_DataflashSetEnv (void)
+void AT91F_Dataflashenv_set(void)
 {
 	int i, j;
 	int part;
@@ -169,8 +169,9 @@
 			/* Set the environment according to the label...*/
 			if((env & FLAG_SETENV) == FLAG_SETENV) {
 				start = dataflash_info[i].Device.area_list[j].start;
-				sprintf((char*) s,"%lX",start);
-				setenv((char*) area_list[part].label,(char*) s);
+				sprintf((char *)s, "%lX", start);
+				env_set((char *)area_list[part].label,
+					(char *)s);
 			}
 			part++;
 		}
diff --git a/drivers/mtd/spi/sf_dataflash.c b/drivers/mtd/spi/sf_dataflash.c
index bcddfa0..e5c0e12 100644
--- a/drivers/mtd/spi/sf_dataflash.c
+++ b/drivers/mtd/spi/sf_dataflash.c
@@ -134,11 +134,17 @@
 	debug("%s: erase addr=0x%x len 0x%x\n", dev->name, offset, len);
 
 	div_u64_rem(len, spi_flash->page_size, &rem);
-	if (rem)
+	if (rem) {
+		printf("%s: len(0x%x) isn't the multiple of page size(0x%x)\n",
+		       dev->name, len, spi_flash->page_size);
 		return -EINVAL;
+	}
 	div_u64_rem(offset, spi_flash->page_size, &rem);
-	if (rem)
+	if (rem) {
+		printf("%s: offset(0x%x) isn't the multiple of page size(0x%x)\n",
+		       dev->name, offset, spi_flash->page_size);
 		return -EINVAL;
+	}
 
 	status = spi_claim_bus(spi);
 	if (status) {
diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c
index 0034a28..34f6888 100644
--- a/drivers/mtd/spi/spi_flash.c
+++ b/drivers/mtd/spi/spi_flash.c
@@ -947,11 +947,25 @@
 	if (IS_ERR_OR_NULL(info))
 		return -ENOENT;
 
-	/* Flash powers up read-only, so clear BP# bits */
+	/*
+	 * Flash powers up read-only, so clear BP# bits.
+	 *
+	 * Note on some flash (like Macronix), QE (quad enable) bit is in the
+	 * same status register as BP# bits, and we need preserve its original
+	 * value during a reboot cycle as this is required by some platforms
+	 * (like Intel ICH SPI controller working under descriptor mode).
+	 */
 	if (JEDEC_MFR(info) == SPI_FLASH_CFI_MFR_ATMEL ||
-	    JEDEC_MFR(info) == SPI_FLASH_CFI_MFR_MACRONIX ||
-	    JEDEC_MFR(info) == SPI_FLASH_CFI_MFR_SST)
-		write_sr(flash, 0);
+	   (JEDEC_MFR(info) == SPI_FLASH_CFI_MFR_SST) ||
+	   (JEDEC_MFR(info) == SPI_FLASH_CFI_MFR_MACRONIX)) {
+		u8 sr = 0;
+
+		if (JEDEC_MFR(info) == SPI_FLASH_CFI_MFR_MACRONIX) {
+			read_sr(flash, &sr);
+			sr &= STATUS_QEB_MXIC;
+		}
+		write_sr(flash, sr);
+	}
 
 	flash->name = info->name;
 	flash->memory_map = spi->memory_map;
diff --git a/drivers/mtd/spi/spi_flash_ids.c b/drivers/mtd/spi/spi_flash_ids.c
index edca94e..c4ccf48 100644
--- a/drivers/mtd/spi/spi_flash_ids.c
+++ b/drivers/mtd/spi/spi_flash_ids.c
@@ -81,6 +81,7 @@
 	{"mx25l12805",	   INFO(0xc22018, 0x0, 64 * 1024,   256, RD_FULL | WR_QPP) },
 	{"mx25l25635f",	   INFO(0xc22019, 0x0, 64 * 1024,   512, RD_FULL | WR_QPP) },
 	{"mx25l51235f",	   INFO(0xc2201a, 0x0, 64 * 1024,  1024, RD_FULL | WR_QPP) },
+	{"mx25u6435f",	   INFO(0xc22537, 0x0, 64 * 1024,   128, RD_FULL | WR_QPP) },
 	{"mx25l12855e",	   INFO(0xc22618, 0x0, 64 * 1024,   256, RD_FULL | WR_QPP) },
 	{"mx66u51235f",    INFO(0xc2253a, 0x0, 64 * 1024,  1024, RD_FULL | WR_QPP) },
 	{"mx66l1g45g",     INFO(0xc2201b, 0x0, 64 * 1024,  2048, RD_FULL | WR_QPP) },
diff --git a/drivers/net/dc2114x.c b/drivers/net/dc2114x.c
index 8245cf5..f38f36b 100644
--- a/drivers/net/dc2114x.c
+++ b/drivers/net/dc2114x.c
@@ -750,7 +750,7 @@
 	uchar enetaddr[6];
 
 	/* Ethernet Addr... */
-	if (!eth_getenv_enetaddr("ethaddr", enetaddr))
+	if (!eth_env_get_enetaddr("ethaddr", enetaddr))
 		return;
 	eeprom[0x0a] = (enetaddr[1] << 8) | enetaddr[0];
 	eeprom[0x0b] = (enetaddr[3] << 8) | enetaddr[2];
diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index 40be520..f16b299 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -985,9 +985,18 @@
 	free(fec->tbd_base);
 }
 
+#ifdef CONFIG_DM_ETH
+struct mii_dev *fec_get_miibus(struct udevice *dev, int dev_id)
+#else
 struct mii_dev *fec_get_miibus(uint32_t base_addr, int dev_id)
+#endif
 {
+#ifdef CONFIG_DM_ETH
+	struct fec_priv *priv = dev_get_priv(dev);
+	struct ethernet_regs *eth = priv->eth;
+#else
 	struct ethernet_regs *eth = (struct ethernet_regs *)base_addr;
+#endif
 	struct mii_dev *bus;
 	int ret;
 
@@ -1096,8 +1105,8 @@
 			sprintf(mac, "eth%daddr", fec->dev_id);
 		else
 			strcpy(mac, "ethaddr");
-		if (!getenv(mac))
-			eth_setenv_enetaddr(mac, ethaddr);
+		if (!env_get(mac))
+			eth_env_set_enetaddr(mac, ethaddr);
 	}
 	return ret;
 err4:
diff --git a/drivers/net/fm/b4860.c b/drivers/net/fm/b4860.c
index 5aeeb87..3245bee 100644
--- a/drivers/net/fm/b4860.c
+++ b/drivers/net/fm/b4860.c
@@ -97,7 +97,7 @@
 			 * Extract hwconfig from environment since environment
 			 * is not setup yet
 			 */
-			getenv_f("hwconfig", buffer, sizeof(buffer));
+			env_get_f("hwconfig", buffer, sizeof(buffer));
 			buf = buffer;
 
 			/* check if XFI interface enable in hwconfig for 10g */
diff --git a/drivers/net/fm/fdt.c b/drivers/net/fm/fdt.c
index 9918d80..5920fec 100644
--- a/drivers/net/fm/fdt.c
+++ b/drivers/net/fm/fdt.c
@@ -36,7 +36,7 @@
 		return;
 
 	/* If the environment variable is not set, then exit silently */
-	p = getenv("fman_ucode");
+	p = env_get("fman_ucode");
 	if (!p)
 		return;
 
diff --git a/drivers/net/fm/fm.c b/drivers/net/fm/fm.c
index 9fe34ad..451dfde 100644
--- a/drivers/net/fm/fm.c
+++ b/drivers/net/fm/fm.c
@@ -418,7 +418,7 @@
 	rc = fman_upload_firmware(index, &reg->fm_imem, addr);
 	if (rc)
 		return rc;
-	setenv_addr("fman_ucode", addr);
+	env_set_addr("fman_ucode", addr);
 
 	fm_init_muram(index, &reg->muram);
 	fm_init_qmi(&reg->fm_qmi_common);
diff --git a/drivers/net/fsl-mc/mc.c b/drivers/net/fsl-mc/mc.c
index 3a30c03..bdb6792 100644
--- a/drivers/net/fsl-mc/mc.c
+++ b/drivers/net/fsl-mc/mc.c
@@ -190,8 +190,8 @@
 	/* MAC address property present */
 	if (fdt_get_property(blob, nodeoffset, propname, NULL)) {
 		/* u-boot MAC addr randomly assigned - leave the present one */
-		if (!eth_getenv_enetaddr_by_index("eth", eth_dev->index,
-						  env_enetaddr))
+		if (!eth_env_get_enetaddr_by_index("eth", eth_dev->index,
+						   env_enetaddr))
 			return err;
 	} else {
 		size = MC_DT_INCREASE_SIZE + strlen(propname) + len;
@@ -530,7 +530,7 @@
 {
 	unsigned long timeout_ms = CONFIG_SYS_LS_MC_BOOT_TIMEOUT_MS;
 
-	char *timeout_ms_env_var = getenv(MC_BOOT_TIMEOUT_ENV_VAR);
+	char *timeout_ms_env_var = env_get(MC_BOOT_TIMEOUT_ENV_VAR);
 
 	if (timeout_ms_env_var) {
 		timeout_ms = simple_strtoul(timeout_ms_env_var, NULL, 10);
@@ -815,7 +815,7 @@
 {
 	unsigned long dram_block_size = CONFIG_SYS_LS_MC_DRAM_BLOCK_MIN_SIZE;
 
-	char *dram_block_size_env_var = getenv(MC_MEM_SIZE_ENV_VAR);
+	char *dram_block_size_env_var = env_get(MC_MEM_SIZE_ENV_VAR);
 
 	if (dram_block_size_env_var) {
 		dram_block_size = simple_strtoul(dram_block_size_env_var, NULL,
@@ -1518,7 +1518,7 @@
 	 * address info properly. Without MAC addresses, the MC code
 	 * can not properly initialize the DPC.
 	 */
-	mc_boot_env_var = getenv(MC_BOOT_ENV_VAR);
+	mc_boot_env_var = env_get(MC_BOOT_ENV_VAR);
 	if (mc_boot_env_var)
 		run_command_list(mc_boot_env_var, -1, 0);
 #endif /* CONFIG_FSL_MC_ENET */
diff --git a/drivers/net/fsl_mcdmafec.c b/drivers/net/fsl_mcdmafec.c
index 628b420..26c714c 100644
--- a/drivers/net/fsl_mcdmafec.c
+++ b/drivers/net/fsl_mcdmafec.c
@@ -383,9 +383,9 @@
 
 	/* Set station address   */
 	if ((u32) fecp == CONFIG_SYS_FEC0_IOBASE)
-		eth_getenv_enetaddr("ethaddr", enetaddr);
+		eth_env_get_enetaddr("ethaddr", enetaddr);
 	else
-		eth_getenv_enetaddr("eth1addr", enetaddr);
+		eth_env_get_enetaddr("eth1addr", enetaddr);
 	fec_set_hwaddr(fecp, enetaddr);
 
 	/* Set Opcode/Pause Duration Register */
diff --git a/drivers/net/ftgmac100.c b/drivers/net/ftgmac100.c
index 5ccc4be..d0939e9 100644
--- a/drivers/net/ftgmac100.c
+++ b/drivers/net/ftgmac100.c
@@ -346,7 +346,7 @@
 
 static void ftgmac100_set_mac_from_env(struct eth_device *dev)
 {
-	eth_getenv_enetaddr("ethaddr", dev->enetaddr);
+	eth_env_get_enetaddr("ethaddr", dev->enetaddr);
 
 	ftgmac100_set_mac(dev, dev->enetaddr);
 }
diff --git a/drivers/net/ftmac100.c b/drivers/net/ftmac100.c
index cd24a21..f231e6b 100644
--- a/drivers/net/ftmac100.c
+++ b/drivers/net/ftmac100.c
@@ -355,7 +355,7 @@
 int ftmac100_read_rom_hwaddr(struct udevice *dev)
 {
 	struct eth_pdata *pdata = dev_get_platdata(dev);
-	eth_getenv_enetaddr("ethaddr", pdata->enetaddr);
+	eth_env_get_enetaddr("ethaddr", pdata->enetaddr);
 	return 0;
 }
 
diff --git a/drivers/net/lan91c96.c b/drivers/net/lan91c96.c
index 3526876..a9fc74b 100644
--- a/drivers/net/lan91c96.c
+++ b/drivers/net/lan91c96.c
@@ -704,13 +704,13 @@
 {
 	uchar v_mac[6];
 
-	if (!eth_getenv_enetaddr("ethaddr", v_mac)) {
+	if (!eth_env_get_enetaddr("ethaddr", v_mac)) {
 		/* get ROM mac value if any */
 		if (!get_rom_mac(dev, v_mac)) {
 			printf("\n*** ERROR: ethaddr is NOT set !!\n");
 			return -1;
 		}
-		eth_setenv_enetaddr("ethaddr", v_mac);
+		eth_env_set_enetaddr("ethaddr", v_mac);
 	}
 
 	smc_set_mac_addr(v_mac); /* use old function to update smc default */
diff --git a/drivers/net/mcffec.c b/drivers/net/mcffec.c
index e1b06b2..39a6747 100644
--- a/drivers/net/mcffec.c
+++ b/drivers/net/mcffec.c
@@ -428,25 +428,25 @@
 	if ((u32) fecp == CONFIG_SYS_FEC0_IOBASE) {
 #ifdef CONFIG_SYS_FEC1_IOBASE
 		volatile fec_t *fecp1 = (fec_t *) (CONFIG_SYS_FEC1_IOBASE);
-		eth_getenv_enetaddr("eth1addr", ea);
+		eth_env_get_enetaddr("eth1addr", ea);
 		fecp1->palr =
 		    (ea[0] << 24) | (ea[1] << 16) | (ea[2] << 8) | (ea[3]);
 		fecp1->paur = (ea[4] << 24) | (ea[5] << 16);
 #endif
-		eth_getenv_enetaddr("ethaddr", ea);
+		eth_env_get_enetaddr("ethaddr", ea);
 		fecp->palr =
 		    (ea[0] << 24) | (ea[1] << 16) | (ea[2] << 8) | (ea[3]);
 		fecp->paur = (ea[4] << 24) | (ea[5] << 16);
 	} else {
 #ifdef CONFIG_SYS_FEC0_IOBASE
 		volatile fec_t *fecp0 = (fec_t *) (CONFIG_SYS_FEC0_IOBASE);
-		eth_getenv_enetaddr("ethaddr", ea);
+		eth_env_get_enetaddr("ethaddr", ea);
 		fecp0->palr =
 		    (ea[0] << 24) | (ea[1] << 16) | (ea[2] << 8) | (ea[3]);
 		fecp0->paur = (ea[4] << 24) | (ea[5] << 16);
 #endif
 #ifdef CONFIG_SYS_FEC1_IOBASE
-		eth_getenv_enetaddr("eth1addr", ea);
+		eth_env_get_enetaddr("eth1addr", ea);
 		fecp->palr =
 		    (ea[0] << 24) | (ea[1] << 16) | (ea[2] << 8) | (ea[3]);
 		fecp->paur = (ea[4] << 24) | (ea[5] << 16);
diff --git a/drivers/net/ne2000_base.c b/drivers/net/ne2000_base.c
index 377d87f..fb088e0 100644
--- a/drivers/net/ne2000_base.c
+++ b/drivers/net/ne2000_base.c
@@ -715,15 +715,15 @@
 	 * to the MAC address value in the environment, so we do not read
 	 * it from the prom or eeprom if it is specified in the environment.
 	 */
-	if (!eth_getenv_enetaddr("ethaddr", dev->enetaddr)) {
+	if (!eth_env_get_enetaddr("ethaddr", dev->enetaddr)) {
 		/* If the MAC address is not in the environment, get it: */
 		if (!get_prom(dev->enetaddr, nic.base)) /* get MAC from prom */
 			dp83902a_init(dev->enetaddr);   /* fallback: seeprom */
 		/* And write it into the environment otherwise eth_write_hwaddr
-		 * returns -1 due to eth_getenv_enetaddr_by_index() failing,
+		 * returns -1 due to eth_env_get_enetaddr_by_index() failing,
 		 * and this causes "Warning: failed to set MAC address", and
 		 * cmd_bdinfo has no ethaddr value which it can show: */
-		eth_setenv_enetaddr("ethaddr", dev->enetaddr);
+		eth_env_set_enetaddr("ethaddr", dev->enetaddr);
 	}
 	return 0;
 }
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index 3500047..e9dbedf 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -62,8 +62,8 @@
 
 	/* update only when the environment has changed */
 	if (env_changed_id != env_id) {
-		netmask = getenv_ip("netmask");
-		our_ip = getenv_ip("ipaddr");
+		netmask = env_get_ip("netmask");
+		our_ip = env_get_ip("ipaddr");
 
 		env_changed_id = env_id;
 	}
@@ -82,11 +82,11 @@
 
 	/* update only when the environment has changed */
 	if (env_changed_id != env_id) {
-		if (getenv("ncip")) {
-			nc_ip = getenv_ip("ncip");
+		if (env_get("ncip")) {
+			nc_ip = env_get_ip("ncip");
 			if (!nc_ip.s_addr)
 				return -1;	/* ncip is 0.0.0.0 */
-			p = strchr(getenv("ncip"), ':');
+			p = strchr(env_get("ncip"), ':');
 			if (p != NULL) {
 				nc_out_port = simple_strtoul(p + 1, NULL, 10);
 				nc_in_port = nc_out_port;
@@ -95,10 +95,10 @@
 			nc_ip.s_addr = ~0; /* ncip is not set, so broadcast */
 		}
 
-		p = getenv("ncoutport");
+		p = env_get("ncoutport");
 		if (p != NULL)
 			nc_out_port = simple_strtoul(p, NULL, 10);
-		p = getenv("ncinport");
+		p = env_get("ncinport");
 		if (p != NULL)
 			nc_in_port = simple_strtoul(p, NULL, 10);
 
diff --git a/drivers/net/phy/micrel_ksz90x1.c b/drivers/net/phy/micrel_ksz90x1.c
index 20f8a55..0bb99e6 100644
--- a/drivers/net/phy/micrel_ksz90x1.c
+++ b/drivers/net/phy/micrel_ksz90x1.c
@@ -258,7 +258,7 @@
 	if (ret)
 		return ret;
 
-	if (getenv("disable_giga"))
+	if (env_get("disable_giga"))
 		features &= ~(SUPPORTED_1000baseT_Half |
 		SUPPORTED_1000baseT_Full);
 	/* force master mode for 1000BaseT due to chip errata */
@@ -344,7 +344,7 @@
 		return ret;
 
 	/* add an option to disable the gigabit feature of this PHY */
-	if (getenv("disable_giga")) {
+	if (env_get("disable_giga")) {
 		unsigned features;
 		unsigned bmcr;
 
diff --git a/drivers/net/sandbox-raw.c b/drivers/net/sandbox-raw.c
index f5fa0e8..590ae0c 100644
--- a/drivers/net/sandbox-raw.c
+++ b/drivers/net/sandbox-raw.c
@@ -33,8 +33,8 @@
 
 	if (strcmp(interface, "lo") == 0) {
 		priv->local = 1;
-		setenv("ipaddr", "127.0.0.1");
-		setenv("serverip", "127.0.0.1");
+		env_set("ipaddr", "127.0.0.1");
+		env_set("serverip", "127.0.0.1");
 	}
 	return sandbox_eth_raw_os_start(interface, pdata->enetaddr, priv);
 }
diff --git a/drivers/net/sh_eth.c b/drivers/net/sh_eth.c
index a7c265b..970d730 100644
--- a/drivers/net/sh_eth.c
+++ b/drivers/net/sh_eth.c
@@ -578,7 +578,7 @@
 	if (retval < 0)
 		return retval;
 
-	if (!eth_getenv_enetaddr("ethaddr", dev->enetaddr))
+	if (!eth_env_get_enetaddr("ethaddr", dev->enetaddr))
 		puts("Please set MAC address\n");
 
 	return ret;
diff --git a/drivers/pci/fsl_pci_init.c b/drivers/pci/fsl_pci_init.c
index af20cf0..df76a94 100644
--- a/drivers/pci/fsl_pci_init.c
+++ b/drivers/pci/fsl_pci_init.c
@@ -390,7 +390,7 @@
 
 #ifdef CONFIG_SRIO_PCIE_BOOT_MASTER
 	/* boot from PCIE --master */
-	char *s = getenv("bootmaster");
+	char *s = env_get("bootmaster");
 	char pcie[6];
 	sprintf(pcie, "PCIE%d", pci_info->pci_num);
 
@@ -673,7 +673,7 @@
 #ifdef CONFIG_SRIO_PCIE_BOOT_MASTER
 	} else {
 		/* boot from PCIE --master releases slave's core 0 */
-		char *s = getenv("bootmaster");
+		char *s = env_get("bootmaster");
 		char pcie[6];
 		sprintf(pcie, "PCIE%d", pci_info->pci_num);
 
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 6b36c18..bbc7dab 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -427,7 +427,7 @@
 
 	if (!gd->pcidelay_done) {
 		/* wait "pcidelay" ms (if defined)... */
-		s = getenv("pcidelay");
+		s = env_get("pcidelay");
 		if (s) {
 			int val = simple_strtoul(s, NULL, 10);
 			for (i = 0; i < val; i++)
@@ -459,7 +459,7 @@
 	hose_head = NULL;
 
 	/* allow env to disable pci init/enum */
-	if (getenv("pcidisable") != NULL)
+	if (env_get("pcidisable") != NULL)
 		return;
 
 	/* now call board specific pci_init()... */
diff --git a/drivers/pci/pci_common.c b/drivers/pci/pci_common.c
index 6526de8..faf25d9 100644
--- a/drivers/pci/pci_common.c
+++ b/drivers/pci/pci_common.c
@@ -89,7 +89,7 @@
 		/*
 		 * Only skip configuration if "pciconfighost" is not set
 		 */
-		if (getenv("pciconfighost") == NULL)
+		if (env_get("pciconfighost") == NULL)
 			return 1;
 #else
 		return 1;
diff --git a/drivers/rtc/m41t60.c b/drivers/rtc/m41t60.c
index 95083f0..2ddfd4e 100644
--- a/drivers/rtc/m41t60.c
+++ b/drivers/rtc/m41t60.c
@@ -200,7 +200,7 @@
 void rtc_reset(void)
 {
 	uchar *const data = rtc_validate();
-	char const *const s = getenv("rtccal");
+	char const *const s = env_get("rtccal");
 
 	if (!data)
 		return;
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index f192ca5..1a65a3f 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -682,7 +682,7 @@
 
 	printf("Found %d device(s).\n", scsi_max_devs);
 #ifndef CONFIG_SPL_BUILD
-	setenv_ulong("scsidevs", scsi_max_devs);
+	env_set_ulong("scsidevs", scsi_max_devs);
 #endif
 	return 0;
 }
diff --git a/drivers/serial/usbtty.c b/drivers/serial/usbtty.c
index 29799dc..353109c 100644
--- a/drivers/serial/usbtty.c
+++ b/drivers/serial/usbtty.c
@@ -526,9 +526,9 @@
 	int snlen;
 
 	/* Ger seiral number */
-	if (!(sn = getenv("serial#"))) {
+	sn = env_get("serial#");
+	if (!sn)
 		sn = "000000000000";
-	}
 	snlen = strlen(sn);
 	if (snlen > sizeof(serial_number) - 1) {
 		printf ("Warning: serial number %s is too long (%d > %lu)\n",
@@ -540,10 +540,9 @@
 
 	/* Decide on which type of UDC device to be.
 	 */
-
-	if(!(tt = getenv("usbtty"))) {
+	tt = env_get("usbtty");
+	if (!tt)
 		tt = "generic";
-	}
 	usbtty_init_terminal_type(strcmp(tt,"cdc_acm"));
 
 	/* prepare buffers... */
diff --git a/drivers/usb/gadget/designware_udc.c b/drivers/usb/gadget/designware_udc.c
index 0db7a3b..a25f501 100644
--- a/drivers/usb/gadget/designware_udc.c
+++ b/drivers/usb/gadget/designware_udc.c
@@ -601,7 +601,7 @@
 	if ((ep != 0) && (udc_device->device_state < STATE_ADDRESSED))
 		return;
 
-	tt = getenv("usbtty");
+	tt = env_get("usbtty");
 	if (!tt)
 		tt = "generic";
 
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 4137d76..2cf5c8d 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -2384,12 +2384,12 @@
 	strlcpy(host_addr, CONFIG_USBNET_HOST_ADDR, sizeof(host_addr));
 #endif
 	/* Check if the user overruled the MAC addresses */
-	if (getenv("usbnet_devaddr"))
-		strlcpy(dev_addr, getenv("usbnet_devaddr"),
+	if (env_get("usbnet_devaddr"))
+		strlcpy(dev_addr, env_get("usbnet_devaddr"),
 			sizeof(dev_addr));
 
-	if (getenv("usbnet_hostaddr"))
-		strlcpy(host_addr, getenv("usbnet_hostaddr"),
+	if (env_get("usbnet_hostaddr"))
+		strlcpy(host_addr, env_get("usbnet_hostaddr"),
 			sizeof(host_addr));
 
 	if (!is_eth_addr_valid(dev_addr)) {
@@ -2420,8 +2420,8 @@
 	gadget = dev->gadget;
 	usb_gadget_connect(gadget);
 
-	if (getenv("cdc_connect_timeout"))
-		timeout = simple_strtoul(getenv("cdc_connect_timeout"),
+	if (env_get("cdc_connect_timeout"))
+		timeout = simple_strtoul(env_get("cdc_connect_timeout"),
 						NULL, 10) * CONFIG_SYS_HZ;
 	ts = get_timer(0);
 	while (!dev->network_started) {
@@ -2685,7 +2685,7 @@
 	l_priv = priv;
 
 	get_ether_addr(CONFIG_USBNET_DEVADDR, pdata->enetaddr);
-	eth_setenv_enetaddr("usbnet_devaddr", pdata->enetaddr);
+	eth_env_set_enetaddr("usbnet_devaddr", pdata->enetaddr);
 
 	return 0;
 }
diff --git a/drivers/usb/gadget/f_dfu.c b/drivers/usb/gadget/f_dfu.c
index dfa4359..bc4be71 100644
--- a/drivers/usb/gadget/f_dfu.c
+++ b/drivers/usb/gadget/f_dfu.c
@@ -725,7 +725,7 @@
 
 	cdev->req->context = f_dfu;
 
-	s = getenv("serial#");
+	s = env_get("serial#");
 	if (s)
 		g_dnl_set_serialnumber((char *)s);
 
diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index 7cd6d24..d05b74b 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -212,7 +212,7 @@
 		f->hs_descriptors = fb_hs_function;
 	}
 
-	s = getenv("serial#");
+	s = env_get("serial#");
 	if (s)
 		g_dnl_set_serialnumber((char *)s);
 
@@ -426,7 +426,7 @@
 		sprintf(str_num, "0x%08x", CONFIG_FASTBOOT_BUF_SIZE);
 		strncat(response, str_num, chars_left);
 	} else if (!strcmp_l1("serialno", cmd)) {
-		s = getenv("serial#");
+		s = env_get("serial#");
 		if (s)
 			strncat(response, s, chars_left);
 		else
@@ -441,7 +441,7 @@
 		}
 
 		sprintf(envstr, "fastboot.%s", cmd);
-		s = getenv(envstr);
+		s = env_get(envstr);
 		if (s) {
 			strncat(response, s, chars_left);
 		} else {
diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index b57c6cd..62c431b 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -225,7 +225,7 @@
 				"phy_type", &len);
 #endif
 	else
-		phy_type = getenv("usb_phy_type");
+		phy_type = env_get("usb_phy_type");
 
 	if (!phy_type) {
 #ifdef CONFIG_SYS_FSL_USB_INTERNAL_UTMI_PHY
diff --git a/drivers/video/ati_radeon_fb.c b/drivers/video/ati_radeon_fb.c
index 07a29ea..5b6c422 100644
--- a/drivers/video/ati_radeon_fb.c
+++ b/drivers/video/ati_radeon_fb.c
@@ -637,7 +637,8 @@
 
 	videomode = CONFIG_SYS_DEFAULT_VIDEO_MODE;
 	/* get video mode via environment */
-	if ((penv = getenv ("videomode")) != NULL) {
+	penv = env_get("videomode");
+	if (penv) {
 		/* deceide if it is a string */
 		if (penv[0] <= '9') {
 			videomode = (int) simple_strtoul (penv, NULL, 16);
diff --git a/drivers/video/cfb_console.c b/drivers/video/cfb_console.c
index b6fc7e1..6c5425c 100644
--- a/drivers/video/cfb_console.c
+++ b/drivers/video/cfb_console.c
@@ -1856,7 +1856,7 @@
 	splash_get_pos(&video_logo_xpos, &video_logo_ypos);
 
 #ifdef CONFIG_SPLASH_SCREEN
-	s = getenv("splashimage");
+	s = env_get("splashimage");
 	if (s != NULL) {
 		ret = splash_screen_prepare();
 		if (ret < 0)
diff --git a/drivers/video/mb862xx.c b/drivers/video/mb862xx.c
index 1c74e97..e0565e1 100644
--- a/drivers/video/mb862xx.c
+++ b/drivers/video/mb862xx.c
@@ -246,7 +246,8 @@
 	tmp = 0;
 	videomode = 0x310;
 	/* get video mode via environment */
-	if ((penv = getenv ("videomode")) != NULL) {
+	penv = env_get("videomode");
+	if (penv) {
 		/* decide if it is a string */
 		if (penv[0] <= '9') {
 			videomode = (int) simple_strtoul (penv, NULL, 16);
diff --git a/drivers/video/mx3fb.c b/drivers/video/mx3fb.c
index 51d06d6..78e595e 100644
--- a/drivers/video/mx3fb.c
+++ b/drivers/video/mx3fb.c
@@ -816,7 +816,7 @@
 
 	videomode = CONFIG_SYS_DEFAULT_VIDEO_MODE;
 	/* get video mode via environment */
-	penv = getenv("videomode");
+	penv = env_get("videomode");
 	if (penv) {
 		/* decide if it is a string */
 		if (penv[0] <= '9') {
diff --git a/drivers/video/mxsfb.c b/drivers/video/mxsfb.c
index 0ddce3d..9d810ba 100644
--- a/drivers/video/mxsfb.c
+++ b/drivers/video/mxsfb.c
@@ -161,7 +161,7 @@
 	puts("Video: ");
 
 	/* Suck display configuration from "videomode" variable */
-	penv = getenv("videomode");
+	penv = env_get("videomode");
 	if (!penv) {
 		puts("MXSFB: 'videomode' variable not set!\n");
 		return NULL;
diff --git a/drivers/video/videomodes.c b/drivers/video/videomodes.c
index cf71ad1..6d96b33 100644
--- a/drivers/video/videomodes.c
+++ b/drivers/video/videomodes.c
@@ -165,7 +165,8 @@
 	/* first search for the environment containing the real param string */
 	s = penv;
 
-	if ((p = getenv (s)) != NULL)
+	p = env_get(s);
+	if (p)
 		s = p;
 
 	/*
@@ -234,7 +235,7 @@
 int video_get_video_mode(unsigned int *xres, unsigned int *yres,
 	unsigned int *depth, unsigned int *freq, const char **options)
 {
-	char *p = getenv("video-mode");
+	char *p = env_get("video-mode");
 	if (!p)
 		return 0;
 
diff --git a/env/Kconfig b/env/Kconfig
new file mode 100644
index 0000000..748f534
--- /dev/null
+++ b/env/Kconfig
@@ -0,0 +1,475 @@
+menu "Environment"
+
+choice
+	prompt "Select the location of the environment"
+	default ENV_IS_IN_MMC if ARCH_SUNXI
+	default ENV_IS_IN_FAT if ARCH_BCM283X
+	default ENV_IS_IN_MMC if ARCH_UNIPHIER
+	default ENV_IS_IN_MMC if ARCH_EXYNOS4
+	default ENV_IS_IN_MMC if MX6SX || MX7D
+	default ENV_IS_IN_FLASH if ARCH_CINTEGRATOR
+	default ENV_IS_IN_SPI_FLASH if ARMADA_XP
+	default ENV_IS_IN_MMC if TEGRA30 || TEGRA124
+	default ENV_IS_IN_MMC if TEGRA_ARMV8_COMMON
+	default ENV_IS_IN_FLASH if ARCH_INTEGRATOR_CP
+	default ENV_IS_IN_FLASH if M548x || M547x || M5282 || MCF547x_8x
+	default ENV_IS_IN_FLASH if MCF532x || MCF52x2
+	default ENV_IS_IN_FLASH if MPC86xx || MPC83xx
+	default ENV_IS_IN_FLASH if ARCH_MPC8572 || ARCH_MPC8548 || ARCH_MPC8641
+	default ENV_IS_IN_FLASH if SH && !CPU_SH4
+	default ENV_IS_IN_SPI_FLASH if INTEL_BAYTRAIL
+	default ENV_IS_IN_SPI_FLASH if INTEL_BROADWELL
+	default ENV_IS_IN_SPI_FLASH if NORTHBRIDGE_INTEL_IVYBRIDGE
+	default ENV_IS_IN_SPI_FLASH if INTEL_QUARK
+	default ENV_IS_IN_SPI_FLASH if INTEL_QUEENSBAY
+	default ENV_IS_IN_FAT if MMC_OMAP_HS && TI_COMMON_CMD_OPTIONS
+	default ENV_IS_NOWHERE
+	help
+	  At present the environment can be stored in only one place. Use this
+	  option to select the location. This is either a device (where the
+	  environemnt information is simply written to a fixed location or
+	  partition on the device) or a filesystem (where the environment
+	  information is written to a file).
+
+config ENV_IS_NOWHERE
+	bool "Environment is not stored"
+	help
+	  Define this if you don't want to or can't have an environment stored
+	  on a storage medium. In this case the environemnt will still exist
+	  while U-Boot is running, but once U-Boot exits it will not be
+	  stored. U-Boot will therefore always start up with a default
+	  environment.
+
+config ENV_IS_IN_DATAFLASH
+	bool "Environment in dataflash"
+	depends on !CHAIN_OF_TRUST
+	help
+	  Define this if you have a DataFlash memory device which you
+	  want to use for the environment.
+
+	  - CONFIG_ENV_OFFSET:
+	  - CONFIG_ENV_ADDR:
+	  - CONFIG_ENV_SIZE:
+
+	  These three #defines specify the offset and size of the
+	  environment area within the total memory of your DataFlash placed
+	  at the specified address.
+
+config ENV_IS_IN_EEPROM
+	bool "Environment in EEPROM"
+	depends on !CHAIN_OF_TRUST
+	help
+	  Use this if you have an EEPROM or similar serial access
+	  device and a driver for it.
+
+	  - CONFIG_ENV_OFFSET:
+	  - CONFIG_ENV_SIZE:
+
+	  These two #defines specify the offset and size of the
+	  environment area within the total memory of your EEPROM.
+
+	  - CONFIG_SYS_I2C_EEPROM_ADDR:
+	  If defined, specified the chip address of the EEPROM device.
+	  The default address is zero.
+
+	  - CONFIG_SYS_I2C_EEPROM_BUS:
+	  If defined, specified the i2c bus of the EEPROM device.
+
+	  - CONFIG_SYS_EEPROM_PAGE_WRITE_BITS:
+	  If defined, the number of bits used to address bytes in a
+	  single page in the EEPROM device.  A 64 byte page, for example
+	  would require six bits.
+
+	  - CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS:
+	  If defined, the number of milliseconds to delay between
+	  page writes.	The default is zero milliseconds.
+
+	  - CONFIG_SYS_I2C_EEPROM_ADDR_LEN:
+	  The length in bytes of the EEPROM memory array address.  Note
+	  that this is NOT the chip address length!
+
+	  - CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW:
+	  EEPROM chips that implement "address overflow" are ones
+	  like Catalyst 24WC04/08/16 which has 9/10/11 bits of
+	  address and the extra bits end up in the "chip address" bit
+	  slots. This makes a 24WC08 (1Kbyte) chip look like four 256
+	  byte chips.
+
+	  Note that we consider the length of the address field to
+	  still be one byte because the extra address bits are hidden
+	  in the chip address.
+
+	  - CONFIG_SYS_EEPROM_SIZE:
+	  The size in bytes of the EEPROM device.
+
+	  - CONFIG_ENV_EEPROM_IS_ON_I2C
+	  define this, if you have I2C and SPI activated, and your
+	  EEPROM, which holds the environment, is on the I2C bus.
+
+	  - CONFIG_I2C_ENV_EEPROM_BUS
+	  if you have an Environment on an EEPROM reached over
+	  I2C muxes, you can define here, how to reach this
+	  EEPROM. For example:
+
+	  #define CONFIG_I2C_ENV_EEPROM_BUS	  1
+
+	  EEPROM which holds the environment, is reached over
+	  a pca9547 i2c mux with address 0x70, channel 3.
+
+config ENV_IS_IN_FAT
+	bool "Environment is in a FAT filesystem"
+	depends on !CHAIN_OF_TRUST
+	select FAT_WRITE
+	help
+	  Define this if you want to use the FAT file system for the environment.
+
+	  - CONFIG_FAT_WRITE:
+	  This must be enabled. Otherwise it cannot save the environment file.
+
+config ENV_IS_IN_FLASH
+	bool "Environment in flash memory"
+	depends on !CHAIN_OF_TRUST
+	help
+	  Define this if you have a flash device which you want to use for the
+	  environment.
+
+	  a) The environment occupies one whole flash sector, which is
+	   "embedded" in the text segment with the U-Boot code. This
+	   happens usually with "bottom boot sector" or "top boot
+	   sector" type flash chips, which have several smaller
+	   sectors at the start or the end. For instance, such a
+	   layout can have sector sizes of 8, 2x4, 16, Nx32 kB. In
+	   such a case you would place the environment in one of the
+	   4 kB sectors - with U-Boot code before and after it. With
+	   "top boot sector" type flash chips, you would put the
+	   environment in one of the last sectors, leaving a gap
+	   between U-Boot and the environment.
+
+	  CONFIG_ENV_OFFSET:
+
+	   Offset of environment data (variable area) to the
+	   beginning of flash memory; for instance, with bottom boot
+	   type flash chips the second sector can be used: the offset
+	   for this sector is given here.
+
+	   CONFIG_ENV_OFFSET is used relative to CONFIG_SYS_FLASH_BASE.
+
+	  CONFIG_ENV_ADDR:
+
+	   This is just another way to specify the start address of
+	   the flash sector containing the environment (instead of
+	   CONFIG_ENV_OFFSET).
+
+	  CONFIG_ENV_SECT_SIZE:
+
+	   Size of the sector containing the environment.
+
+
+	  b) Sometimes flash chips have few, equal sized, BIG sectors.
+	   In such a case you don't want to spend a whole sector for
+	   the environment.
+
+	  CONFIG_ENV_SIZE:
+
+	   If you use this in combination with CONFIG_ENV_IS_IN_FLASH
+	   and CONFIG_ENV_SECT_SIZE, you can specify to use only a part
+	   of this flash sector for the environment. This saves
+	   memory for the RAM copy of the environment.
+
+	   It may also save flash memory if you decide to use this
+	   when your environment is "embedded" within U-Boot code,
+	   since then the remainder of the flash sector could be used
+	   for U-Boot code. It should be pointed out that this is
+	   STRONGLY DISCOURAGED from a robustness point of view:
+	   updating the environment in flash makes it always
+	   necessary to erase the WHOLE sector. If something goes
+	   wrong before the contents has been restored from a copy in
+	   RAM, your target system will be dead.
+
+	  CONFIG_ENV_ADDR_REDUND
+	  CONFIG_ENV_SIZE_REDUND
+
+	   These settings describe a second storage area used to hold
+	   a redundant copy of the environment data, so that there is
+	   a valid backup copy in case there is a power failure during
+	   a "saveenv" operation.
+
+	  BE CAREFUL! Any changes to the flash layout, and some changes to the
+	  source code will make it necessary to adapt <board>/u-boot.lds*
+	  accordingly!
+
+config ENV_IS_IN_MMC
+	bool "Environment in an MMC device"
+	depends on !CHAIN_OF_TRUST
+	help
+	  Define this if you have an MMC device which you want to use for the
+	  environment.
+
+	  CONFIG_SYS_MMC_ENV_DEV:
+
+	  Specifies which MMC device the environment is stored in.
+
+	  CONFIG_SYS_MMC_ENV_PART (optional):
+
+	  Specifies which MMC partition the environment is stored in. If not
+	  set, defaults to partition 0, the user area. Common values might be
+	  1 (first MMC boot partition), 2 (second MMC boot partition).
+
+	  CONFIG_ENV_OFFSET:
+	  CONFIG_ENV_SIZE:
+
+	  These two #defines specify the offset and size of the environment
+	  area within the specified MMC device.
+
+	  If offset is positive (the usual case), it is treated as relative to
+	  the start of the MMC partition. If offset is negative, it is treated
+	  as relative to the end of the MMC partition. This can be useful if
+	  your board may be fitted with different MMC devices, which have
+	  different sizes for the MMC partitions, and you always want the
+	  environment placed at the very end of the partition, to leave the
+	  maximum possible space before it, to store other data.
+
+	  These two values are in units of bytes, but must be aligned to an
+	  MMC sector boundary.
+
+	  CONFIG_ENV_OFFSET_REDUND (optional):
+
+	  Specifies a second storage area, of CONFIG_ENV_SIZE size, used to
+	  hold a redundant copy of the environment data. This provides a
+	  valid backup copy in case the other copy is corrupted, e.g. due
+	  to a power failure during a "saveenv" operation.
+
+	  This value may also be positive or negative; this is handled in the
+	  same way as CONFIG_ENV_OFFSET.
+
+	  This value is also in units of bytes, but must also be aligned to
+	  an MMC sector boundary.
+
+	  CONFIG_ENV_SIZE_REDUND (optional):
+
+	  This value need not be set, even when CONFIG_ENV_OFFSET_REDUND is
+	  set. If this value is set, it must be set to the same value as
+	  CONFIG_ENV_SIZE.
+
+config ENV_IS_IN_NAND
+	bool "Environment in a NAND device"
+	depends on !CHAIN_OF_TRUST
+	help
+	  Define this if you have a NAND device which you want to use for the
+	  environment.
+
+	  - CONFIG_ENV_OFFSET:
+	  - CONFIG_ENV_SIZE:
+
+	  These two #defines specify the offset and size of the environment
+	  area within the first NAND device.  CONFIG_ENV_OFFSET must be
+	  aligned to an erase block boundary.
+
+	  - CONFIG_ENV_OFFSET_REDUND (optional):
+
+	  This setting describes a second storage area of CONFIG_ENV_SIZE
+	  size used to hold a redundant copy of the environment data, so
+	  that there is a valid backup copy in case there is a power failure
+	  during a "saveenv" operation.	 CONFIG_ENV_OFFSET_REDUND must be
+	  aligned to an erase block boundary.
+
+	  - CONFIG_ENV_RANGE (optional):
+
+	  Specifies the length of the region in which the environment
+	  can be written.  This should be a multiple of the NAND device's
+	  block size.  Specifying a range with more erase blocks than
+	  are needed to hold CONFIG_ENV_SIZE allows bad blocks within
+	  the range to be avoided.
+
+	  - CONFIG_ENV_OFFSET_OOB (optional):
+
+	  Enables support for dynamically retrieving the offset of the
+	  environment from block zero's out-of-band data.  The
+	  "nand env.oob" command can be used to record this offset.
+	  Currently, CONFIG_ENV_OFFSET_REDUND is not supported when
+	  using CONFIG_ENV_OFFSET_OOB.
+
+config ENV_IS_IN_NVRAM
+	bool "Environment in a non-volatile RAM"
+	depends on !CHAIN_OF_TRUST
+	help
+	  Define this if you have some non-volatile memory device
+	  (NVRAM, battery buffered SRAM) which you want to use for the
+	  environment.
+
+	  - CONFIG_ENV_ADDR:
+	  - CONFIG_ENV_SIZE:
+
+	  These two #defines are used to determine the memory area you
+	  want to use for environment. It is assumed that this memory
+	  can just be read and written to, without any special
+	  provision.
+
+config ENV_IS_IN_ONENAND
+	bool "Environment is in OneNAND"
+	depends on !CHAIN_OF_TRUST
+	help
+	  Define this if you want to put your local device's environment in
+	  OneNAND.
+
+	  - CONFIG_ENV_ADDR:
+	  - CONFIG_ENV_SIZE:
+
+	  These two #defines are used to determine the device range you
+	  want to use for environment. It is assumed that this memory
+	  can just be read and written to, without any special
+	  provision.
+
+config ENV_IS_IN_REMOTE
+	bool "Environment is in remove memory space"
+	depends on !CHAIN_OF_TRUST
+	help
+	  Define this if you have a remote memory space which you
+	  want to use for the local device's environment.
+
+	  - CONFIG_ENV_ADDR:
+	  - CONFIG_ENV_SIZE:
+
+	  These two #defines specify the address and size of the
+	  environment area within the remote memory space. The
+	  local device can get the environment from remote memory
+	  space by SRIO or PCIE links.
+
+config ENV_IS_IN_SPI_FLASH
+	bool "Environment is in SPI flash"
+	depends on !CHAIN_OF_TRUST
+	help
+	  Define this if you have a SPI Flash memory device which you
+	  want to use for the environment.
+
+	  - CONFIG_ENV_OFFSET:
+	  - CONFIG_ENV_SIZE:
+
+	  These two #defines specify the offset and size of the
+	  environment area within the SPI Flash. CONFIG_ENV_OFFSET must be
+	  aligned to an erase sector boundary.
+
+	  - CONFIG_ENV_SECT_SIZE:
+
+	  Define the SPI flash's sector size.
+
+	  - CONFIG_ENV_OFFSET_REDUND (optional):
+
+	  This setting describes a second storage area of CONFIG_ENV_SIZE
+	  size used to hold a redundant copy of the environment data, so
+	  that there is a valid backup copy in case there is a power failure
+	  during a "saveenv" operation. CONFIG_ENV_OFFSET_REDUND must be
+	  aligned to an erase sector boundary.
+
+	  - CONFIG_ENV_SPI_BUS (optional):
+	  - CONFIG_ENV_SPI_CS (optional):
+
+	  Define the SPI bus and chip select. If not defined they will be 0.
+
+	  - CONFIG_ENV_SPI_MAX_HZ (optional):
+
+	  Define the SPI max work clock. If not defined then use 1MHz.
+
+	  - CONFIG_ENV_SPI_MODE (optional):
+
+	  Define the SPI work mode. If not defined then use SPI_MODE_3.
+
+config ENV_IS_IN_UBI
+	bool "Environment in a UBI volume"
+	depends on !CHAIN_OF_TRUST
+	help
+	  Define this if you have an UBI volume that you want to use for the
+	  environment.  This has the benefit of wear-leveling the environment
+	  accesses, which is important on NAND.
+
+	  - CONFIG_ENV_UBI_PART:
+
+	  Define this to a string that is the mtd partition containing the UBI.
+
+	  - CONFIG_ENV_UBI_VOLUME:
+
+	  Define this to the name of the volume that you want to store the
+	  environment in.
+
+	  - CONFIG_ENV_UBI_VOLUME_REDUND:
+
+	  Define this to the name of another volume to store a second copy of
+	  the environment in.  This will enable redundant environments in UBI.
+	  It is assumed that both volumes are in the same MTD partition.
+
+	  - CONFIG_UBI_SILENCE_MSG
+	  - CONFIG_UBIFS_SILENCE_MSG
+
+	  You will probably want to define these to avoid a really noisy system
+	  when storing the env in UBI.
+
+endchoice
+
+config ENV_FAT_INTERFACE
+	string "Name of the block device for the environment"
+	depends on ENV_IS_IN_FAT
+	default "mmc" if TI_COMMON_CMD_OPTIONS || ARCH_ZYNQMP || ARCH_AT91
+	help
+	  Define this to a string that is the name of the block device.
+
+config ENV_FAT_DEVICE_AND_PART
+	string "Device and partition for where to store the environemt in FAT"
+	depends on ENV_IS_IN_FAT
+	default "0:1" if TI_COMMON_CMD_OPTIONS
+	default "0:auto" if ARCH_ZYNQMP
+	default "0" if ARCH_AT91
+	help
+	  Define this to a string to specify the partition of the device. It can
+	  be as following:
+
+	    "D:P", "D:0", "D", "D:" or "D:auto" (D, P are integers. And P >= 1)
+	       - "D:P": device D partition P. Error occurs if device D has no
+	                partition table.
+	       - "D:0": device D.
+	       - "D" or "D:": device D partition 1 if device D has partition
+	                      table, or the whole device D if has no partition
+	                      table.
+	       - "D:auto": first partition in device D with bootable flag set.
+	                   If none, first valid partition in device D. If no
+	                   partition table then means device D.
+
+config ENV_FAT_FILE
+	string "Name of the FAT file to use for the environemnt"
+	depends on ENV_IS_IN_FAT
+	default "uboot.env"
+	help
+	  It's a string of the FAT file name. This file use to store the
+	  environment.
+
+if ARCH_SUNXI
+
+config ENV_OFFSET
+	hex "Environment Offset"
+	depends on !ENV_IS_IN_UBI
+	depends on !ENV_IS_NOWHERE
+	default 0x88000 if ARCH_SUNXI
+	help
+	  Offset from the start of the device (or partition)
+
+config ENV_SIZE
+	hex "Environment Size"
+	depends on !ENV_IS_NOWHERE
+	default 0x20000 if ARCH_SUNXI
+	help
+	  Size of the environment storage area
+
+config ENV_UBI_PART
+	string "UBI partition name"
+	depends on ENV_IS_IN_UBI
+	help
+	  MTD partition containing the UBI device
+
+config ENV_UBI_VOLUME
+	string "UBI volume name"
+	depends on ENV_IS_IN_UBI
+	help
+	  Name of the volume that you want to store the environment in.
+
+endif
+
+endmenu
diff --git a/env/Makefile b/env/Makefile
new file mode 100644
index 0000000..8df5b9d
--- /dev/null
+++ b/env/Makefile
@@ -0,0 +1,57 @@
+#
+# (C) Copyright 2004-2006
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+
+obj-y += common.o env.o
+
+ifndef CONFIG_SPL_BUILD
+obj-y += attr.o
+obj-y += callback.o
+obj-y += flags.o
+obj-$(CONFIG_ENV_IS_IN_DATAFLASH) += dataflash.o
+obj-$(CONFIG_ENV_IS_IN_EEPROM) += eeprom.o
+extra-$(CONFIG_ENV_IS_EMBEDDED) += embedded.o
+obj-$(CONFIG_ENV_IS_IN_EEPROM) += embedded.o
+extra-$(CONFIG_ENV_IS_IN_FLASH) += embedded.o
+obj-$(CONFIG_ENV_IS_IN_NVRAM) += embedded.o
+obj-$(CONFIG_ENV_IS_IN_FLASH) += flash.o
+obj-$(CONFIG_ENV_IS_IN_MMC) += mmc.o
+obj-$(CONFIG_ENV_IS_IN_FAT) += fat.o
+obj-$(CONFIG_ENV_IS_IN_EXT4) += ext4.o
+obj-$(CONFIG_ENV_IS_IN_NAND) += nand.o
+obj-$(CONFIG_ENV_IS_IN_NVRAM) += nvram.o
+obj-$(CONFIG_ENV_IS_IN_ONENAND) += onenand.o
+obj-$(CONFIG_ENV_IS_IN_SATA) += sata.o
+obj-$(CONFIG_ENV_IS_IN_SPI_FLASH) += sf.o
+obj-$(CONFIG_ENV_IS_IN_REMOTE) += remote.o
+obj-$(CONFIG_ENV_IS_IN_UBI) += ubi.o
+obj-$(CONFIG_ENV_IS_NOWHERE) += nowhere.o
+endif
+
+ifdef CONFIG_SPL_BUILD
+obj-$(CONFIG_ENV_IS_IN_FLASH) += flash.o
+# environment
+ifdef CONFIG_TPL_BUILD
+obj-$(CONFIG_TPL_ENV_SUPPORT) += attr.o
+obj-$(CONFIG_TPL_ENV_SUPPORT) += flags.o
+obj-$(CONFIG_TPL_ENV_SUPPORT) += callback.o
+else
+obj-$(CONFIG_SPL_ENV_SUPPORT) += attr.o
+obj-$(CONFIG_SPL_ENV_SUPPORT) += flags.o
+obj-$(CONFIG_SPL_ENV_SUPPORT) += callback.o
+endif
+ifneq ($(CONFIG_TPL_ENV_SUPPORT)$(CONFIG_SPL_ENV_SUPPORT),)
+obj-$(CONFIG_ENV_IS_NOWHERE) += nowhere.o
+obj-$(CONFIG_ENV_IS_IN_MMC) += mmc.o
+obj-$(CONFIG_ENV_IS_IN_FAT) += fat.o
+obj-$(CONFIG_ENV_IS_IN_EXT4) += ext4.o
+obj-$(CONFIG_ENV_IS_IN_NAND) += nand.o
+obj-$(CONFIG_ENV_IS_IN_SPI_FLASH) += sf.o
+obj-$(CONFIG_ENV_IS_IN_FLASH) += flash.o
+endif
+endif
+
+CFLAGS_embedded.o := -Wa,--no-warn -DENV_CRC=$(shell tools/envcrc 2>/dev/null)
diff --git a/common/env_attr.c b/env/attr.c
similarity index 100%
rename from common/env_attr.c
rename to env/attr.c
diff --git a/common/env_callback.c b/env/callback.c
similarity index 98%
rename from common/env_callback.c
rename to env/callback.c
index 1957cc1..be70980 100644
--- a/common/env_callback.c
+++ b/env/callback.c
@@ -51,7 +51,7 @@
 	int ret = 1;
 
 	if (first_call) {
-		callback_list = getenv(ENV_CALLBACK_VAR);
+		callback_list = env_get(ENV_CALLBACK_VAR);
 		first_call = 0;
 	}
 
diff --git a/common/env_common.c b/env/common.c
similarity index 88%
rename from common/env_common.c
rename to env/common.c
index d9c0c4e..688d5ab 100644
--- a/common/env_common.c
+++ b/env/common.c
@@ -27,49 +27,13 @@
 	.change_ok = env_flags_validate,
 };
 
-__weak uchar env_get_char_spec(int index)
-{
-	return *((uchar *)(gd->env_addr + index));
-}
-
-static uchar env_get_char_init(int index)
-{
-	/* if crc was bad, use the default environment */
-	if (gd->env_valid)
-		return env_get_char_spec(index);
-	else
-		return default_environment[index];
-}
-
-uchar env_get_char_memory(int index)
-{
-	return *env_get_addr(index);
-}
-
-uchar env_get_char(int index)
-{
-	/* if relocated to RAM */
-	if (gd->flags & GD_FLG_RELOC)
-		return env_get_char_memory(index);
-	else
-		return env_get_char_init(index);
-}
-
-const uchar *env_get_addr(int index)
-{
-	if (gd->env_valid)
-		return (uchar *)(gd->env_addr + index);
-	else
-		return &default_environment[index];
-}
-
 /*
  * Read an environment variable as a boolean
  * Return -1 if variable does not exist (default to true)
  */
-int getenv_yesno(const char *var)
+int env_get_yesno(const char *var)
 {
-	char *s = getenv(var);
+	char *s = env_get(var);
 
 	if (s == NULL)
 		return -1;
@@ -80,7 +44,7 @@
 /*
  * Look up the variable from the default environment
  */
-char *getenv_default(const char *name)
+char *env_get_default(const char *name)
 {
 	char *ret_val;
 	unsigned long really_valid = gd->env_valid;
@@ -89,7 +53,7 @@
 	/* Pretend that the image is bad. */
 	gd->flags &= ~GD_FLG_ENV_READY;
 	gd->env_valid = 0;
-	ret_val = getenv(name);
+	ret_val = env_get(name);
 	gd->env_valid = really_valid;
 	gd->flags = real_gd_flags;
 	return ret_val;
@@ -316,7 +280,7 @@
 		set_default_env("!bad CRC");
 #endif
 	} else {
-		env_relocate_spec();
+		env_load();
 	}
 }
 
diff --git a/common/env_dataflash.c b/env/dataflash.c
similarity index 74%
rename from common/env_dataflash.c
rename to env/dataflash.c
index 034e323..77bc595 100644
--- a/common/env_dataflash.c
+++ b/env/dataflash.c
@@ -14,11 +14,7 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-env_t *env_ptr;
-
-char *env_name_spec = "dataflash";
-
-uchar env_get_char_spec(int index)
+static int env_dataflash_get_char(int index)
 {
 	uchar c;
 
@@ -27,7 +23,7 @@
 	return c;
 }
 
-void env_relocate_spec(void)
+static int env_dataflash_load(void)
 {
 	ulong crc, new = 0;
 	unsigned off;
@@ -48,13 +44,15 @@
 		env_import(buf, 1);
 	else
 		set_default_env("!bad CRC");
+
+	return 0;
 }
 
 #ifdef CONFIG_ENV_OFFSET_REDUND
 #error No support for redundant environment on dataflash yet!
 #endif
 
-int saveenv(void)
+static int env_dataflash_save(void)
 {
 	env_t env_new;
 	int ret;
@@ -68,17 +66,10 @@
 				CONFIG_ENV_SIZE);
 }
 
-/*
- * Initialize environment use
- *
- * We are still running from ROM, so data use is limited.
- * Use a (moderately small) buffer on the stack
- */
-int env_init(void)
-{
-	/* use default */
-	gd->env_addr = (ulong)&default_environment[0];
-	gd->env_valid = 1;
-
-	return 0;
-}
+U_BOOT_ENV_LOCATION(dataflash) = {
+	.location	= ENVL_DATAFLASH,
+	ENV_NAME("dataflash")
+	.get_char	= env_dataflash_get_char,
+	.load		= env_dataflash_load,
+	.save		= env_save_ptr(env_dataflash_save),
+};
diff --git a/common/env_eeprom.c b/env/eeprom.c
similarity index 85%
rename from common/env_eeprom.c
rename to env/eeprom.c
index 5f63a6c..08ef630 100644
--- a/common/env_eeprom.c
+++ b/env/eeprom.c
@@ -21,10 +21,6 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-env_t *env_ptr;
-
-char *env_name_spec = "EEPROM";
-
 static int eeprom_bus_read(unsigned dev_addr, unsigned offset,
 			   uchar *buffer, unsigned cnt)
 {
@@ -65,13 +61,13 @@
 	return rcode;
 }
 
-uchar env_get_char_spec(int index)
+static int env_eeprom_get_char(int index)
 {
 	uchar c;
 	unsigned int off = CONFIG_ENV_OFFSET;
 
 #ifdef CONFIG_ENV_OFFSET_REDUND
-	if (gd->env_valid == 2)
+	if (gd->env_valid == ENV_REDUND)
 		off = CONFIG_ENV_OFFSET_REDUND;
 #endif
 	eeprom_bus_read(CONFIG_SYS_DEF_EEPROM_ADDR,
@@ -80,7 +76,7 @@
 	return c;
 }
 
-void env_relocate_spec(void)
+static int env_eeprom_load(void)
 {
 	char buf_env[CONFIG_ENV_SIZE];
 	unsigned int off = CONFIG_ENV_OFFSET;
@@ -128,21 +124,21 @@
 		gd->env_addr	= 0;
 		gd->env_valid	= 0;
 	} else if (crc_ok[0] && !crc_ok[1]) {
-		gd->env_valid = 1;
+		gd->env_valid = ENV_VALID;
 	} else if (!crc_ok[0] && crc_ok[1]) {
-		gd->env_valid = 2;
+		gd->env_valid = ENV_REDUND;
 	} else {
 		/* both ok - check serial */
 		if (flags[0] == ACTIVE_FLAG && flags[1] == OBSOLETE_FLAG)
-			gd->env_valid = 1;
+			gd->env_valid = ENV_VALID;
 		else if (flags[0] == OBSOLETE_FLAG && flags[1] == ACTIVE_FLAG)
-			gd->env_valid = 2;
+			gd->env_valid = ENV_REDUND;
 		else if (flags[0] == 0xFF && flags[1] == 0)
-			gd->env_valid = 2;
+			gd->env_valid = ENV_REDUND;
 		else if (flags[1] == 0xFF && flags[0] == 0)
-			gd->env_valid = 1;
+			gd->env_valid = ENV_VALID;
 		else /* flags are equal - almost impossible */
-			gd->env_valid = 1;
+			gd->env_valid = ENV_VALID;
 	}
 
 #else /* CONFIG_ENV_OFFSET_REDUND */
@@ -170,7 +166,7 @@
 	}
 
 	if (crc == new) {
-		gd->env_valid	= 1;
+		gd->env_valid	= ENV_VALID;
 	} else {
 		gd->env_valid	= 0;
 	}
@@ -178,7 +174,7 @@
 
 	off = CONFIG_ENV_OFFSET;
 #ifdef CONFIG_ENV_OFFSET_REDUND
-	if (gd->env_valid == 2)
+	if (gd->env_valid == ENV_REDUND)
 		off = CONFIG_ENV_OFFSET_REDUND;
 #endif
 
@@ -186,9 +182,11 @@
 		off, (uchar *)buf_env, CONFIG_ENV_SIZE);
 
 	env_import(buf_env, 1);
+
+	return 0;
 }
 
-int saveenv(void)
+static int env_eeprom_save(void)
 {
 	env_t	env_new;
 	int	rc;
@@ -198,14 +196,12 @@
 	char flag_obsolete	= OBSOLETE_FLAG;
 #endif
 
-	BUG_ON(env_ptr != NULL);
-
 	rc = env_export(&env_new);
 	if (rc)
 		return rc;
 
 #ifdef CONFIG_ENV_OFFSET_REDUND
-	if (gd->env_valid == 1) {
+	if (gd->env_valid == ENV_VALID) {
 		off	= CONFIG_ENV_OFFSET_REDUND;
 		off_red	= CONFIG_ENV_OFFSET;
 	}
@@ -222,24 +218,19 @@
 				 off_red + offsetof(env_t, flags),
 				 (uchar *)&flag_obsolete, 1);
 
-		if (gd->env_valid == 1)
-			gd->env_valid = 2;
+		if (gd->env_valid == ENV_VALID)
+			gd->env_valid = ENV_REDUND;
 		else
-			gd->env_valid = 1;
+			gd->env_valid = ENV_VALID;
 	}
 #endif
 	return rc;
 }
 
-/*
- * Initialize Environment use
- *
- * We are still running from ROM, so data use is limited.
- * Use a (moderately small) buffer on the stack
- */
-int env_init(void)
-{
-	gd->env_addr = (ulong)&default_environment[0];
-	gd->env_valid = 1;
-	return 0;
-}
+U_BOOT_ENV_LOCATION(eeprom) = {
+	.location	= ENVL_EEPROM,
+	ENV_NAME("EEPROM")
+	.get_char	= env_eeprom_get_char,
+	.load		= env_eeprom_load,
+	.save		= env_save_ptr(env_eeprom_save),
+};
diff --git a/common/env_embedded.c b/env/embedded.c
similarity index 100%
rename from common/env_embedded.c
rename to env/embedded.c
diff --git a/env/env.c b/env/env.c
new file mode 100644
index 0000000..2b8b961
--- /dev/null
+++ b/env/env.c
@@ -0,0 +1,151 @@
+/*
+ * Copyright (C) 2017 Google, Inc
+ * Written by Simon Glass <sjg@chromium.org>
+ *
+ * SPDX-License-Identifier:     GPL-2.0+
+ */
+
+#include <common.h>
+#include <environment.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static struct env_driver *env_driver_lookup(enum env_location loc)
+{
+	struct env_driver *drv;
+	const int n_ents = ll_entry_count(struct env_driver, env_driver);
+	struct env_driver *entry;
+
+	drv = ll_entry_start(struct env_driver, env_driver);
+	for (entry = drv; entry != drv + n_ents; entry++) {
+		if (loc == entry->location)
+			return entry;
+	}
+
+	/* Not found */
+	return NULL;
+}
+
+static enum env_location env_get_default_location(void)
+{
+	if IS_ENABLED(CONFIG_ENV_IS_IN_DATAFLASH)
+		return ENVL_DATAFLASH;
+	else if IS_ENABLED(CONFIG_ENV_IS_IN_EEPROM)
+		return ENVL_EEPROM;
+	else if IS_ENABLED(CONFIG_ENV_IS_IN_FAT)
+		return ENVL_FAT;
+	else if IS_ENABLED(CONFIG_ENV_IS_IN_FLASH)
+		return ENVL_FLASH;
+	else if IS_ENABLED(CONFIG_ENV_IS_IN_MMC)
+		return ENVL_MMC;
+	else if IS_ENABLED(CONFIG_ENV_IS_IN_NAND)
+		return ENVL_NAND;
+	else if IS_ENABLED(CONFIG_ENV_IS_IN_NVRAM)
+		return ENVL_NVRAM;
+	else if IS_ENABLED(CONFIG_ENV_IS_IN_REMOTE)
+		return ENVL_REMOTE;
+	else if IS_ENABLED(CONFIG_ENV_IS_IN_SPI_FLASH)
+		return ENVL_SPI_FLASH;
+	else if IS_ENABLED(CONFIG_ENV_IS_IN_UBI)
+		return ENVL_UBI;
+	else if IS_ENABLED(CONFIG_ENV_IS_NOWHERE)
+		return ENVL_NOWHERE;
+	else
+		return ENVL_UNKNOWN;
+}
+
+struct env_driver *env_driver_lookup_default(void)
+{
+	enum env_location loc = env_get_default_location();
+	struct env_driver *drv;
+
+	drv = env_driver_lookup(loc);
+	if (!drv) {
+		debug("%s: No environment driver for location %d\n", __func__,
+		      loc);
+		return NULL;
+	}
+
+	return drv;
+}
+
+int env_get_char(int index)
+{
+	struct env_driver *drv = env_driver_lookup_default();
+	int ret;
+
+	if (!gd->env_valid)
+		return default_environment[index];
+	if (!drv)
+		return -ENODEV;
+	if (!drv->get_char)
+		return *(uchar *)(gd->env_addr + index);
+	ret = drv->get_char(index);
+	if (ret < 0) {
+		debug("%s: Environment failed to load (err=%d)\n",
+		      __func__, ret);
+	}
+
+	return ret;
+}
+
+int env_load(void)
+{
+	struct env_driver *drv = env_driver_lookup_default();
+	int ret = 0;
+
+	if (!drv)
+		return -ENODEV;
+	if (!drv->load)
+		return 0;
+	drv->load();  /* TODO(sjg@chromium.org): Make this return an error */
+	if (ret) {
+		debug("%s: Environment failed to load (err=%d)\n", __func__,
+		      ret);
+		return ret;
+	}
+
+	return 0;
+}
+
+int env_save(void)
+{
+	struct env_driver *drv = env_driver_lookup_default();
+	int ret;
+
+	if (!drv)
+		return -ENODEV;
+	if (!drv->save)
+		return -ENOSYS;
+	ret = drv->save();
+	if (ret) {
+		debug("%s: Environment failed to save (err=%d)\n", __func__,
+		      ret);
+		return ret;
+	}
+
+	return 0;
+}
+
+int env_init(void)
+{
+	struct env_driver *drv = env_driver_lookup_default();
+	int ret = -ENOENT;
+
+	if (!drv)
+		return -ENODEV;
+	if (drv->init)
+		ret = drv->init();
+	if (ret == -ENOENT) {
+		gd->env_addr = (ulong)&default_environment[0];
+		gd->env_valid = 0;
+
+		return 0;
+	} else if (ret) {
+		debug("%s: Environment failed to init (err=%d)\n", __func__,
+		      ret);
+		return ret;
+	}
+
+	return 0;
+}
diff --git a/common/env_ext4.c b/env/ext4.c
similarity index 91%
rename from common/env_ext4.c
rename to env/ext4.c
index adefa7d..6520221 100644
--- a/common/env_ext4.c
+++ b/env/ext4.c
@@ -31,23 +31,10 @@
 #include <ext4fs.h>
 #include <mmc.h>
 
-char *env_name_spec = "EXT4";
-
-env_t *env_ptr;
-
 DECLARE_GLOBAL_DATA_PTR;
 
-int env_init(void)
-{
-	/* use default */
-	gd->env_addr = (ulong)&default_environment[0];
-	gd->env_valid = 1;
-
-	return 0;
-}
-
 #ifdef CONFIG_CMD_SAVEENV
-int saveenv(void)
+static int env_ext4_save(void)
 {
 	env_t	env_new;
 	struct blk_desc *dev_desc = NULL;
@@ -88,7 +75,7 @@
 }
 #endif /* CONFIG_CMD_SAVEENV */
 
-void env_relocate_spec(void)
+static int env_ext4_load(void)
 {
 	ALLOC_CACHE_ALIGN_BUFFER(char, buf, CONFIG_ENV_SIZE);
 	struct blk_desc *dev_desc = NULL;
@@ -122,8 +109,17 @@
 	}
 
 	env_import(buf, 1);
-	return;
+	return 0;
 
 err_env_relocate:
 	set_default_env(NULL);
+
+	return -EIO;
 }
+
+U_BOOT_ENV_LOCATION(ext4) = {
+	.location	= ENVL_EXT4,
+	ENV_NAME("EXT4")
+	.load		= env_ext4_load,
+	.save		= env_save_ptr(env_ext4_save),
+};
diff --git a/common/env_fat.c b/env/fat.c
similarity index 76%
rename from common/env_fat.c
rename to env/fat.c
index b51c920..ec49c39 100644
--- a/common/env_fat.c
+++ b/env/fat.c
@@ -19,23 +19,22 @@
 #include <fat.h>
 #include <mmc.h>
 
-char *env_name_spec = "FAT";
-
-env_t *env_ptr;
+#ifdef CONFIG_SPL_BUILD
+/* TODO(sjg@chromium.org): Figure out why this is needed */
+# if !defined(CONFIG_TARGET_AM335X_EVM) || defined(CONFIG_SPL_OS_BOOT)
+#  define LOADENV
+# endif
+#else
+# define LOADENV
+# if defined(CONFIG_CMD_SAVEENV)
+#  define CMD_SAVEENV
+# endif
+#endif
 
 DECLARE_GLOBAL_DATA_PTR;
 
-int env_init(void)
-{
-	/* use default */
-	gd->env_addr = (ulong)&default_environment[0];
-	gd->env_valid = 1;
-
-	return 0;
-}
-
-#ifdef CONFIG_CMD_SAVEENV
-int saveenv(void)
+#ifdef CMD_SAVEENV
+static int env_fat_save(void)
 {
 	env_t	env_new;
 	struct blk_desc *dev_desc = NULL;
@@ -72,9 +71,10 @@
 	puts("done\n");
 	return 0;
 }
-#endif /* CONFIG_CMD_SAVEENV */
+#endif /* CMD_SAVEENV */
 
-void env_relocate_spec(void)
+#ifdef LOADENV
+static int env_fat_load(void)
 {
 	ALLOC_CACHE_ALIGN_BUFFER(char, buf, CONFIG_ENV_SIZE);
 	struct blk_desc *dev_desc = NULL;
@@ -103,8 +103,22 @@
 	}
 
 	env_import(buf, 1);
-	return;
+	return 0;
 
 err_env_relocate:
 	set_default_env(NULL);
+
+	return -EIO;
 }
+#endif /* LOADENV */
+
+U_BOOT_ENV_LOCATION(fat) = {
+	.location	= ENVL_FAT,
+	ENV_NAME("FAT")
+#ifdef LOADENV
+	.load		= env_fat_load,
+#endif
+#ifdef CMD_SAVEENV
+	.save		= env_save_ptr(env_fat_save),
+#endif
+};
diff --git a/common/env_flags.c b/env/flags.c
similarity index 97%
rename from common/env_flags.c
rename to env/flags.c
index 3c50620..4b0ddb6 100644
--- a/common/env_flags.c
+++ b/env/flags.c
@@ -15,7 +15,7 @@
 #include "fw_env.h"
 #include <env_attr.h>
 #include <env_flags.h>
-#define getenv fw_getenv
+#define env_get fw_getenv
 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
 #else
 #include <common.h>
@@ -308,7 +308,7 @@
  */
 enum env_flags_vartype env_flags_get_type(const char *name)
 {
-	const char *flags_list = getenv(ENV_FLAGS_VAR);
+	const char *flags_list = env_get(ENV_FLAGS_VAR);
 	char flags[ENV_FLAGS_ATTR_MAX_LEN + 1];
 
 	if (env_flags_lookup(flags_list, name, flags))
@@ -325,7 +325,7 @@
  */
 enum env_flags_varaccess env_flags_get_varaccess(const char *name)
 {
-	const char *flags_list = getenv(ENV_FLAGS_VAR);
+	const char *flags_list = env_get(ENV_FLAGS_VAR);
 	char flags[ENV_FLAGS_ATTR_MAX_LEN + 1];
 
 	if (env_flags_lookup(flags_list, name, flags))
@@ -426,7 +426,7 @@
 	int ret = 1;
 
 	if (first_call) {
-		flags_list = getenv(ENV_FLAGS_VAR);
+		flags_list = env_get(ENV_FLAGS_VAR);
 		first_call = 0;
 	}
 	/* look in the ".flags" and static for a reference to this variable */
@@ -541,7 +541,7 @@
 			return 1;
 		} else if (item->flags &
 		    ENV_FLAGS_VARACCESS_PREVENT_NONDEF_OVERWR) {
-			const char *defval = getenv_default(name);
+			const char *defval = env_get_default(name);
 
 			if (defval == NULL)
 				defval = "";
diff --git a/common/env_flash.c b/env/flash.c
similarity index 79%
rename from common/env_flash.c
rename to env/flash.c
index 004e884..b60be57 100644
--- a/common/env_flash.c
+++ b/env/flash.c
@@ -20,10 +20,12 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#if defined(CONFIG_CMD_SAVEENV) && defined(CONFIG_CMD_FLASH)
-#define CMD_SAVEENV
-#elif defined(CONFIG_ENV_ADDR_REDUND)
-#error CONFIG_ENV_ADDR_REDUND must have CONFIG_CMD_SAVEENV & CONFIG_CMD_FLASH
+#ifndef CONFIG_SPL_BUILD
+# if defined(CONFIG_CMD_SAVEENV) && defined(CONFIG_CMD_FLASH)
+#  define CMD_SAVEENV
+# elif defined(CONFIG_ENV_ADDR_REDUND)
+#  error CONFIG_ENV_ADDR_REDUND must have CONFIG_CMD_SAVEENV & CONFIG_CMD_FLASH
+# endif
 #endif
 
 #if defined(CONFIG_ENV_SIZE_REDUND) &&	\
@@ -31,34 +33,45 @@
 #error CONFIG_ENV_SIZE_REDUND should not be less then CONFIG_ENV_SIZE
 #endif
 
-char *env_name_spec = "Flash";
+/* TODO(sjg@chromium.org): Figure out all these special cases */
+#if (!defined(CONFIG_MICROBLAZE) && !defined(CONFIG_ARCH_ZYNQ) && \
+	!defined(CONFIG_TARGET_MCCMON6) && !defined(CONFIG_TARGET_X600) && \
+	!defined(CONFIG_TARGET_EDMINIV2)) || \
+	!defined(CONFIG_SPL_BUILD)
+#define LOADENV
+#endif
+
+#if !defined(CONFIG_TARGET_X600) || !defined(CONFIG_SPL_BUILD)
+#define INITENV
+#endif
 
 #ifdef ENV_IS_EMBEDDED
 env_t *env_ptr = &environment;
 
-static env_t *flash_addr = (env_t *)CONFIG_ENV_ADDR;
+static __maybe_unused env_t *flash_addr = (env_t *)CONFIG_ENV_ADDR;
 
 #else /* ! ENV_IS_EMBEDDED */
 
 env_t *env_ptr = (env_t *)CONFIG_ENV_ADDR;
-static env_t *flash_addr = (env_t *)CONFIG_ENV_ADDR;
+static __maybe_unused env_t *flash_addr = (env_t *)CONFIG_ENV_ADDR;
 #endif /* ENV_IS_EMBEDDED */
 
-#if defined(CMD_SAVEENV) || defined(CONFIG_ENV_ADDR_REDUND)
 /* CONFIG_ENV_ADDR is supposed to be on sector boundary */
-static ulong end_addr = CONFIG_ENV_ADDR + CONFIG_ENV_SECT_SIZE - 1;
-#endif
+static ulong __maybe_unused end_addr =
+		CONFIG_ENV_ADDR + CONFIG_ENV_SECT_SIZE - 1;
 
 #ifdef CONFIG_ENV_ADDR_REDUND
-static env_t *flash_addr_new = (env_t *)CONFIG_ENV_ADDR_REDUND;
+
+static env_t __maybe_unused *flash_addr_new = (env_t *)CONFIG_ENV_ADDR_REDUND;
 
 /* CONFIG_ENV_ADDR_REDUND is supposed to be on sector boundary */
-static ulong end_addr_new = CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SECT_SIZE - 1;
+static ulong __maybe_unused end_addr_new =
+		CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SECT_SIZE - 1;
 #endif /* CONFIG_ENV_ADDR_REDUND */
 
-
 #ifdef CONFIG_ENV_ADDR_REDUND
-int env_init(void)
+#ifdef INITENV
+static int env_flash_init(void)
 {
 	int crc1_ok = 0, crc2_ok = 0;
 
@@ -75,35 +88,36 @@
 
 	if (crc1_ok && !crc2_ok) {
 		gd->env_addr	= addr1;
-		gd->env_valid	= 1;
+		gd->env_valid	= ENV_VALID;
 	} else if (!crc1_ok && crc2_ok) {
 		gd->env_addr	= addr2;
-		gd->env_valid	= 1;
+		gd->env_valid	= ENV_VALID;
 	} else if (!crc1_ok && !crc2_ok) {
 		gd->env_addr	= addr_default;
 		gd->env_valid	= 0;
 	} else if (flag1 == ACTIVE_FLAG && flag2 == OBSOLETE_FLAG) {
 		gd->env_addr	= addr1;
-		gd->env_valid	= 1;
+		gd->env_valid	= ENV_VALID;
 	} else if (flag1 == OBSOLETE_FLAG && flag2 == ACTIVE_FLAG) {
 		gd->env_addr	= addr2;
-		gd->env_valid	= 1;
+		gd->env_valid	= ENV_VALID;
 	} else if (flag1 == flag2) {
 		gd->env_addr	= addr1;
-		gd->env_valid	= 2;
+		gd->env_valid	= ENV_REDUND;
 	} else if (flag1 == 0xFF) {
 		gd->env_addr	= addr1;
-		gd->env_valid	= 2;
+		gd->env_valid	= ENV_REDUND;
 	} else if (flag2 == 0xFF) {
 		gd->env_addr	= addr2;
-		gd->env_valid	= 2;
+		gd->env_valid	= ENV_REDUND;
 	}
 
 	return 0;
 }
+#endif
 
 #ifdef CMD_SAVEENV
-int saveenv(void)
+static int env_flash_save(void)
 {
 	env_t	env_new;
 	char	*saved_data = NULL;
@@ -207,11 +221,12 @@
 
 #else /* ! CONFIG_ENV_ADDR_REDUND */
 
-int env_init(void)
+#ifdef INITENV
+static int env_flash_init(void)
 {
 	if (crc32(0, env_ptr->data, ENV_SIZE) == env_ptr->crc) {
 		gd->env_addr	= (ulong)&(env_ptr->data);
-		gd->env_valid	= 1;
+		gd->env_valid	= ENV_VALID;
 		return 0;
 	}
 
@@ -219,9 +234,10 @@
 	gd->env_valid	= 0;
 	return 0;
 }
+#endif
 
 #ifdef CMD_SAVEENV
-int saveenv(void)
+static int env_flash_save(void)
 {
 	env_t	env_new;
 	int	rc = 1;
@@ -291,7 +307,8 @@
 
 #endif /* CONFIG_ENV_ADDR_REDUND */
 
-void env_relocate_spec(void)
+#ifdef LOADENV
+static int env_flash_load(void)
 {
 #ifdef CONFIG_ENV_ADDR_REDUND
 	if (gd->env_addr != (ulong)&(flash_addr->data)) {
@@ -309,7 +326,7 @@
 	    crc32(0, flash_addr_new->data, ENV_SIZE) == flash_addr_new->crc) {
 		char flag = OBSOLETE_FLAG;
 
-		gd->env_valid = 2;
+		gd->env_valid = ENV_REDUND;
 		flash_sect_protect(0, (ulong)flash_addr_new, end_addr_new);
 		flash_write(&flag,
 			    (ulong)&(flash_addr_new->flags),
@@ -321,7 +338,7 @@
 	    (flash_addr->flags & ACTIVE_FLAG) == ACTIVE_FLAG) {
 		char flag = ACTIVE_FLAG;
 
-		gd->env_valid = 2;
+		gd->env_valid = ENV_REDUND;
 		flash_sect_protect(0, (ulong)flash_addr, end_addr);
 		flash_write(&flag,
 			    (ulong)&(flash_addr->flags),
@@ -329,10 +346,27 @@
 		flash_sect_protect(1, (ulong)flash_addr, end_addr);
 	}
 
-	if (gd->env_valid == 2)
+	if (gd->env_valid == ENV_REDUND)
 		puts("*** Warning - some problems detected "
 		     "reading environment; recovered successfully\n\n");
 #endif /* CONFIG_ENV_ADDR_REDUND */
 
 	env_import((char *)flash_addr, 1);
+
+	return 0;
 }
+#endif /* LOADENV */
+
+U_BOOT_ENV_LOCATION(flash) = {
+	.location	= ENVL_FLASH,
+	ENV_NAME("Flash")
+#ifdef LOADENV
+	.load		= env_flash_load,
+#endif
+#ifdef CMD_SAVEENV
+	.save		= env_save_ptr(env_flash_save),
+#endif
+#ifdef INITENV
+	.init		= env_flash_init,
+#endif
+};
diff --git a/common/env_mmc.c b/env/mmc.c
similarity index 89%
rename from common/env_mmc.c
rename to env/mmc.c
index bb760a0..3f3092d 100644
--- a/common/env_mmc.c
+++ b/env/mmc.c
@@ -23,14 +23,6 @@
 #error CONFIG_ENV_SIZE_REDUND should be the same as CONFIG_ENV_SIZE
 #endif
 
-char *env_name_spec = "MMC";
-
-#ifdef ENV_IS_EMBEDDED
-env_t *env_ptr = &environment;
-#else /* ! ENV_IS_EMBEDDED */
-env_t *env_ptr;
-#endif /* ENV_IS_EMBEDDED */
-
 DECLARE_GLOBAL_DATA_PTR;
 
 #if !defined(CONFIG_ENV_OFFSET)
@@ -82,15 +74,6 @@
 	return CONFIG_SYS_MMC_ENV_DEV;
 }
 
-int env_init(void)
-{
-	/* use default */
-	gd->env_addr	= (ulong)&default_environment[0];
-	gd->env_valid	= 1;
-
-	return 0;
-}
-
 #ifdef CONFIG_SYS_MMC_ENV_PART
 __weak uint mmc_get_env_part(struct mmc *mmc)
 {
@@ -145,7 +128,7 @@
 #endif
 }
 
-#ifdef CONFIG_CMD_SAVEENV
+#if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_SPL_BUILD)
 static inline int write_env(struct mmc *mmc, unsigned long size,
 			    unsigned long offset, const void *buffer)
 {
@@ -160,7 +143,7 @@
 	return (n == blk_cnt) ? 0 : -1;
 }
 
-int saveenv(void)
+static int env_mmc_save(void)
 {
 	ALLOC_CACHE_ALIGN_BUFFER(env_t, env_new, 1);
 	int dev = mmc_get_env_dev();
@@ -180,7 +163,7 @@
 		goto fini;
 
 #ifdef CONFIG_ENV_OFFSET_REDUND
-	if (gd->env_valid == 1)
+	if (gd->env_valid == ENV_VALID)
 		copy = 1;
 #endif
 
@@ -200,14 +183,14 @@
 	ret = 0;
 
 #ifdef CONFIG_ENV_OFFSET_REDUND
-	gd->env_valid = gd->env_valid == 2 ? 1 : 2;
+	gd->env_valid = gd->env_valid == ENV_REDUND ? ENV_VALID : ENV_REDUND;
 #endif
 
 fini:
 	fini_mmc_for_env(mmc);
 	return ret;
 }
-#endif /* CONFIG_CMD_SAVEENV */
+#endif /* CONFIG_CMD_SAVEENV && !CONFIG_SPL_BUILD */
 
 static inline int read_env(struct mmc *mmc, unsigned long size,
 			   unsigned long offset, const void *buffer)
@@ -224,7 +207,7 @@
 }
 
 #ifdef CONFIG_ENV_OFFSET_REDUND
-void env_relocate_spec(void)
+static int env_mmc_load(void)
 {
 #if !defined(ENV_IS_EMBEDDED)
 	struct mmc *mmc;
@@ -241,13 +224,13 @@
 
 	errmsg = init_mmc_for_env(mmc);
 	if (errmsg) {
-		ret = 1;
+		ret = -EIO;
 		goto err;
 	}
 
 	if (mmc_get_env_addr(mmc, 0, &offset1) ||
 	    mmc_get_env_addr(mmc, 1, &offset2)) {
-		ret = 1;
+		ret = -EIO;
 		goto fini;
 	}
 
@@ -262,13 +245,13 @@
 
 	if (read1_fail && read2_fail) {
 		errmsg = "!bad CRC";
-		ret = 1;
+		ret = -EIO;
 		goto fini;
 	} else if (!read1_fail && read2_fail) {
-		gd->env_valid = 1;
+		gd->env_valid = ENV_VALID;
 		env_import((char *)tmp_env1, 1);
 	} else if (read1_fail && !read2_fail) {
-		gd->env_valid = 2;
+		gd->env_valid = ENV_REDUND;
 		env_import((char *)tmp_env2, 1);
 	} else {
 		env_import_redund((char *)tmp_env1, (char *)tmp_env2);
@@ -281,10 +264,12 @@
 err:
 	if (ret)
 		set_default_env(errmsg);
+
 #endif
+	return ret;
 }
 #else /* ! CONFIG_ENV_OFFSET_REDUND */
-void env_relocate_spec(void)
+static int env_mmc_load(void)
 {
 #if !defined(ENV_IS_EMBEDDED)
 	ALLOC_CACHE_ALIGN_BUFFER(char, buf, CONFIG_ENV_SIZE);
@@ -298,18 +283,18 @@
 
 	errmsg = init_mmc_for_env(mmc);
 	if (errmsg) {
-		ret = 1;
+		ret = -EIO;
 		goto err;
 	}
 
 	if (mmc_get_env_addr(mmc, 0, &offset)) {
-		ret = 1;
+		ret = -EIO;
 		goto fini;
 	}
 
 	if (read_env(mmc, CONFIG_ENV_SIZE, offset, buf)) {
 		errmsg = "!read failed";
-		ret = 1;
+		ret = -EIO;
 		goto fini;
 	}
 
@@ -322,5 +307,15 @@
 	if (ret)
 		set_default_env(errmsg);
 #endif
+	return ret;
 }
 #endif /* CONFIG_ENV_OFFSET_REDUND */
+
+U_BOOT_ENV_LOCATION(mmc) = {
+	.location	= ENVL_MMC,
+	ENV_NAME("MMC")
+	.load		= env_mmc_load,
+#ifndef CONFIG_SPL_BUILD
+	.save		= env_save_ptr(env_mmc_save),
+#endif
+};
diff --git a/common/env_nand.c b/env/nand.c
similarity index 87%
rename from common/env_nand.c
rename to env/nand.c
index 760f685..dea7b00 100644
--- a/common/env_nand.c
+++ b/env/nand.c
@@ -24,7 +24,8 @@
 #include <search.h>
 #include <errno.h>
 
-#if defined(CONFIG_CMD_SAVEENV) && defined(CONFIG_CMD_NAND)
+#if defined(CONFIG_CMD_SAVEENV) && defined(CONFIG_CMD_NAND) && \
+		!defined(CONFIG_SPL_BUILD)
 #define CMD_SAVEENV
 #elif defined(CONFIG_ENV_OFFSET_REDUND)
 #error CONFIG_ENV_OFFSET_REDUND must have CONFIG_CMD_SAVEENV & CONFIG_CMD_NAND
@@ -39,8 +40,6 @@
 #define CONFIG_ENV_RANGE	CONFIG_ENV_SIZE
 #endif
 
-char *env_name_spec = "NAND";
-
 #if defined(ENV_IS_EMBEDDED)
 env_t *env_ptr = &environment;
 #elif defined(CONFIG_NAND_ENV_DST)
@@ -63,7 +62,7 @@
  * This way the SPL loads not only the U-Boot image from NAND but
  * also the environment.
  */
-int env_init(void)
+static int env_nand_init(void)
 {
 #if defined(ENV_IS_EMBEDDED) || defined(CONFIG_NAND_ENV_DST)
 	int crc1_ok = 0, crc2_ok = 0;
@@ -84,37 +83,37 @@
 
 		return 0;
 	} else if (crc1_ok && !crc2_ok) {
-		gd->env_valid = 1;
+		gd->env_valid = ENV_VALID;
 	}
 #ifdef CONFIG_ENV_OFFSET_REDUND
 	else if (!crc1_ok && crc2_ok) {
-		gd->env_valid = 2;
+		gd->env_valid = ENV_REDUND;
 	} else {
 		/* both ok - check serial */
 		if (tmp_env1->flags == 255 && tmp_env2->flags == 0)
-			gd->env_valid = 2;
+			gd->env_valid = ENV_REDUND;
 		else if (tmp_env2->flags == 255 && tmp_env1->flags == 0)
-			gd->env_valid = 1;
+			gd->env_valid = ENV_VALID;
 		else if (tmp_env1->flags > tmp_env2->flags)
-			gd->env_valid = 1;
+			gd->env_valid = ENV_VALID;
 		else if (tmp_env2->flags > tmp_env1->flags)
-			gd->env_valid = 2;
+			gd->env_valid = ENV_REDUND;
 		else /* flags are equal - almost impossible */
-			gd->env_valid = 1;
+			gd->env_valid = ENV_VALID;
 	}
 
-	if (gd->env_valid == 2)
+	if (gd->env_valid == ENV_REDUND)
 		env_ptr = tmp_env2;
 	else
 #endif
-	if (gd->env_valid == 1)
+	if (gd->env_valid == ENV_VALID)
 		env_ptr = tmp_env1;
 
 	gd->env_addr = (ulong)env_ptr->data;
 
 #else /* ENV_IS_EMBEDDED || CONFIG_NAND_ENV_DST */
 	gd->env_addr	= (ulong)&default_environment[0];
-	gd->env_valid	= 1;
+	gd->env_valid	= ENV_VALID;
 #endif /* ENV_IS_EMBEDDED || CONFIG_NAND_ENV_DST */
 
 	return 0;
@@ -158,12 +157,12 @@
 	return 0;
 }
 
-struct env_location {
+struct nand_env_location {
 	const char *name;
 	const nand_erase_options_t erase_opts;
 };
 
-static int erase_and_write_env(const struct env_location *location,
+static int erase_and_write_env(const struct nand_env_location *location,
 		u_char *env_new)
 {
 	struct mtd_info *mtd;
@@ -184,12 +183,12 @@
 	return ret;
 }
 
-int saveenv(void)
+static int env_nand_save(void)
 {
 	int	ret = 0;
 	ALLOC_CACHE_ALIGN_BUFFER(env_t, env_new, 1);
 	int	env_idx = 0;
-	static const struct env_location location[] = {
+	static const struct nand_env_location location[] = {
 		{
 			.name = "NAND",
 			.erase_opts = {
@@ -217,14 +216,15 @@
 		return ret;
 
 #ifdef CONFIG_ENV_OFFSET_REDUND
-	env_idx = (gd->env_valid == 1);
+	env_idx = (gd->env_valid == ENV_VALID);
 #endif
 
 	ret = erase_and_write_env(&location[env_idx], (u_char *)env_new);
 #ifdef CONFIG_ENV_OFFSET_REDUND
 	if (!ret) {
 		/* preset other copy for next write */
-		gd->env_valid = gd->env_valid == 2 ? 1 : 2;
+		gd->env_valid = gd->env_valid == ENV_REDUND ? ENV_VALID :
+				ENV_REDUND;
 		return ret;
 	}
 
@@ -302,7 +302,7 @@
 	}
 
 	if (oob_buf[0] == ENV_OOB_MARKER) {
-		*result = oob_buf[1] * mtd->erasesize;
+		*result = ovoid ob_buf[1] * mtd->erasesize;
 	} else if (oob_buf[0] == ENV_OOB_MARKER_OLD) {
 		*result = oob_buf[1];
 	} else {
@@ -315,17 +315,21 @@
 #endif
 
 #ifdef CONFIG_ENV_OFFSET_REDUND
-void env_relocate_spec(void)
+static int env_nand_load(void)
 {
-#if !defined(ENV_IS_EMBEDDED)
+#if defined(ENV_IS_EMBEDDED)
+	return 0;
+#else
 	int read1_fail = 0, read2_fail = 0;
 	env_t *tmp_env1, *tmp_env2;
+	int ret = 0;
 
 	tmp_env1 = (env_t *)malloc(CONFIG_ENV_SIZE);
 	tmp_env2 = (env_t *)malloc(CONFIG_ENV_SIZE);
 	if (tmp_env1 == NULL || tmp_env2 == NULL) {
 		puts("Can't allocate buffers for environment\n");
 		set_default_env("!malloc() failed");
+		ret = -EIO;
 		goto done;
 	}
 
@@ -342,10 +346,10 @@
 		set_default_env("!bad env area");
 		goto done;
 	} else if (!read1_fail && read2_fail) {
-		gd->env_valid = 1;
+		gd->env_valid = ENV_VALID;
 		env_import((char *)tmp_env1, 1);
 	} else if (read1_fail && !read2_fail) {
-		gd->env_valid = 2;
+		gd->env_valid = ENV_REDUND;
 		env_import((char *)tmp_env2, 1);
 	} else {
 		env_import_redund((char *)tmp_env1, (char *)tmp_env2);
@@ -355,6 +359,7 @@
 	free(tmp_env1);
 	free(tmp_env2);
 
+	return ret;
 #endif /* ! ENV_IS_EMBEDDED */
 }
 #else /* ! CONFIG_ENV_OFFSET_REDUND */
@@ -363,7 +368,7 @@
  * device i.e., nand_dev_desc + 0. This is also the behaviour using
  * the new NAND code.
  */
-void env_relocate_spec(void)
+static int env_nand_load(void)
 {
 #if !defined(ENV_IS_EMBEDDED)
 	int ret;
@@ -386,10 +391,22 @@
 	ret = readenv(CONFIG_ENV_OFFSET, (u_char *)buf);
 	if (ret) {
 		set_default_env("!readenv() failed");
-		return;
+		return -EIO;
 	}
 
 	env_import(buf, 1);
 #endif /* ! ENV_IS_EMBEDDED */
+
+	return 0;
 }
 #endif /* CONFIG_ENV_OFFSET_REDUND */
+
+U_BOOT_ENV_LOCATION(nand) = {
+	.location	= ENVL_NAND,
+	ENV_NAME("NAND")
+	.load		= env_nand_load,
+#if defined(CMD_SAVEENV)
+	.save		= env_save_ptr(env_nand_save),
+#endif
+	.init		= env_nand_init,
+};
diff --git a/env/nowhere.c b/env/nowhere.c
new file mode 100644
index 0000000..d60de49
--- /dev/null
+++ b/env/nowhere.c
@@ -0,0 +1,21 @@
+/*
+ * (C) Copyright 2000-2010
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * (C) Copyright 2001 Sysgo Real-Time Solutions, GmbH <www.elinos.com>
+ * Andreas Heppel <aheppel@sysgo.de>
+
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <common.h>
+#include <command.h>
+#include <environment.h>
+#include <linux/stddef.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+U_BOOT_ENV_LOCATION(nowhere) = {
+	.location	= ENVL_NOWHERE,
+	ENV_NAME("nowhere")
+};
diff --git a/common/env_nvram.c b/env/nvram.c
similarity index 85%
rename from common/env_nvram.c
rename to env/nvram.c
index 524f07d..5fb3115 100644
--- a/common/env_nvram.c
+++ b/env/nvram.c
@@ -36,15 +36,12 @@
 #ifdef CONFIG_SYS_NVRAM_ACCESS_ROUTINE
 extern void *nvram_read(void *dest, const long src, size_t count);
 extern void nvram_write(long dest, const void *src, size_t count);
-env_t *env_ptr;
 #else
 env_t *env_ptr = (env_t *)CONFIG_ENV_ADDR;
 #endif
 
-char *env_name_spec = "NVRAM";
-
 #ifdef CONFIG_SYS_NVRAM_ACCESS_ROUTINE
-uchar env_get_char_spec(int index)
+static int env_nvram_get_char(int index)
 {
 	uchar c;
 
@@ -54,7 +51,7 @@
 }
 #endif
 
-void env_relocate_spec(void)
+static int env_nvram_load(void)
 {
 	char buf[CONFIG_ENV_SIZE];
 
@@ -64,9 +61,11 @@
 	memcpy(buf, (void *)CONFIG_ENV_ADDR, CONFIG_ENV_SIZE);
 #endif
 	env_import(buf, 1);
+
+	return 0;
 }
 
-int saveenv(void)
+static int env_nvram_save(void)
 {
 	env_t	env_new;
 	int	rcode = 0;
@@ -89,7 +88,7 @@
  *
  * We are still running from ROM, so data use is limited
  */
-int env_init(void)
+static int env_nvram_init(void)
 {
 #if defined(CONFIG_SYS_NVRAM_ACCESS_ROUTINE)
 	ulong crc;
@@ -104,7 +103,7 @@
 	if (crc32(0, env_ptr->data, ENV_SIZE) == env_ptr->crc) {
 		gd->env_addr	= (ulong)&env_ptr->data;
 #endif
-		gd->env_valid	= 1;
+		gd->env_valid = ENV_VALID;
 	} else {
 		gd->env_addr	= (ulong)&default_environment[0];
 		gd->env_valid	= 0;
@@ -112,3 +111,14 @@
 
 	return 0;
 }
+
+U_BOOT_ENV_LOCATION(nvram) = {
+	.location	= ENVL_NVRAM,
+	ENV_NAME("NVRAM")
+#ifdef CONFIG_SYS_NVRAM_ACCESS_ROUTINE
+	.get_char	= env_nvram_get_char,
+#endif
+	.load		= env_nvram_load,
+	.save		= env_save_ptr(env_nvram_save),
+	.init		= env_nvram_init,
+};
diff --git a/common/env_onenand.c b/env/onenand.c
similarity index 88%
rename from common/env_onenand.c
rename to env/onenand.c
index cc3d670..2e3045c 100644
--- a/common/env_onenand.c
+++ b/env/onenand.c
@@ -21,14 +21,12 @@
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/onenand.h>
 
-char *env_name_spec = "OneNAND";
-
 #define ONENAND_MAX_ENV_SIZE	CONFIG_ENV_SIZE
 #define ONENAND_ENV_SIZE(mtd)	(ONENAND_MAX_ENV_SIZE - ENV_HEADER_SIZE)
 
 DECLARE_GLOBAL_DATA_PTR;
 
-void env_relocate_spec(void)
+static int env_onenand_load(void)
 {
 	struct mtd_info *mtd = &onenand_mtd;
 #ifdef CONFIG_ENV_ADDR_FLEX
@@ -60,10 +58,12 @@
 
 	rc = env_import(buf, 1);
 	if (rc)
-		gd->env_valid = 1;
+		gd->env_valid = ENV_VALID;
+
+	return rc ? 0 : -EIO;
 }
 
-int saveenv(void)
+static int env_onenand_save(void)
 {
 	env_t	env_new;
 	int ret;
@@ -106,11 +106,9 @@
 	return 0;
 }
 
-int env_init(void)
-{
-	/* use default */
-	gd->env_addr = (ulong)&default_environment[0];
-	gd->env_valid = 1;
-
-	return 0;
-}
+U_BOOT_ENV_LOCATION(onenand) = {
+	.location	= ENVL_ONENAND,
+	ENV_NAME("OneNAND")
+	.load		= env_onenand_load,
+	.save		= env_save_ptr(env_onenand_save),
+};
diff --git a/common/env_remote.c b/env/remote.c
similarity index 72%
rename from common/env_remote.c
rename to env/remote.c
index eb977ee..c013fdd 100644
--- a/common/env_remote.c
+++ b/env/remote.c
@@ -11,8 +11,6 @@
 #include <environment.h>
 #include <linux/stddef.h>
 
-char *env_name_spec = "Remote";
-
 #ifdef ENV_IS_EMBEDDED
 env_t *env_ptr = &environment;
 #else /* ! ENV_IS_EMBEDDED */
@@ -25,21 +23,19 @@
 #define CONFIG_ENV_OFFSET 0
 #endif
 
-int env_init(void)
+static int env_remote_init(void)
 {
 	if (crc32(0, env_ptr->data, ENV_SIZE) == env_ptr->crc) {
 		gd->env_addr = (ulong)&(env_ptr->data);
-		gd->env_valid = 1;
+		gd->env_valid = ENV_VALID;
 		return 0;
 	}
 
-	gd->env_addr = (ulong)default_environment;
-	gd->env_valid = 0;
-	return 0;
+	return -ENOENT;
 }
 
 #ifdef CONFIG_CMD_SAVEENV
-int saveenv(void)
+static int env_remote_save(void)
 {
 #ifdef CONFIG_SRIO_PCIE_BOOT_SLAVE
 	printf("Can not support the 'saveenv' when boot from SRIO or PCIE!\n");
@@ -50,9 +46,19 @@
 }
 #endif /* CONFIG_CMD_SAVEENV */
 
-void env_relocate_spec(void)
+static int env_remote_load(void)
 {
 #ifndef ENV_IS_EMBEDDED
 	env_import((char *)env_ptr, 1);
 #endif
+
+	return 0;
 }
+
+U_BOOT_ENV_LOCATION(remote) = {
+	.location	= ENVL_REMOTE,
+	ENV_NAME("Remote")
+	.load		= env_remote_load,
+	.save		= env_save_ptr(env_remote_save),
+	.init		= env_remote_init,
+};
diff --git a/common/env_sata.c b/env/sata.c
similarity index 83%
rename from common/env_sata.c
rename to env/sata.c
index b0cee35..a770297 100644
--- a/common/env_sata.c
+++ b/env/sata.c
@@ -24,8 +24,6 @@
 #error CONFIG_ENV_OFFSET or CONFIG_ENV_SIZE not defined
 #endif
 
-char *env_name_spec = "SATA";
-
 DECLARE_GLOBAL_DATA_PTR;
 
 __weak int sata_get_env_dev(void)
@@ -33,15 +31,6 @@
 	return CONFIG_SYS_SATA_ENV_DEV;
 }
 
-int env_init(void)
-{
-	/* use default */
-	gd->env_addr = (ulong)&default_environment[0];
-	gd->env_valid = 1;
-
-	return 0;
-}
-
 #ifdef CONFIG_CMD_SAVEENV
 static inline int write_env(struct blk_desc *sata, unsigned long size,
 			    unsigned long offset, void *buffer)
@@ -56,7 +45,7 @@
 	return (n == blk_cnt) ? 0 : -1;
 }
 
-int saveenv(void)
+static int env_sata_save(void)
 {
 	ALLOC_CACHE_ALIGN_BUFFER(env_t, env_new, 1);
 	struct blk_desc *sata = NULL;
@@ -102,26 +91,36 @@
 	return (n == blk_cnt) ? 0 : -1;
 }
 
-void env_relocate_spec(void)
+static void env_sata_load(void)
 {
 	ALLOC_CACHE_ALIGN_BUFFER(char, buf, CONFIG_ENV_SIZE);
 	struct blk_desc *sata = NULL;
 	int env_sata;
 
 	if (sata_initialize())
-		return;
+		return -EIO;
 
 	env_sata = sata_get_env_dev();
 
 	sata = sata_get_dev(env_sata);
 	if (sata == NULL) {
-		printf("Unknown SATA(%d) device for environment!\n",
-		       env_sata);
-		return;
+		printf("Unknown SATA(%d) device for environment!\n", env_sata);
+		return -EIO;
 	}
 
-	if (read_env(sata, CONFIG_ENV_SIZE, CONFIG_ENV_OFFSET, buf))
-		return set_default_env(NULL);
+	if (read_env(sata, CONFIG_ENV_SIZE, CONFIG_ENV_OFFSET, buf)) {
+		set_default_env(NULL);
+		return -EIO;
+	}
 
 	env_import(buf, 1);
+
+	return 0;
 }
+
+U_BOOT_ENV_LOCATION(sata) = {
+	.location	= ENVL_ESATA,
+	ENV_NAME("SATA")
+	.load		= env_sata_load,
+	.save		= env_save_ptr(env_sata_save),
+};
diff --git a/common/env_sf.c b/env/sf.c
similarity index 86%
rename from common/env_sf.c
rename to env/sf.c
index 45f441a..6f74371 100644
--- a/common/env_sf.c
+++ b/env/sf.c
@@ -32,9 +32,15 @@
 # define CONFIG_ENV_SPI_MODE	CONFIG_SF_DEFAULT_MODE
 #endif
 
+#ifndef CONFIG_SPL_BUILD
+#define CMD_SAVEENV
+#endif
+
 #ifdef CONFIG_ENV_OFFSET_REDUND
+#ifdef CMD_SAVEENV
 static ulong env_offset		= CONFIG_ENV_OFFSET;
 static ulong env_new_offset	= CONFIG_ENV_OFFSET_REDUND;
+#endif
 
 #define ACTIVE_FLAG	1
 #define OBSOLETE_FLAG	0
@@ -42,8 +48,6 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-char *env_name_spec = "SPI Flash";
-
 static struct spi_flash *env_flash;
 
 static int setup_flash_device(void)
@@ -57,7 +61,7 @@
 				     0, 0, &new);
 	if (ret) {
 		set_default_env("!spi_flash_probe_bus_cs() failed");
-		return 1;
+		return ret;
 	}
 
 	env_flash = dev_get_uclass_priv(new);
@@ -69,7 +73,7 @@
 			CONFIG_ENV_SPI_MAX_HZ, CONFIG_ENV_SPI_MODE);
 		if (!env_flash) {
 			set_default_env("!spi_flash_probe() failed");
-			return 1;
+			return -EIO;
 		}
 	}
 #endif
@@ -77,7 +81,8 @@
 }
 
 #if defined(CONFIG_ENV_OFFSET_REDUND)
-int saveenv(void)
+#ifdef CMD_SAVEENV
+static int env_sf_save(void)
 {
 	env_t	env_new;
 	char	*saved_buffer = NULL, flag = OBSOLETE_FLAG;
@@ -90,10 +95,10 @@
 
 	ret = env_export(&env_new);
 	if (ret)
-		return ret;
+		return -EIO;
 	env_new.flags	= ACTIVE_FLAG;
 
-	if (gd->env_valid == 1) {
+	if (gd->env_valid == ENV_VALID) {
 		env_new_offset = CONFIG_ENV_OFFSET_REDUND;
 		env_offset = CONFIG_ENV_OFFSET;
 	} else {
@@ -107,7 +112,7 @@
 		saved_offset = env_new_offset + CONFIG_ENV_SIZE;
 		saved_buffer = memalign(ARCH_DMA_MINALIGN, saved_size);
 		if (!saved_buffer) {
-			ret = 1;
+			ret = -ENOMEM;
 			goto done;
 		}
 		ret = spi_flash_read(env_flash, saved_offset,
@@ -145,7 +150,7 @@
 
 	puts("done\n");
 
-	gd->env_valid = gd->env_valid == 2 ? 1 : 2;
+	gd->env_valid = gd->env_valid == ENV_REDUND ? ENV_VALID : ENV_REDUND;
 
 	printf("Valid environment: %d\n", (int)gd->env_valid);
 
@@ -155,8 +160,9 @@
 
 	return ret;
 }
+#endif /* CMD_SAVEENV */
 
-void env_relocate_spec(void)
+static int env_sf_load(void)
 {
 	int ret;
 	int crc1_ok = 0, crc2_ok = 0;
@@ -170,6 +176,7 @@
 			CONFIG_ENV_SIZE);
 	if (!tmp_env1 || !tmp_env2) {
 		set_default_env("!malloc() failed");
+		ret = -EIO;
 		goto out;
 	}
 
@@ -196,32 +203,33 @@
 
 	if (!crc1_ok && !crc2_ok) {
 		set_default_env("!bad CRC");
+		ret = -EIO;
 		goto err_read;
 	} else if (crc1_ok && !crc2_ok) {
-		gd->env_valid = 1;
+		gd->env_valid = ENV_VALID;
 	} else if (!crc1_ok && crc2_ok) {
-		gd->env_valid = 2;
+		gd->env_valid = ENV_REDUND;
 	} else if (tmp_env1->flags == ACTIVE_FLAG &&
 		   tmp_env2->flags == OBSOLETE_FLAG) {
-		gd->env_valid = 1;
+		gd->env_valid = ENV_VALID;
 	} else if (tmp_env1->flags == OBSOLETE_FLAG &&
 		   tmp_env2->flags == ACTIVE_FLAG) {
-		gd->env_valid = 2;
+		gd->env_valid = ENV_REDUND;
 	} else if (tmp_env1->flags == tmp_env2->flags) {
-		gd->env_valid = 1;
+		gd->env_valid = ENV_VALID;
 	} else if (tmp_env1->flags == 0xFF) {
-		gd->env_valid = 1;
+		gd->env_valid = ENV_VALID;
 	} else if (tmp_env2->flags == 0xFF) {
-		gd->env_valid = 2;
+		gd->env_valid = ENV_REDUND;
 	} else {
 		/*
 		 * this differs from code in env_flash.c, but I think a sane
 		 * default path is desirable.
 		 */
-		gd->env_valid = 1;
+		gd->env_valid = ENV_VALID;
 	}
 
-	if (gd->env_valid == 1)
+	if (gd->env_valid == ENV_VALID)
 		ep = tmp_env1;
 	else
 		ep = tmp_env2;
@@ -238,9 +246,12 @@
 out:
 	free(tmp_env1);
 	free(tmp_env2);
+
+	return ret;
 }
 #else
-int saveenv(void)
+#ifdef CMD_SAVEENV
+static int env_sf_save(void)
 {
 	u32	saved_size, saved_offset, sector;
 	char	*saved_buffer = NULL;
@@ -299,8 +310,9 @@
 
 	return ret;
 }
+#endif /* CMD_SAVEENV */
 
-void env_relocate_spec(void)
+static int env_sf_load(void)
 {
 	int ret;
 	char *buf = NULL;
@@ -308,7 +320,7 @@
 	buf = (char *)memalign(ARCH_DMA_MINALIGN, CONFIG_ENV_SIZE);
 	if (!buf) {
 		set_default_env("!malloc() failed");
-		return;
+		return -EIO;
 	}
 
 	ret = setup_flash_device();
@@ -324,21 +336,23 @@
 
 	ret = env_import(buf, 1);
 	if (ret)
-		gd->env_valid = 1;
+		gd->env_valid = ENV_VALID;
 
 err_read:
 	spi_flash_free(env_flash);
 	env_flash = NULL;
 out:
 	free(buf);
+
+	return ret;
 }
 #endif
 
-int env_init(void)
-{
-	/* SPI flash isn't usable before relocation */
-	gd->env_addr = (ulong)&default_environment[0];
-	gd->env_valid = 1;
-
-	return 0;
-}
+U_BOOT_ENV_LOCATION(sf) = {
+	.location	= ENVL_SPI_FLASH,
+	ENV_NAME("SPI Flash")
+	.load		= env_sf_load,
+#ifdef CMD_SAVEENV
+	.save		= env_save_ptr(env_sf_save),
+#endif
+};
diff --git a/common/env_ubi.c b/env/ubi.c
similarity index 90%
rename from common/env_ubi.c
rename to env/ubi.c
index 95b527d..1c4653d 100644
--- a/common/env_ubi.c
+++ b/env/ubi.c
@@ -16,24 +16,11 @@
 #include <ubi_uboot.h>
 #undef crc32
 
-char *env_name_spec = "UBI";
-
-env_t *env_ptr;
-
 DECLARE_GLOBAL_DATA_PTR;
 
-int env_init(void)
-{
-	/* use default */
-	gd->env_addr = (ulong)&default_environment[0];
-	gd->env_valid = 1;
-
-	return 0;
-}
-
 #ifdef CONFIG_CMD_SAVEENV
 #ifdef CONFIG_SYS_REDUNDAND_ENVIRONMENT
-int saveenv(void)
+static int env_ubi_save(void)
 {
 	ALLOC_CACHE_ALIGN_BUFFER(env_t, env_new, 1);
 	int ret;
@@ -48,7 +35,7 @@
 		return 1;
 	}
 
-	if (gd->env_valid == 1) {
+	if (gd->env_valid == ENV_VALID) {
 		puts("Writing to redundant UBI... ");
 		if (ubi_volume_write(CONFIG_ENV_UBI_VOLUME_REDUND,
 				     (void *)env_new, CONFIG_ENV_SIZE)) {
@@ -70,12 +57,12 @@
 
 	puts("done\n");
 
-	gd->env_valid = gd->env_valid == 2 ? 1 : 2;
+	gd->env_valid = gd->env_valid == ENV_REDUND ? ENV_VALID : ENV_REDUND;
 
 	return 0;
 }
 #else /* ! CONFIG_SYS_REDUNDAND_ENVIRONMENT */
-int saveenv(void)
+static int env_ubi_save(void)
 {
 	ALLOC_CACHE_ALIGN_BUFFER(env_t, env_new, 1);
 	int ret;
@@ -104,7 +91,7 @@
 #endif /* CONFIG_CMD_SAVEENV */
 
 #ifdef CONFIG_SYS_REDUNDAND_ENVIRONMENT
-void env_relocate_spec(void)
+static int env_ubi_load(void)
 {
 	ALLOC_CACHE_ALIGN_BUFFER(char, env1_buf, CONFIG_ENV_SIZE);
 	ALLOC_CACHE_ALIGN_BUFFER(char, env2_buf, CONFIG_ENV_SIZE);
@@ -128,7 +115,7 @@
 		printf("\n** Cannot find mtd partition \"%s\"\n",
 		       CONFIG_ENV_UBI_PART);
 		set_default_env(NULL);
-		return;
+		return -EIO;
 	}
 
 	if (ubi_volume_read(CONFIG_ENV_UBI_VOLUME, (void *)tmp_env1,
@@ -144,9 +131,11 @@
 	}
 
 	env_import_redund((char *)tmp_env1, (char *)tmp_env2);
+
+	return 0;
 }
 #else /* ! CONFIG_SYS_REDUNDAND_ENVIRONMENT */
-void env_relocate_spec(void)
+static int env_ubi_load(void)
 {
 	ALLOC_CACHE_ALIGN_BUFFER(char, buf, CONFIG_ENV_SIZE);
 
@@ -164,16 +153,24 @@
 		printf("\n** Cannot find mtd partition \"%s\"\n",
 		       CONFIG_ENV_UBI_PART);
 		set_default_env(NULL);
-		return;
+		return -EIO;
 	}
 
 	if (ubi_volume_read(CONFIG_ENV_UBI_VOLUME, buf, CONFIG_ENV_SIZE)) {
 		printf("\n** Unable to read env from %s:%s **\n",
 		       CONFIG_ENV_UBI_PART, CONFIG_ENV_UBI_VOLUME);
 		set_default_env(NULL);
-		return;
+		return -EIO;
 	}
 
 	env_import(buf, 1);
+
+	return 0;
 }
 #endif /* CONFIG_SYS_REDUNDAND_ENVIRONMENT */
+
+U_BOOT_ENV_LOCATION(ubi) = {
+	.location	= ENVL_UBI,
+	.load		= env_ubi_load,
+	.save		= env_save_ptr(env_ubi_save),
+};
diff --git a/fs/fs.c b/fs/fs.c
index 595ff1f..13cd362 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -348,7 +348,7 @@
 	if (fs_size(argv[3], &size) < 0)
 		return CMD_RET_FAILURE;
 
-	setenv_hex("filesize", size);
+	env_set_hex("filesize", size);
 
 	return 0;
 }
@@ -379,7 +379,7 @@
 		if (ep == argv[3] || *ep != '\0')
 			return CMD_RET_USAGE;
 	} else {
-		addr_str = getenv("loadaddr");
+		addr_str = env_get("loadaddr");
 		if (addr_str != NULL)
 			addr = simple_strtoul(addr_str, NULL, 16);
 		else
@@ -388,7 +388,7 @@
 	if (argc >= 5) {
 		filename = argv[4];
 	} else {
-		filename = getenv("bootfile");
+		filename = env_get("bootfile");
 		if (!filename) {
 			puts("** No boot file defined **\n");
 			return 1;
@@ -417,8 +417,8 @@
 	}
 	puts("\n");
 
-	setenv_hex("fileaddr", addr);
-	setenv_hex("filesize", len_read);
+	env_set_hex("fileaddr", addr);
+	env_set_hex("filesize", len_read);
 
 	return 0;
 }
@@ -509,7 +509,7 @@
 		return CMD_RET_FAILURE;
 
 	if (argc == 4)
-		setenv(argv[3], uuid);
+		env_set(argv[3], uuid);
 	else
 		printf("%s\n", uuid);
 
@@ -529,7 +529,7 @@
 	info = fs_get_info(fs_type);
 
 	if (argc == 4)
-		setenv(argv[3], info->name);
+		env_set(argv[3], info->name);
 	else
 		printf("%s\n", info->name);
 
diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
index db29489..8f1c9d1 100644
--- a/fs/ubifs/ubifs.c
+++ b/fs/ubifs/ubifs.c
@@ -941,7 +941,7 @@
 
 	err = ubifs_read(filename, (void *)(uintptr_t)addr, 0, size, &actread);
 	if (err == 0) {
-		setenv_hex("filesize", actread);
+		env_set_hex("filesize", actread);
 		printf("Done\n");
 	}
 
diff --git a/include/_exports.h b/include/_exports.h
index 6ff4364..5416041 100644
--- a/include/_exports.h
+++ b/include/_exports.h
@@ -31,8 +31,8 @@
 	EXPORT_FUNC(vprintf, int, vprintf, const char *, va_list)
 	EXPORT_FUNC(do_reset, int, do_reset, cmd_tbl_t *,
 		    int , int , char * const [])
-	EXPORT_FUNC(getenv, char  *, getenv, const char*)
-	EXPORT_FUNC(setenv, int, setenv, const char *, const char *)
+	EXPORT_FUNC(env_get, char  *, env_get, const char*)
+	EXPORT_FUNC(env_set, int, env_set, const char *, const char *)
 	EXPORT_FUNC(simple_strtoul, unsigned long, simple_strtoul,
 		    const char *, char **, unsigned int)
 	EXPORT_FUNC(strict_strtoul, int, strict_strtoul,
diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h
index 86bf656..944f581 100644
--- a/include/asm-generic/global_data.h
+++ b/include/asm-generic/global_data.h
@@ -49,7 +49,7 @@
 	unsigned long precon_buf_idx;	/* Pre-Console buffer index */
 #endif
 	unsigned long env_addr;		/* Address  of Environment struct */
-	unsigned long env_valid;	/* Checksum of Environment valid? */
+	unsigned long env_valid;	/* Environment valid? enum env_valid */
 
 	unsigned long ram_top;		/* Top address of RAM used by U-Boot */
 	unsigned long relocaddr;	/* Start address of U-Boot in RAM */
@@ -76,7 +76,7 @@
 	struct device_node *of_root;
 #endif
 	struct jt_funcs *jt;		/* jump table */
-	char env_buf[32];		/* buffer for getenv() before reloc. */
+	char env_buf[32];		/* buffer for env_get() before reloc. */
 #ifdef CONFIG_TRACE
 	void		*trace_buff;	/* The trace buffer */
 #endif
diff --git a/include/common.h b/include/common.h
index c8fb277..aaed131 100644
--- a/include/common.h
+++ b/include/common.h
@@ -311,16 +311,45 @@
 void	env_relocate (void);
 int	envmatch     (uchar *, int);
 
-/* Avoid unfortunate conflict with libc's getenv() */
-#ifdef CONFIG_SANDBOX
-#define getenv uboot_getenv
-#endif
-char	*getenv	     (const char *);
-int	getenv_f     (const char *name, char *buf, unsigned len);
-ulong getenv_ulong(const char *name, int base, ulong default_val);
+/**
+ * env_get() - Look up the value of an environment variable
+ *
+ * In U-Boot proper this can be called before relocation (which is when the
+ * environment is loaded from storage, i.e. GD_FLG_ENV_READY is 0). In that
+ * case this function calls env_get_f().
+ *
+ * @varname:	Variable to look up
+ * @return value of variable, or NULL if not found
+ */
+char *env_get(const char *varname);
 
 /**
- * getenv_hex() - Return an environment variable as a hex value
+ * env_get_f() - Look up the value of an environment variable (early)
+ *
+ * This function is called from env_get() if the environment has not been
+ * loaded yet (GD_FLG_ENV_READY flag is 0). Some environment locations will
+ * support reading the value (slowly) and some will not.
+ *
+ * @varname:	Variable to look up
+ * @return value of variable, or NULL if not found
+ */
+int env_get_f(const char *name, char *buf, unsigned len);
+
+/**
+ * env_get_ulong() - Return an environment variable as an integer value
+ *
+ * Most U-Boot environment variables store hex values. For those which store
+ * (e.g.) base-10 integers, this function can be used to read the value.
+ *
+ * @name:	Variable to look up
+ * @base:	Base to use (e.g. 10 for base 10, 2 for binary)
+ * @default_val: Default value to return if no value is found
+ * @return the value found, or @default_val if none
+ */
+ulong env_get_ulong(const char *name, int base, ulong default_val);
+
+/**
+ * env_get_hex() - Return an environment variable as a hex value
  *
  * Decode an environment as a hex number (it may or may not have a 0x
  * prefix). If the environment variable cannot be found, or does not start
@@ -329,27 +358,54 @@
  * @varname:		Variable to decode
  * @default_val:	Value to return on error
  */
-ulong getenv_hex(const char *varname, ulong default_val);
+ulong env_get_hex(const char *varname, ulong default_val);
 
 /*
  * Read an environment variable as a boolean
  * Return -1 if variable does not exist (default to true)
  */
-int getenv_yesno(const char *var);
-int	saveenv	     (void);
-int	setenv	     (const char *, const char *);
-int setenv_ulong(const char *varname, ulong value);
-int setenv_hex(const char *varname, ulong value);
+int env_get_yesno(const char *var);
+
 /**
- * setenv_addr - Set an environment variable to an address in hex
+ * env_set() - set an environment variable
+ *
+ * This sets or deletes the value of an environment variable. For setting the
+ * value the variable is created if it does not already exist.
+ *
+ * @varname: Variable to adjust
+ * @value: Value to set for the variable, or NULL or "" to delete the variable
+ * @return 0 if OK, 1 on error
+ */
+int env_set(const char *varname, const char *value);
+
+/**
+ * env_set_ulong() - set an environment variable to an integer
+ *
+ * @varname: Variable to adjust
+ * @value: Value to set for the variable (will be converted to a string)
+ * @return 0 if OK, 1 on error
+ */
+int env_set_ulong(const char *varname, ulong value);
+
+/**
+ * env_set_hex() - set an environment variable to a hex value
+ *
+ * @varname: Variable to adjust
+ * @value: Value to set for the variable (will be converted to a hex string)
+ * @return 0 if OK, 1 on error
+ */
+int env_set_hex(const char *varname, ulong value);
+
+/**
+ * env_set_addr - Set an environment variable to an address in hex
  *
  * @varname:	Environment variable to set
  * @addr:	Value to set it to
  * @return 0 if ok, 1 on error
  */
-static inline int setenv_addr(const char *varname, const void *addr)
+static inline int env_set_addr(const char *varname, const void *addr)
 {
-	return setenv_hex(varname, (ulong)addr);
+	return env_set_hex(varname, (ulong)addr);
 }
 
 #ifdef CONFIG_AUTO_COMPLETE
@@ -693,9 +749,9 @@
 
 /* lib/net_utils.c */
 #include <net.h>
-static inline struct in_addr getenv_ip(char *var)
+static inline struct in_addr env_get_ip(char *var)
 {
-	return string_to_ip(getenv(var));
+	return string_to_ip(env_get(var));
 }
 
 int	pcmcia_init (void);
diff --git a/include/configs/M5208EVBE.h b/include/configs/M5208EVBE.h
index 0fbf457..c56cbd9 100644
--- a/include/configs/M5208EVBE.h
+++ b/include/configs/M5208EVBE.h
@@ -161,8 +161,8 @@
 #define CONFIG_ENV_SECT_SIZE		0x2000
 
 #define LDS_BOARD_TEXT \
-        . = DEFINED(env_offset) ? env_offset : .; \
-        common/env_embedded.o (.text*);
+	. = DEFINED(env_offset) ? env_offset : .; \
+	env/embedded.o(.text*);
 
 /* Cache Configuration */
 #define CONFIG_SYS_CACHELINE_SIZE	16
diff --git a/include/configs/M5235EVB.h b/include/configs/M5235EVB.h
index dac2a32..57bc578 100644
--- a/include/configs/M5235EVB.h
+++ b/include/configs/M5235EVB.h
@@ -176,7 +176,7 @@
 
 #define LDS_BOARD_TEXT \
 	. = DEFINED(env_offset) ? env_offset : .; \
-	common/env_embedded.o (.text);
+	env/embedded.o(.text);
 
 #ifdef NORFLASH_PS32BIT
 #	define CONFIG_ENV_OFFSET		(0x8000)
diff --git a/include/configs/M5249EVB.h b/include/configs/M5249EVB.h
index f6027e2..df0733e 100644
--- a/include/configs/M5249EVB.h
+++ b/include/configs/M5249EVB.h
@@ -85,8 +85,8 @@
 #define CONFIG_SYS_INIT_SP_OFFSET	CONFIG_SYS_GBL_DATA_OFFSET
 
 #define LDS_BOARD_TEXT \
-        . = DEFINED(env_offset) ? env_offset : .; \
-        common/env_embedded.o (.text);
+	. = DEFINED(env_offset) ? env_offset : .; \
+	env/embedded.o(.text);
 
 #define CONFIG_ENV_OFFSET		0x4000	/* Address of Environment Sector*/
 #define CONFIG_ENV_SIZE		0x2000	/* Total Size of Environment Sector	*/
diff --git a/include/configs/M5253DEMO.h b/include/configs/M5253DEMO.h
index 2bdfe80..da8333a 100644
--- a/include/configs/M5253DEMO.h
+++ b/include/configs/M5253DEMO.h
@@ -29,8 +29,8 @@
 #endif
 
 #define LDS_BOARD_TEXT \
-        . = DEFINED(env_offset) ? env_offset : .; \
-        common/env_embedded.o (.text*);
+	. = DEFINED(env_offset) ? env_offset : .; \
+	env/embedded.o(.text*);
 
 /*
  * Command line configuration.
diff --git a/include/configs/M5253EVBE.h b/include/configs/M5253EVBE.h
index 0722ea1..5a2f0e2 100644
--- a/include/configs/M5253EVBE.h
+++ b/include/configs/M5253EVBE.h
@@ -31,7 +31,7 @@
 
 #define LDS_BOARD_TEXT \
 	. = DEFINED(env_offset) ? env_offset : .; \
-	common/env_embedded.o      (.text)
+	env/embedded.o(.text)
 
 /*
  * BOOTP options
diff --git a/include/configs/M5272C3.h b/include/configs/M5272C3.h
index e6bd7f3..f5693d8 100644
--- a/include/configs/M5272C3.h
+++ b/include/configs/M5272C3.h
@@ -39,8 +39,8 @@
 #endif
 
 #define LDS_BOARD_TEXT \
-        . = DEFINED(env_offset) ? env_offset : .; \
-        common/env_embedded.o (.text);
+	. = DEFINED(env_offset) ? env_offset : .; \
+	env/embedded.o(.text);
 
 /*
  * BOOTP options
diff --git a/include/configs/M5275EVB.h b/include/configs/M5275EVB.h
index 6bcd6b6..339a03c 100644
--- a/include/configs/M5275EVB.h
+++ b/include/configs/M5275EVB.h
@@ -40,8 +40,8 @@
 #endif
 
 #define LDS_BOARD_TEXT \
-        . = DEFINED(env_offset) ? env_offset : .; \
-        common/env_embedded.o (.text);
+	. = DEFINED(env_offset) ? env_offset : .; \
+	env/embedded.o(.text);
 
 /*
  * BOOTP options
diff --git a/include/configs/M5282EVB.h b/include/configs/M5282EVB.h
index cc703aa..3f2d9a9 100644
--- a/include/configs/M5282EVB.h
+++ b/include/configs/M5282EVB.h
@@ -32,7 +32,7 @@
 
 #define LDS_BOARD_TEXT \
 	. = DEFINED(env_offset) ? env_offset : .; \
-	common/env_embedded.o (.text*);
+	env/embedded.o(.text*);
 
 /*
  * BOOTP options
diff --git a/include/configs/M53017EVB.h b/include/configs/M53017EVB.h
index f781246..45e4be2 100644
--- a/include/configs/M53017EVB.h
+++ b/include/configs/M53017EVB.h
@@ -183,7 +183,7 @@
 
 #define LDS_BOARD_TEXT \
 	. = DEFINED(env_offset) ? env_offset : .; \
-	common/env_embedded.o       (.text*)
+	env/embedded.o(.text*)
 
 /*-----------------------------------------------------------------------
  * Cache Configuration
diff --git a/include/configs/M5329EVB.h b/include/configs/M5329EVB.h
index f7b284f..1b5cae2 100644
--- a/include/configs/M5329EVB.h
+++ b/include/configs/M5329EVB.h
@@ -185,8 +185,8 @@
 #define CONFIG_ENV_SECT_SIZE	0x2000
 
 #define LDS_BOARD_TEXT \
-        . = DEFINED(env_offset) ? env_offset : .; \
-        common/env_embedded.o (.text*);
+	. = DEFINED(env_offset) ? env_offset : .; \
+	env/embedded.o(.text*);
 
 /*-----------------------------------------------------------------------
  * Cache Configuration
diff --git a/include/configs/M5373EVB.h b/include/configs/M5373EVB.h
index b85e0f0..a0e582e 100644
--- a/include/configs/M5373EVB.h
+++ b/include/configs/M5373EVB.h
@@ -185,8 +185,8 @@
 #define CONFIG_ENV_SECT_SIZE	0x2000
 
 #define LDS_BOARD_TEXT \
-        . = DEFINED(env_offset) ? env_offset : .; \
-        common/env_embedded.o (.text*);
+	. = DEFINED(env_offset) ? env_offset : .; \
+	env/embedded.o(.text*);
 
 /*-----------------------------------------------------------------------
  * Cache Configuration
diff --git a/include/configs/amcore.h b/include/configs/amcore.h
index 0a40746..5f8b6c5 100644
--- a/include/configs/amcore.h
+++ b/include/configs/amcore.h
@@ -93,8 +93,8 @@
 #define CONFIG_ENV_SECT_SIZE		0x1000
 
 #define LDS_BOARD_TEXT \
-        . = DEFINED(env_offset) ? env_offset : .; \
-        common/env_embedded.o (.text*);
+	. = DEFINED(env_offset) ? env_offset : .; \
+	env/embedded.o(.text*);
 
 /* memory map space for linux boot data */
 #define CONFIG_SYS_BOOTMAPSZ		(8 << 20)
diff --git a/include/configs/astro_mcf5373l.h b/include/configs/astro_mcf5373l.h
index af03b30..563732a 100644
--- a/include/configs/astro_mcf5373l.h
+++ b/include/configs/astro_mcf5373l.h
@@ -296,7 +296,7 @@
 
 #define LDS_BOARD_TEXT \
 	. = DEFINED(env_offset) ? env_offset : .; \
-	common/env_embedded.o       (.text*)
+	env/embedded.o(.text*)
 
 #if ENABLE_JFFS
 /* JFFS Partition offset set */
diff --git a/include/configs/cobra5272.h b/include/configs/cobra5272.h
index c44c6ca..9adf7a3 100644
--- a/include/configs/cobra5272.h
+++ b/include/configs/cobra5272.h
@@ -102,8 +102,8 @@
 #endif
 
 #define LDS_BOARD_TEXT \
-        . = DEFINED(env_offset) ? env_offset : .; \
-        common/env_embedded.o (.text);
+	. = DEFINED(env_offset) ? env_offset : .; \
+	env/embedded.o(.text);
 
 /*
  * BOOTP options
diff --git a/include/configs/edison.h b/include/configs/edison.h
index dfac340..399fbc7 100644
--- a/include/configs/edison.h
+++ b/include/configs/edison.h
@@ -42,7 +42,6 @@
 #define CONFIG_SYS_MEMTEST_END			0x01000000
 
 /* Environment */
-#define CONFIG_ENV_IS_IN_MMC
 #define CONFIG_SYS_MMC_ENV_DEV			0
 #define CONFIG_SYS_MMC_ENV_PART			0
 #define CONFIG_ENV_SIZE				(64 * 1024)
diff --git a/include/configs/pfla02.h b/include/configs/pfla02.h
new file mode 100644
index 0000000..be90ce9
--- /dev/null
+++ b/include/configs/pfla02.h
@@ -0,0 +1,174 @@
+/*
+ * Copyright (C) Stefano Babic <sbabic@denx.de>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+
+#ifndef __PCM058_CONFIG_H
+#define __PCM058_CONFIG_H
+
+#include <config_distro_defaults.h>
+
+#ifdef CONFIG_SPL
+#define CONFIG_SPL_SPI_LOAD
+#define CONFIG_SYS_SPI_U_BOOT_OFFS	(64 * 1024)
+#include "imx6_spl.h"
+#endif
+
+#include "mx6_common.h"
+
+/* Thermal */
+#define CONFIG_IMX_THERMAL
+
+/* Serial */
+#define CONFIG_MXC_UART
+#define CONFIG_MXC_UART_BASE	       UART4_BASE
+#define CONSOLE_DEV		"ttymxc3"
+
+/* Early setup */
+#define CONFIG_DISPLAY_BOARDINFO_LATE
+
+
+/* Size of malloc() pool */
+#define CONFIG_SYS_MALLOC_LEN		(8 * SZ_1M)
+
+/* Ethernet */
+#define CONFIG_MII
+#define IMX_FEC_BASE			ENET_BASE_ADDR
+#define CONFIG_FEC_XCV_TYPE		RGMII
+#define CONFIG_ETHPRIME			"FEC"
+#define CONFIG_FEC_MXC_PHYADDR		3
+
+/* SPI Flash */
+#define CONFIG_MXC_SPI
+#define CONFIG_SF_DEFAULT_BUS		2
+#define CONFIG_SF_DEFAULT_CS		0
+#define CONFIG_SF_DEFAULT_SPEED		20000000
+#define CONFIG_SF_DEFAULT_MODE		SPI_MODE_0
+
+/* I2C Configs */
+#define CONFIG_SYS_I2C
+#define CONFIG_SYS_I2C_MXC
+#define CONFIG_SYS_I2C_MXC_I2C1		/* enable I2C bus 0 */
+#define CONFIG_SYS_I2C_SPEED		  100000
+
+#ifndef CONFIG_SPL_BUILD
+#define CONFIG_CMD_NAND
+/* Enable NAND support */
+#define CONFIG_CMD_NAND_TRIMFFS
+#define CONFIG_NAND_MXS
+#define CONFIG_SYS_MAX_NAND_DEVICE	1
+#define CONFIG_SYS_NAND_BASE		0x40000000
+#define CONFIG_SYS_NAND_5_ADDR_CYCLE
+#define CONFIG_SYS_NAND_ONFI_DETECTION
+#endif
+
+/* DMA stuff, needed for GPMI/MXS NAND support */
+#define CONFIG_APBH_DMA
+#define CONFIG_APBH_DMA_BURST
+#define CONFIG_APBH_DMA_BURST8
+
+/* Filesystem support */
+#define CONFIG_MTD_PARTITIONS
+#define CONFIG_MTD_DEVICE
+#define MTDIDS_DEFAULT    "nand0=gpmi-nand"
+#define MTDPARTS_DEFAULT  "mtdparts=gpmi-nand:-(nand);" \
+	"spi2.0:1024k(bootloader),64k(env1),64k(env2),-(rescue)"
+
+/* Various command support */
+
+/* Physical Memory Map */
+#define CONFIG_NR_DRAM_BANKS           1
+#define PHYS_SDRAM                     MMDC0_ARB_BASE_ADDR
+
+#define CONFIG_SYS_SDRAM_BASE          PHYS_SDRAM
+#define CONFIG_SYS_INIT_RAM_ADDR       IRAM_BASE_ADDR
+#define CONFIG_SYS_INIT_RAM_SIZE       IRAM_SIZE
+
+#define CONFIG_SYS_INIT_SP_OFFSET \
+	(CONFIG_SYS_INIT_RAM_SIZE - GENERATED_GBL_DATA_SIZE)
+#define CONFIG_SYS_INIT_SP_ADDR \
+	(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET)
+
+/* MMC Configs */
+#define CONFIG_SYS_FSL_ESDHC_ADDR	0
+#define CONFIG_SYS_FSL_USDHC_NUM	2
+
+/* Environment organization */
+#define CONFIG_ENV_IS_IN_SPI_FLASH
+#define CONFIG_ENV_SIZE                (16 * 1024)
+#define CONFIG_ENV_OFFSET		(1024 * SZ_1K)
+#define CONFIG_ENV_SECT_SIZE		(64 * SZ_1K)
+#define CONFIG_ENV_SPI_BUS             CONFIG_SF_DEFAULT_BUS
+#define CONFIG_ENV_SPI_CS              CONFIG_SF_DEFAULT_CS
+#define CONFIG_ENV_SPI_MODE            CONFIG_SF_DEFAULT_MODE
+#define CONFIG_ENV_SPI_MAX_HZ          CONFIG_SF_DEFAULT_SPEED
+#define CONFIG_SYS_REDUNDAND_ENVIRONMENT
+#define CONFIG_ENV_OFFSET_REDUND       (CONFIG_ENV_OFFSET + \
+						CONFIG_ENV_SECT_SIZE)
+#define CONFIG_ENV_SIZE_REDUND         CONFIG_ENV_SIZE
+
+#ifdef CONFIG_ENV_IS_IN_NAND
+#define CONFIG_ENV_OFFSET              (0x1E0000)
+#define CONFIG_ENV_SECT_SIZE           (128 * SZ_1K)
+#endif
+
+/* Default environment */
+#define CONFIG_EXTRA_ENV_SETTINGS \
+	"addcons=setenv bootargs ${bootargs} "				\
+		"console=${console},${baudrate}\0"			\
+	"addip=setenv bootargs ${bootargs} "				\
+		"ip=${ipaddr}:${serverip}:${gatewayip}:"		\
+		"${netmask}:${hostname}:${netdev}:off\0"		\
+	"addmisc=setenv bootargs ${bootargs} ${miscargs}\0"		\
+	"addmtd=run mtdnand;run mtdspi;"				\
+		"setenv bootargs ${bootargs} ${mtdparts}\0"		\
+	"mtdnand=setenv mtdparts mtdparts=gpmi-nand:"			\
+		"40m(Kernels),400m(root),-(nand)\0"			\
+	"mtdspi=setenv mtdparts ${mtdparts}"				\
+		"';spi2.0:1024k(bootloader),"				\
+			"64k(env1),64k(env2),-(rescue)'\0"		\
+	"bootcmd=if test -n ${rescue};"					\
+		"then run swupdate;fi;run nandboot;run swupdate\0"	\
+	"bootfile=uImage\0"						\
+	"bootimage=uImage\0"						\
+	"console=ttymxc3\0"						\
+	"fdt_addr_r=0x18000000\0"					\
+	"fdt_file=pfla02.dtb\0"						\
+	"fdt_high=0xffffffff\0"						\
+	"initrd_high=0xffffffff\0"					\
+	"kernel_addr_r=" __stringify(CONFIG_LOADADDR) "\0"		\
+	"miscargs=panic=1 quiet\0"					\
+	"mmcargs=setenv bootargs root=${mmcroot} rw rootwait\0"		\
+	"mmcboot=if run mmcload;then "					\
+		"run mmcargs addcons addmisc;"				\
+			"bootm;fi\0"					\
+	"mmcload=mmc rescan;"						\
+		"load mmc 0:${mmcpart} ${kernel_addr_r} boot/fitImage\0"\
+	"mmcpart=1\0"							\
+	"mmcroot=/dev/mmcblk0p1\0"					\
+	"ubiroot=1\0"							\
+	"nandargs=setenv bootargs ubi.mtd=1 "				\
+		"root=ubi0:rootfs${ubiroot} rootfstype=ubifs\0"		\
+	"nandboot=run mtdnand;ubi part nand0,0;"			\
+		"ubi readvol ${kernel_addr_r} kernel${ubiroot};"	\
+		"run nandargs addip addcons addmtd addmisc;"		\
+		"bootm ${kernel_addr_r}\0"				\
+	"net_nfs=tftp ${kernel_addr_r} ${board_name}/${bootfile};"	\
+		"tftp ${fdt_addr_r} ${board_name}/${fdt_file};"		\
+		"run nfsargs addip addcons addmtd addmisc;"		\
+		"bootm ${kernel_addr_r} - ${fdt_addr_r}\0"		\
+	"net_nfs_fit=tftp ${kernel_addr_r} ${board_name}/${fitfile};"	\
+		"run nfsargs addip addcons addmtd addmisc;"		\
+		"bootm ${kernel_addr_r}\0"				\
+	"nfsargs=setenv bootargs root=/dev/nfs"				\
+		" nfsroot=${serverip}:${nfsroot},v3 panic=1\0"		\
+	"swupdate=setenv bootargs root=/dev/ram;"			\
+		"run addip addcons addmtd addmisc;"			\
+		"sf probe;"						\
+		"sf read ${kernel_addr_r} 120000 600000;"		\
+		"sf read 14000000 730000 800000;"			\
+		"bootm ${kernel_addr_r} 14000000\0"
+
+#endif
diff --git a/include/configs/tam3517-common.h b/include/configs/tam3517-common.h
index 54223c4..4336251 100644
--- a/include/configs/tam3517-common.h
+++ b/include/configs/tam3517-common.h
@@ -334,7 +334,7 @@
 		else						\
 			strcpy(ethname, "ethaddr");		\
 		printf("Setting %s from EEPROM with %s\n", ethname, buf);\
-		setenv(ethname, buf);				\
+		env_set(ethname, buf);				\
 	}							\
 } while (0)
 
diff --git a/include/configs/ulcb.h b/include/configs/ulcb.h
index 921b9e5..cce2456 100644
--- a/include/configs/ulcb.h
+++ b/include/configs/ulcb.h
@@ -93,7 +93,6 @@
 #define CONFIG_SH_SDHI_FREQ		200000000
 
 /* Environment in eMMC, at the end of 2nd "boot sector" */
-#define CONFIG_ENV_IS_IN_MMC
 #define CONFIG_ENV_OFFSET		(-CONFIG_ENV_SIZE)
 #define CONFIG_SYS_MMC_ENV_DEV		1
 #define CONFIG_SYS_MMC_ENV_PART		2
diff --git a/include/configs/wandboard.h b/include/configs/wandboard.h
index ed25f42..d9237d7 100644
--- a/include/configs/wandboard.h
+++ b/include/configs/wandboard.h
@@ -123,6 +123,7 @@
 #define BOOT_TARGET_DEVICES(func) \
 	func(MMC, mmc, 0) \
 	func(MMC, mmc, 1) \
+	func(SATA, sata, 0) \
 	func(USB, usb, 0) \
 	func(PXE, pxe, na) \
 	func(DHCP, dhcp, na)
diff --git a/include/dataflash.h b/include/dataflash.h
index 84a56c3..c9f2220 100644
--- a/include/dataflash.h
+++ b/include/dataflash.h
@@ -197,7 +197,7 @@
 
 extern void dataflash_print_info (void);
 extern void dataflash_perror (int err);
-extern void AT91F_DataflashSetEnv (void);
+extern void AT91F_Dataflashenv_set(void);
 
 extern struct dataflash_addr cs[CONFIG_SYS_MAX_DATAFLASH_BANKS];
 extern dataflash_protect_t area_list[NB_DATAFLASH_AREA];
diff --git a/include/environment.h b/include/environment.h
index d86230a..03b41e0 100644
--- a/include/environment.h
+++ b/include/environment.h
@@ -143,10 +143,6 @@
 # define ENV_HEADER_SIZE	(sizeof(uint32_t))
 #endif
 
-#if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE)
-extern char *env_name_spec;
-#endif
-
 #ifdef CONFIG_ENV_AES
 /* Make sure the payload is multiple of AES block size */
 #define ENV_SIZE ((CONFIG_ENV_SIZE - ENV_HEADER_SIZE) & ~(16 - 1))
@@ -174,9 +170,6 @@
 extern const unsigned char default_environment[];
 extern env_t *env_ptr;
 
-extern void env_relocate_spec(void);
-extern unsigned char env_get_char_spec(int);
-
 #if defined(CONFIG_NEEDS_MANUAL_RELOC)
 extern void env_reloc(void);
 #endif
@@ -197,20 +190,101 @@
 #include <env_flags.h>
 #include <search.h>
 
+/* Value for environment validity */
+enum env_valid {
+	ENV_INVALID,	/* No valid environment */
+	ENV_VALID,	/* First or only environment is valid */
+	ENV_REDUND,	/* Redundant environment is valid */
+};
+
+enum env_location {
+	ENVL_DATAFLASH,
+	ENVL_EEPROM,
+	ENVL_EXT4,
+	ENVL_FAT,
+	ENVL_FLASH,
+	ENVL_MMC,
+	ENVL_NAND,
+	ENVL_NVRAM,
+	ENVL_ONENAND,
+	ENVL_REMOTE,
+	ENVL_SPI_FLASH,
+	ENVL_UBI,
+	ENVL_NOWHERE,
+
+	ENVL_COUNT,
+	ENVL_UNKNOWN,
+};
+
+struct env_driver {
+	const char *name;
+	enum env_location location;
+
+	/**
+	 * get_char() - Read a character from the environment
+	 *
+	 * This method is optional. If not provided, a default implementation
+	 * will read from gd->env_addr.
+	 *
+	 * @index: Index of character to read (0=first)
+	 * @return character read, or -ve on error
+	 */
+	int (*get_char)(int index);
+
+	/**
+	 * load() - Load the environment from storage
+	 *
+	 * This method is optional. If not provided, no environment will be
+	 * loaded.
+	 *
+	 * @return 0 if OK, -ve on error
+	 */
+	int (*load)(void);
+
+	/**
+	 * save() - Save the environment to storage
+	 *
+	 * This method is required for 'saveenv' to work.
+	 *
+	 * @return 0 if OK, -ve on error
+	 */
+	int (*save)(void);
+
+	/**
+	 * init() - Set up the initial pre-relocation environment
+	 *
+	 * This method is optional.
+	 *
+	 * @return 0 if OK, -ENOENT if no initial environment could be found,
+	 * other -ve on error
+	 */
+	int (*init)(void);
+};
+
+/* Declare a new environment location driver */
+#define U_BOOT_ENV_LOCATION(__name)					\
+	ll_entry_declare(struct env_driver, __name, env_driver)
+
+/* Declare the name of a location */
+#ifdef CONFIG_CMD_SAVEENV
+#define ENV_NAME(_name) .name = _name,
+#else
+#define ENV_NAME(_name)
+#endif
+
+#ifdef CONFIG_CMD_SAVEENV
+#define env_save_ptr(x) x
+#else
+#define env_save_ptr(x) NULL
+#endif
+
 extern struct hsearch_data env_htab;
 
-/* Function that returns a character from the environment */
-unsigned char env_get_char(int);
-
-/* Function that returns a pointer to a value from the environment */
-const unsigned char *env_get_addr(int);
-unsigned char env_get_char_memory(int index);
-
 /* Function that updates CRC of the enironment */
 void env_crc_update(void);
 
 /* Look up the variable from the default environment */
-char *getenv_default(const char *name);
+char *env_get_default(const char *name);
 
 /* [re]set to the default environment */
 void set_default_env(const char *s);
@@ -229,6 +303,37 @@
 int env_import_redund(const char *buf1, const char *buf2);
 #endif
 
+/**
+ * env_driver_lookup_default() - Look up the default environment driver
+ *
+ * @return pointer to driver, or NULL if none (which should not happen)
+ */
+struct env_driver *env_driver_lookup_default(void);
+
+/**
+ * env_get_char() - Get a character from the early environment
+ *
+ * This reads from the pre-relocation environemnt
+ *
+ * @index: Index of character to read (0 = first)
+ * @return character read, or -ve on error
+ */
+int env_get_char(int index);
+
+/**
+ * env_load() - Load the environment from storage
+ *
+ * @return 0 if OK, -ve on error
+ */
+int env_load(void);
+
+/**
+ * env_save() - Save the environment to storage
+ *
+ * @return 0 if OK, -ve on error
+ */
+int env_save(void);
+
 #endif /* DO_DEPS_ONLY */
 
 #endif /* _ENVIRONMENT_H_ */
diff --git a/include/exports.h b/include/exports.h
index 1d81bc4..ebe81d9 100644
--- a/include/exports.h
+++ b/include/exports.h
@@ -27,8 +27,8 @@
 int vprintf(const char *, va_list);
 unsigned long simple_strtoul(const char *cp, char **endp, unsigned int base);
 int strict_strtoul(const char *cp, unsigned int base, unsigned long *res);
-char *getenv (const char *name);
-int setenv (const char *varname, const char *varvalue);
+char *env_get(const char *name);
+int env_set(const char *varname, const char *value);
 long simple_strtol(const char *cp, char **endp, unsigned int base);
 int strcmp(const char *cs, const char *ct);
 unsigned long ustrtoul(const char *cp, char **endp, unsigned int base);
diff --git a/include/image.h b/include/image.h
index c6f1513..1f4bfda 100644
--- a/include/image.h
+++ b/include/image.h
@@ -373,7 +373,7 @@
 	bd_t		*kbd;
 #endif
 
-	int		verify;		/* getenv("verify")[0] != 'n' */
+	int		verify;		/* env_get("verify")[0] != 'n' */
 
 #define	BOOTM_STATE_START	(0x00000001)
 #define	BOOTM_STATE_FINDOS	(0x00000002)
@@ -769,9 +769,9 @@
 int image_check_hcrc(const image_header_t *hdr);
 int image_check_dcrc(const image_header_t *hdr);
 #ifndef USE_HOSTCC
-ulong getenv_bootm_low(void);
-phys_size_t getenv_bootm_size(void);
-phys_size_t getenv_bootm_mapsize(void);
+ulong env_get_bootm_low(void);
+phys_size_t env_get_bootm_size(void);
+phys_size_t env_get_bootm_mapsize(void);
 #endif
 void memmove_wd(void *to, void *from, size_t len, ulong chunksz);
 
diff --git a/include/net.h b/include/net.h
index e126948..455b48f 100644
--- a/include/net.h
+++ b/include/net.h
@@ -239,11 +239,11 @@
 
 int eth_get_dev_index(void);		/* get the device index */
 void eth_parse_enetaddr(const char *addr, uchar *enetaddr);
-int eth_getenv_enetaddr(const char *name, uchar *enetaddr);
-int eth_setenv_enetaddr(const char *name, const uchar *enetaddr);
+int eth_env_get_enetaddr(const char *name, uchar *enetaddr);
+int eth_env_set_enetaddr(const char *name, const uchar *enetaddr);
 
 /**
- * eth_setenv_enetaddr_by_index() - set the MAC address environment variable
+ * eth_env_set_enetaddr_by_index() - set the MAC address environment variable
  *
  * This sets up an environment variable with the given MAC address (@enetaddr).
  * The environment variable to be set is defined by <@base_name><@index>addr.
@@ -255,7 +255,7 @@
  * @enetaddr:   Pointer to MAC address to put into the variable
  * @return 0 if OK, other value on error
  */
-int eth_setenv_enetaddr_by_index(const char *base_name, int index,
+int eth_env_set_enetaddr_by_index(const char *base_name, int index,
 				 uchar *enetaddr);
 
 
@@ -275,7 +275,7 @@
  * Returns:
  *	Return true if the address is valid.
  */
-int eth_getenv_enetaddr_by_index(const char *base_name, int index,
+int eth_env_get_enetaddr_by_index(const char *base_name, int index,
 				 uchar *enetaddr);
 
 int eth_init(void);			/* Initialize the device */
@@ -834,7 +834,7 @@
 ushort string_to_vlan(const char *s);
 
 /* read a VLAN id from an environment variable */
-ushort getenv_vlan(char *);
+ushort env_get_vlan(char *);
 
 /* copy a filename (allow for "..." notation, limit length) */
 void copy_filename(char *dst, const char *src, int size);
diff --git a/include/netdev.h b/include/netdev.h
index c06b908..b9bfeba 100644
--- a/include/netdev.h
+++ b/include/netdev.h
@@ -130,7 +130,12 @@
 	return num;
 }
 
+#ifdef CONFIG_DM_ETH
+struct mii_dev *fec_get_miibus(struct udevice *dev, int dev_id);
+#else
 struct mii_dev *fec_get_miibus(uint32_t base_addr, int dev_id);
+#endif
+
 #ifdef CONFIG_PHYLIB
 struct phy_device;
 int fec_probe(bd_t *bd, int dev_id, uint32_t base_addr,
diff --git a/include/search.h b/include/search.h
index 402dfd8..df5d61c 100644
--- a/include/search.h
+++ b/include/search.h
@@ -118,7 +118,7 @@
 #define H_MATCH_SUBSTR	(1 << 7) /* search for substring matches	     */
 #define H_MATCH_REGEX	(1 << 8) /* search for regular expression matches    */
 #define H_MATCH_METHOD	(H_MATCH_IDENT | H_MATCH_SUBSTR | H_MATCH_REGEX)
-#define H_PROGRAMMATIC	(1 << 9) /* indicate that an import is from setenv() */
+#define H_PROGRAMMATIC	(1 << 9) /* indicate that an import is from env_set() */
 #define H_ORIGIN_FLAGS	(H_INTERACTIVE | H_PROGRAMMATIC)
 
 #endif /* _SEARCH_H_ */
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index d2dbd0f..107a892 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -1240,7 +1240,7 @@
 # endif
 # ifndef CONFIG_SPL_BUILD
 	/* Allow the early environment to override the fdt address */
-	gd->fdt_blob = (void *)getenv_ulong("fdtcontroladdr", 16,
+	gd->fdt_blob = (void *)env_get_ulong("fdtcontroladdr", 16,
 						(uintptr_t)gd->fdt_blob);
 # endif
 #endif
diff --git a/lib/smbios.c b/lib/smbios.c
index 22ca247..8f19ad8 100644
--- a/lib/smbios.c
+++ b/lib/smbios.c
@@ -112,7 +112,7 @@
 {
 	struct smbios_type1 *t = (struct smbios_type1 *)*current;
 	int len = sizeof(struct smbios_type1);
-	char *serial_str = getenv("serial#");
+	char *serial_str = env_get("serial#");
 
 	memset(t, 0, sizeof(struct smbios_type1));
 	fill_smbios_header(t, SMBIOS_SYSTEM_INFORMATION, len, handle);
diff --git a/lib/uuid.c b/lib/uuid.c
index c8584ed..1536c02 100644
--- a/lib/uuid.c
+++ b/lib/uuid.c
@@ -291,7 +291,7 @@
 	if (argc == 1)
 		printf("%s\n", uuid);
 	else
-		setenv(argv[1], uuid);
+		env_set(argv[1], uuid);
 
 	return CMD_RET_SUCCESS;
 }
diff --git a/net/arp.c b/net/arp.c
index f3ceff9..4c79e09 100644
--- a/net/arp.c
+++ b/net/arp.c
@@ -194,7 +194,7 @@
 		if (net_server_ip.s_addr == net_arp_wait_packet_ip.s_addr) {
 			char buf[20];
 			sprintf(buf, "%pM", &arp->ar_sha);
-			setenv("serveraddr", buf);
+			env_set("serveraddr", buf);
 		}
 #endif
 
diff --git a/net/bootp.c b/net/bootp.c
index be8f710..73370a1 100644
--- a/net/bootp.c
+++ b/net/bootp.c
@@ -170,7 +170,7 @@
 	 * not contain a new value
 	 */
 	if (*net_boot_file_name)
-		setenv("bootfile", net_boot_file_name);
+		env_set("bootfile", net_boot_file_name);
 #endif
 	net_copy_ip(&net_ip, &bp->bp_yiaddr);
 }
@@ -414,7 +414,7 @@
 static u8 *add_vci(u8 *e)
 {
 	char *vci = NULL;
-	char *env_vci = getenv("bootp_vci");
+	char *env_vci = env_get("bootp_vci");
 
 #if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_NET_VCI_STRING)
 	vci = CONFIG_SPL_NET_VCI_STRING;
@@ -488,7 +488,7 @@
 		*e++ = tmp & 0xff;
 	}
 #if defined(CONFIG_BOOTP_SEND_HOSTNAME)
-	hostname = getenv("hostname");
+	hostname = env_get("hostname");
 	if (hostname) {
 		int hostnamelen = strlen(hostname);
 
@@ -503,8 +503,8 @@
 	clientarch = CONFIG_BOOTP_PXE_CLIENTARCH;
 #endif
 
-	if (getenv("bootp_arch"))
-		clientarch = getenv_ulong("bootp_arch", 16, clientarch);
+	if (env_get("bootp_arch"))
+		clientarch = env_get_ulong("bootp_arch", 16, clientarch);
 
 	if (clientarch > 0) {
 		*e++ = 93;	/* Client System Architecture */
@@ -520,7 +520,7 @@
 	*e++ = 0;	/* minor revision */
 
 #ifdef CONFIG_LIB_UUID
-	uuid = getenv("pxeuuid");
+	uuid = env_get("pxeuuid");
 
 	if (uuid) {
 		if (uuid_str_valid(uuid)) {
@@ -713,7 +713,7 @@
 	dhcp_state = INIT;
 #endif
 
-	ep = getenv("bootpretryperiod");
+	ep = env_get("bootpretryperiod");
 	if (ep != NULL)
 		time_taken_max = simple_strtoul(ep, NULL, 10);
 	else
diff --git a/net/dns.c b/net/dns.c
index 7017bac..eee8a02 100644
--- a/net/dns.c
+++ b/net/dns.c
@@ -184,7 +184,7 @@
 			ip_to_string(ip_addr, ip_str);
 			printf("%s\n", ip_str);
 			if (net_dns_env_var)
-				setenv(net_dns_env_var, ip_str);
+				env_set(net_dns_env_var, ip_str);
 		} else {
 			puts("server responded with invalid IP number\n");
 		}
diff --git a/net/eth-uclass.c b/net/eth-uclass.c
index b659961..d30b04b 100644
--- a/net/eth-uclass.c
+++ b/net/eth-uclass.c
@@ -241,8 +241,8 @@
 
 int eth_init(void)
 {
-	char *ethact = getenv("ethact");
-	char *ethrotate = getenv("ethrotate");
+	char *ethact = env_get("ethact");
+	char *ethrotate = env_get("ethrotate");
 	struct udevice *current = NULL;
 	struct udevice *old_current;
 	int ret = -ENODEV;
@@ -401,7 +401,7 @@
 		printf("No ethernet found.\n");
 		bootstage_error(BOOTSTAGE_ID_NET_ETH_START);
 	} else {
-		char *ethprime = getenv("ethprime");
+		char *ethprime = env_get("ethprime");
 		struct udevice *prime_dev = NULL;
 
 		if (ethprime)
@@ -495,7 +495,7 @@
 	if (eth_get_ops(dev)->read_rom_hwaddr)
 		eth_get_ops(dev)->read_rom_hwaddr(dev);
 
-	eth_getenv_enetaddr_by_index("eth", dev->seq, env_enetaddr);
+	eth_env_get_enetaddr_by_index("eth", dev->seq, env_enetaddr);
 	if (!is_zero_ethaddr(env_enetaddr)) {
 		if (!is_zero_ethaddr(pdata->enetaddr) &&
 		    memcmp(pdata->enetaddr, env_enetaddr, ARP_HLEN)) {
@@ -510,7 +510,7 @@
 		/* Override the ROM MAC address */
 		memcpy(pdata->enetaddr, env_enetaddr, ARP_HLEN);
 	} else if (is_valid_ethaddr(pdata->enetaddr)) {
-		eth_setenv_enetaddr_by_index("eth", dev->seq, pdata->enetaddr);
+		eth_env_set_enetaddr_by_index("eth", dev->seq, pdata->enetaddr);
 		printf("\nWarning: %s using MAC address from ROM\n",
 		       dev->name);
 	} else if (is_zero_ethaddr(pdata->enetaddr) ||
diff --git a/net/eth_common.c b/net/eth_common.c
index 58fa295..66d0d22 100644
--- a/net/eth_common.c
+++ b/net/eth_common.c
@@ -24,38 +24,38 @@
 	}
 }
 
-int eth_getenv_enetaddr(const char *name, uchar *enetaddr)
+int eth_env_get_enetaddr(const char *name, uchar *enetaddr)
 {
-	eth_parse_enetaddr(getenv(name), enetaddr);
+	eth_parse_enetaddr(env_get(name), enetaddr);
 	return is_valid_ethaddr(enetaddr);
 }
 
-int eth_setenv_enetaddr(const char *name, const uchar *enetaddr)
+int eth_env_set_enetaddr(const char *name, const uchar *enetaddr)
 {
 	char buf[ARP_HLEN_ASCII + 1];
 
-	if (eth_getenv_enetaddr(name, (uchar *)buf))
+	if (eth_env_get_enetaddr(name, (uchar *)buf))
 		return -EEXIST;
 
 	sprintf(buf, "%pM", enetaddr);
 
-	return setenv(name, buf);
+	return env_set(name, buf);
 }
 
-int eth_getenv_enetaddr_by_index(const char *base_name, int index,
+int eth_env_get_enetaddr_by_index(const char *base_name, int index,
 				 uchar *enetaddr)
 {
 	char enetvar[32];
 	sprintf(enetvar, index ? "%s%daddr" : "%saddr", base_name, index);
-	return eth_getenv_enetaddr(enetvar, enetaddr);
+	return eth_env_get_enetaddr(enetvar, enetaddr);
 }
 
-int eth_setenv_enetaddr_by_index(const char *base_name, int index,
+int eth_env_set_enetaddr_by_index(const char *base_name, int index,
 				 uchar *enetaddr)
 {
 	char enetvar[32];
 	sprintf(enetvar, index ? "%s%daddr" : "%saddr", base_name, index);
-	return eth_setenv_enetaddr(enetvar, enetaddr);
+	return eth_env_set_enetaddr(enetvar, enetaddr);
 }
 
 void eth_common_init(void)
@@ -76,13 +76,13 @@
 	char *skip_state;
 
 	sprintf(enetvar, index ? "eth%dmacskip" : "ethmacskip", index);
-	skip_state = getenv(enetvar);
+	skip_state = env_get(enetvar);
 	return skip_state != NULL;
 }
 
 void eth_current_changed(void)
 {
-	char *act = getenv("ethact");
+	char *act = env_get("ethact");
 	char *ethrotate;
 
 	/*
@@ -90,21 +90,21 @@
 	 * ethernet device if uc_priv->current == NULL. This is not what
 	 * we want when 'ethrotate' variable is 'no'.
 	 */
-	ethrotate = getenv("ethrotate");
+	ethrotate = env_get("ethrotate");
 	if ((ethrotate != NULL) && (strcmp(ethrotate, "no") == 0))
 		return;
 
 	/* update current ethernet name */
 	if (eth_get_dev()) {
 		if (act == NULL || strcmp(act, eth_get_name()) != 0)
-			setenv("ethact", eth_get_name());
+			env_set("ethact", eth_get_name());
 	}
 	/*
 	 * remove the variable completely if there is no active
 	 * interface
 	 */
 	else if (act != NULL)
-		setenv("ethact", NULL);
+		env_set("ethact", NULL);
 }
 
 void eth_try_another(int first_restart)
@@ -116,7 +116,7 @@
 	 * Do not rotate between network interfaces when
 	 * 'ethrotate' variable is set to 'no'.
 	 */
-	ethrotate = getenv("ethrotate");
+	ethrotate = env_get("ethrotate");
 	if ((ethrotate != NULL) && (strcmp(ethrotate, "no") == 0))
 		return;
 
@@ -142,12 +142,12 @@
 
 	env_id = get_env_id();
 	if ((act == NULL) || (env_changed_id != env_id)) {
-		act = getenv("ethact");
+		act = env_get("ethact");
 		env_changed_id = env_id;
 	}
 
 	if (act == NULL) {
-		char *ethprime = getenv("ethprime");
+		char *ethprime = env_get("ethprime");
 		void *dev = NULL;
 
 		if (ethprime)
diff --git a/net/eth_internal.h b/net/eth_internal.h
index a14b208..4b0e716 100644
--- a/net/eth_internal.h
+++ b/net/eth_internal.h
@@ -13,7 +13,7 @@
 void eth_common_init(void);
 
 /**
- * eth_setenv_enetaddr_by_index() - set the MAC address environment variable
+ * eth_env_set_enetaddr_by_index() - set the MAC address environment variable
  *
  * This sets up an environment variable with the given MAC address (@enetaddr).
  * The environment variable to be set is defined by <@base_name><@index>addr.
@@ -25,7 +25,7 @@
  * @enetaddr:	Pointer to MAC address to put into the variable
  * @return 0 if OK, other value on error
  */
-int eth_setenv_enetaddr_by_index(const char *base_name, int index,
+int eth_env_set_enetaddr_by_index(const char *base_name, int index,
 				 uchar *enetaddr);
 
 int eth_mac_skip(int index);
diff --git a/net/eth_legacy.c b/net/eth_legacy.c
index e4bd0f4..be0cf64 100644
--- a/net/eth_legacy.c
+++ b/net/eth_legacy.c
@@ -137,7 +137,7 @@
 	unsigned char env_enetaddr[ARP_HLEN];
 	int ret = 0;
 
-	eth_getenv_enetaddr_by_index(base_name, eth_number, env_enetaddr);
+	eth_env_get_enetaddr_by_index(base_name, eth_number, env_enetaddr);
 
 	if (!is_zero_ethaddr(env_enetaddr)) {
 		if (!is_zero_ethaddr(dev->enetaddr) &&
@@ -152,8 +152,8 @@
 
 		memcpy(dev->enetaddr, env_enetaddr, ARP_HLEN);
 	} else if (is_valid_ethaddr(dev->enetaddr)) {
-		eth_setenv_enetaddr_by_index(base_name, eth_number,
-					     dev->enetaddr);
+		eth_env_set_enetaddr_by_index(base_name, eth_number,
+					      dev->enetaddr);
 	} else if (is_zero_ethaddr(dev->enetaddr)) {
 #ifdef CONFIG_NET_RANDOM_ETHADDR
 		net_random_ethaddr(dev->enetaddr);
@@ -261,7 +261,7 @@
 		bootstage_error(BOOTSTAGE_ID_NET_ETH_START);
 	} else {
 		struct eth_device *dev = eth_devices;
-		char *ethprime = getenv("ethprime");
+		char *ethprime = env_get("ethprime");
 
 		bootstage_mark(BOOTSTAGE_ID_NET_ETH_INIT);
 		do {
diff --git a/net/link_local.c b/net/link_local.c
index dfd240d..31cdef4 100644
--- a/net/link_local.c
+++ b/net/link_local.c
@@ -104,7 +104,7 @@
 
 void link_local_start(void)
 {
-	ip = getenv_ip("llipaddr");
+	ip = env_get_ip("llipaddr");
 	if (ip.s_addr != 0 &&
 	    (ntohl(ip.s_addr) & IN_CLASSB_NET) != LINKLOCAL_ADDR) {
 		puts("invalid link address");
diff --git a/net/net.c b/net/net.c
index 2268890..4259c9e 100644
--- a/net/net.c
+++ b/net/net.c
@@ -319,7 +319,7 @@
 void net_auto_load(void)
 {
 #if defined(CONFIG_CMD_NFS)
-	const char *s = getenv("autoload");
+	const char *s = env_get("autoload");
 
 	if (s != NULL && strcmp(s, "NFS") == 0) {
 		/*
@@ -329,7 +329,7 @@
 		return;
 	}
 #endif
-	if (getenv_yesno("autoload") == 0) {
+	if (env_get_yesno("autoload") == 0) {
 		/*
 		 * Just use BOOTP/RARP to configure system;
 		 * Do not use TFTP to load the bootfile.
@@ -616,8 +616,8 @@
 			if (net_boot_file_size > 0) {
 				printf("Bytes transferred = %d (%x hex)\n",
 				       net_boot_file_size, net_boot_file_size);
-				setenv_hex("filesize", net_boot_file_size);
-				setenv_hex("fileaddr", load_addr);
+				env_set_hex("filesize", net_boot_file_size);
+				env_set_hex("fileaddr", load_addr);
 			}
 			if (protocol != NETCONS)
 				eth_halt();
@@ -668,7 +668,7 @@
 	unsigned long retrycnt = 0;
 	int ret;
 
-	nretry = getenv("netretry");
+	nretry = env_get("netretry");
 	if (nretry) {
 		if (!strcmp(nretry, "yes"))
 			retry_forever = 1;
@@ -1536,7 +1536,7 @@
 	return htons(id);
 }
 
-ushort getenv_vlan(char *var)
+ushort env_get_vlan(char *var)
 {
-	return string_to_vlan(getenv(var));
+	return string_to_vlan(env_get(var));
 }
diff --git a/net/tftp.c b/net/tftp.c
index 61e1671..a5ed8c5 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -706,11 +706,11 @@
 	 * TFTP protocol has a minimal timeout of 1 second.
 	 */
 
-	ep = getenv("tftpblocksize");
+	ep = env_get("tftpblocksize");
 	if (ep != NULL)
 		tftp_block_size_option = simple_strtol(ep, NULL, 10);
 
-	ep = getenv("tftptimeout");
+	ep = env_get("tftptimeout");
 	if (ep != NULL)
 		timeout_ms = simple_strtol(ep, NULL, 10);
 
@@ -720,7 +720,7 @@
 		timeout_ms = 1000;
 	}
 
-	ep = getenv("tftptimeoutcountmax");
+	ep = env_get("tftptimeoutcountmax");
 	if (ep != NULL)
 		tftp_timeout_count_max = simple_strtol(ep, NULL, 10);
 
@@ -822,10 +822,10 @@
 	tftp_our_port = 1024 + (get_timer(0) % 3072);
 
 #ifdef CONFIG_TFTP_PORT
-	ep = getenv("tftpdstp");
+	ep = env_get("tftpdstp");
 	if (ep != NULL)
 		tftp_remote_port = simple_strtol(ep, NULL, 10);
-	ep = getenv("tftpsrcp");
+	ep = env_get("tftpsrcp");
 	if (ep != NULL)
 		tftp_our_port = simple_strtol(ep, NULL, 10);
 #endif
diff --git a/post/post.c b/post/post.c
index 8c2c822..8fef0c3 100644
--- a/post/post.c
+++ b/post/post.c
@@ -180,7 +180,7 @@
 	int i, j;
 
 	for (i = 0; i < varnum; i++) {
-		if (getenv_f(var[i], list, sizeof(list)) <= 0)
+		if (env_get_f(var[i], list, sizeof(list)) <= 0)
 			continue;
 
 		for (j = 0; j < post_list_size; j++)
diff --git a/scripts/Makefile.spl b/scripts/Makefile.spl
index 167b2d9..3ba0007 100644
--- a/scripts/Makefile.spl
+++ b/scripts/Makefile.spl
@@ -69,10 +69,10 @@
 
 # Special handling for a few options which support SPL/TPL
 ifeq ($(CONFIG_TPL_BUILD),y)
-libs-$(CONFIG_TPL_LIBCOMMON_SUPPORT) += common/ cmd/
+libs-$(CONFIG_TPL_LIBCOMMON_SUPPORT) += common/ cmd/ env/
 libs-$(CONFIG_TPL_LIBGENERIC_SUPPORT) += lib/
 else
-libs-$(CONFIG_SPL_LIBCOMMON_SUPPORT) += common/ cmd/
+libs-$(CONFIG_SPL_LIBCOMMON_SUPPORT) += common/ cmd/ env/
 libs-$(CONFIG_SPL_LIBGENERIC_SUPPORT) += lib/
 endif
 
diff --git a/test/command_ut.c b/test/command_ut.c
index 21283eb..f76d525 100644
--- a/test/command_ut.c
+++ b/test/command_ut.c
@@ -19,16 +19,16 @@
 
 	/* commands separated by \n */
 	run_command_list("setenv list 1\n setenv list ${list}1", -1, 0);
-	assert(!strcmp("11", getenv("list")));
+	assert(!strcmp("11", env_get("list")));
 
 	/* command followed by \n and nothing else */
 	run_command_list("setenv list 1${list}\n", -1, 0);
-	assert(!strcmp("111", getenv("list")));
+	assert(!strcmp("111", env_get("list")));
 
 	/* a command string with \0 in it. Stuff after \0 should be ignored */
 	run_command("setenv list", 0);
 	run_command_list(test_cmd, sizeof(test_cmd), 0);
-	assert(!strcmp("123", getenv("list")));
+	assert(!strcmp("123", env_get("list")));
 
 	/*
 	 * a command list where we limit execution to only the first command
@@ -36,7 +36,7 @@
 	 */
 	run_command_list("setenv list 1\n setenv list ${list}2; "
 		"setenv list ${list}3", strlen("setenv list 1"), 0);
-	assert(!strcmp("1", getenv("list")));
+	assert(!strcmp("1", env_get("list")));
 
 	assert(run_command("false", 0) == 1);
 	assert(run_command("echo", 0) == 0);
@@ -46,10 +46,10 @@
 #ifdef CONFIG_HUSH_PARSER
 	run_command("setenv foo 'setenv black 1\nsetenv adder 2'", 0);
 	run_command("run foo", 0);
-	assert(getenv("black") != NULL);
-	assert(!strcmp("1", getenv("black")));
-	assert(getenv("adder") != NULL);
-	assert(!strcmp("2", getenv("adder")));
+	assert(env_get("black") != NULL);
+	assert(!strcmp("1", env_get("black")));
+	assert(env_get("adder") != NULL);
+	assert(!strcmp("2", env_get("adder")));
 #endif
 
 	assert(run_command("", 0) == 0);
diff --git a/test/dm/eth.c b/test/dm/eth.c
index 564ad36..122fab9 100644
--- a/test/dm/eth.c
+++ b/test/dm/eth.c
@@ -26,17 +26,17 @@
 {
 	net_ping_ip = string_to_ip("1.1.2.2");
 
-	setenv("ethact", "eth@10002000");
+	env_set("ethact", "eth@10002000");
 	ut_assertok(net_loop(PING));
-	ut_asserteq_str("eth@10002000", getenv("ethact"));
+	ut_asserteq_str("eth@10002000", env_get("ethact"));
 
-	setenv("ethact", "eth@10003000");
+	env_set("ethact", "eth@10003000");
 	ut_assertok(net_loop(PING));
-	ut_asserteq_str("eth@10003000", getenv("ethact"));
+	ut_asserteq_str("eth@10003000", env_get("ethact"));
 
-	setenv("ethact", "eth@10004000");
+	env_set("ethact", "eth@10004000");
 	ut_assertok(net_loop(PING));
-	ut_asserteq_str("eth@10004000", getenv("ethact"));
+	ut_asserteq_str("eth@10004000", env_get("ethact"));
 
 	return 0;
 }
@@ -45,22 +45,22 @@
 static int dm_test_eth_alias(struct unit_test_state *uts)
 {
 	net_ping_ip = string_to_ip("1.1.2.2");
-	setenv("ethact", "eth0");
+	env_set("ethact", "eth0");
 	ut_assertok(net_loop(PING));
-	ut_asserteq_str("eth@10002000", getenv("ethact"));
+	ut_asserteq_str("eth@10002000", env_get("ethact"));
 
-	setenv("ethact", "eth1");
+	env_set("ethact", "eth1");
 	ut_assertok(net_loop(PING));
-	ut_asserteq_str("eth@10004000", getenv("ethact"));
+	ut_asserteq_str("eth@10004000", env_get("ethact"));
 
 	/* Expected to fail since eth2 is not defined in the device tree */
-	setenv("ethact", "eth2");
+	env_set("ethact", "eth2");
 	ut_assertok(net_loop(PING));
-	ut_asserteq_str("eth@10002000", getenv("ethact"));
+	ut_asserteq_str("eth@10002000", env_get("ethact"));
 
-	setenv("ethact", "eth5");
+	env_set("ethact", "eth5");
 	ut_assertok(net_loop(PING));
-	ut_asserteq_str("eth@10003000", getenv("ethact"));
+	ut_asserteq_str("eth@10003000", env_get("ethact"));
 
 	return 0;
 }
@@ -71,16 +71,16 @@
 	net_ping_ip = string_to_ip("1.1.2.2");
 
 	/* Expected to be "eth@10003000" because of ethprime variable */
-	setenv("ethact", NULL);
-	setenv("ethprime", "eth5");
+	env_set("ethact", NULL);
+	env_set("ethprime", "eth5");
 	ut_assertok(net_loop(PING));
-	ut_asserteq_str("eth@10003000", getenv("ethact"));
+	ut_asserteq_str("eth@10003000", env_get("ethact"));
 
 	/* Expected to be "eth@10002000" because it is first */
-	setenv("ethact", NULL);
-	setenv("ethprime", NULL);
+	env_set("ethact", NULL);
+	env_set("ethprime", NULL);
 	ut_assertok(net_loop(PING));
-	ut_asserteq_str("eth@10002000", getenv("ethact"));
+	ut_asserteq_str("eth@10002000", env_get("ethact"));
 
 	return 0;
 }
@@ -119,28 +119,28 @@
 		ut_assertok(device_remove(dev[i], DM_REMOVE_NORMAL));
 
 		/* Invalidate MAC address */
-		strcpy(ethaddr[i], getenv(addrname[i]));
+		strcpy(ethaddr[i], env_get(addrname[i]));
 		/* Must disable access protection for ethaddr before clearing */
-		setenv(".flags", addrname[i]);
-		setenv(addrname[i], NULL);
+		env_set(".flags", addrname[i]);
+		env_set(addrname[i], NULL);
 	}
 
 	/* Set ethact to "eth@10002000" */
-	setenv("ethact", ethname[0]);
+	env_set("ethact", ethname[0]);
 
 	/* Segment fault might happen if something is wrong */
 	ut_asserteq(-ENODEV, net_loop(PING));
 
 	for (i = 0; i < DM_TEST_ETH_NUM; i++) {
 		/* Restore the env */
-		setenv(".flags", addrname[i]);
-		setenv(addrname[i], ethaddr[i]);
+		env_set(".flags", addrname[i]);
+		env_set(addrname[i], ethaddr[i]);
 
 		/* Probe the device again */
 		ut_assertok(device_probe(dev[i]));
 	}
-	setenv(".flags", NULL);
-	setenv("ethact", NULL);
+	env_set(".flags", NULL);
+	env_set("ethact", NULL);
 
 	return 0;
 }
@@ -150,15 +150,15 @@
 static int _dm_test_eth_rotate1(struct unit_test_state *uts)
 {
 	/* Make sure that the default is to rotate to the next interface */
-	setenv("ethact", "eth@10004000");
+	env_set("ethact", "eth@10004000");
 	ut_assertok(net_loop(PING));
-	ut_asserteq_str("eth@10002000", getenv("ethact"));
+	ut_asserteq_str("eth@10002000", env_get("ethact"));
 
 	/* If ethrotate is no, then we should fail on a bad MAC */
-	setenv("ethact", "eth@10004000");
-	setenv("ethrotate", "no");
+	env_set("ethact", "eth@10004000");
+	env_set("ethrotate", "no");
 	ut_asserteq(-EINVAL, net_loop(PING));
-	ut_asserteq_str("eth@10004000", getenv("ethact"));
+	ut_asserteq_str("eth@10004000", env_get("ethact"));
 
 	return 0;
 }
@@ -166,14 +166,14 @@
 static int _dm_test_eth_rotate2(struct unit_test_state *uts)
 {
 	/* Make sure we can skip invalid devices */
-	setenv("ethact", "eth@10004000");
+	env_set("ethact", "eth@10004000");
 	ut_assertok(net_loop(PING));
-	ut_asserteq_str("eth@10004000", getenv("ethact"));
+	ut_asserteq_str("eth@10004000", env_get("ethact"));
 
 	/* Make sure we can handle device name which is not eth# */
-	setenv("ethact", "sbe5");
+	env_set("ethact", "sbe5");
 	ut_assertok(net_loop(PING));
-	ut_asserteq_str("sbe5", getenv("ethact"));
+	ut_asserteq_str("sbe5", env_get("ethact"));
 
 	return 0;
 }
@@ -187,31 +187,31 @@
 	net_ping_ip = string_to_ip("1.1.2.2");
 
 	/* Invalidate eth1's MAC address */
-	strcpy(ethaddr, getenv("eth1addr"));
+	strcpy(ethaddr, env_get("eth1addr"));
 	/* Must disable access protection for eth1addr before clearing */
-	setenv(".flags", "eth1addr");
-	setenv("eth1addr", NULL);
+	env_set(".flags", "eth1addr");
+	env_set("eth1addr", NULL);
 
 	retval = _dm_test_eth_rotate1(uts);
 
 	/* Restore the env */
-	setenv("eth1addr", ethaddr);
-	setenv("ethrotate", NULL);
+	env_set("eth1addr", ethaddr);
+	env_set("ethrotate", NULL);
 
 	if (!retval) {
 		/* Invalidate eth0's MAC address */
-		strcpy(ethaddr, getenv("ethaddr"));
+		strcpy(ethaddr, env_get("ethaddr"));
 		/* Must disable access protection for ethaddr before clearing */
-		setenv(".flags", "ethaddr");
-		setenv("ethaddr", NULL);
+		env_set(".flags", "ethaddr");
+		env_set("ethaddr", NULL);
 
 		retval = _dm_test_eth_rotate2(uts);
 
 		/* Restore the env */
-		setenv("ethaddr", ethaddr);
+		env_set("ethaddr", ethaddr);
 	}
 	/* Restore the env */
-	setenv(".flags", NULL);
+	env_set(".flags", NULL);
 
 	return retval;
 }
@@ -225,21 +225,21 @@
 	 * the active device should be eth0
 	 */
 	sandbox_eth_disable_response(1, true);
-	setenv("ethact", "eth@10004000");
-	setenv("netretry", "yes");
+	env_set("ethact", "eth@10004000");
+	env_set("netretry", "yes");
 	sandbox_eth_skip_timeout();
 	ut_assertok(net_loop(PING));
-	ut_asserteq_str("eth@10002000", getenv("ethact"));
+	ut_asserteq_str("eth@10002000", env_get("ethact"));
 
 	/*
 	 * eth1 is disabled and netretry is no, so the ping should fail and the
 	 * active device should be eth1
 	 */
-	setenv("ethact", "eth@10004000");
-	setenv("netretry", "no");
+	env_set("ethact", "eth@10004000");
+	env_set("netretry", "no");
 	sandbox_eth_skip_timeout();
 	ut_asserteq(-ETIMEDOUT, net_loop(PING));
-	ut_asserteq_str("eth@10004000", getenv("ethact"));
+	ut_asserteq_str("eth@10004000", env_get("ethact"));
 
 	return 0;
 }
@@ -253,7 +253,7 @@
 	retval = _dm_test_net_retry(uts);
 
 	/* Restore the env */
-	setenv("netretry", NULL);
+	env_set("netretry", NULL);
 	sandbox_eth_disable_response(1, false);
 
 	return retval;
diff --git a/tools/Makefile b/tools/Makefile
index 0743677..a1790eb 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -37,7 +37,7 @@
 HOSTCFLAGS_bmp_logo.o := -pedantic
 
 hostprogs-$(CONFIG_BUILD_ENVCRC) += envcrc
-envcrc-objs := envcrc.o lib/crc32.o common/env_embedded.o lib/sha1.o
+envcrc-objs := envcrc.o lib/crc32.o env/embedded.o lib/sha1.o
 
 hostprogs-$(CONFIG_CMD_NET) += gen_eth_addr
 HOSTCFLAGS_gen_eth_addr.o := -pedantic
@@ -225,7 +225,7 @@
 quiet_cmd_wrap = WRAP    $@
 cmd_wrap = echo "\#include <../$(patsubst $(obj)/%,%,$@)>" >$@
 
-$(obj)/lib/%.c $(obj)/common/%.c:
+$(obj)/lib/%.c $(obj)/common/%.c $(obj)/env/%.c:
 	$(call cmd,wrap)
 
 clean-dirs := lib common
diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c
index c9c79e0..e50c075 100644
--- a/tools/env/fw_env.c
+++ b/tools/env/fw_env.c
@@ -468,7 +468,7 @@
  *	    modified or deleted
  *
  */
-int fw_setenv(int argc, char *argv[], struct env_opts *opts)
+int fw_env_set(int argc, char *argv[], struct env_opts *opts)
 {
 	int i;
 	size_t len;
diff --git a/tools/env/fw_env.h b/tools/env/fw_env.h
index 04bb646..2d37eb5 100644
--- a/tools/env/fw_env.h
+++ b/tools/env/fw_env.h
@@ -44,7 +44,7 @@
 int fw_printenv(int argc, char *argv[], int value_only, struct env_opts *opts);
 
 /**
- * fw_setenv() - adds or removes one variable to the environment
+ * fw_env_set() - adds or removes one variable to the environment
  *
  * @argc: number of strings in argv, argv[0] is variable name,
  *          argc==1 means erase variable, argc > 1 means add a variable
@@ -61,7 +61,7 @@
  * ERRORS:
  *  EROFS - some variables ("ethaddr", "serial#") cannot be modified
  */
-int fw_setenv(int argc, char *argv[], struct env_opts *opts);
+int fw_env_set(int argc, char *argv[], struct env_opts *opts);
 
 /**
  * fw_parse_script() - adds or removes multiple variables with a batch script
diff --git a/tools/env/fw_env_main.c b/tools/env/fw_env_main.c
index b8bff26..6e278ca 100644
--- a/tools/env/fw_env_main.c
+++ b/tools/env/fw_env_main.c
@@ -78,7 +78,7 @@
 		"\n");
 }
 
-void usage_setenv(void)
+void usage_env_set(void)
 {
 	fprintf(stderr,
 		"Usage: fw_setenv [OPTIONS]... [VARIABLE]...\n"
@@ -142,7 +142,7 @@
 			env_opts.lockname = optarg;
 			break;
 		case 'h':
-			do_printenv ? usage_printenv() : usage_setenv();
+			do_printenv ? usage_printenv() : usage_env_set();
 			exit(EXIT_SUCCESS);
 			break;
 		default:
@@ -202,7 +202,7 @@
 			/* ignore common options */
 			break;
 		default: /* '?' */
-			usage_setenv();
+			usage_env_set();
 			exit(EXIT_FAILURE);
 			break;
 		}
@@ -273,7 +273,7 @@
 			retval = EXIT_FAILURE;
 	} else {
 		if (!script_file) {
-			if (fw_setenv(argc, argv, &env_opts) != 0)
+			if (fw_env_set(argc, argv, &env_opts) != 0)
 				retval = EXIT_FAILURE;
 		} else {
 			if (fw_parse_script(script_file, &env_opts) != 0)