netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Álvaro Fernández Rojas" <noltari@gmail.com>
To: f.fainelli@gmail.com, jonas.gorski@gmail.com, andrew@lunn.ch,
	olteanv@gmail.com, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com, linux@armlinux.org.uk,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: "Álvaro Fernández Rojas" <noltari@gmail.com>
Subject: [PATCH 1/1] net: dsa: b53: mmap: add dsa switch ops
Date: Thu, 23 Mar 2023 18:02:38 +0100	[thread overview]
Message-ID: <20230323170238.210687-2-noltari@gmail.com> (raw)
In-Reply-To: <20230323170238.210687-1-noltari@gmail.com>

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 --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
-- 
2.30.2


  reply	other threads:[~2023-03-23 17:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-23 17:02 [PATCH 0/1] net: dsa: b53: mmap: add dsa switch ops Álvaro Fernández Rojas
2023-03-23 17:02 ` Álvaro Fernández Rojas [this message]
2023-03-23 18:19 ` Florian Fainelli
2023-03-23 19:42   ` Álvaro Fernández Rojas
2023-03-23 19:45     ` Florian Fainelli

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=20230323170238.210687-2-noltari@gmail.com \
    --to=noltari@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=jonas.gorski@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).