]> git.proxmox.com Git - mirror_qemu.git/commitdiff
hw: Move M41T80 device from hw/timer/ to hw/rtc/ subdirectory
authorPhilippe Mathieu-Daudé <philmd@redhat.com>
Thu, 3 Oct 2019 23:03:55 +0000 (01:03 +0200)
committerLaurent Vivier <laurent@vivier.eu>
Thu, 24 Oct 2019 18:22:12 +0000 (20:22 +0200)
The M41T80 is a Real Time Clock, not a timer.
Move it under the hw/rtc/ subdirectory.

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20191003230404.19384-6-philmd@redhat.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
MAINTAINERS
hw/rtc/Kconfig
hw/rtc/Makefile.objs
hw/rtc/m41t80.c [new file with mode: 0644]
hw/timer/Kconfig
hw/timer/Makefile.objs
hw/timer/m41t80.c [deleted file]

index 4e65f062f29c75797bfd1be44c124105acede8fa..ba0d1906aae962e5fe6694af12eea3986e68c37d 100644 (file)
@@ -1111,7 +1111,7 @@ F: hw/ppc/sam460ex.c
 F: hw/ppc/ppc440_pcix.c
 F: hw/display/sm501*
 F: hw/ide/sii3112.c
-F: hw/timer/m41t80.c
+F: hw/rtc/m41t80.c
 F: pc-bios/canyonlands.dt[sb]
 F: pc-bios/u-boot-sam460ex-20100605.bin
 F: roms/u-boot-sam460ex
index 159c2335171a0ed94b6fdc7640b1c665b4b8e44a..434b20b2b1bda350c99152bffb6b716bff40acf7 100644 (file)
@@ -1,3 +1,7 @@
+config M41T80
+    bool
+    depends on I2C
+
 config M48T59
     bool
 
index c87f81405e9ddf72ebc7152a08ab2dab1b7b8339..89e8e48c640942a2ae468bd64e7a008ddc35bf8b 100644 (file)
@@ -1,3 +1,4 @@
+common-obj-$(CONFIG_M41T80) += m41t80.o
 common-obj-$(CONFIG_M48T59) += m48t59.o
 ifeq ($(CONFIG_ISA_BUS),y)
 common-obj-$(CONFIG_M48T59) += m48t59-isa.o
diff --git a/hw/rtc/m41t80.c b/hw/rtc/m41t80.c
new file mode 100644 (file)
index 0000000..914ecac
--- /dev/null
@@ -0,0 +1,119 @@
+/*
+ * M41T80 serial rtc emulation
+ *
+ * Copyright (c) 2018 BALATON Zoltan
+ *
+ * This work is licensed under the GNU GPL license version 2 or later.
+ *
+ */
+
+#include "qemu/osdep.h"
+#include "qemu-common.h"
+#include "qemu/log.h"
+#include "qemu/module.h"
+#include "qemu/timer.h"
+#include "qemu/bcd.h"
+#include "hw/i2c/i2c.h"
+
+#define TYPE_M41T80 "m41t80"
+#define M41T80(obj) OBJECT_CHECK(M41t80State, (obj), TYPE_M41T80)
+
+typedef struct M41t80State {
+    I2CSlave parent_obj;
+    int8_t addr;
+} M41t80State;
+
+static void m41t80_realize(DeviceState *dev, Error **errp)
+{
+    M41t80State *s = M41T80(dev);
+
+    s->addr = -1;
+}
+
+static int m41t80_send(I2CSlave *i2c, uint8_t data)
+{
+    M41t80State *s = M41T80(i2c);
+
+    if (s->addr < 0) {
+        s->addr = data;
+    } else {
+        s->addr++;
+    }
+    return 0;
+}
+
+static uint8_t m41t80_recv(I2CSlave *i2c)
+{
+    M41t80State *s = M41T80(i2c);
+    struct tm now;
+    qemu_timeval tv;
+
+    if (s->addr < 0) {
+        s->addr = 0;
+    }
+    if (s->addr >= 1 && s->addr <= 7) {
+        qemu_get_timedate(&now, -1);
+    }
+    switch (s->addr++) {
+    case 0:
+        qemu_gettimeofday(&tv);
+        return to_bcd(tv.tv_usec / 10000);
+    case 1:
+        return to_bcd(now.tm_sec);
+    case 2:
+        return to_bcd(now.tm_min);
+    case 3:
+        return to_bcd(now.tm_hour);
+    case 4:
+        return to_bcd(now.tm_wday);
+    case 5:
+        return to_bcd(now.tm_mday);
+    case 6:
+        return to_bcd(now.tm_mon + 1);
+    case 7:
+        return to_bcd(now.tm_year % 100);
+    case 8 ... 19:
+        qemu_log_mask(LOG_UNIMP, "%s: unimplemented register: %d\n",
+                      __func__, s->addr - 1);
+        return 0;
+    default:
+        qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid register: %d\n",
+                      __func__, s->addr - 1);
+        return 0;
+    }
+}
+
+static int m41t80_event(I2CSlave *i2c, enum i2c_event event)
+{
+    M41t80State *s = M41T80(i2c);
+
+    if (event == I2C_START_SEND) {
+        s->addr = -1;
+    }
+    return 0;
+}
+
+static void m41t80_class_init(ObjectClass *klass, void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(klass);
+    I2CSlaveClass *sc = I2C_SLAVE_CLASS(klass);
+
+    dc->realize = m41t80_realize;
+    sc->send = m41t80_send;
+    sc->recv = m41t80_recv;
+    sc->event = m41t80_event;
+}
+
+static const TypeInfo m41t80_info = {
+    .name          = TYPE_M41T80,
+    .parent        = TYPE_I2C_SLAVE,
+    .instance_size = sizeof(M41t80State),
+    .class_init    = m41t80_class_init,
+};
+
+static void m41t80_register_types(void)
+{
+    type_register_static(&m41t80_info);
+}
+
+type_init(m41t80_register_types)
index a57e9b59fca8c94d6f000ce14822e14966b61b85..a6b668b2559b2a4e05d5f9baefc9edd4b1efec38 100644 (file)
@@ -20,10 +20,6 @@ config HPET
 config I8254
     bool
 
