Switch to little-endian buildroot

This change switches the default toolchain target to little-endian, so
we're able to build buildroot packages as LE.

Firmware components (skiboot, hostboot, etc) are kept as BE, so we
compile the toolchain as biarch.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
diff --git a/openpower/configs/firestone_defconfig b/openpower/configs/firestone_defconfig
index 074809c..966d8ed 100644
--- a/openpower/configs/firestone_defconfig
+++ b/openpower/configs/firestone_defconfig
@@ -1,7 +1,12 @@
-BR2_powerpc64=y
+BR2_powerpc64le=y
 BR2_powerpc_power8=y
 BR2_OPENPOWER_PLATFORM=y
 
+BR2_BINUTILS_EXTRA_CONFIG_OPTIONS="--enable-targets=powerpc64-linux"
+BR2_EXTRA_GCC_CONFIG_OPTIONS="--enable-targets=powerpc64-linux"
+BR2_TOOLCHAIN_BUILDROOT_CXX=y
+# BR2_TOOLCHAIN_BUILDROOT_LIBSTDCPP is not set
+
 BR2_OPENPOWER_CONFIG_NAME="firestone"
 BR2_OPENPOWER_XML_PACKAGE="firestone-xml"
 BR2_HOSTBOOT_CONFIG_FILE="firestone.config"
diff --git a/openpower/configs/habanero_defconfig b/openpower/configs/habanero_defconfig
index 59ae12c..756f60f 100644
--- a/openpower/configs/habanero_defconfig
+++ b/openpower/configs/habanero_defconfig
@@ -1,7 +1,12 @@
-BR2_powerpc64=y
+BR2_powerpc64le=y
 BR2_powerpc_power8=y
 BR2_OPENPOWER_PLATFORM=y
 
+BR2_BINUTILS_EXTRA_CONFIG_OPTIONS="--enable-targets=powerpc64-linux"
+BR2_EXTRA_GCC_CONFIG_OPTIONS="--enable-targets=powerpc64-linux"
+BR2_TOOLCHAIN_BUILDROOT_CXX=y
+# BR2_TOOLCHAIN_BUILDROOT_LIBSTDCPP is not set
+
 BR2_OPENPOWER_CONFIG_NAME="habanero"
 BR2_OPENPOWER_XML_PACKAGE="habanero-xml"
 BR2_HOSTBOOT_CONFIG_FILE="habanero.config"
diff --git a/openpower/configs/linux/skiroot_defconfig b/openpower/configs/linux/skiroot_defconfig
index 78a02c0..648de48 100644
--- a/openpower/configs/linux/skiroot_defconfig
+++ b/openpower/configs/linux/skiroot_defconfig
@@ -3,6 +3,7 @@
 CONFIG_VSX=y
 CONFIG_SMP=y
 CONFIG_NR_CPUS=2048
+CONFIG_CPU_LITTLE_ENDIAN=y
 # CONFIG_SWAP is not set
 CONFIG_SYSVIPC=y
 CONFIG_POSIX_MQUEUE=y
diff --git a/openpower/configs/palmetto_defconfig b/openpower/configs/palmetto_defconfig
index 7af16e9..ad36d6a 100644
--- a/openpower/configs/palmetto_defconfig
+++ b/openpower/configs/palmetto_defconfig
@@ -1,7 +1,12 @@
-BR2_powerpc64=y
+BR2_powerpc64le=y
 BR2_powerpc_power8=y
 BR2_OPENPOWER_PLATFORM=y
 
+BR2_BINUTILS_EXTRA_CONFIG_OPTIONS="--enable-targets=powerpc64-linux"
+BR2_EXTRA_GCC_CONFIG_OPTIONS="--enable-targets=powerpc64-linux"
+BR2_TOOLCHAIN_BUILDROOT_CXX=y
+# BR2_TOOLCHAIN_BUILDROOT_LIBSTDCPP is not set
+
 BR2_OPENPOWER_CONFIG_NAME="palmetto"
 BR2_OPENPOWER_XML_PACKAGE="palmetto-xml"
 BR2_HOSTBOOT_CONFIG_FILE="palmetto.config"
