Patches u-boot for windcharger so that fw_printenv compiles.

Change-Id: I630642f90e4ce2fc7f18f3c84a47b204de55af5c
diff --git a/Makefile b/Makefile
index 66e551f..e5e2d02 100755
--- a/Makefile
+++ b/Makefile
@@ -59,7 +59,7 @@
 
 ifndef COMPRESSED_UBOOT
 COMPRESSED_UBOOT = 0
-endif 
+endif
 
 ifeq (include/config.mk,$(wildcard include/config.mk))
 # load ARCH, BOARD, and CPU configuration
@@ -83,7 +83,7 @@
 endif
 endif
 ifeq ($(ARCH),mips)
-CROSS_COMPILE = mips-linux-
+CROSS_COMPILE = mips-qca-linux-uclibc-
 endif
 ifeq ($(ARCH),nios)
 CROSS_COMPILE = nios-elf-
@@ -164,9 +164,9 @@
 LIBS += $(BOARDLIBS)
 
 ifeq ($(COMPRESSED_UBOOT),1)
-LIBS_BOOTSTRAP = lib_bootstrap/libbootstrap.a 
+LIBS_BOOTSTRAP = lib_bootstrap/libbootstrap.a
 #LIBS_BOOTSTRAP += lib_$(CPU)/lib$(CPU).a
-LIBS_BOOTSTRAP += board/$(BOARDDIR)/lib$(BOARD).a 
+LIBS_BOOTSTRAP += board/$(BOARDDIR)/lib$(BOARD).a
 LIBS_BOOTSTRAP += cpu/$(CPU)/lib$(CPU).a
 ifneq ($(SOC),)
 LIBS_BOOTSTRAP += cpu/$(CPU)/$(SOC)/lib$(SOC).a
@@ -235,11 +235,11 @@
 
 LZMA = $(BUILD_DIR)/util/lzma
 
-tuboot.bin:	System.map bootstrap.bin u-boot.lzimg	
+tuboot.bin:	System.map bootstrap.bin u-boot.lzimg
 		@cat bootstrap.bin > $@
 		@cat u-boot.lzimg >> $@
 
-u-boot.lzimg: $(obj)u-boot.bin System.map 
+u-boot.lzimg: $(obj)u-boot.bin System.map
 		@$(LZMA) e $(obj)u-boot.bin u-boot.bin.lzma
 		@./tools/mkimage -A mips -T firmware -C lzma \
 		-a 0x$(shell grep "T _start" $(TOPDIR)/System.map | awk '{ printf "%s", $$1 }') \
@@ -291,6 +291,9 @@
 		grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \
 		sort > System.map
 
+env:
+	$(MAKE) HOST_CFLAGS="-I$(TOPDIR)/include $(HOSTCFLAGS)" -C tools/env || exit 1
+
 #########################################################################
 else
 all install u-boot u-boot.srec depend dep:
@@ -2058,7 +2061,6 @@
 	@echo '#define FLASH_SIZE 32' >>include/config.h
 	@echo '#define ENABLE_EXT_ADDR_SUPPORT	$(EXT_ADDR_SUPPORT)'	>>include/config.h
 
-
 ifdef pll
 	@echo '#define CFG_PLL_FREQ		$(pll)'	>>include/config.h
 else
@@ -2866,7 +2868,7 @@
 ifeq ($(BUILD_EMU), 40)
     #
 	# No need to include CONFIG_HORNET_EMU_HARDI_WLAN in 40Mhz, only for emulation and 24Mhz board
-	#	
+	#
 else
     #
 	# Configure it as 24Mhz by default
@@ -2930,7 +2932,7 @@
 ifeq ($(BUILD_EMU), 40)
     #
 	# No need to include CONFIG_HORNET_EMU_HARDI_WLAN in 40Mhz, only for emulation and 24Mhz board
-	#	
+	#
 else
     #
 	# Configure it as 24Mhz by default
@@ -3300,7 +3302,7 @@
 endif #}
 ifeq ($(CFG_BOARD_TYPE), ap151-020)
 	@echo '#define UART_RX24_TX20           1'      >>include/config.h
-endif 
+endif
 ifeq ($(CFG_BOARD_TYPE), ap151)
 	@echo '#define UART_RX18_TX20           1'      >>include/config.h
 endif
@@ -3323,7 +3325,7 @@
 endif
 
 ifeq ($(ETH_CONFIG), _s27)
-	@echo '#define CFG_ATHRS27_PHY		1'	>>include/config.h	
+	@echo '#define CFG_ATHRS27_PHY		1'	>>include/config.h
 endif
 
 ifeq ($(ETH_CONFIG), _s17)
