From patchwork Mon Aug 17 07:07:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roese X-Patchwork-Id: 1345678 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=gYRX+9yS; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BVQB25FX4z9sPC for ; Mon, 17 Aug 2020 17:08:24 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 267E48221A; Mon, 17 Aug 2020 09:08:11 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1597648091; bh=/FCdI2swaOna1NJSJ0wnhwxtbmEV3Agnn1I3ez5Tkco=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=gYRX+9ySqwmyrmH//qnqmRUmjpMEkov5RmJ7T5UkmVCkjXHmI2YVu3HxMLzd4h5uS kRLzqTquR2IgDTk9S5NNX8znPneJkCdgSO8LqjfkKF6fg13EM+6Hser77/o6XKDVNN 1KPnLVZEhJBx3wS5XDpxZDsn7xYHCx7hRXI5YE/XiA8jE+3YoZxNAB7y15Yc8GpeQI pRBMD+yeG4QkZI5WYJQhG1rBx1T/NvEi6ETppsBxLsj9NKWmBnlEaBVBfaoo8VwMXk ApxeOX0hIbakgE/5gmrbmKlMY5w3hXLqD+HDRzLQji/U1ZzravewZSNidVn5B7Ws6R 4uPrSbsKgJ3kA== Received: by phobos.denx.de (Postfix, from userid 109) id AF592821FC; Mon, 17 Aug 2020 09:08:09 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mx2.mailbox.org (mx2.mailbox.org [80.241.60.215]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 28620821BE for ; Mon, 17 Aug 2020 09:08:07 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=sr@denx.de Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:105:465:1:1:0]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mx2.mailbox.org (Postfix) with ESMTPS id 985E5A288E; Mon, 17 Aug 2020 09:08:06 +0200 (CEST) Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter06.heinlein-hosting.de (spamfilter06.heinlein-hosting.de [80.241.56.125]) (amavisd-new, port 10030) with ESMTP id t8XCQ4znDHp4; Mon, 17 Aug 2020 09:08:03 +0200 (CEST) From: Stefan Roese To: u-boot@lists.denx.de Cc: sjg@chromium.org, awilliams@marvell.com, trini@konsulko.com, sgarapati@marvell.com, cchavva@marvell.com Subject: [PATCH v2 01/25] fdtdec: Add API to read pci bus-range property Date: Mon, 17 Aug 2020 09:07:38 +0200 Message-Id: <20200817070802.1517632-2-sr@denx.de> In-Reply-To: <20200817070802.1517632-1-sr@denx.de> References: <20200817070802.1517632-1-sr@denx.de> MIME-Version: 1.0 X-MBO-SPAM-Probability: X-Rspamd-Score: -1.31 / 15.00 / 15.00 X-Rspamd-Queue-Id: 50E621843 X-Rspamd-UID: 51410f X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean From: Suneel Garapati Add fdtdec_get_pci_bus_range to read bus-range property values. Signed-off-by: Suneel Garapati Reviewed-by: Simon Glass Signed-off-by: Stefan Roese --- Changes in v2: - Add Reviewed-by tag from Simon Changes in v1: - Add return value description to function prototype in header - Changed from using be32_to_cpup() to fdt32_to_cpu() include/fdtdec.h | 13 +++++++++++++ lib/fdtdec.c | 16 ++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/include/fdtdec.h b/include/fdtdec.h index 760b392bdf..f6759c7f8e 100644 --- a/include/fdtdec.h +++ b/include/fdtdec.h @@ -444,6 +444,19 @@ int fdtdec_get_pci_vendev(const void *blob, int node, int fdtdec_get_pci_bar32(const struct udevice *dev, struct fdt_pci_addr *addr, u32 *bar); +/** + * Look at the bus range property of a device node and return the pci bus + * range for this node. + * The property must hold one fdt_pci_addr with a length. + * @param blob FDT blob + * @param node node to examine + * @param res the resource structure to return the bus range + * @return 0 if ok, negative on error + */ + +int fdtdec_get_pci_bus_range(const void *blob, int node, + struct fdt_resource *res); + /** * Look up a 32-bit integer property in a node and return it. The property * must have at least 4 bytes of data. The value of the first cell is diff --git a/lib/fdtdec.c b/lib/fdtdec.c index 78576b530f..0b40fa374a 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -242,6 +242,22 @@ int fdtdec_get_pci_bar32(const struct udevice *dev, struct fdt_pci_addr *addr, return 0; } + +int fdtdec_get_pci_bus_range(const void *blob, int node, + struct fdt_resource *res) +{ + const u32 *values; + int len; + + values = fdt_getprop(blob, node, "bus-range", &len); + if (!values || len < sizeof(*values) * 2) + return -EINVAL; + + res->start = fdt32_to_cpu(*values++); + res->end = fdt32_to_cpu(*values); + + return 0; +} #endif uint64_t fdtdec_get_uint64(const void *blob, int node, const char *prop_name,