diff --git a/openpower/package/skiboot/skiboot-0002-libflash-Provide-an-internal-parity-implementation-t.patch b/openpower/package/skiboot/skiboot-0002-libflash-Provide-an-internal-parity-implementation-t.patch
new file mode 100644
index 0000000..e377567
--- /dev/null
+++ b/openpower/package/skiboot/skiboot-0002-libflash-Provide-an-internal-parity-implementation-t.patch
@@ -0,0 +1,87 @@
+From de70ad43ccee4dd51e9d38325c7713f590323a47 Mon Sep 17 00:00:00 2001
+From: Jeremy Kerr <jk@ozlabs.org>
+Date: Mon, 23 Feb 2015 16:43:53 +0800
+Subject: [PATCH] libflash: Provide an internal parity implementation, to
+ remove libgcc dependency
+
+In commit 8f5b8616, we introduced a dependency on libgcc, for the
+__builtin_parityl() function in commit 6cfaa3ba.
+
+However, if we're building with a biarch compiler, we may not have a
+libgcc available.
+
+This commit removes the __builtin_parityl() call, and replaces with the
+equivalent instructions, and removes the dependency on libgcc.
+
+Although this is untested, I have confirmed that the __builtin_parityl()
+functions emits the same instructions (on power7 and power8, with
+gcc-4.9) as we're using in the parity() function.
+
+Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
+---
+ Makefile.main  |  5 ++---
+ libflash/ecc.c | 14 +++++++++++++-
+ 2 files changed, 15 insertions(+), 4 deletions(-)
+
+diff --git a/Makefile.main b/Makefile.main
+index 665baf4..b5376fc 100644
+--- a/Makefile.main
++++ b/Makefile.main
+@@ -120,7 +120,6 @@ OBJS += $(LIBPORE)
+ endif
+ OBJS += $(LIBC) $(CCAN) $(DEVSRC_OBJ)
+ OBJS_NO_VER = $(OBJS)
+-EXTRA_LIBS = -Wl,-lgcc
+ ALL_OBJS = $(OBJS) version.o
+ 
+ ALL_OBJS_1 = $(ALL_OBJS) asm/dummy_map.o
+@@ -130,12 +129,12 @@ $(TARGET).lid: $(TARGET).elf
+ 	$(call Q,OBJCOPY, $(OBJCOPY) -O binary -S $^ $@, $@)
+ 
+ $(TARGET).tmp.elf: $(ALL_OBJS_1) $(TARGET).lds $(KERNEL)
+-	$(call Q,LD, $(CC) $(LDFLAGS) -T $(TARGET).lds $(ALL_OBJS_1) $(EXTRA_LIBS) -o $@, $@)
++	$(call Q,LD, $(CC) $(LDFLAGS) -T $(TARGET).lds $(ALL_OBJS_1) -o $@, $@)
+ 
+ asm/real_map.o : $(TARGET).tmp.map
+ 
+ $(TARGET).elf: $(ALL_OBJS_2) $(TARGET).lds $(KERNEL)
+-	$(call Q,LD, $(CC) $(LDFLAGS) -T $(TARGET).lds $(ALL_OBJS_2) $(EXTRA_LIBS) -o $@, $@)
++	$(call Q,LD, $(CC) $(LDFLAGS) -T $(TARGET).lds $(ALL_OBJS_2) -o $@, $@)
+ 
+ $(SUBDIRS):
+ 	$(call Q,MKDIR,mkdir $@, $@)
+diff --git a/libflash/ecc.c b/libflash/ecc.c
+index 9293743..3d94594 100644
+--- a/libflash/ecc.c
++++ b/libflash/ecc.c
+@@ -88,6 +88,18 @@ static uint8_t syndromematrix[] = {
+         UE, UE, UE, UE,  4, UE, UE, UE, UE, UE, UE, UE, UE, UE, UE, UE,
+ };
+ 
++static uint8_t parity(uint64_t data)
++{
++	uint8_t p;
++
++	asm volatile(
++		"popcntb %1,%0\n"
++		"prtyd   %1,%1\n"
++		: "=r"(p) : "r"(data));
++
++	return p;
++}
++
+ /**
+  * Create the ECC field corresponding to a 8-byte data field
+  *
+@@ -100,7 +112,7 @@ static uint8_t eccgenerate(uint64_t data)
+ 	uint8_t result = 0;
+ 
+ 	for (i = 0; i < 8; i++)
+-		result |= __builtin_parityl(eccmatrix[i] & data) << i;
++		result |= parity(eccmatrix[i] & data) << i;
+ 
+ 	return result;
+ }
+-- 
+1.9.1
+
diff --git a/openpower/package/skiboot/skiboot-0003-Makefile-specify-abiv1.patch b/openpower/package/skiboot/skiboot-0003-Makefile-specify-abiv1.patch
new file mode 100644
index 0000000..e689436
--- /dev/null
+++ b/openpower/package/skiboot/skiboot-0003-Makefile-specify-abiv1.patch
@@ -0,0 +1,27 @@
+From 11bff93ad1ca613b1db9d96e9ea9c46b7d7bf48d Mon Sep 17 00:00:00 2001
+From: Jeremy Kerr <jk@ozlabs.org>
+Date: Thu, 5 Mar 2015 22:44:40 +1100
+Subject: [PATCH] Makefile: specify abiv1
+
+Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
+---
+ Makefile.main | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/Makefile.main b/Makefile.main
+index 3c67037..76f0bd3 100644
+--- a/Makefile.main
++++ b/Makefile.main
+@@ -50,7 +50,8 @@ CPPFLAGS += -DBITS_PER_LONG=64 -DHAVE_BIG_ENDIAN
+ # causing all our printf's to warn
+ CPPFLAGS += -ffreestanding
+ 
+-CFLAGS := -fno-strict-aliasing -fstack-protector-all -pie -mbig-endian -m64
++CFLAGS := -fno-strict-aliasing -fstack-protector-all -pie \
++	  -mbig-endian -m64 -mabi=elfv1
+ 
+ ifeq ($(STACK_CHECK),1)
+ CFLAGS += -fstack-protector-all -pg
+-- 
+1.9.1
+
diff --git a/openpower/platform/Config.in b/openpower/platform/Config.in
index badcc22..206b343 100644
--- a/openpower/platform/Config.in
+++ b/openpower/platform/Config.in
@@ -1,4 +1,4 @@
 config BR2_OPENPOWER_PLATFORM
     bool "Enable the OpenPower Platform"
     default n
-    depends on BR2_powerpc64
+    depends on BR2_powerpc64 || BR2_powerpc64le