diff mbox

[U-Boot,08/10] net: axi_emac: Enable access to MDIO in probe

Message ID f64ad8095cf819e9a489a6a1efe4dd65aa08b4c7.1449835152.git.michal.simek@xilinx.com
State Superseded
Delegated to: Michal Simek
Headers show

Commit Message

Michal Simek Dec. 11, 2015, 11:59 a.m. UTC
Detect phy when driver probes.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

 drivers/net/xilinx_axi_emac.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

Comments

Joe Hershberger Dec. 15, 2015, 8:42 p.m. UTC | #1
On Fri, Dec 11, 2015 at 5:59 AM, Michal Simek <michal.simek@xilinx.com> wrote:
> Detect phy when driver probes.
>
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>

A few nits below, but otherwise,

Acked-by: Joe Hershberger <joe.hershberger@ni.com>

> ---
>
>  drivers/net/xilinx_axi_emac.c | 22 ++++++++++++++++++++--
>  1 file changed, 20 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/xilinx_axi_emac.c b/drivers/net/xilinx_axi_emac.c
> index c03f8f730d3a..bff4d1b5affe 100644
> --- a/drivers/net/xilinx_axi_emac.c
> +++ b/drivers/net/xilinx_axi_emac.c
> @@ -222,10 +222,10 @@ static u32 phywrite(struct axidma_priv *priv, u32 phyaddress, u32 registernum,
>  }
>
>  /* Setting axi emac and phy to proper setting */

I think you didn't mean to leave this comment here.

> -static int setup_phy(struct udevice *dev)
> +static int axiemac_phy_init(struct udevice *dev)
>  {
>         u16 phyreg;
> -       u32 i, speed, emmc_reg, ret;
> +       u32 i, ret;
>         struct axidma_priv *priv = dev_get_priv(dev);
>         struct axi_regs *regs = priv->iobase;
>         struct phy_device *phydev;
> @@ -237,6 +237,9 @@ static int setup_phy(struct udevice *dev)
>                         SUPPORTED_1000baseT_Half |
>                         SUPPORTED_1000baseT_Full;
>
> +       /* Set default MDIO divisor */
> +       out_be32(&regs->mdio_mc, XAE_MDIO_DIV_DFT | XAE_MDIO_MC_MDIOEN_MASK);
> +
>         if (priv->phyaddr == -1) {
>                 /* Detect the PHY address */
>                 for (i = 31; i >= 0; i--) {
> @@ -259,6 +262,18 @@ static int setup_phy(struct udevice *dev)
>         phydev->advertising = phydev->supported;
>         priv->phydev = phydev;
>         phy_config(phydev);
> +
> +       return 0;
> +}
> +
> +/* Setting axi emac and phy to proper setting */
> +static int setup_phy(struct udevice *dev)
> +{
> +       u32 speed, emmc_reg;
> +       struct axidma_priv *priv = dev_get_priv(dev);
> +       struct axi_regs *regs = priv->iobase;
> +       struct phy_device *phydev = priv->phydev;
> +
>         if (phy_startup(phydev)) {
>                 printf("axiemac: could not initialize PHY %s\n",
>                        phydev->dev->name);
> @@ -358,6 +373,7 @@ static int axi_ethernet_init(struct axidma_priv *priv)
>         /* Set default MDIO divisor */
>         out_be32(&regs->mdio_mc, XAE_MDIO_DIV_DFT | XAE_MDIO_MC_MDIOEN_MASK);
>
> +

Why do we need two blank lines?

>         debug("axiemac: InitHw done\n");
>         return 0;
>  }
> @@ -621,6 +637,8 @@ static int axi_emac_probe(struct udevice *dev)
>         if (ret)
>                 return ret;
>
> +       axiemac_phy_init(dev);
> +
>         return 0;
>  }
>
> --
> 1.9.1
>
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
Michal Simek Dec. 16, 2015, 8:26 a.m. UTC | #2
On 15.12.2015 21:42, Joe Hershberger wrote:
> On Fri, Dec 11, 2015 at 5:59 AM, Michal Simek <michal.simek@xilinx.com> wrote:
>> Detect phy when driver probes.
>>
>> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> 
> A few nits below, but otherwise,
> 
> Acked-by: Joe Hershberger <joe.hershberger@ni.com>

All nits are valid and fixed in v2.

Thanks,
Michal
diff mbox

Patch

diff --git a/drivers/net/xilinx_axi_emac.c b/drivers/net/xilinx_axi_emac.c
index c03f8f730d3a..bff4d1b5affe 100644
--- a/drivers/net/xilinx_axi_emac.c
+++ b/drivers/net/xilinx_axi_emac.c
@@ -222,10 +222,10 @@  static u32 phywrite(struct axidma_priv *priv, u32 phyaddress, u32 registernum,
 }
 
 /* Setting axi emac and phy to proper setting */
-static int setup_phy(struct udevice *dev)
+static int axiemac_phy_init(struct udevice *dev)
 {
 	u16 phyreg;
-	u32 i, speed, emmc_reg, ret;
+	u32 i, ret;
 	struct axidma_priv *priv = dev_get_priv(dev);
 	struct axi_regs *regs = priv->iobase;
 	struct phy_device *phydev;
@@ -237,6 +237,9 @@  static int setup_phy(struct udevice *dev)
 			SUPPORTED_1000baseT_Half |
 			SUPPORTED_1000baseT_Full;
 
+	/* Set default MDIO divisor */
+	out_be32(&regs->mdio_mc, XAE_MDIO_DIV_DFT | XAE_MDIO_MC_MDIOEN_MASK);
+
 	if (priv->phyaddr == -1) {
 		/* Detect the PHY address */
 		for (i = 31; i >= 0; i--) {
@@ -259,6 +262,18 @@  static int setup_phy(struct udevice *dev)
 	phydev->advertising = phydev->supported;
 	priv->phydev = phydev;
 	phy_config(phydev);
+
+	return 0;
+}
+
+/* Setting axi emac and phy to proper setting */
+static int setup_phy(struct udevice *dev)
+{
+	u32 speed, emmc_reg;
+	struct axidma_priv *priv = dev_get_priv(dev);
+	struct axi_regs *regs = priv->iobase;
+	struct phy_device *phydev = priv->phydev;
+
 	if (phy_startup(phydev)) {
 		printf("axiemac: could not initialize PHY %s\n",
 		       phydev->dev->name);
@@ -358,6 +373,7 @@  static int axi_ethernet_init(struct axidma_priv *priv)
 	/* Set default MDIO divisor */
 	out_be32(&regs->mdio_mc, XAE_MDIO_DIV_DFT | XAE_MDIO_MC_MDIOEN_MASK);
 
+
 	debug("axiemac: InitHw done\n");
 	return 0;
 }
@@ -621,6 +637,8 @@  static int axi_emac_probe(struct udevice *dev)
 	if (ret)
 		return ret;
 
+	axiemac_phy_init(dev);
+
 	return 0;
 }