All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tim Harvey <tharvey@gateworks.com>
To: u-boot@lists.denx.de
Subject: [U-Boot]  [RFC 03/22] thunderx: add FDT support
Date: Fri, 22 Feb 2019 10:03:00 -0800	[thread overview]
Message-ID: <20190222180319.32221-4-tharvey@gateworks.com> (raw)
In-Reply-To: <20190222180319.32221-1-tharvey@gateworks.com>

The thunderx boards use the Cavium Bringup and Diagnostics Kit (BDK) as a
secondary program loader (SPL). This initial boot firmware loads the
device-tree and passes it to the next layer of software in X1.

Signed-off-by: Tim Harvey <tharvey@gateworks.com>
---
 arch/arm/mach-thunderx/Makefile        |  2 +-
 arch/arm/mach-thunderx/fdt.c           | 50 ++++++++++++++++++++++++++
 arch/arm/mach-thunderx/lowlevel_init.S | 31 ++++++++++++++++
 board/cavium/thunderx/thunderx.c       | 12 +++++--
 4 files changed, 92 insertions(+), 3 deletions(-)
 create mode 100644 arch/arm/mach-thunderx/fdt.c
 create mode 100644 arch/arm/mach-thunderx/lowlevel_init.S

diff --git a/arch/arm/mach-thunderx/Makefile b/arch/arm/mach-thunderx/Makefile
index 34b6ecc2f9..fb457cb3e0 100644
--- a/arch/arm/mach-thunderx/Makefile
+++ b/arch/arm/mach-thunderx/Makefile
@@ -1,2 +1,2 @@
 # SPDX-License-Identifier: GPL-2.0+
-obj-y	:= atf.o
+obj-y	:= atf.o lowlevel_init.o fdt.o
diff --git a/arch/arm/mach-thunderx/fdt.c b/arch/arm/mach-thunderx/fdt.c
new file mode 100644
index 0000000000..31f1128e9f
--- /dev/null
+++ b/arch/arm/mach-thunderx/fdt.c
@@ -0,0 +1,50 @@
+// SPDX-License-Identifier:	GPL-2.0+
+/**
+ * Copyright (C) 2014, Cavium Inc.
+ */
+
+#include <common.h>
+#include <malloc.h>
+#include <errno.h>
+#include <environment.h>
+#include <fdtdec.h>
+
+/* From lowlevel_init.S */
+extern unsigned long fdt_base_addr;
+
+/**
+ * If the firmware passed a device tree use it for U-Boot
+ *
+ * @return	FDT base address received from ATF in x1 register
+ */
+void *board_fdt_blob_setup(void)
+{
+        if (fdt_magic(fdt_base_addr) != FDT_MAGIC)
+                return NULL;
+	return (void *)fdt_base_addr;
+}
+
+int ft_board_setup(void *blob, bd_t *bd)
+{
+	int offset;
+	int ret = 0;
+
+	debug("%s\n", __func__);
+	ret = fdt_check_header(blob);
+	if (ret < 0) {
+		printf("ERROR: %s\n", fdt_strerror(ret));
+		return ret;
+	}
+
+	/* remove "cavium, bdk" node from DT */
+	if (blob) {
+		offset = fdt_path_offset(blob, "/cavium,bdk");
+		if(offset >= 0) {
+			ret = fdt_del_node(blob, offset);
+			debug("%s deleted 'cavium,bdk' node\n", __func__);
+		}
+	}
+
+	return ret;
+}
+
diff --git a/arch/arm/mach-thunderx/lowlevel_init.S b/arch/arm/mach-thunderx/lowlevel_init.S
new file mode 100644
index 0000000000..fb81ac4fd0
--- /dev/null
+++ b/arch/arm/mach-thunderx/lowlevel_init.S
@@ -0,0 +1,31 @@
+// SPDX-License-Identifier:	GPL-2.0+
+/*
+ * Copyright (C) 2018, Cavium Inc.
+ */
+
+#include <linux/linkage.h>
+#include <asm/macro.h>
+
+.align 8
+.global fdt_base_addr
+fdt_base_addr:
+	.dword 0x0
+
+.global save_boot_params
+save_boot_params:
+	/* Read FDT base from x1 register passed by ATF */
+	adr	x21, fdt_base_addr
+	str	x1, [x21]
+
+	/* Returns */
+	b	save_boot_params_ret
+
+ENTRY(lowlevel_init)
+	mov	x29, lr			/* Save LR */
+
+	/* any lowlevel init should go here */
+
+	mov	lr, x29			/* Restore LR */
+	ret
+ENDPROC(lowlevel_init)
+
diff --git a/board/cavium/thunderx/thunderx.c b/board/cavium/thunderx/thunderx.c
index 2b80dc56f1..57dce5aee0 100644
--- a/board/cavium/thunderx/thunderx.c
+++ b/board/cavium/thunderx/thunderx.c
@@ -5,8 +5,9 @@
 
 #include <common.h>
 #include <dm.h>
