summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/Kconfig119
-rw-r--r--common/Makefile17
-rw-r--r--common/bloblist.c239
-rw-r--r--common/board_f.c49
-rw-r--r--common/board_r.c3
-rw-r--r--common/console.c7
-rw-r--r--common/cros_ec.c12
-rw-r--r--common/fdt_support.c3
-rw-r--r--common/image-fit.c5
-rw-r--r--common/image-sig.c35
-rw-r--r--common/image.c1
-rw-r--r--common/init/Makefile1
-rw-r--r--common/init/handoff.c47
-rw-r--r--common/lcd.c9
-rw-r--r--common/malloc_simple.c58
-rw-r--r--common/spl/Kconfig95
-rw-r--r--common/spl/spl.c135
-rw-r--r--common/usb.c14
-rw-r--r--common/usb_hub.c16
-rw-r--r--common/usb_kbd.c4
-rw-r--r--common/usb_storage.c34
21 files changed, 785 insertions, 118 deletions
diff --git a/common/Kconfig b/common/Kconfig
index d7300c212f5..57bd16d9623 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -27,6 +27,15 @@ config SPL_BOOTSTAGE
information when SPL finishes and load it when U-Boot proper starts
up.
+config TPL_BOOTSTAGE
+ bool "Boot timing and reported in TPL"
+ depends on BOOTSTAGE
+ help
+ Enable recording of boot time in SPL. To make this visible to U-Boot
+ proper, enable BOOTSTAGE_STASH as well. This will stash the timing
+ information when TPL finishes and load it when U-Boot proper starts
+ up.
+
config BOOTSTAGE_REPORT
bool "Display a detailed boot timing report before booting the OS"
depends on BOOTSTAGE
@@ -290,6 +299,10 @@ config SPL_LOGLEVEL
int
default LOGLEVEL
+config TPL_LOGLEVEL
+ int
+ default LOGLEVEL
+
config SILENT_CONSOLE
bool "Support a silent console"
help
@@ -444,6 +457,16 @@ config LOG
config SPL_LOG
bool "Enable logging support in SPL"
+ depends on LOG
+ help
+ This enables support for logging of status and debug messages. These
+ can be displayed on the console, recorded in a memory buffer, or
+ discarded if not needed. Logging supports various categories and
+ levels of severity.
+
+config TPL_LOG
+ bool "Enable logging support in TPL"
+ depends on LOG
help
This enables support for logging of status and debug messages. These
can be displayed on the console, recorded in a memory buffer, or
@@ -486,6 +509,24 @@ config SPL_LOG_MAX_LEVEL
6 - detail
7 - debug
+config TPL_LOG_MAX_LEVEL
+ int "Maximum log level to record in TPL"
+ depends on TPL_LOG
+ default 3
+ help
+ This selects the maximum log level that will be recorded. Any value
+ higher than this will be ignored. If possible log statements below
+ this level will be discarded at build time. Levels:
+
+ 0 - panic
+ 1 - critical
+ 2 - error
+ 3 - warning
+ 4 - note
+ 5 - info
+ 6 - detail
+ 7 - debug
+
config LOG_CONSOLE
bool "Allow log output to the console"
depends on LOG
@@ -496,9 +537,19 @@ config LOG_CONSOLE
log message is shown - other details like level, category, file and
line number are omitted.
-config LOG_SPL_CONSOLE
+config SPL_LOG_CONSOLE
+ bool "Allow log output to the console in SPL"
+ depends on SPL_LOG
+ default y
+ help
+ Enables a log driver which writes log records to the console.
+ Generally the console is the serial port or LCD display. Only the
+ log message is shown - other details like level, category, file and
+ line number are omitted.
+
+config TPL_LOG_CONSOLE
bool "Allow log output to the console in SPL"
- depends on LOG_SPL
+ depends on TPL_LOG
default y
help
Enables a log driver which writes log records to the console.
@@ -660,6 +711,22 @@ config AVB_VERIFY
* Helpers to access MMC, similar to drivers/fastboot/fb_mmc.c.
* Helpers to alloc/init/free avb ops.
+config SPL_HASH
+ bool # "Support hashing API (SHA1, SHA256, etc.)"
+ help
+ This provides a way to hash data in memory using various supported
+ algorithms (such as SHA1, MD5, CRC32). The API is defined in hash.h
+ and the algorithms it supports are defined in common/hash.c. See
+ also CMD_HASH for command-line access.
+
+config TPL_HASH
+ bool # "Support hashing API (SHA1, SHA256, etc.)"
+ help
+ This provides a way to hash data in memory using various supported
+ algorithms (such as SHA1, MD5, CRC32). The API is defined in hash.h
+ and the algorithms it supports are defined in common/hash.c. See
+ also CMD_HASH for command-line access.
+
endmenu
menu "Update support"
@@ -683,4 +750,52 @@ config UPDATE_TFTP_MSEC_MAX
endmenu
+menu "Blob list"
+
+config BLOBLIST
+ bool "Support for a bloblist"
+ help
+ This enables support for a bloblist in U-Boot, which can be passed
+ from TPL to SPL to U-Boot proper (and potentially to Linux). The
+ blob list supports multiple binary blobs of data, each with a tag,
+ so that different U-Boot components can store data which can survive
+ through to the next stage of the boot.
+
+config SPL_BLOBLIST
+ bool "Support for a bloblist in SPL"
+ depends on BLOBLIST
+ default y if SPL
+ help
+ This enables a bloblist in SPL. If this is the first part of U-Boot
+ to run, then the bloblist is set up in SPL and passed to U-Boot
+ proper. If TPL also has a bloblist, then SPL uses the one from there.
+
+config TPL_BLOBLIST
+ bool "Support for a bloblist in TPL"
+ depends on BLOBLIST
+ default y if TPL
+ help
+ This enables a bloblist in TPL. The bloblist is set up in TPL and
+ passed to SPL and U-Boot proper.
+
+config BLOBLIST_SIZE
+ hex "Size of bloblist"
+ depends on BLOBLIST
+ default 0x400
+ help
+ Sets the size of the bloblist in bytes. This must include all
+ overhead (alignment, bloblist header, record header). The bloblist
+ is set up in the first part of U-Boot to run (TPL, SPL or U-Boot
+ proper), and this sane bloblist is used for subsequent stages.
+
+config BLOBLIST_ADDR
+ hex "Address of bloblist"
+ depends on BLOBLIST
+ default 0xe000 if SANDBOX
+ help
+ Sets the address of the bloblist, set up by the first part of U-Boot
+ which runs. Subsequent U-Boot stages typically use the same address.
+
+endmenu
+
source "common/spl/Kconfig"
diff --git a/common/Makefile b/common/Makefile
index a2388364d9f..65d89dc62d5 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -33,7 +33,7 @@ obj-$(CONFIG_MII) += miiphyutil.o
obj-$(CONFIG_CMD_MII) += miiphyutil.o
obj-$(CONFIG_PHYLIB) += miiphyutil.o
-ifdef CONFIG_CMD_USB
+ifdef CONFIG_USB
obj-y += usb.o usb_hub.o
obj-$(CONFIG_USB_STORAGE) += usb_storage.o
endif
@@ -61,6 +61,7 @@ obj-$(CONFIG_CMDLINE) += cli_readline.o cli_simple.o
endif # !CONFIG_SPL_BUILD
obj-$(CONFIG_$(SPL_TPL_)BOOTSTAGE) += bootstage.o
+obj-$(CONFIG_$(SPL_TPL_)BLOBLIST) += bloblist.o
ifdef CONFIG_SPL_BUILD
ifdef CONFIG_SPL_DFU_SUPPORT
@@ -68,6 +69,7 @@ obj-$(CONFIG_DFU_OVER_USB) += dfu.o
endif
obj-$(CONFIG_SPL_DFU_SUPPORT) += cli_hush.o
obj-$(CONFIG_SPL_HASH_SUPPORT) += hash.o
+obj-$(CONFIG_TPL_HASH_SUPPORT) += hash.o
obj-$(CONFIG_SPL_YMODEM_SUPPORT) += xyzModem.o
obj-$(CONFIG_SPL_LOAD_FIT) += common_fit.o
obj-$(CONFIG_SPL_NET_SUPPORT) += miiphyutil.o
@@ -76,7 +78,8 @@ ifdef CONFIG_SPL_USB_HOST_SUPPORT
obj-$(CONFIG_SPL_USB_SUPPORT) += usb.o usb_hub.o
obj-$(CONFIG_USB_STORAGE) += usb_storage.o
endif
-endif
+endif # CONFIG_SPL_BUILD
+
#others
obj-$(CONFIG_DDR_SPD) += ddr_spd.o
obj-$(CONFIG_SPD_EEPROM) += ddr_spd.o
@@ -90,14 +93,16 @@ obj-$(CONFIG_SPL_SERIAL_SUPPORT) += console.o
endif
else
obj-y += console.o
-endif
+endif # CONFIG_SPL_BUILD
+
obj-$(CONFIG_CROS_EC) += cros_ec.o
obj-y += dlmalloc.o
ifdef CONFIG_SYS_MALLOC_F
-ifneq ($(CONFIG_$(SPL_)SYS_MALLOC_F_LEN),0)
+ifneq ($(CONFIG_$(SPL_TPL_)SYS_MALLOC_F_LEN),0)
obj-y += malloc_simple.o
endif
endif
+
obj-y += image.o
obj-$(CONFIG_ANDROID_BOOT_IMAGE) += image-android.o
obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += image-fdt.o
@@ -118,8 +123,8 @@ obj-y += cli.o
obj-$(CONFIG_FSL_DDR_INTERACTIVE) += cli_simple.o cli_readline.o
obj-$(CONFIG_DFU_OVER_USB) += dfu.o
obj-y += command.o
-obj-$(CONFIG_$(SPL_)LOG) += log.o
-obj-$(CONFIG_$(SPL_)LOG_CONSOLE) += log_console.o
+obj-$(CONFIG_$(SPL_TPL_)LOG) += log.o
+obj-$(CONFIG_$(SPL_TPL_)LOG_CONSOLE) += log_console.o
obj-y += s_record.o
obj-$(CONFIG_CMD_LOADB) += xyzModem.o
obj-$(CONFIG_$(SPL_TPL_)YMODEM_SUPPORT) += xyzModem.o
diff --git a/common/bloblist.c b/common/bloblist.c
new file mode 100644
index 00000000000..b4cf169b05a
--- /dev/null
+++ b/common/bloblist.c
@@ -0,0 +1,239 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2018 Google, Inc
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#include <common.h>
+#include <bloblist.h>
+#include <log.h>
+#include <mapmem.h>
+#include <spl.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+struct bloblist_rec *bloblist_first_blob(struct bloblist_hdr *hdr)
+{
+ if (hdr->alloced <= hdr->hdr_size)
+ return NULL;
+ return (struct bloblist_rec *)((void *)hdr + hdr->hdr_size);
+}
+
+struct bloblist_rec *bloblist_next_blob(struct bloblist_hdr *hdr,
+ struct bloblist_rec *rec)
+{
+ ulong offset;
+
+ offset = (void *)rec - (void *)hdr;
+ offset += rec->hdr_size + ALIGN(rec->size, BLOBLIST_ALIGN);
+ if (offset >= hdr->alloced)
+ return NULL;
+ return (struct bloblist_rec *)((void *)hdr + offset);
+}
+
+#define foreach_rec(_rec, _hdr) \
+ for (_rec = bloblist_first_blob(_hdr); \
+ _rec; \
+ _rec = bloblist_next_blob(_hdr, _rec))
+
+static struct bloblist_rec *bloblist_findrec(uint tag)
+{
+ struct bloblist_hdr *hdr = gd->bloblist;
+ struct bloblist_rec *rec;
+
+ if (!hdr)
+ return NULL;
+
+ foreach_rec(rec, hdr) {
+ if (rec->tag == tag)
+ return rec;
+ }
+
+ return NULL;
+}
+
+static int bloblist_addrec(uint tag, int size, struct bloblist_rec **recp)
+{
+ struct bloblist_hdr *hdr = gd->bloblist;
+ struct bloblist_rec *rec;
+ int new_alloced;
+
+ new_alloced = hdr->alloced + sizeof(*rec) +
+ ALIGN(size, BLOBLIST_ALIGN);
+ if (new_alloced >= hdr->size) {
+ log(LOGC_BLOBLIST, LOGL_ERR,
+ "Failed to allocate %x bytes size=%x, need size>=%x\n",
+ size, hdr->size, new_alloced);
+ return log_msg_ret("bloblist add", -ENOSPC);
+ }
+ rec = (void *)hdr + hdr->alloced;
+ hdr->alloced = new_alloced;
+
+ rec->tag = tag;
+ rec->hdr_size = sizeof(*rec);
+ rec->size = size;
+ rec->spare = 0;
+ *recp = rec;
+
+ return 0;
+}
+
+static int bloblist_ensurerec(uint tag, struct bloblist_rec **recp, int size)
+{
+ struct bloblist_rec *rec;
+
+ rec = bloblist_findrec(tag);
+ if (rec) {
+ if (size && size != rec->size)
+ return -ESPIPE;
+ } else {
+ int ret;
+
+ ret = bloblist_addrec(tag, size, &rec);
+ if (ret)
+ return ret;
+ }
+ *recp = rec;
+
+ return 0;
+}
+
+void *bloblist_find(uint tag, int size)
+{
+ struct bloblist_rec *rec;
+
+ rec = bloblist_findrec(tag);
+ if (!rec)
+ return NULL;
+ if (size && size != rec->size)
+ return NULL;
+
+ return (void *)rec + rec->hdr_size;
+}
+
+void *bloblist_add(uint tag, int size)
+{
+ struct bloblist_rec *rec;
+
+ if (bloblist_addrec(tag, size, &rec))
+ return NULL;
+
+ return rec + 1;
+}
+
+int bloblist_ensure_size(uint tag, int size, void **blobp)
+{
+ struct bloblist_rec *rec;
+ int ret;
+
+ ret = bloblist_ensurerec(tag, &rec, size);
+ if (ret)
+ return ret;
+ *blobp = (void *)rec + rec->hdr_size;
+
+ return 0;
+}
+
+void *bloblist_ensure(uint tag, int size)
+{
+ struct bloblist_rec *rec;
+
+ if (bloblist_ensurerec(tag, &rec, size))
+ return NULL;
+
+ return (void *)rec + rec->hdr_size;
+}
+
+static u32 bloblist_calc_chksum(struct bloblist_hdr *hdr)
+{
+ struct bloblist_rec *rec;
+ u32 chksum;
+
+ chksum = crc32(0, (unsigned char *)hdr,
+ offsetof(struct bloblist_hdr, chksum));
+ foreach_rec(rec, hdr) {
+ chksum = crc32(chksum, (void *)rec, rec->hdr_size);
+ chksum = crc32(chksum, (void *)rec + rec->hdr_size, rec->size);
+ }
+
+ return chksum;
+}
+
+int bloblist_new(ulong addr, uint size, uint flags)
+{
+ struct bloblist_hdr *hdr;
+
+ if (size < sizeof(*hdr))
+ return log_ret(-ENOSPC);
+ if (addr & (BLOBLIST_ALIGN - 1))
+ return log_ret(-EFAULT);
+ hdr = map_sysmem(addr, size);
+ memset(hdr, '\0', sizeof(*hdr));
+ hdr->version = BLOBLIST_VERSION;
+ hdr->hdr_size = sizeof(*hdr);
+ hdr->flags = flags;
+ hdr->magic = BLOBLIST_MAGIC;
+ hdr->size = size;
+ hdr->alloced = hdr->hdr_size;
+ hdr->chksum = 0;
+ gd->bloblist = hdr;
+
+ return 0;
+}
+
+int bloblist_check(ulong addr, uint size)
+{
+ struct bloblist_hdr *hdr;
+ u32 chksum;
+
+ hdr = map_sysmem(addr, sizeof(*hdr));
+ if (hdr->magic != BLOBLIST_MAGIC)
+ return log_msg_ret("Bad magic", -ENOENT);
+ if (hdr->version != BLOBLIST_VERSION)
+ return log_msg_ret("Bad version", -EPROTONOSUPPORT);
+ if (size && hdr->size != size)
+ return log_msg_ret("Bad size", -EFBIG);
+ chksum = bloblist_calc_chksum(hdr);
+ if (hdr->chksum != chksum) {
+ log(LOGC_BLOBLIST, LOGL_ERR, "Checksum %x != %x\n", hdr->chksum,
+ chksum);
+ return log_msg_ret("Bad checksum", -EIO);
+ }
+ gd->bloblist = hdr;
+
+ return 0;
+}
+
+int bloblist_finish(void)
+{
+ struct bloblist_hdr *hdr = gd->bloblist;
+
+ hdr->chksum = bloblist_calc_chksum(hdr);
+
+ return 0;
+}
+
+int bloblist_init(void)
+{
+ bool expected;
+ int ret = -ENOENT;
+
+ /**
+ * Wed expect to find an existing bloblist in the first phase of U-Boot
+ * that runs
+ */
+ expected = !u_boot_first_phase();
+ if (expected)
+ ret = bloblist_check(CONFIG_BLOBLIST_ADDR,
+ CONFIG_BLOBLIST_SIZE);
+ if (ret) {
+ log(LOGC_BLOBLIST, expected ? LOGL_WARNING : LOGL_DEBUG,
+ "Existing bloblist not found: creating new bloblist\n");
+ ret = bloblist_new(CONFIG_BLOBLIST_ADDR, CONFIG_BLOBLIST_SIZE,
+ 0);
+ } else {
+ log(LOGC_BLOBLIST, LOGL_DEBUG, "Found existing bloblist\n");
+ }
+
+ return ret;
+}
diff --git a/common/board_f.c b/common/board_f.c
index a3e80ca9512..149a7229e8f 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -10,6 +10,7 @@
*/
#include <common.h>
+#include <bloblist.h>
#include <console.h>
#include <cpu.h>
#include <dm.h>
@@ -23,6 +24,9 @@
#include <os.h>
#include <post.h>
#include <relocate.h>
+#ifdef CONFIG_SPL
+#include <spl.h>
+#endif
#include <status_led.h>
#include <sysreset.h>
#include <timer.h>
@@ -274,6 +278,17 @@ static int setup_mon_len(void)
return 0;
}
+static int setup_spl_handoff(void)
+{
+#if CONFIG_IS_ENABLED(HANDOFF)
+ gd->spl_handoff = bloblist_find(BLOBLISTT_SPL_HANDOFF,
+ sizeof(struct spl_handoff));
+ debug("Found SPL hand-off info %p\n", gd->spl_handoff);
+#endif
+
+ return 0;
+}
+
__weak int arch_cpu_init(void)
{
return 0;
@@ -549,6 +564,16 @@ static int reserve_stacks(void)
return arch_reserve_stacks();
}
+static int reserve_bloblist(void)
+{
+#ifdef CONFIG_BLOBLIST
+ gd->start_addr_sp -= CONFIG_BLOBLIST_SIZE;
+ gd->new_bloblist = map_sysmem(gd->start_addr_sp, CONFIG_BLOBLIST_SIZE);
+#endif
+
+ return 0;
+}
+
static int display_new_sp(void)
{
debug("New Stack Pointer is: %08lx\n", gd->start_addr_sp);
@@ -655,6 +680,24 @@ static int reloc_bootstage(void)
return 0;
}
+static int reloc_bloblist(void)
+{
+#ifdef CONFIG_BLOBLIST
+ if (gd->flags & GD_FLG_SKIP_RELOC)
+ return 0;
+ if (gd->new_bloblist) {
+ int size = CONFIG_BLOBLIST_SIZE;
+
+ debug("Copying bloblist from %p to %p, size %x\n",
+ gd->bloblist, gd->new_bloblist, size);
+ memcpy(gd->new_bloblist, gd->bloblist, size);
+ gd->bloblist = gd->new_bloblist;
+ }
+#endif
+
+ return 0;
+}
+
static int setup_reloc(void)
{
if (gd->flags & GD_FLG_SKIP_RELOC) {
@@ -802,6 +845,10 @@ static const init_fnc_t init_sequence_f[] = {
initf_malloc,
log_init,
initf_bootstage, /* uses its own timer, so does not need DM */
+#ifdef CONFIG_BLOBLIST
+ bloblist_init,
+#endif
+ setup_spl_handoff,
initf_console_record,
#if defined(CONFIG_HAVE_FSP)
arch_fsp_init,
@@ -899,6 +946,7 @@ static const init_fnc_t init_sequence_f[] = {
reserve_global_data,
reserve_fdt,
reserve_bootstage,
+ reserve_bloblist,
reserve_arch,
reserve_stacks,
dram_init_banksize,
@@ -918,6 +966,7 @@ static const init_fnc_t init_sequence_f[] = {
INIT_FUNC_WATCHDOG_RESET
reloc_fdt,
reloc_bootstage,
+ reloc_bloblist,
setup_reloc,
#if defined(CONFIG_X86) || defined(CONFIG_ARC)
copy_uboot_to_ram,
diff --git a/common/board_r.c b/common/board_r.c
index 2f982b16460..5f3d27aa9f3 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -438,7 +438,8 @@ static int initr_env(void)
else
set_default_env(NULL, 0);
#ifdef CONFIG_OF_CONTROL
- env_set_addr("fdtcontroladdr", gd->fdt_blob);
+ env_set_hex("fdtcontroladdr",
+ (unsigned long)map_to_sysmem(gd->fdt_blob));
#endif
/* Initialize from environment */
diff --git a/common/console.c b/common/console.c
index 9a94f321922..0b0dd76256c 100644
--- a/common/console.c
+++ b/common/console.c
@@ -535,6 +535,13 @@ void putc(const char c)
void puts(const char *s)
{
+#ifdef CONFIG_SANDBOX
+ /* sandbox can send characters to stdout before it has a console */
+ if (!gd || !(gd->flags & GD_FLG_SERIAL_READY)) {
+ os_puts(s);
+ return;
+ }
+#endif
#ifdef CONFIG_DEBUG_UART
if (!gd || !(gd->flags & GD_FLG_SERIAL_READY)) {
while (*s) {
diff --git a/common/cros_ec.c b/common/cros_ec.c
index 4ca15e19d5f..e66471ebd1b 100644
--- a/common/cros_ec.c
+++ b/common/cros_ec.c
@@ -25,15 +25,3 @@ struct udevice *board_get_cros_ec_dev(void)
}
return dev;
}
-
-int cros_ec_get_error(void)
-{
- struct udevice *dev;
- int ret;
-
- ret = uclass_get_device(UCLASS_CROS_EC, 0, &dev);
- if (ret && ret != -ENODEV)
- return ret;
-
- return 0;
-}
diff --git a/common/fdt_support.c b/common/fdt_support.c
index e6daa67990d..3440e42a257 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -7,6 +7,7 @@
*/
#include <common.h>
+#include <mapmem.h>
#include <stdio_dev.h>
#include <linux/ctype.h>
#include <linux/types.h>
@@ -633,7 +634,7 @@ int fdt_shrink_to_minimum(void *blob, uint extrasize)
fdt_set_totalsize(blob, actualsize);
/* Add the new reservation */
- ret = fdt_add_mem_rsv(blob, (uintptr_t)blob, actualsize);
+ ret = fdt_add_mem_rsv(blob, map_to_sysmem(blob), actualsize);
if (ret < 0)
return ret;
diff --git a/common/image-fit.c b/common/image-fit.c
index 8d39a243f8d..ac901e131ca 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -165,6 +165,7 @@ static void fit_image_print_data(const void *fit, int noffset, const char *p,
uint8_t *value;
int value_len;
char *algo;
+ const char *padding;
int required;
int ret, i;
@@ -184,6 +185,10 @@ static void fit_image_print_data(const void *fit, int noffset, const char *p,
printf(" (required)");
printf("\n");
+ padding = fdt_getprop(fit, noffset, "padding", NULL);
+ if (padding)
+ printf("%s %s padding: %s\n", p, type, padding);
+
ret = fit_image_hash_get_value(fit, noffset, &value,
&value_len);
printf("%s %s value: ", p, type);
diff --git a/common/image-sig.c b/common/image-sig.c
index 5d860e12663..4f6b4ec412c 100644
--- a/common/image-sig.c
+++ b/common/image-sig.c
@@ -71,6 +71,19 @@ struct crypto_algo crypto_algos[] = {
};
+struct padding_algo padding_algos[] = {
+ {
+ .name = "pkcs-1.5",
+ .verify = padding_pkcs_15_verify,
+ },
+#ifdef CONFIG_FIT_ENABLE_RSASSA_PSS_SUPPORT
+ {
+ .name = "pss",
+ .verify = padding_pss_verify,
+ }
+#endif /* CONFIG_FIT_ENABLE_RSASSA_PSS_SUPPORT */
+};
+
struct checksum_algo *image_get_checksum_algo(const char *full_name)
{
int i;
@@ -106,6 +119,21 @@ struct crypto_algo *image_get_crypto_algo(const char *full_name)
return NULL;
}
+struct padding_algo *image_get_padding_algo(const char *name)
+{
+ int i;
+
+ if (!name)
+ return NULL;
+
+ for (i = 0; i < ARRAY_SIZE(padding_algos); i++) {
+ if (!strcmp(padding_algos[i].name, name))
+ return &padding_algos[i];
+ }
+
+ return NULL;
+}
+
/**
* fit_region_make_list() - Make a list of image regions
*
@@ -155,6 +183,7 @@ static int fit_image_setup_verify(struct image_sign_info *info,
char **err_msgp)
{
char *algo_name;
+ const char *padding_name;
if (fdt_totalsize(fit) > CONFIG_FIT_SIGNATURE_MAX_SIZE) {
*err_msgp = "Total size too large";
@@ -165,6 +194,11 @@ static int fit_image_setup_verify(struct image_sign_info *info,
*err_msgp = "Can't get hash algo property";
return -1;
}
+
+ padding_name = fdt_getprop(fit, noffset, "padding", NULL);
+ if (!padding_name)
+ padding_name = RSA_DEFAULT_PADDING_NAME;
+
memset(info, '\0', sizeof(*info));
info->keyname = fdt_getprop(fit, noffset, "key-name-hint", NULL);
info->fit = (void *)fit;
@@ -172,6 +206,7 @@ static int fit_image_setup_verify(struct image_sign_info *info,
info->name = algo_name;
info->checksum = image_get_checksum_algo(algo_name);
info->crypto = image_get_crypto_algo(algo_name);
+ info->padding = image_get_padding_algo(padding_name);
info->fdt_blob = gd_fdt_blob();
info->required_keynode = required_keynode;
printf("%s:%s", algo_name, info->keyname);
diff --git a/common/image.c b/common/image.c
index 1c3a7720cbc..0659133fccf 100644
--- a/common/image.c
+++ b/common/image.c
@@ -166,6 +166,7 @@ static const table_entry_t uimage_type[] = {
{ IH_TYPE_FIRMWARE_IVT, "firmware_ivt", "Firmware with HABv4 IVT" },
{ IH_TYPE_PMMC, "pmmc", "TI Power Management Micro-Controller Firmware",},
{ IH_TYPE_STM32IMAGE, "stm32image", "STMicroelectronics STM32 Image" },
+ { IH_TYPE_MTKIMAGE, "mtk_image", "MediaTek BootROM loadable Image" },
{ -1, "", "", },
};
diff --git a/common/init/Makefile b/common/init/Makefile
index 4902635f535..853b56d1e57 100644
--- a/common/init/Makefile
+++ b/common/init/Makefile
@@ -5,3 +5,4 @@
#
obj-y += board_init.o
+obj-$(CONFIG_$(SPL_TPL_)HANDOFF) += handoff.o
diff --git a/common/init/handoff.c b/common/init/handoff.c
new file mode 100644
index 00000000000..e00b43e6a7b
--- /dev/null
+++ b/common/init/handoff.c
@@ -0,0 +1,47 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Passing basic information from SPL to U-Boot proper
+ *
+ * Copyright 2018 Google, Inc
+ */
+
+#include <common.h>
+#include <handoff.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+void handoff_save_dram(struct spl_handoff *ho)
+{
+ ho->ram_size = gd->ram_size;
+#ifdef CONFIG_NR_DRAM_BANKS
+ {
+ struct bd_info *bd = gd->bd;
+ int i;
+
+ for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
+ ho->ram_bank[i].start = bd->bi_dram[i].start;
+ ho->ram_bank[i].size = bd->bi_dram[i].size;
+ }
+ }
+#endif
+}
+
+void handoff_load_dram_size(struct spl_handoff *ho)
+{
+ gd->ram_size = ho->ram_size;
+}
+
+void handoff_load_dram_banks(struct spl_handoff *ho)
+{
+#ifdef CONFIG_NR_DRAM_BANKS
+ {
+ struct bd_info *bd = gd->bd;
+ int i;
+
+ for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
+ bd->bi_dram[i].start = ho->ram_bank[i].start;
+ bd->bi_dram[i].size = ho->ram_bank[i].size;
+ }
+ }
+#endif
+}
diff --git a/common/lcd.c b/common/lcd.c
index 2e2bef3848f..cd630405d44 100644
--- a/common/lcd.c
+++ b/common/lcd.c
@@ -242,14 +242,6 @@ void lcd_clear(void)
lcd_sync();
}
-static int do_lcd_clear(cmd_tbl_t *cmdtp, int flag, int argc,
- char *const argv[])
-{
- lcd_clear();
- return 0;
-}
-U_BOOT_CMD(cls, 1, 1, do_lcd_clear, "clear screen", "");
-
static int lcd_init(void *lcdbase)
{
debug("[LCD] Initializing LCD frambuffer at %p\n", lcdbase);
@@ -389,7 +381,6 @@ static inline void lcd_logo_plot(int x, int y) {}
#if defined(CONFIG_CMD_BMP) || defined(CONFIG_SPLASH_SCREEN)
#ifdef CONFIG_SPLASH_SCREEN_ALIGN
-#define BMP_ALIGN_CENTER 0x7FFF
static void splash_align_axis(int *axis, unsigned long panel_size,
unsigned long picture_size)
diff --git a/common/malloc_simple.c b/common/malloc_simple.c
index 871b5444bd7..eabbb70128b 100644
--- a/common/malloc_simple.c
+++ b/common/malloc_simple.c
@@ -5,6 +5,8 @@
* Copyright (c) 2014 Google, Inc
*/
+#define LOG_CATEGORY LOGC_ALLOC
+
#include <common.h>
#include <malloc.h>
#include <mapmem.h>
@@ -12,40 +14,47 @@
DECLARE_GLOBAL_DATA_PTR;
-void *malloc_simple(size_t bytes)
+static void *alloc_simple(size_t bytes, int align)
{
- ulong new_ptr;
+ ulong addr, new_ptr;
void *ptr;
- new_ptr = gd->malloc_ptr + bytes;
- debug("%s: size=%zx, ptr=%lx, limit=%lx: ", __func__, bytes, new_ptr,
- gd->malloc_limit);
+ addr = ALIGN(gd->malloc_base + gd->malloc_ptr, align);
+ new_ptr = addr + bytes - gd->malloc_base;
+ log_debug("size=%zx, ptr=%lx, limit=%lx: ", bytes, new_ptr,
+ gd->malloc_limit);
if (new_ptr > gd->malloc_limit) {
- debug("space exhausted\n");
+ log_err("alloc space exhausted\n");
return NULL;
}
- ptr = map_sysmem(gd->malloc_base + gd->malloc_ptr, bytes);
+
+ ptr = map_sysmem(addr, bytes);
gd->malloc_ptr = ALIGN(new_ptr, sizeof(new_ptr));
- debug("%lx\n", (ulong)ptr);
return ptr;
}
-void *memalign_simple(size_t align, size_t bytes)
+void *malloc_simple(size_t bytes)
{
- ulong addr, new_ptr;
void *ptr;
- addr = ALIGN(gd->malloc_base + gd->malloc_ptr, align);
- new_ptr = addr + bytes - gd->malloc_base;
- if (new_ptr > gd->malloc_limit) {
- debug("space exhausted\n");
- return NULL;
- }
+ ptr = alloc_simple(bytes, 1);
+ if (!ptr)
+ return ptr;
- ptr = map_sysmem(addr, bytes);
- gd->malloc_ptr = ALIGN(new_ptr, sizeof(new_ptr));
- debug("%lx\n", (ulong)ptr);
+ log_debug("%lx\n", (ulong)ptr);
+
+ return ptr;
+}
+
+void *memalign_simple(size_t align, size_t bytes)
+{
+ void *ptr;
+
+ ptr = alloc_simple(bytes, align);
+ if (!ptr)
+ return ptr;
+ log_debug("aligned to %lx\n", (ulong)ptr);
return ptr;
}
@@ -57,9 +66,16 @@ void *calloc(size_t nmemb, size_t elem_size)
void *ptr;
ptr = malloc(size);
- if (ptr)
- memset(ptr, '\0', size);
+ if (!ptr)
+ return ptr;
+ memset(ptr, '\0', size);
return ptr;
}
#endif
+
+void malloc_simple_info(void)
+{
+ log_info("malloc_simple: %lx bytes used, %lx remain\n", gd->malloc_ptr,
+ CONFIG_VAL(SYS_MALLOC_F_LEN) - gd->malloc_ptr);
+}
diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index d0564621d4d..0ddbffc7d1c 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -25,8 +25,28 @@ config SPL_FRAMEWORK
supports MMC, NAND and YMODEM and other methods loading of U-Boot
and the Linux Kernel. If unsure, say Y.
+config HANDOFF
+ bool "Pass hand-off information from SPL to U-Boot proper"
+ depends on BLOBLIST
+ help
+ It is useful to be able to pass information from SPL to U-Boot
+ proper to preserve state that is known in SPL and is needed in U-Boot.
+ Enable this to locate the handoff information in U-Boot proper, early
+ in boot. It is available in gd->handoff. The state state is set up
+ in SPL (or TPL if that is being used).
+
if SPL
+config SPL_HANDOFF
+ bool "Pass hand-off information from SPL to U-Boot proper"
+ depends on HANDOFF
+ default y
+ help
+ This option enables SPL to write handoff information. This can be
+ used to pass information like the size of SDRAM from SPL to U-Boot
+ proper. Also SPL can receive information from TPL in the same place
+ if that is enabled.
+
config SPL_LDSCRIPT
string "Linker script for the SPL stage"
default "arch/$(ARCH)/cpu/u-boot-spl.lds"
@@ -135,12 +155,21 @@ config SPL_SEPARATE_BSS
location is used. Normally we put the device tree at the end of BSS
but with this option enabled, it goes at _image_binary_end.
-config SPL_DISABLE_BANNER_PRINT
- bool "Disable output of the SPL banner 'U-Boot SPL ...'"
+config SPL_BANNER_PRINT
+ bool "Enable output of the SPL banner 'U-Boot SPL ...'"
+ default y
+ help
+ If this option is enabled, SPL will print the banner with version
+ info. Disabling this option could be useful to reduce TPL boot time
+ (e.g. approx. 6 ms faster, when output on i.MX6 with 115200 baud).
+
+config TPL_BANNER_PRINT
+ bool "Enable output of the TPL banner 'U-Boot TPL ...'"
+ default y
help
If this option is enabled, SPL will not print the banner with version
- info. Selecting this option could be useful to reduce SPL boot time
- (e.g. approx. 6 ms slower, when output on i.MX6 with 115200 baud).
+ info. Disabling this option could be useful to reduce SPL boot time
+ (e.g. approx. 6 ms faster, when output on i.MX6 with 115200 baud).
config SPL_DISPLAY_PRINT
bool "Display a board-specific message in SPL"
@@ -295,6 +324,16 @@ config SPL_HASH_SUPPORT
this option to build system-specific drivers for hash acceleration
as part of an SPL build.
+config TPL_HASH_SUPPORT
+ bool "Support hashing drivers in TPL"
+ select SHA1
+ select SHA256
+ help
+ Enable hashing drivers in SPL. These drivers can be used to
+ accelerate secure boot processing in secure applications. Enable
+ this option to build system-specific drivers for hash acceleration
+ as part of an SPL build.
+
config SPL_DMA_SUPPORT
bool "Support DMA drivers"
help
@@ -376,7 +415,7 @@ config SPL_FPGA_SUPPORT
within SPL.
config SPL_GPIO_SUPPORT
- bool "Support GPIO"
+ bool "Support GPIO in SPL"
help
Enable support for GPIOs (General-purpose Input/Output) in SPL.
GPIOs allow U-Boot to read the state of an input line (high or
@@ -848,6 +887,16 @@ config TPL
if TPL
+config TPL_HANDOFF
+ bool "Pass hand-off information from TPL to SPL and U-Boot proper"
+ depends on HANDOFF
+ default y
+ help
+ This option enables TPL to write handoff information. This can be
+ used to pass information like the size of SDRAM from TPL to U-Boot
+ proper. The information is also available to SPL if it is useful
+ there.
+
config TPL_BOARD_INIT
bool "Call board-specific initialization in TPL"
help
@@ -928,6 +977,17 @@ config TPL_ENV_SUPPORT
help
Enable environment support in TPL. See SPL_ENV_SUPPORT for details.
+config TPL_GPIO_SUPPORT
+ bool "Support GPIO in TPL"
+ help
+ Enable support for GPIOs (General-purpose Input/Output) in TPL.
+ GPIOs allow U-Boot to read the state of an input line (high or
+ low) and set the state of an output line. This can be used to
+ drive LEDs, control power to various system parts and read user
+ input. GPIOs can be useful in TPL to enable a 'sign-of-life' LED,
+ for example. Enable this option to build the drivers in
+ drivers/gpio as part of an TPL build.
+
config TPL_I2C_SUPPORT
bool "Support I2C"
help
@@ -963,6 +1023,22 @@ config TPL_NAND_SUPPORT
help
Enable support for NAND in TPL. See SPL_NAND_SUPPORT for details.
+config TPL_PCI_SUPPORT
+ bool "Support PCI drivers"
+ help
+ Enable support for PCI in TPL. For platforms that need PCI to boot,
+ or must perform some init using PCI in SPL, this provides the
+ necessary driver support. This enables the drivers in drivers/pci
+ as part of a TPL build.
+
+config TPL_PCH_SUPPORT
+ bool "Support PCH drivers"
+ help
+ Enable support for PCH (Platform Controller Hub) devices in TPL.
+ These are used to set up GPIOs and the SPI peripheral early in
+ boot. This enables the drivers in drivers/pch as part of a TPL
+ build.
+
config TPL_RAM_SUPPORT
bool "Support booting from RAM"
help
@@ -977,6 +1053,15 @@ config TPL_RAM_DEVICE
be already in memory when TPL takes over, e.g. loaded by the boot
ROM.
+config TPL_RTC_SUPPORT
+ bool "Support RTC drivers"
+ help
+ Enable RTC (Real-time Clock) support in TPL. This includes support
+ for reading and setting the time. Some RTC devices also have some
+ non-volatile (battery-backed) memory which is accessible if
+ needed. This enables the drivers in drivers/rtc as part of an TPL
+ build.
+
config TPL_SERIAL_SUPPORT
bool "Support serial"
select TPL_PRINTF
diff --git a/common/spl/spl.c b/common/spl/spl.c
index 12f9359c0ac..35120b6efd1 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -7,8 +7,10 @@
*/
#include <common.h>
+#include <bloblist.h>
#include <binman_sym.h>
#include <dm.h>
+#include <handoff.h>
#include <spl.h>
#include <asm/u-boot.h>
#include <nand.h>
@@ -44,6 +46,14 @@ static bd_t bdata __attribute__ ((section(".data")));
*/
__weak void show_boot_progress(int val) {}
+#if defined(CONFIG_SPL_OS_BOOT) || CONFIG_IS_ENABLED(HANDOFF)
+/* weak, default platform-specific function to initialize dram banks */
+__weak int dram_init_banksize(void)
+{
+ return 0;
+}
+#endif
+
/*
* Default function to determine if u-boot or the OS should
* be started. This implementation always returns 1.
@@ -57,19 +67,12 @@ __weak void show_boot_progress(int val) {}
#ifdef CONFIG_SPL_OS_BOOT
__weak int spl_start_uboot(void)
{
- puts("SPL: Please implement spl_start_uboot() for your board\n");
- puts("SPL: Direct Linux boot not active!\n");
+ puts(SPL_TPL_PROMPT
+ "Please implement spl_start_uboot() for your board\n");
+ puts(SPL_TPL_PROMPT "Direct Linux boot not active!\n");
return 1;
}
-/* weak default platform specific function to initialize
- * dram banks
- */
-__weak int dram_init_banksize(void)
-{
- return 0;
-}
-
/*
* Weak default function for arch specific zImage check. Return zero
* and fill start and end address if image is recognized.
@@ -100,13 +103,13 @@ void spl_fixup_fdt(void)
/* fixup the memory dt node */
err = fdt_shrink_to_minimum(fdt_blob, 0);
if (err == 0) {
- printf("spl: fdt_shrink_to_minimum err - %d\n", err);
+ printf(SPL_TPL_PROMPT "fdt_shrink_to_minimum err - %d\n", err);
return;
}
err = arch_fixup_fdt(fdt_blob);
if (err) {
- printf("spl: arch_fixup_fdt err - %d\n", err);
+ printf(SPL_TPL_PROMPT "arch_fixup_fdt err - %d\n", err);
return;
}
#endif
@@ -185,7 +188,7 @@ static int spl_load_fit_image(struct spl_image_info *spl_image,
spl_image->os = IH_OS_U_BOOT;
spl_image->name = "U-Boot";
- debug("spl: payload image: %32s load addr: 0x%lx size: %d\n",
+ debug(SPL_TPL_PROMPT "payload image: %32s load addr: 0x%lx size: %d\n",
spl_image->name, spl_image->load_addr, spl_image->size);
#ifdef CONFIG_SPL_FIT_SIGNATURE
@@ -255,7 +258,8 @@ int spl_parse_image_header(struct spl_image_info *spl_image,
}
spl_image->os = image_get_os(header);
spl_image->name = image_get_name(header);
- debug("spl: payload image: %32s load addr: 0x%lx size: %d\n",
+ debug(SPL_TPL_PROMPT
+ "payload image: %32s load addr: 0x%lx size: %d\n",
spl_image->name, spl_image->load_addr, spl_image->size);
#else
/* LEGACY image not supported */
@@ -284,7 +288,8 @@ int spl_parse_image_header(struct spl_image_info *spl_image,
spl_image->load_addr = CONFIG_SYS_LOAD_ADDR;
spl_image->entry_point = CONFIG_SYS_LOAD_ADDR;
spl_image->size = end - start;
- debug("spl: payload zImage, load addr: 0x%lx size: %d\n",
+ debug(SPL_TPL_PROMPT
+ "payload zImage, load addr: 0x%lx size: %d\n",
spl_image->load_addr, spl_image->size);
return 0;
}
@@ -316,6 +321,44 @@ __weak void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
image_entry();
}
+#if CONFIG_IS_ENABLED(HANDOFF)
+/**
+ * Set up the SPL hand-off information
+ *
+ * This is initially empty (zero) but can be written by
+ */
+static int setup_spl_handoff(void)
+{
+ struct spl_handoff *ho;
+
+ ho = bloblist_ensure(BLOBLISTT_SPL_HANDOFF, sizeof(struct spl_handoff));
+ if (!ho)
+ return -ENOENT;
+
+ return 0;
+}
+
+static int write_spl_handoff(void)
+{
+ struct spl_handoff *ho;
+
+ ho = bloblist_find(BLOBLISTT_SPL_HANDOFF, sizeof(struct spl_handoff));
+ if (!ho)
+ return -ENOENT;
+ handoff_save_dram(ho);
+#ifdef CONFIG_SANDBOX
+ ho->arch.magic = TEST_HANDOFF_MAGIC;
+#endif
+ debug(SPL_TPL_PROMPT "Wrote SPL handoff\n");
+
+ return 0;
+}
+#else
+static inline int setup_spl_handoff(void) { return 0; }
+static inline int write_spl_handoff(void) { return 0; }
+
+#endif /* HANDOFF */
+
static int spl_common_init(bool setup_malloc)
{
int ret;
@@ -336,6 +379,30 @@ static int spl_common_init(bool setup_malloc)
return ret;
}
bootstage_mark_name(BOOTSTAGE_ID_START_SPL, "spl");
+#if CONFIG_IS_ENABLED(LOG)
+ ret = log_init();
+ if (ret) {
+ debug("%s: Failed to set up logging\n", __func__);
+ return ret;
+ }
+#endif
+ if (CONFIG_IS_ENABLED(BLOBLIST)) {
+ ret = bloblist_init();
+ if (ret) {
+ debug("%s: Failed to set up bloblist: ret=%d\n",
+ __func__, ret);
+ return ret;
+ }
+ }
+ if (CONFIG_IS_ENABLED(HANDOFF)) {
+ int ret;
+
+ ret = setup_spl_handoff();
+ if (ret) {
+ puts(SPL_TPL_PROMPT "Cannot set up SPL handoff\n");
+ hang();
+ }
+ }
if (CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)) {
ret = fdtdec_setup();
if (ret) {
@@ -359,6 +426,10 @@ static int spl_common_init(bool setup_malloc)
void spl_set_bd(void)
{
+ /*
+ * NOTE: On some platforms (e.g. x86) bdata may be in flash and not
+ * writeable.
+ */
if (!gd->bd)
gd->bd = &bdata;
}
@@ -453,7 +524,7 @@ static int boot_from_devices(struct spl_image_info *spl_image,
if (loader)
printf("Trying to boot from %s\n", loader->name);
else
- puts("SPL: Unsupported Boot Device!\n");
+ puts(SPL_TPL_PROMPT "Unsupported Boot Device!\n");
#endif
if (loader && !spl_load_image(spl_image, loader)) {
spl_image->boot_device = spl_boot_list[i];
@@ -474,15 +545,12 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
BOOT_DEVICE_NONE,
};
struct spl_image_info spl_image;
+ int ret;
- debug(">>spl:board_init_r()\n");
+ debug(">>" SPL_TPL_PROMPT "board_init_r()\n");
spl_set_bd();
-#ifdef CONFIG_SPL_OS_BOOT
- dram_init_banksize();
-#endif
-
#if defined(CONFIG_SYS_SPL_MALLOC_START)
mem_malloc_init(CONFIG_SYS_SPL_MALLOC_START,
CONFIG_SYS_SPL_MALLOC_SIZE);
@@ -504,6 +572,9 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
spl_board_init();
#endif
+ if (IS_ENABLED(CONFIG_SPL_OS_BOOT) || CONFIG_IS_ENABLED(HANDOFF))
+ dram_init_banksize();
+
bootcount_inc();
memset(&spl_image, '\0', sizeof(spl_image));
@@ -515,11 +586,23 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
if (boot_from_devices(&spl_image, spl_boot_list,
ARRAY_SIZE(spl_boot_list))) {
- puts("SPL: failed to boot from all boot devices\n");
+ puts(SPL_TPL_PROMPT "failed to boot from all boot devices\n");
hang();
}
spl_perform_fixups(&spl_image);
+ if (CONFIG_IS_ENABLED(HANDOFF)) {
+ ret = write_spl_handoff();
+ if (ret)
+ printf(SPL_TPL_PROMPT
+ "SPL hand-off write failed (err=%d)\n", ret);
+ }
+ if (CONFIG_IS_ENABLED(BLOBLIST)) {
+ ret = bloblist_finish();
+ if (ret)
+ printf("Warning: Failed to finish bloblist (ret=%d)\n",
+ ret);
+ }
#ifdef CONFIG_CPU_V7M
spl_image.entry_point |= 0x1;
@@ -556,8 +639,6 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
gd->malloc_ptr / 1024);
#endif
#ifdef CONFIG_BOOTSTAGE_STASH
- int ret;
-
bootstage_mark_name(BOOTSTAGE_ID_END_SPL, "end_spl");
ret = bootstage_stash((void *)CONFIG_BOOTSTAGE_STASH_ADDR,
CONFIG_BOOTSTAGE_STASH_SIZE);
@@ -583,9 +664,9 @@ void preloader_console_init(void)
gd->have_console = 1;
-#ifndef CONFIG_SPL_DISABLE_BANNER_PRINT
- puts("\nU-Boot SPL " PLAIN_VERSION " (" U_BOOT_DATE " - " \
- U_BOOT_TIME " " U_BOOT_TZ ")\n");
+#if CONFIG_IS_ENABLED(BANNER_PRINT)
+ puts("\nU-Boot " SPL_TPL_NAME " " PLAIN_VERSION " (" U_BOOT_DATE " - "
+ U_BOOT_TIME " " U_BOOT_TZ ")\n");
#endif
#ifdef CONFIG_SPL_DISPLAY_PRINT
spl_display_print();
diff --git a/common/usb.c b/common/usb.c
index 78178c54c89..b70f614d244 100644
--- a/common/usb.c
+++ b/common/usb.c
@@ -42,7 +42,7 @@
static int asynch_allowed;
char usb_started; /* flag for the started/stopped USB status */
-#ifndef CONFIG_DM_USB
+#if !CONFIG_IS_ENABLED(DM_USB)
static struct usb_device usb_dev[USB_MAX_DEVICE];
static int dev_index;
@@ -183,7 +183,7 @@ int usb_disable_asynch(int disable)
asynch_allowed = !disable;
return old_value;
}
-#endif /* !CONFIG_DM_USB */
+#endif /* !CONFIG_IS_ENABLED(DM_USB) */
/*-------------------------------------------------------------------
@@ -849,7 +849,7 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size)
* the USB device are static allocated [USB_MAX_DEVICE].
*/
-#ifndef CONFIG_DM_USB
+#if !CONFIG_IS_ENABLED(DM_USB)
/* returns a pointer to the device with the index [index].
* if the device is not assigned (dev->devnum==-1) returns NULL
@@ -906,7 +906,7 @@ __weak int usb_alloc_device(struct usb_device *udev)
{
return 0;
}
-#endif /* !CONFIG_DM_USB */
+#endif /* !CONFIG_IS_ENABLED(DM_USB) */
static int usb_hub_port_reset(struct usb_device *dev, struct usb_device *hub)
{
@@ -1166,7 +1166,7 @@ int usb_setup_device(struct usb_device *dev, bool do_read,
return ret;
}
-#ifndef CONFIG_DM_USB
+#if !CONFIG_IS_ENABLED(DM_USB)
/*
* By the time we get here, the device has gotten a new device ID
* and is in the default state. We need to identify the thing and
@@ -1215,14 +1215,14 @@ int board_usb_cleanup(int index, enum usb_init_type init)
bool usb_device_has_child_on_port(struct usb_device *parent, int port)
{
-#ifdef CONFIG_DM_USB
+#if CONFIG_IS_ENABLED(DM_USB)
return false;
#else
return parent->children[port] != NULL;
#endif
}
-#ifdef CONFIG_DM_USB
+#if CONFIG_IS_ENABLED(DM_USB)
void usb_find_usb2_hub_address_port(struct usb_device *udev,
uint8_t *hub_address, uint8_t *hub_port)
{
diff --git a/common/usb_hub.c b/common/usb_hub.c
index e1d93b83335..33aaeb8e445 100644
--- a/common/usb_hub.c
+++ b/common/usb_hub.c
@@ -64,7 +64,7 @@ static inline bool usb_hub_is_superspeed(struct usb_device *hdev)
return hdev->descriptor.bDeviceProtocol == 3;
}
-#ifdef CONFIG_DM_USB
+#if CONFIG_IS_ENABLED(DM_USB)
bool usb_hub_is_root_hub(struct udevice *hub)
{
if (device_get_uclass_id(hub->parent) != UCLASS_USB_HUB)
@@ -125,7 +125,7 @@ int usb_get_port_status(struct usb_device *dev, int port, void *data)
USB_REQ_GET_STATUS, USB_DIR_IN | USB_RT_PORT, 0, port,
data, sizeof(struct usb_port_status), USB_CNTL_TIMEOUT);
-#ifdef CONFIG_DM_USB
+#if CONFIG_IS_ENABLED(DM_USB)
if (ret < 0)
return ret;
@@ -209,7 +209,7 @@ static void usb_hub_power_on(struct usb_hub_device *hub)
max(100, (int)pgood_delay) + 1000);
}
-#ifndef CONFIG_DM_USB
+#if !CONFIG_IS_ENABLED(DM_USB)
static struct usb_hub_device hub_dev[USB_MAX_HUB];
static int usb_hub_index;
@@ -273,7 +273,7 @@ static int usb_hub_port_reset(struct usb_device *dev, int port,
unsigned short portstatus, portchange;
int delay = HUB_SHORT_RESET_TIME; /* start with short reset delay */
-#ifdef CONFIG_DM_USB
+#if CONFIG_IS_ENABLED(DM_USB)
debug("%s: resetting '%s' port %d...\n", __func__, dev->dev->name,
port + 1);
#else
@@ -394,7 +394,7 @@ int usb_hub_port_connect_change(struct usb_device *dev, int port)
break;
}
-#ifdef CONFIG_DM_USB
+#if CONFIG_IS_ENABLED(DM_USB)
struct udevice *child;
ret = usb_scan_device(dev->dev, port + 1, speed, &child);
@@ -604,7 +604,7 @@ static struct usb_hub_device *usb_get_hub_device(struct usb_device *dev)
{
struct usb_hub_device *hub;
-#ifndef CONFIG_DM_USB
+#if !CONFIG_IS_ENABLED(DM_USB)
/* "allocate" Hub device */
hub = usb_hub_allocate();
#else
@@ -788,7 +788,7 @@ static int usb_hub_configure(struct usb_device *dev)
(le16_to_cpu(hubsts->wHubStatus) & HUB_STATUS_OVERCURRENT) ? \
"" : "no ");
-#ifdef CONFIG_DM_USB
+#if CONFIG_IS_ENABLED(DM_USB)
/*
* Update USB host controller's internal representation of this hub
* after the hub descriptor is fetched.
@@ -930,7 +930,7 @@ int usb_hub_probe(struct usb_device *dev, int ifnum)
return ret;
}
-#ifdef CONFIG_DM_USB
+#if CONFIG_IS_ENABLED(DM_USB)
int usb_hub_scan(struct udevice *hub)
{
struct usb_device *udev = dev_get_parent_priv(hub);
diff --git a/common/usb_kbd.c b/common/usb_kbd.c
index fdeb2aed245..020f0d4117f 100644
--- a/common/usb_kbd.c
+++ b/common/usb_kbd.c
@@ -539,7 +539,7 @@ static int probe_usb_keyboard(struct usb_device *dev)
return 0;
}
-#ifndef CONFIG_DM_USB
+#if !CONFIG_IS_ENABLED(DM_USB)
/* Search for keyboard and register it if found. */
int drv_usb_kbd_init(void)
{
@@ -602,7 +602,7 @@ int usb_kbd_deregister(int force)
#endif
-#ifdef CONFIG_DM_USB
+#if CONFIG_IS_ENABLED(DM_USB)
static int usb_kbd_probe(struct udevice *dev)
{
diff --git a/common/usb_storage.c b/common/usb_storage.c
index 560d60538b6..8c889bb1a64 100644
--- a/common/usb_storage.c
+++ b/common/usb_storage.c
@@ -66,7 +66,7 @@ static __u32 CBWTag;
static int usb_max_devs; /* number of highest available usb device */
-#ifndef CONFIG_BLK
+#if !CONFIG_IS_ENABLED(BLK)
static struct blk_desc usb_dev_desc[USB_MAX_STOR_DEV];
#endif
@@ -99,7 +99,7 @@ struct us_data {
unsigned short max_xfer_blk; /* maximum transfer blocks */
};
-#ifndef CONFIG_BLK
+#if !CONFIG_IS_ENABLED(BLK)
static struct us_data usb_stor[USB_MAX_STOR_DEV];
#endif
@@ -111,7 +111,7 @@ int usb_stor_get_info(struct usb_device *dev, struct us_data *us,
struct blk_desc *dev_desc);
int usb_storage_probe(struct usb_device *dev, unsigned int ifnum,
struct us_data *ss);
-#ifdef CONFIG_BLK
+#if CONFIG_IS_ENABLED(BLK)
static unsigned long usb_stor_read(struct udevice *dev, lbaint_t blknr,
lbaint_t blkcnt, void *buffer);
static unsigned long usb_stor_write(struct udevice *dev, lbaint_t blknr,
@@ -136,7 +136,7 @@ static void usb_show_progress(void)
int usb_stor_info(void)
{
int count = 0;
-#ifdef CONFIG_BLK
+#if CONFIG_IS_ENABLED(BLK)
struct udevice *dev;
for (blk_first_device(IF_TYPE_USB, &dev);
@@ -186,7 +186,7 @@ static int usb_stor_probe_device(struct usb_device *udev)
{
int lun, max_lun;
-#ifdef CONFIG_BLK
+#if CONFIG_IS_ENABLED(BLK)
struct us_data *data;
int ret;
#else
@@ -197,7 +197,7 @@ static int usb_stor_probe_device(struct usb_device *udev)
#endif
debug("\n\nProbing for storage\n");
-#ifdef CONFIG_BLK
+#if CONFIG_IS_ENABLED(BLK)
/*
* We store the us_data in the mass storage device's platdata. It
* is shared by all LUNs (block devices) attached to this mass storage
@@ -299,7 +299,7 @@ int usb_stor_scan(int mode)
if (mode == 1)
printf(" scanning usb for storage devices... ");
-#ifndef CONFIG_DM_USB
+#if !CONFIG_IS_ENABLED(DM_USB)
unsigned char i;
usb_disable_asynch(1); /* asynch transfer not allowed */
@@ -942,7 +942,7 @@ static void usb_stor_set_max_xfer_blk(struct usb_device *udev,
size_t __maybe_unused size;
int __maybe_unused ret;
-#ifndef CONFIG_DM_USB
+#if !CONFIG_IS_ENABLED(DM_USB)
#ifdef CONFIG_USB_EHCI_HCD
/*
* The U-Boot EHCI driver can handle any transfer length as long as
@@ -1119,7 +1119,7 @@ static void usb_bin_fixup(struct usb_device_descriptor descriptor,
}
#endif /* CONFIG_USB_BIN_FIXUP */
-#ifdef CONFIG_BLK
+#if CONFIG_IS_ENABLED(BLK)
static unsigned long usb_stor_read(struct udevice *dev, lbaint_t blknr,
lbaint_t blkcnt, void *buffer)
#else
@@ -1134,14 +1134,14 @@ static unsigned long usb_stor_read(struct blk_desc *block_dev, lbaint_t blknr,
struct us_data *ss;
int retry;
struct scsi_cmd *srb = &usb_ccb;
-#ifdef CONFIG_BLK
+#if CONFIG_IS_ENABLED(BLK)
struct blk_desc *block_dev;
#endif
if (blkcnt == 0)
return 0;
/* Setup device */
-#ifdef CONFIG_BLK
+#if CONFIG_IS_ENABLED(BLK)
block_dev = dev_get_uclass_platdata(dev);
udev = dev_get_parent_priv(dev_get_parent(dev));
debug("\nusb_read: udev %d\n", block_dev->devnum);
@@ -1200,7 +1200,7 @@ retry_it:
return blkcnt;
}
-#ifdef CONFIG_BLK
+#if CONFIG_IS_ENABLED(BLK)
static unsigned long usb_stor_write(struct udevice *dev, lbaint_t blknr,
lbaint_t blkcnt, const void *buffer)
#else
@@ -1215,7 +1215,7 @@ static unsigned long usb_stor_write(struct blk_desc *block_dev, lbaint_t blknr,
struct us_data *ss;
int retry;
struct scsi_cmd *srb = &usb_ccb;
-#ifdef CONFIG_BLK
+#if CONFIG_IS_ENABLED(BLK)
struct blk_desc *block_dev;
#endif
@@ -1223,7 +1223,7 @@ static unsigned long usb_stor_write(struct blk_desc *block_dev, lbaint_t blknr,
return 0;
/* Setup device */
-#ifdef CONFIG_BLK
+#if CONFIG_IS_ENABLED(BLK)
block_dev = dev_get_uclass_platdata(dev);
udev = dev_get_parent_priv(dev_get_parent(dev));
debug("\nusb_read: udev %d\n", block_dev->devnum);
@@ -1495,7 +1495,7 @@ int usb_stor_get_info(struct usb_device *dev, struct us_data *ss,
return 1;
}
-#ifdef CONFIG_DM_USB
+#if CONFIG_IS_ENABLED(DM_USB)
static int usb_mass_storage_probe(struct udevice *dev)
{
@@ -1519,7 +1519,7 @@ U_BOOT_DRIVER(usb_mass_storage) = {
.id = UCLASS_MASS_STORAGE,
.of_match = usb_mass_storage_ids,
.probe = usb_mass_storage_probe,
-#ifdef CONFIG_BLK
+#if CONFIG_IS_ENABLED(BLK)
.platdata_auto_alloc_size = sizeof(struct us_data),
#endif
};
@@ -1540,7 +1540,7 @@ static const struct usb_device_id mass_storage_id_table[] = {
U_BOOT_USB_DEVICE(usb_mass_storage, mass_storage_id_table);
#endif
-#ifdef CONFIG_BLK
+#if CONFIG_IS_ENABLED(BLK)
static const struct blk_ops usb_storage_ops = {
.read = usb_stor_read,
.write = usb_stor_write,