diff mbox series

[32/36] next-cube: add rtc-power-out named gpio to reset the rtc state machine

Message ID 20241023085852.1061031-33-mark.cave-ayland@ilande.co.uk (mailing list archive)
State New
Headers show
Series next-cube: more tidy-ups and improvements | expand

Commit Message

Mark Cave-Ayland Oct. 23, 2024, 8:58 a.m. UTC
This allows us to decouple the next-pc and next-rtc devices from each
other in next_rtc_data_in_irq().

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/m68k/next-cube.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Comments

Mark Cave-Ayland Oct. 24, 2024, 8:45 a.m. UTC | #1
On 23/10/2024 09:58, Mark Cave-Ayland wrote:

> This allows us to decouple the next-pc and next-rtc devices from each
> other in next_rtc_data_in_irq().
> 
> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> ---
>   hw/m68k/next-cube.c | 10 ++++++----
>   1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/m68k/next-cube.c b/hw/m68k/next-cube.c
> index 16b16e9956..0a8b899515 100644
> --- a/hw/m68k/next-cube.c
> +++ b/hw/m68k/next-cube.c
> @@ -58,6 +58,7 @@ struct NeXTRTC {
>       uint8_t retval;
>   
>       qemu_irq data_out_irq;
> +    qemu_irq power_irq;
>   };
>   
>   #define TYPE_NEXT_SCSI "next-scsi"
> @@ -106,7 +107,6 @@ struct NeXTPC {
>       ESCCState escc;
>   
>       NeXTRTC rtc;
> -    qemu_irq rtc_power_irq;
>       qemu_irq rtc_data_irq;
>       qemu_irq rtc_cmd_reset_irq;
>   };
> @@ -184,7 +184,6 @@ static bool next_rtc_cmd_is_write(uint8_t cmd)
>   static void next_rtc_data_in_irq(void *opaque, int n, int level)
>   {
>       NeXTRTC *rtc = NEXT_RTC(opaque);
> -    NeXTPC *s = NEXT_PC(container_of(rtc, NeXTPC, rtc));
>   
>       if (rtc->phase < 8) {
>           rtc->command = (rtc->command << 1) | level;
> @@ -256,7 +255,7 @@ static void next_rtc_data_in_irq(void *opaque, int n, int level)
>               if (rtc->value & 0x04) {
>                   /* clear FTU */
>                   rtc->status = rtc->status & (~0x18);
> -                qemu_irq_lower(s->rtc_power_irq);
> +                qemu_irq_lower(rtc->power_irq);
>               }
>           }
>       }
> @@ -1044,6 +1043,8 @@ static void next_rtc_init(Object *obj)
>                                "rtc-data-out", 1);
>       qdev_init_gpio_in_named(DEVICE(obj), next_rtc_cmd_reset_irq,
>                               "rtc-cmd-reset", 1);
> +    qdev_init_gpio_out_named(DEVICE(obj), &rtc->power_irq,
> +                             "rtc-power-out", 1);
>   }
>   
>   static const VMStateDescription next_rtc_vmstate = {
> @@ -1156,6 +1157,8 @@ static void next_pc_realize(DeviceState *dev, Error **errp)
>                                                          "rtc-data-in", 0));
>       qdev_connect_gpio_out_named(dev, "rtc-cmd-reset", 0,
>                                   qdev_get_gpio_in_named(d, "rtc-cmd-reset", 0));
> +    qdev_connect_gpio_out_named(d, "rtc-power-out", 0,
> +                                qdev_get_gpio_in(dev, NEXT_PWR_I));
>   }
>   
>   static void next_pc_init(Object *obj)
> @@ -1191,7 +1194,6 @@ static void next_pc_init(Object *obj)
>   
>       object_initialize_child(obj, "rtc", &s->rtc, TYPE_NEXT_RTC);
>   
> -    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,
>                               "rtc-data-in", 1);
>       qdev_init_gpio_out_named(DEVICE(obj), &s->rtc_data_irq,

(replying to myself)

I've just noticed the headline summary is wrong and should instead read: "next-cube: 
add rtc-power-out named gpio to trigger the NEXT_PWR_I interrupt".


ATB,

Mark.
diff mbox series

Patch

diff --git a/hw/m68k/next-cube.c b/hw/m68k/next-cube.c
index 16b16e9956..0a8b899515 100644
--- a/hw/m68k/next-cube.c
+++ b/hw/m68k/next-cube.c
@@ -58,6 +58,7 @@  struct NeXTRTC {
     uint8_t retval;
 
     qemu_irq data_out_irq;
+    qemu_irq power_irq;
 };
 
 #define TYPE_NEXT_SCSI "next-scsi"
@@ -106,7 +107,6 @@  struct NeXTPC {
     ESCCState escc;
 
     NeXTRTC rtc;
-    qemu_irq rtc_power_irq;
     qemu_irq rtc_data_irq;
     qemu_irq rtc_cmd_reset_irq;
 };
@@ -184,7 +184,6 @@  static bool next_rtc_cmd_is_write(uint8_t cmd)
 static void next_rtc_data_in_irq(void *opaque, int n, int level)
 {
     NeXTRTC *rtc = NEXT_RTC(opaque);
-    NeXTPC *s = NEXT_PC(container_of(rtc, NeXTPC, rtc));
 
     if (rtc->phase < 8) {
         rtc->command = (rtc->command << 1) | level;
@@ -256,7 +255,7 @@  static void next_rtc_data_in_irq(void *opaque, int n, int level)
             if (rtc->value & 0x04) {
                 /* clear FTU */
                 rtc->status = rtc->status & (~0x18);
-                qemu_irq_lower(s->rtc_power_irq);
+                qemu_irq_lower(rtc->power_irq);
             }
         }
     }
@@ -1044,6 +1043,8 @@  static void next_rtc_init(Object *obj)
                              "rtc-data-out", 1);
     qdev_init_gpio_in_named(DEVICE(obj), next_rtc_cmd_reset_irq,
                             "rtc-cmd-reset", 1);
+    qdev_init_gpio_out_named(DEVICE(obj), &rtc->power_irq,
+                             "rtc-power-out", 1);
 }
 
 static const VMStateDescription next_rtc_vmstate = {
@@ -1156,6 +1157,8 @@  static void next_pc_realize(DeviceState *dev, Error **errp)
                                                        "rtc-data-in", 0));
     qdev_connect_gpio_out_named(dev, "rtc-cmd-reset", 0,
                                 qdev_get_gpio_in_named(d, "rtc-cmd-reset", 0));
+    qdev_connect_gpio_out_named(d, "rtc-power-out", 0,
+                                qdev_get_gpio_in(dev, NEXT_PWR_I));
 }
 
 static void next_pc_init(Object *obj)
@@ -1191,7 +1194,6 @@  static void next_pc_init(Object *obj)
 
     object_initialize_child(obj, "rtc", &s->rtc, TYPE_NEXT_RTC);
 
-    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,
                             "rtc-data-in", 1);
     qdev_init_gpio_out_named(DEVICE(obj), &s->rtc_data_irq,