Skip to content

Commit c232d98

Browse files
committed
[ot] hw/opentitan: gpio: remember input lines between resets
Signed-off-by: James Wainwright <james.wainwright@lowrisc.org>
1 parent b28ee32 commit c232d98

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

hw/opentitan/ot_gpio_eg.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -718,10 +718,8 @@ static void ot_gpio_eg_reset_enter(Object *obj, ResetType type)
718718

719719
/* reset_* fields are properties, never get reset */
720720
s->data_ii = s->reset_in;
721-
s->data_ib = 0;
722721
s->data_out = s->reset_out;
723722
s->data_oe = s->reset_oe;
724-
s->data_bi = UINT32_MAX;
725723
/* all input disable until signal is received, or output is forced */
726724
s->data_gi = ~s->reset_oe;
727725
s->pull_en = 0;
@@ -733,7 +731,13 @@ static void ot_gpio_eg_reset_enter(Object *obj, ResetType type)
733731
s->regs[R_DIRECT_OUT] = s->reset_out;
734732
s->regs[R_DIRECT_OE] = s->reset_oe;
735733

736-
ot_gpio_eg_update_irqs(s);
734+
/*
735+
* Sample the input lines (e.g. the chardev) which persist their state
736+
* across reset. This is important for cases like straps which are held
737+
* asserted across a reset.
738+
*/
739+
ot_gpio_eg_update_data_in(s);
740+
737741
ibex_irq_set(&s->alert, 0);
738742

739743
trace_ot_gpio_reset(s->ot_id, "< enter");
@@ -798,6 +802,10 @@ static void ot_gpio_eg_init(Object *obj)
798802
PARAM_NUM_IO);
799803
qdev_init_gpio_in_named(DEVICE(obj), &ot_gpio_eg_pad_attr_change,
800804
OT_PINMUX_PAD, PARAM_NUM_IO);
805+
806+
/* Backend state persists across reset so initialise it once now */
807+
s->data_ib = 0u;
808+
s->data_bi = UINT32_MAX;
801809
}
802810

803811
static void ot_gpio_eg_class_init(ObjectClass *klass, void *data)

0 commit comments

Comments
 (0)