diff mbox series

[net-next,1/2] net: phy: smsc: export functions for use by meson-gxl PHY driver

Message ID 192db694-5bda-513c-31c5-96ec3b2425d9@gmail.com (mailing list archive)
State Accepted
Commit a69e332b4ef9f697a4558bab9c442a02b3659fcb
Delegated to: Netdev Maintainers
Headers show
Series net: phy: reuse SMSC PHY driver functionality in the meson-gxl PHY driver | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next, async
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 18 this patch: 18
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang success Errors and warnings before: 18 this patch: 18
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 18 this patch: 18
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 89 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Heiner Kallweit March 18, 2023, 8:32 p.m. UTC
The Amlogic Meson internal PHY's have the same register layout as
certain SMSC PHY's (also for non-c22-standard registers). This seems
to be more than just coincidence. Apparently they also need the same
workaround for EDPD mode (energy detect power down). Therefore let's
export SMSC PHY driver functionality for use by the meson-gxl PHY
driver.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/net/phy/smsc.c  | 20 +++++++++++++-------
 include/linux/smscphy.h |  6 ++++++
 2 files changed, 19 insertions(+), 7 deletions(-)

Comments

Chris Healy March 20, 2023, 12:39 a.m. UTC | #1
On a dev board with SMSC LAN8720, this change was tested and confirmed
to still operate normally.

Signed-off-by: Chris Healy <healych@amazon.com>

