Skip to contentSkip to conversation

add support for mc13892 I2C based touch panel for mx35_3ds

PATCH In review Oskar Schirmer 4 participants 12 messages Feb 14, 2012 – Feb 23, 2012

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover add support for mc13892 I2C based touch panel for mx35_3ds

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
Signature · 1 line
1.7.5.4
#1 lore raw

PATCH 1/7 mfd: move mc13xxx global declarations to header file

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

---
 drivers/mfd/mc13xxx-core.c  |   18 -----------
 include/linux/mfd/mc13xxx.h |   66 ++++++++++++++++++++++++++----------------
 2 files changed, 41 insertions(+), 43 deletions(-)
drivers/mfd/mc13xxx-core.c +0 -18
index 7122386..94840c1 100644
@@ -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",
include/linux/mfd/mc13xxx.h +41 -25

78 lines not on this page · raw message

Signature · 1 line
1.7.5.4
#2 lore raw

PATCH 2/7 mfd: split off mc13xxx SPI specifica from core

In reply to 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.

---
 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
drivers/mfd/Kconfig +8 -4
index f147395..750b50c 100644
@@ -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.
 
drivers/mfd/Makefile +1 -0
index b953bab..2dc66ed 100644
@@ -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
 
drivers/mfd/mc13xxx-core.c +25 -140

296 lines not on this page · raw message

drivers/mfd/mc13xxx-spi.c new file +172 -0

172 lines not on this page · raw message

include/linux/mfd/mc13xxx.h +12 -1
index df6654a..9929a8e 100644
@@ -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 {
Signature · 1 line
1.7.5.4
#3 lore raw

PATCH 3/7 mfd: add I2C handling to mc13xxx driver

In reply to 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.

---
 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
drivers/mfd/Kconfig +11 -0
index 750b50c..1dd67da 100644
@@ -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
drivers/mfd/Makefile +1 -0
index 2dc66ed..17129e0 100644
@@ -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
drivers/mfd/mc13xxx-i2c.c new file +149 -0

149 lines not on this page · raw message

include/linux/mfd/mc13xxx.h +2 -0
index 9929a8e..31c925f 100644
@@ -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;
Signature · 1 line
1.7.5.4
#4 lore raw

Re: [PATCH 3/7] mfd: add I2C handling to mc13xxx driver

Quoted 4 lines · 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.

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.

#5 lore raw

PATCH 4/7 input/touchscreen: rename mc13783_ts.c

In reply to Oskar Schirmer

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

---
 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%)
drivers/input/touchscreen/Makefile +1 -1
index 496091e..07c031b 100644
@@ -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
drivers/input/touchscreen/mc13xxx_ts.c renamed from drivers/input/touchscreen/mc13783_ts.c +0 -0
similarity index 100%
rename from drivers/input/touchscreen/mc13783_ts.c
rename to drivers/input/touchscreen/mc13xxx_ts.c
Signature · 1 line
1.7.5.4
#6 lore raw

PATCH 5/7 input/touchscreen: add support for mc13892

In reply to 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.

---
 drivers/input/touchscreen/Kconfig      |   10 +-
 drivers/input/touchscreen/Makefile     |    2 +-
 drivers/input/touchscreen/mc13xxx_ts.c |  166 +++++++++++++++++++++++++-------
 3 files changed, 137 insertions(+), 41 deletions(-)
drivers/input/touchscreen/Kconfig +5 -5
index 4af2a18..51d19cb 100644
@@ -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
drivers/input/touchscreen/Makefile +1 -1
index 07c031b..2c3afda 100644
@@ -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
drivers/input/touchscreen/mc13xxx_ts.c +131 -35

280 lines not on this page · raw message

Signature · 1 line
1.7.5.4
#7 lore raw

PATCH 6/7 input/touchscreen: add calibration functionality with

In reply to Oskar Schirmer

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

---
 drivers/input/touchscreen/Kconfig      |    1 +
 drivers/input/touchscreen/mc13xxx_ts.c |   87 +++++++++++++++++++++++++++++---
 2 files changed, 81 insertions(+), 7 deletions(-)
drivers/input/touchscreen/Kconfig +1 -0
index 51d19cb..9e315d7 100644
@@ -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
drivers/input/touchscreen/mc13xxx_ts.c +80 -7

138 lines not on this page · raw message

Signature · 1 line
1.7.5.4
#8 lore raw

PATCH 7/7 arm/imx: add mc13892 I2C based touch panel support for

In reply to Oskar Schirmer

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

---
 arch/arm/mach-imx/mach-mx35_3ds.c |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)
arch/arm/mach-imx/mach-mx35_3ds.c +27 -0
index 0af6c9c..c65b815 100644
@@ -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);
 }
 
Signature · 1 line
1.7.5.4