From: E Shattow <e@freeshell.de>
To: u-boot@lists.u-boot-project.org
Cc: E Shattow <e@freeshell.de>
Subject: [DNM PATCH v1 2/7] reduced SpacemiT K3 vendor BSP: add guards around config optioned k3.c code
Date: Wed, 28 Oct 2026 17:15:50 -0700 [thread overview]
Message-ID: <20261029001555.1890775-3-e@freeshell.de> (raw)
In-Reply-To: <20261029001555.1890775-1-e@freeshell.de>
Do Not Merge
Informational purpose only, to aid mainline development of SpacemiT K3
support.
---
board/spacemit/k3/k3.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/board/spacemit/k3/k3.c b/board/spacemit/k3/k3.c
index 40b7720eee6d..a06db6f3ffd6 100644
--- a/board/spacemit/k3/k3.c
+++ b/board/spacemit/k3/k3.c
@@ -421,6 +421,7 @@ static ulong read_boot_storage_emmc(ulong byte_addr, ulong byte_size, void* buff
}
#endif
+#if CONFIG_IS_ENABLED(SPI_FLASH)
static ulong read_boot_storage_spinor(ulong byte_addr, ulong byte_size, void* buff)
{
struct udevice *dev;
@@ -434,6 +435,7 @@ static ulong read_boot_storage_spinor(ulong byte_addr, ulong byte_size, void* bu
return 0;
}
}
+#endif
#if CONFIG_IS_ENABLED(SCSI)
static ulong read_boot_storage_ufs(ulong byte_addr, ulong byte_size, void* buff)
@@ -450,7 +452,9 @@ static const struct boot_storage_op storage_op[] = {
#if CONFIG_IS_ENABLED(MMC)
{ BOOT_MODE_EMMC, 0x140000, read_boot_storage_emmc, NULL },
#endif
+#if CONFIG_IS_ENABLED(SPI_FLASH)
{ BOOT_MODE_NOR, 0x10000, read_boot_storage_spinor, NULL },
+#endif
#if CONFIG_IS_ENABLED(SCSI)
{ BOOT_MODE_UFS, 0x140000, read_boot_storage_ufs, NULL },
#endif
@@ -482,6 +486,7 @@ static bool write_boot_storage_emmc(ulong byte_addr, ulong byte_size, void* buff
}
#endif
+#if CONFIG_IS_ENABLED(SPI_FLASH)
static bool write_boot_storage_spinor(ulong byte_addr, ulong byte_size, void* buff)
{
struct udevice *dev;
@@ -497,6 +502,7 @@ static bool write_boot_storage_spinor(ulong byte_addr, ulong byte_size, void* bu
} else
return false;
}
+#endif
#if CONFIG_IS_ENABLED(SCSI)
static bool write_boot_storage_ufs(ulong byte_addr, ulong byte_size, void* buff)
@@ -510,7 +516,9 @@ static const struct boot_storage_op storage_op[] = {
#if CONFIG_IS_ENABLED(MMC)
{ BOOT_MODE_EMMC, 0x140000, read_boot_storage_emmc, write_boot_storage_emmc },
#endif
+#if CONFIG_IS_ENABLED(SPI_FLASH)
{ BOOT_MODE_NOR, 0x10000, read_boot_storage_spinor, write_boot_storage_spinor },
+#endif
#if CONFIG_IS_ENABLED(SCSI)
{ BOOT_MODE_UFS, 0x140000, read_boot_storage_ufs, write_boot_storage_ufs },
#endif
@@ -707,7 +715,11 @@ uint32_t get_serial_number(char *sn, uint32_t max_size)
if ((0 != ret) || (0 == chipid)) {
seed = get_ticks();
for (i = 0; i < sizeof(chipid); i++) {
+#if IS_ENABLED(LIB_RAND)
((uint8_t*)&chipid)[i] = rand_r(&seed);
+#else
+ ((uint8_t*)&chipid)[i] = 0;
+#endif
}
}
snprintf(temp, sizeof(temp), "%016llx", chipid);
@@ -748,7 +760,11 @@ void set_dev_serial_no(void)
int board_init(void)
{
+#if defined(CONFIG_DM_REGULATOR_SPM8XX) \
+|| CONFIG_IS_ENABLED(ESPI) \
+|| CONFIG_IS_ENABLED(RT7451_RETIMER)
int ret = 0;
+#endif
#if CONFIG_IS_ENABLED(RT7451_RETIMER)
struct udevice *dev;
@@ -787,12 +803,15 @@ int board_init(void)
void get_reboot_config(void)
{
+#if CONFIG_IS_ENABLED(DM_PMIC)
int ret;
struct udevice *dev;
uint8_t value;
+#endif
reboot_config = get_boot_mode();
+#if CONFIG_IS_ENABLED(DM_PMIC)
ret = uclass_get_device_by_driver(UCLASS_PMIC,
DM_DRIVER_GET(spacemit_pm8xx), &dev);
if (ret) {
@@ -818,6 +837,7 @@ void get_reboot_config(void)
pr_err("spacemit reboot: PMIC write failed\n");
return;
}
+#endif
}
void run_fastboot_command(void)
@@ -1717,10 +1737,16 @@ void set_env_ethaddr(void)
return;
}
+#if IS_ENABLED(NET_RANDOM_ETHADDR)
/*if there is NO valid MAC address, create 4 random ethaddr */
maccount = 4;
pr_info("generate %d random ethaddr.\n", maccount);
net_random_ethaddr(mac_addr);
+#else
+ mac_addr[3] = 0;
+ mac_addr[4] = 0;
+ mac_addr[5] = 0;
+#endif
mac_addr[0] = 0xfe;
mac_addr[1] = 0xfe;
mac_addr[2] = 0xfe;
@@ -1911,6 +1937,7 @@ int ft_board_setup(void *blob, struct bd_info *bd)
__maybe_unused struct fdt_memory mem;
int ret;
+#if CONFIG_IS_ENABLED(DM_VIDEO)
if (CONFIG_IS_ENABLED(FDT_SIMPLEFB)) {
/* reserved with no-map tag the video buffer */
mem.start = gd->video_bottom;
@@ -1918,6 +1945,7 @@ int ft_board_setup(void *blob, struct bd_info *bd)
fdtdec_add_reserved_memory(blob, "framebuffer", &mem, NULL, 0, NULL, 0);
}
+#endif
ft_board_cpu_fixup(blob, bd);
ft_board_info_fixup(blob, bd);
--
2.53.0
next prev parent reply other threads:[~2026-10-29 0:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-29 0:15 [DNM v1 0/7] Guide to build reduced SpacemiT K3 vendor BSP E Shattow
2026-10-29 0:15 ` [DNM PATCH v1 1/7] reduced SpacemiT K3 vendor BSP: use MKIMAGE build env E Shattow
2026-10-29 0:15 ` E Shattow [this message]
2026-10-29 0:15 ` [DNM PATCH v1 3/7] reduced SpacemiT K3 vendor BSP: add fallback fastboot buf addr and size def E Shattow
2026-10-29 0:15 ` [DNM PATCH v1 4/7] reduced SpacemiT K3 vendor BSP: force UART boot when YMODEM_SUPPORT enabled E Shattow
2026-10-29 0:15 ` [DNM PATCH v1 5/7] reduced SpacemiT K3 vendor BSP: add UART SPI defconfig E Shattow
2026-10-29 0:15 ` [DNM PATCH v1 6/7] reduced SpacemiT K3 vendor BSP: add UART (no SPI) defconfig E Shattow
2026-10-29 0:15 ` [DNM PATCH v1 7/7] reduced SpacemiT K3 vendor BSP: set uart compatible for mainline OpenSBI E Shattow
2026-10-29 0:33 ` [DNM v1 0/7] Guide to build reduced SpacemiT K3 vendor BSP (continued) E Shattow
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=20261029001555.1890775-3-e@freeshell.de \
--to=e@freeshell.de \
--cc=u-boot@lists.u-boot-project.org \
/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.