Makefile for building gfrg240 u-boot images.

Makefile.gfiber that builds dev, prod, and openbox u-boot images
by executing the required config and build steps from the quantenna
tools.

Search for Quantenna specific files under quantenna/
Previously, Makefiles added -I parameters to CFLAGS that would collect
include files from outside the u-boot tree.

Add support for CONFIG_DISABLE_INPUT configuration to disable
console input for production builds.

Change-Id: I7c48ac2d9b2e6052eb7c1048e9245e6174d17fea
diff --git a/Makefile.gfiber b/Makefile.gfiber
new file mode 100644
index 0000000..7442d4a
--- /dev/null
+++ b/Makefile.gfiber
@@ -0,0 +1,80 @@
+#
+# Google makefile to build uboot for quantenna qsr1000 products
+#
+
+export ARCH=arm
+export TOP=$(PWD)
+export CROSS_TOOLDIR=$(TOP)/../../toolchains/quantenna/usr/bin/
+export CROSS_PREFIX=arc-buildroot-linux-uclibc-
+export CROSS_COMPILE=$(CROSS_TOOLDIR)/$(CROSS_PREFIX)
+
+version = $(shell ./version)
+
+LOADERBIN_GFRG240 = ../../loader-bin/quantenna/gfrg240
+
+GFRG240 = gfrg240-dev gfrg240-prod gfrg240-openbox
+
+all:		clean $(GFRG240)
+
+# don't run parallel, the several builds would mix .o files
+.NOTPARALLEL:
+
+clean:
+	make clean
+	rm -rf output.*
+
+clobber: clean
+	-make distclean
+	rm -rf output
+
+gfiber_private.pem:
+	@echo "$@ is required to sign binaries. Get a copy and put it next to Makefile.gfiber"
+	exit 1
+
+#
+# GENERATE_DIGEST(DIR, NAME)
+#
+define GENERATE_DIGEST
+	@echo "Generating digest for $(1)/$(2)"
+	openssl dgst -sign gfiber_private.pem -sha512 -binary -keyform \
+		PEM $(1)/$(2).bin > $(1)/$(2).sig
+endef
+
+install: gfiber_private.pem
+	mkdir -p $(LOADERBIN_GFRG240)
+	cp output/gfrg240-dev/*dev.bin $(LOADERBIN_GFRG240)/u-boot-dev.bin
+	cp output/gfrg240-prod/*prod.bin $(LOADERBIN_GFRG240)/u-boot-prod.bin
+	cp output/gfrg240-openbox/*openbox.bin $(LOADERBIN_GFRG240)/u-boot-openbox.bin
+	$(call GENERATE_DIGEST,$(LOADERBIN_GFRG240),u-boot-dev)
+	$(call GENERATE_DIGEST,$(LOADERBIN_GFRG240),u-boot-prod)
+	$(call GENERATE_DIGEST,$(LOADERBIN_GFRG240),u-boot-openbox)
+
+gfrg240-dev:
+	make -f Makefile clean
+	make -f Makefile ruby_config
+	make -f Makefile all
+	make -f Makefile ruby_mini_config
+	make -f piggy.mk TARGET=u-boot
+	mkdir -p output/$@
+	cp u-boot-piggy.bin output/$@/u-boot-dev.bin
+
+gfrg240-prod:
+	make -f Makefile clean
+	make -f Makefile ruby_config
+	echo "#define CONFIG_DISABLE_INPUT" >> include/config.h
+	echo "#define CONFIG_BOOT_DELAY 0" >> include/config.h
+	make -f Makefile all
+	make -f Makefile ruby_mini_config
+	make -f piggy.mk TARGET=u-boot
+	mkdir -p output/$@
+	cp u-boot-piggy.bin output/$@/u-boot-prod.bin
+
+gfrg240-openbox:
+	make -f Makefile clean
+	make -f Makefile ruby_config
+	echo "#undef CONFIG_DISABLE_INPUT" >> include/config.h
+	make -f Makefile all
+	make -f Makefile ruby_mini_config
+	make -f piggy.mk TARGET=u-boot
+	mkdir -p output/$@
+	cp u-boot-piggy.bin output/$@/u-boot-openbox.bin
diff --git a/board/ruby/Makefile b/board/ruby/Makefile
index 977ad76..d824f02 100644
--- a/board/ruby/Makefile
+++ b/board/ruby/Makefile
@@ -65,7 +65,7 @@
 	rm -f $(LIB) core *.bak .depend
 
 $(obj)u-boot.lds: u-boot.lds.S force
-	$(CPP) -I../../../ -I../../ $(CPPFLAGS) -D__ASSEMBLY__ -P $< > $@
+	$(CPP) -I../../quantenna/ -I../../ $(CPPFLAGS) -D__ASSEMBLY__ -P $< > $@
 
 .PHONY: force
 
diff --git a/common/console.c b/common/console.c
index 2add047..e60bcbd 100644
--- a/common/console.c
+++ b/common/console.c
@@ -295,6 +295,10 @@
 
 int getc(void)
 {
+#ifdef CONFIG_DISABLE_INPUT
+	return 0;
+#endif
+
 #ifdef CONFIG_DISABLE_CONSOLE
 	if (gd->flags & GD_FLG_DISABLE_CONSOLE)
 		return 0;
@@ -311,6 +315,10 @@
 
 int tstc(void)
 {
+#ifdef CONFIG_DISABLE_INPUT
+	return 0;
+#endif
+
 #ifdef CONFIG_DISABLE_CONSOLE
 	if (gd->flags & GD_FLG_DISABLE_CONSOLE)
 		return 0;
diff --git a/config.mk b/config.mk
index b0721ff..e163ba8 100644
--- a/config.mk
+++ b/config.mk
@@ -60,10 +60,10 @@
 	# PLATFORM_CPPFLAGS+= -D__ARC__ -mA7 -mno-sdata -O0 -g -mno-volatile-cache -fomit-frame-pointer
 	# Enable optimization. Disable cache bypassing for "volatile" references.
 	# It is bad design to enable cache bypassing for "volatile" references - readX()/writeX() has to be used.
-	PLATFORM_CPPFLAGS_PATH = -I$(OBJTREE)/../common -I$(OBJTREE)/../include/qtn
+	PLATFORM_CPPFLAGS_PATH = -I$(OBJTREE)/quantenna/common -I$(OBJTREE)/quantenna/include/qtn
 	PLATFORM_CPPFLAGS += -D__ARC__ -mA7 -mno-sdata -Os -g -mvolatile-cache -fomit-frame-pointer $(PLATFORM_CPPFLAGS_PATH)
 endif
-HOST_CFLAGS += -I$(OBJTREE)/../common
+HOST_CFLAGS += -I$(OBJTREE)/quantenna/common
 
 #########################################################################
 #
diff --git a/helper.mk b/helper.mk
index 751519e..70648d9 100644
--- a/helper.mk
+++ b/helper.mk
@@ -3,6 +3,6 @@
 
 define build-mini-ldmap
 	@mkdir -p ${@D}
-	$(CPP) -D__ASSEMBLY__ -I../common -Iinclude $1 $< | grep -vE '^\#' > $@
+	$(CPP) -D__ASSEMBLY__ -Iquantenna/common -Iinclude $1 $< | grep -vE '^\#' > $@
 endef
 
diff --git a/include/asm-arc/arch-arc/arasan_emac_ahb.h b/include/asm-arc/arch-arc/arasan_emac_ahb.h
index 8990890..e3315a7 100755
--- a/include/asm-arc/arch-arc/arasan_emac_ahb.h
+++ b/include/asm-arc/arch-arc/arasan_emac_ahb.h
@@ -36,7 +36,7 @@
 
 /* All the common defines for the Ethernet controller */
 #include <config.h>
-#include "../../../../common/ruby_arasan_emac_ahb.h"
+#include "../../../quantenna/common/ruby_arasan_emac_ahb.h"
 
 #ifndef __ASSEMBLY__
 
diff --git a/piggy.mk b/piggy.mk
index 7e1f769..090e18c 100644
--- a/piggy.mk
+++ b/piggy.mk
@@ -1,6 +1,5 @@
 
 include helper.mk
-include ../Make.toolchain
 
 CFLAGS =
 CC = $(CROSS_COMPILE)gcc
@@ -53,7 +52,7 @@
 		-nostdinc \
 		-mno-sdata -mvolatile-cache -mno-millicode \
 		-pipe \
-		-Iinclude/ -Iboard/ruby/ -I../common/ -I../include/qtn/ \
+		-Iinclude/ -Iboard/ruby/ -Iquantenna/common/ -Iquantenna/include/qtn/ \
 		-isystem $(gccincdir) \
 		-DTEXT_BASE_OFFSET=$(TEXT_BASE_OFFSET_PARENT) \
 		-DTEXT_BASE_OFFSET_CHILD=$(TEXT_BASE_OFFSET_CHILD) \
@@ -88,7 +87,7 @@
 	lib_generic/vsprintf.o			\
 	lib_generic/string.o
 
-LDFLAGS = -L $(tools_path)../lib/gcc/arc-linux-uclibc/4.2.1/ -lgcc
+LDFLAGS = -lgcc
 endif
 
 ifeq ($(TOPAZ_EP_MINI_UBOOT),1)
@@ -105,7 +104,7 @@
 	lib_generic/lzma/LzmaTools.o	\
 	$(LZMA_LIB)
 
-LZMA = ../host/utilities/lzma
+LZMA = quantenna/host/utilities/lzma
 LDMAP = $(BUILD_DIR)/u-boot-piggy.lds
 
 %.lzma: %
diff --git a/qtn_tiny.mk b/qtn_tiny.mk
index a415801..c1a6ee4 100644
--- a/qtn_tiny.mk
+++ b/qtn_tiny.mk
@@ -5,7 +5,6 @@
 #
 
 include helper.mk
-include ../Make.toolchain
 
 CFLAGS =
 CC = $(CROSS_COMPILE)gcc
@@ -34,7 +33,7 @@
 		-nostdinc \
 		-mno-sdata -mvolatile-cache -mno-millicode \
 		-pipe \
-		-Iboard/ruby/ -Iinclude/ -I../common/ -I../include/qtn/ \
+		-Iboard/ruby/ -Iinclude/ -Iquantenna/common/ -Iquantenna/include/qtn/ \
 		-isystem $(gccincdir) \
 		-DTEXT_BASE_OFFSET=$(UBOOT_TINY_TEXT_BASE_OFFSET) \
 
@@ -70,7 +69,7 @@
 	board/ruby_mini/ruby_mini_common.o	\
 	board/ruby_mini/ruby_tiny.o
 
-LDFLAGS = -L $(tools_path)../lib/gcc/arc-linux-uclibc/4.2.1/ -lgcc
+LDFLAGS = -lgcc
 
 LDMAP = $(BUILD_DIR)/u-boot-$(TARGET).lds
 
diff --git a/quantenna/Make.toolchain b/quantenna/Make.toolchain
deleted file mode 100644
index f23b873..0000000
--- a/quantenna/Make.toolchain
+++ /dev/null
@@ -1,6 +0,0 @@
-tools_path := /usr/local/ARC/gcc/bin/
-target_prefix := arc-linux-uclibc-
-compile_prefix := ${tools_path}${target_prefix}
-CROSS_COMPILE := ${compile_prefix}
-ARCH := arc
-