From: Antoine Mathys <barsamin@gmail.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>, paul@codesourcery.com
Subject: Re: [Qemu-devel] [PATCH v3 5/6] hw/ds1338.c: Implement support for the control register.
Date: Wed, 12 Dec 2012 23:33:41 +0100 [thread overview]
Message-ID: <50C90645.50102@gmail.com> (raw)
In-Reply-To: <50C9041A.8020202@gmail.com>
Signed-off-by: Antoine Mathys <barsamin@gmail.com>
---
hw/ds1338.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/hw/ds1338.c b/hw/ds1338.c
index d2f52fc..94a2f54 100644
--- a/hw/ds1338.c
+++ b/hw/ds1338.c
@@ -125,7 +125,8 @@ static int ds1338_send(I2CSlave *i2c, uint8_t data)
s->addr_byte = false;
return 0;
}
- if (s->ptr < 8) {
+ if (s->ptr < 7) {
+ /* Time register. */
struct tm now;
qemu_get_timedate(&now, s->offset);
switch(s->ptr) {
@@ -162,11 +163,19 @@ static int ds1338_send(I2CSlave *i2c, uint8_t data)
case 6:
now.tm_year = from_bcd(data) + 100;
break;
- case 7:
- /* Control register. Currently ignored. */
- break;
}
s->offset = qemu_timedate_diff(&now);
+ } else if (s->ptr == 7) {
+ /* Control register. */
+
+ /* Ensure bits 2, 3 and 6 will read back as zero. */
+ data &= 0xB3;
+
+ /* Attempting to write the OSF flag to logic 1 leaves the
+ value unchanged. */
+ data = (data & ~CTRL_OSF) | (data & s->nvram[s->ptr] & CTRL_OSF);
+
+ s->nvram[s->ptr] = data;
} else {
s->nvram[s->ptr] = data;
}
--
1.7.10.4
next prev parent reply other threads:[~2012-12-12 22:34 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-12 22:24 [Qemu-devel] [PATCH v3 0/6] hw/ds1338.c Antoine Mathys
2012-12-12 22:28 ` [Qemu-devel] [PATCH v3 2/6] hw/ds1338.c: Add definitions for various flags in, the RTC registers Antoine Mathys
2012-12-12 22:29 ` [Qemu-devel] [PATCH v3 1/6] hw/ds1338.c: Correct bug in conversion to BCD Antoine Mathys
2012-12-12 22:33 ` Antoine Mathys [this message]
2012-12-12 22:35 ` [Qemu-devel] [PATCH v3 3/6] hw/ds1338.c: Fix handling of HOURS register Antoine Mathys
2012-12-12 22:35 ` [Qemu-devel] [PATCH v3 6/6] hw/ds1338.c: Fix handling of DAY (wday) register Antoine Mathys
2012-12-12 22:35 ` [Qemu-devel] [PATCH v3 4/6] hw/ds1338.c: Ensure state is properly initialized Antoine Mathys
2012-12-12 22:40 ` Antoine Mathys
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=50C90645.50102@gmail.com \
--to=barsamin@gmail.com \
--cc=paul@codesourcery.com \
--cc=peter.maydell@linaro.org \
--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).