skiboot: Add BR2_SKIBOOT_DEVICETREE

Introduce a buildroot option to build skiboot's external/devicetree
directory and deliver the binaries as op-build output images.

Signed-off-by: Reza Arbab <arbab@linux.ibm.com>
diff --git a/openpower/configs/opal_defconfig b/openpower/configs/opal_defconfig
index 89f9a8f..a790aef 100644
--- a/openpower/configs/opal_defconfig
+++ b/openpower/configs/opal_defconfig
@@ -49,4 +49,5 @@
 BR2_PACKAGE_PETITBOOT=y
 # BR2_PACKAGE_HOST_P8_PORE_BINUTILS is not set
 # BR2_PACKAGE_CAPP_UCODE is not set
+BR2_SKIBOOT_DEVICETREE=y
 # BR2_PACKAGE_IMA_CATALOG is not set
diff --git a/openpower/package/skiboot/Config.in b/openpower/package/skiboot/Config.in
index 01f9374..c55cf34 100644
--- a/openpower/package/skiboot/Config.in
+++ b/openpower/package/skiboot/Config.in
@@ -42,6 +42,9 @@
 	string "URL of custom repository"
 	depends on BR2_SKIBOOT_CUSTOM_GIT
 
+config BR2_SKIBOOT_DEVICETREE
+	bool "Build device trees"
+
 endif
 
 endmenu
diff --git a/openpower/package/skiboot/skiboot.mk b/openpower/package/skiboot/skiboot.mk
index 74c6623..5f3e258 100644
--- a/openpower/package/skiboot/skiboot.mk
+++ b/openpower/package/skiboot/skiboot.mk
@@ -18,6 +18,10 @@
 SKIBOOT_INSTALL_IMAGES = YES
 SKIBOOT_INSTALL_TARGET = NO
 
+ifeq ($(BR2_SKIBOOT_DEVICETREE),y)
+SKIBOOT_DEPENDENCIES += host-dtc
+endif
+
 SKIBOOT_MAKE_OPTS += CC="$(TARGET_CC)" LD="$(TARGET_LD)" \
 		     AS="$(TARGET_AS)" AR="$(TARGET_AR)" NM="$(TARGET_NM)" \
 		     OBJCOPY="$(TARGET_OBJCOPY)" OBJDUMP="$(TARGET_OBJDUMP)" \
@@ -37,10 +41,17 @@
 define SKIBOOT_BUILD_CMDS
 	$(TARGET_CONFIGURE_OPTS) SKIBOOT_VERSION=`cat $(SKIBOOT_VERSION_FILE)` \
 		$(MAKE) $(SKIBOOT_MAKE_OPTS) -C $(@D) all
+
+	$(if $(BR2_SKIBOOT_DEVICETREE), \
+		$(MAKE) -C $(@D)/external/devicetree)
 endef
 
 define SKIBOOT_INSTALL_IMAGES_CMDS
 	$(INSTALL) -D -m 755 $(@D)/skiboot.lid $(BINARIES_DIR)
+
+	$(if $(BR2_SKIBOOT_DEVICETREE), \
+		$(INSTALL) -D -m 644 \
+			$(@D)/external/devicetree/*.dtb $(BINARIES_DIR))
 endef
 
 $(eval $(generic-package))