[v5,net-next,08/13] net: dsa: felix: add functionality when not all ports are supported

Message ID 20230127193559.1001051-9-colin.foster@in-advantage.com
State New
Headers
Series add support for the the vsc7512 internal copper phys |

Commit Message

Colin Foster Jan. 27, 2023, 7:35 p.m. UTC
  When the Felix driver would probe the ports and verify functionality, it
would fail if it hit single port mode that wasn't supported by the driver.

The initial case for the VSC7512 driver will have physical ports that
exist, but aren't supported by the driver implementation. Add the
OCELOT_PORT_MODE_NONE macro to handle this scenario, and allow the Felix
driver to continue with all the ports that are currently functional.

Signed-off-by: Colin Foster <colin.foster@in-advantage.com>
---

v5
    * No changes

v4
    * New patch

---
 drivers/net/dsa/ocelot/felix.c | 11 ++++++++---
 drivers/net/dsa/ocelot/felix.h |  1 +
 2 files changed, 9 insertions(+), 3 deletions(-)
  

Comments

Florian Fainelli Jan. 27, 2023, 7:41 p.m. UTC | #1
On 1/27/2023 11:35 AM, Colin Foster wrote:
> When the Felix driver would probe the ports and verify functionality, it
> would fail if it hit single port mode that wasn't supported by the driver.
> 
> The initial case for the VSC7512 driver will have physical ports that
> exist, but aren't supported by the driver implementation. Add the
> OCELOT_PORT_MODE_NONE macro to handle this scenario, and allow the Felix
> driver to continue with all the ports that are currently functional.
> 
> Signed-off-by: Colin Foster <colin.foster@in-advantage.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
  

Patch

diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c
index d3ff6e8a82e9..d4cc9e60f369 100644
--- a/drivers/net/dsa/ocelot/felix.c
+++ b/drivers/net/dsa/ocelot/felix.c
@@ -1273,10 +1273,15 @@  static int felix_parse_ports_node(struct felix *felix,
 
 		err = felix_validate_phy_mode(felix, port, phy_mode);
 		if (err < 0) {
-			dev_err(dev, "Unsupported PHY mode %s on port %d\n",
-				phy_modes(phy_mode), port);
+			dev_info(dev, "Unsupported PHY mode %s on port %d\n",
+				 phy_modes(phy_mode), port);
 			of_node_put(child);
-			return err;
+
+			/* Leave port_phy_modes[port] = 0, which is also
+			 * PHY_INTERFACE_MODE_NA. This will perform a
+			 * best-effort to bring up as many ports as possible.
+			 */
+			continue;
 		}
 
 		port_phy_modes[port] = phy_mode;
diff --git a/drivers/net/dsa/ocelot/felix.h b/drivers/net/dsa/ocelot/felix.h
index 9e1ae1dde0d9..d5d0b30c0b75 100644
--- a/drivers/net/dsa/ocelot/felix.h
+++ b/drivers/net/dsa/ocelot/felix.h
@@ -7,6 +7,7 @@ 
 #define ocelot_to_felix(o)		container_of((o), struct felix, ocelot)
 #define FELIX_MAC_QUIRKS		OCELOT_QUIRK_PCS_PERFORMS_RATE_ADAPTATION
 
+#define OCELOT_PORT_MODE_NONE		0
 #define OCELOT_PORT_MODE_INTERNAL	BIT(0)
 #define OCELOT_PORT_MODE_SGMII		BIT(1)
 #define OCELOT_PORT_MODE_QSGMII		BIT(2)