Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BSP part of IOT2050-SM #509

Merged
merged 4 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion conf/machine/iot2050.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) Siemens AG, 2019-2022
# Copyright (c) Siemens AG, 2019-2023
#
# Authors:
# Le Jin <[email protected]>
Expand All @@ -21,6 +21,7 @@ DTB_FILES ?= " \
ti/k3-am6548-iot2050-advanced.dtb \
ti/k3-am6548-iot2050-advanced-pg2.dtb \
ti/k3-am6548-iot2050-advanced-m2.dtb \
ti/k3-am6548-iot2050-advanced-sm.dtb \
"

IMAGE_FSTYPES ?= "wic"
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Signed-off-by: Jan Kiszka <[email protected]>
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/tools/iot2050-sign-fw.sh b/tools/iot2050-sign-fw.sh
index 6b426c854c2..75ffd560823 100755
index 6b426c854c20..75ffd560823c 100755
--- a/tools/iot2050-sign-fw.sh
+++ b/tools/iot2050-sign-fw.sh
@@ -5,6 +5,8 @@ if [ -z "$1" ]; then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Signed-off-by: Jan Kiszka <[email protected]>
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/board/siemens/iot2050/board.c b/board/siemens/iot2050/board.c
index 15f5310c7bf..e35e55fb5de 100644
index 15f5310c7bf3..e35e55fb5de8 100644
--- a/board/siemens/iot2050/board.c
+++ b/board/siemens/iot2050/board.c
@@ -160,7 +160,7 @@ static bool board_is_sr1(void)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Signed-off-by: Jan Kiszka <[email protected]>
1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/board/siemens/iot2050/board.c b/board/siemens/iot2050/board.c
index e35e55fb5de..0b0686e2628 100644
index e35e55fb5de8..0b0686e2628b 100644
--- a/board/siemens/iot2050/board.c
+++ b/board/siemens/iot2050/board.c
@@ -155,19 +155,20 @@ static bool board_is_advanced(void)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Reviewed-by: Heinrich Schuchardt <[email protected]>
1 file changed, 9 insertions(+)

diff --git a/include/configs/iot2050.h b/include/configs/iot2050.h
index 4968722d18f..94a9c767882 100644
index 4968722d18f6..94a9c7678825 100644
--- a/include/configs/iot2050.h
+++ b/include/configs/iot2050.h
@@ -15,6 +15,15 @@
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Baocheng Su <[email protected]>
Date: Fri, 1 Dec 2023 19:43:28 +0800
Subject: [PATCH] board: siemens: iot2050: Fix coding style

Add a space after the 'if'

Signed-off-by: Baocheng Su <[email protected]>
---
board/siemens/iot2050/board.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/board/siemens/iot2050/board.c b/board/siemens/iot2050/board.c
index 0b0686e2628b..1fa71f8da6a4 100644
--- a/board/siemens/iot2050/board.c
+++ b/board/siemens/iot2050/board.c
@@ -220,7 +220,7 @@ void set_board_info_env(void)
if (board_is_advanced()) {
if (board_is_pg1())
fdtfile = "ti/k3-am6548-iot2050-advanced.dtb";
- else if(board_is_m2())
+ else if (board_is_m2())
fdtfile = "ti/k3-am6548-iot2050-advanced-m2.dtb";
else
fdtfile = "ti/k3-am6548-iot2050-advanced-pg2.dtb";
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Baocheng Su <[email protected]>
Date: Wed, 29 Nov 2023 23:01:48 +0800
Subject: [PATCH] board: siemens: iot2050: Control pcie power for all variants

The power control pin of pcie interface not only works for M.2 interface
but also for miniPCIE, so promote this logic to all variants to
workaround the module hang issue.

Signed-off-by: Baocheng Su <[email protected]>
---
board/siemens/iot2050/board.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/board/siemens/iot2050/board.c b/board/siemens/iot2050/board.c
index 1fa71f8da6a4..b83d5f8669e8 100644
--- a/board/siemens/iot2050/board.c
+++ b/board/siemens/iot2050/board.c
@@ -185,6 +185,12 @@ static void remove_mmc1_target(void)
free(boot_targets);
}

