]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
Touch Screen: support on OMAP 3430
authorGirish <girishsg@ti.com>
Fri, 2 Nov 2007 15:24:55 +0000 (20:54 +0530)
committerTony Lindgren <tony@atomide.com>
Fri, 16 Nov 2007 22:24:35 +0000 (14:24 -0800)
This patch supports Touchscreen on 3430
Signed-off-by: Girish S G <girishsg@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
arch/arm/configs/omap_3430sdp_defconfig
arch/arm/mach-omap2/board-3430sdp.c
drivers/input/touchscreen/ads7846.c
include/asm-arm/arch-omap/board-3430sdp.h
include/asm-arm/arch-omap/gpio.h
include/linux/spi/ads7846.h

index 1fb87b5d38e8b3a7d91edae6439b7c797488dad7..4e460b72a288c496cd9908c36bde7f2afac7853c 100644 (file)
@@ -549,7 +549,8 @@ CONFIG_INPUT_KEYBOARD=y
 # CONFIG_INPUT_MOUSE is not set
 # CONFIG_INPUT_JOYSTICK is not set
 # CONFIG_INPUT_TABLET is not set
-# CONFIG_INPUT_TOUCHSCREEN is not set
+CONFIG_INPUT_TOUCHSCREEN=y
+# CONFIG_TOUCHSCREEN_ADS7846 is not set
 # CONFIG_INPUT_MISC is not set
 
 #
index 50f05ca7dbbaf46521696fe292a2072095ea6b83..d8f7878882eabe3873bad91ea2c27ab04c08e3b7 100644 (file)
@@ -21,6 +21,8 @@
 #include <linux/workqueue.h>
 #include <linux/err.h>
 #include <linux/clk.h>
+#include <linux/spi/spi.h>
+#include <linux/spi/ads7846.h>
 
 #include <asm/hardware.h>
 #include <asm/mach-types.h>
@@ -28,6 +30,8 @@
 #include <asm/mach/map.h>
 #include <asm/mach/flash.h>
 
+#include <asm/arch/twl4030.h>
+#include <asm/arch/mcspi.h>
 #include <asm/arch/gpio.h>
 #include <asm/arch/mux.h>
 #include <asm/arch/board.h>
@@ -41,6 +45,9 @@
 #define        SDP3430_FLASH_CS        0
 #define        SDP3430_SMC91X_CS       3
 
+#define ENABLE_VAUX3_DEDICATED 0x03
+#define ENABLE_VAUX3_DEV_GRP   0x20
+
 static struct mtd_partition sdp3430_partitions[] = {
        /* bootloader (U-Boot, etc) in first sector */
        {
@@ -115,6 +122,86 @@ static struct platform_device sdp3430_smc91x_device = {
        .resource       = sdp3430_smc91x_resources,
 };
 
+/**
+ * @brief ads7846_dev_init : Requests & sets GPIO line for pen-irq
+ *
+ * @return - void. If request gpio fails then Flag KERN_ERR.
+ */
+static void ads7846_dev_init(void)
+{
+       if (omap_request_gpio(TS_GPIO) < 0) {
+               printk(KERN_ERR "can't get ads746 pen down GPIO\n");
+               return;
+       }
+
+       omap_set_gpio_direction(TS_GPIO, 1);
+
+       omap_set_gpio_debounce(TS_GPIO, 1);
+       omap_set_gpio_debounce_time(TS_GPIO, 0xa);
+}
+
+static int ads7846_get_pendown_state(void)
+{
+       return !omap_get_gpio_datain(TS_GPIO);
+}
+
+/*
+ * This enable(1)/disable(0) the voltage for TS: uses twl4030 calls
+ */
+static int ads7846_vaux_control(int vaux_cntrl)
+{
+       int ret = 0;
+
+#ifdef CONFIG_TWL4030_CORE
+       /* check for return value of ldo_use: if success it returns 0 */
+       if (vaux_cntrl == VAUX_ENABLE) {
+               if (ret != twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
+                       ENABLE_VAUX3_DEDICATED, TWL4030_VAUX3_DEDICATED))
+                       return -EIO;
+               if (ret != twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
+                       ENABLE_VAUX3_DEV_GRP, TWL4030_VAUX3_DEV_GRP))
+                       return -EIO;
+       } else if (vaux_cntrl == VAUX_DISABLE) {
+               if (ret != twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
+                       0x00, TWL4030_VAUX3_DEDICATED))
+                       return -EIO;
+               if (ret != twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
+                       0x00, TWL4030_VAUX3_DEV_GRP))
+                       return -EIO;
+       }
+#else
+       ret = -EIO;
+#endif
+       return ret;
+}
+
+static struct ads7846_platform_data tsc2046_config __initdata = {
+       .get_pendown_state      = ads7846_get_pendown_state,
+       .keep_vref_on           = 1,
+       .vaux_control           = ads7846_vaux_control,
+};
+
+
+static struct omap2_mcspi_device_config tsc2046_mcspi_config = {
+       .turbo_mode     = 0,
+       .single_channel = 1,  /* 0: slave, 1: master */
+};
+
+static struct spi_board_info sdp3430_spi_board_info[] __initdata = {
+       [0] = {
+               /*
+                * TSC2046 operates at a max freqency of 2MHz, so
+                * operate slightly below at 1.5MHz
+                */
+               .modalias               = "ads7846",
+               .bus_num                = 1,
+               .chip_select            = 0,
+               .max_speed_hz           = 1500000,
+               .controller_data        = &tsc2046_mcspi_config,
+               .irq                    = OMAP_GPIO_IRQ(TS_GPIO),
+               .platform_data          = &tsc2046_config,
+       },
+};
 static struct platform_device *sdp3430_devices[] __initdata = {
        &sdp3430_smc91x_device,
        &sdp3430_flash_device,
@@ -180,6 +267,9 @@ static void __init omap_3430sdp_init(void)
        platform_add_devices(sdp3430_devices, ARRAY_SIZE(sdp3430_devices));
        omap_board_config = sdp3430_config;
        omap_board_config_size = ARRAY_SIZE(sdp3430_config);
+       spi_register_board_info(sdp3430_spi_board_info,
+                               ARRAY_SIZE(sdp3430_spi_board_info));
+       ads7846_dev_init();
        omap_serial_init();
 }
 
