From patchwork Thu Apr 17 17:29:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alvise Rigo X-Patchwork-Id: 339992 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 222CB1400B8 for ; Fri, 18 Apr 2014 03:33:22 +1000 (EST) Received: from localhost ([::1]:34029 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WaqBb-000289-RE for incoming@patchwork.ozlabs.org; Thu, 17 Apr 2014 13:33:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34272) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Waq8h-0006No-6P for qemu-devel@nongnu.org; Thu, 17 Apr 2014 13:30:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Waq8b-000571-4e for qemu-devel@nongnu.org; Thu, 17 Apr 2014 13:30:19 -0400 Received: from mail-wi0-f174.google.com ([209.85.212.174]:48998) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Waq8a-000560-U9 for qemu-devel@nongnu.org; Thu, 17 Apr 2014 13:30:13 -0400 Received: by mail-wi0-f174.google.com with SMTP id d1so3257953wiv.13 for ; Thu, 17 Apr 2014 10:30:12 -0700 (PDT) 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=BZOGvO9o3PSu/bEnDAQehKPw1E6L70RSomAnf5IMnS8=; b=RMTzve7RBVz759xw3YUZUnXafL21BKTbZunpqlHImaZMFOhm1JvLQNHZ9wjBrqJuMZ FQzh7j8wKBYGul+bIi+FECqWUNsU62nkgkkNU6+RVYHa2NVYH1hoZqFBCFkP4lZX6vZ2 nwCZn1Q+kxlMNi6yhUz26g2A7JXfDn+MrgwUiVBmZmTVJqdw2Jz9drsVLbXvITs6y7XM qQliFpGS9Xg7Fz6fnXqM9Ctab6fITlUddlGUXMbBcvU5qXaqY60J92323TBGtYXIgC5q ToMtxJ2Ta1pvgyGECV7WIgL4CI+YkuLaRx65GR+8K1kFBzfmS897AAoARZhdw8DX9fuE zaCA== X-Gm-Message-State: ALoCoQk2tWbjqueoCsN52CX7LXficAITw9DK5nyn9omHow7SGeXrYYjM7PM9W5sFosANCDD7/B+m X-Received: by 10.180.189.69 with SMTP id gg5mr6882943wic.52.1397755812020; Thu, 17 Apr 2014 10:30:12 -0700 (PDT) Received: from localhost.localdomain (AGrenoble-651-1-481-123.w90-42.abo.wanadoo.fr. [90.42.177.123]) by mx.google.com with ESMTPSA id gz1sm5996833wib.14.2014.04.17.10.30.10 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 17 Apr 2014 10:30:11 -0700 (PDT) From: Alvise Rigo To: qemu-devel@nongnu.org, a.motakis@virtualopensystems.com, eric.auger@st.com, kim.phillips@linaro.org Date: Thu, 17 Apr 2014 19:29:34 +0200 Message-Id: <1397755775-23833-4-git-send-email-a.rigo@virtualopensystems.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1397755775-23833-1-git-send-email-a.rigo@virtualopensystems.com> References: <1397755775-23833-1-git-send-email-a.rigo@virtualopensystems.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.212.174 Cc: Peter Maydell , tech@virtualopensystems.com, Alvise Rigo Subject: [Qemu-devel] [RFC 3/4] Add AMBA devices support to VFIO 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 The impossibility to add more then one compatibility property to the device tree node was not permitting to bind AMBA devices. Now we can add an arbitrary number of compatibility property values divided by the character ";". If the compatibility string contains the substring "arm,primecell", a clock property will be added to the device tree node in order to allow the AMBA bus code to probe the device. Signed-off-by: Alvise Rigo --- hw/arm/virt.c | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 1fb66ef..dadf5f0 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -344,6 +344,8 @@ static int vfio_init_func(QemuOpts *opts, void *opaque) size_t size; int i; uint32_t *irq_attr; + bool is_amba = false; + int compat_str_len; if (!driver) { qerror_report(QERR_MISSING_PARAMETER, "driver"); @@ -369,12 +371,31 @@ static int vfio_init_func(QemuOpts *opts, void *opaque) /* * process compatibility property string passed by end-user - * replaces / by , - * currently a single property compatibility value is supported! + * replaces / by , and ; by NUL character */ corrected_compat = g_strdup(*pcompat); - char *slash = strchr(corrected_compat, '/'); - *slash = ','; + /* + * the total length of the string has to include also the last + * NUL char. + */ + compat_str_len = strlen(corrected_compat) + 1; + + char *str_ptr = corrected_compat; + while ((str_ptr = strchr(str_ptr, '/')) != NULL) { + *str_ptr = ','; + } + + /* check if is an AMBA device */ + str_ptr = corrected_compat; + if (strstr(str_ptr, "arm,primecell") != NULL) { + is_amba = true; + } + + /* substitute ";" with the NUL char */ + str_ptr = corrected_compat; + while ((str_ptr = strchr(str_ptr, ';')) != NULL) { + *str_ptr = '\0'; + } sysbus_mmio_map(s, 0, vbi->avail_vfio_base); @@ -383,11 +404,19 @@ static int vfio_init_func(QemuOpts *opts, void *opaque) qemu_fdt_add_subnode(vbi->fdt, nodename); qemu_fdt_setprop(vbi->fdt, nodename, "compatible", - corrected_compat, strlen(corrected_compat)); + corrected_compat, compat_str_len); qemu_fdt_setprop_sized_cells(vbi->fdt, nodename, "reg", 2, vbi->avail_vfio_base, 2, size); + if (is_amba) { + qemu_fdt_setprop_cells(vbi->fdt, nodename, "clocks", + vbi->clock_phandle); + char clock_names[] = "apb_pclk"; + qemu_fdt_setprop(vbi->fdt, nodename, "clock-names", clock_names, + sizeof(clock_names)); + } + irq_attr = g_malloc0(num_irqs*3*sizeof(uint32_t)); for (i = 0; i < num_irqs; i++) { sysbus_connect_irq(s, i, vbi->pic[irq_start+i]);