From patchwork Wed Apr 12 07:05:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Schulz X-Patchwork-Id: 9676659 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8F38760383 for ; Wed, 12 Apr 2017 07:06:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 81C7A285AD for ; Wed, 12 Apr 2017 07:06:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 760BA285BE; Wed, 12 Apr 2017 07:06:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EED48285AD for ; Wed, 12 Apr 2017 07:06:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753186AbdDLHGD (ORCPT ); Wed, 12 Apr 2017 03:06:03 -0400 Received: from mail.free-electrons.com ([62.4.15.54]:47266 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752979AbdDLHGC (ORCPT ); Wed, 12 Apr 2017 03:06:02 -0400 Received: by mail.free-electrons.com (Postfix, from userid 110) id 361E6207F4; Wed, 12 Apr 2017 09:06:00 +0200 (CEST) Received: from qschulz.lan (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id 06363207EC; Wed, 12 Apr 2017 09:05:50 +0200 (CEST) From: Quentin Schulz To: nicolas.ferre@microchip.com, broonie@kernel.org Cc: Quentin Schulz , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, alexandre.belloni@free-electrons.com, thomas.petazzoni@free-electrons.com Subject: [PATCH 2/2] spi: atmel: add PM support to SAMA5D2 Date: Wed, 12 Apr 2017 09:05:20 +0200 Message-Id: <20170412070520.29621-2-quentin.schulz@free-electrons.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170412070520.29621-1-quentin.schulz@free-electrons.com> References: <20170412070520.29621-1-quentin.schulz@free-electrons.com> Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This adds PM support to the ATMEL SAMA5D2 Xplained. When suspending, VDDCore is shut down and the SPI registers are lost. Thus, the SPI controller needs to be re-initialized after resuming from a system suspend. Signed-off-by: Quentin Schulz --- drivers/spi/spi-atmel.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c index 247d920..1eb83c9 100644 --- a/drivers/spi/spi-atmel.c +++ b/drivers/spi/spi-atmel.c @@ -1702,8 +1702,17 @@ static int atmel_spi_suspend(struct device *dev) static int atmel_spi_resume(struct device *dev) { struct spi_master *master = dev_get_drvdata(dev); + struct atmel_spi *as = spi_master_get_devdata(master); int ret; + ret = clk_prepare_enable(as->clk); + if (ret) + return ret; + + atmel_spi_init(as); + + clk_disable_unprepare(as->clk); + if (!pm_runtime_suspended(dev)) { ret = atmel_spi_runtime_resume(dev); if (ret)