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.8 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,URIBL_BLOCKED,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 3A919C6377A for ; Fri, 16 Jul 2021 04:15:08 +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 26ACF613D0 for ; Fri, 16 Jul 2021 04:15:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 26ACF613D0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 30C3A81668; Fri, 16 Jul 2021 06:15:04 +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="hsov9Rd1"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 158C081E47; Fri, 16 Jul 2021 06:15:01 +0200 (CEST) Received: from mail-qt1-x836.google.com (mail-qt1-x836.google.com [IPv6:2607:f8b0:4864:20::836]) (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 6DC8D8020E for ; Fri, 16 Jul 2021 06:14:57 +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-qt1-x836.google.com with SMTP id w26so6182789qto.9 for ; Thu, 15 Jul 2021 21:14:57 -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=o1zeC1ep4xBqqIewJ/S7/oaO+03QYm36B4pMHLNtSqE=; b=hsov9Rd1ZriSk22I+qeKt7T9suIDw1VFYIFjraxSDpJS67fQW1wkYNvVMUWJSFb3ep 7Epp3WkHDuuwrx7vXk2bH2NcLhY3OmTkSkb3AFPBGLZoL1Syr1t9n1gagq/9A5utSAC/ wB+33nuZG2S5JyN+NaCMK7C3Guw9pwwfJuzBE9hsUG9qwLWq9ZiCrDDsp57Vnyq1q2G0 Vg9rNemmY7kPPmyeizfqsCDmnq0KIITuLzbBYL+gGKWXh4z95l2hjiQgIJk94H8az05w OqgwdPIN2dlGYE0h3wTAsldWzrWnId+ovInFtGp2KnBmTwj9kyLq1WQWCbU9+zwDb0IW zERA== 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=o1zeC1ep4xBqqIewJ/S7/oaO+03QYm36B4pMHLNtSqE=; b=PrIdG50IavNIKC4xrVS+axYvFQeUOE2zrqBK2fjNRo40jgIMzdhhHLoMDTT36+LAaS a/VuwDGMfKKEvjF5Cl6QMfkojJu+tFnBQ7vN3XXcGk4Zzk+1oOjMDaMXoB71J99A+7CV S/Np+e8THKlE30uPIsahaKfeofTvdz0UEIr1FLYOVTq8iga3ME3KfRHfrHXWJbhcb+f0 /iDNMW+Qc0EAGrSj95xJ6Cgu5YERAURZpVATsFxa9adGuFj2egoLaf32FjaaHMgxVwc+ t3re7Sx7i3GIrtQoV9XyYcF6gNGlxNzCToGvZdZh5Lk9I/e2MuW58SUluPLVT5iD3RwS w6QQ== X-Gm-Message-State: AOAM532tLIX6a/9Z2JbGzADv0lRNDVL42ZNBISXTNzyBOp3DxZ1YgQlk o9fxiafWoWC/EIdxFDylBNM= X-Google-Smtp-Source: ABdhPJytFsoOVbgvNSyIiGfmmMI2+Y7qODfdAartivk3dFY81LOAbC62uLJ0yWKSSvjVoMYe0kf9mA== X-Received: by 2002:a05:622a:1102:: with SMTP id e2mr7295073qty.370.1626408896107; Thu, 15 Jul 2021 21:14:56 -0700 (PDT) Received: from localhost.localdomain ([66.218.48.116]) by smtp.gmail.com with ESMTPSA id d7sm2830232qth.70.2021.07.15.21.14.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jul 2021 21:14:55 -0700 (PDT) From: Tony Dinh To: Stefan Roese , U-Boot Mailing List Cc: Tom Rini , Chris Packham , Tony Dinh Subject: [RESEND PATCH v3 3/4] NSA310S : Use Ethernet PHY name from device tree Date: Thu, 15 Jul 2021 21:13:37 -0700 Message-Id: <20210716041337.13300-1-mibodhi@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210707090647.11360-1-mibodhi@gmail.com> References: <20210707090647.11360-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 In DM Ethernet, the old "egiga0" name is no longer valid, so replace it with Ethernet PHY name from device tree. Also, Ethernet PHY address is available so read it from device tree. Reviewed-by: Stefan Roese Signed-off-by: Tony Dinh --- Changes in v3: - Get eth0 PHY address from device tree Changes in v2: - Correct copyright board/zyxel/nsa310s/nsa310s.c | 49 ++++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 9 deletions(-) diff --git a/board/zyxel/nsa310s/nsa310s.c b/board/zyxel/nsa310s/nsa310s.c index cd4a7723b1..881cacaaa2 100644 --- a/board/zyxel/nsa310s/nsa310s.c +++ b/board/zyxel/nsa310s/nsa310s.c @@ -1,8 +1,7 @@ // SPDX-License-Identifier: GPL-2.0+ /* - * Copyright (C) 2015 - * Gerald Kerma - * Tony Dinh + * Copyright (C) 2015, 2021 Tony Dinh + * Copyright (C) 2015 Gerald Kerma */ #include @@ -81,21 +80,51 @@ int board_init(void) return 0; } +static int fdt_get_phy_addr(const char *path) +{ + const void *fdt = gd->fdt_blob; + const u32 *reg; + const u32 *val; + int node, phandle, addr; + + /* Find the node by its full path */ + node = fdt_path_offset(fdt, path); + if (node >= 0) { + /* Look up phy-handle */ + val = fdt_getprop(fdt, node, "phy-handle", NULL); + if (val) { + phandle = fdt32_to_cpu(*val); + if (!phandle) + return -1; + /* Follow it to its node */ + node = fdt_node_offset_by_phandle(fdt, phandle); + if (node) { + /* Look up reg */ + reg = fdt_getprop(fdt, node, "reg", NULL); + if (reg) { + addr = fdt32_to_cpu(*reg); + return addr; + } + } + } + } + return -1; +} + #ifdef CONFIG_RESET_PHY_R void reset_phy(void) { u16 reg; - u16 phyaddr; - char *name = "egiga0"; + int phyaddr; + char *name = "ethernet-controller@72000"; + char *eth0_path = "/ocp@f1000000/ethernet-controller@72000/ethernet0-port@0"; if (miiphy_set_current_dev(name)) return; - /* read PHY dev address */ - if (miiphy_read(name, 0xee, 0xee, (u16 *) &phyaddr)) { - printf("could not read PHY dev address\n"); + phyaddr = fdt_get_phy_addr(eth0_path); + if (phyaddr < 0) return; - } /* set RGMII delay */ miiphy_write(name, phyaddr, MV88E1318_PGADR_REG, MV88E1318_MAC_CTRL_PG); @@ -131,5 +160,7 @@ void reset_phy(void) /* downshift */ miiphy_write(name, phyaddr, 0x10, 0x3860); miiphy_write(name, phyaddr, 0x0, 0x9140); + + printf("MV88E1318 PHY initialized on %s\n", name); } #endif /* CONFIG_RESET_PHY_R */ -- 2.20.1