From: Dan Murphy <dmurphy@ti.com>
To: u-boot@lists.denx.de
Subject: [RFC PATCH 2/3] net: phy: Add helper routines to set and clear bits
Date: Mon, 20 Apr 2020 13:53:09 -0500 [thread overview]
Message-ID: <20200420185310.6630-2-dmurphy@ti.com> (raw)
In-Reply-To: <20200420185310.6630-1-dmurphy@ti.com>
Add phy_set/clear_bit helper routines so that ported drivers from the
kernel can use these functions.
Signed-off-by: Dan Murphy <dmurphy@ti.com>
---
include/phy.h | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/include/phy.h b/include/phy.h
index b5de14cbfc29..050c989fa537 100644
--- a/include/phy.h
+++ b/include/phy.h
@@ -257,6 +257,44 @@ static inline int phy_write_mmd(struct phy_device *phydev, int devad,
return phy_write(phydev, MDIO_DEVAD_NONE, MII_MMD_DATA, val);
}
+static inline int phy_set_bits_mmd(struct phy_device *phydev, int devad,
+ u32 regnum, u16 val)
+{
+ int value;
+ int ret;
+
+ value = phy_read_mmd(phydev, devad, regnum);
+ if (value < 0)
+ return value;
+
+ value |= val;
+
+ ret = phy_write_mmd(phydev, devad, regnum, value);
+ if (ret < 0)
+ return ret;
+
+ return 0;
+}
+
+static inline int phy_clear_bits_mmd(struct phy_device *phydev, int devad,
+ u32 regnum, u16 val)
+{
+ int value;
+ int ret;
+
+ value = phy_read_mmd(phydev, devad, regnum);
+ if (value < 0)
+ return value;
+
+ value &= ~val;
+
+ ret = phy_write_mmd(phydev, devad, regnum, value);
+ if (ret < 0)
+ return ret;
+
+ return 0;
+}
+
#ifdef CONFIG_PHYLIB_10G
extern struct phy_driver gen10g_driver;
--
2.25.1
next prev parent reply other threads:[~2020-04-20 18:53 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-20 18:53 [RFC PATCH 1/3] net: phy: Add a generic phy file for TI generic PHYs Dan Murphy
2020-04-20 18:53 ` Dan Murphy [this message]
2020-04-21 8:04 ` [RFC PATCH 2/3] net: phy: Add helper routines to set and clear bits Michal Simek
2020-04-21 11:43 ` Dan Murphy
2020-04-21 11:52 ` Michal Simek
2020-04-21 11:54 ` Dan Murphy
2020-04-20 18:53 ` [RFC PATCH 3/3] net: phy: dp83869: Port the kernel driver Dan Murphy
2020-04-21 8:23 ` Michal Simek
2020-04-21 12:04 ` Dan Murphy
2020-04-21 12:39 ` Michal Simek
2020-04-21 14:27 ` Dan Murphy
2021-04-27 7:01 ` Christian Gmeiner
2020-04-21 7:57 ` [RFC PATCH 1/3] net: phy: Add a generic phy file for TI generic PHYs Michal Simek
2020-04-21 11:48 ` Dan Murphy
2020-04-22 16:04 ` Grygorii Strashko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200420185310.6630-2-dmurphy@ti.com \
--to=dmurphy@ti.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox