Skip to content

Commit 9ba1288

Browse files
rivos-eblotloiclefort
authored andcommitted
[ot] hw/opentitan: ot_rstmgr: replace platform reset with IRQ line
It is up to the machine to manage the reset signal. Signed-off-by: Emmanuel Blot <eblot@rivosinc.com>
1 parent eb90603 commit 9ba1288

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

hw/opentitan/ot_rstmgr.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
#include "hw/riscv/ibex_common.h"
4444
#include "hw/riscv/ibex_irq.h"
4545
#include "hw/sysbus.h"
46-
#include "sysemu/hw_accel.h"
4746
#include "sysemu/runstate.h"
4847
#include "trace.h"
4948

@@ -147,6 +146,7 @@ struct OtRstMgrState {
147146
SysBusDevice parent_obj;
148147

149148
MemoryRegion mmio;
149+
IbexIRQ soc_reset;
150150
IbexIRQ sw_reset;
151151
IbexIRQ alerts[PARAM_NUM_ALERTS];
152152
QEMUBH *bus_reset_bh;
@@ -228,12 +228,7 @@ static void ot_rstmgr_reset_bus(void *opaque)
228228
}
229229
qemu_notify_event();
230230

231-
cpu_synchronize_state(s->cpu);
232-
/* Reset all OpenTitan devices connected to RSTMGR parent bus */
233-
bus_cold_reset(s->parent_obj.parent_obj.parent_bus);
234-
cpu_synchronize_post_reset(s->cpu);
235-
236-
/* TODO: manage reset tree (depending on power domains, etc.) */
231+
ibex_irq_raise(&s->soc_reset);
237232
}
238233

239234
static int ot_rstmgr_sw_rst_walker(DeviceState *dev, void *opaque)
@@ -393,7 +388,7 @@ static void ot_rstmgr_regs_write(void *opaque, hwaddr addr, uint64_t val64,
393388
* "Upon completion of reset, this bit is automatically cleared by
394389
* hardware."
395390
*/
396-
ibex_irq_set(&s->sw_reset, (int)true);
391+
ibex_irq_raise(&s->sw_reset);
397392
if (s->fatal_reset) {
398393
s->fatal_reset--;
399394
if (!s->fatal_reset) {
@@ -544,7 +539,8 @@ static void ot_rstmgr_reset(DeviceState *dev)
544539
s->regs[R_SW_RST_CTRL_N_0 + ix] = 0x1u;
545540
}
546541

547-
ibex_irq_set(&s->sw_reset, 0);
542+
ibex_irq_lower(&s->soc_reset);
543+
ibex_irq_lower(&s->sw_reset);
548544
ot_rstmgr_update_alerts(s);
549545
}
550546

@@ -558,6 +554,7 @@ static void ot_rstmgr_init(Object *obj)
558554

559555
s->regs = g_new0(uint32_t, REGS_COUNT);
560556

557+
ibex_qdev_init_irq(obj, &s->soc_reset, OT_RSTMGR_SOC_RST);
561558
ibex_qdev_init_irq(obj, &s->sw_reset, OT_RSTMGR_SW_RST);
562559
ibex_qdev_init_irqs(obj, s->alerts, OT_DEVICE_ALERT, PARAM_NUM_ALERTS);
563560

include/hw/opentitan/ot_rstmgr.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@
3333
#define TYPE_OT_RSTMGR "ot-rstmgr"
3434
OBJECT_DECLARE_SIMPLE_TYPE(OtRstMgrState, OT_RSTMGR)
3535

36-
#define OT_RSTMGR_SW_RST TYPE_OT_RSTMGR "-sw-rst"
37-
3836
typedef enum {
3937
OT_RSTMGR_RESET_POR,
4038
OT_RSTMGR_RESET_LOW_POWER,
@@ -52,6 +50,10 @@ typedef enum {
5250
#define OT_RSTMGR_RESET_REQUEST(_fast_, _req_) \
5351
((int)((1u << 31u) | (((int)(bool)_fast_) << 8u) | _req_))
5452

53+
/* output lines */
54+
#define OT_RSTMGR_SOC_RST TYPE_OT_RSTMGR "-soc-reset"
55+
#define OT_RSTMGR_SW_RST TYPE_OT_RSTMGR "-sw-reset"
56+
5557
/* input lines */
5658
#define OT_RSTMGR_RST_REQ TYPE_OT_RSTMGR "-reset-req"
5759

0 commit comments

Comments
 (0)