netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v5 net-next 0/3] net: axienet: Use a DT property to configure frequency of the MDIO bus
@ 2022-11-17 15:40 Andy Chiu
  2022-11-17 15:40 ` [PATCH v5 net-next 1/3] net: axienet: Unexport and remove unused mdio functions Andy Chiu
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Andy Chiu @ 2022-11-17 15:40 UTC (permalink / raw)
  To: davem, andrew, kuba, michal.simek, radhey.shyam.pandey
  Cc: netdev, devicetree, linux-arm-kernel, robh+dt, pabeni, edumazet,
	andy.chiu, greentime.hu

Some FPGA platforms have to set frequency of the MDIO bus lower than 2.5
MHz. Thus, we use a DT property, which is "clock-frequency", to work
with it at boot time. The default 2.5 MHz would be set if the property
is not pressent. Also, factor out mdio enable/disable functions due to
the api change since 253761a0e61b7.

Changelog:
--- v5 ---
1. Make dt-binding patch prior to the implementation patch.
2. Disable mdio bus in error path.
3. Update description of some functions.
--- v4 ---
1. change MAX_MDIO_FREQ to DEFAULT_MDIO_FREQ as suggested by Andrew.
--- v3 RESEND ---
1. Repost the exact same patch again
--- v3 ---
1. Fix coding style, and make probing of the driver fail if MDC overflow
--- v2 ---
1. Use clock-frequency, as defined in mdio.yaml, to configure MDIO
   clock.
2. Only print out frequency if it is set to a non-standard value.
3. Reduce the scope of axienet_mdio_enable and remove
   axienet_mdio_disable because no one really uses it anymore.

Andy Chiu (3):
  net: axienet: Unexport and remove unused mdio functions
  dt-bindings: describe the support of "clock-frequency" in mdio
  net: axienet: set mdio clock according to bus-frequency

 .../bindings/net/xilinx_axienet.txt           |  2 +
 drivers/net/ethernet/xilinx/xilinx_axienet.h  |  2 -
 .../net/ethernet/xilinx/xilinx_axienet_mdio.c | 79 +++++++++++--------
 3 files changed, 50 insertions(+), 33 deletions(-)

-- 
2.36.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v5 net-next 1/3] net: axienet: Unexport and remove unused mdio functions
  2022-11-17 15:40 [PATCH v5 net-next 0/3] net: axienet: Use a DT property to configure frequency of the MDIO bus Andy Chiu
@ 2022-11-17 15:40 ` Andy Chiu
  2022-11-17 15:40 ` [PATCH v5 net-next 2/3] dt-bindings: describe the support of "clock-frequency" in mdio Andy Chiu
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Andy Chiu @ 2022-11-17 15:40 UTC (permalink / raw)
  To: davem, andrew, kuba, michal.simek, radhey.shyam.pandey
  Cc: netdev, devicetree, linux-arm-kernel, robh+dt, pabeni, edumazet,
	andy.chiu, greentime.hu

Both axienet_mdio_{enable/disable} functions are no longer used in
xilinx_axienet_main.c due to 253761a0e61b7. And axienet_mdio_disable is
not even used in the mdio.c. So unexport and remove them.

Signed-off-by: Andy Chiu <andy.chiu@sifive.com>
Reviewed-by: Greentime Hu <greentime.hu@sifive.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/ethernet/xilinx/xilinx_axienet.h      |  2 --
 drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c | 13 +------------
 2 files changed, 1 insertion(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet.h b/drivers/net/ethernet/xilinx/xilinx_axienet.h
index 6370c447ac5c..575ff9de8985 100644
--- a/drivers/net/ethernet/xilinx/xilinx_axienet.h
+++ b/drivers/net/ethernet/xilinx/xilinx_axienet.h
@@ -611,8 +611,6 @@ static inline void axienet_dma_out_addr(struct axienet_local *lp, off_t reg,
 #endif /* CONFIG_64BIT */
 
 /* Function prototypes visible in xilinx_axienet_mdio.c for other files */
-int axienet_mdio_enable(struct axienet_local *lp);
-void axienet_mdio_disable(struct axienet_local *lp);
 int axienet_mdio_setup(struct axienet_local *lp);
 void axienet_mdio_teardown(struct axienet_local *lp);
 
diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c b/drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c
index 0b3b6935c558..e1f51a071888 100644
--- a/drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c
+++ b/drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c
@@ -153,7 +153,7 @@ static int axienet_mdio_write(struct mii_bus *bus, int phy_id, int reg,
  * Sets up the MDIO interface by initializing the MDIO clock and enabling the
  * MDIO interface in hardware.
  **/
-int axienet_mdio_enable(struct axienet_local *lp)
+static int axienet_mdio_enable(struct axienet_local *lp)
 {
 	u32 host_clock;
 
@@ -226,17 +226,6 @@ int axienet_mdio_enable(struct axienet_local *lp)
 	return axienet_mdio_wait_until_ready(lp);
 }
 
-/**
- * axienet_mdio_disable - MDIO hardware disable function
- * @lp:		Pointer to axienet local data structure.
- *
- * Disable the MDIO interface in hardware.
- **/
-void axienet_mdio_disable(struct axienet_local *lp)
-{
-	axienet_iow(lp, XAE_MDIO_MC_OFFSET, 0);
-}
-
 /**
  * axienet_mdio_setup - MDIO setup function
  * @lp:		Pointer to axienet local data structure.
-- 
2.36.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v5 net-next 2/3] dt-bindings: describe the support of "clock-frequency" in mdio
  2022-11-17 15:40 [PATCH v5 net-next 0/3] net: axienet: Use a DT property to configure frequency of the MDIO bus Andy Chiu
  2022-11-17 15:40 ` [PATCH v5 net-next 1/3] net: axienet: Unexport and remove unused mdio functions Andy Chiu
