diff options
author | Michael Walle <michael@walle.cc> | 2011-04-13 00:29:35 +0200 |
---|---|---|
committer | Edgar E. Iglesias <edgar.iglesias@gmail.com> | 2011-05-03 10:48:40 +0200 |
commit | f3172a0e2e7bd983cada19f11d9bb59400e0dd3d (patch) | |
tree | e99e2ccd7f92aa2b4f90a4294498507409074b27 /hw | |
parent | c07050ddb9659805068b2f1a3686c6f096dd11f9 (diff) | |
download | qemu-f3172a0e2e7bd983cada19f11d9bb59400e0dd3d.zip qemu-f3172a0e2e7bd983cada19f11d9bb59400e0dd3d.tar.gz qemu-f3172a0e2e7bd983cada19f11d9bb59400e0dd3d.tar.bz2 |
milkymist-sysctl: fix timers
Prevent timers from firing right after starting.
Signed-off-by: Michael Walle <michael@walle.cc>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/milkymist-sysctl.c | 26 |
1 files changed, 7 insertions, 19 deletions
diff --git a/hw/milkymist-sysctl.c b/hw/milkymist-sysctl.c index eaea543..6bd0cb9 100644 --- a/hw/milkymist-sysctl.c +++ b/hw/milkymist-sysctl.c @@ -140,24 +140,8 @@ static void sysctl_write(void *opaque, target_phys_addr_t addr, uint32_t value) case R_GPIO_OUT: case R_GPIO_INTEN: case R_TIMER0_COUNTER: - if (value > s->regs[R_TIMER0_COUNTER]) { - value = s->regs[R_TIMER0_COUNTER]; - error_report("milkymist_sysctl: timer0: trying to write a " - "value greater than the limit. Clipping."); - } - /* milkymist timer counts up */ - value = s->regs[R_TIMER0_COUNTER] - value; - ptimer_set_count(s->ptimer0, value); - break; case R_TIMER1_COUNTER: - if (value > s->regs[R_TIMER1_COUNTER]) { - value = s->regs[R_TIMER1_COUNTER]; - error_report("milkymist_sysctl: timer1: trying to write a " - "value greater than the limit. Clipping."); - } - /* milkymist timer counts up */ - value = s->regs[R_TIMER1_COUNTER] - value; - ptimer_set_count(s->ptimer1, value); + s->regs[addr] = value; break; case R_TIMER0_COMPARE: ptimer_set_limit(s->ptimer0, value, 0); @@ -170,10 +154,12 @@ static void sysctl_write(void *opaque, target_phys_addr_t addr, uint32_t value) case R_TIMER0_CONTROL: s->regs[addr] = value; if (s->regs[R_TIMER0_CONTROL] & CTRL_ENABLE) { - trace_milkymist_sysctl_start_timer1(); + trace_milkymist_sysctl_start_timer0(); + ptimer_set_count(s->ptimer0, + s->regs[R_TIMER0_COMPARE] - s->regs[R_TIMER0_COUNTER]); ptimer_run(s->ptimer0, 0); } else { - trace_milkymist_sysctl_stop_timer1(); + trace_milkymist_sysctl_stop_timer0(); ptimer_stop(s->ptimer0); } break; @@ -181,6 +167,8 @@ static void sysctl_write(void *opaque, target_phys_addr_t addr, uint32_t value) s->regs[addr] = value; if (s->regs[R_TIMER1_CONTROL] & CTRL_ENABLE) { trace_milkymist_sysctl_start_timer1(); + ptimer_set_count(s->ptimer1, + s->regs[R_TIMER1_COMPARE] - s->regs[R_TIMER1_COUNTER]); ptimer_run(s->ptimer1, 0); } else { trace_milkymist_sysctl_stop_timer1(); |