From mboxrd@z Thu Jan 1 00:00:00 1970 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 A527FC433EF for ; Fri, 4 Mar 2022 13:27:54 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 999A983CE4; Fri, 4 Mar 2022 14:27:21 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=collabora.com header.i=@collabora.com header.b="f1CdjOtE"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0F08D83D4D; Fri, 4 Mar 2022 13:24:10 +0100 (CET) Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) (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 3444683D48 for ; Fri, 4 Mar 2022 13:24:04 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ariel.dalessandro@collabora.com Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: adalessandro) with ESMTPSA id 760771F466C0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1646396643; bh=F1yGVj5G8h2eMbo1qVZwWFSlG58luPRgeQcw07hDgXw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f1CdjOtEU2qDpu7q6i5JUi8GC3zIRjAbr1d0qLecUxL5QLAIQeTG1R1rMdssZRYWQ 67pxWvqS7PyJusvbNfy5WfEpW+OCqCD/HHwZOQ2kjCpVST+IK4WaCgEJyAxm4La8rJ NR3iqUNofTeta+ulzxmoiW2sEpkOQP7tPUpYYyUSEmzlKtIV8nqrSzirskudKLAn83 C9YiWPO6rOIp1/v2MunGvGyG8PjmM/4lJJKUhAa6C0ShgC/xLlPfmJC5aZSUvUKKXy 1EnxR/wvbxJY0ri8PlshloJ+cwhcTIczGy6XUeCcyWFQjmjOXxi0ST0+Hrt4R0eBV0 xl7/brpd7a1Og== From: Ariel D'Alessandro To: u-boot@lists.denx.de Cc: Peter.Hoyes@arm.com, aford173@gmail.com, alice.guo@nxp.com, andre.przywara@arm.com, andrey.zhizhikin@leica-geosystems.com, ariel.dalessandro@collabora.com, bmeng.cn@gmail.com, christian.gmeiner@gmail.com, christianshewitt@gmail.com, festevam@gmail.com, iliev@ronetix.at, jagan@amarulasolutions.com, jh80.chung@samsung.com, joe.hershberger@ni.com, kettenis@openbsd.org, kever.yang@rock-chips.com, kuldeep.singh@nxp.com, marcel.ziswiler@toradex.com, marex@denx.de, michael@amarulasolutions.com, michal.simek@xilinx.com, oliver.graute@kococonnector.com, pali@kernel.org, paul.liu@linaro.org, pbrobinson@gmail.com, peng.fan@nxp.com, philipp.tomsich@vrull.eu, priyanka.jain@nxp.com, radu-nicolae.pirea@oss.nxp.com, rath@ibv-augsburg.net, rfried.dev@gmail.com, samuel@sholland.org, sbabic@denx.de, simon.k.r.goldschmidt@gmail.com, sjg@chromium.org, stephan@gerhold.net, tharvey@gateworks.com, tien.fong.chee@intel.com, uboot-imx@nxp.com, vladimir.oltean@nxp.com, wd@denx.de, xypron.glpk@gmx.de, ye.li@nxp.com Subject: [PATCH v4 4/6] net: phy: Add phy_modify() accessor Date: Fri, 4 Mar 2022 09:22:26 -0300 Message-Id: <20220304122228.71412-5-ariel.dalessandro@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220304122228.71412-1-ariel.dalessandro@collabora.com> References: <20220304122228.71412-1-ariel.dalessandro@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Fri, 04 Mar 2022 14:27:07 +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.5 at phobos.denx.de X-Virus-Status: Clean Add read-modify-write unlocked accessor for accessing a PHY register. Signed-off-by: Ariel D'Alessandro Reviewed-by: Ramon Fried --- drivers/net/phy/phy.c | 20 ++++++++++++++++++++ include/phy.h | 2 ++ 2 files changed, 22 insertions(+) diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 9935e40fcdc..b73361d87d9 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -1105,3 +1105,23 @@ int phy_get_interface_by_name(const char *str) return -1; } + +/** + * phy_modify - Convenience function for modifying a given PHY register + * @phydev: the phy_device struct + * @devad: The MMD to read from + * @regnum: register number to write + * @mask: bit mask of bits to clear + * @set: new value of bits set in mask to write to @regnum + */ +int phy_modify(struct phy_device *phydev, int devad, int regnum, u16 mask, + u16 set) +{ + int ret; + + ret = phy_read(phydev, devad, regnum); + if (ret < 0) + return ret; + + return phy_write(phydev, devad, regnum, (ret & ~mask) | set); +} diff --git a/include/phy.h b/include/phy.h index d4035fdef2b..2dd2e02ab5d 100644 --- a/include/phy.h +++ b/include/phy.h @@ -500,6 +500,8 @@ int phy_config(struct phy_device *phydev); int phy_shutdown(struct phy_device *phydev); int phy_register(struct phy_driver *drv); int phy_set_supported(struct phy_device *phydev, u32 max_speed); +int phy_modify(struct phy_device *phydev, int devad, int regnum, u16 mask, + u16 set); int genphy_config_aneg(struct phy_device *phydev); int genphy_restart_aneg(struct phy_device *phydev); int genphy_update_link(struct phy_device *phydev); -- 2.34.1