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,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 9234EC07E96 for ; Thu, 15 Jul 2021 08:06:06 +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 95DCB610D1 for ; Thu, 15 Jul 2021 08:06:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 95DCB610D1 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=denx.de 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 ED31D82903; Thu, 15 Jul 2021 10:06:02 +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=1626336363; bh=Avo4oHljsNAwQp9ylOofPPv0xnu+CzShA8LUNrOhf+E=; h=Subject:To:Cc:References:From:Date:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=I4sCDoKWZEN+vCdo/FOaqw8COcKHvF7c0kBeBAfLosvHiyypMZX9y7d69uHOWx5ZL ajXEev9mz35yRyxVzOPNZlBWPy5pOUOxvShK40NZo+jX/g3UPwnaRqWFvPlOaoE5Mg fXUPl40xpH9rCmzooYpBUJWUvMfZMcQEyzqzFlnopd0mB0EyQLSIi80T9MXkw1hpbv MJvHyOv44stOOfgf6N4UIideoBUkGBk795qU4XgTYQ6udE/3vC/jKiwO0fF8m1abSH wb/fCQ0yU2baw4HN3cTvNwE0TvGAEb7RyJ3r9DGEBnmnnJX1xhoecAuizKrEcR++Y5 coNAVR9Jt5iMA== Received: by phobos.denx.de (Postfix, from userid 109) id E960082977; Thu, 15 Jul 2021 10:05:59 +0200 (CEST) Received: from mout-u-204.mailbox.org (mout-u-204.mailbox.org [IPv6:2001:67c:2050:1::465:204]) (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 3F1AC82903 for ; Thu, 15 Jul 2021 10:05:56 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sr@denx.de Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-204.mailbox.org (Postfix) with ESMTPS id 4GQRl804GYzQkB9; Thu, 15 Jul 2021 10:05:56 +0200 (CEST) Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter01.heinlein-hosting.de (spamfilter01.heinlein-hosting.de [80.241.56.115]) (amavisd-new, port 10030) with ESMTP id uIOuodoSgk8T; Thu, 15 Jul 2021 10:05:52 +0200 (CEST) Subject: Re: [PATCH v3 3/4] NSA310S : Use Ethernet PHY name from device tree To: Tony Dinh , U-Boot Mailing List Cc: Tom Rini , Chris Packham References: <20210707090647.11360-1-mibodhi@gmail.com> From: Stefan Roese Message-ID: <273bc7f5-e730-d461-0935-7ec84090ffaf@denx.de> Date: Thu, 15 Jul 2021 10:05:52 +0200 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: de-DE Content-Transfer-Encoding: 8bit X-MBO-SPAM-Probability: X-Rspamd-Score: -2.90 / 15.00 / 15.00 X-Rspamd-Queue-Id: 104361860 X-Rspamd-UID: 9cc567 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 Hi Tony, On 15.07.21 03:11, Tony Dinh wrote: > Hi Stefan, > > I will need to resend this patch (V3 3/4). Ok. Please add the patch version and history back into the patches next time again. Thanks, Stefan > Thanks, > Tony > > On Wed, Jul 7, 2021 at 2:07 AM Tony Dinh > wrote: > > 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. > > 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 | 47 +++++++++++++++++++++++++++++------ >  1 file changed, 39 insertions(+), 8 deletions(-) > > diff --git a/board/zyxel/nsa310s/nsa310s.c > b/board/zyxel/nsa310s/nsa310s.c > index cd4a7723b1..b71de4e11f 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"; > +       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 > Viele Grüße, Stefan -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de