From: Sean Anderson <seanga2@gmail.com>
To: u-boot@lists.denx.de
Subject: [PATCH 05/10] test: Add a test for fdtdec_setup_mem_size_base et al.
Date: Tue, 29 Sep 2020 10:18:30 -0400 [thread overview]
Message-ID: <20200929141835.38435-6-seanga2@gmail.com> (raw)
In-Reply-To: <20200929141835.38435-1-seanga2@gmail.com>
This adds a test for the various methods of extracting ram_base and
ram_size from a device tree.
Signed-off-by: Sean Anderson <seanga2@gmail.com>
---
arch/sandbox/dts/test.dts | 12 ++++++++++
configs/sandbox64_defconfig | 2 +-
configs/sandbox_defconfig | 2 +-
configs/sandbox_flattree_defconfig | 2 +-
test/dm/fdtdec.c | 38 ++++++++++++++++++++++++++++++
5 files changed, 53 insertions(+), 3 deletions(-)
diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index 9f45c48e4e..e98f0cbe25 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -1122,6 +1122,18 @@
resets = <&resetc2 15>, <&resetc2 30>, <&resetc2 60>;
reset-names = "valid", "no_mask", "out_of_range";
};
+
+ memory at 0000 {
+ device_type = "memory";
+ reg = <0x1000 0x2000>,
+ <0x0000 0x1000>;
+ };
+
+ memory at 8000 {
+ device_type = "memory";
+ reg = <0x8000 0x0000>,
+ <0x4000 0x3000>;
+ };
};
#include "sandbox_pmic.dtsi"
diff --git a/configs/sandbox64_defconfig b/configs/sandbox64_defconfig
index c3ca796d51..6324961cf1 100644
--- a/configs/sandbox64_defconfig
+++ b/configs/sandbox64_defconfig
@@ -1,5 +1,5 @@
CONFIG_SYS_TEXT_BASE=0
-CONFIG_NR_DRAM_BANKS=1
+CONFIG_NR_DRAM_BANKS=4
CONFIG_ENV_SIZE=0x2000
CONFIG_PRE_CON_BUF_ADDR=0x100000
CONFIG_BOOTSTAGE_STASH_ADDR=0x0
diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index 6e9f029cc9..20718d26c8 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -1,5 +1,5 @@
CONFIG_SYS_TEXT_BASE=0
-CONFIG_NR_DRAM_BANKS=1
+CONFIG_NR_DRAM_BANKS=4
CONFIG_ENV_SIZE=0x2000
CONFIG_PRE_CON_BUF_ADDR=0xf0000
CONFIG_BOOTSTAGE_STASH_ADDR=0x0
diff --git a/configs/sandbox_flattree_defconfig b/configs/sandbox_flattree_defconfig
index dd93167e1b..a4941b54d3 100644
--- a/configs/sandbox_flattree_defconfig
+++ b/configs/sandbox_flattree_defconfig
@@ -1,5 +1,5 @@
CONFIG_SYS_TEXT_BASE=0
-CONFIG_NR_DRAM_BANKS=1
+CONFIG_NR_DRAM_BANKS=4
CONFIG_ENV_SIZE=0x2000
CONFIG_BOOTSTAGE_STASH_ADDR=0x0
CONFIG_DEFAULT_DEVICE_TREE="sandbox"
diff --git a/test/dm/fdtdec.c b/test/dm/fdtdec.c
index 716993f706..5fcda1cd13 100644
--- a/test/dm/fdtdec.c
+++ b/test/dm/fdtdec.c
@@ -128,3 +128,41 @@ static int dm_test_fdtdec_add_reserved_memory(struct unit_test_state *uts)
}
DM_TEST(dm_test_fdtdec_add_reserved_memory,
UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT | UT_TESTF_FLAT_TREE);
+
+static int _dm_test_fdtdec_setup_mem(struct unit_test_state *uts)
+{
+ ut_assertok(fdtdec_setup_mem_size_base());
+ ut_asserteq(0x1000, gd->ram_base);
+ ut_asserteq(0x2000, gd->ram_size);
+
+ ut_assertok(fdtdec_setup_mem_size_base_lowest());
+ ut_asserteq(0x0000, gd->ram_base);
+ ut_asserteq(0x1000, gd->ram_size);
+
+ ut_assertok(fdtdec_setup_mem_size_base_highest());
+ ut_asserteq(0x4000, gd->ram_base);
+ ut_asserteq(0x3000, gd->ram_size);
+
+ return 0;
+}
+
+/*
+ * We need to wrap the actual test so that we don't overwrite the ram parameters
+ * for the rest of U-Boot
+ */
+static int dm_test_fdtdec_setup_mem(struct unit_test_state *uts)
+{
+ int ret;
+ unsigned long base, size;
+
+ base = gd->ram_base;
+ size = gd->ram_size;
+
+ ret = _dm_test_fdtdec_setup_mem(uts);
+
+ gd->ram_base = base;
+ gd->ram_size = size;
+
+ return ret;
+}
+DM_TEST(dm_test_fdtdec_setup_mem, UT_TESTF_SCAN_FDT | UT_TESTF_FLAT_TREE);
--
2.28.0
next prev parent reply other threads:[~2020-09-29 14:18 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-29 14:18 [PATCH 00/10] riscv: k210: Enable use of AI ram bank Sean Anderson
2020-09-29 14:18 ` [PATCH 01/10] clk: k210: Fix PLLs not being enabled Sean Anderson
2020-09-29 14:18 ` [PATCH 02/10] clk: Add support for the k210 clock driver pre-relocation Sean Anderson
2020-09-29 14:18 ` [PATCH 03/10] riscv: Enable some devices pre-relocation Sean Anderson
2020-09-29 14:18 ` [PATCH 04/10] lib: fdt: Add fdtdec_setup_mem_size_base_highest Sean Anderson
2020-10-12 3:34 ` Simon Glass
2020-09-29 14:18 ` Sean Anderson [this message]
2020-10-12 3:34 ` [PATCH 05/10] test: Add a test for fdtdec_setup_mem_size_base et al Simon Glass
2020-09-29 14:18 ` [PATCH 06/10] ram: Add driver for K210 SRAM Sean Anderson
2020-10-07 13:26 ` Simon Glass
2020-09-29 14:18 ` [PATCH 07/10] ram: sifive: Default to y only if compiling for fu540 Sean Anderson
2020-09-30 4:08 ` Pragnesh Patel
2020-09-29 14:18 ` [PATCH 08/10] riscv: Probe ram in dram_init Sean Anderson
2020-09-29 14:18 ` [PATCH 09/10] riscv: Enable AI ram on K210 Sean Anderson
2020-09-29 14:18 ` [PATCH 10/10] riscv: Don't reserve AI ram in k210 dts Sean Anderson
2020-09-29 15:03 ` Heinrich Schuchardt
2020-09-29 15:07 ` Sean Anderson
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=20200929141835.38435-6-seanga2@gmail.com \
--to=seanga2@gmail.com \
--cc=u-boot@lists.denx.de \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox