All of lore.kernel.org
 help / color / mirror / Atom feed
* TSC2101/2102
@ 2007-03-09 14:06 Imre Deak
  2007-03-09 14:23 ` TSC2101/2102 andrzej zaborowski
  0 siblings, 1 reply; 35+ messages in thread
From: Imre Deak @ 2007-03-09 14:06 UTC (permalink / raw)
  To: balrog, Nishanth Menon; +Cc: Linux OMAP ML

Hi,

I'm wondering about the proper way to convert the existing omap-tsc2101
driver to the SPI framework. Would it make sense to handle it with the
tsc2102 driver? omap-tsc2101 has only the register read / write interface
which is the same as in tsc2102.

Are you planning to do this? I'd need to access the tsc2101 from another
driver.

--Imre

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

* Re: TSC2101/2102
  2007-03-09 14:06 TSC2101/2102 Imre Deak
@ 2007-03-09 14:23 ` andrzej zaborowski
  2007-03-14 13:21   ` TSC2101/2102 Nishanth Menon
  0 siblings, 1 reply; 35+ messages in thread
From: andrzej zaborowski @ 2007-03-09 14:23 UTC (permalink / raw)
  To: Imre Deak; +Cc: Linux OMAP ML, Nishanth Menon

Hiya,

On 09/03/07, Imre Deak <imre.deak@solidboot.com> wrote:
> I'm wondering about the proper way to convert the existing omap-tsc2101
> driver to the SPI framework. Would it make sense to handle it with the
> tsc2102 driver? omap-tsc2101 has only the register read / write interface
> which is the same as in tsc2102.

How about maybe a header file <linux/spi/tsc2xxx.h> shared between
tsc2101/2102 with the register access functions as "static inline"
functions?

Regards,
Andrew

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

* Re: TSC2101/2102
  2007-03-09 14:23 ` TSC2101/2102 andrzej zaborowski
@ 2007-03-14 13:21   ` Nishanth Menon
  2007-03-14 17:09     ` TSC2101/2102 Imre Deak
  0 siblings, 1 reply; 35+ messages in thread
From: Nishanth Menon @ 2007-03-14 13:21 UTC (permalink / raw)
  To: balrogg; +Cc: Linux OMAP ML

andrzej zaborowski stated on 3/9/2007 8:23 AM:
> On 09/03/07, Imre Deak <imre.deak@solidboot.com> wrote:
>> I'm wondering about the proper way to convert the existing omap-tsc2101
>> driver to the SPI framework. Would it make sense to handle it with the
>> tsc2102 driver? omap-tsc2101 has only the register read / write
>> interface
>> which is the same as in tsc2102.
>
> How about maybe a header file <linux/spi/tsc2xxx.h> shared between
> tsc2101/2102 with the register access functions as "static inline"
> functions?
Some TODOs:
1. should interrupt muxing be done here?
2. There are some TSC2005 devices(TS only).. so it will be interesting
to see xxxx.h scales to all..
3. rename this to tsc2xxx_core.[ch]
4. use SPI framework (would not break uwire support I believe).
Regards,
Nishanth Menon

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

* Re: TSC2101/2102
  2007-03-14 13:21   ` TSC2101/2102 Nishanth Menon
@ 2007-03-14 17:09     ` Imre Deak
  2007-03-14 20:35       ` TSC2101/2102 Dirk Behme
                         ` (2 more replies)
  0 siblings, 3 replies; 35+ messages in thread
From: Imre Deak @ 2007-03-14 17:09 UTC (permalink / raw)
  To: Nishanth Menon; +Cc: Linux OMAP ML

