diff mbox series

[1/1] net: dsa: b53: mmap: add dsa switch ops

Message ID 20230323170238.210687-2-noltari@gmail.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series net: dsa: b53: mmap: add dsa switch ops | expand

Checks

Context Check Description
netdev/series_format warning Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit fail Errors and warnings before: 20 this patch: 28
netdev/cc_maintainers success CCed 9 of 9 maintainers
netdev/build_clang fail Errors and warnings before: 18 this patch: 28
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn fail Errors and warnings before: 20 this patch: 28
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 145 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Álvaro Fernández Rojas March 23, 2023, 5:02 p.m. UTC
B53 MMAP switches have a MDIO Mux bus controller which should be used instead
of the default phy_read/phy_write ops used in the rest of the B53 controllers.
Therefore, in order to use the proper MDIO Mux bus controller we need to
replicate the default B53 DSA switch ops removing the phy_read/phy_write
entries.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
---
 drivers/net/dsa/b53/b53_common.c | 22 +++++++++---------
 drivers/net/dsa/b53/b53_mmap.c   | 40 ++++++++++++++++++++++++++++++++
 drivers/net/dsa/b53/b53_priv.h   | 11 +++++++++
 3 files changed, 62 insertions(+), 11 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
index 1f9b251a5452..9080506f2a9c 100644
--- a/drivers/net/dsa/b53/b53_common.c
+++ b/drivers/net/dsa/b53/b53_common.c
@@ -1096,7 +1096,7 @@  int b53_setup_devlink_resources(struct dsa_switch *ds)
 }
 EXPORT_SYMBOL(b53_setup_devlink_resources);
 
-static int b53_setup(struct dsa_switch *ds)
+int b53_setup(struct dsa_switch *ds)
 {
 	struct b53_device *dev = ds->priv;
 	unsigned int port;
@@ -1134,7 +1134,7 @@  static int b53_setup(struct dsa_switch *ds)
 	return b53_setup_devlink_resources(ds);
 }
 
-static void b53_teardown(struct dsa_switch *ds)
+void b53_teardown(struct dsa_switch *ds)
 {
 	dsa_devlink_resources_unregister(ds);
 }
@@ -1253,8 +1253,8 @@  static void b53_adjust_63xx_rgmii(struct dsa_switch *ds, int port,
 		phy_modes(interface));
 }
 
-static void b53_adjust_link(struct dsa_switch *ds, int port,
-			    struct phy_device *phydev)
+void b53_adjust_link(struct dsa_switch *ds, int port,
+		     struct phy_device *phydev)
 {
 	struct b53_device *dev = ds->priv;
 	struct ethtool_eee *p = &dev->ports[port].eee;
@@ -1356,8 +1356,8 @@  void b53_port_event(struct dsa_switch *ds, int port)
 }
 EXPORT_SYMBOL(b53_port_event);
 
