From patchwork Mon Jun 2 07:49:32 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 31258 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f197.google.com (mail-ie0-f197.google.com [209.85.223.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 852CE20AE6 for ; Mon, 2 Jun 2014 07:50:35 +0000 (UTC) Received: by mail-ie0-f197.google.com with SMTP id rd18sf25978011iec.4 for ; Mon, 02 Jun 2014 00:50:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=M7dtSzF+1bJW4zhOv1Bcme4fKYmkh8jpCWI2ktCgfjE=; b=Vro4ihZfzg21T6W9tD3XWjcAK1RYBLTavoB/IU/0RDDLhvdgxGvklIKkWywvqw/7bu 34N083piO9gabphxTaiSwWqUxyd1brxsZWnYrRPKGadtWHuAPktUwrz7/9qiSvV8c6GU qL8Hoz0W+6myubklIH/14f8YV2bOxlbi4zLCV5Z3t+jeEW8ZUg6Wh33O6ryPmB93laOl IUcRH5jKqCmhiR/yhZKmlXuSFJ+RJPX8WuQDMvWufHCFddpXbyVoxEaOoT8zuqw8FevG 8ZMVC8J0gXtVXi5/2FrjfP2nYKTP0yGi9+NtYDakmQ2R6yCdfaPZLZKFRxJxOQRi7nBp 58Cw== X-Gm-Message-State: ALoCoQkPICAd6PRcsoeNHMSHJjzv3viGyLefO4dSADyYv6/5oW0+6PkIWgig8+sWRGnFmi4TXKyY X-Received: by 10.50.61.146 with SMTP id p18mr700481igr.3.1401695435017; Mon, 02 Jun 2014 00:50:35 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.19.173 with SMTP id 42ls1797254qgh.27.gmail; Mon, 02 Jun 2014 00:50:34 -0700 (PDT) X-Received: by 10.52.29.236 with SMTP id n12mr1396741vdh.38.1401695434914; Mon, 02 Jun 2014 00:50:34 -0700 (PDT) Received: from mail-ve0-f176.google.com (mail-ve0-f176.google.com [209.85.128.176]) by mx.google.com with ESMTPS id u13si7528683vem.26.2014.06.02.00.50.34 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 02 Jun 2014 00:50:34 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.176 as permitted sender) client-ip=209.85.128.176; Received: by mail-ve0-f176.google.com with SMTP id jz11so4737581veb.35 for ; Mon, 02 Jun 2014 00:50:34 -0700 (PDT) X-Received: by 10.58.247.66 with SMTP id yc2mr29325575vec.13.1401695434838; Mon, 02 Jun 2014 00:50:34 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp78779vcb; Mon, 2 Jun 2014 00:50:34 -0700 (PDT) X-Received: by 10.180.11.9 with SMTP id m9mr19748788wib.51.1401695432426; Mon, 02 Jun 2014 00:50:32 -0700 (PDT) Received: from mail-we0-f174.google.com (mail-we0-f174.google.com [74.125.82.174]) by mx.google.com with ESMTPS id yx7si23868703wjc.120.2014.06.02.00.50.32 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 02 Jun 2014 00:50:32 -0700 (PDT) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 74.125.82.174 as permitted sender) client-ip=74.125.82.174; Received: by mail-we0-f174.google.com with SMTP id k48so4687227wev.19 for ; Mon, 02 Jun 2014 00:50:32 -0700 (PDT) X-Received: by 10.180.205.239 with SMTP id lj15mr19640430wic.54.1401695432020; Mon, 02 Jun 2014 00:50:32 -0700 (PDT) Received: from midway01-04-00.lavalab ([88.98.47.97]) by mx.google.com with ESMTPSA id je7sm30286772wic.14.2014.06.02.00.50.30 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 02 Jun 2014 00:50:31 -0700 (PDT) From: Eric Auger To: eric.auger@st.com, christoffer.dall@linaro.org, qemu-devel@nongnu.org, kim.phillips@freescale.com, a.rigo@virtualopensystems.com Cc: eric.auger@linaro.org, christophe.barnichon@st.com, kvmarm@lists.cs.columbia.edu, alex.williamson@redhat.com, agraf@suse.de, peter.maydell@linaro.org, stuart.yoder@freescale.com, a.motakis@virtualopensystems.com, patches@linaro.org Subject: [RFC v3 08/10] Add AMBA devices support to VFIO Date: Mon, 2 Jun 2014 08:49:32 +0100 Message-Id: <1401695374-4287-9-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1401695374-4287-1-git-send-email-eric.auger@linaro.org> References: <1401695374-4287-1-git-send-email-eric.auger@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: eric.auger@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.176 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Alvise Rigo 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. [Eric Auger] put str_ptr in the declaration part and rename pcompat into compat Signed-off-by: Alvise Rigo Signed-off-by: Eric Auger --- hw/arm/virt.c | 45 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 8de6d1a..bc561b5 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -369,6 +369,7 @@ static int vfio_init_func(QemuOpts *opts, void *opaque) int irq_start = vbi->avail_vfio_irq; hwaddr vfio_base = vbi->avail_vfio_base; char *nodename; + char *str_ptr; char *corrected_compat, *compat, *name; int num_irqs, num_regions; MemoryRegion *mr; @@ -377,6 +378,8 @@ static int vfio_init_func(QemuOpts *opts, void *opaque) uint64_t *reg_attr; uint64_t size; Error *errp = NULL; + bool is_amba = false; + int compat_str_len; if (!driver) { qerror_report(QERR_MISSING_PARAMETER, "driver"); @@ -442,17 +445,30 @@ 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(compat); - char *slash = strchr(corrected_compat, '/'); - if (slash != NULL) { - *slash = ','; - } else { - error_report("Wrong compat string %s, should contain a /\n", - compat); - exit(1); + /* + * the total length of the string has to include also the last + * NUL char. + */ + compat_str_len = strlen(corrected_compat) + 1; + + 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, vfio_base); @@ -462,7 +478,7 @@ 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); ret = qemu_fdt_setprop_sized_cells_from_array(vbi->fdt, nodename, "reg", num_regions*2, reg_attr); @@ -471,6 +487,15 @@ static int vfio_init_func(QemuOpts *opts, void *opaque) } irq_attr = g_new(uint32_t, num_irqs*3); + + 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)); + } + for (i = 0; i < num_irqs; i++) { sysbus_connect_irq(s, i, vbi->pic[irq_start+i]);