On Sat, Mar 18, 2023 at 1:36 PM Heiner Kallweit <hkallweit1@gmail.com> wrote:
>
> The Amlogic Meson internal PHY's have the same register layout as
> certain SMSC PHY's (also for non-c22-standard registers). This seems
> to be more than just coincidence. Apparently they also need the same
> workaround for EDPD mode (energy detect power down). Therefore let's
> export SMSC PHY driver functionality for use by the meson-gxl PHY
> driver.
>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
>  drivers/net/phy/smsc.c  | 20 +++++++++++++-------
>  include/linux/smscphy.h |  6 ++++++
>  2 files changed, 19 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/net/phy/smsc.c b/drivers/net/phy/smsc.c
> index 721871184..730964b85 100644
> --- a/drivers/net/phy/smsc.c
> +++ b/drivers/net/phy/smsc.c
> @@ -54,7 +54,7 @@ static int smsc_phy_ack_interrupt(struct phy_device *phydev)
>         return rc < 0 ? rc : 0;
>  }
>
> -static int smsc_phy_config_intr(struct phy_device *phydev)
> +int smsc_phy_config_intr(struct phy_device *phydev)
>  {
>         int rc;
>
> @@ -75,8 +75,9 @@ static int smsc_phy_config_intr(struct phy_device *phydev)
>
>         return rc < 0 ? rc : 0;
>  }
> +EXPORT_SYMBOL_GPL(smsc_phy_config_intr);
>
> -static irqreturn_t smsc_phy_handle_interrupt(struct phy_device *phydev)
> +irqreturn_t smsc_phy_handle_interrupt(struct phy_device *phydev)
>  {
>         int irq_status;
>
> @@ -95,18 +96,20 @@ static irqreturn_t smsc_phy_handle_interrupt(struct phy_device *phydev)
>
>         return IRQ_HANDLED;
>  }
> +EXPORT_SYMBOL_GPL(smsc_phy_handle_interrupt);
>
> -static int smsc_phy_config_init(struct phy_device *phydev)
> +int smsc_phy_config_init(struct phy_device *phydev)
>  {
>         struct smsc_phy_priv *priv = phydev->priv;
>
> -       if (!priv->energy_enable || phydev->irq != PHY_POLL)
> +       if (!priv || !priv->energy_enable || phydev->irq != PHY_POLL)
>                 return 0;
>
>         /* Enable energy detect power down mode */
>         return phy_set_bits(phydev, MII_LAN83C185_CTRL_STATUS,
>                             MII_LAN83C185_EDPWRDOWN);
>  }
> +EXPORT_SYMBOL_GPL(smsc_phy_config_init);
>
>  static int smsc_phy_reset(struct phy_device *phydev)
>  {
> @@ -186,7 +189,7 @@ static int lan95xx_config_aneg_ext(struct phy_device *phydev)
>   * The workaround is only applicable to poll mode. Energy Detect Power-Down may
>   * not be used in interrupt mode lest link change detection becomes unreliable.
>   */
> -static int lan87xx_read_status(struct phy_device *phydev)
> +int lan87xx_read_status(struct phy_device *phydev)
>  {
>         struct smsc_phy_priv *priv = phydev->priv;
>         int err;
> @@ -195,7 +198,8 @@ static int lan87xx_read_status(struct phy_device *phydev)
>         if (err)
>                 return err;
>
> -       if (!phydev->link && priv->energy_enable && phydev->irq == PHY_POLL) {
> +       if (!phydev->link && priv && priv->energy_enable &&
> +           phydev->irq == PHY_POLL) {
>                 /* Disable EDPD to wake up PHY */
>                 int rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS);
>                 if (rc < 0)
> @@ -229,6 +233,7 @@ static int lan87xx_read_status(struct phy_device *phydev)
>
>         return err;
>  }
> +EXPORT_SYMBOL_GPL(lan87xx_read_status);
>
>  static int smsc_get_sset_count(struct phy_device *phydev)
>  {
> @@ -269,7 +274,7 @@ static void smsc_get_stats(struct phy_device *phydev,
>                 data[i] = smsc_get_stat(phydev, i);
>  }
>
> -static int smsc_phy_probe(struct phy_device *phydev)
> +int smsc_phy_probe(struct phy_device *phydev)
>  {
>         struct device *dev = &phydev->mdio.dev;
>         struct smsc_phy_priv *priv;
> @@ -294,6 +299,7 @@ static int smsc_phy_probe(struct phy_device *phydev)
>
>         return clk_set_rate(refclk, 50 * 1000 * 1000);
>  }
> +EXPORT_SYMBOL_GPL(smsc_phy_probe);
>
>  static struct phy_driver smsc_phy_driver[] = {
>  {
> diff --git a/include/linux/smscphy.h b/include/linux/smscphy.h
> index 1a136271b..80f37c1db 100644
> --- a/include/linux/smscphy.h
> +++ b/include/linux/smscphy.h
> @@ -28,4 +28,10 @@
>  #define MII_LAN83C185_MODE_POWERDOWN 0xC0 /* Power Down mode */
>  #define MII_LAN83C185_MODE_ALL       0xE0 /* All capable mode */
>
> +int smsc_phy_config_intr(struct phy_device *phydev);
> +irqreturn_t smsc_phy_handle_interrupt(struct phy_device *phydev);
> +int smsc_phy_config_init(struct phy_device *phydev);
> +int lan87xx_read_status(struct phy_device *phydev);
> +int smsc_phy_probe(struct phy_device *phydev);
> +
>  #endif /* __LINUX_SMSCPHY_H__ */
> --
> 2.39.2
>
>
Andrew Lunn March 20, 2023, 12:17 p.m. UTC | #2
On Sun, Mar 19, 2023 at 05:39:51PM -0700, Chris Healy wrote:
> On a dev board with SMSC LAN8720, this change was tested and confirmed
> to still operate normally.
> 
> Signed-off-by: Chris Healy <healych@amazon.com>

Hi Chris

That should be Tested-By:

     Andrew
Chris Healy March 20, 2023, 5:33 p.m. UTC | #3
On Mon, Mar 20, 2023 at 5:17 AM Andrew Lunn <andrew@lunn.ch> wrote:
>
> On Sun, Mar 19, 2023 at 05:39:51PM -0700, Chris Healy wrote:
> > On a dev board with SMSC LAN8720, this change was tested and confirmed
> > to still operate normally.
> >
> > Signed-off-by: Chris Healy <healych@amazon.com>
>
> Hi Chris
>
> That should be Tested-By:
>
>      Andrew

You are correct.  This was a mistake on my part.  I should have stated
"Tested-by" instead of SOB.
diff mbox series

Patch

diff --git a/drivers/net/phy/smsc.c b/drivers/net/phy/smsc.c
index 721871184..730964b85 100644
--- a/drivers/net/phy/smsc.c
+++ b/drivers/net/phy/smsc.c
@@ -54,7 +54,7 @@  static int smsc_phy_ack_interrupt(struct phy_device *phydev)
 	return rc < 0 ? rc : 0;
 }
 
-static int smsc_phy_config_intr(struct phy_device *phydev)
+int smsc_phy_config_intr(struct phy_device *phydev)
 {
 	int rc;
 
@@ -75,8 +75,9 @@  static int smsc_phy_config_intr(struct phy_device *phydev)
 
 	return rc < 0 ? rc : 0;
 }
+EXPORT_SYMBOL_GPL(smsc_phy_config_intr);
 
-static irqreturn_t smsc_phy_handle_interrupt(struct phy_device *phydev)
+irqreturn_t smsc_phy_handle_interrupt(struct phy_device *phydev)
 {
 	int irq_status;
 
@@ -95,18 +96,20 @@  static irqreturn_t smsc_phy_handle_interrupt(struct phy_device *phydev)
 
 	return IRQ_HANDLED;
 }
+EXPORT_SYMBOL_GPL(smsc_phy_handle_interrupt);
 
-static int smsc_phy_config_init(struct phy_device *phydev)
+int smsc_phy_config_init(struct phy_device *phydev)
 {
 	struct smsc_phy_priv *priv = phydev->priv;
 
-	if (!priv->energy_enable || phydev->irq != PHY_POLL)
+	if (!priv || !priv->energy_enable || phydev->irq != PHY_POLL)
 		return 0;
 
 	/* Enable energy detect power down mode */
 	return phy_set_bits(phydev, MII_LAN83C185_CTRL_STATUS,
 			    MII_LAN83C185_EDPWRDOWN);
 }
+EXPORT_SYMBOL_GPL(smsc_phy_config_init);
 
 static int smsc_phy_reset(struct phy_device *phydev)
 {
@@ -186,7 +189,7 @@  static int lan95xx_config_aneg_ext(struct phy_device *phydev)
  * The workaround is only applicable to poll mode. Energy Detect Power-Down may
  * not be used in interrupt mode lest link change detection becomes unreliable.
  */
-static int lan87xx_read_status(struct phy_device *phydev)
+int lan87xx_read_status(struct phy_device *phydev)
 {
 	struct smsc_phy_priv *priv = phydev->priv;
 	int err;
@@ -195,7 +198,8 @@  static int lan87xx_read_status(struct phy_device *phydev)
 	if (err)
 		return err;
 
-	if (!phydev->link && priv->energy_enable && phydev->irq == PHY_POLL) {
+	if (!phydev->link && priv && priv->energy_enable &&
+	    phydev->irq == PHY_POLL) {
 		/* Disable EDPD to wake up PHY */
 		int rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS);
 		if (rc < 0)
@@ -229,6 +233,7 @@  static int lan87xx_read_status(struct phy_device *phydev)
 
 	return err;
 }
+EXPORT_SYMBOL_GPL(lan87xx_read_status);
 
 static int smsc_get_sset_count(struct phy_device *phydev)
 {
@@ -269,7 +274,7 @@  static void smsc_get_stats(struct phy_device *phydev,
 		data[i] = smsc_get_stat(phydev, i);
 }
 
-static int smsc_phy_probe(struct phy_device *phydev)
+int smsc_phy_probe(struct phy_device *phydev)
 {
 	struct device *dev = &phydev->mdio.dev;
 	struct smsc_phy_priv *priv;
@@ -294,6 +299,7 @@  static int smsc_phy_probe(struct phy_device *phydev)
 
 	return clk_set_rate(refclk, 50 * 1000 * 1000);
 }
+EXPORT_SYMBOL_GPL(smsc_phy_probe);
 
 static struct phy_driver smsc_phy_driver[] = {
 {
diff --git a/include/linux/smscphy.h b/include/linux/smscphy.h
index 1a136271b..80f37c1db 100644
--- a/include/linux/smscphy.h
+++ b/include/linux/smscphy.h
@@ -28,4 +28,10 @@ 
 #define MII_LAN83C185_MODE_POWERDOWN 0xC0 /* Power Down mode */
 #define MII_LAN83C185_MODE_ALL       0xE0 /* All capable mode */
 
+int smsc_phy_config_intr(struct phy_device *phydev);
+irqreturn_t smsc_phy_handle_interrupt(struct phy_device *phydev);
+int smsc_phy_config_init(struct phy_device *phydev);
+int lan87xx_read_status(struct phy_device *phydev);
+int smsc_phy_probe(struct phy_device *phydev);
+
 #endif /* __LINUX_SMSCPHY_H__ */