All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 1/2] hw/arm/spitz: Fix reset handling
@ 2016-10-27 19:47 Guenter Roeck
  2016-10-27 19:47 ` [Qemu-devel] [PATCH 2/2] hw/arm/tosa: " Guenter Roeck
  2016-10-28 12:25 ` [Qemu-devel] [PATCH 1/2] hw/arm/spitz: " Peter Maydell
  0 siblings, 2 replies; 3+ messages in thread
From: Guenter Roeck @ 2016-10-27 19:47 UTC (permalink / raw)
  To: Andrzej Zaborowski; +Cc: Peter Maydell, qemu-arm, qemu-devel, Guenter Roeck

Using the CPU reset handler for resets triggered by writing into
gpio pins other than GPIO01 is not appropriate and does not work,
since the reset triggered by writing into GPIO01 is configurable.
Use a separate reset handler for spitz to reset the entire system
and not just the CPU.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 hw/arm/spitz.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/hw/arm/spitz.c b/hw/arm/spitz.c
index 41cc2ee..949a15a 100644
--- a/hw/arm/spitz.c
+++ b/hw/arm/spitz.c
@@ -29,6 +29,7 @@
 #include "sysemu/block-backend.h"
 #include "hw/sysbus.h"
 #include "exec/address-spaces.h"
+#include "sysemu/sysemu.h"
 
 #undef REG_FMT
 #define REG_FMT			"0x%02lx"
@@ -844,9 +845,18 @@ static void spitz_lcd_hsync_handler(void *opaque, int line, int level)
     spitz_hsync ^= 1;
 }
 
+static void spitz_reset(void *opaque, int line, int level)
+{
+    if (level) {
+        qemu_system_reset_request();
+    }
+}
+
 static void spitz_gpio_setup(PXA2xxState *cpu, int slots)
 {
     qemu_irq lcd_hsync;
+    qemu_irq reset;
+
     /*
      * Bad hack: We toggle the LCD hsync GPIO on every GPIO status
      * read to satisfy broken guests that poll-wait for hsync.
@@ -867,7 +877,8 @@ static void spitz_gpio_setup(PXA2xxState *cpu, int slots)
     qemu_irq_raise(qdev_get_gpio_in(cpu->gpio, SPITZ_GPIO_BAT_COVER));
 
     /* Handle reset */
-    qdev_connect_gpio_out(cpu->gpio, SPITZ_GPIO_ON_RESET, cpu->reset);
+    reset = qemu_allocate_irq(spitz_reset, cpu, 0);
+    qdev_connect_gpio_out(cpu->gpio, SPITZ_GPIO_ON_RESET, reset);
 
     /* PCMCIA signals: card's IRQ and Card-Detect */
     if (slots >= 1)
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [Qemu-devel] [PATCH 2/2] hw/arm/tosa: Fix reset handling
  2016-10-27 19:47 [Qemu-devel] [PATCH 1/2] hw/arm/spitz: Fix reset handling Guenter Roeck
@ 2016-10-27 19:47 ` Guenter Roeck
  2016-10-28 12:25 ` [Qemu-devel] [PATCH 1/2] hw/arm/spitz: " Peter Maydell
  1 sibling, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2016-10-27 19:47 UTC (permalink / raw)
  To: Andrzej Zaborowski; +Cc: Peter Maydell, qemu-arm, qemu-devel, Guenter Roeck

Using the CPU reset handler for resets triggered by writing into
gpio pins other than GPIO01 is not appropriate and does not work,
since the reset triggered by writing into GPIO01 is configurable.
Use a separate reset handler for tosa to reset the entire system
and not just the CPU.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 hw/arm/tosa.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/hw/arm/tosa.c b/hw/arm/tosa.c
index 2db6650..1ee12f4 100644
--- a/hw/arm/tosa.c
+++ b/hw/arm/tosa.c
@@ -25,6 +25,7 @@
 #include "sysemu/block-backend.h"
 #include "hw/sysbus.h"
 #include "exec/address-spaces.h"
+#include "sysemu/sysemu.h"
 
 #define TOSA_RAM    0x04000000
 #define TOSA_ROM	0x00800000
@@ -86,6 +87,12 @@ static void tosa_out_switch(void *opaque, int line, int level)
     }
 }
 
+static void tosa_reset(void *opaque, int line, int level)
+{
+    if (level) {
+        qemu_system_reset_request();
+    }
+}
 
 static void tosa_gpio_setup(PXA2xxState *cpu,
                 DeviceState *scp0,
@@ -93,13 +100,16 @@ static void tosa_gpio_setup(PXA2xxState *cpu,
                 TC6393xbState *tmio)
 {
     qemu_irq *outsignals = qemu_allocate_irqs(tosa_out_switch, cpu, 4);
+    qemu_irq reset;
+
     /* MMC/SD host */
     pxa2xx_mmci_handlers(cpu->mmc,
                     qdev_get_gpio_in(scp0, TOSA_GPIO_SD_WP),
                     qemu_irq_invert(qdev_get_gpio_in(cpu->gpio, TOSA_GPIO_nSD_DETECT)));
 
     /* Handle reset */
-    qdev_connect_gpio_out(cpu->gpio, TOSA_GPIO_ON_RESET, cpu->reset);
+    reset = qemu_allocate_irq(tosa_reset, cpu, 0);
+    qdev_connect_gpio_out(cpu->gpio, TOSA_GPIO_ON_RESET, reset);
 
     /* PCMCIA signals: card's IRQ and Card-Detect */
     pxa2xx_pcmcia_set_irq_cb(cpu->pcmcia[0],
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH 1/2] hw/arm/spitz: Fix reset handling
  2016-10-27 19:47 [Qemu-devel] [PATCH 1/2] hw/arm/spitz: Fix reset handling Guenter Roeck
  2016-10-27 19:47 ` [Qemu-devel] [PATCH 2/2] hw/arm/tosa: " Guenter Roeck
@ 2016-10-28 12:25 ` Peter Maydell
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Maydell @ 2016-10-28 12:25 UTC (permalink / raw)
  To: Guenter Roeck; +Cc: Andrzej Zaborowski, qemu-arm, QEMU Developers

On 27 October 2016 at 20:47, Guenter Roeck <linux@roeck-us.net> wrote:
> Using the CPU reset handler for resets triggered by writing into
> gpio pins other than GPIO01 is not appropriate and does not work,
> since the reset triggered by writing into GPIO01 is configurable.
> Use a separate reset handler for spitz to reset the entire system
> and not just the CPU.
>
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>

Thanks; I've applied this and 2/2 to target-arm.next.

-- PMM

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-10-28 12:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-27 19:47 [Qemu-devel] [PATCH 1/2] hw/arm/spitz: Fix reset handling Guenter Roeck
2016-10-27 19:47 ` [Qemu-devel] [PATCH 2/2] hw/arm/tosa: " Guenter Roeck
2016-10-28 12:25 ` [Qemu-devel] [PATCH 1/2] hw/arm/spitz: " Peter Maydell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.