From patchwork Fri Jun 17 15:55:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Pinto X-Patchwork-Id: 9184505 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E1A456075D for ; Fri, 17 Jun 2016 16:12:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C834F200F5 for ; Fri, 17 Jun 2016 16:12:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BD02E27248; Fri, 17 Jun 2016 16:12:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id 3EF87200F5 for ; Fri, 17 Jun 2016 16:12:39 +0000 (UTC) Received: from localhost ([::1]:58737 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDwNq-0007gm-Au for patchwork-qemu-devel@patchwork.kernel.org; Fri, 17 Jun 2016 12:12:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53242) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDw7N-0006eu-Ce for qemu-devel@nongnu.org; Fri, 17 Jun 2016 11:55:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bDw7H-00018b-Ee for qemu-devel@nongnu.org; Fri, 17 Jun 2016 11:55:36 -0400 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:33652) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDw7H-00018U-44 for qemu-devel@nongnu.org; Fri, 17 Jun 2016 11:55:31 -0400 Received: by mail-wm0-x241.google.com with SMTP id r201so755355wme.0 for ; Fri, 17 Jun 2016 08:55:30 -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=zbcaBghLQIert7G3z0xxcUdd+7M8gk+bhe+sUnwST7o=; b=o7a+ZCI9xRs9bSSt+nPevPbW9McdWhpJVMXQBUrJBrUD3c5CgAc+G/ObRWBp/uC/LN 89tGVxqkscTiay+R46xZpScJAKsr6AQwd60EJ5lf0t31sQ/7+MAL3pPaikHG/iwbXq+P EFIGIRAAvYPJhVPyd/2pFkJiaNDLu/+YNFI3sYaTCFkqYKI06S40hDFxSn2xP7u8Ijrj 8r9ZNV4vFGpdKkx1RbzKxPxQgYIG6VwT631dtOxC40N20u9D7tGKogkl7oX9oAW056x8 CFfIFrByEERXcUVF3zkN4b6puylIzyOwSBbsAuZ9xWYoffbmaiFgCnYMGUeOS/BJH97L dfpg== 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=zbcaBghLQIert7G3z0xxcUdd+7M8gk+bhe+sUnwST7o=; b=EDQpAON5MIir3loIzbMekruif6bsXwVEe+epzPM1eHx258FTMWZR+sfylHwEC06204 VsQIk0+khWk6caDV1w2EIZoTHGCZ56EJPZz9gaAiM0wA73ZQocvip8iK3NMHdlii48tI HkIQq+6KfyNikRFLj4vmaxrOd/fR7nAevlURbnMdmNBmuuho67ADfWzCJBWHUcpPNEKl cumE9hlAf2j16SKuAKrj6jJYbETWaXwxBanx70R9txlXBjXzzXO778fp+AcyjmSdrwxe AjUfAUAXM0B8xbW/eQSzfik/sD1wICraszVU7g3IPaxR2LhVAqYaUbR9p+U4BvI/Tqj/ l/9Q== X-Gm-Message-State: ALyK8tLMYUYU5V0KMvXusnWuWt8GX8F5n23A8ciqcD1z71HS5y0DE2LJcgbY0/uohkPqXg== X-Received: by 10.194.203.37 with SMTP id kn5mr3068884wjc.42.1466178930358; Fri, 17 Jun 2016 08:55:30 -0700 (PDT) Received: from bumma.localdomain ([151.67.13.17]) by smtp.googlemail.com with ESMTPSA id q189sm254937wmd.19.2016.06.17.08.55.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 17 Jun 2016 08:55:29 -0700 (PDT) From: Christian Pinto To: qemu-devel@nongnu.org Date: Fri, 17 Jun 2016 17:55:00 +0200 Message-Id: <1466178903-2184-4-git-send-email-c.pinto@virtualopensystems.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1466178903-2184-1-git-send-email-c.pinto@virtualopensystems.com> References: <1466178903-2184-1-git-send-email-c.pinto@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::241 Subject: [Qemu-devel] [RFC v3 3/6] hw/arm: sysbus-fdt X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Claudio.Fontana@huawei.com, Jani.Kokkonen@huawei.com, tech@virtualopensystems.com, b.reynal@virtualopensystems.com, Christian Pinto Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Baptiste Reynal 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 */ };