qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Liu Yu <yu.liu@freescale.com>
To: qemu-devel@nongnu.org, aurelien@aurel32.net, hollisb@us.ibm.com
Cc: Liu Yu <yu.liu@freescale.com>, kvm-ppc@vger.kernel.org
Subject: [Qemu-devel] [PATCH 3/5] kvm/powerpc: Add irq support for E500 core
Date: Tue, 17 Feb 2009 17:59:36 +0800	[thread overview]
Message-ID: <1234864778-19099-4-git-send-email-yu.liu@freescale.com> (raw)
In-Reply-To: <1234864778-19099-3-git-send-email-yu.liu@freescale.com>


Signed-off-by: Liu Yu <yu.liu@freescale.com>
---
 hw/ppc.c                    |   60 +++++++++++++++++++++++++++++++++++++++++++
 hw/ppc.h                    |    1 +
 target-ppc/cpu.h            |   10 +++++++
 target-ppc/translate_init.c |    5 ++-
 4 files changed, 74 insertions(+), 2 deletions(-)

diff --git a/hw/ppc.c b/hw/ppc.c
index 9a01c01..b534e39 100644
--- a/hw/ppc.c
+++ b/hw/ppc.c
@@ -314,6 +314,66 @@ void ppc40x_irq_init (CPUState *env)
                                                   env, PPC40x_INPUT_NB);
 }
 
