From patchwork Thu Oct 22 07:07:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Padmarao Begari X-Patchwork-Id: 1386004 X-Patchwork-Delegate: uboot@andestech.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=quarantine dis=none) header.from=microchip.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=microchip.com header.i=@microchip.com header.a=rsa-sha256 header.s=mchp header.b=EFFqf4nw; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CGzMf4bVPz9sTc for ; Thu, 22 Oct 2020 18:22:22 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 32BE282456; Thu, 22 Oct 2020 09:22:10 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=quarantine dis=none) header.from=microchip.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=microchip.com header.i=@microchip.com header.b="EFFqf4nw"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 67D0382452; Thu, 22 Oct 2020 09:22:09 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from esa5.microchip.iphmx.com (esa5.microchip.iphmx.com [216.71.150.166]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 18F6B82441 for ; Thu, 22 Oct 2020 09:22:05 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=microchip.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=Padmarao.Begari@microchip.com DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1603351327; x=1634887327; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=3oHIMg9ZBgBocn0QxUESxExZQu1Tni9L1uVdmN+LLik=; b=EFFqf4nwy6lejcSDDAVfxfufP/UdePZYvtYWgklDegIjt6hPwDCFZqZU 4JF8IdeHdc9PKOBSy8FT+fnb8p8zDDMqzsVZ6dUXasD9Q28+Nl0uRzHc4 79Pg1gA9vHi9P2/fo8IgcBnFPiWdJBrlPKmyyVkV+SJsNh0bOSmFm2wHi 5bBEmxvagfJygFGCb5ZUVF85x/MShH2A4e5SlFlGUZGOxQTcJ3EMCGcPu N/HGEPUBMgtIJkwkIR3oqVQx25smtcIY1PwL/wHg4MJS+xoZCB2z4JwFb UQ93E4hBZexAL+amJREAq1rovTTFd226DFXbDzphygofLHEvnxp6mmnDJ g==; IronPort-SDR: /N6UqZT8QIY0u696en4NBZV4HAXZM8AJHyYgCFl/6KTDQ0h1UUs4Vu6C1H6ffivICFNUAe9/P3 CgZLEg2e2MgZNTBaFDdObhOchS9kuh4stULVU+59va7BOnyC8KtgqK3OQ0XQ9IWpM5CvO/f+5q 14nvbiyku0HzT9kQdRy5I2nQG0lhSo7sN31TvXfhYopHmtZmbHVjOx99MgwX8KCOAG3bBBGMKA O2a6mS7E8cwxh76+/vE7QzWBIQgLjCykV5/cFxLf1f3s9TY7ftBY/Fs1XVNWjfi/fH7VIC2L3f VVI= X-IronPort-AV: E=Sophos;i="5.77,404,1596524400"; d="scan'208";a="95584599" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 22 Oct 2020 00:22:04 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 22 Oct 2020 00:22:00 -0700 Received: from padmarao-VirtualBox.microchip.com (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.1979.3 via Frontend Transport; Thu, 22 Oct 2020 00:21:54 -0700 From: Padmarao Begari To: , , , , , , CC: , , , , , Padmarao Begari Subject: [PATCH v2 3/7] net: macb: Add phy address to read it from device tree Date: Thu, 22 Oct 2020 12:37:11 +0530 Message-ID: <20201022070715.14759-4-padmarao.begari@microchip.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201022070715.14759-1-padmarao.begari@microchip.com> References: <20201022070715.14759-1-padmarao.begari@microchip.com> MIME-Version: 1.0 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.102.3 at phobos.denx.de X-Virus-Status: Clean Read phy address from device tree and use it to find the phy device if not found then search in the range of 0 to 31. Signed-off-by: Padmarao Begari --- drivers/net/macb.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/net/macb.c b/drivers/net/macb.c index e0e86a274e..7f592d510c 100644 --- a/drivers/net/macb.c +++ b/drivers/net/macb.c @@ -477,6 +477,12 @@ static int macb_phy_find(struct macb_device *macb, const char *name) int i; u16 phy_id; + phy_id = macb_mdio_read(macb, macb->phy_addr, MII_PHYSID1); + if (phy_id != 0xffff) { + printf("%s: PHY present at %d\n", name, macb->phy_addr); + return 0; + } + /* Search for PHY... */ for (i = 0; i < 32; i++) { macb->phy_addr = i; @@ -1256,6 +1262,8 @@ static int macb_eth_probe(struct udevice *dev) struct macb_device *macb = dev_get_priv(dev); const char *phy_mode; int ret; + u32 phy_addr; + ofnode node; phy_mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "phy-mode", NULL); @@ -1266,6 +1274,13 @@ static int macb_eth_probe(struct udevice *dev) return -EINVAL; } + /* Look for a PHY node under the Ethernet node */ + node = dev_read_subnode(dev, "ethernet-phy"); + if (ofnode_valid(node)) { + ofnode_read_u32(node, "reg", &phy_addr); + macb->phy_addr = phy_addr; + } + macb->regs = (void *)pdata->iobase; macb->is_big_endian = (cpu_to_be32(0x12345678) == 0x12345678);