diff --git a/config.mk b/config.mk
index 99e2aaa..81d510f 100755
--- a/config.mk
+++ b/config.mk
@@ -13,7 +13,7 @@
 # the License, or (at your option) any later version.
 #
 # This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  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.
 #
@@ -139,7 +139,7 @@
 CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes \
 	-DBUILD_TAG='"$(BUILD_TAG)"'
 else
-CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes 
+CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes
 ifeq ($(COMPRESSED_UBOOT),1)
 CFLAGS += -DCOMPRESSED_UBOOT=1
 endif
diff --git a/include/linux/mtd/mtd-abi.h b/include/linux/mtd/mtd-abi.h
index 3d1d416..b426464 100755
--- a/include/linux/mtd/mtd-abi.h
+++ b/include/linux/mtd/mtd-abi.h
@@ -7,14 +7,16 @@
 #ifndef __MTD_ABI_H__
 #define __MTD_ABI_H__
 
+#include <linux/types.h>
+
 struct erase_info_user {
-	uint32_t start;
-	uint32_t length;
+	__u32 start;
+	__u32 length;
 };
 
 struct mtd_oob_buf {
-	uint32_t start;
-	uint32_t length;
+	__u32 start;
+	__u32 length;
 	unsigned char *ptr;
 };
 
@@ -58,22 +60,22 @@
 #define MTD_NANDECC_AUTOPL_USR 	4	/* Use the given autoplacement scheme rather than using the default */
 
 struct mtd_info_user {
-	uint8_t type;
-	uint32_t flags;
-	uint32_t size;	 /* Total size of the MTD */
-	uint32_t erasesize;
-	uint32_t oobblock;  /* Size of OOB blocks (e.g. 512) */
-	uint32_t oobsize;   /* Amount of OOB data per block (e.g. 16) */
-	uint32_t ecctype;
-	uint32_t eccsize;
+	__u8 type;
+	__u32 flags;
+	__u32 size;	 /* Total size of the MTD */
+	__u32 erasesize;
+	__u32 oobblock;  /* Size of OOB blocks (e.g. 512) */
+	__u32 oobsize;   /* Amount of OOB data per block (e.g. 16) */
+	__u32 ecctype;
+	__u32 eccsize;
 };
 
 struct region_info_user {
-	uint32_t offset;		/* At which this region starts,
+	__u32 offset;		/* At which this region starts,
 					 * from the beginning of the MTD */
-	uint32_t erasesize;		/* For this region */
-	uint32_t numblocks;		/* Number of blocks in this region */
-	uint32_t regionindex;
+	__u32 erasesize;		/* For this region */
+	__u32 numblocks;		/* Number of blocks in this region */
+	__u32 regionindex;
 };
 
 #define MEMGETINFO              _IOR('M', 1, struct mtd_info_user)
@@ -90,10 +92,10 @@
 #define MEMSETBADBLOCK		_IOW('M', 12, loff_t)
 
 struct nand_oobinfo {
-	uint32_t useecc;
-	uint32_t eccbytes;
-	uint32_t oobfree[8][2];
-	uint32_t eccpos[32];
+	__u32 useecc;
+	__u32 eccbytes;
+	__u32 oobfree[8][2];
+	__u32 eccpos[32];
 };
 
 #endif /* __MTD_ABI_H__ */
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index 0e08464..53bf85f 100755
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -9,9 +9,12 @@
 
 #ifndef __MTD_MTD_H__
 #define __MTD_MTD_H__
-#include <linux/types.h>
 #include <linux/mtd/mtd-abi.h>
 
+typedef struct mtd_info_user mtd_info_t;
+typedef struct erase_info_user erase_info_t;
+typedef struct region_info_user region_info_t;
+
 #define MAX_MTD_DEVICES 16
 
 #define MTD_ERASE_PENDING      	0x01
diff --git a/tools/env/Makefile b/tools/env/Makefile
index 9ce477c..9258a76 100755
--- a/tools/env/Makefile
+++ b/tools/env/Makefile
@@ -27,7 +27,7 @@
 all:	fw_printenv
 
 fw_printenv:	$(SOURCES) $(HEADERS)
-	$(CROSS_COMPILE)gcc -Wall -DUSE_HOSTCC $(SOURCES) -o fw_printenv
+	$(CROSS_COMPILE)gcc $(HOST_CFLAGS) -Wall -DUSE_HOSTCC $(SOURCES) -o fw_printenv
 
 clean:
 	rm -f fw_printenv crc32.c