On 8/27/20 2:38 PM, Yoshinori Sato wrote:
This module generated core and peripheral clock.
Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
---
include/hw/rx/rx62n-cpg.h | 72 ++++++++
include/hw/rx/rx62n.h | 5 +-
hw/rx/rx62n-cpg.c | 344 ++++++++++++++++++++++++++++++++++++++
hw/rx/rx62n.c | 52 +++---
hw/rx/meson.build | 2 +-
5 files changed, 447 insertions(+), 28 deletions(-)
create mode 100644 include/hw/rx/rx62n-cpg.h
create mode 100644 hw/rx/rx62n-cpg.c
...
diff --git a/hw/rx/rx62n.c b/hw/rx/rx62n.c
index 4b5c3c1079..ec63fa5db1 100644
--- a/hw/rx/rx62n.c
+++ b/hw/rx/rx62n.c
@@ -47,6 +47,7 @@
#define RX62N_TMR_BASE 0x00088200
#define RX62N_CMT_BASE 0x00088000
#define RX62N_SCI_BASE 0x00088240
+#define RX62N_CPG_BASE 0x00080010
/*
* RX62N Peripheral IRQ
@@ -56,10 +57,6 @@
#define RX62N_CMT_IRQ 28
#define RX62N_SCI_IRQ 214
-#define RX62N_XTAL_MIN_HZ (8 * 1000 * 1000)
-#define RX62N_XTAL_MAX_HZ (14 * 1000 * 1000)
-#define RX62N_PCLK_MAX_HZ (50 * 1000 * 1000)
-
/*
* IRQ -> IPR mapping table
* 0x00 - 0x91: IPR no (IPR00 to IPR91)
@@ -149,36 +146,45 @@ static void register_tmr(RX62NState *s, int unit)
{
SysBusDevice *tmr;
int i, irqbase;
+ char ckname[16];
object_initialize_child(OBJECT(s), "tmr[*]",
&s->tmr[unit], TYPE_RENESAS_TMR);
tmr = SYS_BUS_DEVICE(&s->tmr[unit]);
- qdev_prop_set_uint64(DEVICE(tmr), "input-freq", s->pclk_freq_hz);
- sysbus_realize(tmr, &error_abort);
irqbase = RX62N_TMR_IRQ + TMR_NR_IRQ * unit;
for (i = 0; i < TMR_NR_IRQ; i++) {
sysbus_connect_irq(tmr, i, s->irq[irqbase + i]);
}
sysbus_mmio_map(tmr, 0, RX62N_TMR_BASE + unit * 0x10);
+
+ qdev_prop_set_uint32(DEVICE(tmr), "unit", unit);
Runtime failure:
qemu-system-rx: Property 'renesas-tmr.unit' not found
+ 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));
}
static void register_cmt(RX62NState *s, int unit)
{
SysBusDevice *cmt;
int i, irqbase;
+ char ckname[16];
object_initialize_child(OBJECT(s), "cmt[*]",
&s->cmt[unit], TYPE_RENESAS_CMT);
cmt = SYS_BUS_DEVICE(&s->cmt[unit]);
- qdev_prop_set_uint64(DEVICE(cmt), "input-freq", s->pclk_freq_hz);
- sysbus_realize(cmt, &error_abort);
+ qdev_prop_set_uint32(DEVICE(cmt), "unit", unit);
irqbase = RX62N_CMT_IRQ + CMT_NR_IRQ * unit;
for (i = 0; i < CMT_NR_IRQ; i++) {
sysbus_connect_irq(cmt, i, s->irq[irqbase + i]);
}
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));