1 | The following changes since commit 0529245488865038344d64fff7ee05864d3d17f6: | 1 | The following changes since commit ae35f033b874c627d81d51070187fbf55f0bf1a7: |
---|---|---|---|
2 | 2 | ||
3 | Merge tag 'pull-target-arm-20221020' of https://git.linaro.org/people/pmaydell/qemu-arm into staging (2022-10-20 14:36:12 -0400) | 3 | Update version for v9.2.0 release (2024-12-10 16:20:54 +0000) |
4 | 4 | ||
5 | are available in the Git repository at: | 5 | are available in the Git repository at: |
6 | 6 | ||
7 | https://github.com/legoater/qemu/ tags/pull-aspeed-20221025 | 7 | https://github.com/legoater/qemu/ tags/pull-aspeed-20241211 |
8 | 8 | ||
9 | for you to fetch changes up to 703229132bb05327044368fc6d19f6acf7dde848: | 9 | for you to fetch changes up to 124f4dc0d832c1bf3a4513c05a2b93bac0a5fac0: |
10 | 10 | ||
11 | arm/aspeed: Replace mx25l25635e chip model (2022-10-24 11:20:16 +0200) | 11 | test/qtest/ast2700-smc-test: Support to test AST2700 (2024-12-11 07:25:53 +0100) |
12 | 12 | ||
13 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
14 | aspeed queue : | 14 | aspeed queue: |
15 | 15 | ||
16 | * Performance improvement with Object class caching | 16 | * Removed tacoma-bmc machine |
17 | * Serial Flash Discovery Parameters support for m25p80 device | 17 | * Added support for SDHCI on AST2700 SoC |
18 | * Various small adjustments on intructions and models | 18 | * Improved functional tests |
19 | * Extended SMC qtest to all Aspeed SoCs | ||
19 | 20 | ||
20 | ---------------------------------------------------------------- | 21 | ---------------------------------------------------------------- |
21 | Alex Bennée (1): | 22 | Cédric Le Goater (8): |
22 | ssi: cache SSIPeripheralClass to avoid GET_CLASS() | 23 | arm: Remove tacoma-bmc machine |
24 | tests/functional: Introduce a specific test for ast1030 SoC | ||
25 | tests/functional: Introduce a specific test for palmetto-bmc machine | ||
26 | tests/functional: Introduce a specific test for romulus-bmc machine | ||
27 | tests/functional: Introduce a specific test for ast2500 SoC | ||
28 | tests/functional: Introduce a specific test for ast2600 SoC | ||
29 | tests/functional: Introduce a specific test for rainier-bmc machine | ||
30 | tests/functional: Move debian boot test from avocado | ||
23 | 31 | ||
24 | Cédric Le Goater (12): | 32 | Jamin Lin (16): |
25 | tests/avocado/machine_aspeed.py: Fix typos on buildroot | 33 | hw/sd/aspeed_sdhci: Fix coding style |
26 | aspeed/smc: Cache AspeedSMCClass | 34 | hw/arm/aspeed: Fix coding style |
27 | ast2600: Drop NEON from the CPU features | 35 | hw:sdhci: Introduce a new "capareg" class member to set the different Capability Registers |
28 | m25p80: Add basic support for the SFDP command | 36 | hw/sd/aspeed_sdhci: Add AST2700 Support |
29 | m25p80: Add the n25q256a SFDP table | 37 | aspeed/soc: Support SDHCI for AST2700 |
30 | m25p80: Add erase size for mx25l25635e | 38 | aspeed/soc: Support eMMC for AST2700 |
31 | m25p80: Add the mx25l25635e SFPD table | 39 | test/qtest/aspeed_smc-test: Move testcases to test_palmetto_bmc function |
32 | m25p80: Add the mx25l25635f SFPD table | 40 | test/qtest/aspeed_smc-test: Introduce a new TestData to test different BMC SOCs |
33 | m25p80: Add the mx66l1g45g SFDP table | 41 | test/qtest/aspeed_smc-test: Support to test all CE pins |
34 | m25p80: Add the w25q256 SFPD table | 42 | test/qtest/aspeed_smc-test: Introducing a "page_addr" data field |
35 | m25p80: Add the w25q512jv SFPD table | 43 | test/qtest/aspeed_smc-test: Support to test AST2500 |
36 | arm/aspeed: Replace mx25l25635e chip model | 44 | test/qtest/aspeed_smc-test: Support to test AST2600 |
45 | test/qtest/aspeed_smc-test: Support to test AST1030 | ||
46 | test/qtest/aspeed_smc-test: Support write page command with QPI mode | ||
47 | test/qtest: Introduce a new aspeed-smc-utils.c to place common testcases | ||
48 | test/qtest/ast2700-smc-test: Support to test AST2700 | ||
37 | 49 | ||
38 | Patrick Williams (2): | 50 | docs/about/deprecated.rst | 8 - |
39 | hw/arm/aspeed: increase Bletchley memory size | 51 | docs/about/removed-features.rst | 10 + |
40 | m25p80: Add the w25q01jvq SFPD table | 52 | docs/system/arm/aspeed.rst | 1 - |
53 | include/hw/sd/aspeed_sdhci.h | 13 +- | ||
54 | tests/qtest/aspeed-smc-utils.h | 95 ++++ | ||
55 | hw/arm/aspeed.c | 28 - | ||
56 | hw/arm/aspeed_ast2400.c | 3 +- | ||
57 | hw/arm/aspeed_ast2600.c | 10 +- | ||
58 | hw/arm/aspeed_ast27x0.c | 35 ++ | ||
59 | hw/sd/aspeed_sdhci.c | 67 ++- | ||
60 | tests/qtest/aspeed-smc-utils.c | 686 ++++++++++++++++++++++++ | ||
61 | tests/qtest/aspeed_smc-test.c | 775 ++++++--------------------- | ||
62 | tests/qtest/ast2700-smc-test.c | 71 +++ | ||
63 | tests/avocado/boot_linux_console.py | 26 - | ||
64 | tests/functional/aspeed.py | 56 ++ | ||
65 | tests/functional/meson.build | 13 +- | ||
66 | tests/functional/test_arm_aspeed.py | 351 ------------ | ||
67 | tests/functional/test_arm_aspeed_ast1030.py | 81 +++ | ||
68 | tests/functional/test_arm_aspeed_ast2500.py | 59 ++ | ||
69 | tests/functional/test_arm_aspeed_ast2600.py | 143 +++++ | ||
70 | tests/functional/test_arm_aspeed_palmetto.py | 24 + | ||
71 | tests/functional/test_arm_aspeed_rainier.py | 64 +++ | ||
72 | tests/functional/test_arm_aspeed_romulus.py | 24 + | ||
73 | tests/qtest/meson.build | 5 +- | ||
74 | 24 files changed, 1623 insertions(+), 1025 deletions(-) | ||
75 | create mode 100644 tests/qtest/aspeed-smc-utils.h | ||
76 | create mode 100644 tests/qtest/aspeed-smc-utils.c | ||
77 | create mode 100644 tests/qtest/ast2700-smc-test.c | ||
78 | create mode 100644 tests/functional/aspeed.py | ||
79 | delete mode 100755 tests/functional/test_arm_aspeed.py | ||
80 | create mode 100644 tests/functional/test_arm_aspeed_ast1030.py | ||
81 | create mode 100644 tests/functional/test_arm_aspeed_ast2500.py | ||
82 | create mode 100644 tests/functional/test_arm_aspeed_ast2600.py | ||
83 | create mode 100644 tests/functional/test_arm_aspeed_palmetto.py | ||
84 | create mode 100644 tests/functional/test_arm_aspeed_rainier.py | ||
85 | create mode 100644 tests/functional/test_arm_aspeed_romulus.py | ||
41 | 86 | ||
42 | Peter Delevoryas (1): | ||
43 | hw/i2c/aspeed: Fix old reg slave receive | ||
44 | 87 | ||
45 | hw/block/m25p80_sfdp.h | 29 ++++ | ||
46 | include/hw/i2c/aspeed_i2c.h | 1 + | ||
47 | include/hw/ssi/aspeed_smc.h | 2 + | ||
48 | include/hw/ssi/ssi.h | 3 + | ||
49 | hw/arm/aspeed.c | 15 +- | ||
50 | hw/arm/aspeed_ast2600.c | 2 + | ||
51 | hw/block/m25p80.c | 52 ++++++- | ||
52 | hw/block/m25p80_sfdp.c | 332 ++++++++++++++++++++++++++++++++++++++++ | ||
53 | hw/i2c/aspeed_i2c.c | 8 +- | ||
54 | hw/ssi/aspeed_smc.c | 9 +- | ||
55 | hw/ssi/ssi.c | 18 +-- | ||
56 | MAINTAINERS | 2 +- | ||
57 | hw/block/meson.build | 1 + | ||
58 | hw/block/trace-events | 1 + | ||
59 | tests/avocado/machine_aspeed.py | 16 +- | ||
60 | 15 files changed, 452 insertions(+), 39 deletions(-) | ||
61 | create mode 100644 hw/block/m25p80_sfdp.h | ||
62 | create mode 100644 hw/block/m25p80_sfdp.c | ||
63 | diff view generated by jsdifflib |
1 | From: Patrick Williams <patrick@stwcx.xyz> | 1 | Removal was scheduled for 10.0. Use the rainier-bmc machine or the |
---|---|---|---|
2 | ast2600-evb as a replacement. | ||
2 | 3 | ||
3 | For the PVT-class hardware we have increased the memory size of | 4 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
4 | this device to 2 GiB. Adjust the device model accordingly. | 5 | Link: https://lore.kernel.org/r/20241119071352.515790-1-clg@redhat.com |
6 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | ||
7 | --- | ||
8 | docs/about/deprecated.rst | 8 -------- | ||
9 | docs/about/removed-features.rst | 10 ++++++++++ | ||
10 | docs/system/arm/aspeed.rst | 1 - | ||
11 | hw/arm/aspeed.c | 28 ---------------------------- | ||
12 | 4 files changed, 10 insertions(+), 37 deletions(-) | ||
5 | 13 | ||
6 | Signed-off-by: Patrick Williams <patrick@stwcx.xyz> | 14 | diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst |
7 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | 15 | index XXXXXXX..XXXXXXX 100644 |
8 | Message-Id: <20221007110529.3657749-1-patrick@stwcx.xyz> | 16 | --- a/docs/about/deprecated.rst |
9 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 17 | +++ b/docs/about/deprecated.rst |
10 | --- | 18 | @@ -XXX,XX +XXX,XX @@ images are not available, OpenWRT dropped support in 2019, U-Boot in |
11 | hw/arm/aspeed.c | 9 ++++++++- | 19 | 2017, Linux also is dropping support in 2024. It is time to let go of |
12 | 1 file changed, 8 insertions(+), 1 deletion(-) | 20 | this ancient hardware and focus on newer CPUs and platforms. |
13 | 21 | ||
22 | -Arm ``tacoma-bmc`` machine (since 9.1) | ||
23 | -'''''''''''''''''''''''''''''''''''''''' | ||
24 | - | ||
25 | -The ``tacoma-bmc`` machine was a board including an AST2600 SoC based | ||
26 | -BMC and a witherspoon like OpenPOWER system. It was used for bring up | ||
27 | -of the AST2600 SoC in labs. It can be easily replaced by the | ||
28 | -``rainier-bmc`` machine which is a real product. | ||
29 | - | ||
30 | Big-Endian variants of MicroBlaze ``petalogix-ml605`` and ``xlnx-zynqmp-pmu`` machines (since 9.2) | ||
31 | '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' | ||
32 | |||
33 | diff --git a/docs/about/removed-features.rst b/docs/about/removed-features.rst | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/docs/about/removed-features.rst | ||
36 | +++ b/docs/about/removed-features.rst | ||
37 | @@ -XXX,XX +XXX,XX @@ Aspeed ``swift-bmc`` machine (removed in 7.0) | ||
38 | This machine was removed because it was unused. Alternative AST2500 based | ||
39 | OpenPOWER machines are ``witherspoon-bmc`` and ``romulus-bmc``. | ||
40 | |||
41 | +Aspeed ``tacoma-bmc`` machine (removed in 10.0) | ||
42 | +''''''''''''''''''''''''''''''''''''''''''''''' | ||
43 | + | ||
44 | +The ``tacoma-bmc`` machine was removed because it didn't bring much | ||
45 | +compared to the ``rainier-bmc`` machine. Also, the ``tacoma-bmc`` was | ||
46 | +a board used for bring up of the AST2600 SoC that never left the | ||
47 | +labs. It can be easily replaced by the ``rainier-bmc`` machine, which | ||
48 | +was the actual final product, or by the ``ast2600-evb`` with some | ||
49 | +tweaks. | ||
50 | + | ||
51 | ppc ``taihu`` machine (removed in 7.2) | ||
52 | ''''''''''''''''''''''''''''''''''''''''''''' | ||
53 | |||
54 | diff --git a/docs/system/arm/aspeed.rst b/docs/system/arm/aspeed.rst | ||
55 | index XXXXXXX..XXXXXXX 100644 | ||
56 | --- a/docs/system/arm/aspeed.rst | ||
57 | +++ b/docs/system/arm/aspeed.rst | ||
58 | @@ -XXX,XX +XXX,XX @@ AST2500 SoC based machines : | ||
59 | AST2600 SoC based machines : | ||
60 | |||
61 | - ``ast2600-evb`` Aspeed AST2600 Evaluation board (Cortex-A7) | ||
62 | -- ``tacoma-bmc`` OpenPOWER Witherspoon POWER9 AST2600 BMC | ||
63 | - ``rainier-bmc`` IBM Rainier POWER10 BMC | ||
64 | - ``fuji-bmc`` Facebook Fuji BMC | ||
65 | - ``bletchley-bmc`` Facebook Bletchley BMC | ||
14 | diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c | 66 | diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c |
15 | index XXXXXXX..XXXXXXX 100644 | 67 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/arm/aspeed.c | 68 | --- a/hw/arm/aspeed.c |
17 | +++ b/hw/arm/aspeed.c | 69 | +++ b/hw/arm/aspeed.c |
18 | @@ -XXX,XX +XXX,XX @@ static void aspeed_machine_fuji_class_init(ObjectClass *oc, void *data) | 70 | @@ -XXX,XX +XXX,XX @@ struct AspeedMachineState { |
19 | aspeed_soc_num_cpus(amc->soc_name); | 71 | #define AST2700_EVB_HW_STRAP2 0x00000003 |
72 | #endif | ||
73 | |||
74 | -/* Tacoma hardware value */ | ||
75 | -#define TACOMA_BMC_HW_STRAP1 0x00000000 | ||
76 | -#define TACOMA_BMC_HW_STRAP2 0x00000040 | ||
77 | - | ||
78 | /* Rainier hardware value: (QEMU prototype) */ | ||
79 | #define RAINIER_BMC_HW_STRAP1 (0x00422016 | SCU_AST2600_HW_STRAP_BOOT_SRC_EMMC) | ||
80 | #define RAINIER_BMC_HW_STRAP2 0x80000848 | ||
81 | @@ -XXX,XX +XXX,XX @@ static void aspeed_machine_ast2600_evb_class_init(ObjectClass *oc, void *data) | ||
82 | aspeed_machine_ast2600_class_emmc_init(oc); | ||
20 | }; | 83 | }; |
21 | 84 | ||
22 | +/* On 32-bit hosts, lower RAM to 1G because of the 2047 MB limit */ | 85 | -static void aspeed_machine_tacoma_class_init(ObjectClass *oc, void *data) |
23 | +#if HOST_LONG_BITS == 32 | 86 | -{ |
24 | +#define BLETCHLEY_BMC_RAM_SIZE (1 * GiB) | 87 | - MachineClass *mc = MACHINE_CLASS(oc); |
25 | +#else | 88 | - AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc); |
26 | +#define BLETCHLEY_BMC_RAM_SIZE (2 * GiB) | 89 | - |
27 | +#endif | 90 | - mc->desc = "OpenPOWER Tacoma BMC (Cortex-A7)"; |
28 | + | 91 | - amc->soc_name = "ast2600-a3"; |
29 | static void aspeed_machine_bletchley_class_init(ObjectClass *oc, void *data) | 92 | - amc->hw_strap1 = TACOMA_BMC_HW_STRAP1; |
93 | - amc->hw_strap2 = TACOMA_BMC_HW_STRAP2; | ||
94 | - amc->fmc_model = "mx66l1g45g"; | ||
95 | - amc->spi_model = "mx66l1g45g"; | ||
96 | - amc->num_cs = 2; | ||
97 | - amc->macs_mask = ASPEED_MAC2_ON; | ||
98 | - amc->i2c_init = witherspoon_bmc_i2c_init; /* Same board layout */ | ||
99 | - mc->default_ram_size = 1 * GiB; | ||
100 | - aspeed_machine_class_init_cpus_defaults(mc); | ||
101 | - | ||
102 | - mc->deprecation_reason = "Please use the similar 'rainier-bmc' machine"; | ||
103 | -}; | ||
104 | - | ||
105 | static void aspeed_machine_g220a_class_init(ObjectClass *oc, void *data) | ||
30 | { | 106 | { |
31 | MachineClass *mc = MACHINE_CLASS(oc); | 107 | MachineClass *mc = MACHINE_CLASS(oc); |
32 | @@ -XXX,XX +XXX,XX @@ static void aspeed_machine_bletchley_class_init(ObjectClass *oc, void *data) | 108 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo aspeed_machine_types[] = { |
33 | amc->num_cs = 2; | 109 | .name = MACHINE_TYPE_NAME("yosemitev2-bmc"), |
34 | amc->macs_mask = ASPEED_MAC2_ON; | 110 | .parent = TYPE_ASPEED_MACHINE, |
35 | amc->i2c_init = bletchley_bmc_i2c_init; | 111 | .class_init = aspeed_machine_yosemitev2_class_init, |
36 | - mc->default_ram_size = 512 * MiB; | 112 | - }, { |
37 | + mc->default_ram_size = BLETCHLEY_BMC_RAM_SIZE; | 113 | - .name = MACHINE_TYPE_NAME("tacoma-bmc"), |
38 | mc->default_cpus = mc->min_cpus = mc->max_cpus = | 114 | - .parent = TYPE_ASPEED_MACHINE, |
39 | aspeed_soc_num_cpus(amc->soc_name); | 115 | - .class_init = aspeed_machine_tacoma_class_init, |
40 | } | 116 | }, { |
117 | .name = MACHINE_TYPE_NAME("tiogapass-bmc"), | ||
118 | .parent = TYPE_ASPEED_MACHINE, | ||
41 | -- | 119 | -- |
42 | 2.37.3 | 120 | 2.47.1 |
43 | 121 | ||
44 | 122 | diff view generated by jsdifflib |
1 | Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com> | 1 | From: Jamin Lin <jamin_lin@aspeedtech.com> |
---|---|---|---|
2 | Message-Id: <20221013161241.2805140-4-clg@kaod.org> | 2 | |
3 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 3 | Fix coding style issues from checkpatch.pl. |
4 | |||
5 | Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com> | ||
6 | Reviewed-by: Cédric Le Goater <clg@redhat.com> | ||
7 | Link: https://lore.kernel.org/r/20241204084453.610660-2-jamin_lin@aspeedtech.com | ||
8 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | ||
4 | --- | 9 | --- |
5 | hw/block/m25p80.c | 3 ++- | 10 | hw/sd/aspeed_sdhci.c | 6 ++++-- |
6 | 1 file changed, 2 insertions(+), 1 deletion(-) | 11 | 1 file changed, 4 insertions(+), 2 deletions(-) |
7 | 12 | ||
8 | diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c | 13 | diff --git a/hw/sd/aspeed_sdhci.c b/hw/sd/aspeed_sdhci.c |
9 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
10 | --- a/hw/block/m25p80.c | 15 | --- a/hw/sd/aspeed_sdhci.c |
11 | +++ b/hw/block/m25p80.c | 16 | +++ b/hw/sd/aspeed_sdhci.c |
12 | @@ -XXX,XX +XXX,XX @@ static const FlashPartInfo known_devices[] = { | 17 | @@ -XXX,XX +XXX,XX @@ static void aspeed_sdhci_write(void *opaque, hwaddr addr, uint64_t val, |
13 | { INFO("mx25l6405d", 0xc22017, 0, 64 << 10, 128, 0) }, | 18 | sdhci->regs[TO_REG(addr)] = (uint32_t)val & ~ASPEED_SDHCI_INFO_RESET; |
14 | { INFO("mx25l12805d", 0xc22018, 0, 64 << 10, 256, 0) }, | 19 | break; |
15 | { INFO("mx25l12855e", 0xc22618, 0, 64 << 10, 256, 0) }, | 20 | case ASPEED_SDHCI_SDIO_140: |
16 | - { INFO6("mx25l25635e", 0xc22019, 0xc22019, 64 << 10, 512, 0) }, | 21 | - sdhci->slots[0].capareg = deposit64(sdhci->slots[0].capareg, 0, 32, val); |
17 | + { INFO6("mx25l25635e", 0xc22019, 0xc22019, 64 << 10, 512, | 22 | + sdhci->slots[0].capareg = deposit64(sdhci->slots[0].capareg, |
18 | + ER_4K | ER_32K) }, | 23 | + 0, 32, val); |
19 | { INFO("mx25l25655e", 0xc22619, 0, 64 << 10, 512, 0) }, | 24 | break; |
20 | { INFO("mx66l51235f", 0xc2201a, 0, 64 << 10, 1024, ER_4K | ER_32K) }, | 25 | case ASPEED_SDHCI_SDIO_144: |
21 | { INFO("mx66u51235f", 0xc2253a, 0, 64 << 10, 1024, ER_4K | ER_32K) }, | 26 | - sdhci->slots[0].capareg = deposit64(sdhci->slots[0].capareg, 32, 32, val); |
27 | + sdhci->slots[0].capareg = deposit64(sdhci->slots[0].capareg, | ||
28 | + 32, 32, val); | ||
29 | break; | ||
30 | case ASPEED_SDHCI_SDIO_148: | ||
31 | sdhci->slots[0].maxcurr = deposit64(sdhci->slots[0].maxcurr, | ||
22 | -- | 32 | -- |
23 | 2.37.3 | 33 | 2.47.1 |
24 | 34 | ||
25 | 35 | diff view generated by jsdifflib |
1 | Currently, the CPU features exposed to the AST2600 QEMU machines are : | 1 | From: Jamin Lin <jamin_lin@aspeedtech.com> |
---|---|---|---|
2 | 2 | ||
3 | half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt | 3 | Fix coding style issues from checkpatch.pl. |
4 | vfpd32 lpae evtstrm | ||
5 | 4 | ||
6 | But, the features of the Cortex A7 CPU on the Aspeed AST2600 A3 SoC | 5 | Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com> |
7 | are : | 6 | Reviewed-by: Cédric Le Goater <clg@redhat.com> |
8 | 7 | Link: https://lore.kernel.org/r/20241204084453.610660-3-jamin_lin@aspeedtech.com | |
9 | half thumb fastmult vfp edsp vfpv3 vfpv3d16 tls vfpv4 idiva idivt | 8 | Signed-off-by: Cédric Le Goater <clg@redhat.com> |
10 | lpae evtstrm | ||
11 | |||
12 | Drop NEON support in the Aspeed AST2600 SoC. | ||
13 | |||
14 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
15 | Message-Id: <20220928164719.655586-3-clg@kaod.org> | ||
16 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
17 | --- | 9 | --- |
18 | hw/arm/aspeed_ast2600.c | 2 ++ | 10 | hw/arm/aspeed_ast2600.c | 3 ++- |
19 | 1 file changed, 2 insertions(+) | 11 | 1 file changed, 2 insertions(+), 1 deletion(-) |
20 | 12 | ||
21 | diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c | 13 | diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c |
22 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/hw/arm/aspeed_ast2600.c | 15 | --- a/hw/arm/aspeed_ast2600.c |
24 | +++ b/hw/arm/aspeed_ast2600.c | 16 | +++ b/hw/arm/aspeed_ast2600.c |
25 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) | 17 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) |
26 | 18 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->gpio), errp)) { | |
27 | object_property_set_int(OBJECT(&s->cpu[i]), "cntfrq", 1125000000, | 19 | return; |
28 | &error_abort); | 20 | } |
29 | + object_property_set_bool(OBJECT(&s->cpu[i]), "neon", false, | 21 | - aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->gpio), 0, sc->memmap[ASPEED_DEV_GPIO]); |
30 | + &error_abort); | 22 | + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->gpio), 0, |
31 | object_property_set_link(OBJECT(&s->cpu[i]), "memory", | 23 | + sc->memmap[ASPEED_DEV_GPIO]); |
32 | OBJECT(s->memory), &error_abort); | 24 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpio), 0, |
25 | aspeed_soc_get_irq(s, ASPEED_DEV_GPIO)); | ||
33 | 26 | ||
34 | -- | 27 | -- |
35 | 2.37.3 | 28 | 2.47.1 |
36 | 29 | ||
37 | 30 | diff view generated by jsdifflib |
1 | Store a reference on the AspeedSMC class under the flash object and | 1 | From: Jamin Lin <jamin_lin@aspeedtech.com> |
---|---|---|---|
2 | use it when accessing the flash contents. Avoiding the class cast | ||
3 | checkers in these hot paths improves performance by 10% when running | ||
4 | the aspeed avocado tests. | ||
5 | 2 | ||
6 | Message-Id: <20220923084803.498337-7-clg@kaod.org> | 3 | Currently, it set the hardcode value of capability registers to all ASPEED SOCs |
7 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 4 | However, the value of capability registers should be different for all ASPEED |
5 | SOCs. For example: the bit 28 of the Capability Register 1 should be 1 for | ||
6 | 64-bits System Bus support for AST2700. | ||
7 | |||
8 | Introduce a new "capareg" class member whose data type is uint_64 to set the | ||
9 | different Capability Registers to all ASPEED SOCs. | ||
10 | |||
11 | The value of Capability Register is "0x0000000001e80080" for AST2400 and | ||
12 | AST2500. The value of Capability Register is "0x0000000701f80080" for AST2600. | ||
13 | |||
14 | Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com> | ||
15 | Reviewed-by: Cédric Le Goater <clg@redhat.com> | ||
16 | Link: https://lore.kernel.org/r/20241204084453.610660-4-jamin_lin@aspeedtech.com | ||
17 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | ||
8 | --- | 18 | --- |
9 | include/hw/ssi/aspeed_smc.h | 2 ++ | 19 | include/hw/sd/aspeed_sdhci.h | 12 +++++++-- |
10 | hw/ssi/aspeed_smc.c | 9 ++++----- | 20 | hw/arm/aspeed_ast2400.c | 3 ++- |
11 | 2 files changed, 6 insertions(+), 5 deletions(-) | 21 | hw/arm/aspeed_ast2600.c | 7 +++--- |
22 | hw/sd/aspeed_sdhci.c | 47 +++++++++++++++++++++++++++++++++++- | ||
23 | 4 files changed, 61 insertions(+), 8 deletions(-) | ||
12 | 24 | ||
13 | diff --git a/include/hw/ssi/aspeed_smc.h b/include/hw/ssi/aspeed_smc.h | 25 | diff --git a/include/hw/sd/aspeed_sdhci.h b/include/hw/sd/aspeed_sdhci.h |
14 | index XXXXXXX..XXXXXXX 100644 | 26 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/include/hw/ssi/aspeed_smc.h | 27 | --- a/include/hw/sd/aspeed_sdhci.h |
16 | +++ b/include/hw/ssi/aspeed_smc.h | 28 | +++ b/include/hw/sd/aspeed_sdhci.h |
17 | @@ -XXX,XX +XXX,XX @@ | 29 | @@ -XXX,XX +XXX,XX @@ |
18 | #include "qom/object.h" | 30 | #include "qom/object.h" |
19 | 31 | ||
20 | struct AspeedSMCState; | 32 | #define TYPE_ASPEED_SDHCI "aspeed.sdhci" |
21 | +struct AspeedSMCClass; | 33 | -OBJECT_DECLARE_SIMPLE_TYPE(AspeedSDHCIState, ASPEED_SDHCI) |
22 | 34 | +#define TYPE_ASPEED_2400_SDHCI TYPE_ASPEED_SDHCI "-ast2400" | |
23 | #define TYPE_ASPEED_SMC_FLASH "aspeed.smc.flash" | 35 | +#define TYPE_ASPEED_2500_SDHCI TYPE_ASPEED_SDHCI "-ast2500" |
24 | OBJECT_DECLARE_SIMPLE_TYPE(AspeedSMCFlash, ASPEED_SMC_FLASH) | 36 | +#define TYPE_ASPEED_2600_SDHCI TYPE_ASPEED_SDHCI "-ast2600" |
25 | @@ -XXX,XX +XXX,XX @@ struct AspeedSMCFlash { | 37 | +OBJECT_DECLARE_TYPE(AspeedSDHCIState, AspeedSDHCIClass, ASPEED_SDHCI) |
26 | SysBusDevice parent_obj; | 38 | |
27 | 39 | -#define ASPEED_SDHCI_CAPABILITIES 0x01E80080 | |
28 | struct AspeedSMCState *controller; | 40 | #define ASPEED_SDHCI_NUM_SLOTS 2 |
29 | + struct AspeedSMCClass *asc; | 41 | #define ASPEED_SDHCI_NUM_REGS (ASPEED_SDHCI_REG_SIZE / sizeof(uint32_t)) |
30 | uint8_t cs; | 42 | #define ASPEED_SDHCI_REG_SIZE 0x100 |
31 | 43 | @@ -XXX,XX +XXX,XX @@ struct AspeedSDHCIState { | |
32 | MemoryRegion mmio; | 44 | uint32_t regs[ASPEED_SDHCI_NUM_REGS]; |
33 | diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c | 45 | }; |
46 | |||
47 | +struct AspeedSDHCIClass { | ||
48 | + SysBusDeviceClass parent_class; | ||
49 | + | ||
50 | + uint64_t capareg; | ||
51 | +}; | ||
52 | + | ||
53 | #endif /* ASPEED_SDHCI_H */ | ||
54 | diff --git a/hw/arm/aspeed_ast2400.c b/hw/arm/aspeed_ast2400.c | ||
34 | index XXXXXXX..XXXXXXX 100644 | 55 | index XXXXXXX..XXXXXXX 100644 |
35 | --- a/hw/ssi/aspeed_smc.c | 56 | --- a/hw/arm/aspeed_ast2400.c |
36 | +++ b/hw/ssi/aspeed_smc.c | 57 | +++ b/hw/arm/aspeed_ast2400.c |
37 | @@ -XXX,XX +XXX,XX @@ static inline int aspeed_smc_flash_cmd(const AspeedSMCFlash *fl) | 58 | @@ -XXX,XX +XXX,XX @@ static void aspeed_ast2400_soc_init(Object *obj) |
38 | static inline int aspeed_smc_flash_addr_width(const AspeedSMCFlash *fl) | 59 | snprintf(typename, sizeof(typename), "aspeed.gpio-%s", socname); |
60 | object_initialize_child(obj, "gpio", &s->gpio, typename); | ||
61 | |||
62 | - object_initialize_child(obj, "sdc", &s->sdhci, TYPE_ASPEED_SDHCI); | ||
63 | + snprintf(typename, sizeof(typename), "aspeed.sdhci-%s", socname); | ||
64 | + object_initialize_child(obj, "sdc", &s->sdhci, typename); | ||
65 | |||
66 | object_property_set_int(OBJECT(&s->sdhci), "num-slots", 2, &error_abort); | ||
67 | |||
68 | diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c | ||
69 | index XXXXXXX..XXXXXXX 100644 | ||
70 | --- a/hw/arm/aspeed_ast2600.c | ||
71 | +++ b/hw/arm/aspeed_ast2600.c | ||
72 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_init(Object *obj) | ||
73 | snprintf(typename, sizeof(typename), "aspeed.gpio-%s-1_8v", socname); | ||
74 | object_initialize_child(obj, "gpio_1_8v", &s->gpio_1_8v, typename); | ||
75 | |||
76 | - object_initialize_child(obj, "sd-controller", &s->sdhci, | ||
77 | - TYPE_ASPEED_SDHCI); | ||
78 | + snprintf(typename, sizeof(typename), "aspeed.sdhci-%s", socname); | ||
79 | + object_initialize_child(obj, "sd-controller", &s->sdhci, typename); | ||
80 | |||
81 | object_property_set_int(OBJECT(&s->sdhci), "num-slots", 2, &error_abort); | ||
82 | |||
83 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_init(Object *obj) | ||
84 | &s->sdhci.slots[i], TYPE_SYSBUS_SDHCI); | ||
85 | } | ||
86 | |||
87 | - object_initialize_child(obj, "emmc-controller", &s->emmc, | ||
88 | - TYPE_ASPEED_SDHCI); | ||
89 | + object_initialize_child(obj, "emmc-controller", &s->emmc, typename); | ||
90 | |||
91 | object_property_set_int(OBJECT(&s->emmc), "num-slots", 1, &error_abort); | ||
92 | |||
93 | diff --git a/hw/sd/aspeed_sdhci.c b/hw/sd/aspeed_sdhci.c | ||
94 | index XXXXXXX..XXXXXXX 100644 | ||
95 | --- a/hw/sd/aspeed_sdhci.c | ||
96 | +++ b/hw/sd/aspeed_sdhci.c | ||
97 | @@ -XXX,XX +XXX,XX @@ static void aspeed_sdhci_realize(DeviceState *dev, Error **errp) | ||
39 | { | 98 | { |
40 | const AspeedSMCState *s = fl->controller; | 99 | SysBusDevice *sbd = SYS_BUS_DEVICE(dev); |
41 | - AspeedSMCClass *asc = ASPEED_SMC_GET_CLASS(s); | 100 | AspeedSDHCIState *sdhci = ASPEED_SDHCI(dev); |
42 | + AspeedSMCClass *asc = fl->asc; | 101 | + AspeedSDHCIClass *asc = ASPEED_SDHCI_GET_CLASS(sdhci); |
43 | 102 | ||
44 | if (asc->addr_width) { | 103 | /* Create input irqs for the slots */ |
45 | return asc->addr_width(s); | 104 | qdev_init_gpio_in_named_with_opaque(DEVICE(sbd), aspeed_sdhci_set_irq, |
46 | @@ -XXX,XX +XXX,XX @@ static uint32_t aspeed_smc_check_segment_addr(const AspeedSMCFlash *fl, | 105 | @@ -XXX,XX +XXX,XX @@ static void aspeed_sdhci_realize(DeviceState *dev, Error **errp) |
47 | uint32_t addr) | 106 | } |
48 | { | 107 | |
49 | const AspeedSMCState *s = fl->controller; | 108 | if (!object_property_set_uint(sdhci_slot, "capareg", |
50 | - AspeedSMCClass *asc = ASPEED_SMC_GET_CLASS(s); | 109 | - ASPEED_SDHCI_CAPABILITIES, errp)) { |
51 | + AspeedSMCClass *asc = fl->asc; | 110 | + asc->capareg, errp)) { |
52 | AspeedSegments seg; | 111 | return; |
53 | 112 | } | |
54 | asc->reg_to_segment(s, s->regs[R_SEG_ADDR0 + fl->cs], &seg); | 113 | |
55 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo aspeed_smc_info = { | 114 | @@ -XXX,XX +XXX,XX @@ static void aspeed_sdhci_class_init(ObjectClass *classp, void *data) |
56 | static void aspeed_smc_flash_realize(DeviceState *dev, Error **errp) | 115 | device_class_set_props(dc, aspeed_sdhci_properties); |
57 | { | ||
58 | AspeedSMCFlash *s = ASPEED_SMC_FLASH(dev); | ||
59 | - AspeedSMCClass *asc; | ||
60 | g_autofree char *name = g_strdup_printf(TYPE_ASPEED_SMC_FLASH ".%d", s->cs); | ||
61 | |||
62 | if (!s->controller) { | ||
63 | @@ -XXX,XX +XXX,XX @@ static void aspeed_smc_flash_realize(DeviceState *dev, Error **errp) | ||
64 | return; | ||
65 | } | ||
66 | |||
67 | - asc = ASPEED_SMC_GET_CLASS(s->controller); | ||
68 | + s->asc = ASPEED_SMC_GET_CLASS(s->controller); | ||
69 | |||
70 | /* | ||
71 | * Use the default segment value to size the memory region. This | ||
72 | * can be changed by FW at runtime. | ||
73 | */ | ||
74 | memory_region_init_io(&s->mmio, OBJECT(s), &aspeed_smc_flash_ops, | ||
75 | - s, name, asc->segments[s->cs].size); | ||
76 | + s, name, s->asc->segments[s->cs].size); | ||
77 | sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->mmio); | ||
78 | } | 116 | } |
79 | 117 | ||
118 | +static void aspeed_2400_sdhci_class_init(ObjectClass *klass, void *data) | ||
119 | +{ | ||
120 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
121 | + AspeedSDHCIClass *asc = ASPEED_SDHCI_CLASS(klass); | ||
122 | + | ||
123 | + dc->desc = "ASPEED 2400 SDHCI Controller"; | ||
124 | + asc->capareg = 0x0000000001e80080; | ||
125 | +} | ||
126 | + | ||
127 | +static void aspeed_2500_sdhci_class_init(ObjectClass *klass, void *data) | ||
128 | +{ | ||
129 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
130 | + AspeedSDHCIClass *asc = ASPEED_SDHCI_CLASS(klass); | ||
131 | + | ||
132 | + dc->desc = "ASPEED 2500 SDHCI Controller"; | ||
133 | + asc->capareg = 0x0000000001e80080; | ||
134 | +} | ||
135 | + | ||
136 | +static void aspeed_2600_sdhci_class_init(ObjectClass *klass, void *data) | ||
137 | +{ | ||
138 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
139 | + AspeedSDHCIClass *asc = ASPEED_SDHCI_CLASS(klass); | ||
140 | + | ||
141 | + dc->desc = "ASPEED 2600 SDHCI Controller"; | ||
142 | + asc->capareg = 0x0000000701f80080; | ||
143 | +} | ||
144 | + | ||
145 | static const TypeInfo aspeed_sdhci_types[] = { | ||
146 | { | ||
147 | .name = TYPE_ASPEED_SDHCI, | ||
148 | .parent = TYPE_SYS_BUS_DEVICE, | ||
149 | .instance_size = sizeof(AspeedSDHCIState), | ||
150 | .class_init = aspeed_sdhci_class_init, | ||
151 | + .class_size = sizeof(AspeedSDHCIClass), | ||
152 | + .abstract = true, | ||
153 | + }, | ||
154 | + { | ||
155 | + .name = TYPE_ASPEED_2400_SDHCI, | ||
156 | + .parent = TYPE_ASPEED_SDHCI, | ||
157 | + .class_init = aspeed_2400_sdhci_class_init, | ||
158 | + }, | ||
159 | + { | ||
160 | + .name = TYPE_ASPEED_2500_SDHCI, | ||
161 | + .parent = TYPE_ASPEED_SDHCI, | ||
162 | + .class_init = aspeed_2500_sdhci_class_init, | ||
163 | + }, | ||
164 | + { | ||
165 | + .name = TYPE_ASPEED_2600_SDHCI, | ||
166 | + .parent = TYPE_ASPEED_SDHCI, | ||
167 | + .class_init = aspeed_2600_sdhci_class_init, | ||
168 | }, | ||
169 | }; | ||
170 | |||
80 | -- | 171 | -- |
81 | 2.37.3 | 172 | 2.47.1 |
82 | 173 | ||
83 | 174 | diff view generated by jsdifflib |
1 | From: Patrick Williams <patrick@stwcx.xyz> | 1 | From: Jamin Lin <jamin_lin@aspeedtech.com> |
---|---|---|---|
2 | 2 | ||
3 | Generated from hardware using the following command and then padding | 3 | Introduce a new ast2700 class to support AST2700. Add a new ast2700 SDHCI class |
4 | with 0xff to fill out a power-of-2: | 4 | init function and set the value of capability register to "0x0000000719f80080". |
5 | hexdump -v -e '8/1 "0x%02x, " "\n"' sfdp` | ||
6 | 5 | ||
7 | Signed-off-by: Patrick Williams <patrick@stwcx.xyz> | 6 | Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com> |
8 | Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com> | 7 | Reviewed-by: Cédric Le Goater <clg@redhat.com> |
9 | [ clg: removed extern ] | 8 | Link: https://lore.kernel.org/r/20241204084453.610660-5-jamin_lin@aspeedtech.com |
10 | Message-Id: <20221006224424.3556372-1-patrick@stwcx.xyz> | 9 | Signed-off-by: Cédric Le Goater <clg@redhat.com> |
11 | Message-Id: <20221013161241.2805140-10-clg@kaod.org> | ||
12 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
13 | --- | 10 | --- |
14 | hw/block/m25p80_sfdp.h | 2 ++ | 11 | include/hw/sd/aspeed_sdhci.h | 1 + |
15 | hw/block/m25p80.c | 3 ++- | 12 | hw/sd/aspeed_sdhci.c | 14 ++++++++++++++ |
16 | hw/block/m25p80_sfdp.c | 36 ++++++++++++++++++++++++++++++++++++ | 13 | 2 files changed, 15 insertions(+) |
17 | 3 files changed, 40 insertions(+), 1 deletion(-) | ||
18 | 14 | ||
19 | diff --git a/hw/block/m25p80_sfdp.h b/hw/block/m25p80_sfdp.h | 15 | diff --git a/include/hw/sd/aspeed_sdhci.h b/include/hw/sd/aspeed_sdhci.h |
20 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/hw/block/m25p80_sfdp.h | 17 | --- a/include/hw/sd/aspeed_sdhci.h |
22 | +++ b/hw/block/m25p80_sfdp.h | 18 | +++ b/include/hw/sd/aspeed_sdhci.h |
23 | @@ -XXX,XX +XXX,XX @@ uint8_t m25p80_sfdp_mx66l1g45g(uint32_t addr); | 19 | @@ -XXX,XX +XXX,XX @@ |
24 | uint8_t m25p80_sfdp_w25q256(uint32_t addr); | 20 | #define TYPE_ASPEED_2400_SDHCI TYPE_ASPEED_SDHCI "-ast2400" |
25 | uint8_t m25p80_sfdp_w25q512jv(uint32_t addr); | 21 | #define TYPE_ASPEED_2500_SDHCI TYPE_ASPEED_SDHCI "-ast2500" |
26 | 22 | #define TYPE_ASPEED_2600_SDHCI TYPE_ASPEED_SDHCI "-ast2600" | |
27 | +uint8_t m25p80_sfdp_w25q01jvq(uint32_t addr); | 23 | +#define TYPE_ASPEED_2700_SDHCI TYPE_ASPEED_SDHCI "-ast2700" |
24 | OBJECT_DECLARE_TYPE(AspeedSDHCIState, AspeedSDHCIClass, ASPEED_SDHCI) | ||
25 | |||
26 | #define ASPEED_SDHCI_NUM_SLOTS 2 | ||
27 | diff --git a/hw/sd/aspeed_sdhci.c b/hw/sd/aspeed_sdhci.c | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/hw/sd/aspeed_sdhci.c | ||
30 | +++ b/hw/sd/aspeed_sdhci.c | ||
31 | @@ -XXX,XX +XXX,XX @@ static void aspeed_2600_sdhci_class_init(ObjectClass *klass, void *data) | ||
32 | asc->capareg = 0x0000000701f80080; | ||
33 | } | ||
34 | |||
35 | +static void aspeed_2700_sdhci_class_init(ObjectClass *klass, void *data) | ||
36 | +{ | ||
37 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
38 | + AspeedSDHCIClass *asc = ASPEED_SDHCI_CLASS(klass); | ||
28 | + | 39 | + |
29 | #endif | 40 | + dc->desc = "ASPEED 2700 SDHCI Controller"; |
30 | diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c | 41 | + asc->capareg = 0x0000000719f80080; |
31 | index XXXXXXX..XXXXXXX 100644 | 42 | +} |
32 | --- a/hw/block/m25p80.c | 43 | + |
33 | +++ b/hw/block/m25p80.c | 44 | static const TypeInfo aspeed_sdhci_types[] = { |
34 | @@ -XXX,XX +XXX,XX @@ static const FlashPartInfo known_devices[] = { | 45 | { |
35 | .sfdp_read = m25p80_sfdp_w25q256 }, | 46 | .name = TYPE_ASPEED_SDHCI, |
36 | { INFO("w25q512jv", 0xef4020, 0, 64 << 10, 1024, ER_4K), | 47 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo aspeed_sdhci_types[] = { |
37 | .sfdp_read = m25p80_sfdp_w25q512jv }, | 48 | .parent = TYPE_ASPEED_SDHCI, |
38 | - { INFO("w25q01jvq", 0xef4021, 0, 64 << 10, 2048, ER_4K) }, | 49 | .class_init = aspeed_2600_sdhci_class_init, |
39 | + { INFO("w25q01jvq", 0xef4021, 0, 64 << 10, 2048, ER_4K), | 50 | }, |
40 | + .sfdp_read = m25p80_sfdp_w25q01jvq }, | 51 | + { |
52 | + .name = TYPE_ASPEED_2700_SDHCI, | ||
53 | + .parent = TYPE_ASPEED_SDHCI, | ||
54 | + .class_init = aspeed_2700_sdhci_class_init, | ||
55 | + }, | ||
41 | }; | 56 | }; |
42 | 57 | ||
43 | typedef enum { | 58 | DEFINE_TYPES(aspeed_sdhci_types) |
44 | diff --git a/hw/block/m25p80_sfdp.c b/hw/block/m25p80_sfdp.c | ||
45 | index XXXXXXX..XXXXXXX 100644 | ||
46 | --- a/hw/block/m25p80_sfdp.c | ||
47 | +++ b/hw/block/m25p80_sfdp.c | ||
48 | @@ -XXX,XX +XXX,XX @@ static const uint8_t sfdp_w25q512jv[] = { | ||
49 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
50 | }; | ||
51 | define_sfdp_read(w25q512jv); | ||
52 | + | ||
53 | +static const uint8_t sfdp_w25q01jvq[] = { | ||
54 | + 0x53, 0x46, 0x44, 0x50, 0x06, 0x01, 0x01, 0xff, | ||
55 | + 0x00, 0x06, 0x01, 0x10, 0x80, 0x00, 0x00, 0xff, | ||
56 | + 0x84, 0x00, 0x01, 0x02, 0xd0, 0x00, 0x00, 0xff, | ||
57 | + 0x03, 0x00, 0x01, 0x02, 0xf0, 0x00, 0x00, 0xff, | ||
58 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
59 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
60 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
61 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
62 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
63 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
64 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
65 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
66 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
67 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
68 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
69 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
70 | + 0xe5, 0x20, 0xfb, 0xff, 0xff, 0xff, 0xff, 0x3f, | ||
71 | + 0x44, 0xeb, 0x08, 0x6b, 0x08, 0x3b, 0x42, 0xbb, | ||
72 | + 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, | ||
73 | + 0xff, 0xff, 0x40, 0xeb, 0x0c, 0x20, 0x0f, 0x52, | ||
74 | + 0x10, 0xd8, 0x00, 0x00, 0x36, 0x02, 0xa6, 0x00, | ||
75 | + 0x82, 0xea, 0x14, 0xe2, 0xe9, 0x63, 0x76, 0x33, | ||
76 | + 0x7a, 0x75, 0x7a, 0x75, 0xf7, 0xa2, 0xd5, 0x5c, | ||
77 | + 0x19, 0xf7, 0x4d, 0xff, 0xe9, 0x70, 0xf9, 0xa5, | ||
78 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
79 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
80 | + 0xff, 0x0a, 0xf0, 0xff, 0x21, 0xff, 0xdc, 0xff, | ||
81 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
82 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
83 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
84 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
85 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
86 | +}; | ||
87 | +define_sfdp_read(w25q01jvq); | ||
88 | -- | 59 | -- |
89 | 2.37.3 | 60 | 2.47.1 |
90 | 61 | ||
91 | 62 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Jamin Lin <jamin_lin@aspeedtech.com> | ||
1 | 2 | ||
3 | Add SDHCI model for AST2700 SDHCI support. The SDHCI controller only support 1 | ||
4 | slot and registers base address is start at 0x1408_0000 and its interrupt is | ||
5 | connected to GICINT133_INTC at bit 1. | ||
6 | |||
7 | Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com> | ||
8 | Reviewed-by: Cédric Le Goater <clg@redhat.com> | ||
9 | Link: https://lore.kernel.org/r/20241204084453.610660-6-jamin_lin@aspeedtech.com | ||
10 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | ||
11 | --- | ||
12 | hw/arm/aspeed_ast27x0.c | 20 ++++++++++++++++++++ | ||
13 | 1 file changed, 20 insertions(+) | ||
14 | |||
15 | diff --git a/hw/arm/aspeed_ast27x0.c b/hw/arm/aspeed_ast27x0.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/hw/arm/aspeed_ast27x0.c | ||
18 | +++ b/hw/arm/aspeed_ast27x0.c | ||
19 | @@ -XXX,XX +XXX,XX @@ static const hwaddr aspeed_soc_ast2700_memmap[] = { | ||
20 | [ASPEED_DEV_I2C] = 0x14C0F000, | ||
21 | [ASPEED_DEV_GPIO] = 0x14C0B000, | ||
22 | [ASPEED_DEV_RTC] = 0x12C0F000, | ||
23 | + [ASPEED_DEV_SDHCI] = 0x14080000, | ||
24 | }; | ||
25 | |||
26 | #define AST2700_MAX_IRQ 256 | ||
27 | @@ -XXX,XX +XXX,XX @@ static const int aspeed_soc_ast2700_irqmap[] = { | ||
28 | [ASPEED_DEV_KCS] = 128, | ||
29 | [ASPEED_DEV_DP] = 28, | ||
30 | [ASPEED_DEV_I3C] = 131, | ||
31 | + [ASPEED_DEV_SDHCI] = 133, | ||
32 | }; | ||
33 | |||
34 | /* GICINT 128 */ | ||
35 | @@ -XXX,XX +XXX,XX @@ static const int aspeed_soc_ast2700_gic132_intcmap[] = { | ||
36 | |||
37 | /* GICINT 133 */ | ||
38 | static const int aspeed_soc_ast2700_gic133_intcmap[] = { | ||
39 | + [ASPEED_DEV_SDHCI] = 1, | ||
40 | [ASPEED_DEV_PECI] = 4, | ||
41 | }; | ||
42 | |||
43 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2700_init(Object *obj) | ||
44 | object_initialize_child(obj, "gpio", &s->gpio, typename); | ||
45 | |||
46 | object_initialize_child(obj, "rtc", &s->rtc, TYPE_ASPEED_RTC); | ||
47 | + | ||
48 | + snprintf(typename, sizeof(typename), "aspeed.sdhci-%s", socname); | ||
49 | + object_initialize_child(obj, "sd-controller", &s->sdhci, typename); | ||
50 | + object_property_set_int(OBJECT(&s->sdhci), "num-slots", 1, &error_abort); | ||
51 | + | ||
52 | + /* Init sd card slot class here so that they're under the correct parent */ | ||
53 | + object_initialize_child(obj, "sd-controller.sdhci", | ||
54 | + &s->sdhci.slots[0], TYPE_SYSBUS_SDHCI); | ||
55 | } | ||
56 | |||
57 | /* | ||
58 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2700_realize(DeviceState *dev, Error **errp) | ||
59 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->rtc), 0, | ||
60 | aspeed_soc_get_irq(s, ASPEED_DEV_RTC)); | ||
61 | |||
62 | + /* SDHCI */ | ||
63 | + if (!sysbus_realize(SYS_BUS_DEVICE(&s->sdhci), errp)) { | ||
64 | + return; | ||
65 | + } | ||
66 | + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->sdhci), 0, | ||
67 | + sc->memmap[ASPEED_DEV_SDHCI]); | ||
68 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->sdhci), 0, | ||
69 | + aspeed_soc_get_irq(s, ASPEED_DEV_SDHCI)); | ||
70 | + | ||
71 | create_unimplemented_device("ast2700.dpmcu", 0x11000000, 0x40000); | ||
72 | create_unimplemented_device("ast2700.iomem0", 0x12000000, 0x01000000); | ||
73 | create_unimplemented_device("ast2700.iomem1", 0x14000000, 0x01000000); | ||
74 | -- | ||
75 | 2.47.1 | ||
76 | |||
77 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Jamin Lin <jamin_lin@aspeedtech.com> | ||
1 | 2 | ||
3 | Add SDHCI model for AST2700 eMMC support. The eMMC controller only support 1 | ||
4 | slot and registers base address is start at 0x1209_0000 and its interrupt is | ||
5 | connected to GICINT 15. | ||
6 | |||
7 | Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com> | ||
8 | Reviewed-by: Cédric Le Goater <clg@redhat.com> | ||
9 | Link: https://lore.kernel.org/r/20241204084453.610660-7-jamin_lin@aspeedtech.com | ||
10 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | ||
11 | --- | ||
12 | hw/arm/aspeed_ast27x0.c | 15 +++++++++++++++ | ||
13 | 1 file changed, 15 insertions(+) | ||
14 | |||
15 | diff --git a/hw/arm/aspeed_ast27x0.c b/hw/arm/aspeed_ast27x0.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/hw/arm/aspeed_ast27x0.c | ||
18 | +++ b/hw/arm/aspeed_ast27x0.c | ||
19 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2700_init(Object *obj) | ||
20 | /* Init sd card slot class here so that they're under the correct parent */ | ||
21 | object_initialize_child(obj, "sd-controller.sdhci", | ||
22 | &s->sdhci.slots[0], TYPE_SYSBUS_SDHCI); | ||
23 | + | ||
24 | + object_initialize_child(obj, "emmc-controller", &s->emmc, typename); | ||
25 | + object_property_set_int(OBJECT(&s->emmc), "num-slots", 1, &error_abort); | ||
26 | + | ||
27 | + object_initialize_child(obj, "emmc-controller.sdhci", &s->emmc.slots[0], | ||
28 | + TYPE_SYSBUS_SDHCI); | ||
29 | } | ||
30 | |||
31 | /* | ||
32 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2700_realize(DeviceState *dev, Error **errp) | ||
33 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->sdhci), 0, | ||
34 | aspeed_soc_get_irq(s, ASPEED_DEV_SDHCI)); | ||
35 | |||
36 | + /* eMMC */ | ||
37 | + if (!sysbus_realize(SYS_BUS_DEVICE(&s->emmc), errp)) { | ||
38 | + return; | ||
39 | + } | ||
40 | + aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->emmc), 0, | ||
41 | + sc->memmap[ASPEED_DEV_EMMC]); | ||
42 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->emmc), 0, | ||
43 | + aspeed_soc_get_irq(s, ASPEED_DEV_EMMC)); | ||
44 | + | ||
45 | create_unimplemented_device("ast2700.dpmcu", 0x11000000, 0x40000); | ||
46 | create_unimplemented_device("ast2700.iomem0", 0x12000000, 0x01000000); | ||
47 | create_unimplemented_device("ast2700.iomem1", 0x14000000, 0x01000000); | ||
48 | -- | ||
49 | 2.47.1 | ||
50 | |||
51 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | This simply moves the ast1030 tests to a new test file. No changes. | ||
1 | 2 | ||
3 | Reviewed-by: Thomas Huth <thuth@redhat.com> | ||
4 | Link: https://lore.kernel.org/r/20241206131132.520911-2-clg@redhat.com | ||
5 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | ||
6 | --- | ||
7 | tests/functional/meson.build | 1 + | ||
8 | tests/functional/test_arm_aspeed.py | 64 ---------------- | ||
9 | tests/functional/test_arm_aspeed_ast1030.py | 81 +++++++++++++++++++++ | ||
10 | 3 files changed, 82 insertions(+), 64 deletions(-) | ||
11 | create mode 100644 tests/functional/test_arm_aspeed_ast1030.py | ||
12 | |||
13 | diff --git a/tests/functional/meson.build b/tests/functional/meson.build | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/tests/functional/meson.build | ||
16 | +++ b/tests/functional/meson.build | ||
17 | @@ -XXX,XX +XXX,XX @@ tests_alpha_system_thorough = [ | ||
18 | |||
19 | tests_arm_system_thorough = [ | ||
20 | 'arm_aspeed', | ||
21 | + 'arm_aspeed_ast1030', | ||
22 | 'arm_bpim2u', | ||
23 | 'arm_canona1100', | ||
24 | 'arm_collie', | ||
25 | diff --git a/tests/functional/test_arm_aspeed.py b/tests/functional/test_arm_aspeed.py | ||
26 | index XXXXXXX..XXXXXXX 100755 | ||
27 | --- a/tests/functional/test_arm_aspeed.py | ||
28 | +++ b/tests/functional/test_arm_aspeed.py | ||
29 | @@ -XXX,XX +XXX,XX @@ | ||
30 | from zipfile import ZipFile | ||
31 | from unittest import skipUnless | ||
32 | |||
33 | -class AST1030Machine(LinuxKernelTest): | ||
34 | - | ||
35 | - ASSET_ZEPHYR_1_04 = Asset( | ||
36 | - ('https://github.com/AspeedTech-BMC' | ||
37 | - '/zephyr/releases/download/v00.01.04/ast1030-evb-demo.zip'), | ||
38 | - '4ac6210adcbc61294927918707c6762483fd844dde5e07f3ba834ad1f91434d3') | ||
39 | - | ||
40 | - def test_ast1030_zephyros_1_04(self): | ||
41 | - self.set_machine('ast1030-evb') | ||
42 | - | ||
43 | - zip_file = self.ASSET_ZEPHYR_1_04.fetch() | ||
44 | - | ||
45 | - kernel_name = "ast1030-evb-demo/zephyr.elf" | ||
46 | - with ZipFile(zip_file, 'r') as zf: | ||
47 | - zf.extract(kernel_name, path=self.workdir) | ||
48 | - kernel_file = os.path.join(self.workdir, kernel_name) | ||
49 | - | ||
50 | - self.vm.set_console() | ||
51 | - self.vm.add_args('-kernel', kernel_file, '-nographic') | ||
52 | - self.vm.launch() | ||
53 | - self.wait_for_console_pattern("Booting Zephyr OS") | ||
54 | - exec_command_and_wait_for_pattern(self, "help", | ||
55 | - "Available commands") | ||
56 | - | ||
57 | - ASSET_ZEPHYR_1_07 = Asset( | ||
58 | - ('https://github.com/AspeedTech-BMC' | ||
59 | - '/zephyr/releases/download/v00.01.07/ast1030-evb-demo.zip'), | ||
60 | - 'ad52e27959746988afaed8429bf4e12ab988c05c4d07c9d90e13ec6f7be4574c') | ||
61 | - | ||
62 | - def test_ast1030_zephyros_1_07(self): | ||
63 | - self.set_machine('ast1030-evb') | ||
64 | - | ||
65 | - zip_file = self.ASSET_ZEPHYR_1_07.fetch() | ||
66 | - | ||
67 | - kernel_name = "ast1030-evb-demo/zephyr.bin" | ||
68 | - with ZipFile(zip_file, 'r') as zf: | ||
69 | - zf.extract(kernel_name, path=self.workdir) | ||
70 | - kernel_file = os.path.join(self.workdir, kernel_name) | ||
71 | - | ||
72 | - self.vm.set_console() | ||
73 | - self.vm.add_args('-kernel', kernel_file, '-nographic') | ||
74 | - self.vm.launch() | ||
75 | - self.wait_for_console_pattern("Booting Zephyr OS") | ||
76 | - for shell_cmd in [ | ||
77 | - 'kernel stacks', | ||
78 | - 'otp info conf', | ||
79 | - 'otp info scu', | ||
80 | - 'hwinfo devid', | ||
81 | - 'crypto aes256_cbc_vault', | ||
82 | - 'random get', | ||
83 | - 'jtag JTAG1 sw_xfer high TMS', | ||
84 | - 'adc ADC0 resolution 12', | ||
85 | - 'adc ADC0 read 42', | ||
86 | - 'adc ADC1 read 69', | ||
87 | - 'i2c scan I2C_0', | ||
88 | - 'i3c attach I3C_0', | ||
89 | - 'hash test', | ||
90 | - 'kernel uptime', | ||
91 | - 'kernel reboot warm', | ||
92 | - 'kernel uptime', | ||
93 | - 'kernel reboot cold', | ||
94 | - 'kernel uptime', | ||
95 | - ]: exec_command_and_wait_for_pattern(self, shell_cmd, "uart:~$") | ||
96 | - | ||
97 | class AST2x00Machine(LinuxKernelTest): | ||
98 | |||
99 | def do_test_arm_aspeed(self, machine, image): | ||
100 | diff --git a/tests/functional/test_arm_aspeed_ast1030.py b/tests/functional/test_arm_aspeed_ast1030.py | ||
101 | new file mode 100644 | ||
102 | index XXXXXXX..XXXXXXX | ||
103 | --- /dev/null | ||
104 | +++ b/tests/functional/test_arm_aspeed_ast1030.py | ||
105 | @@ -XXX,XX +XXX,XX @@ | ||
106 | +#!/usr/bin/env python3 | ||
107 | +# | ||
108 | +# Functional test that boots the ASPEED SoCs with firmware | ||
109 | +# | ||
110 | +# Copyright (C) 2022 ASPEED Technology Inc | ||
111 | +# | ||
112 | +# SPDX-License-Identifier: GPL-2.0-or-later | ||
113 | + | ||
114 | +import os | ||
115 | + | ||
116 | +from qemu_test import LinuxKernelTest, Asset | ||
117 | +from qemu_test import exec_command_and_wait_for_pattern | ||
118 | +from zipfile import ZipFile | ||
119 | + | ||
120 | +class AST1030Machine(LinuxKernelTest): | ||
121 | + | ||
122 | + ASSET_ZEPHYR_1_04 = Asset( | ||
123 | + ('https://github.com/AspeedTech-BMC' | ||
124 | + '/zephyr/releases/download/v00.01.04/ast1030-evb-demo.zip'), | ||
125 | + '4ac6210adcbc61294927918707c6762483fd844dde5e07f3ba834ad1f91434d3') | ||
126 | + | ||
127 | + def test_ast1030_zephyros_1_04(self): | ||
128 | + self.set_machine('ast1030-evb') | ||
129 | + | ||
130 | + zip_file = self.ASSET_ZEPHYR_1_04.fetch() | ||
131 | + | ||
132 | + kernel_name = "ast1030-evb-demo/zephyr.elf" | ||
133 | + with ZipFile(zip_file, 'r') as zf: | ||
134 | + zf.extract(kernel_name, path=self.workdir) | ||
135 | + kernel_file = os.path.join(self.workdir, kernel_name) | ||
136 | + | ||
137 | + self.vm.set_console() | ||
138 | + self.vm.add_args('-kernel', kernel_file, '-nographic') | ||
139 | + self.vm.launch() | ||
140 | + self.wait_for_console_pattern("Booting Zephyr OS") | ||
141 | + exec_command_and_wait_for_pattern(self, "help", | ||
142 | + "Available commands") | ||
143 | + | ||
144 | + ASSET_ZEPHYR_1_07 = Asset( | ||
145 | + ('https://github.com/AspeedTech-BMC' | ||
146 | + '/zephyr/releases/download/v00.01.07/ast1030-evb-demo.zip'), | ||
147 | + 'ad52e27959746988afaed8429bf4e12ab988c05c4d07c9d90e13ec6f7be4574c') | ||
148 | + | ||
149 | + def test_ast1030_zephyros_1_07(self): | ||
150 | + self.set_machine('ast1030-evb') | ||
151 | + | ||
152 | + zip_file = self.ASSET_ZEPHYR_1_07.fetch() | ||
153 | + | ||
154 | + kernel_name = "ast1030-evb-demo/zephyr.bin" | ||
155 | + with ZipFile(zip_file, 'r') as zf: | ||
156 | + zf.extract(kernel_name, path=self.workdir) | ||
157 | + kernel_file = os.path.join(self.workdir, kernel_name) | ||
158 | + | ||
159 | + self.vm.set_console() | ||
160 | + self.vm.add_args('-kernel', kernel_file, '-nographic') | ||
161 | + self.vm.launch() | ||
162 | + self.wait_for_console_pattern("Booting Zephyr OS") | ||
163 | + for shell_cmd in [ | ||
164 | + 'kernel stacks', | ||
165 | + 'otp info conf', | ||
166 | + 'otp info scu', | ||
167 | + 'hwinfo devid', | ||
168 | + 'crypto aes256_cbc_vault', | ||
169 | + 'random get', | ||
170 | + 'jtag JTAG1 sw_xfer high TMS', | ||
171 | + 'adc ADC0 resolution 12', | ||
172 | + 'adc ADC0 read 42', | ||
173 | + 'adc ADC1 read 69', | ||
174 | + 'i2c scan I2C_0', | ||
175 | + 'i3c attach I3C_0', | ||
176 | + 'hash test', | ||
177 | + 'kernel uptime', | ||
178 | + 'kernel reboot warm', | ||
179 | + 'kernel uptime', | ||
180 | + 'kernel reboot cold', | ||
181 | + 'kernel uptime', | ||
182 | + ]: exec_command_and_wait_for_pattern(self, shell_cmd, "uart:~$") | ||
183 | + | ||
184 | + | ||
185 | +if __name__ == '__main__': | ||
186 | + LinuxKernelTest.main() | ||
187 | -- | ||
188 | 2.47.1 | ||
189 | |||
190 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | This introduces a new aspeed module for sharing code between tests and | ||
2 | moves the palmetto test to a new test file. No changes in the test. | ||
1 | 3 | ||
4 | Reviewed-by: Thomas Huth <thuth@redhat.com> | ||
5 | Link: https://lore.kernel.org/r/20241206131132.520911-3-clg@redhat.com | ||
6 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | ||
7 | --- | ||
8 | tests/functional/aspeed.py | 23 +++++++++++++++++++ | ||
9 | tests/functional/meson.build | 2 ++ | ||
10 | tests/functional/test_arm_aspeed.py | 10 -------- | ||
11 | tests/functional/test_arm_aspeed_palmetto.py | 24 ++++++++++++++++++++ | ||
12 | 4 files changed, 49 insertions(+), 10 deletions(-) | ||
13 | create mode 100644 tests/functional/aspeed.py | ||
14 | create mode 100644 tests/functional/test_arm_aspeed_palmetto.py | ||
15 | |||
16 | diff --git a/tests/functional/aspeed.py b/tests/functional/aspeed.py | ||
17 | new file mode 100644 | ||
18 | index XXXXXXX..XXXXXXX | ||
19 | --- /dev/null | ||
20 | +++ b/tests/functional/aspeed.py | ||
21 | @@ -XXX,XX +XXX,XX @@ | ||
22 | +# Test class to boot aspeed machines | ||
23 | +# | ||
24 | +# SPDX-License-Identifier: GPL-2.0-or-later | ||
25 | + | ||
26 | +from qemu_test import LinuxKernelTest | ||
27 | + | ||
28 | +class AspeedTest(LinuxKernelTest): | ||
29 | + | ||
30 | + def do_test_arm_aspeed(self, machine, image): | ||
31 | + self.set_machine(machine) | ||
32 | + self.vm.set_console() | ||
33 | + self.vm.add_args('-drive', 'file=' + image + ',if=mtd,format=raw', | ||
34 | + '-net', 'nic', '-snapshot') | ||
35 | + self.vm.launch() | ||
36 | + | ||
37 | + self.wait_for_console_pattern("U-Boot 2016.07") | ||
38 | + self.wait_for_console_pattern("## Loading kernel from FIT Image at 20080000") | ||
39 | + self.wait_for_console_pattern("Starting kernel ...") | ||
40 | + self.wait_for_console_pattern("Booting Linux on physical CPU 0x0") | ||
41 | + self.wait_for_console_pattern( | ||
42 | + "aspeed-smc 1e620000.spi: read control register: 203b0641") | ||
43 | + self.wait_for_console_pattern("ftgmac100 1e660000.ethernet eth0: irq ") | ||
44 | + self.wait_for_console_pattern("systemd[1]: Set hostname to") | ||
45 | diff --git a/tests/functional/meson.build b/tests/functional/meson.build | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/tests/functional/meson.build | ||
48 | +++ b/tests/functional/meson.build | ||
49 | @@ -XXX,XX +XXX,XX @@ test_timeouts = { | ||
50 | 'aarch64_tuxrun' : 240, | ||
51 | 'aarch64_virt' : 720, | ||
52 | 'acpi_bits' : 420, | ||
53 | + 'arm_aspeed_palmetto' : 120, | ||
54 | 'arm_aspeed' : 600, | ||
55 | 'arm_bpim2u' : 500, | ||
56 | 'arm_collie' : 180, | ||
57 | @@ -XXX,XX +XXX,XX @@ tests_alpha_system_thorough = [ | ||
58 | tests_arm_system_thorough = [ | ||
59 | 'arm_aspeed', | ||
60 | 'arm_aspeed_ast1030', | ||
61 | + 'arm_aspeed_palmetto', | ||
62 | 'arm_bpim2u', | ||
63 | 'arm_canona1100', | ||
64 | 'arm_collie', | ||
65 | diff --git a/tests/functional/test_arm_aspeed.py b/tests/functional/test_arm_aspeed.py | ||
66 | index XXXXXXX..XXXXXXX 100755 | ||
67 | --- a/tests/functional/test_arm_aspeed.py | ||
68 | +++ b/tests/functional/test_arm_aspeed.py | ||
69 | @@ -XXX,XX +XXX,XX @@ def do_test_arm_aspeed(self, machine, image): | ||
70 | self.wait_for_console_pattern("ftgmac100 1e660000.ethernet eth0: irq ") | ||
71 | self.wait_for_console_pattern("systemd[1]: Set hostname to") | ||
72 | |||
73 | - ASSET_PALMETTO_FLASH = Asset( | ||
74 | - ('https://github.com/openbmc/openbmc/releases/download/2.9.0/' | ||
75 | - 'obmc-phosphor-image-palmetto.static.mtd'), | ||
76 | - '3e13bbbc28e424865dc42f35ad672b10f2e82cdb11846bb28fa625b48beafd0d'); | ||
77 | - | ||
78 | - def test_arm_ast2400_palmetto_openbmc_v2_9_0(self): | ||
79 | - image_path = self.ASSET_PALMETTO_FLASH.fetch() | ||
80 | - | ||
81 | - self.do_test_arm_aspeed('palmetto-bmc', image_path) | ||
82 | - | ||
83 | ASSET_ROMULUS_FLASH = Asset( | ||
84 | ('https://github.com/openbmc/openbmc/releases/download/2.9.0/' | ||
85 | 'obmc-phosphor-image-romulus.static.mtd'), | ||
86 | diff --git a/tests/functional/test_arm_aspeed_palmetto.py b/tests/functional/test_arm_aspeed_palmetto.py | ||
87 | new file mode 100644 | ||
88 | index XXXXXXX..XXXXXXX | ||
89 | --- /dev/null | ||
90 | +++ b/tests/functional/test_arm_aspeed_palmetto.py | ||
91 | @@ -XXX,XX +XXX,XX @@ | ||
92 | +#!/usr/bin/env python3 | ||
93 | +# | ||
94 | +# Functional test that boots the ASPEED machines | ||
95 | +# | ||
96 | +# SPDX-License-Identifier: GPL-2.0-or-later | ||
97 | + | ||
98 | +from qemu_test import Asset | ||
99 | +from aspeed import AspeedTest | ||
100 | + | ||
101 | +class PalmettoMachine(AspeedTest): | ||
102 | + | ||
103 | + ASSET_PALMETTO_FLASH = Asset( | ||
104 | + ('https://github.com/openbmc/openbmc/releases/download/2.9.0/' | ||
105 | + 'obmc-phosphor-image-palmetto.static.mtd'), | ||
106 | + '3e13bbbc28e424865dc42f35ad672b10f2e82cdb11846bb28fa625b48beafd0d'); | ||
107 | + | ||
108 | + def test_arm_ast2400_palmetto_openbmc_v2_9_0(self): | ||
109 | + image_path = self.ASSET_PALMETTO_FLASH.fetch() | ||
110 | + | ||
111 | + self.do_test_arm_aspeed('palmetto-bmc', image_path) | ||
112 | + | ||
113 | + | ||
114 | +if __name__ == '__main__': | ||
115 | + AspeedTest.main() | ||
116 | -- | ||
117 | 2.47.1 | ||
118 | |||
119 | diff view generated by jsdifflib |
1 | The SFDP table is 0x80 bytes long. The mandatory table for basic | 1 | This simply moves the romulus-bmc test to a new test file. No changes |
---|---|---|---|
2 | features is available at byte 0x30 and an extra Macronix specific | 2 | in the test. The do_test_arm_aspeed routine is removed from the |
3 | table is available at 0x60. | 3 | test_arm_aspeed.py file because it is now unused. |
4 | 4 | ||
5 | 4B opcodes are not supported. | 5 | Reviewed-by: Thomas Huth <thuth@redhat.com> |
6 | Link: https://lore.kernel.org/r/20241206131132.520911-4-clg@redhat.com | ||
7 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | ||
8 | --- | ||
9 | tests/functional/meson.build | 2 ++ | ||
10 | tests/functional/test_arm_aspeed.py | 26 --------------------- | ||
11 | tests/functional/test_arm_aspeed_romulus.py | 24 +++++++++++++++++++ | ||
12 | 3 files changed, 26 insertions(+), 26 deletions(-) | ||
13 | create mode 100644 tests/functional/test_arm_aspeed_romulus.py | ||
6 | 14 | ||
7 | Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com> | 15 | diff --git a/tests/functional/meson.build b/tests/functional/meson.build |
8 | Message-Id: <20220722063602.128144-4-clg@kaod.org> | ||
9 | Message-Id: <20221013161241.2805140-5-clg@kaod.org> | ||
10 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
11 | --- | ||
12 | hw/block/m25p80_sfdp.h | 3 +++ | ||
13 | hw/block/m25p80.c | 2 +- | ||
14 | hw/block/m25p80_sfdp.c | 26 ++++++++++++++++++++++++++ | ||
15 | 3 files changed, 30 insertions(+), 1 deletion(-) | ||
16 | |||
17 | diff --git a/hw/block/m25p80_sfdp.h b/hw/block/m25p80_sfdp.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/hw/block/m25p80_sfdp.h | 17 | --- a/tests/functional/meson.build |
20 | +++ b/hw/block/m25p80_sfdp.h | 18 | +++ b/tests/functional/meson.build |
19 | @@ -XXX,XX +XXX,XX @@ test_timeouts = { | ||
20 | 'aarch64_virt' : 720, | ||
21 | 'acpi_bits' : 420, | ||
22 | 'arm_aspeed_palmetto' : 120, | ||
23 | + 'arm_aspeed_romulus' : 120, | ||
24 | 'arm_aspeed' : 600, | ||
25 | 'arm_bpim2u' : 500, | ||
26 | 'arm_collie' : 180, | ||
27 | @@ -XXX,XX +XXX,XX @@ tests_arm_system_thorough = [ | ||
28 | 'arm_aspeed', | ||
29 | 'arm_aspeed_ast1030', | ||
30 | 'arm_aspeed_palmetto', | ||
31 | + 'arm_aspeed_romulus', | ||
32 | 'arm_bpim2u', | ||
33 | 'arm_canona1100', | ||
34 | 'arm_collie', | ||
35 | diff --git a/tests/functional/test_arm_aspeed.py b/tests/functional/test_arm_aspeed.py | ||
36 | index XXXXXXX..XXXXXXX 100755 | ||
37 | --- a/tests/functional/test_arm_aspeed.py | ||
38 | +++ b/tests/functional/test_arm_aspeed.py | ||
21 | @@ -XXX,XX +XXX,XX @@ | 39 | @@ -XXX,XX +XXX,XX @@ |
22 | 40 | ||
23 | uint8_t m25p80_sfdp_n25q256a(uint32_t addr); | 41 | class AST2x00Machine(LinuxKernelTest): |
24 | 42 | ||
25 | +uint8_t m25p80_sfdp_mx25l25635e(uint32_t addr); | 43 | - def do_test_arm_aspeed(self, machine, image): |
44 | - self.set_machine(machine) | ||
45 | - self.vm.set_console() | ||
46 | - self.vm.add_args('-drive', 'file=' + image + ',if=mtd,format=raw', | ||
47 | - '-net', 'nic', '-snapshot') | ||
48 | - self.vm.launch() | ||
49 | - | ||
50 | - self.wait_for_console_pattern("U-Boot 2016.07") | ||
51 | - self.wait_for_console_pattern("## Loading kernel from FIT Image at 20080000") | ||
52 | - self.wait_for_console_pattern("Starting kernel ...") | ||
53 | - self.wait_for_console_pattern("Booting Linux on physical CPU 0x0") | ||
54 | - self.wait_for_console_pattern( | ||
55 | - "aspeed-smc 1e620000.spi: read control register: 203b0641") | ||
56 | - self.wait_for_console_pattern("ftgmac100 1e660000.ethernet eth0: irq ") | ||
57 | - self.wait_for_console_pattern("systemd[1]: Set hostname to") | ||
58 | - | ||
59 | - ASSET_ROMULUS_FLASH = Asset( | ||
60 | - ('https://github.com/openbmc/openbmc/releases/download/2.9.0/' | ||
61 | - 'obmc-phosphor-image-romulus.static.mtd'), | ||
62 | - '820341076803f1955bc31e647a512c79f9add4f5233d0697678bab4604c7bb25') | ||
63 | - | ||
64 | - def test_arm_ast2500_romulus_openbmc_v2_9_0(self): | ||
65 | - image_path = self.ASSET_ROMULUS_FLASH.fetch() | ||
66 | - | ||
67 | - self.do_test_arm_aspeed('romulus-bmc', image_path) | ||
68 | - | ||
69 | def do_test_arm_aspeed_buildroot_start(self, image, cpu_id, pattern='Aspeed EVB'): | ||
70 | self.require_netdev('user') | ||
71 | self.vm.set_console() | ||
72 | diff --git a/tests/functional/test_arm_aspeed_romulus.py b/tests/functional/test_arm_aspeed_romulus.py | ||
73 | new file mode 100644 | ||
74 | index XXXXXXX..XXXXXXX | ||
75 | --- /dev/null | ||
76 | +++ b/tests/functional/test_arm_aspeed_romulus.py | ||
77 | @@ -XXX,XX +XXX,XX @@ | ||
78 | +#!/usr/bin/env python3 | ||
79 | +# | ||
80 | +# Functional test that boots the ASPEED machines | ||
81 | +# | ||
82 | +# SPDX-License-Identifier: GPL-2.0-or-later | ||
83 | + | ||
84 | +from qemu_test import Asset | ||
85 | +from aspeed import AspeedTest | ||
86 | + | ||
87 | +class RomulusMachine(AspeedTest): | ||
88 | + | ||
89 | + ASSET_ROMULUS_FLASH = Asset( | ||
90 | + ('https://github.com/openbmc/openbmc/releases/download/2.9.0/' | ||
91 | + 'obmc-phosphor-image-romulus.static.mtd'), | ||
92 | + '820341076803f1955bc31e647a512c79f9add4f5233d0697678bab4604c7bb25') | ||
93 | + | ||
94 | + def test_arm_ast2500_romulus_openbmc_v2_9_0(self): | ||
95 | + image_path = self.ASSET_ROMULUS_FLASH.fetch() | ||
96 | + | ||
97 | + self.do_test_arm_aspeed('romulus-bmc', image_path) | ||
26 | + | 98 | + |
27 | + | 99 | + |
28 | #endif | 100 | +if __name__ == '__main__': |
29 | diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c | 101 | + AspeedTest.main() |
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/hw/block/m25p80.c | ||
32 | +++ b/hw/block/m25p80.c | ||
33 | @@ -XXX,XX +XXX,XX @@ static const FlashPartInfo known_devices[] = { | ||
34 | { INFO("mx25l12805d", 0xc22018, 0, 64 << 10, 256, 0) }, | ||
35 | { INFO("mx25l12855e", 0xc22618, 0, 64 << 10, 256, 0) }, | ||
36 | { INFO6("mx25l25635e", 0xc22019, 0xc22019, 64 << 10, 512, | ||
37 | - ER_4K | ER_32K) }, | ||
38 | + ER_4K | ER_32K), .sfdp_read = m25p80_sfdp_mx25l25635e }, | ||
39 | { INFO("mx25l25655e", 0xc22619, 0, 64 << 10, 512, 0) }, | ||
40 | { INFO("mx66l51235f", 0xc2201a, 0, 64 << 10, 1024, ER_4K | ER_32K) }, | ||
41 | { INFO("mx66u51235f", 0xc2253a, 0, 64 << 10, 1024, ER_4K | ER_32K) }, | ||
42 | diff --git a/hw/block/m25p80_sfdp.c b/hw/block/m25p80_sfdp.c | ||
43 | index XXXXXXX..XXXXXXX 100644 | ||
44 | --- a/hw/block/m25p80_sfdp.c | ||
45 | +++ b/hw/block/m25p80_sfdp.c | ||
46 | @@ -XXX,XX +XXX,XX @@ static const uint8_t sfdp_n25q256a[] = { | ||
47 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
48 | }; | ||
49 | define_sfdp_read(n25q256a); | ||
50 | + | ||
51 | + | ||
52 | +/* | ||
53 | + * Matronix | ||
54 | + */ | ||
55 | + | ||
56 | +/* mx25l25635e. No 4B opcodes */ | ||
57 | +static const uint8_t sfdp_mx25l25635e[] = { | ||
58 | + 0x53, 0x46, 0x44, 0x50, 0x00, 0x01, 0x01, 0xff, | ||
59 | + 0x00, 0x00, 0x01, 0x09, 0x30, 0x00, 0x00, 0xff, | ||
60 | + 0xc2, 0x00, 0x01, 0x04, 0x60, 0x00, 0x00, 0xff, | ||
61 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
62 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
63 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
64 | + 0xe5, 0x20, 0xf3, 0xff, 0xff, 0xff, 0xff, 0x0f, | ||
65 | + 0x44, 0xeb, 0x08, 0x6b, 0x08, 0x3b, 0x04, 0xbb, | ||
66 | + 0xee, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, | ||
67 | + 0xff, 0xff, 0x00, 0xff, 0x0c, 0x20, 0x0f, 0x52, | ||
68 | + 0x10, 0xd8, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
69 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
70 | + 0x00, 0x36, 0x00, 0x27, 0xf7, 0x4f, 0xff, 0xff, | ||
71 | + 0xd9, 0xc8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
72 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
73 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
74 | +}; | ||
75 | +define_sfdp_read(mx25l25635e) | ||
76 | -- | 102 | -- |
77 | 2.37.3 | 103 | 2.47.1 |
78 | 104 | ||
79 | 105 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | 1 | This moves the ast2500-evb tests to a new test file and extends the | |
2 | aspeed module with routines used to run the buildroot and sdk | ||
3 | tests. No changes in the test. | ||
4 | |||
5 | Reviewed-by: Thomas Huth <thuth@redhat.com> | ||
6 | Link: https://lore.kernel.org/r/20241206131132.520911-5-clg@redhat.com | ||
7 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | ||
8 | --- | ||
9 | tests/functional/aspeed.py | 33 ++++++++++++ | ||
10 | tests/functional/meson.build | 2 + | ||
11 | tests/functional/test_arm_aspeed.py | 44 --------------- | ||
12 | tests/functional/test_arm_aspeed_ast2500.py | 59 +++++++++++++++++++++ | ||
13 | 4 files changed, 94 insertions(+), 44 deletions(-) | ||
14 | create mode 100644 tests/functional/test_arm_aspeed_ast2500.py | ||
15 | |||
16 | diff --git a/tests/functional/aspeed.py b/tests/functional/aspeed.py | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/tests/functional/aspeed.py | ||
19 | +++ b/tests/functional/aspeed.py | ||
20 | @@ -XXX,XX +XXX,XX @@ | ||
21 | # | ||
22 | # SPDX-License-Identifier: GPL-2.0-or-later | ||
23 | |||
24 | +from qemu_test import exec_command_and_wait_for_pattern | ||
25 | from qemu_test import LinuxKernelTest | ||
26 | |||
27 | class AspeedTest(LinuxKernelTest): | ||
28 | @@ -XXX,XX +XXX,XX @@ def do_test_arm_aspeed(self, machine, image): | ||
29 | "aspeed-smc 1e620000.spi: read control register: 203b0641") | ||
30 | self.wait_for_console_pattern("ftgmac100 1e660000.ethernet eth0: irq ") | ||
31 | self.wait_for_console_pattern("systemd[1]: Set hostname to") | ||
32 | + | ||
33 | + def do_test_arm_aspeed_buildroot_start(self, image, cpu_id, pattern='Aspeed EVB'): | ||
34 | + self.require_netdev('user') | ||
35 | + self.vm.set_console() | ||
36 | + self.vm.add_args('-drive', 'file=' + image + ',if=mtd,format=raw,read-only=true', | ||
37 | + '-net', 'nic', '-net', 'user') | ||
38 | + self.vm.launch() | ||
39 | + | ||
40 | + self.wait_for_console_pattern('U-Boot 2019.04') | ||
41 | + self.wait_for_console_pattern('## Loading kernel from FIT Image') | ||
42 | + self.wait_for_console_pattern('Starting kernel ...') | ||
43 | + self.wait_for_console_pattern('Booting Linux on physical CPU ' + cpu_id) | ||
44 | + self.wait_for_console_pattern('lease of 10.0.2.15') | ||
45 | + # the line before login: | ||
46 | + self.wait_for_console_pattern(pattern) | ||
47 | + exec_command_and_wait_for_pattern(self, 'root', 'Password:') | ||
48 | + exec_command_and_wait_for_pattern(self, 'passw0rd', '#') | ||
49 | + | ||
50 | + def do_test_arm_aspeed_buildroot_poweroff(self): | ||
51 | + exec_command_and_wait_for_pattern(self, 'poweroff', | ||
52 | + 'reboot: System halted'); | ||
53 | + | ||
54 | + def do_test_arm_aspeed_sdk_start(self, image): | ||
55 | + self.require_netdev('user') | ||
56 | + self.vm.set_console() | ||
57 | + self.vm.add_args('-drive', 'file=' + image + ',if=mtd,format=raw', | ||
58 | + '-net', 'nic', '-net', 'user', '-snapshot') | ||
59 | + self.vm.launch() | ||
60 | + | ||
61 | + self.wait_for_console_pattern('U-Boot 2019.04') | ||
62 | + self.wait_for_console_pattern('## Loading kernel from FIT Image') | ||
63 | + self.wait_for_console_pattern('Starting kernel ...') | ||
64 | diff --git a/tests/functional/meson.build b/tests/functional/meson.build | ||
65 | index XXXXXXX..XXXXXXX 100644 | ||
66 | --- a/tests/functional/meson.build | ||
67 | +++ b/tests/functional/meson.build | ||
68 | @@ -XXX,XX +XXX,XX @@ test_timeouts = { | ||
69 | 'acpi_bits' : 420, | ||
70 | 'arm_aspeed_palmetto' : 120, | ||
71 | 'arm_aspeed_romulus' : 120, | ||
72 | + 'arm_aspeed_ast2500' : 480, | ||
73 | 'arm_aspeed' : 600, | ||
74 | 'arm_bpim2u' : 500, | ||
75 | 'arm_collie' : 180, | ||
76 | @@ -XXX,XX +XXX,XX @@ tests_arm_system_thorough = [ | ||
77 | 'arm_aspeed_ast1030', | ||
78 | 'arm_aspeed_palmetto', | ||
79 | 'arm_aspeed_romulus', | ||
80 | + 'arm_aspeed_ast2500', | ||
81 | 'arm_bpim2u', | ||
82 | 'arm_canona1100', | ||
83 | 'arm_collie', | ||
84 | diff --git a/tests/functional/test_arm_aspeed.py b/tests/functional/test_arm_aspeed.py | ||
85 | index XXXXXXX..XXXXXXX 100755 | ||
86 | --- a/tests/functional/test_arm_aspeed.py | ||
87 | +++ b/tests/functional/test_arm_aspeed.py | ||
88 | @@ -XXX,XX +XXX,XX @@ def do_test_arm_aspeed_buildroot_start(self, image, cpu_id, pattern='Aspeed EVB' | ||
89 | def do_test_arm_aspeed_buildroot_poweroff(self): | ||
90 | exec_command_and_wait_for_pattern(self, 'poweroff', | ||
91 | 'reboot: System halted'); | ||
92 | - | ||
93 | - ASSET_BR2_202311_AST2500_FLASH = Asset( | ||
94 | - ('https://github.com/legoater/qemu-aspeed-boot/raw/master/' | ||
95 | - 'images/ast2500-evb/buildroot-2023.11/flash.img'), | ||
96 | - 'c23db6160cf77d0258397eb2051162c8473a56c441417c52a91ba217186e715f') | ||
97 | - | ||
98 | - def test_arm_ast2500_evb_buildroot(self): | ||
99 | - self.set_machine('ast2500-evb') | ||
100 | - | ||
101 | - image_path = self.ASSET_BR2_202311_AST2500_FLASH.fetch() | ||
102 | - | ||
103 | - self.vm.add_args('-device', | ||
104 | - 'tmp105,bus=aspeed.i2c.bus.3,address=0x4d,id=tmp-test'); | ||
105 | - self.do_test_arm_aspeed_buildroot_start(image_path, '0x0', | ||
106 | - 'ast2500-evb login:') | ||
107 | - | ||
108 | - exec_command_and_wait_for_pattern(self, | ||
109 | - 'echo lm75 0x4d > /sys/class/i2c-dev/i2c-3/device/new_device', | ||
110 | - 'i2c i2c-3: new_device: Instantiated device lm75 at 0x4d'); | ||
111 | - exec_command_and_wait_for_pattern(self, | ||
112 | - 'cat /sys/class/hwmon/hwmon1/temp1_input', '0') | ||
113 | - self.vm.cmd('qom-set', path='/machine/peripheral/tmp-test', | ||
114 | - property='temperature', value=18000); | ||
115 | - exec_command_and_wait_for_pattern(self, | ||
116 | - 'cat /sys/class/hwmon/hwmon1/temp1_input', '18000') | ||
117 | - | ||
118 | - self.do_test_arm_aspeed_buildroot_poweroff() | ||
119 | - | ||
120 | ASSET_BR2_202311_AST2600_FLASH = Asset( | ||
121 | ('https://github.com/legoater/qemu-aspeed-boot/raw/master/' | ||
122 | 'images/ast2600-evb/buildroot-2023.11/flash.img'), | ||
123 | @@ -XXX,XX +XXX,XX @@ def do_test_arm_aspeed_sdk_start(self, image): | ||
124 | self.wait_for_console_pattern('## Loading kernel from FIT Image') | ||
125 | self.wait_for_console_pattern('Starting kernel ...') | ||
126 | |||
127 | - ASSET_SDK_V806_AST2500 = Asset( | ||
128 | - 'https://github.com/AspeedTech-BMC/openbmc/releases/download/v08.06/ast2500-default-obmc.tar.gz', | ||
129 | - 'e1755f3cadff69190438c688d52dd0f0d399b70a1e14b1d3d5540fc4851d38ca') | ||
130 | - | ||
131 | - def test_arm_ast2500_evb_sdk(self): | ||
132 | - self.set_machine('ast2500-evb') | ||
133 | - | ||
134 | - image_path = self.ASSET_SDK_V806_AST2500.fetch() | ||
135 | - | ||
136 | - archive_extract(image_path, self.workdir) | ||
137 | - | ||
138 | - self.do_test_arm_aspeed_sdk_start( | ||
139 | - self.workdir + '/ast2500-default/image-bmc') | ||
140 | - | ||
141 | - self.wait_for_console_pattern('ast2500-default login:') | ||
142 | - | ||
143 | ASSET_SDK_V806_AST2600_A2 = Asset( | ||
144 | 'https://github.com/AspeedTech-BMC/openbmc/releases/download/v08.06/ast2600-a2-obmc.tar.gz', | ||
145 | '9083506135f622d5e7351fcf7d4e1c7125cee5ba16141220c0ba88931f3681a4') | ||
146 | diff --git a/tests/functional/test_arm_aspeed_ast2500.py b/tests/functional/test_arm_aspeed_ast2500.py | ||
147 | new file mode 100644 | ||
148 | index XXXXXXX..XXXXXXX | ||
149 | --- /dev/null | ||
150 | +++ b/tests/functional/test_arm_aspeed_ast2500.py | ||
151 | @@ -XXX,XX +XXX,XX @@ | ||
152 | +#!/usr/bin/env python3 | ||
153 | +# | ||
154 | +# Functional test that boots the ASPEED machines | ||
155 | +# | ||
156 | +# SPDX-License-Identifier: GPL-2.0-or-later | ||
157 | + | ||
158 | +from qemu_test import Asset | ||
159 | +from aspeed import AspeedTest | ||
160 | +from qemu_test import exec_command_and_wait_for_pattern | ||
161 | +from qemu_test.utils import archive_extract | ||
162 | + | ||
163 | +class AST2500Machine(AspeedTest): | ||
164 | + | ||
165 | + ASSET_BR2_202311_AST2500_FLASH = Asset( | ||
166 | + ('https://github.com/legoater/qemu-aspeed-boot/raw/master/' | ||
167 | + 'images/ast2500-evb/buildroot-2023.11/flash.img'), | ||
168 | + 'c23db6160cf77d0258397eb2051162c8473a56c441417c52a91ba217186e715f') | ||
169 | + | ||
170 | + def test_arm_ast2500_evb_buildroot(self): | ||
171 | + self.set_machine('ast2500-evb') | ||
172 | + | ||
173 | + image_path = self.ASSET_BR2_202311_AST2500_FLASH.fetch() | ||
174 | + | ||
175 | + self.vm.add_args('-device', | ||
176 | + 'tmp105,bus=aspeed.i2c.bus.3,address=0x4d,id=tmp-test'); | ||
177 | + self.do_test_arm_aspeed_buildroot_start(image_path, '0x0', | ||
178 | + 'ast2500-evb login:') | ||
179 | + | ||
180 | + exec_command_and_wait_for_pattern(self, | ||
181 | + 'echo lm75 0x4d > /sys/class/i2c-dev/i2c-3/device/new_device', | ||
182 | + 'i2c i2c-3: new_device: Instantiated device lm75 at 0x4d'); | ||
183 | + exec_command_and_wait_for_pattern(self, | ||
184 | + 'cat /sys/class/hwmon/hwmon1/temp1_input', '0') | ||
185 | + self.vm.cmd('qom-set', path='/machine/peripheral/tmp-test', | ||
186 | + property='temperature', value=18000); | ||
187 | + exec_command_and_wait_for_pattern(self, | ||
188 | + 'cat /sys/class/hwmon/hwmon1/temp1_input', '18000') | ||
189 | + | ||
190 | + self.do_test_arm_aspeed_buildroot_poweroff() | ||
191 | + | ||
192 | + ASSET_SDK_V806_AST2500 = Asset( | ||
193 | + 'https://github.com/AspeedTech-BMC/openbmc/releases/download/v08.06/ast2500-default-obmc.tar.gz', | ||
194 | + 'e1755f3cadff69190438c688d52dd0f0d399b70a1e14b1d3d5540fc4851d38ca') | ||
195 | + | ||
196 | + def test_arm_ast2500_evb_sdk(self): | ||
197 | + self.set_machine('ast2500-evb') | ||
198 | + | ||
199 | + image_path = self.ASSET_SDK_V806_AST2500.fetch() | ||
200 | + | ||
201 | + archive_extract(image_path, self.workdir) | ||
202 | + | ||
203 | + self.do_test_arm_aspeed_sdk_start( | ||
204 | + self.workdir + '/ast2500-default/image-bmc') | ||
205 | + | ||
206 | + self.wait_for_console_pattern('ast2500-default login:') | ||
207 | + | ||
208 | + | ||
209 | +if __name__ == '__main__': | ||
210 | + AspeedTest.main() | ||
211 | -- | ||
212 | 2.47.1 | ||
213 | |||
214 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | This moves the ast2600-evb tests to a new test file. No changes in the | ||
2 | test. The routines used to run the buildroot and sdk tests are removed | ||
3 | from the test_arm_aspeed.py file because now unused. | ||
1 | 4 | ||
5 | Reviewed-by: Thomas Huth <thuth@redhat.com> | ||
6 | Link: https://lore.kernel.org/r/20241206131132.520911-6-clg@redhat.com | ||
7 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | ||
8 | --- | ||
9 | tests/functional/meson.build | 2 + | ||
10 | tests/functional/test_arm_aspeed.py | 155 -------------------- | ||
11 | tests/functional/test_arm_aspeed_ast2600.py | 143 ++++++++++++++++++ | ||
12 | 3 files changed, 145 insertions(+), 155 deletions(-) | ||
13 | create mode 100644 tests/functional/test_arm_aspeed_ast2600.py | ||
14 | |||
15 | diff --git a/tests/functional/meson.build b/tests/functional/meson.build | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/tests/functional/meson.build | ||
18 | +++ b/tests/functional/meson.build | ||
19 | @@ -XXX,XX +XXX,XX @@ test_timeouts = { | ||
20 | 'arm_aspeed_palmetto' : 120, | ||
21 | 'arm_aspeed_romulus' : 120, | ||
22 | 'arm_aspeed_ast2500' : 480, | ||
23 | + 'arm_aspeed_ast2600' : 720, | ||
24 | 'arm_aspeed' : 600, | ||
25 | 'arm_bpim2u' : 500, | ||
26 | 'arm_collie' : 180, | ||
27 | @@ -XXX,XX +XXX,XX @@ tests_arm_system_thorough = [ | ||
28 | 'arm_aspeed_palmetto', | ||
29 | 'arm_aspeed_romulus', | ||
30 | 'arm_aspeed_ast2500', | ||
31 | + 'arm_aspeed_ast2600', | ||
32 | 'arm_bpim2u', | ||
33 | 'arm_canona1100', | ||
34 | 'arm_collie', | ||
35 | diff --git a/tests/functional/test_arm_aspeed.py b/tests/functional/test_arm_aspeed.py | ||
36 | index XXXXXXX..XXXXXXX 100755 | ||
37 | --- a/tests/functional/test_arm_aspeed.py | ||
38 | +++ b/tests/functional/test_arm_aspeed.py | ||
39 | @@ -XXX,XX +XXX,XX @@ | ||
40 | from zipfile import ZipFile | ||
41 | from unittest import skipUnless | ||
42 | |||
43 | -class AST2x00Machine(LinuxKernelTest): | ||
44 | - | ||
45 | - def do_test_arm_aspeed_buildroot_start(self, image, cpu_id, pattern='Aspeed EVB'): | ||
46 | - self.require_netdev('user') | ||
47 | - self.vm.set_console() | ||
48 | - self.vm.add_args('-drive', 'file=' + image + ',if=mtd,format=raw,read-only=true', | ||
49 | - '-net', 'nic', '-net', 'user') | ||
50 | - self.vm.launch() | ||
51 | - | ||
52 | - self.wait_for_console_pattern('U-Boot 2019.04') | ||
53 | - self.wait_for_console_pattern('## Loading kernel from FIT Image') | ||
54 | - self.wait_for_console_pattern('Starting kernel ...') | ||
55 | - self.wait_for_console_pattern('Booting Linux on physical CPU ' + cpu_id) | ||
56 | - self.wait_for_console_pattern('lease of 10.0.2.15') | ||
57 | - # the line before login: | ||
58 | - self.wait_for_console_pattern(pattern) | ||
59 | - exec_command_and_wait_for_pattern(self, 'root', 'Password:') | ||
60 | - exec_command_and_wait_for_pattern(self, 'passw0rd', '#') | ||
61 | - | ||
62 | - def do_test_arm_aspeed_buildroot_poweroff(self): | ||
63 | - exec_command_and_wait_for_pattern(self, 'poweroff', | ||
64 | - 'reboot: System halted'); | ||
65 | - ASSET_BR2_202311_AST2600_FLASH = Asset( | ||
66 | - ('https://github.com/legoater/qemu-aspeed-boot/raw/master/' | ||
67 | - 'images/ast2600-evb/buildroot-2023.11/flash.img'), | ||
68 | - 'b62808daef48b438d0728ee07662290490ecfa65987bb91294cafb1bb7ad1a68') | ||
69 | - | ||
70 | - def test_arm_ast2600_evb_buildroot(self): | ||
71 | - self.set_machine('ast2600-evb') | ||
72 | - | ||
73 | - image_path = self.ASSET_BR2_202311_AST2600_FLASH.fetch() | ||
74 | - | ||
75 | - self.vm.add_args('-device', | ||
76 | - 'tmp105,bus=aspeed.i2c.bus.3,address=0x4d,id=tmp-test'); | ||
77 | - self.vm.add_args('-device', | ||
78 | - 'ds1338,bus=aspeed.i2c.bus.3,address=0x32'); | ||
79 | - self.vm.add_args('-device', | ||
80 | - 'i2c-echo,bus=aspeed.i2c.bus.3,address=0x42'); | ||
81 | - self.do_test_arm_aspeed_buildroot_start(image_path, '0xf00', | ||
82 | - 'ast2600-evb login:') | ||
83 | - | ||
84 | - exec_command_and_wait_for_pattern(self, | ||
85 | - 'echo lm75 0x4d > /sys/class/i2c-dev/i2c-3/device/new_device', | ||
86 | - 'i2c i2c-3: new_device: Instantiated device lm75 at 0x4d'); | ||
87 | - exec_command_and_wait_for_pattern(self, | ||
88 | - 'cat /sys/class/hwmon/hwmon1/temp1_input', '0') | ||
89 | - self.vm.cmd('qom-set', path='/machine/peripheral/tmp-test', | ||
90 | - property='temperature', value=18000); | ||
91 | - exec_command_and_wait_for_pattern(self, | ||
92 | - 'cat /sys/class/hwmon/hwmon1/temp1_input', '18000') | ||
93 | - | ||
94 | - exec_command_and_wait_for_pattern(self, | ||
95 | - 'echo ds1307 0x32 > /sys/class/i2c-dev/i2c-3/device/new_device', | ||
96 | - 'i2c i2c-3: new_device: Instantiated device ds1307 at 0x32'); | ||
97 | - year = time.strftime("%Y") | ||
98 | - exec_command_and_wait_for_pattern(self, 'hwclock -f /dev/rtc1', year); | ||
99 | - | ||
100 | - exec_command_and_wait_for_pattern(self, | ||
101 | - 'echo slave-24c02 0x1064 > /sys/bus/i2c/devices/i2c-3/new_device', | ||
102 | - 'i2c i2c-3: new_device: Instantiated device slave-24c02 at 0x64'); | ||
103 | - exec_command_and_wait_for_pattern(self, | ||
104 | - 'i2cset -y 3 0x42 0x64 0x00 0xaa i', '#'); | ||
105 | - exec_command_and_wait_for_pattern(self, | ||
106 | - 'hexdump /sys/bus/i2c/devices/3-1064/slave-eeprom', | ||
107 | - '0000000 ffaa ffff ffff ffff ffff ffff ffff ffff'); | ||
108 | - self.do_test_arm_aspeed_buildroot_poweroff() | ||
109 | - | ||
110 | - ASSET_BR2_202302_AST2600_TPM_FLASH = Asset( | ||
111 | - ('https://github.com/legoater/qemu-aspeed-boot/raw/master/' | ||
112 | - 'images/ast2600-evb/buildroot-2023.02-tpm/flash.img'), | ||
113 | - 'a46009ae8a5403a0826d607215e731a8c68d27c14c41e55331706b8f9c7bd997') | ||
114 | - | ||
115 | - @skipUnless(*has_cmd('swtpm')) | ||
116 | - def test_arm_ast2600_evb_buildroot_tpm(self): | ||
117 | - self.set_machine('ast2600-evb') | ||
118 | - | ||
119 | - image_path = self.ASSET_BR2_202302_AST2600_TPM_FLASH.fetch() | ||
120 | - | ||
121 | - tpmstate_dir = tempfile.TemporaryDirectory(prefix="qemu_") | ||
122 | - socket = os.path.join(tpmstate_dir.name, 'swtpm-socket') | ||
123 | - | ||
124 | - # We must put the TPM state dir in /tmp/, not the build dir, | ||
125 | - # because some distros use AppArmor to lock down swtpm and | ||
126 | - # restrict the set of locations it can access files in. | ||
127 | - subprocess.run(['swtpm', 'socket', '-d', '--tpm2', | ||
128 | - '--tpmstate', f'dir={tpmstate_dir.name}', | ||
129 | - '--ctrl', f'type=unixio,path={socket}']) | ||
130 | - | ||
131 | - self.vm.add_args('-chardev', f'socket,id=chrtpm,path={socket}') | ||
132 | - self.vm.add_args('-tpmdev', 'emulator,id=tpm0,chardev=chrtpm') | ||
133 | - self.vm.add_args('-device', | ||
134 | - 'tpm-tis-i2c,tpmdev=tpm0,bus=aspeed.i2c.bus.12,address=0x2e') | ||
135 | - self.do_test_arm_aspeed_buildroot_start(image_path, '0xf00', 'Aspeed AST2600 EVB') | ||
136 | - | ||
137 | - exec_command_and_wait_for_pattern(self, | ||
138 | - 'echo tpm_tis_i2c 0x2e > /sys/bus/i2c/devices/i2c-12/new_device', | ||
139 | - 'tpm_tis_i2c 12-002e: 2.0 TPM (device-id 0x1, rev-id 1)'); | ||
140 | - exec_command_and_wait_for_pattern(self, | ||
141 | - 'cat /sys/class/tpm/tpm0/pcr-sha256/0', | ||
142 | - 'B804724EA13F52A9072BA87FE8FDCC497DFC9DF9AA15B9088694639C431688E0'); | ||
143 | - | ||
144 | - self.do_test_arm_aspeed_buildroot_poweroff() | ||
145 | - | ||
146 | - def do_test_arm_aspeed_sdk_start(self, image): | ||
147 | - self.require_netdev('user') | ||
148 | - self.vm.set_console() | ||
149 | - self.vm.add_args('-drive', 'file=' + image + ',if=mtd,format=raw', | ||
150 | - '-net', 'nic', '-net', 'user', '-snapshot') | ||
151 | - self.vm.launch() | ||
152 | - | ||
153 | - self.wait_for_console_pattern('U-Boot 2019.04') | ||
154 | - self.wait_for_console_pattern('## Loading kernel from FIT Image') | ||
155 | - self.wait_for_console_pattern('Starting kernel ...') | ||
156 | - | ||
157 | - ASSET_SDK_V806_AST2600_A2 = Asset( | ||
158 | - 'https://github.com/AspeedTech-BMC/openbmc/releases/download/v08.06/ast2600-a2-obmc.tar.gz', | ||
159 | - '9083506135f622d5e7351fcf7d4e1c7125cee5ba16141220c0ba88931f3681a4') | ||
160 | - | ||
161 | - def test_arm_ast2600_evb_sdk(self): | ||
162 | - self.set_machine('ast2600-evb') | ||
163 | - | ||
164 | - image_path = self.ASSET_SDK_V806_AST2600_A2.fetch() | ||
165 | - | ||
166 | - archive_extract(image_path, self.workdir) | ||
167 | - | ||
168 | - self.vm.add_args('-device', | ||
169 | - 'tmp105,bus=aspeed.i2c.bus.5,address=0x4d,id=tmp-test'); | ||
170 | - self.vm.add_args('-device', | ||
171 | - 'ds1338,bus=aspeed.i2c.bus.5,address=0x32'); | ||
172 | - self.do_test_arm_aspeed_sdk_start( | ||
173 | - self.workdir + '/ast2600-a2/image-bmc') | ||
174 | - | ||
175 | - self.wait_for_console_pattern('ast2600-a2 login:') | ||
176 | - | ||
177 | - exec_command_and_wait_for_pattern(self, 'root', 'Password:') | ||
178 | - exec_command_and_wait_for_pattern(self, '0penBmc', 'root@ast2600-a2:~#') | ||
179 | - | ||
180 | - exec_command_and_wait_for_pattern(self, | ||
181 | - 'echo lm75 0x4d > /sys/class/i2c-dev/i2c-5/device/new_device', | ||
182 | - 'i2c i2c-5: new_device: Instantiated device lm75 at 0x4d'); | ||
183 | - exec_command_and_wait_for_pattern(self, | ||
184 | - 'cat /sys/class/hwmon/hwmon19/temp1_input', '0') | ||
185 | - self.vm.cmd('qom-set', path='/machine/peripheral/tmp-test', | ||
186 | - property='temperature', value=18000); | ||
187 | - exec_command_and_wait_for_pattern(self, | ||
188 | - 'cat /sys/class/hwmon/hwmon19/temp1_input', '18000') | ||
189 | - | ||
190 | - exec_command_and_wait_for_pattern(self, | ||
191 | - 'echo ds1307 0x32 > /sys/class/i2c-dev/i2c-5/device/new_device', | ||
192 | - 'i2c i2c-5: new_device: Instantiated device ds1307 at 0x32'); | ||
193 | - year = time.strftime("%Y") | ||
194 | - exec_command_and_wait_for_pattern(self, | ||
195 | - '/sbin/hwclock -f /dev/rtc1', year); | ||
196 | - | ||
197 | - | ||
198 | class AST2x00MachineMMC(LinuxKernelTest): | ||
199 | |||
200 | ASSET_RAINIER_EMMC = Asset( | ||
201 | diff --git a/tests/functional/test_arm_aspeed_ast2600.py b/tests/functional/test_arm_aspeed_ast2600.py | ||
202 | new file mode 100644 | ||
203 | index XXXXXXX..XXXXXXX | ||
204 | --- /dev/null | ||
205 | +++ b/tests/functional/test_arm_aspeed_ast2600.py | ||
206 | @@ -XXX,XX +XXX,XX @@ | ||
207 | +#!/usr/bin/env python3 | ||
208 | +# | ||
209 | +# Functional test that boots the ASPEED machines | ||
210 | +# | ||
211 | +# SPDX-License-Identifier: GPL-2.0-or-later | ||
212 | + | ||
213 | +import os | ||
214 | +import time | ||
215 | +import tempfile | ||
216 | +import subprocess | ||
217 | + | ||
218 | +from qemu_test import Asset | ||
219 | +from aspeed import AspeedTest | ||
220 | +from qemu_test import exec_command_and_wait_for_pattern | ||
221 | +from qemu_test import has_cmd | ||
222 | +from qemu_test.utils import archive_extract | ||
223 | +from unittest import skipUnless | ||
224 | + | ||
225 | +class AST2600Machine(AspeedTest): | ||
226 | + | ||
227 | + ASSET_BR2_202311_AST2600_FLASH = Asset( | ||
228 | + ('https://github.com/legoater/qemu-aspeed-boot/raw/master/' | ||
229 | + 'images/ast2600-evb/buildroot-2023.11/flash.img'), | ||
230 | + 'b62808daef48b438d0728ee07662290490ecfa65987bb91294cafb1bb7ad1a68') | ||
231 | + | ||
232 | + def test_arm_ast2600_evb_buildroot(self): | ||
233 | + self.set_machine('ast2600-evb') | ||
234 | + | ||
235 | + image_path = self.ASSET_BR2_202311_AST2600_FLASH.fetch() | ||
236 | + | ||
237 | + self.vm.add_args('-device', | ||
238 | + 'tmp105,bus=aspeed.i2c.bus.3,address=0x4d,id=tmp-test'); | ||
239 | + self.vm.add_args('-device', | ||
240 | + 'ds1338,bus=aspeed.i2c.bus.3,address=0x32'); | ||
241 | + self.vm.add_args('-device', | ||
242 | + 'i2c-echo,bus=aspeed.i2c.bus.3,address=0x42'); | ||
243 | + self.do_test_arm_aspeed_buildroot_start(image_path, '0xf00', | ||
244 | + 'ast2600-evb login:') | ||
245 | + | ||
246 | + exec_command_and_wait_for_pattern(self, | ||
247 | + 'echo lm75 0x4d > /sys/class/i2c-dev/i2c-3/device/new_device', | ||
248 | + 'i2c i2c-3: new_device: Instantiated device lm75 at 0x4d'); | ||
249 | + exec_command_and_wait_for_pattern(self, | ||
250 | + 'cat /sys/class/hwmon/hwmon1/temp1_input', '0') | ||
251 | + self.vm.cmd('qom-set', path='/machine/peripheral/tmp-test', | ||
252 | + property='temperature', value=18000); | ||
253 | + exec_command_and_wait_for_pattern(self, | ||
254 | + 'cat /sys/class/hwmon/hwmon1/temp1_input', '18000') | ||
255 | + | ||
256 | + exec_command_and_wait_for_pattern(self, | ||
257 | + 'echo ds1307 0x32 > /sys/class/i2c-dev/i2c-3/device/new_device', | ||
258 | + 'i2c i2c-3: new_device: Instantiated device ds1307 at 0x32'); | ||
259 | + year = time.strftime("%Y") | ||
260 | + exec_command_and_wait_for_pattern(self, 'hwclock -f /dev/rtc1', year); | ||
261 | + | ||
262 | + exec_command_and_wait_for_pattern(self, | ||
263 | + 'echo slave-24c02 0x1064 > /sys/bus/i2c/devices/i2c-3/new_device', | ||
264 | + 'i2c i2c-3: new_device: Instantiated device slave-24c02 at 0x64'); | ||
265 | + exec_command_and_wait_for_pattern(self, | ||
266 | + 'i2cset -y 3 0x42 0x64 0x00 0xaa i', '#'); | ||
267 | + exec_command_and_wait_for_pattern(self, | ||
268 | + 'hexdump /sys/bus/i2c/devices/3-1064/slave-eeprom', | ||
269 | + '0000000 ffaa ffff ffff ffff ffff ffff ffff ffff'); | ||
270 | + self.do_test_arm_aspeed_buildroot_poweroff() | ||
271 | + | ||
272 | + ASSET_BR2_202302_AST2600_TPM_FLASH = Asset( | ||
273 | + ('https://github.com/legoater/qemu-aspeed-boot/raw/master/' | ||
274 | + 'images/ast2600-evb/buildroot-2023.02-tpm/flash.img'), | ||
275 | + 'a46009ae8a5403a0826d607215e731a8c68d27c14c41e55331706b8f9c7bd997') | ||
276 | + | ||
277 | + @skipUnless(*has_cmd('swtpm')) | ||
278 | + def test_arm_ast2600_evb_buildroot_tpm(self): | ||
279 | + self.set_machine('ast2600-evb') | ||
280 | + | ||
281 | + image_path = self.ASSET_BR2_202302_AST2600_TPM_FLASH.fetch() | ||
282 | + | ||
283 | + tpmstate_dir = tempfile.TemporaryDirectory(prefix="qemu_") | ||
284 | + socket = os.path.join(tpmstate_dir.name, 'swtpm-socket') | ||
285 | + | ||
286 | + # We must put the TPM state dir in /tmp/, not the build dir, | ||
287 | + # because some distros use AppArmor to lock down swtpm and | ||
288 | + # restrict the set of locations it can access files in. | ||
289 | + subprocess.run(['swtpm', 'socket', '-d', '--tpm2', | ||
290 | + '--tpmstate', f'dir={tpmstate_dir.name}', | ||
291 | + '--ctrl', f'type=unixio,path={socket}']) | ||
292 | + | ||
293 | + self.vm.add_args('-chardev', f'socket,id=chrtpm,path={socket}') | ||
294 | + self.vm.add_args('-tpmdev', 'emulator,id=tpm0,chardev=chrtpm') | ||
295 | + self.vm.add_args('-device', | ||
296 | + 'tpm-tis-i2c,tpmdev=tpm0,bus=aspeed.i2c.bus.12,address=0x2e') | ||
297 | + self.do_test_arm_aspeed_buildroot_start(image_path, '0xf00', 'Aspeed AST2600 EVB') | ||
298 | + | ||
299 | + exec_command_and_wait_for_pattern(self, | ||
300 | + 'echo tpm_tis_i2c 0x2e > /sys/bus/i2c/devices/i2c-12/new_device', | ||
301 | + 'tpm_tis_i2c 12-002e: 2.0 TPM (device-id 0x1, rev-id 1)'); | ||
302 | + exec_command_and_wait_for_pattern(self, | ||
303 | + 'cat /sys/class/tpm/tpm0/pcr-sha256/0', | ||
304 | + 'B804724EA13F52A9072BA87FE8FDCC497DFC9DF9AA15B9088694639C431688E0'); | ||
305 | + | ||
306 | + self.do_test_arm_aspeed_buildroot_poweroff() | ||
307 | + | ||
308 | + ASSET_SDK_V806_AST2600_A2 = Asset( | ||
309 | + 'https://github.com/AspeedTech-BMC/openbmc/releases/download/v08.06/ast2600-a2-obmc.tar.gz', | ||
310 | + '9083506135f622d5e7351fcf7d4e1c7125cee5ba16141220c0ba88931f3681a4') | ||
311 | + | ||
312 | + def test_arm_ast2600_evb_sdk(self): | ||
313 | + self.set_machine('ast2600-evb') | ||
314 | + | ||
315 | + image_path = self.ASSET_SDK_V806_AST2600_A2.fetch() | ||
316 | + | ||
317 | + archive_extract(image_path, self.workdir) | ||
318 | + | ||
319 | + self.vm.add_args('-device', | ||
320 | + 'tmp105,bus=aspeed.i2c.bus.5,address=0x4d,id=tmp-test'); | ||
321 | + self.vm.add_args('-device', | ||
322 | + 'ds1338,bus=aspeed.i2c.bus.5,address=0x32'); | ||
323 | + self.do_test_arm_aspeed_sdk_start( | ||
324 | + self.workdir + '/ast2600-a2/image-bmc') | ||
325 | + | ||
326 | + self.wait_for_console_pattern('ast2600-a2 login:') | ||
327 | + | ||
328 | + exec_command_and_wait_for_pattern(self, 'root', 'Password:') | ||
329 | + exec_command_and_wait_for_pattern(self, '0penBmc', 'root@ast2600-a2:~#') | ||
330 | + | ||
331 | + exec_command_and_wait_for_pattern(self, | ||
332 | + 'echo lm75 0x4d > /sys/class/i2c-dev/i2c-5/device/new_device', | ||
333 | + 'i2c i2c-5: new_device: Instantiated device lm75 at 0x4d'); | ||
334 | + exec_command_and_wait_for_pattern(self, | ||
335 | + 'cat /sys/class/hwmon/hwmon19/temp1_input', '0') | ||
336 | + self.vm.cmd('qom-set', path='/machine/peripheral/tmp-test', | ||
337 | + property='temperature', value=18000); | ||
338 | + exec_command_and_wait_for_pattern(self, | ||
339 | + 'cat /sys/class/hwmon/hwmon19/temp1_input', '18000') | ||
340 | + | ||
341 | + exec_command_and_wait_for_pattern(self, | ||
342 | + 'echo ds1307 0x32 > /sys/class/i2c-dev/i2c-5/device/new_device', | ||
343 | + 'i2c i2c-5: new_device: Instantiated device ds1307 at 0x32'); | ||
344 | + year = time.strftime("%Y") | ||
345 | + exec_command_and_wait_for_pattern(self, | ||
346 | + '/sbin/hwclock -f /dev/rtc1', year); | ||
347 | + | ||
348 | +if __name__ == '__main__': | ||
349 | + AspeedTest.main() | ||
350 | -- | ||
351 | 2.47.1 | ||
352 | |||
353 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | This simply moves the rainier-bmc test to a new test file. No changes | ||
2 | in the test. The test_arm_aspeed.py is deleted. | ||
1 | 3 | ||
4 | Reviewed-by: Thomas Huth <thuth@redhat.com> | ||
5 | Link: https://lore.kernel.org/r/20241206131132.520911-7-clg@redhat.com | ||
6 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | ||
7 | --- | ||
8 | tests/functional/meson.build | 4 ++-- | ||
9 | ...m_aspeed.py => test_arm_aspeed_rainier.py} | 22 +++++-------------- | ||
10 | 2 files changed, 7 insertions(+), 19 deletions(-) | ||
11 | rename tests/functional/{test_arm_aspeed.py => test_arm_aspeed_rainier.py} (71%) | ||
12 | mode change 100755 => 100644 | ||
13 | |||
14 | diff --git a/tests/functional/meson.build b/tests/functional/meson.build | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/tests/functional/meson.build | ||
17 | +++ b/tests/functional/meson.build | ||
18 | @@ -XXX,XX +XXX,XX @@ test_timeouts = { | ||
19 | 'arm_aspeed_romulus' : 120, | ||
20 | 'arm_aspeed_ast2500' : 480, | ||
21 | 'arm_aspeed_ast2600' : 720, | ||
22 | - 'arm_aspeed' : 600, | ||
23 | + 'arm_aspeed_rainier' : 240, | ||
24 | 'arm_bpim2u' : 500, | ||
25 | 'arm_collie' : 180, | ||
26 | 'arm_orangepi' : 540, | ||
27 | @@ -XXX,XX +XXX,XX @@ tests_alpha_system_thorough = [ | ||
28 | ] | ||
29 | |||
30 | tests_arm_system_thorough = [ | ||
31 | - 'arm_aspeed', | ||
32 | 'arm_aspeed_ast1030', | ||
33 | 'arm_aspeed_palmetto', | ||
34 | 'arm_aspeed_romulus', | ||
35 | 'arm_aspeed_ast2500', | ||
36 | 'arm_aspeed_ast2600', | ||
37 | + 'arm_aspeed_rainier', | ||
38 | 'arm_bpim2u', | ||
39 | 'arm_canona1100', | ||
40 | 'arm_collie', | ||
41 | diff --git a/tests/functional/test_arm_aspeed.py b/tests/functional/test_arm_aspeed_rainier.py | ||
42 | old mode 100755 | ||
43 | new mode 100644 | ||
44 | similarity index 71% | ||
45 | rename from tests/functional/test_arm_aspeed.py | ||
46 | rename to tests/functional/test_arm_aspeed_rainier.py | ||
47 | index XXXXXXX..XXXXXXX | ||
48 | --- a/tests/functional/test_arm_aspeed.py | ||
49 | +++ b/tests/functional/test_arm_aspeed_rainier.py | ||
50 | @@ -XXX,XX +XXX,XX @@ | ||
51 | #!/usr/bin/env python3 | ||
52 | # | ||
53 | -# Functional test that boots the ASPEED SoCs with firmware | ||
54 | -# | ||
55 | -# Copyright (C) 2022 ASPEED Technology Inc | ||
56 | +# Functional test that boots the ASPEED machines | ||
57 | # | ||
58 | # SPDX-License-Identifier: GPL-2.0-or-later | ||
59 | |||
60 | -import os | ||
61 | -import time | ||
62 | -import subprocess | ||
63 | -import tempfile | ||
64 | - | ||
65 | -from qemu_test import LinuxKernelTest, Asset | ||
66 | -from qemu_test import exec_command_and_wait_for_pattern | ||
67 | -from qemu_test import interrupt_interactive_console_until_pattern | ||
68 | -from qemu_test import has_cmd | ||
69 | -from qemu_test.utils import archive_extract | ||
70 | -from zipfile import ZipFile | ||
71 | -from unittest import skipUnless | ||
72 | +from qemu_test import Asset | ||
73 | +from aspeed import AspeedTest | ||
74 | |||
75 | -class AST2x00MachineMMC(LinuxKernelTest): | ||
76 | +class RainierMachine(AspeedTest): | ||
77 | |||
78 | ASSET_RAINIER_EMMC = Asset( | ||
79 | ('https://fileserver.linaro.org/s/B6pJTwWEkzSDi36/download/' | ||
80 | @@ -XXX,XX +XXX,XX @@ def test_arm_aspeed_emmc_boot(self): | ||
81 | self.wait_for_console_pattern('IBM eBMC (OpenBMC for IBM Enterprise') | ||
82 | |||
83 | if __name__ == '__main__': | ||
84 | - LinuxKernelTest.main() | ||
85 | + AspeedTest.main() | ||
86 | -- | ||
87 | 2.47.1 | ||
88 | |||
89 | diff view generated by jsdifflib |
1 | A mx25l25635f chip model is generally found on these machines. It's | 1 | This simply moves the debian boot test from the avocado testsuite to |
---|---|---|---|
2 | newer and uses 4B opcodes which is better to exercise the support in | 2 | the new functional testsuite. No changes in the test. |
3 | the Linux kernel. | ||
4 | 3 | ||
5 | Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com> | 4 | Reviewed-by: Thomas Huth <thuth@redhat.com> |
6 | Message-Id: <20220722063602.128144-9-clg@kaod.org> | 5 | Link: https://lore.kernel.org/r/20241206131132.520911-8-clg@redhat.com |
7 | Message-Id: <20221013161241.2805140-11-clg@kaod.org> | 6 | Signed-off-by: Cédric Le Goater <clg@redhat.com> |
8 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
9 | --- | 7 | --- |
10 | hw/arm/aspeed.c | 6 +++--- | 8 | tests/avocado/boot_linux_console.py | 26 --------------------- |
11 | 1 file changed, 3 insertions(+), 3 deletions(-) | 9 | tests/functional/test_arm_aspeed_rainier.py | 24 +++++++++++++++++++ |
10 | 2 files changed, 24 insertions(+), 26 deletions(-) | ||
12 | 11 | ||
13 | diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c | 12 | diff --git a/tests/avocado/boot_linux_console.py b/tests/avocado/boot_linux_console.py |
14 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/arm/aspeed.c | 14 | --- a/tests/avocado/boot_linux_console.py |
16 | +++ b/hw/arm/aspeed.c | 15 | +++ b/tests/avocado/boot_linux_console.py |
17 | @@ -XXX,XX +XXX,XX @@ static void aspeed_machine_palmetto_class_init(ObjectClass *oc, void *data) | 16 | @@ -XXX,XX +XXX,XX @@ def test_arm_quanta_gsj_initrd(self): |
18 | amc->soc_name = "ast2400-a1"; | 17 | self.wait_for_console_pattern('CPU1: thread -1, cpu 1, socket 0') |
19 | amc->hw_strap1 = PALMETTO_BMC_HW_STRAP1; | 18 | self.wait_for_console_pattern( |
20 | amc->fmc_model = "n25q256a"; | 19 | 'Give root password for system maintenance') |
21 | - amc->spi_model = "mx25l25635e"; | 20 | - |
22 | + amc->spi_model = "mx25l25635f"; | 21 | - def test_arm_ast2600_debian(self): |
23 | amc->num_cs = 1; | 22 | - """ |
24 | amc->i2c_init = palmetto_bmc_i2c_init; | 23 | - :avocado: tags=arch:arm |
25 | mc->default_ram_size = 256 * MiB; | 24 | - :avocado: tags=machine:rainier-bmc |
26 | @@ -XXX,XX +XXX,XX @@ static void aspeed_machine_ast2500_evb_class_init(ObjectClass *oc, void *data) | 25 | - """ |
27 | amc->soc_name = "ast2500-a1"; | 26 | - deb_url = ('http://snapshot.debian.org/archive/debian/' |
28 | amc->hw_strap1 = AST2500_EVB_HW_STRAP1; | 27 | - '20220606T211338Z/' |
29 | amc->fmc_model = "mx25l25635e"; | 28 | - 'pool/main/l/linux/' |
30 | - amc->spi_model = "mx25l25635e"; | 29 | - 'linux-image-5.17.0-2-armmp_5.17.6-1%2Bb1_armhf.deb') |
31 | + amc->spi_model = "mx25l25635f"; | 30 | - deb_hash = '8acb2b4439faedc2f3ed4bdb2847ad4f6e0491f73debaeb7f660c8abe4dcdc0e' |
32 | amc->num_cs = 1; | 31 | - deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash, |
33 | amc->i2c_init = ast2500_evb_i2c_init; | 32 | - algorithm='sha256') |
34 | mc->default_ram_size = 512 * MiB; | 33 | - kernel_path = self.extract_from_deb(deb_path, '/boot/vmlinuz-5.17.0-2-armmp') |
35 | @@ -XXX,XX +XXX,XX @@ static void aspeed_machine_witherspoon_class_init(ObjectClass *oc, void *data) | 34 | - dtb_path = self.extract_from_deb(deb_path, |
36 | mc->desc = "OpenPOWER Witherspoon BMC (ARM1176)"; | 35 | - '/usr/lib/linux-image-5.17.0-2-armmp/aspeed-bmc-ibm-rainier.dtb') |
37 | amc->soc_name = "ast2500-a1"; | 36 | - |
38 | amc->hw_strap1 = WITHERSPOON_BMC_HW_STRAP1; | 37 | - self.vm.set_console() |
39 | - amc->fmc_model = "mx25l25635e"; | 38 | - self.vm.add_args('-kernel', kernel_path, |
40 | + amc->fmc_model = "mx25l25635f"; | 39 | - '-dtb', dtb_path, |
41 | amc->spi_model = "mx66l1g45g"; | 40 | - '-net', 'nic') |
42 | amc->num_cs = 2; | 41 | - self.vm.launch() |
43 | amc->i2c_init = witherspoon_bmc_i2c_init; | 42 | - self.wait_for_console_pattern("Booting Linux on physical CPU 0xf00") |
43 | - self.wait_for_console_pattern("SMP: Total of 2 processors activated") | ||
44 | - self.wait_for_console_pattern("No filesystem could mount root") | ||
45 | - | ||
46 | diff --git a/tests/functional/test_arm_aspeed_rainier.py b/tests/functional/test_arm_aspeed_rainier.py | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/tests/functional/test_arm_aspeed_rainier.py | ||
49 | +++ b/tests/functional/test_arm_aspeed_rainier.py | ||
50 | @@ -XXX,XX +XXX,XX @@ def test_arm_aspeed_emmc_boot(self): | ||
51 | self.wait_for_console_pattern('mmcblk0: p1 p2 p3 p4 p5 p6 p7') | ||
52 | self.wait_for_console_pattern('IBM eBMC (OpenBMC for IBM Enterprise') | ||
53 | |||
54 | + ASSET_DEBIAN_LINUX_ARMHF_DEB = Asset( | ||
55 | + ('http://snapshot.debian.org/archive/debian/20220606T211338Z/pool/main/l/linux/linux-image-5.17.0-2-armmp_5.17.6-1%2Bb1_armhf.deb'), | ||
56 | + '8acb2b4439faedc2f3ed4bdb2847ad4f6e0491f73debaeb7f660c8abe4dcdc0e') | ||
57 | + | ||
58 | + def test_arm_debian_kernel_boot(self): | ||
59 | + self.set_machine('rainier-bmc') | ||
60 | + | ||
61 | + deb_path = self.ASSET_DEBIAN_LINUX_ARMHF_DEB.fetch() | ||
62 | + | ||
63 | + kernel_path = self.extract_from_deb(deb_path, '/boot/vmlinuz-5.17.0-2-armmp') | ||
64 | + dtb_path = self.extract_from_deb(deb_path, | ||
65 | + '/usr/lib/linux-image-5.17.0-2-armmp/aspeed-bmc-ibm-rainier.dtb') | ||
66 | + | ||
67 | + self.vm.set_console() | ||
68 | + self.vm.add_args('-kernel', kernel_path, | ||
69 | + '-dtb', dtb_path, | ||
70 | + '-net', 'nic') | ||
71 | + self.vm.launch() | ||
72 | + | ||
73 | + self.wait_for_console_pattern("Booting Linux on physical CPU 0xf00") | ||
74 | + self.wait_for_console_pattern("SMP: Total of 2 processors activated") | ||
75 | + self.wait_for_console_pattern("No filesystem could mount root") | ||
76 | + | ||
77 | + | ||
78 | if __name__ == '__main__': | ||
79 | AspeedTest.main() | ||
44 | -- | 80 | -- |
45 | 2.37.3 | 81 | 2.47.1 |
46 | 82 | ||
47 | 83 | diff view generated by jsdifflib |
1 | The SFDP table size is 0x100 bytes long. Only the mandatory table for | 1 | From: Jamin Lin <jamin_lin@aspeedtech.com> |
---|---|---|---|
2 | basic features is available at byte 0x80. | ||
3 | 2 | ||
4 | Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com> | 3 | So far, the test cases are used for testing SMC model with AST2400 BMC. |
5 | Message-Id: <20220722063602.128144-7-clg@kaod.org> | 4 | However, AST2400 is end off live and ASPEED is no longer support this SOC. |
6 | Message-Id: <20221013161241.2805140-8-clg@kaod.org> | 5 | To test SMC model for AST2500, AST2600 and AST1030, move the test cases |
7 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 6 | from main to test_palmetto_bmc function. |
7 | |||
8 | Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com> | ||
9 | Reviewed-by: Cédric Le Goater <clg@redhat.com> | ||
10 | Link: https://lore.kernel.org/r/20241127091543.1243114-2-jamin_lin@aspeedtech.com | ||
11 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | ||
8 | --- | 12 | --- |
9 | hw/block/m25p80_sfdp.h | 2 ++ | 13 | tests/qtest/aspeed_smc-test.c | 16 ++++++++++++---- |
10 | hw/block/m25p80.c | 3 ++- | 14 | 1 file changed, 12 insertions(+), 4 deletions(-) |
11 | hw/block/m25p80_sfdp.c | 40 ++++++++++++++++++++++++++++++++++++++++ | ||
12 | 3 files changed, 44 insertions(+), 1 deletion(-) | ||
13 | 15 | ||
14 | diff --git a/hw/block/m25p80_sfdp.h b/hw/block/m25p80_sfdp.h | 16 | diff --git a/tests/qtest/aspeed_smc-test.c b/tests/qtest/aspeed_smc-test.c |
15 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/block/m25p80_sfdp.h | 18 | --- a/tests/qtest/aspeed_smc-test.c |
17 | +++ b/hw/block/m25p80_sfdp.h | 19 | +++ b/tests/qtest/aspeed_smc-test.c |
18 | @@ -XXX,XX +XXX,XX @@ uint8_t m25p80_sfdp_mx25l25635e(uint32_t addr); | 20 | @@ -XXX,XX +XXX,XX @@ static void test_write_block_protect_bottom_bit(void) |
19 | uint8_t m25p80_sfdp_mx25l25635f(uint32_t addr); | 21 | flash_reset(); |
20 | uint8_t m25p80_sfdp_mx66l1g45g(uint32_t addr); | 22 | } |
21 | 23 | ||
22 | +uint8_t m25p80_sfdp_w25q256(uint32_t addr); | 24 | -int main(int argc, char **argv) |
25 | +static int test_palmetto_bmc(void) | ||
26 | { | ||
27 | g_autofree char *tmp_path = NULL; | ||
28 | int ret; | ||
29 | int fd; | ||
30 | |||
31 | - g_test_init(&argc, &argv, NULL); | ||
32 | - | ||
33 | fd = g_file_open_tmp("qtest.m25p80.XXXXXX", &tmp_path, NULL); | ||
34 | g_assert(fd >= 0); | ||
35 | ret = ftruncate(fd, FLASH_SIZE); | ||
36 | @@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv) | ||
37 | |||
38 | flash_reset(); | ||
39 | ret = g_test_run(); | ||
40 | - | ||
41 | qtest_quit(global_qtest); | ||
42 | unlink(tmp_path); | ||
23 | + | 43 | + |
24 | #endif | 44 | + return ret; |
25 | diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c | 45 | +} |
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/hw/block/m25p80.c | ||
28 | +++ b/hw/block/m25p80.c | ||
29 | @@ -XXX,XX +XXX,XX @@ static const FlashPartInfo known_devices[] = { | ||
30 | { INFO("w25q64", 0xef4017, 0, 64 << 10, 128, ER_4K) }, | ||
31 | { INFO("w25q80", 0xef5014, 0, 64 << 10, 16, ER_4K) }, | ||
32 | { INFO("w25q80bl", 0xef4014, 0, 64 << 10, 16, ER_4K) }, | ||
33 | - { INFO("w25q256", 0xef4019, 0, 64 << 10, 512, ER_4K) }, | ||
34 | + { INFO("w25q256", 0xef4019, 0, 64 << 10, 512, ER_4K), | ||
35 | + .sfdp_read = m25p80_sfdp_w25q256 }, | ||
36 | { INFO("w25q512jv", 0xef4020, 0, 64 << 10, 1024, ER_4K) }, | ||
37 | { INFO("w25q01jvq", 0xef4021, 0, 64 << 10, 2048, ER_4K) }, | ||
38 | }; | ||
39 | diff --git a/hw/block/m25p80_sfdp.c b/hw/block/m25p80_sfdp.c | ||
40 | index XXXXXXX..XXXXXXX 100644 | ||
41 | --- a/hw/block/m25p80_sfdp.c | ||
42 | +++ b/hw/block/m25p80_sfdp.c | ||
43 | @@ -XXX,XX +XXX,XX @@ static const uint8_t sfdp_mx66l1g45g[] = { | ||
44 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
45 | }; | ||
46 | define_sfdp_read(mx66l1g45g); | ||
47 | + | 46 | + |
48 | +/* | 47 | +int main(int argc, char **argv) |
49 | + * Windbond | 48 | +{ |
50 | + */ | 49 | + int ret; |
51 | + | 50 | + |
52 | +static const uint8_t sfdp_w25q256[] = { | 51 | + g_test_init(&argc, &argv, NULL); |
53 | + 0x53, 0x46, 0x44, 0x50, 0x00, 0x01, 0x00, 0xff, | 52 | + ret = test_palmetto_bmc(); |
54 | + 0x00, 0x00, 0x01, 0x09, 0x80, 0x00, 0x00, 0xff, | 53 | + |
55 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 54 | return ret; |
56 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 55 | } |
57 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
58 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
59 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
60 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
61 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
62 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
63 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
64 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
65 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
66 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
67 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
68 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
69 | + 0xe5, 0x20, 0xf3, 0xff, 0xff, 0xff, 0xff, 0x0f, | ||
70 | + 0x44, 0xeb, 0x08, 0x6b, 0x08, 0x3b, 0x42, 0xbb, | ||
71 | + 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, | ||
72 | + 0xff, 0xff, 0x21, 0xeb, 0x0c, 0x20, 0x0f, 0x52, | ||
73 | + 0x10, 0xd8, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, | ||
74 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
75 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
76 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
77 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
78 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
79 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
80 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
81 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
82 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
83 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
84 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
85 | +}; | ||
86 | +define_sfdp_read(w25q256); | ||
87 | -- | 56 | -- |
88 | 2.37.3 | 57 | 2.47.1 |
89 | 58 | ||
90 | 59 | diff view generated by jsdifflib |
1 | From: Alex Bennée <alex.bennee@linaro.org> | 1 | From: Jamin Lin <jamin_lin@aspeedtech.com> |
---|---|---|---|
2 | 2 | ||
3 | Investigating why some BMC models are so slow compared to a plain ARM | 3 | Currently, these test cases are only used for testing fmc_cs0 for AST2400. |
4 | virt machines I did some profiling of: | 4 | To test others BMC SOCs, introduces a new TestData structure. |
5 | Users can set the spi base address, flash base address, jedesc id and so on | ||
6 | for different BMC SOCs and flash model testing. | ||
5 | 7 | ||
6 | ./qemu-system-arm -M romulus-bmc -nic user \ | 8 | Introduce new helper functions to make the test case more readable. |
7 | -drive | ||
8 | file=obmc-phosphor-image-romulus.static.mtd,format=raw,if=mtd \ | ||
9 | -nographic -serial mon:stdio | ||
10 | 9 | ||
11 | And saw that object_class_dynamic_cast_assert was dominating the | 10 | Set spi base address 0x1E620000, flash_base address 0x20000000 |
12 | profile times. We have a number of cases in this model of the SSI bus. | 11 | and jedec id 0x20ba19 for fmc_cs0 with n25q256a flash for AST2400 |
13 | As the class is static once the object is created we just cache it and | 12 | SMC model testing. |
14 | use it instead of the dynamic case macros. | ||
15 | 13 | ||
16 | Profiling against: | 14 | To pass the TestData into the test case, replace qtest_add_func with |
15 | qtest_add_data_func. | ||
17 | 16 | ||
18 | ./tests/venv/bin/avocado run \ | 17 | Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com> |
19 | tests/avocado/machine_aspeed.py:test_arm_ast2500_romulus_openbmc_v2_9_0 | 18 | Reviewed-by: Cédric Le Goater <clg@redhat.com> |
19 | Link: https://lore.kernel.org/r/20241127091543.1243114-3-jamin_lin@aspeedtech.com | ||
20 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | ||
21 | --- | ||
22 | tests/qtest/aspeed_smc-test.c | 546 +++++++++++++++++++--------------- | ||
23 | 1 file changed, 299 insertions(+), 247 deletions(-) | ||
20 | 24 | ||
21 | Before: 35.565 s ± 0.087 s | 25 | diff --git a/tests/qtest/aspeed_smc-test.c b/tests/qtest/aspeed_smc-test.c |
22 | After: 15.713 s ± 0.287 s | ||
23 | |||
24 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | ||
25 | Cc: Cédric Le Goater <clg@kaod.org> | ||
26 | Tested-by: Cédric Le Goater <clg@kaod.org> | ||
27 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
28 | Message-Id: <20220811151413.3350684-6-alex.bennee@linaro.org> | ||
29 | Message-Id: <20220923084803.498337-6-clg@kaod.org> | ||
30 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
31 | --- | ||
32 | include/hw/ssi/ssi.h | 3 +++ | ||
33 | hw/ssi/ssi.c | 18 ++++++++---------- | ||
34 | 2 files changed, 11 insertions(+), 10 deletions(-) | ||
35 | |||
36 | diff --git a/include/hw/ssi/ssi.h b/include/hw/ssi/ssi.h | ||
37 | index XXXXXXX..XXXXXXX 100644 | 26 | index XXXXXXX..XXXXXXX 100644 |
38 | --- a/include/hw/ssi/ssi.h | 27 | --- a/tests/qtest/aspeed_smc-test.c |
39 | +++ b/include/hw/ssi/ssi.h | 28 | +++ b/tests/qtest/aspeed_smc-test.c |
40 | @@ -XXX,XX +XXX,XX @@ struct SSIPeripheralClass { | 29 | @@ -XXX,XX +XXX,XX @@ |
41 | struct SSIPeripheral { | 30 | #define CTRL_USERMODE 0x3 |
42 | DeviceState parent_obj; | 31 | #define SR_WEL BIT(1) |
43 | 32 | ||
44 | + /* cache the class */ | 33 | -#define ASPEED_FMC_BASE 0x1E620000 |
45 | + SSIPeripheralClass *spc; | 34 | -#define ASPEED_FLASH_BASE 0x20000000 |
35 | - | ||
36 | /* | ||
37 | * Flash commands | ||
38 | */ | ||
39 | @@ -XXX,XX +XXX,XX @@ enum { | ||
40 | ERASE_SECTOR = 0xd8, | ||
41 | }; | ||
42 | |||
43 | -#define FLASH_JEDEC 0x20ba19 /* n25q256a */ | ||
44 | -#define FLASH_SIZE (32 * 1024 * 1024) | ||
45 | - | ||
46 | #define FLASH_PAGE_SIZE 256 | ||
47 | |||
48 | +typedef struct TestData { | ||
49 | + QTestState *s; | ||
50 | + uint64_t spi_base; | ||
51 | + uint64_t flash_base; | ||
52 | + uint32_t jedec_id; | ||
53 | + char *tmp_path; | ||
54 | +} TestData; | ||
46 | + | 55 | + |
47 | /* Chip select state */ | 56 | /* |
48 | bool cs; | 57 | * Use an explicit bswap for the values read/wrote to the flash region |
49 | }; | 58 | * as they are BE and the Aspeed CPU is LE. |
50 | diff --git a/hw/ssi/ssi.c b/hw/ssi/ssi.c | 59 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t make_be32(uint32_t data) |
51 | index XXXXXXX..XXXXXXX 100644 | 60 | return bswap32(data); |
52 | --- a/hw/ssi/ssi.c | 61 | } |
53 | +++ b/hw/ssi/ssi.c | 62 | |
54 | @@ -XXX,XX +XXX,XX @@ static void ssi_cs_default(void *opaque, int n, int level) | 63 | -static void spi_conf(uint32_t value) |
55 | bool cs = !!level; | 64 | +static inline void spi_writel(const TestData *data, uint64_t offset, |
56 | assert(n == 0); | 65 | + uint32_t value) |
57 | if (s->cs != cs) { | 66 | +{ |
58 | - SSIPeripheralClass *ssc = SSI_PERIPHERAL_GET_CLASS(s); | 67 | + qtest_writel(data->s, data->spi_base + offset, value); |
59 | - if (ssc->set_cs) { | 68 | +} |
60 | - ssc->set_cs(s, cs); | 69 | + |
61 | + if (s->spc->set_cs) { | 70 | +static inline uint32_t spi_readl(const TestData *data, uint64_t offset) |
62 | + s->spc->set_cs(s, cs); | 71 | +{ |
72 | + return qtest_readl(data->s, data->spi_base + offset); | ||
73 | +} | ||
74 | + | ||
75 | +static inline void flash_writeb(const TestData *data, uint64_t offset, | ||
76 | + uint8_t value) | ||
77 | +{ | ||
78 | + qtest_writeb(data->s, data->flash_base + offset, value); | ||
79 | +} | ||
80 | + | ||
81 | +static inline void flash_writel(const TestData *data, uint64_t offset, | ||
82 | + uint32_t value) | ||
83 | +{ | ||
84 | + qtest_writel(data->s, data->flash_base + offset, value); | ||
85 | +} | ||
86 | + | ||
87 | +static inline uint8_t flash_readb(const TestData *data, uint64_t offset) | ||
88 | { | ||
89 | - uint32_t conf = readl(ASPEED_FMC_BASE + R_CONF); | ||
90 | + return qtest_readb(data->s, data->flash_base + offset); | ||
91 | +} | ||
92 | + | ||
93 | +static inline uint32_t flash_readl(const TestData *data, uint64_t offset) | ||
94 | +{ | ||
95 | + return qtest_readl(data->s, data->flash_base + offset); | ||
96 | +} | ||
97 | + | ||
98 | +static void spi_conf(const TestData *data, uint32_t value) | ||
99 | +{ | ||
100 | + uint32_t conf = spi_readl(data, R_CONF); | ||
101 | |||
102 | conf |= value; | ||
103 | - writel(ASPEED_FMC_BASE + R_CONF, conf); | ||
104 | + spi_writel(data, R_CONF, conf); | ||
105 | } | ||
106 | |||
107 | -static void spi_conf_remove(uint32_t value) | ||
108 | +static void spi_conf_remove(const TestData *data, uint32_t value) | ||
109 | { | ||
110 | - uint32_t conf = readl(ASPEED_FMC_BASE + R_CONF); | ||
111 | + uint32_t conf = spi_readl(data, R_CONF); | ||
112 | |||
113 | conf &= ~value; | ||
114 | - writel(ASPEED_FMC_BASE + R_CONF, conf); | ||
115 | + spi_writel(data, R_CONF, conf); | ||
116 | } | ||
117 | |||
118 | -static void spi_ce_ctrl(uint32_t value) | ||
119 | +static void spi_ce_ctrl(const TestData *data, uint32_t value) | ||
120 | { | ||
121 | - uint32_t conf = readl(ASPEED_FMC_BASE + R_CE_CTRL); | ||
122 | + uint32_t conf = spi_readl(data, R_CE_CTRL); | ||
123 | |||
124 | conf |= value; | ||
125 | - writel(ASPEED_FMC_BASE + R_CE_CTRL, conf); | ||
126 | + spi_writel(data, R_CE_CTRL, conf); | ||
127 | } | ||
128 | |||
129 | -static void spi_ctrl_setmode(uint8_t mode, uint8_t cmd) | ||
130 | +static void spi_ctrl_setmode(const TestData *data, uint8_t mode, uint8_t cmd) | ||
131 | { | ||
132 | - uint32_t ctrl = readl(ASPEED_FMC_BASE + R_CTRL0); | ||
133 | + uint32_t ctrl = spi_readl(data, R_CTRL0); | ||
134 | ctrl &= ~(CTRL_USERMODE | 0xff << 16); | ||
135 | ctrl |= mode | (cmd << 16); | ||
136 | - writel(ASPEED_FMC_BASE + R_CTRL0, ctrl); | ||
137 | + spi_writel(data, R_CTRL0, ctrl); | ||
138 | } | ||
139 | |||
140 | -static void spi_ctrl_start_user(void) | ||
141 | +static void spi_ctrl_start_user(const TestData *data) | ||
142 | { | ||
143 | - uint32_t ctrl = readl(ASPEED_FMC_BASE + R_CTRL0); | ||
144 | + uint32_t ctrl = spi_readl(data, R_CTRL0); | ||
145 | |||
146 | ctrl |= CTRL_USERMODE | CTRL_CE_STOP_ACTIVE; | ||
147 | - writel(ASPEED_FMC_BASE + R_CTRL0, ctrl); | ||
148 | + spi_writel(data, R_CTRL0, ctrl); | ||
149 | |||
150 | ctrl &= ~CTRL_CE_STOP_ACTIVE; | ||
151 | - writel(ASPEED_FMC_BASE + R_CTRL0, ctrl); | ||
152 | + spi_writel(data, R_CTRL0, ctrl); | ||
153 | } | ||
154 | |||
155 | -static void spi_ctrl_stop_user(void) | ||
156 | +static void spi_ctrl_stop_user(const TestData *data) | ||
157 | { | ||
158 | - uint32_t ctrl = readl(ASPEED_FMC_BASE + R_CTRL0); | ||
159 | + uint32_t ctrl = spi_readl(data, R_CTRL0); | ||
160 | |||
161 | ctrl |= CTRL_USERMODE | CTRL_CE_STOP_ACTIVE; | ||
162 | - writel(ASPEED_FMC_BASE + R_CTRL0, ctrl); | ||
163 | + spi_writel(data, R_CTRL0, ctrl); | ||
164 | } | ||
165 | |||
166 | -static void flash_reset(void) | ||
167 | +static void flash_reset(const TestData *data) | ||
168 | { | ||
169 | - spi_conf(CONF_ENABLE_W0); | ||
170 | + spi_conf(data, CONF_ENABLE_W0); | ||
171 | |||
172 | - spi_ctrl_start_user(); | ||
173 | - writeb(ASPEED_FLASH_BASE, RESET_ENABLE); | ||
174 | - writeb(ASPEED_FLASH_BASE, RESET_MEMORY); | ||
175 | - writeb(ASPEED_FLASH_BASE, WREN); | ||
176 | - writeb(ASPEED_FLASH_BASE, BULK_ERASE); | ||
177 | - writeb(ASPEED_FLASH_BASE, WRDI); | ||
178 | - spi_ctrl_stop_user(); | ||
179 | + spi_ctrl_start_user(data); | ||
180 | + flash_writeb(data, 0, RESET_ENABLE); | ||
181 | + flash_writeb(data, 0, RESET_MEMORY); | ||
182 | + flash_writeb(data, 0, WREN); | ||
183 | + flash_writeb(data, 0, BULK_ERASE); | ||
184 | + flash_writeb(data, 0, WRDI); | ||
185 | + spi_ctrl_stop_user(data); | ||
186 | |||
187 | - spi_conf_remove(CONF_ENABLE_W0); | ||
188 | + spi_conf_remove(data, CONF_ENABLE_W0); | ||
189 | } | ||
190 | |||
191 | -static void test_read_jedec(void) | ||
192 | +static void test_read_jedec(const void *data) | ||
193 | { | ||
194 | + const TestData *test_data = (const TestData *)data; | ||
195 | uint32_t jedec = 0x0; | ||
196 | |||
197 | - spi_conf(CONF_ENABLE_W0); | ||
198 | + spi_conf(test_data, CONF_ENABLE_W0); | ||
199 | |||
200 | - spi_ctrl_start_user(); | ||
201 | - writeb(ASPEED_FLASH_BASE, JEDEC_READ); | ||
202 | - jedec |= readb(ASPEED_FLASH_BASE) << 16; | ||
203 | - jedec |= readb(ASPEED_FLASH_BASE) << 8; | ||
204 | - jedec |= readb(ASPEED_FLASH_BASE); | ||
205 | - spi_ctrl_stop_user(); | ||
206 | + spi_ctrl_start_user(test_data); | ||
207 | + flash_writeb(test_data, 0, JEDEC_READ); | ||
208 | + jedec |= flash_readb(test_data, 0) << 16; | ||
209 | + jedec |= flash_readb(test_data, 0) << 8; | ||
210 | + jedec |= flash_readb(test_data, 0); | ||
211 | + spi_ctrl_stop_user(test_data); | ||
212 | |||
213 | - flash_reset(); | ||
214 | + flash_reset(test_data); | ||
215 | |||
216 | - g_assert_cmphex(jedec, ==, FLASH_JEDEC); | ||
217 | + g_assert_cmphex(jedec, ==, test_data->jedec_id); | ||
218 | } | ||
219 | |||
220 | -static void read_page(uint32_t addr, uint32_t *page) | ||
221 | +static void read_page(const TestData *data, uint32_t addr, uint32_t *page) | ||
222 | { | ||
223 | int i; | ||
224 | |||
225 | - spi_ctrl_start_user(); | ||
226 | + spi_ctrl_start_user(data); | ||
227 | |||
228 | - writeb(ASPEED_FLASH_BASE, EN_4BYTE_ADDR); | ||
229 | - writeb(ASPEED_FLASH_BASE, READ); | ||
230 | - writel(ASPEED_FLASH_BASE, make_be32(addr)); | ||
231 | + flash_writeb(data, 0, EN_4BYTE_ADDR); | ||
232 | + flash_writeb(data, 0, READ); | ||
233 | + flash_writel(data, 0, make_be32(addr)); | ||
234 | |||
235 | /* Continuous read are supported */ | ||
236 | for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
237 | - page[i] = make_be32(readl(ASPEED_FLASH_BASE)); | ||
238 | + page[i] = make_be32(flash_readl(data, 0)); | ||
239 | } | ||
240 | - spi_ctrl_stop_user(); | ||
241 | + spi_ctrl_stop_user(data); | ||
242 | } | ||
243 | |||
244 | -static void read_page_mem(uint32_t addr, uint32_t *page) | ||
245 | +static void read_page_mem(const TestData *data, uint32_t addr, uint32_t *page) | ||
246 | { | ||
247 | int i; | ||
248 | |||
249 | /* move out USER mode to use direct reads from the AHB bus */ | ||
250 | - spi_ctrl_setmode(CTRL_READMODE, READ); | ||
251 | + spi_ctrl_setmode(data, CTRL_READMODE, READ); | ||
252 | |||
253 | for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
254 | - page[i] = make_be32(readl(ASPEED_FLASH_BASE + addr + i * 4)); | ||
255 | + page[i] = make_be32(flash_readl(data, addr + i * 4)); | ||
256 | } | ||
257 | } | ||
258 | |||
259 | -static void write_page_mem(uint32_t addr, uint32_t write_value) | ||
260 | +static void write_page_mem(const TestData *data, uint32_t addr, | ||
261 | + uint32_t write_value) | ||
262 | { | ||
263 | - spi_ctrl_setmode(CTRL_WRITEMODE, PP); | ||
264 | + spi_ctrl_setmode(data, CTRL_WRITEMODE, PP); | ||
265 | |||
266 | for (int i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
267 | - writel(ASPEED_FLASH_BASE + addr + i * 4, write_value); | ||
268 | + flash_writel(data, addr + i * 4, write_value); | ||
269 | } | ||
270 | } | ||
271 | |||
272 | -static void assert_page_mem(uint32_t addr, uint32_t expected_value) | ||
273 | +static void assert_page_mem(const TestData *data, uint32_t addr, | ||
274 | + uint32_t expected_value) | ||
275 | { | ||
276 | uint32_t page[FLASH_PAGE_SIZE / 4]; | ||
277 | - read_page_mem(addr, page); | ||
278 | + read_page_mem(data, addr, page); | ||
279 | for (int i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
280 | g_assert_cmphex(page[i], ==, expected_value); | ||
281 | } | ||
282 | } | ||
283 | |||
284 | -static void test_erase_sector(void) | ||
285 | +static void test_erase_sector(const void *data) | ||
286 | { | ||
287 | + const TestData *test_data = (const TestData *)data; | ||
288 | uint32_t some_page_addr = 0x600 * FLASH_PAGE_SIZE; | ||
289 | uint32_t page[FLASH_PAGE_SIZE / 4]; | ||
290 | int i; | ||
291 | |||
292 | - spi_conf(CONF_ENABLE_W0); | ||
293 | + spi_conf(test_data, CONF_ENABLE_W0); | ||
294 | |||
295 | /* | ||
296 | * Previous page should be full of 0xffs after backend is | ||
297 | * initialized | ||
298 | */ | ||
299 | - read_page(some_page_addr - FLASH_PAGE_SIZE, page); | ||
300 | + read_page(test_data, some_page_addr - FLASH_PAGE_SIZE, page); | ||
301 | for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
302 | g_assert_cmphex(page[i], ==, 0xffffffff); | ||
303 | } | ||
304 | |||
305 | - spi_ctrl_start_user(); | ||
306 | - writeb(ASPEED_FLASH_BASE, EN_4BYTE_ADDR); | ||
307 | - writeb(ASPEED_FLASH_BASE, WREN); | ||
308 | - writeb(ASPEED_FLASH_BASE, PP); | ||
309 | - writel(ASPEED_FLASH_BASE, make_be32(some_page_addr)); | ||
310 | + spi_ctrl_start_user(test_data); | ||
311 | + flash_writeb(test_data, 0, EN_4BYTE_ADDR); | ||
312 | + flash_writeb(test_data, 0, WREN); | ||
313 | + flash_writeb(test_data, 0, PP); | ||
314 | + flash_writel(test_data, 0, make_be32(some_page_addr)); | ||
315 | |||
316 | /* Fill the page with its own addresses */ | ||
317 | for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
318 | - writel(ASPEED_FLASH_BASE, make_be32(some_page_addr + i * 4)); | ||
319 | + flash_writel(test_data, 0, make_be32(some_page_addr + i * 4)); | ||
320 | } | ||
321 | - spi_ctrl_stop_user(); | ||
322 | + spi_ctrl_stop_user(test_data); | ||
323 | |||
324 | /* Check the page is correctly written */ | ||
325 | - read_page(some_page_addr, page); | ||
326 | + read_page(test_data, some_page_addr, page); | ||
327 | for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
328 | g_assert_cmphex(page[i], ==, some_page_addr + i * 4); | ||
329 | } | ||
330 | |||
331 | - spi_ctrl_start_user(); | ||
332 | - writeb(ASPEED_FLASH_BASE, WREN); | ||
333 | - writeb(ASPEED_FLASH_BASE, EN_4BYTE_ADDR); | ||
334 | - writeb(ASPEED_FLASH_BASE, ERASE_SECTOR); | ||
335 | - writel(ASPEED_FLASH_BASE, make_be32(some_page_addr)); | ||
336 | - spi_ctrl_stop_user(); | ||
337 | + spi_ctrl_start_user(test_data); | ||
338 | + flash_writeb(test_data, 0, WREN); | ||
339 | + flash_writeb(test_data, 0, EN_4BYTE_ADDR); | ||
340 | + flash_writeb(test_data, 0, ERASE_SECTOR); | ||
341 | + flash_writel(test_data, 0, make_be32(some_page_addr)); | ||
342 | + spi_ctrl_stop_user(test_data); | ||
343 | |||
344 | /* Check the page is erased */ | ||
345 | - read_page(some_page_addr, page); | ||
346 | + read_page(test_data, some_page_addr, page); | ||
347 | for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
348 | g_assert_cmphex(page[i], ==, 0xffffffff); | ||
349 | } | ||
350 | |||
351 | - flash_reset(); | ||
352 | + flash_reset(test_data); | ||
353 | } | ||
354 | |||
355 | -static void test_erase_all(void) | ||
356 | +static void test_erase_all(const void *data) | ||
357 | { | ||
358 | + const TestData *test_data = (const TestData *)data; | ||
359 | uint32_t some_page_addr = 0x15000 * FLASH_PAGE_SIZE; | ||
360 | uint32_t page[FLASH_PAGE_SIZE / 4]; | ||
361 | int i; | ||
362 | |||
363 | - spi_conf(CONF_ENABLE_W0); | ||
364 | + spi_conf(test_data, CONF_ENABLE_W0); | ||
365 | |||
366 | /* | ||
367 | * Previous page should be full of 0xffs after backend is | ||
368 | * initialized | ||
369 | */ | ||
370 | - read_page(some_page_addr - FLASH_PAGE_SIZE, page); | ||
371 | + read_page(test_data, some_page_addr - FLASH_PAGE_SIZE, page); | ||
372 | for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
373 | g_assert_cmphex(page[i], ==, 0xffffffff); | ||
374 | } | ||
375 | |||
376 | - spi_ctrl_start_user(); | ||
377 | - writeb(ASPEED_FLASH_BASE, EN_4BYTE_ADDR); | ||
378 | - writeb(ASPEED_FLASH_BASE, WREN); | ||
379 | - writeb(ASPEED_FLASH_BASE, PP); | ||
380 | - writel(ASPEED_FLASH_BASE, make_be32(some_page_addr)); | ||
381 | + spi_ctrl_start_user(test_data); | ||
382 | + flash_writeb(test_data, 0, EN_4BYTE_ADDR); | ||
383 | + flash_writeb(test_data, 0, WREN); | ||
384 | + flash_writeb(test_data, 0, PP); | ||
385 | + flash_writel(test_data, 0, make_be32(some_page_addr)); | ||
386 | |||
387 | /* Fill the page with its own addresses */ | ||
388 | for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
389 | - writel(ASPEED_FLASH_BASE, make_be32(some_page_addr + i * 4)); | ||
390 | + flash_writel(test_data, 0, make_be32(some_page_addr + i * 4)); | ||
391 | } | ||
392 | - spi_ctrl_stop_user(); | ||
393 | + spi_ctrl_stop_user(test_data); | ||
394 | |||
395 | /* Check the page is correctly written */ | ||
396 | - read_page(some_page_addr, page); | ||
397 | + read_page(test_data, some_page_addr, page); | ||
398 | for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
399 | g_assert_cmphex(page[i], ==, some_page_addr + i * 4); | ||
400 | } | ||
401 | |||
402 | - spi_ctrl_start_user(); | ||
403 | - writeb(ASPEED_FLASH_BASE, WREN); | ||
404 | - writeb(ASPEED_FLASH_BASE, BULK_ERASE); | ||
405 | - spi_ctrl_stop_user(); | ||
406 | + spi_ctrl_start_user(test_data); | ||
407 | + flash_writeb(test_data, 0, WREN); | ||
408 | + flash_writeb(test_data, 0, BULK_ERASE); | ||
409 | + spi_ctrl_stop_user(test_data); | ||
410 | |||
411 | /* Check the page is erased */ | ||
412 | - read_page(some_page_addr, page); | ||
413 | + read_page(test_data, some_page_addr, page); | ||
414 | for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
415 | g_assert_cmphex(page[i], ==, 0xffffffff); | ||
416 | } | ||
417 | |||
418 | - flash_reset(); | ||
419 | + flash_reset(test_data); | ||
420 | } | ||
421 | |||
422 | -static void test_write_page(void) | ||
423 | +static void test_write_page(const void *data) | ||
424 | { | ||
425 | + const TestData *test_data = (const TestData *)data; | ||
426 | uint32_t my_page_addr = 0x14000 * FLASH_PAGE_SIZE; /* beyond 16MB */ | ||
427 | uint32_t some_page_addr = 0x15000 * FLASH_PAGE_SIZE; | ||
428 | uint32_t page[FLASH_PAGE_SIZE / 4]; | ||
429 | int i; | ||
430 | |||
431 | - spi_conf(CONF_ENABLE_W0); | ||
432 | + spi_conf(test_data, CONF_ENABLE_W0); | ||
433 | |||
434 | - spi_ctrl_start_user(); | ||
435 | - writeb(ASPEED_FLASH_BASE, EN_4BYTE_ADDR); | ||
436 | - writeb(ASPEED_FLASH_BASE, WREN); | ||
437 | - writeb(ASPEED_FLASH_BASE, PP); | ||
438 | - writel(ASPEED_FLASH_BASE, make_be32(my_page_addr)); | ||
439 | + spi_ctrl_start_user(test_data); | ||
440 | + flash_writeb(test_data, 0, EN_4BYTE_ADDR); | ||
441 | + flash_writeb(test_data, 0, WREN); | ||
442 | + flash_writeb(test_data, 0, PP); | ||
443 | + flash_writel(test_data, 0, make_be32(my_page_addr)); | ||
444 | |||
445 | /* Fill the page with its own addresses */ | ||
446 | for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
447 | - writel(ASPEED_FLASH_BASE, make_be32(my_page_addr + i * 4)); | ||
448 | + flash_writel(test_data, 0, make_be32(my_page_addr + i * 4)); | ||
449 | } | ||
450 | - spi_ctrl_stop_user(); | ||
451 | + spi_ctrl_stop_user(test_data); | ||
452 | |||
453 | /* Check what was written */ | ||
454 | - read_page(my_page_addr, page); | ||
455 | + read_page(test_data, my_page_addr, page); | ||
456 | for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
457 | g_assert_cmphex(page[i], ==, my_page_addr + i * 4); | ||
458 | } | ||
459 | |||
460 | /* Check some other page. It should be full of 0xff */ | ||
461 | - read_page(some_page_addr, page); | ||
462 | + read_page(test_data, some_page_addr, page); | ||
463 | for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
464 | g_assert_cmphex(page[i], ==, 0xffffffff); | ||
465 | } | ||
466 | |||
467 | - flash_reset(); | ||
468 | + flash_reset(test_data); | ||
469 | } | ||
470 | |||
471 | -static void test_read_page_mem(void) | ||
472 | +static void test_read_page_mem(const void *data) | ||
473 | { | ||
474 | + const TestData *test_data = (const TestData *)data; | ||
475 | uint32_t my_page_addr = 0x14000 * FLASH_PAGE_SIZE; /* beyond 16MB */ | ||
476 | uint32_t some_page_addr = 0x15000 * FLASH_PAGE_SIZE; | ||
477 | uint32_t page[FLASH_PAGE_SIZE / 4]; | ||
478 | @@ -XXX,XX +XXX,XX @@ static void test_read_page_mem(void) | ||
479 | * Enable 4BYTE mode for controller. This is should be strapped by | ||
480 | * HW for CE0 anyhow. | ||
481 | */ | ||
482 | - spi_ce_ctrl(1 << CRTL_EXTENDED0); | ||
483 | + spi_ce_ctrl(test_data, 1 << CRTL_EXTENDED0); | ||
484 | |||
485 | /* Enable 4BYTE mode for flash. */ | ||
486 | - spi_conf(CONF_ENABLE_W0); | ||
487 | - spi_ctrl_start_user(); | ||
488 | - writeb(ASPEED_FLASH_BASE, EN_4BYTE_ADDR); | ||
489 | - writeb(ASPEED_FLASH_BASE, WREN); | ||
490 | - writeb(ASPEED_FLASH_BASE, PP); | ||
491 | - writel(ASPEED_FLASH_BASE, make_be32(my_page_addr)); | ||
492 | + spi_conf(test_data, CONF_ENABLE_W0); | ||
493 | + spi_ctrl_start_user(test_data); | ||
494 | + flash_writeb(test_data, 0, EN_4BYTE_ADDR); | ||
495 | + flash_writeb(test_data, 0, WREN); | ||
496 | + flash_writeb(test_data, 0, PP); | ||
497 | + flash_writel(test_data, 0, make_be32(my_page_addr)); | ||
498 | |||
499 | /* Fill the page with its own addresses */ | ||
500 | for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
501 | - writel(ASPEED_FLASH_BASE, make_be32(my_page_addr + i * 4)); | ||
502 | + flash_writel(test_data, 0, make_be32(my_page_addr + i * 4)); | ||
503 | } | ||
504 | - spi_ctrl_stop_user(); | ||
505 | - spi_conf_remove(CONF_ENABLE_W0); | ||
506 | + spi_ctrl_stop_user(test_data); | ||
507 | + spi_conf_remove(test_data, CONF_ENABLE_W0); | ||
508 | |||
509 | /* Check what was written */ | ||
510 | - read_page_mem(my_page_addr, page); | ||
511 | + read_page_mem(test_data, my_page_addr, page); | ||
512 | for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
513 | g_assert_cmphex(page[i], ==, my_page_addr + i * 4); | ||
514 | } | ||
515 | |||
516 | /* Check some other page. It should be full of 0xff */ | ||
517 | - read_page_mem(some_page_addr, page); | ||
518 | + read_page_mem(test_data, some_page_addr, page); | ||
519 | for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
520 | g_assert_cmphex(page[i], ==, 0xffffffff); | ||
521 | } | ||
522 | |||
523 | - flash_reset(); | ||
524 | + flash_reset(test_data); | ||
525 | } | ||
526 | |||
527 | -static void test_write_page_mem(void) | ||
528 | +static void test_write_page_mem(const void *data) | ||
529 | { | ||
530 | + const TestData *test_data = (const TestData *)data; | ||
531 | uint32_t my_page_addr = 0x15000 * FLASH_PAGE_SIZE; | ||
532 | uint32_t page[FLASH_PAGE_SIZE / 4]; | ||
533 | int i; | ||
534 | @@ -XXX,XX +XXX,XX @@ static void test_write_page_mem(void) | ||
535 | * Enable 4BYTE mode for controller. This is should be strapped by | ||
536 | * HW for CE0 anyhow. | ||
537 | */ | ||
538 | - spi_ce_ctrl(1 << CRTL_EXTENDED0); | ||
539 | + spi_ce_ctrl(test_data, 1 << CRTL_EXTENDED0); | ||
540 | |||
541 | /* Enable 4BYTE mode for flash. */ | ||
542 | - spi_conf(CONF_ENABLE_W0); | ||
543 | - spi_ctrl_start_user(); | ||
544 | - writeb(ASPEED_FLASH_BASE, EN_4BYTE_ADDR); | ||
545 | - writeb(ASPEED_FLASH_BASE, WREN); | ||
546 | - spi_ctrl_stop_user(); | ||
547 | + spi_conf(test_data, CONF_ENABLE_W0); | ||
548 | + spi_ctrl_start_user(test_data); | ||
549 | + flash_writeb(test_data, 0, EN_4BYTE_ADDR); | ||
550 | + flash_writeb(test_data, 0, WREN); | ||
551 | + spi_ctrl_stop_user(test_data); | ||
552 | |||
553 | /* move out USER mode to use direct writes to the AHB bus */ | ||
554 | - spi_ctrl_setmode(CTRL_WRITEMODE, PP); | ||
555 | + spi_ctrl_setmode(test_data, CTRL_WRITEMODE, PP); | ||
556 | |||
557 | for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
558 | - writel(ASPEED_FLASH_BASE + my_page_addr + i * 4, | ||
559 | + flash_writel(test_data, my_page_addr + i * 4, | ||
560 | make_be32(my_page_addr + i * 4)); | ||
561 | } | ||
562 | |||
563 | /* Check what was written */ | ||
564 | - read_page_mem(my_page_addr, page); | ||
565 | + read_page_mem(test_data, my_page_addr, page); | ||
566 | for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
567 | g_assert_cmphex(page[i], ==, my_page_addr + i * 4); | ||
568 | } | ||
569 | |||
570 | - flash_reset(); | ||
571 | + flash_reset(test_data); | ||
572 | } | ||
573 | |||
574 | -static void test_read_status_reg(void) | ||
575 | +static void test_read_status_reg(const void *data) | ||
576 | { | ||
577 | + const TestData *test_data = (const TestData *)data; | ||
578 | uint8_t r; | ||
579 | |||
580 | - spi_conf(CONF_ENABLE_W0); | ||
581 | + spi_conf(test_data, CONF_ENABLE_W0); | ||
582 | |||
583 | - spi_ctrl_start_user(); | ||
584 | - writeb(ASPEED_FLASH_BASE, RDSR); | ||
585 | - r = readb(ASPEED_FLASH_BASE); | ||
586 | - spi_ctrl_stop_user(); | ||
587 | + spi_ctrl_start_user(test_data); | ||
588 | + flash_writeb(test_data, 0, RDSR); | ||
589 | + r = flash_readb(test_data, 0); | ||
590 | + spi_ctrl_stop_user(test_data); | ||
591 | |||
592 | g_assert_cmphex(r & SR_WEL, ==, 0); | ||
593 | g_assert(!qtest_qom_get_bool | ||
594 | - (global_qtest, "/machine/soc/fmc/ssi.0/child[0]", "write-enable")); | ||
595 | + (test_data->s, "/machine/soc/fmc/ssi.0/child[0]", "write-enable")); | ||
596 | |||
597 | - spi_ctrl_start_user(); | ||
598 | - writeb(ASPEED_FLASH_BASE, WREN); | ||
599 | - writeb(ASPEED_FLASH_BASE, RDSR); | ||
600 | - r = readb(ASPEED_FLASH_BASE); | ||
601 | - spi_ctrl_stop_user(); | ||
602 | + spi_ctrl_start_user(test_data); | ||
603 | + flash_writeb(test_data, 0, WREN); | ||
604 | + flash_writeb(test_data, 0, RDSR); | ||
605 | + r = flash_readb(test_data, 0); | ||
606 | + spi_ctrl_stop_user(test_data); | ||
607 | |||
608 | g_assert_cmphex(r & SR_WEL, ==, SR_WEL); | ||
609 | g_assert(qtest_qom_get_bool | ||
610 | - (global_qtest, "/machine/soc/fmc/ssi.0/child[0]", "write-enable")); | ||
611 | + (test_data->s, "/machine/soc/fmc/ssi.0/child[0]", "write-enable")); | ||
612 | |||
613 | - spi_ctrl_start_user(); | ||
614 | - writeb(ASPEED_FLASH_BASE, WRDI); | ||
615 | - writeb(ASPEED_FLASH_BASE, RDSR); | ||
616 | - r = readb(ASPEED_FLASH_BASE); | ||
617 | - spi_ctrl_stop_user(); | ||
618 | + spi_ctrl_start_user(test_data); | ||
619 | + flash_writeb(test_data, 0, WRDI); | ||
620 | + flash_writeb(test_data, 0, RDSR); | ||
621 | + r = flash_readb(test_data, 0); | ||
622 | + spi_ctrl_stop_user(test_data); | ||
623 | |||
624 | g_assert_cmphex(r & SR_WEL, ==, 0); | ||
625 | g_assert(!qtest_qom_get_bool | ||
626 | - (global_qtest, "/machine/soc/fmc/ssi.0/child[0]", "write-enable")); | ||
627 | + (test_data->s, "/machine/soc/fmc/ssi.0/child[0]", "write-enable")); | ||
628 | |||
629 | - flash_reset(); | ||
630 | + flash_reset(test_data); | ||
631 | } | ||
632 | |||
633 | -static void test_status_reg_write_protection(void) | ||
634 | +static void test_status_reg_write_protection(const void *data) | ||
635 | { | ||
636 | + const TestData *test_data = (const TestData *)data; | ||
637 | uint8_t r; | ||
638 | |||
639 | - spi_conf(CONF_ENABLE_W0); | ||
640 | + spi_conf(test_data, CONF_ENABLE_W0); | ||
641 | |||
642 | /* default case: WP# is high and SRWD is low -> status register writable */ | ||
643 | - spi_ctrl_start_user(); | ||
644 | - writeb(ASPEED_FLASH_BASE, WREN); | ||
645 | + spi_ctrl_start_user(test_data); | ||
646 | + flash_writeb(test_data, 0, WREN); | ||
647 | /* test ability to write SRWD */ | ||
648 | - writeb(ASPEED_FLASH_BASE, WRSR); | ||
649 | - writeb(ASPEED_FLASH_BASE, SRWD); | ||
650 | - writeb(ASPEED_FLASH_BASE, RDSR); | ||
651 | - r = readb(ASPEED_FLASH_BASE); | ||
652 | - spi_ctrl_stop_user(); | ||
653 | + flash_writeb(test_data, 0, WRSR); | ||
654 | + flash_writeb(test_data, 0, SRWD); | ||
655 | + flash_writeb(test_data, 0, RDSR); | ||
656 | + r = flash_readb(test_data, 0); | ||
657 | + spi_ctrl_stop_user(test_data); | ||
658 | g_assert_cmphex(r & SRWD, ==, SRWD); | ||
659 | |||
660 | /* WP# high and SRWD high -> status register writable */ | ||
661 | - spi_ctrl_start_user(); | ||
662 | - writeb(ASPEED_FLASH_BASE, WREN); | ||
663 | + spi_ctrl_start_user(test_data); | ||
664 | + flash_writeb(test_data, 0, WREN); | ||
665 | /* test ability to write SRWD */ | ||
666 | - writeb(ASPEED_FLASH_BASE, WRSR); | ||
667 | - writeb(ASPEED_FLASH_BASE, 0); | ||
668 | - writeb(ASPEED_FLASH_BASE, RDSR); | ||
669 | - r = readb(ASPEED_FLASH_BASE); | ||
670 | - spi_ctrl_stop_user(); | ||
671 | + flash_writeb(test_data, 0, WRSR); | ||
672 | + flash_writeb(test_data, 0, 0); | ||
673 | + flash_writeb(test_data, 0, RDSR); | ||
674 | + r = flash_readb(test_data, 0); | ||
675 | + spi_ctrl_stop_user(test_data); | ||
676 | g_assert_cmphex(r & SRWD, ==, 0); | ||
677 | |||
678 | /* WP# low and SRWD low -> status register writable */ | ||
679 | - qtest_set_irq_in(global_qtest, | ||
680 | + qtest_set_irq_in(test_data->s, | ||
681 | "/machine/soc/fmc/ssi.0/child[0]", "WP#", 0, 0); | ||
682 | - spi_ctrl_start_user(); | ||
683 | - writeb(ASPEED_FLASH_BASE, WREN); | ||
684 | + spi_ctrl_start_user(test_data); | ||
685 | + flash_writeb(test_data, 0, WREN); | ||
686 | /* test ability to write SRWD */ | ||
687 | - writeb(ASPEED_FLASH_BASE, WRSR); | ||
688 | - writeb(ASPEED_FLASH_BASE, SRWD); | ||
689 | - writeb(ASPEED_FLASH_BASE, RDSR); | ||
690 | - r = readb(ASPEED_FLASH_BASE); | ||
691 | - spi_ctrl_stop_user(); | ||
692 | + flash_writeb(test_data, 0, WRSR); | ||
693 | + flash_writeb(test_data, 0, SRWD); | ||
694 | + flash_writeb(test_data, 0, RDSR); | ||
695 | + r = flash_readb(test_data, 0); | ||
696 | + spi_ctrl_stop_user(test_data); | ||
697 | g_assert_cmphex(r & SRWD, ==, SRWD); | ||
698 | |||
699 | /* WP# low and SRWD high -> status register NOT writable */ | ||
700 | - spi_ctrl_start_user(); | ||
701 | - writeb(ASPEED_FLASH_BASE, WREN); | ||
702 | + spi_ctrl_start_user(test_data); | ||
703 | + flash_writeb(test_data, 0 , WREN); | ||
704 | /* test ability to write SRWD */ | ||
705 | - writeb(ASPEED_FLASH_BASE, WRSR); | ||
706 | - writeb(ASPEED_FLASH_BASE, 0); | ||
707 | - writeb(ASPEED_FLASH_BASE, RDSR); | ||
708 | - r = readb(ASPEED_FLASH_BASE); | ||
709 | - spi_ctrl_stop_user(); | ||
710 | + flash_writeb(test_data, 0, WRSR); | ||
711 | + flash_writeb(test_data, 0, 0); | ||
712 | + flash_writeb(test_data, 0, RDSR); | ||
713 | + r = flash_readb(test_data, 0); | ||
714 | + spi_ctrl_stop_user(test_data); | ||
715 | /* write is not successful */ | ||
716 | g_assert_cmphex(r & SRWD, ==, SRWD); | ||
717 | |||
718 | - qtest_set_irq_in(global_qtest, | ||
719 | + qtest_set_irq_in(test_data->s, | ||
720 | "/machine/soc/fmc/ssi.0/child[0]", "WP#", 0, 1); | ||
721 | - flash_reset(); | ||
722 | + flash_reset(test_data); | ||
723 | } | ||
724 | |||
725 | -static void test_write_block_protect(void) | ||
726 | +static void test_write_block_protect(const void *data) | ||
727 | { | ||
728 | + const TestData *test_data = (const TestData *)data; | ||
729 | uint32_t sector_size = 65536; | ||
730 | uint32_t n_sectors = 512; | ||
731 | |||
732 | - spi_ce_ctrl(1 << CRTL_EXTENDED0); | ||
733 | - spi_conf(CONF_ENABLE_W0); | ||
734 | + spi_ce_ctrl(test_data, 1 << CRTL_EXTENDED0); | ||
735 | + spi_conf(test_data, CONF_ENABLE_W0); | ||
736 | |||
737 | uint32_t bp_bits = 0b0; | ||
738 | |||
739 | for (int i = 0; i < 16; i++) { | ||
740 | bp_bits = ((i & 0b1000) << 3) | ((i & 0b0111) << 2); | ||
741 | |||
742 | - spi_ctrl_start_user(); | ||
743 | - writeb(ASPEED_FLASH_BASE, WREN); | ||
744 | - writeb(ASPEED_FLASH_BASE, BULK_ERASE); | ||
745 | - writeb(ASPEED_FLASH_BASE, WREN); | ||
746 | - writeb(ASPEED_FLASH_BASE, WRSR); | ||
747 | - writeb(ASPEED_FLASH_BASE, bp_bits); | ||
748 | - writeb(ASPEED_FLASH_BASE, EN_4BYTE_ADDR); | ||
749 | - writeb(ASPEED_FLASH_BASE, WREN); | ||
750 | - spi_ctrl_stop_user(); | ||
751 | + spi_ctrl_start_user(test_data); | ||
752 | + flash_writeb(test_data, 0, WREN); | ||
753 | + flash_writeb(test_data, 0, BULK_ERASE); | ||
754 | + flash_writeb(test_data, 0, WREN); | ||
755 | + flash_writeb(test_data, 0, WRSR); | ||
756 | + flash_writeb(test_data, 0, bp_bits); | ||
757 | + flash_writeb(test_data, 0, EN_4BYTE_ADDR); | ||
758 | + flash_writeb(test_data, 0, WREN); | ||
759 | + spi_ctrl_stop_user(test_data); | ||
760 | |||
761 | uint32_t num_protected_sectors = i ? MIN(1 << (i - 1), n_sectors) : 0; | ||
762 | uint32_t protection_start = n_sectors - num_protected_sectors; | ||
763 | @@ -XXX,XX +XXX,XX @@ static void test_write_block_protect(void) | ||
764 | for (int sector = 0; sector < n_sectors; sector++) { | ||
765 | uint32_t addr = sector * sector_size; | ||
766 | |||
767 | - assert_page_mem(addr, 0xffffffff); | ||
768 | - write_page_mem(addr, make_be32(0xabcdef12)); | ||
769 | + assert_page_mem(test_data, addr, 0xffffffff); | ||
770 | + write_page_mem(test_data, addr, make_be32(0xabcdef12)); | ||
771 | |||
772 | uint32_t expected_value = protection_start <= sector | ||
773 | && sector < protection_end | ||
774 | ? 0xffffffff : 0xabcdef12; | ||
775 | |||
776 | - assert_page_mem(addr, expected_value); | ||
777 | + assert_page_mem(test_data, addr, expected_value); | ||
63 | } | 778 | } |
64 | } | 779 | } |
65 | s->cs = cs; | 780 | |
66 | @@ -XXX,XX +XXX,XX @@ static void ssi_cs_default(void *opaque, int n, int level) | 781 | - flash_reset(); |
67 | 782 | + flash_reset(test_data); | |
68 | static uint32_t ssi_transfer_raw_default(SSIPeripheral *dev, uint32_t val) | 783 | } |
69 | { | 784 | |
70 | - SSIPeripheralClass *ssc = SSI_PERIPHERAL_GET_CLASS(dev); | 785 | -static void test_write_block_protect_bottom_bit(void) |
71 | + SSIPeripheralClass *ssc = dev->spc; | 786 | +static void test_write_block_protect_bottom_bit(const void *data) |
72 | 787 | { | |
73 | if ((dev->cs && ssc->cs_polarity == SSI_CS_HIGH) || | 788 | + const TestData *test_data = (const TestData *)data; |
74 | - (!dev->cs && ssc->cs_polarity == SSI_CS_LOW) || | 789 | uint32_t sector_size = 65536; |
75 | - ssc->cs_polarity == SSI_CS_NONE) { | 790 | uint32_t n_sectors = 512; |
76 | + (!dev->cs && ssc->cs_polarity == SSI_CS_LOW) || | 791 | |
77 | + ssc->cs_polarity == SSI_CS_NONE) { | 792 | - spi_ce_ctrl(1 << CRTL_EXTENDED0); |
78 | return ssc->transfer(dev, val); | 793 | - spi_conf(CONF_ENABLE_W0); |
79 | } | 794 | + spi_ce_ctrl(test_data, 1 << CRTL_EXTENDED0); |
80 | return 0; | 795 | + spi_conf(test_data, CONF_ENABLE_W0); |
81 | @@ -XXX,XX +XXX,XX @@ static void ssi_peripheral_realize(DeviceState *dev, Error **errp) | 796 | |
82 | ssc->cs_polarity != SSI_CS_NONE) { | 797 | /* top bottom bit is enabled */ |
83 | qdev_init_gpio_in_named(dev, ssi_cs_default, SSI_GPIO_CS, 1); | 798 | uint32_t bp_bits = 0b00100 << 3; |
84 | } | 799 | @@ -XXX,XX +XXX,XX @@ static void test_write_block_protect_bottom_bit(void) |
85 | + s->spc = ssc; | 800 | for (int i = 0; i < 16; i++) { |
86 | 801 | bp_bits = (((i & 0b1000) | 0b0100) << 3) | ((i & 0b0111) << 2); | |
87 | ssc->realize(s, errp); | 802 | |
88 | } | 803 | - spi_ctrl_start_user(); |
89 | @@ -XXX,XX +XXX,XX @@ uint32_t ssi_transfer(SSIBus *bus, uint32_t val) | 804 | - writeb(ASPEED_FLASH_BASE, WREN); |
90 | { | 805 | - writeb(ASPEED_FLASH_BASE, BULK_ERASE); |
91 | BusState *b = BUS(bus); | 806 | - writeb(ASPEED_FLASH_BASE, WREN); |
92 | BusChild *kid; | 807 | - writeb(ASPEED_FLASH_BASE, WRSR); |
93 | - SSIPeripheralClass *ssc; | 808 | - writeb(ASPEED_FLASH_BASE, bp_bits); |
94 | uint32_t r = 0; | 809 | - writeb(ASPEED_FLASH_BASE, EN_4BYTE_ADDR); |
95 | 810 | - writeb(ASPEED_FLASH_BASE, WREN); | |
96 | QTAILQ_FOREACH(kid, &b->children, sibling) { | 811 | - spi_ctrl_stop_user(); |
97 | - SSIPeripheral *peripheral = SSI_PERIPHERAL(kid->child); | 812 | + spi_ctrl_start_user(test_data); |
98 | - ssc = SSI_PERIPHERAL_GET_CLASS(peripheral); | 813 | + flash_writeb(test_data, 0, WREN); |
99 | - r |= ssc->transfer_raw(peripheral, val); | 814 | + flash_writeb(test_data, 0, BULK_ERASE); |
100 | + SSIPeripheral *p = SSI_PERIPHERAL(kid->child); | 815 | + flash_writeb(test_data, 0, WREN); |
101 | + r |= p->spc->transfer_raw(p, val); | 816 | + flash_writeb(test_data, 0, WRSR); |
102 | } | 817 | + flash_writeb(test_data, 0, bp_bits); |
103 | 818 | + flash_writeb(test_data, 0, EN_4BYTE_ADDR); | |
104 | return r; | 819 | + flash_writeb(test_data, 0, WREN); |
820 | + spi_ctrl_stop_user(test_data); | ||
821 | |||
822 | uint32_t num_protected_sectors = i ? MIN(1 << (i - 1), n_sectors) : 0; | ||
823 | uint32_t protection_start = 0; | ||
824 | @@ -XXX,XX +XXX,XX @@ static void test_write_block_protect_bottom_bit(void) | ||
825 | for (int sector = 0; sector < n_sectors; sector++) { | ||
826 | uint32_t addr = sector * sector_size; | ||
827 | |||
828 | - assert_page_mem(addr, 0xffffffff); | ||
829 | - write_page_mem(addr, make_be32(0xabcdef12)); | ||
830 | + assert_page_mem(test_data, addr, 0xffffffff); | ||
831 | + write_page_mem(test_data, addr, make_be32(0xabcdef12)); | ||
832 | |||
833 | uint32_t expected_value = protection_start <= sector | ||
834 | && sector < protection_end | ||
835 | ? 0xffffffff : 0xabcdef12; | ||
836 | |||
837 | - assert_page_mem(addr, expected_value); | ||
838 | + assert_page_mem(test_data, addr, expected_value); | ||
839 | } | ||
840 | } | ||
841 | |||
842 | - flash_reset(); | ||
843 | + flash_reset(test_data); | ||
844 | } | ||
845 | |||
846 | -static int test_palmetto_bmc(void) | ||
847 | +static void test_palmetto_bmc(TestData *data) | ||
848 | { | ||
849 | - g_autofree char *tmp_path = NULL; | ||
850 | int ret; | ||
851 | int fd; | ||
852 | |||
853 | - fd = g_file_open_tmp("qtest.m25p80.XXXXXX", &tmp_path, NULL); | ||
854 | + fd = g_file_open_tmp("qtest.m25p80.n25q256a.XXXXXX", &data->tmp_path, NULL); | ||
855 | g_assert(fd >= 0); | ||
856 | - ret = ftruncate(fd, FLASH_SIZE); | ||
857 | + ret = ftruncate(fd, 32 * 1024 * 1024); | ||
858 | g_assert(ret == 0); | ||
859 | close(fd); | ||
860 | |||
861 | - global_qtest = qtest_initf("-m 256 -machine palmetto-bmc " | ||
862 | - "-drive file=%s,format=raw,if=mtd", | ||
863 | - tmp_path); | ||
864 | - | ||
865 | - qtest_add_func("/ast2400/smc/read_jedec", test_read_jedec); | ||
866 | - qtest_add_func("/ast2400/smc/erase_sector", test_erase_sector); | ||
867 | - qtest_add_func("/ast2400/smc/erase_all", test_erase_all); | ||
868 | - qtest_add_func("/ast2400/smc/write_page", test_write_page); | ||
869 | - qtest_add_func("/ast2400/smc/read_page_mem", test_read_page_mem); | ||
870 | - qtest_add_func("/ast2400/smc/write_page_mem", test_write_page_mem); | ||
871 | - qtest_add_func("/ast2400/smc/read_status_reg", test_read_status_reg); | ||
872 | - qtest_add_func("/ast2400/smc/status_reg_write_protection", | ||
873 | - test_status_reg_write_protection); | ||
874 | - qtest_add_func("/ast2400/smc/write_block_protect", | ||
875 | - test_write_block_protect); | ||
876 | - qtest_add_func("/ast2400/smc/write_block_protect_bottom_bit", | ||
877 | - test_write_block_protect_bottom_bit); | ||
878 | - | ||
879 | - flash_reset(); | ||
880 | - ret = g_test_run(); | ||
881 | - qtest_quit(global_qtest); | ||
882 | - unlink(tmp_path); | ||
883 | - | ||
884 | - return ret; | ||
885 | + data->s = qtest_initf("-m 256 -machine palmetto-bmc " | ||
886 | + "-drive file=%s,format=raw,if=mtd", | ||
887 | + data->tmp_path); | ||
888 | + | ||
889 | + /* fmc cs0 with n25q256a flash */ | ||
890 | + data->flash_base = 0x20000000; | ||
891 | + data->spi_base = 0x1E620000; | ||
892 | + data->jedec_id = 0x20ba19; | ||
893 | + | ||
894 | + qtest_add_data_func("/ast2400/smc/read_jedec", data, test_read_jedec); | ||
895 | + qtest_add_data_func("/ast2400/smc/erase_sector", data, test_erase_sector); | ||
896 | + qtest_add_data_func("/ast2400/smc/erase_all", data, test_erase_all); | ||
897 | + qtest_add_data_func("/ast2400/smc/write_page", data, test_write_page); | ||
898 | + qtest_add_data_func("/ast2400/smc/read_page_mem", | ||
899 | + data, test_read_page_mem); | ||
900 | + qtest_add_data_func("/ast2400/smc/write_page_mem", | ||
901 | + data, test_write_page_mem); | ||
902 | + qtest_add_data_func("/ast2400/smc/read_status_reg", | ||
903 | + data, test_read_status_reg); | ||
904 | + qtest_add_data_func("/ast2400/smc/status_reg_write_protection", | ||
905 | + data, test_status_reg_write_protection); | ||
906 | + qtest_add_data_func("/ast2400/smc/write_block_protect", | ||
907 | + data, test_write_block_protect); | ||
908 | + qtest_add_data_func("/ast2400/smc/write_block_protect_bottom_bit", | ||
909 | + data, test_write_block_protect_bottom_bit); | ||
910 | } | ||
911 | |||
912 | int main(int argc, char **argv) | ||
913 | { | ||
914 | + TestData palmetto_data; | ||
915 | int ret; | ||
916 | |||
917 | g_test_init(&argc, &argv, NULL); | ||
918 | - ret = test_palmetto_bmc(); | ||
919 | |||
920 | + test_palmetto_bmc(&palmetto_data); | ||
921 | + ret = g_test_run(); | ||
922 | + | ||
923 | + qtest_quit(palmetto_data.s); | ||
924 | + unlink(palmetto_data.tmp_path); | ||
925 | return ret; | ||
926 | } | ||
105 | -- | 927 | -- |
106 | 2.37.3 | 928 | 2.47.1 |
107 | 929 | ||
108 | 930 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | 1 | From: Jamin Lin <jamin_lin@aspeedtech.com> | |
2 | |||
3 | Currently, these test cases only support to test CE0. To test all CE pins, | ||
4 | introduces new ce and node members in TestData structure. The ce member is used | ||
5 | for saving the ce index and node member is used for saving the node path, | ||
6 | respectively. | ||
7 | |||
8 | Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com> | ||
9 | Reviewed-by: Cédric Le Goater <clg@redhat.com> | ||
10 | Link: https://lore.kernel.org/r/20241127091543.1243114-4-jamin_lin@aspeedtech.com | ||
11 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | ||
12 | --- | ||
13 | tests/qtest/aspeed_smc-test.c | 77 ++++++++++++++++++----------------- | ||
14 | 1 file changed, 40 insertions(+), 37 deletions(-) | ||
15 | |||
16 | diff --git a/tests/qtest/aspeed_smc-test.c b/tests/qtest/aspeed_smc-test.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/tests/qtest/aspeed_smc-test.c | ||
19 | +++ b/tests/qtest/aspeed_smc-test.c | ||
20 | @@ -XXX,XX +XXX,XX @@ | ||
21 | * ASPEED SPI Controller registers | ||
22 | */ | ||
23 | #define R_CONF 0x00 | ||
24 | -#define CONF_ENABLE_W0 (1 << 16) | ||
25 | +#define CONF_ENABLE_W0 16 | ||
26 | #define R_CE_CTRL 0x04 | ||
27 | #define CRTL_EXTENDED0 0 /* 32 bit addressing for SPI */ | ||
28 | #define R_CTRL0 0x10 | ||
29 | -#define CTRL_CE_STOP_ACTIVE (1 << 2) | ||
30 | +#define CTRL_CE_STOP_ACTIVE BIT(2) | ||
31 | #define CTRL_READMODE 0x0 | ||
32 | #define CTRL_FREADMODE 0x1 | ||
33 | #define CTRL_WRITEMODE 0x2 | ||
34 | @@ -XXX,XX +XXX,XX @@ typedef struct TestData { | ||
35 | uint64_t flash_base; | ||
36 | uint32_t jedec_id; | ||
37 | char *tmp_path; | ||
38 | + uint8_t cs; | ||
39 | + const char *node; | ||
40 | } TestData; | ||
41 | |||
42 | /* | ||
43 | @@ -XXX,XX +XXX,XX @@ static void spi_ce_ctrl(const TestData *data, uint32_t value) | ||
44 | |||
45 | static void spi_ctrl_setmode(const TestData *data, uint8_t mode, uint8_t cmd) | ||
46 | { | ||
47 | - uint32_t ctrl = spi_readl(data, R_CTRL0); | ||
48 | + uint32_t ctrl_reg = R_CTRL0 + data->cs * 4; | ||
49 | + uint32_t ctrl = spi_readl(data, ctrl_reg); | ||
50 | ctrl &= ~(CTRL_USERMODE | 0xff << 16); | ||
51 | ctrl |= mode | (cmd << 16); | ||
52 | - spi_writel(data, R_CTRL0, ctrl); | ||
53 | + spi_writel(data, ctrl_reg, ctrl); | ||
54 | } | ||
55 | |||
56 | static void spi_ctrl_start_user(const TestData *data) | ||
57 | { | ||
58 | - uint32_t ctrl = spi_readl(data, R_CTRL0); | ||
59 | + uint32_t ctrl_reg = R_CTRL0 + data->cs * 4; | ||
60 | + uint32_t ctrl = spi_readl(data, ctrl_reg); | ||
61 | |||
62 | ctrl |= CTRL_USERMODE | CTRL_CE_STOP_ACTIVE; | ||
63 | - spi_writel(data, R_CTRL0, ctrl); | ||
64 | + spi_writel(data, ctrl_reg, ctrl); | ||
65 | |||
66 | ctrl &= ~CTRL_CE_STOP_ACTIVE; | ||
67 | - spi_writel(data, R_CTRL0, ctrl); | ||
68 | + spi_writel(data, ctrl_reg, ctrl); | ||
69 | } | ||
70 | |||
71 | static void spi_ctrl_stop_user(const TestData *data) | ||
72 | { | ||
73 | - uint32_t ctrl = spi_readl(data, R_CTRL0); | ||
74 | + uint32_t ctrl_reg = R_CTRL0 + data->cs * 4; | ||
75 | + uint32_t ctrl = spi_readl(data, ctrl_reg); | ||
76 | |||
77 | ctrl |= CTRL_USERMODE | CTRL_CE_STOP_ACTIVE; | ||
78 | - spi_writel(data, R_CTRL0, ctrl); | ||
79 | + spi_writel(data, ctrl_reg, ctrl); | ||
80 | } | ||
81 | |||
82 | static void flash_reset(const TestData *data) | ||
83 | { | ||
84 | - spi_conf(data, CONF_ENABLE_W0); | ||
85 | + spi_conf(data, 1 << (CONF_ENABLE_W0 + data->cs)); | ||
86 | |||
87 | spi_ctrl_start_user(data); | ||
88 | flash_writeb(data, 0, RESET_ENABLE); | ||
89 | @@ -XXX,XX +XXX,XX @@ static void flash_reset(const TestData *data) | ||
90 | flash_writeb(data, 0, WRDI); | ||
91 | spi_ctrl_stop_user(data); | ||
92 | |||
93 | - spi_conf_remove(data, CONF_ENABLE_W0); | ||
94 | + spi_conf_remove(data, 1 << (CONF_ENABLE_W0 + data->cs)); | ||
95 | } | ||
96 | |||
97 | static void test_read_jedec(const void *data) | ||
98 | @@ -XXX,XX +XXX,XX @@ static void test_read_jedec(const void *data) | ||
99 | const TestData *test_data = (const TestData *)data; | ||
100 | uint32_t jedec = 0x0; | ||
101 | |||
102 | - spi_conf(test_data, CONF_ENABLE_W0); | ||
103 | + spi_conf(test_data, 1 << (CONF_ENABLE_W0 + test_data->cs)); | ||
104 | |||
105 | spi_ctrl_start_user(test_data); | ||
106 | flash_writeb(test_data, 0, JEDEC_READ); | ||
107 | @@ -XXX,XX +XXX,XX @@ static void test_erase_sector(const void *data) | ||
108 | uint32_t page[FLASH_PAGE_SIZE / 4]; | ||
109 | int i; | ||
110 | |||
111 | - spi_conf(test_data, CONF_ENABLE_W0); | ||
112 | + spi_conf(test_data, 1 << (CONF_ENABLE_W0 + test_data->cs)); | ||
113 | |||
114 | /* | ||
115 | * Previous page should be full of 0xffs after backend is | ||
116 | @@ -XXX,XX +XXX,XX @@ static void test_erase_all(const void *data) | ||
117 | uint32_t page[FLASH_PAGE_SIZE / 4]; | ||
118 | int i; | ||
119 | |||
120 | - spi_conf(test_data, CONF_ENABLE_W0); | ||
121 | + spi_conf(test_data, 1 << (CONF_ENABLE_W0 + test_data->cs)); | ||
122 | |||
123 | /* | ||
124 | * Previous page should be full of 0xffs after backend is | ||
125 | @@ -XXX,XX +XXX,XX @@ static void test_write_page(const void *data) | ||
126 | uint32_t page[FLASH_PAGE_SIZE / 4]; | ||
127 | int i; | ||
128 | |||
129 | - spi_conf(test_data, CONF_ENABLE_W0); | ||
130 | + spi_conf(test_data, 1 << (CONF_ENABLE_W0 + test_data->cs)); | ||
131 | |||
132 | spi_ctrl_start_user(test_data); | ||
133 | flash_writeb(test_data, 0, EN_4BYTE_ADDR); | ||
134 | @@ -XXX,XX +XXX,XX @@ static void test_read_page_mem(const void *data) | ||
135 | int i; | ||
136 | |||
137 | /* | ||
138 | - * Enable 4BYTE mode for controller. This is should be strapped by | ||
139 | - * HW for CE0 anyhow. | ||
140 | + * Enable 4BYTE mode for controller. | ||
141 | */ | ||
142 | - spi_ce_ctrl(test_data, 1 << CRTL_EXTENDED0); | ||
143 | + spi_ce_ctrl(test_data, 1 << (CRTL_EXTENDED0 + test_data->cs)); | ||
144 | |||
145 | /* Enable 4BYTE mode for flash. */ | ||
146 | - spi_conf(test_data, CONF_ENABLE_W0); | ||
147 | + spi_conf(test_data, 1 << (CONF_ENABLE_W0 + test_data->cs)); | ||
148 | spi_ctrl_start_user(test_data); | ||
149 | flash_writeb(test_data, 0, EN_4BYTE_ADDR); | ||
150 | flash_writeb(test_data, 0, WREN); | ||
151 | @@ -XXX,XX +XXX,XX @@ static void test_read_page_mem(const void *data) | ||
152 | flash_writel(test_data, 0, make_be32(my_page_addr + i * 4)); | ||
153 | } | ||
154 | spi_ctrl_stop_user(test_data); | ||
155 | - spi_conf_remove(test_data, CONF_ENABLE_W0); | ||
156 | + spi_conf_remove(test_data, 1 << (CONF_ENABLE_W0 + test_data->cs)); | ||
157 | |||
158 | /* Check what was written */ | ||
159 | read_page_mem(test_data, my_page_addr, page); | ||
160 | @@ -XXX,XX +XXX,XX @@ static void test_write_page_mem(const void *data) | ||
161 | int i; | ||
162 | |||
163 | /* | ||
164 | - * Enable 4BYTE mode for controller. This is should be strapped by | ||
165 | - * HW for CE0 anyhow. | ||
166 | + * Enable 4BYTE mode for controller. | ||
167 | */ | ||
168 | - spi_ce_ctrl(test_data, 1 << CRTL_EXTENDED0); | ||
169 | + spi_ce_ctrl(test_data, 1 << (CRTL_EXTENDED0 + test_data->cs)); | ||
170 | |||
171 | /* Enable 4BYTE mode for flash. */ | ||
172 | - spi_conf(test_data, CONF_ENABLE_W0); | ||
173 | + spi_conf(test_data, 1 << (CONF_ENABLE_W0 + test_data->cs)); | ||
174 | spi_ctrl_start_user(test_data); | ||
175 | flash_writeb(test_data, 0, EN_4BYTE_ADDR); | ||
176 | flash_writeb(test_data, 0, WREN); | ||
177 | @@ -XXX,XX +XXX,XX @@ static void test_read_status_reg(const void *data) | ||
178 | const TestData *test_data = (const TestData *)data; | ||
179 | uint8_t r; | ||
180 | |||
181 | - spi_conf(test_data, CONF_ENABLE_W0); | ||
182 | + spi_conf(test_data, 1 << (CONF_ENABLE_W0 + test_data->cs)); | ||
183 | |||
184 | spi_ctrl_start_user(test_data); | ||
185 | flash_writeb(test_data, 0, RDSR); | ||
186 | @@ -XXX,XX +XXX,XX @@ static void test_read_status_reg(const void *data) | ||
187 | |||
188 | g_assert_cmphex(r & SR_WEL, ==, 0); | ||
189 | g_assert(!qtest_qom_get_bool | ||
190 | - (test_data->s, "/machine/soc/fmc/ssi.0/child[0]", "write-enable")); | ||
191 | + (test_data->s, test_data->node, "write-enable")); | ||
192 | |||
193 | spi_ctrl_start_user(test_data); | ||
194 | flash_writeb(test_data, 0, WREN); | ||
195 | @@ -XXX,XX +XXX,XX @@ static void test_read_status_reg(const void *data) | ||
196 | |||
197 | g_assert_cmphex(r & SR_WEL, ==, SR_WEL); | ||
198 | g_assert(qtest_qom_get_bool | ||
199 | - (test_data->s, "/machine/soc/fmc/ssi.0/child[0]", "write-enable")); | ||
200 | + (test_data->s, test_data->node, "write-enable")); | ||
201 | |||
202 | spi_ctrl_start_user(test_data); | ||
203 | flash_writeb(test_data, 0, WRDI); | ||
204 | @@ -XXX,XX +XXX,XX @@ static void test_read_status_reg(const void *data) | ||
205 | |||
206 | g_assert_cmphex(r & SR_WEL, ==, 0); | ||
207 | g_assert(!qtest_qom_get_bool | ||
208 | - (test_data->s, "/machine/soc/fmc/ssi.0/child[0]", "write-enable")); | ||
209 | + (test_data->s, test_data->node, "write-enable")); | ||
210 | |||
211 | flash_reset(test_data); | ||
212 | } | ||
213 | @@ -XXX,XX +XXX,XX @@ static void test_status_reg_write_protection(const void *data) | ||
214 | const TestData *test_data = (const TestData *)data; | ||
215 | uint8_t r; | ||
216 | |||
217 | - spi_conf(test_data, CONF_ENABLE_W0); | ||
218 | + spi_conf(test_data, 1 << (CONF_ENABLE_W0 + test_data->cs)); | ||
219 | |||
220 | /* default case: WP# is high and SRWD is low -> status register writable */ | ||
221 | spi_ctrl_start_user(test_data); | ||
222 | @@ -XXX,XX +XXX,XX @@ static void test_status_reg_write_protection(const void *data) | ||
223 | g_assert_cmphex(r & SRWD, ==, 0); | ||
224 | |||
225 | /* WP# low and SRWD low -> status register writable */ | ||
226 | - qtest_set_irq_in(test_data->s, | ||
227 | - "/machine/soc/fmc/ssi.0/child[0]", "WP#", 0, 0); | ||
228 | + qtest_set_irq_in(test_data->s, test_data->node, "WP#", 0, 0); | ||
229 | spi_ctrl_start_user(test_data); | ||
230 | flash_writeb(test_data, 0, WREN); | ||
231 | /* test ability to write SRWD */ | ||
232 | @@ -XXX,XX +XXX,XX @@ static void test_status_reg_write_protection(const void *data) | ||
233 | /* write is not successful */ | ||
234 | g_assert_cmphex(r & SRWD, ==, SRWD); | ||
235 | |||
236 | - qtest_set_irq_in(test_data->s, | ||
237 | - "/machine/soc/fmc/ssi.0/child[0]", "WP#", 0, 1); | ||
238 | + qtest_set_irq_in(test_data->s, test_data->node, "WP#", 0, 1); | ||
239 | flash_reset(test_data); | ||
240 | } | ||
241 | |||
242 | @@ -XXX,XX +XXX,XX @@ static void test_write_block_protect(const void *data) | ||
243 | uint32_t sector_size = 65536; | ||
244 | uint32_t n_sectors = 512; | ||
245 | |||
246 | - spi_ce_ctrl(test_data, 1 << CRTL_EXTENDED0); | ||
247 | - spi_conf(test_data, CONF_ENABLE_W0); | ||
248 | + spi_ce_ctrl(test_data, 1 << (CRTL_EXTENDED0 + test_data->cs)); | ||
249 | + spi_conf(test_data, 1 << (CONF_ENABLE_W0 + test_data->cs)); | ||
250 | |||
251 | uint32_t bp_bits = 0b0; | ||
252 | |||
253 | @@ -XXX,XX +XXX,XX @@ static void test_write_block_protect_bottom_bit(const void *data) | ||
254 | uint32_t sector_size = 65536; | ||
255 | uint32_t n_sectors = 512; | ||
256 | |||
257 | - spi_ce_ctrl(test_data, 1 << CRTL_EXTENDED0); | ||
258 | - spi_conf(test_data, CONF_ENABLE_W0); | ||
259 | + spi_ce_ctrl(test_data, 1 << (CRTL_EXTENDED0 + test_data->cs)); | ||
260 | + spi_conf(test_data, 1 << (CONF_ENABLE_W0 + test_data->cs)); | ||
261 | |||
262 | /* top bottom bit is enabled */ | ||
263 | uint32_t bp_bits = 0b00100 << 3; | ||
264 | @@ -XXX,XX +XXX,XX @@ static void test_palmetto_bmc(TestData *data) | ||
265 | data->flash_base = 0x20000000; | ||
266 | data->spi_base = 0x1E620000; | ||
267 | data->jedec_id = 0x20ba19; | ||
268 | + data->cs = 0; | ||
269 | + data->node = "/machine/soc/fmc/ssi.0/child[0]"; | ||
270 | |||
271 | qtest_add_data_func("/ast2400/smc/read_jedec", data, test_read_jedec); | ||
272 | qtest_add_data_func("/ast2400/smc/erase_sector", data, test_erase_sector); | ||
273 | -- | ||
274 | 2.47.1 | ||
275 | |||
276 | diff view generated by jsdifflib |
1 | The SFDP table size is 0x200 bytes long. The mandatory table for basic | 1 | From: Jamin Lin <jamin_lin@aspeedtech.com> |
---|---|---|---|
2 | features is available at byte 0x30 plus some more Macronix specific | ||
3 | tables. | ||
4 | 2 | ||
5 | Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com> | 3 | Currently, these test cases used the hardcode offset 0x1400000 (0x14000 * 256) |
6 | Message-Id: <20220722063602.128144-6-clg@kaod.org> | 4 | which was beyond the 16MB flash size for flash page read/write command testing. |
7 | Message-Id: <20221013161241.2805140-7-clg@kaod.org> | 5 | However, the default fmc flash model of ast1030-a1 EVB is "w25q80bl" whose size |
8 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 6 | is 1MB. To test SoC flash models, introduces a new page_addr member in TestData |
7 | structure, so users can set the offset for flash page read/write command | ||
8 | testing. | ||
9 | |||
10 | Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com> | ||
11 | Reviewed-by: Cédric Le Goater <clg@redhat.com> | ||
12 | Link: https://lore.kernel.org/r/20241127091543.1243114-5-jamin_lin@aspeedtech.com | ||
13 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | ||
9 | --- | 14 | --- |
10 | hw/block/m25p80_sfdp.h | 2 +- | 15 | tests/qtest/aspeed_smc-test.c | 17 ++++++++++------- |
11 | hw/block/m25p80.c | 3 +- | 16 | 1 file changed, 10 insertions(+), 7 deletions(-) |
12 | hw/block/m25p80_sfdp.c | 68 ++++++++++++++++++++++++++++++++++++++++++ | ||
13 | 3 files changed, 71 insertions(+), 2 deletions(-) | ||
14 | 17 | ||
15 | diff --git a/hw/block/m25p80_sfdp.h b/hw/block/m25p80_sfdp.h | 18 | diff --git a/tests/qtest/aspeed_smc-test.c b/tests/qtest/aspeed_smc-test.c |
16 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/block/m25p80_sfdp.h | 20 | --- a/tests/qtest/aspeed_smc-test.c |
18 | +++ b/hw/block/m25p80_sfdp.h | 21 | +++ b/tests/qtest/aspeed_smc-test.c |
19 | @@ -XXX,XX +XXX,XX @@ uint8_t m25p80_sfdp_n25q256a(uint32_t addr); | 22 | @@ -XXX,XX +XXX,XX @@ typedef struct TestData { |
20 | 23 | char *tmp_path; | |
21 | uint8_t m25p80_sfdp_mx25l25635e(uint32_t addr); | 24 | uint8_t cs; |
22 | uint8_t m25p80_sfdp_mx25l25635f(uint32_t addr); | 25 | const char *node; |
23 | - | 26 | + uint32_t page_addr; |
24 | +uint8_t m25p80_sfdp_mx66l1g45g(uint32_t addr); | 27 | } TestData; |
25 | 28 | ||
26 | #endif | 29 | /* |
27 | diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c | 30 | @@ -XXX,XX +XXX,XX @@ static void assert_page_mem(const TestData *data, uint32_t addr, |
28 | index XXXXXXX..XXXXXXX 100644 | 31 | static void test_erase_sector(const void *data) |
29 | --- a/hw/block/m25p80.c | 32 | { |
30 | +++ b/hw/block/m25p80.c | 33 | const TestData *test_data = (const TestData *)data; |
31 | @@ -XXX,XX +XXX,XX @@ static const FlashPartInfo known_devices[] = { | 34 | - uint32_t some_page_addr = 0x600 * FLASH_PAGE_SIZE; |
32 | { INFO("mx66l51235f", 0xc2201a, 0, 64 << 10, 1024, ER_4K | ER_32K) }, | 35 | + uint32_t some_page_addr = test_data->page_addr; |
33 | { INFO("mx66u51235f", 0xc2253a, 0, 64 << 10, 1024, ER_4K | ER_32K) }, | 36 | uint32_t page[FLASH_PAGE_SIZE / 4]; |
34 | { INFO("mx66u1g45g", 0xc2253b, 0, 64 << 10, 2048, ER_4K | ER_32K) }, | 37 | int i; |
35 | - { INFO("mx66l1g45g", 0xc2201b, 0, 64 << 10, 2048, ER_4K | ER_32K) }, | 38 | |
36 | + { INFO("mx66l1g45g", 0xc2201b, 0, 64 << 10, 2048, ER_4K | ER_32K), | 39 | @@ -XXX,XX +XXX,XX @@ static void test_erase_sector(const void *data) |
37 | + .sfdp_read = m25p80_sfdp_mx66l1g45g }, | 40 | static void test_erase_all(const void *data) |
38 | 41 | { | |
39 | /* Micron */ | 42 | const TestData *test_data = (const TestData *)data; |
40 | { INFO("n25q032a11", 0x20bb16, 0, 64 << 10, 64, ER_4K) }, | 43 | - uint32_t some_page_addr = 0x15000 * FLASH_PAGE_SIZE; |
41 | diff --git a/hw/block/m25p80_sfdp.c b/hw/block/m25p80_sfdp.c | 44 | + uint32_t some_page_addr = test_data->page_addr; |
42 | index XXXXXXX..XXXXXXX 100644 | 45 | uint32_t page[FLASH_PAGE_SIZE / 4]; |
43 | --- a/hw/block/m25p80_sfdp.c | 46 | int i; |
44 | +++ b/hw/block/m25p80_sfdp.c | 47 | |
45 | @@ -XXX,XX +XXX,XX @@ static const uint8_t sfdp_mx25l25635f[] = { | 48 | @@ -XXX,XX +XXX,XX @@ static void test_erase_all(const void *data) |
46 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 49 | static void test_write_page(const void *data) |
47 | }; | 50 | { |
48 | define_sfdp_read(mx25l25635f); | 51 | const TestData *test_data = (const TestData *)data; |
49 | + | 52 | - uint32_t my_page_addr = 0x14000 * FLASH_PAGE_SIZE; /* beyond 16MB */ |
50 | +static const uint8_t sfdp_mx66l1g45g[] = { | 53 | - uint32_t some_page_addr = 0x15000 * FLASH_PAGE_SIZE; |
51 | + 0x53, 0x46, 0x44, 0x50, 0x06, 0x01, 0x02, 0xff, | 54 | + uint32_t my_page_addr = test_data->page_addr; |
52 | + 0x00, 0x06, 0x01, 0x10, 0x30, 0x00, 0x00, 0xff, | 55 | + uint32_t some_page_addr = my_page_addr + FLASH_PAGE_SIZE; |
53 | + 0xc2, 0x00, 0x01, 0x04, 0x10, 0x01, 0x00, 0xff, | 56 | uint32_t page[FLASH_PAGE_SIZE / 4]; |
54 | + 0x84, 0x00, 0x01, 0x02, 0xc0, 0x00, 0x00, 0xff, | 57 | int i; |
55 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 58 | |
56 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 59 | @@ -XXX,XX +XXX,XX @@ static void test_write_page(const void *data) |
57 | + 0xe5, 0x20, 0xfb, 0xff, 0xff, 0xff, 0xff, 0x3f, | 60 | static void test_read_page_mem(const void *data) |
58 | + 0x44, 0xeb, 0x08, 0x6b, 0x08, 0x3b, 0x04, 0xbb, | 61 | { |
59 | + 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, | 62 | const TestData *test_data = (const TestData *)data; |
60 | + 0xff, 0xff, 0x44, 0xeb, 0x0c, 0x20, 0x0f, 0x52, | 63 | - uint32_t my_page_addr = 0x14000 * FLASH_PAGE_SIZE; /* beyond 16MB */ |
61 | + 0x10, 0xd8, 0x00, 0xff, 0xd6, 0x49, 0xc5, 0x00, | 64 | - uint32_t some_page_addr = 0x15000 * FLASH_PAGE_SIZE; |
62 | + 0x85, 0xdf, 0x04, 0xe3, 0x44, 0x03, 0x67, 0x38, | 65 | + uint32_t my_page_addr = test_data->page_addr; |
63 | + 0x30, 0xb0, 0x30, 0xb0, 0xf7, 0xbd, 0xd5, 0x5c, | 66 | + uint32_t some_page_addr = my_page_addr + FLASH_PAGE_SIZE; |
64 | + 0x4a, 0x9e, 0x29, 0xff, 0xf0, 0x50, 0xf9, 0x85, | 67 | uint32_t page[FLASH_PAGE_SIZE / 4]; |
65 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 68 | int i; |
66 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 69 | |
67 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 70 | @@ -XXX,XX +XXX,XX @@ static void test_read_page_mem(const void *data) |
68 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 71 | static void test_write_page_mem(const void *data) |
69 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 72 | { |
70 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 73 | const TestData *test_data = (const TestData *)data; |
71 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 74 | - uint32_t my_page_addr = 0x15000 * FLASH_PAGE_SIZE; |
72 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 75 | + uint32_t my_page_addr = test_data->page_addr; |
73 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 76 | uint32_t page[FLASH_PAGE_SIZE / 4]; |
74 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 77 | int i; |
75 | + 0x7f, 0xef, 0xff, 0xff, 0x21, 0x5c, 0xdc, 0xff, | 78 | |
76 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 79 | @@ -XXX,XX +XXX,XX @@ static void test_palmetto_bmc(TestData *data) |
77 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 80 | data->jedec_id = 0x20ba19; |
78 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 81 | data->cs = 0; |
79 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 82 | data->node = "/machine/soc/fmc/ssi.0/child[0]"; |
80 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 83 | + /* beyond 16MB */ |
81 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 84 | + data->page_addr = 0x14000 * FLASH_PAGE_SIZE; |
82 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 85 | |
83 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 86 | qtest_add_data_func("/ast2400/smc/read_jedec", data, test_read_jedec); |
84 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 87 | qtest_add_data_func("/ast2400/smc/erase_sector", data, test_erase_sector); |
85 | + 0x00, 0x36, 0x00, 0x27, 0x9d, 0xf9, 0xc0, 0x64, | ||
86 | + 0x85, 0xcb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
87 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
88 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
89 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
90 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
91 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
92 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
93 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
94 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
95 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
96 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
97 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
98 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
99 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
100 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
101 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
102 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
103 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
104 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
105 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
106 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
107 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
108 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
109 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
110 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
111 | + 0xc2, 0xf5, 0x08, 0x00, 0x0c, 0x04, 0x08, 0x08, | ||
112 | + 0x01, 0x00, 0x19, 0x0f, 0x01, 0x01, 0x06, 0xff, | ||
113 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
114 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
115 | +}; | ||
116 | +define_sfdp_read(mx66l1g45g); | ||
117 | -- | 88 | -- |
118 | 2.37.3 | 89 | 2.47.1 |
119 | 90 | ||
120 | 91 | diff view generated by jsdifflib |
1 | The mx25l25635e and mx25l25635f chips have the same JEDEC id but the | 1 | From: Jamin Lin <jamin_lin@aspeedtech.com> |
---|---|---|---|
2 | mx25l25635f has more capabilities reported in the SFDP table. Support | ||
3 | for 4B opcodes is of interest because it is exploited by the Linux | ||
4 | kernel. | ||
5 | 2 | ||
6 | The SFDP table size is 0x200 bytes long. The mandatory table for basic | 3 | Add test_ast2500_evb function and reused testcases for AST2500 testing. |
7 | features is available at byte 0x30 and an extra Macronix specific | 4 | The spi base address, flash base address and ce index of fmc_cs0 are |
8 | table is available at 0x60. | 5 | 0x1E620000, 0x20000000 and 0, respectively. |
6 | The default flash model of fmc_cs0 is "mx25l25635e" whose size is 32MB, | ||
7 | so set jedec_id 0xc22019. | ||
9 | 8 | ||
10 | Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com> | 9 | Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com> |
11 | Message-Id: <20220722063602.128144-5-clg@kaod.org> | 10 | Reviewed-by: Cédric Le Goater <clg@redhat.com> |
12 | Message-Id: <20221013161241.2805140-6-clg@kaod.org> | 11 | Link: https://lore.kernel.org/r/20241127091543.1243114-6-jamin_lin@aspeedtech.com |
13 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 12 | Signed-off-by: Cédric Le Goater <clg@redhat.com> |
14 | --- | 13 | --- |
15 | hw/block/m25p80_sfdp.h | 1 + | 14 | tests/qtest/aspeed_smc-test.c | 40 +++++++++++++++++++++++++++++++++++ |
16 | hw/block/m25p80.c | 2 ++ | 15 | 1 file changed, 40 insertions(+) |
17 | hw/block/m25p80_sfdp.c | 68 ++++++++++++++++++++++++++++++++++++++++++ | ||
18 | 3 files changed, 71 insertions(+) | ||
19 | 16 | ||
20 | diff --git a/hw/block/m25p80_sfdp.h b/hw/block/m25p80_sfdp.h | 17 | diff --git a/tests/qtest/aspeed_smc-test.c b/tests/qtest/aspeed_smc-test.c |
21 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/hw/block/m25p80_sfdp.h | 19 | --- a/tests/qtest/aspeed_smc-test.c |
23 | +++ b/hw/block/m25p80_sfdp.h | 20 | +++ b/tests/qtest/aspeed_smc-test.c |
24 | @@ -XXX,XX +XXX,XX @@ | 21 | @@ -XXX,XX +XXX,XX @@ static void test_palmetto_bmc(TestData *data) |
25 | uint8_t m25p80_sfdp_n25q256a(uint32_t addr); | 22 | data, test_write_block_protect_bottom_bit); |
26 | 23 | } | |
27 | uint8_t m25p80_sfdp_mx25l25635e(uint32_t addr); | 24 | |
28 | +uint8_t m25p80_sfdp_mx25l25635f(uint32_t addr); | 25 | +static void test_ast2500_evb(TestData *data) |
29 | 26 | +{ | |
30 | 27 | + int ret; | |
31 | #endif | 28 | + int fd; |
32 | diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c | ||
33 | index XXXXXXX..XXXXXXX 100644 | ||
34 | --- a/hw/block/m25p80.c | ||
35 | +++ b/hw/block/m25p80.c | ||
36 | @@ -XXX,XX +XXX,XX @@ static const FlashPartInfo known_devices[] = { | ||
37 | { INFO("mx25l12855e", 0xc22618, 0, 64 << 10, 256, 0) }, | ||
38 | { INFO6("mx25l25635e", 0xc22019, 0xc22019, 64 << 10, 512, | ||
39 | ER_4K | ER_32K), .sfdp_read = m25p80_sfdp_mx25l25635e }, | ||
40 | + { INFO6("mx25l25635f", 0xc22019, 0xc22019, 64 << 10, 512, | ||
41 | + ER_4K | ER_32K), .sfdp_read = m25p80_sfdp_mx25l25635f }, | ||
42 | { INFO("mx25l25655e", 0xc22619, 0, 64 << 10, 512, 0) }, | ||
43 | { INFO("mx66l51235f", 0xc2201a, 0, 64 << 10, 1024, ER_4K | ER_32K) }, | ||
44 | { INFO("mx66u51235f", 0xc2253a, 0, 64 << 10, 1024, ER_4K | ER_32K) }, | ||
45 | diff --git a/hw/block/m25p80_sfdp.c b/hw/block/m25p80_sfdp.c | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/hw/block/m25p80_sfdp.c | ||
48 | +++ b/hw/block/m25p80_sfdp.c | ||
49 | @@ -XXX,XX +XXX,XX @@ static const uint8_t sfdp_mx25l25635e[] = { | ||
50 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
51 | }; | ||
52 | define_sfdp_read(mx25l25635e) | ||
53 | + | 29 | + |
54 | +static const uint8_t sfdp_mx25l25635f[] = { | 30 | + fd = g_file_open_tmp("qtest.m25p80.mx25l25635e.XXXXXX", |
55 | + 0x53, 0x46, 0x44, 0x50, 0x00, 0x01, 0x01, 0xff, | 31 | + &data->tmp_path, NULL); |
56 | + 0x00, 0x00, 0x01, 0x09, 0x30, 0x00, 0x00, 0xff, | 32 | + g_assert(fd >= 0); |
57 | + 0xc2, 0x00, 0x01, 0x04, 0x60, 0x00, 0x00, 0xff, | 33 | + ret = ftruncate(fd, 32 * 1024 * 1024); |
58 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 34 | + g_assert(ret == 0); |
59 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 35 | + close(fd); |
60 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 36 | + |
61 | + 0xe5, 0x20, 0xf3, 0xff, 0xff, 0xff, 0xff, 0x0f, | 37 | + data->s = qtest_initf("-machine ast2500-evb " |
62 | + 0x44, 0xeb, 0x08, 0x6b, 0x08, 0x3b, 0x04, 0xbb, | 38 | + "-drive file=%s,format=raw,if=mtd", |
63 | + 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, | 39 | + data->tmp_path); |
64 | + 0xff, 0xff, 0x44, 0xeb, 0x0c, 0x20, 0x0f, 0x52, | 40 | + |
65 | + 0x10, 0xd8, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, | 41 | + /* fmc cs0 with mx25l25635e flash */ |
66 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 42 | + data->flash_base = 0x20000000; |
67 | + 0x00, 0x36, 0x00, 0x27, 0x9d, 0xf9, 0xc0, 0x64, | 43 | + data->spi_base = 0x1E620000; |
68 | + 0x85, 0xcb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 44 | + data->jedec_id = 0xc22019; |
69 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 45 | + data->cs = 0; |
70 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 46 | + data->node = "/machine/soc/fmc/ssi.0/child[0]"; |
71 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 47 | + /* beyond 16MB */ |
72 | + 0xff, 0xff, 0xff, 0xff, 0xc2, 0xf5, 0x08, 0x0a, | 48 | + data->page_addr = 0x14000 * FLASH_PAGE_SIZE; |
73 | + 0x08, 0x04, 0x03, 0x06, 0x00, 0x00, 0x07, 0x29, | 49 | + |
74 | + 0x17, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 50 | + qtest_add_data_func("/ast2500/smc/read_jedec", data, test_read_jedec); |
75 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 51 | + qtest_add_data_func("/ast2500/smc/erase_sector", data, test_erase_sector); |
76 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 52 | + qtest_add_data_func("/ast2500/smc/erase_all", data, test_erase_all); |
77 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 53 | + qtest_add_data_func("/ast2500/smc/write_page", data, test_write_page); |
78 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 54 | + qtest_add_data_func("/ast2500/smc/read_page_mem", |
79 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 55 | + data, test_read_page_mem); |
80 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 56 | + qtest_add_data_func("/ast2500/smc/write_page_mem", |
81 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 57 | + data, test_write_page_mem); |
82 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 58 | + qtest_add_data_func("/ast2500/smc/read_status_reg", |
83 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 59 | + data, test_read_status_reg); |
84 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 60 | +} |
85 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 61 | int main(int argc, char **argv) |
86 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 62 | { |
87 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 63 | TestData palmetto_data; |
88 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 64 | + TestData ast2500_evb_data; |
89 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 65 | int ret; |
90 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 66 | |
91 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 67 | g_test_init(&argc, &argv, NULL); |
92 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 68 | |
93 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 69 | test_palmetto_bmc(&palmetto_data); |
94 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 70 | + test_ast2500_evb(&ast2500_evb_data); |
95 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 71 | ret = g_test_run(); |
96 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 72 | |
97 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 73 | qtest_quit(palmetto_data.s); |
98 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 74 | + qtest_quit(ast2500_evb_data.s); |
99 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 75 | unlink(palmetto_data.tmp_path); |
100 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 76 | + unlink(ast2500_evb_data.tmp_path); |
101 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 77 | return ret; |
102 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 78 | } |
103 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
104 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
105 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
106 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
107 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
108 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
109 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
110 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
111 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
112 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
113 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
114 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
115 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
116 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
117 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
118 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | ||
119 | +}; | ||
120 | +define_sfdp_read(mx25l25635f); | ||
121 | -- | 79 | -- |
122 | 2.37.3 | 80 | 2.47.1 |
123 | 81 | ||
124 | 82 | diff view generated by jsdifflib |
1 | Replace 'buidroot' and 'builroot' by 'buildroot'. | 1 | From: Jamin Lin <jamin_lin@aspeedtech.com> |
---|---|---|---|
2 | 2 | ||
3 | Fixes: f7bc7da0724f ("test/avocado/machine_aspeed.py: Add tests using buildroot images") | 3 | Add test_ast2600_evb function and reused testcases for AST2600 testing. |
4 | Reviewed-by: Thomas Huth <thuth@redhat.com> | 4 | The spi base address, flash base address and ce index of fmc_cs0 are |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 5 | 0x1E620000, 0x20000000 and 0, respectively. |
6 | Reviewed-by: Joel Stanley <joel@jms.id.au> | 6 | The default flash model of fmc_cs0 is "mx66u51235f" whose size is 64MB, |
7 | Message-Id: <20220923084803.498337-2-clg@kaod.org> | 7 | so set jedec_id 0xc2253a. |
8 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 8 | |
9 | Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com> | ||
10 | Reviewed-by: Cédric Le Goater <clg@redhat.com> | ||
11 | Link: https://lore.kernel.org/r/20241127091543.1243114-7-jamin_lin@aspeedtech.com | ||
12 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | ||
9 | --- | 13 | --- |
10 | tests/avocado/machine_aspeed.py | 16 ++++++++-------- | 14 | tests/qtest/aspeed_smc-test.c | 41 +++++++++++++++++++++++++++++++++++ |
11 | 1 file changed, 8 insertions(+), 8 deletions(-) | 15 | 1 file changed, 41 insertions(+) |
12 | 16 | ||
13 | diff --git a/tests/avocado/machine_aspeed.py b/tests/avocado/machine_aspeed.py | 17 | diff --git a/tests/qtest/aspeed_smc-test.c b/tests/qtest/aspeed_smc-test.c |
14 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/tests/avocado/machine_aspeed.py | 19 | --- a/tests/qtest/aspeed_smc-test.c |
16 | +++ b/tests/avocado/machine_aspeed.py | 20 | +++ b/tests/qtest/aspeed_smc-test.c |
17 | @@ -XXX,XX +XXX,XX @@ def test_arm_ast2500_romulus_openbmc_v2_9_0(self): | 21 | @@ -XXX,XX +XXX,XX @@ static void test_ast2500_evb(TestData *data) |
18 | 22 | qtest_add_data_func("/ast2500/smc/read_status_reg", | |
19 | self.do_test_arm_aspeed(image_path) | 23 | data, test_read_status_reg); |
20 | 24 | } | |
21 | - def do_test_arm_aspeed_buidroot_start(self, image, cpu_id): | 25 | + |
22 | + def do_test_arm_aspeed_buildroot_start(self, image, cpu_id): | 26 | +static void test_ast2600_evb(TestData *data) |
23 | self.require_netdev('user') | 27 | +{ |
24 | 28 | + int ret; | |
25 | self.vm.set_console() | 29 | + int fd; |
26 | @@ -XXX,XX +XXX,XX @@ def do_test_arm_aspeed_buidroot_start(self, image, cpu_id): | 30 | + |
27 | exec_command(self, 'root') | 31 | + fd = g_file_open_tmp("qtest.m25p80.mx66u51235f.XXXXXX", |
28 | time.sleep(0.1) | 32 | + &data->tmp_path, NULL); |
29 | 33 | + g_assert(fd >= 0); | |
30 | - def do_test_arm_aspeed_buidroot_poweroff(self): | 34 | + ret = ftruncate(fd, 64 * 1024 * 1024); |
31 | + def do_test_arm_aspeed_buildroot_poweroff(self): | 35 | + g_assert(ret == 0); |
32 | exec_command_and_wait_for_pattern(self, 'poweroff', | 36 | + close(fd); |
33 | 'reboot: System halted'); | 37 | + |
34 | 38 | + data->s = qtest_initf("-machine ast2600-evb " | |
35 | - def test_arm_ast2500_evb_builroot(self): | 39 | + "-drive file=%s,format=raw,if=mtd", |
36 | + def test_arm_ast2500_evb_buildroot(self): | 40 | + data->tmp_path); |
37 | """ | 41 | + |
38 | :avocado: tags=arch:arm | 42 | + /* fmc cs0 with mx66u51235f flash */ |
39 | :avocado: tags=machine:ast2500-evb | 43 | + data->flash_base = 0x20000000; |
40 | @@ -XXX,XX +XXX,XX @@ def test_arm_ast2500_evb_builroot(self): | 44 | + data->spi_base = 0x1E620000; |
41 | 45 | + data->jedec_id = 0xc2253a; | |
42 | self.vm.add_args('-device', | 46 | + data->cs = 0; |
43 | 'tmp105,bus=aspeed.i2c.bus.3,address=0x4d,id=tmp-test'); | 47 | + data->node = "/machine/soc/fmc/ssi.0/child[0]"; |
44 | - self.do_test_arm_aspeed_buidroot_start(image_path, '0x0') | 48 | + /* beyond 16MB */ |
45 | + self.do_test_arm_aspeed_buildroot_start(image_path, '0x0') | 49 | + data->page_addr = 0x14000 * FLASH_PAGE_SIZE; |
46 | 50 | + | |
47 | exec_command_and_wait_for_pattern(self, | 51 | + qtest_add_data_func("/ast2600/smc/read_jedec", data, test_read_jedec); |
48 | 'echo lm75 0x4d > /sys/class/i2c-dev/i2c-3/device/new_device', | 52 | + qtest_add_data_func("/ast2600/smc/erase_sector", data, test_erase_sector); |
49 | @@ -XXX,XX +XXX,XX @@ def test_arm_ast2500_evb_builroot(self): | 53 | + qtest_add_data_func("/ast2600/smc/erase_all", data, test_erase_all); |
50 | exec_command_and_wait_for_pattern(self, | 54 | + qtest_add_data_func("/ast2600/smc/write_page", data, test_write_page); |
51 | 'cat /sys/class/hwmon/hwmon1/temp1_input', '18000') | 55 | + qtest_add_data_func("/ast2600/smc/read_page_mem", |
52 | 56 | + data, test_read_page_mem); | |
53 | - self.do_test_arm_aspeed_buidroot_poweroff() | 57 | + qtest_add_data_func("/ast2600/smc/write_page_mem", |
54 | + self.do_test_arm_aspeed_buildroot_poweroff() | 58 | + data, test_write_page_mem); |
55 | 59 | + qtest_add_data_func("/ast2600/smc/read_status_reg", | |
56 | - def test_arm_ast2600_evb_builroot(self): | 60 | + data, test_read_status_reg); |
57 | + def test_arm_ast2600_evb_buildroot(self): | 61 | +} |
58 | """ | 62 | int main(int argc, char **argv) |
59 | :avocado: tags=arch:arm | 63 | { |
60 | :avocado: tags=machine:ast2600-evb | 64 | TestData palmetto_data; |
61 | @@ -XXX,XX +XXX,XX @@ def test_arm_ast2600_evb_builroot(self): | 65 | TestData ast2500_evb_data; |
62 | 'tmp105,bus=aspeed.i2c.bus.3,address=0x4d,id=tmp-test'); | 66 | + TestData ast2600_evb_data; |
63 | self.vm.add_args('-device', | 67 | int ret; |
64 | 'ds1338,bus=aspeed.i2c.bus.3,address=0x32'); | 68 | |
65 | - self.do_test_arm_aspeed_buidroot_start(image_path, '0xf00') | 69 | g_test_init(&argc, &argv, NULL); |
66 | + self.do_test_arm_aspeed_buildroot_start(image_path, '0xf00') | 70 | |
67 | 71 | test_palmetto_bmc(&palmetto_data); | |
68 | exec_command_and_wait_for_pattern(self, | 72 | test_ast2500_evb(&ast2500_evb_data); |
69 | 'echo lm75 0x4d > /sys/class/i2c-dev/i2c-3/device/new_device', | 73 | + test_ast2600_evb(&ast2600_evb_data); |
70 | @@ -XXX,XX +XXX,XX @@ def test_arm_ast2600_evb_builroot(self): | 74 | ret = g_test_run(); |
71 | year = time.strftime("%Y") | 75 | |
72 | exec_command_and_wait_for_pattern(self, 'hwclock -f /dev/rtc1', year); | 76 | qtest_quit(palmetto_data.s); |
73 | 77 | qtest_quit(ast2500_evb_data.s); | |
74 | - self.do_test_arm_aspeed_buidroot_poweroff() | 78 | + qtest_quit(ast2600_evb_data.s); |
75 | + self.do_test_arm_aspeed_buildroot_poweroff() | 79 | unlink(palmetto_data.tmp_path); |
76 | 80 | unlink(ast2500_evb_data.tmp_path); | |
77 | 81 | + unlink(ast2600_evb_data.tmp_path); | |
78 | class AST2x00MachineSDK(QemuSystemTest): | 82 | return ret; |
83 | } | ||
79 | -- | 84 | -- |
80 | 2.37.3 | 85 | 2.47.1 |
81 | 86 | ||
82 | 87 | diff view generated by jsdifflib |
1 | From: Peter Delevoryas <peter@pjd.dev> | 1 | From: Jamin Lin <jamin_lin@aspeedtech.com> |
---|---|---|---|
2 | 2 | ||
3 | I think when Klaus ported his slave mode changes from the original patch | 3 | Add test_ast1030_evb function and reused testcases for AST1030 testing. |
4 | series to the rewritten I2C module, he changed the behavior of the first | 4 | The base address, flash base address and ce index of fmc_cs0 are |
5 | byte that is received by the slave device. | 5 | 0x7E620000, 0x80000000 and 0, respectively. |
6 | The default flash model of fmc_cs0 is "w25q80bl" whose size is 1MB, | ||
7 | so set jedec_id 0xef4014. | ||
6 | 8 | ||
7 | What's supposed to happen is that the AspeedI2CBus's slave device's | 9 | Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com> |
8 | i2c_event callback should run, and if the event is "send_async", then it | 10 | Reviewed-by: Cédric Le Goater <clg@redhat.com> |
9 | should populate the byte buffer with the 8-bit I2C address that is being | 11 | Link: https://lore.kernel.org/r/20241127091543.1243114-8-jamin_lin@aspeedtech.com |
10 | sent to. Since we only support "send_async", the lowest bit should | 12 | Signed-off-by: Cédric Le Goater <clg@redhat.com> |
11 | always be 0 (indicating that the master is requesting to send data). | 13 | --- |
14 | tests/qtest/aspeed_smc-test.c | 42 +++++++++++++++++++++++++++++++++++ | ||
15 | 1 file changed, 42 insertions(+) | ||
12 | 16 | ||
13 | This is the code Klaus had previously, for reference. [1] | 17 | diff --git a/tests/qtest/aspeed_smc-test.c b/tests/qtest/aspeed_smc-test.c |
14 | |||
15 | switch (event) { | ||
16 | case I2C_START_SEND: | ||
17 | bus->buf = bus->dev_addr << 1; | ||
18 | |||
19 | bus->buf &= I2CD_BYTE_BUF_RX_MASK; | ||
20 | bus->buf <<= I2CD_BYTE_BUF_RX_SHIFT; | ||
21 | |||
22 | bus->intr_status |= (I2CD_INTR_SLAVE_ADDR_RX_MATCH | I2CD_INTR_RX_DONE); | ||
23 | aspeed_i2c_set_state(bus, I2CD_STXD); | ||
24 | |||
25 | break; | ||
26 | |||
27 | [1]: https://lore.kernel.org/qemu-devel/20220331165737.1073520-4-its@irrelevant.dk/ | ||
28 | |||
29 | Fixes: a8d48f59cd021b25 ("hw/i2c/aspeed: add slave device in old register mode") | ||
30 | Signed-off-by: Peter Delevoryas <peter@pjd.dev> | ||
31 | Reviewed-by: Klaus Jensen <k.jensen@samsung.com> | ||
32 | Message-Id: <20220820225712.713209-2-peter@pjd.dev> | ||
33 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
34 | --- | ||
35 | include/hw/i2c/aspeed_i2c.h | 1 + | ||
36 | hw/i2c/aspeed_i2c.c | 8 +++++--- | ||
37 | 2 files changed, 6 insertions(+), 3 deletions(-) | ||
38 | |||
39 | diff --git a/include/hw/i2c/aspeed_i2c.h b/include/hw/i2c/aspeed_i2c.h | ||
40 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
41 | --- a/include/hw/i2c/aspeed_i2c.h | 19 | --- a/tests/qtest/aspeed_smc-test.c |
42 | +++ b/include/hw/i2c/aspeed_i2c.h | 20 | +++ b/tests/qtest/aspeed_smc-test.c |
43 | @@ -XXX,XX +XXX,XX @@ REG32(I2CD_CMD, 0x14) /* I2CD Command/Status */ | 21 | @@ -XXX,XX +XXX,XX @@ static void test_ast2600_evb(TestData *data) |
44 | SHARED_FIELD(M_TX_CMD, 1, 1) | 22 | qtest_add_data_func("/ast2600/smc/read_status_reg", |
45 | SHARED_FIELD(M_START_CMD, 0, 1) | 23 | data, test_read_status_reg); |
46 | REG32(I2CD_DEV_ADDR, 0x18) /* Slave Device Address */ | 24 | } |
47 | + SHARED_FIELD(SLAVE_DEV_ADDR1, 0, 7) | 25 | + |
48 | REG32(I2CD_POOL_CTRL, 0x1C) /* Pool Buffer Control */ | 26 | +static void test_ast1030_evb(TestData *data) |
49 | SHARED_FIELD(RX_COUNT, 24, 5) | 27 | +{ |
50 | SHARED_FIELD(RX_SIZE, 16, 5) | 28 | + int ret; |
51 | diff --git a/hw/i2c/aspeed_i2c.c b/hw/i2c/aspeed_i2c.c | 29 | + int fd; |
52 | index XXXXXXX..XXXXXXX 100644 | 30 | + |
53 | --- a/hw/i2c/aspeed_i2c.c | 31 | + fd = g_file_open_tmp("qtest.m25p80.w25q80bl.XXXXXX", |
54 | +++ b/hw/i2c/aspeed_i2c.c | 32 | + &data->tmp_path, NULL); |
55 | @@ -XXX,XX +XXX,XX @@ static int aspeed_i2c_bus_slave_event(I2CSlave *slave, enum i2c_event event) | 33 | + g_assert(fd >= 0); |
56 | AspeedI2CBus *bus = ASPEED_I2C_BUS(qbus->parent); | 34 | + ret = ftruncate(fd, 1 * 1024 * 1024); |
57 | uint32_t reg_intr_sts = aspeed_i2c_bus_intr_sts_offset(bus); | 35 | + g_assert(ret == 0); |
58 | uint32_t reg_byte_buf = aspeed_i2c_bus_byte_buf_offset(bus); | 36 | + close(fd); |
59 | - uint32_t value; | 37 | + |
60 | + uint32_t reg_dev_addr = aspeed_i2c_bus_dev_addr_offset(bus); | 38 | + data->s = qtest_initf("-machine ast1030-evb " |
61 | + uint32_t dev_addr = SHARED_ARRAY_FIELD_EX32(bus->regs, reg_dev_addr, | 39 | + "-drive file=%s,format=raw,if=mtd", |
62 | + SLAVE_DEV_ADDR1); | 40 | + data->tmp_path); |
63 | 41 | + | |
64 | if (aspeed_i2c_is_new_mode(bus->controller)) { | 42 | + /* fmc cs0 with w25q80bl flash */ |
65 | return aspeed_i2c_bus_new_slave_event(bus, event); | 43 | + data->flash_base = 0x80000000; |
66 | @@ -XXX,XX +XXX,XX @@ static int aspeed_i2c_bus_slave_event(I2CSlave *slave, enum i2c_event event) | 44 | + data->spi_base = 0x7E620000; |
67 | 45 | + data->jedec_id = 0xef4014; | |
68 | switch (event) { | 46 | + data->cs = 0; |
69 | case I2C_START_SEND_ASYNC: | 47 | + data->node = "/machine/soc/fmc/ssi.0/child[0]"; |
70 | - value = SHARED_ARRAY_FIELD_EX32(bus->regs, reg_byte_buf, TX_BUF); | 48 | + /* beyond 512KB */ |
71 | - SHARED_ARRAY_FIELD_DP32(bus->regs, reg_byte_buf, RX_BUF, value << 1); | 49 | + data->page_addr = 0x800 * FLASH_PAGE_SIZE; |
72 | + /* Bit[0] == 0 indicates "send". */ | 50 | + |
73 | + SHARED_ARRAY_FIELD_DP32(bus->regs, reg_byte_buf, RX_BUF, dev_addr << 1); | 51 | + qtest_add_data_func("/ast1030/smc/read_jedec", data, test_read_jedec); |
74 | 52 | + qtest_add_data_func("/ast1030/smc/erase_sector", data, test_erase_sector); | |
75 | ARRAY_FIELD_DP32(bus->regs, I2CD_INTR_STS, SLAVE_ADDR_RX_MATCH, 1); | 53 | + qtest_add_data_func("/ast1030/smc/erase_all", data, test_erase_all); |
76 | SHARED_ARRAY_FIELD_DP32(bus->regs, reg_intr_sts, RX_DONE, 1); | 54 | + qtest_add_data_func("/ast1030/smc/write_page", data, test_write_page); |
55 | + qtest_add_data_func("/ast1030/smc/read_page_mem", | ||
56 | + data, test_read_page_mem); | ||
57 | + qtest_add_data_func("/ast1030/smc/write_page_mem", | ||
58 | + data, test_write_page_mem); | ||
59 | + qtest_add_data_func("/ast1030/smc/read_status_reg", | ||
60 | + data, test_read_status_reg); | ||
61 | +} | ||
62 | + | ||
63 | int main(int argc, char **argv) | ||
64 | { | ||
65 | TestData palmetto_data; | ||
66 | TestData ast2500_evb_data; | ||
67 | TestData ast2600_evb_data; | ||
68 | + TestData ast1030_evb_data; | ||
69 | int ret; | ||
70 | |||
71 | g_test_init(&argc, &argv, NULL); | ||
72 | @@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv) | ||
73 | test_palmetto_bmc(&palmetto_data); | ||
74 | test_ast2500_evb(&ast2500_evb_data); | ||
75 | test_ast2600_evb(&ast2600_evb_data); | ||
76 | + test_ast1030_evb(&ast1030_evb_data); | ||
77 | ret = g_test_run(); | ||
78 | |||
79 | qtest_quit(palmetto_data.s); | ||
80 | qtest_quit(ast2500_evb_data.s); | ||
81 | qtest_quit(ast2600_evb_data.s); | ||
82 | + qtest_quit(ast1030_evb_data.s); | ||
83 | unlink(palmetto_data.tmp_path); | ||
84 | unlink(ast2500_evb_data.tmp_path); | ||
85 | unlink(ast2600_evb_data.tmp_path); | ||
86 | + unlink(ast1030_evb_data.tmp_path); | ||
87 | return ret; | ||
88 | } | ||
77 | -- | 89 | -- |
78 | 2.37.3 | 90 | 2.47.1 |
79 | 91 | ||
80 | 92 | diff view generated by jsdifflib |
1 | The SFDP table size is 0x100 bytes long. The mandatory table for basic | 1 | From: Jamin Lin <jamin_lin@aspeedtech.com> |
---|---|---|---|
2 | features is available at byte 0x80 and two extra Winbond specifics | ||
3 | table are available at 0xC0 and 0xF0. | ||
4 | 2 | ||
5 | Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com> | 3 | Add a new testcase for write page command with QPI mode testing. |
6 | Message-Id: <20220722063602.128144-8-clg@kaod.org> | 4 | Currently, only run this testcase for AST2500, AST2600 and AST1030. |
7 | Message-Id: <20221013161241.2805140-9-clg@kaod.org> | 5 | |
8 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 6 | Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com> |
7 | Reviewed-by: Cédric Le Goater <clg@redhat.com> | ||
8 | Link: https://lore.kernel.org/r/20241127091543.1243114-9-jamin_lin@aspeedtech.com | ||
9 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | ||
9 | --- | 10 | --- |
10 | hw/block/m25p80_sfdp.h | 1 + | 11 | tests/qtest/aspeed_smc-test.c | 74 +++++++++++++++++++++++++++++++++++ |
11 | hw/block/m25p80.c | 3 ++- | 12 | 1 file changed, 74 insertions(+) |
12 | hw/block/m25p80_sfdp.c | 36 ++++++++++++++++++++++++++++++++++++ | ||
13 | 3 files changed, 39 insertions(+), 1 deletion(-) | ||
14 | 13 | ||
15 | diff --git a/hw/block/m25p80_sfdp.h b/hw/block/m25p80_sfdp.h | 14 | diff --git a/tests/qtest/aspeed_smc-test.c b/tests/qtest/aspeed_smc-test.c |
16 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/block/m25p80_sfdp.h | 16 | --- a/tests/qtest/aspeed_smc-test.c |
18 | +++ b/hw/block/m25p80_sfdp.h | 17 | +++ b/tests/qtest/aspeed_smc-test.c |
19 | @@ -XXX,XX +XXX,XX @@ uint8_t m25p80_sfdp_mx25l25635f(uint32_t addr); | 18 | @@ -XXX,XX +XXX,XX @@ |
20 | uint8_t m25p80_sfdp_mx66l1g45g(uint32_t addr); | 19 | #define R_CE_CTRL 0x04 |
21 | 20 | #define CRTL_EXTENDED0 0 /* 32 bit addressing for SPI */ | |
22 | uint8_t m25p80_sfdp_w25q256(uint32_t addr); | 21 | #define R_CTRL0 0x10 |
23 | +uint8_t m25p80_sfdp_w25q512jv(uint32_t addr); | 22 | +#define CTRL_IO_QUAD_IO BIT(31) |
24 | 23 | #define CTRL_CE_STOP_ACTIVE BIT(2) | |
25 | #endif | 24 | #define CTRL_READMODE 0x0 |
26 | diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c | 25 | #define CTRL_FREADMODE 0x1 |
27 | index XXXXXXX..XXXXXXX 100644 | 26 | @@ -XXX,XX +XXX,XX @@ enum { |
28 | --- a/hw/block/m25p80.c | 27 | ERASE_SECTOR = 0xd8, |
29 | +++ b/hw/block/m25p80.c | ||
30 | @@ -XXX,XX +XXX,XX @@ static const FlashPartInfo known_devices[] = { | ||
31 | { INFO("w25q80bl", 0xef4014, 0, 64 << 10, 16, ER_4K) }, | ||
32 | { INFO("w25q256", 0xef4019, 0, 64 << 10, 512, ER_4K), | ||
33 | .sfdp_read = m25p80_sfdp_w25q256 }, | ||
34 | - { INFO("w25q512jv", 0xef4020, 0, 64 << 10, 1024, ER_4K) }, | ||
35 | + { INFO("w25q512jv", 0xef4020, 0, 64 << 10, 1024, ER_4K), | ||
36 | + .sfdp_read = m25p80_sfdp_w25q512jv }, | ||
37 | { INFO("w25q01jvq", 0xef4021, 0, 64 << 10, 2048, ER_4K) }, | ||
38 | }; | 28 | }; |
39 | 29 | ||
40 | diff --git a/hw/block/m25p80_sfdp.c b/hw/block/m25p80_sfdp.c | 30 | +#define CTRL_IO_MODE_MASK (BIT(31) | BIT(30) | BIT(29) | BIT(28)) |
41 | index XXXXXXX..XXXXXXX 100644 | 31 | #define FLASH_PAGE_SIZE 256 |
42 | --- a/hw/block/m25p80_sfdp.c | 32 | |
43 | +++ b/hw/block/m25p80_sfdp.c | 33 | typedef struct TestData { |
44 | @@ -XXX,XX +XXX,XX @@ static const uint8_t sfdp_w25q256[] = { | 34 | @@ -XXX,XX +XXX,XX @@ static void spi_ctrl_stop_user(const TestData *data) |
45 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 35 | spi_writel(data, ctrl_reg, ctrl); |
46 | }; | 36 | } |
47 | define_sfdp_read(w25q256); | 37 | |
38 | +static void spi_ctrl_set_io_mode(const TestData *data, uint32_t value) | ||
39 | +{ | ||
40 | + uint32_t ctrl_reg = R_CTRL0 + data->cs * 4; | ||
41 | + uint32_t ctrl = spi_readl(data, ctrl_reg); | ||
42 | + uint32_t mode; | ||
48 | + | 43 | + |
49 | +static const uint8_t sfdp_w25q512jv[] = { | 44 | + mode = value & CTRL_IO_MODE_MASK; |
50 | + 0x53, 0x46, 0x44, 0x50, 0x06, 0x01, 0x01, 0xff, | 45 | + ctrl &= ~CTRL_IO_MODE_MASK; |
51 | + 0x00, 0x06, 0x01, 0x10, 0x80, 0x00, 0x00, 0xff, | 46 | + ctrl |= mode; |
52 | + 0x84, 0x00, 0x01, 0x02, 0xd0, 0x00, 0x00, 0xff, | 47 | + spi_writel(data, ctrl_reg, ctrl); |
53 | + 0x03, 0x00, 0x01, 0x02, 0xf0, 0x00, 0x00, 0xff, | 48 | +} |
54 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 49 | + |
55 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 50 | static void flash_reset(const TestData *data) |
56 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 51 | { |
57 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 52 | spi_conf(data, 1 << (CONF_ENABLE_W0 + data->cs)); |
58 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 53 | @@ -XXX,XX +XXX,XX @@ static void test_write_block_protect_bottom_bit(const void *data) |
59 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 54 | flash_reset(test_data); |
60 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 55 | } |
61 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 56 | |
62 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 57 | +static void test_write_page_qpi(const void *data) |
63 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 58 | +{ |
64 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 59 | + const TestData *test_data = (const TestData *)data; |
65 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 60 | + uint32_t my_page_addr = test_data->page_addr; |
66 | + 0xe5, 0x20, 0xfb, 0xff, 0xff, 0xff, 0xff, 0x1f, | 61 | + uint32_t some_page_addr = my_page_addr + FLASH_PAGE_SIZE; |
67 | + 0x44, 0xeb, 0x08, 0x6b, 0x08, 0x3b, 0x42, 0xbb, | 62 | + uint32_t page[FLASH_PAGE_SIZE / 4]; |
68 | + 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, | 63 | + uint32_t page_pattern[] = { |
69 | + 0xff, 0xff, 0x40, 0xeb, 0x0c, 0x20, 0x0f, 0x52, | 64 | + 0xebd8c134, 0x5da196bc, 0xae15e729, 0x5085ccdf |
70 | + 0x10, 0xd8, 0x00, 0x00, 0x36, 0x02, 0xa6, 0x00, | 65 | + }; |
71 | + 0x82, 0xea, 0x14, 0xe2, 0xe9, 0x63, 0x76, 0x33, | 66 | + int i; |
72 | + 0x7a, 0x75, 0x7a, 0x75, 0xf7, 0xa2, 0xd5, 0x5c, | 67 | + |
73 | + 0x19, 0xf7, 0x4d, 0xff, 0xe9, 0x70, 0xf9, 0xa5, | 68 | + spi_conf(test_data, 1 << (CONF_ENABLE_W0 + test_data->cs)); |
74 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 69 | + |
75 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 70 | + spi_ctrl_start_user(test_data); |
76 | + 0xff, 0x0a, 0xf0, 0xff, 0x21, 0xff, 0xdc, 0xff, | 71 | + flash_writeb(test_data, 0, EN_4BYTE_ADDR); |
77 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 72 | + flash_writeb(test_data, 0, WREN); |
78 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 73 | + flash_writeb(test_data, 0, PP); |
79 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 74 | + flash_writel(test_data, 0, make_be32(my_page_addr)); |
80 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 75 | + |
81 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 76 | + /* Set QPI mode */ |
82 | +}; | 77 | + spi_ctrl_set_io_mode(test_data, CTRL_IO_QUAD_IO); |
83 | +define_sfdp_read(w25q512jv); | 78 | + |
79 | + /* Fill the page pattern */ | ||
80 | + for (i = 0; i < ARRAY_SIZE(page_pattern); i++) { | ||
81 | + flash_writel(test_data, 0, make_be32(page_pattern[i])); | ||
82 | + } | ||
83 | + | ||
84 | + /* Fill the page with its own addresses */ | ||
85 | + for (; i < FLASH_PAGE_SIZE / 4; i++) { | ||
86 | + flash_writel(test_data, 0, make_be32(my_page_addr + i * 4)); | ||
87 | + } | ||
88 | + | ||
89 | + /* Restore io mode */ | ||
90 | + spi_ctrl_set_io_mode(test_data, 0); | ||
91 | + spi_ctrl_stop_user(test_data); | ||
92 | + | ||
93 | + /* Check what was written */ | ||
94 | + read_page(test_data, my_page_addr, page); | ||
95 | + for (i = 0; i < ARRAY_SIZE(page_pattern); i++) { | ||
96 | + g_assert_cmphex(page[i], ==, page_pattern[i]); | ||
97 | + } | ||
98 | + for (; i < FLASH_PAGE_SIZE / 4; i++) { | ||
99 | + g_assert_cmphex(page[i], ==, my_page_addr + i * 4); | ||
100 | + } | ||
101 | + | ||
102 | + /* Check some other page. It should be full of 0xff */ | ||
103 | + read_page(test_data, some_page_addr, page); | ||
104 | + for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
105 | + g_assert_cmphex(page[i], ==, 0xffffffff); | ||
106 | + } | ||
107 | + | ||
108 | + flash_reset(test_data); | ||
109 | +} | ||
110 | + | ||
111 | static void test_palmetto_bmc(TestData *data) | ||
112 | { | ||
113 | int ret; | ||
114 | @@ -XXX,XX +XXX,XX @@ static void test_ast2500_evb(TestData *data) | ||
115 | data, test_write_page_mem); | ||
116 | qtest_add_data_func("/ast2500/smc/read_status_reg", | ||
117 | data, test_read_status_reg); | ||
118 | + qtest_add_data_func("/ast2500/smc/write_page_qpi", | ||
119 | + data, test_write_page_qpi); | ||
120 | } | ||
121 | |||
122 | static void test_ast2600_evb(TestData *data) | ||
123 | @@ -XXX,XX +XXX,XX @@ static void test_ast2600_evb(TestData *data) | ||
124 | data, test_write_page_mem); | ||
125 | qtest_add_data_func("/ast2600/smc/read_status_reg", | ||
126 | data, test_read_status_reg); | ||
127 | + qtest_add_data_func("/ast2600/smc/write_page_qpi", | ||
128 | + data, test_write_page_qpi); | ||
129 | } | ||
130 | |||
131 | static void test_ast1030_evb(TestData *data) | ||
132 | @@ -XXX,XX +XXX,XX @@ static void test_ast1030_evb(TestData *data) | ||
133 | data, test_write_page_mem); | ||
134 | qtest_add_data_func("/ast1030/smc/read_status_reg", | ||
135 | data, test_read_status_reg); | ||
136 | + qtest_add_data_func("/ast1030/smc/write_page_qpi", | ||
137 | + data, test_write_page_qpi); | ||
138 | } | ||
139 | |||
140 | int main(int argc, char **argv) | ||
84 | -- | 141 | -- |
85 | 2.37.3 | 142 | 2.47.1 |
86 | 143 | ||
87 | 144 | diff view generated by jsdifflib |
1 | JEDEC STANDARD JESD216 for Serial Flash Discovery Parameters (SFDP) | 1 | From: Jamin Lin <jamin_lin@aspeedtech.com> |
---|---|---|---|
2 | provides a mean to describe the features of a serial flash device | ||
3 | using a set of internal parameter tables. | ||
4 | 2 | ||
5 | This is the initial framework for the RDSFDP command giving access to | 3 | The testcases for ASPEED SMC model were placed in aspeed_smc-test.c. |
6 | a private SFDP area under the flash. This area now needs to be | 4 | However, this test file only supports for ARM32. To support all ASPEED SOCs |
7 | populated with the flash device characteristics, using a new | 5 | such as AST2700 whose CPU architecture is aarch64, introduces a new |
8 | 'sfdp_read' handler under FlashPartInfo. | 6 | aspeed-smc-utils source file and move all common APIs and testcases |
7 | from aspeed_smc-test.c to aspeed-smc-utils.c. | ||
9 | 8 | ||
10 | Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com> | 9 | Finally, users are able to re-used these testcase for AST2700 and future |
11 | Message-Id: <20220722063602.128144-2-clg@kaod.org> | 10 | ASPEED SOCs testing. |
12 | Message-Id: <20221013161241.2805140-2-clg@kaod.org> | 11 | |
13 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 12 | Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com> |
13 | Reviewed-by: Cédric Le Goater <clg@redhat.com> | ||
14 | Link: https://lore.kernel.org/r/20241127091543.1243114-10-jamin_lin@aspeedtech.com | ||
15 | Signed-off-by: Cédric Le Goater <clg@redhat.com> | ||
14 | --- | 16 | --- |
15 | hw/block/m25p80_sfdp.h | 18 ++++++++++++++++++ | 17 | tests/qtest/aspeed-smc-utils.h | 95 ++++ |
16 | hw/block/m25p80.c | 27 +++++++++++++++++++++++++++ | 18 | tests/qtest/aspeed-smc-utils.c | 686 ++++++++++++++++++++++++++++ |
17 | MAINTAINERS | 2 +- | 19 | tests/qtest/aspeed_smc-test.c | 800 +++------------------------------ |
18 | hw/block/trace-events | 1 + | 20 | tests/qtest/meson.build | 1 + |
19 | 4 files changed, 47 insertions(+), 1 deletion(-) | 21 | 4 files changed, 841 insertions(+), 741 deletions(-) |
20 | create mode 100644 hw/block/m25p80_sfdp.h | 22 | create mode 100644 tests/qtest/aspeed-smc-utils.h |
23 | create mode 100644 tests/qtest/aspeed-smc-utils.c | ||
21 | 24 | ||
22 | diff --git a/hw/block/m25p80_sfdp.h b/hw/block/m25p80_sfdp.h | 25 | diff --git a/tests/qtest/aspeed-smc-utils.h b/tests/qtest/aspeed-smc-utils.h |
23 | new file mode 100644 | 26 | new file mode 100644 |
24 | index XXXXXXX..XXXXXXX | 27 | index XXXXXXX..XXXXXXX |
25 | --- /dev/null | 28 | --- /dev/null |
26 | +++ b/hw/block/m25p80_sfdp.h | 29 | +++ b/tests/qtest/aspeed-smc-utils.h |
27 | @@ -XXX,XX +XXX,XX @@ | 30 | @@ -XXX,XX +XXX,XX @@ |
28 | +/* | 31 | +/* |
29 | + * M25P80 SFDP | 32 | + * QTest testcase for the M25P80 Flash (Using the Aspeed SPI |
33 | + * Controller) | ||
30 | + * | 34 | + * |
31 | + * Copyright (c) 2020, IBM Corporation. | 35 | + * Copyright (C) 2016 IBM Corp. |
32 | + * | 36 | + * |
33 | + * This code is licensed under the GPL version 2 or later. See the | 37 | + * Permission is hereby granted, free of charge, to any person obtaining a copy |
34 | + * COPYING file in the top-level directory. | 38 | + * of this software and associated documentation files (the "Software"), to deal |
39 | + * in the Software without restriction, including without limitation the rights | ||
40 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
41 | + * copies of the Software, and to permit persons to whom the Software is | ||
42 | + * furnished to do so, subject to the following conditions: | ||
43 | + * | ||
44 | + * The above copyright notice and this permission notice shall be included in | ||
45 | + * all copies or substantial portions of the Software. | ||
46 | + * | ||
47 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
48 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
49 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
50 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
51 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
52 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
53 | + * THE SOFTWARE. | ||
35 | + */ | 54 | + */ |
36 | + | 55 | + |
37 | +#ifndef HW_M25P80_SFDP_H | 56 | +#ifndef TESTS_ASPEED_SMC_UTILS_H |
38 | +#define HW_M25P80_SFDP_H | 57 | +#define TESTS_ASPEED_SMC_UTILS_H |
58 | + | ||
59 | +#include "qemu/osdep.h" | ||
60 | +#include "qemu/bswap.h" | ||
61 | +#include "libqtest-single.h" | ||
62 | +#include "qemu/bitops.h" | ||
39 | + | 63 | + |
40 | +/* | 64 | +/* |
41 | + * SFDP area has a 3 bytes address space. | 65 | + * ASPEED SPI Controller registers |
42 | + */ | 66 | + */ |
43 | +#define M25P80_SFDP_MAX_SIZE (1 << 24) | 67 | +#define R_CONF 0x00 |
44 | + | 68 | +#define CONF_ENABLE_W0 16 |
45 | +#endif | 69 | +#define R_CE_CTRL 0x04 |
46 | diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c | 70 | +#define CRTL_EXTENDED0 0 /* 32 bit addressing for SPI */ |
71 | +#define R_CTRL0 0x10 | ||
72 | +#define CTRL_IO_QUAD_IO BIT(31) | ||
73 | +#define CTRL_CE_STOP_ACTIVE BIT(2) | ||
74 | +#define CTRL_READMODE 0x0 | ||
75 | +#define CTRL_FREADMODE 0x1 | ||
76 | +#define CTRL_WRITEMODE 0x2 | ||
77 | +#define CTRL_USERMODE 0x3 | ||
78 | +#define SR_WEL BIT(1) | ||
79 | + | ||
80 | +/* | ||
81 | + * Flash commands | ||
82 | + */ | ||
83 | +enum { | ||
84 | + JEDEC_READ = 0x9f, | ||
85 | + RDSR = 0x5, | ||
86 | + WRDI = 0x4, | ||
87 | + BULK_ERASE = 0xc7, | ||
88 | + READ = 0x03, | ||
89 | + PP = 0x02, | ||
90 | + WRSR = 0x1, | ||
91 | + WREN = 0x6, | ||
92 | + SRWD = 0x80, | ||
93 | + RESET_ENABLE = 0x66, | ||
94 | + RESET_MEMORY = 0x99, | ||
95 | + EN_4BYTE_ADDR = 0xB7, | ||
96 | + ERASE_SECTOR = 0xd8, | ||
97 | +}; | ||
98 | + | ||
99 | +#define CTRL_IO_MODE_MASK (BIT(31) | BIT(30) | BIT(29) | BIT(28)) | ||
100 | +#define FLASH_PAGE_SIZE 256 | ||
101 | + | ||
102 | +typedef struct AspeedSMCTestData { | ||
103 | + QTestState *s; | ||
104 | + uint64_t spi_base; | ||
105 | + uint64_t flash_base; | ||
106 | + uint32_t jedec_id; | ||
107 | + char *tmp_path; | ||
108 | + uint8_t cs; | ||
109 | + const char *node; | ||
110 | + uint32_t page_addr; | ||
111 | +} AspeedSMCTestData; | ||
112 | + | ||
113 | +void aspeed_smc_test_read_jedec(const void *data); | ||
114 | +void aspeed_smc_test_erase_sector(const void *data); | ||
115 | +void aspeed_smc_test_erase_all(const void *data); | ||
116 | +void aspeed_smc_test_write_page(const void *data); | ||
117 | +void aspeed_smc_test_read_page_mem(const void *data); | ||
118 | +void aspeed_smc_test_write_page_mem(const void *data); | ||
119 | +void aspeed_smc_test_read_status_reg(const void *data); | ||
120 | +void aspeed_smc_test_status_reg_write_protection(const void *data); | ||
121 | +void aspeed_smc_test_write_block_protect(const void *data); | ||
122 | +void aspeed_smc_test_write_block_protect_bottom_bit(const void *data); | ||
123 | +void aspeed_smc_test_write_page_qpi(const void *data); | ||
124 | + | ||
125 | +#endif /* TESTS_ASPEED_SMC_UTILS_H */ | ||
126 | diff --git a/tests/qtest/aspeed-smc-utils.c b/tests/qtest/aspeed-smc-utils.c | ||
127 | new file mode 100644 | ||
128 | index XXXXXXX..XXXXXXX | ||
129 | --- /dev/null | ||
130 | +++ b/tests/qtest/aspeed-smc-utils.c | ||
131 | @@ -XXX,XX +XXX,XX @@ | ||
132 | +/* | ||
133 | + * QTest testcase for the M25P80 Flash (Using the Aspeed SPI | ||
134 | + * Controller) | ||
135 | + * | ||
136 | + * Copyright (C) 2016 IBM Corp. | ||
137 | + * | ||
138 | + * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
139 | + * of this software and associated documentation files (the "Software"), to deal | ||
140 | + * in the Software without restriction, including without limitation the rights | ||
141 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
142 | + * copies of the Software, and to permit persons to whom the Software is | ||
143 | + * furnished to do so, subject to the following conditions: | ||
144 | + * | ||
145 | + * The above copyright notice and this permission notice shall be included in | ||
146 | + * all copies or substantial portions of the Software. | ||
147 | + * | ||
148 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
149 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
150 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
151 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
152 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
153 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
154 | + * THE SOFTWARE. | ||
155 | + */ | ||
156 | + | ||
157 | +#include "qemu/osdep.h" | ||
158 | +#include "qemu/bswap.h" | ||
159 | +#include "libqtest-single.h" | ||
160 | +#include "qemu/bitops.h" | ||
161 | +#include "aspeed-smc-utils.h" | ||
162 | + | ||
163 | +/* | ||
164 | + * Use an explicit bswap for the values read/wrote to the flash region | ||
165 | + * as they are BE and the Aspeed CPU is LE. | ||
166 | + */ | ||
167 | +static inline uint32_t make_be32(uint32_t data) | ||
168 | +{ | ||
169 | + return bswap32(data); | ||
170 | +} | ||
171 | + | ||
172 | +static inline void spi_writel(const AspeedSMCTestData *data, uint64_t offset, | ||
173 | + uint32_t value) | ||
174 | +{ | ||
175 | + qtest_writel(data->s, data->spi_base + offset, value); | ||
176 | +} | ||
177 | + | ||
178 | +static inline uint32_t spi_readl(const AspeedSMCTestData *data, uint64_t offset) | ||
179 | +{ | ||
180 | + return qtest_readl(data->s, data->spi_base + offset); | ||
181 | +} | ||
182 | + | ||
183 | +static inline void flash_writeb(const AspeedSMCTestData *data, uint64_t offset, | ||
184 | + uint8_t value) | ||
185 | +{ | ||
186 | + qtest_writeb(data->s, data->flash_base + offset, value); | ||
187 | +} | ||
188 | + | ||
189 | +static inline void flash_writel(const AspeedSMCTestData *data, uint64_t offset, | ||
190 | + uint32_t value) | ||
191 | +{ | ||
192 | + qtest_writel(data->s, data->flash_base + offset, value); | ||
193 | +} | ||
194 | + | ||
195 | +static inline uint8_t flash_readb(const AspeedSMCTestData *data, | ||
196 | + uint64_t offset) | ||
197 | +{ | ||
198 | + return qtest_readb(data->s, data->flash_base + offset); | ||
199 | +} | ||
200 | + | ||
201 | +static inline uint32_t flash_readl(const AspeedSMCTestData *data, | ||
202 | + uint64_t offset) | ||
203 | +{ | ||
204 | + return qtest_readl(data->s, data->flash_base + offset); | ||
205 | +} | ||
206 | + | ||
207 | +static void spi_conf(const AspeedSMCTestData *data, uint32_t value) | ||
208 | +{ | ||
209 | + uint32_t conf = spi_readl(data, R_CONF); | ||
210 | + | ||
211 | + conf |= value; | ||
212 | + spi_writel(data, R_CONF, conf); | ||
213 | +} | ||
214 | + | ||
215 | +static void spi_conf_remove(const AspeedSMCTestData *data, uint32_t value) | ||
216 | +{ | ||
217 | + uint32_t conf = spi_readl(data, R_CONF); | ||
218 | + | ||
219 | + conf &= ~value; | ||
220 | + spi_writel(data, R_CONF, conf); | ||
221 | +} | ||
222 | + | ||
223 | +static void spi_ce_ctrl(const AspeedSMCTestData *data, uint32_t value) | ||
224 | +{ | ||
225 | + uint32_t conf = spi_readl(data, R_CE_CTRL); | ||
226 | + | ||
227 | + conf |= value; | ||
228 | + spi_writel(data, R_CE_CTRL, conf); | ||
229 | +} | ||
230 | + | ||
231 | +static void spi_ctrl_setmode(const AspeedSMCTestData *data, uint8_t mode, | ||
232 | + uint8_t cmd) | ||
233 | +{ | ||
234 | + uint32_t ctrl_reg = R_CTRL0 + data->cs * 4; | ||
235 | + uint32_t ctrl = spi_readl(data, ctrl_reg); | ||
236 | + ctrl &= ~(CTRL_USERMODE | 0xff << 16); | ||
237 | + ctrl |= mode | (cmd << 16); | ||
238 | + spi_writel(data, ctrl_reg, ctrl); | ||
239 | +} | ||
240 | + | ||
241 | +static void spi_ctrl_start_user(const AspeedSMCTestData *data) | ||
242 | +{ | ||
243 | + uint32_t ctrl_reg = R_CTRL0 + data->cs * 4; | ||
244 | + uint32_t ctrl = spi_readl(data, ctrl_reg); | ||
245 | + | ||
246 | + ctrl |= CTRL_USERMODE | CTRL_CE_STOP_ACTIVE; | ||
247 | + spi_writel(data, ctrl_reg, ctrl); | ||
248 | + | ||
249 | + ctrl &= ~CTRL_CE_STOP_ACTIVE; | ||
250 | + spi_writel(data, ctrl_reg, ctrl); | ||
251 | +} | ||
252 | + | ||
253 | +static void spi_ctrl_stop_user(const AspeedSMCTestData *data) | ||
254 | +{ | ||
255 | + uint32_t ctrl_reg = R_CTRL0 + data->cs * 4; | ||
256 | + uint32_t ctrl = spi_readl(data, ctrl_reg); | ||
257 | + | ||
258 | + ctrl |= CTRL_USERMODE | CTRL_CE_STOP_ACTIVE; | ||
259 | + spi_writel(data, ctrl_reg, ctrl); | ||
260 | +} | ||
261 | + | ||
262 | +static void spi_ctrl_set_io_mode(const AspeedSMCTestData *data, uint32_t value) | ||
263 | +{ | ||
264 | + uint32_t ctrl_reg = R_CTRL0 + data->cs * 4; | ||
265 | + uint32_t ctrl = spi_readl(data, ctrl_reg); | ||
266 | + uint32_t mode; | ||
267 | + | ||
268 | + mode = value & CTRL_IO_MODE_MASK; | ||
269 | + ctrl &= ~CTRL_IO_MODE_MASK; | ||
270 | + ctrl |= mode; | ||
271 | + spi_writel(data, ctrl_reg, ctrl); | ||
272 | +} | ||
273 | + | ||
274 | +static void flash_reset(const AspeedSMCTestData *data) | ||
275 | +{ | ||
276 | + spi_conf(data, 1 << (CONF_ENABLE_W0 + data->cs)); | ||
277 | + | ||
278 | + spi_ctrl_start_user(data); | ||
279 | + flash_writeb(data, 0, RESET_ENABLE); | ||
280 | + flash_writeb(data, 0, RESET_MEMORY); | ||
281 | + flash_writeb(data, 0, WREN); | ||
282 | + flash_writeb(data, 0, BULK_ERASE); | ||
283 | + flash_writeb(data, 0, WRDI); | ||
284 | + spi_ctrl_stop_user(data); | ||
285 | + | ||
286 | + spi_conf_remove(data, 1 << (CONF_ENABLE_W0 + data->cs)); | ||
287 | +} | ||
288 | + | ||
289 | +static void read_page(const AspeedSMCTestData *data, uint32_t addr, | ||
290 | + uint32_t *page) | ||
291 | +{ | ||
292 | + int i; | ||
293 | + | ||
294 | + spi_ctrl_start_user(data); | ||
295 | + | ||
296 | + flash_writeb(data, 0, EN_4BYTE_ADDR); | ||
297 | + flash_writeb(data, 0, READ); | ||
298 | + flash_writel(data, 0, make_be32(addr)); | ||
299 | + | ||
300 | + /* Continuous read are supported */ | ||
301 | + for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
302 | + page[i] = make_be32(flash_readl(data, 0)); | ||
303 | + } | ||
304 | + spi_ctrl_stop_user(data); | ||
305 | +} | ||
306 | + | ||
307 | +static void read_page_mem(const AspeedSMCTestData *data, uint32_t addr, | ||
308 | + uint32_t *page) | ||
309 | +{ | ||
310 | + int i; | ||
311 | + | ||
312 | + /* move out USER mode to use direct reads from the AHB bus */ | ||
313 | + spi_ctrl_setmode(data, CTRL_READMODE, READ); | ||
314 | + | ||
315 | + for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
316 | + page[i] = make_be32(flash_readl(data, addr + i * 4)); | ||
317 | + } | ||
318 | +} | ||
319 | + | ||
320 | +static void write_page_mem(const AspeedSMCTestData *data, uint32_t addr, | ||
321 | + uint32_t write_value) | ||
322 | +{ | ||
323 | + spi_ctrl_setmode(data, CTRL_WRITEMODE, PP); | ||
324 | + | ||
325 | + for (int i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
326 | + flash_writel(data, addr + i * 4, write_value); | ||
327 | + } | ||
328 | +} | ||
329 | + | ||
330 | +static void assert_page_mem(const AspeedSMCTestData *data, uint32_t addr, | ||
331 | + uint32_t expected_value) | ||
332 | +{ | ||
333 | + uint32_t page[FLASH_PAGE_SIZE / 4]; | ||
334 | + read_page_mem(data, addr, page); | ||
335 | + for (int i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
336 | + g_assert_cmphex(page[i], ==, expected_value); | ||
337 | + } | ||
338 | +} | ||
339 | + | ||
340 | +void aspeed_smc_test_read_jedec(const void *data) | ||
341 | +{ | ||
342 | + const AspeedSMCTestData *test_data = (const AspeedSMCTestData *)data; | ||
343 | + uint32_t jedec = 0x0; | ||
344 | + | ||
345 | + spi_conf(test_data, 1 << (CONF_ENABLE_W0 + test_data->cs)); | ||
346 | + | ||
347 | + spi_ctrl_start_user(test_data); | ||
348 | + flash_writeb(test_data, 0, JEDEC_READ); | ||
349 | + jedec |= flash_readb(test_data, 0) << 16; | ||
350 | + jedec |= flash_readb(test_data, 0) << 8; | ||
351 | + jedec |= flash_readb(test_data, 0); | ||
352 | + spi_ctrl_stop_user(test_data); | ||
353 | + | ||
354 | + flash_reset(test_data); | ||
355 | + | ||
356 | + g_assert_cmphex(jedec, ==, test_data->jedec_id); | ||
357 | +} | ||
358 | + | ||
359 | +void aspeed_smc_test_erase_sector(const void *data) | ||
360 | +{ | ||
361 | + const AspeedSMCTestData *test_data = (const AspeedSMCTestData *)data; | ||
362 | + uint32_t some_page_addr = test_data->page_addr; | ||
363 | + uint32_t page[FLASH_PAGE_SIZE / 4]; | ||
364 | + int i; | ||
365 | + | ||
366 | + spi_conf(test_data, 1 << (CONF_ENABLE_W0 + test_data->cs)); | ||
367 | + | ||
368 | + /* | ||
369 | + * Previous page should be full of 0xffs after backend is | ||
370 | + * initialized | ||
371 | + */ | ||
372 | + read_page(test_data, some_page_addr - FLASH_PAGE_SIZE, page); | ||
373 | + for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
374 | + g_assert_cmphex(page[i], ==, 0xffffffff); | ||
375 | + } | ||
376 | + | ||
377 | + spi_ctrl_start_user(test_data); | ||
378 | + flash_writeb(test_data, 0, EN_4BYTE_ADDR); | ||
379 | + flash_writeb(test_data, 0, WREN); | ||
380 | + flash_writeb(test_data, 0, PP); | ||
381 | + flash_writel(test_data, 0, make_be32(some_page_addr)); | ||
382 | + | ||
383 | + /* Fill the page with its own addresses */ | ||
384 | + for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
385 | + flash_writel(test_data, 0, make_be32(some_page_addr + i * 4)); | ||
386 | + } | ||
387 | + spi_ctrl_stop_user(test_data); | ||
388 | + | ||
389 | + /* Check the page is correctly written */ | ||
390 | + read_page(test_data, some_page_addr, page); | ||
391 | + for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
392 | + g_assert_cmphex(page[i], ==, some_page_addr + i * 4); | ||
393 | + } | ||
394 | + | ||
395 | + spi_ctrl_start_user(test_data); | ||
396 | + flash_writeb(test_data, 0, WREN); | ||
397 | + flash_writeb(test_data, 0, EN_4BYTE_ADDR); | ||
398 | + flash_writeb(test_data, 0, ERASE_SECTOR); | ||
399 | + flash_writel(test_data, 0, make_be32(some_page_addr)); | ||
400 | + spi_ctrl_stop_user(test_data); | ||
401 | + | ||
402 | + /* Check the page is erased */ | ||
403 | + read_page(test_data, some_page_addr, page); | ||
404 | + for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
405 | + g_assert_cmphex(page[i], ==, 0xffffffff); | ||
406 | + } | ||
407 | + | ||
408 | + flash_reset(test_data); | ||
409 | +} | ||
410 | + | ||
411 | +void aspeed_smc_test_erase_all(const void *data) | ||
412 | +{ | ||
413 | + const AspeedSMCTestData *test_data = (const AspeedSMCTestData *)data; | ||
414 | + uint32_t some_page_addr = test_data->page_addr; | ||
415 | + uint32_t page[FLASH_PAGE_SIZE / 4]; | ||
416 | + int i; | ||
417 | + | ||
418 | + spi_conf(test_data, 1 << (CONF_ENABLE_W0 + test_data->cs)); | ||
419 | + | ||
420 | + /* | ||
421 | + * Previous page should be full of 0xffs after backend is | ||
422 | + * initialized | ||
423 | + */ | ||
424 | + read_page(test_data, some_page_addr - FLASH_PAGE_SIZE, page); | ||
425 | + for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
426 | + g_assert_cmphex(page[i], ==, 0xffffffff); | ||
427 | + } | ||
428 | + | ||
429 | + spi_ctrl_start_user(test_data); | ||
430 | + flash_writeb(test_data, 0, EN_4BYTE_ADDR); | ||
431 | + flash_writeb(test_data, 0, WREN); | ||
432 | + flash_writeb(test_data, 0, PP); | ||
433 | + flash_writel(test_data, 0, make_be32(some_page_addr)); | ||
434 | + | ||
435 | + /* Fill the page with its own addresses */ | ||
436 | + for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
437 | + flash_writel(test_data, 0, make_be32(some_page_addr + i * 4)); | ||
438 | + } | ||
439 | + spi_ctrl_stop_user(test_data); | ||
440 | + | ||
441 | + /* Check the page is correctly written */ | ||
442 | + read_page(test_data, some_page_addr, page); | ||
443 | + for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
444 | + g_assert_cmphex(page[i], ==, some_page_addr + i * 4); | ||
445 | + } | ||
446 | + | ||
447 | + spi_ctrl_start_user(test_data); | ||
448 | + flash_writeb(test_data, 0, WREN); | ||
449 | + flash_writeb(test_data, 0, BULK_ERASE); | ||
450 | + spi_ctrl_stop_user(test_data); | ||
451 | + | ||
452 | + /* Check the page is erased */ | ||
453 | + read_page(test_data, some_page_addr, page); | ||
454 | + for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
455 | + g_assert_cmphex(page[i], ==, 0xffffffff); | ||
456 | + } | ||
457 | + | ||
458 | + flash_reset(test_data); | ||
459 | +} | ||
460 | + | ||
461 | +void aspeed_smc_test_write_page(const void *data) | ||
462 | +{ | ||
463 | + const AspeedSMCTestData *test_data = (const AspeedSMCTestData *)data; | ||
464 | + uint32_t my_page_addr = test_data->page_addr; | ||
465 | + uint32_t some_page_addr = my_page_addr + FLASH_PAGE_SIZE; | ||
466 | + uint32_t page[FLASH_PAGE_SIZE / 4]; | ||
467 | + int i; | ||
468 | + | ||
469 | + spi_conf(test_data, 1 << (CONF_ENABLE_W0 + test_data->cs)); | ||
470 | + | ||
471 | + spi_ctrl_start_user(test_data); | ||
472 | + flash_writeb(test_data, 0, EN_4BYTE_ADDR); | ||
473 | + flash_writeb(test_data, 0, WREN); | ||
474 | + flash_writeb(test_data, 0, PP); | ||
475 | + flash_writel(test_data, 0, make_be32(my_page_addr)); | ||
476 | + | ||
477 | + /* Fill the page with its own addresses */ | ||
478 | + for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
479 | + flash_writel(test_data, 0, make_be32(my_page_addr + i * 4)); | ||
480 | + } | ||
481 | + spi_ctrl_stop_user(test_data); | ||
482 | + | ||
483 | + /* Check what was written */ | ||
484 | + read_page(test_data, my_page_addr, page); | ||
485 | + for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
486 | + g_assert_cmphex(page[i], ==, my_page_addr + i * 4); | ||
487 | + } | ||
488 | + | ||
489 | + /* Check some other page. It should be full of 0xff */ | ||
490 | + read_page(test_data, some_page_addr, page); | ||
491 | + for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
492 | + g_assert_cmphex(page[i], ==, 0xffffffff); | ||
493 | + } | ||
494 | + | ||
495 | + flash_reset(test_data); | ||
496 | +} | ||
497 | + | ||
498 | +void aspeed_smc_test_read_page_mem(const void *data) | ||
499 | +{ | ||
500 | + const AspeedSMCTestData *test_data = (const AspeedSMCTestData *)data; | ||
501 | + uint32_t my_page_addr = test_data->page_addr; | ||
502 | + uint32_t some_page_addr = my_page_addr + FLASH_PAGE_SIZE; | ||
503 | + uint32_t page[FLASH_PAGE_SIZE / 4]; | ||
504 | + int i; | ||
505 | + | ||
506 | + /* | ||
507 | + * Enable 4BYTE mode for controller. | ||
508 | + */ | ||
509 | + spi_ce_ctrl(test_data, 1 << (CRTL_EXTENDED0 + test_data->cs)); | ||
510 | + | ||
511 | + /* Enable 4BYTE mode for flash. */ | ||
512 | + spi_conf(test_data, 1 << (CONF_ENABLE_W0 + test_data->cs)); | ||
513 | + spi_ctrl_start_user(test_data); | ||
514 | + flash_writeb(test_data, 0, EN_4BYTE_ADDR); | ||
515 | + flash_writeb(test_data, 0, WREN); | ||
516 | + flash_writeb(test_data, 0, PP); | ||
517 | + flash_writel(test_data, 0, make_be32(my_page_addr)); | ||
518 | + | ||
519 | + /* Fill the page with its own addresses */ | ||
520 | + for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
521 | + flash_writel(test_data, 0, make_be32(my_page_addr + i * 4)); | ||
522 | + } | ||
523 | + spi_ctrl_stop_user(test_data); | ||
524 | + spi_conf_remove(test_data, 1 << (CONF_ENABLE_W0 + test_data->cs)); | ||
525 | + | ||
526 | + /* Check what was written */ | ||
527 | + read_page_mem(test_data, my_page_addr, page); | ||
528 | + for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
529 | + g_assert_cmphex(page[i], ==, my_page_addr + i * 4); | ||
530 | + } | ||
531 | + | ||
532 | + /* Check some other page. It should be full of 0xff */ | ||
533 | + read_page_mem(test_data, some_page_addr, page); | ||
534 | + for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
535 | + g_assert_cmphex(page[i], ==, 0xffffffff); | ||
536 | + } | ||
537 | + | ||
538 | + flash_reset(test_data); | ||
539 | +} | ||
540 | + | ||
541 | +void aspeed_smc_test_write_page_mem(const void *data) | ||
542 | +{ | ||
543 | + const AspeedSMCTestData *test_data = (const AspeedSMCTestData *)data; | ||
544 | + uint32_t my_page_addr = test_data->page_addr; | ||
545 | + uint32_t page[FLASH_PAGE_SIZE / 4]; | ||
546 | + int i; | ||
547 | + | ||
548 | + /* | ||
549 | + * Enable 4BYTE mode for controller. | ||
550 | + */ | ||
551 | + spi_ce_ctrl(test_data, 1 << (CRTL_EXTENDED0 + test_data->cs)); | ||
552 | + | ||
553 | + /* Enable 4BYTE mode for flash. */ | ||
554 | + spi_conf(test_data, 1 << (CONF_ENABLE_W0 + test_data->cs)); | ||
555 | + spi_ctrl_start_user(test_data); | ||
556 | + flash_writeb(test_data, 0, EN_4BYTE_ADDR); | ||
557 | + flash_writeb(test_data, 0, WREN); | ||
558 | + spi_ctrl_stop_user(test_data); | ||
559 | + | ||
560 | + /* move out USER mode to use direct writes to the AHB bus */ | ||
561 | + spi_ctrl_setmode(test_data, CTRL_WRITEMODE, PP); | ||
562 | + | ||
563 | + for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
564 | + flash_writel(test_data, my_page_addr + i * 4, | ||
565 | + make_be32(my_page_addr + i * 4)); | ||
566 | + } | ||
567 | + | ||
568 | + /* Check what was written */ | ||
569 | + read_page_mem(test_data, my_page_addr, page); | ||
570 | + for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
571 | + g_assert_cmphex(page[i], ==, my_page_addr + i * 4); | ||
572 | + } | ||
573 | + | ||
574 | + flash_reset(test_data); | ||
575 | +} | ||
576 | + | ||
577 | +void aspeed_smc_test_read_status_reg(const void *data) | ||
578 | +{ | ||
579 | + const AspeedSMCTestData *test_data = (const AspeedSMCTestData *)data; | ||
580 | + uint8_t r; | ||
581 | + | ||
582 | + spi_conf(test_data, 1 << (CONF_ENABLE_W0 + test_data->cs)); | ||
583 | + | ||
584 | + spi_ctrl_start_user(test_data); | ||
585 | + flash_writeb(test_data, 0, RDSR); | ||
586 | + r = flash_readb(test_data, 0); | ||
587 | + spi_ctrl_stop_user(test_data); | ||
588 | + | ||
589 | + g_assert_cmphex(r & SR_WEL, ==, 0); | ||
590 | + g_assert(!qtest_qom_get_bool | ||
591 | + (test_data->s, test_data->node, "write-enable")); | ||
592 | + | ||
593 | + spi_ctrl_start_user(test_data); | ||
594 | + flash_writeb(test_data, 0, WREN); | ||
595 | + flash_writeb(test_data, 0, RDSR); | ||
596 | + r = flash_readb(test_data, 0); | ||
597 | + spi_ctrl_stop_user(test_data); | ||
598 | + | ||
599 | + g_assert_cmphex(r & SR_WEL, ==, SR_WEL); | ||
600 | + g_assert(qtest_qom_get_bool | ||
601 | + (test_data->s, test_data->node, "write-enable")); | ||
602 | + | ||
603 | + spi_ctrl_start_user(test_data); | ||
604 | + flash_writeb(test_data, 0, WRDI); | ||
605 | + flash_writeb(test_data, 0, RDSR); | ||
606 | + r = flash_readb(test_data, 0); | ||
607 | + spi_ctrl_stop_user(test_data); | ||
608 | + | ||
609 | + g_assert_cmphex(r & SR_WEL, ==, 0); | ||
610 | + g_assert(!qtest_qom_get_bool | ||
611 | + (test_data->s, test_data->node, "write-enable")); | ||
612 | + | ||
613 | + flash_reset(test_data); | ||
614 | +} | ||
615 | + | ||
616 | +void aspeed_smc_test_status_reg_write_protection(const void *data) | ||
617 | +{ | ||
618 | + const AspeedSMCTestData *test_data = (const AspeedSMCTestData *)data; | ||
619 | + uint8_t r; | ||
620 | + | ||
621 | + spi_conf(test_data, 1 << (CONF_ENABLE_W0 + test_data->cs)); | ||
622 | + | ||
623 | + /* default case: WP# is high and SRWD is low -> status register writable */ | ||
624 | + spi_ctrl_start_user(test_data); | ||
625 | + flash_writeb(test_data, 0, WREN); | ||
626 | + /* test ability to write SRWD */ | ||
627 | + flash_writeb(test_data, 0, WRSR); | ||
628 | + flash_writeb(test_data, 0, SRWD); | ||
629 | + flash_writeb(test_data, 0, RDSR); | ||
630 | + r = flash_readb(test_data, 0); | ||
631 | + spi_ctrl_stop_user(test_data); | ||
632 | + g_assert_cmphex(r & SRWD, ==, SRWD); | ||
633 | + | ||
634 | + /* WP# high and SRWD high -> status register writable */ | ||
635 | + spi_ctrl_start_user(test_data); | ||
636 | + flash_writeb(test_data, 0, WREN); | ||
637 | + /* test ability to write SRWD */ | ||
638 | + flash_writeb(test_data, 0, WRSR); | ||
639 | + flash_writeb(test_data, 0, 0); | ||
640 | + flash_writeb(test_data, 0, RDSR); | ||
641 | + r = flash_readb(test_data, 0); | ||
642 | + spi_ctrl_stop_user(test_data); | ||
643 | + g_assert_cmphex(r & SRWD, ==, 0); | ||
644 | + | ||
645 | + /* WP# low and SRWD low -> status register writable */ | ||
646 | + qtest_set_irq_in(test_data->s, test_data->node, "WP#", 0, 0); | ||
647 | + spi_ctrl_start_user(test_data); | ||
648 | + flash_writeb(test_data, 0, WREN); | ||
649 | + /* test ability to write SRWD */ | ||
650 | + flash_writeb(test_data, 0, WRSR); | ||
651 | + flash_writeb(test_data, 0, SRWD); | ||
652 | + flash_writeb(test_data, 0, RDSR); | ||
653 | + r = flash_readb(test_data, 0); | ||
654 | + spi_ctrl_stop_user(test_data); | ||
655 | + g_assert_cmphex(r & SRWD, ==, SRWD); | ||
656 | + | ||
657 | + /* WP# low and SRWD high -> status register NOT writable */ | ||
658 | + spi_ctrl_start_user(test_data); | ||
659 | + flash_writeb(test_data, 0 , WREN); | ||
660 | + /* test ability to write SRWD */ | ||
661 | + flash_writeb(test_data, 0, WRSR); | ||
662 | + flash_writeb(test_data, 0, 0); | ||
663 | + flash_writeb(test_data, 0, RDSR); | ||
664 | + r = flash_readb(test_data, 0); | ||
665 | + spi_ctrl_stop_user(test_data); | ||
666 | + /* write is not successful */ | ||
667 | + g_assert_cmphex(r & SRWD, ==, SRWD); | ||
668 | + | ||
669 | + qtest_set_irq_in(test_data->s, test_data->node, "WP#", 0, 1); | ||
670 | + flash_reset(test_data); | ||
671 | +} | ||
672 | + | ||
673 | +void aspeed_smc_test_write_block_protect(const void *data) | ||
674 | +{ | ||
675 | + const AspeedSMCTestData *test_data = (const AspeedSMCTestData *)data; | ||
676 | + uint32_t sector_size = 65536; | ||
677 | + uint32_t n_sectors = 512; | ||
678 | + | ||
679 | + spi_ce_ctrl(test_data, 1 << (CRTL_EXTENDED0 + test_data->cs)); | ||
680 | + spi_conf(test_data, 1 << (CONF_ENABLE_W0 + test_data->cs)); | ||
681 | + | ||
682 | + uint32_t bp_bits = 0b0; | ||
683 | + | ||
684 | + for (int i = 0; i < 16; i++) { | ||
685 | + bp_bits = ((i & 0b1000) << 3) | ((i & 0b0111) << 2); | ||
686 | + | ||
687 | + spi_ctrl_start_user(test_data); | ||
688 | + flash_writeb(test_data, 0, WREN); | ||
689 | + flash_writeb(test_data, 0, BULK_ERASE); | ||
690 | + flash_writeb(test_data, 0, WREN); | ||
691 | + flash_writeb(test_data, 0, WRSR); | ||
692 | + flash_writeb(test_data, 0, bp_bits); | ||
693 | + flash_writeb(test_data, 0, EN_4BYTE_ADDR); | ||
694 | + flash_writeb(test_data, 0, WREN); | ||
695 | + spi_ctrl_stop_user(test_data); | ||
696 | + | ||
697 | + uint32_t num_protected_sectors = i ? MIN(1 << (i - 1), n_sectors) : 0; | ||
698 | + uint32_t protection_start = n_sectors - num_protected_sectors; | ||
699 | + uint32_t protection_end = n_sectors; | ||
700 | + | ||
701 | + for (int sector = 0; sector < n_sectors; sector++) { | ||
702 | + uint32_t addr = sector * sector_size; | ||
703 | + | ||
704 | + assert_page_mem(test_data, addr, 0xffffffff); | ||
705 | + write_page_mem(test_data, addr, make_be32(0xabcdef12)); | ||
706 | + | ||
707 | + uint32_t expected_value = protection_start <= sector | ||
708 | + && sector < protection_end | ||
709 | + ? 0xffffffff : 0xabcdef12; | ||
710 | + | ||
711 | + assert_page_mem(test_data, addr, expected_value); | ||
712 | + } | ||
713 | + } | ||
714 | + | ||
715 | + flash_reset(test_data); | ||
716 | +} | ||
717 | + | ||
718 | +void aspeed_smc_test_write_block_protect_bottom_bit(const void *data) | ||
719 | +{ | ||
720 | + const AspeedSMCTestData *test_data = (const AspeedSMCTestData *)data; | ||
721 | + uint32_t sector_size = 65536; | ||
722 | + uint32_t n_sectors = 512; | ||
723 | + | ||
724 | + spi_ce_ctrl(test_data, 1 << (CRTL_EXTENDED0 + test_data->cs)); | ||
725 | + spi_conf(test_data, 1 << (CONF_ENABLE_W0 + test_data->cs)); | ||
726 | + | ||
727 | + /* top bottom bit is enabled */ | ||
728 | + uint32_t bp_bits = 0b00100 << 3; | ||
729 | + | ||
730 | + for (int i = 0; i < 16; i++) { | ||
731 | + bp_bits = (((i & 0b1000) | 0b0100) << 3) | ((i & 0b0111) << 2); | ||
732 | + | ||
733 | + spi_ctrl_start_user(test_data); | ||
734 | + flash_writeb(test_data, 0, WREN); | ||
735 | + flash_writeb(test_data, 0, BULK_ERASE); | ||
736 | + flash_writeb(test_data, 0, WREN); | ||
737 | + flash_writeb(test_data, 0, WRSR); | ||
738 | + flash_writeb(test_data, 0, bp_bits); | ||
739 | + flash_writeb(test_data, 0, EN_4BYTE_ADDR); | ||
740 | + flash_writeb(test_data, 0, WREN); | ||
741 | + spi_ctrl_stop_user(test_data); | ||
742 | + | ||
743 | + uint32_t num_protected_sectors = i ? MIN(1 << (i - 1), n_sectors) : 0; | ||
744 | + uint32_t protection_start = 0; | ||
745 | + uint32_t protection_end = num_protected_sectors; | ||
746 | + | ||
747 | + for (int sector = 0; sector < n_sectors; sector++) { | ||
748 | + uint32_t addr = sector * sector_size; | ||
749 | + | ||
750 | + assert_page_mem(test_data, addr, 0xffffffff); | ||
751 | + write_page_mem(test_data, addr, make_be32(0xabcdef12)); | ||
752 | + | ||
753 | + uint32_t expected_value = protection_start <= sector | ||
754 | + && sector < protection_end | ||
755 | + ? 0xffffffff : 0xabcdef12; | ||
756 | + | ||
757 | + assert_page_mem(test_data, addr, expected_value); | ||
758 | + } | ||
759 | + } | ||
760 | + | ||
761 | + flash_reset(test_data); | ||
762 | +} | ||
763 | + | ||
764 | +void aspeed_smc_test_write_page_qpi(const void *data) | ||
765 | +{ | ||
766 | + const AspeedSMCTestData *test_data = (const AspeedSMCTestData *)data; | ||
767 | + uint32_t my_page_addr = test_data->page_addr; | ||
768 | + uint32_t some_page_addr = my_page_addr + FLASH_PAGE_SIZE; | ||
769 | + uint32_t page[FLASH_PAGE_SIZE / 4]; | ||
770 | + uint32_t page_pattern[] = { | ||
771 | + 0xebd8c134, 0x5da196bc, 0xae15e729, 0x5085ccdf | ||
772 | + }; | ||
773 | + int i; | ||
774 | + | ||
775 | + spi_conf(test_data, 1 << (CONF_ENABLE_W0 + test_data->cs)); | ||
776 | + | ||
777 | + spi_ctrl_start_user(test_data); | ||
778 | + flash_writeb(test_data, 0, EN_4BYTE_ADDR); | ||
779 | + flash_writeb(test_data, 0, WREN); | ||
780 | + flash_writeb(test_data, 0, PP); | ||
781 | + flash_writel(test_data, 0, make_be32(my_page_addr)); | ||
782 | + | ||
783 | + /* Set QPI mode */ | ||
784 | + spi_ctrl_set_io_mode(test_data, CTRL_IO_QUAD_IO); | ||
785 | + | ||
786 | + /* Fill the page pattern */ | ||
787 | + for (i = 0; i < ARRAY_SIZE(page_pattern); i++) { | ||
788 | + flash_writel(test_data, 0, make_be32(page_pattern[i])); | ||
789 | + } | ||
790 | + | ||
791 | + /* Fill the page with its own addresses */ | ||
792 | + for (; i < FLASH_PAGE_SIZE / 4; i++) { | ||
793 | + flash_writel(test_data, 0, make_be32(my_page_addr + i * 4)); | ||
794 | + } | ||
795 | + | ||
796 | + /* Restore io mode */ | ||
797 | + spi_ctrl_set_io_mode(test_data, 0); | ||
798 | + spi_ctrl_stop_user(test_data); | ||
799 | + | ||
800 | + /* Check what was written */ | ||
801 | + read_page(test_data, my_page_addr, page); | ||
802 | + for (i = 0; i < ARRAY_SIZE(page_pattern); i++) { | ||
803 | + g_assert_cmphex(page[i], ==, page_pattern[i]); | ||
804 | + } | ||
805 | + for (; i < FLASH_PAGE_SIZE / 4; i++) { | ||
806 | + g_assert_cmphex(page[i], ==, my_page_addr + i * 4); | ||
807 | + } | ||
808 | + | ||
809 | + /* Check some other page. It should be full of 0xff */ | ||
810 | + read_page(test_data, some_page_addr, page); | ||
811 | + for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
812 | + g_assert_cmphex(page[i], ==, 0xffffffff); | ||
813 | + } | ||
814 | + | ||
815 | + flash_reset(test_data); | ||
816 | +} | ||
817 | + | ||
818 | diff --git a/tests/qtest/aspeed_smc-test.c b/tests/qtest/aspeed_smc-test.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | 819 | index XXXXXXX..XXXXXXX 100644 |
48 | --- a/hw/block/m25p80.c | 820 | --- a/tests/qtest/aspeed_smc-test.c |
49 | +++ b/hw/block/m25p80.c | 821 | +++ b/tests/qtest/aspeed_smc-test.c |
50 | @@ -XXX,XX +XXX,XX @@ | 822 | @@ -XXX,XX +XXX,XX @@ |
51 | #include "qapi/error.h" | 823 | #include "qemu/bswap.h" |
52 | #include "trace.h" | 824 | #include "libqtest-single.h" |
53 | #include "qom/object.h" | 825 | #include "qemu/bitops.h" |
54 | +#include "m25p80_sfdp.h" | 826 | +#include "aspeed-smc-utils.h" |
55 | 827 | ||
56 | /* 16 MiB max in 3 byte address mode */ | 828 | -/* |
57 | #define MAX_3BYTES_SIZE 0x1000000 | 829 | - * ASPEED SPI Controller registers |
58 | @@ -XXX,XX +XXX,XX @@ typedef struct FlashPartInfo { | 830 | - */ |
59 | * This field inform how many die is in the chip. | 831 | -#define R_CONF 0x00 |
60 | */ | 832 | -#define CONF_ENABLE_W0 16 |
61 | uint8_t die_cnt; | 833 | -#define R_CE_CTRL 0x04 |
62 | + uint8_t (*sfdp_read)(uint32_t sfdp_addr); | 834 | -#define CRTL_EXTENDED0 0 /* 32 bit addressing for SPI */ |
63 | } FlashPartInfo; | 835 | -#define R_CTRL0 0x10 |
64 | 836 | -#define CTRL_IO_QUAD_IO BIT(31) | |
65 | /* adapted from linux */ | 837 | -#define CTRL_CE_STOP_ACTIVE BIT(2) |
66 | @@ -XXX,XX +XXX,XX @@ typedef enum { | 838 | -#define CTRL_READMODE 0x0 |
67 | BULK_ERASE = 0xc7, | 839 | -#define CTRL_FREADMODE 0x1 |
68 | READ_FSR = 0x70, | 840 | -#define CTRL_WRITEMODE 0x2 |
69 | RDCR = 0x15, | 841 | -#define CTRL_USERMODE 0x3 |
70 | + RDSFDP = 0x5a, | 842 | -#define SR_WEL BIT(1) |
71 | 843 | - | |
72 | READ = 0x03, | 844 | -/* |
73 | READ4 = 0x13, | 845 | - * Flash commands |
74 | @@ -XXX,XX +XXX,XX @@ typedef enum { | 846 | - */ |
75 | STATE_COLLECTING_DATA, | 847 | -enum { |
76 | STATE_COLLECTING_VAR_LEN_DATA, | 848 | - JEDEC_READ = 0x9f, |
77 | STATE_READING_DATA, | 849 | - RDSR = 0x5, |
78 | + STATE_READING_SFDP, | 850 | - WRDI = 0x4, |
79 | } CMDState; | 851 | - BULK_ERASE = 0xc7, |
80 | 852 | - READ = 0x03, | |
81 | typedef enum { | 853 | - PP = 0x02, |
82 | @@ -XXX,XX +XXX,XX @@ static inline int get_addr_length(Flash *s) | 854 | - WRSR = 0x1, |
83 | } | 855 | - WREN = 0x6, |
84 | 856 | - SRWD = 0x80, | |
85 | switch (s->cmd_in_progress) { | 857 | - RESET_ENABLE = 0x66, |
86 | + case RDSFDP: | 858 | - RESET_MEMORY = 0x99, |
87 | + return 3; | 859 | - EN_4BYTE_ADDR = 0xB7, |
88 | case PP4: | 860 | - ERASE_SECTOR = 0xd8, |
89 | case PP4_4: | 861 | -}; |
90 | case QPP_4: | 862 | - |
91 | @@ -XXX,XX +XXX,XX @@ static void complete_collecting_data(Flash *s) | 863 | -#define CTRL_IO_MODE_MASK (BIT(31) | BIT(30) | BIT(29) | BIT(28)) |
92 | " by device\n"); | 864 | -#define FLASH_PAGE_SIZE 256 |
93 | } | 865 | - |
94 | break; | 866 | -typedef struct TestData { |
95 | + | 867 | - QTestState *s; |
96 | + case RDSFDP: | 868 | - uint64_t spi_base; |
97 | + s->state = STATE_READING_SFDP; | 869 | - uint64_t flash_base; |
98 | + break; | 870 | - uint32_t jedec_id; |
99 | + | 871 | - char *tmp_path; |
100 | default: | 872 | - uint8_t cs; |
101 | break; | 873 | - const char *node; |
102 | } | 874 | - uint32_t page_addr; |
103 | @@ -XXX,XX +XXX,XX @@ static void decode_new_cmd(Flash *s, uint32_t value) | 875 | -} TestData; |
104 | qemu_log_mask(LOG_GUEST_ERROR, "M25P80: Unknown cmd %x\n", value); | 876 | - |
105 | } | 877 | -/* |
106 | break; | 878 | - * Use an explicit bswap for the values read/wrote to the flash region |
107 | + case RDSFDP: | 879 | - * as they are BE and the Aspeed CPU is LE. |
108 | + if (s->pi->sfdp_read) { | 880 | - */ |
109 | + s->needed_bytes = get_addr_length(s) + 1; /* SFDP addr + dummy */ | 881 | -static inline uint32_t make_be32(uint32_t data) |
110 | + s->pos = 0; | 882 | -{ |
111 | + s->len = 0; | 883 | - return bswap32(data); |
112 | + s->state = STATE_COLLECTING_DATA; | 884 | -} |
113 | + break; | 885 | - |
114 | + } | 886 | -static inline void spi_writel(const TestData *data, uint64_t offset, |
115 | + /* Fallthrough */ | 887 | - uint32_t value) |
116 | + | 888 | -{ |
117 | default: | 889 | - qtest_writel(data->s, data->spi_base + offset, value); |
118 | s->pos = 0; | 890 | -} |
119 | s->len = 1; | 891 | - |
120 | @@ -XXX,XX +XXX,XX @@ static uint32_t m25p80_transfer8(SSIPeripheral *ss, uint32_t tx) | 892 | -static inline uint32_t spi_readl(const TestData *data, uint64_t offset) |
121 | } | 893 | -{ |
122 | } | 894 | - return qtest_readl(data->s, data->spi_base + offset); |
123 | break; | 895 | -} |
124 | + case STATE_READING_SFDP: | 896 | - |
125 | + assert(s->pi->sfdp_read); | 897 | -static inline void flash_writeb(const TestData *data, uint64_t offset, |
126 | + r = s->pi->sfdp_read(s->cur_addr); | 898 | - uint8_t value) |
127 | + trace_m25p80_read_sfdp(s, s->cur_addr, (uint8_t)r); | 899 | -{ |
128 | + s->cur_addr = (s->cur_addr + 1) & (M25P80_SFDP_MAX_SIZE - 1); | 900 | - qtest_writeb(data->s, data->flash_base + offset, value); |
129 | + break; | 901 | -} |
130 | 902 | - | |
131 | default: | 903 | -static inline void flash_writel(const TestData *data, uint64_t offset, |
132 | case STATE_IDLE: | 904 | - uint32_t value) |
133 | diff --git a/MAINTAINERS b/MAINTAINERS | 905 | -{ |
906 | - qtest_writel(data->s, data->flash_base + offset, value); | ||
907 | -} | ||
908 | - | ||
909 | -static inline uint8_t flash_readb(const TestData *data, uint64_t offset) | ||
910 | -{ | ||
911 | - return qtest_readb(data->s, data->flash_base + offset); | ||
912 | -} | ||
913 | - | ||
914 | -static inline uint32_t flash_readl(const TestData *data, uint64_t offset) | ||
915 | -{ | ||
916 | - return qtest_readl(data->s, data->flash_base + offset); | ||
917 | -} | ||
918 | - | ||
919 | -static void spi_conf(const TestData *data, uint32_t value) | ||
920 | -{ | ||
921 | - uint32_t conf = spi_readl(data, R_CONF); | ||
922 | - | ||
923 | - conf |= value; | ||
924 | - spi_writel(data, R_CONF, conf); | ||
925 | -} | ||
926 | - | ||
927 | -static void spi_conf_remove(const TestData *data, uint32_t value) | ||
928 | -{ | ||
929 | - uint32_t conf = spi_readl(data, R_CONF); | ||
930 | - | ||
931 | - conf &= ~value; | ||
932 | - spi_writel(data, R_CONF, conf); | ||
933 | -} | ||
934 | - | ||
935 | -static void spi_ce_ctrl(const TestData *data, uint32_t value) | ||
936 | -{ | ||
937 | - uint32_t conf = spi_readl(data, R_CE_CTRL); | ||
938 | - | ||
939 | - conf |= value; | ||
940 | - spi_writel(data, R_CE_CTRL, conf); | ||
941 | -} | ||
942 | - | ||
943 | -static void spi_ctrl_setmode(const TestData *data, uint8_t mode, uint8_t cmd) | ||
944 | -{ | ||
945 | - uint32_t ctrl_reg = R_CTRL0 + data->cs * 4; | ||
946 | - uint32_t ctrl = spi_readl(data, ctrl_reg); | ||
947 | - ctrl &= ~(CTRL_USERMODE | 0xff << 16); | ||
948 | - ctrl |= mode | (cmd << 16); | ||
949 | - spi_writel(data, ctrl_reg, ctrl); | ||
950 | -} | ||
951 | - | ||
952 | -static void spi_ctrl_start_user(const TestData *data) | ||
953 | -{ | ||
954 | - uint32_t ctrl_reg = R_CTRL0 + data->cs * 4; | ||
955 | - uint32_t ctrl = spi_readl(data, ctrl_reg); | ||
956 | - | ||
957 | - ctrl |= CTRL_USERMODE | CTRL_CE_STOP_ACTIVE; | ||
958 | - spi_writel(data, ctrl_reg, ctrl); | ||
959 | - | ||
960 | - ctrl &= ~CTRL_CE_STOP_ACTIVE; | ||
961 | - spi_writel(data, ctrl_reg, ctrl); | ||
962 | -} | ||
963 | - | ||
964 | -static void spi_ctrl_stop_user(const TestData *data) | ||
965 | -{ | ||
966 | - uint32_t ctrl_reg = R_CTRL0 + data->cs * 4; | ||
967 | - uint32_t ctrl = spi_readl(data, ctrl_reg); | ||
968 | - | ||
969 | - ctrl |= CTRL_USERMODE | CTRL_CE_STOP_ACTIVE; | ||
970 | - spi_writel(data, ctrl_reg, ctrl); | ||
971 | -} | ||
972 | - | ||
973 | -static void spi_ctrl_set_io_mode(const TestData *data, uint32_t value) | ||
974 | -{ | ||
975 | - uint32_t ctrl_reg = R_CTRL0 + data->cs * 4; | ||
976 | - uint32_t ctrl = spi_readl(data, ctrl_reg); | ||
977 | - uint32_t mode; | ||
978 | - | ||
979 | - mode = value & CTRL_IO_MODE_MASK; | ||
980 | - ctrl &= ~CTRL_IO_MODE_MASK; | ||
981 | - ctrl |= mode; | ||
982 | - spi_writel(data, ctrl_reg, ctrl); | ||
983 | -} | ||
984 | - | ||
985 | -static void flash_reset(const TestData *data) | ||
986 | -{ | ||
987 | - spi_conf(data, 1 << (CONF_ENABLE_W0 + data->cs)); | ||
988 | - | ||
989 | - spi_ctrl_start_user(data); | ||
990 | - flash_writeb(data, 0, RESET_ENABLE); | ||
991 | - flash_writeb(data, 0, RESET_MEMORY); | ||
992 | - flash_writeb(data, 0, WREN); | ||
993 | - flash_writeb(data, 0, BULK_ERASE); | ||
994 | - flash_writeb(data, 0, WRDI); | ||
995 | - spi_ctrl_stop_user(data); | ||
996 | - | ||
997 | - spi_conf_remove(data, 1 << (CONF_ENABLE_W0 + data->cs)); | ||
998 | -} | ||
999 | - | ||
1000 | -static void test_read_jedec(const void *data) | ||
1001 | -{ | ||
1002 | - const TestData *test_data = (const TestData *)data; | ||
1003 | - uint32_t jedec = 0x0; | ||
1004 | - | ||
1005 | - spi_conf(test_data, 1 << (CONF_ENABLE_W0 + test_data->cs)); | ||
1006 | - | ||
1007 | - spi_ctrl_start_user(test_data); | ||
1008 | - flash_writeb(test_data, 0, JEDEC_READ); | ||
1009 | - jedec |= flash_readb(test_data, 0) << 16; | ||
1010 | - jedec |= flash_readb(test_data, 0) << 8; | ||
1011 | - jedec |= flash_readb(test_data, 0); | ||
1012 | - spi_ctrl_stop_user(test_data); | ||
1013 | - | ||
1014 | - flash_reset(test_data); | ||
1015 | - | ||
1016 | - g_assert_cmphex(jedec, ==, test_data->jedec_id); | ||
1017 | -} | ||
1018 | - | ||
1019 | -static void read_page(const TestData *data, uint32_t addr, uint32_t *page) | ||
1020 | -{ | ||
1021 | - int i; | ||
1022 | - | ||
1023 | - spi_ctrl_start_user(data); | ||
1024 | - | ||
1025 | - flash_writeb(data, 0, EN_4BYTE_ADDR); | ||
1026 | - flash_writeb(data, 0, READ); | ||
1027 | - flash_writel(data, 0, make_be32(addr)); | ||
1028 | - | ||
1029 | - /* Continuous read are supported */ | ||
1030 | - for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
1031 | - page[i] = make_be32(flash_readl(data, 0)); | ||
1032 | - } | ||
1033 | - spi_ctrl_stop_user(data); | ||
1034 | -} | ||
1035 | - | ||
1036 | -static void read_page_mem(const TestData *data, uint32_t addr, uint32_t *page) | ||
1037 | -{ | ||
1038 | - int i; | ||
1039 | - | ||
1040 | - /* move out USER mode to use direct reads from the AHB bus */ | ||
1041 | - spi_ctrl_setmode(data, CTRL_READMODE, READ); | ||
1042 | - | ||
1043 | - for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
1044 | - page[i] = make_be32(flash_readl(data, addr + i * 4)); | ||
1045 | - } | ||
1046 | -} | ||
1047 | - | ||
1048 | -static void write_page_mem(const TestData *data, uint32_t addr, | ||
1049 | - uint32_t write_value) | ||
1050 | -{ | ||
1051 | - spi_ctrl_setmode(data, CTRL_WRITEMODE, PP); | ||
1052 | - | ||
1053 | - for (int i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
1054 | - flash_writel(data, addr + i * 4, write_value); | ||
1055 | - } | ||
1056 | -} | ||
1057 | - | ||
1058 | -static void assert_page_mem(const TestData *data, uint32_t addr, | ||
1059 | - uint32_t expected_value) | ||
1060 | -{ | ||
1061 | - uint32_t page[FLASH_PAGE_SIZE / 4]; | ||
1062 | - read_page_mem(data, addr, page); | ||
1063 | - for (int i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
1064 | - g_assert_cmphex(page[i], ==, expected_value); | ||
1065 | - } | ||
1066 | -} | ||
1067 | - | ||
1068 | -static void test_erase_sector(const void *data) | ||
1069 | -{ | ||
1070 | - const TestData *test_data = (const TestData *)data; | ||
1071 | - uint32_t some_page_addr = test_data->page_addr; | ||
1072 | - uint32_t page[FLASH_PAGE_SIZE / 4]; | ||
1073 | - int i; | ||
1074 | - | ||
1075 | - spi_conf(test_data, 1 << (CONF_ENABLE_W0 + test_data->cs)); | ||
1076 | - | ||
1077 | - /* | ||
1078 | - * Previous page should be full of 0xffs after backend is | ||
1079 | - * initialized | ||
1080 | - */ | ||
1081 | - read_page(test_data, some_page_addr - FLASH_PAGE_SIZE, page); | ||
1082 | - for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
1083 | - g_assert_cmphex(page[i], ==, 0xffffffff); | ||
1084 | - } | ||
1085 | - | ||
1086 | - spi_ctrl_start_user(test_data); | ||
1087 | - flash_writeb(test_data, 0, EN_4BYTE_ADDR); | ||
1088 | - flash_writeb(test_data, 0, WREN); | ||
1089 | - flash_writeb(test_data, 0, PP); | ||
1090 | - flash_writel(test_data, 0, make_be32(some_page_addr)); | ||
1091 | - | ||
1092 | - /* Fill the page with its own addresses */ | ||
1093 | - for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
1094 | - flash_writel(test_data, 0, make_be32(some_page_addr + i * 4)); | ||
1095 | - } | ||
1096 | - spi_ctrl_stop_user(test_data); | ||
1097 | - | ||
1098 | - /* Check the page is correctly written */ | ||
1099 | - read_page(test_data, some_page_addr, page); | ||
1100 | - for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
1101 | - g_assert_cmphex(page[i], ==, some_page_addr + i * 4); | ||
1102 | - } | ||
1103 | - | ||
1104 | - spi_ctrl_start_user(test_data); | ||
1105 | - flash_writeb(test_data, 0, WREN); | ||
1106 | - flash_writeb(test_data, 0, EN_4BYTE_ADDR); | ||
1107 | - flash_writeb(test_data, 0, ERASE_SECTOR); | ||
1108 | - flash_writel(test_data, 0, make_be32(some_page_addr)); | ||
1109 | - spi_ctrl_stop_user(test_data); | ||
1110 | - | ||
1111 | - /* Check the page is erased */ | ||
1112 | - read_page(test_data, some_page_addr, page); | ||
1113 | - for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
1114 | - g_assert_cmphex(page[i], ==, 0xffffffff); | ||
1115 | - } | ||
1116 | - | ||
1117 | - flash_reset(test_data); | ||
1118 | -} | ||
1119 | - | ||
1120 | -static void test_erase_all(const void *data) | ||
1121 | -{ | ||
1122 | - const TestData *test_data = (const TestData *)data; | ||
1123 | - uint32_t some_page_addr = test_data->page_addr; | ||
1124 | - uint32_t page[FLASH_PAGE_SIZE / 4]; | ||
1125 | - int i; | ||
1126 | - | ||
1127 | - spi_conf(test_data, 1 << (CONF_ENABLE_W0 + test_data->cs)); | ||
1128 | - | ||
1129 | - /* | ||
1130 | - * Previous page should be full of 0xffs after backend is | ||
1131 | - * initialized | ||
1132 | - */ | ||
1133 | - read_page(test_data, some_page_addr - FLASH_PAGE_SIZE, page); | ||
1134 | - for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
1135 | - g_assert_cmphex(page[i], ==, 0xffffffff); | ||
1136 | - } | ||
1137 | - | ||
1138 | - spi_ctrl_start_user(test_data); | ||
1139 | - flash_writeb(test_data, 0, EN_4BYTE_ADDR); | ||
1140 | - flash_writeb(test_data, 0, WREN); | ||
1141 | - flash_writeb(test_data, 0, PP); | ||
1142 | - flash_writel(test_data, 0, make_be32(some_page_addr)); | ||
1143 | - | ||
1144 | - /* Fill the page with its own addresses */ | ||
1145 | - for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
1146 | - flash_writel(test_data, 0, make_be32(some_page_addr + i * 4)); | ||
1147 | - } | ||
1148 | - spi_ctrl_stop_user(test_data); | ||
1149 | - | ||
1150 | - /* Check the page is correctly written */ | ||
1151 | - read_page(test_data, some_page_addr, page); | ||
1152 | - for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
1153 | - g_assert_cmphex(page[i], ==, some_page_addr + i * 4); | ||
1154 | - } | ||
1155 | - | ||
1156 | - spi_ctrl_start_user(test_data); | ||
1157 | - flash_writeb(test_data, 0, WREN); | ||
1158 | - flash_writeb(test_data, 0, BULK_ERASE); | ||
1159 | - spi_ctrl_stop_user(test_data); | ||
1160 | - | ||
1161 | - /* Check the page is erased */ | ||
1162 | - read_page(test_data, some_page_addr, page); | ||
1163 | - for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
1164 | - g_assert_cmphex(page[i], ==, 0xffffffff); | ||
1165 | - } | ||
1166 | - | ||
1167 | - flash_reset(test_data); | ||
1168 | -} | ||
1169 | - | ||
1170 | -static void test_write_page(const void *data) | ||
1171 | -{ | ||
1172 | - const TestData *test_data = (const TestData *)data; | ||
1173 | - uint32_t my_page_addr = test_data->page_addr; | ||
1174 | - uint32_t some_page_addr = my_page_addr + FLASH_PAGE_SIZE; | ||
1175 | - uint32_t page[FLASH_PAGE_SIZE / 4]; | ||
1176 | - int i; | ||
1177 | - | ||
1178 | - spi_conf(test_data, 1 << (CONF_ENABLE_W0 + test_data->cs)); | ||
1179 | - | ||
1180 | - spi_ctrl_start_user(test_data); | ||
1181 | - flash_writeb(test_data, 0, EN_4BYTE_ADDR); | ||
1182 | - flash_writeb(test_data, 0, WREN); | ||
1183 | - flash_writeb(test_data, 0, PP); | ||
1184 | - flash_writel(test_data, 0, make_be32(my_page_addr)); | ||
1185 | - | ||
1186 | - /* Fill the page with its own addresses */ | ||
1187 | - for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
1188 | - flash_writel(test_data, 0, make_be32(my_page_addr + i * 4)); | ||
1189 | - } | ||
1190 | - spi_ctrl_stop_user(test_data); | ||
1191 | - | ||
1192 | - /* Check what was written */ | ||
1193 | - read_page(test_data, my_page_addr, page); | ||
1194 | - for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
1195 | - g_assert_cmphex(page[i], ==, my_page_addr + i * 4); | ||
1196 | - } | ||
1197 | - | ||
1198 | - /* Check some other page. It should be full of 0xff */ | ||
1199 | - read_page(test_data, some_page_addr, page); | ||
1200 | - for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
1201 | - g_assert_cmphex(page[i], ==, 0xffffffff); | ||
1202 | - } | ||
1203 | - | ||
1204 | - flash_reset(test_data); | ||
1205 | -} | ||
1206 | - | ||
1207 | -static void test_read_page_mem(const void *data) | ||
1208 | -{ | ||
1209 | - const TestData *test_data = (const TestData *)data; | ||
1210 | - uint32_t my_page_addr = test_data->page_addr; | ||
1211 | - uint32_t some_page_addr = my_page_addr + FLASH_PAGE_SIZE; | ||
1212 | - uint32_t page[FLASH_PAGE_SIZE / 4]; | ||
1213 | - int i; | ||
1214 | - | ||
1215 | - /* | ||
1216 | - * Enable 4BYTE mode for controller. | ||
1217 | - */ | ||
1218 | - spi_ce_ctrl(test_data, 1 << (CRTL_EXTENDED0 + test_data->cs)); | ||
1219 | - | ||
1220 | - /* Enable 4BYTE mode for flash. */ | ||
1221 | - spi_conf(test_data, 1 << (CONF_ENABLE_W0 + test_data->cs)); | ||
1222 | - spi_ctrl_start_user(test_data); | ||
1223 | - flash_writeb(test_data, 0, EN_4BYTE_ADDR); | ||
1224 | - flash_writeb(test_data, 0, WREN); | ||
1225 | - flash_writeb(test_data, 0, PP); | ||
1226 | - flash_writel(test_data, 0, make_be32(my_page_addr)); | ||
1227 | - | ||
1228 | - /* Fill the page with its own addresses */ | ||
1229 | - for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
1230 | - flash_writel(test_data, 0, make_be32(my_page_addr + i * 4)); | ||
1231 | - } | ||
1232 | - spi_ctrl_stop_user(test_data); | ||
1233 | - spi_conf_remove(test_data, 1 << (CONF_ENABLE_W0 + test_data->cs)); | ||
1234 | - | ||
1235 | - /* Check what was written */ | ||
1236 | - read_page_mem(test_data, my_page_addr, page); | ||
1237 | - for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
1238 | - g_assert_cmphex(page[i], ==, my_page_addr + i * 4); | ||
1239 | - } | ||
1240 | - | ||
1241 | - /* Check some other page. It should be full of 0xff */ | ||
1242 | - read_page_mem(test_data, some_page_addr, page); | ||
1243 | - for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
1244 | - g_assert_cmphex(page[i], ==, 0xffffffff); | ||
1245 | - } | ||
1246 | - | ||
1247 | - flash_reset(test_data); | ||
1248 | -} | ||
1249 | - | ||
1250 | -static void test_write_page_mem(const void *data) | ||
1251 | -{ | ||
1252 | - const TestData *test_data = (const TestData *)data; | ||
1253 | - uint32_t my_page_addr = test_data->page_addr; | ||
1254 | - uint32_t page[FLASH_PAGE_SIZE / 4]; | ||
1255 | - int i; | ||
1256 | - | ||
1257 | - /* | ||
1258 | - * Enable 4BYTE mode for controller. | ||
1259 | - */ | ||
1260 | - spi_ce_ctrl(test_data, 1 << (CRTL_EXTENDED0 + test_data->cs)); | ||
1261 | - | ||
1262 | - /* Enable 4BYTE mode for flash. */ | ||
1263 | - spi_conf(test_data, 1 << (CONF_ENABLE_W0 + test_data->cs)); | ||
1264 | - spi_ctrl_start_user(test_data); | ||
1265 | - flash_writeb(test_data, 0, EN_4BYTE_ADDR); | ||
1266 | - flash_writeb(test_data, 0, WREN); | ||
1267 | - spi_ctrl_stop_user(test_data); | ||
1268 | - | ||
1269 | - /* move out USER mode to use direct writes to the AHB bus */ | ||
1270 | - spi_ctrl_setmode(test_data, CTRL_WRITEMODE, PP); | ||
1271 | - | ||
1272 | - for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
1273 | - flash_writel(test_data, my_page_addr + i * 4, | ||
1274 | - make_be32(my_page_addr + i * 4)); | ||
1275 | - } | ||
1276 | - | ||
1277 | - /* Check what was written */ | ||
1278 | - read_page_mem(test_data, my_page_addr, page); | ||
1279 | - for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
1280 | - g_assert_cmphex(page[i], ==, my_page_addr + i * 4); | ||
1281 | - } | ||
1282 | - | ||
1283 | - flash_reset(test_data); | ||
1284 | -} | ||
1285 | - | ||
1286 | -static void test_read_status_reg(const void *data) | ||
1287 | -{ | ||
1288 | - const TestData *test_data = (const TestData *)data; | ||
1289 | - uint8_t r; | ||
1290 | - | ||
1291 | - spi_conf(test_data, 1 << (CONF_ENABLE_W0 + test_data->cs)); | ||
1292 | - | ||
1293 | - spi_ctrl_start_user(test_data); | ||
1294 | - flash_writeb(test_data, 0, RDSR); | ||
1295 | - r = flash_readb(test_data, 0); | ||
1296 | - spi_ctrl_stop_user(test_data); | ||
1297 | - | ||
1298 | - g_assert_cmphex(r & SR_WEL, ==, 0); | ||
1299 | - g_assert(!qtest_qom_get_bool | ||
1300 | - (test_data->s, test_data->node, "write-enable")); | ||
1301 | - | ||
1302 | - spi_ctrl_start_user(test_data); | ||
1303 | - flash_writeb(test_data, 0, WREN); | ||
1304 | - flash_writeb(test_data, 0, RDSR); | ||
1305 | - r = flash_readb(test_data, 0); | ||
1306 | - spi_ctrl_stop_user(test_data); | ||
1307 | - | ||
1308 | - g_assert_cmphex(r & SR_WEL, ==, SR_WEL); | ||
1309 | - g_assert(qtest_qom_get_bool | ||
1310 | - (test_data->s, test_data->node, "write-enable")); | ||
1311 | - | ||
1312 | - spi_ctrl_start_user(test_data); | ||
1313 | - flash_writeb(test_data, 0, WRDI); | ||
1314 | - flash_writeb(test_data, 0, RDSR); | ||
1315 | - r = flash_readb(test_data, 0); | ||
1316 | - spi_ctrl_stop_user(test_data); | ||
1317 | - | ||
1318 | - g_assert_cmphex(r & SR_WEL, ==, 0); | ||
1319 | - g_assert(!qtest_qom_get_bool | ||
1320 | - (test_data->s, test_data->node, "write-enable")); | ||
1321 | - | ||
1322 | - flash_reset(test_data); | ||
1323 | -} | ||
1324 | - | ||
1325 | -static void test_status_reg_write_protection(const void *data) | ||
1326 | -{ | ||
1327 | - const TestData *test_data = (const TestData *)data; | ||
1328 | - uint8_t r; | ||
1329 | - | ||
1330 | - spi_conf(test_data, 1 << (CONF_ENABLE_W0 + test_data->cs)); | ||
1331 | - | ||
1332 | - /* default case: WP# is high and SRWD is low -> status register writable */ | ||
1333 | - spi_ctrl_start_user(test_data); | ||
1334 | - flash_writeb(test_data, 0, WREN); | ||
1335 | - /* test ability to write SRWD */ | ||
1336 | - flash_writeb(test_data, 0, WRSR); | ||
1337 | - flash_writeb(test_data, 0, SRWD); | ||
1338 | - flash_writeb(test_data, 0, RDSR); | ||
1339 | - r = flash_readb(test_data, 0); | ||
1340 | - spi_ctrl_stop_user(test_data); | ||
1341 | - g_assert_cmphex(r & SRWD, ==, SRWD); | ||
1342 | - | ||
1343 | - /* WP# high and SRWD high -> status register writable */ | ||
1344 | - spi_ctrl_start_user(test_data); | ||
1345 | - flash_writeb(test_data, 0, WREN); | ||
1346 | - /* test ability to write SRWD */ | ||
1347 | - flash_writeb(test_data, 0, WRSR); | ||
1348 | - flash_writeb(test_data, 0, 0); | ||
1349 | - flash_writeb(test_data, 0, RDSR); | ||
1350 | - r = flash_readb(test_data, 0); | ||
1351 | - spi_ctrl_stop_user(test_data); | ||
1352 | - g_assert_cmphex(r & SRWD, ==, 0); | ||
1353 | - | ||
1354 | - /* WP# low and SRWD low -> status register writable */ | ||
1355 | - qtest_set_irq_in(test_data->s, test_data->node, "WP#", 0, 0); | ||
1356 | - spi_ctrl_start_user(test_data); | ||
1357 | - flash_writeb(test_data, 0, WREN); | ||
1358 | - /* test ability to write SRWD */ | ||
1359 | - flash_writeb(test_data, 0, WRSR); | ||
1360 | - flash_writeb(test_data, 0, SRWD); | ||
1361 | - flash_writeb(test_data, 0, RDSR); | ||
1362 | - r = flash_readb(test_data, 0); | ||
1363 | - spi_ctrl_stop_user(test_data); | ||
1364 | - g_assert_cmphex(r & SRWD, ==, SRWD); | ||
1365 | - | ||
1366 | - /* WP# low and SRWD high -> status register NOT writable */ | ||
1367 | - spi_ctrl_start_user(test_data); | ||
1368 | - flash_writeb(test_data, 0 , WREN); | ||
1369 | - /* test ability to write SRWD */ | ||
1370 | - flash_writeb(test_data, 0, WRSR); | ||
1371 | - flash_writeb(test_data, 0, 0); | ||
1372 | - flash_writeb(test_data, 0, RDSR); | ||
1373 | - r = flash_readb(test_data, 0); | ||
1374 | - spi_ctrl_stop_user(test_data); | ||
1375 | - /* write is not successful */ | ||
1376 | - g_assert_cmphex(r & SRWD, ==, SRWD); | ||
1377 | - | ||
1378 | - qtest_set_irq_in(test_data->s, test_data->node, "WP#", 0, 1); | ||
1379 | - flash_reset(test_data); | ||
1380 | -} | ||
1381 | - | ||
1382 | -static void test_write_block_protect(const void *data) | ||
1383 | -{ | ||
1384 | - const TestData *test_data = (const TestData *)data; | ||
1385 | - uint32_t sector_size = 65536; | ||
1386 | - uint32_t n_sectors = 512; | ||
1387 | - | ||
1388 | - spi_ce_ctrl(test_data, 1 << (CRTL_EXTENDED0 + test_data->cs)); | ||
1389 | - spi_conf(test_data, 1 << (CONF_ENABLE_W0 + test_data->cs)); | ||
1390 | - | ||
1391 | - uint32_t bp_bits = 0b0; | ||
1392 | - | ||
1393 | - for (int i = 0; i < 16; i++) { | ||
1394 | - bp_bits = ((i & 0b1000) << 3) | ((i & 0b0111) << 2); | ||
1395 | - | ||
1396 | - spi_ctrl_start_user(test_data); | ||
1397 | - flash_writeb(test_data, 0, WREN); | ||
1398 | - flash_writeb(test_data, 0, BULK_ERASE); | ||
1399 | - flash_writeb(test_data, 0, WREN); | ||
1400 | - flash_writeb(test_data, 0, WRSR); | ||
1401 | - flash_writeb(test_data, 0, bp_bits); | ||
1402 | - flash_writeb(test_data, 0, EN_4BYTE_ADDR); | ||
1403 | - flash_writeb(test_data, 0, WREN); | ||
1404 | - spi_ctrl_stop_user(test_data); | ||
1405 | - | ||
1406 | - uint32_t num_protected_sectors = i ? MIN(1 << (i - 1), n_sectors) : 0; | ||
1407 | - uint32_t protection_start = n_sectors - num_protected_sectors; | ||
1408 | - uint32_t protection_end = n_sectors; | ||
1409 | - | ||
1410 | - for (int sector = 0; sector < n_sectors; sector++) { | ||
1411 | - uint32_t addr = sector * sector_size; | ||
1412 | - | ||
1413 | - assert_page_mem(test_data, addr, 0xffffffff); | ||
1414 | - write_page_mem(test_data, addr, make_be32(0xabcdef12)); | ||
1415 | - | ||
1416 | - uint32_t expected_value = protection_start <= sector | ||
1417 | - && sector < protection_end | ||
1418 | - ? 0xffffffff : 0xabcdef12; | ||
1419 | - | ||
1420 | - assert_page_mem(test_data, addr, expected_value); | ||
1421 | - } | ||
1422 | - } | ||
1423 | - | ||
1424 | - flash_reset(test_data); | ||
1425 | -} | ||
1426 | - | ||
1427 | -static void test_write_block_protect_bottom_bit(const void *data) | ||
1428 | -{ | ||
1429 | - const TestData *test_data = (const TestData *)data; | ||
1430 | - uint32_t sector_size = 65536; | ||
1431 | - uint32_t n_sectors = 512; | ||
1432 | - | ||
1433 | - spi_ce_ctrl(test_data, 1 << (CRTL_EXTENDED0 + test_data->cs)); | ||
1434 | - spi_conf(test_data, 1 << (CONF_ENABLE_W0 + test_data->cs)); | ||
1435 | - | ||
1436 | - /* top bottom bit is enabled */ | ||
1437 | - uint32_t bp_bits = 0b00100 << 3; | ||
1438 | - | ||
1439 | - for (int i = 0; i < 16; i++) { | ||
1440 | - bp_bits = (((i & 0b1000) | 0b0100) << 3) | ((i & 0b0111) << 2); | ||
1441 | - | ||
1442 | - spi_ctrl_start_user(test_data); | ||
1443 | - flash_writeb(test_data, 0, WREN); | ||
1444 | - flash_writeb(test_data, 0, BULK_ERASE); | ||
1445 | - flash_writeb(test_data, 0, WREN); | ||
1446 | - flash_writeb(test_data, 0, WRSR); | ||
1447 | - flash_writeb(test_data, 0, bp_bits); | ||
1448 | - flash_writeb(test_data, 0, EN_4BYTE_ADDR); | ||
1449 | - flash_writeb(test_data, 0, WREN); | ||
1450 | - spi_ctrl_stop_user(test_data); | ||
1451 | - | ||
1452 | - uint32_t num_protected_sectors = i ? MIN(1 << (i - 1), n_sectors) : 0; | ||
1453 | - uint32_t protection_start = 0; | ||
1454 | - uint32_t protection_end = num_protected_sectors; | ||
1455 | - | ||
1456 | - for (int sector = 0; sector < n_sectors; sector++) { | ||
1457 | - uint32_t addr = sector * sector_size; | ||
1458 | - | ||
1459 | - assert_page_mem(test_data, addr, 0xffffffff); | ||
1460 | - write_page_mem(test_data, addr, make_be32(0xabcdef12)); | ||
1461 | - | ||
1462 | - uint32_t expected_value = protection_start <= sector | ||
1463 | - && sector < protection_end | ||
1464 | - ? 0xffffffff : 0xabcdef12; | ||
1465 | - | ||
1466 | - assert_page_mem(test_data, addr, expected_value); | ||
1467 | - } | ||
1468 | - } | ||
1469 | - | ||
1470 | - flash_reset(test_data); | ||
1471 | -} | ||
1472 | - | ||
1473 | -static void test_write_page_qpi(const void *data) | ||
1474 | -{ | ||
1475 | - const TestData *test_data = (const TestData *)data; | ||
1476 | - uint32_t my_page_addr = test_data->page_addr; | ||
1477 | - uint32_t some_page_addr = my_page_addr + FLASH_PAGE_SIZE; | ||
1478 | - uint32_t page[FLASH_PAGE_SIZE / 4]; | ||
1479 | - uint32_t page_pattern[] = { | ||
1480 | - 0xebd8c134, 0x5da196bc, 0xae15e729, 0x5085ccdf | ||
1481 | - }; | ||
1482 | - int i; | ||
1483 | - | ||
1484 | - spi_conf(test_data, 1 << (CONF_ENABLE_W0 + test_data->cs)); | ||
1485 | - | ||
1486 | - spi_ctrl_start_user(test_data); | ||
1487 | - flash_writeb(test_data, 0, EN_4BYTE_ADDR); | ||
1488 | - flash_writeb(test_data, 0, WREN); | ||
1489 | - flash_writeb(test_data, 0, PP); | ||
1490 | - flash_writel(test_data, 0, make_be32(my_page_addr)); | ||
1491 | - | ||
1492 | - /* Set QPI mode */ | ||
1493 | - spi_ctrl_set_io_mode(test_data, CTRL_IO_QUAD_IO); | ||
1494 | - | ||
1495 | - /* Fill the page pattern */ | ||
1496 | - for (i = 0; i < ARRAY_SIZE(page_pattern); i++) { | ||
1497 | - flash_writel(test_data, 0, make_be32(page_pattern[i])); | ||
1498 | - } | ||
1499 | - | ||
1500 | - /* Fill the page with its own addresses */ | ||
1501 | - for (; i < FLASH_PAGE_SIZE / 4; i++) { | ||
1502 | - flash_writel(test_data, 0, make_be32(my_page_addr + i * 4)); | ||
1503 | - } | ||
1504 | - | ||
1505 | - /* Restore io mode */ | ||
1506 | - spi_ctrl_set_io_mode(test_data, 0); | ||
1507 | - spi_ctrl_stop_user(test_data); | ||
1508 | - | ||
1509 | - /* Check what was written */ | ||
1510 | - read_page(test_data, my_page_addr, page); | ||
1511 | - for (i = 0; i < ARRAY_SIZE(page_pattern); i++) { | ||
1512 | - g_assert_cmphex(page[i], ==, page_pattern[i]); | ||
1513 | - } | ||
1514 | - for (; i < FLASH_PAGE_SIZE / 4; i++) { | ||
1515 | - g_assert_cmphex(page[i], ==, my_page_addr + i * 4); | ||
1516 | - } | ||
1517 | - | ||
1518 | - /* Check some other page. It should be full of 0xff */ | ||
1519 | - read_page(test_data, some_page_addr, page); | ||
1520 | - for (i = 0; i < FLASH_PAGE_SIZE / 4; i++) { | ||
1521 | - g_assert_cmphex(page[i], ==, 0xffffffff); | ||
1522 | - } | ||
1523 | - | ||
1524 | - flash_reset(test_data); | ||
1525 | -} | ||
1526 | - | ||
1527 | -static void test_palmetto_bmc(TestData *data) | ||
1528 | +static void test_palmetto_bmc(AspeedSMCTestData *data) | ||
1529 | { | ||
1530 | int ret; | ||
1531 | int fd; | ||
1532 | @@ -XXX,XX +XXX,XX @@ static void test_palmetto_bmc(TestData *data) | ||
1533 | /* beyond 16MB */ | ||
1534 | data->page_addr = 0x14000 * FLASH_PAGE_SIZE; | ||
1535 | |||
1536 | - qtest_add_data_func("/ast2400/smc/read_jedec", data, test_read_jedec); | ||
1537 | - qtest_add_data_func("/ast2400/smc/erase_sector", data, test_erase_sector); | ||
1538 | - qtest_add_data_func("/ast2400/smc/erase_all", data, test_erase_all); | ||
1539 | - qtest_add_data_func("/ast2400/smc/write_page", data, test_write_page); | ||
1540 | + qtest_add_data_func("/ast2400/smc/read_jedec", | ||
1541 | + data, aspeed_smc_test_read_jedec); | ||
1542 | + qtest_add_data_func("/ast2400/smc/erase_sector", | ||
1543 | + data, aspeed_smc_test_erase_sector); | ||
1544 | + qtest_add_data_func("/ast2400/smc/erase_all", | ||
1545 | + data, aspeed_smc_test_erase_all); | ||
1546 | + qtest_add_data_func("/ast2400/smc/write_page", | ||
1547 | + data, aspeed_smc_test_write_page); | ||
1548 | qtest_add_data_func("/ast2400/smc/read_page_mem", | ||
1549 | - data, test_read_page_mem); | ||
1550 | + data, aspeed_smc_test_read_page_mem); | ||
1551 | qtest_add_data_func("/ast2400/smc/write_page_mem", | ||
1552 | - data, test_write_page_mem); | ||
1553 | + data, aspeed_smc_test_write_page_mem); | ||
1554 | qtest_add_data_func("/ast2400/smc/read_status_reg", | ||
1555 | - data, test_read_status_reg); | ||
1556 | + data, aspeed_smc_test_read_status_reg); | ||
1557 | qtest_add_data_func("/ast2400/smc/status_reg_write_protection", | ||
1558 | - data, test_status_reg_write_protection); | ||
1559 | + data, aspeed_smc_test_status_reg_write_protection); | ||
1560 | qtest_add_data_func("/ast2400/smc/write_block_protect", | ||
1561 | - data, test_write_block_protect); | ||
1562 | + data, aspeed_smc_test_write_block_protect); | ||
1563 | qtest_add_data_func("/ast2400/smc/write_block_protect_bottom_bit", | ||
1564 | - data, test_write_block_protect_bottom_bit); | ||
1565 | + data, aspeed_smc_test_write_block_protect_bottom_bit); | ||
1566 | } | ||
1567 | |||
1568 | -static void test_ast2500_evb(TestData *data) | ||
1569 | +static void test_ast2500_evb(AspeedSMCTestData *data) | ||
1570 | { | ||
1571 | int ret; | ||
1572 | int fd; | ||
1573 | @@ -XXX,XX +XXX,XX @@ static void test_ast2500_evb(TestData *data) | ||
1574 | /* beyond 16MB */ | ||
1575 | data->page_addr = 0x14000 * FLASH_PAGE_SIZE; | ||
1576 | |||
1577 | - qtest_add_data_func("/ast2500/smc/read_jedec", data, test_read_jedec); | ||
1578 | - qtest_add_data_func("/ast2500/smc/erase_sector", data, test_erase_sector); | ||
1579 | - qtest_add_data_func("/ast2500/smc/erase_all", data, test_erase_all); | ||
1580 | - qtest_add_data_func("/ast2500/smc/write_page", data, test_write_page); | ||
1581 | + qtest_add_data_func("/ast2500/smc/read_jedec", | ||
1582 | + data, aspeed_smc_test_read_jedec); | ||
1583 | + qtest_add_data_func("/ast2500/smc/erase_sector", | ||
1584 | + data, aspeed_smc_test_erase_sector); | ||
1585 | + qtest_add_data_func("/ast2500/smc/erase_all", | ||
1586 | + data, aspeed_smc_test_erase_all); | ||
1587 | + qtest_add_data_func("/ast2500/smc/write_page", | ||
1588 | + data, aspeed_smc_test_write_page); | ||
1589 | qtest_add_data_func("/ast2500/smc/read_page_mem", | ||
1590 | - data, test_read_page_mem); | ||
1591 | + data, aspeed_smc_test_read_page_mem); | ||
1592 | qtest_add_data_func("/ast2500/smc/write_page_mem", | ||
1593 | - data, test_write_page_mem); | ||
1594 | + data, aspeed_smc_test_write_page_mem); | ||
1595 | qtest_add_data_func("/ast2500/smc/read_status_reg", | ||
1596 | - data, test_read_status_reg); | ||
1597 | + data, aspeed_smc_test_read_status_reg); | ||
1598 | qtest_add_data_func("/ast2500/smc/write_page_qpi", | ||
1599 | - data, test_write_page_qpi); | ||
1600 | + data, aspeed_smc_test_write_page_qpi); | ||
1601 | } | ||
1602 | |||
1603 | -static void test_ast2600_evb(TestData *data) | ||
1604 | +static void test_ast2600_evb(AspeedSMCTestData *data) | ||
1605 | { | ||
1606 | int ret; | ||
1607 | int fd; | ||
1608 | @@ -XXX,XX +XXX,XX @@ static void test_ast2600_evb(TestData *data) | ||
1609 | /* beyond 16MB */ | ||
1610 | data->page_addr = 0x14000 * FLASH_PAGE_SIZE; | ||
1611 | |||
1612 | - qtest_add_data_func("/ast2600/smc/read_jedec", data, test_read_jedec); | ||
1613 | - qtest_add_data_func("/ast2600/smc/erase_sector", data, test_erase_sector); | ||
1614 | - qtest_add_data_func("/ast2600/smc/erase_all", data, test_erase_all); | ||
1615 | - qtest_add_data_func("/ast2600/smc/write_page", data, test_write_page); | ||
1616 | + qtest_add_data_func("/ast2600/smc/read_jedec", | ||
1617 | + data, aspeed_smc_test_read_jedec); | ||
1618 | + qtest_add_data_func("/ast2600/smc/erase_sector", | ||
1619 | + data, aspeed_smc_test_erase_sector); | ||
1620 | + qtest_add_data_func("/ast2600/smc/erase_all", | ||
1621 | + data, aspeed_smc_test_erase_all); | ||
1622 | + qtest_add_data_func("/ast2600/smc/write_page", | ||
1623 | + data, aspeed_smc_test_write_page); | ||
1624 | qtest_add_data_func("/ast2600/smc/read_page_mem", | ||
1625 | - data, test_read_page_mem); | ||
1626 | + data, aspeed_smc_test_read_page_mem); | ||
1627 | qtest_add_data_func("/ast2600/smc/write_page_mem", | ||
1628 | - data, test_write_page_mem); | ||
1629 | + data, aspeed_smc_test_write_page_mem); | ||
1630 | qtest_add_data_func("/ast2600/smc/read_status_reg", | ||
1631 | - data, test_read_status_reg); | ||
1632 | + data, aspeed_smc_test_read_status_reg); | ||
1633 | qtest_add_data_func("/ast2600/smc/write_page_qpi", | ||
1634 | - data, test_write_page_qpi); | ||
1635 | + data, aspeed_smc_test_write_page_qpi); | ||
1636 | } | ||
1637 | |||
1638 | -static void test_ast1030_evb(TestData *data) | ||
1639 | +static void test_ast1030_evb(AspeedSMCTestData *data) | ||
1640 | { | ||
1641 | int ret; | ||
1642 | int fd; | ||
1643 | @@ -XXX,XX +XXX,XX @@ static void test_ast1030_evb(TestData *data) | ||
1644 | /* beyond 512KB */ | ||
1645 | data->page_addr = 0x800 * FLASH_PAGE_SIZE; | ||
1646 | |||
1647 | - qtest_add_data_func("/ast1030/smc/read_jedec", data, test_read_jedec); | ||
1648 | - qtest_add_data_func("/ast1030/smc/erase_sector", data, test_erase_sector); | ||
1649 | - qtest_add_data_func("/ast1030/smc/erase_all", data, test_erase_all); | ||
1650 | - qtest_add_data_func("/ast1030/smc/write_page", data, test_write_page); | ||
1651 | + qtest_add_data_func("/ast1030/smc/read_jedec", | ||
1652 | + data, aspeed_smc_test_read_jedec); | ||
1653 | + qtest_add_data_func("/ast1030/smc/erase_sector", | ||
1654 | + data, aspeed_smc_test_erase_sector); | ||
1655 | + qtest_add_data_func("/ast1030/smc/erase_all", | ||
1656 | + data, aspeed_smc_test_erase_all); | ||
1657 | + qtest_add_data_func("/ast1030/smc/write_page", | ||
1658 | + data, aspeed_smc_test_write_page); | ||
1659 | qtest_add_data_func("/ast1030/smc/read_page_mem", | ||
1660 | - data, test_read_page_mem); | ||
1661 | + data, aspeed_smc_test_read_page_mem); | ||
1662 | qtest_add_data_func("/ast1030/smc/write_page_mem", | ||
1663 | - data, test_write_page_mem); | ||
1664 | + data, aspeed_smc_test_write_page_mem); | ||
1665 | qtest_add_data_func("/ast1030/smc/read_status_reg", | ||
1666 | - data, test_read_status_reg); | ||
1667 | + data, aspeed_smc_test_read_status_reg); | ||
1668 | qtest_add_data_func("/ast1030/smc/write_page_qpi", | ||
1669 | - data, test_write_page_qpi); | ||
1670 | + data, aspeed_smc_test_write_page_qpi); | ||
1671 | } | ||
1672 | |||
1673 | int main(int argc, char **argv) | ||
1674 | { | ||
1675 | - TestData palmetto_data; | ||
1676 | - TestData ast2500_evb_data; | ||
1677 | - TestData ast2600_evb_data; | ||
1678 | - TestData ast1030_evb_data; | ||
1679 | + AspeedSMCTestData palmetto_data; | ||
1680 | + AspeedSMCTestData ast2500_evb_data; | ||
1681 | + AspeedSMCTestData ast2600_evb_data; | ||
1682 | + AspeedSMCTestData ast1030_evb_data; | ||
1683 | int ret; | ||
1684 | |||
1685 | g_test_init(&argc, &argv, NULL); | ||
1686 | diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build | ||
134 | index XXXXXXX..XXXXXXX 100644 | 1687 | index XXXXXXX..XXXXXXX 100644 |
135 | --- a/MAINTAINERS | 1688 | --- a/tests/qtest/meson.build |
136 | +++ b/MAINTAINERS | 1689 | +++ b/tests/qtest/meson.build |
137 | @@ -XXX,XX +XXX,XX @@ SSI | 1690 | @@ -XXX,XX +XXX,XX @@ qtests = { |
138 | M: Alistair Francis <alistair@alistair23.me> | 1691 | 'virtio-net-failover': files('migration-helpers.c'), |
139 | S: Maintained | 1692 | 'vmgenid-test': files('boot-sector.c', 'acpi-utils.c'), |
140 | F: hw/ssi/* | 1693 | 'netdev-socket': files('netdev-socket.c', '../unit/socket-helpers.c'), |
141 | -F: hw/block/m25p80.c | 1694 | + 'aspeed_smc-test': files('aspeed-smc-utils.c', 'aspeed_smc-test.c'), |
142 | +F: hw/block/m25p80* | 1695 | } |
143 | F: include/hw/ssi/ssi.h | 1696 | |
144 | X: hw/ssi/xilinx_* | 1697 | if vnc.found() |
145 | F: tests/qtest/m25p80-test.c | ||
146 | diff --git a/hw/block/trace-events b/hw/block/trace-events | ||
147 | index XXXXXXX..XXXXXXX 100644 | ||
148 | --- a/hw/block/trace-events | ||
149 | +++ b/hw/block/trace-events | ||
150 | @@ -XXX,XX +XXX,XX @@ m25p80_page_program(void *s, uint32_t addr, uint8_t tx) "[%p] page program cur_a | ||
151 | m25p80_transfer(void *s, uint8_t state, uint32_t len, uint8_t needed, uint32_t pos, uint32_t cur_addr, uint8_t t) "[%p] Transfer state 0x%"PRIx8" len 0x%"PRIx32" needed 0x%"PRIx8" pos 0x%"PRIx32" addr 0x%"PRIx32" tx 0x%"PRIx8 | ||
152 | m25p80_read_byte(void *s, uint32_t addr, uint8_t v) "[%p] Read byte 0x%"PRIx32"=0x%"PRIx8 | ||
153 | m25p80_read_data(void *s, uint32_t pos, uint8_t v) "[%p] Read data 0x%"PRIx32"=0x%"PRIx8 | ||
154 | +m25p80_read_sfdp(void *s, uint32_t addr, uint8_t v) "[%p] Read SFDP 0x%"PRIx32"=0x%"PRIx8 | ||
155 | m25p80_binding(void *s) "[%p] Binding to IF_MTD drive" | ||
156 | m25p80_binding_no_bdrv(void *s) "[%p] No BDRV - binding to RAM" | ||
157 | -- | 1698 | -- |
158 | 2.37.3 | 1699 | 2.47.1 |
159 | 1700 | ||
160 | 1701 | diff view generated by jsdifflib |
1 | The same values were collected on 4 differents OpenPower systems, | 1 | From: Jamin Lin <jamin_lin@aspeedtech.com> |
---|---|---|---|
2 | palmettos, romulus and tacoma. | ||
3 | 2 | ||
4 | The SFDP table size is defined as being 0x100 bytes but it could be | 3 | Add test_ast2700_evb function and reused testcases which are from |
5 | bigger. Only the mandatory table for basic features is available at | 4 | aspeed_smc-test.c for AST2700 testing. The base address, flash base address |
6 | byte 0x30. | 5 | and ce index of fmc_cs0 are 0x14000000, 0x100000000 and 0, respectively. |
6 | The default flash model of fmc_cs0 is "w25q01jvq" whose size is 128MB, | ||
7 | so set jedec_id 0xef4021. | ||
7 | 8 | ||
8 | Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com> | 9 | Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com> |
9 | Message-Id: <20220722063602.128144-3-clg@kaod.org> | 10 | Reviewed-by: Cédric Le Goater <clg@redhat.com> |
10 | Message-Id: <20221013161241.2805140-3-clg@kaod.org> | 11 | Link: https://lore.kernel.org/r/20241127091543.1243114-11-jamin_lin@aspeedtech.com |
11 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 12 | Signed-off-by: Cédric Le Goater <clg@redhat.com> |
12 | --- | 13 | --- |
13 | hw/block/m25p80_sfdp.h | 2 ++ | 14 | tests/qtest/ast2700-smc-test.c | 71 ++++++++++++++++++++++++++++++++++ |
14 | hw/block/m25p80.c | 8 +++--- | 15 | tests/qtest/meson.build | 4 +- |
15 | hw/block/m25p80_sfdp.c | 58 ++++++++++++++++++++++++++++++++++++++++++ | 16 | 2 files changed, 74 insertions(+), 1 deletion(-) |
16 | hw/block/meson.build | 1 + | 17 | create mode 100644 tests/qtest/ast2700-smc-test.c |
17 | 4 files changed, 66 insertions(+), 3 deletions(-) | ||
18 | create mode 100644 hw/block/m25p80_sfdp.c | ||
19 | 18 | ||
20 | diff --git a/hw/block/m25p80_sfdp.h b/hw/block/m25p80_sfdp.h | 19 | diff --git a/tests/qtest/ast2700-smc-test.c b/tests/qtest/ast2700-smc-test.c |
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/hw/block/m25p80_sfdp.h | ||
23 | +++ b/hw/block/m25p80_sfdp.h | ||
24 | @@ -XXX,XX +XXX,XX @@ | ||
25 | */ | ||
26 | #define M25P80_SFDP_MAX_SIZE (1 << 24) | ||
27 | |||
28 | +uint8_t m25p80_sfdp_n25q256a(uint32_t addr); | ||
29 | + | ||
30 | #endif | ||
31 | diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/hw/block/m25p80.c | ||
34 | +++ b/hw/block/m25p80.c | ||
35 | @@ -XXX,XX +XXX,XX @@ static const FlashPartInfo known_devices[] = { | ||
36 | { INFO("n25q128a11", 0x20bb18, 0, 64 << 10, 256, ER_4K) }, | ||
37 | { INFO("n25q128a13", 0x20ba18, 0, 64 << 10, 256, ER_4K) }, | ||
38 | { INFO("n25q256a11", 0x20bb19, 0, 64 << 10, 512, ER_4K) }, | ||
39 | - { INFO("n25q256a13", 0x20ba19, 0, 64 << 10, 512, ER_4K) }, | ||
40 | + { INFO("n25q256a13", 0x20ba19, 0, 64 << 10, 512, ER_4K), | ||
41 | + .sfdp_read = m25p80_sfdp_n25q256a }, | ||
42 | { INFO("n25q512a11", 0x20bb20, 0, 64 << 10, 1024, ER_4K) }, | ||
43 | { INFO("n25q512a13", 0x20ba20, 0, 64 << 10, 1024, ER_4K) }, | ||
44 | { INFO("n25q128", 0x20ba18, 0, 64 << 10, 256, 0) }, | ||
45 | { INFO("n25q256a", 0x20ba19, 0, 64 << 10, 512, | ||
46 | - ER_4K | HAS_SR_BP3_BIT6 | HAS_SR_TB) }, | ||
47 | - { INFO("n25q512a", 0x20ba20, 0, 64 << 10, 1024, ER_4K) }, | ||
48 | + ER_4K | HAS_SR_BP3_BIT6 | HAS_SR_TB), | ||
49 | + .sfdp_read = m25p80_sfdp_n25q256a }, | ||
50 | + { INFO("n25q512a", 0x20ba20, 0, 64 << 10, 1024, ER_4K) }, | ||
51 | { INFO("n25q512ax3", 0x20ba20, 0x1000, 64 << 10, 1024, ER_4K) }, | ||
52 | { INFO("mt25ql512ab", 0x20ba20, 0x1044, 64 << 10, 1024, ER_4K | ER_32K) }, | ||
53 | { INFO_STACKED("mt35xu01g", 0x2c5b1b, 0x104100, 128 << 10, 1024, | ||
54 | diff --git a/hw/block/m25p80_sfdp.c b/hw/block/m25p80_sfdp.c | ||
55 | new file mode 100644 | 20 | new file mode 100644 |
56 | index XXXXXXX..XXXXXXX | 21 | index XXXXXXX..XXXXXXX |
57 | --- /dev/null | 22 | --- /dev/null |
58 | +++ b/hw/block/m25p80_sfdp.c | 23 | +++ b/tests/qtest/ast2700-smc-test.c |
59 | @@ -XXX,XX +XXX,XX @@ | 24 | @@ -XXX,XX +XXX,XX @@ |
60 | +/* | 25 | +/* |
61 | + * M25P80 Serial Flash Discoverable Parameter (SFDP) | 26 | + * QTest testcase for the M25P80 Flash using the ASPEED SPI Controller since |
27 | + * AST2700. | ||
62 | + * | 28 | + * |
63 | + * Copyright (c) 2020, IBM Corporation. | 29 | + * SPDX-License-Identifier: GPL-2.0-or-later |
64 | + * | 30 | + * Copyright (C) 2024 ASPEED Technology Inc. |
65 | + * This code is licensed under the GPL version 2 or later. See the | ||
66 | + * COPYING file in the top-level directory. | ||
67 | + */ | 31 | + */ |
68 | + | 32 | + |
69 | +#include "qemu/osdep.h" | 33 | +#include "qemu/osdep.h" |
70 | +#include "qemu/host-utils.h" | 34 | +#include "qemu/bswap.h" |
71 | +#include "m25p80_sfdp.h" | 35 | +#include "libqtest-single.h" |
36 | +#include "qemu/bitops.h" | ||
37 | +#include "aspeed-smc-utils.h" | ||
72 | + | 38 | + |
73 | +#define define_sfdp_read(model) \ | 39 | +static void test_ast2700_evb(AspeedSMCTestData *data) |
74 | + uint8_t m25p80_sfdp_##model(uint32_t addr) \ | 40 | +{ |
75 | + { \ | 41 | + int ret; |
76 | + assert(is_power_of_2(sizeof(sfdp_##model))); \ | 42 | + int fd; |
77 | + return sfdp_##model[addr & (sizeof(sfdp_##model) - 1)]; \ | ||
78 | + } | ||
79 | + | 43 | + |
80 | +/* | 44 | + fd = g_file_open_tmp("qtest.m25p80.w25q01jvq.XXXXXX", |
81 | + * Micron | 45 | + &data->tmp_path, NULL); |
82 | + */ | 46 | + g_assert(fd >= 0); |
83 | +static const uint8_t sfdp_n25q256a[] = { | 47 | + ret = ftruncate(fd, 128 * 1024 * 1024); |
84 | + 0x53, 0x46, 0x44, 0x50, 0x00, 0x01, 0x00, 0xff, | 48 | + g_assert(ret == 0); |
85 | + 0x00, 0x00, 0x01, 0x09, 0x30, 0x00, 0x00, 0xff, | 49 | + close(fd); |
86 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 50 | + |
87 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 51 | + data->s = qtest_initf("-machine ast2700-evb " |
88 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 52 | + "-drive file=%s,format=raw,if=mtd", |
89 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 53 | + data->tmp_path); |
90 | + 0xe5, 0x20, 0xfb, 0xff, 0xff, 0xff, 0xff, 0x0f, | 54 | + |
91 | + 0x29, 0xeb, 0x27, 0x6b, 0x08, 0x3b, 0x27, 0xbb, | 55 | + /* fmc cs0 with w25q01jvq flash */ |
92 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x27, 0xbb, | 56 | + data->flash_base = 0x100000000; |
93 | + 0xff, 0xff, 0x29, 0xeb, 0x0c, 0x20, 0x10, 0xd8, | 57 | + data->spi_base = 0x14000000; |
94 | + 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, | 58 | + data->jedec_id = 0xef4021; |
95 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 59 | + data->cs = 0; |
96 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 60 | + data->node = "/machine/soc/fmc/ssi.0/child[0]"; |
97 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 61 | + /* beyond 64MB */ |
98 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 62 | + data->page_addr = 0x40000 * FLASH_PAGE_SIZE; |
99 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 63 | + |
100 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 64 | + qtest_add_data_func("/ast2700/smc/read_jedec", |
101 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 65 | + data, aspeed_smc_test_read_jedec); |
102 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 66 | + qtest_add_data_func("/ast2700/smc/erase_sector", |
103 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 67 | + data, aspeed_smc_test_erase_sector); |
104 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 68 | + qtest_add_data_func("/ast2700/smc/erase_all", |
105 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 69 | + data, aspeed_smc_test_erase_all); |
106 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 70 | + qtest_add_data_func("/ast2700/smc/write_page", |
107 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 71 | + data, aspeed_smc_test_write_page); |
108 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 72 | + qtest_add_data_func("/ast2700/smc/read_page_mem", |
109 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 73 | + data, aspeed_smc_test_read_page_mem); |
110 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 74 | + qtest_add_data_func("/ast2700/smc/write_page_mem", |
111 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 75 | + data, aspeed_smc_test_write_page_mem); |
112 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 76 | + qtest_add_data_func("/ast2700/smc/read_status_reg", |
113 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 77 | + data, aspeed_smc_test_read_status_reg); |
114 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 78 | + qtest_add_data_func("/ast2700/smc/write_page_qpi", |
115 | + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | 79 | + data, aspeed_smc_test_write_page_qpi); |
116 | +}; | 80 | +} |
117 | +define_sfdp_read(n25q256a); | 81 | + |
118 | diff --git a/hw/block/meson.build b/hw/block/meson.build | 82 | +int main(int argc, char **argv) |
83 | +{ | ||
84 | + AspeedSMCTestData ast2700_evb_data; | ||
85 | + int ret; | ||
86 | + | ||
87 | + g_test_init(&argc, &argv, NULL); | ||
88 | + | ||
89 | + test_ast2700_evb(&ast2700_evb_data); | ||
90 | + ret = g_test_run(); | ||
91 | + | ||
92 | + qtest_quit(ast2700_evb_data.s); | ||
93 | + unlink(ast2700_evb_data.tmp_path); | ||
94 | + return ret; | ||
95 | +} | ||
96 | diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build | ||
119 | index XXXXXXX..XXXXXXX 100644 | 97 | index XXXXXXX..XXXXXXX 100644 |
120 | --- a/hw/block/meson.build | 98 | --- a/tests/qtest/meson.build |
121 | +++ b/hw/block/meson.build | 99 | +++ b/tests/qtest/meson.build |
122 | @@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_ONENAND', if_true: files('onenand.c')) | 100 | @@ -XXX,XX +XXX,XX @@ qtests_aspeed = \ |
123 | softmmu_ss.add(when: 'CONFIG_PFLASH_CFI01', if_true: files('pflash_cfi01.c')) | 101 | 'aspeed_smc-test', |
124 | softmmu_ss.add(when: 'CONFIG_PFLASH_CFI02', if_true: files('pflash_cfi02.c')) | 102 | 'aspeed_gpio-test'] |
125 | softmmu_ss.add(when: 'CONFIG_SSI_M25P80', if_true: files('m25p80.c')) | 103 | qtests_aspeed64 = \ |
126 | +softmmu_ss.add(when: 'CONFIG_SSI_M25P80', if_true: files('m25p80_sfdp.c')) | 104 | - ['ast2700-gpio-test'] |
127 | softmmu_ss.add(when: 'CONFIG_SWIM', if_true: files('swim.c')) | 105 | + ['ast2700-gpio-test', |
128 | softmmu_ss.add(when: 'CONFIG_XEN', if_true: files('xen-block.c')) | 106 | + 'ast2700-smc-test'] |
129 | softmmu_ss.add(when: 'CONFIG_TC58128', if_true: files('tc58128.c')) | 107 | |
108 | qtests_stm32l4x5 = \ | ||
109 | ['stm32l4x5_exti-test', | ||
110 | @@ -XXX,XX +XXX,XX @@ qtests = { | ||
111 | 'vmgenid-test': files('boot-sector.c', 'acpi-utils.c'), | ||
112 | 'netdev-socket': files('netdev-socket.c', '../unit/socket-helpers.c'), | ||
113 | 'aspeed_smc-test': files('aspeed-smc-utils.c', 'aspeed_smc-test.c'), | ||
114 | + 'ast2700-smc-test': files('aspeed-smc-utils.c', 'ast2700-smc-test.c'), | ||
115 | } | ||
116 | |||
117 | if vnc.found() | ||
130 | -- | 118 | -- |
131 | 2.37.3 | 119 | 2.47.1 |
132 | 120 | ||
133 | 121 | diff view generated by jsdifflib |