qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Michael Walle <michael@walle.cc>
To: qemu-devel@nongnu.org
Cc: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
	Michael Walle <michael@walle.cc>
Subject: [Qemu-devel] [PATCH 3/4] milkymist-sysctl: fix timers
Date: Wed, 13 Apr 2011 00:29:35 +0200	[thread overview]
Message-ID: <1302647376-26764-4-git-send-email-michael@walle.cc> (raw)
In-Reply-To: <1302647376-26764-1-git-send-email-michael@walle.cc>

Prevent timers from firing right after starting.

Signed-off-by: Michael Walle <michael@walle.cc>
---
 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();
-- 
1.7.2.3

  parent reply	other threads:[~2011-04-13  1:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-12 22:29 [Qemu-devel] [PATCH 0/4] lm32 and BSP fixes Michael Walle
2011-04-12 22:29 ` [Qemu-devel] [PATCH 1/4] lm32: fix exception handling Michael Walle
2011-04-12 22:29 ` [Qemu-devel] [PATCH 2/4] milkymist-vgafb: fix console resizing Michael Walle
2011-04-12 22:29 ` Michael Walle [this message]
2011-04-12 22:29 ` [Qemu-devel] [PATCH 4/4] lm32: add Milkymist Minimac2 support Michael Walle
2011-05-02 20:10 ` [Qemu-devel] [PATCH 0/4] lm32 and BSP fixes Michael Walle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1302647376-26764-4-git-send-email-michael@walle.cc \
    --to=michael@walle.cc \
    --cc=edgar.iglesias@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).