@ 2022-11-17 15:40 ` Andy Chiu
  2022-11-17 15:40 ` [PATCH v5 net-next 3/3] net: axienet: set mdio clock according to bus-frequency Andy Chiu
  2022-11-21 10:40 ` [PATCH v5 net-next 0/3] net: axienet: Use a DT property to configure frequency of the MDIO bus patchwork-bot+netdevbpf
  3 siblings, 0 replies; 7+ messages in thread
From: Andy Chiu @ 2022-11-17 15:40 UTC (permalink / raw)
  To: davem, andrew, kuba, michal.simek, radhey.shyam.pandey
  Cc: netdev, devicetree, linux-arm-kernel, robh+dt, pabeni, edumazet,
	andy.chiu, greentime.hu, Rob Herring

mdio bus frequency is going to be configurable at boottime by a property
in DT now, so add a description to it.

Signed-off-by: Andy Chiu <andy.chiu@sifive.com>
Reviewed-by: Greentime Hu <greentime.hu@sifive.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Acked-by: Rob Herring <robh@kernel.org>
---
 Documentation/devicetree/bindings/net/xilinx_axienet.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/xilinx_axienet.txt b/Documentation/devicetree/bindings/net/xilinx_axienet.txt
index 1aa4c6006cd0..80e505a2fda1 100644
--- a/Documentation/devicetree/bindings/net/xilinx_axienet.txt
+++ b/Documentation/devicetree/bindings/net/xilinx_axienet.txt
@@ -68,6 +68,8 @@ Optional properties:
  - mdio		: Child node for MDIO bus. Must be defined if PHY access is
 		  required through the core's MDIO interface (i.e. always,
 		  unless the PHY is accessed through a different bus).
+		  Non-standard MDIO bus frequency is supported via
+		  "clock-frequency", see mdio.yaml.
 
  - pcs-handle: 	  Phandle to the internal PCS/PMA PHY in SGMII or 1000Base-X
 		  modes, where "pcs-handle" should be used to point
-- 
2.36.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v5 net-next 3/3] net: axienet: set mdio clock according to bus-frequency
  2022-11-17 15:40 [PATCH v5 net-next 0/3] net: axienet: Use a DT property to configure frequency of the MDIO bus Andy Chiu
  2022-11-17 15:40 ` [PATCH v5 net-next 1/3] net: axienet: Unexport and remove unused mdio functions Andy Chiu
  2022-11-17 15:40 ` [PATCH v5 net-next 2/3] dt-bindings: describe the support of "clock-frequency" in mdio Andy Chiu
@ 2022-11-17 15:40 ` Andy Chiu
  2022-11-17 15:46   ` Pandey, Radhey Shyam
  2022-11-18  0:07   ` Andrew Lunn
  2022-11-21 10:40 ` [PATCH v5 net-next 0/3] net: axienet: Use a DT property to configure frequency of the MDIO bus patchwork-bot+netdevbpf
  3 siblings, 2 replies; 7+ messages in thread
From: Andy Chiu @ 2022-11-17 15:40 UTC (permalink / raw)
  To: davem, andrew, kuba, michal.simek, radhey.shyam.pandey
  Cc: netdev, devicetree, linux-arm-kernel, robh+dt, pabeni, edumazet,
	andy.chiu, greentime.hu

Some FPGA platforms have 80KHz MDIO bus frequency constraint when
connecting Ethernet to its on-board external Marvell PHY. Thus, we may
have to set MDIO clock according to the DT. Otherwise, use the default
2.5 MHz, as specified by 802.3, if the entry is not present.

Also, change MAX_MDIO_FREQ to DEFAULT_MDIO_FREQ because we may actually
set MDIO bus frequency higher than 2.5MHz if undelying devices support
it. And properly disable the mdio bus clock in error path.

Signed-off-by: Andy Chiu <andy.chiu@sifive.com>
---
 .../net/ethernet/xilinx/xilinx_axienet_mdio.c | 70 +++++++++++++------
 1 file changed, 49 insertions(+), 21 deletions(-)

diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c b/drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c
index e1f51a071888..2f07fde361aa 100644
--- a/drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c
+++ b/drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c
@@ -17,7 +17,7 @@
 
 #include "xilinx_axienet.h"
 
-#define MAX_MDIO_FREQ		2500000 /* 2.5 MHz */
+#define DEFAULT_MDIO_FREQ	2500000 /* 2.5 MHz */
 #define DEFAULT_HOST_CLOCK	150000000 /* 150 MHz */
 
 /* Wait till MDIO interface is ready to accept a new transaction.*/
@@ -147,15 +147,20 @@ static int axienet_mdio_write(struct mii_bus *bus, int phy_id, int reg,
 /**
  * axienet_mdio_enable - MDIO hardware setup function
  * @lp:		Pointer to axienet local data structure.
+ * @np:		Pointer to mdio device tree node.
  *
- * Return:	0 on success, -ETIMEDOUT on a timeout.
+ * Return:	0 on success, -ETIMEDOUT on a timeout, -EOVERFLOW on a clock
+ *		divisor overflow.
  *
  * Sets up the MDIO interface by initializing the MDIO clock and enabling the
  * MDIO interface in hardware.
  **/
-static int axienet_mdio_enable(struct axienet_local *lp)
+static int axienet_mdio_enable(struct axienet_local *lp, struct device_node *np)
 {
+	u32 mdio_freq = DEFAULT_MDIO_FREQ;
 	u32 host_clock;
+	u32 clk_div;
+	int ret;
 
 	lp->mii_clk_div = 0;
 
@@ -184,6 +189,12 @@ static int axienet_mdio_enable(struct axienet_local *lp)
 			    host_clock);
 	}
 
+	if (np)
+		of_property_read_u32(np, "clock-frequency", &mdio_freq);
+	if (mdio_freq != DEFAULT_MDIO_FREQ)
+		netdev_info(lp->ndev, "Setting non-standard mdio bus frequency to %u Hz\n",
+			    mdio_freq);
+
 	/* clk_div can be calculated by deriving it from the equation:
 	 * fMDIO = fHOST / ((1 + clk_div) * 2)
 	 *
@@ -209,29 +220,42 @@ static int axienet_mdio_enable(struct axienet_local *lp)
 	 * "clock-frequency" from the CPU
 	 */
 
-	lp->mii_clk_div = (host_clock / (MAX_MDIO_FREQ * 2)) - 1;
+	clk_div = (host_clock / (mdio_freq * 2)) - 1;
 	/* If there is any remainder from the division of
-	 * fHOST / (MAX_MDIO_FREQ * 2), then we need to add
-	 * 1 to the clock divisor or we will surely be above 2.5 MHz
+	 * fHOST / (mdio_freq * 2), then we need to add
+	 * 1 to the clock divisor or we will surely be
+	 * above the requested frequency
 	 */
-	if (host_clock % (MAX_MDIO_FREQ * 2))
-		lp->mii_clk_div++;
+	if (host_clock % (mdio_freq * 2))
+		clk_div++;
+
+	/* Check for overflow of mii_clk_div */
+	if (clk_div & ~XAE_MDIO_MC_CLOCK_DIVIDE_MAX) {
+		netdev_warn(lp->ndev, "MDIO clock divisor overflow\n");
+		return -EOVERFLOW;
+	}
+	lp->mii_clk_div = (u8)clk_div;
 
 	netdev_dbg(lp->ndev,
 		   "Setting MDIO clock divisor to %u/%u Hz host clock.\n",
 		   lp->mii_clk_div, host_clock);
 
-	axienet_iow(lp, XAE_MDIO_MC_OFFSET, lp->mii_clk_div | XAE_MDIO_MC_MDIOEN_MASK);
+	axienet_mdio_mdc_enable(lp);
 
-	return axienet_mdio_wait_until_ready(lp);
+	ret = axienet_mdio_wait_until_ready(lp);
+	if (ret)
+		axienet_mdio_mdc_disable(lp);
+
+	return ret;
 }
 
 /**
  * axienet_mdio_setup - MDIO setup function
  * @lp:		Pointer to axienet local data structure.
  *
- * Return:	0 on success, -ETIMEDOUT on a timeout, -ENOMEM when
- *		mdiobus_alloc (to allocate memory for mii bus structure) fails.
+ * Return:	0 on success, -ETIMEDOUT on a timeout, -EOVERFLOW on a clock
+ *		divisor overflow, -ENOMEM when mdiobus_alloc (to allocate
+ *		memory for mii bus structure) fails.
  *
  * Sets up the MDIO interface by initializing the MDIO clock.
  * Register the MDIO interface.
@@ -242,10 +266,6 @@ int axienet_mdio_setup(struct axienet_local *lp)
 	struct mii_bus *bus;
 	int ret;
 
-	ret = axienet_mdio_enable(lp);
-	if (ret < 0)
-		return ret;
-
 	bus = mdiobus_alloc();
 	if (!bus)
 		return -ENOMEM;
@@ -261,15 +281,23 @@ int axienet_mdio_setup(struct axienet_local *lp)
 	lp->mii_bus = bus;
 
 	mdio_node = of_get_child_by_name(lp->dev->of_node, "mdio");
+	ret = axienet_mdio_enable(lp, mdio_node);
+	if (ret < 0)
+		goto unregister;
 	ret = of_mdiobus_register(bus, mdio_node);
+	if (ret)
+		goto unregister_mdio_enabled;
 	of_node_put(mdio_node);
-	if (ret) {
-		mdiobus_free(bus);
-		lp->mii_bus = NULL;
-		return ret;
-	}
 	axienet_mdio_mdc_disable(lp);
 	return 0;
+
+unregister_mdio_enabled:
+	axienet_mdio_mdc_disable(lp);
+unregister:
+	of_node_put(mdio_node);
+	mdiobus_free(bus);
+	lp->mii_bus = NULL;
+	return ret;
 }
 
 /**
-- 
2.36.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* RE: [PATCH v5 net-next 3/3] net: axienet: set mdio clock according to bus-frequency
  2022-11-17 15:40 ` [PATCH v5 net-next 3/3] net: axienet: set mdio clock according to bus-frequency Andy Chiu
