On Wed, Jul 8, 2026 at 7:17 PM Cédric Le Goater <[email protected]> wrote:
>
> Add read_page_mem_fast_read (CTRL_FREADMODE with dummy byte) and
> write_page_fast_read (user-mode FAST_READ) tests.
>
> Signed-off-by: Cedric Le Goater <[email protected]>
> ---
>  tests/qtest/aspeed-smc-utils.h |  5 ++++
>  tests/qtest/aspeed-smc-utils.c | 49 ++++++++++++++++++++++++++++++++++
>  tests/qtest/aspeed_smc-test.c  | 21 +++++++++++++++
>  tests/qtest/ast2700-smc-test.c |  4 +++
>  4 files changed, 79 insertions(+)
>
> diff --git a/tests/qtest/aspeed-smc-utils.h b/tests/qtest/aspeed-smc-utils.h
> index e2fd8ff1bd16..5a86514caf35 100644
> --- a/tests/qtest/aspeed-smc-utils.h
> +++ b/tests/qtest/aspeed-smc-utils.h
> @@ -44,6 +44,8 @@
>  #define   CTRL_FREADMODE       0x1
>  #define   CTRL_WRITEMODE       0x2
>  #define   CTRL_USERMODE        0x3
> +#define   CTRL_DUMMY_LOW_SHIFT   6
> +#define   CTRL_DUMMY_HIGH_SHIFT  14
>  #define SR_WEL BIT(1)
>
>  /*
> @@ -55,6 +57,7 @@ enum {
>      WRDI = 0x4,
>      BULK_ERASE = 0xc7,
>      READ = 0x03,
> +    FAST_READ = 0x0b,
>      PP = 0x02,
>      WRSR = 0x1,
>      WREN = 0x6,
> @@ -90,5 +93,7 @@ void aspeed_smc_test_status_reg_write_protection(const void 
> *data);
>  void aspeed_smc_test_write_block_protect(const void *data);
>  void aspeed_smc_test_write_block_protect_bottom_bit(const void *data);
>  void aspeed_smc_test_write_page_qpi(const void *data);
> +void aspeed_smc_test_read_page_mem_fast_read(const void *data);
> +void aspeed_smc_test_write_page_fast_read(const void *data);
>
>  #endif /* TESTS_ASPEED_SMC_UTILS_H */
> diff --git a/tests/qtest/aspeed-smc-utils.c b/tests/qtest/aspeed-smc-utils.c
> index ed125741eb36..9883ade0815c 100644
> --- a/tests/qtest/aspeed-smc-utils.c
> +++ b/tests/qtest/aspeed-smc-utils.c
> @@ -697,3 +697,52 @@ void aspeed_smc_test_write_page_qpi(const void *data)
>      flash_reset(test_data);
>  }
>
> +static void read_page_mem_fast_read(const AspeedSMCTestData *data,
> +                                uint32_t addr, uint32_t *page)
> +{
> +    uint32_t ctrl_reg = R_CTRL0 + data->cs * 4;
> +    uint32_t ctrl = spi_readl(data, ctrl_reg);
> +    int i;
> +
> +    /* Set FREADMODE with FAST_READ command and 1 dummy byte */
> +    ctrl &= ~(CTRL_USERMODE | (0xff << 16) |
> +              (0x3 << CTRL_DUMMY_LOW_SHIFT) |
> +              (0x1 << CTRL_DUMMY_HIGH_SHIFT) |
> +              CTRL_IO_MODE_MASK);
> +    ctrl |= CTRL_FREADMODE | (FAST_READ << 16) |
> +            (1 << CTRL_DUMMY_LOW_SHIFT);
> +    spi_writel(data, ctrl_reg, ctrl);

Could just call spi_ctrl_set_fast_read()?

> +
> +    for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) {
> +        page[i] = make_be32(flash_readl(data, addr + i * 4));
> +    }
> +}
> +
> +void aspeed_smc_test_read_page_mem_fast_read(const void *data)
> +{
> +    test_read_page_mem(data, read_page_mem_fast_read);
> +}
> +
> +static void read_page_fast_read(const AspeedSMCTestData *data,
> +                                uint32_t addr, uint32_t *page)
> +{
> +    int i;
> +
> +    spi_ctrl_start_user(data);
> +
> +    flash_writeb(data, 0, EN_4BYTE_ADDR);
> +    flash_writeb(data, 0, FAST_READ);
> +    flash_writel(data, 0, make_be32(addr));
> +    /* 1 dummy byte for standard SPI fast-read */
> +    flash_writeb(data, 0, 0x00);
> +
> +    for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) {
> +        page[i] = make_be32(flash_readl(data, 0));
> +    }
> +    spi_ctrl_stop_user(data);
> +}
> +
> +void aspeed_smc_test_write_page_fast_read(const void *data)
> +{
> +    test_write_page(data, read_page_fast_read);
> +}
> diff --git a/tests/qtest/aspeed_smc-test.c b/tests/qtest/aspeed_smc-test.c
> index 39af1df0ed75..bbda15ad17ea 100644
> --- a/tests/qtest/aspeed_smc-test.c
> +++ b/tests/qtest/aspeed_smc-test.c
> @@ -68,6 +68,15 @@ static void test_palmetto_bmc(AspeedSMCTestData *data)
>                          data, aspeed_smc_test_read_status_reg);
>      qtest_add_data_func("/ast2400/smc/status_reg_write_protection",
>                          data, aspeed_smc_test_status_reg_write_protection);
> +    qtest_add_data_func("/ast2400/smc/read_page_mem_fast_read",
> +                        data, aspeed_smc_test_read_page_mem_fast_read);
> +    qtest_add_data_func("/ast2400/smc/write_page_fast_read",
> +                        data, aspeed_smc_test_write_page_fast_read);
> +    /*
> +     * Block protect tests must be run last because the block protect
> +     * state is not cleared by reset_memory() and silently prevents
> +     * subsequent flash writes.
> +     */
>      qtest_add_data_func("/ast2400/smc/write_block_protect",
>                          data, aspeed_smc_test_write_block_protect);
>      qtest_add_data_func("/ast2400/smc/write_block_protect_bottom_bit",
> @@ -115,6 +124,10 @@ static void test_ast2500_evb(AspeedSMCTestData *data)
>                          data, aspeed_smc_test_read_status_reg);
>      qtest_add_data_func("/ast2500/smc/write_page_qpi",
>                          data, aspeed_smc_test_write_page_qpi);
> +    qtest_add_data_func("/ast2500/smc/read_page_mem_fast_read",
> +                        data, aspeed_smc_test_read_page_mem_fast_read);
> +    qtest_add_data_func("/ast2500/smc/write_page_fast_read",
> +                        data, aspeed_smc_test_write_page_fast_read);
>  }
>
>  static void test_ast2600_evb(AspeedSMCTestData *data)
> @@ -158,6 +171,10 @@ static void test_ast2600_evb(AspeedSMCTestData *data)
>                          data, aspeed_smc_test_read_status_reg);
>      qtest_add_data_func("/ast2600/smc/write_page_qpi",
>                          data, aspeed_smc_test_write_page_qpi);
> +    qtest_add_data_func("/ast2600/smc/read_page_mem_fast_read",
> +                        data, aspeed_smc_test_read_page_mem_fast_read);
> +    qtest_add_data_func("/ast2600/smc/write_page_fast_read",
> +                        data, aspeed_smc_test_write_page_fast_read);
>  }
>
>  static void test_ast1030_evb(AspeedSMCTestData *data)
> @@ -201,6 +218,10 @@ static void test_ast1030_evb(AspeedSMCTestData *data)
>                          data, aspeed_smc_test_read_status_reg);
>      qtest_add_data_func("/ast1030/smc/write_page_qpi",
>                          data, aspeed_smc_test_write_page_qpi);
> +    qtest_add_data_func("/ast1030/smc/read_page_mem_fast_read",
> +                        data, aspeed_smc_test_read_page_mem_fast_read);
> +    qtest_add_data_func("/ast1030/smc/write_page_fast_read",
> +                        data, aspeed_smc_test_write_page_fast_read);
>  }
>
>  int main(int argc, char **argv)
> diff --git a/tests/qtest/ast2700-smc-test.c b/tests/qtest/ast2700-smc-test.c
> index 33fc47230ee5..9ad04b574c0d 100644
> --- a/tests/qtest/ast2700-smc-test.c
> +++ b/tests/qtest/ast2700-smc-test.c
> @@ -52,6 +52,10 @@ static void test_ast2700_evb(AspeedSMCTestData *data)
>                          data, aspeed_smc_test_read_status_reg);
>      qtest_add_data_func("/ast2700/smc/write_page_qpi",
>                          data, aspeed_smc_test_write_page_qpi);
> +    qtest_add_data_func("/ast2700/smc/read_page_mem_fast_read",
> +                        data, aspeed_smc_test_read_page_mem_fast_read);
> +    qtest_add_data_func("/ast2700/smc/write_page_fast_read",
> +                        data, aspeed_smc_test_write_page_fast_read);
>  }
>
>  int main(int argc, char **argv)

Regards,
Bin

Reply via email to