From patchwork Mon Feb 7 12:38:06 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: manjugk manjugk X-Patchwork-Id: 537901 X-Patchwork-Delegate: khilman@deeprootsystems.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p17Cdhtc004898 for ; Mon, 7 Feb 2011 12:39:43 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751886Ab1BGMjm (ORCPT ); Mon, 7 Feb 2011 07:39:42 -0500 Received: from devils.ext.ti.com ([198.47.26.153]:55863 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751597Ab1BGMjm (ORCPT ); Mon, 7 Feb 2011 07:39:42 -0500 Received: from dbdp31.itg.ti.com ([172.24.170.98]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id p17CdZ10014425 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 7 Feb 2011 06:39:38 -0600 Received: from ucmsshproxy.india.ext.ti.com (localhost [127.0.0.1]) by dbdp31.itg.ti.com (8.13.8/8.13.8) with SMTP id p17CdWjk000187; Mon, 7 Feb 2011 18:09:33 +0530 (IST) Received: from localhost (unknown [10.24.244.223]) by ucmsshproxy.india.ext.ti.com (Postfix) with ESMTP id CC4FC158002; Mon, 7 Feb 2011 18:09:32 +0530 (IST) From: "G, Manjunath Kondaiah" To: linux-omap@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, khilman@ti.com, tony@atomide.com Subject: [PATCH v2] OMAP: PM: DMA: Enable runtime pm Date: Mon, 7 Feb 2011 18:08:06 +0530 Message-Id: <1297082286-8449-1-git-send-email-manjugk@ti.com> X-Mailer: git-send-email 1.7.1 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Mon, 07 Feb 2011 12:39:43 +0000 (UTC) diff --git a/arch/arm/plat-omap/dma.c b/arch/arm/plat-omap/dma.c index 2ec3b5d..6bfe25c 100644 --- a/arch/arm/plat-omap/dma.c +++ b/arch/arm/plat-omap/dma.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -59,6 +60,7 @@ enum { DMA_CHAIN_STARTED, DMA_CHAIN_NOTSTARTED }; static struct omap_system_dma_plat_info *p; static struct omap_dma_dev_attr *d; +static struct device *dev; static int enable_1510_mode; static u32 errata; @@ -676,6 +678,7 @@ int omap_request_dma(int dev_id, const char *dev_name, unsigned long flags; struct omap_dma_lch *chan; + pm_runtime_get_sync(dev); spin_lock_irqsave(&dma_chan_lock, flags); for (ch = 0; ch < dma_chan_count; ch++) { if (free_ch == -1 && dma_chan[ch].dev_id == -1) { @@ -686,6 +689,7 @@ int omap_request_dma(int dev_id, const char *dev_name, } if (free_ch == -1) { spin_unlock_irqrestore(&dma_chan_lock, flags); + pm_runtime_put_autosuspend(dev); return -EBUSY; } chan = dma_chan + free_ch; @@ -743,6 +747,7 @@ int omap_request_dma(int dev_id, const char *dev_name, } *dma_ch_out = free_ch; + pm_runtime_put_autosuspend(dev); return 0; } @@ -871,6 +876,8 @@ void omap_start_dma(int lch) { u32 l; + pm_runtime_get_sync(dev); + /* * The CPC/CDAC register needs to be initialized to zero * before starting dma transfer. @@ -1805,6 +1812,8 @@ static int omap1_dma_handle_ch(int ch) if (likely(dma_chan[ch].callback != NULL)) dma_chan[ch].callback(ch, csr, dma_chan[ch].data); + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); return 1; } @@ -1899,6 +1908,8 @@ static int omap2_dma_handle_ch(int ch) if (likely(dma_chan[ch].callback != NULL)) dma_chan[ch].callback(ch, status, dma_chan[ch].data); + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); return 0; } @@ -1978,6 +1989,7 @@ static int __devinit omap_system_dma_probe(struct platform_device *pdev) return -EINVAL; } + dev = &pdev->dev; d = p->dma_attr; errata = p->errata; @@ -1999,6 +2011,11 @@ static int __devinit omap_system_dma_probe(struct platform_device *pdev) } } + pm_runtime_use_autosuspend(dev); + pm_runtime_set_autosuspend_delay(dev, 1000); + pm_runtime_enable(dev); + pm_runtime_get_sync(dev); + spin_lock_init(&dma_chan_lock); for (ch = 0; ch < dma_chan_count; ch++) { omap_clear_dma(ch); @@ -2064,6 +2081,16 @@ static int __devinit omap_system_dma_probe(struct platform_device *pdev) dma_chan[1].dev_id = 1; } p->show_dma_caps(); + + /* + * Note: If dma channels are reserved through boot paramters, + * then dma device is always enabled. + */ + if (omap_dma_reserve_channels) + pm_runtime_get(dev); + + pm_runtime_put_autosuspend(dev); + return 0; exit_dma_irq_fail: