From patchwork Mon Feb 21 20:57:52 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 83880 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 226E9B7063 for ; Tue, 22 Feb 2011 08:19:08 +1100 (EST) Received: from localhost ([127.0.0.1]:38840 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Prd9t-0002B4-IG for incoming@patchwork.ozlabs.org; Mon, 21 Feb 2011 16:19:05 -0500 Received: from [140.186.70.92] (port=42937 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Prd5b-0000GG-Ru for qemu-devel@nongnu.org; Mon, 21 Feb 2011 16:14:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Prd5a-0004yB-P7 for qemu-devel@nongnu.org; Mon, 21 Feb 2011 16:14:40 -0500 Received: from mnementh.archaic.org.uk ([81.2.115.146]:60831) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Prd5a-0004xX-GW for qemu-devel@nongnu.org; Mon, 21 Feb 2011 16:14:38 -0500 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.72) (envelope-from ) id 1PrcpN-0004Rn-P5; Mon, 21 Feb 2011 20:57:53 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 21 Feb 2011 20:57:52 +0000 Message-Id: <1298321873-17064-5-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.3 In-Reply-To: <1298321873-17064-1-git-send-email-peter.maydell@linaro.org> References: <1298321873-17064-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 81.2.115.146 Cc: patches@linaro.org Subject: [Qemu-devel] [PATCH 4/5] hw/irq: Add qemu_irq_split() so one GPIO output can feed two inputs X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Add a qemu_irq_split() function which allows a board to wire a single GPIO output up to two GPIO inputs. This is needed for realview boards, where the MMC card status is visible both in a system register and via a PL061 GPIO module. Signed-off-by: Peter Maydell --- hw/irq.c | 15 +++++++++++++++ hw/irq.h | 3 +++ 2 files changed, 18 insertions(+), 0 deletions(-) diff --git a/hw/irq.c b/hw/irq.c index 7703f62..4035a8c 100644 --- a/hw/irq.c +++ b/hw/irq.c @@ -75,3 +75,18 @@ qemu_irq qemu_irq_invert(qemu_irq irq) qemu_irq_raise(irq); return qemu_allocate_irqs(qemu_notirq, irq, 1)[0]; } + +static void qemu_splitirq(void *opaque, int line, int level) +{ + struct IRQState **irq = opaque; + irq[0]->handler(irq[0]->opaque, irq[0]->n, level); + irq[1]->handler(irq[1]->opaque, irq[1]->n, level); +} + +qemu_irq qemu_irq_split(qemu_irq irq1, qemu_irq irq2) +{ + qemu_irq *s = qemu_mallocz(2 * sizeof(qemu_irq)); + s[0] = irq1; + s[1] = irq2; + return qemu_allocate_irqs(qemu_splitirq, s, 1)[0]; +} diff --git a/hw/irq.h b/hw/irq.h index f7849ed..389ed7a 100644 --- a/hw/irq.h +++ b/hw/irq.h @@ -30,4 +30,7 @@ void qemu_free_irqs(qemu_irq *s); /* Returns a new IRQ with opposite polarity. */ qemu_irq qemu_irq_invert(qemu_irq irq); +/* Returns a new IRQ which feeds into both the passed IRQs */ +qemu_irq qemu_irq_split(qemu_irq irq1, qemu_irq irq2); + #endif