All of lore.kernel.org
 help / color / mirror / Atom feed
From: andrew@lunn.ch (Andrew Lunn)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH net-next 03/18] net: mvpp2: set the SMI PHY address when connecting to the PHY
Date: Wed, 26 Jul 2017 18:08:06 +0200	[thread overview]
Message-ID: <20170726160806.GF12049@lunn.ch> (raw)
In-Reply-To: <20170724134848.19330-4-antoine.tenart@free-electrons.com>

On Mon, Jul 24, 2017 at 03:48:33PM +0200, Antoine Tenart wrote:
> When connecting to the PHY, explicitly set the SMI PHY address in the
> controller registers to configure a given port to be connected to the
> selected PHY.
> 
> Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
> ---
>  drivers/net/ethernet/marvell/mvpp2.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c
> index 1e592abc9067..6ffff929b22a 100644
> --- a/drivers/net/ethernet/marvell/mvpp2.c
> +++ b/drivers/net/ethernet/marvell/mvpp2.c
> @@ -359,6 +359,8 @@
>  #define MVPP22_SMI_MISC_CFG_REG			0x1204
>  #define     MVPP22_SMI_POLLING_EN		BIT(10)
>  
> +#define MVPP22_SMI_PHY_ADDR(port)		(0x120c + (port) * 0x4)
> +
>  #define MVPP22_GMAC_BASE(port)		(0x7000 + (port) * 0x1000 + 0xe00)
>  
>  #define MVPP2_CAUSE_TXQ_SENT_DESC_ALL_MASK	0xff
> @@ -5939,7 +5941,9 @@ static void mvpp21_get_mac_address(struct mvpp2_port *port, unsigned char *addr)
>  
>  static int mvpp2_phy_connect(struct mvpp2_port *port)
>  {
> +	struct mvpp2 *priv = port->priv;
>  	struct phy_device *phy_dev;
> +	u32 phy_addr;
>  
>  	phy_dev = of_phy_connect(port->dev, port->phy_node, mvpp2_link_event, 0,
>  				 port->phy_interface);
> @@ -5954,6 +5958,16 @@ static int mvpp2_phy_connect(struct mvpp2_port *port)
>  	port->duplex  = 0;
>  	port->speed   = 0;
>  
> +	if (priv->hw_version != MVPP22)
> +		return 0;
> +
> +	/* Set the SMI PHY address */
> +	if (of_property_read_u32(port->phy_node, "reg", &phy_addr)) {
> +		netdev_err(port->dev, "cannot find the PHY address\n");
> +		return -EINVAL;
> +	}
> +
> +	writel(phy_addr, priv->iface_base + MVPP22_SMI_PHY_ADDR(port->gop_id));
>  	return 0;
>  }

Hi Antoine

You could use phy_dev->mdiodev->addr, rather than parse the DT.

Why does the MAC need to know this address? The phylib and PHY driver
should be the only thing accessing the PHY, otherwise you are asking
for trouble.

What if the PHY is hanging off some other mdio bus? I've got a
freescale board with dual ethernets and a Marvell switch on the
hardware MDIO bus and a PHY on a bit-banging MDIO bus.

	 Andrew

WARNING: multiple messages have this Message-ID (diff)
From: Andrew Lunn <andrew@lunn.ch>
To: Antoine Tenart <antoine.tenart@free-electrons.com>
Cc: davem@davemloft.net, jason@lakedaemon.net,
	gregory.clement@free-electrons.com,
	sebastian.hesselbarth@gmail.com,
	thomas.petazzoni@free-electrons.com, nadavh@marvell.com,
	linux@armlinux.org.uk, mw@semihalf.com, stefanc@marvell.com,
	netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH net-next 03/18] net: mvpp2: set the SMI PHY address when connecting to the PHY
Date: Wed, 26 Jul 2017 18:08:06 +0200	[thread overview]
Message-ID: <20170726160806.GF12049@lunn.ch> (raw)
In-Reply-To: <20170724134848.19330-4-antoine.tenart@free-electrons.com>

