From patchwork Tue Nov 10 10:34:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Padmarao Begari X-Patchwork-Id: 1397523 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=rf1zegzz; 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 4CVl0b2fVTz9s1l for ; Tue, 10 Nov 2020 21:46:39 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 08C0782585; Tue, 10 Nov 2020 11:46:13 +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="rf1zegzz"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CF0E482585; Tue, 10 Nov 2020 11:46:06 +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=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from esa4.microchip.iphmx.com (esa4.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 9968282553 for ; Tue, 10 Nov 2020 11:46:00 +0100 (CET) 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=1605005160; x=1636541160; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=pLZywbhFhv/wbHMI7EiAgRf+jAJ7YXcLZ79NMxMPOVE=; b=rf1zegzzm6d8Tb5H0jh/vSVTO1k0P2oVk5yZ+j/8JzPBkoNDRZCay7wJ v+Chum7XNpY+LMODk3B8bX8ttDB5BKGTMrXeuliq/v5m8gCjMdAxViFN+ NFZoUyarvaoYmerg4QJx1uYn0CAEYJz04cc5SLanAlNGTZpWG5KMLMyUZ g4UGrCFy5/w1CPQr2mR0Eo98Vjvi+KLmkZRR16Q/MSJxxfjFhapULs96R R8v5iENjDlcoOvSfRy2bhwxjqESM6VRBFCaDCfdWdulVNb2l6PHetVjZs KeBghyMUDawJrY1EzmLxdrLHutTtZHAow7uI8skawy51O/4x7kjZ31B1G A==; IronPort-SDR: QXlkW2yjoL8mr56GBIHwBZfOFFq/LPxlAjG5p2Ym8AJKGxiJYxfq6i5cKXoEtg7/iCYbmNVrlK DRlBmmcSX0lkMhJ5QeQ1c/WIzsNE+4qU978v/0oAEnusic+AGJJLE/jWAGvWFPnu9l385Oy+nI xlJExVGA/aQMPvCw56XFheKAroZo3eCbvlA0CK5ctJx751idom7MN2AsRa2bHufIg23K3fsp4y jIAs7lbP9sH1u3p7nh2095zUwaOGSs2idmajIfEDba3bJvriDzg5L7MlhN34kW7jSaY0QXFzGE bCc= X-IronPort-AV: E=Sophos;i="5.77,466,1596524400"; d="scan'208";a="93108129" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 10 Nov 2020 03:46:00 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Tue, 10 Nov 2020 03:45:59 -0700 Received: from padmarao-VirtualBox.microchip.com (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.1979.3 via Frontend Transport; Tue, 10 Nov 2020 03:45:54 -0700 From: Padmarao Begari To: , , , , , , , CC: , , , , , Padmarao Begari Subject: [PATCH v3 3/7] net: macb: Add phy address to read it from device tree Date: Tue, 10 Nov 2020 16:04:10 +0530 Message-ID: <20201110103414.10142-4-padmarao.begari@microchip.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201110103414.10142-1-padmarao.begari@microchip.com> References: <20201110103414.10142-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 --- drivers/net/macb.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/net/macb.c b/drivers/net/macb.c index 9ccbb7a166..81b1f1ba26 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; @@ -1315,11 +1321,12 @@ 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; - phy_mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "phy-mode", - NULL); + phy_mode = dev_read_prop(dev, "phy-mode", NULL); + if (phy_mode) macb->phy_interface = phy_get_interface_by_name(phy_mode); if (macb->phy_interface == -1) { @@ -1327,6 +1334,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);