From patchwork Wed Nov 9 10:39:30 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 4972 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 8211C23E0E for ; Wed, 9 Nov 2011 10:39:51 +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 761E6A180CE for ; Wed, 9 Nov 2011 10:39:51 +0000 (UTC) Received: by mail-fx0-f52.google.com with SMTP id n26so2131830faa.11 for ; Wed, 09 Nov 2011 02:39:51 -0800 (PST) Received: by 10.152.102.138 with SMTP id fo10mr1088957lab.44.1320835191319; Wed, 09 Nov 2011 02:39:51 -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.10.72 with SMTP id g8cs163021lab; Wed, 9 Nov 2011 02:39:51 -0800 (PST) Received: by 10.213.9.204 with SMTP id m12mr1673506ebm.52.1320835189375; Wed, 09 Nov 2011 02:39:49 -0800 (PST) Received: from eu1sys200aog115.obsmtp.com (eu1sys200aog115.obsmtp.com. [207.126.144.139]) by mx.google.com with SMTP id u60si1076846eeu.174.2011.11.09.02.39.38 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 09 Nov 2011 02:39:49 -0800 (PST) Received-SPF: neutral (google.com: 207.126.144.139 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) client-ip=207.126.144.139; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.139 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 eu1sys200aob115.postini.com ([207.126.147.11]) with SMTP ID DSNKTrpYajMcdkYhggwHdTgug+BxD4ZULjH5@postini.com; Wed, 09 Nov 2011 10:39:48 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 93BECC3; Wed, 9 Nov 2011 10:31:07 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 507E39F6; Wed, 9 Nov 2011 10:39:34 +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 2073624C2E7; Wed, 9 Nov 2011 11:39:28 +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; Wed, 9 Nov 2011 11:39:33 +0100 From: Linus Walleij To: Grant Likely , Cc: , Viresh Kumar , Chris Blair , Linus Walleij Subject: [PATCH 6/6] spi/pl022: add support for pm_runtime autosuspend Date: Wed, 9 Nov 2011 11:39:30 +0100 Message-ID: <1320835170-31370-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. Signed-off-by: Chris Blair Signed-off-by: Linus Walleij --- 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 2e3522d..d3d6521 100644 --- a/drivers/spi/spi-pl022.c +++ b/drivers/spi/spi-pl022.c @@ -1515,7 +1515,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); @@ -2245,7 +2251,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; }; /**