fa1db3d
From patchwork Tue Jun 20 21:55:25 2017
fa1db3d
Content-Type: text/plain; charset="utf-8"
fa1db3d
MIME-Version: 1.0
fa1db3d
Content-Transfer-Encoding: 7bit
fa1db3d
Subject: [U-Boot,2/2] board/db410c: fix fdt address
fa1db3d
From: Rob Clark <robdclark@gmail.com>
fa1db3d
X-Patchwork-Id: 778516
fa1db3d
Message-Id: <20170620215525.10430-2-robdclark@gmail.com>
fa1db3d
To: U-Boot Mailing List <u-boot@lists.denx.de>
fa1db3d
Cc: Nicolas Dechesne <nicolas.dechesne@linaro.org>,
fa1db3d
 Stephen Boyd <sboyd@codeaurora.org>
fa1db3d
Date: Tue, 20 Jun 2017 17:55:25 -0400
fa1db3d
fa1db3d
Signed-off-by: Rob Clark <robdclark@gmail.com>
fa1db3d
---
fa1db3d
Maybe there is a better way to not hardcode this?  But at least with
fa1db3d
the build of lk that I have, the fdt table is at 0x81e00000.  I guess
fa1db3d
there must be a more robust way to do this, since presumably lk when
fa1db3d
booting the linux kernel directly somehow passes the fdt address.
fa1db3d
fa1db3d
 include/configs/dragonboard410c.h | 2 +-
fa1db3d
 1 file changed, 1 insertion(+), 1 deletion(-)
fa1db3d
fa1db3d
diff --git a/include/configs/dragonboard410c.h b/include/configs/dragonboard410c.h
fa1db3d
index 11c842d..3b9932d 100644
fa1db3d
--- a/include/configs/dragonboard410c.h
fa1db3d
+++ b/include/configs/dragonboard410c.h
fa1db3d
@@ -105,7 +105,7 @@ REFLASH(dragonboard/u-boot.img, 8)\
fa1db3d
 	"linux_image=Image\0" \
fa1db3d
 	"kernel_addr_r=0x81000000\0"\
fa1db3d
 	"fdtfile=apq8016-sbc.dtb\0" \
fa1db3d
-	"fdt_addr_r=0x83000000\0"\
fa1db3d
+	"fdt_addr_r=0x81e00000\0"\
fa1db3d
 	"ramdisk_addr_r=0x84000000\0"\
fa1db3d
 	"scriptaddr=0x90000000\0"\
fa1db3d
 	"pxefile_addr_r=0x90100000\0"\
de20c9d
From a2782063c8daf9000d131e85200bc631a16450b4 Mon Sep 17 00:00:00 2001
de20c9d
From: Rob Clark <robdclark@gmail.com>
de20c9d
Date: Wed, 21 Jun 2017 14:21:15 -0400
de20c9d
Subject: [PATCH 01/23] WIP: fix usb
de20c9d
de20c9d
---
de20c9d
 common/usb_storage.c | 4 ++--
de20c9d
 1 file changed, 2 insertions(+), 2 deletions(-)
de20c9d
de20c9d
diff --git a/common/usb_storage.c b/common/usb_storage.c
de20c9d
index df0b057308..b2a3ab49ec 100644
de20c9d
--- a/common/usb_storage.c
de20c9d
+++ b/common/usb_storage.c
de20c9d
@@ -996,7 +996,7 @@ static int usb_request_sense(struct scsi_cmd *srb, struct us_data *ss)
de20c9d
 
de20c9d
 static int usb_test_unit_ready(struct scsi_cmd *srb, struct us_data *ss)
de20c9d
 {
de20c9d
-	int retries = 10;
de20c9d
+	int retries = 20;
de20c9d
 
de20c9d
 	do {
de20c9d
 		memset(&srb->cmd[0], 0, 12);
de20c9d
@@ -1019,7 +1019,7 @@ static int usb_test_unit_ready(struct scsi_cmd *srb, struct us_data *ss)
de20c9d
 		if ((srb->sense_buf[2] == 0x02) &&
de20c9d
 		    (srb->sense_buf[12] == 0x3a))
de20c9d
 			return -1;
de20c9d
-		mdelay(100);
de20c9d
+		mdelay(250);
de20c9d
 	} while (retries--);
de20c9d
 
de20c9d
 	return -1;
de20c9d
-- 
de20c9d
2.13.3
de20c9d
de20c9d
From 40b06f8d422efc1d9674f081ef22445904c01f4f Mon Sep 17 00:00:00 2001
de20c9d
From: Rob Clark <robdclark@gmail.com>
de20c9d
Date: Mon, 3 Jul 2017 08:34:37 -0400
de20c9d
Subject: [PATCH 02/23] HACK: disable emmc
de20c9d
de20c9d
Hitting some timeout which makes boot take much longer.  And
de20c9d
uefi/boot/rootfs partitions will be on sd-card or usb disk, etc,
de20c9d
so we can just ignore emmc.
de20c9d
---
de20c9d
 arch/arm/dts/dragonboard410c.dts | 2 ++
de20c9d
 1 file changed, 2 insertions(+)
de20c9d
de20c9d
diff --git a/arch/arm/dts/dragonboard410c.dts b/arch/arm/dts/dragonboard410c.dts
de20c9d
index 7746622dda..0d3b7a35f4 100644
de20c9d
--- a/arch/arm/dts/dragonboard410c.dts
de20c9d
+++ b/arch/arm/dts/dragonboard410c.dts
de20c9d
@@ -67,6 +67,7 @@
de20c9d
 			reg = <0x78d9000 0x400>;
de20c9d
 		};
