netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Heiner Kallweit <hkallweit1@gmail.com>
To: Andrew Lunn <andrew@lunn.ch>,
	Russell King - ARM Linux <linux@armlinux.org.uk>,
	Jakub Kicinski <kuba@kernel.org>,
	David Miller <davem@davemloft.net>,
	Paolo Abeni <pabeni@redhat.com>,
	Eric Dumazet <edumazet@google.com>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Broadcom internal kernel review list 
	<bcm-kernel-feedback-list@broadcom.com>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: [PATCH net-next 1/4] net: phylib: add getting reference clock
Date: Fri, 24 Mar 2023 19:03:08 +0100	[thread overview]
Message-ID: <97e1f180-ae4e-7314-a736-748bb6746d82@gmail.com> (raw)
In-Reply-To: <0c529488-0fd8-19e1-c5a9-9cf1fab78ed3@gmail.com>

Few PHY drivers (smsc, bcm7xxx, micrel) get and enable the (R)MII
reference clock in their probe() callback. Move this common
functionality to phylib, this allows to remove it from the drivers
in a follow-up.

Note that we now enable the reference clock before deasserting the
PHY reset signal. Maybe this even allows us to get rid of
phy_reset_after_clk_enable().

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/net/phy/phy_device.c | 6 ++++++
 include/linux/phy.h          | 5 +++++
 2 files changed, 11 insertions(+)

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index c0760cbf5..6668487e2 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -3096,6 +3096,12 @@ static int phy_probe(struct device *dev)
 	if (phydrv->flags & PHY_IS_INTERNAL)
 		phydev->is_internal = true;
 
+	phydev->refclk = devm_clk_get_optional_enabled(dev, NULL);
+	if (IS_ERR(phydev->refclk)) {
+		err = PTR_ERR(phydev->refclk);
+		goto out;
+	}
+
 	/* Deassert the reset signal */
 	phy_device_reset(phydev, 0);
 
diff --git a/include/linux/phy.h b/include/linux/phy.h
index fefd5091b..6d6129674 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -11,6 +11,7 @@
 #ifndef __PHY_H
 #define __PHY_H
 
+#include <linux/clk.h>
 #include <linux/compiler.h>
 #include <linux/spinlock.h>
 #include <linux/ethtool.h>
@@ -595,6 +596,7 @@ struct macsec_ops;
  * @interface: enum phy_interface_t value
  * @skb: Netlink message for cable diagnostics
  * @nest: Netlink nest used for cable diagnostics
+ * @refclk: External (R)MII reference clock
  * @ehdr: nNtlink header for cable diagnostics
  * @phy_led_triggers: Array of LED triggers
  * @phy_num_led_triggers: Number of triggers in @phy_led_triggers
@@ -719,6 +721,9 @@ struct phy_device {
 	void *ehdr;
 	struct nlattr *nest;
 
+	/* external (R)MII reference clock */
+	struct clk *refclk;
+
 	/* Interrupt and Polling infrastructure */
 	struct delayed_work state_queue;
 
-- 
2.40.0



  reply	other threads:[~2023-03-24 18:07 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-24 18:01 [PATCH net-next 0/4] net: phy: move getting (R)MII refclock to phylib Heiner Kallweit
2023-03-24 18:03 ` Heiner Kallweit [this message]
2023-03-24 19:10   ` [PATCH net-next 1/4] net: phylib: add getting reference clock Florian Fainelli
2023-03-24 18:03 ` [PATCH net-next 2/4] net: phy: smsc: remove " Heiner Kallweit
2023-03-24 19:07   ` Florian Fainelli
2023-03-24 19:09     ` Florian Fainelli
2023-03-24 19:07   ` Florian Fainelli
2023-03-24 18:04 ` [PATCH net-next 3/4] net: phy: micrel: " Heiner Kallweit
2023-03-24 18:05 ` [PATCH net-next 4/4] net: phy: bcm7xxx: " Heiner Kallweit
2023-03-24 19:03   ` Florian Fainelli
2023-03-24 19:50     ` Heiner Kallweit
2023-03-24 20:11       ` Florian Fainelli
2023-03-24 21:16         ` Heiner Kallweit
2023-03-24 21:19           ` Florian Fainelli

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=97e1f180-ae4e-7314-a736-748bb6746d82@gmail.com \
    --to=hkallweit1@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /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;
as well as URLs for NNTP newsgroup(s).