From patchwork Sun Nov 22 07:53:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcin Wojtas X-Patchwork-Id: 7675491 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 277159F2E2 for ; Sun, 22 Nov 2015 07:56:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 30CF52064B for ; Sun, 22 Nov 2015 07:56:57 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5B72620647 for ; Sun, 22 Nov 2015 07:56:56 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1a0PU5-0000Ll-5T; Sun, 22 Nov 2015 07:54:53 +0000 Received: from mail-lf0-x236.google.com ([2a00:1450:4010:c07::236]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1a0PTT-0008Rz-6M for linux-arm-kernel@lists.infradead.org; Sun, 22 Nov 2015 07:54:16 +0000 Received: by lfdl133 with SMTP id l133so10117735lfd.2 for ; Sat, 21 Nov 2015 23:53:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=sX75iJup/9ZxFtR0bFdLLYTQYh0TJNKOnY0DeHIF5EE=; b=HWP2VcMxrh/+oZXqpdJxv1nFf+UW8K+37lrMy4GG7ZR8YZAMdP5llfTXzcD3qli5mb gLZ7uk1vjasBFyez2wcLaAItvcv5ZnLqON1xLas54zvM/mwPatVqW0zZdgSOHsin4A6c 3jR2047IywxYVFTyyEtDSZKwkKY1lyJgEJQdkRey03FaYx1pVUucrgRSdosxPgP0XgiD JArlUJAD6r7PbVT78f90QJu25sdyhoF7tgh02Mi00DywuEgvCaPDalTJSBWUiu5X4yGV M/b2FQX2/mwHESz6EHtxNrsL9okekuZeRpm95dt5ht2jBhn30lerXDtXHPWrt7lvlDQ3 tqsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=sX75iJup/9ZxFtR0bFdLLYTQYh0TJNKOnY0DeHIF5EE=; b=lbVHEAqtBdu7HSAe41s45nnRoLMbyp1LUeaouyQDhE+i7x23Vs7RqC8wiZ7Ej45hAz oSUfKM2zMx7qohqPVUAhX6C31Usxl4mNoy8ndooIbps0Z8SPWYRnmlMZY4AgKgR+hNru LjjPOqhpB/N06PQgndxSsGxTX5KVIaDUmsMCgWkSJoS/qmI5wShjXPsA3usFejtbrI7M x/gsVILKh41Ap4v2+vWe6fmfBRQgETl/uHlNGMD04RiwZUZI1wDJyTmk7rMfS983jTBL 1K9j8lDGwKA8EyTjjsUSG7scoB7M0cP96/tE7XQHWz0WOg7FQzoUQ4ULS6Uv29//gkP/ fIVA== X-Gm-Message-State: ALoCoQnwYzYwDgud/XPQo7/nbftJod3qknsyNg5CCArBAnJBZ17TXkxBSnnri2njWmu+4TcKHEF4 X-Received: by 10.25.7.8 with SMTP id 8mr3766328lfh.111.1448178833164; Sat, 21 Nov 2015 23:53:53 -0800 (PST) Received: from enkidu.semihalf.local (cardhu.semihalf.com. [213.17.239.108]) by smtp.gmail.com with ESMTPSA id y79sm1010840lfd.45.2015.11.21.23.53.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 21 Nov 2015 23:53:52 -0800 (PST) From: Marcin Wojtas To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org Subject: [PATCH 04/13] net: mvneta: enable suspend/resume support Date: Sun, 22 Nov 2015 08:53:50 +0100 Message-Id: <1448178839-3541-5-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1448178839-3541-1-git-send-email-mw@semihalf.com> References: <1448178839-3541-1-git-send-email-mw@semihalf.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151121_235415_507693_13477CC9 X-CRM114-Status: GOOD ( 13.48 ) X-Spam-Score: -2.6 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thomas.petazzoni@free-electrons.com, andrew@lunn.ch, linux@arm.linux.org.uk, jason@lakedaemon.net, myair@marvell.com, jaz@semihalf.com, simon.guinot@sequanux.org, xswang@marvell.com, nadavh@marvell.com, alior@marvell.com, tn@semihalf.com, gregory.clement@free-electrons.com, nitroshift@yahoo.com, mw@semihalf.com, davem@davemloft.net, sebastian.hesselbarth@gmail.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This commit introduces suspend/resume routines used for both in 'standby' and 'mem' modes. For the latter, in which registers' contents are lost, following steps are performed: * in suspend - update port statistics and, if interface is running, detach netif, clean the queues, disable cpu notifier, shutdown interface and reset port's link status; * in resume, for all interfaces, set default configuration of the port and MBUS windows; * in resume, in case the interface is running, enable accepting packets in legacy parser, power up the port, register cpu notifier and attach netif. Signed-off-by: Marcin Wojtas --- drivers/net/ethernet/marvell/mvneta.c | 70 +++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c index d12b8c6..f079b13 100644 --- a/drivers/net/ethernet/marvell/mvneta.c +++ b/drivers/net/ethernet/marvell/mvneta.c @@ -3442,6 +3442,72 @@ static int mvneta_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_PM_SLEEP +static int mvneta_suspend(struct platform_device *pdev, pm_message_t state) +{ + struct net_device *dev = platform_get_drvdata(pdev); + struct mvneta_port *pp = netdev_priv(dev); + + mvneta_ethtool_update_stats(pp); + + if (!netif_running(dev)) + return 0; + + netif_device_detach(dev); + + mvneta_stop_dev(pp); + unregister_cpu_notifier(&pp->cpu_notifier); + mvneta_cleanup_rxqs(pp); + mvneta_cleanup_txqs(pp); + + /* Reset link status */ + pp->link = 0; + pp->duplex = -1; + pp->speed = 0; + + return 0; +} + +static int mvneta_resume(struct platform_device *pdev) +{ + const struct mbus_dram_target_info *dram_target_info; + struct net_device *dev = platform_get_drvdata(pdev); + struct mvneta_port *pp = netdev_priv(dev); + int ret; + + mvneta_defaults_set(pp); + mvneta_port_power_up(pp, pp->phy_interface); + + dram_target_info = mv_mbus_dram_info(); + if (dram_target_info) + mvneta_conf_mbus_windows(pp, dram_target_info); + + if (!netif_running(dev)) + return 0; + + ret = mvneta_setup_rxqs(pp); + if (ret) { + netdev_err(dev, "unable to setup rxqs after resume\n"); + return ret; + } + + ret = mvneta_setup_txqs(pp); + if (ret) { + netdev_err(dev, "unable to setup txqs after resume\n"); + return ret; + } + + mvneta_set_rx_mode(dev); + mvneta_percpu_elect(pp); + register_cpu_notifier(&pp->cpu_notifier); + mvneta_start_dev(pp); + + netif_device_attach(dev); + + return 0; +} +#endif /* CONFIG_PM_SLEEP */ + static const struct of_device_id mvneta_match[] = { { .compatible = "marvell,armada-370-neta" }, { .compatible = "marvell,armada-xp-neta" }, @@ -3452,6 +3518,10 @@ MODULE_DEVICE_TABLE(of, mvneta_match); static struct platform_driver mvneta_driver = { .probe = mvneta_probe, .remove = mvneta_remove, +#ifdef CONFIG_PM_SLEEP + .suspend = mvneta_suspend, + .resume = mvneta_resume, +#endif .driver = { .name = MVNETA_DRIVER_NAME, .of_match_table = mvneta_match,