From patchwork Sun Oct 28 15:49:17 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasily Khoruzhick X-Patchwork-Id: 1657901 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id D89D33FD4E for ; Sun, 28 Oct 2012 15:49:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751514Ab2J1Ptb (ORCPT ); Sun, 28 Oct 2012 11:49:31 -0400 Received: from mail-la0-f46.google.com ([209.85.215.46]:52293 "EHLO mail-la0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751105Ab2J1Pta (ORCPT ); Sun, 28 Oct 2012 11:49:30 -0400 Received: by mail-la0-f46.google.com with SMTP id h6so3267423lag.19 for ; Sun, 28 Oct 2012 08:49:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer; bh=zQlRM7dcG9e0rBdaNHKxwDcmb9Wog+Q0ACcyNsK6IbA=; b=FW4l9Fp94jjUWT6Jey+wm/sOZ8vYy5tKGeKayhRNybWf8xC5Vd3mjbYn/f/EJ7paO/ PzH+zZOb5C2mrszsEUUGU8h/gxB9S4IgBlex1Tei+v7vn/8ndZW473RTLBseV9O3gAIk JlUkt7dHbxWsGvmGaheNqiZxN2qqb7D1JEXmuR8KMjZ6tgwDbFCeNFs2/dozQN+7nyqV 1iXrTHG1wya+YWHTT1PTvZ5st1StmCjgctnlmtAljrhogxyUSSJ3S5vkmSc3fNOU42dP o3iBeCqZvipkJNQog69XtPMLs6quxyo1siMc/EExlF12UaIBjrEMED4hzca9andOPkbr s5nQ== Received: by 10.152.148.226 with SMTP id tv2mr24795348lab.34.1351439369363; Sun, 28 Oct 2012 08:49:29 -0700 (PDT) Received: from localhost.localdomain ([80.249.90.60]) by mx.google.com with ESMTPS id sy1sm2197686lab.16.2012.10.28.08.49.27 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 28 Oct 2012 08:49:28 -0700 (PDT) From: Vasily Khoruzhick To: Marek Vasut , linux-fbdev@vger.kernel.org, Florian Tobias Schandinat , Richard Purdie , Andrew Morton Cc: Vasily Khoruzhick Subject: [PATCH] lms283gf05: add suspend/resume handlers Date: Sun, 28 Oct 2012 18:49:17 +0300 Message-Id: <1351439357-9843-1-git-send-email-anarsoul@gmail.com> X-Mailer: git-send-email 1.7.12.4 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Signed-off-by: Vasily Khoruzhick --- drivers/video/backlight/lms283gf05.c | 42 ++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/drivers/video/backlight/lms283gf05.c b/drivers/video/backlight/lms283gf05.c index ea43f22..ed15752 100644 --- a/drivers/video/backlight/lms283gf05.c +++ b/drivers/video/backlight/lms283gf05.c @@ -22,6 +22,7 @@ struct lms283gf05_state { struct spi_device *spi; struct lcd_device *ld; + unsigned int power; }; struct lms283gf05_seq { @@ -130,6 +131,8 @@ static int lms283gf05_power_set(struct lcd_device *ld, int power) struct spi_device *spi = st->spi; struct lms283gf05_pdata *pdata = spi->dev.platform_data; + st->power = power; + if (power <= FB_BLANK_NORMAL) { if (pdata) lms283gf05_reset(pdata->reset_gpio, @@ -193,6 +196,43 @@ static int __devinit lms283gf05_probe(struct spi_device *spi) return 0; } +#if defined(CONFIG_PM) +static unsigned int before_power; + +static int lms283gf05_suspend(struct spi_device *spi, pm_message_t mesg) +{ + int ret = 0; + struct lms283gf05_state *state = dev_get_drvdata(&spi->dev); + + dev_dbg(&spi->dev, "lcd->power = %d\n", state->power); + + before_power = state->power; + + /* + * when lcd panel is suspend, lcd panel becomes off + * regardless of status. + */ + ret = lms283gf05_power_set(state->ld, FB_BLANK_POWERDOWN); + + return ret; +} + +static int lms283gf05_resume(struct spi_device *spi) +{ + int ret = 0; + struct lms283gf05_state *state = dev_get_drvdata(&spi->dev); + + dev_dbg(&spi->dev, "before_power = %d\n", before_power); + + ret = lms283gf05_power_set(state->ld, before_power); + + return ret; +} +#else +#define lms283gf05_suspend NULL +#define lms283gf05_resume NULL +#endif + static int __devexit lms283gf05_remove(struct spi_device *spi) { struct lms283gf05_state *st = dev_get_drvdata(&spi->dev); @@ -209,6 +249,8 @@ static struct spi_driver lms283gf05_driver = { }, .probe = lms283gf05_probe, .remove = __devexit_p(lms283gf05_remove), + .suspend = lms283gf05_suspend, + .resume = lms283gf05_resume, }; module_spi_driver(lms283gf05_driver);