From: David Jander <david.jander@xxxxxxxxxxx> The mc13892 has almost the same touchscreen controller as the mc13783. Signed-off-by: David Jander <david@xxxxxxxxxxx> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxxxx> --- 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@xxxxxxxxxxxxxx>"); 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@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html