netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: netdev <netdev@vger.kernel.org>
Cc: Vivien Didelot <vivien.didelot@gmail.com>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Pavel Machek <pavel@ucw.cz>, Andrew Lunn <andrew@lunn.ch>
Subject: [PATCH RFC RFT net-next 05/10] net: dsa: mv88e6060: Support probing as an mdio device
Date: Wed, 30 Jan 2019 01:37:53 +0100	[thread overview]
Message-ID: <20190130003758.23852-6-andrew@lunn.ch> (raw)
In-Reply-To: <20190130003758.23852-1-andrew@lunn.ch>

Probing DSA devices as platform devices has been superseded by using
normal bus drivers. Add support for probing the mv88e6060 device as an
mdio device.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/dsa/mv88e6060.c | 61 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 60 insertions(+), 1 deletion(-)

diff --git a/drivers/net/dsa/mv88e6060.c b/drivers/net/dsa/mv88e6060.c
index 00fdf155dcec..aaa176edafc0 100644
--- a/drivers/net/dsa/mv88e6060.c
+++ b/drivers/net/dsa/mv88e6060.c
@@ -280,19 +280,78 @@ static struct dsa_switch_driver mv88e6060_switch_drv = {
 	.ops		= &mv88e6060_switch_ops,
 };
 
+static int mv88e6060_probe(struct mdio_device *mdiodev)
+{
+	struct device *dev = &mdiodev->dev;
+	struct mv88e6060_priv *priv;
+	struct dsa_switch *ds;
+	const char *name;
+
+	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
+	if (!priv)
+		return -ENOMEM;
+
+	priv->bus = mdiodev->bus;
+	priv->sw_addr = mdiodev->addr;
+
+	name = mv88e6060_get_name(priv->bus, priv->sw_addr);
+	if (!name)
+		return -ENODEV;
+
+	dev_info(dev, "switch %s detected\n", name);
+
+	ds = dsa_switch_alloc(dev, MV88E6060_PORTS);
+	if (!ds)
+		return -ENOMEM;
+
+	ds->priv = priv;
+	ds->dev = dev;
+	ds->ops = &mv88e6060_switch_ops;
+
+	dev_set_drvdata(dev, ds);
+
+	return dsa_register_switch(ds);
+}
+
+static void mv88e6060_remove(struct mdio_device *mdiodev)
+{
+	struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
+
+	dsa_unregister_switch(ds);
+}
+
+static const struct of_device_id mv88e6060_of_match[] = {
+        {
+                .compatible = "marvell,mv88e6060",
+        },
+        { /* sentinel */ },
+};
+
+static struct mdio_driver mv88e6060_driver = {
+        .probe  = mv88e6060_probe,
+        .remove = mv88e6060_remove,
+        .mdiodrv.driver = {
+                .name = "mv88e6060",
+                .of_match_table = mv88e6060_of_match,
+        },
+};
+
 static int __init mv88e6060_init(void)
 {
 	register_switch_driver(&mv88e6060_switch_drv);
-	return 0;
+	return mdio_driver_register(&mv88e6060_driver);
 }
 module_init(mv88e6060_init);
 
 static void __exit mv88e6060_cleanup(void)
 {
+	mdio_driver_unregister(&mv88e6060_driver);
 	unregister_switch_driver(&mv88e6060_switch_drv);
 }
 module_exit(mv88e6060_cleanup);
 
+
+
 MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>");
 MODULE_DESCRIPTION("Driver for Marvell 88E6060 ethernet switch chip");
 MODULE_LICENSE("GPL");
-- 
2.20.1


  parent reply	other threads:[~2019-01-30  0:44 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-30  0:37 [PATCH RFC RFT net-next 00/10] Modernize mv88e6060 and remove legacy probe Andrew Lunn
2019-01-30  0:37 ` [PATCH RFC RFT net-next 01/10] net: dsa: mv88e6xxx: Remove legacy probe support Andrew Lunn
2019-01-30  0:37 ` [PATCH RFC RFT net-next 02/10] net: dsa: mv88e6060: Replace ds with priv Andrew Lunn
2019-01-30  0:37 ` [PATCH RFC RFT net-next 03/10] net: dsa: mv88e6060: Replace REG_WRITE macro Andrew Lunn
2019-01-30  9:24   ` Pavel Machek
2019-01-30 15:42     ` Andrew Lunn
2019-01-30  0:37 ` [PATCH RFC RFT net-next 04/10] net: dsa: mv88e6060: Replace REG_READ macro Andrew Lunn
2019-01-30  0:37 ` Andrew Lunn [this message]
2019-01-30  0:37 ` [PATCH RFC RFT net-next 06/10] net: dsa: mv88e6060: Remove support for legacy probing Andrew Lunn
2019-01-30  0:37 ` [PATCH RFC RFT net-next 07/10] net: dsa: mv88e6060: Add SPDX header Andrew Lunn
2019-01-30  0:37 ` [PATCH RFC RFT net-next 08/10] net: dsa: Remove legacy probing support Andrew Lunn
2019-01-30  0:37 ` [PATCH RFC RFT net-next 09/10] arch: arm: dts: Remove disabled marvell,dsa properties Andrew Lunn
2019-01-30  0:37 ` [PATCH RFC RFT net-next 10/10] bt-bindings: net: DSA: Remove legacy binding Andrew Lunn
2019-01-30  9:27 ` [PATCH RFC RFT net-next 00/10] Modernize mv88e6060 and remove legacy probe Pavel Machek
2019-02-06 11:31 ` Gregory CLEMENT
2019-02-06 12:58   ` Andrew Lunn

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=20190130003758.23852-6-andrew@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=f.fainelli@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=vivien.didelot@gmail.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).