summaryrefslogtreecommitdiff
path: root/include/hw/misc
diff options
context:
space:
mode:
authorMark Cave-Ayland <mark.cave-ayland@ilande.co.uk>2018-06-12 17:43:58 +0100
committerDavid Gibson <david@gibson.dropbear.id.au>2018-06-16 16:32:33 +1000
commit7c4166a971b54a65900d9624ccd9669ba99d75ad (patch)
treea3217491665ad013d2359e57ee0ac9a90e75aebd /include/hw/misc
parentf1114c17eeda907d0a290f25f970d695fc3b16de (diff)
downloadqemu-7c4166a971b54a65900d9624ccd9669ba99d75ad.zip
mac_newworld: add gpios to macio devices with PMU enabled
PMU-enabled New World Macs expose their GPIOs via a separate memory region within the macio device. Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'include/hw/misc')
-rw-r--r--include/hw/misc/macio/gpio.h47
-rw-r--r--include/hw/misc/macio/macio.h3
2 files changed, 50 insertions, 0 deletions
diff --git a/include/hw/misc/macio/gpio.h b/include/hw/misc/macio/gpio.h
new file mode 100644
index 0000000000..2838ae5fde
--- /dev/null
+++ b/include/hw/misc/macio/gpio.h
@@ -0,0 +1,47 @@
+/*
+ * PowerMac NewWorld MacIO GPIO emulation
+ *
+ * Copyright (c) 2016 Benjamin Herrenschmidt
+ * Copyright (c) 2018 Mark Cave-Ayland
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef MACIO_GPIO_H
+#define MACIO_GPIO_H
+
+#define TYPE_MACIO_GPIO "macio-gpio"
+#define MACIO_GPIO(obj) OBJECT_CHECK(MacIOGPIOState, (obj), TYPE_MACIO_GPIO)
+
+typedef struct MacIOGPIOState {
+ /*< private >*/
+ SysBusDevice parent;
+ /*< public >*/
+
+ OpenPICState *pic;
+
+ MemoryRegion gpiomem;
+ qemu_irq gpio_extirqs[10];
+ uint8_t gpio_levels[8];
+ uint8_t gpio_regs[36]; /* XXX Check count */
+} MacIOGPIOState;
+
+void macio_set_gpio(MacIOGPIOState *s, uint32_t gpio, bool state);
+
+#endif
diff --git a/include/hw/misc/macio/macio.h b/include/hw/misc/macio/macio.h
index 9529073ba8..d43883a893 100644
--- a/include/hw/misc/macio/macio.h
+++ b/include/hw/misc/macio/macio.h
@@ -26,8 +26,10 @@
#ifndef MACIO_H
#define MACIO_H
+#include "hw/char/escc.h"
#include "hw/intc/heathrow_pic.h"
#include "hw/misc/macio/cuda.h"
+#include "hw/misc/macio/gpio.h"
#include "hw/ppc/mac_dbdma.h"
#include "hw/ppc/openpic.h"
@@ -74,6 +76,7 @@ typedef struct NewWorldMacIOState {
bool has_adb;
OpenPICState *pic;
MACIOIDEState ide[2];
+ MacIOGPIOState gpio;
} NewWorldMacIOState;
#endif /* MACIO_H */