From patchwork Mon Dec 14 10:55:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Padmarao Begari X-Patchwork-Id: 1415894 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=iG9QBy48; 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CvdtW1DxGz9sS8 for ; Mon, 14 Dec 2020 22:08:49 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 127688280E; Mon, 14 Dec 2020 12:08:25 +0100 (CET) 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="iG9QBy48"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1213C8280E; Mon, 14 Dec 2020 12:08:22 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) (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 CC96E8280B for ; Mon, 14 Dec 2020 12:08:17 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=microchip.com Authentication-Results: phobos.denx.de; spf=pass 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=1607944098; x=1639480098; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=6+aqnTr1lD3wXJGHSlxpAc0IzL+NxEyTQwB2ydiwf2k=; b=iG9QBy48FTCWHuf//OF3SDCk7yB4+cU0AsjvXNvs66U8JLDvoujq0xMx IF994vWQsHqVkjPigdoRswdPUFbQusu/rc/2Q+LeBT8As89z9knPqGPxV 0TJd/Ho0Ra/diJUwJ9Dk5gsCLXcLE+iRLZvzG05YJup6H9DvzVKnYvELg B6JgSrw9gDx+SwtgJe7SXotFkE9ZR2JTOGFn+wMxNfCyZJeU57+jTnLGI ZOdWKTTrCZpeiBnH2ZQeU9C48QHMPwDEAbYaK+qAZWCFf3lG3YcrbAdPd abbmJapynf1R0QEThnLWox6BueUIgGNB44U3TqD6DyU3P7BwPS/WdT5Pn A==; IronPort-SDR: ecNwEYkIfipuF0AbtR46OdErLaSwZ5QaTSdIdJpPxJBZVWHEZhjwjyM/jp0f2sJlwKwSUgTzDC DTNaGVMe1aMoQ7fZeEnaPsZLEdhaiXuARksWxt2Wk0Te83dF0YTGdIeEeQmYoVbOFEs32UNOhc OzfE0cISFub5XQ7PCasxw6y4trQBt1gyMDEEHd9+ZMGXZETvo6Kn6lpdxIXf/JqRu+zhsLpvkT Dcv4vAtXbGl57rPkduopujQeThhbsaqJBhb7LI1J9fDmLnuuDiNEtBSK1IZCJiFCR66Gwz4k35 1aw= X-IronPort-AV: E=Sophos;i="5.78,418,1599548400"; d="scan'208";a="97013233" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 14 Dec 2020 04:08:17 -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; Mon, 14 Dec 2020 04:08:16 -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; Mon, 14 Dec 2020 04:08:11 -0700 From: Padmarao Begari To: , , , , , , , CC: , , , , , Padmarao Begari Subject: [PATCH v6 3/7] net: macb: Add phy address to read it from device tree Date: Mon, 14 Dec 2020 16:25:57 +0530 Message-ID: <20201214105601.2943-4-padmarao.begari@microchip.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201214105601.2943-1-padmarao.begari@microchip.com> References: <20201214105601.2943-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 Reviewed-by: Anup Patel Reviewed-by: Bin Meng Tested-by: Bin Meng --- drivers/net/macb.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/net/macb.c b/drivers/net/macb.c index 626ee49227..9b45187e5a 100644 --- a/drivers/net/macb.c +++ b/drivers/net/macb.c @@ -531,6 +531,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; @@ -1311,6 +1317,7 @@ static int macb_eth_probe(struct udevice *dev) { struct eth_pdata *pdata = dev_get_platdata(dev); struct macb_device *macb = dev_get_priv(dev); + struct ofnode_phandle_args phandle_args; const char *phy_mode; int ret; @@ -1323,6 +1330,12 @@ static int macb_eth_probe(struct udevice *dev) return -EINVAL; } + /* Read phyaddr from DT */ + if (!dev_read_phandle_with_args(dev, "phy-handle", NULL, 0, 0, + &phandle_args)) + macb->phy_addr = ofnode_read_u32_default(phandle_args.node, + "reg", -1); + macb->regs = (void *)pdata->iobase; macb->is_big_endian = (cpu_to_be32(0x12345678) == 0x12345678);