From patchwork Thu Aug 20 20:03:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 7046931 Return-Path: X-Original-To: patchwork-linux-samsung-soc@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 7CA6C9F7B4 for ; Thu, 20 Aug 2015 20:13:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A0A5F20444 for ; Thu, 20 Aug 2015 20:13:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A04E120570 for ; Thu, 20 Aug 2015 20:13:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752339AbbHTUNn (ORCPT ); Thu, 20 Aug 2015 16:13:43 -0400 Received: from mail-wi0-f176.google.com ([209.85.212.176]:33963 "EHLO mail-wi0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752107AbbHTUNm (ORCPT ); Thu, 20 Aug 2015 16:13:42 -0400 Received: by wicne3 with SMTP id ne3so2723756wic.1; Thu, 20 Aug 2015 13:13:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :content-type:content-transfer-encoding; bh=sdB1p/TpaQ43RaCEsguIn04kGxePQmsxzwLQA/E7pQE=; b=LSNQW+I6Kd2wrMHxL8nVu1I1vqXBfl1DazNRw/stZHwYk1KnHylBnj7IqiAWuoaoZg NiQkWdJyT4Am2wJbLXkUpqu3jNUeN/jZKBLMGVP0SRHU+zttr51NdNcCudHmhbg4XvFv fByAGRmkf70LZgWxNEDgiNB1NmVMvvdNVqzNevby6ieMjH4G7geHvVqtNzyyKVUbyLWG kqCqY+LCFC1FbNWfGX6tsG44dt15azQDNJWyB1dY+pYil7vYv4821aC9XCfwVTtg3/JK 65rZrfTPHYHImRkFb1oqxRbsC4Hg2H2DUGxNTIVeu87hnmQgACpHI60IWFvRwv1Xe/Oh Y3GQ== X-Received: by 10.194.122.200 with SMTP id lu8mr8790045wjb.83.1440101621303; Thu, 20 Aug 2015 13:13:41 -0700 (PDT) Received: from ?IPv6:2003:62:5f33:d300:fd69:4033:8d2f:d215? (p200300625F33D300FD6940338D2FD215.dip0.t-ipconnect.de. [2003:62:5f33:d300:fd69:4033:8d2f:d215]) by smtp.googlemail.com with ESMTPSA id y13sm6977800wjq.26.2015.08.20.13.13.40 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 20 Aug 2015 13:13:40 -0700 (PDT) Message-ID: <55D63292.9070703@gmail.com> Date: Thu, 20 Aug 2015 22:03:30 +0200 From: Heiner Kallweit User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Krzysztof Kozlowski CC: linux-samsung-soc@vger.kernel.org, "linux-spi@vger.kernel.org" Subject: [PATCH 2/4 RESEND] spi: s3c64xx: extend driver to make full use of runtime PM autosuspend Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable 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 Extend the driver to make full use of runtime PM autosuspend. Before only the SPI core was instructed to use autosuspend by setting master->auto_runtime_pm. Nevertheless due to the missing pm_runtime_use_autosuspend call autosuspend wasn't active. Signed-off-by: Heiner Kallweit --- Changed: - Let driver autosuspend also after leaving s3c64xx_spi_setup - Enable runtime PM earlier in s3c64xx_spi_probe and prevent suspending in the relevant part of probe drivers/spi/spi-s3c64xx.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index 8a6ab88..edeac06 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c @@ -32,6 +32,7 @@ #define MAX_SPI_PORTS 6 #define S3C64XX_SPI_QUIRK_POLL (1 << 0) #define S3C64XX_SPI_QUIRK_CS_AUTO (1 << 1) +#define AUTOSUSPEND_TIMEOUT 2000 /* Registers and bit-fields */ @@ -859,13 +860,15 @@ static int s3c64xx_spi_setup(struct spi_device *spi) } } - pm_runtime_put(&sdd->pdev->dev); + pm_runtime_mark_last_busy(&sdd->pdev->dev); + pm_runtime_put_autosuspend(&sdd->pdev->dev); if (!(sdd->port_conf->quirks & S3C64XX_SPI_QUIRK_CS_AUTO)) writel(S3C64XX_SPI_SLAVE_SIG_INACT, sdd->regs + S3C64XX_SPI_SLAVE_SEL); return 0; setup_exit: - pm_runtime_put(&sdd->pdev->dev); + pm_runtime_mark_last_busy(&sdd->pdev->dev); + pm_runtime_put_autosuspend(&sdd->pdev->dev); /* setup() returns with device de-selected */ if (!(sdd->port_conf->quirks & S3C64XX_SPI_QUIRK_CS_AUTO)) writel(S3C64XX_SPI_SLAVE_SIG_INACT, sdd->regs + S3C64XX_SPI_SLAVE_SEL); @@ -1133,18 +1136,24 @@ static int s3c64xx_spi_probe(struct platform_device *pdev) goto err0; } + pm_runtime_set_autosuspend_delay(&pdev->dev, AUTOSUSPEND_TIMEOUT); + pm_runtime_use_autosuspend(&pdev->dev); + pm_runtime_set_active(&pdev->dev); + pm_runtime_enable(&pdev->dev); + pm_runtime_get_noresume(&pdev->dev); + /* Setup clocks */ sdd->clk = devm_clk_get(&pdev->dev, "spi"); if (IS_ERR(sdd->clk)) { dev_err(&pdev->dev, "Unable to acquire clock 'spi'\n"); ret = PTR_ERR(sdd->clk); - goto err0; + goto err1; } if (clk_prepare_enable(sdd->clk)) { dev_err(&pdev->dev, "Couldn't enable clock 'spi'\n"); ret = -EBUSY; - goto err0; + goto err1; } sprintf(clk_name, "spi_busclk%d", sci->src_clk_nr); @@ -1180,13 +1189,10 @@ static int s3c64xx_spi_probe(struct platform_device *pdev) S3C64XX_SPI_INT_TX_OVERRUN_EN | S3C64XX_SPI_INT_TX_UNDERRUN_EN, sdd->regs + S3C64XX_SPI_INT_EN); - pm_runtime_set_active(&pdev->dev); - pm_runtime_enable(&pdev->dev); - ret = devm_spi_register_master(&pdev->dev, master); if (ret != 0) { dev_err(&pdev->dev, "cannot register SPI master: %d\n", ret); - goto err4; + goto err3; } dev_dbg(&pdev->dev, "Samsung SoC SPI Driver loaded for Bus SPI-%d with %d Slaves attached\n", @@ -1195,15 +1201,19 @@ static int s3c64xx_spi_probe(struct platform_device *pdev) mem_res, (FIFO_LVL_MASK(sdd) >> 1) + 1, sdd->rx_dma.dmach, sdd->tx_dma.dmach); + pm_runtime_mark_last_busy(&pdev->dev); + pm_runtime_put_autosuspend(&pdev->dev); + return 0; -err4: - pm_runtime_disable(&pdev->dev); - pm_runtime_set_suspended(&pdev->dev); err3: clk_disable_unprepare(sdd->src_clk); err2: clk_disable_unprepare(sdd->clk); +err1: + pm_runtime_put_noidle(&pdev->dev); + pm_runtime_disable(&pdev->dev); + pm_runtime_set_suspended(&pdev->dev); err0: spi_master_put(master);