[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190116153419.3208-1-miquel.raynal@bootlin.com>
Date: Wed, 16 Jan 2019 16:34:19 +0100
From: Miquel Raynal <miquel.raynal@...tlin.com>
To: Andrew Lunn <andrew@...n.ch>,
Vivien Didelot <vivien.didelot@...il.com>,
Florian Fainelli <f.fainelli@...il.com>,
"David S. Miller" <davem@...emloft.net>
Cc: netdev@...r.kernel.org, <linux-kernel@...r.kernel.org>,
Thomas Petazzoni <thomas.petazzoni@...tlin.com>,
Gregory Clement <gregory.clement@...tlin.com>,
Antoine Tenart <antoine.tenart@...tlin.com>,
Maxime Chevallier <maxime.chevallier@...tlin.com>,
Nadav Haklai <nadavh@...vell.com>,
Miquel Raynal <miquel.raynal@...tlin.com>
Subject: [PATCH net-next] net: dsa: mv88e6xxx: Add suspend/resume callbacks
Bring S2RAM support to the mv88e6xxx DSA driver.
The content of the *_irq_poll() helper is moved in *_do_irq_poll() so
that that the function can be called from the ->resume() callback
without using the *work pointer.
Signed-off-by: Miquel Raynal <miquel.raynal@...tlin.com>
---
drivers/net/dsa/mv88e6xxx/chip.c | 52 ++++++++++++++++++++++++++++++--
1 file changed, 49 insertions(+), 3 deletions(-)
diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 8a517d8fb9d1..b88efa9b86e0 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -442,15 +442,21 @@ static int mv88e6xxx_g1_irq_setup(struct mv88e6xxx_chip *chip)
return err;
}
+static void mv88e6xxx_do_irq_poll(struct mv88e6xxx_chip *chip)
+{
+ mv88e6xxx_g1_irq_thread_work(chip);
+
+ kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work,
+ msecs_to_jiffies(100));
+}
+
static void mv88e6xxx_irq_poll(struct kthread_work *work)
{
struct mv88e6xxx_chip *chip = container_of(work,
struct mv88e6xxx_chip,
irq_poll_work.work);
- mv88e6xxx_g1_irq_thread_work(chip);
- kthread_queue_delayed_work(chip->kworker, &chip->irq_poll_work,
- msecs_to_jiffies(100));
+ mv88e6xxx_do_irq_poll(chip);
}
static int mv88e6xxx_irq_poll_setup(struct mv88e6xxx_chip *chip)
@@ -4651,6 +4657,45 @@ static const void *pdata_device_get_match_data(struct device *dev)
return NULL;
}
+static int __maybe_unused mv88e6xxx_suspend(struct device *dev)
+{
+ struct dsa_switch *ds = dev_get_drvdata(dev);
+ struct mv88e6xxx_chip *chip = ds->priv;
+
+ kthread_cancel_delayed_work_sync(&chip->irq_poll_work);
+
+ return dsa_switch_suspend(ds);
+}
+
+static int __maybe_unused mv88e6xxx_resume(struct device *dev)
+{
+ struct dsa_switch *ds = dev_get_drvdata(dev);
+ struct mv88e6xxx_chip *chip = ds->priv;
+ int ret;
+
+ mv88e6xxx_phy_init(chip);
+
+ mutex_lock(&chip->reg_lock);
+ ret = mv88e6xxx_switch_reset(chip);
+ mutex_unlock(&chip->reg_lock);
+ if (ret) {
+ dev_err(dev, "Failed to reset the switch\n");
+ return ret;
+ }
+
+ ret = mv88e6xxx_setup(ds);
+ if (ret) {
+ dev_err(dev, "Failed to setup the switch\n");
+ return ret;
+ }
+
+ mv88e6xxx_do_irq_poll(chip);
+
+ return dsa_switch_resume(ds);
+}
+
+static SIMPLE_DEV_PM_OPS(mv88e6xxx_pm_ops, mv88e6xxx_suspend, mv88e6xxx_resume);
+
static int mv88e6xxx_probe(struct mdio_device *mdiodev)
{
struct dsa_mv88e6xxx_pdata *pdata = mdiodev->dev.platform_data;
@@ -4835,6 +4880,7 @@ static struct mdio_driver mv88e6xxx_driver = {
.mdiodrv.driver = {
.name = "mv88e6085",
.of_match_table = mv88e6xxx_of_match,
+ .pm = &mv88e6xxx_pm_ops,
},
};
--
2.19.1
Powered by blists - more mailing lists