From 9a07b789e2ceb7960e59d8978b25c1f49c620fbf Mon Sep 17 00:00:00 2001 From: Alice Ziuziakowska Date: Fri, 12 Jun 2026 11:05:46 +0100 Subject: [PATCH] hw: correct PLIC context interrupt enable stride See https://github.com/lowRISC/opentitan/pull/30371. Signed-off-by: Alice Ziuziakowska --- hw/top_chip/ip_autogen/rv_plic/data/rv_plic.hjson | 2 +- .../ip_autogen/rv_plic/rtl/rv_plic_reg_pkg.sv | 2 +- hw/vendor/lowrisc_ip.vendor.hjson | 2 +- .../ip_templates/rv_plic/data/rv_plic.hjson.tpl | 2 +- .../0001_context_interrupt_enable_stride.patch | 13 +++++++++++++ rdl/ip/plic.rdl | 2 +- sw/device/lib/hal/autogen/plic.h | 8 ++++---- 7 files changed, 22 insertions(+), 9 deletions(-) create mode 100644 hw/vendor/patches/lowrisc_ip/rv_plic/0001_context_interrupt_enable_stride.patch diff --git a/hw/top_chip/ip_autogen/rv_plic/data/rv_plic.hjson b/hw/top_chip/ip_autogen/rv_plic/data/rv_plic.hjson index e5c4b066c..2e13225b1 100644 --- a/hw/top_chip/ip_autogen/rv_plic/data/rv_plic.hjson +++ b/hw/top_chip/ip_autogen/rv_plic/data/rv_plic.hjson @@ -157,7 +157,7 @@ ], } } - { skipto: "0x2100" } + { skipto: "0x2080" } { multireg: { name: "IE1", desc: "Interrupt Enable for Target 1", diff --git a/hw/top_chip/ip_autogen/rv_plic/rtl/rv_plic_reg_pkg.sv b/hw/top_chip/ip_autogen/rv_plic/rtl/rv_plic_reg_pkg.sv index 05e961462..f2d714e6d 100644 --- a/hw/top_chip/ip_autogen/rv_plic/rtl/rv_plic_reg_pkg.sv +++ b/hw/top_chip/ip_autogen/rv_plic/rtl/rv_plic_reg_pkg.sv @@ -141,7 +141,7 @@ package rv_plic_reg_pkg; parameter logic [BlockAw-1:0] RV_PLIC_PRIO_31_OFFSET = 27'h 7c; parameter logic [BlockAw-1:0] RV_PLIC_IP_OFFSET = 27'h 1000; parameter logic [BlockAw-1:0] RV_PLIC_IE0_OFFSET = 27'h 2000; - parameter logic [BlockAw-1:0] RV_PLIC_IE1_OFFSET = 27'h 2100; + parameter logic [BlockAw-1:0] RV_PLIC_IE1_OFFSET = 27'h 2080; parameter logic [BlockAw-1:0] RV_PLIC_THRESHOLD0_OFFSET = 27'h 200000; parameter logic [BlockAw-1:0] RV_PLIC_CC0_OFFSET = 27'h 200004; parameter logic [BlockAw-1:0] RV_PLIC_THRESHOLD1_OFFSET = 27'h 201000; diff --git a/hw/vendor/lowrisc_ip.vendor.hjson b/hw/vendor/lowrisc_ip.vendor.hjson index 099b36789..d714d4c43 100644 --- a/hw/vendor/lowrisc_ip.vendor.hjson +++ b/hw/vendor/lowrisc_ip.vendor.hjson @@ -46,7 +46,7 @@ {from: "hw/ip_templates/gpio", to: "ip_templates/gpio", patch_dir: "gpio"}, // General purpose I/O {from: "hw/ip_templates/pwrmgr", to: "ip_templates/pwrmgr", patch_dir: "pwrmgr"}, {from: "hw/ip_templates/rstmgr", to: "ip_templates/rstmgr", patch_dir: "rstmgr"}, - {from: "hw/ip_templates/rv_plic", to: "ip_templates/rv_plic"}, + {from: "hw/ip_templates/rv_plic", to: "ip_templates/rv_plic", patch_dir: "rv_plic"}, // Primitives. {from: "hw/ip/prim", to: "ip/prim", patch_dir: "prim"}, diff --git a/hw/vendor/lowrisc_ip/ip_templates/rv_plic/data/rv_plic.hjson.tpl b/hw/vendor/lowrisc_ip/ip_templates/rv_plic/data/rv_plic.hjson.tpl index 689366432..b5d797624 100644 --- a/hw/vendor/lowrisc_ip/ip_templates/rv_plic/data/rv_plic.hjson.tpl +++ b/hw/vendor/lowrisc_ip/ip_templates/rv_plic/data/rv_plic.hjson.tpl @@ -179,7 +179,7 @@ } }, % for i in range(target): - { skipto: "${"0x{:x}".format(0x00002000 + i * 0x100)}" } + { skipto: "${"0x{:x}".format(0x00002000 + i * 0x80)}" } { multireg: { name: "IE${i}", desc: "Interrupt Enable for Target ${i}", diff --git a/hw/vendor/patches/lowrisc_ip/rv_plic/0001_context_interrupt_enable_stride.patch b/hw/vendor/patches/lowrisc_ip/rv_plic/0001_context_interrupt_enable_stride.patch new file mode 100644 index 000000000..8d3e978ba --- /dev/null +++ b/hw/vendor/patches/lowrisc_ip/rv_plic/0001_context_interrupt_enable_stride.patch @@ -0,0 +1,13 @@ +diff --git a/data/rv_plic.hjson.tpl b/data/rv_plic.hjson.tpl +index 68936643..b5d79762 100644 +--- a/data/rv_plic.hjson.tpl ++++ b/data/rv_plic.hjson.tpl +@@ -179,7 +179,7 @@ + } + }, + % for i in range(target): +- { skipto: "${"0x{:x}".format(0x00002000 + i * 0x100)}" } ++ { skipto: "${"0x{:x}".format(0x00002000 + i * 0x80)}" } + { multireg: { + name: "IE${i}", + desc: "Interrupt Enable for Target ${i}", diff --git a/rdl/ip/plic.rdl b/rdl/ip/plic.rdl index 5ba801bcb..9575bd1ef 100644 --- a/rdl/ip/plic.rdl +++ b/rdl/ip/plic.rdl @@ -724,6 +724,6 @@ addrmap rv_plic #( reset = 0x0; desc = "Interrupt Enable of Source"; } E_31[31:31]; - } IE1[1] @ 0x2100; + } IE1[1] @ 0x2080; }; diff --git a/sw/device/lib/hal/autogen/plic.h b/sw/device/lib/hal/autogen/plic.h index da92ebe1a..50b1961b2 100644 --- a/sw/device/lib/hal/autogen/plic.h +++ b/sw/device/lib/hal/autogen/plic.h @@ -62,12 +62,12 @@ typedef volatile struct [[gnu::aligned(4)]] plic_memory_layout { /* plic.ie0 (0x2000) */ uint32_t ie0; - const uint8_t __reserved2[0x2100 - 0x2004]; + const uint8_t __reserved2[0x2080 - 0x2004]; - /* plic.ie1 (0x2100) */ + /* plic.ie1 (0x2080) */ uint32_t ie1; - const uint8_t __reserved3[0x200000 - 0x2104]; + const uint8_t __reserved3[0x200000 - 0x2084]; /* plic.threshold0 (0x200000) */ plic_threshold0 threshold0; @@ -103,7 +103,7 @@ _Static_assert(__builtin_offsetof(struct plic_memory_layout, ip) == 0x1000ul, "incorrect register ip offset"); _Static_assert(__builtin_offsetof(struct plic_memory_layout, ie0) == 0x2000ul, "incorrect register ie0 offset"); -_Static_assert(__builtin_offsetof(struct plic_memory_layout, ie1) == 0x2100ul, +_Static_assert(__builtin_offsetof(struct plic_memory_layout, ie1) == 0x2080ul, "incorrect register ie1 offset"); _Static_assert(__builtin_offsetof(struct plic_memory_layout, threshold0) == 0x200000ul, "incorrect register threshold0 offset");