aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hw/irq.c11
-rw-r--r--hw/irq.h2
-rw-r--r--hw/palm.c24
3 files changed, 18 insertions, 19 deletions
diff --git a/hw/irq.c b/hw/irq.c
index e46ee603c4..bb30ced11b 100644
--- a/hw/irq.c
+++ b/hw/irq.c
@@ -55,3 +55,14 @@ qemu_irq *qemu_allocate_irqs(qemu_irq_handler handler, void *opaque, int n)
return s;
}
+static void qemu_notirq(void *opaque, int line, int level)
+{
+ struct IRQState *irq = opaque;
+
+ irq->handler(irq->opaque, irq->n, !level);
+}
+
+qemu_irq qemu_irq_invert(qemu_irq irq)
+{
+ return qemu_allocate_irqs(qemu_notirq, irq, 1)[0];
+}
diff --git a/hw/irq.h b/hw/irq.h
index 652fd6abeb..2d1a3548b0 100644
--- a/hw/irq.h
+++ b/hw/irq.h
@@ -19,3 +19,5 @@ static inline void qemu_irq_lower(qemu_irq irq)
/* Returns an array of N IRQs. */
qemu_irq *qemu_allocate_irqs(qemu_irq_handler handler, void *opaque, int n);
+/* Returns a new IRQ with opposite polarity. */
+qemu_irq qemu_irq_invert(qemu_irq irq);
diff --git a/hw/palm.c b/hw/palm.c
index 0966413749..a6c9f7d97a 100644
--- a/hw/palm.c
+++ b/hw/palm.c
@@ -76,20 +76,13 @@ static CPUWriteMemoryFunc *static_writefn[] = {
#define PALMTE_MMC2_GPIO 7
#define PALMTE_MMC3_GPIO 11
-static void palmte_pintdav(void *opaque, int line, int level)
-{
- struct omap_mpu_state_s *cpu = (struct omap_mpu_state_s *) opaque;
-
- qemu_set_irq(omap_gpio_in_get(cpu->gpio)[PALMTE_PINTDAV_GPIO],
- !level);
-}
-
static void palmte_microwire_setup(struct omap_mpu_state_s *cpu)
{
+ qemu_irq p_int = omap_gpio_in_get(cpu->gpio)[PALMTE_PINTDAV_GPIO];
+
omap_uwire_attach(
cpu->microwire,
- tsc2102_init(
- qemu_allocate_irqs(palmte_pintdav, cpu, 1)[0]),
+ tsc2102_init(qemu_irq_invert(p_int)),
0);
}
@@ -122,14 +115,6 @@ static void palmte_button_event(void *opaque, int keycode)
!(keycode & 0x80));
}
-static void palmte_mmc_cover(void *opaque, int line, int level)
-{
- struct omap_mpu_state_s *cpu = (struct omap_mpu_state_s *) opaque;
-
- qemu_set_irq(omap_mpuio_in_get(cpu->mpuio)[PALMTE_MMC_SWITCH_GPIO],
- !level);
-}
-
static void palmte_init(int ram_size, int vga_ram_size, int boot_device,
DisplayState *ds, const char **fd_filename, int snapshot,
const char *kernel_filename, const char *kernel_cmdline,
@@ -174,7 +159,8 @@ static void palmte_init(int ram_size, int vga_ram_size, int boot_device,
omap_mmc_handlers(cpu->mmc,
omap_gpio_in_get(cpu->gpio)[PALMTE_MMC_WP_GPIO],
- qemu_allocate_irqs(palmte_mmc_cover, cpu, 1)[0]);
+ qemu_irq_invert(omap_mpuio_in_get(cpu->mpuio)
+ [PALMTE_MMC_SWITCH_GPIO]));
/* Setup initial (reset) machine state */
if (nb_option_roms) {