From patchwork Thu Jul 9 15:20:20 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Damm X-Patchwork-Id: 34832 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n69FNT0J028496 for ; Thu, 9 Jul 2009 15:24:15 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757951AbZGIPYP (ORCPT ); Thu, 9 Jul 2009 11:24:15 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755770AbZGIPYO (ORCPT ); Thu, 9 Jul 2009 11:24:14 -0400 Received: from wf-out-1314.google.com ([209.85.200.174]:3145 "EHLO wf-out-1314.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753841AbZGIPYO (ORCPT ); Thu, 9 Jul 2009 11:24:14 -0400 Received: by wf-out-1314.google.com with SMTP id 26so65585wfd.4 for ; Thu, 09 Jul 2009 08:24:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:date:message-id :in-reply-to:references:subject; bh=v9oefwvNh/T/VB3HZnHVgXe9aJAcDjr5EIn2bZ+T1wg=; b=spPSoDxOdSrlJtokKmcTWPHdNm3AcXKA251tlzxDSp4W8EmN3g4hWJFrzfktLgXT6a lfQPhr2EvVc/awvWSafI6mSXD4L7WNokuzL1copQZKPBwAHnl5Ghd7QsQR4/9SdvTdvv fME8S4kWlw8l8gO27FQefv9sb1ll7sqNU0wm0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:date:message-id:in-reply-to:references:subject; b=PZju4q9otgHumZxeNKszhpUEX/qkwlpwvrk0Ut/GSBfM8LSYJyxjlHvI30cIHbhtGh q50I8YMLX6QtVqfRQBJQwpkfqVAmwALVvmKd29/dDO7L9tCgDX2tlTw63bIbSwSbncDx SPDFUBxObkDJBlsm5W0MnKDsa+7DMmCCIt8X0= Received: by 10.142.142.7 with SMTP id p7mr343327wfd.228.1247153053803; Thu, 09 Jul 2009 08:24:13 -0700 (PDT) Received: from rx1.opensource.se (58x80x213x53.ap58.ftth.ucom.ne.jp [58.80.213.53]) by mx.google.com with ESMTPS id 28sm2610182wfd.24.2009.07.09.08.24.10 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 09 Jul 2009 08:24:12 -0700 (PDT) From: Magnus Damm To: linux-pm@lists.linux-foundation.org Cc: linux-sh@vger.kernel.org, gregkh@suse.de, rjw@sisk.pl, lethal@linux-sh.org, stern@rowland.harvard.edu, pavel@ucw.cz, Magnus Damm Date: Fri, 10 Jul 2009 00:20:20 +0900 Message-Id: <20090709152020.8385.83457.sendpatchset@rx1.opensource.se> In-Reply-To: <20090709151926.8385.92800.sendpatchset@rx1.opensource.se> References: <20090709151926.8385.92800.sendpatchset@rx1.opensource.se> Subject: [PATCH 06/06] video: Runtime PM for sh_mobile_lcdcfb.c Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org From: Magnus Damm This patch modifies the SuperH Mobile LCDC framebuffer driver to support Runtime PM. This patch is very experimental and is missing context save and restore support. At this early point it is however already possible to see that the deferred io clock management strategy pays off since in that mode the clocks are only turned on for a short period of time to redraw the screen. When the screen is unchanged the clocks are disabled and the driver can be in Runtime suspended state. Signed-off-by: Magnus Damm --- drivers/video/sh_mobile_lcdcfb.c | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- 0001/drivers/video/sh_mobile_lcdcfb.c +++ work/drivers/video/sh_mobile_lcdcfb.c 2009-07-09 18:24:22.000000000 +0900 @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -42,9 +43,9 @@ struct sh_mobile_lcdc_chan { struct sh_mobile_lcdc_priv { void __iomem *base; int irq; - atomic_t clk_usecnt; + atomic_t hw_usecnt; + struct device *dev; struct clk *dot_clk; - struct clk *clk; unsigned long lddckr; struct sh_mobile_lcdc_chan ch[2]; int started; @@ -185,8 +186,8 @@ struct sh_mobile_lcdc_sys_bus_ops sh_mob static void sh_mobile_lcdc_clk_on(struct sh_mobile_lcdc_priv *priv) { - if (atomic_inc_and_test(&priv->clk_usecnt)) { - clk_enable(priv->clk); + if (atomic_inc_and_test(&priv->hw_usecnt)) { + pm_runtime_resume(priv->dev); if (priv->dot_clk) clk_enable(priv->dot_clk); } @@ -194,10 +195,10 @@ static void sh_mobile_lcdc_clk_on(struct static void sh_mobile_lcdc_clk_off(struct sh_mobile_lcdc_priv *priv) { - if (atomic_sub_return(1, &priv->clk_usecnt) == -1) { + if (atomic_sub_return(1, &priv->hw_usecnt) == -1) { if (priv->dot_clk) clk_disable(priv->dot_clk); - clk_disable(priv->clk); + pm_schedule_suspend(priv->dev, 0); } } @@ -566,7 +567,6 @@ static int sh_mobile_lcdc_setup_clocks(s int clock_source, struct sh_mobile_lcdc_priv *priv) { - char clk_name[8]; char *str; int icksel; @@ -580,23 +580,17 @@ static int sh_mobile_lcdc_setup_clocks(s priv->lddckr = icksel << 16; - atomic_set(&priv->clk_usecnt, -1); - snprintf(clk_name, sizeof(clk_name), "lcdc%d", pdev->id); - priv->clk = clk_get(&pdev->dev, clk_name); - if (IS_ERR(priv->clk)) { - dev_err(&pdev->dev, "cannot get clock \"%s\"\n", clk_name); - return PTR_ERR(priv->clk); - } - if (str) { priv->dot_clk = clk_get(&pdev->dev, str); if (IS_ERR(priv->dot_clk)) { dev_err(&pdev->dev, "cannot get dot clock %s\n", str); - clk_put(priv->clk); return PTR_ERR(priv->dot_clk); } } - + atomic_set(&priv->hw_usecnt, -1); + pm_suspend_ignore_children(priv->dev, true); + pm_runtime_set_suspended(priv->dev); + pm_runtime_enable(priv->dev); return 0; } @@ -761,6 +755,7 @@ static int __init sh_mobile_lcdc_probe(s } priv->irq = i; + priv->dev = &pdev->dev; platform_set_drvdata(pdev, priv); pdata = pdev->dev.platform_data; @@ -888,7 +883,6 @@ static int __init sh_mobile_lcdc_probe(s if (info->fbdefio) sh_mobile_lcdc_clk_off(priv); } - return 0; err1: sh_mobile_lcdc_remove(pdev); @@ -924,7 +918,6 @@ static int sh_mobile_lcdc_remove(struct if (priv->dot_clk) clk_put(priv->dot_clk); - clk_put(priv->clk); if (priv->base) iounmap(priv->base);