+static void enable_pcie_connector_power(void)
+{
+ set_pinvalue("gpio@601000_17", "P3V3_PCIE_CON_EN", 1);
+ udelay(4 * 100);
+}
+
void set_board_info_env(void)
{
struct iot2050_info *info = IOT2050_INFO_DATA;
@@ -288,10 +294,6 @@ static void m2_connector_setup(void)
struct m2_config_pins config_pins;
unsigned int n;

- /* enable M.2 connector power */
- set_pinvalue("gpio@601000_17", "P3V3_M2_EN", 1);
- udelay(4 * 100);
-
if (m2_manual_config < CONNECTOR_MODE_INVALID) {
mode_info = " [manual mode]";
connector_mode = m2_manual_config;
@@ -429,6 +431,8 @@ int board_late_init(void)
/* change CTRL_MMR register to let serdes0 not output USB3.0 signals. */
writel(0x3, SERDES0_LANE_SELECT);

+ enable_pcie_connector_power();
+
if (board_is_m2())
m2_connector_setup();

Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Baocheng Su <[email protected]>
Date: Wed, 29 Nov 2023 23:16:15 +0800
Subject: [PATCH] board: siemens: iot2050: Pass DDR size from FSBL

Due to new DDR size introduction, the current logic of determining the
DDR size is not able to get the correct size.

Instead, the DDR size is determined by the FSBL(SEBOOT) then passed to
u-boot through the scratchpad info.

The SEBoot version must be >= D/V01.04.0x.0x to support this change.

Also now for some variants, the DDR size may > 2GB, so borrow some code
from the TI evm to iot2050 to support more than 2GB DDR.

Signed-off-by: Baocheng Su <[email protected]>
---
board/siemens/iot2050/board.c | 39 ++++++++++++++++++++++++++---------
doc/board/siemens/iot2050.rst | 3 +++
include/configs/iot2050.h | 3 +++
3 files changed, 35 insertions(+), 10 deletions(-)

diff --git a/board/siemens/iot2050/board.c b/board/siemens/iot2050/board.c
index b83d5f8669e8..d6228b9bd26b 100644
--- a/board/siemens/iot2050/board.c
+++ b/board/siemens/iot2050/board.c
@@ -38,6 +38,8 @@ struct iot2050_info {
u8 mac_addr_cnt;
u8 mac_addr[8][ARP_HLEN];
char seboot_version[40 + 1];
+ u8 padding[3];
+ u32 ddr_size_mb;
} __packed;

/*
@@ -341,25 +343,42 @@ int board_init(void)

int dram_init(void)
{
- if (board_is_advanced())
- gd->ram_size = SZ_2G;
- else
- gd->ram_size = SZ_1G;
+ struct iot2050_info *info = IOT2050_INFO_DATA;
+ gd->ram_size = ((phys_size_t)(info->ddr_size_mb)) << 20;

return 0;
}

+ulong board_get_usable_ram_top(ulong total_size)
+{
+ /* Limit RAM used by U-Boot to the DDR low region */
+ if (gd->ram_top > 0x100000000)
+ return 0x100000000;
+
+ return gd->ram_top;
+}
+
int dram_init_banksize(void)
{
dram_init();

- /* Bank 0 declares the memory available in the DDR low region */
- gd->bd->bi_dram[0].start = CFG_SYS_SDRAM_BASE;
- gd->bd->bi_dram[0].size = gd->ram_size;
+ if (gd->ram_size > SZ_2G) {
+ /* Bank 0 declares the memory available in the DDR low region */
+ gd->bd->bi_dram[0].start = CFG_SYS_SDRAM_BASE;
+ gd->bd->bi_dram[0].size = SZ_2G;
+
+ /* Bank 1 declares the memory available in the DDR high region */
+ gd->bd->bi_dram[1].start = CFG_SYS_SDRAM_BASE1;
+ gd->bd->bi_dram[1].size = gd->ram_size - SZ_2G;
+ } else {
+ /* Bank 0 declares the memory available in the DDR low region */
+ gd->bd->bi_dram[0].start = CFG_SYS_SDRAM_BASE;
+ gd->bd->bi_dram[0].size = gd->ram_size;

- /* Bank 1 declares the memory available in the DDR high region */
- gd->bd->bi_dram[1].start = 0;
- gd->bd->bi_dram[1].size = 0;
+ /* Bank 1 declares the memory available in the DDR high region */
+ gd->bd->bi_dram[1].start = 0;
+ gd->bd->bi_dram[1].size = 0;
+ }

return 0;
}
diff --git a/doc/board/siemens/iot2050.rst b/doc/board/siemens/iot2050.rst
index ee3c5c958464..e88d25caf611 100644
--- a/doc/board/siemens/iot2050.rst
+++ b/doc/board/siemens/iot2050.rst
@@ -29,6 +29,9 @@ The following binaries from that source need to be present in the build folder:
- seboot_pg1.bin
- seboot_pg2.bin

+Note that SE-Boot D01.04.01.02/V01.04.01 or greater is required, otherwise the
+DDR size will not be picked up correctly by U-Boot.
+
When using the watchdog, a related firmware for the R5 core(s) is needed, e.g.
https://github.com/siemens/k3-rti-wdt. The name and location of the image is
configured via CONFIG_WDT_K3_RTI_FW_FILE.
diff --git a/include/configs/iot2050.h b/include/configs/iot2050.h
index 94a9c7678825..5e97ea0d9438 100644
--- a/include/configs/iot2050.h
+++ b/include/configs/iot2050.h
@@ -24,6 +24,9 @@
func(USB, usb, 2)
#endif

+/* DDR Configuration */
+#define CFG_SYS_SDRAM_BASE1 0x880000000
+
/*
* This defines all MMC devices, even if the basic variant has no mmc1.
* The non-supported device will be removed from the boot targets during
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Baocheng Su <[email protected]>
Date: Wed, 29 Nov 2023 23:29:12 +0800
Subject: [PATCH] board: siemens: iot2050: Generalize the fdt fixup

The fdt fixup logic actually also applies to other possible variants who
also have device tree overlays. So generalize this part by extracting
it from the m.2 specific function and make it a standalone one.

Since now we only have M.2 variant consuming the overlay, it may not
have immediate effect for other variant, however this makes the future
variant more easier to apply fdt fixups.

Signed-off-by: Baocheng Su <[email protected]>
---
board/siemens/iot2050/board.c | 32 +++++++++++++++++++-------------
1 file changed, 19 insertions(+), 13 deletions(-)

diff --git a/board/siemens/iot2050/board.c b/board/siemens/iot2050/board.c
index d6228b9bd26b..32f5280125c0 100644
--- a/board/siemens/iot2050/board.c
+++ b/board/siemens/iot2050/board.c
@@ -245,23 +245,14 @@ void set_board_info_env(void)
env_save();
}

-static void m2_overlay_prepare(void)
+static void do_overlay_prepare(const char *overlay_path)
{
#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
- const char *overlay_path;
void *overlay;
u64 loadaddr;
ofnode node;
int ret;

- if (connector_mode == BKEY_PCIEX2)
- return;
-
- if (connector_mode == BKEY_PCIE_EKEY_PCIE)
- overlay_path = "/fit-images/bkey-ekey-pcie-overlay";
- else
- overlay_path = "/fit-images/bkey-usb3-overlay";
-
node = ofnode_path(overlay_path);
if (!ofnode_valid(node))
goto fit_error;
@@ -288,6 +279,21 @@ fit_error:
#endif
}

+static void m2_overlay_prepare(void)
+{
+ const char *overlay_path;
+
+ if (connector_mode == BKEY_PCIEX2)
+ return;
+
+ if (connector_mode == BKEY_PCIE_EKEY_PCIE)
+ overlay_path = "/fit-images/bkey-ekey-pcie-overlay";
+ else
+ overlay_path = "/fit-images/bkey-usb3-overlay";
+
+ do_overlay_prepare(overlay_path);
+}
+
static void m2_connector_setup(void)
{
ulong m2_manual_config = env_get_ulong("m2_manual_config", 10,
@@ -466,7 +472,7 @@ int board_late_init(void)
}

#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
-static void m2_fdt_fixup(void *blob)
+static void variants_fdt_fixup(void *blob)
{
void *overlay_copy = NULL;
void *fdt_copy = NULL;
@@ -506,14 +512,14 @@ cleanup:
return;

fixup_error:
- pr_err("Could not apply M.2 device tree overlay\n");
+ pr_err("Could not apply device tree overlay\n");
goto cleanup;
}

int ft_board_setup(void *blob, struct bd_info *bd)
{
if (board_is_m2())
- m2_fdt_fixup(blob);
+ variants_fdt_fixup(blob);

return 0;
}
Loading