+/* PowerPC E500 internal IRQ controller */
+static void ppce500_set_irq (void *opaque, int pin, int level)
+{
+    CPUState *env = opaque;
+    int cur_level;
+
+    LOG_IRQ("%s: env %p pin %d level %d\n", __func__,
+                env, pin, level);
+    cur_level = (env->irq_input_state >> pin) & 1;
+    /* Don't generate spurious events */
+    if ((cur_level == 1 && level == 0) || (cur_level == 0 && level != 0)) {
+        switch (pin) {
+        case PPCE500_INPUT_MCK:
+            if (level) {
+                LOG_IRQ("%s: reset the PowerPC system\n",
+                            __func__);
+                qemu_system_reset_request();
+            }
+            break;
+        case PPCE500_INPUT_RESET_CORE:
+            if (level) {
+                LOG_IRQ("%s: reset the PowerPC core\n", __func__);
+                ppc_set_irq(env, PPC_INTERRUPT_MCK, level);
+            }
+            break;
+        case PPCE500_INPUT_CINT:
+            /* Level sensitive - active high */
+            LOG_IRQ("%s: set the critical IRQ state to %d\n",
+                        __func__, level);
+            ppc_set_irq(env, PPC_INTERRUPT_CEXT, level);
+            break;
+        case PPCE500_INPUT_INT:
+            /* Level sensitive - active high */
+            LOG_IRQ("%s: set the core IRQ state to %d\n",
+                        __func__, level);
+            ppc_set_irq(env, PPC_INTERRUPT_EXT, level);
+            break;
+        case PPCE500_INPUT_DEBUG:
+            /* Level sensitive - active high */
+            LOG_IRQ("%s: set the debug pin state to %d\n",
+                        __func__, level);
+            ppc_set_irq(env, PPC_INTERRUPT_DEBUG, level);
+            break;
+        default:
+            /* Unknown pin - do nothing */
+            LOG_IRQ("%s: unknown IRQ pin %d\n", __func__, pin);
+            return;
+        }
+        if (level)
+            env->irq_input_state |= 1 << pin;
+        else
+            env->irq_input_state &= ~(1 << pin);
+    }
+}
+
+void ppce500_irq_init (CPUState *env)
+{
+    env->irq_inputs = (void **)qemu_allocate_irqs(&ppce500_set_irq,
+                                        env, PPCE500_INPUT_NB);
+}
 /*****************************************************************************/
 /* PowerPC time base and decrementer emulation */
 struct ppc_tb_t {
diff --git a/hw/ppc.h b/hw/ppc.h
index 75eb11a..2ec4680 100644
--- a/hw/ppc.h
+++ b/hw/ppc.h
@@ -31,6 +31,7 @@ extern CPUReadMemoryFunc *PPC_io_read[];
 void PPC_debug_write (void *opaque, uint32_t addr, uint32_t val);
 
 void ppc40x_irq_init (CPUState *env);
+void ppce500_irq_init (CPUState *env);
 void ppc6xx_irq_init (CPUState *env);
 void ppc970_irq_init (CPUState *env);
 
diff --git a/target-ppc/cpu.h b/target-ppc/cpu.h
index 80ee76c..bdc3cf9 100644
--- a/target-ppc/cpu.h
+++ b/target-ppc/cpu.h
@@ -1356,6 +1356,16 @@ enum {
 };
 
 enum {
+    /* PowerPC E500 input pins */
+    PPCE500_INPUT_RESET_CORE = 0,
+    PPCE500_INPUT_MCK        = 1,
+    PPCE500_INPUT_CINT       = 3,
+    PPCE500_INPUT_INT        = 4,
+    PPCE500_INPUT_DEBUG      = 6,
+    PPCE500_INPUT_NB,
+};
+
+enum {
     /* PowerPC 40x input pins */
     PPC40x_INPUT_RESET_CORE = 0,
     PPC40x_INPUT_RESET_CHIP = 1,
diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c
index 889708f..5d1c0b4 100644
--- a/target-ppc/translate_init.c
+++ b/target-ppc/translate_init.c
@@ -63,6 +63,7 @@ void glue(glue(ppc, name),_irq_init) (CPUPPCState *env);
 PPC_IRQ_INIT_FN(40x);
 PPC_IRQ_INIT_FN(6xx);
 PPC_IRQ_INIT_FN(970);
+PPC_IRQ_INIT_FN(e500);
 
 /* Generic callbacks:
  * do nothing but store/retrieve spr value
@@ -4185,7 +4186,6 @@ static void init_proc_e300 (CPUPPCState *env)
 #define check_pow_e500v2       check_pow_hid0
 #define init_proc_e500v2       init_proc_e500
 
-__attribute__ (( unused ))
 static void init_proc_e500 (CPUPPCState *env)
 {
     /* Time base */
@@ -4287,7 +4287,8 @@ static void init_proc_e500 (CPUPPCState *env)
     init_excp_e200(env);
     env->dcache_line_size = 32;
     env->icache_line_size = 32;
-    /* XXX: TODO: allocate internal IRQ controller */
+    /* Allocate hardware IRQ controller */
+    ppce500_irq_init(env);
 }
 
 /* Non-embedded PowerPC                                                      */
-- 
1.5.4

  reply	other threads:[~2009-02-17 10:11 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-17  9:59 [Qemu-devel] powerpc/kvm: Add MPC8544DS board support Liu Yu
2009-02-17  9:59 ` [Qemu-devel] [PATCH 1/5] kvm/powerpc: Enable MPIC for E500 platform Liu Yu
2009-02-17  9:59   ` [Qemu-devel] [PATCH 2/5] kvm/powerpc: Add freescale pci controller's support Liu Yu
2009-02-17  9:59     ` Liu Yu [this message]
2009-02-17  9:59       ` [Qemu-devel] [PATCH 4/5] kvm/powerpc: Add MPC8544DS board support Liu Yu
2009-02-17  9:59         ` [Qemu-devel] [PATCH 5/5] kvm/powerpc: flat device tree files for MPC8544DS Liu Yu
2009-02-17 15:28         ` [Qemu-devel] [PATCH 4/5] kvm/powerpc: Add MPC8544DS board support Blue Swirl
2009-02-18  7:01           ` Liu Yu-B13201
2009-02-17 15:09     ` [Qemu-devel] [PATCH 2/5] kvm/powerpc: Add freescale pci controller's support Blue Swirl
2009-02-17 16:08       ` M. Warner Losh
2009-02-17 16:23         ` M. Warner Losh
2009-02-17 17:41           ` Jamie Lokier
2009-02-18  6:04       ` Liu Yu-B13201
2009-02-17 14:55   ` [Qemu-devel] [PATCH 1/5] kvm/powerpc: Enable MPIC for E500 platform Blue Swirl
2009-02-18  7:17     ` Liu Yu-B13201
2009-02-19 22:41     ` Aurelien Jarno
2009-02-20 17:20       ` Blue Swirl
2009-02-19 23:09   ` Paulev
  -- strict thread matches above, loose matches on Subject: below --
2009-02-26 10:35 [Qemu-devel] [PATCH v4 0/5] powerpc/kvm: Add MPC8544DS board support Liu Yu
2009-02-26 10:35 ` [Qemu-devel] [PATCH 1/5] kvm/powerpc: Enable MPIC for E500 platform Liu Yu
2009-02-26 10:35   ` [Qemu-devel] [PATCH 2/5] kvm/powerpc: Add freescale pci controller's support Liu Yu
2009-02-26 10:35     ` [Qemu-devel] [PATCH 3/5] kvm/powerpc: Add irq support for E500 core Liu Yu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1234864778-19099-4-git-send-email-yu.liu@freescale.com \
    --to=yu.liu@freescale.com \
    --cc=aurelien@aurel32.net \
    --cc=hollisb@us.ibm.com \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).