From ac1955c374a3629b2212c1eb3b95792d8c83f8bc Mon Sep 17 00:00:00 2001 From: Amaury Pouly Date: Thu, 20 Nov 2025 17:19:43 +0100 Subject: [PATCH] [dt,otp] Rename misleadingly name field and its documentation The documentation was probably copy-paste: the digest is not actually an OTP address but a CSR. Rename the field to make it clearer. Signed-off-by: Amaury Pouly --- hw/ip_templates/otp_ctrl/util/dt.py | 5 +++-- hw/top_darjeeling/ip_autogen/otp_ctrl/util/dt.py | 5 +++-- hw/top_earlgrey/ip_autogen/otp_ctrl/util/dt.py | 5 +++-- sw/device/silicon_creator/lib/drivers/otp.c | 3 ++- .../rom/e2e/keymgr/rom_e2e_keymgr_init_test.c | 16 ++++++++-------- 5 files changed, 19 insertions(+), 15 deletions(-) diff --git a/hw/ip_templates/otp_ctrl/util/dt.py b/hw/ip_templates/otp_ctrl/util/dt.py index ea5aeac32ea13..b390483c8e345 100644 --- a/hw/ip_templates/otp_ctrl/util/dt.py +++ b/hw/ip_templates/otp_ctrl/util/dt.py @@ -52,7 +52,7 @@ class OtpCtrlExt(Extension): OTP_PARTITION_INFO_STRUCT_START_ADDR_FIELD_NAME = Name(["start", "addr"]) OTP_PARTITION_INFO_STRUCT_SIZE_FIELD_NAME = Name(["size"]) - OTP_PARTITION_INFO_STRUCT_DIGEST_ADDR_FIELD_NAME = Name(["digest", "addr"]) + OTP_PARTITION_INFO_STRUCT_DIGEST_ADDR_FIELD_NAME = Name(["digest", "reg", "offset"]) OTP_PARTITION_INFO_STRUCT_ALIGN_MASK_FIELD_NAME = Name(["align", "mask"]) OTP_PARTITION_INFO_STRUCT_NAME = Name.from_snake_case("dt_otp_partition_info") @@ -82,7 +82,8 @@ def __init__(self, ip_helper: IpHelper): self._otp_partition_info_struct.add_field( name = self.OTP_PARTITION_INFO_STRUCT_DIGEST_ADDR_FIELD_NAME, field_type = ScalarType("uint32_t"), - docstring = "The absolute OTP address at which this partition's digest starts", + docstring = "The OTP digest CSR (where the digest is buffered) offset for " + + "this partition.", ) self._otp_partition_info_struct.add_field( name = self.OTP_PARTITION_INFO_STRUCT_ALIGN_MASK_FIELD_NAME, diff --git a/hw/top_darjeeling/ip_autogen/otp_ctrl/util/dt.py b/hw/top_darjeeling/ip_autogen/otp_ctrl/util/dt.py index ea5aeac32ea13..b390483c8e345 100644 --- a/hw/top_darjeeling/ip_autogen/otp_ctrl/util/dt.py +++ b/hw/top_darjeeling/ip_autogen/otp_ctrl/util/dt.py @@ -52,7 +52,7 @@ class OtpCtrlExt(Extension): OTP_PARTITION_INFO_STRUCT_START_ADDR_FIELD_NAME = Name(["start", "addr"]) OTP_PARTITION_INFO_STRUCT_SIZE_FIELD_NAME = Name(["size"]) - OTP_PARTITION_INFO_STRUCT_DIGEST_ADDR_FIELD_NAME = Name(["digest", "addr"]) + OTP_PARTITION_INFO_STRUCT_DIGEST_ADDR_FIELD_NAME = Name(["digest", "reg", "offset"]) OTP_PARTITION_INFO_STRUCT_ALIGN_MASK_FIELD_NAME = Name(["align", "mask"]) OTP_PARTITION_INFO_STRUCT_NAME = Name.from_snake_case("dt_otp_partition_info") @@ -82,7 +82,8 @@ def __init__(self, ip_helper: IpHelper): self._otp_partition_info_struct.add_field( name = self.OTP_PARTITION_INFO_STRUCT_DIGEST_ADDR_FIELD_NAME, field_type = ScalarType("uint32_t"), - docstring = "The absolute OTP address at which this partition's digest starts", + docstring = "The OTP digest CSR (where the digest is buffered) offset for " + + "this partition.", ) self._otp_partition_info_struct.add_field( name = self.OTP_PARTITION_INFO_STRUCT_ALIGN_MASK_FIELD_NAME, diff --git a/hw/top_earlgrey/ip_autogen/otp_ctrl/util/dt.py b/hw/top_earlgrey/ip_autogen/otp_ctrl/util/dt.py index ea5aeac32ea13..b390483c8e345 100644 --- a/hw/top_earlgrey/ip_autogen/otp_ctrl/util/dt.py +++ b/hw/top_earlgrey/ip_autogen/otp_ctrl/util/dt.py @@ -52,7 +52,7 @@ class OtpCtrlExt(Extension): OTP_PARTITION_INFO_STRUCT_START_ADDR_FIELD_NAME = Name(["start", "addr"]) OTP_PARTITION_INFO_STRUCT_SIZE_FIELD_NAME = Name(["size"]) - OTP_PARTITION_INFO_STRUCT_DIGEST_ADDR_FIELD_NAME = Name(["digest", "addr"]) + OTP_PARTITION_INFO_STRUCT_DIGEST_ADDR_FIELD_NAME = Name(["digest", "reg", "offset"]) OTP_PARTITION_INFO_STRUCT_ALIGN_MASK_FIELD_NAME = Name(["align", "mask"]) OTP_PARTITION_INFO_STRUCT_NAME = Name.from_snake_case("dt_otp_partition_info") @@ -82,7 +82,8 @@ def __init__(self, ip_helper: IpHelper): self._otp_partition_info_struct.add_field( name = self.OTP_PARTITION_INFO_STRUCT_DIGEST_ADDR_FIELD_NAME, field_type = ScalarType("uint32_t"), - docstring = "The absolute OTP address at which this partition's digest starts", + docstring = "The OTP digest CSR (where the digest is buffered) offset for " + + "this partition.", ) self._otp_partition_info_struct.add_field( name = self.OTP_PARTITION_INFO_STRUCT_ALIGN_MASK_FIELD_NAME, diff --git a/sw/device/silicon_creator/lib/drivers/otp.c b/sw/device/silicon_creator/lib/drivers/otp.c index 9dc9efb25a397..bb9a5c6070078 100644 --- a/sw/device/silicon_creator/lib/drivers/otp.c +++ b/sw/device/silicon_creator/lib/drivers/otp.c @@ -56,7 +56,8 @@ dt_otp_partition_info_t otp_readable_partition_info(otp_partition_t partition) { uint64_t otp_partition_digest_read(otp_partition_t partition) { uint32_t reg_offset = - otp_ctrl_base() + otp_readable_partition_info(partition).digest_addr; + otp_ctrl_base() + + otp_readable_partition_info(partition).digest_reg_offset; uint64_t value = sec_mmio_read32(reg_offset + sizeof(uint32_t)); value <<= 32; value |= sec_mmio_read32(reg_offset); diff --git a/sw/device/silicon_creator/rom/e2e/keymgr/rom_e2e_keymgr_init_test.c b/sw/device/silicon_creator/rom/e2e/keymgr/rom_e2e_keymgr_init_test.c index baadd021f568b..76364b6442a14 100644 --- a/sw/device/silicon_creator/rom/e2e/keymgr/rom_e2e_keymgr_init_test.c +++ b/sw/device/silicon_creator/rom/e2e/keymgr/rom_e2e_keymgr_init_test.c @@ -43,17 +43,17 @@ bool test_main(void) { // - the digest of the CreatorSwCfg partition, // - the digest of the OwnerSwCfg partition, // - the SHA256 integrity hash of the first stage boot keys. - otp_dai_read( - kOtpPartitionCreatorSwCfg, - /*relative_address=*/ - otp_readable_partition_info(kOtpPartitionCreatorSwCfg).digest_addr - - OTP_CTRL_PARAM_CREATOR_SW_CFG_OFFSET, - otp_state, - /*num_words=*/2); + otp_dai_read(kOtpPartitionCreatorSwCfg, + /*relative_address=*/ + otp_readable_partition_info(kOtpPartitionCreatorSwCfg) + .digest_reg_offset - + OTP_CTRL_PARAM_CREATOR_SW_CFG_OFFSET, + otp_state, + /*num_words=*/2); otp_dai_read( kOtpPartitionOwnerSwCfg, /*relative_address=*/ - otp_readable_partition_info(kOtpPartitionOwnerSwCfg).digest_addr - + otp_readable_partition_info(kOtpPartitionOwnerSwCfg).digest_reg_offset - OTP_CTRL_PARAM_OWNER_SW_CFG_OFFSET, &otp_state[2], /*num_words=*/2);