[-- Attachment #1: Type: text/plain, Size: 1124 bytes --]

On Wed, Mar 14, 2007 at 08:21:24AM -0500, Nishanth Menon wrote:
> andrzej zaborowski stated on 3/9/2007 8:23 AM:
> > On 09/03/07, Imre Deak <imre.deak@solidboot.com> wrote:
> >> I'm wondering about the proper way to convert the existing omap-tsc2101
> >> driver to the SPI framework. Would it make sense to handle it with the
> >> tsc2102 driver? omap-tsc2101 has only the register read / write
> >> interface
> >> which is the same as in tsc2102.
> >
> > How about maybe a header file <linux/spi/tsc2xxx.h> shared between
> > tsc2101/2102 with the register access functions as "static inline"
> > functions?
> Some TODOs:
> 1. should interrupt muxing be done here?
> 2. There are some TSC2005 devices(TS only).. so it will be interesting
> to see xxxx.h scales to all..
> 3. rename this to tsc2xxx_core.[ch]
> 4. use SPI framework (would not break uwire support I believe).

The attached patches try to do #4. Please review it / sign it off as
necessary.

There is an upcoming TSC2301 patch, that should also be taken
into account when creating a tsc2xxx-core.[ch] based on the existing
TSC driver implementations.

--Imre

[-- Attachment #2: 0001-TSC2101-convert-existing-driver-to-use-the-SPI-framework.patch --]
[-- Type: text/plain, Size: 10455 bytes --]

>From 3ac516c27d9d8facf1ac925e1444984849208678 Mon Sep 17 00:00:00 2001
From: Imre Deak <imre.deak@solidboot.com>
Date: Wed, 14 Mar 2007 18:57:44 +0200
Subject: [PATCH] TSC2101: convert existing driver to use the SPI framework

The new driver is functionally the same as the old
drivers/ssi/omap-tsc2101 driver.

Signed-off-by: Imre Deak <imre.deak@solidboot.com>
---
 drivers/spi/Kconfig         |    8 +
 drivers/spi/Makefile        |    1 +
 drivers/spi/tsc2101.c       |  316 +++++++++++++++++++++++++++++++++++++++++++
 include/linux/spi/tsc2101.h |   43 ++++++
 4 files changed, 368 insertions(+), 0 deletions(-)
 create mode 100644 drivers/spi/tsc2101.c
 create mode 100644 include/linux/spi/tsc2101.h

diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index bde6231..e9b871f 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -149,6 +149,14 @@ config SPI_OMAP24XX
 comment "SPI Protocol Masters"
 	depends on SPI_MASTER
 
+config TSC2101
+	depends on SPI_MASTER
+	tristate "TSC2101 chip support"
+	---help---
+	  Say Y here if you want support for the TSC2101 chip.
+	  At the moment it provides basic register read / write interface
+	  as well as a way to enable the MCLK clock.
+
 config TSC2102
 	depends on SPI_MASTER
 	tristate "TSC2102 codec support"
diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile
index 6d84bac..822121a 100644
--- a/drivers/spi/Makefile
+++ b/drivers/spi/Makefile
@@ -24,6 +24,7 @@ obj-$(CONFIG_SPI_OMAP_UWIRE)		+= omap_uwire.o
 # 	... add above this line ...
 
 # SPI protocol drivers (device/link on bus)
+obj-$(CONFIG_TSC2101)			+= tsc2101.o
 obj-$(CONFIG_TSC2102)			+= tsc2102.o
 obj-$(CONFIG_SPI_AT25)		+= at25.o
 # 	... add above this line ...
diff --git a/drivers/spi/tsc2101.c b/drivers/spi/tsc2101.c
new file mode 100644
index 0000000..258d856
--- /dev/null
+++ b/drivers/spi/tsc2101.c
@@ -0,0 +1,316 @@
+/*
+ * linux/drivers/spi/tsc2101.c
+ *
+ * TSC2101 codec interface driver for the OMAP platform
+ *
+ * Copyright (C) 2004 Texas Instruments, Inc.
+ *
+ * This package 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.
+ *
+ * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * History:
+ *
+ * 2004/11/07   Nishanth Menon - Modified for common hooks for Audio and Touchscreen
+ */
+
+#include <linux/kernel.h>
+#include <linux/clk.h>
+#include <linux/device.h>
+#include <linux/spi/spi.h>
+#include <linux/spi/tsc2101.h>
+
+struct tsc2101_device {
+	struct mutex		mutex;
+	int			mclk_enabled;
+	struct clock		*mclk_ck;
+	struct spi_message	message;
+	struct spi_transfer	transfer[2];
+	u16			command;
+	void			(*enable_mclk)(struct spi_device *spi);
+	void			(*disable_mclk)(struct spi_device *spi);
+};
+
+int tsc2101_enable_mclk(struct spi_device *spi)
+{
+	struct tsc2101_device *tsc2101;
+
+	tsc2101 = spi_get_drvdata(spi);
+
+	mutex_lock(&tsc2101->mutex);
+
+	if (spi->dev.power.power_state.event != PM_EVENT_ON) {
+		mutex_unlock(&tsc2101->mutex);
+		return -ENODEV;
+	}
+
+	if (tsc2101->mclk_enabled++ == 0) {
+		if (tsc2101->enable_mclk != NULL)
+			tsc2101->enable_mclk(spi);
+	}
+
+	mutex_unlock(&tsc2101->mutex);
+	return 0;
+}
+EXPORT_SYMBOL(tsc2101_enable_mclk);
+
+void tsc2101_disable_mclk(struct spi_device *spi)
+{
+	struct tsc2101_device *tsc2101;
+
+	tsc2101 = spi_get_drvdata(spi);
+
+	mutex_lock(&tsc2101->mutex);
+
+	if (--tsc2101->mclk_enabled == 0) {
+		if (tsc2101->disable_mclk != NULL &&
+		    spi->dev.power.power_state.event == PM_EVENT_ON)
+			tsc2101->disable_mclk(spi);
+	}
+
+	mutex_lock(&tsc2101->mutex);
+}
+EXPORT_SYMBOL(tsc2101_disable_mclk);
+
+int tsc2101_write_sync(struct spi_device *spi, int page, u8 address, u16 data)
+{
+	struct tsc2101_device *tsc2101;
+	struct spi_message *m;
+	struct spi_transfer *t;
+	int ret;
+
+	tsc2101 = spi_get_drvdata(spi);
+
+	mutex_lock(&tsc2101->mutex);
+	if (spi->dev.power.power_state.event != PM_EVENT_ON) {
+		mutex_unlock(&tsc2101->mutex);
+		return -ENODEV;
+	}
+
+	m = &tsc2101->message;
+	spi_message_init(m);
+	t = &tsc2101->transfer[0];
+	memset(t, 0, sizeof(tsc2101->transfer));
+
+	/* Address */
+	tsc2101->command = (page << 11) | (address << 5);
+	t->tx_buf = &tsc2101->command;
+	t->len = 2;
+	spi_message_add_tail(t, m);
+
+	/* Data */
+	t++;
+	t->tx_buf = &data;
+	t->len = 2;
+	spi_message_add_tail(t, m);
+
+	ret = spi_sync(spi, m);
+	if (!ret)
+		ret = tsc2101->message.status;
+	mutex_unlock(&tsc2101->mutex);
+
+	return ret;
+}
+EXPORT_SYMBOL(tsc2101_write_sync);
+
+int tsc2101_reads_sync(struct spi_device *spi,
+		       int page, u8 startaddress, u16 *data, int numregs)
+{
+	struct tsc2101_device *tsc2101;
+	struct spi_message *m;
+	struct spi_transfer *t;
+	int ret;
+
+	tsc2101 = spi_get_drvdata(spi);
+
+	mutex_lock(&tsc2101->mutex);
+	if (spi->dev.power.power_state.event != PM_EVENT_ON) {
+		mutex_unlock(&tsc2101->mutex);
+		return -ENODEV;
+	}
+
+	m = &tsc2101->message;
+	spi_message_init(m);
+	t = &tsc2101->transfer[0];
+	memset(t, 0, sizeof(tsc2101->transfer));
+
+	/* Address */
+	tsc2101->command = 0x8000 | (page << 11) | (startaddress << 5);
+	t->tx_buf = &tsc2101->command;
+	t->len = 2;
+	spi_message_add_tail(t, m);
+
+	/* Data */
+	t++;
+	t->rx_buf = data;
+	t->len = numregs << 1;
+	spi_message_add_tail(t, m);
+
+	ret = spi_sync(spi, m);
+	if (!ret)
+		ret = tsc2101->message.status;
+
+	mutex_unlock(&tsc2101->mutex);
+
+	return ret;
+}
+EXPORT_SYMBOL(tsc2101_reads_sync);
+
+int tsc2101_read_sync(struct spi_device *spi, int page, u8 address)
+{
+	int err;
+	u16 val;
+
+	err = tsc2101_reads_sync(spi, page, address, &val, 1);
+	if (err)
+		return err;
+	return val;
+}
+EXPORT_SYMBOL(tsc2101_read_sync);
+
+static int tsc2101_suspend(struct spi_device *spi, pm_message_t state)
+{
+	struct tsc2101_device *tsc2101;
+
+	tsc2101 = spi_get_drvdata(spi);
+
+	if (tsc2101 == NULL)
+		return 0;
+
+	mutex_lock(&tsc2101->mutex);
+
+	spi->dev.power.power_state = state;
+	if (tsc2101->mclk_enabled && tsc2101->disable_mclk != NULL)
+		tsc2101->disable_mclk(spi);
+
+	mutex_unlock(&tsc2101->mutex);
+
+	return 0;
+}
+
+static int tsc2101_resume(struct spi_device *spi)
+{
+	struct tsc2101_device *tsc2101;
+
+	tsc2101 = spi_get_drvdata(spi);
+
+	if (tsc2101 == NULL)
+		return 0;
+
+	mutex_lock(&tsc2101->mutex);
+
+	spi->dev.power.power_state = PMSG_ON;
+	if (tsc2101->mclk_enabled && tsc2101->enable_mclk != NULL)
+		tsc2101->enable_mclk(spi);
+
+	mutex_unlock(&tsc2101->mutex);
+
+	return 0;
+}
+
+static int tsc2101_probe(struct spi_device *spi)
+{
+	struct tsc2101_platform_data *pdata;
+	struct tsc2101_device *tsc2101;
+	u16 w;
+	int r;
+
+	pdata = spi->dev.platform_data;
+	if (pdata == NULL) {
+		dev_err(&spi->dev, "no platform data\n");
+		return -ENODEV;
+	}
+
+	tsc2101 = kzalloc(sizeof(*tsc2101), GFP_KERNEL);
+	if (tsc2101 == NULL) {
+		dev_err(&spi->dev, "out of mem\n");
+		return -ENOMEM;
+	}
+
+	spi_set_drvdata(spi, tsc2101);
+	tsc2101->enable_mclk = pdata->enable_mclk;
+	tsc2101->disable_mclk = pdata->disable_mclk;
+
+	mutex_init(&tsc2101->mutex);
+
+	spi->mode = SPI_MODE_0;
+	spi->bits_per_word = 16;
+	if ((r = spi_setup(spi)) < 0) {
+		dev_err(&spi->dev, "SPI setup failed\n");
+		goto err;
+	}
+
+	w = tsc2101_read_sync(spi, 1, 0);
+	if (!(w & (1 << 14))) {
+		dev_err(&spi->dev, "invalid ADC register value %04x\n", w);
+		goto err;
+	}
+
+	if (pdata->init != NULL) {
+		if ((r = pdata->init(spi)) < 0) {
+			dev_err(&spi->dev, "platform init failed\n");
+			goto err;
+		}
+	}
+
+	dev_info(&spi->dev, "initialized\n");
+
+	return 0;
+err:
+	kfree(tsc2101);
+	return r;
+}
+
+static int tsc2101_remove(struct spi_device *spi)
+{
+	struct tsc2101_platform_data *pdata;
+	struct tsc2101_device *tsc2101;
+
+	pdata = spi->dev.platform_data;
+	tsc2101 = spi_get_drvdata(spi);
+
+	/* We assume that this can't race with the rest of the driver. */
+	if (tsc2101->mclk_enabled && tsc2101->disable_mclk != NULL)
+		tsc2101->disable_mclk(spi);
+
+	if (pdata->cleanup != NULL)
+		pdata->cleanup(spi);
+
+	spi_set_drvdata(spi, NULL);
+	kfree(tsc2101);
+
+	return 0;
+}
+
+static struct spi_driver tsc2101_driver = {
+	.probe		= tsc2101_probe,
+	.remove		= tsc2101_remove,
+	.suspend	= tsc2101_suspend,
+	.resume		= tsc2101_resume,
+	.driver		= {
+		.name	= "tsc2101",
+		.owner	= THIS_MODULE,
+	},
+};
+
+static int tsc2101_init(void)
+{
+	return spi_register_driver(&tsc2101_driver);
+}
+
+static void tsc2101_exit(void)
+{
+	spi_unregister_driver(&tsc2101_driver);
+}
+
+module_init(tsc2101_init);
+module_exit(tsc2101_exit);
+
+MODULE_AUTHOR("Texas Instruments");
+MODULE_DESCRIPTION
+    ("Glue audio driver for the TI OMAP1610/OMAP1710 TSC2101 codec.");
+MODULE_LICENSE("GPL");
diff --git a/include/linux/spi/tsc2101.h b/include/linux/spi/tsc2101.h
new file mode 100644
index 0000000..01e6d23
--- /dev/null
+++ b/include/linux/spi/tsc2101.h
@@ -0,0 +1,43 @@
+/*
+ * include/linux/spi/tsc2101.h
+ *
+ * TSC2101 codec interface driver for the OMAP platform
+ *
+ * Copyright (C) 2004 Texas Instruments, Inc.
+ *
+ * This package 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.
+ *
+ * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * History:
+ *
+ * 2004/11/07   Nishanth Menon - Provided common hooks for Audio and Touchscreen
+ */
+
+#ifndef __OMAP_TSC2101_H
+#define __OMAP_TSC2101_H
+
+#include <linux/spi/spi.h>
+
+struct tsc2101_platform_data {
+	int	(*init)(struct spi_device *spi);
+	void	(*cleanup)(struct spi_device *spi);
+	void	(*enable_mclk)(struct spi_device *spi);
+	void	(*disable_mclk)(struct spi_device *spi);
+};
+
+extern int tsc2101_read_sync(struct spi_device *spi, int page, u8 address);
+extern int tsc2101_reads_sync(struct spi_device *spi, int page,
+			       u8 startaddress, u16 * data, int numregs);
+extern int tsc2101_write_sync(struct spi_device *spi, int page, u8 address,
+			       u16 data);
+
+extern int tsc2101_enable_mclk(struct spi_device *spi);
+extern void tsc2101_disable_mclk(struct spi_device *spi);
+
+#endif
+
-- 
1.5.0.rc3


[-- Attachment #3: 0002-ARM-OMAP-TSC2101-add-platform-init-registration-to-board-files.patch --]
[-- Type: text/plain, Size: 6101 bytes --]

>From 9c10561f8acef67715e635842bd06e189607c5d2 Mon Sep 17 00:00:00 2001
From: Imre Deak <imre.deak@solidboot.com>
Date: Wed, 14 Mar 2007 17:52:42 +0200
Subject: [PATCH] ARM: OMAP: TSC2101: add platform init / registration to board files

H2 / H3 boards use this chip, update their board files.

Signed-off-by: Imre Deak <imre.deak@solidboot.com>
---
 arch/arm/mach-omap1/board-h2.c |   77 +++++++++++++++++++++++++++++++++++
 arch/arm/mach-omap1/board-h3.c |   88 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 165 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap1/board-h2.c b/arch/arm/mach-omap1/board-h2.c
index f1a824e..bf8511f 100644
--- a/arch/arm/mach-omap1/board-h2.c
+++ b/arch/arm/mach-omap1/board-h2.c
@@ -28,6 +28,9 @@
 #include <linux/mtd/partitions.h>
 #include <linux/input.h>
 #include <linux/workqueue.h>
+#include <linux/spi/spi.h>
+#include <linux/spi/tsc2101.h>
+#include <linux/clk.h>
 
 #include <asm/hardware.h>
 #include <asm/mach-types.h>
@@ -294,6 +297,78 @@ static struct platform_device h2_lcd_device = {
 	.id		= -1,
 };
 
+struct {
+	struct clk	*mclk;
+	int		initialized;
+} h2_tsc2101;
+
+#define TSC2101_MUX_MCLK_ON	R10_1610_MCLK_ON
+#define TSC2101_MUX_MCLK_OFF	R10_1610_MCLK_OFF
+
+static int h2_tsc2101_init(struct spi_device *spi)
+{
+	int r;
+
+	if (h2_tsc2101.initialized) {
+		printk(KERN_ERR "tsc2101: already initialized\n");
+		return -ENODEV;
+	}
+
+	/* Get the MCLK */
+	h2_tsc2101.mclk = clk_get(&spi->dev, "mclk");
+	if (IS_ERR(h2_tsc2101.mclk)) {
+		dev_err(&spi->dev, "unable to get the clock MCLK\n");
+		return PTR_ERR(h2_tsc2101.mclk);
+	}
+	if ((r = clk_set_rate(h2_tsc2101.mclk, 12000000)) < 0) {
+		dev_err(&spi->dev, "unable to set rate to the MCLK\n");
+		goto err;
+	}
+
+	omap_cfg_reg(TSC2101_MUX_MCLK_OFF);
+	omap_cfg_reg(N15_1610_UWIRE_CS1);
+
+	return 0;
+err:
+	clk_put(h2_tsc2101.mclk);
+	return r;
+}
+
+static void h2_tsc2101_cleanup(struct spi_device *spi)
+{
+	clk_put(h2_tsc2101.mclk);
+	omap_cfg_reg(TSC2101_MUX_MCLK_OFF);
+}
+
+static void h2_tsc2101_enable_mclk(struct spi_device *spi)
+{
+	omap_cfg_reg(TSC2101_MUX_MCLK_ON);
+	clk_enable(h2_tsc2101.mclk);
+}
+
+static void h2_tsc2101_disable_mclk(struct spi_device *spi)
+{
+	clk_disable(h2_tsc2101.mclk);
+	omap_cfg_reg(R10_1610_MCLK_OFF);
+}
+
+static struct tsc2101_platform_data h2_tsc2101_platform_data = {
+	.init		= h2_tsc2101_init,
+	.cleanup	= h2_tsc2101_cleanup,
+	.enable_mclk	= h2_tsc2101_enable_mclk,
+	.disable_mclk	= h2_tsc2101_disable_mclk,
+};
+
+static struct spi_board_info h2_spi_board_info[] __initdata = {
+	[0] = {
+		.modalias	= "tsc2101",
+		.bus_num	= 2,
+		.chip_select	= 1,
+		.max_speed_hz	= 16000000,
+		.platform_data	= &h2_tsc2101_platform_data,
+	},
+};
+
 static struct omap_mcbsp_reg_cfg mcbsp_regs = {
 	.spcr2 = FREE | FRST | GRST | XRST | XINTM(3),
 	.spcr1 = RINTM(3) | RRST,
@@ -438,6 +513,8 @@ static void __init h2_init(void)
 #endif
 
 	platform_add_devices(h2_devices, ARRAY_SIZE(h2_devices));
+	spi_register_board_info(h2_spi_board_info,
+				ARRAY_SIZE(h2_spi_board_info));
 	omap_board_config = h2_config;
 	omap_board_config_size = ARRAY_SIZE(h2_config);
 	omap_serial_init();
diff --git a/arch/arm/mach-omap1/board-h3.c b/arch/arm/mach-omap1/board-h3.c
index 4167f34..5ff9037 100644
--- a/arch/arm/mach-omap1/board-h3.c
+++ b/arch/arm/mach-omap1/board-h3.c
@@ -25,6 +25,9 @@
 #include <linux/mtd/nand.h>
 #include <linux/mtd/partitions.h>
 #include <linux/input.h>
+#include <linux/clk.h>
+#include <linux/spi/spi.h>
+#include <linux/spi/tsc2101.h>
 
 #include <asm/setup.h>
 #include <asm/page.h>
@@ -371,6 +374,89 @@ static struct platform_device h3_lcd_device = {
 	.id		= -1,
 };
 
+struct {
+	struct clk	*mclk;
+	int		initialized;
+} h3_tsc2101;
+
+#define TSC2101_MUX_MCLK_ON	V5_1710_MCLK_ON
+#define TSC2101_MUX_MCLK_OFF	V5_1710_MCLK_OFF
+
+static int h3_tsc2101_init(struct spi_device *spi)
+{
+	u8 io_exp_val;
+	int r;
+
+	if (h3_tsc2101.initialized) {
+		printk(KERN_ERR "tsc2101: already initialized\n");
+		return -ENODEV;
+	}
+
+	/* Get the MCLK */
+	h3_tsc2101.mclk = clk_get(&spi->dev, "mclk");
+	if (IS_ERR(h3_tsc2101.mclk)) {
+		dev_err(&spi->dev, "unable to get the clock MCLK\n");
+		return PTR_ERR(h3_tsc2101.mclk);
+	}
+	if ((r = clk_set_rate(h3_tsc2101.mclk, 12000000)) < 0) {
+		dev_err(&spi->dev, "unable to set rate to the MCLK\n");
+		goto err;
+	}
+
+	if ((r = read_gpio_expa(&io_exp_val, 0x24))) {
+		dev_err(&spi->dev, "error reading from I/O EXPANDER\n");
+		goto err;
+	}
+	io_exp_val |= 0x8;
+	if ((r = write_gpio_expa(io_exp_val, 0x24))) {
+		dev_err(&spi->dev, "error writing to I/O EXPANDER\n");
+		goto err;
+	}
+
+	omap_cfg_reg(N14_1610_UWIRE_CS0);
+	omap_cfg_reg(TSC2101_MUX_MCLK_OFF);
+
+	return 0;
+err:
+	clk_put(h3_tsc2101.mclk);
+	return r;
+}
+
+static void h3_tsc2101_cleanup(struct spi_device *spi)
+{
+	clk_put(h3_tsc2101.mclk);
+	omap_cfg_reg(TSC2101_MUX_MCLK_OFF);
+}
+
+static void h3_tsc2101_enable_mclk(struct spi_device *spi)
+{
+	omap_cfg_reg(TSC2101_MUX_MCLK_ON);
+	clk_enable(h3_tsc2101.mclk);
+}
+
+static void h3_tsc2101_disable_mclk(struct spi_device *spi)
+{
+	clk_disable(h3_tsc2101.mclk);
+	omap_cfg_reg(R10_1610_MCLK_OFF);
+}
+
+static struct tsc2101_platform_data h3_tsc2101_platform_data = {
+	.init		= h3_tsc2101_init,
+	.cleanup	= h3_tsc2101_cleanup,
+	.enable_mclk	= h3_tsc2101_enable_mclk,
+	.disable_mclk	= h3_tsc2101_disable_mclk,
+};
+
+static struct spi_board_info h3_spi_board_info[] __initdata = {
+	[0] = {
+		.modalias	= "tsc2101",
+		.bus_num	= 2,
+		.chip_select	= 0,
+		.max_speed_hz	= 16000000,
+		.platform_data	= &h3_tsc2101_platform_data,
+	},
+};
+
 static struct omap_mcbsp_reg_cfg mcbsp_regs = {
 	.spcr2 = FREE | FRST | GRST | XRST | XINTM(3),
 	.spcr1 = RINTM(3) | RRST,
@@ -484,6 +570,8 @@ static void __init h3_init(void)
 	omap_cfg_reg(V2_1710_GPIO10);
 
 	platform_add_devices(devices, ARRAY_SIZE(devices));
+	spi_register_board_info(h3_spi_board_info,
+				ARRAY_SIZE(h3_spi_board_info));
 	omap_board_config = h3_config;
 	omap_board_config_size = ARRAY_SIZE(h3_config);
 	omap_serial_init();
-- 
1.5.0.rc3


[-- Attachment #4: 0003-ARM-OMAP-update-H2-H3-defconfig.patch --]
[-- Type: text/plain, Size: 33766 bytes --]

>From 6c5d62dc669071afb2f4a7e8d1514c13ddc8a7b9 Mon Sep 17 00:00:00 2001
From: Imre Deak <imre.deak@solidboot.com>
Date: Wed, 14 Mar 2007 18:06:26 +0200
Subject: [PATCH] ARM: OMAP: update H2 / H3 defconfig

Enable the new TSC2101 driver.

Signed-off-by: Imre Deak <imre.deak@solidboot.com>
---
 arch/arm/configs/omap_h2_1610_defconfig |   86 +++++--
 arch/arm/configs/omap_h3_1710_defconfig |  410 +++++++++++++++++++++++--------
 2 files changed, 372 insertions(+), 124 deletions(-)

diff --git a/arch/arm/configs/omap_h2_1610_defconfig b/arch/arm/configs/omap_h2_1610_defconfig
index 65be6fb..7c246b9 100644
--- a/arch/arm/configs/omap_h2_1610_defconfig
+++ b/arch/arm/configs/omap_h2_1610_defconfig
@@ -1,11 +1,14 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.20-rc3-omap1
-# Thu Jan  4 16:07:28 2007
+# Linux kernel version: 2.6.21-rc3-omap1
+# Wed Mar 14 18:03:53 2007
 #
 CONFIG_ARM=y
+CONFIG_SYS_SUPPORTS_APM_EMULATION=y
+CONFIG_GENERIC_GPIO=y
 # CONFIG_GENERIC_TIME is not set
 CONFIG_MMU=y
+# CONFIG_NO_IOPORT is not set
 CONFIG_GENERIC_HARDIRQS=y
 CONFIG_TRACE_IRQFLAGS_SUPPORT=y
 CONFIG_HARDIRQS_SW_RESEND=y
@@ -15,6 +18,7 @@ CONFIG_RWSEM_GENERIC_SPINLOCK=y
 # CONFIG_ARCH_HAS_ILOG2_U64 is not set
 CONFIG_GENERIC_HWEIGHT=y
 CONFIG_GENERIC_CALIBRATE_DELAY=y
+CONFIG_ZONE_DMA=y
 CONFIG_VECTORS_BASE=0xffff0000
 CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
 
@@ -33,6 +37,7 @@ CONFIG_LOCALVERSION_AUTO=y
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 # CONFIG_IPC_NS is not set
+CONFIG_SYSVIPC_SYSCTL=y
 # CONFIG_POSIX_MQUEUE is not set
 # CONFIG_BSD_PROCESS_ACCT is not set
 # CONFIG_TASKSTATS is not set
@@ -41,6 +46,7 @@ CONFIG_SYSVIPC=y
 # CONFIG_IKCONFIG is not set
 CONFIG_SYSFS_DEPRECATED=y
 # CONFIG_RELAY is not set
+CONFIG_BLK_DEV_INITRD=y
 CONFIG_INITRAMFS_SOURCE=""
 CONFIG_CC_OPTIMIZE_FOR_SIZE=y
 CONFIG_SYSCTL=y
@@ -120,6 +126,7 @@ CONFIG_DEFAULT_IOSCHED="anticipatory"
 # CONFIG_ARCH_IXP2000 is not set
 # CONFIG_ARCH_IXP23XX is not set
 # CONFIG_ARCH_L7200 is not set
+# CONFIG_ARCH_NS9XXX is not set
 # CONFIG_ARCH_PNX4008 is not set
 # CONFIG_ARCH_PXA is not set
 # CONFIG_ARCH_RPC is not set
@@ -149,6 +156,8 @@ CONFIG_OMAP_MUX_DEBUG=y
 CONFIG_OMAP_MUX_WARNINGS=y
 # CONFIG_OMAP_STI is not set
 CONFIG_OMAP_MCBSP=y
+# CONFIG_OMAP_MMU_FWK is not set
+# CONFIG_OMAP_MBOX_FWK is not set
 CONFIG_OMAP_MPU_TIMER=y
 # CONFIG_OMAP_32K_TIMER is not set
 # CONFIG_OMAP_DM_TIMER is not set
@@ -207,6 +216,7 @@ CONFIG_ARM_THUMB=y
 # CONFIG_CPU_DCACHE_DISABLE is not set
 # CONFIG_CPU_DCACHE_WRITETHROUGH is not set
 # CONFIG_CPU_CACHE_ROUND_ROBIN is not set
+# CONFIG_OUTER_CACHE is not set
 
 #
 # Bus support
@@ -234,6 +244,7 @@ CONFIG_FLAT_NODE_MEM_MAP=y
 # CONFIG_SPARSEMEM_STATIC is not set
 CONFIG_SPLIT_PTLOCK_CPUS=4096
 # CONFIG_RESOURCES_64BIT is not set
+CONFIG_ZONE_DMA_FLAG=1
 CONFIG_LEDS=y
 # CONFIG_LEDS_TIMER is not set
 # CONFIG_LEDS_CPU is not set
@@ -246,6 +257,7 @@ CONFIG_ZBOOT_ROM_TEXT=0x0
 CONFIG_ZBOOT_ROM_BSS=0x0
 CONFIG_CMDLINE="mem=32M console=ttyS0,115200n8 root=/dev/ram0 rw initrd=0x10600000,8M ramdisk_size=8192"
 # CONFIG_XIP_KERNEL is not set
+# CONFIG_KEXEC is not set
 
 #
 # CPU Frequency scaling
@@ -279,7 +291,7 @@ CONFIG_PM=y
 # CONFIG_PM_LEGACY is not set
 # CONFIG_PM_DEBUG is not set
 # CONFIG_PM_SYSFS_DEPRECATED is not set
-# CONFIG_APM is not set
+# CONFIG_APM_EMULATION is not set
 
 #
 # Networking
@@ -296,6 +308,7 @@ CONFIG_UNIX=y
 CONFIG_XFRM=y
 # CONFIG_XFRM_USER is not set
 # CONFIG_XFRM_SUB_POLICY is not set
+# CONFIG_XFRM_MIGRATE is not set
 # CONFIG_NET_KEY is not set
 CONFIG_INET=y
 # CONFIG_IP_MULTICAST is not set
@@ -380,6 +393,7 @@ CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
 # CONFIG_FW_LOADER is not set
 CONFIG_DEBUG_DRIVER=y
+# CONFIG_DEBUG_DEVRES is not set
 # CONFIG_SYS_HYPERVISOR is not set
 
 #
@@ -403,6 +417,7 @@ CONFIG_MTD_CMDLINE_PARTS=y
 # User Modules And Translation Layers
 #
 CONFIG_MTD_CHAR=y
+CONFIG_MTD_BLKDEVS=y
 CONFIG_MTD_BLOCK=y
 # CONFIG_FTL is not set
 # CONFIG_NFTL is not set
@@ -448,6 +463,8 @@ CONFIG_MTD_CFI_UTIL=y
 #
 # Self-contained MTD device drivers
 #
+# CONFIG_MTD_DATAFLASH is not set
+# CONFIG_MTD_M25P80 is not set
 # CONFIG_MTD_SLRAM is not set
 # CONFIG_MTD_PHRAM is not set
 # CONFIG_MTD_MTDRAM is not set
@@ -478,6 +495,7 @@ CONFIG_MTD_CFI_UTIL=y
 #
 # Plug and Play support
 #
+# CONFIG_PNPACPI is not set
 
 #
 # Block devices
@@ -491,7 +509,6 @@ CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_COUNT=16
 CONFIG_BLK_DEV_RAM_SIZE=8192
 CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
-CONFIG_BLK_DEV_INITRD=y
 # CONFIG_CDROM_PKTCDVD is not set
 # CONFIG_ATA_OVER_ETH is not set
 
@@ -677,7 +694,6 @@ CONFIG_WATCHDOG_NOWAYOUT=y
 # CONFIG_USBPCWATCHDOG is not set
 CONFIG_HW_RANDOM=m
 CONFIG_HW_RANDOM_OMAP=m
-# CONFIG_OMAP_RNG is not set
 # CONFIG_NVRAM is not set
 CONFIG_OMAP_RTC=y
 # CONFIG_DTLK is not set
@@ -733,8 +749,22 @@ CONFIG_TPS65010=y
 #
 # SPI support
 #
-# CONFIG_SPI is not set
-# CONFIG_SPI_MASTER is not set
+CONFIG_SPI=y
+# CONFIG_SPI_DEBUG is not set
+CONFIG_SPI_MASTER=y
+
+#
+# SPI Master Controller Drivers
+#
+CONFIG_SPI_BITBANG=y
+CONFIG_SPI_OMAP_UWIRE=y
+
+#
+# SPI Protocol Masters
+#
+CONFIG_TSC2101=y
+# CONFIG_TSC2102 is not set
+# CONFIG_SPI_AT25 is not set
 
 #
 # Dallas's 1-wire bus
@@ -750,6 +780,7 @@ CONFIG_HWMON=y
 # CONFIG_SENSORS_ADM1021 is not set
 # CONFIG_SENSORS_ADM1025 is not set
 # CONFIG_SENSORS_ADM1026 is not set
+# CONFIG_SENSORS_ADM1029 is not set
 # CONFIG_SENSORS_ADM1031 is not set
 # CONFIG_SENSORS_ADM9240 is not set
 # CONFIG_SENSORS_ASB100 is not set
@@ -762,6 +793,7 @@ CONFIG_HWMON=y
 # CONFIG_SENSORS_GL520SM is not set
 # CONFIG_SENSORS_IT87 is not set
 # CONFIG_SENSORS_LM63 is not set
+# CONFIG_SENSORS_LM70 is not set
 # CONFIG_SENSORS_LM75 is not set
 # CONFIG_SENSORS_LM77 is not set
 # CONFIG_SENSORS_LM78 is not set
@@ -790,7 +822,11 @@ CONFIG_HWMON=y
 #
 # Misc devices
 #
-# CONFIG_TIFM_CORE is not set
+
+#
+# Multifunction device drivers
+#
+# CONFIG_MFD_SM501 is not set
 
 #
 # LED devices
@@ -819,23 +855,30 @@ CONFIG_HWMON=y
 #
 # Graphics support
 #
-CONFIG_FIRMWARE_EDID=y
+# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
 CONFIG_FB=y
+CONFIG_FIRMWARE_EDID=y
+# CONFIG_FB_DDC is not set
 # CONFIG_FB_CFB_FILLRECT is not set
 # CONFIG_FB_CFB_COPYAREA is not set
 # CONFIG_FB_CFB_IMAGEBLIT is not set
+# CONFIG_FB_SVGALIB is not set
 # CONFIG_FB_MACMODES is not set
 # CONFIG_FB_BACKLIGHT is not set
 CONFIG_FB_MODE_HELPERS=y
 # CONFIG_FB_TILEBLITTING is not set
+
+#
+# Frambuffer hardware drivers
+#
 # CONFIG_FB_S1D13XXX is not set
-# CONFIG_FB_VIRTUAL is not set
 CONFIG_FB_OMAP=y
 # CONFIG_FB_OMAP_LCDC_EXTERNAL is not set
 # CONFIG_FB_OMAP_LCD_MIPID is not set
 # CONFIG_FB_OMAP_BOOTLOADER_INIT is not set
 CONFIG_FB_OMAP_CONSISTENT_DMA_SIZE=2
 # CONFIG_FB_OMAP_DMA_TUNE is not set
+# CONFIG_FB_VIRTUAL is not set
 
 #
 # Console display driver support
@@ -855,7 +898,6 @@ CONFIG_LOGO=y
 # CONFIG_LOGO_LINUX_MONO is not set
 # CONFIG_LOGO_LINUX_VGA16 is not set
 CONFIG_LOGO_LINUX_CLUT224=y
-# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
 
 #
 # Sound
@@ -866,6 +908,7 @@ CONFIG_LOGO_LINUX_CLUT224=y
 # HID Devices
 #
 CONFIG_HID=y
+# CONFIG_HID_DEBUG is not set
 
 #
 # USB support
@@ -880,10 +923,8 @@ CONFIG_USB=y
 # Miscellaneous USB options
 #
 CONFIG_USB_DEVICEFS=y
-# CONFIG_USB_BANDWIDTH is not set
 # CONFIG_USB_DYNAMIC_MINORS is not set
 CONFIG_USB_SUSPEND=y
-# CONFIG_USB_MULTITHREAD_PROBE is not set
 CONFIG_USB_OTG=y
 CONFIG_USB_OTG_WHITELIST=y
 # CONFIG_USB_OTG_BLACKLIST_HUB is not set
@@ -893,7 +934,8 @@ CONFIG_USB_OTG_WHITELIST=y
 #
 # CONFIG_USB_ISP116X_HCD is not set
 CONFIG_USB_OHCI_HCD=y
-# CONFIG_USB_OHCI_BIG_ENDIAN is not set
+# CONFIG_USB_OHCI_BIG_ENDIAN_DESC is not set
+# CONFIG_USB_OHCI_BIG_ENDIAN_MMIO is not set
 CONFIG_USB_OHCI_LITTLE_ENDIAN=y
 # CONFIG_USB_SL811_HCD is not set
 # CONFIG_USB_MUSB_HDRC is not set
@@ -936,6 +978,7 @@ CONFIG_USB_OHCI_LITTLE_ENDIAN=y
 # CONFIG_USB_ATI_REMOTE2 is not set
 # CONFIG_USB_KEYSPAN_REMOTE is not set
 # CONFIG_USB_APPLETOUCH is not set
+# CONFIG_USB_GTCO is not set
 
 #
 # USB Imaging devices
@@ -972,6 +1015,7 @@ CONFIG_USB_MON=y
 # CONFIG_USB_RIO500 is not set
 # CONFIG_USB_LEGOTOWER is not set
 # CONFIG_USB_LCD is not set
+# CONFIG_USB_BERRY_CHARGE is not set
 # CONFIG_USB_LED is not set
 # CONFIG_USB_CYPRESS_CY7C63 is not set
 # CONFIG_USB_CYTHERM is not set
@@ -981,6 +1025,7 @@ CONFIG_USB_MON=y
 # CONFIG_USB_APPLEDISPLAY is not set
 # CONFIG_USB_LD is not set
 # CONFIG_USB_TRANCEVIBRATOR is not set
+# CONFIG_USB_IOWARRIOR is not set
 CONFIG_USB_TEST=y
 
 #
@@ -1022,12 +1067,6 @@ CONFIG_RTC_LIB=y
 # CONFIG_RTC_CLASS is not set
 
 #
-# Synchronous Serial Interfaces (SSI)
-#
-CONFIG_OMAP_UWIRE=y
-# CONFIG_OMAP_TSC2101 is not set
-
-#
 # CBUS support
 #
 # CONFIG_CBUS is not set
@@ -1199,15 +1238,16 @@ CONFIG_ENABLE_MUST_CHECK=y
 # CONFIG_DEBUG_FS is not set
 # CONFIG_HEADERS_CHECK is not set
 CONFIG_DEBUG_KERNEL=y
+# CONFIG_DEBUG_SHIRQ is not set
 CONFIG_LOG_BUF_SHIFT=14
 CONFIG_DETECT_SOFTLOCKUP=y
 # CONFIG_SCHEDSTATS is not set
+# CONFIG_TIMER_STATS is not set
 # CONFIG_DEBUG_SLAB is not set
 # CONFIG_DEBUG_RT_MUTEXES is not set
 # CONFIG_RT_MUTEX_TESTER is not set
 # CONFIG_DEBUG_SPINLOCK is not set
 # CONFIG_DEBUG_MUTEXES is not set
-# CONFIG_DEBUG_RWSEMS is not set
 # CONFIG_DEBUG_SPINLOCK_SLEEP is not set
 # CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
 # CONFIG_DEBUG_KOBJECT is not set
@@ -1218,6 +1258,7 @@ CONFIG_DEBUG_INFO=y
 CONFIG_FRAME_POINTER=y
 CONFIG_FORCED_INLINING=y
 # CONFIG_RCU_TORTURE_TEST is not set
+# CONFIG_FAULT_INJECTION is not set
 CONFIG_DEBUG_USER=y
 CONFIG_DEBUG_ERRORS=y
 # CONFIG_DEBUG_LL is not set
@@ -1244,4 +1285,5 @@ CONFIG_CRC32=y
 CONFIG_ZLIB_INFLATE=y
 CONFIG_ZLIB_DEFLATE=y
 CONFIG_PLIST=y
-CONFIG_IOMAP_COPY=y
+CONFIG_HAS_IOMEM=y
+CONFIG_HAS_IOPORT=y
diff --git a/arch/arm/configs/omap_h3_1710_defconfig b/arch/arm/configs/omap_h3_1710_defconfig
index 5e2c5b1..307277c 100644
--- a/arch/arm/configs/omap_h3_1710_defconfig
+++ b/arch/arm/configs/omap_h3_1710_defconfig
@@ -1,19 +1,31 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.14-rc4-omap1
-# Tue Oct 18 17:58:27 2005
+# Linux kernel version: 2.6.21-rc3-omap1
+# Wed Mar 14 18:04:35 2007
 #
 CONFIG_ARM=y
+CONFIG_SYS_SUPPORTS_APM_EMULATION=y
+CONFIG_GENERIC_GPIO=y
+# CONFIG_GENERIC_TIME is not set
 CONFIG_MMU=y
-CONFIG_UID16=y
+# CONFIG_NO_IOPORT is not set
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_TRACE_IRQFLAGS_SUPPORT=y
+CONFIG_HARDIRQS_SW_RESEND=y
+CONFIG_GENERIC_IRQ_PROBE=y
 CONFIG_RWSEM_GENERIC_SPINLOCK=y
+# CONFIG_ARCH_HAS_ILOG2_U32 is not set
+# CONFIG_ARCH_HAS_ILOG2_U64 is not set
+CONFIG_GENERIC_HWEIGHT=y
 CONFIG_GENERIC_CALIBRATE_DELAY=y
+CONFIG_ZONE_DMA=y
+CONFIG_VECTORS_BASE=0xffff0000
+CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
 
 #
 # Code maturity level options
 #
 CONFIG_EXPERIMENTAL=y
-CONFIG_CLEAN_COMPILE=y
 CONFIG_BROKEN_ON_SMP=y
 CONFIG_INIT_ENV_ARG_LIMIT=32
 
@@ -24,31 +36,40 @@ CONFIG_LOCALVERSION=""
 CONFIG_LOCALVERSION_AUTO=y
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
+# CONFIG_IPC_NS is not set
+CONFIG_SYSVIPC_SYSCTL=y
 # CONFIG_POSIX_MQUEUE is not set
 # CONFIG_BSD_PROCESS_ACCT is not set
-CONFIG_SYSCTL=y
+# CONFIG_TASKSTATS is not set
+# CONFIG_UTS_NS is not set
 # CONFIG_AUDIT is not set
-# CONFIG_HOTPLUG is not set
-CONFIG_KOBJECT_UEVENT=y
 # CONFIG_IKCONFIG is not set
+CONFIG_SYSFS_DEPRECATED=y
+# CONFIG_RELAY is not set
+CONFIG_BLK_DEV_INITRD=y
 CONFIG_INITRAMFS_SOURCE=""
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+CONFIG_SYSCTL=y
 # CONFIG_EMBEDDED is not set
+CONFIG_UID16=y
+CONFIG_SYSCTL_SYSCALL=y
 CONFIG_KALLSYMS=y
 # CONFIG_KALLSYMS_ALL is not set
 # CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_HOTPLUG=y
 CONFIG_PRINTK=y
 CONFIG_BUG=y
+CONFIG_ELF_CORE=y
 CONFIG_BASE_FULL=y
 CONFIG_FUTEX=y
 CONFIG_EPOLL=y
-CONFIG_CC_OPTIMIZE_FOR_SIZE=y
 CONFIG_SHMEM=y
-CONFIG_CC_ALIGN_FUNCTIONS=0
-CONFIG_CC_ALIGN_LABELS=0
-CONFIG_CC_ALIGN_LOOPS=0
-CONFIG_CC_ALIGN_JUMPS=0
+CONFIG_SLAB=y
+CONFIG_VM_EVENT_COUNTERS=y
+CONFIG_RT_MUTEXES=y
 # CONFIG_TINY_SHMEM is not set
 CONFIG_BASE_SMALL=0
+# CONFIG_SLOB is not set
 
 #
 # Loadable module support
@@ -56,25 +77,57 @@ CONFIG_BASE_SMALL=0
 CONFIG_MODULES=y
 CONFIG_MODULE_UNLOAD=y
 # CONFIG_MODULE_FORCE_UNLOAD is not set
-CONFIG_OBSOLETE_MODPARM=y
 # CONFIG_MODVERSIONS is not set
 # CONFIG_MODULE_SRCVERSION_ALL is not set
 # CONFIG_KMOD is not set
 
 #
+# Block layer
+#
+CONFIG_BLOCK=y
+# CONFIG_LBD is not set
+# CONFIG_BLK_DEV_IO_TRACE is not set
+# CONFIG_LSF is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+# CONFIG_DEFAULT_AS is not set
+# CONFIG_DEFAULT_DEADLINE is not set
+CONFIG_DEFAULT_CFQ=y
+# CONFIG_DEFAULT_NOOP is not set
+CONFIG_DEFAULT_IOSCHED="cfq"
+
+#
 # System Type
 #
+# CONFIG_ARCH_AAEC2000 is not set
+# CONFIG_ARCH_INTEGRATOR is not set
+# CONFIG_ARCH_REALVIEW is not set
+# CONFIG_ARCH_VERSATILE is not set
+# CONFIG_ARCH_AT91 is not set
 # CONFIG_ARCH_CLPS7500 is not set
 # CONFIG_ARCH_CLPS711X is not set
 # CONFIG_ARCH_CO285 is not set
 # CONFIG_ARCH_EBSA110 is not set
-# CONFIG_ARCH_CAMELOT is not set
+# CONFIG_ARCH_EP93XX is not set
 # CONFIG_ARCH_FOOTBRIDGE is not set
-# CONFIG_ARCH_INTEGRATOR is not set
-# CONFIG_ARCH_IOP3XX is not set
+# CONFIG_ARCH_NETX is not set
+# CONFIG_ARCH_H720X is not set
+# CONFIG_ARCH_IMX is not set
+# CONFIG_ARCH_IOP32X is not set
+# CONFIG_ARCH_IOP33X is not set
+# CONFIG_ARCH_IOP13XX is not set
 # CONFIG_ARCH_IXP4XX is not set
 # CONFIG_ARCH_IXP2000 is not set
+# CONFIG_ARCH_IXP23XX is not set
 # CONFIG_ARCH_L7200 is not set
+# CONFIG_ARCH_NS9XXX is not set
+# CONFIG_ARCH_PNX4008 is not set
 # CONFIG_ARCH_PXA is not set
 # CONFIG_ARCH_RPC is not set
 # CONFIG_ARCH_SA1100 is not set
@@ -82,10 +135,6 @@ CONFIG_OBSOLETE_MODPARM=y
 # CONFIG_ARCH_SHARK is not set
 # CONFIG_ARCH_LH7A40X is not set
 CONFIG_ARCH_OMAP=y
-# CONFIG_ARCH_VERSATILE is not set
-# CONFIG_ARCH_IMX is not set
-# CONFIG_ARCH_H720X is not set
-# CONFIG_ARCH_AAEC2000 is not set
 
 #
 # TI OMAP Implementations
@@ -99,9 +148,14 @@ CONFIG_ARCH_OMAP1=y
 #
 # CONFIG_OMAP_RESET_CLOCKS is not set
 # CONFIG_OMAP_BOOT_TAG is not set
+# CONFIG_OMAP_GPIO_SWITCH is not set
 CONFIG_OMAP_MUX=y
 # CONFIG_OMAP_MUX_DEBUG is not set
 CONFIG_OMAP_MUX_WARNINGS=y
+# CONFIG_OMAP_STI is not set
+CONFIG_OMAP_MCBSP=y
+# CONFIG_OMAP_MMU_FWK is not set
+# CONFIG_OMAP_MBOX_FWK is not set
 CONFIG_OMAP_MPU_TIMER=y
 # CONFIG_OMAP_32K_TIMER is not set
 # CONFIG_OMAP_DM_TIMER is not set
@@ -109,6 +163,7 @@ CONFIG_OMAP_LL_DEBUG_UART1=y
 # CONFIG_OMAP_LL_DEBUG_UART2 is not set
 # CONFIG_OMAP_LL_DEBUG_UART3 is not set
 CONFIG_OMAP_SERIAL_WAKE=y
+# CONFIG_OMAP_DSP is not set
 
 #
 # OMAP Core Type
@@ -124,6 +179,7 @@ CONFIG_ARCH_OMAP16XX=y
 # CONFIG_MACH_OMAP_H2 is not set
 CONFIG_MACH_OMAP_H3=y
 # CONFIG_MACH_OMAP_OSK is not set
+# CONFIG_MACH_NOKIA770 is not set
 # CONFIG_MACH_OMAP_GENERIC is not set
 
 #
@@ -136,7 +192,6 @@ CONFIG_OMAP_ARM_168MHZ=y
 # CONFIG_OMAP_ARM_120MHZ is not set
 # CONFIG_OMAP_ARM_60MHZ is not set
 # CONFIG_OMAP_ARM_30MHZ is not set
-# CONFIG_OMAP_DSP is not set
 
 #
 # Processor Type
@@ -148,6 +203,8 @@ CONFIG_CPU_ABRT_EV5TJ=y
 CONFIG_CPU_CACHE_VIVT=y
 CONFIG_CPU_COPY_V4WB=y
 CONFIG_CPU_TLB_V4WBI=y
+CONFIG_CPU_CP15=y
+CONFIG_CPU_CP15_MMU=y
 
 #
 # Processor Features
@@ -157,11 +214,11 @@ CONFIG_ARM_THUMB=y
 # CONFIG_CPU_DCACHE_DISABLE is not set
 # CONFIG_CPU_DCACHE_WRITETHROUGH is not set
 # CONFIG_CPU_CACHE_ROUND_ROBIN is not set
+# CONFIG_OUTER_CACHE is not set
 
 #
 # Bus support
 #
-CONFIG_ISA_DMA_API=y
 
 #
 # PCCARD (PCMCIA/CardBus) support
@@ -173,6 +230,8 @@ CONFIG_ISA_DMA_API=y
 #
 # CONFIG_PREEMPT is not set
 # CONFIG_NO_IDLE_HZ is not set
+CONFIG_HZ=100
+# CONFIG_AEABI is not set
 # CONFIG_ARCH_DISCONTIGMEM_ENABLE is not set
 CONFIG_SELECT_MEMORY_MODEL=y
 CONFIG_FLATMEM_MANUAL=y
@@ -181,9 +240,10 @@ CONFIG_FLATMEM_MANUAL=y
 CONFIG_FLATMEM=y
 CONFIG_FLAT_NODE_MEM_MAP=y
 # CONFIG_SPARSEMEM_STATIC is not set
+CONFIG_SPLIT_PTLOCK_CPUS=4096
+# CONFIG_RESOURCES_64BIT is not set
+CONFIG_ZONE_DMA_FLAG=1
 CONFIG_LEDS=y
-# CONFIG_LEDS_TIMER is not set
-# CONFIG_LEDS_CPU is not set
 CONFIG_ALIGNMENT_TRAP=y
 
 #
@@ -194,6 +254,7 @@ CONFIG_ZBOOT_ROM_BSS=0x10200000
 # CONFIG_ZBOOT_ROM is not set
 CONFIG_CMDLINE="mem=32M console=ttyS0,115200n8 initrd=0x10A00000,8M root=/dev/ram0 rw ip=dhcp devfs=mount"
 # CONFIG_XIP_KERNEL is not set
+# CONFIG_KEXEC is not set
 
 #
 # CPU Frequency scaling
@@ -224,6 +285,10 @@ CONFIG_BINFMT_AOUT=y
 # Power management options
 #
 CONFIG_PM=y
+# CONFIG_PM_LEGACY is not set
+# CONFIG_PM_DEBUG is not set
+# CONFIG_PM_SYSFS_DEPRECATED is not set
+# CONFIG_APM_EMULATION is not set
 
 #
 # Networking
@@ -233,9 +298,14 @@ CONFIG_NET=y
 #
 # Networking options
 #
+# CONFIG_NETDEBUG is not set
 CONFIG_PACKET=y
 # CONFIG_PACKET_MMAP is not set
 CONFIG_UNIX=y
+CONFIG_XFRM=y
+# CONFIG_XFRM_USER is not set
+# CONFIG_XFRM_SUB_POLICY is not set
+# CONFIG_XFRM_MIGRATE is not set
 # CONFIG_NET_KEY is not set
 CONFIG_INET=y
 CONFIG_IP_MULTICAST=y
@@ -253,12 +323,21 @@ CONFIG_IP_PNP_BOOTP=y
 # CONFIG_INET_AH is not set
 # CONFIG_INET_ESP is not set
 # CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_XFRM_TUNNEL is not set
 # CONFIG_INET_TUNNEL is not set
+CONFIG_INET_XFRM_MODE_TRANSPORT=y
+CONFIG_INET_XFRM_MODE_TUNNEL=y
+CONFIG_INET_XFRM_MODE_BEET=y
 CONFIG_INET_DIAG=y
 CONFIG_INET_TCP_DIAG=y
 # CONFIG_TCP_CONG_ADVANCED is not set
-CONFIG_TCP_CONG_BIC=y
+CONFIG_TCP_CONG_CUBIC=y
+CONFIG_DEFAULT_TCP_CONG="cubic"
+# CONFIG_TCP_MD5SIG is not set
 # CONFIG_IPV6 is not set
+# CONFIG_INET6_XFRM_TUNNEL is not set
+# CONFIG_INET6_TUNNEL is not set
+# CONFIG_NETWORK_SECMARK is not set
 # CONFIG_NETFILTER is not set
 
 #
@@ -270,6 +349,11 @@ CONFIG_TCP_CONG_BIC=y
 # SCTP Configuration (EXPERIMENTAL)
 #
 # CONFIG_IP_SCTP is not set
+
+#
+# TIPC Configuration (EXPERIMENTAL)
+#
+# CONFIG_TIPC is not set
 # CONFIG_ATM is not set
 # CONFIG_BRIDGE is not set
 # CONFIG_VLAN_8021Q is not set
@@ -279,11 +363,13 @@ CONFIG_TCP_CONG_BIC=y
 # CONFIG_ATALK is not set
 # CONFIG_X25 is not set
 # CONFIG_LAPB is not set
-# CONFIG_NET_DIVERT is not set
 # CONFIG_ECONET is not set
 # CONFIG_WAN_ROUTER is not set
+
+#
+# QoS and/or fair queueing
+#
 # CONFIG_NET_SCHED is not set
-# CONFIG_NET_CLS_ROUTE is not set
 
 #
 # Network testing
@@ -334,12 +420,8 @@ CONFIG_IRDA=y
 #
 # CONFIG_USB_IRDA is not set
 # CONFIG_SIGMATEL_FIR is not set
-# CONFIG_NSC_FIR is not set
-# CONFIG_WINBOND_FIR is not set
-CONFIG_OMAP1610_IR=y
-# CONFIG_SMC_IRCC_FIR is not set
-# CONFIG_ALI_FIR is not set
-# CONFIG_VIA_FIR is not set
+# CONFIG_MCS_FIR is not set
+# CONFIG_OMAP_IR is not set
 # CONFIG_BT is not set
 # CONFIG_IEEE80211 is not set
 
@@ -354,6 +436,13 @@ CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
 # CONFIG_FW_LOADER is not set
 # CONFIG_DEBUG_DRIVER is not set
+# CONFIG_DEBUG_DEVRES is not set
+# CONFIG_SYS_HYPERVISOR is not set
+
+#
+# Connector - unified userspace <-> kernelspace linker
+#
+# CONFIG_CONNECTOR is not set
 
 #
 # Memory Technology Devices (MTD)
@@ -368,6 +457,7 @@ CONFIG_PREVENT_FIRMWARE_BUILD=y
 #
 # Plug and Play support
 #
+# CONFIG_PNPACPI is not set
 
 #
 # Block devices
@@ -379,16 +469,8 @@ CONFIG_PREVENT_FIRMWARE_BUILD=y
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_COUNT=16
 CONFIG_BLK_DEV_RAM_SIZE=4096
-CONFIG_BLK_DEV_INITRD=y
+CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
 # CONFIG_CDROM_PKTCDVD is not set
-
-#
-# IO Schedulers
-#
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
 # CONFIG_ATA_OVER_ETH is not set
 
 #
@@ -396,6 +478,12 @@ CONFIG_IOSCHED_CFQ=y
 #
 # CONFIG_RAID_ATTRS is not set
 # CONFIG_SCSI is not set
+# CONFIG_SCSI_NETLINK is not set
+
+#
+# Serial ATA (prod) and Parallel ATA (experimental) drivers
+#
+# CONFIG_ATA is not set
 
 #
 # Multi-device support (RAID and LVM)
@@ -465,9 +553,11 @@ CONFIG_PPP=y
 # CONFIG_PPP_SYNC_TTY is not set
 # CONFIG_PPP_DEFLATE is not set
 # CONFIG_PPP_BSDCOMP is not set
+# CONFIG_PPP_MPPE is not set
 # CONFIG_PPPOE is not set
 CONFIG_SLIP=y
 CONFIG_SLIP_COMPRESSED=y
+CONFIG_SLHC=y
 # CONFIG_SLIP_SMART is not set
 # CONFIG_SLIP_MODE_SLIP6 is not set
 # CONFIG_SHAPER is not set
@@ -484,6 +574,7 @@ CONFIG_SLIP_COMPRESSED=y
 # Input device support
 #
 CONFIG_INPUT=y
+# CONFIG_INPUT_FF_MEMLESS is not set
 
 #
 # Userland interfaces
@@ -506,7 +597,9 @@ CONFIG_INPUT_KEYBOARD=y
 # CONFIG_KEYBOARD_LKKBD is not set
 # CONFIG_KEYBOARD_XTKBD is not set
 # CONFIG_KEYBOARD_NEWTON is not set
+# CONFIG_KEYBOARD_STOWAWAY is not set
 CONFIG_KEYBOARD_OMAP=y
+# CONFIG_KEYBOARD_GPIO is not set
 # CONFIG_INPUT_MOUSE is not set
 # CONFIG_INPUT_JOYSTICK is not set
 # CONFIG_INPUT_TOUCHSCREEN is not set
@@ -526,6 +619,7 @@ CONFIG_SERIO_SERPORT=y
 CONFIG_VT=y
 CONFIG_VT_CONSOLE=y
 CONFIG_HW_CONSOLE=y
+# CONFIG_VT_HW_CONSOLE_BINDING is not set
 # CONFIG_SERIAL_NONSTANDARD is not set
 
 #
@@ -534,6 +628,7 @@ CONFIG_HW_CONSOLE=y
 CONFIG_SERIAL_8250=y
 CONFIG_SERIAL_8250_CONSOLE=y
 CONFIG_SERIAL_8250_NR_UARTS=4
+CONFIG_SERIAL_8250_RUNTIME_UARTS=4
 # CONFIG_SERIAL_8250_EXTENDED is not set
 
 #
@@ -559,27 +654,24 @@ CONFIG_WATCHDOG_NOWAYOUT=y
 # Watchdog Device Drivers
 #
 # CONFIG_SOFT_WATCHDOG is not set
+# CONFIG_OMAP_WATCHDOG is not set
 
 #
 # USB-based Watchdog Cards
 #
 # CONFIG_USBPCWATCHDOG is not set
-# CONFIG_OMAP_WATCHDOG is not set
-# CONFIG_OMAP_RNG is not set
+CONFIG_HW_RANDOM=m
+CONFIG_HW_RANDOM_OMAP=m
 # CONFIG_NVRAM is not set
-# CONFIG_RTC is not set
 CONFIG_OMAP_RTC=y
 # CONFIG_DTLK is not set
 # CONFIG_R3964 is not set
-
-#
-# Ftape, the floppy tape device driver
-#
 # CONFIG_RAW_DRIVER is not set
 
 #
 # TPM devices
 #
+# CONFIG_TCG_TPM is not set
 
 #
 # I2C support
@@ -597,10 +689,11 @@ CONFIG_I2C=y
 #
 # I2C Hardware Bus support
 #
+# CONFIG_I2C_OCORES is not set
+CONFIG_I2C_OMAP=y
 # CONFIG_I2C_PARPORT_LIGHT is not set
 # CONFIG_I2C_STUB is not set
 # CONFIG_I2C_PCA_ISA is not set
-CONFIG_I2C_OMAP=y
 
 #
 # Miscellaneous I2C Chip support
@@ -611,7 +704,6 @@ CONFIG_I2C_OMAP=y
 # CONFIG_SENSORS_PCF8574 is not set
 # CONFIG_SENSORS_PCA9539 is not set
 # CONFIG_SENSORS_PCF8591 is not set
-# CONFIG_SENSORS_RTC8564 is not set
 CONFIG_ISP1301_OMAP=m
 CONFIG_TPS65010=y
 # CONFIG_SENSORS_TLV320AIC23 is not set
@@ -623,24 +715,53 @@ CONFIG_GPIOEXPANDER_OMAP=y
 # CONFIG_I2C_DEBUG_CHIP is not set
 
 #
+# SPI support
+#
+CONFIG_SPI=y
+# CONFIG_SPI_DEBUG is not set
+CONFIG_SPI_MASTER=y
+
+#
+# SPI Master Controller Drivers
+#
+CONFIG_SPI_BITBANG=y
+CONFIG_SPI_OMAP_UWIRE=y
+
+#
+# SPI Protocol Masters
+#
+CONFIG_TSC2101=y
+# CONFIG_TSC2102 is not set
+# CONFIG_SPI_AT25 is not set
+
+#
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
 # Hardware Monitoring support
 #
 CONFIG_HWMON=y
 # CONFIG_HWMON_VID is not set
+# CONFIG_SENSORS_ABITUGURU is not set
 # CONFIG_SENSORS_ADM1021 is not set
 # CONFIG_SENSORS_ADM1025 is not set
 # CONFIG_SENSORS_ADM1026 is not set
+# CONFIG_SENSORS_ADM1029 is not set
 # CONFIG_SENSORS_ADM1031 is not set
 # CONFIG_SENSORS_ADM9240 is not set
 # CONFIG_SENSORS_ASB100 is not set
 # CONFIG_SENSORS_ATXP1 is not set
 # CONFIG_SENSORS_DS1621 is not set
+# CONFIG_SENSORS_F71805F is not set
 # CONFIG_SENSORS_FSCHER is not set
 # CONFIG_SENSORS_FSCPOS is not set
 # CONFIG_SENSORS_GL518SM is not set
 # CONFIG_SENSORS_GL520SM is not set
 # CONFIG_SENSORS_IT87 is not set
 # CONFIG_SENSORS_LM63 is not set
+# CONFIG_SENSORS_LM70 is not set
 # CONFIG_SENSORS_LM75 is not set
 # CONFIG_SENSORS_LM77 is not set
 # CONFIG_SENSORS_LM78 is not set
@@ -652,10 +773,15 @@ CONFIG_HWMON=y
 # CONFIG_SENSORS_LM92 is not set
 # CONFIG_SENSORS_MAX1619 is not set
 # CONFIG_SENSORS_PC87360 is not set
+# CONFIG_SENSORS_PC87427 is not set
 # CONFIG_SENSORS_SMSC47M1 is not set
+# CONFIG_SENSORS_SMSC47M192 is not set
 # CONFIG_SENSORS_SMSC47B397 is not set
+# CONFIG_SENSORS_VT1211 is not set
 # CONFIG_SENSORS_W83781D is not set
+# CONFIG_SENSORS_W83791D is not set
 # CONFIG_SENSORS_W83792D is not set
+# CONFIG_SENSORS_W83793 is not set
 # CONFIG_SENSORS_W83L785TS is not set
 # CONFIG_SENSORS_W83627HF is not set
 # CONFIG_SENSORS_W83627EHF is not set
@@ -666,53 +792,104 @@ CONFIG_HWMON=y
 #
 
 #
-# Multimedia Capabilities Port drivers
+# Multifunction device drivers
+#
+# CONFIG_MFD_SM501 is not set
+
+#
+# LED devices
+#
+# CONFIG_NEW_LEDS is not set
+
+#
+# LED drivers
+#
+
+#
+# LED Triggers
 #
 
 #
 # Multimedia devices
 #
 CONFIG_VIDEO_DEV=y
+CONFIG_VIDEO_V4L1=y
+CONFIG_VIDEO_V4L1_COMPAT=y
+CONFIG_VIDEO_V4L2=y
 
 #
-# Video For Linux
+# Video Capture Adapters
 #
 
 #
-# Video Adapters
+# Video Capture Adapters
 #
+# CONFIG_VIDEO_ADV_DEBUG is not set
+CONFIG_VIDEO_HELPER_CHIPS_AUTO=y
 # CONFIG_VIDEO_CPIA is not set
+# CONFIG_VIDEO_CPIA2 is not set
 # CONFIG_VIDEO_SAA5246A is not set
 # CONFIG_VIDEO_SAA5249 is not set
 # CONFIG_TUNER_3036 is not set
+
+#
+# V4L USB devices
+#
+# CONFIG_VIDEO_PVRUSB2 is not set
+# CONFIG_VIDEO_EM28XX is not set
+# CONFIG_VIDEO_USBVISION is not set
+# CONFIG_USB_VICAM is not set
+# CONFIG_USB_IBMCAM is not set
+# CONFIG_USB_KONICAWC is not set
+# CONFIG_USB_QUICKCAM_MESSENGER is not set
+# CONFIG_USB_ET61X251 is not set
 # CONFIG_VIDEO_OVCAMCHIP is not set
+# CONFIG_USB_W9968CF is not set
+# CONFIG_USB_OV511 is not set
+# CONFIG_USB_SE401 is not set
+# CONFIG_USB_SN9C102 is not set
+# CONFIG_USB_STV680 is not set
+# CONFIG_USB_ZC0301 is not set
+# CONFIG_USB_PWC is not set
 # CONFIG_VIDEO_OMAP_CAMERA is not set
 
 #
 # Radio Adapters
 #
-# CONFIG_RADIO_MAESTRO is not set
+# CONFIG_RADIO_TEA5761 is not set
+# CONFIG_USB_DSBR is not set
 
 #
 # Digital Video Broadcasting Devices
 #
 # CONFIG_DVB is not set
+# CONFIG_USB_DABUSB is not set
 
 #
 # Graphics support
 #
+# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
 CONFIG_FB=y
+# CONFIG_FIRMWARE_EDID is not set
+# CONFIG_FB_DDC is not set
 # CONFIG_FB_CFB_FILLRECT is not set
 # CONFIG_FB_CFB_COPYAREA is not set
 # CONFIG_FB_CFB_IMAGEBLIT is not set
-CONFIG_FB_SOFT_CURSOR=y
+# CONFIG_FB_SVGALIB is not set
 # CONFIG_FB_MACMODES is not set
+# CONFIG_FB_BACKLIGHT is not set
 CONFIG_FB_MODE_HELPERS=y
 # CONFIG_FB_TILEBLITTING is not set
+
+#
+# Frambuffer hardware drivers
+#
 # CONFIG_FB_S1D13XXX is not set
 CONFIG_FB_OMAP=y
-CONFIG_FB_OMAP_LCDC_INTERNAL=y
 # CONFIG_FB_OMAP_LCDC_EXTERNAL is not set
+# CONFIG_FB_OMAP_LCD_MIPID is not set
+# CONFIG_FB_OMAP_BOOTLOADER_INIT is not set
+CONFIG_FB_OMAP_CONSISTENT_DMA_SIZE=2
 # CONFIG_FB_OMAP_DMA_TUNE is not set
 # CONFIG_FB_VIRTUAL is not set
 
@@ -722,6 +899,7 @@ CONFIG_FB_OMAP_LCDC_INTERNAL=y
 # CONFIG_VGA_CONSOLE is not set
 CONFIG_DUMMY_CONSOLE=y
 CONFIG_FRAMEBUFFER_CONSOLE=y
+# CONFIG_FRAMEBUFFER_CONSOLE_ROTATION is not set
 # CONFIG_FONTS is not set
 CONFIG_FONT_8x8=y
 CONFIG_FONT_8x16=y
@@ -733,7 +911,6 @@ CONFIG_LOGO=y
 # CONFIG_LOGO_LINUX_MONO is not set
 # CONFIG_LOGO_LINUX_VGA16 is not set
 CONFIG_LOGO_LINUX_CLUT224=y
-# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
 
 #
 # Sound
@@ -749,18 +926,23 @@ CONFIG_SOUND=y
 # Open Sound System
 #
 CONFIG_SOUND_PRIME=y
-# CONFIG_SOUND_OMAP is not set
+# CONFIG_OBSOLETE_OSS is not set
 # CONFIG_SOUND_MSNDCLAS is not set
 # CONFIG_SOUND_MSNDPIN is not set
-# CONFIG_SOUND_OSS is not set
 # CONFIG_SOUND_TVMIXER is not set
-# CONFIG_SOUND_AD1980 is not set
+
+#
+# HID Devices
+#
+CONFIG_HID=y
+# CONFIG_HID_DEBUG is not set
 
 #
 # USB support
 #
 CONFIG_USB_ARCH_HAS_HCD=y
 CONFIG_USB_ARCH_HAS_OHCI=y
+# CONFIG_USB_ARCH_HAS_EHCI is not set
 CONFIG_USB=m
 # CONFIG_USB_DEBUG is not set
 
@@ -768,8 +950,8 @@ CONFIG_USB=m
 # Miscellaneous USB options
 #
 # CONFIG_USB_DEVICEFS is not set
-# CONFIG_USB_BANDWIDTH is not set
 # CONFIG_USB_DYNAMIC_MINORS is not set
+# CONFIG_USB_SUSPEND is not set
 # CONFIG_USB_OTG is not set
 
 #
@@ -777,22 +959,30 @@ CONFIG_USB=m
 #
 # CONFIG_USB_ISP116X_HCD is not set
 CONFIG_USB_OHCI_HCD=m
-# CONFIG_USB_OHCI_BIG_ENDIAN is not set
+# CONFIG_USB_OHCI_BIG_ENDIAN_DESC is not set
+# CONFIG_USB_OHCI_BIG_ENDIAN_MMIO is not set
 CONFIG_USB_OHCI_LITTLE_ENDIAN=y
 # CONFIG_USB_SL811_HCD is not set
 
 #
+# Enable Host or Gadget support to see Inventra options
+#
+# CONFIG_USB_MUSB_HDRC is not set
+
+#
 # USB Device Class drivers
 #
-# CONFIG_OBSOLETE_OSS_USB_DRIVER is not set
-# CONFIG_USB_BLUETOOTH_TTY is not set
 # CONFIG_USB_ACM is not set
 # CONFIG_USB_PRINTER is not set
 
 #
-# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' may also be needed; see USB_STORAGE Help for more information
+# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
 #
-# CONFIG_USB_STORAGE is not set
+
+#
+# may also be needed; see USB_STORAGE Help for more information
+#
+# CONFIG_USB_LIBUSUAL is not set
 
 #
 # USB Input Devices
@@ -809,14 +999,14 @@ CONFIG_USB_OHCI_LITTLE_ENDIAN=y
 # CONFIG_USB_ACECAD is not set
 # CONFIG_USB_KBTAB is not set
 # CONFIG_USB_POWERMATE is not set
-# CONFIG_USB_MTOUCH is not set
-# CONFIG_USB_ITMTOUCH is not set
-# CONFIG_USB_EGALAX is not set
+# CONFIG_USB_TOUCHSCREEN is not set
 # CONFIG_USB_YEALINK is not set
 # CONFIG_USB_XPAD is not set
 # CONFIG_USB_ATI_REMOTE is not set
+# CONFIG_USB_ATI_REMOTE2 is not set
 # CONFIG_USB_KEYSPAN_REMOTE is not set
 # CONFIG_USB_APPLETOUCH is not set
+# CONFIG_USB_GTCO is not set
 
 #
 # USB Imaging devices
@@ -824,26 +1014,13 @@ CONFIG_USB_OHCI_LITTLE_ENDIAN=y
 # CONFIG_USB_MDC800 is not set
 
 #
-# USB Multimedia devices
-#
-# CONFIG_USB_DABUSB is not set
-# CONFIG_USB_VICAM is not set
-# CONFIG_USB_DSBR is not set
-# CONFIG_USB_IBMCAM is not set
-# CONFIG_USB_KONICAWC is not set
-# CONFIG_USB_OV511 is not set
-# CONFIG_USB_SE401 is not set
-# CONFIG_USB_SN9C102 is not set
-# CONFIG_USB_STV680 is not set
-# CONFIG_USB_PWC is not set
-
-#
 # USB Network Adapters
 #
 # CONFIG_USB_CATC is not set
 # CONFIG_USB_KAWETH is not set
 # CONFIG_USB_PEGASUS is not set
 # CONFIG_USB_RTL8150 is not set
+# CONFIG_USB_USBNET_MII is not set
 # CONFIG_USB_USBNET is not set
 CONFIG_USB_MON=y
 
@@ -861,16 +1038,22 @@ CONFIG_USB_MON=y
 #
 # CONFIG_USB_EMI62 is not set
 # CONFIG_USB_EMI26 is not set
+# CONFIG_USB_ADUTUX is not set
 # CONFIG_USB_AUERSWALD is not set
 # CONFIG_USB_RIO500 is not set
 # CONFIG_USB_LEGOTOWER is not set
 # CONFIG_USB_LCD is not set
+# CONFIG_USB_BERRY_CHARGE is not set
 # CONFIG_USB_LED is not set
+# CONFIG_USB_CYPRESS_CY7C63 is not set
 # CONFIG_USB_CYTHERM is not set
-# CONFIG_USB_PHIDGETKIT is not set
-# CONFIG_USB_PHIDGETSERVO is not set
+# CONFIG_USB_PHIDGET is not set
 # CONFIG_USB_IDMOUSE is not set
+# CONFIG_USB_FTDI_ELAN is not set
+# CONFIG_USB_APPLEDISPLAY is not set
 # CONFIG_USB_LD is not set
+# CONFIG_USB_TRANCEVIBRATOR is not set
+# CONFIG_USB_IOWARRIOR is not set
 
 #
 # USB DSL modem support
@@ -887,16 +1070,18 @@ CONFIG_USB_MON=y
 CONFIG_MMC=y
 # CONFIG_MMC_DEBUG is not set
 CONFIG_MMC_BLOCK=y
-# CONFIG_MMC_BLOCK_BROKEN_RFD is not set
-# CONFIG_MMC_BULKTRANSFER is not set
 CONFIG_MMC_OMAP=y
-# CONFIG_MMC_WBSD is not set
 
 #
-# Synchronous Serial Interfaces (SSI)
+# Real Time Clock
+#
+CONFIG_RTC_LIB=y
+# CONFIG_RTC_CLASS is not set
+
+#
+# CBUS support
 #
-CONFIG_OMAP_UWIRE=y
-# CONFIG_OMAP_TSC2101 is not set
+# CONFIG_CBUS is not set
 
 #
 # File systems
@@ -907,15 +1092,18 @@ CONFIG_EXT2_FS_XATTR=y
 # CONFIG_EXT2_FS_SECURITY is not set
 # CONFIG_EXT2_FS_XIP is not set
 # CONFIG_EXT3_FS is not set
-# CONFIG_JBD is not set
+# CONFIG_EXT4DEV_FS is not set
 CONFIG_FS_MBCACHE=y
 # CONFIG_REISERFS_FS is not set
 # CONFIG_JFS_FS is not set
 # CONFIG_FS_POSIX_ACL is not set
 # CONFIG_XFS_FS is not set
+# CONFIG_GFS2_FS is not set
+# CONFIG_OCFS2_FS is not set
 # CONFIG_MINIX_FS is not set
 CONFIG_ROMFS_FS=y
 CONFIG_INOTIFY=y
+CONFIG_INOTIFY_USER=y
 # CONFIG_QUOTA is not set
 CONFIG_DNOTIFY=y
 # CONFIG_AUTOFS_FS is not set
@@ -939,11 +1127,12 @@ CONFIG_DNOTIFY=y
 # Pseudo filesystems
 #
 CONFIG_PROC_FS=y
+CONFIG_PROC_SYSCTL=y
 CONFIG_SYSFS=y
 # CONFIG_TMPFS is not set
 # CONFIG_HUGETLB_PAGE is not set
 CONFIG_RAMFS=y
-# CONFIG_RELAYFS_FS is not set
+# CONFIG_CONFIGFS_FS is not set
 
 #
 # Miscellaneous filesystems
@@ -997,6 +1186,11 @@ CONFIG_MSDOS_PARTITION=y
 # CONFIG_NLS is not set
 
 #
+# Distributed Lock Manager
+#
+# CONFIG_DLM is not set
+
+#
 # Profiling support
 #
 # CONFIG_PROFILING is not set
@@ -1005,24 +1199,36 @@ CONFIG_MSDOS_PARTITION=y
 # Kernel hacking
 #
 # CONFIG_PRINTK_TIME is not set
-CONFIG_DEBUG_KERNEL=y
+CONFIG_ENABLE_MUST_CHECK=y
 # CONFIG_MAGIC_SYSRQ is not set
+# CONFIG_UNUSED_SYMBOLS is not set
+# CONFIG_DEBUG_FS is not set
+# CONFIG_HEADERS_CHECK is not set
+CONFIG_DEBUG_KERNEL=y
+# CONFIG_DEBUG_SHIRQ is not set
 CONFIG_LOG_BUF_SHIFT=14
 CONFIG_DETECT_SOFTLOCKUP=y
 # CONFIG_SCHEDSTATS is not set
+# CONFIG_TIMER_STATS is not set
 # CONFIG_DEBUG_SLAB is not set
+# CONFIG_DEBUG_RT_MUTEXES is not set
+# CONFIG_RT_MUTEX_TESTER is not set
 # CONFIG_DEBUG_SPINLOCK is not set
+# CONFIG_DEBUG_MUTEXES is not set
 # CONFIG_DEBUG_SPINLOCK_SLEEP is not set
+# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
 # CONFIG_DEBUG_KOBJECT is not set
 CONFIG_DEBUG_BUGVERBOSE=y
 CONFIG_DEBUG_INFO=y
-# CONFIG_DEBUG_FS is not set
+# CONFIG_DEBUG_VM is not set
+# CONFIG_DEBUG_LIST is not set
 CONFIG_FRAME_POINTER=y
+CONFIG_FORCED_INLINING=y
+# CONFIG_RCU_TORTURE_TEST is not set
+# CONFIG_FAULT_INJECTION is not set
 CONFIG_DEBUG_USER=y
-# CONFIG_DEBUG_WAITQ is not set
 CONFIG_DEBUG_ERRORS=y
 # CONFIG_DEBUG_LL is not set
-# CONFIG_DEBUG_ICEDCC is not set
 
 #
 # Security options
@@ -1036,13 +1242,13 @@ CONFIG_DEBUG_ERRORS=y
 # CONFIG_CRYPTO is not set
 
 #
-# Hardware crypto devices
-#
-
-#
 # Library routines
 #
+CONFIG_BITREVERSE=y
 CONFIG_CRC_CCITT=y
 # CONFIG_CRC16 is not set
 CONFIG_CRC32=y
 # CONFIG_LIBCRC32C is not set
+CONFIG_PLIST=y
+CONFIG_HAS_IOMEM=y
+CONFIG_HAS_IOPORT=y
-- 
1.5.0.rc3


[-- Attachment #5: Type: text/plain, Size: 0 bytes --]



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

* Re: TSC2101/2102
  2007-03-14 17:09     ` TSC2101/2102 Imre Deak
@ 2007-03-14 20:35       ` Dirk Behme
  2007-03-15  1:18       ` TSC2101/2102 Kyungmin Park
  2007-03-29 20:26       ` TSC2101/2102 Tony Lindgren
  2 siblings, 0 replies; 35+ messages in thread
From: Dirk Behme @ 2007-03-14 20:35 UTC (permalink / raw)
  To: Imre Deak; +Cc: Linux OMAP ML

Imre Deak wrote:
> On Wed, Mar 14, 2007 at 08:21:24AM -0500, Nishanth Menon wrote:
> 
>>andrzej zaborowski stated on 3/9/2007 8:23 AM:
>>
>>>On 09/03/07, Imre Deak <imre.deak@solidboot.com> wrote:
>>>
>>>>I'm wondering about the proper way to convert the existing omap-tsc2101
>>>>driver to the SPI framework. Would it make sense to handle it with the
>>>>tsc2102 driver? omap-tsc2101 has only the register read / write
>>>>interface
>>>>which is the same as in tsc2102.
>>>
>>>How about maybe a header file <linux/spi/tsc2xxx.h> shared between
>>>tsc2101/2102 with the register access functions as "static inline"
>>>functions?
>>
>>Some TODOs:
>>1. should interrupt muxing be done here?
>>2. There are some TSC2005 devices(TS only).. so it will be interesting
>>to see xxxx.h scales to all..
>>3. rename this to tsc2xxx_core.[ch]
>>4. use SPI framework (would not break uwire support I believe).
> 
> 
> The attached patches try to do #4. Please review it / sign it off as
> necessary.

Great! Many thanks.

Is this already sufficient to remove 
drivers/ssi/omap-tsc2101.[ch]? If yes, I would propose to 
apply this to get rid of tsc in ssi directory as fast as 
possible. And, in parallel, we can use this as starting 
point for further improvements as mentioned above.

Dirk

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

* RE: TSC2101/2102
  2007-03-14 17:09     ` TSC2101/2102 Imre Deak
  2007-03-14 20:35       ` TSC2101/2102 Dirk Behme
@ 2007-03-15  1:18       ` Kyungmin Park
  2007-03-15 10:23         ` TSC2101/2102 Imre Deak
  2007-03-29 20:26       ` TSC2101/2102 Tony Lindgren
  2 siblings, 1 reply; 35+ messages in thread
From: Kyungmin Park @ 2007-03-15  1:18 UTC (permalink / raw)
  To: 'Imre Deak', 'Nishanth Menon'; +Cc: 'Linux OMAP ML'

Hi,

> 
> On Wed, Mar 14, 2007 at 08:21:24AM -0500, Nishanth Menon wrote:
> > andrzej zaborowski stated on 3/9/2007 8:23 AM:
> > > On 09/03/07, Imre Deak <imre.deak@solidboot.com> wrote:
> > >> I'm wondering about the proper way to convert the existing 
> > >> omap-tsc2101 driver to the SPI framework. Would it make sense to 
> > >> handle it with the
> > >> tsc2102 driver? omap-tsc2101 has only the register read / write 
> > >> interface which is the same as in tsc2102.
> > >
> > > How about maybe a header file <linux/spi/tsc2xxx.h> shared between
> > > tsc2101/2102 with the register access functions as "static inline"
> > > functions?
> > Some TODOs:
> > 1. should interrupt muxing be done here?
> > 2. There are some TSC2005 devices(TS only).. so it will be 
> interesting 
> > to see xxxx.h scales to all..
> > 3. rename this to tsc2xxx_core.[ch]
> > 4. use SPI framework (would not break uwire support I believe).
> 
> The attached patches try to do #4. Please review it / sign it 
> off as necessary.
> 
> There is an upcoming TSC2301 patch, that should also be taken 
> into account when creating a tsc2xxx-core.[ch] based on the 
> existing TSC driver implementations.
> 

Cool!!!

In the previous time, I implemented the tsc2101 on OMAP2 based on tsc2301.
[1]
The current code only supports 16-bit tsc2101 for OMAP1.
We have to consider OMAP2 tsc2101 for H4 and apollon.

Here's simple changes.

+struct tsc2101_platform_data {
+       int     (*init)(struct spi_device *spi);
+       void    (*cleanup)(struct spi_device *spi);
+       void    (*enable_mclk)(struct spi_device *spi);
+       void    (*disable_mclk)(struct spi_device *spi);

+       int       bits_per_word;

+};

How about to add 'bits_per_word' to platform. So if the bits_per_word is
empty. it assumes it will use 16-bit, otherwise we use it provided from
platform.

+struct tsc2101_device {
+       struct mutex            mutex;
+       int                     mclk_enabled;
+       struct clock            *mclk_ck;
+       struct spi_message      message;
+       struct spi_transfer     transfer[2];
+       u16                     command;
+       void                    (*enable_mclk)(struct spi_device *spi);
+       void                    (*disable_mclk)(struct spi_device *spi);

+       int		32bit_shift;	/* 16 if 32-bit bus, otherwise 0 */

+};

Please change the command from u16 to u32. Umm, I'm not sure we have to
change the parameter from u16 *data to u32 *data.

I will check it.

Thank you,
Kyungmin Park

1. http://linux.omap.com/pipermail/linux-omap-open-source/2007-
January/008933.html

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

* Re: TSC2101/2102
  2007-03-15  1:18       ` TSC2101/2102 Kyungmin Park
@ 2007-03-15 10:23         ` Imre Deak
  2007-03-15 14:23           ` Regarding use of DirectFB Raja Mallik
  2007-03-16  0:28           ` TSC2101/2102 Kyungmin Park
  0 siblings, 2 replies; 35+ messages in thread
From: Imre Deak @ 2007-03-15 10:23 UTC (permalink / raw)
  To: Kyungmin Park; +Cc: 'Linux OMAP ML'

Hi,

On Thu, Mar 15, 2007 at 10:18:14AM +0900, Kyungmin Park wrote:
> [...] 
>
> In the previous time, I implemented the tsc2101 on OMAP2 based on tsc2301.
> [1]

I needed only the basic register read / write interface to access the
TSC2101 GPIO lines. The TS part you wrote is still needed, it's
init function being called from the tsc2101.c probe, as it's done in
tsc2301-core.c.

> The current code only supports 16-bit tsc2101 for OMAP1.
> We have to consider OMAP2 tsc2101 for H4 and apollon.

Is the 32-bit interface some alternate interface configuration for the chip?
In the TSC2101 spec I found at least only a description of the 16-bit
protocoll. Could you point to a documentation for this?

--Imre

> 
> Here's simple changes.
> 
> +struct tsc2101_platform_data {
> +       int     (*init)(struct spi_device *spi);
> +       void    (*cleanup)(struct spi_device *spi);
> +       void    (*enable_mclk)(struct spi_device *spi);
> +       void    (*disable_mclk)(struct spi_device *spi);
> 
> +       int       bits_per_word;
> 
> +};
> 
> How about to add 'bits_per_word' to platform. So if the bits_per_word is
> empty. it assumes it will use 16-bit, otherwise we use it provided from
> platform.
> 
> +struct tsc2101_device {
> +       struct mutex            mutex;
> +       int                     mclk_enabled;
> +       struct clock            *mclk_ck;
> +       struct spi_message      message;
> +       struct spi_transfer     transfer[2];
> +       u16                     command;
> +       void                    (*enable_mclk)(struct spi_device *spi);
> +       void                    (*disable_mclk)(struct spi_device *spi);
> 
> +       int		32bit_shift;	/* 16 if 32-bit bus, otherwise 0 */
> 
> +};
> 
> Please change the command from u16 to u32. Umm, I'm not sure we have to
> change the parameter from u16 *data to u32 *data.
> 
> I will check it.
> 
> Thank you,
> Kyungmin Park
> 
> 1. http://linux.omap.com/pipermail/linux-omap-open-source/2007-
> January/008933.html
> 

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

* Regarding use of DirectFB
  2007-03-15 10:23         ` TSC2101/2102 Imre Deak
@ 2007-03-15 14:23           ` Raja Mallik
  2007-03-15 17:09             ` Cliff Brake
  2007-03-16  0:28           ` TSC2101/2102 Kyungmin Park
  1 sibling, 1 reply; 35+ messages in thread
From: Raja Mallik @ 2007-03-15 14:23 UTC (permalink / raw)
  To: linux-omap-open-source

Hi All,

I am working on to run some DirectFB application on my board that has
omap5912  core. I am using linux-2.6.20 git kernel port and arm toolchain
built with gcc-4.1.2, bin utils-2.17, glibc-2.5.

We found that Ti' omap frame buffer is working fine.
Has there been any port of directfb applications running on omap5912?

Pl, share your reference..

-Raja Mallik

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

* Re: Regarding use of DirectFB
  2007-03-15 14:23           ` Regarding use of DirectFB Raja Mallik
@ 2007-03-15 17:09             ` Cliff Brake
  0 siblings, 0 replies; 35+ messages in thread
From: Cliff Brake @ 2007-03-15 17:09 UTC (permalink / raw)
  To: Raja Mallik; +Cc: linux-omap-open-source

On 3/15/07, Raja Mallik <raja.mallik@sqlstar.com> wrote:

> I am working on to run some DirectFB application on my board that has
> omap5912  core. I am using linux-2.6.20 git kernel port and arm toolchain
> built with gcc-4.1.2, bin utils-2.17, glibc-2.5.
>
> We found that Ti' omap frame buffer is working fine.
> Has there been any port of directfb applications running on omap5912?

http://openembedded.org supports directfb, and I have heard reports
that people are successfully using it on PXA270 based systems.  I
suspect directfb apps would also run fine on omap.

Cliff

-- 
=======================
Cliff Brake
http://bec-systems.com

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

* RE: TSC2101/2102
  2007-03-15 10:23         ` TSC2101/2102 Imre Deak
  2007-03-15 14:23           ` Regarding use of DirectFB Raja Mallik
@ 2007-03-16  0:28           ` Kyungmin Park
  2007-03-16  7:41             ` TSC2101/2102 Imre Deak
  1 sibling, 1 reply; 35+ messages in thread
From: Kyungmin Park @ 2007-03-16  0:28 UTC (permalink / raw)
  To: 'Imre Deak'; +Cc: 'Linux OMAP ML'

Hi, 

> 
> I needed only the basic register read / write interface to access the
> TSC2101 GPIO lines. The TS part you wrote is still needed, 
> it's init function being called from the tsc2101.c probe, as 
> it's done in tsc2301-core.c.
> 
> > The current code only supports 16-bit tsc2101 for OMAP1.
> > We have to consider OMAP2 tsc2101 for H4 and apollon.
> 
> Is the 32-bit interface some alternate interface 
> configuration for the chip?

No. it's only needed in SPI protocol.

I don't know it's possible to use 16-bit mode in OMAP2. but most driver
which uses tsc2101 on OMAP2 uses 32-bit access.

Thank you,
Kyungmin Park

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

* Re: TSC2101/2102
  2007-03-16  0:28           ` TSC2101/2102 Kyungmin Park
@ 2007-03-16  7:41             ` Imre Deak
  2007-03-16  8:05               ` TSC2101/2102 Kyungmin Park
  0 siblings, 1 reply; 35+ messages in thread
From: Imre Deak @ 2007-03-16  7:41 UTC (permalink / raw)
  To: Kyungmin Park; +Cc: 'Linux OMAP ML'

On Fri, Mar 16, 2007 at 09:28:24AM +0900, Kyungmin Park wrote:
> Hi, 
> 
> > 
> > I needed only the basic register read / write interface to access the
> > TSC2101 GPIO lines. The TS part you wrote is still needed, 
> > it's init function being called from the tsc2101.c probe, as 
> > it's done in tsc2301-core.c.
> > 
> > > The current code only supports 16-bit tsc2101 for OMAP1.
> > > We have to consider OMAP2 tsc2101 for H4 and apollon.
> > 
> > Is the 32-bit interface some alternate interface 
> > configuration for the chip?
> 
> No. it's only needed in SPI protocol.
> 
> I don't know it's possible to use 16-bit mode in OMAP2. but most driver
> which uses tsc2101 on OMAP2 uses 32-bit access.

The following is an example how you setup the transfer for 32-bit
transfer:

+static void tsc2101_ts_setup_spi_xfer(struct tsc2101 *tsc)
+{
+	struct tsc2101_ts *ts = tsc->ts;
+	struct spi_message *m = &ts->read_msg;
+	struct spi_transfer *x = &ts->read_xfer[0];
+
+	ts->address[0] = (0x8000 | TSC2101_REG_X) << 16;
+	ts->address[1] = (0x8000 | TSC2101_REG_Y) << 16;
+	ts->address[2] = (0x8000 | TSC2101_REG_Z1) << 16;
+	ts->address[3] = (0x8000 | TSC2101_REG_Z2) << 16;
+
+	spi_message_init(m);
+
+	x->tx_buf = &ts->address;
+	x->rx_buf = &ts->data;
+	x->len = 16;
+	spi_message_add_tail(x, m);
+
+	m->complete = tsc2101_ts_rx;
+	m->context = tsc;
+}

While this may work, I'm not sure the driver should have support for such
an alternate protocol. What's the benifit of it? The TSC2xxx chips have a
register address auto increment feature, so you need to send only the
starting address and then do a read for each consecutive registers. Did
you try the 16-bit mode in SPI_MODE_0 as it's done in the TSC2301 driver?

--Imre

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

* RE: TSC2101/2102
  2007-03-16  7:41             ` TSC2101/2102 Imre Deak
@ 2007-03-16  8:05               ` Kyungmin Park
  2007-03-16  9:49                 ` TSC2101/2102 Imre Deak
  0 siblings, 1 reply; 35+ messages in thread
From: Kyungmin Park @ 2007-03-16  8:05 UTC (permalink / raw)
  To: 'Imre Deak'; +Cc: 'Linux OMAP ML'


> > > 
> > > I needed only the basic register read / write interface to access 
> > > the
> > > TSC2101 GPIO lines. The TS part you wrote is still 
> needed, it's init 
> > > function being called from the tsc2101.c probe, as it's done in 
> > > tsc2301-core.c.
> > > 
> > > > The current code only supports 16-bit tsc2101 for OMAP1.
> > > > We have to consider OMAP2 tsc2101 for H4 and apollon.
> > > 
> > > Is the 32-bit interface some alternate interface 
> configuration for 
> > > the chip?
> > 
> > No. it's only needed in SPI protocol.
> > 
> > I don't know it's possible to use 16-bit mode in OMAP2. but most 
> > driver which uses tsc2101 on OMAP2 uses 32-bit access.
> 
> The following is an example how you setup the transfer for 32-bit
> transfer:
> 
> +static void tsc2101_ts_setup_spi_xfer(struct tsc2101 *tsc) {
> +	struct tsc2101_ts *ts = tsc->ts;
> +	struct spi_message *m = &ts->read_msg;
> +	struct spi_transfer *x = &ts->read_xfer[0];
> +
> +	ts->address[0] = (0x8000 | TSC2101_REG_X) << 16;
> +	ts->address[1] = (0x8000 | TSC2101_REG_Y) << 16;
> +	ts->address[2] = (0x8000 | TSC2101_REG_Z1) << 16;
> +	ts->address[3] = (0x8000 | TSC2101_REG_Z2) << 16;
> +
> +	spi_message_init(m);
> +
> +	x->tx_buf = &ts->address;
> +	x->rx_buf = &ts->data;
> +	x->len = 16;
> +	spi_message_add_tail(x, m);
> +
> +	m->complete = tsc2101_ts_rx;
> +	m->context = tsc;
> +}
> 
> While this may work, I'm not sure the driver should have 
> support for such an alternate protocol. What's the benifit of 
> it? The TSC2xxx chips have a register address auto increment 
> feature, so you need to send only the starting address and 
> then do a read for each consecutive registers. Did you try 
> the 16-bit mode in SPI_MODE_0 as it's done in the TSC2301 driver?

No, it's not work if we provide the one address

/* XXX: tsc2101 specific */
static const u32 tsc2101_ts_read_data[4] = {
        (0x8000 | TSC2101_REG_X) << 16,
        (0x8000 | TSC2101_REG_Y) << 16,
        (0x8000 | TSC2101_REG_Z1) << 16,
        (0x8000 | TSC2101_REG_Z2) << 16,
};

static void tsc2101_ts_setup_spi_xfer(struct tsc2101 *tsc)
{
        struct tsc2101_ts *ts = tsc->ts;
        struct spi_message *m = &ts->read_msg;
        struct spi_transfer *x = &ts->read_xfer[0];

        spi_message_init(m);

        x->tx_buf = &tsc2101_ts_read_data;
        x->rx_buf = &ts->data;
        x->len = 16;
        spi_message_add_tail(x, m);

        m->complete = tsc2101_ts_rx;
        m->context = tsc;
}

No, I don't try to use 16-bit mode. since it's working well 32-bit mode, I
just use it for a long time.

Thank you,
Kyungmin Park

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

* Re: TSC2101/2102
  2007-03-16  8:05               ` TSC2101/2102 Kyungmin Park
@ 2007-03-16  9:49                 ` Imre Deak
  2007-03-19  2:02                   ` TSC2101/2102 Kyungmin Park
  0 siblings, 1 reply; 35+ messages in thread
From: Imre Deak @ 2007-03-16  9:49 UTC (permalink / raw)
  To: Kyungmin Park; +Cc: 'Linux OMAP ML'

On Fri, Mar 16, 2007 at 05:05:58PM +0900, Kyungmin Park wrote:
> 
> > > > 
> > > > I needed only the basic register read / write interface to access 
> > > > the
> > > > TSC2101 GPIO lines. The TS part you wrote is still 
> > needed, it's init 
> > > > function being called from the tsc2101.c probe, as it's done in 
> > > > tsc2301-core.c.
> > > > 
> > > > > The current code only supports 16-bit tsc2101 for OMAP1.
> > > > > We have to consider OMAP2 tsc2101 for H4 and apollon.
> > > > 
> > > > Is the 32-bit interface some alternate interface 
> > configuration for 
> > > > the chip?
> > > 
> > > No. it's only needed in SPI protocol.
> > > 
> > > I don't know it's possible to use 16-bit mode in OMAP2. but most 
> > > driver which uses tsc2101 on OMAP2 uses 32-bit access.
> > 
> > The following is an example how you setup the transfer for 32-bit
> > transfer:
> > 
> > +static void tsc2101_ts_setup_spi_xfer(struct tsc2101 *tsc) {
> > +	struct tsc2101_ts *ts = tsc->ts;
> > +	struct spi_message *m = &ts->read_msg;
> > +	struct spi_transfer *x = &ts->read_xfer[0];
> > +
> > +	ts->address[0] = (0x8000 | TSC2101_REG_X) << 16;
> > +	ts->address[1] = (0x8000 | TSC2101_REG_Y) << 16;
> > +	ts->address[2] = (0x8000 | TSC2101_REG_Z1) << 16;
> > +	ts->address[3] = (0x8000 | TSC2101_REG_Z2) << 16;
> > +
> > +	spi_message_init(m);
> > +
> > +	x->tx_buf = &ts->address;
> > +	x->rx_buf = &ts->data;
> > +	x->len = 16;
> > +	spi_message_add_tail(x, m);
> > +
> > +	m->complete = tsc2101_ts_rx;
> > +	m->context = tsc;
> > +}
> > 
> > While this may work, I'm not sure the driver should have 
> > support for such an alternate protocol. What's the benifit of 
> > it? The TSC2xxx chips have a register address auto increment 
> > feature, so you need to send only the starting address and 
> > then do a read for each consecutive registers. Did you try 
> > the 16-bit mode in SPI_MODE_0 as it's done in the TSC2301 driver?
> 
> No, it's not work if we provide the one address
> 
> /* XXX: tsc2101 specific */
> static const u32 tsc2101_ts_read_data[4] = {
>         (0x8000 | TSC2101_REG_X) << 16,
>         (0x8000 | TSC2101_REG_Y) << 16,
>         (0x8000 | TSC2101_REG_Z1) << 16,
>         (0x8000 | TSC2101_REG_Z2) << 16,
> };
> 
> static void tsc2101_ts_setup_spi_xfer(struct tsc2101 *tsc)
> {
>         struct tsc2101_ts *ts = tsc->ts;
>         struct spi_message *m = &ts->read_msg;
>         struct spi_transfer *x = &ts->read_xfer[0];
> 
>         spi_message_init(m);
> 
>         x->tx_buf = &tsc2101_ts_read_data;
>         x->rx_buf = &ts->data;
>         x->len = 16;
>         spi_message_add_tail(x, m);
> 
>         m->complete = tsc2101_ts_rx;
>         m->context = tsc;
> }
> 
> No, I don't try to use 16-bit mode. since it's working well 32-bit mode, I
> just use it for a long time.

Could you try it with debugging enabled in omap2_mcspi? Would be interesting
to see where the problem is.

--Imre
> 

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

* RE: TSC2101/2102
  2007-03-16  9:49                 ` TSC2101/2102 Imre Deak
@ 2007-03-19  2:02                   ` Kyungmin Park
  2007-03-19  7:37                     ` TSC2101/2102 Jarkko Nikula
  0 siblings, 1 reply; 35+ messages in thread
From: Kyungmin Park @ 2007-03-19  2:02 UTC (permalink / raw)
  To: 'Imre Deak'; +Cc: 'Linux OMAP ML'

Hi Imre Deak,

> 
> Could you try it with debugging enabled in omap2_mcspi? Would 
> be interesting
> to see where the problem is.

Before read/write I set the these values for TSC2101 intialization

write-32 08600016
write-32 08a00008
write-32 08400000
write-32 09a00900
write-32 08204000
write-32 08008bf4

If we set four read data

write-32 80000000
read-32 ffff0a9b
write-32 80200000
read-32 ffff064f
write-32 80400000
read-32 ffff055f
write-32 80600000
read-32 ffff0deb

and if not

write-32 80000000
read-32 ffff0c4b
write-32 70616d6f
read-32 ffffffff
write-32 6364755f
read-32 ffffffff
write-32 00000000
read-32 ffffffff
--repeat forever--

I think tsc2101 increase the its address automatically. but it's not work at 32-
bit mode.
I also tried to change the format and values "tsc2101_ts_read_data" but it's
same situation.

Ah, a few days ago, tsc2301 driver is merged in omap tree. Why don't you
consider the tsc2301 driver too?
Because I tried to use tsc2102 driver before, but it's not work well. but
tsc2301 is working well.

tsc2xxx driver? I heard tsc2301 is super set of tsc210x, (the bigger chip
number, the more functions)

There's some issue related with omap2_mcspi inferface.
If I use the 32-bit mode, it required the 32-bit data buffer address. so we
mask the read results like this

static void tsc2101_ts_rx(void *arg)
{
        x  = ts->data[0] & 0xffff;
        y  = ts->data[1] & 0xffff;
        z1 = ts->data[2] & 0xffff;
        z2 = ts->data[3] & 0xffff;
}

What's the better approcahes to address this problem?
1. modify the omap2_mcspi source
2. mask the results
3. others.

Thank you,
Kyungmin Park

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

* Re: TSC2101/2102
  2007-03-19  2:02                   ` TSC2101/2102 Kyungmin Park
@ 2007-03-19  7:37                     ` Jarkko Nikula
  2007-03-19  8:04                       ` TSC2101/2102 Kyungmin Park
  0 siblings, 1 reply; 35+ messages in thread
From: Jarkko Nikula @ 2007-03-19  7:37 UTC (permalink / raw)
  To: kmpark; +Cc: 'Linux OMAP ML'

On Mon, 19 Mar 2007 11:02:30 +0900
"ext Kyungmin Park" <kmpark@infradead.org> wrote:

> Ah, a few days ago, tsc2301 driver is merged in omap tree. Why don't you
> consider the tsc2301 driver too?

Hmm... from where I could find the tsc2301 driver from omap tree? Just started to wonder has someone already pushed it there :-)

My copy of the tree is from ftp://www.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap-2.6.git. Is it rebased correctly? E.g. last commit in master branch is from "Fri Feb 16" but "Wed Mar 7" in omap-drivers.

We have some kind of working version of 2301 driver with subdrivers separated to proper kernel directories (drivers/input/touchscreen, sound/soc/codecs) but e.g. audio part is not yet actual ASoC driver.

> tsc2xxx driver? I heard tsc2301 is super set of tsc210x, (the bigger chip
> number, the more functions)
> 
I had a short look to TSC2101 spec and at least audio parts of TSC230x and TSC2101 are not compatible. Different block diagrams and most/all of the audio registers.

http://www.ti.com/lit/gpn/tsc2101
http://www.ti.com/lit/gpn/tsc2301


Jarkko

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

* RE: TSC2101/2102
  2007-03-19  7:37                     ` TSC2101/2102 Jarkko Nikula
@ 2007-03-19  8:04                       ` Kyungmin Park
  2007-03-19  8:37                         ` TSC2101/2102 Jarkko Nikula
  0 siblings, 1 reply; 35+ messages in thread
From: Kyungmin Park @ 2007-03-19  8:04 UTC (permalink / raw)
  To: 'Jarkko Nikula'; +Cc: 'Linux OMAP ML'

> 
> On Mon, 19 Mar 2007 11:02:30 +0900
> "ext Kyungmin Park" <kmpark@infradead.org> wrote:
> 
> > Ah, a few days ago, tsc2301 driver is merged in omap tree. 
> Why don't you
> > consider the tsc2301 driver too?
> 
> Hmm... from where I could find the tsc2301 driver from omap 
> tree? Just started to wonder has someone already pushed it there :-)
> 
> My copy of the tree is from 
> ftp://www.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-oma
> p-2.6.git. Is it rebased correctly? E.g. last commit in 
> master branch is from "Fri Feb 16" but "Wed Mar 7" in omap-drivers.

I usually use the omap git tree in mvista.
http://source.mvista.com/git/gitweb.cgi?p=linux-omap-
2.6.git;a=commit;h=a7b9b17c9025066cd05f555bbba5542bcf16df3a
it was commited at Tue, 13 Mar.

> 
> We have some kind of working version of 2301 driver with 
> subdrivers separated to proper kernel directories 
> (drivers/input/touchscreen, sound/soc/codecs) but e.g. audio 
> part is not yet actual ASoC driver.
> 
> > tsc2xxx driver? I heard tsc2301 is super set of tsc210x, 
> (the bigger chip
> > number, the more functions)
> > 
> I had a short look to TSC2101 spec and at least audio parts 
> of TSC230x and TSC2101 are not compatible. Different block 
> diagrams and most/all of the audio registers.
> 
> http://www.ti.com/lit/gpn/tsc2101
> http://www.ti.com/lit/gpn/tsc2301

Yes, I knew it. I also suffered because of its different registers.

In my opinion, As OMAP CPU registers. it has common registers and chip specific
ones.
So we can define it at least headers files.

# common parts

 TSC2XXX_TS_X,
 TSC2XXX_TS_Y,

# chip specific parts
 TSC21XX_AUDIO_CTRL1.
 TSC23XX_AUDIO_CTRL1,

I will send the tsc2101 patch based on tsc2301 files. I think it's complicted
with Imre's tsc2101 patch. 

Thank you,
Kyungmin Park

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

* Re: TSC2101/2102
  2007-03-19  8:04                       ` TSC2101/2102 Kyungmin Park
@ 2007-03-19  8:37                         ` Jarkko Nikula
  2007-03-19 19:22                           ` TSC2101/2102 tony
  2007-03-20  1:46                           ` TSC2101/2102 Kyungmin Park
  0 siblings, 2 replies; 35+ messages in thread
From: Jarkko Nikula @ 2007-03-19  8:37 UTC (permalink / raw)
  To: kmpark; +Cc: 'Linux OMAP ML'

On Mon, 19 Mar 2007 17:04:55 +0900
"ext Kyungmin Park" <kmpark@infradead.org> wrote:

> > My copy of the tree is from 
> > ftp://www.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-oma
> > p-2.6.git. Is it rebased correctly? E.g. last commit in 
> > master branch is from "Fri Feb 16" but "Wed Mar 7" in omap-drivers.
> 
> I usually use the omap git tree in mvista.
> http://source.mvista.com/git/gitweb.cgi?p=linux-omap-
> 2.6.git;a=commit;h=a7b9b17c9025066cd05f555bbba5542bcf16df3a
> it was commited at Tue, 13 Mar.
> 
I'll see. That pushed version wasn't very good one. It didn't compile without warnings, etc. I'll send soon few patches in top of it.

Tony, any plans to keep sync kernel.org and mvista.com trees?

> I will send the tsc2101 patch based on tsc2301 files. I think it's complicted
> with Imre's tsc2101 patch. 
> 
How about just keeping both of them separated including config names, header files, etc. for awhile until both are pushed & working. Bit easier first step for us I think :-)


Jarkko

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

* Re: TSC2101/2102
  2007-03-19  8:37                         ` TSC2101/2102 Jarkko Nikula
@ 2007-03-19 19:22                           ` tony
  2007-03-20  1:46                           ` TSC2101/2102 Kyungmin Park
  1 sibling, 0 replies; 35+ messages in thread
From: tony @ 2007-03-19 19:22 UTC (permalink / raw)
  To: Jarkko Nikula; +Cc: 'Linux OMAP ML', kmpark

* Jarkko Nikula <jarkko.nikula@nokia.com> [070319 04:38]:
>
> Tony, any plans to keep sync kernel.org and mvista.com trees?

Yeah, sorry I was at a conference last week and my net access was
spotty. Working on updating to trees to 2.6.21-rc4 now, and will also
update kernel.org tree then.

Tony

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

* RE: TSC2101/2102
  2007-03-19  8:37                         ` TSC2101/2102 Jarkko Nikula
  2007-03-19 19:22                           ` TSC2101/2102 tony
@ 2007-03-20  1:46                           ` Kyungmin Park
  2007-03-20 13:27                             ` TSC2101/2102 tony
  1 sibling, 1 reply; 35+ messages in thread
From: Kyungmin Park @ 2007-03-20  1:46 UTC (permalink / raw)
  To: 'Jarkko Nikula'; +Cc: 'Linux OMAP ML'

[-- Attachment #1: Type: text/plain, Size: 3212 bytes --]

> 
> > I will send the tsc2101 patch based on tsc2301 files. I 
> think it's complicted
> > with Imre's tsc2101 patch. 
> > 
> How about just keeping both of them separated including 
> config names, header files, etc. for awhile until both are 
> pushed & working. Bit easier first step for us I think :-)

I agree.

Here's tsc2101 patch. It includes the tsc2101 spi functions and touchscreen
part.
It's similary with your updated pache style.

I think it's not compatible with OMAP1 touchscreen in touchscreen/omap. But I
added the 16-bit bus handling part. It needs to be check.

Umm the new updated git tree don't have tsc2301 commit. maybe it's missing :)

Here's sample configuration at apollon.

diff --git a/arch/arm/mach-omap2/board-apollon.c b/arch/arm/mach-omap2/board-
apollon.c
index 5488961..4f2ea29 100644
--- a/arch/arm/mach-omap2/board-apollon.c
+++ b/arch/arm/mach-omap2/board-apollon.c
@@ -24,9 +24,10 @@
 #include <linux/mtd/onenand.h>
 #include <linux/irq.h>
 #include <linux/interrupt.h>
+#include <linux/spi/spi.h>
+#include <linux/spi/tsc2101.h>
 #include <linux/delay.h>
 #include <linux/leds.h>
-#include <linux/irq.h>
 #include <linux/err.h>
 #include <linux/clk.h>

@@ -42,6 +43,7 @@
 #include <asm/arch/board.h>
 #include <asm/arch/common.h>
 #include <asm/arch/gpmc.h>
+#include <asm/arch/mcspi.h>
 #include "prcm-regs.h"

 /* LED & Switch macros */
@@ -51,6 +53,7 @@
 #define SW_ENTER_GPIO16                16
 #define SW_UP_GPIO17           17
 #define SW_DOWN_GPIO58         58
+#define PINTDAV_GPIO85         85

 #define APOLLON_FLASH_CS       0
 #define APOLLON_ETH_CS         1
@@ -358,6 +361,33 @@ static void __init apollon_usb_init(void)
        omap_set_gpio_dataout(12, 0);
 }

+static struct omap2_mcspi_device_config tsc2101_mcspi_config = {
+       .turbo_mode             = 0,
+       .single_channel         = 0,
+};
+
+static struct tsc2101_platform_data tsc2101_platform_config = {
+       /* Bus */
+       .bits_per_word          = 32,
+
+       /* Touchscreen */
+       .dav_gpio               = PINTDAV_GPIO85,
+       .ts_x_plate_ohm         = 200,
+       .ts_stab_time           = 500,          /* 500 usec */
+       .ts_hw_avg              = 16,
+};
+
+static struct spi_board_info apollon_spi_board_info[] __initdata = {
+       [0] = {
+               .modalias               = "tsc2101",
+               .bus_num                = 1,
+               .chip_select            = 0,
+               .max_speed_hz           = 6000000,
+               .controller_data        = &tsc2101_mcspi_config,
+               .platform_data          = &tsc2101_platform_config,
+       },
+};
+
 static void __init omap_apollon_init(void)
 {
        apollon_led_init();
@@ -373,6 +403,8 @@ static void __init omap_apollon_init(void)
         * You have to mux them off in device drivers later on
         * if not needed.
         */
+       spi_register_board_info(apollon_spi_board_info,
+                               ARRAY_SIZE(apollon_spi_board_info));
        platform_add_devices(apollon_devices, ARRAY_SIZE(apollon_devices));
        omap_board_config = apollon_config;
        omap_board_config_size = ARRAY_SIZE(apollon_config);

Thank you,
Kyungmin Park

[-- Attachment #2: tsc2101.patch --]
[-- Type: application/octet-stream, Size: 35017 bytes --]

diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index 6b46c9b..da5caea 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -159,4 +159,17 @@ config TOUCHSCREEN_UCB1400
 	  To compile this driver as a module, choose M here: the
 	  module will be called ucb1400_ts.
 
+config TOUCHSCREEN_TSC2101
+	tristate "TSC2101 touchscreen support"
+	depends on SPI_TSC2101
+	help
+	  Say Y here if you have a touchscreen interface using the
+	  TSC2101 controller, and your board-specific initialization
+	  code includes that in its table of SPI devices.
+
+	  If unsure, say N (but it's safe to say "Y").
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called tsc2101_ts.
+
 endif
diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile
index 061bc14..973154b 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -16,5 +16,6 @@ obj-$(CONFIG_TOUCHSCREEN_PENMOUNT)	+= penmount.o
 obj-$(CONFIG_TOUCHSCREEN_TOUCHRIGHT)	+= touchright.o
 obj-$(CONFIG_TOUCHSCREEN_TOUCHWIN)	+= touchwin.o
 obj-$(CONFIG_TOUCHSCREEN_UCB1400)	+= ucb1400_ts.o
+obj-$(CONFIG_TOUCHSCREEN_TSC2101)	+= tsc2101_ts.o
 obj-$(CONFIG_TOUCHSCREEN_TSC2102)	+= tsc2102_ts.o
 obj-$(CONFIG_TOUCHSCREEN_OMAP)	+= omap/
diff --git a/drivers/input/touchscreen/tsc2101_ts.c b/drivers/input/touchscreen/tsc2101_ts.c
new file mode 100644
index 0000000..8dc6378
--- /dev/null
+++ b/drivers/input/touchscreen/tsc2101_ts.c
@@ -0,0 +1,715 @@
+/*
+ * TSC2101 touchscreen driver
+ *
+ * Copyright (C) 2005-2006 Nokia Corporation
+ *
+ * Copyright (C) 2007 Samsung Electronics
+ * Kyungmin Park <kyungmin.park@samsung.com>
+ *
+ * Derived from TSC2301 written by Jarkko Oikarinen, Imre Deak and Juha Yrjola
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/input.h>
+#include <linux/interrupt.h>
+#include <linux/delay.h>
+#include <linux/spi/spi.h>
+
+#ifdef CONFIG_ARCH_OMAP
+#include <asm/arch/gpio.h>
+#endif
+
+#include <linux/spi/tsc2101.h>
+
+/**
+ * The touchscreen interface operates as follows:
+ *
+ * Initialize:
+ *    Request access to GPIO (DAV)
+ *    tsc2101_dav_irq_handler will trigger when DAV line goes down
+ *
+ *  1) Pen is pressed against touchscreeen
+ *  2) TSC2101 performs AD conversion
+ *  3) After the conversion is done TSC2101 drives DAV line down
+ *  4) GPIO IRQ is received and tsc2101_dav_irq_handler is called
+ *  5) tsc2101_dav_irq_handler sets up tsc2101_ts_timer in TSC2101_TS_SCAN_TIME
+ *  6) tsc2101_ts_timer disables the irq and requests spi driver
+ *     to read X, Y, Z1 and Z2
+ *  7) SPI framework calls tsc2101_ts_rx after the coordinates are read
+ *  8) tsc2101_ts_rx reports coordinates to input layer and
+ *     sets up tsc2101_ts_timer to be called after TSC2101_TS_SCAN_TIME
+ *  9) if tsc2101_tx_timer notices that the pen has been lifted, the lift event
+ *     is sent, and irq is again enabled.
+ */
+
+
+#define TSC2101_TOUCHSCREEN_PRODUCT_ID      		0x0052
+#define TSC2101_TOUCHSCREEN_PRODUCT_VERSION 		0x0001
+
+#define TSC2101_TS_SCAN_TIME		     		1
+
+#define TSC2101_ADCREG_CONVERSION_CTRL_BY_TSC2101	0x8000
+#define TSC2101_ADCREG_CONVERSION_CTRL_BY_HOST		0x0000
+
+#define TSC2101_ADCREG_FUNCTION_NONE			0x0000
+#define TSC2101_ADCREG_FUNCTION_XY			0x0400
+#define TSC2101_ADCREG_FUNCTION_XYZ			0x0800
+#define TSC2101_ADCREG_FUNCTION_X			0x0C00
+#define TSC2101_ADCREG_FUNCTION_Y			0x1000
+#define TSC2101_ADCREG_FUNCTION_Z			0x1400
+#define TSC2101_ADCREG_FUNCTION_DAT1			0x1800
+#define TSC2101_ADCREG_FUNCTION_DAT2			0x1C00
+#define TSC2101_ADCREG_FUNCTION_AUX1			0x2000
+#define TSC2101_ADCREG_FUNCTION_AUX2			0x2400
+#define TSC2101_ADCREG_FUNCTION_TEMP			0x2800
+
+#define TSC2101_ADCREG_RESOLUTION_8BIT			0x0100
+#define TSC2101_ADCREG_RESOLUTION_10BIT			0x0200
+#define TSC2101_ADCREG_RESOLUTION_12BIT			0x0300
+
+#define TSC2101_ADCREG_AVERAGING_NONE			0x0000
+#define TSC2101_ADCREG_AVERAGING_4AVG			0x0040
+#define TSC2101_ADCREG_AVERAGING_8AVG			0x0080
+#define TSC2101_ADCREG_AVERAGING_16AVG			0x00C0
+
+#define TSC2101_ADCREG_CLOCK_8MHZ			0x0000
+#define TSC2101_ADCREG_CLOCK_4MHZ			0x0010
+#define TSC2101_ADCREG_CLOCK_2MHZ			0x0020
+#define TSC2101_ADCREG_CLOCK_1MHZ			0x0030
+
+#define TSC2101_ADCREG_VOLTAGE_STAB_0US			0x0000
+#define TSC2101_ADCREG_VOLTAGE_STAB_100US		0x0002
+#define TSC2101_ADCREG_VOLTAGE_STAB_500US		0x0004
+#define TSC2101_ADCREG_VOLTAGE_STAB_1MS			0x0006
+#define TSC2101_ADCREG_VOLTAGE_STAB_5MS			0x0008
+#define TSC2101_ADCREG_VOLTAGE_STAB_10MS		0x000A
+#define TSC2101_ADCREG_VOLTAGE_STAB_50MS		0x000C
+#define TSC2101_ADCREG_VOLTAGE_STAB_100MS		0x000E
+
+#define TSC2101_ADCREG_STOP_CONVERSION			0x4000
+
+#define TSC2101_STATUSREG_DAV				0x4000
+#define TSC2101_PROGREG_DELAY				0x0900
+
+#define MAX_12BIT					((1 << 12) - 1)
+
+struct tsc2101_ts {
+	struct input_dev	*idev;
+	char			phys[32];
+	struct timer_list	timer;
+	spinlock_t		lock;
+
+	struct spi_transfer	read_xfer[2];
+	struct spi_message	read_msg;
+	u32                     data[4];
+
+	int			hw_avg_max;
+	u16			x;
+	u16			y;
+	u16			p;
+	int			sample_cnt;
+
+	int			ignore_last : 1;
+	u16			x_plate_ohm;
+	int			stab_time;
+	int			max_pressure;
+	int			touch_pressure;
+	int			pressure_limit;
+
+	u16			irq_enabled:1;
+	u16			pen_down:1;
+	u16			disabled:1;
+	u16			pending:1;
+
+	int			hw_flags;
+
+	s16			dav_gpio;
+	int			irq;
+};
+
+static int tsc2101_ts_check_config(struct tsc2101_ts *ts, int *hw_flags)
+{
+	int flags;
+
+	flags = 0;
+	switch (ts->hw_avg_max) {
+	case 0:
+		flags |= TSC2101_ADCREG_AVERAGING_NONE;
+		break;
+	case 4:
+		flags |= TSC2101_ADCREG_AVERAGING_4AVG;
+		break;
+	case 8:
+		flags |= TSC2101_ADCREG_AVERAGING_8AVG;
+		break;
+	case 16:
+		flags |= TSC2101_ADCREG_AVERAGING_16AVG;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	switch (ts->stab_time) {
+	case 0:
+		flags |= TSC2101_ADCREG_VOLTAGE_STAB_0US;
+		break;
+	case 100:
+		flags |= TSC2101_ADCREG_VOLTAGE_STAB_100US;
+		break;
+	case 500:
+		flags |= TSC2101_ADCREG_VOLTAGE_STAB_500US;
+		break;
+	case 1000:
+		flags |= TSC2101_ADCREG_VOLTAGE_STAB_1MS;
+		break;
+	case 5000:
+		flags |= TSC2101_ADCREG_VOLTAGE_STAB_5MS;
+		break;
+	case 10000:
+		flags |= TSC2101_ADCREG_VOLTAGE_STAB_10MS;
+		break;
+	case 50000:
+		flags |= TSC2101_ADCREG_VOLTAGE_STAB_50MS;
+		break;
+	case 100000:
+		flags |= TSC2101_ADCREG_VOLTAGE_STAB_100MS;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	*hw_flags = flags;
+	return 0;
+}
+
+/* XXX: tsc2101 specific */
+static int tsc2101_ts_configure(struct tsc2101 *tsc, int flags)
+{
+	struct spi_transfer xfer[6];
+	struct spi_transfer *x;
+	struct spi_message m;
+	int reg;
+	u32 val, adc_val;
+	u32 data[6];
+
+	/*
+	 * TSC2101-controlled conversions
+	 * 12-bit samples
+	 * continuous X,Y,Z1,Z2 scan mode
+	 * average (mean) 16 samples per coordinate
+	 * 1 MHz internal conversion clock
+	 * 500 usec panel voltage stabilization delay
+	 * => 0x8bf4
+	 */
+	/* Averaging and voltage stabilization settings in flags */
+	adc_val = TSC2101_ADCREG_CONVERSION_CTRL_BY_TSC2101 |
+		TSC2101_ADCREG_FUNCTION_XYZ |
+		TSC2101_ADCREG_RESOLUTION_12BIT |
+		TSC2101_ADCREG_CLOCK_1MHZ |
+		flags;
+	printk("adc val = 0x%08x\n", adc_val);
+
+	/* Now we prepare the command for transferring */
+	/* Use internal reference clock */
+	reg = TSC2101_REG_REF;
+	val = 0x0016;
+	data[0] = (reg << 16) | val;
+
+	reg = TSC2101_REG_CONFIG;
+	val = 0x0008;
+	data[1] = (reg << 16) | val;
+
+	reg = TSC2101_REG_BUFFER;
+	val = 0x0;
+	data[2] = (reg << 16) | val;
+
+	reg = TSC2101_REG_PROG_DELAY;
+	val = 0x0900;
+	data[3] = (reg << 16) | val;
+
+	reg = TSC2101_REG_STATUS;
+	val = TSC2101_STATUSREG_DAV;
+	data[4] = (reg << 16) | val;
+
+	reg = TSC2101_REG_ADC;
+	data[5] = (reg << 16) | adc_val;
+
+	spi_message_init(&m);
+	m.spi = tsc->spi;
+
+	memset(xfer, 0, sizeof(xfer));
+	x = &xfer[0];
+
+	x->tx_buf = &data[0];
+	x->len = 4;
+	x->cs_change = 1;
+	spi_message_add_tail(x, &m);
+
+	x++;
+	x->tx_buf = &data[1];
+	x->len = 4;
+	x->cs_change = 1;
+	spi_message_add_tail(x, &m);
+
+	x++;
+	x->tx_buf = &data[2];
+	x->len = 4;
+	spi_message_add_tail(x, &m);
+
+	x++;
+	x->tx_buf = &data[3];
+	x->len = 4;
+	spi_message_add_tail(x, &m);
+
+	x++;
+	x->tx_buf = &data[4];
+	x->len = 4;
+	spi_message_add_tail(x, &m);
+
+	x++;
+	x->tx_buf = &data[5];
+	x->len = 4;
+	spi_message_add_tail(x, &m);
+
+	spi_sync(m.spi, &m);
+
+	return 0;
+}
+
+static void tsc2101_ts_start_scan(struct tsc2101 *tsc)
+{
+	tsc2101_ts_configure(tsc, tsc->ts->hw_flags);
+}
+
+static void tsc2101_ts_stop_scan(struct tsc2101 *tsc)
+{
+	tsc2101_ts_configure(tsc, TSC2101_ADCREG_STOP_CONVERSION);
+}
+
+static int device_suspended(struct device *dev)
+{
+	struct tsc2101 *tsc = dev_get_drvdata(dev);
+	return dev->power.power_state.event != PM_EVENT_ON || tsc->ts->disabled;
+}
+
+static void update_pen_state(struct tsc2101_ts *ts, int x, int y, int pressure)
+{
+	int sync = 0;
+
+	if (pressure) {
+		input_report_abs(ts->idev, ABS_X, x);
+		input_report_abs(ts->idev, ABS_Y, y);
+		input_report_abs(ts->idev, ABS_PRESSURE, pressure);
+		if (!ts->pen_down)
+			input_report_key(ts->idev, BTN_TOUCH, 1);
+		sync = 1;
+	} else if (ts->pen_down) {
+		input_report_abs(ts->idev, ABS_PRESSURE, 0);
+		input_report_key(ts->idev, BTN_TOUCH, 0);
+		sync = 1;
+	}
+
+	if (sync)
+		input_sync(ts->idev);
+
+	ts->pen_down = pressure ? 1 : 0;
+#ifdef VERBOSE
+	dev_dbg(&tsc->spi->dev, "x %4d y %4d p %4d\n", x, y, pressure);
+#endif
+}
+
+/* XXX: TSC2101 specific */
+/*
+ * This procedure is called by the SPI framework after the coordinates
+ * have been read from TSC2101
+ */
+static void tsc2101_ts_rx(void *arg)
+{
+	struct tsc2101 *tsc = arg;
+	struct tsc2101_ts *ts = tsc->ts;
+	unsigned int x, y, z1, z2, pressure;
+
+	x  = ts->data[0] & 0xffff;
+	y  = ts->data[1] & 0xffff;
+	z1 = ts->data[2] & 0xffff;
+	z2 = ts->data[3] & 0xffff;
+
+	if (z1) {
+		pressure = ts->x_plate_ohm * x;
+		pressure /= 4096;
+		pressure *= z2 - z1;
+		pressure /= z1;
+	} else
+		pressure = 0;
+
+	/* If pressure value is above a preset limit (pen is barely
+	 * touching the screen) we can't trust the coordinate values.
+	 */
+	if (pressure < ts->pressure_limit && x < MAX_12BIT && y < MAX_12BIT) {
+		ts->pressure_limit = ts->max_pressure;
+		if (ts->ignore_last) {
+			if (ts->sample_cnt)
+				update_pen_state(ts, ts->x, ts->y, ts->p);
+			ts->x = x;
+			ts->y = y;
+			ts->p = pressure;
+		} else
+			update_pen_state(ts, x, y, pressure);
+		ts->sample_cnt++;
+	}
+
+	mod_timer(&ts->timer,
+		  jiffies + msecs_to_jiffies(TSC2101_TS_SCAN_TIME));
+}
+
+static int is_pen_down(struct tsc2101_ts *ts)
+{
+	return ts->pen_down;
+}
+
+/*
+ * Timer is called every TSC2101_TS_SCAN_TIME when the pen is down
+ */
+static void tsc2101_ts_timer(unsigned long arg)
+{
+	struct tsc2101 *tsc = (void *) arg;
+	struct tsc2101_ts *ts = tsc->ts;
+	unsigned long flags;
+	int ndav;
+	int r;
+
+	spin_lock_irqsave(&ts->lock, flags);
+	ndav = omap_get_gpio_datain(ts->dav_gpio);
+	if (ndav || device_suspended(&tsc->spi->dev)) {
+		/* Pen has been lifted */
+		if (!device_suspended(&tsc->spi->dev)) {
+			ts->irq_enabled = 1;
+			enable_irq(ts->irq);
+		}
+		update_pen_state(ts, 0, 0, 0);
+		ts->pending = 0;
+		spin_unlock_irqrestore(&ts->lock, flags);
+
+	} else {
+		ts->pen_down = 1;
+		spin_unlock_irqrestore(&ts->lock, flags);
+
+		r = spi_async(tsc->spi, &ts->read_msg);
+		if (r)
+			dev_err(&tsc->spi->dev, "ts: spi_async() failed");
+	}
+}
+
+/*
+ * This interrupt is called when pen is down and first coordinates are
+ * available. That is indicated by a falling edge on DEV line.  IRQ is
+ * disabled here because while the pen is down the coordinates are
+ * read by a timer.
+ */
+static irqreturn_t tsc2101_ts_irq_handler(int irq, void *dev_id)
+{
+	struct tsc2101 *tsc = dev_id;
+	struct tsc2101_ts *ts = tsc->ts;
+	unsigned long flags;
+
+	spin_lock_irqsave(&ts->lock, flags);
+	if (ts->irq_enabled) {
+		ts->irq_enabled = 0;
+		disable_irq(ts->irq);
+		ts->pending = 1;
+		ts->pressure_limit = ts->touch_pressure;
+		ts->sample_cnt = 0;
+		mod_timer(&ts->timer,
+			  jiffies + msecs_to_jiffies(TSC2101_TS_SCAN_TIME));
+	}
+	spin_unlock_irqrestore(&ts->lock, flags);
+
+	return IRQ_HANDLED;
+}
+
+/* Must be called with ts->lock held */
+static void tsc2101_ts_disable(struct tsc2101 *tsc)
+{
+	struct tsc2101_ts *ts = tsc->ts;
+
+	if (ts->disabled)
+		return;
+
+	ts->disabled = 1;
+	if (!ts->pending) {
+		ts->irq_enabled = 0;
+		disable_irq(ts->irq);
+	} else {
+		while (ts->pending) {
+			spin_unlock_irq(&ts->lock);
+			msleep(1);
+			spin_lock_irq(&ts->lock);
+		}
+	}
+
+	spin_unlock_irq(&ts->lock);
+	tsc2101_ts_stop_scan(tsc);
+	spin_lock_irq(&ts->lock);
+}
+
+static void tsc2101_ts_enable(struct tsc2101 *tsc)
+{
+	struct tsc2101_ts *ts = tsc->ts;
+
+	if (!ts->disabled)
+		return;
+
+	ts->disabled = 0;
+	ts->irq_enabled = 1;
+	enable_irq(ts->irq);
+
+	spin_unlock_irq(&ts->lock);
+	tsc2101_ts_start_scan(tsc);
+	spin_lock_irq(&ts->lock);
+}
+
+#ifdef CONFIG_PM
+int tsc2101_ts_suspend(struct tsc2101 *tsc)
+{
+	struct tsc2101_ts *ts = tsc->ts;
+
+	spin_lock_irq(&ts->lock);
+	tsc2101_ts_disable(tsc);
+	spin_unlock_irq(&ts->lock);
+
+	return 0;
+}
+
+void tsc2101_ts_resume(struct tsc2101 *tsc)
+{
+	struct tsc2101_ts *ts = tsc->ts;
+
+	spin_lock_irq(&ts->lock);
+	tsc2101_ts_enable(tsc);
+	spin_unlock_irq(&ts->lock);
+}
+#endif
+
+void tsc2101_ts_prep_for_clk_stop(struct tsc2101 *tsc)
+{
+}
+
+void tsc2101_ts_cont_after_clk_stop(struct tsc2101 *tsc)
+{
+}
+
+/* XXX: tsc2101 specific */
+static u32 tsc2101_ts_read_data[] = {
+	(0x8000 | TSC2101_REG_X) << 16,
+	(0x8000 | TSC2101_REG_Y) << 16,
+	(0x8000 | TSC2101_REG_Z1) << 16,
+	(0x8000 | TSC2101_REG_Z2) << 16,
+};
+
+static void tsc2101_ts_setup_spi_xfer(struct tsc2101 *tsc)
+{
+	struct tsc2101_ts *ts = tsc->ts;
+	struct spi_message *m = &ts->read_msg;
+	struct spi_transfer *x = &ts->read_xfer[0];
+
+	spi_message_init(m);
+
+	x->tx_buf = &tsc2101_ts_read_data;
+	x->rx_buf = &ts->data;
+	x->len = 16;
+	spi_message_add_tail(x, m);
+
+	m->complete = tsc2101_ts_rx;
+	m->context = tsc;
+}
+
+static ssize_t tsc2101_ts_pen_down_show(struct device *dev,
+					struct device_attribute *attr,
+					char *buf)
+{
+	struct tsc2101 *tsc = dev_get_drvdata(dev);
+
+	return sprintf(buf, "%u\n", is_pen_down(tsc->ts));
+}
+
+static DEVICE_ATTR(pen_down, S_IRUGO, tsc2101_ts_pen_down_show, NULL);
+
+static ssize_t tsc2101_ts_disable_show(struct device *dev,
+				       struct device_attribute *attr, char *buf)
+{
+	struct tsc2101		*tsc = dev_get_drvdata(dev);
+	struct tsc2101_ts	*ts = tsc->ts;
+
+	return sprintf(buf, "%u\n", ts->disabled);
+}
+
+static ssize_t tsc2101_ts_disable_store(struct device *dev,
+					struct device_attribute *attr,
+					const char *buf, size_t count)
+{
+	struct tsc2101		*tsc = dev_get_drvdata(dev);
+	struct tsc2101_ts	*ts = tsc->ts;
+	char *endp;
+	int i;
+
+	i = simple_strtoul(buf, &endp, 10);
+	spin_lock_irq(&ts->lock);
+
+	if (i)
+		tsc2101_ts_disable(tsc);
+	else
+		tsc2101_ts_enable(tsc);
+
+	spin_unlock_irq(&ts->lock);
+
+	return count;
+}
+
+static DEVICE_ATTR(disable_ts, 0664, tsc2101_ts_disable_show,
+		   tsc2101_ts_disable_store);
+
+int __devinit tsc2101_ts_init(struct tsc2101 *tsc,
+			      struct tsc2101_platform_data *pdata)
+{
+	struct tsc2101_ts *ts;
+	struct input_dev *idev;
+	int dav_gpio, r;
+
+	if (pdata->dav_gpio < 0) {
+		dev_err(&tsc->spi->dev, "need DAV GPIO");
+		return -EINVAL;
+	}
+	dav_gpio = pdata->dav_gpio;
+
+	ts = kzalloc(sizeof(*ts), GFP_KERNEL);
+	if (ts == NULL)
+		return -ENOMEM;
+	tsc->ts = ts;
+
+	ts->dav_gpio = dav_gpio;
+#ifdef CONFIG_ARCH_OMAP
+	r = omap_request_gpio(dav_gpio);
+	if (r < 0) {
+		dev_err(&tsc->spi->dev, "unable to get DAV GPIO");
+		goto err1;
+	}
+	omap_set_gpio_direction(dav_gpio, 1);
+	ts->irq = OMAP_GPIO_IRQ(dav_gpio);
+#endif
+	init_timer(&ts->timer);
+	ts->timer.data = (unsigned long) tsc;
+	ts->timer.function = tsc2101_ts_timer;
+
+	spin_lock_init(&ts->lock);
+
+	ts->x_plate_ohm	= pdata->ts_x_plate_ohm ? : 280;
+	ts->hw_avg_max	= pdata->ts_hw_avg;
+	ts->max_pressure= pdata->ts_max_pressure ? : MAX_12BIT;
+	ts->touch_pressure = pdata->ts_touch_pressure ? : ts->max_pressure;
+	ts->ignore_last	= pdata->ts_ignore_last;
+	ts->stab_time	= pdata->ts_stab_time;
+
+	if ((r = tsc2101_ts_check_config(ts, &ts->hw_flags))) {
+		dev_err(&tsc->spi->dev, "invalid configuration\n");
+		goto err2;
+	}
+
+	idev = input_allocate_device();
+	if (idev == NULL) {
+		r = -ENOMEM;
+		goto err2;
+	}
+	idev->cdev.dev = &tsc->spi->dev;
+	idev->name = "TSC2101 touchscreen";
+	snprintf(ts->phys, sizeof(ts->phys),
+		 "%s/input-ts", tsc->spi->dev.bus_id);
+	idev->phys = ts->phys;
+
+	idev->evbit[0] = BIT(EV_ABS) | BIT(EV_KEY);
+	idev->absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE);
+	ts->idev = idev;
+
+	tsc2101_ts_setup_spi_xfer(tsc);
+
+	/* These parameters should perhaps be configurable? */
+	input_set_abs_params(idev, ABS_X, 0, 4096, 0, 0);
+	input_set_abs_params(idev, ABS_Y, 0, 4096, 0, 0);
+	input_set_abs_params(idev, ABS_PRESSURE, 0, 1024, 0, 0);
+
+	tsc2101_ts_start_scan(tsc);
+
+	ts->irq_enabled = 1;
+	r = request_irq(ts->irq, tsc2101_ts_irq_handler,
+			SA_SAMPLE_RANDOM | SA_TRIGGER_FALLING,
+			"tsc2101-ts", tsc);
+	if (r < 0) {
+		dev_err(&tsc->spi->dev, "unable to get DAV IRQ");
+		goto err3;
+	}
+	set_irq_wake(ts->irq, 1);
+
+	r = device_create_file(&tsc->spi->dev, &dev_attr_pen_down);
+	r = device_create_file(&tsc->spi->dev, &dev_attr_disable_ts);
+
+	r = input_register_device(idev);
+	if (r < 0) {
+		dev_err(&tsc->spi->dev, "can't register touchscreen device\n");
+		goto err4;
+	}
+
+	return 0;
+err4:
+	device_remove_file(&tsc->spi->dev, &dev_attr_disable_ts);
+	device_remove_file(&tsc->spi->dev, &dev_attr_pen_down);
+	free_irq(ts->irq, tsc);
+err3:
+	tsc2101_ts_stop_scan(tsc);
+	input_free_device(idev);
+err2:
+#ifdef CONFIG_ARCH_OMAP
+	omap_free_gpio(dav_gpio);
+#endif
+err1:
+	kfree(ts);
+	return r;
+}
+
+void __devexit tsc2101_ts_exit(struct tsc2101 *tsc)
+{
+	struct tsc2101_ts *ts = tsc->ts;
+	unsigned long flags;
+
+	spin_lock_irqsave(&ts->lock, flags);
+	tsc2101_ts_disable(tsc);
+	spin_unlock_irqrestore(&ts->lock, flags);
+
+	device_remove_file(&tsc->spi->dev, &dev_attr_disable_ts);
+	device_remove_file(&tsc->spi->dev, &dev_attr_pen_down);
+
+	free_irq(ts->irq, tsc);
+	input_unregister_device(ts->idev);
+
+#ifdef CONFIG_ARCH_OMAP
+	omap_free_gpio(ts->dav_gpio);
+#endif
+	kfree(ts);
+}
+
+MODULE_AUTHOR("Jarkko Oikarinen, Kyungmin Park");
+MODULE_DESCRIPTION("Touchscreen driver for TSC2101");
+MODULE_LICENSE("GPL");
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index c98392c..64f59e0 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -149,6 +149,21 @@ config SPI_OMAP24XX
 comment "SPI Protocol Masters"
 	depends on SPI_MASTER
 
+config SPI_TSC2101
+	tristate "TSC2101 driver"
+	depends on SPI_MASTER
+	help
+	  Say Y here if you have a TSC2101 chip connected to a SPI
+	  bus on your board.
+
+	  The TSC2101 is a highly integrated PDA analog interface circuit.
+	  It contains a complete 12-bit A/D resistive touch screen
+	  converter (ADC) including drivers, touch pressure measurement
+	  capability.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called tsc2101.
+
 config TSC2102
 	depends on SPI_MASTER
 	tristate "TSC2102 codec support"
diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile
index bfa8ea3..810ff0f 100644
--- a/drivers/spi/Makefile
+++ b/drivers/spi/Makefile
@@ -24,6 +24,7 @@ obj-$(CONFIG_SPI_OMAP_UWIRE)		+= omap_uwire.o
 # 	... add above this line ...
 
 # SPI protocol drivers (device/link on bus)
+obj-$(CONFIG_SPI_TSC2101)		+= tsc2101.o
 obj-$(CONFIG_TSC2102)			+= tsc2102.o
 obj-$(CONFIG_SPI_AT25)		+= at25.o
 obj-$(CONFIG_SPI_TSC2301)		+= tsc2301.o
diff --git a/drivers/spi/tsc2101.c b/drivers/spi/tsc2101.c
new file mode 100644
index 0000000..6c8b1a4
--- /dev/null
+++ b/drivers/spi/tsc2101.c
@@ -0,0 +1,280 @@
+/*
+ * TSC2101 driver
+ *
+ * Copyright (C) 2005, 2006 Nokia Corporation
+ *
+ * Copyright (C) 2007 Samsung Electronics
+ * Kyungmin Park <kyungmin.park@samsung.com>
+ *
+ * Derived from TSC2301 written by Juha Yrjola
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <linux/module.h>
+#include <linux/device.h>
+#include <linux/delay.h>
+#include <linux/spi/spi.h>
+#include <linux/spi/tsc2101.h>
+
+#ifdef CONFIG_ARCH_OMAP
+#include <asm/arch/gpio.h>
+#endif
+
+u16 tsc2101_read_reg(struct tsc2101 *tsc, int reg)
+{
+	struct spi_transfer t[2];
+	struct spi_message m;
+	u32 data = 0, cmd;
+
+	memset(&t, 0, sizeof(t));
+	spi_message_init(&m);
+	m.spi = tsc->spi;
+
+	if (tsc->spi->bits_per_word == 32) {
+		cmd = 0x8000 | reg;
+		cmd <<= 16;
+		
+		t[0].tx_buf = &cmd;
+		t[0].rx_buf = &data;
+		t[0].len = 4;
+		spi_message_add_tail(&t[0], &m);
+	} else {
+		/* Address */
+		cmd = 0x8000 | reg;
+		t[0].tx_buf = &cmd;
+		t[0].rx_buf = NULL;
+		t[0].len = 2;
+		spi_message_add_tail(&t[0], &m);
+
+		/* Data */
+		t[1].tx_buf = NULL;
+		t[1].rx_buf = &data;
+		t[1].len = 2;
+		spi_message_add_tail(&t[1], &m);
+	}
+
+	spi_sync(m.spi, &m);
+
+	return (data & 0xffff);
+}
+
+void tsc2101_write_reg(struct tsc2101 *tsc, int reg, u16 val)
+{
+	struct spi_transfer t;
+	struct spi_message m;
+	u32 data;
+
+	spi_message_init(&m);
+	m.spi = tsc->spi;
+
+	/* Now we prepare the command for transferring */
+	if (tsc->spi->bits_per_word == 32)
+		data = (reg << 16) | val;
+	else
+		data = (val << 16) | reg;
+
+	memset(&t, 0, sizeof(t));
+	t.tx_buf = &data;
+	t.rx_buf = NULL;
+	t.len = 4;
+	spi_message_add_tail(&t, &m);
+
+	spi_sync(m.spi, &m);
+}
+
+void tsc2101_read_buf(struct tsc2101 *tsc, int reg, u16 *rx_buf, int len)
+{
+	/* Not yet implemented... */
+}
+
+void tsc2101_enable_mclk(struct device *dev)
+{
+	struct tsc2101 *tsc = dev_get_drvdata(dev);
+
+	if (tsc->enable_clock == NULL)
+		return;
+
+	tsc->enable_clock(dev);
+}
+
+void tsc2101_disable_mclk(struct device *dev)
+{
+	struct tsc2101 *tsc = dev_get_drvdata(dev);
+
+	might_sleep();
+	if (tsc->disable_clock == NULL)
+		return;
+
+	/* Submodules might need to take action before stopping the
+	 * clock. Keypad scanning needs to be stopped / restarted for one.
+	 */
+	if (tsc->ts != NULL)
+		tsc2101_ts_prep_for_clk_stop(tsc);
+	if (tsc->mixer != NULL)
+		tsc2101_mixer_prep_for_clk_stop(tsc);
+
+	tsc->disable_clock(dev);
+
+	if (tsc->mixer != NULL)
+		tsc2101_mixer_cont_after_clk_stop(tsc);
+	if (tsc->ts != NULL)
+		tsc2101_ts_cont_after_clk_stop(tsc);
+}
+
+static int __devinit tsc2101_probe(struct spi_device *spi)
+{
+	struct tsc2101			*tsc;
+	struct tsc2101_platform_data	*pdata = spi->dev.platform_data;
+	int r;
+
+	if (!pdata) {
+		dev_dbg(&spi->dev, "no platform data?\n");
+		return -ENODEV;
+	}
+
+	printk("TSC2101 driver initializing\n");
+
+	tsc = kzalloc(sizeof(*tsc), GFP_KERNEL);
+	if (tsc == NULL)
+		return -ENOMEM;
+
+	dev_set_drvdata(&spi->dev, tsc);
+	tsc->spi = spi;
+	spi->dev.power.power_state = PMSG_ON;
+
+	tsc->enable_clock = pdata->enable_clock;
+	tsc->disable_clock = pdata->disable_clock;
+
+	if (pdata->reset_gpio >= 0) {
+		tsc->reset_gpio = pdata->reset_gpio;
+#ifdef CONFIG_ARCH_OMAP
+		r = omap_request_gpio(tsc->reset_gpio);
+		if (r < 0)
+			goto err1;
+		omap_set_gpio_dataout(tsc->reset_gpio, 1);
+		omap_set_gpio_direction(tsc->reset_gpio, 0);
+		mdelay(1);
+		omap_set_gpio_dataout(tsc->reset_gpio, 0);
+#endif
+	} else
+		tsc->reset_gpio = -1;
+
+	spi->mode = SPI_MODE_0;
+	if (pdata->bits_per_word)
+		spi->bits_per_word = pdata->bits_per_word;
+	else
+		spi->bits_per_word = 16;
+
+	/* The max speed might've been defined by the board-specific struct */
+	if (!spi->max_speed_hz)
+		spi->max_speed_hz = TSC2101_HZ;
+	spi_setup(spi);
+
+	if (pdata->init) {
+		r = pdata->init(spi);
+		if (r)
+			goto err1;
+	}
+
+	r = tsc2101_ts_init(tsc, pdata);
+	if (r)
+		goto err1;
+	r = tsc2101_mixer_init(tsc, pdata);
+	if (r)
+		goto err2;
+	return 0;
+
+err2:
+	tsc2101_ts_exit(tsc);
+err1:
+	kfree(tsc);
+	return r;
+}
+
+static int __devexit tsc2101_remove(struct spi_device *spi)
+{
+	struct tsc2101_platform_data *pdata;
+	struct tsc2101 *tsc = dev_get_drvdata(&spi->dev);
+
+	pdata = spi->dev.platform_data;
+
+	if (pdata->cleanup)
+		pdata->cleanup(spi);
+
+	tsc2101_mixer_exit(tsc);
+        tsc2101_ts_exit(tsc);
+	kfree(tsc);
+
+	return 0;
+}
+
+#ifdef CONFIG_PM
+static int tsc2101_suspend(struct spi_device *spi, pm_message_t mesg)
+{
+	struct tsc2101 *tsc = dev_get_drvdata(&spi->dev);
+	int r;
+
+	if ((r = tsc2101_mixer_suspend(tsc)) < 0)
+		return r;
+	if ((r = tsc2101_ts_suspend(tsc)) < 0)
+		goto err1;
+
+	return 0;
+err1:
+	tsc2101_mixer_resume(tsc);
+	return r;
+}
+
+static int tsc2101_resume(struct spi_device *spi)
+{
+	struct tsc2101 *tsc = dev_get_drvdata(&spi->dev);
+
+	tsc2101_ts_resume(tsc);
+	tsc2101_mixer_resume(tsc);
+	return 0;
+}
+#endif
+
+static struct spi_driver tsc2101_driver = {
+	.driver = {
+		   .name = "tsc2101",
+		   .bus = &spi_bus_type,
+		   .owner = THIS_MODULE,
+	},
+#ifdef CONFIG_PM
+	.suspend = tsc2101_suspend,
+	.resume = tsc2101_resume,
+#endif
+	.probe = tsc2101_probe,
+	.remove = __devexit_p(tsc2101_remove),
+};
+
+static int __init tsc2101_init(void)
+{
+	return spi_register_driver(&tsc2101_driver);
+}
+
+static void __exit tsc2101_exit(void)
+{
+	spi_unregister_driver(&tsc2101_driver);
+}
+
+module_init(tsc2101_init);
+module_exit(tsc2101_exit);
+
+MODULE_AUTHOR("Imre Deak, Kyungmin Park");
+MODULE_DESCRIPTION("SPI Interface driver for TI TSC2101 chips");
+MODULE_LICENSE("GPL");
diff --git a/include/linux/spi/tsc2101.h b/include/linux/spi/tsc2101.h
new file mode 100644
index 0000000..22b803f
--- /dev/null
+++ b/include/linux/spi/tsc2101.h
@@ -0,0 +1,203 @@
+#ifndef _LINUX_SPI_TSC2101_H
+#define _LINUX_SPI_TSC2101_H
+
+#include <linux/types.h>
+#include <linux/timer.h>
+
+struct tsc2101_platform_data {
+	unsigned	bits_per_word;
+	int		(*init)(struct spi_device *spi);
+	void		(*cleanup)(struct spi_device *spi);
+
+	/*
+	 * Keypad
+	 */
+	s16	reset_gpio;
+	s16	keyb_int;
+	s16	keymap[16];	/* Set a key to a negative value if not used */
+	unsigned kp_rep:1;	/* Enable keypad repeating */
+
+	/*
+	 * Touchscreen
+	 */
+	s16	dav_gpio;
+	s16	pen_int_gpio;
+	u16	ts_x_plate_ohm;
+	u32	ts_stab_time;	/* voltage settling time */
+	u8	ts_hw_avg;	/* HW assiseted averaging. Can be
+				   0, 4, 8, 16 samples per reading */
+	u32	ts_max_pressure;/* Samples with bigger pressure value will
+				   be ignored, since the corresponding X, Y
+				   values are unreliable */
+	u32	ts_touch_pressure;	/* Pressure limit until we report a
+					   touch event. After that we switch
+					   to ts_max_pressure. */
+	unsigned ts_ignore_last : 1;
+
+	/*
+	 * Audio
+	 */
+	unsigned	pll_pdc:4;
+	unsigned	pll_a:4;
+	unsigned	pll_n:4;
+	unsigned	pll_output:1; /* Output PLL on GPIO_0 */
+
+	unsigned	mclk_ratio:2;
+	unsigned	i2s_sample_rate:4;
+	unsigned	i2s_format:2;
+	/* Mask for audio blocks to be powered down */
+	u16		power_down_blocks;
+
+	/* Called after codec has been initialized, can be NULL */
+	int (* codec_init)(struct device *tsc2101_dev);
+	/* Called when codec is being removed, can be NULL */
+	void (* codec_cleanup)(struct device *tsc2101_dev);
+	int	(*enable_clock)(struct device *dev);
+	void	(*disable_clock)(struct device *dev);
+	int	(*get_keyb_irq_state)(struct device *dev);
+
+	const struct tsc2101_mixer_gpio {
+		const char	*name;
+		unsigned	gpio:4;
+		unsigned	inverted:1;
+		unsigned	def_enable:1; /* enable by default */
+		unsigned	deactivate_on_pd:1; /* power-down flag */
+	} *mixer_gpios;
+	int	n_mixer_gpios;
+};
+
+struct tsc2101_kp;
+struct tsc2101_ts;
+struct tsc2101_mixer;
+
+struct tsc2101 {
+	struct spi_device	*spi;
+
+	s16			reset_gpio;
+	u16			config2_shadow;
+
+        struct tsc2101_kp	*kp;
+	struct tsc2101_ts	*ts;
+	struct tsc2101_mixer	*mixer;
+
+	int			(*enable_clock)(struct device *dev);
+	void			(*disable_clock)(struct device *dev);
+};
+
+
+#define TSC2101_HZ	33000000
+
+#define TSC2101_REG(page, addr)  (((page) << 11) | ((addr) << 5))
+#define TSC2101_REG_TO_PAGE(reg) (((reg) >> 11) & 0x03)
+#define TSC2101_REG_TO_ADDR(reg) (((reg) >> 5)  & 0x1f)
+
+#define TSC2101_REG_X		TSC2101_REG(0, 0)
+#define TSC2101_REG_Y		TSC2101_REG(0, 1)
+#define TSC2101_REG_Z1		TSC2101_REG(0, 2)
+#define TSC2101_REG_Z2		TSC2101_REG(0, 3)
+
+#define TSC2101_REG_ADC		TSC2101_REG(1, 0)
+#define TSC2101_REG_STATUS	TSC2101_REG(1, 1)
+#define TSC2101_REG_BUFFER	TSC2101_REG(1, 2)
+#define TSC2101_REG_REF		TSC2101_REG(1, 3)
+#define TSC2101_REG_CONFIG	TSC2101_REG(1, 5)
+#define TSC2101_REG_PROG_DELAY	TSC2101_REG(1, 13)
+
+#define TSC2101_REG_AUDIO1	TSC2101_REG(2, 0)
+#define TSC2101_REG_DAC_GAIN	TSC2101_REG(2, 2)
+#define TSC2101_REG_AUDIO2	TSC2101_REG(2, 4)
+#define TSC2101_REG_DAC_POWER	TSC2101_REG(2, 5)
+#define TSC2101_REG_AUDIO3	TSC2101_REG(2, 6)
+#define TSC2101_REG_ADCLKCFG	TSC2101_REG(2, 27)
+
+#define TSC2101_REG_PD_MISC_APD		(1 << 15)
+#define TSC2101_REG_PD_MISC_AVPD	(1 << 14)
+#define TSC2101_REG_PD_MISC_ABPD	(1 << 13)
+#define TSC2101_REG_PD_MISC_HAPD	(1 << 12)
+#define TSC2101_REG_PD_MISC_MOPD	(1 << 11)
+#define TSC2101_REG_PD_MISC_DAPD	(1 << 10)
+#define TSC2101_REG_PD_MISC_ADPDL	(1 << 9)
+#define TSC2101_REG_PD_MISC_ADPDR	(1 << 8)
+#define TSC2101_REG_PD_MISC_PDSTS	(1 << 7)
+#define TSC2101_REG_PD_MISC_MIBPD	(1 << 6)
+
+/* I2S sample rate */
+#define TSC2101_I2S_SR_48000	0x00
+#define TSC2101_I2S_SR_44100	0x01
+#define TSC2101_I2S_SR_32000	0x02
+#define TSC2101_I2S_SR_24000	0x03
+#define TSC2101_I2S_SR_22050	0x04
+#define TSC2101_I2S_SR_16000	0x05
+#define TSC2101_I2S_SR_12000	0x06
+#define TSC2101_I2S_SR_11050	0x07
+#define TSC2101_I2S_SR_8000	0x08
+
+/* 16-bit, MSB-first. DAC Right-Justified, ADC Left-Justified */
+#define TSC2101_I2S_FORMAT0	0x00
+/* 20-bit, MSB-first. DAC Right-Justified, ADC Left-Justified */
+#define TSC2101_I2S_FORMAT1	0x01
+/* 20-bit, MSB-first. DAC Left-Justified, ADC Left-Justified */
+#define TSC2101_I2S_FORMAT2	0x02
+/* 20-bit, MSB-first */
+#define TSC2101_I2S_FORMAT3	0x03
+
+/* Master Clock Ratio */
+#define TSC2101_MCLK_256xFS	0x00 /* default */
+#define TSC2101_MCLK_384xFS	0x01
+#define TSC2101_MCLK_512xFS	0x02
+
+
+extern u16 tsc2101_read_reg(struct tsc2101 *tsc, int reg);
+extern void tsc2101_write_reg(struct tsc2101 *tsc, int reg, u16 val);
+extern void tsc2101_write_kbc(struct tsc2101 *tsc, int val);
+extern void tsc2101_write_pll(struct tsc2101 *tsc, int pll_n, int pll_a,
+			      int pll_pdc, int pct_e, int pll_o);
+extern void tsc2101_read_buf(struct tsc2101 *tsc, int reg, u16 *buf, int len);
+
+#define TSC2101_DECL_MOD(module)					\
+extern int  tsc2101_##module##_init(struct tsc2101 *tsc,		\
+			   struct tsc2101_platform_data *pdata);	\
+extern void tsc2101_##module##_exit(struct tsc2101 *tsc);		\
+extern void tsc2101_##module##_prep_for_clk_stop(struct tsc2101 *tsc);	\
+extern void tsc2101_##module##_cont_after_clk_stop(struct tsc2101 *tsc);\
+extern int  tsc2101_##module##_suspend(struct tsc2101 *tsc);		\
+extern void tsc2101_##module##_resume(struct tsc2101 *tsc);
+
+#define TSC2101_DECL_EMPTY_MOD(module)					\
+static inline int tsc2101_##module##_init(struct tsc2101 *tsc,		\
+			   struct tsc2101_platform_data *pdata)		\
+{									\
+	return 0;							\
+}									\
+static inline void tsc2101_##module##_exit(struct tsc2101 *tsc) {}	\
+static inline void tsc2101_##module##_prep_for_clk_stop			\
+					(struct tsc2101 *tsc) {}	\
+static inline void tsc2101_##module##_cont_after_clk_stop		\
+					(struct tsc2101 *tsc) {}	\
+static inline int  tsc2101_##module##_suspend(struct tsc2101 *tsc)	\
+{									\
+	return 0;							\
+}									\
+static inline void tsc2101_##module##_resume(struct tsc2101 *tsc) {}
+
+#ifdef CONFIG_TOUCHSCREEN_TSC2101
+TSC2101_DECL_MOD(ts)
+#else
+TSC2101_DECL_EMPTY_MOD(ts)
+#endif
+
+#ifdef CONFIG_SND_SOC_TSC2101
+TSC2101_DECL_MOD(mixer)
+extern void tsc2101_mixer_set_power(struct device *tsc_dev, int dac, int adc);
+
+struct snd_card;
+extern int tsc2101_mixer_register_controls(struct device *tsc_dev,
+					   struct snd_card *card);
+#else
+TSC2101_DECL_EMPTY_MOD(mixer)
+#endif
+
+extern void tsc2101_enable_mclk(struct device *tsc_dev);
+extern void tsc2101_disable_mclk(struct device *tsc_dev);
+
+#endif

[-- Attachment #3: Type: text/plain, Size: 0 bytes --]



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

* Re: TSC2101/2102
  2007-03-20  1:46                           ` TSC2101/2102 Kyungmin Park
@ 2007-03-20 13:27                             ` tony
  2007-03-20 13:54                               ` TSC2101/2102 Jarkko Nikula
  0 siblings, 1 reply; 35+ messages in thread
From: tony @ 2007-03-20 13:27 UTC (permalink / raw)
  To: Kyungmin Park; +Cc: 'Linux OMAP ML'

Hi,

* Kyungmin Park <kmpark@infradead.org> [070319 21:47]:
> 
> Umm the new updated git tree don't have tsc2301 commit. maybe it's missing :)

Just want to verify we haven't lost anything.. Are you talking about
commit a7b9b17c9025066cd05f555bbba5542bcf16df3a or something else?

At least a7b9b17c9025066cd05f555bbba5542bcf16df3a is there, if it's some
other commit you're talking about please let me know.

The commits in the master tree currently get buried easily as we have a
long series of patches in omap-upstream and omap-drivers and I keep rebasing
them continuously. This problem should disappear for most part once
omap-upstream is merged into Linus' tree.

Regards,

Tony

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

* Re: TSC2101/2102
  2007-03-20 13:27                             ` TSC2101/2102 tony
@ 2007-03-20 13:54                               ` Jarkko Nikula
  2007-03-20 15:38                                 ` TSC2101/2102 Tony Lindgren
  0 siblings, 1 reply; 35+ messages in thread
From: Jarkko Nikula @ 2007-03-20 13:54 UTC (permalink / raw)
  To: ext tony@atomide.com; +Cc: 'Linux OMAP ML', Kyungmin Park

> > Umm the new updated git tree don't have tsc2301 commit. maybe it's
> > missing :)
> 
> Just want to verify we haven't lost anything.. Are you talking about
> commit a7b9b17c9025066cd05f555bbba5542bcf16df3a or something else?
> 
Yep, that and some other recent commits were missing from
linux-omap tree in kernel.org. Now both kernel.org and
source.mvista.com linux-omap trees seems to be in sync.


Jarkko

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

* Re: TSC2101/2102
  2007-03-20 13:54                               ` TSC2101/2102 Jarkko Nikula
@ 2007-03-20 15:38                                 ` Tony Lindgren
  2007-03-21 19:24                                   ` TSC2101/2102 Eduardo Valentin
  0 siblings, 1 reply; 35+ messages in thread
From: Tony Lindgren @ 2007-03-20 15:38 UTC (permalink / raw)
  To: Jarkko Nikula; +Cc: 'Linux OMAP ML', Kyungmin Park

* Jarkko Nikula <jarkko.nikula@nokia.com> [070320 09:56]:
> > > Umm the new updated git tree don't have tsc2301 commit. maybe it's
> > > missing :)
> > 
> > Just want to verify we haven't lost anything.. Are you talking about
> > commit a7b9b17c9025066cd05f555bbba5542bcf16df3a or something else?
> > 
> Yep, that and some other recent commits were missing from
> linux-omap tree in kernel.org. Now both kernel.org and
> source.mvista.com linux-omap trees seems to be in sync.

OK, thanks for verifying. The kernel.org tree was out of sync for
last week. In general they should be in sync though.

Tony

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

* Re: TSC2101/2102
  2007-03-20 15:38                                 ` TSC2101/2102 Tony Lindgren
@ 2007-03-21 19:24                                   ` Eduardo Valentin
  2007-03-22  6:48                                     ` TSC2101/2102 Jarkko Nikula
  0 siblings, 1 reply; 35+ messages in thread
From: Eduardo Valentin @ 2007-03-21 19:24 UTC (permalink / raw)
  To: Tony Lindgren; +Cc: Linux OMAP ML, Kyungmin Park

[-- Attachment #1: Type: text/plain, Size: 1251 bytes --]

Hello all,

SPI API has changed. Following this discussion, this patch fixes OMAP
H2 LCD initialization.

This patch (patch-lcd-h2-spi-fix.diff) applies on top of Imre Deak's
patch (spi-tsc2101-patch.diff).


Signed-off-by: Imre Deak <imre.deak@solidboot.com>
Signed-off-by: Eduardo Valentin <eduardo.valentin@indt.org.br>

--
Eduardo Valentin

On 3/20/07, Tony Lindgren <tony@atomide.com> wrote:
> * Jarkko Nikula <jarkko.nikula@nokia.com> [070320 09:56]:
> > > > Umm the new updated git tree don't have tsc2301 commit. maybe it's
> > > > missing :)
> > >
> > > Just want to verify we haven't lost anything.. Are you talking about
> > > commit a7b9b17c9025066cd05f555bbba5542bcf16df3a or something else?
> > >
> > Yep, that and some other recent commits were missing from
> > linux-omap tree in kernel.org. Now both kernel.org and
> > source.mvista.com linux-omap trees seems to be in sync.
>
> OK, thanks for verifying. The kernel.org tree was out of sync for
> last week. In general they should be in sync though.
>
> Tony
> _______________________________________________
> Linux-omap-open-source mailing list
> Linux-omap-open-source@linux.omap.com
> http://linux.omap.com/mailman/listinfo/linux-omap-open-source
>


-- 
Eduardo Bezerra Valentin

[-- Attachment #2: spi-tsc2101-patch.diff --]
[-- Type: text/x-patch, Size: 25839 bytes --]

Index: linux-omap-2.6/arch/arm/configs/omap_h2_1610_defconfig
===================================================================
--- linux-omap-2.6.orig/arch/arm/configs/omap_h2_1610_defconfig	2007-03-21 15:11:12.000000000 -0400
+++ linux-omap-2.6/arch/arm/configs/omap_h2_1610_defconfig	2007-03-21 15:12:49.000000000 -0400
@@ -1,11 +1,14 @@
 #
 # Automatically generated make config: don't edit
-# Linux kernel version: 2.6.20-rc3-omap1
-# Thu Jan  4 16:07:28 2007
+# Linux kernel version: 2.6.21-rc3-omap1
+# Tue Mar 13 14:36:54 2007
 #
 CONFIG_ARM=y
+CONFIG_SYS_SUPPORTS_APM_EMULATION=y
+CONFIG_GENERIC_GPIO=y
 # CONFIG_GENERIC_TIME is not set
 CONFIG_MMU=y
+# CONFIG_NO_IOPORT is not set
 CONFIG_GENERIC_HARDIRQS=y
 CONFIG_TRACE_IRQFLAGS_SUPPORT=y
 CONFIG_HARDIRQS_SW_RESEND=y
@@ -15,6 +18,7 @@ CONFIG_RWSEM_GENERIC_SPINLOCK=y
 # CONFIG_ARCH_HAS_ILOG2_U64 is not set
 CONFIG_GENERIC_HWEIGHT=y
 CONFIG_GENERIC_CALIBRATE_DELAY=y
+CONFIG_ZONE_DMA=y
 CONFIG_VECTORS_BASE=0xffff0000
 CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
 
@@ -33,6 +37,7 @@ CONFIG_LOCALVERSION_AUTO=y
 CONFIG_SWAP=y
 CONFIG_SYSVIPC=y
 # CONFIG_IPC_NS is not set
+CONFIG_SYSVIPC_SYSCTL=y
 # CONFIG_POSIX_MQUEUE is not set
 # CONFIG_BSD_PROCESS_ACCT is not set
 # CONFIG_TASKSTATS is not set
@@ -41,6 +46,7 @@ CONFIG_SYSVIPC=y
 # CONFIG_IKCONFIG is not set
 CONFIG_SYSFS_DEPRECATED=y
 # CONFIG_RELAY is not set
+CONFIG_BLK_DEV_INITRD=y
 CONFIG_INITRAMFS_SOURCE=""
 CONFIG_CC_OPTIMIZE_FOR_SIZE=y
 CONFIG_SYSCTL=y
@@ -120,6 +126,7 @@ CONFIG_DEFAULT_IOSCHED="anticipatory"
 # CONFIG_ARCH_IXP2000 is not set
 # CONFIG_ARCH_IXP23XX is not set
 # CONFIG_ARCH_L7200 is not set
+# CONFIG_ARCH_NS9XXX is not set
 # CONFIG_ARCH_PNX4008 is not set
 # CONFIG_ARCH_PXA is not set
 # CONFIG_ARCH_RPC is not set
@@ -149,6 +156,8 @@ CONFIG_OMAP_MUX_DEBUG=y
 CONFIG_OMAP_MUX_WARNINGS=y
 # CONFIG_OMAP_STI is not set
 CONFIG_OMAP_MCBSP=y
+# CONFIG_OMAP_MMU_FWK is not set
+# CONFIG_OMAP_MBOX_FWK is not set
 CONFIG_OMAP_MPU_TIMER=y
 # CONFIG_OMAP_32K_TIMER is not set
 # CONFIG_OMAP_DM_TIMER is not set
@@ -207,6 +216,7 @@ CONFIG_ARM_THUMB=y
 # CONFIG_CPU_DCACHE_DISABLE is not set
 # CONFIG_CPU_DCACHE_WRITETHROUGH is not set
 # CONFIG_CPU_CACHE_ROUND_ROBIN is not set
+# CONFIG_OUTER_CACHE is not set
 
 #
 # Bus support
@@ -234,6 +244,7 @@ CONFIG_FLAT_NODE_MEM_MAP=y
 # CONFIG_SPARSEMEM_STATIC is not set
 CONFIG_SPLIT_PTLOCK_CPUS=4096
 # CONFIG_RESOURCES_64BIT is not set
+CONFIG_ZONE_DMA_FLAG=1
 CONFIG_LEDS=y
 # CONFIG_LEDS_TIMER is not set
 # CONFIG_LEDS_CPU is not set
@@ -246,6 +257,7 @@ CONFIG_ZBOOT_ROM_TEXT=0x0
 CONFIG_ZBOOT_ROM_BSS=0x0
 CONFIG_CMDLINE="mem=32M console=ttyS0,115200n8 root=/dev/ram0 rw initrd=0x10600000,8M ramdisk_size=8192"
 # CONFIG_XIP_KERNEL is not set
+# CONFIG_KEXEC is not set
 
 #
 # CPU Frequency scaling
@@ -279,7 +291,7 @@ CONFIG_PM=y
 # CONFIG_PM_LEGACY is not set
 # CONFIG_PM_DEBUG is not set
 # CONFIG_PM_SYSFS_DEPRECATED is not set
-# CONFIG_APM is not set
+# CONFIG_APM_EMULATION is not set
 
 #
 # Networking
@@ -296,6 +308,7 @@ CONFIG_UNIX=y
 CONFIG_XFRM=y
 # CONFIG_XFRM_USER is not set
 # CONFIG_XFRM_SUB_POLICY is not set
+# CONFIG_XFRM_MIGRATE is not set
 # CONFIG_NET_KEY is not set
 CONFIG_INET=y
 # CONFIG_IP_MULTICAST is not set
@@ -380,6 +393,7 @@ CONFIG_STANDALONE=y
 CONFIG_PREVENT_FIRMWARE_BUILD=y
 # CONFIG_FW_LOADER is not set
 CONFIG_DEBUG_DRIVER=y
+# CONFIG_DEBUG_DEVRES is not set
 # CONFIG_SYS_HYPERVISOR is not set
 
 #
@@ -403,6 +417,7 @@ CONFIG_MTD_CMDLINE_PARTS=y
 # User Modules And Translation Layers
 #
 CONFIG_MTD_CHAR=y
+CONFIG_MTD_BLKDEVS=y
 CONFIG_MTD_BLOCK=y
 # CONFIG_FTL is not set
 # CONFIG_NFTL is not set
@@ -448,6 +463,8 @@ CONFIG_MTD_CFI_UTIL=y
 #
 # Self-contained MTD device drivers
 #
+# CONFIG_MTD_DATAFLASH is not set
+# CONFIG_MTD_M25P80 is not set
 # CONFIG_MTD_SLRAM is not set
 # CONFIG_MTD_PHRAM is not set
 # CONFIG_MTD_MTDRAM is not set
@@ -478,6 +495,7 @@ CONFIG_MTD_CFI_UTIL=y
 #
 # Plug and Play support
 #
+# CONFIG_PNPACPI is not set
 
 #
 # Block devices
@@ -491,7 +509,6 @@ CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_COUNT=16
 CONFIG_BLK_DEV_RAM_SIZE=8192
 CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
-CONFIG_BLK_DEV_INITRD=y
 # CONFIG_CDROM_PKTCDVD is not set
 # CONFIG_ATA_OVER_ETH is not set
 
@@ -677,7 +694,6 @@ CONFIG_WATCHDOG_NOWAYOUT=y
 # CONFIG_USBPCWATCHDOG is not set
 CONFIG_HW_RANDOM=m
 CONFIG_HW_RANDOM_OMAP=m
-# CONFIG_OMAP_RNG is not set
 # CONFIG_NVRAM is not set
 CONFIG_OMAP_RTC=y
 # CONFIG_DTLK is not set
@@ -733,8 +749,22 @@ CONFIG_TPS65010=y
 #
 # SPI support
 #
-# CONFIG_SPI is not set
-# CONFIG_SPI_MASTER is not set
+CONFIG_SPI=y
+# CONFIG_SPI_DEBUG is not set
+CONFIG_SPI_MASTER=y
+
+#
+# SPI Master Controller Drivers
+#
+# CONFIG_SPI_BITBANG is not set
+# CONFIG_SPI_OMAP_UWIRE is not set
+
+#
+# SPI Protocol Masters
+#
+CONFIG_TSC2101=y
+# CONFIG_TSC2102 is not set
+# CONFIG_SPI_AT25 is not set
 
 #
 # Dallas's 1-wire bus
@@ -750,6 +780,7 @@ CONFIG_HWMON=y
 # CONFIG_SENSORS_ADM1021 is not set
 # CONFIG_SENSORS_ADM1025 is not set
 # CONFIG_SENSORS_ADM1026 is not set
+# CONFIG_SENSORS_ADM1029 is not set
 # CONFIG_SENSORS_ADM1031 is not set
 # CONFIG_SENSORS_ADM9240 is not set
 # CONFIG_SENSORS_ASB100 is not set
@@ -762,6 +793,7 @@ CONFIG_HWMON=y
 # CONFIG_SENSORS_GL520SM is not set
 # CONFIG_SENSORS_IT87 is not set
 # CONFIG_SENSORS_LM63 is not set
+# CONFIG_SENSORS_LM70 is not set
 # CONFIG_SENSORS_LM75 is not set
 # CONFIG_SENSORS_LM77 is not set
 # CONFIG_SENSORS_LM78 is not set
@@ -790,7 +822,11 @@ CONFIG_HWMON=y
 #
 # Misc devices
 #
-# CONFIG_TIFM_CORE is not set
+
+#
+# Multifunction device drivers
+#
+# CONFIG_MFD_SM501 is not set
 
 #
 # LED devices
@@ -819,23 +855,30 @@ CONFIG_HWMON=y
 #
 # Graphics support
 #
-CONFIG_FIRMWARE_EDID=y
+# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
 CONFIG_FB=y
+CONFIG_FIRMWARE_EDID=y
+# CONFIG_FB_DDC is not set
 # CONFIG_FB_CFB_FILLRECT is not set
 # CONFIG_FB_CFB_COPYAREA is not set
 # CONFIG_FB_CFB_IMAGEBLIT is not set
+# CONFIG_FB_SVGALIB is not set
 # CONFIG_FB_MACMODES is not set
 # CONFIG_FB_BACKLIGHT is not set
 CONFIG_FB_MODE_HELPERS=y
 # CONFIG_FB_TILEBLITTING is not set
+
+#
+# Frambuffer hardware drivers
+#
 # CONFIG_FB_S1D13XXX is not set
-# CONFIG_FB_VIRTUAL is not set
 CONFIG_FB_OMAP=y
 # CONFIG_FB_OMAP_LCDC_EXTERNAL is not set
 # CONFIG_FB_OMAP_LCD_MIPID is not set
 # CONFIG_FB_OMAP_BOOTLOADER_INIT is not set
 CONFIG_FB_OMAP_CONSISTENT_DMA_SIZE=2
 # CONFIG_FB_OMAP_DMA_TUNE is not set
+# CONFIG_FB_VIRTUAL is not set
 
 #
 # Console display driver support
@@ -855,7 +898,6 @@ CONFIG_LOGO=y
 # CONFIG_LOGO_LINUX_MONO is not set
 # CONFIG_LOGO_LINUX_VGA16 is not set
 CONFIG_LOGO_LINUX_CLUT224=y
-# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
 
 #
 # Sound
@@ -866,6 +908,7 @@ CONFIG_LOGO_LINUX_CLUT224=y
 # HID Devices
 #
 CONFIG_HID=y
+# CONFIG_HID_DEBUG is not set
 
 #
 # USB support
@@ -880,10 +923,8 @@ CONFIG_USB=y
 # Miscellaneous USB options
 #
 CONFIG_USB_DEVICEFS=y
-# CONFIG_USB_BANDWIDTH is not set
 # CONFIG_USB_DYNAMIC_MINORS is not set
 CONFIG_USB_SUSPEND=y
-# CONFIG_USB_MULTITHREAD_PROBE is not set
 CONFIG_USB_OTG=y
 CONFIG_USB_OTG_WHITELIST=y
 # CONFIG_USB_OTG_BLACKLIST_HUB is not set
@@ -893,7 +934,8 @@ CONFIG_USB_OTG_WHITELIST=y
 #
 # CONFIG_USB_ISP116X_HCD is not set
 CONFIG_USB_OHCI_HCD=y
-# CONFIG_USB_OHCI_BIG_ENDIAN is not set
+# CONFIG_USB_OHCI_BIG_ENDIAN_DESC is not set
+# CONFIG_USB_OHCI_BIG_ENDIAN_MMIO is not set
 CONFIG_USB_OHCI_LITTLE_ENDIAN=y
 # CONFIG_USB_SL811_HCD is not set
 # CONFIG_USB_MUSB_HDRC is not set
@@ -936,6 +978,7 @@ CONFIG_USB_OHCI_LITTLE_ENDIAN=y
 # CONFIG_USB_ATI_REMOTE2 is not set
 # CONFIG_USB_KEYSPAN_REMOTE is not set
 # CONFIG_USB_APPLETOUCH is not set
+# CONFIG_USB_GTCO is not set
 
 #
 # USB Imaging devices
@@ -972,6 +1015,7 @@ CONFIG_USB_MON=y
 # CONFIG_USB_RIO500 is not set
 # CONFIG_USB_LEGOTOWER is not set
 # CONFIG_USB_LCD is not set
+# CONFIG_USB_BERRY_CHARGE is not set
 # CONFIG_USB_LED is not set
 # CONFIG_USB_CYPRESS_CY7C63 is not set
 # CONFIG_USB_CYTHERM is not set
@@ -981,6 +1025,7 @@ CONFIG_USB_MON=y
 # CONFIG_USB_APPLEDISPLAY is not set
 # CONFIG_USB_LD is not set
 # CONFIG_USB_TRANCEVIBRATOR is not set
+# CONFIG_USB_IOWARRIOR is not set
 CONFIG_USB_TEST=y
 
 #
@@ -1022,12 +1067,6 @@ CONFIG_RTC_LIB=y
 # CONFIG_RTC_CLASS is not set
 
 #
-# Synchronous Serial Interfaces (SSI)
-#
-CONFIG_OMAP_UWIRE=y
-# CONFIG_OMAP_TSC2101 is not set
-
-#
 # CBUS support
 #
 # CONFIG_CBUS is not set
@@ -1199,15 +1238,16 @@ CONFIG_ENABLE_MUST_CHECK=y
 # CONFIG_DEBUG_FS is not set
 # CONFIG_HEADERS_CHECK is not set
 CONFIG_DEBUG_KERNEL=y
+# CONFIG_DEBUG_SHIRQ is not set
 CONFIG_LOG_BUF_SHIFT=14
 CONFIG_DETECT_SOFTLOCKUP=y
 # CONFIG_SCHEDSTATS is not set
+# CONFIG_TIMER_STATS is not set
 # CONFIG_DEBUG_SLAB is not set
 # CONFIG_DEBUG_RT_MUTEXES is not set
 # CONFIG_RT_MUTEX_TESTER is not set
 # CONFIG_DEBUG_SPINLOCK is not set
 # CONFIG_DEBUG_MUTEXES is not set
-# CONFIG_DEBUG_RWSEMS is not set
 # CONFIG_DEBUG_SPINLOCK_SLEEP is not set
 # CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
 # CONFIG_DEBUG_KOBJECT is not set
@@ -1218,6 +1258,7 @@ CONFIG_DEBUG_INFO=y
 CONFIG_FRAME_POINTER=y
 CONFIG_FORCED_INLINING=y
 # CONFIG_RCU_TORTURE_TEST is not set
+# CONFIG_FAULT_INJECTION is not set
 CONFIG_DEBUG_USER=y
 CONFIG_DEBUG_ERRORS=y
 # CONFIG_DEBUG_LL is not set
@@ -1244,4 +1285,5 @@ CONFIG_CRC32=y
 CONFIG_ZLIB_INFLATE=y
 CONFIG_ZLIB_DEFLATE=y
 CONFIG_PLIST=y
-CONFIG_IOMAP_COPY=y
+CONFIG_HAS_IOMEM=y
+CONFIG_HAS_IOPORT=y
Index: linux-omap-2.6/arch/arm/mach-omap1/board-h2.c
===================================================================
--- linux-omap-2.6.orig/arch/arm/mach-omap1/board-h2.c	2007-03-21 15:11:12.000000000 -0400
+++ linux-omap-2.6/arch/arm/mach-omap1/board-h2.c	2007-03-21 15:12:49.000000000 -0400
@@ -28,6 +28,9 @@
 #include <linux/mtd/partitions.h>
 #include <linux/input.h>
 #include <linux/workqueue.h>
+#include <linux/clk.h>
+#include <linux/spi/spi.h>
+#include <linux/spi/tsc2101.h>
 
 #include <asm/hardware.h>
 #include <asm/mach-types.h>
@@ -294,6 +297,86 @@ static struct platform_device h2_lcd_dev
 	.id		= -1,
 };
 
+static void h2_lcd_dev_init(struct spi_device *tsc2101)
+{
+	/* The LCD is connected to the GPIO pins of the TSC2101, so
+	 * we have to tie them here. We can also register the LCD driver
+	 * first only here, where we know that the TSC driver is ready.
+	 */
+	h2_lcd_device.dev.platform_data = tsc2101;
+
+	platform_device_add(&h2_lcd_device);
+}
+
+struct {
+	struct clk	*mclk;
+	int		initialized;
+} h2_tsc2101;
+
+static int h2_tsc2101_init(struct spi_device *spi)
+{
+	int r;
+
+	if (h2_tsc2101.initialized) {
+		printk(KERN_ERR "tsc2101: already initialized\n");
+		return -ENODEV;
+	}
+
+	/* Get the MCLK */
+	h2_tsc2101.mclk = clk_get(&spi->dev, "mclk");
+	if (IS_ERR(h2_tsc2101.mclk)) {
+		dev_err(&spi->dev, "unable to get the clock MCLK\n");
+		return PTR_ERR(h2_tsc2101.mclk);
+	}
+	if ((r = clk_set_rate(h2_tsc2101.mclk, 12000000)) < 0) {
+		dev_err(&spi->dev, "unable to set rate to the MCLK\n");
+		goto err;
+	}
+
+	omap_cfg_reg(R10_1610_MCLK_OFF);
+	omap_cfg_reg(N15_1610_UWIRE_CS1);
+
+	h2_lcd_dev_init(spi);
+
+	return 0;
+err:
+	clk_put(h2_tsc2101.mclk);
+	return r;
+}
+
+static void h2_tsc2101_cleanup(struct spi_device *spi)
+{
+	clk_put(h2_tsc2101.mclk);
+	omap_cfg_reg(R10_1610_MCLK_OFF);
+}
+
+static void h2_tsc2101_enable_mclk(struct spi_device *spi)
+{
+	omap_cfg_reg(R10_1610_MCLK_ON);
+}
+
+static void h2_tsc2101_disable_mclk(struct spi_device *spi)
+{
+	omap_cfg_reg(R10_1610_MCLK_OFF);
+}
+
+static struct tsc2101_platform_data h2_tsc2101_platform_data = {
+	.init		= h2_tsc2101_init,
+	.cleanup	= h2_tsc2101_cleanup,
+	.enable_mclk	= h2_tsc2101_enable_mclk,
+	.disable_mclk	= h2_tsc2101_disable_mclk,
+};
+
+static struct spi_board_info h2_spi_board_info[] __initdata = {
+	[0] = {
+		.modalias	= "tsc2101",
+		.bus_num	= 2,
+		.chip_select	= 1,
+		.max_speed_hz	= 16000000,
+		.platform_data	= &h2_tsc2101_platform_data,
+	},
+};
+
 static struct omap_mcbsp_reg_cfg mcbsp_regs = {
 	.spcr2 = FREE | FRST | GRST | XRST | XINTM(3),
 	.spcr1 = RINTM(3) | RRST,
@@ -335,7 +418,6 @@ static struct platform_device *h2_device
 	&h2_smc91x_device,
 	&h2_irda_device,
 	&h2_kp_device,
-	&h2_lcd_device,
 	&h2_mcbsp1_device,
 };
 
@@ -438,6 +520,8 @@ static void __init h2_init(void)
 #endif
 
 	platform_add_devices(h2_devices, ARRAY_SIZE(h2_devices));
+	spi_register_board_info(h2_spi_board_info,
+				ARRAY_SIZE(h2_spi_board_info));
 	omap_board_config = h2_config;
 	omap_board_config_size = ARRAY_SIZE(h2_config);
 	omap_serial_init();
Index: linux-omap-2.6/drivers/spi/Kconfig
===================================================================
--- linux-omap-2.6.orig/drivers/spi/Kconfig	2007-03-21 15:11:12.000000000 -0400
+++ linux-omap-2.6/drivers/spi/Kconfig	2007-03-21 15:12:49.000000000 -0400
@@ -149,6 +149,14 @@ config SPI_OMAP24XX
 comment "SPI Protocol Masters"
 	depends on SPI_MASTER
 
+config TSC2101
+	depends on SPI_MASTER
+	tristate "TSC2101 chip support"
+	---help---
+	  Say Y here if you want support for the TSC2101 chip.
+	  At the moment it provides basic register read / write interface
+	  as well as a way to enable the MCLK clock.
+
 config TSC2102
 	depends on SPI_MASTER
 	tristate "TSC2102 codec support"
Index: linux-omap-2.6/drivers/spi/Makefile
===================================================================
--- linux-omap-2.6.orig/drivers/spi/Makefile	2007-03-21 15:11:12.000000000 -0400
+++ linux-omap-2.6/drivers/spi/Makefile	2007-03-21 15:12:49.000000000 -0400
@@ -24,6 +24,7 @@ obj-$(CONFIG_SPI_OMAP_UWIRE)		+= omap_uw
 # 	... add above this line ...
 
 # SPI protocol drivers (device/link on bus)
+obj-$(CONFIG_TSC2101)			+= tsc2101.o
 obj-$(CONFIG_TSC2102)			+= tsc2102.o
 obj-$(CONFIG_SPI_AT25)		+= at25.o
 obj-$(CONFIG_SPI_TSC2301)		+= tsc2301.o
Index: linux-omap-2.6/drivers/spi/tsc2101.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux-omap-2.6/drivers/spi/tsc2101.c	2007-03-21 15:12:49.000000000 -0400
@@ -0,0 +1,327 @@
+/*
+ * linux/drivers/ssi/omap-tsc2101.c
+ *
+ * TSC2101 codec interface driver for the OMAP platform
+ *
+ * Copyright (C) 2004 Texas Instruments, Inc.
+ *
+ * This package 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.
+ *
+ * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * History:
+ *
+ * 2004/11/07   Nishanth Menon - Modified for common hooks for Audio and Touchscreen
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/sched.h>
+#include <linux/errno.h>
+#include <linux/delay.h>
+#include <linux/clk.h>
+#include <linux/device.h>
+
+#include <asm/system.h>
+#include <asm/irq.h>
+#include <asm/io.h>
+#include <asm/mach-types.h>
+#include <asm/hardware.h>
+
+#include <asm/arch/mux.h>
+#include <asm/arch/io.h>
+#include <asm/arch/hardware.h>
+
+#include <linux/spi/spi.h>
+#include <linux/spi/tsc2101.h>
+
+struct tsc2101_device {
+	struct mutex		mutex;
+	int			mclk_enabled;
+	struct clock		*mclk_ck;
+	struct spi_message	message;
+	struct spi_transfer	transfer[2];
+	u16			command;
+	void			(*enable_mclk)(struct spi_device *spi);
+	void			(*disable_mclk)(struct spi_device *spi);
+};
+
+int tsc2101_enable_mclk(struct spi_device *spi)
+{
+	struct tsc2101_device *tsc2101;
+
+	tsc2101 = spi_get_drvdata(spi);
+
+	mutex_lock(&tsc2101->mutex);
+
+	if (spi->dev.power.power_state.event != PM_EVENT_ON) {
+		mutex_unlock(&tsc2101->mutex);
+		return -ENODEV;
+	}
+
+	if (tsc2101->mclk_enabled++ == 0) {
+		if (tsc2101->enable_mclk != NULL)
+			tsc2101->enable_mclk(spi);
+	}
+
+	mutex_unlock(&tsc2101->mutex);
+	return 0;
+}
+EXPORT_SYMBOL(tsc2101_enable_mclk);
+
+void tsc2101_disable_mclk(struct spi_device *spi)
+{
+	struct tsc2101_device *tsc2101;
+
+	tsc2101 = spi_get_drvdata(spi);
+
+	mutex_lock(&tsc2101->mutex);
+
+	if (--tsc2101->mclk_enabled == 0) {
+		if (tsc2101->disable_mclk != NULL &&
+		    spi->dev.power.power_state.event == PM_EVENT_ON)
+			tsc2101->disable_mclk(spi);
+	}
+
+	mutex_lock(&tsc2101->mutex);
+}
+EXPORT_SYMBOL(tsc2101_disable_mclk);
+
+int tsc2101_write_sync(struct spi_device *spi, int page, u8 address, u16 data)
+{
+	struct tsc2101_device *tsc2101;
+	struct spi_message *m;
+	struct spi_transfer *t;
+	int ret;
+
+	tsc2101 = spi_get_drvdata(spi);
+
+	mutex_lock(&tsc2101->mutex);
+	if (spi->dev.power.power_state.event != PM_EVENT_ON) {
+		mutex_unlock(&tsc2101->mutex);
+		return -ENODEV;
+	}
+
+	m = &tsc2101->message;
+	spi_message_init(m);
+	t = &tsc2101->transfer[0];
+	memset(t, 0, sizeof(tsc2101->transfer));
+
+	/* Address */
+	tsc2101->command = (page << 11) | (address << 5);
+	t->tx_buf = &tsc2101->command;
+	t->len = 2;
+	spi_message_add_tail(t, m);
+
+	/* Data */
+	t++;
+	t->tx_buf = &data;
+	t->len = 2;
+	spi_message_add_tail(t, m);
+
+	ret = spi_sync(spi, m);
+	if (!ret)
+		ret = tsc2101->message.status;
+	mutex_unlock(&tsc2101->mutex);
+
+	return ret;
+}
+EXPORT_SYMBOL(tsc2101_write_sync);
+
+int tsc2101_reads_sync(struct spi_device *spi,
+		       int page, u8 startaddress, u16 *data, int numregs)
+{
+	struct tsc2101_device *tsc2101;
+	struct spi_message *m;
+	struct spi_transfer *t;
+	int ret;
+
+	tsc2101 = spi_get_drvdata(spi);
+
+	mutex_lock(&tsc2101->mutex);
+	if (spi->dev.power.power_state.event != PM_EVENT_ON) {
+		mutex_unlock(&tsc2101->mutex);
+		return -ENODEV;
+	}
+
+	m = &tsc2101->message;
+	spi_message_init(m);
+	t = &tsc2101->transfer[0];
+	memset(t, 0, sizeof(tsc2101->transfer));
+
+	/* Address */
+	tsc2101->command = 0x8000 | (page << 11) | (startaddress << 5);
+	t->tx_buf = &tsc2101->command;
+	t->len = 2;
+	spi_message_add_tail(t, m);
+
+	/* Data */
+	t++;
+	t->rx_buf = data;
+	t->len = numregs << 1;
+	spi_message_add_tail(t, m);
+
+	ret = spi_sync(spi, m);
+	if (!ret)
+		ret = tsc2101->message.status;
+
+	mutex_unlock(&tsc2101->mutex);
+
+	return ret;
+}
+EXPORT_SYMBOL(tsc2101_reads_sync);
+
+int tsc2101_read_sync(struct spi_device *spi, int page, u8 address)
+{
+	int err;
+	u16 val;
+
+	err = tsc2101_reads_sync(spi, page, address, &val, 1);
+	if (err)
+		return err;
+	return val;
+}
+EXPORT_SYMBOL(tsc2101_read_sync);
+
+static int tsc2101_suspend(struct spi_device *spi, pm_message_t state)
+{
+	struct tsc2101_device *tsc2101;
+
+	tsc2101 = spi_get_drvdata(spi);
+
+	if (tsc2101 == NULL)
+		return 0;
+
+	mutex_lock(&tsc2101->mutex);
+
+	spi->dev.power.power_state = state;
+	if (tsc2101->mclk_enabled && tsc2101->disable_mclk != NULL)
+		tsc2101->disable_mclk(spi);
+
+	mutex_unlock(&tsc2101->mutex);
+
+	return 0;
+}
+
+static int tsc2101_resume(struct spi_device *spi)
+{
+	struct tsc2101_device *tsc2101;
+
+	tsc2101 = spi_get_drvdata(spi);
+
+	if (tsc2101 == NULL)
+		return 0;
+
+	mutex_lock(&tsc2101->mutex);
+
+	spi->dev.power.power_state = PMSG_ON;
+	if (tsc2101->mclk_enabled && tsc2101->enable_mclk != NULL)
+		tsc2101->enable_mclk(spi);
+
+	mutex_unlock(&tsc2101->mutex);
+
+	return 0;
+}
+
+static int tsc2101_probe(struct spi_device *spi)
+{
+	struct tsc2101_platform_data *pdata;
+	struct tsc2101_device *tsc2101;
+	u16 w;
+	int r;
+
+	pdata = spi->dev.platform_data;
+	if (pdata == NULL) {
+		dev_err(&spi->dev, "no platform data\n");
+		return -ENODEV;
+	}
+
+	tsc2101 = kzalloc(sizeof(*tsc2101), GFP_KERNEL);
+	if (tsc2101 == NULL) {
+		dev_err(&spi->dev, "out of mem\n");
+		return -ENOMEM;
+	}
+
+	spi_set_drvdata(spi, tsc2101);
+	tsc2101->enable_mclk = pdata->enable_mclk;
+	tsc2101->disable_mclk = pdata->disable_mclk;
+
+	mutex_init(&tsc2101->mutex);
+
+	spi->mode = SPI_MODE_0;
+	spi->bits_per_word = 16;
+	if ((r = spi_setup(spi)) < 0) {
+		dev_err(&spi->dev, "SPI setup failed\n");
+		goto err;
+	}
+
+	w = tsc2101_read_sync(spi, 1, 0);
+	if (!(w & (1 << 14))) {
+		dev_err(&spi->dev, "invalid ADC register value %04x\n", w);
+		goto err;
+	}
+
+	if (pdata->init != NULL) {
+		if ((r = pdata->init(spi)) < 0)
+			goto err;
+	}
+
+	return 0;
+err:
+	kfree(tsc2101);
+	return r;
+}
+
+static int tsc2101_remove(struct spi_device *spi)
+{
+	struct tsc2101_platform_data *pdata;
+	struct tsc2101_device *tsc2101;
+
+	pdata = spi->dev.platform_data;
+	tsc2101 = spi_get_drvdata(spi);
+
+	/* We assume that this can't race with the rest of the driver. */
+	if (tsc2101->mclk_enabled && tsc2101->disable_mclk != NULL)
+		tsc2101->disable_mclk(spi);
+
+	if (pdata->cleanup != NULL)
+		pdata->cleanup(spi);
+
+	spi_set_drvdata(spi, NULL);
+	kfree(tsc2101);
+
+	return 0;
+}
+
+static struct spi_driver tsc2101_driver = {
+	.probe		= tsc2101_probe,
+	.remove		= tsc2101_remove,
+	.suspend	= tsc2101_suspend,
+	.resume		= tsc2101_resume,
+	.driver		= {
+		.name	= "tsc2101",
+		.owner	= THIS_MODULE,
+	},
+};
+
+static int tsc2101_init(void)
+{
+	return spi_register_driver(&tsc2101_driver);
+}
+
+static void tsc2101_exit(void)
+{
+	spi_unregister_driver(&tsc2101_driver);
+}
+
+module_init(tsc2101_init);
+module_exit(tsc2101_exit);
+
+MODULE_AUTHOR("Texas Instruments");
+MODULE_DESCRIPTION
+    ("Glue audio driver for the TI OMAP1610/OMAP1710 TSC2101 codec.");
+MODULE_LICENSE("GPL");
Index: linux-omap-2.6/drivers/video/omap/lcd_h2.c
===================================================================
--- linux-omap-2.6.orig/drivers/video/omap/lcd_h2.c	2007-03-21 15:11:12.000000000 -0400
+++ linux-omap-2.6/drivers/video/omap/lcd_h2.c	2007-03-21 15:12:49.000000000 -0400
@@ -23,42 +23,18 @@
 
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/spi/tsc2101.h>
 
 #include <asm/arch/mux.h>
 #include <asm/arch/omapfb.h>
 
-#include "../drivers/ssi/omap-uwire.h"
-
-#define MODULE_NAME		"omapfb-lcd_h2"
-#define TSC2101_UWIRE_CS	1
-
-#define pr_err(fmt, args...) printk(KERN_ERR MODULE_NAME ": " fmt, ## args)
-
-static int tsc2101_write_reg(int page, int reg, u16 data)
-{
-	u16	cmd;
-	int	r;
-
-	cmd = ((page & 3) << 11) | ((reg & 0x3f) << 5);
-	if (omap_uwire_data_transfer(TSC2101_UWIRE_CS, cmd, 16, 0, NULL, 1))
-		r = -1;
-	else
-		r = omap_uwire_data_transfer(TSC2101_UWIRE_CS, data, 16, 0,
-					     NULL, 0);
-
-	return r;
-}
+static struct {
+	struct platform_device	*lcd_dev;
+	struct spi_device	*tsc2101_dev;
+} h2_panel_dev;
 
 static int h2_panel_init(struct lcd_panel *panel, struct omapfb_device *fbdev)
 {
-	unsigned long uwire_flags;
-
-	 /* Configure N15 pin to be uWire CS1 */
-	omap_cfg_reg(N15_1610_UWIRE_CS1);
-	uwire_flags = UWIRE_READ_RISING_EDGE | UWIRE_WRITE_RISING_EDGE;
-	uwire_flags |= UWIRE_FREQ_DIV_8;
-	omap_uwire_configure_mode(TSC2101_UWIRE_CS, uwire_flags);
-
 	return 0;
 }
 
@@ -73,7 +49,10 @@ static int h2_panel_enable(struct lcd_pa
 	/* Assert LCD_EN, BKLIGHT_EN pins on LCD panel
 	 * page2, GPIO config reg, GPIO(0,1) to out and asserted
 	 */
-	r = tsc2101_write_reg(2, 0x23, 0xCC00) ? -1 : 0;
+	r = tsc2101_write_sync(h2_panel_dev.tsc2101_dev, 2, 0x23, 0xcc00);
+	if (r < 0)
+		dev_err(&h2_panel_dev.lcd_dev->dev,
+			"failed to enable LCD panel\n");
 
 	return r;
 }
@@ -83,8 +62,9 @@ static void h2_panel_disable(struct lcd_
 	/* Deassert LCD_EN and BKLIGHT_EN pins on LCD panel
 	 * page2, GPIO config reg, GPIO(0,1) to out and deasserted
 	 */
-	if (tsc2101_write_reg(2, 0x23, 0x8800))
-		pr_err("failed to disable LCD panel\n");
+	if (tsc2101_write_sync(h2_panel_dev.tsc2101_dev, 2, 0x23, 0x8800))
+		dev_err(&h2_panel_dev.lcd_dev->dev,
+			"failed to disable LCD panel\n");
 }
 
 static unsigned long h2_panel_get_caps(struct lcd_panel *panel)
@@ -117,6 +97,19 @@ struct lcd_panel h2_panel = {
 
 static int h2_panel_probe(struct platform_device *pdev)
 {
+	struct spi_device *tsc2101;
+
+	tsc2101 = dev_get_drvdata(&pdev->dev);
+	if (tsc2101 == NULL) {
+		dev_err(&pdev->dev, "no platform data\n");
+		return -ENODEV;
+	}
+	if (strncmp(tsc2101->modalias, "tsc2101", 8) != 0) {
+		dev_err(&pdev->dev, "tsc2101 not found\n");
+		return -EINVAL;
+	}
+	h2_panel_dev.lcd_dev = pdev;
+	h2_panel_dev.tsc2101_dev = tsc2101;
 	omapfb_register_panel(&h2_panel);
 	return 0;
 }
Index: linux-omap-2.6/include/linux/spi/tsc2101.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux-omap-2.6/include/linux/spi/tsc2101.h	2007-03-21 15:12:49.000000000 -0400
@@ -0,0 +1,43 @@
+/*
+ * linux/drivers/ssi/omap-tsc2101.h
+ *
+ * TSC2101 codec interface driver for the OMAP platform
+ *
+ * Copyright (C) 2004 Texas Instruments, Inc.
+ *
+ * This package 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.
+ *
+ * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * History:
+ *
+ * 2004/11/07   Nishanth Menon - Provided common hooks for Audio and Touchscreen
+ */
+
+#ifndef __OMAP_TSC2101_H
+#define __OMAP_TSC2101_H
+
+#include <linux/spi/spi.h>
+
+struct tsc2101_platform_data {
+	int	(*init)(struct spi_device *spi);
+	void	(*cleanup)(struct spi_device *spi);
+	void	(*enable_mclk)(struct spi_device *spi);
+	void	(*disable_mclk)(struct spi_device *spi);
+};
+
+extern int tsc2101_read_sync(struct spi_device *spi, int page, u8 address);
+extern int tsc2101_reads_sync(struct spi_device *spi, int page,
+			       u8 startaddress, u16 * data, int numregs);
+extern int tsc2101_write_sync(struct spi_device *spi, int page, u8 address,
+			       u16 data);
+
+extern int tsc2101_enable_mclk(struct spi_device *spi);
+extern void tsc2101_disable_mclk(struct spi_device *spi);
+
+#endif
+

[-- Attachment #3: patch-lcd-h2-spi-fix.diff --]
[-- Type: text/x-patch, Size: 2126 bytes --]

[PATCH] OMAP H2 LCD Fixes

SPI API has changed from kernel version 2.6.X to 2.6.20-rc1.
This patch fixes OMAP H2 LCD initialization.

This patch applies on top of Imre Deak's patch:
http://linux.omap.com/pipermail/linux-omap-open-source/2007-March/009334.html

Signed-off-by: Eduardo Valentin <eduardo.valentin@indt.org.br>
---

Index: linux-omap-2.6/arch/arm/configs/omap_h2_1610_defconfig
===================================================================
--- linux-omap-2.6.orig/arch/arm/configs/omap_h2_1610_defconfig	2007-03-21 15:12:49.000000000 -0400
+++ linux-omap-2.6/arch/arm/configs/omap_h2_1610_defconfig	2007-03-21 15:12:56.000000000 -0400
@@ -757,7 +757,7 @@ CONFIG_SPI_MASTER=y
 # SPI Master Controller Drivers
 #
 # CONFIG_SPI_BITBANG is not set
-# CONFIG_SPI_OMAP_UWIRE is not set
+CONFIG_SPI_OMAP_UWIRE=y
 
 #
 # SPI Protocol Masters
Index: linux-omap-2.6/arch/arm/mach-omap1/board-h2.c
===================================================================
--- linux-omap-2.6.orig/arch/arm/mach-omap1/board-h2.c	2007-03-21 15:12:49.000000000 -0400
+++ linux-omap-2.6/arch/arm/mach-omap1/board-h2.c	2007-03-21 15:12:56.000000000 -0400
@@ -303,7 +303,9 @@ static void h2_lcd_dev_init(struct spi_d
 	 * we have to tie them here. We can also register the LCD driver
 	 * first only here, where we know that the TSC driver is ready.
 	 */
-	h2_lcd_device.dev.platform_data = tsc2101;
+	device_initialize(&h2_lcd_device.dev);
+
+	dev_set_drvdata(&h2_lcd_device.dev, tsc2101);
 
 	platform_device_add(&h2_lcd_device);
 }
Index: linux-omap-2.6/sound/arm/Kconfig
===================================================================
--- linux-omap-2.6.orig/sound/arm/Kconfig	2007-03-21 15:11:12.000000000 -0400
+++ linux-omap-2.6/sound/arm/Kconfig	2007-03-21 15:12:56.000000000 -0400
@@ -52,8 +52,8 @@ config SND_OMAP_TSC2101
  	tristate "OMAP TSC2101 alsa driver"
  	depends on ARCH_OMAP && SND
  	select SND_PCM
-         select OMAP_TSC2101
-         select OMAP_UWIRE if ARCH_OMAP
+	 select TSC2101
+	 select SPI_OMAP_UWIRE if ARCH_OMAP
 	 select OMAP_MCBSP
  	help
  	  Say Y here if you have a OMAP platform board

[-- Attachment #4: Type: text/plain, Size: 0 bytes --]



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

* Re: TSC2101/2102
  2007-03-21 19:24                                   ` TSC2101/2102 Eduardo Valentin
@ 2007-03-22  6:48                                     ` Jarkko Nikula
  2007-03-30 18:49                                       ` TSC2101/2102 Tony Lindgren
  0 siblings, 1 reply; 35+ messages in thread
From: Jarkko Nikula @ 2007-03-22  6:48 UTC (permalink / raw)
  To: ext Eduardo Valentin; +Cc: Kyungmin Park, Linux OMAP ML

On Wed, 21 Mar 2007 15:24:21 -0400
"ext Eduardo Valentin" <edubezval@gmail.com> wrote:

> This patch (patch-lcd-h2-spi-fix.diff) applies on top of Imre Deak's
> patch (spi-tsc2101-patch.diff).
> 
Hi, my two cents. It seems that almost everyone forgot to update/remove
path names in comment section when moving files to another directory :-)

spi-tsc2101-patch.diff:

--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux-omap-2.6/drivers/spi/tsc2101.c	2007-03-21
15:12:49.000000000 -0400 @@ -0,0 +1,327 @@
+/*
+ * linux/drivers/ssi/omap-tsc2101.c
+ *

===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux-omap-2.6/include/linux/spi/tsc2101.h	2007-03-21
15:12:49.000000000 -0400 @@ -0,0 +1,43 @@
+/*
+ * linux/drivers/ssi/omap-tsc2101.h
+ *

-- 
Jarkko

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

* Re: TSC2101/2102
  2007-03-14 17:09     ` TSC2101/2102 Imre Deak
  2007-03-14 20:35       ` TSC2101/2102 Dirk Behme
  2007-03-15  1:18       ` TSC2101/2102 Kyungmin Park
@ 2007-03-29 20:26       ` Tony Lindgren
  2 siblings, 0 replies; 35+ messages in thread
From: Tony Lindgren @ 2007-03-29 20:26 UTC (permalink / raw)
  To: Imre Deak; +Cc: Linux OMAP ML

* Imre Deak <imre.deak@solidboot.com> [070314 13:16]:
> On Wed, Mar 14, 2007 at 08:21:24AM -0500, Nishanth Menon wrote:
> > andrzej zaborowski stated on 3/9/2007 8:23 AM:
> > > On 09/03/07, Imre Deak <imre.deak@solidboot.com> wrote:
> > >> I'm wondering about the proper way to convert the existing omap-tsc2101
> > >> driver to the SPI framework. Would it make sense to handle it with the
> > >> tsc2102 driver? omap-tsc2101 has only the register read / write
> > >> interface
> > >> which is the same as in tsc2102.
> > >
> > > How about maybe a header file <linux/spi/tsc2xxx.h> shared between
> > > tsc2101/2102 with the register access functions as "static inline"
> > > functions?
> > Some TODOs:
> > 1. should interrupt muxing be done here?
> > 2. There are some TSC2005 devices(TS only).. so it will be interesting
> > to see xxxx.h scales to all..
> > 3. rename this to tsc2xxx_core.[ch]
> > 4. use SPI framework (would not break uwire support I believe).
> 
> The attached patches try to do #4. Please review it / sign it off as
> necessary.
> 
> There is an upcoming TSC2301 patch, that should also be taken
> into account when creating a tsc2xxx-core.[ch] based on the existing
> TSC driver implementations.

I'll push these 3 patches today.

Tony

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

* Re: TSC2101/2102
  2007-03-22  6:48                                     ` TSC2101/2102 Jarkko Nikula
@ 2007-03-30 18:49                                       ` Tony Lindgren
  2007-03-31 12:52                                         ` TSC2101/2102 Eduardo Valentin
  0 siblings, 1 reply; 35+ messages in thread
From: Tony Lindgren @ 2007-03-30 18:49 UTC (permalink / raw)
  To: Jarkko Nikula; +Cc: Kyungmin Park, Linux OMAP ML

* Jarkko Nikula <jarkko.nikula@nokia.com> [070322 02:50]:
> On Wed, 21 Mar 2007 15:24:21 -0400
> "ext Eduardo Valentin" <edubezval@gmail.com> wrote:
> 
> > This patch (patch-lcd-h2-spi-fix.diff) applies on top of Imre Deak's
> > patch (spi-tsc2101-patch.diff).
> > 
> Hi, my two cents. It seems that almost everyone forgot to update/remove
> path names in comment section when moving files to another directory :-)
> 
> spi-tsc2101-patch.diff:
> 
> --- /dev/null	1970-01-01 00:00:00.000000000 +0000
> +++ linux-omap-2.6/drivers/spi/tsc2101.c	2007-03-21
> 15:12:49.000000000 -0400 @@ -0,0 +1,327 @@
> +/*
> + * linux/drivers/ssi/omap-tsc2101.c
> + *
> 
> ===================================================================
> --- /dev/null	1970-01-01 00:00:00.000000000 +0000
> +++ linux-omap-2.6/include/linux/spi/tsc2101.h	2007-03-21
> 15:12:49.000000000 -0400 @@ -0,0 +1,43 @@
> +/*
> + * linux/drivers/ssi/omap-tsc2101.h
> + *
> 

Kyungmin, Eduardo & Jarkko, please sign your patches above so I can
apply them!

Tony

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

* Re: TSC2101/2102
  2007-03-30 18:49                                       ` TSC2101/2102 Tony Lindgren
@ 2007-03-31 12:52                                         ` Eduardo Valentin
  2007-03-31 17:01                                           ` TSC2101/2102 Imre Deak
  0 siblings, 1 reply; 35+ messages in thread
From: Eduardo Valentin @ 2007-03-31 12:52 UTC (permalink / raw)
  To: Tony Lindgren; +Cc: Linux OMAP ML, Kyungmin Park

[-- Attachment #1: Type: text/plain, Size: 1467 bytes --]

Hello Tony,


    This is an updated patch to fix lcd for H2 board. This one is
applied against
current linux omap (commit ).

    The patch is a merge of what was discussed here and what is already pushed.

Signed-off-by: Eduardo Valentin <eduardo.valentin@indt.org.br>

BR,

Eduardo Valentin

On 3/30/07, Tony Lindgren <tony@atomide.com> wrote:
> * Jarkko Nikula <jarkko.nikula@nokia.com> [070322 02:50]:
> > On Wed, 21 Mar 2007 15:24:21 -0400
> > "ext Eduardo Valentin" <edubezval@gmail.com> wrote:
> >
> > > This patch (patch-lcd-h2-spi-fix.diff) applies on top of Imre Deak's
> > > patch (spi-tsc2101-patch.diff).
> > >
> > Hi, my two cents. It seems that almost everyone forgot to update/remove
> > path names in comment section when moving files to another directory :-)
> >
> > spi-tsc2101-patch.diff:
> >
> > --- /dev/null 1970-01-01 00:00:00.000000000 +0000
> > +++ linux-omap-2.6/drivers/spi/tsc2101.c      2007-03-21
> > 15:12:49.000000000 -0400 @@ -0,0 +1,327 @@
> > +/*
> > + * linux/drivers/ssi/omap-tsc2101.c
> > + *
> >
> > ===================================================================
> > --- /dev/null 1970-01-01 00:00:00.000000000 +0000
> > +++ linux-omap-2.6/include/linux/spi/tsc2101.h        2007-03-21
> > 15:12:49.000000000 -0400 @@ -0,0 +1,43 @@
> > +/*
> > + * linux/drivers/ssi/omap-tsc2101.h
> > + *
> >
>
> Kyungmin, Eduardo & Jarkko, please sign your patches above so I can
> apply them!
>
> Tony
>


-- 
Eduardo Bezerra Valentin

[-- Attachment #2: patch_fix_h2_lcd.diff --]
[-- Type: text/x-patch, Size: 4122 bytes --]

Index: linux-omap-2.6/drivers/video/omap/lcd_h2.c
===================================================================
--- linux-omap-2.6.orig/drivers/video/omap/lcd_h2.c	2007-03-30 14:21:50.000000000 -0400
+++ linux-omap-2.6/drivers/video/omap/lcd_h2.c	2007-03-30 14:22:01.000000000 -0400
@@ -23,42 +23,18 @@
 
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/spi/tsc2101.h>
 
 #include <asm/arch/mux.h>
 #include <asm/arch/omapfb.h>
 
-#include "../drivers/ssi/omap-uwire.h"
-
-#define MODULE_NAME		"omapfb-lcd_h2"
-#define TSC2101_UWIRE_CS	1
-
-#define pr_err(fmt, args...) printk(KERN_ERR MODULE_NAME ": " fmt, ## args)
-
-static int tsc2101_write_reg(int page, int reg, u16 data)
-{
-	u16	cmd;
-	int	r;
-
-	cmd = ((page & 3) << 11) | ((reg & 0x3f) << 5);
-	if (omap_uwire_data_transfer(TSC2101_UWIRE_CS, cmd, 16, 0, NULL, 1))
-		r = -1;
-	else
-		r = omap_uwire_data_transfer(TSC2101_UWIRE_CS, data, 16, 0,
-					     NULL, 0);
-
-	return r;
-}
+static struct {
+	struct platform_device	*lcd_dev;
+	struct spi_device	*tsc2101_dev;
+} h2_panel_dev;
 
 static int h2_panel_init(struct lcd_panel *panel, struct omapfb_device *fbdev)
 {
-	unsigned long uwire_flags;
-
-	 /* Configure N15 pin to be uWire CS1 */
-	omap_cfg_reg(N15_1610_UWIRE_CS1);
-	uwire_flags = UWIRE_READ_RISING_EDGE | UWIRE_WRITE_RISING_EDGE;
-	uwire_flags |= UWIRE_FREQ_DIV_8;
-	omap_uwire_configure_mode(TSC2101_UWIRE_CS, uwire_flags);
-
 	return 0;
 }
 
@@ -73,7 +49,10 @@ static int h2_panel_enable(struct lcd_pa
 	/* Assert LCD_EN, BKLIGHT_EN pins on LCD panel
 	 * page2, GPIO config reg, GPIO(0,1) to out and asserted
 	 */
-	r = tsc2101_write_reg(2, 0x23, 0xCC00) ? -1 : 0;
+	r = tsc2101_write_sync(h2_panel_dev.tsc2101_dev, 2, 0x23, 0xcc00);
+	if (r < 0)
+		dev_err(&h2_panel_dev.lcd_dev->dev,
+			"failed to enable LCD panel\n");
 
 	return r;
 }
@@ -83,8 +62,9 @@ static void h2_panel_disable(struct lcd_
 	/* Deassert LCD_EN and BKLIGHT_EN pins on LCD panel
 	 * page2, GPIO config reg, GPIO(0,1) to out and deasserted
 	 */
-	if (tsc2101_write_reg(2, 0x23, 0x8800))
-		pr_err("failed to disable LCD panel\n");
+	if (tsc2101_write_sync(h2_panel_dev.tsc2101_dev, 2, 0x23, 0x8800))
+		dev_err(&h2_panel_dev.lcd_dev->dev,
+			"failed to disable LCD panel\n");
 }
 
 static unsigned long h2_panel_get_caps(struct lcd_panel *panel)
@@ -117,6 +97,19 @@ struct lcd_panel h2_panel = {
 
 static int h2_panel_probe(struct platform_device *pdev)
 {
+	struct spi_device *tsc2101;
+
+	tsc2101 = dev_get_drvdata(&pdev->dev);
+	if (tsc2101 == NULL) {
+		dev_err(&pdev->dev, "no platform data\n");
+		return -ENODEV;
+	}
+	if (strncmp(tsc2101->modalias, "tsc2101", 8) != 0) {
+		dev_err(&pdev->dev, "tsc2101 not found\n");
+		return -EINVAL;
+	}
+	h2_panel_dev.lcd_dev = pdev;
+	h2_panel_dev.tsc2101_dev = tsc2101;
 	omapfb_register_panel(&h2_panel);
 	return 0;
 }
Index: linux-omap-2.6/arch/arm/mach-omap1/board-h2.c
===================================================================
--- linux-omap-2.6.orig/arch/arm/mach-omap1/board-h2.c	2007-03-30 14:26:13.000000000 -0400
+++ linux-omap-2.6/arch/arm/mach-omap1/board-h2.c	2007-03-30 14:36:53.000000000 -0400
@@ -305,6 +305,19 @@ struct {
 #define TSC2101_MUX_MCLK_ON	R10_1610_MCLK_ON
 #define TSC2101_MUX_MCLK_OFF	R10_1610_MCLK_OFF
 
+static void h2_lcd_dev_init(struct spi_device *tsc2101)
+{
+	/* The LCD is connected to the GPIO pins of the TSC2101, so
+	 * we have to tie them here. We can also register the LCD driver
+	 * first only here, where we know that the TSC driver is ready.
+	 */
+
+	device_initialize(&h2_lcd_device.dev);
+
+	dev_set_drvdata(&h2_lcd_device.dev, tsc2101);
+	platform_device_add(&h2_lcd_device);
+}
+
 static int h2_tsc2101_init(struct spi_device *spi)
 {
 	int r;
@@ -328,6 +341,8 @@ static int h2_tsc2101_init(struct spi_de
 	omap_cfg_reg(TSC2101_MUX_MCLK_OFF);
 	omap_cfg_reg(N15_1610_UWIRE_CS1);
 
+	h2_lcd_dev_init(spi);
+
 	return 0;
 err:
 	clk_put(h2_tsc2101.mclk);
@@ -410,7 +425,6 @@ static struct platform_device *h2_device
 	&h2_smc91x_device,
 	&h2_irda_device,
 	&h2_kp_device,
-	&h2_lcd_device,
 	&h2_mcbsp1_device,
 };
 

[-- Attachment #3: Type: text/plain, Size: 0 bytes --]



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

* Re: TSC2101/2102
  2007-03-31 12:52                                         ` TSC2101/2102 Eduardo Valentin
@ 2007-03-31 17:01                                           ` Imre Deak
  2007-04-02 13:43                                             ` TSC2101/2102 Eduardo Valentin
  0 siblings, 1 reply; 35+ messages in thread
From: Imre Deak @ 2007-03-31 17:01 UTC (permalink / raw)
  To: Eduardo Valentin; +Cc: Kyungmin Park, Linux OMAP ML

On Sat, Mar 31, 2007 at 08:52:17AM -0400, Eduardo Valentin wrote:
> Hello Tony,
> 
> 
>    This is an updated patch to fix lcd for H2 board. This one is
> applied against
> current linux omap (commit ).
> 
>    The patch is a merge of what was discussed here and what is already 
>    pushed.
> 
> Signed-off-by: Eduardo Valentin <eduardo.valentin@indt.org.br>
> 
> BR,
> 
> Eduardo Valentin
> 
> [...]
>
> Index: linux-omap-2.6/arch/arm/mach-omap1/board-h2.c
> ===================================================================
> --- linux-omap-2.6.orig/arch/arm/mach-omap1/board-h2.c	2007-03-30 14:26:13.000000000 -0400
> +++ linux-omap-2.6/arch/arm/mach-omap1/board-h2.c	2007-03-30 14:36:53.000000000 -0400
> @@ -305,6 +305,19 @@ struct {
>  #define TSC2101_MUX_MCLK_ON	R10_1610_MCLK_ON
>  #define TSC2101_MUX_MCLK_OFF	R10_1610_MCLK_OFF
>  
> +static void h2_lcd_dev_init(struct spi_device *tsc2101)
> +{
> +	/* The LCD is connected to the GPIO pins of the TSC2101, so
> +	 * we have to tie them here. We can also register the LCD driver
> +	 * first only here, where we know that the TSC driver is ready.
> +	 */
> +
> +	device_initialize(&h2_lcd_device.dev);
> +
> +	dev_set_drvdata(&h2_lcd_device.dev, tsc2101);

Is this really necessary? Why isn't it ok to pass it through the
platform_data?

--Imre

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

* Re: TSC2101/2102
  2007-03-31 17:01                                           ` TSC2101/2102 Imre Deak
@ 2007-04-02 13:43                                             ` Eduardo Valentin
  2007-04-02 20:23                                               ` TSC2101/2102 Imre Deak
  0 siblings, 1 reply; 35+ messages in thread
From: Eduardo Valentin @ 2007-04-02 13:43 UTC (permalink / raw)
  To: Imre Deak; +Cc: Kyungmin Park, Linux OMAP ML

Hi Imre Deak,




On 3/31/07, Imre Deak <imre.deak@solidboot.com> wrote:
> On Sat, Mar 31, 2007 at 08:52:17AM -0400, Eduardo Valentin wrote:
> > Hello Tony,
> >
> >
> >    This is an updated patch to fix lcd for H2 board. This one is
> > applied against
> > current linux omap (commit ).
> >
> >    The patch is a merge of what was discussed here and what is already
> >    pushed.
> >
> > Signed-off-by: Eduardo Valentin <eduardo.valentin@indt.org.br>
> >
> > BR,
> >
> > Eduardo Valentin
> >
> > [...]
> >
> > Index: linux-omap-2.6/arch/arm/mach-omap1/board-h2.c
> > ===================================================================
> > --- linux-omap-2.6.orig/arch/arm/mach-omap1/board-h2.c        2007-03-30 14:26:13.000000000 -0400
> > +++ linux-omap-2.6/arch/arm/mach-omap1/board-h2.c     2007-03-30 14:36:53.000000000 -0400
> > @@ -305,6 +305,19 @@ struct {
> >  #define TSC2101_MUX_MCLK_ON  R10_1610_MCLK_ON
> >  #define TSC2101_MUX_MCLK_OFF R10_1610_MCLK_OFF
> >
> > +static void h2_lcd_dev_init(struct spi_device *tsc2101)
> > +{
> > +     /* The LCD is connected to the GPIO pins of the TSC2101, so
> > +      * we have to tie them here. We can also register the LCD driver
> > +      * first only here, where we know that the TSC driver is ready.
> > +      */
> > +
> > +     device_initialize(&h2_lcd_device.dev);
> > +
> > +     dev_set_drvdata(&h2_lcd_device.dev, tsc2101);
>
> Is this really necessary? Why isn't it ok to pass it through the
> platform_data?

   I tested also with
h2_lcd_device.dev.platform_data = tsc2101;

   But the lcd is not initialized using this line. During the board
boot, it prints:
lcd_h2 lcd_h2: no platform data

  I know that it is weird, but that's why I used dev_set_drvdata().


BR,

Eduardo Valentin

>
> --Imre
>
>


-- 
Eduardo Bezerra Valentin

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

* Re: TSC2101/2102
  2007-04-02 13:43                                             ` TSC2101/2102 Eduardo Valentin
@ 2007-04-02 20:23                                               ` Imre Deak
  2007-04-02 20:41                                                 ` TSC2101/2102 Eduardo Valentin
  0 siblings, 1 reply; 35+ messages in thread
From: Imre Deak @ 2007-04-02 20:23 UTC (permalink / raw)
  To: Eduardo Valentin; +Cc: Kyungmin Park, Linux OMAP ML

On Mon, Apr 02, 2007 at 09:43:58AM -0400, Eduardo Valentin wrote:
> Hi Imre Deak,
> 
> 
> 
> 
> On 3/31/07, Imre Deak <imre.deak@solidboot.com> wrote:
> >On Sat, Mar 31, 2007 at 08:52:17AM -0400, Eduardo Valentin wrote:
> >> Hello Tony,
> >>
> >>
> >>    This is an updated patch to fix lcd for H2 board. This one is
> >> applied against
> >> current linux omap (commit ).
> >>
> >>    The patch is a merge of what was discussed here and what is already
> >>    pushed.
> >>
> >> Signed-off-by: Eduardo Valentin <eduardo.valentin@indt.org.br>
> >>
> >> BR,
> >>
> >> Eduardo Valentin
> >>
> >> [...]
> >>
> >> Index: linux-omap-2.6/arch/arm/mach-omap1/board-h2.c
> >> ===================================================================
> >> --- linux-omap-2.6.orig/arch/arm/mach-omap1/board-h2.c        2007-03-30 
> >14:26:13.000000000 -0400
> >> +++ linux-omap-2.6/arch/arm/mach-omap1/board-h2.c     2007-03-30 
> >14:36:53.000000000 -0400
> >> @@ -305,6 +305,19 @@ struct {
> >>  #define TSC2101_MUX_MCLK_ON  R10_1610_MCLK_ON
> >>  #define TSC2101_MUX_MCLK_OFF R10_1610_MCLK_OFF
> >>
> >> +static void h2_lcd_dev_init(struct spi_device *tsc2101)
> >> +{
> >> +     /* The LCD is connected to the GPIO pins of the TSC2101, so
> >> +      * we have to tie them here. We can also register the LCD driver
> >> +      * first only here, where we know that the TSC driver is ready.
> >> +      */
> >> +
> >> +     device_initialize(&h2_lcd_device.dev);
> >> +
> >> +     dev_set_drvdata(&h2_lcd_device.dev, tsc2101);
> >
> >Is this really necessary? Why isn't it ok to pass it through the
> >platform_data?
> 
>   I tested also with
> h2_lcd_device.dev.platform_data = tsc2101;
> 
>   But the lcd is not initialized using this line. During the board
> boot, it prints:
> lcd_h2 lcd_h2: no platform data

Odd. Calling platform_device_add is one bug at least so that should be
fixed as follows:

+static void h2_lcd_dev_init(struct spi_device *tsc2101)
+{
+	/* The LCD is connected to the GPIO pins of the TSC2101, so
+	 * we have to tie them here. We can also register the LCD driver
+	 * first only here, where we know that the TSC driver is ready.
+	 */
+	h2_lcd_device.dev.platform_data = tsc2101;
+
+	platform_device_register(&h2_lcd_device);
+}

> 
>  I know that it is weird, but that's why I used dev_set_drvdata().

I think it's not a good thing to do, since the related field is for driver
private data.

--Imre

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

* Re: TSC2101/2102
  2007-04-02 20:23                                               ` TSC2101/2102 Imre Deak
@ 2007-04-02 20:41                                                 ` Eduardo Valentin
  2007-04-03 11:22                                                   ` TSC2101/2102 Eduardo Valentin
  0 siblings, 1 reply; 35+ messages in thread
From: Eduardo Valentin @ 2007-04-02 20:41 UTC (permalink / raw)
  To: Imre Deak; +Cc: Kyungmin Park, Linux OMAP ML

Hello Imre

On 4/2/07, Imre Deak <imre.deak@solidboot.com> wrote:
> On Mon, Apr 02, 2007 at 09:43:58AM -0400, Eduardo Valentin wrote:
> > Hi Imre Deak,
> >
> >
> >
> >
> > On 3/31/07, Imre Deak <imre.deak@solidboot.com> wrote:
> > >On Sat, Mar 31, 2007 at 08:52:17AM -0400, Eduardo Valentin wrote:
> > >> Hello Tony,
> > >>
> > >>
> > >>    This is an updated patch to fix lcd for H2 board. This one is
> > >> applied against
> > >> current linux omap (commit ).
> > >>
> > >>    The patch is a merge of what was discussed here and what is already
> > >>    pushed.
> > >>
> > >> Signed-off-by: Eduardo Valentin <eduardo.valentin@indt.org.br>
> > >>
> > >> BR,
> > >>
> > >> Eduardo Valentin
> > >>
> > >> [...]
> > >>
> > >> Index: linux-omap-2.6/arch/arm/mach-omap1/board-h2.c
> > >> ===================================================================
> > >> --- linux-omap-2.6.orig/arch/arm/mach-omap1/board-h2.c        2007-03-30
> > >14:26:13.000000000 -0400
> > >> +++ linux-omap-2.6/arch/arm/mach-omap1/board-h2.c     2007-03-30
> > >14:36:53.000000000 -0400
> > >> @@ -305,6 +305,19 @@ struct {
> > >>  #define TSC2101_MUX_MCLK_ON  R10_1610_MCLK_ON
> > >>  #define TSC2101_MUX_MCLK_OFF R10_1610_MCLK_OFF
> > >>
> > >> +static void h2_lcd_dev_init(struct spi_device *tsc2101)
> > >> +{
> > >> +     /* The LCD is connected to the GPIO pins of the TSC2101, so
> > >> +      * we have to tie them here. We can also register the LCD driver
> > >> +      * first only here, where we know that the TSC driver is ready.
> > >> +      */
> > >> +
> > >> +     device_initialize(&h2_lcd_device.dev);
> > >> +
> > >> +     dev_set_drvdata(&h2_lcd_device.dev, tsc2101);
> > >
> > >Is this really necessary? Why isn't it ok to pass it through the
> > >platform_data?
> >
> >   I tested also with
> > h2_lcd_device.dev.platform_data = tsc2101;
> >
> >   But the lcd is not initialized using this line. During the board
> > boot, it prints:
> > lcd_h2 lcd_h2: no platform data
>
> Odd. Calling platform_device_add is one bug at least so that should be
> fixed as follows:
>
> +static void h2_lcd_dev_init(struct spi_device *tsc2101)
> +{
> +       /* The LCD is connected to the GPIO pins of the TSC2101, so
> +        * we have to tie them here. We can also register the LCD driver
> +        * first only here, where we know that the TSC driver is ready.
> +        */
> +       h2_lcd_device.dev.platform_data = tsc2101;
> +
> +       platform_device_register(&h2_lcd_device);
> +}
>
> >
> >  I know that it is weird, but that's why I used dev_set_drvdata().
>
> I think it's not a good thing to do, since the related field is for driver
> private data.

Yes, I agree with you. It is odd ! :) But with this sequence:

	h2_lcd_device.dev.platform_data = tsc2101;
	platform_device_register(&h2_lcd_device);

The lcd does not initialize properly. During the boot process, it prints:

lcd_h2 lcd_h2: no platform data
tsc2101 spi2.1: initialized

and the lcd device is not powered on.

This is what I'm currently getting here on my H2. Maybe someone would
test this patch also :)

Cheers,


Eduardo Valentin

>
> --Imre
>
>


-- 
Eduardo Bezerra Valentin

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

* Re: TSC2101/2102
  2007-04-02 20:41                                                 ` TSC2101/2102 Eduardo Valentin
@ 2007-04-03 11:22                                                   ` Eduardo Valentin
  2007-04-03 14:36                                                     ` TSC2101/2102 Imre Deak
  0 siblings, 1 reply; 35+ messages in thread
From: Eduardo Valentin @ 2007-04-03 11:22 UTC (permalink / raw)
  To: Imre Deak; +Cc: Kyungmin Park, Linux OMAP ML

Hello again Imre,


   I didn't understand properly your question. My bad. Sorry.
   I used set_drvdata because it is used into lcd_h2.c (accordingly to
my previous patch):
@@ -117,6 +97,19 @@ struct lcd_panel h2_panel = {

 static int h2_panel_probe(struct platform_device *pdev)
 {
+	struct spi_device *tsc2101;
+
+	tsc2101 = dev_get_drvdata(&pdev->dev);
+	if (tsc2101 == NULL) {
+		dev_err(&pdev->dev, "no platform data\n");
+		return -ENODEV;
+	}

   Of course, it is clear enough that this dev_err message is wrong.
It must be "no driver data". My bad again. However, why do you suggest
use platform_data instead of driver_data?


Cheers,


Eduardo Valentin

On 4/2/07, Eduardo Valentin <edubezval@gmail.com> wrote:
> Hello Imre
>
> On 4/2/07, Imre Deak <imre.deak@solidboot.com> wrote:
> > On Mon, Apr 02, 2007 at 09:43:58AM -0400, Eduardo Valentin wrote:
> > > Hi Imre Deak,
> > >
> > >
> > >
> > >
> > > On 3/31/07, Imre Deak <imre.deak@solidboot.com> wrote:
> > > >On Sat, Mar 31, 2007 at 08:52:17AM -0400, Eduardo Valentin wrote:
> > > >> Hello Tony,
> > > >>
> > > >>
> > > >>    This is an updated patch to fix lcd for H2 board. This one is
> > > >> applied against
> > > >> current linux omap (commit ).
> > > >>
> > > >>    The patch is a merge of what was discussed here and what is already
> > > >>    pushed.
> > > >>
> > > >> Signed-off-by: Eduardo Valentin <eduardo.valentin@indt.org.br>
> > > >>
> > > >> BR,
> > > >>
> > > >> Eduardo Valentin
> > > >>
> > > >> [...]
> > > >>
> > > >> Index: linux-omap-2.6/arch/arm/mach-omap1/board-h2.c
> > > >> ===================================================================
> > > >> --- linux-omap-2.6.orig/arch/arm/mach-omap1/board-h2.c        2007-03-30
> > > >14:26:13.000000000 -0400
> > > >> +++ linux-omap-2.6/arch/arm/mach-omap1/board-h2.c     2007-03-30
> > > >14:36:53.000000000 -0400
> > > >> @@ -305,6 +305,19 @@ struct {
> > > >>  #define TSC2101_MUX_MCLK_ON  R10_1610_MCLK_ON
> > > >>  #define TSC2101_MUX_MCLK_OFF R10_1610_MCLK_OFF
> > > >>
> > > >> +static void h2_lcd_dev_init(struct spi_device *tsc2101)
> > > >> +{
> > > >> +     /* The LCD is connected to the GPIO pins of the TSC2101, so
> > > >> +      * we have to tie them here. We can also register the LCD driver
> > > >> +      * first only here, where we know that the TSC driver is ready.
> > > >> +      */
> > > >> +
> > > >> +     device_initialize(&h2_lcd_device.dev);
> > > >> +
> > > >> +     dev_set_drvdata(&h2_lcd_device.dev, tsc2101);
> > > >
> > > >Is this really necessary? Why isn't it ok to pass it through the
> > > >platform_data?
> > >
> > >   I tested also with
> > > h2_lcd_device.dev.platform_data = tsc2101;
> > >
> > >   But the lcd is not initialized using this line. During the board
> > > boot, it prints:
> > > lcd_h2 lcd_h2: no platform data
> >
> > Odd. Calling platform_device_add is one bug at least so that should be
> > fixed as follows:
> >
> > +static void h2_lcd_dev_init(struct spi_device *tsc2101)
> > +{
> > +       /* The LCD is connected to the GPIO pins of the TSC2101, so
> > +        * we have to tie them here. We can also register the LCD driver
> > +        * first only here, where we know that the TSC driver is ready.
> > +        */
> > +       h2_lcd_device.dev.platform_data = tsc2101;
> > +
> > +       platform_device_register(&h2_lcd_device);
> > +}
> >
> > >
> > >  I know that it is weird, but that's why I used dev_set_drvdata().
> >
> > I think it's not a good thing to do, since the related field is for driver
> > private data.
>
> Yes, I agree with you. It is odd ! :) But with this sequence:
>
>         h2_lcd_device.dev.platform_data = tsc2101;
>         platform_device_register(&h2_lcd_device);
>
> The lcd does not initialize properly. During the boot process, it prints:
>
> lcd_h2 lcd_h2: no platform data
> tsc2101 spi2.1: initialized
>
> and the lcd device is not powered on.
>
> This is what I'm currently getting here on my H2. Maybe someone would
> test this patch also :)
>
> Cheers,
>
>
> Eduardo Valentin
>
> >
> > --Imre
> >
> >
>
>
> --
> Eduardo Bezerra Valentin
>


-- 
Eduardo Bezerra Valentin

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

* Re: TSC2101/2102
  2007-04-03 11:22                                                   ` TSC2101/2102 Eduardo Valentin
@ 2007-04-03 14:36                                                     ` Imre Deak
  2007-04-03 15:10                                                       ` TSC2101/2102 Eduardo Valentin
  0 siblings, 1 reply; 35+ messages in thread
From: Imre Deak @ 2007-04-03 14:36 UTC (permalink / raw)
  To: Eduardo Valentin; +Cc: Kyungmin Park, Linux OMAP ML

Hi,

On Tue, Apr 03, 2007 at 07:22:57AM -0400, Eduardo Valentin wrote:
> Hello again Imre,
> 
> 
>   I didn't understand properly your question. My bad. Sorry.
>   I used set_drvdata because it is used into lcd_h2.c (accordingly to
> my previous patch):
> @@ -117,6 +97,19 @@ struct lcd_panel h2_panel = {
> 
> static int h2_panel_probe(struct platform_device *pdev)
> {
> +	struct spi_device *tsc2101;
> +
> +	tsc2101 = dev_get_drvdata(&pdev->dev);
> +	if (tsc2101 == NULL) {
> +		dev_err(&pdev->dev, "no platform data\n");
> +		return -ENODEV;
> +	}
> 
>   Of course, it is clear enough that this dev_err message is wrong.
> It must be "no driver data". My bad again. However, why do you suggest
> use platform_data instead of driver_data?

That's the standard way platforms pass init data to the driver. The
driver can then use the driver_data field for it's own purpose.

But more important would be to know why platform_data gets zero'd, since
the device core is not touching it. A workaround you're proposing might
just delay some other problem..

--Imre

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

* Re: TSC2101/2102
  2007-04-03 14:36                                                     ` TSC2101/2102 Imre Deak
@ 2007-04-03 15:10                                                       ` Eduardo Valentin
  2007-04-03 19:23                                                         ` TSC2101/2102 Tony Lindgren
  0 siblings, 1 reply; 35+ messages in thread
From: Eduardo Valentin @ 2007-04-03 15:10 UTC (permalink / raw)
  To: Imre Deak; +Cc: Kyungmin Park, Linux OMAP ML

[-- Attachment #1: Type: text/plain, Size: 1594 bytes --]

Hi Imre,


   All right, I agreed with you :). I'm re-sending now an updated
patch. Now it uses  platform_data field to pass the spi_device to lcd.
The lcd now is working here. It also fix the omap_h2_1610_defconfig
file to include CONFIG_SPI_TSC2101 option.

   I applied/tested it against commit 6cb703eea609cb60448ce71740495c24ac0e9646.

Cheers,

On 4/3/07, Imre Deak <imre.deak@solidboot.com> wrote:
> Hi,
>
> On Tue, Apr 03, 2007 at 07:22:57AM -0400, Eduardo Valentin wrote:
> > Hello again Imre,
> >
> >
> >   I didn't understand properly your question. My bad. Sorry.
> >   I used set_drvdata because it is used into lcd_h2.c (accordingly to
> > my previous patch):
> > @@ -117,6 +97,19 @@ struct lcd_panel h2_panel = {
> >
> > static int h2_panel_probe(struct platform_device *pdev)
> > {
> > +     struct spi_device *tsc2101;
> > +
> > +     tsc2101 = dev_get_drvdata(&pdev->dev);
> > +     if (tsc2101 == NULL) {
> > +             dev_err(&pdev->dev, "no platform data\n");
> > +             return -ENODEV;
> > +     }
> >
> >   Of course, it is clear enough that this dev_err message is wrong.
> > It must be "no driver data". My bad again. However, why do you suggest
> > use platform_data instead of driver_data?
>
> That's the standard way platforms pass init data to the driver. The
> driver can then use the driver_data field for it's own purpose.
>
> But more important would be to know why platform_data gets zero'd, since
> the device core is not touching it. A workaround you're proposing might
> just delay some other problem..
>
> --Imre
>


-- 
Eduardo Bezerra Valentin

[-- Attachment #2: patch_fix_h2_lcd.diff --]
[-- Type: text/x-patch, Size: 4754 bytes --]

This is an updated patch to fix lcd for H2 board. It uses platform_data field
to pass spi_device to lcd driver.

Signed-off-by: Eduardo Valentin <eduardo.valentin@indt.org.br>

Index: linux-omap-2.6/drivers/video/omap/lcd_h2.c
===================================================================
--- linux-omap-2.6.orig/drivers/video/omap/lcd_h2.c	2007-04-03 10:53:43.000000000 -0400
+++ linux-omap-2.6/drivers/video/omap/lcd_h2.c	2007-04-03 10:55:56.000000000 -0400
@@ -23,42 +23,18 @@
 
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/spi/tsc2101.h>
 
 #include <asm/arch/mux.h>
 #include <asm/arch/omapfb.h>
 
-#include "../drivers/ssi/omap-uwire.h"
-
-#define MODULE_NAME		"omapfb-lcd_h2"
-#define TSC2101_UWIRE_CS	1
-
-#define pr_err(fmt, args...) printk(KERN_ERR MODULE_NAME ": " fmt, ## args)
-
-static int tsc2101_write_reg(int page, int reg, u16 data)
-{
-	u16	cmd;
-	int	r;
-
-	cmd = ((page & 3) << 11) | ((reg & 0x3f) << 5);
-	if (omap_uwire_data_transfer(TSC2101_UWIRE_CS, cmd, 16, 0, NULL, 1))
-		r = -1;
-	else
-		r = omap_uwire_data_transfer(TSC2101_UWIRE_CS, data, 16, 0,
-					     NULL, 0);
-
-	return r;
-}
+static struct {
+	struct platform_device	*lcd_dev;
+	struct spi_device	*tsc2101_dev;
+} h2_panel_dev;
 
 static int h2_panel_init(struct lcd_panel *panel, struct omapfb_device *fbdev)
 {
-	unsigned long uwire_flags;
-
-	 /* Configure N15 pin to be uWire CS1 */
-	omap_cfg_reg(N15_1610_UWIRE_CS1);
-	uwire_flags = UWIRE_READ_RISING_EDGE | UWIRE_WRITE_RISING_EDGE;
-	uwire_flags |= UWIRE_FREQ_DIV_8;
-	omap_uwire_configure_mode(TSC2101_UWIRE_CS, uwire_flags);
-
 	return 0;
 }
 
@@ -73,7 +49,10 @@ static int h2_panel_enable(struct lcd_pa
 	/* Assert LCD_EN, BKLIGHT_EN pins on LCD panel
 	 * page2, GPIO config reg, GPIO(0,1) to out and asserted
 	 */
-	r = tsc2101_write_reg(2, 0x23, 0xCC00) ? -1 : 0;
+	r = tsc2101_write_sync(h2_panel_dev.tsc2101_dev, 2, 0x23, 0xcc00);
+	if (r < 0)
+		dev_err(&h2_panel_dev.lcd_dev->dev,
+			"failed to enable LCD panel\n");
 
 	return r;
 }
@@ -83,8 +62,9 @@ static void h2_panel_disable(struct lcd_
 	/* Deassert LCD_EN and BKLIGHT_EN pins on LCD panel
 	 * page2, GPIO config reg, GPIO(0,1) to out and deasserted
 	 */
-	if (tsc2101_write_reg(2, 0x23, 0x8800))
-		pr_err("failed to disable LCD panel\n");
+	if (tsc2101_write_sync(h2_panel_dev.tsc2101_dev, 2, 0x23, 0x8800))
+		dev_err(&h2_panel_dev.lcd_dev->dev,
+			"failed to disable LCD panel\n");
 }
 
 static unsigned long h2_panel_get_caps(struct lcd_panel *panel)
@@ -117,6 +97,19 @@ struct lcd_panel h2_panel = {
 
 static int h2_panel_probe(struct platform_device *pdev)
 {
+	struct spi_device *tsc2101;
+
+	tsc2101 = pdev->dev.platform_data;
+	if (tsc2101 == NULL) {
+		dev_err(&pdev->dev, "no platform data\n");
+		return -ENODEV;
+	}
+	if (strncmp(tsc2101->modalias, "tsc2101", 8) != 0) {
+		dev_err(&pdev->dev, "tsc2101 not found\n");
+		return -EINVAL;
+	}
+	h2_panel_dev.lcd_dev = pdev;
+	h2_panel_dev.tsc2101_dev = tsc2101;
 	omapfb_register_panel(&h2_panel);
 	return 0;
 }
Index: linux-omap-2.6/arch/arm/mach-omap1/board-h2.c
===================================================================
--- linux-omap-2.6.orig/arch/arm/mach-omap1/board-h2.c	2007-04-03 10:53:43.000000000 -0400
+++ linux-omap-2.6/arch/arm/mach-omap1/board-h2.c	2007-04-03 10:55:56.000000000 -0400
@@ -305,6 +305,17 @@ struct {
 #define TSC2101_MUX_MCLK_ON	R10_1610_MCLK_ON
 #define TSC2101_MUX_MCLK_OFF	R10_1610_MCLK_OFF
 
+static void h2_lcd_dev_init(struct spi_device *tsc2101)
+{
+	/* The LCD is connected to the GPIO pins of the TSC2101, so
+	 * we have to tie them here. We can also register the LCD driver
+	 * first only here, where we know that the TSC driver is ready.
+	 */
+
+	h2_lcd_device.dev.platform_data = tsc2101;
+	platform_device_register(&h2_lcd_device);
+}
+
 static int h2_tsc2101_init(struct spi_device *spi)
 {
 	int r;
@@ -328,6 +339,8 @@ static int h2_tsc2101_init(struct spi_de
 	omap_cfg_reg(TSC2101_MUX_MCLK_OFF);
 	omap_cfg_reg(N15_1610_UWIRE_CS1);
 
+	h2_lcd_dev_init(spi);
+
 	return 0;
 err:
 	clk_put(h2_tsc2101.mclk);
@@ -410,7 +423,6 @@ static struct platform_device *h2_device
 	&h2_smc91x_device,
 	&h2_irda_device,
 	&h2_kp_device,
-	&h2_lcd_device,
 	&h2_mcbsp1_device,
 };
 
Index: linux-omap-2.6/arch/arm/configs/omap_h2_1610_defconfig
===================================================================
--- linux-omap-2.6.orig/arch/arm/configs/omap_h2_1610_defconfig	2007-04-03 11:00:46.000000000 -0400
+++ linux-omap-2.6/arch/arm/configs/omap_h2_1610_defconfig	2007-04-03 11:01:27.000000000 -0400
@@ -762,7 +762,7 @@ CONFIG_SPI_OMAP_UWIRE=y
 #
 # SPI Protocol Masters
 #
-CONFIG_TSC2101=y
+CONFIG_SPI_TSC2101=y
 # CONFIG_TSC2102 is not set
 # CONFIG_SPI_AT25 is not set
 

[-- Attachment #3: Type: text/plain, Size: 0 bytes --]



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

* Re: TSC2101/2102
  2007-04-03 15:10                                                       ` TSC2101/2102 Eduardo Valentin
@ 2007-04-03 19:23                                                         ` Tony Lindgren
  0 siblings, 0 replies; 35+ messages in thread
From: Tony Lindgren @ 2007-04-03 19:23 UTC (permalink / raw)
  To: Eduardo Valentin; +Cc: Kyungmin Park, Linux OMAP ML

* Eduardo Valentin <edubezval@gmail.com> [070403 11:10]:
> Hi Imre,
> 
> 
>   All right, I agreed with you :). I'm re-sending now an updated
> patch. Now it uses  platform_data field to pass the spi_device to lcd.
> The lcd now is working here. It also fix the omap_h2_1610_defconfig
> file to include CONFIG_SPI_TSC2101 option.

I'll merge the drivers/video/omap/ changes to Imre's add framebuffer
patch. And I'll push the board init changes to omap-upstream.
The h2 defconfig should end up in the master branch.

Subject to comments from Imre, of course.

Regards,

Tony

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

end of thread, other threads:[~2007-04-03 19:23 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-09 14:06 TSC2101/2102 Imre Deak
2007-03-09 14:23 ` TSC2101/2102 andrzej zaborowski
2007-03-14 13:21   ` TSC2101/2102 Nishanth Menon
2007-03-14 17:09     ` TSC2101/2102 Imre Deak
2007-03-14 20:35       ` TSC2101/2102 Dirk Behme
2007-03-15  1:18       ` TSC2101/2102 Kyungmin Park
2007-03-15 10:23         ` TSC2101/2102 Imre Deak
2007-03-15 14:23           ` Regarding use of DirectFB Raja Mallik
2007-03-15 17:09             ` Cliff Brake
2007-03-16  0:28           ` TSC2101/2102 Kyungmin Park
2007-03-16  7:41             ` TSC2101/2102 Imre Deak
2007-03-16  8:05               ` TSC2101/2102 Kyungmin Park
2007-03-16  9:49                 ` TSC2101/2102 Imre Deak
2007-03-19  2:02                   ` TSC2101/2102 Kyungmin Park
2007-03-19  7:37                     ` TSC2101/2102 Jarkko Nikula
2007-03-19  8:04                       ` TSC2101/2102 Kyungmin Park
2007-03-19  8:37                         ` TSC2101/2102 Jarkko Nikula
2007-03-19 19:22                           ` TSC2101/2102 tony
2007-03-20  1:46                           ` TSC2101/2102 Kyungmin Park
2007-03-20 13:27                             ` TSC2101/2102 tony
2007-03-20 13:54                               ` TSC2101/2102 Jarkko Nikula
2007-03-20 15:38                                 ` TSC2101/2102 Tony Lindgren
2007-03-21 19:24                                   ` TSC2101/2102 Eduardo Valentin
2007-03-22  6:48                                     ` TSC2101/2102 Jarkko Nikula
2007-03-30 18:49                                       ` TSC2101/2102 Tony Lindgren
2007-03-31 12:52                                         ` TSC2101/2102 Eduardo Valentin
2007-03-31 17:01                                           ` TSC2101/2102 Imre Deak
2007-04-02 13:43                                             ` TSC2101/2102 Eduardo Valentin
2007-04-02 20:23                                               ` TSC2101/2102 Imre Deak
2007-04-02 20:41                                                 ` TSC2101/2102 Eduardo Valentin
2007-04-03 11:22                                                   ` TSC2101/2102 Eduardo Valentin
2007-04-03 14:36                                                     ` TSC2101/2102 Imre Deak
2007-04-03 15:10                                                       ` TSC2101/2102 Eduardo Valentin
2007-04-03 19:23                                                         ` TSC2101/2102 Tony Lindgren
2007-03-29 20:26       ` TSC2101/2102 Tony Lindgren

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.