On Mon, Jul 24, 2017 at 03:48:33PM +0200, Antoine Tenart wrote:
> When connecting to the PHY, explicitly set the SMI PHY address in the
> controller registers to configure a given port to be connected to the
> selected PHY.
> 
> Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
> ---
>  drivers/net/ethernet/marvell/mvpp2.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c
> index 1e592abc9067..6ffff929b22a 100644
> --- a/drivers/net/ethernet/marvell/mvpp2.c
> +++ b/drivers/net/ethernet/marvell/mvpp2.c
> @@ -359,6 +359,8 @@
>  #define MVPP22_SMI_MISC_CFG_REG			0x1204
>  #define     MVPP22_SMI_POLLING_EN		BIT(10)
>  
> +#define MVPP22_SMI_PHY_ADDR(port)		(0x120c + (port) * 0x4)
> +
>  #define MVPP22_GMAC_BASE(port)		(0x7000 + (port) * 0x1000 + 0xe00)
>  
>  #define MVPP2_CAUSE_TXQ_SENT_DESC_ALL_MASK	0xff
> @@ -5939,7 +5941,9 @@ static void mvpp21_get_mac_address(struct mvpp2_port *port, unsigned char *addr)
>  
>  static int mvpp2_phy_connect(struct mvpp2_port *port)
>  {
> +	struct mvpp2 *priv = port->priv;
>  	struct phy_device *phy_dev;
> +	u32 phy_addr;
>  
>  	phy_dev = of_phy_connect(port->dev, port->phy_node, mvpp2_link_event, 0,
>  				 port->phy_interface);
> @@ -5954,6 +5958,16 @@ static int mvpp2_phy_connect(struct mvpp2_port *port)
>  	port->duplex  = 0;
>  	port->speed   = 0;
>  
> +	if (priv->hw_version != MVPP22)
> +		return 0;
> +
> +	/* Set the SMI PHY address */
> +	if (of_property_read_u32(port->phy_node, "reg", &phy_addr)) {
> +		netdev_err(port->dev, "cannot find the PHY address\n");
> +		return -EINVAL;
> +	}
> +
> +	writel(phy_addr, priv->iface_base + MVPP22_SMI_PHY_ADDR(port->gop_id));
>  	return 0;
>  }

Hi Antoine

You could use phy_dev->mdiodev->addr, rather than parse the DT.

Why does the MAC need to know this address? The phylib and PHY driver
should be the only thing accessing the PHY, otherwise you are asking
for trouble.

What if the PHY is hanging off some other mdio bus? I've got a
freescale board with dual ethernets and a Marvell switch on the
hardware MDIO bus and a PHY on a bit-banging MDIO bus.

	 Andrew

  parent reply	other threads:[~2017-07-26 16:08 UTC|newest]

