linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: zumeng.chen@windriver.com (Zumeng Chen)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 5/5] ARM: OMAP3530evm: set pendown_state and debounce time for ads7846
Date: Wed, 20 Jun 2012 17:14:53 +0800	[thread overview]
Message-ID: <1340183693-3195-6-git-send-email-zumeng.chen@windriver.com> (raw)
In-Reply-To: <1340183693-3195-1-git-send-email-zumeng.chen@windriver.com>

Currently most ads7846 config definitions for OMAP3 series boards have
been moved to common-board-devices.c, and it is transparent for init.
And it's no very proper to do gpio_request based on get_pendown_state
since omap_ads7846_init knows everything about ads7846_config.

So it's more fit to request gpio according to the right gpio_pendown
and set debounce time conditionally. If we don't set proper debouce
time, there are flooded interrupt counters of ads7846 responding to
one time touch on screen, then the driver couldn't work very well.

This patch has been validated on 3530evm.

Signed-off-by: Zumeng Chen <zumeng.chen@windriver.com>
---
 arch/arm/mach-omap2/board-omap3evm.c       |    1 -
 arch/arm/mach-omap2/common-board-devices.c |   18 ++++++++++++++++--
 arch/arm/mach-omap2/common-board-devices.h |    1 +
 3 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-omap2/board-omap3evm.c b/arch/arm/mach-omap2/board-omap3evm.c
index 02d8047..834cfc0 100644
--- a/arch/arm/mach-omap2/board-omap3evm.c
+++ b/arch/arm/mach-omap2/board-omap3evm.c
@@ -58,7 +58,6 @@
 #include "hsmmc.h"
 #include "common-board-devices.h"
 
-#define OMAP3_EVM_TS_GPIO	175
 #define OMAP3_EVM_EHCI_VBUS	22
 #define OMAP3_EVM_EHCI_SELECT	61
 
diff --git a/arch/arm/mach-omap2/common-board-devices.c b/arch/arm/mach-omap2/common-board-devices.c
index 1706ebc..4ba070e 100644
--- a/arch/arm/mach-omap2/common-board-devices.c
+++ b/arch/arm/mach-omap2/common-board-devices.c
@@ -35,6 +35,16 @@ static struct omap2_mcspi_device_config ads7846_mcspi_config = {
 	.turbo_mode	= 0,
 };
 
+/*
+ * ADS7846 driver maybe request a gpio according to the value
+ * of pdata->get_pendown_state, but we have done this. So set
+ * get_pendown_state to avoid twice gpio requesting.
+ */
+static int omap3_get_pendown_state(void)
+{
+	return !gpio_get_value(OMAP3_EVM_TS_GPIO);
+}
+
 static struct ads7846_platform_data ads7846_config = {
 	.x_max			= 0x0fff,
 	.y_max			= 0x0fff,
@@ -45,6 +55,7 @@ static struct ads7846_platform_data ads7846_config = {
 	.debounce_rep		= 1,
 	.gpio_pendown		= -EINVAL,
 	.keep_vref_on		= 1,
+	.get_pendown_state	= &omap3_get_pendown_state,
 };
 
 static struct spi_board_info ads7846_spi_board_info __initdata = {
@@ -63,14 +74,17 @@ void __init omap_ads7846_init(int bus_num, int gpio_pendown, int gpio_debounce,
 	struct spi_board_info *spi_bi = &ads7846_spi_board_info;
 	int err;
 
-	if (board_pdata && board_pdata->get_pendown_state) {
+	if (gpio_pendown) {
 		err = gpio_request_one(gpio_pendown, GPIOF_IN, "TSPenDown");
 		if (err) {
 			pr_err("Couldn't obtain gpio for TSPenDown: %d\n", err);
 			return;
 		}
-		gpio_export(gpio_pendown, 0);
 
+		/* TS GPIOPendown doesn't allow user to change the direction */
+		gpio_export(gpio_pendown, false);
+
+		/* Set proper debouce time for ads7846. */
 		if (gpio_debounce)
 			gpio_set_debounce(gpio_pendown, gpio_debounce);
 	}
diff --git a/arch/arm/mach-omap2/common-board-devices.h b/arch/arm/mach-omap2/common-board-devices.h
index a0b4a428..4c4ef6a 100644
--- a/arch/arm/mach-omap2/common-board-devices.h
+++ b/arch/arm/mach-omap2/common-board-devices.h
@@ -4,6 +4,7 @@
 #include "twl-common.h"
 
 #define NAND_BLOCK_SIZE	SZ_128K
+#define OMAP3_EVM_TS_GPIO	175
 
 struct mtd_partition;
 struct ads7846_platform_data;
-- 
1.7.5.4

      parent reply	other threads:[~2012-06-20  9:14 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-20  9:14 [PATCH v3 0/5] ARM OMAP3530evm misc fixes Zumeng Chen
2012-06-20  9:14 ` [PATCH 1/5] ARM: OMAP3EVM: Add NAND flash definition Zumeng Chen
2012-06-20  9:14 ` [PATCH 2/5] ARM: OMAP3EVM: Adding USB internal LDOs board file Zumeng Chen
2012-06-20  9:14 ` [PATCH 3/5] ARM: omap3evm: enable VBUS switch for EHCI tranceiver Zumeng Chen
2012-06-20 12:05   ` Sergei Shtylyov
2012-06-21  1:03     ` Zumeng Chen
2012-07-06  8:41     ` Tony Lindgren
2012-07-08  7:50       ` Zumeng Chen
2012-06-20  9:14 ` [PATCH 4/5] ARM: OMAP3EVM: cosmetic fixes for parent clk set Zumeng Chen
2012-06-20 16:00   ` Jon Hunter
2012-06-21  1:05     ` Zumeng Chen
2012-07-06  8:38   ` Tony Lindgren
2012-06-20  9:14 ` Zumeng Chen [this message]

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=1340183693-3195-6-git-send-email-zumeng.chen@windriver.com \
    --to=zumeng.chen@windriver.com \
    --cc=linux-arm-kernel@lists.infradead.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).