From patchwork Wed Nov 5 09:41:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frediano Ziglio X-Patchwork-Id: 40170 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f69.google.com (mail-wg0-f69.google.com [74.125.82.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A9801240A6 for ; Wed, 5 Nov 2014 09:43:35 +0000 (UTC) Received: by mail-wg0-f69.google.com with SMTP id l18sf240578wgh.4 for ; Wed, 05 Nov 2014 01:43:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:mime-version:cc:subject:precedence:list-id :list-unsubscribe:list-post:list-help:list-subscribe:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:list-archive:content-type:content-transfer-encoding; bh=JSR2zw3Clh2arwja20qGfo4rlnSi0FvNWaaS1q4tzxA=; b=HTBoak9//Tcbnaeug1tBDB2aQ4GuRt8IQX8+WDWqoXm/a+vm52JQm7bCw/vX9oufbA YihN64YG5nE0zCWaHj/rE4yWhg0Yoxnm6ITWRwPWl2uR1r1UbZ2Cp9UhSageRYL4Narb bA7P0E8WIWsAX7Tnapcb3wYslceTsguynUaSEjrsC2XJYt7T1to7BMI5gPyzO8vrsg4T U3F3oRn+WYlX4g6bP5JVxS5VupZA/OUoW7zJynzWjMr8KVmXZmik+p5S5hXrIvZDM/VX ZpT0eNAaFNcZNRUmyztuPruWk7ngW+MbFckaCnTto+BZuX4F2JDkTaOa2HrHVS+WpSw0 PUsg== X-Gm-Message-State: ALoCoQnK/2RqwYZ/1v+L135VZQRADGJ9Ewu5wXA3Y8kvz+dIvuxRRTH2Tqf6ZYPyOJ96N+h1FmjG X-Received: by 10.194.206.10 with SMTP id lk10mr3188482wjc.3.1415180614848; Wed, 05 Nov 2014 01:43:34 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.29.5 with SMTP id f5ls971787lah.62.gmail; Wed, 05 Nov 2014 01:43:34 -0800 (PST) X-Received: by 10.112.147.199 with SMTP id tm7mr28215903lbb.92.1415180614212; Wed, 05 Nov 2014 01:43:34 -0800 (PST) Received: from mail-la0-f53.google.com (mail-la0-f53.google.com. [209.85.215.53]) by mx.google.com with ESMTPS id ir2si5043471lac.127.2014.11.05.01.43.34 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 05 Nov 2014 01:43:34 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) client-ip=209.85.215.53; Received: by mail-la0-f53.google.com with SMTP id mc6so317827lab.26 for ; Wed, 05 Nov 2014 01:43:34 -0800 (PST) X-Received: by 10.112.202.104 with SMTP id kh8mr4370366lbc.46.1415180614060; Wed, 05 Nov 2014 01:43:34 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp256304lbc; Wed, 5 Nov 2014 01:43:33 -0800 (PST) X-Received: by 10.224.21.133 with SMTP id j5mr86339104qab.51.1415180612690; Wed, 05 Nov 2014 01:43:32 -0800 (PST) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id l7si5282769qge.108.2014.11.05.01.43.32 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 05 Nov 2014 01:43:32 -0800 (PST) Received-SPF: none (google.com: xen-devel-bounces@lists.xen.org does not designate permitted sender hosts) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Xlx6y-0007Zh-S8; Wed, 05 Nov 2014 09:42:44 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Xlx6x-0007Yf-OK for xen-devel@lists.xen.org; Wed, 05 Nov 2014 09:42:43 +0000 Received: from [85.158.143.35] by server-1.bemta-4.messagelabs.com id 8F/44-09842-311F9545; Wed, 05 Nov 2014 09:42:43 +0000 X-Env-Sender: frediano.ziglio@huawei.com X-Msg-Ref: server-16.tower-21.messagelabs.com!1415180558!9449863!1 X-Originating-IP: [119.145.14.65] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTE5LjE0NS4xNC42NSA9PiA3NzQ2Mw==\n X-StarScan-Received: X-StarScan-Version: 6.12.4; banners=-,-,- X-VirusChecked: Checked Received: (qmail 16690 invoked from network); 5 Nov 2014 09:42:42 -0000 Received: from szxga02-in.huawei.com (HELO szxga02-in.huawei.com) (119.145.14.65) by server-16.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 5 Nov 2014 09:42:42 -0000 Received: from 172.24.2.119 (EHLO szxeml450-hub.china.huawei.com) ([172.24.2.119]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CBW70535; Wed, 05 Nov 2014 17:42:37 +0800 (CST) Received: from localhost.localdomain (10.47.71.64) by szxeml450-hub.china.huawei.com (10.82.67.193) with Microsoft SMTP Server id 14.3.158.1; Wed, 5 Nov 2014 17:42:29 +0800 From: Frediano Ziglio To: Ian Campbell , Stefano Stabellini , Tim Deegan , Julien Grall , Date: Wed, 5 Nov 2014 09:41:14 +0000 Message-ID: <1415180475-8339-8-git-send-email-frediano.ziglio@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1415180475-8339-1-git-send-email-frediano.ziglio@huawei.com> References: <1415180475-8339-1-git-send-email-frediano.ziglio@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.47.71.64] X-CFilter-Loop: Reflected Cc: zoltan.kiss@huawei.com, xen-devel@lists.xen.org Subject: [Xen-devel] [PATCH v3 7/8] xen/device_tree: Add dt_device_get_address_raw X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: frediano.ziglio@huawei.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: Allow to read untranslated address from device node. Signed-off-by: Frediano Ziglio --- xen/common/device_tree.c | 34 ++++++++++++++++++++++++++++++++++ xen/include/xen/device_tree.h | 11 +++++++++++ 2 files changed, 45 insertions(+) diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c index 1a886c0..4186a24 100644 --- a/xen/common/device_tree.c +++ b/xen/common/device_tree.c @@ -711,6 +711,40 @@ int dt_device_get_address(const struct dt_device_node *dev, int index, return 0; } +/* dt_device_get_address_raw - Returns address not translated */ +int dt_device_get_address_raw(const struct dt_device_node *dev, int index, + u64 *addr) +{ + const __be32 *addrp; + const struct dt_device_node *parent; + const struct dt_bus *bus; + int na, ns; + + if ( !addr ) + return -EINVAL; + + addrp = dt_get_address(dev, index, NULL, NULL); + if ( addrp == NULL ) + return -EINVAL; + + /* Get parent & match bus type */ + parent = dt_get_parent(dev); + if ( parent == NULL ) + return -EINVAL; + bus = dt_match_bus(parent); + if ( !bus ) + return -EINVAL; + + /* Count address cells & copy address locally */ + bus->count_cells(dev, &na, &ns); + if ( !DT_CHECK_ADDR_COUNT(na) ) + return -EINVAL; + + *addr = dt_read_number(addrp, na); + return 0; +} + + /** * dt_find_node_by_phandle - Find a node given a phandle * @handle: phandle of the node to find diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h index 629bfb2..3d2a4ae 100644 --- a/xen/include/xen/device_tree.h +++ b/xen/include/xen/device_tree.h @@ -475,6 +475,17 @@ int dt_device_get_address(const struct dt_device_node *dev, int index, u64 *addr, u64 *size); /** + * dt_device_get_address_raw - Get an address for a device + * @device: the device whose address is to be resolved + * @index: index of the address to resolve + * @addr: address filled by this function + * + * This function get a raw (unresolved) address. It returns 0 on success. + */ +int dt_device_get_address_raw(const struct dt_device_node *dev, int index, + u64 *addr); + +/** * dt_number_of_irq - Get the number of IRQ for a device * @device: the device whose number of interrupt is to be retrieved *