From patchwork Wed May 3 12:37:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Schulz X-Patchwork-Id: 98489 Delivered-To: patch@linaro.org Received: by 10.140.89.200 with SMTP id v66csp34392qgd; Wed, 3 May 2017 05:38:46 -0700 (PDT) X-Received: by 10.99.106.5 with SMTP id f5mr38237976pgc.66.1493815126543; Wed, 03 May 2017 05:38:46 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b18si21469543pgf.259.2017.05.03.05.38.46; Wed, 03 May 2017 05:38:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of netdev-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 netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751550AbdECMiR (ORCPT + 6 others); Wed, 3 May 2017 08:38:17 -0400 Received: from mail.free-electrons.com ([62.4.15.54]:44078 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751619AbdECMiF (ORCPT ); Wed, 3 May 2017 08:38:05 -0400 Received: by mail.free-electrons.com (Postfix, from userid 110) id 47F0320806; Wed, 3 May 2017 14:38:03 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.free-electrons.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost.localdomain (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id 0810C207EB; Wed, 3 May 2017 14:38:03 +0200 (CEST) From: Quentin Schulz To: wg@grandegger.com, mkl@pengutronix.de, mario.huettel@gmx.net, socketcan@hartkopp.net Cc: Quentin Schulz , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, alexandre.belloni@free-electrons.com, thomas.petazzoni@free-electrons.com Subject: [PATCH v2 2/2] can: m_can: add deep Suspend/Resume support Date: Wed, 3 May 2017 14:37:50 +0200 Message-Id: <20170503123750.26134-2-quentin.schulz@free-electrons.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170503123750.26134-1-quentin.schulz@free-electrons.com> References: <20170503123750.26134-1-quentin.schulz@free-electrons.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This adds Power Management deep Suspend/Resume support for Bosch M_CAN chip. When the system resumes from deep sleep, the chip needs to be fully reinitialized (RAM, chip, clocks, irq, candev, ...) to be functional. Signed-off-by: Quentin Schulz --- drivers/net/can/m_can/m_can.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) -- 2.11.0 diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 3f0445440146..9e0143b528f1 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1670,12 +1670,10 @@ static __maybe_unused int m_can_suspend(struct device *dev) struct m_can_priv *priv = netdev_priv(ndev); if (netif_running(ndev)) { - netif_stop_queue(ndev); netif_device_detach(ndev); + m_can_close(ndev); } - /* TODO: enter low power */ - priv->can.state = CAN_STATE_SLEEPING; return 0; @@ -1686,13 +1684,13 @@ static __maybe_unused int m_can_resume(struct device *dev) struct net_device *ndev = dev_get_drvdata(dev); struct m_can_priv *priv = netdev_priv(ndev); - /* TODO: exit low power */ + m_can_init_ram(priv); priv->can.state = CAN_STATE_ERROR_ACTIVE; if (netif_running(ndev)) { + m_can_open(ndev); netif_device_attach(ndev); - netif_start_queue(ndev); } return 0;