Skip to content

Commit 567224d

Browse files
committed
[ot] hw/opentitan: ot_gpio: add an input enable property
Signed-off-by: Emmanuel Blot <eblot@rivosinc.com>
1 parent 89e9155 commit 567224d

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

hw/opentitan/ot_gpio_dj.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ struct OtGpioDjState {
140140
uint32_t opendrain; /* open drain (1 -> hi-z) */
141141
uint32_t pull_en; /* pull up/down enable */
142142
uint32_t pull_sel; /* pull up or pull down */
143-
uint32_t connected; /* connected to an external device */
143+
uint32_t connected; /* connected to an external device or preset */
144144

145145
char ibuf[PARAM_NUM_IO]; /* backed input buffer */
146146
unsigned ipos;
@@ -153,6 +153,7 @@ struct OtGpioDjState {
153153
uint32_t reset_in; /* initial input levels */
154154
uint32_t reset_out; /* initial output levels */
155155
uint32_t reset_oe; /* initial output enable vs. hi-z levels */
156+
uint32_t reset_ie; /* initial input enable (reset_in active GPIOs) */
156157
uint32_t ibex_out; /* output w/ ibex_gpio (vs. tri-state) signalization */
157158
CharBackend chr; /* communication device */
158159
guint watch_tag; /* tracker for comm device change */
@@ -208,7 +209,7 @@ static void ot_gpio_dj_update_data_in(OtGpioDjState *s)
208209

209210
uint32_t ii_mask = s->connected & ~s->data_gi & ~s->data_oe;
210211
uint32_t bi_mask = ~s->connected & ~s->data_bi & ~s->data_oe;
211-
uint32_t pi_mask = s->connected & s->data_gi & s->data_bi & ~s->data_oe;
212+
uint32_t pi_mask = s->data_gi & s->data_bi & ~s->data_oe;
212213

213214
uint32_t data_ii = s->data_ii & ii_mask;
214215
uint32_t data_ib = s->data_ib & bi_mask;
@@ -801,6 +802,7 @@ static Property ot_gpio_dj_properties[] = {
801802
DEFINE_PROP_STRING("log_id", OtGpioDjState, log_id),
802803
DEFINE_PROP_UINT32("in", OtGpioDjState, reset_in, 0u),
803804
DEFINE_PROP_UINT32("out", OtGpioDjState, reset_out, 0u),
805+
DEFINE_PROP_UINT32("ie", OtGpioDjState, reset_ie, 0u),
804806
DEFINE_PROP_UINT32("oe", OtGpioDjState, reset_oe, 0u),
805807
DEFINE_PROP_UINT32("ibex_out", OtGpioDjState, ibex_out, 0u),
806808
DEFINE_PROP_BOOL("wipe", OtGpioDjState, wipe, false),
@@ -834,17 +836,16 @@ static void ot_gpio_dj_reset_enter(Object *obj, ResetType type)
834836
memset(&s->backend_state, 0, sizeof(s->backend_state));
835837

836838
/* reset_* fields are properties, never get reset */
839+
s->connected = s->reset_oe | s->reset_ie;
837840
s->data_ii = s->reset_in;
838841
s->data_ib = 0;
839842
s->data_out = s->reset_out;
840843
s->data_oe = s->reset_oe;
841844
s->data_bi = UINT32_MAX;
842-
/* all input disable until signal is received, or output is forced */
843-
s->data_gi = ~s->reset_oe;
845+
s->data_gi = ~s->connected;
844846
s->pull_en = 0;
845847
s->pull_sel = 0;
846848
s->invert = 0;
847-
s->connected = 0;
848849

849850
s->regs[R_DATA_IN] = s->reset_in;
850851
s->regs[R_DIRECT_OUT] = s->reset_out;

0 commit comments

Comments
 (0)