linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/7] add support for mc13892 I2C based touch panel for mx35_3ds
@ 2012-02-14 10:34 Oskar Schirmer
  2012-02-14 10:34 ` [PATCH 1/7] mfd: move mc13xxx global declarations to header file Oskar Schirmer
                   ` (7 more replies)
  0 siblings, 8 replies; 12+ messages in thread
From: Oskar Schirmer @ 2012-02-14 10:34 UTC (permalink / raw)
  To: sameo
  Cc: dmitry.torokhov, kernel, u.kleine-koenig, philippe.retornaz,
	michael.thalmeier, linux-kernel, Oskar Schirmer

mc13xxx touch panel support is limited to SPI based solutions
and to mc13783 based systems when it is about touch panel.

Add both I2C support to the mfd mc13xxx-core driver
and mc13892 specific support to the mc13xxx touch driver,
including calibration support for the latter.

Insert declarations needed for use with mx35_3ds development board.

Oskar Schirmer (7):
  mfd: move mc13xxx global declarations to header file
  mfd: split off mc13xxx SPI specifica from core
  mfd: add I2C handling to mc13xxx driver
  input/touchscreen: rename mc13783_ts.c
  input/touchscreen: add support for mc13892
  input/touchscreen: add calibration functionality with mc13xxx series
  arm/imx: add mc13892 I2C based touch panel support for mx35_3ds

 arch/arm/mach-imx/mach-mx35_3ds.c      |   27 ++
 drivers/input/touchscreen/Kconfig      |   11 +-
 drivers/input/touchscreen/Makefile     |    2 +-
 drivers/input/touchscreen/mc13783_ts.c |  259 -------------------
 drivers/input/touchscreen/mc13xxx_ts.c |  428 ++++++++++++++++++++++++++++++++
 drivers/mfd/Kconfig                    |   23 ++-
 drivers/mfd/Makefile                   |    2 +
 drivers/mfd/mc13xxx-core.c             |  183 ++------------
 drivers/mfd/mc13xxx-i2c.c              |  149 +++++++++++
 drivers/mfd/mc13xxx-spi.c              |  172 +++++++++++++
 include/linux/mfd/mc13xxx.h            |   77 ++++--
 11 files changed, 882 insertions(+), 451 deletions(-)
 delete mode 100644 drivers/input/touchscreen/mc13783_ts.c
 create mode 100644 drivers/input/touchscreen/mc13xxx_ts.c
 create mode 100644 drivers/mfd/mc13xxx-i2c.c
 create mode 100644 drivers/mfd/mc13xxx-spi.c

-- 
1.7.5.4


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

* [PATCH 1/7] mfd: move mc13xxx global declarations to header file
  2012-02-14 10:34 [PATCH 0/7] add support for mc13892 I2C based touch panel for mx35_3ds Oskar Schirmer
@ 2012-02-14 10:34 ` Oskar Schirmer
  2012-02-14 10:34 ` [PATCH 2/7] mfd: split off mc13xxx SPI specifica from core Oskar Schirmer
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Oskar Schirmer @ 2012-02-14 10:34 UTC (permalink / raw)
  To: sameo
  Cc: dmitry.torokhov, kernel, u.kleine-koenig, philippe.retornaz,
	michael.thalmeier, linux-kernel, Oskar Schirmer

In preparation to split SPI specific stuff from mc13xxx-core.c
into a separate file, move non local stuff into the mc13xxx
header file.

Signed-off-by: Oskar Schirmer <oskar@scara.com>
---
 drivers/mfd/mc13xxx-core.c  |   18 -----------
 include/linux/mfd/mc13xxx.h |   66 ++++++++++++++++++++++++++----------------
 2 files changed, 41 insertions(+), 43 deletions(-)

diff --git a/drivers/mfd/mc13xxx-core.c b/drivers/mfd/mc13xxx-core.c
index 7122386..94840c1 100644
--- a/drivers/mfd/mc13xxx-core.c
+++ b/drivers/mfd/mc13xxx-core.c
@@ -22,18 +22,6 @@
 #include <linux/of_device.h>
 #include <linux/of_gpio.h>
 
-struct mc13xxx {
-	struct spi_device *spidev;
-	struct mutex lock;
-	int irq;
-	int flags;
-
-	irq_handler_t irqhandler[MC13XXX_NUM_IRQ];
-	void *irqdata[MC13XXX_NUM_IRQ];
-
-	int adcflags;
-};
-
 #define MC13XXX_IRQSTAT0	0
 #define MC13XXX_IRQSTAT0_ADCDONEI	(1 << 0)
 #define MC13XXX_IRQSTAT0_ADCBISDONEI	(1 << 1)
@@ -475,12 +463,6 @@ static irqreturn_t mc13xxx_irq_thread(int irq, void *data)
 	return IRQ_RETVAL(handled);
 }
 