-config M41T80
-    bool
-    depends on I2C
-
 config TWL92230
     bool
     depends on I2C
index fe2d1fbc4040b8efe3f7f1645565269be184693b..2fb12162a623bf5c37d459b35191f1bb7a564904 100644 (file)
@@ -6,7 +6,6 @@ common-obj-$(CONFIG_CADENCE) += cadence_ttc.o
 common-obj-$(CONFIG_DS1338) += ds1338.o
 common-obj-$(CONFIG_HPET) += hpet.o
 common-obj-$(CONFIG_I8254) += i8254_common.o i8254.o
-common-obj-$(CONFIG_M41T80) += m41t80.o
 common-obj-$(CONFIG_PUV3) += puv3_ost.o
 common-obj-$(CONFIG_TWL92230) += twl92230.o
 common-obj-$(CONFIG_XILINX) += xilinx_timer.o
diff --git a/hw/timer/m41t80.c b/hw/timer/m41t80.c
deleted file mode 100644 (file)
index 914ecac..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * M41T80 serial rtc emulation
- *
- * Copyright (c) 2018 BALATON Zoltan
- *
- * This work is licensed under the GNU GPL license version 2 or later.
- *
- */
-
-#include "qemu/osdep.h"
-#include "qemu-common.h"
-#include "qemu/log.h"
-#include "qemu/module.h"
-#include "qemu/timer.h"
-#include "qemu/bcd.h"
-#include "hw/i2c/i2c.h"
-
-#define TYPE_M41T80 "m41t80"
-#define M41T80(obj) OBJECT_CHECK(M41t80State, (obj), TYPE_M41T80)
-
-typedef struct M41t80State {
-    I2CSlave parent_obj;
-    int8_t addr;
-} M41t80State;
-
-static void m41t80_realize(DeviceState *dev, Error **errp)
-{
-    M41t80State *s = M41T80(dev);
-
-    s->addr = -1;
-}
-
-static int m41t80_send(I2CSlave *i2c, uint8_t data)
-{
-    M41t80State *s = M41T80(i2c);
-
-    if (s->addr < 0) {
-        s->addr = data;
-    } else {
-        s->addr++;
-    }
-    return 0;
-}
-
-static uint8_t m41t80_recv(I2CSlave *i2c)
-{
-    M41t80State *s = M41T80(i2c);
-    struct tm now;
-    qemu_timeval tv;
-
-    if (s->addr < 0) {
-        s->addr = 0;
-    }
-    if (s->addr >= 1 && s->addr <= 7) {
-        qemu_get_timedate(&now, -1);
-    }
-    switch (s->addr++) {
-    case 0:
-        qemu_gettimeofday(&tv);
-        return to_bcd(tv.tv_usec / 10000);
-    case 1:
-        return to_bcd(now.tm_sec);
-    case 2:
-        return to_bcd(now.tm_min);
-    case 3:
-        return to_bcd(now.tm_hour);
-    case 4:
-        return to_bcd(now.tm_wday);
-    case 5:
-        return to_bcd(now.tm_mday);
-    case 6:
-        return to_bcd(now.tm_mon + 1);
-    case 7:
-        return to_bcd(now.tm_year % 100);
-    case 8 ... 19:
-        qemu_log_mask(LOG_UNIMP, "%s: unimplemented register: %d\n",
-                      __func__, s->addr - 1);
-        return 0;
-    default:
-        qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid register: %d\n",
-                      __func__, s->addr - 1);
-        return 0;
-    }
-}
-
-static int m41t80_event(I2CSlave *i2c, enum i2c_event event)
-{
-    M41t80State *s = M41T80(i2c);
-
-    if (event == I2C_START_SEND) {
-        s->addr = -1;
-    }
-    return 0;
-}
-
-static void m41t80_class_init(ObjectClass *klass, void *data)
-{
-    DeviceClass *dc = DEVICE_CLASS(klass);
-    I2CSlaveClass *sc = I2C_SLAVE_CLASS(klass);
-
-    dc->realize = m41t80_realize;
-    sc->send = m41t80_send;
-    sc->recv = m41t80_recv;
-    sc->event = m41t80_event;
-}
-
-static const TypeInfo m41t80_info = {
-    .name          = TYPE_M41T80,
-    .parent        = TYPE_I2C_SLAVE,
-    .instance_size = sizeof(M41t80State),
-    .class_init    = m41t80_class_init,
-};
-
-static void m41t80_register_types(void)
-{
-    type_register_static(&m41t80_info);
-}
-
-type_init(m41t80_register_types)