[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 22/24] test/qtest/aspeed_smc-test: Support write page command with
From: |
Cédric Le Goater |
Subject: |
[PULL 22/24] test/qtest/aspeed_smc-test: Support write page command with QPI mode |
Date: |
Wed, 11 Dec 2024 07:30:56 +0100 |
From: Jamin Lin <jamin_lin@aspeedtech.com>
Add a new testcase for write page command with QPI mode testing.
Currently, only run this testcase for AST2500, AST2600 and AST1030.
Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Link:
https://lore.kernel.org/r/20241127091543.1243114-9-jamin_lin@aspeedtech.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
---
tests/qtest/aspeed_smc-test.c | 74 +++++++++++++++++++++++++++++++++++
1 file changed, 74 insertions(+)
diff --git a/tests/qtest/aspeed_smc-test.c b/tests/qtest/aspeed_smc-test.c
index c5c38e23c5b2..59f3876cdc36 100644
--- a/tests/qtest/aspeed_smc-test.c
+++ b/tests/qtest/aspeed_smc-test.c
@@ -36,6 +36,7 @@
#define R_CE_CTRL 0x04
#define CRTL_EXTENDED0 0 /* 32 bit addressing for SPI */
#define R_CTRL0 0x10
+#define CTRL_IO_QUAD_IO BIT(31)
#define CTRL_CE_STOP_ACTIVE BIT(2)
#define CTRL_READMODE 0x0
#define CTRL_FREADMODE 0x1
@@ -62,6 +63,7 @@ enum {
ERASE_SECTOR = 0xd8,
};
+#define CTRL_IO_MODE_MASK (BIT(31) | BIT(30) | BIT(29) | BIT(28))
#define FLASH_PAGE_SIZE 256
typedef struct TestData {
@@ -171,6 +173,18 @@ static void spi_ctrl_stop_user(const TestData *data)
spi_writel(data, ctrl_reg, ctrl);
}
+static void spi_ctrl_set_io_mode(const TestData *data, uint32_t value)
+{
+ uint32_t ctrl_reg = R_CTRL0 + data->cs * 4;
+ uint32_t ctrl = spi_readl(data, ctrl_reg);
+ uint32_t mode;
+
+ mode = value & CTRL_IO_MODE_MASK;
+ ctrl &= ~CTRL_IO_MODE_MASK;
+ ctrl |= mode;
+ spi_writel(data, ctrl_reg, ctrl);
+}
+
static void flash_reset(const TestData *data)
{
spi_conf(data, 1 << (CONF_ENABLE_W0 + data->cs));
@@ -659,6 +673,60 @@ static void test_write_block_protect_bottom_bit(const void
*data)
flash_reset(test_data);
}
+static void test_write_page_qpi(const void *data)
+{
+ const TestData *test_data = (const TestData *)data;
+ uint32_t my_page_addr = test_data->page_addr;
+ uint32_t some_page_addr = my_page_addr + FLASH_PAGE_SIZE;
+ uint32_t page[FLASH_PAGE_SIZE / 4];
+ uint32_t page_pattern[] = {
+ 0xebd8c134, 0x5da196bc, 0xae15e729, 0x5085ccdf
+ };
+ int i;
+
+ spi_conf(test_data, 1 << (CONF_ENABLE_W0 + test_data->cs));
+
+ spi_ctrl_start_user(test_data);
+ flash_writeb(test_data, 0, EN_4BYTE_ADDR);
+ flash_writeb(test_data, 0, WREN);
+ flash_writeb(test_data, 0, PP);
+ flash_writel(test_data, 0, make_be32(my_page_addr));
+
+ /* Set QPI mode */
+ spi_ctrl_set_io_mode(test_data, CTRL_IO_QUAD_IO);
+
+ /* Fill the page pattern */
+ for (i = 0; i < ARRAY_SIZE(page_pattern); i++) {
+ flash_writel(test_data, 0, make_be32(page_pattern[i]));
+ }
+
+ /* Fill the page with its own addresses */
+ for (; i < FLASH_PAGE_SIZE / 4; i++) {
+ flash_writel(test_data, 0, make_be32(my_page_addr + i * 4));
+ }
+
+ /* Restore io mode */
+ spi_ctrl_set_io_mode(test_data, 0);
+ spi_ctrl_stop_user(test_data);
+
+ /* Check what was written */
+ read_page(test_data, my_page_addr, page);
+ for (i = 0; i < ARRAY_SIZE(page_pattern); i++) {
+ g_assert_cmphex(page[i], ==, page_pattern[i]);
+ }
+ for (; i < FLASH_PAGE_SIZE / 4; i++) {
+ g_assert_cmphex(page[i], ==, my_page_addr + i * 4);
+ }
+
+ /* Check some other page. It should be full of 0xff */
+ read_page(test_data, some_page_addr, page);
+ for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) {
+ g_assert_cmphex(page[i], ==, 0xffffffff);
+ }
+
+ flash_reset(test_data);
+}
+
static void test_palmetto_bmc(TestData *data)
{
int ret;
@@ -736,6 +804,8 @@ static void test_ast2500_evb(TestData *data)
data, test_write_page_mem);
qtest_add_data_func("/ast2500/smc/read_status_reg",
data, test_read_status_reg);
+ qtest_add_data_func("/ast2500/smc/write_page_qpi",
+ data, test_write_page_qpi);
}
static void test_ast2600_evb(TestData *data)
@@ -773,6 +843,8 @@ static void test_ast2600_evb(TestData *data)
data, test_write_page_mem);
qtest_add_data_func("/ast2600/smc/read_status_reg",
data, test_read_status_reg);
+ qtest_add_data_func("/ast2600/smc/write_page_qpi",
+ data, test_write_page_qpi);
}
static void test_ast1030_evb(TestData *data)
@@ -810,6 +882,8 @@ static void test_ast1030_evb(TestData *data)
data, test_write_page_mem);
qtest_add_data_func("/ast1030/smc/read_status_reg",
data, test_read_status_reg);
+ qtest_add_data_func("/ast1030/smc/write_page_qpi",
+ data, test_write_page_qpi);
}
int main(int argc, char **argv)
--
2.47.1
- [PULL 13/24] tests/functional: Introduce a specific test for rainier-bmc machine, (continued)
- [PULL 13/24] tests/functional: Introduce a specific test for rainier-bmc machine, Cédric Le Goater, 2024/12/11
- [PULL 21/24] test/qtest/aspeed_smc-test: Support to test AST1030, Cédric Le Goater, 2024/12/11
- [PULL 06/24] aspeed/soc: Support SDHCI for AST2700, Cédric Le Goater, 2024/12/11
- [PULL 15/24] test/qtest/aspeed_smc-test: Move testcases to test_palmetto_bmc function, Cédric Le Goater, 2024/12/11
- [PULL 19/24] test/qtest/aspeed_smc-test: Support to test AST2500, Cédric Le Goater, 2024/12/11
- [PULL 18/24] test/qtest/aspeed_smc-test: Introducing a "page_addr" data field, Cédric Le Goater, 2024/12/11
- [PULL 08/24] tests/functional: Introduce a specific test for ast1030 SoC, Cédric Le Goater, 2024/12/11
- [PULL 11/24] tests/functional: Introduce a specific test for ast2500 SoC, Cédric Le Goater, 2024/12/11
- [PULL 23/24] test/qtest: Introduce a new aspeed-smc-utils.c to place common testcases, Cédric Le Goater, 2024/12/11
- [PULL 20/24] test/qtest/aspeed_smc-test: Support to test AST2600, Cédric Le Goater, 2024/12/11
- [PULL 22/24] test/qtest/aspeed_smc-test: Support write page command with QPI mode,
Cédric Le Goater <=
- [PULL 24/24] test/qtest/ast2700-smc-test: Support to test AST2700, Cédric Le Goater, 2024/12/11
- Re: [PULL 00/24] aspeed queue, Peter Maydell, 2024/12/11