All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] input/mc13xxx_ts.c: Add support for mc13892
@ 2011-09-26 14:57 Uwe Kleine-König
  2011-09-26 17:54 ` Dmitry Torokhov
  2011-09-28 18:51 ` [PATCH v2] input/mc13783_ts: " Uwe Kleine-König
  0 siblings, 2 replies; 3+ messages in thread
From: Uwe Kleine-König @ 2011-09-26 14:57 UTC (permalink / raw)
  To: linux-input; +Cc: Dmitry Torokhov, David Jander

The mc13892 has almost the same touchscreen controller as the mc13783.
This patch adds support for mc13892.

Based on an earlier patch by David Jander.

Cc: David Jander <david@protonic.nl>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/input/touchscreen/Kconfig      |   10 +-
 drivers/input/touchscreen/Makefile     |    2 +-
 drivers/input/touchscreen/mc13783_ts.c |  259 -----------------------------
 drivers/input/touchscreen/mc13xxx_ts.c |  282 ++++++++++++++++++++++++++++++++
 4 files changed, 288 insertions(+), 265 deletions(-)
 delete mode 100644 drivers/input/touchscreen/mc13783_ts.c
 create mode 100644 drivers/input/touchscreen/mc13xxx_ts.c

diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index cabd9e5..3daeae6 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -548,17 +548,17 @@ config TOUCHSCREEN_USB_COMPOSITE
 	  To compile this driver as a module, choose M here: the
 	  module will be called usbtouchscreen.
 
-config TOUCHSCREEN_MC13783
-	tristate "Freescale MC13783 touchscreen input driver"
-	depends on MFD_MC13783
+config TOUCHSCREEN_MC13XXX
+	tristate "Freescale MC13783/MC13892 touchscreen input driver"
+	depends on MFD_MC13XXX
 	help
-	  Say Y here if you have an Freescale MC13783 PMIC on your
+	  Say Y here if you have an Freescale MC13783/MC13892 PMIC on your
 	  board and want to use its touchscreen
 
 	  If unsure, say N.
 
 	  To compile this driver as a module, choose M here: the
-	  module will be called mc13783_ts.
+	  module will be called mc13xxx_ts.
 
 config TOUCHSCREEN_USB_EGALAX
 	default y
diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile
index 282d6f7..2e90c01 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -28,7 +28,7 @@ obj-$(CONFIG_TOUCHSCREEN_INEXIO)	+= inexio.o
 obj-$(CONFIG_TOUCHSCREEN_INTEL_MID)	+= intel-mid-touch.o
 obj-$(CONFIG_TOUCHSCREEN_LPC32XX)	+= lpc32xx_ts.o
 obj-$(CONFIG_TOUCHSCREEN_MAX11801)	+= max11801_ts.o
-obj-$(CONFIG_TOUCHSCREEN_MC13783)	+= mc13783_ts.o
+obj-$(CONFIG_TOUCHSCREEN_MC13XXX)	+= mc13xxx_ts.o
 obj-$(CONFIG_TOUCHSCREEN_MCS5000)	+= mcs5000_ts.o
 obj-$(CONFIG_TOUCHSCREEN_MIGOR)		+= migor_ts.o
 obj-$(CONFIG_TOUCHSCREEN_MTOUCH)	+= mtouch.o
diff --git a/drivers/input/touchscreen/mc13783_ts.c b/drivers/input/touchscreen/mc13783_ts.c
deleted file mode 100644
index ede0274..0000000
--- a/drivers/input/touchscreen/mc13783_ts.c
+++ /dev/null
@@ -1,259 +0,0 @@
-/*
- * Driver for the Freescale Semiconductor MC13783 touchscreen.
- *
- * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved.
- * Copyright (C) 2009 Sascha Hauer, Pengutronix
- *
- * Initial development of this code was funded by
- * Phytec Messtechnik GmbH, http://www.phytec.de/
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published by
- * the Free Software Foundation.
- */
-#include <linux/platform_device.h>
-#include <linux/mfd/mc13783.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/input.h>
-#include <linux/sched.h>
-#include <linux/slab.h>
-#include <linux/init.h>
-
-#define MC13783_TS_NAME	"mc13783-ts"
-
-#define DEFAULT_SAMPLE_TOLERANCE 300
-
-static unsigned int sample_tolerance = DEFAULT_SAMPLE_TOLERANCE;
-module_param(sample_tolerance, uint, S_IRUGO | S_IWUSR);
-MODULE_PARM_DESC(sample_tolerance,
-		"If the minimal and maximal value read out for one axis (out "
-		"of three) differ by this value (default: "
-		__stringify(DEFAULT_SAMPLE_TOLERANCE) ") or more, the reading "
-		"is supposed to be wrong and is discarded.  Set to 0 to "
-		"disable this check.");
-
-struct mc13783_ts_priv {
-	struct input_dev *idev;
-	struct mc13xxx *mc13xxx;
-	struct delayed_work work;
-	struct workqueue_struct *workq;
-	unsigned int sample[4];
-};
-
-static irqreturn_t mc13783_ts_handler(int irq, void *data)
-{
-	struct mc13783_ts_priv *priv = data;
-
-	mc13xxx_irq_ack(priv->mc13xxx, irq);
-
-	/*
-	 * Kick off reading coordinates. Note that if work happens already
-	 * be queued for future execution (it rearms itself) it will not
-	 * be rescheduled for immediate execution here. However the rearm
-	 * delay is HZ / 50 which is acceptable.
-	 */
-	queue_delayed_work(priv->workq, &priv->work, 0);
-
-	return IRQ_HANDLED;
-}
-
-#define sort3(a0, a1, a2) ({						\
-		if (a0 > a1)						\
-			swap(a0, a1);					\
-		if (a1 > a2)						\
-			swap(a1, a2);					\
-		if (a0 > a1)						\
-			swap(a0, a1);					\
-		})
-
-static void mc13783_ts_report_sample(struct mc13783_ts_priv *priv)
-{
-	struct input_dev *idev = priv->idev;
-	int x0, x1, x2, y0, y1, y2;
-	int cr0, cr1;
-
-	/*
-	 * the values are 10-bit wide only, but the two least significant
-	 * bits are for future 12 bit use and reading yields 0
-	 */
-	x0 = priv->sample[0] & 0xfff;
-	x1 = priv->sample[1] & 0xfff;
-	x2 = priv->sample[2] & 0xfff;
-	y0 = priv->sample[3] & 0xfff;
-	y1 = (priv->sample[0] >> 12) & 0xfff;
-	y2 = (priv->sample[1] >> 12) & 0xfff;
-	cr0 = (priv->sample[2] >> 12) & 0xfff;
-	cr1 = (priv->sample[3] >> 12) & 0xfff;
-
-	dev_dbg(&idev->dev,
-		"x: (% 4d,% 4d,% 4d) y: (% 4d, % 4d,% 4d) cr: (% 4d, % 4d)\n",
-		x0, x1, x2, y0, y1, y2, cr0, cr1);
-
-	sort3(x0, x1, x2);
-	sort3(y0, y1, y2);
-
-	cr0 = (cr0 + cr1) / 2;
-
-	if (!cr0 || !sample_tolerance ||
-			(x2 - x0 < sample_tolerance &&
-			 y2 - y0 < sample_tolerance)) {
-		/* report the median coordinate and average pressure */
-		if (cr0) {
-			input_report_abs(idev, ABS_X, x1);
-			input_report_abs(idev, ABS_Y, y1);
-
-			dev_dbg(&idev->dev, "report (%d, %d, %d)\n",
-					x1, y1, 0x1000 - cr0);
-			queue_delayed_work(priv->workq, &priv->work, HZ / 50);
-		} else
-			dev_dbg(&idev->dev, "report release\n");
-
-		input_report_abs(idev, ABS_PRESSURE,
-				cr0 ? 0x1000 - cr0 : cr0);
-		input_report_key(idev, BTN_TOUCH, cr0);
-		input_sync(idev);
-	} else
-		dev_dbg(&idev->dev, "discard event\n");
-}
-
-static void mc13783_ts_work(struct work_struct *work)
-{
-	struct mc13783_ts_priv *priv =
-		container_of(work, struct mc13783_ts_priv, work.work);
-	unsigned int mode = MC13XXX_ADC_MODE_TS;
-	unsigned int channel = 12;
-
-	if (mc13xxx_adc_do_conversion(priv->mc13xxx,
-				mode, channel, priv->sample) == 0)
-		mc13783_ts_report_sample(priv);
-}
-
-static int mc13783_ts_open(struct input_dev *dev)
-{
-	struct mc13783_ts_priv *priv = input_get_drvdata(dev);
-	int ret;
-
-	mc13xxx_lock(priv->mc13xxx);
-
-	mc13xxx_irq_ack(priv->mc13xxx, MC13XXX_IRQ_TS);
-
-	ret = mc13xxx_irq_request(priv->mc13xxx, MC13XXX_IRQ_TS,
-		mc13783_ts_handler, MC13783_TS_NAME, priv);
-	if (ret)
-		goto out;
-
-	ret = mc13xxx_reg_rmw(priv->mc13xxx, MC13XXX_ADC0,
-			MC13XXX_ADC0_TSMOD_MASK, MC13XXX_ADC0_TSMOD0);
-	if (ret)
-		mc13xxx_irq_free(priv->mc13xxx, MC13XXX_IRQ_TS, priv);
-out:
-	mc13xxx_unlock(priv->mc13xxx);
-	return ret;
-}
-
-static void mc13783_ts_close(struct input_dev *dev)
-{
-	struct mc13783_ts_priv *priv = input_get_drvdata(dev);
-
-	mc13xxx_lock(priv->mc13xxx);
-	mc13xxx_reg_rmw(priv->mc13xxx, MC13XXX_ADC0,
-			MC13XXX_ADC0_TSMOD_MASK, 0);
-	mc13xxx_irq_free(priv->mc13xxx, MC13XXX_IRQ_TS, priv);
-	mc13xxx_unlock(priv->mc13xxx);
-
-	cancel_delayed_work_sync(&priv->work);
-}
-
-static int __init mc13783_ts_probe(struct platform_device *pdev)
-{
-	struct mc13783_ts_priv *priv;
-	struct input_dev *idev;
-	int ret = -ENOMEM;
-
-	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
-	idev = input_allocate_device();
-	if (!priv || !idev)
-		goto err_free_mem;
-
-	INIT_DELAYED_WORK(&priv->work, mc13783_ts_work);
-	priv->mc13xxx = dev_get_drvdata(pdev->dev.parent);
-	priv->idev = idev;
-
-	/*
-	 * We need separate workqueue because mc13783_adc_do_conversion
-	 * uses keventd and thus would deadlock.
-	 */
-	priv->workq = create_singlethread_workqueue("mc13783_ts");
-	if (!priv->workq)
-		goto err_free_mem;
-
-	idev->name = MC13783_TS_NAME;
-	idev->dev.parent = &pdev->dev;
-
-	idev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
-	idev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
-	input_set_abs_params(idev, ABS_X, 0, 0xfff, 0, 0);
-	input_set_abs_params(idev, ABS_Y, 0, 0xfff, 0, 0);
-	input_set_abs_params(idev, ABS_PRESSURE, 0, 0xfff, 0, 0);
-
-	idev->open = mc13783_ts_open;
-	idev->close = mc13783_ts_close;
-
-	input_set_drvdata(idev, priv);
-
-	ret = input_register_device(priv->idev);
-	if (ret) {
-		dev_err(&pdev->dev,
-			"register input device failed with %d\n", ret);
-		goto err_destroy_wq;
-	}
-
-	platform_set_drvdata(pdev, priv);
-	return 0;
-
-err_destroy_wq:
-	destroy_workqueue(priv->workq);
-err_free_mem:
-	input_free_device(idev);
-	kfree(priv);
-	return ret;
-}
-
-static int __devexit mc13783_ts_remove(struct platform_device *pdev)
-{
-	struct mc13783_ts_priv *priv = platform_get_drvdata(pdev);
-
-	platform_set_drvdata(pdev, NULL);
-
-	destroy_workqueue(priv->workq);
-	input_unregister_device(priv->idev);
-	kfree(priv);
-
-	return 0;
-}
-
-static struct platform_driver mc13783_ts_driver = {
-	.remove		= __devexit_p(mc13783_ts_remove),
-	.driver		= {
-		.owner	= THIS_MODULE,
-		.name	= MC13783_TS_NAME,
-	},
-};
-
-static int __init mc13783_ts_init(void)
-{
-	return platform_driver_probe(&mc13783_ts_driver, &mc13783_ts_probe);
-}
-module_init(mc13783_ts_init);
-
-static void __exit mc13783_ts_exit(void)
-{
-	platform_driver_unregister(&mc13783_ts_driver);
-}
-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);
diff --git a/drivers/input/touchscreen/mc13xxx_ts.c b/drivers/input/touchscreen/mc13xxx_ts.c
new file mode 100644
index 0000000..2eda31b
--- /dev/null
+++ b/drivers/input/touchscreen/mc13xxx_ts.c
@@ -0,0 +1,282 @@
+/*
+ * Driver for the Freescale Semiconductor MC13783 touchscreen.
+ *
+ * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright (C) 2009 Sascha Hauer, Pengutronix
+ *
+ * Initial development of this code was funded by
+ * Phytec Messtechnik GmbH, http://www.phytec.de/
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ */
+#include <linux/platform_device.h>
+#include <linux/mfd/mc13783.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/input.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/init.h>
+
+#define DRIVER_NAME	"mc13xxx-ts"
+
+#define DEFAULT_SAMPLE_TOLERANCE 300
+
+static unsigned int sample_tolerance = DEFAULT_SAMPLE_TOLERANCE;
+module_param(sample_tolerance, uint, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(sample_tolerance,
+		"If the minimal and maximal value read out for one axis (out "
+		"of three) differ by this value (default: "
+		__stringify(DEFAULT_SAMPLE_TOLERANCE) ") or more, the reading "
+		"is supposed to be wrong and is discarded.  Set to 0 to "
+		"disable this check.");
+
+#define MC13XXX_TWO_SAMPLES	1
+
+struct mc13783_ts_priv {
+	struct platform_device *pdev;
+	struct input_dev *idev;
+	struct mc13xxx *mc13xxx;
+	struct delayed_work work;
+	struct workqueue_struct *workq;
+	unsigned int sample[4];
+};
+
+static irqreturn_t mc13783_ts_handler(int irq, void *data)
+{
+	struct mc13783_ts_priv *priv = data;
+
+	mc13xxx_irq_ack(priv->mc13xxx, irq);
+
+	/*
+	 * Kick off reading coordinates. Note that if work happens already
+	 * be queued for future execution (it rearms itself) it will not
+	 * be rescheduled for immediate execution here. However the rearm
+	 * delay is HZ / 50 which is acceptable.
+	 */
+	queue_delayed_work(priv->workq, &priv->work, 0);
+
+	return IRQ_HANDLED;
+}
+
+#define sort3(a0, a1, a2) ({						\
+		if (a0 > a1)						\
+			swap(a0, a1);					\
+		if (a1 > a2)						\
+			swap(a1, a2);					\
+		if (a0 > a1)						\
+			swap(a0, a1);					\
+		})
+
+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;
+
+	/*
+	 * the values are 10-bit wide only, but the two least significant
+	 * bits are for future 12 bit use and reading yields 0
+	 */
+	x0 = priv->sample[0] & 0xfff;
+	x1 = priv->sample[1] & 0xfff;
+	x2 = priv->sample[2] & 0xfff;
+	y0 = priv->sample[3] & 0xfff;
+	y1 = (priv->sample[0] >> 12) & 0xfff;
+	y2 = (priv->sample[1] >> 12) & 0xfff;
+	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 & MC13XXX_TWO_SAMPLES) {
+		/* better use x2 = (x1 + x0) / 2 ? */
+		x2 = x1;
+		y2 = y1;
+	}
+
+	dev_dbg(&idev->dev,
+		"x: (% 4d,% 4d,% 4d) y: (% 4d, % 4d,% 4d) cr: (% 4d, % 4d)\n",
+		x0, x1, x2, y0, y1, y2, cr0, cr1);
+
+	sort3(x0, x1, x2);
+	sort3(y0, y1, y2);
+
+	cr0 = (cr0 + cr1) / 2;
+
+	if (!cr0 || !sample_tolerance ||
+			(x2 - x0 < sample_tolerance &&
+			 y2 - y0 < sample_tolerance)) {
+		/* report the median coordinate and average pressure */
+		if (cr0) {
+			input_report_abs(idev, ABS_X, x1);
+			input_report_abs(idev, ABS_Y, y1);
+
+			dev_dbg(&idev->dev, "report (%d, %d, %d)\n",
+					x1, y1, 0x1000 - cr0);
+			queue_delayed_work(priv->workq, &priv->work, HZ / 50);
+		} else
+			dev_dbg(&idev->dev, "report release\n");
+
+		input_report_abs(idev, ABS_PRESSURE,
+				cr0 ? 0x1000 - cr0 : cr0);
+		input_report_key(idev, BTN_TOUCH, cr0);
+		input_sync(idev);
+	} else
+		dev_dbg(&idev->dev, "discard event\n");
+}
+
+static void mc13783_ts_work(struct work_struct *work)
+{
+	struct mc13783_ts_priv *priv =
+		container_of(work, struct mc13783_ts_priv, work.work);
+	unsigned int mode = MC13XXX_ADC_MODE_TS;
+	unsigned int channel = 12;
+
+	if (mc13xxx_adc_do_conversion(priv->mc13xxx,
+				mode, channel, priv->sample) == 0)
+		mc13783_ts_report_sample(priv);
+}
+
+static int mc13783_ts_open(struct input_dev *dev)
+{
+	struct mc13783_ts_priv *priv = input_get_drvdata(dev);
+	int ret;
+
+	mc13xxx_lock(priv->mc13xxx);
+
+	mc13xxx_irq_ack(priv->mc13xxx, MC13XXX_IRQ_TS);
+
+	ret = mc13xxx_irq_request(priv->mc13xxx, MC13XXX_IRQ_TS,
+		mc13783_ts_handler, DRIVER_NAME, priv);
+	if (ret)
+		goto out;
+
+	ret = mc13xxx_reg_rmw(priv->mc13xxx, MC13XXX_ADC0,
+			MC13XXX_ADC0_TSMOD_MASK, MC13XXX_ADC0_TSMOD0);
+	if (ret)
+		mc13xxx_irq_free(priv->mc13xxx, MC13XXX_IRQ_TS, priv);
+out:
+	mc13xxx_unlock(priv->mc13xxx);
+	return ret;
+}
+
+static void mc13783_ts_close(struct input_dev *dev)
+{
+	struct mc13783_ts_priv *priv = input_get_drvdata(dev);
+
+	mc13xxx_lock(priv->mc13xxx);
+	mc13xxx_reg_rmw(priv->mc13xxx, MC13XXX_ADC0,
+			MC13XXX_ADC0_TSMOD_MASK, 0);
+	mc13xxx_irq_free(priv->mc13xxx, MC13XXX_IRQ_TS, priv);
+	mc13xxx_unlock(priv->mc13xxx);
+
+	cancel_delayed_work_sync(&priv->work);
+}
+
+static int __init mc13783_ts_probe(struct platform_device *pdev)
+{
+	struct mc13783_ts_priv *priv;
+	struct input_dev *idev;
+	int ret = -ENOMEM;
+
+	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
+	idev = input_allocate_device();
+	if (!priv || !idev)
+		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;
+
+	/*
+	 * We need separate workqueue because mc13783_adc_do_conversion
+	 * uses keventd and thus would deadlock.
+	 */
+	priv->workq = create_singlethread_workqueue(pdev->name);
+	if (!priv->workq)
+		goto err_free_mem;
+
+	idev->name = pdev->name;
+	idev->dev.parent = &pdev->dev;
+
+	idev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
+	idev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
+	input_set_abs_params(idev, ABS_X, 0, 0xfff, 0, 0);
+	input_set_abs_params(idev, ABS_Y, 0, 0xfff, 0, 0);
+	input_set_abs_params(idev, ABS_PRESSURE, 0, 0xfff, 0, 0);
+
+	idev->open = mc13783_ts_open;
+	idev->close = mc13783_ts_close;
+
+	input_set_drvdata(idev, priv);
+
+	ret = input_register_device(priv->idev);
+	if (ret) {
+		dev_err(&pdev->dev,
+			"register input device failed with %d\n", ret);
+		goto err_destroy_wq;
+	}
+
+	platform_set_drvdata(pdev, priv);
+	return 0;
+
+err_destroy_wq:
+	destroy_workqueue(priv->workq);
+err_free_mem:
+	input_free_device(idev);
+	kfree(priv);
+	return ret;
+}
+
+static int __devexit mc13783_ts_remove(struct platform_device *pdev)
+{
+	struct mc13783_ts_priv *priv = platform_get_drvdata(pdev);
+
+	platform_set_drvdata(pdev, NULL);
+
+	destroy_workqueue(priv->workq);
+	input_unregister_device(priv->idev);
+	kfree(priv);
+
+	return 0;
+}
+static const struct platform_device_id mc13xxx_ts_idtable[] = {
+	{
+		.name = "mc13783-ts",
+	}, {
+		.name = "mc13892-ts",
+		.driver_data = MC13XXX_TWO_SAMPLES,
+	}, {
+		/* sentinel */
+	}
+};
+MODULE_DEVICE_TABLE(platform, mc13xxx_ts_idtable);
+
+static struct platform_driver mc13783_ts_driver = {
+	.id_table	= mc13xxx_ts_idtable,
+	.remove		= __devexit_p(mc13783_ts_remove),
+	.driver		= {
+		.owner	= THIS_MODULE,
+		.name	= DRIVER_NAME,
+	},
+};
+
+static int __init mc13783_ts_init(void)
+{
+	return platform_driver_probe(&mc13783_ts_driver, &mc13783_ts_probe);
+}
+module_init(mc13783_ts_init);
+
+static void __exit mc13783_ts_exit(void)
+{
+	platform_driver_unregister(&mc13783_ts_driver);
+}
+module_exit(mc13783_ts_exit);
+
+MODULE_DESCRIPTION("MC13783 input touchscreen driver");
+MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>");
+MODULE_LICENSE("GPL v2");
-- 
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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] input/mc13xxx_ts.c: Add support for mc13892
  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 ` [PATCH v2] input/mc13783_ts: " Uwe Kleine-König
  1 sibling, 0 replies; 3+ messages in thread
From: Dmitry Torokhov @ 2011-09-26 17:54 UTC (permalink / raw)
  To: Uwe Kleine-König; +Cc: linux-input, David Jander

Hi Uwe,

On Mon, Sep 26, 2011 at 04:57:37PM +0200, Uwe Kleine-König wrote:
> The mc13892 has almost the same touchscreen controller as the mc13783.
> This patch adds support for mc13892.
> 
> Based on an earlier patch by David Jander.
> 
> Cc: David Jander <david@protonic.nl>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
>  drivers/input/touchscreen/Kconfig      |   10 +-
>  drivers/input/touchscreen/Makefile     |    2 +-
>  drivers/input/touchscreen/mc13783_ts.c |  259 -----------------------------
>  drivers/input/touchscreen/mc13xxx_ts.c |  282 ++++++++++++++++++++++++++++++++
>  4 files changed, 288 insertions(+), 265 deletions(-)
>  delete mode 100644 drivers/input/touchscreen/mc13783_ts.c
>  create mode 100644 drivers/input/touchscreen/mc13xxx_ts.c

This rename hides completely what was done to the driver to support the
new chip. I also do not think that rename is that useful; I think if we
simply update Kconfig text an driver description to reflectthe fact that
we now support 2 chips that shoudl be enough.

Thanks.

-- 
Dmitry
--
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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v2] input/mc13783_ts: Add support for mc13892
  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
  1 sibling, 0 replies; 3+ messages in thread
From: Uwe Kleine-König @ 2011-09-28 18:51 UTC (permalink / raw)
  To: linux-input; +Cc: Dmitry Torokhov, David Jander, kernel, David Jander

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-09-28 18:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH v2] input/mc13783_ts: " Uwe Kleine-König

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.