Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id A8E37C05027 for ; Thu, 9 Feb 2023 12:24:02 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id F012385CA7; Thu, 9 Feb 2023 13:23:59 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="VhnDLrnl"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 69A4585E74; Thu, 9 Feb 2023 08:29:27 +0100 (CET) Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) (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 0741C85EA8 for ; Thu, 9 Feb 2023 08:29:23 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=s-vadapalli@ti.com Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 3197TGgv025375; Thu, 9 Feb 2023 01:29:16 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1675927756; bh=qvXDbwNJBVCK8XfK7Cz8kmvIhHOBWCpbrQDO1xicEnU=; h=Date:CC:Subject:To:References:From:In-Reply-To; b=VhnDLrnl0Nn6heYIfuSr38hrEGP4TNATCNPg/R/E7S0xb0cMAdx+tfX8fNvh6VbcF aRG0auKpEWLjTc71xjWltRKMNNanukmOAkdQx2EyQptx87dDnpGa6K/NHkrzf5l89j U/H8u0PPRx+Fux1MxoBxUzkiq93YpEfiA05vCaKo= Received: from DFLE114.ent.ti.com (dfle114.ent.ti.com [10.64.6.35]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 3197TGG9058126 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 9 Feb 2023 01:29:16 -0600 Received: from DFLE108.ent.ti.com (10.64.6.29) by DFLE114.ent.ti.com (10.64.6.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.16; Thu, 9 Feb 2023 01:29:16 -0600 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE108.ent.ti.com (10.64.6.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.16 via Frontend Transport; Thu, 9 Feb 2023 01:29:16 -0600 Received: from [172.24.145.61] (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 3197TD1M019329; Thu, 9 Feb 2023 01:29:14 -0600 Message-ID: <3c810d57-d919-13a3-8309-e01dfd59190f@ti.com> Date: Thu, 9 Feb 2023 12:59:13 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 CC: , Joe Hershberger , Ramon Fried , Praneeth Bajjuri , , Subject: Re: [PATCH] cpsw_mdio.c: Use correct reg in cpsw_mdio_get_alive Content-Language: en-US To: Ulf Samuelsson References: <20230207082527.2319-1-ulf@emagii.com> From: Siddharth Vadapalli In-Reply-To: <20230207082527.2319-1-ulf@emagii.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Mailman-Approved-At: Thu, 09 Feb 2023 13:23:57 +0100 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.6 at phobos.denx.de X-Virus-Status: Clean Hello Ulf, On 07/02/23 13:55, Ulf Samuelsson wrote: > cpsw_mdio_get_alive reads the wrong register. > See page 2316 in SPRUH73Q AM335x TRM > > Signed-off-by: Ulf Samuelsson > Cc: Joe Hershberger > Cc: Ramon Fried > --- > drivers/net/ti/cpsw_mdio.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/net/ti/cpsw_mdio.c b/drivers/net/ti/cpsw_mdio.c > index a5ba73b739..ac791faa81 100644 > --- a/drivers/net/ti/cpsw_mdio.c > +++ b/drivers/net/ti/cpsw_mdio.c > @@ -51,7 +51,7 @@ struct cpsw_mdio_regs { > #define USERACCESS_PHY_REG_SHIFT (21) > #define USERACCESS_PHY_ADDR_SHIFT (16) > #define USERACCESS_DATA GENMASK(15, 0) > - } user[0]; > + } user[2]; > }; > > #define CPSW_MDIO_DIV_DEF 0xff > @@ -366,8 +366,8 @@ u32 cpsw_mdio_get_alive(struct mii_dev *bus) > struct cpsw_mdio *mdio = bus->priv; > u32 val; > > - val = readl(&mdio->regs->control); > - return val & GENMASK(15, 0); > + val = readl(&mdio->regs->alive); > + return val & GENMASK(7, 0); Referring to the TRM for AM335x at [0], on page 2401, the MDIOALIVE register reports the presence of Ethernet PHYs up to ADDR 31. Also, the cpsw driver: drivers/net/ti/cpsw.c which uses the cpsw_mdio_get_alive() function, expects the return value to be a 16 bit value. Therefore, I believe that the GENMASK should retain the previous value of "GENMASK(15, 0)", while only the register being read needs to be changed from "control" to "alive". Please let me know if I misunderstood something regarding your implementation. [0] https://www.ti.com/lit/ug/spruh73q/spruh73q.pdf Regards, Siddharth. > } > > struct mii_dev *cpsw_mdio_init(const char *name, phys_addr_t mdio_base,