-#include <malloc.h>
 #include <errno.h>
+#include <fdt_support.h>
+#include <malloc.h>
 #include <linux/compiler.h>
 
 #include <asm/arch-thunderx/atf.h>
@@ -38,7 +39,10 @@ U_BOOT_DEVICE(thunderx_serial1) = {
 	.name = "serial_pl01x",
 	.platdata = &serial1,
 };
-#endif
+#else
+/* From lowlevel_init.S */
+extern unsigned long fdt_base_addr;
+#endif // !CONFIG_IS_ENABLED(OF_CONTROL)
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -70,6 +74,10 @@ struct mm_region *mem_map = thunderx_mem_map;
 
 int board_init(void)
 {
+#if CONFIG_IS_ENABLED(OF_CONTROL)
+	ulong fdt_addr = (ulong)fdt_base_addr;
+	set_working_fdt_addr(fdt_addr);
+#endif
 	return 0;
 }
 
-- 
2.17.1

  parent reply	other threads:[~2019-02-22 18:03 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-22 18:02 [U-Boot] [RFC 00/22] Add support for Cavium Octeon-TX CN80XX/CN81XX Tim Harvey
2019-02-22 18:02 ` [U-Boot] [RFC 01/22] arm: introduce ARCH_THUNDERX Tim Harvey
2019-02-24 16:08   ` Alexander Graf
2019-02-24 16:13   ` Alexander Graf
2019-02-22 18:02 ` [U-Boot] [RFC 02/22] arm: add thunderx_81xx Tim Harvey
2019-02-24 16:35   ` Alexander Graf
2019-02-22 18:03 ` Tim Harvey [this message]
2019-02-24 16:39   ` [U-Boot] [RFC 03/22] thunderx: add FDT support Alexander Graf
2019-02-22 18:03 ` [U-Boot] [RFC 04/22] thunderx: add thunderx register definitions and misc functions Tim Harvey
2019-02-24 16:42   ` Alexander Graf
2019-02-22 18:03 ` [U-Boot] [RFC 05/22] thunderx: move DRAM prints to debug Tim Harvey
2019-02-22 18:03 ` [U-Boot] [RFC 06/22] dm: pci: add PCI SR-IOV EA support Tim Harvey
2019-02-22 18:03 ` [U-Boot] [RFC 07/22] fdt: add fdtdec_get_pci_bus_range Tim Harvey
2019-02-22 18:03 ` [U-Boot] [RFC 08/22] pci: add thunderx pci/ecam driver Tim Harvey
2019-02-22 18:03 ` [U-Boot] [RFC 09/22] pci: fix pce enumeration on thunderx Tim Harvey
2019-02-22 18:03 ` [U-Boot] [RFC 10/22] arm: include 64bit io accessors Tim Harvey
2019-02-22 18:03 ` [U-Boot] [RFC 11/22] gpio: add thunderx gpio driver Tim Harvey
2019-02-22 18:03 ` [U-Boot] [RFC 12/22] i2c: add thunderx I2C driver Tim Harvey
2019-02-22 18:03 ` [U-Boot] [RFC 13/22] spi: add thunderx SPI driver Tim Harvey
2019-02-22 18:03 ` [U-Boot] [RFC 14/22] xhci: add support for cavium thunderx XHCI Tim Harvey
2019-02-22 18:03 ` [U-Boot] [RFC 15/22] thunderx_81xx: add support for XHCI Tim Harvey
2019-02-22 18:03 ` [U-Boot] [RFC 16/22] thunderx_81xx: enable usb mass storage and usb ethernet Tim Harvey
2019-02-22 18:03 ` [U-Boot] [RFC 17/22] ahci: support 64bit systems Tim Harvey
2019-02-22 18:03 ` [U-Boot] [RFC 18/22] ahci: set n_ports from host caps Tim Harvey
2019-02-22 18:03 ` [U-Boot] [RFC 19/22] ahci: add support for ThunderX AHCI Tim Harvey
2019-02-22 18:03 ` [U-Boot] [RFC 20/22] thunderx_81xx: add AHCI support Tim Harvey
2019-02-22 18:03 ` [U-Boot] [RFC 21/22] net: add thunderx vnic drivers Tim Harvey
2019-02-22 18:03 ` [U-Boot] [RFC 22/22] pci: auto probe thunderx NIC devices Tim Harvey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190222180319.32221-4-tharvey@gateworks.com \
    --to=tharvey@gateworks.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.