linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: linux-input@vger.kernel.org
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	David Jander <david@protonic.nl>,
	kernel@pengutronix.de, David Jander <david.jander@protonic.nl>
Subject: [PATCH v2] input/mc13783_ts: Add support for mc13892
Date: Wed, 28 Sep 2011 20:51:08 +0200	[thread overview]
Message-ID: <1317235868-3436-1-git-send-email-u.kleine-koenig@pengutronix.de> (raw)
In-Reply-To: <1317049057-4936-1-git-send-email-u.kleine-koenig@pengutronix.de>

From: David Jander <david.jander@protonic.nl>

The mc13892 has almost the same touchscreen controller as the mc13783.

Signed-off-by: David Jander <david@protonic.nl>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
changes since (implicit) v1:
 - undo renaming
 - report average of the two samples on mc13892 instead of the first.
 - some minor cosmetic changes
 - set author to David as he did the technical work, I only cleaned up.

 drivers/input/touchscreen/Kconfig      |    8 +++---
 drivers/input/touchscreen/mc13783_ts.c |   35 ++++++++++++++++++++++++++-----
 2 files changed, 33 insertions(+), 10 deletions(-)

diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index cabd9e5..aeece83 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -549,11 +549,11 @@ config TOUCHSCREEN_USB_COMPOSITE
 	  module will be called usbtouchscreen.
 
 config TOUCHSCREEN_MC13783
-	tristate "Freescale MC13783 touchscreen input driver"
-	depends on MFD_MC13783
+	tristate "Freescale MC13783/MC13892 touchscreen input driver"
+	depends on MFD_MC13XXX
 	help
-	  Say Y here if you have an Freescale MC13783 PMIC on your
-	  board and want to use its touchscreen
+	  Say Y here if you have an Freescale MC13783/MC13892 PMIC on your
+	  board and want to use its touchscreen.
 
 	  If unsure, say N.
 
diff --git a/drivers/input/touchscreen/mc13783_ts.c b/drivers/input/touchscreen/mc13783_ts.c
index ede0274..afa62cf 100644
--- a/drivers/input/touchscreen/mc13783_ts.c
+++ b/drivers/input/touchscreen/mc13783_ts.c
@@ -20,7 +20,7 @@
 #include <linux/slab.h>
 #include <linux/init.h>
 
-#define MC13783_TS_NAME	"mc13783-ts"
+#define DRIVER_NAME	"mc13783-ts"
 
 #define DEFAULT_SAMPLE_TOLERANCE 300
 
@@ -33,7 +33,10 @@ MODULE_PARM_DESC(sample_tolerance,
 		"is supposed to be wrong and is discarded.  Set to 0 to "
 		"disable this check.");
 
+#define MC13783_TS_TWO_SAMPLES	1
+
 struct mc13783_ts_priv {
+	struct platform_device *pdev;
 	struct input_dev *idev;
 	struct mc13xxx *mc13xxx;
 	struct delayed_work work;
@@ -69,6 +72,7 @@ static irqreturn_t mc13783_ts_handler(int irq, void *data)
 
 static void mc13783_ts_report_sample(struct mc13783_ts_priv *priv)
 {
+	struct platform_device *pdev = priv->pdev;
 	struct input_dev *idev = priv->idev;
 	int x0, x1, x2, y0, y1, y2;
 	int cr0, cr1;
@@ -86,6 +90,13 @@ static void mc13783_ts_report_sample(struct mc13783_ts_priv *priv)
 	cr0 = (priv->sample[2] >> 12) & 0xfff;
 	cr1 = (priv->sample[3] >> 12) & 0xfff;
 
+	/* On the mc13892, x2 and y2 are invalid */
+	if (platform_get_device_id(pdev)->driver_data &
+			MC13783_TS_TWO_SAMPLES) {
+		x2 = (x1 + x0) / 2;
+		y2 = (y1 + y0) / 2;
+	}
+
 	dev_dbg(&idev->dev,
 		"x: (% 4d,% 4d,% 4d) y: (% 4d, % 4d,% 4d) cr: (% 4d, % 4d)\n",
 		x0, x1, x2, y0, y1, y2, cr0, cr1);
@@ -139,7 +150,7 @@ static int mc13783_ts_open(struct input_dev *dev)
 	mc13xxx_irq_ack(priv->mc13xxx, MC13XXX_IRQ_TS);
 
 	ret = mc13xxx_irq_request(priv->mc13xxx, MC13XXX_IRQ_TS,
-		mc13783_ts_handler, MC13783_TS_NAME, priv);
+		mc13783_ts_handler, DRIVER_NAME, priv);
 	if (ret)
 		goto out;
 
@@ -177,6 +188,7 @@ static int __init mc13783_ts_probe(struct platform_device *pdev)
 		goto err_free_mem;
 
 	INIT_DELAYED_WORK(&priv->work, mc13783_ts_work);
+	priv->pdev = pdev;
 	priv->mc13xxx = dev_get_drvdata(pdev->dev.parent);
 	priv->idev = idev;
 
@@ -184,11 +196,11 @@ static int __init mc13783_ts_probe(struct platform_device *pdev)
 	 * We need separate workqueue because mc13783_adc_do_conversion
 	 * uses keventd and thus would deadlock.
 	 */
-	priv->workq = create_singlethread_workqueue("mc13783_ts");
+	priv->workq = create_singlethread_workqueue(pdev->name);
 	if (!priv->workq)
 		goto err_free_mem;
 
-	idev->name = MC13783_TS_NAME;
+	idev->name = pdev->name;
 	idev->dev.parent = &pdev->dev;
 
 	idev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
@@ -232,12 +244,24 @@ static int __devexit mc13783_ts_remove(struct platform_device *pdev)
 
 	return 0;
 }
+static const struct platform_device_id mc13783_ts_idtable[] = {
+	{
+		.name = "mc13783-ts",
+	}, {
+		.name = "mc13892-ts",
+		.driver_data = MC13783_TS_TWO_SAMPLES,
+	}, {
+		/* sentinel */
+	}
+};
+MODULE_DEVICE_TABLE(platform, mc13783_ts_idtable);
 
 static struct platform_driver mc13783_ts_driver = {
+	.id_table	= mc13783_ts_idtable,
 	.remove		= __devexit_p(mc13783_ts_remove),
 	.driver		= {
 		.owner	= THIS_MODULE,
-		.name	= MC13783_TS_NAME,
+		.name	= DRIVER_NAME,
 	},
 };
 
@@ -256,4 +280,3 @@ module_exit(mc13783_ts_exit);
 MODULE_DESCRIPTION("MC13783 input touchscreen driver");
 MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>");
 MODULE_LICENSE("GPL v2");
-MODULE_ALIAS("platform:" MC13783_TS_NAME);
-- 
1.7.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

      parent reply	other threads:[~2011-09-28 18:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-26 14:57 [PATCH] input/mc13xxx_ts.c: Add support for mc13892 Uwe Kleine-König
2011-09-26 17:54 ` Dmitry Torokhov
2011-09-28 18:51 ` Uwe Kleine-König [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=1317235868-3436-1-git-send-email-u.kleine-koenig@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=david.jander@protonic.nl \
    --cc=david@protonic.nl \
    --cc=dmitry.torokhov@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-input@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).