index f59aecf5ec1565fe4959308edc8cc034c3a0a9a3..e7c50e6e7e361ec3695f4223754dcf264b5f883f 100644 (file)
@@ -838,6 +838,15 @@ static int __devinit ads7846_probe(struct spi_device *spi)
                return -ENODEV;
        }
 
+       /* enable voltage */
+       if (pdata->vaux_control != NULL) {
+               err = pdata->vaux_control(VAUX_ENABLE);
+               if (err != 0) {
+                       dev_dbg(&spi->dev, "TS vaux enable failed\n");
+                       return err;
+               }
+       }
+
        /* don't exceed max specified sample rate */
        if (spi->max_speed_hz > (125000 * SAMPLE_BITS)) {
                dev_dbg(&spi->dev, "f(sample) %d KHz?\n",
index fa919c05defdb87567e59e5a6c284b8c40fc2b1a..4a0247da9a826fe7d7339388d67d4d308e1118b3 100644 (file)
 #define OMAP34XX_ETHR_START            DEBUG_BASE
 #define OMAP34XX_ETHR_GPIO_IRQ         29
 
+/*
+ * GPIO used for TSC2046, TI's Touchscreen controller
+ */
+#ifdef CONFIG_OMAP3430_ES2
+#define TS_GPIO                2
+#else
+#define TS_GPIO                3
+#endif
+
 /* NAND */
 /* IMPORTANT NOTE ON MAPPING
  * 3430SDP - 343X
index 33ca8a76836f1d350257ad88c1376e8b5e22cfaf..f926b6b1e2c97938606d7f413c4cb695bc67e604 100644 (file)
@@ -80,7 +80,7 @@ extern int omap_get_gpio_datain(int gpio);
 extern void omap2_gpio_prepare_for_retention(void);
 extern void omap2_gpio_resume_after_retention(void);
 
-#ifdef CONFIG_ARCH_OMAP24XX
+#if defined(CONFIG_ARCH_OMAP24XX) || defined(CONFIG_ARCH_OMAP34XX)
 extern void omap_set_gpio_debounce(int gpio, int enable);
 extern void omap_set_gpio_debounce_time(int gpio, int enable);
 #endif
index 334d3141162966a4daacc7233d4bdf843b4d4e6a..eeed74de9b63fa50017e4fdc2aa2dcc4d4cdcf4d 100644 (file)
@@ -47,5 +47,10 @@ struct ads7846_platform_data {
                                 void **filter_data);
        int     (*filter)       (void *filter_data, int data_idx, int *val);
        void    (*filter_cleanup)(void *filter_data);
+
+       /* controls enabling/disabling*/
+       int     (*vaux_control)(int vaux_cntrl);
+#define VAUX_ENABLE    1
+#define VAUX_DISABLE   0
 };