On 4/29/26 7:32 AM, Arun Menon wrote:
Hi,
On Tue, Apr 28, 2026 at 01:07:17PM +0000, Stefan Berger wrote:
For some TPM I2C tests it is important to be able to reenable the
selection of the master. Implement aspeed_i2c_restart to enable this.
Signed-off-by: Stefan Berger <[email protected]>
---
tests/qtest/qtest_aspeed.c | 8 +++++++-
tests/qtest/qtest_aspeed.h | 2 ++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/tests/qtest/qtest_aspeed.c b/tests/qtest/qtest_aspeed.c
index f6da9adea9..13934cc660 100644
--- a/tests/qtest/qtest_aspeed.c
+++ b/tests/qtest/qtest_aspeed.c
@@ -15,11 +15,17 @@
#include "qtest_aspeed.h"
#include "hw/i2c/aspeed_i2c.h"
+static int once;
can we make this a boolean?
+
+void aspeed_i2c_restart(void)
+{
+ once = false;
+}
+
static void aspeed_i2c_startup(QTestState *s, uint32_t baseaddr,
uint8_t slave_addr, uint8_t reg)
{
uint32_t v;
- static int once;
Can we check if the A_I2CD_MASTER_EN bit is set directly without having
the need to store a global static variable? For example:
static bool is_aspeed_i2c_master_enabled(QTestState *s, uint32_t baseaddr)
{
uint32_t reg_val;
return ((qtest_readl(s, baseaddr + A_I2CC_FUN_CTRL)
& A_I2CD_MASTER_EN) != 0);
}
and use it here:
if (!once) {
if (!is_aspeed_i2c_master_enabled(s, baseaddr)) {
for restarts, we can directly write to the register
qtest_writel(s, bus_addr + A_I2CC_FUN_CTRL, 0);
and the subsequent call to aspeed_i2c_startup() will handle the init properly.
Yes, that's better. Thanks.