Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1208832imu; Wed, 16 Jan 2019 14:51:29 -0800 (PST) X-Google-Smtp-Source: ALg8bN69Jgdu94vOEwJ3S0b0VZIGnONJ1r2QvZM+HjaWHZgyfzxJYLCxH0H9XMSC8ske3yJgWp1u X-Received: by 2002:a62:710a:: with SMTP id m10mr12210625pfc.69.1547679089276; Wed, 16 Jan 2019 14:51:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547679089; cv=none; d=google.com; s=arc-20160816; b=a3Ut8i++u+jEM2B+aUqFU3TvorTmiqtCrKkOofLiz+QwXZhTDoWw7/BxwhGJsNLQbe ouoHVPpdKLFKE8FwDwkZE9kzd9U1O1a+YJD8WMixxP0UPugAlRUYkSvkBTVM/HhvkAZF ZSsSjO3QyWwwVQugiuw9CGbRRbm+zXQor7/Cu2ag1mC+UdXny5BxuZ1wA70YHai9xScj stD3I5kSQEDNZ4mQEOImQL/HxyWh0VP2uF/ccguCdouJgZ+aL4JRP9lQ5Hi5O7M8bqo+ o2QCFSZFKXR+tT4pqSs7ZTIxKd30tBgaT1MNmIgl1QG/0njaTET/p5d4mcH7Tt4yu+r5 haJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=z1H+iHLBtkZaRbS2r/yjhxyOKzrjGCnzCJgxSted8P4=; b=T8PCvTzk5bs7R1KwcSpHVtllMu/z2q5ChiWPOKAxTzb1hUyui10XiDdc/D/SEAuzHn LfDIfWXlAgNnUS+pW36Dgxj+sJp18AyLGiXqmqrAtuX4+ECzxvcPyLr9zNpCpgYe+Opn cfkD3Cvst2AzwnfKu2WuJCu+amRX/0JkQhGHUOKNbJ3z+2cesznmQM1rgjFePm8L5KYb MYKgGDobdz8sbj1520jqzOlm51YxEbGipdoAExptzyna2uZqMd5msgNcuXLLiemcRWwT P1BBTvkZZ0hOxFuSPZ6gtWwJN8OvPbL4nkAZk7yB2aL4pO0mO4O0F/0VWcRcZvqyHgTx 6K/w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g69si7751571pfg.225.2019.01.16.14.51.11; Wed, 16 Jan 2019 14:51:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404944AbfAPPe1 (ORCPT + 99 others); Wed, 16 Jan 2019 10:34:27 -0500 Received: from mail.bootlin.com ([62.4.15.54]:36817 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2394084AbfAPPe0 (ORCPT ); Wed, 16 Jan 2019 10:34:26 -0500 Received: by mail.bootlin.com (Postfix, from userid 110) id B4F77207AC; Wed, 16 Jan 2019 16:34:23 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.2 Received: from localhost.localdomain (aaubervilliers-681-1-37-87.w90-88.abo.wanadoo.fr [90.88.156.87]) by mail.bootlin.com (Postfix) with ESMTPSA id 62017206F9; Wed, 16 Jan 2019 16:34:23 +0100 (CET) From: Miquel Raynal To: Andrew Lunn , Vivien Didelot , Florian Fainelli , "David S. Miller" Cc: netdev@vger.kernel.org, , Thomas Petazzoni , Gregory Clement , Antoine Tenart , Maxime Chevallier , Nadav Haklai , Miquel Raynal Subject: [PATCH net-next] net: dsa: mv88e6xxx: Add suspend/resume callbacks Date: Wed, 16 Jan 2019 16:34:19 +0100 Message-Id: <20190116153419.3208-1-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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