tests/qtest: Add qtest for NPCM8XX PSPI module
PATCH v2 1/1 tests/qtest: Add qtest for NPCM8XX PSPI module
- Created qtest to check initialization of registers in PSPI Module
- Implemented test into Build File
Tested:
./build/tests/qtest/npcm8xx-pspi_test
---
Changes since v1:
- MAINTAINERS file not need to change
- Add comment for copyright/license information
- Correct CTL registers to use 16 bits
- Remove printf() in test cases
tests/qtest/meson.build | 3 + tests/qtest/npcm8xx_pspi-test.c | 118 ++++++++++++++++++++++++++++++++ 2 files changed, 121 insertions(+) create mode 100644 tests/qtest/npcm8xx_pspi-test.c
tests/qtest/meson.build +3 -0
@@ -210,6 +210,8 @@ qtests_npcm7xx = \ 'npcm7xx_watchdog_timer-test', 'npcm_gmac-test'] + \ (slirp.found() ? ['npcm7xx_emc-test'] : []) +qtests_npcm8xx = \ + ['npcm8xx_pspi-test'] qtests_aspeed = \ ['aspeed_hace-test', 'aspeed_smc-test',
@@ -257,6 +259,7 @@ qtests_aarch64 = \ (config_all_accel.has_key('CONFIG_TCG') and \ config_all_devices.has_key('CONFIG_TPM_TIS_I2C') ? ['tpm-tis-i2c-test'] : []) + \ (config_all_devices.has_key('CONFIG_ASPEED_SOC') ? qtests_aspeed64 : []) + \ + (config_all_devices.has_key('CONFIG_NPCM8XX') ? qtests_npcm8xx : []) + \ ['arm-cpu-features', 'numa-test', 'boot-serial-test',
tests/qtest/npcm8xx_pspi-test.c new file +118 -0
118 lines not on this page · raw message
Signature · 1 line
2.34.1
From: Tim Lee <[email protected]>
Sent: Wednesday, May 7, 2025 5:19 PM
To: [email protected]; [email protected]; [email protected]; [email protected]; CS20 KFTing <[email protected]>; CS20 CHLi30 <[email protected]>
Cc: [email protected]; [email protected]; Tim Lee <[email protected]>
Subject: [v2] tests/qtest: Add qtest for NPCM8XX PSPI module
- Created qtest to check initialization of registers in PSPI Module
- Implemented test into Build File
Tested:
./build/tests/qtest/npcm8xx-pspi_test
---
Changes since v1:
- MAINTAINERS file not need to change
- Add comment for copyright/license information
- Correct CTL registers to use 16 bits
- Remove printf() in test cases
tests/qtest/meson.build | 3 + tests/qtest/npcm8xx_pspi-test.c | 118 ++++++++++++++++++++++++++++++++ 2 files changed, 121 insertions(+) create mode 100644 tests/qtest/npcm8xx_pspi-test.c
tests/qtest/meson.build +4 -0
@@ -210,6 +210,8 @@ qtests_npcm7xx = \ 'npcm7xx_watchdog_timer-test', 'npcm_gmac-test'] + \ (slirp.found() ? ['npcm7xx_emc-test'] : []) +qtests_npcm8xx = \ + ['npcm8xx_pspi-test'] qtests_aspeed = \ ['aspeed_hace-test', 'aspeed_smc-test',
@@ -257,6 +259,7 @@ qtests_aarch64 = \ (config_all_accel.has_key('CONFIG_TCG') and \ config_all_devices.has_key('CONFIG_TPM_TIS_I2C') ? ['tpm-tis-i2c-test'] : []) + \ (config_all_devices.has_key('CONFIG_ASPEED_SOC') ? qtests_aspeed64 : []) + \ + (config_all_devices.has_key('CONFIG_NPCM8XX') ? qtests_npcm8xx : []) + + \ ['arm-cpu-features', 'numa-test',
'boot-serial-test',
tests/qtest/npcm8xx_pspi-test.c new file +108 -0
108 lines not on this page · raw message
--
2.34.1
________________________________
________________________________
The privileged confidential information contained in this email is intended for use only by the addressees as indicated by the original sender of this email. If you are not the addressee indicated in this email or are not responsible for delivery of the email to such a person, please kindly reply to the sender indicating this fact and delete all copies of it from your computer and network server immediately. Your cooperation is highly appreciated. It is advised that any unauthorized use of confidential information of Nuvoton is strictly prohibited; and any information in this email irrelevant to the official business of Nuvoton shall be deemed as neither given nor endorsed by Nuvoton.
Peter Maydell
AppliedQuoted 7 lines · Tim Lee
- Created qtest to check initialization of registers in PSPI Module
- Implemented test into Build FileTested:
./build/tests/qtest/npcm8xx-pspi_test
Quoted 7 lines
Signed-off-by Tim Lee <[email protected]>---
Changes since v1:
-MAINTAINERSfile not need to change
- Add comment for copyright/license information
- Correct CTL registers to use 16 bits
- Removeprintf()in test cases
Applied to target-arm.next, thanks.
-- PMM
Quoted 19 lines · Peter Maydell
Quoted 7 lines · Tim Lee
- Created qtest to check initialization of registers in PSPI Module
- Implemented test into Build FileTested:
./build/tests/qtest/npcm8xx-pspi_testQuoted 7 lines
Signed-off-by Tim Lee <[email protected]>---
Changes since v1:
-MAINTAINERSfile not need to change
- Add comment for copyright/license information
- Correct CTL registers to use 16 bits
- Removeprintf()in test cases
Quoted 1 line
Applied to target-arm.next, thanks.
...but it fails "make check", so I've dropped it:
not ok /aarch64/npcm8xx_pspi/data - ERROR:../../tests/qtest/npcm8xx_pspi-test.c:
80:test_data: assertion failed (output == test): (0x00000000 == 0x00001234) Bail out!
----------------------------------- stderr ----------------------------------- **
ERROR:../../tests/qtest/npcm8xx_pspi-test.c:80:test_data: assertion failed (outp ut == test): (0x00000000 == 0x00001234)
(test program exited with status code -6)
thanks
-- PMM
Hi Peter,
Sorry about that. When I ran this qtest and I found an error then I tried to modify npcm_pspi driver to make data register read/write test pass.
[R +0.080118] writew 0xf0201002 0x4
[S +0.080126] OK
[R +0.080148] readw 0xf0201002
[S +0.080153] OK 0x0000000000000004
[R +0.080168] writew 0xf0201000 0x1234
[S +0.080171] OK
[R +0.080191] readw 0xf0201000
[S +0.080194] OK 0x0000000000001234
[I +0.080445] CLOSED
ok 3 /aarch64/npcm8xx_pspi/data
# End of npcm8xx_pspi tests
# End of aarch64 tests
Here is the change diff of what I modified in npcm_pspi_write_data() Should I submit this patch for npcm_pspi driver? I'm not sure if I modified it correctly. Thanks for your time.
static void npcm_pspi_write_data(NPCMPSPIState *s, uint16_t data) {
- uint16_t value = 0;
+ uint16_t data_l, data_h = 0;
if (FIELD_EX16(s->regs[R_PSPI_CTL1], PSPI_CTL1, MOD)) {
- value = ssi_transfer(s->spi, extract16(data, 8, 8)) << 8;
+ data_h = (extract16(data, 8, 8) << 8);
+ ssi_transfer(s->spi, data_h);
}
- value |= ssi_transfer(s->spi, extract16(data, 0, 8));
- s->regs[R_PSPI_DATA] = value;
+ data_l = extract16(data, 0, 8);
+ ssi_transfer(s->spi, data_l);
+ s->regs[R_PSPI_DATA] = (data_h | data_l);Peter Maydell <[email protected]> 於 2025年5月11日 週日 下午9:58寫道:
Quoted 37 lines · Peter Maydell
Quoted 19 lines · Tim Lee
Quoted 7 lines
- Created qtest to check initialization of registers in PSPI Module
- Implemented test into Build FileTested:
./build/tests/qtest/npcm8xx-pspi_testQuoted 7 lines
Signed-off-by Tim Lee <[email protected]>---
Changes since v1:
-MAINTAINERSfile not need to change
- Add comment for copyright/license information
- Correct CTL registers to use 16 bits
- Removeprintf()in test casesQuoted 1 line
Applied to target-arm.next, thanks.
...but it fails "make check", so I've dropped it:
not ok /aarch64/npcm8xx_pspi/data - ERROR:../../tests/qtest/npcm8xx_pspi-test.c:
80:test_data: assertion failed (output == test): (0x00000000==0x00001234) Bail out!
----------------------------------- stderr ----------------------------------- **
ERROR:../../tests/qtest/npcm8xx_pspi-test.c:80:test_data: assertion failed (outp ut == test): (0x00000000==0x00001234)(test program exited with status code -6)
thanks
-- PMM
Signature · 2 lines
Best regards, Tim Lee
Quoted 28 lines · Tim Lee
Hi Peter,
Sorry about that. When I ran this qtest and I found an error then I tried to modifynpcm_pspidriver to make data register read/write test pass.[R +0.080118] writew
0xf02010020x4
[S +0.080126] OK
[R +0.080148] readw0xf0201002
[S +0.080153] OK0x0000000000000004
[R +0.080168] writew0xf02010000x1234
[S +0.080171] OK
[R +0.080191] readw0xf0201000
[S +0.080194] OK0x0000000000001234
[I +0.080445] CLOSED
ok 3 /aarch64/npcm8xx_pspi/data
# End ofnpcm8xx_pspitests
# End of aarch64 testsHere is the change diff of what I modified in
npcm_pspi_write_data()Should I submit this patch fornpcm_pspidriver? I'm not sure if I modified it correctly. Thanks for your time.static void
npcm_pspi_write_data(NPCMPSPIState *s, uint16_t data){(quoted diff) +1
-1- uint16_t value = 0; + uint16_t data_l, data_h = 0;
Review
Quoted 10 lines
(quoted diff) +5
-3if (FIELD_EX16(s->regs[R_PSPI_CTL1], PSPI_CTL1, MOD)) { - value = ssi_transfer(s->spi, extract16(data, 8, 8)) << 8; + data_h = (extract16(data, 8, 8) << 8); + ssi_transfer(s->spi, data_h); } - value |= ssi_transfer(s->spi, extract16(data, 0, 8)); - s->regs[R_PSPI_DATA] = value; + data_l = extract16(data, 0, 8); + ssi_transfer(s->spi, data_l); + s->regs[R_PSPI_DATA] = (data_h | data_l);
If you think there's a bug in the PSPI device then the best thing is to submit what you think is the fix as its own patch, with a commit message that details what the incorrect behaviour is (and why you think it's incorrect, e.g. with reference to a data sheet). Then the NPCM folks can review it for whether it's correct or not.
You can send a 2-patch series with the bug fix as patch 1, followed by the new test case as patch 2.
thanks
-- PMM