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 B0C8EC61DA4 for ; Thu, 9 Feb 2023 12:24:34 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 90F7285F2A; Thu, 9 Feb 2023 13:24:11 +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="snKblc9G"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 55D8185D99; Thu, 9 Feb 2023 10:55:07 +0100 (CET) Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) (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 D4F2285CF2 for ; Thu, 9 Feb 2023 10:55:03 +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 fllv0034.itg.ti.com ([10.64.40.246]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 3199svoj063009; Thu, 9 Feb 2023 03:54:57 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1675936497; bh=/lIvZ8/RIVwFLLECyI5IiBi3DmB+m5fek8KsKaKrTKw=; h=Date:CC:Subject:To:References:From:In-Reply-To; b=snKblc9G3T+8AhLCpuG342fQqjXFP2EANNNc3NOFRee0dD8c0Wv2ZUE6SE2gbEDTv A5g0aSFPc86vW8krVCG/hw1pBlNPrShl0TzGk8NDR5AJaR46xYuHqFtVJn5fcktibJ BBdUAhT50gBGqjmzzxjDyHlHY3EHqgIcTdgLi8Go= Received: from DLEE101.ent.ti.com (dlee101.ent.ti.com [157.170.170.31]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 3199sv2P057673 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 9 Feb 2023 03:54:57 -0600 Received: from DLEE108.ent.ti.com (157.170.170.38) by DLEE101.ent.ti.com (157.170.170.31) 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 03:54:56 -0600 Received: from lelv0326.itg.ti.com (10.180.67.84) by DLEE108.ent.ti.com (157.170.170.38) 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 03:54:56 -0600 Received: from [172.24.145.61] (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 3199srO5010302; Thu, 9 Feb 2023 03:54:54 -0600 Message-ID: <493386bb-ee49-d4f1-a96a-0de74ca5b9f0@ti.com> Date: Thu, 9 Feb 2023 15:24:53 +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 , Ulf Samuelsson References: <20230207082527.2319-1-ulf@emagii.com> <3c810d57-d919-13a3-8309-e01dfd59190f@ti.com> <09adde15-36ac-f3ff-55b6-78dcc783b99a@emagii.com> From: Siddharth Vadapalli In-Reply-To: <09adde15-36ac-f3ff-55b6-78dcc783b99a@emagii.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit 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 On 09/02/23 14:56, Ulf Samuelsson wrote: > > Den 2023-02-09 kl. 08:29, skrev Siddharth Vadapalli: >> 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. >> > We had an unusual H/W where the PHY (actually a switch) was connected to the > second Ethernet port. All boards I have seen have the PHY connected to the first > port or have both ports connected. > > IIRC correctly (this patch is > 2 years old), > we had bad data in the bits (15:8) and this is why only the 8 bits. > Only bits [1:0] are used anyway. Thank you for clarifying. Reviewed-by: Siddharth Vadapalli Regards, Siddharth.