From patchwork Fri Dec 14 12:13:54 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 206447 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 75F2F2C008C for ; Sat, 15 Dec 2012 00:07:15 +1100 (EST) Received: from localhost ([::1]:55089 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TjUC9-0007xP-Px for incoming@patchwork.ozlabs.org; Fri, 14 Dec 2012 07:16:49 -0500 Received: from eggs.gnu.org ([208.118.235.92]:56531) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TjUAI-0005hc-ND for qemu-devel@nongnu.org; Fri, 14 Dec 2012 07:15:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TjUA8-00011h-CY for qemu-devel@nongnu.org; Fri, 14 Dec 2012 07:14:54 -0500 Received: from cantor2.suse.de ([195.135.220.15]:39313 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TjUA7-0000zY-V4; Fri, 14 Dec 2012 07:14:44 -0500 Received: from relay2.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id D97D0A5215; Fri, 14 Dec 2012 13:14:14 +0100 (CET) From: Alexander Graf To: "qemu-ppc@nongnu.org List" Date: Fri, 14 Dec 2012 13:13:54 +0100 Message-Id: <1355487236-27451-39-git-send-email-agraf@suse.de> X-Mailer: git-send-email 1.6.0.2 In-Reply-To: <1355487236-27451-1-git-send-email-agraf@suse.de> References: <1355487236-27451-1-git-send-email-agraf@suse.de> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x X-Received-From: 195.135.220.15 Cc: qemu-devel qemu-devel Subject: [Qemu-devel] [PATCH 38/40] PPC: e500: pci: Export slot2irq calculation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org We need the calculation method to get from a PCI slot ID to its respective interrupt line twice. Once in the internal map function and once when assembling the device tree. So let's extract the calculation to a separate function that can be called by both users. Signed-off-by: Alexander Graf --- hw/ppc/e500.c | 5 ++++- hw/ppce500_pci.c | 3 ++- hw/ppce500_pci.h | 9 +++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 hw/ppce500_pci.h diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index 564f654..af6b671 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -34,6 +34,7 @@ #include "hw/sysbus.h" #include "exec-memory.h" #include "host-utils.h" +#include "hw/ppce500_pci.h" #define BINARY_DEVICE_TREE_FILE "mpc8544ds.dtb" #define UIMAGE_LOAD_BASE 0 @@ -72,6 +73,7 @@ static uint32_t *pci_map_create(void *fdt, uint32_t mpic, int first_slot, int i = 0; int slot; int pci_irq; + int host_irq; int last_slot = first_slot + nr_slots; uint32_t *pci_map; @@ -85,7 +87,8 @@ static uint32_t *pci_map_create(void *fdt, uint32_t mpic, int first_slot, pci_map[i++] = cpu_to_be32(0x0); pci_map[i++] = cpu_to_be32(pci_irq + 1); pci_map[i++] = cpu_to_be32(mpic); - pci_map[i++] = cpu_to_be32(((pci_irq + slot) % 4) + 1); + host_irq = ppce500_pci_map_irq_slot(slot, pci_irq); + pci_map[i++] = cpu_to_be32(host_irq + 1); pci_map[i++] = cpu_to_be32(0x1); } } diff --git a/hw/ppce500_pci.c b/hw/ppce500_pci.c index 561a776..09e3507 100644 --- a/hw/ppce500_pci.c +++ b/hw/ppce500_pci.c @@ -19,6 +19,7 @@ #include "pci.h" #include "pci_host.h" #include "bswap.h" +#include "ppce500_pci.h" #ifdef DEBUG_PCI #define pci_debug(fmt, ...) fprintf(stderr, fmt, ## __VA_ARGS__) @@ -256,7 +257,7 @@ static int mpc85xx_pci_map_irq(PCIDevice *pci_dev, int irq_num) int devno = pci_dev->devfn >> 3; int ret; - ret = (irq_num + devno) % 4; + ret = ppce500_pci_map_irq_slot(devno, irq_num); pci_debug("%s: devfn %x irq %d -> %d devno:%x\n", __func__, pci_dev->devfn, irq_num, ret, devno); diff --git a/hw/ppce500_pci.h b/hw/ppce500_pci.h new file mode 100644 index 0000000..61f773e --- /dev/null +++ b/hw/ppce500_pci.h @@ -0,0 +1,9 @@ +#ifndef PPCE500_PCI_H +#define PPCE500_PCI_H + +static inline int ppce500_pci_map_irq_slot(int devno, int irq_num) +{ + return (devno + irq_num) % 4; +} + +#endif