From patchwork Fri Oct 16 14:23:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Padmarao Begari X-Patchwork-Id: 1383383 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=85.214.62.61; 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=USAJ0+YP; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CCT2g1VLyz9sRk for ; Sat, 17 Oct 2020 01:25:31 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C3E67824E9; Fri, 16 Oct 2020 16:24:33 +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="USAJ0+YP"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 48829824D2; Fri, 16 Oct 2020 16:24:30 +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 esa3.microchip.iphmx.com (esa3.microchip.iphmx.com [68.232.153.233]) (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 8F0B4824A8 for ; Fri, 16 Oct 2020 16:24:27 +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=1602858267; x=1634394267; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=ISonjOO4zH9fg54Eaeeu+ZbOu+cL/D4tqKJ7A9zdMW4=; b=USAJ0+YPHaO0mLynd/9Gr/V5LxQW0XKX+fAkYS6lphFDOLVJ9AYDvtaw CXIwg7o/1+HdTEMTNIVpTtpSllAGHfovXZcqN7G+DziG06G8SG8iU5Gz8 u8ptB2d3ogMrSeUkBsGgsKujvTm5aXyo8Wq+TagI3nxHGLy2wvmtA+7Mb Fdo66pF17jAWYJaPoIIkoeJwjTifcRhrss9ZO9q6hkngDeEhnlAEguIVy n5r8qH/0Hb0TRgU0JP2FgcLtaYrNC0C0ylSyOPtT2TnvTcxfCXtqLErRr 0EVqzBa9UJrFyVWDcgvwiM9XMpG2LZUJXByIxkbUPI6f1HjoqnVBEF4zy A==; IronPort-SDR: ciQLVdAGZuJ/fACU1Xmoahe2u3wMVJaaTRRZG9pESvpR7u+FnNHu5Z7N7+547KHN5N22rftS5V 4l5Ka9B1xFH9KTRNw5RLMGP9TcBa/uiYYVK+wThj+MxiJgcV2M5awP9bBk8YovD8SBTacp/ewN bKIQfTf1s6v2E0tBy0js0WRAB6UerPytEYvM612EaJtTtJXm2ZP/B8Pm0/XXN5piZDSu4WD51C TTtaDdlm1AkIHZX0Z6R4rhUeVqvN9coyzs0nneYR9FzGHqI8gNUgXTZN+l8K7HYu5jGsMf+amn WBs= X-IronPort-AV: E=Sophos;i="5.77,383,1596524400"; d="scan'208";a="95634020" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa3.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 16 Oct 2020 07:24:25 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 16 Oct 2020 07:24:25 -0700 Received: from ryzen.microchip.com (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.1979.3 via Frontend Transport; Fri, 16 Oct 2020 07:24:22 -0700 From: To: , , , , , , CC: , , , , , Padmarao Begari Subject: [PATCH v1 6/8] net: macb: Add phy address to read it from device tree Date: Fri, 16 Oct 2020 15:23:13 +0100 Message-ID: <20201016142315.30289-7-padmarao.begari@microchip.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201016142315.30289-1-padmarao.begari@microchip.com> References: <20201016142315.30289-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 From: Padmarao Begari 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 e06d85d849..fda90f4e49 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; @@ -1254,6 +1260,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); @@ -1264,6 +1272,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);