public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: "Marek Behún" <kabel@kernel.org>
To: Joe Hershberger <joe.hershberger@ni.com>,
	Ramon Fried <rfried.dev@gmail.com>
Cc: u-boot@lists.denx.de, "Marek Behún" <marek.behun@nic.cz>,
	"Bin Meng" <bmeng.cn@gmail.com>,
	"Heinrich Schuchardt" <xypron.glpk@gmx.de>,
	"Priyanka Jain" <priyanka.jain@nxp.com>,
	"Vladimir Oltean" <vladimir.oltean@nxp.com>
Subject: [PATCH u-boot-net 04/14] net: mdio-uclass: add wrappers for read/write/reset operations
Date: Thu, 17 Mar 2022 13:49:48 +0100	[thread overview]
Message-ID: <20220317124958.27921-5-kabel@kernel.org> (raw)
In-Reply-To: <20220317124958.27921-1-kabel@kernel.org>

From: Marek Behún <marek.behun@nic.cz>

Add wrappers dm_mdio_read(), dm_mdio_write() and dm_mdio_reset() for
DM MDIO's .read(), .write() and .reset() operations.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
---
 include/miiphy.h  | 31 +++++++++++++++++++++++++++++++
 net/mdio-uclass.c | 31 +++++++++++++++++++++++++++++++
 2 files changed, 62 insertions(+)

