xref: /openbmc/qemu/include/hw/input/lasips2.h (revision 2f95279a)
1 /*
2  * QEMU LASI PS/2 emulation
3  *
4  * Copyright (c) 2019 Sven Schnelle
5  *
6  */
7 
8 /*
9  * QEMU interface:
10  * + sysbus MMIO region 0: MemoryRegion defining the LASI PS2 keyboard
11  *   registers
12  * + sysbus MMIO region 1: MemoryRegion defining the LASI PS2 mouse
13  *   registers
14  * + sysbus IRQ 0: LASI PS2 output irq
15  * + Named GPIO input "lasips2-port-input-irq[0..1]": set to 1 if the downstream
16  *   LASIPS2Port has asserted its irq
17  */
18 
19 #ifndef HW_INPUT_LASIPS2_H
20 #define HW_INPUT_LASIPS2_H
21 
22 #include "exec/hwaddr.h"
23 #include "hw/sysbus.h"
24 #include "hw/input/ps2.h"
25 
26 #define TYPE_LASIPS2_PORT "lasips2-port"
27 OBJECT_DECLARE_TYPE(LASIPS2Port, LASIPS2PortDeviceClass, LASIPS2_PORT)
28 
29 struct LASIPS2PortDeviceClass {
30     DeviceClass parent;
31 
32     DeviceRealize parent_realize;
33 };
34 
35 typedef struct LASIPS2State LASIPS2State;
36 
37 struct LASIPS2Port {
38     DeviceState parent_obj;
39 
40     LASIPS2State *lasips2;
41     MemoryRegion reg;
42     PS2State *ps2dev;
43     uint8_t id;
44     uint8_t control;
45     uint8_t buf;
46     bool loopback_rbne;
47     qemu_irq irq;
48 };
49 
50 #define TYPE_LASIPS2_KBD_PORT "lasips2-kbd-port"
51 OBJECT_DECLARE_SIMPLE_TYPE(LASIPS2KbdPort, LASIPS2_KBD_PORT)
52 
53 struct LASIPS2KbdPort {
54     LASIPS2Port parent_obj;
55 
56     PS2KbdState kbd;
57 };
58 
59 #define TYPE_LASIPS2_MOUSE_PORT "lasips2-mouse-port"
60 OBJECT_DECLARE_SIMPLE_TYPE(LASIPS2MousePort, LASIPS2_MOUSE_PORT)
61 
62 struct LASIPS2MousePort {
63     LASIPS2Port parent_obj;
64 
65     PS2MouseState mouse;
66 };
67 
68 struct LASIPS2State {
69     SysBusDevice parent_obj;
70 
71     LASIPS2KbdPort kbd_port;
72     LASIPS2MousePort mouse_port;
73     uint8_t int_status;
74     qemu_irq irq;
75 };
76 
77 #define TYPE_LASIPS2 "lasips2"
78 OBJECT_DECLARE_SIMPLE_TYPE(LASIPS2State, LASIPS2)
79 
80 #endif /* HW_INPUT_LASIPS2_H */
81