diff options
Diffstat (limited to 'sim/bfin/dv-bfin_gpio2.c')
-rw-r--r-- | sim/bfin/dv-bfin_gpio2.c | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/sim/bfin/dv-bfin_gpio2.c b/sim/bfin/dv-bfin_gpio2.c index 0069e0d331b..a2b941956a0 100644 --- a/sim/bfin/dv-bfin_gpio2.c +++ b/sim/bfin/dv-bfin_gpio2.c @@ -66,22 +66,28 @@ bfin_gpio_io_write_buffer (struct hw *me, const void *source, int space, bu32 *value32p; void *valuep; + mmr_off = addr - port->base; + + /* Invalid access mode is higher priority than missing register. */ + if (mmr_off == mmr_offset (mux)) + { + if (!dv_bfin_mmr_require_32 (me, addr, nr_bytes, true)) + return 0; + } + else + if (!dv_bfin_mmr_require_16 (me, addr, nr_bytes, true)) + return 0; + if (nr_bytes == 4) value = dv_load_4 (source); else value = dv_load_2 (source); - mmr_off = addr - port->base; valuep = (void *)((unsigned long)port + mmr_base() + mmr_off); value16p = valuep; value32p = valuep; HW_TRACE_WRITE (); - if (mmr_off == mmr_offset (mux)) - dv_bfin_mmr_require_32 (me, addr, nr_bytes, true); - else - dv_bfin_mmr_require_16 (me, addr, nr_bytes, true); - switch (mmr_off) { case mmr_offset(fer): @@ -108,7 +114,7 @@ bfin_gpio_io_write_buffer (struct hw *me, const void *source, int space, break; default: dv_bfin_mmr_invalid (me, addr, nr_bytes, true); - break; + return 0; } /* If tweaking output pins, make sure we send updated port info. */ @@ -148,17 +154,23 @@ bfin_gpio_io_read_buffer (struct hw *me, void *dest, int space, void *valuep; mmr_off = addr - port->base; + + /* Invalid access mode is higher priority than missing register. */ + if (mmr_off == mmr_offset (mux)) + { + if (!dv_bfin_mmr_require_32 (me, addr, nr_bytes, false)) + return 0; + } + else + if (!dv_bfin_mmr_require_16 (me, addr, nr_bytes, false)) + return 0; + valuep = (void *)((unsigned long)port + mmr_base() + mmr_off); value16p = valuep; value32p = valuep; HW_TRACE_READ (); - if (mmr_off == mmr_offset (mux)) - dv_bfin_mmr_require_32 (me, addr, nr_bytes, false); - else - dv_bfin_mmr_require_16 (me, addr, nr_bytes, false); - switch (mmr_off) { case mmr_offset(data): @@ -179,7 +191,7 @@ bfin_gpio_io_read_buffer (struct hw *me, void *dest, int space, break; default: dv_bfin_mmr_invalid (me, addr, nr_bytes, false); - break; + return 0; } return nr_bytes; |