-enum mc13xxx_id {
-	MC13XXX_ID_MC13783,
-	MC13XXX_ID_MC13892,
-	MC13XXX_ID_INVALID,
-};
-
 static const char *mc13xxx_chipname[] = {
 	[MC13XXX_ID_MC13783] = "mc13783",
 	[MC13XXX_ID_MC13892] = "mc13892",
diff --git a/include/linux/mfd/mc13xxx.h b/include/linux/mfd/mc13xxx.h
index b86ee45..df6654a 100644
--- a/include/linux/mfd/mc13xxx.h
+++ b/include/linux/mfd/mc13xxx.h
@@ -11,7 +11,47 @@
 
 #include <linux/interrupt.h>
 
-struct mc13xxx;
+#define MC13XXX_IRQ_ADCDONE	0
+#define MC13XXX_IRQ_ADCBISDONE	1
+#define MC13XXX_IRQ_TS		2
+#define MC13XXX_IRQ_CHGDET	6
+#define MC13XXX_IRQ_CHGREV	8
+#define MC13XXX_IRQ_CHGSHORT	9
+#define MC13XXX_IRQ_CCCV	10
+#define MC13XXX_IRQ_CHGCURR	11
+#define MC13XXX_IRQ_BPON	12
+#define MC13XXX_IRQ_LOBATL	13
+#define MC13XXX_IRQ_LOBATH	14
+#define MC13XXX_IRQ_1HZ		24
+#define MC13XXX_IRQ_TODA	25
+#define MC13XXX_IRQ_SYSRST	30
+#define MC13XXX_IRQ_RTCRST	31
+#define MC13XXX_IRQ_PC		32
+#define MC13XXX_IRQ_WARM	33
+#define MC13XXX_IRQ_MEMHLD	34
+#define MC13XXX_IRQ_THWARNL	36
+#define MC13XXX_IRQ_THWARNH	37
+#define MC13XXX_IRQ_CLK		38
+
+#define MC13XXX_NUM_IRQ		46
+
+enum mc13xxx_id {
+	MC13XXX_ID_MC13783,
+	MC13XXX_ID_MC13892,
+	MC13XXX_ID_INVALID,
+};
+
+struct mc13xxx {
+	struct spi_device *spidev;
+	struct mutex lock;
+	int irq;
+	int flags;
+
+	irq_handler_t irqhandler[MC13XXX_NUM_IRQ];
+	void *irqdata[MC13XXX_NUM_IRQ];
+
+	int adcflags;
+};
 
 void mc13xxx_lock(struct mc13xxx *mc13xxx);
 void mc13xxx_unlock(struct mc13xxx *mc13xxx);
@@ -40,30 +80,6 @@ int mc13xxx_get_flags(struct mc13xxx *mc13xxx);
 int mc13xxx_adc_do_conversion(struct mc13xxx *mc13xxx,
 		unsigned int mode, unsigned int channel, unsigned int *sample);
 
-#define MC13XXX_IRQ_ADCDONE	0
-#define MC13XXX_IRQ_ADCBISDONE	1
-#define MC13XXX_IRQ_TS		2
-#define MC13XXX_IRQ_CHGDET	6
-#define MC13XXX_IRQ_CHGREV	8
-#define MC13XXX_IRQ_CHGSHORT	9
-#define MC13XXX_IRQ_CCCV	10
-#define MC13XXX_IRQ_CHGCURR	11
-#define MC13XXX_IRQ_BPON	12
-#define MC13XXX_IRQ_LOBATL	13
-#define MC13XXX_IRQ_LOBATH	14
-#define MC13XXX_IRQ_1HZ		24
-#define MC13XXX_IRQ_TODA	25
-#define MC13XXX_IRQ_SYSRST	30
-#define MC13XXX_IRQ_RTCRST	31
-#define MC13XXX_IRQ_PC		32
-#define MC13XXX_IRQ_WARM	33
-#define MC13XXX_IRQ_MEMHLD	34
-#define MC13XXX_IRQ_THWARNL	36
-#define MC13XXX_IRQ_THWARNH	37
-#define MC13XXX_IRQ_CLK		38
-
-#define MC13XXX_NUM_IRQ		46
-
 struct regulator_init_data;
 
 struct mc13xxx_regulator_init_data {
-- 
1.7.5.4


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

* [PATCH 2/7] mfd: split off mc13xxx SPI specifica from core
  2012-02-14 10:34 [PATCH 0/7] add support for mc13892 I2C based touch panel for mx35_3ds Oskar Schirmer
  2012-02-14 10:34 ` [PATCH 1/7] mfd: move mc13xxx global declarations to header file Oskar Schirmer
@ 2012-02-14 10:34 ` Oskar Schirmer
  2012-02-14 10:34 ` [PATCH 3/7] mfd: add I2C handling to mc13xxx driver Oskar Schirmer
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Oskar Schirmer @ 2012-02-14 10:34 UTC (permalink / raw)
  To: sameo
  Cc: dmitry.torokhov, kernel, u.kleine-koenig, philippe.retornaz,
	michael.thalmeier, linux-kernel, Oskar Schirmer

mc13xxx-core.c includes handling SPI directly.
To be able to alternatively use mc13xxx with I2C,
split off SPI specific functionality into separate
file mc13xxx-spi.c, leaving mc13xxx-core.c independent
of the chosen wiring.

Signed-off-by: Oskar Schirmer <oskar@scara.com>
---
 drivers/mfd/Kconfig         |   12 ++-
 drivers/mfd/Makefile        |    1 +
 drivers/mfd/mc13xxx-core.c  |  165 ++++++-----------------------------------
 drivers/mfd/mc13xxx-spi.c   |  172 +++++++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/mc13xxx.h |   13 +++-
 5 files changed, 218 insertions(+), 145 deletions(-)
 create mode 100644 drivers/mfd/mc13xxx-spi.c

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index f147395..750b50c 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -572,14 +572,18 @@ config MFD_MC13783
 	tristate
 
 config MFD_MC13XXX
-	tristate "Support Freescale MC13783 and MC13892"
-	depends on SPI_MASTER
+	tristate
 	select MFD_CORE
 	select MFD_MC13783
+
+config MFD_MC13XXX_SPI
+	tristate "Support Freescale MC13783 and MC13892 with SPI"
+	select MFD_MC13XXX
+	depends on SPI_MASTER
 	help
 	  Support for the Freescale (Atlas) PMIC and audio CODECs
-	  MC13783 and MC13892.
-	  This driver provides common support for accessing  the device,
+	  MC13783 and MC13892, wired for SPI use.
+	  This driver provides common support for accessing the device,
 	  additional drivers must be enabled in order to use the
 	  functionality of the device.
 
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index b953bab..2dc66ed 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -53,6 +53,7 @@ obj-$(CONFIG_TWL6030_PWM)	+= twl6030-pwm.o
 obj-$(CONFIG_TWL6040_CORE)	+= twl6040-core.o twl6040-irq.o
 
 obj-$(CONFIG_MFD_MC13XXX)	+= mc13xxx-core.o
+obj-$(CONFIG_MFD_MC13XXX_SPI)	+= mc13xxx-spi.o
 
 obj-$(CONFIG_MFD_CORE)		+= mfd-core.o
 
diff --git a/drivers/mfd/mc13xxx-core.c b/drivers/mfd/mc13xxx-core.c
index 94840c1..1102b77 100644
--- a/drivers/mfd/mc13xxx-core.c
+++ b/drivers/mfd/mc13xxx-core.c
@@ -15,7 +15,6 @@
 #include <linux/platform_device.h>
 #include <linux/mutex.h>
 #include <linux/interrupt.h>
-#include <linux/spi/spi.h>
 #include <linux/mfd/core.h>
 #include <linux/mfd/mc13xxx.h>
 #include <linux/of.h>
@@ -132,29 +131,26 @@
 void mc13xxx_lock(struct mc13xxx *mc13xxx)
 {
 	if (!mutex_trylock(&mc13xxx->lock)) {
-		dev_dbg(&mc13xxx->spidev->dev, "wait for %s from %pf\n",
+		dev_dbg(mc13xxx->dev, "wait for %s from %pf\n",
 				__func__, __builtin_return_address(0));
 
 		mutex_lock(&mc13xxx->lock);
 	}
-	dev_dbg(&mc13xxx->spidev->dev, "%s from %pf\n",
+	dev_dbg(mc13xxx->dev, "%s from %pf\n",
 			__func__, __builtin_return_address(0));
 }
 EXPORT_SYMBOL(mc13xxx_lock);
 
 void mc13xxx_unlock(struct mc13xxx *mc13xxx)
 {
-	dev_dbg(&mc13xxx->spidev->dev, "%s from %pf\n",
+	dev_dbg(mc13xxx->dev, "%s from %pf\n",
 			__func__, __builtin_return_address(0));
 	mutex_unlock(&mc13xxx->lock);
 }
 EXPORT_SYMBOL(mc13xxx_unlock);
 
-#define MC13XXX_REGOFFSET_SHIFT 25
 int mc13xxx_reg_read(struct mc13xxx *mc13xxx, unsigned int offset, u32 *val)
 {
-	struct spi_transfer t;
-	struct spi_message m;
 	int ret;
 
 	BUG_ON(!mutex_is_locked(&mc13xxx->lock));
@@ -162,66 +158,24 @@ int mc13xxx_reg_read(struct mc13xxx *mc13xxx, unsigned int offset, u32 *val)
 	if (offset > MC13XXX_NUMREGS)
 		return -EINVAL;
 
-	*val = offset << MC13XXX_REGOFFSET_SHIFT;
+	ret = mc13xxx->read(mc13xxx, offset, val);
 
-	memset(&t, 0, sizeof(t));
-
-	t.tx_buf = val;
-	t.rx_buf = val;
-	t.len = sizeof(u32);
-
-	spi_message_init(&m);
-	spi_message_add_tail(&t, &m);
-
-	ret = spi_sync(mc13xxx->spidev, &m);
-
-	/* error in message.status implies error return from spi_sync */
-	BUG_ON(!ret && m.status);
-
-	if (ret)
-		return ret;
-
-	*val &= 0xffffff;
-
-	dev_vdbg(&mc13xxx->spidev->dev, "[0x%02x] -> 0x%06x\n", offset, *val);
-
-	return 0;
+	return ret;
 }
 EXPORT_SYMBOL(mc13xxx_reg_read);
 
 int mc13xxx_reg_write(struct mc13xxx *mc13xxx, unsigned int offset, u32 val)
 {
-	u32 buf;
-	struct spi_transfer t;
-	struct spi_message m;
 	int ret;
 
 	BUG_ON(!mutex_is_locked(&mc13xxx->lock));
 
-	dev_vdbg(&mc13xxx->spidev->dev, "[0x%02x] <- 0x%06x\n", offset, val);
-
 	if (offset > MC13XXX_NUMREGS || val > 0xffffff)
 		return -EINVAL;
 
-	buf = 1 << 31 | offset << MC13XXX_REGOFFSET_SHIFT | val;
-
-	memset(&t, 0, sizeof(t));
-
-	t.tx_buf = &buf;
-	t.rx_buf = &buf;
-	t.len = sizeof(u32);
-
-	spi_message_init(&m);
-	spi_message_add_tail(&t, &m);
-
-	ret = spi_sync(mc13xxx->spidev, &m);
-
-	BUG_ON(!ret && m.status);
+	ret = mc13xxx->write(mc13xxx, offset, val);
 
-	if (ret)
-		return ret;
-
-	return 0;
+	return ret;
 }
 EXPORT_SYMBOL(mc13xxx_reg_write);
 
@@ -427,7 +381,7 @@ static int mc13xxx_irq_handle(struct mc13xxx *mc13xxx,
 			if (handled == IRQ_HANDLED)
 				num_handled++;
 		} else {
-			dev_err(&mc13xxx->spidev->dev,
+			dev_err(mc13xxx->dev,
 					"BUG: irq %u but no handler\n",
 					baseirq + irq);
 
@@ -501,7 +455,7 @@ static int mc13xxx_identify(struct mc13xxx *mc13xxx, enum mc13xxx_id *id)
 		if (ret)
 			return ret;
 
-		dev_info(&mc13xxx->spidev->dev, "%s: rev: %d.%d, "
+		dev_info(mc13xxx->dev, "%s: rev: %d.%d, "
 				"fin: %d, fab: %d, icid: %d/%d\n",
 				mc13xxx_chipname[*id],
 				maskval(revision, MC13XXX_REVISION_REVFULL),
@@ -513,10 +467,8 @@ static int mc13xxx_identify(struct mc13xxx *mc13xxx, enum mc13xxx_id *id)
 	}
 
 	if (*id != MC13XXX_ID_INVALID) {
-		const struct spi_device_id *devid =
-			spi_get_device_id(mc13xxx->spidev);
-		if (!devid || devid->driver_data != *id)
-			dev_warn(&mc13xxx->spidev->dev, "device id doesn't "
+		if (!mc13xxx->driver_data || *mc13xxx->driver_data != *id)
+			dev_warn(mc13xxx->dev, "device id doesn't "
 					"match auto detection!\n");
 	}
 
@@ -525,13 +477,10 @@ static int mc13xxx_identify(struct mc13xxx *mc13xxx, enum mc13xxx_id *id)
 
 static const char *mc13xxx_get_chipname(struct mc13xxx *mc13xxx)
 {
-	const struct spi_device_id *devid =
-		spi_get_device_id(mc13xxx->spidev);
-
-	if (!devid)
+	if (!mc13xxx->driver_data)
 		return NULL;
 
-	return mc13xxx_chipname[devid->driver_data];
+	return mc13xxx_chipname[*mc13xxx->driver_data];
 }
 
 int mc13xxx_get_flags(struct mc13xxx *mc13xxx)
@@ -571,7 +520,7 @@ int mc13xxx_adc_do_conversion(struct mc13xxx *mc13xxx, unsigned int mode,
 	};
 	init_completion(&adcdone_data.done);
 
-	dev_dbg(&mc13xxx->spidev->dev, "%s\n", __func__);
+	dev_dbg(mc13xxx->dev, "%s\n", __func__);
 
 	mc13xxx_lock(mc13xxx);
 
@@ -613,7 +562,7 @@ int mc13xxx_adc_do_conversion(struct mc13xxx *mc13xxx, unsigned int mode,
 		return -EINVAL;
 	}
 
-	dev_dbg(&mc13xxx->spidev->dev, "%s: request irq\n", __func__);
+	dev_dbg(mc13xxx->dev, "%s: request irq\n", __func__);
 	mc13xxx_irq_request(mc13xxx, MC13XXX_IRQ_ADCDONE,
 			mc13xxx_handler_adcdone, __func__, &adcdone_data);
 	mc13xxx_irq_ack(mc13xxx, MC13XXX_IRQ_ADCDONE);
@@ -671,7 +620,7 @@ static int mc13xxx_add_subdevice_pdata(struct mc13xxx *mc13xxx,
 	if (!cell.name)
 		return -ENOMEM;
 
-	return mfd_add_devices(&mc13xxx->spidev->dev, -1, &cell, 1, NULL, 0);
+	return mfd_add_devices(mc13xxx->dev, -1, &cell, 1, NULL, 0);
 }
 
 static int mc13xxx_add_subdevice(struct mc13xxx *mc13xxx, const char *format)
@@ -682,7 +631,7 @@ static int mc13xxx_add_subdevice(struct mc13xxx *mc13xxx, const char *format)
 #ifdef CONFIG_OF
 static int mc13xxx_probe_flags_dt(struct mc13xxx *mc13xxx)
 {
-	struct device_node *np = mc13xxx->spidev->dev.of_node;
+	struct device_node *np = mc13xxx->dev.of_node;
 
 	if (!np)
 		return -ENODEV;
@@ -708,49 +657,13 @@ static inline int mc13xxx_probe_flags_dt(struct mc13xxx *mc13xxx)
 }
 #endif
 
-static const struct spi_device_id mc13xxx_device_id[] = {
-	{
-		.name = "mc13783",
-		.driver_data = MC13XXX_ID_MC13783,
-	}, {
-		.name = "mc13892",
-		.driver_data = MC13XXX_ID_MC13892,
-	}, {
-		/* sentinel */
-	}
-};
-MODULE_DEVICE_TABLE(spi, mc13xxx_device_id);
-
-static const struct of_device_id mc13xxx_dt_ids[] = {
-	{ .compatible = "fsl,mc13783", .data = (void *) MC13XXX_ID_MC13783, },
-	{ .compatible = "fsl,mc13892", .data = (void *) MC13XXX_ID_MC13892, },
-	{ /* sentinel */ }
-};
-MODULE_DEVICE_TABLE(of, mc13xxx_dt_ids);
-
-static int mc13xxx_probe(struct spi_device *spi)
+int mc13xxx_device_init(struct mc13xxx *mc13xxx)
 {
-	const struct of_device_id *of_id;
-	struct spi_driver *sdrv = to_spi_driver(spi->dev.driver);
-	struct mc13xxx *mc13xxx;
-	struct mc13xxx_platform_data *pdata = dev_get_platdata(&spi->dev);
+	struct mc13xxx_platform_data *pdata = dev_get_platdata(mc13xxx->dev);
 	enum mc13xxx_id id;
 	int ret;
 
-	of_id = of_match_device(mc13xxx_dt_ids, &spi->dev);
-	if (of_id)
-		sdrv->id_table = &mc13xxx_device_id[(enum mc13xxx_id) of_id->data];
-
-	mc13xxx = kzalloc(sizeof(*mc13xxx), GFP_KERNEL);
-	if (!mc13xxx)
-		return -ENOMEM;
-
-	dev_set_drvdata(&spi->dev, mc13xxx);
-	spi->mode = SPI_MODE_0 | SPI_CS_HIGH;
-	spi->bits_per_word = 32;
-	spi_setup(spi);
-
-	mc13xxx->spidev = spi;
+	dev_set_drvdata(mc13xxx->dev, mc13xxx);
 
 	mutex_init(&mc13xxx->lock);
 	mc13xxx_lock(mc13xxx);
@@ -768,14 +681,14 @@ static int mc13xxx_probe(struct spi_device *spi)
 	if (ret)
 		goto err_mask;
 
-	ret = request_threaded_irq(spi->irq, NULL, mc13xxx_irq_thread,
+	ret = request_threaded_irq(mc13xxx->irq, NULL, mc13xxx_irq_thread,
 			IRQF_ONESHOT | IRQF_TRIGGER_HIGH, "mc13xxx", mc13xxx);
 
 	if (ret) {
 err_mask:
 err_revision:
 		mc13xxx_unlock(mc13xxx);
-		dev_set_drvdata(&spi->dev, NULL);
+		dev_set_drvdata(mc13xxx->dev, NULL);
 		kfree(mc13xxx);
 		return ret;
 	}
@@ -813,41 +726,13 @@ err_revision:
 	return 0;
 }
 
-static int __devexit mc13xxx_remove(struct spi_device *spi)
+void mc13xxx_device_exit(struct mc13xxx *mc13xxx)
 {
-	struct mc13xxx *mc13xxx = dev_get_drvdata(&spi->dev);
-
-	free_irq(mc13xxx->spidev->irq, mc13xxx);
-
-	mfd_remove_devices(&spi->dev);
+	free_irq(mc13xxx->irq, mc13xxx);
 
+	mfd_remove_devices(mc13xxx->dev);
 	kfree(mc13xxx);
-
-	return 0;
-}
-
-static struct spi_driver mc13xxx_driver = {
-	.id_table = mc13xxx_device_id,
-	.driver = {
-		.name = "mc13xxx",
-		.owner = THIS_MODULE,
-		.of_match_table = mc13xxx_dt_ids,
-	},
-	.probe = mc13xxx_probe,
-	.remove = __devexit_p(mc13xxx_remove),
-};
-
-static int __init mc13xxx_init(void)
-{
-	return spi_register_driver(&mc13xxx_driver);
-}
-subsys_initcall(mc13xxx_init);
-
-static void __exit mc13xxx_exit(void)
-{
-	spi_unregister_driver(&mc13xxx_driver);
 }
-module_exit(mc13xxx_exit);
 
 MODULE_DESCRIPTION("Core driver for Freescale MC13XXX PMIC");
 MODULE_AUTHOR("Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>");
diff --git a/drivers/mfd/mc13xxx-spi.c b/drivers/mfd/mc13xxx-spi.c
new file mode 100644
index 0000000..37277c1
--- /dev/null
+++ b/drivers/mfd/mc13xxx-spi.c
@@ -0,0 +1,172 @@
+/*
+ * Copyright 2009-2010 Pengutronix
+ * Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>
+ *
+ * loosely based on an earlier driver that has
+ * Copyright 2009 Pengutronix, Sascha Hauer <s.hauer@pengutronix.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/slab.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/mutex.h>
+#include <linux/interrupt.h>
+#include <linux/spi/spi.h>
+#include <linux/mfd/core.h>
+#include <linux/mfd/mc13xxx.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+
+#define MC13XXX_REGOFFSET_SHIFT 25
+static int mc13xxx_spi_read(struct mc13xxx *mc13xxx,
+			unsigned int offset, u32 *val)
+{
+	struct spi_transfer t;
+	struct spi_message m;
+	int ret;
+
+	*val = offset << MC13XXX_REGOFFSET_SHIFT;
+
+	memset(&t, 0, sizeof(t));
+
+	t.tx_buf = val;
+	t.rx_buf = val;
+	t.len = sizeof(u32);
+
+	spi_message_init(&m);
+	spi_message_add_tail(&t, &m);
+
+	ret = spi_sync(mc13xxx->control.spidev, &m);
+
+	/* error in message.status implies error return from spi_sync */
+	BUG_ON(!ret && m.status);
+
+	if (ret)
+		return ret;
+
+	*val &= 0xffffff;
+
+	dev_vdbg(mc13xxx->dev, "[0x%02x] -> 0x%06x\n", offset, *val);
+
+	return 0;
+}
+
+static int mc13xxx_spi_write(struct mc13xxx *mc13xxx,
+			unsigned int offset, u32 val)
+{
+	u32 buf;
+	struct spi_transfer t;
+	struct spi_message m;
+	int ret;
+
+	dev_vdbg(mc13xxx->dev, "[0x%02x] <- 0x%06x\n", offset, val);
+
+	buf = 1 << 31 | offset << MC13XXX_REGOFFSET_SHIFT | val;
+
+	memset(&t, 0, sizeof(t));
+
+	t.tx_buf = &buf;
+	t.rx_buf = &buf;
+	t.len = sizeof(u32);
+
+	spi_message_init(&m);
+	spi_message_add_tail(&t, &m);
+
+	ret = spi_sync(mc13xxx->control.spidev, &m);
+
+	BUG_ON(!ret && m.status);
+
+	return ret;
+}
+
+static const struct spi_device_id mc13xxx_spi_device_id[] = {
+	{
+		.name = "mc13783",
+		.driver_data = MC13XXX_ID_MC13783,
+	}, {
+		.name = "mc13892",
+		.driver_data = MC13XXX_ID_MC13892,
+	}, {
+		/* sentinel */
+	}
+};
+MODULE_DEVICE_TABLE(spi, mc13xxx_spi_device_id);
+
+static const struct of_device_id mc13xxx_dt_ids[] = {
+	{ .compatible = "fsl,mc13783", .data = (void *) MC13XXX_ID_MC13783, },
+	{ .compatible = "fsl,mc13892", .data = (void *) MC13XXX_ID_MC13892, },
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, mc13xxx_dt_ids);
+
+static int mc13xxx_spi_probe(struct spi_device *spi)
+{
+	const struct of_device_id *of_id;
+	struct spi_driver *sdrv = to_spi_driver(spi->dev.driver);
+	struct mc13xxx *mc13xxx;
+	const struct spi_device_id *devid;
+
+	of_id = of_match_device(mc13xxx_dt_ids, &spi->dev);
+	if (of_id)
+		sdrv->id_table =
+			&mc13xxx_spi_device_id[(enum mc13xxx_id) of_id->data];
+
+	mc13xxx = kzalloc(sizeof(*mc13xxx), GFP_KERNEL);
+	if (!mc13xxx)
+		return -ENOMEM;
+
+	mc13xxx->dev = &spi->dev;
+	mc13xxx->control.spidev = spi;
+	mc13xxx->read = mc13xxx_spi_read;
+	mc13xxx->write = mc13xxx_spi_write;
+	mc13xxx->irq = spi->irq;
+
+	spi->mode = SPI_MODE_0 | SPI_CS_HIGH;
+	spi->bits_per_word = 32;
+	spi_setup(spi);
+
+	devid = spi_get_device_id(spi);
+	mc13xxx->driver_data = devid ? &devid->driver_data : NULL;
+
+	return mc13xxx_device_init(mc13xxx);
+}
+
+static int __devexit mc13xxx_spi_remove(struct spi_device *spi)
+{
+	struct mc13xxx *mc13xxx = spi_get_drvdata(spi);
+
+	mc13xxx_device_exit(mc13xxx);
+
+	return 0;
+}
+
+static struct spi_driver mc13xxx_spi_driver = {
+	.id_table = mc13xxx_spi_device_id,
+	.driver = {
+		.name = "mc13xxx",
+		.owner = THIS_MODULE,
+		.of_match_table = mc13xxx_dt_ids,
+	},
+	.probe = mc13xxx_spi_probe,
+	.remove = __devexit_p(mc13xxx_spi_remove),
+};
+
+static int __init mc13xxx_spi_init(void)
+{
+	return spi_register_driver(&mc13xxx_spi_driver);
+}
+subsys_initcall(mc13xxx_spi_init);
+
+static void __exit mc13xxx_spi_exit(void)
+{
+	spi_unregister_driver(&mc13xxx_spi_driver);
+}
+module_exit(mc13xxx_spi_exit);
+
+MODULE_DESCRIPTION("SPI support for Freescale MC13XXX PMIC");
+MODULE_AUTHOR("Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>");
+MODULE_LICENSE("GPL v2");
diff --git a/include/linux/mfd/mc13xxx.h b/include/linux/mfd/mc13xxx.h
index df6654a..9929a8e 100644
--- a/include/linux/mfd/mc13xxx.h
+++ b/include/linux/mfd/mc13xxx.h
@@ -10,6 +10,7 @@
 #define __LINUX_MFD_MC13XXX_H
 
 #include <linux/interrupt.h>
+#include <linux/spi/spi.h>
 
 #define MC13XXX_IRQ_ADCDONE	0
 #define MC13XXX_IRQ_ADCBISDONE	1
@@ -42,15 +43,22 @@ enum mc13xxx_id {
 };
 
 struct mc13xxx {
-	struct spi_device *spidev;
+	struct device *dev;
+	union {
+		struct spi_device *spidev;
+	} control;
 	struct mutex lock;
 	int irq;
 	int flags;
 
+	int (*read)(struct mc13xxx *mc13xxx, unsigned int offset, u32 *val);
+	int (*write)(struct mc13xxx *mc13xxx, unsigned int offset, u32 val);
+
 	irq_handler_t irqhandler[MC13XXX_NUM_IRQ];
 	void *irqdata[MC13XXX_NUM_IRQ];
 
 	int adcflags;
+	const kernel_ulong_t *driver_data;
 };
 
 void mc13xxx_lock(struct mc13xxx *mc13xxx);
@@ -80,6 +88,9 @@ int mc13xxx_get_flags(struct mc13xxx *mc13xxx);
 int mc13xxx_adc_do_conversion(struct mc13xxx *mc13xxx,
 		unsigned int mode, unsigned int channel, unsigned int *sample);
 
+int mc13xxx_device_init(struct mc13xxx *mc13xxx);
+void mc13xxx_device_exit(struct mc13xxx *mc13xxx);
+
 struct regulator_init_data;
 
 struct mc13xxx_regulator_init_data {
-- 
1.7.5.4


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

* [PATCH 3/7] mfd: add I2C handling to mc13xxx driver
  2012-02-14 10:34 [PATCH 0/7] add support for mc13892 I2C based touch panel for mx35_3ds Oskar Schirmer
  2012-02-14 10:34 ` [PATCH 1/7] mfd: move mc13xxx global declarations to header file Oskar Schirmer
  2012-02-14 10:34 ` [PATCH 2/7] mfd: split off mc13xxx SPI specifica from core Oskar Schirmer
@ 2012-02-14 10:34 ` Oskar Schirmer
  2012-02-16 16:40   ` Mark Brown
  2012-02-14 10:34 ` [PATCH 4/7] input/touchscreen: rename mc13783_ts.c Oskar Schirmer
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 12+ messages in thread
From: Oskar Schirmer @ 2012-02-14 10:34 UTC (permalink / raw)
  To: sameo
  Cc: dmitry.torokhov, kernel, u.kleine-koenig, philippe.retornaz,
	michael.thalmeier, linux-kernel, Oskar Schirmer

mc13xxx chips may be wired to SPI or I2C, alternatively.
Up to now, mc13xxx did support SPI wiring solely.
Add support for I2C wiring, make the two alternatives
separate menu option in configuration.

Signed-off-by: Oskar Schirmer <oskar@scara.com>
---
 drivers/mfd/Kconfig         |   11 +++
 drivers/mfd/Makefile        |    1 +
 drivers/mfd/mc13xxx-i2c.c   |  149 +++++++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/mc13xxx.h |    2 +
 4 files changed, 163 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mfd/mc13xxx-i2c.c

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 750b50c..1dd67da 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -576,6 +576,17 @@ config MFD_MC13XXX
 	select MFD_CORE
 	select MFD_MC13783
 
+config MFD_MC13XXX_I2C
+	tristate "Support Freescale MC13783 and MC13892 with I2C"
+	select MFD_MC13XXX
+	depends on I2C && GPIOLIB
+	help
+	  Support for the Freescale (Atlas) PMIC and audio CODECs
+	  MC13783 and MC13892, wired for I2C use.
+	  This driver provides common support for accessing the device,
+	  additional drivers must be enabled in order to use the
+	  functionality of the device.
+
 config MFD_MC13XXX_SPI
 	tristate "Support Freescale MC13783 and MC13892 with SPI"
 	select MFD_MC13XXX
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 2dc66ed..17129e0 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -53,6 +53,7 @@ obj-$(CONFIG_TWL6030_PWM)	+= twl6030-pwm.o
 obj-$(CONFIG_TWL6040_CORE)	+= twl6040-core.o twl6040-irq.o
 
 obj-$(CONFIG_MFD_MC13XXX)	+= mc13xxx-core.o
+obj-$(CONFIG_MFD_MC13XXX_I2C)	+= mc13xxx-i2c.o
 obj-$(CONFIG_MFD_MC13XXX_SPI)	+= mc13xxx-spi.o
 
 obj-$(CONFIG_MFD_CORE)		+= mfd-core.o
diff --git a/drivers/mfd/mc13xxx-i2c.c b/drivers/mfd/mc13xxx-i2c.c
new file mode 100644
index 0000000..b7b16b8
--- /dev/null
+++ b/drivers/mfd/mc13xxx-i2c.c
@@ -0,0 +1,149 @@
+/*
+ * Copyright 2012 Oskar Schirmer <oskar@scara.com>
+ *
+ * loosely based on drivers that have
+ * Copyright 2008-2010 Freescale Semiconductor, Inc.,
+ * Copyright 2009 Pengutronix, Sascha Hauer <s.hauer@pengutronix.de> and
+ * Copyright 2011 Texas Instruments Inc.,
+ *                      Margarita Olaya Cabrera <magi@slimlogic.co.uk>
+ *
+ * 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/slab.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/mutex.h>
+#include <linux/interrupt.h>
+#include <linux/i2c.h>
+#include <linux/mfd/core.h>
+#include <linux/mfd/mc13xxx.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+
+static int mc13xxx_i2c_read(struct mc13xxx *mc13xxx,
+			unsigned int offset, u32 *val)
+{
+	struct i2c_client *i2c = mc13xxx->control.i2cdev;
+	unsigned char buf[3];
+	int ret;
+
+	memset(buf, 0, 3);
+	ret = i2c_smbus_read_i2c_block_data(i2c, offset, 3, buf);
+	if (ret != 3) {
+		dev_dbg(mc13xxx->dev, "24bit read error, ret = %d %s\n",
+				ret, i2c->name);
+		return ret;
+	}
+
+	*val = buf[0] << 16 | buf[1] << 8 | buf[2];
+
+	dev_vdbg(mc13xxx->dev, "[0x%02x] -> 0x%06x\n", offset, *val);
+
+	return 0;
+}
+
+static int mc13xxx_i2c_write(struct mc13xxx *mc13xxx,
+			unsigned int offset, u32 val)
+{
+	struct i2c_client *i2c = mc13xxx->control.i2cdev;
+	unsigned char buf[3];
+	int ret;
+
+	buf[0] = (val >> 16) & 0xff;
+	buf[1] = (val >> 8) & 0xff;
+	buf[2] = val & 0xff;
+
+	ret = i2c_smbus_write_i2c_block_data(i2c, offset, 3, buf);
+	if (ret != 0) {
+		dev_dbg(mc13xxx->dev, "24bit write error, ret = %d %s\n",
+				ret, i2c->name);
+		return ret;
+	}
+
+	return 0;
+}
+
+static const struct i2c_device_id mc13xxx_i2c_device_id[] = {
+	{
+		.name = "mc13783",
+		.driver_data = MC13XXX_ID_MC13783,
+	}, {
+		.name = "mc13892",
+		.driver_data = MC13XXX_ID_MC13892,
+	}, {
+		/* sentinel */
+	}
+};
+MODULE_DEVICE_TABLE(i2c, mc13xxx_i2c_device_id);
+
+static const struct of_device_id mc13xxx_dt_ids[] = {
+	{ .compatible = "fsl,mc13783", .data = (void *) MC13XXX_ID_MC13783, },
+	{ .compatible = "fsl,mc13892", .data = (void *) MC13XXX_ID_MC13892, },
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, mc13xxx_dt_ids);
+
+static int mc13xxx_i2c_probe(struct i2c_client *i2c,
+			const struct i2c_device_id *id)
+{
+	const struct of_device_id *of_id;
+	struct i2c_driver *idrv = to_i2c_driver(i2c->dev.driver);
+	struct mc13xxx *mc13xxx;
+
+	of_id = of_match_device(mc13xxx_dt_ids, &i2c->dev);
+	if (of_id)
+		idrv->id_table =
+			&mc13xxx_i2c_device_id[(enum mc13xxx_id) of_id->data];
+
+	mc13xxx = kzalloc(sizeof(*mc13xxx), GFP_KERNEL);
+	if (!mc13xxx)
+		return -ENOMEM;
+
+	mc13xxx->dev = &i2c->dev;
+	mc13xxx->control.i2cdev = i2c;
+	mc13xxx->read = mc13xxx_i2c_read;
+	mc13xxx->write = mc13xxx_i2c_write;
+	mc13xxx->irq = i2c->irq;
+
+	mc13xxx->driver_data = id ? &id->driver_data : NULL;
+
+	return mc13xxx_device_init(mc13xxx);
+}
+
+static int __devexit mc13xxx_i2c_remove(struct i2c_client *i2c)
+{
+	struct mc13xxx *mc13xxx = i2c_get_clientdata(i2c);
+
+	mc13xxx_device_exit(mc13xxx);
+
+	return 0;
+}
+
+static struct i2c_driver mc13xxx_i2c_driver = {
+	.id_table = mc13xxx_i2c_device_id,
+	.driver = {
+		.name = "mc13xxx",
+		.owner = THIS_MODULE,
+	},
+	.probe = mc13xxx_i2c_probe,
+	.remove = __devexit_p(mc13xxx_i2c_remove),
+};
+
+static int __init mc13xxx_i2c_init(void)
+{
+	return i2c_add_driver(&mc13xxx_i2c_driver);
+}
+subsys_initcall(mc13xxx_i2c_init);
+
+static void __exit mc13xxx_i2c_exit(void)
+{
+	i2c_del_driver(&mc13xxx_i2c_driver);
+}
+module_exit(mc13xxx_i2c_exit);
+
+MODULE_DESCRIPTION("I2C support for Freescale MC13XXX PMIC");
+MODULE_AUTHOR("Oskar Schirmer <oskar@scara.com>");
+MODULE_LICENSE("GPL v2");
diff --git a/include/linux/mfd/mc13xxx.h b/include/linux/mfd/mc13xxx.h
index 9929a8e..31c925f 100644
--- a/include/linux/mfd/mc13xxx.h
+++ b/include/linux/mfd/mc13xxx.h
@@ -9,6 +9,7 @@
 #ifndef __LINUX_MFD_MC13XXX_H
 #define __LINUX_MFD_MC13XXX_H
 
