All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: dsa: add missing phy address offset
@ 2019-02-20 18:15 Marcel Reichmuth
  2019-02-20 19:27 ` Florian Fainelli
  0 siblings, 1 reply; 5+ messages in thread
From: Marcel Reichmuth @ 2019-02-20 18:15 UTC (permalink / raw)
  To: linux-kernel, netdev
  Cc: andrew, vivien.didelot, f.fainelli, davem, Marcel Reichmuth

When phys do not start at address 0 like on the mv88e6341 the wrong
phy address is used and therefore the slave ports can not be
initialized. This patch adds the proper offset to the phy address.

Signed-off-by: Marcel Reichmuth <marcel.reichmuth@netmodule.com>
---
 drivers/net/dsa/mv88e6xxx/chip.c | 3 +++
 include/net/dsa.h                | 1 +
 net/dsa/slave.c                  | 3 ++-
 3 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 12fd7ce3f1ff..0ca649f784d2 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -2198,12 +2198,15 @@ static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
 static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
 {
 	struct dsa_switch *ds = chip->ds;
+	struct dsa_port *dp = &ds->ports[port];
 	int err;
 	u16 reg;
 
 	chip->ports[port].chip = chip;
 	chip->ports[port].port = port;
 
+	dp->phy_base_addr = chip->info->phy_base_addr;
+
 	/* MAC Forcing register: don't force link, speed, duplex or flow control
 	 * state to any particular values on physical ports, but force the CPU
 	 * port and all DSA ports to their maximum bandwidth and full duplex.
diff --git a/include/net/dsa.h b/include/net/dsa.h
index b3eefe8e18fd..f9c9dc1f6d21 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -196,6 +196,7 @@ struct dsa_port {
 
 	struct dsa_switch	*ds;
 	unsigned int		index;
+	unsigned int		phy_base_addr;
 	const char		*name;
 	const struct dsa_port	*cpu_dp;
 	struct device_node	*dn;
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index a1c9fe155057..4f67dff34a3b 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -1221,7 +1221,8 @@ static int dsa_slave_phy_setup(struct net_device *slave_dev)
 		/* We could not connect to a designated PHY or SFP, so use the
 		 * switch internal MDIO bus instead
 		 */
-		ret = dsa_slave_phy_connect(slave_dev, dp->index);
+		ret = dsa_slave_phy_connect(slave_dev, dp->phy_base_addr +
+			dp->index);
 		if (ret) {
 			netdev_err(slave_dev,
 				   "failed to connect to port %d: %d\n",
-- 
2.11.0


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

* Re: [PATCH] net: dsa: add missing phy address offset
  2019-02-20 18:15 [PATCH] net: dsa: add missing phy address offset Marcel Reichmuth
@ 2019-02-20 19:27 ` Florian Fainelli
  2019-02-20 19:31   ` Andrew Lunn
  0 siblings, 1 reply; 5+ messages in thread
From: Florian Fainelli @ 2019-02-20 19:27 UTC (permalink / raw)
  To: Marcel Reichmuth, linux-kernel, netdev; +Cc: andrew, vivien.didelot, davem

On 2/20/19 10:15 AM, Marcel Reichmuth wrote:
> When phys do not start at address 0 like on the mv88e6341 the wrong
> phy address is used and therefore the slave ports can not be
> initialized. This patch adds the proper offset to the phy address.
> 
> Signed-off-by: Marcel Reichmuth <marcel.reichmuth@netmodule.com>

You are supposed to describe the port to PHY mapping using the binding,
so for instance:

ports {
	port@0 {
		reg = <0>;
		phy-handle = <&phy1>;
	};

};

mdio {
	phy1: phy@1 {
		reg = <1>;
	};
};

etc. is not that working for you?

> ---
>  drivers/net/dsa/mv88e6xxx/chip.c | 3 +++
>  include/net/dsa.h                | 1 +
>  net/dsa/slave.c                  | 3 ++-
>  3 files changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
> index 12fd7ce3f1ff..0ca649f784d2 100644
> --- a/drivers/net/dsa/mv88e6xxx/chip.c
> +++ b/drivers/net/dsa/mv88e6xxx/chip.c
> @@ -2198,12 +2198,15 @@ static int mv88e6xxx_setup_upstream_port(struct mv88e6xxx_chip *chip, int port)
>  static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port)
>  {
>  	struct dsa_switch *ds = chip->ds;
> +	struct dsa_port *dp = &ds->ports[port];
>  	int err;
>  	u16 reg;
>  
>  	chip->ports[port].chip = chip;
>  	chip->ports[port].port = port;
>  
> +	dp->phy_base_addr = chip->info->phy_base_addr;
> +
>  	/* MAC Forcing register: don't force link, speed, duplex or flow control
>  	 * state to any particular values on physical ports, but force the CPU
>  	 * port and all DSA ports to their maximum bandwidth and full duplex.
> diff --git a/include/net/dsa.h b/include/net/dsa.h
> index b3eefe8e18fd..f9c9dc1f6d21 100644
> --- a/include/net/dsa.h
> +++ b/include/net/dsa.h
> @@ -196,6 +196,7 @@ struct dsa_port {
>  
>  	struct dsa_switch	*ds;
>  	unsigned int		index;
> +	unsigned int		phy_base_addr;
>  	const char		*name;
>  	const struct dsa_port	*cpu_dp;
>  	struct device_node	*dn;
> diff --git a/net/dsa/slave.c b/net/dsa/slave.c
> index a1c9fe155057..4f67dff34a3b 100644
> --- a/net/dsa/slave.c
> +++ b/net/dsa/slave.c
> @@ -1221,7 +1221,8 @@ static int dsa_slave_phy_setup(struct net_device *slave_dev)
>  		/* We could not connect to a designated PHY or SFP, so use the
>  		 * switch internal MDIO bus instead
>  		 */
> -		ret = dsa_slave_phy_connect(slave_dev, dp->index);
> +		ret = dsa_slave_phy_connect(slave_dev, dp->phy_base_addr +
> +			dp->index);
>  		if (ret) {
>  			netdev_err(slave_dev,
>  				   "failed to connect to port %d: %d\n",
> 


-- 
Florian

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

* Re: [PATCH] net: dsa: add missing phy address offset
  2019-02-20 19:27 ` Florian Fainelli
