[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 27/33] next-cube: move rtc-data-in gpio from next-pc to next-r
From: |
Mark Cave-Ayland |
Subject: |
[PATCH v3 27/33] next-cube: move rtc-data-in gpio from next-pc to next-rtc device |
Date: |
Sun, 22 Dec 2024 13:00:06 +0000 |
Add a new rtc-data-out gpio to the next-pc device and wire it up to the next-rtc
rtc-data-in gpio using the standard qdev gpio APIs.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: Thomas Huth <huth@tuxfamily.org>
---
hw/m68k/next-cube.c | 26 +++++++++++++++++---------
1 file changed, 17 insertions(+), 9 deletions(-)
diff --git a/hw/m68k/next-cube.c b/hw/m68k/next-cube.c
index a279754643..83154a3661 100644
--- a/hw/m68k/next-cube.c
+++ b/hw/m68k/next-cube.c
@@ -105,6 +105,7 @@ struct NeXTPC {
NeXTRTC rtc;
qemu_irq rtc_power_irq;
+ qemu_irq rtc_data_irq;
};
typedef struct next_dma {
@@ -179,8 +180,8 @@ static bool next_rtc_cmd_is_write(uint8_t cmd)
static void next_rtc_data_in_irq(void *opaque, int n, int level)
{
- NeXTPC *s = NEXT_PC(opaque);
- NeXTRTC *rtc = &s->rtc;
+ NeXTRTC *rtc = NEXT_RTC(opaque);
+ NeXTPC *s = NEXT_PC(container_of(rtc, NeXTPC, rtc));
if (rtc->phase < 8) {
rtc->command = (rtc->command << 1) | level;
@@ -274,13 +275,10 @@ static void next_scr2_rtc_update(NeXTPC *s)
/* If we are in going down clock... do something */
if (((old_scr2 & SCR2_RTCLK) != (scr2_2 & SCR2_RTCLK)) &&
((scr2_2 & SCR2_RTCLK) == 0)) {
- qemu_irq rtc_data_in_irq = qdev_get_gpio_in_named(
- DEVICE(s), "rtc-data-in", 0);
-
if (scr2_2 & SCR2_RTDATA) {
- qemu_irq_raise(rtc_data_in_irq);
+ qemu_irq_raise(s->rtc_data_irq);
} else {
- qemu_irq_lower(rtc_data_in_irq);
+ qemu_irq_lower(s->rtc_data_irq);
}
}
} else {
@@ -1028,6 +1026,12 @@ static void next_rtc_reset_hold(Object *obj, ResetType
type)
memcpy(rtc->ram, rtc_ram2, 32);
}
+static void next_rtc_init(Object *obj)
+{
+ qdev_init_gpio_in_named(DEVICE(obj), next_rtc_data_in_irq,
+ "rtc-data-in", 1);
+}
+
static const VMStateDescription next_rtc_vmstate = {
.name = "next-rtc",
.version_id = 3,
@@ -1057,6 +1061,7 @@ static void next_rtc_class_init(ObjectClass *klass, void
*data)
static const TypeInfo next_rtc_info = {
.name = TYPE_NEXT_RTC,
.parent = TYPE_SYS_BUS_DEVICE,
+ .instance_init = next_rtc_init,
.instance_size = sizeof(NeXTRTC),
.class_init = next_rtc_class_init,
};
@@ -1128,6 +1133,9 @@ static void next_pc_realize(DeviceState *dev, Error
**errp)
if (!sysbus_realize(SYS_BUS_DEVICE(d), errp)) {
return;
}
+ /* Data from NeXTPC to RTC */
+ qdev_connect_gpio_out_named(dev, "rtc-data-out", 0,
+ qdev_get_gpio_in_named(d, "rtc-data-in", 0));
}
static void next_pc_init(Object *obj)
@@ -1166,8 +1174,8 @@ static void next_pc_init(Object *obj)
s->rtc_power_irq = qdev_get_gpio_in(DEVICE(obj), NEXT_PWR_I);
qdev_init_gpio_in_named(DEVICE(obj), next_pc_rtc_data_in_irq,
"pc-rtc-data-in", 1);
- qdev_init_gpio_in_named(DEVICE(obj), next_rtc_data_in_irq,
- "rtc-data-in", 1);
+ qdev_init_gpio_out_named(DEVICE(obj), &s->rtc_data_irq,
+ "rtc-data-out", 1);
}
/*
--
2.39.5
- [PATCH v3 22/33] next-cube: use named gpio to set RTC data bit in scr2, (continued)
- [PATCH v3 22/33] next-cube: use named gpio to set RTC data bit in scr2, Mark Cave-Ayland, 2024/12/22
- [PATCH v3 29/33] next-cube: add rtc-cmd-reset named gpio to reset the rtc state machine, Mark Cave-Ayland, 2024/12/22
- [PATCH v3 32/33] next-cube: rename old_scr2 and scr2_2 in next_scr2_rtc_update(), Mark Cave-Ayland, 2024/12/22
- [PATCH v3 19/33] next-cube: use qemu_irq to drive int_status in next_scr2_rtc_update(), Mark Cave-Ayland, 2024/12/22
- [PATCH v3 30/33] next-cube: add rtc-power-out named gpio to trigger the NEXT_PWR_I interrupt, Mark Cave-Ayland, 2024/12/22
- [PATCH v3 10/33] next-cube: map ESCC registers as a subregion of the next.scr memory region, Mark Cave-Ayland, 2024/12/22
- [PATCH v3 09/33] next-cube: move floppy disk MMIO to separate memory region in next-pc, Mark Cave-Ayland, 2024/12/22
- [PATCH v3 16/33] next-cube: rearrange NeXTState declarations to improve readability, Mark Cave-Ayland, 2024/12/22
- [PATCH v3 23/33] next-cube: use named gpio to read RTC data bit in scr2, Mark Cave-Ayland, 2024/12/22
- [PATCH v3 24/33] next-cube: don't use rtc phase value of -1, Mark Cave-Ayland, 2024/12/22
- [PATCH v3 27/33] next-cube: move rtc-data-in gpio from next-pc to next-rtc device,
Mark Cave-Ayland <=
- [PATCH v3 28/33] next-cube: use named gpio output for next-rtc data, Mark Cave-Ayland, 2024/12/22
- [PATCH v3 31/33] next-cube: move next_rtc_cmd_is_write() and next_rtc_data_in_irq() functions, Mark Cave-Ayland, 2024/12/22
- [PATCH v3 25/33] next-cube: QOMify NeXTRTC, Mark Cave-Ayland, 2024/12/22
- [PATCH v3 33/33] next-cube: add my copyright to the top of the file, Mark Cave-Ayland, 2024/12/22
- [PATCH v3 07/33] next-cube: move SCSI CSRs from next-pc to the next-scsi device, Mark Cave-Ayland, 2024/12/22
- [PATCH v3 18/33] next-cube: rename typedef struct NextRtc to NeXTRTC, Mark Cave-Ayland, 2024/12/22
- [PATCH v3 21/33] next-cube: always use retval to return rtc read values, Mark Cave-Ayland, 2024/12/22
- [PATCH v3 26/33] next-cube: move reset of next-rtc fields from next-pc to next-rtc, Mark Cave-Ayland, 2024/12/22
- Re: [PATCH v3 00/33] next-cube: more tidy-ups and improvements, Thomas Huth, 2024/12/29