From: Yoshinori Sato <ysato@users.sourceforge.jp>
To: qemu-devel@nongnu.org
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Subject: [PATCH 10/11] hw/sh4: sh7750 use new hw modules.
Date: Thu, 27 May 2021 14:21:21 +0900 [thread overview]
Message-ID: <20210527052122.97103-11-ysato@users.sourceforge.jp> (raw)
In-Reply-To: <20210527052122.97103-1-ysato@users.sourceforge.jp>
Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
---
include/hw/sh4/sh.h | 8 -----
hw/sh4/sh7750.c | 87 +++++++++++++++++++++++++++++++++++++++------
hw/sh4/Kconfig | 4 +--
3 files changed, 79 insertions(+), 20 deletions(-)
diff --git a/include/hw/sh4/sh.h b/include/hw/sh4/sh.h
index becb596979..74e1ba59a8 100644
--- a/include/hw/sh4/sh.h
+++ b/include/hw/sh4/sh.h
@@ -55,14 +55,6 @@ int sh7750_register_io_device(struct SH7750State *s,
/* sh_serial.c */
#define SH_SERIAL_FEAT_SCIF (1 << 0)
-void sh_serial_init(MemoryRegion *sysmem,
- hwaddr base, int feat,
- uint32_t freq, Chardev *chr,
- qemu_irq eri_source,
- qemu_irq rxi_source,
- qemu_irq txi_source,
- qemu_irq tei_source,
- qemu_irq bri_source);
/* sh7750.c */
qemu_irq sh7750_irl(struct SH7750State *s);
diff --git a/hw/sh4/sh7750.c b/hw/sh4/sh7750.c
index 2f6c382aa6..b2f6ebe936 100644
--- a/hw/sh4/sh7750.c
+++ b/hw/sh4/sh7750.c
@@ -31,9 +31,10 @@
#include "sh7750_regs.h"
#include "sh7750_regnames.h"
#include "hw/sh4/sh_intc.h"
-#include "hw/timer/tmu012.h"
+#include "hw/timer/renesas_timer.h"
#include "exec/exec-all.h"
#include "hw/sh4/sh7751-cpg.h"
+#include "hw/char/renesas_sci.h"
#include "hw/qdev-properties.h"
#define NB_DEVICES 4
@@ -774,6 +775,74 @@ static SH7751CPGBaseState *sh_cpg_init(MemoryRegion *sysmem,
return cpg;
}
+static void tmu012_init(MemoryRegion *sysmem, hwaddr base,
+ int unit,
+ qemu_irq ch0_irq, qemu_irq ch1_irq,
+ qemu_irq ch2_irq0, qemu_irq ch2_irq1,
+ SH7751CPGBaseState *cpg)
+{
+ RenesasTMUState *tmu;
+ char ckname[16];
+
+ tmu = RENESAS_TMU(qdev_new(TYPE_RENESAS_TMU));
+ qdev_prop_set_uint32(DEVICE(tmu), "unit", unit);
+ snprintf(ckname, sizeof(ckname), "pck_tmu-%d", unit);
+ qdev_connect_clock_in(DEVICE(tmu), "pck",
+ qdev_get_clock_out(DEVICE(cpg), "pck_tmu-0"));
+
+ sysbus_realize(SYS_BUS_DEVICE(tmu), &error_abort);
+ sysbus_connect_irq(SYS_BUS_DEVICE(tmu), 0, ch0_irq);
+ sysbus_connect_irq(SYS_BUS_DEVICE(tmu), 1, ch1_irq);
+ if (unit == 0) {
+ sysbus_connect_irq(SYS_BUS_DEVICE(tmu), 2, ch2_irq0);
+ }
+ /* ch2_irq1 is not used. */
+
+ sysbus_mmio_map(SYS_BUS_DEVICE(tmu), 0, base);
+ sysbus_mmio_map(SYS_BUS_DEVICE(tmu), 1, P4ADDR(base));
+ sysbus_mmio_map(SYS_BUS_DEVICE(tmu), 2, A7ADDR(base));
+}
+
+static void sh_serial_init(MemoryRegion *sysmem,
+ hwaddr base, int feat,
+ uint32_t freq, Chardev *chr,
+ qemu_irq eri_source,
+ qemu_irq rxi_source,
+ qemu_irq txi_source,
+ qemu_irq tei_source,
+ qemu_irq bri_source,
+ SH7751CPGBaseState *cpg)
+{
+ RenesasSCIBaseState *sci;
+ char ckname[16];
+
+ switch(feat) {
+ case 0: /* SCI */
+ sci = RENESAS_SCI_BASE(qdev_new(TYPE_RENESAS_SCI));
+ snprintf(ckname, sizeof(ckname), "pck_sci");
+ break;
+ case SH_SERIAL_FEAT_SCIF:
+ sci = RENESAS_SCI_BASE(qdev_new(TYPE_RENESAS_SCIF));
+ snprintf(ckname, sizeof(ckname), "pck_scif");
+ break;
+ }
+ qdev_prop_set_chr(DEVICE(sci), "chardev", chr);
+ qdev_prop_set_uint32(DEVICE(sci), "register-size", SCI_REGSIZE_32);
+ qdev_connect_clock_in(DEVICE(sci), "pck",
+ qdev_get_clock_out(DEVICE(cpg), ckname));
+ sysbus_connect_irq(SYS_BUS_DEVICE(sci), 0, eri_source);
+ sysbus_connect_irq(SYS_BUS_DEVICE(sci), 1, rxi_source);
+ sysbus_connect_irq(SYS_BUS_DEVICE(sci), 2, txi_source);
+ if (tei_source)
+ sysbus_connect_irq(SYS_BUS_DEVICE(sci), 3, tei_source);
+ if (bri_source)
+ sysbus_connect_irq(SYS_BUS_DEVICE(sci), 3, bri_source);
+ sysbus_realize(SYS_BUS_DEVICE(sci), &error_abort);
+ sysbus_mmio_map(SYS_BUS_DEVICE(sci), 0, base);
+ sysbus_mmio_map(SYS_BUS_DEVICE(sci), 1, P4ADDR(base));
+ sysbus_mmio_map(SYS_BUS_DEVICE(sci), 2, A7ADDR(base));
+}
+
SH7750State *sh7750_init(SuperHCPU *cpu, MemoryRegion *sysmem)
{
SH7750State *s;
@@ -830,7 +899,7 @@ SH7750State *sh7750_init(SuperHCPU *cpu, MemoryRegion *sysmem)
s->intc.irqs[SCI1_RXI],
s->intc.irqs[SCI1_TXI],
s->intc.irqs[SCI1_TEI],
- NULL);
+ NULL, cpg);
sh_serial_init(sysmem, 0x1fe80000,
SH_SERIAL_FEAT_SCIF,
s->periph_freq, serial_hd(1),
@@ -838,17 +907,14 @@ SH7750State *sh7750_init(SuperHCPU *cpu, MemoryRegion *sysmem)
s->intc.irqs[SCIF_RXI],
s->intc.irqs[SCIF_TXI],
NULL,
- s->intc.irqs[SCIF_BRI]);
+ s->intc.irqs[SCIF_BRI], cpg);
- tmu012_init(sysmem, 0x1fd80000,
- TMU012_FEAT_TOCR | TMU012_FEAT_3CHAN | TMU012_FEAT_EXTCLK,
- s->periph_freq,
+ tmu012_init(sysmem, 0x1fd80000, 0,
s->intc.irqs[TMU0],
s->intc.irqs[TMU1],
s->intc.irqs[TMU2_TUNI],
- s->intc.irqs[TMU2_TICPI]);
+ s->intc.irqs[TMU2_TICPI], cpg);
- sysbus_realize(SYS_BUS_DEVICE(cpg), &error_abort);
if (cpu->env.id & (SH_CPU_SH7750 | SH_CPU_SH7750S | SH_CPU_SH7751)) {
sh_intc_register_sources(&s->intc,
_INTC_ARRAY(vectors_dma4),
@@ -865,10 +931,10 @@ SH7750State *sh7750_init(SuperHCPU *cpu, MemoryRegion *sysmem)
sh_intc_register_sources(&s->intc,
_INTC_ARRAY(vectors_tmu34),
NULL, 0);
- tmu012_init(sysmem, 0x1e100000, 0, s->periph_freq,
+ tmu012_init(sysmem, 0x1e100000, 1,
s->intc.irqs[TMU3],
s->intc.irqs[TMU4],
- NULL, NULL);
+ NULL, NULL, cpg);
}
if (cpu->env.id & (SH_CPU_SH7751_ALL)) {
@@ -886,6 +952,7 @@ SH7750State *sh7750_init(SuperHCPU *cpu, MemoryRegion *sysmem)
sh_intc_register_sources(&s->intc,
_INTC_ARRAY(vectors_irl),
_INTC_ARRAY(groups_irl));
+ sysbus_realize(SYS_BUS_DEVICE(cpg), &error_abort);
return s;
}
diff --git a/hw/sh4/Kconfig b/hw/sh4/Kconfig
index ab733a3f76..b2da634d22 100644
--- a/hw/sh4/Kconfig
+++ b/hw/sh4/Kconfig
@@ -20,5 +20,5 @@ config SHIX
config SH7750
bool
select SH_INTC
- select SH_SCI
- select SH_TIMER
+ select RENESAS_TIMER
+ select RENESAS_SCI
--
2.20.1
next prev parent reply other threads:[~2021-05-27 5:26 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-27 5:21 [PATCH 00/11] Unified peripheral emulation for Renesas chips Yoshinori Sato
2021-05-27 5:21 ` [PATCH 01/11] hw/char: Renesas SCI module Yoshinori Sato
2021-06-04 9:09 ` Peter Maydell
2021-06-06 14:31 ` Yoshinori Sato
2021-06-06 14:36 ` Yoshinori Sato
2021-05-27 5:21 ` [PATCH 02/11] hw/char: remove sh_serial Yoshinori Sato
2021-06-04 10:08 ` Peter Maydell
2021-06-06 14:33 ` Yoshinori Sato
2021-06-06 14:33 ` Yoshinori Sato
2021-06-06 14:37 ` Yoshinori Sato
2021-05-27 5:21 ` [PATCH 03/11] hw/timer: Renesas TMU/CMT module Yoshinori Sato
2021-05-27 5:21 ` [PATCH 04/11] hw/timer: Remove sh_timer Yoshinori Sato
2021-05-27 5:21 ` [PATCH 05/11] hw/timer: Remove renesas_cmt Yoshinori Sato
2021-05-27 5:21 ` [PATCH 06/11] hw/rx: Add RX62N Clock generator Yoshinori Sato
2021-05-27 5:21 ` [PATCH 07/11] hw/timer: Renesas 8bit timer Yoshinori Sato
2021-06-04 10:12 ` Peter Maydell
2021-05-27 5:21 ` [PATCH 08/11] hw/rx: rx62n use new hw modules Yoshinori Sato
2021-05-27 5:21 ` [PATCH 09/11] hw/sh4: sh7750 Add CPG Yoshinori Sato
2021-05-27 5:21 ` Yoshinori Sato [this message]
2021-05-27 5:21 ` [PATCH 11/11] hw/rx: rx-gdbsim Add bootstrup for linux Yoshinori Sato
2021-05-27 5:33 ` [PATCH 00/11] Unified peripheral emulation for Renesas chips no-reply
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=20210527052122.97103-11-ysato@users.sourceforge.jp \
--to=ysato@users.sourceforge.jp \
--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).