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,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 23160C4338F for ; Fri, 30 Jul 2021 03:04:29 +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 737B560527 for ; Fri, 30 Jul 2021 03:04:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 737B560527 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 6527E831D4; Fri, 30 Jul 2021 05:04:26 +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="PYcPUtJr"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 20CC7831D8; Fri, 30 Jul 2021 05:04:25 +0200 (CEST) Received: from mail-qk1-x72f.google.com (mail-qk1-x72f.google.com [IPv6:2607:f8b0:4864:20::72f]) (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 BD7CA831D4 for ; Fri, 30 Jul 2021 05:04:21 +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-qk1-x72f.google.com with SMTP id 184so8121170qkh.1 for ; Thu, 29 Jul 2021 20:04:21 -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=w0XcDS7aczPTcKXbI0iJPnCFDcWbRsMAint3RuN66b8=; b=PYcPUtJrT2hz7652x8KV5wI0z6BXnyIh5XGs3qSz5m6xnyd9vDLwOH9K0abSTirPWl kzPPmR1+GVa2D7vr+J9sfO4KKIUyuBcostEhx91ciZQ84TwQxPeRET2nRIgyDxo3QgQP siTD5esTSIC5TQ0MMgJ7NHjwhKBwrt3j+kyro4he8ZpeVdEHmmKeEwmZtAQhMQB2o5Gh C2zPucTXsBLxjKtOKMUYUr9/8K0lpuEQQrZHziHlbwvnUHBxGVIjy8uTR27KGf3788jx fbM82AURLRLnE9XsHdfmB2C87NJq9hQ6n7WTa8mYh7/iZxlHzxYXeP3UgQKHjUMOnMsb aVkQ== 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=w0XcDS7aczPTcKXbI0iJPnCFDcWbRsMAint3RuN66b8=; b=LWNKnzhE/UhEbiA4Hw0NSzvEXv1Jrdmpkg65VzrMhJhuRy2ooZ+434A83gZnzPgxcw HwHqExI8lXIm+VvM7GHPio/PNessyhnHFy09cL7IxeCFx16yhAUd5MwAbY2G+oiIXp9x ePS213djJ3Dk9ANoI7Jb1AatqgVrE4E8VkZvVnXEbxofSORxvpx4CYRIFhaoLJOJsABJ Z19t1LeT9W51XZnXj6s5fpxf73N3mNE6t7krjxNbuhqzAUzoroJbZ4ohoJAz0zRu0k5R hw2SHqOY/7Ab6/1oJ8WUKcUeI58bCwZh/z5FwGwCAYvFvksh0fRXByNzHkkZLD8V9xDb /ysA== X-Gm-Message-State: AOAM531IKD7DXbVDbBcTfFe0iymdRyp8lIC1W+dOmE+IOWPEPREJhuOi LateJoiUdjTjDuZZoNEukfpjV9IRBFo= X-Google-Smtp-Source: ABdhPJyoqLojzKO4vxHvRyiNzSwZ3LyrwTGXUSoa8Om7xaqyiJ4CBfZ7UCuDhvfjqwZkydouvkSQBw== X-Received: by 2002:a05:620a:628:: with SMTP id 8mr235660qkv.290.1627614260593; Thu, 29 Jul 2021 20:04:20 -0700 (PDT) Received: from localhost.localdomain ([66.218.48.244]) by smtp.gmail.com with ESMTPSA id s19sm99900qtx.5.2021.07.29.20.04.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jul 2021 20:04:20 -0700 (PDT) From: Tony Dinh To: U-Boot Mailing List , Stefan Roese , Suriyan Ramasami Cc: Chris Packham , Tom Rini , Tony Dinh , Simon Glass Subject: [PATCH 3/3] arm: kirkwood: GoFlex Home: Use Ethernet PHY name and address from device tree Date: Thu, 29 Jul 2021 20:02:43 -0700 Message-Id: <20210730030244.25308-4-mibodhi@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210730030244.25308-1-mibodhi@gmail.com> References: <20210730030244.25308-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 these with Ethernet PHY names from device tree. Also, read Ethernet PHY address from device tree. Signed-off-by: Tony Dinh --- board/Seagate/goflexhome/goflexhome.c | 57 +++++++++++++++++++++------ 1 file changed, 45 insertions(+), 12 deletions(-) diff --git a/board/Seagate/goflexhome/goflexhome.c b/board/Seagate/goflexhome/goflexhome.c index af8cab7bdc..52be64fb8c 100644 --- a/board/Seagate/goflexhome/goflexhome.c +++ b/board/Seagate/goflexhome/goflexhome.c @@ -1,5 +1,9 @@ // SPDX-License-Identifier: GPL-2.0+ /* + * Copyright (C) 2021 + * Tony Dinh + * Suriyan Ramasami + * * Copyright (C) 2013 Suriyan Ramasami * * Based on dockstar.c originally written by @@ -107,36 +111,65 @@ 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 /* Configure and enable MV88E1116 PHY */ void reset_phy(void) { u16 reg; - u16 devadr; - 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; - /* command to read PHY dev address */ - if (miiphy_read(name, 0xEE, 0xEE, (u16 *)&devadr)) { - printf("Err..%s could not read PHY dev address\n", - __func__); + phyaddr = fdt_get_phy_addr(eth0_path); + if (phyaddr < 0) return; - } /* * Enable RGMII delay on Tx and Rx for CPU port * Ref: sec 4.7.2 of chip datasheet */ - miiphy_write(name, devadr, MV88E1116_PGADR_REG, 2); - miiphy_read(name, devadr, MV88E1116_MAC_CTRL_REG, ®); + miiphy_write(name, phyaddr, MV88E1116_PGADR_REG, 2); + miiphy_read(name, phyaddr, MV88E1116_MAC_CTRL_REG, ®); reg |= (MV88E1116_RGMII_RXTM_CTRL | MV88E1116_RGMII_TXTM_CTRL); - miiphy_write(name, devadr, MV88E1116_MAC_CTRL_REG, reg); - miiphy_write(name, devadr, MV88E1116_PGADR_REG, 0); + miiphy_write(name, phyaddr, MV88E1116_MAC_CTRL_REG, reg); + miiphy_write(name, phyaddr, MV88E1116_PGADR_REG, 0); /* reset the phy */ - miiphy_reset(name, devadr); + miiphy_reset(name, phyaddr); printf("88E1116 Initialized on %s\n", name); } -- 2.20.1