aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorAntoine Mathys <barsamin@gmail.com>2012-12-13 14:05:28 +0000
committerPeter Maydell <peter.maydell@linaro.org>2012-12-13 14:05:28 +0000
commit996e91f04b9cc55cf246052856abe9189a5a0f28 (patch)
tree8f2703f816afe0c5729d4df0871864dc7d3a8949 /hw
parented3d37d287300b7bcdb4605b921e5ec593afd214 (diff)
downloadqemu-996e91f04b9cc55cf246052856abe9189a5a0f28.zip
qemu-996e91f04b9cc55cf246052856abe9189a5a0f28.tar.gz
qemu-996e91f04b9cc55cf246052856abe9189a5a0f28.tar.bz2
hw/ds1338.c: Implement support for the control register.
Signed-off-by: Antoine Mathys <barsamin@gmail.com> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw')
-rw-r--r--hw/ds1338.c17
1 files 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;
}