diff mbox series

[08/11] hw/rx: rx62n use new hw modules.

Message ID 20210527052122.97103-9-ysato@users.sourceforge.jp (mailing list archive)
State New, archived
Headers show
Series Unified peripheral emulation for Renesas chips | expand

Commit Message

Yoshinori Sato May 27, 2021, 5:21 a.m. UTC
Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
---
 include/hw/rx/rx62n.h | 10 +++++-----
 hw/rx/rx62n.c         | 18 ++++++++++++------
 hw/rx/Kconfig         |  4 ++--
 3 files changed, 19 insertions(+), 13 deletions(-)
diff mbox series

Patch

diff --git a/include/hw/rx/rx62n.h b/include/hw/rx/rx62n.h
index 44f5fcc74d..942ed0639f 100644
--- a/include/hw/rx/rx62n.h
+++ b/include/hw/rx/rx62n.h
@@ -26,8 +26,8 @@ 
 
 #include "target/rx/cpu.h"
 #include "hw/intc/rx_icu.h"
-#include "hw/timer/renesas_tmr.h"
-#include "hw/timer/renesas_cmt.h"
+#include "hw/timer/renesas_tmr8.h"
+#include "hw/timer/renesas_timer.h"
 #include "hw/char/renesas_sci.h"
 #include "hw/rx/rx62n-cpg.h"
 #include "qemu/units.h"
@@ -56,9 +56,9 @@  struct RX62NState {
 
     RXCPU cpu;
     RXICUState icu;
-    RTMRState tmr[RX62N_NR_TMR];
-    RCMTState cmt[RX62N_NR_CMT];
-    RSCIState sci[RX62N_NR_SCI];
+    RenesasTMR8State tmr[RX62N_NR_TMR];
+    RenesasCMTState cmt[RX62N_NR_CMT];
+    RenesasSCIState sci[RX62N_NR_SCI];
     RX62NCPGState cpg;
 
     MemoryRegion *sysmem;
diff --git a/hw/rx/rx62n.c b/hw/rx/rx62n.c
index cfd41930bf..58eff0b4a3 100644
--- a/hw/rx/rx62n.c
+++ b/hw/rx/rx62n.c
@@ -164,7 +164,7 @@  static void register_tmr(RX62NState *s, int unit)
     char ckname[16];
 
     object_initialize_child(OBJECT(s), "tmr[*]",
-                            &s->tmr[unit], TYPE_RENESAS_TMR);
+                            &s->tmr[unit], TYPE_RENESAS_TMR8);
     tmr = SYS_BUS_DEVICE(&s->tmr[unit]);
 
     irqbase = RX62N_TMR_IRQ + TMR_NR_IRQ * unit;
@@ -174,10 +174,10 @@  static void register_tmr(RX62NState *s, int unit)
     sysbus_mmio_map(tmr, 0, RX62N_TMR_BASE + unit * 0x10);
 
     qdev_prop_set_uint32(DEVICE(tmr), "unit", unit);
-    sysbus_realize(tmr, &error_abort);
     snprintf(ckname, sizeof(ckname), "pck_tmr8-%d", unit);
     qdev_connect_clock_in(DEVICE(tmr), "pck",
                           qdev_get_clock_out(DEVICE(&s->cpg), ckname));
+    sysbus_realize(tmr, &error_abort);
 }
 
 static void register_cmt(RX62NState *s, int unit)
@@ -190,6 +190,9 @@  static void register_cmt(RX62NState *s, int unit)
                             &s->cmt[unit], TYPE_RENESAS_CMT);
     cmt = SYS_BUS_DEVICE(&s->cmt[unit]);
     qdev_prop_set_uint32(DEVICE(cmt), "unit", unit);
+    snprintf(ckname, sizeof(ckname), "pck_cmt-%d", unit);
+    qdev_connect_clock_in(DEVICE(cmt), "pck",
+                          qdev_get_clock_out(DEVICE(&s->cpg), ckname));
 
     irqbase = RX62N_CMT_IRQ + CMT_NR_IRQ * unit;
     for (i = 0; i < CMT_NR_IRQ; i++) {
@@ -197,20 +200,23 @@  static void register_cmt(RX62NState *s, int unit)
     }
     sysbus_mmio_map(cmt, 0, RX62N_CMT_BASE + unit * 0x10);
     sysbus_realize(cmt, &error_abort);
-    snprintf(ckname, sizeof(ckname), "pck_cmt-%d", unit);
-    qdev_connect_clock_in(DEVICE(cmt), "pck",
-                          qdev_get_clock_out(DEVICE(&s->cpg), ckname));
 }
 
 static void register_sci(RX62NState *s, int unit)
 {
     SysBusDevice *sci;
     int i, irqbase;
+    char ckname[16];
 
     object_initialize_child(OBJECT(s), "sci[*]",
-                            &s->sci[unit], TYPE_RENESAS_SCI);
+                            &s->sci[unit], TYPE_RENESAS_SCIA);
     sci = SYS_BUS_DEVICE(&s->sci[unit]);
     qdev_prop_set_chr(DEVICE(sci), "chardev", serial_hd(unit));
+    qdev_prop_set_uint32(DEVICE(sci), "unit", unit);
+    qdev_prop_set_uint32(DEVICE(sci), "register-size", SCI_REGSIZE_8);
+    snprintf(ckname, sizeof(ckname), "pck_sci-%d", unit);
+    qdev_connect_clock_in(DEVICE(sci), "pck",
+                          qdev_get_clock_out(DEVICE(&s->cpg), ckname));
     sysbus_realize(sci, &error_abort);
 
     irqbase = RX62N_SCI_IRQ + SCI_NR_IRQ * unit;
diff --git a/hw/rx/Kconfig b/hw/rx/Kconfig
index 2b297c5a6a..9cd1082623 100644
--- a/hw/rx/Kconfig
+++ b/hw/rx/Kconfig
@@ -1,8 +1,8 @@ 
 config RX62N_MCU
     bool
     select RX_ICU
-    select RENESAS_TMR
-    select RENESAS_CMT
+    select RENESAS_TMR8
+    select RENESAS_TIMER
     select RENESAS_SCI
 
 config RX_GDBSIM