+#include <linux/i2c.h>
 #include <linux/interrupt.h>
 #include <linux/spi/spi.h>
 
@@ -45,6 +46,7 @@ enum mc13xxx_id {
 struct mc13xxx {
 	struct device *dev;
 	union {
+		struct i2c_client *i2cdev;
 		struct spi_device *spidev;
 	} control;
 	struct mutex lock;
-- 
1.7.5.4


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

* [PATCH 4/7] input/touchscreen: rename mc13783_ts.c
  2012-02-14 10:34 [PATCH 0/7] add support for mc13892 I2C based touch panel for mx35_3ds Oskar Schirmer
                   ` (2 preceding siblings ...)
  2012-02-14 10:34 ` [PATCH 3/7] mfd: add I2C handling to mc13xxx driver Oskar Schirmer
@ 2012-02-14 10:34 ` Oskar Schirmer
  2012-02-14 10:34 ` [PATCH 5/7] input/touchscreen: add support for mc13892 Oskar Schirmer
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Oskar Schirmer @ 2012-02-14 10:34 UTC (permalink / raw)
  To: sameo
  Cc: dmitry.torokhov, kernel, u.kleine-koenig, philippe.retornaz,
	michael.thalmeier, linux-kernel, Oskar Schirmer

In preparation to add support for mc13892 touch device,
rename mc13783 touch driver to more generic mc13xxx name.

Signed-off-by: Oskar Schirmer <oskar@scara.com>
---
 drivers/input/touchscreen/Makefile                 |    2 +-
 .../touchscreen/{mc13783_ts.c => mc13xxx_ts.c}     |    0
 2 files changed, 1 insertions(+), 1 deletions(-)
 rename drivers/input/touchscreen/{mc13783_ts.c => mc13xxx_ts.c} (100%)

diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile
index 496091e..07c031b 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -30,7 +30,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_MC13783)	+= 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/mc13xxx_ts.c
similarity index 100%
rename from drivers/input/touchscreen/mc13783_ts.c
rename to drivers/input/touchscreen/mc13xxx_ts.c
-- 
1.7.5.4


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

* [PATCH 5/7] input/touchscreen: add support for mc13892
  2012-02-14 10:34 [PATCH 0/7] add support for mc13892 I2C based touch panel for mx35_3ds Oskar Schirmer
                   ` (3 preceding siblings ...)
  2012-02-14 10:34 ` [PATCH 4/7] input/touchscreen: rename mc13783_ts.c Oskar Schirmer
@ 2012-02-14 10:34 ` Oskar Schirmer
  2012-02-14 10:34 ` [PATCH 6/7] input/touchscreen: add calibration functionality with Oskar Schirmer
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Oskar Schirmer @ 2012-02-14 10:34 UTC (permalink / raw)
  To: sameo
  Cc: dmitry.torokhov, kernel, u.kleine-koenig, philippe.retornaz,
	michael.thalmeier, linux-kernel, Oskar Schirmer

Current driver mc13xxx_ts.c does provide support for
mc13783 chip, only. Add support for similar mc13892 chip,
rename a bunch of identifiers to reflect multichip support.

Signed-off-by: Oskar Schirmer <oskar@scara.com>
---
 drivers/input/touchscreen/Kconfig      |   10 +-
 drivers/input/touchscreen/Makefile     |    2 +-
 drivers/input/touchscreen/mc13xxx_ts.c |  166 +++++++++++++++++++++++++-------
 3 files changed, 137 insertions(+), 41 deletions(-)

diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index 4af2a18..51d19cb 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -584,17 +584,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 MC13XXX 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 MC13XXX 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 07c031b..2c3afda 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -30,7 +30,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)	+= mc13xxx_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/mc13xxx_ts.c b/drivers/input/touchscreen/mc13xxx_ts.c
index ede0274..802228e 100644
--- a/drivers/input/touchscreen/mc13xxx_ts.c
+++ b/drivers/input/touchscreen/mc13xxx_ts.c
@@ -1,5 +1,5 @@
 /*
- * Driver for the Freescale Semiconductor MC13783 touchscreen.
+ * Driver for the Freescale Semiconductor MC13xxx touchscreen.
  *
  * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved.
  * Copyright (C) 2009 Sascha Hauer, Pengutronix
@@ -12,7 +12,7 @@
  * the Free Software Foundation.
  */
 #include <linux/platform_device.h>
