This patch adds the basic board init routines that invoke the common and
mach-snapdragon specific SPL frameworks to proceed with the hand over from
boot rom to the next stage i.e. U-Boot proper. This also provides the
linker script to generate the SPL image in the format expected by the boot
rom.

Reviewed-by: Balaji Selvanathan <[email protected]>
Reviewed-by: Simon Glass <[email protected]>
Signed-off-by: Varadarajan Narayanan <[email protected]>
---
 arch/arm/mach-snapdragon/include/mach/spl.h     | 14 ++++
 board/qualcomm/ipq5210/Makefile                 |  3 +
 board/qualcomm/ipq5210/ipq5210-spl-wrap-elf.lds | 18 +++++
 board/qualcomm/ipq5210/spl-ipq5210.c            | 96 +++++++++++++++++++++++++
 include/configs/ipq5210.h                       | 11 +++
 5 files changed, 142 insertions(+)

diff --git a/arch/arm/mach-snapdragon/include/mach/spl.h 
b/arch/arm/mach-snapdragon/include/mach/spl.h
new file mode 100644
index 00000000000..9e09bad82bc
--- /dev/null
+++ b/arch/arm/mach-snapdragon/include/mach/spl.h
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
+ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
+ */
+
+#ifndef __SPL_H__
+#define __SPL_H__
+
+void qcom_spl_malloc_init_f(void);
+int qcom_spl_loader_pre_ddr(u8 boot_device);
+int qclib_post_process_from_spl(void);
+void qcom_spl_error_handler(void *arg);
+
+#endif /* __SPL_H__ */
diff --git a/board/qualcomm/ipq5210/Makefile b/board/qualcomm/ipq5210/Makefile
new file mode 100644
index 00000000000..d808c106524
--- /dev/null
+++ b/board/qualcomm/ipq5210/Makefile
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0
+
+obj-$(CONFIG_SPL) := spl-ipq5210.o
diff --git a/board/qualcomm/ipq5210/ipq5210-spl-wrap-elf.lds 
b/board/qualcomm/ipq5210/ipq5210-spl-wrap-elf.lds
new file mode 100644
index 00000000000..f0ced6765da
--- /dev/null
+++ b/board/qualcomm/ipq5210/ipq5210-spl-wrap-elf.lds
@@ -0,0 +1,18 @@
+/*
+ * SPDX-License-Identifier: GPL-2.0
+ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
+ */
+PHDRS {
+       ptype PT_LOAD FLAGS(0x7);
+}
+
+ENTRY(_entry)
+
+SECTIONS {
+       . = CONFIG_PLATFORM_ELFENTRY;
+       _entry = . ;
+       data : {
+               *(.data)
+               . = ALIGN(4);
+       } :ptype
+}
diff --git a/board/qualcomm/ipq5210/spl-ipq5210.c 
b/board/qualcomm/ipq5210/spl-ipq5210.c
new file mode 100644
index 00000000000..e0c52c0a6f6
--- /dev/null
+++ b/board/qualcomm/ipq5210/spl-ipq5210.c
@@ -0,0 +1,96 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
+ */
+#include <hang.h>
+#include <cpu_func.h>
+#include <event.h>
+#include <init.h>
+#include <image.h>
+#include <spl.h>
+#include <spl_load.h>
+#include <asm/io.h>
+#include <asm/system.h>
+#include <asm/sections.h>
+#include <soc/qcom/smem.h>
+#include <atf_common.h>
+#include <linux/err.h>
+#include <dm/device-internal.h>
+#include <part.h>
+#include <blk.h>
+#include <dm/uclass.h>
+#include <mach/pbl.h>
+#include <mach/spl.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#if defined(CONFIG_SPL_BUILD)
+/**
+ * board_init_f() - Main entry point for SPL.
+ * @dummy:     Dummy argument (unused).
+ */
+void board_init_f(ulong dummy)
+{
+       int ret;
+
+       memset(__bss_start, 0, __bss_end - __bss_start); /* Clear BSS */
+
+       qcom_spl_malloc_init_f();
+
+       ret = spl_early_init();
+       if (ret) {
+               pr_debug("spl_early_init() failed (%d)\n", ret);
+               goto fail;
+       }
+
+       event_notify_null(EVT_LAST_STAGE_INIT);
+
+       preloader_console_init();
+
+       ret = qcom_spl_loader_pre_ddr(spl_boot_device());
+       if (ret) {
+               pr_debug("qcom_spl_loader_pre_ddr() failed (%d)\n", ret);
+               goto fail;
+       }
+
+       ret = qclib_post_process_from_spl();
+       if (ret) {
+               pr_debug("qclib_post_process_from_spl() failed (%d)\n", ret);
+               goto fail;
+       }
+
+       board_init_r(NULL, 0);
+
+fail:
+       if (ret)
+               reset_cpu();
+}
+#endif /* CONFIG_SPL_BUILD */
+
+int board_fit_config_name_match(const char *name)
+{
+       /*
+        * SPL loads the pre-HLOS images from bootldr FIT image
+        * as below
+        *
+        * In board_init_f() - Matches "pre-ddr" configuration node and
+        * load the images mentioned in its <loadables>
+        *
+        * In board_init_r() - Matches "post-ddr" configuration node and
+        * load the images mentioned in its <loadables>
+        *
+        */
+       if (!(gd->flags & GD_FLG_SPL_INIT)) {
+               if (!strcmp(name, "pre-ddr")) {
+                       printf("Selected FIT Config: %s\n", name);
+                       return 0;
+               }
+       } else {
+               if (!strcmp(name, "post-ddr")) {
+                       printf("Selected FIT Config: %s\n", name);
+                       return 0;
+               }
+       }
+
+       return -EINVAL;
+}
diff --git a/include/configs/ipq5210.h b/include/configs/ipq5210.h
new file mode 100644
index 00000000000..5cbf838af82
--- /dev/null
+++ b/include/configs/ipq5210.h
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
+ */
+
+#ifndef __CONFIGS_IPQ5210_H
+#define __CONFIGS_IPQ5210_H
+
+#include <linux/sizes.h>
+
+#endif

-- 
2.34.1

Reply via email to