@ 2019-02-20 19:31   ` Andrew Lunn
  2019-02-21  7:53     ` Marcel Reichmuth
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Lunn @ 2019-02-20 19:31 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: Marcel Reichmuth, linux-kernel, netdev, vivien.didelot, davem

On Wed, Feb 20, 2019 at 11:27:16AM -0800, Florian Fainelli wrote:
> On 2/20/19 10:15 AM, Marcel Reichmuth wrote:
> > When phys do not start at address 0 like on the mv88e6341 the wrong
> > phy address is used and therefore the slave ports can not be
> > initialized. This patch adds the proper offset to the phy address.
> > 
> > Signed-off-by: Marcel Reichmuth <marcel.reichmuth@netmodule.com>
> 
> You are supposed to describe the port to PHY mapping using the binding,
> so for instance:
> 
> ports {
> 	port@0 {
> 		reg = <0>;
> 		phy-handle = <&phy1>;
> 	};
> 
> };
> 
> mdio {
> 	phy1: phy@1 {
> 		reg = <1>;
> 	};
> };
> 
> etc. is not that working for you?


The Espressobin does exactly this:

arch/arm64/boot/dts/marvell/armada-3720-espressobin.dts 

It also uses the 6341.

	Andrew

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

* Re: [PATCH] net: dsa: add missing phy address offset
  2019-02-20 19:31   ` Andrew Lunn
@ 2019-02-21  7:53     ` Marcel Reichmuth
  2019-02-21 13:10       ` Andrew Lunn
  0 siblings, 1 reply; 5+ messages in thread
From: Marcel Reichmuth @ 2019-02-21  7:53 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: Florian Fainelli, linux-kernel, netdev, vivien.didelot, davem

On Wed, Feb 20, 2019 at 08:31:22PM +0100, Andrew Lunn wrote:
> On Wed, Feb 20, 2019 at 11:27:16AM -0800, Florian Fainelli wrote:
> > On 2/20/19 10:15 AM, Marcel Reichmuth wrote:
> > 
> > You are supposed to describe the port to PHY mapping using the binding,
> > so for instance:
> > 
> > ports {
> > 	port@0 {
> > 		reg = <0>;
> > 		phy-handle = <&phy1>;
> > 	};
> > 
> > };
> > 
> > mdio {
> > 	phy1: phy@1 {
> > 		reg = <1>;
> > 	};
> > };
> > 
> > etc. is not that working for you?
> 
> 
> The Espressobin does exactly this:
> 
> arch/arm64/boot/dts/marvell/armada-3720-espressobin.dts 
> 
> It also uses the 6341.
>
Thank you very much for your hints. Yes that works indeed too. I
just assumed it was intended to work automatically with the 
built-in phys as it does with the other switches I am using.


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

* Re: [PATCH] net: dsa: add missing phy address offset
  2019-02-21  7:53     ` Marcel Reichmuth
@ 2019-02-21 13:10       ` Andrew Lunn
  0 siblings, 0 replies; 5+ messages in thread
From: Andrew Lunn @ 2019-02-21 13:10 UTC (permalink / raw)
  To: Marcel Reichmuth
  Cc: Florian Fainelli, linux-kernel, netdev, vivien.didelot, davem

> Thank you very much for your hints. Yes that works indeed too. I
> just assumed it was intended to work automatically with the 
> built-in phys as it does with the other switches I am using.

Hi Marcel

The basic assumption is there is a one to one mapping of port number
to PHY address. All the other Marvell switch have this mapping.

Since the needed flexibility exists to support this, and Marvell has
not repeated this odd design, i decided not to do anything about it in
code.

	Andrew

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

end of thread, other threads:[~2019-02-21 13:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-20 18:15 [PATCH] net: dsa: add missing phy address offset Marcel Reichmuth
2019-02-20 19:27 ` Florian Fainelli
2019-02-20 19:31   ` Andrew Lunn
2019-02-21  7:53     ` Marcel Reichmuth
2019-02-21 13:10       ` Andrew Lunn

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.