summaryrefslogtreecommitdiff
path: root/common/spl
diff options
context:
space:
mode:
authorTom Rini <[email protected]>2023-10-02 10:55:44 -0400
committerTom Rini <[email protected]>2023-10-02 10:55:44 -0400
commitac897385bbfa30cfdfb62ccf24acfcd4b274b2ff (patch)
treeae567980737beb24ca24e2ee8cfeaf6eb9e26e3f /common/spl
parent4459ed60cb1e0562bc5b40405e2b4b9bbf766d57 (diff)
parente29b932aa07fa0226d325b35d96cd4eea0370129 (diff)
Merge branch 'next'
Signed-off-by: Tom Rini <[email protected]>
Diffstat (limited to 'common/spl')
-rw-r--r--common/spl/Kconfig2
-rw-r--r--common/spl/Kconfig.tpl2
-rw-r--r--common/spl/spl.c8
-rw-r--r--common/spl/spl_dfu.c1
-rw-r--r--common/spl/spl_fit.c3
-rw-r--r--common/spl/spl_mmc.c2
-rw-r--r--common/spl/spl_opensbi.c1
-rw-r--r--common/spl/spl_ram.c19
-rw-r--r--common/spl/spl_sdp.c21
-rw-r--r--common/spl/spl_semihosting.c31
10 files changed, 67 insertions, 23 deletions
diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index c5dd476db58..1c2fe78e3e0 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -67,7 +67,7 @@ config SPL_SIZE_LIMIT_SUBTRACT_MALLOC
config SPL_SIZE_LIMIT_PROVIDE_STACK
hex "SPL image size check: provide stack space before relocation"
depends on SPL_SIZE_LIMIT > 0
- default 0
+ default 0x0
help
If set, this size is reserved in SPL_SIZE_LIMIT check to ensure such
an image does not overflow SRAM if SPL_SIZE_LIMIT describes the size
diff --git a/common/spl/Kconfig.tpl b/common/spl/Kconfig.tpl
index 3d6cf1e59f3..cc71578f646 100644
--- a/common/spl/Kconfig.tpl
+++ b/common/spl/Kconfig.tpl
@@ -126,7 +126,7 @@ config TPL_POWER
config TPL_TEXT_BASE
hex "Base address for the .text section of the TPL stage"
- default 0
+ default 0x0
help
The base address for the .text section of the TPL stage.
diff --git a/common/spl/spl.c b/common/spl/spl.c
index 0062f3f45d9..cd294e81b2a 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -45,10 +45,6 @@
DECLARE_GLOBAL_DATA_PTR;
DECLARE_BINMAN_MAGIC_SYM;
-#ifndef CFG_SYS_UBOOT_START
-#define CFG_SYS_UBOOT_START CONFIG_TEXT_BASE
-#endif
-
u32 *boot_params_ptr = NULL;
#if CONFIG_IS_ENABLED(BINMAN_UBOOT_SYMBOLS)
@@ -252,7 +248,7 @@ void spl_set_header_raw_uboot(struct spl_image_info *spl_image)
spl_image->entry_point = u_boot_pos;
spl_image->load_addr = u_boot_pos;
} else {
- spl_image->entry_point = CFG_SYS_UBOOT_START;
+ spl_image->entry_point = CONFIG_SYS_UBOOT_START;
spl_image->load_addr = CONFIG_TEXT_BASE;
}
spl_image->os = IH_OS_U_BOOT;
@@ -800,7 +796,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
IS_ENABLED(CONFIG_SPL_ATF))
dram_init_banksize();
- if (CONFIG_IS_ENABLED(PCI)) {
+ if (CONFIG_IS_ENABLED(PCI) && !(gd->flags & GD_FLG_DM_DEAD)) {
ret = pci_init();
if (ret)
puts(SPL_TPL_PROMPT "Cannot initialize PCI\n");
diff --git a/common/spl/spl_dfu.c b/common/spl/spl_dfu.c
index 5728d43ad3f..8a779da8fa1 100644
--- a/common/spl/spl_dfu.c
+++ b/common/spl/spl_dfu.c
@@ -15,6 +15,7 @@
#include <g_dnl.h>
#include <usb.h>
#include <dfu.h>
+#include <linux/printk.h>
static int run_dfu(int usb_index, char *interface, char *devstring)
{
diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index 730639f7562..b1668c0396c 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -17,6 +17,7 @@
#include <asm/cache.h>
#include <asm/global_data.h>
#include <linux/libfdt.h>
+#include <linux/printk.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -816,7 +817,7 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
}
/*
- * If a platform does not provide CFG_SYS_UBOOT_START, U-Boot's
+ * If a platform does not provide CONFIG_SYS_UBOOT_START, U-Boot's
* Makefile will set it to 0 and it will end up as the entry point
* here. What it actually means is: use the load address.
*/
diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
index a665091b00f..20f687e1389 100644
--- a/common/spl/spl_mmc.c
+++ b/common/spl/spl_mmc.c
@@ -229,7 +229,7 @@ static int mmc_load_image_raw_os(struct spl_image_info *spl_image,
{
int ret;
-#if CONFIG_VAL(SYS_MMCSD_RAW_MODE_ARGS_SECTOR)
+#if defined(CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR)
unsigned long count;
count = blk_dread(mmc_get_blk_desc(mmc),
diff --git a/common/spl/spl_opensbi.c b/common/spl/spl_opensbi.c
index e2aaa460468..0df611623ae 100644
--- a/common/spl/spl_opensbi.c
+++ b/common/spl/spl_opensbi.c
@@ -15,6 +15,7 @@
#include <asm/smp.h>
#include <opensbi.h>
#include <linux/libfdt.h>
+#include <linux/printk.h>
DECLARE_GLOBAL_DATA_PTR;
diff --git a/common/spl/spl_ram.c b/common/spl/spl_ram.c
index 93cf420d810..4158ed1c32d 100644
--- a/common/spl/spl_ram.c
+++ b/common/spl/spl_ram.c
@@ -20,12 +20,16 @@
static ulong spl_ram_load_read(struct spl_load_info *load, ulong sector,
ulong count, void *buf)
{
- ulong addr;
+ ulong addr = 0;
debug("%s: sector %lx, count %lx, buf %lx\n",
__func__, sector, count, (ulong)buf);
- addr = (ulong)CONFIG_SPL_LOAD_FIT_ADDRESS + sector;
+ if (IS_ENABLED(CONFIG_SPL_LOAD_FIT)) {
+ addr = IF_ENABLED_INT(CONFIG_SPL_LOAD_FIT,
+ CONFIG_SPL_LOAD_FIT_ADDRESS);
+ }
+ addr += sector;
if (CONFIG_IS_ENABLED(IMAGE_PRE_LOAD))
addr += image_load_offset;
@@ -38,20 +42,23 @@ static int spl_ram_load_image(struct spl_image_info *spl_image,
struct spl_boot_device *bootdev)
{
struct legacy_img_hdr *header;
+ ulong addr = 0;
int ret;
- header = (struct legacy_img_hdr *)CONFIG_SPL_LOAD_FIT_ADDRESS;
+ if (IS_ENABLED(CONFIG_SPL_LOAD_FIT)) {
+ addr = IF_ENABLED_INT(CONFIG_SPL_LOAD_FIT,
+ CONFIG_SPL_LOAD_FIT_ADDRESS);
+ }
if (CONFIG_IS_ENABLED(IMAGE_PRE_LOAD)) {
- unsigned long addr = (unsigned long)header;
ret = image_pre_load(addr);
if (ret)
return ret;
addr += image_load_offset;
- header = (struct legacy_img_hdr *)addr;
}
+ header = map_sysmem(addr, 0);
#if CONFIG_IS_ENABLED(DFU)
if (bootdev->boot_device == BOOT_DEVICE_DFU)
@@ -84,7 +91,7 @@ static int spl_ram_load_image(struct spl_image_info *spl_image,
u_boot_pos = (ulong)spl_get_load_buffer(-sizeof(*header),
sizeof(*header));
}
- header = (struct legacy_img_hdr *)map_sysmem(u_boot_pos, 0);
+ header = map_sysmem(u_boot_pos, 0);
ret = spl_parse_image_header(spl_image, bootdev, header);
}
diff --git a/common/spl/spl_sdp.c b/common/spl/spl_sdp.c
index cc4fb4f7cca..9143c27bbf1 100644
--- a/common/spl/spl_sdp.c
+++ b/common/spl/spl_sdp.c
@@ -10,14 +10,18 @@
#include <usb.h>
#include <g_dnl.h>
#include <sdp.h>
+#include <linux/printk.h>
static int spl_sdp_load_image(struct spl_image_info *spl_image,
struct spl_boot_device *bootdev)
{
- int ret;
const int controller_index = CONFIG_SPL_SDP_USB_DEV;
+ struct udevice *udc;
+ int ret;
- usb_gadget_initialize(controller_index);
+ ret = udc_device_get_by_index(controller_index, &udc);
+ if (ret)
+ return ret;
board_usb_init(controller_index, USB_INIT_DEVICE);
@@ -25,13 +29,13 @@ static int spl_sdp_load_image(struct spl_image_info *spl_image,
ret = g_dnl_register("usb_dnl_sdp");
if (ret) {
pr_err("SDP dnl register failed: %d\n", ret);
- return ret;
+ goto err_detach;
}
- ret = sdp_init(controller_index);
+ ret = sdp_init(udc);
if (ret) {
pr_err("SDP init failed: %d\n", ret);
- return -ENODEV;
+ goto err_unregister;
}
/*
@@ -39,10 +43,13 @@ static int spl_sdp_load_image(struct spl_image_info *spl_image,
* or it loads a FIT image and returns it to be handled by the SPL
* code.
*/
- ret = spl_sdp_handle(controller_index, spl_image, bootdev);
+ ret = spl_sdp_handle(udc, spl_image, bootdev);
debug("SDP ended\n");
- usb_gadget_release(controller_index);
+err_unregister:
+ g_dnl_unregister();
+err_detach:
+ udc_device_put(udc);
return ret;
}
SPL_LOAD_IMAGE_METHOD("USB SDP", 0, BOOT_DEVICE_BOARD, spl_sdp_load_image);
diff --git a/common/spl/spl_semihosting.c b/common/spl/spl_semihosting.c
index 5b5e842a11b..f7dd289286d 100644
--- a/common/spl/spl_semihosting.c
+++ b/common/spl/spl_semihosting.c
@@ -21,6 +21,23 @@ static int smh_read_full(long fd, void *memp, size_t len)
return 0;
}
+static ulong smh_fit_read(struct spl_load_info *load, ulong file_offset,
+ ulong size, void *buf)
+{
+ long fd;
+ ulong ret;
+
+ fd = smh_open(load->filename, MODE_READ | MODE_BINARY);
+ if (fd < 0) {
+ log_debug("could not open %s: %ld\n", load->filename, fd);
+ return 0;
+ }
+ ret = smh_read(fd, buf, size);
+ smh_close(fd);
+
+ return ret;
+}
+
static int spl_smh_load_image(struct spl_image_info *spl_image,
struct spl_boot_device *bootdev)
{
@@ -49,6 +66,20 @@ static int spl_smh_load_image(struct spl_image_info *spl_image,
goto out;
}
+ if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
+ image_get_magic(header) == FDT_MAGIC) {
+ struct spl_load_info load;
+
+ debug("Found FIT\n");
+ load.read = smh_fit_read;
+ load.bl_len = 1;
+ load.filename = filename;
+ load.priv = NULL;
+ smh_close(fd);
+
+ return spl_load_simple_fit(spl_image, &load, 0, header);
+ }
+
ret = spl_parse_image_header(spl_image, bootdev, header);
if (ret) {
log_debug("failed to parse image header: %d\n", ret);