de20c9d
 
de20c9d
+/*
de20c9d
 		sdhci@07824000 {
de20c9d
 			compatible = "qcom,sdhci-msm-v4";
de20c9d
 			reg = <0x7824900 0x11c 0x7824000 0x800>;
de20c9d
@@ -76,6 +77,7 @@
de20c9d
 			clock = <&clkc 0>;
de20c9d
 			clock-frequency = <100000000>;
de20c9d
 		};
de20c9d
+*/
de20c9d
 
de20c9d
 		sdhci@07864000 {
de20c9d
 			compatible = "qcom,sdhci-msm-v4";
de20c9d
-- 
de20c9d
2.13.3
de20c9d
de20c9d
From 03569f3ef44fd1208a68030c1740d7347bcf3fa3 Mon Sep 17 00:00:00 2001
de20c9d
From: Rob Clark <robdclark@gmail.com>
de20c9d
Date: Fri, 23 Jun 2017 15:36:33 -0400
de20c9d
Subject: [PATCH 03/23] dm: core: also parse chosen node
de20c9d
de20c9d
This is the node that would contain, for example, the framebuffer setup
de20c9d
by an earlier stage.
de20c9d
de20c9d
Signed-off-by: Rob Clark <robdclark@gmail.com>
de20c9d
---
de20c9d
 drivers/core/root.c | 22 +++++++++++++++++++++-
de20c9d
 1 file changed, 21 insertions(+), 1 deletion(-)
de20c9d
de20c9d
diff --git a/drivers/core/root.c b/drivers/core/root.c
de20c9d
index d691d6ff94..5e6b2da248 100644
de20c9d
--- a/drivers/core/root.c
de20c9d
+++ b/drivers/core/root.c
de20c9d
@@ -266,6 +266,26 @@ static int dm_scan_fdt_node(struct udevice *parent, const void *blob,
de20c9d
 	for (offset = fdt_first_subnode(blob, offset);
de20c9d
 	     offset > 0;
de20c9d
 	     offset = fdt_next_subnode(blob, offset)) {
de20c9d
+		ofnode node = offset_to_ofnode(offset);
de20c9d
+
de20c9d
+		/* "chosen" node isn't a device itself but may contain some: */
de20c9d
+		if (strcmp(ofnode_get_name(node), "chosen") == 0) {
de20c9d
+			dm_dbg("parsing subnodes of \"chosen\"\n");
de20c9d
+
de20c9d
+			for (node = ofnode_first_subnode(node);
de20c9d
+			     ofnode_valid(node);
de20c9d
+			     node = ofnode_next_subnode(node)) {
de20c9d
+				dm_dbg("subnode: %s\n", ofnode_get_name(node));
de20c9d
+				err = lists_bind_fdt(parent, node, NULL);
de20c9d
+				if (err && !ret) {
de20c9d
+					ret = err;
de20c9d
+					dm_dbg("%s: ret=%d\n", ofnode_get_name(node), ret);
de20c9d
+				}
de20c9d
+			}
de20c9d
+
de20c9d
+			continue;
de20c9d
+		}
de20c9d
+
de20c9d
 		if (pre_reloc_only &&
de20c9d
 		    !dm_fdt_pre_reloc(blob, offset))
de20c9d
 			continue;
de20c9d
@@ -273,7 +293,7 @@ static int dm_scan_fdt_node(struct udevice *parent, const void *blob,
de20c9d
 			dm_dbg("   - ignoring disabled device\n");
de20c9d
 			continue;
de20c9d
 		}
de20c9d
-		err = lists_bind_fdt(parent, offset_to_ofnode(offset), NULL);
de20c9d
+		err = lists_bind_fdt(parent, node, NULL);
de20c9d
 		if (err && !ret) {
de20c9d
 			ret = err;
de20c9d
 			debug("%s: ret=%d\n", fdt_get_name(blob, offset, NULL),
de20c9d
-- 
de20c9d
2.13.3
de20c9d
de20c9d
From 9f99ca35c96d4b564062bb86ddc62f7421632906 Mon Sep 17 00:00:00 2001
de20c9d
From: Rob Clark <robdclark@gmail.com>
de20c9d
Date: Thu, 22 Jun 2017 16:17:00 -0400
de20c9d
Subject: [PATCH 04/23] video: simplefb
de20c9d
de20c9d
Not really qcom specific, but for now qcom/lk is the one firmware that
de20c9d
is (afaiu) setting up the appropriate dt node for pre-configured
de20c9d
display.  Uses the generic simple-framebuffer DT bindings so this should
de20c9d
be useful on other platforms.
de20c9d
de20c9d
Signed-off-by: Rob Clark <robdclark@gmail.com>
de20c9d
---
de20c9d
 drivers/video/Kconfig    | 10 +++++++
de20c9d
 drivers/video/Makefile   |  2 +-
de20c9d
 drivers/video/simplefb.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++
de20c9d
 3 files changed, 82 insertions(+), 1 deletion(-)
de20c9d
 create mode 100644 drivers/video/simplefb.c
de20c9d
de20c9d
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
de20c9d
index 61dfed8c06..8eb0359231 100644
de20c9d
--- a/drivers/video/Kconfig
de20c9d
+++ b/drivers/video/Kconfig
de20c9d
@@ -628,4 +628,14 @@ config VIDEO_DW_HDMI
de20c9d
 	  rather requires a SoC-specific glue driver to call it), it
de20c9d
 	  can not be enabled from the configuration menu.
de20c9d
 
de20c9d
+config VIDEO_SIMPLE
de20c9d
+	bool "Simple display driver for preconfigured display"
de20c9d
+	help
de20c9d
+	  Enables a simple generic display driver which utilizes the
de20c9d
+	  simple-framebuffer devicetree bindings.
de20c9d
+
de20c9d
+	  This driver assumes that the display hardware has been initialized
de20c9d
+	  before u-boot starts, and u-boot will simply render to the pre-
de20c9d
+	  allocated frame buffer surface.
de20c9d
+
de20c9d
 endmenu
de20c9d
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
de20c9d
index ac5371f2ae..52f50f647b 100644
de20c9d
--- a/drivers/video/Makefile
de20c9d
+++ b/drivers/video/Makefile
de20c9d
@@ -57,7 +57,7 @@ obj-$(CONFIG_FORMIKE) += formike.o
de20c9d
 obj-$(CONFIG_LG4573) += lg4573.o
de20c9d
 obj-$(CONFIG_AM335X_LCD) += am335x-fb.o
de20c9d
 obj-$(CONFIG_VIDEO_DW_HDMI) += dw_hdmi.o
de20c9d
-
de20c9d
+obj-$(CONFIG_VIDEO_SIMPLE) += simplefb.o
de20c9d
 obj-${CONFIG_VIDEO_TEGRA124} += tegra124/
de20c9d
 obj-${CONFIG_EXYNOS_FB} += exynos/
de20c9d
 obj-${CONFIG_VIDEO_ROCKCHIP} += rockchip/
de20c9d
diff --git a/drivers/video/simplefb.c b/drivers/video/simplefb.c
de20c9d
new file mode 100644
de20c9d
index 0000000000..035a9761b9
de20c9d
--- /dev/null
de20c9d
+++ b/drivers/video/simplefb.c
de20c9d
@@ -0,0 +1,71 @@
de20c9d
+/*
de20c9d
+ * (C) Copyright 2017 Rob Clark
de20c9d
+ *
de20c9d
+ * SPDX-License-Identifier:	GPL-2.0+
de20c9d
+ */
de20c9d
+
de20c9d
+#include <common.h>
de20c9d
+#include <dm.h>
de20c9d
+#include <fdtdec.h>
de20c9d
+#include <fdt_support.h>
de20c9d
+#include <video.h>
de20c9d
+
de20c9d
+static int simple_video_probe(struct udevice *dev)
de20c9d
+{
de20c9d
+	struct video_uc_platdata *plat = dev_get_uclass_platdata(dev);
de20c9d
+	struct video_priv *uc_priv = dev_get_uclass_priv(dev);
de20c9d
+	const void *blob = gd->fdt_blob;
de20c9d
+	const int node = dev_of_offset(dev);
de20c9d
+	const char *format;
de20c9d
+	fdt_addr_t base;
de20c9d
+	fdt_size_t size;
de20c9d
+
de20c9d
+	base = fdtdec_get_addr_size_auto_parent(blob, dev_of_offset(dev->parent),
de20c9d
+			node, "reg", 0, &size, false);
de20c9d
+	if (base == FDT_ADDR_T_NONE) {
de20c9d
+		debug("%s: Failed to decode memory region\n", __func__);
de20c9d
+		return -EINVAL;
de20c9d
+	}
de20c9d
+
de20c9d
+	debug("%s: base=%llx, size=%llu\n", __func__, base, size);
de20c9d
+
de20c9d
+	// TODO is there some way to reserve the framebuffer
de20c9d
+	// region so it isn't clobbered?
de20c9d
+	plat->base = base;
de20c9d
+	plat->size = size;
de20c9d
+
de20c9d
+	video_set_flush_dcache(dev, true);
de20c9d
+
de20c9d
+	debug("%s: Query resolution...\n", __func__);
de20c9d
+
de20c9d
+	uc_priv->xsize = fdtdec_get_uint(blob, node, "width", 0);
de20c9d
+	uc_priv->ysize = fdtdec_get_uint(blob, node, "height", 0);
de20c9d
+	uc_priv->rot = 0;
de20c9d
+
de20c9d
+	format = fdt_getprop(blob, node, "format", NULL);
de20c9d
+	debug("%s: %dx%d@%s\n", __func__, uc_priv->xsize, uc_priv->ysize, format);
de20c9d
+
de20c9d
+	if (strcmp(format, "r5g6b5") == 0) {
de20c9d
+		uc_priv->bpix = VIDEO_BPP16;
de20c9d
+	} else if (strcmp(format, "a8b8g8r8") == 0) {
de20c9d
+		uc_priv->bpix = VIDEO_BPP32;
de20c9d
+	} else {
de20c9d
+		printf("%s: invalid format: %s\n", __func__, format);
de20c9d
+		return -EINVAL;
de20c9d
+	}
de20c9d
+
de20c9d
+	return 0;
de20c9d
+}
de20c9d
+
de20c9d
+static const struct udevice_id simple_video_ids[] = {
de20c9d
+	{ .compatible = "simple-framebuffer" },
de20c9d
+	{ }
de20c9d
+};
de20c9d
+
de20c9d
+U_BOOT_DRIVER(simple_video) = {
de20c9d
+	.name	= "simple_video",
de20c9d
+	.id	= UCLASS_VIDEO,
de20c9d
+	.of_match = simple_video_ids,
de20c9d
+	.probe	= simple_video_probe,
de20c9d
+	.flags	= DM_FLAG_PRE_RELOC,
de20c9d
+};
de20c9d
-- 
de20c9d
2.13.3
de20c9d
de20c9d
From 1d6f9273461ba5afa7f04cb8ea00fd87272642f8 Mon Sep 17 00:00:00 2001
de20c9d
From: Rob Clark <robdclark@gmail.com>
de20c9d
Date: Tue, 4 Jul 2017 09:16:08 -0400
de20c9d
Subject: [PATCH 05/23] video: add config option to skip framebuffer clear
de20c9d
de20c9d
The use-case is that the thing that loaded u-boot already put a splash
de20c9d
image on screen.  And we want to preserve that until grub boot menu
de20c9d
takes over.
de20c9d
de20c9d
Signed-off-by: Rob Clark <robdclark@gmail.com>
de20c9d
---
de20c9d
 drivers/video/Kconfig        | 8 ++++++++
de20c9d
 drivers/video/cfb_console.c  | 3 ++-
de20c9d
 drivers/video/video-uclass.c | 4 +++-
de20c9d
 3 files changed, 13 insertions(+), 2 deletions(-)
de20c9d
de20c9d
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
de20c9d
index 8eb0359231..7b56b20344 100644
de20c9d
--- a/drivers/video/Kconfig
de20c9d
+++ b/drivers/video/Kconfig
de20c9d
@@ -98,6 +98,14 @@ config SYS_WHITE_ON_BLACK
de20c9d
 	 better in low-light situations or to reduce eye strain in some
de20c9d
 	 cases.
de20c9d
 
de20c9d
+config NO_FB_CLEAR
de20c9d
+	bool "Skip framebuffer clear"
de20c9d
+	help
de20c9d
+	  If firmware (whatever loads u-boot) has already put a splash image
de20c9d
+	  on screen, you might want to preserve it until whatever u-boots
de20c9d
+	  loads takes over the screen.  This, for example, can be used to
de20c9d
+	  keep splash image on screen until grub graphical boot menu starts.
de20c9d
+
de20c9d
 source "drivers/video/fonts/Kconfig"
de20c9d
 
de20c9d
 config VIDCONSOLE_AS_LCD
de20c9d
diff --git a/drivers/video/cfb_console.c b/drivers/video/cfb_console.c
de20c9d
index f54802052e..85fa5b0cae 100644
de20c9d
--- a/drivers/video/cfb_console.c
de20c9d
+++ b/drivers/video/cfb_console.c
de20c9d
@@ -2091,7 +2091,8 @@ static int cfg_video_init(void)
de20c9d
 	}
de20c9d
 	eorx = fgx ^ bgx;
de20c9d
 
de20c9d
-	video_clear();
de20c9d
+	if (!CONFIG_IS_ENABLED(NO_FB_CLEAR))
de20c9d
+		video_clear();
de20c9d
 
de20c9d
 #ifdef CONFIG_VIDEO_LOGO
de20c9d
 	/* Plot the logo and get start point of console */
de20c9d
diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c
de20c9d
index 3036e3a1f2..dfa39b0d1b 100644
de20c9d
--- a/drivers/video/video-uclass.c
de20c9d
+++ b/drivers/video/video-uclass.c
de20c9d
@@ -199,7 +199,9 @@ static int video_post_probe(struct udevice *dev)
de20c9d
 #else
de20c9d
 	priv->colour_bg = 0xffffff;
de20c9d
 #endif
de20c9d
-	video_clear(dev);
de20c9d
+
de20c9d
+	if (!CONFIG_IS_ENABLED(NO_FB_CLEAR))
de20c9d
+		video_clear(dev);
de20c9d
 
de20c9d
 	/*
de20c9d
 	 * Create a text console device. For now we always do this, although
de20c9d
-- 
de20c9d
2.13.3
de20c9d
de20c9d
From d031c039a18b3a76a4ef16fb4ff8581a79f42fe3 Mon Sep 17 00:00:00 2001
de20c9d
From: Rob Clark <robdclark@gmail.com>
de20c9d
Date: Thu, 3 Aug 2017 09:52:14 -0400
de20c9d
Subject: [PATCH 06/23] fdtdec: allow board to provide fdt for
de20c9d
 CONFIG_OF_SEPARATE
de20c9d
de20c9d
Similar to CONFIG_OF_BOARD, but in this case the fdt is still built by
de20c9d
u-boot build.  This allows the board to patch the fdt, etc.
de20c9d
de20c9d
In the specific case of dragonboard 410c, we pass the u-boot generated
de20c9d
fdt to the previous stage of bootloader (by embedding it in the
de20c9d
u-boot.img that is loaded by lk/aboot), which patches the fdt and passes
de20c9d
it back to u-boot.
de20c9d
de20c9d
Signed-off-by: Rob Clark <robdclark@gmail.com>
de20c9d
---
de20c9d
 include/fdtdec.h |  3 ++-
de20c9d
 lib/fdtdec.c     | 45 ++++++++++++++++++++++++++-------------------
de20c9d
 2 files changed, 28 insertions(+), 20 deletions(-)
de20c9d
de20c9d
diff --git a/include/fdtdec.h b/include/fdtdec.h
de20c9d
index 4a0947c626..b9acec735a 100644
de20c9d
--- a/include/fdtdec.h
de20c9d
+++ b/include/fdtdec.h
de20c9d
@@ -986,7 +986,8 @@ int fdtdec_setup(void);
de20c9d
 
de20c9d
 /**
de20c9d
  * Board-specific FDT initialization. Returns the address to a device tree blob.
de20c9d
- * Called when CONFIG_OF_BOARD is defined.
de20c9d
+ * Called when CONFIG_OF_BOARD is defined, or if CONFIG_OF_SEPARATE is defined
de20c9d
+ * and the board implements it.
de20c9d
  */
de20c9d
 void *board_fdt_blob_setup(void);
de20c9d
 
de20c9d
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
de20c9d
index d2dbd0f122..07c458673c 100644
de20c9d
--- a/lib/fdtdec.c
de20c9d
+++ b/lib/fdtdec.c
de20c9d
@@ -1203,34 +1203,41 @@ int fdtdec_setup_memory_banksize(void)
de20c9d
 }
de20c9d
 #endif
de20c9d
 
de20c9d
-int fdtdec_setup(void)
de20c9d
+#ifdef CONFIG_OF_SEPARATE
de20c9d
+/*
de20c9d
+ * For CONFIG_OF_SEPARATE, the board may optionally implement this to
de20c9d
+ * provide and/or fixup the fdt.
de20c9d
+ */
de20c9d
+__weak void *board_fdt_blob_setup(void)
de20c9d
 {
de20c9d
-#if CONFIG_IS_ENABLED(OF_CONTROL)
de20c9d
-# ifdef CONFIG_OF_EMBED
de20c9d
-	/* Get a pointer to the FDT */
de20c9d
-	gd->fdt_blob = __dtb_dt_begin;
de20c9d
-# elif defined CONFIG_OF_SEPARATE
de20c9d
-#  ifdef CONFIG_SPL_BUILD
de20c9d
+	void *fdt_blob = NULL;
de20c9d
+#ifdef CONFIG_SPL_BUILD
de20c9d
 	/* FDT is at end of BSS unless it is in a different memory region */
de20c9d
 	if (IS_ENABLED(CONFIG_SPL_SEPARATE_BSS))
de20c9d
-		gd->fdt_blob = (ulong *)&_image_binary_end;
de20c9d
+		fdt_blob = (ulong *)&_image_binary_end;
de20c9d
 	else
de20c9d
-		gd->fdt_blob = (ulong *)&__bss_end;
de20c9d
+		fdt_blob = (ulong *)&__bss_end;
de20c9d
 
de20c9d
-#  elif defined CONFIG_FIT_EMBED
de20c9d
-	gd->fdt_blob = locate_dtb_in_fit(&_end);
de20c9d
+#elif defined CONFIG_FIT_EMBED
de20c9d
+	fdt_blob = locate_dtb_in_fit(&_end);
de20c9d
 
de20c9d
-	if (gd->fdt_blob == NULL || gd->fdt_blob <= ((void *)&_end)) {
de20c9d
+	if (fdt_blob == NULL || fdt_blob <= ((void *)&_end))
de20c9d
 		puts("Failed to find proper dtb in embedded FIT Image\n");
de20c9d
-		return -1;
de20c9d
-	}
de20c9d
-
de20c9d
-#  else
de20c9d
+#else
de20c9d
 	/* FDT is at end of image */
de20c9d
-	gd->fdt_blob = (ulong *)&_end;
de20c9d
+	fdt_blob = (ulong *)&_end;
de20c9d
 #  endif
de20c9d
-# elif defined(CONFIG_OF_BOARD)
de20c9d
-	/* Allow the board to override the fdt address. */
de20c9d
+	return fdt_blob;
de20c9d
+}
de20c9d
+#endif
de20c9d
+
de20c9d
+int fdtdec_setup(void)
de20c9d
+{
de20c9d
+#if CONFIG_IS_ENABLED(OF_CONTROL)
de20c9d
+# ifdef CONFIG_OF_EMBED
de20c9d
+	/* Get a pointer to the FDT */
de20c9d
+	gd->fdt_blob = __dtb_dt_begin;
de20c9d
+# elif defined(CONFIG_OF_SEPARATE) || defined(CONFIG_OF_BOARD)
de20c9d
 	gd->fdt_blob = board_fdt_blob_setup();
de20c9d
 # elif defined(CONFIG_OF_HOSTFILE)
de20c9d
 	if (sandbox_read_fdt_from_file()) {
de20c9d
-- 
de20c9d
2.13.3
de20c9d
de20c9d
From 7f0491168cf31c9935dede6fb1f560ef33cfb739 Mon Sep 17 00:00:00 2001
de20c9d
From: Rob Clark <robdclark@gmail.com>
de20c9d
Date: Fri, 23 Jun 2017 07:52:08 -0400
de20c9d
Subject: [PATCH 07/23] db410c: use fdt passed from lk
de20c9d
de20c9d
lk patches the fdt to set some device's MAC addresses and more
de20c9d
importantly to patch in the simple-framebuffer node that we want u-boot
de20c9d
to see.
de20c9d
de20c9d
Signed-off-by: Rob Clark <robdclark@gmail.com>
de20c9d
---
de20c9d
 board/qualcomm/dragonboard410c/Makefile          |  1 +
de20c9d
 board/qualcomm/dragonboard410c/dragonboard410c.c |  8 ++++++
de20c9d
 board/qualcomm/dragonboard410c/lowlevel_init.S   | 36 ++++++++++++++++++++++++
de20c9d
 3 files changed, 45 insertions(+)
de20c9d
 create mode 100644 board/qualcomm/dragonboard410c/lowlevel_init.S
de20c9d
de20c9d
diff --git a/board/qualcomm/dragonboard410c/Makefile b/board/qualcomm/dragonboard410c/Makefile
de20c9d
index cd678088fa..5082383be4 100644
de20c9d
--- a/board/qualcomm/dragonboard410c/Makefile
de20c9d
+++ b/board/qualcomm/dragonboard410c/Makefile
de20c9d
@@ -5,4 +5,5 @@
de20c9d
 #
de20c9d
 
de20c9d
 obj-y	:= dragonboard410c.o
de20c9d
+obj-y	+= lowlevel_init.o
de20c9d
 extra-y += head.o
de20c9d
diff --git a/board/qualcomm/dragonboard410c/dragonboard410c.c b/board/qualcomm/dragonboard410c/dragonboard410c.c
de20c9d
index 37d0b85e0e..1fa4dc1b15 100644
de20c9d
--- a/board/qualcomm/dragonboard410c/dragonboard410c.c
de20c9d
+++ b/board/qualcomm/dragonboard410c/dragonboard410c.c
de20c9d
@@ -27,6 +27,14 @@ int dram_init_banksize(void)
de20c9d
 	return 0;
de20c9d
 }
de20c9d
 
de20c9d
+extern unsigned long fw_dtb_pointer;
de20c9d
+
de20c9d
+void *board_fdt_blob_setup(void)
de20c9d
+{
de20c9d
+	if (fdt_magic(fw_dtb_pointer) != FDT_MAGIC)
de20c9d
+		return NULL;
de20c9d
+	return (void *)fw_dtb_pointer;
de20c9d
+}
de20c9d
 
de20c9d
 int board_prepare_usb(enum usb_init_type type)
de20c9d
 {
de20c9d
diff --git a/board/qualcomm/dragonboard410c/lowlevel_init.S b/board/qualcomm/dragonboard410c/lowlevel_init.S
de20c9d
new file mode 100644
de20c9d
index 0000000000..cdbd8e14db
de20c9d
--- /dev/null
de20c9d
+++ b/board/qualcomm/dragonboard410c/lowlevel_init.S
de20c9d
@@ -0,0 +1,36 @@
de20c9d
+/*
de20c9d
+ * (C) Copyright 2016
de20c9d
+ * C├ędric Schieli <cschieli@gmail.com>
de20c9d
+ *
de20c9d
+ * SPDX-License-Identifier:	GPL-2.0+
de20c9d
+ */
de20c9d
+
de20c9d
+#include <config.h>
de20c9d
+
de20c9d
+.align 8
de20c9d
+.global fw_dtb_pointer
de20c9d
+fw_dtb_pointer:
de20c9d
+#ifdef CONFIG_ARM64
de20c9d
+	.dword 0x0
de20c9d
+#else
de20c9d
+	.word 0x0
de20c9d
+#endif
de20c9d
+
de20c9d
+/*
de20c9d
+ * Routine: save_boot_params (called after reset from start.S)
de20c9d
+ * Description: save ATAG/FDT address provided by the firmware at boot time
de20c9d
+ */
de20c9d
+
de20c9d
+.global save_boot_params
de20c9d
+save_boot_params:
de20c9d
+
de20c9d
+	/* The firmware provided ATAG/FDT address can be found in r2/x0 */
de20c9d
+#ifdef CONFIG_ARM64
de20c9d
+	adr	x8, fw_dtb_pointer
de20c9d
+	str	x0, [x8]
de20c9d
+#else
de20c9d
+	str	r2, fw_dtb_pointer
de20c9d
+#endif
de20c9d
+
de20c9d
+	/* Returns */
de20c9d
+	b	save_boot_params_ret
de20c9d
-- 
de20c9d
2.13.3
de20c9d
de20c9d
From 9999019fa74908218fd85a51f8c4b45231f9489a Mon Sep 17 00:00:00 2001
de20c9d
From: Rob Clark <robdclark@gmail.com>
de20c9d
Date: Wed, 19 Jul 2017 11:40:15 -0400
de20c9d
Subject: [PATCH 08/23] db410c: add reserved-memory node to dts
de20c9d
de20c9d
If lk lights up display and populates simple-framebuffer node, it will
de20c9d
also setup a reserved-memory node (needed by simplefb on linux).  But
de20c9d
it isn't clever enough to cope when the reserved-memory node is not
de20c9d
present.
de20c9d
de20c9d
Signed-off-by: Rob Clark <robdclark@gmail.com>
de20c9d
---
de20c9d
 arch/arm/dts/dragonboard410c.dts | 7 ++++++-
de20c9d
 1 file changed, 6 insertions(+), 1 deletion(-)
de20c9d
de20c9d
diff --git a/arch/arm/dts/dragonboard410c.dts b/arch/arm/dts/dragonboard410c.dts
de20c9d
index 0d3b7a35f4..a47b95264c 100644
de20c9d
--- a/arch/arm/dts/dragonboard410c.dts
de20c9d
+++ b/arch/arm/dts/dragonboard410c.dts
de20c9d
@@ -23,11 +23,16 @@
de20c9d
 		reg = <0 0x80000000 0 0x3da00000>;
de20c9d
 	};
de20c9d
 
de20c9d
+	reserved-memory {
de20c9d
+		#address-cells = <2>;
de20c9d
+		#size-cells = <2>;
de20c9d
+		ranges;
de20c9d
+	};
de20c9d
+
de20c9d
 	chosen {
de20c9d
 		stdout-path = "/soc/serial@78b0000";
de20c9d
 	};
de20c9d
 
de20c9d
-
de20c9d
 	soc {
de20c9d
 		#address-cells = <0x1>;
de20c9d
 		#size-cells = <0x1>;
de20c9d
-- 
de20c9d
2.13.3
de20c9d
de20c9d
From 8f96a0198893ace6d53993ac091e81e7c0d1764c Mon Sep 17 00:00:00 2001
de20c9d
From: Rob Clark <robdclark@gmail.com>
de20c9d
Date: Sat, 24 Jun 2017 10:01:45 -0400
de20c9d
Subject: [PATCH 10/23] db410c: config updates
de20c9d
de20c9d
Signed-off-by: Rob Clark <robdclark@gmail.com>
de20c9d
---
de20c9d
 configs/dragonboard410c_defconfig | 11 +++++++++++
de20c9d
 1 file changed, 11 insertions(+)
de20c9d
de20c9d
diff --git a/configs/dragonboard410c_defconfig b/configs/dragonboard410c_defconfig
de20c9d
index c78b4a6fd5..d9cb269085 100644
de20c9d
--- a/configs/dragonboard410c_defconfig
de20c9d
+++ b/configs/dragonboard410c_defconfig
de20c9d
@@ -9,6 +9,7 @@ CONFIG_ENV_IS_NOWHERE=y
de20c9d
 CONFIG_SYS_PROMPT="dragonboard410c => "
de20c9d
 # CONFIG_CMD_IMI is not set
de20c9d
 # CONFIG_CMD_IMLS is not set
de20c9d
+CONFIG_CMD_POWEROFF=y
de20c9d
 CONFIG_CMD_MD5SUM=y
de20c9d
 CONFIG_CMD_MEMINFO=y
de20c9d
 CONFIG_CMD_UNZIP=y
de20c9d
@@ -21,11 +22,14 @@ CONFIG_CMD_TIMER=y
de20c9d
 CONFIG_CLK=y
de20c9d
 CONFIG_MSM_GPIO=y
de20c9d
 CONFIG_PM8916_GPIO=y
de20c9d
+CONFIG_DM_KEYBOARD=y
de20c9d
 CONFIG_LED=y
de20c9d
 CONFIG_LED_GPIO=y
de20c9d
 CONFIG_DM_MMC=y
de20c9d
 CONFIG_MMC_SDHCI=y
de20c9d
 CONFIG_MMC_SDHCI_MSM=y
de20c9d
+CONFIG_DM_ETH=y
de20c9d
+# CONFIG_NETDEVICES is not set
de20c9d
 CONFIG_DM_PMIC=y
de20c9d
 CONFIG_PMIC_PM8916=y
de20c9d
 CONFIG_MSM_SERIAL=y
de20c9d
@@ -38,4 +42,11 @@ CONFIG_USB_EHCI_MSM=y
de20c9d
 CONFIG_USB_ULPI_VIEWPORT=y
de20c9d
 CONFIG_USB_ULPI=y
de20c9d
 CONFIG_USB_STORAGE=y
de20c9d
+CONFIG_USB_KEYBOARD=y
de20c9d
+CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
de20c9d
+CONFIG_DM_VIDEO=y
de20c9d
+# CONFIG_VIDEO_BPP8 is not set
de20c9d
+CONFIG_NO_FB_CLEAR=y
de20c9d
+CONFIG_VIDEO_SIMPLE=y
de20c9d
+CONFIG_FAT_WRITE=y
de20c9d
 CONFIG_OF_LIBFDT_OVERLAY=y
de20c9d
-- 
de20c9d
2.13.3
de20c9d
de20c9d
From 4667c7da8cfb1883d5e734d1017b33e354e699eb Mon Sep 17 00:00:00 2001
de20c9d
From: Rob Clark <robdclark@gmail.com>
de20c9d
Date: Fri, 21 Jul 2017 16:24:03 -0400
de20c9d
Subject: [PATCH 11/23] db410c: enable r8152 usb eth
de20c9d
de20c9d
Signed-off-by: Rob Clark <robdclark@gmail.com>
de20c9d
---
de20c9d
 include/configs/dragonboard410c.h | 1 +
de20c9d
 1 file changed, 1 insertion(+)
de20c9d
de20c9d
diff --git a/include/configs/dragonboard410c.h b/include/configs/dragonboard410c.h
de20c9d
index 626dff8dcd..bbc9685e0e 100644
de20c9d
--- a/include/configs/dragonboard410c.h
de20c9d
+++ b/include/configs/dragonboard410c.h
de20c9d
@@ -44,6 +44,7 @@
de20c9d
 #define CONFIG_USB_ETHER_ASIX88179
de20c9d
 #define CONFIG_USB_ETHER_MCS7830
de20c9d
 #define CONFIG_USB_ETHER_SMSC95XX
de20c9d
+#define CONFIG_USB_ETHER_RTL8152
de20c9d
 
de20c9d
 /* Extra Commands */
de20c9d
 /* Enable that for switching of boot partitions */
de20c9d
-- 
de20c9d
2.13.3
de20c9d
de20c9d
From 76fba480e6ee494e2e01c19bb8952f42a3b6a710 Mon Sep 17 00:00:00 2001
de20c9d
From: Rob Clark <robdclark@gmail.com>
de20c9d
Date: Mon, 3 Jul 2017 09:15:44 -0400
de20c9d
Subject: [PATCH 12/23] usb: kbd: don't fail with iomux
de20c9d
de20c9d
stdin might not be set, which would cause iomux_doenv() to fail
de20c9d
therefore causing probe_usb_keyboard() to fail.  Furthermore if we do
de20c9d
have iomux enabled, the sensible thing (in terms of user experience)
de20c9d
would be to simply add ourselves to the list of stdin devices.
de20c9d
de20c9d
Signed-off-by: Rob Clark <robdclark@gmail.com>
de20c9d
---
de20c9d
 common/usb_kbd.c | 15 +++++++++++++++
de20c9d
 1 file changed, 15 insertions(+)
de20c9d
de20c9d
diff --git a/common/usb_kbd.c b/common/usb_kbd.c
de20c9d
index d2d29cc98f..703dd748f5 100644
de20c9d
--- a/common/usb_kbd.c
de20c9d
+++ b/common/usb_kbd.c
de20c9d
@@ -517,7 +517,22 @@ static int probe_usb_keyboard(struct usb_device *dev)
de20c9d
 
de20c9d
 	stdinname = getenv("stdin");
de20c9d
 #if CONFIG_IS_ENABLED(CONSOLE_MUX)
de20c9d
+	char *devname = DEVNAME;
de20c9d
+	/*
de20c9d
+	 * stdin might not be set yet.. either way, with console-mux the
de20c9d
+	 * sensible thing to do is add ourselves to the list of stdio
de20c9d
+	 * devices:
de20c9d
+	 */
de20c9d
+	if (stdinname && !strstr(stdinname, DEVNAME)) {
de20c9d
+		char *newstdin = malloc(strlen(stdinname) + strlen(","DEVNAME) + 1);
de20c9d
+		sprintf(newstdin, "%s,"DEVNAME, stdinname);
de20c9d
+		stdinname = newstdin;
de20c9d
+	} else if (!stdinname) {
de20c9d
+		stdinname = devname;
de20c9d
+	}
de20c9d
 	error = iomux_doenv(stdin, stdinname);
de20c9d
+	if (stdinname != devname)
de20c9d
+		free(stdinname);
de20c9d
 	if (error)
de20c9d
 		return error;
de20c9d
 #else
de20c9d
-- 
de20c9d
2.13.3
de20c9d
de20c9d
From 47f22a41df082c62411389ab5bf6e9ae26d93083 Mon Sep 17 00:00:00 2001
de20c9d
From: Rob Clark <robdclark@gmail.com>
de20c9d
Date: Wed, 19 Jul 2017 10:39:12 -0400
de20c9d
Subject: [PATCH 13/23] usb: kbd: add missing \n
de20c9d
de20c9d
Signed-off-by: Rob Clark <robdclark@gmail.com>
de20c9d
---
de20c9d
 common/usb_kbd.c | 2 +-
de20c9d
 1 file changed, 1 insertion(+), 1 deletion(-)
de20c9d
de20c9d
diff --git a/common/usb_kbd.c b/common/usb_kbd.c
de20c9d
index 703dd748f5..92d5e96d01 100644
de20c9d
--- a/common/usb_kbd.c
de20c9d
+++ b/common/usb_kbd.c
de20c9d
@@ -655,7 +655,7 @@ static int usb_kbd_remove(struct udevice *dev)
de20c9d
 
de20c9d
 	return 0;
de20c9d
 err:
de20c9d
-	printf("%s: warning, ret=%d", __func__, ret);
de20c9d
+	printf("%s: warning, ret=%d\n", __func__, ret);
de20c9d
 	return ret;
de20c9d
 }
de20c9d
 
de20c9d
-- 
de20c9d
2.13.3
de20c9d
de20c9d
From 54997f67cc935704cab36025d98d27eaf5a4aa7c Mon Sep 17 00:00:00 2001
de20c9d
From: Rob Clark <robdclark@gmail.com>
de20c9d
Date: Mon, 26 Jun 2017 10:29:40 -0400
de20c9d
Subject: [PATCH 09/23] db410c: on aarch64 the fdtfile is in per-vendor
de20c9d
 subdirectory
de20c9d
de20c9d
Signed-off-by: Rob Clark <robdclark@gmail.com>
de20c9d
---
de20c9d
 include/configs/dragonboard410c.h | 2 +-
de20c9d
 1 file changed, 1 insertion(+), 1 deletion(-)
de20c9d
de20c9d
diff --git a/include/configs/dragonboard410c.h b/include/configs/dragonboard410c.h
de20c9d
index d9dc639aeb..626dff8dcd 100644
de20c9d
--- a/include/configs/dragonboard410c.h
de20c9d
+++ b/include/configs/dragonboard410c.h
de20c9d
@@ -104,7 +104,7 @@
de20c9d
 	"initrd_high=0xffffffffffffffff\0" \
de20c9d
 	"linux_image=Image\0" \
de20c9d
 	"kernel_addr_r=0x81000000\0"\
de20c9d
-	"fdtfile=apq8016-sbc.dtb\0" \
de20c9d
+	"fdtfile=qcom/apq8016-sbc.dtb\0" \
de20c9d
 	"fdt_addr_r=0x81e00000\0"\
de20c9d
 	"ramdisk_addr_r=0x84000000\0"\
de20c9d
 	"scriptaddr=0x90000000\0"\
de20c9d
-- 
de20c9d
2.13.3
de20c9d