linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mark Brown <broonie@opensource.wolfsonmicro.com>
To: Andrew Morton <akpm@linux-foundation.org>,
	Dmitry Torokhov <dtor@mail.ru>, Jiri Kosina <jkosina@suse.cz>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	Mark Brown <broonie@opensource.wolfsonmicro.com>
Subject: [PATCH 3/3] wm97xx-core: Support use as a wakeup source
Date: Mon, 14 Apr 2008 18:39:35 +0100	[thread overview]
Message-ID: <1208194775-4293-3-git-send-email-broonie@opensource.wolfsonmicro.com> (raw)
In-Reply-To: <1208194775-4293-2-git-send-email-broonie@opensource.wolfsonmicro.com>

The PENDOWN signal from the WM97xx touch screen controllers can be used
to generate a wakeup event when the system is suspended. Provide a new
machine configuration option 'suspend_mode' allowing machine drivers to
enable this. If no suspend_mode is provided then the touch panel will be
powered down when the system is suspended.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
 drivers/input/touchscreen/wm97xx-core.c |   22 ++++++++++++++++++++++
 include/linux/wm97xx.h                  |    3 +++
 2 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/drivers/input/touchscreen/wm97xx-core.c b/drivers/input/touchscreen/wm97xx-core.c
index fec07c2..e1a1ca0 100644
--- a/drivers/input/touchscreen/wm97xx-core.c
+++ b/drivers/input/touchscreen/wm97xx-core.c
@@ -689,10 +689,32 @@ static int wm97xx_remove(struct device *dev)
 static int wm97xx_suspend(struct device *dev, pm_message_t state)
 {
 	struct wm97xx *wm = dev_get_drvdata(dev);
+	u16 reg;
+	int suspend_mode;
+
+	if (wm->mach_ops)
+		suspend_mode = wm->mach_ops->suspend_mode;
+	else
+		suspend_mode = 0;
 
 	if (wm->input_dev->users)
 		cancel_delayed_work_sync(&wm->ts_reader);
 
+	/* Power down the digitiser (bypassing the cache for resume) */
+	reg = wm97xx_reg_read(wm, AC97_WM97XX_DIGITISER2);
+	reg &= ~WM97XX_PRP_DET_DIG;
+	if (wm->input_dev->users && suspend_mode)
+		reg |= suspend_mode;
+	wm->ac97->bus->ops->write(wm->ac97, AC97_WM97XX_DIGITISER2, reg);
+
+	/* WM9713 has an additional power bit - turn it off if there
+	 * are no users or if suspend mode is zero. */
+	if (wm->id == WM9713_ID2 &&
+	    (!wm->input_dev->users || !suspend_mode)) {
+		reg = wm97xx_reg_read(wm, AC97_EXTENDED_MID) | 0x8000;
+		wm97xx_reg_write(wm, AC97_EXTENDED_MID, reg);
+	}
+
 	return 0;
 }
 
diff --git a/include/linux/wm97xx.h b/include/linux/wm97xx.h
index ed01c7d..2082833 100644
--- a/include/linux/wm97xx.h
+++ b/include/linux/wm97xx.h
@@ -258,6 +258,9 @@ struct wm97xx_mach_ops {
 	/* pre and post sample - can be used to minimise any analog noise */
 	void (*pre_sample) (int);  /* function to run before sampling */
 	void (*post_sample) (int);  /* function to run after sampling */
+
+	/* WM97XX_PRP value to configure while system is suspended */
+	u16 suspend_mode;
 };
 
 struct wm97xx {
-- 
1.5.5


  reply	other threads:[~2008-04-14 17:39 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-14 17:38 WM97xx touchscreen updates Mark Brown
2008-04-14 17:39 ` [PATCH 1/3] wm97xx-core: Only schedule interrupt handler if not already scheduled Mark Brown
2008-04-14 17:39   ` [PATCH 2/3] wm97xx-core: Use IRQF_SAMPLE_RANDOM Mark Brown
2008-04-14 17:39     ` Mark Brown [this message]
2008-04-14 20:34       ` [PATCH 3/3] wm97xx-core: Support use as a wakeup source Dmitry Torokhov
2008-04-15  0:29         ` David Brownell
2008-04-15 12:18           ` Mark Brown
2008-04-14 18:10   ` [PATCH 1/3] wm97xx-core: Only schedule interrupt handler if not already scheduled Dmitry Torokhov
2008-04-15  8:48     ` Mark Brown
2008-04-15 13:02       ` Dmitry Torokhov
2008-04-15 14:42         ` Mark Brown
  -- strict thread matches above, loose matches on Subject: below --
2008-04-15 14:45 WM97xx touchscreen updates Mark Brown
2008-04-15 14:47 ` [PATCH 1/3] wm97xx-core: Only schedule interrupt handler if not already scheduled Mark Brown
2008-04-15 14:47   ` [PATCH 2/3] wm97xx-core: Use IRQF_SAMPLE_RANDOM Mark Brown
2008-04-15 14:47     ` [PATCH 3/3] wm97xx-core: Support use as a wakeup source Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1208194775-4293-3-git-send-email-broonie@opensource.wolfsonmicro.com \
    --to=broonie@opensource.wolfsonmicro.com \
    --cc=akpm@linux-foundation.org \
    --cc=dtor@mail.ru \
    --cc=jkosina@suse.cz \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).