From patchwork Fri Aug 21 17:29:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 7052841 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 31A4FC05AC for ; Fri, 21 Aug 2015 17:40:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5017520451 for ; Fri, 21 Aug 2015 17:40:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9BE7920504 for ; Fri, 21 Aug 2015 17:40:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752153AbbHURkV (ORCPT ); Fri, 21 Aug 2015 13:40:21 -0400 Received: from mail-wi0-f170.google.com ([209.85.212.170]:33944 "EHLO mail-wi0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751934AbbHURkQ (ORCPT ); Fri, 21 Aug 2015 13:40:16 -0400 Received: by wicne3 with SMTP id ne3so25624124wic.1; Fri, 21 Aug 2015 10:40:14 -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=VUFl7bG7RUswmL+leld9FYu9CTcMlKU6OiFRYG35vhE=; b=sM7+u44KFOLSfvakG9TT2Euwq32pYU3yAKcc9ZLBQpqnuZE2ueNZri11wtHB5hWpVw Tb5ligtmYtUo/KM+aaYntzZM8N1kVNorlJqT6cgWxsjygmBRWf58d4j13jLK7r8jfjdt kLWEcvkwrJ64+gQvUhzMZvGsHBg/hcVlJhOPqJcvlrLKeiUq/awM1FkEHpsVioy1MEjf UGB9c1rRV3jc+U1MrNgOhozjoxjqwv079VvJZpBSk0wqsWGVei6rsHMuvFYB4ResDWWD RFtJFFeS1XD6vm1KlPxIk1zY1BQruJGqThhViX2aKy6P96xScH0Q7JERq4wejoLffue2 /rcA== X-Received: by 10.194.120.198 with SMTP id le6mr17361226wjb.133.1440178814760; Fri, 21 Aug 2015 10:40:14 -0700 (PDT) Received: from ?IPv6:2003:62:5f33:d300:4526:b663:4b92:a3e2? (p200300625F33D3004526B6634B92A3E2.dip0.t-ipconnect.de. [2003:62:5f33:d300:4526:b663:4b92:a3e2]) by smtp.googlemail.com with ESMTPSA id j2sm10887508wjq.5.2015.08.21.10.40.13 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 21 Aug 2015 10:40:13 -0700 (PDT) Message-ID: <55D76003.8070608@gmail.com> Date: Fri, 21 Aug 2015 19:29:39 +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 v2] 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.6 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 Reviewed-by: Krzysztof Kozlowski --- 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 v2: - Don't init runtime PM before the driver has a reference to the clocks drivers/spi/spi-s3c64xx.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index 8a6ab88..d117fa6 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); @@ -1162,6 +1165,12 @@ static int s3c64xx_spi_probe(struct platform_device *pdev) goto err2; } + 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_sync(&pdev->dev); + /* Setup Deufult Mode */ s3c64xx_spi_hwinit(sdd, sdd->port_id); @@ -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,12 +1201,16 @@ 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: +err3: + pm_runtime_put_noidle(&pdev->dev); pm_runtime_disable(&pdev->dev); pm_runtime_set_suspended(&pdev->dev); -err3: + clk_disable_unprepare(sdd->src_clk); err2: clk_disable_unprepare(sdd->clk);