Patchwork nseries: attach monitor powerdown request to menelaus

login
register
mail settings
Submitter Paolo Bonzini
Date Jan. 20, 2012, 11:10 a.m.
Message ID <1327057834-6778-1-git-send-email-pbonzini@redhat.com>
Download mbox | patch
Permalink /patch/137005/
State New
Headers show

Comments

Paolo Bonzini - Jan. 20, 2012, 11:10 a.m.
I noticed some unused code in the twl92230, probably from before
qdev-ification.  This patch makes the machine use the chip's pwrbtn
signal.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/nseries.c  |    2 ++
 hw/twl92230.c |   21 +++++++++------------
 2 files changed, 11 insertions(+), 12 deletions(-)
andrzej zaborowski - Feb. 17, 2012, 6:57 a.m.
On 20 January 2012 12:10, Paolo Bonzini <pbonzini@redhat.com> wrote:
> I noticed some unused code in the twl92230, probably from before
> qdev-ification.  This patch makes the machine use the chip's pwrbtn
> signal.

Thanks, applied this patch.

Cheers

Patch

diff --git a/hw/nseries.c b/hw/nseries.c
index d429dbd..c5b3184 100644
--- a/hw/nseries.c
+++ b/hw/nseries.c
@@ -204,6 +204,8 @@  static void n8x0_i2c_setup(struct n800_s *s)
                           qdev_get_gpio_in(s->cpu->ih[0],
                                            OMAP_INT_24XX_SYS_NIRQ));
 
+    qemu_system_powerdown = qdev_get_gpio_in(dev, 3);
+
     /* Attach a TMP105 PM chip (A0 wired to ground) */
     dev = i2c_create_slave(s->i2c, "tmp105", N8X0_TMP105_ADDR);
     qdev_connect_gpio_out(dev, 0, tmp_irq);
diff --git a/hw/twl92230.c b/hw/twl92230.c
index a75448f..6416752 100644
--- a/hw/twl92230.c
+++ b/hw/twl92230.c
@@ -61,9 +61,7 @@  typedef struct {
     } rtc;
     uint16_t rtc_next_vmstate;
     qemu_irq out[4];
-    qemu_irq *in;
     uint8_t pwrbtn_state;
-    qemu_irq pwrbtn;
 } MenelausState;
 
 static inline void menelaus_update(MenelausState *s)
@@ -186,14 +184,12 @@  static void menelaus_gpio_set(void *opaque, int line, int level)
 {
     MenelausState *s = (MenelausState *) opaque;
 
-    /* No interrupt generated */
-    s->inputs &= ~(1 << line);
-    s->inputs |= level << line;
-}
-
-static void menelaus_pwrbtn_set(void *opaque, int line, int level)
-{
-    MenelausState *s = (MenelausState *) opaque;
+    if (line < 3) {
+        /* No interrupt generated */
+        s->inputs &= ~(1 << line);
+        s->inputs |= level << line;
+        return;
+    }
 
     if (!s->pwrbtn_state && level) {
         s->status |= 1 << 11;					/* PSHBTN */
@@ -849,8 +845,9 @@  static int twl92230_init(i2c_slave *i2c)
     s->rtc.hz_tm = qemu_new_timer_ms(rt_clock, menelaus_rtc_hz, s);
     /* Three output pins plus one interrupt pin.  */
     qdev_init_gpio_out(&i2c->qdev, s->out, 4);
-    qdev_init_gpio_in(&i2c->qdev, menelaus_gpio_set, 3);
-    s->pwrbtn = qemu_allocate_irqs(menelaus_pwrbtn_set, s, 1)[0];
+
+    /* Three input pins plus one power-button pin.  */
+    qdev_init_gpio_in(&i2c->qdev, menelaus_gpio_set, 4);
 
     menelaus_reset(&s->i2c);