@ 2022-11-17 15:46   ` Pandey, Radhey Shyam
  2022-11-18  0:07   ` Andrew Lunn
  1 sibling, 0 replies; 7+ messages in thread
From: Pandey, Radhey Shyam @ 2022-11-17 15:46 UTC (permalink / raw)
  To: Andy Chiu, davem, andrew, kuba, michal.simek, radhey.shyam.pandey
  Cc: netdev, devicetree, linux-arm-kernel, robh+dt, pabeni, edumazet,
	greentime.hu

> -----Original Message-----
> From: Andy Chiu <andy.chiu@sifive.com>
> Sent: Thursday, November 17, 2022 9:10 PM
> To: davem@davemloft.net; andrew@lunn.ch; kuba@kernel.org;
> michal.simek@xilinx.com; radhey.shyam.pandey@xilinx.com
> Cc: netdev@vger.kernel.org; devicetree@vger.kernel.org; linux-arm-
> kernel@lists.infradead.org; robh+dt@kernel.org; pabeni@redhat.com;
> edumazet@google.com; andy.chiu@sifive.com; greentime.hu@sifive.com
> Subject: [PATCH v5 net-next 3/3] net: axienet: set mdio clock according to
> bus-frequency
> 
> CAUTION: This message has originated from an External Source. Please use
> proper judgment and caution when opening attachments, clicking links, or
> responding to this email.
> 
> 
> Some FPGA platforms have 80KHz MDIO bus frequency constraint when
> connecting Ethernet to its on-board external Marvell PHY. Thus, we may have
> to set MDIO clock according to the DT. Otherwise, use the default
> 2.5 MHz, as specified by 802.3, if the entry is not present.
> 
> Also, change MAX_MDIO_FREQ to DEFAULT_MDIO_FREQ because we may
> actually set MDIO bus frequency higher than 2.5MHz if undelying devices
> support it. And properly disable the mdio bus clock in error path.
> 
> Signed-off-by: Andy Chiu <andy.chiu@sifive.com>
> ---
>  .../net/ethernet/xilinx/xilinx_axienet_mdio.c | 70 +++++++++++++------
>  1 file changed, 49 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c
> b/drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c
> index e1f51a071888..2f07fde361aa 100644
> --- a/drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c
> +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c
> @@ -17,7 +17,7 @@
> 
>  #include "xilinx_axienet.h"
> 
> -#define MAX_MDIO_FREQ          2500000 /* 2.5 MHz */
> +#define DEFAULT_MDIO_FREQ      2500000 /* 2.5 MHz */
>  #define DEFAULT_HOST_CLOCK     150000000 /* 150 MHz */
> 
>  /* Wait till MDIO interface is ready to accept a new transaction.*/ @@ -
> 147,15 +147,20 @@ static int axienet_mdio_write(struct mii_bus *bus, int
> phy_id, int reg,
>  /**
>   * axienet_mdio_enable - MDIO hardware setup function
>   * @lp:                Pointer to axienet local data structure.
> + * @np:                Pointer to mdio device tree node.
>   *
> - * Return:     0 on success, -ETIMEDOUT on a timeout.
> + * Return:     0 on success, -ETIMEDOUT on a timeout, -EOVERFLOW on a
> clock
> + *             divisor overflow.
>   *
>   * Sets up the MDIO interface by initializing the MDIO clock and enabling the
>   * MDIO interface in hardware.
>   **/
> -static int axienet_mdio_enable(struct axienet_local *lp)
> +static int axienet_mdio_enable(struct axienet_local *lp, struct
> +device_node *np)
>  {
> +       u32 mdio_freq = DEFAULT_MDIO_FREQ;
>         u32 host_clock;
> +       u32 clk_div;
> +       int ret;
> 
>         lp->mii_clk_div = 0;
> 
> @@ -184,6 +189,12 @@ static int axienet_mdio_enable(struct axienet_local
> *lp)
>                             host_clock);
>         }
> 
> +       if (np)
> +               of_property_read_u32(np, "clock-frequency", &mdio_freq);
> +       if (mdio_freq != DEFAULT_MDIO_FREQ)
> +               netdev_info(lp->ndev, "Setting non-standard mdio bus frequency
> to %u Hz\n",
> +                           mdio_freq);
> +
>         /* clk_div can be calculated by deriving it from the equation:
>          * fMDIO = fHOST / ((1 + clk_div) * 2)
>          *
> @@ -209,29 +220,42 @@ static int axienet_mdio_enable(struct axienet_local
> *lp)
>          * "clock-frequency" from the CPU
>          */
> 
> -       lp->mii_clk_div = (host_clock / (MAX_MDIO_FREQ * 2)) - 1;
> +       clk_div = (host_clock / (mdio_freq * 2)) - 1;
>         /* If there is any remainder from the division of
> -        * fHOST / (MAX_MDIO_FREQ * 2), then we need to add
> -        * 1 to the clock divisor or we will surely be above 2.5 MHz
> +        * fHOST / (mdio_freq * 2), then we need to add
> +        * 1 to the clock divisor or we will surely be
> +        * above the requested frequency
>          */
> -       if (host_clock % (MAX_MDIO_FREQ * 2))
> -               lp->mii_clk_div++;
> +       if (host_clock % (mdio_freq * 2))
> +               clk_div++;
> +
> +       /* Check for overflow of mii_clk_div */
> +       if (clk_div & ~XAE_MDIO_MC_CLOCK_DIVIDE_MAX) {
> +               netdev_warn(lp->ndev, "MDIO clock divisor overflow\n");
> +               return -EOVERFLOW;
> +       }
> +       lp->mii_clk_div = (u8)clk_div;
> 
>         netdev_dbg(lp->ndev,
>                    "Setting MDIO clock divisor to %u/%u Hz host clock.\n",
>                    lp->mii_clk_div, host_clock);
> 
> -       axienet_iow(lp, XAE_MDIO_MC_OFFSET, lp->mii_clk_div |
> XAE_MDIO_MC_MDIOEN_MASK);
> +       axienet_mdio_mdc_enable(lp);
> 
> -       return axienet_mdio_wait_until_ready(lp);
> +       ret = axienet_mdio_wait_until_ready(lp);
> +       if (ret)
> +               axienet_mdio_mdc_disable(lp);
> +
> +       return ret;
>  }
> 
>  /**
>   * axienet_mdio_setup - MDIO setup function
>   * @lp:                Pointer to axienet local data structure.
>   *
> - * Return:     0 on success, -ETIMEDOUT on a timeout, -ENOMEM when
> - *             mdiobus_alloc (to allocate memory for mii bus structure) fails.
> + * Return:     0 on success, -ETIMEDOUT on a timeout, -EOVERFLOW on a
> clock
> + *             divisor overflow, -ENOMEM when mdiobus_alloc (to allocate
> + *             memory for mii bus structure) fails.
>   *
>   * Sets up the MDIO interface by initializing the MDIO clock.
>   * Register the MDIO interface.
> @@ -242,10 +266,6 @@ int axienet_mdio_setup(struct axienet_local *lp)
>         struct mii_bus *bus;
>         int ret;
> 
> -       ret = axienet_mdio_enable(lp);
> -       if (ret < 0)
> -               return ret;
> -
>         bus = mdiobus_alloc();
>         if (!bus)
>                 return -ENOMEM;
> @@ -261,15 +281,23 @@ int axienet_mdio_setup(struct axienet_local *lp)
>         lp->mii_bus = bus;
> 
>         mdio_node = of_get_child_by_name(lp->dev->of_node, "mdio");
> +       ret = axienet_mdio_enable(lp, mdio_node);
> +       if (ret < 0)
> +               goto unregister;
>         ret = of_mdiobus_register(bus, mdio_node);
> +       if (ret)
> +               goto unregister_mdio_enabled;
>         of_node_put(mdio_node);
> -       if (ret) {
> -               mdiobus_free(bus);
> -               lp->mii_bus = NULL;
> -               return ret;
> -       }
>         axienet_mdio_mdc_disable(lp);
>         return 0;
> +
> +unregister_mdio_enabled:
> +       axienet_mdio_mdc_disable(lp);
> +unregister:
> +       of_node_put(mdio_node);
> +       mdiobus_free(bus);
> +       lp->mii_bus = NULL;
> +       return ret;
>  }
> 
>  /**
> --
> 2.36.0

Reviewed-by: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v5 net-next 3/3] net: axienet: set mdio clock according to bus-frequency
  2022-11-17 15:40 ` [PATCH v5 net-next 3/3] net: axienet: set mdio clock according to bus-frequency Andy Chiu
  2022-11-17 15:46   ` Pandey, Radhey Shyam
@ 2022-11-18  0:07   ` Andrew Lunn
  1 sibling, 0 replies; 7+ messages in thread
From: Andrew Lunn @ 2022-11-18  0:07 UTC (permalink / raw)
  To: Andy Chiu
  Cc: davem, kuba, michal.simek, radhey.shyam.pandey, netdev,
	devicetree, linux-arm-kernel, robh+dt, pabeni, edumazet,
	greentime.hu

On Thu, Nov 17, 2022 at 11:40:14PM +0800, Andy Chiu wrote:
> Some FPGA platforms have 80KHz MDIO bus frequency constraint when
> connecting Ethernet to its on-board external Marvell PHY. Thus, we may
> have to set MDIO clock according to the DT. Otherwise, use the default
> 2.5 MHz, as specified by 802.3, if the entry is not present.
> 
> Also, change MAX_MDIO_FREQ to DEFAULT_MDIO_FREQ because we may actually
> set MDIO bus frequency higher than 2.5MHz if undelying devices support
> it. And properly disable the mdio bus clock in error path.
> 
> Signed-off-by: Andy Chiu <andy.chiu@sifive.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v5 net-next 0/3] net: axienet: Use a DT property to configure frequency of the MDIO bus
  2022-11-17 15:40 [PATCH v5 net-next 0/3] net: axienet: Use a DT property to configure frequency of the MDIO bus Andy Chiu
                   ` (2 preceding siblings ...)
  2022-11-17 15:40 ` [PATCH v5 net-next 3/3] net: axienet: set mdio clock according to bus-frequency Andy Chiu
@ 2022-11-21 10:40 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 7+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-11-21 10:40 UTC (permalink / raw)
  To: Andy Chiu
  Cc: davem, andrew, kuba, michal.simek, radhey.shyam.pandey, netdev,
	devicetree, linux-arm-kernel, robh+dt, pabeni, edumazet,
	greentime.hu

Hello:

This series was applied to netdev/net-next.git (master)
by David S. Miller <davem@davemloft.net>:

On Thu, 17 Nov 2022 23:40:11 +0800 you wrote:
> Some FPGA platforms have to set frequency of the MDIO bus lower than 2.5
> MHz. Thus, we use a DT property, which is "clock-frequency", to work
> with it at boot time. The default 2.5 MHz would be set if the property
> is not pressent. Also, factor out mdio enable/disable functions due to
> the api change since 253761a0e61b7.
> 
> Changelog:
> 
> [...]

Here is the summary with links:
  - [v5,net-next,1/3] net: axienet: Unexport and remove unused mdio functions
    https://git.kernel.org/netdev/net-next/c/29f8eefba3ba
  - [v5,net-next,2/3] dt-bindings: describe the support of "clock-frequency" in mdio
    https://git.kernel.org/netdev/net-next/c/6830604ec0c7
  - [v5,net-next,3/3] net: axienet: set mdio clock according to bus-frequency
    https://git.kernel.org/netdev/net-next/c/2e1f2c1066c1

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-11-21 10:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-17 15:40 [PATCH v5 net-next 0/3] net: axienet: Use a DT property to configure frequency of the MDIO bus Andy Chiu
2022-11-17 15:40 ` [PATCH v5 net-next 1/3] net: axienet: Unexport and remove unused mdio functions Andy Chiu
2022-11-17 15:40 ` [PATCH v5 net-next 2/3] dt-bindings: describe the support of "clock-frequency" in mdio Andy Chiu
2022-11-17 15:40 ` [PATCH v5 net-next 3/3] net: axienet: set mdio clock according to bus-frequency Andy Chiu
2022-11-17 15:46   ` Pandey, Radhey Shyam
2022-11-18  0:07   ` Andrew Lunn
2022-11-21 10:40 ` [PATCH v5 net-next 0/3] net: axienet: Use a DT property to configure frequency of the MDIO bus patchwork-bot+netdevbpf

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).