-#include <linux/mfd/mc13783.h>
+#include <linux/mfd/mc13xxx.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/input.h>
@@ -20,7 +20,7 @@
 #include <linux/slab.h>
 #include <linux/init.h>
 
-#define MC13783_TS_NAME	"mc13783-ts"
+#define DRIVER_NAME	"mc13xxx-ts"
 
 #define DEFAULT_SAMPLE_TOLERANCE 300
 
@@ -33,7 +33,16 @@ MODULE_PARM_DESC(sample_tolerance,
 		"is supposed to be wrong and is discarded.  Set to 0 to "
 		"disable this check.");
 
-struct mc13783_ts_priv {
+#define DEFAULT_PRESSURE_LIMIT 2048
+
+static unsigned int pressure_limit = DEFAULT_PRESSURE_LIMIT;
+module_param(pressure_limit, uint, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(pressure_limit,
+		"Pressure values below this value (default: "
+		__stringify(DEFAULT_PRESSURE_LIMIT) ") are taken "
+		"as release event.");
+
+struct mc13xxx_ts_priv {
 	struct input_dev *idev;
 	struct mc13xxx *mc13xxx;
 	struct delayed_work work;
@@ -41,9 +50,9 @@ struct mc13783_ts_priv {
 	unsigned int sample[4];
 };
 
-static irqreturn_t mc13783_ts_handler(int irq, void *data)
+static irqreturn_t mc13xxx_ts_handler(int irq, void *data)
 {
-	struct mc13783_ts_priv *priv = data;
+	struct mc13xxx_ts_priv *priv = data;
 
 	mc13xxx_irq_ack(priv->mc13xxx, irq);
 
@@ -67,7 +76,7 @@ static irqreturn_t mc13783_ts_handler(int irq, void *data)
 			swap(a0, a1);					\
 		})
 
-static void mc13783_ts_report_sample(struct mc13783_ts_priv *priv)
+static void mc13783_ts_report_sample(struct mc13xxx_ts_priv *priv)
 {
 	struct input_dev *idev = priv->idev;
 	int x0, x1, x2, y0, y1, y2;
@@ -117,10 +126,63 @@ static void mc13783_ts_report_sample(struct mc13783_ts_priv *priv)
 		dev_dbg(&idev->dev, "discard event\n");
 }
 
+static void mc13892_ts_report_sample(struct mc13xxx_ts_priv *priv)
+{
+	struct input_dev *idev = priv->idev;
+	int x0, x1, y0, y1;
+	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;
+	y0 = priv->sample[3] & 0xfff;
+	y1 = (priv->sample[0] >> 12) & 0xfff;
+	cr0 = (priv->sample[2] >> 12) & 0xfff;
+	cr1 = (priv->sample[3] >> 12) & 0xfff;
+
+	dev_dbg(&idev->dev,
+		"x: (% 4d,% 4d) y: (% 4d,% 4d) cr: (% 4d, % 4d)\n",
+		x0, x1, y0, y1, cr0, cr1);
+
+	if (x0 > x1)
+		swap(x0, x1);
+	if (y0 > y1)
+		swap(y0, y1);
+
+	cr0 = 0x1000 - ((cr0 + cr1) / 2);
+	if (cr0 < pressure_limit)
+		cr0 = 0;
+
+	if (!cr0 || !sample_tolerance ||
+			(x1 - x0 < sample_tolerance &&
+			 y1 - y0 < sample_tolerance)) {
+		/* report the average coordinate and pressure */
+		if (cr0) {
+			x0 = (x0 + x1) / 2;
+			y0 = (y0 + y1) / 2;
+			input_report_abs(idev, ABS_X, x0);
+			input_report_abs(idev, ABS_Y, y0);
+
+			dev_dbg(&idev->dev, "report (%d, %d, %d)\n",
+					x0, y0, 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);
+		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);
+	struct mc13xxx_ts_priv *priv =
+		container_of(work, struct mc13xxx_ts_priv, work.work);
 	unsigned int mode = MC13XXX_ADC_MODE_TS;
 	unsigned int channel = 12;
 
@@ -129,9 +191,21 @@ static void mc13783_ts_work(struct work_struct *work)
 		mc13783_ts_report_sample(priv);
 }
 
-static int mc13783_ts_open(struct input_dev *dev)
+static void mc13892_ts_work(struct work_struct *work)
+{
+	struct mc13xxx_ts_priv *priv =
+		container_of(work, struct mc13xxx_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)
+		mc13892_ts_report_sample(priv);
+}
+
+static int mc13xxx_ts_open(struct input_dev *dev)
 {
-	struct mc13783_ts_priv *priv = input_get_drvdata(dev);
+	struct mc13xxx_ts_priv *priv = input_get_drvdata(dev);
 	int ret;
 
 	mc13xxx_lock(priv->mc13xxx);
@@ -139,7 +213,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);
+		mc13xxx_ts_handler, DRIVER_NAME, priv);
 	if (ret)
 		goto out;
 
@@ -152,9 +226,9 @@ out:
 	return ret;
 }
 
-static void mc13783_ts_close(struct input_dev *dev)
+static void mc13xxx_ts_close(struct input_dev *dev)
 {
-	struct mc13783_ts_priv *priv = input_get_drvdata(dev);
+	struct mc13xxx_ts_priv *priv = input_get_drvdata(dev);
 
 	mc13xxx_lock(priv->mc13xxx);
 	mc13xxx_reg_rmw(priv->mc13xxx, MC13XXX_ADC0,
@@ -165,9 +239,9 @@ static void mc13783_ts_close(struct input_dev *dev)
 	cancel_delayed_work_sync(&priv->work);
 }
 
-static int __init mc13783_ts_probe(struct platform_device *pdev)
+static int __init mc13xxx_ts_probe(struct platform_device *pdev)
 {
-	struct mc13783_ts_priv *priv;
+	struct mc13xxx_ts_priv *priv;
 	struct input_dev *idev;
 	int ret = -ENOMEM;
 
@@ -176,19 +250,29 @@ static int __init mc13783_ts_probe(struct platform_device *pdev)
 	if (!priv || !idev)
 		goto err_free_mem;
 
-	INIT_DELAYED_WORK(&priv->work, mc13783_ts_work);
+	switch (platform_get_device_id(pdev)->driver_data) {
+	case MC13XXX_ID_MC13783:
+		INIT_DELAYED_WORK(&priv->work, mc13783_ts_work);
+		break;
+	case MC13XXX_ID_MC13892:
+		INIT_DELAYED_WORK(&priv->work, mc13892_ts_work);
+		break;
+	default:
+		goto err_free_mem;
+	}
+
 	priv->mc13xxx = dev_get_drvdata(pdev->dev.parent);
 	priv->idev = idev;
 
 	/*
-	 * We need separate workqueue because mc13783_adc_do_conversion
+	 * We need separate workqueue because mc13xxx_adc_do_conversion
 	 * uses keventd and thus would deadlock.
 	 */
-	priv->workq = create_singlethread_workqueue("mc13783_ts");
+	priv->workq = create_singlethread_workqueue("mc13xxx_ts");
 	if (!priv->workq)
 		goto err_free_mem;
 
-	idev->name = MC13783_TS_NAME;
+	idev->name = DRIVER_NAME;
 	idev->dev.parent = &pdev->dev;
 
 	idev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
@@ -197,8 +281,8 @@ static int __init mc13783_ts_probe(struct platform_device *pdev)
 	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;
+	idev->open = mc13xxx_ts_open;
+	idev->close = mc13xxx_ts_close;
 
 	input_set_drvdata(idev, priv);
 
@@ -220,9 +304,9 @@ err_free_mem:
 	return ret;
 }
 
-static int __devexit mc13783_ts_remove(struct platform_device *pdev)
+static int __devexit mc13xxx_ts_remove(struct platform_device *pdev)
 {
-	struct mc13783_ts_priv *priv = platform_get_drvdata(pdev);
+	struct mc13xxx_ts_priv *priv = platform_get_drvdata(pdev);
 
 	platform_set_drvdata(pdev, NULL);
 
@@ -233,27 +317,39 @@ static int __devexit mc13783_ts_remove(struct platform_device *pdev)
 	return 0;
 }
 
-static struct platform_driver mc13783_ts_driver = {
-	.remove		= __devexit_p(mc13783_ts_remove),
+const struct platform_device_id mc13xxx_ts_idtable[] = {
+	{
+		.name = "mc13783-ts",
+		.driver_data = MC13XXX_ID_MC13783,
+	}, {
+		.name = "mc13892-ts",
+		.driver_data = MC13XXX_ID_MC13892,
+	},
+	{ }
+};
+
+static struct platform_driver mc13xxx_ts_driver = {
+	.id_table	= mc13xxx_ts_idtable,
+	.remove		= __devexit_p(mc13xxx_ts_remove),
 	.driver		= {
+		.name	= DRIVER_NAME,
 		.owner	= THIS_MODULE,
-		.name	= MC13783_TS_NAME,
 	},
 };
 
-static int __init mc13783_ts_init(void)
+static int __init mc13xxx_ts_init(void)
 {
-	return platform_driver_probe(&mc13783_ts_driver, &mc13783_ts_probe);
+	return platform_driver_probe(&mc13xxx_ts_driver, &mc13xxx_ts_probe);
 }
-module_init(mc13783_ts_init);
+module_init(mc13xxx_ts_init);
 
-static void __exit mc13783_ts_exit(void)
+static void __exit mc13xxx_ts_exit(void)
 {
-	platform_driver_unregister(&mc13783_ts_driver);
+	platform_driver_unregister(&mc13xxx_ts_driver);
 }
-module_exit(mc13783_ts_exit);
+module_exit(mc13xxx_ts_exit);
 
-MODULE_DESCRIPTION("MC13783 input touchscreen driver");
+MODULE_DESCRIPTION("MC13xxx input touchscreen driver");
 MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>");
 MODULE_LICENSE("GPL v2");
-MODULE_ALIAS("platform:" MC13783_TS_NAME);
+MODULE_ALIAS("platform:" DRIVER_NAME MC13XXX_TS_NAME);
-- 
1.7.5.4


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

* [PATCH 6/7] input/touchscreen: add calibration functionality with
  2012-02-14 10:34 [PATCH 0/7] add support for mc13892 I2C based touch panel for mx35_3ds Oskar Schirmer
                   ` (4 preceding siblings ...)
  2012-02-14 10:34 ` [PATCH 5/7] input/touchscreen: add support for mc13892 Oskar Schirmer
@ 2012-02-14 10:34 ` Oskar Schirmer
  2012-02-14 10:34 ` [PATCH 7/7] arm/imx: add mc13892 I2C based touch panel support for Oskar Schirmer
  2012-02-14 11:49 ` [PATCH 0/7] add support for mc13892 I2C based touch panel for mx35_3ds Uwe Kleine-König
  7 siblings, 0 replies; 12+ messages in thread
From: Oskar Schirmer @ 2012-02-14 10:34 UTC (permalink / raw)
  To: sameo
  Cc: dmitry.torokhov, kernel, u.kleine-koenig, philippe.retornaz,
	michael.thalmeier, linux-kernel, Oskar Schirmer

Currently mc13xxx_ts does provide uncalibrated data only.
Add means to calibrate touchscreen through simple matrix calculus,
parameters accessible via sysfs.

Signed-off-by: Oskar Schirmer <oskar@scara.com>
---
 drivers/input/touchscreen/Kconfig      |    1 +
 drivers/input/touchscreen/mc13xxx_ts.c |   87 +++++++++++++++++++++++++++++---
 2 files changed, 81 insertions(+), 7 deletions(-)

diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index 51d19cb..9e315d7 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -587,6 +587,7 @@ config TOUCHSCREEN_USB_COMPOSITE
 config TOUCHSCREEN_MC13XXX
 	tristate "Freescale MC13XXX touchscreen input driver"
 	depends on MFD_MC13XXX
+	select SYSFS
 	help
 	  Say Y here if you have an Freescale MC13XXX PMIC on your
 	  board and want to use its touchscreen
diff --git a/drivers/input/touchscreen/mc13xxx_ts.c b/drivers/input/touchscreen/mc13xxx_ts.c
index 802228e..02f61a7 100644
--- a/drivers/input/touchscreen/mc13xxx_ts.c
+++ b/drivers/input/touchscreen/mc13xxx_ts.c
@@ -48,6 +48,7 @@ struct mc13xxx_ts_priv {
 	struct delayed_work work;
 	struct workqueue_struct *workq;
 	unsigned int sample[4];
+	int calibration[7];
 };
 
 static irqreturn_t mc13xxx_ts_handler(int irq, void *data)
@@ -76,6 +77,26 @@ static irqreturn_t mc13xxx_ts_handler(int irq, void *data)
 			swap(a0, a1);					\
 		})
 
+static void mc13xxx_report_abs_calibrated(struct mc13xxx_ts_priv *priv,
+			struct input_dev *idev, int x, int y)
+{
+	int *calib = priv->calibration;
+	int xc, yc;
+	if (calib[6]) {
+		xc = (calib[0] * x + calib[1] * y + calib[2]) / calib[6];
+		if (xc < 0)
+			xc = 0;
+		yc = (calib[3] * x + calib[4] * y + calib[5]) / calib[6];
+		if (yc < 0)
+			yc = 0;
+	} else {
+		xc = x;
+		yc = y;
+	}
+	input_report_abs(idev, ABS_X, xc);
+	input_report_abs(idev, ABS_Y, yc);
+}
+
 static void mc13783_ts_report_sample(struct mc13xxx_ts_priv *priv)
 {
 	struct input_dev *idev = priv->idev;
@@ -109,9 +130,7 @@ static void mc13783_ts_report_sample(struct mc13xxx_ts_priv *priv)
 			 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);
-
+			mc13xxx_report_abs_calibrated(priv, idev, x1, y1);
 			dev_dbg(&idev->dev, "report (%d, %d, %d)\n",
 					x1, y1, 0x1000 - cr0);
 			queue_delayed_work(priv->workq, &priv->work, HZ / 50);
@@ -163,9 +182,7 @@ static void mc13892_ts_report_sample(struct mc13xxx_ts_priv *priv)
 		if (cr0) {
 			x0 = (x0 + x1) / 2;
 			y0 = (y0 + y1) / 2;
-			input_report_abs(idev, ABS_X, x0);
-			input_report_abs(idev, ABS_Y, y0);
-
+			mc13xxx_report_abs_calibrated(priv, idev, x0, y0);
 			dev_dbg(&idev->dev, "report (%d, %d, %d)\n",
 					x0, y0, cr0);
 			queue_delayed_work(priv->workq, &priv->work, HZ / 50);
@@ -239,6 +256,53 @@ static void mc13xxx_ts_close(struct input_dev *dev)
 	cancel_delayed_work_sync(&priv->work);
 }
 
+static ssize_t mc13xxx_calibration_show(struct device *d,
+		struct device_attribute *attr, char *buf)
+{
+	struct mc13xxx_ts_priv *priv = dev_get_drvdata(d);
+	int i, p, r;
+
+	p = 0;
+	for (i = 0; i < 7; i++) {
+		r = sprintf(&buf[p], i == 6 ? "%d\n" : "%d ",
+				priv->calibration[i]);
+		if (r < 0)
+			return r;
+		p += r;
+	}
+	return p;
+}
+
+static ssize_t mc13xxx_calibration_store(struct device *d,
+		struct device_attribute *attr, const char *buf, size_t count)
+{
+	struct mc13xxx_ts_priv *priv = dev_get_drvdata(d);
+	int i, p, r;
+	int c[7];
+
+	p = 0;
+	for (i = 0; i < 7; i++) {
+		if (sscanf(&buf[p], "%d%n", &c[i], &r) != 1)
+			return -EINVAL;
+		p += r;
+	}
+	memcpy(priv->calibration, c, sizeof(priv->calibration));
+	return count;
+}
+
+static DEVICE_ATTR(calibration, S_IWUSR | S_IRUGO,
+		mc13xxx_calibration_show, mc13xxx_calibration_store);
+
+static int mc13xxx_init_sysfs(struct device *d)
+{
+	return device_create_file(d, &dev_attr_calibration);
+}
+
+static void mc13xxx_free_sysfs(struct device *d)
+{
+	device_remove_file(d, &dev_attr_calibration);
+}
+
 static int __init mc13xxx_ts_probe(struct platform_device *pdev)
 {
 	struct mc13xxx_ts_priv *priv;
@@ -286,16 +350,24 @@ static int __init mc13xxx_ts_probe(struct platform_device *pdev)
 
 	input_set_drvdata(idev, priv);
 
+	ret = mc13xxx_init_sysfs(&pdev->dev);
+	if (ret) {
+		dev_err(&pdev->dev, "failed to init sysfs.\n");
+		goto err_destroy_wq;
+	}
+
 	ret = input_register_device(priv->idev);
 	if (ret) {
 		dev_err(&pdev->dev,
 			"register input device failed with %d\n", ret);
-		goto err_destroy_wq;
+		goto err_free_sysfs;
 	}
 
 	platform_set_drvdata(pdev, priv);
 	return 0;
 
+err_free_sysfs:
+	mc13xxx_free_sysfs(&pdev->dev);
 err_destroy_wq:
 	destroy_workqueue(priv->workq);
 err_free_mem:
@@ -310,6 +382,7 @@ static int __devexit mc13xxx_ts_remove(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, NULL);
 
+	mc13xxx_free_sysfs(&pdev->dev);
 	destroy_workqueue(priv->workq);
 	input_unregister_device(priv->idev);
 	kfree(priv);
-- 
1.7.5.4


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

* [PATCH 7/7] arm/imx: add mc13892 I2C based touch panel support for
  2012-02-14 10:34 [PATCH 0/7] add support for mc13892 I2C based touch panel for mx35_3ds Oskar Schirmer
                   ` (5 preceding siblings ...)
  2012-02-14 10:34 ` [PATCH 6/7] input/touchscreen: add calibration functionality with Oskar Schirmer
@ 2012-02-14 10:34 ` Oskar Schirmer
  2012-02-14 11:49 ` [PATCH 0/7] add support for mc13892 I2C based touch panel for mx35_3ds Uwe Kleine-König
  7 siblings, 0 replies; 12+ messages in thread
From: Oskar Schirmer @ 2012-02-14 10:34 UTC (permalink / raw)
  To: sameo
  Cc: dmitry.torokhov, kernel, u.kleine-koenig, philippe.retornaz,
	michael.thalmeier, linux-kernel, Oskar Schirmer

MX35_3DS development board comes with optional touch screen
driven by I2C wired mc13892. Set up platform specific declarations.

Signed-off-by: Oskar Schirmer <oskar@scara.com>
---
 arch/arm/mach-imx/mach-mx35_3ds.c |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-imx/mach-mx35_3ds.c b/arch/arm/mach-imx/mach-mx35_3ds.c
index 0af6c9c..c65b815 100644
--- a/arch/arm/mach-imx/mach-mx35_3ds.c
+++ b/arch/arm/mach-imx/mach-mx35_3ds.c
@@ -41,9 +41,13 @@
 #include <mach/irqs.h>
 #include <mach/3ds_debugboard.h>
 
+#include <linux/i2c.h>
+#include <linux/mfd/mc13xxx.h>
+
 #include "devices-imx35.h"
 
 #define EXPIO_PARENT_INT	gpio_to_irq(IMX_GPIO_NR(1, 1))
+#define GPIO_PMIC_INT		IMX_GPIO_NR(2, 0)
 
 static const struct imxuart_platform_data uart_pdata __initconst = {
 	.flags = IMXUART_HAVE_RTSCTS,
@@ -117,6 +121,8 @@ static iomux_v3_cfg_t mx35pdk_pads[] = {
 	MX35_PAD_SD1_DATA1__ESDHC1_DAT1,
 	MX35_PAD_SD1_DATA2__ESDHC1_DAT2,
 	MX35_PAD_SD1_DATA3__ESDHC1_DAT3,
+	/* PMIC */
+	MX35_PAD_GPIO2_0__GPIO2_0,
 	/* I2C1 */
 	MX35_PAD_I2C1_CLK__I2C1_SCL,
 	MX35_PAD_I2C1_DAT__I2C1_SDA,
@@ -174,6 +180,18 @@ static const struct imxi2c_platform_data mx35_3ds_i2c0_data __initconst = {
 	.bitrate = 100000,
 };
 
+static struct mc13xxx_platform_data mx35_3ds_pmic = {
+	.flags = MC13XXX_USE_TOUCHSCREEN,
+};
+
+static struct i2c_board_info mx35_3ds_i2c_devices[] = {
+	{
+		I2C_BOARD_INFO("mc13892", 0x08),
+		.platform_data = &mx35_3ds_pmic,
+		.irq = IMX_GPIO_TO_IRQ(GPIO_PMIC_INT),
+	}
+};
+
 /*
  * Board specific initialization.
  */
@@ -187,6 +205,12 @@ static void __init mx35_3ds_init(void)
 	imx35_add_imx2_wdt(NULL);
 	platform_add_devices(devices, ARRAY_SIZE(devices));
 
+	if (0 != gpio_request(GPIO_PMIC_INT, "PMIC_INT"))
+		printk(KERN_WARNING "PMIC_INT: Couldn't get gpio (%d)\n",
+			GPIO_PMIC_INT);
+	else
+		gpio_direction_input(GPIO_PMIC_INT);
+
 	imx35_add_imx_uart0(&uart_pdata);
 
 	if (otg_mode_host)
@@ -203,6 +227,9 @@ static void __init mx35_3ds_init(void)
 	if (mxc_expio_init(MX35_CS5_BASE_ADDR, EXPIO_PARENT_INT))
 		pr_warn("Init of the debugboard failed, all "
 				"devices on the debugboard are unusable.\n");
+
+	i2c_register_board_info(0, mx35_3ds_i2c_devices,
+			ARRAY_SIZE(mx35_3ds_i2c_devices));
 	imx35_add_imx_i2c0(&mx35_3ds_i2c0_data);
 }
 
-- 
1.7.5.4


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

* Re: [PATCH 0/7] add support for mc13892 I2C based touch panel for mx35_3ds
  2012-02-14 10:34 [PATCH 0/7] add support for mc13892 I2C based touch panel for mx35_3ds Oskar Schirmer
                   ` (6 preceding siblings ...)
  2012-02-14 10:34 ` [PATCH 7/7] arm/imx: add mc13892 I2C based touch panel support for Oskar Schirmer
@ 2012-02-14 11:49 ` Uwe Kleine-König
  2012-02-14 14:27   ` Oskar Schirmer
  2012-02-23 15:37   ` Samuel Ortiz
  7 siblings, 2 replies; 12+ messages in thread
From: Uwe Kleine-König @ 2012-02-14 11:49 UTC (permalink / raw)
  To: Oskar Schirmer
  Cc: sameo, dmitry.torokhov, kernel, philippe.retornaz,
	michael.thalmeier, linux-kernel

Hello,

I didn't check your series, but are you aware of the series available at

	http://thread.gmane.org/gmane.linux.drivers.i2c/9872

?

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

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

* Re: [PATCH 0/7] add support for mc13892 I2C based touch panel for mx35_3ds
  2012-02-14 11:49 ` [PATCH 0/7] add support for mc13892 I2C based touch panel for mx35_3ds Uwe Kleine-König
@ 2012-02-14 14:27   ` Oskar Schirmer
  2012-02-23 15:37   ` Samuel Ortiz
  1 sibling, 0 replies; 12+ messages in thread
From: Oskar Schirmer @ 2012-02-14 14:27 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Oskar Schirmer, sameo, dmitry.torokhov, kernel,
	philippe.retornaz, michael.thalmeier, linux-kernel, marc

Hello Uwe, Marc,

Uwe just pointed me to Your mc13xxx i2c patch series,
when I posted mine this morning, http://lkml.org/lkml/2012/2/14/98

On Tue, Feb 14, 2012 at 12:49:49 +0100, Uwe Kleine-König wrote:
> I didn't check your series, but are you aware of the series available at
> 
> 	http://thread.gmane.org/gmane.linux.drivers.i2c/9872
> 
> ?

No, I didn't see that one, thanks for the hint.

  Oskar

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

* Re: [PATCH 3/7] mfd: add I2C handling to mc13xxx driver
  2012-02-14 10:34 ` [PATCH 3/7] mfd: add I2C handling to mc13xxx driver Oskar Schirmer
@ 2012-02-16 16:40   ` Mark Brown
  0 siblings, 0 replies; 12+ messages in thread
From: Mark Brown @ 2012-02-16 16:40 UTC (permalink / raw)
  To: Oskar Schirmer
  Cc: sameo, dmitry.torokhov, kernel, u.kleine-koenig,
	philippe.retornaz, michael.thalmeier, linux-kernel

On Tue, Feb 14, 2012 at 10:34:28AM +0000, Oskar Schirmer wrote:
> mc13xxx chips may be wired to SPI or I2C, alternatively.
> Up to now, mc13xxx did support SPI wiring solely.
> Add support for I2C wiring, make the two alternatives
> separate menu option in configuration.

As with the last time you posted this it really would be better to
convert this to regmap rather than add new open coded register map I/O
support.

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

* Re: [PATCH 0/7] add support for mc13892 I2C based touch panel for mx35_3ds
  2012-02-14 11:49 ` [PATCH 0/7] add support for mc13892 I2C based touch panel for mx35_3ds Uwe Kleine-König
  2012-02-14 14:27   ` Oskar Schirmer
@ 2012-02-23 15:37   ` Samuel Ortiz
  1 sibling, 0 replies; 12+ messages in thread
From: Samuel Ortiz @ 2012-02-23 15:37 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Oskar Schirmer, dmitry.torokhov, kernel, philippe.retornaz,
	michael.thalmeier, linux-kernel

Hi Uwe, Oskar,

On Tue, Feb 14, 2012 at 12:49:49PM +0100, Uwe Kleine-König wrote:
> Hello,
> 
> I didn't check your series, but are you aware of the series available at
> 
> 	http://thread.gmane.org/gmane.linux.drivers.i2c/9872
FYI this has not been merged. I'm waiting for Marc to address the many
comments triggered by his patchset.

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/

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

end of thread, other threads:[~2012-02-23 15:37 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-14 10:34 [PATCH 0/7] add support for mc13892 I2C based touch panel for mx35_3ds Oskar Schirmer
2012-02-14 10:34 ` [PATCH 1/7] mfd: move mc13xxx global declarations to header file Oskar Schirmer
2012-02-14 10:34 ` [PATCH 2/7] mfd: split off mc13xxx SPI specifica from core Oskar Schirmer
2012-02-14 10:34 ` [PATCH 3/7] mfd: add I2C handling to mc13xxx driver Oskar Schirmer
2012-02-16 16:40   ` Mark Brown
2012-02-14 10:34 ` [PATCH 4/7] input/touchscreen: rename mc13783_ts.c Oskar Schirmer
2012-02-14 10:34 ` [PATCH 5/7] input/touchscreen: add support for mc13892 Oskar Schirmer
2012-02-14 10:34 ` [PATCH 6/7] input/touchscreen: add calibration functionality with Oskar Schirmer
2012-02-14 10:34 ` [PATCH 7/7] arm/imx: add mc13892 I2C based touch panel support for Oskar Schirmer
2012-02-14 11:49 ` [PATCH 0/7] add support for mc13892 I2C based touch panel for mx35_3ds Uwe Kleine-König
2012-02-14 14:27   ` Oskar Schirmer
2012-02-23 15:37   ` Samuel Ortiz

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).