Thread overview: 104+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-24 13:48 [PATCH net-next 00/18] net: mvpp2: MAC/GoP configuration and optional PHYs Antoine Tenart
2017-07-24 13:48 ` Antoine Tenart
2017-07-24 13:48 ` [PATCH net-next 01/18] net: mvpp2: unify register definitions coding style Antoine Tenart
2017-07-24 13:48   ` Antoine Tenart
2017-07-24 13:48 ` [PATCH net-next 02/18] net: mvpp2: fix the synchronization module bypass macro name Antoine Tenart
2017-07-24 13:48   ` Antoine Tenart
2017-07-24 13:48 ` [PATCH net-next 03/18] net: mvpp2: set the SMI PHY address when connecting to the PHY Antoine Tenart
2017-07-24 13:48   ` Antoine Tenart
2017-07-24 16:40   ` Sergei Shtylyov
2017-07-24 16:40     ` Sergei Shtylyov
2017-07-25  8:42     ` Antoine Tenart
2017-07-25  8:42       ` Antoine Tenart
2017-07-26 16:08   ` Andrew Lunn [this message]
2017-07-26 16:08     ` Andrew Lunn
2017-07-28  1:49     ` Antoine Tenart
2017-07-28  1:49       ` Antoine Tenart
2017-07-28  4:21       ` Andrew Lunn
2017-07-28  4:21         ` Andrew Lunn
2017-08-22 14:41         ` Antoine Tenart
2017-08-22 14:41           ` Antoine Tenart
2017-08-22 14:50           ` Andrew Lunn
2017-08-22 14:50             ` Andrew Lunn
2017-08-23 10:40         ` [EXT] " Stefan Chulski
2017-08-23 10:40           ` Stefan Chulski
2017-08-23 12:34           ` Andrew Lunn
2017-08-23 12:34             ` Andrew Lunn
2017-08-23 13:30             ` Stefan Chulski
2017-08-23 13:30               ` Stefan Chulski
2017-08-23 13:34               ` Andrew Lunn
2017-08-23 13:34                 ` Andrew Lunn
2017-07-24 13:48 ` [PATCH net-next 04/18] net: mvpp2: move the mii configuration in the ndo_open path Antoine Tenart
2017-07-24 13:48   ` Antoine Tenart
2017-07-26 16:11   ` Andrew Lunn
2017-07-26 16:11     ` Andrew Lunn
2017-07-28  1:44     ` Antoine Tenart
2017-07-28  1:44       ` Antoine Tenart
2017-07-24 13:48 ` [PATCH net-next 05/18] net: mvpp2: initialize the GMAC when using a port Antoine Tenart
2017-07-24 13:48   ` Antoine Tenart
2017-07-26 16:14   ` Andrew Lunn
2017-07-26 16:14     ` Andrew Lunn
2017-07-24 13:48 ` [PATCH net-next 06/18] net: mvpp2: initialize the XLG MAC " Antoine Tenart
2017-07-24 13:48   ` Antoine Tenart
2017-07-24 13:48 ` [PATCH net-next 07/18] net: mvpp2: initialize the GoP Antoine Tenart
2017-07-24 13:48   ` Antoine Tenart
2017-07-26 16:16   ` Andrew Lunn
2017-07-26 16:16     ` Andrew Lunn
2017-07-24 13:48 ` [PATCH net-next 08/18] net: mvpp2: make the phy optional Antoine Tenart
2017-07-24 13:48   ` Antoine Tenart
2017-07-26 16:20   ` Andrew Lunn
2017-07-26 16:20     ` Andrew Lunn
2017-07-28  1:50     ` Antoine Tenart
2017-07-28  1:50       ` Antoine Tenart
2017-07-24 13:48 ` [PATCH net-next 09/18] net: mvpp2: use named interrupts Antoine Tenart
2017-07-24 13:48   ` Antoine Tenart
2017-07-24 16:49   ` Sergei Shtylyov
2017-07-24 16:49     ` Sergei Shtylyov
2017-07-25  8:45     ` Antoine Tenart
2017-07-25  8:45       ` Antoine Tenart
2017-07-24 13:48 ` [PATCH net-next 10/18] net: mvpp2: use the GoP interrupt for link status changes Antoine Tenart
2017-07-24 13:48   ` Antoine Tenart
2017-07-24 22:58   ` Marcin Wojtas
2017-07-24 22:58     ` Marcin Wojtas
2017-07-25  8:47     ` Antoine Tenart
2017-07-25  8:47       ` Antoine Tenart
2017-07-25 13:17   ` Thomas Petazzoni
2017-07-25 13:17     ` Thomas Petazzoni
2017-07-26  0:07     ` Antoine Tenart
2017-07-26  0:07       ` Antoine Tenart
2017-07-26 16:26   ` Andrew Lunn
2017-07-26 16:26     ` Andrew Lunn
2017-07-26 19:38     ` Russell King - ARM Linux
2017-07-26 19:38       ` Russell King - ARM Linux
2017-08-23  8:25     ` Antoine Tenart
2017-08-23  8:25       ` Antoine Tenart
2017-08-23 15:24       ` [EXT] " Stefan Chulski
2017-08-23 15:24         ` Stefan Chulski
2017-08-23 16:04         ` Antoine Tenart
2017-08-23 16:04           ` Antoine Tenart
2017-08-23 21:05           ` Marcin Wojtas
2017-08-23 21:05             ` Marcin Wojtas
2017-08-24 10:59             ` Antoine Tenart
2017-08-24 10:59               ` Antoine Tenart
2017-07-24 13:48 ` [PATCH net-next 11/18] Documentation/bindings: net: marvell-pp2: add the system controller Antoine Tenart
2017-07-24 13:48   ` Antoine Tenart
2017-07-24 13:48 ` [PATCH net-next 12/18] Documentation/bindings: net: marvell-pp2: add the interrupt-names Antoine Tenart
2017-07-24 13:48   ` Antoine Tenart
2017-07-24 13:48 ` [PATCH net-next 13/18] arm64: dts: marvell: cp110: use named interrupts for the Ethernet ports Antoine Tenart
2017-07-24 13:48   ` Antoine Tenart
2017-07-24 13:48 ` [PATCH net-next 14/18] arm64: dts: marvell: cp110: add PPv2 port interrupts Antoine Tenart
2017-07-24 13:48   ` Antoine Tenart
2017-07-24 13:48 ` [PATCH net-next 15/18] arm64: dts: marvell: add a reference to the sysctrl syscon in the ppv2 node Antoine Tenart
2017-07-24 13:48   ` Antoine Tenart
2017-07-24 13:48 ` [PATCH net-next 16/18] arm64: dts: marvell: mcbin: enable more networking ports Antoine Tenart
2017-07-24 13:48   ` Antoine Tenart
2017-07-24 13:48 ` [PATCH net-next 17/18] arm64: dts: marvell: 7040-db: enable the SFP port Antoine Tenart
2017-07-24 13:48   ` Antoine Tenart
2017-07-24 13:48 ` [PATCH net-next 18/18] arm64: dts: marvell: 8040-db: enable the SFP ports Antoine Tenart
2017-07-24 13:48   ` Antoine Tenart
2017-07-24 23:56 ` [PATCH net-next 00/18] net: mvpp2: MAC/GoP configuration and optional PHYs Marcin Wojtas
2017-07-24 23:56   ` Marcin Wojtas
2017-07-25  8:48   ` Antoine Tenart
2017-07-25  8:48     ` Antoine Tenart
2017-07-25 10:45     ` Marcin Wojtas
2017-07-25 10:45       ` Marcin Wojtas

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=20170726160806.GF12049@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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 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.