diff --git a/include/miiphy.h b/include/miiphy.h
index 235ae066dd..110921f20d 100644
--- a/include/miiphy.h
+++ b/include/miiphy.h
@@ -157,6 +157,37 @@ struct mdio_ops {
  */
 void dm_mdio_probe_devices(void);
 
+/**
+ * dm_mdio_read - Wrapper over .read() operation for DM MDIO
+ *
+ * @mdiodev: mdio device
+ * @addr: PHY address on MDIO bus
+ * @devad: device address on PHY if C45; should be MDIO_DEVAD_NONE if C22
+ * @reg: register address
+ * Return: register value if non-negative, -error code otherwise
+ */
+int dm_mdio_read(struct udevice *mdio_dev, int addr, int devad, int reg);
+
+/**
+ * dm_mdio_write - Wrapper over .write() operation for DM MDIO
+ *
+ * @mdiodev: mdio device
+ * @addr: PHY address on MDIO bus
+ * @devad: device address on PHY if C45; should be MDIO_DEVAD_NONE if C22
+ * @reg: register address
+ * @val: value to write
+ * Return: 0 on success, -error code otherwise
+ */
+int dm_mdio_write(struct udevice *mdio_dev, int addr, int devad, int reg, u16 val);
+
+/**
+ * dm_mdio_reset - Wrapper over .reset() operation for DM MDIO
+ *
+ * @mdiodev: mdio device
+ * Return: 0 on success, -error code otherwise
+ */
+int dm_mdio_reset(struct udevice *mdio_dev);
+
 /**
  * dm_mdio_phy_connect - Wrapper over phy_connect for DM MDIO
  *
diff --git a/net/mdio-uclass.c b/net/mdio-uclass.c
index 233b70171b..887c228167 100644
--- a/net/mdio-uclass.c
+++ b/net/mdio-uclass.c
@@ -57,6 +57,37 @@ static int dm_mdio_post_bind(struct udevice *dev)
 	return 0;
 }
 
+int dm_mdio_read(struct udevice *mdio_dev, int addr, int devad, int reg)
+{
+	struct mdio_ops *ops = mdio_get_ops(mdio_dev);
+
+	if (!ops->read)
+		return -ENOSYS;
+
+	return ops->read(mdio_dev, addr, devad, reg);
+}
+
+int dm_mdio_write(struct udevice *mdio_dev, int addr, int devad, int reg,
+		  u16 val)
+{
+	struct mdio_ops *ops = mdio_get_ops(mdio_dev);
+
+	if (!ops->write)
+		return -ENOSYS;
+
+	return ops->write(mdio_dev, addr, devad, reg, val);
+}
+
+int dm_mdio_reset(struct udevice *mdio_dev)
+{
+	struct mdio_ops *ops = mdio_get_ops(mdio_dev);
+
+	if (!ops->reset)
+		return 0;
+
+	return ops->reset(mdio_dev);
+}
+
 /*
  * Following read/write/reset functions are registered with legacy MII code.
  * These are called for PHY operations by upper layers and we further call the
-- 
2.34.1


  parent reply	other threads:[~2022-03-17 12:51 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-17 12:49 [PATCH u-boot-net 00/14] u-boot-net refactors, fixes, cleanups Marek Behún
2022-03-17 12:49 ` [PATCH u-boot-net 01/14] net: mdio-uclass: fix type for phy_mode_str and phy_handle_str Marek Behún
2022-03-18  7:54   ` Ramon Fried
2022-03-17 12:49 ` [PATCH u-boot-net 02/14] net: mdio-uclass: use ARRAY_SIZE() Marek Behún
2022-03-18  7:55   ` Ramon Fried
2022-03-17 12:49 ` [PATCH u-boot-net 03/14] net: introduce helpers to get PHY ofnode from MAC Marek Behún
2022-03-18  8:02   ` Ramon Fried
2022-03-28  6:35   ` Simon Glass
2022-03-28 21:51     ` Marek Behún
2022-03-17 12:49 ` Marek Behún [this message]
2022-03-18  8:00   ` [PATCH u-boot-net 04/14] net: mdio-uclass: add wrappers for read/write/reset operations Ramon Fried
2022-03-17 12:49 ` [PATCH u-boot-net 05/14] treewide: use dm_mdio_read/write/reset() wrappers Marek Behún
2022-03-18  8:04   ` Ramon Fried
2022-03-17 12:49 ` [PATCH u-boot-net 06/14] net: phy: fix parsing wrong property Marek Behún
2022-03-18  8:05   ` Ramon Fried
2022-03-17 12:49 ` [PATCH u-boot-net 07/14] net: introduce helpers to get PHY interface mode from a device/ofnode Marek Behún
2022-03-18  8:07   ` Ramon Fried
2022-03-17 12:49 ` [PATCH u-boot-net 08/14] treewide: Rename PHY_INTERFACE_MODE_COUNT to PHY_INTERFACE_MODE_MAX Marek Behún
2022-03-18  7:34   ` Stefan Roese
2022-03-17 12:49 ` [PATCH u-boot-net 09/14] treewide: Rename PHY_INTERFACE_MODE_NONE to PHY_INTERFACE_MODE_NA Marek Behún
2022-03-18  7:34   ` Stefan Roese
2022-03-18  8:07   ` Ramon Fried
2022-03-17 12:49 ` [PATCH u-boot-net 10/14] phy: Move PHY_INTERFACE_MODE_NA to the beginning of the enum definition Marek Behún
2022-03-18  7:34   ` Stefan Roese
2022-03-18  8:08   ` Ramon Fried
2022-03-17 12:49 ` [PATCH u-boot-net 11/14] net: phy: xilinx: Check interface type in ->config(), not ->probe() Marek Behún
2022-03-18  8:09   ` Ramon Fried
2022-03-17 12:49 ` [PATCH u-boot-net 12/14] net: phy: use ->is_c45 instead of is_10g_interface() Marek Behún
2022-03-18  8:10   ` Ramon Fried
2022-03-17 12:49 ` [PATCH u-boot-net 13/14] bcmgenet, sun8i_emac: Don't connect PHY two times Marek Behún
2022-03-18  8:10   ` Ramon Fried
2022-03-17 12:49 ` [PATCH u-boot-net 14/14] net: phy: don't require PHY interface mode during PHY creation Marek Behún
2022-03-18  8:12   ` Ramon Fried
2022-03-18  8:13 ` [PATCH u-boot-net 00/14] u-boot-net refactors, fixes, cleanups Ramon Fried

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=20220317124958.27921-5-kabel@kernel.org \
    --to=kabel@kernel.org \
    --cc=bmeng.cn@gmail.com \
    --cc=joe.hershberger@ni.com \
    --cc=marek.behun@nic.cz \
    --cc=priyanka.jain@nxp.com \
    --cc=rfried.dev@gmail.com \
    --cc=u-boot@lists.denx.de \
    --cc=vladimir.oltean@nxp.com \
    --cc=xypron.glpk@gmx.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