-static void b53_phylink_get_caps(struct dsa_switch *ds, int port,
-				 struct phylink_config *config)
+void b53_phylink_get_caps(struct dsa_switch *ds, int port,
+			  struct phylink_config *config)
 {
 	struct b53_device *dev = ds->priv;
 
@@ -1401,9 +1401,9 @@  static void b53_phylink_get_caps(struct dsa_switch *ds, int port,
 	config->legacy_pre_march2020 = false;
 }
 
-static struct phylink_pcs *b53_phylink_mac_select_pcs(struct dsa_switch *ds,
-						      int port,
-						      phy_interface_t interface)
+struct phylink_pcs *b53_phylink_mac_select_pcs(struct dsa_switch *ds,
+					       int port,
+					       phy_interface_t interface)
 {
 	struct b53_device *dev = ds->priv;
 
@@ -2262,7 +2262,7 @@  int b53_set_mac_eee(struct dsa_switch *ds, int port, struct ethtool_eee *e)
 }
 EXPORT_SYMBOL(b53_set_mac_eee);
 
-static int b53_change_mtu(struct dsa_switch *ds, int port, int mtu)
+int b53_change_mtu(struct dsa_switch *ds, int port, int mtu)
 {
 	struct b53_device *dev = ds->priv;
 	bool enable_jumbo;
@@ -2277,7 +2277,7 @@  static int b53_change_mtu(struct dsa_switch *ds, int port, int mtu)
 	return b53_set_jumbo(dev, enable_jumbo, allow_10_100);
 }
 
-static int b53_get_max_mtu(struct dsa_switch *ds, int port)
+int b53_get_max_mtu(struct dsa_switch *ds, int port)
 {
 	return JMS_MAX_SIZE;
 }
diff --git a/drivers/net/dsa/b53/b53_mmap.c b/drivers/net/dsa/b53/b53_mmap.c
index 7bb774368f64..45481db7a891 100644
--- a/drivers/net/dsa/b53/b53_mmap.c
+++ b/drivers/net/dsa/b53/b53_mmap.c
@@ -22,6 +22,7 @@ 
 #include <linux/io.h>
 #include <linux/platform_device.h>
 #include <linux/platform_data/b53.h>
+#include <net/dsa.h>
 
 #include "b53_priv.h"
 
@@ -29,6 +30,44 @@  struct b53_mmap_priv {
 	void __iomem *regs;
 };
 
+static const struct dsa_switch_ops b53_mmap_switch_ops = {
+	.get_tag_protocol	= b53_get_tag_protocol,
+	.setup			= b53_setup,
+	.teardown		= b53_teardown,
+	.get_strings		= b53_get_strings,
+	.get_ethtool_stats	= b53_get_ethtool_stats,
+	.get_sset_count		= b53_get_sset_count,
+	.get_ethtool_phy_stats	= b53_get_ethtool_phy_stats,
+	.adjust_link		= b53_adjust_link,
+	.phylink_get_caps	= b53_phylink_get_caps,
+	.phylink_mac_select_pcs	= b53_phylink_mac_select_pcs,
+	.phylink_mac_config	= b53_phylink_mac_config,
+	.phylink_mac_link_down	= b53_phylink_mac_link_down,
+	.phylink_mac_link_up	= b53_phylink_mac_link_up,
+	.port_enable		= b53_enable_port,
+	.port_disable		= b53_disable_port,
+	.get_mac_eee		= b53_get_mac_eee,
+	.set_mac_eee		= b53_set_mac_eee,
+	.port_bridge_join	= b53_br_join,
+	.port_bridge_leave	= b53_br_leave,
+	.port_pre_bridge_flags	= b53_br_flags_pre,
+	.port_bridge_flags	= b53_br_flags,
+	.port_stp_state_set	= b53_br_set_stp_state,
+	.port_fast_age		= b53_br_fast_age,
+	.port_vlan_filtering	= b53_vlan_filtering,
+	.port_vlan_add		= b53_vlan_add,
+	.port_vlan_del		= b53_vlan_del,
+	.port_fdb_dump		= b53_fdb_dump,
+	.port_fdb_add		= b53_fdb_add,
+	.port_fdb_del		= b53_fdb_del,
+	.port_mirror_add	= b53_mirror_add,
+	.port_mirror_del	= b53_mirror_del,
+	.port_mdb_add		= b53_mdb_add,
+	.port_mdb_del		= b53_mdb_del,
+	.port_max_mtu		= b53_get_max_mtu,
+	.port_change_mtu	= b53_change_mtu,
+};
+
 static int b53_mmap_read8(struct b53_device *dev, u8 page, u8 reg, u8 *val)
 {
 	struct b53_mmap_priv *priv = dev->priv;
@@ -302,6 +341,7 @@  static int b53_mmap_probe(struct platform_device *pdev)
 	if (!dev)
 		return -ENOMEM;
 
+	dev->ds->ops = &b53_mmap_switch_ops;
 	dev->pdata = pdata;
 
 	platform_set_drvdata(pdev, dev);
diff --git a/drivers/net/dsa/b53/b53_priv.h b/drivers/net/dsa/b53/b53_priv.h
index a689a6950189..cd759b177c94 100644
--- a/drivers/net/dsa/b53/b53_priv.h
+++ b/drivers/net/dsa/b53/b53_priv.h
@@ -348,7 +348,16 @@  int b53_br_flags(struct dsa_switch *ds, int port,
 		 struct switchdev_brport_flags flags,
 		 struct netlink_ext_ack *extack);
 int b53_setup_devlink_resources(struct dsa_switch *ds);
+int b53_setup(struct dsa_switch *ds);
+void b53_teardown(struct dsa_switch *ds);
+void b53_adjust_link(struct dsa_switch *ds, int port,
+		     struct phy_device *phydev);
 void b53_port_event(struct dsa_switch *ds, int port);
+void b53_phylink_get_caps(struct dsa_switch *ds, int port,
+			  struct phylink_config *config);
+struct phylink_pcs *b53_phylink_mac_select_pcs(struct dsa_switch *ds,
+					       int port,
+					       phy_interface_t interface);
 void b53_phylink_mac_config(struct dsa_switch *ds, int port,
 			    unsigned int mode,
 			    const struct phylink_link_state *state);
@@ -396,5 +405,7 @@  void b53_eee_enable_set(struct dsa_switch *ds, int port, bool enable);
 int b53_eee_init(struct dsa_switch *ds, int port, struct phy_device *phy);
 int b53_get_mac_eee(struct dsa_switch *ds, int port, struct ethtool_eee *e);
 int b53_set_mac_eee(struct dsa_switch *ds, int port, struct ethtool_eee *e);
+int b53_change_mtu(struct dsa_switch *ds, int port, int mtu);
+int b53_get_max_mtu(struct dsa_switch *ds, int port);
 
 #endif