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 CE54DC433F5 for ; Mon, 2 May 2022 07:01:30 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0317880FC8; Mon, 2 May 2022 09:01:24 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1651474884; bh=8R/CSHndYfF25ryJ6rN3Sz17hbdsjhLbvwoytbKeR/w=; h=Date:Subject:To:Cc:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=vkLGZLc6wUe0uVg3ot2TQ9xtUKciCv85GDu0B2GHcswwiWyYsQqvdiSTT3DU7gv3d ytPiGHo7pF2AAqt7bB1yMmiANUVT0Pihd3+URU7VNsYoF0ZTnm7Z9UjBIDiK582tH4 mW153FwYavyyPDwZaBvlIDtb06rlZt5NiGiSxzBqE5H7X4uTQL0gLMSac2xTywb/vc xCmE5xh+IELEVsAJozvk++dR6Tvi872mSVejWdjbcI76wopk4tDxWW9k0PjbXZlQC7 qRR76J6eC3WnVVNDZFIQ2/ejOIHmMI5JY9qqQtvlSdssZLcqVxcUFlE9v7S09etdRU m+i82tpDy6j8g== Received: by phobos.denx.de (Postfix, from userid 109) id 2911783439; Mon, 2 May 2022 09:01:21 +0200 (CEST) Received: from mout-u-204.mailbox.org (mout-u-204.mailbox.org [IPv6:2001:67c:2050:101:465::204]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 761FC80F7B for ; Mon, 2 May 2022 09:01:18 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sr@denx.de Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:105:465:1:2:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-204.mailbox.org (Postfix) with ESMTPS id 4KsDXD2GGNz9sRY; Mon, 2 May 2022 09:01:16 +0200 (CEST) Message-ID: <655df3b8-5ee1-5443-ea8f-e53cde98ccef@denx.de> Date: Mon, 2 May 2022 09:00:40 +0200 MIME-Version: 1.0 Subject: Re: [PATCH u-boot-marvell 06/19] net: mdio-uclass: add dm_phy_find_by_ofnode() helper Content-Language: en-US To: =?UTF-8?Q?Marek_Beh=c3=ban?= Cc: Robert Marko , =?UTF-8?Q?Pali_Roh=c3=a1r?= , U-Boot-Denx , Ramon Fried , Joe Hershberger , =?UTF-8?Q?Marek_Beh=c3=ban?= , Heinrich Schuchardt , Vladimir Oltean , Simon Glass References: <20220427104202.1205-1-kabel@kernel.org> <20220427104202.1205-7-kabel@kernel.org> From: Stefan Roese In-Reply-To: <20220427104202.1205-7-kabel@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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.5 at phobos.denx.de X-Virus-Status: Clean On 27.04.22 12:41, Marek Behún wrote: > From: Marek Behún > > Add helper to resolve PHY node from it's ofnode via DM MDIO subsystem. > > Signed-off-by: Marek Behún Reviewed-by: Stefan Roese Thanks, Stefan > --- > include/miiphy.h | 9 +++++++++ > net/mdio-uclass.c | 22 ++++++++++++++++++++++ > 2 files changed, 31 insertions(+) > > diff --git a/include/miiphy.h b/include/miiphy.h > index 110921f20d..c66a1845b5 100644 > --- a/include/miiphy.h > +++ b/include/miiphy.h > @@ -188,6 +188,15 @@ int dm_mdio_write(struct udevice *mdio_dev, int addr, int devad, int reg, u16 va > */ > int dm_mdio_reset(struct udevice *mdio_dev); > > +/** > + * dm_phy_find_by_ofnode - Find PHY device by ofnode > + * > + * @phynode: PHY's ofnode > + * > + * Return: pointer to phy_device, or NULL on error > + */ > +struct phy_device *dm_phy_find_by_ofnode(ofnode phynode); > + > /** > * dm_mdio_phy_connect - Wrapper over phy_connect for DM MDIO > * > diff --git a/net/mdio-uclass.c b/net/mdio-uclass.c > index 7593618d9a..4401492ca0 100644 > --- a/net/mdio-uclass.c > +++ b/net/mdio-uclass.c > @@ -129,6 +129,28 @@ static int dm_mdio_pre_remove(struct udevice *dev) > return 0; > } > > +struct phy_device *dm_phy_find_by_ofnode(ofnode phynode) > +{ > + struct mdio_perdev_priv *pdata; > + struct udevice *mdiodev; > + u32 phy_addr; > + > + if (ofnode_read_u32(phynode, "reg", &phy_addr)) > + return NULL; > + > + if (uclass_get_device_by_ofnode(UCLASS_MDIO, > + ofnode_get_parent(phynode), > + &mdiodev)) > + return NULL; > + > + if (device_probe(mdiodev)) > + return NULL; > + > + pdata = dev_get_uclass_priv(mdiodev); > + > + return phy_find_by_mask(pdata->mii_bus, BIT(phy_addr)); > +} > + > struct phy_device *dm_mdio_phy_connect(struct udevice *mdiodev, int phyaddr, > struct udevice *ethdev, > phy_interface_t interface) Viele Grüße, Stefan Roese -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de