From patchwork Tue Oct 29 21:07:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suneel Garapati X-Patchwork-Id: 1186294 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="btmhkeel"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 472kmZ5DKXz9sCJ for ; Wed, 30 Oct 2019 08:11:58 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 5F539C21E18; Tue, 29 Oct 2019 21:09:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id B9B54C21E1D; Tue, 29 Oct 2019 21:08:42 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 3C236C21E07; Tue, 29 Oct 2019 21:08:35 +0000 (UTC) Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) by lists.denx.de (Postfix) with ESMTPS id F1161C21DA6 for ; Tue, 29 Oct 2019 21:08:28 +0000 (UTC) Received: by mail-pf1-f194.google.com with SMTP id q26so6886180pfn.11 for ; Tue, 29 Oct 2019 14:08:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wHV4TYOcZZ+LF/GddY69AEM7MdRsBmLgsetgVBwFn/w=; b=btmhkeel0XNOyr1s13c4cCoEvcU98FQvjTN8lKCfmAhjIjIl8TWDkA9zx2Ktkiix9J MVloVwGxBcC+3bnNDJ89DwzNDQZpnze6CLoDnw+0BIo3KZtFC8nKDSOi/CW4Cd3p9bJW XlE2B585QXheX1S7vPLrcHP1juKP6yH+MwumceIjEEyFu96ZcpNe02g5AVbmDchmYzXb mJv4lOqNmEMy0MaoQMzBxR3nBaVJA4myxfto3btIv+a9Xa7B2Oz46h4iMvLCZYeUUEEN nowx3//ixsCh6RdfqAMq94N625r2eDq7KYIdHJKVtu/F9J9oedWK20z87MScuxQ0JyHl fsmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wHV4TYOcZZ+LF/GddY69AEM7MdRsBmLgsetgVBwFn/w=; b=ExVU6y7/LUHQAL26aoMBtXJUojYpYFASoG/lt9wT+eWVDG1vao+1LTFFCnjRzWigAB uf84hZwXx0lhhutOp9ViMEeMFcIV+u721wPor0FKzVzyTC/w9SnjgCE07Ys4pHMsWZuO veVp39AEfgnwcA9JUDqUq58KTcN7vdBAX0bACPhBuVgOxhFJt8ZERco7SORA6uvfXTwj f8k6+1dmDpSDNkWPK+zjxc9KByqgusDKGHv7Nmob+lE0kvhvnulxqFjcv6d7evnvBXRz O7563iIc65sB564NOEpdcJYr+pWekUx/E03CMKJdR5YyTIT8uQGA68UCUYSLl7VPQ8O8 cjFg== X-Gm-Message-State: APjAAAV/fir+P1mGGwuaiN4YzuAUuUXbFyybAWuiJI6GArnPQ6jDyF0x EFpwf/wlGvvhiX8wmGkmT1cVwSvY X-Google-Smtp-Source: APXvYqzAPM46J1YAncBCrJfSWzj9yrQNzv5jiiENhmKf4ysEtTQ1kdGcQ0stHVBldp8js6t0ZUWGQQ== X-Received: by 2002:a17:90a:bb01:: with SMTP id u1mr9425879pjr.12.1572383307376; Tue, 29 Oct 2019 14:08:27 -0700 (PDT) Received: from suneel.hsd1.ca.comcast.net ([2601:641:4000:c9c0:7044:5eef:7096:2413]) by smtp.gmail.com with ESMTPSA id q3sm131160pgj.54.2019.10.29.14.08.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2019 14:08:27 -0700 (PDT) From: Suneel Garapati To: u-boot Date: Tue, 29 Oct 2019 14:07:55 -0700 Message-Id: <20191029210821.1954-4-suneelglinux@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191029210821.1954-1-suneelglinux@gmail.com> References: <20191029210821.1954-1-suneelglinux@gmail.com> MIME-Version: 1.0 Cc: Tom Rini , Matthias Brugger , Joe Hershberger , Prasun Kapoor , Maen Suleiman , Chandrakala Chavva , Zi Shen Lim , Stefan Roese , Chris Packham Subject: [U-Boot] [RFC PATCH 03/29] fdtdec: add API to read pci bus-range property X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" From: Suneel Garapati Add fdtdec_get_pci_bus_range to read bus-range property values. Signed-off-by: Suneel Garapati --- include/fdtdec.h | 12 ++++++++++++ lib/fdtdec.c | 16 ++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/include/fdtdec.h b/include/fdtdec.h index f1e58f9732..afbd22b25a 100644 --- a/include/fdtdec.h +++ b/include/fdtdec.h @@ -441,6 +441,18 @@ int fdtdec_get_pci_vendev(const void *blob, int node, int fdtdec_get_pci_bar32(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 + */ + +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 17736ce665..fb61eda1fd 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -237,6 +237,22 @@ int fdtdec_get_pci_bar32(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 = be32_to_cpup(values++); + res->end = be32_to_cpup(values); + + return 0; +} #endif uint64_t fdtdec_get_uint64(const void *blob, int node, const char *prop_name,