From patchwork Tue Nov 22 08:25:17 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 5266 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id C10E623E0C for ; Tue, 22 Nov 2011 08:25:42 +0000 (UTC) Received: from mail-fx0-f52.google.com (mail-fx0-f52.google.com [209.85.161.52]) by fiordland.canonical.com (Postfix) with ESMTP id 6DA32A18545 for ; Tue, 22 Nov 2011 08:25:42 +0000 (UTC) Received: by mail-fx0-f52.google.com with SMTP id a26so135351faa.11 for ; Tue, 22 Nov 2011 00:25:42 -0800 (PST) Received: by 10.152.144.136 with SMTP id sm8mr11154997lab.33.1321950342069; Tue, 22 Nov 2011 00:25:42 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.152.41.198 with SMTP id h6cs166954lal; Tue, 22 Nov 2011 00:25:41 -0800 (PST) Received: by 10.14.22.197 with SMTP id t45mr1268954eet.94.1321950340342; Tue, 22 Nov 2011 00:25:40 -0800 (PST) Received: from eu1sys200aog116.obsmtp.com (eu1sys200aog116.obsmtp.com. [207.126.144.141]) by mx.google.com with SMTP id q28si2971348eea.156.2011.11.22.00.25.28 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 22 Nov 2011 00:25:40 -0800 (PST) Received-SPF: neutral (google.com: 207.126.144.141 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) client-ip=207.126.144.141; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.141 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) smtp.mail=linus.walleij@stericsson.com Received: from beta.dmz-ap.st.com ([138.198.100.35]) (using TLSv1) by eu1sys200aob116.postini.com ([207.126.147.11]) with SMTP ID DSNKTstcd/2+RYpsw9NzCQg/pd9RANEj7enP@postini.com; Tue, 22 Nov 2011 08:25:39 UTC Received: from zeta.dmz-ap.st.com (ns6.st.com [138.198.234.13]) by beta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 60053E3; Tue, 22 Nov 2011 08:16:56 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 8301DCF2; Tue, 22 Nov 2011 08:25:23 +0000 (GMT) Received: from exdcvycastm003.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm003", Issuer "exdcvycastm003" (not verified)) by relay1.stm.gmessaging.net (Postfix) with ESMTPS id 6AEDD24C07C; Tue, 22 Nov 2011 09:25:18 +0100 (CET) Received: from localhost.localdomain (10.230.100.153) by smtp.stericsson.com (10.230.100.1) with Microsoft SMTP Server (TLS) id 8.3.83.0; Tue, 22 Nov 2011 09:25:22 +0100 From: Linus Walleij To: Grant Likely , Cc: , Viresh Kumar , Chris Blair , Linus Walleij Subject: [PATCH 6/7] spi/pl022: add support for pm_runtime autosuspend Date: Tue, 22 Nov 2011 09:25:17 +0100 Message-ID: <1321950317-4849-1-git-send-email-linus.walleij@stericsson.com> X-Mailer: git-send-email 1.7.3.2 MIME-Version: 1.0 From: Chris Blair Adds support for configuring the spi bus to use autosuspend for runtime power management. This can reduce the latency in starting an spi transfer by not suspending the device immediately following completion of a transfer. If another transfer then takes place before the autosuspend timeout, the call to resume the device can return immediately rather than needing to risk sleeping in order to resume the device. Reviewed-by: Viresh Kumar Signed-off-by: Chris Blair Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Add Viresh's Reviewed-by --- drivers/spi/spi-pl022.c | 20 ++++++++++++++++++-- include/linux/amba/pl022.h | 4 ++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c index 82a929f..13988a3 100644 --- a/drivers/spi/spi-pl022.c +++ b/drivers/spi/spi-pl022.c @@ -1516,7 +1516,13 @@ static void pump_messages(struct work_struct *work) /* nothing more to do - disable spi/ssp and power off */ writew((readw(SSP_CR1(pl022->virtbase)) & (~SSP_CR1_MASK_SSE)), SSP_CR1(pl022->virtbase)); - pm_runtime_put(&pl022->adev->dev); + + if (pl022->master_info->autosuspend_delay > 0) { + pm_runtime_mark_last_busy(&pl022->adev->dev); + pm_runtime_put_autosuspend(&pl022->adev->dev); + } else { + pm_runtime_put(&pl022->adev->dev); + } } pl022->busy = false; spin_unlock_irqrestore(&pl022->queue_lock, flags); @@ -2247,7 +2253,17 @@ pl022_probe(struct amba_device *adev, const struct amba_id *id) dev_dbg(dev, "probe succeeded\n"); /* let runtime pm put suspend */ - pm_runtime_put(dev); + if (platform_info->autosuspend_delay > 0) { + dev_info(&adev->dev, + "will use autosuspend for runtime pm, delay %dms\n", + platform_info->autosuspend_delay); + pm_runtime_set_autosuspend_delay(dev, + platform_info->autosuspend_delay); + pm_runtime_use_autosuspend(dev); + pm_runtime_put_autosuspend(dev); + } else { + pm_runtime_put(dev); + } return 0; err_spi_register: diff --git a/include/linux/amba/pl022.h b/include/linux/amba/pl022.h index 4ce98f5..572f637 100644 --- a/include/linux/amba/pl022.h +++ b/include/linux/amba/pl022.h @@ -238,6 +238,9 @@ struct dma_chan; * @enable_dma: if true enables DMA driven transfers. * @dma_rx_param: parameter to locate an RX DMA channel. * @dma_tx_param: parameter to locate a TX DMA channel. + * @autosuspend_delay: delay in ms following transfer completion before the + * runtime power management system suspends the device. A setting of 0 + * indicates no delay and the device will be suspended immediately. */ struct pl022_ssp_controller { u16 bus_id; @@ -246,6 +249,7 @@ struct pl022_ssp_controller { bool (*dma_filter)(struct dma_chan *chan, void *filter_param); void *dma_rx_param; void *dma_tx_param; + int autosuspend_delay; }; /**