[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 34/50] ps2: add gpio for output IRQ and optionally use it in ps2_
From: |
Mark Cave-Ayland |
Subject: |
[PATCH 34/50] ps2: add gpio for output IRQ and optionally use it in ps2_raise_irq() and ps2_lower_irq() |
Date: |
Sun, 22 May 2022 19:18:20 +0100 |
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>
---
hw/input/ps2.c | 21 +++++++++++++++++++--
include/hw/input/ps2.h | 4 ++++
2 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/hw/input/ps2.c b/hw/input/ps2.c
index 214dda60bf..891eb7181c 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 (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 (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,
.abstract = true
diff --git a/include/hw/input/ps2.h b/include/hw/input/ps2.h
index d04d291287..6e5c404cb5 100644
--- a/include/hw/input/ps2.h
+++ b/include/hw/input/ps2.h
@@ -50,11 +50,15 @@ typedef struct {
int rptr, wptr, cwptr, count;
} PS2Queue;
+/* Output IRQ */
+#define PS2_DEVICE_IRQ 0
+
struct PS2State {
SysBusDevice parent_obj;
PS2Queue queue;
int32_t write_cmd;
+ qemu_irq irq;
void (*update_irq)(void *, int);
void *update_arg;
};
--
2.20.1
- [PATCH 29/50] pckbd: more vmstate_register() from i8042_mm_init() to i8042_mmio_realize(), (continued)
- [PATCH 29/50] pckbd: more vmstate_register() from i8042_mm_init() to i8042_mmio_realize(), Mark Cave-Ayland, 2022/05/22
- [PATCH 31/50] ps2: make ps2_raise_irq() function static, Mark Cave-Ayland, 2022/05/22
- [PATCH 23/50] pckbd: add mask qdev property to I8042_MMIO device, Mark Cave-Ayland, 2022/05/22
- [PATCH 26/50] pckbd: implement i8042_mmio_init() function, Mark Cave-Ayland, 2022/05/22
- [PATCH 25/50] pckbd: implement i8042_mmio_realize() function, Mark Cave-Ayland, 2022/05/22
- [PATCH 35/50] pckbd: replace irq_kbd and irq_mouse with qemu_irq array in KBDState, Mark Cave-Ayland, 2022/05/22
- [PATCH 32/50] ps2: use ps2_raise_irq() instead of calling update_irq() directly, Mark Cave-Ayland, 2022/05/22
- [PATCH 27/50] pckbd: alter i8042_mm_init() to return a I8042_MMIO device, Mark Cave-Ayland, 2022/05/22
- [PATCH 28/50] pckbd: move mapping of I8042_MMIO registers to MIPS magnum machine, Mark Cave-Ayland, 2022/05/22
- [PATCH 33/50] ps2: introduce ps2_lower_irq() instead of calling update_irq() directly, Mark Cave-Ayland, 2022/05/22
- [PATCH 34/50] ps2: add gpio for output IRQ and optionally use it in ps2_raise_irq() and ps2_lower_irq(),
Mark Cave-Ayland <=
- [PATCH 37/50] lasips2: QOMify LASIPS2State, Mark Cave-Ayland, 2022/05/22
- [PATCH 39/50] lasips2: rename lasips2_init() to lasips2_initfn() and update it to return the LASIPS2 device, Mark Cave-Ayland, 2022/05/22
- [PATCH 30/50] pckbd: move ps2_kbd_init() and ps2_mouse_init() to i8042_mmio_realize(), Mark Cave-Ayland, 2022/05/22
- [PATCH 36/50] pl050: switch over from update_irq() function to PS2 device gpio, Mark Cave-Ayland, 2022/05/22
- [PATCH 38/50] lasips2: move lasips2 QOM types from lasips2.c to lasips2.h, Mark Cave-Ayland, 2022/05/22
- [PATCH 41/50] lasips2: move mapping of LASIPS2 registers to HPPA machine, Mark Cave-Ayland, 2022/05/22
- [PATCH 40/50] lasips2: implement lasips2_init() function, Mark Cave-Ayland, 2022/05/22
- [PATCH 42/50] lasips2: move initialisation of PS2 ports from lasi_initfn() to lasi_init(), Mark Cave-Ayland, 2022/05/22
- [PATCH 43/50] lasips2: add base property, Mark Cave-Ayland, 2022/05/22
- [PATCH 48/50] pckbd: add i8042_reset() function to I8042 device, Mark Cave-Ayland, 2022/05/22