aboutsummaryrefslogtreecommitdiff
path: root/hw/input/ps2.c
diff options
context:
space:
mode:
authorMark Cave-Ayland <mark.cave-ayland@ilande.co.uk>2022-06-24 14:40:49 +0100
committerMark Cave-Ayland <mark.cave-ayland@ilande.co.uk>2022-06-26 18:40:12 +0100
commit6beb79e11a48b7876dfd63fcfb51d1a603936928 (patch)
treebc065e72bc1d3265c960b205bbf84dd6d73dae49 /hw/input/ps2.c
parent5cb6e55622570cfc2284dfe4c95f64aee428e63c (diff)
ps2: add gpio for output IRQ and optionally use it in ps2_raise_irq() and ps2_lower_irq()
Define the gpio for the PS2 output IRQ in ps2_init() and add logic to optionally use it in ps2_raise_irq() and ps2_lower_irq() if the gpio is connected. If the gpio is not connected then call the legacy update_irq() function as before. This allows the incremental conversion of devices from the legacy update_irq() function to use gpios instead. Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Acked-by: Helge Deller <deller@gmx.de> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Message-Id: <20220624134109.881989-35-mark.cave-ayland@ilande.co.uk>
Diffstat (limited to 'hw/input/ps2.c')
-rw-r--r--hw/input/ps2.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/hw/input/ps2.c b/hw/input/ps2.c
index bc0bcf1789..98c6206fb8 100644
--- a/hw/input/ps2.c
+++ b/hw/input/ps2.c
@@ -24,6 +24,7 @@
#include "qemu/osdep.h"
#include "qemu/log.h"
+#include "hw/irq.h"
#include "hw/sysbus.h"
#include "hw/input/ps2.h"
#include "migration/vmstate.h"
@@ -174,12 +175,20 @@ void ps2_queue_noirq(PS2State *s, int b)
static void ps2_raise_irq(PS2State *s)
{
- s->update_irq(s->update_arg, 1);
+ if (qemu_irq_is_connected(s->irq)) {
+ qemu_set_irq(s->irq, 1);
+ } else {
+ s->update_irq(s->update_arg, 1);
+ }
}
static void ps2_lower_irq(PS2State *s)
{
- s->update_irq(s->update_arg, 0);
+ if (qemu_irq_is_connected(s->irq)) {
+ qemu_set_irq(s->irq, 0);
+ } else {
+ s->update_irq(s->update_arg, 0);
+ }
}
void ps2_queue(PS2State *s, int b)
@@ -1305,6 +1314,13 @@ static const TypeInfo ps2_mouse_info = {
.class_init = ps2_mouse_class_init
};
+static void ps2_init(Object *obj)
+{
+ PS2State *s = PS2_DEVICE(obj);
+
+ qdev_init_gpio_out(DEVICE(obj), &s->irq, 1);
+}
+
static void ps2_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
@@ -1316,6 +1332,7 @@ static void ps2_class_init(ObjectClass *klass, void *data)
static const TypeInfo ps2_info = {
.name = TYPE_PS2_DEVICE,
.parent = TYPE_SYS_BUS_DEVICE,
+ .instance_init = ps2_init,
.instance_size = sizeof(PS2State),
.class_init = ps2_class_init,
.class_size = sizeof(PS2DeviceClass),