From b7c020c0dd6740a8bcbb022fb3469e3f69c95e25 Mon Sep 17 00:00:00 2001 From: Tim Trippel Date: Thu, 12 Dec 2024 14:43:08 -0800 Subject: [PATCH] [manuf] add delay to OTP writes Allow charge pump to recover on real silicon. Signed-off-by: Tim Trippel --- sw/device/lib/testing/BUILD | 1 + sw/device/lib/testing/otp_ctrl_testutils.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/sw/device/lib/testing/BUILD b/sw/device/lib/testing/BUILD index b2f42b50813715..0e346b8d7e0e28 100644 --- a/sw/device/lib/testing/BUILD +++ b/sw/device/lib/testing/BUILD @@ -306,6 +306,7 @@ cc_library( target_compatible_with = [OPENTITAN_CPU], deps = [ "//sw/device/lib/dif:otp_ctrl", + "//sw/device/lib/runtime:hart", "//sw/device/lib/runtime:ibex", "//sw/device/lib/runtime:log", "//sw/device/lib/testing/test_framework:check", diff --git a/sw/device/lib/testing/otp_ctrl_testutils.c b/sw/device/lib/testing/otp_ctrl_testutils.c index fda2322e4c8a08..86eb37654a625f 100644 --- a/sw/device/lib/testing/otp_ctrl_testutils.c +++ b/sw/device/lib/testing/otp_ctrl_testutils.c @@ -5,6 +5,7 @@ #include "sw/device/lib/testing/otp_ctrl_testutils.h" #include "sw/device/lib/dif/dif_otp_ctrl.h" +#include "sw/device/lib/runtime/hart.h" #include "sw/device/lib/runtime/ibex.h" #include "sw/device/lib/runtime/log.h" #include "sw/device/lib/testing/test_framework/check.h" @@ -173,6 +174,9 @@ status_t otp_ctrl_testutils_dai_write32(const dif_otp_ctrl_t *otp, if (read_data != buffer[i]) { return INTERNAL(); } + + // Wait for charge pump to recover. + busy_spin_micros(10000); // 10ms } return OK_STATUS(); } @@ -194,6 +198,9 @@ status_t otp_ctrl_testutils_dai_write64(const dif_otp_ctrl_t *otp, if (read_data != buffer[i]) { return INTERNAL(); } + + // Wait for charge pump to recover. + busy_spin_micros(10000); // 10ms } return OK_STATUS(); }