From patchwork Fri Mar 18 09:13:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baptiste Reynal X-Patchwork-Id: 8617361 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id F37D1C0554 for ; Fri, 18 Mar 2016 09:13:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A2259203F3 for ; Fri, 18 Mar 2016 09:13:58 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BFD732039C for ; Fri, 18 Mar 2016 09:13:55 +0000 (UTC) Received: from localhost ([::1]:42361 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agqTi-0002in-OR for patchwork-qemu-devel@patchwork.kernel.org; Fri, 18 Mar 2016 05:13:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42162) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agqTM-0002dd-RR for qemu-devel@nongnu.org; Fri, 18 Mar 2016 05:13:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1agqTL-0003mc-R7 for qemu-devel@nongnu.org; Fri, 18 Mar 2016 05:13:32 -0400 Received: from mail-wm0-x229.google.com ([2a00:1450:400c:c09::229]:37772) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agqTL-0003mR-Go for qemu-devel@nongnu.org; Fri, 18 Mar 2016 05:13:31 -0400 Received: by mail-wm0-x229.google.com with SMTP id p65so27718639wmp.0 for ; Fri, 18 Mar 2016 02:13:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtualopensystems-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=u6vy/xilNbkQfhj3l+O2FOu23HMfkSgtozkE1OE97k8=; b=vDhJO6bI2XCwJcSh5iUg2tE+Nyl47OrELxaStOwq5qbwx1K33EPVOL9D0L/Uyq4fdF I1tOMs6dVc20jMyc90G8T9WuNBQj2ERA80E9pd9YMta5h6CLafIzCkNY8tQ4jbVR/irx pJrUovf3IZfIXGj+BIcaGsJywO8Cj3pVJZhPq5FmS/Hzmgh1WPpS4MVVhCLw4jpFYLiQ mJRUSfCssbhgQWwUpyauv8ZhWizSdDZW/rzd2P2CTYFCdBLKGKR/j4A7MAELH0hUFiEX VKQawJ8xA/tkE7uA3pkiuK/feYBxiuyCJ5CQyt5N1l6awIpMMTGY5dUDu/FXeQryn6nc bFWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=u6vy/xilNbkQfhj3l+O2FOu23HMfkSgtozkE1OE97k8=; b=B42MP9bHViO6OftTJWJOAAZNu/jr+n2OlkpIY0DNIseRYI1CCRQ+VXs+XUUc4JpXPi A2+VHevdmPefYvGpJE69PsVnaxfQdWDgoMNCXg4C+P7emaBC+Jz3+dN5blghd1nXk+/y U/To8aakAMpbvGUGoODemEW0QhQk5IfykDYA544Z/nwe01xh7ytvk+hX3k23ysFYB4pJ KTskrtXwyzyHCDW8R8sXrZflAzkm0AyOSGNJBCFaTNlCsKJy/5mR/FpuwAInTC/7iVeS jx5KPF+8cV2l0B0SDPSL7Qye2eHVofD2Ne2D0I+xiFsWaT4SZgxA7NFpvH7FTWFeFV8s 5law== X-Gm-Message-State: AD7BkJI9l3jVNcJ5N7nJwAE8prHOihW4b+Y0yq1BYhb+Boy7493PS/OMEAK4+dCC/bQiBw== X-Received: by 10.28.65.137 with SMTP id o131mr16339633wma.54.1458292410980; Fri, 18 Mar 2016 02:13:30 -0700 (PDT) Received: from localhost (LMontsouris-657-1-4-224.w90-63.abo.wanadoo.fr. [90.63.239.224]) by smtp.gmail.com with ESMTPSA id e127sm34020469wma.20.2016.03.18.02.13.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Mar 2016 02:13:30 -0700 (PDT) From: Baptiste Reynal To: qemu-devel@nongnu.org Date: Fri, 18 Mar 2016 10:13:02 +0100 Message-Id: <1458292385-13802-4-git-send-email-b.reynal@virtualopensystems.com> X-Mailer: git-send-email 2.7.3 In-Reply-To: <1458292385-13802-1-git-send-email-b.reynal@virtualopensystems.com> References: <1458292385-13802-1-git-send-email-b.reynal@virtualopensystems.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::229 Cc: b.reynal@virtualopensystems.com, Jani.Kokkonen@huawei.com, tech@virtualopensystems.com, Claudio.Fontana@huawei.com, Christian Pinto Subject: [Qemu-devel] [RFC v2 3/6] hw/arm: sysbus-fdt 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Added node creation for dynamically instantiated sysbus SDM device. Support added for all ARM machines modeling dynamic sysbus devices instantiation. Signed-off-by: Christian Pinto Signed-off-by: Baptiste Reynal --- hw/arm/sysbus-fdt.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/hw/arm/sysbus-fdt.c b/hw/arm/sysbus-fdt.c index 9d28797..9ad7912 100644 --- a/hw/arm/sysbus-fdt.c +++ b/hw/arm/sysbus-fdt.c @@ -28,6 +28,7 @@ #include "sysemu/sysemu.h" #include "hw/vfio/vfio-platform.h" #include "hw/vfio/vfio-calxeda-xgmac.h" +#include "hw/misc/sdm-platform.h" #include "hw/arm/fdt.h" /* @@ -123,9 +124,70 @@ fail_reg: return ret; } +/** + * add_sdm_fdt_node + * + * Generates a node with following properties: + * compatible string, regs, interrupts + * + */ +static int add_sdm_fdt_node(SysBusDevice *sbdev, void *opaque) +{ + PlatformBusFDTData *data = opaque; + PlatformBusDevice *pbus = data->pbus; + const char sdm_compat[] = "sdm-ipi"; + void *fdt = data->fdt; + const char *parent_node = data->pbus_node_name; + char *nodename; + int ret = -1; + uint32_t *irq_attr, *reg_attr; + uint64_t mmio_base, irq_number; + + mmio_base = platform_bus_get_mmio_addr(pbus, sbdev, 0); + nodename = g_strdup_printf("%s/%s@%" PRIx64, parent_node, + TYPE_SDM_PLATFORM, mmio_base); + qemu_fdt_add_subnode(fdt, nodename); + + qemu_fdt_setprop(fdt, nodename, "compatible", sdm_compat, + sizeof(sdm_compat)); + + /** + * There is only one MMIO region defined for the SDM device + */ + reg_attr = g_new(uint32_t, 2); + mmio_base = platform_bus_get_mmio_addr(pbus, sbdev, 0); + reg_attr[0] = cpu_to_be32(mmio_base); + reg_attr[1] = cpu_to_be32(SDM_PLATFORM_SIZE); + ret = qemu_fdt_setprop(fdt, nodename, "reg", reg_attr, + 2 * sizeof(uint32_t)); + if (ret) { + error_report("could not set reg property of node %s", nodename); + goto fail; + } + + irq_attr = g_new(uint32_t, 3); + irq_number = platform_bus_get_irqn(pbus, sbdev , 0) + + data->irq_start; + irq_attr[0] = cpu_to_be32(GIC_FDT_IRQ_TYPE_SPI); + irq_attr[1] = cpu_to_be32(irq_number); + irq_attr[2] = cpu_to_be32(GIC_FDT_IRQ_FLAGS_EDGE_LO_HI); + ret = qemu_fdt_setprop(fdt, nodename, "interrupts", + irq_attr, 3 * sizeof(uint32_t)); + if (ret) { + error_report("could not set interrupts property of node %s", + nodename); + } + g_free(irq_attr); +fail: + g_free(reg_attr); + g_free(nodename); + return ret; +} + /* list of supported dynamic sysbus devices */ static const NodeCreationPair add_fdt_node_functions[] = { {TYPE_VFIO_CALXEDA_XGMAC, add_calxeda_midway_xgmac_fdt_node}, + {TYPE_SDM_PLATFORM, add_sdm_fdt_node}, {"", NULL}, /* last element */ };