From: Yang Xiwen via B4 Relay <devnull+forbidden405.outlook.com@kernel.org> To: Joe Hershberger <joe.hershberger@ni.com>, Ramon Fried <rfried.dev@gmail.com> Cc: u-boot@lists.denx.de, Yang Xiwen <forbidden405@outlook.com> Subject: [PATCH v3 3/5] net: hifemac: register MDIO bus device for subnode Date: Mon, 22 Jan 2024 22:33:22 +0800 [thread overview] Message-ID: <20240122-net-v3-3-f1e80564725b@outlook.com> (raw) In-Reply-To: <20240122-net-v3-0-f1e80564725b@outlook.com> From: Yang Xiwen <forbidden405@outlook.com> register internal MDIO bus device if it is a subnode. Signed-off-by: Yang Xiwen <forbidden405@outlook.com> --- drivers/net/hifemac.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/net/hifemac.c b/drivers/net/hifemac.c index 1088f3eca3..39c0233b62 100644 --- a/drivers/net/hifemac.c +++ b/drivers/net/hifemac.c @@ -15,6 +15,7 @@ #include <wait_bit.h> #include <asm/io.h> #include <dm/device_compat.h> +#include <dm/lists.h> #include <linux/delay.h> #include <linux/kernel.h> @@ -337,6 +338,8 @@ int hisi_femac_of_to_plat(struct udevice *dev) { int ret, i; struct hisi_femac_priv *priv = dev_get_priv(dev); + ofnode mdio_node; + bool mdio_registered = false; static const char * const clk_strs[] = { [CLK_MAC] = "mac", [CLK_BUS] = "bus", @@ -388,6 +391,31 @@ int hisi_femac_of_to_plat(struct udevice *dev) MAC_RESET_DELAY_PROPERTY, MAC_RESET_ASSERT_PERIOD); + /* Create MDIO bus */ + ofnode_for_each_subnode(mdio_node, dev_ofnode(dev)) { + const char *subnode_name = ofnode_get_name(mdio_node); + struct udevice *mdiodev; + + // Skip subnodes not starting with "mdio" + if (strncmp(subnode_name, "mdio", 4)) + continue; + + ret = device_bind_driver_to_node(dev, "hisi-femac-mdio", + subnode_name, mdio_node, &mdiodev); + if (ret) { + dev_err(dev, "Failed to register MDIO bus device %d\n", ret); + return log_msg_ret("net", ret); + } + + mdio_registered = true; + break; + } + + if (!mdio_registered) { + dev_err(dev, "No MDIO subnode is found!\n"); + return log_msg_ret("mdio", -ENODATA); + } + return 0; } -- 2.43.0
WARNING: multiple messages have this Message-ID (diff)
From: Yang Xiwen <forbidden405@outlook.com> To: Joe Hershberger <joe.hershberger@ni.com>, Ramon Fried <rfried.dev@gmail.com> Cc: u-boot@lists.denx.de, Yang Xiwen <forbidden405@outlook.com> Subject: [PATCH v3 3/5] net: hifemac: register MDIO bus device for subnode Date: Mon, 22 Jan 2024 22:33:22 +0800 [thread overview] Message-ID: <20240122-net-v3-3-f1e80564725b@outlook.com> (raw) In-Reply-To: <20240122-net-v3-0-f1e80564725b@outlook.com> register internal MDIO bus device if it is a subnode. Signed-off-by: Yang Xiwen <forbidden405@outlook.com> --- drivers/net/hifemac.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/net/hifemac.c b/drivers/net/hifemac.c index 1088f3eca3..39c0233b62 100644 --- a/drivers/net/hifemac.c +++ b/drivers/net/hifemac.c @@ -15,6 +15,7 @@ #include <wait_bit.h> #include <asm/io.h> #include <dm/device_compat.h> +#include <dm/lists.h> #include <linux/delay.h> #include <linux/kernel.h> @@ -337,6 +338,8 @@ int hisi_femac_of_to_plat(struct udevice *dev) { int ret, i; struct hisi_femac_priv *priv = dev_get_priv(dev); + ofnode mdio_node; + bool mdio_registered = false; static const char * const clk_strs[] = { [CLK_MAC] = "mac", [CLK_BUS] = "bus", @@ -388,6 +391,31 @@ int hisi_femac_of_to_plat(struct udevice *dev) MAC_RESET_DELAY_PROPERTY, MAC_RESET_ASSERT_PERIOD); + /* Create MDIO bus */ + ofnode_for_each_subnode(mdio_node, dev_ofnode(dev)) { + const char *subnode_name = ofnode_get_name(mdio_node); + struct udevice *mdiodev; + + // Skip subnodes not starting with "mdio" + if (strncmp(subnode_name, "mdio", 4)) + continue; + + ret = device_bind_driver_to_node(dev, "hisi-femac-mdio", + subnode_name, mdio_node, &mdiodev); + if (ret) { + dev_err(dev, "Failed to register MDIO bus device %d\n", ret); + return log_msg_ret("net", ret); + } + + mdio_registered = true; + break; + } + + if (!mdio_registered) { + dev_err(dev, "No MDIO subnode is found!\n"); + return log_msg_ret("mdio", -ENODATA); + } + return 0; } -- 2.43.0
next prev parent reply other threads:[~2024-01-22 14:34 UTC|newest] Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-01-22 14:33 [PATCH v3 0/5] net: hifemac: a few cleanups Yang Xiwen via B4 Relay 2024-01-22 14:33 ` Yang Xiwen 2024-01-22 14:33 ` [PATCH v3 1/5] net: hifemac_mdio: use log_msg_ret() correctly, report error by dev_err() Yang Xiwen via B4 Relay 2024-01-22 14:33 ` Yang Xiwen 2024-03-28 15:09 ` Tom Rini 2024-01-22 14:33 ` [PATCH v3 2/5] net: hifemac: fix log reporting Yang Xiwen via B4 Relay 2024-01-22 14:33 ` Yang Xiwen 2024-01-22 14:33 ` Yang Xiwen via B4 Relay [this message] 2024-01-22 14:33 ` [PATCH v3 3/5] net: hifemac: register MDIO bus device for subnode Yang Xiwen 2024-01-22 14:33 ` [PATCH v3 4/5] net: hifemac: implement `net stats` needed ops Yang Xiwen via B4 Relay 2024-01-22 14:33 ` Yang Xiwen 2024-01-22 14:33 ` [PATCH v3 5/5] net: hifemac: make some functions static Yang Xiwen via B4 Relay 2024-01-22 14:33 ` Yang Xiwen
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=20240122-net-v3-3-f1e80564725b@outlook.com \ --to=devnull+forbidden405.outlook.com@kernel.org \ --cc=forbidden405@outlook.com \ --cc=joe.hershberger@ni.com \ --cc=rfried.dev@gmail.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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.