Skip to contentSkip to conversation

net: dsa: add missing phy address offset

PATCH In review Marcel Reichmuth 3 participants 5 messages Feb 20, 2019 – Feb 21, 2019

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: dsa: add missing phy address offset

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.

---
 drivers/net/dsa/mv88e6xxx/chip.c | 3 +++
 include/net/dsa.h                | 1 +
 net/dsa/slave.c                  | 3 ++-
 3 files changed, 6 insertions(+), 1 deletion(-)
drivers/net/dsa/mv88e6xxx/chip.c +3 -0
index 12fd7ce3f1ff..0ca649f784d2 100644
@@ -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.
include/net/dsa.h +1 -0
index b3eefe8e18fd..f9c9dc1f6d21 100644
@@ -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;
net/dsa/slave.c +2 -1
index a1c9fe155057..4f67dff34a3b 100644
@@ -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",
Signature · 1 line
2.11.0
#1 lore raw
Quoted 5 lines · 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.

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?

Quoted 53 lines
---
 drivers/net/dsa/mv88e6xxx/chip.c | 3 +++
 include/net/dsa.h                | 1 +
 net/dsa/slave.c                  | 3 ++-
 3 files changed, 6 insertions(+), 1 deletion(-)
drivers/net/dsa/mv88e6xxx/chip.c +3 -0
index 12fd7ce3f1ff..0ca649f784d2 100644
@@ -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.
include/net/dsa.h +1 -0
index b3eefe8e18fd..f9c9dc1f6d21 100644
@@ -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;
net/dsa/slave.c +2 -1
index a1c9fe155057..4f67dff34a3b 100644
@@ -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",
Signature · 1 line
Florian
maintainer
#2 lore raw
Quoted 18 lines · Florian Fainelli
Quoted 5 lines · 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.

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

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

};

Quoted 7 lines
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

#3 lore raw
Quoted 20 lines · Andrew Lunn
Quoted 19 lines · Florian Fainelli

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>;
	};
};
Quoted 9 lines
Quoted 1 line

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.

maintainer
#4 lore raw
Quoted 3 lines

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