From patchwork Fri Mar 13 15:36:55 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Damm X-Patchwork-Id: 11758 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 n2DFdSic028115 for ; Fri, 13 Mar 2009 15:39:29 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755411AbZCMPj3 (ORCPT ); Fri, 13 Mar 2009 11:39:29 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1750843AbZCMPj3 (ORCPT ); Fri, 13 Mar 2009 11:39:29 -0400 Received: from ti-out-0910.google.com ([209.85.142.188]:33929 "EHLO ti-out-0910.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755411AbZCMPj2 (ORCPT ); Fri, 13 Mar 2009 11:39:28 -0400 Received: by ti-out-0910.google.com with SMTP id d10so1524010tib.23 for ; Fri, 13 Mar 2009 08:39:25 -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 :subject; bh=5yLQ03tjqL6FTth6a1b1SywLHXh8g0mEfpZ5XGhU2KQ=; b=q9T0A/t46L8YlOMWu5G1fnOIeAEWLvE1I70MJQHVaC1PxIp4elzivw4gB+s4OekVbs rHLnG10AYmzU3ySXUd7vdJFBhZu8jc4bjcvKpjybuoELj3aQ1t9tDAzMIJrJGU+QWwkh 2yokbJMmkgpDgQhXIDmHa5bJHGnI7bhb6tt7w= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:date:message-id:subject; b=hiPcxoZWJAfTcn/TgtkNVV+c/2TerXs8zXRt8HX1Of4lAL+GKefikVtvbd3GL2QeO7 tw9rBxBTpbwTSEtFi62Dcctchr1IRAgtC4e4tNsmrKhp1BVNaiax6Fir5J1l7XiWpCy5 PIhG36YCbTN5vhSyRoQYhCKt+CHw6C1+OKEIE= Received: by 10.110.86.3 with SMTP id j3mr2132950tib.48.1236958765288; Fri, 13 Mar 2009 08:39:25 -0700 (PDT) Received: from rx1.opensource.se (210-227-008-067.jp.fiberbit.net [210.227.8.67]) by mx.google.com with ESMTPS id d4sm948083tib.28.2009.03.13.08.39.23 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 13 Mar 2009 08:39:24 -0700 (PDT) From: Magnus Damm To: linux-fbdev-devel@lists.sourceforge.net Cc: Magnus Damm , lethal@linux-sh.org, linux-sh@vger.kernel.org Date: Sat, 14 Mar 2009 00:36:55 +0900 Message-Id: <20090313153655.20515.14828.sendpatchset@rx1.opensource.se> Subject: [PATCH] video: sh_mobile_lcdcfb suspend/resume support Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org From: Magnus Damm This patch adds suspend/resume support to the LCDC driver for SuperH Mobile - sh_mobile_lcdcfb. We simply stop hardware on suspend and start it again on resume. For RGB panels this is trivial, but for SYS panels in deferred io mode this becomes a bit more --- 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 difficult - we need to wait for a frame end interrupt to make sure the clocks are balanced before stopping the actual hardware. Signed-off-by: Magnus Damm --- Tested on ap325 and Migo-R. drivers/video/sh_mobile_lcdcfb.c | 66 +++++++++++++++++++++++++++++++++----- 1 file changed, 59 insertions(+), 7 deletions(-) --- 0001/drivers/video/sh_mobile_lcdcfb.c +++ work/drivers/video/sh_mobile_lcdcfb.c 2009-03-14 00:06:47.000000000 +0900 @@ -33,6 +33,8 @@ struct sh_mobile_lcdc_chan { struct fb_info info; dma_addr_t dma_handle; struct fb_deferred_io defio; + unsigned long frame_end; + wait_queue_head_t frame_end_wait; }; struct sh_mobile_lcdc_priv { @@ -226,7 +228,10 @@ static void sh_mobile_lcdc_deferred_io_t static irqreturn_t sh_mobile_lcdc_irq(int irq, void *data) { struct sh_mobile_lcdc_priv *priv = data; + struct sh_mobile_lcdc_chan *ch; unsigned long tmp; + int is_sub; + int k; /* acknowledge interrupt */ tmp = lcdc_read(priv, _LDINTR); @@ -234,8 +239,24 @@ static irqreturn_t sh_mobile_lcdc_irq(in tmp |= 0x000000ff ^ LDINTR_FS; /* status in low 8 */ lcdc_write(priv, _LDINTR, tmp); - /* disable clocks */ - sh_mobile_lcdc_clk_off(priv); + /* figure out if this interrupt is for main or sub lcd */ + is_sub = (lcdc_read(priv, _LDSR) & (1 << 10)) ? 1 : 0; + + /* wake up channel and disable clocks*/ + for (k = 0; k < ARRAY_SIZE(priv->ch); k++) { + ch = &priv->ch[k]; + + if (!ch->enabled) + continue; + + if (is_sub == lcdc_chan_is_sublcd(ch)) { + ch->frame_end = 1; + wake_up(&ch->frame_end_wait); + + sh_mobile_lcdc_clk_off(priv); + } + } + return IRQ_HANDLED; } @@ -448,18 +469,27 @@ static void sh_mobile_lcdc_stop(struct s struct sh_mobile_lcdc_board_cfg *board_cfg; int k; - /* tell the board code to disable the panel */ + /* clean up deferred io and ask board code to disable panel */ for (k = 0; k < ARRAY_SIZE(priv->ch); k++) { ch = &priv->ch[k]; - board_cfg = &ch->cfg.board_cfg; - if (board_cfg->display_off) - board_cfg->display_off(board_cfg->board_data); - /* cleanup deferred io if enabled */ + /* deferred io mode: + * flush frame, and wait for frame end interrupt + * clean up deferred io and enable clock + */ if (ch->info.fbdefio) { + ch->frame_end = 0; + schedule_delayed_work(&ch->info.deferred_work, 0); + wait_event(ch->frame_end_wait, ch->frame_end); fb_deferred_io_cleanup(&ch->info); ch->info.fbdefio = NULL; + sh_mobile_lcdc_clk_on(priv); } + + board_cfg = &ch->cfg.board_cfg; + if (board_cfg->display_off) + board_cfg->display_off(board_cfg->board_data); + } /* stop the lcdc */ @@ -652,6 +682,26 @@ static int sh_mobile_lcdc_set_bpp(struct return 0; } +static int sh_mobile_lcdc_suspend(struct device *dev) +{ + struct platform_device *pdev = to_platform_device(dev); + + sh_mobile_lcdc_stop(platform_get_drvdata(pdev)); + return 0; +} + +static int sh_mobile_lcdc_resume(struct device *dev) +{ + struct platform_device *pdev = to_platform_device(dev); + + return sh_mobile_lcdc_start(platform_get_drvdata(pdev)); +} + +static struct dev_pm_ops sh_mobile_lcdc_dev_pm_ops = { + .suspend = sh_mobile_lcdc_suspend, + .resume = sh_mobile_lcdc_resume, +}; + static int sh_mobile_lcdc_remove(struct platform_device *pdev); static int __init sh_mobile_lcdc_probe(struct platform_device *pdev) @@ -707,6 +757,7 @@ static int __init sh_mobile_lcdc_probe(s dev_err(&pdev->dev, "unsupported interface type\n"); goto err1; } + init_waitqueue_head(&priv->ch[i].frame_end_wait); switch (pdata->ch[i].chan) { case LCDC_CHAN_MAINLCD: @@ -860,6 +911,7 @@ static struct platform_driver sh_mobile_ .driver = { .name = "sh_mobile_lcdc_fb", .owner = THIS_MODULE, + .pm = &sh_mobile_lcdc_dev_pm_ops, }, .probe = sh_mobile_lcdc_probe, .remove = sh_mobile_lcdc_remove,