From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AD897C4338F for ; Sun, 15 Aug 2021 00:18:53 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D29D460FC1 for ; Sun, 15 Aug 2021 00:18:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D29D460FC1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0EAD982DFA; Sun, 15 Aug 2021 02:18:51 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Y16mML7v"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1E5CB82E05; Sun, 15 Aug 2021 02:18:49 +0200 (CEST) Received: from mail-qv1-xf34.google.com (mail-qv1-xf34.google.com [IPv6:2607:f8b0:4864:20::f34]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id CAB4282DFA for ; Sun, 15 Aug 2021 02:18:44 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=mibodhi@gmail.com Received: by mail-qv1-xf34.google.com with SMTP id kl2so7354522qvb.11 for ; Sat, 14 Aug 2021 17:18:44 -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=QYXbHJF71ncQZ/0BN7UD8xW4NHhQwpcuqYGFvxm9Eqc=; b=Y16mML7v6S58ZH2WPMVRag0mU2GEpirdkEzn8k7E9T9utz33PCHPgzoayhROkLQh3S xdamSUQ3a6QFIogw/QiIRTyBnbbxYYjuLH2QwtBJJhdqzgNTQf1yaCU8VK0Kab1JaV0T 6NblRaEUg3AEHXhsQkuavNmCQNq2+/rZc4FYcF7n+tv01749jeZijeCrsXV2t5oh1xKX lXVeHOnhrQn0naC6HQLsrsiFZ3+xTWTeLIzCCNXRquoEbx+fZtgfTuf5/dNtIaPdPsiM 44+15wHYw5n62Q+0wQBeEEthAMZl2ClpiPNU7pN3sKv0bALfg76czNhq9XtqjYzywFPR Zfhg== 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=QYXbHJF71ncQZ/0BN7UD8xW4NHhQwpcuqYGFvxm9Eqc=; b=DaRE8yrgvQKP1y/URRgeFZOzh+Y6LQJNZbyT6fJInCOm7WfwMKqxzFrErysmeCy0Tj 5WUmQIrSiq3r4g7ZF2hAyRZhFmhkhS7zGEy+/B/c/4QbU/go/VHXGe9pxPw4+j0cjkdo G6X2SZnWE6G/8krGpkyUy6ru69ygRaFSvSeVRAqo7M3E2TSUXT8MLhfl6Z3fw6mKzKgJ pAapcfk0iw0slaNRdaRyP1KbE8hJQL4Hy0ylwUv5/Kxm+1UmPCHZ3Ptd4Ypuj9kWBAIg WkRs6ewhMXA5nSAIqN087v3dFcAJFHvZCrDG4hVYyfMQdbc40C+xh3okaBQDM6BDu+CS s/9Q== X-Gm-Message-State: AOAM531hY5tWoNc2r313SQC70+2qKgWr/XBojd85MjaDiPw+KsIuUfRA jkZ5vqAl1vJKa63DmaJmGKwyuta0tkY= X-Google-Smtp-Source: ABdhPJw8ie5Ly6wzI4zF7k0MBHuKlZ/nb+e8zr0IbVAhFVbotBk7MECL14lDnkEXBeohznYEBXMyYQ== X-Received: by 2002:a05:6214:324:: with SMTP id j4mr9384323qvu.34.1628986723492; Sat, 14 Aug 2021 17:18:43 -0700 (PDT) Received: from localhost.localdomain ([66.218.48.244]) by smtp.gmail.com with ESMTPSA id x13sm2887122qki.97.2021.08.14.17.18.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Aug 2021 17:18:43 -0700 (PDT) From: Tony Dinh To: U-Boot Mailing List , Stefan Roese , Simon Glass , Ramon Fried , Joe Hershberger Cc: Tom Rini , Tony Dinh Subject: [PATCH v2 2/3] common: Add fdt network helper header file Date: Sat, 14 Aug 2021 17:17:12 -0700 Message-Id: <20210815001713.4148-2-mibodhi@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210815001713.4148-1-mibodhi@gmail.com> References: <20210806044910.23500-1-mibodhi@gmail.com> <20210815001713.4148-1-mibodhi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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.103.2 at phobos.denx.de X-Virus-Status: Clean Add include header file fdt_support_net.h Reviewed-by: Stefan Roese Acked-by: Ramon Fried Signed-off-by: Tony Dinh --- Changes in v2: - Return FDT_ERR_NOTFOUND if fdt_get_phy_addr failed to find PHY addr include/fdt_support_net.h | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 include/fdt_support_net.h diff --git a/include/fdt_support_net.h b/include/fdt_support_net.h new file mode 100644 index 0000000000..87852ffc41 --- /dev/null +++ b/include/fdt_support_net.h @@ -0,0 +1,39 @@ +/* SPDX-License-Identifier: GPL-2.0+ + * + * Copyright (C) 2021 Tony Dinh + */ + +#ifndef __fdt_support_net_h +#define __fdt_support_net_h + +/** + * This file contains convenience functions for decoding network related + * information from FDTs. It is intended to be used by board-specific code + * within U-Boot. + */ + +/* + * fdt_get_phy_addr - Return the Ethernet PHY address + * + * Convenience function to return the PHY address of an + * ethernet device given its full path as defined in the device tree + * + * @path full path to the network device node + * @return PHY address, or -FDT_ERR_NOTFOUND if it does not exist + * + * Usage examples: + * + * Get PHY address of eth0 for a Kirkwood board as defined in kirkwood.dtsi + * int phyaddr; + * char *eth0_path = "/ocp@f1000000/ethernet-controller@72000"; + * phyaddr = fdt_get_phy_addr(eth0_path); + * + * Get PHY address of eth1 for a Armada 38x board as defined + * in armada-38x.dtsi + * int phyaddr; + * char *eth1_path = "/soc/ethernet@30000"; + * phyaddr = fdt_get_phy_addr(eth1_path); + */ +int fdt_get_phy_addr(const char *path); + +#endif -- 2.20.1